diff options
254 files changed, 0 insertions, 203191 deletions
diff --git a/target/linux/generic-2.4/config-default b/target/linux/generic-2.4/config-default deleted file mode 100644 index c5348ca..0000000 --- a/target/linux/generic-2.4/config-default +++ /dev/null @@ -1,777 +0,0 @@ -# CONFIG_64BIT_PHYS_ADDR is not set -# CONFIG_ACENIC is not set -# CONFIG_ACER_PICA_61 is not set -# CONFIG_ACORN_PARTITION is not set -# CONFIG_ADFS_FS is not set -# CONFIG_ADFS_FS_RW is not set -# CONFIG_AFFS_FS is not set -# CONFIG_AGP is not set -# CONFIG_AIRONET4500 is not set -# CONFIG_AIRONET4500_NONCS is not set -# CONFIG_AIRONET4500_PROC is not set -# CONFIG_AMD_PM768 is not set -# CONFIG_AMIGA_PARTITION is not set -# CONFIG_APPLICOM is not set -# CONFIG_ARCNET is not set -# CONFIG_ARLAN is not set -# CONFIG_ARPD is not set -# CONFIG_ATALK is not set -# CONFIG_ATARI_PARTITION is not set -# CONFIG_AUTOFS4_FS is not set -# CONFIG_AUTOFS_FS is not set -# CONFIG_BAGET_MIPS is not set -# CONFIG_BEFS_DEBUG is not set -# CONFIG_BEFS_FS is not set -# CONFIG_BFS_FS is not set -# CONFIG_BINFMT_AOUT is not set -# CONFIG_BINFMT_ELF32 is not set -# CONFIG_BINFMT_ELF_AOUT is not set -CONFIG_BINFMT_ELF=y -# CONFIG_BINFMT_MISC is not set -# CONFIG_BLK_CPQ_CISS_DA is not set -# CONFIG_BLK_CPQ_DA is not set -# CONFIG_BLK_DEV_DAC960 is not set -# CONFIG_BLK_DEV_FD is not set -# CONFIG_BLK_DEV_HD is not set -# CONFIG_BLK_DEV_INITRD is not set -CONFIG_BLK_DEV_LOOP=m -# CONFIG_BLK_DEV_LVM is not set -# CONFIG_BLK_DEV_MD is not set -CONFIG_BLK_DEV_NBD=m -# CONFIG_BLK_DEV_RAM is not set -CONFIG_BLK_DEV_SD=m -# CONFIG_BLK_DEV_SR is not set -# CONFIG_BLK_DEV_SX8 is not set -# CONFIG_BLK_DEV_UMEM is not set -# CONFIG_BLK_DEV_XD is not set -# CONFIG_BLK_STATS is not set -# CONFIG_BONDING is not set -CONFIG_BRIDGE=y -# CONFIG_BSD_DISKLABEL is not set -# CONFIG_BSD_PROCESS_ACCT is not set -# CONFIG_BUILD_ELF64 is not set -# CONFIG_BUSMOUSE is not set -# CONFIG_CASIO_E55 is not set -# CONFIG_CHR_DEV_OSST is not set -CONFIG_CHR_DEV_SG=m -# CONFIG_CHR_DEV_ST is not set -CONFIG_CIFS=m -CONFIG_CIFS_POSIX=y -# CONFIG_CIFS_STATS is not set -# CONFIG_CISS_MONITOR_THREAD is not set -# CONFIG_CISS_SCSI_TAPE is not set -# CONFIG_CODA_FS is not set -# CONFIG_COGENT_CSB250 is not set -# CONFIG_CPU_ADVANCED is not set -# CONFIG_CPU_HAS_LLDSCD is not set -CONFIG_CPU_HAS_LLSC=y -CONFIG_CPU_HAS_PREFETCH=y -CONFIG_CPU_HAS_SYNC=y -# CONFIG_CPU_HAS_WB is not set -CONFIG_CPU_LITTLE_ENDIAN=y -CONFIG_CPU_MIPS32=y -# CONFIG_CPU_MIPS64 is not set -# CONFIG_CPU_NEVADA is not set -# CONFIG_CPU_R10000 is not set -# CONFIG_CPU_R3000 is not set -# CONFIG_CPU_R4300 is not set -# CONFIG_CPU_R4X00 is not set -# CONFIG_CPU_R5000 is not set -# CONFIG_CPU_R5432 is not set -# CONFIG_CPU_R6000 is not set -# CONFIG_CPU_R8000 is not set -# CONFIG_CPU_RM7000 is not set -# CONFIG_CPU_RM9000 is not set -# CONFIG_CPU_SB1 is not set -# CONFIG_CPU_TX39XX is not set -# CONFIG_CPU_TX49XX is not set -# CONFIG_CPU_VR41XX is not set -# CONFIG_CRAMFS is not set -CONFIG_CROSSCOMPILE=y -CONFIG_CRYPTO_AES=m -CONFIG_CRYPTO_ANUBIS=m -CONFIG_CRYPTO_ARC4=m -CONFIG_CRYPTO_BLOWFISH=m -CONFIG_CRYPTO_CAST5=m -CONFIG_CRYPTO_CAST6=m -CONFIG_CRYPTO_DEFLATE=m -CONFIG_CRYPTO_DES=m -CONFIG_CRYPTO_HMAC=y -CONFIG_CRYPTO_KHAZAD=m -CONFIG_CRYPTO_MD4=m -CONFIG_CRYPTO_MD5=m -CONFIG_CRYPTO_MICHAEL_MIC=m -CONFIG_CRYPTO_NULL=m -CONFIG_CRYPTO_SERPENT=m -CONFIG_CRYPTO_SHA1=m -CONFIG_CRYPTO_SHA256=m -CONFIG_CRYPTO_SHA512=m -CONFIG_CRYPTO_TEA=m -CONFIG_CRYPTO_TEST=m -CONFIG_CRYPTO_TWOFISH=m -CONFIG_CRYPTO_WP512=m -CONFIG_CRYPTO=y -# CONFIG_DDB5074 is not set -# CONFIG_DDB5476 is not set -# CONFIG_DDB5477 is not set -# CONFIG_DEBUG_INFO is not set -# CONFIG_DECNET is not set -# CONFIG_DECSTATION is not set -# CONFIG_DEVFS_DEBUG is not set -CONFIG_DEVFS_FS=y -CONFIG_DEVFS_MOUNT=y -CONFIG_DEVPTS_FS=y -# CONFIG_DL2K is not set -# CONFIG_DRM is not set -# CONFIG_DTLK is not set -# CONFIG_DUMMY is not set -# CONFIG_DUMMY_KEYB is not set -# CONFIG_E1000 is not set -# CONFIG_ECONET is not set -# CONFIG_EFI_PARTITION is not set -# CONFIG_EFS_FS is not set -# CONFIG_EQUALIZER is not set -# CONFIG_ETHERTAP is not set -CONFIG_EXPERIMENTAL=y -CONFIG_EXT2_FS=m -CONFIG_EXT3_FS=m -CONFIG_FAT_FS=m -# CONFIG_FDDI is not set -# CONFIG_FTAPE is not set -# CONFIG_FTL is not set -# CONFIG_FUSION_BOOT is not set -# CONFIG_FUSION_CTL is not set -# CONFIG_FUSION_ISENSE is not set -# CONFIG_FUSION is not set -# CONFIG_FUSION_LAN is not set -# CONFIG_FW_LOADER is not set -# CONFIG_GDB_CONSOLE is not set -# CONFIG_HAMACHI is not set -# CONFIG_HERMES is not set -# CONFIG_HFS_FS is not set -CONFIG_HFSPLUS_FS=m -# CONFIG_HIGHMEM is not set -# CONFIG_HIPPI is not set -# CONFIG_HOTPLUG_PCI_COMPAQ is not set -# CONFIG_HOTPLUG_PCI_COMPAQ_NVRAM is not set -# CONFIG_HOTPLUG_PCI is not set -# CONFIG_HOTPLUG_PCI_PCIE is not set -# CONFIG_HOTPLUG_PCI_PCIE_POLL_EVENT_MODE is not set -# CONFIG_HOTPLUG_PCI_SHPC is not set -# CONFIG_HOTPLUG_PCI_SHPC_POLL_EVENT_MODE is not set -CONFIG_HOTPLUG=y -# CONFIG_HPFS_FS is not set -# CONFIG_HP_LASERJET is not set -# CONFIG_I2C is not set -# CONFIG_IBM_WORKPAD is not set -# CONFIG_IEEE1394_CMP is not set -# CONFIG_IEEE1394_DV1394 is not set -# CONFIG_IEEE1394_ETH1394 is not set -# CONFIG_IEEE1394_OHCI1394 is not set -# CONFIG_IEEE1394_OUI_DB is not set -# CONFIG_IEEE1394_RAWIO is not set -# CONFIG_IEEE1394_SBP2_PHYS_DMA is not set -# CONFIG_IEEE1394_VERBOSEDEBUG is not set -# CONFIG_IEEE1394_VIDEO1394 is not set -CONFIG_IMQ=m -# CONFIG_INET_ECN is not set -CONFIG_INET=y -# CONFIG_INPUT is not set -# CONFIG_INPUT_DB9 is not set -# CONFIG_INPUT_EVDEV is not set -# CONFIG_INPUT_GAMECON is not set -# CONFIG_INPUT_GAMEPORT is not set -# CONFIG_INPUT_IFORCE_USB is not set -# CONFIG_INPUT_JOYDEV is not set -# CONFIG_INPUT_KEYBDEV is not set -# CONFIG_INPUT_MOUSEDEV is not set -# CONFIG_INPUT_SERIO is not set -# CONFIG_INPUT_TURBOGRAFX is not set -# CONFIG_INPUT_UINPUT is not set -# CONFIG_INTERMEZZO_FS is not set -CONFIG_IP6_NF_FILTER=m -CONFIG_IP6_NF_IPTABLES=m -CONFIG_IP6_NF_MANGLE=m -# CONFIG_IP6_NF_MATCH_AHESP is not set -# CONFIG_IP6_NF_MATCH_CONDITION is not set -CONFIG_IP6_NF_MATCH_EUI64=m -CONFIG_IP6_NF_MATCH_FRAG=m -# CONFIG_IP6_NF_MATCH_HL is not set -# CONFIG_IP6_NF_MATCH_IPV6HEADER is not set -CONFIG_IP6_NF_MATCH_LENGTH=m -CONFIG_IP6_NF_MATCH_LIMIT=m -CONFIG_IP6_NF_MATCH_MAC=m -CONFIG_IP6_NF_MATCH_MARK=m -CONFIG_IP6_NF_MATCH_MULTIPORT=m -# CONFIG_IP6_NF_MATCH_OPTS is not set -CONFIG_IP6_NF_MATCH_OWNER=m -CONFIG_IP6_NF_MATCH_RANDOM=m -# CONFIG_IP6_NF_MATCH_RT is not set -# CONFIG_IP6_NF_QUEUE is not set -CONFIG_IP6_NF_RAW=m -CONFIG_IP6_NF_TARGET_IMQ=m -CONFIG_IP6_NF_TARGET_LOG=m -CONFIG_IP6_NF_TARGET_MARK=m -CONFIG_IP6_NF_TARGET_REJECT=m -CONFIG_IP_ADVANCED_ROUTER=y -# CONFIG_IPMI_DEVICE_INTERFACE is not set -# CONFIG_IPMI_HANDLER is not set -# CONFIG_IPMI_KCS is not set -# CONFIG_IPMI_PANIC_EVENT is not set -# CONFIG_IPMI_WATCHDOG is not set -CONFIG_IP_MROUTE=y -CONFIG_IP_MULTICAST=y -CONFIG_IP_MULTIPLE_TABLES=y -CONFIG_IP_NF_AMANDA=m -CONFIG_IP_NF_ARPFILTER=m -CONFIG_IP_NF_ARP_MANGLE=m -CONFIG_IP_NF_ARPTABLES=m -# CONFIG_IP_NF_COMPAT_IPCHAINS is not set -# CONFIG_IP_NF_COMPAT_IPFWADM is not set -CONFIG_IP_NF_CONNTRACK=m -CONFIG_IP_NF_CONNTRACK_MARK=y -CONFIG_IP_NF_CT_ACCT=m -CONFIG_IP_NF_CT_PROTO_GRE=m -CONFIG_IP_NF_FILTER=m -CONFIG_IP_NF_FTP=m -CONFIG_IP_NF_H323=m -CONFIG_IP_NF_IPTABLES=m -CONFIG_IP_NF_IRC=m -CONFIG_IP_NF_MANGLE=m -CONFIG_IP_NF_MATCH_AH_ESP=m -CONFIG_IP_NF_MATCH_CONDITION=m -CONFIG_IP_NF_MATCH_CONNBYTES=m -CONFIG_IP_NF_MATCH_CONNMARK=m -CONFIG_IP_NF_MATCH_CONNTRACK=m -CONFIG_IP_NF_MATCH_COMMENT=m -CONFIG_IP_NF_MATCH_DSCP=m -CONFIG_IP_NF_MATCH_ECN=m -CONFIG_IP_NF_MATCH_HELPER=m -CONFIG_IP_NF_MATCH_IPP2P=m -CONFIG_IP_NF_MATCH_IPRANGE=m -# CONFIG_IP_NF_MATCH_LAYER7_DEBUG is not set -CONFIG_IP_NF_MATCH_LAYER7=m -CONFIG_IP_NF_MATCH_LENGTH=m -CONFIG_IP_NF_MATCH_LIMIT=m -CONFIG_IP_NF_MATCH_MAC=m -CONFIG_IP_NF_MATCH_MARK=m -CONFIG_IP_NF_MATCH_MULTIPORT=m -CONFIG_IP_NF_MATCH_OWNER=m -CONFIG_IP_NF_MATCH_PKTTYPE=m -# CONFIG_IP_NF_MATCH_QUOTA is not set -CONFIG_IP_NF_MATCH_RANDOM=m -CONFIG_IP_NF_MATCH_RECENT=m -CONFIG_IP_NF_MATCH_SET=m -CONFIG_IP_NF_MATCH_STATE=m -CONFIG_IP_NF_MATCH_STRING=m -CONFIG_IP_NF_MATCH_TCPMSS=m -CONFIG_IP_NF_MATCH_TIME=m -CONFIG_IP_NF_MATCH_TOS=m -CONFIG_IP_NF_MATCH_TTL=m -CONFIG_IP_NF_MATCH_UNCLEAN=m -CONFIG_IP_NF_MMS=m -CONFIG_IP_NF_NAT_AMANDA=m -CONFIG_IP_NF_NAT_FTP=m -CONFIG_IP_NF_NAT_H323=m -CONFIG_IP_NF_NAT_IRC=m -CONFIG_IP_NF_NAT=m -CONFIG_IP_NF_NAT_MMS=m -CONFIG_IP_NF_NAT_NEEDED=y -CONFIG_IP_NF_NAT_PPTP=m -CONFIG_IP_NF_NAT_PROTO_GRE=m -CONFIG_IP_NF_NAT_RTSP=m -CONFIG_IP_NF_NAT_SNMP_BASIC=m -CONFIG_IP_NF_NAT_TFTP=m -CONFIG_IP_NF_PPTP=m -CONFIG_IP_NF_QUEUE=m -CONFIG_IP_NF_RAW=m -CONFIG_IP_NF_RTSP=m -CONFIG_IP_NF_SET_HASHSIZE=1024 -CONFIG_IP_NF_SET_IPHASH=m -CONFIG_IP_NF_SET_IPMAP=m -CONFIG_IP_NF_SET_IPTREE=m -CONFIG_IP_NF_SET=m -CONFIG_IP_NF_SET_MACIPMAP=m -CONFIG_IP_NF_SET_MAX=256 -CONFIG_IP_NF_SET_NETHASH=m -CONFIG_IP_NF_SET_PORTMAP=m -CONFIG_IP_NF_TARGET_CLASSIFY=m -CONFIG_IP_NF_TARGET_CONNMARK=m -CONFIG_IP_NF_TARGET_DSCP=m -CONFIG_IP_NF_TARGET_ECN=m -CONFIG_IP_NF_TARGET_IMQ=m -CONFIG_IP_NF_TARGET_LOG=m -CONFIG_IP_NF_TARGET_MARK=m -CONFIG_IP_NF_TARGET_MASQUERADE=m -CONFIG_IP_NF_TARGET_MIRROR=m -CONFIG_IP_NF_TARGET_NETMAP=m -CONFIG_IP_NF_TARGET_NOTRACK=m -CONFIG_IP_NF_TARGET_REDIRECT=m -CONFIG_IP_NF_TARGET_REJECT=m -CONFIG_IP_NF_TARGET_SET=m -CONFIG_IP_NF_TARGET_TCPMSS=m -CONFIG_IP_NF_TARGET_TOS=m -CONFIG_IP_NF_TARGET_TTL=m -CONFIG_IP_NF_TARGET_ULOG=m -CONFIG_IP_NF_TFTP=m -# CONFIG_IP_PIMSM_V1 is not set -# CONFIG_IP_PIMSM_V2 is not set -# CONFIG_IP_PNP is not set -CONFIG_IP_ROUTE_FWMARK=y -CONFIG_IP_ROUTE_MULTIPATH=y -CONFIG_IP_ROUTE_NAT=y -CONFIG_IP_ROUTE_TOS=y -# CONFIG_IP_ROUTE_VERBOSE is not set -# CONFIG_IP_SCTP is not set -CONFIG_IPSEC_NAT_TRAVERSAL=y -CONFIG_IPV6=m -# CONFIG_IPX is not set -# CONFIG_IRDA is not set -# CONFIG_ISA is not set -# CONFIG_ISAPNP is not set -# CONFIG_ISDN is not set -CONFIG_ISO9660_FS=m -# CONFIG_JBD_DEBUG is not set -CONFIG_JBD=m -# CONFIG_JFFS2_BBC_ARMLIB is not set -CONFIG_JFFS2_BBC_LZARI=y -# CONFIG_JFFS2_BBC_LZHD is not set -# CONFIG_JFFS2_BBC_LZO is not set -# CONFIG_JFFS2_BBC_LZSS is not set -CONFIG_JFFS2_FS_DEBUG=0 -CONFIG_JFFS2_FS=y -# CONFIG_JFFS_FS is not set -# CONFIG_JFS_DEBUG is not set -# CONFIG_JFS_FS is not set -# CONFIG_JFS_STATISTICS is not set -CONFIG_JOLIET=y -# CONFIG_KCORE_AOUT is not set -CONFIG_KCORE_ELF=y -# CONFIG_KHTTPD is not set -# CONFIG_KMOD is not set -# CONFIG_LANCE is not set -# CONFIG_LAPB is not set -# CONFIG_LASAT is not set -# CONFIG_LDM_PARTITION is not set -# CONFIG_LLC is not set -CONFIG_LOCKD=m -CONFIG_LOCKD_V4=y -CONFIG_MAC_PARTITION=y -CONFIG_MAGIC_SYSRQ=y -# CONFIG_MCA is not set -# CONFIG_MD is not set -# CONFIG_MD_LINEAR is not set -# CONFIG_MD_MULTIPATH is not set -# CONFIG_MD_RAID0 is not set -# CONFIG_MD_RAID1 is not set -# CONFIG_MD_RAID5 is not set -CONFIG_MINI_FO=y -# CONFIG_MINIX_SUBPARTITION is not set -# CONFIG_MIPS32_COMPAT is not set -# CONFIG_MIPS32_N32 is not set -# CONFIG_MIPS32_O32 is not set -CONFIG_MIPS32=y -# CONFIG_MIPS64 is not set -# CONFIG_MIPS_ATLAS is not set -# CONFIG_MIPS_AU1000 is not set -# CONFIG_MIPS_BOSPORUS is not set -# CONFIG_MIPS_COBALT is not set -# CONFIG_MIPS_DB1000 is not set -# CONFIG_MIPS_DB1100 is not set -# CONFIG_MIPS_DB1200 is not set -# CONFIG_MIPS_DB1500 is not set -# CONFIG_MIPS_DB1550 is not set -# CONFIG_MIPS_EV64120 is not set -# CONFIG_MIPS_EV96100 is not set -# CONFIG_MIPS_FICMMP is not set -# CONFIG_MIPS_HYDROGEN3 is not set -# CONFIG_MIPS_ITE8172 is not set -# CONFIG_MIPS_IVR is not set -# CONFIG_MIPS_MAGNUM_4000 is not set -# CONFIG_MIPS_MALTA is not set -# CONFIG_MIPS_MIRAGE is not set -# CONFIG_MIPS_MTX1 is not set -# CONFIG_MIPS_PB1000 is not set -# CONFIG_MIPS_PB1100 is not set -# CONFIG_MIPS_PB1200 is not set -# CONFIG_MIPS_PB1500 is not set -# CONFIG_MIPS_PB1550 is not set -# CONFIG_MIPS_SEAD is not set -# CONFIG_MIPS_UNCACHED is not set -# CONFIG_MIPS_XXS1500 is not set -CONFIG_MIPS=y -CONFIG_MODULES=y -# CONFIG_MODVERSIONS is not set -# CONFIG_MOMENCO_JAGUAR_ATX is not set -# CONFIG_MOMENCO_OCELOT_C is not set -# CONFIG_MOMENCO_OCELOT_G is not set -# CONFIG_MOMENCO_OCELOT is not set -# CONFIG_MOUSE is not set -CONFIG_MSDOS_PARTITION=y -# CONFIG_MTD_ABSENT is not set -# CONFIG_MTD_AMDSTD is not set -# CONFIG_MTD_BLKMTD is not set -CONFIG_MTD_BLOCK=y -# CONFIG_MTD_BOSPORUS is not set -CONFIG_MTD_CFI_ADV_OPTIONS=y -CONFIG_MTD_CFI_AMDSTD=y -CONFIG_MTD_CFI_B1=y -CONFIG_MTD_CFI_B2=y -# CONFIG_MTD_CFI_B4 is not set -# CONFIG_MTD_CFI_B8 is not set -# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set -CONFIG_MTD_CFI_GEOMETRY=y -CONFIG_MTD_CFI_I1=y -# CONFIG_MTD_CFI_I2 is not set -# CONFIG_MTD_CFI_I4 is not set -# CONFIG_MTD_CFI_I8 is not set -CONFIG_MTD_CFI_INTELEXT=y -# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set -CONFIG_MTD_CFI_NOSWAP=y -# CONFIG_MTD_CFI_STAA is not set -CONFIG_MTD_CFI=y -CONFIG_MTD_CHAR=y -# CONFIG_MTD_CMDLINE_PARTS is not set -# CONFIG_MTD_CONCAT is not set -# CONFIG_MTD_CSTM_MIPS_IXX is not set -# CONFIG_MTD_DB1X00 is not set -# CONFIG_MTD_DEBUG is not set -# CONFIG_MTD_DOC1000 is not set -# CONFIG_MTD_DOC2000 is not set -# CONFIG_MTD_DOC2001 is not set -# CONFIG_MTD_DOCPROBE is not set -CONFIG_MTD_GEN_PROBE=y -# CONFIG_MTD_HYDROGEN3 is not set -# CONFIG_MTD_JEDEC is not set -# CONFIG_MTD_JEDECPROBE is not set -# CONFIG_MTD_LASAT is not set -# CONFIG_MTD_MIRAGE is not set -# CONFIG_MTD_MTDRAM is not set -# CONFIG_MTD_MTX1 is not set -# CONFIG_MTD_NAND is not set -# CONFIG_MTD_OBSOLETE_CHIPS is not set -# CONFIG_MTD_OCELOT is not set -CONFIG_MTD_PARTITIONS=y -# CONFIG_MTD_PB1000 is not set -# CONFIG_MTD_PB1100 is not set -# CONFIG_MTD_PB1500 is not set -# CONFIG_MTD_PB1550 is not set -# CONFIG_MTD_PCI is not set -# CONFIG_MTD_PCMCIA is not set -# CONFIG_MTD_PHYSMAP is not set -# CONFIG_MTD_PMC551 is not set -# CONFIG_MTD_RAM is not set -# CONFIG_MTD_REDBOOT_PARTS is not set -# CONFIG_MTD_ROM is not set -# CONFIG_MTD_SHARP is not set -# CONFIG_MTD_SLRAM is not set -# CONFIG_MTD_XXS1500 is not set -CONFIG_MTD=y -# CONFIG_MYRI_SBUS is not set -# CONFIG_NCPFS_EXTRAS is not set -# CONFIG_NCPFS_IOCTL_LOCKING is not set -# CONFIG_NCP_FS is not set -# CONFIG_NCPFS_NFS_NS is not set -# CONFIG_NCPFS_NLS is not set -# CONFIG_NCPFS_OS2_NS is not set -# CONFIG_NCPFS_PACKET_SIGNING is not set -# CONFIG_NCPFS_SMALLDOS is not set -# CONFIG_NCPFS_STRONG is not set -# CONFIG_NEC_EAGLE is not set -# CONFIG_NEC_OSPREY is not set -CONFIG_NET_CLS_FW=m -CONFIG_NET_CLS_POLICE=y -CONFIG_NET_CLS_ROUTE4=m -CONFIG_NET_CLS_ROUTE=y -CONFIG_NET_CLS_RSVP6=m -CONFIG_NET_CLS_RSVP=m -CONFIG_NET_CLS_TCINDEX=m -CONFIG_NET_CLS_U32=m -CONFIG_NET_CLS=y -CONFIG_NETDEVICES=y -# CONFIG_NET_DIVERT is not set -CONFIG_NET_ESTIMATOR=y -CONFIG_NET_ETHERNET=y -# CONFIG_NET_FASTROUTE is not set -# CONFIG_NET_FC is not set -# CONFIG_NETFILTER_DEBUG is not set -CONFIG_NETFILTER=y -# CONFIG_NET_HW_FLOWCONTROL is not set -# CONFIG_NET_IPGRE_BROADCAST is not set -CONFIG_NET_IPGRE=m -CONFIG_NET_IPIP=m -# CONFIG_NET_ISA is not set -CONFIG_NETLINK_DEV=m -# CONFIG_NET_PKTGEN is not set -# CONFIG_NET_POCKET is not set -CONFIG_NET_QOS=y -CONFIG_NET_RADIO=y -CONFIG_NET_RANDOM=y -CONFIG_NET_SCH_CBQ=m -CONFIG_NET_SCH_CSZ=m -CONFIG_NET_SCH_DSMARK=m -CONFIG_NET_SCHED=y -CONFIG_NET_SCH_GRED=m -CONFIG_NET_SCH_HFSC=m -CONFIG_NET_SCH_HTB=m -CONFIG_NET_SCH_INGRESS=m -# CONFIG_NET_SCH_NETEM is not set -CONFIG_NET_SCH_PRIO=m -CONFIG_NET_SCH_RED=m -CONFIG_NET_SCH_SFQ=m -CONFIG_NET_SCH_TBF=m -CONFIG_NET_SCH_TEQL=m -# CONFIG_NET_VENDOR_3COM is not set -# CONFIG_NET_VENDOR_RACAL is not set -# CONFIG_NET_VENDOR_SMC is not set -CONFIG_NET=y -# CONFIG_NFS_DIRECTIO is not set -CONFIG_NFSD=m -# CONFIG_NFSD_TCP is not set -CONFIG_NFSD_V3=y -CONFIG_NFS_FS=m -CONFIG_NFS_V3=y -# CONFIG_NFTL is not set -# CONFIG_NINO is not set -CONFIG_NLS_CODEPAGE_1250=m -# CONFIG_NLS_CODEPAGE_1251 is not set -CONFIG_NLS_CODEPAGE_437=m -# CONFIG_NLS_CODEPAGE_737 is not set -# CONFIG_NLS_CODEPAGE_775 is not set -CONFIG_NLS_CODEPAGE_850=m -# CONFIG_NLS_CODEPAGE_852 is not set -# CONFIG_NLS_CODEPAGE_855 is not set -# CONFIG_NLS_CODEPAGE_857 is not set -# CONFIG_NLS_CODEPAGE_860 is not set -# CONFIG_NLS_CODEPAGE_861 is not set -# CONFIG_NLS_CODEPAGE_862 is not set -# CONFIG_NLS_CODEPAGE_863 is not set -# CONFIG_NLS_CODEPAGE_864 is not set -# CONFIG_NLS_CODEPAGE_865 is not set -# CONFIG_NLS_CODEPAGE_866 is not set -# CONFIG_NLS_CODEPAGE_869 is not set -# CONFIG_NLS_CODEPAGE_874 is not set -# CONFIG_NLS_CODEPAGE_932 is not set -# CONFIG_NLS_CODEPAGE_936 is not set -# CONFIG_NLS_CODEPAGE_949 is not set -# CONFIG_NLS_CODEPAGE_950 is not set -CONFIG_NLS_DEFAULT="iso8859-1" -# CONFIG_NLS_ISO8859_13 is not set -# CONFIG_NLS_ISO8859_14 is not set -CONFIG_NLS_ISO8859_15=m -CONFIG_NLS_ISO8859_1=m -# CONFIG_NLS_ISO8859_2 is not set -# CONFIG_NLS_ISO8859_3 is not set -# CONFIG_NLS_ISO8859_4 is not set -# CONFIG_NLS_ISO8859_5 is not set -# CONFIG_NLS_ISO8859_6 is not set -# CONFIG_NLS_ISO8859_7 is not set -# CONFIG_NLS_ISO8859_8 is not set -# CONFIG_NLS_ISO8859_9 is not set -CONFIG_NLS_KOI8_R=m -# CONFIG_NLS_KOI8_U is not set -CONFIG_NLS_UTF8=m -CONFIG_NLS=y -CONFIG_NONCOHERENT_IO=y -# CONFIG_NS83820 is not set -CONFIG_NTFS_FS=m -# CONFIG_NTFS_RW is not set -# CONFIG_NVRAM is not set -# CONFIG_OCF_BENCH is not set -# CONFIG_OCF_C7108 is not set -# CONFIG_OCF_CRYPTODEV is not set -# CONFIG_OCF_CRYPTOSOFT is not set -# CONFIG_OCF_EP80579 is not set -# CONFIG_OCF_FIPS is not set -# CONFIG_OCF_HIFN is not set -# CONFIG_OCF_IXP4XX is not set -# CONFIG_OCF_OCF is not set -# CONFIG_OCF_OCFNULL is not set -# CONFIG_OCF_PASEMI is not set -# CONFIG_OCF_RANDOMHARVEST is not set -# CONFIG_OCF_SAFE is not set -# CONFIG_OCF_TALITOS is not set -# CONFIG_OLIVETTI_M700 is not set -# CONFIG_OOM_KILLER is not set -# CONFIG_OSF_PARTITION is not set -CONFIG_PACKET_MMAP=y -CONFIG_PACKET=y -# CONFIG_PAGE_SIZE_16KB is not set -CONFIG_PAGE_SIZE_4KB=y -# CONFIG_PAGE_SIZE_64KB is not set -# CONFIG_PARIDE is not set -CONFIG_PARTITION_ADVANCED=y -# CONFIG_PHONE is not set -# CONFIG_PHONE_IXJ is not set -# CONFIG_PHONE_IXJ_PCMCIA is not set -# CONFIG_PLIP is not set -# CONFIG_PMC_BIG_SUR is not set -# CONFIG_PMC_STRETCH is not set -# CONFIG_PMC_YOSEMITE is not set -# CONFIG_PNP is not set -CONFIG_PPP_ASYNC=m -CONFIG_PPP_BSDCOMP=m -CONFIG_PPP_DEFLATE=m -CONFIG_PPP_FILTER=y -CONFIG_PPP=m -CONFIG_PPP_MPPE_MPPC=m -CONFIG_PPP_MULTILINK=y -CONFIG_PPPOE=m -CONFIG_PPP_SYNC_TTY=m -# CONFIG_PRISM54 is not set -CONFIG_PROC_FS=y -# CONFIG_QFMT_V2 is not set -# CONFIG_QIC02_TAPE is not set -# CONFIG_QNX4FS_FS is not set -# CONFIG_QNX4FS_RW is not set -# CONFIG_QUOTA is not set -# CONFIG_R3964 is not set -# CONFIG_R8169 is not set -CONFIG_RAMFS=y -# CONFIG_RCPCI is not set -# CONFIG_REISERFS_CHECK is not set -# CONFIG_REISERFS_FS is not set -# CONFIG_REISERFS_PROC_INFO is not set -# CONFIG_ROMFS_FS is not set -# CONFIG_ROOT_NFS is not set -# CONFIG_RTC is not set -# CONFIG_RUNTIME_DEBUG is not set -CONFIG_RWSEM_GENERIC_SPINLOCK=y -# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set -# CONFIG_SBUS is not set -# CONFIG_SCSI_7000FASST is not set -# CONFIG_SCSI_AACRAID is not set -# CONFIG_SCSI_ACARD is not set -# CONFIG_SCSI_ADVANSYS is not set -# CONFIG_SCSI_AHA152X is not set -# CONFIG_SCSI_AHA1542 is not set -# CONFIG_SCSI_AHA1740 is not set -# CONFIG_SCSI_AIC79XX is not set -# CONFIG_SCSI_AIC7XXX is not set -# CONFIG_SCSI_AIC7XXX_OLD is not set -# CONFIG_SCSI_AM53C974 is not set -# CONFIG_SCSI_ATA_PIIX is not set -# CONFIG_SCSI_BUSLOGIC is not set -# CONFIG_SCSI_CONSTANTS is not set -# CONFIG_SCSI_DEBUG is not set -# CONFIG_SCSI_DEBUG_QUEUES is not set -# CONFIG_SCSI_DMX3191D is not set -# CONFIG_SCSI_DPT_I2O is not set -# CONFIG_SCSI_DTC3280 is not set -# CONFIG_SCSI_EATA_DMA is not set -# CONFIG_SCSI_EATA is not set -# CONFIG_SCSI_EATA_PIO is not set -# CONFIG_SCSI_FUTURE_DOMAIN is not set -# CONFIG_SCSI_GDTH is not set -# CONFIG_SCSI_GENERIC_NCR5380 is not set -# CONFIG_SCSI_IN2000 is not set -# CONFIG_SCSI_INIA100 is not set -# CONFIG_SCSI_INITIO is not set -# CONFIG_SCSI_LOGGING is not set -CONFIG_SCSI=m -# CONFIG_SCSI_MEGARAID2 is not set -# CONFIG_SCSI_MEGARAID is not set -CONFIG_SCSI_MULTI_LUN=y -# CONFIG_SCSI_NCR53C406A is not set -# CONFIG_SCSI_NCR53C7xx is not set -# CONFIG_SCSI_NSP32 is not set -# CONFIG_SCSI_PAS16 is not set -# CONFIG_SCSI_PCI2000 is not set -# CONFIG_SCSI_PCI2220I is not set -# CONFIG_SCSI_PSI240I is not set -# CONFIG_SCSI_QLOGIC_FAS is not set -# CONFIG_SCSI_SATA_AHCI is not set -# CONFIG_SCSI_SATA is not set -# CONFIG_SCSI_SATA_NV is not set -# CONFIG_SCSI_SATA_PROMISE is not set -# CONFIG_SCSI_SATA_QSTOR is not set -# CONFIG_SCSI_SATA_SIL is not set -# CONFIG_SCSI_SATA_SIS is not set -# CONFIG_SCSI_SATA_SVW is not set -# CONFIG_SCSI_SATA_SX4 is not set -# CONFIG_SCSI_SATA_ULI is not set -# CONFIG_SCSI_SATA_VIA is not set -# CONFIG_SCSI_SATA_VITESSE is not set -# CONFIG_SCSI_SIM710 is not set -# CONFIG_SCSI_SYM53C416 is not set -# CONFIG_SCSI_T128 is not set -# CONFIG_SCSI_U14_34F is not set -# CONFIG_SCx200_GPIO is not set -# CONFIG_SCx200 is not set -CONFIG_SD_EXTRA_DEVS=5 -CONFIG_SERIAL_CONSOLE=y -# CONFIG_SERIAL_EXTENDED is not set -# CONFIG_SERIAL_NONSTANDARD is not set -CONFIG_SERIAL=y -# CONFIG_SGI_IP22 is not set -# CONFIG_SGI_IP27 is not set -# CONFIG_SGI_PARTITION is not set -CONFIG_SHAPER=m -# CONFIG_SIBYTE_SB1xxx_SOC is not set -# CONFIG_SK98LIN is not set -# CONFIG_SKGE is not set -# CONFIG_SKY2 is not set -# CONFIG_SLIP is not set -# CONFIG_SMB_FS is not set -# CONFIG_SMB_NLS is not set -# CONFIG_SNI_RM200_PCI is not set -# CONFIG_SOLARIS_X86_PARTITION is not set -# CONFIG_SQUASHFS_EMBEDDED is not set -CONFIG_SQUASHFS=y -# CONFIG_STRIP is not set -# CONFIG_SUNBMAC is not set -# CONFIG_SUNGEM is not set -# CONFIG_SUNLANCE is not set -# CONFIG_SUN_PARTITION is not set -# CONFIG_SUNQE is not set -CONFIG_SUNRPC=m -CONFIG_SYN_COOKIES=y -CONFIG_SYSCTL=y -# CONFIG_SYSV_FS is not set -CONFIG_SYSVIPC=y -# CONFIG_TANBAC_TB0226 is not set -# CONFIG_TANBAC_TB0229 is not set -# CONFIG_TC is not set -# CONFIG_TIGON3 is not set -CONFIG_TMPFS=y -# CONFIG_TOSHIBA_JMR3927 is not set -# CONFIG_TOSHIBA_RBTX4927 is not set -# CONFIG_TR is not set -CONFIG_TUN=m -# CONFIG_UDF_FS is not set -# CONFIG_UDF_RW is not set -# CONFIG_UFS_FS is not set -# CONFIG_UFS_FS_WRITE is not set -# CONFIG_ULTRIX_PARTITION is not set -# CONFIG_UMSDOS_FS is not set -CONFIG_UNIX98_PTY_COUNT=128 -CONFIG_UNIX98_PTYS=y -# CONFIG_UNIXWARE_DISKLABEL is not set -CONFIG_UNIX=y -# CONFIG_USB_BLUETOOTH is not set -# CONFIG_USB_GADGET is not set -CONFIG_USB_USBNET=m -CONFIG_VFAT_FS=m -# CONFIG_VICTOR_MPC30X is not set -CONFIG_VLAN_8021Q=y -# CONFIG_VTAG_ICACHE is not set -# CONFIG_VT is not set -# CONFIG_VXFS_FS is not set -# CONFIG_WAN is not set -CONFIG_WAN_ROUTER=m -# CONFIG_WATCHDOG_NOWAYOUT is not set -CONFIG_WATCHDOG=y -# CONFIG_WAVELAN is not set -# CONFIG_WDT_W83627 is not set -# CONFIG_X25 is not set -# CONFIG_XFS_DEBUG is not set -CONFIG_XFS_FS=m -# CONFIG_XFS_QUOTA is not set -# CONFIG_XFS_RT is not set -# CONFIG_XFS_TRACE is not set -# CONFIG_YELLOWFIN is not set -# CONFIG_ZAO_CAPCELLA is not set -# CONFIG_ZISOFS_FS is not set -# CONFIG_ZISOFS is not set -CONFIG_ZLIB_DEFLATE=y -CONFIG_ZLIB_INFLATE=y diff --git a/target/linux/generic-2.4/files/crypto/ocf/Config.in b/target/linux/generic-2.4/files/crypto/ocf/Config.in deleted file mode 100644 index d722cba..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/Config.in +++ /dev/null @@ -1,36 +0,0 @@ -############################################################################# - -mainmenu_option next_comment -comment 'OCF Configuration' -tristate 'OCF (Open Cryptograhic Framework)' CONFIG_OCF_OCF -dep_mbool ' enable fips RNG checks (fips check on RNG data before use)' \ - CONFIG_OCF_FIPS $CONFIG_OCF_OCF -dep_mbool ' enable harvesting entropy for /dev/random' \ - CONFIG_OCF_RANDOMHARVEST $CONFIG_OCF_OCF -dep_tristate ' cryptodev (user space support)' \ - CONFIG_OCF_CRYPTODEV $CONFIG_OCF_OCF -dep_tristate ' cryptosoft (software crypto engine)' \ - CONFIG_OCF_CRYPTOSOFT $CONFIG_OCF_OCF -dep_tristate ' safenet (HW crypto engine)' \ - CONFIG_OCF_SAFE $CONFIG_OCF_OCF -dep_tristate ' IXP4xx (HW crypto engine)' \ - CONFIG_OCF_IXP4XX $CONFIG_OCF_OCF -dep_mbool ' Enable IXP4xx HW to perform SHA1 and MD5 hashing (very slow)' \ - CONFIG_OCF_IXP4XX_SHA1_MD5 $CONFIG_OCF_IXP4XX -dep_tristate ' hifn (HW crypto engine)' \ - CONFIG_OCF_HIFN $CONFIG_OCF_OCF -dep_tristate ' talitos (HW crypto engine)' \ - CONFIG_OCF_TALITOS $CONFIG_OCF_OCF -dep_tristate ' pasemi (HW crypto engine)' \ - CONFIG_OCF_PASEMI $CONFIG_OCF_OCF -dep_tristate ' ep80579 (HW crypto engine)' \ - CONFIG_OCF_EP80579 $CONFIG_OCF_OCF -dep_tristate ' Micronas c7108 (HW crypto engine)' \ - CONFIG_OCF_C7108 $CONFIG_OCF_OCF -dep_tristate ' ocfnull (does no crypto)' \ - CONFIG_OCF_OCFNULL $CONFIG_OCF_OCF -dep_tristate ' ocf-bench (HW crypto in-kernel benchmark)' \ - CONFIG_OCF_BENCH $CONFIG_OCF_OCF -endmenu - -############################################################################# diff --git a/target/linux/generic-2.4/files/crypto/ocf/Kconfig b/target/linux/generic-2.4/files/crypto/ocf/Kconfig deleted file mode 100644 index b9c24ff..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/Kconfig +++ /dev/null @@ -1,119 +0,0 @@ -menu "OCF Configuration" - -config OCF_OCF - tristate "OCF (Open Cryptograhic Framework)" - help - A linux port of the OpenBSD/FreeBSD crypto framework. - -config OCF_RANDOMHARVEST - bool "crypto random --- harvest entropy for /dev/random" - depends on OCF_OCF - help - Includes code to harvest random numbers from devices that support it. - -config OCF_FIPS - bool "enable fips RNG checks" - depends on OCF_OCF && OCF_RANDOMHARVEST - help - Run all RNG provided data through a fips check before - adding it /dev/random's entropy pool. - -config OCF_CRYPTODEV - tristate "cryptodev (user space support)" - depends on OCF_OCF - help - The user space API to access crypto hardware. - -config OCF_CRYPTOSOFT - tristate "cryptosoft (software crypto engine)" - depends on OCF_OCF - help - A software driver for the OCF framework that uses - the kernel CryptoAPI. - -config OCF_SAFE - tristate "safenet (HW crypto engine)" - depends on OCF_OCF - help - A driver for a number of the safenet Excel crypto accelerators. - Currently tested and working on the 1141 and 1741. - -config OCF_IXP4XX - tristate "IXP4xx (HW crypto engine)" - depends on OCF_OCF - help - XScale IXP4xx crypto accelerator driver. Requires the - Intel Access library. - -config OCF_IXP4XX_SHA1_MD5 - bool "IXP4xx SHA1 and MD5 Hashing" - depends on OCF_IXP4XX - help - Allows the IXP4xx crypto accelerator to perform SHA1 and MD5 hashing. - Note: this is MUCH slower than using cryptosoft (software crypto engine). - -config OCF_HIFN - tristate "hifn (HW crypto engine)" - depends on OCF_OCF - help - OCF driver for various HIFN based crypto accelerators. - (7951, 7955, 7956, 7751, 7811) - -config OCF_HIFNHIPP - tristate "Hifn HIPP (HW packet crypto engine)" - depends on OCF_OCF - help - OCF driver for various HIFN (HIPP) based crypto accelerators - (7855) - -config OCF_TALITOS - tristate "talitos (HW crypto engine)" - depends on OCF_OCF - help - OCF driver for Freescale's security engine (SEC/talitos). - -config OCF_PASEMI - tristate "pasemi (HW crypto engine)" - depends on OCF_OCF && PPC_PASEMI - help - OCF driver for the PA Semi PWRficient DMA Engine - -config OCF_EP80579 - tristate "ep80579 (HW crypto engine)" - depends on OCF_OCF - help - OCF driver for the Intel EP80579 Integrated Processor Product Line. - -config OCF_CRYPTOCTEON - tristate "cryptocteon (HW crypto engine)" - depends on OCF_OCF - help - OCF driver for the Cavium OCTEON Processors. - -config OCF_KIRKWOOD - tristate "kirkwood (HW crypto engine)" - depends on OCF_OCF - help - OCF driver for the Marvell Kirkwood (88F6xxx) Processors. - -config OCF_C7108 - tristate "Micronas 7108 (HW crypto engine)" - depends on OCF_OCF - help - OCF driver for the Microna 7108 Cipher processors. - -config OCF_OCFNULL - tristate "ocfnull (fake crypto engine)" - depends on OCF_OCF - help - OCF driver for measuring ipsec overheads (does no crypto) - -config OCF_BENCH - tristate "ocf-bench (HW crypto in-kernel benchmark)" - depends on OCF_OCF - help - A very simple encryption test for the in-kernel interface - of OCF. Also includes code to benchmark the IXP Access library - for comparison. - -endmenu diff --git a/target/linux/generic-2.4/files/crypto/ocf/Makefile b/target/linux/generic-2.4/files/crypto/ocf/Makefile deleted file mode 100644 index fa951f4..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/Makefile +++ /dev/null @@ -1,124 +0,0 @@ -# for SGlinux builds --include $(ROOTDIR)/modules/.config - -OCF_OBJS = crypto.o criov.o - -ifdef CONFIG_OCF_RANDOMHARVEST - OCF_OBJS += random.o -endif - -ifdef CONFIG_OCF_FIPS - OCF_OBJS += rndtest.o -endif - -# Add in autoconf.h to get #defines for CONFIG_xxx -AUTOCONF_H=$(ROOTDIR)/modules/autoconf.h -ifeq ($(AUTOCONF_H), $(wildcard $(AUTOCONF_H))) - EXTRA_CFLAGS += -include $(AUTOCONF_H) - export EXTRA_CFLAGS -endif - -ifndef obj - obj ?= . - _obj = subdir - mod-subdirs := safe hifn ixp4xx talitos ocfnull - export-objs += crypto.o criov.o random.o - list-multi += ocf.o - _slash := -else - _obj = obj - _slash := / -endif - -EXTRA_CFLAGS += -I$(obj)/. - -obj-$(CONFIG_OCF_OCF) += ocf.o -obj-$(CONFIG_OCF_CRYPTODEV) += cryptodev.o -obj-$(CONFIG_OCF_CRYPTOSOFT) += cryptosoft.o -obj-$(CONFIG_OCF_BENCH) += ocf-bench.o - -$(_obj)-$(CONFIG_OCF_SAFE) += safe$(_slash) -$(_obj)-$(CONFIG_OCF_HIFN) += hifn$(_slash) -$(_obj)-$(CONFIG_OCF_IXP4XX) += ixp4xx$(_slash) -$(_obj)-$(CONFIG_OCF_TALITOS) += talitos$(_slash) -$(_obj)-$(CONFIG_OCF_PASEMI) += pasemi$(_slash) -$(_obj)-$(CONFIG_OCF_EP80579) += ep80579$(_slash) -$(_obj)-$(CONFIG_OCF_CRYPTOCTEON) += cryptocteon$(_slash) -$(_obj)-$(CONFIG_OCF_KIRKWOOD) += kirkwood$(_slash) -$(_obj)-$(CONFIG_OCF_OCFNULL) += ocfnull$(_slash) -$(_obj)-$(CONFIG_OCF_C7108) += c7108$(_slash) - -ocf-objs := $(OCF_OBJS) - -$(list-multi) dummy1: $(ocf-objs) - $(LD) -r -o $@ $(ocf-objs) - -.PHONY: -clean: - rm -f *.o *.ko .*.o.flags .*.ko.cmd .*.o.cmd .*.mod.o.cmd *.mod.c - rm -f */*.o */*.ko */.*.o.cmd */.*.ko.cmd */.*.mod.o.cmd */*.mod.c */.*.o.flags - -ifdef TOPDIR --include $(TOPDIR)/Rules.make -endif - -# -# release gen targets -# - -.PHONY: patch -patch: - REL=`date +%Y%m%d`; \ - patch=ocf-linux-$$REL.patch; \ - patch24=ocf-linux-24-$$REL.patch; \ - patch26=ocf-linux-26-$$REL.patch; \ - ( \ - find . -name Makefile; \ - find . -name Config.in; \ - find . -name Kconfig; \ - find . -name README; \ - find . -name '*.[ch]' | grep -v '.mod.c'; \ - ) | while read t; do \ - diff -Nau /dev/null $$t | sed 's?^+++ \./?+++ linux/crypto/ocf/?'; \ - done > $$patch; \ - cat patches/linux-2.4.35-ocf.patch $$patch > $$patch24; \ - cat patches/linux-2.6.33-ocf.patch $$patch > $$patch26 - -.PHONY: tarball -tarball: - REL=`date +%Y%m%d`; RELDIR=/tmp/ocf-linux-$$REL; \ - CURDIR=`pwd`; \ - rm -rf /tmp/ocf-linux-$$REL*; \ - mkdir -p $$RELDIR/tools; \ - cp README* $$RELDIR; \ - cp patches/openss*.patch $$RELDIR; \ - cp patches/crypto-tools.patch $$RELDIR; \ - cp tools/[!C]* $$RELDIR/tools; \ - cd ..; \ - tar cvf $$RELDIR/ocf-linux.tar \ - --exclude=CVS \ - --exclude=.* \ - --exclude=*.o \ - --exclude=*.ko \ - --exclude=*.mod.* \ - --exclude=README* \ - --exclude=ocf-*.patch \ - --exclude=ocf/patches/openss*.patch \ - --exclude=ocf/patches/crypto-tools.patch \ - --exclude=ocf/tools \ - ocf; \ - gzip -9 $$RELDIR/ocf-linux.tar; \ - cd /tmp; \ - tar cvf ocf-linux-$$REL.tar ocf-linux-$$REL; \ - gzip -9 ocf-linux-$$REL.tar; \ - cd $$CURDIR/../../user; \ - rm -rf /tmp/crypto-tools-$$REL*; \ - tar cvf /tmp/crypto-tools-$$REL.tar \ - --exclude=CVS \ - --exclude=.* \ - --exclude=*.o \ - --exclude=cryptotest \ - --exclude=cryptokeytest \ - crypto-tools; \ - gzip -9 /tmp/crypto-tools-$$REL.tar - diff --git a/target/linux/generic-2.4/files/crypto/ocf/README b/target/linux/generic-2.4/files/crypto/ocf/README deleted file mode 100644 index 5ac39f7..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/README +++ /dev/null @@ -1,167 +0,0 @@ -README - ocf-linux-20100325 ---------------------------- - -This README provides instructions for getting ocf-linux compiled and -operating in a generic linux environment. For other information you -might like to visit the home page for this project: - - http://ocf-linux.sourceforge.net/ - -Adding OCF to linux -------------------- - - Not much in this file for now, just some notes. I usually build - the ocf support as modules but it can be built into the kernel as - well. To use it: - - * mknod /dev/crypto c 10 70 - - * to add OCF to your kernel source, you have two options. Apply - the kernel specific patch: - - cd linux-2.4*; gunzip < ocf-linux-24-XXXXXXXX.patch.gz | patch -p1 - cd linux-2.6*; gunzip < ocf-linux-26-XXXXXXXX.patch.gz | patch -p1 - - if you do one of the above, then you can proceed to the next step, - or you can do the above process by hand with using the patches against - linux-2.4.35 and 2.6.33 to include the ocf code under crypto/ocf. - Here's how to add it: - - for 2.4.35 (and later) - - cd linux-2.4.35/crypto - tar xvzf ocf-linux.tar.gz - cd .. - patch -p1 < crypto/ocf/patches/linux-2.4.35-ocf.patch - - for 2.6.23 (and later), find the kernel patch specific (or nearest) - to your kernel versions and then: - - cd linux-2.6.NN/crypto - tar xvzf ocf-linux.tar.gz - cd .. - patch -p1 < crypto/ocf/patches/linux-2.6.NN-ocf.patch - - It should be easy to take this patch and apply it to other more - recent versions of the kernels. The same patches should also work - relatively easily on kernels as old as 2.6.11 and 2.4.18. - - * under 2.4 if you are on a non-x86 platform, you may need to: - - cp linux-2.X.x/include/asm-i386/kmap_types.h linux-2.X.x/include/asm-YYY - - so that you can build the kernel crypto support needed for the cryptosoft - driver. - - * For simplicity you should enable all the crypto support in your kernel - except for the test driver. Likewise for the OCF options. Do not - enable OCF crypto drivers for HW that you do not have (for example - ixp4xx will not compile on non-Xscale systems). - - * make sure that cryptodev.h (from ocf-linux.tar.gz) is installed as - crypto/cryptodev.h in an include directory that is used for building - applications for your platform. For example on a host system that - might be: - - /usr/include/crypto/cryptodev.h - - * patch your openssl-0.9.8n code with the openssl-0.9.8n.patch. - (NOTE: there is no longer a need to patch ssh). The patch is against: - openssl-0_9_8e - - If you need a patch for an older version of openssl, you should look - to older OCF releases. This patch is unlikely to work on older - openssl versions. - - openssl-0.9.8n.patch - - enables --with-cryptodev for non BSD systems - - adds -cpu option to openssl speed for calculating CPU load - under linux - - fixes null pointer in openssl speed multi thread output. - - fixes test keys to work with linux crypto's more stringent - key checking. - - adds MD5/SHA acceleration (Ronen Shitrit), only enabled - with the --with-cryptodev-digests option - - fixes bug in engine code caching. - - * build crypto-tools-XXXXXXXX.tar.gz if you want to try some of the BSD - tools for testing OCF (ie., cryptotest). - -How to load the OCF drivers ---------------------------- - - First insert the base modules: - - insmod ocf - insmod cryptodev - - You can then install the software OCF driver with: - - insmod cryptosoft - - and one or more of the OCF HW drivers with: - - insmod safe - insmod hifn7751 - insmod ixp4xx - ... - - all the drivers take a debug option to enable verbose debug so that - you can see what is going on. For debug you load them as: - - insmod ocf crypto_debug=1 - insmod cryptodev cryptodev_debug=1 - insmod cryptosoft swcr_debug=1 - - You may load more than one OCF crypto driver but then there is no guarantee - as to which will be used. - - You can also enable debug at run time on 2.6 systems with the following: - - echo 1 > /sys/module/ocf/parameters/crypto_debug - echo 1 > /sys/module/cryptodev/parameters/cryptodev_debug - echo 1 > /sys/module/cryptosoft/parameters/swcr_debug - echo 1 > /sys/module/hifn7751/parameters/hifn_debug - echo 1 > /sys/module/safe/parameters/safe_debug - echo 1 > /sys/module/ixp4xx/parameters/ixp_debug - ... - -Testing the OCF support ------------------------ - - run "cryptotest", it should do a short test for a couple of - des packets. If it does everything is working. - - If this works, then ssh will use the driver when invoked as: - - ssh -c 3des username@host - - to see for sure that it is operating, enable debug as defined above. - - To get a better idea of performance run: - - cryptotest 100 4096 - - There are more options to cryptotest, see the help. - - It is also possible to use openssl to test the speed of the crypto - drivers. - - openssl speed -evp des -engine cryptodev -elapsed - openssl speed -evp des3 -engine cryptodev -elapsed - openssl speed -evp aes128 -engine cryptodev -elapsed - - and multiple threads (10) with: - - openssl speed -evp des -engine cryptodev -elapsed -multi 10 - openssl speed -evp des3 -engine cryptodev -elapsed -multi 10 - openssl speed -evp aes128 -engine cryptodev -elapsed -multi 10 - - for public key testing you can try: - - cryptokeytest - openssl speed -engine cryptodev rsa -elapsed - openssl speed -engine cryptodev dsa -elapsed - -David McCullough -david_mccullough@mcafee.com diff --git a/target/linux/generic-2.4/files/crypto/ocf/c7108/Makefile b/target/linux/generic-2.4/files/crypto/ocf/c7108/Makefile deleted file mode 100644 index e7e634b..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/c7108/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# for SGlinux builds --include $(ROOTDIR)/modules/.config - -obj-$(CONFIG_OCF_C7108) += aes-7108.o - -obj ?= . -EXTRA_CFLAGS += -I$(obj)/.. -I$(obj)/ - -ifdef TOPDIR --include $(TOPDIR)/Rules.make -endif - diff --git a/target/linux/generic-2.4/files/crypto/ocf/c7108/aes-7108.c b/target/linux/generic-2.4/files/crypto/ocf/c7108/aes-7108.c deleted file mode 100644 index a5ac054..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/c7108/aes-7108.c +++ /dev/null @@ -1,839 +0,0 @@ -/* - * Copyright (C) 2006 Micronas USA - * - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR 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. - * - * Effort sponsored in part by the Defense Advanced Research Projects - * Agency (DARPA) and Air Force Research Laboratory, Air Force - * Materiel Command, USAF, under agreement number F30602-01-2-0537. - * - */ - -//#include <linux/config.h> -#include <linux/module.h> -#include <linux/init.h> -#include <linux/list.h> -#include <linux/slab.h> -#include <linux/sched.h> -#include <linux/wait.h> -#include <linux/crypto.h> -#include <linux/mm.h> -#include <linux/skbuff.h> -#include <linux/random.h> -#include <asm/io.h> -#include <asm/delay.h> -//#include <asm/scatterlist.h> -#include <linux/scatterlist.h> -#include <linux/dma-mapping.h> -#include <linux/highmem.h> -#include <cryptodev.h> -#include <uio.h> -#include <aes-7108.h> - -/* Runtime mode */ -static int c7108_crypto_mode = C7108_AES_CTRL_MODE_CTR; -//static int c7108_crypto_mode = C7108_AES_CTRL_MODE_CBC; - -static int32_t c7108_id = -1; -static struct cipher_7108 **c7108_sessions = NULL; -static u_int32_t c7108_sesnum = 0; -static unsigned long iobar; - -/* Crypto entry points */ -static int c7108_process(void *, struct cryptop *, int); -static int c7108_newsession(void *, u_int32_t *, struct cryptoini *); -static int c7108_freesession(void *, u_int64_t); - -/* Globals */ -static int debug = 0; -static spinlock_t csr_mutex; - -/* Generic controller-based lock */ -#define AES_LOCK()\ - spin_lock(&csr_mutex) -#define AES_UNLOCK()\ - spin_unlock(&csr_mutex) - -/* 7108 AES register access */ -#define c7108_reg_wr8(a,d) iowrite8(d, (void*)(iobar+(a))) -#define c7108_reg_wr16(a,d) iowrite16(d, (void*)(iobar+(a))) -#define c7108_reg_wr32(a,d) iowrite32(d, (void*)(iobar+(a))) -#define c7108_reg_rd8(a) ioread8((void*)(iobar+(a))) -#define c7108_reg_rd16(a) ioread16((void*)(iobar+(a))) -#define c7108_reg_rd32(a) ioread32((void*)(iobar+(a))) - -static int -c7108_xlate_key(int klen, u8* k8ptr, u32* k32ptr) -{ - int i, nw=0; - nw = ((klen >= 256) ? 8 : (klen >= 192) ? 6 : 4); - for ( i = 0; i < nw; i++) { - k32ptr[i] = (k8ptr[i+3] << 24) | (k8ptr[i+2] << 16) | - (k8ptr[i+1] << 8) | k8ptr[i]; - - } - return 0; -} - -static int -c7108_cache_key(int klen, u32* k32ptr, u8* k8ptr) -{ - int i, nb=0; - u8* ptr = (u8*)k32ptr; - nb = ((klen >= 256) ? 32 : (klen >= 192) ? 24 : 16); - for ( i = 0; i < nb; i++) - k8ptr[i] = ptr[i]; - return 0; -} - -static int -c7108_aes_setup_dma(u32 src, u32 dst, u32 len) -{ - if (len < 16) { - printk("len < 16\n"); - return -10; - } - if (len % 16) { - printk("len not multiple of 16\n"); - return -11; - } - c7108_reg_wr16(C7108_AES_DMA_SRC0_LO, (u16) src); - c7108_reg_wr16(C7108_AES_DMA_SRC0_HI, (u16)((src & 0xffff0000) >> 16)); - c7108_reg_wr16(C7108_AES_DMA_DST0_LO, (u16) dst); - c7108_reg_wr16(C7108_AES_DMA_DST0_HI, (u16)((dst & 0xffff0000) >> 16)); - c7108_reg_wr16(C7108_AES_DMA_LEN, (u16) ((len / 16) - 1)); - - return 0; -} - -static int -c7108_aes_set_hw_iv(u8 iv[16]) -{ - c7108_reg_wr16(C7108_AES_IV0_LO, (u16) ((iv[1] << 8) | iv[0])); - c7108_reg_wr16(C7108_AES_IV0_HI, (u16) ((iv[3] << 8) | iv[2])); - c7108_reg_wr16(C7108_AES_IV1_LO, (u16) ((iv[5] << 8) | iv[4])); - c7108_reg_wr16(C7108_AES_IV1_HI, (u16) ((iv[7] << 8) | iv[6])); - c7108_reg_wr16(C7108_AES_IV2_LO, (u16) ((iv[9] << 8) | iv[8])); - c7108_reg_wr16(C7108_AES_IV2_HI, (u16) ((iv[11] << 8) | iv[10])); - c7108_reg_wr16(C7108_AES_IV3_LO, (u16) ((iv[13] << 8) | iv[12])); - c7108_reg_wr16(C7108_AES_IV3_HI, (u16) ((iv[15] << 8) | iv[14])); - - return 0; -} - -static void -c7108_aes_read_dkey(u32 * dkey) -{ - dkey[0] = (c7108_reg_rd16(C7108_AES_EKEY0_HI) << 16) | - c7108_reg_rd16(C7108_AES_EKEY0_LO); - dkey[1] = (c7108_reg_rd16(C7108_AES_EKEY1_HI) << 16) | - c7108_reg_rd16(C7108_AES_EKEY1_LO); - dkey[2] = (c7108_reg_rd16(C7108_AES_EKEY2_HI) << 16) | - c7108_reg_rd16(C7108_AES_EKEY2_LO); - dkey[3] = (c7108_reg_rd16(C7108_AES_EKEY3_HI) << 16) | - c7108_reg_rd16(C7108_AES_EKEY3_LO); - dkey[4] = (c7108_reg_rd16(C7108_AES_EKEY4_HI) << 16) | - c7108_reg_rd16(C7108_AES_EKEY4_LO); - dkey[5] = (c7108_reg_rd16(C7108_AES_EKEY5_HI) << 16) | - c7108_reg_rd16(C7108_AES_EKEY5_LO); - dkey[6] = (c7108_reg_rd16(C7108_AES_EKEY6_HI) << 16) | - c7108_reg_rd16(C7108_AES_EKEY6_LO); - dkey[7] = (c7108_reg_rd16(C7108_AES_EKEY7_HI) << 16) | - c7108_reg_rd16(C7108_AES_EKEY7_LO); -} - -static int -c7108_aes_cipher(int op, - u32 dst, - u32 src, - u32 len, - int klen, - u16 mode, - u32 key[8], - u8 iv[16]) -{ - int rv = 0, cnt=0; - u16 ctrl = 0, stat = 0; - - AES_LOCK(); - - /* Setup key length */ - if (klen == 128) { - ctrl |= C7108_AES_KEY_LEN_128; - } else if (klen == 192) { - ctrl |= C7108_AES_KEY_LEN_192; - } else if (klen == 256) { - ctrl |= C7108_AES_KEY_LEN_256; - } else { - AES_UNLOCK(); - return -3; - } - - /* Check opcode */ - if (C7108_AES_ENCRYPT == op) { - ctrl |= C7108_AES_ENCRYPT; - } else if (C7108_AES_DECRYPT == op) { - ctrl |= C7108_AES_DECRYPT; - } else { - AES_UNLOCK(); - return -4; - } - - /* check mode */ - if ( (mode != C7108_AES_CTRL_MODE_CBC) && - (mode != C7108_AES_CTRL_MODE_CFB) && - (mode != C7108_AES_CTRL_MODE_OFB) && - (mode != C7108_AES_CTRL_MODE_CTR) && - (mode != C7108_AES_CTRL_MODE_ECB) ) { - AES_UNLOCK(); - return -5; - } - - /* Now set mode */ - ctrl |= mode; - - /* For CFB, OFB, and CTR, neither backward key - * expansion nor key inversion is required. - */ - if ( (C7108_AES_DECRYPT == op) && - (C7108_AES_CTRL_MODE_CBC == mode || - C7108_AES_CTRL_MODE_ECB == mode ) ){ - - /* Program Key */ - c7108_reg_wr16(C7108_AES_KEY0_LO, (u16) key[4]); - c7108_reg_wr16(C7108_AES_KEY0_HI, (u16) (key[4] >> 16)); - c7108_reg_wr16(C7108_AES_KEY1_LO, (u16) key[5]); - c7108_reg_wr16(C7108_AES_KEY1_HI, (u16) (key[5] >> 16)); - c7108_reg_wr16(C7108_AES_KEY2_LO, (u16) key[6]); - c7108_reg_wr16(C7108_AES_KEY2_HI, (u16) (key[6] >> 16)); - c7108_reg_wr16(C7108_AES_KEY3_LO, (u16) key[7]); - c7108_reg_wr16(C7108_AES_KEY3_HI, (u16) (key[7] >> 16)); - c7108_reg_wr16(C7108_AES_KEY6_LO, (u16) key[2]); - c7108_reg_wr16(C7108_AES_KEY6_HI, (u16) (key[2] >> 16)); - c7108_reg_wr16(C7108_AES_KEY7_LO, (u16) key[3]); - c7108_reg_wr16(C7108_AES_KEY7_HI, (u16) (key[3] >> 16)); - - - if (192 == klen) { - c7108_reg_wr16(C7108_AES_KEY4_LO, (u16) key[7]); - c7108_reg_wr16(C7108_AES_KEY4_HI, (u16) (key[7] >> 16)); - c7108_reg_wr16(C7108_AES_KEY5_LO, (u16) key[7]); - c7108_reg_wr16(C7108_AES_KEY5_HI, (u16) (key[7] >> 16)); - - } else if (256 == klen) { - /* 256 */ - c7108_reg_wr16(C7108_AES_KEY4_LO, (u16) key[0]); - c7108_reg_wr16(C7108_AES_KEY4_HI, (u16) (key[0] >> 16)); - c7108_reg_wr16(C7108_AES_KEY5_LO, (u16) key[1]); - c7108_reg_wr16(C7108_AES_KEY5_HI, (u16) (key[1] >> 16)); - - } - - } else { - /* Program Key */ - c7108_reg_wr16(C7108_AES_KEY0_LO, (u16) key[0]); - c7108_reg_wr16(C7108_AES_KEY0_HI, (u16) (key[0] >> 16)); - c7108_reg_wr16(C7108_AES_KEY1_LO, (u16) key[1]); - c7108_reg_wr16(C7108_AES_KEY1_HI, (u16) (key[1] >> 16)); - c7108_reg_wr16(C7108_AES_KEY2_LO, (u16) key[2]); - c7108_reg_wr16(C7108_AES_KEY2_HI, (u16) (key[2] >> 16)); - c7108_reg_wr16(C7108_AES_KEY3_LO, (u16) key[3]); - c7108_reg_wr16(C7108_AES_KEY3_HI, (u16) (key[3] >> 16)); - c7108_reg_wr16(C7108_AES_KEY4_LO, (u16) key[4]); - c7108_reg_wr16(C7108_AES_KEY4_HI, (u16) (key[4] >> 16)); - c7108_reg_wr16(C7108_AES_KEY5_LO, (u16) key[5]); - c7108_reg_wr16(C7108_AES_KEY5_HI, (u16) (key[5] >> 16)); - c7108_reg_wr16(C7108_AES_KEY6_LO, (u16) key[6]); - c7108_reg_wr16(C7108_AES_KEY6_HI, (u16) (key[6] >> 16)); - c7108_reg_wr16(C7108_AES_KEY7_LO, (u16) key[7]); - c7108_reg_wr16(C7108_AES_KEY7_HI, (u16) (key[7] >> 16)); - - } - - /* Set IV always */ - c7108_aes_set_hw_iv(iv); - - /* Program DMA addresses */ - if ((rv = c7108_aes_setup_dma(src, dst, len)) < 0) { - AES_UNLOCK(); - return rv; - } - - - /* Start AES cipher */ - c7108_reg_wr16(C7108_AES_CTRL, ctrl | C7108_AES_GO); - - //printk("Ctrl: 0x%x\n", ctrl | C7108_AES_GO); - do { - /* TODO: interrupt mode */ - // printk("aes_stat=0x%x\n", stat); - //udelay(100); - } while ((cnt++ < 1000000) && - !((stat=c7108_reg_rd16(C7108_AES_CTRL))&C7108_AES_OP_DONE)); - - - if ((mode == C7108_AES_CTRL_MODE_ECB)|| - (mode == C7108_AES_CTRL_MODE_CBC)) { - /* Save out key when the lock is held ... */ - c7108_aes_read_dkey(key); - } - - AES_UNLOCK(); - return 0; - -} - -/* - * Generate a new crypto device session. - */ -static int -c7108_newsession(void *arg, u_int32_t *sid, struct cryptoini *cri) -{ - struct cipher_7108 **swd; - u_int32_t i; - char *algo; - int mode, xfm_type; - - dprintk("%s()\n", __FUNCTION__); - if (sid == NULL || cri == NULL) { - dprintk("%s,%d - EINVAL\n", __FILE__, __LINE__); - return EINVAL; - } - - if (c7108_sessions) { - for (i = 1; i < c7108_sesnum; i++) - if (c7108_sessions[i] == NULL) - break; - } else - i = 1; /* NB: to silence compiler warning */ - - if (c7108_sessions == NULL || i == c7108_sesnum) { - if (c7108_sessions == NULL) { - i = 1; /* We leave c7108_sessions[0] empty */ - c7108_sesnum = CRYPTO_SW_SESSIONS; - } else - c7108_sesnum *= 2; - - swd = kmalloc(c7108_sesnum * sizeof(struct cipher_7108 *), - GFP_ATOMIC); - if (swd == NULL) { - /* Reset session number */ - if (c7108_sesnum == CRYPTO_SW_SESSIONS) - c7108_sesnum = 0; - else - c7108_sesnum /= 2; - dprintk("%s,%d: ENOBUFS\n", __FILE__, __LINE__); - return ENOBUFS; - } - memset(swd, 0, c7108_sesnum * sizeof(struct cipher_7108 *)); - - /* Copy existing sessions */ - if (c7108_sessions) { - memcpy(swd, c7108_sessions, - (c7108_sesnum / 2) * sizeof(struct cipher_7108 *)); - kfree(c7108_sessions); - } - - c7108_sessions = swd; - - } - - swd = &c7108_sessions[i]; - *sid = i; - - while (cri) { - *swd = (struct cipher_7108 *) - kmalloc(sizeof(struct cipher_7108), GFP_ATOMIC); - if (*swd == NULL) { - c7108_freesession(NULL, i); - dprintk("%s,%d: EINVAL\n", __FILE__, __LINE__); - return ENOBUFS; - } - memset(*swd, 0, sizeof(struct cipher_7108)); - - algo = NULL; - mode = 0; - xfm_type = HW_TYPE_CIPHER; - - switch (cri->cri_alg) { - - case CRYPTO_AES_CBC: - algo = "aes"; - mode = CRYPTO_TFM_MODE_CBC; - c7108_crypto_mode = C7108_AES_CTRL_MODE_CBC; - break; -#if 0 - case CRYPTO_AES_CTR: - algo = "aes_ctr"; - mode = CRYPTO_TFM_MODE_CBC; - c7108_crypto_mode = C7108_AES_CTRL_MODE_CTR; - break; - case CRYPTO_AES_ECB: - algo = "aes_ecb"; - mode = CRYPTO_TFM_MODE_CBC; - c7108_crypto_mode = C7108_AES_CTRL_MODE_ECB; - break; - case CRYPTO_AES_OFB: - algo = "aes_ofb"; - mode = CRYPTO_TFM_MODE_CBC; - c7108_crypto_mode = C7108_AES_CTRL_MODE_OFB; - break; - case CRYPTO_AES_CFB: - algo = "aes_cfb"; - mode = CRYPTO_TFM_MODE_CBC; - c7108_crypto_mode = C7108_AES_CTRL_MODE_CFB; - break; -#endif - default: - printk("unsupported crypto algorithm: %d\n", - cri->cri_alg); - return -EINVAL; - break; - } - - - if (!algo || !*algo) { - printk("cypher_7108_crypto: Unknown algo 0x%x\n", - cri->cri_alg); - c7108_freesession(NULL, i); - return EINVAL; - } - - if (xfm_type == HW_TYPE_CIPHER) { - if (debug) { - dprintk("%s key:", __FUNCTION__); - for (i = 0; i < (cri->cri_klen + 7) / 8; i++) - dprintk("%s0x%02x", (i % 8) ? " " : "\n ", - cri->cri_key[i]); - dprintk("\n"); - } - - } else if (xfm_type == SW_TYPE_HMAC || - xfm_type == SW_TYPE_HASH) { - printk("cypher_7108_crypto: HMAC unsupported!\n"); - return -EINVAL; - c7108_freesession(NULL, i); - } else { - printk("cypher_7108_crypto: " - "Unhandled xfm_type %d\n", xfm_type); - c7108_freesession(NULL, i); - return EINVAL; - } - - (*swd)->cri_alg = cri->cri_alg; - (*swd)->xfm_type = xfm_type; - - cri = cri->cri_next; - swd = &((*swd)->next); - } - return 0; -} - -/* - * Free a session. - */ -static int -c7108_freesession(void *arg, u_int64_t tid) -{ - struct cipher_7108 *swd; - u_int32_t sid = CRYPTO_SESID2LID(tid); - - dprintk("%s()\n", __FUNCTION__); - if (sid > c7108_sesnum || c7108_sessions == NULL || - c7108_sessions[sid] == NULL) { - dprintk("%s,%d: EINVAL\n", __FILE__, __LINE__); - return(EINVAL); - } - - /* Silently accept and return */ - if (sid == 0) - return(0); - - while ((swd = c7108_sessions[sid]) != NULL) { - c7108_sessions[sid] = swd->next; - kfree(swd); - } - return 0; -} - -/* - * Process a hardware request. - */ -static int -c7108_process(void *arg, struct cryptop *crp, int hint) -{ - struct cryptodesc *crd; - struct cipher_7108 *sw; - u_int32_t lid; - int type; - u32 hwkey[8]; - -#define SCATTERLIST_MAX 16 - struct scatterlist sg[SCATTERLIST_MAX]; - int sg_num, sg_len, skip; - struct sk_buff *skb = NULL; - struct uio *uiop = NULL; - - dprintk("%s()\n", __FUNCTION__); - /* Sanity check */ - if (crp == NULL) { - dprintk("%s,%d: EINVAL\n", __FILE__, __LINE__); - return EINVAL; - } - - crp->crp_etype = 0; - - if (crp->crp_desc == NULL || crp->crp_buf == NULL) { - dprintk("%s,%d: EINVAL\n", __FILE__, __LINE__); - crp->crp_etype = EINVAL; - goto done; - } - - lid = crp->crp_sid & 0xffffffff; - if (lid >= c7108_sesnum || lid == 0 || c7108_sessions == NULL || - c7108_sessions[lid] == NULL) { - crp->crp_etype = ENOENT; - dprintk("%s,%d: ENOENT\n", __FILE__, __LINE__); - goto done; - } - - /* - * do some error checking outside of the loop for SKB and IOV - * processing this leaves us with valid skb or uiop pointers - * for later - */ - if (crp->crp_flags & CRYPTO_F_SKBUF) { - skb = (struct sk_buff *) crp->crp_buf; - if (skb_shinfo(skb)->nr_frags >= SCATTERLIST_MAX) { - printk("%s,%d: %d nr_frags > SCATTERLIST_MAX", - __FILE__, __LINE__, - skb_shinfo(skb)->nr_frags); - goto done; - } - } else if (crp->crp_flags & CRYPTO_F_IOV) { - uiop = (struct uio *) crp->crp_buf; - if (uiop->uio_iovcnt > SCATTERLIST_MAX) { - printk("%s,%d: %d uio_iovcnt > SCATTERLIST_MAX", - __FILE__, __LINE__, - uiop->uio_iovcnt); - goto done; - } - } - - /* Go through crypto descriptors, processing as we go */ - for (crd = crp->crp_desc; crd; crd = crd->crd_next) { - /* - * Find the crypto context. - * - * XXX Note that the logic here prevents us from having - * XXX the same algorithm multiple times in a session - * XXX (or rather, we can but it won't give us the right - * XXX results). To do that, we'd need some way of differentiating - * XXX between the various instances of an algorithm (so we can - * XXX locate the correct crypto context). - */ - for (sw = c7108_sessions[lid]; - sw && sw->cri_alg != crd->crd_alg; - sw = sw->next) - ; - - /* No such context ? */ - if (sw == NULL) { - crp->crp_etype = EINVAL; - dprintk("%s,%d: EINVAL\n", __FILE__, __LINE__); - goto done; - } - - skip = crd->crd_skip; - - /* - * setup the SG list skip from the start of the buffer - */ - memset(sg, 0, sizeof(sg)); - if (crp->crp_flags & CRYPTO_F_SKBUF) { - int i, len; - type = CRYPTO_BUF_SKBUF; - - sg_num = 0; - sg_len = 0; - - if (skip < skb_headlen(skb)) { - //sg[sg_num].page = virt_to_page(skb->data + skip); - //sg[sg_num].offset = offset_in_page(skb->data + skip); - len = skb_headlen(skb) - skip; - if (len + sg_len > crd->crd_len) - len = crd->crd_len - sg_len; - //sg[sg_num].length = len; - sg_set_page(&sg[sg_num], virt_to_page(skb->data + skip), len, offset_in_page(skb->data + skip)); - sg_len += sg[sg_num].length; - sg_num++; - skip = 0; - } else - skip -= skb_headlen(skb); - - for (i = 0; sg_len < crd->crd_len && - i < skb_shinfo(skb)->nr_frags && - sg_num < SCATTERLIST_MAX; i++) { - if (skip < skb_shinfo(skb)->frags[i].size) { - //sg[sg_num].page = skb_shinfo(skb)->frags[i].page; - //sg[sg_num].offset = skb_shinfo(skb)->frags[i].page_offset + skip; - len = skb_shinfo(skb)->frags[i].size - skip; - if (len + sg_len > crd->crd_len) - len = crd->crd_len - sg_len; - //sg[sg_num].length = len; - sg_set_page(&sg[sg_num], skb_shinfo(skb)->frags[i].page, len, skb_shinfo(skb)->frags[i].page_offset + skip); - sg_len += sg[sg_num].length; - sg_num++; - skip = 0; - } else - skip -= skb_shinfo(skb)->frags[i].size; - } - } else if (crp->crp_flags & CRYPTO_F_IOV) { - int len; - type = CRYPTO_BUF_IOV; - sg_len = 0; - for (sg_num = 0; sg_len < crd->crd_len && - sg_num < uiop->uio_iovcnt && - sg_num < SCATTERLIST_MAX; sg_num++) { - if (skip < uiop->uio_iov[sg_num].iov_len) { - //sg[sg_num].page = virt_to_page(uiop->uio_iov[sg_num].iov_base+skip); - //sg[sg_num].offset = offset_in_page(uiop->uio_iov[sg_num].iov_base+skip); - len = uiop->uio_iov[sg_num].iov_len - skip; - if (len + sg_len > crd->crd_len) - len = crd->crd_len - sg_len; - //sg[sg_num].length = len; - sg_set_page(&sg[sg_num], virt_to_page(uiop->uio_iov[sg_num].iov_base+skip), len, offset_in_page(uiop->uio_iov[sg_num].iov_base+skip)); - sg_len += sg[sg_num].length; - skip = 0; - } else - skip -= uiop->uio_iov[sg_num].iov_len; - } - } else { - type = CRYPTO_BUF_CONTIG; - //sg[0].page = virt_to_page(crp->crp_buf + skip); - //sg[0].offset = offset_in_page(crp->crp_buf + skip); - sg_len = (crp->crp_ilen - skip); - if (sg_len > crd->crd_len) - sg_len = crd->crd_len; - //sg[0].length = sg_len; - sg_set_page(&sg[0], virt_to_page(crp->crp_buf + skip), sg_len, offset_in_page(crp->crp_buf + skip)); - sg_num = 1; - } - - - switch (sw->xfm_type) { - - case HW_TYPE_CIPHER: { - - unsigned char iv[64]; - unsigned char *ivp = iv; - int i; - int ivsize = 16; /* fixed for AES */ - int blocksize = 16; /* fixed for AES */ - - if (sg_len < blocksize) { - crp->crp_etype = EINVAL; - dprintk("%s,%d: EINVAL len %d < %d\n", - __FILE__, __LINE__, - sg_len, - blocksize); - goto done; - } - - if (ivsize > sizeof(iv)) { - crp->crp_etype = EINVAL; - dprintk("%s,%d: EINVAL\n", __FILE__, __LINE__); - goto done; - } - - if (crd->crd_flags & CRD_F_ENCRYPT) { /* encrypt */ - - if (crd->crd_flags & CRD_F_IV_EXPLICIT) { - ivp = crd->crd_iv; - } else { - get_random_bytes(ivp, ivsize); - } - /* - * do we have to copy the IV back to the buffer ? - */ - if ((crd->crd_flags & CRD_F_IV_PRESENT) == 0) { - crypto_copyback(crp->crp_buf, - crd->crd_inject, - ivsize, - (caddr_t)ivp); - } - - c7108_xlate_key(crd->crd_klen, - (u8*)crd->crd_key, (u32*)hwkey); - - /* Encrypt SG list */ - for (i = 0; i < sg_num; i++) { - sg[i].dma_address = - dma_map_single(NULL, - kmap(sg_page(&sg[i])) + sg[i].offset, sg_len, DMA_BIDIRECTIONAL); -#if 0 - printk("sg[%d]:0x%08x, off 0x%08x " - "kmap 0x%08x phys 0x%08x\n", - i, sg[i].page, sg[i].offset, - kmap(sg[i].page) + sg[i].offset, - sg[i].dma_address); -#endif - c7108_aes_cipher(C7108_AES_ENCRYPT, - sg[i].dma_address, - sg[i].dma_address, - sg_len, - crd->crd_klen, - c7108_crypto_mode, - hwkey, - ivp); - - if ((c7108_crypto_mode == C7108_AES_CTRL_MODE_CBC)|| - (c7108_crypto_mode == C7108_AES_CTRL_MODE_ECB)) { - /* Read back expanded key and cache it in key - * context. - * NOTE: for ECB/CBC modes only (not CTR, CFB, OFB) - * where you set the key once. - */ - c7108_cache_key(crd->crd_klen, - (u32*)hwkey, (u8*)crd->crd_key); -#if 0 - printk("%s expanded key:", __FUNCTION__); - for (i = 0; i < (crd->crd_klen + 7) / 8; i++) - printk("%s0x%02x", (i % 8) ? " " : "\n ", - crd->crd_key[i]); - printk("\n"); -#endif - } - } - } - else { /*decrypt */ - - if (crd->crd_flags & CRD_F_IV_EXPLICIT) { - ivp = crd->crd_iv; - } else { - crypto_copydata(crp->crp_buf, crd->crd_inject, - ivsize, (caddr_t)ivp); - } - - c7108_xlate_key(crd->crd_klen, - (u8*)crd->crd_key, (u32*)hwkey); - - /* Decrypt SG list */ - for (i = 0; i < sg_num; i++) { - sg[i].dma_address = - dma_map_single(NULL, - kmap(sg_page(&sg[i])) + sg[i].offset, - sg_len, DMA_BIDIRECTIONAL); - -#if 0 - printk("sg[%d]:0x%08x, off 0x%08x " - "kmap 0x%08x phys 0x%08x\n", - i, sg[i].page, sg[i].offset, - kmap(sg[i].page) + sg[i].offset, - sg[i].dma_address); -#endif - c7108_aes_cipher(C7108_AES_DECRYPT, - sg[i].dma_address, - sg[i].dma_address, - sg_len, - crd->crd_klen, - c7108_crypto_mode, - hwkey, - ivp); - } - } - } break; - case SW_TYPE_HMAC: - case SW_TYPE_HASH: - crp->crp_etype = EINVAL; - goto done; - break; - - case SW_TYPE_COMP: - crp->crp_etype = EINVAL; - goto done; - break; - - default: - /* Unknown/unsupported algorithm */ - dprintk("%s,%d: EINVAL\n", __FILE__, __LINE__); - crp->crp_etype = EINVAL; - goto done; - } - } - -done: - crypto_done(crp); - return 0; -} - -static struct { - softc_device_decl sc_dev; -} a7108dev; - -static device_method_t a7108_methods = { -/* crypto device methods */ - DEVMETHOD(cryptodev_newsession, c7108_newsession), - DEVMETHOD(cryptodev_freesession, c7108_freesession), - DEVMETHOD(cryptodev_process, c7108_process), - DEVMETHOD(cryptodev_kprocess, NULL) -}; - -static int -cypher_7108_crypto_init(void) -{ - dprintk("%s(%p)\n", __FUNCTION__, cypher_7108_crypto_init); - - iobar = (unsigned long)ioremap(CCU_AES_REG_BASE, 0x4000); - printk("7108: AES @ 0x%08x (0x%08x phys) %s mode\n", - iobar, CCU_AES_REG_BASE, - c7108_crypto_mode & C7108_AES_CTRL_MODE_CBC ? "CBC" : - c7108_crypto_mode & C7108_AES_CTRL_MODE_ECB ? "ECB" : - c7108_crypto_mode & C7108_AES_CTRL_MODE_CTR ? "CTR" : - c7108_crypto_mode & C7108_AES_CTRL_MODE_CFB ? "CFB" : - c7108_crypto_mode & C7108_AES_CTRL_MODE_OFB ? "OFB" : "???"); - csr_mutex = SPIN_LOCK_UNLOCKED; - - memset(&a7108dev, 0, sizeof(a7108dev)); - softc_device_init(&a7108dev, "aes7108", 0, a7108_methods); - - c7108_id = crypto_get_driverid(softc_get_device(&a7108dev), CRYPTOCAP_F_HARDWARE); - if (c7108_id < 0) - panic("7108: crypto device cannot initialize!"); - -// crypto_register(c7108_id, CRYPTO_AES_CBC, 0, 0, c7108_newsession, c7108_freesession, c7108_process, NULL); - crypto_register(c7108_id, CRYPTO_AES_CBC, 0, 0); - - return(0); -} - -static void -cypher_7108_crypto_exit(void) -{ - dprintk("%s()\n", __FUNCTION__); - crypto_unregister_all(c7108_id); - c7108_id = -1; -} - -module_init(cypher_7108_crypto_init); -module_exit(cypher_7108_crypto_exit); - -MODULE_LICENSE("Dual BSD/GPL"); -MODULE_DESCRIPTION("Cypher 7108 Crypto (OCF module for kernel crypto)"); diff --git a/target/linux/generic-2.4/files/crypto/ocf/c7108/aes-7108.h b/target/linux/generic-2.4/files/crypto/ocf/c7108/aes-7108.h deleted file mode 100644 index 0c7bfcb..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/c7108/aes-7108.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (C) 2006 Micronas USA - * - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR 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. - * - * Effort sponsored in part by the Defense Advanced Research Projects - * Agency (DARPA) and Air Force Research Laboratory, Air Force - * Materiel Command, USAF, under agreement number F30602-01-2-0537. - * - */ - -#ifndef __AES_7108_H__ -#define __AES_7108_H__ - -/* Cypher 7108 AES Controller Hardware */ -#define CCU_REG_BASE 0x1b500000 -#define CCU_AES_REG_BASE (CCU_REG_BASE + 0x100) -#define C7108_AES_KEY0_LO (0x0000) -#define C7108_AES_KEY0_HI (0x0004) -#define C7108_AES_KEY1_LO (0x0008) -#define C7108_AES_KEY1_HI (0x000c) -#define C7108_AES_KEY2_LO (0x0010) -#define C7108_AES_KEY2_HI (0x0014) -#define C7108_AES_KEY3_LO (0x0018) -#define C7108_AES_KEY3_HI (0x001c) -#define C7108_AES_KEY4_LO (0x0020) -#define C7108_AES_KEY4_HI (0x0024) -#define C7108_AES_KEY5_LO (0x0028) -#define C7108_AES_KEY5_HI (0x002c) -#define C7108_AES_KEY6_LO (0x0030) -#define C7108_AES_KEY6_HI (0x0034) -#define C7108_AES_KEY7_LO (0x0038) -#define C7108_AES_KEY7_HI (0x003c) -#define C7108_AES_IV0_LO (0x0040) -#define C7108_AES_IV0_HI (0x0044) -#define C7108_AES_IV1_LO (0x0048) -#define C7108_AES_IV1_HI (0x004c) -#define C7108_AES_IV2_LO (0x0050) -#define C7108_AES_IV2_HI (0x0054) -#define C7108_AES_IV3_LO (0x0058) -#define C7108_AES_IV3_HI (0x005c) - -#define C7108_AES_DMA_SRC0_LO (0x0068) /* Bits 0:15 */ -#define C7108_AES_DMA_SRC0_HI (0x006c) /* Bits 27:16 */ -#define C7108_AES_DMA_DST0_LO (0x0070) /* Bits 0:15 */ -#define C7108_AES_DMA_DST0_HI (0x0074) /* Bits 27:16 */ -#define C7108_AES_DMA_LEN (0x0078) /*Bytes:(Count+1)x16 */ - -/* AES/Copy engine control register */ -#define C7108_AES_CTRL (0x007c) /* AES control */ -#define C7108_AES_CTRL_RS (1<<0) /* Which set of src/dst to use */ - -/* AES Cipher mode, controlled by setting Bits 2:0 */ -#define C7108_AES_CTRL_MODE_CBC 0 -#define C7108_AES_CTRL_MODE_CFB (1<<0) -#define C7108_AES_CTRL_MODE_OFB (1<<1) -#define C7108_AES_CTRL_MODE_CTR ((1<<0)|(1<<1)) -#define C7108_AES_CTRL_MODE_ECB (1<<2) - -/* AES Key length , Bits 5:4 */ -#define C7108_AES_KEY_LEN_128 0 /* 00 */ -#define C7108_AES_KEY_LEN_192 (1<<4) /* 01 */ -#define C7108_AES_KEY_LEN_256 (1<<5) /* 10 */ - -/* AES Operation (crypt/decrypt), Bit 3 */ -#define C7108_AES_DECRYPT (1<<3) /* Clear for encrypt */ -#define C7108_AES_ENCRYPT 0 -#define C7108_AES_INTR (1<<13) /* Set on done trans from 0->1*/ -#define C7108_AES_GO (1<<14) /* Run */ -#define C7108_AES_OP_DONE (1<<15) /* Set when complete */ - - -/* Expanded key registers */ -#define C7108_AES_EKEY0_LO (0x0080) -#define C7108_AES_EKEY0_HI (0x0084) -#define C7108_AES_EKEY1_LO (0x0088) -#define C7108_AES_EKEY1_HI (0x008c) -#define C7108_AES_EKEY2_LO (0x0090) -#define C7108_AES_EKEY2_HI (0x0094) -#define C7108_AES_EKEY3_LO (0x0098) -#define C7108_AES_EKEY3_HI (0x009c) -#define C7108_AES_EKEY4_LO (0x00a0) -#define C7108_AES_EKEY4_HI (0x00a4) -#define C7108_AES_EKEY5_LO (0x00a8) -#define C7108_AES_EKEY5_HI (0x00ac) -#define C7108_AES_EKEY6_LO (0x00b0) -#define C7108_AES_EKEY6_HI (0x00b4) -#define C7108_AES_EKEY7_LO (0x00b8) -#define C7108_AES_EKEY7_HI (0x00bc) -#define C7108_AES_OK (0x00fc) /* Reset: "OK" */ - -#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK) - -/* Software session entry */ - -#define HW_TYPE_CIPHER 0 -#define SW_TYPE_HMAC 1 -#define SW_TYPE_AUTH2 2 -#define SW_TYPE_HASH 3 -#define SW_TYPE_COMP 4 - -struct cipher_7108 { - int xfm_type; - int cri_alg; - union { - struct { - char sw_key[HMAC_BLOCK_LEN]; - int sw_klen; - int sw_authlen; - } hmac; - } u; - struct cipher_7108 *next; -}; - - - -#endif /* __C7108_AES_7108_H__ */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/criov.c b/target/linux/generic-2.4/files/crypto/ocf/criov.c deleted file mode 100644 index 6d7d3ad..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/criov.c +++ /dev/null @@ -1,215 +0,0 @@ -/* $OpenBSD: criov.c,v 1.9 2002/01/29 15:48:29 jason Exp $ */ - -/* - * Linux port done by David McCullough <david_mccullough@mcafee.com> - * Copyright (C) 2006-2010 David McCullough - * Copyright (C) 2004-2005 Intel Corporation. - * The license and original author are listed below. - * - * Copyright (c) 1999 Theo de Raadt - * - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR 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. - * -__FBSDID("$FreeBSD: src/sys/opencrypto/criov.c,v 1.5 2006/06/04 22:15:13 pjd Exp $"); - */ - -#ifndef AUTOCONF_INCLUDED -#include <linux/config.h> -#endif -#include <linux/module.h> -#include <linux/init.h> -#include <linux/slab.h> -#include <linux/uio.h> -#include <linux/skbuff.h> -#include <linux/kernel.h> -#include <linux/mm.h> -#include <asm/io.h> - -#include <uio.h> -#include <cryptodev.h> - -/* - * This macro is only for avoiding code duplication, as we need to skip - * given number of bytes in the same way in three functions below. - */ -#define CUIO_SKIP() do { \ - KASSERT(off >= 0, ("%s: off %d < 0", __func__, off)); \ - KASSERT(len >= 0, ("%s: len %d < 0", __func__, len)); \ - while (off > 0) { \ - KASSERT(iol >= 0, ("%s: empty in skip", __func__)); \ - if (off < iov->iov_len) \ - break; \ - off -= iov->iov_len; \ - iol--; \ - iov++; \ - } \ -} while (0) - -void -cuio_copydata(struct uio* uio, int off, int len, caddr_t cp) -{ - struct iovec *iov = uio->uio_iov; - int iol = uio->uio_iovcnt; - unsigned count; - - CUIO_SKIP(); - while (len > 0) { - KASSERT(iol >= 0, ("%s: empty", __func__)); - count = min((int)(iov->iov_len - off), len); - memcpy(cp, ((caddr_t)iov->iov_base) + off, count); - len -= count; - cp += count; - off = 0; - iol--; - iov++; - } -} - -void -cuio_copyback(struct uio* uio, int off, int len, caddr_t cp) -{ - struct iovec *iov = uio->uio_iov; - int iol = uio->uio_iovcnt; - unsigned count; - - CUIO_SKIP(); - while (len > 0) { - KASSERT(iol >= 0, ("%s: empty", __func__)); - count = min((int)(iov->iov_len - off), len); - memcpy(((caddr_t)iov->iov_base) + off, cp, count); - len -= count; - cp += count; - off = 0; - iol--; - iov++; - } -} - -/* - * Return a pointer to iov/offset of location in iovec list. - */ -struct iovec * -cuio_getptr(struct uio *uio, int loc, int *off) -{ - struct iovec *iov = uio->uio_iov; - int iol = uio->uio_iovcnt; - - while (loc >= 0) { - /* Normal end of search */ - if (loc < iov->iov_len) { - *off = loc; - return (iov); - } - - loc -= iov->iov_len; - if (iol == 0) { - if (loc == 0) { - /* Point at the end of valid data */ - *off = iov->iov_len; - return (iov); - } else - return (NULL); - } else { - iov++, iol--; - } - } - - return (NULL); -} - -EXPORT_SYMBOL(cuio_copyback); -EXPORT_SYMBOL(cuio_copydata); -EXPORT_SYMBOL(cuio_getptr); - - -static void -skb_copy_bits_back(struct sk_buff *skb, int offset, caddr_t cp, int len) -{ - int i; - if (offset < skb_headlen(skb)) { - memcpy(skb->data + offset, cp, min_t(int, skb_headlen(skb), len)); - len -= skb_headlen(skb); - cp += skb_headlen(skb); - } - offset -= skb_headlen(skb); - for (i = 0; len > 0 && i < skb_shinfo(skb)->nr_frags; i++) { - if (offset < skb_shinfo(skb)->frags[i].size) { - memcpy(page_address(skb_shinfo(skb)->frags[i].page) + - skb_shinfo(skb)->frags[i].page_offset, - cp, min_t(int, skb_shinfo(skb)->frags[i].size, len)); - len -= skb_shinfo(skb)->frags[i].size; - cp += skb_shinfo(skb)->frags[i].size; - } - offset -= skb_shinfo(skb)->frags[i].size; - } -} - -void -crypto_copyback(int flags, caddr_t buf, int off, int size, caddr_t in) -{ - - if ((flags & CRYPTO_F_SKBUF) != 0) - skb_copy_bits_back((struct sk_buff *)buf, off, in, size); - else if ((flags & CRYPTO_F_IOV) != 0) - cuio_copyback((struct uio *)buf, off, size, in); - else - bcopy(in, buf + off, size); -} - -void -crypto_copydata(int flags, caddr_t buf, int off, int size, caddr_t out) -{ - - if ((flags & CRYPTO_F_SKBUF) != 0) - skb_copy_bits((struct sk_buff *)buf, off, out, size); - else if ((flags & CRYPTO_F_IOV) != 0) - cuio_copydata((struct uio *)buf, off, size, out); - else - bcopy(buf + off, out, size); -} - -int -crypto_apply(int flags, caddr_t buf, int off, int len, - int (*f)(void *, void *, u_int), void *arg) -{ -#if 0 - int error; - - if ((flags & CRYPTO_F_SKBUF) != 0) - error = XXXXXX((struct mbuf *)buf, off, len, f, arg); - else if ((flags & CRYPTO_F_IOV) != 0) - error = cuio_apply((struct uio *)buf, off, len, f, arg); - else - error = (*f)(arg, buf + off, len); - return (error); -#else - KASSERT(0, ("crypto_apply not implemented!\n")); -#endif - return 0; -} - -EXPORT_SYMBOL(crypto_copyback); -EXPORT_SYMBOL(crypto_copydata); -EXPORT_SYMBOL(crypto_apply); - diff --git a/target/linux/generic-2.4/files/crypto/ocf/crypto.c b/target/linux/generic-2.4/files/crypto/ocf/crypto.c deleted file mode 100644 index 9735f0c..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/crypto.c +++ /dev/null @@ -1,1784 +0,0 @@ -/*- - * Linux port done by David McCullough <david_mccullough@mcafee.com> - * Copyright (C) 2006-2010 David McCullough - * Copyright (C) 2004-2005 Intel Corporation. - * The license and original author are listed below. - * - * Redistribution and use in source and binary forms, with or without - * Copyright (c) 2002-2006 Sam Leffler. All rights reserved. - * - * 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 AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR 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. - */ - -#if 0 -#include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/opencrypto/crypto.c,v 1.27 2007/03/21 03:42:51 sam Exp $"); -#endif - -/* - * Cryptographic Subsystem. - * - * This code is derived from the Openbsd Cryptographic Framework (OCF) - * that has the copyright shown below. Very little of the original - * code remains. - */ -/*- - * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu) - * - * This code was written by Angelos D. Keromytis in Athens, Greece, in - * February 2000. Network Security Technologies Inc. (NSTI) kindly - * supported the development of this code. - * - * Copyright (c) 2000, 2001 Angelos D. Keromytis - * - * Permission to use, copy, and modify this software with or without fee - * is hereby granted, provided that this entire notice is included in - * all source code copies of any software which is or includes a copy or - * modification of this software. - * - * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY - * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE - * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR - * PURPOSE. - * -__FBSDID("$FreeBSD: src/sys/opencrypto/crypto.c,v 1.16 2005/01/07 02:29:16 imp Exp $"); - */ - - -#ifndef AUTOCONF_INCLUDED -#include <linux/config.h> -#endif -#include <linux/module.h> -#include <linux/init.h> -#include <linux/list.h> -#include <linux/slab.h> -#include <linux/wait.h> -#include <linux/sched.h> -#include <linux/spinlock.h> -#include <linux/version.h> -#include <cryptodev.h> - -/* - * keep track of whether or not we have been initialised, a big - * issue if we are linked into the kernel and a driver gets started before - * us - */ -static int crypto_initted = 0; - -/* - * Crypto drivers register themselves by allocating a slot in the - * crypto_drivers table with crypto_get_driverid() and then registering - * each algorithm they support with crypto_register() and crypto_kregister(). - */ - -/* - * lock on driver table - * we track its state as spin_is_locked does not do anything on non-SMP boxes - */ -static spinlock_t crypto_drivers_lock; -static int crypto_drivers_locked; /* for non-SMP boxes */ - -#define CRYPTO_DRIVER_LOCK() \ - ({ \ - spin_lock_irqsave(&crypto_drivers_lock, d_flags); \ - crypto_drivers_locked = 1; \ - dprintk("%s,%d: DRIVER_LOCK()\n", __FILE__, __LINE__); \ - }) -#define CRYPTO_DRIVER_UNLOCK() \ - ({ \ - dprintk("%s,%d: DRIVER_UNLOCK()\n", __FILE__, __LINE__); \ - crypto_drivers_locked = 0; \ - spin_unlock_irqrestore(&crypto_drivers_lock, d_flags); \ - }) -#define CRYPTO_DRIVER_ASSERT() \ - ({ \ - if (!crypto_drivers_locked) { \ - dprintk("%s,%d: DRIVER_ASSERT!\n", __FILE__, __LINE__); \ - } \ - }) - -/* - * Crypto device/driver capabilities structure. - * - * Synchronization: - * (d) - protected by CRYPTO_DRIVER_LOCK() - * (q) - protected by CRYPTO_Q_LOCK() - * Not tagged fields are read-only. - */ -struct cryptocap { - device_t cc_dev; /* (d) device/driver */ - u_int32_t cc_sessions; /* (d) # of sessions */ - u_int32_t cc_koperations; /* (d) # os asym operations */ - /* - * Largest possible operator length (in bits) for each type of - * encryption algorithm. XXX not used - */ - u_int16_t cc_max_op_len[CRYPTO_ALGORITHM_MAX + 1]; - u_int8_t cc_alg[CRYPTO_ALGORITHM_MAX + 1]; - u_int8_t cc_kalg[CRK_ALGORITHM_MAX + 1]; - - int cc_flags; /* (d) flags */ -#define CRYPTOCAP_F_CLEANUP 0x80000000 /* needs resource cleanup */ - int cc_qblocked; /* (q) symmetric q blocked */ - int cc_kqblocked; /* (q) asymmetric q blocked */ - - int cc_unqblocked; /* (q) symmetric q blocked */ - int cc_unkqblocked; /* (q) asymmetric q blocked */ -}; -static struct cryptocap *crypto_drivers = NULL; -static int crypto_drivers_num = 0; - -/* - * There are two queues for crypto requests; one for symmetric (e.g. - * cipher) operations and one for asymmetric (e.g. MOD)operations. - * A single mutex is used to lock access to both queues. We could - * have one per-queue but having one simplifies handling of block/unblock - * operations. - */ -static int crp_sleep = 0; -static LIST_HEAD(crp_q); /* request queues */ -static LIST_HEAD(crp_kq); - -static spinlock_t crypto_q_lock; - -int crypto_all_qblocked = 0; /* protect with Q_LOCK */ -module_param(crypto_all_qblocked, int, 0444); -MODULE_PARM_DESC(crypto_all_qblocked, "Are all crypto queues blocked"); - -int crypto_all_kqblocked = 0; /* protect with Q_LOCK */ -module_param(crypto_all_kqblocked, int, 0444); -MODULE_PARM_DESC(crypto_all_kqblocked, "Are all asym crypto queues blocked"); - -#define CRYPTO_Q_LOCK() \ - ({ \ - spin_lock_irqsave(&crypto_q_lock, q_flags); \ - dprintk("%s,%d: Q_LOCK()\n", __FILE__, __LINE__); \ - }) -#define CRYPTO_Q_UNLOCK() \ - ({ \ - dprintk("%s,%d: Q_UNLOCK()\n", __FILE__, __LINE__); \ - spin_unlock_irqrestore(&crypto_q_lock, q_flags); \ - }) - -/* - * There are two queues for processing completed crypto requests; one - * for the symmetric and one for the asymmetric ops. We only need one - * but have two to avoid type futzing (cryptop vs. cryptkop). A single - * mutex is used to lock access to both queues. Note that this lock - * must be separate from the lock on request queues to insure driver - * callbacks don't generate lock order reversals. - */ -static LIST_HEAD(crp_ret_q); /* callback queues */ -static LIST_HEAD(crp_ret_kq); - -static spinlock_t crypto_ret_q_lock; -#define CRYPTO_RETQ_LOCK() \ - ({ \ - spin_lock_irqsave(&crypto_ret_q_lock, r_flags); \ - dprintk("%s,%d: RETQ_LOCK\n", __FILE__, __LINE__); \ - }) -#define CRYPTO_RETQ_UNLOCK() \ - ({ \ - dprintk("%s,%d: RETQ_UNLOCK\n", __FILE__, __LINE__); \ - spin_unlock_irqrestore(&crypto_ret_q_lock, r_flags); \ - }) -#define CRYPTO_RETQ_EMPTY() (list_empty(&crp_ret_q) && list_empty(&crp_ret_kq)) - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) -static kmem_cache_t *cryptop_zone; -static kmem_cache_t *cryptodesc_zone; -#else -static struct kmem_cache *cryptop_zone; -static struct kmem_cache *cryptodesc_zone; -#endif - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) -#include <linux/sched.h> -#define kill_proc(p,s,v) send_sig(s,find_task_by_vpid(p),0) -#endif - -#define debug crypto_debug -int crypto_debug = 0; -module_param(crypto_debug, int, 0644); -MODULE_PARM_DESC(crypto_debug, "Enable debug"); -EXPORT_SYMBOL(crypto_debug); - -/* - * Maximum number of outstanding crypto requests before we start - * failing requests. We need this to prevent DOS when too many - * requests are arriving for us to keep up. Otherwise we will - * run the system out of memory. Since crypto is slow, we are - * usually the bottleneck that needs to say, enough is enough. - * - * We cannot print errors when this condition occurs, we are already too - * slow, printing anything will just kill us - */ - -static int crypto_q_cnt = 0; -module_param(crypto_q_cnt, int, 0444); -MODULE_PARM_DESC(crypto_q_cnt, - "Current number of outstanding crypto requests"); - -static int crypto_q_max = 1000; -module_param(crypto_q_max, int, 0644); -MODULE_PARM_DESC(crypto_q_max, - "Maximum number of outstanding crypto requests"); - -#define bootverbose crypto_verbose -static int crypto_verbose = 0; -module_param(crypto_verbose, int, 0644); -MODULE_PARM_DESC(crypto_verbose, - "Enable verbose crypto startup"); - -int crypto_usercrypto = 1; /* userland may do crypto reqs */ -module_param(crypto_usercrypto, int, 0644); -MODULE_PARM_DESC(crypto_usercrypto, - "Enable/disable user-mode access to crypto support"); - -int crypto_userasymcrypto = 1; /* userland may do asym crypto reqs */ -module_param(crypto_userasymcrypto, int, 0644); -MODULE_PARM_DESC(crypto_userasymcrypto, - "Enable/disable user-mode access to asymmetric crypto support"); - -int crypto_devallowsoft = 0; /* only use hardware crypto */ -module_param(crypto_devallowsoft, int, 0644); -MODULE_PARM_DESC(crypto_devallowsoft, - "Enable/disable use of software crypto support"); - -/* - * This parameter controls the maximum number of crypto operations to - * do consecutively in the crypto kernel thread before scheduling to allow - * other processes to run. Without it, it is possible to get into a - * situation where the crypto thread never allows any other processes to run. - * Default to 1000 which should be less than one second. - */ -static int crypto_max_loopcount = 1000; -module_param(crypto_max_loopcount, int, 0644); -MODULE_PARM_DESC(crypto_max_loopcount, - "Maximum number of crypto ops to do before yielding to other processes"); - -static pid_t cryptoproc = (pid_t) -1; -static struct completion cryptoproc_exited; -static DECLARE_WAIT_QUEUE_HEAD(cryptoproc_wait); -static pid_t cryptoretproc = (pid_t) -1; -static struct completion cryptoretproc_exited; -static DECLARE_WAIT_QUEUE_HEAD(cryptoretproc_wait); - -static int crypto_proc(void *arg); -static int crypto_ret_proc(void *arg); -static int crypto_invoke(struct cryptocap *cap, struct cryptop *crp, int hint); -static int crypto_kinvoke(struct cryptkop *krp, int flags); -static void crypto_exit(void); -static int crypto_init(void); - -static struct cryptostats cryptostats; - -static struct cryptocap * -crypto_checkdriver(u_int32_t hid) -{ - if (crypto_drivers == NULL) - return NULL; - return (hid >= crypto_drivers_num ? NULL : &crypto_drivers[hid]); -} - -/* - * Compare a driver's list of supported algorithms against another - * list; return non-zero if all algorithms are supported. - */ -static int -driver_suitable(const struct cryptocap *cap, const struct cryptoini *cri) -{ - const struct cryptoini *cr; - - /* See if all the algorithms are supported. */ - for (cr = cri; cr; cr = cr->cri_next) - if (cap->cc_alg[cr->cri_alg] == 0) - return 0; - return 1; -} - -/* - * Select a driver for a new session that supports the specified - * algorithms and, optionally, is constrained according to the flags. - * The algorithm we use here is pretty stupid; just use the - * first driver that supports all the algorithms we need. If there - * are multiple drivers we choose the driver with the fewest active - * sessions. We prefer hardware-backed drivers to software ones. - * - * XXX We need more smarts here (in real life too, but that's - * XXX another story altogether). - */ -static struct cryptocap * -crypto_select_driver(const struct cryptoini *cri, int flags) -{ - struct cryptocap *cap, *best; - int match, hid; - - CRYPTO_DRIVER_ASSERT(); - - /* - * Look first for hardware crypto devices if permitted. - */ - if (flags & CRYPTOCAP_F_HARDWARE) - match = CRYPTOCAP_F_HARDWARE; - else - match = CRYPTOCAP_F_SOFTWARE; - best = NULL; -again: - for (hid = 0; hid < crypto_drivers_num; hid++) { - cap = &crypto_drivers[hid]; - /* - * If it's not initialized, is in the process of - * going away, or is not appropriate (hardware - * or software based on match), then skip. - */ - if (cap->cc_dev == NULL || - (cap->cc_flags & CRYPTOCAP_F_CLEANUP) || - (cap->cc_flags & match) == 0) - continue; - - /* verify all the algorithms are supported. */ - if (driver_suitable(cap, cri)) { - if (best == NULL || - cap->cc_sessions < best->cc_sessions) - best = cap; - } - } - if (best != NULL) - return best; - if (match == CRYPTOCAP_F_HARDWARE && (flags & CRYPTOCAP_F_SOFTWARE)) { - /* sort of an Algol 68-style for loop */ - match = CRYPTOCAP_F_SOFTWARE; - goto again; - } - return best; -} - -/* - * Create a new session. The crid argument specifies a crypto - * driver to use or constraints on a driver to select (hardware - * only, software only, either). Whatever driver is selected - * must be capable of the requested crypto algorithms. - */ -int -crypto_newsession(u_int64_t *sid, struct cryptoini *cri, int crid) -{ - struct cryptocap *cap; - u_int32_t hid, lid; - int err; - unsigned long d_flags; - - CRYPTO_DRIVER_LOCK(); - if ((crid & (CRYPTOCAP_F_HARDWARE | CRYPTOCAP_F_SOFTWARE)) == 0) { - /* - * Use specified driver; verify it is capable. - */ - cap = crypto_checkdriver(crid); - if (cap != NULL && !driver_suitable(cap, cri)) - cap = NULL; - } else { - /* - * No requested driver; select based on crid flags. - */ - cap = crypto_select_driver(cri, crid); - /* - * if NULL then can't do everything in one session. - * XXX Fix this. We need to inject a "virtual" session - * XXX layer right about here. - */ - } - if (cap != NULL) { - /* Call the driver initialization routine. */ - hid = cap - crypto_drivers; - lid = hid; /* Pass the driver ID. */ - cap->cc_sessions++; - CRYPTO_DRIVER_UNLOCK(); - err = CRYPTODEV_NEWSESSION(cap->cc_dev, &lid, cri); - CRYPTO_DRIVER_LOCK(); - if (err == 0) { - (*sid) = (cap->cc_flags & 0xff000000) - | (hid & 0x00ffffff); - (*sid) <<= 32; - (*sid) |= (lid & 0xffffffff); - } else - cap->cc_sessions--; - } else - err = EINVAL; - CRYPTO_DRIVER_UNLOCK(); - return err; -} - -static void -crypto_remove(struct cryptocap *cap) -{ - CRYPTO_DRIVER_ASSERT(); - if (cap->cc_sessions == 0 && cap->cc_koperations == 0) - bzero(cap, sizeof(*cap)); -} - -/* - * Delete an existing session (or a reserved session on an unregistered - * driver). - */ -int -crypto_freesession(u_int64_t sid) -{ - struct cryptocap *cap; - u_int32_t hid; - int err = 0; - unsigned long d_flags; - - dprintk("%s()\n", __FUNCTION__); - CRYPTO_DRIVER_LOCK(); - - if (crypto_drivers == NULL) { - err = EINVAL; - goto done; - } - - /* Determine two IDs. */ - hid = CRYPTO_SESID2HID(sid); - - if (hid >= crypto_drivers_num) { - dprintk("%s - INVALID DRIVER NUM %d\n", __FUNCTION__, hid); - err = ENOENT; - goto done; - } - cap = &crypto_drivers[hid]; - - if (cap->cc_dev) { - CRYPTO_DRIVER_UNLOCK(); - /* Call the driver cleanup routine, if available, unlocked. */ - err = CRYPTODEV_FREESESSION(cap->cc_dev, sid); - CRYPTO_DRIVER_LOCK(); - } - - if (cap->cc_sessions) - cap->cc_sessions--; - - if (cap->cc_flags & CRYPTOCAP_F_CLEANUP) - crypto_remove(cap); - -done: - CRYPTO_DRIVER_UNLOCK(); - return err; -} - -/* - * Return an unused driver id. Used by drivers prior to registering - * support for the algorithms they handle. - */ -int32_t -crypto_get_driverid(device_t dev, int flags) -{ - struct cryptocap *newdrv; - int i; - unsigned long d_flags; - - if ((flags & (CRYPTOCAP_F_HARDWARE | CRYPTOCAP_F_SOFTWARE)) == 0) { - printf("%s: no flags specified when registering driver\n", - device_get_nameunit(dev)); - return -1; - } - - CRYPTO_DRIVER_LOCK(); - - for (i = 0; i < crypto_drivers_num; i++) { - if (crypto_drivers[i].cc_dev == NULL && - (crypto_drivers[i].cc_flags & CRYPTOCAP_F_CLEANUP) == 0) { - break; - } - } - - /* Out of entries, allocate some more. */ - if (i == crypto_drivers_num) { - /* Be careful about wrap-around. */ - if (2 * crypto_drivers_num <= crypto_drivers_num) { - CRYPTO_DRIVER_UNLOCK(); - printk("crypto: driver count wraparound!\n"); - return -1; - } - - newdrv = kmalloc(2 * crypto_drivers_num * sizeof(struct cryptocap), - GFP_KERNEL); - if (newdrv == NULL) { - CRYPTO_DRIVER_UNLOCK(); - printk("crypto: no space to expand driver table!\n"); - return -1; - } - - memcpy(newdrv, crypto_drivers, - crypto_drivers_num * sizeof(struct cryptocap)); - memset(&newdrv[crypto_drivers_num], 0, - crypto_drivers_num * sizeof(struct cryptocap)); - - crypto_drivers_num *= 2; - - kfree(crypto_drivers); - crypto_drivers = newdrv; - } - - /* NB: state is zero'd on free */ - crypto_drivers[i].cc_sessions = 1; /* Mark */ - crypto_drivers[i].cc_dev = dev; - crypto_drivers[i].cc_flags = flags; - if (bootverbose) - printf("crypto: assign %s driver id %u, flags %u\n", - device_get_nameunit(dev), i, flags); - - CRYPTO_DRIVER_UNLOCK(); - - return i; -} - -/* - * Lookup a driver by name. We match against the full device - * name and unit, and against just the name. The latter gives - * us a simple widlcarding by device name. On success return the - * driver/hardware identifier; otherwise return -1. - */ -int -crypto_find_driver(const char *match) -{ - int i, len = strlen(match); - unsigned long d_flags; - - CRYPTO_DRIVER_LOCK(); - for (i = 0; i < crypto_drivers_num; i++) { - device_t dev = crypto_drivers[i].cc_dev; - if (dev == NULL || - (crypto_drivers[i].cc_flags & CRYPTOCAP_F_CLEANUP)) - continue; - if (strncmp(match, device_get_nameunit(dev), len) == 0 || - strncmp(match, device_get_name(dev), len) == 0) - break; - } - CRYPTO_DRIVER_UNLOCK(); - return i < crypto_drivers_num ? i : -1; -} - -/* - * Return the device_t for the specified driver or NULL - * if the driver identifier is invalid. - */ -device_t -crypto_find_device_byhid(int hid) -{ - struct cryptocap *cap = crypto_checkdriver(hid); - return cap != NULL ? cap->cc_dev : NULL; -} - -/* - * Return the device/driver capabilities. - */ -int -crypto_getcaps(int hid) -{ - struct cryptocap *cap = crypto_checkdriver(hid); - return cap != NULL ? cap->cc_flags : 0; -} - -/* - * Register support for a key-related algorithm. This routine - * is called once for each algorithm supported a driver. - */ -int -crypto_kregister(u_int32_t driverid, int kalg, u_int32_t flags) -{ - struct cryptocap *cap; - int err; - unsigned long d_flags; - - dprintk("%s()\n", __FUNCTION__); - CRYPTO_DRIVER_LOCK(); - - cap = crypto_checkdriver(driverid); - if (cap != NULL && - (CRK_ALGORITM_MIN <= kalg && kalg <= CRK_ALGORITHM_MAX)) { - /* - * XXX Do some performance testing to determine placing. - * XXX We probably need an auxiliary data structure that - * XXX describes relative performances. - */ - - cap->cc_kalg[kalg] = flags | CRYPTO_ALG_FLAG_SUPPORTED; - if (bootverbose) - printf("crypto: %s registers key alg %u flags %u\n" - , device_get_nameunit(cap->cc_dev) - , kalg - , flags - ); - err = 0; - } else - err = EINVAL; - - CRYPTO_DRIVER_UNLOCK(); - return err; -} - -/* - * Register support for a non-key-related algorithm. This routine - * is called once for each such algorithm supported by a driver. - */ -int -crypto_register(u_int32_t driverid, int alg, u_int16_t maxoplen, - u_int32_t flags) -{ - struct cryptocap *cap; - int err; - unsigned long d_flags; - - dprintk("%s(id=0x%x, alg=%d, maxoplen=%d, flags=0x%x)\n", __FUNCTION__, - driverid, alg, maxoplen, flags); - - CRYPTO_DRIVER_LOCK(); - - cap = crypto_checkdriver(driverid); - /* NB: algorithms are in the range [1..max] */ - if (cap != NULL && - (CRYPTO_ALGORITHM_MIN <= alg && alg <= CRYPTO_ALGORITHM_MAX)) { - /* - * XXX Do some performance testing to determine placing. - * XXX We probably need an auxiliary data structure that - * XXX describes relative performances. - */ - - cap->cc_alg[alg] = flags | CRYPTO_ALG_FLAG_SUPPORTED; - cap->cc_max_op_len[alg] = maxoplen; - if (bootverbose) - printf("crypto: %s registers alg %u flags %u maxoplen %u\n" - , device_get_nameunit(cap->cc_dev) - , alg - , flags - , maxoplen - ); - cap->cc_sessions = 0; /* Unmark */ - err = 0; - } else - err = EINVAL; - - CRYPTO_DRIVER_UNLOCK(); - return err; -} - -static void -driver_finis(struct cryptocap *cap) -{ - u_int32_t ses, kops; - - CRYPTO_DRIVER_ASSERT(); - - ses = cap->cc_sessions; - kops = cap->cc_koperations; - bzero(cap, sizeof(*cap)); - if (ses != 0 || kops != 0) { - /* - * If there are pending sessions, - * just mark as invalid. - */ - cap->cc_flags |= CRYPTOCAP_F_CLEANUP; - cap->cc_sessions = ses; - cap->cc_koperations = kops; - } -} - -/* - * Unregister a crypto driver. If there are pending sessions using it, - * leave enough information around so that subsequent calls using those - * sessions will correctly detect the driver has been unregistered and - * reroute requests. - */ -int -crypto_unregister(u_int32_t driverid, int alg) -{ - struct cryptocap *cap; - int i, err; - unsigned long d_flags; - - dprintk("%s()\n", __FUNCTION__); - CRYPTO_DRIVER_LOCK(); - - cap = crypto_checkdriver(driverid); - if (cap != NULL && - (CRYPTO_ALGORITHM_MIN <= alg && alg <= CRYPTO_ALGORITHM_MAX) && - cap->cc_alg[alg] != 0) { - cap->cc_alg[alg] = 0; - cap->cc_max_op_len[alg] = 0; - - /* Was this the last algorithm ? */ - for (i = 1; i <= CRYPTO_ALGORITHM_MAX; i++) - if (cap->cc_alg[i] != 0) - break; - - if (i == CRYPTO_ALGORITHM_MAX + 1) - driver_finis(cap); - err = 0; - } else - err = EINVAL; - CRYPTO_DRIVER_UNLOCK(); - return err; -} - -/* - * Unregister all algorithms associated with a crypto driver. - * If there are pending sessions using it, leave enough information - * around so that subsequent calls using those sessions will - * correctly detect the driver has been unregistered and reroute - * requests. - */ -int -crypto_unregister_all(u_int32_t driverid) -{ - struct cryptocap *cap; - int err; - unsigned long d_flags; - - dprintk("%s()\n", __FUNCTION__); - CRYPTO_DRIVER_LOCK(); - cap = crypto_checkdriver(driverid); - if (cap != NULL) { - driver_finis(cap); - err = 0; - } else - err = EINVAL; - CRYPTO_DRIVER_UNLOCK(); - - return err; -} - -/* - * Clear blockage on a driver. The what parameter indicates whether - * the driver is now ready for cryptop's and/or cryptokop's. - */ -int -crypto_unblock(u_int32_t driverid, int what) -{ - struct cryptocap *cap; - int err; - unsigned long q_flags; - - CRYPTO_Q_LOCK(); - cap = crypto_checkdriver(driverid); - if (cap != NULL) { - if (what & CRYPTO_SYMQ) { - cap->cc_qblocked = 0; - cap->cc_unqblocked = 0; - crypto_all_qblocked = 0; - } - if (what & CRYPTO_ASYMQ) { - cap->cc_kqblocked = 0; - cap->cc_unkqblocked = 0; - crypto_all_kqblocked = 0; - } - if (crp_sleep) - wake_up_interruptible(&cryptoproc_wait); - err = 0; - } else - err = EINVAL; - CRYPTO_Q_UNLOCK(); //DAVIDM should this be a driver lock - - return err; -} - -/* - * Add a crypto request to a queue, to be processed by the kernel thread. - */ -int -crypto_dispatch(struct cryptop *crp) -{ - struct cryptocap *cap; - int result = -1; - unsigned long q_flags; - - dprintk("%s()\n", __FUNCTION__); - - cryptostats.cs_ops++; - - CRYPTO_Q_LOCK(); - if (crypto_q_cnt >= crypto_q_max) { - CRYPTO_Q_UNLOCK(); - cryptostats.cs_drops++; - return ENOMEM; - } - crypto_q_cnt++; - - /* make sure we are starting a fresh run on this crp. */ - crp->crp_flags &= ~CRYPTO_F_DONE; - crp->crp_etype = 0; - - /* - * Caller marked the request to be processed immediately; dispatch - * it directly to the driver unless the driver is currently blocked. - */ - if ((crp->crp_flags & CRYPTO_F_BATCH) == 0) { - int hid = CRYPTO_SESID2HID(crp->crp_sid); - cap = crypto_checkdriver(hid); - /* Driver cannot disappear when there is an active session. */ - KASSERT(cap != NULL, ("%s: Driver disappeared.", __func__)); - if (!cap->cc_qblocked) { - crypto_all_qblocked = 0; - crypto_drivers[hid].cc_unqblocked = 1; - CRYPTO_Q_UNLOCK(); - result = crypto_invoke(cap, crp, 0); - CRYPTO_Q_LOCK(); - if (result == ERESTART) - if (crypto_drivers[hid].cc_unqblocked) - crypto_drivers[hid].cc_qblocked = 1; - crypto_drivers[hid].cc_unqblocked = 0; - } - } - if (result == ERESTART) { - /* - * The driver ran out of resources, mark the - * driver ``blocked'' for cryptop's and put - * the request back in the queue. It would - * best to put the request back where we got - * it but that's hard so for now we put it - * at the front. This should be ok; putting - * it at the end does not work. - */ - list_add(&crp->crp_next, &crp_q); - cryptostats.cs_blocks++; - result = 0; - } else if (result == -1) { - TAILQ_INSERT_TAIL(&crp_q, crp, crp_next); - result = 0; - } - if (crp_sleep) - wake_up_interruptible(&cryptoproc_wait); - CRYPTO_Q_UNLOCK(); - return result; -} - -/* - * Add an asymetric crypto request to a queue, - * to be processed by the kernel thread. - */ -int -crypto_kdispatch(struct cryptkop *krp) -{ - int error; - unsigned long q_flags; - - cryptostats.cs_kops++; - - error = crypto_kinvoke(krp, krp->krp_crid); - if (error == ERESTART) { - CRYPTO_Q_LOCK(); - TAILQ_INSERT_TAIL(&crp_kq, krp, krp_next); - if (crp_sleep) - wake_up_interruptible(&cryptoproc_wait); - CRYPTO_Q_UNLOCK(); - error = 0; - } - return error; -} - -/* - * Verify a driver is suitable for the specified operation. - */ -static __inline int -kdriver_suitable(const struct cryptocap *cap, const struct cryptkop *krp) -{ - return (cap->cc_kalg[krp->krp_op] & CRYPTO_ALG_FLAG_SUPPORTED) != 0; -} - -/* - * Select a driver for an asym operation. The driver must - * support the necessary algorithm. The caller can constrain - * which device is selected with the flags parameter. The - * algorithm we use here is pretty stupid; just use the first - * driver that supports the algorithms we need. If there are - * multiple suitable drivers we choose the driver with the - * fewest active operations. We prefer hardware-backed - * drivers to software ones when either may be used. - */ -static struct cryptocap * -crypto_select_kdriver(const struct cryptkop *krp, int flags) -{ - struct cryptocap *cap, *best, *blocked; - int match, hid; - - CRYPTO_DRIVER_ASSERT(); - - /* - * Look first for hardware crypto devices if permitted. - */ - if (flags & CRYPTOCAP_F_HARDWARE) - match = CRYPTOCAP_F_HARDWARE; - else - match = CRYPTOCAP_F_SOFTWARE; - best = NULL; - blocked = NULL; -again: - for (hid = 0; hid < crypto_drivers_num; hid++) { - cap = &crypto_drivers[hid]; - /* - * If it's not initialized, is in the process of - * going away, or is not appropriate (hardware - * or software based on match), then skip. - */ - if (cap->cc_dev == NULL || - (cap->cc_flags & CRYPTOCAP_F_CLEANUP) || - (cap->cc_flags & match) == 0) - continue; - - /* verify all the algorithms are supported. */ - if (kdriver_suitable(cap, krp)) { - if (best == NULL || - cap->cc_koperations < best->cc_koperations) - best = cap; - } - } - if (best != NULL) - return best; - if (match == CRYPTOCAP_F_HARDWARE && (flags & CRYPTOCAP_F_SOFTWARE)) { - /* sort of an Algol 68-style for loop */ - match = CRYPTOCAP_F_SOFTWARE; - goto again; - } - return best; -} - -/* - * Dispatch an assymetric crypto request. - */ -static int -crypto_kinvoke(struct cryptkop *krp, int crid) -{ - struct cryptocap *cap = NULL; - int error; - unsigned long d_flags; - - KASSERT(krp != NULL, ("%s: krp == NULL", __func__)); - KASSERT(krp->krp_callback != NULL, - ("%s: krp->crp_callback == NULL", __func__)); - - CRYPTO_DRIVER_LOCK(); - if ((crid & (CRYPTOCAP_F_HARDWARE | CRYPTOCAP_F_SOFTWARE)) == 0) { - cap = crypto_checkdriver(crid); - if (cap != NULL) { - /* - * Driver present, it must support the necessary - * algorithm and, if s/w drivers are excluded, - * it must be registered as hardware-backed. - */ - if (!kdriver_suitable(cap, krp) || - (!crypto_devallowsoft && - (cap->cc_flags & CRYPTOCAP_F_HARDWARE) == 0)) - cap = NULL; - } - } else { - /* - * No requested driver; select based on crid flags. - */ - if (!crypto_devallowsoft) /* NB: disallow s/w drivers */ - crid &= ~CRYPTOCAP_F_SOFTWARE; - cap = crypto_select_kdriver(krp, crid); - } - if (cap != NULL && !cap->cc_kqblocked) { - krp->krp_hid = cap - crypto_drivers; - cap->cc_koperations++; - CRYPTO_DRIVER_UNLOCK(); - error = CRYPTODEV_KPROCESS(cap->cc_dev, krp, 0); - CRYPTO_DRIVER_LOCK(); - if (error == ERESTART) { - cap->cc_koperations--; - CRYPTO_DRIVER_UNLOCK(); - return (error); - } - /* return the actual device used */ - krp->krp_crid = krp->krp_hid; - } else { - /* - * NB: cap is !NULL if device is blocked; in - * that case return ERESTART so the operation - * is resubmitted if possible. - */ - error = (cap == NULL) ? ENODEV : ERESTART; - } - CRYPTO_DRIVER_UNLOCK(); - - if (error) { - krp->krp_status = error; - crypto_kdone(krp); - } - return 0; -} - - -/* - * Dispatch a crypto request to the appropriate crypto devices. - */ -static int -crypto_invoke(struct cryptocap *cap, struct cryptop *crp, int hint) -{ - KASSERT(crp != NULL, ("%s: crp == NULL", __func__)); - KASSERT(crp->crp_callback != NULL, - ("%s: crp->crp_callback == NULL", __func__)); - KASSERT(crp->crp_desc != NULL, ("%s: crp->crp_desc == NULL", __func__)); - - dprintk("%s()\n", __FUNCTION__); - -#ifdef CRYPTO_TIMING - if (crypto_timing) - crypto_tstat(&cryptostats.cs_invoke, &crp->crp_tstamp); -#endif - if (cap->cc_flags & CRYPTOCAP_F_CLEANUP) { - struct cryptodesc *crd; - u_int64_t nid; - - /* - * Driver has unregistered; migrate the session and return - * an error to the caller so they'll resubmit the op. - * - * XXX: What if there are more already queued requests for this - * session? - */ - crypto_freesession(crp->crp_sid); - - for (crd = crp->crp_desc; crd->crd_next; crd = crd->crd_next) - crd->CRD_INI.cri_next = &(crd->crd_next->CRD_INI); - - /* XXX propagate flags from initial session? */ - if (crypto_newsession(&nid, &(crp->crp_desc->CRD_INI), - CRYPTOCAP_F_HARDWARE | CRYPTOCAP_F_SOFTWARE) == 0) - crp->crp_sid = nid; - - crp->crp_etype = EAGAIN; - crypto_done(crp); - return 0; - } else { - /* - * Invoke the driver to process the request. - */ - return CRYPTODEV_PROCESS(cap->cc_dev, crp, hint); - } -} - -/* - * Release a set of crypto descriptors. - */ -void -crypto_freereq(struct cryptop *crp) -{ - struct cryptodesc *crd; - - if (crp == NULL) - return; - -#ifdef DIAGNOSTIC - { - struct cryptop *crp2; - unsigned long q_flags; - - CRYPTO_Q_LOCK(); - TAILQ_FOREACH(crp2, &crp_q, crp_next) { - KASSERT(crp2 != crp, - ("Freeing cryptop from the crypto queue (%p).", - crp)); - } - CRYPTO_Q_UNLOCK(); - CRYPTO_RETQ_LOCK(); - TAILQ_FOREACH(crp2, &crp_ret_q, crp_next) { - KASSERT(crp2 != crp, - ("Freeing cryptop from the return queue (%p).", - crp)); - } - CRYPTO_RETQ_UNLOCK(); - } -#endif - - while ((crd = crp->crp_desc) != NULL) { - crp->crp_desc = crd->crd_next; - kmem_cache_free(cryptodesc_zone, crd); - } - kmem_cache_free(cryptop_zone, crp); -} - -/* - * Acquire a set of crypto descriptors. - */ -struct cryptop * -crypto_getreq(int num) -{ - struct cryptodesc *crd; - struct cryptop *crp; - - crp = kmem_cache_alloc(cryptop_zone, SLAB_ATOMIC); - if (crp != NULL) { - memset(crp, 0, sizeof(*crp)); - INIT_LIST_HEAD(&crp->crp_next); - init_waitqueue_head(&crp->crp_waitq); - while (num--) { - crd = kmem_cache_alloc(cryptodesc_zone, SLAB_ATOMIC); - if (crd == NULL) { - crypto_freereq(crp); - return NULL; - } - memset(crd, 0, sizeof(*crd)); - crd->crd_next = crp->crp_desc; - crp->crp_desc = crd; - } - } - return crp; -} - -/* - * Invoke the callback on behalf of the driver. - */ -void -crypto_done(struct cryptop *crp) -{ - unsigned long q_flags; - - dprintk("%s()\n", __FUNCTION__); - if ((crp->crp_flags & CRYPTO_F_DONE) == 0) { - crp->crp_flags |= CRYPTO_F_DONE; - CRYPTO_Q_LOCK(); - crypto_q_cnt--; - CRYPTO_Q_UNLOCK(); - } else - printk("crypto: crypto_done op already done, flags 0x%x", - crp->crp_flags); - if (crp->crp_etype != 0) - cryptostats.cs_errs++; - /* - * CBIMM means unconditionally do the callback immediately; - * CBIFSYNC means do the callback immediately only if the - * operation was done synchronously. Both are used to avoid - * doing extraneous context switches; the latter is mostly - * used with the software crypto driver. - */ - if ((crp->crp_flags & CRYPTO_F_CBIMM) || - ((crp->crp_flags & CRYPTO_F_CBIFSYNC) && - (CRYPTO_SESID2CAPS(crp->crp_sid) & CRYPTOCAP_F_SYNC))) { - /* - * Do the callback directly. This is ok when the - * callback routine does very little (e.g. the - * /dev/crypto callback method just does a wakeup). - */ - crp->crp_callback(crp); - } else { - unsigned long r_flags; - /* - * Normal case; queue the callback for the thread. - */ - CRYPTO_RETQ_LOCK(); - if (CRYPTO_RETQ_EMPTY()) - wake_up_interruptible(&cryptoretproc_wait);/* shared wait channel */ - TAILQ_INSERT_TAIL(&crp_ret_q, crp, crp_next); - CRYPTO_RETQ_UNLOCK(); - } -} - -/* - * Invoke the callback on behalf of the driver. - */ -void -crypto_kdone(struct cryptkop *krp) -{ - struct cryptocap *cap; - unsigned long d_flags; - - if ((krp->krp_flags & CRYPTO_KF_DONE) != 0) - printk("crypto: crypto_kdone op already done, flags 0x%x", - krp->krp_flags); - krp->krp_flags |= CRYPTO_KF_DONE; - if (krp->krp_status != 0) - cryptostats.cs_kerrs++; - - CRYPTO_DRIVER_LOCK(); - /* XXX: What if driver is loaded in the meantime? */ - if (krp->krp_hid < crypto_drivers_num) { - cap = &crypto_drivers[krp->krp_hid]; - cap->cc_koperations--; - KASSERT(cap->cc_koperations >= 0, ("cc_koperations < 0")); - if (cap->cc_flags & CRYPTOCAP_F_CLEANUP) - crypto_remove(cap); - } - CRYPTO_DRIVER_UNLOCK(); - - /* - * CBIMM means unconditionally do the callback immediately; - * This is used to avoid doing extraneous context switches - */ - if ((krp->krp_flags & CRYPTO_KF_CBIMM)) { - /* - * Do the callback directly. This is ok when the - * callback routine does very little (e.g. the - * /dev/crypto callback method just does a wakeup). - */ - krp->krp_callback(krp); - } else { - unsigned long r_flags; - /* - * Normal case; queue the callback for the thread. - */ - CRYPTO_RETQ_LOCK(); - if (CRYPTO_RETQ_EMPTY()) - wake_up_interruptible(&cryptoretproc_wait);/* shared wait channel */ - TAILQ_INSERT_TAIL(&crp_ret_kq, krp, krp_next); - CRYPTO_RETQ_UNLOCK(); - } -} - -int -crypto_getfeat(int *featp) -{ - int hid, kalg, feat = 0; - unsigned long d_flags; - - CRYPTO_DRIVER_LOCK(); - for (hid = 0; hid < crypto_drivers_num; hid++) { - const struct cryptocap *cap = &crypto_drivers[hid]; - - if ((cap->cc_flags & CRYPTOCAP_F_SOFTWARE) && - !crypto_devallowsoft) { - continue; - } - for (kalg = 0; kalg < CRK_ALGORITHM_MAX; kalg++) - if (cap->cc_kalg[kalg] & CRYPTO_ALG_FLAG_SUPPORTED) - feat |= 1 << kalg; - } - CRYPTO_DRIVER_UNLOCK(); - *featp = feat; - return (0); -} - -/* - * Crypto thread, dispatches crypto requests. - */ -static int -crypto_proc(void *arg) -{ - struct cryptop *crp, *submit; - struct cryptkop *krp, *krpp; - struct cryptocap *cap; - u_int32_t hid; - int result, hint; - unsigned long q_flags; - int loopcount = 0; - - ocf_daemonize("crypto"); - - CRYPTO_Q_LOCK(); - for (;;) { - /* - * we need to make sure we don't get into a busy loop with nothing - * to do, the two crypto_all_*blocked vars help us find out when - * we are all full and can do nothing on any driver or Q. If so we - * wait for an unblock. - */ - crypto_all_qblocked = !list_empty(&crp_q); - - /* - * Find the first element in the queue that can be - * processed and look-ahead to see if multiple ops - * are ready for the same driver. - */ - submit = NULL; - hint = 0; - list_for_each_entry(crp, &crp_q, crp_next) { - hid = CRYPTO_SESID2HID(crp->crp_sid); - cap = crypto_checkdriver(hid); - /* - * Driver cannot disappear when there is an active - * session. - */ - KASSERT(cap != NULL, ("%s:%u Driver disappeared.", - __func__, __LINE__)); - if (cap == NULL || cap->cc_dev == NULL) { - /* Op needs to be migrated, process it. */ - if (submit == NULL) - submit = crp; - break; - } - if (!cap->cc_qblocked) { - if (submit != NULL) { - /* - * We stop on finding another op, - * regardless whether its for the same - * driver or not. We could keep - * searching the queue but it might be - * better to just use a per-driver - * queue instead. - */ - if (CRYPTO_SESID2HID(submit->crp_sid) == hid) - hint = CRYPTO_HINT_MORE; - break; - } else { - submit = crp; - if ((submit->crp_flags & CRYPTO_F_BATCH) == 0) - break; - /* keep scanning for more are q'd */ - } - } - } - if (submit != NULL) { - hid = CRYPTO_SESID2HID(submit->crp_sid); - crypto_all_qblocked = 0; - list_del(&submit->crp_next); - crypto_drivers[hid].cc_unqblocked = 1; - cap = crypto_checkdriver(hid); - CRYPTO_Q_UNLOCK(); - KASSERT(cap != NULL, ("%s:%u Driver disappeared.", - __func__, __LINE__)); - result = crypto_invoke(cap, submit, hint); - CRYPTO_Q_LOCK(); - if (result == ERESTART) { - /* - * The driver ran out of resources, mark the - * driver ``blocked'' for cryptop's and put - * the request back in the queue. It would - * best to put the request back where we got - * it but that's hard so for now we put it - * at the front. This should be ok; putting - * it at the end does not work. - */ - /* XXX validate sid again? */ - list_add(&submit->crp_next, &crp_q); - cryptostats.cs_blocks++; - if (crypto_drivers[hid].cc_unqblocked) - crypto_drivers[hid].cc_qblocked=0; - crypto_drivers[hid].cc_unqblocked=0; - } - crypto_drivers[hid].cc_unqblocked = 0; - } - - crypto_all_kqblocked = !list_empty(&crp_kq); - - /* As above, but for key ops */ - krp = NULL; - list_for_each_entry(krpp, &crp_kq, krp_next) { - cap = crypto_checkdriver(krpp->krp_hid); - if (cap == NULL || cap->cc_dev == NULL) { - /* - * Operation needs to be migrated, invalidate - * the assigned device so it will reselect a - * new one below. Propagate the original - * crid selection flags if supplied. - */ - krp->krp_hid = krp->krp_crid & - (CRYPTOCAP_F_SOFTWARE|CRYPTOCAP_F_HARDWARE); - if (krp->krp_hid == 0) - krp->krp_hid = - CRYPTOCAP_F_SOFTWARE|CRYPTOCAP_F_HARDWARE; - break; - } - if (!cap->cc_kqblocked) { - krp = krpp; - break; - } - } - if (krp != NULL) { - crypto_all_kqblocked = 0; - list_del(&krp->krp_next); - crypto_drivers[krp->krp_hid].cc_kqblocked = 1; - CRYPTO_Q_UNLOCK(); - result = crypto_kinvoke(krp, krp->krp_hid); - CRYPTO_Q_LOCK(); - if (result == ERESTART) { - /* - * The driver ran out of resources, mark the - * driver ``blocked'' for cryptkop's and put - * the request back in the queue. It would - * best to put the request back where we got - * it but that's hard so for now we put it - * at the front. This should be ok; putting - * it at the end does not work. - */ - /* XXX validate sid again? */ - list_add(&krp->krp_next, &crp_kq); - cryptostats.cs_kblocks++; - } else - crypto_drivers[krp->krp_hid].cc_kqblocked = 0; - } - - if (submit == NULL && krp == NULL) { - /* - * Nothing more to be processed. Sleep until we're - * woken because there are more ops to process. - * This happens either by submission or by a driver - * becoming unblocked and notifying us through - * crypto_unblock. Note that when we wakeup we - * start processing each queue again from the - * front. It's not clear that it's important to - * preserve this ordering since ops may finish - * out of order if dispatched to different devices - * and some become blocked while others do not. - */ - dprintk("%s - sleeping (qe=%d qb=%d kqe=%d kqb=%d)\n", - __FUNCTION__, - list_empty(&crp_q), crypto_all_qblocked, - list_empty(&crp_kq), crypto_all_kqblocked); - loopcount = 0; - CRYPTO_Q_UNLOCK(); - crp_sleep = 1; - wait_event_interruptible(cryptoproc_wait, - !(list_empty(&crp_q) || crypto_all_qblocked) || - !(list_empty(&crp_kq) || crypto_all_kqblocked) || - cryptoproc == (pid_t) -1); - crp_sleep = 0; - if (signal_pending (current)) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) - spin_lock_irq(¤t->sigmask_lock); -#endif - flush_signals(current); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) - spin_unlock_irq(¤t->sigmask_lock); -#endif - } - CRYPTO_Q_LOCK(); - dprintk("%s - awake\n", __FUNCTION__); - if (cryptoproc == (pid_t) -1) - break; - cryptostats.cs_intrs++; - } else if (loopcount > crypto_max_loopcount) { - /* - * Give other processes a chance to run if we've - * been using the CPU exclusively for a while. - */ - loopcount = 0; - schedule(); - } - loopcount++; - } - CRYPTO_Q_UNLOCK(); - complete_and_exit(&cryptoproc_exited, 0); -} - -/* - * Crypto returns thread, does callbacks for processed crypto requests. - * Callbacks are done here, rather than in the crypto drivers, because - * callbacks typically are expensive and would slow interrupt handling. - */ -static int -crypto_ret_proc(void *arg) -{ - struct cryptop *crpt; - struct cryptkop *krpt; - unsigned long r_flags; - - ocf_daemonize("crypto_ret"); - - CRYPTO_RETQ_LOCK(); - for (;;) { - /* Harvest return q's for completed ops */ - crpt = NULL; - if (!list_empty(&crp_ret_q)) - crpt = list_entry(crp_ret_q.next, typeof(*crpt), crp_next); - if (crpt != NULL) - list_del(&crpt->crp_next); - - krpt = NULL; - if (!list_empty(&crp_ret_kq)) - krpt = list_entry(crp_ret_kq.next, typeof(*krpt), krp_next); - if (krpt != NULL) - list_del(&krpt->krp_next); - - if (crpt != NULL || krpt != NULL) { - CRYPTO_RETQ_UNLOCK(); - /* - * Run callbacks unlocked. - */ - if (crpt != NULL) - crpt->crp_callback(crpt); - if (krpt != NULL) - krpt->krp_callback(krpt); - CRYPTO_RETQ_LOCK(); - } else { - /* - * Nothing more to be processed. Sleep until we're - * woken because there are more returns to process. - */ - dprintk("%s - sleeping\n", __FUNCTION__); - CRYPTO_RETQ_UNLOCK(); - wait_event_interruptible(cryptoretproc_wait, - cryptoretproc == (pid_t) -1 || - !list_empty(&crp_ret_q) || - !list_empty(&crp_ret_kq)); - if (signal_pending (current)) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) - spin_lock_irq(¤t->sigmask_lock); -#endif - flush_signals(current); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) - spin_unlock_irq(¤t->sigmask_lock); -#endif - } - CRYPTO_RETQ_LOCK(); - dprintk("%s - awake\n", __FUNCTION__); - if (cryptoretproc == (pid_t) -1) { - dprintk("%s - EXITING!\n", __FUNCTION__); - break; - } - cryptostats.cs_rets++; - } - } - CRYPTO_RETQ_UNLOCK(); - complete_and_exit(&cryptoretproc_exited, 0); -} - - -#if 0 /* should put this into /proc or something */ -static void -db_show_drivers(void) -{ - int hid; - - db_printf("%12s %4s %4s %8s %2s %2s\n" - , "Device" - , "Ses" - , "Kops" - , "Flags" - , "QB" - , "KB" - ); - for (hid = 0; hid < crypto_drivers_num; hid++) { - const struct cryptocap *cap = &crypto_drivers[hid]; - if (cap->cc_dev == NULL) - continue; - db_printf("%-12s %4u %4u %08x %2u %2u\n" - , device_get_nameunit(cap->cc_dev) - , cap->cc_sessions - , cap->cc_koperations - , cap->cc_flags - , cap->cc_qblocked - , cap->cc_kqblocked - ); - } -} - -DB_SHOW_COMMAND(crypto, db_show_crypto) -{ - struct cryptop *crp; - - db_show_drivers(); - db_printf("\n"); - - db_printf("%4s %8s %4s %4s %4s %4s %8s %8s\n", - "HID", "Caps", "Ilen", "Olen", "Etype", "Flags", - "Desc", "Callback"); - TAILQ_FOREACH(crp, &crp_q, crp_next) { - db_printf("%4u %08x %4u %4u %4u %04x %8p %8p\n" - , (int) CRYPTO_SESID2HID(crp->crp_sid) - , (int) CRYPTO_SESID2CAPS(crp->crp_sid) - , crp->crp_ilen, crp->crp_olen - , crp->crp_etype - , crp->crp_flags - , crp->crp_desc - , crp->crp_callback - ); - } - if (!TAILQ_EMPTY(&crp_ret_q)) { - db_printf("\n%4s %4s %4s %8s\n", - "HID", "Etype", "Flags", "Callback"); - TAILQ_FOREACH(crp, &crp_ret_q, crp_next) { - db_printf("%4u %4u %04x %8p\n" - , (int) CRYPTO_SESID2HID(crp->crp_sid) - , crp->crp_etype - , crp->crp_flags - , crp->crp_callback - ); - } - } -} - -DB_SHOW_COMMAND(kcrypto, db_show_kcrypto) -{ - struct cryptkop *krp; - - db_show_drivers(); - db_printf("\n"); - - db_printf("%4s %5s %4s %4s %8s %4s %8s\n", - "Op", "Status", "#IP", "#OP", "CRID", "HID", "Callback"); - TAILQ_FOREACH(krp, &crp_kq, krp_next) { - db_printf("%4u %5u %4u %4u %08x %4u %8p\n" - , krp->krp_op - , krp->krp_status - , krp->krp_iparams, krp->krp_oparams - , krp->krp_crid, krp->krp_hid - , krp->krp_callback - ); - } - if (!TAILQ_EMPTY(&crp_ret_q)) { - db_printf("%4s %5s %8s %4s %8s\n", - "Op", "Status", "CRID", "HID", "Callback"); - TAILQ_FOREACH(krp, &crp_ret_kq, krp_next) { - db_printf("%4u %5u %08x %4u %8p\n" - , krp->krp_op - , krp->krp_status - , krp->krp_crid, krp->krp_hid - , krp->krp_callback - ); - } - } -} -#endif - - -static int -crypto_init(void) -{ - int error; - - dprintk("%s(%p)\n", __FUNCTION__, (void *) crypto_init); - - if (crypto_initted) - return 0; - crypto_initted = 1; - - spin_lock_init(&crypto_drivers_lock); - spin_lock_init(&crypto_q_lock); - spin_lock_init(&crypto_ret_q_lock); - - cryptop_zone = kmem_cache_create("cryptop", sizeof(struct cryptop), - 0, SLAB_HWCACHE_ALIGN, NULL -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23) - , NULL -#endif - ); - - cryptodesc_zone = kmem_cache_create("cryptodesc", sizeof(struct cryptodesc), - 0, SLAB_HWCACHE_ALIGN, NULL -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23) - , NULL -#endif - ); - - if (cryptodesc_zone == NULL || cryptop_zone == NULL) { - printk("crypto: crypto_init cannot setup crypto zones\n"); - error = ENOMEM; - goto bad; - } - - crypto_drivers_num = CRYPTO_DRIVERS_INITIAL; - crypto_drivers = kmalloc(crypto_drivers_num * sizeof(struct cryptocap), - GFP_KERNEL); - if (crypto_drivers == NULL) { - printk("crypto: crypto_init cannot setup crypto drivers\n"); - error = ENOMEM; - goto bad; - } - - memset(crypto_drivers, 0, crypto_drivers_num * sizeof(struct cryptocap)); - - init_completion(&cryptoproc_exited); - init_completion(&cryptoretproc_exited); - - cryptoproc = 0; /* to avoid race condition where proc runs first */ - cryptoproc = kernel_thread(crypto_proc, NULL, CLONE_FS|CLONE_FILES); - if (cryptoproc < 0) { - error = cryptoproc; - printk("crypto: crypto_init cannot start crypto thread; error %d", - error); - goto bad; - } - - cryptoretproc = 0; /* to avoid race condition where proc runs first */ - cryptoretproc = kernel_thread(crypto_ret_proc, NULL, CLONE_FS|CLONE_FILES); - if (cryptoretproc < 0) { - error = cryptoretproc; - printk("crypto: crypto_init cannot start cryptoret thread; error %d", - error); - goto bad; - } - - return 0; -bad: - crypto_exit(); - return error; -} - - -static void -crypto_exit(void) -{ - pid_t p; - unsigned long d_flags; - - dprintk("%s()\n", __FUNCTION__); - - /* - * Terminate any crypto threads. - */ - - CRYPTO_DRIVER_LOCK(); - p = cryptoproc; - cryptoproc = (pid_t) -1; - kill_proc(p, SIGTERM, 1); - wake_up_interruptible(&cryptoproc_wait); - CRYPTO_DRIVER_UNLOCK(); - - wait_for_completion(&cryptoproc_exited); - - CRYPTO_DRIVER_LOCK(); - p = cryptoretproc; - cryptoretproc = (pid_t) -1; - kill_proc(p, SIGTERM, 1); - wake_up_interruptible(&cryptoretproc_wait); - CRYPTO_DRIVER_UNLOCK(); - - wait_for_completion(&cryptoretproc_exited); - - /* XXX flush queues??? */ - - /* - * Reclaim dynamically allocated resources. - */ - if (crypto_drivers != NULL) - kfree(crypto_drivers); - - if (cryptodesc_zone != NULL) - kmem_cache_destroy(cryptodesc_zone); - if (cryptop_zone != NULL) - kmem_cache_destroy(cryptop_zone); -} - - -EXPORT_SYMBOL(crypto_newsession); -EXPORT_SYMBOL(crypto_freesession); -EXPORT_SYMBOL(crypto_get_driverid); -EXPORT_SYMBOL(crypto_kregister); -EXPORT_SYMBOL(crypto_register); -EXPORT_SYMBOL(crypto_unregister); -EXPORT_SYMBOL(crypto_unregister_all); -EXPORT_SYMBOL(crypto_unblock); -EXPORT_SYMBOL(crypto_dispatch); -EXPORT_SYMBOL(crypto_kdispatch); -EXPORT_SYMBOL(crypto_freereq); -EXPORT_SYMBOL(crypto_getreq); -EXPORT_SYMBOL(crypto_done); -EXPORT_SYMBOL(crypto_kdone); -EXPORT_SYMBOL(crypto_getfeat); -EXPORT_SYMBOL(crypto_userasymcrypto); -EXPORT_SYMBOL(crypto_getcaps); -EXPORT_SYMBOL(crypto_find_driver); -EXPORT_SYMBOL(crypto_find_device_byhid); - -module_init(crypto_init); -module_exit(crypto_exit); - -MODULE_LICENSE("BSD"); -MODULE_AUTHOR("David McCullough <david_mccullough@mcafee.com>"); -MODULE_DESCRIPTION("OCF (OpenBSD Cryptographic Framework)"); diff --git a/target/linux/generic-2.4/files/crypto/ocf/cryptocteon/Makefile b/target/linux/generic-2.4/files/crypto/ocf/cryptocteon/Makefile deleted file mode 100644 index eeed0d6..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/cryptocteon/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# for SGlinux builds --include $(ROOTDIR)/modules/.config - -obj-$(CONFIG_OCF_CRYPTOCTEON) += cryptocteon.o - -obj ?= . -EXTRA_CFLAGS += -I$(obj)/.. -I$(obj)/ - -ifdef CONFIG_OCF_CRYPTOCTEON -# you need the cavium crypto component installed -EXTRA_CFLAGS += -I$(ROOTDIR)/prop/include -endif - -ifdef TOPDIR --include $(TOPDIR)/Rules.make -endif - diff --git a/target/linux/generic-2.4/files/crypto/ocf/cryptocteon/cavium_crypto.c b/target/linux/generic-2.4/files/crypto/ocf/cryptocteon/cavium_crypto.c deleted file mode 100644 index ceaf77c..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/cryptocteon/cavium_crypto.c +++ /dev/null @@ -1,2283 +0,0 @@ -/* - * Copyright (c) 2009 David McCullough <david.mccullough@securecomputing.com> - * - * Copyright (c) 2003-2007 Cavium Networks (support@cavium.com). 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Cavium Networks - * 4. Cavium Networks' name may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * This Software, including technical data, may be subject to U.S. export - * control laws, including the U.S. Export Administration Act and its - * associated regulations, and may be subject to export or import regulations - * in other countries. You warrant that You will comply strictly in all - * respects with all such regulations and acknowledge that you have the - * responsibility to obtain licenses to export, re-export or import the - * Software. - * - * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" AND - * WITH ALL FAULTS AND CAVIUM MAKES NO PROMISES, REPRESENTATIONS OR WARRANTIES, - * EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO THE - * SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR - * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM - * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE, - * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF - * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR - * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR - * PERFORMANCE OF THE SOFTWARE LIES WITH YOU. -*/ -/****************************************************************************/ - -#include <linux/scatterlist.h> -#include <asm/octeon/octeon.h> -#include "octeon-asm.h" - -/****************************************************************************/ - -extern unsigned long octeon_crypto_enable(struct octeon_cop2_state *); -extern void octeon_crypto_disable(struct octeon_cop2_state *, unsigned long); - -#define SG_INIT(s, p, i, l) \ - { \ - (i) = 0; \ - (l) = (s)[0].length; \ - (p) = (typeof(p)) sg_virt((s)); \ - CVMX_PREFETCH0((p)); \ - } - -#define SG_CONSUME(s, p, i, l) \ - { \ - (p)++; \ - (l) -= sizeof(*(p)); \ - if ((l) < 0) { \ - dprintk("%s, %d: l = %d\n", __FILE__, __LINE__, l); \ - } else if ((l) == 0) { \ - (i)++; \ - (l) = (s)[0].length; \ - (p) = (typeof(p)) sg_virt(s); \ - CVMX_PREFETCH0((p)); \ - } \ - } - -#define ESP_HEADER_LENGTH 8 -#define DES_CBC_IV_LENGTH 8 -#define AES_CBC_IV_LENGTH 16 -#define ESP_HMAC_LEN 12 - -#define ESP_HEADER_LENGTH 8 -#define DES_CBC_IV_LENGTH 8 - -/****************************************************************************/ - -#define CVM_LOAD_SHA_UNIT(dat, next) { \ - if (next == 0) { \ - next = 1; \ - CVMX_MT_HSH_DAT (dat, 0); \ - } else if (next == 1) { \ - next = 2; \ - CVMX_MT_HSH_DAT (dat, 1); \ - } else if (next == 2) { \ - next = 3; \ - CVMX_MT_HSH_DAT (dat, 2); \ - } else if (next == 3) { \ - next = 4; \ - CVMX_MT_HSH_DAT (dat, 3); \ - } else if (next == 4) { \ - next = 5; \ - CVMX_MT_HSH_DAT (dat, 4); \ - } else if (next == 5) { \ - next = 6; \ - CVMX_MT_HSH_DAT (dat, 5); \ - } else if (next == 6) { \ - next = 7; \ - CVMX_MT_HSH_DAT (dat, 6); \ - } else { \ - CVMX_MT_HSH_STARTSHA (dat); \ - next = 0; \ - } \ -} - -#define CVM_LOAD2_SHA_UNIT(dat1, dat2, next) { \ - if (next == 0) { \ - CVMX_MT_HSH_DAT (dat1, 0); \ - CVMX_MT_HSH_DAT (dat2, 1); \ - next = 2; \ - } else if (next == 1) { \ - CVMX_MT_HSH_DAT (dat1, 1); \ - CVMX_MT_HSH_DAT (dat2, 2); \ - next = 3; \ - } else if (next == 2) { \ - CVMX_MT_HSH_DAT (dat1, 2); \ - CVMX_MT_HSH_DAT (dat2, 3); \ - next = 4; \ - } else if (next == 3) { \ - CVMX_MT_HSH_DAT (dat1, 3); \ - CVMX_MT_HSH_DAT (dat2, 4); \ - next = 5; \ - } else if (next == 4) { \ - CVMX_MT_HSH_DAT (dat1, 4); \ - CVMX_MT_HSH_DAT (dat2, 5); \ - next = 6; \ - } else if (next == 5) { \ - CVMX_MT_HSH_DAT (dat1, 5); \ - CVMX_MT_HSH_DAT (dat2, 6); \ - next = 7; \ - } else if (next == 6) { \ - CVMX_MT_HSH_DAT (dat1, 6); \ - CVMX_MT_HSH_STARTSHA (dat2); \ - next = 0; \ - } else { \ - CVMX_MT_HSH_STARTSHA (dat1); \ - CVMX_MT_HSH_DAT (dat2, 0); \ - next = 1; \ - } \ -} - -/****************************************************************************/ - -#define CVM_LOAD_MD5_UNIT(dat, next) { \ - if (next == 0) { \ - next = 1; \ - CVMX_MT_HSH_DAT (dat, 0); \ - } else if (next == 1) { \ - next = 2; \ - CVMX_MT_HSH_DAT (dat, 1); \ - } else if (next == 2) { \ - next = 3; \ - CVMX_MT_HSH_DAT (dat, 2); \ - } else if (next == 3) { \ - next = 4; \ - CVMX_MT_HSH_DAT (dat, 3); \ - } else if (next == 4) { \ - next = 5; \ - CVMX_MT_HSH_DAT (dat, 4); \ - } else if (next == 5) { \ - next = 6; \ - CVMX_MT_HSH_DAT (dat, 5); \ - } else if (next == 6) { \ - next = 7; \ - CVMX_MT_HSH_DAT (dat, 6); \ - } else { \ - CVMX_MT_HSH_STARTMD5 (dat); \ - next = 0; \ - } \ -} - -#define CVM_LOAD2_MD5_UNIT(dat1, dat2, next) { \ - if (next == 0) { \ - CVMX_MT_HSH_DAT (dat1, 0); \ - CVMX_MT_HSH_DAT (dat2, 1); \ - next = 2; \ - } else if (next == 1) { \ - CVMX_MT_HSH_DAT (dat1, 1); \ - CVMX_MT_HSH_DAT (dat2, 2); \ - next = 3; \ - } else if (next == 2) { \ - CVMX_MT_HSH_DAT (dat1, 2); \ - CVMX_MT_HSH_DAT (dat2, 3); \ - next = 4; \ - } else if (next == 3) { \ - CVMX_MT_HSH_DAT (dat1, 3); \ - CVMX_MT_HSH_DAT (dat2, 4); \ - next = 5; \ - } else if (next == 4) { \ - CVMX_MT_HSH_DAT (dat1, 4); \ - CVMX_MT_HSH_DAT (dat2, 5); \ - next = 6; \ - } else if (next == 5) { \ - CVMX_MT_HSH_DAT (dat1, 5); \ - CVMX_MT_HSH_DAT (dat2, 6); \ - next = 7; \ - } else if (next == 6) { \ - CVMX_MT_HSH_DAT (dat1, 6); \ - CVMX_MT_HSH_STARTMD5 (dat2); \ - next = 0; \ - } else { \ - CVMX_MT_HSH_STARTMD5 (dat1); \ - CVMX_MT_HSH_DAT (dat2, 0); \ - next = 1; \ - } \ -} - -/****************************************************************************/ - -static inline uint64_t -swap64(uint64_t a) -{ - return ((a >> 56) | - (((a >> 48) & 0xfful) << 8) | - (((a >> 40) & 0xfful) << 16) | - (((a >> 32) & 0xfful) << 24) | - (((a >> 24) & 0xfful) << 32) | - (((a >> 16) & 0xfful) << 40) | - (((a >> 8) & 0xfful) << 48) | (((a >> 0) & 0xfful) << 56)); -} - -/****************************************************************************/ - -void -octo_calc_hash(__u8 auth, unsigned char *key, uint64_t *inner, uint64_t *outer) -{ - uint8_t hash_key[64]; - uint64_t *key1; - register uint64_t xor1 = 0x3636363636363636ULL; - register uint64_t xor2 = 0x5c5c5c5c5c5c5c5cULL; - struct octeon_cop2_state state; - unsigned long flags; - - dprintk("%s()\n", __FUNCTION__); - - memset(hash_key, 0, sizeof(hash_key)); - memcpy(hash_key, (uint8_t *) key, (auth ? 20 : 16)); - key1 = (uint64_t *) hash_key; - flags = octeon_crypto_enable(&state); - if (auth) { - CVMX_MT_HSH_IV(0x67452301EFCDAB89ULL, 0); - CVMX_MT_HSH_IV(0x98BADCFE10325476ULL, 1); - CVMX_MT_HSH_IV(0xC3D2E1F000000000ULL, 2); - } else { - CVMX_MT_HSH_IV(0x0123456789ABCDEFULL, 0); - CVMX_MT_HSH_IV(0xFEDCBA9876543210ULL, 1); - } - - CVMX_MT_HSH_DAT((*key1 ^ xor1), 0); - key1++; - CVMX_MT_HSH_DAT((*key1 ^ xor1), 1); - key1++; - CVMX_MT_HSH_DAT((*key1 ^ xor1), 2); - key1++; - CVMX_MT_HSH_DAT((*key1 ^ xor1), 3); - key1++; - CVMX_MT_HSH_DAT((*key1 ^ xor1), 4); - key1++; - CVMX_MT_HSH_DAT((*key1 ^ xor1), 5); - key1++; - CVMX_MT_HSH_DAT((*key1 ^ xor1), 6); - key1++; - if (auth) - CVMX_MT_HSH_STARTSHA((*key1 ^ xor1)); - else - CVMX_MT_HSH_STARTMD5((*key1 ^ xor1)); - - CVMX_MF_HSH_IV(inner[0], 0); - CVMX_MF_HSH_IV(inner[1], 1); - if (auth) { - inner[2] = 0; - CVMX_MF_HSH_IV(((uint64_t *) inner)[2], 2); - } - - memset(hash_key, 0, sizeof(hash_key)); - memcpy(hash_key, (uint8_t *) key, (auth ? 20 : 16)); - key1 = (uint64_t *) hash_key; - if (auth) { - CVMX_MT_HSH_IV(0x67452301EFCDAB89ULL, 0); - CVMX_MT_HSH_IV(0x98BADCFE10325476ULL, 1); - CVMX_MT_HSH_IV(0xC3D2E1F000000000ULL, 2); - } else { - CVMX_MT_HSH_IV(0x0123456789ABCDEFULL, 0); - CVMX_MT_HSH_IV(0xFEDCBA9876543210ULL, 1); - } - - CVMX_MT_HSH_DAT((*key1 ^ xor2), 0); - key1++; - CVMX_MT_HSH_DAT((*key1 ^ xor2), 1); - key1++; - CVMX_MT_HSH_DAT((*key1 ^ xor2), 2); - key1++; - CVMX_MT_HSH_DAT((*key1 ^ xor2), 3); - key1++; - CVMX_MT_HSH_DAT((*key1 ^ xor2), 4); - key1++; - CVMX_MT_HSH_DAT((*key1 ^ xor2), 5); - key1++; - CVMX_MT_HSH_DAT((*key1 ^ xor2), 6); - key1++; - if (auth) - CVMX_MT_HSH_STARTSHA((*key1 ^ xor2)); - else - CVMX_MT_HSH_STARTMD5((*key1 ^ xor2)); - - CVMX_MF_HSH_IV(outer[0], 0); - CVMX_MF_HSH_IV(outer[1], 1); - if (auth) { - outer[2] = 0; - CVMX_MF_HSH_IV(outer[2], 2); - } - octeon_crypto_disable(&state, flags); - return; -} - -/****************************************************************************/ -/* DES functions */ - -int -octo_des_cbc_encrypt( - struct octo_sess *od, - struct scatterlist *sg, int sg_len, - int auth_off, int auth_len, - int crypt_off, int crypt_len, - int icv_off, uint8_t *ivp) -{ - uint64_t *data; - int data_i, data_l; - struct octeon_cop2_state state; - unsigned long flags; - - dprintk("%s()\n", __FUNCTION__); - - if (unlikely(od == NULL || sg==NULL || sg_len==0 || ivp==NULL || - (crypt_off & 0x7) || (crypt_off + crypt_len > sg_len))) { - dprintk("%s: Bad parameters od=%p sg=%p sg_len=%d " - "auth_off=%d auth_len=%d crypt_off=%d crypt_len=%d " - "icv_off=%d ivp=%p\n", __FUNCTION__, od, sg, sg_len, - auth_off, auth_len, crypt_off, crypt_len, icv_off, ivp); - return -EINVAL; - } - - SG_INIT(sg, data, data_i, data_l); - - CVMX_PREFETCH0(ivp); - CVMX_PREFETCH0(od->octo_enckey); - - flags = octeon_crypto_enable(&state); - - /* load 3DES Key */ - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[0], 0); - if (od->octo_encklen == 24) { - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[1], 1); - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[2], 2); - } else if (od->octo_encklen == 8) { - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[0], 1); - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[0], 2); - } else { - octeon_crypto_disable(&state, flags); - dprintk("%s: Bad key length %d\n", __FUNCTION__, od->octo_encklen); - return -EINVAL; - } - - CVMX_MT_3DES_IV(* (uint64_t *) ivp); - - while (crypt_off > 0) { - SG_CONSUME(sg, data, data_i, data_l); - crypt_off -= 8; - } - - while (crypt_len > 0) { - CVMX_MT_3DES_ENC_CBC(*data); - CVMX_MF_3DES_RESULT(*data); - SG_CONSUME(sg, data, data_i, data_l); - crypt_len -= 8; - } - - octeon_crypto_disable(&state, flags); - return 0; -} - - -int -octo_des_cbc_decrypt( - struct octo_sess *od, - struct scatterlist *sg, int sg_len, - int auth_off, int auth_len, - int crypt_off, int crypt_len, - int icv_off, uint8_t *ivp) -{ - uint64_t *data; - int data_i, data_l; - struct octeon_cop2_state state; - unsigned long flags; - - dprintk("%s()\n", __FUNCTION__); - - if (unlikely(od == NULL || sg==NULL || sg_len==0 || ivp==NULL || - (crypt_off & 0x7) || (crypt_off + crypt_len > sg_len))) { - dprintk("%s: Bad parameters od=%p sg=%p sg_len=%d " - "auth_off=%d auth_len=%d crypt_off=%d crypt_len=%d " - "icv_off=%d ivp=%p\n", __FUNCTION__, od, sg, sg_len, - auth_off, auth_len, crypt_off, crypt_len, icv_off, ivp); - return -EINVAL; - } - - SG_INIT(sg, data, data_i, data_l); - - CVMX_PREFETCH0(ivp); - CVMX_PREFETCH0(od->octo_enckey); - - flags = octeon_crypto_enable(&state); - - /* load 3DES Key */ - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[0], 0); - if (od->octo_encklen == 24) { - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[1], 1); - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[2], 2); - } else if (od->octo_encklen == 8) { - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[0], 1); - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[0], 2); - } else { - octeon_crypto_disable(&state, flags); - dprintk("%s: Bad key length %d\n", __FUNCTION__, od->octo_encklen); - return -EINVAL; - } - - CVMX_MT_3DES_IV(* (uint64_t *) ivp); - - while (crypt_off > 0) { - SG_CONSUME(sg, data, data_i, data_l); - crypt_off -= 8; - } - - while (crypt_len > 0) { - CVMX_MT_3DES_DEC_CBC(*data); - CVMX_MF_3DES_RESULT(*data); - SG_CONSUME(sg, data, data_i, data_l); - crypt_len -= 8; - } - - octeon_crypto_disable(&state, flags); - return 0; -} - -/****************************************************************************/ -/* AES functions */ - -int -octo_aes_cbc_encrypt( - struct octo_sess *od, - struct scatterlist *sg, int sg_len, - int auth_off, int auth_len, - int crypt_off, int crypt_len, - int icv_off, uint8_t *ivp) -{ - uint64_t *data, *pdata; - int data_i, data_l; - struct octeon_cop2_state state; - unsigned long flags; - - dprintk("%s()\n", __FUNCTION__); - - if (unlikely(od == NULL || sg==NULL || sg_len==0 || ivp==NULL || - (crypt_off & 0x7) || (crypt_off + crypt_len > sg_len))) { - dprintk("%s: Bad parameters od=%p sg=%p sg_len=%d " - "auth_off=%d auth_len=%d crypt_off=%d crypt_len=%d " - "icv_off=%d ivp=%p\n", __FUNCTION__, od, sg, sg_len, - auth_off, auth_len, crypt_off, crypt_len, icv_off, ivp); - return -EINVAL; - } - - SG_INIT(sg, data, data_i, data_l); - - CVMX_PREFETCH0(ivp); - CVMX_PREFETCH0(od->octo_enckey); - - flags = octeon_crypto_enable(&state); - - /* load AES Key */ - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[0], 0); - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[1], 1); - - if (od->octo_encklen == 16) { - CVMX_MT_AES_KEY(0x0, 2); - CVMX_MT_AES_KEY(0x0, 3); - } else if (od->octo_encklen == 24) { - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[2], 2); - CVMX_MT_AES_KEY(0x0, 3); - } else if (od->octo_encklen == 32) { - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[2], 2); - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[3], 3); - } else { - octeon_crypto_disable(&state, flags); - dprintk("%s: Bad key length %d\n", __FUNCTION__, od->octo_encklen); - return -EINVAL; - } - CVMX_MT_AES_KEYLENGTH(od->octo_encklen / 8 - 1); - - CVMX_MT_AES_IV(((uint64_t *) ivp)[0], 0); - CVMX_MT_AES_IV(((uint64_t *) ivp)[1], 1); - - while (crypt_off > 0) { - SG_CONSUME(sg, data, data_i, data_l); - crypt_off -= 8; - } - - while (crypt_len > 0) { - pdata = data; - CVMX_MT_AES_ENC_CBC0(*data); - SG_CONSUME(sg, data, data_i, data_l); - CVMX_MT_AES_ENC_CBC1(*data); - CVMX_MF_AES_RESULT(*pdata, 0); - CVMX_MF_AES_RESULT(*data, 1); - SG_CONSUME(sg, data, data_i, data_l); - crypt_len -= 16; - } - - octeon_crypto_disable(&state, flags); - return 0; -} - - -int -octo_aes_cbc_decrypt( - struct octo_sess *od, - struct scatterlist *sg, int sg_len, - int auth_off, int auth_len, - int crypt_off, int crypt_len, - int icv_off, uint8_t *ivp) -{ - uint64_t *data, *pdata; - int data_i, data_l; - struct octeon_cop2_state state; - unsigned long flags; - - dprintk("%s()\n", __FUNCTION__); - - if (unlikely(od == NULL || sg==NULL || sg_len==0 || ivp==NULL || - (crypt_off & 0x7) || (crypt_off + crypt_len > sg_len))) { - dprintk("%s: Bad parameters od=%p sg=%p sg_len=%d " - "auth_off=%d auth_len=%d crypt_off=%d crypt_len=%d " - "icv_off=%d ivp=%p\n", __FUNCTION__, od, sg, sg_len, - auth_off, auth_len, crypt_off, crypt_len, icv_off, ivp); - return -EINVAL; - } - - SG_INIT(sg, data, data_i, data_l); - - CVMX_PREFETCH0(ivp); - CVMX_PREFETCH0(od->octo_enckey); - - flags = octeon_crypto_enable(&state); - - /* load AES Key */ - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[0], 0); - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[1], 1); - - if (od->octo_encklen == 16) { - CVMX_MT_AES_KEY(0x0, 2); - CVMX_MT_AES_KEY(0x0, 3); - } else if (od->octo_encklen == 24) { - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[2], 2); - CVMX_MT_AES_KEY(0x0, 3); - } else if (od->octo_encklen == 32) { - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[2], 2); - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[3], 3); - } else { - octeon_crypto_disable(&state, flags); - dprintk("%s: Bad key length %d\n", __FUNCTION__, od->octo_encklen); - return -EINVAL; - } - CVMX_MT_AES_KEYLENGTH(od->octo_encklen / 8 - 1); - - CVMX_MT_AES_IV(((uint64_t *) ivp)[0], 0); - CVMX_MT_AES_IV(((uint64_t *) ivp)[1], 1); - - while (crypt_off > 0) { - SG_CONSUME(sg, data, data_i, data_l); - crypt_off -= 8; - } - - while (crypt_len > 0) { - pdata = data; - CVMX_MT_AES_DEC_CBC0(*data); - SG_CONSUME(sg, data, data_i, data_l); - CVMX_MT_AES_DEC_CBC1(*data); - CVMX_MF_AES_RESULT(*pdata, 0); - CVMX_MF_AES_RESULT(*data, 1); - SG_CONSUME(sg, data, data_i, data_l); - crypt_len -= 16; - } - - octeon_crypto_disable(&state, flags); - return 0; -} - -/****************************************************************************/ -/* MD5 */ - -int -octo_null_md5_encrypt( - struct octo_sess *od, - struct scatterlist *sg, int sg_len, - int auth_off, int auth_len, - int crypt_off, int crypt_len, - int icv_off, uint8_t *ivp) -{ - register int next = 0; - uint64_t *data; - uint64_t tmp1, tmp2; - int data_i, data_l, alen = auth_len; - struct octeon_cop2_state state; - unsigned long flags; - - dprintk("%s()\n", __FUNCTION__); - - if (unlikely(od == NULL || sg==NULL || sg_len==0 || - (auth_off & 0x7) || (auth_off + auth_len > sg_len))) { - dprintk("%s: Bad parameters od=%p sg=%p sg_len=%d " - "auth_off=%d auth_len=%d crypt_off=%d crypt_len=%d " - "icv_off=%d ivp=%p\n", __FUNCTION__, od, sg, sg_len, - auth_off, auth_len, crypt_off, crypt_len, icv_off, ivp); - return -EINVAL; - } - - SG_INIT(sg, data, data_i, data_l); - - flags = octeon_crypto_enable(&state); - - /* Load MD5 IV */ - CVMX_MT_HSH_IV(od->octo_hminner[0], 0); - CVMX_MT_HSH_IV(od->octo_hminner[1], 1); - - while (auth_off > 0) { - SG_CONSUME(sg, data, data_i, data_l); - auth_off -= 8; - } - - while (auth_len > 0) { - CVM_LOAD_MD5_UNIT(*data, next); - auth_len -= 8; - SG_CONSUME(sg, data, data_i, data_l); - } - - /* finish the hash */ - CVMX_PREFETCH0(od->octo_hmouter); -#if 0 - if (unlikely(inplen)) { - uint64_t tmp = 0; - uint8_t *p = (uint8_t *) & tmp; - p[inplen] = 0x80; - do { - inplen--; - p[inplen] = ((uint8_t *) data)[inplen]; - } while (inplen); - CVM_LOAD_MD5_UNIT(tmp, next); - } else { - CVM_LOAD_MD5_UNIT(0x8000000000000000ULL, next); - } -#else - CVM_LOAD_MD5_UNIT(0x8000000000000000ULL, next); -#endif - - /* Finish Inner hash */ - while (next != 7) { - CVM_LOAD_MD5_UNIT(((uint64_t) 0x0ULL), next); - } - CVMX_ES64(tmp1, ((alen + 64) << 3)); - CVM_LOAD_MD5_UNIT(tmp1, next); - - /* Get the inner hash of HMAC */ - CVMX_MF_HSH_IV(tmp1, 0); - CVMX_MF_HSH_IV(tmp2, 1); - - /* Initialize hash unit */ - CVMX_MT_HSH_IV(od->octo_hmouter[0], 0); - CVMX_MT_HSH_IV(od->octo_hmouter[1], 1); - - CVMX_MT_HSH_DAT(tmp1, 0); - CVMX_MT_HSH_DAT(tmp2, 1); - CVMX_MT_HSH_DAT(0x8000000000000000ULL, 2); - CVMX_MT_HSH_DATZ(3); - CVMX_MT_HSH_DATZ(4); - CVMX_MT_HSH_DATZ(5); - CVMX_MT_HSH_DATZ(6); - CVMX_ES64(tmp1, ((64 + 16) << 3)); - CVMX_MT_HSH_STARTMD5(tmp1); - - /* save the HMAC */ - SG_INIT(sg, data, data_i, data_l); - while (icv_off > 0) { - SG_CONSUME(sg, data, data_i, data_l); - icv_off -= 8; - } - CVMX_MF_HSH_IV(*data, 0); - SG_CONSUME(sg, data, data_i, data_l); - CVMX_MF_HSH_IV(tmp1, 1); - *(uint32_t *)data = (uint32_t) (tmp1 >> 32); - - octeon_crypto_disable(&state, flags); - return 0; -} - -/****************************************************************************/ -/* SHA1 */ - -int -octo_null_sha1_encrypt( - struct octo_sess *od, - struct scatterlist *sg, int sg_len, - int auth_off, int auth_len, - int crypt_off, int crypt_len, - int icv_off, uint8_t *ivp) -{ - register int next = 0; - uint64_t *data; - uint64_t tmp1, tmp2, tmp3; - int data_i, data_l, alen = auth_len; - struct octeon_cop2_state state; - unsigned long flags; - - dprintk("%s()\n", __FUNCTION__); - - if (unlikely(od == NULL || sg==NULL || sg_len==0 || - (auth_off & 0x7) || (auth_off + auth_len > sg_len))) { - dprintk("%s: Bad parameters od=%p sg=%p sg_len=%d " - "auth_off=%d auth_len=%d crypt_off=%d crypt_len=%d " - "icv_off=%d ivp=%p\n", __FUNCTION__, od, sg, sg_len, - auth_off, auth_len, crypt_off, crypt_len, icv_off, ivp); - return -EINVAL; - } - - SG_INIT(sg, data, data_i, data_l); - - flags = octeon_crypto_enable(&state); - - /* Load SHA1 IV */ - CVMX_MT_HSH_IV(od->octo_hminner[0], 0); - CVMX_MT_HSH_IV(od->octo_hminner[1], 1); - CVMX_MT_HSH_IV(od->octo_hminner[2], 2); - - while (auth_off > 0) { - SG_CONSUME(sg, data, data_i, data_l); - auth_off -= 8; - } - - while (auth_len > 0) { - CVM_LOAD_SHA_UNIT(*data, next); - auth_len -= 8; - SG_CONSUME(sg, data, data_i, data_l); - } - - /* finish the hash */ - CVMX_PREFETCH0(od->octo_hmouter); -#if 0 - if (unlikely(inplen)) { - uint64_t tmp = 0; - uint8_t *p = (uint8_t *) & tmp; - p[inplen] = 0x80; - do { - inplen--; - p[inplen] = ((uint8_t *) data)[inplen]; - } while (inplen); - CVM_LOAD_MD5_UNIT(tmp, next); - } else { - CVM_LOAD_MD5_UNIT(0x8000000000000000ULL, next); - } -#else - CVM_LOAD_SHA_UNIT(0x8000000000000000ULL, next); -#endif - - /* Finish Inner hash */ - while (next != 7) { - CVM_LOAD_SHA_UNIT(((uint64_t) 0x0ULL), next); - } - CVM_LOAD_SHA_UNIT((uint64_t) ((alen + 64) << 3), next); - - /* Get the inner hash of HMAC */ - CVMX_MF_HSH_IV(tmp1, 0); - CVMX_MF_HSH_IV(tmp2, 1); - tmp3 = 0; - CVMX_MF_HSH_IV(tmp3, 2); - - /* Initialize hash unit */ - CVMX_MT_HSH_IV(od->octo_hmouter[0], 0); - CVMX_MT_HSH_IV(od->octo_hmouter[1], 1); - CVMX_MT_HSH_IV(od->octo_hmouter[2], 2); - - CVMX_MT_HSH_DAT(tmp1, 0); - CVMX_MT_HSH_DAT(tmp2, 1); - tmp3 |= 0x0000000080000000; - CVMX_MT_HSH_DAT(tmp3, 2); - CVMX_MT_HSH_DATZ(3); - CVMX_MT_HSH_DATZ(4); - CVMX_MT_HSH_DATZ(5); - CVMX_MT_HSH_DATZ(6); - CVMX_MT_HSH_STARTSHA((uint64_t) ((64 + 20) << 3)); - - /* save the HMAC */ - SG_INIT(sg, data, data_i, data_l); - while (icv_off > 0) { - SG_CONSUME(sg, data, data_i, data_l); - icv_off -= 8; - } - CVMX_MF_HSH_IV(*data, 0); - SG_CONSUME(sg, data, data_i, data_l); - CVMX_MF_HSH_IV(tmp1, 1); - *(uint32_t *)data = (uint32_t) (tmp1 >> 32); - - octeon_crypto_disable(&state, flags); - return 0; -} - -/****************************************************************************/ -/* DES MD5 */ - -int -octo_des_cbc_md5_encrypt( - struct octo_sess *od, - struct scatterlist *sg, int sg_len, - int auth_off, int auth_len, - int crypt_off, int crypt_len, - int icv_off, uint8_t *ivp) -{ - register int next = 0; - union { - uint32_t data32[2]; - uint64_t data64[1]; - } mydata; - uint64_t *data = &mydata.data64[0]; - uint32_t *data32; - uint64_t tmp1, tmp2; - int data_i, data_l, alen = auth_len; - struct octeon_cop2_state state; - unsigned long flags; - - dprintk("%s()\n", __FUNCTION__); - - if (unlikely(od == NULL || sg==NULL || sg_len==0 || ivp==NULL || - (crypt_off & 0x3) || (crypt_off + crypt_len > sg_len) || - (crypt_len & 0x7) || - (auth_len & 0x7) || - (auth_off & 0x3) || (auth_off + auth_len > sg_len))) { - dprintk("%s: Bad parameters od=%p sg=%p sg_len=%d " - "auth_off=%d auth_len=%d crypt_off=%d crypt_len=%d " - "icv_off=%d ivp=%p\n", __FUNCTION__, od, sg, sg_len, - auth_off, auth_len, crypt_off, crypt_len, icv_off, ivp); - return -EINVAL; - } - - SG_INIT(sg, data32, data_i, data_l); - - CVMX_PREFETCH0(ivp); - CVMX_PREFETCH0(od->octo_enckey); - - flags = octeon_crypto_enable(&state); - - /* load 3DES Key */ - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[0], 0); - if (od->octo_encklen == 24) { - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[1], 1); - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[2], 2); - } else if (od->octo_encklen == 8) { - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[0], 1); - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[0], 2); - } else { - octeon_crypto_disable(&state, flags); - dprintk("%s: Bad key length %d\n", __FUNCTION__, od->octo_encklen); - return -EINVAL; - } - - CVMX_MT_3DES_IV(* (uint64_t *) ivp); - - /* Load MD5 IV */ - CVMX_MT_HSH_IV(od->octo_hminner[0], 0); - CVMX_MT_HSH_IV(od->octo_hminner[1], 1); - - while (crypt_off > 0 && auth_off > 0) { - SG_CONSUME(sg, data32, data_i, data_l); - crypt_off -= 4; - auth_off -= 4; - } - - while (crypt_len > 0 || auth_len > 0) { - uint32_t *first = data32; - mydata.data32[0] = *first; - SG_CONSUME(sg, data32, data_i, data_l); - mydata.data32[1] = *data32; - if (crypt_off <= 0) { - if (crypt_len > 0) { - CVMX_MT_3DES_ENC_CBC(*data); - CVMX_MF_3DES_RESULT(*data); - crypt_len -= 8; - } - } else - crypt_off -= 8; - if (auth_off <= 0) { - if (auth_len > 0) { - CVM_LOAD_MD5_UNIT(*data, next); - auth_len -= 8; - } - } else - auth_off -= 8; - *first = mydata.data32[0]; - *data32 = mydata.data32[1]; - SG_CONSUME(sg, data32, data_i, data_l); - } - - /* finish the hash */ - CVMX_PREFETCH0(od->octo_hmouter); -#if 0 - if (unlikely(inplen)) { - uint64_t tmp = 0; - uint8_t *p = (uint8_t *) & tmp; - p[inplen] = 0x80; - do { - inplen--; - p[inplen] = ((uint8_t *) data)[inplen]; - } while (inplen); - CVM_LOAD_MD5_UNIT(tmp, next); - } else { - CVM_LOAD_MD5_UNIT(0x8000000000000000ULL, next); - } -#else - CVM_LOAD_MD5_UNIT(0x8000000000000000ULL, next); -#endif - - /* Finish Inner hash */ - while (next != 7) { - CVM_LOAD_MD5_UNIT(((uint64_t) 0x0ULL), next); - } - CVMX_ES64(tmp1, ((alen + 64) << 3)); - CVM_LOAD_MD5_UNIT(tmp1, next); - - /* Get the inner hash of HMAC */ - CVMX_MF_HSH_IV(tmp1, 0); - CVMX_MF_HSH_IV(tmp2, 1); - - /* Initialize hash unit */ - CVMX_MT_HSH_IV(od->octo_hmouter[0], 0); - CVMX_MT_HSH_IV(od->octo_hmouter[1], 1); - - CVMX_MT_HSH_DAT(tmp1, 0); - CVMX_MT_HSH_DAT(tmp2, 1); - CVMX_MT_HSH_DAT(0x8000000000000000ULL, 2); - CVMX_MT_HSH_DATZ(3); - CVMX_MT_HSH_DATZ(4); - CVMX_MT_HSH_DATZ(5); - CVMX_MT_HSH_DATZ(6); - CVMX_ES64(tmp1, ((64 + 16) << 3)); - CVMX_MT_HSH_STARTMD5(tmp1); - - /* save the HMAC */ - SG_INIT(sg, data32, data_i, data_l); - while (icv_off > 0) { - SG_CONSUME(sg, data32, data_i, data_l); - icv_off -= 4; - } - CVMX_MF_HSH_IV(tmp1, 0); - *data32 = (uint32_t) (tmp1 >> 32); - SG_CONSUME(sg, data32, data_i, data_l); - *data32 = (uint32_t) tmp1; - SG_CONSUME(sg, data32, data_i, data_l); - CVMX_MF_HSH_IV(tmp1, 1); - *data32 = (uint32_t) (tmp1 >> 32); - - octeon_crypto_disable(&state, flags); - return 0; -} - -int -octo_des_cbc_md5_decrypt( - struct octo_sess *od, - struct scatterlist *sg, int sg_len, - int auth_off, int auth_len, - int crypt_off, int crypt_len, - int icv_off, uint8_t *ivp) -{ - register int next = 0; - union { - uint32_t data32[2]; - uint64_t data64[1]; - } mydata; - uint64_t *data = &mydata.data64[0]; - uint32_t *data32; - uint64_t tmp1, tmp2; - int data_i, data_l, alen = auth_len; - struct octeon_cop2_state state; - unsigned long flags; - - dprintk("%s()\n", __FUNCTION__); - - if (unlikely(od == NULL || sg==NULL || sg_len==0 || ivp==NULL || - (crypt_off & 0x3) || (crypt_off + crypt_len > sg_len) || - (crypt_len & 0x7) || - (auth_len & 0x7) || - (auth_off & 0x3) || (auth_off + auth_len > sg_len))) { - dprintk("%s: Bad parameters od=%p sg=%p sg_len=%d " - "auth_off=%d auth_len=%d crypt_off=%d crypt_len=%d " - "icv_off=%d ivp=%p\n", __FUNCTION__, od, sg, sg_len, - auth_off, auth_len, crypt_off, crypt_len, icv_off, ivp); - return -EINVAL; - } - - SG_INIT(sg, data32, data_i, data_l); - - CVMX_PREFETCH0(ivp); - CVMX_PREFETCH0(od->octo_enckey); - - flags = octeon_crypto_enable(&state); - - /* load 3DES Key */ - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[0], 0); - if (od->octo_encklen == 24) { - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[1], 1); - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[2], 2); - } else if (od->octo_encklen == 8) { - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[0], 1); - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[0], 2); - } else { - octeon_crypto_disable(&state, flags); - dprintk("%s: Bad key length %d\n", __FUNCTION__, od->octo_encklen); - return -EINVAL; - } - - CVMX_MT_3DES_IV(* (uint64_t *) ivp); - - /* Load MD5 IV */ - CVMX_MT_HSH_IV(od->octo_hminner[0], 0); - CVMX_MT_HSH_IV(od->octo_hminner[1], 1); - - while (crypt_off > 0 && auth_off > 0) { - SG_CONSUME(sg, data32, data_i, data_l); - crypt_off -= 4; - auth_off -= 4; - } - - while (crypt_len > 0 || auth_len > 0) { - uint32_t *first = data32; - mydata.data32[0] = *first; - SG_CONSUME(sg, data32, data_i, data_l); - mydata.data32[1] = *data32; - if (auth_off <= 0) { - if (auth_len > 0) { - CVM_LOAD_MD5_UNIT(*data, next); - auth_len -= 8; - } - } else - auth_off -= 8; - if (crypt_off <= 0) { - if (crypt_len > 0) { - CVMX_MT_3DES_DEC_CBC(*data); - CVMX_MF_3DES_RESULT(*data); - crypt_len -= 8; - } - } else - crypt_off -= 8; - *first = mydata.data32[0]; - *data32 = mydata.data32[1]; - SG_CONSUME(sg, data32, data_i, data_l); - } - - /* finish the hash */ - CVMX_PREFETCH0(od->octo_hmouter); -#if 0 - if (unlikely(inplen)) { - uint64_t tmp = 0; - uint8_t *p = (uint8_t *) & tmp; - p[inplen] = 0x80; - do { - inplen--; - p[inplen] = ((uint8_t *) data)[inplen]; - } while (inplen); - CVM_LOAD_MD5_UNIT(tmp, next); - } else { - CVM_LOAD_MD5_UNIT(0x8000000000000000ULL, next); - } -#else - CVM_LOAD_MD5_UNIT(0x8000000000000000ULL, next); -#endif - - /* Finish Inner hash */ - while (next != 7) { - CVM_LOAD_MD5_UNIT(((uint64_t) 0x0ULL), next); - } - CVMX_ES64(tmp1, ((alen + 64) << 3)); - CVM_LOAD_MD5_UNIT(tmp1, next); - - /* Get the inner hash of HMAC */ - CVMX_MF_HSH_IV(tmp1, 0); - CVMX_MF_HSH_IV(tmp2, 1); - - /* Initialize hash unit */ - CVMX_MT_HSH_IV(od->octo_hmouter[0], 0); - CVMX_MT_HSH_IV(od->octo_hmouter[1], 1); - - CVMX_MT_HSH_DAT(tmp1, 0); - CVMX_MT_HSH_DAT(tmp2, 1); - CVMX_MT_HSH_DAT(0x8000000000000000ULL, 2); - CVMX_MT_HSH_DATZ(3); - CVMX_MT_HSH_DATZ(4); - CVMX_MT_HSH_DATZ(5); - CVMX_MT_HSH_DATZ(6); - CVMX_ES64(tmp1, ((64 + 16) << 3)); - CVMX_MT_HSH_STARTMD5(tmp1); - - /* save the HMAC */ - SG_INIT(sg, data32, data_i, data_l); - while (icv_off > 0) { - SG_CONSUME(sg, data32, data_i, data_l); - icv_off -= 4; - } - CVMX_MF_HSH_IV(tmp1, 0); - *data32 = (uint32_t) (tmp1 >> 32); - SG_CONSUME(sg, data32, data_i, data_l); - *data32 = (uint32_t) tmp1; - SG_CONSUME(sg, data32, data_i, data_l); - CVMX_MF_HSH_IV(tmp1, 1); - *data32 = (uint32_t) (tmp1 >> 32); - - octeon_crypto_disable(&state, flags); - return 0; -} - -/****************************************************************************/ -/* DES SHA */ - -int -octo_des_cbc_sha1_encrypt( - struct octo_sess *od, - struct scatterlist *sg, int sg_len, - int auth_off, int auth_len, - int crypt_off, int crypt_len, - int icv_off, uint8_t *ivp) -{ - register int next = 0; - union { - uint32_t data32[2]; - uint64_t data64[1]; - } mydata; - uint64_t *data = &mydata.data64[0]; - uint32_t *data32; - uint64_t tmp1, tmp2, tmp3; - int data_i, data_l, alen = auth_len; - struct octeon_cop2_state state; - unsigned long flags; - - dprintk("%s()\n", __FUNCTION__); - - if (unlikely(od == NULL || sg==NULL || sg_len==0 || ivp==NULL || - (crypt_off & 0x3) || (crypt_off + crypt_len > sg_len) || - (crypt_len & 0x7) || - (auth_len & 0x7) || - (auth_off & 0x3) || (auth_off + auth_len > sg_len))) { - dprintk("%s: Bad parameters od=%p sg=%p sg_len=%d " - "auth_off=%d auth_len=%d crypt_off=%d crypt_len=%d " - "icv_off=%d ivp=%p\n", __FUNCTION__, od, sg, sg_len, - auth_off, auth_len, crypt_off, crypt_len, icv_off, ivp); - return -EINVAL; - } - - SG_INIT(sg, data32, data_i, data_l); - - CVMX_PREFETCH0(ivp); - CVMX_PREFETCH0(od->octo_enckey); - - flags = octeon_crypto_enable(&state); - - /* load 3DES Key */ - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[0], 0); - if (od->octo_encklen == 24) { - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[1], 1); - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[2], 2); - } else if (od->octo_encklen == 8) { - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[0], 1); - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[0], 2); - } else { - octeon_crypto_disable(&state, flags); - dprintk("%s: Bad key length %d\n", __FUNCTION__, od->octo_encklen); - return -EINVAL; - } - - CVMX_MT_3DES_IV(* (uint64_t *) ivp); - - /* Load SHA1 IV */ - CVMX_MT_HSH_IV(od->octo_hminner[0], 0); - CVMX_MT_HSH_IV(od->octo_hminner[1], 1); - CVMX_MT_HSH_IV(od->octo_hminner[2], 2); - - while (crypt_off > 0 && auth_off > 0) { - SG_CONSUME(sg, data32, data_i, data_l); - crypt_off -= 4; - auth_off -= 4; - } - - while (crypt_len > 0 || auth_len > 0) { - uint32_t *first = data32; - mydata.data32[0] = *first; - SG_CONSUME(sg, data32, data_i, data_l); - mydata.data32[1] = *data32; - if (crypt_off <= 0) { - if (crypt_len > 0) { - CVMX_MT_3DES_ENC_CBC(*data); - CVMX_MF_3DES_RESULT(*data); - crypt_len -= 8; - } - } else - crypt_off -= 8; - if (auth_off <= 0) { - if (auth_len > 0) { - CVM_LOAD_SHA_UNIT(*data, next); - auth_len -= 8; - } - } else - auth_off -= 8; - *first = mydata.data32[0]; - *data32 = mydata.data32[1]; - SG_CONSUME(sg, data32, data_i, data_l); - } - - /* finish the hash */ - CVMX_PREFETCH0(od->octo_hmouter); -#if 0 - if (unlikely(inplen)) { - uint64_t tmp = 0; - uint8_t *p = (uint8_t *) & tmp; - p[inplen] = 0x80; - do { - inplen--; - p[inplen] = ((uint8_t *) data)[inplen]; - } while (inplen); - CVM_LOAD_SHA_UNIT(tmp, next); - } else { - CVM_LOAD_SHA_UNIT(0x8000000000000000ULL, next); - } -#else - CVM_LOAD_SHA_UNIT(0x8000000000000000ULL, next); -#endif - - /* Finish Inner hash */ - while (next != 7) { - CVM_LOAD_SHA_UNIT(((uint64_t) 0x0ULL), next); - } - CVM_LOAD_SHA_UNIT((uint64_t) ((alen + 64) << 3), next); - - /* Get the inner hash of HMAC */ - CVMX_MF_HSH_IV(tmp1, 0); - CVMX_MF_HSH_IV(tmp2, 1); - tmp3 = 0; - CVMX_MF_HSH_IV(tmp3, 2); - - /* Initialize hash unit */ - CVMX_MT_HSH_IV(od->octo_hmouter[0], 0); - CVMX_MT_HSH_IV(od->octo_hmouter[1], 1); - CVMX_MT_HSH_IV(od->octo_hmouter[2], 2); - - CVMX_MT_HSH_DAT(tmp1, 0); - CVMX_MT_HSH_DAT(tmp2, 1); - tmp3 |= 0x0000000080000000; - CVMX_MT_HSH_DAT(tmp3, 2); - CVMX_MT_HSH_DATZ(3); - CVMX_MT_HSH_DATZ(4); - CVMX_MT_HSH_DATZ(5); - CVMX_MT_HSH_DATZ(6); - CVMX_MT_HSH_STARTSHA((uint64_t) ((64 + 20) << 3)); - - /* save the HMAC */ - SG_INIT(sg, data32, data_i, data_l); - while (icv_off > 0) { - SG_CONSUME(sg, data32, data_i, data_l); - icv_off -= 4; - } - CVMX_MF_HSH_IV(tmp1, 0); - *data32 = (uint32_t) (tmp1 >> 32); - SG_CONSUME(sg, data32, data_i, data_l); - *data32 = (uint32_t) tmp1; - SG_CONSUME(sg, data32, data_i, data_l); - CVMX_MF_HSH_IV(tmp1, 1); - *data32 = (uint32_t) (tmp1 >> 32); - - octeon_crypto_disable(&state, flags); - return 0; -} - -int -octo_des_cbc_sha1_decrypt( - struct octo_sess *od, - struct scatterlist *sg, int sg_len, - int auth_off, int auth_len, - int crypt_off, int crypt_len, - int icv_off, uint8_t *ivp) -{ - register int next = 0; - union { - uint32_t data32[2]; - uint64_t data64[1]; - } mydata; - uint64_t *data = &mydata.data64[0]; - uint32_t *data32; - uint64_t tmp1, tmp2, tmp3; - int data_i, data_l, alen = auth_len; - struct octeon_cop2_state state; - unsigned long flags; - - dprintk("%s()\n", __FUNCTION__); - - if (unlikely(od == NULL || sg==NULL || sg_len==0 || ivp==NULL || - (crypt_off & 0x3) || (crypt_off + crypt_len > sg_len) || - (crypt_len & 0x7) || - (auth_len & 0x7) || - (auth_off & 0x3) || (auth_off + auth_len > sg_len))) { - dprintk("%s: Bad parameters od=%p sg=%p sg_len=%d " - "auth_off=%d auth_len=%d crypt_off=%d crypt_len=%d " - "icv_off=%d ivp=%p\n", __FUNCTION__, od, sg, sg_len, - auth_off, auth_len, crypt_off, crypt_len, icv_off, ivp); - return -EINVAL; - } - - SG_INIT(sg, data32, data_i, data_l); - - CVMX_PREFETCH0(ivp); - CVMX_PREFETCH0(od->octo_enckey); - - flags = octeon_crypto_enable(&state); - - /* load 3DES Key */ - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[0], 0); - if (od->octo_encklen == 24) { - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[1], 1); - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[2], 2); - } else if (od->octo_encklen == 8) { - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[0], 1); - CVMX_MT_3DES_KEY(((uint64_t *) od->octo_enckey)[0], 2); - } else { - octeon_crypto_disable(&state, flags); - dprintk("%s: Bad key length %d\n", __FUNCTION__, od->octo_encklen); - return -EINVAL; - } - - CVMX_MT_3DES_IV(* (uint64_t *) ivp); - - /* Load SHA1 IV */ - CVMX_MT_HSH_IV(od->octo_hminner[0], 0); - CVMX_MT_HSH_IV(od->octo_hminner[1], 1); - CVMX_MT_HSH_IV(od->octo_hminner[2], 2); - - while (crypt_off > 0 && auth_off > 0) { - SG_CONSUME(sg, data32, data_i, data_l); - crypt_off -= 4; - auth_off -= 4; - } - - while (crypt_len > 0 || auth_len > 0) { - uint32_t *first = data32; - mydata.data32[0] = *first; - SG_CONSUME(sg, data32, data_i, data_l); - mydata.data32[1] = *data32; - if (auth_off <= 0) { - if (auth_len > 0) { - CVM_LOAD_SHA_UNIT(*data, next); - auth_len -= 8; - } - } else - auth_off -= 8; - if (crypt_off <= 0) { - if (crypt_len > 0) { - CVMX_MT_3DES_DEC_CBC(*data); - CVMX_MF_3DES_RESULT(*data); - crypt_len -= 8; - } - } else - crypt_off -= 8; - *first = mydata.data32[0]; - *data32 = mydata.data32[1]; - SG_CONSUME(sg, data32, data_i, data_l); - } - - /* finish the hash */ - CVMX_PREFETCH0(od->octo_hmouter); -#if 0 - if (unlikely(inplen)) { - uint64_t tmp = 0; - uint8_t *p = (uint8_t *) & tmp; - p[inplen] = 0x80; - do { - inplen--; - p[inplen] = ((uint8_t *) data)[inplen]; - } while (inplen); - CVM_LOAD_SHA_UNIT(tmp, next); - } else { - CVM_LOAD_SHA_UNIT(0x8000000000000000ULL, next); - } -#else - CVM_LOAD_SHA_UNIT(0x8000000000000000ULL, next); -#endif - - /* Finish Inner hash */ - while (next != 7) { - CVM_LOAD_SHA_UNIT(((uint64_t) 0x0ULL), next); - } - CVM_LOAD_SHA_UNIT((uint64_t) ((alen + 64) << 3), next); - - /* Get the inner hash of HMAC */ - CVMX_MF_HSH_IV(tmp1, 0); - CVMX_MF_HSH_IV(tmp2, 1); - tmp3 = 0; - CVMX_MF_HSH_IV(tmp3, 2); - - /* Initialize hash unit */ - CVMX_MT_HSH_IV(od->octo_hmouter[0], 0); - CVMX_MT_HSH_IV(od->octo_hmouter[1], 1); - CVMX_MT_HSH_IV(od->octo_hmouter[2], 2); - - CVMX_MT_HSH_DAT(tmp1, 0); - CVMX_MT_HSH_DAT(tmp2, 1); - tmp3 |= 0x0000000080000000; - CVMX_MT_HSH_DAT(tmp3, 2); - CVMX_MT_HSH_DATZ(3); - CVMX_MT_HSH_DATZ(4); - CVMX_MT_HSH_DATZ(5); - CVMX_MT_HSH_DATZ(6); - CVMX_MT_HSH_STARTSHA((uint64_t) ((64 + 20) << 3)); - /* save the HMAC */ - SG_INIT(sg, data32, data_i, data_l); - while (icv_off > 0) { - SG_CONSUME(sg, data32, data_i, data_l); - icv_off -= 4; - } - CVMX_MF_HSH_IV(tmp1, 0); - *data32 = (uint32_t) (tmp1 >> 32); - SG_CONSUME(sg, data32, data_i, data_l); - *data32 = (uint32_t) tmp1; - SG_CONSUME(sg, data32, data_i, data_l); - CVMX_MF_HSH_IV(tmp1, 1); - *data32 = (uint32_t) (tmp1 >> 32); - - octeon_crypto_disable(&state, flags); - return 0; -} - -/****************************************************************************/ -/* AES MD5 */ - -int -octo_aes_cbc_md5_encrypt( - struct octo_sess *od, - struct scatterlist *sg, int sg_len, - int auth_off, int auth_len, - int crypt_off, int crypt_len, - int icv_off, uint8_t *ivp) -{ - register int next = 0; - union { - uint32_t data32[2]; - uint64_t data64[1]; - } mydata[2]; - uint64_t *pdata = &mydata[0].data64[0]; - uint64_t *data = &mydata[1].data64[0]; - uint32_t *data32; - uint64_t tmp1, tmp2; - int data_i, data_l, alen = auth_len; - struct octeon_cop2_state state; - unsigned long flags; - - dprintk("%s()\n", __FUNCTION__); - - if (unlikely(od == NULL || sg==NULL || sg_len==0 || ivp==NULL || - (crypt_off & 0x3) || (crypt_off + crypt_len > sg_len) || - (crypt_len & 0x7) || - (auth_len & 0x7) || - (auth_off & 0x3) || (auth_off + auth_len > sg_len))) { - dprintk("%s: Bad parameters od=%p sg=%p sg_len=%d " - "auth_off=%d auth_len=%d crypt_off=%d crypt_len=%d " - "icv_off=%d ivp=%p\n", __FUNCTION__, od, sg, sg_len, - auth_off, auth_len, crypt_off, crypt_len, icv_off, ivp); - return -EINVAL; - } - - SG_INIT(sg, data32, data_i, data_l); - - CVMX_PREFETCH0(ivp); - CVMX_PREFETCH0(od->octo_enckey); - - flags = octeon_crypto_enable(&state); - - /* load AES Key */ - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[0], 0); - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[1], 1); - - if (od->octo_encklen == 16) { - CVMX_MT_AES_KEY(0x0, 2); - CVMX_MT_AES_KEY(0x0, 3); - } else if (od->octo_encklen == 24) { - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[2], 2); - CVMX_MT_AES_KEY(0x0, 3); - } else if (od->octo_encklen == 32) { - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[2], 2); - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[3], 3); - } else { - octeon_crypto_disable(&state, flags); - dprintk("%s: Bad key length %d\n", __FUNCTION__, od->octo_encklen); - return -EINVAL; - } - CVMX_MT_AES_KEYLENGTH(od->octo_encklen / 8 - 1); - - CVMX_MT_AES_IV(((uint64_t *) ivp)[0], 0); - CVMX_MT_AES_IV(((uint64_t *) ivp)[1], 1); - - /* Load MD5 IV */ - CVMX_MT_HSH_IV(od->octo_hminner[0], 0); - CVMX_MT_HSH_IV(od->octo_hminner[1], 1); - - while (crypt_off > 0 && auth_off > 0) { - SG_CONSUME(sg, data32, data_i, data_l); - crypt_off -= 4; - auth_off -= 4; - } - - /* align auth and crypt */ - while (crypt_off > 0 && auth_len > 0) { - mydata[0].data32[0] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - mydata[0].data32[1] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - CVM_LOAD_MD5_UNIT(*pdata, next); - crypt_off -= 8; - auth_len -= 8; - } - - while (crypt_len > 0) { - uint32_t *pdata32[3]; - - pdata32[0] = data32; - mydata[0].data32[0] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - - pdata32[1] = data32; - mydata[0].data32[1] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - - pdata32[2] = data32; - mydata[1].data32[0] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - - mydata[1].data32[1] = *data32; - - CVMX_MT_AES_ENC_CBC0(*pdata); - CVMX_MT_AES_ENC_CBC1(*data); - CVMX_MF_AES_RESULT(*pdata, 0); - CVMX_MF_AES_RESULT(*data, 1); - crypt_len -= 16; - - if (auth_len > 0) { - CVM_LOAD_MD5_UNIT(*pdata, next); - auth_len -= 8; - } - if (auth_len > 0) { - CVM_LOAD_MD5_UNIT(*data, next); - auth_len -= 8; - } - - *pdata32[0] = mydata[0].data32[0]; - *pdata32[1] = mydata[0].data32[1]; - *pdata32[2] = mydata[1].data32[0]; - *data32 = mydata[1].data32[1]; - - SG_CONSUME(sg, data32, data_i, data_l); - } - - /* finish any left over hashing */ - while (auth_len > 0) { - mydata[0].data32[0] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - mydata[0].data32[1] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - CVM_LOAD_MD5_UNIT(*pdata, next); - auth_len -= 8; - } - - /* finish the hash */ - CVMX_PREFETCH0(od->octo_hmouter); -#if 0 - if (unlikely(inplen)) { - uint64_t tmp = 0; - uint8_t *p = (uint8_t *) & tmp; - p[inplen] = 0x80; - do { - inplen--; - p[inplen] = ((uint8_t *) data)[inplen]; - } while (inplen); - CVM_LOAD_MD5_UNIT(tmp, next); - } else { - CVM_LOAD_MD5_UNIT(0x8000000000000000ULL, next); - } -#else - CVM_LOAD_MD5_UNIT(0x8000000000000000ULL, next); -#endif - - /* Finish Inner hash */ - while (next != 7) { - CVM_LOAD_MD5_UNIT(((uint64_t) 0x0ULL), next); - } - CVMX_ES64(tmp1, ((alen + 64) << 3)); - CVM_LOAD_MD5_UNIT(tmp1, next); - - /* Get the inner hash of HMAC */ - CVMX_MF_HSH_IV(tmp1, 0); - CVMX_MF_HSH_IV(tmp2, 1); - - /* Initialize hash unit */ - CVMX_MT_HSH_IV(od->octo_hmouter[0], 0); - CVMX_MT_HSH_IV(od->octo_hmouter[1], 1); - - CVMX_MT_HSH_DAT(tmp1, 0); - CVMX_MT_HSH_DAT(tmp2, 1); - CVMX_MT_HSH_DAT(0x8000000000000000ULL, 2); - CVMX_MT_HSH_DATZ(3); - CVMX_MT_HSH_DATZ(4); - CVMX_MT_HSH_DATZ(5); - CVMX_MT_HSH_DATZ(6); - CVMX_ES64(tmp1, ((64 + 16) << 3)); - CVMX_MT_HSH_STARTMD5(tmp1); - - /* save the HMAC */ - SG_INIT(sg, data32, data_i, data_l); - while (icv_off > 0) { - SG_CONSUME(sg, data32, data_i, data_l); - icv_off -= 4; - } - CVMX_MF_HSH_IV(tmp1, 0); - *data32 = (uint32_t) (tmp1 >> 32); - SG_CONSUME(sg, data32, data_i, data_l); - *data32 = (uint32_t) tmp1; - SG_CONSUME(sg, data32, data_i, data_l); - CVMX_MF_HSH_IV(tmp1, 1); - *data32 = (uint32_t) (tmp1 >> 32); - - octeon_crypto_disable(&state, flags); - return 0; -} - -int -octo_aes_cbc_md5_decrypt( - struct octo_sess *od, - struct scatterlist *sg, int sg_len, - int auth_off, int auth_len, - int crypt_off, int crypt_len, - int icv_off, uint8_t *ivp) -{ - register int next = 0; - union { - uint32_t data32[2]; - uint64_t data64[1]; - } mydata[2]; - uint64_t *pdata = &mydata[0].data64[0]; - uint64_t *data = &mydata[1].data64[0]; - uint32_t *data32; - uint64_t tmp1, tmp2; - int data_i, data_l, alen = auth_len; - struct octeon_cop2_state state; - unsigned long flags; - - dprintk("%s()\n", __FUNCTION__); - - if (unlikely(od == NULL || sg==NULL || sg_len==0 || ivp==NULL || - (crypt_off & 0x3) || (crypt_off + crypt_len > sg_len) || - (crypt_len & 0x7) || - (auth_len & 0x7) || - (auth_off & 0x3) || (auth_off + auth_len > sg_len))) { - dprintk("%s: Bad parameters od=%p sg=%p sg_len=%d " - "auth_off=%d auth_len=%d crypt_off=%d crypt_len=%d " - "icv_off=%d ivp=%p\n", __FUNCTION__, od, sg, sg_len, - auth_off, auth_len, crypt_off, crypt_len, icv_off, ivp); - return -EINVAL; - } - - SG_INIT(sg, data32, data_i, data_l); - - CVMX_PREFETCH0(ivp); - CVMX_PREFETCH0(od->octo_enckey); - - flags = octeon_crypto_enable(&state); - - /* load AES Key */ - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[0], 0); - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[1], 1); - - if (od->octo_encklen == 16) { - CVMX_MT_AES_KEY(0x0, 2); - CVMX_MT_AES_KEY(0x0, 3); - } else if (od->octo_encklen == 24) { - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[2], 2); - CVMX_MT_AES_KEY(0x0, 3); - } else if (od->octo_encklen == 32) { - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[2], 2); - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[3], 3); - } else { - octeon_crypto_disable(&state, flags); - dprintk("%s: Bad key length %d\n", __FUNCTION__, od->octo_encklen); - return -EINVAL; - } - CVMX_MT_AES_KEYLENGTH(od->octo_encklen / 8 - 1); - - CVMX_MT_AES_IV(((uint64_t *) ivp)[0], 0); - CVMX_MT_AES_IV(((uint64_t *) ivp)[1], 1); - - /* Load MD5 IV */ - CVMX_MT_HSH_IV(od->octo_hminner[0], 0); - CVMX_MT_HSH_IV(od->octo_hminner[1], 1); - - while (crypt_off > 0 && auth_off > 0) { - SG_CONSUME(sg, data32, data_i, data_l); - crypt_off -= 4; - auth_off -= 4; - } - - /* align auth and crypt */ - while (crypt_off > 0 && auth_len > 0) { - mydata[0].data32[0] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - mydata[0].data32[1] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - CVM_LOAD_MD5_UNIT(*pdata, next); - crypt_off -= 8; - auth_len -= 8; - } - - while (crypt_len > 0) { - uint32_t *pdata32[3]; - - pdata32[0] = data32; - mydata[0].data32[0] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - pdata32[1] = data32; - mydata[0].data32[1] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - pdata32[2] = data32; - mydata[1].data32[0] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - mydata[1].data32[1] = *data32; - - if (auth_len > 0) { - CVM_LOAD_MD5_UNIT(*pdata, next); - auth_len -= 8; - } - - if (auth_len > 0) { - CVM_LOAD_MD5_UNIT(*data, next); - auth_len -= 8; - } - - CVMX_MT_AES_DEC_CBC0(*pdata); - CVMX_MT_AES_DEC_CBC1(*data); - CVMX_MF_AES_RESULT(*pdata, 0); - CVMX_MF_AES_RESULT(*data, 1); - crypt_len -= 16; - - *pdata32[0] = mydata[0].data32[0]; - *pdata32[1] = mydata[0].data32[1]; - *pdata32[2] = mydata[1].data32[0]; - *data32 = mydata[1].data32[1]; - - SG_CONSUME(sg, data32, data_i, data_l); - } - - /* finish left over hash if any */ - while (auth_len > 0) { - mydata[0].data32[0] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - mydata[0].data32[1] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - CVM_LOAD_MD5_UNIT(*pdata, next); - auth_len -= 8; - } - - - /* finish the hash */ - CVMX_PREFETCH0(od->octo_hmouter); -#if 0 - if (unlikely(inplen)) { - uint64_t tmp = 0; - uint8_t *p = (uint8_t *) & tmp; - p[inplen] = 0x80; - do { - inplen--; - p[inplen] = ((uint8_t *) data)[inplen]; - } while (inplen); - CVM_LOAD_MD5_UNIT(tmp, next); - } else { - CVM_LOAD_MD5_UNIT(0x8000000000000000ULL, next); - } -#else - CVM_LOAD_MD5_UNIT(0x8000000000000000ULL, next); -#endif - - /* Finish Inner hash */ - while (next != 7) { - CVM_LOAD_MD5_UNIT(((uint64_t) 0x0ULL), next); - } - CVMX_ES64(tmp1, ((alen + 64) << 3)); - CVM_LOAD_MD5_UNIT(tmp1, next); - - /* Get the inner hash of HMAC */ - CVMX_MF_HSH_IV(tmp1, 0); - CVMX_MF_HSH_IV(tmp2, 1); - - /* Initialize hash unit */ - CVMX_MT_HSH_IV(od->octo_hmouter[0], 0); - CVMX_MT_HSH_IV(od->octo_hmouter[1], 1); - - CVMX_MT_HSH_DAT(tmp1, 0); - CVMX_MT_HSH_DAT(tmp2, 1); - CVMX_MT_HSH_DAT(0x8000000000000000ULL, 2); - CVMX_MT_HSH_DATZ(3); - CVMX_MT_HSH_DATZ(4); - CVMX_MT_HSH_DATZ(5); - CVMX_MT_HSH_DATZ(6); - CVMX_ES64(tmp1, ((64 + 16) << 3)); - CVMX_MT_HSH_STARTMD5(tmp1); - - /* save the HMAC */ - SG_INIT(sg, data32, data_i, data_l); - while (icv_off > 0) { - SG_CONSUME(sg, data32, data_i, data_l); - icv_off -= 4; - } - CVMX_MF_HSH_IV(tmp1, 0); - *data32 = (uint32_t) (tmp1 >> 32); - SG_CONSUME(sg, data32, data_i, data_l); - *data32 = (uint32_t) tmp1; - SG_CONSUME(sg, data32, data_i, data_l); - CVMX_MF_HSH_IV(tmp1, 1); - *data32 = (uint32_t) (tmp1 >> 32); - - octeon_crypto_disable(&state, flags); - return 0; -} - -/****************************************************************************/ -/* AES SHA1 */ - -int -octo_aes_cbc_sha1_encrypt( - struct octo_sess *od, - struct scatterlist *sg, int sg_len, - int auth_off, int auth_len, - int crypt_off, int crypt_len, - int icv_off, uint8_t *ivp) -{ - register int next = 0; - union { - uint32_t data32[2]; - uint64_t data64[1]; - } mydata[2]; - uint64_t *pdata = &mydata[0].data64[0]; - uint64_t *data = &mydata[1].data64[0]; - uint32_t *data32; - uint64_t tmp1, tmp2, tmp3; - int data_i, data_l, alen = auth_len; - struct octeon_cop2_state state; - unsigned long flags; - - dprintk("%s(a_off=%d a_len=%d c_off=%d c_len=%d icv_off=%d)\n", - __FUNCTION__, auth_off, auth_len, crypt_off, crypt_len, icv_off); - - if (unlikely(od == NULL || sg==NULL || sg_len==0 || ivp==NULL || - (crypt_off & 0x3) || (crypt_off + crypt_len > sg_len) || - (crypt_len & 0x7) || - (auth_len & 0x7) || - (auth_off & 0x3) || (auth_off + auth_len > sg_len))) { - dprintk("%s: Bad parameters od=%p sg=%p sg_len=%d " - "auth_off=%d auth_len=%d crypt_off=%d crypt_len=%d " - "icv_off=%d ivp=%p\n", __FUNCTION__, od, sg, sg_len, - auth_off, auth_len, crypt_off, crypt_len, icv_off, ivp); - return -EINVAL; - } - - SG_INIT(sg, data32, data_i, data_l); - - CVMX_PREFETCH0(ivp); - CVMX_PREFETCH0(od->octo_enckey); - - flags = octeon_crypto_enable(&state); - - /* load AES Key */ - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[0], 0); - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[1], 1); - - if (od->octo_encklen == 16) { - CVMX_MT_AES_KEY(0x0, 2); - CVMX_MT_AES_KEY(0x0, 3); - } else if (od->octo_encklen == 24) { - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[2], 2); - CVMX_MT_AES_KEY(0x0, 3); - } else if (od->octo_encklen == 32) { - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[2], 2); - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[3], 3); - } else { - octeon_crypto_disable(&state, flags); - dprintk("%s: Bad key length %d\n", __FUNCTION__, od->octo_encklen); - return -EINVAL; - } - CVMX_MT_AES_KEYLENGTH(od->octo_encklen / 8 - 1); - - CVMX_MT_AES_IV(((uint64_t *) ivp)[0], 0); - CVMX_MT_AES_IV(((uint64_t *) ivp)[1], 1); - - /* Load SHA IV */ - CVMX_MT_HSH_IV(od->octo_hminner[0], 0); - CVMX_MT_HSH_IV(od->octo_hminner[1], 1); - CVMX_MT_HSH_IV(od->octo_hminner[2], 2); - - while (crypt_off > 0 && auth_off > 0) { - SG_CONSUME(sg, data32, data_i, data_l); - crypt_off -= 4; - auth_off -= 4; - } - - /* align auth and crypt */ - while (crypt_off > 0 && auth_len > 0) { - mydata[0].data32[0] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - mydata[0].data32[1] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - CVM_LOAD_SHA_UNIT(*pdata, next); - crypt_off -= 8; - auth_len -= 8; - } - - while (crypt_len > 0) { - uint32_t *pdata32[3]; - - pdata32[0] = data32; - mydata[0].data32[0] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - pdata32[1] = data32; - mydata[0].data32[1] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - pdata32[2] = data32; - mydata[1].data32[0] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - mydata[1].data32[1] = *data32; - - CVMX_MT_AES_ENC_CBC0(*pdata); - CVMX_MT_AES_ENC_CBC1(*data); - CVMX_MF_AES_RESULT(*pdata, 0); - CVMX_MF_AES_RESULT(*data, 1); - crypt_len -= 16; - - if (auth_len > 0) { - CVM_LOAD_SHA_UNIT(*pdata, next); - auth_len -= 8; - } - if (auth_len > 0) { - CVM_LOAD_SHA_UNIT(*data, next); - auth_len -= 8; - } - - *pdata32[0] = mydata[0].data32[0]; - *pdata32[1] = mydata[0].data32[1]; - *pdata32[2] = mydata[1].data32[0]; - *data32 = mydata[1].data32[1]; - - SG_CONSUME(sg, data32, data_i, data_l); - } - - /* finish and hashing */ - while (auth_len > 0) { - mydata[0].data32[0] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - mydata[0].data32[1] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - CVM_LOAD_SHA_UNIT(*pdata, next); - auth_len -= 8; - } - - /* finish the hash */ - CVMX_PREFETCH0(od->octo_hmouter); -#if 0 - if (unlikely(inplen)) { - uint64_t tmp = 0; - uint8_t *p = (uint8_t *) & tmp; - p[inplen] = 0x80; - do { - inplen--; - p[inplen] = ((uint8_t *) data)[inplen]; - } while (inplen); - CVM_LOAD_SHA_UNIT(tmp, next); - } else { - CVM_LOAD_SHA_UNIT(0x8000000000000000ULL, next); - } -#else - CVM_LOAD_SHA_UNIT(0x8000000000000000ULL, next); -#endif - - /* Finish Inner hash */ - while (next != 7) { - CVM_LOAD_SHA_UNIT(((uint64_t) 0x0ULL), next); - } - CVM_LOAD_SHA_UNIT((uint64_t) ((alen + 64) << 3), next); - - /* Get the inner hash of HMAC */ - CVMX_MF_HSH_IV(tmp1, 0); - CVMX_MF_HSH_IV(tmp2, 1); - tmp3 = 0; - CVMX_MF_HSH_IV(tmp3, 2); - - /* Initialize hash unit */ - CVMX_MT_HSH_IV(od->octo_hmouter[0], 0); - CVMX_MT_HSH_IV(od->octo_hmouter[1], 1); - CVMX_MT_HSH_IV(od->octo_hmouter[2], 2); - - CVMX_MT_HSH_DAT(tmp1, 0); - CVMX_MT_HSH_DAT(tmp2, 1); - tmp3 |= 0x0000000080000000; - CVMX_MT_HSH_DAT(tmp3, 2); - CVMX_MT_HSH_DATZ(3); - CVMX_MT_HSH_DATZ(4); - CVMX_MT_HSH_DATZ(5); - CVMX_MT_HSH_DATZ(6); - CVMX_MT_HSH_STARTSHA((uint64_t) ((64 + 20) << 3)); - - /* finish the hash */ - CVMX_PREFETCH0(od->octo_hmouter); -#if 0 - if (unlikely(inplen)) { - uint64_t tmp = 0; - uint8_t *p = (uint8_t *) & tmp; - p[inplen] = 0x80; - do { - inplen--; - p[inplen] = ((uint8_t *) data)[inplen]; - } while (inplen); - CVM_LOAD_MD5_UNIT(tmp, next); - } else { - CVM_LOAD_MD5_UNIT(0x8000000000000000ULL, next); - } -#else - CVM_LOAD_MD5_UNIT(0x8000000000000000ULL, next); -#endif - - /* save the HMAC */ - SG_INIT(sg, data32, data_i, data_l); - while (icv_off > 0) { - SG_CONSUME(sg, data32, data_i, data_l); - icv_off -= 4; - } - CVMX_MF_HSH_IV(tmp1, 0); - *data32 = (uint32_t) (tmp1 >> 32); - SG_CONSUME(sg, data32, data_i, data_l); - *data32 = (uint32_t) tmp1; - SG_CONSUME(sg, data32, data_i, data_l); - CVMX_MF_HSH_IV(tmp1, 1); - *data32 = (uint32_t) (tmp1 >> 32); - - octeon_crypto_disable(&state, flags); - return 0; -} - -int -octo_aes_cbc_sha1_decrypt( - struct octo_sess *od, - struct scatterlist *sg, int sg_len, - int auth_off, int auth_len, - int crypt_off, int crypt_len, - int icv_off, uint8_t *ivp) -{ - register int next = 0; - union { - uint32_t data32[2]; - uint64_t data64[1]; - } mydata[2]; - uint64_t *pdata = &mydata[0].data64[0]; - uint64_t *data = &mydata[1].data64[0]; - uint32_t *data32; - uint64_t tmp1, tmp2, tmp3; - int data_i, data_l, alen = auth_len; - struct octeon_cop2_state state; - unsigned long flags; - - dprintk("%s(a_off=%d a_len=%d c_off=%d c_len=%d icv_off=%d)\n", - __FUNCTION__, auth_off, auth_len, crypt_off, crypt_len, icv_off); - - if (unlikely(od == NULL || sg==NULL || sg_len==0 || ivp==NULL || - (crypt_off & 0x3) || (crypt_off + crypt_len > sg_len) || - (crypt_len & 0x7) || - (auth_len & 0x7) || - (auth_off & 0x3) || (auth_off + auth_len > sg_len))) { - dprintk("%s: Bad parameters od=%p sg=%p sg_len=%d " - "auth_off=%d auth_len=%d crypt_off=%d crypt_len=%d " - "icv_off=%d ivp=%p\n", __FUNCTION__, od, sg, sg_len, - auth_off, auth_len, crypt_off, crypt_len, icv_off, ivp); - return -EINVAL; - } - - SG_INIT(sg, data32, data_i, data_l); - - CVMX_PREFETCH0(ivp); - CVMX_PREFETCH0(od->octo_enckey); - - flags = octeon_crypto_enable(&state); - - /* load AES Key */ - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[0], 0); - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[1], 1); - - if (od->octo_encklen == 16) { - CVMX_MT_AES_KEY(0x0, 2); - CVMX_MT_AES_KEY(0x0, 3); - } else if (od->octo_encklen == 24) { - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[2], 2); - CVMX_MT_AES_KEY(0x0, 3); - } else if (od->octo_encklen == 32) { - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[2], 2); - CVMX_MT_AES_KEY(((uint64_t *) od->octo_enckey)[3], 3); - } else { - octeon_crypto_disable(&state, flags); - dprintk("%s: Bad key length %d\n", __FUNCTION__, od->octo_encklen); - return -EINVAL; - } - CVMX_MT_AES_KEYLENGTH(od->octo_encklen / 8 - 1); - - CVMX_MT_AES_IV(((uint64_t *) ivp)[0], 0); - CVMX_MT_AES_IV(((uint64_t *) ivp)[1], 1); - - /* Load SHA1 IV */ - CVMX_MT_HSH_IV(od->octo_hminner[0], 0); - CVMX_MT_HSH_IV(od->octo_hminner[1], 1); - CVMX_MT_HSH_IV(od->octo_hminner[2], 2); - - while (crypt_off > 0 && auth_off > 0) { - SG_CONSUME(sg, data32, data_i, data_l); - crypt_off -= 4; - auth_off -= 4; - } - - /* align auth and crypt */ - while (crypt_off > 0 && auth_len > 0) { - mydata[0].data32[0] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - mydata[0].data32[1] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - CVM_LOAD_SHA_UNIT(*pdata, next); - crypt_off -= 8; - auth_len -= 8; - } - - while (crypt_len > 0) { - uint32_t *pdata32[3]; - - pdata32[0] = data32; - mydata[0].data32[0] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - pdata32[1] = data32; - mydata[0].data32[1] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - pdata32[2] = data32; - mydata[1].data32[0] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - mydata[1].data32[1] = *data32; - - if (auth_len > 0) { - CVM_LOAD_SHA_UNIT(*pdata, next); - auth_len -= 8; - } - if (auth_len > 0) { - CVM_LOAD_SHA_UNIT(*data, next); - auth_len -= 8; - } - - CVMX_MT_AES_DEC_CBC0(*pdata); - CVMX_MT_AES_DEC_CBC1(*data); - CVMX_MF_AES_RESULT(*pdata, 0); - CVMX_MF_AES_RESULT(*data, 1); - crypt_len -= 16; - - *pdata32[0] = mydata[0].data32[0]; - *pdata32[1] = mydata[0].data32[1]; - *pdata32[2] = mydata[1].data32[0]; - *data32 = mydata[1].data32[1]; - - SG_CONSUME(sg, data32, data_i, data_l); - } - - /* finish and leftover hashing */ - while (auth_len > 0) { - mydata[0].data32[0] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - mydata[0].data32[1] = *data32; - SG_CONSUME(sg, data32, data_i, data_l); - CVM_LOAD_SHA_UNIT(*pdata, next); - auth_len -= 8; - } - - /* finish the hash */ - CVMX_PREFETCH0(od->octo_hmouter); -#if 0 - if (unlikely(inplen)) { - uint64_t tmp = 0; - uint8_t *p = (uint8_t *) & tmp; - p[inplen] = 0x80; - do { - inplen--; - p[inplen] = ((uint8_t *) data)[inplen]; - } while (inplen); - CVM_LOAD_SHA_UNIT(tmp, next); - } else { - CVM_LOAD_SHA_UNIT(0x8000000000000000ULL, next); - } -#else - CVM_LOAD_SHA_UNIT(0x8000000000000000ULL, next); -#endif - - /* Finish Inner hash */ - while (next != 7) { - CVM_LOAD_SHA_UNIT(((uint64_t) 0x0ULL), next); - } - CVM_LOAD_SHA_UNIT((uint64_t) ((alen + 64) << 3), next); - - /* Get the inner hash of HMAC */ - CVMX_MF_HSH_IV(tmp1, 0); - CVMX_MF_HSH_IV(tmp2, 1); - tmp3 = 0; - CVMX_MF_HSH_IV(tmp3, 2); - - /* Initialize hash unit */ - CVMX_MT_HSH_IV(od->octo_hmouter[0], 0); - CVMX_MT_HSH_IV(od->octo_hmouter[1], 1); - CVMX_MT_HSH_IV(od->octo_hmouter[2], 2); - - CVMX_MT_HSH_DAT(tmp1, 0); - CVMX_MT_HSH_DAT(tmp2, 1); - tmp3 |= 0x0000000080000000; - CVMX_MT_HSH_DAT(tmp3, 2); - CVMX_MT_HSH_DATZ(3); - CVMX_MT_HSH_DATZ(4); - CVMX_MT_HSH_DATZ(5); - CVMX_MT_HSH_DATZ(6); - CVMX_MT_HSH_STARTSHA((uint64_t) ((64 + 20) << 3)); - - /* finish the hash */ - CVMX_PREFETCH0(od->octo_hmouter); -#if 0 - if (unlikely(inplen)) { - uint64_t tmp = 0; - uint8_t *p = (uint8_t *) & tmp; - p[inplen] = 0x80; - do { - inplen--; - p[inplen] = ((uint8_t *) data)[inplen]; - } while (inplen); - CVM_LOAD_MD5_UNIT(tmp, next); - } else { - CVM_LOAD_MD5_UNIT(0x8000000000000000ULL, next); - } -#else - CVM_LOAD_MD5_UNIT(0x8000000000000000ULL, next); -#endif - - /* save the HMAC */ - SG_INIT(sg, data32, data_i, data_l); - while (icv_off > 0) { - SG_CONSUME(sg, data32, data_i, data_l); - icv_off -= 4; - } - CVMX_MF_HSH_IV(tmp1, 0); - *data32 = (uint32_t) (tmp1 >> 32); - SG_CONSUME(sg, data32, data_i, data_l); - *data32 = (uint32_t) tmp1; - SG_CONSUME(sg, data32, data_i, data_l); - CVMX_MF_HSH_IV(tmp1, 1); - *data32 = (uint32_t) (tmp1 >> 32); - - octeon_crypto_disable(&state, flags); - return 0; -} - -/****************************************************************************/ diff --git a/target/linux/generic-2.4/files/crypto/ocf/cryptocteon/cryptocteon.c b/target/linux/generic-2.4/files/crypto/ocf/cryptocteon/cryptocteon.c deleted file mode 100644 index 9940f59..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/cryptocteon/cryptocteon.c +++ /dev/null @@ -1,574 +0,0 @@ -/* - * Octeon Crypto for OCF - * - * Written by David McCullough <david_mccullough@mcafee.com> - * Copyright (C) 2009-2010 David McCullough - * - * LICENSE TERMS - * - * The free distribution and use of this software in both source and binary - * form is allowed (with or without changes) provided that: - * - * 1. distributions of this source code include the above copyright - * notice, this list of conditions and the following disclaimer; - * - * 2. distributions in binary form include the above copyright - * notice, this list of conditions and the following disclaimer - * in the documentation and/or other associated materials; - * - * 3. the copyright holder's name is not used to endorse products - * built using this software without specific written permission. - * - * DISCLAIMER - * - * This software is provided 'as is' with no explicit or implied warranties - * in respect of its properties, including, but not limited to, correctness - * and/or fitness for purpose. - * --------------------------------------------------------------------------- - */ - -#ifndef AUTOCONF_INCLUDED -#include <linux/config.h> -#endif -#include <linux/module.h> -#include <linux/init.h> -#include <linux/list.h> -#include <linux/slab.h> -#include <linux/sched.h> -#include <linux/wait.h> -#include <linux/crypto.h> -#include <linux/mm.h> -#include <linux/skbuff.h> -#include <linux/random.h> -#include <linux/scatterlist.h> - -#include <cryptodev.h> -#include <uio.h> - -struct { - softc_device_decl sc_dev; -} octo_softc; - -#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK) - -struct octo_sess { - int octo_encalg; - #define MAX_CIPHER_KEYLEN 64 - char octo_enckey[MAX_CIPHER_KEYLEN]; - int octo_encklen; - - int octo_macalg; - #define MAX_HASH_KEYLEN 64 - char octo_mackey[MAX_HASH_KEYLEN]; - int octo_macklen; - int octo_mackey_set; - - int octo_mlen; - int octo_ivsize; - -#if 0 - int (*octo_decrypt)(struct scatterlist *sg, int sg_len, - uint8_t *key, int key_len, uint8_t * iv, - uint64_t *hminner, uint64_t *hmouter); - - int (*octo_encrypt)(struct scatterlist *sg, int sg_len, - uint8_t *key, int key_len, uint8_t * iv, - uint64_t *hminner, uint64_t *hmouter); -#else - int (*octo_encrypt)(struct octo_sess *od, - struct scatterlist *sg, int sg_len, - int auth_off, int auth_len, - int crypt_off, int crypt_len, - int icv_off, uint8_t *ivp); - int (*octo_decrypt)(struct octo_sess *od, - struct scatterlist *sg, int sg_len, - int auth_off, int auth_len, - int crypt_off, int crypt_len, - int icv_off, uint8_t *ivp); -#endif - - uint64_t octo_hminner[3]; - uint64_t octo_hmouter[3]; -}; - -int32_t octo_id = -1; -module_param(octo_id, int, 0444); -MODULE_PARM_DESC(octo_id, "Read-Only OCF ID for cryptocteon driver"); - -static struct octo_sess **octo_sessions = NULL; -static u_int32_t octo_sesnum = 0; - -static int octo_process(device_t, struct cryptop *, int); -static int octo_newsession(device_t, u_int32_t *, struct cryptoini *); -static int octo_freesession(device_t, u_int64_t); - -static device_method_t octo_methods = { - /* crypto device methods */ - DEVMETHOD(cryptodev_newsession, octo_newsession), - DEVMETHOD(cryptodev_freesession,octo_freesession), - DEVMETHOD(cryptodev_process, octo_process), -}; - -#define debug octo_debug -int octo_debug = 0; -module_param(octo_debug, int, 0644); -MODULE_PARM_DESC(octo_debug, "Enable debug"); - - -#include "cavium_crypto.c" - - -/* - * Generate a new octo session. We artifically limit it to a single - * hash/cipher or hash-cipher combo just to make it easier, most callers - * do not expect more than this anyway. - */ -static int -octo_newsession(device_t dev, u_int32_t *sid, struct cryptoini *cri) -{ - struct cryptoini *c, *encini = NULL, *macini = NULL; - struct octo_sess **ocd; - int i; - - dprintk("%s()\n", __FUNCTION__); - if (sid == NULL || cri == NULL) { - dprintk("%s,%d - EINVAL\n", __FILE__, __LINE__); - return EINVAL; - } - - /* - * To keep it simple, we only handle hash, cipher or hash/cipher in a - * session, you cannot currently do multiple ciphers/hashes in one - * session even though it would be possibel to code this driver to - * handle it. - */ - for (i = 0, c = cri; c && i < 2; i++) { - if (c->cri_alg == CRYPTO_MD5_HMAC || - c->cri_alg == CRYPTO_SHA1_HMAC || - c->cri_alg == CRYPTO_NULL_HMAC) { - if (macini) { - break; - } - macini = c; - } - if (c->cri_alg == CRYPTO_DES_CBC || - c->cri_alg == CRYPTO_3DES_CBC || - c->cri_alg == CRYPTO_AES_CBC || - c->cri_alg == CRYPTO_NULL_CBC) { - if (encini) { - break; - } - encini = c; - } - c = c->cri_next; - } - if (!macini && !encini) { - dprintk("%s,%d - EINVAL bad cipher/hash or combination\n", - __FILE__, __LINE__); - return EINVAL; - } - if (c) { - dprintk("%s,%d - EINVAL cannot handle chained cipher/hash combos\n", - __FILE__, __LINE__); - return EINVAL; - } - - /* - * So we have something we can do, lets setup the session - */ - - if (octo_sessions) { - for (i = 1; i < octo_sesnum; i++) - if (octo_sessions[i] == NULL) - break; - } else - i = 1; /* NB: to silence compiler warning */ - - if (octo_sessions == NULL || i == octo_sesnum) { - if (octo_sessions == NULL) { - i = 1; /* We leave octo_sessions[0] empty */ - octo_sesnum = CRYPTO_SW_SESSIONS; - } else - octo_sesnum *= 2; - - ocd = kmalloc(octo_sesnum * sizeof(struct octo_sess *), SLAB_ATOMIC); - if (ocd == NULL) { - /* Reset session number */ - if (octo_sesnum == CRYPTO_SW_SESSIONS) - octo_sesnum = 0; - else - octo_sesnum /= 2; - dprintk("%s,%d: ENOBUFS\n", __FILE__, __LINE__); - return ENOBUFS; - } - memset(ocd, 0, octo_sesnum * sizeof(struct octo_sess *)); - - /* Copy existing sessions */ - if (octo_sessions) { - memcpy(ocd, octo_sessions, - (octo_sesnum / 2) * sizeof(struct octo_sess *)); - kfree(octo_sessions); - } - - octo_sessions = ocd; - } - - ocd = &octo_sessions[i]; - *sid = i; - - - *ocd = (struct octo_sess *) kmalloc(sizeof(struct octo_sess), SLAB_ATOMIC); - if (*ocd == NULL) { - octo_freesession(NULL, i); - dprintk("%s,%d: ENOBUFS\n", __FILE__, __LINE__); - return ENOBUFS; - } - memset(*ocd, 0, sizeof(struct octo_sess)); - - if (encini && encini->cri_key) { - (*ocd)->octo_encklen = (encini->cri_klen + 7) / 8; - memcpy((*ocd)->octo_enckey, encini->cri_key, (*ocd)->octo_encklen); - } - - if (macini && macini->cri_key) { - (*ocd)->octo_macklen = (macini->cri_klen + 7) / 8; - memcpy((*ocd)->octo_mackey, macini->cri_key, (*ocd)->octo_macklen); - } - - (*ocd)->octo_mlen = 0; - if (encini && encini->cri_mlen) - (*ocd)->octo_mlen = encini->cri_mlen; - else if (macini && macini->cri_mlen) - (*ocd)->octo_mlen = macini->cri_mlen; - else - (*ocd)->octo_mlen = 12; - - /* - * point c at the enc if it exists, otherwise the mac - */ - c = encini ? encini : macini; - - switch (c->cri_alg) { - case CRYPTO_DES_CBC: - case CRYPTO_3DES_CBC: - (*ocd)->octo_ivsize = 8; - switch (macini ? macini->cri_alg : -1) { - case CRYPTO_MD5_HMAC: - (*ocd)->octo_encrypt = octo_des_cbc_md5_encrypt; - (*ocd)->octo_decrypt = octo_des_cbc_md5_decrypt; - octo_calc_hash(0, macini->cri_key, (*ocd)->octo_hminner, - (*ocd)->octo_hmouter); - break; - case CRYPTO_SHA1_HMAC: - (*ocd)->octo_encrypt = octo_des_cbc_sha1_encrypt; - (*ocd)->octo_decrypt = octo_des_cbc_sha1_encrypt; - octo_calc_hash(1, macini->cri_key, (*ocd)->octo_hminner, - (*ocd)->octo_hmouter); - break; - case -1: - (*ocd)->octo_encrypt = octo_des_cbc_encrypt; - (*ocd)->octo_decrypt = octo_des_cbc_decrypt; - break; - default: - octo_freesession(NULL, i); - dprintk("%s,%d: EINVALn", __FILE__, __LINE__); - return EINVAL; - } - break; - case CRYPTO_AES_CBC: - (*ocd)->octo_ivsize = 16; - switch (macini ? macini->cri_alg : -1) { - case CRYPTO_MD5_HMAC: - (*ocd)->octo_encrypt = octo_aes_cbc_md5_encrypt; - (*ocd)->octo_decrypt = octo_aes_cbc_md5_decrypt; - octo_calc_hash(0, macini->cri_key, (*ocd)->octo_hminner, - (*ocd)->octo_hmouter); - break; - case CRYPTO_SHA1_HMAC: - (*ocd)->octo_encrypt = octo_aes_cbc_sha1_encrypt; - (*ocd)->octo_decrypt = octo_aes_cbc_sha1_decrypt; - octo_calc_hash(1, macini->cri_key, (*ocd)->octo_hminner, - (*ocd)->octo_hmouter); - break; - case -1: - (*ocd)->octo_encrypt = octo_aes_cbc_encrypt; - (*ocd)->octo_decrypt = octo_aes_cbc_decrypt; - break; - default: - octo_freesession(NULL, i); - dprintk("%s,%d: EINVALn", __FILE__, __LINE__); - return EINVAL; - } - break; - case CRYPTO_MD5_HMAC: - (*ocd)->octo_encrypt = octo_null_md5_encrypt; - (*ocd)->octo_decrypt = octo_null_md5_encrypt; - octo_calc_hash(0, macini->cri_key, (*ocd)->octo_hminner, - (*ocd)->octo_hmouter); - break; - case CRYPTO_SHA1_HMAC: - (*ocd)->octo_encrypt = octo_null_sha1_encrypt; - (*ocd)->octo_decrypt = octo_null_sha1_encrypt; - octo_calc_hash(1, macini->cri_key, (*ocd)->octo_hminner, - (*ocd)->octo_hmouter); - break; - default: - octo_freesession(NULL, i); - dprintk("%s,%d: EINVALn", __FILE__, __LINE__); - return EINVAL; - } - - (*ocd)->octo_encalg = encini ? encini->cri_alg : -1; - (*ocd)->octo_macalg = macini ? macini->cri_alg : -1; - - return 0; -} - -/* - * Free a session. - */ -static int -octo_freesession(device_t dev, u_int64_t tid) -{ - u_int32_t sid = CRYPTO_SESID2LID(tid); - - dprintk("%s()\n", __FUNCTION__); - if (sid > octo_sesnum || octo_sessions == NULL || - octo_sessions[sid] == NULL) { - dprintk("%s,%d: EINVAL\n", __FILE__, __LINE__); - return(EINVAL); - } - - /* Silently accept and return */ - if (sid == 0) - return(0); - - if (octo_sessions[sid]) - kfree(octo_sessions[sid]); - octo_sessions[sid] = NULL; - return 0; -} - -/* - * Process a request. - */ -static int -octo_process(device_t dev, struct cryptop *crp, int hint) -{ - struct cryptodesc *crd; - struct octo_sess *od; - u_int32_t lid; -#define SCATTERLIST_MAX 16 - struct scatterlist sg[SCATTERLIST_MAX]; - int sg_num, sg_len; - struct sk_buff *skb = NULL; - struct uio *uiop = NULL; - struct cryptodesc *enccrd = NULL, *maccrd = NULL; - unsigned char *ivp = NULL; - unsigned char iv_data[HASH_MAX_LEN]; - int auth_off = 0, auth_len = 0, crypt_off = 0, crypt_len = 0, icv_off = 0; - - dprintk("%s()\n", __FUNCTION__); - /* Sanity check */ - if (crp == NULL) { - dprintk("%s,%d: EINVAL\n", __FILE__, __LINE__); - return EINVAL; - } - - crp->crp_etype = 0; - - if (crp->crp_desc == NULL || crp->crp_buf == NULL) { - dprintk("%s,%d: EINVAL\n", __FILE__, __LINE__); - crp->crp_etype = EINVAL; - goto done; - } - - lid = crp->crp_sid & 0xffffffff; - if (lid >= octo_sesnum || lid == 0 || octo_sessions == NULL || - octo_sessions[lid] == NULL) { - crp->crp_etype = ENOENT; - dprintk("%s,%d: ENOENT\n", __FILE__, __LINE__); - goto done; - } - od = octo_sessions[lid]; - - /* - * do some error checking outside of the loop for SKB and IOV processing - * this leaves us with valid skb or uiop pointers for later - */ - if (crp->crp_flags & CRYPTO_F_SKBUF) { - skb = (struct sk_buff *) crp->crp_buf; - if (skb_shinfo(skb)->nr_frags >= SCATTERLIST_MAX) { - printk("%s,%d: %d nr_frags > SCATTERLIST_MAX", __FILE__, __LINE__, - skb_shinfo(skb)->nr_frags); - goto done; - } - } else if (crp->crp_flags & CRYPTO_F_IOV) { - uiop = (struct uio *) crp->crp_buf; - if (uiop->uio_iovcnt > SCATTERLIST_MAX) { - printk("%s,%d: %d uio_iovcnt > SCATTERLIST_MAX", __FILE__, __LINE__, - uiop->uio_iovcnt); - goto done; - } - } - - /* point our enccrd and maccrd appropriately */ - crd = crp->crp_desc; - if (crd->crd_alg == od->octo_encalg) enccrd = crd; - if (crd->crd_alg == od->octo_macalg) maccrd = crd; - crd = crd->crd_next; - if (crd) { - if (crd->crd_alg == od->octo_encalg) enccrd = crd; - if (crd->crd_alg == od->octo_macalg) maccrd = crd; - crd = crd->crd_next; - } - if (crd) { - crp->crp_etype = EINVAL; - dprintk("%s,%d: ENOENT - descriptors do not match session\n", - __FILE__, __LINE__); - goto done; - } - - if (enccrd) { - if (enccrd->crd_flags & CRD_F_IV_EXPLICIT) { - ivp = enccrd->crd_iv; - } else { - ivp = iv_data; - crypto_copydata(crp->crp_flags, crp->crp_buf, - enccrd->crd_inject, od->octo_ivsize, (caddr_t) ivp); - } - - if (maccrd) { - auth_off = maccrd->crd_skip; - auth_len = maccrd->crd_len; - icv_off = maccrd->crd_inject; - } - - crypt_off = enccrd->crd_skip; - crypt_len = enccrd->crd_len; - } else { /* if (maccrd) */ - auth_off = maccrd->crd_skip; - auth_len = maccrd->crd_len; - icv_off = maccrd->crd_inject; - } - - - /* - * setup the SG list to cover the buffer - */ - memset(sg, 0, sizeof(sg)); - if (crp->crp_flags & CRYPTO_F_SKBUF) { - int i, len; - - sg_num = 0; - sg_len = 0; - - len = skb_headlen(skb); - sg_set_page(&sg[sg_num], virt_to_page(skb->data), len, - offset_in_page(skb->data)); - sg_len += len; - sg_num++; - - for (i = 0; i < skb_shinfo(skb)->nr_frags && sg_num < SCATTERLIST_MAX; - i++) { - len = skb_shinfo(skb)->frags[i].size; - sg_set_page(&sg[sg_num], skb_shinfo(skb)->frags[i].page, - len, skb_shinfo(skb)->frags[i].page_offset); - sg_len += len; - sg_num++; - } - } else if (crp->crp_flags & CRYPTO_F_IOV) { - int len; - - sg_len = 0; - for (sg_num = 0; sg_len < crp->crp_ilen && - sg_num < uiop->uio_iovcnt && - sg_num < SCATTERLIST_MAX; sg_num++) { - len = uiop->uio_iov[sg_num].iov_len; - sg_set_page(&sg[sg_num], - virt_to_page(uiop->uio_iov[sg_num].iov_base), len, - offset_in_page(uiop->uio_iov[sg_num].iov_base)); - sg_len += len; - } - } else { - sg_len = crp->crp_ilen; - sg_set_page(&sg[0], virt_to_page(crp->crp_buf), sg_len, - offset_in_page(crp->crp_buf)); - sg_num = 1; - } - - - /* - * setup a new explicit key - */ - if (enccrd) { - if (enccrd->crd_flags & CRD_F_KEY_EXPLICIT) { - od->octo_encklen = (enccrd->crd_klen + 7) / 8; - memcpy(od->octo_enckey, enccrd->crd_key, od->octo_encklen); - } - } - if (maccrd) { - if (maccrd->crd_flags & CRD_F_KEY_EXPLICIT) { - od->octo_macklen = (maccrd->crd_klen + 7) / 8; - memcpy(od->octo_mackey, maccrd->crd_key, od->octo_macklen); - od->octo_mackey_set = 0; - } - if (!od->octo_mackey_set) { - octo_calc_hash(maccrd->crd_alg == CRYPTO_MD5_HMAC ? 0 : 1, - maccrd->crd_key, od->octo_hminner, od->octo_hmouter); - od->octo_mackey_set = 1; - } - } - - - if (!enccrd || (enccrd->crd_flags & CRD_F_ENCRYPT)) - (*od->octo_encrypt)(od, sg, sg_len, - auth_off, auth_len, crypt_off, crypt_len, icv_off, ivp); - else - (*od->octo_decrypt)(od, sg, sg_len, - auth_off, auth_len, crypt_off, crypt_len, icv_off, ivp); - -done: - crypto_done(crp); - return 0; -} - -static int -cryptocteon_init(void) -{ - dprintk("%s(%p)\n", __FUNCTION__, cryptocteon_init); - - softc_device_init(&octo_softc, "cryptocteon", 0, octo_methods); - - octo_id = crypto_get_driverid(softc_get_device(&octo_softc), - CRYPTOCAP_F_HARDWARE | CRYPTOCAP_F_SYNC); - if (octo_id < 0) { - printk("Cryptocteon device cannot initialize!"); - return -ENODEV; - } - - crypto_register(octo_id, CRYPTO_MD5_HMAC, 0,0); - crypto_register(octo_id, CRYPTO_SHA1_HMAC, 0,0); - //crypto_register(octo_id, CRYPTO_MD5, 0,0); - //crypto_register(octo_id, CRYPTO_SHA1, 0,0); - crypto_register(octo_id, CRYPTO_DES_CBC, 0,0); - crypto_register(octo_id, CRYPTO_3DES_CBC, 0,0); - crypto_register(octo_id, CRYPTO_AES_CBC, 0,0); - - return(0); -} - -static void -cryptocteon_exit(void) -{ - dprintk("%s()\n", __FUNCTION__); - crypto_unregister_all(octo_id); - octo_id = -1; -} - -module_init(cryptocteon_init); -module_exit(cryptocteon_exit); - -MODULE_LICENSE("BSD"); -MODULE_AUTHOR("David McCullough <david_mccullough@mcafee.com>"); -MODULE_DESCRIPTION("Cryptocteon (OCF module for Cavium OCTEON crypto)"); diff --git a/target/linux/generic-2.4/files/crypto/ocf/cryptodev.c b/target/linux/generic-2.4/files/crypto/ocf/cryptodev.c deleted file mode 100644 index 87a4c37..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/cryptodev.c +++ /dev/null @@ -1,1061 +0,0 @@ -/* $OpenBSD: cryptodev.c,v 1.52 2002/06/19 07:22:46 deraadt Exp $ */ - -/*- - * Linux port done by David McCullough <david_mccullough@mcafee.com> - * Copyright (C) 2006-2010 David McCullough - * Copyright (C) 2004-2005 Intel Corporation. - * The license and original author are listed below. - * - * Copyright (c) 2001 Theo de Raadt - * Copyright (c) 2002-2006 Sam Leffler, Errno Consulting - * - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR 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. - * - * Effort sponsored in part by the Defense Advanced Research Projects - * Agency (DARPA) and Air Force Research Laboratory, Air Force - * Materiel Command, USAF, under agreement number F30602-01-2-0537. - * -__FBSDID("$FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.34 2007/05/09 19:37:02 gnn Exp $"); - */ - -#ifndef AUTOCONF_INCLUDED -#include <linux/config.h> -#endif -#include <linux/types.h> -#include <linux/time.h> -#include <linux/delay.h> -#include <linux/list.h> -#include <linux/init.h> -#include <linux/sched.h> -#include <linux/unistd.h> -#include <linux/module.h> -#include <linux/wait.h> -#include <linux/slab.h> -#include <linux/fs.h> -#include <linux/dcache.h> -#include <linux/file.h> -#include <linux/mount.h> -#include <linux/miscdevice.h> -#include <linux/version.h> -#include <asm/uaccess.h> - -#include <cryptodev.h> -#include <uio.h> - -extern asmlinkage long sys_dup(unsigned int fildes); - -#define debug cryptodev_debug -int cryptodev_debug = 0; -module_param(cryptodev_debug, int, 0644); -MODULE_PARM_DESC(cryptodev_debug, "Enable cryptodev debug"); - -struct csession_info { - u_int16_t blocksize; - u_int16_t minkey, maxkey; - - u_int16_t keysize; - /* u_int16_t hashsize; */ - u_int16_t authsize; - u_int16_t authkey; - /* u_int16_t ctxsize; */ -}; - -struct csession { - struct list_head list; - u_int64_t sid; - u_int32_t ses; - - wait_queue_head_t waitq; - - u_int32_t cipher; - - u_int32_t mac; - - caddr_t key; - int keylen; - u_char tmp_iv[EALG_MAX_BLOCK_LEN]; - - caddr_t mackey; - int mackeylen; - - struct csession_info info; - - struct iovec iovec; - struct uio uio; - int error; -}; - -struct fcrypt { - struct list_head csessions; - int sesn; -}; - -static struct csession *csefind(struct fcrypt *, u_int); -static int csedelete(struct fcrypt *, struct csession *); -static struct csession *cseadd(struct fcrypt *, struct csession *); -static struct csession *csecreate(struct fcrypt *, u_int64_t, - struct cryptoini *crie, struct cryptoini *cria, struct csession_info *); -static int csefree(struct csession *); - -static int cryptodev_op(struct csession *, struct crypt_op *); -static int cryptodev_key(struct crypt_kop *); -static int cryptodev_find(struct crypt_find_op *); - -static int cryptodev_cb(void *); -static int cryptodev_open(struct inode *inode, struct file *filp); - -/* - * Check a crypto identifier to see if it requested - * a valid crid and it's capabilities match. - */ -static int -checkcrid(int crid) -{ - int hid = crid & ~(CRYPTOCAP_F_SOFTWARE | CRYPTOCAP_F_HARDWARE); - int typ = crid & (CRYPTOCAP_F_SOFTWARE | CRYPTOCAP_F_HARDWARE); - int caps = 0; - - /* if the user hasn't selected a driver, then just call newsession */ - if (hid == 0 && typ != 0) - return 0; - - caps = crypto_getcaps(hid); - - /* didn't find anything with capabilities */ - if (caps == 0) { - dprintk("%s: hid=%x typ=%x not matched\n", __FUNCTION__, hid, typ); - return EINVAL; - } - - /* the user didn't specify SW or HW, so the driver is ok */ - if (typ == 0) - return 0; - - /* if the type specified didn't match */ - if (typ != (caps & (CRYPTOCAP_F_SOFTWARE | CRYPTOCAP_F_HARDWARE))) { - dprintk("%s: hid=%x typ=%x caps=%x not matched\n", __FUNCTION__, - hid, typ, caps); - return EINVAL; - } - - return 0; -} - -static int -cryptodev_op(struct csession *cse, struct crypt_op *cop) -{ - struct cryptop *crp = NULL; - struct cryptodesc *crde = NULL, *crda = NULL; - int error = 0; - - dprintk("%s()\n", __FUNCTION__); - if (cop->len > CRYPTO_MAX_DATA_LEN) { - dprintk("%s: %d > %d\n", __FUNCTION__, cop->len, CRYPTO_MAX_DATA_LEN); - return (E2BIG); - } - - if (cse->info.blocksize && (cop->len % cse->info.blocksize) != 0) { - dprintk("%s: blocksize=%d len=%d\n", __FUNCTION__, cse->info.blocksize, - cop->len); - return (EINVAL); - } - - cse->uio.uio_iov = &cse->iovec; - cse->uio.uio_iovcnt = 1; - cse->uio.uio_offset = 0; -#if 0 - cse->uio.uio_resid = cop->len; - cse->uio.uio_segflg = UIO_SYSSPACE; - cse->uio.uio_rw = UIO_WRITE; - cse->uio.uio_td = td; -#endif - cse->uio.uio_iov[0].iov_len = cop->len; - if (cse->info.authsize) - cse->uio.uio_iov[0].iov_len += cse->info.authsize; - cse->uio.uio_iov[0].iov_base = kmalloc(cse->uio.uio_iov[0].iov_len, - GFP_KERNEL); - - if (cse->uio.uio_iov[0].iov_base == NULL) { - dprintk("%s: iov_base kmalloc(%d) failed\n", __FUNCTION__, - (int)cse->uio.uio_iov[0].iov_len); - return (ENOMEM); - } - - crp = crypto_getreq((cse->info.blocksize != 0) + (cse->info.authsize != 0)); - if (crp == NULL) { - dprintk("%s: ENOMEM\n", __FUNCTION__); - error = ENOMEM; - goto bail; - } - - if (cse->info.authsize && cse->info.blocksize) { - if (cop->op == COP_ENCRYPT) { - crde = crp->crp_desc; - crda = crde->crd_next; - } else { - crda = crp->crp_desc; - crde = crda->crd_next; - } - } else if (cse->info.authsize) { - crda = crp->crp_desc; - } else if (cse->info.blocksize) { - crde = crp->crp_desc; - } else { - dprintk("%s: bad request\n", __FUNCTION__); - error = EINVAL; - goto bail; - } - - if ((error = copy_from_user(cse->uio.uio_iov[0].iov_base, cop->src, - cop->len))) { - dprintk("%s: bad copy\n", __FUNCTION__); - goto bail; - } - - if (crda) { - crda->crd_skip = 0; - crda->crd_len = cop->len; - crda->crd_inject = cop->len; - - crda->crd_alg = cse->mac; - crda->crd_key = cse->mackey; - crda->crd_klen = cse->mackeylen * 8; - } - - if (crde) { - if (cop->op == COP_ENCRYPT) - crde->crd_flags |= CRD_F_ENCRYPT; - else - crde->crd_flags &= ~CRD_F_ENCRYPT; - crde->crd_len = cop->len; - crde->crd_inject = 0; - - crde->crd_alg = cse->cipher; - crde->crd_key = cse->key; - crde->crd_klen = cse->keylen * 8; - } - - crp->crp_ilen = cse->uio.uio_iov[0].iov_len; - crp->crp_flags = CRYPTO_F_IOV | CRYPTO_F_CBIMM - | (cop->flags & COP_F_BATCH); - crp->crp_buf = (caddr_t)&cse->uio; - crp->crp_callback = (int (*) (struct cryptop *)) cryptodev_cb; - crp->crp_sid = cse->sid; - crp->crp_opaque = (void *)cse; - - if (cop->iv) { - if (crde == NULL) { - error = EINVAL; - dprintk("%s no crde\n", __FUNCTION__); - goto bail; - } - if (cse->cipher == CRYPTO_ARC4) { /* XXX use flag? */ - error = EINVAL; - dprintk("%s arc4 with IV\n", __FUNCTION__); - goto bail; - } - if ((error = copy_from_user(cse->tmp_iv, cop->iv, - cse->info.blocksize))) { - dprintk("%s bad iv copy\n", __FUNCTION__); - goto bail; - } - memcpy(crde->crd_iv, cse->tmp_iv, cse->info.blocksize); - crde->crd_flags |= CRD_F_IV_EXPLICIT | CRD_F_IV_PRESENT; - crde->crd_skip = 0; - } else if (cse->cipher == CRYPTO_ARC4) { /* XXX use flag? */ - crde->crd_skip = 0; - } else if (crde) { - crde->crd_flags |= CRD_F_IV_PRESENT; - crde->crd_skip = cse->info.blocksize; - crde->crd_len -= cse->info.blocksize; - } - - if (cop->mac && crda == NULL) { - error = EINVAL; - dprintk("%s no crda\n", __FUNCTION__); - goto bail; - } - - /* - * Let the dispatch run unlocked, then, interlock against the - * callback before checking if the operation completed and going - * to sleep. This insures drivers don't inherit our lock which - * results in a lock order reversal between crypto_dispatch forced - * entry and the crypto_done callback into us. - */ - error = crypto_dispatch(crp); - if (error) { - dprintk("%s error in crypto_dispatch\n", __FUNCTION__); - goto bail; - } - - dprintk("%s about to WAIT\n", __FUNCTION__); - /* - * we really need to wait for driver to complete to maintain - * state, luckily interrupts will be remembered - */ - do { - error = wait_event_interruptible(crp->crp_waitq, - ((crp->crp_flags & CRYPTO_F_DONE) != 0)); - /* - * we can't break out of this loop or we will leave behind - * a huge mess, however, staying here means if your driver - * is broken user applications can hang and not be killed. - * The solution, fix your driver :-) - */ - if (error) { - schedule(); - error = 0; - } - } while ((crp->crp_flags & CRYPTO_F_DONE) == 0); - dprintk("%s finished WAITING error=%d\n", __FUNCTION__, error); - - if (crp->crp_etype != 0) { - error = crp->crp_etype; - dprintk("%s error in crp processing\n", __FUNCTION__); - goto bail; - } - - if (cse->error) { - error = cse->error; - dprintk("%s error in cse processing\n", __FUNCTION__); - goto bail; - } - - if (cop->dst && (error = copy_to_user(cop->dst, - cse->uio.uio_iov[0].iov_base, cop->len))) { - dprintk("%s bad dst copy\n", __FUNCTION__); - goto bail; - } - - if (cop->mac && - (error=copy_to_user(cop->mac, - (caddr_t)cse->uio.uio_iov[0].iov_base + cop->len, - cse->info.authsize))) { - dprintk("%s bad mac copy\n", __FUNCTION__); - goto bail; - } - -bail: - if (crp) - crypto_freereq(crp); - if (cse->uio.uio_iov[0].iov_base) - kfree(cse->uio.uio_iov[0].iov_base); - - return (error); -} - -static int -cryptodev_cb(void *op) -{ - struct cryptop *crp = (struct cryptop *) op; - struct csession *cse = (struct csession *)crp->crp_opaque; - int error; - - dprintk("%s()\n", __FUNCTION__); - error = crp->crp_etype; - if (error == EAGAIN) { - crp->crp_flags &= ~CRYPTO_F_DONE; -#ifdef NOTYET - /* - * DAVIDM I am fairly sure that we should turn this into a batch - * request to stop bad karma/lockup, revisit - */ - crp->crp_flags |= CRYPTO_F_BATCH; -#endif - return crypto_dispatch(crp); - } - if (error != 0 || (crp->crp_flags & CRYPTO_F_DONE)) { - cse->error = error; - wake_up_interruptible(&crp->crp_waitq); - } - return (0); -} - -static int -cryptodevkey_cb(void *op) -{ - struct cryptkop *krp = (struct cryptkop *) op; - dprintk("%s()\n", __FUNCTION__); - wake_up_interruptible(&krp->krp_waitq); - return (0); -} - -static int -cryptodev_key(struct crypt_kop *kop) -{ - struct cryptkop *krp = NULL; - int error = EINVAL; - int in, out, size, i; - - dprintk("%s()\n", __FUNCTION__); - if (kop->crk_iparams + kop->crk_oparams > CRK_MAXPARAM) { - dprintk("%s params too big\n", __FUNCTION__); - return (EFBIG); - } - - in = kop->crk_iparams; - out = kop->crk_oparams; - switch (kop->crk_op) { - case CRK_MOD_EXP: - if (in == 3 && out == 1) - break; - return (EINVAL); - case CRK_MOD_EXP_CRT: - if (in == 6 && out == 1) - break; - return (EINVAL); - case CRK_DSA_SIGN: - if (in == 5 && out == 2) - break; - return (EINVAL); - case CRK_DSA_VERIFY: - if (in == 7 && out == 0) - break; - return (EINVAL); - case CRK_DH_COMPUTE_KEY: - if (in == 3 && out == 1) - break; - return (EINVAL); - default: - return (EINVAL); - } - - krp = (struct cryptkop *)kmalloc(sizeof *krp, GFP_KERNEL); - if (!krp) - return (ENOMEM); - bzero(krp, sizeof *krp); - krp->krp_op = kop->crk_op; - krp->krp_status = kop->crk_status; - krp->krp_iparams = kop->crk_iparams; - krp->krp_oparams = kop->crk_oparams; - krp->krp_crid = kop->crk_crid; - krp->krp_status = 0; - krp->krp_flags = CRYPTO_KF_CBIMM; - krp->krp_callback = (int (*) (struct cryptkop *)) cryptodevkey_cb; - init_waitqueue_head(&krp->krp_waitq); - - for (i = 0; i < CRK_MAXPARAM; i++) - krp->krp_param[i].crp_nbits = kop->crk_param[i].crp_nbits; - for (i = 0; i < krp->krp_iparams + krp->krp_oparams; i++) { - size = (krp->krp_param[i].crp_nbits + 7) / 8; - if (size == 0) - continue; - krp->krp_param[i].crp_p = (caddr_t) kmalloc(size, GFP_KERNEL); - if (i >= krp->krp_iparams) - continue; - error = copy_from_user(krp->krp_param[i].crp_p, - kop->crk_param[i].crp_p, size); - if (error) - goto fail; - } - - error = crypto_kdispatch(krp); - if (error) - goto fail; - - do { - error = wait_event_interruptible(krp->krp_waitq, - ((krp->krp_flags & CRYPTO_KF_DONE) != 0)); - /* - * we can't break out of this loop or we will leave behind - * a huge mess, however, staying here means if your driver - * is broken user applications can hang and not be killed. - * The solution, fix your driver :-) - */ - if (error) { - schedule(); - error = 0; - } - } while ((krp->krp_flags & CRYPTO_KF_DONE) == 0); - - dprintk("%s finished WAITING error=%d\n", __FUNCTION__, error); - - kop->crk_crid = krp->krp_crid; /* device that did the work */ - if (krp->krp_status != 0) { - error = krp->krp_status; - goto fail; - } - - for (i = krp->krp_iparams; i < krp->krp_iparams + krp->krp_oparams; i++) { - size = (krp->krp_param[i].crp_nbits + 7) / 8; - if (size == 0) - continue; - error = copy_to_user(kop->crk_param[i].crp_p, krp->krp_param[i].crp_p, - size); - if (error) - goto fail; - } - -fail: - if (krp) { - kop->crk_status = krp->krp_status; - for (i = 0; i < CRK_MAXPARAM; i++) { - if (krp->krp_param[i].crp_p) - kfree(krp->krp_param[i].crp_p); - } - kfree(krp); - } - return (error); -} - -static int -cryptodev_find(struct crypt_find_op *find) -{ - device_t dev; - - if (find->crid != -1) { - dev = crypto_find_device_byhid(find->crid); - if (dev == NULL) - return (ENOENT); - strlcpy(find->name, device_get_nameunit(dev), - sizeof(find->name)); - } else { - find->crid = crypto_find_driver(find->name); - if (find->crid == -1) - return (ENOENT); - } - return (0); -} - -static struct csession * -csefind(struct fcrypt *fcr, u_int ses) -{ - struct csession *cse; - - dprintk("%s()\n", __FUNCTION__); - list_for_each_entry(cse, &fcr->csessions, list) - if (cse->ses == ses) - return (cse); - return (NULL); -} - -static int -csedelete(struct fcrypt *fcr, struct csession *cse_del) -{ - struct csession *cse; - - dprintk("%s()\n", __FUNCTION__); - list_for_each_entry(cse, &fcr->csessions, list) { - if (cse == cse_del) { - list_del(&cse->list); - return (1); - } - } - return (0); -} - -static struct csession * -cseadd(struct fcrypt *fcr, struct csession *cse) -{ - dprintk("%s()\n", __FUNCTION__); - list_add_tail(&cse->list, &fcr->csessions); - cse->ses = fcr->sesn++; - return (cse); -} - -static struct csession * -csecreate(struct fcrypt *fcr, u_int64_t sid, struct cryptoini *crie, - struct cryptoini *cria, struct csession_info *info) -{ - struct csession *cse; - - dprintk("%s()\n", __FUNCTION__); - cse = (struct csession *) kmalloc(sizeof(struct csession), GFP_KERNEL); - if (cse == NULL) - return NULL; - memset(cse, 0, sizeof(struct csession)); - - INIT_LIST_HEAD(&cse->list); - init_waitqueue_head(&cse->waitq); - - cse->key = crie->cri_key; - cse->keylen = crie->cri_klen/8; - cse->mackey = cria->cri_key; - cse->mackeylen = cria->cri_klen/8; - cse->sid = sid; - cse->cipher = crie->cri_alg; - cse->mac = cria->cri_alg; - cse->info = *info; - cseadd(fcr, cse); - return (cse); -} - -static int -csefree(struct csession *cse) -{ - int error; - - dprintk("%s()\n", __FUNCTION__); - error = crypto_freesession(cse->sid); - if (cse->key) - kfree(cse->key); - if (cse->mackey) - kfree(cse->mackey); - kfree(cse); - return(error); -} - -static int -cryptodev_ioctl( - struct inode *inode, - struct file *filp, - unsigned int cmd, - unsigned long arg) -{ - struct cryptoini cria, crie; - struct fcrypt *fcr = filp->private_data; - struct csession *cse; - struct csession_info info; - struct session2_op sop; - struct crypt_op cop; - struct crypt_kop kop; - struct crypt_find_op fop; - u_int64_t sid; - u_int32_t ses = 0; - int feat, fd, error = 0, crid; - mm_segment_t fs; - - dprintk("%s(cmd=%x arg=%lx)\n", __FUNCTION__, cmd, arg); - - switch (cmd) { - - case CRIOGET: { - dprintk("%s(CRIOGET)\n", __FUNCTION__); - fs = get_fs(); - set_fs(get_ds()); - for (fd = 0; fd < files_fdtable(current->files)->max_fds; fd++) - if (files_fdtable(current->files)->fd[fd] == filp) - break; - fd = sys_dup(fd); - set_fs(fs); - put_user(fd, (int *) arg); - return IS_ERR_VALUE(fd) ? fd : 0; - } - -#define CIOCGSESSSTR (cmd == CIOCGSESSION ? "CIOCGSESSION" : "CIOCGSESSION2") - case CIOCGSESSION: - case CIOCGSESSION2: - dprintk("%s(%s)\n", __FUNCTION__, CIOCGSESSSTR); - memset(&crie, 0, sizeof(crie)); - memset(&cria, 0, sizeof(cria)); - memset(&info, 0, sizeof(info)); - memset(&sop, 0, sizeof(sop)); - - if (copy_from_user(&sop, (void*)arg, (cmd == CIOCGSESSION) ? - sizeof(struct session_op) : sizeof(sop))) { - dprintk("%s(%s) - bad copy\n", __FUNCTION__, CIOCGSESSSTR); - error = EFAULT; - goto bail; - } - - switch (sop.cipher) { - case 0: - dprintk("%s(%s) - no cipher\n", __FUNCTION__, CIOCGSESSSTR); - break; - case CRYPTO_NULL_CBC: - info.blocksize = NULL_BLOCK_LEN; - info.minkey = NULL_MIN_KEY_LEN; - info.maxkey = NULL_MAX_KEY_LEN; - break; - case CRYPTO_DES_CBC: - info.blocksize = DES_BLOCK_LEN; - info.minkey = DES_MIN_KEY_LEN; - info.maxkey = DES_MAX_KEY_LEN; - break; - case CRYPTO_3DES_CBC: - info.blocksize = DES3_BLOCK_LEN; - info.minkey = DES3_MIN_KEY_LEN; - info.maxkey = DES3_MAX_KEY_LEN; - break; - case CRYPTO_BLF_CBC: - info.blocksize = BLOWFISH_BLOCK_LEN; - info.minkey = BLOWFISH_MIN_KEY_LEN; - info.maxkey = BLOWFISH_MAX_KEY_LEN; - break; - case CRYPTO_CAST_CBC: - info.blocksize = CAST128_BLOCK_LEN; - info.minkey = CAST128_MIN_KEY_LEN; - info.maxkey = CAST128_MAX_KEY_LEN; - break; - case CRYPTO_SKIPJACK_CBC: - info.blocksize = SKIPJACK_BLOCK_LEN; - info.minkey = SKIPJACK_MIN_KEY_LEN; - info.maxkey = SKIPJACK_MAX_KEY_LEN; - break; - case CRYPTO_AES_CBC: - info.blocksize = AES_BLOCK_LEN; - info.minkey = AES_MIN_KEY_LEN; - info.maxkey = AES_MAX_KEY_LEN; - break; - case CRYPTO_ARC4: - info.blocksize = ARC4_BLOCK_LEN; - info.minkey = ARC4_MIN_KEY_LEN; - info.maxkey = ARC4_MAX_KEY_LEN; - break; - case CRYPTO_CAMELLIA_CBC: - info.blocksize = CAMELLIA_BLOCK_LEN; - info.minkey = CAMELLIA_MIN_KEY_LEN; - info.maxkey = CAMELLIA_MAX_KEY_LEN; - break; - default: - dprintk("%s(%s) - bad cipher\n", __FUNCTION__, CIOCGSESSSTR); - error = EINVAL; - goto bail; - } - - switch (sop.mac) { - case 0: - dprintk("%s(%s) - no mac\n", __FUNCTION__, CIOCGSESSSTR); - break; - case CRYPTO_NULL_HMAC: - info.authsize = NULL_HASH_LEN; - break; - case CRYPTO_MD5: - info.authsize = MD5_HASH_LEN; - break; - case CRYPTO_SHA1: - info.authsize = SHA1_HASH_LEN; - break; - case CRYPTO_SHA2_256: - info.authsize = SHA2_256_HASH_LEN; - break; - case CRYPTO_SHA2_384: - info.authsize = SHA2_384_HASH_LEN; - break; - case CRYPTO_SHA2_512: - info.authsize = SHA2_512_HASH_LEN; - break; - case CRYPTO_RIPEMD160: - info.authsize = RIPEMD160_HASH_LEN; - break; - case CRYPTO_MD5_HMAC: - info.authsize = MD5_HASH_LEN; - info.authkey = 16; - break; - case CRYPTO_SHA1_HMAC: - info.authsize = SHA1_HASH_LEN; - info.authkey = 20; - break; - case CRYPTO_SHA2_256_HMAC: - info.authsize = SHA2_256_HASH_LEN; - info.authkey = 32; - break; - case CRYPTO_SHA2_384_HMAC: - info.authsize = SHA2_384_HASH_LEN; - info.authkey = 48; - break; - case CRYPTO_SHA2_512_HMAC: - info.authsize = SHA2_512_HASH_LEN; - info.authkey = 64; - break; - case CRYPTO_RIPEMD160_HMAC: - info.authsize = RIPEMD160_HASH_LEN; - info.authkey = 20; - break; - default: - dprintk("%s(%s) - bad mac\n", __FUNCTION__, CIOCGSESSSTR); - error = EINVAL; - goto bail; - } - - if (info.blocksize) { - crie.cri_alg = sop.cipher; - crie.cri_klen = sop.keylen * 8; - if ((info.maxkey && sop.keylen > info.maxkey) || - sop.keylen < info.minkey) { - dprintk("%s(%s) - bad key\n", __FUNCTION__, CIOCGSESSSTR); - error = EINVAL; - goto bail; - } - - crie.cri_key = (u_int8_t *) kmalloc(crie.cri_klen/8+1, GFP_KERNEL); - if (copy_from_user(crie.cri_key, sop.key, - crie.cri_klen/8)) { - dprintk("%s(%s) - bad copy\n", __FUNCTION__, CIOCGSESSSTR); - error = EFAULT; - goto bail; - } - if (info.authsize) - crie.cri_next = &cria; - } - - if (info.authsize) { - cria.cri_alg = sop.mac; - cria.cri_klen = sop.mackeylen * 8; - if (info.authkey && sop.mackeylen != info.authkey) { - dprintk("%s(%s) - mackeylen %d != %d\n", __FUNCTION__, - CIOCGSESSSTR, sop.mackeylen, info.authkey); - error = EINVAL; - goto bail; - } - - if (cria.cri_klen) { - cria.cri_key = (u_int8_t *) kmalloc(cria.cri_klen/8,GFP_KERNEL); - if (copy_from_user(cria.cri_key, sop.mackey, - cria.cri_klen / 8)) { - dprintk("%s(%s) - bad copy\n", __FUNCTION__, CIOCGSESSSTR); - error = EFAULT; - goto bail; - } - } - } - - /* NB: CIOGSESSION2 has the crid */ - if (cmd == CIOCGSESSION2) { - crid = sop.crid; - error = checkcrid(crid); - if (error) { - dprintk("%s(%s) - checkcrid %x\n", __FUNCTION__, - CIOCGSESSSTR, error); - goto bail; - } - } else { - /* allow either HW or SW to be used */ - crid = CRYPTOCAP_F_HARDWARE | CRYPTOCAP_F_SOFTWARE; - } - error = crypto_newsession(&sid, (info.blocksize ? &crie : &cria), crid); - if (error) { - dprintk("%s(%s) - newsession %d\n",__FUNCTION__,CIOCGSESSSTR,error); - goto bail; - } - - cse = csecreate(fcr, sid, &crie, &cria, &info); - if (cse == NULL) { - crypto_freesession(sid); - error = EINVAL; - dprintk("%s(%s) - csecreate failed\n", __FUNCTION__, CIOCGSESSSTR); - goto bail; - } - sop.ses = cse->ses; - - if (cmd == CIOCGSESSION2) { - /* return hardware/driver id */ - sop.crid = CRYPTO_SESID2HID(cse->sid); - } - - if (copy_to_user((void*)arg, &sop, (cmd == CIOCGSESSION) ? - sizeof(struct session_op) : sizeof(sop))) { - dprintk("%s(%s) - bad copy\n", __FUNCTION__, CIOCGSESSSTR); - error = EFAULT; - } -bail: - if (error) { - dprintk("%s(%s) - bail %d\n", __FUNCTION__, CIOCGSESSSTR, error); - if (crie.cri_key) - kfree(crie.cri_key); - if (cria.cri_key) - kfree(cria.cri_key); - } - break; - case CIOCFSESSION: - dprintk("%s(CIOCFSESSION)\n", __FUNCTION__); - get_user(ses, (uint32_t*)arg); - cse = csefind(fcr, ses); - if (cse == NULL) { - error = EINVAL; - dprintk("%s(CIOCFSESSION) - Fail %d\n", __FUNCTION__, error); - break; - } - csedelete(fcr, cse); - error = csefree(cse); - break; - case CIOCCRYPT: - dprintk("%s(CIOCCRYPT)\n", __FUNCTION__); - if(copy_from_user(&cop, (void*)arg, sizeof(cop))) { - dprintk("%s(CIOCCRYPT) - bad copy\n", __FUNCTION__); - error = EFAULT; - goto bail; - } - cse = csefind(fcr, cop.ses); - if (cse == NULL) { - error = EINVAL; - dprintk("%s(CIOCCRYPT) - Fail %d\n", __FUNCTION__, error); - break; - } - error = cryptodev_op(cse, &cop); - if(copy_to_user((void*)arg, &cop, sizeof(cop))) { - dprintk("%s(CIOCCRYPT) - bad return copy\n", __FUNCTION__); - error = EFAULT; - goto bail; - } - break; - case CIOCKEY: - case CIOCKEY2: - dprintk("%s(CIOCKEY)\n", __FUNCTION__); - if (!crypto_userasymcrypto) - return (EPERM); /* XXX compat? */ - if(copy_from_user(&kop, (void*)arg, sizeof(kop))) { - dprintk("%s(CIOCKEY) - bad copy\n", __FUNCTION__); - error = EFAULT; - goto bail; - } - if (cmd == CIOCKEY) { - /* NB: crypto core enforces s/w driver use */ - kop.crk_crid = - CRYPTOCAP_F_HARDWARE | CRYPTOCAP_F_SOFTWARE; - } - error = cryptodev_key(&kop); - if(copy_to_user((void*)arg, &kop, sizeof(kop))) { - dprintk("%s(CIOCGKEY) - bad return copy\n", __FUNCTION__); - error = EFAULT; - goto bail; - } - break; - case CIOCASYMFEAT: - dprintk("%s(CIOCASYMFEAT)\n", __FUNCTION__); - if (!crypto_userasymcrypto) { - /* - * NB: if user asym crypto operations are - * not permitted return "no algorithms" - * so well-behaved applications will just - * fallback to doing them in software. - */ - feat = 0; - } else - error = crypto_getfeat(&feat); - if (!error) { - error = copy_to_user((void*)arg, &feat, sizeof(feat)); - } - break; - case CIOCFINDDEV: - if (copy_from_user(&fop, (void*)arg, sizeof(fop))) { - dprintk("%s(CIOCFINDDEV) - bad copy\n", __FUNCTION__); - error = EFAULT; - goto bail; - } - error = cryptodev_find(&fop); - if (copy_to_user((void*)arg, &fop, sizeof(fop))) { - dprintk("%s(CIOCFINDDEV) - bad return copy\n", __FUNCTION__); - error = EFAULT; - goto bail; - } - break; - default: - dprintk("%s(unknown ioctl 0x%x)\n", __FUNCTION__, cmd); - error = EINVAL; - break; - } - return(-error); -} - -#ifdef HAVE_UNLOCKED_IOCTL -static long -cryptodev_unlocked_ioctl( - struct file *filp, - unsigned int cmd, - unsigned long arg) -{ - return cryptodev_ioctl(NULL, filp, cmd, arg); -} -#endif - -static int -cryptodev_open(struct inode *inode, struct file *filp) -{ - struct fcrypt *fcr; - - dprintk("%s()\n", __FUNCTION__); - if (filp->private_data) { - printk("cryptodev: Private data already exists !\n"); - return(0); - } - - fcr = kmalloc(sizeof(*fcr), GFP_KERNEL); - if (!fcr) { - dprintk("%s() - malloc failed\n", __FUNCTION__); - return(-ENOMEM); - } - memset(fcr, 0, sizeof(*fcr)); - - INIT_LIST_HEAD(&fcr->csessions); - filp->private_data = fcr; - return(0); -} - -static int -cryptodev_release(struct inode *inode, struct file *filp) -{ - struct fcrypt *fcr = filp->private_data; - struct csession *cse, *tmp; - - dprintk("%s()\n", __FUNCTION__); - if (!filp) { - printk("cryptodev: No private data on release\n"); - return(0); - } - - list_for_each_entry_safe(cse, tmp, &fcr->csessions, list) { - list_del(&cse->list); - (void)csefree(cse); - } - filp->private_data = NULL; - kfree(fcr); - return(0); -} - -static struct file_operations cryptodev_fops = { - .owner = THIS_MODULE, - .open = cryptodev_open, - .release = cryptodev_release, - .ioctl = cryptodev_ioctl, -#ifdef HAVE_UNLOCKED_IOCTL - .unlocked_ioctl = cryptodev_unlocked_ioctl, -#endif -}; - -static struct miscdevice cryptodev = { - .minor = CRYPTODEV_MINOR, - .name = "crypto", - .fops = &cryptodev_fops, -}; - -static int __init -cryptodev_init(void) -{ - int rc; - - dprintk("%s(%p)\n", __FUNCTION__, cryptodev_init); - rc = misc_register(&cryptodev); - if (rc) { - printk(KERN_ERR "cryptodev: registration of /dev/crypto failed\n"); - return(rc); - } - - return(0); -} - -static void __exit -cryptodev_exit(void) -{ - dprintk("%s()\n", __FUNCTION__); - misc_deregister(&cryptodev); -} - -module_init(cryptodev_init); -module_exit(cryptodev_exit); - -MODULE_LICENSE("BSD"); -MODULE_AUTHOR("David McCullough <david_mccullough@mcafee.com>"); -MODULE_DESCRIPTION("Cryptodev (user interface to OCF)"); diff --git a/target/linux/generic-2.4/files/crypto/ocf/cryptodev.h b/target/linux/generic-2.4/files/crypto/ocf/cryptodev.h deleted file mode 100644 index 6032317..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/cryptodev.h +++ /dev/null @@ -1,479 +0,0 @@ -/* $FreeBSD: src/sys/opencrypto/cryptodev.h,v 1.25 2007/05/09 19:37:02 gnn Exp $ */ -/* $OpenBSD: cryptodev.h,v 1.31 2002/06/11 11:14:29 beck Exp $ */ - -/*- - * Linux port done by David McCullough <david_mccullough@mcafee.com> - * Copyright (C) 2006-2010 David McCullough - * Copyright (C) 2004-2005 Intel Corporation. - * The license and original author are listed below. - * - * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu) - * Copyright (c) 2002-2006 Sam Leffler, Errno Consulting - * - * This code was written by Angelos D. Keromytis in Athens, Greece, in - * February 2000. Network Security Technologies Inc. (NSTI) kindly - * supported the development of this code. - * - * Copyright (c) 2000 Angelos D. Keromytis - * - * Permission to use, copy, and modify this software with or without fee - * is hereby granted, provided that this entire notice is included in - * all source code copies of any software which is or includes a copy or - * modification of this software. - * - * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY - * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE - * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR - * PURPOSE. - * - * Copyright (c) 2001 Theo de Raadt - * - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR 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. - * - * Effort sponsored in part by the Defense Advanced Research Projects - * Agency (DARPA) and Air Force Research Laboratory, Air Force - * Materiel Command, USAF, under agreement number F30602-01-2-0537. - * - */ - -#ifndef _CRYPTO_CRYPTO_H_ -#define _CRYPTO_CRYPTO_H_ - -/* Some initial values */ -#define CRYPTO_DRIVERS_INITIAL 4 -#define CRYPTO_SW_SESSIONS 32 - -/* Hash values */ -#define NULL_HASH_LEN 0 -#define MD5_HASH_LEN 16 -#define SHA1_HASH_LEN 20 -#define RIPEMD160_HASH_LEN 20 -#define SHA2_256_HASH_LEN 32 -#define SHA2_384_HASH_LEN 48 -#define SHA2_512_HASH_LEN 64 -#define MD5_KPDK_HASH_LEN 16 -#define SHA1_KPDK_HASH_LEN 20 -/* Maximum hash algorithm result length */ -#define HASH_MAX_LEN SHA2_512_HASH_LEN /* Keep this updated */ - -/* HMAC values */ -#define NULL_HMAC_BLOCK_LEN 1 -#define MD5_HMAC_BLOCK_LEN 64 -#define SHA1_HMAC_BLOCK_LEN 64 -#define RIPEMD160_HMAC_BLOCK_LEN 64 -#define SHA2_256_HMAC_BLOCK_LEN 64 -#define SHA2_384_HMAC_BLOCK_LEN 128 -#define SHA2_512_HMAC_BLOCK_LEN 128 -/* Maximum HMAC block length */ -#define HMAC_MAX_BLOCK_LEN SHA2_512_HMAC_BLOCK_LEN /* Keep this updated */ -#define HMAC_IPAD_VAL 0x36 -#define HMAC_OPAD_VAL 0x5C - -/* Encryption algorithm block sizes */ -#define NULL_BLOCK_LEN 1 -#define DES_BLOCK_LEN 8 -#define DES3_BLOCK_LEN 8 -#define BLOWFISH_BLOCK_LEN 8 -#define SKIPJACK_BLOCK_LEN 8 -#define CAST128_BLOCK_LEN 8 -#define RIJNDAEL128_BLOCK_LEN 16 -#define AES_BLOCK_LEN RIJNDAEL128_BLOCK_LEN -#define CAMELLIA_BLOCK_LEN 16 -#define ARC4_BLOCK_LEN 1 -#define EALG_MAX_BLOCK_LEN AES_BLOCK_LEN /* Keep this updated */ - -/* Encryption algorithm min and max key sizes */ -#define NULL_MIN_KEY_LEN 0 -#define NULL_MAX_KEY_LEN 0 -#define DES_MIN_KEY_LEN 8 -#define DES_MAX_KEY_LEN 8 -#define DES3_MIN_KEY_LEN 24 -#define DES3_MAX_KEY_LEN 24 -#define BLOWFISH_MIN_KEY_LEN 4 -#define BLOWFISH_MAX_KEY_LEN 56 -#define SKIPJACK_MIN_KEY_LEN 10 -#define SKIPJACK_MAX_KEY_LEN 10 -#define CAST128_MIN_KEY_LEN 5 -#define CAST128_MAX_KEY_LEN 16 -#define RIJNDAEL128_MIN_KEY_LEN 16 -#define RIJNDAEL128_MAX_KEY_LEN 32 -#define AES_MIN_KEY_LEN RIJNDAEL128_MIN_KEY_LEN -#define AES_MAX_KEY_LEN RIJNDAEL128_MAX_KEY_LEN -#define CAMELLIA_MIN_KEY_LEN 16 -#define CAMELLIA_MAX_KEY_LEN 32 -#define ARC4_MIN_KEY_LEN 1 -#define ARC4_MAX_KEY_LEN 256 - -/* Max size of data that can be processed */ -#define CRYPTO_MAX_DATA_LEN 64*1024 - 1 - -#define CRYPTO_ALGORITHM_MIN 1 -#define CRYPTO_DES_CBC 1 -#define CRYPTO_3DES_CBC 2 -#define CRYPTO_BLF_CBC 3 -#define CRYPTO_CAST_CBC 4 -#define CRYPTO_SKIPJACK_CBC 5 -#define CRYPTO_MD5_HMAC 6 -#define CRYPTO_SHA1_HMAC 7 -#define CRYPTO_RIPEMD160_HMAC 8 -#define CRYPTO_MD5_KPDK 9 -#define CRYPTO_SHA1_KPDK 10 -#define CRYPTO_RIJNDAEL128_CBC 11 /* 128 bit blocksize */ -#define CRYPTO_AES_CBC 11 /* 128 bit blocksize -- the same as above */ -#define CRYPTO_ARC4 12 -#define CRYPTO_MD5 13 -#define CRYPTO_SHA1 14 -#define CRYPTO_NULL_HMAC 15 -#define CRYPTO_NULL_CBC 16 -#define CRYPTO_DEFLATE_COMP 17 /* Deflate compression algorithm */ -#define CRYPTO_SHA2_256_HMAC 18 -#define CRYPTO_SHA2_384_HMAC 19 -#define CRYPTO_SHA2_512_HMAC 20 -#define CRYPTO_CAMELLIA_CBC 21 -#define CRYPTO_SHA2_256 22 -#define CRYPTO_SHA2_384 23 -#define CRYPTO_SHA2_512 24 -#define CRYPTO_RIPEMD160 25 -#define CRYPTO_ALGORITHM_MAX 25 /* Keep updated - see below */ - -/* Algorithm flags */ -#define CRYPTO_ALG_FLAG_SUPPORTED 0x01 /* Algorithm is supported */ -#define CRYPTO_ALG_FLAG_RNG_ENABLE 0x02 /* Has HW RNG for DH/DSA */ -#define CRYPTO_ALG_FLAG_DSA_SHA 0x04 /* Can do SHA on msg */ - -/* - * Crypto driver/device flags. They can set in the crid - * parameter when creating a session or submitting a key - * op to affect the device/driver assigned. If neither - * of these are specified then the crid is assumed to hold - * the driver id of an existing (and suitable) device that - * must be used to satisfy the request. - */ -#define CRYPTO_FLAG_HARDWARE 0x01000000 /* hardware accelerated */ -#define CRYPTO_FLAG_SOFTWARE 0x02000000 /* software implementation */ - -/* NB: deprecated */ -struct session_op { - u_int32_t cipher; /* ie. CRYPTO_DES_CBC */ - u_int32_t mac; /* ie. CRYPTO_MD5_HMAC */ - - u_int32_t keylen; /* cipher key */ - caddr_t key; - int mackeylen; /* mac key */ - caddr_t mackey; - - u_int32_t ses; /* returns: session # */ -}; - -struct session2_op { - u_int32_t cipher; /* ie. CRYPTO_DES_CBC */ - u_int32_t mac; /* ie. CRYPTO_MD5_HMAC */ - - u_int32_t keylen; /* cipher key */ - caddr_t key; - int mackeylen; /* mac key */ - caddr_t mackey; - - u_int32_t ses; /* returns: session # */ - int crid; /* driver id + flags (rw) */ - int pad[4]; /* for future expansion */ -}; - -struct crypt_op { - u_int32_t ses; - u_int16_t op; /* i.e. COP_ENCRYPT */ -#define COP_NONE 0 -#define COP_ENCRYPT 1 -#define COP_DECRYPT 2 - u_int16_t flags; -#define COP_F_BATCH 0x0008 /* Batch op if possible */ - u_int len; - caddr_t src, dst; /* become iov[] inside kernel */ - caddr_t mac; /* must be big enough for chosen MAC */ - caddr_t iv; -}; - -/* - * Parameters for looking up a crypto driver/device by - * device name or by id. The latter are returned for - * created sessions (crid) and completed key operations. - */ -struct crypt_find_op { - int crid; /* driver id + flags */ - char name[32]; /* device/driver name */ -}; - -/* bignum parameter, in packed bytes, ... */ -struct crparam { - caddr_t crp_p; - u_int crp_nbits; -}; - -#define CRK_MAXPARAM 8 - -struct crypt_kop { - u_int crk_op; /* ie. CRK_MOD_EXP or other */ - u_int crk_status; /* return status */ - u_short crk_iparams; /* # of input parameters */ - u_short crk_oparams; /* # of output parameters */ - u_int crk_crid; /* NB: only used by CIOCKEY2 (rw) */ - struct crparam crk_param[CRK_MAXPARAM]; -}; -#define CRK_ALGORITM_MIN 0 -#define CRK_MOD_EXP 0 -#define CRK_MOD_EXP_CRT 1 -#define CRK_DSA_SIGN 2 -#define CRK_DSA_VERIFY 3 -#define CRK_DH_COMPUTE_KEY 4 -#define CRK_ALGORITHM_MAX 4 /* Keep updated - see below */ - -#define CRF_MOD_EXP (1 << CRK_MOD_EXP) -#define CRF_MOD_EXP_CRT (1 << CRK_MOD_EXP_CRT) -#define CRF_DSA_SIGN (1 << CRK_DSA_SIGN) -#define CRF_DSA_VERIFY (1 << CRK_DSA_VERIFY) -#define CRF_DH_COMPUTE_KEY (1 << CRK_DH_COMPUTE_KEY) - -/* - * done against open of /dev/crypto, to get a cloned descriptor. - * Please use F_SETFD against the cloned descriptor. - */ -#define CRIOGET _IOWR('c', 100, u_int32_t) -#define CRIOASYMFEAT CIOCASYMFEAT -#define CRIOFINDDEV CIOCFINDDEV - -/* the following are done against the cloned descriptor */ -#define CIOCGSESSION _IOWR('c', 101, struct session_op) -#define CIOCFSESSION _IOW('c', 102, u_int32_t) -#define CIOCCRYPT _IOWR('c', 103, struct crypt_op) -#define CIOCKEY _IOWR('c', 104, struct crypt_kop) -#define CIOCASYMFEAT _IOR('c', 105, u_int32_t) -#define CIOCGSESSION2 _IOWR('c', 106, struct session2_op) -#define CIOCKEY2 _IOWR('c', 107, struct crypt_kop) -#define CIOCFINDDEV _IOWR('c', 108, struct crypt_find_op) - -struct cryptotstat { - struct timespec acc; /* total accumulated time */ - struct timespec min; /* min time */ - struct timespec max; /* max time */ - u_int32_t count; /* number of observations */ -}; - -struct cryptostats { - u_int32_t cs_ops; /* symmetric crypto ops submitted */ - u_int32_t cs_errs; /* symmetric crypto ops that failed */ - u_int32_t cs_kops; /* asymetric/key ops submitted */ - u_int32_t cs_kerrs; /* asymetric/key ops that failed */ - u_int32_t cs_intrs; /* crypto swi thread activations */ - u_int32_t cs_rets; /* crypto return thread activations */ - u_int32_t cs_blocks; /* symmetric op driver block */ - u_int32_t cs_kblocks; /* symmetric op driver block */ - /* - * When CRYPTO_TIMING is defined at compile time and the - * sysctl debug.crypto is set to 1, the crypto system will - * accumulate statistics about how long it takes to process - * crypto requests at various points during processing. - */ - struct cryptotstat cs_invoke; /* crypto_dipsatch -> crypto_invoke */ - struct cryptotstat cs_done; /* crypto_invoke -> crypto_done */ - struct cryptotstat cs_cb; /* crypto_done -> callback */ - struct cryptotstat cs_finis; /* callback -> callback return */ - - u_int32_t cs_drops; /* crypto ops dropped due to congestion */ -}; - -#ifdef __KERNEL__ - -/* Standard initialization structure beginning */ -struct cryptoini { - int cri_alg; /* Algorithm to use */ - int cri_klen; /* Key length, in bits */ - int cri_mlen; /* Number of bytes we want from the - entire hash. 0 means all. */ - caddr_t cri_key; /* key to use */ - u_int8_t cri_iv[EALG_MAX_BLOCK_LEN]; /* IV to use */ - struct cryptoini *cri_next; -}; - -/* Describe boundaries of a single crypto operation */ -struct cryptodesc { - int crd_skip; /* How many bytes to ignore from start */ - int crd_len; /* How many bytes to process */ - int crd_inject; /* Where to inject results, if applicable */ - int crd_flags; - -#define CRD_F_ENCRYPT 0x01 /* Set when doing encryption */ -#define CRD_F_IV_PRESENT 0x02 /* When encrypting, IV is already in - place, so don't copy. */ -#define CRD_F_IV_EXPLICIT 0x04 /* IV explicitly provided */ -#define CRD_F_DSA_SHA_NEEDED 0x08 /* Compute SHA-1 of buffer for DSA */ -#define CRD_F_KEY_EXPLICIT 0x10 /* Key explicitly provided */ -#define CRD_F_COMP 0x0f /* Set when doing compression */ - - struct cryptoini CRD_INI; /* Initialization/context data */ -#define crd_iv CRD_INI.cri_iv -#define crd_key CRD_INI.cri_key -#define crd_alg CRD_INI.cri_alg -#define crd_klen CRD_INI.cri_klen -#define crd_mlen CRD_INI.cri_mlen - - struct cryptodesc *crd_next; -}; - -/* Structure describing complete operation */ -struct cryptop { - struct list_head crp_next; - wait_queue_head_t crp_waitq; - - u_int64_t crp_sid; /* Session ID */ - int crp_ilen; /* Input data total length */ - int crp_olen; /* Result total length */ - - int crp_etype; /* - * Error type (zero means no error). - * All error codes except EAGAIN - * indicate possible data corruption (as in, - * the data have been touched). On all - * errors, the crp_sid may have changed - * (reset to a new one), so the caller - * should always check and use the new - * value on future requests. - */ - int crp_flags; - -#define CRYPTO_F_SKBUF 0x0001 /* Input/output are skbuf chains */ -#define CRYPTO_F_IOV 0x0002 /* Input/output are uio */ -#define CRYPTO_F_REL 0x0004 /* Must return data in same place */ -#define CRYPTO_F_BATCH 0x0008 /* Batch op if possible */ -#define CRYPTO_F_CBIMM 0x0010 /* Do callback immediately */ -#define CRYPTO_F_DONE 0x0020 /* Operation completed */ -#define CRYPTO_F_CBIFSYNC 0x0040 /* Do CBIMM if op is synchronous */ - - caddr_t crp_buf; /* Data to be processed */ - caddr_t crp_opaque; /* Opaque pointer, passed along */ - struct cryptodesc *crp_desc; /* Linked list of processing descriptors */ - - int (*crp_callback)(struct cryptop *); /* Callback function */ -}; - -#define CRYPTO_BUF_CONTIG 0x0 -#define CRYPTO_BUF_IOV 0x1 -#define CRYPTO_BUF_SKBUF 0x2 - -#define CRYPTO_OP_DECRYPT 0x0 -#define CRYPTO_OP_ENCRYPT 0x1 - -/* - * Hints passed to process methods. - */ -#define CRYPTO_HINT_MORE 0x1 /* more ops coming shortly */ - -struct cryptkop { - struct list_head krp_next; - wait_queue_head_t krp_waitq; - - int krp_flags; -#define CRYPTO_KF_DONE 0x0001 /* Operation completed */ -#define CRYPTO_KF_CBIMM 0x0002 /* Do callback immediately */ - - u_int krp_op; /* ie. CRK_MOD_EXP or other */ - u_int krp_status; /* return status */ - u_short krp_iparams; /* # of input parameters */ - u_short krp_oparams; /* # of output parameters */ - u_int krp_crid; /* desired device, etc. */ - u_int32_t krp_hid; - struct crparam krp_param[CRK_MAXPARAM]; /* kvm */ - int (*krp_callback)(struct cryptkop *); -}; - -#include <ocf-compat.h> - -/* - * Session ids are 64 bits. The lower 32 bits contain a "local id" which - * is a driver-private session identifier. The upper 32 bits contain a - * "hardware id" used by the core crypto code to identify the driver and - * a copy of the driver's capabilities that can be used by client code to - * optimize operation. - */ -#define CRYPTO_SESID2HID(_sid) (((_sid) >> 32) & 0x00ffffff) -#define CRYPTO_SESID2CAPS(_sid) (((_sid) >> 32) & 0xff000000) -#define CRYPTO_SESID2LID(_sid) (((u_int32_t) (_sid)) & 0xffffffff) - -extern int crypto_newsession(u_int64_t *sid, struct cryptoini *cri, int hard); -extern int crypto_freesession(u_int64_t sid); -#define CRYPTOCAP_F_HARDWARE CRYPTO_FLAG_HARDWARE -#define CRYPTOCAP_F_SOFTWARE CRYPTO_FLAG_SOFTWARE -#define CRYPTOCAP_F_SYNC 0x04000000 /* operates synchronously */ -extern int32_t crypto_get_driverid(device_t dev, int flags); -extern int crypto_find_driver(const char *); -extern device_t crypto_find_device_byhid(int hid); -extern int crypto_getcaps(int hid); -extern int crypto_register(u_int32_t driverid, int alg, u_int16_t maxoplen, - u_int32_t flags); -extern int crypto_kregister(u_int32_t, int, u_int32_t); -extern int crypto_unregister(u_int32_t driverid, int alg); -extern int crypto_unregister_all(u_int32_t driverid); -extern int crypto_dispatch(struct cryptop *crp); -extern int crypto_kdispatch(struct cryptkop *); -#define CRYPTO_SYMQ 0x1 -#define CRYPTO_ASYMQ 0x2 -extern int crypto_unblock(u_int32_t, int); -extern void crypto_done(struct cryptop *crp); -extern void crypto_kdone(struct cryptkop *); -extern int crypto_getfeat(int *); - -extern void crypto_freereq(struct cryptop *crp); -extern struct cryptop *crypto_getreq(int num); - -extern int crypto_usercrypto; /* userland may do crypto requests */ -extern int crypto_userasymcrypto; /* userland may do asym crypto reqs */ -extern int crypto_devallowsoft; /* only use hardware crypto */ - -/* - * random number support, crypto_unregister_all will unregister - */ -extern int crypto_rregister(u_int32_t driverid, - int (*read_random)(void *arg, u_int32_t *buf, int len), void *arg); -extern int crypto_runregister_all(u_int32_t driverid); - -/* - * Crypto-related utility routines used mainly by drivers. - * - * XXX these don't really belong here; but for now they're - * kept apart from the rest of the system. - */ -struct uio; -extern void cuio_copydata(struct uio* uio, int off, int len, caddr_t cp); -extern void cuio_copyback(struct uio* uio, int off, int len, caddr_t cp); -extern struct iovec *cuio_getptr(struct uio *uio, int loc, int *off); - -extern void crypto_copyback(int flags, caddr_t buf, int off, int size, - caddr_t in); -extern void crypto_copydata(int flags, caddr_t buf, int off, int size, - caddr_t out); -extern int crypto_apply(int flags, caddr_t buf, int off, int len, - int (*f)(void *, void *, u_int), void *arg); - -#endif /* __KERNEL__ */ -#endif /* _CRYPTO_CRYPTO_H_ */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/cryptosoft.c b/target/linux/generic-2.4/files/crypto/ocf/cryptosoft.c deleted file mode 100644 index 52e1570..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/cryptosoft.c +++ /dev/null @@ -1,1210 +0,0 @@ -/* - * An OCF module that uses the linux kernel cryptoapi, based on the - * original cryptosoft for BSD by Angelos D. Keromytis (angelos@cis.upenn.edu) - * but is mostly unrecognisable, - * - * Written by David McCullough <david_mccullough@mcafee.com> - * Copyright (C) 2004-2010 David McCullough - * Copyright (C) 2004-2005 Intel Corporation. - * - * LICENSE TERMS - * - * The free distribution and use of this software in both source and binary - * form is allowed (with or without changes) provided that: - * - * 1. distributions of this source code include the above copyright - * notice, this list of conditions and the following disclaimer; - * - * 2. distributions in binary form include the above copyright - * notice, this list of conditions and the following disclaimer - * in the documentation and/or other associated materials; - * - * 3. the copyright holder's name is not used to endorse products - * built using this software without specific written permission. - * - * ALTERNATIVELY, provided that this notice is retained in full, this product - * may be distributed under the terms of the GNU General Public License (GPL), - * in which case the provisions of the GPL apply INSTEAD OF those given above. - * - * DISCLAIMER - * - * This software is provided 'as is' with no explicit or implied warranties - * in respect of its properties, including, but not limited to, correctness - * and/or fitness for purpose. - * --------------------------------------------------------------------------- - */ - -#ifndef AUTOCONF_INCLUDED -#include <linux/config.h> -#endif -#include <linux/module.h> -#include <linux/init.h> -#include <linux/list.h> -#include <linux/slab.h> -#include <linux/sched.h> -#include <linux/wait.h> -#include <linux/crypto.h> -#include <linux/mm.h> -#include <linux/skbuff.h> -#include <linux/random.h> -#include <linux/version.h> -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10) -#include <linux/scatterlist.h> -#endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29) -#include <crypto/hash.h> -#endif - -#include <cryptodev.h> -#include <uio.h> - -struct { - softc_device_decl sc_dev; -} swcr_softc; - -#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK) - -#define SW_TYPE_CIPHER 0x01 -#define SW_TYPE_HMAC 0x02 -#define SW_TYPE_HASH 0x04 -#define SW_TYPE_COMP 0x08 -#define SW_TYPE_BLKCIPHER 0x10 -#define SW_TYPE_ALG_MASK 0x1f - -#define SW_TYPE_ASYNC 0x8000 - -/* We change some of the above if we have an async interface */ - -#define SW_TYPE_ALG_AMASK (SW_TYPE_ALG_MASK | SW_TYPE_ASYNC) - -#define SW_TYPE_ABLKCIPHER (SW_TYPE_BLKCIPHER | SW_TYPE_ASYNC) -#define SW_TYPE_AHASH (SW_TYPE_HASH | SW_TYPE_ASYNC) -#define SW_TYPE_AHMAC (SW_TYPE_HMAC | SW_TYPE_ASYNC) - -#define SCATTERLIST_MAX 16 - -struct swcr_data { - int sw_type; - int sw_alg; - struct crypto_tfm *sw_tfm; - union { - struct { - char *sw_key; - int sw_klen; - int sw_mlen; - } hmac; - void *sw_comp_buf; - } u; - struct swcr_data *sw_next; -}; - -struct swcr_req { - struct swcr_data *sw_head; - struct swcr_data *sw; - struct cryptop *crp; - struct cryptodesc *crd; - struct scatterlist sg[SCATTERLIST_MAX]; - unsigned char iv[EALG_MAX_BLOCK_LEN]; - char result[HASH_MAX_LEN]; - void *crypto_req; -}; - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) -static kmem_cache_t *swcr_req_cache; -#else -static struct kmem_cache *swcr_req_cache; -#endif - -#ifndef CRYPTO_TFM_MODE_CBC -/* - * As of linux-2.6.21 this is no longer defined, and presumably no longer - * needed to be passed into the crypto core code. - */ -#define CRYPTO_TFM_MODE_CBC 0 -#define CRYPTO_TFM_MODE_ECB 0 -#endif - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) - /* - * Linux 2.6.19 introduced a new Crypto API, setup macro's to convert new - * API into old API. - */ - - /* Symmetric/Block Cipher */ - struct blkcipher_desc - { - struct crypto_tfm *tfm; - void *info; - }; - #define ecb(X) #X , CRYPTO_TFM_MODE_ECB - #define cbc(X) #X , CRYPTO_TFM_MODE_CBC - #define crypto_has_blkcipher(X, Y, Z) crypto_alg_available(X, 0) - #define crypto_blkcipher_cast(X) X - #define crypto_blkcipher_tfm(X) X - #define crypto_alloc_blkcipher(X, Y, Z) crypto_alloc_tfm(X, mode) - #define crypto_blkcipher_ivsize(X) crypto_tfm_alg_ivsize(X) - #define crypto_blkcipher_blocksize(X) crypto_tfm_alg_blocksize(X) - #define crypto_blkcipher_setkey(X, Y, Z) crypto_cipher_setkey(X, Y, Z) - #define crypto_blkcipher_encrypt_iv(W, X, Y, Z) \ - crypto_cipher_encrypt_iv((W)->tfm, X, Y, Z, (u8 *)((W)->info)) - #define crypto_blkcipher_decrypt_iv(W, X, Y, Z) \ - crypto_cipher_decrypt_iv((W)->tfm, X, Y, Z, (u8 *)((W)->info)) - #define crypto_blkcipher_set_flags(x, y) /* nop */ - - /* Hash/HMAC/Digest */ - struct hash_desc - { - struct crypto_tfm *tfm; - }; - #define hmac(X) #X , 0 - #define crypto_has_hash(X, Y, Z) crypto_alg_available(X, 0) - #define crypto_hash_cast(X) X - #define crypto_hash_tfm(X) X - #define crypto_alloc_hash(X, Y, Z) crypto_alloc_tfm(X, mode) - #define crypto_hash_digestsize(X) crypto_tfm_alg_digestsize(X) - #define crypto_hash_digest(W, X, Y, Z) \ - crypto_digest_digest((W)->tfm, X, sg_num, Z) - - /* Asymmetric Cipher */ - #define crypto_has_cipher(X, Y, Z) crypto_alg_available(X, 0) - - /* Compression */ - #define crypto_has_comp(X, Y, Z) crypto_alg_available(X, 0) - #define crypto_comp_tfm(X) X - #define crypto_comp_cast(X) X - #define crypto_alloc_comp(X, Y, Z) crypto_alloc_tfm(X, mode) - #define plain(X) #X , 0 -#else - #define ecb(X) "ecb(" #X ")" , 0 - #define cbc(X) "cbc(" #X ")" , 0 - #define hmac(X) "hmac(" #X ")" , 0 - #define plain(X) #X , 0 -#endif /* if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) */ - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) -/* no ablkcipher in older kernels */ -#define crypto_alloc_ablkcipher(a,b,c) (NULL) -#define crypto_ablkcipher_tfm(x) ((struct crypto_tfm *)(x)) -#define crypto_ablkcipher_set_flags(a, b) /* nop */ -#define crypto_ablkcipher_setkey(x, y, z) (-EINVAL) -#define crypto_has_ablkcipher(a,b,c) (0) -#else -#define HAVE_ABLKCIPHER -#endif - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32) -/* no ahash in older kernels */ -#define crypto_ahash_tfm(x) ((struct crypto_tfm *)(x)) -#define crypto_alloc_ahash(a,b,c) (NULL) -#define crypto_ahash_digestsize(x) 0 -#else -#define HAVE_AHASH -#endif - -struct crypto_details { - char *alg_name; - int mode; - int sw_type; -}; - -static struct crypto_details crypto_details[] = { - [CRYPTO_DES_CBC] = { cbc(des), SW_TYPE_BLKCIPHER, }, - [CRYPTO_3DES_CBC] = { cbc(des3_ede), SW_TYPE_BLKCIPHER, }, - [CRYPTO_BLF_CBC] = { cbc(blowfish), SW_TYPE_BLKCIPHER, }, - [CRYPTO_CAST_CBC] = { cbc(cast5), SW_TYPE_BLKCIPHER, }, - [CRYPTO_SKIPJACK_CBC] = { cbc(skipjack), SW_TYPE_BLKCIPHER, }, - [CRYPTO_MD5_HMAC] = { hmac(md5), SW_TYPE_HMAC, }, - [CRYPTO_SHA1_HMAC] = { hmac(sha1), SW_TYPE_HMAC, }, - [CRYPTO_RIPEMD160_HMAC] = { hmac(ripemd160), SW_TYPE_HMAC, }, - [CRYPTO_MD5_KPDK] = { plain(md5-kpdk), SW_TYPE_HASH, }, - [CRYPTO_SHA1_KPDK] = { plain(sha1-kpdk), SW_TYPE_HASH, }, - [CRYPTO_AES_CBC] = { cbc(aes), SW_TYPE_BLKCIPHER, }, - [CRYPTO_ARC4] = { ecb(arc4), SW_TYPE_BLKCIPHER, }, - [CRYPTO_MD5] = { plain(md5), SW_TYPE_HASH, }, - [CRYPTO_SHA1] = { plain(sha1), SW_TYPE_HASH, }, - [CRYPTO_NULL_HMAC] = { hmac(digest_null), SW_TYPE_HMAC, }, - [CRYPTO_NULL_CBC] = { cbc(cipher_null), SW_TYPE_BLKCIPHER, }, - [CRYPTO_DEFLATE_COMP] = { plain(deflate), SW_TYPE_COMP, }, - [CRYPTO_SHA2_256_HMAC] = { hmac(sha256), SW_TYPE_HMAC, }, - [CRYPTO_SHA2_384_HMAC] = { hmac(sha384), SW_TYPE_HMAC, }, - [CRYPTO_SHA2_512_HMAC] = { hmac(sha512), SW_TYPE_HMAC, }, - [CRYPTO_CAMELLIA_CBC] = { cbc(camellia), SW_TYPE_BLKCIPHER, }, - [CRYPTO_SHA2_256] = { plain(sha256), SW_TYPE_HASH, }, - [CRYPTO_SHA2_384] = { plain(sha384), SW_TYPE_HASH, }, - [CRYPTO_SHA2_512] = { plain(sha512), SW_TYPE_HASH, }, - [CRYPTO_RIPEMD160] = { plain(ripemd160), SW_TYPE_HASH, }, -}; - -int32_t swcr_id = -1; -module_param(swcr_id, int, 0444); -MODULE_PARM_DESC(swcr_id, "Read-Only OCF ID for cryptosoft driver"); - -int swcr_fail_if_compression_grows = 1; -module_param(swcr_fail_if_compression_grows, int, 0644); -MODULE_PARM_DESC(swcr_fail_if_compression_grows, - "Treat compression that results in more data as a failure"); - -int swcr_no_ahash = 0; -module_param(swcr_no_ahash, int, 0644); -MODULE_PARM_DESC(swcr_no_ahash, - "Do not use async hash/hmac even if available"); - -int swcr_no_ablk = 0; -module_param(swcr_no_ablk, int, 0644); -MODULE_PARM_DESC(swcr_no_ablk, - "Do not use async blk ciphers even if available"); - -static struct swcr_data **swcr_sessions = NULL; -static u_int32_t swcr_sesnum = 0; - -static int swcr_process(device_t, struct cryptop *, int); -static int swcr_newsession(device_t, u_int32_t *, struct cryptoini *); -static int swcr_freesession(device_t, u_int64_t); - -static device_method_t swcr_methods = { - /* crypto device methods */ - DEVMETHOD(cryptodev_newsession, swcr_newsession), - DEVMETHOD(cryptodev_freesession,swcr_freesession), - DEVMETHOD(cryptodev_process, swcr_process), -}; - -#define debug swcr_debug -int swcr_debug = 0; -module_param(swcr_debug, int, 0644); -MODULE_PARM_DESC(swcr_debug, "Enable debug"); - -static void swcr_process_req(struct swcr_req *req); - -/* - * Generate a new software session. - */ -static int -swcr_newsession(device_t dev, u_int32_t *sid, struct cryptoini *cri) -{ - struct swcr_data **swd; - u_int32_t i; - int error; - char *algo; - int mode; - - dprintk("%s()\n", __FUNCTION__); - if (sid == NULL || cri == NULL) { - dprintk("%s,%d - EINVAL\n", __FILE__, __LINE__); - return EINVAL; - } - - if (swcr_sessions) { - for (i = 1; i < swcr_sesnum; i++) - if (swcr_sessions[i] == NULL) - break; - } else - i = 1; /* NB: to silence compiler warning */ - - if (swcr_sessions == NULL || i == swcr_sesnum) { - if (swcr_sessions == NULL) { - i = 1; /* We leave swcr_sessions[0] empty */ - swcr_sesnum = CRYPTO_SW_SESSIONS; - } else - swcr_sesnum *= 2; - - swd = kmalloc(swcr_sesnum * sizeof(struct swcr_data *), SLAB_ATOMIC); - if (swd == NULL) { - /* Reset session number */ - if (swcr_sesnum == CRYPTO_SW_SESSIONS) - swcr_sesnum = 0; - else - swcr_sesnum /= 2; - dprintk("%s,%d: ENOBUFS\n", __FILE__, __LINE__); - return ENOBUFS; - } - memset(swd, 0, swcr_sesnum * sizeof(struct swcr_data *)); - - /* Copy existing sessions */ - if (swcr_sessions) { - memcpy(swd, swcr_sessions, - (swcr_sesnum / 2) * sizeof(struct swcr_data *)); - kfree(swcr_sessions); - } - - swcr_sessions = swd; - } - - swd = &swcr_sessions[i]; - *sid = i; - - while (cri) { - *swd = (struct swcr_data *) kmalloc(sizeof(struct swcr_data), - SLAB_ATOMIC); - if (*swd == NULL) { - swcr_freesession(NULL, i); - dprintk("%s,%d: ENOBUFS\n", __FILE__, __LINE__); - return ENOBUFS; - } - memset(*swd, 0, sizeof(struct swcr_data)); - - if (cri->cri_alg < 0 || - cri->cri_alg>=sizeof(crypto_details)/sizeof(crypto_details[0])){ - printk("cryptosoft: Unknown algorithm 0x%x\n", cri->cri_alg); - swcr_freesession(NULL, i); - return EINVAL; - } - - algo = crypto_details[cri->cri_alg].alg_name; - if (!algo || !*algo) { - printk("cryptosoft: Unsupported algorithm 0x%x\n", cri->cri_alg); - swcr_freesession(NULL, i); - return EINVAL; - } - - mode = crypto_details[cri->cri_alg].mode; - (*swd)->sw_type = crypto_details[cri->cri_alg].sw_type; - (*swd)->sw_alg = cri->cri_alg; - - /* Algorithm specific configuration */ - switch (cri->cri_alg) { - case CRYPTO_NULL_CBC: - cri->cri_klen = 0; /* make it work with crypto API */ - break; - default: - break; - } - - if ((*swd)->sw_type & SW_TYPE_BLKCIPHER) { - dprintk("%s crypto_alloc_*blkcipher(%s, 0x%x)\n", __FUNCTION__, - algo, mode); - - /* try async first */ - (*swd)->sw_tfm = swcr_no_ablk ? NULL : - crypto_ablkcipher_tfm(crypto_alloc_ablkcipher(algo, 0, 0)); - if ((*swd)->sw_tfm) { - dprintk("%s %s cipher is async\n", __FUNCTION__, algo); - (*swd)->sw_type |= SW_TYPE_ASYNC; - } else { - dprintk("%s %s cipher is sync\n", __FUNCTION__, algo); - (*swd)->sw_tfm = crypto_blkcipher_tfm( - crypto_alloc_blkcipher(algo, 0, CRYPTO_ALG_ASYNC)); - } - if (!(*swd)->sw_tfm) { - dprintk("cryptosoft: crypto_alloc_blkcipher failed(%s, 0x%x)\n", - algo,mode); - swcr_freesession(NULL, i); - return EINVAL; - } - - if (debug) { - dprintk("%s key:cri->cri_klen=%d,(cri->cri_klen + 7)/8=%d", - __FUNCTION__, cri->cri_klen, (cri->cri_klen + 7) / 8); - for (i = 0; i < (cri->cri_klen + 7) / 8; i++) - dprintk("%s0x%x", (i % 8) ? " " : "\n ", - cri->cri_key[i] & 0xff); - dprintk("\n"); - } - if ((*swd)->sw_type & SW_TYPE_ASYNC) { - /* OCF doesn't enforce keys */ - crypto_ablkcipher_set_flags( - __crypto_ablkcipher_cast((*swd)->sw_tfm), - CRYPTO_TFM_REQ_WEAK_KEY); - error = crypto_ablkcipher_setkey( - __crypto_ablkcipher_cast((*swd)->sw_tfm), - cri->cri_key, (cri->cri_klen + 7) / 8); - } else { - /* OCF doesn't enforce keys */ - crypto_blkcipher_set_flags( - crypto_blkcipher_cast((*swd)->sw_tfm), - CRYPTO_TFM_REQ_WEAK_KEY); - error = crypto_blkcipher_setkey( - crypto_blkcipher_cast((*swd)->sw_tfm), - cri->cri_key, (cri->cri_klen + 7) / 8); - } - if (error) { - printk("cryptosoft: setkey failed %d (crt_flags=0x%x)\n", error, - (*swd)->sw_tfm->crt_flags); - swcr_freesession(NULL, i); - return error; - } - } else if ((*swd)->sw_type & (SW_TYPE_HMAC | SW_TYPE_HASH)) { - dprintk("%s crypto_alloc_*hash(%s, 0x%x)\n", __FUNCTION__, - algo, mode); - - /* try async first */ - (*swd)->sw_tfm = swcr_no_ahash ? NULL : - crypto_ahash_tfm(crypto_alloc_ahash(algo, 0, 0)); - if ((*swd)->sw_tfm) { - dprintk("%s %s hash is async\n", __FUNCTION__, algo); - (*swd)->sw_type |= SW_TYPE_ASYNC; - } else { - dprintk("%s %s hash is sync\n", __FUNCTION__, algo); - (*swd)->sw_tfm = crypto_hash_tfm( - crypto_alloc_hash(algo, 0, CRYPTO_ALG_ASYNC)); - } - - if (!(*swd)->sw_tfm) { - dprintk("cryptosoft: crypto_alloc_hash failed(%s,0x%x)\n", - algo, mode); - swcr_freesession(NULL, i); - return EINVAL; - } - - (*swd)->u.hmac.sw_klen = (cri->cri_klen + 7) / 8; - (*swd)->u.hmac.sw_key = (char *)kmalloc((*swd)->u.hmac.sw_klen, - SLAB_ATOMIC); - if ((*swd)->u.hmac.sw_key == NULL) { - swcr_freesession(NULL, i); - dprintk("%s,%d: ENOBUFS\n", __FILE__, __LINE__); - return ENOBUFS; - } - memcpy((*swd)->u.hmac.sw_key, cri->cri_key, (*swd)->u.hmac.sw_klen); - if (cri->cri_mlen) { - (*swd)->u.hmac.sw_mlen = cri->cri_mlen; - } else if ((*swd)->sw_type & SW_TYPE_ASYNC) { - (*swd)->u.hmac.sw_mlen = crypto_ahash_digestsize( - __crypto_ahash_cast((*swd)->sw_tfm)); - } else { - (*swd)->u.hmac.sw_mlen = crypto_hash_digestsize( - crypto_hash_cast((*swd)->sw_tfm)); - } - } else if ((*swd)->sw_type & SW_TYPE_COMP) { - (*swd)->sw_tfm = crypto_comp_tfm( - crypto_alloc_comp(algo, 0, CRYPTO_ALG_ASYNC)); - if (!(*swd)->sw_tfm) { - dprintk("cryptosoft: crypto_alloc_comp failed(%s,0x%x)\n", - algo, mode); - swcr_freesession(NULL, i); - return EINVAL; - } - (*swd)->u.sw_comp_buf = kmalloc(CRYPTO_MAX_DATA_LEN, SLAB_ATOMIC); - if ((*swd)->u.sw_comp_buf == NULL) { - swcr_freesession(NULL, i); - dprintk("%s,%d: ENOBUFS\n", __FILE__, __LINE__); - return ENOBUFS; - } - } else { - printk("cryptosoft: Unhandled sw_type %d\n", (*swd)->sw_type); - swcr_freesession(NULL, i); - return EINVAL; - } - - cri = cri->cri_next; - swd = &((*swd)->sw_next); - } - return 0; -} - -/* - * Free a session. - */ -static int -swcr_freesession(device_t dev, u_int64_t tid) -{ - struct swcr_data *swd; - u_int32_t sid = CRYPTO_SESID2LID(tid); - - dprintk("%s()\n", __FUNCTION__); - if (sid > swcr_sesnum || swcr_sessions == NULL || - swcr_sessions[sid] == NULL) { - dprintk("%s,%d: EINVAL\n", __FILE__, __LINE__); - return(EINVAL); - } - - /* Silently accept and return */ - if (sid == 0) - return(0); - - while ((swd = swcr_sessions[sid]) != NULL) { - swcr_sessions[sid] = swd->sw_next; - if (swd->sw_tfm) { - switch (swd->sw_type & SW_TYPE_ALG_AMASK) { -#ifdef HAVE_AHASH - case SW_TYPE_AHMAC: - case SW_TYPE_AHASH: - crypto_free_ahash(__crypto_ahash_cast(swd->sw_tfm)); - break; -#endif -#ifdef HAVE_ABLKCIPHER - case SW_TYPE_ABLKCIPHER: - crypto_free_ablkcipher(__crypto_ablkcipher_cast(swd->sw_tfm)); - break; -#endif - case SW_TYPE_BLKCIPHER: - crypto_free_blkcipher(crypto_blkcipher_cast(swd->sw_tfm)); - break; - case SW_TYPE_HMAC: - case SW_TYPE_HASH: - crypto_free_hash(crypto_hash_cast(swd->sw_tfm)); - break; - case SW_TYPE_COMP: - crypto_free_comp(crypto_comp_cast(swd->sw_tfm)); - default: - crypto_free_tfm(swd->sw_tfm); - break; - } - swd->sw_tfm = NULL; - } - if (swd->sw_type & SW_TYPE_COMP) { - if (swd->u.sw_comp_buf) - kfree(swd->u.sw_comp_buf); - } else { - if (swd->u.hmac.sw_key) - kfree(swd->u.hmac.sw_key); - } - kfree(swd); - } - return 0; -} - -#if defined(HAVE_ABLKCIPHER) || defined(HAVE_AHASH) -/* older kernels had no async interface */ - -static void swcr_process_callback(struct crypto_async_request *creq, int err) -{ - struct swcr_req *req = creq->data; - - dprintk("%s()\n", __FUNCTION__); - if (err) { - if (err == -EINPROGRESS) - return; - dprintk("%s() fail %d\n", __FUNCTION__, -err); - req->crp->crp_etype = -err; - goto done; - } - - switch (req->sw->sw_type & SW_TYPE_ALG_AMASK) { - case SW_TYPE_AHMAC: - case SW_TYPE_AHASH: - crypto_copyback(req->crp->crp_flags, req->crp->crp_buf, - req->crd->crd_inject, req->sw->u.hmac.sw_mlen, req->result); - ahash_request_free(req->crypto_req); - break; - case SW_TYPE_ABLKCIPHER: - ablkcipher_request_free(req->crypto_req); - break; - default: - req->crp->crp_etype = EINVAL; - goto done; - } - - req->crd = req->crd->crd_next; - if (req->crd) { - swcr_process_req(req); - return; - } - -done: - dprintk("%s crypto_done %p\n", __FUNCTION__, req); - crypto_done(req->crp); - kmem_cache_free(swcr_req_cache, req); -} -#endif /* defined(HAVE_ABLKCIPHER) || defined(HAVE_AHASH) */ - - -static void swcr_process_req(struct swcr_req *req) -{ - struct swcr_data *sw; - struct cryptop *crp = req->crp; - struct cryptodesc *crd = req->crd; - struct sk_buff *skb = (struct sk_buff *) crp->crp_buf; - struct uio *uiop = (struct uio *) crp->crp_buf; - int sg_num, sg_len, skip; - - dprintk("%s()\n", __FUNCTION__); - - /* - * Find the crypto context. - * - * XXX Note that the logic here prevents us from having - * XXX the same algorithm multiple times in a session - * XXX (or rather, we can but it won't give us the right - * XXX results). To do that, we'd need some way of differentiating - * XXX between the various instances of an algorithm (so we can - * XXX locate the correct crypto context). - */ - for (sw = req->sw_head; sw && sw->sw_alg != crd->crd_alg; sw = sw->sw_next) - ; - - /* No such context ? */ - if (sw == NULL) { - crp->crp_etype = EINVAL; - dprintk("%s,%d: EINVAL\n", __FILE__, __LINE__); - goto done; - } - - req->sw = sw; - skip = crd->crd_skip; - - /* - * setup the SG list skip from the start of the buffer - */ - memset(req->sg, 0, sizeof(req->sg)); - sg_init_table(req->sg, SCATTERLIST_MAX); - if (crp->crp_flags & CRYPTO_F_SKBUF) { - int i, len; - - sg_num = 0; - sg_len = 0; - - if (skip < skb_headlen(skb)) { - len = skb_headlen(skb) - skip; - if (len + sg_len > crd->crd_len) - len = crd->crd_len - sg_len; - sg_set_page(&req->sg[sg_num], - virt_to_page(skb->data + skip), len, - offset_in_page(skb->data + skip)); - sg_len += len; - sg_num++; - skip = 0; - } else - skip -= skb_headlen(skb); - - for (i = 0; sg_len < crd->crd_len && - i < skb_shinfo(skb)->nr_frags && - sg_num < SCATTERLIST_MAX; i++) { - if (skip < skb_shinfo(skb)->frags[i].size) { - len = skb_shinfo(skb)->frags[i].size - skip; - if (len + sg_len > crd->crd_len) - len = crd->crd_len - sg_len; - sg_set_page(&req->sg[sg_num], - skb_shinfo(skb)->frags[i].page, - len, - skb_shinfo(skb)->frags[i].page_offset + skip); - sg_len += len; - sg_num++; - skip = 0; - } else - skip -= skb_shinfo(skb)->frags[i].size; - } - } else if (crp->crp_flags & CRYPTO_F_IOV) { - int len; - - sg_len = 0; - for (sg_num = 0; sg_len < crd->crd_len && - sg_num < uiop->uio_iovcnt && - sg_num < SCATTERLIST_MAX; sg_num++) { - if (skip <= uiop->uio_iov[sg_num].iov_len) { - len = uiop->uio_iov[sg_num].iov_len - skip; - if (len + sg_len > crd->crd_len) - len = crd->crd_len - sg_len; - sg_set_page(&req->sg[sg_num], - virt_to_page(uiop->uio_iov[sg_num].iov_base+skip), - len, - offset_in_page(uiop->uio_iov[sg_num].iov_base+skip)); - sg_len += len; - skip = 0; - } else - skip -= uiop->uio_iov[sg_num].iov_len; - } - } else { - sg_len = (crp->crp_ilen - skip); - if (sg_len > crd->crd_len) - sg_len = crd->crd_len; - sg_set_page(&req->sg[0], virt_to_page(crp->crp_buf + skip), - sg_len, offset_in_page(crp->crp_buf + skip)); - sg_num = 1; - } - - switch (sw->sw_type & SW_TYPE_ALG_AMASK) { - -#ifdef HAVE_AHASH - case SW_TYPE_AHMAC: - case SW_TYPE_AHASH: - { - int ret; - - /* check we have room for the result */ - if (crp->crp_ilen - crd->crd_inject < sw->u.hmac.sw_mlen) { - dprintk("cryptosoft: EINVAL crp_ilen=%d, len=%d, inject=%d " - "digestsize=%d\n", crp->crp_ilen, crd->crd_skip + sg_len, - crd->crd_inject, sw->u.hmac.sw_mlen); - crp->crp_etype = EINVAL; - goto done; - } - - req->crypto_req = - ahash_request_alloc(__crypto_ahash_cast(sw->sw_tfm),GFP_KERNEL); - if (!req->crypto_req) { - crp->crp_etype = ENOMEM; - dprintk("%s,%d: ENOMEM ahash_request_alloc", __FILE__, __LINE__); - goto done; - } - - ahash_request_set_callback(req->crypto_req, - CRYPTO_TFM_REQ_MAY_BACKLOG, swcr_process_callback, req); - - memset(req->result, 0, sizeof(req->result)); - - if (sw->sw_type & SW_TYPE_AHMAC) - crypto_ahash_setkey(__crypto_ahash_cast(sw->sw_tfm), - sw->u.hmac.sw_key, sw->u.hmac.sw_klen); - ahash_request_set_crypt(req->crypto_req, req->sg, req->result, sg_len); - ret = crypto_ahash_digest(req->crypto_req); - switch (ret) { - case -EINPROGRESS: - case -EBUSY: - return; - default: - case 0: - dprintk("hash OP %s %d\n", ret ? "failed" : "success", ret); - crp->crp_etype = ret; - ahash_request_free(req->crypto_req); - goto done; - } - } break; -#endif /* HAVE_AHASH */ - -#ifdef HAVE_ABLKCIPHER - case SW_TYPE_ABLKCIPHER: { - int ret; - unsigned char *ivp = req->iv; - int ivsize = - crypto_ablkcipher_ivsize(__crypto_ablkcipher_cast(sw->sw_tfm)); - - if (sg_len < crypto_ablkcipher_blocksize( - __crypto_ablkcipher_cast(sw->sw_tfm))) { - crp->crp_etype = EINVAL; - dprintk("%s,%d: EINVAL len %d < %d\n", __FILE__, __LINE__, - sg_len, crypto_ablkcipher_blocksize( - __crypto_ablkcipher_cast(sw->sw_tfm))); - goto done; - } - - if (ivsize > sizeof(req->iv)) { - crp->crp_etype = EINVAL; - dprintk("%s,%d: EINVAL\n", __FILE__, __LINE__); - goto done; - } - - req->crypto_req = ablkcipher_request_alloc( - __crypto_ablkcipher_cast(sw->sw_tfm), GFP_KERNEL); - if (!req->crypto_req) { - crp->crp_etype = ENOMEM; - dprintk("%s,%d: ENOMEM ablkcipher_request_alloc", - __FILE__, __LINE__); - goto done; - } - - ablkcipher_request_set_callback(req->crypto_req, - CRYPTO_TFM_REQ_MAY_BACKLOG, swcr_process_callback, req); - - if (crd->crd_flags & CRD_F_KEY_EXPLICIT) { - int i, error; - - if (debug) { - dprintk("%s key:", __FUNCTION__); - for (i = 0; i < (crd->crd_klen + 7) / 8; i++) - dprintk("%s0x%x", (i % 8) ? " " : "\n ", - crd->crd_key[i] & 0xff); - dprintk("\n"); - } - /* OCF doesn't enforce keys */ - crypto_ablkcipher_set_flags(__crypto_ablkcipher_cast(sw->sw_tfm), - CRYPTO_TFM_REQ_WEAK_KEY); - error = crypto_ablkcipher_setkey( - __crypto_ablkcipher_cast(sw->sw_tfm), crd->crd_key, - (crd->crd_klen + 7) / 8); - if (error) { - dprintk("cryptosoft: setkey failed %d (crt_flags=0x%x)\n", - error, sw->sw_tfm->crt_flags); - crp->crp_etype = -error; - } - } - - if (crd->crd_flags & CRD_F_ENCRYPT) { /* encrypt */ - - if (crd->crd_flags & CRD_F_IV_EXPLICIT) - ivp = crd->crd_iv; - else - get_random_bytes(ivp, ivsize); - /* - * do we have to copy the IV back to the buffer ? - */ - if ((crd->crd_flags & CRD_F_IV_PRESENT) == 0) { - crypto_copyback(crp->crp_flags, crp->crp_buf, - crd->crd_inject, ivsize, (caddr_t)ivp); - } - ablkcipher_request_set_crypt(req->crypto_req, req->sg, req->sg, - sg_len, ivp); - ret = crypto_ablkcipher_encrypt(req->crypto_req); - - } else { /*decrypt */ - - if (crd->crd_flags & CRD_F_IV_EXPLICIT) - ivp = crd->crd_iv; - else - crypto_copydata(crp->crp_flags, crp->crp_buf, - crd->crd_inject, ivsize, (caddr_t)ivp); - ablkcipher_request_set_crypt(req->crypto_req, req->sg, req->sg, - sg_len, ivp); - ret = crypto_ablkcipher_decrypt(req->crypto_req); - } - - switch (ret) { - case -EINPROGRESS: - case -EBUSY: - return; - default: - case 0: - dprintk("crypto OP %s %d\n", ret ? "failed" : "success", ret); - crp->crp_etype = ret; - goto done; - } - } break; -#endif /* HAVE_ABLKCIPHER */ - - case SW_TYPE_BLKCIPHER: { - unsigned char iv[EALG_MAX_BLOCK_LEN]; - unsigned char *ivp = iv; - struct blkcipher_desc desc; - int ivsize = crypto_blkcipher_ivsize(crypto_blkcipher_cast(sw->sw_tfm)); - - if (sg_len < crypto_blkcipher_blocksize( - crypto_blkcipher_cast(sw->sw_tfm))) { - crp->crp_etype = EINVAL; - dprintk("%s,%d: EINVAL len %d < %d\n", __FILE__, __LINE__, - sg_len, crypto_blkcipher_blocksize( - crypto_blkcipher_cast(sw->sw_tfm))); - goto done; - } - - if (ivsize > sizeof(iv)) { - crp->crp_etype = EINVAL; - dprintk("%s,%d: EINVAL\n", __FILE__, __LINE__); - goto done; - } - - if (crd->crd_flags & CRD_F_KEY_EXPLICIT) { - int i, error; - - if (debug) { - dprintk("%s key:", __FUNCTION__); - for (i = 0; i < (crd->crd_klen + 7) / 8; i++) - dprintk("%s0x%x", (i % 8) ? " " : "\n ", - crd->crd_key[i] & 0xff); - dprintk("\n"); - } - /* OCF doesn't enforce keys */ - crypto_blkcipher_set_flags(crypto_blkcipher_cast(sw->sw_tfm), - CRYPTO_TFM_REQ_WEAK_KEY); - error = crypto_blkcipher_setkey( - crypto_blkcipher_cast(sw->sw_tfm), crd->crd_key, - (crd->crd_klen + 7) / 8); - if (error) { - dprintk("cryptosoft: setkey failed %d (crt_flags=0x%x)\n", - error, sw->sw_tfm->crt_flags); - crp->crp_etype = -error; - } - } - - memset(&desc, 0, sizeof(desc)); - desc.tfm = crypto_blkcipher_cast(sw->sw_tfm); - - if (crd->crd_flags & CRD_F_ENCRYPT) { /* encrypt */ - - if (crd->crd_flags & CRD_F_IV_EXPLICIT) { - ivp = crd->crd_iv; - } else { - get_random_bytes(ivp, ivsize); - } - /* - * do we have to copy the IV back to the buffer ? - */ - if ((crd->crd_flags & CRD_F_IV_PRESENT) == 0) { - crypto_copyback(crp->crp_flags, crp->crp_buf, - crd->crd_inject, ivsize, (caddr_t)ivp); - } - desc.info = ivp; - crypto_blkcipher_encrypt_iv(&desc, req->sg, req->sg, sg_len); - - } else { /*decrypt */ - - if (crd->crd_flags & CRD_F_IV_EXPLICIT) { - ivp = crd->crd_iv; - } else { - crypto_copydata(crp->crp_flags, crp->crp_buf, - crd->crd_inject, ivsize, (caddr_t)ivp); - } - desc.info = ivp; - crypto_blkcipher_decrypt_iv(&desc, req->sg, req->sg, sg_len); - } - } break; - - case SW_TYPE_HMAC: - case SW_TYPE_HASH: - { - char result[HASH_MAX_LEN]; - struct hash_desc desc; - - /* check we have room for the result */ - if (crp->crp_ilen - crd->crd_inject < sw->u.hmac.sw_mlen) { - dprintk("cryptosoft: EINVAL crp_ilen=%d, len=%d, inject=%d " - "digestsize=%d\n", crp->crp_ilen, crd->crd_skip + sg_len, - crd->crd_inject, sw->u.hmac.sw_mlen); - crp->crp_etype = EINVAL; - goto done; - } - - memset(&desc, 0, sizeof(desc)); - desc.tfm = crypto_hash_cast(sw->sw_tfm); - - memset(result, 0, sizeof(result)); - - if (sw->sw_type & SW_TYPE_HMAC) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) - crypto_hmac(sw->sw_tfm, sw->u.hmac.sw_key, &sw->u.hmac.sw_klen, - req->sg, sg_num, result); -#else - crypto_hash_setkey(desc.tfm, sw->u.hmac.sw_key, - sw->u.hmac.sw_klen); - crypto_hash_digest(&desc, req->sg, sg_len, result); -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) */ - - } else { /* SW_TYPE_HASH */ - crypto_hash_digest(&desc, req->sg, sg_len, result); - } - - crypto_copyback(crp->crp_flags, crp->crp_buf, - crd->crd_inject, sw->u.hmac.sw_mlen, result); - } - break; - - case SW_TYPE_COMP: { - void *ibuf = NULL; - void *obuf = sw->u.sw_comp_buf; - int ilen = sg_len, olen = CRYPTO_MAX_DATA_LEN; - int ret = 0; - - /* - * we need to use an additional copy if there is more than one - * input chunk since the kernel comp routines do not handle - * SG yet. Otherwise we just use the input buffer as is. - * Rather than allocate another buffer we just split the tmp - * buffer we already have. - * Perhaps we should just use zlib directly ? - */ - if (sg_num > 1) { - int blk; - - ibuf = obuf; - for (blk = 0; blk < sg_num; blk++) { - memcpy(obuf, sg_virt(&req->sg[blk]), - req->sg[blk].length); - obuf += req->sg[blk].length; - } - olen -= sg_len; - } else - ibuf = sg_virt(&req->sg[0]); - - if (crd->crd_flags & CRD_F_ENCRYPT) { /* compress */ - ret = crypto_comp_compress(crypto_comp_cast(sw->sw_tfm), - ibuf, ilen, obuf, &olen); - if (!ret && olen > crd->crd_len) { - dprintk("cryptosoft: ERANGE compress %d into %d\n", - crd->crd_len, olen); - if (swcr_fail_if_compression_grows) - ret = ERANGE; - } - } else { /* decompress */ - ret = crypto_comp_decompress(crypto_comp_cast(sw->sw_tfm), - ibuf, ilen, obuf, &olen); - if (!ret && (olen + crd->crd_inject) > crp->crp_olen) { - dprintk("cryptosoft: ETOOSMALL decompress %d into %d, " - "space for %d,at offset %d\n", - crd->crd_len, olen, crp->crp_olen, crd->crd_inject); - ret = ETOOSMALL; - } - } - if (ret) - dprintk("%s,%d: ret = %d\n", __FILE__, __LINE__, ret); - - /* - * on success copy result back, - * linux crpyto API returns -errno, we need to fix that - */ - crp->crp_etype = ret < 0 ? -ret : ret; - if (ret == 0) { - /* copy back the result and return it's size */ - crypto_copyback(crp->crp_flags, crp->crp_buf, - crd->crd_inject, olen, obuf); - crp->crp_olen = olen; - } - - - } break; - - default: - /* Unknown/unsupported algorithm */ - dprintk("%s,%d: EINVAL\n", __FILE__, __LINE__); - crp->crp_etype = EINVAL; - goto done; - } - -done: - crypto_done(crp); - kmem_cache_free(swcr_req_cache, req); -} - - -/* - * Process a crypto request. - */ -static int -swcr_process(device_t dev, struct cryptop *crp, int hint) -{ - struct swcr_req *req = NULL; - u_int32_t lid; - - dprintk("%s()\n", __FUNCTION__); - /* Sanity check */ - if (crp == NULL) { - dprintk("%s,%d: EINVAL\n", __FILE__, __LINE__); - return EINVAL; - } - - crp->crp_etype = 0; - - if (crp->crp_desc == NULL || crp->crp_buf == NULL) { - dprintk("%s,%d: EINVAL\n", __FILE__, __LINE__); - crp->crp_etype = EINVAL; - goto done; - } - - lid = crp->crp_sid & 0xffffffff; - if (lid >= swcr_sesnum || lid == 0 || swcr_sessions == NULL || - swcr_sessions[lid] == NULL) { - crp->crp_etype = ENOENT; - dprintk("%s,%d: ENOENT\n", __FILE__, __LINE__); - goto done; - } - - /* - * do some error checking outside of the loop for SKB and IOV processing - * this leaves us with valid skb or uiop pointers for later - */ - if (crp->crp_flags & CRYPTO_F_SKBUF) { - struct sk_buff *skb = (struct sk_buff *) crp->crp_buf; - if (skb_shinfo(skb)->nr_frags >= SCATTERLIST_MAX) { - printk("%s,%d: %d nr_frags > SCATTERLIST_MAX", __FILE__, __LINE__, - skb_shinfo(skb)->nr_frags); - goto done; - } - } else if (crp->crp_flags & CRYPTO_F_IOV) { - struct uio *uiop = (struct uio *) crp->crp_buf; - if (uiop->uio_iovcnt > SCATTERLIST_MAX) { - printk("%s,%d: %d uio_iovcnt > SCATTERLIST_MAX", __FILE__, __LINE__, - uiop->uio_iovcnt); - goto done; - } - } - - /* - * setup a new request ready for queuing - */ - req = kmem_cache_alloc(swcr_req_cache, SLAB_ATOMIC); - if (req == NULL) { - dprintk("%s,%d: ENOMEM\n", __FILE__, __LINE__); - crp->crp_etype = ENOMEM; - goto done; - } - memset(req, 0, sizeof(*req)); - - req->sw_head = swcr_sessions[lid]; - req->crp = crp; - req->crd = crp->crp_desc; - - swcr_process_req(req); - return 0; - -done: - crypto_done(crp); - if (req) - kmem_cache_free(swcr_req_cache, req); - return 0; -} - - -static int -cryptosoft_init(void) -{ - int i, sw_type, mode; - char *algo; - - dprintk("%s(%p)\n", __FUNCTION__, cryptosoft_init); - - swcr_req_cache = kmem_cache_create("cryptosoft_req", - sizeof(struct swcr_req), 0, SLAB_HWCACHE_ALIGN, NULL -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23) - , NULL -#endif - ); - if (!swcr_req_cache) { - printk("cryptosoft: failed to create request cache\n"); - return -ENOENT; - } - - softc_device_init(&swcr_softc, "cryptosoft", 0, swcr_methods); - - swcr_id = crypto_get_driverid(softc_get_device(&swcr_softc), - CRYPTOCAP_F_SOFTWARE | CRYPTOCAP_F_SYNC); - if (swcr_id < 0) { - printk("cryptosoft: Software crypto device cannot initialize!"); - return -ENODEV; - } - -#define REGISTER(alg) \ - crypto_register(swcr_id, alg, 0,0) - - for (i = 0; i < sizeof(crypto_details)/sizeof(crypto_details[0]); i++) { - int found; - - algo = crypto_details[i].alg_name; - if (!algo || !*algo) { - dprintk("%s:Algorithm %d not supported\n", __FUNCTION__, i); - continue; - } - - mode = crypto_details[i].mode; - sw_type = crypto_details[i].sw_type; - - found = 0; - switch (sw_type & SW_TYPE_ALG_MASK) { - case SW_TYPE_CIPHER: - found = crypto_has_cipher(algo, 0, CRYPTO_ALG_ASYNC); - break; - case SW_TYPE_HMAC: - found = crypto_has_hash(algo, 0, swcr_no_ahash?CRYPTO_ALG_ASYNC:0); - break; - case SW_TYPE_HASH: - found = crypto_has_hash(algo, 0, swcr_no_ahash?CRYPTO_ALG_ASYNC:0); - break; - case SW_TYPE_COMP: - found = crypto_has_comp(algo, 0, CRYPTO_ALG_ASYNC); - break; - case SW_TYPE_BLKCIPHER: - found = crypto_has_blkcipher(algo, 0, CRYPTO_ALG_ASYNC); - if (!found && !swcr_no_ablk) - found = crypto_has_ablkcipher(algo, 0, 0); - break; - } - if (found) { - REGISTER(i); - } else { - dprintk("%s:Algorithm Type %d not supported (algorithm %d:'%s')\n", - __FUNCTION__, sw_type, i, algo); - } - } - return 0; -} - -static void -cryptosoft_exit(void) -{ - dprintk("%s()\n", __FUNCTION__); - crypto_unregister_all(swcr_id); - swcr_id = -1; - kmem_cache_destroy(swcr_req_cache); -} - -late_initcall(cryptosoft_init); -module_exit(cryptosoft_exit); - -MODULE_LICENSE("Dual BSD/GPL"); -MODULE_AUTHOR("David McCullough <david_mccullough@securecomputing.com>"); -MODULE_DESCRIPTION("Cryptosoft (OCF module for kernel crypto)"); diff --git a/target/linux/generic-2.4/files/crypto/ocf/ep80579/Makefile b/target/linux/generic-2.4/files/crypto/ocf/ep80579/Makefile deleted file mode 100644 index 9aab295..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/ep80579/Makefile +++ /dev/null @@ -1,119 +0,0 @@ -######################################################################### -# -# Targets supported -# all - builds everything and installs -# install - identical to all -# depend - build dependencies -# clean - clears derived objects except the .depend files -# distclean- clears all derived objects and the .depend file -# -# @par -# This file is provided under a dual BSD/GPLv2 license. When using or -# redistributing this file, you may do so under either license. -# -# GPL LICENSE SUMMARY -# -# Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of version 2 of the GNU General Public License as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. -# The full GNU General Public License is included in this distribution -# in the file called LICENSE.GPL. -# -# Contact Information: -# Intel Corporation -# -# BSD LICENSE -# -# Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Intel Corporation nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# -# version: Security.L.1.0.2-229 -############################################################################ - - -####################Common variables and definitions######################## - -ifndef ICP_ROOT -$(warning ICP_ROOT is undefined. Please set the path to EP80579 release package directory \ - "-> setenv ICP_ROOT <path>") -all fastdep: - : -else - -ifndef KERNEL_SOURCE_ROOT -$(error KERNEL_SOURCE_ROOT is undefined. Please set the path to the kernel source directory \ - "-> setenv KERNEL_SOURCE_ROOT <path>") -endif - -# Ensure The ENV_DIR environmental var is defined. -ifndef ICP_ENV_DIR -$(error ICP_ENV_DIR is undefined. Please set the path to EP80579 driver environment.mk file \ - "-> setenv ICP_ENV_DIR <path>") -endif - -#Add your project environment Makefile -include ${ICP_ENV_DIR}/environment.mk - -#include the makefile with all the default and common Make variable definitions -include ${ICP_BUILDSYSTEM_PATH}/build_files/common.mk - -#Add the name for the executable, Library or Module output definitions -OUTPUT_NAME= icp_ocf - -# List of Source Files to be compiled -SOURCES= icp_common.c icp_sym.c icp_asym.c icp_ocf_linux.c - -#common includes between all supported OSes -INCLUDES= -I ${ICP_API_DIR} -I${ICP_LAC_API} \ --I${ICP_OCF_SRC_DIR} - -# The location of the os level makefile needs to be changed. -include ${ICP_ENV_DIR}/${ICP_OS}_${ICP_OS_LEVEL}.mk - -# On the line directly below list the outputs you wish to build for, -# e.g "lib_static lib_shared exe module" as shown below -install: module - -###################Include rules makefiles######################## -include ${ICP_BUILDSYSTEM_PATH}/build_files/rules.mk -###################End of Rules inclusion######################### - -endif diff --git a/target/linux/generic-2.4/files/crypto/ocf/ep80579/icp_asym.c b/target/linux/generic-2.4/files/crypto/ocf/ep80579/icp_asym.c deleted file mode 100644 index d2641c5..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/ep80579/icp_asym.c +++ /dev/null @@ -1,1334 +0,0 @@ -/*************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Corporation - * - * BSD LICENSE - * - * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - * version: Security.L.1.0.2-229 - * - ***************************************************************************/ - -#include "icp_ocf.h" - -/*The following define values (containing the word 'INDEX') are used to find -the index of each input buffer of the crypto_kop struct (see OCF cryptodev.h). -These values were found through analysis of the OCF OpenSSL patch. If the -calling program uses different input buffer positions, these defines will have -to be changed.*/ - -/*DIFFIE HELLMAN buffer index values*/ -#define ICP_DH_KRP_PARAM_PRIME_INDEX (0) -#define ICP_DH_KRP_PARAM_BASE_INDEX (1) -#define ICP_DH_KRP_PARAM_PRIVATE_VALUE_INDEX (2) -#define ICP_DH_KRP_PARAM_RESULT_INDEX (3) - -/*MOD EXP buffer index values*/ -#define ICP_MOD_EXP_KRP_PARAM_BASE_INDEX (0) -#define ICP_MOD_EXP_KRP_PARAM_EXPONENT_INDEX (1) -#define ICP_MOD_EXP_KRP_PARAM_MODULUS_INDEX (2) -#define ICP_MOD_EXP_KRP_PARAM_RESULT_INDEX (3) - -/*MOD EXP CRT buffer index values*/ -#define ICP_MOD_EXP_CRT_KRP_PARAM_PRIME_P_INDEX (0) -#define ICP_MOD_EXP_CRT_KRP_PARAM_PRIME_Q_INDEX (1) -#define ICP_MOD_EXP_CRT_KRP_PARAM_I_INDEX (2) -#define ICP_MOD_EXP_CRT_KRP_PARAM_EXPONENT_DP_INDEX (3) -#define ICP_MOD_EXP_CRT_KRP_PARAM_EXPONENT_DQ_INDEX (4) -#define ICP_MOD_EXP_CRT_KRP_PARAM_COEFF_QINV_INDEX (5) -#define ICP_MOD_EXP_CRT_KRP_PARAM_RESULT_INDEX (6) - -/*DSA sign buffer index values*/ -#define ICP_DSA_SIGN_KRP_PARAM_DGST_INDEX (0) -#define ICP_DSA_SIGN_KRP_PARAM_PRIME_P_INDEX (1) -#define ICP_DSA_SIGN_KRP_PARAM_PRIME_Q_INDEX (2) -#define ICP_DSA_SIGN_KRP_PARAM_G_INDEX (3) -#define ICP_DSA_SIGN_KRP_PARAM_X_INDEX (4) -#define ICP_DSA_SIGN_KRP_PARAM_R_RESULT_INDEX (5) -#define ICP_DSA_SIGN_KRP_PARAM_S_RESULT_INDEX (6) - -/*DSA verify buffer index values*/ -#define ICP_DSA_VERIFY_KRP_PARAM_DGST_INDEX (0) -#define ICP_DSA_VERIFY_KRP_PARAM_PRIME_P_INDEX (1) -#define ICP_DSA_VERIFY_KRP_PARAM_PRIME_Q_INDEX (2) -#define ICP_DSA_VERIFY_KRP_PARAM_G_INDEX (3) -#define ICP_DSA_VERIFY_KRP_PARAM_PUBKEY_INDEX (4) -#define ICP_DSA_VERIFY_KRP_PARAM_SIG_R_INDEX (5) -#define ICP_DSA_VERIFY_KRP_PARAM_SIG_S_INDEX (6) - -/*DSA sign prime Q vs random number K size check values*/ -#define DONT_RUN_LESS_THAN_CHECK (0) -#define FAIL_A_IS_GREATER_THAN_B (1) -#define FAIL_A_IS_EQUAL_TO_B (1) -#define SUCCESS_A_IS_LESS_THAN_B (0) -#define DSA_SIGN_RAND_GEN_VAL_CHECK_MAX_ITERATIONS (500) - -/* We need to set a cryptokp success value just in case it is set or allocated - and not set to zero outside of this module */ -#define CRYPTO_OP_SUCCESS (0) - -/*Function to compute Diffie Hellman (DH) phase 1 or phase 2 key values*/ -static int icp_ocfDrvDHComputeKey(struct cryptkop *krp); - -/*Function to compute a Modular Exponentiation (Mod Exp)*/ -static int icp_ocfDrvModExp(struct cryptkop *krp); - -/*Function to compute a Mod Exp using the Chinease Remainder Theorem*/ -static int icp_ocfDrvModExpCRT(struct cryptkop *krp); - -/*Helper function to compute whether the first big number argument is less than - the second big number argument */ -static int -icp_ocfDrvCheckALessThanB(CpaFlatBuffer * pK, CpaFlatBuffer * pQ, int *doCheck); - -/*Function to sign an input with DSA R and S keys*/ -static int icp_ocfDrvDsaSign(struct cryptkop *krp); - -/*Function to Verify a DSA buffer signature*/ -static int icp_ocfDrvDsaVerify(struct cryptkop *krp); - -/*Callback function for DH operation*/ -static void -icp_ocfDrvDhP1CallBack(void *callbackTag, - CpaStatus status, - void *pOpData, CpaFlatBuffer * pLocalOctetStringPV); - -/*Callback function for ME operation*/ -static void -icp_ocfDrvModExpCallBack(void *callbackTag, - CpaStatus status, - void *pOpData, CpaFlatBuffer * pResult); - -/*Callback function for ME CRT operation*/ -static void -icp_ocfDrvModExpCRTCallBack(void *callbackTag, - CpaStatus status, - void *pOpData, CpaFlatBuffer * pOutputData); - -/*Callback function for DSA sign operation*/ -static void -icp_ocfDrvDsaRSSignCallBack(void *callbackTag, - CpaStatus status, - void *pOpData, - CpaBoolean protocolStatus, - CpaFlatBuffer * pR, CpaFlatBuffer * pS); - -/*Callback function for DSA Verify operation*/ -static void -icp_ocfDrvDsaVerifyCallBack(void *callbackTag, - CpaStatus status, - void *pOpData, CpaBoolean verifyStatus); - -/* Name : icp_ocfDrvPkeProcess - * - * Description : This function will choose which PKE process to follow - * based on the input arguments - */ -int icp_ocfDrvPkeProcess(icp_device_t dev, struct cryptkop *krp, int hint) -{ - CpaStatus lacStatus = CPA_STATUS_SUCCESS; - - if (NULL == krp) { - DPRINTK("%s(): Invalid input parameters, cryptkop = %p\n", - __FUNCTION__, krp); - return EINVAL; - } - - if (CPA_TRUE == icp_atomic_read(&icp_ocfDrvIsExiting)) { - krp->krp_status = ECANCELED; - return ECANCELED; - } - - switch (krp->krp_op) { - case CRK_DH_COMPUTE_KEY: - DPRINTK("%s() doing DH_COMPUTE_KEY\n", __FUNCTION__); - lacStatus = icp_ocfDrvDHComputeKey(krp); - if (CPA_STATUS_SUCCESS != lacStatus) { - EPRINTK("%s(): icp_ocfDrvDHComputeKey failed " - "(%d).\n", __FUNCTION__, lacStatus); - krp->krp_status = ECANCELED; - return ECANCELED; - } - - break; - - case CRK_MOD_EXP: - DPRINTK("%s() doing MOD_EXP \n", __FUNCTION__); - lacStatus = icp_ocfDrvModExp(krp); - if (CPA_STATUS_SUCCESS != lacStatus) { - EPRINTK("%s(): icp_ocfDrvModExp failed (%d).\n", - __FUNCTION__, lacStatus); - krp->krp_status = ECANCELED; - return ECANCELED; - } - - break; - - case CRK_MOD_EXP_CRT: - DPRINTK("%s() doing MOD_EXP_CRT \n", __FUNCTION__); - lacStatus = icp_ocfDrvModExpCRT(krp); - if (CPA_STATUS_SUCCESS != lacStatus) { - EPRINTK("%s(): icp_ocfDrvModExpCRT " - "failed (%d).\n", __FUNCTION__, lacStatus); - krp->krp_status = ECANCELED; - return ECANCELED; - } - - break; - - case CRK_DSA_SIGN: - DPRINTK("%s() doing DSA_SIGN \n", __FUNCTION__); - lacStatus = icp_ocfDrvDsaSign(krp); - if (CPA_STATUS_SUCCESS != lacStatus) { - EPRINTK("%s(): icp_ocfDrvDsaSign " - "failed (%d).\n", __FUNCTION__, lacStatus); - krp->krp_status = ECANCELED; - return ECANCELED; - } - - break; - - case CRK_DSA_VERIFY: - DPRINTK("%s() doing DSA_VERIFY \n", __FUNCTION__); - lacStatus = icp_ocfDrvDsaVerify(krp); - if (CPA_STATUS_SUCCESS != lacStatus) { - EPRINTK("%s(): icp_ocfDrvDsaVerify " - "failed (%d).\n", __FUNCTION__, lacStatus); - krp->krp_status = ECANCELED; - return ECANCELED; - } - - break; - - default: - EPRINTK("%s(): Asymettric function not " - "supported (%d).\n", __FUNCTION__, krp->krp_op); - krp->krp_status = EOPNOTSUPP; - return EOPNOTSUPP; - } - - return ICP_OCF_DRV_STATUS_SUCCESS; -} - -/* Name : icp_ocfDrvSwapBytes - * - * Description : This function is used to swap the byte order of a buffer. - * It has been seen that in general we are passed little endian byte order - * buffers, but LAC only accepts big endian byte order buffers. - */ -static void inline icp_ocfDrvSwapBytes(u_int8_t * num, u_int32_t buff_len_bytes) -{ - - int i; - u_int8_t *end_ptr; - u_int8_t hold_val; - - end_ptr = num + (buff_len_bytes - 1); - buff_len_bytes = buff_len_bytes >> 1; - for (i = 0; i < buff_len_bytes; i++) { - hold_val = *num; - *num = *end_ptr; - num++; - *end_ptr = hold_val; - end_ptr--; - } -} - -/* Name : icp_ocfDrvDHComputeKey - * - * Description : This function will map Diffie Hellman calls from OCF - * to the LAC API. OCF uses this function for Diffie Hellman Phase1 and - * Phase2. LAC has a separate Diffie Hellman Phase2 call, however both phases - * break down to a modular exponentiation. - */ -static int icp_ocfDrvDHComputeKey(struct cryptkop *krp) -{ - CpaStatus lacStatus = CPA_STATUS_SUCCESS; - void *callbackTag = NULL; - CpaCyDhPhase1KeyGenOpData *pPhase1OpData = NULL; - CpaFlatBuffer *pLocalOctetStringPV = NULL; - uint32_t dh_prime_len_bytes = 0, dh_prime_len_bits = 0; - - /* Input checks - check prime is a multiple of 8 bits to allow for - allocation later */ - dh_prime_len_bits = - (krp->krp_param[ICP_DH_KRP_PARAM_PRIME_INDEX].crp_nbits); - - /* LAC can reject prime lengths based on prime key sizes, we just - need to make sure we can allocate space for the base and - exponent buffers correctly */ - if ((dh_prime_len_bits % NUM_BITS_IN_BYTE) != 0) { - APRINTK("%s(): Warning Prime number buffer size is not a " - "multiple of 8 bits\n", __FUNCTION__); - } - - /* Result storage space should be the same size as the prime as this - value can take up the same amount of storage space */ - if (dh_prime_len_bits != - krp->krp_param[ICP_DH_KRP_PARAM_RESULT_INDEX].crp_nbits) { - DPRINTK("%s(): Return Buffer must be the same size " - "as the Prime buffer\n", __FUNCTION__); - krp->krp_status = EINVAL; - return EINVAL; - } - /* Switch to size in bytes */ - BITS_TO_BYTES(dh_prime_len_bytes, dh_prime_len_bits); - - callbackTag = krp; - -/*All allocations are set to ICP_M_NOWAIT due to the possibility of getting -called in interrupt context*/ - pPhase1OpData = icp_kmem_cache_zalloc(drvDH_zone, ICP_M_NOWAIT); - if (NULL == pPhase1OpData) { - APRINTK("%s():Failed to get memory for key gen data\n", - __FUNCTION__); - krp->krp_status = ENOMEM; - return ENOMEM; - } - - pLocalOctetStringPV = - icp_kmem_cache_zalloc(drvFlatBuffer_zone, ICP_M_NOWAIT); - if (NULL == pLocalOctetStringPV) { - APRINTK("%s():Failed to get memory for pLocalOctetStringPV\n", - __FUNCTION__); - ICP_CACHE_FREE(drvDH_zone, pPhase1OpData); - krp->krp_status = ENOMEM; - return ENOMEM; - } - - /* Link parameters */ - pPhase1OpData->primeP.pData = - krp->krp_param[ICP_DH_KRP_PARAM_PRIME_INDEX].crp_p; - - pPhase1OpData->primeP.dataLenInBytes = dh_prime_len_bytes; - - icp_ocfDrvSwapBytes(pPhase1OpData->primeP.pData, dh_prime_len_bytes); - - pPhase1OpData->baseG.pData = - krp->krp_param[ICP_DH_KRP_PARAM_BASE_INDEX].crp_p; - - BITS_TO_BYTES(pPhase1OpData->baseG.dataLenInBytes, - krp->krp_param[ICP_DH_KRP_PARAM_BASE_INDEX].crp_nbits); - - icp_ocfDrvSwapBytes(pPhase1OpData->baseG.pData, - pPhase1OpData->baseG.dataLenInBytes); - - pPhase1OpData->privateValueX.pData = - krp->krp_param[ICP_DH_KRP_PARAM_PRIVATE_VALUE_INDEX].crp_p; - - BITS_TO_BYTES(pPhase1OpData->privateValueX.dataLenInBytes, - krp->krp_param[ICP_DH_KRP_PARAM_PRIVATE_VALUE_INDEX]. - crp_nbits); - - icp_ocfDrvSwapBytes(pPhase1OpData->privateValueX.pData, - pPhase1OpData->privateValueX.dataLenInBytes); - - /* Output parameters */ - pLocalOctetStringPV->pData = - krp->krp_param[ICP_DH_KRP_PARAM_RESULT_INDEX].crp_p; - - BITS_TO_BYTES(pLocalOctetStringPV->dataLenInBytes, - krp->krp_param[ICP_DH_KRP_PARAM_RESULT_INDEX].crp_nbits); - - lacStatus = cpaCyDhKeyGenPhase1(CPA_INSTANCE_HANDLE_SINGLE, - icp_ocfDrvDhP1CallBack, - callbackTag, pPhase1OpData, - pLocalOctetStringPV); - - if (CPA_STATUS_SUCCESS != lacStatus) { - EPRINTK("%s(): DH Phase 1 Key Gen failed (%d).\n", - __FUNCTION__, lacStatus); - icp_ocfDrvFreeFlatBuffer(pLocalOctetStringPV); - ICP_CACHE_FREE(drvDH_zone, pPhase1OpData); - } - - return lacStatus; -} - -/* Name : icp_ocfDrvModExp - * - * Description : This function will map ordinary Modular Exponentiation calls - * from OCF to the LAC API. - * - */ -static int icp_ocfDrvModExp(struct cryptkop *krp) -{ - CpaStatus lacStatus = CPA_STATUS_SUCCESS; - void *callbackTag = NULL; - CpaCyLnModExpOpData *pModExpOpData = NULL; - CpaFlatBuffer *pResult = NULL; - - if ((krp->krp_param[ICP_MOD_EXP_KRP_PARAM_MODULUS_INDEX].crp_nbits % - NUM_BITS_IN_BYTE) != 0) { - DPRINTK("%s(): Warning - modulus buffer size (%d) is not a " - "multiple of 8 bits\n", __FUNCTION__, - krp->krp_param[ICP_MOD_EXP_KRP_PARAM_MODULUS_INDEX]. - crp_nbits); - } - - /* Result storage space should be the same size as the prime as this - value can take up the same amount of storage space */ - if (krp->krp_param[ICP_MOD_EXP_KRP_PARAM_MODULUS_INDEX].crp_nbits > - krp->krp_param[ICP_MOD_EXP_KRP_PARAM_RESULT_INDEX].crp_nbits) { - APRINTK("%s(): Return Buffer size must be the same or" - " greater than the Modulus buffer\n", __FUNCTION__); - krp->krp_status = EINVAL; - return EINVAL; - } - - callbackTag = krp; - - pModExpOpData = icp_kmem_cache_zalloc(drvLnModExp_zone, ICP_M_NOWAIT); - if (NULL == pModExpOpData) { - APRINTK("%s():Failed to get memory for key gen data\n", - __FUNCTION__); - krp->krp_status = ENOMEM; - return ENOMEM; - } - - pResult = icp_kmem_cache_zalloc(drvFlatBuffer_zone, ICP_M_NOWAIT); - if (NULL == pResult) { - APRINTK("%s():Failed to get memory for ModExp result\n", - __FUNCTION__); - ICP_CACHE_FREE(drvLnModExp_zone, pModExpOpData); - krp->krp_status = ENOMEM; - return ENOMEM; - } - - /* Link parameters */ - pModExpOpData->modulus.pData = - krp->krp_param[ICP_MOD_EXP_KRP_PARAM_MODULUS_INDEX].crp_p; - BITS_TO_BYTES(pModExpOpData->modulus.dataLenInBytes, - krp->krp_param[ICP_MOD_EXP_KRP_PARAM_MODULUS_INDEX]. - crp_nbits); - - icp_ocfDrvSwapBytes(pModExpOpData->modulus.pData, - pModExpOpData->modulus.dataLenInBytes); - - DPRINTK("%s : base (%d)\n", __FUNCTION__, krp-> - krp_param[ICP_MOD_EXP_KRP_PARAM_BASE_INDEX].crp_nbits); - pModExpOpData->base.pData = - krp->krp_param[ICP_MOD_EXP_KRP_PARAM_BASE_INDEX].crp_p; - BITS_TO_BYTES(pModExpOpData->base.dataLenInBytes, - krp->krp_param[ICP_MOD_EXP_KRP_PARAM_BASE_INDEX]. - crp_nbits); - icp_ocfDrvSwapBytes(pModExpOpData->base.pData, - pModExpOpData->base.dataLenInBytes); - - pModExpOpData->exponent.pData = - krp->krp_param[ICP_MOD_EXP_KRP_PARAM_EXPONENT_INDEX].crp_p; - BITS_TO_BYTES(pModExpOpData->exponent.dataLenInBytes, - krp->krp_param[ICP_MOD_EXP_KRP_PARAM_EXPONENT_INDEX]. - crp_nbits); - - icp_ocfDrvSwapBytes(pModExpOpData->exponent.pData, - pModExpOpData->exponent.dataLenInBytes); - /* Output parameters */ - pResult->pData = - krp->krp_param[ICP_MOD_EXP_KRP_PARAM_RESULT_INDEX].crp_p, - BITS_TO_BYTES(pResult->dataLenInBytes, - krp->krp_param[ICP_MOD_EXP_KRP_PARAM_RESULT_INDEX]. - crp_nbits); - - lacStatus = cpaCyLnModExp(CPA_INSTANCE_HANDLE_SINGLE, - icp_ocfDrvModExpCallBack, - callbackTag, pModExpOpData, pResult); - - if (CPA_STATUS_SUCCESS != lacStatus) { - EPRINTK("%s(): Mod Exp Operation failed (%d).\n", - __FUNCTION__, lacStatus); - krp->krp_status = ECANCELED; - icp_ocfDrvFreeFlatBuffer(pResult); - ICP_CACHE_FREE(drvLnModExp_zone, pModExpOpData); - } - - return lacStatus; -} - -/* Name : icp_ocfDrvModExpCRT - * - * Description : This function will map ordinary Modular Exponentiation Chinese - * Remainder Theorem implementaion calls from OCF to the LAC API. - * - * Note : Mod Exp CRT for this driver is accelerated through LAC RSA type 2 - * decrypt operation. Therefore P and Q input values must always be prime - * numbers. Although basic primality checks are done in LAC, it is up to the - * user to do any correct prime number checking before passing the inputs. - */ -static int icp_ocfDrvModExpCRT(struct cryptkop *krp) -{ - CpaStatus lacStatus = CPA_STATUS_SUCCESS; - CpaCyRsaDecryptOpData *rsaDecryptOpData = NULL; - void *callbackTag = NULL; - CpaFlatBuffer *pOutputData = NULL; - - /*Parameter input checks are all done by LAC, no need to repeat - them here. */ - callbackTag = krp; - - rsaDecryptOpData = - icp_kmem_cache_zalloc(drvRSADecrypt_zone, ICP_M_NOWAIT); - if (NULL == rsaDecryptOpData) { - APRINTK("%s():Failed to get memory" - " for MOD EXP CRT Op data struct\n", __FUNCTION__); - krp->krp_status = ENOMEM; - return ENOMEM; - } - - rsaDecryptOpData->pRecipientPrivateKey - = icp_kmem_cache_zalloc(drvRSAPrivateKey_zone, ICP_M_NOWAIT); - if (NULL == rsaDecryptOpData->pRecipientPrivateKey) { - APRINTK("%s():Failed to get memory for MOD EXP CRT" - " private key values struct\n", __FUNCTION__); - ICP_CACHE_FREE(drvRSADecrypt_zone, rsaDecryptOpData); - krp->krp_status = ENOMEM; - return ENOMEM; - } - - rsaDecryptOpData->pRecipientPrivateKey-> - version = CPA_CY_RSA_VERSION_TWO_PRIME; - rsaDecryptOpData->pRecipientPrivateKey-> - privateKeyRepType = CPA_CY_RSA_PRIVATE_KEY_REP_TYPE_2; - - pOutputData = icp_kmem_cache_zalloc(drvFlatBuffer_zone, ICP_M_NOWAIT); - if (NULL == pOutputData) { - APRINTK("%s():Failed to get memory" - " for MOD EXP CRT output data\n", __FUNCTION__); - ICP_CACHE_FREE(drvRSAPrivateKey_zone, - rsaDecryptOpData->pRecipientPrivateKey); - ICP_CACHE_FREE(drvRSADecrypt_zone, rsaDecryptOpData); - krp->krp_status = ENOMEM; - return ENOMEM; - } - - rsaDecryptOpData->pRecipientPrivateKey-> - version = CPA_CY_RSA_VERSION_TWO_PRIME; - rsaDecryptOpData->pRecipientPrivateKey-> - privateKeyRepType = CPA_CY_RSA_PRIVATE_KEY_REP_TYPE_2; - - /* Link parameters */ - rsaDecryptOpData->inputData.pData = - krp->krp_param[ICP_MOD_EXP_CRT_KRP_PARAM_I_INDEX].crp_p; - BITS_TO_BYTES(rsaDecryptOpData->inputData.dataLenInBytes, - krp->krp_param[ICP_MOD_EXP_CRT_KRP_PARAM_I_INDEX]. - crp_nbits); - - icp_ocfDrvSwapBytes(rsaDecryptOpData->inputData.pData, - rsaDecryptOpData->inputData.dataLenInBytes); - - rsaDecryptOpData->pRecipientPrivateKey->privateKeyRep2.prime1P.pData = - krp->krp_param[ICP_MOD_EXP_CRT_KRP_PARAM_PRIME_P_INDEX].crp_p; - BITS_TO_BYTES(rsaDecryptOpData->pRecipientPrivateKey->privateKeyRep2. - prime1P.dataLenInBytes, - krp->krp_param[ICP_MOD_EXP_CRT_KRP_PARAM_PRIME_P_INDEX]. - crp_nbits); - - icp_ocfDrvSwapBytes(rsaDecryptOpData->pRecipientPrivateKey-> - privateKeyRep2.prime1P.pData, - rsaDecryptOpData->pRecipientPrivateKey-> - privateKeyRep2.prime1P.dataLenInBytes); - - rsaDecryptOpData->pRecipientPrivateKey->privateKeyRep2.prime2Q.pData = - krp->krp_param[ICP_MOD_EXP_CRT_KRP_PARAM_PRIME_Q_INDEX].crp_p; - BITS_TO_BYTES(rsaDecryptOpData->pRecipientPrivateKey->privateKeyRep2. - prime2Q.dataLenInBytes, - krp->krp_param[ICP_MOD_EXP_CRT_KRP_PARAM_PRIME_Q_INDEX]. - crp_nbits); - - icp_ocfDrvSwapBytes(rsaDecryptOpData->pRecipientPrivateKey-> - privateKeyRep2.prime2Q.pData, - rsaDecryptOpData->pRecipientPrivateKey-> - privateKeyRep2.prime2Q.dataLenInBytes); - - rsaDecryptOpData->pRecipientPrivateKey-> - privateKeyRep2.exponent1Dp.pData = - krp->krp_param[ICP_MOD_EXP_CRT_KRP_PARAM_EXPONENT_DP_INDEX].crp_p; - BITS_TO_BYTES(rsaDecryptOpData->pRecipientPrivateKey->privateKeyRep2. - exponent1Dp.dataLenInBytes, - krp-> - krp_param[ICP_MOD_EXP_CRT_KRP_PARAM_EXPONENT_DP_INDEX]. - crp_nbits); - - icp_ocfDrvSwapBytes(rsaDecryptOpData->pRecipientPrivateKey-> - privateKeyRep2.exponent1Dp.pData, - rsaDecryptOpData->pRecipientPrivateKey-> - privateKeyRep2.exponent1Dp.dataLenInBytes); - - rsaDecryptOpData->pRecipientPrivateKey-> - privateKeyRep2.exponent2Dq.pData = - krp->krp_param[ICP_MOD_EXP_CRT_KRP_PARAM_EXPONENT_DQ_INDEX].crp_p; - BITS_TO_BYTES(rsaDecryptOpData->pRecipientPrivateKey-> - privateKeyRep2.exponent2Dq.dataLenInBytes, - krp-> - krp_param[ICP_MOD_EXP_CRT_KRP_PARAM_EXPONENT_DQ_INDEX]. - crp_nbits); - - icp_ocfDrvSwapBytes(rsaDecryptOpData->pRecipientPrivateKey-> - privateKeyRep2.exponent2Dq.pData, - rsaDecryptOpData->pRecipientPrivateKey-> - privateKeyRep2.exponent2Dq.dataLenInBytes); - - rsaDecryptOpData->pRecipientPrivateKey-> - privateKeyRep2.coefficientQInv.pData = - krp->krp_param[ICP_MOD_EXP_CRT_KRP_PARAM_COEFF_QINV_INDEX].crp_p; - BITS_TO_BYTES(rsaDecryptOpData->pRecipientPrivateKey-> - privateKeyRep2.coefficientQInv.dataLenInBytes, - krp-> - krp_param[ICP_MOD_EXP_CRT_KRP_PARAM_COEFF_QINV_INDEX]. - crp_nbits); - - icp_ocfDrvSwapBytes(rsaDecryptOpData->pRecipientPrivateKey-> - privateKeyRep2.coefficientQInv.pData, - rsaDecryptOpData->pRecipientPrivateKey-> - privateKeyRep2.coefficientQInv.dataLenInBytes); - - /* Output Parameter */ - pOutputData->pData = - krp->krp_param[ICP_MOD_EXP_CRT_KRP_PARAM_RESULT_INDEX].crp_p; - BITS_TO_BYTES(pOutputData->dataLenInBytes, - krp->krp_param[ICP_MOD_EXP_CRT_KRP_PARAM_RESULT_INDEX]. - crp_nbits); - - lacStatus = cpaCyRsaDecrypt(CPA_INSTANCE_HANDLE_SINGLE, - icp_ocfDrvModExpCRTCallBack, - callbackTag, rsaDecryptOpData, pOutputData); - - if (CPA_STATUS_SUCCESS != lacStatus) { - EPRINTK("%s(): Mod Exp CRT Operation failed (%d).\n", - __FUNCTION__, lacStatus); - krp->krp_status = ECANCELED; - icp_ocfDrvFreeFlatBuffer(pOutputData); - ICP_CACHE_FREE(drvRSAPrivateKey_zone, - rsaDecryptOpData->pRecipientPrivateKey); - ICP_CACHE_FREE(drvRSADecrypt_zone, rsaDecryptOpData); - } - - return lacStatus; -} - -/* Name : icp_ocfDrvCheckALessThanB - * - * Description : This function will check whether the first argument is less - * than the second. It is used to check whether the DSA RS sign Random K - * value is less than the Prime Q value (as defined in the specification) - * - */ -static int -icp_ocfDrvCheckALessThanB(CpaFlatBuffer * pK, CpaFlatBuffer * pQ, int *doCheck) -{ - - uint8_t *MSB_K = pK->pData; - uint8_t *MSB_Q = pQ->pData; - uint32_t buffer_lengths_in_bytes = pQ->dataLenInBytes; - - if (DONT_RUN_LESS_THAN_CHECK == *doCheck) { - return FAIL_A_IS_GREATER_THAN_B; - } - -/*Check MSBs -if A == B, check next MSB -if A > B, return A_IS_GREATER_THAN_B -if A < B, return A_IS_LESS_THAN_B (success) -*/ - while (*MSB_K == *MSB_Q) { - MSB_K++; - MSB_Q++; - - buffer_lengths_in_bytes--; - if (0 == buffer_lengths_in_bytes) { - DPRINTK("%s() Buffers have equal value!!\n", - __FUNCTION__); - return FAIL_A_IS_EQUAL_TO_B; - } - - } - - if (*MSB_K < *MSB_Q) { - return SUCCESS_A_IS_LESS_THAN_B; - } else { - return FAIL_A_IS_GREATER_THAN_B; - } - -} - -/* Name : icp_ocfDrvDsaSign - * - * Description : This function will map DSA RS Sign from OCF to the LAC API. - * - * NOTE: From looking at OCF patch to OpenSSL and even the number of input - * parameters, OCF expects us to generate the random seed value. This value - * is generated and passed to LAC, however the number is discared in the - * callback and not returned to the user. - */ -static int icp_ocfDrvDsaSign(struct cryptkop *krp) -{ - CpaStatus lacStatus = CPA_STATUS_SUCCESS; - CpaCyDsaRSSignOpData *dsaRsSignOpData = NULL; - void *callbackTag = NULL; - CpaCyRandGenOpData randGenOpData; - int primeQSizeInBytes = 0; - int doCheck = 0; - CpaFlatBuffer randData; - CpaBoolean protocolStatus = CPA_FALSE; - CpaFlatBuffer *pR = NULL; - CpaFlatBuffer *pS = NULL; - - callbackTag = krp; - - BITS_TO_BYTES(primeQSizeInBytes, - krp->krp_param[ICP_DSA_SIGN_KRP_PARAM_PRIME_Q_INDEX]. - crp_nbits); - - if (DSA_RS_SIGN_PRIMEQ_SIZE_IN_BYTES != primeQSizeInBytes) { - APRINTK("%s(): DSA PRIME Q size not equal to the " - "FIPS defined 20bytes, = %d\n", - __FUNCTION__, primeQSizeInBytes); - krp->krp_status = EDOM; - return EDOM; - } - - dsaRsSignOpData = - icp_kmem_cache_zalloc(drvDSARSSign_zone, ICP_M_NOWAIT); - if (NULL == dsaRsSignOpData) { - APRINTK("%s():Failed to get memory" - " for DSA RS Sign Op data struct\n", __FUNCTION__); - krp->krp_status = ENOMEM; - return ENOMEM; - } - - dsaRsSignOpData->K.pData = - icp_kmem_cache_alloc(drvDSARSSignKValue_zone, ICP_M_NOWAIT); - - if (NULL == dsaRsSignOpData->K.pData) { - APRINTK("%s():Failed to get memory" - " for DSA RS Sign Op Random value\n", __FUNCTION__); - ICP_CACHE_FREE(drvDSARSSign_zone, dsaRsSignOpData); - krp->krp_status = ENOMEM; - return ENOMEM; - } - - pR = icp_kmem_cache_zalloc(drvFlatBuffer_zone, ICP_M_NOWAIT); - if (NULL == pR) { - APRINTK("%s():Failed to get memory" - " for DSA signature R\n", __FUNCTION__); - ICP_CACHE_FREE(drvDSARSSignKValue_zone, - dsaRsSignOpData->K.pData); - ICP_CACHE_FREE(drvDSARSSign_zone, dsaRsSignOpData); - krp->krp_status = ENOMEM; - return ENOMEM; - } - - pS = icp_kmem_cache_zalloc(drvFlatBuffer_zone, ICP_M_NOWAIT); - if (NULL == pS) { - APRINTK("%s():Failed to get memory" - " for DSA signature S\n", __FUNCTION__); - icp_ocfDrvFreeFlatBuffer(pR); - ICP_CACHE_FREE(drvDSARSSignKValue_zone, - dsaRsSignOpData->K.pData); - ICP_CACHE_FREE(drvDSARSSign_zone, dsaRsSignOpData); - krp->krp_status = ENOMEM; - return ENOMEM; - } - - /*link prime number parameter for ease of processing */ - dsaRsSignOpData->P.pData = - krp->krp_param[ICP_DSA_SIGN_KRP_PARAM_PRIME_P_INDEX].crp_p; - BITS_TO_BYTES(dsaRsSignOpData->P.dataLenInBytes, - krp->krp_param[ICP_DSA_SIGN_KRP_PARAM_PRIME_P_INDEX]. - crp_nbits); - - icp_ocfDrvSwapBytes(dsaRsSignOpData->P.pData, - dsaRsSignOpData->P.dataLenInBytes); - - dsaRsSignOpData->Q.pData = - krp->krp_param[ICP_DSA_SIGN_KRP_PARAM_PRIME_Q_INDEX].crp_p; - BITS_TO_BYTES(dsaRsSignOpData->Q.dataLenInBytes, - krp->krp_param[ICP_DSA_SIGN_KRP_PARAM_PRIME_Q_INDEX]. - crp_nbits); - - icp_ocfDrvSwapBytes(dsaRsSignOpData->Q.pData, - dsaRsSignOpData->Q.dataLenInBytes); - - /*generate random number with equal buffer size to Prime value Q, - but value less than Q */ - dsaRsSignOpData->K.dataLenInBytes = dsaRsSignOpData->Q.dataLenInBytes; - - randGenOpData.generateBits = CPA_TRUE; - randGenOpData.lenInBytes = dsaRsSignOpData->K.dataLenInBytes; - - icp_ocfDrvPtrAndLenToFlatBuffer(dsaRsSignOpData->K.pData, - dsaRsSignOpData->K.dataLenInBytes, - &randData); - - doCheck = 0; - while (icp_ocfDrvCheckALessThanB(&(dsaRsSignOpData->K), - &(dsaRsSignOpData->Q), &doCheck)) { - - if (CPA_STATUS_SUCCESS - != cpaCyRandGen(CPA_INSTANCE_HANDLE_SINGLE, - NULL, NULL, &randGenOpData, &randData)) { - APRINTK("%s(): ERROR - Failed to generate DSA RS Sign K" - "value\n", __FUNCTION__); - icp_ocfDrvFreeFlatBuffer(pS); - icp_ocfDrvFreeFlatBuffer(pR); - ICP_CACHE_FREE(drvDSARSSignKValue_zone, - dsaRsSignOpData->K.pData); - ICP_CACHE_FREE(drvDSARSSign_zone, dsaRsSignOpData); - krp->krp_status = EAGAIN; - return EAGAIN; - } - - doCheck++; - if (DSA_SIGN_RAND_GEN_VAL_CHECK_MAX_ITERATIONS == doCheck) { - APRINTK("%s(): ERROR - Failed to find DSA RS Sign K " - "value less than Q value\n", __FUNCTION__); - icp_ocfDrvFreeFlatBuffer(pS); - icp_ocfDrvFreeFlatBuffer(pR); - ICP_CACHE_FREE(drvDSARSSignKValue_zone, - dsaRsSignOpData->K.pData); - ICP_CACHE_FREE(drvDSARSSign_zone, dsaRsSignOpData); - krp->krp_status = EAGAIN; - return EAGAIN; - } - - } - /*Rand Data - no need to swap bytes for pK */ - - /* Link parameters */ - dsaRsSignOpData->G.pData = - krp->krp_param[ICP_DSA_SIGN_KRP_PARAM_G_INDEX].crp_p; - BITS_TO_BYTES(dsaRsSignOpData->G.dataLenInBytes, - krp->krp_param[ICP_DSA_SIGN_KRP_PARAM_G_INDEX].crp_nbits); - - icp_ocfDrvSwapBytes(dsaRsSignOpData->G.pData, - dsaRsSignOpData->G.dataLenInBytes); - - dsaRsSignOpData->X.pData = - krp->krp_param[ICP_DSA_SIGN_KRP_PARAM_X_INDEX].crp_p; - BITS_TO_BYTES(dsaRsSignOpData->X.dataLenInBytes, - krp->krp_param[ICP_DSA_SIGN_KRP_PARAM_X_INDEX].crp_nbits); - icp_ocfDrvSwapBytes(dsaRsSignOpData->X.pData, - dsaRsSignOpData->X.dataLenInBytes); - - /*OpenSSL dgst parameter is left in big endian byte order, - therefore no byte swap is required */ - dsaRsSignOpData->M.pData = - krp->krp_param[ICP_DSA_SIGN_KRP_PARAM_DGST_INDEX].crp_p; - BITS_TO_BYTES(dsaRsSignOpData->M.dataLenInBytes, - krp->krp_param[ICP_DSA_SIGN_KRP_PARAM_DGST_INDEX]. - crp_nbits); - - /* Output Parameters */ - pS->pData = krp->krp_param[ICP_DSA_SIGN_KRP_PARAM_S_RESULT_INDEX].crp_p; - BITS_TO_BYTES(pS->dataLenInBytes, - krp->krp_param[ICP_DSA_SIGN_KRP_PARAM_S_RESULT_INDEX]. - crp_nbits); - - pR->pData = krp->krp_param[ICP_DSA_SIGN_KRP_PARAM_R_RESULT_INDEX].crp_p; - BITS_TO_BYTES(pR->dataLenInBytes, - krp->krp_param[ICP_DSA_SIGN_KRP_PARAM_R_RESULT_INDEX]. - crp_nbits); - - lacStatus = cpaCyDsaSignRS(CPA_INSTANCE_HANDLE_SINGLE, - icp_ocfDrvDsaRSSignCallBack, - callbackTag, dsaRsSignOpData, - &protocolStatus, pR, pS); - - if (CPA_STATUS_SUCCESS != lacStatus) { - EPRINTK("%s(): DSA RS Sign Operation failed (%d).\n", - __FUNCTION__, lacStatus); - krp->krp_status = ECANCELED; - icp_ocfDrvFreeFlatBuffer(pS); - icp_ocfDrvFreeFlatBuffer(pR); - ICP_CACHE_FREE(drvDSARSSignKValue_zone, - dsaRsSignOpData->K.pData); - ICP_CACHE_FREE(drvDSARSSign_zone, dsaRsSignOpData); - } - - return lacStatus; -} - -/* Name : icp_ocfDrvDsaVerify - * - * Description : This function will map DSA RS Verify from OCF to the LAC API. - * - */ -static int icp_ocfDrvDsaVerify(struct cryptkop *krp) -{ - CpaStatus lacStatus = CPA_STATUS_SUCCESS; - CpaCyDsaVerifyOpData *dsaVerifyOpData = NULL; - void *callbackTag = NULL; - CpaBoolean verifyStatus = CPA_FALSE; - - callbackTag = krp; - - dsaVerifyOpData = - icp_kmem_cache_zalloc(drvDSAVerify_zone, ICP_M_NOWAIT); - if (NULL == dsaVerifyOpData) { - APRINTK("%s():Failed to get memory" - " for DSA Verify Op data struct\n", __FUNCTION__); - krp->krp_status = ENOMEM; - return ENOMEM; - } - - /* Link parameters */ - dsaVerifyOpData->P.pData = - krp->krp_param[ICP_DSA_VERIFY_KRP_PARAM_PRIME_P_INDEX].crp_p; - BITS_TO_BYTES(dsaVerifyOpData->P.dataLenInBytes, - krp->krp_param[ICP_DSA_VERIFY_KRP_PARAM_PRIME_P_INDEX]. - crp_nbits); - icp_ocfDrvSwapBytes(dsaVerifyOpData->P.pData, - dsaVerifyOpData->P.dataLenInBytes); - - dsaVerifyOpData->Q.pData = - krp->krp_param[ICP_DSA_VERIFY_KRP_PARAM_PRIME_Q_INDEX].crp_p; - BITS_TO_BYTES(dsaVerifyOpData->Q.dataLenInBytes, - krp->krp_param[ICP_DSA_VERIFY_KRP_PARAM_PRIME_Q_INDEX]. - crp_nbits); - icp_ocfDrvSwapBytes(dsaVerifyOpData->Q.pData, - dsaVerifyOpData->Q.dataLenInBytes); - - dsaVerifyOpData->G.pData = - krp->krp_param[ICP_DSA_VERIFY_KRP_PARAM_G_INDEX].crp_p; - BITS_TO_BYTES(dsaVerifyOpData->G.dataLenInBytes, - krp->krp_param[ICP_DSA_VERIFY_KRP_PARAM_G_INDEX]. - crp_nbits); - icp_ocfDrvSwapBytes(dsaVerifyOpData->G.pData, - dsaVerifyOpData->G.dataLenInBytes); - - dsaVerifyOpData->Y.pData = - krp->krp_param[ICP_DSA_VERIFY_KRP_PARAM_PUBKEY_INDEX].crp_p; - BITS_TO_BYTES(dsaVerifyOpData->Y.dataLenInBytes, - krp->krp_param[ICP_DSA_VERIFY_KRP_PARAM_PUBKEY_INDEX]. - crp_nbits); - icp_ocfDrvSwapBytes(dsaVerifyOpData->Y.pData, - dsaVerifyOpData->Y.dataLenInBytes); - - /*OpenSSL dgst parameter is left in big endian byte order, - therefore no byte swap is required */ - dsaVerifyOpData->M.pData = - krp->krp_param[ICP_DSA_VERIFY_KRP_PARAM_DGST_INDEX].crp_p; - BITS_TO_BYTES(dsaVerifyOpData->M.dataLenInBytes, - krp->krp_param[ICP_DSA_VERIFY_KRP_PARAM_DGST_INDEX]. - crp_nbits); - - dsaVerifyOpData->R.pData = - krp->krp_param[ICP_DSA_VERIFY_KRP_PARAM_SIG_R_INDEX].crp_p; - BITS_TO_BYTES(dsaVerifyOpData->R.dataLenInBytes, - krp->krp_param[ICP_DSA_VERIFY_KRP_PARAM_SIG_R_INDEX]. - crp_nbits); - icp_ocfDrvSwapBytes(dsaVerifyOpData->R.pData, - dsaVerifyOpData->R.dataLenInBytes); - - dsaVerifyOpData->S.pData = - krp->krp_param[ICP_DSA_VERIFY_KRP_PARAM_SIG_S_INDEX].crp_p; - BITS_TO_BYTES(dsaVerifyOpData->S.dataLenInBytes, - krp->krp_param[ICP_DSA_VERIFY_KRP_PARAM_SIG_S_INDEX]. - crp_nbits); - icp_ocfDrvSwapBytes(dsaVerifyOpData->S.pData, - dsaVerifyOpData->S.dataLenInBytes); - - lacStatus = cpaCyDsaVerify(CPA_INSTANCE_HANDLE_SINGLE, - icp_ocfDrvDsaVerifyCallBack, - callbackTag, dsaVerifyOpData, &verifyStatus); - - if (CPA_STATUS_SUCCESS != lacStatus) { - EPRINTK("%s(): DSA Verify Operation failed (%d).\n", - __FUNCTION__, lacStatus); - ICP_CACHE_FREE(drvDSAVerify_zone, dsaVerifyOpData); - krp->krp_status = ECANCELED; - } - - return lacStatus; -} - -/* Name : icp_ocfDrvDhP1Callback - * - * Description : When this function returns it signifies that the LAC - * component has completed the DH operation. - */ -static void -icp_ocfDrvDhP1CallBack(void *callbackTag, - CpaStatus status, - void *pOpData, CpaFlatBuffer * pLocalOctetStringPV) -{ - struct cryptkop *krp = NULL; - CpaCyDhPhase1KeyGenOpData *pPhase1OpData = NULL; - - if (NULL == callbackTag) { - DPRINTK("%s(): Invalid input parameters - " - "callbackTag data is NULL\n", __FUNCTION__); - return; - } - krp = (struct cryptkop *)callbackTag; - - if (NULL == pOpData) { - DPRINTK("%s(): Invalid input parameters - " - "Operation Data is NULL\n", __FUNCTION__); - krp->krp_status = ECANCELED; - crypto_kdone(krp); - return; - } - pPhase1OpData = (CpaCyDhPhase1KeyGenOpData *) pOpData; - - if (NULL == pLocalOctetStringPV) { - DPRINTK("%s(): Invalid input parameters - " - "pLocalOctetStringPV Data is NULL\n", __FUNCTION__); - memset(pPhase1OpData, 0, sizeof(CpaCyDhPhase1KeyGenOpData)); - ICP_CACHE_FREE(drvDH_zone, pPhase1OpData); - krp->krp_status = ECANCELED; - crypto_kdone(krp); - return; - } - - if (CPA_STATUS_SUCCESS == status) { - krp->krp_status = CRYPTO_OP_SUCCESS; - } else { - APRINTK("%s(): Diffie Hellman Phase1 Key Gen failed - " - "Operation Status = %d\n", __FUNCTION__, status); - krp->krp_status = ECANCELED; - } - - icp_ocfDrvSwapBytes(pLocalOctetStringPV->pData, - pLocalOctetStringPV->dataLenInBytes); - - icp_ocfDrvFreeFlatBuffer(pLocalOctetStringPV); - memset(pPhase1OpData, 0, sizeof(CpaCyDhPhase1KeyGenOpData)); - ICP_CACHE_FREE(drvDH_zone, pPhase1OpData); - - crypto_kdone(krp); - - return; -} - -/* Name : icp_ocfDrvModExpCallBack - * - * Description : When this function returns it signifies that the LAC - * component has completed the Mod Exp operation. - */ -static void -icp_ocfDrvModExpCallBack(void *callbackTag, - CpaStatus status, - void *pOpdata, CpaFlatBuffer * pResult) -{ - struct cryptkop *krp = NULL; - CpaCyLnModExpOpData *pLnModExpOpData = NULL; - - if (NULL == callbackTag) { - DPRINTK("%s(): Invalid input parameters - " - "callbackTag data is NULL\n", __FUNCTION__); - return; - } - krp = (struct cryptkop *)callbackTag; - - if (NULL == pOpdata) { - DPRINTK("%s(): Invalid Mod Exp input parameters - " - "Operation Data is NULL\n", __FUNCTION__); - krp->krp_status = ECANCELED; - crypto_kdone(krp); - return; - } - pLnModExpOpData = (CpaCyLnModExpOpData *) pOpdata; - - if (NULL == pResult) { - DPRINTK("%s(): Invalid input parameters - " - "pResult data is NULL\n", __FUNCTION__); - krp->krp_status = ECANCELED; - memset(pLnModExpOpData, 0, sizeof(CpaCyLnModExpOpData)); - ICP_CACHE_FREE(drvLnModExp_zone, pLnModExpOpData); - crypto_kdone(krp); - return; - } - - if (CPA_STATUS_SUCCESS == status) { - krp->krp_status = CRYPTO_OP_SUCCESS; - } else { - APRINTK("%s(): LAC Mod Exp Operation failed - " - "Operation Status = %d\n", __FUNCTION__, status); - krp->krp_status = ECANCELED; - } - - icp_ocfDrvSwapBytes(pResult->pData, pResult->dataLenInBytes); - - /*switch base size value back to original */ - if (pLnModExpOpData->base.pData == - (uint8_t *) & (krp-> - krp_param[ICP_MOD_EXP_KRP_PARAM_BASE_INDEX]. - crp_nbits)) { - *((uint32_t *) pLnModExpOpData->base.pData) = - ntohl(*((uint32_t *) pLnModExpOpData->base.pData)); - } - icp_ocfDrvFreeFlatBuffer(pResult); - memset(pLnModExpOpData, 0, sizeof(CpaCyLnModExpOpData)); - ICP_CACHE_FREE(drvLnModExp_zone, pLnModExpOpData); - - crypto_kdone(krp); - - return; - -} - -/* Name : icp_ocfDrvModExpCRTCallBack - * - * Description : When this function returns it signifies that the LAC - * component has completed the Mod Exp CRT operation. - */ -static void -icp_ocfDrvModExpCRTCallBack(void *callbackTag, - CpaStatus status, - void *pOpData, CpaFlatBuffer * pOutputData) -{ - struct cryptkop *krp = NULL; - CpaCyRsaDecryptOpData *pDecryptData = NULL; - - if (NULL == callbackTag) { - DPRINTK("%s(): Invalid input parameters - " - "callbackTag data is NULL\n", __FUNCTION__); - return; - } - - krp = (struct cryptkop *)callbackTag; - - if (NULL == pOpData) { - DPRINTK("%s(): Invalid input parameters - " - "Operation Data is NULL\n", __FUNCTION__); - krp->krp_status = ECANCELED; - crypto_kdone(krp); - return; - } - pDecryptData = (CpaCyRsaDecryptOpData *) pOpData; - - if (NULL == pOutputData) { - DPRINTK("%s(): Invalid input parameter - " - "pOutputData is NULL\n", __FUNCTION__); - memset(pDecryptData->pRecipientPrivateKey, 0, - sizeof(CpaCyRsaPrivateKey)); - ICP_CACHE_FREE(drvRSAPrivateKey_zone, - pDecryptData->pRecipientPrivateKey); - memset(pDecryptData, 0, sizeof(CpaCyRsaDecryptOpData)); - ICP_CACHE_FREE(drvRSADecrypt_zone, pDecryptData); - krp->krp_status = ECANCELED; - crypto_kdone(krp); - return; - } - - if (CPA_STATUS_SUCCESS == status) { - krp->krp_status = CRYPTO_OP_SUCCESS; - } else { - APRINTK("%s(): LAC Mod Exp CRT operation failed - " - "Operation Status = %d\n", __FUNCTION__, status); - krp->krp_status = ECANCELED; - } - - icp_ocfDrvSwapBytes(pOutputData->pData, pOutputData->dataLenInBytes); - - icp_ocfDrvFreeFlatBuffer(pOutputData); - memset(pDecryptData->pRecipientPrivateKey, 0, - sizeof(CpaCyRsaPrivateKey)); - ICP_CACHE_FREE(drvRSAPrivateKey_zone, - pDecryptData->pRecipientPrivateKey); - memset(pDecryptData, 0, sizeof(CpaCyRsaDecryptOpData)); - ICP_CACHE_FREE(drvRSADecrypt_zone, pDecryptData); - - crypto_kdone(krp); - - return; -} - -/* Name : icp_ocfDrvDsaRSSignCallBack - * - * Description : When this function returns it signifies that the LAC - * component has completed the DSA RS sign operation. - */ -static void -icp_ocfDrvDsaRSSignCallBack(void *callbackTag, - CpaStatus status, - void *pOpData, - CpaBoolean protocolStatus, - CpaFlatBuffer * pR, CpaFlatBuffer * pS) -{ - struct cryptkop *krp = NULL; - CpaCyDsaRSSignOpData *pSignData = NULL; - - if (NULL == callbackTag) { - DPRINTK("%s(): Invalid input parameters - " - "callbackTag data is NULL\n", __FUNCTION__); - return; - } - - krp = (struct cryptkop *)callbackTag; - - if (NULL == pOpData) { - DPRINTK("%s(): Invalid input parameters - " - "Operation Data is NULL\n", __FUNCTION__); - krp->krp_status = ECANCELED; - crypto_kdone(krp); - return; - } - pSignData = (CpaCyDsaRSSignOpData *) pOpData; - - if (NULL == pR) { - DPRINTK("%s(): Invalid input parameter - " - "pR sign is NULL\n", __FUNCTION__); - icp_ocfDrvFreeFlatBuffer(pS); - ICP_CACHE_FREE(drvDSARSSign_zone, pSignData); - krp->krp_status = ECANCELED; - crypto_kdone(krp); - return; - } - - if (NULL == pS) { - DPRINTK("%s(): Invalid input parameter - " - "pS sign is NULL\n", __FUNCTION__); - icp_ocfDrvFreeFlatBuffer(pR); - ICP_CACHE_FREE(drvDSARSSign_zone, pSignData); - krp->krp_status = ECANCELED; - crypto_kdone(krp); - return; - } - - if (CPA_STATUS_SUCCESS != status) { - APRINTK("%s(): LAC DSA RS Sign operation failed - " - "Operation Status = %d\n", __FUNCTION__, status); - krp->krp_status = ECANCELED; - } else { - krp->krp_status = CRYPTO_OP_SUCCESS; - - if (CPA_TRUE != protocolStatus) { - DPRINTK("%s(): LAC DSA RS Sign operation failed due " - "to protocol error\n", __FUNCTION__); - krp->krp_status = EIO; - } - } - - /* Swap bytes only when the callback status is successful and - protocolStatus is set to true */ - if (CPA_STATUS_SUCCESS == status && CPA_TRUE == protocolStatus) { - icp_ocfDrvSwapBytes(pR->pData, pR->dataLenInBytes); - icp_ocfDrvSwapBytes(pS->pData, pS->dataLenInBytes); - } - - icp_ocfDrvFreeFlatBuffer(pR); - icp_ocfDrvFreeFlatBuffer(pS); - memset(pSignData->K.pData, 0, pSignData->K.dataLenInBytes); - ICP_CACHE_FREE(drvDSARSSignKValue_zone, pSignData->K.pData); - memset(pSignData, 0, sizeof(CpaCyDsaRSSignOpData)); - ICP_CACHE_FREE(drvDSARSSign_zone, pSignData); - crypto_kdone(krp); - - return; -} - -/* Name : icp_ocfDrvDsaVerifyCallback - * - * Description : When this function returns it signifies that the LAC - * component has completed the DSA Verify operation. - */ -static void -icp_ocfDrvDsaVerifyCallBack(void *callbackTag, - CpaStatus status, - void *pOpData, CpaBoolean verifyStatus) -{ - - struct cryptkop *krp = NULL; - CpaCyDsaVerifyOpData *pVerData = NULL; - - if (NULL == callbackTag) { - DPRINTK("%s(): Invalid input parameters - " - "callbackTag data is NULL\n", __FUNCTION__); - return; - } - - krp = (struct cryptkop *)callbackTag; - - if (NULL == pOpData) { - DPRINTK("%s(): Invalid input parameters - " - "Operation Data is NULL\n", __FUNCTION__); - krp->krp_status = ECANCELED; - crypto_kdone(krp); - return; - } - pVerData = (CpaCyDsaVerifyOpData *) pOpData; - - if (CPA_STATUS_SUCCESS != status) { - APRINTK("%s(): LAC DSA Verify operation failed - " - "Operation Status = %d\n", __FUNCTION__, status); - krp->krp_status = ECANCELED; - } else { - krp->krp_status = CRYPTO_OP_SUCCESS; - - if (CPA_TRUE != verifyStatus) { - DPRINTK("%s(): DSA signature invalid\n", __FUNCTION__); - krp->krp_status = EIO; - } - } - - /* Swap bytes only when the callback status is successful and - verifyStatus is set to true */ - /*Just swapping back the key values for now. Possibly all - swapped buffers need to be reverted */ - if (CPA_STATUS_SUCCESS == status && CPA_TRUE == verifyStatus) { - icp_ocfDrvSwapBytes(pVerData->R.pData, - pVerData->R.dataLenInBytes); - icp_ocfDrvSwapBytes(pVerData->S.pData, - pVerData->S.dataLenInBytes); - } - - memset(pVerData, 0, sizeof(CpaCyDsaVerifyOpData)); - ICP_CACHE_FREE(drvDSAVerify_zone, pVerData); - crypto_kdone(krp); - - return; -} diff --git a/target/linux/generic-2.4/files/crypto/ocf/ep80579/icp_common.c b/target/linux/generic-2.4/files/crypto/ocf/ep80579/icp_common.c deleted file mode 100644 index 5d46c0a..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/ep80579/icp_common.c +++ /dev/null @@ -1,773 +0,0 @@ -/************************************************************************* - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Corporation - * - * BSD LICENSE - * - * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - * version: Security.L.1.0.2-229 - * - ***************************************************************************/ - -/* - * An OCF module that uses Intel® QuickAssist Integrated Accelerator to do the - * crypto. - * - * This driver requires the ICP Access Library that is available from Intel in - * order to operate. - */ - -#include "icp_ocf.h" - -#define ICP_OCF_COMP_NAME "ICP_OCF" -#define ICP_OCF_VER_MAIN (2) -#define ICP_OCF_VER_MJR (1) -#define ICP_OCF_VER_MNR (0) - -#define MAX_DEREG_RETRIES (100) -#define DEFAULT_DEREG_RETRIES (10) -#define DEFAULT_DEREG_DELAY_IN_JIFFIES (10) - -/* This defines the maximum number of sessions possible between OCF - and the OCF EP80579 Driver. If set to zero, there is no limit. */ -#define DEFAULT_OCF_TO_DRV_MAX_SESSION_COUNT (0) -#define NUM_SUPPORTED_CAPABILITIES (21) - -/*Slab zone names*/ -#define ICP_SESSION_DATA_NAME "icp_ocf.SesDat" -#define ICP_OP_DATA_NAME "icp_ocf.OpDat" -#define ICP_DH_NAME "icp_ocf.DH" -#define ICP_MODEXP_NAME "icp_ocf.ModExp" -#define ICP_RSA_DECRYPT_NAME "icp_ocf.RSAdec" -#define ICP_RSA_PKEY_NAME "icp_ocf.RSApk" -#define ICP_DSA_SIGN_NAME "icp_ocf.DSAsg" -#define ICP_DSA_VER_NAME "icp_ocf.DSAver" -#define ICP_RAND_VAL_NAME "icp_ocf.DSArnd" -#define ICP_FLAT_BUFF_NAME "icp_ocf.FB" - -/*Slabs zones*/ -icp_kmem_cache drvSessionData_zone = NULL; -icp_kmem_cache drvOpData_zone = NULL; -icp_kmem_cache drvDH_zone = NULL; -icp_kmem_cache drvLnModExp_zone = NULL; -icp_kmem_cache drvRSADecrypt_zone = NULL; -icp_kmem_cache drvRSAPrivateKey_zone = NULL; -icp_kmem_cache drvDSARSSign_zone = NULL; -icp_kmem_cache drvDSARSSignKValue_zone = NULL; -icp_kmem_cache drvDSAVerify_zone = NULL; - -/*Slab zones for flatbuffers and bufferlist*/ -icp_kmem_cache drvFlatBuffer_zone = NULL; - -static inline int icp_cache_null_check(void) -{ - return (drvSessionData_zone && drvOpData_zone - && drvDH_zone && drvLnModExp_zone && drvRSADecrypt_zone - && drvRSAPrivateKey_zone && drvDSARSSign_zone - && drvDSARSSign_zone && drvDSARSSignKValue_zone - && drvDSAVerify_zone && drvFlatBuffer_zone); -} - -/*Function to free all allocated slab caches before exiting the module*/ -static void icp_ocfDrvFreeCaches(void); - -int32_t icp_ocfDrvDriverId = INVALID_DRIVER_ID; - -/* Module parameter - gives the number of times LAC deregistration shall be - re-tried */ -int num_dereg_retries = DEFAULT_DEREG_RETRIES; - -/* Module parameter - gives the delay time in jiffies before a LAC session - shall be attempted to be deregistered again */ -int dereg_retry_delay_in_jiffies = DEFAULT_DEREG_DELAY_IN_JIFFIES; - -/* Module parameter - gives the maximum number of sessions possible between - OCF and the OCF EP80579 Driver. If set to zero, there is no limit.*/ -int max_sessions = DEFAULT_OCF_TO_DRV_MAX_SESSION_COUNT; - -/* This is set when the module is removed from the system, no further - processing can take place if this is set */ -icp_atomic_t icp_ocfDrvIsExiting = ICP_ATOMIC_INIT(0); - -/* This is used to show how many lac sessions were not deregistered*/ -icp_atomic_t lac_session_failed_dereg_count = ICP_ATOMIC_INIT(0); - -/* This is used to track the number of registered sessions between OCF and - * and the OCF EP80579 driver, when max_session is set to value other than - * zero. This ensures that the max_session set for the OCF and the driver - * is equal to the LAC registered sessions */ -icp_atomic_t num_ocf_to_drv_registered_sessions = ICP_ATOMIC_INIT(0); - -/* Head of linked list used to store session data */ -icp_drvSessionListHead_t icp_ocfDrvGlobalSymListHead; -icp_drvSessionListHead_t icp_ocfDrvGlobalSymListHead_FreeMemList; - -icp_spinlock_t icp_ocfDrvSymSessInfoListSpinlock; - -/*Below pointer is only used in linux, FreeBSD uses the name to -create its own variable name*/ -icp_workqueue *icp_ocfDrvFreeLacSessionWorkQ = NULL; -ICP_WORKQUEUE_DEFINE_THREAD(icp_ocfDrvFreeLacSessionWorkQ); - -struct icp_drvBuffListInfo defBuffListInfo; - -/* Name : icp_ocfDrvInit - * - * Description : This function will register all the symmetric and asymmetric - * functionality that will be accelerated by the hardware. It will also - * get a unique driver ID from the OCF and initialise all slab caches - */ -ICP_MODULE_INIT_FUNC(icp_ocfDrvInit) -{ - int ocfStatus = 0; - - IPRINTK("=== %s ver %d.%d.%d ===\n", ICP_OCF_COMP_NAME, - ICP_OCF_VER_MAIN, ICP_OCF_VER_MJR, ICP_OCF_VER_MNR); - - if (MAX_DEREG_RETRIES < num_dereg_retries) { - EPRINTK("Session deregistration retry count set to greater " - "than %d", MAX_DEREG_RETRIES); - icp_module_return_code(EINVAL); - } - - /* Initialize and Start the Cryptographic component */ - if (CPA_STATUS_SUCCESS != - cpaCyStartInstance(CPA_INSTANCE_HANDLE_SINGLE)) { - EPRINTK("Failed to initialize and start the instance " - "of the Cryptographic component.\n"); - return icp_module_return_code(EINVAL); - } - - icp_spin_lock_init(&icp_ocfDrvSymSessInfoListSpinlock); - - /* Set the default size of BufferList to allocate */ - memset(&defBuffListInfo, 0, sizeof(struct icp_drvBuffListInfo)); - if (ICP_OCF_DRV_STATUS_SUCCESS != - icp_ocfDrvBufferListMemInfo(ICP_OCF_DRV_DEFAULT_BUFFLIST_ARRAYS, - &defBuffListInfo)) { - EPRINTK("Failed to get bufferlist memory info.\n"); - return icp_module_return_code(ENOMEM); - } - - /*Register OCF EP80579 Driver with OCF */ - icp_ocfDrvDriverId = ICP_CRYPTO_GET_DRIVERID(); - - if (icp_ocfDrvDriverId < 0) { - EPRINTK("%s : ICP driver failed to register with OCF!\n", - __FUNCTION__); - return icp_module_return_code(ENODEV); - } - - /*Create all the slab caches used by the OCF EP80579 Driver */ - drvSessionData_zone = - ICP_CACHE_CREATE(ICP_SESSION_DATA_NAME, struct icp_drvSessionData); - - /* - * Allocation of the OpData includes the allocation space for meta data. - * The memory after the opData structure is reserved for this meta data. - */ - drvOpData_zone = - icp_kmem_cache_create(ICP_OP_DATA_NAME, - sizeof(struct icp_drvOpData) + - defBuffListInfo.metaSize, - ICP_KERNEL_CACHE_ALIGN, - ICP_KERNEL_CACHE_NOINIT); - - drvDH_zone = ICP_CACHE_CREATE(ICP_DH_NAME, CpaCyDhPhase1KeyGenOpData); - - drvLnModExp_zone = - ICP_CACHE_CREATE(ICP_MODEXP_NAME, CpaCyLnModExpOpData); - - drvRSADecrypt_zone = - ICP_CACHE_CREATE(ICP_RSA_DECRYPT_NAME, CpaCyRsaDecryptOpData); - - drvRSAPrivateKey_zone = - ICP_CACHE_CREATE(ICP_RSA_PKEY_NAME, CpaCyRsaPrivateKey); - - drvDSARSSign_zone = - ICP_CACHE_CREATE(ICP_DSA_SIGN_NAME, CpaCyDsaRSSignOpData); - - /*too awkward to use a macro here */ - drvDSARSSignKValue_zone = - ICP_CACHE_CREATE(ICP_RAND_VAL_NAME, - DSA_RS_SIGN_PRIMEQ_SIZE_IN_BYTES); - - drvDSAVerify_zone = - ICP_CACHE_CREATE(ICP_DSA_VER_NAME, CpaCyDsaVerifyOpData); - - drvFlatBuffer_zone = - ICP_CACHE_CREATE(ICP_FLAT_BUFF_NAME, CpaFlatBuffer); - - if (0 == icp_cache_null_check()) { - icp_ocfDrvFreeCaches(); - EPRINTK("%s() line %d: Not enough memory!\n", - __FUNCTION__, __LINE__); - return ENOMEM; - } - - /* Register the ICP symmetric crypto support. */ - ICP_REG_SYM_WITH_OCF(icp_ocfDrvDriverId, CRYPTO_NULL_CBC, ocfStatus); - ICP_REG_SYM_WITH_OCF(icp_ocfDrvDriverId, CRYPTO_DES_CBC, ocfStatus); - ICP_REG_SYM_WITH_OCF(icp_ocfDrvDriverId, CRYPTO_3DES_CBC, ocfStatus); - ICP_REG_SYM_WITH_OCF(icp_ocfDrvDriverId, CRYPTO_AES_CBC, ocfStatus); - ICP_REG_SYM_WITH_OCF(icp_ocfDrvDriverId, CRYPTO_ARC4, ocfStatus); - ICP_REG_SYM_WITH_OCF(icp_ocfDrvDriverId, CRYPTO_MD5, ocfStatus); - ICP_REG_SYM_WITH_OCF(icp_ocfDrvDriverId, CRYPTO_MD5_HMAC, ocfStatus); - ICP_REG_SYM_WITH_OCF(icp_ocfDrvDriverId, CRYPTO_SHA1, ocfStatus); - ICP_REG_SYM_WITH_OCF(icp_ocfDrvDriverId, CRYPTO_SHA1_HMAC, ocfStatus); - ICP_REG_SYM_WITH_OCF(icp_ocfDrvDriverId, CRYPTO_SHA2_256, ocfStatus); - ICP_REG_SYM_WITH_OCF(icp_ocfDrvDriverId, CRYPTO_SHA2_256_HMAC, - ocfStatus); - ICP_REG_SYM_WITH_OCF(icp_ocfDrvDriverId, CRYPTO_SHA2_384, ocfStatus); - ICP_REG_SYM_WITH_OCF(icp_ocfDrvDriverId, CRYPTO_SHA2_384_HMAC, - ocfStatus); - ICP_REG_SYM_WITH_OCF(icp_ocfDrvDriverId, CRYPTO_SHA2_512, ocfStatus); - ICP_REG_SYM_WITH_OCF(icp_ocfDrvDriverId, CRYPTO_SHA2_512_HMAC, - ocfStatus); - - /* Register the ICP asymmetric algorithm support */ - ICP_REG_ASYM_WITH_OCF(icp_ocfDrvDriverId, CRK_DH_COMPUTE_KEY, - ocfStatus); - ICP_REG_ASYM_WITH_OCF(icp_ocfDrvDriverId, CRK_MOD_EXP, ocfStatus); - ICP_REG_ASYM_WITH_OCF(icp_ocfDrvDriverId, CRK_MOD_EXP_CRT, ocfStatus); - ICP_REG_ASYM_WITH_OCF(icp_ocfDrvDriverId, CRK_DSA_SIGN, ocfStatus); - ICP_REG_ASYM_WITH_OCF(icp_ocfDrvDriverId, CRK_DSA_VERIFY, ocfStatus); - - /* Register the ICP random number generator support */ - ICP_REG_RAND_WITH_OCF(icp_ocfDrvDriverId, - icp_ocfDrvReadRandom, NULL, ocfStatus); - - if (OCF_ZERO_FUNCTIONALITY_REGISTERED == ocfStatus) { - DPRINTK("%s: Failed to register any device capabilities\n", - __FUNCTION__); - icp_ocfDrvFreeCaches(); - icp_ocfDrvDriverId = INVALID_DRIVER_ID; - return icp_module_return_code(ECANCELED); - } - - DPRINTK("%s: Registered %d of %d device capabilities\n", - __FUNCTION__, ocfStatus, NUM_SUPPORTED_CAPABILITIES); - - /*Session data linked list used during module exit */ - ICP_INIT_LIST_HEAD(&icp_ocfDrvGlobalSymListHead); - ICP_INIT_LIST_HEAD(&icp_ocfDrvGlobalSymListHead_FreeMemList); - - ICP_WORKQUEUE_CREATE(icp_ocfDrvFreeLacSessionWorkQ, "icpwq"); - if (ICP_WORKQUEUE_NULL_CHECK(icp_ocfDrvFreeLacSessionWorkQ)) { - EPRINTK("%s: Failed to create single " - "thread workqueue\n", __FUNCTION__); - icp_ocfDrvFreeCaches(); - icp_ocfDrvDriverId = INVALID_DRIVER_ID; - return icp_module_return_code(ENOMEM); - } - - return icp_module_return_code(0); -} - -/* Name : icp_ocfDrvExit - * - * Description : This function will deregister all the symmetric sessions - * registered with the LAC component. It will also deregister all symmetric - * and asymmetric functionality that can be accelerated by the hardware via OCF - * and random number generation if it is enabled. - */ -ICP_MODULE_EXIT_FUNC(icp_ocfDrvExit) -{ - CpaStatus lacStatus = CPA_STATUS_SUCCESS; - struct icp_drvSessionData *sessionData = NULL; - struct icp_drvSessionData *tempSessionData = NULL; - int i, remaining_delay_time_in_jiffies = 0; - - /* For FreeBSD the invariant macro below makes function to return */ - /* with EBUSY value in the case of any session which has been regi- */ - /* stered with LAC not being deregistered. */ - /* The Linux implementation is empty since it is purely to compensate */ - /* for a limitation of the FreeBSD 7.1 Opencrypto framework. */ - - ICP_MODULE_EXIT_INV(); - - /* There is a possibility of a process or new session command being */ - /* sent before this variable is incremented. The aim of this variable */ - /* is to stop a loop of calls creating a deadlock situation which */ - /* would prevent the driver from exiting. */ - icp_atomic_set(&icp_ocfDrvIsExiting, 1); - - /*Existing sessions will be routed to another driver after these calls */ - crypto_unregister_all(icp_ocfDrvDriverId); - crypto_runregister_all(icp_ocfDrvDriverId); - - if (ICP_WORKQUEUE_NULL_CHECK(icp_ocfDrvFreeLacSessionWorkQ)) { - DPRINTK("%s: workqueue already " - "destroyed, therefore module exit " - " function already called. Exiting.\n", __FUNCTION__); - return ICP_MODULE_EXIT_FUNC_RETURN_VAL; - } - /*If any sessions are waiting to be deregistered, do that. This also - flushes the work queue */ - ICP_WORKQUEUE_DESTROY(icp_ocfDrvFreeLacSessionWorkQ); - - /*ENTER CRITICAL SECTION */ - icp_spin_lockbh_lock(&icp_ocfDrvSymSessInfoListSpinlock); - - ICP_LIST_FOR_EACH_ENTRY_SAFE(tempSessionData, sessionData, - &icp_ocfDrvGlobalSymListHead, listNode) { - for (i = 0; i < num_dereg_retries; i++) { - /*No harm if bad input - LAC will handle error cases */ - if (ICP_SESSION_RUNNING == tempSessionData->inUse) { - lacStatus = - cpaCySymRemoveSession - (CPA_INSTANCE_HANDLE_SINGLE, - tempSessionData->sessHandle); - if (CPA_STATUS_SUCCESS == lacStatus) { - /* Succesfully deregistered */ - break; - } else if (CPA_STATUS_RETRY != lacStatus) { - icp_atomic_inc - (&lac_session_failed_dereg_count); - break; - } - - /*schedule_timout returns the time left for completion if - * this task is set to TASK_INTERRUPTIBLE */ - remaining_delay_time_in_jiffies = - dereg_retry_delay_in_jiffies; - while (0 > remaining_delay_time_in_jiffies) { - remaining_delay_time_in_jiffies = - icp_schedule_timeout - (&icp_ocfDrvSymSessInfoListSpinlock, - remaining_delay_time_in_jiffies); - } - - DPRINTK - ("%s(): Retry %d to deregistrate the session\n", - __FUNCTION__, i); - } - } - - /*remove from current list */ - ICP_LIST_DEL(tempSessionData, listNode); - /*add to free mem linked list */ - ICP_LIST_ADD(tempSessionData, - &icp_ocfDrvGlobalSymListHead_FreeMemList, - listNode); - - } - - /*EXIT CRITICAL SECTION */ - icp_spin_lockbh_unlock(&icp_ocfDrvSymSessInfoListSpinlock); - - /*set back to initial values */ - sessionData = NULL; - /*still have a reference in our list! */ - tempSessionData = NULL; - /*free memory */ - - ICP_LIST_FOR_EACH_ENTRY_SAFE(tempSessionData, sessionData, - &icp_ocfDrvGlobalSymListHead_FreeMemList, - listNode) { - - ICP_LIST_DEL(tempSessionData, listNode); - /* Free allocated CpaCySymSessionCtx */ - if (NULL != tempSessionData->sessHandle) { - icp_kfree(tempSessionData->sessHandle); - } - memset(tempSessionData, 0, sizeof(struct icp_drvSessionData)); - ICP_CACHE_FREE(drvSessionData_zone, tempSessionData); - } - - if (0 != icp_atomic_read(&lac_session_failed_dereg_count)) { - DPRINTK("%s(): %d LAC sessions were not deregistered " - "correctly. This is not a clean exit! \n", - __FUNCTION__, - icp_atomic_read(&lac_session_failed_dereg_count)); - } - - icp_ocfDrvFreeCaches(); - icp_ocfDrvDriverId = INVALID_DRIVER_ID; - - icp_spin_lock_destroy(&icp_ocfDrvSymSessInfoListSpinlock); - - /* Shutdown the Cryptographic component */ - lacStatus = cpaCyStopInstance(CPA_INSTANCE_HANDLE_SINGLE); - if (CPA_STATUS_SUCCESS != lacStatus) { - DPRINTK("%s(): Failed to stop instance of the " - "Cryptographic component.(status == %d)\n", - __FUNCTION__, lacStatus); - } - - return ICP_MODULE_EXIT_FUNC_RETURN_VAL; -} - -/* Name : icp_ocfDrvFreeCaches - * - * Description : This function deregisters all slab caches - */ -static void icp_ocfDrvFreeCaches(void) -{ - icp_atomic_set(&icp_ocfDrvIsExiting, 1); - - /*Sym Zones */ - ICP_CACHE_DESTROY(drvSessionData_zone); - ICP_CACHE_DESTROY(drvOpData_zone); - - /*Asym zones */ - ICP_CACHE_DESTROY(drvDH_zone); - ICP_CACHE_DESTROY(drvLnModExp_zone); - ICP_CACHE_DESTROY(drvRSADecrypt_zone); - ICP_CACHE_DESTROY(drvRSAPrivateKey_zone); - ICP_CACHE_DESTROY(drvDSARSSignKValue_zone); - ICP_CACHE_DESTROY(drvDSARSSign_zone); - ICP_CACHE_DESTROY(drvDSAVerify_zone); - - /*FlatBuffer and BufferList Zones */ - ICP_CACHE_DESTROY(drvFlatBuffer_zone); - -} - -/* Name : icp_ocfDrvDeregRetry - * - * Description : This function will try to farm the session deregistration - * off to a work queue. If it fails, nothing more can be done and it - * returns an error - */ -int icp_ocfDrvDeregRetry(CpaCySymSessionCtx sessionToDeregister) -{ - struct icp_ocfDrvFreeLacSession *workstore = NULL; - - DPRINTK("%s(): Retry - Deregistering session (%p)\n", - __FUNCTION__, sessionToDeregister); - - /*make sure the session is not available to be allocated during this - process */ - icp_atomic_inc(&lac_session_failed_dereg_count); - - /*Farm off to work queue */ - workstore = - icp_kmalloc(sizeof(struct icp_ocfDrvFreeLacSession), ICP_M_NOWAIT); - if (NULL == workstore) { - DPRINTK("%s(): unable to free session - no memory available " - "for work queue\n", __FUNCTION__); - return ENOMEM; - } - - workstore->sessionToDeregister = sessionToDeregister; - - icp_init_work(&(workstore->work), - icp_ocfDrvDeferedFreeLacSessionTaskFn, workstore); - - ICP_WORKQUEUE_ENQUEUE(icp_ocfDrvFreeLacSessionWorkQ, - &(workstore->work)); - - return ICP_OCF_DRV_STATUS_SUCCESS; - -} - -/* Name : icp_ocfDrvDeferedFreeLacSessionProcess - * - * Description : This function will retry (module input parameter) - * 'num_dereg_retries' times to deregister any symmetric session that recieves a - * CPA_STATUS_RETRY message from the LAC component. This function is run in - * Thread context because it is called from a worker thread - */ -void icp_ocfDrvDeferedFreeLacSessionProcess(void *arg) -{ - struct icp_ocfDrvFreeLacSession *workstore = NULL; - CpaCySymSessionCtx sessionToDeregister = NULL; - int i = 0; - int remaining_delay_time_in_jiffies = 0; - CpaStatus lacStatus = CPA_STATUS_SUCCESS; - - workstore = (struct icp_ocfDrvFreeLacSession *)arg; - if (NULL == workstore) { - DPRINTK("%s() function called with null parameter \n", - __FUNCTION__); - return; - } - - sessionToDeregister = workstore->sessionToDeregister; - icp_kfree(workstore); - - /*if exiting, give deregistration one more blast only */ - if (icp_atomic_read(&icp_ocfDrvIsExiting) == CPA_TRUE) { - lacStatus = cpaCySymRemoveSession(CPA_INSTANCE_HANDLE_SINGLE, - sessionToDeregister); - - if (lacStatus != CPA_STATUS_SUCCESS) { - DPRINTK("%s() Failed to Dereg LAC session %p " - "during module exit\n", __FUNCTION__, - sessionToDeregister); - return; - } - - icp_atomic_dec(&lac_session_failed_dereg_count); - return; - } - - for (i = 0; i <= num_dereg_retries; i++) { - lacStatus = cpaCySymRemoveSession(CPA_INSTANCE_HANDLE_SINGLE, - sessionToDeregister); - - if (lacStatus == CPA_STATUS_SUCCESS) { - icp_atomic_dec(&lac_session_failed_dereg_count); - return; - } - if (lacStatus != CPA_STATUS_RETRY) { - DPRINTK("%s() Failed to deregister session - lacStatus " - " = %d", __FUNCTION__, lacStatus); - break; - } - - /*schedule_timout returns the time left for completion if this - task is set to TASK_INTERRUPTIBLE */ - remaining_delay_time_in_jiffies = dereg_retry_delay_in_jiffies; - while (0 < remaining_delay_time_in_jiffies) { - remaining_delay_time_in_jiffies = - icp_schedule_timeout(NULL, - remaining_delay_time_in_jiffies); - } - - } - - DPRINTK("%s(): Unable to deregister session\n", __FUNCTION__); - DPRINTK("%s(): Number of unavailable LAC sessions = %d\n", __FUNCTION__, - icp_atomic_read(&lac_session_failed_dereg_count)); -} - -/* Name : icp_ocfDrvPtrAndLenToFlatBuffer - * - * Description : This function converts a "pointer and length" buffer - * structure to Fredericksburg Flat Buffer (CpaFlatBuffer) format. - * - * This function assumes that the data passed in are valid. - */ -inline void -icp_ocfDrvPtrAndLenToFlatBuffer(void *pData, uint32_t len, - CpaFlatBuffer * pFlatBuffer) -{ - pFlatBuffer->pData = pData; - pFlatBuffer->dataLenInBytes = len; -} - -/* Name : icp_ocfDrvPtrAndLenToBufferList - * - * Description : This function converts a "pointer and length" buffer - * structure to Fredericksburg Scatter/Gather Buffer (CpaBufferList) format. - * - * This function assumes that the data passed in are valid. - */ -inline void -icp_ocfDrvPtrAndLenToBufferList(void *pDataIn, uint32_t length, - CpaBufferList * pBufferList) -{ - pBufferList->numBuffers = 1; - pBufferList->pBuffers->pData = pDataIn; - pBufferList->pBuffers->dataLenInBytes = length; -} - -/* Name : icp_ocfDrvBufferListToPtrAndLen - * - * Description : This function converts Fredericksburg Scatter/Gather Buffer - * (CpaBufferList) format to a "pointer and length" buffer structure. - * - * This function assumes that the data passed in are valid. - */ -inline void -icp_ocfDrvBufferListToPtrAndLen(CpaBufferList * pBufferList, - void **ppDataOut, uint32_t * pLength) -{ - *ppDataOut = pBufferList->pBuffers->pData; - *pLength = pBufferList->pBuffers->dataLenInBytes; -} - -/* Name : icp_ocfDrvBufferListMemInfo - * - * Description : This function will set the number of flat buffers in - * bufferlist, the size of memory to allocate for the pPrivateMetaData - * member of the CpaBufferList. - */ -int -icp_ocfDrvBufferListMemInfo(uint16_t numBuffers, - struct icp_drvBuffListInfo *buffListInfo) -{ - buffListInfo->numBuffers = numBuffers; - - if (CPA_STATUS_SUCCESS != - cpaCyBufferListGetMetaSize(CPA_INSTANCE_HANDLE_SINGLE, - buffListInfo->numBuffers, - &(buffListInfo->metaSize))) { - EPRINTK("%s() Failed to get buffer list meta size.\n", - __FUNCTION__); - return ICP_OCF_DRV_STATUS_FAIL; - } - - return ICP_OCF_DRV_STATUS_SUCCESS; -} - -/* Name : icp_ocfDrvFreeFlatBuffer - * - * Description : This function will deallocate flat buffer. - */ -inline void icp_ocfDrvFreeFlatBuffer(CpaFlatBuffer * pFlatBuffer) -{ - if (pFlatBuffer != NULL) { - memset(pFlatBuffer, 0, sizeof(CpaFlatBuffer)); - ICP_CACHE_FREE(drvFlatBuffer_zone, pFlatBuffer); - } -} - -/* Name : icp_ocfDrvAllocMetaData - * - * Description : This function will allocate memory for the - * pPrivateMetaData member of CpaBufferList. - */ -inline int -icp_ocfDrvAllocMetaData(CpaBufferList * pBufferList, - struct icp_drvOpData *pOpData) -{ - Cpa32U metaSize = 0; - - if (pBufferList->numBuffers <= ICP_OCF_DRV_DEFAULT_BUFFLIST_ARRAYS) { - uint8_t *pOpDataStartAddr = (uint8_t *) pOpData; - - if (0 == defBuffListInfo.metaSize) { - pBufferList->pPrivateMetaData = NULL; - return ICP_OCF_DRV_STATUS_SUCCESS; - } - /* - * The meta data allocation has been included as part of the - * op data. It has been pre-allocated in memory just after the - * icp_drvOpData structure. - */ - pBufferList->pPrivateMetaData = (void *)(pOpDataStartAddr + - sizeof(struct - icp_drvOpData)); - } else { - if (CPA_STATUS_SUCCESS != - cpaCyBufferListGetMetaSize(CPA_INSTANCE_HANDLE_SINGLE, - pBufferList->numBuffers, - &metaSize)) { - EPRINTK("%s() Failed to get buffer list meta size.\n", - __FUNCTION__); - return ICP_OCF_DRV_STATUS_FAIL; - } - - if (0 == metaSize) { - pBufferList->pPrivateMetaData = NULL; - return ICP_OCF_DRV_STATUS_SUCCESS; - } - - pBufferList->pPrivateMetaData = - icp_kmalloc(metaSize, ICP_M_NOWAIT); - } - if (NULL == pBufferList->pPrivateMetaData) { - EPRINTK("%s() Failed to allocate pPrivateMetaData.\n", - __FUNCTION__); - return ICP_OCF_DRV_STATUS_FAIL; - } - - return ICP_OCF_DRV_STATUS_SUCCESS; -} - -/* Name : icp_ocfDrvFreeMetaData - * - * Description : This function will deallocate pPrivateMetaData memory. - */ -inline void icp_ocfDrvFreeMetaData(CpaBufferList * pBufferList) -{ - if (NULL == pBufferList->pPrivateMetaData) { - return; - } - - /* - * Only free the meta data if the BufferList has more than - * ICP_OCF_DRV_DEFAULT_BUFFLIST_ARRAYS number of buffers. - * Otherwise, the meta data shall be freed when the icp_drvOpData is - * freed. - */ - if (ICP_OCF_DRV_DEFAULT_BUFFLIST_ARRAYS < pBufferList->numBuffers) { - icp_kfree(pBufferList->pPrivateMetaData); - } -} - -/* Module declaration, init and exit functions */ -ICP_DECLARE_MODULE(icp_ocf, icp_ocfDrvInit, icp_ocfDrvExit); -ICP_MODULE_DESCRIPTION("OCF Driver for Intel Quick Assist crypto acceleration"); -ICP_MODULE_VERSION(icp_ocf, ICP_OCF_VER_MJR); -ICP_MODULE_LICENSE("Dual BSD/GPL"); -ICP_MODULE_AUTHOR("Intel"); - -/* Module parameters */ -ICP_MODULE_PARAM_INT(icp_ocf, num_dereg_retries, - "Number of times to retry LAC Sym Session Deregistration. " - "Default 10, Max 100"); -ICP_MODULE_PARAM_INT(icp_ocf, dereg_retry_delay_in_jiffies, "Delay in jiffies " - "(added to a schedule() function call) before a LAC Sym " - "Session Dereg is retried. Default 10"); -ICP_MODULE_PARAM_INT(icp_ocf, max_sessions, - "This sets the maximum number of sessions " - "between OCF and this driver. If this value is set to zero," - "max session count checking is disabled. Default is zero(0)"); - -/* Module dependencies */ -#define MODULE_MIN_VER 1 -#define CRYPTO_MAX_VER 3 -#define LAC_MAX_VER 2 - -ICP_MODULE_DEPEND(icp_ocf, crypto, MODULE_MIN_VER, MODULE_MIN_VER, - CRYPTO_MAX_VER); -ICP_MODULE_DEPEND(icp_ocf, cryptodev, MODULE_MIN_VER, MODULE_MIN_VER, - CRYPTO_MAX_VER); -ICP_MODULE_DEPEND(icp_ocf, icp_crypto, MODULE_MIN_VER, MODULE_MIN_VER, - LAC_MAX_VER); diff --git a/target/linux/generic-2.4/files/crypto/ocf/ep80579/icp_ocf.h b/target/linux/generic-2.4/files/crypto/ocf/ep80579/icp_ocf.h deleted file mode 100644 index d9dde87..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/ep80579/icp_ocf.h +++ /dev/null @@ -1,376 +0,0 @@ -/*************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Corporation - * - * BSD LICENSE - * - * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - * version: Security.L.1.0.2-229 - * - ***************************************************************************/ - -/* - * OCF driver header file for the Intel ICP processor. - */ - -#ifndef ICP_OCF_H_ -#define ICP_OCF_H_ - -#include <cpa.h> -#include <cpa_cy_im.h> -#include <cpa_cy_sym.h> -#include <cpa_cy_rand.h> -#include <cpa_cy_dh.h> -#include <cpa_cy_rsa.h> -#include <cpa_cy_ln.h> -#include <cpa_cy_common.h> -#include <cpa_cy_dsa.h> - -#include "icp_os.h" - -#define NUM_BITS_IN_BYTE (8) -#define NUM_BITS_IN_BYTE_MINUS_ONE (NUM_BITS_IN_BYTE -1) -#define INVALID_DRIVER_ID (-1) -#define RETURN_RAND_NUM_GEN_FAILED (-1) - -/*This is the max block cipher initialisation vector*/ -#define MAX_IV_LEN_IN_BYTES (20) -/*This is used to check whether the OCF to this driver session limit has - been disabled*/ -#define NO_OCF_TO_DRV_MAX_SESSIONS (0) - -/*OCF values mapped here*/ -#define ICP_SHA1_DIGEST_SIZE_IN_BYTES (SHA1_HASH_LEN) -#define ICP_SHA256_DIGEST_SIZE_IN_BYTES (SHA2_256_HASH_LEN) -#define ICP_SHA384_DIGEST_SIZE_IN_BYTES (SHA2_384_HASH_LEN) -#define ICP_SHA512_DIGEST_SIZE_IN_BYTES (SHA2_512_HASH_LEN) -#define ICP_MD5_DIGEST_SIZE_IN_BYTES (MD5_HASH_LEN) -#define ARC4_COUNTER_LEN (ARC4_BLOCK_LEN) - -#define OCF_REGISTRATION_STATUS_SUCCESS (0) -#define OCF_ZERO_FUNCTIONALITY_REGISTERED (0) -#define ICP_OCF_DRV_NO_CRYPTO_PROCESS_ERROR (0) -#define ICP_OCF_DRV_STATUS_SUCCESS (0) -#define ICP_OCF_DRV_STATUS_FAIL (1) - -/*Turn on/off debug options*/ -#define ICP_OCF_PRINT_DEBUG_MESSAGES (0) -#define ICP_OCF_PRINT_KERN_ALERT (1) -#define ICP_OCF_PRINT_KERN_ERRS (1) - -#if ICP_OCF_PRINT_DEBUG_MESSAGES == 1 -#define DPRINTK(args...) \ -{ \ - ICP_IPRINTK(args); \ -} - -#else //ICP_OCF_PRINT_DEBUG_MESSAGES == 1 - -#define DPRINTK(args...) - -#endif //ICP_OCF_PRINT_DEBUG_MESSAGES == 1 - -#if ICP_OCF_PRINT_KERN_ALERT == 1 -#define APRINTK(args...) \ -{ \ - ICP_APRINTK(args); \ -} - -#else //ICP_OCF_PRINT_KERN_ALERT == 1 - -#define APRINTK(args...) - -#endif //ICP_OCF_PRINT_KERN_ALERT == 1 - -#if ICP_OCF_PRINT_KERN_ERRS == 1 -#define EPRINTK(args...) \ -{ \ - ICP_EPRINTK(args); \ -} - -#else //ICP_OCF_PRINT_KERN_ERRS == 1 - -#define EPRINTK(args...) - -#endif //ICP_OCF_PRINT_KERN_ERRS == 1 - -#define IPRINTK(args...) \ -{ \ - ICP_IPRINTK(args); \ -} - -/*DSA Prime Q size in bytes (as defined in the standard) */ -#define DSA_RS_SIGN_PRIMEQ_SIZE_IN_BYTES (20) - -#define BITS_TO_BYTES(bytes, bits) \ - bytes = (bits + NUM_BITS_IN_BYTE_MINUS_ONE) / NUM_BITS_IN_BYTE - -typedef enum { - ICP_OCF_DRV_ALG_CIPHER = 0, - ICP_OCF_DRV_ALG_HASH -} icp_ocf_drv_alg_type_t; - -typedef ICP_LIST_HEAD(icp_drvSessionListHead_s, - icp_drvSessionData) icp_drvSessionListHead_t; - -/*Values used to derisk chances of performs being called against -deregistered sessions (for which the slab page has been reclaimed) -This is not a fix - since page frames are reclaimed from a slab, one cannot -rely on that memory not being re-used by another app.*/ -typedef enum { - ICP_SESSION_INITIALISED = 0x5C5C5C, - ICP_SESSION_RUNNING = 0x005C00, - ICP_SESSION_DEREGISTERED = 0xC5C5C5 -} usage_derisk; - -/* This struct is required for deferred session - deregistration as a work queue function can - only have one argument*/ -struct icp_ocfDrvFreeLacSession { - CpaCySymSessionCtx sessionToDeregister; - icp_workstruct work; -}; - -/* -This is the OCF<->OCF_DRV session object: - -1.listNode - The first member is a listNode. These session objects are added to a linked - list in order to make it easier to remove them all at session exit time. - -2.inUse - The second member is used to give the session object state and derisk the - possibility of OCF batch calls executing against a deregistered session (as - described above). - -3.sessHandle - The third member is a LAC<->OCF_DRV session handle (initialised with the first - perform request for that session). - -4.lacSessCtx - The fourth is the LAC session context. All the parameters for this structure - are only known when the first perform request for this session occurs. That is - why the OCF EP80579 Driver only registers a new LAC session at perform time -*/ -struct icp_drvSessionData { - ICP_LIST_ENTRY(icp_drvSessionData) listNode; - usage_derisk inUse; - CpaCySymSessionCtx sessHandle; - CpaCySymSessionSetupData lacSessCtx; -}; - -/* These are all defined in icp_common.c */ -extern icp_atomic_t lac_session_failed_dereg_count; -extern icp_atomic_t icp_ocfDrvIsExiting; -extern icp_atomic_t num_ocf_to_drv_registered_sessions; - -extern int32_t icp_ocfDrvDriverId; - -extern icp_drvSessionListHead_t icp_ocfDrvGlobalSymListHead; -extern icp_drvSessionListHead_t icp_ocfDrvGlobalSymListHead_FreeMemList; -extern icp_workqueue *icp_ocfDrvFreeLacSessionWorkQ; -extern icp_spinlock_t icp_ocfDrvSymSessInfoListSpinlock; - -/*Slab zones for symettric functionality, instantiated in icp_common.c*/ -extern icp_kmem_cache drvSessionData_zone; -extern icp_kmem_cache drvOpData_zone; - -/*Slabs zones for asymettric functionality, instantiated in icp_common.c*/ -extern icp_kmem_cache drvDH_zone; -extern icp_kmem_cache drvLnModExp_zone; -extern icp_kmem_cache drvRSADecrypt_zone; -extern icp_kmem_cache drvRSAPrivateKey_zone; -extern icp_kmem_cache drvDSARSSign_zone; -extern icp_kmem_cache drvDSARSSignKValue_zone; -extern icp_kmem_cache drvDSAVerify_zone; - -/* Module parameters defined in icp_cpmmon.c*/ - -/* Module parameters - gives the number of times LAC deregistration shall be - re-tried */ -extern int num_dereg_retries; - -/* Module parameter - gives the delay time in jiffies before a LAC session - shall be attempted to be deregistered again */ -extern int dereg_retry_delay_in_jiffies; - -/* Module parameter - gives the maximum number of sessions possible between - OCF and the OCF EP80579 Driver. If set to zero, there is no limit.*/ -extern int max_sessions; - -/*Slab zones for flatbuffers and bufferlist*/ -extern icp_kmem_cache drvFlatBuffer_zone; - -#define ICP_OCF_DRV_DEFAULT_BUFFLIST_ARRAYS (16) - -struct icp_drvBuffListInfo { - Cpa16U numBuffers; - Cpa32U metaSize; - Cpa32U metaOffset; - Cpa32U buffListSize; -}; - -extern struct icp_drvBuffListInfo defBuffListInfo; - -/* This struct is used to keep a reference to the relevant node in the list - of sessionData structs, to the buffer type required by OCF and to the OCF - provided crp struct that needs to be returned. All this info is needed in - the callback function.*/ -struct icp_drvOpData { - CpaCySymOpData lacOpData; - uint32_t digestSizeInBytes; - struct cryptop *crp; - uint8_t bufferType; - uint8_t ivData[MAX_IV_LEN_IN_BYTES]; - uint16_t numBufferListArray; - CpaBufferList srcBuffer; - CpaFlatBuffer bufferListArray[ICP_OCF_DRV_DEFAULT_BUFFLIST_ARRAYS]; - CpaBoolean verifyResult; -}; - -/* Create a new session between OCF and this driver*/ -int icp_ocfDrvNewSession(icp_device_t dev, uint32_t * sild, - struct cryptoini *cri); - -/* Free a session between this driver and the Quick Assist Framework*/ -int icp_ocfDrvFreeLACSession(icp_device_t dev, uint64_t sid); - -/* Defer freeing a Quick Assist session*/ -void icp_ocfDrvDeferedFreeLacSessionProcess(void *arg); - -/* Process OCF cryptographic request for a symmetric algorithm*/ -int icp_ocfDrvSymProcess(icp_device_t dev, struct cryptop *crp, int hint); - -/* Process OCF cryptographic request for an asymmetric algorithm*/ -int icp_ocfDrvPkeProcess(icp_device_t dev, struct cryptkop *krp, int hint); - -/* Populate a buffer with random data*/ -int icp_ocfDrvReadRandom(void *arg, uint32_t * buf, int maxwords); - -/* Retry Quick Assist session deregistration*/ -int icp_ocfDrvDeregRetry(CpaCySymSessionCtx sessionToDeregister); - -/* Convert an OS scatter gather list to a CPA buffer list*/ -int icp_ocfDrvPacketBuffToBufferList(icp_packet_buffer_t * pPacketBuffer, - CpaBufferList * bufferList); - -/* Convert a CPA buffer list to an OS scatter gather list*/ -int icp_ocfDrvBufferListToPacketBuff(CpaBufferList * bufferList, - icp_packet_buffer_t ** pPacketBuffer); - -/* Get the number of buffers in an OS scatter gather list*/ -uint16_t icp_ocfDrvGetPacketBuffFrags(icp_packet_buffer_t * pPacketBuffer); - -/* Convert a single OS buffer to a CPA Flat Buffer*/ -void icp_ocfDrvSinglePacketBuffToFlatBuffer(icp_packet_buffer_t * pPacketBuffer, - CpaFlatBuffer * pFlatBuffer); - -/* Add pointer and length to a CPA Flat Buffer structure*/ -void icp_ocfDrvPtrAndLenToFlatBuffer(void *pData, uint32_t len, - CpaFlatBuffer * pFlatBuffer); - -/* Convert pointer and length values to a CPA buffer list*/ -void icp_ocfDrvPtrAndLenToBufferList(void *pDataIn, uint32_t length, - CpaBufferList * pBufferList); - -/* Convert a CPA buffer list to pointer and length values*/ -void icp_ocfDrvBufferListToPtrAndLen(CpaBufferList * pBufferList, - void **ppDataOut, uint32_t * pLength); - -/* Set the number of flat buffers in bufferlist and the size of memory - to allocate for the pPrivateMetaData member of the CpaBufferList.*/ -int icp_ocfDrvBufferListMemInfo(uint16_t numBuffers, - struct icp_drvBuffListInfo *buffListInfo); - -/* Find pointer position of the digest within an OS scatter gather list*/ -uint8_t *icp_ocfDrvPacketBufferDigestPointerFind(struct icp_drvOpData - *drvOpData, - int offsetInBytes, - uint32_t digestSizeInBytes); - -/*This top level function is used to find a pointer to where a digest is - stored/needs to be inserted. */ -uint8_t *icp_ocfDrvDigestPointerFind(struct icp_drvOpData *drvOpData, - struct cryptodesc *crp_desc); - -/* Free a CPA flat buffer*/ -void icp_ocfDrvFreeFlatBuffer(CpaFlatBuffer * pFlatBuffer); - -/* This function will allocate memory for the pPrivateMetaData - member of CpaBufferList. */ -int icp_ocfDrvAllocMetaData(CpaBufferList * pBufferList, - struct icp_drvOpData *pOpData); - -/* Free data allocated for the pPrivateMetaData - member of CpaBufferList.*/ -void icp_ocfDrvFreeMetaData(CpaBufferList * pBufferList); - -#define ICP_CACHE_CREATE(cache_ID, cache_name) \ - icp_kmem_cache_create(cache_ID, sizeof(cache_name),ICP_KERNEL_CACHE_ALIGN,\ - ICP_KERNEL_CACHE_NOINIT) - -#define ICP_CACHE_FREE(args...) \ - icp_kmem_cache_free (args) - -#define ICP_CACHE_DESTROY(slab_zone)\ -{\ - if(NULL != slab_zone){\ - icp_kmem_cache_destroy(slab_zone);\ - slab_zone = NULL;\ - }\ -} - -#endif -/* ICP_OCF_H_ */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/ep80579/icp_sym.c b/target/linux/generic-2.4/files/crypto/ocf/ep80579/icp_sym.c deleted file mode 100644 index e1c7148..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/ep80579/icp_sym.c +++ /dev/null @@ -1,1153 +0,0 @@ -/*************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Corporation - * - * BSD LICENSE - * - * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - * version: Security.L.1.0.2-229 - * - ***************************************************************************/ -/* - * An OCF module that uses the API for Intel® QuickAssist Technology to do the - * cryptography. - * - * This driver requires the ICP Access Library that is available from Intel in - * order to operate. - */ - -#include "icp_ocf.h" - -/*This is the call back function for all symmetric cryptographic processes. - Its main functionality is to free driver crypto operation structure and to - call back to OCF*/ -static void -icp_ocfDrvSymCallBack(void *callbackTag, - CpaStatus status, - const CpaCySymOp operationType, - void *pOpData, - CpaBufferList * pDstBuffer, CpaBoolean verifyResult); - -/*This function is used to extract crypto processing information from the OCF - inputs, so as that it may be passed onto LAC*/ -static int -icp_ocfDrvProcessDataSetup(struct icp_drvOpData *drvOpData, - struct cryptodesc *crp_desc); - -/*This function checks whether the crp_desc argument pertains to a digest or a - cipher operation*/ -static int icp_ocfDrvAlgCheck(struct cryptodesc *crp_desc); - -/*This function copies all the passed in session context information and stores - it in a LAC context structure*/ -static int -icp_ocfDrvAlgorithmSetup(struct cryptoini *cri, - CpaCySymSessionSetupData * lacSessCtx); - -/*This function is used to free an OCF->OCF_DRV session object*/ -static void icp_ocfDrvFreeOCFSession(struct icp_drvSessionData *sessionData); - -/*max IOV buffs supported in a UIO structure*/ -#define NUM_IOV_SUPPORTED (1) - -/* Name : icp_ocfDrvSymCallBack - * - * Description : When this function returns it signifies that the LAC - * component has completed the relevant symmetric operation. - * - * Notes : The callbackTag is a pointer to an icp_drvOpData. This memory - * object was passed to LAC for the cryptographic processing and contains all - * the relevant information for cleaning up buffer handles etc. so that the - * OCF EP80579 Driver portion of this crypto operation can be fully completed. - */ -static void -icp_ocfDrvSymCallBack(void *callbackTag, - CpaStatus status, - const CpaCySymOp operationType, - void *pOpData, - CpaBufferList * pDstBuffer, CpaBoolean verifyResult) -{ - struct cryptop *crp = NULL; - struct icp_drvOpData *temp_drvOpData = - (struct icp_drvOpData *)callbackTag; - uint64_t *tempBasePtr = NULL; - uint32_t tempLen = 0; - - if (NULL == temp_drvOpData) { - DPRINTK("%s(): The callback from the LAC component" - " has failed due to Null userOpaque data" - "(status == %d).\n", __FUNCTION__, status); - DPRINTK("%s(): Unable to call OCF back! \n", __FUNCTION__); - return; - } - - crp = temp_drvOpData->crp; - crp->crp_etype = ICP_OCF_DRV_NO_CRYPTO_PROCESS_ERROR; - - if (NULL == pOpData) { - DPRINTK("%s(): The callback from the LAC component" - " has failed due to Null Symmetric Op data" - "(status == %d).\n", __FUNCTION__, status); - crp->crp_etype = ECANCELED; - crypto_done(crp); - return; - } - - if (NULL == pDstBuffer) { - DPRINTK("%s(): The callback from the LAC component" - " has failed due to Null Dst Bufferlist data" - "(status == %d).\n", __FUNCTION__, status); - crp->crp_etype = ECANCELED; - crypto_done(crp); - return; - } - - if (CPA_STATUS_SUCCESS == status) { - - if (temp_drvOpData->bufferType == ICP_CRYPTO_F_PACKET_BUF) { - if (ICP_OCF_DRV_STATUS_SUCCESS != - icp_ocfDrvBufferListToPacketBuff(pDstBuffer, - (icp_packet_buffer_t - **) - & (crp->crp_buf))) { - EPRINTK("%s(): BufferList to SkBuff " - "conversion error.\n", __FUNCTION__); - crp->crp_etype = EPERM; - } - } else { - icp_ocfDrvBufferListToPtrAndLen(pDstBuffer, - (void **)&tempBasePtr, - &tempLen); - crp->crp_olen = (int)tempLen; - } - - } else { - DPRINTK("%s(): The callback from the LAC component has failed" - "(status == %d).\n", __FUNCTION__, status); - - crp->crp_etype = ECANCELED; - } - - if (temp_drvOpData->numBufferListArray > - ICP_OCF_DRV_DEFAULT_BUFFLIST_ARRAYS) { - icp_kfree(pDstBuffer->pBuffers); - } - icp_ocfDrvFreeMetaData(pDstBuffer); - ICP_CACHE_FREE(drvOpData_zone, temp_drvOpData); - - /* Invoke the OCF callback function */ - crypto_done(crp); - - return; -} - -/* Name : icp_ocfDrvNewSession - * - * Description : This function will create a new Driver<->OCF session - * - * Notes : LAC session registration happens during the first perform call. - * That is the first time we know all information about a given session. - */ -int icp_ocfDrvNewSession(icp_device_t dev, uint32_t * sid, - struct cryptoini *cri) -{ - struct icp_drvSessionData *sessionData = NULL; - uint32_t delete_session = 0; - - /* The SID passed in should be our driver ID. We can return the */ - /* local ID (LID) which is a unique identifier which we can use */ - /* to differentiate between the encrypt/decrypt LAC session handles */ - if (NULL == sid) { - EPRINTK("%s(): Invalid input parameters - NULL sid.\n", - __FUNCTION__); - return EINVAL; - } - - if (NULL == cri) { - EPRINTK("%s(): Invalid input parameters - NULL cryptoini.\n", - __FUNCTION__); - return EINVAL; - } - - if (icp_ocfDrvDriverId != *sid) { - EPRINTK("%s(): Invalid input parameters - bad driver ID\n", - __FUNCTION__); - EPRINTK("\t sid = 0x08%p \n \t cri = 0x08%p \n", sid, cri); - return EINVAL; - } - - sessionData = icp_kmem_cache_zalloc(drvSessionData_zone, ICP_M_NOWAIT); - if (NULL == sessionData) { - DPRINTK("%s():No memory for Session Data\n", __FUNCTION__); - return ENOMEM; - } - - /*ENTER CRITICAL SECTION */ - icp_spin_lockbh_lock(&icp_ocfDrvSymSessInfoListSpinlock); - /*put this check in the spinlock so no new sessions can be added to the - linked list when we are exiting */ - if (CPA_TRUE == icp_atomic_read(&icp_ocfDrvIsExiting)) { - delete_session++; - - } else if (NO_OCF_TO_DRV_MAX_SESSIONS != max_sessions) { - if (icp_atomic_read(&num_ocf_to_drv_registered_sessions) >= - (max_sessions - - icp_atomic_read(&lac_session_failed_dereg_count))) { - delete_session++; - } else { - icp_atomic_inc(&num_ocf_to_drv_registered_sessions); - /* Add to session data linked list */ - ICP_LIST_ADD(sessionData, &icp_ocfDrvGlobalSymListHead, - listNode); - } - - } else if (NO_OCF_TO_DRV_MAX_SESSIONS == max_sessions) { - ICP_LIST_ADD(sessionData, &icp_ocfDrvGlobalSymListHead, - listNode); - } - - sessionData->inUse = ICP_SESSION_INITIALISED; - - /*EXIT CRITICAL SECTION */ - icp_spin_lockbh_unlock(&icp_ocfDrvSymSessInfoListSpinlock); - - if (delete_session) { - DPRINTK("%s():No Session handles available\n", __FUNCTION__); - ICP_CACHE_FREE(drvSessionData_zone, sessionData); - return EPERM; - } - - if (ICP_OCF_DRV_STATUS_SUCCESS != - icp_ocfDrvAlgorithmSetup(cri, &(sessionData->lacSessCtx))) { - DPRINTK("%s():algorithm not supported\n", __FUNCTION__); - icp_ocfDrvFreeOCFSession(sessionData); - return EINVAL; - } - - if (cri->cri_next) { - if (cri->cri_next->cri_next != NULL) { - DPRINTK("%s():only two chained algorithms supported\n", - __FUNCTION__); - icp_ocfDrvFreeOCFSession(sessionData); - return EPERM; - } - - if (ICP_OCF_DRV_STATUS_SUCCESS != - icp_ocfDrvAlgorithmSetup(cri->cri_next, - &(sessionData->lacSessCtx))) { - DPRINTK("%s():second algorithm not supported\n", - __FUNCTION__); - icp_ocfDrvFreeOCFSession(sessionData); - return EINVAL; - } - - sessionData->lacSessCtx.symOperation = - CPA_CY_SYM_OP_ALGORITHM_CHAINING; - } - - *sid = (uint32_t) sessionData; - - return ICP_OCF_DRV_STATUS_SUCCESS; -} - -/* Name : icp_ocfDrvAlgorithmSetup - * - * Description : This function builds the session context data from the - * information supplied through OCF. Algorithm chain order and whether the - * session is Encrypt/Decrypt can only be found out at perform time however, so - * the session is registered with LAC at that time. - */ -static int -icp_ocfDrvAlgorithmSetup(struct cryptoini *cri, - CpaCySymSessionSetupData * lacSessCtx) -{ - - lacSessCtx->sessionPriority = CPA_CY_PRIORITY_NORMAL; - - switch (cri->cri_alg) { - - case CRYPTO_NULL_CBC: - DPRINTK("%s(): NULL CBC\n", __FUNCTION__); - lacSessCtx->symOperation = CPA_CY_SYM_OP_CIPHER; - lacSessCtx->cipherSetupData.cipherAlgorithm = - CPA_CY_SYM_CIPHER_NULL; - lacSessCtx->cipherSetupData.cipherKeyLenInBytes = - cri->cri_klen / NUM_BITS_IN_BYTE; - lacSessCtx->cipherSetupData.pCipherKey = cri->cri_key; - break; - - case CRYPTO_DES_CBC: - DPRINTK("%s(): DES CBC\n", __FUNCTION__); - lacSessCtx->symOperation = CPA_CY_SYM_OP_CIPHER; - lacSessCtx->cipherSetupData.cipherAlgorithm = - CPA_CY_SYM_CIPHER_DES_CBC; - lacSessCtx->cipherSetupData.cipherKeyLenInBytes = - cri->cri_klen / NUM_BITS_IN_BYTE; - lacSessCtx->cipherSetupData.pCipherKey = cri->cri_key; - break; - - case CRYPTO_3DES_CBC: - DPRINTK("%s(): 3DES CBC\n", __FUNCTION__); - lacSessCtx->symOperation = CPA_CY_SYM_OP_CIPHER; - lacSessCtx->cipherSetupData.cipherAlgorithm = - CPA_CY_SYM_CIPHER_3DES_CBC; - lacSessCtx->cipherSetupData.cipherKeyLenInBytes = - cri->cri_klen / NUM_BITS_IN_BYTE; - lacSessCtx->cipherSetupData.pCipherKey = cri->cri_key; - break; - - case CRYPTO_AES_CBC: - DPRINTK("%s(): AES CBC\n", __FUNCTION__); - lacSessCtx->symOperation = CPA_CY_SYM_OP_CIPHER; - lacSessCtx->cipherSetupData.cipherAlgorithm = - CPA_CY_SYM_CIPHER_AES_CBC; - lacSessCtx->cipherSetupData.cipherKeyLenInBytes = - cri->cri_klen / NUM_BITS_IN_BYTE; - lacSessCtx->cipherSetupData.pCipherKey = cri->cri_key; - break; - - case CRYPTO_ARC4: - DPRINTK("%s(): ARC4\n", __FUNCTION__); - lacSessCtx->symOperation = CPA_CY_SYM_OP_CIPHER; - lacSessCtx->cipherSetupData.cipherAlgorithm = - CPA_CY_SYM_CIPHER_ARC4; - lacSessCtx->cipherSetupData.cipherKeyLenInBytes = - cri->cri_klen / NUM_BITS_IN_BYTE; - lacSessCtx->cipherSetupData.pCipherKey = cri->cri_key; - break; - - case CRYPTO_SHA1: - DPRINTK("%s(): SHA1\n", __FUNCTION__); - lacSessCtx->symOperation = CPA_CY_SYM_OP_HASH; - lacSessCtx->hashSetupData.hashAlgorithm = CPA_CY_SYM_HASH_SHA1; - lacSessCtx->hashSetupData.hashMode = CPA_CY_SYM_HASH_MODE_PLAIN; - lacSessCtx->hashSetupData.digestResultLenInBytes = - (cri->cri_mlen ? - cri->cri_mlen : ICP_SHA1_DIGEST_SIZE_IN_BYTES); - - break; - - case CRYPTO_SHA1_HMAC: - DPRINTK("%s(): SHA1_HMAC\n", __FUNCTION__); - lacSessCtx->symOperation = CPA_CY_SYM_OP_HASH; - lacSessCtx->hashSetupData.hashAlgorithm = CPA_CY_SYM_HASH_SHA1; - lacSessCtx->hashSetupData.hashMode = CPA_CY_SYM_HASH_MODE_AUTH; - lacSessCtx->hashSetupData.digestResultLenInBytes = - (cri->cri_mlen ? - cri->cri_mlen : ICP_SHA1_DIGEST_SIZE_IN_BYTES); - lacSessCtx->hashSetupData.authModeSetupData.authKey = - cri->cri_key; - lacSessCtx->hashSetupData.authModeSetupData.authKeyLenInBytes = - cri->cri_klen / NUM_BITS_IN_BYTE; - lacSessCtx->hashSetupData.authModeSetupData.aadLenInBytes = 0; - - break; - - case CRYPTO_SHA2_256: - DPRINTK("%s(): SHA256\n", __FUNCTION__); - lacSessCtx->symOperation = CPA_CY_SYM_OP_HASH; - lacSessCtx->hashSetupData.hashAlgorithm = - CPA_CY_SYM_HASH_SHA256; - lacSessCtx->hashSetupData.hashMode = CPA_CY_SYM_HASH_MODE_PLAIN; - lacSessCtx->hashSetupData.digestResultLenInBytes = - (cri->cri_mlen ? - cri->cri_mlen : ICP_SHA256_DIGEST_SIZE_IN_BYTES); - - break; - - case CRYPTO_SHA2_256_HMAC: - DPRINTK("%s(): SHA256_HMAC\n", __FUNCTION__); - lacSessCtx->symOperation = CPA_CY_SYM_OP_HASH; - lacSessCtx->hashSetupData.hashAlgorithm = - CPA_CY_SYM_HASH_SHA256; - lacSessCtx->hashSetupData.hashMode = CPA_CY_SYM_HASH_MODE_AUTH; - lacSessCtx->hashSetupData.digestResultLenInBytes = - (cri->cri_mlen ? - cri->cri_mlen : ICP_SHA256_DIGEST_SIZE_IN_BYTES); - lacSessCtx->hashSetupData.authModeSetupData.authKey = - cri->cri_key; - lacSessCtx->hashSetupData.authModeSetupData.authKeyLenInBytes = - cri->cri_klen / NUM_BITS_IN_BYTE; - lacSessCtx->hashSetupData.authModeSetupData.aadLenInBytes = 0; - - break; - - case CRYPTO_SHA2_384: - DPRINTK("%s(): SHA384\n", __FUNCTION__); - lacSessCtx->symOperation = CPA_CY_SYM_OP_HASH; - lacSessCtx->hashSetupData.hashAlgorithm = - CPA_CY_SYM_HASH_SHA384; - lacSessCtx->hashSetupData.hashMode = CPA_CY_SYM_HASH_MODE_PLAIN; - lacSessCtx->hashSetupData.digestResultLenInBytes = - (cri->cri_mlen ? - cri->cri_mlen : ICP_SHA384_DIGEST_SIZE_IN_BYTES); - - break; - - case CRYPTO_SHA2_384_HMAC: - DPRINTK("%s(): SHA384_HMAC\n", __FUNCTION__); - lacSessCtx->symOperation = CPA_CY_SYM_OP_HASH; - lacSessCtx->hashSetupData.hashAlgorithm = - CPA_CY_SYM_HASH_SHA384; - lacSessCtx->hashSetupData.hashMode = CPA_CY_SYM_HASH_MODE_AUTH; - lacSessCtx->hashSetupData.digestResultLenInBytes = - (cri->cri_mlen ? - cri->cri_mlen : ICP_SHA384_DIGEST_SIZE_IN_BYTES); - lacSessCtx->hashSetupData.authModeSetupData.authKey = - cri->cri_key; - lacSessCtx->hashSetupData.authModeSetupData.authKeyLenInBytes = - cri->cri_klen / NUM_BITS_IN_BYTE; - lacSessCtx->hashSetupData.authModeSetupData.aadLenInBytes = 0; - - break; - - case CRYPTO_SHA2_512: - DPRINTK("%s(): SHA512\n", __FUNCTION__); - lacSessCtx->symOperation = CPA_CY_SYM_OP_HASH; - lacSessCtx->hashSetupData.hashAlgorithm = - CPA_CY_SYM_HASH_SHA512; - lacSessCtx->hashSetupData.hashMode = CPA_CY_SYM_HASH_MODE_PLAIN; - lacSessCtx->hashSetupData.digestResultLenInBytes = - (cri->cri_mlen ? - cri->cri_mlen : ICP_SHA512_DIGEST_SIZE_IN_BYTES); - - break; - - case CRYPTO_SHA2_512_HMAC: - DPRINTK("%s(): SHA512_HMAC\n", __FUNCTION__); - lacSessCtx->symOperation = CPA_CY_SYM_OP_HASH; - lacSessCtx->hashSetupData.hashAlgorithm = - CPA_CY_SYM_HASH_SHA512; - lacSessCtx->hashSetupData.hashMode = CPA_CY_SYM_HASH_MODE_AUTH; - lacSessCtx->hashSetupData.digestResultLenInBytes = - (cri->cri_mlen ? - cri->cri_mlen : ICP_SHA512_DIGEST_SIZE_IN_BYTES); - lacSessCtx->hashSetupData.authModeSetupData.authKey = - cri->cri_key; - lacSessCtx->hashSetupData.authModeSetupData.authKeyLenInBytes = - cri->cri_klen / NUM_BITS_IN_BYTE; - lacSessCtx->hashSetupData.authModeSetupData.aadLenInBytes = 0; - - break; - - case CRYPTO_MD5: - DPRINTK("%s(): MD5\n", __FUNCTION__); - lacSessCtx->symOperation = CPA_CY_SYM_OP_HASH; - lacSessCtx->hashSetupData.hashAlgorithm = CPA_CY_SYM_HASH_MD5; - lacSessCtx->hashSetupData.hashMode = CPA_CY_SYM_HASH_MODE_PLAIN; - lacSessCtx->hashSetupData.digestResultLenInBytes = - (cri->cri_mlen ? - cri->cri_mlen : ICP_MD5_DIGEST_SIZE_IN_BYTES); - - break; - - case CRYPTO_MD5_HMAC: - DPRINTK("%s(): MD5_HMAC\n", __FUNCTION__); - lacSessCtx->symOperation = CPA_CY_SYM_OP_HASH; - lacSessCtx->hashSetupData.hashAlgorithm = CPA_CY_SYM_HASH_MD5; - lacSessCtx->hashSetupData.hashMode = CPA_CY_SYM_HASH_MODE_AUTH; - lacSessCtx->hashSetupData.digestResultLenInBytes = - (cri->cri_mlen ? - cri->cri_mlen : ICP_MD5_DIGEST_SIZE_IN_BYTES); - lacSessCtx->hashSetupData.authModeSetupData.authKey = - cri->cri_key; - lacSessCtx->hashSetupData.authModeSetupData.authKeyLenInBytes = - cri->cri_klen / NUM_BITS_IN_BYTE; - lacSessCtx->hashSetupData.authModeSetupData.aadLenInBytes = 0; - - break; - - default: - DPRINTK("%s(): ALG Setup FAIL\n", __FUNCTION__); - return ICP_OCF_DRV_STATUS_FAIL; - } - - return ICP_OCF_DRV_STATUS_SUCCESS; -} - -/* Name : icp_ocfDrvFreeOCFSession - * - * Description : This function deletes all existing Session data representing - * the Cryptographic session established between OCF and this driver. This - * also includes freeing the memory allocated for the session context. The - * session object is also removed from the session linked list. - */ -static void icp_ocfDrvFreeOCFSession(struct icp_drvSessionData *sessionData) -{ - - sessionData->inUse = ICP_SESSION_DEREGISTERED; - - /*ENTER CRITICAL SECTION */ - icp_spin_lockbh_lock(&icp_ocfDrvSymSessInfoListSpinlock); - - if (CPA_TRUE == icp_atomic_read(&icp_ocfDrvIsExiting)) { - /*If the Driver is exiting, allow that process to - handle any deletions */ - /*EXIT CRITICAL SECTION */ - icp_spin_lockbh_unlock(&icp_ocfDrvSymSessInfoListSpinlock); - return; - } - - icp_atomic_dec(&num_ocf_to_drv_registered_sessions); - - ICP_LIST_DEL(sessionData, listNode); - - /*EXIT CRITICAL SECTION */ - icp_spin_lockbh_unlock(&icp_ocfDrvSymSessInfoListSpinlock); - - if (NULL != sessionData->sessHandle) { - icp_kfree(sessionData->sessHandle); - } - ICP_CACHE_FREE(drvSessionData_zone, sessionData); -} - -/* Name : icp_ocfDrvFreeLACSession - * - * Description : This attempts to deregister a LAC session. If it fails, the - * deregistation retry function is called. - */ -int icp_ocfDrvFreeLACSession(icp_device_t dev, uint64_t sid) -{ - CpaCySymSessionCtx sessionToDeregister = NULL; - struct icp_drvSessionData *sessionData = NULL; - CpaStatus lacStatus = CPA_STATUS_SUCCESS; - int retval = 0; - - sessionData = (struct icp_drvSessionData *)CRYPTO_SESID2LID(sid); - if (NULL == sessionData) { - EPRINTK("%s(): OCF Free session called with Null Session ID.\n", - __FUNCTION__); - return EINVAL; - } - - sessionToDeregister = sessionData->sessHandle; - - if ((ICP_SESSION_INITIALISED != sessionData->inUse) && - (ICP_SESSION_RUNNING != sessionData->inUse) && - (ICP_SESSION_DEREGISTERED != sessionData->inUse)) { - DPRINTK("%s() Session not initialised.\n", __FUNCTION__); - return EINVAL; - } - - if (ICP_SESSION_RUNNING == sessionData->inUse) { - lacStatus = cpaCySymRemoveSession(CPA_INSTANCE_HANDLE_SINGLE, - sessionToDeregister); - if (CPA_STATUS_RETRY == lacStatus) { - if (ICP_OCF_DRV_STATUS_SUCCESS != - icp_ocfDrvDeregRetry(&sessionToDeregister)) { - /* the retry function increments the - dereg failed count */ - DPRINTK("%s(): LAC failed to deregister the " - "session. (localSessionId= %p)\n", - __FUNCTION__, sessionToDeregister); - retval = EPERM; - } - - } else if (CPA_STATUS_SUCCESS != lacStatus) { - DPRINTK("%s(): LAC failed to deregister the session. " - "localSessionId= %p, lacStatus = %d\n", - __FUNCTION__, sessionToDeregister, lacStatus); - icp_atomic_inc(&lac_session_failed_dereg_count); - retval = EPERM; - } - } else { - DPRINTK("%s() Session not registered with LAC.\n", - __FUNCTION__); - } - - icp_ocfDrvFreeOCFSession(sessionData); - return retval; - -} - -/* Name : icp_ocfDrvAlgCheck - * - * Description : This function checks whether the cryptodesc argument pertains - * to a sym or hash function - */ -static int icp_ocfDrvAlgCheck(struct cryptodesc *crp_desc) -{ - - if (crp_desc->crd_alg == CRYPTO_3DES_CBC || - crp_desc->crd_alg == CRYPTO_AES_CBC || - crp_desc->crd_alg == CRYPTO_DES_CBC || - crp_desc->crd_alg == CRYPTO_NULL_CBC || - crp_desc->crd_alg == CRYPTO_ARC4) { - return ICP_OCF_DRV_ALG_CIPHER; - } - - return ICP_OCF_DRV_ALG_HASH; -} - -/* Name : icp_ocfDrvSymProcess - * - * Description : This function will map symmetric functionality calls from OCF - * to the LAC API. It will also allocate memory to store the session context. - * - * Notes: If it is the first perform call for a given session, then a LAC - * session is registered. After the session is registered, no checks as - * to whether session paramaters have changed (e.g. alg chain order) are - * done. - */ -int icp_ocfDrvSymProcess(icp_device_t dev, struct cryptop *crp, int hint) -{ - struct icp_drvSessionData *sessionData = NULL; - struct icp_drvOpData *drvOpData = NULL; - CpaStatus lacStatus = CPA_STATUS_SUCCESS; - Cpa32U sessionCtxSizeInBytes = 0; - - if (NULL == crp) { - DPRINTK("%s(): Invalid input parameters, cryptop is NULL\n", - __FUNCTION__); - return EINVAL; - } - - if (NULL == crp->crp_desc) { - DPRINTK("%s(): Invalid input parameters, no crp_desc attached " - "to crp\n", __FUNCTION__); - crp->crp_etype = EINVAL; - return EINVAL; - } - - if (NULL == crp->crp_buf) { - DPRINTK("%s(): Invalid input parameters, no buffer attached " - "to crp\n", __FUNCTION__); - crp->crp_etype = EINVAL; - return EINVAL; - } - - if (CPA_TRUE == icp_atomic_read(&icp_ocfDrvIsExiting)) { - crp->crp_etype = EFAULT; - return EFAULT; - } - - sessionData = (struct icp_drvSessionData *) - (CRYPTO_SESID2LID(crp->crp_sid)); - if (NULL == sessionData) { - DPRINTK("%s(): Invalid input parameters, Null Session ID \n", - __FUNCTION__); - crp->crp_etype = EINVAL; - return EINVAL; - } - -/*If we get a request against a deregisted session, cancel operation*/ - if (ICP_SESSION_DEREGISTERED == sessionData->inUse) { - DPRINTK("%s(): Session ID %d was deregistered \n", - __FUNCTION__, (int)(CRYPTO_SESID2LID(crp->crp_sid))); - crp->crp_etype = EFAULT; - return EFAULT; - } - -/*If none of the session states are set, then the session structure was either - not initialised properly or we are reading from a freed memory area (possible - due to OCF batch mode not removing queued requests against deregistered - sessions*/ - if (ICP_SESSION_INITIALISED != sessionData->inUse && - ICP_SESSION_RUNNING != sessionData->inUse) { - DPRINTK("%s(): Session - ID %d - not properly initialised or " - "memory freed back to the kernel \n", - __FUNCTION__, (int)(CRYPTO_SESID2LID(crp->crp_sid))); - crp->crp_etype = EINVAL; - return EINVAL; - } - - /*For the below checks, remember error checking is already done in LAC. - We're not validating inputs subsequent to registration */ - if (sessionData->inUse == ICP_SESSION_INITIALISED) { - DPRINTK("%s(): Initialising session\n", __FUNCTION__); - - if (NULL != crp->crp_desc->crd_next) { - if (ICP_OCF_DRV_ALG_CIPHER == - icp_ocfDrvAlgCheck(crp->crp_desc)) { - - sessionData->lacSessCtx.algChainOrder = - CPA_CY_SYM_ALG_CHAIN_ORDER_CIPHER_THEN_HASH; - - if (crp->crp_desc->crd_flags & CRD_F_ENCRYPT) { - sessionData->lacSessCtx.cipherSetupData. - cipherDirection = - CPA_CY_SYM_CIPHER_DIRECTION_ENCRYPT; - } else { - sessionData->lacSessCtx.cipherSetupData. - cipherDirection = - CPA_CY_SYM_CIPHER_DIRECTION_DECRYPT; - } - } else { - sessionData->lacSessCtx.algChainOrder = - CPA_CY_SYM_ALG_CHAIN_ORDER_HASH_THEN_CIPHER; - - if (crp->crp_desc->crd_next->crd_flags & - CRD_F_ENCRYPT) { - sessionData->lacSessCtx.cipherSetupData. - cipherDirection = - CPA_CY_SYM_CIPHER_DIRECTION_ENCRYPT; - } else { - sessionData->lacSessCtx.cipherSetupData. - cipherDirection = - CPA_CY_SYM_CIPHER_DIRECTION_DECRYPT; - } - - } - - } else if (ICP_OCF_DRV_ALG_CIPHER == - icp_ocfDrvAlgCheck(crp->crp_desc)) { - if (crp->crp_desc->crd_flags & CRD_F_ENCRYPT) { - sessionData->lacSessCtx.cipherSetupData. - cipherDirection = - CPA_CY_SYM_CIPHER_DIRECTION_ENCRYPT; - } else { - sessionData->lacSessCtx.cipherSetupData. - cipherDirection = - CPA_CY_SYM_CIPHER_DIRECTION_DECRYPT; - } - - } - - /*No action required for standalone Auth here */ - - /* Allocate memory for SymSessionCtx before the Session Registration */ - lacStatus = - cpaCySymSessionCtxGetSize(CPA_INSTANCE_HANDLE_SINGLE, - &(sessionData->lacSessCtx), - &sessionCtxSizeInBytes); - if (CPA_STATUS_SUCCESS != lacStatus) { - EPRINTK("%s(): cpaCySymSessionCtxGetSize failed - %d\n", - __FUNCTION__, lacStatus); - crp->crp_etype = EINVAL; - return EINVAL; - } - sessionData->sessHandle = - icp_kmalloc(sessionCtxSizeInBytes, ICP_M_NOWAIT); - if (NULL == sessionData->sessHandle) { - EPRINTK - ("%s(): Failed to get memory for SymSessionCtx\n", - __FUNCTION__); - crp->crp_etype = ENOMEM; - return ENOMEM; - } - - lacStatus = cpaCySymInitSession(CPA_INSTANCE_HANDLE_SINGLE, - icp_ocfDrvSymCallBack, - &(sessionData->lacSessCtx), - sessionData->sessHandle); - - if (CPA_STATUS_SUCCESS != lacStatus) { - EPRINTK("%s(): cpaCySymInitSession failed -%d \n", - __FUNCTION__, lacStatus); - crp->crp_etype = EFAULT; - return EFAULT; - } - - sessionData->inUse = ICP_SESSION_RUNNING; - } - - drvOpData = icp_kmem_cache_zalloc(drvOpData_zone, ICP_M_NOWAIT); - if (NULL == drvOpData) { - EPRINTK("%s():Failed to get memory for drvOpData\n", - __FUNCTION__); - crp->crp_etype = ENOMEM; - return ENOMEM; - } - - drvOpData->lacOpData.pSessionCtx = sessionData->sessHandle; - drvOpData->digestSizeInBytes = sessionData->lacSessCtx.hashSetupData. - digestResultLenInBytes; - drvOpData->crp = crp; - - /* Set the default buffer list array memory allocation */ - drvOpData->srcBuffer.pBuffers = drvOpData->bufferListArray; - drvOpData->numBufferListArray = ICP_OCF_DRV_DEFAULT_BUFFLIST_ARRAYS; - - if (ICP_OCF_DRV_STATUS_SUCCESS != - icp_ocfDrvProcessDataSetup(drvOpData, drvOpData->crp->crp_desc)) { - crp->crp_etype = EINVAL; - goto err; - } - - if (drvOpData->crp->crp_desc->crd_next != NULL) { - if (icp_ocfDrvProcessDataSetup(drvOpData, drvOpData->crp-> - crp_desc->crd_next)) { - crp->crp_etype = EINVAL; - goto err; - } - - } - - /* - * Allocate buffer list array memory if the data fragment is more than - * the default number (ICP_OCF_DRV_DEFAULT_BUFFLIST_ARRAYS) and not - * calculated already - */ - if (crp->crp_flags & ICP_CRYPTO_F_PACKET_BUF) { - if (NULL == drvOpData->lacOpData.pDigestResult) { - drvOpData->numBufferListArray = - icp_ocfDrvGetPacketBuffFrags((icp_packet_buffer_t *) - crp->crp_buf); - } - - if (ICP_OCF_DRV_DEFAULT_BUFFLIST_ARRAYS < - drvOpData->numBufferListArray) { - DPRINTK("%s() numBufferListArray more than default\n", - __FUNCTION__); - drvOpData->srcBuffer.pBuffers = NULL; - drvOpData->srcBuffer.pBuffers = - icp_kmalloc(drvOpData->numBufferListArray * - sizeof(CpaFlatBuffer), ICP_M_NOWAIT); - if (NULL == drvOpData->srcBuffer.pBuffers) { - EPRINTK("%s() Failed to get memory for " - "pBuffers\n", __FUNCTION__); - ICP_CACHE_FREE(drvOpData_zone, drvOpData); - crp->crp_etype = ENOMEM; - return ENOMEM; - } - } - } - - /* - * Check the type of buffer structure we got and convert it into - * CpaBufferList format. - */ - if (crp->crp_flags & ICP_CRYPTO_F_PACKET_BUF) { - if (ICP_OCF_DRV_STATUS_SUCCESS != - icp_ocfDrvPacketBuffToBufferList((icp_packet_buffer_t *) - crp->crp_buf, - &(drvOpData->srcBuffer))) { - EPRINTK("%s():Failed to translate from packet buffer " - "to bufferlist\n", __FUNCTION__); - crp->crp_etype = EINVAL; - goto err; - } - - drvOpData->bufferType = ICP_CRYPTO_F_PACKET_BUF; - } else if (crp->crp_flags & CRYPTO_F_IOV) { - /* OCF only supports IOV of one entry. */ - if (NUM_IOV_SUPPORTED == - ((struct uio *)(crp->crp_buf))->uio_iovcnt) { - - icp_ocfDrvPtrAndLenToBufferList(((struct uio *)(crp-> - crp_buf))-> - uio_iov[0].iov_base, - ((struct uio *)(crp-> - crp_buf))-> - uio_iov[0].iov_len, - &(drvOpData-> - srcBuffer)); - - drvOpData->bufferType = CRYPTO_F_IOV; - - } else { - DPRINTK("%s():Unable to handle IOVs with lengths of " - "greater than one!\n", __FUNCTION__); - crp->crp_etype = EINVAL; - goto err; - } - - } else { - icp_ocfDrvPtrAndLenToBufferList(crp->crp_buf, - crp->crp_ilen, - &(drvOpData->srcBuffer)); - - drvOpData->bufferType = CRYPTO_BUF_CONTIG; - } - - /* Allocate srcBuffer's private meta data */ - if (ICP_OCF_DRV_STATUS_SUCCESS != - icp_ocfDrvAllocMetaData(&(drvOpData->srcBuffer), drvOpData)) { - EPRINTK("%s() icp_ocfDrvAllocMetaData failed\n", __FUNCTION__); - memset(&(drvOpData->lacOpData), 0, sizeof(CpaCySymOpData)); - crp->crp_etype = EINVAL; - goto err; - } - - /* Perform "in-place" crypto operation */ - lacStatus = cpaCySymPerformOp(CPA_INSTANCE_HANDLE_SINGLE, - (void *)drvOpData, - &(drvOpData->lacOpData), - &(drvOpData->srcBuffer), - &(drvOpData->srcBuffer), - &(drvOpData->verifyResult)); - if (CPA_STATUS_RETRY == lacStatus) { - DPRINTK("%s(): cpaCySymPerformOp retry, lacStatus = %d\n", - __FUNCTION__, lacStatus); - memset(&(drvOpData->lacOpData), 0, sizeof(CpaCySymOpData)); - crp->crp_etype = ERESTART; - goto err; - } - if (CPA_STATUS_SUCCESS != lacStatus) { - EPRINTK("%s(): cpaCySymPerformOp failed, lacStatus = %d\n", - __FUNCTION__, lacStatus); - memset(&(drvOpData->lacOpData), 0, sizeof(CpaCySymOpData)); - crp->crp_etype = EINVAL; - goto err; - } - - return 0; //OCF success status value - - err: - if (drvOpData->numBufferListArray > ICP_OCF_DRV_DEFAULT_BUFFLIST_ARRAYS) { - icp_kfree(drvOpData->srcBuffer.pBuffers); - } - icp_ocfDrvFreeMetaData(&(drvOpData->srcBuffer)); - ICP_CACHE_FREE(drvOpData_zone, drvOpData); - - return crp->crp_etype; -} - -/* Name : icp_ocfDrvProcessDataSetup - * - * Description : This function will setup all the cryptographic operation data - * that is required by LAC to execute the operation. - */ -static int icp_ocfDrvProcessDataSetup(struct icp_drvOpData *drvOpData, - struct cryptodesc *crp_desc) -{ - CpaCyRandGenOpData randGenOpData; - CpaFlatBuffer randData; - - drvOpData->lacOpData.packetType = CPA_CY_SYM_PACKET_TYPE_FULL; - - /* Convert from the cryptop to the ICP LAC crypto parameters */ - switch (crp_desc->crd_alg) { - case CRYPTO_NULL_CBC: - drvOpData->lacOpData. - cryptoStartSrcOffsetInBytes = crp_desc->crd_skip; - drvOpData->lacOpData. - messageLenToCipherInBytes = crp_desc->crd_len; - drvOpData->verifyResult = CPA_FALSE; - drvOpData->lacOpData.ivLenInBytes = NULL_BLOCK_LEN; - break; - case CRYPTO_DES_CBC: - drvOpData->lacOpData. - cryptoStartSrcOffsetInBytes = crp_desc->crd_skip; - drvOpData->lacOpData. - messageLenToCipherInBytes = crp_desc->crd_len; - drvOpData->verifyResult = CPA_FALSE; - drvOpData->lacOpData.ivLenInBytes = DES_BLOCK_LEN; - break; - case CRYPTO_3DES_CBC: - drvOpData->lacOpData. - cryptoStartSrcOffsetInBytes = crp_desc->crd_skip; - drvOpData->lacOpData. - messageLenToCipherInBytes = crp_desc->crd_len; - drvOpData->verifyResult = CPA_FALSE; - drvOpData->lacOpData.ivLenInBytes = DES3_BLOCK_LEN; - break; - case CRYPTO_ARC4: - drvOpData->lacOpData. - cryptoStartSrcOffsetInBytes = crp_desc->crd_skip; - drvOpData->lacOpData. - messageLenToCipherInBytes = crp_desc->crd_len; - drvOpData->verifyResult = CPA_FALSE; - drvOpData->lacOpData.ivLenInBytes = ARC4_COUNTER_LEN; - break; - case CRYPTO_AES_CBC: - drvOpData->lacOpData. - cryptoStartSrcOffsetInBytes = crp_desc->crd_skip; - drvOpData->lacOpData. - messageLenToCipherInBytes = crp_desc->crd_len; - drvOpData->verifyResult = CPA_FALSE; - drvOpData->lacOpData.ivLenInBytes = RIJNDAEL128_BLOCK_LEN; - break; - case CRYPTO_SHA1: - case CRYPTO_SHA1_HMAC: - case CRYPTO_SHA2_256: - case CRYPTO_SHA2_256_HMAC: - case CRYPTO_SHA2_384: - case CRYPTO_SHA2_384_HMAC: - case CRYPTO_SHA2_512: - case CRYPTO_SHA2_512_HMAC: - case CRYPTO_MD5: - case CRYPTO_MD5_HMAC: - drvOpData->lacOpData. - hashStartSrcOffsetInBytes = crp_desc->crd_skip; - drvOpData->lacOpData. - messageLenToHashInBytes = crp_desc->crd_len; - drvOpData->lacOpData. - pDigestResult = - icp_ocfDrvDigestPointerFind(drvOpData, crp_desc); - - if (NULL == drvOpData->lacOpData.pDigestResult) { - DPRINTK("%s(): ERROR - could not calculate " - "Digest Result memory address\n", __FUNCTION__); - return ICP_OCF_DRV_STATUS_FAIL; - } - - drvOpData->lacOpData.digestVerify = CPA_FALSE; - break; - default: - DPRINTK("%s(): Crypto process error - algorithm not " - "found \n", __FUNCTION__); - return ICP_OCF_DRV_STATUS_FAIL; - } - - /* Figure out what the IV is supposed to be */ - if ((crp_desc->crd_alg == CRYPTO_DES_CBC) || - (crp_desc->crd_alg == CRYPTO_3DES_CBC) || - (crp_desc->crd_alg == CRYPTO_AES_CBC)) { - /*ARC4 doesn't use an IV */ - if (crp_desc->crd_flags & CRD_F_IV_EXPLICIT) { - /* Explicit IV provided to OCF */ - drvOpData->lacOpData.pIv = crp_desc->crd_iv; - } else { - /* IV is not explicitly provided to OCF */ - - /* Point the LAC OP Data IV pointer to our allocated - storage location for this session. */ - drvOpData->lacOpData.pIv = drvOpData->ivData; - - if ((crp_desc->crd_flags & CRD_F_ENCRYPT) && - ((crp_desc->crd_flags & CRD_F_IV_PRESENT) == 0)) { - - /* Encrypting - need to create IV */ - randGenOpData.generateBits = CPA_TRUE; - randGenOpData.lenInBytes = MAX_IV_LEN_IN_BYTES; - - icp_ocfDrvPtrAndLenToFlatBuffer((Cpa8U *) - drvOpData-> - ivData, - MAX_IV_LEN_IN_BYTES, - &randData); - - if (CPA_STATUS_SUCCESS != - cpaCyRandGen(CPA_INSTANCE_HANDLE_SINGLE, - NULL, NULL, - &randGenOpData, &randData)) { - DPRINTK("%s(): ERROR - Failed to" - " generate" - " Initialisation Vector\n", - __FUNCTION__); - return ICP_OCF_DRV_STATUS_FAIL; - } - - crypto_copyback(drvOpData->crp-> - crp_flags, - drvOpData->crp->crp_buf, - crp_desc->crd_inject, - drvOpData->lacOpData. - ivLenInBytes, - (caddr_t) (drvOpData->lacOpData. - pIv)); - } else { - /* Reading IV from buffer */ - crypto_copydata(drvOpData->crp-> - crp_flags, - drvOpData->crp->crp_buf, - crp_desc->crd_inject, - drvOpData->lacOpData. - ivLenInBytes, - (caddr_t) (drvOpData->lacOpData. - pIv)); - } - - } - - } - - return ICP_OCF_DRV_STATUS_SUCCESS; -} - -/* Name : icp_ocfDrvDigestPointerFind - * - * Description : This function is used to find the memory address of where the - * digest information shall be stored in. Input buffer types are an skbuff, iov - * or flat buffer. The address is found using the buffer data start address and - * an offset. - * - * Note: In the case of a linux skbuff, the digest address may exist within - * a memory space linked to from the start buffer. These linked memory spaces - * must be traversed by the data length offset in order to find the digest start - * address. Whether there is enough space for the digest must also be checked. - */ -uint8_t *icp_ocfDrvDigestPointerFind(struct icp_drvOpData * drvOpData, - struct cryptodesc * crp_desc) -{ - - int offsetInBytes = crp_desc->crd_inject; - uint32_t digestSizeInBytes = drvOpData->digestSizeInBytes; - uint8_t *flat_buffer_base = NULL; - int flat_buffer_length = 0; - - if (drvOpData->crp->crp_flags & ICP_CRYPTO_F_PACKET_BUF) { - - return icp_ocfDrvPacketBufferDigestPointerFind(drvOpData, - offsetInBytes, - digestSizeInBytes); - - } else { - /* IOV or flat buffer */ - if (drvOpData->crp->crp_flags & CRYPTO_F_IOV) { - /*single IOV check has already been done */ - flat_buffer_base = ((struct uio *) - (drvOpData->crp->crp_buf))-> - uio_iov[0].iov_base; - flat_buffer_length = ((struct uio *) - (drvOpData->crp->crp_buf))-> - uio_iov[0].iov_len; - } else { - flat_buffer_base = (uint8_t *) drvOpData->crp->crp_buf; - flat_buffer_length = drvOpData->crp->crp_ilen; - } - - if (flat_buffer_length < (offsetInBytes + digestSizeInBytes)) { - DPRINTK("%s() Not enough space for Digest " - "(IOV/Flat Buffer) \n", __FUNCTION__); - return NULL; - } else { - return (uint8_t *) (flat_buffer_base + offsetInBytes); - } - } - DPRINTK("%s() Should not reach this point\n", __FUNCTION__); - return NULL; -} diff --git a/target/linux/generic-2.4/files/crypto/ocf/hifn/Makefile b/target/linux/generic-2.4/files/crypto/ocf/hifn/Makefile deleted file mode 100644 index 163fed0..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/hifn/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# for SGlinux builds --include $(ROOTDIR)/modules/.config - -obj-$(CONFIG_OCF_HIFN) += hifn7751.o -obj-$(CONFIG_OCF_HIFNHIPP) += hifnHIPP.o - -obj ?= . -EXTRA_CFLAGS += -I$(obj)/.. -I$(obj)/ - -ifdef TOPDIR --include $(TOPDIR)/Rules.make -endif - diff --git a/target/linux/generic-2.4/files/crypto/ocf/hifn/hifn7751.c b/target/linux/generic-2.4/files/crypto/ocf/hifn/hifn7751.c deleted file mode 100644 index 6136e84..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/hifn/hifn7751.c +++ /dev/null @@ -1,2976 +0,0 @@ -/* $OpenBSD: hifn7751.c,v 1.120 2002/05/17 00:33:34 deraadt Exp $ */ - -/*- - * Invertex AEON / Hifn 7751 driver - * Copyright (c) 1999 Invertex Inc. All rights reserved. - * Copyright (c) 1999 Theo de Raadt - * Copyright (c) 2000-2001 Network Security Technologies, Inc. - * http://www.netsec.net - * Copyright (c) 2003 Hifn Inc. - * - * This driver is based on a previous driver by Invertex, for which they - * requested: Please send any comments, feedback, bug-fixes, or feature - * requests to software@invertex.com. - * - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR 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. - * - * Effort sponsored in part by the Defense Advanced Research Projects - * Agency (DARPA) and Air Force Research Laboratory, Air Force - * Materiel Command, USAF, under agreement number F30602-01-2-0537. - * - * -__FBSDID("$FreeBSD: src/sys/dev/hifn/hifn7751.c,v 1.40 2007/03/21 03:42:49 sam Exp $"); - */ - -/* - * Driver for various Hifn encryption processors. - */ -#ifndef AUTOCONF_INCLUDED -#include <linux/config.h> -#endif -#include <linux/module.h> -#include <linux/init.h> -#include <linux/list.h> -#include <linux/slab.h> -#include <linux/wait.h> -#include <linux/sched.h> -#include <linux/pci.h> -#include <linux/delay.h> -#include <linux/interrupt.h> -#include <linux/spinlock.h> -#include <linux/random.h> -#include <linux/version.h> -#include <linux/skbuff.h> -#include <asm/io.h> - -#include <cryptodev.h> -#include <uio.h> -#include <hifn/hifn7751reg.h> -#include <hifn/hifn7751var.h> - -#if 1 -#define DPRINTF(a...) if (hifn_debug) { \ - printk("%s: ", sc ? \ - device_get_nameunit(sc->sc_dev) : "hifn"); \ - printk(a); \ - } else -#else -#define DPRINTF(a...) -#endif - -static inline int -pci_get_revid(struct pci_dev *dev) -{ - u8 rid = 0; - pci_read_config_byte(dev, PCI_REVISION_ID, &rid); - return rid; -} - -static struct hifn_stats hifnstats; - -#define debug hifn_debug -int hifn_debug = 0; -module_param(hifn_debug, int, 0644); -MODULE_PARM_DESC(hifn_debug, "Enable debug"); - -int hifn_maxbatch = 1; -module_param(hifn_maxbatch, int, 0644); -MODULE_PARM_DESC(hifn_maxbatch, "max ops to batch w/o interrupt"); - -int hifn_cache_linesize = 0x10; -module_param(hifn_cache_linesize, int, 0444); -MODULE_PARM_DESC(hifn_cache_linesize, "PCI config cache line size"); - -#ifdef MODULE_PARM -char *hifn_pllconfig = NULL; -MODULE_PARM(hifn_pllconfig, "s"); -#else -char hifn_pllconfig[32]; /* This setting is RO after loading */ -module_param_string(hifn_pllconfig, hifn_pllconfig, 32, 0444); -#endif -MODULE_PARM_DESC(hifn_pllconfig, "PLL config, ie., pci66, ext33, ..."); - -#ifdef HIFN_VULCANDEV -#include <sys/conf.h> -#include <sys/uio.h> - -static struct cdevsw vulcanpk_cdevsw; /* forward declaration */ -#endif - -/* - * Prototypes and count for the pci_device structure - */ -static int hifn_probe(struct pci_dev *dev, const struct pci_device_id *ent); -static void hifn_remove(struct pci_dev *dev); - -static int hifn_newsession(device_t, u_int32_t *, struct cryptoini *); -static int hifn_freesession(device_t, u_int64_t); -static int hifn_process(device_t, struct cryptop *, int); - -static device_method_t hifn_methods = { - /* crypto device methods */ - DEVMETHOD(cryptodev_newsession, hifn_newsession), - DEVMETHOD(cryptodev_freesession,hifn_freesession), - DEVMETHOD(cryptodev_process, hifn_process), -}; - -static void hifn_reset_board(struct hifn_softc *, int); -static void hifn_reset_puc(struct hifn_softc *); -static void hifn_puc_wait(struct hifn_softc *); -static int hifn_enable_crypto(struct hifn_softc *); -static void hifn_set_retry(struct hifn_softc *sc); -static void hifn_init_dma(struct hifn_softc *); -static void hifn_init_pci_registers(struct hifn_softc *); -static int hifn_sramsize(struct hifn_softc *); -static int hifn_dramsize(struct hifn_softc *); -static int hifn_ramtype(struct hifn_softc *); -static void hifn_sessions(struct hifn_softc *); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19) -static irqreturn_t hifn_intr(int irq, void *arg); -#else -static irqreturn_t hifn_intr(int irq, void *arg, struct pt_regs *regs); -#endif -static u_int hifn_write_command(struct hifn_command *, u_int8_t *); -static u_int32_t hifn_next_signature(u_int32_t a, u_int cnt); -static void hifn_callback(struct hifn_softc *, struct hifn_command *, u_int8_t *); -static int hifn_crypto(struct hifn_softc *, struct hifn_command *, struct cryptop *, int); -static int hifn_readramaddr(struct hifn_softc *, int, u_int8_t *); -static int hifn_writeramaddr(struct hifn_softc *, int, u_int8_t *); -static int hifn_dmamap_load_src(struct hifn_softc *, struct hifn_command *); -static int hifn_dmamap_load_dst(struct hifn_softc *, struct hifn_command *); -static int hifn_init_pubrng(struct hifn_softc *); -static void hifn_tick(unsigned long arg); -static void hifn_abort(struct hifn_softc *); -static void hifn_alloc_slot(struct hifn_softc *, int *, int *, int *, int *); - -static void hifn_write_reg_0(struct hifn_softc *, bus_size_t, u_int32_t); -static void hifn_write_reg_1(struct hifn_softc *, bus_size_t, u_int32_t); - -#ifdef CONFIG_OCF_RANDOMHARVEST -static int hifn_read_random(void *arg, u_int32_t *buf, int len); -#endif - -#define HIFN_MAX_CHIPS 8 -static struct hifn_softc *hifn_chip_idx[HIFN_MAX_CHIPS]; - -static __inline u_int32_t -READ_REG_0(struct hifn_softc *sc, bus_size_t reg) -{ - u_int32_t v = readl(sc->sc_bar0 + reg); - sc->sc_bar0_lastreg = (bus_size_t) -1; - return (v); -} -#define WRITE_REG_0(sc, reg, val) hifn_write_reg_0(sc, reg, val) - -static __inline u_int32_t -READ_REG_1(struct hifn_softc *sc, bus_size_t reg) -{ - u_int32_t v = readl(sc->sc_bar1 + reg); - sc->sc_bar1_lastreg = (bus_size_t) -1; - return (v); -} -#define WRITE_REG_1(sc, reg, val) hifn_write_reg_1(sc, reg, val) - -/* - * map in a given buffer (great on some arches :-) - */ - -static int -pci_map_uio(struct hifn_softc *sc, struct hifn_operand *buf, struct uio *uio) -{ - struct iovec *iov = uio->uio_iov; - - DPRINTF("%s()\n", __FUNCTION__); - - buf->mapsize = 0; - for (buf->nsegs = 0; buf->nsegs < uio->uio_iovcnt; ) { - buf->segs[buf->nsegs].ds_addr = pci_map_single(sc->sc_pcidev, - iov->iov_base, iov->iov_len, - PCI_DMA_BIDIRECTIONAL); - buf->segs[buf->nsegs].ds_len = iov->iov_len; - buf->mapsize += iov->iov_len; - iov++; - buf->nsegs++; - } - /* identify this buffer by the first segment */ - buf->map = (void *) buf->segs[0].ds_addr; - return(0); -} - -/* - * map in a given sk_buff - */ - -static int -pci_map_skb(struct hifn_softc *sc,struct hifn_operand *buf,struct sk_buff *skb) -{ - int i; - - DPRINTF("%s()\n", __FUNCTION__); - - buf->mapsize = 0; - - buf->segs[0].ds_addr = pci_map_single(sc->sc_pcidev, - skb->data, skb_headlen(skb), PCI_DMA_BIDIRECTIONAL); - buf->segs[0].ds_len = skb_headlen(skb); - buf->mapsize += buf->segs[0].ds_len; - - buf->nsegs = 1; - - for (i = 0; i < skb_shinfo(skb)->nr_frags; ) { - buf->segs[buf->nsegs].ds_len = skb_shinfo(skb)->frags[i].size; - buf->segs[buf->nsegs].ds_addr = pci_map_single(sc->sc_pcidev, - page_address(skb_shinfo(skb)->frags[i].page) + - skb_shinfo(skb)->frags[i].page_offset, - buf->segs[buf->nsegs].ds_len, PCI_DMA_BIDIRECTIONAL); - buf->mapsize += buf->segs[buf->nsegs].ds_len; - buf->nsegs++; - } - - /* identify this buffer by the first segment */ - buf->map = (void *) buf->segs[0].ds_addr; - return(0); -} - -/* - * map in a given contiguous buffer - */ - -static int -pci_map_buf(struct hifn_softc *sc,struct hifn_operand *buf, void *b, int len) -{ - DPRINTF("%s()\n", __FUNCTION__); - - buf->mapsize = 0; - buf->segs[0].ds_addr = pci_map_single(sc->sc_pcidev, - b, len, PCI_DMA_BIDIRECTIONAL); - buf->segs[0].ds_len = len; - buf->mapsize += buf->segs[0].ds_len; - buf->nsegs = 1; - - /* identify this buffer by the first segment */ - buf->map = (void *) buf->segs[0].ds_addr; - return(0); -} - -#if 0 /* not needed at this time */ -static void -pci_sync_iov(struct hifn_softc *sc, struct hifn_operand *buf) -{ - int i; - - DPRINTF("%s()\n", __FUNCTION__); - for (i = 0; i < buf->nsegs; i++) - pci_dma_sync_single_for_cpu(sc->sc_pcidev, buf->segs[i].ds_addr, - buf->segs[i].ds_len, PCI_DMA_BIDIRECTIONAL); -} -#endif - -static void -pci_unmap_buf(struct hifn_softc *sc, struct hifn_operand *buf) -{ - int i; - DPRINTF("%s()\n", __FUNCTION__); - for (i = 0; i < buf->nsegs; i++) { - pci_unmap_single(sc->sc_pcidev, buf->segs[i].ds_addr, - buf->segs[i].ds_len, PCI_DMA_BIDIRECTIONAL); - buf->segs[i].ds_addr = 0; - buf->segs[i].ds_len = 0; - } - buf->nsegs = 0; - buf->mapsize = 0; - buf->map = 0; -} - -static const char* -hifn_partname(struct hifn_softc *sc) -{ - /* XXX sprintf numbers when not decoded */ - switch (pci_get_vendor(sc->sc_pcidev)) { - case PCI_VENDOR_HIFN: - switch (pci_get_device(sc->sc_pcidev)) { - case PCI_PRODUCT_HIFN_6500: return "Hifn 6500"; - case PCI_PRODUCT_HIFN_7751: return "Hifn 7751"; - case PCI_PRODUCT_HIFN_7811: return "Hifn 7811"; - case PCI_PRODUCT_HIFN_7951: return "Hifn 7951"; - case PCI_PRODUCT_HIFN_7955: return "Hifn 7955"; - case PCI_PRODUCT_HIFN_7956: return "Hifn 7956"; - } - return "Hifn unknown-part"; - case PCI_VENDOR_INVERTEX: - switch (pci_get_device(sc->sc_pcidev)) { - case PCI_PRODUCT_INVERTEX_AEON: return "Invertex AEON"; - } - return "Invertex unknown-part"; - case PCI_VENDOR_NETSEC: - switch (pci_get_device(sc->sc_pcidev)) { - case PCI_PRODUCT_NETSEC_7751: return "NetSec 7751"; - } - return "NetSec unknown-part"; - } - return "Unknown-vendor unknown-part"; -} - -static u_int -checkmaxmin(struct pci_dev *dev, const char *what, u_int v, u_int min, u_int max) -{ - struct hifn_softc *sc = pci_get_drvdata(dev); - if (v > max) { - device_printf(sc->sc_dev, "Warning, %s %u out of range, " - "using max %u\n", what, v, max); - v = max; - } else if (v < min) { - device_printf(sc->sc_dev, "Warning, %s %u out of range, " - "using min %u\n", what, v, min); - v = min; - } - return v; -} - -/* - * Select PLL configuration for 795x parts. This is complicated in - * that we cannot determine the optimal parameters without user input. - * The reference clock is derived from an external clock through a - * multiplier. The external clock is either the host bus (i.e. PCI) - * or an external clock generator. When using the PCI bus we assume - * the clock is either 33 or 66 MHz; for an external source we cannot - * tell the speed. - * - * PLL configuration is done with a string: "pci" for PCI bus, or "ext" - * for an external source, followed by the frequency. We calculate - * the appropriate multiplier and PLL register contents accordingly. - * When no configuration is given we default to "pci66" since that - * always will allow the card to work. If a card is using the PCI - * bus clock and in a 33MHz slot then it will be operating at half - * speed until the correct information is provided. - * - * We use a default setting of "ext66" because according to Mike Ham - * of HiFn, almost every board in existence has an external crystal - * populated at 66Mhz. Using PCI can be a problem on modern motherboards, - * because PCI33 can have clocks from 0 to 33Mhz, and some have - * non-PCI-compliant spread-spectrum clocks, which can confuse the pll. - */ -static void -hifn_getpllconfig(struct pci_dev *dev, u_int *pll) -{ - const char *pllspec = hifn_pllconfig; - u_int freq, mul, fl, fh; - u_int32_t pllconfig; - char *nxt; - - if (pllspec == NULL) - pllspec = "ext66"; - fl = 33, fh = 66; - pllconfig = 0; - if (strncmp(pllspec, "ext", 3) == 0) { - pllspec += 3; - pllconfig |= HIFN_PLL_REF_SEL; - switch (pci_get_device(dev)) { - case PCI_PRODUCT_HIFN_7955: - case PCI_PRODUCT_HIFN_7956: - fl = 20, fh = 100; - break; -#ifdef notyet - case PCI_PRODUCT_HIFN_7954: - fl = 20, fh = 66; - break; -#endif - } - } else if (strncmp(pllspec, "pci", 3) == 0) - pllspec += 3; - freq = strtoul(pllspec, &nxt, 10); - if (nxt == pllspec) - freq = 66; - else - freq = checkmaxmin(dev, "frequency", freq, fl, fh); - /* - * Calculate multiplier. We target a Fck of 266 MHz, - * allowing only even values, possibly rounded down. - * Multipliers > 8 must set the charge pump current. - */ - mul = checkmaxmin(dev, "PLL divisor", (266 / freq) &~ 1, 2, 12); - pllconfig |= (mul / 2 - 1) << HIFN_PLL_ND_SHIFT; - if (mul > 8) - pllconfig |= HIFN_PLL_IS; - *pll = pllconfig; -} - -/* - * Attach an interface that successfully probed. - */ -static int -hifn_probe(struct pci_dev *dev, const struct pci_device_id *ent) -{ - struct hifn_softc *sc = NULL; - char rbase; - u_int16_t ena, rev; - int rseg, rc; - unsigned long mem_start, mem_len; - static int num_chips = 0; - - DPRINTF("%s()\n", __FUNCTION__); - - if (pci_enable_device(dev) < 0) - return(-ENODEV); - - if (pci_set_mwi(dev)) - return(-ENODEV); - - if (!dev->irq) { - printk("hifn: found device with no IRQ assigned. check BIOS settings!"); - pci_disable_device(dev); - return(-ENODEV); - } - - sc = (struct hifn_softc *) kmalloc(sizeof(*sc), GFP_KERNEL); - if (!sc) - return(-ENOMEM); - memset(sc, 0, sizeof(*sc)); - - softc_device_init(sc, "hifn", num_chips, hifn_methods); - - sc->sc_pcidev = dev; - sc->sc_irq = -1; - sc->sc_cid = -1; - sc->sc_num = num_chips++; - if (sc->sc_num < HIFN_MAX_CHIPS) - hifn_chip_idx[sc->sc_num] = sc; - - pci_set_drvdata(sc->sc_pcidev, sc); - - spin_lock_init(&sc->sc_mtx); - - /* XXX handle power management */ - - /* - * The 7951 and 795x have a random number generator and - * public key support; note this. - */ - if (pci_get_vendor(dev) == PCI_VENDOR_HIFN && - (pci_get_device(dev) == PCI_PRODUCT_HIFN_7951 || - pci_get_device(dev) == PCI_PRODUCT_HIFN_7955 || - pci_get_device(dev) == PCI_PRODUCT_HIFN_7956)) - sc->sc_flags = HIFN_HAS_RNG | HIFN_HAS_PUBLIC; - /* - * The 7811 has a random number generator and - * we also note it's identity 'cuz of some quirks. - */ - if (pci_get_vendor(dev) == PCI_VENDOR_HIFN && - pci_get_device(dev) == PCI_PRODUCT_HIFN_7811) - sc->sc_flags |= HIFN_IS_7811 | HIFN_HAS_RNG; - - /* - * The 795x parts support AES. - */ - if (pci_get_vendor(dev) == PCI_VENDOR_HIFN && - (pci_get_device(dev) == PCI_PRODUCT_HIFN_7955 || - pci_get_device(dev) == PCI_PRODUCT_HIFN_7956)) { - sc->sc_flags |= HIFN_IS_7956 | HIFN_HAS_AES; - /* - * Select PLL configuration. This depends on the - * bus and board design and must be manually configured - * if the default setting is unacceptable. - */ - hifn_getpllconfig(dev, &sc->sc_pllconfig); - } - - /* - * Setup PCI resources. Note that we record the bus - * tag and handle for each register mapping, this is - * used by the READ_REG_0, WRITE_REG_0, READ_REG_1, - * and WRITE_REG_1 macros throughout the driver. - */ - mem_start = pci_resource_start(sc->sc_pcidev, 0); - mem_len = pci_resource_len(sc->sc_pcidev, 0); - sc->sc_bar0 = (ocf_iomem_t) ioremap(mem_start, mem_len); - if (!sc->sc_bar0) { - device_printf(sc->sc_dev, "cannot map bar%d register space\n", 0); - goto fail; - } - sc->sc_bar0_lastreg = (bus_size_t) -1; - - mem_start = pci_resource_start(sc->sc_pcidev, 1); - mem_len = pci_resource_len(sc->sc_pcidev, 1); - sc->sc_bar1 = (ocf_iomem_t) ioremap(mem_start, mem_len); - if (!sc->sc_bar1) { - device_printf(sc->sc_dev, "cannot map bar%d register space\n", 1); - goto fail; - } - sc->sc_bar1_lastreg = (bus_size_t) -1; - - /* fix up the bus size */ - if (pci_set_dma_mask(dev, DMA_32BIT_MASK)) { - device_printf(sc->sc_dev, "No usable DMA configuration, aborting.\n"); - goto fail; - } - if (pci_set_consistent_dma_mask(dev, DMA_32BIT_MASK)) { - device_printf(sc->sc_dev, - "No usable consistent DMA configuration, aborting.\n"); - goto fail; - } - - hifn_set_retry(sc); - - /* - * Setup the area where the Hifn DMA's descriptors - * and associated data structures. - */ - sc->sc_dma = (struct hifn_dma *) pci_alloc_consistent(dev, - sizeof(*sc->sc_dma), - &sc->sc_dma_physaddr); - if (!sc->sc_dma) { - device_printf(sc->sc_dev, "cannot alloc sc_dma\n"); - goto fail; - } - bzero(sc->sc_dma, sizeof(*sc->sc_dma)); - - /* - * Reset the board and do the ``secret handshake'' - * to enable the crypto support. Then complete the - * initialization procedure by setting up the interrupt - * and hooking in to the system crypto support so we'll - * get used for system services like the crypto device, - * IPsec, RNG device, etc. - */ - hifn_reset_board(sc, 0); - - if (hifn_enable_crypto(sc) != 0) { - device_printf(sc->sc_dev, "crypto enabling failed\n"); - goto fail; - } - hifn_reset_puc(sc); - - hifn_init_dma(sc); - hifn_init_pci_registers(sc); - - pci_set_master(sc->sc_pcidev); - - /* XXX can't dynamically determine ram type for 795x; force dram */ - if (sc->sc_flags & HIFN_IS_7956) - sc->sc_drammodel = 1; - else if (hifn_ramtype(sc)) - goto fail; - - if (sc->sc_drammodel == 0) - hifn_sramsize(sc); - else - hifn_dramsize(sc); - - /* - * Workaround for NetSec 7751 rev A: half ram size because two - * of the address lines were left floating - */ - if (pci_get_vendor(dev) == PCI_VENDOR_NETSEC && - pci_get_device(dev) == PCI_PRODUCT_NETSEC_7751 && - pci_get_revid(dev) == 0x61) /*XXX???*/ - sc->sc_ramsize >>= 1; - - /* - * Arrange the interrupt line. - */ - rc = request_irq(dev->irq, hifn_intr, IRQF_SHARED, "hifn", sc); - if (rc) { - device_printf(sc->sc_dev, "could not map interrupt: %d\n", rc); - goto fail; - } - sc->sc_irq = dev->irq; - - hifn_sessions(sc); - - /* - * NB: Keep only the low 16 bits; this masks the chip id - * from the 7951. - */ - rev = READ_REG_1(sc, HIFN_1_REVID) & 0xffff; - - rseg = sc->sc_ramsize / 1024; - rbase = 'K'; - if (sc->sc_ramsize >= (1024 * 1024)) { - rbase = 'M'; - rseg /= 1024; - } - device_printf(sc->sc_dev, "%s, rev %u, %d%cB %cram", - hifn_partname(sc), rev, - rseg, rbase, sc->sc_drammodel ? 'd' : 's'); - if (sc->sc_flags & HIFN_IS_7956) - printf(", pll=0x%x<%s clk, %ux mult>", - sc->sc_pllconfig, - sc->sc_pllconfig & HIFN_PLL_REF_SEL ? "ext" : "pci", - 2 + 2*((sc->sc_pllconfig & HIFN_PLL_ND) >> 11)); - printf("\n"); - - sc->sc_cid = crypto_get_driverid(softc_get_device(sc),CRYPTOCAP_F_HARDWARE); - if (sc->sc_cid < 0) { - device_printf(sc->sc_dev, "could not get crypto driver id\n"); - goto fail; - } - - WRITE_REG_0(sc, HIFN_0_PUCNFG, - READ_REG_0(sc, HIFN_0_PUCNFG) | HIFN_PUCNFG_CHIPID); - ena = READ_REG_0(sc, HIFN_0_PUSTAT) & HIFN_PUSTAT_CHIPENA; - - switch (ena) { - case HIFN_PUSTAT_ENA_2: - crypto_register(sc->sc_cid, CRYPTO_3DES_CBC, 0, 0); - crypto_register(sc->sc_cid, CRYPTO_ARC4, 0, 0); - if (sc->sc_flags & HIFN_HAS_AES) - crypto_register(sc->sc_cid, CRYPTO_AES_CBC, 0, 0); - /*FALLTHROUGH*/ - case HIFN_PUSTAT_ENA_1: - crypto_register(sc->sc_cid, CRYPTO_MD5, 0, 0); - crypto_register(sc->sc_cid, CRYPTO_SHA1, 0, 0); - crypto_register(sc->sc_cid, CRYPTO_MD5_HMAC, 0, 0); - crypto_register(sc->sc_cid, CRYPTO_SHA1_HMAC, 0, 0); - crypto_register(sc->sc_cid, CRYPTO_DES_CBC, 0, 0); - break; - } - - if (sc->sc_flags & (HIFN_HAS_PUBLIC | HIFN_HAS_RNG)) - hifn_init_pubrng(sc); - - init_timer(&sc->sc_tickto); - sc->sc_tickto.function = hifn_tick; - sc->sc_tickto.data = (unsigned long) sc->sc_num; - mod_timer(&sc->sc_tickto, jiffies + HZ); - - return (0); - -fail: - if (sc->sc_cid >= 0) - crypto_unregister_all(sc->sc_cid); - if (sc->sc_irq != -1) - free_irq(sc->sc_irq, sc); - if (sc->sc_dma) { - /* Turn off DMA polling */ - WRITE_REG_1(sc, HIFN_1_DMA_CNFG, HIFN_DMACNFG_MSTRESET | - HIFN_DMACNFG_DMARESET | HIFN_DMACNFG_MODE); - - pci_free_consistent(sc->sc_pcidev, - sizeof(*sc->sc_dma), - sc->sc_dma, sc->sc_dma_physaddr); - } - kfree(sc); - return (-ENXIO); -} - -/* - * Detach an interface that successfully probed. - */ -static void -hifn_remove(struct pci_dev *dev) -{ - struct hifn_softc *sc = pci_get_drvdata(dev); - unsigned long l_flags; - - DPRINTF("%s()\n", __FUNCTION__); - - KASSERT(sc != NULL, ("hifn_detach: null software carrier!")); - - /* disable interrupts */ - HIFN_LOCK(sc); - WRITE_REG_1(sc, HIFN_1_DMA_IER, 0); - HIFN_UNLOCK(sc); - - /*XXX other resources */ - del_timer_sync(&sc->sc_tickto); - - /* Turn off DMA polling */ - WRITE_REG_1(sc, HIFN_1_DMA_CNFG, HIFN_DMACNFG_MSTRESET | - HIFN_DMACNFG_DMARESET | HIFN_DMACNFG_MODE); - - crypto_unregister_all(sc->sc_cid); - - free_irq(sc->sc_irq, sc); - - pci_free_consistent(sc->sc_pcidev, sizeof(*sc->sc_dma), - sc->sc_dma, sc->sc_dma_physaddr); -} - - -static int -hifn_init_pubrng(struct hifn_softc *sc) -{ - int i; - - DPRINTF("%s()\n", __FUNCTION__); - - if ((sc->sc_flags & HIFN_IS_7811) == 0) { - /* Reset 7951 public key/rng engine */ - WRITE_REG_1(sc, HIFN_1_PUB_RESET, - READ_REG_1(sc, HIFN_1_PUB_RESET) | HIFN_PUBRST_RESET); - - for (i = 0; i < 100; i++) { - DELAY(1000); - if ((READ_REG_1(sc, HIFN_1_PUB_RESET) & - HIFN_PUBRST_RESET) == 0) - break; - } - - if (i == 100) { - device_printf(sc->sc_dev, "public key init failed\n"); - return (1); - } - } - - /* Enable the rng, if available */ -#ifdef CONFIG_OCF_RANDOMHARVEST - if (sc->sc_flags & HIFN_HAS_RNG) { - if (sc->sc_flags & HIFN_IS_7811) { - u_int32_t r; - r = READ_REG_1(sc, HIFN_1_7811_RNGENA); - if (r & HIFN_7811_RNGENA_ENA) { - r &= ~HIFN_7811_RNGENA_ENA; - WRITE_REG_1(sc, HIFN_1_7811_RNGENA, r); - } - WRITE_REG_1(sc, HIFN_1_7811_RNGCFG, - HIFN_7811_RNGCFG_DEFL); - r |= HIFN_7811_RNGENA_ENA; - WRITE_REG_1(sc, HIFN_1_7811_RNGENA, r); - } else - WRITE_REG_1(sc, HIFN_1_RNG_CONFIG, - READ_REG_1(sc, HIFN_1_RNG_CONFIG) | - HIFN_RNGCFG_ENA); - - sc->sc_rngfirst = 1; - crypto_rregister(sc->sc_cid, hifn_read_random, sc); - } -#endif - - /* Enable public key engine, if available */ - if (sc->sc_flags & HIFN_HAS_PUBLIC) { - WRITE_REG_1(sc, HIFN_1_PUB_IEN, HIFN_PUBIEN_DONE); - sc->sc_dmaier |= HIFN_DMAIER_PUBDONE; - WRITE_REG_1(sc, HIFN_1_DMA_IER, sc->sc_dmaier); -#ifdef HIFN_VULCANDEV - sc->sc_pkdev = make_dev(&vulcanpk_cdevsw, 0, - UID_ROOT, GID_WHEEL, 0666, - "vulcanpk"); - sc->sc_pkdev->si_drv1 = sc; -#endif - } - - return (0); -} - -#ifdef CONFIG_OCF_RANDOMHARVEST -static int -hifn_read_random(void *arg, u_int32_t *buf, int len) -{ - struct hifn_softc *sc = (struct hifn_softc *) arg; - u_int32_t sts; - int i, rc = 0; - - if (len <= 0) - return rc; - - if (sc->sc_flags & HIFN_IS_7811) { - /* ONLY VALID ON 7811!!!! */ - for (i = 0; i < 5; i++) { - sts = READ_REG_1(sc, HIFN_1_7811_RNGSTS); - if (sts & HIFN_7811_RNGSTS_UFL) { - device_printf(sc->sc_dev, - "RNG underflow: disabling\n"); - /* DAVIDM perhaps return -1 */ - break; - } - if ((sts & HIFN_7811_RNGSTS_RDY) == 0) - break; - - /* - * There are at least two words in the RNG FIFO - * at this point. - */ - if (rc < len) - buf[rc++] = READ_REG_1(sc, HIFN_1_7811_RNGDAT); - if (rc < len) - buf[rc++] = READ_REG_1(sc, HIFN_1_7811_RNGDAT); - } - } else - buf[rc++] = READ_REG_1(sc, HIFN_1_RNG_DATA); - - /* NB: discard first data read */ - if (sc->sc_rngfirst) { - sc->sc_rngfirst = 0; - rc = 0; - } - - return(rc); -} -#endif /* CONFIG_OCF_RANDOMHARVEST */ - -static void -hifn_puc_wait(struct hifn_softc *sc) -{ - int i; - int reg = HIFN_0_PUCTRL; - - if (sc->sc_flags & HIFN_IS_7956) { - reg = HIFN_0_PUCTRL2; - } - - for (i = 5000; i > 0; i--) { - DELAY(1); - if (!(READ_REG_0(sc, reg) & HIFN_PUCTRL_RESET)) - break; - } - if (!i) - device_printf(sc->sc_dev, "proc unit did not reset(0x%x)\n", - READ_REG_0(sc, HIFN_0_PUCTRL)); -} - -/* - * Reset the processing unit. - */ -static void -hifn_reset_puc(struct hifn_softc *sc) -{ - /* Reset processing unit */ - int reg = HIFN_0_PUCTRL; - - if (sc->sc_flags & HIFN_IS_7956) { - reg = HIFN_0_PUCTRL2; - } - WRITE_REG_0(sc, reg, HIFN_PUCTRL_DMAENA); - - hifn_puc_wait(sc); -} - -/* - * Set the Retry and TRDY registers; note that we set them to - * zero because the 7811 locks up when forced to retry (section - * 3.6 of "Specification Update SU-0014-04". Not clear if we - * should do this for all Hifn parts, but it doesn't seem to hurt. - */ -static void -hifn_set_retry(struct hifn_softc *sc) -{ - DPRINTF("%s()\n", __FUNCTION__); - /* NB: RETRY only responds to 8-bit reads/writes */ - pci_write_config_byte(sc->sc_pcidev, HIFN_RETRY_TIMEOUT, 0); - pci_write_config_dword(sc->sc_pcidev, HIFN_TRDY_TIMEOUT, 0); - /* piggy back the cache line setting here */ - pci_write_config_byte(sc->sc_pcidev, PCI_CACHE_LINE_SIZE, hifn_cache_linesize); -} - -/* - * Resets the board. Values in the regesters are left as is - * from the reset (i.e. initial values are assigned elsewhere). - */ -static void -hifn_reset_board(struct hifn_softc *sc, int full) -{ - u_int32_t reg; - - DPRINTF("%s()\n", __FUNCTION__); - /* - * Set polling in the DMA configuration register to zero. 0x7 avoids - * resetting the board and zeros out the other fields. - */ - WRITE_REG_1(sc, HIFN_1_DMA_CNFG, HIFN_DMACNFG_MSTRESET | - HIFN_DMACNFG_DMARESET | HIFN_DMACNFG_MODE); - - /* - * Now that polling has been disabled, we have to wait 1 ms - * before resetting the board. - */ - DELAY(1000); - - /* Reset the DMA unit */ - if (full) { - WRITE_REG_1(sc, HIFN_1_DMA_CNFG, HIFN_DMACNFG_MODE); - DELAY(1000); - } else { - WRITE_REG_1(sc, HIFN_1_DMA_CNFG, - HIFN_DMACNFG_MODE | HIFN_DMACNFG_MSTRESET); - hifn_reset_puc(sc); - } - - KASSERT(sc->sc_dma != NULL, ("hifn_reset_board: null DMA tag!")); - bzero(sc->sc_dma, sizeof(*sc->sc_dma)); - - /* Bring dma unit out of reset */ - WRITE_REG_1(sc, HIFN_1_DMA_CNFG, HIFN_DMACNFG_MSTRESET | - HIFN_DMACNFG_DMARESET | HIFN_DMACNFG_MODE); - - hifn_puc_wait(sc); - hifn_set_retry(sc); - - if (sc->sc_flags & HIFN_IS_7811) { - for (reg = 0; reg < 1000; reg++) { - if (READ_REG_1(sc, HIFN_1_7811_MIPSRST) & - HIFN_MIPSRST_CRAMINIT) - break; - DELAY(1000); - } - if (reg == 1000) - device_printf(sc->sc_dev, ": cram init timeout\n"); - } else { - /* set up DMA configuration register #2 */ - /* turn off all PK and BAR0 swaps */ - WRITE_REG_1(sc, HIFN_1_DMA_CNFG2, - (3 << HIFN_DMACNFG2_INIT_WRITE_BURST_SHIFT)| - (3 << HIFN_DMACNFG2_INIT_READ_BURST_SHIFT)| - (2 << HIFN_DMACNFG2_TGT_WRITE_BURST_SHIFT)| - (2 << HIFN_DMACNFG2_TGT_READ_BURST_SHIFT)); - } -} - -static u_int32_t -hifn_next_signature(u_int32_t a, u_int cnt) -{ - int i; - u_int32_t v; - - for (i = 0; i < cnt; i++) { - - /* get the parity */ - v = a & 0x80080125; - v ^= v >> 16; - v ^= v >> 8; - v ^= v >> 4; - v ^= v >> 2; - v ^= v >> 1; - - a = (v & 1) ^ (a << 1); - } - - return a; -} - - -/* - * Checks to see if crypto is already enabled. If crypto isn't enable, - * "hifn_enable_crypto" is called to enable it. The check is important, - * as enabling crypto twice will lock the board. - */ -static int -hifn_enable_crypto(struct hifn_softc *sc) -{ - u_int32_t dmacfg, ramcfg, encl, addr, i; - char offtbl[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 }; - - DPRINTF("%s()\n", __FUNCTION__); - - ramcfg = READ_REG_0(sc, HIFN_0_PUCNFG); - dmacfg = READ_REG_1(sc, HIFN_1_DMA_CNFG); - - /* - * The RAM config register's encrypt level bit needs to be set before - * every read performed on the encryption level register. - */ - WRITE_REG_0(sc, HIFN_0_PUCNFG, ramcfg | HIFN_PUCNFG_CHIPID); - - encl = READ_REG_0(sc, HIFN_0_PUSTAT) & HIFN_PUSTAT_CHIPENA; - - /* - * Make sure we don't re-unlock. Two unlocks kills chip until the - * next reboot. - */ - if (encl == HIFN_PUSTAT_ENA_1 || encl == HIFN_PUSTAT_ENA_2) { -#ifdef HIFN_DEBUG - if (hifn_debug) - device_printf(sc->sc_dev, - "Strong crypto already enabled!\n"); -#endif - goto report; - } - - if (encl != 0 && encl != HIFN_PUSTAT_ENA_0) { -#ifdef HIFN_DEBUG - if (hifn_debug) - device_printf(sc->sc_dev, - "Unknown encryption level 0x%x\n", encl); -#endif - return 1; - } - - WRITE_REG_1(sc, HIFN_1_DMA_CNFG, HIFN_DMACNFG_UNLOCK | - HIFN_DMACNFG_MSTRESET | HIFN_DMACNFG_DMARESET | HIFN_DMACNFG_MODE); - DELAY(1000); - addr = READ_REG_1(sc, HIFN_UNLOCK_SECRET1); - DELAY(1000); - WRITE_REG_1(sc, HIFN_UNLOCK_SECRET2, 0); - DELAY(1000); - - for (i = 0; i <= 12; i++) { - addr = hifn_next_signature(addr, offtbl[i] + 0x101); - WRITE_REG_1(sc, HIFN_UNLOCK_SECRET2, addr); - - DELAY(1000); - } - - WRITE_REG_0(sc, HIFN_0_PUCNFG, ramcfg | HIFN_PUCNFG_CHIPID); - encl = READ_REG_0(sc, HIFN_0_PUSTAT) & HIFN_PUSTAT_CHIPENA; - -#ifdef HIFN_DEBUG - if (hifn_debug) { - if (encl != HIFN_PUSTAT_ENA_1 && encl != HIFN_PUSTAT_ENA_2) - device_printf(sc->sc_dev, "Engine is permanently " - "locked until next system reset!\n"); - else - device_printf(sc->sc_dev, "Engine enabled " - "successfully!\n"); - } -#endif - -report: - WRITE_REG_0(sc, HIFN_0_PUCNFG, ramcfg); - WRITE_REG_1(sc, HIFN_1_DMA_CNFG, dmacfg); - - switch (encl) { - case HIFN_PUSTAT_ENA_1: - case HIFN_PUSTAT_ENA_2: - break; - case HIFN_PUSTAT_ENA_0: - default: - device_printf(sc->sc_dev, "disabled\n"); - break; - } - - return 0; -} - -/* - * Give initial values to the registers listed in the "Register Space" - * section of the HIFN Software Development reference manual. - */ -static void -hifn_init_pci_registers(struct hifn_softc *sc) -{ - DPRINTF("%s()\n", __FUNCTION__); - - /* write fixed values needed by the Initialization registers */ - WRITE_REG_0(sc, HIFN_0_PUCTRL, HIFN_PUCTRL_DMAENA); - WRITE_REG_0(sc, HIFN_0_FIFOCNFG, HIFN_FIFOCNFG_THRESHOLD); - WRITE_REG_0(sc, HIFN_0_PUIER, HIFN_PUIER_DSTOVER); - - /* write all 4 ring address registers */ - WRITE_REG_1(sc, HIFN_1_DMA_CRAR, sc->sc_dma_physaddr + - offsetof(struct hifn_dma, cmdr[0])); - WRITE_REG_1(sc, HIFN_1_DMA_SRAR, sc->sc_dma_physaddr + - offsetof(struct hifn_dma, srcr[0])); - WRITE_REG_1(sc, HIFN_1_DMA_DRAR, sc->sc_dma_physaddr + - offsetof(struct hifn_dma, dstr[0])); - WRITE_REG_1(sc, HIFN_1_DMA_RRAR, sc->sc_dma_physaddr + - offsetof(struct hifn_dma, resr[0])); - - DELAY(2000); - - /* write status register */ - WRITE_REG_1(sc, HIFN_1_DMA_CSR, - HIFN_DMACSR_D_CTRL_DIS | HIFN_DMACSR_R_CTRL_DIS | - HIFN_DMACSR_S_CTRL_DIS | HIFN_DMACSR_C_CTRL_DIS | - HIFN_DMACSR_D_ABORT | HIFN_DMACSR_D_DONE | HIFN_DMACSR_D_LAST | - HIFN_DMACSR_D_WAIT | HIFN_DMACSR_D_OVER | - HIFN_DMACSR_R_ABORT | HIFN_DMACSR_R_DONE | HIFN_DMACSR_R_LAST | - HIFN_DMACSR_R_WAIT | HIFN_DMACSR_R_OVER | - HIFN_DMACSR_S_ABORT | HIFN_DMACSR_S_DONE | HIFN_DMACSR_S_LAST | - HIFN_DMACSR_S_WAIT | - HIFN_DMACSR_C_ABORT | HIFN_DMACSR_C_DONE | HIFN_DMACSR_C_LAST | - HIFN_DMACSR_C_WAIT | - HIFN_DMACSR_ENGINE | - ((sc->sc_flags & HIFN_HAS_PUBLIC) ? - HIFN_DMACSR_PUBDONE : 0) | - ((sc->sc_flags & HIFN_IS_7811) ? - HIFN_DMACSR_ILLW | HIFN_DMACSR_ILLR : 0)); - - sc->sc_d_busy = sc->sc_r_busy = sc->sc_s_busy = sc->sc_c_busy = 0; - sc->sc_dmaier |= HIFN_DMAIER_R_DONE | HIFN_DMAIER_C_ABORT | - HIFN_DMAIER_D_OVER | HIFN_DMAIER_R_OVER | - HIFN_DMAIER_S_ABORT | HIFN_DMAIER_D_ABORT | HIFN_DMAIER_R_ABORT | - ((sc->sc_flags & HIFN_IS_7811) ? - HIFN_DMAIER_ILLW | HIFN_DMAIER_ILLR : 0); - sc->sc_dmaier &= ~HIFN_DMAIER_C_WAIT; - WRITE_REG_1(sc, HIFN_1_DMA_IER, sc->sc_dmaier); - - - if (sc->sc_flags & HIFN_IS_7956) { - u_int32_t pll; - - WRITE_REG_0(sc, HIFN_0_PUCNFG, HIFN_PUCNFG_COMPSING | - HIFN_PUCNFG_TCALLPHASES | - HIFN_PUCNFG_TCDRVTOTEM | HIFN_PUCNFG_BUS32); - - /* turn off the clocks and insure bypass is set */ - pll = READ_REG_1(sc, HIFN_1_PLL); - pll = (pll &~ (HIFN_PLL_PK_CLK_SEL | HIFN_PLL_PE_CLK_SEL)) - | HIFN_PLL_BP | HIFN_PLL_MBSET; - WRITE_REG_1(sc, HIFN_1_PLL, pll); - DELAY(10*1000); /* 10ms */ - - /* change configuration */ - pll = (pll &~ HIFN_PLL_CONFIG) | sc->sc_pllconfig; - WRITE_REG_1(sc, HIFN_1_PLL, pll); - DELAY(10*1000); /* 10ms */ - - /* disable bypass */ - pll &= ~HIFN_PLL_BP; - WRITE_REG_1(sc, HIFN_1_PLL, pll); - /* enable clocks with new configuration */ - pll |= HIFN_PLL_PK_CLK_SEL | HIFN_PLL_PE_CLK_SEL; - WRITE_REG_1(sc, HIFN_1_PLL, pll); - } else { - WRITE_REG_0(sc, HIFN_0_PUCNFG, HIFN_PUCNFG_COMPSING | - HIFN_PUCNFG_DRFR_128 | HIFN_PUCNFG_TCALLPHASES | - HIFN_PUCNFG_TCDRVTOTEM | HIFN_PUCNFG_BUS32 | - (sc->sc_drammodel ? HIFN_PUCNFG_DRAM : HIFN_PUCNFG_SRAM)); - } - - WRITE_REG_0(sc, HIFN_0_PUISR, HIFN_PUISR_DSTOVER); - WRITE_REG_1(sc, HIFN_1_DMA_CNFG, HIFN_DMACNFG_MSTRESET | - HIFN_DMACNFG_DMARESET | HIFN_DMACNFG_MODE | HIFN_DMACNFG_LAST | - ((HIFN_POLL_FREQUENCY << 16 ) & HIFN_DMACNFG_POLLFREQ) | - ((HIFN_POLL_SCALAR << 8) & HIFN_DMACNFG_POLLINVAL)); -} - -/* - * The maximum number of sessions supported by the card - * is dependent on the amount of context ram, which - * encryption algorithms are enabled, and how compression - * is configured. This should be configured before this - * routine is called. - */ -static void -hifn_sessions(struct hifn_softc *sc) -{ - u_int32_t pucnfg; - int ctxsize; - - DPRINTF("%s()\n", __FUNCTION__); - - pucnfg = READ_REG_0(sc, HIFN_0_PUCNFG); - - if (pucnfg & HIFN_PUCNFG_COMPSING) { - if (pucnfg & HIFN_PUCNFG_ENCCNFG) - ctxsize = 128; - else - ctxsize = 512; - /* - * 7955/7956 has internal context memory of 32K - */ - if (sc->sc_flags & HIFN_IS_7956) - sc->sc_maxses = 32768 / ctxsize; - else - sc->sc_maxses = 1 + - ((sc->sc_ramsize - 32768) / ctxsize); - } else - sc->sc_maxses = sc->sc_ramsize / 16384; - - if (sc->sc_maxses > 2048) - sc->sc_maxses = 2048; -} - -/* - * Determine ram type (sram or dram). Board should be just out of a reset - * state when this is called. - */ -static int -hifn_ramtype(struct hifn_softc *sc) -{ - u_int8_t data[8], dataexpect[8]; - int i; - - for (i = 0; i < sizeof(data); i++) - data[i] = dataexpect[i] = 0x55; - if (hifn_writeramaddr(sc, 0, data)) - return (-1); - if (hifn_readramaddr(sc, 0, data)) - return (-1); - if (bcmp(data, dataexpect, sizeof(data)) != 0) { - sc->sc_drammodel = 1; - return (0); - } - - for (i = 0; i < sizeof(data); i++) - data[i] = dataexpect[i] = 0xaa; - if (hifn_writeramaddr(sc, 0, data)) - return (-1); - if (hifn_readramaddr(sc, 0, data)) - return (-1); - if (bcmp(data, dataexpect, sizeof(data)) != 0) { - sc->sc_drammodel = 1; - return (0); - } - - return (0); -} - -#define HIFN_SRAM_MAX (32 << 20) -#define HIFN_SRAM_STEP_SIZE 16384 -#define HIFN_SRAM_GRANULARITY (HIFN_SRAM_MAX / HIFN_SRAM_STEP_SIZE) - -static int -hifn_sramsize(struct hifn_softc *sc) -{ - u_int32_t a; - u_int8_t data[8]; - u_int8_t dataexpect[sizeof(data)]; - int32_t i; - - for (i = 0; i < sizeof(data); i++) - data[i] = dataexpect[i] = i ^ 0x5a; - - for (i = HIFN_SRAM_GRANULARITY - 1; i >= 0; i--) { - a = i * HIFN_SRAM_STEP_SIZE; - bcopy(&i, data, sizeof(i)); - hifn_writeramaddr(sc, a, data); - } - - for (i = 0; i < HIFN_SRAM_GRANULARITY; i++) { - a = i * HIFN_SRAM_STEP_SIZE; - bcopy(&i, dataexpect, sizeof(i)); - if (hifn_readramaddr(sc, a, data) < 0) - return (0); - if (bcmp(data, dataexpect, sizeof(data)) != 0) - return (0); - sc->sc_ramsize = a + HIFN_SRAM_STEP_SIZE; - } - - return (0); -} - -/* - * XXX For dram boards, one should really try all of the - * HIFN_PUCNFG_DSZ_*'s. This just assumes that PUCNFG - * is already set up correctly. - */ -static int -hifn_dramsize(struct hifn_softc *sc) -{ - u_int32_t cnfg; - - if (sc->sc_flags & HIFN_IS_7956) { - /* - * 7955/7956 have a fixed internal ram of only 32K. - */ - sc->sc_ramsize = 32768; - } else { - cnfg = READ_REG_0(sc, HIFN_0_PUCNFG) & - HIFN_PUCNFG_DRAMMASK; - sc->sc_ramsize = 1 << ((cnfg >> 13) + 18); - } - return (0); -} - -static void -hifn_alloc_slot(struct hifn_softc *sc, int *cmdp, int *srcp, int *dstp, int *resp) -{ - struct hifn_dma *dma = sc->sc_dma; - - DPRINTF("%s()\n", __FUNCTION__); - - if (dma->cmdi == HIFN_D_CMD_RSIZE) { - dma->cmdi = 0; - dma->cmdr[HIFN_D_CMD_RSIZE].l = htole32(HIFN_D_JUMP|HIFN_D_MASKDONEIRQ); - wmb(); - dma->cmdr[HIFN_D_CMD_RSIZE].l |= htole32(HIFN_D_VALID); - HIFN_CMDR_SYNC(sc, HIFN_D_CMD_RSIZE, - BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); - } - *cmdp = dma->cmdi++; - dma->cmdk = dma->cmdi; - - if (dma->srci == HIFN_D_SRC_RSIZE) { - dma->srci = 0; - dma->srcr[HIFN_D_SRC_RSIZE].l = htole32(HIFN_D_JUMP|HIFN_D_MASKDONEIRQ); - wmb(); - dma->srcr[HIFN_D_SRC_RSIZE].l |= htole32(HIFN_D_VALID); - HIFN_SRCR_SYNC(sc, HIFN_D_SRC_RSIZE, - BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); - } - *srcp = dma->srci++; - dma->srck = dma->srci; - - if (dma->dsti == HIFN_D_DST_RSIZE) { - dma->dsti = 0; - dma->dstr[HIFN_D_DST_RSIZE].l = htole32(HIFN_D_JUMP|HIFN_D_MASKDONEIRQ); - wmb(); - dma->dstr[HIFN_D_DST_RSIZE].l |= htole32(HIFN_D_VALID); - HIFN_DSTR_SYNC(sc, HIFN_D_DST_RSIZE, - BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); - } - *dstp = dma->dsti++; - dma->dstk = dma->dsti; - - if (dma->resi == HIFN_D_RES_RSIZE) { - dma->resi = 0; - dma->resr[HIFN_D_RES_RSIZE].l = htole32(HIFN_D_JUMP|HIFN_D_MASKDONEIRQ); - wmb(); - dma->resr[HIFN_D_RES_RSIZE].l |= htole32(HIFN_D_VALID); - HIFN_RESR_SYNC(sc, HIFN_D_RES_RSIZE, - BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); - } - *resp = dma->resi++; - dma->resk = dma->resi; -} - -static int -hifn_writeramaddr(struct hifn_softc *sc, int addr, u_int8_t *data) -{ - struct hifn_dma *dma = sc->sc_dma; - hifn_base_command_t wc; - const u_int32_t masks = HIFN_D_VALID | HIFN_D_LAST | HIFN_D_MASKDONEIRQ; - int r, cmdi, resi, srci, dsti; - - DPRINTF("%s()\n", __FUNCTION__); - - wc.masks = htole16(3 << 13); - wc.session_num = htole16(addr >> 14); - wc.total_source_count = htole16(8); - wc.total_dest_count = htole16(addr & 0x3fff); - - hifn_alloc_slot(sc, &cmdi, &srci, &dsti, &resi); - - WRITE_REG_1(sc, HIFN_1_DMA_CSR, - HIFN_DMACSR_C_CTRL_ENA | HIFN_DMACSR_S_CTRL_ENA | - HIFN_DMACSR_D_CTRL_ENA | HIFN_DMACSR_R_CTRL_ENA); - - /* build write command */ - bzero(dma->command_bufs[cmdi], HIFN_MAX_COMMAND); - *(hifn_base_command_t *)dma->command_bufs[cmdi] = wc; - bcopy(data, &dma->test_src, sizeof(dma->test_src)); - - dma->srcr[srci].p = htole32(sc->sc_dma_physaddr - + offsetof(struct hifn_dma, test_src)); - dma->dstr[dsti].p = htole32(sc->sc_dma_physaddr - + offsetof(struct hifn_dma, test_dst)); - - dma->cmdr[cmdi].l = htole32(16 | masks); - dma->srcr[srci].l = htole32(8 | masks); - dma->dstr[dsti].l = htole32(4 | masks); - dma->resr[resi].l = htole32(4 | masks); - - for (r = 10000; r >= 0; r--) { - DELAY(10); - if ((dma->resr[resi].l & htole32(HIFN_D_VALID)) == 0) - break; - } - if (r == 0) { - device_printf(sc->sc_dev, "writeramaddr -- " - "result[%d](addr %d) still valid\n", resi, addr); - r = -1; - return (-1); - } else - r = 0; - - WRITE_REG_1(sc, HIFN_1_DMA_CSR, - HIFN_DMACSR_C_CTRL_DIS | HIFN_DMACSR_S_CTRL_DIS | - HIFN_DMACSR_D_CTRL_DIS | HIFN_DMACSR_R_CTRL_DIS); - - return (r); -} - -static int -hifn_readramaddr(struct hifn_softc *sc, int addr, u_int8_t *data) -{ - struct hifn_dma *dma = sc->sc_dma; - hifn_base_command_t rc; - const u_int32_t masks = HIFN_D_VALID | HIFN_D_LAST | HIFN_D_MASKDONEIRQ; - int r, cmdi, srci, dsti, resi; - - DPRINTF("%s()\n", __FUNCTION__); - - rc.masks = htole16(2 << 13); - rc.session_num = htole16(addr >> 14); - rc.total_source_count = htole16(addr & 0x3fff); - rc.total_dest_count = htole16(8); - - hifn_alloc_slot(sc, &cmdi, &srci, &dsti, &resi); - - WRITE_REG_1(sc, HIFN_1_DMA_CSR, - HIFN_DMACSR_C_CTRL_ENA | HIFN_DMACSR_S_CTRL_ENA | - HIFN_DMACSR_D_CTRL_ENA | HIFN_DMACSR_R_CTRL_ENA); - - bzero(dma->command_bufs[cmdi], HIFN_MAX_COMMAND); - *(hifn_base_command_t *)dma->command_bufs[cmdi] = rc; - - dma->srcr[srci].p = htole32(sc->sc_dma_physaddr + - offsetof(struct hifn_dma, test_src)); - dma->test_src = 0; - dma->dstr[dsti].p = htole32(sc->sc_dma_physaddr + - offsetof(struct hifn_dma, test_dst)); - dma->test_dst = 0; - dma->cmdr[cmdi].l = htole32(8 | masks); - dma->srcr[srci].l = htole32(8 | masks); - dma->dstr[dsti].l = htole32(8 | masks); - dma->resr[resi].l = htole32(HIFN_MAX_RESULT | masks); - - for (r = 10000; r >= 0; r--) { - DELAY(10); - if ((dma->resr[resi].l & htole32(HIFN_D_VALID)) == 0) - break; - } - if (r == 0) { - device_printf(sc->sc_dev, "readramaddr -- " - "result[%d](addr %d) still valid\n", resi, addr); - r = -1; - } else { - r = 0; - bcopy(&dma->test_dst, data, sizeof(dma->test_dst)); - } - - WRITE_REG_1(sc, HIFN_1_DMA_CSR, - HIFN_DMACSR_C_CTRL_DIS | HIFN_DMACSR_S_CTRL_DIS | - HIFN_DMACSR_D_CTRL_DIS | HIFN_DMACSR_R_CTRL_DIS); - - return (r); -} - -/* - * Initialize the descriptor rings. - */ -static void -hifn_init_dma(struct hifn_softc *sc) -{ - struct hifn_dma *dma = sc->sc_dma; - int i; - - DPRINTF("%s()\n", __FUNCTION__); - - hifn_set_retry(sc); - - /* initialize static pointer values */ - for (i = 0; i < HIFN_D_CMD_RSIZE; i++) - dma->cmdr[i].p = htole32(sc->sc_dma_physaddr + - offsetof(struct hifn_dma, command_bufs[i][0])); - for (i = 0; i < HIFN_D_RES_RSIZE; i++) - dma->resr[i].p = htole32(sc->sc_dma_physaddr + - offsetof(struct hifn_dma, result_bufs[i][0])); - - dma->cmdr[HIFN_D_CMD_RSIZE].p = - htole32(sc->sc_dma_physaddr + offsetof(struct hifn_dma, cmdr[0])); - dma->srcr[HIFN_D_SRC_RSIZE].p = - htole32(sc->sc_dma_physaddr + offsetof(struct hifn_dma, srcr[0])); - dma->dstr[HIFN_D_DST_RSIZE].p = - htole32(sc->sc_dma_physaddr + offsetof(struct hifn_dma, dstr[0])); - dma->resr[HIFN_D_RES_RSIZE].p = - htole32(sc->sc_dma_physaddr + offsetof(struct hifn_dma, resr[0])); - - dma->cmdu = dma->srcu = dma->dstu = dma->resu = 0; - dma->cmdi = dma->srci = dma->dsti = dma->resi = 0; - dma->cmdk = dma->srck = dma->dstk = dma->resk = 0; -} - -/* - * Writes out the raw command buffer space. Returns the - * command buffer size. - */ -static u_int -hifn_write_command(struct hifn_command *cmd, u_int8_t *buf) -{ - struct hifn_softc *sc = NULL; - u_int8_t *buf_pos; - hifn_base_command_t *base_cmd; - hifn_mac_command_t *mac_cmd; - hifn_crypt_command_t *cry_cmd; - int using_mac, using_crypt, len, ivlen; - u_int32_t dlen, slen; - - DPRINTF("%s()\n", __FUNCTION__); - - buf_pos = buf; - using_mac = cmd->base_masks & HIFN_BASE_CMD_MAC; - using_crypt = cmd->base_masks & HIFN_BASE_CMD_CRYPT; - - base_cmd = (hifn_base_command_t *)buf_pos; - base_cmd->masks = htole16(cmd->base_masks); - slen = cmd->src_mapsize; - if (cmd->sloplen) - dlen = cmd->dst_mapsize - cmd->sloplen + sizeof(u_int32_t); - else - dlen = cmd->dst_mapsize; - base_cmd->total_source_count = htole16(slen & HIFN_BASE_CMD_LENMASK_LO); - base_cmd->total_dest_count = htole16(dlen & HIFN_BASE_CMD_LENMASK_LO); - dlen >>= 16; - slen >>= 16; - base_cmd->session_num = htole16( - ((slen << HIFN_BASE_CMD_SRCLEN_S) & HIFN_BASE_CMD_SRCLEN_M) | - ((dlen << HIFN_BASE_CMD_DSTLEN_S) & HIFN_BASE_CMD_DSTLEN_M)); - buf_pos += sizeof(hifn_base_command_t); - - if (using_mac) { - mac_cmd = (hifn_mac_command_t *)buf_pos; - dlen = cmd->maccrd->crd_len; - mac_cmd->source_count = htole16(dlen & 0xffff); - dlen >>= 16; - mac_cmd->masks = htole16(cmd->mac_masks | - ((dlen << HIFN_MAC_CMD_SRCLEN_S) & HIFN_MAC_CMD_SRCLEN_M)); - mac_cmd->header_skip = htole16(cmd->maccrd->crd_skip); - mac_cmd->reserved = 0; - buf_pos += sizeof(hifn_mac_command_t); - } - - if (using_crypt) { - cry_cmd = (hifn_crypt_command_t *)buf_pos; - dlen = cmd->enccrd->crd_len; - cry_cmd->source_count = htole16(dlen & 0xffff); - dlen >>= 16; - cry_cmd->masks = htole16(cmd->cry_masks | - ((dlen << HIFN_CRYPT_CMD_SRCLEN_S) & HIFN_CRYPT_CMD_SRCLEN_M)); - cry_cmd->header_skip = htole16(cmd->enccrd->crd_skip); - cry_cmd->reserved = 0; - buf_pos += sizeof(hifn_crypt_command_t); - } - - if (using_mac && cmd->mac_masks & HIFN_MAC_CMD_NEW_KEY) { - bcopy(cmd->mac, buf_pos, HIFN_MAC_KEY_LENGTH); - buf_pos += HIFN_MAC_KEY_LENGTH; - } - - if (using_crypt && cmd->cry_masks & HIFN_CRYPT_CMD_NEW_KEY) { - switch (cmd->cry_masks & HIFN_CRYPT_CMD_ALG_MASK) { - case HIFN_CRYPT_CMD_ALG_3DES: - bcopy(cmd->ck, buf_pos, HIFN_3DES_KEY_LENGTH); - buf_pos += HIFN_3DES_KEY_LENGTH; - break; - case HIFN_CRYPT_CMD_ALG_DES: - bcopy(cmd->ck, buf_pos, HIFN_DES_KEY_LENGTH); - buf_pos += HIFN_DES_KEY_LENGTH; - break; - case HIFN_CRYPT_CMD_ALG_RC4: - len = 256; - do { - int clen; - - clen = MIN(cmd->cklen, len); - bcopy(cmd->ck, buf_pos, clen); - len -= clen; - buf_pos += clen; - } while (len > 0); - bzero(buf_pos, 4); - buf_pos += 4; - break; - case HIFN_CRYPT_CMD_ALG_AES: - /* - * AES keys are variable 128, 192 and - * 256 bits (16, 24 and 32 bytes). - */ - bcopy(cmd->ck, buf_pos, cmd->cklen); - buf_pos += cmd->cklen; - break; - } - } - - if (using_crypt && cmd->cry_masks & HIFN_CRYPT_CMD_NEW_IV) { - switch (cmd->cry_masks & HIFN_CRYPT_CMD_ALG_MASK) { - case HIFN_CRYPT_CMD_ALG_AES: - ivlen = HIFN_AES_IV_LENGTH; - break; - default: - ivlen = HIFN_IV_LENGTH; - break; - } - bcopy(cmd->iv, buf_pos, ivlen); - buf_pos += ivlen; - } - - if ((cmd->base_masks & (HIFN_BASE_CMD_MAC|HIFN_BASE_CMD_CRYPT)) == 0) { - bzero(buf_pos, 8); - buf_pos += 8; - } - - return (buf_pos - buf); -} - -static int -hifn_dmamap_aligned(struct hifn_operand *op) -{ - struct hifn_softc *sc = NULL; - int i; - - DPRINTF("%s()\n", __FUNCTION__); - - for (i = 0; i < op->nsegs; i++) { - if (op->segs[i].ds_addr & 3) - return (0); - if ((i != (op->nsegs - 1)) && (op->segs[i].ds_len & 3)) - return (0); - } - return (1); -} - -static __inline int -hifn_dmamap_dstwrap(struct hifn_softc *sc, int idx) -{ - struct hifn_dma *dma = sc->sc_dma; - - if (++idx == HIFN_D_DST_RSIZE) { - dma->dstr[idx].l = htole32(HIFN_D_VALID | HIFN_D_JUMP | - HIFN_D_MASKDONEIRQ); - HIFN_DSTR_SYNC(sc, idx, - BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); - idx = 0; - } - return (idx); -} - -static int -hifn_dmamap_load_dst(struct hifn_softc *sc, struct hifn_command *cmd) -{ - struct hifn_dma *dma = sc->sc_dma; - struct hifn_operand *dst = &cmd->dst; - u_int32_t p, l; - int idx, used = 0, i; - - DPRINTF("%s()\n", __FUNCTION__); - - idx = dma->dsti; - for (i = 0; i < dst->nsegs - 1; i++) { - dma->dstr[idx].p = htole32(dst->segs[i].ds_addr); - dma->dstr[idx].l = htole32(HIFN_D_MASKDONEIRQ | dst->segs[i].ds_len); - wmb(); - dma->dstr[idx].l |= htole32(HIFN_D_VALID); - HIFN_DSTR_SYNC(sc, idx, - BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); - used++; - - idx = hifn_dmamap_dstwrap(sc, idx); - } - - if (cmd->sloplen == 0) { - p = dst->segs[i].ds_addr; - l = HIFN_D_MASKDONEIRQ | HIFN_D_LAST | - dst->segs[i].ds_len; - } else { - p = sc->sc_dma_physaddr + - offsetof(struct hifn_dma, slop[cmd->slopidx]); - l = HIFN_D_MASKDONEIRQ | HIFN_D_LAST | - sizeof(u_int32_t); - - if ((dst->segs[i].ds_len - cmd->sloplen) != 0) { - dma->dstr[idx].p = htole32(dst->segs[i].ds_addr); - dma->dstr[idx].l = htole32(HIFN_D_MASKDONEIRQ | - (dst->segs[i].ds_len - cmd->sloplen)); - wmb(); - dma->dstr[idx].l |= htole32(HIFN_D_VALID); - HIFN_DSTR_SYNC(sc, idx, - BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); - used++; - - idx = hifn_dmamap_dstwrap(sc, idx); - } - } - dma->dstr[idx].p = htole32(p); - dma->dstr[idx].l = htole32(l); - wmb(); - dma->dstr[idx].l |= htole32(HIFN_D_VALID); - HIFN_DSTR_SYNC(sc, idx, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); - used++; - - idx = hifn_dmamap_dstwrap(sc, idx); - - dma->dsti = idx; - dma->dstu += used; - return (idx); -} - -static __inline int -hifn_dmamap_srcwrap(struct hifn_softc *sc, int idx) -{ - struct hifn_dma *dma = sc->sc_dma; - - if (++idx == HIFN_D_SRC_RSIZE) { - dma->srcr[idx].l = htole32(HIFN_D_VALID | - HIFN_D_JUMP | HIFN_D_MASKDONEIRQ); - HIFN_SRCR_SYNC(sc, HIFN_D_SRC_RSIZE, - BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); - idx = 0; - } - return (idx); -} - -static int -hifn_dmamap_load_src(struct hifn_softc *sc, struct hifn_command *cmd) -{ - struct hifn_dma *dma = sc->sc_dma; - struct hifn_operand *src = &cmd->src; - int idx, i; - u_int32_t last = 0; - - DPRINTF("%s()\n", __FUNCTION__); - - idx = dma->srci; - for (i = 0; i < src->nsegs; i++) { - if (i == src->nsegs - 1) - last = HIFN_D_LAST; - - dma->srcr[idx].p = htole32(src->segs[i].ds_addr); - dma->srcr[idx].l = htole32(src->segs[i].ds_len | - HIFN_D_MASKDONEIRQ | last); - wmb(); - dma->srcr[idx].l |= htole32(HIFN_D_VALID); - HIFN_SRCR_SYNC(sc, idx, - BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); - - idx = hifn_dmamap_srcwrap(sc, idx); - } - dma->srci = idx; - dma->srcu += src->nsegs; - return (idx); -} - - -static int -hifn_crypto( - struct hifn_softc *sc, - struct hifn_command *cmd, - struct cryptop *crp, - int hint) -{ - struct hifn_dma *dma = sc->sc_dma; - u_int32_t cmdlen, csr; - int cmdi, resi, err = 0; - unsigned long l_flags; - - DPRINTF("%s()\n", __FUNCTION__); - - /* - * need 1 cmd, and 1 res - * - * NB: check this first since it's easy. - */ - HIFN_LOCK(sc); - if ((dma->cmdu + 1) > HIFN_D_CMD_RSIZE || - (dma->resu + 1) > HIFN_D_RES_RSIZE) { -#ifdef HIFN_DEBUG - if (hifn_debug) { - device_printf(sc->sc_dev, - "cmd/result exhaustion, cmdu %u resu %u\n", - dma->cmdu, dma->resu); - } -#endif - hifnstats.hst_nomem_cr++; - sc->sc_needwakeup |= CRYPTO_SYMQ; - HIFN_UNLOCK(sc); - return (ERESTART); - } - - if (crp->crp_flags & CRYPTO_F_SKBUF) { - if (pci_map_skb(sc, &cmd->src, cmd->src_skb)) { - hifnstats.hst_nomem_load++; - err = ENOMEM; - goto err_srcmap1; - } - } else if (crp->crp_flags & CRYPTO_F_IOV) { - if (pci_map_uio(sc, &cmd->src, cmd->src_io)) { - hifnstats.hst_nomem_load++; - err = ENOMEM; - goto err_srcmap1; - } - } else { - if (pci_map_buf(sc, &cmd->src, cmd->src_buf, crp->crp_ilen)) { - hifnstats.hst_nomem_load++; - err = ENOMEM; - goto err_srcmap1; - } - } - - if (hifn_dmamap_aligned(&cmd->src)) { - cmd->sloplen = cmd->src_mapsize & 3; - cmd->dst = cmd->src; - } else { - if (crp->crp_flags & CRYPTO_F_IOV) { - DPRINTF("%s,%d: %s - EINVAL\n",__FILE__,__LINE__,__FUNCTION__); - err = EINVAL; - goto err_srcmap; - } else if (crp->crp_flags & CRYPTO_F_SKBUF) { -#ifdef NOTYET - int totlen, len; - struct mbuf *m, *m0, *mlast; - - KASSERT(cmd->dst_m == cmd->src_m, - ("hifn_crypto: dst_m initialized improperly")); - hifnstats.hst_unaligned++; - /* - * Source is not aligned on a longword boundary. - * Copy the data to insure alignment. If we fail - * to allocate mbufs or clusters while doing this - * we return ERESTART so the operation is requeued - * at the crypto later, but only if there are - * ops already posted to the hardware; otherwise we - * have no guarantee that we'll be re-entered. - */ - totlen = cmd->src_mapsize; - if (cmd->src_m->m_flags & M_PKTHDR) { - len = MHLEN; - MGETHDR(m0, M_DONTWAIT, MT_DATA); - if (m0 && !m_dup_pkthdr(m0, cmd->src_m, M_DONTWAIT)) { - m_free(m0); - m0 = NULL; - } - } else { - len = MLEN; - MGET(m0, M_DONTWAIT, MT_DATA); - } - if (m0 == NULL) { - hifnstats.hst_nomem_mbuf++; - err = dma->cmdu ? ERESTART : ENOMEM; - goto err_srcmap; - } - if (totlen >= MINCLSIZE) { - MCLGET(m0, M_DONTWAIT); - if ((m0->m_flags & M_EXT) == 0) { - hifnstats.hst_nomem_mcl++; - err = dma->cmdu ? ERESTART : ENOMEM; - m_freem(m0); - goto err_srcmap; - } - len = MCLBYTES; - } - totlen -= len; - m0->m_pkthdr.len = m0->m_len = len; - mlast = m0; - - while (totlen > 0) { - MGET(m, M_DONTWAIT, MT_DATA); - if (m == NULL) { - hifnstats.hst_nomem_mbuf++; - err = dma->cmdu ? ERESTART : ENOMEM; - m_freem(m0); - goto err_srcmap; - } - len = MLEN; - if (totlen >= MINCLSIZE) { - MCLGET(m, M_DONTWAIT); - if ((m->m_flags & M_EXT) == 0) { - hifnstats.hst_nomem_mcl++; - err = dma->cmdu ? ERESTART : ENOMEM; - mlast->m_next = m; - m_freem(m0); - goto err_srcmap; - } - len = MCLBYTES; - } - - m->m_len = len; - m0->m_pkthdr.len += len; - totlen -= len; - - mlast->m_next = m; - mlast = m; - } - cmd->dst_m = m0; -#else - device_printf(sc->sc_dev, - "%s,%d: CRYPTO_F_SKBUF unaligned not implemented\n", - __FILE__, __LINE__); - err = EINVAL; - goto err_srcmap; -#endif - } else { - device_printf(sc->sc_dev, - "%s,%d: unaligned contig buffers not implemented\n", - __FILE__, __LINE__); - err = EINVAL; - goto err_srcmap; - } - } - - if (cmd->dst_map == NULL) { - if (crp->crp_flags & CRYPTO_F_SKBUF) { - if (pci_map_skb(sc, &cmd->dst, cmd->dst_skb)) { - hifnstats.hst_nomem_map++; - err = ENOMEM; - goto err_dstmap1; - } - } else if (crp->crp_flags & CRYPTO_F_IOV) { - if (pci_map_uio(sc, &cmd->dst, cmd->dst_io)) { - hifnstats.hst_nomem_load++; - err = ENOMEM; - goto err_dstmap1; - } - } else { - if (pci_map_buf(sc, &cmd->dst, cmd->dst_buf, crp->crp_ilen)) { - hifnstats.hst_nomem_load++; - err = ENOMEM; - goto err_dstmap1; - } - } - } - -#ifdef HIFN_DEBUG - if (hifn_debug) { - device_printf(sc->sc_dev, - "Entering cmd: stat %8x ien %8x u %d/%d/%d/%d n %d/%d\n", - READ_REG_1(sc, HIFN_1_DMA_CSR), - READ_REG_1(sc, HIFN_1_DMA_IER), - dma->cmdu, dma->srcu, dma->dstu, dma->resu, - cmd->src_nsegs, cmd->dst_nsegs); - } -#endif - -#if 0 - if (cmd->src_map == cmd->dst_map) { - bus_dmamap_sync(sc->sc_dmat, cmd->src_map, - BUS_DMASYNC_PREWRITE|BUS_DMASYNC_PREREAD); - } else { - bus_dmamap_sync(sc->sc_dmat, cmd->src_map, - BUS_DMASYNC_PREWRITE); - bus_dmamap_sync(sc->sc_dmat, cmd->dst_map, - BUS_DMASYNC_PREREAD); - } -#endif - - /* - * need N src, and N dst - */ - if ((dma->srcu + cmd->src_nsegs) > HIFN_D_SRC_RSIZE || - (dma->dstu + cmd->dst_nsegs + 1) > HIFN_D_DST_RSIZE) { -#ifdef HIFN_DEBUG - if (hifn_debug) { - device_printf(sc->sc_dev, - "src/dst exhaustion, srcu %u+%u dstu %u+%u\n", - dma->srcu, cmd->src_nsegs, - dma->dstu, cmd->dst_nsegs); - } -#endif - hifnstats.hst_nomem_sd++; - err = ERESTART; - goto err_dstmap; - } - - if (dma->cmdi == HIFN_D_CMD_RSIZE) { - dma->cmdi = 0; - dma->cmdr[HIFN_D_CMD_RSIZE].l = htole32(HIFN_D_JUMP|HIFN_D_MASKDONEIRQ); - wmb(); - dma->cmdr[HIFN_D_CMD_RSIZE].l |= htole32(HIFN_D_VALID); - HIFN_CMDR_SYNC(sc, HIFN_D_CMD_RSIZE, - BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); - } - cmdi = dma->cmdi++; - cmdlen = hifn_write_command(cmd, dma->command_bufs[cmdi]); - HIFN_CMD_SYNC(sc, cmdi, BUS_DMASYNC_PREWRITE); - - /* .p for command/result already set */ - dma->cmdr[cmdi].l = htole32(cmdlen | HIFN_D_LAST | - HIFN_D_MASKDONEIRQ); - wmb(); - dma->cmdr[cmdi].l |= htole32(HIFN_D_VALID); - HIFN_CMDR_SYNC(sc, cmdi, - BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); - dma->cmdu++; - - /* - * We don't worry about missing an interrupt (which a "command wait" - * interrupt salvages us from), unless there is more than one command - * in the queue. - */ - if (dma->cmdu > 1) { - sc->sc_dmaier |= HIFN_DMAIER_C_WAIT; - WRITE_REG_1(sc, HIFN_1_DMA_IER, sc->sc_dmaier); - } - - hifnstats.hst_ipackets++; - hifnstats.hst_ibytes += cmd->src_mapsize; - - hifn_dmamap_load_src(sc, cmd); - - /* - * Unlike other descriptors, we don't mask done interrupt from - * result descriptor. - */ -#ifdef HIFN_DEBUG - if (hifn_debug) - device_printf(sc->sc_dev, "load res\n"); -#endif - if (dma->resi == HIFN_D_RES_RSIZE) { - dma->resi = 0; - dma->resr[HIFN_D_RES_RSIZE].l = htole32(HIFN_D_JUMP|HIFN_D_MASKDONEIRQ); - wmb(); - dma->resr[HIFN_D_RES_RSIZE].l |= htole32(HIFN_D_VALID); - HIFN_RESR_SYNC(sc, HIFN_D_RES_RSIZE, - BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); - } - resi = dma->resi++; - KASSERT(dma->hifn_commands[resi] == NULL, - ("hifn_crypto: command slot %u busy", resi)); - dma->hifn_commands[resi] = cmd; - HIFN_RES_SYNC(sc, resi, BUS_DMASYNC_PREREAD); - if ((hint & CRYPTO_HINT_MORE) && sc->sc_curbatch < hifn_maxbatch) { - dma->resr[resi].l = htole32(HIFN_MAX_RESULT | - HIFN_D_LAST | HIFN_D_MASKDONEIRQ); - wmb(); - dma->resr[resi].l |= htole32(HIFN_D_VALID); - sc->sc_curbatch++; - if (sc->sc_curbatch > hifnstats.hst_maxbatch) - hifnstats.hst_maxbatch = sc->sc_curbatch; - hifnstats.hst_totbatch++; - } else { - dma->resr[resi].l = htole32(HIFN_MAX_RESULT | HIFN_D_LAST); - wmb(); - dma->resr[resi].l |= htole32(HIFN_D_VALID); - sc->sc_curbatch = 0; - } - HIFN_RESR_SYNC(sc, resi, - BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); - dma->resu++; - - if (cmd->sloplen) - cmd->slopidx = resi; - - hifn_dmamap_load_dst(sc, cmd); - - csr = 0; - if (sc->sc_c_busy == 0) { - csr |= HIFN_DMACSR_C_CTRL_ENA; - sc->sc_c_busy = 1; - } - if (sc->sc_s_busy == 0) { - csr |= HIFN_DMACSR_S_CTRL_ENA; - sc->sc_s_busy = 1; - } - if (sc->sc_r_busy == 0) { - csr |= HIFN_DMACSR_R_CTRL_ENA; - sc->sc_r_busy = 1; - } - if (sc->sc_d_busy == 0) { - csr |= HIFN_DMACSR_D_CTRL_ENA; - sc->sc_d_busy = 1; - } - if (csr) - WRITE_REG_1(sc, HIFN_1_DMA_CSR, csr); - -#ifdef HIFN_DEBUG - if (hifn_debug) { - device_printf(sc->sc_dev, "command: stat %8x ier %8x\n", - READ_REG_1(sc, HIFN_1_DMA_CSR), - READ_REG_1(sc, HIFN_1_DMA_IER)); - } -#endif - - sc->sc_active = 5; - HIFN_UNLOCK(sc); - KASSERT(err == 0, ("hifn_crypto: success with error %u", err)); - return (err); /* success */ - -err_dstmap: - if (cmd->src_map != cmd->dst_map) - pci_unmap_buf(sc, &cmd->dst); -err_dstmap1: -err_srcmap: - if (crp->crp_flags & CRYPTO_F_SKBUF) { - if (cmd->src_skb != cmd->dst_skb) -#ifdef NOTYET - m_freem(cmd->dst_m); -#else - device_printf(sc->sc_dev, - "%s,%d: CRYPTO_F_SKBUF src != dst not implemented\n", - __FILE__, __LINE__); -#endif - } - pci_unmap_buf(sc, &cmd->src); -err_srcmap1: - HIFN_UNLOCK(sc); - return (err); -} - -static void -hifn_tick(unsigned long arg) -{ - struct hifn_softc *sc; - unsigned long l_flags; - - if (arg >= HIFN_MAX_CHIPS) - return; - sc = hifn_chip_idx[arg]; - if (!sc) - return; - - HIFN_LOCK(sc); - if (sc->sc_active == 0) { - struct hifn_dma *dma = sc->sc_dma; - u_int32_t r = 0; - - if (dma->cmdu == 0 && sc->sc_c_busy) { - sc->sc_c_busy = 0; - r |= HIFN_DMACSR_C_CTRL_DIS; - } - if (dma->srcu == 0 && sc->sc_s_busy) { - sc->sc_s_busy = 0; - r |= HIFN_DMACSR_S_CTRL_DIS; - } - if (dma->dstu == 0 && sc->sc_d_busy) { - sc->sc_d_busy = 0; - r |= HIFN_DMACSR_D_CTRL_DIS; - } - if (dma->resu == 0 && sc->sc_r_busy) { - sc->sc_r_busy = 0; - r |= HIFN_DMACSR_R_CTRL_DIS; - } - if (r) - WRITE_REG_1(sc, HIFN_1_DMA_CSR, r); - } else - sc->sc_active--; - HIFN_UNLOCK(sc); - mod_timer(&sc->sc_tickto, jiffies + HZ); -} - -static irqreturn_t -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19) -hifn_intr(int irq, void *arg) -#else -hifn_intr(int irq, void *arg, struct pt_regs *regs) -#endif -{ - struct hifn_softc *sc = arg; - struct hifn_dma *dma; - u_int32_t dmacsr, restart; - int i, u; - unsigned long l_flags; - - dmacsr = READ_REG_1(sc, HIFN_1_DMA_CSR); - - /* Nothing in the DMA unit interrupted */ - if ((dmacsr & sc->sc_dmaier) == 0) - return IRQ_NONE; - - HIFN_LOCK(sc); - - dma = sc->sc_dma; - -#ifdef HIFN_DEBUG - if (hifn_debug) { - device_printf(sc->sc_dev, - "irq: stat %08x ien %08x damier %08x i %d/%d/%d/%d k %d/%d/%d/%d u %d/%d/%d/%d\n", - dmacsr, READ_REG_1(sc, HIFN_1_DMA_IER), sc->sc_dmaier, - dma->cmdi, dma->srci, dma->dsti, dma->resi, - dma->cmdk, dma->srck, dma->dstk, dma->resk, - dma->cmdu, dma->srcu, dma->dstu, dma->resu); - } -#endif - - WRITE_REG_1(sc, HIFN_1_DMA_CSR, dmacsr & sc->sc_dmaier); - - if ((sc->sc_flags & HIFN_HAS_PUBLIC) && - (dmacsr & HIFN_DMACSR_PUBDONE)) - WRITE_REG_1(sc, HIFN_1_PUB_STATUS, - READ_REG_1(sc, HIFN_1_PUB_STATUS) | HIFN_PUBSTS_DONE); - - restart = dmacsr & (HIFN_DMACSR_D_OVER | HIFN_DMACSR_R_OVER); - if (restart) - device_printf(sc->sc_dev, "overrun %x\n", dmacsr); - - if (sc->sc_flags & HIFN_IS_7811) { - if (dmacsr & HIFN_DMACSR_ILLR) - device_printf(sc->sc_dev, "illegal read\n"); - if (dmacsr & HIFN_DMACSR_ILLW) - device_printf(sc->sc_dev, "illegal write\n"); - } - - restart = dmacsr & (HIFN_DMACSR_C_ABORT | HIFN_DMACSR_S_ABORT | - HIFN_DMACSR_D_ABORT | HIFN_DMACSR_R_ABORT); - if (restart) { - device_printf(sc->sc_dev, "abort, resetting.\n"); - hifnstats.hst_abort++; - hifn_abort(sc); - HIFN_UNLOCK(sc); - return IRQ_HANDLED; - } - - if ((dmacsr & HIFN_DMACSR_C_WAIT) && (dma->cmdu == 0)) { - /* - * If no slots to process and we receive a "waiting on - * command" interrupt, we disable the "waiting on command" - * (by clearing it). - */ - sc->sc_dmaier &= ~HIFN_DMAIER_C_WAIT; - WRITE_REG_1(sc, HIFN_1_DMA_IER, sc->sc_dmaier); - } - - /* clear the rings */ - i = dma->resk; u = dma->resu; - while (u != 0) { - HIFN_RESR_SYNC(sc, i, - BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); - if (dma->resr[i].l & htole32(HIFN_D_VALID)) { - HIFN_RESR_SYNC(sc, i, - BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); - break; - } - - if (i != HIFN_D_RES_RSIZE) { - struct hifn_command *cmd; - u_int8_t *macbuf = NULL; - - HIFN_RES_SYNC(sc, i, BUS_DMASYNC_POSTREAD); - cmd = dma->hifn_commands[i]; - KASSERT(cmd != NULL, - ("hifn_intr: null command slot %u", i)); - dma->hifn_commands[i] = NULL; - - if (cmd->base_masks & HIFN_BASE_CMD_MAC) { - macbuf = dma->result_bufs[i]; - macbuf += 12; - } - - hifn_callback(sc, cmd, macbuf); - hifnstats.hst_opackets++; - u--; - } - - if (++i == (HIFN_D_RES_RSIZE + 1)) - i = 0; - } - dma->resk = i; dma->resu = u; - - i = dma->srck; u = dma->srcu; - while (u != 0) { - if (i == HIFN_D_SRC_RSIZE) - i = 0; - HIFN_SRCR_SYNC(sc, i, - BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); - if (dma->srcr[i].l & htole32(HIFN_D_VALID)) { - HIFN_SRCR_SYNC(sc, i, - BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); - break; - } - i++, u--; - } - dma->srck = i; dma->srcu = u; - - i = dma->cmdk; u = dma->cmdu; - while (u != 0) { - HIFN_CMDR_SYNC(sc, i, - BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); - if (dma->cmdr[i].l & htole32(HIFN_D_VALID)) { - HIFN_CMDR_SYNC(sc, i, - BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); - break; - } - if (i != HIFN_D_CMD_RSIZE) { - u--; - HIFN_CMD_SYNC(sc, i, BUS_DMASYNC_POSTWRITE); - } - if (++i == (HIFN_D_CMD_RSIZE + 1)) - i = 0; - } - dma->cmdk = i; dma->cmdu = u; - - HIFN_UNLOCK(sc); - - if (sc->sc_needwakeup) { /* XXX check high watermark */ - int wakeup = sc->sc_needwakeup & (CRYPTO_SYMQ|CRYPTO_ASYMQ); -#ifdef HIFN_DEBUG - if (hifn_debug) - device_printf(sc->sc_dev, - "wakeup crypto (%x) u %d/%d/%d/%d\n", - sc->sc_needwakeup, - dma->cmdu, dma->srcu, dma->dstu, dma->resu); -#endif - sc->sc_needwakeup &= ~wakeup; - crypto_unblock(sc->sc_cid, wakeup); - } - - return IRQ_HANDLED; -} - -/* - * Allocate a new 'session' and return an encoded session id. 'sidp' - * contains our registration id, and should contain an encoded session - * id on successful allocation. - */ -static int -hifn_newsession(device_t dev, u_int32_t *sidp, struct cryptoini *cri) -{ - struct hifn_softc *sc = device_get_softc(dev); - struct cryptoini *c; - int mac = 0, cry = 0, sesn; - struct hifn_session *ses = NULL; - unsigned long l_flags; - - DPRINTF("%s()\n", __FUNCTION__); - - KASSERT(sc != NULL, ("hifn_newsession: null softc")); - if (sidp == NULL || cri == NULL || sc == NULL) { - DPRINTF("%s,%d: %s - EINVAL\n", __FILE__, __LINE__, __FUNCTION__); - return (EINVAL); - } - - HIFN_LOCK(sc); - if (sc->sc_sessions == NULL) { - ses = sc->sc_sessions = (struct hifn_session *)kmalloc(sizeof(*ses), - SLAB_ATOMIC); - if (ses == NULL) { - HIFN_UNLOCK(sc); - return (ENOMEM); - } - sesn = 0; - sc->sc_nsessions = 1; - } else { - for (sesn = 0; sesn < sc->sc_nsessions; sesn++) { - if (!sc->sc_sessions[sesn].hs_used) { - ses = &sc->sc_sessions[sesn]; - break; - } - } - - if (ses == NULL) { - sesn = sc->sc_nsessions; - ses = (struct hifn_session *)kmalloc((sesn + 1) * sizeof(*ses), - SLAB_ATOMIC); - if (ses == NULL) { - HIFN_UNLOCK(sc); - return (ENOMEM); - } - bcopy(sc->sc_sessions, ses, sesn * sizeof(*ses)); - bzero(sc->sc_sessions, sesn * sizeof(*ses)); - kfree(sc->sc_sessions); - sc->sc_sessions = ses; - ses = &sc->sc_sessions[sesn]; - sc->sc_nsessions++; - } - } - HIFN_UNLOCK(sc); - - bzero(ses, sizeof(*ses)); - ses->hs_used = 1; - - for (c = cri; c != NULL; c = c->cri_next) { - switch (c->cri_alg) { - case CRYPTO_MD5: - case CRYPTO_SHA1: - case CRYPTO_MD5_HMAC: - case CRYPTO_SHA1_HMAC: - if (mac) { - DPRINTF("%s,%d: %s - EINVAL\n",__FILE__,__LINE__,__FUNCTION__); - return (EINVAL); - } - mac = 1; - ses->hs_mlen = c->cri_mlen; - if (ses->hs_mlen == 0) { - switch (c->cri_alg) { - case CRYPTO_MD5: - case CRYPTO_MD5_HMAC: - ses->hs_mlen = 16; - break; - case CRYPTO_SHA1: - case CRYPTO_SHA1_HMAC: - ses->hs_mlen = 20; - break; - } - } - break; - case CRYPTO_DES_CBC: - case CRYPTO_3DES_CBC: - case CRYPTO_AES_CBC: - /* XXX this may read fewer, does it matter? */ - read_random(ses->hs_iv, - c->cri_alg == CRYPTO_AES_CBC ? - HIFN_AES_IV_LENGTH : HIFN_IV_LENGTH); - /*FALLTHROUGH*/ - case CRYPTO_ARC4: - if (cry) { - DPRINTF("%s,%d: %s - EINVAL\n",__FILE__,__LINE__,__FUNCTION__); - return (EINVAL); - } - cry = 1; - break; - default: - DPRINTF("%s,%d: %s - EINVAL\n",__FILE__,__LINE__,__FUNCTION__); - return (EINVAL); - } - } - if (mac == 0 && cry == 0) { - DPRINTF("%s,%d: %s - EINVAL\n",__FILE__,__LINE__,__FUNCTION__); - return (EINVAL); - } - - *sidp = HIFN_SID(device_get_unit(sc->sc_dev), sesn); - - return (0); -} - -/* - * Deallocate a session. - * XXX this routine should run a zero'd mac/encrypt key into context ram. - * XXX to blow away any keys already stored there. - */ -static int -hifn_freesession(device_t dev, u_int64_t tid) -{ - struct hifn_softc *sc = device_get_softc(dev); - int session, error; - u_int32_t sid = CRYPTO_SESID2LID(tid); - unsigned long l_flags; - - DPRINTF("%s()\n", __FUNCTION__); - - KASSERT(sc != NULL, ("hifn_freesession: null softc")); - if (sc == NULL) { - DPRINTF("%s,%d: %s - EINVAL\n",__FILE__,__LINE__,__FUNCTION__); - return (EINVAL); - } - - HIFN_LOCK(sc); - session = HIFN_SESSION(sid); - if (session < sc->sc_nsessions) { - bzero(&sc->sc_sessions[session], sizeof(struct hifn_session)); - error = 0; - } else { - DPRINTF("%s,%d: %s - EINVAL\n",__FILE__,__LINE__,__FUNCTION__); - error = EINVAL; - } - HIFN_UNLOCK(sc); - - return (error); -} - -static int -hifn_process(device_t dev, struct cryptop *crp, int hint) -{ - struct hifn_softc *sc = device_get_softc(dev); - struct hifn_command *cmd = NULL; - int session, err, ivlen; - struct cryptodesc *crd1, *crd2, *maccrd, *enccrd; - - DPRINTF("%s()\n", __FUNCTION__); - - if (crp == NULL || crp->crp_callback == NULL) { - hifnstats.hst_invalid++; - DPRINTF("%s,%d: %s - EINVAL\n",__FILE__,__LINE__,__FUNCTION__); - return (EINVAL); - } - session = HIFN_SESSION(crp->crp_sid); - - if (sc == NULL || session >= sc->sc_nsessions) { - DPRINTF("%s,%d: %s - EINVAL\n",__FILE__,__LINE__,__FUNCTION__); - err = EINVAL; - goto errout; - } - - cmd = kmalloc(sizeof(struct hifn_command), SLAB_ATOMIC); - if (cmd == NULL) { - hifnstats.hst_nomem++; - err = ENOMEM; - goto errout; - } - memset(cmd, 0, sizeof(*cmd)); - - if (crp->crp_flags & CRYPTO_F_SKBUF) { - cmd->src_skb = (struct sk_buff *)crp->crp_buf; - cmd->dst_skb = (struct sk_buff *)crp->crp_buf; - } else if (crp->crp_flags & CRYPTO_F_IOV) { - cmd->src_io = (struct uio *)crp->crp_buf; - cmd->dst_io = (struct uio *)crp->crp_buf; - } else { - cmd->src_buf = crp->crp_buf; - cmd->dst_buf = crp->crp_buf; - } - - crd1 = crp->crp_desc; - if (crd1 == NULL) { - DPRINTF("%s,%d: %s - EINVAL\n",__FILE__,__LINE__,__FUNCTION__); - err = EINVAL; - goto errout; - } - crd2 = crd1->crd_next; - - if (crd2 == NULL) { - if (crd1->crd_alg == CRYPTO_MD5_HMAC || - crd1->crd_alg == CRYPTO_SHA1_HMAC || - crd1->crd_alg == CRYPTO_SHA1 || - crd1->crd_alg == CRYPTO_MD5) { - maccrd = crd1; - enccrd = NULL; - } else if (crd1->crd_alg == CRYPTO_DES_CBC || - crd1->crd_alg == CRYPTO_3DES_CBC || - crd1->crd_alg == CRYPTO_AES_CBC || - crd1->crd_alg == CRYPTO_ARC4) { - if ((crd1->crd_flags & CRD_F_ENCRYPT) == 0) - cmd->base_masks |= HIFN_BASE_CMD_DECODE; - maccrd = NULL; - enccrd = crd1; - } else { - DPRINTF("%s,%d: %s - EINVAL\n",__FILE__,__LINE__,__FUNCTION__); - err = EINVAL; - goto errout; - } - } else { - if ((crd1->crd_alg == CRYPTO_MD5_HMAC || - crd1->crd_alg == CRYPTO_SHA1_HMAC || - crd1->crd_alg == CRYPTO_MD5 || - crd1->crd_alg == CRYPTO_SHA1) && - (crd2->crd_alg == CRYPTO_DES_CBC || - crd2->crd_alg == CRYPTO_3DES_CBC || - crd2->crd_alg == CRYPTO_AES_CBC || - crd2->crd_alg == CRYPTO_ARC4) && - ((crd2->crd_flags & CRD_F_ENCRYPT) == 0)) { - cmd->base_masks = HIFN_BASE_CMD_DECODE; - maccrd = crd1; - enccrd = crd2; - } else if ((crd1->crd_alg == CRYPTO_DES_CBC || - crd1->crd_alg == CRYPTO_ARC4 || - crd1->crd_alg == CRYPTO_3DES_CBC || - crd1->crd_alg == CRYPTO_AES_CBC) && - (crd2->crd_alg == CRYPTO_MD5_HMAC || - crd2->crd_alg == CRYPTO_SHA1_HMAC || - crd2->crd_alg == CRYPTO_MD5 || - crd2->crd_alg == CRYPTO_SHA1) && - (crd1->crd_flags & CRD_F_ENCRYPT)) { - enccrd = crd1; - maccrd = crd2; - } else { - /* - * We cannot order the 7751 as requested - */ - DPRINTF("%s,%d: %s %d,%d,%d - EINVAL\n",__FILE__,__LINE__,__FUNCTION__, crd1->crd_alg, crd2->crd_alg, crd1->crd_flags & CRD_F_ENCRYPT); - err = EINVAL; - goto errout; - } - } - - if (enccrd) { - cmd->enccrd = enccrd; - cmd->base_masks |= HIFN_BASE_CMD_CRYPT; - switch (enccrd->crd_alg) { - case CRYPTO_ARC4: - cmd->cry_masks |= HIFN_CRYPT_CMD_ALG_RC4; - break; - case CRYPTO_DES_CBC: - cmd->cry_masks |= HIFN_CRYPT_CMD_ALG_DES | - HIFN_CRYPT_CMD_MODE_CBC | - HIFN_CRYPT_CMD_NEW_IV; - break; - case CRYPTO_3DES_CBC: - cmd->cry_masks |= HIFN_CRYPT_CMD_ALG_3DES | - HIFN_CRYPT_CMD_MODE_CBC | - HIFN_CRYPT_CMD_NEW_IV; - break; - case CRYPTO_AES_CBC: - cmd->cry_masks |= HIFN_CRYPT_CMD_ALG_AES | - HIFN_CRYPT_CMD_MODE_CBC | - HIFN_CRYPT_CMD_NEW_IV; - break; - default: - DPRINTF("%s,%d: %s - EINVAL\n",__FILE__,__LINE__,__FUNCTION__); - err = EINVAL; - goto errout; - } - if (enccrd->crd_alg != CRYPTO_ARC4) { - ivlen = ((enccrd->crd_alg == CRYPTO_AES_CBC) ? - HIFN_AES_IV_LENGTH : HIFN_IV_LENGTH); - if (enccrd->crd_flags & CRD_F_ENCRYPT) { - if (enccrd->crd_flags & CRD_F_IV_EXPLICIT) - bcopy(enccrd->crd_iv, cmd->iv, ivlen); - else - bcopy(sc->sc_sessions[session].hs_iv, - cmd->iv, ivlen); - - if ((enccrd->crd_flags & CRD_F_IV_PRESENT) - == 0) { - crypto_copyback(crp->crp_flags, - crp->crp_buf, enccrd->crd_inject, - ivlen, cmd->iv); - } - } else { - if (enccrd->crd_flags & CRD_F_IV_EXPLICIT) - bcopy(enccrd->crd_iv, cmd->iv, ivlen); - else { - crypto_copydata(crp->crp_flags, - crp->crp_buf, enccrd->crd_inject, - ivlen, cmd->iv); - } - } - } - - if (enccrd->crd_flags & CRD_F_KEY_EXPLICIT) - cmd->cry_masks |= HIFN_CRYPT_CMD_NEW_KEY; - cmd->ck = enccrd->crd_key; - cmd->cklen = enccrd->crd_klen >> 3; - cmd->cry_masks |= HIFN_CRYPT_CMD_NEW_KEY; - - /* - * Need to specify the size for the AES key in the masks. - */ - if ((cmd->cry_masks & HIFN_CRYPT_CMD_ALG_MASK) == - HIFN_CRYPT_CMD_ALG_AES) { - switch (cmd->cklen) { - case 16: - cmd->cry_masks |= HIFN_CRYPT_CMD_KSZ_128; - break; - case 24: - cmd->cry_masks |= HIFN_CRYPT_CMD_KSZ_192; - break; - case 32: - cmd->cry_masks |= HIFN_CRYPT_CMD_KSZ_256; - break; - default: - DPRINTF("%s,%d: %s - EINVAL\n",__FILE__,__LINE__,__FUNCTION__); - err = EINVAL; - goto errout; - } - } - } - - if (maccrd) { - cmd->maccrd = maccrd; - cmd->base_masks |= HIFN_BASE_CMD_MAC; - - switch (maccrd->crd_alg) { - case CRYPTO_MD5: - cmd->mac_masks |= HIFN_MAC_CMD_ALG_MD5 | - HIFN_MAC_CMD_RESULT | HIFN_MAC_CMD_MODE_HASH | - HIFN_MAC_CMD_POS_IPSEC; - break; - case CRYPTO_MD5_HMAC: - cmd->mac_masks |= HIFN_MAC_CMD_ALG_MD5 | - HIFN_MAC_CMD_RESULT | HIFN_MAC_CMD_MODE_HMAC | - HIFN_MAC_CMD_POS_IPSEC | HIFN_MAC_CMD_TRUNC; - break; - case CRYPTO_SHA1: - cmd->mac_masks |= HIFN_MAC_CMD_ALG_SHA1 | - HIFN_MAC_CMD_RESULT | HIFN_MAC_CMD_MODE_HASH | - HIFN_MAC_CMD_POS_IPSEC; - break; - case CRYPTO_SHA1_HMAC: - cmd->mac_masks |= HIFN_MAC_CMD_ALG_SHA1 | - HIFN_MAC_CMD_RESULT | HIFN_MAC_CMD_MODE_HMAC | - HIFN_MAC_CMD_POS_IPSEC | HIFN_MAC_CMD_TRUNC; - break; - } - - if (maccrd->crd_alg == CRYPTO_SHA1_HMAC || - maccrd->crd_alg == CRYPTO_MD5_HMAC) { - cmd->mac_masks |= HIFN_MAC_CMD_NEW_KEY; - bcopy(maccrd->crd_key, cmd->mac, maccrd->crd_klen >> 3); - bzero(cmd->mac + (maccrd->crd_klen >> 3), - HIFN_MAC_KEY_LENGTH - (maccrd->crd_klen >> 3)); - } - } - - cmd->crp = crp; - cmd->session_num = session; - cmd->softc = sc; - - err = hifn_crypto(sc, cmd, crp, hint); - if (!err) { - return 0; - } else if (err == ERESTART) { - /* - * There weren't enough resources to dispatch the request - * to the part. Notify the caller so they'll requeue this - * request and resubmit it again soon. - */ -#ifdef HIFN_DEBUG - if (hifn_debug) - device_printf(sc->sc_dev, "requeue request\n"); -#endif - kfree(cmd); - sc->sc_needwakeup |= CRYPTO_SYMQ; - return (err); - } - -errout: - if (cmd != NULL) - kfree(cmd); - if (err == EINVAL) - hifnstats.hst_invalid++; - else - hifnstats.hst_nomem++; - crp->crp_etype = err; - crypto_done(crp); - return (err); -} - -static void -hifn_abort(struct hifn_softc *sc) -{ - struct hifn_dma *dma = sc->sc_dma; - struct hifn_command *cmd; - struct cryptop *crp; - int i, u; - - DPRINTF("%s()\n", __FUNCTION__); - - i = dma->resk; u = dma->resu; - while (u != 0) { - cmd = dma->hifn_commands[i]; - KASSERT(cmd != NULL, ("hifn_abort: null command slot %u", i)); - dma->hifn_commands[i] = NULL; - crp = cmd->crp; - - if ((dma->resr[i].l & htole32(HIFN_D_VALID)) == 0) { - /* Salvage what we can. */ - u_int8_t *macbuf; - - if (cmd->base_masks & HIFN_BASE_CMD_MAC) { - macbuf = dma->result_bufs[i]; - macbuf += 12; - } else - macbuf = NULL; - hifnstats.hst_opackets++; - hifn_callback(sc, cmd, macbuf); - } else { -#if 0 - if (cmd->src_map == cmd->dst_map) { - bus_dmamap_sync(sc->sc_dmat, cmd->src_map, - BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE); - } else { - bus_dmamap_sync(sc->sc_dmat, cmd->src_map, - BUS_DMASYNC_POSTWRITE); - bus_dmamap_sync(sc->sc_dmat, cmd->dst_map, - BUS_DMASYNC_POSTREAD); - } -#endif - - if (cmd->src_skb != cmd->dst_skb) { -#ifdef NOTYET - m_freem(cmd->src_m); - crp->crp_buf = (caddr_t)cmd->dst_m; -#else - device_printf(sc->sc_dev, - "%s,%d: CRYPTO_F_SKBUF src != dst not implemented\n", - __FILE__, __LINE__); -#endif - } - - /* non-shared buffers cannot be restarted */ - if (cmd->src_map != cmd->dst_map) { - /* - * XXX should be EAGAIN, delayed until - * after the reset. - */ - crp->crp_etype = ENOMEM; - pci_unmap_buf(sc, &cmd->dst); - } else - crp->crp_etype = ENOMEM; - - pci_unmap_buf(sc, &cmd->src); - - kfree(cmd); - if (crp->crp_etype != EAGAIN) - crypto_done(crp); - } - - if (++i == HIFN_D_RES_RSIZE) - i = 0; - u--; - } - dma->resk = i; dma->resu = u; - - hifn_reset_board(sc, 1); - hifn_init_dma(sc); - hifn_init_pci_registers(sc); -} - -static void -hifn_callback(struct hifn_softc *sc, struct hifn_command *cmd, u_int8_t *macbuf) -{ - struct hifn_dma *dma = sc->sc_dma; - struct cryptop *crp = cmd->crp; - struct cryptodesc *crd; - int i, u, ivlen; - - DPRINTF("%s()\n", __FUNCTION__); - -#if 0 - if (cmd->src_map == cmd->dst_map) { - bus_dmamap_sync(sc->sc_dmat, cmd->src_map, - BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD); - } else { - bus_dmamap_sync(sc->sc_dmat, cmd->src_map, - BUS_DMASYNC_POSTWRITE); - bus_dmamap_sync(sc->sc_dmat, cmd->dst_map, - BUS_DMASYNC_POSTREAD); - } -#endif - - if (crp->crp_flags & CRYPTO_F_SKBUF) { - if (cmd->src_skb != cmd->dst_skb) { -#ifdef NOTYET - crp->crp_buf = (caddr_t)cmd->dst_m; - totlen = cmd->src_mapsize; - for (m = cmd->dst_m; m != NULL; m = m->m_next) { - if (totlen < m->m_len) { - m->m_len = totlen; - totlen = 0; - } else - totlen -= m->m_len; - } - cmd->dst_m->m_pkthdr.len = cmd->src_m->m_pkthdr.len; - m_freem(cmd->src_m); -#else - device_printf(sc->sc_dev, - "%s,%d: CRYPTO_F_SKBUF src != dst not implemented\n", - __FILE__, __LINE__); -#endif - } - } - - if (cmd->sloplen != 0) { - crypto_copyback(crp->crp_flags, crp->crp_buf, - cmd->src_mapsize - cmd->sloplen, cmd->sloplen, - (caddr_t)&dma->slop[cmd->slopidx]); - } - - i = dma->dstk; u = dma->dstu; - while (u != 0) { - if (i == HIFN_D_DST_RSIZE) - i = 0; -#if 0 - bus_dmamap_sync(sc->sc_dmat, sc->sc_dmamap, - BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); -#endif - if (dma->dstr[i].l & htole32(HIFN_D_VALID)) { -#if 0 - bus_dmamap_sync(sc->sc_dmat, sc->sc_dmamap, - BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); -#endif - break; - } - i++, u--; - } - dma->dstk = i; dma->dstu = u; - - hifnstats.hst_obytes += cmd->dst_mapsize; - - if ((cmd->base_masks & (HIFN_BASE_CMD_CRYPT | HIFN_BASE_CMD_DECODE)) == - HIFN_BASE_CMD_CRYPT) { - for (crd = crp->crp_desc; crd; crd = crd->crd_next) { - if (crd->crd_alg != CRYPTO_DES_CBC && - crd->crd_alg != CRYPTO_3DES_CBC && - crd->crd_alg != CRYPTO_AES_CBC) - continue; - ivlen = ((crd->crd_alg == CRYPTO_AES_CBC) ? - HIFN_AES_IV_LENGTH : HIFN_IV_LENGTH); - crypto_copydata(crp->crp_flags, crp->crp_buf, - crd->crd_skip + crd->crd_len - ivlen, ivlen, - cmd->softc->sc_sessions[cmd->session_num].hs_iv); - break; - } - } - - if (macbuf != NULL) { - for (crd = crp->crp_desc; crd; crd = crd->crd_next) { - int len; - - if (crd->crd_alg != CRYPTO_MD5 && - crd->crd_alg != CRYPTO_SHA1 && - crd->crd_alg != CRYPTO_MD5_HMAC && - crd->crd_alg != CRYPTO_SHA1_HMAC) { - continue; - } - len = cmd->softc->sc_sessions[cmd->session_num].hs_mlen; - crypto_copyback(crp->crp_flags, crp->crp_buf, - crd->crd_inject, len, macbuf); - break; - } - } - - if (cmd->src_map != cmd->dst_map) - pci_unmap_buf(sc, &cmd->dst); - pci_unmap_buf(sc, &cmd->src); - kfree(cmd); - crypto_done(crp); -} - -/* - * 7811 PB3 rev/2 parts lock-up on burst writes to Group 0 - * and Group 1 registers; avoid conditions that could create - * burst writes by doing a read in between the writes. - * - * NB: The read we interpose is always to the same register; - * we do this because reading from an arbitrary (e.g. last) - * register may not always work. - */ -static void -hifn_write_reg_0(struct hifn_softc *sc, bus_size_t reg, u_int32_t val) -{ - if (sc->sc_flags & HIFN_IS_7811) { - if (sc->sc_bar0_lastreg == reg - 4) - readl(sc->sc_bar0 + HIFN_0_PUCNFG); - sc->sc_bar0_lastreg = reg; - } - writel(val, sc->sc_bar0 + reg); -} - -static void -hifn_write_reg_1(struct hifn_softc *sc, bus_size_t reg, u_int32_t val) -{ - if (sc->sc_flags & HIFN_IS_7811) { - if (sc->sc_bar1_lastreg == reg - 4) - readl(sc->sc_bar1 + HIFN_1_REVID); - sc->sc_bar1_lastreg = reg; - } - writel(val, sc->sc_bar1 + reg); -} - - -static struct pci_device_id hifn_pci_tbl[] = { - { PCI_VENDOR_HIFN, PCI_PRODUCT_HIFN_7951, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, - { PCI_VENDOR_HIFN, PCI_PRODUCT_HIFN_7955, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, - { PCI_VENDOR_HIFN, PCI_PRODUCT_HIFN_7956, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, - { PCI_VENDOR_NETSEC, PCI_PRODUCT_NETSEC_7751, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, - { PCI_VENDOR_INVERTEX, PCI_PRODUCT_INVERTEX_AEON, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, - { PCI_VENDOR_HIFN, PCI_PRODUCT_HIFN_7811, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, - /* - * Other vendors share this PCI ID as well, such as - * http://www.powercrypt.com, and obviously they also - * use the same key. - */ - { PCI_VENDOR_HIFN, PCI_PRODUCT_HIFN_7751, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, - { 0, 0, 0, 0, 0, 0, } -}; -MODULE_DEVICE_TABLE(pci, hifn_pci_tbl); - -static struct pci_driver hifn_driver = { - .name = "hifn", - .id_table = hifn_pci_tbl, - .probe = hifn_probe, - .remove = hifn_remove, - /* add PM stuff here one day */ -}; - -static int __init hifn_init (void) -{ - struct hifn_softc *sc = NULL; - int rc; - - DPRINTF("%s(%p)\n", __FUNCTION__, hifn_init); - - rc = pci_register_driver(&hifn_driver); - pci_register_driver_compat(&hifn_driver, rc); - - return rc; -} - -static void __exit hifn_exit (void) -{ - pci_unregister_driver(&hifn_driver); -} - -module_init(hifn_init); -module_exit(hifn_exit); - -MODULE_LICENSE("BSD"); -MODULE_AUTHOR("David McCullough <david_mccullough@mcafee.com>"); -MODULE_DESCRIPTION("OCF driver for hifn PCI crypto devices"); diff --git a/target/linux/generic-2.4/files/crypto/ocf/hifn/hifn7751reg.h b/target/linux/generic-2.4/files/crypto/ocf/hifn/hifn7751reg.h deleted file mode 100644 index ccf54f9..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/hifn/hifn7751reg.h +++ /dev/null @@ -1,540 +0,0 @@ -/* $FreeBSD: src/sys/dev/hifn/hifn7751reg.h,v 1.7 2007/03/21 03:42:49 sam Exp $ */ -/* $OpenBSD: hifn7751reg.h,v 1.35 2002/04/08 17:49:42 jason Exp $ */ - -/*- - * Invertex AEON / Hifn 7751 driver - * Copyright (c) 1999 Invertex Inc. All rights reserved. - * Copyright (c) 1999 Theo de Raadt - * Copyright (c) 2000-2001 Network Security Technologies, Inc. - * http://www.netsec.net - * - * Please send any comments, feedback, bug-fixes, or feature requests to - * software@invertex.com. - * - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR 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. - * - * Effort sponsored in part by the Defense Advanced Research Projects - * Agency (DARPA) and Air Force Research Laboratory, Air Force - * Materiel Command, USAF, under agreement number F30602-01-2-0537. - * - */ -#ifndef __HIFN_H__ -#define __HIFN_H__ - -/* - * Some PCI configuration space offset defines. The names were made - * identical to the names used by the Linux kernel. - */ -#define HIFN_BAR0 PCIR_BAR(0) /* PUC register map */ -#define HIFN_BAR1 PCIR_BAR(1) /* DMA register map */ -#define HIFN_TRDY_TIMEOUT 0x40 -#define HIFN_RETRY_TIMEOUT 0x41 - -/* - * PCI vendor and device identifiers - * (the names are preserved from their OpenBSD source). - */ -#define PCI_VENDOR_HIFN 0x13a3 /* Hifn */ -#define PCI_PRODUCT_HIFN_7751 0x0005 /* 7751 */ -#define PCI_PRODUCT_HIFN_6500 0x0006 /* 6500 */ -#define PCI_PRODUCT_HIFN_7811 0x0007 /* 7811 */ -#define PCI_PRODUCT_HIFN_7855 0x001f /* 7855 */ -#define PCI_PRODUCT_HIFN_7951 0x0012 /* 7951 */ -#define PCI_PRODUCT_HIFN_7955 0x0020 /* 7954/7955 */ -#define PCI_PRODUCT_HIFN_7956 0x001d /* 7956 */ - -#define PCI_VENDOR_INVERTEX 0x14e1 /* Invertex */ -#define PCI_PRODUCT_INVERTEX_AEON 0x0005 /* AEON */ - -#define PCI_VENDOR_NETSEC 0x1660 /* NetSec */ -#define PCI_PRODUCT_NETSEC_7751 0x7751 /* 7751 */ - -/* - * The values below should multiple of 4 -- and be large enough to handle - * any command the driver implements. - * - * MAX_COMMAND = base command + mac command + encrypt command + - * mac-key + rc4-key - * MAX_RESULT = base result + mac result + mac + encrypt result - * - * - */ -#define HIFN_MAX_COMMAND (8 + 8 + 8 + 64 + 260) -#define HIFN_MAX_RESULT (8 + 4 + 20 + 4) - -/* - * hifn_desc_t - * - * Holds an individual descriptor for any of the rings. - */ -typedef struct hifn_desc { - volatile u_int32_t l; /* length and status bits */ - volatile u_int32_t p; -} hifn_desc_t; - -/* - * Masks for the "length" field of struct hifn_desc. - */ -#define HIFN_D_LENGTH 0x0000ffff /* length bit mask */ -#define HIFN_D_MASKDONEIRQ 0x02000000 /* mask the done interrupt */ -#define HIFN_D_DESTOVER 0x04000000 /* destination overflow */ -#define HIFN_D_OVER 0x08000000 /* overflow */ -#define HIFN_D_LAST 0x20000000 /* last descriptor in chain */ -#define HIFN_D_JUMP 0x40000000 /* jump descriptor */ -#define HIFN_D_VALID 0x80000000 /* valid bit */ - - -/* - * Processing Unit Registers (offset from BASEREG0) - */ -#define HIFN_0_PUDATA 0x00 /* Processing Unit Data */ -#define HIFN_0_PUCTRL 0x04 /* Processing Unit Control */ -#define HIFN_0_PUISR 0x08 /* Processing Unit Interrupt Status */ -#define HIFN_0_PUCNFG 0x0c /* Processing Unit Configuration */ -#define HIFN_0_PUIER 0x10 /* Processing Unit Interrupt Enable */ -#define HIFN_0_PUSTAT 0x14 /* Processing Unit Status/Chip ID */ -#define HIFN_0_FIFOSTAT 0x18 /* FIFO Status */ -#define HIFN_0_FIFOCNFG 0x1c /* FIFO Configuration */ -#define HIFN_0_PUCTRL2 0x28 /* Processing Unit Control (2nd map) */ -#define HIFN_0_MUTE1 0x80 -#define HIFN_0_MUTE2 0x90 -#define HIFN_0_SPACESIZE 0x100 /* Register space size */ - -/* Processing Unit Control Register (HIFN_0_PUCTRL) */ -#define HIFN_PUCTRL_CLRSRCFIFO 0x0010 /* clear source fifo */ -#define HIFN_PUCTRL_STOP 0x0008 /* stop pu */ -#define HIFN_PUCTRL_LOCKRAM 0x0004 /* lock ram */ -#define HIFN_PUCTRL_DMAENA 0x0002 /* enable dma */ -#define HIFN_PUCTRL_RESET 0x0001 /* Reset processing unit */ - -/* Processing Unit Interrupt Status Register (HIFN_0_PUISR) */ -#define HIFN_PUISR_CMDINVAL 0x8000 /* Invalid command interrupt */ -#define HIFN_PUISR_DATAERR 0x4000 /* Data error interrupt */ -#define HIFN_PUISR_SRCFIFO 0x2000 /* Source FIFO ready interrupt */ -#define HIFN_PUISR_DSTFIFO 0x1000 /* Destination FIFO ready interrupt */ -#define HIFN_PUISR_DSTOVER 0x0200 /* Destination overrun interrupt */ -#define HIFN_PUISR_SRCCMD 0x0080 /* Source command interrupt */ -#define HIFN_PUISR_SRCCTX 0x0040 /* Source context interrupt */ -#define HIFN_PUISR_SRCDATA 0x0020 /* Source data interrupt */ -#define HIFN_PUISR_DSTDATA 0x0010 /* Destination data interrupt */ -#define HIFN_PUISR_DSTRESULT 0x0004 /* Destination result interrupt */ - -/* Processing Unit Configuration Register (HIFN_0_PUCNFG) */ -#define HIFN_PUCNFG_DRAMMASK 0xe000 /* DRAM size mask */ -#define HIFN_PUCNFG_DSZ_256K 0x0000 /* 256k dram */ -#define HIFN_PUCNFG_DSZ_512K 0x2000 /* 512k dram */ -#define HIFN_PUCNFG_DSZ_1M 0x4000 /* 1m dram */ -#define HIFN_PUCNFG_DSZ_2M 0x6000 /* 2m dram */ -#define HIFN_PUCNFG_DSZ_4M 0x8000 /* 4m dram */ -#define HIFN_PUCNFG_DSZ_8M 0xa000 /* 8m dram */ -#define HIFN_PUNCFG_DSZ_16M 0xc000 /* 16m dram */ -#define HIFN_PUCNFG_DSZ_32M 0xe000 /* 32m dram */ -#define HIFN_PUCNFG_DRAMREFRESH 0x1800 /* DRAM refresh rate mask */ -#define HIFN_PUCNFG_DRFR_512 0x0000 /* 512 divisor of ECLK */ -#define HIFN_PUCNFG_DRFR_256 0x0800 /* 256 divisor of ECLK */ -#define HIFN_PUCNFG_DRFR_128 0x1000 /* 128 divisor of ECLK */ -#define HIFN_PUCNFG_TCALLPHASES 0x0200 /* your guess is as good as mine... */ -#define HIFN_PUCNFG_TCDRVTOTEM 0x0100 /* your guess is as good as mine... */ -#define HIFN_PUCNFG_BIGENDIAN 0x0080 /* DMA big endian mode */ -#define HIFN_PUCNFG_BUS32 0x0040 /* Bus width 32bits */ -#define HIFN_PUCNFG_BUS16 0x0000 /* Bus width 16 bits */ -#define HIFN_PUCNFG_CHIPID 0x0020 /* Allow chipid from PUSTAT */ -#define HIFN_PUCNFG_DRAM 0x0010 /* Context RAM is DRAM */ -#define HIFN_PUCNFG_SRAM 0x0000 /* Context RAM is SRAM */ -#define HIFN_PUCNFG_COMPSING 0x0004 /* Enable single compression context */ -#define HIFN_PUCNFG_ENCCNFG 0x0002 /* Encryption configuration */ - -/* Processing Unit Interrupt Enable Register (HIFN_0_PUIER) */ -#define HIFN_PUIER_CMDINVAL 0x8000 /* Invalid command interrupt */ -#define HIFN_PUIER_DATAERR 0x4000 /* Data error interrupt */ -#define HIFN_PUIER_SRCFIFO 0x2000 /* Source FIFO ready interrupt */ -#define HIFN_PUIER_DSTFIFO 0x1000 /* Destination FIFO ready interrupt */ -#define HIFN_PUIER_DSTOVER 0x0200 /* Destination overrun interrupt */ -#define HIFN_PUIER_SRCCMD 0x0080 /* Source command interrupt */ -#define HIFN_PUIER_SRCCTX 0x0040 /* Source context interrupt */ -#define HIFN_PUIER_SRCDATA 0x0020 /* Source data interrupt */ -#define HIFN_PUIER_DSTDATA 0x0010 /* Destination data interrupt */ -#define HIFN_PUIER_DSTRESULT 0x0004 /* Destination result interrupt */ - -/* Processing Unit Status Register/Chip ID (HIFN_0_PUSTAT) */ -#define HIFN_PUSTAT_CMDINVAL 0x8000 /* Invalid command interrupt */ -#define HIFN_PUSTAT_DATAERR 0x4000 /* Data error interrupt */ -#define HIFN_PUSTAT_SRCFIFO 0x2000 /* Source FIFO ready interrupt */ -#define HIFN_PUSTAT_DSTFIFO 0x1000 /* Destination FIFO ready interrupt */ -#define HIFN_PUSTAT_DSTOVER 0x0200 /* Destination overrun interrupt */ -#define HIFN_PUSTAT_SRCCMD 0x0080 /* Source command interrupt */ -#define HIFN_PUSTAT_SRCCTX 0x0040 /* Source context interrupt */ -#define HIFN_PUSTAT_SRCDATA 0x0020 /* Source data interrupt */ -#define HIFN_PUSTAT_DSTDATA 0x0010 /* Destination data interrupt */ -#define HIFN_PUSTAT_DSTRESULT 0x0004 /* Destination result interrupt */ -#define HIFN_PUSTAT_CHIPREV 0x00ff /* Chip revision mask */ -#define HIFN_PUSTAT_CHIPENA 0xff00 /* Chip enabled mask */ -#define HIFN_PUSTAT_ENA_2 0x1100 /* Level 2 enabled */ -#define HIFN_PUSTAT_ENA_1 0x1000 /* Level 1 enabled */ -#define HIFN_PUSTAT_ENA_0 0x3000 /* Level 0 enabled */ -#define HIFN_PUSTAT_REV_2 0x0020 /* 7751 PT6/2 */ -#define HIFN_PUSTAT_REV_3 0x0030 /* 7751 PT6/3 */ - -/* FIFO Status Register (HIFN_0_FIFOSTAT) */ -#define HIFN_FIFOSTAT_SRC 0x7f00 /* Source FIFO available */ -#define HIFN_FIFOSTAT_DST 0x007f /* Destination FIFO available */ - -/* FIFO Configuration Register (HIFN_0_FIFOCNFG) */ -#define HIFN_FIFOCNFG_THRESHOLD 0x0400 /* must be written as this value */ - -/* - * DMA Interface Registers (offset from BASEREG1) - */ -#define HIFN_1_DMA_CRAR 0x0c /* DMA Command Ring Address */ -#define HIFN_1_DMA_SRAR 0x1c /* DMA Source Ring Address */ -#define HIFN_1_DMA_RRAR 0x2c /* DMA Result Ring Address */ -#define HIFN_1_DMA_DRAR 0x3c /* DMA Destination Ring Address */ -#define HIFN_1_DMA_CSR 0x40 /* DMA Status and Control */ -#define HIFN_1_DMA_IER 0x44 /* DMA Interrupt Enable */ -#define HIFN_1_DMA_CNFG 0x48 /* DMA Configuration */ -#define HIFN_1_PLL 0x4c /* 7955/7956: PLL config */ -#define HIFN_1_7811_RNGENA 0x60 /* 7811: rng enable */ -#define HIFN_1_7811_RNGCFG 0x64 /* 7811: rng config */ -#define HIFN_1_7811_RNGDAT 0x68 /* 7811: rng data */ -#define HIFN_1_7811_RNGSTS 0x6c /* 7811: rng status */ -#define HIFN_1_DMA_CNFG2 0x6c /* 7955/7956: dma config #2 */ -#define HIFN_1_7811_MIPSRST 0x94 /* 7811: MIPS reset */ -#define HIFN_1_REVID 0x98 /* Revision ID */ - -#define HIFN_1_PUB_RESET 0x204 /* Public/RNG Reset */ -#define HIFN_1_PUB_BASE 0x300 /* Public Base Address */ -#define HIFN_1_PUB_OPLEN 0x304 /* 7951-compat Public Operand Length */ -#define HIFN_1_PUB_OP 0x308 /* 7951-compat Public Operand */ -#define HIFN_1_PUB_STATUS 0x30c /* 7951-compat Public Status */ -#define HIFN_1_PUB_IEN 0x310 /* Public Interrupt enable */ -#define HIFN_1_RNG_CONFIG 0x314 /* RNG config */ -#define HIFN_1_RNG_DATA 0x318 /* RNG data */ -#define HIFN_1_PUB_MODE 0x320 /* PK mode */ -#define HIFN_1_PUB_FIFO_OPLEN 0x380 /* first element of oplen fifo */ -#define HIFN_1_PUB_FIFO_OP 0x384 /* first element of op fifo */ -#define HIFN_1_PUB_MEM 0x400 /* start of Public key memory */ -#define HIFN_1_PUB_MEMEND 0xbff /* end of Public key memory */ - -/* DMA Status and Control Register (HIFN_1_DMA_CSR) */ -#define HIFN_DMACSR_D_CTRLMASK 0xc0000000 /* Destinition Ring Control */ -#define HIFN_DMACSR_D_CTRL_NOP 0x00000000 /* Dest. Control: no-op */ -#define HIFN_DMACSR_D_CTRL_DIS 0x40000000 /* Dest. Control: disable */ -#define HIFN_DMACSR_D_CTRL_ENA 0x80000000 /* Dest. Control: enable */ -#define HIFN_DMACSR_D_ABORT 0x20000000 /* Destinition Ring PCIAbort */ -#define HIFN_DMACSR_D_DONE 0x10000000 /* Destinition Ring Done */ -#define HIFN_DMACSR_D_LAST 0x08000000 /* Destinition Ring Last */ -#define HIFN_DMACSR_D_WAIT 0x04000000 /* Destinition Ring Waiting */ -#define HIFN_DMACSR_D_OVER 0x02000000 /* Destinition Ring Overflow */ -#define HIFN_DMACSR_R_CTRL 0x00c00000 /* Result Ring Control */ -#define HIFN_DMACSR_R_CTRL_NOP 0x00000000 /* Result Control: no-op */ -#define HIFN_DMACSR_R_CTRL_DIS 0x00400000 /* Result Control: disable */ -#define HIFN_DMACSR_R_CTRL_ENA 0x00800000 /* Result Control: enable */ -#define HIFN_DMACSR_R_ABORT 0x00200000 /* Result Ring PCI Abort */ -#define HIFN_DMACSR_R_DONE 0x00100000 /* Result Ring Done */ -#define HIFN_DMACSR_R_LAST 0x00080000 /* Result Ring Last */ -#define HIFN_DMACSR_R_WAIT 0x00040000 /* Result Ring Waiting */ -#define HIFN_DMACSR_R_OVER 0x00020000 /* Result Ring Overflow */ -#define HIFN_DMACSR_S_CTRL 0x0000c000 /* Source Ring Control */ -#define HIFN_DMACSR_S_CTRL_NOP 0x00000000 /* Source Control: no-op */ -#define HIFN_DMACSR_S_CTRL_DIS 0x00004000 /* Source Control: disable */ -#define HIFN_DMACSR_S_CTRL_ENA 0x00008000 /* Source Control: enable */ -#define HIFN_DMACSR_S_ABORT 0x00002000 /* Source Ring PCI Abort */ -#define HIFN_DMACSR_S_DONE 0x00001000 /* Source Ring Done */ -#define HIFN_DMACSR_S_LAST 0x00000800 /* Source Ring Last */ -#define HIFN_DMACSR_S_WAIT 0x00000400 /* Source Ring Waiting */ -#define HIFN_DMACSR_ILLW 0x00000200 /* Illegal write (7811 only) */ -#define HIFN_DMACSR_ILLR 0x00000100 /* Illegal read (7811 only) */ -#define HIFN_DMACSR_C_CTRL 0x000000c0 /* Command Ring Control */ -#define HIFN_DMACSR_C_CTRL_NOP 0x00000000 /* Command Control: no-op */ -#define HIFN_DMACSR_C_CTRL_DIS 0x00000040 /* Command Control: disable */ -#define HIFN_DMACSR_C_CTRL_ENA 0x00000080 /* Command Control: enable */ -#define HIFN_DMACSR_C_ABORT 0x00000020 /* Command Ring PCI Abort */ -#define HIFN_DMACSR_C_DONE 0x00000010 /* Command Ring Done */ -#define HIFN_DMACSR_C_LAST 0x00000008 /* Command Ring Last */ -#define HIFN_DMACSR_C_WAIT 0x00000004 /* Command Ring Waiting */ -#define HIFN_DMACSR_PUBDONE 0x00000002 /* Public op done (7951 only) */ -#define HIFN_DMACSR_ENGINE 0x00000001 /* Command Ring Engine IRQ */ - -/* DMA Interrupt Enable Register (HIFN_1_DMA_IER) */ -#define HIFN_DMAIER_D_ABORT 0x20000000 /* Destination Ring PCIAbort */ -#define HIFN_DMAIER_D_DONE 0x10000000 /* Destination Ring Done */ -#define HIFN_DMAIER_D_LAST 0x08000000 /* Destination Ring Last */ -#define HIFN_DMAIER_D_WAIT 0x04000000 /* Destination Ring Waiting */ -#define HIFN_DMAIER_D_OVER 0x02000000 /* Destination Ring Overflow */ -#define HIFN_DMAIER_R_ABORT 0x00200000 /* Result Ring PCI Abort */ -#define HIFN_DMAIER_R_DONE 0x00100000 /* Result Ring Done */ -#define HIFN_DMAIER_R_LAST 0x00080000 /* Result Ring Last */ -#define HIFN_DMAIER_R_WAIT 0x00040000 /* Result Ring Waiting */ -#define HIFN_DMAIER_R_OVER 0x00020000 /* Result Ring Overflow */ -#define HIFN_DMAIER_S_ABORT 0x00002000 /* Source Ring PCI Abort */ -#define HIFN_DMAIER_S_DONE 0x00001000 /* Source Ring Done */ -#define HIFN_DMAIER_S_LAST 0x00000800 /* Source Ring Last */ -#define HIFN_DMAIER_S_WAIT 0x00000400 /* Source Ring Waiting */ -#define HIFN_DMAIER_ILLW 0x00000200 /* Illegal write (7811 only) */ -#define HIFN_DMAIER_ILLR 0x00000100 /* Illegal read (7811 only) */ -#define HIFN_DMAIER_C_ABORT 0x00000020 /* Command Ring PCI Abort */ -#define HIFN_DMAIER_C_DONE 0x00000010 /* Command Ring Done */ -#define HIFN_DMAIER_C_LAST 0x00000008 /* Command Ring Last */ -#define HIFN_DMAIER_C_WAIT 0x00000004 /* Command Ring Waiting */ -#define HIFN_DMAIER_PUBDONE 0x00000002 /* public op done (7951 only) */ -#define HIFN_DMAIER_ENGINE 0x00000001 /* Engine IRQ */ - -/* DMA Configuration Register (HIFN_1_DMA_CNFG) */ -#define HIFN_DMACNFG_BIGENDIAN 0x10000000 /* big endian mode */ -#define HIFN_DMACNFG_POLLFREQ 0x00ff0000 /* Poll frequency mask */ -#define HIFN_DMACNFG_UNLOCK 0x00000800 -#define HIFN_DMACNFG_POLLINVAL 0x00000700 /* Invalid Poll Scalar */ -#define HIFN_DMACNFG_LAST 0x00000010 /* Host control LAST bit */ -#define HIFN_DMACNFG_MODE 0x00000004 /* DMA mode */ -#define HIFN_DMACNFG_DMARESET 0x00000002 /* DMA Reset # */ -#define HIFN_DMACNFG_MSTRESET 0x00000001 /* Master Reset # */ - -/* DMA Configuration Register (HIFN_1_DMA_CNFG2) */ -#define HIFN_DMACNFG2_PKSWAP32 (1 << 19) /* swap the OPLEN/OP reg */ -#define HIFN_DMACNFG2_PKSWAP8 (1 << 18) /* swap the bits of OPLEN/OP */ -#define HIFN_DMACNFG2_BAR0_SWAP32 (1<<17) /* swap the bytes of BAR0 */ -#define HIFN_DMACNFG2_BAR1_SWAP8 (1<<16) /* swap the bits of BAR0 */ -#define HIFN_DMACNFG2_INIT_WRITE_BURST_SHIFT 12 -#define HIFN_DMACNFG2_INIT_READ_BURST_SHIFT 8 -#define HIFN_DMACNFG2_TGT_WRITE_BURST_SHIFT 4 -#define HIFN_DMACNFG2_TGT_READ_BURST_SHIFT 0 - -/* 7811 RNG Enable Register (HIFN_1_7811_RNGENA) */ -#define HIFN_7811_RNGENA_ENA 0x00000001 /* enable RNG */ - -/* 7811 RNG Config Register (HIFN_1_7811_RNGCFG) */ -#define HIFN_7811_RNGCFG_PRE1 0x00000f00 /* first prescalar */ -#define HIFN_7811_RNGCFG_OPRE 0x00000080 /* output prescalar */ -#define HIFN_7811_RNGCFG_DEFL 0x00000f80 /* 2 words/ 1/100 sec */ - -/* 7811 RNG Status Register (HIFN_1_7811_RNGSTS) */ -#define HIFN_7811_RNGSTS_RDY 0x00004000 /* two numbers in FIFO */ -#define HIFN_7811_RNGSTS_UFL 0x00001000 /* rng underflow */ - -/* 7811 MIPS Reset Register (HIFN_1_7811_MIPSRST) */ -#define HIFN_MIPSRST_BAR2SIZE 0xffff0000 /* sdram size */ -#define HIFN_MIPSRST_GPRAMINIT 0x00008000 /* gpram can be accessed */ -#define HIFN_MIPSRST_CRAMINIT 0x00004000 /* ctxram can be accessed */ -#define HIFN_MIPSRST_LED2 0x00000400 /* external LED2 */ -#define HIFN_MIPSRST_LED1 0x00000200 /* external LED1 */ -#define HIFN_MIPSRST_LED0 0x00000100 /* external LED0 */ -#define HIFN_MIPSRST_MIPSDIS 0x00000004 /* disable MIPS */ -#define HIFN_MIPSRST_MIPSRST 0x00000002 /* warm reset MIPS */ -#define HIFN_MIPSRST_MIPSCOLD 0x00000001 /* cold reset MIPS */ - -/* Public key reset register (HIFN_1_PUB_RESET) */ -#define HIFN_PUBRST_RESET 0x00000001 /* reset public/rng unit */ - -/* Public operation register (HIFN_1_PUB_OP) */ -#define HIFN_PUBOP_AOFFSET 0x0000003e /* A offset */ -#define HIFN_PUBOP_BOFFSET 0x00000fc0 /* B offset */ -#define HIFN_PUBOP_MOFFSET 0x0003f000 /* M offset */ -#define HIFN_PUBOP_OP_MASK 0x003c0000 /* Opcode: */ -#define HIFN_PUBOP_OP_NOP 0x00000000 /* NOP */ -#define HIFN_PUBOP_OP_ADD 0x00040000 /* ADD */ -#define HIFN_PUBOP_OP_ADDC 0x00080000 /* ADD w/carry */ -#define HIFN_PUBOP_OP_SUB 0x000c0000 /* SUB */ -#define HIFN_PUBOP_OP_SUBC 0x00100000 /* SUB w/carry */ -#define HIFN_PUBOP_OP_MODADD 0x00140000 /* Modular ADD */ -#define HIFN_PUBOP_OP_MODSUB 0x00180000 /* Modular SUB */ -#define HIFN_PUBOP_OP_INCA 0x001c0000 /* INC A */ -#define HIFN_PUBOP_OP_DECA 0x00200000 /* DEC A */ -#define HIFN_PUBOP_OP_MULT 0x00240000 /* MULT */ -#define HIFN_PUBOP_OP_MODMULT 0x00280000 /* Modular MULT */ -#define HIFN_PUBOP_OP_MODRED 0x002c0000 /* Modular Red */ -#define HIFN_PUBOP_OP_MODEXP 0x00300000 /* Modular Exp */ - -/* Public operand length register (HIFN_1_PUB_OPLEN) */ -#define HIFN_PUBOPLEN_MODLEN 0x0000007f -#define HIFN_PUBOPLEN_EXPLEN 0x0003ff80 -#define HIFN_PUBOPLEN_REDLEN 0x003c0000 - -/* Public status register (HIFN_1_PUB_STATUS) */ -#define HIFN_PUBSTS_DONE 0x00000001 /* operation done */ -#define HIFN_PUBSTS_CARRY 0x00000002 /* carry */ -#define HIFN_PUBSTS_FIFO_EMPTY 0x00000100 /* fifo empty */ -#define HIFN_PUBSTS_FIFO_FULL 0x00000200 /* fifo full */ -#define HIFN_PUBSTS_FIFO_OVFL 0x00000400 /* fifo overflow */ -#define HIFN_PUBSTS_FIFO_WRITE 0x000f0000 /* fifo write */ -#define HIFN_PUBSTS_FIFO_READ 0x0f000000 /* fifo read */ - -/* Public interrupt enable register (HIFN_1_PUB_IEN) */ -#define HIFN_PUBIEN_DONE 0x00000001 /* operation done interrupt */ - -/* Random number generator config register (HIFN_1_RNG_CONFIG) */ -#define HIFN_RNGCFG_ENA 0x00000001 /* enable rng */ - -/* - * Register offsets in register set 1 - */ - -#define HIFN_UNLOCK_SECRET1 0xf4 -#define HIFN_UNLOCK_SECRET2 0xfc - -/* - * PLL config register - * - * This register is present only on 7954/7955/7956 parts. It must be - * programmed according to the bus interface method used by the h/w. - * Note that the parts require a stable clock. Since the PCI clock - * may vary the reference clock must usually be used. To avoid - * overclocking the core logic, setup must be done carefully, refer - * to the driver for details. The exact multiplier required varies - * by part and system configuration; refer to the Hifn documentation. - */ -#define HIFN_PLL_REF_SEL 0x00000001 /* REF/HBI clk selection */ -#define HIFN_PLL_BP 0x00000002 /* bypass (used during setup) */ -/* bit 2 reserved */ -#define HIFN_PLL_PK_CLK_SEL 0x00000008 /* public key clk select */ -#define HIFN_PLL_PE_CLK_SEL 0x00000010 /* packet engine clk select */ -/* bits 5-9 reserved */ -#define HIFN_PLL_MBSET 0x00000400 /* must be set to 1 */ -#define HIFN_PLL_ND 0x00003800 /* Fpll_ref multiplier select */ -#define HIFN_PLL_ND_SHIFT 11 -#define HIFN_PLL_ND_2 0x00000000 /* 2x */ -#define HIFN_PLL_ND_4 0x00000800 /* 4x */ -#define HIFN_PLL_ND_6 0x00001000 /* 6x */ -#define HIFN_PLL_ND_8 0x00001800 /* 8x */ -#define HIFN_PLL_ND_10 0x00002000 /* 10x */ -#define HIFN_PLL_ND_12 0x00002800 /* 12x */ -/* bits 14-15 reserved */ -#define HIFN_PLL_IS 0x00010000 /* charge pump current select */ -/* bits 17-31 reserved */ - -/* - * Board configuration specifies only these bits. - */ -#define HIFN_PLL_CONFIG (HIFN_PLL_IS|HIFN_PLL_ND|HIFN_PLL_REF_SEL) - -/* - * Public Key Engine Mode Register - */ -#define HIFN_PKMODE_HOSTINVERT (1 << 0) /* HOST INVERT */ -#define HIFN_PKMODE_ENHANCED (1 << 1) /* Enable enhanced mode */ - - -/********************************************************************* - * Structs for board commands - * - *********************************************************************/ - -/* - * Structure to help build up the command data structure. - */ -typedef struct hifn_base_command { - volatile u_int16_t masks; - volatile u_int16_t session_num; - volatile u_int16_t total_source_count; - volatile u_int16_t total_dest_count; -} hifn_base_command_t; - -#define HIFN_BASE_CMD_MAC 0x0400 -#define HIFN_BASE_CMD_CRYPT 0x0800 -#define HIFN_BASE_CMD_DECODE 0x2000 -#define HIFN_BASE_CMD_SRCLEN_M 0xc000 -#define HIFN_BASE_CMD_SRCLEN_S 14 -#define HIFN_BASE_CMD_DSTLEN_M 0x3000 -#define HIFN_BASE_CMD_DSTLEN_S 12 -#define HIFN_BASE_CMD_LENMASK_HI 0x30000 -#define HIFN_BASE_CMD_LENMASK_LO 0x0ffff - -/* - * Structure to help build up the command data structure. - */ -typedef struct hifn_crypt_command { - volatile u_int16_t masks; - volatile u_int16_t header_skip; - volatile u_int16_t source_count; - volatile u_int16_t reserved; -} hifn_crypt_command_t; - -#define HIFN_CRYPT_CMD_ALG_MASK 0x0003 /* algorithm: */ -#define HIFN_CRYPT_CMD_ALG_DES 0x0000 /* DES */ -#define HIFN_CRYPT_CMD_ALG_3DES 0x0001 /* 3DES */ -#define HIFN_CRYPT_CMD_ALG_RC4 0x0002 /* RC4 */ -#define HIFN_CRYPT_CMD_ALG_AES 0x0003 /* AES */ -#define HIFN_CRYPT_CMD_MODE_MASK 0x0018 /* Encrypt mode: */ -#define HIFN_CRYPT_CMD_MODE_ECB 0x0000 /* ECB */ -#define HIFN_CRYPT_CMD_MODE_CBC 0x0008 /* CBC */ -#define HIFN_CRYPT_CMD_MODE_CFB 0x0010 /* CFB */ -#define HIFN_CRYPT_CMD_MODE_OFB 0x0018 /* OFB */ -#define HIFN_CRYPT_CMD_CLR_CTX 0x0040 /* clear context */ -#define HIFN_CRYPT_CMD_NEW_KEY 0x0800 /* expect new key */ -#define HIFN_CRYPT_CMD_NEW_IV 0x1000 /* expect new iv */ - -#define HIFN_CRYPT_CMD_SRCLEN_M 0xc000 -#define HIFN_CRYPT_CMD_SRCLEN_S 14 - -#define HIFN_CRYPT_CMD_KSZ_MASK 0x0600 /* AES key size: */ -#define HIFN_CRYPT_CMD_KSZ_128 0x0000 /* 128 bit */ -#define HIFN_CRYPT_CMD_KSZ_192 0x0200 /* 192 bit */ -#define HIFN_CRYPT_CMD_KSZ_256 0x0400 /* 256 bit */ - -/* - * Structure to help build up the command data structure. - */ -typedef struct hifn_mac_command { - volatile u_int16_t masks; - volatile u_int16_t header_skip; - volatile u_int16_t source_count; - volatile u_int16_t reserved; -} hifn_mac_command_t; - -#define HIFN_MAC_CMD_ALG_MASK 0x0001 -#define HIFN_MAC_CMD_ALG_SHA1 0x0000 -#define HIFN_MAC_CMD_ALG_MD5 0x0001 -#define HIFN_MAC_CMD_MODE_MASK 0x000c -#define HIFN_MAC_CMD_MODE_HMAC 0x0000 -#define HIFN_MAC_CMD_MODE_SSL_MAC 0x0004 -#define HIFN_MAC_CMD_MODE_HASH 0x0008 -#define HIFN_MAC_CMD_MODE_FULL 0x0004 -#define HIFN_MAC_CMD_TRUNC 0x0010 -#define HIFN_MAC_CMD_RESULT 0x0020 -#define HIFN_MAC_CMD_APPEND 0x0040 -#define HIFN_MAC_CMD_SRCLEN_M 0xc000 -#define HIFN_MAC_CMD_SRCLEN_S 14 - -/* - * MAC POS IPsec initiates authentication after encryption on encodes - * and before decryption on decodes. - */ -#define HIFN_MAC_CMD_POS_IPSEC 0x0200 -#define HIFN_MAC_CMD_NEW_KEY 0x0800 - -/* - * The poll frequency and poll scalar defines are unshifted values used - * to set fields in the DMA Configuration Register. - */ -#ifndef HIFN_POLL_FREQUENCY -#define HIFN_POLL_FREQUENCY 0x1 -#endif - -#ifndef HIFN_POLL_SCALAR -#define HIFN_POLL_SCALAR 0x0 -#endif - -#define HIFN_MAX_SEGLEN 0xffff /* maximum dma segment len */ -#define HIFN_MAX_DMALEN 0x3ffff /* maximum dma length */ -#endif /* __HIFN_H__ */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/hifn/hifn7751var.h b/target/linux/generic-2.4/files/crypto/ocf/hifn/hifn7751var.h deleted file mode 100644 index 9a5f231..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/hifn/hifn7751var.h +++ /dev/null @@ -1,369 +0,0 @@ -/* $FreeBSD: src/sys/dev/hifn/hifn7751var.h,v 1.9 2007/03/21 03:42:49 sam Exp $ */ -/* $OpenBSD: hifn7751var.h,v 1.42 2002/04/08 17:49:42 jason Exp $ */ - -/*- - * Invertex AEON / Hifn 7751 driver - * Copyright (c) 1999 Invertex Inc. All rights reserved. - * Copyright (c) 1999 Theo de Raadt - * Copyright (c) 2000-2001 Network Security Technologies, Inc. - * http://www.netsec.net - * - * Please send any comments, feedback, bug-fixes, or feature requests to - * software@invertex.com. - * - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR 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. - * - * Effort sponsored in part by the Defense Advanced Research Projects - * Agency (DARPA) and Air Force Research Laboratory, Air Force - * Materiel Command, USAF, under agreement number F30602-01-2-0537. - * - */ - -#ifndef __HIFN7751VAR_H__ -#define __HIFN7751VAR_H__ - -#ifdef __KERNEL__ - -/* - * Some configurable values for the driver. By default command+result - * descriptor rings are the same size. The src+dst descriptor rings - * are sized at 3.5x the number of potential commands. Slower parts - * (e.g. 7951) tend to run out of src descriptors; faster parts (7811) - * src+cmd/result descriptors. It's not clear that increasing the size - * of the descriptor rings helps performance significantly as other - * factors tend to come into play (e.g. copying misaligned packets). - */ -#define HIFN_D_CMD_RSIZE 24 /* command descriptors */ -#define HIFN_D_SRC_RSIZE ((HIFN_D_CMD_RSIZE * 7) / 2) /* source descriptors */ -#define HIFN_D_RES_RSIZE HIFN_D_CMD_RSIZE /* result descriptors */ -#define HIFN_D_DST_RSIZE HIFN_D_SRC_RSIZE /* destination descriptors */ - -/* - * Length values for cryptography - */ -#define HIFN_DES_KEY_LENGTH 8 -#define HIFN_3DES_KEY_LENGTH 24 -#define HIFN_MAX_CRYPT_KEY_LENGTH HIFN_3DES_KEY_LENGTH -#define HIFN_IV_LENGTH 8 -#define HIFN_AES_IV_LENGTH 16 -#define HIFN_MAX_IV_LENGTH HIFN_AES_IV_LENGTH - -/* - * Length values for authentication - */ -#define HIFN_MAC_KEY_LENGTH 64 -#define HIFN_MD5_LENGTH 16 -#define HIFN_SHA1_LENGTH 20 -#define HIFN_MAC_TRUNC_LENGTH 12 - -#define MAX_SCATTER 64 - -/* - * Data structure to hold all 4 rings and any other ring related data. - */ -struct hifn_dma { - /* - * Descriptor rings. We add +1 to the size to accomidate the - * jump descriptor. - */ - struct hifn_desc cmdr[HIFN_D_CMD_RSIZE+1]; - struct hifn_desc srcr[HIFN_D_SRC_RSIZE+1]; - struct hifn_desc dstr[HIFN_D_DST_RSIZE+1]; - struct hifn_desc resr[HIFN_D_RES_RSIZE+1]; - - struct hifn_command *hifn_commands[HIFN_D_RES_RSIZE]; - - u_char command_bufs[HIFN_D_CMD_RSIZE][HIFN_MAX_COMMAND]; - u_char result_bufs[HIFN_D_CMD_RSIZE][HIFN_MAX_RESULT]; - u_int32_t slop[HIFN_D_CMD_RSIZE]; - - u_int64_t test_src, test_dst; - - /* - * Our current positions for insertion and removal from the desriptor - * rings. - */ - int cmdi, srci, dsti, resi; - volatile int cmdu, srcu, dstu, resu; - int cmdk, srck, dstk, resk; -}; - -struct hifn_session { - int hs_used; - int hs_mlen; - u_int8_t hs_iv[HIFN_MAX_IV_LENGTH]; -}; - -#define HIFN_RING_SYNC(sc, r, i, f) \ - /* DAVIDM bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_dmamap, (f)) */ - -#define HIFN_CMDR_SYNC(sc, i, f) HIFN_RING_SYNC((sc), cmdr, (i), (f)) -#define HIFN_RESR_SYNC(sc, i, f) HIFN_RING_SYNC((sc), resr, (i), (f)) -#define HIFN_SRCR_SYNC(sc, i, f) HIFN_RING_SYNC((sc), srcr, (i), (f)) -#define HIFN_DSTR_SYNC(sc, i, f) HIFN_RING_SYNC((sc), dstr, (i), (f)) - -#define HIFN_CMD_SYNC(sc, i, f) \ - /* DAVIDM bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_dmamap, (f)) */ - -#define HIFN_RES_SYNC(sc, i, f) \ - /* DAVIDM bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_dmamap, (f)) */ - -typedef int bus_size_t; - -/* - * Holds data specific to a single HIFN board. - */ -struct hifn_softc { - softc_device_decl sc_dev; - - struct pci_dev *sc_pcidev; /* PCI device pointer */ - spinlock_t sc_mtx; /* per-instance lock */ - - int sc_num; /* for multiple devs */ - - ocf_iomem_t sc_bar0; - bus_size_t sc_bar0_lastreg;/* bar0 last reg written */ - ocf_iomem_t sc_bar1; - bus_size_t sc_bar1_lastreg;/* bar1 last reg written */ - - int sc_irq; - - u_int32_t sc_dmaier; - u_int32_t sc_drammodel; /* 1=dram, 0=sram */ - u_int32_t sc_pllconfig; /* 7954/7955/7956 PLL config */ - - struct hifn_dma *sc_dma; - dma_addr_t sc_dma_physaddr;/* physical address of sc_dma */ - - int sc_dmansegs; - int32_t sc_cid; - int sc_maxses; - int sc_nsessions; - struct hifn_session *sc_sessions; - int sc_ramsize; - int sc_flags; -#define HIFN_HAS_RNG 0x1 /* includes random number generator */ -#define HIFN_HAS_PUBLIC 0x2 /* includes public key support */ -#define HIFN_HAS_AES 0x4 /* includes AES support */ -#define HIFN_IS_7811 0x8 /* Hifn 7811 part */ -#define HIFN_IS_7956 0x10 /* Hifn 7956/7955 don't have SDRAM */ - - struct timer_list sc_tickto; /* for managing DMA */ - - int sc_rngfirst; - int sc_rnghz; /* RNG polling frequency */ - - int sc_c_busy; /* command ring busy */ - int sc_s_busy; /* source data ring busy */ - int sc_d_busy; /* destination data ring busy */ - int sc_r_busy; /* result ring busy */ - int sc_active; /* for initial countdown */ - int sc_needwakeup; /* ops q'd wating on resources */ - int sc_curbatch; /* # ops submitted w/o int */ - int sc_suspended; -#ifdef HIFN_VULCANDEV - struct cdev *sc_pkdev; -#endif -}; - -#define HIFN_LOCK(_sc) spin_lock_irqsave(&(_sc)->sc_mtx, l_flags) -#define HIFN_UNLOCK(_sc) spin_unlock_irqrestore(&(_sc)->sc_mtx, l_flags) - -/* - * hifn_command_t - * - * This is the control structure used to pass commands to hifn_encrypt(). - * - * flags - * ----- - * Flags is the bitwise "or" values for command configuration. A single - * encrypt direction needs to be set: - * - * HIFN_ENCODE or HIFN_DECODE - * - * To use cryptography, a single crypto algorithm must be included: - * - * HIFN_CRYPT_3DES or HIFN_CRYPT_DES - * - * To use authentication is used, a single MAC algorithm must be included: - * - * HIFN_MAC_MD5 or HIFN_MAC_SHA1 - * - * By default MD5 uses a 16 byte hash and SHA-1 uses a 20 byte hash. - * If the value below is set, hash values are truncated or assumed - * truncated to 12 bytes: - * - * HIFN_MAC_TRUNC - * - * Keys for encryption and authentication can be sent as part of a command, - * or the last key value used with a particular session can be retrieved - * and used again if either of these flags are not specified. - * - * HIFN_CRYPT_NEW_KEY, HIFN_MAC_NEW_KEY - * - * session_num - * ----------- - * A number between 0 and 2048 (for DRAM models) or a number between - * 0 and 768 (for SRAM models). Those who don't want to use session - * numbers should leave value at zero and send a new crypt key and/or - * new MAC key on every command. If you use session numbers and - * don't send a key with a command, the last key sent for that same - * session number will be used. - * - * Warning: Using session numbers and multiboard at the same time - * is currently broken. - * - * mbuf - * ---- - * Either fill in the mbuf pointer and npa=0 or - * fill packp[] and packl[] and set npa to > 0 - * - * mac_header_skip - * --------------- - * The number of bytes of the source_buf that are skipped over before - * authentication begins. This must be a number between 0 and 2^16-1 - * and can be used by IPsec implementers to skip over IP headers. - * *** Value ignored if authentication not used *** - * - * crypt_header_skip - * ----------------- - * The number of bytes of the source_buf that are skipped over before - * the cryptographic operation begins. This must be a number between 0 - * and 2^16-1. For IPsec, this number will always be 8 bytes larger - * than the auth_header_skip (to skip over the ESP header). - * *** Value ignored if cryptography not used *** - * - */ -struct hifn_operand { - union { - struct sk_buff *skb; - struct uio *io; - unsigned char *buf; - } u; - void *map; - bus_size_t mapsize; - int nsegs; - struct { - dma_addr_t ds_addr; - int ds_len; - } segs[MAX_SCATTER]; -}; - -struct hifn_command { - u_int16_t session_num; - u_int16_t base_masks, cry_masks, mac_masks; - u_int8_t iv[HIFN_MAX_IV_LENGTH], *ck, mac[HIFN_MAC_KEY_LENGTH]; - int cklen; - int sloplen, slopidx; - - struct hifn_operand src; - struct hifn_operand dst; - - struct hifn_softc *softc; - struct cryptop *crp; - struct cryptodesc *enccrd, *maccrd; -}; - -#define src_skb src.u.skb -#define src_io src.u.io -#define src_map src.map -#define src_mapsize src.mapsize -#define src_segs src.segs -#define src_nsegs src.nsegs -#define src_buf src.u.buf - -#define dst_skb dst.u.skb -#define dst_io dst.u.io -#define dst_map dst.map -#define dst_mapsize dst.mapsize -#define dst_segs dst.segs -#define dst_nsegs dst.nsegs -#define dst_buf dst.u.buf - -/* - * Return values for hifn_crypto() - */ -#define HIFN_CRYPTO_SUCCESS 0 -#define HIFN_CRYPTO_BAD_INPUT (-1) -#define HIFN_CRYPTO_RINGS_FULL (-2) - -/************************************************************************** - * - * Function: hifn_crypto - * - * Purpose: Called by external drivers to begin an encryption on the - * HIFN board. - * - * Blocking/Non-blocking Issues - * ============================ - * The driver cannot block in hifn_crypto (no calls to tsleep) currently. - * hifn_crypto() returns HIFN_CRYPTO_RINGS_FULL if there is not enough - * room in any of the rings for the request to proceed. - * - * Return Values - * ============= - * 0 for success, negative values on error - * - * Defines for negative error codes are: - * - * HIFN_CRYPTO_BAD_INPUT : The passed in command had invalid settings. - * HIFN_CRYPTO_RINGS_FULL : All DMA rings were full and non-blocking - * behaviour was requested. - * - *************************************************************************/ - -/* - * Convert back and forth from 'sid' to 'card' and 'session' - */ -#define HIFN_CARD(sid) (((sid) & 0xf0000000) >> 28) -#define HIFN_SESSION(sid) ((sid) & 0x000007ff) -#define HIFN_SID(crd,ses) (((crd) << 28) | ((ses) & 0x7ff)) - -#endif /* _KERNEL */ - -struct hifn_stats { - u_int64_t hst_ibytes; - u_int64_t hst_obytes; - u_int32_t hst_ipackets; - u_int32_t hst_opackets; - u_int32_t hst_invalid; - u_int32_t hst_nomem; /* malloc or one of hst_nomem_* */ - u_int32_t hst_abort; - u_int32_t hst_noirq; /* IRQ for no reason */ - u_int32_t hst_totbatch; /* ops submitted w/o interrupt */ - u_int32_t hst_maxbatch; /* max ops submitted together */ - u_int32_t hst_unaligned; /* unaligned src caused copy */ - /* - * The following divides hst_nomem into more specific buckets. - */ - u_int32_t hst_nomem_map; /* bus_dmamap_create failed */ - u_int32_t hst_nomem_load; /* bus_dmamap_load_* failed */ - u_int32_t hst_nomem_mbuf; /* MGET* failed */ - u_int32_t hst_nomem_mcl; /* MCLGET* failed */ - u_int32_t hst_nomem_cr; /* out of command/result descriptor */ - u_int32_t hst_nomem_sd; /* out of src/dst descriptors */ -}; - -#endif /* __HIFN7751VAR_H__ */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/hifn/hifnHIPP.c b/target/linux/generic-2.4/files/crypto/ocf/hifn/hifnHIPP.c deleted file mode 100644 index a11b236..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/hifn/hifnHIPP.c +++ /dev/null @@ -1,421 +0,0 @@ -/*- - * Driver for Hifn HIPP-I/II chipset - * Copyright (c) 2006 Michael Richardson <mcr@xelerance.com> - * - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR 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. - * - * Effort sponsored by Hifn Inc. - * - */ - -/* - * Driver for various Hifn encryption processors. - */ -#ifndef AUTOCONF_INCLUDED -#include <linux/config.h> -#endif -#include <linux/module.h> -#include <linux/init.h> -#include <linux/list.h> -#include <linux/slab.h> -#include <linux/wait.h> -#include <linux/sched.h> -#include <linux/pci.h> -#include <linux/delay.h> -#include <linux/interrupt.h> -#include <linux/spinlock.h> -#include <linux/random.h> -#include <linux/version.h> -#include <linux/skbuff.h> -#include <linux/uio.h> -#include <linux/sysfs.h> -#include <linux/miscdevice.h> -#include <asm/io.h> - -#include <cryptodev.h> - -#include "hifnHIPPreg.h" -#include "hifnHIPPvar.h" - -#if 1 -#define DPRINTF(a...) if (hipp_debug) { \ - printk("%s: ", sc ? \ - device_get_nameunit(sc->sc_dev) : "hifn"); \ - printk(a); \ - } else -#else -#define DPRINTF(a...) -#endif - -typedef int bus_size_t; - -static inline int -pci_get_revid(struct pci_dev *dev) -{ - u8 rid = 0; - pci_read_config_byte(dev, PCI_REVISION_ID, &rid); - return rid; -} - -#define debug hipp_debug -int hipp_debug = 0; -module_param(hipp_debug, int, 0644); -MODULE_PARM_DESC(hipp_debug, "Enable debug"); - -int hipp_maxbatch = 1; -module_param(hipp_maxbatch, int, 0644); -MODULE_PARM_DESC(hipp_maxbatch, "max ops to batch w/o interrupt"); - -static int hipp_probe(struct pci_dev *dev, const struct pci_device_id *ent); -static void hipp_remove(struct pci_dev *dev); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19) -static irqreturn_t hipp_intr(int irq, void *arg); -#else -static irqreturn_t hipp_intr(int irq, void *arg, struct pt_regs *regs); -#endif - -static int hipp_num_chips = 0; -static struct hipp_softc *hipp_chip_idx[HIPP_MAX_CHIPS]; - -static int hipp_newsession(device_t, u_int32_t *, struct cryptoini *); -static int hipp_freesession(device_t, u_int64_t); -static int hipp_process(device_t, struct cryptop *, int); - -static device_method_t hipp_methods = { - /* crypto device methods */ - DEVMETHOD(cryptodev_newsession, hipp_newsession), - DEVMETHOD(cryptodev_freesession,hipp_freesession), - DEVMETHOD(cryptodev_process, hipp_process), -}; - -static __inline u_int32_t -READ_REG(struct hipp_softc *sc, unsigned int barno, bus_size_t reg) -{ - u_int32_t v = readl(sc->sc_bar[barno] + reg); - //sc->sc_bar0_lastreg = (bus_size_t) -1; - return (v); -} -static __inline void -WRITE_REG(struct hipp_softc *sc, unsigned int barno, bus_size_t reg, u_int32_t val) -{ - writel(val, sc->sc_bar[barno] + reg); -} - -#define READ_REG_0(sc, reg) READ_REG(sc, 0, reg) -#define WRITE_REG_0(sc, reg, val) WRITE_REG(sc,0, reg, val) -#define READ_REG_1(sc, reg) READ_REG(sc, 1, reg) -#define WRITE_REG_1(sc, reg, val) WRITE_REG(sc,1, reg, val) - -static int -hipp_newsession(device_t dev, u_int32_t *sidp, struct cryptoini *cri) -{ - return EINVAL; -} - -static int -hipp_freesession(device_t dev, u_int64_t tid) -{ - return EINVAL; -} - -static int -hipp_process(device_t dev, struct cryptop *crp, int hint) -{ - return EINVAL; -} - -static const char* -hipp_partname(struct hipp_softc *sc, char buf[128], size_t blen) -{ - char *n = NULL; - - switch (pci_get_vendor(sc->sc_pcidev)) { - case PCI_VENDOR_HIFN: - switch (pci_get_device(sc->sc_pcidev)) { - case PCI_PRODUCT_HIFN_7855: n = "Hifn 7855"; - case PCI_PRODUCT_HIFN_8155: n = "Hifn 8155"; - case PCI_PRODUCT_HIFN_6500: n = "Hifn 6500"; - } - } - - if(n==NULL) { - snprintf(buf, blen, "VID=%02x,PID=%02x", - pci_get_vendor(sc->sc_pcidev), - pci_get_device(sc->sc_pcidev)); - } else { - buf[0]='\0'; - strncat(buf, n, blen); - } - return buf; -} - -struct hipp_fs_entry { - struct attribute attr; - /* other stuff */ -}; - - -static ssize_t -cryptoid_show(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct hipp_softc *sc; - - sc = pci_get_drvdata(to_pci_dev (dev)); - return sprintf (buf, "%d\n", sc->sc_cid); -} - -struct device_attribute hipp_dev_cryptoid = __ATTR_RO(cryptoid); - -/* - * Attach an interface that successfully probed. - */ -static int -hipp_probe(struct pci_dev *dev, const struct pci_device_id *ent) -{ - struct hipp_softc *sc = NULL; - int i; - //char rbase; - //u_int16_t ena; - int rev; - //int rseg; - int rc; - - DPRINTF("%s()\n", __FUNCTION__); - - if (pci_enable_device(dev) < 0) - return(-ENODEV); - - if (pci_set_mwi(dev)) - return(-ENODEV); - - if (!dev->irq) { - printk("hifn: found device with no IRQ assigned. check BIOS settings!"); - pci_disable_device(dev); - return(-ENODEV); - } - - sc = (struct hipp_softc *) kmalloc(sizeof(*sc), GFP_KERNEL); - if (!sc) - return(-ENOMEM); - memset(sc, 0, sizeof(*sc)); - - softc_device_init(sc, "hifn-hipp", hipp_num_chips, hipp_methods); - - sc->sc_pcidev = dev; - sc->sc_irq = -1; - sc->sc_cid = -1; - sc->sc_num = hipp_num_chips++; - - if (sc->sc_num < HIPP_MAX_CHIPS) - hipp_chip_idx[sc->sc_num] = sc; - - pci_set_drvdata(sc->sc_pcidev, sc); - - spin_lock_init(&sc->sc_mtx); - - /* - * Setup PCI resources. - * The READ_REG_0, WRITE_REG_0, READ_REG_1, - * and WRITE_REG_1 macros throughout the driver are used - * to permit better debugging. - */ - for(i=0; i<4; i++) { - unsigned long mem_start, mem_len; - mem_start = pci_resource_start(sc->sc_pcidev, i); - mem_len = pci_resource_len(sc->sc_pcidev, i); - sc->sc_barphy[i] = (caddr_t)mem_start; - sc->sc_bar[i] = (ocf_iomem_t) ioremap(mem_start, mem_len); - if (!sc->sc_bar[i]) { - device_printf(sc->sc_dev, "cannot map bar%d register space\n", i); - goto fail; - } - } - - //hipp_reset_board(sc, 0); - pci_set_master(sc->sc_pcidev); - - /* - * Arrange the interrupt line. - */ - rc = request_irq(dev->irq, hipp_intr, IRQF_SHARED, "hifn", sc); - if (rc) { - device_printf(sc->sc_dev, "could not map interrupt: %d\n", rc); - goto fail; - } - sc->sc_irq = dev->irq; - - rev = READ_REG_1(sc, HIPP_1_REVID) & 0xffff; - - { - char b[32]; - device_printf(sc->sc_dev, "%s, rev %u", - hipp_partname(sc, b, sizeof(b)), rev); - } - -#if 0 - if (sc->sc_flags & HIFN_IS_7956) - printf(", pll=0x%x<%s clk, %ux mult>", - sc->sc_pllconfig, - sc->sc_pllconfig & HIFN_PLL_REF_SEL ? "ext" : "pci", - 2 + 2*((sc->sc_pllconfig & HIFN_PLL_ND) >> 11)); -#endif - printf("\n"); - - sc->sc_cid = crypto_get_driverid(softc_get_device(sc),CRYPTOCAP_F_HARDWARE); - if (sc->sc_cid < 0) { - device_printf(sc->sc_dev, "could not get crypto driver id\n"); - goto fail; - } - -#if 0 /* cannot work with a non-GPL module */ - /* make a sysfs entry to let the world know what entry we got */ - sysfs_create_file(&sc->sc_pcidev->dev.kobj, &hipp_dev_cryptoid.attr); -#endif - -#if 0 - init_timer(&sc->sc_tickto); - sc->sc_tickto.function = hifn_tick; - sc->sc_tickto.data = (unsigned long) sc->sc_num; - mod_timer(&sc->sc_tickto, jiffies + HZ); -#endif - -#if 0 /* no code here yet ?? */ - crypto_register(sc->sc_cid, CRYPTO_3DES_CBC, 0, 0); -#endif - - return (0); - -fail: - if (sc->sc_cid >= 0) - crypto_unregister_all(sc->sc_cid); - if (sc->sc_irq != -1) - free_irq(sc->sc_irq, sc); - -#if 0 - if (sc->sc_dma) { - /* Turn off DMA polling */ - WRITE_REG_1(sc, HIFN_1_DMA_CNFG, HIFN_DMACNFG_MSTRESET | - HIFN_DMACNFG_DMARESET | HIFN_DMACNFG_MODE); - - pci_free_consistent(sc->sc_pcidev, - sizeof(*sc->sc_dma), - sc->sc_dma, sc->sc_dma_physaddr); - } -#endif - kfree(sc); - return (-ENXIO); -} - -/* - * Detach an interface that successfully probed. - */ -static void -hipp_remove(struct pci_dev *dev) -{ - struct hipp_softc *sc = pci_get_drvdata(dev); - unsigned long l_flags; - - DPRINTF("%s()\n", __FUNCTION__); - - /* disable interrupts */ - HIPP_LOCK(sc); - -#if 0 - WRITE_REG_1(sc, HIFN_1_DMA_IER, 0); - HIFN_UNLOCK(sc); - - /*XXX other resources */ - del_timer_sync(&sc->sc_tickto); - - /* Turn off DMA polling */ - WRITE_REG_1(sc, HIFN_1_DMA_CNFG, HIFN_DMACNFG_MSTRESET | - HIFN_DMACNFG_DMARESET | HIFN_DMACNFG_MODE); -#endif - - crypto_unregister_all(sc->sc_cid); - - free_irq(sc->sc_irq, sc); - -#if 0 - pci_free_consistent(sc->sc_pcidev, sizeof(*sc->sc_dma), - sc->sc_dma, sc->sc_dma_physaddr); -#endif -} - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19) -static irqreturn_t hipp_intr(int irq, void *arg) -#else -static irqreturn_t hipp_intr(int irq, void *arg, struct pt_regs *regs) -#endif -{ - struct hipp_softc *sc = arg; - - sc = sc; /* shut up compiler */ - - return IRQ_HANDLED; -} - -static struct pci_device_id hipp_pci_tbl[] = { - { PCI_VENDOR_HIFN, PCI_PRODUCT_HIFN_7855, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, - { PCI_VENDOR_HIFN, PCI_PRODUCT_HIFN_8155, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, - { 0 } -}; -MODULE_DEVICE_TABLE(pci, hipp_pci_tbl); - -static struct pci_driver hipp_driver = { - .name = "hipp", - .id_table = hipp_pci_tbl, - .probe = hipp_probe, - .remove = hipp_remove, - /* add PM stuff here one day */ -}; - -static int __init hipp_init (void) -{ - struct hipp_softc *sc = NULL; - int rc; - - DPRINTF("%s(%p)\n", __FUNCTION__, hipp_init); - - rc = pci_register_driver(&hipp_driver); - pci_register_driver_compat(&hipp_driver, rc); - - return rc; -} - -static void __exit hipp_exit (void) -{ - pci_unregister_driver(&hipp_driver); -} - -module_init(hipp_init); -module_exit(hipp_exit); - -MODULE_LICENSE("BSD"); -MODULE_AUTHOR("Michael Richardson <mcr@xelerance.com>"); -MODULE_DESCRIPTION("OCF driver for hifn HIPP-I/II PCI crypto devices"); diff --git a/target/linux/generic-2.4/files/crypto/ocf/hifn/hifnHIPPreg.h b/target/linux/generic-2.4/files/crypto/ocf/hifn/hifnHIPPreg.h deleted file mode 100644 index 8c0e720..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/hifn/hifnHIPPreg.h +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * Hifn HIPP-I/HIPP-II (7855/8155) driver. - * Copyright (c) 2006 Michael Richardson <mcr@xelerance.com> - * - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR 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. - * - * Effort sponsored by Hifn inc. - * - */ - -#ifndef __HIFNHIPP_H__ -#define __HIFNHIPP_H__ - -/* - * PCI vendor and device identifiers - */ -#define PCI_VENDOR_HIFN 0x13a3 /* Hifn */ -#define PCI_PRODUCT_HIFN_6500 0x0006 /* 6500 */ -#define PCI_PRODUCT_HIFN_7855 0x001f /* 7855 */ -#define PCI_PRODUCT_HIFN_8155 0x999 /* XXX 8155 */ - -#define HIPP_1_REVID 0x01 /* BOGUS */ - -#endif /* __HIPP_H__ */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/hifn/hifnHIPPvar.h b/target/linux/generic-2.4/files/crypto/ocf/hifn/hifnHIPPvar.h deleted file mode 100644 index 61d292f..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/hifn/hifnHIPPvar.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Hifn HIPP-I/HIPP-II (7855/8155) driver. - * Copyright (c) 2006 Michael Richardson <mcr@xelerance.com> * - * - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR 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. - * - * Effort sponsored by Hifn inc. - * - */ - -#ifndef __HIFNHIPPVAR_H__ -#define __HIFNHIPPVAR_H__ - -#define HIPP_MAX_CHIPS 8 - -/* - * Holds data specific to a single Hifn HIPP-I board. - */ -struct hipp_softc { - softc_device_decl sc_dev; - - struct pci_dev *sc_pcidev; /* device backpointer */ - ocf_iomem_t sc_bar[5]; - caddr_t sc_barphy[5]; /* physical address */ - int sc_num; /* for multiple devs */ - spinlock_t sc_mtx; /* per-instance lock */ - int32_t sc_cid; - int sc_irq; - -#if 0 - - u_int32_t sc_dmaier; - u_int32_t sc_drammodel; /* 1=dram, 0=sram */ - u_int32_t sc_pllconfig; /* 7954/7955/7956 PLL config */ - - struct hifn_dma *sc_dma; - dma_addr_t sc_dma_physaddr;/* physical address of sc_dma */ - - int sc_dmansegs; - int sc_maxses; - int sc_nsessions; - struct hifn_session *sc_sessions; - int sc_ramsize; - int sc_flags; -#define HIFN_HAS_RNG 0x1 /* includes random number generator */ -#define HIFN_HAS_PUBLIC 0x2 /* includes public key support */ -#define HIFN_HAS_AES 0x4 /* includes AES support */ -#define HIFN_IS_7811 0x8 /* Hifn 7811 part */ -#define HIFN_IS_7956 0x10 /* Hifn 7956/7955 don't have SDRAM */ - - struct timer_list sc_tickto; /* for managing DMA */ - - int sc_rngfirst; - int sc_rnghz; /* RNG polling frequency */ - - int sc_c_busy; /* command ring busy */ - int sc_s_busy; /* source data ring busy */ - int sc_d_busy; /* destination data ring busy */ - int sc_r_busy; /* result ring busy */ - int sc_active; /* for initial countdown */ - int sc_needwakeup; /* ops q'd wating on resources */ - int sc_curbatch; /* # ops submitted w/o int */ - int sc_suspended; - struct miscdevice sc_miscdev; -#endif -}; - -#define HIPP_LOCK(_sc) spin_lock_irqsave(&(_sc)->sc_mtx, l_flags) -#define HIPP_UNLOCK(_sc) spin_unlock_irqrestore(&(_sc)->sc_mtx, l_flags) - -#endif /* __HIFNHIPPVAR_H__ */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/ixp4xx/Makefile b/target/linux/generic-2.4/files/crypto/ocf/ixp4xx/Makefile deleted file mode 100644 index d94a3b7..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/ixp4xx/Makefile +++ /dev/null @@ -1,104 +0,0 @@ -# for SGlinux builds --include $(ROOTDIR)/modules/.config - -# -# You will need to point this at your Intel ixp425 includes, this portion -# of the Makefile only really works under SGLinux with the appropriate libs -# installed. They can be downloaded from http://www.snapgear.org/ -# -ifeq ($(CONFIG_CPU_IXP46X),y) -IXPLATFORM = ixp46X -else -ifeq ($(CONFIG_CPU_IXP43X),y) -IXPLATFORM = ixp43X -else -IXPLATFORM = ixp42X -endif -endif - -ifdef CONFIG_IXP400_LIB_2_4 -IX_XSCALE_SW = $(ROOTDIR)/modules/ixp425/ixp400-2.4/ixp400_xscale_sw -OSAL_DIR = $(ROOTDIR)/modules/ixp425/ixp400-2.4/ixp_osal -endif -ifdef CONFIG_IXP400_LIB_2_1 -IX_XSCALE_SW = $(ROOTDIR)/modules/ixp425/ixp400-2.1/ixp400_xscale_sw -OSAL_DIR = $(ROOTDIR)/modules/ixp425/ixp400-2.1/ixp_osal -endif -ifdef CONFIG_IXP400_LIB_2_0 -IX_XSCALE_SW = $(ROOTDIR)/modules/ixp425/ixp400-2.0/ixp400_xscale_sw -OSAL_DIR = $(ROOTDIR)/modules/ixp425/ixp400-2.0/ixp_osal -endif -ifdef IX_XSCALE_SW -ifdef CONFIG_IXP400_LIB_2_4 -IXP_CFLAGS = \ - -I$(ROOTDIR)/. \ - -I$(IX_XSCALE_SW)/src/include \ - -I$(OSAL_DIR)/common/include/ \ - -I$(OSAL_DIR)/common/include/modules/ \ - -I$(OSAL_DIR)/common/include/modules/ddk/ \ - -I$(OSAL_DIR)/common/include/modules/bufferMgt/ \ - -I$(OSAL_DIR)/common/include/modules/ioMem/ \ - -I$(OSAL_DIR)/common/os/linux/include/ \ - -I$(OSAL_DIR)/common/os/linux/include/core/ \ - -I$(OSAL_DIR)/common/os/linux/include/modules/ \ - -I$(OSAL_DIR)/common/os/linux/include/modules/ddk/ \ - -I$(OSAL_DIR)/common/os/linux/include/modules/bufferMgt/ \ - -I$(OSAL_DIR)/common/os/linux/include/modules/ioMem/ \ - -I$(OSAL_DIR)/platforms/$(IXPLATFORM)/include/ \ - -I$(OSAL_DIR)/platforms/$(IXPLATFORM)/os/linux/include/ \ - -DENABLE_IOMEM -DENABLE_BUFFERMGT -DENABLE_DDK \ - -DUSE_IXP4XX_CRYPTO -else -IXP_CFLAGS = \ - -I$(ROOTDIR)/. \ - -I$(IX_XSCALE_SW)/src/include \ - -I$(OSAL_DIR)/ \ - -I$(OSAL_DIR)/os/linux/include/ \ - -I$(OSAL_DIR)/os/linux/include/modules/ \ - -I$(OSAL_DIR)/os/linux/include/modules/ioMem/ \ - -I$(OSAL_DIR)/os/linux/include/modules/bufferMgt/ \ - -I$(OSAL_DIR)/os/linux/include/core/ \ - -I$(OSAL_DIR)/os/linux/include/platforms/ \ - -I$(OSAL_DIR)/os/linux/include/platforms/ixp400/ \ - -I$(OSAL_DIR)/os/linux/include/platforms/ixp400/ixp425 \ - -I$(OSAL_DIR)/os/linux/include/platforms/ixp400/ixp465 \ - -I$(OSAL_DIR)/os/linux/include/core/ \ - -I$(OSAL_DIR)/include/ \ - -I$(OSAL_DIR)/include/modules/ \ - -I$(OSAL_DIR)/include/modules/bufferMgt/ \ - -I$(OSAL_DIR)/include/modules/ioMem/ \ - -I$(OSAL_DIR)/include/platforms/ \ - -I$(OSAL_DIR)/include/platforms/ixp400/ \ - -DUSE_IXP4XX_CRYPTO -endif -endif -ifdef CONFIG_IXP400_LIB_1_4 -IXP_CFLAGS = \ - -I$(ROOTDIR)/. \ - -I$(ROOTDIR)/modules/ixp425/ixp400-1.4/ixp400_xscale_sw/src/include \ - -I$(ROOTDIR)/modules/ixp425/ixp400-1.4/ixp400_xscale_sw/src/linux \ - -DUSE_IXP4XX_CRYPTO -endif -ifndef IXPDIR -IXPDIR = ixp-version-is-not-supported -endif - -ifeq ($(CONFIG_CPU_IXP46X),y) -IXP_CFLAGS += -D__ixp46X -else -ifeq ($(CONFIG_CPU_IXP43X),y) -IXP_CFLAGS += -D__ixp43X -else -IXP_CFLAGS += -D__ixp42X -endif -endif - -obj-$(CONFIG_OCF_IXP4XX) += ixp4xx.o - -obj ?= . -EXTRA_CFLAGS += $(IXP_CFLAGS) -I$(obj)/.. -I$(obj)/. - -ifdef TOPDIR --include $(TOPDIR)/Rules.make -endif - diff --git a/target/linux/generic-2.4/files/crypto/ocf/ixp4xx/ixp4xx.c b/target/linux/generic-2.4/files/crypto/ocf/ixp4xx/ixp4xx.c deleted file mode 100644 index d5414a4..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/ixp4xx/ixp4xx.c +++ /dev/null @@ -1,1324 +0,0 @@ -/* - * An OCF module that uses Intels IXP CryptACC API to do the crypto. - * This driver requires the IXP400 Access Library that is available - * from Intel in order to operate (or compile). - * - * Written by David McCullough <david_mccullough@mcafee.com> - * Copyright (C) 2006-2010 David McCullough - * Copyright (C) 2004-2005 Intel Corporation. - * - * LICENSE TERMS - * - * The free distribution and use of this software in both source and binary - * form is allowed (with or without changes) provided that: - * - * 1. distributions of this source code include the above copyright - * notice, this list of conditions and the following disclaimer; - * - * 2. distributions in binary form include the above copyright - * notice, this list of conditions and the following disclaimer - * in the documentation and/or other associated materials; - * - * 3. the copyright holder's name is not used to endorse products - * built using this software without specific written permission. - * - * ALTERNATIVELY, provided that this notice is retained in full, this product - * may be distributed under the terms of the GNU General Public License (GPL), - * in which case the provisions of the GPL apply INSTEAD OF those given above. - * - * DISCLAIMER - * - * This software is provided 'as is' with no explicit or implied warranties - * in respect of its properties, including, but not limited to, correctness - * and/or fitness for purpose. - */ - -#ifndef AUTOCONF_INCLUDED -#include <linux/config.h> -#endif -#include <linux/module.h> -#include <linux/init.h> -#include <linux/list.h> -#include <linux/slab.h> -#include <linux/sched.h> -#include <linux/wait.h> -#include <linux/crypto.h> -#include <linux/interrupt.h> -#include <asm/scatterlist.h> - -#include <IxTypes.h> -#include <IxOsBuffMgt.h> -#include <IxNpeDl.h> -#include <IxCryptoAcc.h> -#include <IxQMgr.h> -#include <IxOsServices.h> -#include <IxOsCacheMMU.h> - -#include <cryptodev.h> -#include <uio.h> - -#ifndef IX_MBUF_PRIV -#define IX_MBUF_PRIV(x) ((x)->priv) -#endif - -struct ixp_data; - -struct ixp_q { - struct list_head ixp_q_list; - struct ixp_data *ixp_q_data; - struct cryptop *ixp_q_crp; - struct cryptodesc *ixp_q_ccrd; - struct cryptodesc *ixp_q_acrd; - IX_MBUF ixp_q_mbuf; - UINT8 *ixp_hash_dest; /* Location for hash in client buffer */ - UINT8 *ixp_hash_src; /* Location of hash in internal buffer */ - unsigned char ixp_q_iv_data[IX_CRYPTO_ACC_MAX_CIPHER_IV_LENGTH]; - unsigned char *ixp_q_iv; -}; - -struct ixp_data { - int ixp_registered; /* is the context registered */ - int ixp_crd_flags; /* detect direction changes */ - - int ixp_cipher_alg; - int ixp_auth_alg; - - UINT32 ixp_ctx_id; - UINT32 ixp_hash_key_id; /* used when hashing */ - IxCryptoAccCtx ixp_ctx; - IX_MBUF ixp_pri_mbuf; - IX_MBUF ixp_sec_mbuf; - - struct work_struct ixp_pending_work; - struct work_struct ixp_registration_work; - struct list_head ixp_q; /* unprocessed requests */ -}; - -#ifdef __ixp46X - -#define MAX_IOP_SIZE 64 /* words */ -#define MAX_OOP_SIZE 128 - -#define MAX_PARAMS 3 - -struct ixp_pkq { - struct list_head pkq_list; - struct cryptkop *pkq_krp; - - IxCryptoAccPkeEauInOperands pkq_op; - IxCryptoAccPkeEauOpResult pkq_result; - - UINT32 pkq_ibuf0[MAX_IOP_SIZE]; - UINT32 pkq_ibuf1[MAX_IOP_SIZE]; - UINT32 pkq_ibuf2[MAX_IOP_SIZE]; - UINT32 pkq_obuf[MAX_OOP_SIZE]; -}; - -static LIST_HEAD(ixp_pkq); /* current PK wait list */ -static struct ixp_pkq *ixp_pk_cur; -static spinlock_t ixp_pkq_lock; - -#endif /* __ixp46X */ - -static int ixp_blocked = 0; - -static int32_t ixp_id = -1; -static struct ixp_data **ixp_sessions = NULL; -static u_int32_t ixp_sesnum = 0; - -static int ixp_process(device_t, struct cryptop *, int); -static int ixp_newsession(device_t, u_int32_t *, struct cryptoini *); -static int ixp_freesession(device_t, u_int64_t); -#ifdef __ixp46X -static int ixp_kprocess(device_t, struct cryptkop *krp, int hint); -#endif - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) -static kmem_cache_t *qcache; -#else -static struct kmem_cache *qcache; -#endif - -#define debug ixp_debug -static int ixp_debug = 0; -module_param(ixp_debug, int, 0644); -MODULE_PARM_DESC(ixp_debug, "Enable debug"); - -static int ixp_init_crypto = 1; -module_param(ixp_init_crypto, int, 0444); /* RO after load/boot */ -MODULE_PARM_DESC(ixp_init_crypto, "Call ixCryptoAccInit (default is 1)"); - -static void ixp_process_pending(void *arg); -static void ixp_registration(void *arg); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) -static void ixp_process_pending_wq(struct work_struct *work); -static void ixp_registration_wq(struct work_struct *work); -#endif - -/* - * dummy device structure - */ - -static struct { - softc_device_decl sc_dev; -} ixpdev; - -static device_method_t ixp_methods = { - /* crypto device methods */ - DEVMETHOD(cryptodev_newsession, ixp_newsession), - DEVMETHOD(cryptodev_freesession,ixp_freesession), - DEVMETHOD(cryptodev_process, ixp_process), -#ifdef __ixp46X - DEVMETHOD(cryptodev_kprocess, ixp_kprocess), -#endif -}; - -/* - * Generate a new software session. - */ -static int -ixp_newsession(device_t dev, u_int32_t *sid, struct cryptoini *cri) -{ - struct ixp_data *ixp; - u_int32_t i; -#define AUTH_LEN(cri, def) \ - (cri->cri_mlen ? cri->cri_mlen : (def)) - - dprintk("%s():alg %d\n", __FUNCTION__,cri->cri_alg); - if (sid == NULL || cri == NULL) { - dprintk("%s,%d - EINVAL\n", __FILE__, __LINE__); - return EINVAL; - } - - if (ixp_sessions) { - for (i = 1; i < ixp_sesnum; i++) - if (ixp_sessions[i] == NULL) - break; - } else - i = 1; /* NB: to silence compiler warning */ - - if (ixp_sessions == NULL || i == ixp_sesnum) { - struct ixp_data **ixpd; - - if (ixp_sessions == NULL) { - i = 1; /* We leave ixp_sessions[0] empty */ - ixp_sesnum = CRYPTO_SW_SESSIONS; - } else - ixp_sesnum *= 2; - - ixpd = kmalloc(ixp_sesnum * sizeof(struct ixp_data *), SLAB_ATOMIC); - if (ixpd == NULL) { - /* Reset session number */ - if (ixp_sesnum == CRYPTO_SW_SESSIONS) - ixp_sesnum = 0; - else - ixp_sesnum /= 2; - dprintk("%s,%d: ENOBUFS\n", __FILE__, __LINE__); - return ENOBUFS; - } - memset(ixpd, 0, ixp_sesnum * sizeof(struct ixp_data *)); - - /* Copy existing sessions */ - if (ixp_sessions) { - memcpy(ixpd, ixp_sessions, - (ixp_sesnum / 2) * sizeof(struct ixp_data *)); - kfree(ixp_sessions); - } - - ixp_sessions = ixpd; - } - - ixp_sessions[i] = (struct ixp_data *) kmalloc(sizeof(struct ixp_data), - SLAB_ATOMIC); - if (ixp_sessions[i] == NULL) { - ixp_freesession(NULL, i); - dprintk("%s,%d: EINVAL\n", __FILE__, __LINE__); - return ENOBUFS; - } - - *sid = i; - - ixp = ixp_sessions[i]; - memset(ixp, 0, sizeof(*ixp)); - - ixp->ixp_cipher_alg = -1; - ixp->ixp_auth_alg = -1; - ixp->ixp_ctx_id = -1; - INIT_LIST_HEAD(&ixp->ixp_q); - - ixp->ixp_ctx.useDifferentSrcAndDestMbufs = 0; - - while (cri) { - switch (cri->cri_alg) { - case CRYPTO_DES_CBC: - ixp->ixp_cipher_alg = cri->cri_alg; - ixp->ixp_ctx.cipherCtx.cipherAlgo = IX_CRYPTO_ACC_CIPHER_DES; - ixp->ixp_ctx.cipherCtx.cipherMode = IX_CRYPTO_ACC_MODE_CBC; - ixp->ixp_ctx.cipherCtx.cipherKeyLen = (cri->cri_klen + 7) / 8; - ixp->ixp_ctx.cipherCtx.cipherBlockLen = IX_CRYPTO_ACC_DES_BLOCK_64; - ixp->ixp_ctx.cipherCtx.cipherInitialVectorLen = - IX_CRYPTO_ACC_DES_IV_64; - memcpy(ixp->ixp_ctx.cipherCtx.key.cipherKey, - cri->cri_key, (cri->cri_klen + 7) / 8); - break; - - case CRYPTO_3DES_CBC: - ixp->ixp_cipher_alg = cri->cri_alg; - ixp->ixp_ctx.cipherCtx.cipherAlgo = IX_CRYPTO_ACC_CIPHER_3DES; - ixp->ixp_ctx.cipherCtx.cipherMode = IX_CRYPTO_ACC_MODE_CBC; - ixp->ixp_ctx.cipherCtx.cipherKeyLen = (cri->cri_klen + 7) / 8; - ixp->ixp_ctx.cipherCtx.cipherBlockLen = IX_CRYPTO_ACC_DES_BLOCK_64; - ixp->ixp_ctx.cipherCtx.cipherInitialVectorLen = - IX_CRYPTO_ACC_DES_IV_64; - memcpy(ixp->ixp_ctx.cipherCtx.key.cipherKey, - cri->cri_key, (cri->cri_klen + 7) / 8); - break; - - case CRYPTO_RIJNDAEL128_CBC: - ixp->ixp_cipher_alg = cri->cri_alg; - ixp->ixp_ctx.cipherCtx.cipherAlgo = IX_CRYPTO_ACC_CIPHER_AES; - ixp->ixp_ctx.cipherCtx.cipherMode = IX_CRYPTO_ACC_MODE_CBC; - ixp->ixp_ctx.cipherCtx.cipherKeyLen = (cri->cri_klen + 7) / 8; - ixp->ixp_ctx.cipherCtx.cipherBlockLen = 16; - ixp->ixp_ctx.cipherCtx.cipherInitialVectorLen = 16; - memcpy(ixp->ixp_ctx.cipherCtx.key.cipherKey, - cri->cri_key, (cri->cri_klen + 7) / 8); - break; - - case CRYPTO_MD5: - case CRYPTO_MD5_HMAC: - ixp->ixp_auth_alg = cri->cri_alg; - ixp->ixp_ctx.authCtx.authAlgo = IX_CRYPTO_ACC_AUTH_MD5; - ixp->ixp_ctx.authCtx.authDigestLen = AUTH_LEN(cri, MD5_HASH_LEN); - ixp->ixp_ctx.authCtx.aadLen = 0; - /* Only MD5_HMAC needs a key */ - if (cri->cri_alg == CRYPTO_MD5_HMAC) { - ixp->ixp_ctx.authCtx.authKeyLen = (cri->cri_klen + 7) / 8; - if (ixp->ixp_ctx.authCtx.authKeyLen > - sizeof(ixp->ixp_ctx.authCtx.key.authKey)) { - printk( - "ixp4xx: Invalid key length for MD5_HMAC - %d bits\n", - cri->cri_klen); - ixp_freesession(NULL, i); - return EINVAL; - } - memcpy(ixp->ixp_ctx.authCtx.key.authKey, - cri->cri_key, (cri->cri_klen + 7) / 8); - } - break; - - case CRYPTO_SHA1: - case CRYPTO_SHA1_HMAC: - ixp->ixp_auth_alg = cri->cri_alg; - ixp->ixp_ctx.authCtx.authAlgo = IX_CRYPTO_ACC_AUTH_SHA1; - ixp->ixp_ctx.authCtx.authDigestLen = AUTH_LEN(cri, SHA1_HASH_LEN); - ixp->ixp_ctx.authCtx.aadLen = 0; - /* Only SHA1_HMAC needs a key */ - if (cri->cri_alg == CRYPTO_SHA1_HMAC) { - ixp->ixp_ctx.authCtx.authKeyLen = (cri->cri_klen + 7) / 8; - if (ixp->ixp_ctx.authCtx.authKeyLen > - sizeof(ixp->ixp_ctx.authCtx.key.authKey)) { - printk( - "ixp4xx: Invalid key length for SHA1_HMAC - %d bits\n", - cri->cri_klen); - ixp_freesession(NULL, i); - return EINVAL; - } - memcpy(ixp->ixp_ctx.authCtx.key.authKey, - cri->cri_key, (cri->cri_klen + 7) / 8); - } - break; - - default: - printk("ixp: unknown algo 0x%x\n", cri->cri_alg); - ixp_freesession(NULL, i); - return EINVAL; - } - cri = cri->cri_next; - } - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) - INIT_WORK(&ixp->ixp_pending_work, ixp_process_pending_wq); - INIT_WORK(&ixp->ixp_registration_work, ixp_registration_wq); -#else - INIT_WORK(&ixp->ixp_pending_work, ixp_process_pending, ixp); - INIT_WORK(&ixp->ixp_registration_work, ixp_registration, ixp); -#endif - - return 0; -} - - -/* - * Free a session. - */ -static int -ixp_freesession(device_t dev, u_int64_t tid) -{ - u_int32_t sid = CRYPTO_SESID2LID(tid); - - dprintk("%s()\n", __FUNCTION__); - if (sid > ixp_sesnum || ixp_sessions == NULL || - ixp_sessions[sid] == NULL) { - dprintk("%s,%d: EINVAL\n", __FILE__, __LINE__); - return EINVAL; - } - - /* Silently accept and return */ - if (sid == 0) - return 0; - - if (ixp_sessions[sid]) { - if (ixp_sessions[sid]->ixp_ctx_id != -1) { - ixCryptoAccCtxUnregister(ixp_sessions[sid]->ixp_ctx_id); - ixp_sessions[sid]->ixp_ctx_id = -1; - } - kfree(ixp_sessions[sid]); - } - ixp_sessions[sid] = NULL; - if (ixp_blocked) { - ixp_blocked = 0; - crypto_unblock(ixp_id, CRYPTO_SYMQ); - } - return 0; -} - - -/* - * callback for when hash processing is complete - */ - -static void -ixp_hash_perform_cb( - UINT32 hash_key_id, - IX_MBUF *bufp, - IxCryptoAccStatus status) -{ - struct ixp_q *q; - - dprintk("%s(%u, %p, 0x%x)\n", __FUNCTION__, hash_key_id, bufp, status); - - if (bufp == NULL) { - printk("ixp: NULL buf in %s\n", __FUNCTION__); - return; - } - - q = IX_MBUF_PRIV(bufp); - if (q == NULL) { - printk("ixp: NULL priv in %s\n", __FUNCTION__); - return; - } - - if (status == IX_CRYPTO_ACC_STATUS_SUCCESS) { - /* On success, need to copy hash back into original client buffer */ - memcpy(q->ixp_hash_dest, q->ixp_hash_src, - (q->ixp_q_data->ixp_auth_alg == CRYPTO_SHA1) ? - SHA1_HASH_LEN : MD5_HASH_LEN); - } - else { - printk("ixp: hash perform failed status=%d\n", status); - q->ixp_q_crp->crp_etype = EINVAL; - } - - /* Free internal buffer used for hashing */ - kfree(IX_MBUF_MDATA(&q->ixp_q_mbuf)); - - crypto_done(q->ixp_q_crp); - kmem_cache_free(qcache, q); -} - -/* - * setup a request and perform it - */ -static void -ixp_q_process(struct ixp_q *q) -{ - IxCryptoAccStatus status; - struct ixp_data *ixp = q->ixp_q_data; - int auth_off = 0; - int auth_len = 0; - int crypt_off = 0; - int crypt_len = 0; - int icv_off = 0; - char *crypt_func; - - dprintk("%s(%p)\n", __FUNCTION__, q); - - if (q->ixp_q_ccrd) { - if (q->ixp_q_ccrd->crd_flags & CRD_F_IV_EXPLICIT) { - q->ixp_q_iv = q->ixp_q_ccrd->crd_iv; - } else { - q->ixp_q_iv = q->ixp_q_iv_data; - crypto_copydata(q->ixp_q_crp->crp_flags, q->ixp_q_crp->crp_buf, - q->ixp_q_ccrd->crd_inject, - ixp->ixp_ctx.cipherCtx.cipherInitialVectorLen, - (caddr_t) q->ixp_q_iv); - } - - if (q->ixp_q_acrd) { - auth_off = q->ixp_q_acrd->crd_skip; - auth_len = q->ixp_q_acrd->crd_len; - icv_off = q->ixp_q_acrd->crd_inject; - } - - crypt_off = q->ixp_q_ccrd->crd_skip; - crypt_len = q->ixp_q_ccrd->crd_len; - } else { /* if (q->ixp_q_acrd) */ - auth_off = q->ixp_q_acrd->crd_skip; - auth_len = q->ixp_q_acrd->crd_len; - icv_off = q->ixp_q_acrd->crd_inject; - } - - if (q->ixp_q_crp->crp_flags & CRYPTO_F_SKBUF) { - struct sk_buff *skb = (struct sk_buff *) q->ixp_q_crp->crp_buf; - if (skb_shinfo(skb)->nr_frags) { - /* - * DAVIDM fix this limitation one day by using - * a buffer pool and chaining, it is not currently - * needed for current user/kernel space acceleration - */ - printk("ixp: Cannot handle fragmented skb's yet !\n"); - q->ixp_q_crp->crp_etype = ENOENT; - goto done; - } - IX_MBUF_MLEN(&q->ixp_q_mbuf) = - IX_MBUF_PKT_LEN(&q->ixp_q_mbuf) = skb->len; - IX_MBUF_MDATA(&q->ixp_q_mbuf) = skb->data; - } else if (q->ixp_q_crp->crp_flags & CRYPTO_F_IOV) { - struct uio *uiop = (struct uio *) q->ixp_q_crp->crp_buf; - if (uiop->uio_iovcnt != 1) { - /* - * DAVIDM fix this limitation one day by using - * a buffer pool and chaining, it is not currently - * needed for current user/kernel space acceleration - */ - printk("ixp: Cannot handle more than 1 iovec yet !\n"); - q->ixp_q_crp->crp_etype = ENOENT; - goto done; - } - IX_MBUF_MLEN(&q->ixp_q_mbuf) = - IX_MBUF_PKT_LEN(&q->ixp_q_mbuf) = uiop->uio_iov[0].iov_len; - IX_MBUF_MDATA(&q->ixp_q_mbuf) = uiop->uio_iov[0].iov_base; - } else /* contig buffer */ { - IX_MBUF_MLEN(&q->ixp_q_mbuf) = - IX_MBUF_PKT_LEN(&q->ixp_q_mbuf) = q->ixp_q_crp->crp_ilen; - IX_MBUF_MDATA(&q->ixp_q_mbuf) = q->ixp_q_crp->crp_buf; - } - - IX_MBUF_PRIV(&q->ixp_q_mbuf) = q; - - if (ixp->ixp_auth_alg == CRYPTO_SHA1 || ixp->ixp_auth_alg == CRYPTO_MD5) { - /* - * For SHA1 and MD5 hash, need to create an internal buffer that is big - * enough to hold the original data + the appropriate padding for the - * hash algorithm. - */ - UINT8 *tbuf = NULL; - - IX_MBUF_MLEN(&q->ixp_q_mbuf) = IX_MBUF_PKT_LEN(&q->ixp_q_mbuf) = - ((IX_MBUF_MLEN(&q->ixp_q_mbuf) * 8) + 72 + 511) / 8; - tbuf = kmalloc(IX_MBUF_MLEN(&q->ixp_q_mbuf), SLAB_ATOMIC); - - if (IX_MBUF_MDATA(&q->ixp_q_mbuf) == NULL) { - printk("ixp: kmalloc(%u, SLAB_ATOMIC) failed\n", - IX_MBUF_MLEN(&q->ixp_q_mbuf)); - q->ixp_q_crp->crp_etype = ENOMEM; - goto done; - } - memcpy(tbuf, &(IX_MBUF_MDATA(&q->ixp_q_mbuf))[auth_off], auth_len); - - /* Set location in client buffer to copy hash into */ - q->ixp_hash_dest = - &(IX_MBUF_MDATA(&q->ixp_q_mbuf))[auth_off + auth_len]; - - IX_MBUF_MDATA(&q->ixp_q_mbuf) = tbuf; - - /* Set location in internal buffer for where hash starts */ - q->ixp_hash_src = &(IX_MBUF_MDATA(&q->ixp_q_mbuf))[auth_len]; - - crypt_func = "ixCryptoAccHashPerform"; - status = ixCryptoAccHashPerform(ixp->ixp_ctx.authCtx.authAlgo, - &q->ixp_q_mbuf, ixp_hash_perform_cb, 0, auth_len, auth_len, - &ixp->ixp_hash_key_id); - } - else { - crypt_func = "ixCryptoAccAuthCryptPerform"; - status = ixCryptoAccAuthCryptPerform(ixp->ixp_ctx_id, &q->ixp_q_mbuf, - NULL, auth_off, auth_len, crypt_off, crypt_len, icv_off, - q->ixp_q_iv); - } - - if (IX_CRYPTO_ACC_STATUS_SUCCESS == status) - return; - - if (IX_CRYPTO_ACC_STATUS_QUEUE_FULL == status) { - q->ixp_q_crp->crp_etype = ENOMEM; - goto done; - } - - printk("ixp: %s failed %u\n", crypt_func, status); - q->ixp_q_crp->crp_etype = EINVAL; - -done: - crypto_done(q->ixp_q_crp); - kmem_cache_free(qcache, q); -} - - -/* - * because we cannot process the Q from the Register callback - * we do it here on a task Q. - */ - -static void -ixp_process_pending(void *arg) -{ - struct ixp_data *ixp = arg; - struct ixp_q *q = NULL; - - dprintk("%s(%p)\n", __FUNCTION__, arg); - - if (!ixp) - return; - - while (!list_empty(&ixp->ixp_q)) { - q = list_entry(ixp->ixp_q.next, struct ixp_q, ixp_q_list); - list_del(&q->ixp_q_list); - ixp_q_process(q); - } -} - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) -static void -ixp_process_pending_wq(struct work_struct *work) -{ - struct ixp_data *ixp = container_of(work, struct ixp_data, ixp_pending_work); - ixp_process_pending(ixp); -} -#endif - -/* - * callback for when context registration is complete - */ - -static void -ixp_register_cb(UINT32 ctx_id, IX_MBUF *bufp, IxCryptoAccStatus status) -{ - int i; - struct ixp_data *ixp; - struct ixp_q *q; - - dprintk("%s(%d, %p, %d)\n", __FUNCTION__, ctx_id, bufp, status); - - /* - * free any buffer passed in to this routine - */ - if (bufp) { - IX_MBUF_MLEN(bufp) = IX_MBUF_PKT_LEN(bufp) = 0; - kfree(IX_MBUF_MDATA(bufp)); - IX_MBUF_MDATA(bufp) = NULL; - } - - for (i = 0; i < ixp_sesnum; i++) { - ixp = ixp_sessions[i]; - if (ixp && ixp->ixp_ctx_id == ctx_id) - break; - } - if (i >= ixp_sesnum) { - printk("ixp: invalid context id %d\n", ctx_id); - return; - } - - if (IX_CRYPTO_ACC_STATUS_WAIT == status) { - /* this is normal to free the first of two buffers */ - dprintk("ixp: register not finished yet.\n"); - return; - } - - if (IX_CRYPTO_ACC_STATUS_SUCCESS != status) { - printk("ixp: register failed 0x%x\n", status); - while (!list_empty(&ixp->ixp_q)) { - q = list_entry(ixp->ixp_q.next, struct ixp_q, ixp_q_list); - list_del(&q->ixp_q_list); - q->ixp_q_crp->crp_etype = EINVAL; - crypto_done(q->ixp_q_crp); - kmem_cache_free(qcache, q); - } - return; - } - - /* - * we are now registered, we cannot start processing the Q here - * or we get strange errors with AES (DES/3DES seem to be ok). - */ - ixp->ixp_registered = 1; - schedule_work(&ixp->ixp_pending_work); -} - - -/* - * callback for when data processing is complete - */ - -static void -ixp_perform_cb( - UINT32 ctx_id, - IX_MBUF *sbufp, - IX_MBUF *dbufp, - IxCryptoAccStatus status) -{ - struct ixp_q *q; - - dprintk("%s(%d, %p, %p, 0x%x)\n", __FUNCTION__, ctx_id, sbufp, - dbufp, status); - - if (sbufp == NULL) { - printk("ixp: NULL sbuf in ixp_perform_cb\n"); - return; - } - - q = IX_MBUF_PRIV(sbufp); - if (q == NULL) { - printk("ixp: NULL priv in ixp_perform_cb\n"); - return; - } - - if (status != IX_CRYPTO_ACC_STATUS_SUCCESS) { - printk("ixp: perform failed status=%d\n", status); - q->ixp_q_crp->crp_etype = EINVAL; - } - - crypto_done(q->ixp_q_crp); - kmem_cache_free(qcache, q); -} - - -/* - * registration is not callable at IRQ time, so we defer - * to a task queue, this routines completes the registration for us - * when the task queue runs - * - * Unfortunately this means we cannot tell OCF that the driver is blocked, - * we do that on the next request. - */ - -static void -ixp_registration(void *arg) -{ - struct ixp_data *ixp = arg; - struct ixp_q *q = NULL; - IX_MBUF *pri = NULL, *sec = NULL; - int status = IX_CRYPTO_ACC_STATUS_SUCCESS; - - if (!ixp) { - printk("ixp: ixp_registration with no arg\n"); - return; - } - - if (ixp->ixp_ctx_id != -1) { - ixCryptoAccCtxUnregister(ixp->ixp_ctx_id); - ixp->ixp_ctx_id = -1; - } - - if (list_empty(&ixp->ixp_q)) { - printk("ixp: ixp_registration with no Q\n"); - return; - } - - /* - * setup the primary and secondary buffers - */ - q = list_entry(ixp->ixp_q.next, struct ixp_q, ixp_q_list); - if (q->ixp_q_acrd) { - pri = &ixp->ixp_pri_mbuf; - sec = &ixp->ixp_sec_mbuf; - IX_MBUF_MLEN(pri) = IX_MBUF_PKT_LEN(pri) = 128; - IX_MBUF_MDATA(pri) = (unsigned char *) kmalloc(128, SLAB_ATOMIC); - IX_MBUF_MLEN(sec) = IX_MBUF_PKT_LEN(sec) = 128; - IX_MBUF_MDATA(sec) = (unsigned char *) kmalloc(128, SLAB_ATOMIC); - } - - /* Only need to register if a crypt op or HMAC op */ - if (!(ixp->ixp_auth_alg == CRYPTO_SHA1 || - ixp->ixp_auth_alg == CRYPTO_MD5)) { - status = ixCryptoAccCtxRegister( - &ixp->ixp_ctx, - pri, sec, - ixp_register_cb, - ixp_perform_cb, - &ixp->ixp_ctx_id); - } - else { - /* Otherwise we start processing pending q */ - schedule_work(&ixp->ixp_pending_work); - } - - if (IX_CRYPTO_ACC_STATUS_SUCCESS == status) - return; - - if (IX_CRYPTO_ACC_STATUS_EXCEED_MAX_TUNNELS == status) { - printk("ixp: ixCryptoAccCtxRegister failed (out of tunnels)\n"); - ixp_blocked = 1; - /* perhaps we should return EGAIN on queued ops ? */ - return; - } - - printk("ixp: ixCryptoAccCtxRegister failed %d\n", status); - ixp->ixp_ctx_id = -1; - - /* - * everything waiting is toasted - */ - while (!list_empty(&ixp->ixp_q)) { - q = list_entry(ixp->ixp_q.next, struct ixp_q, ixp_q_list); - list_del(&q->ixp_q_list); - q->ixp_q_crp->crp_etype = ENOENT; - crypto_done(q->ixp_q_crp); - kmem_cache_free(qcache, q); - } -} - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) -static void -ixp_registration_wq(struct work_struct *work) -{ - struct ixp_data *ixp = container_of(work, struct ixp_data, - ixp_registration_work); - ixp_registration(ixp); -} -#endif - -/* - * Process a request. - */ -static int -ixp_process(device_t dev, struct cryptop *crp, int hint) -{ - struct ixp_data *ixp; - unsigned int lid; - struct ixp_q *q = NULL; - int status; - - dprintk("%s()\n", __FUNCTION__); - - /* Sanity check */ - if (crp == NULL) { - dprintk("%s,%d: EINVAL\n", __FILE__, __LINE__); - return EINVAL; - } - - crp->crp_etype = 0; - - if (ixp_blocked) - return ERESTART; - - if (crp->crp_desc == NULL || crp->crp_buf == NULL) { - dprintk("%s,%d: EINVAL\n", __FILE__, __LINE__); - crp->crp_etype = EINVAL; - goto done; - } - - /* - * find the session we are using - */ - - lid = crp->crp_sid & 0xffffffff; - if (lid >= ixp_sesnum || lid == 0 || ixp_sessions == NULL || - ixp_sessions[lid] == NULL) { - crp->crp_etype = ENOENT; - dprintk("%s,%d: ENOENT\n", __FILE__, __LINE__); - goto done; - } - ixp = ixp_sessions[lid]; - - /* - * setup a new request ready for queuing - */ - q = kmem_cache_alloc(qcache, SLAB_ATOMIC); - if (q == NULL) { - dprintk("%s,%d: ENOMEM\n", __FILE__, __LINE__); - crp->crp_etype = ENOMEM; - goto done; - } - /* - * save some cycles by only zeroing the important bits - */ - memset(&q->ixp_q_mbuf, 0, sizeof(q->ixp_q_mbuf)); - q->ixp_q_ccrd = NULL; - q->ixp_q_acrd = NULL; - q->ixp_q_crp = crp; - q->ixp_q_data = ixp; - - /* - * point the cipher and auth descriptors appropriately - * check that we have something to do - */ - if (crp->crp_desc->crd_alg == ixp->ixp_cipher_alg) - q->ixp_q_ccrd = crp->crp_desc; - else if (crp->crp_desc->crd_alg == ixp->ixp_auth_alg) - q->ixp_q_acrd = crp->crp_desc; - else { - crp->crp_etype = ENOENT; - dprintk("%s,%d: bad desc match: ENOENT\n", __FILE__, __LINE__); - goto done; - } - if (crp->crp_desc->crd_next) { - if (crp->crp_desc->crd_next->crd_alg == ixp->ixp_cipher_alg) - q->ixp_q_ccrd = crp->crp_desc->crd_next; - else if (crp->crp_desc->crd_next->crd_alg == ixp->ixp_auth_alg) - q->ixp_q_acrd = crp->crp_desc->crd_next; - else { - crp->crp_etype = ENOENT; - dprintk("%s,%d: bad desc match: ENOENT\n", __FILE__, __LINE__); - goto done; - } - } - - /* - * If there is a direction change for this context then we mark it as - * unregistered and re-register is for the new direction. This is not - * a very expensive operation and currently only tends to happen when - * user-space application are doing benchmarks - * - * DM - we should be checking for pending requests before unregistering. - */ - if (q->ixp_q_ccrd && ixp->ixp_registered && - ixp->ixp_crd_flags != (q->ixp_q_ccrd->crd_flags & CRD_F_ENCRYPT)) { - dprintk("%s - detected direction change on session\n", __FUNCTION__); - ixp->ixp_registered = 0; - } - - /* - * if we are registered, call straight into the perform code - */ - if (ixp->ixp_registered) { - ixp_q_process(q); - return 0; - } - - /* - * the only part of the context not set in newsession is the direction - * dependent parts - */ - if (q->ixp_q_ccrd) { - ixp->ixp_crd_flags = (q->ixp_q_ccrd->crd_flags & CRD_F_ENCRYPT); - if (q->ixp_q_ccrd->crd_flags & CRD_F_ENCRYPT) { - ixp->ixp_ctx.operation = q->ixp_q_acrd ? - IX_CRYPTO_ACC_OP_ENCRYPT_AUTH : IX_CRYPTO_ACC_OP_ENCRYPT; - } else { - ixp->ixp_ctx.operation = q->ixp_q_acrd ? - IX_CRYPTO_ACC_OP_AUTH_DECRYPT : IX_CRYPTO_ACC_OP_DECRYPT; - } - } else { - /* q->ixp_q_acrd must be set if we are here */ - ixp->ixp_ctx.operation = IX_CRYPTO_ACC_OP_AUTH_CALC; - } - - status = list_empty(&ixp->ixp_q); - list_add_tail(&q->ixp_q_list, &ixp->ixp_q); - if (status) - schedule_work(&ixp->ixp_registration_work); - return 0; - -done: - if (q) - kmem_cache_free(qcache, q); - crypto_done(crp); - return 0; -} - - -#ifdef __ixp46X -/* - * key processing support for the ixp465 - */ - - -/* - * copy a BN (LE) into a buffer (BE) an fill out the op appropriately - * assume zeroed and only copy bits that are significant - */ - -static int -ixp_copy_ibuf(struct crparam *p, IxCryptoAccPkeEauOperand *op, UINT32 *buf) -{ - unsigned char *src = (unsigned char *) p->crp_p; - unsigned char *dst; - int len, bits = p->crp_nbits; - - dprintk("%s()\n", __FUNCTION__); - - if (bits > MAX_IOP_SIZE * sizeof(UINT32) * 8) { - dprintk("%s - ibuf too big (%d > %d)\n", __FUNCTION__, - bits, MAX_IOP_SIZE * sizeof(UINT32) * 8); - return -1; - } - - len = (bits + 31) / 32; /* the number UINT32's needed */ - - dst = (unsigned char *) &buf[len]; - dst--; - - while (bits > 0) { - *dst-- = *src++; - bits -= 8; - } - -#if 0 /* no need to zero remaining bits as it is done during request alloc */ - while (dst > (unsigned char *) buf) - *dst-- = '\0'; -#endif - - op->pData = buf; - op->dataLen = len; - return 0; -} - -/* - * copy out the result, be as forgiving as we can about small output buffers - */ - -static int -ixp_copy_obuf(struct crparam *p, IxCryptoAccPkeEauOpResult *op, UINT32 *buf) -{ - unsigned char *dst = (unsigned char *) p->crp_p; - unsigned char *src = (unsigned char *) buf; - int len, z, bits = p->crp_nbits; - - dprintk("%s()\n", __FUNCTION__); - - len = op->dataLen * sizeof(UINT32); - - /* skip leading zeroes to be small buffer friendly */ - z = 0; - while (z < len && src[z] == '\0') - z++; - - src += len; - src--; - len -= z; - - while (len > 0 && bits > 0) { - *dst++ = *src--; - len--; - bits -= 8; - } - - while (bits > 0) { - *dst++ = '\0'; - bits -= 8; - } - - if (len > 0) { - dprintk("%s - obuf is %d (z=%d, ob=%d) bytes too small\n", - __FUNCTION__, len, z, p->crp_nbits / 8); - return -1; - } - - return 0; -} - - -/* - * the parameter offsets for exp_mod - */ - -#define IXP_PARAM_BASE 0 -#define IXP_PARAM_EXP 1 -#define IXP_PARAM_MOD 2 -#define IXP_PARAM_RES 3 - -/* - * key processing complete callback, is also used to start processing - * by passing a NULL for pResult - */ - -static void -ixp_kperform_cb( - IxCryptoAccPkeEauOperation operation, - IxCryptoAccPkeEauOpResult *pResult, - BOOL carryOrBorrow, - IxCryptoAccStatus status) -{ - struct ixp_pkq *q, *tmp; - unsigned long flags; - - dprintk("%s(0x%x, %p, %d, 0x%x)\n", __FUNCTION__, operation, pResult, - carryOrBorrow, status); - - /* handle a completed request */ - if (pResult) { - if (ixp_pk_cur && &ixp_pk_cur->pkq_result == pResult) { - q = ixp_pk_cur; - if (status != IX_CRYPTO_ACC_STATUS_SUCCESS) { - dprintk("%s() - op failed 0x%x\n", __FUNCTION__, status); - q->pkq_krp->krp_status = ERANGE; /* could do better */ - } else { - /* copy out the result */ - if (ixp_copy_obuf(&q->pkq_krp->krp_param[IXP_PARAM_RES], - &q->pkq_result, q->pkq_obuf)) - q->pkq_krp->krp_status = ERANGE; - } - crypto_kdone(q->pkq_krp); - kfree(q); - ixp_pk_cur = NULL; - } else - printk("%s - callback with invalid result pointer\n", __FUNCTION__); - } - - spin_lock_irqsave(&ixp_pkq_lock, flags); - if (ixp_pk_cur || list_empty(&ixp_pkq)) { - spin_unlock_irqrestore(&ixp_pkq_lock, flags); - return; - } - - list_for_each_entry_safe(q, tmp, &ixp_pkq, pkq_list) { - - list_del(&q->pkq_list); - ixp_pk_cur = q; - - spin_unlock_irqrestore(&ixp_pkq_lock, flags); - - status = ixCryptoAccPkeEauPerform( - IX_CRYPTO_ACC_OP_EAU_MOD_EXP, - &q->pkq_op, - ixp_kperform_cb, - &q->pkq_result); - - if (status == IX_CRYPTO_ACC_STATUS_SUCCESS) { - dprintk("%s() - ixCryptoAccPkeEauPerform SUCCESS\n", __FUNCTION__); - return; /* callback will return here for callback */ - } else if (status == IX_CRYPTO_ACC_STATUS_RETRY) { - printk("%s() - ixCryptoAccPkeEauPerform RETRY\n", __FUNCTION__); - } else { - printk("%s() - ixCryptoAccPkeEauPerform failed %d\n", - __FUNCTION__, status); - } - q->pkq_krp->krp_status = ERANGE; /* could do better */ - crypto_kdone(q->pkq_krp); - kfree(q); - spin_lock_irqsave(&ixp_pkq_lock, flags); - } - spin_unlock_irqrestore(&ixp_pkq_lock, flags); -} - - -static int -ixp_kprocess(device_t dev, struct cryptkop *krp, int hint) -{ - struct ixp_pkq *q; - int rc = 0; - unsigned long flags; - - dprintk("%s l1=%d l2=%d l3=%d l4=%d\n", __FUNCTION__, - krp->krp_param[IXP_PARAM_BASE].crp_nbits, - krp->krp_param[IXP_PARAM_EXP].crp_nbits, - krp->krp_param[IXP_PARAM_MOD].crp_nbits, - krp->krp_param[IXP_PARAM_RES].crp_nbits); - - - if (krp->krp_op != CRK_MOD_EXP) { - krp->krp_status = EOPNOTSUPP; - goto err; - } - - q = (struct ixp_pkq *) kmalloc(sizeof(*q), GFP_KERNEL); - if (q == NULL) { - krp->krp_status = ENOMEM; - goto err; - } - - /* - * The PKE engine does not appear to zero the output buffer - * appropriately, so we need to do it all here. - */ - memset(q, 0, sizeof(*q)); - - q->pkq_krp = krp; - INIT_LIST_HEAD(&q->pkq_list); - - if (ixp_copy_ibuf(&krp->krp_param[IXP_PARAM_BASE], &q->pkq_op.modExpOpr.M, - q->pkq_ibuf0)) - rc = 1; - if (!rc && ixp_copy_ibuf(&krp->krp_param[IXP_PARAM_EXP], - &q->pkq_op.modExpOpr.e, q->pkq_ibuf1)) - rc = 2; - if (!rc && ixp_copy_ibuf(&krp->krp_param[IXP_PARAM_MOD], - &q->pkq_op.modExpOpr.N, q->pkq_ibuf2)) - rc = 3; - - if (rc) { - kfree(q); - krp->krp_status = ERANGE; - goto err; - } - - q->pkq_result.pData = q->pkq_obuf; - q->pkq_result.dataLen = - (krp->krp_param[IXP_PARAM_RES].crp_nbits + 31) / 32; - - spin_lock_irqsave(&ixp_pkq_lock, flags); - list_add_tail(&q->pkq_list, &ixp_pkq); - spin_unlock_irqrestore(&ixp_pkq_lock, flags); - - if (!ixp_pk_cur) - ixp_kperform_cb(0, NULL, 0, 0); - return (0); - -err: - crypto_kdone(krp); - return (0); -} - - - -#ifdef CONFIG_OCF_RANDOMHARVEST -/* - * We run the random number generator output through SHA so that it - * is FIPS compliant. - */ - -static volatile int sha_done = 0; -static unsigned char sha_digest[20]; - -static void -ixp_hash_cb(UINT8 *digest, IxCryptoAccStatus status) -{ - dprintk("%s(%p, %d)\n", __FUNCTION__, digest, status); - if (sha_digest != digest) - printk("digest error\n"); - if (IX_CRYPTO_ACC_STATUS_SUCCESS == status) - sha_done = 1; - else - sha_done = -status; -} - -static int -ixp_read_random(void *arg, u_int32_t *buf, int maxwords) -{ - IxCryptoAccStatus status; - int i, n, rc; - - dprintk("%s(%p, %d)\n", __FUNCTION__, buf, maxwords); - memset(buf, 0, maxwords * sizeof(*buf)); - status = ixCryptoAccPkePseudoRandomNumberGet(maxwords, buf); - if (status != IX_CRYPTO_ACC_STATUS_SUCCESS) { - dprintk("%s: ixCryptoAccPkePseudoRandomNumberGet failed %d\n", - __FUNCTION__, status); - return 0; - } - - /* - * run the random data through SHA to make it look more random - */ - - n = sizeof(sha_digest); /* process digest bytes at a time */ - - rc = 0; - for (i = 0; i < maxwords; i += n / sizeof(*buf)) { - if ((maxwords - i) * sizeof(*buf) < n) - n = (maxwords - i) * sizeof(*buf); - sha_done = 0; - status = ixCryptoAccPkeHashPerform(IX_CRYPTO_ACC_AUTH_SHA1, - (UINT8 *) &buf[i], n, ixp_hash_cb, sha_digest); - if (status != IX_CRYPTO_ACC_STATUS_SUCCESS) { - dprintk("ixCryptoAccPkeHashPerform failed %d\n", status); - return -EIO; - } - while (!sha_done) - schedule(); - if (sha_done < 0) { - dprintk("ixCryptoAccPkeHashPerform failed CB %d\n", -sha_done); - return 0; - } - memcpy(&buf[i], sha_digest, n); - rc += n / sizeof(*buf);; - } - - return rc; -} -#endif /* CONFIG_OCF_RANDOMHARVEST */ - -#endif /* __ixp46X */ - - - -/* - * our driver startup and shutdown routines - */ - -static int -ixp_init(void) -{ - dprintk("%s(%p)\n", __FUNCTION__, ixp_init); - - if (ixp_init_crypto && ixCryptoAccInit() != IX_CRYPTO_ACC_STATUS_SUCCESS) - printk("ixCryptoAccInit failed, assuming already initialised!\n"); - - qcache = kmem_cache_create("ixp4xx_q", sizeof(struct ixp_q), 0, - SLAB_HWCACHE_ALIGN, NULL -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23) - , NULL -#endif - ); - if (!qcache) { - printk("failed to create Qcache\n"); - return -ENOENT; - } - - memset(&ixpdev, 0, sizeof(ixpdev)); - softc_device_init(&ixpdev, "ixp4xx", 0, ixp_methods); - - ixp_id = crypto_get_driverid(softc_get_device(&ixpdev), - CRYPTOCAP_F_HARDWARE); - if (ixp_id < 0) - panic("IXP/OCF crypto device cannot initialize!"); - -#define REGISTER(alg) \ - crypto_register(ixp_id,alg,0,0) - - REGISTER(CRYPTO_DES_CBC); - REGISTER(CRYPTO_3DES_CBC); - REGISTER(CRYPTO_RIJNDAEL128_CBC); -#ifdef CONFIG_OCF_IXP4XX_SHA1_MD5 - REGISTER(CRYPTO_MD5); - REGISTER(CRYPTO_SHA1); -#endif - REGISTER(CRYPTO_MD5_HMAC); - REGISTER(CRYPTO_SHA1_HMAC); -#undef REGISTER - -#ifdef __ixp46X - spin_lock_init(&ixp_pkq_lock); - /* - * we do not enable the go fast options here as they can potentially - * allow timing based attacks - * - * http://www.openssl.org/news/secadv_20030219.txt - */ - ixCryptoAccPkeEauExpConfig(0, 0); - crypto_kregister(ixp_id, CRK_MOD_EXP, 0); -#ifdef CONFIG_OCF_RANDOMHARVEST - crypto_rregister(ixp_id, ixp_read_random, NULL); -#endif -#endif - - return 0; -} - -static void -ixp_exit(void) -{ - dprintk("%s()\n", __FUNCTION__); - crypto_unregister_all(ixp_id); - ixp_id = -1; - kmem_cache_destroy(qcache); - qcache = NULL; -} - -module_init(ixp_init); -module_exit(ixp_exit); - -MODULE_LICENSE("Dual BSD/GPL"); -MODULE_AUTHOR("David McCullough <dmccullough@cyberguard.com>"); -MODULE_DESCRIPTION("ixp (OCF module for IXP4xx crypto)"); diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/Makefile b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/Makefile deleted file mode 100644 index 6dafd00..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# for SGlinux builds --include $(ROOTDIR)/modules/.config - -obj-$(CONFIG_OCF_KIRKWOOD) += mv_cesa.o - -mv_cesa-y := cesa/mvCesa.o cesa/mvLru.o cesa/mvMD5.o cesa/mvSHA1.o cesa/AES/mvAesAlg.o cesa/AES/mvAesApi.o cesa/mvCesaDebug.o cesa_ocf_drv.o - -# Extra objects required by the CESA driver -mv_cesa-y += mvHal/kw_family/ctrlEnv/mvCtrlEnvLib.o mvHal/kw_family/boardEnv/mvBoardEnvLib.o mvHal/mv_hal/twsi/mvTwsi.o mvHal/kw_family/ctrlEnv/sys/mvCpuIf.o mvHal/kw_family/ctrlEnv/sys/mvAhbToMbus.o mvHal/kw_family/ctrlEnv/sys/mvSysDram.o mvHal/linux_oss/mvOs.o mvHal/kw_family/ctrlEnv/mvCtrlEnvAddrDec.o mvHal/mv_hal/gpp/mvGpp.o mvHal/kw_family/ctrlEnv/sys/mvSysPex.o mvHal/mv_hal/pex/mvPex.o mvHal/kw_family/boardEnv/mvBoardEnvSpec.o mvHal/common/mvCommon.o mvHal/common/mvDebug.o mvHal/kw_family/ctrlEnv/sys/mvSysCesa.o - -ifdef src -EXTRA_CFLAGS += -I$(src)/.. -I$(src)/cesa -I$(src)/mvHal -I$(src)/mvHal/common -I$(src)/mvHal/kw_family -I$(src)/mvHal/mv_hal -I$(src)/mvHal/linux_oss -I$(src) -endif - -EXTRA_CFLAGS += -DMV_LINUX -DMV_CPU_LE -DMV_ARM -DMV_INCLUDE_CESA -DMV_INCLUDE_PEX -DMV_CACHE_COHERENCY=3 -ifdef TOPDIR --include $(TOPDIR)/Rules.make -endif - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/AES/mvAes.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/AES/mvAes.h deleted file mode 100644 index 07a8601..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/AES/mvAes.h +++ /dev/null @@ -1,62 +0,0 @@ -/* mvAes.h v2.0 August '99 - * Reference ANSI C code - */ - -/* AES Cipher header file for ANSI C Submissions - Lawrence E. Bassham III - Computer Security Division - National Institute of Standards and Technology - - April 15, 1998 - - This sample is to assist implementers developing to the Cryptographic -API Profile for AES Candidate Algorithm Submissions. Please consult this -document as a cross-reference. - - ANY CHANGES, WHERE APPROPRIATE, TO INFORMATION PROVIDED IN THIS FILE -MUST BE DOCUMENTED. CHANGES ARE ONLY APPROPRIATE WHERE SPECIFIED WITH -THE STRING "CHANGE POSSIBLE". FUNCTION CALLS AND THEIR PARAMETERS CANNOT -BE CHANGED. STRUCTURES CAN BE ALTERED TO ALLOW IMPLEMENTERS TO INCLUDE -IMPLEMENTATION SPECIFIC INFORMATION. -*/ - -/* Includes: - Standard include files -*/ - -#include "mvOs.h" - - -/* Error Codes - CHANGE POSSIBLE: inclusion of additional error codes */ - -/* Key direction is invalid, e.g., unknown value */ -#define AES_BAD_KEY_DIR -1 - -/* Key material not of correct length */ -#define AES_BAD_KEY_MAT -2 - -/* Key passed is not valid */ -#define AES_BAD_KEY_INSTANCE -3 - -/* Params struct passed to cipherInit invalid */ -#define AES_BAD_CIPHER_MODE -4 - -/* Cipher in wrong state (e.g., not initialized) */ -#define AES_BAD_CIPHER_STATE -5 - -#define AES_BAD_CIPHER_INSTANCE -7 - - -/* Function protoypes */ -/* CHANGED: makeKey(): parameter blockLen added - this parameter is absolutely necessary if you want to - setup the round keys in a variable block length setting - cipherInit(): parameter blockLen added (for obvious reasons) - */ -int aesMakeKey(MV_U8 *expandedKey, MV_U8 *keyMaterial, int keyLen, int blockLen); -int aesBlockEncrypt128(MV_U8 mode, MV_U8 *IV, MV_U8 *expandedKey, int keyLen, - MV_U32 *plain, int numBlocks, MV_U32 *cipher); -int aesBlockDecrypt128(MV_U8 mode, MV_U8 *IV, MV_U8 *expandedKey, int keyLen, - MV_U32 *plain, int numBlocks, MV_U32 *cipher); - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/AES/mvAesAlg.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/AES/mvAesAlg.c deleted file mode 100644 index a65dc28..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/AES/mvAesAlg.c +++ /dev/null @@ -1,317 +0,0 @@ -/* rijndael-alg-ref.c v2.0 August '99 - * Reference ANSI C code - * authors: Paulo Barreto - * Vincent Rijmen, K.U.Leuven - * - * This code is placed in the public domain. - */ - -#include "mvOs.h" - -#include "mvAesAlg.h" - -#include "mvAesBoxes.dat" - - -MV_U8 mul1(MV_U8 aa, MV_U8 bb); -void KeyAddition(MV_U8 a[4][MAXBC], MV_U8 rk[4][MAXBC], MV_U8 BC); -void ShiftRow128Enc(MV_U8 a[4][MAXBC]); -void ShiftRow128Dec(MV_U8 a[4][MAXBC]); -void Substitution(MV_U8 a[4][MAXBC], MV_U8 box[256]); -void MixColumn(MV_U8 a[4][MAXBC], MV_U8 rk[4][MAXBC]); -void InvMixColumn(MV_U8 a[4][MAXBC]); - - -#define mul(aa, bb) (mask[bb] & Alogtable[aa + Logtable[bb]]) - -MV_U8 mul1(MV_U8 aa, MV_U8 bb) -{ - return mask[bb] & Alogtable[aa + Logtable[bb]]; -} - - -void KeyAddition(MV_U8 a[4][MAXBC], MV_U8 rk[4][MAXBC], MV_U8 BC) -{ - /* Exor corresponding text input and round key input bytes - */ - ((MV_U32*)(&(a[0][0])))[0] ^= ((MV_U32*)(&(rk[0][0])))[0]; - ((MV_U32*)(&(a[1][0])))[0] ^= ((MV_U32*)(&(rk[1][0])))[0]; - ((MV_U32*)(&(a[2][0])))[0] ^= ((MV_U32*)(&(rk[2][0])))[0]; - ((MV_U32*)(&(a[3][0])))[0] ^= ((MV_U32*)(&(rk[3][0])))[0]; - -} - -void ShiftRow128Enc(MV_U8 a[4][MAXBC]) { - /* Row 0 remains unchanged - * The other three rows are shifted a variable amount - */ - MV_U8 tmp[MAXBC]; - - tmp[0] = a[1][1]; - tmp[1] = a[1][2]; - tmp[2] = a[1][3]; - tmp[3] = a[1][0]; - - ((MV_U32*)(&(a[1][0])))[0] = ((MV_U32*)(&(tmp[0])))[0]; - /* - a[1][0] = tmp[0]; - a[1][1] = tmp[1]; - a[1][2] = tmp[2]; - a[1][3] = tmp[3]; - */ - tmp[0] = a[2][2]; - tmp[1] = a[2][3]; - tmp[2] = a[2][0]; - tmp[3] = a[2][1]; - - ((MV_U32*)(&(a[2][0])))[0] = ((MV_U32*)(&(tmp[0])))[0]; - /* - a[2][0] = tmp[0]; - a[2][1] = tmp[1]; - a[2][2] = tmp[2]; - a[2][3] = tmp[3]; - */ - tmp[0] = a[3][3]; - tmp[1] = a[3][0]; - tmp[2] = a[3][1]; - tmp[3] = a[3][2]; - - ((MV_U32*)(&(a[3][0])))[0] = ((MV_U32*)(&(tmp[0])))[0]; - /* - a[3][0] = tmp[0]; - a[3][1] = tmp[1]; - a[3][2] = tmp[2]; - a[3][3] = tmp[3]; - */ -} - -void ShiftRow128Dec(MV_U8 a[4][MAXBC]) { - /* Row 0 remains unchanged - * The other three rows are shifted a variable amount - */ - MV_U8 tmp[MAXBC]; - - tmp[0] = a[1][3]; - tmp[1] = a[1][0]; - tmp[2] = a[1][1]; - tmp[3] = a[1][2]; - - ((MV_U32*)(&(a[1][0])))[0] = ((MV_U32*)(&(tmp[0])))[0]; - /* - a[1][0] = tmp[0]; - a[1][1] = tmp[1]; - a[1][2] = tmp[2]; - a[1][3] = tmp[3]; - */ - - tmp[0] = a[2][2]; - tmp[1] = a[2][3]; - tmp[2] = a[2][0]; - tmp[3] = a[2][1]; - - ((MV_U32*)(&(a[2][0])))[0] = ((MV_U32*)(&(tmp[0])))[0]; - /* - a[2][0] = tmp[0]; - a[2][1] = tmp[1]; - a[2][2] = tmp[2]; - a[2][3] = tmp[3]; - */ - - tmp[0] = a[3][1]; - tmp[1] = a[3][2]; - tmp[2] = a[3][3]; - tmp[3] = a[3][0]; - - ((MV_U32*)(&(a[3][0])))[0] = ((MV_U32*)(&(tmp[0])))[0]; - /* - a[3][0] = tmp[0]; - a[3][1] = tmp[1]; - a[3][2] = tmp[2]; - a[3][3] = tmp[3]; - */ -} - -void Substitution(MV_U8 a[4][MAXBC], MV_U8 box[256]) { - /* Replace every byte of the input by the byte at that place - * in the nonlinear S-box - */ - int i, j; - - for(i = 0; i < 4; i++) - for(j = 0; j < 4; j++) a[i][j] = box[a[i][j]] ; -} - -void MixColumn(MV_U8 a[4][MAXBC], MV_U8 rk[4][MAXBC]) { - /* Mix the four bytes of every column in a linear way - */ - MV_U8 b[4][MAXBC]; - int i, j; - - for(j = 0; j < 4; j++){ - b[0][j] = mul(25,a[0][j]) ^ mul(1,a[1][j]) ^ a[2][j] ^ a[3][j]; - b[1][j] = mul(25,a[1][j]) ^ mul(1,a[2][j]) ^ a[3][j] ^ a[0][j]; - b[2][j] = mul(25,a[2][j]) ^ mul(1,a[3][j]) ^ a[0][j] ^ a[1][j]; - b[3][j] = mul(25,a[3][j]) ^ mul(1,a[0][j]) ^ a[1][j] ^ a[2][j]; - } - for(i = 0; i < 4; i++) - /*for(j = 0; j < BC; j++) a[i][j] = b[i][j];*/ - ((MV_U32*)(&(a[i][0])))[0] = ((MV_U32*)(&(b[i][0])))[0] ^ ((MV_U32*)(&(rk[i][0])))[0];; -} - -void InvMixColumn(MV_U8 a[4][MAXBC]) { - /* Mix the four bytes of every column in a linear way - * This is the opposite operation of Mixcolumn - */ - MV_U8 b[4][MAXBC]; - int i, j; - - for(j = 0; j < 4; j++){ - b[0][j] = mul(223,a[0][j]) ^ mul(104,a[1][j]) ^ mul(238,a[2][j]) ^ mul(199,a[3][j]); - b[1][j] = mul(223,a[1][j]) ^ mul(104,a[2][j]) ^ mul(238,a[3][j]) ^ mul(199,a[0][j]); - b[2][j] = mul(223,a[2][j]) ^ mul(104,a[3][j]) ^ mul(238,a[0][j]) ^ mul(199,a[1][j]); - b[3][j] = mul(223,a[3][j]) ^ mul(104,a[0][j]) ^ mul(238,a[1][j]) ^ mul(199,a[2][j]); - } - for(i = 0; i < 4; i++) - /*for(j = 0; j < BC; j++) a[i][j] = b[i][j];*/ - ((MV_U32*)(&(a[i][0])))[0] = ((MV_U32*)(&(b[i][0])))[0]; -} - -int rijndaelKeySched (MV_U8 k[4][MAXKC], int keyBits, int blockBits, MV_U8 W[MAXROUNDS+1][4][MAXBC]) -{ - /* Calculate the necessary round keys - * The number of calculations depends on keyBits and blockBits - */ - int KC, BC, ROUNDS; - int i, j, t, rconpointer = 0; - MV_U8 tk[4][MAXKC]; - - switch (keyBits) { - case 128: KC = 4; break; - case 192: KC = 6; break; - case 256: KC = 8; break; - default : return (-1); - } - - switch (blockBits) { - case 128: BC = 4; break; - case 192: BC = 6; break; - case 256: BC = 8; break; - default : return (-2); - } - - switch (keyBits >= blockBits ? keyBits : blockBits) { - case 128: ROUNDS = 10; break; - case 192: ROUNDS = 12; break; - case 256: ROUNDS = 14; break; - default : return (-3); /* this cannot happen */ - } - - - for(j = 0; j < KC; j++) - for(i = 0; i < 4; i++) - tk[i][j] = k[i][j]; - t = 0; - /* copy values into round key array */ - for(j = 0; (j < KC) && (t < (ROUNDS+1)*BC); j++, t++) - for(i = 0; i < 4; i++) W[t / BC][i][t % BC] = tk[i][j]; - - while (t < (ROUNDS+1)*BC) { /* while not enough round key material calculated */ - /* calculate new values */ - for(i = 0; i < 4; i++) - tk[i][0] ^= S[tk[(i+1)%4][KC-1]]; - tk[0][0] ^= rcon[rconpointer++]; - - if (KC != 8) - for(j = 1; j < KC; j++) - for(i = 0; i < 4; i++) tk[i][j] ^= tk[i][j-1]; - else { - for(j = 1; j < KC/2; j++) - for(i = 0; i < 4; i++) tk[i][j] ^= tk[i][j-1]; - for(i = 0; i < 4; i++) tk[i][KC/2] ^= S[tk[i][KC/2 - 1]]; - for(j = KC/2 + 1; j < KC; j++) - for(i = 0; i < 4; i++) tk[i][j] ^= tk[i][j-1]; - } - /* copy values into round key array */ - for(j = 0; (j < KC) && (t < (ROUNDS+1)*BC); j++, t++) - for(i = 0; i < 4; i++) W[t / BC][i][t % BC] = tk[i][j]; - } - - return 0; -} - - - -int rijndaelEncrypt128(MV_U8 a[4][MAXBC], MV_U8 rk[MAXROUNDS+1][4][MAXBC], int rounds) -{ - /* Encryption of one block. - */ - int r, BC, ROUNDS; - - BC = 4; - ROUNDS = rounds; - - /* begin with a key addition - */ - - KeyAddition(a,rk[0],BC); - - /* ROUNDS-1 ordinary rounds - */ - for(r = 1; r < ROUNDS; r++) { - Substitution(a,S); - ShiftRow128Enc(a); - MixColumn(a, rk[r]); - /*KeyAddition(a,rk[r],BC);*/ - } - - /* Last round is special: there is no MixColumn - */ - Substitution(a,S); - ShiftRow128Enc(a); - KeyAddition(a,rk[ROUNDS],BC); - - return 0; -} - - -int rijndaelDecrypt128(MV_U8 a[4][MAXBC], MV_U8 rk[MAXROUNDS+1][4][MAXBC], int rounds) -{ - int r, BC, ROUNDS; - - BC = 4; - ROUNDS = rounds; - - /* To decrypt: apply the inverse operations of the encrypt routine, - * in opposite order - * - * (KeyAddition is an involution: it 's equal to its inverse) - * (the inverse of Substitution with table S is Substitution with the inverse table of S) - * (the inverse of Shiftrow is Shiftrow over a suitable distance) - */ - - /* First the special round: - * without InvMixColumn - * with extra KeyAddition - */ - KeyAddition(a,rk[ROUNDS],BC); - ShiftRow128Dec(a); - Substitution(a,Si); - - /* ROUNDS-1 ordinary rounds - */ - for(r = ROUNDS-1; r > 0; r--) { - KeyAddition(a,rk[r],BC); - InvMixColumn(a); - ShiftRow128Dec(a); - Substitution(a,Si); - - } - - /* End with the extra key addition - */ - - KeyAddition(a,rk[0],BC); - - return 0; -} - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/AES/mvAesAlg.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/AES/mvAesAlg.h deleted file mode 100644 index ec81e40..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/AES/mvAesAlg.h +++ /dev/null @@ -1,19 +0,0 @@ -/* rijndael-alg-ref.h v2.0 August '99 - * Reference ANSI C code - * authors: Paulo Barreto - * Vincent Rijmen, K.U.Leuven - */ -#ifndef __RIJNDAEL_ALG_H -#define __RIJNDAEL_ALG_H - -#define MAXBC (128/32) -#define MAXKC (256/32) -#define MAXROUNDS 14 - - -int rijndaelKeySched (MV_U8 k[4][MAXKC], int keyBits, int blockBits, MV_U8 rk[MAXROUNDS+1][4][MAXBC]); - -int rijndaelEncrypt128(MV_U8 a[4][MAXBC], MV_U8 rk[MAXROUNDS+1][4][MAXBC], int rounds); -int rijndaelDecrypt128(MV_U8 a[4][MAXBC], MV_U8 rk[MAXROUNDS+1][4][MAXBC], int rounds); - -#endif /* __RIJNDAEL_ALG_H */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/AES/mvAesApi.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/AES/mvAesApi.c deleted file mode 100644 index b432dc6..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/AES/mvAesApi.c +++ /dev/null @@ -1,312 +0,0 @@ -/* rijndael-api-ref.c v2.1 April 2000 - * Reference ANSI C code - * authors: v2.0 Paulo Barreto - * Vincent Rijmen, K.U.Leuven - * v2.1 Vincent Rijmen, K.U.Leuven - * - * This code is placed in the public domain. - */ -#include "mvOs.h" - -#include "mvAes.h" -#include "mvAesAlg.h" - - -/* Defines: - Add any additional defines you need -*/ - -#define MODE_ECB 1 /* Are we ciphering in ECB mode? */ -#define MODE_CBC 2 /* Are we ciphering in CBC mode? */ -#define MODE_CFB1 3 /* Are we ciphering in 1-bit CFB mode? */ - - -int aesMakeKey(MV_U8 *expandedKey, MV_U8 *keyMaterial, int keyLen, int blockLen) -{ - MV_U8 W[MAXROUNDS+1][4][MAXBC]; - MV_U8 k[4][MAXKC]; - MV_U8 j; - int i, rounds, KC; - - if (expandedKey == NULL) - { - return AES_BAD_KEY_INSTANCE; - } - - if (!((keyLen == 128) || (keyLen == 192) || (keyLen == 256))) - { - return AES_BAD_KEY_MAT; - } - - if (keyMaterial == NULL) - { - return AES_BAD_KEY_MAT; - } - - /* initialize key schedule: */ - for(i=0; i<keyLen/8; i++) - { - j = keyMaterial[i]; - k[i % 4][i / 4] = j; - } - - rijndaelKeySched (k, keyLen, blockLen, W); -#ifdef MV_AES_DEBUG - { - MV_U8* pW = &W[0][0][0]; - int x; - - mvOsPrintf("Expended Key: size = %d\n", sizeof(W)); - for(i=0; i<sizeof(W); i++) - { - mvOsPrintf("%02x ", pW[i]); - } - for(i=0; i<MAXROUNDS+1; i++) - { - mvOsPrintf("\n Round #%02d: ", i); - for(x=0; x<MAXBC; x++) - { - mvOsPrintf("%02x%02x%02x%02x ", - W[i][0][x], W[i][1][x], W[i][2][x], W[i][3][x]); - } - mvOsPrintf("\n"); - } - } -#endif /* MV_AES_DEBUG */ - switch (keyLen) - { - case 128: - rounds = 10; - KC = 4; - break; - case 192: - rounds = 12; - KC = 6; - break; - case 256: - rounds = 14; - KC = 8; - break; - default : - return (-1); - } - - for(i=0; i<MAXBC; i++) - { - for(j=0; j<4; j++) - { - expandedKey[i*4+j] = W[rounds][j][i]; - } - } - for(; i<KC; i++) - { - for(j=0; j<4; j++) - { - expandedKey[i*4+j] = W[rounds-1][j][i+MAXBC-KC]; - } - } - - - return 0; -} - -int aesBlockEncrypt128(MV_U8 mode, MV_U8 *IV, MV_U8 *expandedKey, int keyLen, - MV_U32 *plain, int numBlocks, MV_U32 *cipher) -{ - int i, j, t; - MV_U8 block[4][MAXBC]; - int rounds; - char *input, *outBuffer; - - input = (char*)plain; - outBuffer = (char*)cipher; - - /* check parameter consistency: */ - if( (expandedKey == NULL) || ((keyLen != 128) && (keyLen != 192) && (keyLen != 256))) - { - return AES_BAD_KEY_MAT; - } - if ((mode != MODE_ECB && mode != MODE_CBC)) - { - return AES_BAD_CIPHER_STATE; - } - - switch (keyLen) - { - case 128: rounds = 10; break; - case 192: rounds = 12; break; - case 256: rounds = 14; break; - default : return (-3); /* this cannot happen */ - } - - - switch (mode) - { - case MODE_ECB: - for (i = 0; i < numBlocks; i++) - { - for (j = 0; j < 4; j++) - { - for(t = 0; t < 4; t++) - /* parse input stream into rectangular array */ - block[t][j] = input[16*i+4*j+t] & 0xFF; - } - rijndaelEncrypt128(block, (MV_U8 (*)[4][MAXBC])expandedKey, rounds); - for (j = 0; j < 4; j++) - { - /* parse rectangular array into output ciphertext bytes */ - for(t = 0; t < 4; t++) - outBuffer[16*i+4*j+t] = (MV_U8) block[t][j]; - - } - } - break; - - case MODE_CBC: - for (j = 0; j < 4; j++) - { - for(t = 0; t < 4; t++) - /* parse initial value into rectangular array */ - block[t][j] = IV[t+4*j] & 0xFF; - } - for (i = 0; i < numBlocks; i++) - { - for (j = 0; j < 4; j++) - { - for(t = 0; t < 4; t++) - /* parse input stream into rectangular array and exor with - IV or the previous ciphertext */ - block[t][j] ^= input[16*i+4*j+t] & 0xFF; - } - rijndaelEncrypt128(block, (MV_U8 (*)[4][MAXBC])expandedKey, rounds); - for (j = 0; j < 4; j++) - { - /* parse rectangular array into output ciphertext bytes */ - for(t = 0; t < 4; t++) - outBuffer[16*i+4*j+t] = (MV_U8) block[t][j]; - } - } - break; - - default: return AES_BAD_CIPHER_STATE; - } - - return 0; -} - -int aesBlockDecrypt128(MV_U8 mode, MV_U8 *IV, MV_U8 *expandedKey, int keyLen, - MV_U32 *srcData, int numBlocks, MV_U32 *dstData) -{ - int i, j, t; - MV_U8 block[4][MAXBC]; - MV_U8 iv[4][MAXBC]; - int rounds; - char *input, *outBuffer; - - input = (char*)srcData; - outBuffer = (char*)dstData; - - if (expandedKey == NULL) - { - return AES_BAD_KEY_MAT; - } - - /* check parameter consistency: */ - if (keyLen != 128 && keyLen != 192 && keyLen != 256) - { - return AES_BAD_KEY_MAT; - } - if ((mode != MODE_ECB && mode != MODE_CBC)) - { - return AES_BAD_CIPHER_STATE; - } - - switch (keyLen) - { - case 128: rounds = 10; break; - case 192: rounds = 12; break; - case 256: rounds = 14; break; - default : return (-3); /* this cannot happen */ - } - - - switch (mode) - { - case MODE_ECB: - for (i = 0; i < numBlocks; i++) - { - for (j = 0; j < 4; j++) - { - for(t = 0; t < 4; t++) - { - /* parse input stream into rectangular array */ - block[t][j] = input[16*i+4*j+t] & 0xFF; - } - } - rijndaelDecrypt128(block, (MV_U8 (*)[4][MAXBC])expandedKey, rounds); - for (j = 0; j < 4; j++) - { - /* parse rectangular array into output ciphertext bytes */ - for(t = 0; t < 4; t++) - outBuffer[16*i+4*j+t] = (MV_U8) block[t][j]; - } - } - break; - - case MODE_CBC: - /* first block */ - for (j = 0; j < 4; j++) - { - for(t = 0; t < 4; t++) - { - /* parse input stream into rectangular array */ - block[t][j] = input[4*j+t] & 0xFF; - iv[t][j] = block[t][j]; - } - } - rijndaelDecrypt128(block, (MV_U8 (*)[4][MAXBC])expandedKey, rounds); - - for (j = 0; j < 4; j++) - { - /* exor the IV and parse rectangular array into output ciphertext bytes */ - for(t = 0; t < 4; t++) - { - outBuffer[4*j+t] = (MV_U8) (block[t][j] ^ IV[t+4*j]); - IV[t+4*j] = iv[t][j]; - } - } - - /* next blocks */ - for (i = 1; i < numBlocks; i++) - { - for (j = 0; j < 4; j++) - { - for(t = 0; t < 4; t++) - { - /* parse input stream into rectangular array */ - iv[t][j] = input[16*i+4*j+t] & 0xFF; - block[t][j] = iv[t][j]; - } - } - rijndaelDecrypt128(block, (MV_U8 (*)[4][MAXBC])expandedKey, rounds); - - for (j = 0; j < 4; j++) - { - /* exor previous ciphertext block and parse rectangular array - into output ciphertext bytes */ - for(t = 0; t < 4; t++) - { - outBuffer[16*i+4*j+t] = (MV_U8) (block[t][j] ^ IV[t+4*j]); - IV[t+4*j] = iv[t][j]; - } - } - } - break; - - default: return AES_BAD_CIPHER_STATE; - } - - return 0; -} - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvCesa.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvCesa.c deleted file mode 100644 index 17ab086..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvCesa.c +++ /dev/null @@ -1,3126 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#include "cesa/mvCesa.h" - -#include "ctrlEnv/mvCtrlEnvLib.h" -#undef CESA_DEBUG - - -/********** Global variables **********/ - -/* If request size is more than MV_CESA_MAX_BUF_SIZE the - * request is processed as fragmented request. - */ - -MV_CESA_STATS cesaStats; - -MV_BUF_INFO cesaSramSaBuf; -short cesaLastSid = -1; -MV_CESA_SA* pCesaSAD = NULL; -MV_U16 cesaMaxSA = 0; - -MV_CESA_REQ* pCesaReqFirst = NULL; -MV_CESA_REQ* pCesaReqLast = NULL; -MV_CESA_REQ* pCesaReqEmpty = NULL; -MV_CESA_REQ* pCesaReqProcess = NULL; -int cesaQueueDepth = 0; -int cesaReqResources = 0; - -MV_CESA_SRAM_MAP* cesaSramVirtPtr = NULL; -MV_U32 cesaCryptEngBase = 0; -void *cesaOsHandle = NULL; -#if (MV_CESA_VERSION >= 3) -MV_U32 cesaChainLength = 0; -int chainReqNum = 0; -MV_U32 chainIndex = 0; -MV_CESA_REQ* pNextActiveChain = 0; -MV_CESA_REQ* pEndCurrChain = 0; -MV_BOOL isFirstReq = MV_TRUE; -#endif - -static INLINE MV_U8* mvCesaSramAddrGet(void) -{ -#ifdef MV_CESA_NO_SRAM - return (MV_U8*)cesaSramVirtPtr; -#else - return (MV_U8*)cesaCryptEngBase; -#endif /* MV_CESA_NO_SRAM */ -} - -static INLINE MV_ULONG mvCesaSramVirtToPhys(void* pDev, MV_U8* pSramVirt) -{ -#ifdef MV_CESA_NO_SRAM - return (MV_ULONG)mvOsIoVirtToPhy(NULL, pSramVirt); -#else - return (MV_ULONG)pSramVirt; -#endif /* MV_CESA_NO_SRAM */ -} - -/* Internal Function prototypes */ - -static INLINE void mvCesaSramDescrBuild(MV_U32 config, int frag, - int cryptoOffset, int ivOffset, int cryptoLength, - int macOffset, int digestOffset, int macLength, int macTotalLen, - MV_CESA_REQ *pCesaReq, MV_DMA_DESC* pDmaDesc); - -static INLINE void mvCesaSramSaUpdate(short sid, MV_DMA_DESC *pDmaDesc); - -static INLINE int mvCesaDmaCopyPrepare(MV_CESA_MBUF* pMbuf, MV_U8* pSramBuf, - MV_DMA_DESC* pDmaDesc, MV_BOOL isToMbuf, - int offset, int copySize, MV_BOOL skipFlush); - -static void mvCesaHmacIvGet(MV_CESA_MAC_MODE macMode, unsigned char key[], int keyLength, - unsigned char innerIV[], unsigned char outerIV[]); - -static MV_STATUS mvCesaFragAuthComplete(MV_CESA_REQ* pReq, MV_CESA_SA* pSA, - int macDataSize); - -static MV_CESA_COMMAND* mvCesaCtrModeInit(void); - -static MV_STATUS mvCesaCtrModePrepare(MV_CESA_COMMAND *pCtrModeCmd, MV_CESA_COMMAND *pCmd); -static MV_STATUS mvCesaCtrModeComplete(MV_CESA_COMMAND *pOrgCmd, MV_CESA_COMMAND *pCmd); -static void mvCesaCtrModeFinish(MV_CESA_COMMAND *pCmd); - -static INLINE MV_STATUS mvCesaReqProcess(MV_CESA_REQ* pReq); -static MV_STATUS mvCesaFragReqProcess(MV_CESA_REQ* pReq, MV_U8 frag); - -static INLINE MV_STATUS mvCesaParamCheck(MV_CESA_SA* pSA, MV_CESA_COMMAND *pCmd, MV_U8* pFixOffset); -static INLINE MV_STATUS mvCesaFragParamCheck(MV_CESA_SA* pSA, MV_CESA_COMMAND *pCmd); - -static INLINE void mvCesaFragSizeFind(MV_CESA_SA* pSA, MV_CESA_REQ* pReq, - int cryptoOffset, int macOffset, - int* pCopySize, int* pCryptoDataSize, int* pMacDataSize); -static MV_STATUS mvCesaMbufCacheUnmap(MV_CESA_MBUF* pMbuf, int offset, int size); - - -/* Go to the next request in the request queue */ -static INLINE MV_CESA_REQ* MV_CESA_REQ_NEXT_PTR(MV_CESA_REQ* pReq) -{ - if(pReq == pCesaReqLast) - return pCesaReqFirst; - - return pReq+1; -} - -#if (MV_CESA_VERSION >= 3) -/* Go to the previous request in the request queue */ -static INLINE MV_CESA_REQ* MV_CESA_REQ_PREV_PTR(MV_CESA_REQ* pReq) -{ - if(pReq == pCesaReqFirst) - return pCesaReqLast; - - return pReq-1; -} - -#endif - - -static INLINE void mvCesaReqProcessStart(MV_CESA_REQ* pReq) -{ - int frag; - -#if (MV_CESA_VERSION >= 3) - pReq->state = MV_CESA_CHAIN; -#else - pReq->state = MV_CESA_PROCESS; -#endif - cesaStats.startCount++; - - if(pReq->fragMode == MV_CESA_FRAG_NONE) - { - frag = 0; - } - else - { - frag = pReq->frags.nextFrag; - pReq->frags.nextFrag++; - } -#if (MV_CESA_VERSION >= 2) - /* Enable TDMA engine */ - MV_REG_WRITE(MV_CESA_TDMA_CURR_DESC_PTR_REG, 0); - MV_REG_WRITE(MV_CESA_TDMA_NEXT_DESC_PTR_REG, - (MV_U32)mvCesaVirtToPhys(&pReq->dmaDescBuf, pReq->dma[frag].pDmaFirst)); -#else - /* Enable IDMA engine */ - MV_REG_WRITE(IDMA_CURR_DESC_PTR_REG(0), 0); - MV_REG_WRITE(IDMA_NEXT_DESC_PTR_REG(0), - (MV_U32)mvCesaVirtToPhys(&pReq->dmaDescBuf, pReq->dma[frag].pDmaFirst)); -#endif /* MV_CESA_VERSION >= 2 */ - -#if defined(MV_BRIDGE_SYNC_REORDER) - mvOsBridgeReorderWA(); -#endif - - /* Start Accelerator */ - MV_REG_WRITE(MV_CESA_CMD_REG, MV_CESA_CMD_CHAN_ENABLE_MASK); -} - - -/******************************************************************************* -* mvCesaHalInit - Initialize the CESA driver -* -* DESCRIPTION: -* This function initialize the CESA driver. -* 1) Session database -* 2) Request queue -* 4) DMA descriptor lists - one list per request. Each list -* has MV_CESA_MAX_DMA_DESC descriptors. -* -* INPUT: -* numOfSession - maximum number of supported sessions -* queueDepth - number of elements in the request queue. -* pSramBase - virtual address of Sram -* osHandle - A handle used by the OS to allocate memory for the -* module (Passed to the OS Services layer) -* -* RETURN: -* MV_OK - Success -* MV_NO_RESOURCE - Fail, can't allocate resources: -* Session database, request queue, -* DMA descriptors list, LRU cache database. -* MV_NOT_ALIGNED - Sram base address is not 8 byte aligned. -* -*******************************************************************************/ -MV_STATUS mvCesaHalInit (int numOfSession, int queueDepth, char* pSramBase, MV_U32 cryptEngBase, - void *osHandle) -{ - int i, req; - MV_U32 descOffsetReg, configReg; - MV_CESA_SRAM_SA *pSramSA; - - - mvOsPrintf("mvCesaInit: sessions=%d, queue=%d, pSram=%p\n", - numOfSession, queueDepth, pSramBase); - - cesaOsHandle = osHandle; - /* Create Session database */ - pCesaSAD = mvOsMalloc(sizeof(MV_CESA_SA)*numOfSession); - if(pCesaSAD == NULL) - { - mvOsPrintf("mvCesaInit: Can't allocate %u bytes for %d SAs\n", - sizeof(MV_CESA_SA)*numOfSession, numOfSession); - mvCesaFinish(); - return MV_NO_RESOURCE; - } - memset(pCesaSAD, 0, sizeof(MV_CESA_SA)*numOfSession); - cesaMaxSA = numOfSession; - - /* Allocate imag of sramSA in the DRAM */ - cesaSramSaBuf.bufSize = sizeof(MV_CESA_SRAM_SA)*numOfSession + - CPU_D_CACHE_LINE_SIZE; - - cesaSramSaBuf.bufVirtPtr = mvOsIoCachedMalloc(osHandle,cesaSramSaBuf.bufSize, - &cesaSramSaBuf.bufPhysAddr, - &cesaSramSaBuf.memHandle); - - if(cesaSramSaBuf.bufVirtPtr == NULL) - { - mvOsPrintf("mvCesaInit: Can't allocate %d bytes for sramSA structures\n", - cesaSramSaBuf.bufSize); - mvCesaFinish(); - return MV_NO_RESOURCE; - } - memset(cesaSramSaBuf.bufVirtPtr, 0, cesaSramSaBuf.bufSize); - pSramSA = (MV_CESA_SRAM_SA*)MV_ALIGN_UP((MV_ULONG)cesaSramSaBuf.bufVirtPtr, - CPU_D_CACHE_LINE_SIZE); - for(i=0; i<numOfSession; i++) - { - pCesaSAD[i].pSramSA = &pSramSA[i]; - } - - /* Create request queue */ - pCesaReqFirst = mvOsMalloc(sizeof(MV_CESA_REQ)*queueDepth); - if(pCesaReqFirst == NULL) - { - mvOsPrintf("mvCesaInit: Can't allocate %u bytes for %d requests\n", - sizeof(MV_CESA_REQ)*queueDepth, queueDepth); - mvCesaFinish(); - return MV_NO_RESOURCE; - } - memset(pCesaReqFirst, 0, sizeof(MV_CESA_REQ)*queueDepth); - pCesaReqEmpty = pCesaReqFirst; - pCesaReqLast = pCesaReqFirst + (queueDepth-1); - pCesaReqProcess = pCesaReqEmpty; - cesaQueueDepth = queueDepth; - cesaReqResources = queueDepth; -#if (MV_CESA_VERSION >= 3) - cesaChainLength = MAX_CESA_CHAIN_LENGTH; -#endif - /* pSramBase must be 8 byte aligned */ - if( MV_IS_NOT_ALIGN((MV_ULONG)pSramBase, 8) ) - { - mvOsPrintf("mvCesaInit: pSramBase (%p) must be 8 byte aligned\n", - pSramBase); - mvCesaFinish(); - return MV_NOT_ALIGNED; - } - cesaSramVirtPtr = (MV_CESA_SRAM_MAP*)pSramBase; - - cesaCryptEngBase = cryptEngBase; - - /*memset(cesaSramVirtPtr, 0, sizeof(MV_CESA_SRAM_MAP));*/ - - /* Clear registers */ - MV_REG_WRITE( MV_CESA_CFG_REG, 0); - MV_REG_WRITE( MV_CESA_ISR_CAUSE_REG, 0); - MV_REG_WRITE( MV_CESA_ISR_MASK_REG, 0); - - /* Initialize DMA descriptor lists for all requests in Request queue */ - descOffsetReg = configReg = 0; - for(req=0; req<queueDepth; req++) - { - int frag; - MV_CESA_REQ* pReq; - MV_DMA_DESC* pDmaDesc; - - pReq = &pCesaReqFirst[req]; - - pReq->cesaDescBuf.bufSize = sizeof(MV_CESA_DESC)*MV_CESA_MAX_REQ_FRAGS + - CPU_D_CACHE_LINE_SIZE; - - pReq->cesaDescBuf.bufVirtPtr = - mvOsIoCachedMalloc(osHandle,pReq->cesaDescBuf.bufSize, - &pReq->cesaDescBuf.bufPhysAddr, - &pReq->cesaDescBuf.memHandle); - - if(pReq->cesaDescBuf.bufVirtPtr == NULL) - { - mvOsPrintf("mvCesaInit: req=%d, Can't allocate %d bytes for CESA descriptors\n", - req, pReq->cesaDescBuf.bufSize); - mvCesaFinish(); - return MV_NO_RESOURCE; - } - memset(pReq->cesaDescBuf.bufVirtPtr, 0, pReq->cesaDescBuf.bufSize); - pReq->pCesaDesc = (MV_CESA_DESC*)MV_ALIGN_UP((MV_ULONG)pReq->cesaDescBuf.bufVirtPtr, - CPU_D_CACHE_LINE_SIZE); - - pReq->dmaDescBuf.bufSize = sizeof(MV_DMA_DESC)*MV_CESA_MAX_DMA_DESC*MV_CESA_MAX_REQ_FRAGS + - CPU_D_CACHE_LINE_SIZE; - - pReq->dmaDescBuf.bufVirtPtr = - mvOsIoCachedMalloc(osHandle,pReq->dmaDescBuf.bufSize, - &pReq->dmaDescBuf.bufPhysAddr, - &pReq->dmaDescBuf.memHandle); - - if(pReq->dmaDescBuf.bufVirtPtr == NULL) - { - mvOsPrintf("mvCesaInit: req=%d, Can't allocate %d bytes for DMA descriptor list\n", - req, pReq->dmaDescBuf.bufSize); - mvCesaFinish(); - return MV_NO_RESOURCE; - } - memset(pReq->dmaDescBuf.bufVirtPtr, 0, pReq->dmaDescBuf.bufSize); - pDmaDesc = (MV_DMA_DESC*)MV_ALIGN_UP((MV_ULONG)pReq->dmaDescBuf.bufVirtPtr, - CPU_D_CACHE_LINE_SIZE); - - for(frag=0; frag<MV_CESA_MAX_REQ_FRAGS; frag++) - { - MV_CESA_DMA* pDma = &pReq->dma[frag]; - - pDma->pDmaFirst = pDmaDesc; - pDma->pDmaLast = NULL; - - for(i=0; i<MV_CESA_MAX_DMA_DESC-1; i++) - { - /* link all DMA descriptors together */ - pDma->pDmaFirst[i].phyNextDescPtr = - MV_32BIT_LE(mvCesaVirtToPhys(&pReq->dmaDescBuf, &pDmaDesc[i+1])); - } - pDma->pDmaFirst[i].phyNextDescPtr = 0; - mvOsCacheFlush(NULL, &pDma->pDmaFirst[0], MV_CESA_MAX_DMA_DESC*sizeof(MV_DMA_DESC)); - - pDmaDesc += MV_CESA_MAX_DMA_DESC; - } - } - /*mvCesaCryptoIvSet(NULL, MV_CESA_MAX_IV_LENGTH);*/ - descOffsetReg = (MV_U16)((MV_U8*)&cesaSramVirtPtr->desc - mvCesaSramAddrGet()); - MV_REG_WRITE(MV_CESA_CHAN_DESC_OFFSET_REG, descOffsetReg); - - configReg |= (MV_CESA_CFG_WAIT_DMA_MASK | MV_CESA_CFG_ACT_DMA_MASK); -#if (MV_CESA_VERSION >= 3) - configReg |= MV_CESA_CFG_CHAIN_MODE_MASK; -#endif - -#if (MV_CESA_VERSION >= 2) - /* Initialize TDMA engine */ - MV_REG_WRITE(MV_CESA_TDMA_CTRL_REG, MV_CESA_TDMA_CTRL_VALUE); - MV_REG_WRITE(MV_CESA_TDMA_BYTE_COUNT_REG, 0); - MV_REG_WRITE(MV_CESA_TDMA_CURR_DESC_PTR_REG, 0); -#else - /* Initialize IDMA #0 engine */ - MV_REG_WRITE(IDMA_CTRL_LOW_REG(0), 0); - MV_REG_WRITE(IDMA_BYTE_COUNT_REG(0), 0); - MV_REG_WRITE(IDMA_CURR_DESC_PTR_REG(0), 0); - MV_REG_WRITE(IDMA_CTRL_HIGH_REG(0), ICCHR_ENDIAN_LITTLE -#ifdef MV_CPU_LE - | ICCHR_DESC_BYTE_SWAP_EN -#endif - ); - /* Clear Cause Byte of IDMA channel to be used */ - MV_REG_WRITE( IDMA_CAUSE_REG, ~ICICR_CAUSE_MASK_ALL(0)); - MV_REG_WRITE(IDMA_CTRL_LOW_REG(0), MV_CESA_IDMA_CTRL_LOW_VALUE); -#endif /* (MV_CESA_VERSION >= 2) */ - - /* Set CESA configuration registers */ - MV_REG_WRITE( MV_CESA_CFG_REG, configReg); - mvCesaDebugStatsClear(); - - return MV_OK; -} - -/******************************************************************************* -* mvCesaFinish - Shutdown the CESA driver -* -* DESCRIPTION: -* This function shutdown the CESA driver and free all allocted resources. -* -* INPUT: None -* -* RETURN: -* MV_OK - Success -* Other - Fail -* -*******************************************************************************/ -MV_STATUS mvCesaFinish (void) -{ - int req; - MV_CESA_REQ* pReq; - - mvOsPrintf("mvCesaFinish: \n"); - - cesaSramVirtPtr = NULL; - - /* Free all resources: DMA list, etc. */ - for(req=0; req<cesaQueueDepth; req++) - { - pReq = &pCesaReqFirst[req]; - if(pReq->dmaDescBuf.bufVirtPtr != NULL) - { - mvOsIoCachedFree(cesaOsHandle,pReq->dmaDescBuf.bufSize, - pReq->dmaDescBuf.bufPhysAddr, - pReq->dmaDescBuf.bufVirtPtr, - pReq->dmaDescBuf.memHandle); - } - if(pReq->cesaDescBuf.bufVirtPtr != NULL) - { - mvOsIoCachedFree(cesaOsHandle,pReq->cesaDescBuf.bufSize, - pReq->cesaDescBuf.bufPhysAddr, - pReq->cesaDescBuf.bufVirtPtr, - pReq->cesaDescBuf.memHandle); - } - } -#if (MV_CESA_VERSION < 2) - MV_REG_WRITE(IDMA_CTRL_LOW_REG(0), 0); -#endif /* (MV_CESA_VERSION < 2) */ - - /* Free request queue */ - if(pCesaReqFirst != NULL) - { - mvOsFree(pCesaReqFirst); - pCesaReqFirst = pCesaReqLast = NULL; - pCesaReqEmpty = pCesaReqProcess = NULL; - cesaQueueDepth = cesaReqResources = 0; - } - /* Free SA database */ - if(pCesaSAD != NULL) - { - mvOsFree(pCesaSAD); - pCesaSAD = NULL; - cesaMaxSA = 0; - } - MV_REG_WRITE( MV_CESA_CFG_REG, 0); - MV_REG_WRITE( MV_CESA_ISR_CAUSE_REG, 0); - MV_REG_WRITE( MV_CESA_ISR_MASK_REG, 0); - - return MV_OK; -} - -/******************************************************************************* -* mvCesaCryptoIvSet - Set IV value for Crypto algorithm working in CBC mode -* -* DESCRIPTION: -* This function set IV value using by Crypto algorithms in CBC mode. -* Each channel has its own IV value. -* This function gets IV value from the caller. If no IV value passed from -* the caller or only part of IV passed, the function will init the rest part -* of IV value (or the whole IV) by random value. -* -* INPUT: -* MV_U8* pIV - Pointer to IV value supplied by user. If pIV==NULL -* the function will generate random IV value. -* int ivSize - size (in bytes) of IV provided by user. If ivSize is -* smaller than maximum IV size, the function will complete -* IV by random value. -* -* RETURN: -* MV_OK - Success -* Other - Fail -* -*******************************************************************************/ -MV_STATUS mvCesaCryptoIvSet(MV_U8* pIV, int ivSize) -{ - MV_U8* pSramIV; -#if defined(MV646xx) - mvOsPrintf("mvCesaCryptoIvSet: ERR. shouldn't use this call on MV64660\n"); -#endif - pSramIV = cesaSramVirtPtr->cryptoIV; - if(ivSize > MV_CESA_MAX_IV_LENGTH) - { - mvOsPrintf("mvCesaCryptoIvSet: ivSize (%d) is too large\n", ivSize); - ivSize = MV_CESA_MAX_IV_LENGTH; - } - if(pIV != NULL) - { - memcpy(pSramIV, pIV, ivSize); - ivSize = MV_CESA_MAX_IV_LENGTH - ivSize; - pSramIV += ivSize; - } - - while(ivSize > 0) - { - int size, mv_random = mvOsRand(); - - size = MV_MIN(ivSize, sizeof(mv_random)); - memcpy(pSramIV, (void*)&mv_random, size); - - pSramIV += size; - ivSize -= size; - } -/* - mvOsCacheFlush(NULL, cesaSramVirtPtr->cryptoIV, - MV_CESA_MAX_IV_LENGTH); - mvOsCacheInvalidate(NULL, cesaSramVirtPtr->cryptoIV, - MV_CESA_MAX_IV_LENGTH); -*/ - return MV_OK; -} - -/******************************************************************************* -* mvCesaSessionOpen - Open new uni-directional crypto session -* -* DESCRIPTION: -* This function open new session. -* -* INPUT: -* MV_CESA_OPEN_SESSION *pSession - pointer to new session input parameters -* -* OUTPUT: -* short *pSid - session ID, should be used for all future -* requests over this session. -* -* RETURN: -* MV_OK - Session opend successfully. -* MV_FULL - All sessions are in use, no free place in -* SA database. -* MV_BAD_PARAM - One of session input parameters is invalid. -* -*******************************************************************************/ -MV_STATUS mvCesaSessionOpen(MV_CESA_OPEN_SESSION *pSession, short* pSid) -{ - short sid; - MV_U32 config = 0; - int digestSize; - - cesaStats.openedCount++; - - /* Find free entry in SAD */ - for(sid=0; sid<cesaMaxSA; sid++) - { - if(pCesaSAD[sid].valid == 0) - { - break; - } - } - if(sid == cesaMaxSA) - { - mvOsPrintf("mvCesaSessionOpen: SA Database is FULL\n"); - return MV_FULL; - } - - /* Check Input parameters for Open session */ - if (pSession->operation >= MV_CESA_MAX_OPERATION) - { - mvOsPrintf("mvCesaSessionOpen: Unexpected operation %d\n", - pSession->operation); - return MV_BAD_PARAM; - } - config |= (pSession->operation << MV_CESA_OPERATION_OFFSET); - - if( (pSession->direction != MV_CESA_DIR_ENCODE) && - (pSession->direction != MV_CESA_DIR_DECODE) ) - { - mvOsPrintf("mvCesaSessionOpen: Unexpected direction %d\n", - pSession->direction); - return MV_BAD_PARAM; - } - config |= (pSession->direction << MV_CESA_DIRECTION_BIT); - /* Clear SA entry */ - /* memset(&pCesaSAD[sid], 0, sizeof(pCesaSAD[sid])); */ - - /* Check AUTH parameters and update SA entry */ - if(pSession->operation != MV_CESA_CRYPTO_ONLY) - { - /* For HMAC (MD5 and SHA1) - Maximum Key size is 64 bytes */ - if( (pSession->macMode == MV_CESA_MAC_HMAC_MD5) || - (pSession->macMode == MV_CESA_MAC_HMAC_SHA1) ) - { - if(pSession->macKeyLength > MV_CESA_MAX_MAC_KEY_LENGTH) - { - mvOsPrintf("mvCesaSessionOpen: macKeyLength %d is too large\n", - pSession->macKeyLength); - return MV_BAD_PARAM; - } - mvCesaHmacIvGet(pSession->macMode, pSession->macKey, pSession->macKeyLength, - pCesaSAD[sid].pSramSA->macInnerIV, - pCesaSAD[sid].pSramSA->macOuterIV); - pCesaSAD[sid].macKeyLength = pSession->macKeyLength; - } - switch(pSession->macMode) - { - case MV_CESA_MAC_MD5: - case MV_CESA_MAC_HMAC_MD5: - digestSize = MV_CESA_MD5_DIGEST_SIZE; - break; - - case MV_CESA_MAC_SHA1: - case MV_CESA_MAC_HMAC_SHA1: - digestSize = MV_CESA_SHA1_DIGEST_SIZE; - break; - - default: - mvOsPrintf("mvCesaSessionOpen: Unexpected macMode %d\n", - pSession->macMode); - return MV_BAD_PARAM; - } - config |= (pSession->macMode << MV_CESA_MAC_MODE_OFFSET); - - /* Supported digest sizes: MD5 - 16 bytes (128 bits), */ - /* SHA1 - 20 bytes (160 bits) or 12 bytes (96 bits) for both */ - if( (pSession->digestSize != digestSize) && (pSession->digestSize != 12)) - { - mvOsPrintf("mvCesaSessionOpen: Unexpected digest size %d\n", - pSession->digestSize); - mvOsPrintf("\t Valid values [bytes]: MD5-16, SHA1-20, Both-12\n"); - return MV_BAD_PARAM; - } - pCesaSAD[sid].digestSize = pSession->digestSize; - - if(pCesaSAD[sid].digestSize == 12) - { - /* Set MV_CESA_MAC_DIGEST_SIZE_BIT if digest size is 96 bits */ - config |= (MV_CESA_MAC_DIGEST_96B << MV_CESA_MAC_DIGEST_SIZE_BIT); - } - } - - /* Check CRYPTO parameters and update SA entry */ - if(pSession->operation != MV_CESA_MAC_ONLY) - { - switch(pSession->cryptoAlgorithm) - { - case MV_CESA_CRYPTO_DES: - pCesaSAD[sid].cryptoKeyLength = MV_CESA_DES_KEY_LENGTH; - pCesaSAD[sid].cryptoBlockSize = MV_CESA_DES_BLOCK_SIZE; - break; - - case MV_CESA_CRYPTO_3DES: - pCesaSAD[sid].cryptoKeyLength = MV_CESA_3DES_KEY_LENGTH; - pCesaSAD[sid].cryptoBlockSize = MV_CESA_DES_BLOCK_SIZE; - /* Only EDE mode is supported */ - config |= (MV_CESA_CRYPTO_3DES_EDE << - MV_CESA_CRYPTO_3DES_MODE_BIT); - break; - - case MV_CESA_CRYPTO_AES: - switch(pSession->cryptoKeyLength) - { - case 16: - pCesaSAD[sid].cryptoKeyLength = MV_CESA_AES_128_KEY_LENGTH; - config |= (MV_CESA_CRYPTO_AES_KEY_128 << - MV_CESA_CRYPTO_AES_KEY_LEN_OFFSET); - break; - - case 24: - pCesaSAD[sid].cryptoKeyLength = MV_CESA_AES_192_KEY_LENGTH; - config |= (MV_CESA_CRYPTO_AES_KEY_192 << - MV_CESA_CRYPTO_AES_KEY_LEN_OFFSET); - break; - - case 32: - default: - pCesaSAD[sid].cryptoKeyLength = MV_CESA_AES_256_KEY_LENGTH; - config |= (MV_CESA_CRYPTO_AES_KEY_256 << - MV_CESA_CRYPTO_AES_KEY_LEN_OFFSET); - break; - } - pCesaSAD[sid].cryptoBlockSize = MV_CESA_AES_BLOCK_SIZE; - break; - - default: - mvOsPrintf("mvCesaSessionOpen: Unexpected cryptoAlgorithm %d\n", - pSession->cryptoAlgorithm); - return MV_BAD_PARAM; - } - config |= (pSession->cryptoAlgorithm << MV_CESA_CRYPTO_ALG_OFFSET); - - if(pSession->cryptoKeyLength != pCesaSAD[sid].cryptoKeyLength) - { - mvOsPrintf("cesaSessionOpen: Wrong CryptoKeySize %d != %d\n", - pSession->cryptoKeyLength, pCesaSAD[sid].cryptoKeyLength); - return MV_BAD_PARAM; - } - - /* Copy Crypto key */ - if( (pSession->cryptoAlgorithm == MV_CESA_CRYPTO_AES) && - (pSession->direction == MV_CESA_DIR_DECODE)) - { - /* Crypto Key for AES decode is computed from original key material */ - /* and depend on cryptoKeyLength (128/192/256 bits) */ - aesMakeKey(pCesaSAD[sid].pSramSA->cryptoKey, pSession->cryptoKey, - pSession->cryptoKeyLength*8, MV_CESA_AES_BLOCK_SIZE*8); - } - else - { - /*panic("mvCesaSessionOpen2");*/ - memcpy(pCesaSAD[sid].pSramSA->cryptoKey, pSession->cryptoKey, - pCesaSAD[sid].cryptoKeyLength); - - } - - switch(pSession->cryptoMode) - { - case MV_CESA_CRYPTO_ECB: - pCesaSAD[sid].cryptoIvSize = 0; - break; - - case MV_CESA_CRYPTO_CBC: - pCesaSAD[sid].cryptoIvSize = pCesaSAD[sid].cryptoBlockSize; - break; - - case MV_CESA_CRYPTO_CTR: - /* Supported only for AES algorithm */ - if(pSession->cryptoAlgorithm != MV_CESA_CRYPTO_AES) - { - mvOsPrintf("mvCesaSessionOpen: CRYPTO CTR mode supported for AES only\n"); - return MV_BAD_PARAM; - } - pCesaSAD[sid].cryptoIvSize = 0; - pCesaSAD[sid].ctrMode = 1; - /* Replace to ECB mode for HW */ - pSession->cryptoMode = MV_CESA_CRYPTO_ECB; - break; - - default: - mvOsPrintf("mvCesaSessionOpen: Unexpected cryptoMode %d\n", - pSession->cryptoMode); - return MV_BAD_PARAM; - } - - config |= (pSession->cryptoMode << MV_CESA_CRYPTO_MODE_BIT); - } - pCesaSAD[sid].config = config; - - mvOsCacheFlush(NULL, pCesaSAD[sid].pSramSA, sizeof(MV_CESA_SRAM_SA)); - if(pSid != NULL) - *pSid = sid; - - pCesaSAD[sid].valid = 1; - return MV_OK; -} - -/******************************************************************************* -* mvCesaSessionClose - Close active crypto session -* -* DESCRIPTION: -* This function closes existing session -* -* INPUT: -* short sid - Unique identifier of the session to be closed -* -* RETURN: -* MV_OK - Session closed successfully. -* MV_BAD_PARAM - Session identifier is out of valid range. -* MV_NOT_FOUND - There is no active session with such ID. -* -*******************************************************************************/ -MV_STATUS mvCesaSessionClose(short sid) -{ - cesaStats.closedCount++; - - if(sid >= cesaMaxSA) - { - mvOsPrintf("CESA Error: sid (%d) is too big\n", sid); - return MV_BAD_PARAM; - } - if(pCesaSAD[sid].valid == 0) - { - mvOsPrintf("CESA Warning: Session (sid=%d) is invalid\n", sid); - return MV_NOT_FOUND; - } - if(cesaLastSid == sid) - cesaLastSid = -1; - - pCesaSAD[sid].valid = 0; - return MV_OK; -} - -/******************************************************************************* -* mvCesaAction - Perform crypto operation -* -* DESCRIPTION: -* This function set new CESA request FIFO queue for further HW processing. -* The function checks request parameters before set new request to the queue. -* If one of the CESA channels is ready for processing the request will be -* passed to HW. When request processing is finished the CESA interrupt will -* be generated by HW. The caller should call mvCesaReadyGet() function to -* complete request processing and get result. -* -* INPUT: -* MV_CESA_COMMAND *pCmd - pointer to new CESA request. -* It includes pointers to Source and Destination -* buffers, session identifier get from -* mvCesaSessionOpen() function, pointer to caller -* private data and all needed crypto parameters. -* -* RETURN: -* MV_OK - request successfully added to request queue -* and will be processed. -* MV_NO_MORE - request successfully added to request queue and will -* be processed, but request queue became Full and next -* request will not be accepted. -* MV_NO_RESOURCE - request queue is FULL and the request can not -* be processed. -* MV_OUT_OF_CPU_MEM - memory allocation needed for request processing is -* failed. Request can not be processed. -* MV_NOT_ALLOWED - This mixed request (CRYPTO+MAC) can not be processed -* as one request and should be splitted for two requests: -* CRYPTO_ONLY and MAC_ONLY. -* MV_BAD_PARAM - One of the request parameters is out of valid range. -* The request can not be processed. -* -*******************************************************************************/ -MV_STATUS mvCesaAction (MV_CESA_COMMAND *pCmd) -{ - MV_STATUS status; - MV_CESA_REQ* pReq = pCesaReqEmpty; - int sid = pCmd->sessionId; - MV_CESA_SA* pSA = &pCesaSAD[sid]; -#if (MV_CESA_VERSION >= 3) - MV_CESA_REQ* pFromReq; - MV_CESA_REQ* pToReq; -#endif - cesaStats.reqCount++; - - /* Check that the request queue is not FULL */ - if(cesaReqResources == 0) - return MV_NO_RESOURCE; - - if( (sid >= cesaMaxSA) || (!pSA->valid) ) - { - mvOsPrintf("CESA Action Error: Session sid=%d is INVALID\n", sid); - return MV_BAD_PARAM; - } - pSA->count++; - - if(pSA->ctrMode) - { - /* AES in CTR mode can't be mixed with Authentication */ - if( (pSA->config & MV_CESA_OPERATION_MASK) != - (MV_CESA_CRYPTO_ONLY << MV_CESA_OPERATION_OFFSET) ) - { - mvOsPrintf("mvCesaAction : CRYPTO CTR mode can't be mixed with AUTH\n"); - return MV_NOT_ALLOWED; - } - /* All other request parameters should not be checked because key stream */ - /* (not user data) processed by AES HW engine */ - pReq->pOrgCmd = pCmd; - /* Allocate temporary pCmd structure for Key stream */ - pCmd = mvCesaCtrModeInit(); - if(pCmd == NULL) - return MV_OUT_OF_CPU_MEM; - - /* Prepare Key stream */ - mvCesaCtrModePrepare(pCmd, pReq->pOrgCmd); - pReq->fixOffset = 0; - } - else - { - /* Check request parameters and calculae fixOffset */ - status = mvCesaParamCheck(pSA, pCmd, &pReq->fixOffset); - if(status != MV_OK) - { - return status; - } - } - pReq->pCmd = pCmd; - - /* Check if the packet need fragmentation */ - if(pCmd->pSrc->mbufSize <= sizeof(cesaSramVirtPtr->buf) ) - { - /* request size is smaller than single buffer size */ - pReq->fragMode = MV_CESA_FRAG_NONE; - - /* Prepare NOT fragmented packets */ - status = mvCesaReqProcess(pReq); - if(status != MV_OK) - { - mvOsPrintf("CesaReady: ReqProcess error: pReq=%p, status=0x%x\n", - pReq, status); - } -#if (MV_CESA_VERSION >= 3) - pReq->frags.numFrag = 1; -#endif - } - else - { - MV_U8 frag = 0; - - /* request size is larger than buffer size - needs fragmentation */ - - /* Check restrictions for processing fragmented packets */ - status = mvCesaFragParamCheck(pSA, pCmd); - if(status != MV_OK) - return status; - - pReq->fragMode = MV_CESA_FRAG_FIRST; - pReq->frags.nextFrag = 0; - - /* Prepare Process Fragmented packets */ - while(pReq->fragMode != MV_CESA_FRAG_LAST) - { - if(frag >= MV_CESA_MAX_REQ_FRAGS) - { - mvOsPrintf("mvCesaAction Error: Too large request frag=%d\n", frag); - return MV_OUT_OF_CPU_MEM; - } - status = mvCesaFragReqProcess(pReq, frag); - if(status == MV_OK) { -#if (MV_CESA_VERSION >= 3) - if(frag) { - pReq->dma[frag-1].pDmaLast->phyNextDescPtr = - MV_32BIT_LE(mvCesaVirtToPhys(&pReq->dmaDescBuf, pReq->dma[frag].pDmaFirst)); - mvOsCacheFlush(NULL, pReq->dma[frag-1].pDmaLast, sizeof(MV_DMA_DESC)); - } -#endif - frag++; - } - } - pReq->frags.numFrag = frag; -#if (MV_CESA_VERSION >= 3) - if(chainReqNum) { - chainReqNum += pReq->frags.numFrag; - if(chainReqNum >= MAX_CESA_CHAIN_LENGTH) - chainReqNum = MAX_CESA_CHAIN_LENGTH; - } -#endif - } - - pReq->state = MV_CESA_PENDING; - - pCesaReqEmpty = MV_CESA_REQ_NEXT_PTR(pReq); - cesaReqResources -= 1; - -/* #ifdef CESA_DEBUG */ - if( (cesaQueueDepth - cesaReqResources) > cesaStats.maxReqCount) - cesaStats.maxReqCount = (cesaQueueDepth - cesaReqResources); -/* #endif CESA_DEBUG */ - - cesaLastSid = sid; - -#if (MV_CESA_VERSION >= 3) - /* Are we within chain bounderies and follows the first request ? */ - if((chainReqNum > 0) && (chainReqNum < MAX_CESA_CHAIN_LENGTH)) { - if(chainIndex) { - pFromReq = MV_CESA_REQ_PREV_PTR(pReq); - pToReq = pReq; - pReq->state = MV_CESA_CHAIN; - /* assume concatenating is possible */ - pFromReq->dma[pFromReq->frags.numFrag-1].pDmaLast->phyNextDescPtr = - MV_32BIT_LE(mvCesaVirtToPhys(&pToReq->dmaDescBuf, pToReq->dma[0].pDmaFirst)); - mvOsCacheFlush(NULL, pFromReq->dma[pFromReq->frags.numFrag-1].pDmaLast, sizeof(MV_DMA_DESC)); - - /* align active & next pointers */ - if(pNextActiveChain->state != MV_CESA_PENDING) - pEndCurrChain = pNextActiveChain = MV_CESA_REQ_NEXT_PTR(pReq); - } - else { /* we have only one chain, start new one */ - chainReqNum = 0; - chainIndex++; - /* align active & next pointers */ - if(pNextActiveChain->state != MV_CESA_PENDING) - pEndCurrChain = pNextActiveChain = pReq; - } - } - else { - /* In case we concatenate full chain */ - if(chainReqNum == MAX_CESA_CHAIN_LENGTH) { - chainIndex++; - if(pNextActiveChain->state != MV_CESA_PENDING) - pEndCurrChain = pNextActiveChain = pReq; - chainReqNum = 0; - } - - pReq = pCesaReqProcess; - if(pReq->state == MV_CESA_PENDING) { - pNextActiveChain = pReq; - pEndCurrChain = MV_CESA_REQ_NEXT_PTR(pReq); - /* Start Process new request */ - mvCesaReqProcessStart(pReq); - } - } - - chainReqNum++; - - if((chainIndex < MAX_CESA_CHAIN_LENGTH) && (chainReqNum > cesaStats.maxChainUsage)) - cesaStats.maxChainUsage = chainReqNum; - -#else - - /* Check status of CESA channels and process requests if possible */ - pReq = pCesaReqProcess; - if(pReq->state == MV_CESA_PENDING) - { - /* Start Process new request */ - mvCesaReqProcessStart(pReq); - } -#endif - /* If request queue became FULL - return MV_NO_MORE */ - if(cesaReqResources == 0) - return MV_NO_MORE; - - return MV_OK; - -} - -/******************************************************************************* -* mvCesaReadyGet - Get crypto request that processing is finished -* -* DESCRIPTION: -* This function complete request processing and return ready request to -* caller. To don't miss interrupts the caller must call this function -* while MV_OK or MV_TERMINATE values returned. -* -* INPUT: -* MV_U32 chanMap - map of CESA channels finished thier job -* accordingly with CESA Cause register. -* MV_CESA_RESULT* pResult - pointer to structure contains information -* about ready request. It includes pointer to -* user private structure "pReqPrv", session identifier -* for this request "sessionId" and return code. -* Return code set to MV_FAIL if calculated digest value -* on decode direction is different than digest value -* in the packet. -* -* RETURN: -* MV_OK - Success, ready request is returned. -* MV_NOT_READY - Next request is not ready yet. New interrupt will -* be generated for futher request processing. -* MV_EMPTY - There is no more request for processing. -* MV_BUSY - Fragmented request is not ready yet. -* MV_TERMINATE - Call this function once more to complete processing -* of fragmented request. -* -*******************************************************************************/ -MV_STATUS mvCesaReadyGet(MV_CESA_RESULT* pResult) -{ - MV_STATUS status, readyStatus = MV_NOT_READY; - MV_U32 statusReg; - MV_CESA_REQ* pReq; - MV_CESA_SA* pSA; - -#if (MV_CESA_VERSION >= 3) - if(isFirstReq == MV_TRUE) { - if(chainIndex == 0) - chainReqNum = 0; - - isFirstReq = MV_FALSE; - - if(pNextActiveChain->state == MV_CESA_PENDING) { - /* Start request Process */ - mvCesaReqProcessStart(pNextActiveChain); - pEndCurrChain = pNextActiveChain; - if(chainIndex > 0) - chainIndex--; - /* Update pNextActiveChain to next chain head */ - while(pNextActiveChain->state == MV_CESA_CHAIN) - pNextActiveChain = MV_CESA_REQ_NEXT_PTR(pNextActiveChain); - } - } - - /* Check if there are more processed requests - can we remove pEndCurrChain ??? */ - if(pCesaReqProcess == pEndCurrChain) { - isFirstReq = MV_TRUE; - pEndCurrChain = pNextActiveChain; -#else - if(pCesaReqProcess->state != MV_CESA_PROCESS) { -#endif - return MV_EMPTY; - } - -#ifdef CESA_DEBUG - statusReg = MV_REG_READ(MV_CESA_STATUS_REG); - if( statusReg & MV_CESA_STATUS_ACTIVE_MASK ) - { - mvOsPrintf("mvCesaReadyGet: Not Ready, Status = 0x%x\n", statusReg); - cesaStats.notReadyCount++; - return MV_NOT_READY; - } -#endif /* CESA_DEBUG */ - - cesaStats.readyCount++; - - pReq = pCesaReqProcess; - pSA = &pCesaSAD[pReq->pCmd->sessionId]; - - pResult->retCode = MV_OK; - if(pReq->fragMode != MV_CESA_FRAG_NONE) - { - MV_U8* pNewDigest; - int frag; -#if (MV_CESA_VERSION >= 3) - pReq->frags.nextFrag = 1; - while(pReq->frags.nextFrag <= pReq->frags.numFrag) { -#endif - frag = (pReq->frags.nextFrag - 1); - - /* Restore DMA descriptor list */ - pReq->dma[frag].pDmaLast->phyNextDescPtr = - MV_32BIT_LE(mvCesaVirtToPhys(&pReq->dmaDescBuf, &pReq->dma[frag].pDmaLast[1])); - pReq->dma[frag].pDmaLast = NULL; - - /* Special processing for finished fragmented request */ - if(pReq->frags.nextFrag >= pReq->frags.numFrag) - { - mvCesaMbufCacheUnmap(pReq->pCmd->pDst, 0, pReq->pCmd->pDst->mbufSize); - - /* Fragmented packet is ready */ - if( (pSA->config & MV_CESA_OPERATION_MASK) != - (MV_CESA_CRYPTO_ONLY << MV_CESA_OPERATION_OFFSET) ) - { - int macDataSize = pReq->pCmd->macLength - pReq->frags.macSize; - - if(macDataSize != 0) - { - /* Calculate all other blocks by SW */ - mvCesaFragAuthComplete(pReq, pSA, macDataSize); - } - - /* Copy new digest from SRAM to the Destination buffer */ - pNewDigest = cesaSramVirtPtr->buf + pReq->frags.newDigestOffset; - status = mvCesaCopyToMbuf(pNewDigest, pReq->pCmd->pDst, - pReq->pCmd->digestOffset, pSA->digestSize); - - /* For decryption: Compare new digest value with original one */ - if((pSA->config & MV_CESA_DIRECTION_MASK) == - (MV_CESA_DIR_DECODE << MV_CESA_DIRECTION_BIT)) - { - if( memcmp(pNewDigest, pReq->frags.orgDigest, pSA->digestSize) != 0) - { -/* - mvOsPrintf("Digest error: chan=%d, newDigest=%p, orgDigest=%p, status = 0x%x\n", - chan, pNewDigest, pReq->frags.orgDigest, MV_REG_READ(MV_CESA_STATUS_REG)); -*/ - /* Signiture verification is failed */ - pResult->retCode = MV_FAIL; - } - } - } - readyStatus = MV_OK; - } -#if (MV_CESA_VERSION >= 3) - pReq->frags.nextFrag++; - } -#endif - } - else - { - mvCesaMbufCacheUnmap(pReq->pCmd->pDst, 0, pReq->pCmd->pDst->mbufSize); - - /* Restore DMA descriptor list */ - pReq->dma[0].pDmaLast->phyNextDescPtr = - MV_32BIT_LE(mvCesaVirtToPhys(&pReq->dmaDescBuf, &pReq->dma[0].pDmaLast[1])); - pReq->dma[0].pDmaLast = NULL; - if( ((pSA->config & MV_CESA_OPERATION_MASK) != - (MV_CESA_CRYPTO_ONLY << MV_CESA_OPERATION_OFFSET) ) && - ((pSA->config & MV_CESA_DIRECTION_MASK) == - (MV_CESA_DIR_DECODE << MV_CESA_DIRECTION_BIT)) ) - { - /* For AUTH on decode : Check Digest result in Status register */ - statusReg = MV_REG_READ(MV_CESA_STATUS_REG); - if(statusReg & MV_CESA_STATUS_DIGEST_ERR_MASK) - { -/* - mvOsPrintf("Digest error: chan=%d, status = 0x%x\n", - chan, statusReg); -*/ - /* Signiture verification is failed */ - pResult->retCode = MV_FAIL; - } - } - readyStatus = MV_OK; - } - - if(readyStatus == MV_OK) - { - /* If Request is ready - Prepare pResult structure */ - pResult->pReqPrv = pReq->pCmd->pReqPrv; - pResult->sessionId = pReq->pCmd->sessionId; - - pReq->state = MV_CESA_IDLE; - pCesaReqProcess = MV_CESA_REQ_NEXT_PTR(pReq); - cesaReqResources++; - - if(pSA->ctrMode) - { - /* For AES CTR mode - complete processing and free allocated resources */ - mvCesaCtrModeComplete(pReq->pOrgCmd, pReq->pCmd); - mvCesaCtrModeFinish(pReq->pCmd); - pReq->pOrgCmd = NULL; - } - } - -#if (MV_CESA_VERSION < 3) - if(pCesaReqProcess->state == MV_CESA_PROCESS) - { - /* Start request Process */ - mvCesaReqProcessStart(pCesaReqProcess); - if(readyStatus == MV_NOT_READY) - readyStatus = MV_BUSY; - } - else if(pCesaReqProcess != pCesaReqEmpty) - { - /* Start process new request from the queue */ - mvCesaReqProcessStart(pCesaReqProcess); - } -#endif - return readyStatus; -} - -/***************** Functions to work with CESA_MBUF structure ******************/ - -/******************************************************************************* -* mvCesaMbufOffset - Locate offset in the Mbuf structure -* -* DESCRIPTION: -* This function locates offset inside Multi-Bufeer structure. -* It get fragment number and place in the fragment where the offset -* is located. -* -* -* INPUT: -* MV_CESA_MBUF* pMbuf - Pointer to multi-buffer structure -* int offset - Offset from the beginning of the data presented by -* the Mbuf structure. -* -* OUTPUT: -* int* pBufOffset - Offset from the beginning of the fragment where -* the offset is located. -* -* RETURN: -* int - Number of fragment, where the offset is located\ -* -*******************************************************************************/ -int mvCesaMbufOffset(MV_CESA_MBUF* pMbuf, int offset, int* pBufOffset) -{ - int frag = 0; - - while(offset > 0) - { - if(frag >= pMbuf->numFrags) - { - mvOsPrintf("mvCesaMbufOffset: Error: frag (%d) > numFrags (%d)\n", - frag, pMbuf->numFrags); - return MV_INVALID; - } - if(offset < pMbuf->pFrags[frag].bufSize) - { - break; - } - offset -= pMbuf->pFrags[frag].bufSize; - frag++; - } - if(pBufOffset != NULL) - *pBufOffset = offset; - - return frag; -} - -/******************************************************************************* -* mvCesaCopyFromMbuf - Copy data from the Mbuf structure to continuous buffer -* -* DESCRIPTION: -* -* -* INPUT: -* MV_U8* pDstBuf - Pointer to continuous buffer, where data is -* copied to. -* MV_CESA_MBUF* pSrcMbuf - Pointer to multi-buffer structure where data is -* copied from. -* int offset - Offset in the Mbuf structure where located first -* byte of data should be copied. -* int size - Size of data should be copied -* -* RETURN: -* MV_OK - Success, all data is copied successfully. -* MV_OUT_OF_RANGE - Failed, offset is out of Multi-buffer data range. -* No data is copied. -* MV_EMPTY - Multi-buffer structure has not enough data to copy -* Data from the offset to end of Mbuf data is copied. -* -*******************************************************************************/ -MV_STATUS mvCesaCopyFromMbuf(MV_U8* pDstBuf, MV_CESA_MBUF* pSrcMbuf, - int offset, int size) -{ - int frag, fragOffset, bufSize; - MV_U8* pBuf; - - if(size == 0) - return MV_OK; - - frag = mvCesaMbufOffset(pSrcMbuf, offset, &fragOffset); - if(frag == MV_INVALID) - { - mvOsPrintf("CESA Mbuf Error: offset (%d) out of range\n", offset); - return MV_OUT_OF_RANGE; - } - - bufSize = pSrcMbuf->pFrags[frag].bufSize - fragOffset; - pBuf = pSrcMbuf->pFrags[frag].bufVirtPtr + fragOffset; - while(MV_TRUE) - { - if(size <= bufSize) - { - memcpy(pDstBuf, pBuf, size); - return MV_OK; - } - memcpy(pDstBuf, pBuf, bufSize); - size -= bufSize; - frag++; - pDstBuf += bufSize; - if(frag >= pSrcMbuf->numFrags) - break; - - bufSize = pSrcMbuf->pFrags[frag].bufSize; - pBuf = pSrcMbuf->pFrags[frag].bufVirtPtr; - } - mvOsPrintf("mvCesaCopyFromMbuf: Mbuf is EMPTY - %d bytes isn't copied\n", - size); - return MV_EMPTY; -} - -/******************************************************************************* -* mvCesaCopyToMbuf - Copy data from continuous buffer to the Mbuf structure -* -* DESCRIPTION: -* -* -* INPUT: -* MV_U8* pSrcBuf - Pointer to continuous buffer, where data is -* copied from. -* MV_CESA_MBUF* pDstMbuf - Pointer to multi-buffer structure where data is -* copied to. -* int offset - Offset in the Mbuf structure where located first -* byte of data should be copied. -* int size - Size of data should be copied -* -* RETURN: -* MV_OK - Success, all data is copied successfully. -* MV_OUT_OF_RANGE - Failed, offset is out of Multi-buffer data range. -* No data is copied. -* MV_FULL - Multi-buffer structure has not enough place to copy -* all data. Data from the offset to end of Mbuf data -* is copied. -* -*******************************************************************************/ -MV_STATUS mvCesaCopyToMbuf(MV_U8* pSrcBuf, MV_CESA_MBUF* pDstMbuf, - int offset, int size) -{ - int frag, fragOffset, bufSize; - MV_U8* pBuf; - - if(size == 0) - return MV_OK; - - frag = mvCesaMbufOffset(pDstMbuf, offset, &fragOffset); - if(frag == MV_INVALID) - { - mvOsPrintf("CESA Mbuf Error: offset (%d) out of range\n", offset); - return MV_OUT_OF_RANGE; - } - - bufSize = pDstMbuf->pFrags[frag].bufSize - fragOffset; - pBuf = pDstMbuf->pFrags[frag].bufVirtPtr + fragOffset; - while(MV_TRUE) - { - if(size <= bufSize) - { - memcpy(pBuf, pSrcBuf, size); - return MV_OK; - } - memcpy(pBuf, pSrcBuf, bufSize); - size -= bufSize; - frag++; - pSrcBuf += bufSize; - if(frag >= pDstMbuf->numFrags) - break; - - bufSize = pDstMbuf->pFrags[frag].bufSize; - pBuf = pDstMbuf->pFrags[frag].bufVirtPtr; - } - mvOsPrintf("mvCesaCopyToMbuf: Mbuf is FULL - %d bytes isn't copied\n", - size); - return MV_FULL; -} - -/******************************************************************************* -* mvCesaMbufCopy - Copy data from one Mbuf structure to the other Mbuf structure -* -* DESCRIPTION: -* -* -* INPUT: -* -* MV_CESA_MBUF* pDstMbuf - Pointer to multi-buffer structure where data is -* copied to. -* int dstMbufOffset - Offset in the dstMbuf structure where first byte -* of data should be copied to. -* MV_CESA_MBUF* pSrcMbuf - Pointer to multi-buffer structure where data is -* copied from. -* int srcMbufOffset - Offset in the srcMbuf structure where first byte -* of data should be copied from. -* int size - Size of data should be copied -* -* RETURN: -* MV_OK - Success, all data is copied successfully. -* MV_OUT_OF_RANGE - Failed, srcMbufOffset or dstMbufOffset is out of -* srcMbuf or dstMbuf structure correspondently. -* No data is copied. -* MV_BAD_SIZE - srcMbuf or dstMbuf structure is too small to copy -* all data. Partial data is copied -* -*******************************************************************************/ -MV_STATUS mvCesaMbufCopy(MV_CESA_MBUF* pMbufDst, int dstMbufOffset, - MV_CESA_MBUF* pMbufSrc, int srcMbufOffset, int size) -{ - int srcFrag, dstFrag, srcSize, dstSize, srcOffset, dstOffset; - int copySize; - MV_U8 *pSrc, *pDst; - - if(size == 0) - return MV_OK; - - srcFrag = mvCesaMbufOffset(pMbufSrc, srcMbufOffset, &srcOffset); - if(srcFrag == MV_INVALID) - { - mvOsPrintf("CESA srcMbuf Error: offset (%d) out of range\n", srcMbufOffset); - return MV_OUT_OF_RANGE; - } - pSrc = pMbufSrc->pFrags[srcFrag].bufVirtPtr + srcOffset; - srcSize = pMbufSrc->pFrags[srcFrag].bufSize - srcOffset; - - dstFrag = mvCesaMbufOffset(pMbufDst, dstMbufOffset, &dstOffset); - if(dstFrag == MV_INVALID) - { - mvOsPrintf("CESA dstMbuf Error: offset (%d) out of range\n", dstMbufOffset); - return MV_OUT_OF_RANGE; - } - pDst = pMbufDst->pFrags[dstFrag].bufVirtPtr + dstOffset; - dstSize = pMbufDst->pFrags[dstFrag].bufSize - dstOffset; - - while(size > 0) - { - copySize = MV_MIN(srcSize, dstSize); - if(size <= copySize) - { - memcpy(pDst, pSrc, size); - return MV_OK; - } - memcpy(pDst, pSrc, copySize); - size -= copySize; - srcSize -= copySize; - dstSize -= copySize; - - if(srcSize == 0) - { - srcFrag++; - if(srcFrag >= pMbufSrc->numFrags) - break; - - pSrc = pMbufSrc->pFrags[srcFrag].bufVirtPtr; - srcSize = pMbufSrc->pFrags[srcFrag].bufSize; - } - - if(dstSize == 0) - { - dstFrag++; - if(dstFrag >= pMbufDst->numFrags) - break; - - pDst = pMbufDst->pFrags[dstFrag].bufVirtPtr; - dstSize = pMbufDst->pFrags[dstFrag].bufSize; - } - } - mvOsPrintf("mvCesaMbufCopy: BAD size - %d bytes isn't copied\n", - size); - - return MV_BAD_SIZE; -} - -static MV_STATUS mvCesaMbufCacheUnmap(MV_CESA_MBUF* pMbuf, int offset, int size) -{ - int frag, fragOffset, bufSize; - MV_U8* pBuf; - - if(size == 0) - return MV_OK; - - frag = mvCesaMbufOffset(pMbuf, offset, &fragOffset); - if(frag == MV_INVALID) - { - mvOsPrintf("CESA Mbuf Error: offset (%d) out of range\n", offset); - return MV_OUT_OF_RANGE; - } - - bufSize = pMbuf->pFrags[frag].bufSize - fragOffset; - pBuf = pMbuf->pFrags[frag].bufVirtPtr + fragOffset; - while(MV_TRUE) - { - if(size <= bufSize) - { - mvOsCacheUnmap(NULL, mvOsIoVirtToPhy(NULL, pBuf), size); - return MV_OK; - } - - mvOsCacheUnmap(NULL, mvOsIoVirtToPhy(NULL, pBuf), bufSize); - size -= bufSize; - frag++; - if(frag >= pMbuf->numFrags) - break; - - bufSize = pMbuf->pFrags[frag].bufSize; - pBuf = pMbuf->pFrags[frag].bufVirtPtr; - } - mvOsPrintf("%s: Mbuf is FULL - %d bytes isn't Unmapped\n", - __FUNCTION__, size); - return MV_FULL; -} - - -/*************************************** Local Functions ******************************/ - -/******************************************************************************* -* mvCesaFragReqProcess - Process fragmented request -* -* DESCRIPTION: -* This function processes a fragment of fragmented request (First, Middle or Last) -* -* -* INPUT: -* MV_CESA_REQ* pReq - Pointer to the request in the request queue. -* -* RETURN: -* MV_OK - The fragment is successfully passed to HW for processing. -* MV_TERMINATE - Means, that HW finished its work on this packet and no more -* interrupts will be generated for this request. -* Function mvCesaReadyGet() must be called to complete request -* processing and get request result. -* -*******************************************************************************/ -static MV_STATUS mvCesaFragReqProcess(MV_CESA_REQ* pReq, MV_U8 frag) -{ - int i, copySize, cryptoDataSize, macDataSize, sid; - int cryptoIvOffset, digestOffset; - MV_U32 config; - MV_CESA_COMMAND* pCmd = pReq->pCmd; - MV_CESA_SA* pSA; - MV_CESA_MBUF* pMbuf; - MV_DMA_DESC* pDmaDesc = pReq->dma[frag].pDmaFirst; - MV_U8* pSramBuf = cesaSramVirtPtr->buf; - int macTotalLen = 0; - int fixOffset, cryptoOffset, macOffset; - - cesaStats.fragCount++; - - sid = pReq->pCmd->sessionId; - - pSA = &pCesaSAD[sid]; - - cryptoIvOffset = digestOffset = 0; - i = macDataSize = 0; - cryptoDataSize = 0; - - /* First fragment processing */ - if(pReq->fragMode == MV_CESA_FRAG_FIRST) - { - /* pReq->frags monitors processing of fragmented request between fragments */ - pReq->frags.bufOffset = 0; - pReq->frags.cryptoSize = 0; - pReq->frags.macSize = 0; - - config = pSA->config | (MV_CESA_FRAG_FIRST << MV_CESA_FRAG_MODE_OFFSET); - - /* fixOffset can be not equal to zero only for FIRST fragment */ - fixOffset = pReq->fixOffset; - /* For FIRST fragment crypto and mac offsets are taken from pCmd */ - cryptoOffset = pCmd->cryptoOffset; - macOffset = pCmd->macOffset; - - copySize = sizeof(cesaSramVirtPtr->buf) - pReq->fixOffset; - - /* Find fragment size: Must meet all requirements for CRYPTO and MAC - * cryptoDataSize - size of data will be encrypted/decrypted in this fragment - * macDataSize - size of data will be signed/verified in this fragment - * copySize - size of data will be copied from srcMbuf to SRAM and - * back to dstMbuf for this fragment - */ - mvCesaFragSizeFind(pSA, pReq, cryptoOffset, macOffset, - ©Size, &cryptoDataSize, &macDataSize); - - if( (pSA->config & MV_CESA_OPERATION_MASK) != - (MV_CESA_MAC_ONLY << MV_CESA_OPERATION_OFFSET)) - { - /* CryptoIV special processing */ - if( (pSA->config & MV_CESA_CRYPTO_MODE_MASK) == - (MV_CESA_CRYPTO_CBC << MV_CESA_CRYPTO_MODE_BIT) ) - { - /* In CBC mode for encode direction when IV from user */ - if( (pCmd->ivFromUser) && - ((pSA->config & MV_CESA_DIRECTION_MASK) == - (MV_CESA_DIR_ENCODE << MV_CESA_DIRECTION_BIT)) ) - { - - /* For Crypto Encode in CBC mode HW always takes IV from SRAM IVPointer, - * (not from IVBufPointer). So when ivFromUser==1, we should copy IV from user place - * in the buffer to SRAM IVPointer - */ - i += mvCesaDmaCopyPrepare(pCmd->pSrc, cesaSramVirtPtr->cryptoIV, &pDmaDesc[i], - MV_FALSE, pCmd->ivOffset, pSA->cryptoIvSize, pCmd->skipFlush); - } - - /* Special processing when IV is not located in the first fragment */ - if(pCmd->ivOffset > (copySize - pSA->cryptoIvSize)) - { - /* Prepare dummy place for cryptoIV in SRAM */ - cryptoIvOffset = cesaSramVirtPtr->tempCryptoIV - mvCesaSramAddrGet(); - - /* For Decryption: Copy IV value from pCmd->ivOffset to Special SRAM place */ - if((pSA->config & MV_CESA_DIRECTION_MASK) == - (MV_CESA_DIR_DECODE << MV_CESA_DIRECTION_BIT)) - { - i += mvCesaDmaCopyPrepare(pCmd->pSrc, cesaSramVirtPtr->tempCryptoIV, &pDmaDesc[i], - MV_FALSE, pCmd->ivOffset, pSA->cryptoIvSize, pCmd->skipFlush); - } - else - { - /* For Encryption when IV is NOT from User: */ - /* Copy IV from SRAM to buffer (pCmd->ivOffset) */ - if(pCmd->ivFromUser == 0) - { - /* copy IV value from cryptoIV to Buffer (pCmd->ivOffset) */ - i += mvCesaDmaCopyPrepare(pCmd->pSrc, cesaSramVirtPtr->cryptoIV, &pDmaDesc[i], - MV_TRUE, pCmd->ivOffset, pSA->cryptoIvSize, pCmd->skipFlush); - } - } - } - else - { - cryptoIvOffset = pCmd->ivOffset; - } - } - } - - if( (pSA->config & MV_CESA_OPERATION_MASK) != - (MV_CESA_CRYPTO_ONLY << MV_CESA_OPERATION_OFFSET) ) - { - /* MAC digest special processing on Decode direction */ - if((pSA->config & MV_CESA_DIRECTION_MASK) == - (MV_CESA_DIR_DECODE << MV_CESA_DIRECTION_BIT)) - { - /* Save digest from pCmd->digestOffset */ - mvCesaCopyFromMbuf(pReq->frags.orgDigest, - pCmd->pSrc, pCmd->digestOffset, pSA->digestSize); - - /* If pCmd->digestOffset is not located on the first */ - if(pCmd->digestOffset > (copySize - pSA->digestSize)) - { - MV_U8 digestZero[MV_CESA_MAX_DIGEST_SIZE]; - - /* Set zeros to pCmd->digestOffset (DRAM) */ - memset(digestZero, 0, MV_CESA_MAX_DIGEST_SIZE); - mvCesaCopyToMbuf(digestZero, pCmd->pSrc, pCmd->digestOffset, pSA->digestSize); - - /* Prepare dummy place for digest in SRAM */ - digestOffset = cesaSramVirtPtr->tempDigest - mvCesaSramAddrGet(); - } - else - { - digestOffset = pCmd->digestOffset; - } - } - } - /* Update SA in SRAM */ - if(cesaLastSid != sid) - { - mvCesaSramSaUpdate(sid, &pDmaDesc[i]); - i++; - } - - pReq->fragMode = MV_CESA_FRAG_MIDDLE; - } - else - { - /* Continue fragment */ - fixOffset = 0; - cryptoOffset = 0; - macOffset = 0; - if( (pCmd->pSrc->mbufSize - pReq->frags.bufOffset) <= sizeof(cesaSramVirtPtr->buf)) - { - /* Last fragment */ - config = pSA->config | (MV_CESA_FRAG_LAST << MV_CESA_FRAG_MODE_OFFSET); - pReq->fragMode = MV_CESA_FRAG_LAST; - copySize = pCmd->pSrc->mbufSize - pReq->frags.bufOffset; - - if( (pSA->config & MV_CESA_OPERATION_MASK) != - (MV_CESA_CRYPTO_ONLY << MV_CESA_OPERATION_OFFSET) ) - { - macDataSize = pCmd->macLength - pReq->frags.macSize; - - /* If pCmd->digestOffset is not located on last fragment */ - if(pCmd->digestOffset < pReq->frags.bufOffset) - { - /* Prepare dummy place for digest in SRAM */ - digestOffset = cesaSramVirtPtr->tempDigest - mvCesaSramAddrGet(); - } - else - { - digestOffset = pCmd->digestOffset - pReq->frags.bufOffset; - } - pReq->frags.newDigestOffset = digestOffset; - macTotalLen = pCmd->macLength; - - /* HW can't calculate the Digest correctly for fragmented packets - * in the following cases: - * - MV88F5182 || - * - MV88F5181L when total macLength more that 16 Kbytes || - * - total macLength more that 64 Kbytes - */ - if( (mvCtrlModelGet() == MV_5182_DEV_ID) || - ( (mvCtrlModelGet() == MV_5181_DEV_ID) && - (mvCtrlRevGet() >= MV_5181L_A0_REV) && - (pCmd->macLength >= (1 << 14)) ) ) - { - return MV_TERMINATE; - } - } - if( (pSA->config & MV_CESA_OPERATION_MASK) != - (MV_CESA_MAC_ONLY << MV_CESA_OPERATION_OFFSET) ) - { - cryptoDataSize = pCmd->cryptoLength - pReq->frags.cryptoSize; - } - - /* cryptoIvOffset - don't care */ - } - else - { - /* WA for MV88F5182 SHA1 and MD5 fragmentation mode */ - if( (mvCtrlModelGet() == MV_5182_DEV_ID) && - (((pSA->config & MV_CESA_MAC_MODE_MASK) == - (MV_CESA_MAC_MD5 << MV_CESA_MAC_MODE_OFFSET)) || - ((pSA->config & MV_CESA_MAC_MODE_MASK) == - (MV_CESA_MAC_SHA1 << MV_CESA_MAC_MODE_OFFSET))) ) - { - pReq->frags.newDigestOffset = cesaSramVirtPtr->tempDigest - mvCesaSramAddrGet(); - pReq->fragMode = MV_CESA_FRAG_LAST; - - return MV_TERMINATE; - } - /* Middle fragment */ - config = pSA->config | (MV_CESA_FRAG_MIDDLE << MV_CESA_FRAG_MODE_OFFSET); - copySize = sizeof(cesaSramVirtPtr->buf); - /* digestOffset and cryptoIvOffset - don't care */ - - /* Find fragment size */ - mvCesaFragSizeFind(pSA, pReq, cryptoOffset, macOffset, - ©Size, &cryptoDataSize, &macDataSize); - } - } - /********* Prepare DMA descriptors to copy from pSrc to SRAM *********/ - pMbuf = pCmd->pSrc; - i += mvCesaDmaCopyPrepare(pMbuf, pSramBuf + fixOffset, &pDmaDesc[i], - MV_FALSE, pReq->frags.bufOffset, copySize, pCmd->skipFlush); - - /* Prepare CESA descriptor to copy from DRAM to SRAM by DMA */ - mvCesaSramDescrBuild(config, frag, - cryptoOffset + fixOffset, cryptoIvOffset + fixOffset, - cryptoDataSize, macOffset + fixOffset, - digestOffset + fixOffset, macDataSize, macTotalLen, - pReq, &pDmaDesc[i]); - i++; - - /* Add special descriptor Ownership for CPU */ - pDmaDesc[i].byteCnt = 0; - pDmaDesc[i].phySrcAdd = 0; - pDmaDesc[i].phyDestAdd = 0; - i++; - - /********* Prepare DMA descriptors to copy from SRAM to pDst *********/ - pMbuf = pCmd->pDst; - i += mvCesaDmaCopyPrepare(pMbuf, pSramBuf + fixOffset, &pDmaDesc[i], - MV_TRUE, pReq->frags.bufOffset, copySize, pCmd->skipFlush); - - /* Next field of Last DMA descriptor must be NULL */ - pDmaDesc[i-1].phyNextDescPtr = 0; - pReq->dma[frag].pDmaLast = &pDmaDesc[i-1]; - mvOsCacheFlush(NULL, pReq->dma[frag].pDmaFirst, - i*sizeof(MV_DMA_DESC)); - - /*mvCesaDebugDescriptor(&cesaSramVirtPtr->desc[frag]);*/ - - pReq->frags.bufOffset += copySize; - pReq->frags.cryptoSize += cryptoDataSize; - pReq->frags.macSize += macDataSize; - - return MV_OK; -} - - -/******************************************************************************* -* mvCesaReqProcess - Process regular (Non-fragmented) request -* -* DESCRIPTION: -* This function processes the whole (not fragmented) request -* -* INPUT: -* MV_CESA_REQ* pReq - Pointer to the request in the request queue. -* -* RETURN: -* MV_OK - The request is successfully passed to HW for processing. -* Other - Failure. The request will not be processed -* -*******************************************************************************/ -static MV_STATUS mvCesaReqProcess(MV_CESA_REQ* pReq) -{ - MV_CESA_MBUF *pMbuf; - MV_DMA_DESC *pDmaDesc; - MV_U8 *pSramBuf; - int sid, i, fixOffset; - MV_CESA_SA *pSA; - MV_CESA_COMMAND *pCmd = pReq->pCmd; - - cesaStats.procCount++; - - sid = pCmd->sessionId; - pSA = &pCesaSAD[sid]; - pDmaDesc = pReq->dma[0].pDmaFirst; - pSramBuf = cesaSramVirtPtr->buf; - fixOffset = pReq->fixOffset; - -/* - mvOsPrintf("mvCesaReqProcess: sid=%d, pSA=%p, pDmaDesc=%p, pSramBuf=%p\n", - sid, pSA, pDmaDesc, pSramBuf); -*/ - i = 0; - - /* Crypto IV Special processing in CBC mode for Encryption direction */ - if( ((pSA->config & MV_CESA_OPERATION_MASK) != (MV_CESA_MAC_ONLY << MV_CESA_OPERATION_OFFSET)) && - ((pSA->config & MV_CESA_CRYPTO_MODE_MASK) == (MV_CESA_CRYPTO_CBC << MV_CESA_CRYPTO_MODE_BIT)) && - ((pSA->config & MV_CESA_DIRECTION_MASK) == (MV_CESA_DIR_ENCODE << MV_CESA_DIRECTION_BIT)) && - (pCmd->ivFromUser) ) - { - /* For Crypto Encode in CBC mode HW always takes IV from SRAM IVPointer, - * (not from IVBufPointer). So when ivFromUser==1, we should copy IV from user place - * in the buffer to SRAM IVPointer - */ - i += mvCesaDmaCopyPrepare(pCmd->pSrc, cesaSramVirtPtr->cryptoIV, &pDmaDesc[i], - MV_FALSE, pCmd->ivOffset, pSA->cryptoIvSize, pCmd->skipFlush); - } - - /* Update SA in SRAM */ - if(cesaLastSid != sid) - { - mvCesaSramSaUpdate(sid, &pDmaDesc[i]); - i++; - } - - /********* Prepare DMA descriptors to copy from pSrc to SRAM *********/ - pMbuf = pCmd->pSrc; - i += mvCesaDmaCopyPrepare(pMbuf, pSramBuf + fixOffset, &pDmaDesc[i], - MV_FALSE, 0, pMbuf->mbufSize, pCmd->skipFlush); - - /* Prepare Security Accelerator descriptor to SRAM words 0 - 7 */ - mvCesaSramDescrBuild(pSA->config, 0, pCmd->cryptoOffset + fixOffset, - pCmd->ivOffset + fixOffset, pCmd->cryptoLength, - pCmd->macOffset + fixOffset, pCmd->digestOffset + fixOffset, - pCmd->macLength, pCmd->macLength, pReq, &pDmaDesc[i]); - i++; - - /* Add special descriptor Ownership for CPU */ - pDmaDesc[i].byteCnt = 0; - pDmaDesc[i].phySrcAdd = 0; - pDmaDesc[i].phyDestAdd = 0; - i++; - - /********* Prepare DMA descriptors to copy from SRAM to pDst *********/ - pMbuf = pCmd->pDst; - i += mvCesaDmaCopyPrepare(pMbuf, pSramBuf + fixOffset, &pDmaDesc[i], - MV_TRUE, 0, pMbuf->mbufSize, pCmd->skipFlush); - - /* Next field of Last DMA descriptor must be NULL */ - pDmaDesc[i-1].phyNextDescPtr = 0; - pReq->dma[0].pDmaLast = &pDmaDesc[i-1]; - mvOsCacheFlush(NULL, pReq->dma[0].pDmaFirst, i*sizeof(MV_DMA_DESC)); - - return MV_OK; -} - - -/******************************************************************************* -* mvCesaSramDescrBuild - Set CESA descriptor in SRAM -* -* DESCRIPTION: -* This function builds CESA descriptor in SRAM from all Command parameters -* -* -* INPUT: -* int chan - CESA channel uses the descriptor -* MV_U32 config - 32 bits of WORD_0 in CESA descriptor structure -* int cryptoOffset - Offset from the beginning of SRAM buffer where -* data for encryption/decription is started. -* int ivOffset - Offset of crypto IV from the SRAM base. Valid only -* for first fragment. -* int cryptoLength - Size (in bytes) of data for encryption/descryption -* operation on this fragment. -* int macOffset - Offset from the beginning of SRAM buffer where -* data for Authentication is started -* int digestOffset - Offset from the beginning of SRAM buffer where -* digest is located. Valid for first and last fragments. -* int macLength - Size (in bytes) of data for Authentication -* operation on this fragment. -* int macTotalLen - Toatl size (in bytes) of data for Authentication -* operation on the whole request (packet). Valid for -* last fragment only. -* -* RETURN: None -* -*******************************************************************************/ -static void mvCesaSramDescrBuild(MV_U32 config, int frag, - int cryptoOffset, int ivOffset, int cryptoLength, - int macOffset, int digestOffset, int macLength, - int macTotalLen, MV_CESA_REQ* pReq, MV_DMA_DESC* pDmaDesc) -{ - MV_CESA_DESC* pCesaDesc = &pReq->pCesaDesc[frag]; - MV_CESA_DESC* pSramDesc = pSramDesc = &cesaSramVirtPtr->desc; - MV_U16 sramBufOffset = (MV_U16)((MV_U8*)cesaSramVirtPtr->buf - mvCesaSramAddrGet()); - - pCesaDesc->config = MV_32BIT_LE(config); - - if( (config & MV_CESA_OPERATION_MASK) != - (MV_CESA_MAC_ONLY << MV_CESA_OPERATION_OFFSET) ) - { - /* word 1 */ - pCesaDesc->cryptoSrcOffset = MV_16BIT_LE(sramBufOffset + cryptoOffset); - pCesaDesc->cryptoDstOffset = MV_16BIT_LE(sramBufOffset + cryptoOffset); - /* word 2 */ - pCesaDesc->cryptoDataLen = MV_16BIT_LE(cryptoLength); - /* word 3 */ - pCesaDesc->cryptoKeyOffset = MV_16BIT_LE((MV_U16)(cesaSramVirtPtr->sramSA.cryptoKey - - mvCesaSramAddrGet())); - /* word 4 */ - pCesaDesc->cryptoIvOffset = MV_16BIT_LE((MV_U16)(cesaSramVirtPtr->cryptoIV - - mvCesaSramAddrGet())); - pCesaDesc->cryptoIvBufOffset = MV_16BIT_LE(sramBufOffset + ivOffset); - } - - if( (config & MV_CESA_OPERATION_MASK) != - (MV_CESA_CRYPTO_ONLY << MV_CESA_OPERATION_OFFSET) ) - { - /* word 5 */ - pCesaDesc->macSrcOffset = MV_16BIT_LE(sramBufOffset + macOffset); - pCesaDesc->macTotalLen = MV_16BIT_LE(macTotalLen); - - /* word 6 */ - pCesaDesc->macDigestOffset = MV_16BIT_LE(sramBufOffset + digestOffset); - pCesaDesc->macDataLen = MV_16BIT_LE(macLength); - - /* word 7 */ - pCesaDesc->macInnerIvOffset = MV_16BIT_LE((MV_U16)(cesaSramVirtPtr->sramSA.macInnerIV - - mvCesaSramAddrGet())); - pCesaDesc->macOuterIvOffset = MV_16BIT_LE((MV_U16)(cesaSramVirtPtr->sramSA.macOuterIV - - mvCesaSramAddrGet())); - } - /* Prepare DMA descriptor to CESA descriptor from DRAM to SRAM */ - pDmaDesc->phySrcAdd = MV_32BIT_LE(mvCesaVirtToPhys(&pReq->cesaDescBuf, pCesaDesc)); - pDmaDesc->phyDestAdd = MV_32BIT_LE(mvCesaSramVirtToPhys(NULL, (MV_U8*)pSramDesc)); - pDmaDesc->byteCnt = MV_32BIT_LE(sizeof(MV_CESA_DESC) | BIT31); - - /* flush Source buffer */ - mvOsCacheFlush(NULL, pCesaDesc, sizeof(MV_CESA_DESC)); -} - -/******************************************************************************* -* mvCesaSramSaUpdate - Move required SA information to SRAM if needed. -* -* DESCRIPTION: -* Copy to SRAM values of the required SA. -* -* -* INPUT: -* short sid - Session ID needs SRAM Cache update -* MV_DMA_DESC *pDmaDesc - Pointer to DMA descriptor used to -* copy SA values from DRAM to SRAM. -* -* RETURN: -* MV_OK - Cache entry for this SA copied to SRAM. -* MV_NO_CHANGE - Cache entry for this SA already exist in SRAM -* -*******************************************************************************/ -static INLINE void mvCesaSramSaUpdate(short sid, MV_DMA_DESC *pDmaDesc) -{ - MV_CESA_SA *pSA = &pCesaSAD[sid]; - - /* Prepare DMA descriptor to Copy CACHE_SA from SA database in DRAM to SRAM */ - pDmaDesc->byteCnt = MV_32BIT_LE(sizeof(MV_CESA_SRAM_SA) | BIT31); - pDmaDesc->phySrcAdd = MV_32BIT_LE(mvCesaVirtToPhys(&cesaSramSaBuf, pSA->pSramSA)); - pDmaDesc->phyDestAdd = - MV_32BIT_LE(mvCesaSramVirtToPhys(NULL, (MV_U8*)&cesaSramVirtPtr->sramSA)); - - /* Source buffer is already flushed during OpenSession*/ - /*mvOsCacheFlush(NULL, &pSA->sramSA, sizeof(MV_CESA_SRAM_SA));*/ -} - -/******************************************************************************* -* mvCesaDmaCopyPrepare - prepare DMA descriptor list to copy data presented by -* Mbuf structure from DRAM to SRAM -* -* DESCRIPTION: -* -* -* INPUT: -* MV_CESA_MBUF* pMbuf - pointer to Mbuf structure contains request -* data in DRAM -* MV_U8* pSramBuf - pointer to buffer in SRAM where data should -* be copied to. -* MV_DMA_DESC* pDmaDesc - pointer to first DMA descriptor for this copy. -* The function set number of DMA descriptors needed -* to copy the copySize bytes from Mbuf. -* MV_BOOL isToMbuf - Copy direction. -* MV_TRUE means copy from SRAM buffer to Mbuf in DRAM. -* MV_FALSE means copy from Mbuf in DRAM to SRAM buffer. -* int offset - Offset in the Mbuf structure that copy should be -* started from. -* int copySize - Size of data should be copied. -* -* RETURN: -* int - number of DMA descriptors used for the copy. -* -*******************************************************************************/ -#ifndef MV_NETBSD -static INLINE int mvCesaDmaCopyPrepare(MV_CESA_MBUF* pMbuf, MV_U8* pSramBuf, - MV_DMA_DESC* pDmaDesc, MV_BOOL isToMbuf, - int offset, int copySize, MV_BOOL skipFlush) -{ - int bufOffset, bufSize, size, frag, i; - MV_U8* pBuf; - - i = 0; - - /* Calculate start place for copy: fragment number and offset in the fragment */ - frag = mvCesaMbufOffset(pMbuf, offset, &bufOffset); - bufSize = pMbuf->pFrags[frag].bufSize - bufOffset; - pBuf = pMbuf->pFrags[frag].bufVirtPtr + bufOffset; - - /* Size accumulate total copy size */ - size = 0; - - /* Create DMA lists to copy mBuf from pSrc to SRAM */ - while(size < copySize) - { - /* Find copy size for each DMA descriptor */ - bufSize = MV_MIN(bufSize, (copySize - size)); - pDmaDesc[i].byteCnt = MV_32BIT_LE(bufSize | BIT31); - if(isToMbuf) - { - pDmaDesc[i].phyDestAdd = MV_32BIT_LE(mvOsIoVirtToPhy(NULL, pBuf)); - pDmaDesc[i].phySrcAdd = - MV_32BIT_LE(mvCesaSramVirtToPhys(NULL, (pSramBuf + size))); - /* invalidate the buffer */ - if(skipFlush == MV_FALSE) - mvOsCacheInvalidate(NULL, pBuf, bufSize); - } - else - { - pDmaDesc[i].phySrcAdd = MV_32BIT_LE(mvOsIoVirtToPhy(NULL, pBuf)); - pDmaDesc[i].phyDestAdd = - MV_32BIT_LE(mvCesaSramVirtToPhys(NULL, (pSramBuf + size))); - /* flush the buffer */ - if(skipFlush == MV_FALSE) - mvOsCacheFlush(NULL, pBuf, bufSize); - } - - /* Count number of used DMA descriptors */ - i++; - size += bufSize; - - /* go to next fragment in the Mbuf */ - frag++; - pBuf = pMbuf->pFrags[frag].bufVirtPtr; - bufSize = pMbuf->pFrags[frag].bufSize; - } - return i; -} -#else /* MV_NETBSD */ -static int mvCesaDmaCopyPrepare(MV_CESA_MBUF* pMbuf, MV_U8* pSramBuf, - MV_DMA_DESC* pDmaDesc, MV_BOOL isToMbuf, - int offset, int copySize, MV_BOOL skipFlush) -{ - int bufOffset, bufSize, thisSize, size, frag, i; - MV_ULONG bufPhys, sramPhys; - MV_U8* pBuf; - - /* - * Calculate start place for copy: fragment number and offset in - * the fragment - */ - frag = mvCesaMbufOffset(pMbuf, offset, &bufOffset); - - /* - * Get SRAM physical address only once. We can update it in-place - * as we build the descriptor chain. - */ - sramPhys = mvCesaSramVirtToPhys(NULL, pSramBuf); - - /* - * 'size' accumulates total copy size, 'i' counts desccriptors. - */ - size = i = 0; - - /* Create DMA lists to copy mBuf from pSrc to SRAM */ - while (size < copySize) { - /* - * Calculate # of bytes to copy from the current fragment, - * and the pointer to the start of data - */ - bufSize = pMbuf->pFrags[frag].bufSize - bufOffset; - pBuf = pMbuf->pFrags[frag].bufVirtPtr + bufOffset; - bufOffset = 0; /* First frag may be non-zero */ - frag++; - - /* - * As long as there is data in the current fragment... - */ - while (bufSize > 0) { - /* - * Ensure we don't cross an MMU page boundary. - * XXX: This is NetBSD-specific, but it is a - * quick and dirty way to fix the problem. - * A true HAL would rely on the OS-specific - * driver to do this... - */ - thisSize = PAGE_SIZE - - (((MV_ULONG)pBuf) & (PAGE_SIZE - 1)); - thisSize = MV_MIN(bufSize, thisSize); - /* - * Make sure we don't copy more than requested - */ - if (thisSize > (copySize - size)) { - thisSize = copySize - size; - bufSize = 0; - } - - /* - * Physicall address of this fragment - */ - bufPhys = MV_32BIT_LE(mvOsIoVirtToPhy(NULL, pBuf)); - - /* - * Set up the descriptor - */ - pDmaDesc[i].byteCnt = MV_32BIT_LE(thisSize | BIT31); - if(isToMbuf) { - pDmaDesc[i].phyDestAdd = bufPhys; - pDmaDesc[i].phySrcAdd = MV_32BIT_LE(sramPhys); - /* invalidate the buffer */ - if(skipFlush == MV_FALSE) - mvOsCacheInvalidate(NULL, pBuf, thisSize); - } else { - pDmaDesc[i].phySrcAdd = bufPhys; - pDmaDesc[i].phyDestAdd = MV_32BIT_LE(sramPhys); - /* flush the buffer */ - if(skipFlush == MV_FALSE) - mvOsCacheFlush(NULL, pBuf, thisSize); - } - - pDmaDesc[i].phyNextDescPtr = - MV_32BIT_LE(mvOsIoVirtToPhy(NULL,(&pDmaDesc[i+1]))); - - /* flush the DMA desc */ - mvOsCacheFlush(NULL, &pDmaDesc[i], sizeof(MV_DMA_DESC)); - - /* Update state */ - bufSize -= thisSize; - sramPhys += thisSize; - pBuf += thisSize; - size += thisSize; - i++; - } - } - - return i; -} -#endif /* MV_NETBSD */ -/******************************************************************************* -* mvCesaHmacIvGet - Calculate Inner and Outter values from HMAC key -* -* DESCRIPTION: -* This function calculate Inner and Outer values used for HMAC algorithm. -* This operation allows improve performance fro the whole HMAC processing. -* -* INPUT: -* MV_CESA_MAC_MODE macMode - Authentication mode: HMAC_MD5 or HMAC_SHA1. -* unsigned char key[] - Pointer to HMAC key. -* int keyLength - Size of HMAC key (maximum 64 bytes) -* -* OUTPUT: -* unsigned char innerIV[] - HASH(key^inner) -* unsigned char outerIV[] - HASH(key^outter) -* -* RETURN: None -* -*******************************************************************************/ -static void mvCesaHmacIvGet(MV_CESA_MAC_MODE macMode, unsigned char key[], int keyLength, - unsigned char innerIV[], unsigned char outerIV[]) -{ - unsigned char inner[MV_CESA_MAX_MAC_KEY_LENGTH]; - unsigned char outer[MV_CESA_MAX_MAC_KEY_LENGTH]; - int i, digestSize = 0; -#if defined(MV_CPU_LE) || defined(MV_PPC) - MV_U32 swapped32, val32, *pVal32; -#endif - for(i=0; i<keyLength; i++) - { - inner[i] = 0x36 ^ key[i]; - outer[i] = 0x5c ^ key[i]; - } - - for(i=keyLength; i<MV_CESA_MAX_MAC_KEY_LENGTH; i++) - { - inner[i] = 0x36; - outer[i] = 0x5c; - } - if(macMode == MV_CESA_MAC_HMAC_MD5) - { - MV_MD5_CONTEXT ctx; - - mvMD5Init(&ctx); - mvMD5Update(&ctx, inner, MV_CESA_MAX_MAC_KEY_LENGTH); - - memcpy(innerIV, ctx.buf, MV_CESA_MD5_DIGEST_SIZE); - memset(&ctx, 0, sizeof(ctx)); - - mvMD5Init(&ctx); - mvMD5Update(&ctx, outer, MV_CESA_MAX_MAC_KEY_LENGTH); - memcpy(outerIV, ctx.buf, MV_CESA_MD5_DIGEST_SIZE); - memset(&ctx, 0, sizeof(ctx)); - digestSize = MV_CESA_MD5_DIGEST_SIZE; - } - else if(macMode == MV_CESA_MAC_HMAC_SHA1) - { - MV_SHA1_CTX ctx; - - mvSHA1Init(&ctx); - mvSHA1Update(&ctx, inner, MV_CESA_MAX_MAC_KEY_LENGTH); - memcpy(innerIV, ctx.state, MV_CESA_SHA1_DIGEST_SIZE); - memset(&ctx, 0, sizeof(ctx)); - - mvSHA1Init(&ctx); - mvSHA1Update(&ctx, outer, MV_CESA_MAX_MAC_KEY_LENGTH); - memcpy(outerIV, ctx.state, MV_CESA_SHA1_DIGEST_SIZE); - memset(&ctx, 0, sizeof(ctx)); - digestSize = MV_CESA_SHA1_DIGEST_SIZE; - } - else - { - mvOsPrintf("hmacGetIV: Unexpected macMode %d\n", macMode); - } -#if defined(MV_CPU_LE) || defined(MV_PPC) - /* 32 bits Swap of Inner and Outer values */ - pVal32 = (MV_U32*)innerIV; - for(i=0; i<digestSize/4; i++) - { - val32 = *pVal32; - swapped32 = MV_BYTE_SWAP_32BIT(val32); - *pVal32 = swapped32; - pVal32++; - } - pVal32 = (MV_U32*)outerIV; - for(i=0; i<digestSize/4; i++) - { - val32 = *pVal32; - swapped32 = MV_BYTE_SWAP_32BIT(val32); - *pVal32 = swapped32; - pVal32++; - } -#endif /* defined(MV_CPU_LE) || defined(MV_PPC) */ -} - - -/******************************************************************************* -* mvCesaFragSha1Complete - Complete SHA1 authentication started by HW using SW -* -* DESCRIPTION: -* -* -* INPUT: -* MV_CESA_MBUF* pMbuf - Pointer to Mbuf structure where data -* for SHA1 is placed. -* int offset - Offset in the Mbuf structure where -* unprocessed data for SHA1 is started. -* MV_U8* pOuterIV - Pointer to OUTER for this session. -* If pOuterIV==NULL - MAC mode is HASH_SHA1 -* If pOuterIV!=NULL - MAC mode is HMAC_SHA1 -* int macLeftSize - Size of unprocessed data for SHA1. -* int macTotalSize - Total size of data for SHA1 in the -* request (processed + unprocessed) -* -* OUTPUT: -* MV_U8* pDigest - Pointer to place where calculated Digest will -* be stored. -* -* RETURN: None -* -*******************************************************************************/ -static void mvCesaFragSha1Complete(MV_CESA_MBUF* pMbuf, int offset, - MV_U8* pOuterIV, int macLeftSize, - int macTotalSize, MV_U8* pDigest) -{ - MV_SHA1_CTX ctx; - MV_U8 *pData; - int i, frag, fragOffset, size; - - /* Read temporary Digest from HW */ - for(i=0; i<MV_CESA_SHA1_DIGEST_SIZE/4; i++) - { - ctx.state[i] = MV_REG_READ(MV_CESA_AUTH_INIT_VAL_DIGEST_REG(i)); - } - /* Initialize MV_SHA1_CTX structure */ - memset(ctx.buffer, 0, 64); - /* Set count[0] in bits. 32 bits is enough for 512 MBytes */ - /* so count[1] is always 0 */ - ctx.count[0] = ((macTotalSize - macLeftSize) * 8); - ctx.count[1] = 0; - - /* If HMAC - add size of Inner block (64 bytes) ro count[0] */ - if(pOuterIV != NULL) - ctx.count[0] += (64 * 8); - - /* Get place of unprocessed data in the Mbuf structure */ - frag = mvCesaMbufOffset(pMbuf, offset, &fragOffset); - if(frag == MV_INVALID) - { - mvOsPrintf("CESA Mbuf Error: offset (%d) out of range\n", offset); - return; - } - - pData = pMbuf->pFrags[frag].bufVirtPtr + fragOffset; - size = pMbuf->pFrags[frag].bufSize - fragOffset; - - /* Complete Inner part */ - while(macLeftSize > 0) - { - if(macLeftSize <= size) - { - mvSHA1Update(&ctx, pData, macLeftSize); - break; - } - mvSHA1Update(&ctx, pData, size); - macLeftSize -= size; - frag++; - pData = pMbuf->pFrags[frag].bufVirtPtr; - size = pMbuf->pFrags[frag].bufSize; - } - mvSHA1Final(pDigest, &ctx); -/* - mvOsPrintf("mvCesaFragSha1Complete: pOuterIV=%p, macLeftSize=%d, macTotalSize=%d\n", - pOuterIV, macLeftSize, macTotalSize); - mvDebugMemDump(pDigest, MV_CESA_SHA1_DIGEST_SIZE, 1); -*/ - - if(pOuterIV != NULL) - { - /* If HMAC - Complete Outer part */ - for(i=0; i<MV_CESA_SHA1_DIGEST_SIZE/4; i++) - { -#if defined(MV_CPU_LE) || defined(MV_ARM) - ctx.state[i] = MV_BYTE_SWAP_32BIT(((MV_U32*)pOuterIV)[i]); -#else - ctx.state[i] = ((MV_U32*)pOuterIV)[i]; -#endif - } - memset(ctx.buffer, 0, 64); - - ctx.count[0] = 64*8; - ctx.count[1] = 0; - mvSHA1Update(&ctx, pDigest, MV_CESA_SHA1_DIGEST_SIZE); - mvSHA1Final(pDigest, &ctx); - } -} - -/******************************************************************************* -* mvCesaFragMd5Complete - Complete MD5 authentication started by HW using SW -* -* DESCRIPTION: -* -* -* INPUT: -* MV_CESA_MBUF* pMbuf - Pointer to Mbuf structure where data -* for SHA1 is placed. -* int offset - Offset in the Mbuf structure where -* unprocessed data for MD5 is started. -* MV_U8* pOuterIV - Pointer to OUTER for this session. -* If pOuterIV==NULL - MAC mode is HASH_MD5 -* If pOuterIV!=NULL - MAC mode is HMAC_MD5 -* int macLeftSize - Size of unprocessed data for MD5. -* int macTotalSize - Total size of data for MD5 in the -* request (processed + unprocessed) -* -* OUTPUT: -* MV_U8* pDigest - Pointer to place where calculated Digest will -* be stored. -* -* RETURN: None -* -*******************************************************************************/ -static void mvCesaFragMd5Complete(MV_CESA_MBUF* pMbuf, int offset, - MV_U8* pOuterIV, int macLeftSize, - int macTotalSize, MV_U8* pDigest) -{ - MV_MD5_CONTEXT ctx; - MV_U8 *pData; - int i, frag, fragOffset, size; - - /* Read temporary Digest from HW */ - for(i=0; i<MV_CESA_MD5_DIGEST_SIZE/4; i++) - { - ctx.buf[i] = MV_REG_READ(MV_CESA_AUTH_INIT_VAL_DIGEST_REG(i)); - } - memset(ctx.in, 0, 64); - - /* Set count[0] in bits. 32 bits is enough for 512 MBytes */ - /* so count[1] is always 0 */ - ctx.bits[0] = ((macTotalSize - macLeftSize) * 8); - ctx.bits[1] = 0; - - /* If HMAC - add size of Inner block (64 bytes) ro count[0] */ - if(pOuterIV != NULL) - ctx.bits[0] += (64 * 8); - - frag = mvCesaMbufOffset(pMbuf, offset, &fragOffset); - if(frag == MV_INVALID) - { - mvOsPrintf("CESA Mbuf Error: offset (%d) out of range\n", offset); - return; - } - - pData = pMbuf->pFrags[frag].bufVirtPtr + fragOffset; - size = pMbuf->pFrags[frag].bufSize - fragOffset; - - /* Complete Inner part */ - while(macLeftSize > 0) - { - if(macLeftSize <= size) - { - mvMD5Update(&ctx, pData, macLeftSize); - break; - } - mvMD5Update(&ctx, pData, size); - macLeftSize -= size; - frag++; - pData = pMbuf->pFrags[frag].bufVirtPtr; - size = pMbuf->pFrags[frag].bufSize; - } - mvMD5Final(pDigest, &ctx); - -/* - mvOsPrintf("mvCesaFragMd5Complete: pOuterIV=%p, macLeftSize=%d, macTotalSize=%d\n", - pOuterIV, macLeftSize, macTotalSize); - mvDebugMemDump(pDigest, MV_CESA_MD5_DIGEST_SIZE, 1); -*/ - if(pOuterIV != NULL) - { - /* Complete Outer part */ - for(i=0; i<MV_CESA_MD5_DIGEST_SIZE/4; i++) - { -#if defined(MV_CPU_LE) || defined(MV_ARM) - ctx.buf[i] = MV_BYTE_SWAP_32BIT(((MV_U32*)pOuterIV)[i]); -#else - ctx.buf[i] = ((MV_U32*)pOuterIV)[i]; -#endif - } - memset(ctx.in, 0, 64); - - ctx.bits[0] = 64*8; - ctx.bits[1] = 0; - mvMD5Update(&ctx, pDigest, MV_CESA_MD5_DIGEST_SIZE); - mvMD5Final(pDigest, &ctx); - } -} - -/******************************************************************************* -* mvCesaFragAuthComplete - -* -* DESCRIPTION: -* -* -* INPUT: -* MV_CESA_REQ* pReq, -* MV_CESA_SA* pSA, -* int macDataSize -* -* RETURN: -* MV_STATUS -* -*******************************************************************************/ -static MV_STATUS mvCesaFragAuthComplete(MV_CESA_REQ* pReq, MV_CESA_SA* pSA, - int macDataSize) -{ - MV_CESA_COMMAND* pCmd = pReq->pCmd; - MV_U8* pDigest; - MV_CESA_MAC_MODE macMode; - MV_U8* pOuterIV = NULL; - - /* Copy data from Source fragment to Destination */ - if(pCmd->pSrc != pCmd->pDst) - { - mvCesaMbufCopy(pCmd->pDst, pReq->frags.bufOffset, - pCmd->pSrc, pReq->frags.bufOffset, macDataSize); - } - -/* - mvCesaCopyFromMbuf(cesaSramVirtPtr->buf[0], pCmd->pSrc, pReq->frags.bufOffset, macDataSize); - mvCesaCopyToMbuf(cesaSramVirtPtr->buf[0], pCmd->pDst, pReq->frags.bufOffset, macDataSize); -*/ - pDigest = (mvCesaSramAddrGet() + pReq->frags.newDigestOffset); - - macMode = (pSA->config & MV_CESA_MAC_MODE_MASK) >> MV_CESA_MAC_MODE_OFFSET; -/* - mvOsPrintf("macDataSize=%d, macLength=%d, digestOffset=%d, macMode=%d\n", - macDataSize, pCmd->macLength, pCmd->digestOffset, macMode); -*/ - switch(macMode) - { - case MV_CESA_MAC_HMAC_MD5: - pOuterIV = pSA->pSramSA->macOuterIV; - - case MV_CESA_MAC_MD5: - mvCesaFragMd5Complete(pCmd->pDst, pReq->frags.bufOffset, pOuterIV, - macDataSize, pCmd->macLength, pDigest); - break; - - case MV_CESA_MAC_HMAC_SHA1: - pOuterIV = pSA->pSramSA->macOuterIV; - - case MV_CESA_MAC_SHA1: - mvCesaFragSha1Complete(pCmd->pDst, pReq->frags.bufOffset, pOuterIV, - macDataSize, pCmd->macLength, pDigest); - break; - - default: - mvOsPrintf("mvCesaFragAuthComplete: Unexpected macMode %d\n", macMode); - return MV_BAD_PARAM; - } - return MV_OK; -} - -/******************************************************************************* -* mvCesaCtrModeInit - -* -* DESCRIPTION: -* -* -* INPUT: NONE -* -* -* RETURN: -* MV_CESA_COMMAND* -* -*******************************************************************************/ -static MV_CESA_COMMAND* mvCesaCtrModeInit(void) -{ - MV_CESA_MBUF *pMbuf; - MV_U8 *pBuf; - MV_CESA_COMMAND *pCmd; - - pBuf = mvOsMalloc(sizeof(MV_CESA_COMMAND) + - sizeof(MV_CESA_MBUF) + sizeof(MV_BUF_INFO) + 100); - if(pBuf == NULL) - { - mvOsPrintf("mvCesaSessionOpen: Can't allocate %u bytes for CTR Mode\n", - sizeof(MV_CESA_COMMAND) + sizeof(MV_CESA_MBUF) + sizeof(MV_BUF_INFO) ); - return NULL; - } - pCmd = (MV_CESA_COMMAND*)pBuf; - pBuf += sizeof(MV_CESA_COMMAND); - - pMbuf = (MV_CESA_MBUF*)pBuf; - pBuf += sizeof(MV_CESA_MBUF); - - pMbuf->pFrags = (MV_BUF_INFO*)pBuf; - - pMbuf->numFrags = 1; - pCmd->pSrc = pMbuf; - pCmd->pDst = pMbuf; -/* - mvOsPrintf("CtrModeInit: pCmd=%p, pSrc=%p, pDst=%p, pFrags=%p\n", - pCmd, pCmd->pSrc, pCmd->pDst, - pMbuf->pFrags); -*/ - return pCmd; -} - -/******************************************************************************* -* mvCesaCtrModePrepare - -* -* DESCRIPTION: -* -* -* INPUT: -* MV_CESA_COMMAND *pCtrModeCmd, MV_CESA_COMMAND *pCmd -* -* RETURN: -* MV_STATUS -* -*******************************************************************************/ -static MV_STATUS mvCesaCtrModePrepare(MV_CESA_COMMAND *pCtrModeCmd, MV_CESA_COMMAND *pCmd) -{ - MV_CESA_MBUF *pMbuf; - MV_U8 *pBuf, *pIV; - MV_U32 counter, *pCounter; - int cryptoSize = MV_ALIGN_UP(pCmd->cryptoLength, MV_CESA_AES_BLOCK_SIZE); -/* - mvOsPrintf("CtrModePrepare: pCmd=%p, pCtrSrc=%p, pCtrDst=%p, pOrgCmd=%p, pOrgSrc=%p, pOrgDst=%p\n", - pCmd, pCmd->pSrc, pCmd->pDst, - pCtrModeCmd, pCtrModeCmd->pSrc, pCtrModeCmd->pDst); -*/ - pMbuf = pCtrModeCmd->pSrc; - - /* Allocate buffer for Key stream */ - pBuf = mvOsIoCachedMalloc(cesaOsHandle,cryptoSize, - &pMbuf->pFrags[0].bufPhysAddr, - &pMbuf->pFrags[0].memHandle); - if(pBuf == NULL) - { - mvOsPrintf("mvCesaCtrModePrepare: Can't allocate %d bytes\n", cryptoSize); - return MV_OUT_OF_CPU_MEM; - } - memset(pBuf, 0, cryptoSize); - mvOsCacheFlush(NULL, pBuf, cryptoSize); - - pMbuf->pFrags[0].bufVirtPtr = pBuf; - pMbuf->mbufSize = cryptoSize; - pMbuf->pFrags[0].bufSize = cryptoSize; - - pCtrModeCmd->pReqPrv = pCmd->pReqPrv; - pCtrModeCmd->sessionId = pCmd->sessionId; - - /* ivFromUser and ivOffset are don't care */ - pCtrModeCmd->cryptoOffset = 0; - pCtrModeCmd->cryptoLength = cryptoSize; - - /* digestOffset, macOffset and macLength are don't care */ - - mvCesaCopyFromMbuf(pBuf, pCmd->pSrc, pCmd->ivOffset, MV_CESA_AES_BLOCK_SIZE); - pCounter = (MV_U32*)(pBuf + (MV_CESA_AES_BLOCK_SIZE - sizeof(counter))); - counter = *pCounter; - counter = MV_32BIT_BE(counter); - pIV = pBuf; - cryptoSize -= MV_CESA_AES_BLOCK_SIZE; - - /* fill key stream */ - while(cryptoSize > 0) - { - pBuf += MV_CESA_AES_BLOCK_SIZE; - memcpy(pBuf, pIV, MV_CESA_AES_BLOCK_SIZE - sizeof(counter)); - pCounter = (MV_U32*)(pBuf + (MV_CESA_AES_BLOCK_SIZE - sizeof(counter))); - counter++; - *pCounter = MV_32BIT_BE(counter); - cryptoSize -= MV_CESA_AES_BLOCK_SIZE; - } - - return MV_OK; -} - -/******************************************************************************* -* mvCesaCtrModeComplete - -* -* DESCRIPTION: -* -* -* INPUT: -* MV_CESA_COMMAND *pOrgCmd, MV_CESA_COMMAND *pCmd -* -* RETURN: -* MV_STATUS -* -*******************************************************************************/ -static MV_STATUS mvCesaCtrModeComplete(MV_CESA_COMMAND *pOrgCmd, MV_CESA_COMMAND *pCmd) -{ - int srcFrag, dstFrag, srcOffset, dstOffset, keyOffset, srcSize, dstSize; - int cryptoSize = pCmd->cryptoLength; - MV_U8 *pSrc, *pDst, *pKey; - MV_STATUS status = MV_OK; -/* - mvOsPrintf("CtrModeComplete: pCmd=%p, pCtrSrc=%p, pCtrDst=%p, pOrgCmd=%p, pOrgSrc=%p, pOrgDst=%p\n", - pCmd, pCmd->pSrc, pCmd->pDst, - pOrgCmd, pOrgCmd->pSrc, pOrgCmd->pDst); -*/ - /* XOR source data with key stream to destination data */ - pKey = pCmd->pDst->pFrags[0].bufVirtPtr; - keyOffset = 0; - - if( (pOrgCmd->pSrc != pOrgCmd->pDst) && - (pOrgCmd->cryptoOffset > 0) ) - { - /* Copy Prefix from source buffer to destination buffer */ - - status = mvCesaMbufCopy(pOrgCmd->pDst, 0, - pOrgCmd->pSrc, 0, pOrgCmd->cryptoOffset); -/* - status = mvCesaCopyFromMbuf(tempBuf, pOrgCmd->pSrc, - 0, pOrgCmd->cryptoOffset); - status = mvCesaCopyToMbuf(tempBuf, pOrgCmd->pDst, - 0, pOrgCmd->cryptoOffset); -*/ - } - - srcFrag = mvCesaMbufOffset(pOrgCmd->pSrc, pOrgCmd->cryptoOffset, &srcOffset); - pSrc = pOrgCmd->pSrc->pFrags[srcFrag].bufVirtPtr; - srcSize = pOrgCmd->pSrc->pFrags[srcFrag].bufSize; - - dstFrag = mvCesaMbufOffset(pOrgCmd->pDst, pOrgCmd->cryptoOffset, &dstOffset); - pDst = pOrgCmd->pDst->pFrags[dstFrag].bufVirtPtr; - dstSize = pOrgCmd->pDst->pFrags[dstFrag].bufSize; - - while(cryptoSize > 0) - { - pDst[dstOffset] = (pSrc[srcOffset] ^ pKey[keyOffset]); - - cryptoSize--; - dstOffset++; - srcOffset++; - keyOffset++; - - if(srcOffset >= srcSize) - { - srcFrag++; - srcOffset = 0; - pSrc = pOrgCmd->pSrc->pFrags[srcFrag].bufVirtPtr; - srcSize = pOrgCmd->pSrc->pFrags[srcFrag].bufSize; - } - - if(dstOffset >= dstSize) - { - dstFrag++; - dstOffset = 0; - pDst = pOrgCmd->pDst->pFrags[dstFrag].bufVirtPtr; - dstSize = pOrgCmd->pDst->pFrags[dstFrag].bufSize; - } - } - - if(pOrgCmd->pSrc != pOrgCmd->pDst) - { - /* Copy Suffix from source buffer to destination buffer */ - srcOffset = pOrgCmd->cryptoOffset + pOrgCmd->cryptoLength; - - if( (pOrgCmd->pDst->mbufSize - srcOffset) > 0) - { - status = mvCesaMbufCopy(pOrgCmd->pDst, srcOffset, - pOrgCmd->pSrc, srcOffset, - pOrgCmd->pDst->mbufSize - srcOffset); - } - -/* - status = mvCesaCopyFromMbuf(tempBuf, pOrgCmd->pSrc, - srcOffset, pOrgCmd->pSrc->mbufSize - srcOffset); - status = mvCesaCopyToMbuf(tempBuf, pOrgCmd->pDst, - srcOffset, pOrgCmd->pDst->mbufSize - srcOffset); -*/ - } - - /* Free buffer used for Key stream */ - mvOsIoCachedFree(cesaOsHandle,pCmd->pDst->pFrags[0].bufSize, - pCmd->pDst->pFrags[0].bufPhysAddr, - pCmd->pDst->pFrags[0].bufVirtPtr, - pCmd->pDst->pFrags[0].memHandle); - - return MV_OK; -} - -/******************************************************************************* -* mvCesaCtrModeFinish - -* -* DESCRIPTION: -* -* -* INPUT: -* MV_CESA_COMMAND* pCmd -* -* RETURN: -* MV_STATUS -* -*******************************************************************************/ -static void mvCesaCtrModeFinish(MV_CESA_COMMAND* pCmd) -{ - mvOsFree(pCmd); -} - -/******************************************************************************* -* mvCesaParamCheck - -* -* DESCRIPTION: -* -* -* INPUT: -* MV_CESA_SA* pSA, MV_CESA_COMMAND *pCmd, MV_U8* pFixOffset -* -* RETURN: -* MV_STATUS -* -*******************************************************************************/ -static MV_STATUS mvCesaParamCheck(MV_CESA_SA* pSA, MV_CESA_COMMAND *pCmd, - MV_U8* pFixOffset) -{ - MV_U8 fixOffset = 0xFF; - - /* Check AUTH operation parameters */ - if( ((pSA->config & MV_CESA_OPERATION_MASK) != - (MV_CESA_CRYPTO_ONLY << MV_CESA_OPERATION_OFFSET)) ) - { - /* MAC offset should be at least 4 byte aligned */ - if( MV_IS_NOT_ALIGN(pCmd->macOffset, 4) ) - { - mvOsPrintf("mvCesaAction: macOffset %d must be 4 byte aligned\n", - pCmd->macOffset); - return MV_BAD_PARAM; - } - /* Digest offset must be 4 byte aligned */ - if( MV_IS_NOT_ALIGN(pCmd->digestOffset, 4) ) - { - mvOsPrintf("mvCesaAction: digestOffset %d must be 4 byte aligned\n", - pCmd->digestOffset); - return MV_BAD_PARAM; - } - /* In addition all offsets should be the same alignment: 8 or 4 */ - if(fixOffset == 0xFF) - { - fixOffset = (pCmd->macOffset % 8); - } - else - { - if( (pCmd->macOffset % 8) != fixOffset) - { - mvOsPrintf("mvCesaAction: macOffset %d mod 8 must be equal %d\n", - pCmd->macOffset, fixOffset); - return MV_BAD_PARAM; - } - } - if( (pCmd->digestOffset % 8) != fixOffset) - { - mvOsPrintf("mvCesaAction: digestOffset %d mod 8 must be equal %d\n", - pCmd->digestOffset, fixOffset); - return MV_BAD_PARAM; - } - } - /* Check CRYPTO operation parameters */ - if( ((pSA->config & MV_CESA_OPERATION_MASK) != - (MV_CESA_MAC_ONLY << MV_CESA_OPERATION_OFFSET)) ) - { - /* CryptoOffset should be at least 4 byte aligned */ - if( MV_IS_NOT_ALIGN(pCmd->cryptoOffset, 4) ) - { - mvOsPrintf("CesaAction: cryptoOffset=%d must be 4 byte aligned\n", - pCmd->cryptoOffset); - return MV_BAD_PARAM; - } - /* cryptoLength should be the whole number of blocks */ - if( MV_IS_NOT_ALIGN(pCmd->cryptoLength, pSA->cryptoBlockSize) ) - { - mvOsPrintf("mvCesaAction: cryptoLength=%d must be %d byte aligned\n", - pCmd->cryptoLength, pSA->cryptoBlockSize); - return MV_BAD_PARAM; - } - if(fixOffset == 0xFF) - { - fixOffset = (pCmd->cryptoOffset % 8); - } - else - { - /* In addition all offsets should be the same alignment: 8 or 4 */ - if( (pCmd->cryptoOffset % 8) != fixOffset) - { - mvOsPrintf("mvCesaAction: cryptoOffset %d mod 8 must be equal %d \n", - pCmd->cryptoOffset, fixOffset); - return MV_BAD_PARAM; - } - } - - /* check for CBC mode */ - if(pSA->cryptoIvSize > 0) - { - /* cryptoIV must not be part of CryptoLength */ - if( ((pCmd->ivOffset + pSA->cryptoIvSize) > pCmd->cryptoOffset) && - (pCmd->ivOffset < (pCmd->cryptoOffset + pCmd->cryptoLength)) ) - { - mvOsPrintf("mvCesaFragParamCheck: cryptoIvOffset (%d) is part of cryptoLength (%d+%d)\n", - pCmd->ivOffset, pCmd->macOffset, pCmd->macLength); - return MV_BAD_PARAM; - } - - /* ivOffset must be 4 byte aligned */ - if( MV_IS_NOT_ALIGN(pCmd->ivOffset, 4) ) - { - mvOsPrintf("CesaAction: ivOffset=%d must be 4 byte aligned\n", - pCmd->ivOffset); - return MV_BAD_PARAM; - } - /* In addition all offsets should be the same alignment: 8 or 4 */ - if( (pCmd->ivOffset % 8) != fixOffset) - { - mvOsPrintf("mvCesaAction: ivOffset %d mod 8 must be %d\n", - pCmd->ivOffset, fixOffset); - return MV_BAD_PARAM; - } - } - } - return MV_OK; -} - -/******************************************************************************* -* mvCesaFragParamCheck - -* -* DESCRIPTION: -* -* -* INPUT: -* MV_CESA_SA* pSA, MV_CESA_COMMAND *pCmd -* -* RETURN: -* MV_STATUS -* -*******************************************************************************/ -static MV_STATUS mvCesaFragParamCheck(MV_CESA_SA* pSA, MV_CESA_COMMAND *pCmd) -{ - int offset; - - if( ((pSA->config & MV_CESA_OPERATION_MASK) != - (MV_CESA_CRYPTO_ONLY << MV_CESA_OPERATION_OFFSET)) ) - { - /* macOffset must be less that SRAM buffer size */ - if(pCmd->macOffset > (sizeof(cesaSramVirtPtr->buf) - MV_CESA_AUTH_BLOCK_SIZE)) - { - mvOsPrintf("mvCesaFragParamCheck: macOffset is too large (%d)\n", - pCmd->macOffset); - return MV_BAD_PARAM; - } - /* macOffset+macSize must be more than mbufSize - SRAM buffer size */ - if( ((pCmd->macOffset + pCmd->macLength) > pCmd->pSrc->mbufSize) || - ((pCmd->pSrc->mbufSize - (pCmd->macOffset + pCmd->macLength)) >= - sizeof(cesaSramVirtPtr->buf)) ) - { - mvOsPrintf("mvCesaFragParamCheck: macLength is too large (%d), mbufSize=%d\n", - pCmd->macLength, pCmd->pSrc->mbufSize); - return MV_BAD_PARAM; - } - } - - if( ((pSA->config & MV_CESA_OPERATION_MASK) != - (MV_CESA_MAC_ONLY << MV_CESA_OPERATION_OFFSET)) ) - { - /* cryptoOffset must be less that SRAM buffer size */ - /* 4 for possible fixOffset */ - if( (pCmd->cryptoOffset + 4) > (sizeof(cesaSramVirtPtr->buf) - pSA->cryptoBlockSize)) - { - mvOsPrintf("mvCesaFragParamCheck: cryptoOffset is too large (%d)\n", - pCmd->cryptoOffset); - return MV_BAD_PARAM; - } - - /* cryptoOffset+cryptoSize must be more than mbufSize - SRAM buffer size */ - if( ((pCmd->cryptoOffset + pCmd->cryptoLength) > pCmd->pSrc->mbufSize) || - ((pCmd->pSrc->mbufSize - (pCmd->cryptoOffset + pCmd->cryptoLength)) >= - (sizeof(cesaSramVirtPtr->buf) - pSA->cryptoBlockSize)) ) - { - mvOsPrintf("mvCesaFragParamCheck: cryptoLength is too large (%d), mbufSize=%d\n", - pCmd->cryptoLength, pCmd->pSrc->mbufSize); - return MV_BAD_PARAM; - } - } - - /* When MAC_THEN_CRYPTO or CRYPTO_THEN_MAC */ - if( ((pSA->config & MV_CESA_OPERATION_MASK) == - (MV_CESA_MAC_THEN_CRYPTO << MV_CESA_OPERATION_OFFSET)) || - ((pSA->config & MV_CESA_OPERATION_MASK) == - (MV_CESA_CRYPTO_THEN_MAC << MV_CESA_OPERATION_OFFSET)) ) - { - if( (mvCtrlModelGet() == MV_5182_DEV_ID) || - ( (mvCtrlModelGet() == MV_5181_DEV_ID) && - (mvCtrlRevGet() >= MV_5181L_A0_REV) && - (pCmd->macLength >= (1 << 14)) ) ) - { - return MV_NOT_ALLOWED; - } - - /* abs(cryptoOffset-macOffset) must be aligned cryptoBlockSize */ - if(pCmd->cryptoOffset > pCmd->macOffset) - { - offset = pCmd->cryptoOffset - pCmd->macOffset; - } - else - { - offset = pCmd->macOffset - pCmd->cryptoOffset; - } - - if( MV_IS_NOT_ALIGN(offset, pSA->cryptoBlockSize) ) - { -/* - mvOsPrintf("mvCesaFragParamCheck: (cryptoOffset - macOffset) must be %d byte aligned\n", - pSA->cryptoBlockSize); -*/ - return MV_NOT_ALLOWED; - } - /* Digest must not be part of CryptoLength */ - if( ((pCmd->digestOffset + pSA->digestSize) > pCmd->cryptoOffset) && - (pCmd->digestOffset < (pCmd->cryptoOffset + pCmd->cryptoLength)) ) - { -/* - mvOsPrintf("mvCesaFragParamCheck: digestOffset (%d) is part of cryptoLength (%d+%d)\n", - pCmd->digestOffset, pCmd->cryptoOffset, pCmd->cryptoLength); -*/ - return MV_NOT_ALLOWED; - } - } - return MV_OK; -} - -/******************************************************************************* -* mvCesaFragSizeFind - -* -* DESCRIPTION: -* -* -* INPUT: -* MV_CESA_SA* pSA, MV_CESA_COMMAND *pCmd, -* int cryptoOffset, int macOffset, -* -* OUTPUT: -* int* pCopySize, int* pCryptoDataSize, int* pMacDataSize -* -* RETURN: -* MV_STATUS -* -*******************************************************************************/ -static void mvCesaFragSizeFind(MV_CESA_SA* pSA, MV_CESA_REQ* pReq, - int cryptoOffset, int macOffset, - int* pCopySize, int* pCryptoDataSize, int* pMacDataSize) -{ - MV_CESA_COMMAND *pCmd = pReq->pCmd; - int cryptoDataSize, macDataSize, copySize; - - cryptoDataSize = macDataSize = 0; - copySize = *pCopySize; - - if( (pSA->config & MV_CESA_OPERATION_MASK) != - (MV_CESA_MAC_ONLY << MV_CESA_OPERATION_OFFSET) ) - { - cryptoDataSize = MV_MIN( (copySize - cryptoOffset), - (pCmd->cryptoLength - (pReq->frags.cryptoSize + 1)) ); - - /* cryptoSize for each fragment must be the whole number of blocksSize */ - if( MV_IS_NOT_ALIGN(cryptoDataSize, pSA->cryptoBlockSize) ) - { - cryptoDataSize = MV_ALIGN_DOWN(cryptoDataSize, pSA->cryptoBlockSize); - copySize = cryptoOffset + cryptoDataSize; - } - } - if( (pSA->config & MV_CESA_OPERATION_MASK) != - (MV_CESA_CRYPTO_ONLY << MV_CESA_OPERATION_OFFSET) ) - { - macDataSize = MV_MIN( (copySize - macOffset), - (pCmd->macLength - (pReq->frags.macSize + 1))); - - /* macSize for each fragment (except last) must be the whole number of blocksSize */ - if( MV_IS_NOT_ALIGN(macDataSize, MV_CESA_AUTH_BLOCK_SIZE) ) - { - macDataSize = MV_ALIGN_DOWN(macDataSize, MV_CESA_AUTH_BLOCK_SIZE); - copySize = macOffset + macDataSize; - } - cryptoDataSize = copySize - cryptoOffset; - } - *pCopySize = copySize; - - if(pCryptoDataSize != NULL) - *pCryptoDataSize = cryptoDataSize; - - if(pMacDataSize != NULL) - *pMacDataSize = macDataSize; -} diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvCesa.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvCesa.h deleted file mode 100644 index 115274f..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvCesa.h +++ /dev/null @@ -1,412 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -/******************************************************************************* -* mvCesa.h - Header File for Cryptographic Engines and Security Accelerator -* -* DESCRIPTION: -* This header file contains macros typedefs and function declaration for -* the Marvell Cryptographic Engines and Security Accelerator. -* -*******************************************************************************/ - -#ifndef __mvCesa_h__ -#define __mvCesa_h__ - -#include "mvOs.h" -#include "mvCommon.h" -#include "mvDebug.h" - -#include "ctrlEnv/mvCtrlEnvSpec.h" - -#include "cesa/mvMD5.h" -#include "cesa/mvSHA1.h" - -#include "cesa/mvCesa.h" -#include "cesa/AES/mvAes.h" -#include "mvSysHwConfig.h" - -#ifdef MV_INCLUDE_IDMA -#include "idma/mvIdma.h" -#include "idma/mvIdmaRegs.h" -#else -/* Redefine MV_DMA_DESC structure */ -typedef struct _mvDmaDesc -{ - MV_U32 byteCnt; /* The total number of bytes to transfer */ - MV_U32 phySrcAdd; /* The physical source address */ - MV_U32 phyDestAdd; /* The physical destination address */ - MV_U32 phyNextDescPtr; /* If we are using chain mode DMA transfer, */ - /* then this pointer should point to the */ - /* physical address of the next descriptor, */ - /* otherwise it should be NULL. */ -}MV_DMA_DESC; -#endif /* MV_INCLUDE_IDMA */ - -#include "cesa/mvCesaRegs.h" - -#define MV_CESA_AUTH_BLOCK_SIZE 64 /* bytes */ - -#define MV_CESA_MD5_DIGEST_SIZE 16 /* bytes */ -#define MV_CESA_SHA1_DIGEST_SIZE 20 /* bytes */ - -#define MV_CESA_MAX_DIGEST_SIZE MV_CESA_SHA1_DIGEST_SIZE - -#define MV_CESA_DES_KEY_LENGTH 8 /* bytes = 64 bits */ -#define MV_CESA_3DES_KEY_LENGTH 24 /* bytes = 192 bits */ -#define MV_CESA_AES_128_KEY_LENGTH 16 /* bytes = 128 bits */ -#define MV_CESA_AES_192_KEY_LENGTH 24 /* bytes = 192 bits */ -#define MV_CESA_AES_256_KEY_LENGTH 32 /* bytes = 256 bits */ - -#define MV_CESA_MAX_CRYPTO_KEY_LENGTH MV_CESA_AES_256_KEY_LENGTH - -#define MV_CESA_DES_BLOCK_SIZE 8 /* bytes = 64 bits */ -#define MV_CESA_3DES_BLOCK_SIZE 8 /* bytes = 64 bits */ - -#define MV_CESA_AES_BLOCK_SIZE 16 /* bytes = 128 bits */ - -#define MV_CESA_MAX_IV_LENGTH MV_CESA_AES_BLOCK_SIZE - -#define MV_CESA_MAX_MAC_KEY_LENGTH 64 /* bytes */ - -typedef struct -{ - MV_U8 cryptoKey[MV_CESA_MAX_CRYPTO_KEY_LENGTH]; - MV_U8 macKey[MV_CESA_MAX_MAC_KEY_LENGTH]; - MV_CESA_OPERATION operation; - MV_CESA_DIRECTION direction; - MV_CESA_CRYPTO_ALG cryptoAlgorithm; - MV_CESA_CRYPTO_MODE cryptoMode; - MV_U8 cryptoKeyLength; - MV_CESA_MAC_MODE macMode; - MV_U8 macKeyLength; - MV_U8 digestSize; - -} MV_CESA_OPEN_SESSION; - -typedef struct -{ - MV_BUF_INFO *pFrags; - MV_U16 numFrags; - MV_U16 mbufSize; - -} MV_CESA_MBUF; - -typedef struct -{ - void* pReqPrv; /* instead of reqId */ - MV_U32 retCode; - MV_16 sessionId; - -} MV_CESA_RESULT; - -typedef void (*MV_CESA_CALLBACK) (MV_CESA_RESULT* pResult); - - -typedef struct -{ - void* pReqPrv; /* instead of reqId */ - MV_CESA_MBUF* pSrc; - MV_CESA_MBUF* pDst; - MV_CESA_CALLBACK* pFuncCB; - MV_16 sessionId; - MV_U16 ivFromUser; - MV_U16 ivOffset; - MV_U16 cryptoOffset; - MV_U16 cryptoLength; - MV_U16 digestOffset; - MV_U16 macOffset; - MV_U16 macLength; - MV_BOOL skipFlush; -} MV_CESA_COMMAND; - - - -MV_STATUS mvCesaHalInit (int numOfSession, int queueDepth, char* pSramBase, MV_U32 cryptEngBase, void *osHandle); -MV_STATUS mvCesaFinish (void); -MV_STATUS mvCesaSessionOpen(MV_CESA_OPEN_SESSION *pSession, short* pSid); -MV_STATUS mvCesaSessionClose(short sid); -MV_STATUS mvCesaCryptoIvSet(MV_U8* pIV, int ivSize); - -MV_STATUS mvCesaAction (MV_CESA_COMMAND* pCmd); - -MV_U32 mvCesaInProcessGet(void); -MV_STATUS mvCesaReadyDispatch(void); -MV_STATUS mvCesaReadyGet(MV_CESA_RESULT* pResult); -MV_BOOL mvCesaIsReady(void); - -int mvCesaMbufOffset(MV_CESA_MBUF* pMbuf, int offset, int* pBufOffset); -MV_STATUS mvCesaCopyFromMbuf(MV_U8* pDst, MV_CESA_MBUF* pSrcMbuf, - int offset, int size); -MV_STATUS mvCesaCopyToMbuf(MV_U8* pSrc, MV_CESA_MBUF* pDstMbuf, - int offset, int size); -MV_STATUS mvCesaMbufCopy(MV_CESA_MBUF* pMbufDst, int dstMbufOffset, - MV_CESA_MBUF* pMbufSrc, int srcMbufOffset, int size); - -/********** Debug functions ********/ - -void mvCesaDebugMbuf(const char* str, MV_CESA_MBUF *pMbuf, int offset, int size); -void mvCesaDebugSA(short sid, int mode); -void mvCesaDebugStats(void); -void mvCesaDebugStatsClear(void); -void mvCesaDebugRegs(void); -void mvCesaDebugStatus(void); -void mvCesaDebugQueue(int mode); -void mvCesaDebugSram(int mode); -void mvCesaDebugSAD(int mode); - - -/******** CESA Private definitions ********/ -#if (MV_CESA_VERSION >= 2) -#if (MV_CACHE_COHERENCY == MV_CACHE_COHER_SW) -#define MV_CESA_TDMA_CTRL_VALUE MV_CESA_TDMA_DST_BURST_MASK(MV_CESA_TDMA_BURST_128B) \ - | MV_CESA_TDMA_SRC_BURST_MASK(MV_CESA_TDMA_BURST_128B) \ - | MV_CESA_TDMA_OUTSTAND_READ_EN_MASK \ - | MV_CESA_TDMA_NO_BYTE_SWAP_MASK \ - | MV_CESA_TDMA_ENABLE_MASK -#else -#define MV_CESA_TDMA_CTRL_VALUE MV_CESA_TDMA_DST_BURST_MASK(MV_CESA_TDMA_BURST_32B) \ - | MV_CESA_TDMA_SRC_BURST_MASK(MV_CESA_TDMA_BURST_128B) \ - /*| MV_CESA_TDMA_OUTSTAND_READ_EN_MASK */\ - | MV_CESA_TDMA_ENABLE_MASK - -#endif -#else -#define MV_CESA_IDMA_CTRL_LOW_VALUE ICCLR_DST_BURST_LIM_128BYTE \ - | ICCLR_SRC_BURST_LIM_128BYTE \ - | ICCLR_INT_MODE_MASK \ - | ICCLR_BLOCK_MODE \ - | ICCLR_CHAN_ENABLE \ - | ICCLR_DESC_MODE_16M -#endif /* MV_CESA_VERSION >= 2 */ - -#define MV_CESA_MAX_PKT_SIZE (64 * 1024) -#define MV_CESA_MAX_MBUF_FRAGS 20 - -#define MV_CESA_MAX_REQ_FRAGS ( (MV_CESA_MAX_PKT_SIZE / MV_CESA_MAX_BUF_SIZE) + 1) - -#define MV_CESA_MAX_DMA_DESC (MV_CESA_MAX_MBUF_FRAGS*2 + 5) - -#define MAX_CESA_CHAIN_LENGTH 20 - -typedef enum -{ - MV_CESA_IDLE = 0, - MV_CESA_PENDING, - MV_CESA_PROCESS, - MV_CESA_READY, -#if (MV_CESA_VERSION >= 3) - MV_CESA_CHAIN, -#endif -} MV_CESA_STATE; - - -/* Session database */ - -/* Map of Key materials of the session in SRAM. - * Each field must be 8 byte aligned - * Total size: 32 + 24 + 24 = 80 bytes - */ -typedef struct -{ - MV_U8 cryptoKey[MV_CESA_MAX_CRYPTO_KEY_LENGTH]; - MV_U8 macInnerIV[MV_CESA_MAX_DIGEST_SIZE]; - MV_U8 reservedInner[4]; - MV_U8 macOuterIV[MV_CESA_MAX_DIGEST_SIZE]; - MV_U8 reservedOuter[4]; - -} MV_CESA_SRAM_SA; - -typedef struct -{ - MV_CESA_SRAM_SA* pSramSA; - MV_U32 config; - MV_U8 cryptoKeyLength; - MV_U8 cryptoIvSize; - MV_U8 cryptoBlockSize; - MV_U8 digestSize; - MV_U8 macKeyLength; - MV_U8 valid; - MV_U8 ctrMode; - MV_U32 count; - -} MV_CESA_SA; - -/* DMA list management */ -typedef struct -{ - MV_DMA_DESC* pDmaFirst; - MV_DMA_DESC* pDmaLast; - -} MV_CESA_DMA; - - -typedef struct -{ - MV_U8 numFrag; - MV_U8 nextFrag; - int bufOffset; - int cryptoSize; - int macSize; - int newDigestOffset; - MV_U8 orgDigest[MV_CESA_MAX_DIGEST_SIZE]; - -} MV_CESA_FRAGS; - -/* Request queue */ -typedef struct -{ - MV_U8 state; - MV_U8 fragMode; - MV_U8 fixOffset; - MV_CESA_COMMAND* pCmd; - MV_CESA_COMMAND* pOrgCmd; - MV_BUF_INFO dmaDescBuf; - MV_CESA_DMA dma[MV_CESA_MAX_REQ_FRAGS]; - MV_BUF_INFO cesaDescBuf; - MV_CESA_DESC* pCesaDesc; - MV_CESA_FRAGS frags; - - -} MV_CESA_REQ; - - -/* SRAM map */ -/* Total SRAM size calculation */ -/* SRAM size = - * MV_CESA_MAX_BUF_SIZE + - * sizeof(MV_CESA_DESC) + - * MV_CESA_MAX_IV_LENGTH + - * MV_CESA_MAX_IV_LENGTH + - * MV_CESA_MAX_DIGEST_SIZE + - * sizeof(MV_CESA_SRAM_SA) - * = 1600 + 32 + 16 + 16 + 24 + 80 + 280 (reserved) = 2048 bytes - * = 3200 + 32 + 16 + 16 + 24 + 80 + 728 (reserved) = 4096 bytes - */ -typedef struct -{ - MV_U8 buf[MV_CESA_MAX_BUF_SIZE]; - MV_CESA_DESC desc; - MV_U8 cryptoIV[MV_CESA_MAX_IV_LENGTH]; - MV_U8 tempCryptoIV[MV_CESA_MAX_IV_LENGTH]; - MV_U8 tempDigest[MV_CESA_MAX_DIGEST_SIZE+4]; - MV_CESA_SRAM_SA sramSA; - -} MV_CESA_SRAM_MAP; - - -typedef struct -{ - MV_U32 openedCount; - MV_U32 closedCount; - MV_U32 fragCount; - MV_U32 reqCount; - MV_U32 maxReqCount; - MV_U32 procCount; - MV_U32 readyCount; - MV_U32 notReadyCount; - MV_U32 startCount; -#if (MV_CESA_VERSION >= 3) - MV_U32 maxChainUsage; -#endif - -} MV_CESA_STATS; - - -/* External variables */ - -extern MV_CESA_STATS cesaStats; -extern MV_CESA_FRAGS cesaFrags; - -extern MV_BUF_INFO cesaSramSaBuf; - -extern MV_CESA_SA* pCesaSAD; -extern MV_U16 cesaMaxSA; - -extern MV_CESA_REQ* pCesaReqFirst; -extern MV_CESA_REQ* pCesaReqLast; -extern MV_CESA_REQ* pCesaReqEmpty; -extern MV_CESA_REQ* pCesaReqProcess; -extern int cesaQueueDepth; -extern int cesaReqResources; -#if (MV_CESA_VERSION>= 3) -extern MV_U32 cesaChainLength; -#endif - -extern MV_CESA_SRAM_MAP* cesaSramVirtPtr; -extern MV_U32 cesaSramPhysAddr; - -static INLINE MV_ULONG mvCesaVirtToPhys(MV_BUF_INFO* pBufInfo, void* pVirt) -{ - return (pBufInfo->bufPhysAddr + ((MV_U8*)pVirt - pBufInfo->bufVirtPtr)); -} - -/* Additional DEBUG functions */ -void mvCesaDebugSramSA(MV_CESA_SRAM_SA* pSramSA, int mode); -void mvCesaDebugCmd(MV_CESA_COMMAND* pCmd, int mode); -void mvCesaDebugDescriptor(MV_CESA_DESC* pDesc); - - - -#endif /* __mvCesa_h__ */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvCesaDebug.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvCesaDebug.c deleted file mode 100644 index 31b78a8..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvCesaDebug.c +++ /dev/null @@ -1,484 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#include "mvOs.h" -#include "mvDebug.h" - -#include "cesa/mvMD5.h" -#include "cesa/mvSHA1.h" - -#include "cesa/mvCesa.h" -#include "cesa/mvCesaRegs.h" -#include "cesa/AES/mvAes.h" - -static const char* mvCesaDebugStateStr(MV_CESA_STATE state) -{ - switch(state) - { - case MV_CESA_IDLE: - return "Idle"; - - case MV_CESA_PENDING: - return "Pend"; - - case MV_CESA_PROCESS: - return "Proc"; - - case MV_CESA_READY: - return "Ready"; - - default: - break; - } - return "Unknown"; -} - -static const char* mvCesaDebugOperStr(MV_CESA_OPERATION oper) -{ - switch(oper) - { - case MV_CESA_MAC_ONLY: - return "MacOnly"; - - case MV_CESA_CRYPTO_ONLY: - return "CryptoOnly"; - - case MV_CESA_MAC_THEN_CRYPTO: - return "MacCrypto"; - - case MV_CESA_CRYPTO_THEN_MAC: - return "CryptoMac"; - - default: - break; - } - return "Null"; -} - -static const char* mvCesaDebugCryptoAlgStr(MV_CESA_CRYPTO_ALG cryptoAlg) -{ - switch(cryptoAlg) - { - case MV_CESA_CRYPTO_DES: - return "DES"; - - case MV_CESA_CRYPTO_3DES: - return "3DES"; - - case MV_CESA_CRYPTO_AES: - return "AES"; - - default: - break; - } - return "Null"; -} - -static const char* mvCesaDebugMacModeStr(MV_CESA_MAC_MODE macMode) -{ - switch(macMode) - { - case MV_CESA_MAC_MD5: - return "MD5"; - - case MV_CESA_MAC_SHA1: - return "SHA1"; - - case MV_CESA_MAC_HMAC_MD5: - return "HMAC-MD5"; - - case MV_CESA_MAC_HMAC_SHA1: - return "HMAC_SHA1"; - - default: - break; - } - return "Null"; -} - -void mvCesaDebugCmd(MV_CESA_COMMAND* pCmd, int mode) -{ - mvOsPrintf("pCmd=%p, pReqPrv=%p, pSrc=%p, pDst=%p, pCB=%p, sid=%d\n", - pCmd, pCmd->pReqPrv, pCmd->pSrc, pCmd->pDst, - pCmd->pFuncCB, pCmd->sessionId); - mvOsPrintf("isUser=%d, ivOffs=%d, crOffs=%d, crLen=%d, digest=%d, macOffs=%d, macLen=%d\n", - pCmd->ivFromUser, pCmd->ivOffset, pCmd->cryptoOffset, pCmd->cryptoLength, - pCmd->digestOffset, pCmd->macOffset, pCmd->macLength); -} - -/* no need to use in tool */ -void mvCesaDebugMbuf(const char* str, MV_CESA_MBUF *pMbuf, int offset, int size) -{ - int frag, len, fragOffset; - - if(str != NULL) - mvOsPrintf("%s: pMbuf=%p, numFrags=%d, mbufSize=%d\n", - str, pMbuf, pMbuf->numFrags, pMbuf->mbufSize); - - frag = mvCesaMbufOffset(pMbuf, offset, &fragOffset); - if(frag == MV_INVALID) - { - mvOsPrintf("CESA Mbuf Error: offset (%d) out of range\n", offset); - return; - } - - for(; frag<pMbuf->numFrags; frag++) - { - mvOsPrintf("#%2d. bufVirt=%p, bufSize=%d\n", - frag, pMbuf->pFrags[frag].bufVirtPtr, - pMbuf->pFrags[frag].bufSize); - if(size > 0) - { - len = MV_MIN(pMbuf->pFrags[frag].bufSize, size); - mvDebugMemDump(pMbuf->pFrags[frag].bufVirtPtr+fragOffset, len, 1); - size -= len; - fragOffset = 0; - } - } -} - -void mvCesaDebugRegs(void) -{ - mvOsPrintf("\t CESA Registers:\n"); - - mvOsPrintf("MV_CESA_CMD_REG : 0x%X = 0x%08x\n", - MV_CESA_CMD_REG, - MV_REG_READ( MV_CESA_CMD_REG ) ); - - mvOsPrintf("MV_CESA_CHAN_DESC_OFFSET_REG : 0x%X = 0x%08x\n", - MV_CESA_CHAN_DESC_OFFSET_REG, - MV_REG_READ(MV_CESA_CHAN_DESC_OFFSET_REG) ); - - mvOsPrintf("MV_CESA_CFG_REG : 0x%X = 0x%08x\n", - MV_CESA_CFG_REG, - MV_REG_READ( MV_CESA_CFG_REG ) ); - - mvOsPrintf("MV_CESA_STATUS_REG : 0x%X = 0x%08x\n", - MV_CESA_STATUS_REG, - MV_REG_READ( MV_CESA_STATUS_REG ) ); - - mvOsPrintf("MV_CESA_ISR_CAUSE_REG : 0x%X = 0x%08x\n", - MV_CESA_ISR_CAUSE_REG, - MV_REG_READ( MV_CESA_ISR_CAUSE_REG ) ); - - mvOsPrintf("MV_CESA_ISR_MASK_REG : 0x%X = 0x%08x\n", - MV_CESA_ISR_MASK_REG, - MV_REG_READ( MV_CESA_ISR_MASK_REG ) ); -#if (MV_CESA_VERSION >= 2) - mvOsPrintf("MV_CESA_TDMA_CTRL_REG : 0x%X = 0x%08x\n", - MV_CESA_TDMA_CTRL_REG, - MV_REG_READ( MV_CESA_TDMA_CTRL_REG ) ); - - mvOsPrintf("MV_CESA_TDMA_BYTE_COUNT_REG : 0x%X = 0x%08x\n", - MV_CESA_TDMA_BYTE_COUNT_REG, - MV_REG_READ( MV_CESA_TDMA_BYTE_COUNT_REG ) ); - - mvOsPrintf("MV_CESA_TDMA_SRC_ADDR_REG : 0x%X = 0x%08x\n", - MV_CESA_TDMA_SRC_ADDR_REG, - MV_REG_READ( MV_CESA_TDMA_SRC_ADDR_REG ) ); - - mvOsPrintf("MV_CESA_TDMA_DST_ADDR_REG : 0x%X = 0x%08x\n", - MV_CESA_TDMA_DST_ADDR_REG, - MV_REG_READ( MV_CESA_TDMA_DST_ADDR_REG ) ); - - mvOsPrintf("MV_CESA_TDMA_NEXT_DESC_PTR_REG : 0x%X = 0x%08x\n", - MV_CESA_TDMA_NEXT_DESC_PTR_REG, - MV_REG_READ( MV_CESA_TDMA_NEXT_DESC_PTR_REG ) ); - - mvOsPrintf("MV_CESA_TDMA_CURR_DESC_PTR_REG : 0x%X = 0x%08x\n", - MV_CESA_TDMA_CURR_DESC_PTR_REG, - MV_REG_READ( MV_CESA_TDMA_CURR_DESC_PTR_REG ) ); - - mvOsPrintf("MV_CESA_TDMA_ERROR_CAUSE_REG : 0x%X = 0x%08x\n", - MV_CESA_TDMA_ERROR_CAUSE_REG, - MV_REG_READ( MV_CESA_TDMA_ERROR_CAUSE_REG ) ); - - mvOsPrintf("MV_CESA_TDMA_ERROR_MASK_REG : 0x%X = 0x%08x\n", - MV_CESA_TDMA_ERROR_MASK_REG, - MV_REG_READ( MV_CESA_TDMA_ERROR_CAUSE_REG ) ); - -#endif -} - -void mvCesaDebugStatus(void) -{ - mvOsPrintf("\n\t CESA Status\n\n"); - - mvOsPrintf("pReqQ=%p, qDepth=%d, reqSize=%ld bytes, qRes=%d, ", - pCesaReqFirst, cesaQueueDepth, sizeof(MV_CESA_REQ), - cesaReqResources); -#if (MV_CESA_VERSION >= 3) - mvOsPrintf("chainLength=%u\n",cesaChainLength); -#else - mvOsPrintf("\n"); -#endif - - mvOsPrintf("pSAD=%p, maxSA=%d, sizeSA=%ld bytes\n", - pCesaSAD, cesaMaxSA, sizeof(MV_CESA_SA)); - - mvOsPrintf("\n"); - - mvCesaDebugRegs(); - mvCesaDebugStats(); - mvCesaDebugStatsClear(); -} - -void mvCesaDebugDescriptor(MV_CESA_DESC* pDesc) -{ - mvOsPrintf("config=0x%08x, crSrcOffs=0x%04x, crDstOffs=0x%04x\n", - pDesc->config, pDesc->cryptoSrcOffset, pDesc->cryptoDstOffset); - - mvOsPrintf("crLen=0x%04x, crKeyOffs=0x%04x, ivOffs=0x%04x, ivBufOffs=0x%04x\n", - pDesc->cryptoDataLen, pDesc->cryptoKeyOffset, - pDesc->cryptoIvOffset, pDesc->cryptoIvBufOffset); - - mvOsPrintf("macSrc=0x%04x, digest=0x%04x, macLen=0x%04x, inIv=0x%04x, outIv=0x%04x\n", - pDesc->macSrcOffset, pDesc->macDigestOffset, pDesc->macDataLen, - pDesc->macInnerIvOffset, pDesc->macOuterIvOffset); -} - -void mvCesaDebugQueue(int mode) -{ - mvOsPrintf("\n\t CESA Request Queue:\n\n"); - - mvOsPrintf("pFirstReq=%p, pLastReq=%p, qDepth=%d, reqSize=%ld bytes\n", - pCesaReqFirst, pCesaReqLast, cesaQueueDepth, sizeof(MV_CESA_REQ)); - - mvOsPrintf("pEmpty=%p, pProcess=%p, qResources=%d\n", - pCesaReqEmpty, pCesaReqProcess, - cesaReqResources); - - if(mode != 0) - { - int count = 0; - MV_CESA_REQ* pReq = pCesaReqFirst; - - for(count=0; count<cesaQueueDepth; count++) - { - /* Print out requsts */ - mvOsPrintf("%02d. pReq=%p, state=%s, frag=0x%x, pCmd=%p, pDma=%p, pDesc=%p\n", - count, pReq, mvCesaDebugStateStr(pReq->state), - pReq->fragMode, pReq->pCmd, pReq->dma[0].pDmaFirst, &pReq->pCesaDesc[0]); - if(pReq->fragMode != MV_CESA_FRAG_NONE) - { - int frag; - - mvOsPrintf("pFrags=%p, num=%d, next=%d, bufOffset=%d, cryptoSize=%d, macSize=%d\n", - &pReq->frags, pReq->frags.numFrag, pReq->frags.nextFrag, - pReq->frags.bufOffset, pReq->frags.cryptoSize, pReq->frags.macSize); - for(frag=0; frag<pReq->frags.numFrag; frag++) - { - mvOsPrintf("#%d: pDmaFirst=%p, pDesc=%p\n", frag, - pReq->dma[frag].pDmaFirst, &pReq->pCesaDesc[frag]); - } - } - if(mode > 1) - { - /* Print out Command */ - mvCesaDebugCmd(pReq->pCmd, mode); - - /* Print out Descriptor */ - mvCesaDebugDescriptor(&pReq->pCesaDesc[0]); - } - pReq++; - } - } -} - - -void mvCesaDebugSramSA(MV_CESA_SRAM_SA* pSramSA, int mode) -{ - if(pSramSA == NULL) - { - mvOsPrintf("cesaSramSA: Unexpected pSramSA=%p\n", pSramSA); - return; - } - mvOsPrintf("pSramSA=%p, sizeSramSA=%ld bytes\n", - pSramSA, sizeof(MV_CESA_SRAM_SA)); - - if(mode != 0) - { - mvOsPrintf("cryptoKey=%p, maxCryptoKey=%d bytes\n", - pSramSA->cryptoKey, MV_CESA_MAX_CRYPTO_KEY_LENGTH); - mvDebugMemDump(pSramSA->cryptoKey, MV_CESA_MAX_CRYPTO_KEY_LENGTH, 1); - - mvOsPrintf("macInnerIV=%p, maxInnerIV=%d bytes\n", - pSramSA->macInnerIV, MV_CESA_MAX_DIGEST_SIZE); - mvDebugMemDump(pSramSA->macInnerIV, MV_CESA_MAX_DIGEST_SIZE, 1); - - mvOsPrintf("macOuterIV=%p, maxOuterIV=%d bytes\n", - pSramSA->macOuterIV, MV_CESA_MAX_DIGEST_SIZE); - mvDebugMemDump(pSramSA->macOuterIV, MV_CESA_MAX_DIGEST_SIZE, 1); - } -} - -void mvCesaDebugSA(short sid, int mode) -{ - MV_CESA_OPERATION oper; - MV_CESA_DIRECTION dir; - MV_CESA_CRYPTO_ALG cryptoAlg; - MV_CESA_CRYPTO_MODE cryptoMode; - MV_CESA_MAC_MODE macMode; - MV_CESA_SA* pSA = &pCesaSAD[sid]; - - if( (pSA->valid) || ((pSA->count != 0) && (mode > 0)) || (mode >= 2) ) - { - mvOsPrintf("\n\nCESA SA Entry #%d (%p) - %s (count=%d)\n", - sid, pSA, - pSA->valid ? "Valid" : "Invalid", pSA->count); - - oper = (pSA->config & MV_CESA_OPERATION_MASK) >> MV_CESA_OPERATION_OFFSET; - dir = (pSA->config & MV_CESA_DIRECTION_MASK) >> MV_CESA_DIRECTION_BIT; - mvOsPrintf("%s - %s ", mvCesaDebugOperStr(oper), - (dir == MV_CESA_DIR_ENCODE) ? "Encode" : "Decode"); - if(oper != MV_CESA_MAC_ONLY) - { - cryptoAlg = (pSA->config & MV_CESA_CRYPTO_ALG_MASK) >> MV_CESA_CRYPTO_ALG_OFFSET; - cryptoMode = (pSA->config & MV_CESA_CRYPTO_MODE_MASK) >> MV_CESA_CRYPTO_MODE_BIT; - mvOsPrintf("- %s - %s ", mvCesaDebugCryptoAlgStr(cryptoAlg), - (cryptoMode == MV_CESA_CRYPTO_ECB) ? "ECB" : "CBC"); - } - if(oper != MV_CESA_CRYPTO_ONLY) - { - macMode = (pSA->config & MV_CESA_MAC_MODE_MASK) >> MV_CESA_MAC_MODE_OFFSET; - mvOsPrintf("- %s ", mvCesaDebugMacModeStr(macMode)); - } - mvOsPrintf("\n"); - - if(mode > 0) - { - mvOsPrintf("config=0x%08x, cryptoKeySize=%d, digestSize=%d\n", - pCesaSAD[sid].config, pCesaSAD[sid].cryptoKeyLength, - pCesaSAD[sid].digestSize); - - mvCesaDebugSramSA(pCesaSAD[sid].pSramSA, mode); - } - } -} - - -/**/ -void mvCesaDebugSram(int mode) -{ - mvOsPrintf("\n\t SRAM contents: size=%ld, pVirt=%p\n\n", - sizeof(MV_CESA_SRAM_MAP), cesaSramVirtPtr); - - mvOsPrintf("\n\t Sram buffer: size=%d, pVirt=%p\n", - MV_CESA_MAX_BUF_SIZE, cesaSramVirtPtr->buf); - if(mode != 0) - mvDebugMemDump(cesaSramVirtPtr->buf, 64, 1); - - mvOsPrintf("\n"); - mvOsPrintf("\n\t Sram descriptor: size=%ld, pVirt=%p\n", - sizeof(MV_CESA_DESC), &cesaSramVirtPtr->desc); - if(mode != 0) - { - mvOsPrintf("\n"); - mvCesaDebugDescriptor(&cesaSramVirtPtr->desc); - } - mvOsPrintf("\n\t Sram IV: size=%d, pVirt=%p\n", - MV_CESA_MAX_IV_LENGTH, &cesaSramVirtPtr->cryptoIV); - if(mode != 0) - { - mvOsPrintf("\n"); - mvDebugMemDump(cesaSramVirtPtr->cryptoIV, MV_CESA_MAX_IV_LENGTH, 1); - } - mvOsPrintf("\n"); - mvCesaDebugSramSA(&cesaSramVirtPtr->sramSA, 0); -} - -void mvCesaDebugSAD(int mode) -{ - int sid; - - mvOsPrintf("\n\t Cesa SAD status: pSAD=%p, maxSA=%d\n", - pCesaSAD, cesaMaxSA); - - for(sid=0; sid<cesaMaxSA; sid++) - { - mvCesaDebugSA(sid, mode); - } -} - -void mvCesaDebugStats(void) -{ - mvOsPrintf("\n\t Cesa Statistics\n"); - - mvOsPrintf("Opened=%u, Closed=%u\n", - cesaStats.openedCount, cesaStats.closedCount); - mvOsPrintf("Req=%u, maxReq=%u, frags=%u, start=%u\n", - cesaStats.reqCount, cesaStats.maxReqCount, - cesaStats.fragCount, cesaStats.startCount); -#if (MV_CESA_VERSION >= 3) - mvOsPrintf("maxChainUsage=%u\n",cesaStats.maxChainUsage); -#endif - mvOsPrintf("\n"); - mvOsPrintf("proc=%u, ready=%u, notReady=%u\n", - cesaStats.procCount, cesaStats.readyCount, cesaStats.notReadyCount); -} - -void mvCesaDebugStatsClear(void) -{ - memset(&cesaStats, 0, sizeof(cesaStats)); -} diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvCesaRegs.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvCesaRegs.h deleted file mode 100644 index b12e44b..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvCesaRegs.h +++ /dev/null @@ -1,357 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __mvCesaRegs_h__ -#define __mvCesaRegs_h__ - -#include "mvTypes.h" - -typedef struct -{ - /* word 0 */ - MV_U32 config; - /* word 1 */ - MV_U16 cryptoSrcOffset; - MV_U16 cryptoDstOffset; - /* word 2 */ - MV_U16 cryptoDataLen; - MV_U16 reserved1; - /* word 3 */ - MV_U16 cryptoKeyOffset; - MV_U16 reserved2; - /* word 4 */ - MV_U16 cryptoIvOffset; - MV_U16 cryptoIvBufOffset; - /* word 5 */ - MV_U16 macSrcOffset; - MV_U16 macTotalLen; - /* word 6 */ - MV_U16 macDigestOffset; - MV_U16 macDataLen; - /* word 7 */ - MV_U16 macInnerIvOffset; - MV_U16 macOuterIvOffset; - -} MV_CESA_DESC; - -/* operation */ -typedef enum -{ - MV_CESA_MAC_ONLY = 0, - MV_CESA_CRYPTO_ONLY = 1, - MV_CESA_MAC_THEN_CRYPTO = 2, - MV_CESA_CRYPTO_THEN_MAC = 3, - - MV_CESA_MAX_OPERATION - -} MV_CESA_OPERATION; - -#define MV_CESA_OPERATION_OFFSET 0 -#define MV_CESA_OPERATION_MASK (0x3 << MV_CESA_OPERATION_OFFSET) - -/* mac algorithm */ -typedef enum -{ - MV_CESA_MAC_NULL = 0, - MV_CESA_MAC_MD5 = 4, - MV_CESA_MAC_SHA1 = 5, - MV_CESA_MAC_HMAC_MD5 = 6, - MV_CESA_MAC_HMAC_SHA1 = 7, - -} MV_CESA_MAC_MODE; - -#define MV_CESA_MAC_MODE_OFFSET 4 -#define MV_CESA_MAC_MODE_MASK (0x7 << MV_CESA_MAC_MODE_OFFSET) - -typedef enum -{ - MV_CESA_MAC_DIGEST_FULL = 0, - MV_CESA_MAC_DIGEST_96B = 1, - -} MV_CESA_MAC_DIGEST_SIZE; - -#define MV_CESA_MAC_DIGEST_SIZE_BIT 7 -#define MV_CESA_MAC_DIGEST_SIZE_MASK (1 << MV_CESA_MAC_DIGEST_SIZE_BIT) - - -typedef enum -{ - MV_CESA_CRYPTO_NULL = 0, - MV_CESA_CRYPTO_DES = 1, - MV_CESA_CRYPTO_3DES = 2, - MV_CESA_CRYPTO_AES = 3, - -} MV_CESA_CRYPTO_ALG; - -#define MV_CESA_CRYPTO_ALG_OFFSET 8 -#define MV_CESA_CRYPTO_ALG_MASK (0x3 << MV_CESA_CRYPTO_ALG_OFFSET) - - -/* direction */ -typedef enum -{ - MV_CESA_DIR_ENCODE = 0, - MV_CESA_DIR_DECODE = 1, - -} MV_CESA_DIRECTION; - -#define MV_CESA_DIRECTION_BIT 12 -#define MV_CESA_DIRECTION_MASK (1 << MV_CESA_DIRECTION_BIT) - -/* crypto IV mode */ -typedef enum -{ - MV_CESA_CRYPTO_ECB = 0, - MV_CESA_CRYPTO_CBC = 1, - - /* NO HW Support */ - MV_CESA_CRYPTO_CTR = 10, - -} MV_CESA_CRYPTO_MODE; - -#define MV_CESA_CRYPTO_MODE_BIT 16 -#define MV_CESA_CRYPTO_MODE_MASK (1 << MV_CESA_CRYPTO_MODE_BIT) - -/* 3DES mode */ -typedef enum -{ - MV_CESA_CRYPTO_3DES_EEE = 0, - MV_CESA_CRYPTO_3DES_EDE = 1, - -} MV_CESA_CRYPTO_3DES_MODE; - -#define MV_CESA_CRYPTO_3DES_MODE_BIT 20 -#define MV_CESA_CRYPTO_3DES_MODE_MASK (1 << MV_CESA_CRYPTO_3DES_MODE_BIT) - - -/* AES Key Length */ -typedef enum -{ - MV_CESA_CRYPTO_AES_KEY_128 = 0, - MV_CESA_CRYPTO_AES_KEY_192 = 1, - MV_CESA_CRYPTO_AES_KEY_256 = 2, - -} MV_CESA_CRYPTO_AES_KEY_LEN; - -#define MV_CESA_CRYPTO_AES_KEY_LEN_OFFSET 24 -#define MV_CESA_CRYPTO_AES_KEY_LEN_MASK (0x3 << MV_CESA_CRYPTO_AES_KEY_LEN_OFFSET) - -/* Fragmentation mode */ -typedef enum -{ - MV_CESA_FRAG_NONE = 0, - MV_CESA_FRAG_FIRST = 1, - MV_CESA_FRAG_LAST = 2, - MV_CESA_FRAG_MIDDLE = 3, - -} MV_CESA_FRAG_MODE; - -#define MV_CESA_FRAG_MODE_OFFSET 30 -#define MV_CESA_FRAG_MODE_MASK (0x3 << MV_CESA_FRAG_MODE_OFFSET) -/*---------------------------------------------------------------------------*/ - -/********** Security Accelerator Command Register **************/ -#define MV_CESA_CMD_REG (MV_CESA_REG_BASE + 0xE00) - -#define MV_CESA_CMD_CHAN_ENABLE_BIT 0 -#define MV_CESA_CMD_CHAN_ENABLE_MASK (1 << MV_CESA_CMD_CHAN_ENABLE_BIT) - -#define MV_CESA_CMD_CHAN_DISABLE_BIT 2 -#define MV_CESA_CMD_CHAN_DISABLE_MASK (1 << MV_CESA_CMD_CHAN_DISABLE_BIT) - -/********** Security Accelerator Descriptor Pointers Register **********/ -#define MV_CESA_CHAN_DESC_OFFSET_REG (MV_CESA_REG_BASE + 0xE04) - -/********** Security Accelerator Configuration Register **********/ -#define MV_CESA_CFG_REG (MV_CESA_REG_BASE + 0xE08) - -#define MV_CESA_CFG_STOP_DIGEST_ERR_BIT 0 -#define MV_CESA_CFG_STOP_DIGEST_ERR_MASK (1 << MV_CESA_CFG_STOP_DIGEST_ERR_BIT) - -#define MV_CESA_CFG_WAIT_DMA_BIT 7 -#define MV_CESA_CFG_WAIT_DMA_MASK (1 << MV_CESA_CFG_WAIT_DMA_BIT) - -#define MV_CESA_CFG_ACT_DMA_BIT 9 -#define MV_CESA_CFG_ACT_DMA_MASK (1 << MV_CESA_CFG_ACT_DMA_BIT) - -#define MV_CESA_CFG_CHAIN_MODE_BIT 11 -#define MV_CESA_CFG_CHAIN_MODE_MASK (1 << MV_CESA_CFG_CHAIN_MODE_BIT) - -/********** Security Accelerator Status Register ***********/ -#define MV_CESA_STATUS_REG (MV_CESA_REG_BASE + 0xE0C) - -#define MV_CESA_STATUS_ACTIVE_BIT 0 -#define MV_CESA_STATUS_ACTIVE_MASK (1 << MV_CESA_STATUS_ACTIVE_BIT) - -#define MV_CESA_STATUS_DIGEST_ERR_BIT 8 -#define MV_CESA_STATUS_DIGEST_ERR_MASK (1 << MV_CESA_STATUS_DIGEST_ERR_BIT) - - -/* Cryptographic Engines and Security Accelerator Interrupt Cause Register */ -#define MV_CESA_ISR_CAUSE_REG (MV_CESA_REG_BASE + 0xE20) - -/* Cryptographic Engines and Security Accelerator Interrupt Mask Register */ -#define MV_CESA_ISR_MASK_REG (MV_CESA_REG_BASE + 0xE24) - -#define MV_CESA_CAUSE_AUTH_MASK (1 << 0) -#define MV_CESA_CAUSE_DES_MASK (1 << 1) -#define MV_CESA_CAUSE_AES_ENCR_MASK (1 << 2) -#define MV_CESA_CAUSE_AES_DECR_MASK (1 << 3) -#define MV_CESA_CAUSE_DES_ALL_MASK (1 << 4) - -#define MV_CESA_CAUSE_ACC_BIT 5 -#define MV_CESA_CAUSE_ACC_MASK (1 << MV_CESA_CAUSE_ACC_BIT) - -#define MV_CESA_CAUSE_ACC_DMA_BIT 7 -#define MV_CESA_CAUSE_ACC_DMA_MASK (1 << MV_CESA_CAUSE_ACC_DMA_BIT) -#define MV_CESA_CAUSE_ACC_DMA_ALL_MASK (3 << MV_CESA_CAUSE_ACC_DMA_BIT) - -#define MV_CESA_CAUSE_DMA_COMPL_BIT 9 -#define MV_CESA_CAUSE_DMA_COMPL_MASK (1 << MV_CESA_CAUSE_DMA_COMPL_BIT) - -#define MV_CESA_CAUSE_DMA_OWN_ERR_BIT 10 -#define MV_CESA_CAUSE_DMA_OWN_ERR_MASK (1 < MV_CESA_CAUSE_DMA_OWN_ERR_BIT) - -#define MV_CESA_CAUSE_DMA_CHAIN_PKT_BIT 11 -#define MV_CESA_CAUSE_DMA_CHAIN_PKT_MASK (1 < MV_CESA_CAUSE_DMA_CHAIN_PKT_BIT) - - -#define MV_CESA_AUTH_DATA_IN_REG (MV_CESA_REG_BASE + 0xd38) -#define MV_CESA_AUTH_BIT_COUNT_LOW_REG (MV_CESA_REG_BASE + 0xd20) -#define MV_CESA_AUTH_BIT_COUNT_HIGH_REG (MV_CESA_REG_BASE + 0xd24) - -#define MV_CESA_AUTH_INIT_VAL_DIGEST_REG(i) (MV_CESA_REG_BASE + 0xd00 + (i<<2)) - -#define MV_CESA_AUTH_INIT_VAL_DIGEST_A_REG (MV_CESA_REG_BASE + 0xd00) -#define MV_CESA_AUTH_INIT_VAL_DIGEST_B_REG (MV_CESA_REG_BASE + 0xd04) -#define MV_CESA_AUTH_INIT_VAL_DIGEST_C_REG (MV_CESA_REG_BASE + 0xd08) -#define MV_CESA_AUTH_INIT_VAL_DIGEST_D_REG (MV_CESA_REG_BASE + 0xd0c) -#define MV_CESA_AUTH_INIT_VAL_DIGEST_E_REG (MV_CESA_REG_BASE + 0xd10) -#define MV_CESA_AUTH_COMMAND_REG (MV_CESA_REG_BASE + 0xd18) - -#define MV_CESA_AUTH_ALGORITHM_BIT 0 -#define MV_CESA_AUTH_ALGORITHM_MD5 (0<<AUTH_ALGORITHM_BIT) -#define MV_CESA_AUTH_ALGORITHM_SHA1 (1<<AUTH_ALGORITHM_BIT) - -#define MV_CESA_AUTH_IV_MODE_BIT 1 -#define MV_CESA_AUTH_IV_MODE_INIT (0<<AUTH_IV_MODE_BIT) -#define MV_CESA_AUTH_IV_MODE_CONTINUE (1<<AUTH_IV_MODE_BIT) - -#define MV_CESA_AUTH_DATA_BYTE_SWAP_BIT 2 -#define MV_CESA_AUTH_DATA_BYTE_SWAP_MASK (1<<AUTH_DATA_BYTE_SWAP_BIT) - - -#define MV_CESA_AUTH_IV_BYTE_SWAP_BIT 4 -#define MV_CESA_AUTH_IV_BYTE_SWAP_MASK (1<<AUTH_IV_BYTE_SWAP_BIT) - -#define MV_CESA_AUTH_TERMINATION_BIT 31 -#define MV_CESA_AUTH_TERMINATION_MASK (1<<AUTH_TERMINATION_BIT) - - -/*************** TDMA Control Register ************************************************/ -#define MV_CESA_TDMA_CTRL_REG (MV_CESA_TDMA_REG_BASE + 0x840) - -#define MV_CESA_TDMA_BURST_32B 3 -#define MV_CESA_TDMA_BURST_128B 4 - -#define MV_CESA_TDMA_DST_BURST_OFFSET 0 -#define MV_CESA_TDMA_DST_BURST_ALL_MASK (0x7<<MV_CESA_TDMA_DST_BURST_OFFSET) -#define MV_CESA_TDMA_DST_BURST_MASK(burst) ((burst)<<MV_CESA_TDMA_DST_BURST_OFFSET) - -#define MV_CESA_TDMA_OUTSTAND_READ_EN_BIT 4 -#define MV_CESA_TDMA_OUTSTAND_READ_EN_MASK (1<<MV_CESA_TDMA_OUTSTAND_READ_EN_BIT) - -#define MV_CESA_TDMA_SRC_BURST_OFFSET 6 -#define MV_CESA_TDMA_SRC_BURST_ALL_MASK (0x7<<MV_CESA_TDMA_SRC_BURST_OFFSET) -#define MV_CESA_TDMA_SRC_BURST_MASK(burst) ((burst)<<MV_CESA_TDMA_SRC_BURST_OFFSET) - -#define MV_CESA_TDMA_CHAIN_MODE_BIT 9 -#define MV_CESA_TDMA_NON_CHAIN_MODE_MASK (1<<MV_CESA_TDMA_CHAIN_MODE_BIT) - -#define MV_CESA_TDMA_BYTE_SWAP_BIT 11 -#define MV_CESA_TDMA_BYTE_SWAP_MASK (0 << MV_CESA_TDMA_BYTE_SWAP_BIT) -#define MV_CESA_TDMA_NO_BYTE_SWAP_MASK (1 << MV_CESA_TDMA_BYTE_SWAP_BIT) - -#define MV_CESA_TDMA_ENABLE_BIT 12 -#define MV_CESA_TDMA_ENABLE_MASK (1<<MV_CESA_TDMA_ENABLE_BIT) - -#define MV_CESA_TDMA_FETCH_NEXT_DESC_BIT 13 -#define MV_CESA_TDMA_FETCH_NEXT_DESC_MASK (1<<MV_CESA_TDMA_FETCH_NEXT_DESC_BIT) - -#define MV_CESA_TDMA_CHAN_ACTIVE_BIT 14 -#define MV_CESA_TDMA_CHAN_ACTIVE_MASK (1<<MV_CESA_TDMA_CHAN_ACTIVE_BIT) -/*------------------------------------------------------------------------------------*/ - -#define MV_CESA_TDMA_BYTE_COUNT_REG (MV_CESA_TDMA_REG_BASE + 0x800) -#define MV_CESA_TDMA_SRC_ADDR_REG (MV_CESA_TDMA_REG_BASE + 0x810) -#define MV_CESA_TDMA_DST_ADDR_REG (MV_CESA_TDMA_REG_BASE + 0x820) -#define MV_CESA_TDMA_NEXT_DESC_PTR_REG (MV_CESA_TDMA_REG_BASE + 0x830) -#define MV_CESA_TDMA_CURR_DESC_PTR_REG (MV_CESA_TDMA_REG_BASE + 0x870) - -#define MV_CESA_TDMA_ERROR_CAUSE_REG (MV_CESA_TDMA_REG_BASE + 0x8C0) -#define MV_CESA_TDMA_ERROR_MASK_REG (MV_CESA_TDMA_REG_BASE + 0x8C4) - - -#endif /* __mvCesaRegs_h__ */ - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvCesaTest.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvCesaTest.c deleted file mode 100644 index a74828c..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvCesaTest.c +++ /dev/null @@ -1,3096 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#include "mvOs.h" - -#if defined(MV_VXWORKS) - -#include "sysLib.h" -#include "logLib.h" -#include "tickLib.h" -#include "intLib.h" -#include "config.h" - - -SEM_ID cesaSemId = NULL; -SEM_ID cesaWaitSemId = NULL; - -#define CESA_TEST_LOCK(flags) flags = intLock() -#define CESA_TEST_UNLOCK(flags) intUnlock(flags) - -#define CESA_TEST_WAIT_INIT() cesaWaitSemId = semBCreate(SEM_Q_PRIORITY, SEM_EMPTY) -#define CESA_TEST_WAKE_UP() semGive(cesaWaitSemId) -#define CESA_TEST_WAIT(cond, ms) semTake(cesaWaitSemId, (sysClkRateGet()*ms)/1000) - -#define CESA_TEST_TICK_GET() tickGet() -#define CESA_TEST_TICK_TO_MS(tick) (((tick)*1000)/sysClkRateGet()) - -#elif defined(MV_LINUX) - -#include <linux/wait.h> -wait_queue_head_t cesaTest_waitq; -spinlock_t cesaLock; - -#define CESA_TEST_LOCK(flags) spin_lock_irqsave( &cesaLock, flags) -#define CESA_TEST_UNLOCK(flags) spin_unlock_irqrestore( &cesaLock, flags); - -#define CESA_TEST_WAIT_INIT() init_waitqueue_head(&cesaTest_waitq) -#define CESA_TEST_WAKE_UP() wake_up(&cesaTest_waitq) -#define CESA_TEST_WAIT(cond, ms) wait_event_timeout(cesaTest_waitq, (cond), msecs_to_jiffies(ms)) - -#define CESA_TEST_TICK_GET() jiffies -#define CESA_TEST_TICK_TO_MS(tick) jiffies_to_msecs(tick) - -#elif defined(MV_NETBSD) - -#include <sys/param.h> -#include <sys/kernel.h> -static int cesaLock; - -#define CESA_TEST_LOCK(flags) flags = splnet() -#define CESA_TEST_UNLOCK(flags) splx(flags) - -#define CESA_TEST_WAIT_INIT() /* nothing */ -#define CESA_TEST_WAKE_UP() wakeup(&cesaLock) -#define CESA_TEST_WAIT(cond, ms) \ -do { \ - while (!(cond)) \ - tsleep(&cesaLock, PWAIT, "cesatest",mstohz(ms)); \ -} while (/*CONSTCOND*/0) - -#define CESA_TEST_TICK_GET() hardclock_ticks -#define CESA_TEST_TICK_TO_MS(tick) ((1000/hz)*(tick)) - -#define request_irq(i,h,t,n,a) \ - !mv_intr_establish((i),IPL_NET,(int(*)(void *))(h),(a)) - -#else -#error "Only Linux, VxWorks, or NetBSD OS are supported" -#endif - -#include "mvDebug.h" - -#include "mvSysHwConfig.h" -#include "boardEnv/mvBoardEnvLib.h" -#include "ctrlEnv/sys/mvCpuIf.h" -#include "cntmr/mvCntmr.h" -#include "cesa/mvCesa.h" -#include "cesa/mvCesaRegs.h" -#include "cesa/mvMD5.h" -#include "cesa/mvSHA1.h" - -#if defined(CONFIG_MV646xx) -#include "marvell_pic.h" -#endif - -#define MV_CESA_USE_TIMER_ID 0 -#define CESA_DEF_BUF_SIZE 1500 -#define CESA_DEF_BUF_NUM 1 -#define CESA_DEF_SESSION_NUM 32 - -#define CESA_DEF_ITER_NUM 100 - -#define CESA_DEF_REQ_SIZE 256 - - -/* CESA Tests Debug */ -#undef CESA_TEST_DEBUG - -#ifdef CESA_TEST_DEBUG - -# define CESA_TEST_DEBUG_PRINT(msg) mvOsPrintf msg -# define CESA_TEST_DEBUG_CODE(code) code - -typedef struct -{ - int type; /* 0 - isrEmpty, 1 - cesaReadyGet, 2 - cesaAction */ - MV_U32 timeStamp; - MV_U32 cause; - MV_U32 realCause; - MV_U32 dmaCause; - int resources; - MV_CESA_REQ* pReqReady; - MV_CESA_REQ* pReqEmpty; - MV_CESA_REQ* pReqProcess; -} MV_CESA_TEST_TRACE; - -#define MV_CESA_TEST_TRACE_SIZE 25 - -static int cesaTestTraceIdx = 0; -static MV_CESA_TEST_TRACE cesaTestTrace[MV_CESA_TEST_TRACE_SIZE]; - -static void cesaTestTraceAdd(int type, MV_U32 cause) -{ - cesaTestTrace[cesaTestTraceIdx].type = type; - cesaTestTrace[cesaTestTraceIdx].cause = cause; - cesaTestTrace[cesaTestTraceIdx].realCause = MV_REG_READ(MV_CESA_ISR_CAUSE_REG); - cesaTestTrace[cesaTestTraceIdx].dmaCause = MV_REG_READ(IDMA_CAUSE_REG); - cesaTestTrace[cesaTestTraceIdx].resources = cesaReqResources; - cesaTestTrace[cesaTestTraceIdx].pReqReady = pCesaReqReady; - cesaTestTrace[cesaTestTraceIdx].pReqEmpty = pCesaReqEmpty; - cesaTestTrace[cesaTestTraceIdx].pReqProcess = pCesaReqProcess; - cesaTestTrace[cesaTestTraceIdx].timeStamp = mvCntmrRead(MV_CESA_USE_TIMER_ID); - cesaTestTraceIdx++; - if(cesaTestTraceIdx == MV_CESA_TEST_TRACE_SIZE) - cesaTestTraceIdx = 0; -} - -#else - -# define CESA_TEST_DEBUG_PRINT(msg) -# define CESA_TEST_DEBUG_CODE(code) - -#endif /* CESA_TEST_DEBUG */ - -int cesaExpReqId=0; -int cesaCbIter=0; - -int cesaIdx; -int cesaIteration; -int cesaRateSize; -int cesaReqSize; -unsigned long cesaTaskId; -int cesaBufNum; -int cesaBufSize; -int cesaCheckOffset; -int cesaCheckSize; -int cesaCheckMode; -int cesaTestIdx; -int cesaCaseIdx; - - -MV_U32 cesaTestIsrCount = 0; -MV_U32 cesaTestIsrMissCount = 0; - -MV_U32 cesaCryptoError = 0; -MV_U32 cesaReqIdError = 0; -MV_U32 cesaError = 0; - -char* cesaHexBuffer = NULL; - -char* cesaBinBuffer = NULL; -char* cesaExpBinBuffer = NULL; - -char* cesaInputHexStr = NULL; -char* cesaOutputHexStr = NULL; - -MV_BUF_INFO cesaReqBufs[CESA_DEF_REQ_SIZE]; - -MV_CESA_COMMAND* cesaCmdRing; -MV_CESA_RESULT cesaResult; - -int cesaTestFull = 0; - -MV_BOOL cesaIsReady = MV_FALSE; -MV_U32 cesaCycles = 0; -MV_U32 cesaBeginTicks = 0; -MV_U32 cesaEndTicks = 0; -MV_U32 cesaRate = 0; -MV_U32 cesaRateAfterDot = 0; - -void *cesaTestOSHandle = NULL; - -enum -{ - CESA_FAST_CHECK_MODE = 0, - CESA_FULL_CHECK_MODE, - CESA_NULL_CHECK_MODE, - CESA_SHOW_CHECK_MODE, - CESA_SW_SHOW_CHECK_MODE, - CESA_SW_NULL_CHECK_MODE, - - CESA_MAX_CHECK_MODE -}; - -enum -{ - DES_TEST_TYPE = 0, - TRIPLE_DES_TEST_TYPE = 1, - AES_TEST_TYPE = 2, - MD5_TEST_TYPE = 3, - SHA_TEST_TYPE = 4, - COMBINED_TEST_TYPE = 5, - - MAX_TEST_TYPE -}; - -/* Tests data base */ -typedef struct -{ - short sid; - char cryptoAlgorithm; /* DES/3DES/AES */ - char cryptoMode; /* ECB or CBC */ - char macAlgorithm; /* MD5 / SHA1 */ - char operation; /* CRYPTO/HMAC/CRYPTO+HMAC/HMAC+CRYPTO */ - char direction; /* ENCODE(SIGN)/DECODE(VERIFY) */ - unsigned char* pCryptoKey; - int cryptoKeySize; - unsigned char* pMacKey; - int macKeySize; - const char* name; - -} MV_CESA_TEST_SESSION; - -typedef struct -{ - MV_CESA_TEST_SESSION* pSessions; - int numSessions; - -} MV_CESA_TEST_DB_ENTRY; - -typedef struct -{ - char* plainHexStr; - char* cipherHexStr; - unsigned char* pCryptoIV; - int cryptoLength; - int macLength; - int digestOffset; - -} MV_CESA_TEST_CASE; - -typedef struct -{ - int size; - const char* outputHexStr; - -} MV_CESA_SIZE_TEST; - -static unsigned char cryptoKey1[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, - 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, - 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef}; - -static unsigned char cryptoKey7[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef}; -static unsigned char iv1[] = {0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef}; - - -static unsigned char cryptoKey2[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}; - -static unsigned char cryptoKey3[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17}; - -static unsigned char cryptoKey4[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f}; - -static unsigned char cryptoKey5[] = {0x56, 0xe4, 0x7a, 0x38, 0xc5, 0x59, 0x89, 0x74, - 0xbc, 0x46, 0x90, 0x3d, 0xba, 0x29, 0x03, 0x49}; - - -static unsigned char key3des1[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, - 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x01, - 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x01, 0x23}; - -/* Input ASCII string: The quick brown fox jump */ -static char plain3des1[] = "54686520717566636B2062726F776E20666F78206A756D70"; -static char cipher3des1[] = "A826FD8CE53B855FCCE21C8112256FE668D5C05DD9B6B900"; - -static unsigned char key3des2[] = {0x62, 0x7f, 0x46, 0x0e, 0x08, 0x10, 0x4a, 0x10, - 0x43, 0xcd, 0x26, 0x5d, 0x58, 0x40, 0xea, 0xf1, - 0x31, 0x3e, 0xdf, 0x97, 0xdf, 0x2a, 0x8a, 0x8c}; - -static unsigned char iv3des2[] = {0x8e, 0x29, 0xf7, 0x5e, 0xa7, 0x7e, 0x54, 0x75}; - -static char plain3des2[] = "326a494cd33fe756"; - -static char cipher3desCbc2[] = "8e29f75ea77e5475" - "b22b8d66de970692"; - -static unsigned char key3des3[] = {0x37, 0xae, 0x5e, 0xbf, 0x46, 0xdf, 0xf2, 0xdc, - 0x07, 0x54, 0xb9, 0x4f, 0x31, 0xcb, 0xb3, 0x85, - 0x5e, 0x7f, 0xd3, 0x6d, 0xc8, 0x70, 0xbf, 0xae}; - -static unsigned char iv3des3[] = {0x3d, 0x1d, 0xe3, 0xcc, 0x13, 0x2e, 0x3b, 0x65}; - -static char plain3des3[] = "84401f78fe6c10876d8ea23094ea5309"; - -static char cipher3desCbc3[] = "3d1de3cc132e3b65" - "7b1f7c7e3b1c948ebd04a75ffba7d2f5"; - -static unsigned char iv5[] = {0x8c, 0xe8, 0x2e, 0xef, 0xbe, 0xa0, 0xda, 0x3c, - 0x44, 0x69, 0x9e, 0xd7, 0xdb, 0x51, 0xb7, 0xd9}; - -static unsigned char aesCtrKey[] = {0x76, 0x91, 0xBE, 0x03, 0x5E, 0x50, 0x20, 0xA8, - 0xAC, 0x6E, 0x61, 0x85, 0x29, 0xF9, 0xA0, 0xDC}; - -static unsigned char mdKey1[] = {0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b}; - -static unsigned char mdKey2[] = {0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa}; - -static unsigned char shaKey1[] = {0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b}; - -static unsigned char shaKey2[] = {0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa}; - -static unsigned char mdKey4[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10}; - -static unsigned char shaKey4[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, - 0x11, 0x12, 0x13, 0x14}; - - -static MV_CESA_TEST_SESSION desTestSessions[] = -{ -/*000*/ {-1, MV_CESA_CRYPTO_DES, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY, - MV_CESA_DIR_ENCODE, - cryptoKey7, sizeof(cryptoKey7)/sizeof(cryptoKey7[0]), - NULL, 0, - "DES ECB encode", - }, -/*001*/ {-1, MV_CESA_CRYPTO_DES, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY, - MV_CESA_DIR_DECODE, - cryptoKey7, sizeof(cryptoKey7)/sizeof(cryptoKey7[0]), - NULL, 0, - "DES ECB decode", - }, -/*002*/ {-1, MV_CESA_CRYPTO_DES, MV_CESA_CRYPTO_CBC, - MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY, - MV_CESA_DIR_ENCODE, - cryptoKey7, sizeof(cryptoKey7)/sizeof(cryptoKey7[0]), - NULL, 0, - "DES CBC encode" - }, -/*003*/ {-1, MV_CESA_CRYPTO_DES, MV_CESA_CRYPTO_CBC, - MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY, - MV_CESA_DIR_DECODE, - cryptoKey7, sizeof(cryptoKey7)/sizeof(cryptoKey7[0]), - NULL, 0, - "DES CBC decode" - }, -/*004*/ {-1, MV_CESA_CRYPTO_NULL, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY, - MV_CESA_DIR_ENCODE, - NULL, 0, NULL, 0, - "NULL Crypto Algorithm encode" - }, -}; - - -static MV_CESA_TEST_SESSION tripleDesTestSessions[] = -{ -/*100*/ {-1, MV_CESA_CRYPTO_3DES, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY, - MV_CESA_DIR_ENCODE, - cryptoKey1, sizeof(cryptoKey1)/sizeof(cryptoKey1[0]), - NULL, 0, - "3DES ECB encode", - }, -/*101*/ {-1, MV_CESA_CRYPTO_3DES, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY, - MV_CESA_DIR_DECODE, - cryptoKey1, sizeof(cryptoKey1)/sizeof(cryptoKey1[0]), - NULL, 0, - "3DES ECB decode", - }, -/*102*/ {-1, MV_CESA_CRYPTO_3DES, MV_CESA_CRYPTO_CBC, - MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY, - MV_CESA_DIR_ENCODE, - cryptoKey1, sizeof(cryptoKey1)/sizeof(cryptoKey1[0]), - NULL, 0, - "3DES CBC encode" - }, -/*103*/ {-1, MV_CESA_CRYPTO_3DES, MV_CESA_CRYPTO_CBC, - MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY, - MV_CESA_DIR_DECODE, - cryptoKey1, sizeof(cryptoKey1)/sizeof(cryptoKey1[0]), - NULL, 0, - "3DES CBC decode" - }, -/*104*/ {-1, MV_CESA_CRYPTO_3DES, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY, - MV_CESA_DIR_ENCODE, - key3des1, sizeof(key3des1), - NULL, 0, - "3DES ECB encode" - }, -/*105*/ {-1, MV_CESA_CRYPTO_3DES, MV_CESA_CRYPTO_CBC, - MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY, - MV_CESA_DIR_ENCODE, - key3des2, sizeof(key3des2), - NULL, 0, - "3DES ECB encode" - }, -/*106*/ {-1, MV_CESA_CRYPTO_3DES, MV_CESA_CRYPTO_CBC, - MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY, - MV_CESA_DIR_ENCODE, - key3des3, sizeof(key3des3), - NULL, 0, - "3DES ECB encode" - }, -}; - - -static MV_CESA_TEST_SESSION aesTestSessions[] = -{ -/*200*/ {-1, MV_CESA_CRYPTO_AES, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY, - MV_CESA_DIR_ENCODE, - cryptoKey2, sizeof(cryptoKey2)/sizeof(cryptoKey2[0]), - NULL, 0, - "AES-128 ECB encode" - }, -/*201*/ {-1, MV_CESA_CRYPTO_AES, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY, - MV_CESA_DIR_DECODE, - cryptoKey2, sizeof(cryptoKey2)/sizeof(cryptoKey2[0]), - NULL, 0, - "AES-128 ECB decode" - }, -/*202*/ {-1, MV_CESA_CRYPTO_AES, MV_CESA_CRYPTO_CBC, - MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY, - MV_CESA_DIR_ENCODE, - cryptoKey5, sizeof(cryptoKey5)/sizeof(cryptoKey5[0]), - NULL, 0, - "AES-128 CBC encode" - }, -/*203*/ {-1, MV_CESA_CRYPTO_AES, MV_CESA_CRYPTO_CBC, - MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY, - MV_CESA_DIR_DECODE, - cryptoKey5, sizeof(cryptoKey5)/sizeof(cryptoKey5[0]), - NULL, 0, - "AES-128 CBC decode" - }, -/*204*/ {-1, MV_CESA_CRYPTO_AES, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY, - MV_CESA_DIR_ENCODE, - cryptoKey3, sizeof(cryptoKey3)/sizeof(cryptoKey3[0]), - NULL, 0, - "AES-192 ECB encode" - }, -/*205*/ {-1, MV_CESA_CRYPTO_AES, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY, - MV_CESA_DIR_DECODE, - cryptoKey3, sizeof(cryptoKey3)/sizeof(cryptoKey3[0]), - NULL, 0, - "AES-192 ECB decode" - }, -/*206*/ {-1, MV_CESA_CRYPTO_AES, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY, - MV_CESA_DIR_ENCODE, - cryptoKey4, sizeof(cryptoKey4)/sizeof(cryptoKey4[0]), - NULL, 0, - "AES-256 ECB encode" - }, -/*207*/ {-1, MV_CESA_CRYPTO_AES, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY, - MV_CESA_DIR_DECODE, - cryptoKey4, sizeof(cryptoKey4)/sizeof(cryptoKey4[0]), - NULL, 0, - "AES-256 ECB decode" - }, -/*208*/ {-1, MV_CESA_CRYPTO_AES, MV_CESA_CRYPTO_CTR, - MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY, - MV_CESA_DIR_ENCODE, - aesCtrKey, sizeof(aesCtrKey)/sizeof(aesCtrKey[0]), - NULL, 0, - "AES-128 CTR encode" - }, -}; - - -static MV_CESA_TEST_SESSION md5TestSessions[] = -{ -/*300*/ {-1, MV_CESA_CRYPTO_NULL, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_HMAC_MD5, MV_CESA_MAC_ONLY, - MV_CESA_DIR_ENCODE, - NULL, 0, - mdKey1, sizeof(mdKey1), - "HMAC-MD5 Generate Signature" - }, -/*301*/ {-1, MV_CESA_CRYPTO_NULL, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_HMAC_MD5, MV_CESA_MAC_ONLY, - MV_CESA_DIR_DECODE, - NULL, 0, - mdKey1, sizeof(mdKey1), - "HMAC-MD5 Verify Signature" - }, -/*302*/ {-1, MV_CESA_CRYPTO_NULL, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_HMAC_MD5, MV_CESA_MAC_ONLY, - MV_CESA_DIR_ENCODE, - NULL, 0, - mdKey2, sizeof(mdKey2), - "HMAC-MD5 Generate Signature" - }, -/*303*/ {-1, MV_CESA_CRYPTO_NULL, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_HMAC_MD5, MV_CESA_MAC_ONLY, - MV_CESA_DIR_DECODE, - NULL, 0, - mdKey2, sizeof(mdKey2), - "HMAC-MD5 Verify Signature" - }, -/*304*/ {-1, MV_CESA_CRYPTO_NULL, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_HMAC_MD5, MV_CESA_MAC_ONLY, - MV_CESA_DIR_ENCODE, - NULL, 0, - mdKey4, sizeof(mdKey4), - "HMAC-MD5 Generate Signature" - }, -/*305*/ {-1, MV_CESA_CRYPTO_NULL, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_MD5, MV_CESA_MAC_ONLY, - MV_CESA_DIR_ENCODE, - NULL, 0, - NULL, 0, - "HASH-MD5 Generate Signature" - }, -}; - - -static MV_CESA_TEST_SESSION shaTestSessions[] = -{ -/*400*/ {-1, MV_CESA_CRYPTO_NULL, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_HMAC_SHA1, MV_CESA_MAC_ONLY, - MV_CESA_DIR_ENCODE, - NULL, 0, - shaKey1, sizeof(shaKey1), - "HMAC-SHA1 Generate Signature" - }, -/*401*/ {-1, MV_CESA_CRYPTO_NULL, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_HMAC_SHA1, MV_CESA_MAC_ONLY, - MV_CESA_DIR_DECODE, - NULL, 0, - shaKey1, sizeof(shaKey1), - "HMAC-SHA1 Verify Signature" - }, -/*402*/ {-1, MV_CESA_CRYPTO_NULL, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_HMAC_SHA1, MV_CESA_MAC_ONLY, - MV_CESA_DIR_ENCODE, - NULL, 0, - shaKey2, sizeof(shaKey2), - "HMAC-SHA1 Generate Signature" - }, -/*403*/ {-1, MV_CESA_CRYPTO_NULL, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_HMAC_SHA1, MV_CESA_MAC_ONLY, - MV_CESA_DIR_DECODE, - NULL, 0, - shaKey2, sizeof(shaKey2), - "HMAC-SHA1 Verify Signature" - }, -/*404*/ {-1, MV_CESA_CRYPTO_NULL, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_HMAC_SHA1, MV_CESA_MAC_ONLY, - MV_CESA_DIR_ENCODE, - NULL, 0, - shaKey4, sizeof(shaKey4), - "HMAC-SHA1 Generate Signature" - }, -/*405*/ {-1, MV_CESA_CRYPTO_NULL, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_SHA1, MV_CESA_MAC_ONLY, - MV_CESA_DIR_ENCODE, - NULL, 0, - NULL, 0, - "HASH-SHA1 Generate Signature" - }, -}; - -static MV_CESA_TEST_SESSION combinedTestSessions[] = -{ -/*500*/ {-1, MV_CESA_CRYPTO_DES, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_HMAC_MD5, MV_CESA_CRYPTO_THEN_MAC, - MV_CESA_DIR_ENCODE, - cryptoKey1, MV_CESA_DES_KEY_LENGTH, - mdKey4, sizeof(mdKey4), - "DES + MD5 encode" - }, -/*501*/ {-1, MV_CESA_CRYPTO_DES, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_HMAC_SHA1, MV_CESA_CRYPTO_THEN_MAC, - MV_CESA_DIR_ENCODE, - cryptoKey1, MV_CESA_DES_KEY_LENGTH, - shaKey4, sizeof(shaKey4), - "DES + SHA1 encode" - }, -/*502*/ {-1, MV_CESA_CRYPTO_3DES, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_HMAC_MD5, MV_CESA_CRYPTO_THEN_MAC, - MV_CESA_DIR_ENCODE, - cryptoKey1, sizeof(cryptoKey1)/sizeof(cryptoKey1[0]), - mdKey4, sizeof(mdKey4), - "3DES + MD5 encode" - }, -/*503*/ {-1, MV_CESA_CRYPTO_3DES, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_HMAC_SHA1, MV_CESA_CRYPTO_THEN_MAC, - MV_CESA_DIR_ENCODE, - cryptoKey1, sizeof(cryptoKey1)/sizeof(cryptoKey1[0]), - shaKey4, sizeof(shaKey4), - "3DES + SHA1 encode" - }, -/*504*/ {-1, MV_CESA_CRYPTO_3DES, MV_CESA_CRYPTO_CBC, - MV_CESA_MAC_HMAC_MD5, MV_CESA_CRYPTO_THEN_MAC, - MV_CESA_DIR_ENCODE, - cryptoKey1, sizeof(cryptoKey1)/sizeof(cryptoKey1[0]), - mdKey4, sizeof(mdKey4), - "3DES CBC + MD5 encode" - }, -/*505*/ {-1, MV_CESA_CRYPTO_3DES, MV_CESA_CRYPTO_CBC, - MV_CESA_MAC_HMAC_SHA1, MV_CESA_CRYPTO_THEN_MAC, - MV_CESA_DIR_ENCODE, - cryptoKey1, sizeof(cryptoKey1)/sizeof(cryptoKey1[0]), - shaKey4, sizeof(shaKey4), - "3DES CBC + SHA1 encode" - }, -/*506*/ {-1, MV_CESA_CRYPTO_AES, MV_CESA_CRYPTO_CBC, - MV_CESA_MAC_HMAC_MD5, MV_CESA_CRYPTO_THEN_MAC, - MV_CESA_DIR_ENCODE, - cryptoKey5, sizeof(cryptoKey5)/sizeof(cryptoKey5[0]), - mdKey4, sizeof(mdKey4), - "AES-128 CBC + MD5 encode" - }, -/*507*/ {-1, MV_CESA_CRYPTO_AES, MV_CESA_CRYPTO_CBC, - MV_CESA_MAC_HMAC_SHA1, MV_CESA_CRYPTO_THEN_MAC, - MV_CESA_DIR_ENCODE, - cryptoKey5, sizeof(cryptoKey5)/sizeof(cryptoKey5[0]), - shaKey4, sizeof(shaKey4), - "AES-128 CBC + SHA1 encode" - }, -/*508*/ {-1, MV_CESA_CRYPTO_3DES, MV_CESA_CRYPTO_ECB, - MV_CESA_MAC_HMAC_MD5, MV_CESA_MAC_THEN_CRYPTO, - MV_CESA_DIR_DECODE, - cryptoKey1, sizeof(cryptoKey1)/sizeof(cryptoKey1[0]), - mdKey4, sizeof(mdKey4), - "HMAC-MD5 + 3DES decode" - }, -}; - - -static MV_CESA_TEST_DB_ENTRY cesaTestsDB[MAX_TEST_TYPE+1] = -{ - { desTestSessions, sizeof(desTestSessions)/sizeof(desTestSessions[0]) }, - { tripleDesTestSessions, sizeof(tripleDesTestSessions)/sizeof(tripleDesTestSessions[0]) }, - { aesTestSessions, sizeof(aesTestSessions)/sizeof(aesTestSessions[0]) }, - { md5TestSessions, sizeof(md5TestSessions)/sizeof(md5TestSessions[0]) }, - { shaTestSessions, sizeof(shaTestSessions)/sizeof(shaTestSessions[0]) }, - { combinedTestSessions, sizeof(combinedTestSessions)/sizeof(combinedTestSessions[0]) }, - { NULL, 0 } -}; - - -char cesaNullPlainHexText[] = "000000000000000000000000000000000000000000000000"; - -char cesaPlainAsciiText[] = "Now is the time for all "; -char cesaPlainHexEbc[] = "4e6f77206973207468652074696d6520666f7220616c6c20"; -char cesaCipherHexEcb[] = "3fa40e8a984d48156a271787ab8883f9893d51ec4b563b53"; -char cesaPlainHexCbc[] = "1234567890abcdef4e6f77206973207468652074696d6520666f7220616c6c20"; -char cesaCipherHexCbc[] = "1234567890abcdefe5c7cdde872bf27c43e934008c389c0f683788499a7c05f6"; - -char cesaAesPlainHexEcb[] = "000102030405060708090a0b0c0d0e0f"; -char cesaAes128cipherHexEcb[] = "0a940bb5416ef045f1c39458c653ea5a"; -char cesaAes192cipherHexEcb[] = "0060bffe46834bb8da5cf9a61ff220ae"; -char cesaAes256cipherHexEcb[] = "5a6e045708fb7196f02e553d02c3a692"; - -char cesaAsciiStr1[] = "Hi There"; -char cesaDataHexStr1[] = "4869205468657265"; -char cesaHmacMd5digestHex1[] = "9294727a3638bb1c13f48ef8158bfc9d"; -char cesaHmacSha1digestHex1[] = "b617318655057264e28bc0b6fb378c8ef146be00"; -char cesaDataAndMd5digest1[] = "48692054686572659294727a3638bb1c13f48ef8158bfc9d"; -char cesaDataAndSha1digest1[] = "4869205468657265b617318655057264e28bc0b6fb378c8ef146be00"; - -char cesaAesPlainText[] = "a0a1a2a3a4a5a6a7a8a9aaabacadaeaf" - "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf" - "c0c1c2c3c4c5c6c7c8c9cacbcccdcecf" - "d0d1d2d3d4d5d6d7d8d9dadbdcdddedf"; - -char cesaAes128CipherCbc[] = "c30e32ffedc0774e6aff6af0869f71aa" - "0f3af07a9a31a9c684db207eb0ef8e4e" - "35907aa632c3ffdf868bb7b29d3d46ad" - "83ce9f9a102ee99d49a53e87f4c3da55"; - -char cesaAesIvPlainText[] = "8ce82eefbea0da3c44699ed7db51b7d9" - "a0a1a2a3a4a5a6a7a8a9aaabacadaeaf" - "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf" - "c0c1c2c3c4c5c6c7c8c9cacbcccdcecf" - "d0d1d2d3d4d5d6d7d8d9dadbdcdddedf"; - -char cesaAes128IvCipherCbc[] = "8ce82eefbea0da3c44699ed7db51b7d9" - "c30e32ffedc0774e6aff6af0869f71aa" - "0f3af07a9a31a9c684db207eb0ef8e4e" - "35907aa632c3ffdf868bb7b29d3d46ad" - "83ce9f9a102ee99d49a53e87f4c3da55"; - -char cesaAesCtrPlain[] = "00E0017B27777F3F4A1786F000000001" - "000102030405060708090A0B0C0D0E0F" - "101112131415161718191A1B1C1D1E1F" - "20212223"; - -char cesaAesCtrCipher[] = "00E0017B27777F3F4A1786F000000001" - "C1CF48A89F2FFDD9CF4652E9EFDB72D7" - "4540A42BDE6D7836D59A5CEAAEF31053" - "25B2072F"; - - - -/* Input cesaHmacHex3 is '0xdd' repeated 50 times */ -char cesaHmacMd5digestHex3[] = "56be34521d144c88dbb8c733f0e8b3f6"; -char cesaHmacSha1digestHex3[] = "125d7342b9ac11cd91a39af48aa17b4f63f175d3"; -char cesaDataHexStr3[50*2+1] = ""; -char cesaDataAndMd5digest3[sizeof(cesaDataHexStr3)+sizeof(cesaHmacMd5digestHex3)+8*2+1] = ""; -char cesaDataAndSha1digest3[sizeof(cesaDataHexStr3)+sizeof(cesaHmacSha1digestHex3)+8*2+1] = ""; - -/* Ascii string is "abc" */ -char hashHexStr3[] = "616263"; -char hashMd5digest3[] = "900150983cd24fb0d6963f7d28e17f72"; -char hashSha1digest3[] = "a9993e364706816aba3e25717850c26c9cd0d89d"; - -char hashHexStr80[] = "31323334353637383930" - "31323334353637383930" - "31323334353637383930" - "31323334353637383930" - "31323334353637383930" - "31323334353637383930" - "31323334353637383930" - "31323334353637383930"; - -char hashMd5digest80[] = "57edf4a22be3c955ac49da2e2107b67a"; - -char tripleDesThenMd5digest80[] = "b7726a03aad490bd6c5a452a89a1b271"; -char tripleDesThenSha1digest80[] = "b2ddeaca91030eab5b95a234ef2c0f6e738ff883"; - -char cbc3desThenMd5digest80[] = "6f463057e1a90e0e91ae505b527bcec0"; -char cbc3desThenSha1digest80[] = "1b002ed050be743aa98860cf35659646bb8efcc0"; - -char cbcAes128ThenMd5digest80[] = "6b6e863ac5a71d15e3e9b1c86c9ba05f"; -char cbcAes128ThenSha1digest80[] = "13558472d1fc1c90dffec6e5136c7203452d509b"; - - -static MV_CESA_TEST_CASE cesaTestCases[] = -{ - /* plainHexStr cipherHexStr IV crypto mac digest */ - /* Length Length Offset */ - /*0*/ { NULL, NULL, NULL, 0, 0, -1 }, - /*1*/ { cesaPlainHexEbc, cesaCipherHexEcb, NULL, 24, 0, -1 }, - /*2*/ { cesaPlainHexCbc, cesaCipherHexCbc, NULL, 24, 0, -1 }, - /*3*/ { cesaAesPlainHexEcb, cesaAes128cipherHexEcb, NULL, 16, 0, -1 }, - /*4*/ { cesaAesPlainHexEcb, cesaAes192cipherHexEcb, NULL, 16, 0, -1 }, - /*5*/ { cesaAesPlainHexEcb, cesaAes256cipherHexEcb, NULL, 16, 0, -1 }, - /*6*/ { cesaDataHexStr1, cesaHmacMd5digestHex1, NULL, 0, 8, -1 }, - /*7*/ { NULL, cesaDataAndMd5digest1, NULL, 0, 8, -1 }, - /*8*/ { cesaDataHexStr3, cesaHmacMd5digestHex3, NULL, 0, 50, -1 }, - /*9*/ { NULL, cesaDataAndMd5digest3, NULL, 0, 50, -1 }, -/*10*/ { cesaAesPlainText, cesaAes128IvCipherCbc, iv5, 64, 0, -1 }, -/*11*/ { cesaDataHexStr1, cesaHmacSha1digestHex1, NULL, 0, 8, -1 }, -/*12*/ { NULL, cesaDataAndSha1digest1, NULL, 0, 8, -1 }, -/*13*/ { cesaDataHexStr3, cesaHmacSha1digestHex3, NULL, 0, 50, -1 }, -/*14*/ { NULL, cesaDataAndSha1digest3, NULL, 0, 50, -1 }, -/*15*/ { hashHexStr3, hashMd5digest3, NULL, 0, 3, -1 }, -/*16*/ { hashHexStr3, hashSha1digest3, NULL, 0, 3, -1 }, -/*17*/ { hashHexStr80, tripleDesThenMd5digest80, NULL, 80, 80, -1 }, -/*18*/ { hashHexStr80, tripleDesThenSha1digest80, NULL, 80, 80, -1 }, -/*19*/ { hashHexStr80, cbc3desThenMd5digest80, iv1, 80, 80, -1 }, -/*20*/ { hashHexStr80, cbc3desThenSha1digest80, iv1, 80, 80, -1 }, -/*21*/ { hashHexStr80, cbcAes128ThenMd5digest80, iv5, 80, 80, -1 }, -/*22*/ { hashHexStr80, cbcAes128ThenSha1digest80, iv5, 80, 80, -1 }, -/*23*/ { cesaAesCtrPlain, cesaAesCtrCipher, NULL, 36, 0, -1 }, -/*24*/ { cesaAesIvPlainText, cesaAes128IvCipherCbc, NULL, 64, 0, -1 }, -/*25*/ { plain3des1, cipher3des1, NULL, 0, 0, -1 }, -/*26*/ { plain3des2, cipher3desCbc2, iv3des2,0, 0, -1 }, -/*27*/ { plain3des3, cipher3desCbc3, iv3des3,0, 0, -1 }, -}; - - -/* Key = 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - * 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa - * Input 0xdd repeated "size" times - */ -static MV_CESA_SIZE_TEST mdMultiSizeTest302[] = -{ - { 80, "7a031a640c14a4872814930b1ef3a5b2" }, - { 512, "5488e6c5a14dc72a79f28312ca5b939b" }, - { 1000, "d00814f586a8b78a05724239d2531821" }, - { 1001, "bf07df7b7f49d3f5b5ecacd4e9e63281" }, - { 1002, "1ed4a1a802e87817a819d4e37bb4d0f7" }, - { 1003, "5972ab64a4f265ee371dac2f2f137f90" }, - { 1004, "71f95e7ec3aa7df2548e90898abdb28e" }, - { 1005, "e082790b4857fcfc266e92e59e608814" }, - { 1006, "9500f02fd8ac7fde8b10e4fece9a920d" }, - { 1336, "e42edcce57d0b75b01aa09d71427948b" }, - { 1344, "bb5454ada0deb49ba0a97ffd60f57071" }, - { 1399, "0f44d793e744b24d53f44f295082ee8c" }, - { 1400, "359de8a03a9b707928c6c60e0e8d79f1" }, - { 1401, "e913858b484cbe2b384099ea88d8855b" }, - { 1402, "d9848a164af53620e0540c1d7d87629e" }, - { 1403, "0c9ee1c2c9ef45e9b625c26cbaf3e822" }, - { 1404, "12edd4f609416e3c936170360561b064" }, - { 1405, "7fc912718a05446395345009132bf562" }, - { 1406, "882f17425e579ff0d85a91a59f308aa0" }, - { 1407, "005cae408630a2fb5db82ad9db7e59da" }, - { 1408, "64655f8b404b3fea7a3e3e609bc5088f" }, - { 1409, "4a145284a7f74e01b6bb1a0ec6a0dd80" }, - { 2048, "67caf64475650732def374ebb8bde3fd" }, - { 2049, "6c84f11f472825f7e6cd125c2981884b" }, - { 2050, "8999586754a73a99efbe4dbad2816d41" }, - { 2051, "ba6946b610e098d286bc81091659dfff" }, - { 2052, "d0afa01c92d4d13def2b024f36faed83" }, - { 3072, "61d8beac61806afa2585d74a9a0e6974" }, - { 3074, "f6501a28dcc24d1e4770505c51a87ed3" }, - { 3075, "ea4a6929be67e33e61ff475369248b73" }, - { 4048, "aa8c4d68f282a07e7385acdfa69f4bed" }, - { 4052, "afb5ed2c0e1d430ea59e59ed5ed6b18a" }, - { 4058, "9e8553f9bdd43aebe0bd729f0e600c99" }, - { 6144, "f628f3e5d183fe5cdd3a5abee39cf872" }, - { 6150, "89a3efcea9a2f25f919168ad4a1fd292" }, - { 6400, "cdd176b7fb747873efa4da5e32bdf88f" }, - { 6528, "b1d707b027354aca152c45ee559ccd3f" }, - { 8192, "c600ea4429ac47f9941f09182166e51a" }, - {16384, "16e8754bfbeb4c649218422792267a37" }, - {18432, "0fd0607521b0aa8b52219cfbe215f63e" }, - { 0, NULL }, -}; - -/* Key = 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - * 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10 - * InputHexStr = "31323334353637383930" (ASCII = "1234567890") - */ -static MV_CESA_SIZE_TEST mdMultiSizeTest304[] = -{ - { 80, "a456c4723fee6068530af5a2afa71627" }, - { 512, "f85c2a2344f5de68b432208ad13e5794" }, - { 1000, "35464d6821fd4a293a41eb84e274c8c5" }, - { 1001, "c08eedbdce60cceb54bc2d732bb32c8b" }, - { 1002, "5664f71800c011cc311cb6943339c1b8" }, - { 1003, "779c723b044c585dc7802b13e8501bdc" }, - { 1004, "55e500766a2c307bc5c5fdd15e4cacd4" }, - { 1005, "d5f978954f5c38529d1679d2b714f068" }, - { 1006, "cd3efc827ce628b7281b72172693abf9" }, - { 1336, "6f04479910785878ae6335b8d1e87edf" }, - { 1344, "b6d27b50c2bce1ba2a8e1b5cc4324368" }, - { 1399, "65f70a1d4c86e5eaeb0704c8a7816795" }, - { 1400, "3394b5adc4cb3ff98843ca260a44a88a" }, - { 1401, "3a06f3582033a66a4e57e0603ce94e74" }, - { 1402, "e4d97f5ed51edc48abfa46eeb5c31752" }, - { 1403, "3d05e40b080ee3bedf293cb87b7140e7" }, - { 1404, "8cf294fc3cd153ab18dccb2a52cbf244" }, - { 1405, "d1487bd42f6edd9b4dab316631159221" }, - { 1406, "0527123b6bf6936cf5d369dc18c6c70f" }, - { 1407, "3224a06639db70212a0cd1ae1fcc570a" }, - { 1408, "a9e13335612c0356f5e2c27086e86c43" }, - { 1409, "a86d1f37d1ed8a3552e9a4f04dceea98" }, - { 2048, "396905c9b961cd0f6152abfb69c4449c" }, - { 2049, "49f39bff85d9dcf059fadb89efc4a70f" }, - { 2050, "3a2b4823bc4d0415656550226a63e34a" }, - { 2051, "dec60580d406c782540f398ad0bcc7e0" }, - { 2052, "32f76610a14310309eb748fe025081bf" }, - { 3072, "45edc1a42bf9d708a621076b63b774da" }, - { 3074, "9be1b333fe7c0c9f835fb369dc45f778" }, - { 3075, "8c06fcac7bd0e7b7a17fd6508c09a549" }, - { 4048, "0ddaef848184bf0ad98507a10f1e90e4" }, - { 4052, "81976bcaeb274223983996c137875cb8" }, - { 4058, "0b0a7a1c82bc7cbc64d8b7cd2dc2bb22" }, - { 6144, "1c24056f52725ede2dff0d7f9fc9855f" }, - { 6150, "b7f4b65681c4e43ee68ca466ca9ca4ec" }, - { 6400, "443bbaab9f7331ddd4bf11b659cd43c8" }, - { 6528, "216f44f23047cfee03a7a64f88f9a995" }, - { 8192, "ac7a993b2cad54879dba1bde63e39097" }, - { 8320, "55ed7be9682d6c0025b3221a62088d08" }, - {16384, "c6c722087653b62007aea668277175e5" }, - {18432, "f1faca8e907872c809e14ffbd85792d6" }, - { 0, NULL }, -}; - -/* HASH-MD5 - * InputHexStr = "31323334353637383930" (ASCII = "1234567890") - * repeated "size" times - */ -static MV_CESA_SIZE_TEST mdMultiSizeTest305[] = -{ - { 80, "57edf4a22be3c955ac49da2e2107b67a" }, - { 512, "c729ae8f0736cc377a9767a660eaa04e" }, - { 1000, "f1257a8659eb92d36fe14c6bf3852a6a" }, - { 1001, "f8a46fe8ea04fdc8c7de0e84042d3878" }, - { 1002, "da188dd67bff87d58aa3c02af2d0cc0f" }, - { 1003, "961753017feee04c9b93a8e51658a829" }, - { 1004, "dd68c4338608dcc87807a711636bf2af" }, - { 1005, "e338d567d3ce66bf69ada29658a8759b" }, - { 1006, "443c9811e8b92599b0b149e8d7ec700a" }, - { 1336, "89a98511706008ba4cbd0b4a24fa5646" }, - { 1344, "335a919805f370b9e402a62c6fe01739" }, - { 1399, "5d18d0eddcd84212fe28d812b5e80e3b" }, - { 1400, "6b695c240d2dffd0dffc99459ca76db6" }, - { 1401, "49590f61298a76719bc93a57a30136f5" }, - { 1402, "94c2999fa3ef1910a683d69b2b8476f2" }, - { 1403, "37073a02ab00ecba2645c57c228860db" }, - { 1404, "1bcd06994fce28b624f0c5fdc2dcdd2b" }, - { 1405, "11b93671a64c95079e8cf9e7cddc8b3d" }, - { 1406, "4b6695772a4c66313fa4871017d05f36" }, - { 1407, "d1539b97fbfda1c075624e958de19c5b" }, - { 1408, "b801b9b69920907cd018e8063092ede9" }, - { 1409, "b765f1406cfe78e238273ed01bbcaf7e" }, - { 2048, "1d7e2c64ac29e2b3fb4c272844ed31f5" }, - { 2049, "71d38fac49c6b1f4478d8d88447bcdd0" }, - { 2050, "141c34a5592b1bebfa731e0b23d0cdba" }, - { 2051, "c5e1853f21c59f5d6039bd13d4b380d8" }, - { 2052, "dd44a0d128b63d4b5cccd967906472d7" }, - { 3072, "37d158e33b21390822739d13db7b87fe" }, - { 3074, "aef3b209d01d39d0597fe03634bbf441" }, - { 3075, "335ffb428eabf210bada96d74d5a4012" }, - { 4048, "2434c2b43d798d2819487a886261fc64" }, - { 4052, "ac2fa84a8a33065b2e92e36432e861f8" }, - { 4058, "856781f85616c341c3533d090c1e1e84" }, - { 6144, "e5d134c652c18bf19833e115f7a82e9b" }, - { 6150, "a09a353be7795fac2401dac5601872e6" }, - { 6400, "08b9033ac6a1821398f50af75a2dbc83" }, - { 6528, "3d47aa193a8540c091e7e02f779e6751" }, - { 8192, "d3164e710c0626f6f395b38f20141cb7" }, - { 8320, "b727589d9183ff4e8491dd24466974a3" }, - {16384, "3f54d970793d2274d5b20d10a69938ac" }, - {18432, "f558511dcf81985b7a1bb57fad970531" }, - { 0, NULL }, -}; - - -/* Key = 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - * 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa - * 0xaa, 0xaa, 0xaa, 0xaa - * InputHexStr = "31323334353637383930" (ASCII = "1234567890") - */ -static MV_CESA_SIZE_TEST shaMultiSizeTest402[] = -{ - { 80, "e812f370e659705a1649940d1f78cd7af18affd3" }, - { 512, "e547f886b2c15d995ed76a8a924cb408c8080f66" }, - { 1000, "239443194409f1a5342ecde1a092c8f3a3ed790a" }, - { 1001, "f278ab9a102850a9f48dc4e9e6822afe2d0c52b5" }, - { 1002, "8bcc667df5ab6ece988b3af361d09747c77f4e72" }, - { 1003, "0fae6046c7dc1d3e356b25af836f6077a363f338" }, - { 1004, "0ea48401cc92ae6bc92ae76685269cb0167fbe1a" }, - { 1005, "ecbcd7c879b295bafcd8766cbeac58cc371e31d1" }, - { 1006, "eb4a4a3d07d1e9a15e6f1ab8a9c47f243e27324c" }, - { 1336, "f5950ee1d77c10e9011d2149699c9366fe52529c" }, - { 1344, "b04263604a63c351b0b3b9cf1785b4bdba6c8838" }, - { 1399, "8cb1cff61d5b784045974a2fc69386e3b8d24218" }, - { 1400, "9bb2f3fcbeddb2b90f0be797cd647334a2816d51" }, - { 1401, "23ae462a7a0cb440f7445791079a5d75a535dd33" }, - { 1402, "832974b524a4d3f9cc2f45a3cabf5ccef65cd2aa" }, - { 1403, "d1c683742fe404c3c20d5704a5430e7832a7ec95" }, - { 1404, "867c79042e64f310628e219d8b85594cd0c7adc3" }, - { 1405, "c9d81d49d13d94358f56ccfd61af02b36c69f7c3" }, - { 1406, "0df43daab2786172f9b8d07d61f14a070cf1287a" }, - { 1407, "0fd8f3ad7f169534b274d4c66bbddd89f759e391" }, - { 1408, "3987511182b18473a564436003139b808fa46343" }, - { 1409, "ef667e063c9e9f539a8987a8d0bd3066ee85d901" }, - { 2048, "921109c99f3fedaca21727156d5f2b4460175327" }, - { 2049, "47188600dd165eb45f27c27196d3c46f4f042c1b" }, - { 2050, "8831939904009338de10e7fa670847041387807d" }, - { 2051, "2f8ebb5db2997d614e767be1050366f3641e7520" }, - { 2052, "669e51cd730dae158d3bef8adba075bd95a0d011" }, - { 3072, "cfee66cfd83abc8451af3c96c6b35a41cc6c55f5" }, - { 3074, "216ea26f02976a261b7d21a4dd3085157bedfabd" }, - { 3075, "bd612ebba021fd8e012b14c3bd60c8c5161fabc0" }, - { 4048, "c2564c1fdf2d5e9d7dde7aace2643428e90662e8" }, - { 4052, "91ce61fe924b445dfe7b5a1dcd10a27caec16df6" }, - { 4058, "db2a9be5ee8124f091c7ebd699266c5de223c164" }, - { 6144, "855109903feae2ba3a7a05a326b8a171116eb368" }, - { 6150, "37520bb3a668294d9c7b073e7e3daf8fee248a78" }, - { 6400, "60a353c841b6d2b1a05890349dad2fa33c7536b7" }, - { 6528, "9e53a43a69bb42d7c8522ca8bd632e421d5edb36" }, - { 8192, "a918cb0da862eaea0a33ee0efea50243e6b4927c" }, - { 8320, "29a5dcf55d1db29cd113fcf0572ae414f1c71329" }, - {16384, "6fb27966138e0c8d5a0d65ace817ebd53633cee1" }, - {18432, "ca09900d891c7c9ae2a559b10f63a217003341c1" }, - { 0, NULL }, -}; - -/* Key = 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - * 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10 - * 0x11, 0x12, 0x13, 0x14 - * InputHexStr = "31323334353637383930" (ASCII = "1234567890") - */ -static MV_CESA_SIZE_TEST shaMultiSizeTest404[] = -{ - { 80, "beaf20a34b06a87558d156c0949bc3957d40222e" }, - { 512, "3353955358d886bc2940a3c7f337ff7dafb59c7b" }, - { 1000, "8737a542c5e9b2b6244b757ebb69d5bd602a829f" }, - { 1001, "fd9e7582d8a5d3c9fe3b923e4e6a41b07a1eb4d4" }, - { 1002, "a146d14a6fc3c274ff600568f4d75b977989e00d" }, - { 1003, "be22601bbc027ddef2dec97d30b3dc424fd803c5" }, - { 1004, "3e71fe99b2fe2b7bfdf4dbf0c7f3da25d7ea35e7" }, - { 1005, "2c422735d7295408fddd76f5e8a83a2a8da13df3" }, - { 1006, "6d875319049314b61855101a647b9ba3313428e6" }, - { 1336, "c1631ea80bad9dc43a180712461b65a0598c711c" }, - { 1344, "816069bf91d34581005746e2e0283d0f9c7b7605" }, - { 1399, "4e139866dc61cfcb8b67ca2ebd637b3a538593af" }, - { 1400, "ff2a0f8dd2b02c5417910f6f55d33a78e081a723" }, - { 1401, "ab00c12be62336964cbce31ae97fe2a0002984d5" }, - { 1402, "61349e7f999f3a1acc56c3e9a5060a9c4a7b05b6" }, - { 1403, "3edbc0f61e435bc1317fa27d840076093fb79353" }, - { 1404, "d052c6dfdbe63d45dab23ef9893e2aa4636aca1e" }, - { 1405, "0cc16b7388d67bf0add15a31e6e6c753cfae4987" }, - { 1406, "c96ba7eaad74253c38c22101b558d2850b1d1b90" }, - { 1407, "3445428a40d2c6556e7c55797ad8d323b61a48d9" }, - { 1408, "8d6444f937a09317c89834187b8ea9b8d3a8c56b" }, - { 1409, "c700acd3ecd19014ea2bdb4d42510c467e088475" }, - { 2048, "ee27d2a0cb77470c2f496212dfd68b5bb7b04e4b" }, - { 2049, "683762d7a02983b26a6d046e6451d9cd82c25932" }, - { 2050, "0fd20f1d55a9ee18363c2a6fd54aa13aee69992f" }, - { 2051, "86c267d8cc4bc8d59090e4f8b303da960fd228b7" }, - { 2052, "452395ae05b3ec503eea34f86fc0832485ad97c1" }, - { 3072, "75198e3cfd0b9bcff2dabdf8e38e6fdaa33ca49a" }, - { 3074, "4e24785ef080141ce4aab4675986d9acea624d7c" }, - { 3075, "3a20c5978dd637ec0e809bf84f0d9ccf30bc65bf" }, - { 4048, "3c32da256be7a7554922bf5fed51b0d2d09e59ad" }, - { 4052, "fff898426ea16e54325ae391a32c6c9bce4c23c0" }, - { 4058, "c800b9e562e1c91e1310116341a3c91d37f848ec" }, - { 6144, "d91d509d0cc4376c2d05bf9a5097717a373530e6" }, - { 6150, "d957030e0f13c5df07d9eec298542d8f94a07f12" }, - { 6400, "bb745313c3d7dc17b3f955e5534ad500a1082613" }, - { 6528, "77905f80d9ca82080bbb3e5654896dabfcfd1bdb" }, - { 8192, "5237fd9a81830c974396f99f32047586612ff3c0" }, - { 8320, "57668e28d5f2dba0839518a11db0f6af3d7e08bf" }, - {16384, "62e093fde467f0748087beea32e9af97d5c61241" }, - {18432, "845fb33130c7d6ea554fd5aacb9c50cf7ccb5929" }, - { 0, NULL }, -}; - -/* HASH-SHA1 - * InputHexStr = "31323334353637383930" (ASCII = "1234567890") - * repeated "size" times - */ -static MV_CESA_SIZE_TEST shaMultiSizeTest405[] = -{ - { 80, "50abf5706a150990a08b2c5ea40fa0e585554732" }, - { 512, "f14516a08948fa27917a974d219741a697ba0087" }, - { 1000, "0bd18c378d5788817eb4f1e5dc07d867efa5cbf4" }, - { 1001, "ca29b85c35db1b8aef83c977893a11159d1b7aa2" }, - { 1002, "d83bc973eaaedb8a31437994dabbb3304b0be086" }, - { 1003, "2cf7bbef0acd6c00536b5c58ca470df9a3a90b6c" }, - { 1004, "e4375d09b1223385a8a393066f8209acfd936a80" }, - { 1005, "1029b38043e027745d019ce1d2d68e3d8b9d8f99" }, - { 1006, "deea16dcebbd8ac137e2b984deb639b9fb5e9680" }, - { 1336, "ea031b065fff63dcfb6a41956e4777520cdbc55d" }, - { 1344, "b52096c6445e6c0a8355995c70dc36ae186c863c" }, - { 1399, "cde2f6f8379870db4b32cf17471dc828a8dbff2b" }, - { 1400, "e53ff664064bc09fe5054c650806bd42d8179518" }, - { 1401, "d1156db5ddafcace64cdb510ff0d4af9b9a8ad64" }, - { 1402, "34ede0e9a909dd84a2ae291539105c0507b958e1" }, - { 1403, "a772ca3536da77e6ad3251e4f9e1234a4d7b87c0" }, - { 1404, "29740fd2b04e7a8bfd32242db6233156ad699948" }, - { 1405, "65b17397495b70ce4865dad93bf991b74c97cce1" }, - { 1406, "a7ee89cd0754061fdb91af7ea6abad2c69d542e3" }, - { 1407, "3eebf82f7420188e23d328b7ce93580b279a5715" }, - { 1408, "e08d3363a8b9a490dfb3a4c453452b8f114deeec" }, - { 1409, "95d74df739181a4ff30b8c39e28793a36598e924" }, - { 2048, "aa40262509c2abf84aab0197f83187fc90056d91" }, - { 2049, "7dec28ef105bc313bade8d9a7cdeac58b99de5ea" }, - { 2050, "d2e30f77ec81197de20f56588a156094ecb88450" }, - { 2051, "6b22ccc874833e96551a39da0c0edcaa0d969d92" }, - { 2052, "f843141e57875cd669af58744bc60aa9ea59549c" }, - { 3072, "09c5fedeaa62c132e673cc3c608a00142273d086" }, - { 3074, "b09e95eea9c7b1b007a58accec488301901a7f3d" }, - { 3075, "e6226b77b4ada287a8c9bbcf4ed71eec5ce632dc" }, - { 4048, "e99394894f855821951ddddf5bfc628547435f5c" }, - { 4052, "32d2f1af38be9cfba6cd03d55a254d0b3e1eb382" }, - { 4058, "d906552a4f2aca3a22e1fecccbcd183d7289d0ef" }, - { 6144, "2e7f62d35a860988e1224dc0543204af19316041" }, - { 6150, "d6b89698ee133df46fec9d552fadc328aa5a1b51" }, - { 6400, "dff50e90c46853988fa3a4b4ce5dda6945aae976" }, - { 6528, "9e63ec0430b96db02d38bc78357a2f63de2ab7f8" }, - { 8192, "971eb71ed60394d5ab5abb12e88420bdd41b5992" }, - { 8320, "91606a31b46afeaac965cecf87297e791b211013" }, - {16384, "547f830a5ec1f5f170ce818f156b1002cabc7569" }, - {18432, "f16f272787f3b8d539652e4dc315af6ab4fda0ef" }, - { 0, NULL }, -}; - -/* CryptoKey = 0x01234567, 0x89abcdef, - * 0x01234567, 0x89abcdef, - * 0x01234567, 0x89abcdef; - * MacKey = 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - * 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10 - * InputHexStr = "31323334353637383930" (ASCII = "1234567890") - * Note: only sizes aligned to 3DES block size (8 bytes) allowed - */ -static MV_CESA_SIZE_TEST tripleDesMdMultiSizeTest502[] = -{ - { 64, "9586962a2aaaef28803dec2e17807a7f" }, - { 80, "b7726a03aad490bd6c5a452a89a1b271" }, - { 352, "f1ed9563aecc3c0d2766eb2bed3b4e4c" }, - { 512, "0f9decb11ab40fe86f4d4d9397bc020e" }, - { 1000, "3ba69deac12cab8ff9dff7dbd9669927" }, - { 1336, "6cf47bf1e80e03e2c1d0945bc50d37d2" }, - { 1344, "4be388dab21ceb3fa1b8d302e9b821f7" }, - { 1400, "a58b79fb21dd9bfc6ec93e3b99fb0ef1" }, - { 1408, "8bc97379fc2ac3237effcdd4f7a86528" }, - { 2048, "1339f03ab3076f25a20bc4cba16eb5bf" }, - { 3072, "731204d2d90c4b36ae41f5e1fb874288" }, - { 4048, "c028d998cfda5642547b7e1ed5ea16e4" }, - { 6144, "b1b19cd910cc51bd22992f1e59f1e068" }, - { 6400, "44e4613496ba622deb0e7cb768135a2f" }, - { 6528, "3b06b0a86f8db9cd67f9448dfcf10549" }, - { 8192, "d581780b7163138a0f412be681457d82" }, - {16384, "03b8ac05527faaf1bed03df149c65ccf" }, - {18432, "677c8a86a41dab6c5d81b85b8fb10ff6" }, - { 0, NULL }, -}; - - -/* CryptoKey = 0x01234567, 0x89abcdef, - * 0x01234567, 0x89abcdef, - * 0x01234567, 0x89abcdef; - * MacKey = 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - * 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10 - * 0x11, 0x12, 0x13, 0x14 - * InputHexStr = "31323334353637383930" (ASCII = "1234567890") - * Note: only sizes aligned to 3DES block size (8 bytes) allowed - */ -static MV_CESA_SIZE_TEST tripleDesShaMultiSizeTest503[] = -{ - { 64, "44a1e9bcbfc1429630d9ea68b7a48b0427a684f2" }, - { 80, "b2ddeaca91030eab5b95a234ef2c0f6e738ff883" }, - { 352, "4b91864c7ff629bdff75d9726421f76705452aaf" }, - { 512, "6dd37faceeb2aa98ba74f4242ed6734a4d546af5" }, - { 1000, "463661c30300be512a9df40904f0757cde5f1141" }, - { 1336, "b931f831d9034fe59c65176400b039fe9c1f44a5" }, - { 1344, "af8866b1cd4a4887d6185bfe72470ffdfb3648e1" }, - { 1400, "49c6caf07296d5e31d2504d088bc5b20c3ee7cdb" }, - { 1408, "fcae8deedbc6ebf0763575dc7e9de075b448a0f4" }, - { 2048, "edece5012146c1faa0dd10f50b183ba5d2af58ac" }, - { 3072, "5b83625adb43a488b8d64fecf39bb766818547b7" }, - { 4048, "d2c533678d26c970293af60f14c8279dc708bfc9" }, - { 6144, "b8f67af4f991b08b725f969b049ebf813bfacc5c" }, - { 6400, "d9a6c7f746ac7a60ef2edbed2841cf851c25cfb0" }, - { 6528, "376792b8c8d18161d15579fb7829e6e3a27e9946" }, - { 8192, "d890eabdca195b34ef8724b28360cffa92ae5655" }, - {16384, "a167ee52639ec7bf19aee9c6e8f76667c14134b9" }, - {18432, "e4396ab56f67296b220985a12078f4a0e365d2cc" }, - { 0, NULL }, -}; - -/* CryptoKey = 0x01234567, 0x89abcdef, - * 0x01234567, 0x89abcdef, - * 0x01234567, 0x89abcdef - * IV = 0x12345678, 0x90abcdef - * MacKey = 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - * 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10 - * InputHexStr = "31323334353637383930" (ASCII = "1234567890") - * Note: only sizes aligned to 3DES block size (8 bytes) allowed - */ -static MV_CESA_SIZE_TEST cbc3desMdMultiSizeTest504[] = -{ - { 64, "8d10e00802460ede0058c139ba48bd2d" }, - { 80, "6f463057e1a90e0e91ae505b527bcec0" }, - { 352, "4938d48bdf86aece2c6851e7c6079788" }, - { 512, "516705d59f3cf810ebf2a13a23a7d42e" }, - { 1000, "a5a000ee5c830e67ddc6a2d2e5644b31" }, - { 1336, "44af60087b74ed07950088efbe3b126a" }, - { 1344, "1f5b39e0577920af731dabbfcf6dfc2a" }, - { 1400, "6804ea640e29b9cd39e08bc37dbce734" }, - { 1408, "4fb436624b02516fc9d1535466574bf9" }, - { 2048, "c909b0985c423d8d86719f701e9e83db" }, - { 3072, "cfe0bc34ef97213ee3d3f8b10122db21" }, - { 4048, "03ea10b5ae4ddeb20aed6af373082ed1" }, - { 6144, "b9a0ff4f87fc14b3c2dc6f0ed0998fdf" }, - { 6400, "6995f85d9d4985dd99e974ec7dda9dd6" }, - { 6528, "bbbb548ce2fa3d58467f6a6a5168a0e6" }, - { 8192, "afe101fbe745bb449ae4f50d10801456" }, - {16384, "9741706d0b1c923340c4660ff97cacdf" }, - {18432, "b0217becb73cb8f61fd79c7ce9d023fb" }, - { 0, NULL }, -}; - - -/* CryptoKey = 0x01234567, 0x89abcdef, - * 0x01234567, 0x89abcdef, - * 0x01234567, 0x89abcdef; - * IV = 0x12345678, 0x90abcdef - * MacKey = 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - * 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10 - * 0x11, 0x12, 0x13, 0x14 - * InputHexStr = "31323334353637383930" (ASCII = "1234567890") - * Note: only sizes aligned to 3DES block size (8 bytes) allowed - */ -static MV_CESA_SIZE_TEST cbc3desShaMultiSizeTest505[] = -{ - { 64, "409187e5bdb0be4a7754ca3747f7433dc4f01b98" }, - { 80, "1b002ed050be743aa98860cf35659646bb8efcc0" }, - { 352, "6cbf7ebe50fa4fa6eecc19eca23f9eae553ccfff" }, - { 512, "cfb5253fb4bf72b743320c30c7e48c54965853b0" }, - { 1000, "95e04e1ca2937e7c5a9aba9e42d2bcdb8a7af21f" }, - { 1336, "3b5c1f5eee5837ebf67b83ae01405542d77a6627" }, - { 1344, "2b3d42ab25615437f98a1ee310b81d07a02badc2" }, - { 1400, "7f8687df7c1af44e4baf3c934b6cca5ab6bc993e" }, - { 1408, "473a581c5f04f7527d50793c845471ac87e86430" }, - { 2048, "e41d20cae7ebe34e6e828ed62b1e5734019037bb" }, - { 3072, "275664afd7a561d804e6b0d204e53939cde653ae" }, - { 4048, "0d220cc5b34aeeb46bbbd637dde6290b5a8285a3" }, - { 6144, "cb393ddcc8b1c206060625b7d822ef9839e67bc5" }, - { 6400, "dd3317e2a627fc04800f74a4b05bfda00fab0347" }, - { 6528, "8a74c3b2441ab3f5a7e08895cc432566219a7c41" }, - { 8192, "b8e6ef3a549ed0e005bd5b8b1a5fe6689e9711a7" }, - {16384, "55f59404008276cdac0e2ba0d193af2d40eac5ce" }, - {18432, "86ae6c4fc72369a54cce39938e2d0296cd9c6ec5" }, - { 0, NULL }, -}; - - -/* CryptoKey = 0x01234567, 0x89abcdef, - * 0x01234567, 0x89abcdef, - * 0x01234567, 0x89abcdef - * IV = 0x12345678, 0x90abcdef - * MacKey = 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - * 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10 - * InputHexStr = "31323334353637383930" (ASCII = "1234567890") - * Note: only sizes aligned to AES block size (16 bytes) allowed - */ -static MV_CESA_SIZE_TEST cbcAes128md5multiSizeTest506[] = -{ - { 16, "7ca4c2ba866751598720c5c4aa0d6786" }, - { 64, "7dba7fb988e80da609b1fea7254bced8" }, - { 80, "6b6e863ac5a71d15e3e9b1c86c9ba05f" }, - { 352, "a1ceb9c2e3021002400d525187a9f38c" }, - { 512, "596c055c1c55db748379223164075641" }, - { 1008, "f920989c02f3b3603f53c99d89492377" }, - { 1344, "2e496b73759d77ed32ea222dbd2e7b41" }, - { 1408, "7178c046b3a8d772efdb6a71c4991ea4" }, - { 2048, "a917f0099c69eb94079a8421714b6aad" }, - { 3072, "693cd5033d7f5391d3c958519fa9e934" }, - { 4048, "139dca91bcff65b3c40771749052906b" }, - { 6144, "428d9cef6df4fb70a6e9b6bbe4819e55" }, - { 6400, "9c0b909e76daa811e12b1fc17000a0c4" }, - { 6528, "ad876f6297186a7be1f1b907ed860eda" }, - { 8192, "479cbbaca37dd3191ea1f3e8134a0ef4" }, - {16384, "60fda559c74f91df538100c9842f2f15" }, - {18432, "4a3eb1cba1fa45f3981270953f720c42" }, - { 0, NULL }, -}; - - -/* CryptoKey = 0x01234567, 0x89abcdef, - * 0x01234567, 0x89abcdef, - * 0x01234567, 0x89abcdef; - * IV = 0x12345678, 0x90abcdef - * MacKey = 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - * 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10 - * 0x11, 0x12, 0x13, 0x14 - * InputHexStr = "31323334353637383930" (ASCII = "1234567890") - * Note: only sizes aligned to AES block size (16 bytes) allowed - */ -static MV_CESA_SIZE_TEST cbcAes128sha1multiSizeTest507[] = -{ - { 16, "9aa8dc1c45f0946daf78057fa978759c625c1fee" }, - { 64, "9f588fc1ede851e5f8b20256abc9979465ae2189" }, - { 80, "13558472d1fc1c90dffec6e5136c7203452d509b" }, - { 352, "6b93518e006cfaa1f7adb24615e7291fb0a27e06" }, - { 512, "096874951a77fbbf333e49d80c096ee2016e09bd" }, - { 1008, "696fc203c2e4b5ae0ec5d1db3f623c490bc6dbac" }, - { 1344, "79bf77509935ccd3528caaac6a5eb6481f74029b" }, - { 1408, "627f9462b95fc188e8cfa7eec15119bdc5d4fcf1" }, - { 2048, "3d50d0c005feba92fe41502d609fced9c882b4d1" }, - { 3072, "758807e5b983e3a91c06fb218fe0f73f77111e94" }, - { 4048, "ca90e85242e33f005da3504416a52098d0d31fb2" }, - { 6144, "8044c1d4fd06642dfc46990b4f18b61ef1e972cf" }, - { 6400, "166f1f4ea57409f04feba9fb1e39af0e00bd6f43" }, - { 6528, "0389016a39485d6e330f8b4215ddf718b404f7e9" }, - { 8192, "6df7ee2a8b61d6f7f860ce8dbf778f0c2a5b508b" }, - {16384, "a70a6d8dfa1f91ded621c3dbaed34162bc48783f" }, - {18432, "8dfad627922ce15df1eed10bdbed49244efa57db" }, - { 0, NULL }, -}; - - -void cesaTestPrintStatus(void); - - -/*------------------------- LOCAL FUNCTIONs ---------------------------------*/ -MV_STATUS testCmd(int sid, int iter, MV_CESA_COMMAND* pCmd, - MV_CESA_TEST_SESSION* pTestSession, MV_U8* pIV, int ivSize); -MV_STATUS testClose(int idx); -MV_STATUS testOpen(int idx); -void close_session(int sid); -void cesaTestCheckReady(const MV_CESA_RESULT *r); -void cesaCheckReady(MV_CESA_RESULT* r); -void printTestResults(int idx, MV_STATUS status, int checkMode); -void cesaLastResult(void); -void cesaTestPrintReq(int req, int offset, int size); - -void cesaTestPrintStatus(void); -void cesaTestPrintSession(int idx); -void sizeTest(int testIdx, int iter, int checkMode); -void multiTest(int iter, int reqSize, int checkMode); -void oneTest(int testIdx, int caseIdx,int iter, int reqSize, int checkMode); -void multiSizeTest(int idx, int iter, int checkMode, char* inputData); -void cesaTest(int iter, int reqSize, int checkMode); -void cesaOneTest(int testIdx, int caseIdx,int iter, int reqSize, int checkMode); -void combiTest(int iter, int reqSize, int checkMode); -void shaTest(int iter, int reqSize, int checkMode); -void mdTest(int iter, int reqSize, int checkMode); -void aesTest(int iter, int reqSize, int checkMode); -void tripleDesTest(int iter, int reqSize, int checkMode); -void desTest(int iter, int reqSize, int checkMode); -void cesaTestStop(void); -MV_STATUS testRun(int idx, int caseIdx, int iter,int reqSize, int checkMode); -void cesaTestStart(int bufNum, int bufSize); - - -static MV_U32 getRate(MV_U32* remainder) -{ - MV_U32 kBits, milliSec, rate; - - milliSec = 0; - if( (cesaEndTicks - cesaBeginTicks) > 0) - { - milliSec = CESA_TEST_TICK_TO_MS(cesaEndTicks - cesaBeginTicks); - } - if(milliSec == 0) - { - if(remainder != NULL) - *remainder = 0; - return 0; - } - - kBits = (cesaIteration*cesaRateSize*8)/1000; - rate = kBits/milliSec; - if(remainder != NULL) - *remainder = ((kBits % milliSec)*10)/milliSec; - - return rate; -} - -static char* extractMbuf(MV_CESA_MBUF *pMbuf, - int offset, int size, char* hexStr) -{ - mvCesaCopyFromMbuf((MV_U8*)cesaBinBuffer, pMbuf, offset, size); - mvBinToHex((const MV_U8*)cesaBinBuffer, hexStr, size); - - return hexStr; -} - -static MV_BOOL cesaCheckMbuf(MV_CESA_MBUF *pMbuf, - const char* hexString, int offset, - int checkSize) -{ - MV_BOOL isFailed = MV_FALSE; - MV_STATUS status; - int size = strlen(hexString)/2; - int checkedSize = 0; -/* - mvOsPrintf("cesaCheckMbuf: pMbuf=%p, offset=%d, checkSize=%d, mBufSize=%d\n", - pMbuf, offset, checkSize, pMbuf->mbufSize); -*/ - if(pMbuf->mbufSize < (checkSize + offset)) - { - mvOsPrintf("checkSize (%d) is too large: offset=%d, mbufSize=%d\n", - checkSize, offset, pMbuf->mbufSize); - return MV_TRUE; - } - status = mvCesaCopyFromMbuf((MV_U8*)cesaBinBuffer, pMbuf, offset, checkSize); - if(status != MV_OK) - { - mvOsPrintf("CesaTest: Can't copy %d bytes from Mbuf=%p to checkBuf=%p\n", - checkSize, pMbuf, cesaBinBuffer); - return MV_TRUE; - } -/* - mvDebugMemDump(cesaBinBuffer, size, 1); -*/ - mvHexToBin(hexString, (MV_U8*)cesaExpBinBuffer, size); - - /* Compare buffers */ - while(checkSize > checkedSize) - { - size = MV_MIN(size, (checkSize - checkedSize)); - if(memcmp(cesaExpBinBuffer, &cesaBinBuffer[checkedSize], size) != 0) - { - mvOsPrintf("CheckMbuf failed: checkSize=%d, size=%d, checkedSize=%d\n", - checkSize, size, checkedSize); - mvDebugMemDump(&cesaBinBuffer[checkedSize], size, 1); - mvDebugMemDump(cesaExpBinBuffer, size, 1); - - isFailed = MV_TRUE; - break; - } - checkedSize += size; - } - - return isFailed; -} - -static MV_STATUS cesaSetMbuf(MV_CESA_MBUF *pMbuf, - const char* hexString, - int offset, int reqSize) -{ - MV_STATUS status = MV_OK; - int copySize, size = strlen(hexString)/2; - - mvHexToBin(hexString, (MV_U8*)cesaBinBuffer, size); - - copySize = 0; - while(reqSize > copySize) - { - size = MV_MIN(size, (reqSize - copySize)); - - status = mvCesaCopyToMbuf((MV_U8*)cesaBinBuffer, pMbuf, offset+copySize, size); - if(status != MV_OK) - { - mvOsPrintf("cesaSetMbuf Error: Copy %d of %d bytes to MBuf\n", - copySize, reqSize); - break; - } - copySize += size; - } - pMbuf->mbufSize = offset+copySize; - return status; -} - -static MV_CESA_TEST_SESSION* getTestSessionDb(int idx, int* pTestIdx) -{ - int testIdx, dbIdx = idx/100; - - if(dbIdx > MAX_TEST_TYPE) - { - mvOsPrintf("Wrong index %d - No such test type\n", idx); - return NULL; - } - testIdx = idx % 100; - - if(testIdx >= cesaTestsDB[dbIdx].numSessions) - { - mvOsPrintf("Wrong index %d - No such test\n", idx); - return NULL; - } - if(pTestIdx != NULL) - *pTestIdx = testIdx; - - return cesaTestsDB[dbIdx].pSessions; -} - -/* Debug */ -void cesaTestPrintReq(int req, int offset, int size) -{ - MV_CESA_MBUF* pMbuf; - - mvOsPrintf("cesaTestPrintReq: req=%d, offset=%d, size=%d\n", - req, offset, size); - mvDebugMemDump(cesaCmdRing, 128, 4); - - pMbuf = cesaCmdRing[req].pSrc; - mvCesaDebugMbuf("src", pMbuf, offset,size); - pMbuf = cesaCmdRing[req].pDst; - mvCesaDebugMbuf("dst", pMbuf, offset, size); - - cesaTestPrintStatus(); -} - -void cesaLastResult(void) -{ - mvOsPrintf("Last Result: ReqId = %d, SessionId = %d, rc = (%d)\n", - (MV_U32)cesaResult.pReqPrv, cesaResult.sessionId, - cesaResult.retCode); -} - -void printTestResults(int idx, MV_STATUS status, int checkMode) -{ - int testIdx; - MV_CESA_TEST_SESSION* pTestSessions = getTestSessionDb(idx, &testIdx); - - if(pTestSessions == NULL) - return; - - mvOsPrintf("%-35s %4dx%-4d : ", pTestSessions[testIdx].name, - cesaIteration, cesaReqSize); - if( (status == MV_OK) && - (cesaCryptoError == 0) && - (cesaError == 0) && - (cesaReqIdError == 0) ) - { - mvOsPrintf("Passed, Rate=%3u.%u Mbps (%5u cpp)\n", - cesaRate, cesaRateAfterDot, cesaEndTicks - cesaBeginTicks); - } - else - { - mvOsPrintf("Failed, Status = 0x%x\n", status); - if(cesaCryptoError > 0) - mvOsPrintf("cryptoError : %d\n", cesaCryptoError); - if(cesaReqIdError > 0) - mvOsPrintf("reqIdError : %d\n", cesaReqIdError); - if(cesaError > 0) - mvOsPrintf("cesaError : %d\n", cesaError); - } - if(cesaTestIsrMissCount > 0) - mvOsPrintf("cesaIsrMissed : %d\n", cesaTestIsrMissCount); -} - -void cesaCheckReady(MV_CESA_RESULT* r) -{ - int reqId; - MV_CESA_MBUF *pMbuf; - MV_BOOL isFailed; - - cesaResult = *r; - reqId = (int)cesaResult.pReqPrv; - pMbuf = cesaCmdRing[reqId].pDst; - -/* - mvOsPrintf("cesaCheckReady: reqId=%d, checkOffset=%d, checkSize=%d\n", - reqId, cesaCheckOffset, cesaCheckSize); -*/ - /* Check expected reqId */ - if(reqId != cesaExpReqId) - { - cesaReqIdError++; -/* - mvOsPrintf("CESA reqId Error: cbIter=%d (%d), reqId=%d, expReqId=%d\n", - cesaCbIter, cesaIteration, reqId, cesaExpReqId); -*/ - } - else - { - if( (cesaCheckMode == CESA_FULL_CHECK_MODE) || - (cesaCheckMode == CESA_FAST_CHECK_MODE) ) - { - if(cesaResult.retCode != MV_OK) - { - cesaError++; - - mvOsPrintf("CESA Error: cbIter=%d (%d), reqId=%d, rc=%d\n", - cesaCbIter, cesaIteration, reqId, cesaResult.retCode); - } - else - { - if( (cesaCheckSize > 0) && (cesaOutputHexStr != NULL) ) - { - /* Check expected output */ - - isFailed = cesaCheckMbuf(pMbuf, cesaOutputHexStr, cesaCheckOffset, cesaCheckSize); - if(isFailed) - { - mvOsPrintf("CESA Crypto Error: cbIter=%d (%d), reqId=%d\n", - cesaCbIter, cesaIteration, reqId); - - CESA_TEST_DEBUG_PRINT(("Error: reqId=%d, reqSize=%d, checkOffset=%d, checkSize=%d\n", - reqId, cesaReqSize, cesaCheckOffset, cesaCheckSize)); - - CESA_TEST_DEBUG_PRINT(("Output str: %s\n", cesaOutputHexStr)); - - CESA_TEST_DEBUG_CODE( mvCesaDebugMbuf("error", pMbuf, 0, cesaCheckOffset+cesaCheckSize) ); - - cesaCryptoError++; - } - } - } - } - } - if(cesaCheckMode == CESA_SHOW_CHECK_MODE) - { - extractMbuf(pMbuf, cesaCheckOffset, cesaCheckSize, cesaHexBuffer); - mvOsPrintf("%4d, %s\n", cesaCheckOffset, cesaHexBuffer); - } - - cesaCbIter++; - if(cesaCbIter >= cesaIteration) - { - cesaCbIter = 0; - cesaExpReqId = 0; - cesaIsReady = MV_TRUE; - - cesaEndTicks = CESA_TEST_TICK_GET(); - cesaRate = getRate(&cesaRateAfterDot); - } - else - { - cesaExpReqId = reqId + 1; - if(cesaExpReqId == CESA_DEF_REQ_SIZE) - cesaExpReqId = 0; - } -} - - -#ifdef MV_NETBSD -static int cesaTestReadyIsr(void *arg) -#else -#ifdef __KERNEL__ -static irqreturn_t cesaTestReadyIsr( int irq , void *dev_id) -#endif -#ifdef MV_VXWORKS -void cesaTestReadyIsr(void) -#endif -#endif -{ - MV_U32 cause; - MV_STATUS status; - MV_CESA_RESULT result; - - cesaTestIsrCount++; - /* Clear cause register */ - cause = MV_REG_READ(MV_CESA_ISR_CAUSE_REG); - if( (cause & MV_CESA_CAUSE_ACC_DMA_ALL_MASK) == 0) - { - mvOsPrintf("cesaTestReadyIsr: cause=0x%x\n", cause); -#ifdef MV_NETBSD - return 0; -#else -#ifdef __KERNEL__ - return 1; -#else - return; -#endif -#endif - } - - MV_REG_WRITE(MV_CESA_ISR_CAUSE_REG, 0); - - while(MV_TRUE) - { - /* Get Ready requests */ - status = mvCesaReadyGet(&result); - if(status == MV_OK) - cesaCheckReady(&result); - - break; - } - if( (cesaTestFull == 1) && (status != MV_BUSY) ) - { - cesaTestFull = 0; - CESA_TEST_WAKE_UP(); - } - -#ifdef __KERNEL__ - return 1; -#endif -} - -void -cesaTestCheckReady(const MV_CESA_RESULT *r) -{ - MV_CESA_RESULT result = *r; - - cesaCheckReady(&result); - - if (cesaTestFull == 1) { - cesaTestFull = 0; - CESA_TEST_WAKE_UP(); - } -} - -static INLINE int open_session(MV_CESA_OPEN_SESSION* pOs) -{ - MV_U16 sid; - MV_STATUS status; - - status = mvCesaSessionOpen(pOs, (short*)&sid); - if(status != MV_OK) - { - mvOsPrintf("CesaTest: Can't open new session - status = 0x%x\n", - status); - return -1; - } - - return (int)sid; -} - -void close_session(int sid) -{ - MV_STATUS status; - - status = mvCesaSessionClose(sid); - if(status != MV_OK) - { - mvOsPrintf("CesaTest: Can't close session %d - status = 0x%x\n", - sid, status); - } -} - -MV_STATUS testOpen(int idx) -{ - MV_CESA_OPEN_SESSION os; - int sid, i, testIdx; - MV_CESA_TEST_SESSION* pTestSession; - MV_U16 digestSize = 0; - - pTestSession = getTestSessionDb(idx, &testIdx); - if(pTestSession == NULL) - { - mvOsPrintf("Test %d is not exist\n", idx); - return MV_BAD_PARAM; - } - pTestSession = &pTestSession[testIdx]; - - if(pTestSession->sid != -1) - { - mvOsPrintf("Session for test %d already created: sid=%d\n", - idx, pTestSession->sid); - return MV_OK; - } - - os.cryptoAlgorithm = pTestSession->cryptoAlgorithm; - os.macMode = pTestSession->macAlgorithm; - switch(os.macMode) - { - case MV_CESA_MAC_MD5: - case MV_CESA_MAC_HMAC_MD5: - digestSize = MV_CESA_MD5_DIGEST_SIZE; - break; - - case MV_CESA_MAC_SHA1: - case MV_CESA_MAC_HMAC_SHA1: - digestSize = MV_CESA_SHA1_DIGEST_SIZE; - break; - - case MV_CESA_MAC_NULL: - digestSize = 0; - } - os.cryptoMode = pTestSession->cryptoMode; - os.direction = pTestSession->direction; - os.operation = pTestSession->operation; - - for(i=0; i<pTestSession->cryptoKeySize; i++) - os.cryptoKey[i] = pTestSession->pCryptoKey[i]; - - os.cryptoKeyLength = pTestSession->cryptoKeySize; - - for(i=0; i<pTestSession->macKeySize; i++) - os.macKey[i] = pTestSession->pMacKey[i]; - - os.macKeyLength = pTestSession->macKeySize; - os.digestSize = digestSize; - - sid = open_session(&os); - if(sid == -1) - { - mvOsPrintf("Can't open session for test %d: rc=0x%x\n", - idx, cesaResult.retCode); - return cesaResult.retCode; - } - CESA_TEST_DEBUG_PRINT(("Opened session: sid = %d\n", sid)); - pTestSession->sid = sid; - return MV_OK; -} - -MV_STATUS testClose(int idx) -{ - int testIdx; - MV_CESA_TEST_SESSION* pTestSession; - - pTestSession = getTestSessionDb(idx, &testIdx); - if(pTestSession == NULL) - { - mvOsPrintf("Test %d is not exist\n", idx); - return MV_BAD_PARAM; - } - pTestSession = &pTestSession[testIdx]; - - if(pTestSession->sid == -1) - { - mvOsPrintf("Test session %d is not opened\n", idx); - return MV_NO_SUCH; - } - - close_session(pTestSession->sid); - pTestSession->sid = -1; - - return MV_OK; -} - -MV_STATUS testCmd(int sid, int iter, MV_CESA_COMMAND* pCmd, - MV_CESA_TEST_SESSION* pTestSession, MV_U8* pIV, int ivSize) -{ - int cmdReqId = 0; - int i; - MV_STATUS rc = MV_OK; - char ivZeroHex[] = "0000"; - - if(iter == 0) - iter = CESA_DEF_ITER_NUM; - - if(pCmd == NULL) - { - mvOsPrintf("testCmd failed: pCmd=NULL\n"); - return MV_BAD_PARAM; - } - pCmd->sessionId = sid; - - cesaCryptoError = 0; - cesaReqIdError = 0; - cesaError = 0; - cesaTestIsrMissCount = 0; - cesaIsReady = MV_FALSE; - cesaIteration = iter; - - if(cesaInputHexStr == NULL) - cesaInputHexStr = cesaPlainHexEbc; - - for(i=0; i<CESA_DEF_REQ_SIZE; i++) - { - pCmd->pSrc = (MV_CESA_MBUF*)(cesaCmdRing[i].pSrc); - if(pIV != NULL) - { - /* If IV from SA - set IV in Source buffer to zeros */ - cesaSetMbuf(pCmd->pSrc, ivZeroHex, 0, pCmd->cryptoOffset); - cesaSetMbuf(pCmd->pSrc, cesaInputHexStr, pCmd->cryptoOffset, - (cesaReqSize - pCmd->cryptoOffset)); - } - else - { - cesaSetMbuf(pCmd->pSrc, cesaInputHexStr, 0, cesaReqSize); - } - pCmd->pDst = (MV_CESA_MBUF*)(cesaCmdRing[i].pDst); - cesaSetMbuf(pCmd->pDst, cesaNullPlainHexText, 0, cesaReqSize); - - memcpy(&cesaCmdRing[i], pCmd, sizeof(*pCmd)); - } - - if(cesaCheckMode == CESA_SW_SHOW_CHECK_MODE) - { - MV_U8 pDigest[MV_CESA_MAX_DIGEST_SIZE]; - - if(pTestSession->macAlgorithm == MV_CESA_MAC_MD5) - { - mvMD5(pCmd->pSrc->pFrags[0].bufVirtPtr, pCmd->macLength, pDigest); - mvOsPrintf("SW HASH_MD5: reqSize=%d, macLength=%d\n", - cesaReqSize, pCmd->macLength); - mvDebugMemDump(pDigest, MV_CESA_MD5_DIGEST_SIZE, 1); - return MV_OK; - } - if(pTestSession->macAlgorithm == MV_CESA_MAC_SHA1) - { - mvSHA1(pCmd->pSrc->pFrags[0].bufVirtPtr, pCmd->macLength, pDigest); - mvOsPrintf("SW HASH_SHA1: reqSize=%d, macLength=%d\n", - cesaReqSize, pCmd->macLength); - mvDebugMemDump(pDigest, MV_CESA_SHA1_DIGEST_SIZE, 1); - return MV_OK; - } - } - - cesaBeginTicks = CESA_TEST_TICK_GET(); - CESA_TEST_DEBUG_CODE( memset(cesaTestTrace, 0, sizeof(cesaTestTrace)); - cesaTestTraceIdx = 0; - ); - - if(cesaCheckMode == CESA_SW_NULL_CHECK_MODE) - { - volatile MV_U8 pDigest[MV_CESA_MAX_DIGEST_SIZE]; - - for(i=0; i<iter; i++) - { - if(pTestSession->macAlgorithm == MV_CESA_MAC_MD5) - { - mvMD5(pCmd->pSrc->pFrags[0].bufVirtPtr, pCmd->macLength, (unsigned char*)pDigest); - } - if(pTestSession->macAlgorithm == MV_CESA_MAC_SHA1) - { - mvSHA1(pCmd->pSrc->pFrags[0].bufVirtPtr, pCmd->macLength, (MV_U8 *)pDigest); - } - } - cesaEndTicks = CESA_TEST_TICK_GET(); - cesaRate = getRate(&cesaRateAfterDot); - cesaIsReady = MV_TRUE; - - return MV_OK; - } - - /*cesaTestIsrCount = 0;*/ - /*mvCesaDebugStatsClear();*/ - -#ifndef MV_NETBSD - MV_REG_WRITE(MV_CESA_ISR_CAUSE_REG, 0); -#endif - - for(i=0; i<iter; i++) - { - unsigned long flags; - - pCmd = &cesaCmdRing[cmdReqId]; - pCmd->pReqPrv = (void*)cmdReqId; - - CESA_TEST_LOCK(flags); - - rc = mvCesaAction(pCmd); - if(rc == MV_NO_RESOURCE) - cesaTestFull = 1; - - CESA_TEST_UNLOCK(flags); - - if(rc == MV_NO_RESOURCE) - { - CESA_TEST_LOCK(flags); - CESA_TEST_WAIT( (cesaTestFull == 0), 100); - CESA_TEST_UNLOCK(flags); - if(cesaTestFull == 1) - { - mvOsPrintf("CESA Test timeout: i=%d, iter=%d, cesaTestFull=%d\n", - i, iter, cesaTestFull); - cesaTestFull = 0; - return MV_TIMEOUT; - } - - CESA_TEST_LOCK(flags); - - rc = mvCesaAction(pCmd); - - CESA_TEST_UNLOCK(flags); - } - if( (rc != MV_OK) && (rc != MV_NO_MORE) ) - { - mvOsPrintf("mvCesaAction failed: rc=%d\n", rc); - return rc; - } - - cmdReqId++; - if(cmdReqId >= CESA_DEF_REQ_SIZE) - cmdReqId = 0; - -#ifdef MV_LINUX - /* Reschedule each 16 requests */ - if( (i & 0xF) == 0) - schedule(); -#endif - } - return MV_OK; -} - -void cesaTestStart(int bufNum, int bufSize) -{ - int i, j, idx; - MV_CESA_MBUF *pMbufSrc, *pMbufDst; - MV_BUF_INFO *pFragsSrc, *pFragsDst; - char *pBuf; -#ifndef MV_NETBSD - int numOfSessions, queueDepth; - char *pSram; - MV_STATUS status; - MV_CPU_DEC_WIN addrDecWin; -#endif - - cesaCmdRing = mvOsMalloc(sizeof(MV_CESA_COMMAND) * CESA_DEF_REQ_SIZE); - if(cesaCmdRing == NULL) - { - mvOsPrintf("testStart: Can't allocate %ld bytes of memory\n", - sizeof(MV_CESA_COMMAND) * CESA_DEF_REQ_SIZE); - return; - } - memset(cesaCmdRing, 0, sizeof(MV_CESA_COMMAND) * CESA_DEF_REQ_SIZE); - - if(bufNum == 0) - bufNum = CESA_DEF_BUF_NUM; - - if(bufSize == 0) - bufSize = CESA_DEF_BUF_SIZE; - - cesaBufNum = bufNum; - cesaBufSize = bufSize; - mvOsPrintf("CESA test started: bufNum = %d, bufSize = %d\n", - bufNum, bufSize); - - cesaHexBuffer = mvOsMalloc(2*bufNum*bufSize); - if(cesaHexBuffer == NULL) - { - mvOsPrintf("testStart: Can't malloc %d bytes for cesaHexBuffer.\n", - 2*bufNum*bufSize); - return; - } - memset(cesaHexBuffer, 0, (2*bufNum*bufSize)); - - cesaBinBuffer = mvOsMalloc(bufNum*bufSize); - if(cesaBinBuffer == NULL) - { - mvOsPrintf("testStart: Can't malloc %d bytes for cesaBinBuffer\n", - bufNum*bufSize); - return; - } - memset(cesaBinBuffer, 0, (bufNum*bufSize)); - - cesaExpBinBuffer = mvOsMalloc(bufNum*bufSize); - if(cesaExpBinBuffer == NULL) - { - mvOsPrintf("testStart: Can't malloc %d bytes for cesaExpBinBuffer\n", - bufNum*bufSize); - return; - } - memset(cesaExpBinBuffer, 0, (bufNum*bufSize)); - - CESA_TEST_WAIT_INIT(); - - pMbufSrc = mvOsMalloc(sizeof(MV_CESA_MBUF) * CESA_DEF_REQ_SIZE); - pFragsSrc = mvOsMalloc(sizeof(MV_BUF_INFO) * bufNum * CESA_DEF_REQ_SIZE); - - pMbufDst = mvOsMalloc(sizeof(MV_CESA_MBUF) * CESA_DEF_REQ_SIZE); - pFragsDst = mvOsMalloc(sizeof(MV_BUF_INFO) * bufNum * CESA_DEF_REQ_SIZE); - - if( (pMbufSrc == NULL) || (pFragsSrc == NULL) || - (pMbufDst == NULL) || (pFragsDst == NULL) ) - { - mvOsPrintf("testStart: Can't malloc Src and Dst pMbuf and pFrags structures.\n"); - /* !!!! Dima cesaTestCleanup();*/ - return; - } - - memset(pMbufSrc, 0, sizeof(MV_CESA_MBUF) * CESA_DEF_REQ_SIZE); - memset(pFragsSrc, 0, sizeof(MV_BUF_INFO) * bufNum * CESA_DEF_REQ_SIZE); - - memset(pMbufDst, 0, sizeof(MV_CESA_MBUF) * CESA_DEF_REQ_SIZE); - memset(pFragsDst, 0, sizeof(MV_BUF_INFO) * bufNum * CESA_DEF_REQ_SIZE); - - mvOsPrintf("Cesa Test Start: pMbufSrc=%p, pFragsSrc=%p, pMbufDst=%p, pFragsDst=%p\n", - pMbufSrc, pFragsSrc, pMbufDst, pFragsDst); - - idx = 0; - for(i=0; i<CESA_DEF_REQ_SIZE; i++) - { - pBuf = mvOsIoCachedMalloc(cesaTestOSHandle,bufSize * bufNum * 2, - &cesaReqBufs[i].bufPhysAddr, - &cesaReqBufs[i].memHandle); - if(pBuf == NULL) - { - mvOsPrintf("testStart: Can't malloc %d bytes for pBuf\n", - bufSize * bufNum * 2); - return; - } - - memset(pBuf, 0, bufSize * bufNum * 2); - mvOsCacheFlush(cesaTestOSHandle,pBuf, bufSize * bufNum * 2); - if(pBuf == NULL) - { - mvOsPrintf("cesaTestStart: Can't allocate %d bytes for req_%d buffers\n", - bufSize * bufNum * 2, i); - return; - } - - cesaReqBufs[i].bufVirtPtr = (MV_U8*)pBuf; - cesaReqBufs[i].bufSize = bufSize * bufNum * 2; - - cesaCmdRing[i].pSrc = &pMbufSrc[i]; - cesaCmdRing[i].pSrc->pFrags = &pFragsSrc[idx]; - cesaCmdRing[i].pSrc->numFrags = bufNum; - cesaCmdRing[i].pSrc->mbufSize = 0; - - cesaCmdRing[i].pDst = &pMbufDst[i]; - cesaCmdRing[i].pDst->pFrags = &pFragsDst[idx]; - cesaCmdRing[i].pDst->numFrags = bufNum; - cesaCmdRing[i].pDst->mbufSize = 0; - - for(j=0; j<bufNum; j++) - { - cesaCmdRing[i].pSrc->pFrags[j].bufVirtPtr = (MV_U8*)pBuf; - cesaCmdRing[i].pSrc->pFrags[j].bufSize = bufSize; - pBuf += bufSize; - cesaCmdRing[i].pDst->pFrags[j].bufVirtPtr = (MV_U8*)pBuf; - cesaCmdRing[i].pDst->pFrags[j].bufSize = bufSize; - pBuf += bufSize; - } - idx += bufNum; - } - -#ifndef MV_NETBSD - if (mvCpuIfTargetWinGet(CRYPT_ENG, &addrDecWin) == MV_OK) - pSram = (char*)addrDecWin.addrWin.baseLow; - else - { - mvOsPrintf("mvCesaInit: ERR. mvCpuIfTargetWinGet failed\n"); - return; - } - -#ifdef MV_CESA_NO_SRAM - pSram = mvOsMalloc(4*1024+8); - if(pSram == NULL) - { - mvOsPrintf("CesaTest: can't allocate %d bytes for SRAM simulation\n", - 4*1024+8); - /* !!!! Dima cesaTestCleanup();*/ - return; - } - pSram = (MV_U8*)MV_ALIGN_UP((MV_U32)pSram, 8); -#endif /* MV_CESA_NO_SRAM */ - - numOfSessions = CESA_DEF_SESSION_NUM; - queueDepth = CESA_DEF_REQ_SIZE - MV_CESA_MAX_CHAN; - - status = mvCesaInit(numOfSessions, queueDepth, pSram, NULL); - if(status != MV_OK) - { - mvOsPrintf("mvCesaInit is Failed: status = 0x%x\n", status); - /* !!!! Dima cesaTestCleanup();*/ - return; - } -#endif /* !MV_NETBSD */ - - /* Prepare data for tests */ - for(i=0; i<50; i++) - strcat((char*)cesaDataHexStr3, "dd"); - - strcpy((char*)cesaDataAndMd5digest3, cesaDataHexStr3); - strcpy((char*)cesaDataAndSha1digest3, cesaDataHexStr3); - - /* Digest must be 8 byte aligned */ - for(; i<56; i++) - { - strcat((char*)cesaDataAndMd5digest3, "00"); - strcat((char*)cesaDataAndSha1digest3, "00"); - } - strcat((char*)cesaDataAndMd5digest3, cesaHmacMd5digestHex3); - strcat((char*)cesaDataAndSha1digest3, cesaHmacSha1digestHex3); - -#ifndef MV_NETBSD - MV_REG_WRITE( MV_CESA_ISR_CAUSE_REG, 0); - MV_REG_WRITE( MV_CESA_ISR_MASK_REG, MV_CESA_CAUSE_ACC_DMA_MASK); -#endif - -#ifdef MV_VXWORKS - { - MV_STATUS status; - - status = intConnect((VOIDFUNCPTR *)INT_LVL_CESA, cesaTestReadyIsr, (int)NULL); - if (status != OK) - { - mvOsPrintf("CESA: Can't connect CESA (%d) interrupt, status=0x%x \n", - INT_LVL_CESA, status); - /* !!!! Dima cesaTestCleanup();*/ - return; - } - cesaSemId = semMCreate(SEM_Q_PRIORITY | SEM_INVERSION_SAFE | SEM_DELETE_SAFE); - if(cesaSemId == NULL) - { - mvOsPrintf("cesaTestStart: Can't create semaphore\n"); - return; - } - intEnable(INT_LVL_CESA); - } -#endif /* MV_VXWORKS */ - -#if !defined(MV_NETBSD) && defined(__KERNEL__) - if( request_irq(CESA_IRQ, cesaTestReadyIsr, (SA_INTERRUPT) , "cesa_test", NULL ) ) - { - mvOsPrintf( "cannot assign irq\n" ); - /* !!!! Dima cesaTestCleanup();*/ - return; - } - spin_lock_init( &cesaLock ); -#endif -} - -MV_STATUS testRun(int idx, int caseIdx, int iter, - int reqSize, int checkMode) -{ - int testIdx, count, sid, digestSize; - int blockSize; - MV_CESA_TEST_SESSION* pTestSession; - MV_CESA_COMMAND cmd; - MV_STATUS status; - - memset(&cmd, 0, sizeof(cmd)); - - pTestSession = getTestSessionDb(idx, &testIdx); - if(pTestSession == NULL) - { - mvOsPrintf("Test %d is not exist\n", idx); - return MV_BAD_PARAM; - } - pTestSession = &pTestSession[testIdx]; - - sid = pTestSession->sid; - if(sid == -1) - { - mvOsPrintf("Test %d is not opened\n", idx); - return MV_BAD_STATE; - } - switch(pTestSession->cryptoAlgorithm) - { - case MV_CESA_CRYPTO_DES: - case MV_CESA_CRYPTO_3DES: - blockSize = MV_CESA_DES_BLOCK_SIZE; - break; - - case MV_CESA_CRYPTO_AES: - blockSize = MV_CESA_AES_BLOCK_SIZE; - break; - - case MV_CESA_CRYPTO_NULL: - blockSize = 0; - break; - - default: - mvOsPrintf("cesaTestRun: Bad CryptoAlgorithm=%d\n", - pTestSession->cryptoAlgorithm); - return MV_BAD_PARAM; - } - switch(pTestSession->macAlgorithm) - { - case MV_CESA_MAC_MD5: - case MV_CESA_MAC_HMAC_MD5: - digestSize = MV_CESA_MD5_DIGEST_SIZE; - break; - - case MV_CESA_MAC_SHA1: - case MV_CESA_MAC_HMAC_SHA1: - digestSize = MV_CESA_SHA1_DIGEST_SIZE; - break; - default: - digestSize = 0; - } - - if(iter == 0) - iter = CESA_DEF_ITER_NUM; - - if(pTestSession->direction == MV_CESA_DIR_ENCODE) - { - cesaOutputHexStr = cesaTestCases[caseIdx].cipherHexStr; - cesaInputHexStr = cesaTestCases[caseIdx].plainHexStr; - } - else - { - cesaOutputHexStr = cesaTestCases[caseIdx].plainHexStr; - cesaInputHexStr = cesaTestCases[caseIdx].cipherHexStr; - } - - cmd.sessionId = sid; - if(checkMode == CESA_FAST_CHECK_MODE) - { - cmd.cryptoLength = cesaTestCases[caseIdx].cryptoLength; - cmd.macLength = cesaTestCases[caseIdx].macLength; - } - else - { - cmd.cryptoLength = reqSize; - cmd.macLength = reqSize; - } - cesaRateSize = cmd.cryptoLength; - cesaReqSize = cmd.cryptoLength; - cmd.cryptoOffset = 0; - if(pTestSession->operation != MV_CESA_MAC_ONLY) - { - if( (pTestSession->cryptoMode == MV_CESA_CRYPTO_CBC) || - (pTestSession->cryptoMode == MV_CESA_CRYPTO_CTR) ) - { - cmd.ivOffset = 0; - cmd.cryptoOffset = blockSize; - if(cesaTestCases[caseIdx].pCryptoIV == NULL) - { - cmd.ivFromUser = 1; - } - else - { - cmd.ivFromUser = 0; - mvCesaCryptoIvSet(cesaTestCases[caseIdx].pCryptoIV, blockSize); - } - cesaReqSize = cmd.cryptoOffset + cmd.cryptoLength; - } - } - -/* - mvOsPrintf("ivFromUser=%d, cryptoLength=%d, cesaReqSize=%d, cryptoOffset=%d\n", - cmd.ivFromUser, cmd.cryptoLength, cesaReqSize, cmd.cryptoOffset); -*/ - if(pTestSession->operation != MV_CESA_CRYPTO_ONLY) - { - cmd.macOffset = cmd.cryptoOffset; - - if(cesaTestCases[caseIdx].digestOffset == -1) - { - cmd.digestOffset = cmd.macOffset + cmd.macLength; - cmd.digestOffset = MV_ALIGN_UP(cmd.digestOffset, 8); - } - else - { - cmd.digestOffset = cesaTestCases[caseIdx].digestOffset; - } - if( (cmd.digestOffset + digestSize) > cesaReqSize) - cesaReqSize = cmd.digestOffset + digestSize; - } - - cesaCheckMode = checkMode; - - if(checkMode == CESA_NULL_CHECK_MODE) - { - cesaCheckSize = 0; - cesaCheckOffset = 0; - } - else - { - if(pTestSession->operation == MV_CESA_CRYPTO_ONLY) - { - cesaCheckOffset = 0; - cesaCheckSize = cmd.cryptoLength; - } - else - { - cesaCheckSize = digestSize; - cesaCheckOffset = cmd.digestOffset; - } - } -/* - mvOsPrintf("reqSize=%d, checkSize=%d, checkOffset=%d, checkMode=%d\n", - cesaReqSize, cesaCheckSize, cesaCheckOffset, cesaCheckMode); - - mvOsPrintf("blockSize=%d, ivOffset=%d, ivFromUser=%d, crOffset=%d, crLength=%d\n", - blockSize, cmd.ivOffset, cmd.ivFromUser, - cmd.cryptoOffset, cmd.cryptoLength); - - mvOsPrintf("macOffset=%d, digestOffset=%d, macLength=%d\n", - cmd.macOffset, cmd.digestOffset, cmd.macLength); -*/ - status = testCmd(sid, iter, &cmd, pTestSession, - cesaTestCases[caseIdx].pCryptoIV, blockSize); - - if(status != MV_OK) - return status; - - /* Wait when all callbacks is received */ - count = 0; - while(cesaIsReady == MV_FALSE) - { - mvOsSleep(10); - count++; - if(count > 100) - { - mvOsPrintf("testRun: Timeout occured\n"); - return MV_TIMEOUT; - } - } - - return MV_OK; -} - - -void cesaTestStop(void) -{ - MV_CESA_MBUF *pMbufSrc, *pMbufDst; - MV_BUF_INFO *pFragsSrc, *pFragsDst; - int i; - - /* Release all allocated memories */ - pMbufSrc = (MV_CESA_MBUF*)(cesaCmdRing[0].pSrc); - pFragsSrc = cesaCmdRing[0].pSrc->pFrags; - - pMbufDst = (MV_CESA_MBUF*)(cesaCmdRing[0].pDst); - pFragsDst = cesaCmdRing[0].pDst->pFrags; - - mvOsFree(pMbufSrc); - mvOsFree(pMbufDst); - mvOsFree(pFragsSrc); - mvOsFree(pFragsDst); - - for(i=0; i<CESA_DEF_REQ_SIZE; i++) - { - mvOsIoCachedFree(cesaTestOSHandle,cesaReqBufs[i].bufSize, - cesaReqBufs[i].bufPhysAddr,cesaReqBufs[i].bufVirtPtr, - cesaReqBufs[i].memHandle); - } - cesaDataHexStr3[0] = '\0'; -} - -void desTest(int iter, int reqSize, int checkMode) -{ - int mode, i; - MV_STATUS status; - - mode = checkMode; - if(checkMode == CESA_FULL_CHECK_MODE) - mode = CESA_FAST_CHECK_MODE; - i = iter; - if(mode != CESA_NULL_CHECK_MODE) - i = 1; - - testOpen(0); - testOpen(1); - testOpen(2); - testOpen(3); - -/* DES / ECB mode / Encrypt only */ - status = testRun(0, 1, iter, reqSize, checkMode); - printTestResults(0, status, checkMode); - -/* DES / ECB mode / Decrypt only */ - status = testRun(1, 1, iter, reqSize, checkMode); - printTestResults(1, status, checkMode); - -/* DES / CBC mode / Encrypt only */ - status = testRun(2, 2, i, reqSize, mode); - printTestResults(2, status, mode); - -/* DES / CBC mode / Decrypt only */ - status = testRun(3, 2, iter, reqSize, mode); - printTestResults(3, status, mode); - - testClose(0); - testClose(1); - testClose(2); - testClose(3); -} - -void tripleDesTest(int iter, int reqSize, int checkMode) -{ - int mode, i; - MV_STATUS status; - - mode = checkMode; - if(checkMode == CESA_FULL_CHECK_MODE) - mode = CESA_FAST_CHECK_MODE; - i = iter; - if(mode != CESA_NULL_CHECK_MODE) - i = 1; - - testOpen(100); - testOpen(101); - testOpen(102); - testOpen(103); - -/* 3DES / ECB mode / Encrypt only */ - status = testRun(100, 1, iter, reqSize, checkMode); - printTestResults(100, status, checkMode); - -/* 3DES / ECB mode / Decrypt only */ - status = testRun(101, 1, iter, reqSize, checkMode); - printTestResults(101, status, checkMode); - -/* 3DES / CBC mode / Encrypt only */ - status = testRun(102, 2, i, reqSize, mode); - printTestResults(102, status, mode); - -/* 3DES / CBC mode / Decrypt only */ - status = testRun(103, 2, iter, reqSize, mode); - printTestResults(103, status, mode); - - testClose(100); - testClose(101); - testClose(102); - testClose(103); -} - -void aesTest(int iter, int reqSize, int checkMode) -{ - MV_STATUS status; - int mode, i; - - mode = checkMode; - if(checkMode == CESA_FULL_CHECK_MODE) - mode = CESA_FAST_CHECK_MODE; - - i = iter; - if(mode != CESA_NULL_CHECK_MODE) - i = 1; - - testOpen(200); - testOpen(201); - testOpen(202); - testOpen(203); - testOpen(204); - testOpen(205); - testOpen(206); - testOpen(207); - testOpen(208); - -/* AES-128 Encode ECB mode */ - status = testRun(200, 3, iter, reqSize, checkMode); - printTestResults(200, status, checkMode); - -/* AES-128 Decode ECB mode */ - status = testRun(201, 3, iter, reqSize, checkMode); - printTestResults(201, status, checkMode); - -/* AES-128 Encode CBC mode (IV from SA) */ - status = testRun(202, 10, i, reqSize, mode); - printTestResults(202, status, mode); - -/* AES-128 Encode CBC mode (IV from User) */ - status = testRun(202, 24, i, reqSize, mode); - printTestResults(202, status, mode); - -/* AES-128 Decode CBC mode */ - status = testRun(203, 24, iter, reqSize, mode); - printTestResults(203, status, checkMode); - -/* AES-192 Encode ECB mode */ - status = testRun(204, 4, iter, reqSize, checkMode); - printTestResults(204, status, checkMode); - -/* AES-192 Decode ECB mode */ - status = testRun(205, 4, iter, reqSize, checkMode); - printTestResults(205, status, checkMode); - -/* AES-256 Encode ECB mode */ - status = testRun(206, 5, iter, reqSize, checkMode); - printTestResults(206, status, checkMode); - -/* AES-256 Decode ECB mode */ - status = testRun(207, 5, iter, reqSize, checkMode); - printTestResults(207, status, checkMode); - -#if defined(MV_LINUX) -/* AES-128 Encode CTR mode */ - status = testRun(208, 23, iter, reqSize, mode); - printTestResults(208, status, checkMode); -#endif - testClose(200); - testClose(201); - testClose(202); - testClose(203); - testClose(204); - testClose(205); - testClose(206); - testClose(207); - testClose(208); -} - - -void mdTest(int iter, int reqSize, int checkMode) -{ - int mode; - MV_STATUS status; - - if(iter == 0) - iter = CESA_DEF_ITER_NUM; - - mode = checkMode; - if(checkMode == CESA_FULL_CHECK_MODE) - mode = CESA_FAST_CHECK_MODE; - - testOpen(300); - testOpen(301); - testOpen(302); - testOpen(303); - testOpen(305); - -/* HMAC-MD5 Generate signature test */ - status = testRun(300, 6, iter, reqSize, mode); - printTestResults(300, status, checkMode); - -/* HMAC-MD5 Verify Signature test */ - status = testRun(301, 7, iter, reqSize, mode); - printTestResults(301, status, checkMode); - -/* HMAC-MD5 Generate signature test */ - status = testRun(302, 8, iter, reqSize, mode); - printTestResults(302, status, checkMode); - -/* HMAC-MD5 Verify Signature test */ - status = testRun(303, 9, iter, reqSize, mode); - printTestResults(303, status, checkMode); - -/* HASH-MD5 Generate signature test */ - status = testRun(305, 15, iter, reqSize, mode); - printTestResults(305, status, checkMode); - - testClose(300); - testClose(301); - testClose(302); - testClose(303); - testClose(305); -} - -void shaTest(int iter, int reqSize, int checkMode) -{ - int mode; - MV_STATUS status; - - if(iter == 0) - iter = CESA_DEF_ITER_NUM; - - mode = checkMode; - if(checkMode == CESA_FULL_CHECK_MODE) - mode = CESA_FAST_CHECK_MODE; - - testOpen(400); - testOpen(401); - testOpen(402); - testOpen(403); - testOpen(405); - -/* HMAC-SHA1 Generate signature test */ - status = testRun(400, 11, iter, reqSize, mode); - printTestResults(400, status, checkMode); - -/* HMAC-SHA1 Verify Signature test */ - status = testRun(401, 12, iter, reqSize, mode); - printTestResults(401, status, checkMode); - -/* HMAC-SHA1 Generate signature test */ - status = testRun(402, 13, iter, reqSize, mode); - printTestResults(402, status, checkMode); - -/* HMAC-SHA1 Verify Signature test */ - status = testRun(403, 14, iter, reqSize, mode); - printTestResults(403, status, checkMode); - -/* HMAC-SHA1 Generate signature test */ - status = testRun(405, 16, iter, reqSize, mode); - printTestResults(405, status, checkMode); - - testClose(400); - testClose(401); - testClose(402); - testClose(403); - testClose(405); -} - -void combiTest(int iter, int reqSize, int checkMode) -{ - MV_STATUS status; - int mode, i; - - mode = checkMode; - if(checkMode == CESA_FULL_CHECK_MODE) - mode = CESA_FAST_CHECK_MODE; - - if(iter == 0) - iter = CESA_DEF_ITER_NUM; - - i = iter; - if(mode != CESA_NULL_CHECK_MODE) - i = 1; - - testOpen(500); - testOpen(501); - testOpen(502); - testOpen(503); - testOpen(504); - testOpen(505); - testOpen(506); - testOpen(507); - -/* DES ECB + MD5 encode test */ - status = testRun(500, 17, iter, reqSize, mode); - printTestResults(500, status, mode); - -/* DES ECB + SHA1 encode test */ - status = testRun(501, 18, iter, reqSize, mode); - printTestResults(501, status, mode); - -/* 3DES ECB + MD5 encode test */ - status = testRun(502, 17, iter, reqSize, mode); - printTestResults(502, status, mode); - -/* 3DES ECB + SHA1 encode test */ - status = testRun(503, 18, iter, reqSize, mode); - printTestResults(503, status, mode); - -/* 3DES CBC + MD5 encode test */ - status = testRun(504, 19, i, reqSize, mode); - printTestResults(504, status, mode); - -/* 3DES CBC + SHA1 encode test */ - status = testRun(505, 20, i, reqSize, mode); - printTestResults(505, status, mode); - -/* AES-128 CBC + MD5 encode test */ - status = testRun(506, 21, i, reqSize, mode); - printTestResults(506, status, mode); - -/* AES-128 CBC + SHA1 encode test */ - status = testRun(507, 22, i, reqSize, mode); - printTestResults(507, status, mode); - - testClose(500); - testClose(501); - testClose(502); - testClose(503); - testClose(504); - testClose(505); - testClose(506); - testClose(507); -} - -void cesaOneTest(int testIdx, int caseIdx, - int iter, int reqSize, int checkMode) -{ - MV_STATUS status; - - if(iter == 0) - iter = CESA_DEF_ITER_NUM; - - mvOsPrintf("test=%d, case=%d, size=%d, iter=%d\n", - testIdx, caseIdx, reqSize, iter); - - status = testOpen(testIdx); - - status = testRun(testIdx, caseIdx, iter, reqSize, checkMode); - printTestResults(testIdx, status, checkMode); - status = testClose(testIdx); - -} - -void cesaTest(int iter, int reqSize, int checkMode) -{ - if(iter == 0) - iter = CESA_DEF_ITER_NUM; - - mvOsPrintf("%d iteration\n", iter); - mvOsPrintf("%d size\n\n", reqSize); - -/* DES tests */ - desTest(iter, reqSize, checkMode); - -/* 3DES tests */ - tripleDesTest(iter, reqSize, checkMode); - -/* AES tests */ - aesTest(iter, reqSize, checkMode); - -/* MD5 tests */ - mdTest(iter, reqSize, checkMode); - -/* SHA-1 tests */ - shaTest(iter, reqSize, checkMode); -} - -void multiSizeTest(int idx, int iter, int checkMode, char* inputData) -{ - MV_STATUS status; - int i; - MV_CESA_SIZE_TEST* pMultiTest; - - if( testOpen(idx) != MV_OK) - return; - - if(iter == 0) - iter = CESA_DEF_ITER_NUM; - - if(checkMode == CESA_SHOW_CHECK_MODE) - { - iter = 1; - } - else - checkMode = CESA_FULL_CHECK_MODE; - - cesaTestCases[0].plainHexStr = inputData; - cesaTestCases[0].pCryptoIV = NULL; - - switch(idx) - { - case 302: - pMultiTest = mdMultiSizeTest302; - if(inputData == NULL) - cesaTestCases[0].plainHexStr = cesaDataHexStr3; - break; - - case 304: - pMultiTest = mdMultiSizeTest304; - if(inputData == NULL) - cesaTestCases[0].plainHexStr = hashHexStr80; - break; - - case 305: - pMultiTest = mdMultiSizeTest305; - if(inputData == NULL) - cesaTestCases[0].plainHexStr = hashHexStr80; - break; - - case 402: - pMultiTest = shaMultiSizeTest402; - if(inputData == NULL) - cesaTestCases[0].plainHexStr = hashHexStr80; - break; - - case 404: - pMultiTest = shaMultiSizeTest404; - if(inputData == NULL) - cesaTestCases[0].plainHexStr = hashHexStr80; - break; - - case 405: - pMultiTest = shaMultiSizeTest405; - if(inputData == NULL) - cesaTestCases[0].plainHexStr = hashHexStr80; - break; - - case 502: - pMultiTest = tripleDesMdMultiSizeTest502; - if(inputData == NULL) - cesaTestCases[0].plainHexStr = hashHexStr80; - break; - - case 503: - pMultiTest = tripleDesShaMultiSizeTest503; - if(inputData == NULL) - cesaTestCases[0].plainHexStr = hashHexStr80; - break; - - case 504: - iter = 1; - pMultiTest = cbc3desMdMultiSizeTest504; - cesaTestCases[0].pCryptoIV = iv1; - if(inputData == NULL) - cesaTestCases[0].plainHexStr = hashHexStr80; - break; - - case 505: - iter = 1; - pMultiTest = cbc3desShaMultiSizeTest505; - cesaTestCases[0].pCryptoIV = iv1; - if(inputData == NULL) - cesaTestCases[0].plainHexStr = hashHexStr80; - break; - - case 506: - iter = 1; - pMultiTest = cbcAes128md5multiSizeTest506; - cesaTestCases[0].pCryptoIV = iv5; - if(inputData == NULL) - cesaTestCases[0].plainHexStr = hashHexStr80; - break; - - case 507: - iter = 1; - pMultiTest = cbcAes128sha1multiSizeTest507; - cesaTestCases[0].pCryptoIV = iv5; - if(inputData == NULL) - cesaTestCases[0].plainHexStr = hashHexStr80; - break; - - default: - iter = 1; - checkMode = CESA_SHOW_CHECK_MODE; - pMultiTest = mdMultiSizeTest302; - if(inputData == NULL) - cesaTestCases[0].plainHexStr = hashHexStr80; - } - i = 0; - while(pMultiTest[i].outputHexStr != NULL) - { - cesaTestCases[0].cipherHexStr = (char *)pMultiTest[i].outputHexStr; - status = testRun(idx, 0, iter, pMultiTest[i].size, - checkMode); - if(checkMode != CESA_SHOW_CHECK_MODE) - { - cesaReqSize = pMultiTest[i].size; - printTestResults(idx, status, checkMode); - } - if(status != MV_OK) - break; - i++; - } - testClose(idx); -/* - mvCesaDebugStatus(); - cesaTestPrintStatus(); -*/ -} - -void open_session_test(int idx, int caseIdx, int iter) -{ - int reqIdError, cryptoError, openErrors, i; - int openErrDisp[100]; - MV_STATUS status; - - memset(openErrDisp, 0, sizeof(openErrDisp)); - openErrors = 0; - reqIdError = 0; - cryptoError = 0; - for(i=0; i<iter; i++) - { - status = testOpen(idx); - if(status != MV_OK) - { - openErrors++; - openErrDisp[status]++; - } - else - { - testRun(idx, caseIdx, 1, 0, CESA_FAST_CHECK_MODE); - if(cesaCryptoError > 0) - cryptoError++; - if(cesaReqIdError > 0) - reqIdError++; - - testClose(idx); - } - } - if(cryptoError > 0) - mvOsPrintf("cryptoError : %d\n", cryptoError); - if(reqIdError > 0) - mvOsPrintf("reqIdError : %d\n", reqIdError); - - if(openErrors > 0) - { - mvOsPrintf("Open Errors = %d\n", openErrors); - for(i=0; i<100; i++) - { - if(openErrDisp[i] != 0) - mvOsPrintf("Error %d - occurs %d times\n", i, openErrDisp[i]); - } - } -} - - -void loopback_test(int idx, int iter, int size, char* pPlainData) -{ -} - - -#if defined(MV_VXWORKS) -int testMode = 0; -unsigned __TASKCONV cesaTask(void* args) -{ - int reqSize = cesaReqSize; - - if(testMode == 0) - { - cesaOneTest(cesaTestIdx, cesaCaseIdx, cesaIteration, - reqSize, cesaCheckMode); - } - else - { - if(testMode == 1) - { - cesaTest(cesaIteration, reqSize, cesaCheckMode); - combiTest(cesaIteration, reqSize, cesaCheckMode); - } - else - { - multiSizeTest(cesaIdx, cesaIteration, cesaCheckMode, NULL); - } - } - return 0; -} - -void oneTest(int testIdx, int caseIdx, - int iter, int reqSize, int checkMode) -{ - long rc; - - cesaIteration = iter; - cesaReqSize = cesaRateSize = reqSize; - cesaCheckMode = checkMode; - testMode = 0; - cesaTestIdx = testIdx; - cesaCaseIdx = caseIdx; - rc = mvOsTaskCreate("CESA_T", 100, 4*1024, cesaTask, NULL, &cesaTaskId); - if (rc != MV_OK) - { - mvOsPrintf("hMW: Can't create CESA multiCmd test task, rc = %ld\n", rc); - } -} - -void multiTest(int iter, int reqSize, int checkMode) -{ - long rc; - - cesaIteration = iter; - cesaCheckMode = checkMode; - cesaReqSize = reqSize; - testMode = 1; - rc = mvOsTaskCreate("CESA_T", 100, 4*1024, cesaTask, NULL, &cesaTaskId); - if (rc != MV_OK) - { - mvOsPrintf("hMW: Can't create CESA multiCmd test task, rc = %ld\n", rc); - } -} - -void sizeTest(int testIdx, int iter, int checkMode) -{ - long rc; - - cesaIteration = iter; - cesaCheckMode = checkMode; - testMode = 2; - cesaIdx = testIdx; - rc = mvOsTaskCreate("CESA_T", 100, 4*1024, cesaTask, NULL, &cesaTaskId); - if (rc != MV_OK) - { - mvOsPrintf("hMW: Can't create CESA test task, rc = %ld\n", rc); - } -} - -#endif /* MV_VXWORKS */ - -extern void mvCesaDebugSA(short sid, int mode); -void cesaTestPrintSession(int idx) -{ - int testIdx; - MV_CESA_TEST_SESSION* pTestSession; - - pTestSession = getTestSessionDb(idx, &testIdx); - if(pTestSession == NULL) - { - mvOsPrintf("Test %d is not exist\n", idx); - return; - } - pTestSession = &pTestSession[testIdx]; - - if(pTestSession->sid == -1) - { - mvOsPrintf("Test session %d is not opened\n", idx); - return; - } - - mvCesaDebugSA(pTestSession->sid, 1); -} - -void cesaTestPrintStatus(void) -{ - mvOsPrintf("\n\t Cesa Test Status\n\n"); - - mvOsPrintf("isrCount=%d\n", - cesaTestIsrCount); - -#ifdef CESA_TEST_DEBUG - { - int i, j; - j = cesaTestTraceIdx; - mvOsPrintf("No Type Cause rCause iCause Res Time pReady pProc pEmpty\n"); - for(i=0; i<MV_CESA_TEST_TRACE_SIZE; i++) - { - mvOsPrintf("%02d. %d 0x%04x 0x%04x 0x%04x 0x%02x 0x%02x %02d 0x%06x %p %p %p\n", - j, cesaTestTrace[j].type, cesaTestTrace[j].cause, cesaTestTrace[j].realCause, - cesaTestTrace[j].dmaCause, cesaTestTrace[j].resources, cesaTestTrace[j].timeStamp, - cesaTestTrace[j].pReqReady, cesaTestTrace[j].pReqProcess, cesaTestTrace[j].pReqEmpty); - j++; - if(j == MV_CESA_TEST_TRACE_SIZE) - j = 0; - } - } -#endif /* CESA_TEST_DEBUG */ -} diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvLru.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvLru.c deleted file mode 100644 index 9ab29a8..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvLru.c +++ /dev/null @@ -1,158 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#include "mvOs.h" -#include "mvLru.h" -/* LRU Cache support */ - - -/* Init LRU cache database */ -MV_LRU_CACHE* mvLruCacheInit(int numOfEntries) -{ - int i; - MV_LRU_CACHE* pLruCache; - - pLruCache = mvOsMalloc(sizeof(MV_LRU_CACHE)); - if(pLruCache == NULL) - { - return NULL; - } - memset(pLruCache, 0, sizeof(MV_LRU_CACHE)); - - pLruCache->table = mvOsMalloc(numOfEntries*sizeof(MV_LRU_ENTRY)); - if(pLruCache->table == NULL) - { - mvOsFree(pLruCache); - return NULL; - } - memset(pLruCache->table, 0, numOfEntries*sizeof(MV_LRU_ENTRY)); - pLruCache->tableSize = numOfEntries; - - for(i=0; i<numOfEntries; i++) - { - pLruCache->table[i].next = i+1; - pLruCache->table[i].prev = i-1; - } - pLruCache->least = 0; - pLruCache->most = numOfEntries-1; - - return pLruCache; -} - -void mvLruCacheFinish(MV_LRU_CACHE* pLruCache) -{ - mvOsFree(pLruCache->table); - mvOsFree(pLruCache); -} - -/* Update LRU cache database after using cache Index */ -void mvLruCacheIdxUpdate(MV_LRU_CACHE* pLruHndl, int cacheIdx) -{ - int prev, next; - - if(cacheIdx == pLruHndl->most) - return; - - next = pLruHndl->table[cacheIdx].next; - if(cacheIdx == pLruHndl->least) - { - pLruHndl->least = next; - } - else - { - prev = pLruHndl->table[cacheIdx].prev; - - pLruHndl->table[next].prev = prev; - pLruHndl->table[prev].next = next; - } - - pLruHndl->table[pLruHndl->most].next = cacheIdx; - pLruHndl->table[cacheIdx].prev = pLruHndl->most; - pLruHndl->most = cacheIdx; -} - -/* Delete LRU cache entry */ -void mvLruCacheIdxDelete(MV_LRU_CACHE* pLruHndl, int cacheIdx) -{ - int prev, next; - - if(cacheIdx == pLruHndl->least) - return; - - prev = pLruHndl->table[cacheIdx].prev; - if(cacheIdx == pLruHndl->most) - { - pLruHndl->most = prev; - } - else - { - next = pLruHndl->table[cacheIdx].next; - - pLruHndl->table[next].prev = prev; - pLruHndl->table[prev].next = next; - } - pLruHndl->table[pLruHndl->least].prev = cacheIdx; - pLruHndl->table[cacheIdx].next = pLruHndl->least; - pLruHndl->least = cacheIdx; -} diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvLru.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvLru.h deleted file mode 100644 index 896e7f8..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvLru.h +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ -/******************************************************************************* -* mvLru.h - Header File for Least Recently Used Cache algorithm -* -* DESCRIPTION: -* This header file contains macros typedefs and function declaration for -* the Least Recently Used Cache algorithm. -* -*******************************************************************************/ - -#ifndef __mvLru_h__ -#define __mvLru_h__ - - -typedef struct -{ - int next; - int prev; -} MV_LRU_ENTRY; - -typedef struct -{ - int least; - int most; - MV_LRU_ENTRY* table; - int tableSize; - -}MV_LRU_CACHE; - - -/* Find Cache index for replacement LRU */ -static INLINE int mvLruCacheIdxFind(MV_LRU_CACHE* pLruHndl) -{ - return pLruHndl->least; -} - -/* Init LRU cache module */ -MV_LRU_CACHE* mvLruCacheInit(int numOfEntries); - -/* Finish LRU cache module */ -void mvLruCacheFinish(MV_LRU_CACHE* pLruHndl); - -/* Update LRU cache database after using cache Index */ -void mvLruCacheIdxUpdate(MV_LRU_CACHE* pLruHndl, int cacheIdx); - -/* Delete LRU cache entry */ -void mvLruCacheIdxDelete(MV_LRU_CACHE* pLruHndl, int cacheIdx); - - -#endif /* __mvLru_h__ */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvMD5.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvMD5.c deleted file mode 100644 index 189f629..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvMD5.c +++ /dev/null @@ -1,349 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#include "mvOs.h" -#include "mvMD5.h" - -static void mvMD5Transform(MV_U32 buf[4], MV_U32 const in[MV_MD5_MAC_LEN]); - -#ifdef MV_CPU_LE -#define mvByteReverse(buf, len) /* Nothing */ -#else -static void mvByteReverse(unsigned char *buf, unsigned longs); - -/* - * Note: this code is harmless on little-endian machines. - */ -static void mvByteReverse(unsigned char *buf, unsigned longs) -{ - MV_U32 t; - - do - { - t = (MV_U32) ((unsigned) buf[3] << 8 | buf[2]) << 16 | - ((unsigned) buf[1] << 8 | buf[0]); - *(MV_U32 *) buf = t; - buf += 4; - } while (--longs); -} -#endif - -/* - * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious - * initialization constants. - */ -void mvMD5Init(MV_MD5_CONTEXT *ctx) -{ - ctx->buf[0] = 0x67452301; - ctx->buf[1] = 0xefcdab89; - ctx->buf[2] = 0x98badcfe; - ctx->buf[3] = 0x10325476; - - ctx->bits[0] = 0; - ctx->bits[1] = 0; -} - -/* - * Update context to reflect the concatenation of another buffer full - * of bytes. - */ -void mvMD5Update(MV_MD5_CONTEXT *ctx, unsigned char const *buf, unsigned len) -{ - MV_U32 t; - - /* Update bitcount */ - - t = ctx->bits[0]; - if ((ctx->bits[0] = t + ((MV_U32) len << 3)) < t) - ctx->bits[1]++; /* Carry from low to high */ - ctx->bits[1] += len >> 29; - - t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ - - /* Handle any leading odd-sized chunks */ - - if (t) - { - unsigned char *p = (unsigned char *) ctx->in + t; - - t = 64 - t; - if (len < t) - { - memcpy(p, buf, len); - return; - } - memcpy(p, buf, t); - mvByteReverse(ctx->in, MV_MD5_MAC_LEN); - mvMD5Transform(ctx->buf, (MV_U32 *) ctx->in); - buf += t; - len -= t; - } - /* Process data in 64-byte chunks */ - - while (len >= 64) - { - memcpy(ctx->in, buf, 64); - mvByteReverse(ctx->in, MV_MD5_MAC_LEN); - mvMD5Transform(ctx->buf, (MV_U32 *) ctx->in); - buf += 64; - len -= 64; - } - - /* Handle any remaining bytes of data. */ - - memcpy(ctx->in, buf, len); -} - -/* - * Final wrapup - pad to 64-byte boundary with the bit pattern - * 1 0* (64-bit count of bits processed, MSB-first) - */ -void mvMD5Final(unsigned char digest[MV_MD5_MAC_LEN], MV_MD5_CONTEXT *ctx) -{ - unsigned count; - unsigned char *p; - - /* Compute number of bytes mod 64 */ - count = (ctx->bits[0] >> 3) & 0x3F; - - /* Set the first char of padding to 0x80. This is safe since there is - always at least one byte free */ - p = ctx->in + count; - *p++ = 0x80; - - /* Bytes of padding needed to make 64 bytes */ - count = 64 - 1 - count; - - /* Pad out to 56 mod 64 */ - if (count < 8) - { - /* Two lots of padding: Pad the first block to 64 bytes */ - memset(p, 0, count); - mvByteReverse(ctx->in, MV_MD5_MAC_LEN); - mvMD5Transform(ctx->buf, (MV_U32 *) ctx->in); - - /* Now fill the next block with 56 bytes */ - memset(ctx->in, 0, 56); - } - else - { - /* Pad block to 56 bytes */ - memset(p, 0, count - 8); - } - mvByteReverse(ctx->in, 14); - - /* Append length in bits and transform */ - ((MV_U32 *) ctx->in)[14] = ctx->bits[0]; - ((MV_U32 *) ctx->in)[15] = ctx->bits[1]; - - mvMD5Transform(ctx->buf, (MV_U32 *) ctx->in); - mvByteReverse((unsigned char *) ctx->buf, 4); - memcpy(digest, ctx->buf, MV_MD5_MAC_LEN); - memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ -} - -/* The four core functions - F1 is optimized somewhat */ - -/* #define F1(x, y, z) (x & y | ~x & z) */ -#define F1(x, y, z) (z ^ (x & (y ^ z))) -#define F2(x, y, z) F1(z, x, y) -#define F3(x, y, z) (x ^ y ^ z) -#define F4(x, y, z) (y ^ (x | ~z)) - -/* This is the central step in the MD5 algorithm. */ -#define MD5STEP(f, w, x, y, z, data, s) \ - ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x ) - -/* - * The core of the MD5 algorithm, this alters an existing MD5 hash to - * reflect the addition of 16 longwords of new data. MD5Update blocks - * the data and converts bytes into longwords for this routine. - */ -static void mvMD5Transform(MV_U32 buf[4], MV_U32 const in[MV_MD5_MAC_LEN]) -{ - register MV_U32 a, b, c, d; - - a = buf[0]; - b = buf[1]; - c = buf[2]; - d = buf[3]; - - MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); - MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); - MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); - MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); - MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); - MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); - MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); - MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); - MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); - MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); - MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); - MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); - MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); - MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); - MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); - MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); - - MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); - MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); - MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); - MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); - MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); - MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); - MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); - MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); - MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); - MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); - MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); - MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); - MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); - MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); - MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); - MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); - - MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); - MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); - MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); - MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); - MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); - MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); - MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); - MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); - MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); - MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); - MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); - MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); - MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); - MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); - MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); - MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); - - MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); - MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); - MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); - MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); - MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); - MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); - MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); - MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); - MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); - MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); - MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); - MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); - MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); - MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); - MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); - MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); - - buf[0] += a; - buf[1] += b; - buf[2] += c; - buf[3] += d; -} - -void mvMD5(unsigned char const *buf, unsigned len, unsigned char* digest) -{ - MV_MD5_CONTEXT ctx; - - mvMD5Init(&ctx); - mvMD5Update(&ctx, buf, len); - mvMD5Final(digest, &ctx); -} - - -void mvHmacMd5(unsigned char const* text, int text_len, - unsigned char const* key, int key_len, - unsigned char* digest) -{ - int i; - MV_MD5_CONTEXT ctx; - unsigned char k_ipad[64+1]; /* inner padding - key XORd with ipad */ - unsigned char k_opad[64+1]; /* outer padding - key XORd with opad */ - - /* start out by storing key in pads */ - memset(k_ipad, 0, 64); - memcpy(k_ipad, key, key_len); - memset(k_opad, 0, 64); - memcpy(k_opad, key, key_len); - - /* XOR key with ipad and opad values */ - for (i=0; i<64; i++) - { - k_ipad[i] ^= 0x36; - k_opad[i] ^= 0x5c; - } - - /* perform inner MD5 */ - mvMD5Init(&ctx); /* init ctx for 1st pass */ - mvMD5Update(&ctx, k_ipad, 64); /* start with inner pad */ - mvMD5Update(&ctx, text, text_len); /* then text of datagram */ - mvMD5Final(digest, &ctx); /* finish up 1st pass */ - - /* perform outer MD5 */ - mvMD5Init(&ctx); /* init ctx for 2nd pass */ - mvMD5Update(&ctx, k_opad, 64); /* start with outer pad */ - mvMD5Update(&ctx, digest, 16); /* then results of 1st hash */ - mvMD5Final(digest, &ctx); /* finish up 2nd pass */ -} diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvMD5.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvMD5.h deleted file mode 100644 index d05c6b6..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvMD5.h +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __mvMD5_h__ -#define __mvMD5_h__ - -#include "mvMD5.h" - -#define MV_MD5_MAC_LEN 16 - - -typedef struct -{ - MV_U32 buf[4]; - MV_U32 bits[2]; - MV_U8 in[64]; - -} MV_MD5_CONTEXT; - -void mvMD5Init(MV_MD5_CONTEXT *context); -void mvMD5Update(MV_MD5_CONTEXT *context, unsigned char const *buf, - unsigned len); -void mvMD5Final(unsigned char digest[16], MV_MD5_CONTEXT *context); - -void mvMD5(unsigned char const *buf, unsigned len, unsigned char* digest); - -void mvHmacMd5(unsigned char const* text, int text_len, - unsigned char const* key, int key_len, - unsigned char* digest); - - -#endif /* __mvMD5_h__ */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvSHA1.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvSHA1.c deleted file mode 100644 index 0e0786b..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvSHA1.c +++ /dev/null @@ -1,239 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#include "mvOs.h" -#include "mvSHA1.h" - -#define SHA1HANDSOFF - -typedef union -{ - MV_U8 c[64]; - MV_U32 l[16]; - -} CHAR64LONG16; - -static void mvSHA1Transform(MV_U32 state[5], const MV_U8 *buffer); - -#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) - - -#ifdef MV_CPU_LE -#define blk0(i) (block->l[i] = (rol(block->l[i], 24) & 0xFF00FF00) | \ - (rol(block->l[i], 8) & 0x00FF00FF)) -#else -#define blk0(i) block->l[i] -#endif -#define blk(i) (block->l[i & 15] = rol(block->l[(i + 13) & 15] ^ \ - block->l[(i + 8) & 15] ^ block->l[(i + 2) & 15] ^ block->l[i & 15], 1)) - -/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */ -#define R0(v,w,x,y,z,i) \ - z += ((w & (x ^ y)) ^ y) + blk0(i) + 0x5A827999 + rol(v, 5); \ - w = rol(w, 30); -#define R1(v,w,x,y,z,i) \ - z += ((w & (x ^ y)) ^ y) + blk(i) + 0x5A827999 + rol(v, 5); \ - w = rol(w, 30); -#define R2(v,w,x,y,z,i) \ - z += (w ^ x ^ y) + blk(i) + 0x6ED9EBA1 + rol(v, 5); w = rol(w, 30); -#define R3(v,w,x,y,z,i) \ - z += (((w | x) & y) | (w & x)) + blk(i) + 0x8F1BBCDC + rol(v, 5); \ - w = rol(w, 30); -#define R4(v,w,x,y,z,i) \ - z += (w ^ x ^ y) + blk(i) + 0xCA62C1D6 + rol(v, 5); \ - w=rol(w, 30); - -/* Hash a single 512-bit block. This is the core of the algorithm. */ -static void mvSHA1Transform(MV_U32 state[5], const MV_U8 *buffer) -{ - MV_U32 a, b, c, d, e; - CHAR64LONG16* block; - -#ifdef SHA1HANDSOFF - static MV_U32 workspace[16]; - - block = (CHAR64LONG16 *) workspace; - memcpy(block, buffer, 64); -#else - block = (CHAR64LONG16 *) buffer; -#endif - /* Copy context->state[] to working vars */ - a = state[0]; - b = state[1]; - c = state[2]; - d = state[3]; - e = state[4]; - /* 4 rounds of 20 operations each. Loop unrolled. */ - R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3); - R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7); - R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11); - R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15); - R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19); - R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23); - R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27); - R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31); - R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35); - R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39); - R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43); - R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47); - R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51); - R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55); - R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59); - R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63); - R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67); - R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71); - R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75); - R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79); - /* Add the working vars back into context.state[] */ - state[0] += a; - state[1] += b; - state[2] += c; - state[3] += d; - state[4] += e; - /* Wipe variables */ - a = b = c = d = e = 0; -} - -void mvSHA1Init(MV_SHA1_CTX* context) -{ - /* SHA1 initialization constants */ - context->state[0] = 0x67452301; - context->state[1] = 0xEFCDAB89; - context->state[2] = 0x98BADCFE; - context->state[3] = 0x10325476; - context->state[4] = 0xC3D2E1F0; - context->count[0] = context->count[1] = 0; -} - - -/* Run your data through this. */ -void mvSHA1Update(MV_SHA1_CTX *context, MV_U8 const *data, - unsigned int len) -{ - MV_U32 i, j; - - j = (context->count[0] >> 3) & 63; - if ((context->count[0] += len << 3) < (len << 3)) - context->count[1]++; - context->count[1] += (len >> 29); - if ((j + len) > 63) - { - memcpy(&context->buffer[j], data, (i = 64-j)); - mvSHA1Transform(context->state, context->buffer); - for ( ; i + 63 < len; i += 64) - { - mvSHA1Transform(context->state, &data[i]); - } - j = 0; - } - else - { - i = 0; - } - memcpy(&context->buffer[j], &data[i], len - i); -} - -void mvSHA1Final(MV_U8* digest, MV_SHA1_CTX* context) -{ - MV_U32 i; - MV_U8 finalcount[8]; - - for (i = 0; i < 8; i++) - { - finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)] >> - ((3-(i & 3)) * 8) ) & 255); /* Endian independent */ - } - mvSHA1Update(context, (const unsigned char *) "\200", 1); - while ((context->count[0] & 504) != 448) - { - mvSHA1Update(context, (const unsigned char *) "\0", 1); - } - mvSHA1Update(context, finalcount, 8); /* Should cause a mvSHA1Transform() - */ - for (i = 0; i < 20; i++) - { - digest[i] = (unsigned char) - ((context->state[i >> 2] >> ((3 - (i & 3)) * 8)) & 255); - } - /* Wipe variables */ - i = 0; - memset(context->buffer, 0, 64); - memset(context->state, 0, 20); - memset(context->count, 0, 8); - memset(finalcount, 0, 8); - -#ifdef SHA1HANDSOFF /* make SHA1Transform overwrite it's own static vars */ - mvSHA1Transform(context->state, context->buffer); -#endif -} - - -void mvSHA1(MV_U8 const *buf, unsigned int len, MV_U8* digest) -{ - MV_SHA1_CTX ctx; - - mvSHA1Init(&ctx); - mvSHA1Update(&ctx, buf, len); - mvSHA1Final(digest, &ctx); -} diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvSHA1.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvSHA1.h deleted file mode 100644 index 17df9fc..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/mvSHA1.h +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __mvSHA1_h__ -#define __mvSHA1_h__ - -#include "mvSHA1.h" - -#define MV_SHA1_MAC_LEN 20 - - -typedef struct -{ - MV_U32 state[5]; - MV_U32 count[2]; - MV_U8 buffer[64]; - -} MV_SHA1_CTX; - -void mvSHA1Init(MV_SHA1_CTX *context); -void mvSHA1Update(MV_SHA1_CTX *context, MV_U8 const *buf, unsigned int len); -void mvSHA1Final(MV_U8* digest, MV_SHA1_CTX *context); - -void mvSHA1(MV_U8 const *buf, unsigned int len, MV_U8* digest); - - -#endif /* __mvSHA1_h__ */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa_ocf_drv.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa_ocf_drv.c deleted file mode 100644 index ccf9227..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa_ocf_drv.c +++ /dev/null @@ -1,1296 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -*******************************************************************************/ - -#ifndef AUTOCONF_INCLUDED -#include <linux/config.h> -#endif -#include <linux/module.h> -#include <linux/init.h> -#include <linux/list.h> -#include <linux/slab.h> -#include <linux/sched.h> -#include <linux/wait.h> -#include <linux/crypto.h> -#include <linux/mm.h> -#include <linux/skbuff.h> -#include <linux/random.h> -#include <linux/platform_device.h> -#include <asm/scatterlist.h> -#include <linux/spinlock.h> -#include "ctrlEnv/sys/mvSysCesa.h" -#include "cesa/mvCesa.h" /* moved here before cryptodev.h due to include dependencies */ -#include <cryptodev.h> -#include <uio.h> -#include <plat/mv_cesa.h> -#include <linux/mbus.h> -#include "mvDebug.h" - -#include "cesa/mvMD5.h" -#include "cesa/mvSHA1.h" - -#include "cesa/mvCesaRegs.h" -#include "cesa/AES/mvAes.h" -#include "cesa/mvLru.h" - -#undef RT_DEBUG -#ifdef RT_DEBUG -static int debug = 1; -module_param(debug, int, 1); -MODULE_PARM_DESC(debug, "Enable debug"); -#undef dprintk -#define dprintk(a...) if (debug) { printk(a); } else -#else -static int debug = 0; -#undef dprintk -#define dprintk(a...) -#endif - - -/* TDMA Regs */ -#define WINDOW_BASE(i) 0xA00 + (i << 3) -#define WINDOW_CTRL(i) 0xA04 + (i << 3) - -/* interrupt handling */ -#undef CESA_OCF_POLLING -#undef CESA_OCF_TASKLET - -#if defined(CESA_OCF_POLLING) && defined(CESA_OCF_TASKLET) -#error "don't use both tasklet and polling mode" -#endif - -extern int cesaReqResources; -/* support for spliting action into 2 actions */ -#define CESA_OCF_SPLIT - -/* general defines */ -#define CESA_OCF_MAX_SES 128 -#define CESA_Q_SIZE 64 - - -/* data structures */ -struct cesa_ocf_data { - int cipher_alg; - int auth_alg; - int encrypt_tn_auth; -#define auth_tn_decrypt encrypt_tn_auth - int ivlen; - int digestlen; - short sid_encrypt; - short sid_decrypt; - /* fragment workaround sessions */ - short frag_wa_encrypt; - short frag_wa_decrypt; - short frag_wa_auth; -}; - -/* CESA device data */ -struct cesa_dev { - void __iomem *sram; - void __iomem *reg; - struct mv_cesa_platform_data *plat_data; - int irq; -}; - -#define DIGEST_BUF_SIZE 32 -struct cesa_ocf_process { - MV_CESA_COMMAND cesa_cmd; - MV_CESA_MBUF cesa_mbuf; - MV_BUF_INFO cesa_bufs[MV_CESA_MAX_MBUF_FRAGS]; - char digest[DIGEST_BUF_SIZE]; - int digest_len; - struct cryptop *crp; - int need_cb; -}; - -/* global variables */ -static int32_t cesa_ocf_id = -1; -static struct cesa_ocf_data *cesa_ocf_sessions[CESA_OCF_MAX_SES]; -static spinlock_t cesa_lock; -static struct cesa_dev cesa_device; - -/* static APIs */ -static int cesa_ocf_process (device_t, struct cryptop *, int); -static int cesa_ocf_newsession (device_t, u_int32_t *, struct cryptoini *); -static int cesa_ocf_freesession (device_t, u_int64_t); -static void cesa_callback (unsigned long); -static irqreturn_t cesa_interrupt_handler (int, void *); -#ifdef CESA_OCF_POLLING -static void cesa_interrupt_polling(void); -#endif -#ifdef CESA_OCF_TASKLET -static struct tasklet_struct cesa_ocf_tasklet; -#endif - -static struct timeval tt_start; -static struct timeval tt_end; - -/* - * dummy device structure - */ - -static struct { - softc_device_decl sc_dev; -} mv_cesa_dev; - -static device_method_t mv_cesa_methods = { - /* crypto device methods */ - DEVMETHOD(cryptodev_newsession, cesa_ocf_newsession), - DEVMETHOD(cryptodev_freesession,cesa_ocf_freesession), - DEVMETHOD(cryptodev_process, cesa_ocf_process), - DEVMETHOD(cryptodev_kprocess, NULL), -}; - - - -/* Add debug Trace */ -#undef CESA_OCF_TRACE_DEBUG -#ifdef CESA_OCF_TRACE_DEBUG - -#define MV_CESA_USE_TIMER_ID 0 - -typedef struct -{ - int type; /* 0 - isrEmpty, 1 - cesaReadyGet, 2 - cesaAction */ - MV_U32 timeStamp; - MV_U32 cause; - MV_U32 realCause; - MV_U32 dmaCause; - int resources; - MV_CESA_REQ* pReqReady; - MV_CESA_REQ* pReqEmpty; - MV_CESA_REQ* pReqProcess; -} MV_CESA_TEST_TRACE; - -#define MV_CESA_TEST_TRACE_SIZE 50 - -static int cesaTestTraceIdx = 0; -static MV_CESA_TEST_TRACE cesaTestTrace[MV_CESA_TEST_TRACE_SIZE]; - -static void cesaTestTraceAdd(int type) -{ - cesaTestTrace[cesaTestTraceIdx].type = type; - cesaTestTrace[cesaTestTraceIdx].realCause = MV_REG_READ(MV_CESA_ISR_CAUSE_REG); - //cesaTestTrace[cesaTestTraceIdx].idmaCause = MV_REG_READ(IDMA_CAUSE_REG); - cesaTestTrace[cesaTestTraceIdx].resources = cesaReqResources; - cesaTestTrace[cesaTestTraceIdx].pReqReady = pCesaReqReady; - cesaTestTrace[cesaTestTraceIdx].pReqEmpty = pCesaReqEmpty; - cesaTestTrace[cesaTestTraceIdx].pReqProcess = pCesaReqProcess; - cesaTestTrace[cesaTestTraceIdx].timeStamp = mvCntmrRead(MV_CESA_USE_TIMER_ID); - cesaTestTraceIdx++; - if(cesaTestTraceIdx == MV_CESA_TEST_TRACE_SIZE) - cesaTestTraceIdx = 0; -} - -#else /* CESA_OCF_TRACE_DEBUG */ - -#define cesaTestTraceAdd(x) - -#endif /* CESA_OCF_TRACE_DEBUG */ - -unsigned int -get_usec(unsigned int start) -{ - if(start) { - do_gettimeofday (&tt_start); - return 0; - } - else { - do_gettimeofday (&tt_end); - tt_end.tv_sec -= tt_start.tv_sec; - tt_end.tv_usec -= tt_start.tv_usec; - if (tt_end.tv_usec < 0) { - tt_end.tv_usec += 1000 * 1000; - tt_end.tv_sec -= 1; - } - } - printk("time taken is %d\n", (unsigned int)(tt_end.tv_usec + tt_end.tv_sec * 1000000)); - return (tt_end.tv_usec + tt_end.tv_sec * 1000000); -} - -#ifdef RT_DEBUG -/* - * check that the crp action match the current session - */ -static int -ocf_check_action(struct cryptop *crp, struct cesa_ocf_data *cesa_ocf_cur_ses) { - int count = 0; - int encrypt = 0, decrypt = 0, auth = 0; - struct cryptodesc *crd; - - /* Go through crypto descriptors, processing as we go */ - for (crd = crp->crp_desc; crd; crd = crd->crd_next, count++) { - if(count > 2) { - printk("%s,%d: session mode is not supported.\n", __FILE__, __LINE__); - return 1; - } - - /* Encryption /Decryption */ - if(crd->crd_alg == cesa_ocf_cur_ses->cipher_alg) { - /* check that the action is compatible with session */ - if(encrypt || decrypt) { - printk("%s,%d: session mode is not supported.\n", __FILE__, __LINE__); - return 1; - } - - if(crd->crd_flags & CRD_F_ENCRYPT) { /* encrypt */ - if( (count == 2) && (cesa_ocf_cur_ses->encrypt_tn_auth) ) { - printk("%s,%d: sequence isn't supported by this session.\n", __FILE__, __LINE__); - return 1; - } - encrypt++; - } - else { /* decrypt */ - if( (count == 2) && !(cesa_ocf_cur_ses->auth_tn_decrypt) ) { - printk("%s,%d: sequence isn't supported by this session.\n", __FILE__, __LINE__); - return 1; - } - decrypt++; - } - - } - /* Authentication */ - else if(crd->crd_alg == cesa_ocf_cur_ses->auth_alg) { - /* check that the action is compatible with session */ - if(auth) { - printk("%s,%d: session mode is not supported.\n", __FILE__, __LINE__); - return 1; - } - if( (count == 2) && (decrypt) && (cesa_ocf_cur_ses->auth_tn_decrypt)) { - printk("%s,%d: sequence isn't supported by this session.\n", __FILE__, __LINE__); - return 1; - } - if( (count == 2) && (encrypt) && !(cesa_ocf_cur_ses->encrypt_tn_auth)) { - printk("%s,%d: sequence isn't supported by this session.\n", __FILE__, __LINE__); - return 1; - } - auth++; - } - else { - printk("%s,%d: Alg isn't supported by this session.\n", __FILE__, __LINE__); - return 1; - } - } - return 0; - -} -#endif - -/* - * Process a request. - */ -static int -cesa_ocf_process(device_t dev, struct cryptop *crp, int hint) -{ - struct cesa_ocf_process *cesa_ocf_cmd = NULL; - struct cesa_ocf_process *cesa_ocf_cmd_wa = NULL; - MV_CESA_COMMAND *cesa_cmd; - struct cryptodesc *crd; - struct cesa_ocf_data *cesa_ocf_cur_ses; - int sid = 0, temp_len = 0, i; - int encrypt = 0, decrypt = 0, auth = 0; - int status; - struct sk_buff *skb = NULL; - struct uio *uiop = NULL; - unsigned char *ivp; - MV_BUF_INFO *p_buf_info; - MV_CESA_MBUF *p_mbuf_info; - unsigned long flags; - - dprintk("%s()\n", __FUNCTION__); - - if( cesaReqResources <= 1 ) { - dprintk("%s,%d: ERESTART\n", __FILE__, __LINE__); - return ERESTART; - } - -#ifdef RT_DEBUG - /* Sanity check */ - if (crp == NULL) { - printk("%s,%d: EINVAL\n", __FILE__, __LINE__); - return EINVAL; - } - - if (crp->crp_desc == NULL || crp->crp_buf == NULL ) { - printk("%s,%d: EINVAL\n", __FILE__, __LINE__); - crp->crp_etype = EINVAL; - return EINVAL; - } - - sid = crp->crp_sid & 0xffffffff; - if ((sid >= CESA_OCF_MAX_SES) || (cesa_ocf_sessions[sid] == NULL)) { - crp->crp_etype = ENOENT; - printk("%s,%d: ENOENT session %d \n", __FILE__, __LINE__, sid); - return EINVAL; - } -#endif - - sid = crp->crp_sid & 0xffffffff; - crp->crp_etype = 0; - cesa_ocf_cur_ses = cesa_ocf_sessions[sid]; - -#ifdef RT_DEBUG - if(ocf_check_action(crp, cesa_ocf_cur_ses)){ - goto p_error; - } -#endif - - /* malloc a new cesa process */ - cesa_ocf_cmd = kmalloc(sizeof(struct cesa_ocf_process), GFP_ATOMIC); - - if (cesa_ocf_cmd == NULL) { - printk("%s,%d: ENOBUFS \n", __FILE__, __LINE__); - goto p_error; - } - memset(cesa_ocf_cmd, 0, sizeof(struct cesa_ocf_process)); - - /* init cesa_process */ - cesa_ocf_cmd->crp = crp; - /* always call callback */ - cesa_ocf_cmd->need_cb = 1; - - /* init cesa_cmd for usage of the HALs */ - cesa_cmd = &cesa_ocf_cmd->cesa_cmd; - cesa_cmd->pReqPrv = (void *)cesa_ocf_cmd; - cesa_cmd->sessionId = cesa_ocf_cur_ses->sid_encrypt; /* defualt use encrypt */ - - /* prepare src buffer */ - /* we send the entire buffer to the HAL, even if only part of it should be encrypt/auth. */ - /* if not using seesions for both encrypt and auth, then it will be wiser to to copy only */ - /* from skip to crd_len. */ - p_buf_info = cesa_ocf_cmd->cesa_bufs; - p_mbuf_info = &cesa_ocf_cmd->cesa_mbuf; - - p_buf_info += 2; /* save 2 first buffers for IV and digest - - we won't append them to the end since, they - might be places in an unaligned addresses. */ - - p_mbuf_info->pFrags = p_buf_info; - temp_len = 0; - - /* handle SKB */ - if (crp->crp_flags & CRYPTO_F_SKBUF) { - - dprintk("%s,%d: handle SKB.\n", __FILE__, __LINE__); - skb = (struct sk_buff *) crp->crp_buf; - - if (skb_shinfo(skb)->nr_frags >= (MV_CESA_MAX_MBUF_FRAGS - 1)) { - printk("%s,%d: %d nr_frags > MV_CESA_MAX_MBUF_FRAGS", __FILE__, __LINE__, skb_shinfo(skb)->nr_frags); - goto p_error; - } - - p_mbuf_info->mbufSize = skb->len; - temp_len = skb->len; - /* first skb fragment */ - p_buf_info->bufSize = skb_headlen(skb); - p_buf_info->bufVirtPtr = skb->data; - p_buf_info++; - - /* now handle all other skb fragments */ - for ( i = 0; i < skb_shinfo(skb)->nr_frags; i++ ) { - skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; - p_buf_info->bufSize = frag->size; - p_buf_info->bufVirtPtr = page_address(frag->page) + frag->page_offset; - p_buf_info++; - } - p_mbuf_info->numFrags = skb_shinfo(skb)->nr_frags + 1; - } - /* handle UIO */ - else if(crp->crp_flags & CRYPTO_F_IOV) { - - dprintk("%s,%d: handle UIO.\n", __FILE__, __LINE__); - uiop = (struct uio *) crp->crp_buf; - - if (uiop->uio_iovcnt > (MV_CESA_MAX_MBUF_FRAGS - 1)) { - printk("%s,%d: %d uio_iovcnt > MV_CESA_MAX_MBUF_FRAGS \n", __FILE__, __LINE__, uiop->uio_iovcnt); - goto p_error; - } - - p_mbuf_info->mbufSize = crp->crp_ilen; - p_mbuf_info->numFrags = uiop->uio_iovcnt; - for(i = 0; i < uiop->uio_iovcnt; i++) { - p_buf_info->bufVirtPtr = uiop->uio_iov[i].iov_base; - p_buf_info->bufSize = uiop->uio_iov[i].iov_len; - temp_len += p_buf_info->bufSize; - dprintk("%s,%d: buf %x-> addr %x, size %x \n" - , __FILE__, __LINE__, i, (unsigned int)p_buf_info->bufVirtPtr, p_buf_info->bufSize); - p_buf_info++; - } - - } - /* handle CONTIG */ - else { - dprintk("%s,%d: handle CONTIG.\n", __FILE__, __LINE__); - p_mbuf_info->numFrags = 1; - p_mbuf_info->mbufSize = crp->crp_ilen; - p_buf_info->bufVirtPtr = crp->crp_buf; - p_buf_info->bufSize = crp->crp_ilen; - temp_len = crp->crp_ilen; - p_buf_info++; - } - - /* Support up to 64K why? cause! */ - if(crp->crp_ilen > 64*1024) { - printk("%s,%d: buf too big %x \n", __FILE__, __LINE__, crp->crp_ilen); - goto p_error; - } - - if( temp_len != crp->crp_ilen ) { - printk("%s,%d: warning size don't match.(%x %x) \n", __FILE__, __LINE__, temp_len, crp->crp_ilen); - } - - cesa_cmd->pSrc = p_mbuf_info; - cesa_cmd->pDst = p_mbuf_info; - - /* restore p_buf_info to point to first available buf */ - p_buf_info = cesa_ocf_cmd->cesa_bufs; - p_buf_info += 1; - - - /* Go through crypto descriptors, processing as we go */ - for (crd = crp->crp_desc; crd; crd = crd->crd_next) { - - /* Encryption /Decryption */ - if(crd->crd_alg == cesa_ocf_cur_ses->cipher_alg) { - - dprintk("%s,%d: cipher", __FILE__, __LINE__); - - cesa_cmd->cryptoOffset = crd->crd_skip; - cesa_cmd->cryptoLength = crd->crd_len; - - if(crd->crd_flags & CRD_F_ENCRYPT) { /* encrypt */ - dprintk(" encrypt \n"); - encrypt++; - - /* handle IV */ - if (crd->crd_flags & CRD_F_IV_EXPLICIT) { /* IV from USER */ - dprintk("%s,%d: IV from USER (offset %x) \n", __FILE__, __LINE__, crd->crd_inject); - cesa_cmd->ivFromUser = 1; - ivp = crd->crd_iv; - - /* - * do we have to copy the IV back to the buffer ? - */ - if ((crd->crd_flags & CRD_F_IV_PRESENT) == 0) { - dprintk("%s,%d: copy the IV back to the buffer\n", __FILE__, __LINE__); - cesa_cmd->ivOffset = crd->crd_inject; - crypto_copy_bits_back(crp->crp_buf, crd->crd_inject, ivp, cesa_ocf_cur_ses->ivlen); - } - else { - dprintk("%s,%d: don't copy the IV back to the buffer \n", __FILE__, __LINE__); - p_mbuf_info->numFrags++; - p_mbuf_info->mbufSize += cesa_ocf_cur_ses->ivlen; - p_mbuf_info->pFrags = p_buf_info; - - p_buf_info->bufVirtPtr = ivp; - p_buf_info->bufSize = cesa_ocf_cur_ses->ivlen; - p_buf_info--; - - /* offsets */ - cesa_cmd->ivOffset = 0; - cesa_cmd->cryptoOffset += cesa_ocf_cur_ses->ivlen; - if(auth) { - cesa_cmd->macOffset += cesa_ocf_cur_ses->ivlen; - cesa_cmd->digestOffset += cesa_ocf_cur_ses->ivlen; - } - } - } - else { /* random IV */ - dprintk("%s,%d: random IV \n", __FILE__, __LINE__); - cesa_cmd->ivFromUser = 0; - - /* - * do we have to copy the IV back to the buffer ? - */ - /* in this mode the HAL will always copy the IV */ - /* given by the session to the ivOffset */ - if ((crd->crd_flags & CRD_F_IV_PRESENT) == 0) { - cesa_cmd->ivOffset = crd->crd_inject; - } - else { - /* if IV isn't copy, then how will the user know which IV did we use??? */ - printk("%s,%d: EINVAL\n", __FILE__, __LINE__); - goto p_error; - } - } - } - else { /* decrypt */ - dprintk(" decrypt \n"); - decrypt++; - cesa_cmd->sessionId = cesa_ocf_cur_ses->sid_decrypt; - - /* handle IV */ - if (crd->crd_flags & CRD_F_IV_EXPLICIT) { - dprintk("%s,%d: IV from USER \n", __FILE__, __LINE__); - /* append the IV buf to the mbuf */ - cesa_cmd->ivFromUser = 1; - p_mbuf_info->numFrags++; - p_mbuf_info->mbufSize += cesa_ocf_cur_ses->ivlen; - p_mbuf_info->pFrags = p_buf_info; - - p_buf_info->bufVirtPtr = crd->crd_iv; - p_buf_info->bufSize = cesa_ocf_cur_ses->ivlen; - p_buf_info--; - - /* offsets */ - cesa_cmd->ivOffset = 0; - cesa_cmd->cryptoOffset += cesa_ocf_cur_ses->ivlen; - if(auth) { - cesa_cmd->macOffset += cesa_ocf_cur_ses->ivlen; - cesa_cmd->digestOffset += cesa_ocf_cur_ses->ivlen; - } - } - else { - dprintk("%s,%d: IV inside the buffer \n", __FILE__, __LINE__); - cesa_cmd->ivFromUser = 0; - cesa_cmd->ivOffset = crd->crd_inject; - } - } - - } - /* Authentication */ - else if(crd->crd_alg == cesa_ocf_cur_ses->auth_alg) { - dprintk("%s,%d: Authentication \n", __FILE__, __LINE__); - auth++; - cesa_cmd->macOffset = crd->crd_skip; - cesa_cmd->macLength = crd->crd_len; - - /* digest + mac */ - cesa_cmd->digestOffset = crd->crd_inject; - } - else { - printk("%s,%d: Alg isn't supported by this session.\n", __FILE__, __LINE__); - goto p_error; - } - } - - dprintk("\n"); - dprintk("%s,%d: Sending Action: \n", __FILE__, __LINE__); - dprintk("%s,%d: IV from user: %d. IV offset %x \n", __FILE__, __LINE__, cesa_cmd->ivFromUser, cesa_cmd->ivOffset); - dprintk("%s,%d: crypt offset %x len %x \n", __FILE__, __LINE__, cesa_cmd->cryptoOffset, cesa_cmd->cryptoLength); - dprintk("%s,%d: Auth offset %x len %x \n", __FILE__, __LINE__, cesa_cmd->macOffset, cesa_cmd->macLength); - dprintk("%s,%d: set digest in offset %x . \n", __FILE__, __LINE__, cesa_cmd->digestOffset); - if(debug) { - mvCesaDebugMbuf("SRC BUFFER", cesa_cmd->pSrc, 0, cesa_cmd->pSrc->mbufSize); - } - - - /* send action to HAL */ - spin_lock_irqsave(&cesa_lock, flags); - status = mvCesaAction(cesa_cmd); - spin_unlock_irqrestore(&cesa_lock, flags); - - /* action not allowed */ - if(status == MV_NOT_ALLOWED) { -#ifdef CESA_OCF_SPLIT - /* if both encrypt and auth try to split */ - if(auth && (encrypt || decrypt)) { - MV_CESA_COMMAND *cesa_cmd_wa; - - /* malloc a new cesa process and init it */ - cesa_ocf_cmd_wa = kmalloc(sizeof(struct cesa_ocf_process), GFP_ATOMIC); - - if (cesa_ocf_cmd_wa == NULL) { - printk("%s,%d: ENOBUFS \n", __FILE__, __LINE__); - goto p_error; - } - memcpy(cesa_ocf_cmd_wa, cesa_ocf_cmd, sizeof(struct cesa_ocf_process)); - cesa_cmd_wa = &cesa_ocf_cmd_wa->cesa_cmd; - cesa_cmd_wa->pReqPrv = (void *)cesa_ocf_cmd_wa; - cesa_ocf_cmd_wa->need_cb = 0; - - /* break requests to two operation, first operation completion won't call callback */ - if((decrypt) && (cesa_ocf_cur_ses->auth_tn_decrypt)) { - cesa_cmd_wa->sessionId = cesa_ocf_cur_ses->frag_wa_auth; - cesa_cmd->sessionId = cesa_ocf_cur_ses->frag_wa_decrypt; - } - else if((decrypt) && !(cesa_ocf_cur_ses->auth_tn_decrypt)) { - cesa_cmd_wa->sessionId = cesa_ocf_cur_ses->frag_wa_decrypt; - cesa_cmd->sessionId = cesa_ocf_cur_ses->frag_wa_auth; - } - else if((encrypt) && (cesa_ocf_cur_ses->encrypt_tn_auth)) { - cesa_cmd_wa->sessionId = cesa_ocf_cur_ses->frag_wa_encrypt; - cesa_cmd->sessionId = cesa_ocf_cur_ses->frag_wa_auth; - } - else if((encrypt) && !(cesa_ocf_cur_ses->encrypt_tn_auth)){ - cesa_cmd_wa->sessionId = cesa_ocf_cur_ses->frag_wa_auth; - cesa_cmd->sessionId = cesa_ocf_cur_ses->frag_wa_encrypt; - } - else { - printk("%s,%d: Unsupporterd fragment wa mode \n", __FILE__, __LINE__); - goto p_error; - } - - /* send the 2 actions to the HAL */ - spin_lock_irqsave(&cesa_lock, flags); - status = mvCesaAction(cesa_cmd_wa); - spin_unlock_irqrestore(&cesa_lock, flags); - - if((status != MV_NO_MORE) && (status != MV_OK)) { - printk("%s,%d: cesa action failed, status = 0x%x\n", __FILE__, __LINE__, status); - goto p_error; - } - spin_lock_irqsave(&cesa_lock, flags); - status = mvCesaAction(cesa_cmd); - spin_unlock_irqrestore(&cesa_lock, flags); - - } - /* action not allowed and can't split */ - else -#endif - { - goto p_error; - } - } - - /* Hal Q is full, send again. This should never happen */ - if(status == MV_NO_RESOURCE) { - printk("%s,%d: cesa no more resources \n", __FILE__, __LINE__); - if(cesa_ocf_cmd) - kfree(cesa_ocf_cmd); - if(cesa_ocf_cmd_wa) - kfree(cesa_ocf_cmd_wa); - return ERESTART; - } - else if((status != MV_NO_MORE) && (status != MV_OK)) { - printk("%s,%d: cesa action failed, status = 0x%x\n", __FILE__, __LINE__, status); - goto p_error; - } - - -#ifdef CESA_OCF_POLLING - cesa_interrupt_polling(); -#endif - cesaTestTraceAdd(5); - - return 0; -p_error: - crp->crp_etype = EINVAL; - if(cesa_ocf_cmd) - kfree(cesa_ocf_cmd); - if(cesa_ocf_cmd_wa) - kfree(cesa_ocf_cmd_wa); - return EINVAL; -} - -/* - * cesa callback. - */ -static void -cesa_callback(unsigned long dummy) -{ - struct cesa_ocf_process *cesa_ocf_cmd = NULL; - struct cryptop *crp = NULL; - MV_CESA_RESULT result[MV_CESA_MAX_CHAN]; - int res_idx = 0,i; - MV_STATUS status; - - dprintk("%s()\n", __FUNCTION__); - -#ifdef CESA_OCF_TASKLET - disable_irq(cesa_device.irq); -#endif - while(MV_TRUE) { - - /* Get Ready requests */ - spin_lock(&cesa_lock); - status = mvCesaReadyGet(&result[res_idx]); - spin_unlock(&cesa_lock); - - cesaTestTraceAdd(2); - - if(status != MV_OK) { -#ifdef CESA_OCF_POLLING - if(status == MV_BUSY) { /* Fragment */ - cesa_interrupt_polling(); - return; - } -#endif - break; - } - res_idx++; - break; - } - - for(i = 0; i < res_idx; i++) { - - if(!result[i].pReqPrv) { - printk("%s,%d: warning private is NULL\n", __FILE__, __LINE__); - break; - } - - cesa_ocf_cmd = result[i].pReqPrv; - crp = cesa_ocf_cmd->crp; - - // ignore HMAC error. - //if(result->retCode) - // crp->crp_etype = EIO; - -#if defined(CESA_OCF_POLLING) - if(!cesa_ocf_cmd->need_cb){ - cesa_interrupt_polling(); - } -#endif - if(cesa_ocf_cmd->need_cb) { - if(debug) { - mvCesaDebugMbuf("DST BUFFER", cesa_ocf_cmd->cesa_cmd.pDst, 0, cesa_ocf_cmd->cesa_cmd.pDst->mbufSize); - } - crypto_done(crp); - } - kfree(cesa_ocf_cmd); - } -#ifdef CESA_OCF_TASKLET - enable_irq(cesa_device.irq); -#endif - - cesaTestTraceAdd(3); - - return; -} - -#ifdef CESA_OCF_POLLING -static void -cesa_interrupt_polling(void) -{ - u32 cause; - - dprintk("%s()\n", __FUNCTION__); - - /* Read cause register */ - do { - cause = MV_REG_READ(MV_CESA_ISR_CAUSE_REG); - cause &= MV_CESA_CAUSE_ACC_DMA_ALL_MASK; - - } while (cause == 0); - - /* clear interrupts */ - MV_REG_WRITE(MV_CESA_ISR_CAUSE_REG, 0); - - cesa_callback(0); - - return; -} - -#endif - -/* - * cesa Interrupt polling routine. - */ -static irqreturn_t -cesa_interrupt_handler(int irq, void *arg) -{ - u32 cause; - - dprintk("%s()\n", __FUNCTION__); - - cesaTestTraceAdd(0); - - /* Read cause register */ - cause = MV_REG_READ(MV_CESA_ISR_CAUSE_REG); - - if( (cause & MV_CESA_CAUSE_ACC_DMA_ALL_MASK) == 0) - { - /* Empty interrupt */ - dprintk("%s,%d: cesaTestReadyIsr: cause=0x%x\n", __FILE__, __LINE__, cause); - return IRQ_HANDLED; - } - - /* clear interrupts */ - MV_REG_WRITE(MV_CESA_ISR_CAUSE_REG, 0); - - cesaTestTraceAdd(1); -#ifdef CESA_OCF_TASKLET - tasklet_hi_schedule(&cesa_ocf_tasklet); -#else - cesa_callback(0); -#endif - return IRQ_HANDLED; -} - -/* - * Open a session. - */ -static int -/*cesa_ocf_newsession(void *arg, u_int32_t *sid, struct cryptoini *cri)*/ -cesa_ocf_newsession(device_t dev, u_int32_t *sid, struct cryptoini *cri) -{ - u32 status = 0, i; - u32 count = 0, auth = 0, encrypt =0; - struct cesa_ocf_data *cesa_ocf_cur_ses; - MV_CESA_OPEN_SESSION cesa_session; - MV_CESA_OPEN_SESSION *cesa_ses = &cesa_session; - - - dprintk("%s()\n", __FUNCTION__); - if (sid == NULL || cri == NULL) { - printk("%s,%d: EINVAL\n", __FILE__, __LINE__); - return EINVAL; - } - - /* leave first empty like in other implementations */ - for (i = 1; i < CESA_OCF_MAX_SES; i++) { - if (cesa_ocf_sessions[i] == NULL) - break; - } - - if(i >= CESA_OCF_MAX_SES) { - printk("%s,%d: no more sessions \n", __FILE__, __LINE__); - return EINVAL; - } - - cesa_ocf_sessions[i] = (struct cesa_ocf_data *) kmalloc(sizeof(struct cesa_ocf_data), GFP_ATOMIC); - if (cesa_ocf_sessions[i] == NULL) { - cesa_ocf_freesession(NULL, i); - printk("%s,%d: ENOBUFS \n", __FILE__, __LINE__); - return ENOBUFS; - } - dprintk("%s,%d: new session %d \n", __FILE__, __LINE__, i); - - *sid = i; - cesa_ocf_cur_ses = cesa_ocf_sessions[i]; - memset(cesa_ocf_cur_ses, 0, sizeof(struct cesa_ocf_data)); - cesa_ocf_cur_ses->sid_encrypt = -1; - cesa_ocf_cur_ses->sid_decrypt = -1; - cesa_ocf_cur_ses->frag_wa_encrypt = -1; - cesa_ocf_cur_ses->frag_wa_decrypt = -1; - cesa_ocf_cur_ses->frag_wa_auth = -1; - - /* init the session */ - memset(cesa_ses, 0, sizeof(MV_CESA_OPEN_SESSION)); - count = 1; - while (cri) { - if(count > 2) { - printk("%s,%d: don't support more then 2 operations\n", __FILE__, __LINE__); - goto error; - } - switch (cri->cri_alg) { - case CRYPTO_AES_CBC: - dprintk("%s,%d: (%d) AES CBC \n", __FILE__, __LINE__, count); - cesa_ocf_cur_ses->cipher_alg = cri->cri_alg; - cesa_ocf_cur_ses->ivlen = MV_CESA_AES_BLOCK_SIZE; - cesa_ses->cryptoAlgorithm = MV_CESA_CRYPTO_AES; - cesa_ses->cryptoMode = MV_CESA_CRYPTO_CBC; - if(cri->cri_klen/8 > MV_CESA_MAX_CRYPTO_KEY_LENGTH) { - printk("%s,%d: CRYPTO key too long.\n", __FILE__, __LINE__); - goto error; - } - memcpy(cesa_ses->cryptoKey, cri->cri_key, cri->cri_klen/8); - dprintk("%s,%d: key length %d \n", __FILE__, __LINE__, cri->cri_klen/8); - cesa_ses->cryptoKeyLength = cri->cri_klen/8; - encrypt += count; - break; - case CRYPTO_3DES_CBC: - dprintk("%s,%d: (%d) 3DES CBC \n", __FILE__, __LINE__, count); - cesa_ocf_cur_ses->cipher_alg = cri->cri_alg; - cesa_ocf_cur_ses->ivlen = MV_CESA_3DES_BLOCK_SIZE; - cesa_ses->cryptoAlgorithm = MV_CESA_CRYPTO_3DES; - cesa_ses->cryptoMode = MV_CESA_CRYPTO_CBC; - if(cri->cri_klen/8 > MV_CESA_MAX_CRYPTO_KEY_LENGTH) { - printk("%s,%d: CRYPTO key too long.\n", __FILE__, __LINE__); - goto error; - } - memcpy(cesa_ses->cryptoKey, cri->cri_key, cri->cri_klen/8); - cesa_ses->cryptoKeyLength = cri->cri_klen/8; - encrypt += count; - break; - case CRYPTO_DES_CBC: - dprintk("%s,%d: (%d) DES CBC \n", __FILE__, __LINE__, count); - cesa_ocf_cur_ses->cipher_alg = cri->cri_alg; - cesa_ocf_cur_ses->ivlen = MV_CESA_DES_BLOCK_SIZE; - cesa_ses->cryptoAlgorithm = MV_CESA_CRYPTO_DES; - cesa_ses->cryptoMode = MV_CESA_CRYPTO_CBC; - if(cri->cri_klen/8 > MV_CESA_MAX_CRYPTO_KEY_LENGTH) { - printk("%s,%d: CRYPTO key too long.\n", __FILE__, __LINE__); - goto error; - } - memcpy(cesa_ses->cryptoKey, cri->cri_key, cri->cri_klen/8); - cesa_ses->cryptoKeyLength = cri->cri_klen/8; - encrypt += count; - break; - case CRYPTO_MD5: - case CRYPTO_MD5_HMAC: - dprintk("%s,%d: (%d) %sMD5 CBC \n", __FILE__, __LINE__, count, (cri->cri_alg != CRYPTO_MD5)? "H-":" "); - cesa_ocf_cur_ses->auth_alg = cri->cri_alg; - cesa_ocf_cur_ses->digestlen = (cri->cri_alg == CRYPTO_MD5)? MV_CESA_MD5_DIGEST_SIZE : 12; - cesa_ses->macMode = (cri->cri_alg == CRYPTO_MD5)? MV_CESA_MAC_MD5 : MV_CESA_MAC_HMAC_MD5; - if(cri->cri_klen/8 > MV_CESA_MAX_CRYPTO_KEY_LENGTH) { - printk("%s,%d: MAC key too long. \n", __FILE__, __LINE__); - goto error; - } - cesa_ses->macKeyLength = cri->cri_klen/8; - memcpy(cesa_ses->macKey, cri->cri_key, cri->cri_klen/8); - cesa_ses->digestSize = cesa_ocf_cur_ses->digestlen; - auth += count; - break; - case CRYPTO_SHA1: - case CRYPTO_SHA1_HMAC: - dprintk("%s,%d: (%d) %sSHA1 CBC \n", __FILE__, __LINE__, count, (cri->cri_alg != CRYPTO_SHA1)? "H-":" "); - cesa_ocf_cur_ses->auth_alg = cri->cri_alg; - cesa_ocf_cur_ses->digestlen = (cri->cri_alg == CRYPTO_SHA1)? MV_CESA_SHA1_DIGEST_SIZE : 12; - cesa_ses->macMode = (cri->cri_alg == CRYPTO_SHA1)? MV_CESA_MAC_SHA1 : MV_CESA_MAC_HMAC_SHA1; - if(cri->cri_klen/8 > MV_CESA_MAX_CRYPTO_KEY_LENGTH) { - printk("%s,%d: MAC key too long. \n", __FILE__, __LINE__); - goto error; - } - cesa_ses->macKeyLength = cri->cri_klen/8; - memcpy(cesa_ses->macKey, cri->cri_key, cri->cri_klen/8); - cesa_ses->digestSize = cesa_ocf_cur_ses->digestlen; - auth += count; - break; - default: - printk("%s,%d: unknown algo 0x%x\n", __FILE__, __LINE__, cri->cri_alg); - goto error; - } - cri = cri->cri_next; - count++; - } - - if((encrypt > 2) || (auth > 2)) { - printk("%s,%d: session mode is not supported.\n", __FILE__, __LINE__); - goto error; - } - /* create new sessions in HAL */ - if(encrypt) { - cesa_ses->operation = MV_CESA_CRYPTO_ONLY; - /* encrypt session */ - if(auth == 1) { - cesa_ses->operation = MV_CESA_MAC_THEN_CRYPTO; - } - else if(auth == 2) { - cesa_ses->operation = MV_CESA_CRYPTO_THEN_MAC; - cesa_ocf_cur_ses->encrypt_tn_auth = 1; - } - else { - cesa_ses->operation = MV_CESA_CRYPTO_ONLY; - } - cesa_ses->direction = MV_CESA_DIR_ENCODE; - status = mvCesaSessionOpen(cesa_ses, &cesa_ocf_cur_ses->sid_encrypt); - if(status != MV_OK) { - printk("%s,%d: Can't open new session - status = 0x%x\n", __FILE__, __LINE__, status); - goto error; - } - /* decrypt session */ - if( cesa_ses->operation == MV_CESA_MAC_THEN_CRYPTO ) { - cesa_ses->operation = MV_CESA_CRYPTO_THEN_MAC; - } - else if( cesa_ses->operation == MV_CESA_CRYPTO_THEN_MAC ) { - cesa_ses->operation = MV_CESA_MAC_THEN_CRYPTO; - } - cesa_ses->direction = MV_CESA_DIR_DECODE; - status = mvCesaSessionOpen(cesa_ses, &cesa_ocf_cur_ses->sid_decrypt); - if(status != MV_OK) { - printk("%s,%d: Can't open new session - status = 0x%x\n", __FILE__, __LINE__, status); - goto error; - } - - /* preapre one action sessions for case we will need to split an action */ -#ifdef CESA_OCF_SPLIT - if(( cesa_ses->operation == MV_CESA_MAC_THEN_CRYPTO ) || - ( cesa_ses->operation == MV_CESA_CRYPTO_THEN_MAC )) { - /* open one session for encode and one for decode */ - cesa_ses->operation = MV_CESA_CRYPTO_ONLY; - cesa_ses->direction = MV_CESA_DIR_ENCODE; - status = mvCesaSessionOpen(cesa_ses, &cesa_ocf_cur_ses->frag_wa_encrypt); - if(status != MV_OK) { - printk("%s,%d: Can't open new session - status = 0x%x\n", __FILE__, __LINE__, status); - goto error; - } - - cesa_ses->direction = MV_CESA_DIR_DECODE; - status = mvCesaSessionOpen(cesa_ses, &cesa_ocf_cur_ses->frag_wa_decrypt); - if(status != MV_OK) { - printk("%s,%d: Can't open new session - status = 0x%x\n", __FILE__, __LINE__, status); - goto error; - } - /* open one session for auth */ - cesa_ses->operation = MV_CESA_MAC_ONLY; - cesa_ses->direction = MV_CESA_DIR_ENCODE; - status = mvCesaSessionOpen(cesa_ses, &cesa_ocf_cur_ses->frag_wa_auth); - if(status != MV_OK) { - printk("%s,%d: Can't open new session - status = 0x%x\n", __FILE__, __LINE__, status); - goto error; - } - } -#endif - } - else { /* only auth */ - cesa_ses->operation = MV_CESA_MAC_ONLY; - cesa_ses->direction = MV_CESA_DIR_ENCODE; - status = mvCesaSessionOpen(cesa_ses, &cesa_ocf_cur_ses->sid_encrypt); - if(status != MV_OK) { - printk("%s,%d: Can't open new session - status = 0x%x\n", __FILE__, __LINE__, status); - goto error; - } - } - - return 0; -error: - cesa_ocf_freesession(NULL, *sid); - return EINVAL; - -} - - -/* - * Free a session. - */ -static int -cesa_ocf_freesession(device_t dev, u_int64_t tid) -{ - struct cesa_ocf_data *cesa_ocf_cur_ses; - u_int32_t sid = CRYPTO_SESID2LID(tid); - //unsigned long flags; - - dprintk("%s() %d \n", __FUNCTION__, sid); - if ( (sid >= CESA_OCF_MAX_SES) || (cesa_ocf_sessions[sid] == NULL) ) { - printk("%s,%d: EINVAL can't free session %d \n", __FILE__, __LINE__, sid); - return(EINVAL); - } - - /* Silently accept and return */ - if (sid == 0) - return(0); - - /* release session from HAL */ - cesa_ocf_cur_ses = cesa_ocf_sessions[sid]; - if (cesa_ocf_cur_ses->sid_encrypt != -1) { - mvCesaSessionClose(cesa_ocf_cur_ses->sid_encrypt); - } - if (cesa_ocf_cur_ses->sid_decrypt != -1) { - mvCesaSessionClose(cesa_ocf_cur_ses->sid_decrypt); - } - if (cesa_ocf_cur_ses->frag_wa_encrypt != -1) { - mvCesaSessionClose(cesa_ocf_cur_ses->frag_wa_encrypt); - } - if (cesa_ocf_cur_ses->frag_wa_decrypt != -1) { - mvCesaSessionClose(cesa_ocf_cur_ses->frag_wa_decrypt); - } - if (cesa_ocf_cur_ses->frag_wa_auth != -1) { - mvCesaSessionClose(cesa_ocf_cur_ses->frag_wa_auth); - } - - kfree(cesa_ocf_cur_ses); - cesa_ocf_sessions[sid] = NULL; - - return 0; -} - - -/* TDMA Window setup */ - -static void __init -setup_tdma_mbus_windows(struct cesa_dev *dev) -{ - int i; - - for (i = 0; i < 4; i++) { - writel(0, dev->reg + WINDOW_BASE(i)); - writel(0, dev->reg + WINDOW_CTRL(i)); - } - - for (i = 0; i < dev->plat_data->dram->num_cs; i++) { - struct mbus_dram_window *cs = dev->plat_data->dram->cs + i; - writel( - ((cs->size - 1) & 0xffff0000) | - (cs->mbus_attr << 8) | - (dev->plat_data->dram->mbus_dram_target_id << 4) | 1, - dev->reg + WINDOW_CTRL(i) - ); - writel(cs->base, dev->reg + WINDOW_BASE(i)); - } -} - -/* - * our driver startup and shutdown routines - */ -static int -mv_cesa_ocf_init(struct platform_device *pdev) -{ -#if defined(CONFIG_MV78200) || defined(CONFIG_MV632X) - if (MV_FALSE == mvSocUnitIsMappedToThisCpu(CESA)) - { - dprintk("CESA is not mapped to this CPU\n"); - return -ENODEV; - } -#endif - - dprintk("%s\n", __FUNCTION__); - memset(&mv_cesa_dev, 0, sizeof(mv_cesa_dev)); - softc_device_init(&mv_cesa_dev, "MV CESA", 0, mv_cesa_methods); - cesa_ocf_id = crypto_get_driverid(softc_get_device(&mv_cesa_dev),CRYPTOCAP_F_HARDWARE); - - if (cesa_ocf_id < 0) - panic("MV CESA crypto device cannot initialize!"); - - dprintk("%s,%d: cesa ocf device id is %d \n", __FILE__, __LINE__, cesa_ocf_id); - - /* CESA unit is auto power on off */ -#if 0 - if (MV_FALSE == mvCtrlPwrClckGet(CESA_UNIT_ID,0)) - { - printk("\nWarning CESA %d is Powered Off\n",0); - return EINVAL; - } -#endif - - memset(&cesa_device, 0, sizeof(struct cesa_dev)); - /* Get the IRQ, and crypto memory regions */ - { - struct resource *res; - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sram"); - - if (!res) - return -ENXIO; - - cesa_device.sram = ioremap(res->start, res->end - res->start + 1); - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); - - if (!res) { - iounmap(cesa_device.sram); - return -ENXIO; - } - cesa_device.reg = ioremap(res->start, res->end - res->start + 1); - cesa_device.irq = platform_get_irq(pdev, 0); - cesa_device.plat_data = pdev->dev.platform_data; - setup_tdma_mbus_windows(&cesa_device); - - } - - - if( MV_OK != mvCesaInit(CESA_OCF_MAX_SES*5, CESA_Q_SIZE, cesa_device.reg, - NULL) ) { - printk("%s,%d: mvCesaInit Failed. \n", __FILE__, __LINE__); - return EINVAL; - } - - /* clear and unmask Int */ - MV_REG_WRITE( MV_CESA_ISR_CAUSE_REG, 0); -#ifndef CESA_OCF_POLLING - MV_REG_WRITE( MV_CESA_ISR_MASK_REG, MV_CESA_CAUSE_ACC_DMA_MASK); -#endif -#ifdef CESA_OCF_TASKLET - tasklet_init(&cesa_ocf_tasklet, cesa_callback, (unsigned int) 0); -#endif - /* register interrupt */ - if( request_irq( cesa_device.irq, cesa_interrupt_handler, - (IRQF_DISABLED) , "cesa", &cesa_ocf_id) < 0) { - printk("%s,%d: cannot assign irq %x\n", __FILE__, __LINE__, cesa_device.reg); - return EINVAL; - } - - - memset(cesa_ocf_sessions, 0, sizeof(struct cesa_ocf_data *) * CESA_OCF_MAX_SES); - -#define REGISTER(alg) \ - crypto_register(cesa_ocf_id, alg, 0,0) - REGISTER(CRYPTO_AES_CBC); - REGISTER(CRYPTO_DES_CBC); - REGISTER(CRYPTO_3DES_CBC); - REGISTER(CRYPTO_MD5); - REGISTER(CRYPTO_MD5_HMAC); - REGISTER(CRYPTO_SHA1); - REGISTER(CRYPTO_SHA1_HMAC); -#undef REGISTER - - return 0; -} - -static void -mv_cesa_ocf_exit(struct platform_device *pdev) -{ - dprintk("%s()\n", __FUNCTION__); - - crypto_unregister_all(cesa_ocf_id); - cesa_ocf_id = -1; - iounmap(cesa_device.reg); - iounmap(cesa_device.sram); - free_irq(cesa_device.irq, NULL); - - /* mask and clear Int */ - MV_REG_WRITE( MV_CESA_ISR_MASK_REG, 0); - MV_REG_WRITE( MV_CESA_ISR_CAUSE_REG, 0); - - - if( MV_OK != mvCesaFinish() ) { - printk("%s,%d: mvCesaFinish Failed. \n", __FILE__, __LINE__); - return; - } -} - - -void cesa_ocf_debug(void) -{ - -#ifdef CESA_OCF_TRACE_DEBUG - { - int i, j; - j = cesaTestTraceIdx; - mvOsPrintf("No Type rCause iCause Proc Isr Res Time pReady pProc pEmpty\n"); - for(i=0; i<MV_CESA_TEST_TRACE_SIZE; i++) - { - mvOsPrintf("%02d. %d 0x%04x 0x%04x 0x%02x 0x%02x %02d 0x%06x %p %p %p\n", - j, cesaTestTrace[j].type, cesaTestTrace[j].realCause, - cesaTestTrace[j].idmaCause, - cesaTestTrace[j].resources, cesaTestTrace[j].timeStamp, - cesaTestTrace[j].pReqReady, cesaTestTrace[j].pReqProcess, cesaTestTrace[j].pReqEmpty); - j++; - if(j == MV_CESA_TEST_TRACE_SIZE) - j = 0; - } - } -#endif - -} - -static struct platform_driver marvell_cesa = { - .probe = mv_cesa_ocf_init, - .remove = mv_cesa_ocf_exit, - .driver = { - .owner = THIS_MODULE, - .name = "mv_crypto", - }, -}; - -MODULE_ALIAS("platform:mv_crypto"); - -static int __init mv_cesa_init(void) -{ - return platform_driver_register(&marvell_cesa); -} - -module_init(mv_cesa_init); - -static void __exit mv_cesa_exit(void) -{ - platform_driver_unregister(&marvell_cesa); -} - -module_exit(mv_cesa_exit); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Ronen Shitrit"); -MODULE_DESCRIPTION("OCF module for Orion CESA crypto"); diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mv802_3.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mv802_3.h deleted file mode 100644 index 3769dde..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mv802_3.h +++ /dev/null @@ -1,213 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -#ifndef __INCmv802_3h -#define __INCmv802_3h - - -/* includes */ -#include "mvTypes.h" - -/* Defines */ -#define MV_MAX_ETH_DATA 1500 - -/* 802.3 types */ -#define MV_IP_TYPE 0x0800 -#define MV_IP_ARP_TYPE 0x0806 -#define MV_APPLE_TALK_ARP_TYPE 0x80F3 -#define MV_NOVELL_IPX_TYPE 0x8137 -#define MV_EAPOL_TYPE 0x888e - - - -/* Encapsulation header for RFC1042 and Ethernet_tunnel */ - -#define MV_RFC1042_SNAP_HEADER {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00} - -#define MV_ETH_SNAP_LSB 0xF8 - - -#define MV_MAC_ADDR_SIZE (6) -#define MV_MAC_STR_SIZE (20) -#define MV_VLAN_HLEN (4) - -/* This macro checks for a multicast mac address */ -#define MV_IS_MULTICAST_MAC(mac) (((mac)[0] & 0x1) == 1) - - -/* This macro checks for an broadcast mac address */ -#define MV_IS_BROADCAST_MAC(mac) \ - (((mac)[0] == 0xFF) && \ - ((mac)[1] == 0xFF) && \ - ((mac)[2] == 0xFF) && \ - ((mac)[3] == 0xFF) && \ - ((mac)[4] == 0xFF) && \ - ((mac)[5] == 0xFF)) - - -/* Typedefs */ -typedef struct -{ - MV_U8 pDA[MV_MAC_ADDR_SIZE]; - MV_U8 pSA[MV_MAC_ADDR_SIZE]; - MV_U16 typeOrLen; - -} MV_802_3_HEADER; - -enum { - MV_IP_PROTO_NULL = 0, /* Dummy protocol for TCP */ - MV_IP_PROTO_ICMP = 1, /* Internet Control Message Protocol */ - MV_IP_PROTO_IGMP = 2, /* Internet Group Management Protocol */ - MV_IP_PROTO_IPIP = 4, /* IPIP tunnels (older KA9Q tunnels use 94) */ - MV_IP_PROTO_TCP = 6, /* Transmission Control Protocol */ - MV_IP_PROTO_EGP = 8, /* Exterior Gateway Protocol */ - MV_IP_PROTO_PUP = 12, /* PUP protocol */ - MV_IP_PROTO_UDP = 17, /* User Datagram Protocol */ - MV_IP_PROTO_IDP = 22, /* XNS IDP protocol */ - MV_IP_PROTO_DCCP = 33, /* Datagram Congestion Control Protocol */ - MV_IP_PROTO_IPV6 = 41, /* IPv6-in-IPv4 tunnelling */ - MV_IP_PROTO_RSVP = 46, /* RSVP protocol */ - MV_IP_PROTO_GRE = 47, /* Cisco GRE tunnels (rfc 1701,1702) */ - MV_IP_PROTO_ESP = 50, /* Encapsulation Security Payload protocol */ - MV_IP_PROTO_AH = 51, /* Authentication Header protocol */ - MV_IP_PROTO_BEETPH = 94, /* IP option pseudo header for BEET */ - MV_IP_PROTO_PIM = 103, - MV_IP_PROTO_COMP = 108, /* Compression Header protocol */ - MV_IP_PROTO_ZERO_HOP = 114, /* Any 0 hop protocol (IANA) */ - MV_IP_PROTO_SCTP = 132, /* Stream Control Transport Protocol */ - MV_IP_PROTO_UDPLITE = 136, /* UDP-Lite (RFC 3828) */ - - MV_IP_PROTO_RAW = 255, /* Raw IP packets */ - MV_IP_PROTO_MAX -}; - -typedef struct -{ - MV_U8 version; - MV_U8 tos; - MV_U16 totalLength; - MV_U16 identifier; - MV_U16 fragmentCtrl; - MV_U8 ttl; - MV_U8 protocol; - MV_U16 checksum; - MV_U32 srcIP; - MV_U32 dstIP; - -} MV_IP_HEADER; - -typedef struct -{ - MV_U32 spi; - MV_U32 seqNum; -} MV_ESP_HEADER; - -#define MV_ICMP_ECHOREPLY 0 /* Echo Reply */ -#define MV_ICMP_DEST_UNREACH 3 /* Destination Unreachable */ -#define MV_ICMP_SOURCE_QUENCH 4 /* Source Quench */ -#define MV_ICMP_REDIRECT 5 /* Redirect (change route) */ -#define MV_ICMP_ECHO 8 /* Echo Request */ -#define MV_ICMP_TIME_EXCEEDED 11 /* Time Exceeded */ -#define MV_ICMP_PARAMETERPROB 12 /* Parameter Problem */ -#define MV_ICMP_TIMESTAMP 13 /* Timestamp Request */ -#define MV_ICMP_TIMESTAMPREPLY 14 /* Timestamp Reply */ -#define MV_ICMP_INFO_REQUEST 15 /* Information Request */ -#define MV_ICMP_INFO_REPLY 16 /* Information Reply */ -#define MV_ICMP_ADDRESS 17 /* Address Mask Request */ -#define MV_ICMP_ADDRESSREPLY 18 /* Address Mask Reply */ - -typedef struct -{ - MV_U8 type; - MV_U8 code; - MV_U16 checksum; - MV_U16 id; - MV_U16 sequence; - -} MV_ICMP_ECHO_HEADER; - -typedef struct -{ - MV_U16 source; - MV_U16 dest; - MV_U32 seq; - MV_U32 ack_seq; - MV_U16 flags; - MV_U16 window; - MV_U16 chksum; - MV_U16 urg_offset; - -} MV_TCP_HEADER; - -typedef struct -{ - MV_U16 source; - MV_U16 dest; - MV_U16 len; - MV_U16 check; - -} MV_UDP_HEADER; - -#endif /* __INCmv802_3h */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mvCommon.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mvCommon.c deleted file mode 100644 index dc0e0cf..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mvCommon.c +++ /dev/null @@ -1,277 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#include "mvOs.h" -#include "mv802_3.h" -#include "mvCommon.h" - - -/******************************************************************************* -* mvMacStrToHex - Convert MAC format string to hex. -* -* DESCRIPTION: -* This function convert MAC format string to hex. -* -* INPUT: -* macStr - MAC address string. Fornat of address string is -* uu:vv:ww:xx:yy:zz, where ":" can be any delimiter. -* -* OUTPUT: -* macHex - MAC in hex format. -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_STATUS mvMacStrToHex(const char* macStr, MV_U8* macHex) -{ - int i; - char tmp[3]; - - for(i = 0; i < MV_MAC_ADDR_SIZE; i++) - { - tmp[0] = macStr[(i * 3) + 0]; - tmp[1] = macStr[(i * 3) + 1]; - tmp[2] = '\0'; - macHex[i] = (MV_U8) (strtol(tmp, NULL, 16)); - } - return MV_OK; -} - -/******************************************************************************* -* mvMacHexToStr - Convert MAC in hex format to string format. -* -* DESCRIPTION: -* This function convert MAC in hex format to string format. -* -* INPUT: -* macHex - MAC in hex format. -* -* OUTPUT: -* macStr - MAC address string. String format is uu:vv:ww:xx:yy:zz. -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_STATUS mvMacHexToStr(MV_U8* macHex, char* macStr) -{ - int i; - - for(i = 0; i < MV_MAC_ADDR_SIZE; i++) - { - mvOsSPrintf(&macStr[i * 3], "%02x:", macHex[i]); - } - macStr[(i * 3) - 1] = '\0'; - - return MV_OK; -} - -/******************************************************************************* -* mvSizePrint - Print the given size with size unit description. -* -* DESCRIPTION: -* This function print the given size with size unit description. -* FOr example when size paramter is 0x180000, the function prints: -* "size 1MB+500KB" -* -* INPUT: -* size - Size in bytes. -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_VOID mvSizePrint(MV_U32 size) -{ - mvOsOutput("size "); - - if(size >= _1G) - { - mvOsOutput("%3dGB ", size / _1G); - size %= _1G; - if(size) - mvOsOutput("+"); - } - if(size >= _1M ) - { - mvOsOutput("%3dMB ", size / _1M); - size %= _1M; - if(size) - mvOsOutput("+"); - } - if(size >= _1K) - { - mvOsOutput("%3dKB ", size / _1K); - size %= _1K; - if(size) - mvOsOutput("+"); - } - if(size > 0) - { - mvOsOutput("%3dB ", size); - } -} - -/******************************************************************************* -* mvHexToBin - Convert hex to binary -* -* DESCRIPTION: -* This function Convert hex to binary. -* -* INPUT: -* pHexStr - hex buffer pointer. -* size - Size to convert. -* -* OUTPUT: -* pBin - Binary buffer pointer. -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_VOID mvHexToBin(const char* pHexStr, MV_U8* pBin, int size) -{ - int j, i; - char tmp[3]; - MV_U8 byte; - - for(j=0, i=0; j<size; j++, i+=2) - { - tmp[0] = pHexStr[i]; - tmp[1] = pHexStr[i+1]; - tmp[2] = '\0'; - byte = (MV_U8) (strtol(tmp, NULL, 16) & 0xFF); - pBin[j] = byte; - } -} - -void mvAsciiToHex(const char* asciiStr, char* hexStr) -{ - int i=0; - - while(asciiStr[i] != 0) - { - mvOsSPrintf(&hexStr[i*2], "%02x", asciiStr[i]); - i++; - } - hexStr[i*2] = 0; -} - - -void mvBinToHex(const MV_U8* bin, char* hexStr, int size) -{ - int i; - - for(i=0; i<size; i++) - { - mvOsSPrintf(&hexStr[i*2], "%02x", bin[i]); - } - hexStr[i*2] = '\0'; -} - -void mvBinToAscii(const MV_U8* bin, char* asciiStr, int size) -{ - int i; - - for(i=0; i<size; i++) - { - mvOsSPrintf(&asciiStr[i*2], "%c", bin[i]); - } - asciiStr[i*2] = '\0'; -} - -/******************************************************************************* -* mvLog2 - -* -* DESCRIPTION: -* Calculate the Log2 of a given number. -* -* INPUT: -* num - A number to calculate the Log2 for. -* -* OUTPUT: -* None. -* -* RETURN: -* Log 2 of the input number, or 0xFFFFFFFF if input is 0. -* -*******************************************************************************/ -MV_U32 mvLog2(MV_U32 num) -{ - MV_U32 result = 0; - if(num == 0) - return 0xFFFFFFFF; - while(num != 1) - { - num = num >> 1; - result++; - } - return result; -} - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mvCommon.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mvCommon.h deleted file mode 100644 index c8e9ce1..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mvCommon.h +++ /dev/null @@ -1,308 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - - -#ifndef __INCmvCommonh -#define __INCmvCommonh - -#include "mvTypes.h" - -/* Swap tool */ - -/* 16bit nibble swap. For example 0x1234 -> 0x2143 */ -#define MV_NIBBLE_SWAP_16BIT(X) (((X&0xf) << 4) | \ - ((X&0xf0) >> 4) | \ - ((X&0xf00) << 4) | \ - ((X&0xf000) >> 4)) - -/* 32bit nibble swap. For example 0x12345678 -> 0x21436587 */ -#define MV_NIBBLE_SWAP_32BIT(X) (((X&0xf) << 4) | \ - ((X&0xf0) >> 4) | \ - ((X&0xf00) << 4) | \ - ((X&0xf000) >> 4) | \ - ((X&0xf0000) << 4) | \ - ((X&0xf00000) >> 4) | \ - ((X&0xf000000) << 4) | \ - ((X&0xf0000000) >> 4)) - -/* 16bit byte swap. For example 0x1122 -> 0x2211 */ -#define MV_BYTE_SWAP_16BIT(X) ((((X)&0xff)<<8) | (((X)&0xff00)>>8)) - -/* 32bit byte swap. For example 0x11223344 -> 0x44332211 */ -#define MV_BYTE_SWAP_32BIT(X) ((((X)&0xff)<<24) | \ - (((X)&0xff00)<<8) | \ - (((X)&0xff0000)>>8) | \ - (((X)&0xff000000)>>24)) - -/* 64bit byte swap. For example 0x11223344.55667788 -> 0x88776655.44332211 */ -#define MV_BYTE_SWAP_64BIT(X) ((l64) ((((X)&0xffULL)<<56) | \ - (((X)&0xff00ULL)<<40) | \ - (((X)&0xff0000ULL)<<24) | \ - (((X)&0xff000000ULL)<<8) | \ - (((X)&0xff00000000ULL)>>8) | \ - (((X)&0xff0000000000ULL)>>24) | \ - (((X)&0xff000000000000ULL)>>40) | \ - (((X)&0xff00000000000000ULL)>>56))) - -/* Endianess macros. */ -#if defined(MV_CPU_LE) - #define MV_16BIT_LE(X) (X) - #define MV_32BIT_LE(X) (X) - #define MV_64BIT_LE(X) (X) - #define MV_16BIT_BE(X) MV_BYTE_SWAP_16BIT(X) - #define MV_32BIT_BE(X) MV_BYTE_SWAP_32BIT(X) - #define MV_64BIT_BE(X) MV_BYTE_SWAP_64BIT(X) -#elif defined(MV_CPU_BE) - #define MV_16BIT_LE(X) MV_BYTE_SWAP_16BIT(X) - #define MV_32BIT_LE(X) MV_BYTE_SWAP_32BIT(X) - #define MV_64BIT_LE(X) MV_BYTE_SWAP_64BIT(X) - #define MV_16BIT_BE(X) (X) - #define MV_32BIT_BE(X) (X) - #define MV_64BIT_BE(X) (X) -#else - #error "CPU endianess isn't defined!\n" -#endif - - -/* Bit field definitions */ -#define NO_BIT 0x00000000 -#define BIT0 0x00000001 -#define BIT1 0x00000002 -#define BIT2 0x00000004 -#define BIT3 0x00000008 -#define BIT4 0x00000010 -#define BIT5 0x00000020 -#define BIT6 0x00000040 -#define BIT7 0x00000080 -#define BIT8 0x00000100 -#define BIT9 0x00000200 -#define BIT10 0x00000400 -#define BIT11 0x00000800 -#define BIT12 0x00001000 -#define BIT13 0x00002000 -#define BIT14 0x00004000 -#define BIT15 0x00008000 -#define BIT16 0x00010000 -#define BIT17 0x00020000 -#define BIT18 0x00040000 -#define BIT19 0x00080000 -#define BIT20 0x00100000 -#define BIT21 0x00200000 -#define BIT22 0x00400000 -#define BIT23 0x00800000 -#define BIT24 0x01000000 -#define BIT25 0x02000000 -#define BIT26 0x04000000 -#define BIT27 0x08000000 -#define BIT28 0x10000000 -#define BIT29 0x20000000 -#define BIT30 0x40000000 -#define BIT31 0x80000000 - -/* Handy sizes */ -#define _1K 0x00000400 -#define _2K 0x00000800 -#define _4K 0x00001000 -#define _8K 0x00002000 -#define _16K 0x00004000 -#define _32K 0x00008000 -#define _64K 0x00010000 -#define _128K 0x00020000 -#define _256K 0x00040000 -#define _512K 0x00080000 - -#define _1M 0x00100000 -#define _2M 0x00200000 -#define _4M 0x00400000 -#define _8M 0x00800000 -#define _16M 0x01000000 -#define _32M 0x02000000 -#define _64M 0x04000000 -#define _128M 0x08000000 -#define _256M 0x10000000 -#define _512M 0x20000000 - -#define _1G 0x40000000 -#define _2G 0x80000000 - -/* Tclock and Sys clock define */ -#define _100MHz 100000000 -#define _125MHz 125000000 -#define _133MHz 133333334 -#define _150MHz 150000000 -#define _160MHz 160000000 -#define _166MHz 166666667 -#define _175MHz 175000000 -#define _178MHz 178000000 -#define _183MHz 183333334 -#define _187MHz 187000000 -#define _192MHz 192000000 -#define _194MHz 194000000 -#define _200MHz 200000000 -#define _233MHz 233333334 -#define _250MHz 250000000 -#define _266MHz 266666667 -#define _300MHz 300000000 - -/* For better address window table readability */ -#define EN MV_TRUE -#define DIS MV_FALSE -#define N_A -1 /* Not applicable */ - -/* Cache configuration options for memory (DRAM, SRAM, ... ) */ - -/* Memory uncached, HW or SW cache coherency is not needed */ -#define MV_UNCACHED 0 -/* Memory cached, HW cache coherency supported in WriteThrough mode */ -#define MV_CACHE_COHER_HW_WT 1 -/* Memory cached, HW cache coherency supported in WriteBack mode */ -#define MV_CACHE_COHER_HW_WB 2 -/* Memory cached, No HW cache coherency, Cache coherency must be in SW */ -#define MV_CACHE_COHER_SW 3 - - -/* Macro for testing aligment. Positive if number is NOT aligned */ -#define MV_IS_NOT_ALIGN(number, align) ((number) & ((align) - 1)) - -/* Macro for alignment up. For example, MV_ALIGN_UP(0x0330, 0x20) = 0x0340 */ -#define MV_ALIGN_UP(number, align) \ -(((number) & ((align) - 1)) ? (((number) + (align)) & ~((align)-1)) : (number)) - -/* Macro for alignment down. For example, MV_ALIGN_UP(0x0330, 0x20) = 0x0320 */ -#define MV_ALIGN_DOWN(number, align) ((number) & ~((align)-1)) - -/* This macro returns absolute value */ -#define MV_ABS(number) (((int)(number) < 0) ? -(int)(number) : (int)(number)) - - -/* Bit fields manipulation macros */ - -/* An integer word which its 'x' bit is set */ -#define MV_BIT_MASK(bitNum) (1 << (bitNum) ) - -/* Checks wheter bit 'x' in integer word is set */ -#define MV_BIT_CHECK(word, bitNum) ( (word) & MV_BIT_MASK(bitNum) ) - -/* Clear (reset) bit 'x' in integer word (RMW - Read-Modify-Write) */ -#define MV_BIT_CLEAR(word, bitNum) ( (word) &= ~(MV_BIT_MASK(bitNum)) ) - -/* Set bit 'x' in integer word (RMW) */ -#define MV_BIT_SET(word, bitNum) ( (word) |= MV_BIT_MASK(bitNum) ) - -/* Invert bit 'x' in integer word (RMW) */ -#define MV_BIT_INV(word, bitNum) ( (word) ^= MV_BIT_MASK(bitNum) ) - -/* Get the min between 'a' or 'b' */ -#define MV_MIN(a,b) (((a) < (b)) ? (a) : (b)) - -/* Get the max between 'a' or 'b' */ -#define MV_MAX(a,b) (((a) < (b)) ? (b) : (a)) - -/* Temporary */ -#define mvOsDivide(num, div) \ -({ \ - int i=0, rem=(num); \ - \ - while(rem >= (div)) \ - { \ - rem -= (div); \ - i++; \ - } \ - (i); \ -}) - -/* Temporary */ -#define mvOsReminder(num, div) \ -({ \ - int rem = (num); \ - \ - while(rem >= (div)) \ - rem -= (div); \ - (rem); \ -}) - -#define MV_IP_QUAD(ipAddr) ((ipAddr >> 24) & 0xFF), ((ipAddr >> 16) & 0xFF), \ - ((ipAddr >> 8) & 0xFF), ((ipAddr >> 0) & 0xFF) - -#define MV_IS_POWER_OF_2(num) ((num != 0) && ((num & (num - 1)) == 0)) - -#ifndef MV_ASMLANGUAGE -/* mvCommon API list */ - -MV_VOID mvHexToBin(const char* pHexStr, MV_U8* pBin, int size); -void mvAsciiToHex(const char* asciiStr, char* hexStr); -void mvBinToHex(const MV_U8* bin, char* hexStr, int size); -void mvBinToAscii(const MV_U8* bin, char* asciiStr, int size); - -MV_STATUS mvMacStrToHex(const char* macStr, MV_U8* macHex); -MV_STATUS mvMacHexToStr(MV_U8* macHex, char* macStr); -void mvSizePrint(MV_U32); - -MV_U32 mvLog2(MV_U32 num); - -#endif /* MV_ASMLANGUAGE */ - - -#endif /* __INCmvCommonh */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mvDebug.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mvDebug.c deleted file mode 100644 index 087f36d..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mvDebug.c +++ /dev/null @@ -1,326 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - - -/* includes */ -#include "mvOs.h" -#include "mv802_3.h" -#include "mvCommon.h" -#include "mvDebug.h" - -/* Global variables effect on behave MV_DEBUG_PRINT and MV_DEBUG_CODE macros - * mvDebug - map of bits (one for each module) bit=1 means enable - * debug code and messages for this module - * mvModuleDebug - array of 32 bits varables one for each module - */ -MV_U32 mvDebug = 0; -MV_U32 mvDebugModules[MV_MODULE_MAX]; - -/* Init mvModuleDebug array to default values */ -void mvDebugInit(void) -{ - int bit; - - mvDebug = 0; - for(bit=0; bit<MV_MODULE_MAX; bit++) - { - mvDebugModules[bit] = MV_DEBUG_FLAG_ERR | MV_DEBUG_FLAG_STATS; - mvDebug |= MV_BIT_MASK(bit); - } -} - -void mvDebugModuleEnable(MV_MODULE_ID module, MV_BOOL isEnable) -{ - if (isEnable) - { - MV_BIT_SET(mvDebug, module); - } - else - MV_BIT_CLEAR(mvDebug, module); -} - -void mvDebugModuleSetFlags(MV_MODULE_ID module, MV_U32 flags) -{ - mvDebugModules[module] |= flags; -} - -void mvDebugModuleClearFlags(MV_MODULE_ID module, MV_U32 flags) -{ - mvDebugModules[module] &= ~flags; -} - -/* Dump memory in specific format: - * address: X1X1X1X1 X2X2X2X2 ... X8X8X8X8 - */ -void mvDebugMemDump(void* addr, int size, int access) -{ - int i, j; - MV_U32 memAddr = (MV_U32)addr; - - if(access == 0) - access = 1; - - if( (access != 4) && (access != 2) && (access != 1) ) - { - mvOsPrintf("%d wrong access size. Access must be 1 or 2 or 4\n", - access); - return; - } - memAddr = MV_ALIGN_DOWN( (unsigned int)addr, 4); - size = MV_ALIGN_UP(size, 4); - addr = (void*)MV_ALIGN_DOWN( (unsigned int)addr, access); - while(size > 0) - { - mvOsPrintf("%08x: ", memAddr); - i = 0; - /* 32 bytes in the line */ - while(i < 32) - { - if(memAddr >= (MV_U32)addr) - { - switch(access) - { - case 1: - if( memAddr == CPU_PHY_MEM(memAddr) ) - { - mvOsPrintf("%02x ", MV_MEMIO8_READ(memAddr)); - } - else - { - mvOsPrintf("%02x ", *((MV_U8*)memAddr)); - } - break; - - case 2: - if( memAddr == CPU_PHY_MEM(memAddr) ) - { - mvOsPrintf("%04x ", MV_MEMIO16_READ(memAddr)); - } - else - { - mvOsPrintf("%04x ", *((MV_U16*)memAddr)); - } - break; - - case 4: - if( memAddr == CPU_PHY_MEM(memAddr) ) - { - mvOsPrintf("%08x ", MV_MEMIO32_READ(memAddr)); - } - else - { - mvOsPrintf("%08x ", *((MV_U32*)memAddr)); - } - break; - } - } - else - { - for(j=0; j<(access*2+1); j++) - mvOsPrintf(" "); - } - i += access; - memAddr += access; - size -= access; - if(size <= 0) - break; - } - mvOsPrintf("\n"); - } -} - -void mvDebugPrintBufInfo(BUF_INFO* pBufInfo, int size, int access) -{ - if(pBufInfo == NULL) - { - mvOsPrintf("\n!!! pBufInfo = NULL\n"); - return; - } - mvOsPrintf("\n*** pBufInfo=0x%x, cmdSts=0x%08x, pBuf=0x%x, bufSize=%d\n", - (unsigned int)pBufInfo, - (unsigned int)pBufInfo->cmdSts, - (unsigned int)pBufInfo->pBuff, - (unsigned int)pBufInfo->bufSize); - mvOsPrintf("pData=0x%x, byteCnt=%d, pNext=0x%x, uInfo1=0x%x, uInfo2=0x%x\n", - (unsigned int)pBufInfo->pData, - (unsigned int)pBufInfo->byteCnt, - (unsigned int)pBufInfo->pNextBufInfo, - (unsigned int)pBufInfo->userInfo1, - (unsigned int)pBufInfo->userInfo2); - if(pBufInfo->pData != NULL) - { - if(size > pBufInfo->byteCnt) - size = pBufInfo->byteCnt; - mvDebugMemDump(pBufInfo->pData, size, access); - } -} - -void mvDebugPrintPktInfo(MV_PKT_INFO* pPktInfo, int size, int access) -{ - int frag, len; - - if(pPktInfo == NULL) - { - mvOsPrintf("\n!!! pPktInfo = NULL\n"); - return; - } - mvOsPrintf("\npPkt=%p, stat=0x%08x, numFr=%d, size=%d, pFr=%p, osInfo=0x%lx\n", - pPktInfo, pPktInfo->status, pPktInfo->numFrags, pPktInfo->pktSize, - pPktInfo->pFrags, pPktInfo->osInfo); - - for(frag=0; frag<pPktInfo->numFrags; frag++) - { - mvOsPrintf("#%2d. bufVirt=%p, bufSize=%d\n", - frag, pPktInfo->pFrags[frag].bufVirtPtr, - pPktInfo->pFrags[frag].bufSize); - if(size > 0) - { - len = MV_MIN((int)pPktInfo->pFrags[frag].bufSize, size); - mvDebugMemDump(pPktInfo->pFrags[frag].bufVirtPtr, len, access); - size -= len; - } - } - -} - -void mvDebugPrintIpAddr(MV_U32 ipAddr) -{ - mvOsPrintf("%d.%d.%d.%d", ((ipAddr >> 24) & 0xFF), ((ipAddr >> 16) & 0xFF), - ((ipAddr >> 8) & 0xFF), ((ipAddr >> 0) & 0xFF)); -} - -void mvDebugPrintMacAddr(const MV_U8* pMacAddr) -{ - int i; - - mvOsPrintf("%02x", (unsigned int)pMacAddr[0]); - for(i=1; i<MV_MAC_ADDR_SIZE; i++) - { - mvOsPrintf(":%02x", pMacAddr[i]); - } - /* mvOsPrintf("\n");*/ -} - - -/******* There are three functions deals with MV_DEBUG_TIMES structure ********/ - -/* Reset MV_DEBUG_TIMES entry */ -void mvDebugResetTimeEntry(MV_DEBUG_TIMES* pTimeEntry, int count, char* pName) -{ - pTimeEntry->begin = 0; - pTimeEntry->count = count; - pTimeEntry->end = 0; - pTimeEntry->left = pTimeEntry->count; - pTimeEntry->total = 0; - pTimeEntry->min = 0xFFFFFFFF; - pTimeEntry->max = 0x0; - strncpy(pTimeEntry->name, pName, sizeof(pTimeEntry->name)-1); - pTimeEntry->name[sizeof(pTimeEntry->name)-1] = '\0'; -} - -/* Print out MV_DEBUG_TIMES entry */ -void mvDebugPrintTimeEntry(MV_DEBUG_TIMES* pTimeEntry, MV_BOOL isTitle) -{ - int num; - - if(isTitle == MV_TRUE) - mvOsPrintf("Event NumOfEvents TotalTime Average Min Max\n"); - - num = pTimeEntry->count-pTimeEntry->left; - if(num > 0) - { - mvOsPrintf("%-11s %6u 0x%08lx %6lu %6lu %6lu\n", - pTimeEntry->name, num, pTimeEntry->total, pTimeEntry->total/num, - pTimeEntry->min, pTimeEntry->max); - } -} - -/* Update MV_DEBUG_TIMES entry */ -void mvDebugUpdateTimeEntry(MV_DEBUG_TIMES* pTimeEntry) -{ - MV_U32 delta; - - if(pTimeEntry->left > 0) - { - if(pTimeEntry->end <= pTimeEntry->begin) - { - delta = pTimeEntry->begin - pTimeEntry->end; - } - else - { - delta = ((MV_U32)0x10000 - pTimeEntry->end) + pTimeEntry->begin; - } - pTimeEntry->total += delta; - - if(delta < pTimeEntry->min) - pTimeEntry->min = delta; - - if(delta > pTimeEntry->max) - pTimeEntry->max = delta; - - pTimeEntry->left--; - } -} - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mvDebug.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mvDebug.h deleted file mode 100644 index e4975be..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mvDebug.h +++ /dev/null @@ -1,178 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - - -#ifndef __INCmvDebugh -#define __INCmvDebugh - -/* includes */ -#include "mvTypes.h" - -typedef enum -{ - MV_MODULE_INVALID = -1, - MV_MODULE_ETH = 0, - MV_MODULE_IDMA, - MV_MODULE_XOR, - MV_MODULE_TWASI, - MV_MODULE_MGI, - MV_MODULE_USB, - MV_MODULE_CESA, - - MV_MODULE_MAX -}MV_MODULE_ID; - -/* Define generic flags useful for most of modules */ -#define MV_DEBUG_FLAG_ALL (0) -#define MV_DEBUG_FLAG_INIT (1 << 0) -#define MV_DEBUG_FLAG_RX (1 << 1) -#define MV_DEBUG_FLAG_TX (1 << 2) -#define MV_DEBUG_FLAG_ERR (1 << 3) -#define MV_DEBUG_FLAG_TRACE (1 << 4) -#define MV_DEBUG_FLAG_DUMP (1 << 5) -#define MV_DEBUG_FLAG_CACHE (1 << 6) -#define MV_DEBUG_FLAG_IOCTL (1 << 7) -#define MV_DEBUG_FLAG_STATS (1 << 8) - -extern MV_U32 mvDebug; -extern MV_U32 mvDebugModules[MV_MODULE_MAX]; - -#ifdef MV_DEBUG -# define MV_DEBUG_PRINT(module, flags, msg) mvOsPrintf msg -# define MV_DEBUG_CODE(module, flags, code) code -#elif defined(MV_RT_DEBUG) -# define MV_DEBUG_PRINT(module, flags, msg) \ - if( (mvDebug & (1<<(module))) && \ - ((mvDebugModules[(module)] & (flags)) == (flags)) ) \ - mvOsPrintf msg -# define MV_DEBUG_CODE(module, flags, code) \ - if( (mvDebug & (1<<(module))) && \ - ((mvDebugModules[(module)] & (flags)) == (flags)) ) \ - code -#else -# define MV_DEBUG_PRINT(module, flags, msg) -# define MV_DEBUG_CODE(module, flags, code) -#endif - - - -/* typedefs */ - -/* time measurement structure used to check how much time pass between - * two points - */ -typedef struct { - char name[20]; /* name of the entry */ - unsigned long begin; /* time measured on begin point */ - unsigned long end; /* time measured on end point */ - unsigned long total; /* Accumulated time */ - unsigned long left; /* The rest measurement actions */ - unsigned long count; /* Maximum measurement actions */ - unsigned long min; /* Minimum time from begin to end */ - unsigned long max; /* Maximum time from begin to end */ -} MV_DEBUG_TIMES; - - -/* mvDebug.h API list */ - -/****** Error Recording ******/ - -/* Dump memory in specific format: - * address: X1X1X1X1 X2X2X2X2 ... X8X8X8X8 - */ -void mvDebugMemDump(void* addr, int size, int access); - -void mvDebugPrintBufInfo(BUF_INFO* pBufInfo, int size, int access); - -void mvDebugPrintPktInfo(MV_PKT_INFO* pPktInfo, int size, int access); - -void mvDebugPrintIpAddr(MV_U32 ipAddr); - -void mvDebugPrintMacAddr(const MV_U8* pMacAddr); - -/**** There are three functions deals with MV_DEBUG_TIMES structure ****/ - -/* Reset MV_DEBUG_TIMES entry */ -void mvDebugResetTimeEntry(MV_DEBUG_TIMES* pTimeEntry, int count, char* name); - -/* Update MV_DEBUG_TIMES entry */ -void mvDebugUpdateTimeEntry(MV_DEBUG_TIMES* pTimeEntry); - -/* Print out MV_DEBUG_TIMES entry */ -void mvDebugPrintTimeEntry(MV_DEBUG_TIMES* pTimeEntry, MV_BOOL isTitle); - - -/******** General ***********/ - -/* Change value of mvDebugPrint global variable */ - -void mvDebugInit(void); -void mvDebugModuleEnable(MV_MODULE_ID module, MV_BOOL isEnable); -void mvDebugModuleSetFlags(MV_MODULE_ID module, MV_U32 flags); -void mvDebugModuleClearFlags(MV_MODULE_ID module, MV_U32 flags); - - -#endif /* __INCmvDebug.h */ - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mvDeviceId.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mvDeviceId.h deleted file mode 100644 index 4782094..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mvDeviceId.h +++ /dev/null @@ -1,225 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCmvDeviceIdh -#define __INCmvDeviceIdh - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* defines */ -#define MARVELL_VEN_ID 0x11ab - -/* Disco-3 */ -#define MV64460_DEV_ID 0x6480 -#define MV64460B_DEV_ID 0x6485 -#define MV64430_DEV_ID 0x6420 - -/* Disco-5 */ -#define MV64560_DEV_ID 0x6450 - -/* Disco-6 */ -#define MV64660_DEV_ID 0x6460 - -/* Orion */ -#define MV_1181_DEV_ID 0x1181 -#define MV_5181_DEV_ID 0x5181 -#define MV_5281_DEV_ID 0x5281 -#define MV_5182_DEV_ID 0x5182 -#define MV_8660_DEV_ID 0x8660 -#define MV_5180_DEV_ID 0x5180 -#define MV_5082_DEV_ID 0x5082 -#define MV_1281_DEV_ID 0x1281 -#define MV_6082_DEV_ID 0x6082 -#define MV_6183_DEV_ID 0x6183 -#define MV_6183L_DEV_ID 0x6083 - -#define MV_5281_D0_REV 0x4 -#define MV_5281_D0_ID ((MV_5281_DEV_ID << 16) | MV_5281_D0_REV) -#define MV_5281_D0_NAME "88F5281 D0" - -#define MV_5281_D1_REV 0x5 -#define MV_5281_D1_ID ((MV_5281_DEV_ID << 16) | MV_5281_D1_REV) -#define MV_5281_D1_NAME "88F5281 D1" - -#define MV_5281_D2_REV 0x6 -#define MV_5281_D2_ID ((MV_5281_DEV_ID << 16) | MV_5281_D2_REV) -#define MV_5281_D2_NAME "88F5281 D2" - - -#define MV_5181L_A0_REV 0x8 /* need for PCIE Er */ -#define MV_5181_A1_REV 0x1 /* for USB Er ..*/ -#define MV_5181_B0_REV 0x2 -#define MV_5181_B1_REV 0x3 -#define MV_5182_A1_REV 0x1 -#define MV_5180N_B1_REV 0x3 -#define MV_5181L_A0_ID ((MV_5181_DEV_ID << 16) | MV_5181L_A0_REV) - - - -/* kw */ -#define MV_6281_DEV_ID 0x6281 -#define MV_6192_DEV_ID 0x6192 -#define MV_6190_DEV_ID 0x6190 -#define MV_6180_DEV_ID 0x6180 - -#define MV_6281_A0_REV 0x2 -#define MV_6281_A0_ID ((MV_6281_DEV_ID << 16) | MV_6281_A0_REV) -#define MV_6281_A0_NAME "88F6281 A0" - -#define MV_6192_A0_REV 0x2 -#define MV_6192_A0_ID ((MV_6192_DEV_ID << 16) | MV_6192_A0_REV) -#define MV_6192_A0_NAME "88F6192 A0" - -#define MV_6190_A0_REV 0x2 -#define MV_6190_A0_ID ((MV_6190_DEV_ID << 16) | MV_6190_A0_REV) -#define MV_6190_A0_NAME "88F6190 A0" - -#define MV_6180_A0_REV 0x2 -#define MV_6180_A0_ID ((MV_6180_DEV_ID << 16) | MV_6180_A0_REV) -#define MV_6180_A0_NAME "88F6180 A0" - -#define MV_6281_A1_REV 0x3 -#define MV_6281_A1_ID ((MV_6281_DEV_ID << 16) | MV_6281_A1_REV) -#define MV_6281_A1_NAME "88F6281 A1" - -#define MV_6192_A1_REV 0x3 -#define MV_6192_A1_ID ((MV_6192_DEV_ID << 16) | MV_6192_A1_REV) -#define MV_6192_A1_NAME "88F6192 A1" - -#define MV_6190_A1_REV 0x3 -#define MV_6190_A1_ID ((MV_6190_DEV_ID << 16) | MV_6190_A1_REV) -#define MV_6190_A1_NAME "88F6190 A1" - -#define MV_6180_A1_REV 0x3 -#define MV_6180_A1_ID ((MV_6180_DEV_ID << 16) | MV_6180_A1_REV) -#define MV_6180_A1_NAME "88F6180 A1" - -#define MV_88F6XXX_A0_REV 0x2 -#define MV_88F6XXX_A1_REV 0x3 -/* Disco-Duo */ -#define MV_78XX0_ZY_DEV_ID 0x6381 -#define MV_78XX0_ZY_NAME "MV78X00" - -#define MV_78XX0_Z0_REV 0x1 -#define MV_78XX0_Z0_ID ((MV_78XX0_ZY_DEV_ID << 16) | MV_78XX0_Z0_REV) -#define MV_78XX0_Z0_NAME "78X00 Z0" - -#define MV_78XX0_Y0_REV 0x2 -#define MV_78XX0_Y0_ID ((MV_78XX0_ZY_DEV_ID << 16) | MV_78XX0_Y0_REV) -#define MV_78XX0_Y0_NAME "78X00 Y0" - -#define MV_78XX0_DEV_ID 0x7800 -#define MV_78XX0_NAME "MV78X00" - -#define MV_76100_DEV_ID 0x7610 -#define MV_78200_DEV_ID 0x7820 -#define MV_78100_DEV_ID 0x7810 -#define MV_78XX0_A0_REV 0x1 -#define MV_78XX0_A1_REV 0x2 - -#define MV_76100_NAME "MV76100" -#define MV_78100_NAME "MV78100" -#define MV_78200_NAME "MV78200" - -#define MV_76100_A0_ID ((MV_76100_DEV_ID << 16) | MV_78XX0_A0_REV) -#define MV_78100_A0_ID ((MV_78100_DEV_ID << 16) | MV_78XX0_A0_REV) -#define MV_78200_A0_ID ((MV_78200_DEV_ID << 16) | MV_78XX0_A0_REV) - -#define MV_76100_A1_ID ((MV_76100_DEV_ID << 16) | MV_78XX0_A1_REV) -#define MV_78100_A1_ID ((MV_78100_DEV_ID << 16) | MV_78XX0_A1_REV) -#define MV_78200_A1_ID ((MV_78200_DEV_ID << 16) | MV_78XX0_A1_REV) - -#define MV_76100_A0_NAME "MV76100 A0" -#define MV_78100_A0_NAME "MV78100 A0" -#define MV_78200_A0_NAME "MV78200 A0" -#define MV_78XX0_A0_NAME "MV78XX0 A0" - -#define MV_76100_A1_NAME "MV76100 A1" -#define MV_78100_A1_NAME "MV78100 A1" -#define MV_78200_A1_NAME "MV78200 A1" -#define MV_78XX0_A1_NAME "MV78XX0 A1" - -/*MV88F632X family*/ -#define MV_6321_DEV_ID 0x6321 -#define MV_6322_DEV_ID 0x6322 -#define MV_6323_DEV_ID 0x6323 - -#define MV_6321_NAME "88F6321" -#define MV_6322_NAME "88F6322" -#define MV_6323_NAME "88F6323" - -#define MV_632X_A1_REV 0x2 - -#define MV_6321_A1_ID ((MV_6321_DEV_ID << 16) | MV_632X_A1_REV) -#define MV_6322_A1_ID ((MV_6322_DEV_ID << 16) | MV_632X_A1_REV) -#define MV_6323_A1_ID ((MV_6323_DEV_ID << 16) | MV_632X_A1_REV) - -#define MV_6321_A1_NAME "88F6321 A1" -#define MV_6322_A1_NAME "88F6322 A1" -#define MV_6323_A1_NAME "88F6323 A1" - - -#endif /* __INCmvDeviceIdh */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mvHalVer.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mvHalVer.h deleted file mode 100644 index 1849198..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mvHalVer.h +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -#ifndef __INCmvHalVerh -#define __INCmvHalVerh - -/* Defines */ -#define MV_HAL_VERSION "FEROCEON_HAL_3_1_7" -#define MV_RELEASE_BASELINE "SoCandControllers_FEROCEON_RELEASE_7_9_2009_KW_4_3_4_DD_2_1_4_6183_1_1_4" - -#endif /* __INCmvHalVerh */
\ No newline at end of file diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mvStack.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mvStack.c deleted file mode 100644 index 41ca7ce..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mvStack.c +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* -* Copyright 2003, Marvell Semiconductor Israel LTD. * -* THIS CODE CONTAINS CONFIDENTIAL INFORMATION OF MARVELL. * -* NO RIGHTS ARE GRANTED HEREIN UNDER ANY PATENT, MASK WORK RIGHT OR COPYRIGHT * -* OF MARVELL OR ANY THIRD PARTY. MARVELL RESERVES THE RIGHT AT ITS SOLE * -* DISCRETION TO REQUEST THAT THIS CODE BE IMMEDIATELY RETURNED TO MARVELL. * -* THIS CODE IS PROVIDED "AS IS". MARVELL MAKES NO WARRANTIES, EXPRESSED, * -* IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, COMPLETENESS OR PERFORMANCE. * -* * -* MARVELL COMPRISES MARVELL TECHNOLOGY GROUP LTD. (MTGL) AND ITS SUBSIDIARIES, * -* MARVELL INTERNATIONAL LTD. (MIL), MARVELL TECHNOLOGY, INC. (MTI), MARVELL * -* SEMICONDUCTOR, INC. (MSI), MARVELL ASIA PTE LTD. (MAPL), MARVELL JAPAN K.K. * -* (MJKK), MARVELL SEMICONDUCTOR ISRAEL LTD (MSIL). * -******************************************************************************** -* mvQueue.c -* -* FILENAME: $Workfile: mvStack.c $ -* REVISION: $Revision: 1.1 $ -* LAST UPDATE: $Modtime: $ -* -* DESCRIPTION: -* This file implements simple Stack LIFO functionality. -*******************************************************************************/ - -/* includes */ -#include "mvOs.h" -#include "mvTypes.h" -#include "mvDebug.h" -#include "mvStack.h" - -/* defines */ - - -/* Public functions */ - - -/* Purpose: Create new stack - * Inputs: - * - MV_U32 noOfElements - maximum number of elements in the stack. - * Each element 4 bytes size - * Return: void* - pointer to created stack. - */ -void* mvStackCreate(int numOfElements) -{ - MV_STACK* pStack; - MV_U32* pStackElements; - - pStack = (MV_STACK*)mvOsMalloc(sizeof(MV_STACK)); - pStackElements = (MV_U32*)mvOsMalloc(numOfElements*sizeof(MV_U32)); - if( (pStack == NULL) || (pStackElements == NULL) ) - { - mvOsPrintf("mvStack: Can't create new stack\n"); - return NULL; - } - memset(pStackElements, 0, numOfElements*sizeof(MV_U32)); - pStack->numOfElements = numOfElements; - pStack->stackIdx = 0; - pStack->stackElements = pStackElements; - - return pStack; -} - -/* Purpose: Delete existing stack - * Inputs: - * - void* stackHndl - Stack handle as returned by "mvStackCreate()" function - * - * Return: MV_STATUS MV_NOT_FOUND - Failure. StackHandle is not valid. - * MV_OK - Success. - */ -MV_STATUS mvStackDelete(void* stackHndl) -{ - MV_STACK* pStack = (MV_STACK*)stackHndl; - - if( (pStack == NULL) || (pStack->stackElements == NULL) ) - return MV_NOT_FOUND; - - mvOsFree(pStack->stackElements); - mvOsFree(pStack); - - return MV_OK; -} - - -/* PrintOut status of the stack */ -void mvStackStatus(void* stackHndl, MV_BOOL isPrintElements) -{ - int i; - MV_STACK* pStack = (MV_STACK*)stackHndl; - - mvOsPrintf("StackHandle=%p, pElements=%p, numElements=%d, stackIdx=%d\n", - stackHndl, pStack->stackElements, pStack->numOfElements, - pStack->stackIdx); - if(isPrintElements == MV_TRUE) - { - for(i=0; i<pStack->stackIdx; i++) - { - mvOsPrintf("%3d. Value=0x%x\n", i, pStack->stackElements[i]); - } - } -} diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mvStack.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mvStack.h deleted file mode 100644 index e247e61..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mvStack.h +++ /dev/null @@ -1,140 +0,0 @@ -/******************************************************************************* -* Copyright 2003, Marvell Semiconductor Israel LTD. * -* THIS CODE CONTAINS CONFIDENTIAL INFORMATION OF MARVELL. * -* NO RIGHTS ARE GRANTED HEREIN UNDER ANY PATENT, MASK WORK RIGHT OR COPYRIGHT * -* OF MARVELL OR ANY THIRD PARTY. MARVELL RESERVES THE RIGHT AT ITS SOLE * -* DISCRETION TO REQUEST THAT THIS CODE BE IMMEDIATELY RETURNED TO MARVELL. * -* THIS CODE IS PROVIDED "AS IS". MARVELL MAKES NO WARRANTIES, EXPRESSED, * -* IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, COMPLETENESS OR PERFORMANCE. * -* * -* MARVELL COMPRISES MARVELL TECHNOLOGY GROUP LTD. (MTGL) AND ITS SUBSIDIARIES, * -* MARVELL INTERNATIONAL LTD. (MIL), MARVELL TECHNOLOGY, INC. (MTI), MARVELL * -* SEMICONDUCTOR, INC. (MSI), MARVELL ASIA PTE LTD. (MAPL), MARVELL JAPAN K.K. * -* (MJKK), MARVELL SEMICONDUCTOR ISRAEL LTD (MSIL). * -******************************************************************************** -* mvStack.h - Header File for : -* -* FILENAME: $Workfile: mvStack.h $ -* REVISION: $Revision: 1.1 $ -* LAST UPDATE: $Modtime: $ -* -* DESCRIPTION: -* This file defines simple Stack (LIFO) functionality. -* -*******************************************************************************/ - -#ifndef __mvStack_h__ -#define __mvStack_h__ - - -/* includes */ -#include "mvTypes.h" - - -/* defines */ - - -/* typedefs */ -/* Data structure describes general purpose Stack */ -typedef struct -{ - int stackIdx; - int numOfElements; - MV_U32* stackElements; -} MV_STACK; - -static INLINE MV_BOOL mvStackIsFull(void* stackHndl) -{ - MV_STACK* pStack = (MV_STACK*)stackHndl; - - if(pStack->stackIdx == pStack->numOfElements) - return MV_TRUE; - - return MV_FALSE; -} - -static INLINE MV_BOOL mvStackIsEmpty(void* stackHndl) -{ - MV_STACK* pStack = (MV_STACK*)stackHndl; - - if(pStack->stackIdx == 0) - return MV_TRUE; - - return MV_FALSE; -} -/* Purpose: Push new element to stack - * Inputs: - * - void* stackHndl - Stack handle as returned by "mvStackCreate()" function. - * - MV_U32 value - New element. - * - * Return: MV_STATUS MV_FULL - Failure. Stack is full. - * MV_OK - Success. Element is put to stack. - */ -static INLINE void mvStackPush(void* stackHndl, MV_U32 value) -{ - MV_STACK* pStack = (MV_STACK*)stackHndl; - -#ifdef MV_RT_DEBUG - if(pStack->stackIdx == pStack->numOfElements) - { - mvOsPrintf("mvStackPush: Stack is FULL\n"); - return; - } -#endif /* MV_RT_DEBUG */ - - pStack->stackElements[pStack->stackIdx] = value; - pStack->stackIdx++; -} - -/* Purpose: Pop element from the top of stack and copy it to "pValue" - * Inputs: - * - void* stackHndl - Stack handle as returned by "mvStackCreate()" function. - * - MV_U32 value - Element in the top of stack. - * - * Return: MV_STATUS MV_EMPTY - Failure. Stack is empty. - * MV_OK - Success. Element is removed from the stack and - * copied to pValue argument - */ -static INLINE MV_U32 mvStackPop(void* stackHndl) -{ - MV_STACK* pStack = (MV_STACK*)stackHndl; - -#ifdef MV_RT_DEBUG - if(pStack->stackIdx == 0) - { - mvOsPrintf("mvStackPop: Stack is EMPTY\n"); - return 0; - } -#endif /* MV_RT_DEBUG */ - - pStack->stackIdx--; - return pStack->stackElements[pStack->stackIdx]; -} - -static INLINE int mvStackIndex(void* stackHndl) -{ - MV_STACK* pStack = (MV_STACK*)stackHndl; - - return pStack->stackIdx; -} - -static INLINE int mvStackFreeElements(void* stackHndl) -{ - MV_STACK* pStack = (MV_STACK*)stackHndl; - - return (pStack->numOfElements - pStack->stackIdx); -} - -/* mvStack.h API list */ - -/* Create new Stack */ -void* mvStackCreate(int numOfElements); - -/* Delete existing stack */ -MV_STATUS mvStackDelete(void* stackHndl); - -/* Print status of the stack */ -void mvStackStatus(void* stackHndl, MV_BOOL isPrintElements); - -#endif /* __mvStack_h__ */ - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mvTypes.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mvTypes.h deleted file mode 100644 index de212a1..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/common/mvTypes.h +++ /dev/null @@ -1,245 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -#ifndef __INCmvTypesh -#define __INCmvTypesh - -/* Defines */ - -/* The following is a list of Marvell status */ -#define MV_ERROR (-1) -#define MV_OK (0x00) /* Operation succeeded */ -#define MV_FAIL (0x01) /* Operation failed */ -#define MV_BAD_VALUE (0x02) /* Illegal value (general) */ -#define MV_OUT_OF_RANGE (0x03) /* The value is out of range */ -#define MV_BAD_PARAM (0x04) /* Illegal parameter in function called */ -#define MV_BAD_PTR (0x05) /* Illegal pointer value */ -#define MV_BAD_SIZE (0x06) /* Illegal size */ -#define MV_BAD_STATE (0x07) /* Illegal state of state machine */ -#define MV_SET_ERROR (0x08) /* Set operation failed */ -#define MV_GET_ERROR (0x09) /* Get operation failed */ -#define MV_CREATE_ERROR (0x0A) /* Fail while creating an item */ -#define MV_NOT_FOUND (0x0B) /* Item not found */ -#define MV_NO_MORE (0x0C) /* No more items found */ -#define MV_NO_SUCH (0x0D) /* No such item */ -#define MV_TIMEOUT (0x0E) /* Time Out */ -#define MV_NO_CHANGE (0x0F) /* Parameter(s) is already in this value */ -#define MV_NOT_SUPPORTED (0x10) /* This request is not support */ -#define MV_NOT_IMPLEMENTED (0x11) /* Request supported but not implemented */ -#define MV_NOT_INITIALIZED (0x12) /* The item is not initialized */ -#define MV_NO_RESOURCE (0x13) /* Resource not available (memory ...) */ -#define MV_FULL (0x14) /* Item is full (Queue or table etc...) */ -#define MV_EMPTY (0x15) /* Item is empty (Queue or table etc...) */ -#define MV_INIT_ERROR (0x16) /* Error occured while INIT process */ -#define MV_HW_ERROR (0x17) /* Hardware error */ -#define MV_TX_ERROR (0x18) /* Transmit operation not succeeded */ -#define MV_RX_ERROR (0x19) /* Recieve operation not succeeded */ -#define MV_NOT_READY (0x1A) /* The other side is not ready yet */ -#define MV_ALREADY_EXIST (0x1B) /* Tried to create existing item */ -#define MV_OUT_OF_CPU_MEM (0x1C) /* Cpu memory allocation failed. */ -#define MV_NOT_STARTED (0x1D) /* Not started yet */ -#define MV_BUSY (0x1E) /* Item is busy. */ -#define MV_TERMINATE (0x1F) /* Item terminates it's work. */ -#define MV_NOT_ALIGNED (0x20) /* Wrong alignment */ -#define MV_NOT_ALLOWED (0x21) /* Operation NOT allowed */ -#define MV_WRITE_PROTECT (0x22) /* Write protected */ - - -#define MV_INVALID (int)(-1) - -#define MV_FALSE 0 -#define MV_TRUE (!(MV_FALSE)) - - -#ifndef NULL -#define NULL ((void*)0) -#endif - - -#ifndef MV_ASMLANGUAGE -/* typedefs */ - -typedef char MV_8; -typedef unsigned char MV_U8; - -typedef int MV_32; -typedef unsigned int MV_U32; - -typedef short MV_16; -typedef unsigned short MV_U16; - -#ifdef MV_PPC64 -typedef long MV_64; -typedef unsigned long MV_U64; -#else -typedef long long MV_64; -typedef unsigned long long MV_U64; -#endif - -typedef long MV_LONG; /* 32/64 */ -typedef unsigned long MV_ULONG; /* 32/64 */ - -typedef int MV_STATUS; -typedef int MV_BOOL; -typedef void MV_VOID; -typedef float MV_FLOAT; - -typedef int (*MV_FUNCPTR) (void); /* ptr to function returning int */ -typedef void (*MV_VOIDFUNCPTR) (void); /* ptr to function returning void */ -typedef double (*MV_DBLFUNCPTR) (void); /* ptr to function returning double*/ -typedef float (*MV_FLTFUNCPTR) (void); /* ptr to function returning float */ - -typedef MV_U32 MV_KHZ; -typedef MV_U32 MV_MHZ; -typedef MV_U32 MV_HZ; - - -/* This enumerator describes the set of commands that can be applied on */ -/* an engine (e.g. IDMA, XOR). Appling a comman depends on the current */ -/* status (see MV_STATE enumerator) */ -/* Start can be applied only when status is IDLE */ -/* Stop can be applied only when status is IDLE, ACTIVE or PAUSED */ -/* Pause can be applied only when status is ACTIVE */ -/* Restart can be applied only when status is PAUSED */ -typedef enum _mvCommand -{ - MV_START, /* Start */ - MV_STOP, /* Stop */ - MV_PAUSE, /* Pause */ - MV_RESTART /* Restart */ -} MV_COMMAND; - -/* This enumerator describes the set of state conditions. */ -/* Moving from one state to other is stricted. */ -typedef enum _mvState -{ - MV_IDLE, - MV_ACTIVE, - MV_PAUSED, - MV_UNDEFINED_STATE -} MV_STATE; - - -/* This structure describes address space window. Window base can be */ -/* 64 bit, window size up to 4GB */ -typedef struct _mvAddrWin -{ - MV_U32 baseLow; /* 32bit base low */ - MV_U32 baseHigh; /* 32bit base high */ - MV_U32 size; /* 32bit size */ -}MV_ADDR_WIN; - -/* This binary enumerator describes protection attribute status */ -typedef enum _mvProtRight -{ - ALLOWED, /* Protection attribute allowed */ - FORBIDDEN /* Protection attribute forbidden */ -}MV_PROT_RIGHT; - -/* Unified struct for Rx and Tx packet operations. The user is required to */ -/* be familier only with Tx/Rx descriptor command status. */ -typedef struct _bufInfo -{ - MV_U32 cmdSts; /* Tx/Rx command status */ - MV_U16 byteCnt; /* Size of valid data in the buffer */ - MV_U16 bufSize; /* Total size of the buffer */ - MV_U8 *pBuff; /* Pointer to Buffer */ - MV_U8 *pData; /* Pointer to data in the Buffer */ - MV_U32 userInfo1; /* Tx/Rx attached user information 1 */ - MV_U32 userInfo2; /* Tx/Rx attached user information 2 */ - struct _bufInfo *pNextBufInfo; /* Next buffer in packet */ -} BUF_INFO; - -/* This structure contains information describing one of buffers - * (fragments) they are built Ethernet packet. - */ -typedef struct -{ - MV_U8* bufVirtPtr; - MV_ULONG bufPhysAddr; - MV_U32 bufSize; - MV_U32 dataSize; - MV_U32 memHandle; - MV_32 bufAddrShift; -} MV_BUF_INFO; - -/* This structure contains information describing Ethernet packet. - * The packet can be divided for few buffers (fragments) - */ -typedef struct -{ - MV_ULONG osInfo; - MV_BUF_INFO *pFrags; - MV_U32 status; - MV_U16 pktSize; - MV_U16 numFrags; - MV_U32 ownerId; - MV_U32 fragIP; -} MV_PKT_INFO; - -#endif /* MV_ASMLANGUAGE */ - -#endif /* __INCmvTypesh */ - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/dbg-trace.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/dbg-trace.c deleted file mode 100644 index 644fd02..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/dbg-trace.c +++ /dev/null @@ -1,110 +0,0 @@ -#include <linux/kernel.h> -#include <linux/slab.h> -#include <linux/time.h> -#include "dbg-trace.h" - -#define TRACE_ARR_LEN 800 -#define STR_LEN 128 -struct trace { - struct timeval tv; - char str[STR_LEN]; - unsigned int callback_val1; - unsigned int callback_val2; - char valid; -}; -static unsigned int (*trc_callback1) (unsigned char) = NULL; -static unsigned int (*trc_callback2) (unsigned char) = NULL; -static unsigned char trc_param1 = 0; -static unsigned char trc_param2 = 0; -struct trace *trc_arr; -static int trc_index; -static int trc_active = 0; - -void TRC_START() -{ - trc_active = 1; -} - -void TRC_STOP() -{ - trc_active = 0; -} - -void TRC_INIT(void *callback1, void *callback2, unsigned char callback1_param, unsigned char callback2_param) -{ - printk("Marvell debug tracing is on\n"); - trc_arr = (struct trace *)kmalloc(TRACE_ARR_LEN*sizeof(struct trace),GFP_KERNEL); - if(trc_arr == NULL) - { - printk("Can't allocate Debug Trace buffer\n"); - return; - } - memset(trc_arr,0,TRACE_ARR_LEN*sizeof(struct trace)); - trc_index = 0; - trc_callback1 = callback1; - trc_callback2 = callback2; - trc_param1 = callback1_param; - trc_param2 = callback2_param; -} -void TRC_REC(char *fmt,...) -{ - va_list args; - struct trace *trc = &trc_arr[trc_index]; - - if(trc_active == 0) - return; - - do_gettimeofday(&trc->tv); - if(trc_callback1) - trc->callback_val1 = trc_callback1(trc_param1); - if(trc_callback2) - trc->callback_val2 = trc_callback2(trc_param2); - va_start(args, fmt); - vsprintf(trc->str,fmt,args); - va_end(args); - trc->valid = 1; - if((++trc_index) == TRACE_ARR_LEN) { - trc_index = 0; - } -} -void TRC_OUTPUT(void) -{ - int i,j; - struct trace *p; - printk("\n\nTrace %d items\n",TRACE_ARR_LEN); - for(i=0,j=trc_index; i<TRACE_ARR_LEN; i++,j++) { - if(j == TRACE_ARR_LEN) - j = 0; - p = &trc_arr[j]; - if(p->valid) { - unsigned long uoffs; - struct trace *plast; - if(p == &trc_arr[0]) - plast = &trc_arr[TRACE_ARR_LEN-1]; - else - plast = p-1; - if(p->tv.tv_sec == ((plast)->tv.tv_sec)) - uoffs = (p->tv.tv_usec - ((plast)->tv.tv_usec)); - else - uoffs = (1000000 - ((plast)->tv.tv_usec)) + - ((p->tv.tv_sec - ((plast)->tv.tv_sec) - 1) * 1000000) + - p->tv.tv_usec; - printk("%03d: [+%ld usec]", j, (unsigned long)uoffs); - if(trc_callback1) - printk("[%u]",p->callback_val1); - if(trc_callback2) - printk("[%u]",p->callback_val2); - printk(": %s",p->str); - } - p->valid = 0; - } - memset(trc_arr,0,TRACE_ARR_LEN*sizeof(struct trace)); - trc_index = 0; -} -void TRC_RELEASE(void) -{ - kfree(trc_arr); - trc_index = 0; -} - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/dbg-trace.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/dbg-trace.h deleted file mode 100644 index a5aac26..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/dbg-trace.h +++ /dev/null @@ -1,24 +0,0 @@ - -#ifndef _MV_DBG_TRCE_H_ -#define _MV_DBG_TRCE_H_ - -#ifdef CONFIG_MV_DBG_TRACE -void TRC_INIT(void *callback1, void *callback2, - unsigned char callback1_param, unsigned char callback2_param); -void TRC_REC(char *fmt,...); -void TRC_OUTPUT(void); -void TRC_RELEASE(void); -void TRC_START(void); -void TRC_STOP(void); - -#else -#define TRC_INIT(x1,x2,x3,x4) -#define TRC_REC(X...) -#define TRC_OUTPUT() -#define TRC_RELEASE() -#define TRC_START() -#define TRC_STOP() -#endif - - -#endif diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/boardEnv/mvBoardEnvLib.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/boardEnv/mvBoardEnvLib.c deleted file mode 100644 index 5f62784..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/boardEnv/mvBoardEnvLib.c +++ /dev/null @@ -1,2513 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#include "boardEnv/mvBoardEnvLib.h" -#include "ctrlEnv/mvCtrlEnvLib.h" -#include "ctrlEnv/sys/mvCpuIf.h" -#include "cpu/mvCpu.h" -#include "cntmr/mvCntmr.h" -#include "gpp/mvGpp.h" -#include "twsi/mvTwsi.h" -#include "pex/mvPex.h" -#include "device/mvDevice.h" -#include "eth/gbe/mvEthRegs.h" - -/* defines */ -/* #define MV_DEBUG */ -#ifdef MV_DEBUG - #define DB(x) x -#else - #define DB(x) -#endif - -extern MV_CPU_ARM_CLK _cpuARMDDRCLK[]; - -#define CODE_IN_ROM MV_FALSE -#define CODE_IN_RAM MV_TRUE - -extern MV_BOARD_INFO* boardInfoTbl[]; -#define BOARD_INFO(boardId) boardInfoTbl[boardId - BOARD_ID_BASE] - -/* Locals */ -static MV_DEV_CS_INFO* boardGetDevEntry(MV_32 devNum, MV_BOARD_DEV_CLASS devClass); - -MV_U32 tClkRate = -1; - - -/******************************************************************************* -* mvBoardEnvInit - Init board -* -* DESCRIPTION: -* In this function the board environment take care of device bank -* initialization. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_VOID mvBoardEnvInit(MV_VOID) -{ - MV_U32 boardId= mvBoardIdGet(); - - if (!((boardId >= BOARD_ID_BASE)&&(boardId < MV_MAX_BOARD_ID))) - { - mvOsPrintf("mvBoardEnvInit:Board unknown.\n"); - return; - - } - - /* Set GPP Out value */ - MV_REG_WRITE(GPP_DATA_OUT_REG(0), BOARD_INFO(boardId)->gppOutValLow); - MV_REG_WRITE(GPP_DATA_OUT_REG(1), BOARD_INFO(boardId)->gppOutValHigh); - - /* set GPP polarity */ - mvGppPolaritySet(0, 0xFFFFFFFF, BOARD_INFO(boardId)->gppPolarityValLow); - mvGppPolaritySet(1, 0xFFFFFFFF, BOARD_INFO(boardId)->gppPolarityValHigh); - - /* Workaround for Erratum FE-MISC-70*/ - if(mvCtrlRevGet()==MV_88F6XXX_A0_REV) - { - BOARD_INFO(boardId)->gppOutEnValLow &= 0xfffffffd; - BOARD_INFO(boardId)->gppOutEnValLow |= (BOARD_INFO(boardId)->gppOutEnValHigh) & 0x00000002; - } /*End of WA*/ - - /* Set GPP Out Enable*/ - mvGppTypeSet(0, 0xFFFFFFFF, BOARD_INFO(boardId)->gppOutEnValLow); - mvGppTypeSet(1, 0xFFFFFFFF, BOARD_INFO(boardId)->gppOutEnValHigh); - - /* Nand CE */ - MV_REG_BIT_SET(NAND_CTRL_REG, NAND_ACTCEBOOT_BIT); -} - -/******************************************************************************* -* mvBoardModelGet - Get Board model -* -* DESCRIPTION: -* This function returns 16bit describing board model. -* Board model is constructed of one byte major and minor numbers in the -* following manner: -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* String describing board model. -* -*******************************************************************************/ -MV_U16 mvBoardModelGet(MV_VOID) -{ - return (mvBoardIdGet() >> 16); -} - -/******************************************************************************* -* mbBoardRevlGet - Get Board revision -* -* DESCRIPTION: -* This function returns a 32bit describing the board revision. -* Board revision is constructed of 4bytes. 2bytes describes major number -* and the other 2bytes describes minor munber. -* For example for board revision 3.4 the function will return -* 0x00030004. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* String describing board model. -* -*******************************************************************************/ -MV_U16 mvBoardRevGet(MV_VOID) -{ - return (mvBoardIdGet() & 0xFFFF); -} - -/******************************************************************************* -* mvBoardNameGet - Get Board name -* -* DESCRIPTION: -* This function returns a string describing the board model and revision. -* String is extracted from board I2C EEPROM. -* -* INPUT: -* None. -* -* OUTPUT: -* pNameBuff - Buffer to contain board name string. Minimum size 32 chars. -* -* RETURN: -* -* MV_ERROR if informantion can not be read. -*******************************************************************************/ -MV_STATUS mvBoardNameGet(char *pNameBuff) -{ - MV_U32 boardId= mvBoardIdGet(); - - if (!((boardId >= BOARD_ID_BASE)&&(boardId < MV_MAX_BOARD_ID))) - { - mvOsSPrintf (pNameBuff, "Board unknown.\n"); - return MV_ERROR; - - } - - mvOsSPrintf (pNameBuff, "%s",BOARD_INFO(boardId)->boardName); - - return MV_OK; -} - -/******************************************************************************* -* mvBoardIsPortInSgmii - -* -* DESCRIPTION: -* This routine returns MV_TRUE for port number works in SGMII or MV_FALSE -* For all other options. -* -* INPUT: -* ethPortNum - Ethernet port number. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_TRUE - port in SGMII. -* MV_FALSE - other. -* -*******************************************************************************/ -MV_BOOL mvBoardIsPortInSgmii(MV_U32 ethPortNum) -{ - MV_BOOL ethPortSgmiiSupport[BOARD_ETH_PORT_NUM] = MV_ETH_PORT_SGMII; - - if(ethPortNum >= BOARD_ETH_PORT_NUM) - { - mvOsPrintf ("Invalid portNo=%d\n", ethPortNum); - return MV_FALSE; - } - return ethPortSgmiiSupport[ethPortNum]; -} - -/******************************************************************************* -* mvBoardIsPortInGmii - -* -* DESCRIPTION: -* This routine returns MV_TRUE for port number works in GMII or MV_FALSE -* For all other options. -* -* INPUT: -* -* OUTPUT: -* None. -* -* RETURN: -* MV_TRUE - port in GMII. -* MV_FALSE - other. -* -*******************************************************************************/ -MV_BOOL mvBoardIsPortInGmii(MV_VOID) -{ - MV_U32 devClassId, devClass = 0; - if (mvBoardMppGroupTypeGet(devClass) == MV_BOARD_AUTO) - { - /* Get MPP module ID */ - devClassId = mvBoarModuleTypeGet(devClass); - if (MV_BOARD_MODULE_GMII_ID == devClassId) - return MV_TRUE; - } - else if (mvBoardMppGroupTypeGet(devClass) == MV_BOARD_GMII) - return MV_TRUE; - - return MV_FALSE; -} -/******************************************************************************* -* mvBoardPhyAddrGet - Get the phy address -* -* DESCRIPTION: -* This routine returns the Phy address of a given ethernet port. -* -* INPUT: -* ethPortNum - Ethernet port number. -* -* OUTPUT: -* None. -* -* RETURN: -* 32bit describing Phy address, -1 if the port number is wrong. -* -*******************************************************************************/ -MV_32 mvBoardPhyAddrGet(MV_U32 ethPortNum) -{ - MV_U32 boardId= mvBoardIdGet(); - - if (!((boardId >= BOARD_ID_BASE)&&(boardId < MV_MAX_BOARD_ID))) - { - mvOsPrintf("mvBoardPhyAddrGet: Board unknown.\n"); - return MV_ERROR; - } - - return BOARD_INFO(boardId)->pBoardMacInfo[ethPortNum].boardEthSmiAddr; -} - -/******************************************************************************* -* mvBoardMacSpeedGet - Get the Mac speed -* -* DESCRIPTION: -* This routine returns the Mac speed if pre define of a given ethernet port. -* -* INPUT: -* ethPortNum - Ethernet port number. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BOARD_MAC_SPEED, -1 if the port number is wrong. -* -*******************************************************************************/ -MV_BOARD_MAC_SPEED mvBoardMacSpeedGet(MV_U32 ethPortNum) -{ - MV_U32 boardId= mvBoardIdGet(); - - if (!((boardId >= BOARD_ID_BASE)&&(boardId < MV_MAX_BOARD_ID))) - { - mvOsPrintf("mvBoardMacSpeedGet: Board unknown.\n"); - return MV_ERROR; - } - - return BOARD_INFO(boardId)->pBoardMacInfo[ethPortNum].boardMacSpeed; -} - -/******************************************************************************* -* mvBoardLinkStatusIrqGet - Get the IRQ number for the link status indication -* -* DESCRIPTION: -* This routine returns the IRQ number for the link status indication. -* -* INPUT: -* ethPortNum - Ethernet port number. -* -* OUTPUT: -* None. -* -* RETURN: -* the number of the IRQ for the link status indication, -1 if the port -* number is wrong or if not relevant. -* -*******************************************************************************/ -MV_32 mvBoardLinkStatusIrqGet(MV_U32 ethPortNum) -{ - MV_U32 boardId = mvBoardIdGet(); - - if (!((boardId >= BOARD_ID_BASE)&&(boardId < MV_MAX_BOARD_ID))) - { - mvOsPrintf("mvBoardLinkStatusIrqGet: Board unknown.\n"); - return MV_ERROR; - } - - return BOARD_INFO(boardId)->pSwitchInfo[ethPortNum].linkStatusIrq; -} - -/******************************************************************************* -* mvBoardSwitchPortGet - Get the mapping between the board connector and the -* Ethernet Switch port -* -* DESCRIPTION: -* This routine returns the matching Switch port. -* -* INPUT: -* ethPortNum - Ethernet port number. -* boardPortNum - logical number of the connector on the board -* -* OUTPUT: -* None. -* -* RETURN: -* the matching Switch port, -1 if the port number is wrong or if not relevant. -* -*******************************************************************************/ -MV_32 mvBoardSwitchPortGet(MV_U32 ethPortNum, MV_U8 boardPortNum) -{ - MV_U32 boardId = mvBoardIdGet(); - - if (!((boardId >= BOARD_ID_BASE)&&(boardId < MV_MAX_BOARD_ID))) - { - mvOsPrintf("mvBoardSwitchPortGet: Board unknown.\n"); - return MV_ERROR; - } - if (boardPortNum >= BOARD_ETH_SWITCH_PORT_NUM) - { - mvOsPrintf("mvBoardSwitchPortGet: Illegal board port number.\n"); - return MV_ERROR; - } - - return BOARD_INFO(boardId)->pSwitchInfo[ethPortNum].qdPort[boardPortNum]; -} - -/******************************************************************************* -* mvBoardSwitchCpuPortGet - Get the the Ethernet Switch CPU port -* -* DESCRIPTION: -* This routine returns the Switch CPU port. -* -* INPUT: -* ethPortNum - Ethernet port number. -* -* OUTPUT: -* None. -* -* RETURN: -* the Switch CPU port, -1 if the port number is wrong or if not relevant. -* -*******************************************************************************/ -MV_32 mvBoardSwitchCpuPortGet(MV_U32 ethPortNum) -{ - MV_U32 boardId = mvBoardIdGet(); - - if (!((boardId >= BOARD_ID_BASE)&&(boardId < MV_MAX_BOARD_ID))) - { - mvOsPrintf("mvBoardSwitchCpuPortGet: Board unknown.\n"); - return MV_ERROR; - } - - return BOARD_INFO(boardId)->pSwitchInfo[ethPortNum].qdCpuPort; -} - -/******************************************************************************* -* mvBoardIsSwitchConnected - Get switch connection status -* DESCRIPTION: -* This routine returns port's connection status -* -* INPUT: -* ethPortNum - Ethernet port number. -* -* OUTPUT: -* None. -* -* RETURN: -* 1 - if ethPortNum is connected to switch, 0 otherwise -* -*******************************************************************************/ -MV_32 mvBoardIsSwitchConnected(MV_U32 ethPortNum) -{ - MV_U32 boardId = mvBoardIdGet(); - - if (!((boardId >= BOARD_ID_BASE)&&(boardId < MV_MAX_BOARD_ID))) - { - mvOsPrintf("mvBoardIsSwitchConnected: Board unknown.\n"); - return MV_ERROR; - } - - if(ethPortNum >= BOARD_INFO(boardId)->numBoardMacInfo) - { - mvOsPrintf("mvBoardIsSwitchConnected: Illegal port number(%u)\n", ethPortNum); - return MV_ERROR; - } - - if((MV_32)(BOARD_INFO(boardId)->pSwitchInfo)) - return (MV_32)(BOARD_INFO(boardId)->pSwitchInfo[ethPortNum].switchOnPort == ethPortNum); - else - return 0; -} -/******************************************************************************* -* mvBoardSmiScanModeGet - Get Switch SMI scan mode -* -* DESCRIPTION: -* This routine returns Switch SMI scan mode. -* -* INPUT: -* ethPortNum - Ethernet port number. -* -* OUTPUT: -* None. -* -* RETURN: -* 1 for SMI_MANUAL_MODE, -1 if the port number is wrong or if not relevant. -* -*******************************************************************************/ -MV_32 mvBoardSmiScanModeGet(MV_U32 ethPortNum) -{ - MV_U32 boardId = mvBoardIdGet(); - - if (!((boardId >= BOARD_ID_BASE)&&(boardId < MV_MAX_BOARD_ID))) - { - mvOsPrintf("mvBoardSmiScanModeGet: Board unknown.\n"); - return MV_ERROR; - } - - return BOARD_INFO(boardId)->pSwitchInfo[ethPortNum].smiScanMode; -} -/******************************************************************************* -* mvBoardSpecInitGet - -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* None. -* -* RETURN: Return MV_TRUE and parameters in case board need spesific phy init, -* otherwise return MV_FALSE. -* -* -*******************************************************************************/ - -MV_BOOL mvBoardSpecInitGet(MV_U32* regOff, MV_U32* data) -{ - return MV_FALSE; -} - -/******************************************************************************* -* mvBoardTclkGet - Get the board Tclk (Controller clock) -* -* DESCRIPTION: -* This routine extract the controller core clock. -* This function uses the controller counters to make identification. -* Note: In order to avoid interference, make sure task context switch -* and interrupts will not occure during this function operation -* -* INPUT: -* countNum - Counter number. -* -* OUTPUT: -* None. -* -* RETURN: -* 32bit clock cycles in Hertz. -* -*******************************************************************************/ -MV_U32 mvBoardTclkGet(MV_VOID) -{ - if(mvCtrlModelGet()==MV_6281_DEV_ID) - { -#if defined(TCLK_AUTO_DETECT) - MV_U32 tmpTClkRate = MV_BOARD_TCLK_166MHZ; - - tmpTClkRate = MV_REG_READ(MPP_SAMPLE_AT_RESET); - tmpTClkRate &= MSAR_TCLCK_MASK; - - switch (tmpTClkRate) - { - case MSAR_TCLCK_166: - return MV_BOARD_TCLK_166MHZ; - break; - case MSAR_TCLCK_200: - return MV_BOARD_TCLK_200MHZ; - break; - } -#else - return MV_BOARD_TCLK_200MHZ; -#endif - } - - return MV_BOARD_TCLK_166MHZ; - -} -/******************************************************************************* -* mvBoardSysClkGet - Get the board SysClk (CPU bus clock) -* -* DESCRIPTION: -* This routine extract the CPU bus clock. -* -* INPUT: -* countNum - Counter number. -* -* OUTPUT: -* None. -* -* RETURN: -* 32bit clock cycles in Hertz. -* -*******************************************************************************/ -static MV_U32 mvBoard6180SysClkGet(MV_VOID) -{ - MV_U32 sysClkRate=0; - MV_CPU_ARM_CLK _cpu6180_ddr_l2_CLK[] = MV_CPU6180_DDR_L2_CLCK_TBL; - - sysClkRate = MV_REG_READ(MPP_SAMPLE_AT_RESET); - sysClkRate = sysClkRate & MSAR_CPUCLCK_MASK_6180; - sysClkRate = sysClkRate >> MSAR_CPUCLCK_OFFS_6180; - - sysClkRate = _cpu6180_ddr_l2_CLK[sysClkRate].ddrClk; - - return sysClkRate; - -} - -MV_U32 mvBoardSysClkGet(MV_VOID) -{ -#ifdef SYSCLK_AUTO_DETECT - MV_U32 sysClkRate, tmp, pClkRate, indexDdrRtio; - MV_U32 cpuCLK[] = MV_CPU_CLCK_TBL; - MV_U32 ddrRtio[][2] = MV_DDR_CLCK_RTIO_TBL; - - if(mvCtrlModelGet() == MV_6180_DEV_ID) - return mvBoard6180SysClkGet(); - - tmp = MV_REG_READ(MPP_SAMPLE_AT_RESET); - pClkRate = MSAR_CPUCLCK_EXTRACT(tmp); - pClkRate = cpuCLK[pClkRate]; - - indexDdrRtio = tmp & MSAR_DDRCLCK_RTIO_MASK; - indexDdrRtio = indexDdrRtio >> MSAR_DDRCLCK_RTIO_OFFS; - if(ddrRtio[indexDdrRtio][0] != 0) - sysClkRate = ((pClkRate * ddrRtio[indexDdrRtio][1]) / ddrRtio[indexDdrRtio][0]); - else - sysClkRate = 0; - return sysClkRate; -#else - return MV_BOARD_DEFAULT_SYSCLK; -#endif -} - - -/******************************************************************************* -* mvBoardPexBridgeIntPinGet - Get PEX to PCI bridge interrupt pin number -* -* DESCRIPTION: -* Multi-ported PCI Express bridges that is implemented on the board -* collapse interrupts across multiple conventional PCI/PCI-X buses. -* A dual-headed PCI Express bridge would map (or "swizzle") the -* interrupts per the following table (in accordance with the respective -* logical PCI/PCI-X bridge's Device Number), collapse the INTA#-INTD# -* signals from its two logical PCI/PCI-X bridges, collapse the -* INTA#-INTD# signals from any internal sources, and convert the -* signals to in-band PCI Express messages. 10 -* This function returns the upstream interrupt as it was converted by -* the bridge, according to board configuration and the following table: -* PCI dev num -* Interrupt pin 7, 8, 9 -* A -> A D C -* B -> B A D -* C -> C B A -* D -> D C B -* -* -* INPUT: -* devNum - PCI/PCIX device number. -* intPin - PCI Int pin -* -* OUTPUT: -* None. -* -* RETURN: -* Int pin connected to the Interrupt controller -* -*******************************************************************************/ -MV_U32 mvBoardPexBridgeIntPinGet(MV_U32 devNum, MV_U32 intPin) -{ - MV_U32 realIntPin = ((intPin + (3 - (devNum % 4))) %4 ); - - if (realIntPin == 0) return 4; - else return realIntPin; - -} - -/******************************************************************************* -* mvBoardDebugLedNumGet - Get number of debug Leds -* -* DESCRIPTION: -* INPUT: -* boardId -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_U32 mvBoardDebugLedNumGet(MV_U32 boardId) -{ - return BOARD_INFO(boardId)->activeLedsNumber; -} - -/******************************************************************************* -* mvBoardDebugLeg - Set the board debug Leds -* -* DESCRIPTION: turn on/off status leds. -* Note: assume MPP leds are part of group 0 only. -* -* INPUT: -* hexNum - Number to be displied in hex by Leds. -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_VOID mvBoardDebugLed(MV_U32 hexNum) -{ - MV_U32 val = 0,totalMask, currentBitMask = 1,i; - MV_U32 boardId= mvBoardIdGet(); - - if (BOARD_INFO(boardId)->pLedGppPin == NULL) - return; - - totalMask = (1 << BOARD_INFO(boardId)->activeLedsNumber) -1; - hexNum &= totalMask; - totalMask = 0; - - for (i = 0 ; i < BOARD_INFO(boardId)->activeLedsNumber ; i++) - { - if (hexNum & currentBitMask) - { - val |= (1 << BOARD_INFO(boardId)->pLedGppPin[i]); - } - - totalMask |= (1 << BOARD_INFO(boardId)->pLedGppPin[i]); - - currentBitMask = (currentBitMask << 1); - } - - if (BOARD_INFO(boardId)->ledsPolarity) - { - mvGppValueSet(0, totalMask, val); - } - else - { - mvGppValueSet(0, totalMask, ~val); - } -} - - -/******************************************************************************* -* mvBoarGpioPinGet - mvBoarGpioPinGet -* -* DESCRIPTION: -* -* INPUT: -* class - MV_BOARD_GPP_CLASS enum. -* -* OUTPUT: -* None. -* -* RETURN: -* GPIO pin number. The function return -1 for bad parameters. -* -*******************************************************************************/ -MV_32 mvBoarGpioPinNumGet(MV_BOARD_GPP_CLASS class, MV_U32 index) -{ - MV_U32 boardId, i; - MV_U32 indexFound = 0; - - boardId = mvBoardIdGet(); - - if (!((boardId >= BOARD_ID_BASE)&&(boardId < MV_MAX_BOARD_ID))) - { - mvOsPrintf("mvBoardRTCGpioPinGet:Board unknown.\n"); - return MV_ERROR; - - } - - for (i = 0; i < BOARD_INFO(boardId)->numBoardGppInfo; i++) - if (BOARD_INFO(boardId)->pBoardGppInfo[i].devClass == class) { - if (indexFound == index) - return (MV_U32)BOARD_INFO(boardId)->pBoardGppInfo[i].gppPinNum; - else - indexFound++; - - } - - return MV_ERROR; -} - - -/******************************************************************************* -* mvBoardRTCGpioPinGet - mvBoardRTCGpioPinGet -* -* DESCRIPTION: -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* GPIO pin number. The function return -1 for bad parameters. -* -*******************************************************************************/ -MV_32 mvBoardRTCGpioPinGet(MV_VOID) -{ - return mvBoarGpioPinNumGet(BOARD_GPP_RTC, 0); -} - - -/******************************************************************************* -* mvBoardReset - mvBoardReset -* -* DESCRIPTION: -* Reset the board -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* None -* -*******************************************************************************/ -MV_VOID mvBoardReset(MV_VOID) -{ - MV_32 resetPin; - - /* Get gpp reset pin if define */ - resetPin = mvBoardResetGpioPinGet(); - if (resetPin != MV_ERROR) - { - MV_REG_BIT_RESET( GPP_DATA_OUT_REG(0) ,(1 << resetPin)); - MV_REG_BIT_RESET( GPP_DATA_OUT_EN_REG(0) ,(1 << resetPin)); - - } - else - { - /* No gpp reset pin was found, try to reset ussing - system reset out */ - MV_REG_BIT_SET( CPU_RSTOUTN_MASK_REG , BIT2); - MV_REG_BIT_SET( CPU_SYS_SOFT_RST_REG , BIT0); - } -} - -/******************************************************************************* -* mvBoardResetGpioPinGet - mvBoardResetGpioPinGet -* -* DESCRIPTION: -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* GPIO pin number. The function return -1 for bad parameters. -* -*******************************************************************************/ -MV_32 mvBoardResetGpioPinGet(MV_VOID) -{ - return mvBoarGpioPinNumGet(BOARD_GPP_RESET, 0); -} -/******************************************************************************* -* mvBoardSDIOGpioPinGet - mvBoardSDIOGpioPinGet -* -* DESCRIPTION: -* used for hotswap detection -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* GPIO pin number. The function return -1 for bad parameters. -* -*******************************************************************************/ -MV_32 mvBoardSDIOGpioPinGet(MV_VOID) -{ - return mvBoarGpioPinNumGet(BOARD_GPP_SDIO_DETECT, 0); -} - -/******************************************************************************* -* mvBoardUSBVbusGpioPinGet - return Vbus input GPP -* -* DESCRIPTION: -* -* INPUT: -* int devNo. -* -* OUTPUT: -* None. -* -* RETURN: -* GPIO pin number. The function return -1 for bad parameters. -* -*******************************************************************************/ -MV_32 mvBoardUSBVbusGpioPinGet(MV_32 devId) -{ - return mvBoarGpioPinNumGet(BOARD_GPP_USB_VBUS, devId); -} - -/******************************************************************************* -* mvBoardUSBVbusEnGpioPinGet - return Vbus Enable output GPP -* -* DESCRIPTION: -* -* INPUT: -* int devNo. -* -* OUTPUT: -* None. -* -* RETURN: -* GPIO pin number. The function return -1 for bad parameters. -* -*******************************************************************************/ -MV_32 mvBoardUSBVbusEnGpioPinGet(MV_32 devId) -{ - return mvBoarGpioPinNumGet(BOARD_GPP_USB_VBUS_EN, devId); -} - - -/******************************************************************************* -* mvBoardGpioIntMaskGet - Get GPIO mask for interrupt pins -* -* DESCRIPTION: -* This function returns a 32-bit mask of GPP pins that connected to -* interrupt generating sources on board. -* For example if UART channel A is hardwired to GPP pin 8 and -* UART channel B is hardwired to GPP pin 4 the fuinction will return -* the value 0x000000110 -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* See description. The function return -1 if board is not identified. -* -*******************************************************************************/ -MV_32 mvBoardGpioIntMaskLowGet(MV_VOID) -{ - MV_U32 boardId; - - boardId = mvBoardIdGet(); - - if (!((boardId >= BOARD_ID_BASE)&&(boardId < MV_MAX_BOARD_ID))) - { - mvOsPrintf("mvBoardGpioIntMaskGet:Board unknown.\n"); - return MV_ERROR; - - } - - return BOARD_INFO(boardId)->intsGppMaskLow; -} -MV_32 mvBoardGpioIntMaskHighGet(MV_VOID) -{ - MV_U32 boardId; - - boardId = mvBoardIdGet(); - - if (!((boardId >= BOARD_ID_BASE)&&(boardId < MV_MAX_BOARD_ID))) - { - mvOsPrintf("mvBoardGpioIntMaskGet:Board unknown.\n"); - return MV_ERROR; - - } - - return BOARD_INFO(boardId)->intsGppMaskHigh; -} - - -/******************************************************************************* -* mvBoardMppGet - Get board dependent MPP register value -* -* DESCRIPTION: -* MPP settings are derived from board design. -* MPP group consist of 8 MPPs. An MPP group represent MPP -* control register. -* This function retrieves board dependend MPP register value. -* -* INPUT: -* mppGroupNum - MPP group number. -* -* OUTPUT: -* None. -* -* RETURN: -* 32bit value describing MPP control register value. -* -*******************************************************************************/ -MV_32 mvBoardMppGet(MV_U32 mppGroupNum) -{ - MV_U32 boardId; - - boardId = mvBoardIdGet(); - - if (!((boardId >= BOARD_ID_BASE)&&(boardId < MV_MAX_BOARD_ID))) - { - mvOsPrintf("mvBoardMppGet:Board unknown.\n"); - return MV_ERROR; - - } - - return BOARD_INFO(boardId)->pBoardMppConfigValue[0].mppGroup[mppGroupNum]; -} - - -/******************************************************************************* -* mvBoardMppGroupId - If MPP group type is AUTO then identify it using twsi -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* None. -* -* RETURN: -* -*******************************************************************************/ -MV_VOID mvBoardMppGroupIdUpdate(MV_VOID) -{ - - MV_BOARD_MPP_GROUP_CLASS devClass; - MV_BOARD_MODULE_ID_CLASS devClassId; - MV_BOARD_MPP_TYPE_CLASS mppGroupType; - MV_U32 devId; - MV_U32 maxMppGrp = 1; - - devId = mvCtrlModelGet(); - - switch(devId){ - case MV_6281_DEV_ID: - maxMppGrp = MV_6281_MPP_MAX_MODULE; - break; - case MV_6192_DEV_ID: - maxMppGrp = MV_6192_MPP_MAX_MODULE; - break; - case MV_6190_DEV_ID: - maxMppGrp = MV_6190_MPP_MAX_MODULE; - break; - case MV_6180_DEV_ID: - maxMppGrp = MV_6180_MPP_MAX_MODULE; - break; - } - - for (devClass = 0; devClass < maxMppGrp; devClass++) - { - /* If MPP group can be defined by the module connected to it */ - if (mvBoardMppGroupTypeGet(devClass) == MV_BOARD_AUTO) - { - /* Get MPP module ID */ - devClassId = mvBoarModuleTypeGet(devClass); - if (MV_ERROR != devClassId) - { - switch(devClassId) - { - case MV_BOARD_MODULE_TDM_ID: - case MV_BOARD_MODULE_TDM_5CHAN_ID: - mppGroupType = MV_BOARD_TDM; - break; - case MV_BOARD_MODULE_AUDIO_ID: - mppGroupType = MV_BOARD_AUDIO; - break; - case MV_BOARD_MODULE_RGMII_ID: - mppGroupType = MV_BOARD_RGMII; - break; - case MV_BOARD_MODULE_GMII_ID: - mppGroupType = MV_BOARD_GMII; - break; - case MV_BOARD_MODULE_TS_ID: - mppGroupType = MV_BOARD_TS; - break; - case MV_BOARD_MODULE_MII_ID: - mppGroupType = MV_BOARD_MII; - break; - default: - mppGroupType = MV_BOARD_OTHER; - break; - } - } - else - /* The module bay is empty */ - mppGroupType = MV_BOARD_OTHER; - - /* Update MPP group type */ - mvBoardMppGroupTypeSet(devClass, mppGroupType); - } - - /* Update MPP output voltage for RGMII 1.8V. Set port to GMII for GMII module */ - if ((mvBoardMppGroupTypeGet(devClass) == MV_BOARD_RGMII)) - MV_REG_BIT_SET(MPP_OUTPUT_DRIVE_REG,MPP_1_8_RGMII1_OUTPUT_DRIVE | MPP_1_8_RGMII0_OUTPUT_DRIVE); - else - { - if ((mvBoardMppGroupTypeGet(devClass) == MV_BOARD_GMII)) - { - MV_REG_BIT_RESET(MPP_OUTPUT_DRIVE_REG, BIT7 | BIT15); - MV_REG_BIT_RESET(ETH_PORT_SERIAL_CTRL_1_REG(0),BIT3); - MV_REG_BIT_RESET(ETH_PORT_SERIAL_CTRL_1_REG(1),BIT3); - } - else if ((mvBoardMppGroupTypeGet(devClass) == MV_BOARD_MII)) - { - /* Assumption that the MDC & MDIO should be 3.3V */ - MV_REG_BIT_RESET(MPP_OUTPUT_DRIVE_REG, BIT7 | BIT15); - /* Assumption that only ETH1 can be MII when using modules on DB */ - MV_REG_BIT_RESET(ETH_PORT_SERIAL_CTRL_1_REG(1),BIT3); - } - } - } -} - -/******************************************************************************* -* mvBoardMppGroupTypeGet -* -* DESCRIPTION: -* -* INPUT: -* mppGroupClass - MPP group number 0 for MPP[35:20] or 1 for MPP[49:36]. -* -* OUTPUT: -* None. -* -* RETURN: -* -*******************************************************************************/ -MV_BOARD_MPP_TYPE_CLASS mvBoardMppGroupTypeGet(MV_BOARD_MPP_GROUP_CLASS mppGroupClass) -{ - MV_U32 boardId; - - boardId = mvBoardIdGet(); - - if (!((boardId >= BOARD_ID_BASE)&&(boardId < MV_MAX_BOARD_ID))) - { - mvOsPrintf("mvBoardMppGet:Board unknown.\n"); - return MV_ERROR; - - } - - if (mppGroupClass == MV_BOARD_MPP_GROUP_1) - return BOARD_INFO(boardId)->pBoardMppTypeValue[0].boardMppGroup1; - else - return BOARD_INFO(boardId)->pBoardMppTypeValue[0].boardMppGroup2; -} - -/******************************************************************************* -* mvBoardMppGroupTypeSet -* -* DESCRIPTION: -* -* INPUT: -* mppGroupClass - MPP group number 0 for MPP[35:20] or 1 for MPP[49:36]. -* mppGroupType - MPP group type for MPP[35:20] or for MPP[49:36]. -* -* OUTPUT: -* None. -* -* RETURN: -* -*******************************************************************************/ -MV_VOID mvBoardMppGroupTypeSet(MV_BOARD_MPP_GROUP_CLASS mppGroupClass, - MV_BOARD_MPP_TYPE_CLASS mppGroupType) -{ - MV_U32 boardId; - - boardId = mvBoardIdGet(); - - if (!((boardId >= BOARD_ID_BASE)&&(boardId < MV_MAX_BOARD_ID))) - { - mvOsPrintf("mvBoardMppGet:Board unknown.\n"); - } - - if (mppGroupClass == MV_BOARD_MPP_GROUP_1) - BOARD_INFO(boardId)->pBoardMppTypeValue[0].boardMppGroup1 = mppGroupType; - else - BOARD_INFO(boardId)->pBoardMppTypeValue[0].boardMppGroup2 = mppGroupType; - -} - -/******************************************************************************* -* mvBoardMppMuxSet - Update MPP mux -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* None. -* -* RETURN: -* -*******************************************************************************/ -MV_VOID mvBoardMppMuxSet(MV_VOID) -{ - - MV_BOARD_MPP_GROUP_CLASS devClass; - MV_BOARD_MPP_TYPE_CLASS mppGroupType; - MV_U32 devId; - MV_U8 muxVal = 0xf; - MV_U32 maxMppGrp = 1; - MV_TWSI_SLAVE twsiSlave; - MV_TWSI_ADDR slave; - - devId = mvCtrlModelGet(); - - switch(devId){ - case MV_6281_DEV_ID: - maxMppGrp = MV_6281_MPP_MAX_MODULE; - break; - case MV_6192_DEV_ID: - maxMppGrp = MV_6192_MPP_MAX_MODULE; - break; - case MV_6190_DEV_ID: - maxMppGrp = MV_6190_MPP_MAX_MODULE; - break; - case MV_6180_DEV_ID: - maxMppGrp = MV_6180_MPP_MAX_MODULE; - break; - } - - for (devClass = 0; devClass < maxMppGrp; devClass++) - { - mppGroupType = mvBoardMppGroupTypeGet(devClass); - - switch(mppGroupType) - { - case MV_BOARD_TDM: - muxVal &= ~(devClass ? (0x2 << (devClass * 2)):0x0); - break; - case MV_BOARD_AUDIO: - muxVal &= ~(devClass ? 0x7 : 0x0); /*old Z0 value 0xd:0x0*/ - break; - case MV_BOARD_TS: - muxVal &= ~(devClass ? (0x2 << (devClass * 2)):0x0); - break; - default: - muxVal |= (devClass ? 0xf : 0); - break; - } - } - - /* TWSI init */ - slave.type = ADDR7_BIT; - slave.address = 0; - mvTwsiInit(0, TWSI_SPEED, mvBoardTclkGet(), &slave, 0); - - /* Read MPP module ID */ - DB(mvOsPrintf("Board: twsi exp set\n")); - twsiSlave.slaveAddr.address = mvBoardTwsiExpAddrGet(MV_BOARD_MUX_I2C_ADDR_ENTRY); - twsiSlave.slaveAddr.type = mvBoardTwsiExpAddrTypeGet(MV_BOARD_MUX_I2C_ADDR_ENTRY); - twsiSlave.validOffset = MV_TRUE; - /* Offset is the first command after the address which indicate the register number to be read - in next operation */ - twsiSlave.offset = 2; - twsiSlave.moreThen256 = MV_FALSE; - - - - if( MV_OK != mvTwsiWrite (0, &twsiSlave, &muxVal, 1) ) - { - DB(mvOsPrintf("Board: twsi exp out val fail\n")); - return; - } - DB(mvOsPrintf("Board: twsi exp out val succeded\n")); - - /* Change twsi exp to output */ - twsiSlave.offset = 6; - muxVal = 0; - if( MV_OK != mvTwsiWrite (0, &twsiSlave, &muxVal, 1) ) - { - DB(mvOsPrintf("Board: twsi exp change to out fail\n")); - return; - } - DB(mvOsPrintf("Board: twsi exp change to out succeded\n")); - -} - -/******************************************************************************* -* mvBoardTdmMppSet - set MPPs in TDM module -* -* DESCRIPTION: -* -* INPUT: type of second telephony device -* -* OUTPUT: -* None. -* -* RETURN: -* -*******************************************************************************/ -MV_VOID mvBoardTdmMppSet(MV_32 chType) -{ - - MV_BOARD_MPP_GROUP_CLASS devClass; - MV_BOARD_MPP_TYPE_CLASS mppGroupType; - MV_U32 devId; - MV_U8 muxVal = 1; - MV_U8 muxValMask = 1; - MV_U8 twsiVal; - MV_U32 maxMppGrp = 1; - MV_TWSI_SLAVE twsiSlave; - MV_TWSI_ADDR slave; - - devId = mvCtrlModelGet(); - - switch(devId){ - case MV_6281_DEV_ID: - maxMppGrp = MV_6281_MPP_MAX_MODULE; - break; - case MV_6192_DEV_ID: - maxMppGrp = MV_6192_MPP_MAX_MODULE; - break; - case MV_6190_DEV_ID: - maxMppGrp = MV_6190_MPP_MAX_MODULE; - break; - case MV_6180_DEV_ID: - maxMppGrp = MV_6180_MPP_MAX_MODULE; - break; - } - - for (devClass = 0; devClass < maxMppGrp; devClass++) - { - mppGroupType = mvBoardMppGroupTypeGet(devClass); - if(mppGroupType == MV_BOARD_TDM) - break; - } - - if(devClass == maxMppGrp) - return; /* TDM module not found */ - - /* TWSI init */ - slave.type = ADDR7_BIT; - slave.address = 0; - mvTwsiInit(0, TWSI_SPEED, mvBoardTclkGet(), &slave, 0); - - /* Read MPP module ID */ - DB(mvOsPrintf("Board: twsi exp set\n")); - twsiSlave.slaveAddr.address = mvBoardTwsiExpAddrGet(devClass); - twsiSlave.slaveAddr.type = ADDR7_BIT; - twsiSlave.validOffset = MV_TRUE; - /* Offset is the first command after the address which indicate the register number to be read - in next operation */ - twsiSlave.offset = 3; - twsiSlave.moreThen256 = MV_FALSE; - - if(mvBoardIdGet() == RD_88F6281A_ID) - { - muxVal = 0xc; - muxValMask = 0xf3; - } - - mvTwsiRead(0, &twsiSlave, &twsiVal, 1); - muxVal = (twsiVal & muxValMask) | muxVal; - - if( MV_OK != mvTwsiWrite (0, &twsiSlave, &muxVal, 1) ) - { - mvOsPrintf("Board: twsi exp out val fail\n"); - return; - } - DB(mvOsPrintf("Board: twsi exp out val succeded\n")); - - /* Change twsi exp to output */ - twsiSlave.offset = 7; - muxVal = 0xfe; - if(mvBoardIdGet() == RD_88F6281A_ID) - muxVal = 0xf3; - - mvTwsiRead(0, &twsiSlave, &twsiVal, 1); - muxVal = (twsiVal & muxVal); - - if( MV_OK != mvTwsiWrite (0, &twsiSlave, &muxVal, 1) ) - { - mvOsPrintf("Board: twsi exp change to out fail\n"); - return; - } - DB(mvOsPrintf("Board: twsi exp change to out succeded\n")); - /* reset the line to 0 */ - twsiSlave.offset = 3; - muxVal = 0; - muxValMask = 1; - - if(mvBoardIdGet() == RD_88F6281A_ID) { - muxVal = 0x0; - muxValMask = 0xf3; - } - - mvTwsiRead(0, &twsiSlave, &twsiVal, 1); - muxVal = (twsiVal & muxValMask) | muxVal; - - if( MV_OK != mvTwsiWrite (0, &twsiSlave, &muxVal, 1) ) - { - mvOsPrintf("Board: twsi exp out val fail\n"); - return; - } - DB(mvOsPrintf("Board: twsi exp out val succeded\n")); - - mvOsDelay(20); - - /* set the line to 1 */ - twsiSlave.offset = 3; - muxVal = 1; - muxValMask = 1; - - if(mvBoardIdGet() == RD_88F6281A_ID) - { - muxVal = 0xc; - muxValMask = 0xf3; - if(chType) /* FXS - issue reset properly */ - { - MV_REG_BIT_SET(GPP_DATA_OUT_REG(1), MV_GPP12); - mvOsDelay(50); - MV_REG_BIT_RESET(GPP_DATA_OUT_REG(1), MV_GPP12); - } - else /* FXO - issue reset via TDM_CODEC_RST*/ - { - /* change MPP44 type to TDM_CODEC_RST(0x2) */ - MV_REG_WRITE(MPP_CONTROL_REG5, ((MV_REG_READ(MPP_CONTROL_REG5) & 0xFFF0FFFF) | BIT17)); - } - } - - mvTwsiRead(0, &twsiSlave, &twsiVal, 1); - muxVal = (twsiVal & muxValMask) | muxVal; - - if( MV_OK != mvTwsiWrite (0, &twsiSlave, &muxVal, 1) ) - { - mvOsPrintf("Board: twsi exp out val fail\n"); - return; - } - - /* TBD - 5 channels */ -#if defined(MV_TDM_5CHANNELS) - /* change MPP38 type to GPIO(0x0) & polarity for TDM_STROBE */ - MV_REG_WRITE(MPP_CONTROL_REG4, (MV_REG_READ(MPP_CONTROL_REG4) & 0xF0FFFFFF)); - mvGppPolaritySet(1, MV_GPP6, 0); - - twsiSlave.offset = 6; - twsiSlave.slaveAddr.address = mvBoardTwsiExpAddrGet(2); - - mvTwsiRead(0, &twsiSlave, &twsiVal, 1); - muxVal = (twsiVal & ~BIT2); - - if( MV_OK != mvTwsiWrite (0, &twsiSlave, &muxVal, 1) ) - { - mvOsPrintf("Board: twsi exp change to out fail\n"); - return; - } - - - twsiSlave.offset = 2; - - mvTwsiRead(0, &twsiSlave, &twsiVal, 1); - muxVal = (twsiVal & ~BIT2); - - if( MV_OK != mvTwsiWrite (0, &twsiSlave, &muxVal, 1) ) - { - mvOsPrintf("Board: twsi exp change to out fail\n"); - return; - } -#endif - DB(mvOsPrintf("Board: twsi exp out val succeded\n")); - - -} -/******************************************************************************* -* mvBoardVoiceConnModeGet - return SLIC/DAA connection & interrupt modes -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* None. -* -* RETURN: -* -*******************************************************************************/ - -MV_VOID mvBoardVoiceConnModeGet(MV_32* connMode, MV_32* irqMode) -{ - switch(mvBoardIdGet()) - { - case RD_88F6281A_ID: - *connMode = DAISY_CHAIN_MODE; - *irqMode = INTERRUPT_TO_TDM; - break; - case DB_88F6281A_BP_ID: - *connMode = DUAL_CHIP_SELECT_MODE; - *irqMode = INTERRUPT_TO_TDM; - break; - case RD_88F6192A_ID: - *connMode = DUAL_CHIP_SELECT_MODE; - *irqMode = INTERRUPT_TO_TDM; - break; - case DB_88F6192A_BP_ID: - *connMode = DUAL_CHIP_SELECT_MODE; - *irqMode = INTERRUPT_TO_TDM; - break; - default: - *connMode = *irqMode = -1; - mvOsPrintf("mvBoardVoiceAssembleModeGet: TDM not supported(boardId=0x%x)\n",mvBoardIdGet()); - } - return; - -} - -/******************************************************************************* -* mvBoardMppModuleTypePrint - print module detect -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* None. -* -* RETURN: -* -*******************************************************************************/ -MV_VOID mvBoardMppModuleTypePrint(MV_VOID) -{ - - MV_BOARD_MPP_GROUP_CLASS devClass; - MV_BOARD_MPP_TYPE_CLASS mppGroupType; - MV_U32 devId; - MV_U32 maxMppGrp = 1; - - devId = mvCtrlModelGet(); - - switch(devId){ - case MV_6281_DEV_ID: - maxMppGrp = MV_6281_MPP_MAX_MODULE; - break; - case MV_6192_DEV_ID: - maxMppGrp = MV_6192_MPP_MAX_MODULE; - break; - case MV_6190_DEV_ID: - maxMppGrp = MV_6190_MPP_MAX_MODULE; - break; - case MV_6180_DEV_ID: - maxMppGrp = MV_6180_MPP_MAX_MODULE; - break; - } - - for (devClass = 0; devClass < maxMppGrp; devClass++) - { - mppGroupType = mvBoardMppGroupTypeGet(devClass); - - switch(mppGroupType) - { - case MV_BOARD_TDM: - if(devId != MV_6190_DEV_ID) - mvOsPrintf("Module %d is TDM\n", devClass); - break; - case MV_BOARD_AUDIO: - if(devId != MV_6190_DEV_ID) - mvOsPrintf("Module %d is AUDIO\n", devClass); - break; - case MV_BOARD_RGMII: - if(devId != MV_6190_DEV_ID) - mvOsPrintf("Module %d is RGMII\n", devClass); - break; - case MV_BOARD_GMII: - if(devId != MV_6190_DEV_ID) - mvOsPrintf("Module %d is GMII\n", devClass); - break; - case MV_BOARD_TS: - if(devId != MV_6190_DEV_ID) - mvOsPrintf("Module %d is TS\n", devClass); - break; - default: - break; - } - } -} - -/* Board devices API managments */ - -/******************************************************************************* -* mvBoardGetDeviceNumber - Get number of device of some type on the board -* -* DESCRIPTION: -* -* INPUT: -* devType - The device type ( Flash,RTC , etc .. ) -* -* OUTPUT: -* None. -* -* RETURN: -* If the device is found on the board the then the functions returns the -* number of those devices else the function returns 0 -* -* -*******************************************************************************/ -MV_32 mvBoardGetDevicesNumber(MV_BOARD_DEV_CLASS devClass) -{ - MV_U32 foundIndex=0,devNum; - MV_U32 boardId= mvBoardIdGet(); - - if (!((boardId >= BOARD_ID_BASE)&&(boardId < MV_MAX_BOARD_ID))) - { - mvOsPrintf("mvBoardGetDeviceNumber:Board unknown.\n"); - return 0xFFFFFFFF; - - } - - for (devNum = START_DEV_CS; devNum < BOARD_INFO(boardId)->numBoardDeviceIf; devNum++) - { - if (BOARD_INFO(boardId)->pDevCsInfo[devNum].devClass == devClass) - { - foundIndex++; - } - } - - return foundIndex; - -} - -/******************************************************************************* -* mvBoardGetDeviceBaseAddr - Get base address of a device existing on the board -* -* DESCRIPTION: -* -* INPUT: -* devIndex - The device sequential number on the board -* devType - The device type ( Flash,RTC , etc .. ) -* -* OUTPUT: -* None. -* -* RETURN: -* If the device is found on the board the then the functions returns the -* Base address else the function returns 0xffffffff -* -* -*******************************************************************************/ -MV_32 mvBoardGetDeviceBaseAddr(MV_32 devNum, MV_BOARD_DEV_CLASS devClass) -{ - MV_DEV_CS_INFO* devEntry; - devEntry = boardGetDevEntry(devNum,devClass); - if (devEntry != NULL) - { - return mvCpuIfTargetWinBaseLowGet(DEV_TO_TARGET(devEntry->deviceCS)); - - } - - return 0xFFFFFFFF; -} - -/******************************************************************************* -* mvBoardGetDeviceBusWidth - Get Bus width of a device existing on the board -* -* DESCRIPTION: -* -* INPUT: -* devIndex - The device sequential number on the board -* devType - The device type ( Flash,RTC , etc .. ) -* -* OUTPUT: -* None. -* -* RETURN: -* If the device is found on the board the then the functions returns the -* Bus width else the function returns 0xffffffff -* -* -*******************************************************************************/ -MV_32 mvBoardGetDeviceBusWidth(MV_32 devNum, MV_BOARD_DEV_CLASS devClass) -{ - MV_DEV_CS_INFO* devEntry; - - devEntry = boardGetDevEntry(devNum,devClass); - if (devEntry != NULL) - { - return 8; - } - - return 0xFFFFFFFF; - -} - -/******************************************************************************* -* mvBoardGetDeviceWidth - Get dev width of a device existing on the board -* -* DESCRIPTION: -* -* INPUT: -* devIndex - The device sequential number on the board -* devType - The device type ( Flash,RTC , etc .. ) -* -* OUTPUT: -* None. -* -* RETURN: -* If the device is found on the board the then the functions returns the -* dev width else the function returns 0xffffffff -* -* -*******************************************************************************/ -MV_32 mvBoardGetDeviceWidth(MV_32 devNum, MV_BOARD_DEV_CLASS devClass) -{ - MV_DEV_CS_INFO* devEntry; - MV_U32 boardId= mvBoardIdGet(); - - if (!((boardId >= BOARD_ID_BASE)&&(boardId < MV_MAX_BOARD_ID))) - { - mvOsPrintf("Board unknown.\n"); - return 0xFFFFFFFF; - } - - devEntry = boardGetDevEntry(devNum,devClass); - if (devEntry != NULL) - return devEntry->devWidth; - - return MV_ERROR; - -} - -/******************************************************************************* -* mvBoardGetDeviceWinSize - Get the window size of a device existing on the board -* -* DESCRIPTION: -* -* INPUT: -* devIndex - The device sequential number on the board -* devType - The device type ( Flash,RTC , etc .. ) -* -* OUTPUT: -* None. -* -* RETURN: -* If the device is found on the board the then the functions returns the -* window size else the function returns 0xffffffff -* -* -*******************************************************************************/ -MV_32 mvBoardGetDeviceWinSize(MV_32 devNum, MV_BOARD_DEV_CLASS devClass) -{ - MV_DEV_CS_INFO* devEntry; - MV_U32 boardId = mvBoardIdGet(); - - if (!((boardId >= BOARD_ID_BASE)&&(boardId < MV_MAX_BOARD_ID))) - { - mvOsPrintf("Board unknown.\n"); - return 0xFFFFFFFF; - } - - devEntry = boardGetDevEntry(devNum,devClass); - if (devEntry != NULL) - { - return mvCpuIfTargetWinSizeGet(DEV_TO_TARGET(devEntry->deviceCS)); - } - - return 0xFFFFFFFF; -} - - -/******************************************************************************* -* boardGetDevEntry - returns the entry pointer of a device on the board -* -* DESCRIPTION: -* -* INPUT: -* devIndex - The device sequential number on the board -* devType - The device type ( Flash,RTC , etc .. ) -* -* OUTPUT: -* None. -* -* RETURN: -* If the device is found on the board the then the functions returns the -* dev number else the function returns 0x0 -* -* -*******************************************************************************/ -static MV_DEV_CS_INFO* boardGetDevEntry(MV_32 devNum, MV_BOARD_DEV_CLASS devClass) -{ - MV_U32 foundIndex=0,devIndex; - MV_U32 boardId= mvBoardIdGet(); - - if (!((boardId >= BOARD_ID_BASE)&&(boardId < MV_MAX_BOARD_ID))) - { - mvOsPrintf("boardGetDevEntry: Board unknown.\n"); - return NULL; - - } - - for (devIndex = START_DEV_CS; devIndex < BOARD_INFO(boardId)->numBoardDeviceIf; devIndex++) - { - /* TBR */ - /*if (BOARD_INFO(boardId)->pDevCsInfo[devIndex].deviceCS == MV_BOOTDEVICE_INDEX) - continue;*/ - - if (BOARD_INFO(boardId)->pDevCsInfo[devIndex].devClass == devClass) - { - if (foundIndex == devNum) - { - return &(BOARD_INFO(boardId)->pDevCsInfo[devIndex]); - } - foundIndex++; - } - } - - /* device not found */ - return NULL; -} - -/* Get device CS number */ - -MV_U32 boardGetDevCSNum(MV_32 devNum, MV_BOARD_DEV_CLASS devClass) -{ - MV_DEV_CS_INFO* devEntry; - MV_U32 boardId= mvBoardIdGet(); - - if (!((boardId >= BOARD_ID_BASE)&&(boardId < MV_MAX_BOARD_ID))) - { - mvOsPrintf("Board unknown.\n"); - return 0xFFFFFFFF; - - } - - - devEntry = boardGetDevEntry(devNum,devClass); - if (devEntry != NULL) - return devEntry->deviceCS; - - return 0xFFFFFFFF; - -} - -/******************************************************************************* -* mvBoardRtcTwsiAddrTypeGet - -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* None. -* -* RETURN: -* -* -*******************************************************************************/ -MV_U8 mvBoardRtcTwsiAddrTypeGet() -{ - int i; - MV_U32 boardId= mvBoardIdGet(); - - for (i = 0; i < BOARD_INFO(boardId)->numBoardTwsiDev; i++) - if (BOARD_INFO(boardId)->pBoardTwsiDev[i].devClass == BOARD_TWSI_RTC) - return BOARD_INFO(boardId)->pBoardTwsiDev[i].twsiDevAddrType; - return (MV_ERROR); -} - -/******************************************************************************* -* mvBoardRtcTwsiAddrGet - -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* None. -* -* RETURN: -* -* -*******************************************************************************/ -MV_U8 mvBoardRtcTwsiAddrGet() -{ - int i; - MV_U32 boardId= mvBoardIdGet(); - - for (i = 0; i < BOARD_INFO(boardId)->numBoardTwsiDev; i++) - if (BOARD_INFO(boardId)->pBoardTwsiDev[i].devClass == BOARD_TWSI_RTC) - return BOARD_INFO(boardId)->pBoardTwsiDev[i].twsiDevAddr; - return (0xFF); -} - -/******************************************************************************* -* mvBoardA2DTwsiAddrTypeGet - -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* None. -* -* RETURN: -* -* -*******************************************************************************/ -MV_U8 mvBoardA2DTwsiAddrTypeGet() -{ - int i; - MV_U32 boardId= mvBoardIdGet(); - - for (i = 0; i < BOARD_INFO(boardId)->numBoardTwsiDev; i++) - if (BOARD_INFO(boardId)->pBoardTwsiDev[i].devClass == BOARD_TWSI_AUDIO_DEC) - return BOARD_INFO(boardId)->pBoardTwsiDev[i].twsiDevAddrType; - return (MV_ERROR); -} - -/******************************************************************************* -* mvBoardA2DTwsiAddrGet - -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* None. -* -* RETURN: -* -* -*******************************************************************************/ -MV_U8 mvBoardA2DTwsiAddrGet() -{ - int i; - MV_U32 boardId= mvBoardIdGet(); - - for (i = 0; i < BOARD_INFO(boardId)->numBoardTwsiDev; i++) - if (BOARD_INFO(boardId)->pBoardTwsiDev[i].devClass == BOARD_TWSI_AUDIO_DEC) - return BOARD_INFO(boardId)->pBoardTwsiDev[i].twsiDevAddr; - return (0xFF); -} - -/******************************************************************************* -* mvBoardTwsiExpAddrTypeGet - -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* None. -* -* RETURN: -* -* -*******************************************************************************/ -MV_U8 mvBoardTwsiExpAddrTypeGet(MV_U32 index) -{ - int i; - MV_U32 indexFound = 0; - MV_U32 boardId= mvBoardIdGet(); - - for (i = 0; i < BOARD_INFO(boardId)->numBoardTwsiDev; i++) - if (BOARD_INFO(boardId)->pBoardTwsiDev[i].devClass == BOARD_DEV_TWSI_EXP) - { - if (indexFound == index) - return BOARD_INFO(boardId)->pBoardTwsiDev[i].twsiDevAddrType; - else - indexFound++; - } - - return (MV_ERROR); -} - -/******************************************************************************* -* mvBoardTwsiExpAddrGet - -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* None. -* -* RETURN: -* -* -*******************************************************************************/ -MV_U8 mvBoardTwsiExpAddrGet(MV_U32 index) -{ - int i; - MV_U32 indexFound = 0; - MV_U32 boardId= mvBoardIdGet(); - - for (i = 0; i < BOARD_INFO(boardId)->numBoardTwsiDev; i++) - if (BOARD_INFO(boardId)->pBoardTwsiDev[i].devClass == BOARD_DEV_TWSI_EXP) - { - if (indexFound == index) - return BOARD_INFO(boardId)->pBoardTwsiDev[i].twsiDevAddr; - else - indexFound++; - } - - return (0xFF); -} - - -/******************************************************************************* -* mvBoardTwsiSatRAddrTypeGet - -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* None. -* -* RETURN: -* -* -*******************************************************************************/ -MV_U8 mvBoardTwsiSatRAddrTypeGet(MV_U32 index) -{ - int i; - MV_U32 indexFound = 0; - MV_U32 boardId= mvBoardIdGet(); - - for (i = 0; i < BOARD_INFO(boardId)->numBoardTwsiDev; i++) - if (BOARD_INFO(boardId)->pBoardTwsiDev[i].devClass == BOARD_DEV_TWSI_SATR) - { - if (indexFound == index) - return BOARD_INFO(boardId)->pBoardTwsiDev[i].twsiDevAddrType; - else - indexFound++; - } - - return (MV_ERROR); -} - -/******************************************************************************* -* mvBoardTwsiSatRAddrGet - -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* None. -* -* RETURN: -* -* -*******************************************************************************/ -MV_U8 mvBoardTwsiSatRAddrGet(MV_U32 index) -{ - int i; - MV_U32 indexFound = 0; - MV_U32 boardId= mvBoardIdGet(); - - for (i = 0; i < BOARD_INFO(boardId)->numBoardTwsiDev; i++) - if (BOARD_INFO(boardId)->pBoardTwsiDev[i].devClass == BOARD_DEV_TWSI_SATR) - { - if (indexFound == index) - return BOARD_INFO(boardId)->pBoardTwsiDev[i].twsiDevAddr; - else - indexFound++; - } - - return (0xFF); -} - -/******************************************************************************* -* mvBoardNandWidthGet - -* -* DESCRIPTION: Get the width of the first NAND device in byte. -* -* INPUT: -* -* OUTPUT: -* None. -* -* RETURN: 1, 2, 4 or MV_ERROR -* -* -*******************************************************************************/ -/* */ -MV_32 mvBoardNandWidthGet(void) -{ - MV_U32 devNum; - MV_U32 devWidth; - MV_U32 boardId= mvBoardIdGet(); - - for (devNum = START_DEV_CS; devNum < BOARD_INFO(boardId)->numBoardDeviceIf; devNum++) - { - devWidth = mvBoardGetDeviceWidth(devNum, BOARD_DEV_NAND_FLASH); - if (devWidth != MV_ERROR) - return (devWidth / 8); - } - - /* NAND wasn't found */ - return MV_ERROR; -} - -MV_U32 gBoardId = -1; - -/******************************************************************************* -* mvBoardIdGet - Get Board model -* -* DESCRIPTION: -* This function returns board ID. -* Board ID is 32bit word constructed of board model (16bit) and -* board revision (16bit) in the following way: 0xMMMMRRRR. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* 32bit board ID number, '-1' if board is undefined. -* -*******************************************************************************/ -MV_U32 mvBoardIdGet(MV_VOID) -{ - MV_U32 tmpBoardId = -1; - - if(gBoardId == -1) - { - #if defined(DB_88F6281A) - tmpBoardId = DB_88F6281A_BP_ID; - #elif defined(RD_88F6281A) - tmpBoardId = RD_88F6281A_ID; - #elif defined(DB_88F6192A) - tmpBoardId = DB_88F6192A_BP_ID; - #elif defined(DB_88F6190A) - tmpBoardId = DB_88F6190A_BP_ID; - #elif defined(RD_88F6192A) - tmpBoardId = RD_88F6192A_ID; - #elif defined(RD_88F6190A) - tmpBoardId = RD_88F6190A_ID; - #elif defined(DB_88F6180A) - tmpBoardId = DB_88F6180A_BP_ID; - #elif defined(RD_88F6281A_PCAC) - tmpBoardId = RD_88F6281A_PCAC_ID; - #elif defined(RD_88F6281A_SHEEVA_PLUG) - tmpBoardId = SHEEVA_PLUG_ID; - #elif defined(DB_CUSTOMER) - tmpBoardId = DB_CUSTOMER_ID; - #endif - gBoardId = tmpBoardId; - } - - return gBoardId; -} - - -/******************************************************************************* -* mvBoarModuleTypeGet - mvBoarModuleTypeGet -* -* DESCRIPTION: -* -* INPUT: -* group num - MV_BOARD_MPP_GROUP_CLASS enum -* -* OUTPUT: -* None. -* -* RETURN: -* module num - MV_BOARD_MODULE_CLASS enum -* -*******************************************************************************/ -MV_BOARD_MODULE_ID_CLASS mvBoarModuleTypeGet(MV_BOARD_MPP_GROUP_CLASS devClass) -{ - MV_TWSI_SLAVE twsiSlave; - MV_TWSI_ADDR slave; - MV_U8 data; - - /* TWSI init */ - slave.type = ADDR7_BIT; - slave.address = 0; - mvTwsiInit(0, TWSI_SPEED, mvBoardTclkGet(), &slave, 0); - - /* Read MPP module ID */ - DB(mvOsPrintf("Board: Read MPP module ID\n")); - twsiSlave.slaveAddr.address = mvBoardTwsiExpAddrGet(devClass); - twsiSlave.slaveAddr.type = mvBoardTwsiExpAddrTypeGet(devClass); - twsiSlave.validOffset = MV_TRUE; - /* Offset is the first command after the address which indicate the register number to be read - in next operation */ - twsiSlave.offset = 0; - twsiSlave.moreThen256 = MV_FALSE; - - - - if( MV_OK != mvTwsiRead (0, &twsiSlave, &data, 1) ) - { - DB(mvOsPrintf("Board: Read MPP module ID fail\n")); - return MV_ERROR; - } - DB(mvOsPrintf("Board: Read MPP module ID succeded\n")); - - return data; -} - -/******************************************************************************* -* mvBoarTwsiSatRGet - -* -* DESCRIPTION: -* -* INPUT: -* device num - one of three devices -* reg num - 0 or 1 -* -* OUTPUT: -* None. -* -* RETURN: -* reg value -* -*******************************************************************************/ -MV_U8 mvBoarTwsiSatRGet(MV_U8 devNum, MV_U8 regNum) -{ - MV_TWSI_SLAVE twsiSlave; - MV_TWSI_ADDR slave; - MV_U8 data; - - /* TWSI init */ - slave.type = ADDR7_BIT; - slave.address = 0; - mvTwsiInit(0, TWSI_SPEED, mvBoardTclkGet(), &slave, 0); - - /* Read MPP module ID */ - DB(mvOsPrintf("Board: Read S@R device read\n")); - twsiSlave.slaveAddr.address = mvBoardTwsiSatRAddrGet(devNum); - twsiSlave.slaveAddr.type = mvBoardTwsiSatRAddrTypeGet(devNum); - twsiSlave.validOffset = MV_TRUE; - /* Use offset as command */ - twsiSlave.offset = regNum; - twsiSlave.moreThen256 = MV_FALSE; - - if( MV_OK != mvTwsiRead (0, &twsiSlave, &data, 1) ) - { - DB(mvOsPrintf("Board: Read S@R fail\n")); - return MV_ERROR; - } - DB(mvOsPrintf("Board: Read S@R succeded\n")); - - return data; -} - -/******************************************************************************* -* mvBoarTwsiSatRSet - -* -* DESCRIPTION: -* -* INPUT: -* devNum - one of three devices -* regNum - 0 or 1 -* regVal - value -* -* -* OUTPUT: -* None. -* -* RETURN: -* reg value -* -*******************************************************************************/ -MV_STATUS mvBoarTwsiSatRSet(MV_U8 devNum, MV_U8 regNum, MV_U8 regVal) -{ - MV_TWSI_SLAVE twsiSlave; - MV_TWSI_ADDR slave; - - /* TWSI init */ - slave.type = ADDR7_BIT; - slave.address = 0; - mvTwsiInit(0, TWSI_SPEED, mvBoardTclkGet(), &slave, 0); - - /* Read MPP module ID */ - twsiSlave.slaveAddr.address = mvBoardTwsiSatRAddrGet(devNum); - twsiSlave.slaveAddr.type = mvBoardTwsiSatRAddrTypeGet(devNum); - twsiSlave.validOffset = MV_TRUE; - DB(mvOsPrintf("Board: Write S@R device addr %x, type %x, data %x\n", twsiSlave.slaveAddr.address,\ - twsiSlave.slaveAddr.type, regVal)); - /* Use offset as command */ - twsiSlave.offset = regNum; - twsiSlave.moreThen256 = MV_FALSE; - if( MV_OK != mvTwsiWrite (0, &twsiSlave, ®Val, 1) ) - { - DB(mvOsPrintf("Board: Write S@R fail\n")); - return MV_ERROR; - } - DB(mvOsPrintf("Board: Write S@R succeded\n")); - - return MV_OK; -} - -/******************************************************************************* -* mvBoardSlicGpioPinGet - -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* None. -* -* RETURN: -* -* -*******************************************************************************/ -MV_32 mvBoardSlicGpioPinGet(MV_U32 slicNum) -{ - MV_U32 boardId; - boardId = mvBoardIdGet(); - - switch (boardId) - { - case DB_88F6281A_BP_ID: - case RD_88F6281A_ID: - default: - return MV_ERROR; - break; - - } -} - -/******************************************************************************* -* mvBoardFanPowerControl - Turn on/off the fan power control on the RD-6281A -* -* DESCRIPTION: -* -* INPUT: -* mode - MV_TRUE = on ; MV_FALSE = off -* -* OUTPUT: -* MV_STATUS - MV_OK , MV_ERROR. -* -* RETURN: -* -*******************************************************************************/ -MV_STATUS mvBoardFanPowerControl(MV_BOOL mode) -{ - - MV_U8 val = 1, twsiVal; - MV_TWSI_SLAVE twsiSlave; - MV_TWSI_ADDR slave; - - if(mvBoardIdGet() != RD_88F6281A_ID) - return MV_ERROR; - - /* TWSI init */ - slave.type = ADDR7_BIT; - slave.address = 0; - mvTwsiInit(0, TWSI_SPEED, mvBoardTclkGet(), &slave, 0); - - /* Read MPP module ID */ - DB(mvOsPrintf("Board: twsi exp set\n")); - twsiSlave.slaveAddr.address = mvBoardTwsiExpAddrGet(1); - twsiSlave.slaveAddr.type = ADDR7_BIT; - twsiSlave.validOffset = MV_TRUE; - /* Offset is the first command after the address which indicate the register number to be read - in next operation */ - twsiSlave.offset = 3; - twsiSlave.moreThen256 = MV_FALSE; - if(mode == MV_TRUE) - val = 0x1; - else - val = 0; - mvTwsiRead(0, &twsiSlave, &twsiVal, 1); - val = (twsiVal & 0xfe) | val; - - if( MV_OK != mvTwsiWrite (0, &twsiSlave, &val, 1) ) - { - DB(mvOsPrintf("Board: twsi exp out val fail\n")); - return MV_ERROR; - } - DB(mvOsPrintf("Board: twsi exp out val succeded\n")); - - /* Change twsi exp to output */ - twsiSlave.offset = 7; - mvTwsiRead(0, &twsiSlave, &twsiVal, 1); - val = (twsiVal & 0xfe); - if( MV_OK != mvTwsiWrite (0, &twsiSlave, &val, 1) ) - { - DB(mvOsPrintf("Board: twsi exp change to out fail\n")); - return MV_ERROR; - } - DB(mvOsPrintf("Board: twsi exp change to out succeded\n")); - return MV_OK; -} - -/******************************************************************************* -* mvBoardHDDPowerControl - Turn on/off the HDD power control on the RD-6281A -* -* DESCRIPTION: -* -* INPUT: -* mode - MV_TRUE = on ; MV_FALSE = off -* -* OUTPUT: -* MV_STATUS - MV_OK , MV_ERROR. -* -* RETURN: -* -*******************************************************************************/ -MV_STATUS mvBoardHDDPowerControl(MV_BOOL mode) -{ - - MV_U8 val = 1, twsiVal; - MV_TWSI_SLAVE twsiSlave; - MV_TWSI_ADDR slave; - - if(mvBoardIdGet() != RD_88F6281A_ID) - return MV_ERROR; - - /* TWSI init */ - slave.type = ADDR7_BIT; - slave.address = 0; - mvTwsiInit(0, TWSI_SPEED, mvBoardTclkGet(), &slave, 0); - - /* Read MPP module ID */ - DB(mvOsPrintf("Board: twsi exp set\n")); - twsiSlave.slaveAddr.address = mvBoardTwsiExpAddrGet(1); - twsiSlave.slaveAddr.type = ADDR7_BIT; - twsiSlave.validOffset = MV_TRUE; - /* Offset is the first command after the address which indicate the register number to be read - in next operation */ - twsiSlave.offset = 3; - twsiSlave.moreThen256 = MV_FALSE; - if(mode == MV_TRUE) - val = 0x2; - else - val = 0; - mvTwsiRead(0, &twsiSlave, &twsiVal, 1); - val = (twsiVal & 0xfd) | val; - if( MV_OK != mvTwsiWrite (0, &twsiSlave, &val, 1) ) - { - DB(mvOsPrintf("Board: twsi exp out val fail\n")); - return MV_ERROR; - } - DB(mvOsPrintf("Board: twsi exp out val succeded\n")); - - /* Change twsi exp to output */ - twsiSlave.offset = 7; - mvTwsiRead(0, &twsiSlave, &twsiVal, 1); - val = (twsiVal & 0xfd); - if( MV_OK != mvTwsiWrite (0, &twsiSlave, &val, 1) ) - { - DB(mvOsPrintf("Board: twsi exp change to out fail\n")); - return MV_ERROR; - } - DB(mvOsPrintf("Board: twsi exp change to out succeded\n")); - return MV_OK; -} - -/******************************************************************************* -* mvBoardSDioWPControl - Turn on/off the SDIO WP on the RD-6281A -* -* DESCRIPTION: -* -* INPUT: -* mode - MV_TRUE = on ; MV_FALSE = off -* -* OUTPUT: -* MV_STATUS - MV_OK , MV_ERROR. -* -* RETURN: -* -*******************************************************************************/ -MV_STATUS mvBoardSDioWPControl(MV_BOOL mode) -{ - - MV_U8 val = 1, twsiVal; - MV_TWSI_SLAVE twsiSlave; - MV_TWSI_ADDR slave; - - if(mvBoardIdGet() != RD_88F6281A_ID) - return MV_ERROR; - - /* TWSI init */ - slave.type = ADDR7_BIT; - slave.address = 0; - mvTwsiInit(0, TWSI_SPEED, mvBoardTclkGet(), &slave, 0); - - /* Read MPP module ID */ - DB(mvOsPrintf("Board: twsi exp set\n")); - twsiSlave.slaveAddr.address = mvBoardTwsiExpAddrGet(0); - twsiSlave.slaveAddr.type = ADDR7_BIT; - twsiSlave.validOffset = MV_TRUE; - /* Offset is the first command after the address which indicate the register number to be read - in next operation */ - twsiSlave.offset = 3; - twsiSlave.moreThen256 = MV_FALSE; - if(mode == MV_TRUE) - val = 0x10; - else - val = 0; - mvTwsiRead(0, &twsiSlave, &twsiVal, 1); - val = (twsiVal & 0xef) | val; - if( MV_OK != mvTwsiWrite (0, &twsiSlave, &val, 1) ) - { - DB(mvOsPrintf("Board: twsi exp out val fail\n")); - return MV_ERROR; - } - DB(mvOsPrintf("Board: twsi exp out val succeded\n")); - - /* Change twsi exp to output */ - twsiSlave.offset = 7; - mvTwsiRead(0, &twsiSlave, &twsiVal, 1); - val = (twsiVal & 0xef); - if( MV_OK != mvTwsiWrite (0, &twsiSlave, &val, 1) ) - { - DB(mvOsPrintf("Board: twsi exp change to out fail\n")); - return MV_ERROR; - } - DB(mvOsPrintf("Board: twsi exp change to out succeded\n")); - return MV_OK; -} - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/boardEnv/mvBoardEnvLib.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/boardEnv/mvBoardEnvLib.h deleted file mode 100644 index dead633..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/boardEnv/mvBoardEnvLib.h +++ /dev/null @@ -1,376 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ -#ifndef __INCmvBoardEnvLibh -#define __INCmvBoardEnvLibh - -/* defines */ -/* The below constant macros defines the board I2C EEPROM data offsets */ - - - -#include "ctrlEnv/mvCtrlEnvLib.h" -#include "mvSysHwConfig.h" -#include "boardEnv/mvBoardEnvSpec.h" - - -/* DUART stuff for Tclk detection only */ -#define DUART_BAUD_RATE 115200 -#define MAX_CLOCK_MARGINE 5000000 /* Maximum detected clock margine */ - -/* Voice devices assembly modes */ -#define DAISY_CHAIN_MODE 1 -#define DUAL_CHIP_SELECT_MODE 0 -#define INTERRUPT_TO_MPP 1 -#define INTERRUPT_TO_TDM 0 - - -#define BOARD_ETH_PORT_NUM MV_ETH_MAX_PORTS -#define BOARD_ETH_SWITCH_PORT_NUM 5 - -#define MV_BOARD_MAX_USB_IF 1 -#define MV_BOARD_MAX_MPP 7 -#define MV_BOARD_NAME_LEN 0x20 - -typedef struct _boardData -{ - MV_U32 magic; - MV_U16 boardId; - MV_U8 boardVer; - MV_U8 boardRev; - MV_U32 reserved1; - MV_U32 reserved2; - -}BOARD_DATA; - -typedef enum _devBoardMppGroupClass -{ - MV_BOARD_MPP_GROUP_1, - MV_BOARD_MPP_GROUP_2, - MV_BOARD_MAX_MPP_GROUP -}MV_BOARD_MPP_GROUP_CLASS; - -typedef enum _devBoardMppTypeClass -{ - MV_BOARD_AUTO, - MV_BOARD_TDM, - MV_BOARD_AUDIO, - MV_BOARD_RGMII, - MV_BOARD_GMII, - MV_BOARD_TS, - MV_BOARD_MII, - MV_BOARD_OTHER -}MV_BOARD_MPP_TYPE_CLASS; - -typedef enum _devBoardModuleIdClass -{ - MV_BOARD_MODULE_TDM_ID = 1, - MV_BOARD_MODULE_AUDIO_ID, - MV_BOARD_MODULE_RGMII_ID, - MV_BOARD_MODULE_GMII_ID, - MV_BOARD_MODULE_TS_ID, - MV_BOARD_MODULE_MII_ID, - MV_BOARD_MODULE_TDM_5CHAN_ID, - MV_BOARD_MODULE_OTHER_ID -}MV_BOARD_MODULE_ID_CLASS; - -typedef struct _boardMppTypeInfo -{ - MV_BOARD_MPP_TYPE_CLASS boardMppGroup1; - MV_BOARD_MPP_TYPE_CLASS boardMppGroup2; - -}MV_BOARD_MPP_TYPE_INFO; - - -typedef enum _devBoardClass -{ - BOARD_DEV_NOR_FLASH, - BOARD_DEV_NAND_FLASH, - BOARD_DEV_SEVEN_SEG, - BOARD_DEV_FPGA, - BOARD_DEV_SRAM, - BOARD_DEV_SPI_FLASH, - BOARD_DEV_OTHER, -}MV_BOARD_DEV_CLASS; - -typedef enum _devTwsiBoardClass -{ - BOARD_TWSI_RTC, - BOARD_DEV_TWSI_EXP, - BOARD_DEV_TWSI_SATR, - BOARD_TWSI_AUDIO_DEC, - BOARD_TWSI_OTHER -}MV_BOARD_TWSI_CLASS; - -typedef enum _devGppBoardClass -{ - BOARD_GPP_RTC, - BOARD_GPP_MV_SWITCH, - BOARD_GPP_USB_VBUS, - BOARD_GPP_USB_VBUS_EN, - BOARD_GPP_USB_OC, - BOARD_GPP_USB_HOST_DEVICE, - BOARD_GPP_REF_CLCK, - BOARD_GPP_VOIP_SLIC, - BOARD_GPP_LIFELINE, - BOARD_GPP_BUTTON, - BOARD_GPP_TS_BUTTON_C, - BOARD_GPP_TS_BUTTON_U, - BOARD_GPP_TS_BUTTON_D, - BOARD_GPP_TS_BUTTON_L, - BOARD_GPP_TS_BUTTON_R, - BOARD_GPP_POWER_BUTTON, - BOARD_GPP_RESTOR_BUTTON, - BOARD_GPP_WPS_BUTTON, - BOARD_GPP_HDD0_POWER, - BOARD_GPP_HDD1_POWER, - BOARD_GPP_FAN_POWER, - BOARD_GPP_RESET, - BOARD_GPP_POWER_ON_LED, - BOARD_GPP_HDD_POWER, - BOARD_GPP_SDIO_POWER, - BOARD_GPP_SDIO_DETECT, - BOARD_GPP_SDIO_WP, - BOARD_GPP_SWITCH_PHY_INT, - BOARD_GPP_TSU_DIRCTION, - BOARD_GPP_OTHER -}MV_BOARD_GPP_CLASS; - - -typedef struct _devCsInfo -{ - MV_U8 deviceCS; - MV_U32 params; - MV_U32 devClass; /* MV_BOARD_DEV_CLASS */ - MV_U8 devWidth; - -}MV_DEV_CS_INFO; - - -#define MV_BOARD_PHY_FORCE_10MB 0x0 -#define MV_BOARD_PHY_FORCE_100MB 0x1 -#define MV_BOARD_PHY_FORCE_1000MB 0x2 -#define MV_BOARD_PHY_SPEED_AUTO 0x3 - -typedef struct _boardSwitchInfo -{ - MV_32 linkStatusIrq; - MV_32 qdPort[BOARD_ETH_SWITCH_PORT_NUM]; - MV_32 qdCpuPort; - MV_32 smiScanMode; /* 1 for SMI_MANUAL_MODE, 0 otherwise */ - MV_32 switchOnPort; - -}MV_BOARD_SWITCH_INFO; - -typedef struct _boardLedInfo -{ - MV_U8 activeLedsNumber; - MV_U8 ledsPolarity; /* '0' or '1' to turn on led */ - MV_U8* gppPinNum; /* Pointer to GPP values */ - -}MV_BOARD_LED_INFO; - -typedef struct _boardGppInfo -{ - MV_BOARD_GPP_CLASS devClass; - MV_U8 gppPinNum; - -}MV_BOARD_GPP_INFO; - - -typedef struct _boardTwsiInfo -{ - MV_BOARD_TWSI_CLASS devClass; - MV_U8 twsiDevAddr; - MV_U8 twsiDevAddrType; - -}MV_BOARD_TWSI_INFO; - - -typedef enum _boardMacSpeed -{ - BOARD_MAC_SPEED_10M, - BOARD_MAC_SPEED_100M, - BOARD_MAC_SPEED_1000M, - BOARD_MAC_SPEED_AUTO, - -}MV_BOARD_MAC_SPEED; - -typedef struct _boardMacInfo -{ - MV_BOARD_MAC_SPEED boardMacSpeed; - MV_U8 boardEthSmiAddr; - -}MV_BOARD_MAC_INFO; - -typedef struct _boardMppInfo -{ - MV_U32 mppGroup[MV_BOARD_MAX_MPP]; - -}MV_BOARD_MPP_INFO; - -typedef struct _boardInfo -{ - char boardName[MV_BOARD_NAME_LEN]; - MV_U8 numBoardMppTypeValue; - MV_BOARD_MPP_TYPE_INFO* pBoardMppTypeValue; - MV_U8 numBoardMppConfigValue; - MV_BOARD_MPP_INFO* pBoardMppConfigValue; - MV_U32 intsGppMaskLow; - MV_U32 intsGppMaskHigh; - MV_U8 numBoardDeviceIf; - MV_DEV_CS_INFO* pDevCsInfo; - MV_U8 numBoardTwsiDev; - MV_BOARD_TWSI_INFO* pBoardTwsiDev; - MV_U8 numBoardMacInfo; - MV_BOARD_MAC_INFO* pBoardMacInfo; - MV_U8 numBoardGppInfo; - MV_BOARD_GPP_INFO* pBoardGppInfo; - MV_U8 activeLedsNumber; - MV_U8* pLedGppPin; - MV_U8 ledsPolarity; /* '0' or '1' to turn on led */ - /* GPP values */ - MV_U32 gppOutEnValLow; - MV_U32 gppOutEnValHigh; - MV_U32 gppOutValLow; - MV_U32 gppOutValHigh; - MV_U32 gppPolarityValLow; - MV_U32 gppPolarityValHigh; - - /* Switch Configuration */ - MV_BOARD_SWITCH_INFO* pSwitchInfo; -}MV_BOARD_INFO; - - - -MV_VOID mvBoardEnvInit(MV_VOID); -MV_U32 mvBoardIdGet(MV_VOID); -MV_U16 mvBoardModelGet(MV_VOID); -MV_U16 mvBoardRevGet(MV_VOID); -MV_STATUS mvBoardNameGet(char *pNameBuff); -MV_32 mvBoardPhyAddrGet(MV_U32 ethPortNum); -MV_BOARD_MAC_SPEED mvBoardMacSpeedGet(MV_U32 ethPortNum); -MV_32 mvBoardLinkStatusIrqGet(MV_U32 ethPortNum); -MV_32 mvBoardSwitchPortGet(MV_U32 ethPortNum, MV_U8 boardPortNum); -MV_32 mvBoardSwitchCpuPortGet(MV_U32 ethPortNum); -MV_32 mvBoardIsSwitchConnected(MV_U32 ethPortNum); -MV_32 mvBoardSmiScanModeGet(MV_U32 ethPortNum); -MV_BOOL mvBoardIsPortInSgmii(MV_U32 ethPortNum); -MV_BOOL mvBoardIsPortInGmii(MV_VOID); -MV_U32 mvBoardTclkGet(MV_VOID); -MV_U32 mvBoardSysClkGet(MV_VOID); -MV_U32 mvBoardDebugLedNumGet(MV_U32 boardId); -MV_VOID mvBoardDebugLed(MV_U32 hexNum); -MV_32 mvBoardMppGet(MV_U32 mppGroupNum); - -MV_U8 mvBoardRtcTwsiAddrTypeGet(MV_VOID); -MV_U8 mvBoardRtcTwsiAddrGet(MV_VOID); - -MV_U8 mvBoardA2DTwsiAddrTypeGet(MV_VOID); -MV_U8 mvBoardA2DTwsiAddrGet(MV_VOID); - -MV_U8 mvBoardTwsiExpAddrGet(MV_U32 index); -MV_U8 mvBoardTwsiSatRAddrTypeGet(MV_U32 index); -MV_U8 mvBoardTwsiSatRAddrGet(MV_U32 index); -MV_U8 mvBoardTwsiExpAddrTypeGet(MV_U32 index); -MV_BOARD_MODULE_ID_CLASS mvBoarModuleTypeGet(MV_BOARD_MPP_GROUP_CLASS devClass); -MV_BOARD_MPP_TYPE_CLASS mvBoardMppGroupTypeGet(MV_BOARD_MPP_GROUP_CLASS mppGroupClass); -MV_VOID mvBoardMppGroupTypeSet(MV_BOARD_MPP_GROUP_CLASS mppGroupClass, - MV_BOARD_MPP_TYPE_CLASS mppGroupType); -MV_VOID mvBoardMppGroupIdUpdate(MV_VOID); -MV_VOID mvBoardMppMuxSet(MV_VOID); -MV_VOID mvBoardTdmMppSet(MV_32 chType); -MV_VOID mvBoardVoiceConnModeGet(MV_32* connMode, MV_32* irqMode); - -MV_VOID mvBoardMppModuleTypePrint(MV_VOID); -MV_VOID mvBoardReset(MV_VOID); -MV_U8 mvBoarTwsiSatRGet(MV_U8 devNum, MV_U8 regNum); -MV_STATUS mvBoarTwsiSatRSet(MV_U8 devNum, MV_U8 regNum, MV_U8 regVal); -MV_BOOL mvBoardSpecInitGet(MV_U32* regOff, MV_U32* data); -/* Board devices API managments */ -MV_32 mvBoardGetDevicesNumber(MV_BOARD_DEV_CLASS devClass); -MV_32 mvBoardGetDeviceBaseAddr(MV_32 devNum, MV_BOARD_DEV_CLASS devClass); -MV_32 mvBoardGetDeviceBusWidth(MV_32 devNum, MV_BOARD_DEV_CLASS devClass); -MV_32 mvBoardGetDeviceWidth(MV_32 devNum, MV_BOARD_DEV_CLASS devClass); -MV_32 mvBoardGetDeviceWinSize(MV_32 devNum, MV_BOARD_DEV_CLASS devClass); -MV_U32 boardGetDevCSNum(MV_32 devNum, MV_BOARD_DEV_CLASS devClass); - -/* Gpio Pin Connections API */ -MV_32 mvBoardUSBVbusGpioPinGet(int devId); -MV_32 mvBoardUSBVbusEnGpioPinGet(int devId); -MV_U32 mvBoardPexBridgeIntPinGet(MV_U32 devNum, MV_U32 intPin); - -MV_32 mvBoardResetGpioPinGet(MV_VOID); -MV_32 mvBoardRTCGpioPinGet(MV_VOID); -MV_32 mvBoardGpioIntMaskLowGet(MV_VOID); -MV_32 mvBoardGpioIntMaskHighGet(MV_VOID); -MV_32 mvBoardSlicGpioPinGet(MV_U32 slicNum); - -MV_32 mvBoardSDIOGpioPinGet(MV_VOID); -MV_STATUS mvBoardSDioWPControl(MV_BOOL mode); -MV_32 mvBoarGpioPinNumGet(MV_BOARD_GPP_CLASS class, MV_U32 index); - -MV_32 mvBoardNandWidthGet(void); -MV_STATUS mvBoardFanPowerControl(MV_BOOL mode); -MV_STATUS mvBoardHDDPowerControl(MV_BOOL mode); -#endif /* __INCmvBoardEnvLibh */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/boardEnv/mvBoardEnvSpec.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/boardEnv/mvBoardEnvSpec.c deleted file mode 100644 index e256c4f..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/boardEnv/mvBoardEnvSpec.c +++ /dev/null @@ -1,848 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ -#include "mvCommon.h" -#include "mvBoardEnvLib.h" -#include "mvBoardEnvSpec.h" -#include "twsi/mvTwsi.h" - -#define DB_88F6281A_BOARD_PCI_IF_NUM 0x0 -#define DB_88F6281A_BOARD_TWSI_DEF_NUM 0x7 -#define DB_88F6281A_BOARD_MAC_INFO_NUM 0x2 -#define DB_88F6281A_BOARD_GPP_INFO_NUM 0x3 -#define DB_88F6281A_BOARD_MPP_CONFIG_NUM 0x1 -#define DB_88F6281A_BOARD_MPP_GROUP_TYPE_NUM 0x1 -#if defined(MV_NAND) && defined(MV_NAND_BOOT) - #define DB_88F6281A_BOARD_DEVICE_CONFIG_NUM 0x1 -#elif defined(MV_NAND) && defined(MV_SPI_BOOT) - #define DB_88F6281A_BOARD_DEVICE_CONFIG_NUM 0x2 -#else - #define DB_88F6281A_BOARD_DEVICE_CONFIG_NUM 0x1 -#endif -#define DB_88F6281A_BOARD_DEBUG_LED_NUM 0x0 - - -MV_BOARD_TWSI_INFO db88f6281AInfoBoardTwsiDev[] = - /* {{MV_BOARD_DEV_CLASS devClass, MV_U8 twsiDevAddr, MV_U8 twsiDevAddrType}} */ - { - {BOARD_DEV_TWSI_EXP, 0x20, ADDR7_BIT}, - {BOARD_DEV_TWSI_EXP, 0x21, ADDR7_BIT}, - {BOARD_DEV_TWSI_EXP, 0x27, ADDR7_BIT}, - {BOARD_DEV_TWSI_SATR, 0x4C, ADDR7_BIT}, - {BOARD_DEV_TWSI_SATR, 0x4D, ADDR7_BIT}, - {BOARD_DEV_TWSI_SATR, 0x4E, ADDR7_BIT}, - {BOARD_TWSI_AUDIO_DEC, 0x4A, ADDR7_BIT} - }; - -MV_BOARD_MAC_INFO db88f6281AInfoBoardMacInfo[] = - /* {{MV_BOARD_MAC_SPEED boardMacSpeed, MV_U8 boardEthSmiAddr}} */ - { - {BOARD_MAC_SPEED_AUTO, 0x8}, - {BOARD_MAC_SPEED_AUTO, 0x9} - }; - -MV_BOARD_MPP_TYPE_INFO db88f6281AInfoBoardMppTypeInfo[] = - /* {{MV_BOARD_MPP_TYPE_CLASS boardMppGroup1, - MV_BOARD_MPP_TYPE_CLASS boardMppGroup2}} */ - {{MV_BOARD_AUTO, MV_BOARD_AUTO} - }; - -MV_BOARD_GPP_INFO db88f6281AInfoBoardGppInfo[] = - /* {{MV_BOARD_GPP_CLASS devClass, MV_U8 gppPinNum}} */ - { - {BOARD_GPP_TSU_DIRCTION, 33} - /*muxed with TDM/Audio module via IOexpender - {BOARD_GPP_SDIO_DETECT, 38}, - {BOARD_GPP_USB_VBUS, 49}*/ - }; - -MV_DEV_CS_INFO db88f6281AInfoBoardDeCsInfo[] = - /*{deviceCS, params, devType, devWidth}*/ -#if defined(MV_NAND) && defined(MV_NAND_BOOT) - {{0, N_A, BOARD_DEV_NAND_FLASH, 8}}; /* NAND DEV */ -#elif defined(MV_NAND) && defined(MV_SPI_BOOT) - { - {0, N_A, BOARD_DEV_NAND_FLASH, 8}, /* NAND DEV */ - {1, N_A, BOARD_DEV_SPI_FLASH, 8}, /* SPI DEV */ - }; -#else - {{1, N_A, BOARD_DEV_SPI_FLASH, 8}}; /* SPI DEV */ -#endif - -MV_BOARD_MPP_INFO db88f6281AInfoBoardMppConfigValue[] = - {{{ - DB_88F6281A_MPP0_7, - DB_88F6281A_MPP8_15, - DB_88F6281A_MPP16_23, - DB_88F6281A_MPP24_31, - DB_88F6281A_MPP32_39, - DB_88F6281A_MPP40_47, - DB_88F6281A_MPP48_55 - }}}; - - -MV_BOARD_INFO db88f6281AInfo = { - "DB-88F6281A-BP", /* boardName[MAX_BOARD_NAME_LEN] */ - DB_88F6281A_BOARD_MPP_GROUP_TYPE_NUM, /* numBoardMppGroupType */ - db88f6281AInfoBoardMppTypeInfo, - DB_88F6281A_BOARD_MPP_CONFIG_NUM, /* numBoardMppConfig */ - db88f6281AInfoBoardMppConfigValue, - 0, /* intsGppMaskLow */ - 0, /* intsGppMaskHigh */ - DB_88F6281A_BOARD_DEVICE_CONFIG_NUM, /* numBoardDevIf */ - db88f6281AInfoBoardDeCsInfo, - DB_88F6281A_BOARD_TWSI_DEF_NUM, /* numBoardTwsiDev */ - db88f6281AInfoBoardTwsiDev, - DB_88F6281A_BOARD_MAC_INFO_NUM, /* numBoardMacInfo */ - db88f6281AInfoBoardMacInfo, - DB_88F6281A_BOARD_GPP_INFO_NUM, /* numBoardGppInfo */ - db88f6281AInfoBoardGppInfo, - DB_88F6281A_BOARD_DEBUG_LED_NUM, /* activeLedsNumber */ - NULL, - 0, /* ledsPolarity */ - DB_88F6281A_OE_LOW, /* gppOutEnLow */ - DB_88F6281A_OE_HIGH, /* gppOutEnHigh */ - DB_88F6281A_OE_VAL_LOW, /* gppOutValLow */ - DB_88F6281A_OE_VAL_HIGH, /* gppOutValHigh */ - 0, /* gppPolarityValLow */ - BIT6, /* gppPolarityValHigh */ - NULL /* pSwitchInfo */ -}; - - -#define RD_88F6281A_BOARD_PCI_IF_NUM 0x0 -#define RD_88F6281A_BOARD_TWSI_DEF_NUM 0x2 -#define RD_88F6281A_BOARD_MAC_INFO_NUM 0x2 -#define RD_88F6281A_BOARD_GPP_INFO_NUM 0x5 -#define RD_88F6281A_BOARD_MPP_GROUP_TYPE_NUM 0x1 -#define RD_88F6281A_BOARD_MPP_CONFIG_NUM 0x1 -#if defined(MV_NAND) && defined(MV_NAND_BOOT) - #define RD_88F6281A_BOARD_DEVICE_CONFIG_NUM 0x1 -#elif defined(MV_NAND) && defined(MV_SPI_BOOT) - #define RD_88F6281A_BOARD_DEVICE_CONFIG_NUM 0x2 -#else - #define RD_88F6281A_BOARD_DEVICE_CONFIG_NUM 0x1 -#endif -#define RD_88F6281A_BOARD_DEBUG_LED_NUM 0x0 - -MV_BOARD_MAC_INFO rd88f6281AInfoBoardMacInfo[] = - /* {{MV_BOARD_MAC_SPEED boardMacSpeed, MV_U8 boardEthSmiAddr}} */ - {{BOARD_MAC_SPEED_1000M, 0xa}, - {BOARD_MAC_SPEED_AUTO, 0xb} - }; - -MV_BOARD_SWITCH_INFO rd88f6281AInfoBoardSwitchInfo[] = - /* MV_32 linkStatusIrq, {MV_32 qdPort0, MV_32 qdPort1, MV_32 qdPort2, MV_32 qdPort3, MV_32 qdPort4}, - MV_32 qdCpuPort, MV_32 smiScanMode, MV_32 switchOnPort} */ - {{38, {0, 1, 2, 3, -1}, 5, 2, 0}, - {-1, {-1}, -1, -1, -1}}; - -MV_BOARD_TWSI_INFO rd88f6281AInfoBoardTwsiDev[] = - /* {{MV_BOARD_DEV_CLASS devClass, MV_U8 twsiDevAddr, MV_U8 twsiDevAddrType}} */ - { - {BOARD_DEV_TWSI_EXP, 0xFF, ADDR7_BIT}, /* dummy entry to align with modules indexes */ - {BOARD_DEV_TWSI_EXP, 0x27, ADDR7_BIT} - }; - -MV_BOARD_MPP_TYPE_INFO rd88f6281AInfoBoardMppTypeInfo[] = - {{MV_BOARD_RGMII, MV_BOARD_TDM} - }; - -MV_DEV_CS_INFO rd88f6281AInfoBoardDeCsInfo[] = - /*{deviceCS, params, devType, devWidth}*/ -#if defined(MV_NAND) && defined(MV_NAND_BOOT) - {{0, N_A, BOARD_DEV_NAND_FLASH, 8}}; /* NAND DEV */ -#elif defined(MV_NAND) && defined(MV_SPI_BOOT) - { - {0, N_A, BOARD_DEV_NAND_FLASH, 8}, /* NAND DEV */ - {1, N_A, BOARD_DEV_SPI_FLASH, 8}, /* SPI DEV */ - }; -#else - {{1, N_A, BOARD_DEV_SPI_FLASH, 8}}; /* SPI DEV */ -#endif - -MV_BOARD_GPP_INFO rd88f6281AInfoBoardGppInfo[] = - /* {{MV_BOARD_GPP_CLASS devClass, MV_U8 gppPinNum}} */ - {{BOARD_GPP_SDIO_DETECT, 28}, - {BOARD_GPP_USB_OC, 29}, - {BOARD_GPP_WPS_BUTTON, 35}, - {BOARD_GPP_MV_SWITCH, 38}, - {BOARD_GPP_USB_VBUS, 49} - }; - -MV_BOARD_MPP_INFO rd88f6281AInfoBoardMppConfigValue[] = - {{{ - RD_88F6281A_MPP0_7, - RD_88F6281A_MPP8_15, - RD_88F6281A_MPP16_23, - RD_88F6281A_MPP24_31, - RD_88F6281A_MPP32_39, - RD_88F6281A_MPP40_47, - RD_88F6281A_MPP48_55 - }}}; - -MV_BOARD_INFO rd88f6281AInfo = { - "RD-88F6281A", /* boardName[MAX_BOARD_NAME_LEN] */ - RD_88F6281A_BOARD_MPP_GROUP_TYPE_NUM, /* numBoardMppGroupType */ - rd88f6281AInfoBoardMppTypeInfo, - RD_88F6281A_BOARD_MPP_CONFIG_NUM, /* numBoardMppConfig */ - rd88f6281AInfoBoardMppConfigValue, - 0, /* intsGppMaskLow */ - (1 << 3), /* intsGppMaskHigh */ - RD_88F6281A_BOARD_DEVICE_CONFIG_NUM, /* numBoardDevIf */ - rd88f6281AInfoBoardDeCsInfo, - RD_88F6281A_BOARD_TWSI_DEF_NUM, /* numBoardTwsiDev */ - rd88f6281AInfoBoardTwsiDev, - RD_88F6281A_BOARD_MAC_INFO_NUM, /* numBoardMacInfo */ - rd88f6281AInfoBoardMacInfo, - RD_88F6281A_BOARD_GPP_INFO_NUM, /* numBoardGppInfo */ - rd88f6281AInfoBoardGppInfo, - RD_88F6281A_BOARD_DEBUG_LED_NUM, /* activeLedsNumber */ - NULL, - 0, /* ledsPolarity */ - RD_88F6281A_OE_LOW, /* gppOutEnLow */ - RD_88F6281A_OE_HIGH, /* gppOutEnHigh */ - RD_88F6281A_OE_VAL_LOW, /* gppOutValLow */ - RD_88F6281A_OE_VAL_HIGH, /* gppOutValHigh */ - 0, /* gppPolarityValLow */ - BIT6, /* gppPolarityValHigh */ - rd88f6281AInfoBoardSwitchInfo /* pSwitchInfo */ -}; - - -#define DB_88F6192A_BOARD_PCI_IF_NUM 0x0 -#define DB_88F6192A_BOARD_TWSI_DEF_NUM 0x7 -#define DB_88F6192A_BOARD_MAC_INFO_NUM 0x2 -#define DB_88F6192A_BOARD_GPP_INFO_NUM 0x3 -#define DB_88F6192A_BOARD_MPP_GROUP_TYPE_NUM 0x1 -#define DB_88F6192A_BOARD_MPP_CONFIG_NUM 0x1 -#if defined(MV_NAND) && defined(MV_NAND_BOOT) - #define DB_88F6192A_BOARD_DEVICE_CONFIG_NUM 0x1 -#elif defined(MV_NAND) && defined(MV_SPI_BOOT) - #define DB_88F6192A_BOARD_DEVICE_CONFIG_NUM 0x2 -#else - #define DB_88F6192A_BOARD_DEVICE_CONFIG_NUM 0x1 -#endif -#define DB_88F6192A_BOARD_DEBUG_LED_NUM 0x0 - -MV_BOARD_TWSI_INFO db88f6192AInfoBoardTwsiDev[] = - /* {{MV_BOARD_DEV_CLASS devClass, MV_U8 twsiDevAddr, MV_U8 twsiDevAddrType}} */ - { - {BOARD_DEV_TWSI_EXP, 0x20, ADDR7_BIT}, - {BOARD_DEV_TWSI_EXP, 0x21, ADDR7_BIT}, - {BOARD_DEV_TWSI_EXP, 0x27, ADDR7_BIT}, - {BOARD_DEV_TWSI_SATR, 0x4C, ADDR7_BIT}, - {BOARD_DEV_TWSI_SATR, 0x4D, ADDR7_BIT}, - {BOARD_DEV_TWSI_SATR, 0x4E, ADDR7_BIT}, - {BOARD_TWSI_AUDIO_DEC, 0x4A, ADDR7_BIT} - }; - -MV_BOARD_MAC_INFO db88f6192AInfoBoardMacInfo[] = - /* {{MV_BOARD_MAC_SPEED boardMacSpeed, MV_U8 boardEthSmiAddr}} */ - { - {BOARD_MAC_SPEED_AUTO, 0x8}, - {BOARD_MAC_SPEED_AUTO, 0x9} - }; - -MV_BOARD_MPP_TYPE_INFO db88f6192AInfoBoardMppTypeInfo[] = - /* {{MV_BOARD_MPP_TYPE_CLASS boardMppGroup1, - MV_BOARD_MPP_TYPE_CLASS boardMppGroup2}} */ - {{MV_BOARD_AUTO, MV_BOARD_OTHER} - }; - -MV_DEV_CS_INFO db88f6192AInfoBoardDeCsInfo[] = - /*{deviceCS, params, devType, devWidth}*/ -#if defined(MV_NAND) && defined(MV_NAND_BOOT) - {{0, N_A, BOARD_DEV_NAND_FLASH, 8}}; /* NAND DEV */ -#elif defined(MV_NAND) && defined(MV_SPI_BOOT) - { - {0, N_A, BOARD_DEV_NAND_FLASH, 8}, /* NAND DEV */ - {1, N_A, BOARD_DEV_SPI_FLASH, 8}, /* SPI DEV */ - }; -#else - {{1, N_A, BOARD_DEV_SPI_FLASH, 8}}; /* SPI DEV */ -#endif - -MV_BOARD_GPP_INFO db88f6192AInfoBoardGppInfo[] = - /* {{MV_BOARD_GPP_CLASS devClass, MV_U8 gppPinNum}} */ - { - {BOARD_GPP_SDIO_WP, 20}, - {BOARD_GPP_USB_VBUS, 22}, - {BOARD_GPP_SDIO_DETECT, 23}, - }; - -MV_BOARD_MPP_INFO db88f6192AInfoBoardMppConfigValue[] = - {{{ - DB_88F6192A_MPP0_7, - DB_88F6192A_MPP8_15, - DB_88F6192A_MPP16_23, - DB_88F6192A_MPP24_31, - DB_88F6192A_MPP32_35 - }}}; - -MV_BOARD_INFO db88f6192AInfo = { - "DB-88F6192A-BP", /* boardName[MAX_BOARD_NAME_LEN] */ - DB_88F6192A_BOARD_MPP_GROUP_TYPE_NUM, /* numBoardMppGroupType */ - db88f6192AInfoBoardMppTypeInfo, - DB_88F6192A_BOARD_MPP_CONFIG_NUM, /* numBoardMppConfig */ - db88f6192AInfoBoardMppConfigValue, - 0, /* intsGppMaskLow */ - (1 << 3), /* intsGppMaskHigh */ - DB_88F6192A_BOARD_DEVICE_CONFIG_NUM, /* numBoardDevIf */ - db88f6192AInfoBoardDeCsInfo, - DB_88F6192A_BOARD_TWSI_DEF_NUM, /* numBoardTwsiDev */ - db88f6192AInfoBoardTwsiDev, - DB_88F6192A_BOARD_MAC_INFO_NUM, /* numBoardMacInfo */ - db88f6192AInfoBoardMacInfo, - DB_88F6192A_BOARD_GPP_INFO_NUM, /* numBoardGppInfo */ - db88f6192AInfoBoardGppInfo, - DB_88F6192A_BOARD_DEBUG_LED_NUM, /* activeLedsNumber */ - NULL, - 0, /* ledsPolarity */ - DB_88F6192A_OE_LOW, /* gppOutEnLow */ - DB_88F6192A_OE_HIGH, /* gppOutEnHigh */ - DB_88F6192A_OE_VAL_LOW, /* gppOutValLow */ - DB_88F6192A_OE_VAL_HIGH, /* gppOutValHigh */ - 0, /* gppPolarityValLow */ - 0, /* gppPolarityValHigh */ - NULL /* pSwitchInfo */ -}; - -#define DB_88F6190A_BOARD_MAC_INFO_NUM 0x1 - -MV_BOARD_INFO db88f6190AInfo = { - "DB-88F6190A-BP", /* boardName[MAX_BOARD_NAME_LEN] */ - DB_88F6192A_BOARD_MPP_GROUP_TYPE_NUM, /* numBoardMppGroupType */ - db88f6192AInfoBoardMppTypeInfo, - DB_88F6192A_BOARD_MPP_CONFIG_NUM, /* numBoardMppConfig */ - db88f6192AInfoBoardMppConfigValue, - 0, /* intsGppMaskLow */ - (1 << 3), /* intsGppMaskHigh */ - DB_88F6192A_BOARD_DEVICE_CONFIG_NUM, /* numBoardDevIf */ - db88f6192AInfoBoardDeCsInfo, - DB_88F6192A_BOARD_TWSI_DEF_NUM, /* numBoardTwsiDev */ - db88f6192AInfoBoardTwsiDev, - DB_88F6190A_BOARD_MAC_INFO_NUM, /* numBoardMacInfo */ - db88f6192AInfoBoardMacInfo, - DB_88F6192A_BOARD_GPP_INFO_NUM, /* numBoardGppInfo */ - db88f6192AInfoBoardGppInfo, - DB_88F6192A_BOARD_DEBUG_LED_NUM, /* activeLedsNumber */ - NULL, - 0, /* ledsPolarity */ - DB_88F6192A_OE_LOW, /* gppOutEnLow */ - DB_88F6192A_OE_HIGH, /* gppOutEnHigh */ - DB_88F6192A_OE_VAL_LOW, /* gppOutValLow */ - DB_88F6192A_OE_VAL_HIGH, /* gppOutValHigh */ - 0, /* gppPolarityValLow */ - 0, /* gppPolarityValHigh */ - NULL /* pSwitchInfo */ -}; - -#define RD_88F6192A_BOARD_PCI_IF_NUM 0x0 -#define RD_88F6192A_BOARD_TWSI_DEF_NUM 0x0 -#define RD_88F6192A_BOARD_MAC_INFO_NUM 0x1 -#define RD_88F6192A_BOARD_GPP_INFO_NUM 0xE -#define RD_88F6192A_BOARD_MPP_GROUP_TYPE_NUM 0x1 -#define RD_88F6192A_BOARD_MPP_CONFIG_NUM 0x1 -#define RD_88F6192A_BOARD_DEVICE_CONFIG_NUM 0x1 -#define RD_88F6192A_BOARD_DEBUG_LED_NUM 0x3 - -MV_U8 rd88f6192AInfoBoardDebugLedIf[] = - {17, 28, 29}; - -MV_BOARD_MAC_INFO rd88f6192AInfoBoardMacInfo[] = - /* {{MV_BOARD_MAC_SPEED boardMacSpeed, MV_U8 boardEthSmiAddr}} */ - {{BOARD_MAC_SPEED_AUTO, 0x8} - }; - -MV_BOARD_MPP_TYPE_INFO rd88f6192AInfoBoardMppTypeInfo[] = - /* {{MV_BOARD_MPP_TYPE_CLASS boardMppGroup1, - MV_BOARD_MPP_TYPE_CLASS boardMppGroup2}} */ - {{MV_BOARD_OTHER, MV_BOARD_OTHER} - }; - -MV_DEV_CS_INFO rd88f6192AInfoBoardDeCsInfo[] = - /*{deviceCS, params, devType, devWidth}*/ - {{1, N_A, BOARD_DEV_SPI_FLASH, 8}}; /* SPI DEV */ - -MV_BOARD_GPP_INFO rd88f6192AInfoBoardGppInfo[] = - /* {{MV_BOARD_GPP_CLASS devClass, MV_U8 gppPinNum}} */ - { - {BOARD_GPP_USB_VBUS_EN, 10}, - {BOARD_GPP_USB_HOST_DEVICE, 11}, - {BOARD_GPP_RESET, 14}, - {BOARD_GPP_POWER_ON_LED, 15}, - {BOARD_GPP_HDD_POWER, 16}, - {BOARD_GPP_WPS_BUTTON, 24}, - {BOARD_GPP_TS_BUTTON_C, 25}, - {BOARD_GPP_USB_VBUS, 26}, - {BOARD_GPP_USB_OC, 27}, - {BOARD_GPP_TS_BUTTON_U, 30}, - {BOARD_GPP_TS_BUTTON_R, 31}, - {BOARD_GPP_TS_BUTTON_L, 32}, - {BOARD_GPP_TS_BUTTON_D, 34}, - {BOARD_GPP_FAN_POWER, 35} - }; - -MV_BOARD_MPP_INFO rd88f6192AInfoBoardMppConfigValue[] = - {{{ - RD_88F6192A_MPP0_7, - RD_88F6192A_MPP8_15, - RD_88F6192A_MPP16_23, - RD_88F6192A_MPP24_31, - RD_88F6192A_MPP32_35 - }}}; - -MV_BOARD_INFO rd88f6192AInfo = { - "RD-88F6192A-NAS", /* boardName[MAX_BOARD_NAME_LEN] */ - RD_88F6192A_BOARD_MPP_GROUP_TYPE_NUM, /* numBoardMppGroupType */ - rd88f6192AInfoBoardMppTypeInfo, - RD_88F6192A_BOARD_MPP_CONFIG_NUM, /* numBoardMppConfig */ - rd88f6192AInfoBoardMppConfigValue, - 0, /* intsGppMaskLow */ - (1 << 3), /* intsGppMaskHigh */ - RD_88F6192A_BOARD_DEVICE_CONFIG_NUM, /* numBoardDevIf */ - rd88f6192AInfoBoardDeCsInfo, - RD_88F6192A_BOARD_TWSI_DEF_NUM, /* numBoardTwsiDev */ - NULL, - RD_88F6192A_BOARD_MAC_INFO_NUM, /* numBoardMacInfo */ - rd88f6192AInfoBoardMacInfo, - RD_88F6192A_BOARD_GPP_INFO_NUM, /* numBoardGppInfo */ - rd88f6192AInfoBoardGppInfo, - RD_88F6192A_BOARD_DEBUG_LED_NUM, /* activeLedsNumber */ - rd88f6192AInfoBoardDebugLedIf, - 0, /* ledsPolarity */ - RD_88F6192A_OE_LOW, /* gppOutEnLow */ - RD_88F6192A_OE_HIGH, /* gppOutEnHigh */ - RD_88F6192A_OE_VAL_LOW, /* gppOutValLow */ - RD_88F6192A_OE_VAL_HIGH, /* gppOutValHigh */ - 0, /* gppPolarityValLow */ - 0, /* gppPolarityValHigh */ - NULL /* pSwitchInfo */ -}; - -MV_BOARD_INFO rd88f6190AInfo = { - "RD-88F6190A-NAS", /* boardName[MAX_BOARD_NAME_LEN] */ - RD_88F6192A_BOARD_MPP_GROUP_TYPE_NUM, /* numBoardMppGroupType */ - rd88f6192AInfoBoardMppTypeInfo, - RD_88F6192A_BOARD_MPP_CONFIG_NUM, /* numBoardMppConfig */ - rd88f6192AInfoBoardMppConfigValue, - 0, /* intsGppMaskLow */ - (1 << 3), /* intsGppMaskHigh */ - RD_88F6192A_BOARD_DEVICE_CONFIG_NUM, /* numBoardDevIf */ - rd88f6192AInfoBoardDeCsInfo, - RD_88F6192A_BOARD_TWSI_DEF_NUM, /* numBoardTwsiDev */ - NULL, - RD_88F6192A_BOARD_MAC_INFO_NUM, /* numBoardMacInfo */ - rd88f6192AInfoBoardMacInfo, - RD_88F6192A_BOARD_GPP_INFO_NUM, /* numBoardGppInfo */ - rd88f6192AInfoBoardGppInfo, - RD_88F6192A_BOARD_DEBUG_LED_NUM, /* activeLedsNumber */ - rd88f6192AInfoBoardDebugLedIf, - 0, /* ledsPolarity */ - RD_88F6192A_OE_LOW, /* gppOutEnLow */ - RD_88F6192A_OE_HIGH, /* gppOutEnHigh */ - RD_88F6192A_OE_VAL_LOW, /* gppOutValLow */ - RD_88F6192A_OE_VAL_HIGH, /* gppOutValHigh */ - 0, /* gppPolarityValLow */ - 0, /* gppPolarityValHigh */ - NULL /* pSwitchInfo */ -}; - -#define DB_88F6180A_BOARD_PCI_IF_NUM 0x0 -#define DB_88F6180A_BOARD_TWSI_DEF_NUM 0x5 -#define DB_88F6180A_BOARD_MAC_INFO_NUM 0x1 -#define DB_88F6180A_BOARD_GPP_INFO_NUM 0x0 -#define DB_88F6180A_BOARD_MPP_GROUP_TYPE_NUM 0x2 -#define DB_88F6180A_BOARD_MPP_CONFIG_NUM 0x1 -#define DB_88F6180A_BOARD_DEVICE_CONFIG_NUM 0x1 -#define DB_88F6180A_BOARD_DEBUG_LED_NUM 0x0 - -MV_BOARD_TWSI_INFO db88f6180AInfoBoardTwsiDev[] = - /* {{MV_BOARD_DEV_CLASS devClass, MV_U8 twsiDevAddr, MV_U8 twsiDevAddrType}} */ - { - {BOARD_DEV_TWSI_EXP, 0x20, ADDR7_BIT}, - {BOARD_DEV_TWSI_EXP, 0x21, ADDR7_BIT}, - {BOARD_DEV_TWSI_EXP, 0x27, ADDR7_BIT}, - {BOARD_DEV_TWSI_SATR, 0x4C, ADDR7_BIT}, - {BOARD_TWSI_AUDIO_DEC, 0x4A, ADDR7_BIT} - }; - -MV_BOARD_MAC_INFO db88f6180AInfoBoardMacInfo[] = - /* {{MV_BOARD_MAC_SPEED boardMacSpeed, MV_U8 boardEthSmiAddr}} */ - {{BOARD_MAC_SPEED_AUTO, 0x8} - }; - -MV_BOARD_GPP_INFO db88f6180AInfoBoardGppInfo[] = - /* {{MV_BOARD_GPP_CLASS devClass, MV_U8 gppPinNum}} */ - { - /* Muxed with TDM/Audio module via IOexpender - {BOARD_GPP_USB_VBUS, 6} */ - }; - -MV_BOARD_MPP_TYPE_INFO db88f6180AInfoBoardMppTypeInfo[] = - /* {{MV_BOARD_MPP_TYPE_CLASS boardMppGroup1, - MV_BOARD_MPP_TYPE_CLASS boardMppGroup2}} */ - {{MV_BOARD_OTHER, MV_BOARD_AUTO} - }; - -MV_DEV_CS_INFO db88f6180AInfoBoardDeCsInfo[] = - /*{deviceCS, params, devType, devWidth}*/ -#if defined(MV_NAND_BOOT) - {{0, N_A, BOARD_DEV_NAND_FLASH, 8}}; /* NAND DEV */ -#else - {{1, N_A, BOARD_DEV_SPI_FLASH, 8}}; /* SPI DEV */ -#endif - -MV_BOARD_MPP_INFO db88f6180AInfoBoardMppConfigValue[] = - {{{ - DB_88F6180A_MPP0_7, - DB_88F6180A_MPP8_15, - DB_88F6180A_MPP16_23, - DB_88F6180A_MPP24_31, - DB_88F6180A_MPP32_39, - DB_88F6180A_MPP40_44 - }}}; - -MV_BOARD_INFO db88f6180AInfo = { - "DB-88F6180A-BP", /* boardName[MAX_BOARD_NAME_LEN] */ - DB_88F6180A_BOARD_MPP_GROUP_TYPE_NUM, /* numBoardMppGroupType */ - db88f6180AInfoBoardMppTypeInfo, - DB_88F6180A_BOARD_MPP_CONFIG_NUM, /* numBoardMppConfig */ - db88f6180AInfoBoardMppConfigValue, - 0, /* intsGppMaskLow */ - 0, /* intsGppMaskHigh */ - DB_88F6180A_BOARD_DEVICE_CONFIG_NUM, /* numBoardDevIf */ - db88f6180AInfoBoardDeCsInfo, - DB_88F6180A_BOARD_TWSI_DEF_NUM, /* numBoardTwsiDev */ - db88f6180AInfoBoardTwsiDev, - DB_88F6180A_BOARD_MAC_INFO_NUM, /* numBoardMacInfo */ - db88f6180AInfoBoardMacInfo, - DB_88F6180A_BOARD_GPP_INFO_NUM, /* numBoardGppInfo */ - NULL, - DB_88F6180A_BOARD_DEBUG_LED_NUM, /* activeLedsNumber */ - NULL, - 0, /* ledsPolarity */ - DB_88F6180A_OE_LOW, /* gppOutEnLow */ - DB_88F6180A_OE_HIGH, /* gppOutEnHigh */ - DB_88F6180A_OE_VAL_LOW, /* gppOutValLow */ - DB_88F6180A_OE_VAL_HIGH, /* gppOutValHigh */ - 0, /* gppPolarityValLow */ - 0, /* gppPolarityValHigh */ - NULL /* pSwitchInfo */ -}; - - -#define RD_88F6281A_PCAC_BOARD_PCI_IF_NUM 0x0 -#define RD_88F6281A_PCAC_BOARD_TWSI_DEF_NUM 0x1 -#define RD_88F6281A_PCAC_BOARD_MAC_INFO_NUM 0x1 -#define RD_88F6281A_PCAC_BOARD_GPP_INFO_NUM 0x0 -#define RD_88F6281A_PCAC_BOARD_MPP_GROUP_TYPE_NUM 0x1 -#define RD_88F6281A_PCAC_BOARD_MPP_CONFIG_NUM 0x1 -#if defined(MV_NAND) && defined(MV_NAND_BOOT) - #define RD_88F6281A_PCAC_BOARD_DEVICE_CONFIG_NUM 0x1 -#elif defined(MV_NAND) && defined(MV_SPI_BOOT) - #define RD_88F6281A_PCAC_BOARD_DEVICE_CONFIG_NUM 0x2 -#else - #define RD_88F6281A_PCAC_BOARD_DEVICE_CONFIG_NUM 0x1 -#endif -#define RD_88F6281A_PCAC_BOARD_DEBUG_LED_NUM 0x4 - -MV_U8 rd88f6281APcacInfoBoardDebugLedIf[] = - {38, 39, 40, 41}; - -MV_BOARD_MAC_INFO rd88f6281APcacInfoBoardMacInfo[] = - /* {{MV_BOARD_MAC_SPEED boardMacSpeed, MV_U8 boardEthSmiAddr}} */ - {{BOARD_MAC_SPEED_AUTO, 0x8} - }; - -MV_BOARD_TWSI_INFO rd88f6281APcacInfoBoardTwsiDev[] = - /* {{MV_BOARD_DEV_CLASS devClass, MV_U8 twsiDevAddr, MV_U8 twsiDevAddrType}} */ - { - {BOARD_TWSI_OTHER, 0xa7, ADDR7_BIT} - }; - -MV_BOARD_MPP_TYPE_INFO rd88f6281APcacInfoBoardMppTypeInfo[] = - {{MV_BOARD_OTHER, MV_BOARD_OTHER} - }; - -MV_DEV_CS_INFO rd88f6281APcacInfoBoardDeCsInfo[] = - /*{deviceCS, params, devType, devWidth}*/ -#if defined(MV_NAND) && defined(MV_NAND_BOOT) - {{0, N_A, BOARD_DEV_NAND_FLASH, 8}}; /* NAND DEV */ -#elif defined(MV_NAND) && defined(MV_SPI_BOOT) - { - {0, N_A, BOARD_DEV_NAND_FLASH, 8}, /* NAND DEV */ - {1, N_A, BOARD_DEV_SPI_FLASH, 8}, /* SPI DEV */ - }; -#else - {{1, N_A, BOARD_DEV_SPI_FLASH, 8}}; /* SPI DEV */ -#endif - -MV_BOARD_MPP_INFO rd88f6281APcacInfoBoardMppConfigValue[] = - {{{ - RD_88F6281A_PCAC_MPP0_7, - RD_88F6281A_PCAC_MPP8_15, - RD_88F6281A_PCAC_MPP16_23, - RD_88F6281A_PCAC_MPP24_31, - RD_88F6281A_PCAC_MPP32_39, - RD_88F6281A_PCAC_MPP40_47, - RD_88F6281A_PCAC_MPP48_55 - }}}; - -MV_BOARD_INFO rd88f6281APcacInfo = { - "RD-88F6281A-PCAC", /* boardName[MAX_BOARD_NAME_LEN] */ - RD_88F6281A_PCAC_BOARD_MPP_GROUP_TYPE_NUM, /* numBoardMppGroupType */ - rd88f6281APcacInfoBoardMppTypeInfo, - RD_88F6281A_PCAC_BOARD_MPP_CONFIG_NUM, /* numBoardMppConfig */ - rd88f6281APcacInfoBoardMppConfigValue, - 0, /* intsGppMaskLow */ - (1 << 3), /* intsGppMaskHigh */ - RD_88F6281A_PCAC_BOARD_DEVICE_CONFIG_NUM, /* numBoardDevIf */ - rd88f6281APcacInfoBoardDeCsInfo, - RD_88F6281A_PCAC_BOARD_TWSI_DEF_NUM, /* numBoardTwsiDev */ - rd88f6281APcacInfoBoardTwsiDev, - RD_88F6281A_PCAC_BOARD_MAC_INFO_NUM, /* numBoardMacInfo */ - rd88f6281APcacInfoBoardMacInfo, - RD_88F6281A_PCAC_BOARD_GPP_INFO_NUM, /* numBoardGppInfo */ - 0, - RD_88F6281A_PCAC_BOARD_DEBUG_LED_NUM, /* activeLedsNumber */ - NULL, - 0, /* ledsPolarity */ - RD_88F6281A_PCAC_OE_LOW, /* gppOutEnLow */ - RD_88F6281A_PCAC_OE_HIGH, /* gppOutEnHigh */ - RD_88F6281A_PCAC_OE_VAL_LOW, /* gppOutValLow */ - RD_88F6281A_PCAC_OE_VAL_HIGH, /* gppOutValHigh */ - 0, /* gppPolarityValLow */ - 0, /* gppPolarityValHigh */ - NULL /* pSwitchInfo */ -}; - - -/* 6281 Sheeva Plug*/ - -#define SHEEVA_PLUG_BOARD_PCI_IF_NUM 0x0 -#define SHEEVA_PLUG_BOARD_TWSI_DEF_NUM 0x0 -#define SHEEVA_PLUG_BOARD_MAC_INFO_NUM 0x1 -#define SHEEVA_PLUG_BOARD_GPP_INFO_NUM 0x0 -#define SHEEVA_PLUG_BOARD_MPP_GROUP_TYPE_NUN 0x1 -#define SHEEVA_PLUG_BOARD_MPP_CONFIG_NUM 0x1 -#define SHEEVA_PLUG_BOARD_DEVICE_CONFIG_NUM 0x1 -#define SHEEVA_PLUG_BOARD_DEBUG_LED_NUM 0x1 - -MV_U8 sheevaPlugInfoBoardDebugLedIf[] = - {49}; - -MV_BOARD_MAC_INFO sheevaPlugInfoBoardMacInfo[] = - /* {{MV_BOARD_MAC_SPEED boardMacSpeed, MV_U8 boardEthSmiAddr}} */ - {{BOARD_MAC_SPEED_AUTO, 0x0}}; - -MV_BOARD_TWSI_INFO sheevaPlugInfoBoardTwsiDev[] = - /* {{MV_BOARD_DEV_CLASS devClass, MV_U8 twsiDevAddr, MV_U8 twsiDevAddrType}} */ - {{BOARD_TWSI_OTHER, 0x0, ADDR7_BIT}}; - -MV_BOARD_MPP_TYPE_INFO sheevaPlugInfoBoardMppTypeInfo[] = - {{MV_BOARD_OTHER, MV_BOARD_OTHER} - }; - -MV_DEV_CS_INFO sheevaPlugInfoBoardDeCsInfo[] = - /*{deviceCS, params, devType, devWidth}*/ - {{0, N_A, BOARD_DEV_NAND_FLASH, 8}}; /* NAND DEV */ - -MV_BOARD_MPP_INFO sheevaPlugInfoBoardMppConfigValue[] = - {{{ - RD_SHEEVA_PLUG_MPP0_7, - RD_SHEEVA_PLUG_MPP8_15, - RD_SHEEVA_PLUG_MPP16_23, - RD_SHEEVA_PLUG_MPP24_31, - RD_SHEEVA_PLUG_MPP32_39, - RD_SHEEVA_PLUG_MPP40_47, - RD_SHEEVA_PLUG_MPP48_55 - }}}; - -MV_BOARD_INFO sheevaPlugInfo = { - "SHEEVA PLUG", /* boardName[MAX_BOARD_NAME_LEN] */ - SHEEVA_PLUG_BOARD_MPP_GROUP_TYPE_NUN, /* numBoardMppGroupType */ - sheevaPlugInfoBoardMppTypeInfo, - SHEEVA_PLUG_BOARD_MPP_CONFIG_NUM, /* numBoardMppConfig */ - sheevaPlugInfoBoardMppConfigValue, - 0, /* intsGppMaskLow */ - 0, /* intsGppMaskHigh */ - SHEEVA_PLUG_BOARD_DEVICE_CONFIG_NUM, /* numBoardDevIf */ - sheevaPlugInfoBoardDeCsInfo, - SHEEVA_PLUG_BOARD_TWSI_DEF_NUM, /* numBoardTwsiDev */ - sheevaPlugInfoBoardTwsiDev, - SHEEVA_PLUG_BOARD_MAC_INFO_NUM, /* numBoardMacInfo */ - sheevaPlugInfoBoardMacInfo, - SHEEVA_PLUG_BOARD_GPP_INFO_NUM, /* numBoardGppInfo */ - 0, - SHEEVA_PLUG_BOARD_DEBUG_LED_NUM, /* activeLedsNumber */ - sheevaPlugInfoBoardDebugLedIf, - 0, /* ledsPolarity */ - RD_SHEEVA_PLUG_OE_LOW, /* gppOutEnLow */ - RD_SHEEVA_PLUG_OE_HIGH, /* gppOutEnHigh */ - RD_SHEEVA_PLUG_OE_VAL_LOW, /* gppOutValLow */ - RD_SHEEVA_PLUG_OE_VAL_HIGH, /* gppOutValHigh */ - 0, /* gppPolarityValLow */ - 0, /* gppPolarityValHigh */ - NULL /* pSwitchInfo */ -}; - -/* Customer specific board place holder*/ - -#define DB_CUSTOMER_BOARD_PCI_IF_NUM 0x0 -#define DB_CUSTOMER_BOARD_TWSI_DEF_NUM 0x0 -#define DB_CUSTOMER_BOARD_MAC_INFO_NUM 0x0 -#define DB_CUSTOMER_BOARD_GPP_INFO_NUM 0x0 -#define DB_CUSTOMER_BOARD_MPP_GROUP_TYPE_NUN 0x0 -#define DB_CUSTOMER_BOARD_MPP_CONFIG_NUM 0x0 -#if defined(MV_NAND) && defined(MV_NAND_BOOT) - #define DB_CUSTOMER_BOARD_DEVICE_CONFIG_NUM 0x0 -#elif defined(MV_NAND) && defined(MV_SPI_BOOT) - #define DB_CUSTOMER_BOARD_DEVICE_CONFIG_NUM 0x0 -#else - #define DB_CUSTOMER_BOARD_DEVICE_CONFIG_NUM 0x0 -#endif -#define DB_CUSTOMER_BOARD_DEBUG_LED_NUM 0x0 - -MV_U8 dbCustomerInfoBoardDebugLedIf[] = - {0}; - -MV_BOARD_MAC_INFO dbCustomerInfoBoardMacInfo[] = - /* {{MV_BOARD_MAC_SPEED boardMacSpeed, MV_U8 boardEthSmiAddr}} */ - {{BOARD_MAC_SPEED_AUTO, 0x0}}; - -MV_BOARD_TWSI_INFO dbCustomerInfoBoardTwsiDev[] = - /* {{MV_BOARD_DEV_CLASS devClass, MV_U8 twsiDevAddr, MV_U8 twsiDevAddrType}} */ - {{BOARD_TWSI_OTHER, 0x0, ADDR7_BIT}}; - -MV_BOARD_MPP_TYPE_INFO dbCustomerInfoBoardMppTypeInfo[] = - {{MV_BOARD_OTHER, MV_BOARD_OTHER} - }; - -MV_DEV_CS_INFO dbCustomerInfoBoardDeCsInfo[] = - /*{deviceCS, params, devType, devWidth}*/ -#if defined(MV_NAND) && defined(MV_NAND_BOOT) - {{0, N_A, BOARD_DEV_NAND_FLASH, 8}}; /* NAND DEV */ -#elif defined(MV_NAND) && defined(MV_SPI_BOOT) - { - {0, N_A, BOARD_DEV_NAND_FLASH, 8}, /* NAND DEV */ - {2, N_A, BOARD_DEV_SPI_FLASH, 8}, /* SPI DEV */ - }; -#else - {{2, N_A, BOARD_DEV_SPI_FLASH, 8}}; /* SPI DEV */ -#endif - -MV_BOARD_MPP_INFO dbCustomerInfoBoardMppConfigValue[] = - {{{ - DB_CUSTOMER_MPP0_7, - DB_CUSTOMER_MPP8_15, - DB_CUSTOMER_MPP16_23, - DB_CUSTOMER_MPP24_31, - DB_CUSTOMER_MPP32_39, - DB_CUSTOMER_MPP40_47, - DB_CUSTOMER_MPP48_55 - }}}; - -MV_BOARD_INFO dbCustomerInfo = { - "DB-CUSTOMER", /* boardName[MAX_BOARD_NAME_LEN] */ - DB_CUSTOMER_BOARD_MPP_GROUP_TYPE_NUN, /* numBoardMppGroupType */ - dbCustomerInfoBoardMppTypeInfo, - DB_CUSTOMER_BOARD_MPP_CONFIG_NUM, /* numBoardMppConfig */ - dbCustomerInfoBoardMppConfigValue, - 0, /* intsGppMaskLow */ - 0, /* intsGppMaskHigh */ - DB_CUSTOMER_BOARD_DEVICE_CONFIG_NUM, /* numBoardDevIf */ - dbCustomerInfoBoardDeCsInfo, - DB_CUSTOMER_BOARD_TWSI_DEF_NUM, /* numBoardTwsiDev */ - dbCustomerInfoBoardTwsiDev, - DB_CUSTOMER_BOARD_MAC_INFO_NUM, /* numBoardMacInfo */ - dbCustomerInfoBoardMacInfo, - DB_CUSTOMER_BOARD_GPP_INFO_NUM, /* numBoardGppInfo */ - 0, - DB_CUSTOMER_BOARD_DEBUG_LED_NUM, /* activeLedsNumber */ - NULL, - 0, /* ledsPolarity */ - DB_CUSTOMER_OE_LOW, /* gppOutEnLow */ - DB_CUSTOMER_OE_HIGH, /* gppOutEnHigh */ - DB_CUSTOMER_OE_VAL_LOW, /* gppOutValLow */ - DB_CUSTOMER_OE_VAL_HIGH, /* gppOutValHigh */ - 0, /* gppPolarityValLow */ - 0, /* gppPolarityValHigh */ - NULL /* pSwitchInfo */ -}; - -MV_BOARD_INFO* boardInfoTbl[] = { - &db88f6281AInfo, - &rd88f6281AInfo, - &db88f6192AInfo, - &rd88f6192AInfo, - &db88f6180AInfo, - &db88f6190AInfo, - &rd88f6190AInfo, - &rd88f6281APcacInfo, - &dbCustomerInfo, - &sheevaPlugInfo - }; - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/boardEnv/mvBoardEnvSpec.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/boardEnv/mvBoardEnvSpec.h deleted file mode 100644 index 0372eee..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/boardEnv/mvBoardEnvSpec.h +++ /dev/null @@ -1,262 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -#ifndef __INCmvBoardEnvSpech -#define __INCmvBoardEnvSpech - -#include "mvSysHwConfig.h" - - -/* For future use */ -#define BD_ID_DATA_START_OFFS 0x0 -#define BD_DETECT_SEQ_OFFS 0x0 -#define BD_SYS_NUM_OFFS 0x4 -#define BD_NAME_OFFS 0x8 - -/* I2C bus addresses */ -#define MV_BOARD_CTRL_I2C_ADDR 0x0 /* Controller slave addr */ -#define MV_BOARD_CTRL_I2C_ADDR_TYPE ADDR7_BIT -#define MV_BOARD_DIMM0_I2C_ADDR 0x56 -#define MV_BOARD_DIMM0_I2C_ADDR_TYPE ADDR7_BIT -#define MV_BOARD_DIMM1_I2C_ADDR 0x54 -#define MV_BOARD_DIMM1_I2C_ADDR_TYPE ADDR7_BIT -#define MV_BOARD_EEPROM_I2C_ADDR 0x51 -#define MV_BOARD_EEPROM_I2C_ADDR_TYPE ADDR7_BIT -#define MV_BOARD_MAIN_EEPROM_I2C_ADDR 0x50 -#define MV_BOARD_MAIN_EEPROM_I2C_ADDR_TYPE ADDR7_BIT -#define MV_BOARD_MUX_I2C_ADDR_ENTRY 0x2 -#define MV_BOARD_DIMM_I2C_CHANNEL 0x0 - -#define BOOT_FLASH_INDEX 0 -#define MAIN_FLASH_INDEX 1 - -#define BOARD_ETH_START_PORT_NUM 0 - -/* Supported clocks */ -#define MV_BOARD_TCLK_100MHZ 100000000 -#define MV_BOARD_TCLK_125MHZ 125000000 -#define MV_BOARD_TCLK_133MHZ 133333333 -#define MV_BOARD_TCLK_150MHZ 150000000 -#define MV_BOARD_TCLK_166MHZ 166666667 -#define MV_BOARD_TCLK_200MHZ 200000000 - -#define MV_BOARD_SYSCLK_100MHZ 100000000 -#define MV_BOARD_SYSCLK_125MHZ 125000000 -#define MV_BOARD_SYSCLK_133MHZ 133333333 -#define MV_BOARD_SYSCLK_150MHZ 150000000 -#define MV_BOARD_SYSCLK_166MHZ 166666667 -#define MV_BOARD_SYSCLK_200MHZ 200000000 -#define MV_BOARD_SYSCLK_233MHZ 233333333 -#define MV_BOARD_SYSCLK_250MHZ 250000000 -#define MV_BOARD_SYSCLK_267MHZ 266666667 -#define MV_BOARD_SYSCLK_300MHZ 300000000 -#define MV_BOARD_SYSCLK_333MHZ 333333334 -#define MV_BOARD_SYSCLK_400MHZ 400000000 - -#define MV_BOARD_REFCLK_25MHZ 25000000 - -/* Board specific */ -/* =============================== */ - -/* boards ID numbers */ - -#define BOARD_ID_BASE 0x0 - -/* New board ID numbers */ -#define DB_88F6281A_BP_ID (BOARD_ID_BASE) -#define DB_88F6281_BP_MLL_ID 1680 -#define RD_88F6281A_ID (BOARD_ID_BASE+0x1) -#define RD_88F6281_MLL_ID 1682 -#define DB_88F6192A_BP_ID (BOARD_ID_BASE+0x2) -#define RD_88F6192A_ID (BOARD_ID_BASE+0x3) -#define RD_88F6192_MLL_ID 1681 -#define DB_88F6180A_BP_ID (BOARD_ID_BASE+0x4) -#define DB_88F6190A_BP_ID (BOARD_ID_BASE+0x5) -#define RD_88F6190A_ID (BOARD_ID_BASE+0x6) -#define RD_88F6281A_PCAC_ID (BOARD_ID_BASE+0x7) -#define DB_CUSTOMER_ID (BOARD_ID_BASE+0x8) -#define SHEEVA_PLUG_ID (BOARD_ID_BASE+0x9) -#define MV_MAX_BOARD_ID (SHEEVA_PLUG_ID + 1) - -/* DB-88F6281A-BP */ -#if defined(MV_NAND) - #define DB_88F6281A_MPP0_7 0x21111111 -#else - #define DB_88F6281A_MPP0_7 0x21112220 -#endif -#define DB_88F6281A_MPP8_15 0x11113311 -#define DB_88F6281A_MPP16_23 0x00551111 -#define DB_88F6281A_MPP24_31 0x00000000 -#define DB_88F6281A_MPP32_39 0x00000000 -#define DB_88F6281A_MPP40_47 0x00000000 -#define DB_88F6281A_MPP48_55 0x00000000 -#define DB_88F6281A_OE_LOW 0x0 -#if defined(MV_TDM_5CHANNELS) - #define DB_88F6281A_OE_HIGH (BIT6) -#else -#define DB_88F6281A_OE_HIGH 0x0 -#endif -#define DB_88F6281A_OE_VAL_LOW 0x0 -#define DB_88F6281A_OE_VAL_HIGH 0x0 - -/* RD-88F6281A */ -#if defined(MV_NAND) - #define RD_88F6281A_MPP0_7 0x21111111 -#else - #define RD_88F6281A_MPP0_7 0x21112220 -#endif -#define RD_88F6281A_MPP8_15 0x11113311 -#define RD_88F6281A_MPP16_23 0x33331111 -#define RD_88F6281A_MPP24_31 0x33003333 -#define RD_88F6281A_MPP32_39 0x20440533 -#define RD_88F6281A_MPP40_47 0x22202222 -#define RD_88F6281A_MPP48_55 0x00000002 -#define RD_88F6281A_OE_LOW (BIT28 | BIT29) -#define RD_88F6281A_OE_HIGH (BIT3 | BIT6 | BIT17) -#define RD_88F6281A_OE_VAL_LOW 0x0 -#define RD_88F6281A_OE_VAL_HIGH 0x0 - -/* DB-88F6192A-BP */ -#if defined(MV_NAND) - #define DB_88F6192A_MPP0_7 0x21111111 -#else - #define DB_88F6192A_MPP0_7 0x21112220 -#endif -#define DB_88F6192A_MPP8_15 0x11113311 -#define DB_88F6192A_MPP16_23 0x00501111 -#define DB_88F6192A_MPP24_31 0x00000000 -#define DB_88F6192A_MPP32_35 0x00000000 -#define DB_88F6192A_OE_LOW (BIT22 | BIT23) -#define DB_88F6192A_OE_HIGH 0x0 -#define DB_88F6192A_OE_VAL_LOW 0x0 -#define DB_88F6192A_OE_VAL_HIGH 0x0 - -/* RD-88F6192A */ -#define RD_88F6192A_MPP0_7 0x01222222 -#define RD_88F6192A_MPP8_15 0x00000011 -#define RD_88F6192A_MPP16_23 0x05550000 -#define RD_88F6192A_MPP24_31 0x0 -#define RD_88F6192A_MPP32_35 0x0 -#define RD_88F6192A_OE_LOW (BIT11 | BIT14 | BIT24 | BIT25 | BIT26 | BIT27 | BIT30 | BIT31) -#define RD_88F6192A_OE_HIGH (BIT0 | BIT2) -#define RD_88F6192A_OE_VAL_LOW 0x18400 -#define RD_88F6192A_OE_VAL_HIGH 0x8 - -/* DB-88F6180A-BP */ -#if defined(MV_NAND) - #define DB_88F6180A_MPP0_7 0x21111111 -#else - #define DB_88F6180A_MPP0_7 0x01112222 -#endif -#define DB_88F6180A_MPP8_15 0x11113311 -#define DB_88F6180A_MPP16_23 0x00001111 -#define DB_88F6180A_MPP24_31 0x0 -#define DB_88F6180A_MPP32_39 0x4444c000 -#define DB_88F6180A_MPP40_44 0x00044444 -#define DB_88F6180A_OE_LOW 0x0 -#define DB_88F6180A_OE_HIGH 0x0 -#define DB_88F6180A_OE_VAL_LOW 0x0 -#define DB_88F6180A_OE_VAL_HIGH 0x0 - -/* RD-88F6281A_PCAC */ -#define RD_88F6281A_PCAC_MPP0_7 0x21111111 -#define RD_88F6281A_PCAC_MPP8_15 0x00003311 -#define RD_88F6281A_PCAC_MPP16_23 0x00001100 -#define RD_88F6281A_PCAC_MPP24_31 0x00000000 -#define RD_88F6281A_PCAC_MPP32_39 0x00000000 -#define RD_88F6281A_PCAC_MPP40_47 0x00000000 -#define RD_88F6281A_PCAC_MPP48_55 0x00000000 -#define RD_88F6281A_PCAC_OE_LOW 0x0 -#define RD_88F6281A_PCAC_OE_HIGH 0x0 -#define RD_88F6281A_PCAC_OE_VAL_LOW 0x0 -#define RD_88F6281A_PCAC_OE_VAL_HIGH 0x0 - -/* SHEEVA PLUG */ -#define RD_SHEEVA_PLUG_MPP0_7 0x01111111 -#define RD_SHEEVA_PLUG_MPP8_15 0x11113322 -#define RD_SHEEVA_PLUG_MPP16_23 0x00001111 -#define RD_SHEEVA_PLUG_MPP24_31 0x00100000 -#define RD_SHEEVA_PLUG_MPP32_39 0x00000000 -#define RD_SHEEVA_PLUG_MPP40_47 0x00000000 -#define RD_SHEEVA_PLUG_MPP48_55 0x00000000 -#define RD_SHEEVA_PLUG_OE_LOW 0x0 -#define RD_SHEEVA_PLUG_OE_HIGH 0x0 -#define RD_SHEEVA_PLUG_OE_VAL_LOW (BIT29) -#define RD_SHEEVA_PLUG_OE_VAL_HIGH ((~(BIT17 | BIT16 | BIT15)) | BIT14) - -/* DB-CUSTOMER */ -#define DB_CUSTOMER_MPP0_7 0x21111111 -#define DB_CUSTOMER_MPP8_15 0x00003311 -#define DB_CUSTOMER_MPP16_23 0x00001100 -#define DB_CUSTOMER_MPP24_31 0x00000000 -#define DB_CUSTOMER_MPP32_39 0x00000000 -#define DB_CUSTOMER_MPP40_47 0x00000000 -#define DB_CUSTOMER_MPP48_55 0x00000000 -#define DB_CUSTOMER_OE_LOW 0x0 -#define DB_CUSTOMER_OE_HIGH (~((BIT6) | (BIT7) | (BIT8) | (BIT9))) -#define DB_CUSTOMER_OE_VAL_LOW 0x0 -#define DB_CUSTOMER_OE_VAL_HIGH 0x0 - -#endif /* __INCmvBoardEnvSpech */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/cpu/mvCpu.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/cpu/mvCpu.c deleted file mode 100644 index fed0fa1..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/cpu/mvCpu.c +++ /dev/null @@ -1,320 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -#include "cpu/mvCpu.h" -#include "ctrlEnv/mvCtrlEnvLib.h" -#include "ctrlEnv/mvCtrlEnvRegs.h" -#include "ctrlEnv/sys/mvCpuIfRegs.h" - -/* defines */ -#ifdef MV_DEBUG - #define DB(x) x -#else - #define DB(x) -#endif - -/* locals */ - -/******************************************************************************* -* mvCpuPclkGet - Get the CPU pClk (pipe clock) -* -* DESCRIPTION: -* This routine extract the CPU core clock. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* 32bit clock cycles in MHertz. -* -*******************************************************************************/ -/* 6180 have different clk reset sampling */ - -static MV_U32 mvCpu6180PclkGet(MV_VOID) -{ - MV_U32 tmpPClkRate=0; - MV_CPU_ARM_CLK cpu6180_ddr_l2_CLK[] = MV_CPU6180_DDR_L2_CLCK_TBL; - - tmpPClkRate = MV_REG_READ(MPP_SAMPLE_AT_RESET); - tmpPClkRate = tmpPClkRate & MSAR_CPUCLCK_MASK_6180; - tmpPClkRate = tmpPClkRate >> MSAR_CPUCLCK_OFFS_6180; - - tmpPClkRate = cpu6180_ddr_l2_CLK[tmpPClkRate].cpuClk; - - return tmpPClkRate; -} - - -MV_U32 mvCpuPclkGet(MV_VOID) -{ -#if defined(PCLCK_AUTO_DETECT) - MV_U32 tmpPClkRate=0; - MV_U32 cpuCLK[] = MV_CPU_CLCK_TBL; - - if(mvCtrlModelGet() == MV_6180_DEV_ID) - return mvCpu6180PclkGet(); - - tmpPClkRate = MV_REG_READ(MPP_SAMPLE_AT_RESET); - tmpPClkRate = MSAR_CPUCLCK_EXTRACT(tmpPClkRate); - tmpPClkRate = cpuCLK[tmpPClkRate]; - - return tmpPClkRate; -#else - return MV_DEFAULT_PCLK -#endif -} - -/******************************************************************************* -* mvCpuL2ClkGet - Get the CPU L2 (CPU bus clock) -* -* DESCRIPTION: -* This routine extract the CPU L2 clock. -* -* RETURN: -* 32bit clock cycles in Hertz. -* -*******************************************************************************/ -static MV_U32 mvCpu6180L2ClkGet(MV_VOID) -{ - MV_U32 L2ClkRate=0; - MV_CPU_ARM_CLK _cpu6180_ddr_l2_CLK[] = MV_CPU6180_DDR_L2_CLCK_TBL; - - L2ClkRate = MV_REG_READ(MPP_SAMPLE_AT_RESET); - L2ClkRate = L2ClkRate & MSAR_CPUCLCK_MASK_6180; - L2ClkRate = L2ClkRate >> MSAR_CPUCLCK_OFFS_6180; - - L2ClkRate = _cpu6180_ddr_l2_CLK[L2ClkRate].l2Clk; - - return L2ClkRate; - -} - -MV_U32 mvCpuL2ClkGet(MV_VOID) -{ -#ifdef L2CLK_AUTO_DETECT - MV_U32 L2ClkRate, tmp, pClkRate, indexL2Rtio; - MV_U32 L2Rtio[][2] = MV_L2_CLCK_RTIO_TBL; - - if(mvCtrlModelGet() == MV_6180_DEV_ID) - return mvCpu6180L2ClkGet(); - - pClkRate = mvCpuPclkGet(); - - tmp = MV_REG_READ(MPP_SAMPLE_AT_RESET); - indexL2Rtio = MSAR_L2CLCK_EXTRACT(tmp); - - L2ClkRate = ((pClkRate * L2Rtio[indexL2Rtio][1]) / L2Rtio[indexL2Rtio][0]); - - return L2ClkRate; -#else - return MV_BOARD_DEFAULT_L2CLK; -#endif -} - - -/******************************************************************************* -* mvCpuNameGet - Get CPU name -* -* DESCRIPTION: -* This function returns a string describing the CPU model and revision. -* -* INPUT: -* None. -* -* OUTPUT: -* pNameBuff - Buffer to contain board name string. Minimum size 32 chars. -* -* RETURN: -* None. -*******************************************************************************/ -MV_VOID mvCpuNameGet(char *pNameBuff) -{ - MV_U32 cpuModel; - - cpuModel = mvOsCpuPartGet(); - - /* The CPU module is indicated in the Processor Version Register (PVR) */ - switch(cpuModel) - { - case CPU_PART_MRVL131: - mvOsSPrintf(pNameBuff, "%s (Rev %d)", "Marvell Feroceon",mvOsCpuRevGet()); - break; - case CPU_PART_ARM926: - mvOsSPrintf(pNameBuff, "%s (Rev %d)", "ARM926",mvOsCpuRevGet()); - break; - case CPU_PART_ARM946: - mvOsSPrintf(pNameBuff, "%s (Rev %d)", "ARM946",mvOsCpuRevGet()); - break; - default: - mvOsSPrintf(pNameBuff,"??? (0x%04x) (Rev %d)",cpuModel,mvOsCpuRevGet()); - break; - } /* switch */ - - return; -} - - -#define MV_PROC_STR_SIZE 50 - -static void mvCpuIfGetL2EccMode(MV_8 *buf) -{ - MV_U32 regVal = MV_REG_READ(CPU_L2_CONFIG_REG); - if (regVal & BIT2) - mvOsSPrintf(buf, "L2 ECC Enabled"); - else - mvOsSPrintf(buf, "L2 ECC Disabled"); -} - -static void mvCpuIfGetL2Mode(MV_8 *buf) -{ - MV_U32 regVal = 0; - __asm volatile ("mrc p15, 1, %0, c15, c1, 0" : "=r" (regVal)); /* Read Marvell extra features register */ - if (regVal & BIT22) - mvOsSPrintf(buf, "L2 Enabled"); - else - mvOsSPrintf(buf, "L2 Disabled"); -} - -static void mvCpuIfGetL2PrefetchMode(MV_8 *buf) -{ - MV_U32 regVal = 0; - __asm volatile ("mrc p15, 1, %0, c15, c1, 0" : "=r" (regVal)); /* Read Marvell extra features register */ - if (regVal & BIT24) - mvOsSPrintf(buf, "L2 Prefetch Disabled"); - else - mvOsSPrintf(buf, "L2 Prefetch Enabled"); -} - -static void mvCpuIfGetWriteAllocMode(MV_8 *buf) -{ - MV_U32 regVal = 0; - __asm volatile ("mrc p15, 1, %0, c15, c1, 0" : "=r" (regVal)); /* Read Marvell extra features register */ - if (regVal & BIT28) - mvOsSPrintf(buf, "Write Allocate Enabled"); - else - mvOsSPrintf(buf, "Write Allocate Disabled"); -} - -static void mvCpuIfGetCpuStreamMode(MV_8 *buf) -{ - MV_U32 regVal = 0; - __asm volatile ("mrc p15, 1, %0, c15, c1, 0" : "=r" (regVal)); /* Read Marvell extra features register */ - if (regVal & BIT29) - mvOsSPrintf(buf, "CPU Streaming Enabled"); - else - mvOsSPrintf(buf, "CPU Streaming Disabled"); -} - -static void mvCpuIfPrintCpuRegs(void) -{ - MV_U32 regVal = 0; - - __asm volatile ("mrc p15, 1, %0, c15, c1, 0" : "=r" (regVal)); /* Read Marvell extra features register */ - mvOsPrintf("Extra Feature Reg = 0x%x\n",regVal); - - __asm volatile ("mrc p15, 0, %0, c1, c0, 0" : "=r" (regVal)); /* Read Control register */ - mvOsPrintf("Control Reg = 0x%x\n",regVal); - - __asm volatile ("mrc p15, 0, %0, c0, c0, 0" : "=r" (regVal)); /* Read ID Code register */ - mvOsPrintf("ID Code Reg = 0x%x\n",regVal); - - __asm volatile ("mrc p15, 0, %0, c0, c0, 1" : "=r" (regVal)); /* Read Cache Type register */ - mvOsPrintf("Cache Type Reg = 0x%x\n",regVal); - -} - -MV_U32 mvCpuIfPrintSystemConfig(MV_8 *buffer, MV_U32 index) -{ - MV_U32 count = 0; - - MV_8 L2_ECC_str[MV_PROC_STR_SIZE]; - MV_8 L2_En_str[MV_PROC_STR_SIZE]; - MV_8 L2_Prefetch_str[MV_PROC_STR_SIZE]; - MV_8 Write_Alloc_str[MV_PROC_STR_SIZE]; - MV_8 Cpu_Stream_str[MV_PROC_STR_SIZE]; - - mvCpuIfGetL2Mode(L2_En_str); - mvCpuIfGetL2EccMode(L2_ECC_str); - mvCpuIfGetL2PrefetchMode(L2_Prefetch_str); - mvCpuIfGetWriteAllocMode(Write_Alloc_str); - mvCpuIfGetCpuStreamMode(Cpu_Stream_str); - mvCpuIfPrintCpuRegs(); - - count += mvOsSPrintf(buffer + count + index, "%s\n", L2_En_str); - count += mvOsSPrintf(buffer + count + index, "%s\n", L2_ECC_str); - count += mvOsSPrintf(buffer + count + index, "%s\n", L2_Prefetch_str); - count += mvOsSPrintf(buffer + count + index, "%s\n", Write_Alloc_str); - count += mvOsSPrintf(buffer + count + index, "%s\n", Cpu_Stream_str); - return count; -} - -MV_U32 whoAmI(MV_VOID) -{ - return 0; -} - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/cpu/mvCpu.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/cpu/mvCpu.h deleted file mode 100644 index 7f58b03..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/cpu/mvCpu.h +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -#ifndef __INCmvCpuh -#define __INCmvCpuh - -#include "mvCommon.h" -#include "mvOs.h" -#include "ctrlEnv/mvCtrlEnvSpec.h" - -/* defines */ -#define CPU_PART_MRVL131 0x131 -#define CPU_PART_ARM926 0x926 -#define CPU_PART_ARM946 0x946 -#define MV_CPU_ARM_CLK_ELM_SIZE 12 -#define MV_CPU_ARM_CLK_RATIO_OFF 8 -#define MV_CPU_ARM_CLK_DDR_OFF 4 - -#ifndef MV_ASMLANGUAGE -typedef struct _mvCpuArmClk -{ - MV_U32 cpuClk; /* CPU clock in MHz */ - MV_U32 ddrClk; /* DDR clock in MHz */ - MV_U32 l2Clk; /* CPU DDR clock ratio */ - -}MV_CPU_ARM_CLK; - -MV_U32 mvCpuPclkGet(MV_VOID); -MV_VOID mvCpuNameGet(char *pNameBuff); -MV_U32 mvCpuL2ClkGet(MV_VOID); -MV_U32 mvCpuIfPrintSystemConfig(MV_8 *buffer, MV_U32 index); -MV_U32 whoAmI(MV_VOID); - -#endif /* MV_ASMLANGUAGE */ - - -#endif /* __INCmvCpuh */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/mvCtrlEnvAddrDec.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/mvCtrlEnvAddrDec.c deleted file mode 100644 index 2d148e0..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/mvCtrlEnvAddrDec.c +++ /dev/null @@ -1,296 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -/******************************************************************************* -* mvCtrlEnvAddrDec.h - Marvell controller address decode library -* -* DESCRIPTION: -* -* DEPENDENCIES: -* None. -* -*******************************************************************************/ - -/* includes */ -#include "ctrlEnv/mvCtrlEnvAddrDec.h" -#include "ctrlEnv/sys/mvAhbToMbusRegs.h" -#include "ddr2/mvDramIfRegs.h" -#include "pex/mvPexRegs.h" - -#define MV_DEBUG - -/* defines */ -#ifdef MV_DEBUG - #define DB(x) x -#else - #define DB(x) -#endif - -/* Default Attributes array */ -MV_TARGET_ATTRIB mvTargetDefaultsArray[] = TARGETS_DEF_ARRAY; -extern MV_TARGET *sampleAtResetTargetArray; -/* Dram\AHBToMbus\PEX share regsiter */ - -#define CTRL_DEC_BASE_OFFS 16 -#define CTRL_DEC_BASE_MASK (0xffff << CTRL_DEC_BASE_OFFS) -#define CTRL_DEC_BASE_ALIGNMENT 0x10000 - -#define CTRL_DEC_SIZE_OFFS 16 -#define CTRL_DEC_SIZE_MASK (0xffff << CTRL_DEC_SIZE_OFFS) -#define CTRL_DEC_SIZE_ALIGNMENT 0x10000 - -#define CTRL_DEC_WIN_EN BIT0 - - - -/******************************************************************************* -* mvCtrlAddrDecToReg - Get address decode register format values -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* -* RETURN: -* -*******************************************************************************/ -MV_STATUS mvCtrlAddrDecToReg(MV_ADDR_WIN *pAddrDecWin, MV_DEC_REGS *pAddrDecRegs) -{ - - MV_U32 baseToReg=0 , sizeToReg=0; - - /* BaseLow[31:16] => base register [31:16] */ - baseToReg = pAddrDecWin->baseLow & CTRL_DEC_BASE_MASK; - - /* Write to address decode Base Address Register */ - pAddrDecRegs->baseReg &= ~CTRL_DEC_BASE_MASK; - pAddrDecRegs->baseReg |= baseToReg; - - /* Get size register value according to window size */ - sizeToReg = ctrlSizeToReg(pAddrDecWin->size, CTRL_DEC_SIZE_ALIGNMENT); - - /* Size parameter validity check. */ - if (-1 == sizeToReg) - { - return MV_BAD_PARAM; - } - - /* set size */ - pAddrDecRegs->sizeReg &= ~CTRL_DEC_SIZE_MASK; - pAddrDecRegs->sizeReg |= (sizeToReg << CTRL_DEC_SIZE_OFFS); - - - return MV_OK; - -} - -/******************************************************************************* -* mvCtrlRegToAddrDec - Extract address decode struct from registers. -* -* DESCRIPTION: -* This function extract address decode struct from address decode -* registers given as parameters. -* -* INPUT: -* pAddrDecRegs - Address decode register struct. -* -* OUTPUT: -* pAddrDecWin - Target window data structure. -* -* RETURN: -* MV_BAD_PARAM if address decode registers data is invalid. -* -*******************************************************************************/ -MV_STATUS mvCtrlRegToAddrDec(MV_DEC_REGS *pAddrDecRegs, MV_ADDR_WIN *pAddrDecWin) -{ - MV_U32 sizeRegVal; - - sizeRegVal = (pAddrDecRegs->sizeReg & CTRL_DEC_SIZE_MASK) >> - CTRL_DEC_SIZE_OFFS; - - pAddrDecWin->size = ctrlRegToSize(sizeRegVal, CTRL_DEC_SIZE_ALIGNMENT); - - - /* Extract base address */ - /* Base register [31:16] ==> baseLow[31:16] */ - pAddrDecWin->baseLow = pAddrDecRegs->baseReg & CTRL_DEC_BASE_MASK; - - pAddrDecWin->baseHigh = 0; - - return MV_OK; - -} - -/******************************************************************************* -* mvCtrlAttribGet - -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* -* RETURN: -* -*******************************************************************************/ - -MV_STATUS mvCtrlAttribGet(MV_TARGET target, - MV_TARGET_ATTRIB *targetAttrib) -{ - - targetAttrib->attrib = mvTargetDefaultsArray[MV_CHANGE_BOOT_CS(target)].attrib; - targetAttrib->targetId = mvTargetDefaultsArray[MV_CHANGE_BOOT_CS(target)].targetId; - - return MV_OK; - -} - -/******************************************************************************* -* mvCtrlGetAttrib - -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* -* RETURN: -* -*******************************************************************************/ -MV_TARGET mvCtrlTargetGet(MV_TARGET_ATTRIB *targetAttrib) -{ - MV_TARGET target; - MV_TARGET x; - for (target = SDRAM_CS0; target < MAX_TARGETS ; target ++) - { - x = MV_CHANGE_BOOT_CS(target); - if ((mvTargetDefaultsArray[x].attrib == targetAttrib->attrib) && - (mvTargetDefaultsArray[MV_CHANGE_BOOT_CS(target)].targetId == targetAttrib->targetId)) - { - /* found it */ - break; - } - } - - return target; -} - -MV_STATUS mvCtrlAddrDecToParams(MV_DEC_WIN *pAddrDecWin, - MV_DEC_WIN_PARAMS *pWinParam) -{ - MV_U32 baseToReg=0, sizeToReg=0; - - /* BaseLow[31:16] => base register [31:16] */ - baseToReg = pAddrDecWin->addrWin.baseLow & CTRL_DEC_BASE_MASK; - - /* Write to address decode Base Address Register */ - pWinParam->baseAddr &= ~CTRL_DEC_BASE_MASK; - pWinParam->baseAddr |= baseToReg; - - /* Get size register value according to window size */ - sizeToReg = ctrlSizeToReg(pAddrDecWin->addrWin.size, CTRL_DEC_SIZE_ALIGNMENT); - - /* Size parameter validity check. */ - if (-1 == sizeToReg) - { - mvOsPrintf("mvCtrlAddrDecToParams: ERR. ctrlSizeToReg failed.\n"); - return MV_BAD_PARAM; - } - pWinParam->size = sizeToReg; - - pWinParam->attrib = mvTargetDefaultsArray[MV_CHANGE_BOOT_CS(pAddrDecWin->target)].attrib; - pWinParam->targetId = mvTargetDefaultsArray[MV_CHANGE_BOOT_CS(pAddrDecWin->target)].targetId; - - return MV_OK; -} - -MV_STATUS mvCtrlParamsToAddrDec(MV_DEC_WIN_PARAMS *pWinParam, - MV_DEC_WIN *pAddrDecWin) -{ - MV_TARGET_ATTRIB targetAttrib; - - pAddrDecWin->addrWin.baseLow = pWinParam->baseAddr; - - /* Upper 32bit address base is supported under PCI High Address remap */ - pAddrDecWin->addrWin.baseHigh = 0; - - /* Prepare sizeReg to ctrlRegToSize function */ - pAddrDecWin->addrWin.size = ctrlRegToSize(pWinParam->size, CTRL_DEC_SIZE_ALIGNMENT); - - if (-1 == pAddrDecWin->addrWin.size) - { - DB(mvOsPrintf("mvCtrlParamsToAddrDec: ERR. ctrlRegToSize failed.\n")); - return MV_BAD_PARAM; - } - targetAttrib.targetId = pWinParam->targetId; - targetAttrib.attrib = pWinParam->attrib; - - pAddrDecWin->target = mvCtrlTargetGet(&targetAttrib); - - return MV_OK; -} - - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/mvCtrlEnvAddrDec.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/mvCtrlEnvAddrDec.h deleted file mode 100644 index 30efe98..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/mvCtrlEnvAddrDec.h +++ /dev/null @@ -1,203 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -#ifndef __INCmvCtrlEnvAddrDech -#define __INCmvCtrlEnvAddrDech - -/* includes */ -#include "ctrlEnv/mvCtrlEnvLib.h" -#include "ctrlEnv/mvCtrlEnvRegs.h" - - -/* defines */ -/* DUnit attributes */ -#define ATMWCR_WIN_DUNIT_CS0_OFFS 0 -#define ATMWCR_WIN_DUNIT_CS0_MASK BIT0 -#define ATMWCR_WIN_DUNIT_CS0_REQ (0 << ATMWCR_WIN_DUNIT_CS0_OFFS) - -#define ATMWCR_WIN_DUNIT_CS1_OFFS 1 -#define ATMWCR_WIN_DUNIT_CS1_MASK BIT1 -#define ATMWCR_WIN_DUNIT_CS1_REQ (0 << ATMWCR_WIN_DUNIT_CS1_OFFS) - -#define ATMWCR_WIN_DUNIT_CS2_OFFS 2 -#define ATMWCR_WIN_DUNIT_CS2_MASK BIT2 -#define ATMWCR_WIN_DUNIT_CS2_REQ (0 << ATMWCR_WIN_DUNIT_CS2_OFFS) - -#define ATMWCR_WIN_DUNIT_CS3_OFFS 3 -#define ATMWCR_WIN_DUNIT_CS3_MASK BIT3 -#define ATMWCR_WIN_DUNIT_CS3_REQ (0 << ATMWCR_WIN_DUNIT_CS3_OFFS) - -/* RUnit (Device) attributes */ -#define ATMWCR_WIN_RUNIT_DEVCS0_OFFS 0 -#define ATMWCR_WIN_RUNIT_DEVCS0_MASK BIT0 -#define ATMWCR_WIN_RUNIT_DEVCS0_REQ (0 << ATMWCR_WIN_RUNIT_DEVCS0_OFFS) - -#define ATMWCR_WIN_RUNIT_DEVCS1_OFFS 1 -#define ATMWCR_WIN_RUNIT_DEVCS1_MASK BIT1 -#define ATMWCR_WIN_RUNIT_DEVCS1_REQ (0 << ATMWCR_WIN_RUNIT_DEVCS1_OFFS) - -#define ATMWCR_WIN_RUNIT_DEVCS2_OFFS 2 -#define ATMWCR_WIN_RUNIT_DEVCS2_MASK BIT2 -#define ATMWCR_WIN_RUNIT_DEVCS2_REQ (0 << ATMWCR_WIN_RUNIT_DEVCS2_OFFS) - -#define ATMWCR_WIN_RUNIT_BOOTCS_OFFS 4 -#define ATMWCR_WIN_RUNIT_BOOTCS_MASK BIT4 -#define ATMWCR_WIN_RUNIT_BOOTCS_REQ (0 << ATMWCR_WIN_RUNIT_BOOTCS_OFFS) - -/* LMaster (PCI) attributes */ -#define ATMWCR_WIN_LUNIT_BYTE_SWP_OFFS 0 -#define ATMWCR_WIN_LUNIT_BYTE_SWP_MASK BIT0 -#define ATMWCR_WIN_LUNIT_BYTE_SWP (0 << ATMWCR_WIN_LUNIT_BYTE_SWP_OFFS) -#define ATMWCR_WIN_LUNIT_BYTE_NO_SWP (1 << ATMWCR_WIN_LUNIT_BYTE_SWP_OFFS) - - -#define ATMWCR_WIN_LUNIT_WORD_SWP_OFFS 1 -#define ATMWCR_WIN_LUNIT_WORD_SWP_MASK BIT1 -#define ATMWCR_WIN_LUNIT_WORD_SWP (0 << ATMWCR_WIN_LUNIT_WORD_SWP_OFFS) -#define ATMWCR_WIN_LUNIT_WORD_NO_SWP (1 << ATMWCR_WIN_LUNIT_WORD_SWP_OFFS) - -#define ATMWCR_WIN_LUNIT_NO_SNOOP BIT2 - -#define ATMWCR_WIN_LUNIT_TYPE_OFFS 3 -#define ATMWCR_WIN_LUNIT_TYPE_MASK BIT3 -#define ATMWCR_WIN_LUNIT_TYPE_IO (0 << ATMWCR_WIN_LUNIT_TYPE_OFFS) -#define ATMWCR_WIN_LUNIT_TYPE_MEM (1 << ATMWCR_WIN_LUNIT_TYPE_OFFS) - -#define ATMWCR_WIN_LUNIT_FORCE64_OFFS 4 -#define ATMWCR_WIN_LUNIT_FORCE64_MASK BIT4 -#define ATMWCR_WIN_LUNIT_FORCE64 (0 << ATMWCR_WIN_LUNIT_FORCE64_OFFS) - -#define ATMWCR_WIN_LUNIT_ORDERING_OFFS 6 -#define ATMWCR_WIN_LUNIT_ORDERING_MASK BIT6 -#define ATMWCR_WIN_LUNIT_ORDERING (1 << ATMWCR_WIN_LUNIT_FORCE64_OFFS) - -/* PEX Attributes */ -#define ATMWCR_WIN_PEX_TYPE_OFFS 3 -#define ATMWCR_WIN_PEX_TYPE_MASK BIT3 -#define ATMWCR_WIN_PEX_TYPE_IO (0 << ATMWCR_WIN_PEX_TYPE_OFFS) -#define ATMWCR_WIN_PEX_TYPE_MEM (1 << ATMWCR_WIN_PEX_TYPE_OFFS) - -/* typedefs */ - -/* Unsupported attributes for address decode: */ -/* 2) PCI0/1_REQ64n control */ - -typedef struct _mvDecRegs -{ - MV_U32 baseReg; - MV_U32 baseRegHigh; - MV_U32 sizeReg; - -}MV_DEC_REGS; - -typedef struct _mvTargetAttrib -{ - MV_U8 attrib; /* chip select attributes */ - MV_TARGET_ID targetId; /* Target Id of this MV_TARGET */ - -}MV_TARGET_ATTRIB; - - -/* This structure describes address decode window */ -typedef struct _mvDecWin -{ - MV_TARGET target; /* Target for addr decode window */ - MV_ADDR_WIN addrWin; /* Address window of target */ - MV_BOOL enable; /* Window enable/disable */ -}MV_DEC_WIN; - -typedef struct _mvDecWinParams -{ - MV_TARGET_ID targetId; /* Target ID field */ - MV_U8 attrib; /* Attribute field */ - MV_U32 baseAddr; /* Base address in register format */ - MV_U32 size; /* Size in register format */ -}MV_DEC_WIN_PARAMS; - - -/* mvCtrlEnvAddrDec API list */ - -MV_STATUS mvCtrlAddrDecToReg(MV_ADDR_WIN *pAddrDecWin, - MV_DEC_REGS *pAddrDecRegs); - -MV_STATUS mvCtrlRegToAddrDec(MV_DEC_REGS *pAddrDecRegs, - MV_ADDR_WIN *pAddrDecWin); - -MV_STATUS mvCtrlAttribGet(MV_TARGET target, - MV_TARGET_ATTRIB *targetAttrib); - -MV_TARGET mvCtrlTargetGet(MV_TARGET_ATTRIB *targetAttrib); - - -MV_STATUS mvCtrlAddrDecToParams(MV_DEC_WIN *pAddrDecWin, - MV_DEC_WIN_PARAMS *pWinParam); - -MV_STATUS mvCtrlParamsToAddrDec(MV_DEC_WIN_PARAMS *pWinParam, - MV_DEC_WIN *pAddrDecWin); - - - - -#endif /* __INCmvCtrlEnvAddrDech */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/mvCtrlEnvAsm.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/mvCtrlEnvAsm.h deleted file mode 100644 index 6f6367a..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/mvCtrlEnvAsm.h +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -#ifndef __INCmvCtrlEnvAsmh -#define __INCmvCtrlEnvAsmh -#include "pex/mvPexRegs.h" - -#define CHIP_BOND_REG 0x10034 -#define PCKG_OPT_MASK_AS #3 -#define PXCCARI_REVID_MASK_AS #PXCCARI_REVID_MASK - -/* Read device ID into toReg bits 15:0 from 0xd0000000 */ -/* defines */ -#define MV_DV_CTRL_MODEL_GET_ASM(toReg, tmpReg) \ - MV_DV_REG_READ_ASM(toReg, tmpReg, CHIP_BOND_REG);\ - and toReg, toReg, PCKG_OPT_MASK_AS /* Mask for package ID */ - -/* Read device ID into toReg bits 15:0 from 0xf1000000*/ -#define MV_CTRL_MODEL_GET_ASM(toReg, tmpReg) \ - MV_REG_READ_ASM(toReg, tmpReg, CHIP_BOND_REG);\ - and toReg, toReg, PCKG_OPT_MASK_AS /* Mask for package ID */ - -/* Read Revision into toReg bits 7:0 0xd0000000*/ -#define MV_DV_CTRL_REV_GET_ASM(toReg, tmpReg) \ - /* Read device revision */ \ - MV_DV_REG_READ_ASM(toReg, tmpReg, PEX_CFG_DIRECT_ACCESS(0,PEX_CLASS_CODE_AND_REVISION_ID));\ - and toReg, toReg, PXCCARI_REVID_MASK_AS /* Mask for calss ID */ - -/* Read Revision into toReg bits 7:0 0xf1000000*/ -#define MV_CTRL_REV_GET_ASM(toReg, tmpReg) \ - /* Read device revision */ \ - MV_REG_READ_ASM(toReg, tmpReg, PEX_CFG_DIRECT_ACCESS(0,PEX_CLASS_CODE_AND_REVISION_ID));\ - and toReg, toReg, PXCCARI_REVID_MASK_AS /* Mask for calss ID */ - - -#endif /* __INCmvCtrlEnvAsmh */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/mvCtrlEnvLib.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/mvCtrlEnvLib.c deleted file mode 100644 index adf451d..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/mvCtrlEnvLib.c +++ /dev/null @@ -1,1825 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -/* includes */ -#include "mvCommon.h" -#include "mvCtrlEnvLib.h" -#include "ctrlEnv/sys/mvCpuIf.h" - -#if defined(MV_INCLUDE_PEX) -#include "pex/mvPex.h" -#include "ctrlEnv/sys/mvSysPex.h" -#endif - -#if defined(MV_INCLUDE_GIG_ETH) -#include "ctrlEnv/sys/mvSysGbe.h" -#endif - -#if defined(MV_INCLUDE_XOR) -#include "ctrlEnv/sys/mvSysXor.h" -#endif - -#if defined(MV_INCLUDE_SATA) -#include "ctrlEnv/sys/mvSysSata.h" -#endif - -#if defined(MV_INCLUDE_USB) -#include "ctrlEnv/sys/mvSysUsb.h" -#endif - -#if defined(MV_INCLUDE_AUDIO) -#include "ctrlEnv/sys/mvSysAudio.h" -#endif - -#if defined(MV_INCLUDE_CESA) -#include "ctrlEnv/sys/mvSysCesa.h" -#endif - -#if defined(MV_INCLUDE_TS) -#include "ctrlEnv/sys/mvSysTs.h" -#endif - -/* defines */ -#ifdef MV_DEBUG - #define DB(x) x -#else - #define DB(x) -#endif - -/******************************************************************************* -* mvCtrlEnvInit - Initialize Marvell controller environment. -* -* DESCRIPTION: -* This function get environment information and initialize controller -* internal/external environment. For example -* 1) MPP settings according to board MPP macros. -* NOTE: It is the user responsibility to shut down all DMA channels -* in device and disable controller sub units interrupts during -* boot process. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_STATUS mvCtrlEnvInit(MV_VOID) -{ - MV_U32 mppGroup; - MV_U32 devId; - MV_U32 boardId; - MV_U32 i; - MV_U32 maxMppGrp = 1; - MV_U32 mppVal = 0; - MV_U32 bootVal = 0; - MV_U32 mppGroupType = 0; - MV_U32 mppGroup1[][3] = MPP_GROUP_1_TYPE; - MV_U32 mppGroup2[][3] = MPP_GROUP_2_TYPE; - - devId = mvCtrlModelGet(); - boardId= mvBoardIdGet(); - - switch(devId){ - case MV_6281_DEV_ID: - maxMppGrp = MV_6281_MPP_MAX_GROUP; - break; - case MV_6192_DEV_ID: - maxMppGrp = MV_6192_MPP_MAX_GROUP; - break; - case MV_6190_DEV_ID: - maxMppGrp = MV_6190_MPP_MAX_GROUP; - break; - case MV_6180_DEV_ID: - maxMppGrp = MV_6180_MPP_MAX_GROUP; - break; - } - - /* MPP Init */ - /* We split mpp init to 3 phases: - * 1. We init mpp[19:0] from the board info. mpp[23:20] will be over write - * in phase 2. - * 2. We detect the mpp group type and according the mpp values [35:20]. - * 3. We detect the mpp group type and according the mpp values [49:36]. - */ - /* Mpp phase 1 mpp[19:0] */ - /* Read MPP group from board level and assign to MPP register */ - for (mppGroup = 0; mppGroup < 3; mppGroup++) - { - mppVal = mvBoardMppGet(mppGroup); - if (mppGroup == 0) - { - bootVal = MV_REG_READ(mvCtrlMppRegGet(mppGroup)); - if (mvCtrlIsBootFromSPI()) - { - mppVal &= ~0xffff; - bootVal &= 0xffff; - mppVal |= bootVal; - } - else if (mvCtrlIsBootFromSPIUseNAND()) - { - mppVal &= ~0xf0000000; - bootVal &= 0xf0000000; - mppVal |= bootVal; - } - else if (mvCtrlIsBootFromNAND()) - { - mppVal &= ~0xffffff; - bootVal &= 0xffffff; - mppVal |= bootVal; - } - } - - if (mppGroup == 2) - { - bootVal = MV_REG_READ(mvCtrlMppRegGet(mppGroup)); - if (mvCtrlIsBootFromNAND()) - { - mppVal &= ~0xff00; - bootVal &= 0xff00; - mppVal |= bootVal; - } - } - - MV_REG_WRITE(mvCtrlMppRegGet(mppGroup), mppVal); - } - - /* Identify MPPs group */ - mvBoardMppGroupIdUpdate(); - - /* Update MPPs mux relevent only on Marvell DB */ - if ((boardId == DB_88F6281A_BP_ID) || - (boardId == DB_88F6180A_BP_ID)) - mvBoardMppMuxSet(); - - mppGroupType = mvBoardMppGroupTypeGet(MV_BOARD_MPP_GROUP_1); - - /* Mpp phase 2 */ - /* Read MPP group from board level and assign to MPP register */ - if (devId != MV_6180_DEV_ID) - { - i = 0; - for (mppGroup = 2; mppGroup < 5; mppGroup++) - { - if ((mppGroupType == MV_BOARD_OTHER) || - (boardId == RD_88F6281A_ID) || - (boardId == RD_88F6192A_ID) || - (boardId == RD_88F6190A_ID) || - (boardId == RD_88F6281A_PCAC_ID) || - (boardId == SHEEVA_PLUG_ID)) - mppVal = mvBoardMppGet(mppGroup); - else - { - mppVal = mppGroup1[mppGroupType][i]; - i++; - } - - /* Group 2 is shared mpp[23:16] */ - if (mppGroup == 2) - { - bootVal = MV_REG_READ(mvCtrlMppRegGet(mppGroup)); - mppVal &= ~0xffff; - bootVal &= 0xffff; - mppVal |= bootVal; - } - - MV_REG_WRITE(mvCtrlMppRegGet(mppGroup), mppVal); - } - } - - if ((devId == MV_6192_DEV_ID) || (devId == MV_6190_DEV_ID)) - return MV_OK; - - /* Mpp phase 3 */ - mppGroupType = mvBoardMppGroupTypeGet(MV_BOARD_MPP_GROUP_2); - /* Read MPP group from board level and assign to MPP register */ - i = 0; - for (mppGroup = 4; mppGroup < 7; mppGroup++) - { - if ((mppGroupType == MV_BOARD_OTHER) || - (boardId == RD_88F6281A_ID) || - (boardId == RD_88F6281A_PCAC_ID) || - (boardId == SHEEVA_PLUG_ID)) - mppVal = mvBoardMppGet(mppGroup); - else - { - mppVal = mppGroup2[mppGroupType][i]; - i++; - } - - /* Group 4 is shared mpp[35:32] */ - if (mppGroup == 4) - { - bootVal = MV_REG_READ(mvCtrlMppRegGet(mppGroup)); - mppVal &= ~0xffff; - bootVal &= 0xffff; - mppVal |= bootVal; - } - - MV_REG_WRITE(mvCtrlMppRegGet(mppGroup), mppVal); - } - /* Update SSCG configuration register*/ - if(mvBoardIdGet() == DB_88F6281A_BP_ID || mvBoardIdGet() == DB_88F6192A_BP_ID || - mvBoardIdGet() == DB_88F6190A_BP_ID || mvBoardIdGet() == DB_88F6180A_BP_ID) - MV_REG_WRITE(0x100d8, 0x53); - - return MV_OK; -} - -/******************************************************************************* -* mvCtrlMppRegGet - return reg address of mpp group -* -* DESCRIPTION: -* -* INPUT: -* mppGroup - MPP group. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_U32 - Register address. -* -*******************************************************************************/ -MV_U32 mvCtrlMppRegGet(MV_U32 mppGroup) -{ - MV_U32 ret; - - switch(mppGroup){ - case (0): ret = MPP_CONTROL_REG0; - break; - case (1): ret = MPP_CONTROL_REG1; - break; - case (2): ret = MPP_CONTROL_REG2; - break; - case (3): ret = MPP_CONTROL_REG3; - break; - case (4): ret = MPP_CONTROL_REG4; - break; - case (5): ret = MPP_CONTROL_REG5; - break; - case (6): ret = MPP_CONTROL_REG6; - break; - default: ret = MPP_CONTROL_REG0; - break; - } - return ret; -} -#if defined(MV_INCLUDE_PEX) -/******************************************************************************* -* mvCtrlPexMaxIfGet - Get Marvell controller number of PEX interfaces. -* -* DESCRIPTION: -* This function returns Marvell controller number of PEX interfaces. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* Marvell controller number of PEX interfaces. If controller -* ID is undefined the function returns '0'. -* -*******************************************************************************/ -MV_U32 mvCtrlPexMaxIfGet(MV_VOID) -{ - - return MV_PEX_MAX_IF; -} -#endif - -#if defined(MV_INCLUDE_GIG_ETH) -/******************************************************************************* -* mvCtrlEthMaxPortGet - Get Marvell controller number of etherent ports. -* -* DESCRIPTION: -* This function returns Marvell controller number of etherent port. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* Marvell controller number of etherent port. -* -*******************************************************************************/ -MV_U32 mvCtrlEthMaxPortGet(MV_VOID) -{ - MV_U32 devId; - - devId = mvCtrlModelGet(); - - switch(devId){ - case MV_6281_DEV_ID: - return MV_6281_ETH_MAX_PORTS; - break; - case MV_6192_DEV_ID: - return MV_6192_ETH_MAX_PORTS; - break; - case MV_6190_DEV_ID: - return MV_6190_ETH_MAX_PORTS; - break; - case MV_6180_DEV_ID: - return MV_6180_ETH_MAX_PORTS; - break; - } - return 0; - -} -#endif - -#if defined(MV_INCLUDE_XOR) -/******************************************************************************* -* mvCtrlXorMaxChanGet - Get Marvell controller number of XOR channels. -* -* DESCRIPTION: -* This function returns Marvell controller number of XOR channels. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* Marvell controller number of XOR channels. -* -*******************************************************************************/ -MV_U32 mvCtrlXorMaxChanGet(MV_VOID) -{ - return MV_XOR_MAX_CHAN; -} -#endif - -#if defined(MV_INCLUDE_USB) -/******************************************************************************* -* mvCtrlUsbHostMaxGet - Get number of Marvell Usb controllers -* -* DESCRIPTION: -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* returns number of Marvell USB controllers. -* -*******************************************************************************/ -MV_U32 mvCtrlUsbMaxGet(void) -{ - return MV_USB_MAX_PORTS; -} -#endif - - -#if defined(MV_INCLUDE_NAND) -/******************************************************************************* -* mvCtrlNandSupport - Return if this controller has integrated NAND flash support -* -* DESCRIPTION: -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_TRUE if NAND is supported and MV_FALSE otherwise -* -*******************************************************************************/ -MV_U32 mvCtrlNandSupport(MV_VOID) -{ - MV_U32 devId; - - devId = mvCtrlModelGet(); - - switch(devId){ - case MV_6281_DEV_ID: - return MV_6281_NAND; - break; - case MV_6192_DEV_ID: - return MV_6192_NAND; - break; - case MV_6190_DEV_ID: - return MV_6190_NAND; - break; - case MV_6180_DEV_ID: - return MV_6180_NAND; - break; - } - return 0; - -} -#endif - -#if defined(MV_INCLUDE_SDIO) -/******************************************************************************* -* mvCtrlSdioSupport - Return if this controller has integrated SDIO flash support -* -* DESCRIPTION: -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_TRUE if SDIO is supported and MV_FALSE otherwise -* -*******************************************************************************/ -MV_U32 mvCtrlSdioSupport(MV_VOID) -{ - MV_U32 devId; - - devId = mvCtrlModelGet(); - - switch(devId){ - case MV_6281_DEV_ID: - return MV_6281_SDIO; - break; - case MV_6192_DEV_ID: - return MV_6192_SDIO; - break; - case MV_6190_DEV_ID: - return MV_6190_SDIO; - break; - case MV_6180_DEV_ID: - return MV_6180_SDIO; - break; - } - return 0; - -} -#endif - -#if defined(MV_INCLUDE_TS) -/******************************************************************************* -* mvCtrlTsSupport - Return if this controller has integrated TS flash support -* -* DESCRIPTION: -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_TRUE if TS is supported and MV_FALSE otherwise -* -*******************************************************************************/ -MV_U32 mvCtrlTsSupport(MV_VOID) -{ - MV_U32 devId; - - devId = mvCtrlModelGet(); - - switch(devId){ - case MV_6281_DEV_ID: - return MV_6281_TS; - break; - case MV_6192_DEV_ID: - return MV_6192_TS; - break; - case MV_6190_DEV_ID: - return MV_6190_TS; - break; - case MV_6180_DEV_ID: - return MV_6180_TS; - break; - } - return 0; -} -#endif - -#if defined(MV_INCLUDE_AUDIO) -/******************************************************************************* -* mvCtrlAudioSupport - Return if this controller has integrated AUDIO flash support -* -* DESCRIPTION: -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_TRUE if AUDIO is supported and MV_FALSE otherwise -* -*******************************************************************************/ -MV_U32 mvCtrlAudioSupport(MV_VOID) -{ - MV_U32 devId; - - devId = mvCtrlModelGet(); - - switch(devId){ - case MV_6281_DEV_ID: - return MV_6281_AUDIO; - break; - case MV_6192_DEV_ID: - return MV_6192_AUDIO; - break; - case MV_6190_DEV_ID: - return MV_6190_AUDIO; - break; - case MV_6180_DEV_ID: - return MV_6180_AUDIO; - break; - } - return 0; - -} -#endif - -#if defined(MV_INCLUDE_TDM) -/******************************************************************************* -* mvCtrlTdmSupport - Return if this controller has integrated TDM flash support -* -* DESCRIPTION: -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_TRUE if TDM is supported and MV_FALSE otherwise -* -*******************************************************************************/ -MV_U32 mvCtrlTdmSupport(MV_VOID) -{ - MV_U32 devId; - - devId = mvCtrlModelGet(); - - switch(devId){ - case MV_6281_DEV_ID: - return MV_6281_TDM; - break; - case MV_6192_DEV_ID: - return MV_6192_TDM; - break; - case MV_6190_DEV_ID: - return MV_6190_TDM; - break; - case MV_6180_DEV_ID: - return MV_6180_TDM; - break; - } - return 0; - -} -#endif - -/******************************************************************************* -* mvCtrlModelGet - Get Marvell controller device model (Id) -* -* DESCRIPTION: -* This function returns 16bit describing the device model (ID) as defined -* in PCI Device and Vendor ID configuration register offset 0x0. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* 16bit desscribing Marvell controller ID -* -*******************************************************************************/ -MV_U16 mvCtrlModelGet(MV_VOID) -{ - MV_U32 devId; - - devId = MV_REG_READ(CHIP_BOND_REG); - devId &= PCKG_OPT_MASK; - - switch(devId){ - case 2: - return MV_6281_DEV_ID; - break; - case 1: - if (((MV_REG_READ(PEX_CFG_DIRECT_ACCESS(0,PEX_DEVICE_AND_VENDOR_ID))& 0xffff0000) >> 16) - == MV_6190_DEV_ID) - return MV_6190_DEV_ID; - else - return MV_6192_DEV_ID; - break; - case 0: - return MV_6180_DEV_ID; - break; - } - - return 0; -} -/******************************************************************************* -* mvCtrlRevGet - Get Marvell controller device revision number -* -* DESCRIPTION: -* This function returns 8bit describing the device revision as defined -* in PCI Express Class Code and Revision ID Register. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* 8bit desscribing Marvell controller revision number -* -*******************************************************************************/ -MV_U8 mvCtrlRevGet(MV_VOID) -{ - MV_U8 revNum; -#if defined(MV_INCLUDE_CLK_PWR_CNTRL) - /* Check pex power state */ - MV_U32 pexPower; - pexPower = mvCtrlPwrClckGet(PEX_UNIT_ID,0); - if (pexPower == MV_FALSE) - mvCtrlPwrClckSet(PEX_UNIT_ID, 0, MV_TRUE); -#endif - revNum = (MV_U8)MV_REG_READ(PEX_CFG_DIRECT_ACCESS(0,PCI_CLASS_CODE_AND_REVISION_ID)); -#if defined(MV_INCLUDE_CLK_PWR_CNTRL) - /* Return to power off state */ - if (pexPower == MV_FALSE) - mvCtrlPwrClckSet(PEX_UNIT_ID, 0, MV_FALSE); -#endif - return ((revNum & PCCRIR_REVID_MASK) >> PCCRIR_REVID_OFFS); -} - -/******************************************************************************* -* mvCtrlNameGet - Get Marvell controller name -* -* DESCRIPTION: -* This function returns a string describing the device model and revision. -* -* INPUT: -* None. -* -* OUTPUT: -* pNameBuff - Buffer to contain device name string. Minimum size 30 chars. -* -* RETURN: -* -* MV_ERROR if informantion can not be read. -*******************************************************************************/ -MV_STATUS mvCtrlNameGet(char *pNameBuff) -{ - mvOsSPrintf (pNameBuff, "%s%x Rev %d", SOC_NAME_PREFIX, - mvCtrlModelGet(), mvCtrlRevGet()); - - return MV_OK; -} - -/******************************************************************************* -* mvCtrlModelRevGet - Get Controller Model (Device ID) and Revision -* -* DESCRIPTION: -* This function returns 32bit value describing both Device ID and Revision -* as defined in PCI Express Device and Vendor ID Register and device revision -* as defined in PCI Express Class Code and Revision ID Register. - -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* 32bit describing both controller device ID and revision number -* -*******************************************************************************/ -MV_U32 mvCtrlModelRevGet(MV_VOID) -{ - return ((mvCtrlModelGet() << 16) | mvCtrlRevGet()); -} - -/******************************************************************************* -* mvCtrlModelRevNameGet - Get Marvell controller name -* -* DESCRIPTION: -* This function returns a string describing the device model and revision. -* -* INPUT: -* None. -* -* OUTPUT: -* pNameBuff - Buffer to contain device name string. Minimum size 30 chars. -* -* RETURN: -* -* MV_ERROR if informantion can not be read. -*******************************************************************************/ - -MV_STATUS mvCtrlModelRevNameGet(char *pNameBuff) -{ - - switch (mvCtrlModelRevGet()) - { - case MV_6281_A0_ID: - mvOsSPrintf (pNameBuff, "%s",MV_6281_A0_NAME); - break; - case MV_6192_A0_ID: - mvOsSPrintf (pNameBuff, "%s",MV_6192_A0_NAME); - break; - case MV_6180_A0_ID: - mvOsSPrintf (pNameBuff, "%s",MV_6180_A0_NAME); - break; - case MV_6190_A0_ID: - mvOsSPrintf (pNameBuff, "%s",MV_6190_A0_NAME); - break; - case MV_6281_A1_ID: - mvOsSPrintf (pNameBuff, "%s",MV_6281_A1_NAME); - break; - case MV_6192_A1_ID: - mvOsSPrintf (pNameBuff, "%s",MV_6192_A1_NAME); - break; - case MV_6180_A1_ID: - mvOsSPrintf (pNameBuff, "%s",MV_6180_A1_NAME); - break; - case MV_6190_A1_ID: - mvOsSPrintf (pNameBuff, "%s",MV_6190_A1_NAME); - break; - default: - mvCtrlNameGet(pNameBuff); - break; - } - - return MV_OK; -} - - -/******************************************************************************* -* ctrlWinOverlapTest - Test address windows for overlaping. -* -* DESCRIPTION: -* This function checks the given two address windows for overlaping. -* -* INPUT: -* pAddrWin1 - Address window 1. -* pAddrWin2 - Address window 2. -* -* OUTPUT: -* None. -* -* RETURN: -* -* MV_TRUE if address window overlaps, MV_FALSE otherwise. -*******************************************************************************/ -MV_STATUS ctrlWinOverlapTest(MV_ADDR_WIN *pAddrWin1, MV_ADDR_WIN *pAddrWin2) -{ - MV_U32 winBase1, winBase2; - MV_U32 winTop1, winTop2; - - /* check if we have overflow than 4G*/ - if (((0xffffffff - pAddrWin1->baseLow) < pAddrWin1->size-1)|| - ((0xffffffff - pAddrWin2->baseLow) < pAddrWin2->size-1)) - { - return MV_TRUE; - } - - winBase1 = pAddrWin1->baseLow; - winBase2 = pAddrWin2->baseLow; - winTop1 = winBase1 + pAddrWin1->size-1; - winTop2 = winBase2 + pAddrWin2->size-1; - - - if (((winBase1 <= winTop2 ) && ( winTop2 <= winTop1)) || - ((winBase1 <= winBase2) && (winBase2 <= winTop1))) - { - return MV_TRUE; - } - else - { - return MV_FALSE; - } -} - -/******************************************************************************* -* ctrlWinWithinWinTest - Test address windows for overlaping. -* -* DESCRIPTION: -* This function checks the given win1 boundries is within -* win2 boundries. -* -* INPUT: -* pAddrWin1 - Address window 1. -* pAddrWin2 - Address window 2. -* -* OUTPUT: -* None. -* -* RETURN: -* -* MV_TRUE if found win1 inside win2, MV_FALSE otherwise. -*******************************************************************************/ -MV_STATUS ctrlWinWithinWinTest(MV_ADDR_WIN *pAddrWin1, MV_ADDR_WIN *pAddrWin2) -{ - MV_U32 winBase1, winBase2; - MV_U32 winTop1, winTop2; - - winBase1 = pAddrWin1->baseLow; - winBase2 = pAddrWin2->baseLow; - winTop1 = winBase1 + pAddrWin1->size -1; - winTop2 = winBase2 + pAddrWin2->size -1; - - if (((winBase1 >= winBase2 ) && ( winBase1 <= winTop2)) || - ((winTop1 >= winBase2) && (winTop1 <= winTop2))) - { - return MV_TRUE; - } - else - { - return MV_FALSE; - } -} - -static const char* cntrlName[] = TARGETS_NAME_ARRAY; - -/******************************************************************************* -* mvCtrlTargetNameGet - Get Marvell controller target name -* -* DESCRIPTION: -* This function convert the trget enumeration to string. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* Target name (const MV_8 *) -*******************************************************************************/ -const MV_8* mvCtrlTargetNameGet( MV_TARGET target ) -{ - - if (target >= MAX_TARGETS) - { - return "target unknown"; - } - - return cntrlName[target]; -} - -/******************************************************************************* -* mvCtrlAddrDecShow - Print the Controller units address decode map. -* -* DESCRIPTION: -* This function the Controller units address decode map. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_VOID mvCtrlAddrDecShow(MV_VOID) -{ - mvCpuIfAddDecShow(); - mvAhbToMbusAddDecShow(); -#if defined(MV_INCLUDE_PEX) - mvPexAddrDecShow(); -#endif -#if defined(MV_INCLUDE_USB) - mvUsbAddrDecShow(); -#endif -#if defined(MV_INCLUDE_GIG_ETH) - mvEthAddrDecShow(); -#endif -#if defined(MV_INCLUDE_XOR) - mvXorAddrDecShow(); -#endif -#if defined(MV_INCLUDE_SATA) - mvSataAddrDecShow(); -#endif -#if defined(MV_INCLUDE_AUDIO) - mvAudioAddrDecShow(); -#endif -#if defined(MV_INCLUDE_TS) - mvTsuAddrDecShow(); -#endif -} - -/******************************************************************************* -* ctrlSizeToReg - Extract size value for register assignment. -* -* DESCRIPTION: -* Address decode size parameter must be programed from LSB to MSB as -* sequence of 1's followed by sequence of 0's. The number of 1's -* specifies the size of the window in 64 KB granularity (e.g. a -* value of 0x00ff specifies 256x64k = 16 MB). -* This function extract the size value from the size parameter according -* to given aligment paramter. For example for size 0x1000000 (16MB) and -* aligment 0x10000 (64KB) the function will return 0x00FF. -* -* INPUT: -* size - Size. -* alignment - Size alignment. Note that alignment must be power of 2! -* -* OUTPUT: -* None. -* -* RETURN: -* 32bit describing size register value correspond to size parameter. -* If value is '-1' size parameter or aligment are invalid. -*******************************************************************************/ -MV_U32 ctrlSizeToReg(MV_U32 size, MV_U32 alignment) -{ - MV_U32 retVal; - - /* Check size parameter alignment */ - if ((0 == size) || (MV_IS_NOT_ALIGN(size, alignment))) - { - DB(mvOsPrintf("ctrlSizeToReg: ERR. Size is zero or not aligned.\n")); - return -1; - } - - /* Take out the "alignment" portion out of the size parameter */ - alignment--; /* Now the alignmet is a sequance of '1' (e.g. 0xffff) */ - /* and size is 0x1000000 (16MB) for example */ - while(alignment & 1) /* Check that alignmet LSB is set */ - { - size = (size >> 1); /* If LSB is set, move 'size' one bit to right */ - alignment = (alignment >> 1); - } - - /* If after the alignment first '0' was met we still have '1' in */ - /* it then aligment is invalid (not power of 2) */ - if (alignment) - { - DB(mvOsPrintf("ctrlSizeToReg: ERR. Alignment parameter 0x%x invalid.\n", - (MV_U32)alignment)); - return -1; - } - - /* Now the size is shifted right according to aligment: 0x0100 */ - size--; /* Now the size is a sequance of '1': 0x00ff */ - - retVal = size ; - - /* Check that LSB to MSB is sequence of 1's followed by sequence of 0's */ - while(size & 1) /* Check that LSB is set */ - { - size = (size >> 1); /* If LSB is set, move one bit to the right */ - } - - if (size) /* Sequance of 1's is over. Check that we have no other 1's */ - { - DB(mvOsPrintf("ctrlSizeToReg: ERR. Size parameter 0x%x invalid.\n", - size)); - return -1; - } - - return retVal; - -} - -/******************************************************************************* -* ctrlRegToSize - Extract size value from register value. -* -* DESCRIPTION: -* This function extract a size value from the register size parameter -* according to given aligment paramter. For example for register size -* value 0xff and aligment 0x10000 the function will return 0x01000000. -* -* INPUT: -* regSize - Size as in register format. See ctrlSizeToReg. -* alignment - Size alignment. Note that alignment must be power of 2! -* -* OUTPUT: -* None. -* -* RETURN: -* 32bit describing size. -* If value is '-1' size parameter or aligment are invalid. -*******************************************************************************/ -MV_U32 ctrlRegToSize(MV_U32 regSize, MV_U32 alignment) -{ - MV_U32 temp; - - /* Check that LSB to MSB is sequence of 1's followed by sequence of 0's */ - temp = regSize; /* Now the size is a sequance of '1': 0x00ff */ - - while(temp & 1) /* Check that LSB is set */ - { - temp = (temp >> 1); /* If LSB is set, move one bit to the right */ - } - - if (temp) /* Sequance of 1's is over. Check that we have no other 1's */ - { - DB(mvOsPrintf("ctrlRegToSize: ERR. Size parameter 0x%x invalid.\n", - regSize)); - return -1; - } - - - /* Check that aligment is a power of two */ - temp = alignment - 1;/* Now the alignmet is a sequance of '1' (0xffff) */ - - while(temp & 1) /* Check that alignmet LSB is set */ - { - temp = (temp >> 1); /* If LSB is set, move 'size' one bit to right */ - } - - /* If after the 'temp' first '0' was met we still have '1' in 'temp' */ - /* then 'temp' is invalid (not power of 2) */ - if (temp) - { - DB(mvOsPrintf("ctrlSizeToReg: ERR. Alignment parameter 0x%x invalid.\n", - alignment)); - return -1; - } - - regSize++; /* Now the size is 0x0100 */ - - /* Add in the "alignment" portion to the register size parameter */ - alignment--; /* Now the alignmet is a sequance of '1' (e.g. 0xffff) */ - - while(alignment & 1) /* Check that alignmet LSB is set */ - { - regSize = (regSize << 1); /* LSB is set, move 'size' one bit left */ - alignment = (alignment >> 1); - } - - return regSize; -} - - -/******************************************************************************* -* ctrlSizeRegRoundUp - Round up given size -* -* DESCRIPTION: -* This function round up a given size to a size that fits the -* restrictions of size format given an aligment parameter. -* to given aligment paramter. For example for size parameter 0xa1000 and -* aligment 0x1000 the function will return 0xFF000. -* -* INPUT: -* size - Size. -* alignment - Size alignment. Note that alignment must be power of 2! -* -* OUTPUT: -* None. -* -* RETURN: -* 32bit describing size value correspond to size in register. -*******************************************************************************/ -MV_U32 ctrlSizeRegRoundUp(MV_U32 size, MV_U32 alignment) -{ - MV_U32 msbBit = 0; - MV_U32 retSize; - - /* Check if size parameter is already comply with restriction */ - if (!(-1 == ctrlSizeToReg(size, alignment))) - { - return size; - } - - while(size) - { - size = (size >> 1); - msbBit++; - } - - retSize = (1 << msbBit); - - if (retSize < alignment) - { - return alignment; - } - else - { - return retSize; - } -} -/******************************************************************************* -* mvCtrlSysRstLengthCounterGet - Return number of milliseconds the reset button -* was pressed and clear counter -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* -* RETURN: number of milliseconds the reset button was pressed -*******************************************************************************/ -MV_U32 mvCtrlSysRstLengthCounterGet(MV_VOID) -{ - static volatile MV_U32 Count = 0; - - if(!Count) { - Count = (MV_REG_READ(SYSRST_LENGTH_COUNTER_REG) & SLCR_COUNT_MASK); - Count = (Count / (MV_BOARD_REFCLK_25MHZ / 1000)); - /* clear counter for next boot */ - MV_REG_BIT_SET(SYSRST_LENGTH_COUNTER_REG, SLCR_CLR_MASK); - } - - DB(mvOsPrintf("mvCtrlSysRstLengthCounterGet: Reset button was pressed for %u milliseconds\n", Count)); - - return Count; -} - -MV_BOOL mvCtrlIsBootFromSPI(MV_VOID) -{ - MV_U32 satr = 0; - satr = MV_REG_READ(MPP_SAMPLE_AT_RESET); - if(mvCtrlModelGet() == MV_6180_DEV_ID) - { - if (MSAR_BOOT_MODE_6180(satr) == MSAR_BOOT_SPI_WITH_BOOTROM_6180) - return MV_TRUE; - else - return MV_FALSE; - } - satr = satr & MSAR_BOOT_MODE_MASK; - if (satr == MSAR_BOOT_SPI_WITH_BOOTROM) - return MV_TRUE; - else - return MV_FALSE; -} - -MV_BOOL mvCtrlIsBootFromSPIUseNAND(MV_VOID) -{ - MV_U32 satr = 0; - if(mvCtrlModelGet() == MV_6180_DEV_ID) - return MV_FALSE; - satr = MV_REG_READ(MPP_SAMPLE_AT_RESET); - satr = satr & MSAR_BOOT_MODE_MASK; - - if (satr == MSAR_BOOT_SPI_USE_NAND_WITH_BOOTROM) - return MV_TRUE; - else - return MV_FALSE; -} - -MV_BOOL mvCtrlIsBootFromNAND(MV_VOID) -{ - MV_U32 satr = 0; - satr = MV_REG_READ(MPP_SAMPLE_AT_RESET); - if(mvCtrlModelGet() == MV_6180_DEV_ID) - { - if (MSAR_BOOT_MODE_6180(satr) == MSAR_BOOT_NAND_WITH_BOOTROM_6180) - return MV_TRUE; - else - return MV_FALSE; - } - satr = satr & MSAR_BOOT_MODE_MASK; - if ((satr == MSAR_BOOT_NAND_WITH_BOOTROM)) - return MV_TRUE; - else - return MV_FALSE; -} - -#if defined(MV_INCLUDE_CLK_PWR_CNTRL) -/******************************************************************************* -* mvCtrlPwrSaveOn - Set Power save mode -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* -* RETURN: -*******************************************************************************/ -MV_VOID mvCtrlPwrSaveOn(MV_VOID) -{ - unsigned long old,temp; - /* Disable int */ - __asm__ __volatile__("mrs %0, cpsr\n" - "orr %1, %0, #0xc0\n" - "msr cpsr_c, %1" - : "=r" (old), "=r" (temp) - : - : "memory"); - - /* Set SoC in power save */ - MV_REG_BIT_SET(POWER_MNG_CTRL_REG, BIT11); - /* Wait for int */ - __asm__ __volatile__("mcr p15, 0, r0, c7, c0, 4"); - - /* Enabled int */ - __asm__ __volatile__("msr cpsr_c, %0" - : - : "r" (old) - : "memory"); -} - - - -/******************************************************************************* -* mvCtrlPwrSaveOff - Go out of power save mode -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* -* RETURN: -*******************************************************************************/ -MV_VOID mvCtrlPwrSaveOff(MV_VOID) -{ - unsigned long old,temp; - /* Disable int */ - __asm__ __volatile__("mrs %0, cpsr\n" - "orr %1, %0, #0xc0\n" - "msr cpsr_c, %1" - : "=r" (old), "=r" (temp) - : - : "memory"); - - /* Set SoC in power save */ - MV_REG_BIT_RESET(POWER_MNG_CTRL_REG, BIT11); - /* Wait for int */ - __asm__ __volatile__("mcr p15, 0, r0, c7, c0, 4"); - - /* Enabled int */ - __asm__ __volatile__("msr cpsr_c, %0" - : - : "r" (old) - : "memory"); -} - -/******************************************************************************* -* mvCtrlPwrClckSet - Set Power State for specific Unit -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* -* RETURN: -*******************************************************************************/ -MV_VOID mvCtrlPwrClckSet(MV_UNIT_ID unitId, MV_U32 index, MV_BOOL enable) -{ - switch (unitId) - { -#if defined(MV_INCLUDE_PEX) - case PEX_UNIT_ID: - if (enable == MV_FALSE) - { - MV_REG_BIT_RESET(POWER_MNG_CTRL_REG, PMC_PEXSTOPCLOCK_MASK); - } - else - { - MV_REG_BIT_SET(POWER_MNG_CTRL_REG, PMC_PEXSTOPCLOCK_MASK); - } - break; -#endif -#if defined(MV_INCLUDE_GIG_ETH) - case ETH_GIG_UNIT_ID: - if (enable == MV_FALSE) - { - MV_REG_BIT_RESET(POWER_MNG_CTRL_REG, PMC_GESTOPCLOCK_MASK(index)); - } - else - { - MV_REG_BIT_SET(POWER_MNG_CTRL_REG, PMC_GESTOPCLOCK_MASK(index)); - } - break; -#endif -#if defined(MV_INCLUDE_INTEG_SATA) - case SATA_UNIT_ID: - if (enable == MV_FALSE) - { - MV_REG_BIT_RESET(POWER_MNG_CTRL_REG, PMC_SATASTOPCLOCK_MASK(index)); - } - else - { - MV_REG_BIT_SET(POWER_MNG_CTRL_REG, PMC_SATASTOPCLOCK_MASK(index)); - } - break; -#endif -#if defined(MV_INCLUDE_CESA) - case CESA_UNIT_ID: - if (enable == MV_FALSE) - { - MV_REG_BIT_RESET(POWER_MNG_CTRL_REG, PMC_SESTOPCLOCK_MASK); - } - else - { - MV_REG_BIT_SET(POWER_MNG_CTRL_REG, PMC_SESTOPCLOCK_MASK); - } - break; -#endif -#if defined(MV_INCLUDE_USB) - case USB_UNIT_ID: - if (enable == MV_FALSE) - { - MV_REG_BIT_RESET(POWER_MNG_CTRL_REG, PMC_USBSTOPCLOCK_MASK); - } - else - { - MV_REG_BIT_SET(POWER_MNG_CTRL_REG, PMC_USBSTOPCLOCK_MASK); - } - break; -#endif -#if defined(MV_INCLUDE_AUDIO) - case AUDIO_UNIT_ID: - if (enable == MV_FALSE) - { - MV_REG_BIT_RESET(POWER_MNG_CTRL_REG, PMC_AUDIOSTOPCLOCK_MASK); - } - else - { - MV_REG_BIT_SET(POWER_MNG_CTRL_REG, PMC_AUDIOSTOPCLOCK_MASK); - } - break; -#endif -#if defined(MV_INCLUDE_TS) - case TS_UNIT_ID: - if (enable == MV_FALSE) - { - MV_REG_BIT_RESET(POWER_MNG_CTRL_REG, PMC_TSSTOPCLOCK_MASK); - } - else - { - MV_REG_BIT_SET(POWER_MNG_CTRL_REG, PMC_TSSTOPCLOCK_MASK); - } - break; -#endif -#if defined(MV_INCLUDE_SDIO) - case SDIO_UNIT_ID: - if (enable == MV_FALSE) - { - MV_REG_BIT_RESET(POWER_MNG_CTRL_REG, PMC_SDIOSTOPCLOCK_MASK); - } - else - { - MV_REG_BIT_SET(POWER_MNG_CTRL_REG, PMC_SDIOSTOPCLOCK_MASK); - } - break; -#endif -#if defined(MV_INCLUDE_TDM) - case TDM_UNIT_ID: - if (enable == MV_FALSE) - { - MV_REG_BIT_RESET(POWER_MNG_CTRL_REG, PMC_TDMSTOPCLOCK_MASK); - } - else - { - MV_REG_BIT_SET(POWER_MNG_CTRL_REG, PMC_TDMSTOPCLOCK_MASK); - } - break; -#endif - - default: - - break; - - } -} - -/******************************************************************************* -* mvCtrlPwrClckGet - Get Power State of specific Unit -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* -* RETURN: -******************************************************************************/ -MV_BOOL mvCtrlPwrClckGet(MV_UNIT_ID unitId, MV_U32 index) -{ - MV_U32 reg = MV_REG_READ(POWER_MNG_CTRL_REG); - MV_BOOL state = MV_TRUE; - - switch (unitId) - { -#if defined(MV_INCLUDE_PEX) - case PEX_UNIT_ID: - if ((reg & PMC_PEXSTOPCLOCK_MASK) == PMC_PEXSTOPCLOCK_STOP) - { - state = MV_FALSE; - } - else state = MV_TRUE; - - break; -#endif -#if defined(MV_INCLUDE_GIG_ETH) - case ETH_GIG_UNIT_ID: - if ((reg & PMC_GESTOPCLOCK_MASK(index)) == PMC_GESTOPCLOCK_STOP(index)) - { - state = MV_FALSE; - } - else state = MV_TRUE; - break; -#endif -#if defined(MV_INCLUDE_SATA) - case SATA_UNIT_ID: - if ((reg & PMC_SATASTOPCLOCK_MASK(index)) == PMC_SATASTOPCLOCK_STOP(index)) - { - state = MV_FALSE; - } - else state = MV_TRUE; - break; -#endif -#if defined(MV_INCLUDE_CESA) - case CESA_UNIT_ID: - if ((reg & PMC_SESTOPCLOCK_MASK) == PMC_SESTOPCLOCK_STOP) - { - state = MV_FALSE; - } - else state = MV_TRUE; - break; -#endif -#if defined(MV_INCLUDE_USB) - case USB_UNIT_ID: - if ((reg & PMC_USBSTOPCLOCK_MASK) == PMC_USBSTOPCLOCK_STOP) - { - state = MV_FALSE; - } - else state = MV_TRUE; - break; -#endif -#if defined(MV_INCLUDE_AUDIO) - case AUDIO_UNIT_ID: - if ((reg & PMC_AUDIOSTOPCLOCK_MASK) == PMC_AUDIOSTOPCLOCK_STOP) - { - state = MV_FALSE; - } - else state = MV_TRUE; - break; -#endif -#if defined(MV_INCLUDE_TS) - case TS_UNIT_ID: - if ((reg & PMC_TSSTOPCLOCK_MASK) == PMC_TSSTOPCLOCK_STOP) - { - state = MV_FALSE; - } - else state = MV_TRUE; - break; -#endif -#if defined(MV_INCLUDE_SDIO) - case SDIO_UNIT_ID: - if ((reg & PMC_SDIOSTOPCLOCK_MASK)== PMC_SDIOSTOPCLOCK_STOP) - { - state = MV_FALSE; - } - else state = MV_TRUE; - break; -#endif -#if defined(MV_INCLUDE_TDM) - case TDM_UNIT_ID: - if ((reg & PMC_TDMSTOPCLOCK_MASK) == PMC_TDMSTOPCLOCK_STOP) - { - state = MV_FALSE; - } - else state = MV_TRUE; - break; -#endif - - default: - state = MV_TRUE; - break; - } - - - return state; -} -/******************************************************************************* -* mvCtrlPwrMemSet - Set Power State for memory on specific Unit -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* -* RETURN: -*******************************************************************************/ -MV_VOID mvCtrlPwrMemSet(MV_UNIT_ID unitId, MV_U32 index, MV_BOOL enable) -{ - switch (unitId) - { -#if defined(MV_INCLUDE_PEX) - case PEX_UNIT_ID: - if (enable == MV_FALSE) - { - MV_REG_BIT_SET(POWER_MNG_MEM_CTRL_REG, PMC_PEXSTOPMEM_MASK); - } - else - { - MV_REG_BIT_RESET(POWER_MNG_MEM_CTRL_REG, PMC_PEXSTOPMEM_MASK); - } - break; -#endif -#if defined(MV_INCLUDE_GIG_ETH) - case ETH_GIG_UNIT_ID: - if (enable == MV_FALSE) - { - MV_REG_BIT_SET(POWER_MNG_MEM_CTRL_REG, PMC_GESTOPMEM_MASK(index)); - } - else - { - MV_REG_BIT_RESET(POWER_MNG_MEM_CTRL_REG, PMC_GESTOPMEM_MASK(index)); - } - break; -#endif -#if defined(MV_INCLUDE_INTEG_SATA) - case SATA_UNIT_ID: - if (enable == MV_FALSE) - { - MV_REG_BIT_SET(POWER_MNG_MEM_CTRL_REG, PMC_SATASTOPMEM_MASK(index)); - } - else - { - MV_REG_BIT_RESET(POWER_MNG_MEM_CTRL_REG, PMC_SATASTOPMEM_MASK(index)); - } - break; -#endif -#if defined(MV_INCLUDE_CESA) - case CESA_UNIT_ID: - if (enable == MV_FALSE) - { - MV_REG_BIT_SET(POWER_MNG_MEM_CTRL_REG, PMC_SESTOPMEM_MASK); - } - else - { - MV_REG_BIT_RESET(POWER_MNG_MEM_CTRL_REG, PMC_SESTOPMEM_MASK); - } - break; -#endif -#if defined(MV_INCLUDE_USB) - case USB_UNIT_ID: - if (enable == MV_FALSE) - { - MV_REG_BIT_SET(POWER_MNG_MEM_CTRL_REG, PMC_USBSTOPMEM_MASK); - } - else - { - MV_REG_BIT_RESET(POWER_MNG_MEM_CTRL_REG, PMC_USBSTOPMEM_MASK); - } - break; -#endif -#if defined(MV_INCLUDE_AUDIO) - case AUDIO_UNIT_ID: - if (enable == MV_FALSE) - { - MV_REG_BIT_SET(POWER_MNG_MEM_CTRL_REG, PMC_AUDIOSTOPMEM_MASK); - } - else - { - MV_REG_BIT_RESET(POWER_MNG_MEM_CTRL_REG, PMC_AUDIOSTOPMEM_MASK); - } - break; -#endif -#if defined(MV_INCLUDE_XOR) - case XOR_UNIT_ID: - if (enable == MV_FALSE) - { - MV_REG_BIT_SET(POWER_MNG_MEM_CTRL_REG, PMC_XORSTOPMEM_MASK(index)); - } - else - { - MV_REG_BIT_RESET(POWER_MNG_MEM_CTRL_REG, PMC_XORSTOPMEM_MASK(index)); - } - break; -#endif - default: - - break; - - } -} - -/******************************************************************************* -* mvCtrlPwrMemGet - Get Power State of memory on specific Unit -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* -* RETURN: -******************************************************************************/ -MV_BOOL mvCtrlPwrMemGet(MV_UNIT_ID unitId, MV_U32 index) -{ - MV_U32 reg = MV_REG_READ(POWER_MNG_MEM_CTRL_REG); - MV_BOOL state = MV_TRUE; - - switch (unitId) - { -#if defined(MV_INCLUDE_PEX) - case PEX_UNIT_ID: - if ((reg & PMC_PEXSTOPMEM_MASK) == PMC_PEXSTOPMEM_STOP) - { - state = MV_FALSE; - } - else state = MV_TRUE; - - break; -#endif -#if defined(MV_INCLUDE_GIG_ETH) - case ETH_GIG_UNIT_ID: - if ((reg & PMC_GESTOPMEM_MASK(index)) == PMC_GESTOPMEM_STOP(index)) - { - state = MV_FALSE; - } - else state = MV_TRUE; - break; -#endif -#if defined(MV_INCLUDE_SATA) - case SATA_UNIT_ID: - if ((reg & PMC_SATASTOPMEM_MASK(index)) == PMC_SATASTOPMEM_STOP(index)) - { - state = MV_FALSE; - } - else state = MV_TRUE; - break; -#endif -#if defined(MV_INCLUDE_CESA) - case CESA_UNIT_ID: - if ((reg & PMC_SESTOPMEM_MASK) == PMC_SESTOPMEM_STOP) - { - state = MV_FALSE; - } - else state = MV_TRUE; - break; -#endif -#if defined(MV_INCLUDE_USB) - case USB_UNIT_ID: - if ((reg & PMC_USBSTOPMEM_MASK) == PMC_USBSTOPMEM_STOP) - { - state = MV_FALSE; - } - else state = MV_TRUE; - break; -#endif -#if defined(MV_INCLUDE_AUDIO) - case AUDIO_UNIT_ID: - if ((reg & PMC_AUDIOSTOPMEM_MASK) == PMC_AUDIOSTOPMEM_STOP) - { - state = MV_FALSE; - } - else state = MV_TRUE; - break; -#endif -#if defined(MV_INCLUDE_XOR) - case XOR_UNIT_ID: - if ((reg & PMC_XORSTOPMEM_MASK(index)) == PMC_XORSTOPMEM_STOP(index)) - { - state = MV_FALSE; - } - else state = MV_TRUE; - break; -#endif - - default: - state = MV_TRUE; - break; - } - - - return state; -} -#else -MV_VOID mvCtrlPwrClckSet(MV_UNIT_ID unitId, MV_U32 index, MV_BOOL enable) {return;} -MV_BOOL mvCtrlPwrClckGet(MV_UNIT_ID unitId, MV_U32 index) {return MV_TRUE;} -#endif /* #if defined(MV_INCLUDE_CLK_PWR_CNTRL) */ - - -/******************************************************************************* -* mvMPPConfigToSPI - Change MPP[3:0] configuration to SPI mode -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* -* RETURN: -******************************************************************************/ -MV_VOID mvMPPConfigToSPI(MV_VOID) -{ - MV_U32 mppVal = 0; - MV_U32 bootVal = 0; - - if(!mvCtrlIsBootFromSPIUseNAND()) - return; - mppVal = 0x00002220; /* Set MPP [3:1] to SPI mode */ - bootVal = MV_REG_READ(mvCtrlMppRegGet(0)); - bootVal &= 0xffff000f; - mppVal |= bootVal; - - MV_REG_WRITE(mvCtrlMppRegGet(0), mppVal); -} - - -/******************************************************************************* -* mvMPPConfigToDefault - Change MPP[7:0] configuration to default configuration -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* -* RETURN: -******************************************************************************/ -MV_VOID mvMPPConfigToDefault(MV_VOID) -{ - MV_U32 mppVal = 0; - MV_U32 bootVal = 0; - - if(!mvCtrlIsBootFromSPIUseNAND()) - return; - mppVal = mvBoardMppGet(0); - bootVal = MV_REG_READ(mvCtrlMppRegGet(0)); - mppVal &= ~0xffff000f; - bootVal &= 0xffff000f; - mppVal |= bootVal; - - MV_REG_WRITE(mvCtrlMppRegGet(0), mppVal); -} - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/mvCtrlEnvLib.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/mvCtrlEnvLib.h deleted file mode 100644 index 6e2e813..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/mvCtrlEnvLib.h +++ /dev/null @@ -1,185 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -#ifndef __INCmvCtrlEnvLibh -#define __INCmvCtrlEnvLibh - -/* includes */ -#include "mvSysHwConfig.h" -#include "mvCommon.h" -#include "mvTypes.h" -#include "mvOs.h" -#include "boardEnv/mvBoardEnvLib.h" -#include "ctrlEnv/mvCtrlEnvSpec.h" -#include "ctrlEnv/mvCtrlEnvRegs.h" -#include "ctrlEnv/mvCtrlEnvAddrDec.h" - - -/* typedefs */ - -/* This enumerator describes the possible HW cache coherency policies the */ -/* controllers supports. */ -typedef enum _mvCachePolicy -{ - NO_COHERENCY, /* No HW cache coherency support */ - WT_COHERENCY, /* HW cache coherency supported in Write Through policy */ - WB_COHERENCY /* HW cache coherency supported in Write Back policy */ -}MV_CACHE_POLICY; - - -/* The swapping is referred to a 64-bit words (as this is the controller */ -/* internal data path width). This enumerator describes the possible */ -/* data swap types. Below is an example of the data 0x0011223344556677 */ -typedef enum _mvSwapType -{ - MV_BYTE_SWAP, /* Byte Swap 77 66 55 44 33 22 11 00 */ - MV_NO_SWAP, /* No swapping 00 11 22 33 44 55 66 77 */ - MV_BYTE_WORD_SWAP, /* Both byte and word swap 33 22 11 00 77 66 55 44 */ - MV_WORD_SWAP, /* Word swap 44 55 66 77 00 11 22 33 */ - SWAP_TYPE_MAX /* Delimiter for this enumerator */ -}MV_SWAP_TYPE; - -/* This structure describes access rights for Access protection windows */ -/* that can be found in IDMA, XOR, Ethernet and MPSC units. */ -/* Note that the permission enumerator coresponds to its register format. */ -/* For example, Read only premission is presented as "1" in register field. */ -typedef enum _mvAccessRights -{ - NO_ACCESS_ALLOWED = 0, /* No access allowed */ - READ_ONLY = 1, /* Read only permission */ - ACC_RESERVED = 2, /* Reserved access right */ - FULL_ACCESS = 3, /* Read and Write permission */ - MAX_ACC_RIGHTS -}MV_ACCESS_RIGHTS; - - -/* mcspLib.h API list */ - -MV_STATUS mvCtrlEnvInit(MV_VOID); -MV_U32 mvCtrlMppRegGet(MV_U32 mppGroup); - -#if defined(MV_INCLUDE_PEX) -MV_U32 mvCtrlPexMaxIfGet(MV_VOID); -#else -#define mvCtrlPexMaxIfGet() (0) -#endif - -#define mvCtrlPciIfMaxIfGet() (0) - -#if defined(MV_INCLUDE_GIG_ETH) -MV_U32 mvCtrlEthMaxPortGet(MV_VOID); -#endif -#if defined(MV_INCLUDE_XOR) -MV_U32 mvCtrlXorMaxChanGet(MV_VOID); -#endif -#if defined(MV_INCLUDE_USB) -MV_U32 mvCtrlUsbMaxGet(MV_VOID); -#endif -#if defined(MV_INCLUDE_NAND) -MV_U32 mvCtrlNandSupport(MV_VOID); -#endif -#if defined(MV_INCLUDE_SDIO) -MV_U32 mvCtrlSdioSupport(MV_VOID); -#endif -#if defined(MV_INCLUDE_TS) -MV_U32 mvCtrlTsSupport(MV_VOID); -#endif -#if defined(MV_INCLUDE_AUDIO) -MV_U32 mvCtrlAudioSupport(MV_VOID); -#endif -#if defined(MV_INCLUDE_TDM) -MV_U32 mvCtrlTdmSupport(MV_VOID); -#endif - -MV_U16 mvCtrlModelGet(MV_VOID); -MV_U8 mvCtrlRevGet(MV_VOID); -MV_STATUS mvCtrlNameGet(char *pNameBuff); -MV_U32 mvCtrlModelRevGet(MV_VOID); -MV_STATUS mvCtrlModelRevNameGet(char *pNameBuff); -MV_VOID mvCtrlAddrDecShow(MV_VOID); -const MV_8* mvCtrlTargetNameGet(MV_TARGET target); -MV_U32 ctrlSizeToReg(MV_U32 size, MV_U32 alignment); -MV_U32 ctrlRegToSize(MV_U32 regSize, MV_U32 alignment); -MV_U32 ctrlSizeRegRoundUp(MV_U32 size, MV_U32 alignment); -MV_U32 mvCtrlSysRstLengthCounterGet(MV_VOID); -MV_STATUS ctrlWinOverlapTest(MV_ADDR_WIN *pAddrWin1, MV_ADDR_WIN *pAddrWin2); -MV_STATUS ctrlWinWithinWinTest(MV_ADDR_WIN *pAddrWin1, MV_ADDR_WIN *pAddrWin2); - -MV_VOID mvCtrlPwrClckSet(MV_UNIT_ID unitId, MV_U32 index, MV_BOOL enable); -MV_BOOL mvCtrlPwrClckGet(MV_UNIT_ID unitId, MV_U32 index); -MV_VOID mvCtrlPwrMemSet(MV_UNIT_ID unitId, MV_U32 index, MV_BOOL enable); -MV_BOOL mvCtrlIsBootFromSPI(MV_VOID); -MV_BOOL mvCtrlIsBootFromSPIUseNAND(MV_VOID); -MV_BOOL mvCtrlIsBootFromNAND(MV_VOID); -#if defined(MV_INCLUDE_CLK_PWR_CNTRL) -MV_VOID mvCtrlPwrSaveOn(MV_VOID); -MV_VOID mvCtrlPwrSaveOff(MV_VOID); -#endif -MV_BOOL mvCtrlPwrMemGet(MV_UNIT_ID unitId, MV_U32 index); -MV_VOID mvMPPConfigToSPI(MV_VOID); -MV_VOID mvMPPConfigToDefault(MV_VOID); - - -#endif /* __INCmvCtrlEnvLibh */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/mvCtrlEnvRegs.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/mvCtrlEnvRegs.h deleted file mode 100644 index ae3f141..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/mvCtrlEnvRegs.h +++ /dev/null @@ -1,419 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCmvCtrlEnvRegsh -#define __INCmvCtrlEnvRegsh - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* CV Support */ -#define PEX0_MEM0 PEX0_MEM -#define PCI0_MEM0 PEX0_MEM - -/* Controller revision info */ -#define PCI_CLASS_CODE_AND_REVISION_ID 0x008 -#define PCCRIR_REVID_OFFS 0 /* Revision ID */ -#define PCCRIR_REVID_MASK (0xff << PCCRIR_REVID_OFFS) - -/* Controler environment registers offsets */ - -/* Power Managment Control */ -#define POWER_MNG_MEM_CTRL_REG 0x20118 - -#define PMC_GESTOPMEM_OFFS(port) ((port)? 13 : 0) -#define PMC_GESTOPMEM_MASK(port) (1 << PMC_GESTOPMEM_OFFS(port)) -#define PMC_GESTOPMEM_EN(port) (0 << PMC_GESTOPMEM_OFFS(port)) -#define PMC_GESTOPMEM_STOP(port) (1 << PMC_GESTOPMEM_OFFS(port)) - -#define PMC_PEXSTOPMEM_OFFS 1 -#define PMC_PEXSTOPMEM_MASK (1 << PMC_PEXSTOPMEM_OFFS) -#define PMC_PEXSTOPMEM_EN (0 << PMC_PEXSTOPMEM_OFFS) -#define PMC_PEXSTOPMEM_STOP (1 << PMC_PEXSTOPMEM_OFFS) - -#define PMC_USBSTOPMEM_OFFS 2 -#define PMC_USBSTOPMEM_MASK (1 << PMC_USBSTOPMEM_OFFS) -#define PMC_USBSTOPMEM_EN (0 << PMC_USBSTOPMEM_OFFS) -#define PMC_USBSTOPMEM_STOP (1 << PMC_USBSTOPMEM_OFFS) - -#define PMC_DUNITSTOPMEM_OFFS 3 -#define PMC_DUNITSTOPMEM_MASK (1 << PMC_DUNITSTOPMEM_OFFS) -#define PMC_DUNITSTOPMEM_EN (0 << PMC_DUNITSTOPMEM_OFFS) -#define PMC_DUNITSTOPMEM_STOP (1 << PMC_DUNITSTOPMEM_OFFS) - -#define PMC_RUNITSTOPMEM_OFFS 4 -#define PMC_RUNITSTOPMEM_MASK (1 << PMC_RUNITSTOPMEM_OFFS) -#define PMC_RUNITSTOPMEM_EN (0 << PMC_RUNITSTOPMEM_OFFS) -#define PMC_RUNITSTOPMEM_STOP (1 << PMC_RUNITSTOPMEM_OFFS) - -#define PMC_XORSTOPMEM_OFFS(port) (5+(port*2)) -#define PMC_XORSTOPMEM_MASK(port) (1 << PMC_XORSTOPMEM_OFFS(port)) -#define PMC_XORSTOPMEM_EN(port) (0 << PMC_XORSTOPMEM_OFFS(port)) -#define PMC_XORSTOPMEM_STOP(port) (1 << PMC_XORSTOPMEM_OFFS(port)) - -#define PMC_SATASTOPMEM_OFFS(port) (6+(port*5)) -#define PMC_SATASTOPMEM_MASK(port) (1 << PMC_SATASTOPMEM_OFFS(port)) -#define PMC_SATASTOPMEM_EN(port) (0 << PMC_SATASTOPMEM_OFFS(port)) -#define PMC_SATASTOPMEM_STOP(port) (1 << PMC_SATASTOPMEM_OFFS(port)) - -#define PMC_SESTOPMEM_OFFS 8 -#define PMC_SESTOPMEM_MASK (1 << PMC_SESTOPMEM_OFFS) -#define PMC_SESTOPMEM_EN (0 << PMC_SESTOPMEM_OFFS) -#define PMC_SESTOPMEM_STOP (1 << PMC_SESTOPMEM_OFFS) - -#define PMC_AUDIOSTOPMEM_OFFS 9 -#define PMC_AUDIOSTOPMEM_MASK (1 << PMC_AUDIOSTOPMEM_OFFS) -#define PMC_AUDIOSTOPMEM_EN (0 << PMC_AUDIOSTOPMEM_OFFS) -#define PMC_AUDIOSTOPMEM_STOP (1 << PMC_AUDIOSTOPMEM_OFFS) - -#define POWER_MNG_CTRL_REG 0x2011C - -#define PMC_GESTOPCLOCK_OFFS(port) ((port)? 19 : 0) -#define PMC_GESTOPCLOCK_MASK(port) (1 << PMC_GESTOPCLOCK_OFFS(port)) -#define PMC_GESTOPCLOCK_EN(port) (1 << PMC_GESTOPCLOCK_OFFS(port)) -#define PMC_GESTOPCLOCK_STOP(port) (0 << PMC_GESTOPCLOCK_OFFS(port)) - -#define PMC_PEXPHYSTOPCLOCK_OFFS 1 -#define PMC_PEXPHYSTOPCLOCK_MASK (1 << PMC_PEXPHYSTOPCLOCK_OFFS) -#define PMC_PEXPHYSTOPCLOCK_EN (1 << PMC_PEXPHYSTOPCLOCK_OFFS) -#define PMC_PEXPHYSTOPCLOCK_STOP (0 << PMC_PEXPHYSTOPCLOCK_OFFS) - -#define PMC_PEXSTOPCLOCK_OFFS 2 -#define PMC_PEXSTOPCLOCK_MASK (1 << PMC_PEXSTOPCLOCK_OFFS) -#define PMC_PEXSTOPCLOCK_EN (1 << PMC_PEXSTOPCLOCK_OFFS) -#define PMC_PEXSTOPCLOCK_STOP (0 << PMC_PEXSTOPCLOCK_OFFS) - -#define PMC_USBSTOPCLOCK_OFFS 3 -#define PMC_USBSTOPCLOCK_MASK (1 << PMC_USBSTOPCLOCK_OFFS) -#define PMC_USBSTOPCLOCK_EN (1 << PMC_USBSTOPCLOCK_OFFS) -#define PMC_USBSTOPCLOCK_STOP (0 << PMC_USBSTOPCLOCK_OFFS) - -#define PMC_SDIOSTOPCLOCK_OFFS 4 -#define PMC_SDIOSTOPCLOCK_MASK (1 << PMC_SDIOSTOPCLOCK_OFFS) -#define PMC_SDIOSTOPCLOCK_EN (1 << PMC_SDIOSTOPCLOCK_OFFS) -#define PMC_SDIOSTOPCLOCK_STOP (0 << PMC_SDIOSTOPCLOCK_OFFS) - -#define PMC_TSSTOPCLOCK_OFFS 5 -#define PMC_TSSTOPCLOCK_MASK (1 << PMC_TSSTOPCLOCK_OFFS) -#define PMC_TSSTOPCLOCK_EN (1 << PMC_TSSTOPCLOCK_OFFS) -#define PMC_TSSTOPCLOCK_STOP (0 << PMC_TSSTOPCLOCK_OFFS) - -#define PMC_AUDIOSTOPCLOCK_OFFS 9 -#define PMC_AUDIOSTOPCLOCK_MASK (1 << PMC_AUDIOSTOPCLOCK_OFFS) -#define PMC_AUDIOSTOPCLOCK_EN (1 << PMC_AUDIOSTOPCLOCK_OFFS) -#define PMC_AUDIOSTOPCLOCK_STOP (0 << PMC_AUDIOSTOPCLOCK_OFFS) - -#define PMC_POWERSAVE_OFFS 11 -#define PMC_POWERSAVE_MASK (1 << PMC_POWERSAVE_OFFS) -#define PMC_POWERSAVE_EN (1 << PMC_POWERSAVE_OFFS) -#define PMC_POWERSAVE_STOP (0 << PMC_POWERSAVE_OFFS) - - - - -#define PMC_SATASTOPCLOCK_OFFS(port) (14+(port)) -#define PMC_SATASTOPCLOCK_MASK(port) (1 << PMC_SATASTOPCLOCK_OFFS(port)) -#define PMC_SATASTOPCLOCK_EN(port) (1 << PMC_SATASTOPCLOCK_OFFS(port)) -#define PMC_SATASTOPCLOCK_STOP(port) (0 << PMC_SATASTOPCLOCK_OFFS(port)) - -#define PMC_SESTOPCLOCK_OFFS 17 -#define PMC_SESTOPCLOCK_MASK (1 << PMC_SESTOPCLOCK_OFFS) -#define PMC_SESTOPCLOCK_EN (1 << PMC_SESTOPCLOCK_OFFS) -#define PMC_SESTOPCLOCK_STOP (0 << PMC_SESTOPCLOCK_OFFS) - -#define PMC_TDMSTOPCLOCK_OFFS 20 -#define PMC_TDMSTOPCLOCK_MASK (1 << PMC_TDMSTOPCLOCK_OFFS) -#define PMC_TDMSTOPCLOCK_EN (1 << PMC_TDMSTOPCLOCK_OFFS) -#define PMC_TDMSTOPCLOCK_STOP (0 << PMC_TDMSTOPCLOCK_OFFS) - - -/* Controler environment registers offsets */ -#define MPP_CONTROL_REG0 0x10000 -#define MPP_CONTROL_REG1 0x10004 -#define MPP_CONTROL_REG2 0x10008 -#define MPP_CONTROL_REG3 0x1000C -#define MPP_CONTROL_REG4 0x10010 -#define MPP_CONTROL_REG5 0x10014 -#define MPP_CONTROL_REG6 0x10018 -#define MPP_SAMPLE_AT_RESET 0x10030 -#define CHIP_BOND_REG 0x10034 -#define SYSRST_LENGTH_COUNTER_REG 0x10050 -#define SLCR_COUNT_OFFS 0 -#define SLCR_COUNT_MASK (0x1FFFFFFF << SLCR_COUNT_OFFS) -#define SLCR_CLR_OFFS 31 -#define SLCR_CLR_MASK (1 << SLCR_CLR_OFFS) -#define PCKG_OPT_MASK 0x3 -#define MPP_OUTPUT_DRIVE_REG 0x100E0 -#define MPP_RGMII0_OUTPUT_DRIVE_OFFS 7 -#define MPP_3_3_RGMII0_OUTPUT_DRIVE (0x0 << MPP_RGMII0_OUTPUT_DRIVE_OFFS) -#define MPP_1_8_RGMII0_OUTPUT_DRIVE (0x1 << MPP_RGMII0_OUTPUT_DRIVE_OFFS) -#define MPP_RGMII1_OUTPUT_DRIVE_OFFS 15 -#define MPP_3_3_RGMII1_OUTPUT_DRIVE (0x0 << MPP_RGMII1_OUTPUT_DRIVE_OFFS) -#define MPP_1_8_RGMII1_OUTPUT_DRIVE (0x1 << MPP_RGMII1_OUTPUT_DRIVE_OFFS) - -#define MSAR_BOOT_MODE_OFFS 12 -#define MSAR_BOOT_MODE_MASK (0x7 << MSAR_BOOT_MODE_OFFS) -#define MSAR_BOOT_NAND_WITH_BOOTROM (0x5 << MSAR_BOOT_MODE_OFFS) -#define MSAR_BOOT_SPI_WITH_BOOTROM (0x4 << MSAR_BOOT_MODE_OFFS) -#define MSAR_BOOT_SPI_USE_NAND_WITH_BOOTROM (0x2 << MSAR_BOOT_MODE_OFFS) - -#define MSAR_BOOT_MODE_6180(X) (((X & 0x3000) >> 12) | \ - ((X & 0x2) << 1)) -#define MSAR_BOOT_SPI_WITH_BOOTROM_6180 0x1 -#define MSAR_BOOT_NAND_WITH_BOOTROM_6180 0x5 - -#define MSAR_TCLCK_OFFS 21 -#define MSAR_TCLCK_MASK (0x1 << MSAR_TCLCK_OFFS) -#define MSAR_TCLCK_166 (0x1 << MSAR_TCLCK_OFFS) -#define MSAR_TCLCK_200 (0x0 << MSAR_TCLCK_OFFS) - - -#define MSAR_CPUCLCK_EXTRACT(X) (((X & 0x2) >> 1) | ((X & 0x400000) >> 21) | \ - ((X & 0x18) >> 1)) - -#define MSAR_CPUCLCK_OFFS_6180 2 -#define MSAR_CPUCLCK_MASK_6180 (0x7 << MSAR_CPUCLCK_OFFS_6180) - -#define MSAR_DDRCLCK_RTIO_OFFS 5 -#define MSAR_DDRCLCK_RTIO_MASK (0xF << MSAR_DDRCLCK_RTIO_OFFS) - -#define MSAR_L2CLCK_EXTRACT(X) (((X & 0x600) >> 9) | ((X & 0x80000) >> 17)) - -#ifndef MV_ASMLANGUAGE -/* CPU clock for 6281,6192 0->Resereved */ -#define MV_CPU_CLCK_TBL { 0, 0, 0, 0, \ - 600000000, 0, 800000000, 1000000000, \ - 0, 1200000000, 0, 0, \ - 1500000000, 0, 0, 0} - -/* DDR clock RATIO for 6281,6192 {0,0}->Reserved */ -#define MV_DDR_CLCK_RTIO_TBL {\ - {0, 0}, {0, 0}, {2, 1}, {0, 0}, \ - {3, 1}, {0, 0}, {4, 1}, {9, 2}, \ - {5, 1}, {6, 1}, {0, 0}, {0, 0}, \ - {0, 0}, {0, 0}, {0, 0}, {0, 0} \ -} - -/* L2 clock RATIO for 6281,6192 {1,1}->Reserved */ -#define MV_L2_CLCK_RTIO_TBL {\ - {0, 0}, {2, 1}, {0, 0}, {3, 1}, \ - {0, 0}, {0, 0}, {0, 0}, {0, 0} \ -} - -/* 6180 have different clk reset sampling */ -/* ARM CPU, DDR, L2 clock for 6180 {0,0,0}->Reserved */ -#define MV_CPU6180_DDR_L2_CLCK_TBL { \ - {0, 0, 0 },\ - {0, 0, 0 },\ - {0, 0, 0 },\ - {0, 0, 0 },\ - {0, 0, 0 },\ - {600000000, 200000000, 300000000 },\ - {800000000, 200000000, 400000000 },\ - {0, 0, 0 }\ -} - - - -/* These macros help units to identify a target Mbus Arbiter group */ -#define MV_TARGET_IS_DRAM(target) \ - ((target >= SDRAM_CS0) && (target <= SDRAM_CS3)) - -#define MV_TARGET_IS_PEX0(target) \ - ((target >= PEX0_MEM) && (target <= PEX0_IO)) - -#define MV_TARGET_IS_PEX1(target) 0 - -#define MV_TARGET_IS_PEX(target) (MV_TARGET_IS_PEX0(target) || MV_TARGET_IS_PEX1(target)) - -#define MV_TARGET_IS_DEVICE(target) \ - ((target >= DEVICE_CS0) && (target <= DEVICE_CS3)) - -#define MV_PCI_DRAM_BAR_TO_DRAM_TARGET(bar) 0 - -#define MV_TARGET_IS_AS_BOOT(target) ((target) == (sampleAtResetTargetArray[ \ - (mvCtrlModelGet() == MV_6180_DEV_ID)? MSAR_BOOT_MODE_6180 \ - (MV_REG_READ(MPP_SAMPLE_AT_RESET)):((MV_REG_READ(MPP_SAMPLE_AT_RESET)\ - & MSAR_BOOT_MODE_MASK) >> MSAR_BOOT_MODE_OFFS)])) - - -#define MV_CHANGE_BOOT_CS(target) (((target) == DEV_BOOCS)?\ - sampleAtResetTargetArray[(mvCtrlModelGet() == MV_6180_DEV_ID)? \ - MSAR_BOOT_MODE_6180(MV_REG_READ(MPP_SAMPLE_AT_RESET)): \ - ((MV_REG_READ(MPP_SAMPLE_AT_RESET) & MSAR_BOOT_MODE_MASK)\ - >> MSAR_BOOT_MODE_OFFS)]:(target)) - -#define TCLK_TO_COUNTER_RATIO 1 /* counters running in Tclk */ - -#define BOOT_TARGETS_NAME_ARRAY { \ - TBL_TERM, \ - TBL_TERM, \ - BOOT_ROM_CS, \ - TBL_TERM, \ - BOOT_ROM_CS, \ - BOOT_ROM_CS, \ - TBL_TERM, \ - TBL_TERM \ -} - -#define BOOT_TARGETS_NAME_ARRAY_6180 { \ - TBL_TERM, \ - BOOT_ROM_CS, \ - TBL_TERM, \ - TBL_TERM, \ - TBL_TERM, \ - BOOT_ROM_CS, \ - TBL_TERM, \ - TBL_TERM \ -} - - -/* For old competability */ -#define DEVICE_CS0 NFLASH_CS -#define DEVICE_CS1 SPI_CS -#define DEVICE_CS2 BOOT_ROM_CS -#define DEVICE_CS3 DEV_BOOCS -#define MV_BOOTDEVICE_INDEX 0 - -#define START_DEV_CS DEV_CS0 -#define DEV_TO_TARGET(dev) ((dev) + DEVICE_CS0) - -#define PCI_IF0_MEM0 PEX0_MEM -#define PCI_IF0_IO PEX0_IO - - -/* This enumerator defines the Marvell controller target ID */ -typedef enum _mvTargetId -{ - DRAM_TARGET_ID = 0 , /* Port 0 -> DRAM interface */ - DEV_TARGET_ID = 1, /* Port 1 -> Nand/SPI */ - PEX0_TARGET_ID = 4 , /* Port 4 -> PCI Express0 */ - CRYPT_TARGET_ID = 3 , /* Port 3 --> Crypto Engine */ - SAGE_TARGET_ID = 12 , /* Port 12 -> SAGE Unit */ - MAX_TARGETS_ID -}MV_TARGET_ID; - - -/* This enumerator described the possible Controller paripheral targets. */ -/* Controller peripherals are designated memory/IO address spaces that the */ -/* controller can access. They are also refered as "targets" */ -typedef enum _mvTarget -{ - TBL_TERM = -1, /* none valid target, used as targets list terminator*/ - SDRAM_CS0, /* SDRAM chip select 0 */ - SDRAM_CS1, /* SDRAM chip select 1 */ - SDRAM_CS2, /* SDRAM chip select 2 */ - SDRAM_CS3, /* SDRAM chip select 3 */ - PEX0_MEM, /* PCI Express 0 Memory */ - PEX0_IO, /* PCI Express 0 IO */ - INTER_REGS, /* Internal registers */ - NFLASH_CS, /* NFLASH_CS */ - SPI_CS, /* SPI_CS */ - BOOT_ROM_CS, /* BOOT_ROM_CS */ - DEV_BOOCS, /* DEV_BOOCS */ - CRYPT_ENG, /* Crypto Engine */ -#ifdef MV_INCLUDE_SAGE - SAGE_UNIT, /* SAGE Unit */ -#endif - MAX_TARGETS - -}MV_TARGET; - -#define TARGETS_DEF_ARRAY { \ - {0x0E, DRAM_TARGET_ID }, /* SDRAM_CS0 */ \ - {0x0D, DRAM_TARGET_ID }, /* SDRAM_CS1 */ \ - {0x0B, DRAM_TARGET_ID }, /* SDRAM_CS0 */ \ - {0x07, DRAM_TARGET_ID }, /* SDRAM_CS1 */ \ - {0xE8, PEX0_TARGET_ID }, /* PEX0_MEM */ \ - {0xE0, PEX0_TARGET_ID }, /* PEX0_IO */ \ - {0xFF, 0xFF }, /* INTER_REGS */ \ - {0x2F, DEV_TARGET_ID }, /* NFLASH_CS */ \ - {0x1E, DEV_TARGET_ID }, /* SPI_CS */ \ - {0x1D, DEV_TARGET_ID }, /* BOOT_ROM_CS */ \ - {0x1E, DEV_TARGET_ID }, /* DEV_BOOCS */ \ - {0x01, CRYPT_TARGET_ID}, /* CRYPT_ENG */ \ - {0x00, SAGE_TARGET_ID } \ -} - - -#define TARGETS_NAME_ARRAY { \ - "SDRAM_CS0", /* SDRAM_CS0 */ \ - "SDRAM_CS1", /* SDRAM_CS1 */ \ - "SDRAM_CS2", /* SDRAM_CS2 */ \ - "SDRAM_CS3", /* SDRAM_CS3 */ \ - "PEX0_MEM", /* PEX0_MEM */ \ - "PEX0_IO", /* PEX0_IO */ \ - "INTER_REGS", /* INTER_REGS */ \ - "NFLASH_CS", /* NFLASH_CS */ \ - "SPI_CS", /* SPI_CS */ \ - "BOOT_ROM_CS", /* BOOT_ROM_CS */ \ - "DEV_BOOTCS", /* DEV_BOOCS */ \ - "CRYPT_ENG", /* CRYPT_ENG */ \ - "SAGE_UNIT" /* SAGE_UNIT */ \ -} -#endif /* MV_ASMLANGUAGE */ - - -#endif diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/mvCtrlEnvSpec.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/mvCtrlEnvSpec.h deleted file mode 100644 index e41d80a..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/mvCtrlEnvSpec.h +++ /dev/null @@ -1,257 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCmvCtrlEnvSpech -#define __INCmvCtrlEnvSpech - -#include "mvDeviceId.h" -#include "mvSysHwConfig.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define MV_ARM_SOC -#define SOC_NAME_PREFIX "MV88F" - - -/* units base and port numbers */ -#ifdef MV_ASMLANGUAGE -#define XOR_UNIT_BASE(unit) 0x60800 -#else -#define MV_XOR_REG_BASE 0x60000 -#define XOR_UNIT_BASE(unit) ((unit)? 0x60900:0x60800) -#endif - -#define TDM_REG_BASE 0xD0000 -#define USB_REG_BASE(dev) 0x50000 -#define AUDIO_REG_BASE 0xA0000 -#define SATA_REG_BASE 0x80000 -#define MV_CESA_REG_BASE 0x3D000 -#define MV_CESA_TDMA_REG_BASE 0x30000 -#define MV_SDIO_REG_BASE 0x90000 -#define MV_ETH_REG_BASE(port) (((port) == 0) ? 0x72000 : 0x76000) -#define MV_UART_CHAN_BASE(chanNum) (0x12000 + (chanNum * 0x100)) -#define DRAM_BASE 0x0 -#define CNTMR_BASE 0x20300 -#define TWSI_SLAVE_BASE(chanNum) 0x11000 -#define PEX_IF_BASE(pexIf) 0x40000 -#define MPP_REG_BASE 0x10000 -#define TSU_GLOBAL_REG_BASE 0xB4000 -#define MAX_AHB_TO_MBUS_REG_BASE 0x20000 - -#define INTER_REGS_SIZE _1M -/* This define describes the TWSI interrupt bit and location */ -#define TWSI_CPU_MAIN_INT_CAUSE_REG 0x20200 -#define TWSI0_CPU_MAIN_INT_BIT (1<<29) -#define TWSI_SPEED 100000 - -#define MV_GPP_MAX_GROUP 2 -#define MV_CNTMR_MAX_COUNTER 2 -#define MV_UART_MAX_CHAN 2 -#define MV_XOR_MAX_UNIT 2 -#define MV_XOR_MAX_CHAN 4 /* total channels for all units together*/ -#define MV_XOR_MAX_CHAN_PER_UNIT 2 /* channels for units */ -#define MV_SATA_MAX_CHAN 2 - -#define MV_6281_MPP_MAX_MODULE 2 -#define MV_6192_MPP_MAX_MODULE 1 -#define MV_6190_MPP_MAX_MODULE 1 -#define MV_6180_MPP_MAX_MODULE 2 -#define MV_6281_MPP_MAX_GROUP 7 -#define MV_6192_MPP_MAX_GROUP 4 -#define MV_6190_MPP_MAX_GROUP 4 -#define MV_6180_MPP_MAX_GROUP 3 - -#define MV_DRAM_MAX_CS 4 - -/* This define describes the maximum number of supported PCI\PCIX Interfaces*/ -#define MV_PCI_MAX_IF 0 -#define MV_PCI_START_IF 0 - -/* This define describes the maximum number of supported PEX Interfaces */ -#define MV_INCLUDE_PEX0 -#define MV_DISABLE_PEX_DEVICE_BAR -#define MV_PEX_MAX_IF 1 -#define MV_PEX_START_IF MV_PCI_MAX_IF - -/* This define describes the maximum number of supported PCI Interfaces */ -#define MV_PCI_IF_MAX_IF (MV_PEX_MAX_IF+MV_PCI_MAX_IF) - -#define MV_ETH_MAX_PORTS 2 -#define MV_6281_ETH_MAX_PORTS 2 -#define MV_6192_ETH_MAX_PORTS 2 -#define MV_6190_ETH_MAX_PORTS 1 -#define MV_6180_ETH_MAX_PORTS 1 - -#define MV_IDMA_MAX_CHAN 0 - -#define MV_USB_MAX_PORTS 1 - -#define MV_USB_VERSION 1 - - -#define MV_6281_NAND 1 -#define MV_6192_NAND 1 -#define MV_6190_NAND 1 -#define MV_6180_NAND 0 - -#define MV_6281_SDIO 1 -#define MV_6192_SDIO 1 -#define MV_6190_SDIO 1 -#define MV_6180_SDIO 1 - -#define MV_6281_TS 1 -#define MV_6192_TS 1 -#define MV_6190_TS 0 -#define MV_6180_TS 0 - -#define MV_6281_AUDIO 1 -#define MV_6192_AUDIO 1 -#define MV_6190_AUDIO 0 -#define MV_6180_AUDIO 1 - -#define MV_6281_TDM 1 -#define MV_6192_TDM 1 -#define MV_6190_TDM 0 -#define MV_6180_TDM 0 - -#define MV_DEVICE_MAX_CS 4 - -/* Others */ -#define PEX_HOST_BUS_NUM(pciIf) (pciIf) -#define PEX_HOST_DEV_NUM(pciIf) 0 - -#define PCI_IO(pciIf) (PEX0_IO) -#define PCI_MEM(pciIf, memNum) (PEX0_MEM0) -/* CESA version #2: One channel, 2KB SRAM, TDMA */ -#if defined(MV_CESA_CHAIN_MODE_SUPPORT) - #define MV_CESA_VERSION 3 -#else -#define MV_CESA_VERSION 2 -#endif -#define MV_CESA_SRAM_SIZE 2*1024 -/* This define describes the maximum number of supported Ethernet ports */ -#define MV_ETH_VERSION 4 -#define MV_ETH_MAX_RXQ 8 -#define MV_ETH_MAX_TXQ 8 -#define MV_ETH_PORT_SGMII { MV_FALSE, MV_FALSE } -/* This define describes the the support of USB */ -#define MV_USB_VERSION 1 - -#define MV_INCLUDE_SDRAM_CS0 -#define MV_INCLUDE_SDRAM_CS1 -#define MV_INCLUDE_SDRAM_CS2 -#define MV_INCLUDE_SDRAM_CS3 - -#define MV_INCLUDE_DEVICE_CS0 -#define MV_INCLUDE_DEVICE_CS1 -#define MV_INCLUDE_DEVICE_CS2 -#define MV_INCLUDE_DEVICE_CS3 - -#define MPP_GROUP_1_TYPE {\ - {0, 0, 0}, /* Reserved for AUTO */ \ - {0x22220000, 0x22222222, 0x2222}, /* TDM */ \ - {0x44440000, 0x00044444, 0x0000}, /* AUDIO */ \ - {0x33330000, 0x33003333, 0x0033}, /* RGMII */ \ - {0x33330000, 0x03333333, 0x0033}, /* GMII */ \ - {0x11110000, 0x11111111, 0x0001}, /* TS */ \ - {0x33330000, 0x33333333, 0x3333} /* MII */ \ -} - -#define MPP_GROUP_2_TYPE {\ - {0, 0, 0}, /* Reserved for AUTO */ \ - {0x22220000, 0x22222222, 0x22}, /* TDM */ \ - {0x44440000, 0x00044444, 0x0}, /* AUDIO */ \ - {0, 0, 0}, /* N_A */ \ - {0, 0, 0}, /* N_A */ \ - {0x11110000, 0x11111111, 0x01} /* TS */ \ -} - -#ifndef MV_ASMLANGUAGE - -/* This enumerator defines the Marvell Units ID */ -typedef enum _mvUnitId -{ - DRAM_UNIT_ID, - PEX_UNIT_ID, - ETH_GIG_UNIT_ID, - USB_UNIT_ID, - IDMA_UNIT_ID, - XOR_UNIT_ID, - SATA_UNIT_ID, - TDM_UNIT_ID, - UART_UNIT_ID, - CESA_UNIT_ID, - SPI_UNIT_ID, - AUDIO_UNIT_ID, - SDIO_UNIT_ID, - TS_UNIT_ID, - MAX_UNITS_ID - -}MV_UNIT_ID; - -#endif - -#endif /* __INCmvCtrlEnvSpech */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvAhbToMbus.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvAhbToMbus.c deleted file mode 100644 index d21bb07..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvAhbToMbus.c +++ /dev/null @@ -1,1048 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -/* includes */ -#include "ctrlEnv/sys/mvAhbToMbus.h" -#include "ctrlEnv/mvCtrlEnvAddrDec.h" - -#undef MV_DEBUG -/* defines */ -#ifdef MV_DEBUG - #define DB(x) x -#else - #define DB(x) -#endif - -/* typedefs */ - - -/* CPU address remap registers offsets are inconsecutive. This struct */ -/* describes address remap register offsets */ -typedef struct _ahbToMbusRemapRegOffs -{ - MV_U32 lowRegOffs; /* Low 32-bit remap register offset */ - MV_U32 highRegOffs; /* High 32 bit remap register offset */ -}AHB_TO_MBUS_REMAP_REG_OFFS; - -/* locals */ -static MV_STATUS ahbToMbusRemapRegOffsGet (MV_U32 winNum, - AHB_TO_MBUS_REMAP_REG_OFFS *pRemapRegs); - -/******************************************************************************* -* mvAhbToMbusInit - Initialize Ahb To Mbus Address Map ! -* -* DESCRIPTION: -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_OK laways. -* -*******************************************************************************/ -MV_STATUS mvAhbToMbusInit(void) -{ - return MV_OK; - -} - -/******************************************************************************* -* mvAhbToMbusWinSet - Set CPU-to-peripheral winNum address window -* -* DESCRIPTION: -* This function sets -* address window, also known as address decode window. -* A new address decode window is set for specified winNum address window. -* If address decode window parameter structure enables the window, -* the routine will also enable the winNum window, allowing CPU to access -* the winNum window. -* -* INPUT: -* winNum - Windows number. -* pAddrDecWin - CPU winNum window data structure. -* -* OUTPUT: -* N/A -* -* RETURN: -* MV_OK if CPU winNum window was set correctly, MV_ERROR in case of -* address window overlapps with other active CPU winNum window or -* trying to assign 36bit base address while CPU does not support that. -* The function returns MV_NOT_SUPPORTED, if the winNum is unsupported. -* -*******************************************************************************/ -MV_STATUS mvAhbToMbusWinSet(MV_U32 winNum, MV_AHB_TO_MBUS_DEC_WIN *pAddrDecWin) -{ - MV_TARGET_ATTRIB targetAttribs; - MV_DEC_REGS decRegs; - - /* Parameter checking */ - if (winNum >= MAX_AHB_TO_MBUS_WINS) - { - mvOsPrintf("mvAhbToMbusWinSet: ERR. Invalid winNum %d\n", winNum); - return MV_NOT_SUPPORTED; - } - - - /* read base register*/ - if (winNum != MV_AHB_TO_MBUS_INTREG_WIN) - { - decRegs.baseReg = MV_REG_READ(AHB_TO_MBUS_WIN_BASE_REG(winNum)); - } - else - { - decRegs.baseReg = MV_REG_READ(AHB_TO_MBUS_WIN_INTEREG_REG); - } - - /* check if address is aligned to the size */ - if(MV_IS_NOT_ALIGN(pAddrDecWin->addrWin.baseLow, pAddrDecWin->addrWin.size)) - { - mvOsPrintf("mvAhbToMbusWinSet:Error setting AHB to MBUS window %d to "\ - "target %s.\nAddress 0x%08x is unaligned to size 0x%x.\n", - winNum, - mvCtrlTargetNameGet(pAddrDecWin->target), - pAddrDecWin->addrWin.baseLow, - pAddrDecWin->addrWin.size); - return MV_ERROR; - } - - /* read control register*/ - if (winNum != MV_AHB_TO_MBUS_INTREG_WIN) - { - decRegs.sizeReg = MV_REG_READ(AHB_TO_MBUS_WIN_CTRL_REG(winNum)); - } - - if (MV_OK != mvCtrlAddrDecToReg(&(pAddrDecWin->addrWin),&decRegs)) - { - mvOsPrintf("mvAhbToMbusWinSet:mvCtrlAddrDecToReg Failed\n"); - return MV_ERROR; - } - - /* enable\Disable */ - if (MV_TRUE == pAddrDecWin->enable) - { - decRegs.sizeReg |= ATMWCR_WIN_ENABLE; - } - else - { - decRegs.sizeReg &= ~ATMWCR_WIN_ENABLE; - } - - mvCtrlAttribGet(pAddrDecWin->target,&targetAttribs); - - /* set attributes */ - decRegs.sizeReg &= ~ATMWCR_WIN_ATTR_MASK; - decRegs.sizeReg |= targetAttribs.attrib << ATMWCR_WIN_ATTR_OFFS; - /* set target ID */ - decRegs.sizeReg &= ~ATMWCR_WIN_TARGET_MASK; - decRegs.sizeReg |= targetAttribs.targetId << ATMWCR_WIN_TARGET_OFFS; - -#if !defined(MV_RUN_FROM_FLASH) - /* To be on the safe side we disable the window before writing the */ - /* new values. */ - if (winNum != MV_AHB_TO_MBUS_INTREG_WIN) - { - mvAhbToMbusWinEnable(winNum,MV_FALSE); - } -#endif - - /* 3) Write to address decode Base Address Register */ - if (winNum != MV_AHB_TO_MBUS_INTREG_WIN) - { - MV_REG_WRITE(AHB_TO_MBUS_WIN_BASE_REG(winNum), decRegs.baseReg); - } - else - { - MV_REG_WRITE(AHB_TO_MBUS_WIN_INTEREG_REG, decRegs.baseReg); - } - - - /* Internal register space have no size */ - /* register. Do not perform size register assigment for those targets */ - if (winNum != MV_AHB_TO_MBUS_INTREG_WIN) - { - /* Write to address decode Size Register */ - MV_REG_WRITE(AHB_TO_MBUS_WIN_CTRL_REG(winNum), decRegs.sizeReg); - } - - return MV_OK; -} - -/******************************************************************************* -* mvAhbToMbusWinGet - Get CPU-to-peripheral winNum address window -* -* DESCRIPTION: -* Get the CPU peripheral winNum address window. -* -* INPUT: -* winNum - Peripheral winNum enumerator -* -* OUTPUT: -* pAddrDecWin - CPU winNum window information data structure. -* -* RETURN: -* MV_OK if winNum exist, MV_ERROR otherwise. -* -*******************************************************************************/ -MV_STATUS mvAhbToMbusWinGet(MV_U32 winNum, MV_AHB_TO_MBUS_DEC_WIN *pAddrDecWin) -{ - MV_DEC_REGS decRegs; - MV_TARGET_ATTRIB targetAttrib; - - - /* Parameter checking */ - if (winNum >= MAX_AHB_TO_MBUS_WINS) - { - mvOsPrintf("mvAhbToMbusWinGet: ERR. Invalid winNum %d\n", winNum); - return MV_NOT_SUPPORTED; - } - - - /* Internal register space size have no size register*/ - if (winNum != MV_AHB_TO_MBUS_INTREG_WIN) - { - decRegs.sizeReg = MV_REG_READ(AHB_TO_MBUS_WIN_CTRL_REG(winNum)); - } - else - { - decRegs.sizeReg = 0; - } - - - /* Read base and size */ - if (winNum != MV_AHB_TO_MBUS_INTREG_WIN) - { - decRegs.baseReg = MV_REG_READ(AHB_TO_MBUS_WIN_BASE_REG(winNum)); - } - else - { - decRegs.baseReg = MV_REG_READ(AHB_TO_MBUS_WIN_INTEREG_REG); - } - - - - if (MV_OK != mvCtrlRegToAddrDec(&decRegs,&(pAddrDecWin->addrWin))) - { - mvOsPrintf("mvAhbToMbusWinGet: mvCtrlRegToAddrDec Failed \n"); - return MV_ERROR; - } - - if (winNum == MV_AHB_TO_MBUS_INTREG_WIN) - { - pAddrDecWin->addrWin.size = INTER_REGS_SIZE; - pAddrDecWin->target = INTER_REGS; - pAddrDecWin->enable = MV_TRUE; - - return MV_OK; - } - - - if (decRegs.sizeReg & ATMWCR_WIN_ENABLE) - { - pAddrDecWin->enable = MV_TRUE; - } - else - { - pAddrDecWin->enable = MV_FALSE; - - } - - - - if (-1 == pAddrDecWin->addrWin.size) - { - return MV_ERROR; - } - - /* attrib and targetId */ - targetAttrib.attrib = (decRegs.sizeReg & ATMWCR_WIN_ATTR_MASK) >> - ATMWCR_WIN_ATTR_OFFS; - targetAttrib.targetId = (decRegs.sizeReg & ATMWCR_WIN_TARGET_MASK) >> - ATMWCR_WIN_TARGET_OFFS; - - pAddrDecWin->target = mvCtrlTargetGet(&targetAttrib); - - return MV_OK; -} - -/******************************************************************************* -* mvAhbToMbusWinTargetGet - Get Window number associated with target -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* -* RETURN: -* -*******************************************************************************/ -MV_U32 mvAhbToMbusWinTargetGet(MV_TARGET target) -{ - MV_AHB_TO_MBUS_DEC_WIN decWin; - MV_U32 winNum; - - /* Check parameters */ - if (target >= MAX_TARGETS) - { - mvOsPrintf("mvAhbToMbusWinTargetGet: target %d is Illigal\n", target); - return 0xffffffff; - } - - if (INTER_REGS == target) - { - return MV_AHB_TO_MBUS_INTREG_WIN; - } - - for (winNum = 0; winNum < MAX_AHB_TO_MBUS_WINS ; winNum++) - { - if (winNum == MV_AHB_TO_MBUS_INTREG_WIN) - continue; - - if (mvAhbToMbusWinGet(winNum,&decWin) != MV_OK) - { - mvOsPrintf("mvAhbToMbusWinTargetGet: mvAhbToMbusWinGet fail\n"); - return 0xffffffff; - - } - - if (decWin.enable == MV_TRUE) - { - if (decWin.target == target) - { - return winNum; - } - - } - - } - - return 0xFFFFFFFF; - - -} - -/******************************************************************************* -* mvAhbToMbusWinAvailGet - Get First Available window number. -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* -* RETURN: -* -*******************************************************************************/ -MV_U32 mvAhbToMbusWinAvailGet(MV_VOID) -{ - MV_AHB_TO_MBUS_DEC_WIN decWin; - MV_U32 winNum; - - for (winNum = 0; winNum < MAX_AHB_TO_MBUS_WINS ; winNum++) - { - if (winNum == MV_AHB_TO_MBUS_INTREG_WIN) - continue; - - if (mvAhbToMbusWinGet(winNum,&decWin) != MV_OK) - { - mvOsPrintf("mvAhbToMbusWinTargetGet: mvAhbToMbusWinGet fail\n"); - return 0xffffffff; - - } - - if (decWin.enable == MV_FALSE) - { - return winNum; - } - - } - - return 0xFFFFFFFF; -} - - -/******************************************************************************* -* mvAhbToMbusWinEnable - Enable/disable a CPU address decode window -* -* DESCRIPTION: -* This function enable/disable a CPU address decode window. -* if parameter 'enable' == MV_TRUE the routine will enable the -* window, thus enabling CPU accesses (before enabling the window it is -* tested for overlapping). Otherwise, the window will be disabled. -* -* INPUT: -* winNum - Peripheral winNum enumerator. -* enable - Enable/disable parameter. -* -* OUTPUT: -* N/A -* -* RETURN: -* MV_ERROR if protection window number was wrong, or the window -* overlapps other winNum window. -* -*******************************************************************************/ -MV_STATUS mvAhbToMbusWinEnable(MV_U32 winNum, MV_BOOL enable) -{ - - /* Parameter checking */ - if (winNum >= MAX_AHB_TO_MBUS_WINS) - { - mvOsPrintf("mvAhbToMbusWinEnable: ERR. Invalid winNum %d\n", winNum); - return MV_NOT_SUPPORTED; - } - - /* Internal registers bar can't be disable or enabled */ - if (winNum == MV_AHB_TO_MBUS_INTREG_WIN) - { - return (enable ? MV_OK : MV_ERROR); - } - - if (enable == MV_TRUE) - { - /* enable the window */ - MV_REG_BIT_SET(AHB_TO_MBUS_WIN_CTRL_REG(winNum), ATMWCR_WIN_ENABLE); - } - else - { /* Disable address decode winNum window */ - MV_REG_BIT_RESET(AHB_TO_MBUS_WIN_CTRL_REG(winNum), ATMWCR_WIN_ENABLE); - } - - return MV_OK; -} - - -/******************************************************************************* -* mvAhbToMbusWinRemap - Set CPU remap register for address windows. -* -* DESCRIPTION: -* After a CPU address hits one of PCI address decode windows there is an -* option to remap the address to a different one. For example, CPU -* executes a read from PCI winNum window address 0x1200.0000. This -* can be modified so the address on the PCI bus would be 0x1400.0000 -* Using the PCI address remap mechanism. -* -* INPUT: -* winNum - Peripheral winNum enumerator. Must be a PCI winNum. -* pAddrDecWin - CPU winNum window information data structure. -* Note that caller has to fill in the base field only. The -* size field is ignored. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_ERROR if winNum is not a PCI one, MV_OK otherwise. -* -*******************************************************************************/ -MV_U32 mvAhbToMbusWinRemap(MV_U32 winNum, MV_ADDR_WIN *pAddrWin) -{ - MV_U32 baseAddr; - AHB_TO_MBUS_REMAP_REG_OFFS remapRegOffs; - - MV_U32 effectiveBaseAddress=0, - baseAddrValue=0,windowSizeValue=0; - - - /* Get registers offsets of given winNum */ - if (MV_NO_SUCH == ahbToMbusRemapRegOffsGet(winNum, &remapRegOffs)) - { - return 0xffffffff; - } - - /* 1) Set address remap low */ - baseAddr = pAddrWin->baseLow; - - /* Check base address aligment */ - /* - if (MV_IS_NOT_ALIGN(baseAddr, ATMWRLR_REMAP_LOW_ALIGNMENT)) - { - mvOsPrintf("mvAhbToMbusPciRemap: Warning. Target base 0x%x unaligned\n", - baseAddr); - return MV_ERROR; - } - */ - - /* BaseLow[31:16] => base register [31:16] */ - baseAddr = baseAddr & ATMWRLR_REMAP_LOW_MASK; - - MV_REG_WRITE(remapRegOffs.lowRegOffs, baseAddr); - - MV_REG_WRITE(remapRegOffs.highRegOffs, pAddrWin->baseHigh); - - - baseAddrValue = MV_REG_READ(AHB_TO_MBUS_WIN_BASE_REG(winNum)); - windowSizeValue = MV_REG_READ(AHB_TO_MBUS_WIN_CTRL_REG(winNum)); - - baseAddrValue &= ATMWBR_BASE_MASK; - windowSizeValue &=ATMWCR_WIN_SIZE_MASK; - - /* Start calculating the effective Base Address */ - effectiveBaseAddress = baseAddrValue ; - - /* The effective base address will be combined from the chopped (if any) - remap value (according to the size value and remap mechanism) and the - window's base address */ - effectiveBaseAddress |= (((windowSizeValue) | 0xffff) & pAddrWin->baseLow); - /* If the effectiveBaseAddress exceed the window boundaries return an - invalid value. */ - - if (effectiveBaseAddress > (baseAddrValue + (windowSizeValue | 0xffff))) - { - mvOsPrintf("mvAhbToMbusPciRemap: Error\n"); - return 0xffffffff; - } - - return effectiveBaseAddress; - - -} -/******************************************************************************* -* mvAhbToMbusWinTargetSwap - Swap AhbToMbus windows between targets -* -* DESCRIPTION: -* -* INPUT: -* target1 - CPU Interface target 1 -* target2 - CPU Interface target 2 -* -* OUTPUT: -* None. -* -* RETURN: -* MV_ERROR if targets are illigal, or if one of the targets is not -* associated to a valid window . -* MV_OK otherwise. -* -*******************************************************************************/ - - -MV_STATUS mvAhbToMbusWinTargetSwap(MV_TARGET target1,MV_TARGET target2) -{ - MV_U32 winNum1,winNum2; - MV_AHB_TO_MBUS_DEC_WIN winDec1,winDec2,winDecTemp; - AHB_TO_MBUS_REMAP_REG_OFFS remapRegs1,remapRegs2; - MV_U32 remapBaseLow1=0,remapBaseLow2=0; - MV_U32 remapBaseHigh1=0,remapBaseHigh2=0; - - - /* Check parameters */ - if (target1 >= MAX_TARGETS) - { - mvOsPrintf("mvAhbToMbusWinTargetSwap: target %d is Illigal\n", target1); - return MV_ERROR; - } - - if (target2 >= MAX_TARGETS) - { - mvOsPrintf("mvAhbToMbusWinTargetSwap: target %d is Illigal\n", target1); - return MV_ERROR; - } - - - /* get window associated with this target */ - winNum1 = mvAhbToMbusWinTargetGet(target1); - - if (winNum1 == 0xffffffff) - { - mvOsPrintf("mvAhbToMbusWinTargetSwap: target %d has illigal win %d\n", - target1,winNum1); - return MV_ERROR; - - } - - /* get window associated with this target */ - winNum2 = mvAhbToMbusWinTargetGet(target2); - - if (winNum2 == 0xffffffff) - { - mvOsPrintf("mvAhbToMbusWinTargetSwap: target %d has illigal win %d\n", - target2,winNum2); - return MV_ERROR; - - } - - /* now Get original values of both Windows */ - if (MV_OK != mvAhbToMbusWinGet(winNum1,&winDec1)) - { - mvOsPrintf("mvAhbToMbusWinTargetSwap: mvAhbToMbusWinGet failed win %d\n", - winNum1); - return MV_ERROR; - - } - if (MV_OK != mvAhbToMbusWinGet(winNum2,&winDec2)) - { - mvOsPrintf("mvAhbToMbusWinTargetSwap: mvAhbToMbusWinGet failed win %d\n", - winNum2); - return MV_ERROR; - - } - - - /* disable both windows */ - if (MV_OK != mvAhbToMbusWinEnable(winNum1,MV_FALSE)) - { - mvOsPrintf("mvAhbToMbusWinTargetSwap: failed to enable window %d\n", - winNum1); - return MV_ERROR; - - } - if (MV_OK != mvAhbToMbusWinEnable(winNum2,MV_FALSE)) - { - mvOsPrintf("mvAhbToMbusWinTargetSwap: failed to enable windo %d\n", - winNum2); - return MV_ERROR; - - } - - - /* now swap targets */ - - /* first save winDec2 values */ - winDecTemp.addrWin.baseHigh = winDec2.addrWin.baseHigh; - winDecTemp.addrWin.baseLow = winDec2.addrWin.baseLow; - winDecTemp.addrWin.size = winDec2.addrWin.size; - winDecTemp.enable = winDec2.enable; - winDecTemp.target = winDec2.target; - - /* winDec2 = winDec1 */ - winDec2.addrWin.baseHigh = winDec1.addrWin.baseHigh; - winDec2.addrWin.baseLow = winDec1.addrWin.baseLow; - winDec2.addrWin.size = winDec1.addrWin.size; - winDec2.enable = winDec1.enable; - winDec2.target = winDec1.target; - - - /* winDec1 = winDecTemp */ - winDec1.addrWin.baseHigh = winDecTemp.addrWin.baseHigh; - winDec1.addrWin.baseLow = winDecTemp.addrWin.baseLow; - winDec1.addrWin.size = winDecTemp.addrWin.size; - winDec1.enable = winDecTemp.enable; - winDec1.target = winDecTemp.target; - - - /* now set the new values */ - - - mvAhbToMbusWinSet(winNum1,&winDec1); - mvAhbToMbusWinSet(winNum2,&winDec2); - - - - - - /* now we will treat the remap windows if exist */ - - - /* now check if one or both windows has a remap window - as well after the swap ! */ - - /* if a window had a remap value differnt than the base value - before the swap , then after the swap the remap value will be - equal to the base value unless both windows has a remap windows*/ - - /* first get old values */ - if (MV_NO_SUCH != ahbToMbusRemapRegOffsGet(winNum1,&remapRegs1)) - { - remapBaseLow1 = MV_REG_READ(remapRegs1.lowRegOffs); - remapBaseHigh1 = MV_REG_READ(remapRegs1.highRegOffs); - - } - if (MV_NO_SUCH != ahbToMbusRemapRegOffsGet(winNum2,&remapRegs2)) - { - remapBaseLow2 = MV_REG_READ(remapRegs2.lowRegOffs); - remapBaseHigh2 = MV_REG_READ(remapRegs2.highRegOffs); - - - } - - /* now do the swap */ - if (MV_NO_SUCH != ahbToMbusRemapRegOffsGet(winNum1,&remapRegs1)) - { - if (MV_NO_SUCH != ahbToMbusRemapRegOffsGet(winNum2,&remapRegs2)) - { - /* Two windows has a remap !!! so swap */ - - MV_REG_WRITE(remapRegs2.highRegOffs,remapBaseHigh1); - MV_REG_WRITE(remapRegs2.lowRegOffs,remapBaseLow1); - - MV_REG_WRITE(remapRegs1.highRegOffs,remapBaseHigh2); - MV_REG_WRITE(remapRegs1.lowRegOffs,remapBaseLow2); - - - - } - else - { - /* remap == base */ - MV_REG_WRITE(remapRegs1.highRegOffs,winDec1.addrWin.baseHigh); - MV_REG_WRITE(remapRegs1.lowRegOffs,winDec1.addrWin.baseLow); - - } - - } - else if (MV_NO_SUCH != ahbToMbusRemapRegOffsGet(winNum2,&remapRegs2)) - { - /* remap == base */ - MV_REG_WRITE(remapRegs2.highRegOffs,winDec2.addrWin.baseHigh); - MV_REG_WRITE(remapRegs2.lowRegOffs,winDec2.addrWin.baseLow); - - } - - - - return MV_OK; - - -} - - - -#if defined(MV_88F1181) - -/******************************************************************************* -* mvAhbToMbusXbarCtrlSet - Set The CPU master Xbar arbitration. -* -* DESCRIPTION: -* This function sets CPU Mbus Arbiter -* -* INPUT: -* pPizzaArbArray - A priority Structure describing 16 "pizza slices". At -* each clock cycle, the crossbar arbiter samples all -* requests and gives the bus to the next agent according -* to the "pizza". -* -* OUTPUT: -* N/A -* -* RETURN: -* MV_ERROR if paramers to function invalid. -* -*******************************************************************************/ -MV_STATUS mvMbusArbSet(MV_MBUS_ARB_TARGET *pPizzaArbArray) -{ - MV_U32 sliceNum; - MV_U32 xbarCtrl = 0; - MV_MBUS_ARB_TARGET xbarTarget; - - /* 1) Set crossbar control low register */ - for (sliceNum = 0; sliceNum < MRLR_SLICE_NUM; sliceNum++) - { - xbarTarget = pPizzaArbArray[sliceNum]; - - /* sliceNum parameter check */ - if (xbarTarget > MAX_MBUS_ARB_TARGETS) - { - mvOsPrintf("mvAhbToMbusXbarCtrlSet: ERR. Can't set Target %d\n", - xbarTarget); - return MV_ERROR; - } - xbarCtrl |= (xbarTarget << MRLR_LOW_ARB_OFFS(sliceNum)); - } - /* Write to crossbar control low register */ - MV_REG_WRITE(MBUS_ARBITER_LOW_REG, xbarCtrl); - - xbarCtrl = 0; - - /* 2) Set crossbar control high register */ - for (sliceNum = MRLR_SLICE_NUM; - sliceNum < MRLR_SLICE_NUM+MRHR_SLICE_NUM; - sliceNum++) - { - - xbarTarget = pPizzaArbArray[sliceNum]; - - /* sliceNum parameter check */ - if (xbarTarget > MAX_MBUS_ARB_TARGETS) - { - mvOsPrintf("mvAhbToMbusXbarCtrlSet: ERR. Can't set Target %d\n", - xbarTarget); - return MV_ERROR; - } - xbarCtrl |= (xbarTarget << MRHR_HIGH_ARB_OFFS(sliceNum)); - } - /* Write to crossbar control high register */ - MV_REG_WRITE(MBUS_ARBITER_HIGH_REG, xbarCtrl); - - return MV_OK; -} - -/******************************************************************************* -* mvMbusArbCtrlSet - Set MBus Arbiter control register -* -* DESCRIPTION: -* -* INPUT: -* ctrl - pointer to MV_MBUS_ARB_CTRL register -* -* OUTPUT: -* N/A -* -* RETURN: -* MV_ERROR if paramers to function invalid. -* -*******************************************************************************/ -MV_STATUS mvMbusArbCtrlSet(MV_MBUS_ARB_CTRL *ctrl) -{ - - if (ctrl->highPrio == MV_FALSE) - { - MV_REG_BIT_RESET(MBUS_ARBITER_CTRL_REG, MACR_ARB_ARM_TOP); - } - else - { - MV_REG_BIT_SET(MBUS_ARBITER_CTRL_REG, MACR_ARB_ARM_TOP); - } - - if (ctrl->fixedRoundRobin == MV_FALSE) - { - MV_REG_BIT_RESET(MBUS_ARBITER_CTRL_REG, MACR_ARB_TARGET_FIXED); - } - else - { - MV_REG_BIT_SET(MBUS_ARBITER_CTRL_REG, MACR_ARB_TARGET_FIXED); - } - - if (ctrl->starvEn == MV_FALSE) - { - MV_REG_BIT_RESET(MBUS_ARBITER_CTRL_REG, MACR_ARB_REQ_CTRL_EN); - } - else - { - MV_REG_BIT_SET(MBUS_ARBITER_CTRL_REG, MACR_ARB_REQ_CTRL_EN); - } - - return MV_OK; -} - -/******************************************************************************* -* mvMbusArbCtrlGet - Get MBus Arbiter control register -* -* DESCRIPTION: -* -* INPUT: -* ctrl - pointer to MV_MBUS_ARB_CTRL register -* -* OUTPUT: -* ctrl - pointer to MV_MBUS_ARB_CTRL register -* -* RETURN: -* MV_ERROR if paramers to function invalid. -* -*******************************************************************************/ -MV_STATUS mvMbusArbCtrlGet(MV_MBUS_ARB_CTRL *ctrl) -{ - - MV_U32 ctrlReg = MV_REG_READ(MBUS_ARBITER_CTRL_REG); - - if (ctrlReg & MACR_ARB_ARM_TOP) - { - ctrl->highPrio = MV_TRUE; - } - else - { - ctrl->highPrio = MV_FALSE; - } - - if (ctrlReg & MACR_ARB_TARGET_FIXED) - { - ctrl->fixedRoundRobin = MV_TRUE; - } - else - { - ctrl->fixedRoundRobin = MV_FALSE; - } - - if (ctrlReg & MACR_ARB_REQ_CTRL_EN) - { - ctrl->starvEn = MV_TRUE; - } - else - { - ctrl->starvEn = MV_FALSE; - } - - - return MV_OK; -} - -#endif /* #if defined(MV_88F1181) */ - - - -/******************************************************************************* -* ahbToMbusRemapRegOffsGet - Get CPU address remap register offsets -* -* DESCRIPTION: -* CPU to PCI address remap registers offsets are inconsecutive. -* This function returns PCI address remap registers offsets. -* -* INPUT: -* winNum - Address decode window number. See MV_U32 enumerator. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_ERROR if winNum is not a PCI one. -* -*******************************************************************************/ -static MV_STATUS ahbToMbusRemapRegOffsGet(MV_U32 winNum, - AHB_TO_MBUS_REMAP_REG_OFFS *pRemapRegs) -{ - switch (winNum) - { - case 0: - case 1: - pRemapRegs->lowRegOffs = AHB_TO_MBUS_WIN_REMAP_LOW_REG(winNum); - pRemapRegs->highRegOffs = AHB_TO_MBUS_WIN_REMAP_HIGH_REG(winNum); - break; - case 2: - case 3: - if((mvCtrlModelGet() == MV_5281_DEV_ID) || - (mvCtrlModelGet() == MV_1281_DEV_ID) || - (mvCtrlModelGet() == MV_6183_DEV_ID) || - (mvCtrlModelGet() == MV_6183L_DEV_ID)) - { - pRemapRegs->lowRegOffs = AHB_TO_MBUS_WIN_REMAP_LOW_REG(winNum); - pRemapRegs->highRegOffs = AHB_TO_MBUS_WIN_REMAP_HIGH_REG(winNum); - break; - } - else - { - pRemapRegs->lowRegOffs = 0; - pRemapRegs->highRegOffs = 0; - - DB(mvOsPrintf("ahbToMbusRemapRegOffsGet: ERR. Invalid winNum %d\n", - winNum)); - return MV_NO_SUCH; - } - default: - { - pRemapRegs->lowRegOffs = 0; - pRemapRegs->highRegOffs = 0; - - DB(mvOsPrintf("ahbToMbusRemapRegOffsGet: ERR. Invalid winNum %d\n", - winNum)); - return MV_NO_SUCH; - } - } - - return MV_OK; -} - -/******************************************************************************* -* mvAhbToMbusAddDecShow - Print the AHB to MBus bridge address decode map. -* -* DESCRIPTION: -* This function print the CPU address decode map. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_VOID mvAhbToMbusAddDecShow(MV_VOID) -{ - MV_AHB_TO_MBUS_DEC_WIN win; - MV_U32 winNum; - mvOsOutput( "\n" ); - mvOsOutput( "AHB To MBUS Bridge:\n" ); - mvOsOutput( "-------------------\n" ); - - for( winNum = 0; winNum < MAX_AHB_TO_MBUS_WINS; winNum++ ) - { - memset( &win, 0, sizeof(MV_AHB_TO_MBUS_DEC_WIN) ); - - mvOsOutput( "win%d - ", winNum ); - - if( mvAhbToMbusWinGet( winNum, &win ) == MV_OK ) - { - if( win.enable ) - { - mvOsOutput( "%s base %08x, ", - mvCtrlTargetNameGet(win.target), win.addrWin.baseLow ); - mvOsOutput( "...." ); - mvSizePrint( win.addrWin.size ); - - mvOsOutput( "\n" ); - - } - else - mvOsOutput( "disable\n" ); - } - } - -} - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvAhbToMbus.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvAhbToMbus.h deleted file mode 100644 index 1b352a1..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvAhbToMbus.h +++ /dev/null @@ -1,130 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -#ifndef __INCmvAhbToMbush -#define __INCmvAhbToMbush - -/* includes */ -#include "ctrlEnv/mvCtrlEnvLib.h" -#include "ctrlEnv/sys/mvAhbToMbusRegs.h" -#include "ctrlEnv/mvCtrlEnvAddrDec.h" - -/* defines */ - -#if defined(MV_88F1181) -/* This enumerator defines the Marvell controller possible MBUS arbiter */ -/* target ports. It is used to define crossbar priority scheame (pizza) */ -typedef enum _mvMBusArbTargetId -{ - DRAM_MBUS_ARB_TARGET = 0, /* Port 0 -> DRAM interface */ - TWSI_MBUS_ARB_TARGET = 1, /* Port 1 -> TWSI */ - ARM_MBUS_ARB_TARGET = 2, /* Port 2 -> ARM */ - PEX1_MBUS_ARB_TARGET = 3, /* Port 3 -> PCI Express 1 */ - PEX0_MBUS_ARB_TARGET = 4, /* Port 4 -> PCI Express0 */ - MAX_MBUS_ARB_TARGETS -}MV_MBUS_ARB_TARGET; - -typedef struct _mvMBusArbCtrl -{ - MV_BOOL starvEn; - MV_BOOL highPrio; - MV_BOOL fixedRoundRobin; - -}MV_MBUS_ARB_CTRL; - -#endif /* #if defined(MV_88F1181) */ - -typedef struct _mvAhbtoMbusDecWin -{ - MV_TARGET target; - MV_ADDR_WIN addrWin; /* An address window*/ - MV_BOOL enable; /* Address decode window is enabled/disabled */ - -}MV_AHB_TO_MBUS_DEC_WIN; - -/* mvAhbToMbus.h API list */ - -MV_STATUS mvAhbToMbusInit(MV_VOID); -MV_STATUS mvAhbToMbusWinSet(MV_U32 winNum, MV_AHB_TO_MBUS_DEC_WIN *pAddrDecWin); -MV_STATUS mvAhbToMbusWinGet(MV_U32 winNum, MV_AHB_TO_MBUS_DEC_WIN *pAddrDecWin); -MV_STATUS mvAhbToMbusWinEnable(MV_U32 winNum,MV_BOOL enable); -MV_U32 mvAhbToMbusWinRemap(MV_U32 winNum, MV_ADDR_WIN *pAddrDecWin); -MV_U32 mvAhbToMbusWinTargetGet(MV_TARGET target); -MV_U32 mvAhbToMbusWinAvailGet(MV_VOID); -MV_STATUS mvAhbToMbusWinTargetSwap(MV_TARGET target1,MV_TARGET target2); - -#if defined(MV_88F1181) - -MV_STATUS mvMbusArbSet(MV_MBUS_ARB_TARGET *pPizzaArbArray); -MV_STATUS mvMbusArbCtrlSet(MV_MBUS_ARB_CTRL *ctrl); -MV_STATUS mvMbusArbCtrlGet(MV_MBUS_ARB_CTRL *ctrl); - -#endif /* #if defined(MV_88F1181) */ - - -MV_VOID mvAhbToMbusAddDecShow(MV_VOID); - - -#endif /* __INCmvAhbToMbush */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvAhbToMbusRegs.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvAhbToMbusRegs.h deleted file mode 100644 index 97dc631..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvAhbToMbusRegs.h +++ /dev/null @@ -1,143 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -#ifndef __INCmvAhbToMbusRegsh -#define __INCmvAhbToMbusRegsh - -/******************************/ -/* ARM Address Map Registers */ -/******************************/ - -#define MAX_AHB_TO_MBUS_WINS 9 -#define MV_AHB_TO_MBUS_INTREG_WIN 8 - - -#define AHB_TO_MBUS_WIN_CTRL_REG(winNum) (0x20000 + (winNum)*0x10) -#define AHB_TO_MBUS_WIN_BASE_REG(winNum) (0x20004 + (winNum)*0x10) -#define AHB_TO_MBUS_WIN_REMAP_LOW_REG(winNum) (0x20008 + (winNum)*0x10) -#define AHB_TO_MBUS_WIN_REMAP_HIGH_REG(winNum) (0x2000C + (winNum)*0x10) -#define AHB_TO_MBUS_WIN_INTEREG_REG 0x20080 - -/* Window Control Register */ -/* AHB_TO_MBUS_WIN_CTRL_REG (ATMWCR)*/ -#define ATMWCR_WIN_ENABLE BIT0 /* Window Enable */ - -#define ATMWCR_WIN_TARGET_OFFS 4 /* The target interface associated - with this window*/ -#define ATMWCR_WIN_TARGET_MASK (0xf << ATMWCR_WIN_TARGET_OFFS) - -#define ATMWCR_WIN_ATTR_OFFS 8 /* The target interface attributes - Associated with this window */ -#define ATMWCR_WIN_ATTR_MASK (0xff << ATMWCR_WIN_ATTR_OFFS) - - -/* -Used with the Base register to set the address window size and location -Must be programed from LSB to MSB as sequence of 1’s followed -by sequence of 0’s. The number of 1’s specifies the size of the window -in 64 KB granularity (e.g. a value of 0x00FF specifies 256 = 16 MB). - -NOTE: A value of 0x0 specifies 64KB size. -*/ -#define ATMWCR_WIN_SIZE_OFFS 16 /* Window Size */ -#define ATMWCR_WIN_SIZE_MASK (0xffff << ATMWCR_WIN_SIZE_OFFS) -#define ATMWCR_WIN_SIZE_ALIGNMENT 0x10000 - -/* Window Base Register */ -/* AHB_TO_MBUS_WIN_BASE_REG (ATMWBR) */ - -/* -Used with the size field to set the address window size and location. -Corresponds to transaction address[31:16] -*/ -#define ATMWBR_BASE_OFFS 16 /* Base Address */ -#define ATMWBR_BASE_MASK (0xffff << ATMWBR_BASE_OFFS) -#define ATMWBR_BASE_ALIGNMENT 0x10000 - -/* Window Remap Low Register */ -/* AHB_TO_MBUS_WIN_REMAP_LOW_REG (ATMWRLR) */ - -/* -Used with the size field to specifies address bits[31:0] to be driven to -the target interface.: -target_addr[31:16] = (addr[31:16] & size[15:0]) | (remap[31:16] & ~size[15:0]) -*/ -#define ATMWRLR_REMAP_LOW_OFFS 16 /* Remap Address */ -#define ATMWRLR_REMAP_LOW_MASK (0xffff << ATMWRLR_REMAP_LOW_OFFS) -#define ATMWRLR_REMAP_LOW_ALIGNMENT 0x10000 - -/* Window Remap High Register */ -/* AHB_TO_MBUS_WIN_REMAP_HIGH_REG (ATMWRHR) */ - -/* -Specifies address bits[63:32] to be driven to the target interface. -target_addr[63:32] = (RemapHigh[31:0] -*/ -#define ATMWRHR_REMAP_HIGH_OFFS 0 /* Remap Address */ -#define ATMWRHR_REMAP_HIGH_MASK (0xffffffff << ATMWRHR_REMAP_HIGH_OFFS) - - -#endif /* __INCmvAhbToMbusRegsh */ - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvCpuIf.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvCpuIf.c deleted file mode 100644 index 872dc6e..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvCpuIf.c +++ /dev/null @@ -1,1036 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -/* includes */ -#include "ctrlEnv/sys/mvCpuIf.h" -#include "ctrlEnv/sys/mvAhbToMbusRegs.h" -#include "cpu/mvCpu.h" -#include "ctrlEnv/mvCtrlEnvLib.h" -#include "mvSysHwConfig.h" -#include "mvSysDram.h" - -/*#define MV_DEBUG*/ -/* defines */ - -#ifdef MV_DEBUG - #define DB(x) x -#else - #define DB(x) -#endif - -/* locals */ -/* static functions */ -static MV_BOOL cpuTargetWinOverlap(MV_TARGET target, MV_ADDR_WIN *pAddrWin); - -MV_TARGET * sampleAtResetTargetArray; -MV_TARGET sampleAtResetTargetArrayP[] = BOOT_TARGETS_NAME_ARRAY; -MV_TARGET sampleAtResetTargetArray6180P[] = BOOT_TARGETS_NAME_ARRAY_6180; -/******************************************************************************* -* mvCpuIfInit - Initialize Controller CPU interface -* -* DESCRIPTION: -* This function initialize Controller CPU interface: -* 1. Set CPU interface configuration registers. -* 2. Set CPU master Pizza arbiter control according to static -* configuration described in configuration file. -* 3. Opens CPU address decode windows. DRAM windows are assumed to be -* already set (auto detection). -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_STATUS mvCpuIfInit(MV_CPU_DEC_WIN *cpuAddrWinMap) -{ - MV_U32 regVal; - MV_TARGET target; - MV_ADDR_WIN addrWin; - - if (cpuAddrWinMap == NULL) - { - DB(mvOsPrintf("mvCpuIfInit:ERR. cpuAddrWinMap == NULL\n")); - return MV_ERROR; - } - - /*Initialize the boot target array according to device type*/ - if(mvCtrlModelGet() == MV_6180_DEV_ID) - sampleAtResetTargetArray = sampleAtResetTargetArray6180P; - else - sampleAtResetTargetArray = sampleAtResetTargetArrayP; - - /* Set ARM Configuration register */ - regVal = MV_REG_READ(CPU_CONFIG_REG); - regVal &= ~CPU_CONFIG_DEFAULT_MASK; - regVal |= CPU_CONFIG_DEFAULT; - MV_REG_WRITE(CPU_CONFIG_REG,regVal); - - /* First disable all CPU target windows */ - for (target = 0; cpuAddrWinMap[target].enable != TBL_TERM; target++) - { - if ((MV_TARGET_IS_DRAM(target))||(target == INTER_REGS)) - { - continue; - } - -#if defined(MV_MEM_OVER_PCI_WA) || defined(MV_UART_OVER_PCI_WA) - /* If the target PEX or PCI and memory is over PEX or PCI we don't touch this CPU windows */ - if (MV_TARGET_IS_PCI(target)) - { - continue; - } -#endif - -#if defined(MV_MEM_OVER_PEX_WA) || defined(MV_UART_OVER_PEX_WA) - /* If the target PEX or PCI and memory is over PEX or PCI we don't touch this CPU windows */ - if (MV_TARGET_IS_PEX(target)) - { - continue; - } -#endif -#if defined(MV_RUN_FROM_FLASH) - /* Don't disable the boot device. */ - if (target == DEV_BOOCS) - { - continue; - } -#endif /* MV_RUN_FROM_FLASH */ - mvCpuIfTargetWinEnable(MV_CHANGE_BOOT_CS(target),MV_FALSE); - } - -#if defined(MV_RUN_FROM_FLASH) - /* Resize the bootcs windows before other windows, because this */ - /* window is enabled and will cause an overlap if not resized. */ - target = DEV_BOOCS; - - if (MV_OK != mvCpuIfTargetWinSet(target, &cpuAddrWinMap[target])) - { - DB(mvOsPrintf("mvCpuIfInit:ERR. mvCpuIfTargetWinSet fail\n")); - return MV_ERROR; - } - - addrWin.baseLow = cpuAddrWinMap[target].addrWin.baseLow; - addrWin.baseHigh = cpuAddrWinMap[target].addrWin.baseHigh; - if (0xffffffff == mvAhbToMbusWinRemap(cpuAddrWinMap[target].winNum ,&addrWin)) - { - DB(mvOsPrintf("mvCpuIfInit:WARN. mvAhbToMbusWinRemap can't remap winNum=%d\n", - cpuAddrWinMap[target].winNum)); - } - -#endif /* MV_RUN_FROM_FLASH */ - - /* Go through all targets in user table until table terminator */ - for (target = 0; cpuAddrWinMap[target].enable != TBL_TERM; target++) - { - -#if defined(MV_RUN_FROM_FLASH) - if (target == DEV_BOOCS) - { - continue; - } -#endif /* MV_RUN_FROM_FLASH */ - - /* if DRAM auto sizing is used do not initialized DRAM target windows, */ - /* assuming this already has been done earlier. */ -#ifdef MV_DRAM_AUTO_SIZE - if (MV_TARGET_IS_DRAM(target)) - { - continue; - } -#endif - -#if defined(MV_MEM_OVER_PCI_WA) || defined(MV_UART_OVER_PCI_WA) - /* If the target PEX or PCI and memory is over PEX or PCI we don't touch this CPU windows */ - if (MV_TARGET_IS_PCI(target)) - { - continue; - } -#endif - -#if defined(MV_MEM_OVER_PEX_WA) || defined(MV_UART_OVER_PEX_WA) - /* If the target PEX or PCI and memory is over PEX or PCI we don't touch this CPU windows */ - if (MV_TARGET_IS_PEX(target)) - { - continue; - } -#endif - /* If the target attribute is the same as the boot device attribute */ - /* then it's stays disable */ - if (MV_TARGET_IS_AS_BOOT(target)) - { - continue; - } - - if((0 == cpuAddrWinMap[target].addrWin.size) || - (DIS == cpuAddrWinMap[target].enable)) - - { - if (MV_OK != mvCpuIfTargetWinEnable(target, MV_FALSE)) - { - DB(mvOsPrintf("mvCpuIfInit:ERR. mvCpuIfTargetWinEnable fail\n")); - return MV_ERROR; - } - - } - else - { - if (MV_OK != mvCpuIfTargetWinSet(target, &cpuAddrWinMap[target])) - { - DB(mvOsPrintf("mvCpuIfInit:ERR. mvCpuIfTargetWinSet fail\n")); - return MV_ERROR; - } - - addrWin.baseLow = cpuAddrWinMap[target].addrWin.baseLow; - addrWin.baseHigh = cpuAddrWinMap[target].addrWin.baseHigh; - if (0xffffffff == mvAhbToMbusWinRemap(cpuAddrWinMap[target].winNum ,&addrWin)) - { - DB(mvOsPrintf("mvCpuIfInit:WARN. mvAhbToMbusWinRemap can't remap winNum=%d\n", - cpuAddrWinMap[target].winNum)); - } - - - } - } - - return MV_OK; - - -} - - -/******************************************************************************* -* mvCpuIfTargetWinSet - Set CPU-to-peripheral target address window -* -* DESCRIPTION: -* This function sets a peripheral target (e.g. SDRAM bank0, PCI0_MEM0) -* address window, also known as address decode window. -* A new address decode window is set for specified target address window. -* If address decode window parameter structure enables the window, -* the routine will also enable the target window, allowing CPU to access -* the target window. -* -* INPUT: -* target - Peripheral target enumerator. -* pAddrDecWin - CPU target window data structure. -* -* OUTPUT: -* N/A -* -* RETURN: -* MV_OK if CPU target window was set correctly, MV_ERROR in case of -* address window overlapps with other active CPU target window or -* trying to assign 36bit base address while CPU does not support that. -* The function returns MV_NOT_SUPPORTED, if the target is unsupported. -* -*******************************************************************************/ -MV_STATUS mvCpuIfTargetWinSet(MV_TARGET target, MV_CPU_DEC_WIN *pAddrDecWin) -{ - MV_AHB_TO_MBUS_DEC_WIN decWin; - MV_U32 existingWinNum; - MV_DRAM_DEC_WIN addrDecWin; - - target = MV_CHANGE_BOOT_CS(target); - - /* Check parameters */ - if (target >= MAX_TARGETS) - { - mvOsPrintf("mvCpuIfTargetWinSet: target %d is Illigal\n", target); - return MV_ERROR; - } - - /* 2) Check if the requested window overlaps with current windows */ - if (MV_TRUE == cpuTargetWinOverlap(target, &pAddrDecWin->addrWin)) - { - mvOsPrintf("mvCpuIfTargetWinSet: ERR. Target %d overlap\n", target); - return MV_BAD_PARAM; - } - - if (MV_TARGET_IS_DRAM(target)) - { - /* copy relevant data to MV_DRAM_DEC_WIN structure */ - addrDecWin.addrWin.baseHigh = pAddrDecWin->addrWin.baseHigh; - addrDecWin.addrWin.baseLow = pAddrDecWin->addrWin.baseLow; - addrDecWin.addrWin.size = pAddrDecWin->addrWin.size; - addrDecWin.enable = pAddrDecWin->enable; - - - if (mvDramIfWinSet(target,&addrDecWin) != MV_OK); - { - mvOsPrintf("mvCpuIfTargetWinSet: mvDramIfWinSet Failed\n"); - return MV_ERROR; - } - - } - else - { - /* copy relevant data to MV_AHB_TO_MBUS_DEC_WIN structure */ - decWin.addrWin.baseLow = pAddrDecWin->addrWin.baseLow; - decWin.addrWin.baseHigh = pAddrDecWin->addrWin.baseHigh; - decWin.addrWin.size = pAddrDecWin->addrWin.size; - decWin.enable = pAddrDecWin->enable; - decWin.target = target; - - existingWinNum = mvAhbToMbusWinTargetGet(target); - - /* check if there is already another Window configured - for this target */ - if ((existingWinNum < MAX_AHB_TO_MBUS_WINS )&& - (existingWinNum != pAddrDecWin->winNum)) - { - /* if we want to enable the new winow number - passed by the user , then the old one should - be disabled */ - if (MV_TRUE == pAddrDecWin->enable) - { - /* be sure it is disabled */ - mvAhbToMbusWinEnable(existingWinNum , MV_FALSE); - } - } - - if (mvAhbToMbusWinSet(pAddrDecWin->winNum,&decWin) != MV_OK) - { - mvOsPrintf("mvCpuIfTargetWinSet: mvAhbToMbusWinSet Failed\n"); - return MV_ERROR; - } - - } - - return MV_OK; -} - -/******************************************************************************* -* mvCpuIfTargetWinGet - Get CPU-to-peripheral target address window -* -* DESCRIPTION: -* Get the CPU peripheral target address window. -* -* INPUT: -* target - Peripheral target enumerator -* -* OUTPUT: -* pAddrDecWin - CPU target window information data structure. -* -* RETURN: -* MV_OK if target exist, MV_ERROR otherwise. -* -*******************************************************************************/ -MV_STATUS mvCpuIfTargetWinGet(MV_TARGET target, MV_CPU_DEC_WIN *pAddrDecWin) -{ - - MV_U32 winNum=0xffffffff; - MV_AHB_TO_MBUS_DEC_WIN decWin; - MV_DRAM_DEC_WIN addrDecWin; - - target = MV_CHANGE_BOOT_CS(target); - - /* Check parameters */ - if (target >= MAX_TARGETS) - { - mvOsPrintf("mvCpuIfTargetWinGet: target %d is Illigal\n", target); - return MV_ERROR; - } - - if (MV_TARGET_IS_DRAM(target)) - { - if (mvDramIfWinGet(target,&addrDecWin) != MV_OK) - { - mvOsPrintf("mvCpuIfTargetWinGet: Failed to get window target %d\n", - target); - return MV_ERROR; - } - - /* copy relevant data to MV_CPU_DEC_WIN structure */ - pAddrDecWin->addrWin.baseLow = addrDecWin.addrWin.baseLow; - pAddrDecWin->addrWin.baseHigh = addrDecWin.addrWin.baseHigh; - pAddrDecWin->addrWin.size = addrDecWin.addrWin.size; - pAddrDecWin->enable = addrDecWin.enable; - pAddrDecWin->winNum = 0xffffffff; - - } - else - { - /* get the Window number associated with this target */ - - winNum = mvAhbToMbusWinTargetGet(target); - if (winNum >= MAX_AHB_TO_MBUS_WINS) - { - return MV_NO_SUCH; - - } - - if (mvAhbToMbusWinGet(winNum , &decWin) != MV_OK) - { - mvOsPrintf("%s: mvAhbToMbusWinGet Failed at winNum = %d\n", - __FUNCTION__, winNum); - return MV_ERROR; - - } - - /* copy relevant data to MV_CPU_DEC_WIN structure */ - pAddrDecWin->addrWin.baseLow = decWin.addrWin.baseLow; - pAddrDecWin->addrWin.baseHigh = decWin.addrWin.baseHigh; - pAddrDecWin->addrWin.size = decWin.addrWin.size; - pAddrDecWin->enable = decWin.enable; - pAddrDecWin->winNum = winNum; - - } - - - - - return MV_OK; -} - - -/******************************************************************************* -* mvCpuIfTargetWinEnable - Enable/disable a CPU address decode window -* -* DESCRIPTION: -* This function enable/disable a CPU address decode window. -* if parameter 'enable' == MV_TRUE the routine will enable the -* window, thus enabling CPU accesses (before enabling the window it is -* tested for overlapping). Otherwise, the window will be disabled. -* -* INPUT: -* target - Peripheral target enumerator. -* enable - Enable/disable parameter. -* -* OUTPUT: -* N/A -* -* RETURN: -* MV_ERROR if protection window number was wrong, or the window -* overlapps other target window. -* -*******************************************************************************/ -MV_STATUS mvCpuIfTargetWinEnable(MV_TARGET target,MV_BOOL enable) -{ - MV_U32 winNum, temp; - MV_CPU_DEC_WIN addrDecWin; - - target = MV_CHANGE_BOOT_CS(target); - - /* Check parameters */ - if (target >= MAX_TARGETS) - { - mvOsPrintf("mvCpuIfTargetWinEnable: target %d is Illigal\n", target); - return MV_ERROR; - } - - /* get the window and check if it exist */ - temp = mvCpuIfTargetWinGet(target, &addrDecWin); - if (MV_NO_SUCH == temp) - { - return (enable? MV_ERROR: MV_OK); - } - else if( MV_OK != temp) - { - mvOsPrintf("%s: ERR. Getting target %d failed.\n",__FUNCTION__, target); - return MV_ERROR; - } - - - /* check overlap */ - - if (MV_TRUE == enable) - { - if (MV_TRUE == cpuTargetWinOverlap(target, &addrDecWin.addrWin)) - { - DB(mvOsPrintf("%s: ERR. Target %d overlap\n",__FUNCTION__, target)); - return MV_ERROR; - } - - } - - - if (MV_TARGET_IS_DRAM(target)) - { - if (mvDramIfWinEnable(target , enable) != MV_OK) - { - mvOsPrintf("mvCpuIfTargetWinGet: mvDramIfWinEnable Failed at \n"); - return MV_ERROR; - - } - - } - else - { - /* get the Window number associated with this target */ - - winNum = mvAhbToMbusWinTargetGet(target); - - if (winNum >= MAX_AHB_TO_MBUS_WINS) - { - return (enable? MV_ERROR: MV_OK); - } - - if (mvAhbToMbusWinEnable(winNum , enable) != MV_OK) - { - mvOsPrintf("mvCpuIfTargetWinGet: Failed to enable window = %d\n", - winNum); - return MV_ERROR; - - } - - } - - return MV_OK; -} - - -/******************************************************************************* -* mvCpuIfTargetWinSizeGet - Get CPU target address window size -* -* DESCRIPTION: -* Get the size of CPU-to-peripheral target window. -* -* INPUT: -* target - Peripheral target enumerator -* -* OUTPUT: -* None. -* -* RETURN: -* 32bit size. Function also returns '0' if window is closed. -* Function returns 0xFFFFFFFF in case of an error. -* -*******************************************************************************/ -MV_U32 mvCpuIfTargetWinSizeGet(MV_TARGET target) -{ - MV_CPU_DEC_WIN addrDecWin; - - target = MV_CHANGE_BOOT_CS(target); - - /* Check parameters */ - if (target >= MAX_TARGETS) - { - mvOsPrintf("mvCpuIfTargetWinSizeGet: target %d is Illigal\n", target); - return 0; - } - - /* Get the winNum window */ - if (MV_OK != mvCpuIfTargetWinGet(target, &addrDecWin)) - { - mvOsPrintf("mvCpuIfTargetWinSizeGet:ERR. Getting target %d failed.\n", - target); - return 0; - } - - /* Check if window is enabled */ - if (addrDecWin.enable == MV_TRUE) - { - return (addrDecWin.addrWin.size); - } - else - { - return 0; /* Window disabled. return 0 */ - } -} - -/******************************************************************************* -* mvCpuIfTargetWinBaseLowGet - Get CPU target address window base low -* -* DESCRIPTION: -* CPU-to-peripheral target address window base is constructed of -* two parts: Low and high. -* This function gets the CPU peripheral target low base address. -* -* INPUT: -* target - Peripheral target enumerator -* -* OUTPUT: -* None. -* -* RETURN: -* 32bit low base address. -* -*******************************************************************************/ -MV_U32 mvCpuIfTargetWinBaseLowGet(MV_TARGET target) -{ - MV_CPU_DEC_WIN addrDecWin; - - target = MV_CHANGE_BOOT_CS(target); - - /* Check parameters */ - if (target >= MAX_TARGETS) - { - mvOsPrintf("mvCpuIfTargetWinBaseLowGet: target %d is Illigal\n", target); - return 0xffffffff; - } - - /* Get the target window */ - if (MV_OK != mvCpuIfTargetWinGet(target, &addrDecWin)) - { - mvOsPrintf("mvCpuIfTargetWinBaseLowGet:ERR. Getting target %d failed.\n", - target); - return 0xffffffff; - } - - if (MV_FALSE == addrDecWin.enable) - { - return 0xffffffff; - } - return (addrDecWin.addrWin.baseLow); -} - -/******************************************************************************* -* mvCpuIfTargetWinBaseHighGet - Get CPU target address window base high -* -* DESCRIPTION: -* CPU-to-peripheral target address window base is constructed of -* two parts: Low and high. -* This function gets the CPU peripheral target high base address. -* -* INPUT: -* target - Peripheral target enumerator -* -* OUTPUT: -* None. -* -* RETURN: -* 32bit high base address. -* -*******************************************************************************/ -MV_U32 mvCpuIfTargetWinBaseHighGet(MV_TARGET target) -{ - MV_CPU_DEC_WIN addrDecWin; - - target = MV_CHANGE_BOOT_CS(target); - - /* Check parameters */ - if (target >= MAX_TARGETS) - { - mvOsPrintf("mvCpuIfTargetWinBaseLowGet: target %d is Illigal\n", target); - return 0xffffffff; - } - - /* Get the target window */ - if (MV_OK != mvCpuIfTargetWinGet(target, &addrDecWin)) - { - mvOsPrintf("mvCpuIfTargetWinBaseHighGet:ERR. Getting target %d failed.\n", - target); - return 0xffffffff; - } - - if (MV_FALSE == addrDecWin.enable) - { - return 0; - } - - return (addrDecWin.addrWin.baseHigh); -} - -#if defined(MV_INCLUDE_PEX) -/******************************************************************************* -* mvCpuIfPexRemap - Set CPU remap register for address windows. -* -* DESCRIPTION: -* -* INPUT: -* pexTarget - Peripheral target enumerator. Must be a PEX target. -* pAddrDecWin - CPU target window information data structure. -* Note that caller has to fill in the base field only. The -* size field is ignored. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_ERROR if target is not a PEX one, MV_OK otherwise. -* -*******************************************************************************/ -MV_U32 mvCpuIfPexRemap(MV_TARGET pexTarget, MV_ADDR_WIN *pAddrDecWin) -{ - MV_U32 winNum; - - /* Check parameters */ - - if (mvCtrlPexMaxIfGet() > 1) - { - if ((!MV_TARGET_IS_PEX1(pexTarget))&&(!MV_TARGET_IS_PEX0(pexTarget))) - { - mvOsPrintf("mvCpuIfPexRemap: target %d is Illigal\n",pexTarget); - return 0xffffffff; - } - - } - else - { - if (!MV_TARGET_IS_PEX0(pexTarget)) - { - mvOsPrintf("mvCpuIfPexRemap: target %d is Illigal\n",pexTarget); - return 0xffffffff; - } - - } - - /* get the Window number associated with this target */ - winNum = mvAhbToMbusWinTargetGet(pexTarget); - - if (winNum >= MAX_AHB_TO_MBUS_WINS) - { - mvOsPrintf("mvCpuIfPexRemap: mvAhbToMbusWinTargetGet Failed\n"); - return 0xffffffff; - - } - - return mvAhbToMbusWinRemap(winNum , pAddrDecWin); -} - -#endif - -#if defined(MV_INCLUDE_PCI) -/******************************************************************************* -* mvCpuIfPciRemap - Set CPU remap register for address windows. -* -* DESCRIPTION: -* -* INPUT: -* pciTarget - Peripheral target enumerator. Must be a PCI target. -* pAddrDecWin - CPU target window information data structure. -* Note that caller has to fill in the base field only. The -* size field is ignored. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_ERROR if target is not a PCI one, MV_OK otherwise. -* -*******************************************************************************/ -MV_U32 mvCpuIfPciRemap(MV_TARGET pciTarget, MV_ADDR_WIN *pAddrDecWin) -{ - MV_U32 winNum; - - /* Check parameters */ - if (!MV_TARGET_IS_PCI(pciTarget)) - { - mvOsPrintf("mvCpuIfPciRemap: target %d is Illigal\n",pciTarget); - return 0xffffffff; - } - - /* get the Window number associated with this target */ - winNum = mvAhbToMbusWinTargetGet(pciTarget); - - if (winNum >= MAX_AHB_TO_MBUS_WINS) - { - mvOsPrintf("mvCpuIfPciRemap: mvAhbToMbusWinTargetGet Failed\n"); - return 0xffffffff; - - } - - return mvAhbToMbusWinRemap(winNum , pAddrDecWin); -} -#endif /* MV_INCLUDE_PCI */ - - -/******************************************************************************* -* mvCpuIfPciIfRemap - Set CPU remap register for address windows. -* -* DESCRIPTION: -* -* INPUT: -* pciTarget - Peripheral target enumerator. Must be a PCI target. -* pAddrDecWin - CPU target window information data structure. -* Note that caller has to fill in the base field only. The -* size field is ignored. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_ERROR if target is not a PCI one, MV_OK otherwise. -* -*******************************************************************************/ -MV_U32 mvCpuIfPciIfRemap(MV_TARGET pciIfTarget, MV_ADDR_WIN *pAddrDecWin) -{ -#if defined(MV_INCLUDE_PEX) - if (MV_TARGET_IS_PEX(pciIfTarget)) - { - return mvCpuIfPexRemap(pciIfTarget,pAddrDecWin); - } -#endif -#if defined(MV_INCLUDE_PCI) - - if (MV_TARGET_IS_PCI(pciIfTarget)) - { - return mvCpuIfPciRemap(pciIfTarget,pAddrDecWin); - } -#endif - return 0; -} - - - -/******************************************************************************* -* mvCpuIfTargetOfBaseAddressGet - Get the target according to base address -* -* DESCRIPTION: -* -* INPUT: -* baseAddress - base address to be checked -* -* OUTPUT: -* None. -* -* RETURN: -* the target number that baseAddress belongs to or MAX_TARGETS is not -* found -* -*******************************************************************************/ - -MV_TARGET mvCpuIfTargetOfBaseAddressGet(MV_U32 baseAddress) -{ - MV_CPU_DEC_WIN win; - MV_U32 target; - - for( target = 0; target < MAX_TARGETS; target++ ) - { - if( mvCpuIfTargetWinGet( target, &win ) == MV_OK ) - { - if( win.enable ) - { - if ((baseAddress >= win.addrWin.baseLow) && - (baseAddress < win.addrWin.baseLow + win.addrWin.size)) break; - } - } - else return MAX_TARGETS; - - } - - return target; -} -/******************************************************************************* -* cpuTargetWinOverlap - Detect CPU address decode windows overlapping -* -* DESCRIPTION: -* An unpredicted behaviur is expected in case CPU address decode -* windows overlapps. -* This function detects CPU address decode windows overlapping of a -* specified target. The function does not check the target itself for -* overlapping. The function also skipps disabled address decode windows. -* -* INPUT: -* target - Peripheral target enumerator. -* pAddrDecWin - An address decode window struct. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_TRUE if the given address window overlaps current address -* decode map, MV_FALSE otherwise. -* -*******************************************************************************/ -static MV_BOOL cpuTargetWinOverlap(MV_TARGET target, MV_ADDR_WIN *pAddrWin) -{ - MV_U32 targetNum; - MV_CPU_DEC_WIN addrDecWin; - MV_STATUS status; - - - for(targetNum = 0; targetNum < MAX_TARGETS; targetNum++) - { -#if defined(MV_RUN_FROM_FLASH) - if(MV_TARGET_IS_AS_BOOT(target)) - { - if (MV_CHANGE_BOOT_CS(targetNum) == target) - continue; - } -#endif /* MV_RUN_FROM_FLASH */ - - /* don't check our target or illegal targets */ - if (targetNum == target) - { - continue; - } - - /* Get window parameters */ - status = mvCpuIfTargetWinGet(targetNum, &addrDecWin); - if(MV_NO_SUCH == status) - { - continue; - } - if(MV_OK != status) - { - DB(mvOsPrintf("cpuTargetWinOverlap: ERR. TargetWinGet failed\n")); - return MV_TRUE; - } - - /* Do not check disabled windows */ - if (MV_FALSE == addrDecWin.enable) - { - continue; - } - - if(MV_TRUE == ctrlWinOverlapTest(pAddrWin, &addrDecWin.addrWin)) - { - DB(mvOsPrintf( - "cpuTargetWinOverlap: Required target %d overlap current %d\n", - target, targetNum)); - return MV_TRUE; - } - } - - return MV_FALSE; - -} - -/******************************************************************************* -* mvCpuIfAddDecShow - Print the CPU address decode map. -* -* DESCRIPTION: -* This function print the CPU address decode map. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_VOID mvCpuIfAddDecShow(MV_VOID) -{ - MV_CPU_DEC_WIN win; - MV_U32 target; - mvOsOutput( "\n" ); - mvOsOutput( "CPU Interface\n" ); - mvOsOutput( "-------------\n" ); - - for( target = 0; target < MAX_TARGETS; target++ ) - { - - memset( &win, 0, sizeof(MV_CPU_DEC_WIN) ); - - mvOsOutput( "%s ",mvCtrlTargetNameGet(target)); - mvOsOutput( "...." ); - - if( mvCpuIfTargetWinGet( target, &win ) == MV_OK ) - { - if( win.enable ) - { - mvOsOutput( "base %08x, ", win.addrWin.baseLow ); - mvSizePrint( win.addrWin.size ); - mvOsOutput( "\n" ); - - } - else - mvOsOutput( "disable\n" ); - } - else if( mvCpuIfTargetWinGet( target, &win ) == MV_NO_SUCH ) - { - mvOsOutput( "no such\n" ); - } - } -} - -/******************************************************************************* -* mvCpuIfEnablePex - Enable PCI Express. -* -* DESCRIPTION: -* This function Enable PCI Express. -* -* INPUT: -* pexIf - PEX interface number. -* pexType - MV_PEX_ROOT_COMPLEX - root complex device -* MV_PEX_END_POINT - end point device -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -#if defined(MV_INCLUDE_PEX) -MV_VOID mvCpuIfEnablePex(MV_U32 pexIf, MV_PEX_TYPE pexType) -{ - /* Set pex mode incase S@R not exist */ - if( pexType == MV_PEX_END_POINT) - { - MV_REG_BIT_RESET(PEX_CTRL_REG(pexIf),PXCR_DEV_TYPE_CTRL_MASK); - /* Change pex mode in capability reg */ - MV_REG_BIT_RESET(PEX_CFG_DIRECT_ACCESS(pexIf,PEX_CAPABILITY_REG), BIT22); - MV_REG_BIT_SET(PEX_CFG_DIRECT_ACCESS(pexIf,PEX_CAPABILITY_REG), BIT20); - - } - else - { - MV_REG_BIT_SET(PEX_CTRL_REG(pexIf),PXCR_DEV_TYPE_CTRL_MASK); - } - - /* CPU config register Pex enable */ - MV_REG_BIT_SET(CPU_CTRL_STAT_REG,CCSR_PCI_ACCESS_MASK); -} -#endif - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvCpuIf.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvCpuIf.h deleted file mode 100644 index 224ed07..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvCpuIf.h +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -#ifndef __INCmvCpuIfh -#define __INCmvCpuIfh - -/* includes */ -#include "ctrlEnv/mvCtrlEnvLib.h" -#include "ctrlEnv/sys/mvCpuIfRegs.h" -#include "ctrlEnv/sys/mvAhbToMbus.h" -#include "ddr2/mvDramIf.h" -#include "ctrlEnv/sys/mvSysDram.h" -#if defined(MV_INCLUDE_PEX) -#include "pex/mvPex.h" -#endif - -/* defines */ - -/* typedefs */ -/* This structure describes CPU interface address decode window */ -typedef struct _mvCpuIfDecWin -{ - MV_ADDR_WIN addrWin; /* An address window*/ - MV_U32 winNum; /* Window Number in the AHB To Mbus bridge */ - MV_BOOL enable; /* Address decode window is enabled/disabled */ - -}MV_CPU_DEC_WIN; - - - -/* mvCpuIfLib.h API list */ - -/* mvCpuIfLib.h API list */ - -MV_STATUS mvCpuIfInit(MV_CPU_DEC_WIN *cpuAddrWinMap); -MV_STATUS mvCpuIfTargetWinSet(MV_TARGET target, MV_CPU_DEC_WIN *pAddrDecWin); -MV_STATUS mvCpuIfTargetWinGet(MV_TARGET target, MV_CPU_DEC_WIN *pAddrDecWin); -MV_STATUS mvCpuIfTargetWinEnable(MV_TARGET target,MV_BOOL enable); -MV_U32 mvCpuIfTargetWinSizeGet(MV_TARGET target); -MV_U32 mvCpuIfTargetWinBaseLowGet(MV_TARGET target); -MV_U32 mvCpuIfTargetWinBaseHighGet(MV_TARGET target); -MV_TARGET mvCpuIfTargetOfBaseAddressGet(MV_U32 baseAddress); -#if defined(MV_INCLUDE_PEX) -MV_U32 mvCpuIfPexRemap(MV_TARGET pexTarget, MV_ADDR_WIN *pAddrDecWin); -MV_VOID mvCpuIfEnablePex(MV_U32 pexIf, MV_PEX_TYPE pexType); -#endif -#if defined(MV_INCLUDE_PCI) -MV_U32 mvCpuIfPciRemap(MV_TARGET pciTarget, MV_ADDR_WIN *pAddrDecWin); -#endif -MV_U32 mvCpuIfPciIfRemap(MV_TARGET pciTarget, MV_ADDR_WIN *pAddrDecWin); - -MV_VOID mvCpuIfAddDecShow(MV_VOID); - -#if defined(MV88F6281) -MV_STATUS mvCpuIfBridgeReorderWAInit(void); -#endif - -#endif /* __INCmvCpuIfh */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvCpuIfRegs.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvCpuIfRegs.h deleted file mode 100644 index 8cfeee2..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvCpuIfRegs.h +++ /dev/null @@ -1,304 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -#ifndef __INCmvCpuIfRegsh -#define __INCmvCpuIfRegsh - -/****************************************/ -/* ARM Control and Status Registers Map */ -/****************************************/ - -#define CPU_CONFIG_REG 0x20100 -#define CPU_CTRL_STAT_REG 0x20104 -#define CPU_RSTOUTN_MASK_REG 0x20108 -#define CPU_SYS_SOFT_RST_REG 0x2010C -#define CPU_AHB_MBUS_CAUSE_INT_REG 0x20110 -#define CPU_AHB_MBUS_MASK_INT_REG 0x20114 -#define CPU_FTDLL_CONFIG_REG 0x20120 -#define CPU_L2_CONFIG_REG 0x20128 - - - -/* ARM Configuration register */ -/* CPU_CONFIG_REG (CCR) */ - - -/* Reset vector location */ -#define CCR_VEC_INIT_LOC_OFFS 1 -#define CCR_VEC_INIT_LOC_MASK BIT1 -/* reset at 0x00000000 */ -#define CCR_VEC_INIT_LOC_0000 (0 << CCR_VEC_INIT_LOC_OFFS) -/* reset at 0xFFFF0000 */ -#define CCR_VEC_INIT_LOC_FF00 (1 << CCR_VEC_INIT_LOC_OFFS) - - -#define CCR_AHB_ERROR_PROP_OFFS 2 -#define CCR_AHB_ERROR_PROP_MASK BIT2 -/* Erros are not propogated to AHB */ -#define CCR_AHB_ERROR_PROP_NO_INDICATE (0 << CCR_AHB_ERROR_PROP_OFFS) -/* Erros are propogated to AHB */ -#define CCR_AHB_ERROR_PROP_INDICATE (1 << CCR_AHB_ERROR_PROP_OFFS) - - -#define CCR_ENDIAN_INIT_OFFS 3 -#define CCR_ENDIAN_INIT_MASK BIT3 -#define CCR_ENDIAN_INIT_LITTLE (0 << CCR_ENDIAN_INIT_OFFS) -#define CCR_ENDIAN_INIT_BIG (1 << CCR_ENDIAN_INIT_OFFS) - - -#define CCR_INCR_EN_OFFS 4 -#define CCR_INCR_EN_MASK BIT4 -#define CCR_INCR_EN BIT4 - - -#define CCR_NCB_BLOCKING_OFFS 5 -#define CCR_NCB_BLOCKING_MASK (1 << CCR_NCB_BLOCKING_OFFS) -#define CCR_NCB_BLOCKING_NON (0 << CCR_NCB_BLOCKING_OFFS) -#define CCR_NCB_BLOCKING_EN (1 << CCR_NCB_BLOCKING_OFFS) - -#define CCR_CPU_2_MBUSL_TICK_DRV_OFFS 8 -#define CCR_CPU_2_MBUSL_TICK_DRV_MASK (0xF << CCR_CPU_2_MBUSL_TICK_DRV_OFFS) -#define CCR_CPU_2_MBUSL_TICK_SMPL_OFFS 12 -#define CCR_CPU_2_MBUSL_TICK_SMPL_MASK (0xF << CCR_CPU_2_MBUSL_TICK_SMPL_OFFS) -#define CCR_ICACH_PREF_BUF_ENABLE BIT16 -#define CCR_DCACH_PREF_BUF_ENABLE BIT17 - -/* Ratio options for CPU to DDR for 6281/6192/6190 */ -#define CPU_2_DDR_CLK_1x3 4 -#define CPU_2_DDR_CLK_1x4 6 - -/* Ratio options for CPU to DDR for 6281 only */ -#define CPU_2_DDR_CLK_2x9 7 -#define CPU_2_DDR_CLK_1x5 8 -#define CPU_2_DDR_CLK_1x6 9 - -/* Ratio options for CPU to DDR for 6180 only */ -#define CPU_2_DDR_CLK_1x3_1 0x5 -#define CPU_2_DDR_CLK_1x4_1 0x6 - -/* Default values for CPU to Mbus-L DDR Interface Tick Driver and */ -/* CPU to Mbus-L Tick Sample fields in CPU config register */ - -#define TICK_DRV_1x1 0 -#define TICK_DRV_1x2 0 -#define TICK_DRV_1x3 1 -#define TICK_DRV_1x4 2 -#define TICK_SMPL_1x1 0 -#define TICK_SMPL_1x2 1 -#define TICK_SMPL_1x3 0 -#define TICK_SMPL_1x4 0 - -#define CPU_2_MBUSL_DDR_CLK_1x2 \ - ((TICK_DRV_1x2 << CCR_CPU_2_MBUSL_TICK_DRV_OFFS) | \ - (TICK_SMPL_1x2 << CCR_CPU_2_MBUSL_TICK_SMPL_OFFS)) -#define CPU_2_MBUSL_DDR_CLK_1x3 \ - ((TICK_DRV_1x3 << CCR_CPU_2_MBUSL_TICK_DRV_OFFS) | \ - (TICK_SMPL_1x3 << CCR_CPU_2_MBUSL_TICK_SMPL_OFFS)) -#define CPU_2_MBUSL_DDR_CLK_1x4 \ - ((TICK_DRV_1x4 << CCR_CPU_2_MBUSL_TICK_DRV_OFFS) | \ - (TICK_SMPL_1x4 << CCR_CPU_2_MBUSL_TICK_SMPL_OFFS)) - -/* ARM Control and Status register */ -/* CPU_CTRL_STAT_REG (CCSR) */ - - -/* -This is used to block PCI express\PCI from access Socrates/Feroceon GP -while ARM boot is still in progress -*/ - -#define CCSR_PCI_ACCESS_OFFS 0 -#define CCSR_PCI_ACCESS_MASK BIT0 -#define CCSR_PCI_ACCESS_ENABLE (0 << CCSR_PCI_ACCESS_OFFS) -#define CCSR_PCI_ACCESS_DISBALE (1 << CCSR_PCI_ACCESS_OFFS) - -#define CCSR_ARM_RESET BIT1 -#define CCSR_SELF_INT BIT2 -#define CCSR_BIG_ENDIAN BIT15 - - -/* RSTOUTn Mask Register */ -/* CPU_RSTOUTN_MASK_REG (CRMR) */ - -#define CRMR_PEX_RST_OUT_OFFS 0 -#define CRMR_PEX_RST_OUT_MASK BIT0 -#define CRMR_PEX_RST_OUT_ENABLE (1 << CRMR_PEX_RST_OUT_OFFS) -#define CRMR_PEX_RST_OUT_DISABLE (0 << CRMR_PEX_RST_OUT_OFFS) - -#define CRMR_WD_RST_OUT_OFFS 1 -#define CRMR_WD_RST_OUT_MASK BIT1 -#define CRMR_WD_RST_OUT_ENABLE (1 << CRMR_WD_RST_OUT_OFFS) -#define CRMR_WD_RST_OUT_DISBALE (0 << CRMR_WD_RST_OUT_OFFS) - -#define CRMR_SOFT_RST_OUT_OFFS 2 -#define CRMR_SOFT_RST_OUT_MASK BIT2 -#define CRMR_SOFT_RST_OUT_ENABLE (1 << CRMR_SOFT_RST_OUT_OFFS) -#define CRMR_SOFT_RST_OUT_DISBALE (0 << CRMR_SOFT_RST_OUT_OFFS) - -/* System Software Reset Register */ -/* CPU_SYS_SOFT_RST_REG (CSSRR) */ - -#define CSSRR_SYSTEM_SOFT_RST BIT0 - -/* AHB to Mbus Bridge Interrupt Cause Register*/ -/* CPU_AHB_MBUS_CAUSE_INT_REG (CAMCIR) */ - -#define CAMCIR_ARM_SELF_INT BIT0 -#define CAMCIR_ARM_TIMER0_INT_REQ BIT1 -#define CAMCIR_ARM_TIMER1_INT_REQ BIT2 -#define CAMCIR_ARM_WD_TIMER_INT_REQ BIT3 - - -/* AHB to Mbus Bridge Interrupt Mask Register*/ -/* CPU_AHB_MBUS_MASK_INT_REG (CAMMIR) */ - -#define CAMCIR_ARM_SELF_INT_OFFS 0 -#define CAMCIR_ARM_SELF_INT_MASK BIT0 -#define CAMCIR_ARM_SELF_INT_EN (1 << CAMCIR_ARM_SELF_INT_OFFS) -#define CAMCIR_ARM_SELF_INT_DIS (0 << CAMCIR_ARM_SELF_INT_OFFS) - - -#define CAMCIR_ARM_TIMER0_INT_REQ_OFFS 1 -#define CAMCIR_ARM_TIMER0_INT_REQ_MASK BIT1 -#define CAMCIR_ARM_TIMER0_INT_REQ_EN (1 << CAMCIR_ARM_TIMER0_INT_REQ_OFFS) -#define CAMCIR_ARM_TIMER0_INT_REQ_DIS (0 << CAMCIR_ARM_TIMER0_INT_REQ_OFFS) - -#define CAMCIR_ARM_TIMER1_INT_REQ_OFFS 2 -#define CAMCIR_ARM_TIMER1_INT_REQ_MASK BIT2 -#define CAMCIR_ARM_TIMER1_INT_REQ_EN (1 << CAMCIR_ARM_TIMER1_INT_REQ_OFFS) -#define CAMCIR_ARM_TIMER1_INT_REQ_DIS (0 << CAMCIR_ARM_TIMER1_INT_REQ_OFFS) - -#define CAMCIR_ARM_WD_TIMER_INT_REQ_OFFS 3 -#define CAMCIR_ARM_WD_TIMER_INT_REQ_MASK BIT3 -#define CAMCIR_ARM_WD_TIMER_INT_REQ_EN (1 << CAMCIR_ARM_WD_TIMER_INT_REQ_OFFS) -#define CAMCIR_ARM_WD_TIMER_INT_REQ_DIS (0 << CAMCIR_ARM_WD_TIMER_INT_REQ_OFFS) - -/* CPU FTDLL Config register (CFCR) fields */ -#define CFCR_FTDLL_ICACHE_TAG_OFFS 0 -#define CFCR_FTDLL_ICACHE_TAG_MASK (0x7F << CFCR_FTDLL_ICACHE_TAG_OFFS) -#define CFCR_FTDLL_DCACHE_TAG_OFFS 8 -#define CFCR_FTDLL_DCACHE_TAG_MASK (0x7F << CFCR_FTDLL_DCACHE_TAG_OFFS) -#define CFCR_FTDLL_OVERWRITE_ENABLE (1 << 15) -/* For Orion 2 D2 only */ -#define CFCR_MRVL_CPU_ID_OFFS 16 -#define CFCR_MRVL_CPU_ID_MASK (0x1 << CFCR_MRVL_CPU_ID_OFFS) -#define CFCR_ARM_CPU_ID (0x0 << CFCR_MRVL_CPU_ID_OFFS) -#define CFCR_MRVL_CPU_ID (0x1 << CFCR_MRVL_CPU_ID_OFFS) -#define CFCR_VFP_SUB_ARC_NUM_OFFS 7 -#define CFCR_VFP_SUB_ARC_NUM_MASK (0x1 << CFCR_VFP_SUB_ARC_NUM_OFFS) -#define CFCR_VFP_SUB_ARC_NUM_1 (0x0 << CFCR_VFP_SUB_ARC_NUM_OFFS) -#define CFCR_VFP_SUB_ARC_NUM_2 (0x1 << CFCR_VFP_SUB_ARC_NUM_OFFS) - -/* CPU_L2_CONFIG_REG fields */ -#ifdef MV_CPU_LE -#define CL2CR_L2_ECC_EN_OFFS 2 -#define CL2CR_L2_WT_MODE_OFFS 4 -#else -#define CL2CR_L2_ECC_EN_OFFS 26 -#define CL2CR_L2_WT_MODE_OFFS 28 -#endif - -#define CL2CR_L2_ECC_EN_MASK (1 << CL2CR_L2_ECC_EN_OFFS) -#define CL2CR_L2_WT_MODE_MASK (1 << CL2CR_L2_WT_MODE_OFFS) - -/*******************************************/ -/* Main Interrupt Controller Registers Map */ -/*******************************************/ - -#define CPU_MAIN_INT_CAUSE_REG 0x20200 -#define CPU_MAIN_IRQ_MASK_REG 0x20204 -#define CPU_MAIN_FIQ_MASK_REG 0x20208 -#define CPU_ENPOINT_MASK_REG 0x2020C -#define CPU_MAIN_INT_CAUSE_HIGH_REG 0x20210 -#define CPU_MAIN_IRQ_MASK_HIGH_REG 0x20214 -#define CPU_MAIN_FIQ_MASK_HIGH_REG 0x20218 -#define CPU_ENPOINT_MASK_HIGH_REG 0x2021C - - -/*******************************************/ -/* ARM Doorbell Registers Map */ -/*******************************************/ - -#define CPU_HOST_TO_ARM_DRBL_REG 0x20400 -#define CPU_HOST_TO_ARM_MASK_REG 0x20404 -#define CPU_ARM_TO_HOST_DRBL_REG 0x20408 -#define CPU_ARM_TO_HOST_MASK_REG 0x2040C - - - -/* CPU control register map */ -/* Set bits means value is about to change according to new value */ -#define CPU_CONFIG_DEFAULT_MASK (CCR_VEC_INIT_LOC_MASK | CCR_AHB_ERROR_PROP_MASK) - -#define CPU_CONFIG_DEFAULT (CCR_VEC_INIT_LOC_FF00) - -/* CPU Control and status defaults */ -#define CPU_CTRL_STAT_DEFAULT_MASK (CCSR_PCI_ACCESS_MASK) - - -#define CPU_CTRL_STAT_DEFAULT (CCSR_PCI_ACCESS_ENABLE) - -#endif /* __INCmvCpuIfRegsh */ - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysAudio.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysAudio.c deleted file mode 100644 index 769475f..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysAudio.c +++ /dev/null @@ -1,324 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ -#include "mvSysAudio.h" - -/******************************************************************************* -* mvAudioWinSet - Set AUDIO target address window -* -* DESCRIPTION: -* This function sets a peripheral target (e.g. SDRAM bank0, PCI_MEM0) -* address window, also known as address decode window. -* After setting this target window, the AUDIO will be able to access the -* target within the address window. -* -* INPUT: -* winNum - AUDIO target address decode window number. -* pAddrDecWin - AUDIO target window data structure. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_ERROR if address window overlapps with other address decode windows. -* MV_BAD_PARAM if base address is invalid parameter or target is -* unknown. -* -*******************************************************************************/ -MV_STATUS mvAudioWinSet(MV_U32 winNum, MV_AUDIO_DEC_WIN *pAddrDecWin) -{ - MV_TARGET_ATTRIB targetAttribs; - MV_DEC_REGS decRegs; - - /* Parameter checking */ - if (winNum >= MV_AUDIO_MAX_ADDR_DECODE_WIN) - { - mvOsPrintf("%s: ERR. Invalid win num %d\n",__FUNCTION__, winNum); - return MV_BAD_PARAM; - } - - /* check if address is aligned to the size */ - if(MV_IS_NOT_ALIGN(pAddrDecWin->addrWin.baseLow, pAddrDecWin->addrWin.size)) - { - mvOsPrintf("mvAudioWinSet:Error setting AUDIO window %d to "\ - "target %s.\nAddress 0x%08x is unaligned to size 0x%x.\n", - winNum, - mvCtrlTargetNameGet(pAddrDecWin->target), - pAddrDecWin->addrWin.baseLow, - pAddrDecWin->addrWin.size); - return MV_ERROR; - } - - decRegs.baseReg = 0; - decRegs.sizeReg = 0; - - if (MV_OK != mvCtrlAddrDecToReg(&(pAddrDecWin->addrWin),&decRegs)) - { - mvOsPrintf("%s: mvCtrlAddrDecToReg Failed\n", __FUNCTION__); - return MV_ERROR; - } - - mvCtrlAttribGet(pAddrDecWin->target, &targetAttribs); - - /* set attributes */ - decRegs.sizeReg &= ~MV_AUDIO_WIN_ATTR_MASK; - decRegs.sizeReg |= (targetAttribs.attrib << MV_AUDIO_WIN_ATTR_OFFSET); - - /* set target ID */ - decRegs.sizeReg &= ~MV_AUDIO_WIN_TARGET_MASK; - decRegs.sizeReg |= (targetAttribs.targetId << MV_AUDIO_WIN_TARGET_OFFSET); - - if (pAddrDecWin->enable == MV_TRUE) - { - decRegs.sizeReg |= MV_AUDIO_WIN_ENABLE_MASK; - } - else - { - decRegs.sizeReg &= ~MV_AUDIO_WIN_ENABLE_MASK; - } - - MV_REG_WRITE( MV_AUDIO_WIN_CTRL_REG(winNum), decRegs.sizeReg); - MV_REG_WRITE( MV_AUDIO_WIN_BASE_REG(winNum), decRegs.baseReg); - - return MV_OK; -} - -/******************************************************************************* -* mvAudioWinGet - Get AUDIO peripheral target address window. -* -* DESCRIPTION: -* Get AUDIO peripheral target address window. -* -* INPUT: -* winNum - AUDIO target address decode window number. -* -* OUTPUT: -* pAddrDecWin - AUDIO target window data structure. -* -* RETURN: -* MV_ERROR if register parameters are invalid. -* -*******************************************************************************/ -MV_STATUS mvAudioWinGet(MV_U32 winNum, MV_AUDIO_DEC_WIN *pAddrDecWin) -{ - MV_DEC_REGS decRegs; - MV_TARGET_ATTRIB targetAttrib; - - /* Parameter checking */ - if (winNum >= MV_AUDIO_MAX_ADDR_DECODE_WIN) - { - mvOsPrintf("%s : ERR. Invalid winNum %d\n", - __FUNCTION__, winNum); - return MV_NOT_SUPPORTED; - } - - decRegs.baseReg = MV_REG_READ( MV_AUDIO_WIN_BASE_REG(winNum) ); - decRegs.sizeReg = MV_REG_READ( MV_AUDIO_WIN_CTRL_REG(winNum) ); - - if (MV_OK != mvCtrlRegToAddrDec(&decRegs, &pAddrDecWin->addrWin) ) - { - mvOsPrintf("%s: mvCtrlRegToAddrDec Failed\n", __FUNCTION__); - return MV_ERROR; - } - - /* attrib and targetId */ - targetAttrib.attrib = (decRegs.sizeReg & MV_AUDIO_WIN_ATTR_MASK) >> - MV_AUDIO_WIN_ATTR_OFFSET; - targetAttrib.targetId = (decRegs.sizeReg & MV_AUDIO_WIN_TARGET_MASK) >> - MV_AUDIO_WIN_TARGET_OFFSET; - - pAddrDecWin->target = mvCtrlTargetGet(&targetAttrib); - - /* Check if window is enabled */ - if(decRegs.sizeReg & MV_AUDIO_WIN_ENABLE_MASK) - { - pAddrDecWin->enable = MV_TRUE; - } - else - { - pAddrDecWin->enable = MV_FALSE; - } - return MV_OK; -} -/******************************************************************************* -* mvAudioAddrDecShow - Print the AUDIO address decode map. -* -* DESCRIPTION: -* This function print the AUDIO address decode map. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_VOID mvAudioAddrDecShow(MV_VOID) -{ - - MV_AUDIO_DEC_WIN win; - int i; - - if (MV_FALSE == mvCtrlPwrClckGet(AUDIO_UNIT_ID, 0)) - return; - - - mvOsOutput( "\n" ); - mvOsOutput( "AUDIO:\n" ); - mvOsOutput( "----\n" ); - - for( i = 0; i < MV_AUDIO_MAX_ADDR_DECODE_WIN; i++ ) - { - memset( &win, 0, sizeof(MV_AUDIO_DEC_WIN) ); - - mvOsOutput( "win%d - ", i ); - - if( mvAudioWinGet( i, &win ) == MV_OK ) - { - if( win.enable ) - { - mvOsOutput( "%s base %08x, ", - mvCtrlTargetNameGet(win.target), win.addrWin.baseLow ); - mvOsOutput( "...." ); - - mvSizePrint( win.addrWin.size ); - - mvOsOutput( "\n" ); - } - else - mvOsOutput( "disable\n" ); - } - } -} - - -/******************************************************************************* -* mvAudioWinInit - Initialize the integrated AUDIO target address window. -* -* DESCRIPTION: -* Initialize the AUDIO peripheral target address window. -* -* INPUT: -* -* -* OUTPUT: -* -* -* RETURN: -* MV_ERROR if register parameters are invalid. -* -*******************************************************************************/ -MV_STATUS mvAudioInit(MV_VOID) -{ - int winNum; - MV_AUDIO_DEC_WIN audioWin; - MV_CPU_DEC_WIN cpuAddrDecWin; - MV_U32 status; - - mvAudioHalInit(); - - /* Initiate Audio address decode */ - - /* First disable all address decode windows */ - for(winNum = 0; winNum < MV_AUDIO_MAX_ADDR_DECODE_WIN; winNum++) - { - MV_U32 regVal = MV_REG_READ(MV_AUDIO_WIN_CTRL_REG(winNum)); - regVal &= ~MV_AUDIO_WIN_ENABLE_MASK; - MV_REG_WRITE(MV_AUDIO_WIN_CTRL_REG(winNum), regVal); - } - - for(winNum = 0; winNum < MV_AUDIO_MAX_ADDR_DECODE_WIN; winNum++) - { - - /* We will set the Window to DRAM_CS0 in default */ - /* first get attributes from CPU If */ - status = mvCpuIfTargetWinGet(SDRAM_CS0, - &cpuAddrDecWin); - - if (MV_OK != status) - { - mvOsPrintf("%s: ERR. mvCpuIfTargetWinGet failed\n", __FUNCTION__); - return MV_ERROR; - } - - if (cpuAddrDecWin.enable == MV_TRUE) - { - audioWin.addrWin.baseHigh = cpuAddrDecWin.addrWin.baseHigh; - audioWin.addrWin.baseLow = cpuAddrDecWin.addrWin.baseLow; - audioWin.addrWin.size = cpuAddrDecWin.addrWin.size; - audioWin.enable = MV_TRUE; - audioWin.target = SDRAM_CS0; - - if(MV_OK != mvAudioWinSet(winNum, &audioWin)) - { - return MV_ERROR; - } - } - } - - return MV_OK; -} - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysAudio.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysAudio.h deleted file mode 100644 index f59eb9a..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysAudio.h +++ /dev/null @@ -1,123 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ -#ifndef __INCMVSysAudioH -#define __INCMVSysAudioH - -#include "mvCommon.h" -#include "audio/mvAudio.h" -#include "ctrlEnv/mvCtrlEnvSpec.h" -#include "ctrlEnv/sys/mvCpuIf.h" - -/***********************************/ -/* Audio Address Decoding registers*/ -/***********************************/ - -#define MV_AUDIO_MAX_ADDR_DECODE_WIN 2 -#define MV_AUDIO_RECORD_WIN_NUM 0 -#define MV_AUDIO_PLAYBACK_WIN_NUM 1 - -#define MV_AUDIO_WIN_CTRL_REG(win) (AUDIO_REG_BASE + 0xA04 + ((win)<<3)) -#define MV_AUDIO_WIN_BASE_REG(win) (AUDIO_REG_BASE + 0xA00 + ((win)<<3)) - -#define MV_AUDIO_RECORD_WIN_CTRL_REG MV_AUDIO_WIN_CTRL_REG(MV_AUDIO_RECORD_WIN_NUM) -#define MV_AUDIO_RECORD_WIN_BASE_REG MV_AUDIO_WIN_BASE_REG(MV_AUDIO_RECORD_WIN_NUM) -#define MV_AUDIO_PLAYBACK_WIN_CTRL_REG MV_AUDIO_WIN_CTRL_REG(MV_AUDIO_PLAYBACK_WIN_NUM) -#define MV_AUDIO_PLAYBACK_WIN_BASE_REG MV_AUDIO_WIN_BASE_REG(MV_AUDIO_PLAYBACK_WIN_NUM) - - -/* BITs in Windows 0-3 Control and Base Registers */ -#define MV_AUDIO_WIN_ENABLE_BIT 0 -#define MV_AUDIO_WIN_ENABLE_MASK (1<<MV_AUDIO_WIN_ENABLE_BIT) - -#define MV_AUDIO_WIN_TARGET_OFFSET 4 -#define MV_AUDIO_WIN_TARGET_MASK (0xF<<MV_AUDIO_WIN_TARGET_OFFSET) - -#define MV_AUDIO_WIN_ATTR_OFFSET 8 -#define MV_AUDIO_WIN_ATTR_MASK (0xFF<<MV_AUDIO_WIN_ATTR_OFFSET) - -#define MV_AUDIO_WIN_SIZE_OFFSET 16 -#define MV_AUDIO_WIN_SIZE_MASK (0xFFFF<<MV_AUDIO_WIN_SIZE_OFFSET) - -#define MV_AUDIO_WIN_BASE_OFFSET 16 -#define MV_AUDIO_WIN_BASE_MASK (0xFFFF<<MV_AUDIO_WIN_BASE_OFFSET) - - -typedef struct _mvAudioDecWin -{ - MV_TARGET target; - MV_ADDR_WIN addrWin; /* An address window*/ - MV_BOOL enable; /* Address decode window is enabled/disabled */ - -} MV_AUDIO_DEC_WIN; - - -MV_STATUS mvAudioInit(MV_VOID); -MV_STATUS mvAudioWinGet(MV_U32 winNum, MV_AUDIO_DEC_WIN *pAddrDecWin); -MV_STATUS mvAudioWinSet(MV_U32 winNum, MV_AUDIO_DEC_WIN *pAddrDecWin); -MV_STATUS mvAudioWinInit(MV_VOID); -MV_VOID mvAudioAddrDecShow(MV_VOID); - - -#endif - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysCesa.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysCesa.c deleted file mode 100644 index 84d0cd0..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysCesa.c +++ /dev/null @@ -1,382 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#include "mvSysCesa.h" - -#if (MV_CESA_VERSION >= 2) -MV_TARGET tdmaAddrDecPrioTable[] = -{ -#if defined(MV_INCLUDE_SDRAM_CS0) - SDRAM_CS0, -#endif -#if defined(MV_INCLUDE_SDRAM_CS1) - SDRAM_CS1, -#endif -#if defined(MV_INCLUDE_SDRAM_CS2) - SDRAM_CS2, -#endif -#if defined(MV_INCLUDE_SDRAM_CS3) - SDRAM_CS3, -#endif -#if defined(MV_INCLUDE_PEX) - PEX0_MEM, -#endif - - TBL_TERM -}; - -/******************************************************************************* -* mvCesaWinGet - Get TDMA target address window. -* -* DESCRIPTION: -* Get TDMA target address window. -* -* INPUT: -* winNum - TDMA target address decode window number. -* -* OUTPUT: -* pDecWin - TDMA target window data structure. -* -* RETURN: -* MV_ERROR if register parameters are invalid. -* -*******************************************************************************/ -static MV_STATUS mvCesaWinGet(MV_U32 winNum, MV_DEC_WIN *pDecWin) -{ - MV_DEC_WIN_PARAMS winParam; - MV_U32 sizeReg, baseReg; - - /* Parameter checking */ - if (winNum >= MV_CESA_TDMA_ADDR_DEC_WIN) - { - mvOsPrintf("%s : ERR. Invalid winNum %d\n", - __FUNCTION__, winNum); - return MV_NOT_SUPPORTED; - } - - baseReg = MV_REG_READ( MV_CESA_TDMA_BASE_ADDR_REG(winNum) ); - sizeReg = MV_REG_READ( MV_CESA_TDMA_WIN_CTRL_REG(winNum) ); - - /* Check if window is enabled */ - if(sizeReg & MV_CESA_TDMA_WIN_ENABLE_MASK) - { - pDecWin->enable = MV_TRUE; - - /* Extract window parameters from registers */ - winParam.targetId = (sizeReg & MV_CESA_TDMA_WIN_TARGET_MASK) >> MV_CESA_TDMA_WIN_TARGET_OFFSET; - winParam.attrib = (sizeReg & MV_CESA_TDMA_WIN_ATTR_MASK) >> MV_CESA_TDMA_WIN_ATTR_OFFSET; - winParam.size = (sizeReg & MV_CESA_TDMA_WIN_SIZE_MASK) >> MV_CESA_TDMA_WIN_SIZE_OFFSET; - winParam.baseAddr = (baseReg & MV_CESA_TDMA_WIN_BASE_MASK); - - /* Translate the decode window parameters to address decode struct */ - if (MV_OK != mvCtrlParamsToAddrDec(&winParam, pDecWin)) - { - mvOsPrintf("Failed to translate register parameters to CESA address" \ - " decode window structure\n"); - return MV_ERROR; - } - } - else - { - pDecWin->enable = MV_FALSE; - } - return MV_OK; -} - -/******************************************************************************* -* cesaWinOverlapDetect - Detect CESA TDMA address windows overlapping -* -* DESCRIPTION: -* An unpredicted behaviur is expected in case TDMA address decode -* windows overlapps. -* This function detects TDMA address decode windows overlapping of a -* specified window. The function does not check the window itself for -* overlapping. The function also skipps disabled address decode windows. -* -* INPUT: -* winNum - address decode window number. -* pAddrDecWin - An address decode window struct. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_TRUE - if the given address window overlap current address -* decode map, -* MV_FALSE - otherwise, MV_ERROR if reading invalid data -* from registers. -* -*******************************************************************************/ -static MV_STATUS cesaWinOverlapDetect(MV_U32 winNum, MV_ADDR_WIN *pAddrWin) -{ - MV_U32 winNumIndex; - MV_DEC_WIN addrDecWin; - - for(winNumIndex=0; winNumIndex<MV_CESA_TDMA_ADDR_DEC_WIN; winNumIndex++) - { - /* Do not check window itself */ - if (winNumIndex == winNum) - { - continue; - } - - /* Get window parameters */ - if (MV_OK != mvCesaWinGet(winNumIndex, &addrDecWin)) - { - mvOsPrintf("%s: ERR. TargetWinGet failed\n", __FUNCTION__); - return MV_ERROR; - } - - /* Do not check disabled windows */ - if(addrDecWin.enable == MV_FALSE) - { - continue; - } - - if (MV_TRUE == ctrlWinOverlapTest(pAddrWin, &(addrDecWin.addrWin))) - { - return MV_TRUE; - } - } - return MV_FALSE; -} - -/******************************************************************************* -* mvCesaTdmaWinSet - Set CESA TDMA target address window -* -* DESCRIPTION: -* This function sets a peripheral target (e.g. SDRAM bank0, PCI_MEM0) -* address window, also known as address decode window. -* After setting this target window, the CESA TDMA will be able to access the -* target within the address window. -* -* INPUT: -* winNum - CESA TDMA target address decode window number. -* pAddrDecWin - CESA TDMA target window data structure. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_ERROR - if address window overlapps with other address decode windows. -* MV_BAD_PARAM - if base address is invalid parameter or target is -* unknown. -* -*******************************************************************************/ -static MV_STATUS mvCesaTdmaWinSet(MV_U32 winNum, MV_DEC_WIN *pDecWin) -{ - MV_DEC_WIN_PARAMS winParams; - MV_U32 sizeReg, baseReg; - - /* Parameter checking */ - if (winNum >= MV_CESA_TDMA_ADDR_DEC_WIN) - { - mvOsPrintf("mvCesaTdmaWinSet: ERR. Invalid win num %d\n",winNum); - return MV_BAD_PARAM; - } - - /* Check if the requested window overlapps with current windows */ - if (MV_TRUE == cesaWinOverlapDetect(winNum, &pDecWin->addrWin)) - { - mvOsPrintf("%s: ERR. Window %d overlap\n", __FUNCTION__, winNum); - return MV_ERROR; - } - - /* check if address is aligned to the size */ - if(MV_IS_NOT_ALIGN(pDecWin->addrWin.baseLow, pDecWin->addrWin.size)) - { - mvOsPrintf("mvCesaTdmaWinSet: Error setting CESA TDMA window %d to "\ - "target %s.\nAddress 0x%08x is unaligned to size 0x%x.\n", - winNum, - mvCtrlTargetNameGet(pDecWin->target), - pDecWin->addrWin.baseLow, - pDecWin->addrWin.size); - return MV_ERROR; - } - - if(MV_OK != mvCtrlAddrDecToParams(pDecWin, &winParams)) - { - mvOsPrintf("%s: mvCtrlAddrDecToParams Failed\n", __FUNCTION__); - return MV_ERROR; - } - - /* set Size, Attributes and TargetID */ - sizeReg = (((winParams.targetId << MV_CESA_TDMA_WIN_TARGET_OFFSET) & MV_CESA_TDMA_WIN_TARGET_MASK) | - ((winParams.attrib << MV_CESA_TDMA_WIN_ATTR_OFFSET) & MV_CESA_TDMA_WIN_ATTR_MASK) | - ((winParams.size << MV_CESA_TDMA_WIN_SIZE_OFFSET) & MV_CESA_TDMA_WIN_SIZE_MASK)); - - if (pDecWin->enable == MV_TRUE) - { - sizeReg |= MV_CESA_TDMA_WIN_ENABLE_MASK; - } - else - { - sizeReg &= ~MV_CESA_TDMA_WIN_ENABLE_MASK; - } - - /* Update Base value */ - baseReg = (winParams.baseAddr & MV_CESA_TDMA_WIN_BASE_MASK); - - MV_REG_WRITE( MV_CESA_TDMA_WIN_CTRL_REG(winNum), sizeReg); - MV_REG_WRITE( MV_CESA_TDMA_BASE_ADDR_REG(winNum), baseReg); - - return MV_OK; -} - - -static MV_STATUS mvCesaTdmaAddrDecInit (void) -{ - MV_U32 winNum; - MV_STATUS status; - MV_CPU_DEC_WIN cpuAddrDecWin; - MV_DEC_WIN cesaWin; - MV_U32 winPrioIndex = 0; - - /* First disable all address decode windows */ - for(winNum=0; winNum<MV_CESA_TDMA_ADDR_DEC_WIN; winNum++) - { - MV_REG_BIT_RESET(MV_CESA_TDMA_WIN_CTRL_REG(winNum), MV_CESA_TDMA_WIN_ENABLE_MASK); - } - - /* Go through all windows in user table until table terminator */ - winNum = 0; - while( (tdmaAddrDecPrioTable[winPrioIndex] != TBL_TERM) && - (winNum < MV_CESA_TDMA_ADDR_DEC_WIN) ) { - - /* first get attributes from CPU If */ - status = mvCpuIfTargetWinGet(tdmaAddrDecPrioTable[winPrioIndex], - &cpuAddrDecWin); - if(MV_NO_SUCH == status){ - winPrioIndex++; - continue; - } - - if (MV_OK != status) - { - mvOsPrintf("cesaInit: TargetWinGet failed. winNum=%d, winIdx=%d, target=%d, status=0x%x\n", - winNum, winPrioIndex, tdmaAddrDecPrioTable[winPrioIndex], status); - return MV_ERROR; - } - if (cpuAddrDecWin.enable == MV_TRUE) - { - cesaWin.addrWin.baseHigh = cpuAddrDecWin.addrWin.baseHigh; - cesaWin.addrWin.baseLow = cpuAddrDecWin.addrWin.baseLow; - cesaWin.addrWin.size = cpuAddrDecWin.addrWin.size; - cesaWin.enable = MV_TRUE; - cesaWin.target = tdmaAddrDecPrioTable[winPrioIndex]; - -#if defined(MV646xx) - /* Get the default attributes for that target window */ - mvCtrlDefAttribGet(cesaWin.target, &cesaWin.addrWinAttr); -#endif /* MV646xx */ - - if(MV_OK != mvCesaTdmaWinSet(winNum, &cesaWin)) - { - mvOsPrintf("mvCesaTdmaWinSet FAILED: winNum=%d\n", - winNum); - return MV_ERROR; - } - winNum++; - } - winPrioIndex++; - } - return MV_OK; -} -#endif /* MV_CESA_VERSION >= 2 */ - - - - -MV_STATUS mvCesaInit (int numOfSession, int queueDepth, char* pSramBase, void *osHandle) -{ - MV_U32 cesaCryptEngBase; - MV_CPU_DEC_WIN addrDecWin; - - if(sizeof(MV_CESA_SRAM_MAP) > MV_CESA_SRAM_SIZE) - { - mvOsPrintf("mvCesaInit: Wrong SRAM map - %ld > %d\n", - sizeof(MV_CESA_SRAM_MAP), MV_CESA_SRAM_SIZE); - return MV_FAIL; - } -#if 0 - if (mvCpuIfTargetWinGet(CRYPT_ENG, &addrDecWin) == MV_OK) - cesaCryptEngBase = addrDecWin.addrWin.baseLow; - else - { - mvOsPrintf("mvCesaInit: ERR. mvCpuIfTargetWinGet failed\n"); - return MV_ERROR; - } -#else - cesaCryptEngBase = (MV_U32)pSramBase; -#endif - -#if 0 /* Already done in the platform init */ -#if (MV_CESA_VERSION >= 2) - mvCesaTdmaAddrDecInit(); -#endif /* MV_CESA_VERSION >= 2 */ -#endif - return mvCesaHalInit(numOfSession, queueDepth, pSramBase, cesaCryptEngBase, - osHandle); - -} diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysCesa.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysCesa.h deleted file mode 100644 index 73bcdc5..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysCesa.h +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __mvSysCesa_h__ -#define __mvSysCesa_h__ - - -#include "mvCommon.h" -#include "cesa/mvCesa.h" -#include "ctrlEnv/mvCtrlEnvSpec.h" -#include "ctrlEnv/sys/mvCpuIf.h" - -/***************************** TDMA Registers *************************************/ - -#define MV_CESA_TDMA_ADDR_DEC_WIN 4 - -#define MV_CESA_TDMA_BASE_ADDR_REG(win) (MV_CESA_TDMA_REG_BASE + 0xa00 + (win<<3)) - -#define MV_CESA_TDMA_WIN_CTRL_REG(win) (MV_CESA_TDMA_REG_BASE + 0xa04 + (win<<3)) - -#define MV_CESA_TDMA_WIN_ENABLE_BIT 0 -#define MV_CESA_TDMA_WIN_ENABLE_MASK (1 << MV_CESA_TDMA_WIN_ENABLE_BIT) - -#define MV_CESA_TDMA_WIN_TARGET_OFFSET 4 -#define MV_CESA_TDMA_WIN_TARGET_MASK (0xf << MV_CESA_TDMA_WIN_TARGET_OFFSET) - -#define MV_CESA_TDMA_WIN_ATTR_OFFSET 8 -#define MV_CESA_TDMA_WIN_ATTR_MASK (0xff << MV_CESA_TDMA_WIN_ATTR_OFFSET) - -#define MV_CESA_TDMA_WIN_SIZE_OFFSET 16 -#define MV_CESA_TDMA_WIN_SIZE_MASK (0xFFFF << MV_CESA_TDMA_WIN_SIZE_OFFSET) - -#define MV_CESA_TDMA_WIN_BASE_OFFSET 16 -#define MV_CESA_TDMA_WIN_BASE_MASK (0xFFFF << MV_CESA_TDMA_WIN_BASE_OFFSET) - - -MV_STATUS mvCesaInit (int numOfSession, int queueDepth, char* pSramBase, void *osHandle); - -#endif diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysDram.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysDram.c deleted file mode 100644 index 6f76c2c..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysDram.c +++ /dev/null @@ -1,348 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -/* includes */ - -#include "ddr2/mvDramIf.h" -#include "ctrlEnv/sys/mvCpuIf.h" -#include "ctrlEnv/sys/mvSysDram.h" - -/* #define MV_DEBUG */ -#ifdef MV_DEBUG -#define DB(x) x -#else -#define DB(x) -#endif - -static MV_BOOL sdramIfWinOverlap(MV_TARGET target, MV_ADDR_WIN *pAddrWin); - -/******************************************************************************* -* mvDramIfWinSet - Set DRAM interface address decode window -* -* DESCRIPTION: -* This function sets DRAM interface address decode window. -* -* INPUT: -* target - System target. Use only SDRAM targets. -* pAddrDecWin - SDRAM address window structure. -* -* OUTPUT: -* None -* -* RETURN: -* MV_BAD_PARAM if parameters are invalid or window is invalid, MV_OK -* otherwise. -*******************************************************************************/ -MV_STATUS mvDramIfWinSet(MV_TARGET target, MV_DRAM_DEC_WIN *pAddrDecWin) -{ - MV_U32 baseReg=0,sizeReg=0; - MV_U32 baseToReg=0 , sizeToReg=0; - - /* Check parameters */ - if (!MV_TARGET_IS_DRAM(target)) - { - mvOsPrintf("mvDramIfWinSet: target %d is not SDRAM\n", target); - return MV_BAD_PARAM; - } - - /* Check if the requested window overlaps with current enabled windows */ - if (MV_TRUE == sdramIfWinOverlap(target, &pAddrDecWin->addrWin)) - { - mvOsPrintf("mvDramIfWinSet: ERR. Target %d overlaps\n", target); - return MV_BAD_PARAM; - } - - /* check if address is aligned to the size */ - if(MV_IS_NOT_ALIGN(pAddrDecWin->addrWin.baseLow, pAddrDecWin->addrWin.size)) - { - mvOsPrintf("mvDramIfWinSet:Error setting DRAM interface window %d."\ - "\nAddress 0x%08x is unaligned to size 0x%x.\n", - target, - pAddrDecWin->addrWin.baseLow, - pAddrDecWin->addrWin.size); - return MV_ERROR; - } - - /* read base register*/ - baseReg = MV_REG_READ(SDRAM_BASE_ADDR_REG(0,target)); - - /* read size register */ - sizeReg = MV_REG_READ(SDRAM_SIZE_REG(0,target)); - - /* BaseLow[31:16] => base register [31:16] */ - baseToReg = pAddrDecWin->addrWin.baseLow & SCBAR_BASE_MASK; - - /* Write to address decode Base Address Register */ - baseReg &= ~SCBAR_BASE_MASK; - baseReg |= baseToReg; - - /* Translate the given window size to register format */ - sizeToReg = ctrlSizeToReg(pAddrDecWin->addrWin.size, SCSR_SIZE_ALIGNMENT); - - /* Size parameter validity check. */ - if (-1 == sizeToReg) - { - mvOsPrintf("mvCtrlAddrDecToReg: ERR. Win %d size invalid.\n",target); - return MV_BAD_PARAM; - } - - /* set size */ - sizeReg &= ~SCSR_SIZE_MASK; - /* Size is located at upper 16 bits */ - sizeReg |= (sizeToReg << SCSR_SIZE_OFFS); - - /* enable/Disable */ - if (MV_TRUE == pAddrDecWin->enable) - { - sizeReg |= SCSR_WIN_EN; - } - else - { - sizeReg &= ~SCSR_WIN_EN; - } - - /* 3) Write to address decode Base Address Register */ - MV_REG_WRITE(SDRAM_BASE_ADDR_REG(0,target), baseReg); - - /* Write to address decode Size Register */ - MV_REG_WRITE(SDRAM_SIZE_REG(0,target), sizeReg); - - return MV_OK; -} -/******************************************************************************* -* mvDramIfWinGet - Get DRAM interface address decode window -* -* DESCRIPTION: -* This function gets DRAM interface address decode window. -* -* INPUT: -* target - System target. Use only SDRAM targets. -* -* OUTPUT: -* pAddrDecWin - SDRAM address window structure. -* -* RETURN: -* MV_BAD_PARAM if parameters are invalid or window is invalid, MV_OK -* otherwise. -*******************************************************************************/ -MV_STATUS mvDramIfWinGet(MV_TARGET target, MV_DRAM_DEC_WIN *pAddrDecWin) -{ - MV_U32 baseReg,sizeReg; - MV_U32 sizeRegVal; - /* Check parameters */ - if (!MV_TARGET_IS_DRAM(target)) - { - mvOsPrintf("mvDramIfWinGet: target %d is Illigal\n", target); - return MV_ERROR; - } - - /* Read base and size registers */ - sizeReg = MV_REG_READ(SDRAM_SIZE_REG(0,target)); - baseReg = MV_REG_READ(SDRAM_BASE_ADDR_REG(0,target)); - - sizeRegVal = (sizeReg & SCSR_SIZE_MASK) >> SCSR_SIZE_OFFS; - - pAddrDecWin->addrWin.size = ctrlRegToSize(sizeRegVal, - SCSR_SIZE_ALIGNMENT); - - /* Check if ctrlRegToSize returned OK */ - if (-1 == pAddrDecWin->addrWin.size) - { - mvOsPrintf("mvDramIfWinGet: size of target %d is Illigal\n", target); - return MV_ERROR; - } - - /* Extract base address */ - /* Base register [31:16] ==> baseLow[31:16] */ - pAddrDecWin->addrWin.baseLow = baseReg & SCBAR_BASE_MASK; - - pAddrDecWin->addrWin.baseHigh = 0; - - - if (sizeReg & SCSR_WIN_EN) - { - pAddrDecWin->enable = MV_TRUE; - } - else - { - pAddrDecWin->enable = MV_FALSE; - } - - return MV_OK; -} -/******************************************************************************* -* mvDramIfWinEnable - Enable/Disable SDRAM address decode window -* -* DESCRIPTION: -* This function enable/Disable SDRAM address decode window. -* -* INPUT: -* target - System target. Use only SDRAM targets. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_ERROR in case function parameter are invalid, MV_OK otherewise. -* -*******************************************************************************/ -MV_STATUS mvDramIfWinEnable(MV_TARGET target, MV_BOOL enable) -{ - MV_DRAM_DEC_WIN addrDecWin; - - /* Check parameters */ - if (!MV_TARGET_IS_DRAM(target)) - { - mvOsPrintf("mvDramIfWinEnable: target %d is Illigal\n", target); - return MV_ERROR; - } - - if (enable == MV_TRUE) - { /* First check for overlap with other enabled windows */ - if (MV_OK != mvDramIfWinGet(target, &addrDecWin)) - { - mvOsPrintf("mvDramIfWinEnable:ERR. Getting target %d failed.\n", - target); - return MV_ERROR; - } - /* Check for overlapping */ - if (MV_FALSE == sdramIfWinOverlap(target, &(addrDecWin.addrWin))) - { - /* No Overlap. Enable address decode winNum window */ - MV_REG_BIT_SET(SDRAM_SIZE_REG(0,target), SCSR_WIN_EN); - } - else - { /* Overlap detected */ - mvOsPrintf("mvDramIfWinEnable: ERR. Target %d overlap detect\n", - target); - return MV_ERROR; - } - } - else - { /* Disable address decode winNum window */ - MV_REG_BIT_RESET(SDRAM_SIZE_REG(0, target), SCSR_WIN_EN); - } - - return MV_OK; -} - -/******************************************************************************* -* sdramIfWinOverlap - Check if an address window overlap an SDRAM address window -* -* DESCRIPTION: -* This function scan each SDRAM address decode window to test if it -* overlapps the given address windoow -* -* INPUT: -* target - SDRAM target where the function skips checking. -* pAddrDecWin - The tested address window for overlapping with -* SDRAM windows. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_TRUE if the given address window overlaps any enabled address -* decode map, MV_FALSE otherwise. -* -*******************************************************************************/ -static MV_BOOL sdramIfWinOverlap(MV_TARGET target, MV_ADDR_WIN *pAddrWin) -{ - MV_TARGET targetNum; - MV_DRAM_DEC_WIN addrDecWin; - - for(targetNum = SDRAM_CS0; targetNum < MV_DRAM_MAX_CS ; targetNum++) - { - /* don't check our winNum or illegal targets */ - if (targetNum == target) - { - continue; - } - - /* Get window parameters */ - if (MV_OK != mvDramIfWinGet(targetNum, &addrDecWin)) - { - mvOsPrintf("sdramIfWinOverlap: ERR. TargetWinGet failed\n"); - return MV_ERROR; - } - - /* Do not check disabled windows */ - if (MV_FALSE == addrDecWin.enable) - { - continue; - } - - if(MV_TRUE == ctrlWinOverlapTest(pAddrWin, &addrDecWin.addrWin)) - { - mvOsPrintf( - "sdramIfWinOverlap: Required target %d overlap winNum %d\n", - target, targetNum); - return MV_TRUE; - } - } - - return MV_FALSE; -} - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysDram.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysDram.h deleted file mode 100644 index 7bd9c9d..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysDram.h +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -#ifndef __sysDram -#define __sysDram - -/* This structure describes CPU interface address decode window */ -typedef struct _mvDramIfDecWin -{ - MV_ADDR_WIN addrWin; /* An address window*/ - MV_BOOL enable; /* Address decode window is enabled/disabled */ -}MV_DRAM_DEC_WIN; - -MV_STATUS mvDramIfWinSet(MV_TARGET target, MV_DRAM_DEC_WIN *pAddrDecWin); -MV_STATUS mvDramIfWinGet(MV_TARGET target, MV_DRAM_DEC_WIN *pAddrDecWin); -MV_STATUS mvDramIfWinEnable(MV_TARGET target, MV_BOOL enable); - -#endif diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysGbe.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysGbe.c deleted file mode 100644 index 7f6e4a5..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysGbe.c +++ /dev/null @@ -1,658 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -#include "ctrlEnv/sys/mvSysGbe.h" - - - -typedef struct _mvEthDecWin -{ - MV_TARGET target; - MV_ADDR_WIN addrWin; /* An address window*/ - MV_BOOL enable; /* Address decode window is enabled/disabled */ - -}MV_ETH_DEC_WIN; - -MV_TARGET ethAddrDecPrioTap[] = -{ -#if defined(MV_INCLUDE_SDRAM_CS0) - SDRAM_CS0, -#endif -#if defined(MV_INCLUDE_SDRAM_CS1) - SDRAM_CS1, -#endif -#if defined(MV_INCLUDE_SDRAM_CS2) - SDRAM_CS2, -#endif -#if defined(MV_INCLUDE_SDRAM_CS3) - SDRAM_CS3, -#endif -#if defined(MV_INCLUDE_DEVICE_CS0) - DEVICE_CS0, -#endif -#if defined(MV_INCLUDE_DEVICE_CS1) - DEVICE_CS1, -#endif -#if defined(MV_INCLUDE_DEVICE_CS2) - DEVICE_CS2, -#endif -#if defined(MV_INCLUDE_DEVICE_CS3) - DEVICE_CS3, -#endif -#if defined(MV_INCLUDE_PEX) - PEX0_IO, -#endif - TBL_TERM -}; - -static MV_STATUS ethWinOverlapDetect(int port, MV_U32 winNum, MV_ADDR_WIN *pAddrWin); -static MV_STATUS mvEthWinSet(int port, MV_U32 winNum, MV_ETH_DEC_WIN *pAddrDecWin); -static MV_STATUS mvEthWinGet(int port, MV_U32 winNum, MV_ETH_DEC_WIN *pAddrDecWin); - - -/******************************************************************************* -* mvEthWinInit - Initialize ETH address decode windows -* -* DESCRIPTION: -* This function initialize ETH window decode unit. It set the -* default address decode windows of the unit. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_ERROR if setting fail. -*******************************************************************************/ -/* Configure EthDrv memory map registes. */ -MV_STATUS mvEthWinInit (int port) -{ - MV_U32 winNum, status, winPrioIndex=0, i, regVal=0; - MV_ETH_DEC_WIN ethWin; - MV_CPU_DEC_WIN cpuAddrDecWin; - static MV_U32 accessProtReg = 0; - -#if (MV_ETH_VERSION <= 1) - static MV_BOOL isFirst = MV_TRUE; - - if(isFirst == MV_FALSE) - { - MV_REG_WRITE(ETH_ACCESS_PROTECT_REG(port), accessProtReg); - return MV_OK; - } - isFirst = MV_FALSE; -#endif /* MV_GIGA_ETH_VERSION */ - - /* Initiate Ethernet address decode */ - - /* First disable all address decode windows */ - for(winNum=0; winNum<ETH_MAX_DECODE_WIN; winNum++) - { - regVal |= MV_BIT_MASK(winNum); - } - MV_REG_WRITE(ETH_BASE_ADDR_ENABLE_REG(port), regVal); - - /* Go through all windows in user table until table terminator */ - for (winNum=0; ((ethAddrDecPrioTap[winPrioIndex] != TBL_TERM) && - (winNum < ETH_MAX_DECODE_WIN)); ) - { - /* first get attributes from CPU If */ - status = mvCpuIfTargetWinGet(ethAddrDecPrioTap[winPrioIndex], - &cpuAddrDecWin); - - if(MV_NO_SUCH == status) - { - winPrioIndex++; - continue; - } - if (MV_OK != status) - { - mvOsPrintf("mvEthWinInit: ERR. mvCpuIfTargetWinGet failed\n"); - return MV_ERROR; - } - - if (cpuAddrDecWin.enable == MV_TRUE) - { - ethWin.addrWin.baseHigh = cpuAddrDecWin.addrWin.baseHigh; - ethWin.addrWin.baseLow = cpuAddrDecWin.addrWin.baseLow; - ethWin.addrWin.size = cpuAddrDecWin.addrWin.size; - ethWin.enable = MV_TRUE; - ethWin.target = ethAddrDecPrioTap[winPrioIndex]; - - if(MV_OK != mvEthWinSet(port, winNum, ðWin)) - { - mvOsPrintf("mvEthWinInit: ERR. mvEthWinSet failed winNum=%d\n", - winNum); - return MV_ERROR; - } - winNum++; - } - winPrioIndex ++; - } - - /* set full access to all windows. */ - for(i=0; i<winNum; i++) - { - accessProtReg |= (FULL_ACCESS << (i*2)); - } - MV_REG_WRITE(ETH_ACCESS_PROTECT_REG(port), accessProtReg); - - return MV_OK; -} - -/******************************************************************************* -* mvEthWinSet - Set ETH target address window -* -* DESCRIPTION: -* This function sets a peripheral target (e.g. SDRAM bank0, PCI_MEM0) -* address window, also known as address decode window. -* After setting this target window, the ETH will be able to access the -* target within the address window. -* -* INPUT: -* winNum - ETH to target address decode window number. -* pAddrDecWin - ETH target window data structure. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_ERROR if address window overlapps with other address decode windows. -* MV_BAD_PARAM if base address is invalid parameter or target is -* unknown. -* -*******************************************************************************/ -MV_STATUS mvEthWinSet(int port, MV_U32 winNum, MV_ETH_DEC_WIN *pAddrDecWin) -{ - MV_TARGET_ATTRIB targetAttribs; - MV_DEC_REGS decRegs; - - /* Parameter checking */ - if (winNum >= ETH_MAX_DECODE_WIN) - { - mvOsPrintf("mvEthWinSet: ERR. Invalid win num %d\n",winNum); - return MV_BAD_PARAM; - } - - /* Check if the requested window overlapps with current windows */ - if (MV_TRUE == ethWinOverlapDetect(port, winNum, &pAddrDecWin->addrWin)) - { - mvOsPrintf("mvEthWinSet: ERR. Window %d overlap\n", winNum); - return MV_ERROR; - } - - /* check if address is aligned to the size */ - if(MV_IS_NOT_ALIGN(pAddrDecWin->addrWin.baseLow, pAddrDecWin->addrWin.size)) - { - mvOsPrintf("mvEthWinSet: Error setting Ethernet window %d to "\ - "target %s.\nAddress 0x%08x is unaligned to size 0x%x.\n", - winNum, - mvCtrlTargetNameGet(pAddrDecWin->target), - pAddrDecWin->addrWin.baseLow, - pAddrDecWin->addrWin.size); - return MV_ERROR; - } - - - decRegs.baseReg = MV_REG_READ(ETH_WIN_BASE_REG(port, winNum)); - decRegs.sizeReg = MV_REG_READ(ETH_WIN_SIZE_REG(port, winNum)); - - if (MV_OK != mvCtrlAddrDecToReg(&(pAddrDecWin->addrWin),&decRegs)) - { - mvOsPrintf("mvEthWinSet:mvCtrlAddrDecToReg Failed\n"); - return MV_ERROR; - } - - mvCtrlAttribGet(pAddrDecWin->target,&targetAttribs); - - /* set attributes */ - decRegs.baseReg &= ~ETH_WIN_ATTR_MASK; - decRegs.baseReg |= targetAttribs.attrib << ETH_WIN_ATTR_OFFS; - /* set target ID */ - decRegs.baseReg &= ~ETH_WIN_TARGET_MASK; - decRegs.baseReg |= targetAttribs.targetId << ETH_WIN_TARGET_OFFS; - - /* for the safe side we disable the window before writing the new - values */ - mvEthWinEnable(port, winNum, MV_FALSE); - MV_REG_WRITE(ETH_WIN_BASE_REG(port, winNum), decRegs.baseReg); - - /* Write to address decode Size Register */ - MV_REG_WRITE(ETH_WIN_SIZE_REG(port, winNum), decRegs.sizeReg); - - /* Enable address decode target window */ - if (pAddrDecWin->enable == MV_TRUE) - { - mvEthWinEnable(port, winNum, MV_TRUE); - } - - return MV_OK; -} - -/******************************************************************************* -* mvETHWinGet - Get dma peripheral target address window. -* -* DESCRIPTION: -* Get ETH peripheral target address window. -* -* INPUT: -* winNum - ETH to target address decode window number. -* -* OUTPUT: -* pAddrDecWin - ETH target window data structure. -* -* RETURN: -* MV_ERROR if register parameters are invalid. -* -*******************************************************************************/ -MV_STATUS mvEthWinGet(int port, MV_U32 winNum, MV_ETH_DEC_WIN *pAddrDecWin) -{ - MV_DEC_REGS decRegs; - MV_TARGET_ATTRIB targetAttrib; - - /* Parameter checking */ - if (winNum >= ETH_MAX_DECODE_WIN) - { - mvOsPrintf("mvEthWinGet: ERR. Invalid winNum %d\n", winNum); - return MV_NOT_SUPPORTED; - } - - decRegs.baseReg = MV_REG_READ(ETH_WIN_BASE_REG(port, winNum)); - decRegs.sizeReg = MV_REG_READ(ETH_WIN_SIZE_REG(port, winNum)); - - if (MV_OK != mvCtrlRegToAddrDec(&decRegs,&(pAddrDecWin->addrWin))) - { - mvOsPrintf("mvAhbToMbusWinGet: mvCtrlRegToAddrDec Failed \n"); - return MV_ERROR; - } - - /* attrib and targetId */ - targetAttrib.attrib = - (decRegs.baseReg & ETH_WIN_ATTR_MASK) >> ETH_WIN_ATTR_OFFS; - targetAttrib.targetId = - (decRegs.baseReg & ETH_WIN_TARGET_MASK) >> ETH_WIN_TARGET_OFFS; - - pAddrDecWin->target = mvCtrlTargetGet(&targetAttrib); - - /* Check if window is enabled */ - if (~(MV_REG_READ(ETH_BASE_ADDR_ENABLE_REG(port))) & (1 << winNum) ) - { - pAddrDecWin->enable = MV_TRUE; - } - else - { - pAddrDecWin->enable = MV_FALSE; - } - - return MV_OK; -} - -/******************************************************************************* -* mvEthWinEnable - Enable/disable a ETH to target address window -* -* DESCRIPTION: -* This function enable/disable a ETH to target address window. -* According to parameter 'enable' the routine will enable the -* window, thus enabling ETH accesses (before enabling the window it is -* tested for overlapping). Otherwise, the window will be disabled. -* -* INPUT: -* winNum - ETH to target address decode window number. -* enable - Enable/disable parameter. -* -* OUTPUT: -* N/A -* -* RETURN: -* MV_ERROR if decode window number was wrong or enabled window overlapps. -* -*******************************************************************************/ -MV_STATUS mvEthWinEnable(int port, MV_U32 winNum,MV_BOOL enable) -{ - MV_ETH_DEC_WIN addrDecWin; - - /* Parameter checking */ - if (winNum >= ETH_MAX_DECODE_WIN) - { - mvOsPrintf("mvEthTargetWinEnable:ERR. Invalid winNum%d\n",winNum); - return MV_ERROR; - } - - if (enable == MV_TRUE) - { /* First check for overlap with other enabled windows */ - /* Get current window */ - if (MV_OK != mvEthWinGet(port, winNum, &addrDecWin)) - { - mvOsPrintf("mvEthTargetWinEnable:ERR. targetWinGet fail\n"); - return MV_ERROR; - } - /* Check for overlapping */ - if (MV_FALSE == ethWinOverlapDetect(port, winNum, &(addrDecWin.addrWin))) - { - /* No Overlap. Enable address decode target window */ - MV_REG_BIT_RESET(ETH_BASE_ADDR_ENABLE_REG(port), (1 << winNum)); - } - else - { /* Overlap detected */ - mvOsPrintf("mvEthTargetWinEnable:ERR. Overlap detected\n"); - return MV_ERROR; - } - } - else - { /* Disable address decode target window */ - MV_REG_BIT_SET(ETH_BASE_ADDR_ENABLE_REG(port), (1 << winNum)); - } - return MV_OK; -} - -/******************************************************************************* -* mvEthWinTargetGet - Get Window number associated with target -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* -* RETURN: -* window number -* -*******************************************************************************/ -MV_U32 mvEthWinTargetGet(int port, MV_TARGET target) -{ - MV_ETH_DEC_WIN decWin; - MV_U32 winNum; - - /* Check parameters */ - if (target >= MAX_TARGETS) - { - mvOsPrintf("mvAhbToMbusWinTargetGet: target %d is Illigal\n", target); - return 0xffffffff; - } - - for (winNum=0; winNum<ETH_MAX_DECODE_WIN; winNum++) - { - if (mvEthWinGet(port, winNum,&decWin) != MV_OK) - { - mvOsPrintf("mvAhbToMbusWinTargetGet: window returned error\n"); - return 0xffffffff; - } - - if (decWin.enable == MV_TRUE) - { - if (decWin.target == target) - { - return winNum; - } - } - } - return 0xFFFFFFFF; -} - -/******************************************************************************* -* mvEthProtWinSet - Set access protection of Ethernet to target window. -* -* DESCRIPTION: -* Each Ethernet port can be configured with access attributes for each -* of the Ethenret to target windows (address decode windows). This -* function sets access attributes to a given window for the given channel. -* -* INPUTS: -* ethPort - ETH channel number. See MV_ETH_CHANNEL enumerator. -* winNum - IETH to target address decode window number. -* access - IETH access rights. See MV_ACCESS_RIGHTS enumerator. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_ERROR in case window number is invalid or access right reserved. -* -*******************************************************************************/ -MV_STATUS mvEthProtWinSet(MV_U32 portNo, MV_U32 winNum, MV_ACCESS_RIGHTS access) -{ - MV_U32 protReg; - - /* Parameter checking */ - if(portNo >= mvCtrlEthMaxPortGet()) - { - mvOsPrintf("mvEthProtWinSet:ERR. Invalid port number %d\n", portNo); - return MV_ERROR; - } - - if (winNum >= ETH_MAX_DECODE_WIN) - { - mvOsPrintf("mvEthProtWinSet:ERR. Invalid winNum%d\n",winNum); - return MV_ERROR; - } - - if((access == ACC_RESERVED) || (access >= MAX_ACC_RIGHTS)) - { - mvOsPrintf("mvEthProtWinSet:ERR. Inv access param %d\n", access); - return MV_ERROR; - } - /* Read current protection register */ - protReg = MV_REG_READ(ETH_ACCESS_PROTECT_REG(portNo)); - - /* Clear protection window field */ - protReg &= ~(ETH_PROT_WIN_MASK(winNum)); - - /* Set new protection field value */ - protReg |= (access << (ETH_PROT_WIN_OFFS(winNum))); - - /* Write protection register back */ - MV_REG_WRITE(ETH_ACCESS_PROTECT_REG(portNo), protReg); - - return MV_OK; -} - -/******************************************************************************* -* ethWinOverlapDetect - Detect ETH address windows overlapping -* -* DESCRIPTION: -* An unpredicted behaviur is expected in case ETH address decode -* windows overlapps. -* This function detects ETH address decode windows overlapping of a -* specified window. The function does not check the window itself for -* overlapping. The function also skipps disabled address decode windows. -* -* INPUT: -* winNum - address decode window number. -* pAddrDecWin - An address decode window struct. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_TRUE if the given address window overlap current address -* decode map, MV_FALSE otherwise, MV_ERROR if reading invalid data -* from registers. -* -*******************************************************************************/ -static MV_STATUS ethWinOverlapDetect(int port, MV_U32 winNum, MV_ADDR_WIN *pAddrWin) -{ - MV_U32 baseAddrEnableReg; - MV_U32 winNumIndex; - MV_ETH_DEC_WIN addrDecWin; - - /* Read base address enable register. Do not check disabled windows */ - baseAddrEnableReg = MV_REG_READ(ETH_BASE_ADDR_ENABLE_REG(port)); - - for (winNumIndex=0; winNumIndex<ETH_MAX_DECODE_WIN; winNumIndex++) - { - /* Do not check window itself */ - if (winNumIndex == winNum) - { - continue; - } - - /* Do not check disabled windows */ - if (baseAddrEnableReg & (1 << winNumIndex)) - { - continue; - } - - /* Get window parameters */ - if (MV_OK != mvEthWinGet(port, winNumIndex, &addrDecWin)) - { - mvOsPrintf("ethWinOverlapDetect: ERR. TargetWinGet failed\n"); - return MV_ERROR; - } -/* - mvOsPrintf("ethWinOverlapDetect:\n - winNumIndex =%d baseHigh =0x%x baseLow=0x%x size=0x%x enable=0x%x\n", - winNumIndex, - addrDecWin.addrWin.baseHigh, - addrDecWin.addrWin.baseLow, - addrDecWin.addrWin.size, - addrDecWin.enable); -*/ - if (MV_TRUE == ctrlWinOverlapTest(pAddrWin, &(addrDecWin.addrWin))) - { - return MV_TRUE; - } - } - return MV_FALSE; -} - -/******************************************************************************* -* mvEthAddrDecShow - Print the Etherent address decode map. -* -* DESCRIPTION: -* This function print the Etherent address decode map. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -void mvEthPortAddrDecShow(int port) -{ - MV_ETH_DEC_WIN win; - int i; - - mvOsOutput( "\n" ); - mvOsOutput( "ETH %d:\n", port ); - mvOsOutput( "----\n" ); - - for( i = 0; i < ETH_MAX_DECODE_WIN; i++ ) - { - memset( &win, 0, sizeof(ETH_MAX_DECODE_WIN) ); - - mvOsOutput( "win%d - ", i ); - - if( mvEthWinGet(port, i, &win ) == MV_OK ) - { - if( win.enable ) - { - mvOsOutput( "%s base %08x, ", - mvCtrlTargetNameGet(win.target), win.addrWin.baseLow ); - mvOsOutput( "...." ); - mvSizePrint( win.addrWin.size ); - - mvOsOutput( "\n" ); - } - else - mvOsOutput( "disable\n" ); - } - } - return; -} - -void mvEthAddrDecShow(void) -{ - int port; - - for(port=0; port<mvCtrlEthMaxPortGet(); port++) - { - if (MV_FALSE == mvCtrlPwrClckGet(ETH_GIG_UNIT_ID, port)) continue; - - mvEthPortAddrDecShow(port); - } -} - - -void mvEthInit(void) -{ - MV_U32 port; - - /* Power down all existing ports */ - for(port=0; port<mvCtrlEthMaxPortGet(); port++) - { - if (MV_FALSE == mvCtrlPwrClckGet(ETH_GIG_UNIT_ID, port)) - continue; - - mvEthPortPowerUp(port); - mvEthWinInit(port); - } - mvEthHalInit(); -} diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysGbe.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysGbe.h deleted file mode 100644 index 615af51..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysGbe.h +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCmvSysGbeh -#define __INCmvSysGbeh - -#include "mvCommon.h" -#include "eth/mvEth.h" -#include "ctrlEnv/mvCtrlEnvSpec.h" -#include "ctrlEnv/sys/mvCpuIf.h" - -#define ETH_WIN_BASE_REG(port, win) (MV_ETH_REG_BASE(port) + 0x200 + ((win)<<3)) -#define ETH_WIN_SIZE_REG(port, win) (MV_ETH_REG_BASE(port) + 0x204 + ((win)<<3)) -#define ETH_WIN_REMAP_REG(port, win) (MV_ETH_REG_BASE(port) + 0x280 + ((win)<<2)) -#define ETH_BASE_ADDR_ENABLE_REG(port) (MV_ETH_REG_BASE(port) + 0x290) -#define ETH_ACCESS_PROTECT_REG(port) (MV_ETH_REG_BASE(port) + 0x294) - -/**** Address decode parameters ****/ - -/* Ethernet Base Address Register bits */ -#define ETH_MAX_DECODE_WIN 6 -#define ETH_MAX_HIGH_ADDR_REMAP_WIN 4 - -/* Ethernet Port Access Protect (EPAP) register */ - -/* The target associated with this window*/ -#define ETH_WIN_TARGET_OFFS 0 -#define ETH_WIN_TARGET_MASK (0xf << ETH_WIN_TARGET_OFFS) -/* The target attributes Associated with window */ -#define ETH_WIN_ATTR_OFFS 8 -#define ETH_WIN_ATTR_MASK (0xff << ETH_WIN_ATTR_OFFS) - -/* Ethernet Port Access Protect Register (EPAPR) */ -#define ETH_PROT_NO_ACCESS NO_ACCESS_ALLOWED -#define ETH_PROT_READ_ONLY READ_ONLY -#define ETH_PROT_FULL_ACCESS FULL_ACCESS -#define ETH_PROT_WIN_OFFS(winNum) (2 * (winNum)) -#define ETH_PROT_WIN_MASK(winNum) (0x3 << ETH_PROT_WIN_OFFS(winNum)) - -MV_STATUS mvEthWinInit (int port); -MV_STATUS mvEthWinEnable(int port, MV_U32 winNum, MV_BOOL enable); -MV_U32 mvEthWinTargetGet(int port, MV_TARGET target); -MV_STATUS mvEthProtWinSet(MV_U32 portNo, MV_U32 winNum, MV_ACCESS_RIGHTS - access); - -void mvEthPortAddrDecShow(int port); - -MV_VOID mvEthAddrDecShow(MV_VOID); - -void mvEthInit(void); - -#endif diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysPex.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysPex.c deleted file mode 100644 index b0cb466..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysPex.c +++ /dev/null @@ -1,1697 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#include "ctrlEnv/sys/mvSysPex.h" - -/* this structure describes the mapping between a Pex Window and a CPU target*/ -typedef struct _pexWinToTarget -{ - MV_TARGET target; - MV_BOOL enable; - -}PEX_WIN_TO_TARGET; - -/* this array is a priority array that define How Pex windows should be -configured , We have only 6 Pex Windows that can be configured , but we -have maximum of 9 CPU target windows ! the following array is a priority -array where the lowest index has the highest priotiy and the highest -index has the lowest priority of being cnfigured */ - -MV_U32 pexDevBarPrioTable[] = -{ -#if defined(MV_INCLUDE_DEVICE_CS0) - DEVICE_CS0, -#endif -#if defined(MV_INCLUDE_DEVICE_CS1) - DEVICE_CS1, -#endif -#if defined(MV_INCLUDE_DEVICE_CS2) - DEVICE_CS2, -#endif -#if defined(MV_INCLUDE_DEVICE_CS3) - DEVICE_CS3, -#endif -/* -#if defined(MV_INCLUDE_DEVICE_CS4) - DEVICE_CS4, -#endif -*/ - TBL_TERM -}; - - -/* PEX Wins registers offsets are inconsecutive. This struct describes WIN */ -/* register offsets and its function where its is located. */ -/* Also, PEX address remap registers offsets are inconsecutive. This struct */ -/* describes address remap register offsets */ -typedef struct _pexWinRegInfo -{ - MV_U32 baseLowRegOffs; - MV_U32 baseHighRegOffs; - MV_U32 sizeRegOffs; - MV_U32 remapLowRegOffs; - MV_U32 remapHighRegOffs; - -}PEX_WIN_REG_INFO; - -static MV_STATUS pexWinOverlapDetect(MV_U32 pexIf, MV_U32 winNum, - MV_ADDR_WIN *pAddrWin); -static MV_STATUS pexWinRegInfoGet(MV_U32 pexIf, MV_U32 winNum, - PEX_WIN_REG_INFO *pWinRegInfo); - -static MV_STATUS pexBarIsValid(MV_U32 baseLow, MV_U32 size); - -static MV_BOOL pexIsWinWithinBar(MV_U32 pexIf,MV_ADDR_WIN *pAddrWin); -static MV_BOOL pexBarOverlapDetect(MV_U32 pexIf,MV_U32 barNum, - MV_ADDR_WIN *pAddrWin); -const MV_8* pexBarNameGet( MV_U32 bar ); - - -/******************************************************************************* -* mvPexInit - Initialize PEX interfaces -* -* DESCRIPTION: -* -* This function is responsible of intialization of the Pex Interface , It -* configure the Pex Bars and Windows in the following manner: -* -* Assumptions : -* Bar0 is always internal registers bar -* Bar1 is always the DRAM bar -* Bar2 is always the Device bar -* -* 1) Sets the Internal registers bar base by obtaining the base from -* the CPU Interface -* 2) Sets the DRAM bar base and size by getting the base and size from -* the CPU Interface when the size is the sum of all enabled DRAM -* chip selects and the base is the base of CS0 . -* 3) Sets the Device bar base and size by getting these values from the -* CPU Interface when the base is the base of the lowest base of the -* Device chip selects, and the -* -* -* INPUT: -* -* pexIf - PEX interface number. -* -* -* OUTPUT: -* None. -* -* RETURN: -* MV_OK if function success otherwise MV_ERROR or MV_BAD_PARAM -* -*******************************************************************************/ -MV_STATUS mvPexInit(MV_U32 pexIf, MV_PEX_TYPE pexType) -{ - MV_U32 bar; - MV_U32 winNum; - MV_PEX_BAR pexBar; - MV_PEX_DEC_WIN pexWin; - MV_CPU_DEC_WIN addrDecWin; - MV_TARGET target; - MV_U32 pexCurrWin=0; - MV_U32 status; - /* default and exapntion rom - are always configured */ - -#ifndef MV_DISABLE_PEX_DEVICE_BAR - MV_U32 winIndex; - MV_U32 maxBase=0, sizeOfMaxBase=0; - MV_U32 pexStartWindow; -#endif - - /* Parameter checking */ - if(pexIf >= mvCtrlPexMaxIfGet()) - { - mvOsPrintf("mvPexInit: ERR. Invalid PEX interface %d\n", pexIf); - return MV_BAD_PARAM; - } - - /* Enabled CPU access to PCI-Express */ - mvCpuIfEnablePex(pexIf, pexType); - - /* Start with bars */ - /* First disable all PEX bars*/ - for (bar = 0; bar < PEX_MAX_BARS; bar++) - { - if (PEX_INTER_REGS_BAR != bar) - { - if (MV_OK != mvPexBarEnable(pexIf, bar, MV_FALSE)) - { - mvOsPrintf("mvPexInit:mvPexBarEnable bar =%d failed \n",bar); - return MV_ERROR; - } - - } - - } - - /* and disable all PEX target windows */ - for (winNum = 0; winNum < PEX_MAX_TARGET_WIN - 2; winNum++) - { - if (MV_OK != mvPexTargetWinEnable(pexIf, winNum, MV_FALSE)) - { - mvOsPrintf("mvPexInit:mvPexTargetWinEnable winNum =%d failed \n", - winNum); - return MV_ERROR; - - } - } - - /* Now, go through all bars*/ - - - -/******************************************************************************/ -/* Internal registers bar */ -/******************************************************************************/ - bar = PEX_INTER_REGS_BAR; - - /* we only open the bar , no need to open windows for this bar */ - - /* first get the CS attribute from the CPU Interface */ - if (MV_OK !=mvCpuIfTargetWinGet(INTER_REGS,&addrDecWin)) - { - mvOsPrintf("mvPexInit: ERR. mvCpuIfTargetWinGet failed target =%d\n",INTER_REGS); - return MV_ERROR; - } - - pexBar.addrWin.baseHigh = addrDecWin.addrWin.baseHigh; - pexBar.addrWin.baseLow = addrDecWin.addrWin.baseLow; - pexBar.addrWin.size = addrDecWin.addrWin.size; - pexBar.enable = MV_TRUE; - - if (MV_OK != mvPexBarSet(pexIf, bar, &pexBar)) - { - mvOsPrintf("mvPexInit: ERR. mvPexBarSet %d failed\n", bar); - return MV_ERROR; - } - -/******************************************************************************/ -/* DRAM bar */ -/******************************************************************************/ - - bar = PEX_DRAM_BAR; - - pexBar.addrWin.size = 0; - - for (target = SDRAM_CS0;target < MV_DRAM_MAX_CS; target++ ) - { - - status = mvCpuIfTargetWinGet(target,&addrDecWin); - - if((MV_NO_SUCH == status)&&(target != SDRAM_CS0)) - { - continue; - } - - /* first get attributes from CPU If */ - if (MV_OK != status) - { - mvOsPrintf("mvPexInit: ERR. mvCpuIfTargetWinGet failed target =%d\n",target); - return MV_ERROR; - } - if (addrDecWin.enable == MV_TRUE) - { - /* the base is the base of DRAM CS0 always */ - if (SDRAM_CS0 == target ) - { - pexBar.addrWin.baseHigh = addrDecWin.addrWin.baseHigh; - pexBar.addrWin.baseLow = addrDecWin.addrWin.baseLow; - - } - - /* increment the bar size to be the sum of the size of all - DRAM chips selecs */ - pexBar.addrWin.size += addrDecWin.addrWin.size; - - /* set a Pex window for this target ! - DRAM CS always will have a Pex Window , and is not a - part of the priority table */ - pexWin.addrWin.baseHigh = addrDecWin.addrWin.baseHigh; - pexWin.addrWin.baseLow = addrDecWin.addrWin.baseLow; - pexWin.addrWin.size = addrDecWin.addrWin.size; - - /* we disable the windows at first because we are not - sure that it is witihin bar boundries */ - pexWin.enable =MV_FALSE; - pexWin.target = target; - pexWin.targetBar = bar; - - if (MV_OK != mvPexTargetWinSet(pexIf,pexCurrWin++,&pexWin)) - { - mvOsPrintf("mvPexInit: ERR. mvPexTargetWinSet failed\n"); - return MV_ERROR; - } - } - } - - /* check if the size of the bar is illeggal */ - if (-1 == ctrlSizeToReg(pexBar.addrWin.size, PXBCR_BAR_SIZE_ALIGNMENT)) - { - /* try to get a good size */ - pexBar.addrWin.size = ctrlSizeRegRoundUp(pexBar.addrWin.size, - PXBCR_BAR_SIZE_ALIGNMENT); - } - - /* check if the size and base are valid */ - if (MV_TRUE == pexBarOverlapDetect(pexIf,bar,&pexBar.addrWin)) - { - mvOsPrintf("mvPexInit:Warning :Bar %d size is illigal\n",bar); - mvOsPrintf("it will be disabled\n"); - mvOsPrintf("please check Pex and CPU windows configuration\n"); - } - else - { - pexBar.enable = MV_TRUE; - - /* configure the bar */ - if (MV_OK != mvPexBarSet(pexIf, bar, &pexBar)) - { - mvOsPrintf("mvPexInit: ERR. mvPexBarSet %d failed\n", bar); - return MV_ERROR; - } - - /* after the bar was configured then we enable the Pex windows*/ - for (winNum = 0;winNum < pexCurrWin ;winNum++) - { - if (MV_OK != mvPexTargetWinEnable(pexIf, winNum, MV_TRUE)) - { - mvOsPrintf("mvPexInit: Can't enable window =%d\n",winNum); - return MV_ERROR; - } - - } - } - -/******************************************************************************/ -/* DEVICE bar */ -/******************************************************************************/ - -/* Open the Device BAR for non linux only */ -#ifndef MV_DISABLE_PEX_DEVICE_BAR - - /* then device bar*/ - bar = PEX_DEVICE_BAR; - - /* save the starting window */ - pexStartWindow = pexCurrWin; - pexBar.addrWin.size = 0; - pexBar.addrWin.baseLow = 0xffffffff; - pexBar.addrWin.baseHigh = 0; - maxBase = 0; - - for (target = DEV_TO_TARGET(START_DEV_CS);target < DEV_TO_TARGET(MV_DEV_MAX_CS); target++ ) - { - status = mvCpuIfTargetWinGet(target,&addrDecWin); - - if (MV_NO_SUCH == status) - { - continue; - } - - if (MV_OK != status) - { - mvOsPrintf("mvPexInit: ERR. mvCpuIfTargetWinGet failed target =%d\n",target); - return MV_ERROR; - } - - if (addrDecWin.enable == MV_TRUE) - { - /* get the minimum base */ - if (addrDecWin.addrWin.baseLow < pexBar.addrWin.baseLow) - { - pexBar.addrWin.baseLow = addrDecWin.addrWin.baseLow; - } - - /* get the maximum base */ - if (addrDecWin.addrWin.baseLow > maxBase) - { - maxBase = addrDecWin.addrWin.baseLow; - sizeOfMaxBase = addrDecWin.addrWin.size; - } - - /* search in the priority table for this target */ - for (winIndex = 0; pexDevBarPrioTable[winIndex] != TBL_TERM; - winIndex++) - { - if (pexDevBarPrioTable[winIndex] != target) - { - continue; - } - else if (pexDevBarPrioTable[winIndex] == target) - { - /*found it */ - - /* if the index of this target in the prio table is valid - then we set the Pex window for this target, a valid index is - an index that is lower than the number of the windows that - was not configured yet */ - - /* we subtract 2 always because the default and expantion - rom windows are always configured */ - if ( pexCurrWin < PEX_MAX_TARGET_WIN - 2) - { - /* set a Pex window for this target ! */ - pexWin.addrWin.baseHigh = addrDecWin.addrWin.baseHigh; - pexWin.addrWin.baseLow = addrDecWin.addrWin.baseLow; - pexWin.addrWin.size = addrDecWin.addrWin.size; - - /* we disable the windows at first because we are not - sure that it is witihin bar boundries */ - pexWin.enable = MV_FALSE; - pexWin.target = target; - pexWin.targetBar = bar; - - if (MV_OK != mvPexTargetWinSet(pexIf,pexCurrWin++, - &pexWin)) - { - mvOsPrintf("mvPexInit: ERR. Window Set failed\n"); - return MV_ERROR; - } - } - } - } - } - } - - pexBar.addrWin.size = maxBase - pexBar.addrWin.baseLow + sizeOfMaxBase; - pexBar.enable = MV_TRUE; - - /* check if the size of the bar is illegal */ - if (-1 == ctrlSizeToReg(pexBar.addrWin.size, PXBCR_BAR_SIZE_ALIGNMENT)) - { - /* try to get a good size */ - pexBar.addrWin.size = ctrlSizeRegRoundUp(pexBar.addrWin.size, - PXBCR_BAR_SIZE_ALIGNMENT); - } - - /* check if the size and base are valid */ - if (MV_TRUE == pexBarOverlapDetect(pexIf,bar,&pexBar.addrWin)) - { - mvOsPrintf("mvPexInit:Warning :Bar %d size is illigal\n",bar); - mvOsPrintf("it will be disabled\n"); - mvOsPrintf("please check Pex and CPU windows configuration\n"); - } - else - { - if (MV_OK != mvPexBarSet(pexIf, bar, &pexBar)) - { - mvOsPrintf("mvPexInit: ERR. mvPexBarSet %d failed\n", bar); - return MV_ERROR; - } - - /* now enable the windows */ - for (winNum = pexStartWindow; winNum < pexCurrWin ; winNum++) - { - if (MV_OK != mvPexTargetWinEnable(pexIf, winNum, MV_TRUE)) - { - mvOsPrintf("mvPexInit:mvPexTargetWinEnable winNum =%d failed \n", - winNum); - return MV_ERROR; - } - } - } - -#endif - - return mvPexHalInit(pexIf, pexType); - -} - -/******************************************************************************* -* mvPexTargetWinSet - Set PEX to peripheral target address window BAR -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* N/A -* -* RETURN: -* MV_OK if PEX BAR target window was set correctly, -* MV_BAD_PARAM on bad params -* MV_ERROR otherwise -* (e.g. address window overlapps with other active PEX target window). -* -*******************************************************************************/ -MV_STATUS mvPexTargetWinSet(MV_U32 pexIf, MV_U32 winNum, - MV_PEX_DEC_WIN *pAddrDecWin) -{ - - MV_DEC_REGS decRegs; - PEX_WIN_REG_INFO winRegInfo; - MV_TARGET_ATTRIB targetAttribs; - - /* Parameter checking */ - if(pexIf >= mvCtrlPexMaxIfGet()) - { - mvOsPrintf("mvPexTargetWinSet: ERR. Invalid PEX interface %d\n", pexIf); - return MV_BAD_PARAM; - } - - if (winNum >= PEX_MAX_TARGET_WIN) - { - mvOsPrintf("mvPexTargetWinSet: ERR. Invalid PEX winNum %d\n", winNum); - return MV_BAD_PARAM; - - } - - /* get the pex Window registers offsets */ - pexWinRegInfoGet(pexIf,winNum,&winRegInfo); - - - if (MV_TRUE == pAddrDecWin->enable) - { - - /* 2) Check if the requested window overlaps with current windows */ - if (MV_TRUE == pexWinOverlapDetect(pexIf,winNum, &pAddrDecWin->addrWin)) - { - mvOsPrintf("mvPexTargetWinSet: ERR. Target %d overlap\n", winNum); - return MV_BAD_PARAM; - } - - /* 2) Check if the requested window overlaps with current windows */ - if (MV_FALSE == pexIsWinWithinBar(pexIf,&pAddrDecWin->addrWin)) - { - mvOsPrintf("mvPexTargetWinSet: Win %d should be in bar boundries\n", - winNum); - return MV_BAD_PARAM; - } - - } - - - - /* read base register*/ - - if (winRegInfo.baseLowRegOffs) - { - decRegs.baseReg = MV_REG_READ(winRegInfo.baseLowRegOffs); - } - else - { - decRegs.baseReg = 0; - } - - if (winRegInfo.sizeRegOffs) - { - decRegs.sizeReg = MV_REG_READ(winRegInfo.sizeRegOffs); - } - else - { - decRegs.sizeReg =0; - } - - if (MV_OK != mvCtrlAddrDecToReg(&(pAddrDecWin->addrWin),&decRegs)) - { - mvOsPrintf("mvPexTargetWinSet:mvCtrlAddrDecToReg Failed\n"); - return MV_ERROR; - } - - /* enable\Disable */ - if (MV_TRUE == pAddrDecWin->enable) - { - decRegs.sizeReg |= PXWCR_WIN_EN; - } - else - { - decRegs.sizeReg &= ~PXWCR_WIN_EN; - } - - - /* clear bit location */ - decRegs.sizeReg &= ~PXWCR_WIN_BAR_MAP_MASK; - - /* set bar Mapping */ - if (pAddrDecWin->targetBar == 1) - { - decRegs.sizeReg |= PXWCR_WIN_BAR_MAP_BAR1; - } - else if (pAddrDecWin->targetBar == 2) - { - decRegs.sizeReg |= PXWCR_WIN_BAR_MAP_BAR2; - } - - mvCtrlAttribGet(pAddrDecWin->target,&targetAttribs); - - /* set attributes */ - decRegs.sizeReg &= ~PXWCR_ATTRIB_MASK; - decRegs.sizeReg |= targetAttribs.attrib << PXWCR_ATTRIB_OFFS; - /* set target ID */ - decRegs.sizeReg &= ~PXWCR_TARGET_MASK; - decRegs.sizeReg |= targetAttribs.targetId << PXWCR_TARGET_OFFS; - - - /* 3) Write to address decode Base Address Register */ - - if (winRegInfo.baseLowRegOffs) - { - MV_REG_WRITE(winRegInfo.baseLowRegOffs, decRegs.baseReg); - } - - /* write size reg */ - if (winRegInfo.sizeRegOffs) - { - if ((MV_PEX_WIN_DEFAULT == winNum)|| - (MV_PEX_WIN_EXP_ROM == winNum)) - { - /* clear size because there is no size field*/ - decRegs.sizeReg &= ~PXWCR_SIZE_MASK; - - /* clear enable because there is no enable field*/ - decRegs.sizeReg &= ~PXWCR_WIN_EN; - - } - - MV_REG_WRITE(winRegInfo.sizeRegOffs, decRegs.sizeReg); - } - - - return MV_OK; - -} - -/******************************************************************************* -* mvPexTargetWinGet - Get PEX to peripheral target address window -* -* DESCRIPTION: -* Get the PEX to peripheral target address window BAR. -* -* INPUT: -* pexIf - PEX interface number. -* bar - BAR to be accessed by slave. -* -* OUTPUT: -* pAddrBarWin - PEX target window information data structure. -* -* RETURN: -* MV_BAD_PARAM for bad parameters ,MV_ERROR on error ! otherwise MV_OK -* -*******************************************************************************/ -MV_STATUS mvPexTargetWinGet(MV_U32 pexIf, MV_U32 winNum, - MV_PEX_DEC_WIN *pAddrDecWin) -{ - MV_TARGET_ATTRIB targetAttrib; - MV_DEC_REGS decRegs; - - PEX_WIN_REG_INFO winRegInfo; - - /* Parameter checking */ - if(pexIf >= mvCtrlPexMaxIfGet()) - { - mvOsPrintf("mvPexTargetWinGet: ERR. Invalid PEX interface %d\n", pexIf); - return MV_BAD_PARAM; - } - - if (winNum >= PEX_MAX_TARGET_WIN) - { - mvOsPrintf("mvPexTargetWinGet: ERR. Invalid PEX winNum %d\n", winNum); - return MV_BAD_PARAM; - - } - - /* get the pex Window registers offsets */ - pexWinRegInfoGet(pexIf,winNum,&winRegInfo); - - /* read base register*/ - if (winRegInfo.baseLowRegOffs) - { - decRegs.baseReg = MV_REG_READ(winRegInfo.baseLowRegOffs); - } - else - { - decRegs.baseReg = 0; - } - - /* read size reg */ - if (winRegInfo.sizeRegOffs) - { - decRegs.sizeReg = MV_REG_READ(winRegInfo.sizeRegOffs); - } - else - { - decRegs.sizeReg =0; - } - - if (MV_OK != mvCtrlRegToAddrDec(&decRegs,&(pAddrDecWin->addrWin))) - { - mvOsPrintf("mvPexTargetWinGet: mvCtrlRegToAddrDec Failed \n"); - return MV_ERROR; - - } - - if (decRegs.sizeReg & PXWCR_WIN_EN) - { - pAddrDecWin->enable = MV_TRUE; - } - else - { - pAddrDecWin->enable = MV_FALSE; - - } - - - #if 0 - if (-1 == pAddrDecWin->addrWin.size) - { - return MV_ERROR; - } - #endif - - - /* get target bar */ - if ((decRegs.sizeReg & PXWCR_WIN_BAR_MAP_MASK) == PXWCR_WIN_BAR_MAP_BAR1 ) - { - pAddrDecWin->targetBar = 1; - } - else if ((decRegs.sizeReg & PXWCR_WIN_BAR_MAP_MASK) == - PXWCR_WIN_BAR_MAP_BAR2 ) - { - pAddrDecWin->targetBar = 2; - } - - /* attrib and targetId */ - pAddrDecWin->attrib = (decRegs.sizeReg & PXWCR_ATTRIB_MASK) >> - PXWCR_ATTRIB_OFFS; - pAddrDecWin->targetId = (decRegs.sizeReg & PXWCR_TARGET_MASK) >> - PXWCR_TARGET_OFFS; - - targetAttrib.attrib = pAddrDecWin->attrib; - targetAttrib.targetId = pAddrDecWin->targetId; - - pAddrDecWin->target = mvCtrlTargetGet(&targetAttrib); - - return MV_OK; - -} - - -/******************************************************************************* -* mvPexTargetWinEnable - Enable/disable a PEX BAR window -* -* DESCRIPTION: -* This function enable/disable a PEX BAR window. -* if parameter 'enable' == MV_TRUE the routine will enable the -* window, thus enabling PEX accesses for that BAR (before enabling the -* window it is tested for overlapping). Otherwise, the window will -* be disabled. -* -* INPUT: -* pexIf - PEX interface number. -* bar - BAR to be accessed by slave. -* enable - Enable/disable parameter. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM for bad parameters ,MV_ERROR on error ! otherwise MV_OK -* -*******************************************************************************/ -MV_STATUS mvPexTargetWinEnable(MV_U32 pexIf,MV_U32 winNum, MV_BOOL enable) -{ - PEX_WIN_REG_INFO winRegInfo; - MV_PEX_DEC_WIN addrDecWin; - - /* Parameter checking */ - if(pexIf >= mvCtrlPexMaxIfGet()) - { - mvOsPrintf("mvPexTargetWinEnable: ERR. Invalid PEX If %d\n", pexIf); - return MV_BAD_PARAM; - } - - if (winNum >= PEX_MAX_TARGET_WIN) - { - mvOsPrintf("mvPexTargetWinEnable ERR. Invalid PEX winNum %d\n", winNum); - return MV_BAD_PARAM; - - } - - - /* get the pex Window registers offsets */ - pexWinRegInfoGet(pexIf,winNum,&winRegInfo); - - - /* if the address windows is disabled , we only disable the appropriare - pex window and ignore other settings */ - - if (MV_FALSE == enable) - { - - /* this is not relevant to default and expantion rom - windows */ - if (winRegInfo.sizeRegOffs) - { - if ((MV_PEX_WIN_DEFAULT != winNum)&& - (MV_PEX_WIN_EXP_ROM != winNum)) - { - MV_REG_BIT_RESET(winRegInfo.sizeRegOffs, PXWCR_WIN_EN); - } - } - - } - else - { - if (MV_OK != mvPexTargetWinGet(pexIf,winNum, &addrDecWin)) - { - mvOsPrintf("mvPexTargetWinEnable: mvPexTargetWinGet Failed\n"); - return MV_ERROR; - } - - /* Check if the requested window overlaps with current windows */ - if (MV_TRUE == pexWinOverlapDetect(pexIf,winNum, &addrDecWin.addrWin)) - { - mvOsPrintf("mvPexTargetWinEnable: ERR. Target %d overlap\n", winNum); - return MV_BAD_PARAM; - } - - if (MV_FALSE == pexIsWinWithinBar(pexIf,&addrDecWin.addrWin)) - { - mvOsPrintf("mvPexTargetWinEnable: Win %d should be in bar boundries\n", - winNum); - return MV_BAD_PARAM; - } - - - /* this is not relevant to default and expantion rom - windows */ - if (winRegInfo.sizeRegOffs) - { - if ((MV_PEX_WIN_DEFAULT != winNum)&& - (MV_PEX_WIN_EXP_ROM != winNum)) - { - MV_REG_BIT_SET(winRegInfo.sizeRegOffs, PXWCR_WIN_EN); - } - } - - - } - - return MV_OK; - -} - - - -/******************************************************************************* -* mvPexTargetWinRemap - Set PEX to target address window remap. -* -* DESCRIPTION: -* The PEX interface supports remap of the BAR original address window. -* For each BAR it is possible to define a remap address. For example -* an address 0x12345678 that hits BAR 0x10 (SDRAM CS[0]) will be modified -* according to remap register but will also be targeted to the -* SDRAM CS[0]. -* -* INPUT: -* pexIf - PEX interface number. -* bar - Peripheral target enumerator accessed by slave. -* pAddrWin - Address window to be checked. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM for bad parameters ,MV_ERROR on error ! otherwise MV_OK -* -*******************************************************************************/ -MV_STATUS mvPexTargetWinRemap(MV_U32 pexIf, MV_U32 winNum, - MV_PEX_REMAP_WIN *pAddrWin) -{ - - PEX_WIN_REG_INFO winRegInfo; - - /* Parameter checking */ - if (pexIf >= mvCtrlPexMaxIfGet()) - { - mvOsPrintf("mvPexTargetWinRemap: ERR. Invalid PEX interface num %d\n", - pexIf); - return MV_BAD_PARAM; - } - if (MV_PEX_WIN_DEFAULT == winNum) - { - mvOsPrintf("mvPexTargetWinRemap: ERR. Invalid PEX win num %d\n", - winNum); - return MV_BAD_PARAM; - - } - - if (MV_IS_NOT_ALIGN(pAddrWin->addrWin.baseLow, PXWRR_REMAP_ALIGNMENT)) - { - mvOsPrintf("mvPexTargetWinRemap: Error remap PEX interface %d win %d."\ - "\nAddress 0x%08x is unaligned to size 0x%x.\n", - pexIf, - winNum, - pAddrWin->addrWin.baseLow, - pAddrWin->addrWin.size); - - return MV_ERROR; - } - - pexWinRegInfoGet(pexIf, winNum, &winRegInfo); - - /* Set remap low register value */ - MV_REG_WRITE(winRegInfo.remapLowRegOffs, pAddrWin->addrWin.baseLow); - - /* Skip base high settings if the BAR has only base low (32-bit) */ - if (0 != winRegInfo.remapHighRegOffs) - { - MV_REG_WRITE(winRegInfo.remapHighRegOffs, pAddrWin->addrWin.baseHigh); - } - - - if (pAddrWin->enable == MV_TRUE) - { - MV_REG_BIT_SET(winRegInfo.remapLowRegOffs,PXWRR_REMAP_EN); - } - else - { - MV_REG_BIT_RESET(winRegInfo.remapLowRegOffs,PXWRR_REMAP_EN); - } - - return MV_OK; -} - -/******************************************************************************* -* mvPexTargetWinRemapEnable - -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* -* RETURN: -* MV_BAD_PARAM for bad parameters ,MV_ERROR on error ! otherwise MV_OK -* -*******************************************************************************/ - -MV_STATUS mvPexTargetWinRemapEnable(MV_U32 pexIf, MV_U32 winNum, - MV_BOOL enable) -{ - PEX_WIN_REG_INFO winRegInfo; - - /* Parameter checking */ - if (pexIf >= mvCtrlPexMaxIfGet()) - { - mvOsPrintf("mvPexTargetWinRemap: ERR. Invalid PEX interface num %d\n", - pexIf); - return MV_BAD_PARAM; - } - if (MV_PEX_WIN_DEFAULT == winNum) - { - mvOsPrintf("mvPexTargetWinRemap: ERR. Invalid PEX win num %d\n", - winNum); - return MV_BAD_PARAM; - - } - - - pexWinRegInfoGet(pexIf, winNum, &winRegInfo); - - if (enable == MV_TRUE) - { - MV_REG_BIT_SET(winRegInfo.remapLowRegOffs,PXWRR_REMAP_EN); - } - else - { - MV_REG_BIT_RESET(winRegInfo.remapLowRegOffs,PXWRR_REMAP_EN); - } - - return MV_OK; - -} - -/******************************************************************************* -* mvPexBarSet - Set PEX bar address and size -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM for bad parameters ,MV_ERROR on error ! otherwise MV_OK -* -*******************************************************************************/ -MV_STATUS mvPexBarSet(MV_U32 pexIf, - MV_U32 barNum, - MV_PEX_BAR *pAddrWin) -{ - MV_U32 regBaseLow; - MV_U32 regSize,sizeToReg; - - - /* check parameters */ - if(pexIf >= mvCtrlPexMaxIfGet()) - { - mvOsPrintf("mvPexBarSet: ERR. Invalid PEX interface %d\n", pexIf); - return MV_BAD_PARAM; - } - - if(barNum >= PEX_MAX_BARS) - { - mvOsPrintf("mvPexBarSet: ERR. Invalid bar number %d\n", barNum); - return MV_BAD_PARAM; - } - - - if (pAddrWin->addrWin.size == 0) - { - mvOsPrintf("mvPexBarSet: Size zero is Illigal\n" ); - return MV_BAD_PARAM; - } - - - /* Check if the window complies with PEX spec */ - if (MV_TRUE != pexBarIsValid(pAddrWin->addrWin.baseLow, - pAddrWin->addrWin.size)) - { - mvOsPrintf("mvPexBarSet: ERR. Target %d window invalid\n", barNum); - return MV_BAD_PARAM; - } - - /* 2) Check if the requested bar overlaps with current bars */ - if (MV_TRUE == pexBarOverlapDetect(pexIf,barNum, &pAddrWin->addrWin)) - { - mvOsPrintf("mvPexBarSet: ERR. Target %d overlap\n", barNum); - return MV_BAD_PARAM; - } - - /* Get size register value according to window size */ - sizeToReg = ctrlSizeToReg(pAddrWin->addrWin.size, PXBCR_BAR_SIZE_ALIGNMENT); - - /* Read bar size */ - if (PEX_INTER_REGS_BAR != barNum) /* internal registers have no size */ - { - regSize = MV_REG_READ(PEX_BAR_CTRL_REG(pexIf,barNum)); - - /* Size parameter validity check. */ - if (-1 == sizeToReg) - { - mvOsPrintf("mvPexBarSet: ERR. Target BAR %d size invalid.\n",barNum); - return MV_BAD_PARAM; - } - - regSize &= ~PXBCR_BAR_SIZE_MASK; - regSize |= (sizeToReg << PXBCR_BAR_SIZE_OFFS) ; - - MV_REG_WRITE(PEX_BAR_CTRL_REG(pexIf,barNum),regSize); - - } - - /* set size */ - - - - /* Read base address low */ - regBaseLow = MV_REG_READ(PEX_CFG_DIRECT_ACCESS(pexIf, - PEX_MV_BAR_BASE(barNum))); - - /* clear current base */ - if (PEX_INTER_REGS_BAR == barNum) - { - regBaseLow &= ~PXBIR_BASE_MASK; - regBaseLow |= (pAddrWin->addrWin.baseLow & PXBIR_BASE_MASK); - } - else - { - regBaseLow &= ~PXBR_BASE_MASK; - regBaseLow |= (pAddrWin->addrWin.baseLow & PXBR_BASE_MASK); - } - - /* if we had a previous value that contain the bar type (MeM\IO), we want to - restore it */ - regBaseLow |= PEX_BAR_DEFAULT_ATTRIB; - - - - /* write base low */ - MV_REG_WRITE(PEX_CFG_DIRECT_ACCESS(pexIf,PEX_MV_BAR_BASE(barNum)), - regBaseLow); - - if (pAddrWin->addrWin.baseHigh != 0) - { - /* Read base address high */ - MV_REG_WRITE(PEX_CFG_DIRECT_ACCESS(pexIf,PEX_MV_BAR_BASE_HIGH(barNum)), - pAddrWin->addrWin.baseHigh); - - } - - /* lastly enable the Bar */ - if (pAddrWin->enable == MV_TRUE) - { - if (PEX_INTER_REGS_BAR != barNum) /* internal registers - are enabled always */ - { - MV_REG_BIT_SET(PEX_BAR_CTRL_REG(pexIf,barNum),PXBCR_BAR_EN); - } - } - else if (MV_FALSE == pAddrWin->enable) - { - if (PEX_INTER_REGS_BAR != barNum) /* internal registers - are enabled always */ - { - MV_REG_BIT_RESET(PEX_BAR_CTRL_REG(pexIf,barNum),PXBCR_BAR_EN); - } - - } - - - - return MV_OK; -} - - -/******************************************************************************* -* mvPexBarGet - Get PEX bar address and size -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM for bad parameters ,MV_ERROR on error ! otherwise MV_OK -* -*******************************************************************************/ - -MV_STATUS mvPexBarGet(MV_U32 pexIf, - MV_U32 barNum, - MV_PEX_BAR *pAddrWin) -{ - /* check parameters */ - if(pexIf >= mvCtrlPexMaxIfGet()) - { - mvOsPrintf("mvPexBarGet: ERR. Invalid PEX interface %d\n", pexIf); - return MV_BAD_PARAM; - } - - if(barNum >= PEX_MAX_BARS) - { - mvOsPrintf("mvPexBarGet: ERR. Invalid bar number %d\n", barNum); - return MV_BAD_PARAM; - } - - /* read base low */ - pAddrWin->addrWin.baseLow = - MV_REG_READ(PEX_CFG_DIRECT_ACCESS(pexIf,PEX_MV_BAR_BASE(barNum))); - - - if (PEX_INTER_REGS_BAR == barNum) - { - pAddrWin->addrWin.baseLow &= PXBIR_BASE_MASK; - } - else - { - pAddrWin->addrWin.baseLow &= PXBR_BASE_MASK; - } - - - /* read base high */ - pAddrWin->addrWin.baseHigh = - MV_REG_READ(PEX_CFG_DIRECT_ACCESS(pexIf,PEX_MV_BAR_BASE_HIGH(barNum))); - - - /* Read bar size */ - if (PEX_INTER_REGS_BAR != barNum) /* internal registers have no size */ - { - pAddrWin->addrWin.size = MV_REG_READ(PEX_BAR_CTRL_REG(pexIf,barNum)); - - /* check if enable or not */ - if (pAddrWin->addrWin.size & PXBCR_BAR_EN) - { - pAddrWin->enable = MV_TRUE; - } - else - { - pAddrWin->enable = MV_FALSE; - } - - /* now get the size */ - pAddrWin->addrWin.size &= PXBCR_BAR_SIZE_MASK; - pAddrWin->addrWin.size >>= PXBCR_BAR_SIZE_OFFS; - - pAddrWin->addrWin.size = ctrlRegToSize(pAddrWin->addrWin.size, - PXBCR_BAR_SIZE_ALIGNMENT); - - } - else /* PEX_INTER_REGS_BAR */ - { - pAddrWin->addrWin.size = INTER_REGS_SIZE; - pAddrWin->enable = MV_TRUE; - } - - - return MV_OK; -} - -/******************************************************************************* -* mvPexBarEnable - -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM for bad parameters ,MV_ERROR on error ! otherwise MV_OK -* -*******************************************************************************/ - - -MV_STATUS mvPexBarEnable(MV_U32 pexIf, MV_U32 barNum, MV_BOOL enable) -{ - - MV_PEX_BAR pexBar; - - /* check parameters */ - if(pexIf >= mvCtrlPexMaxIfGet()) - { - mvOsPrintf("mvPexBarEnable: ERR. Invalid PEX interface %d\n", pexIf); - return MV_BAD_PARAM; - } - - - if(barNum >= PEX_MAX_BARS) - { - mvOsPrintf("mvPexBarEnable: ERR. Invalid bar number %d\n", barNum); - return MV_BAD_PARAM; - } - - if (PEX_INTER_REGS_BAR == barNum) - { - if (MV_TRUE == enable) - { - return MV_OK; - } - else - { - return MV_ERROR; - } - } - - - if (MV_FALSE == enable) - { - /* disable bar and quit */ - MV_REG_BIT_RESET(PEX_BAR_CTRL_REG(pexIf,barNum),PXBCR_BAR_EN); - return MV_OK; - } - - /* else */ - - if (mvPexBarGet(pexIf,barNum,&pexBar) != MV_OK) - { - mvOsPrintf("mvPexBarEnable: mvPexBarGet Failed\n"); - return MV_ERROR; - - } - - if (MV_TRUE == pexBar.enable) - { - /* it is already enabled !!! */ - return MV_OK; - } - - /* else enable the bar*/ - - pexBar.enable = MV_TRUE; - - if (mvPexBarSet(pexIf,barNum,&pexBar) != MV_OK) - { - mvOsPrintf("mvPexBarEnable: mvPexBarSet Failed\n"); - return MV_ERROR; - - } - - return MV_OK; -} - - -/******************************************************************************* -* pexWinOverlapDetect - Detect address windows overlapping -* -* DESCRIPTION: -* This function detects address window overlapping of a given address -* window in PEX BARs. -* -* INPUT: -* pAddrWin - Address window to be checked. -* bar - BAR to be accessed by slave. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_TRUE if the given address window overlap current address -* decode map, MV_FALSE otherwise. -* -*******************************************************************************/ -static MV_BOOL pexWinOverlapDetect(MV_U32 pexIf, - MV_U32 winNum, - MV_ADDR_WIN *pAddrWin) -{ - MV_U32 win; - MV_PEX_DEC_WIN addrDecWin; - - - for(win = 0; win < PEX_MAX_TARGET_WIN -2 ; win++) - { - /* don't check our target or illegal targets */ - if (winNum == win) - { - continue; - } - - /* Get window parameters */ - if (MV_OK != mvPexTargetWinGet(pexIf, win, &addrDecWin)) - { - mvOsPrintf("pexWinOverlapDetect: ERR. TargetWinGet failed win=%x\n", - win); - return MV_ERROR; - } - - /* Do not check disabled windows */ - if (MV_FALSE == addrDecWin.enable) - { - continue; - } - - - if(MV_TRUE == ctrlWinOverlapTest(pAddrWin, &addrDecWin.addrWin)) - { - mvOsPrintf("pexWinOverlapDetect: winNum %d overlap current %d\n", - winNum, win); - return MV_TRUE; - } - } - - return MV_FALSE; -} - -/******************************************************************************* -* pexIsWinWithinBar - Detect if address is within PEX bar boundries -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* None. -* -* RETURN: -* MV_TRUE if the given address window overlap current address -* decode map, MV_FALSE otherwise. -* -*******************************************************************************/ -static MV_BOOL pexIsWinWithinBar(MV_U32 pexIf, - MV_ADDR_WIN *pAddrWin) -{ - MV_U32 bar; - MV_PEX_BAR addrDecWin; - - for(bar = 0; bar < PEX_MAX_BARS; bar++) - { - - /* Get window parameters */ - if (MV_OK != mvPexBarGet(pexIf, bar, &addrDecWin)) - { - mvOsPrintf("pexIsWinWithinBar: ERR. mvPexBarGet failed\n"); - return MV_ERROR; - } - - /* Do not check disabled bars */ - if (MV_FALSE == addrDecWin.enable) - { - continue; - } - - - if(MV_TRUE == ctrlWinWithinWinTest(pAddrWin, &addrDecWin.addrWin)) - { - return MV_TRUE; - } - } - - return MV_FALSE; - -} - -/******************************************************************************* -* pexBarOverlapDetect - Detect address windows overlapping -* -* DESCRIPTION: -* This function detects address window overlapping of a given address -* window in PEX BARs. -* -* INPUT: -* pAddrWin - Address window to be checked. -* bar - BAR to be accessed by slave. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_TRUE if the given address window overlap current address -* decode map, MV_FALSE otherwise. -* -*******************************************************************************/ -static MV_BOOL pexBarOverlapDetect(MV_U32 pexIf, - MV_U32 barNum, - MV_ADDR_WIN *pAddrWin) -{ - MV_U32 bar; - MV_PEX_BAR barDecWin; - - - for(bar = 0; bar < PEX_MAX_BARS; bar++) - { - /* don't check our target or illegal targets */ - if (barNum == bar) - { - continue; - } - - /* Get window parameters */ - if (MV_OK != mvPexBarGet(pexIf, bar, &barDecWin)) - { - mvOsPrintf("pexBarOverlapDetect: ERR. TargetWinGet failed\n"); - return MV_ERROR; - } - - /* don'nt check disabled bars */ - if (barDecWin.enable == MV_FALSE) - { - continue; - } - - - if(MV_TRUE == ctrlWinOverlapTest(pAddrWin, &barDecWin.addrWin)) - { - mvOsPrintf("pexBarOverlapDetect: winNum %d overlap current %d\n", - barNum, bar); - return MV_TRUE; - } - } - - return MV_FALSE; -} - -/******************************************************************************* -* pexBarIsValid - Check if the given address window is valid -* -* DESCRIPTION: -* PEX spec restrict BAR base to be aligned to BAR size. -* This function checks if the given address window is valid. -* -* INPUT: -* baseLow - 32bit low base address. -* size - Window size. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_TRUE if the address window is valid, MV_FALSE otherwise. -* -*******************************************************************************/ -static MV_STATUS pexBarIsValid(MV_U32 baseLow, MV_U32 size) -{ - - /* PCI spec restrict BAR base to be aligned to BAR size */ - if(MV_IS_NOT_ALIGN(baseLow, size)) - { - return MV_ERROR; - } - else - { - return MV_TRUE; - } - - return MV_TRUE; -} - -/******************************************************************************* -* pexBarRegInfoGet - Get BAR register information -* -* DESCRIPTION: -* PEX BARs registers offsets are inconsecutive. -* This function gets a PEX BAR register information like register offsets -* and function location of the BAR. -* -* INPUT: -* pexIf - PEX interface number. -* bar - The PEX BAR in question. -* -* OUTPUT: -* pBarRegInfo - BAR register info struct. -* -* RETURN: -* MV_BAD_PARAM when bad parameters ,MV_ERROR on error ,othewise MV_OK -* -*******************************************************************************/ -static MV_STATUS pexWinRegInfoGet(MV_U32 pexIf, - MV_U32 winNum, - PEX_WIN_REG_INFO *pWinRegInfo) -{ - - if ((winNum >= 0)&&(winNum <=3)) - { - pWinRegInfo->baseLowRegOffs = PEX_WIN0_3_BASE_REG(pexIf,winNum); - pWinRegInfo->baseHighRegOffs = 0; - pWinRegInfo->sizeRegOffs = PEX_WIN0_3_CTRL_REG(pexIf,winNum); - pWinRegInfo->remapLowRegOffs = PEX_WIN0_3_REMAP_REG(pexIf,winNum); - pWinRegInfo->remapHighRegOffs = 0; - } - else if ((winNum >= 4)&&(winNum <=5)) - { - pWinRegInfo->baseLowRegOffs = PEX_WIN4_5_BASE_REG(pexIf,winNum); - pWinRegInfo->baseHighRegOffs = 0; - pWinRegInfo->sizeRegOffs = PEX_WIN4_5_CTRL_REG(pexIf,winNum); - pWinRegInfo->remapLowRegOffs = PEX_WIN4_5_REMAP_REG(pexIf,winNum); - pWinRegInfo->remapHighRegOffs = PEX_WIN4_5_REMAP_HIGH_REG(pexIf,winNum); - - } - else if (MV_PEX_WIN_DEFAULT == winNum) - { - pWinRegInfo->baseLowRegOffs = 0; - pWinRegInfo->baseHighRegOffs = 0; - pWinRegInfo->sizeRegOffs = PEX_WIN_DEFAULT_CTRL_REG(pexIf); - pWinRegInfo->remapLowRegOffs = 0; - pWinRegInfo->remapHighRegOffs = 0; - } - else if (MV_PEX_WIN_EXP_ROM == winNum) - { - pWinRegInfo->baseLowRegOffs = 0; - pWinRegInfo->baseHighRegOffs = 0; - pWinRegInfo->sizeRegOffs = PEX_WIN_EXP_ROM_CTRL_REG(pexIf); - pWinRegInfo->remapLowRegOffs = PEX_WIN_EXP_ROM_REMAP_REG(pexIf); - pWinRegInfo->remapHighRegOffs = 0; - - } - - return MV_OK; -} - -/******************************************************************************* -* pexBarNameGet - Get the string name of PEX BAR. -* -* DESCRIPTION: -* This function get the string name of PEX BAR. -* -* INPUT: -* bar - PEX bar number. -* -* OUTPUT: -* None. -* -* RETURN: -* pointer to the string name of PEX BAR. -* -*******************************************************************************/ -const MV_8* pexBarNameGet( MV_U32 bar ) -{ - switch( bar ) - { - case PEX_INTER_REGS_BAR: - return "Internal Regs Bar0...."; - case PEX_DRAM_BAR: - return "DRAM Bar1............."; - case PEX_DEVICE_BAR: - return "Devices Bar2.........."; - default: - return "Bar unknown"; - } -} -/******************************************************************************* -* mvPexAddrDecShow - Print the PEX address decode map (BARs and windows). -* -* DESCRIPTION: -* This function print the PEX address decode map (BARs and windows). -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_VOID mvPexAddrDecShow(MV_VOID) -{ - MV_PEX_BAR pexBar; - MV_PEX_DEC_WIN win; - MV_U32 pexIf; - MV_U32 bar,winNum; - - for( pexIf = 0; pexIf < mvCtrlPexMaxIfGet(); pexIf++ ) - { - if (MV_FALSE == mvCtrlPwrClckGet(PEX_UNIT_ID, pexIf)) continue; - mvOsOutput( "\n" ); - mvOsOutput( "PEX%d:\n", pexIf ); - mvOsOutput( "-----\n" ); - - mvOsOutput( "\nPex Bars \n\n"); - - for( bar = 0; bar < PEX_MAX_BARS; bar++ ) - { - memset( &pexBar, 0, sizeof(MV_PEX_BAR) ); - - mvOsOutput( "%s ", pexBarNameGet(bar) ); - - if( mvPexBarGet( pexIf, bar, &pexBar ) == MV_OK ) - { - if( pexBar.enable ) - { - mvOsOutput( "base %08x, ", pexBar.addrWin.baseLow ); - mvSizePrint( pexBar.addrWin.size ); - mvOsOutput( "\n" ); - } - else - mvOsOutput( "disable\n" ); - } - } - mvOsOutput( "\nPex Decode Windows\n\n"); - - for( winNum = 0; winNum < PEX_MAX_TARGET_WIN - 2; winNum++) - { - memset( &win, 0,sizeof(MV_PEX_DEC_WIN) ); - - mvOsOutput( "win%d - ", winNum ); - - if ( mvPexTargetWinGet(pexIf,winNum,&win) == MV_OK) - { - if (win.enable) - { - mvOsOutput( "%s base %08x, ", - mvCtrlTargetNameGet(win.target), win.addrWin.baseLow ); - mvOsOutput( "...." ); - mvSizePrint( win.addrWin.size ); - - mvOsOutput( "\n" ); - } - else - mvOsOutput( "disable\n" ); - - - } - } - - memset( &win, 0,sizeof(MV_PEX_DEC_WIN) ); - - mvOsOutput( "default win - " ); - - if ( mvPexTargetWinGet(pexIf, MV_PEX_WIN_DEFAULT, &win) == MV_OK) - { - mvOsOutput( "%s ", - mvCtrlTargetNameGet(win.target) ); - mvOsOutput( "\n" ); - } - memset( &win, 0,sizeof(MV_PEX_DEC_WIN) ); - - mvOsOutput( "Expansion ROM - " ); - - if ( mvPexTargetWinGet(pexIf, MV_PEX_WIN_EXP_ROM, &win) == MV_OK) - { - mvOsOutput( "%s ", - mvCtrlTargetNameGet(win.target) ); - mvOsOutput( "\n" ); - } - - } -} - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysPex.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysPex.h deleted file mode 100644 index 3505613..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysPex.h +++ /dev/null @@ -1,348 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCSysPEXH -#define __INCSysPEXH - -#include "mvCommon.h" -#include "ctrlEnv/sys/mvCpuIf.h" -#include "ctrlEnv/mvCtrlEnvLib.h" -#include "ctrlEnv/mvCtrlEnvAddrDec.h" - -/* 4KB granularity */ -#define MINIMUM_WINDOW_SIZE 0x1000 -#define MINIMUM_BAR_SIZE 0x1000 -#define MINIMUM_BAR_SIZE_MASK 0xFFFFF000 -#define BAR_SIZE_OFFS 12 -#define BAR_SIZE_MASK (0xFFFFF << BAR_SIZE_OFFS) - - - -#define MV_PEX_WIN_DEFAULT 6 -#define MV_PEX_WIN_EXP_ROM 7 -#define PEX_MAX_TARGET_WIN 8 - - -#define PEX_MAX_BARS 3 -#define PEX_INTER_REGS_BAR 0 -#define PEX_DRAM_BAR 1 -#define PEX_DEVICE_BAR 2 - -/*************************************/ -/* PCI Express BAR Control Registers */ -/*************************************/ -#define PEX_BAR_CTRL_REG(pexIf,bar) (0x41804 + (bar-1)*4- (pexIf)*0x10000) -#define PEX_EXP_ROM_BAR_CTRL_REG(pexIf) (0x4180C - (pexIf)*0x10000) - - -/* PCI Express BAR Control Register */ -/* PEX_BAR_CTRL_REG (PXBCR) */ - -#define PXBCR_BAR_EN BIT0 -#define PXBCR_BAR_SIZE_OFFS 16 -#define PXBCR_BAR_SIZE_MASK (0xffff << PXBCR_BAR_SIZE_OFFS) -#define PXBCR_BAR_SIZE_ALIGNMENT 0x10000 - - - -/* PCI Express Expansion ROM BAR Control Register */ -/* PEX_EXP_ROM_BAR_CTRL_REG (PXERBCR) */ - -#define PXERBCR_EXPROM_EN BIT0 -#define PXERBCR_EXPROMSZ_OFFS 19 -#define PXERBCR_EXPROMSZ_MASK (0xf << PXERBCR_EXPROMSZ_OFFS) -#define PXERBCR_EXPROMSZ_512KB (0x0 << PXERBCR_EXPROMSZ_OFFS) -#define PXERBCR_EXPROMSZ_1024KB (0x1 << PXERBCR_EXPROMSZ_OFFS) -#define PXERBCR_EXPROMSZ_2048KB (0x3 << PXERBCR_EXPROMSZ_OFFS) -#define PXERBCR_EXPROMSZ_4096KB (0x7 << PXERBCR_EXPROMSZ_OFFS) - -/************************************************/ -/* PCI Express Address Window Control Registers */ -/************************************************/ -#define PEX_WIN0_3_CTRL_REG(pexIf,winNum) \ - (0x41820 + (winNum) * 0x10 - (pexIf) * 0x10000) -#define PEX_WIN0_3_BASE_REG(pexIf,winNum) \ - (0x41824 + (winNum) * 0x10 - (pexIf) * 0x10000) -#define PEX_WIN0_3_REMAP_REG(pexIf,winNum) \ - (0x4182C + (winNum) * 0x10 - (pexIf) * 0x10000) -#define PEX_WIN4_5_CTRL_REG(pexIf,winNum) \ - (0x41860 + (winNum - 4) * 0x20 - (pexIf) * 0x10000) -#define PEX_WIN4_5_BASE_REG(pexIf,winNum) \ - (0x41864 + (winNum - 4) * 0x20 - (pexIf) * 0x10000) -#define PEX_WIN4_5_REMAP_REG(pexIf,winNum) \ - (0x4186C + (winNum - 4) * 0x20 - (pexIf) * 0x10000) -#define PEX_WIN4_5_REMAP_HIGH_REG(pexIf,winNum) \ - (0x41870 + (winNum - 4) * 0x20 - (pexIf) * 0x10000) - -#define PEX_WIN_DEFAULT_CTRL_REG(pexIf) (0x418B0 - (pexIf) * 0x10000) -#define PEX_WIN_EXP_ROM_CTRL_REG(pexIf) (0x418C0 - (pexIf) * 0x10000) -#define PEX_WIN_EXP_ROM_REMAP_REG(pexIf) (0x418C4 - (pexIf) * 0x10000) - -/* PCI Express Window Control Register */ -/* PEX_WIN_CTRL_REG (PXWCR) */ - -#define PXWCR_WIN_EN BIT0 /* Window Enable.*/ - -#define PXWCR_WIN_BAR_MAP_OFFS 1 /* Mapping to BAR.*/ -#define PXWCR_WIN_BAR_MAP_MASK BIT1 -#define PXWCR_WIN_BAR_MAP_BAR1 (0 << PXWCR_WIN_BAR_MAP_OFFS) -#define PXWCR_WIN_BAR_MAP_BAR2 (1 << PXWCR_WIN_BAR_MAP_OFFS) - -#define PXWCR_TARGET_OFFS 4 /*Unit ID */ -#define PXWCR_TARGET_MASK (0xf << PXWCR_TARGET_OFFS) - -#define PXWCR_ATTRIB_OFFS 8 /* target attributes */ -#define PXWCR_ATTRIB_MASK (0xff << PXWCR_ATTRIB_OFFS) - -#define PXWCR_SIZE_OFFS 16 /* size */ -#define PXWCR_SIZE_MASK (0xffff << PXWCR_SIZE_OFFS) -#define PXWCR_SIZE_ALIGNMENT 0x10000 - -/* PCI Express Window Base Register */ -/* PEX_WIN_BASE_REG (PXWBR)*/ - -#define PXWBR_BASE_OFFS 16 /* address[31:16] */ -#define PXWBR_BASE_MASK (0xffff << PXWBR_BASE_OFFS) -#define PXWBR_BASE_ALIGNMENT 0x10000 - -/* PCI Express Window Remap Register */ -/* PEX_WIN_REMAP_REG (PXWRR)*/ - -#define PXWRR_REMAP_EN BIT0 -#define PXWRR_REMAP_OFFS 16 -#define PXWRR_REMAP_MASK (0xffff << PXWRR_REMAP_OFFS) -#define PXWRR_REMAP_ALIGNMENT 0x10000 - -/* PCI Express Window Remap (High) Register */ -/* PEX_WIN_REMAP_HIGH_REG (PXWRHR)*/ - -#define PXWRHR_REMAP_HIGH_OFFS 0 -#define PXWRHR_REMAP_HIGH_MASK (0xffffffff << PXWRHR_REMAP_HIGH_OFFS) - -/* PCI Express Default Window Control Register */ -/* PEX_WIN_DEFAULT_CTRL_REG (PXWDCR) */ - -#define PXWDCR_TARGET_OFFS 4 /*Unit ID */ -#define PXWDCR_TARGET_MASK (0xf << PXWDCR_TARGET_OFFS) -#define PXWDCR_ATTRIB_OFFS 8 /* target attributes */ -#define PXWDCR_ATTRIB_MASK (0xff << PXWDCR_ATTRIB_OFFS) - -/* PCI Express Expansion ROM Window Control Register */ -/* PEX_WIN_EXP_ROM_CTRL_REG (PXWERCR)*/ - -#define PXWERCR_TARGET_OFFS 4 /*Unit ID */ -#define PXWERCR_TARGET_MASK (0xf << PXWERCR_TARGET_OFFS) -#define PXWERCR_ATTRIB_OFFS 8 /* target attributes */ -#define PXWERCR_ATTRIB_MASK (0xff << PXWERCR_ATTRIB_OFFS) - -/* PCI Express Expansion ROM Window Remap Register */ -/* PEX_WIN_EXP_ROM_REMAP_REG (PXWERRR)*/ - -#define PXWERRR_REMAP_EN BIT0 -#define PXWERRR_REMAP_OFFS 16 -#define PXWERRR_REMAP_MASK (0xffff << PXWERRR_REMAP_OFFS) -#define PXWERRR_REMAP_ALIGNMENT 0x10000 - - - -/*PEX_MEMORY_BAR_BASE_ADDR(barNum) (PXMBBA)*/ -/* PCI Express BAR0 Internal Register*/ -/*PEX BAR0_INTER_REG (PXBIR)*/ - -#define PXBIR_IOSPACE BIT0 /* Memory Space Indicator */ - -#define PXBIR_TYPE_OFFS 1 /* BAR Type/Init Val. */ -#define PXBIR_TYPE_MASK (0x3 << PXBIR_TYPE_OFFS) -#define PXBIR_TYPE_32BIT_ADDR (0x0 << PXBIR_TYPE_OFFS) -#define PXBIR_TYPE_64BIT_ADDR (0x2 << PXBIR_TYPE_OFFS) - -#define PXBIR_PREFETCH_EN BIT3 /* Prefetch Enable */ - -#define PXBIR_BASE_OFFS 20 /* Base address. Address bits [31:20] */ -#define PXBIR_BASE_MASK (0xfff << PXBIR_BASE_OFFS) -#define PXBIR_BASE_ALIGNMET (1 << PXBIR_BASE_OFFS) - - -/* PCI Express BAR0 Internal (High) Register*/ -/*PEX BAR0_INTER_REG_HIGH (PXBIRH)*/ - -#define PXBIRH_BASE_OFFS 0 /* Base address. Bits [63:32] */ -#define PXBIRH_BASE_MASK (0xffffffff << PBBHR_BASE_OFFS) - - -#define PEX_BAR_DEFAULT_ATTRIB 0xc /* Memory - Prefetch - 64 bit address */ -#define PEX_BAR0_DEFAULT_ATTRIB PEX_BAR_DEFAULT_ATTRIB -#define PEX_BAR1_DEFAULT_ATTRIB PEX_BAR_DEFAULT_ATTRIB -#define PEX_BAR2_DEFAULT_ATTRIB PEX_BAR_DEFAULT_ATTRIB - - -/* PCI Express BAR1 Register */ -/* PCI Express BAR2 Register*/ -/*PEX BAR1_REG (PXBR)*/ -/*PEX BAR2_REG (PXBR)*/ - -#define PXBR_IOSPACE BIT0 /* Memory Space Indicator */ - -#define PXBR_TYPE_OFFS 1 /* BAR Type/Init Val. */ -#define PXBR_TYPE_MASK (0x3 << PXBR_TYPE_OFFS) -#define PXBR_TYPE_32BIT_ADDR (0x0 << PXBR_TYPE_OFFS) -#define PXBR_TYPE_64BIT_ADDR (0x2 << PXBR_TYPE_OFFS) - -#define PXBR_PREFETCH_EN BIT3 /* Prefetch Enable */ - -#define PXBR_BASE_OFFS 16 /* Base address. Address bits [31:16] */ -#define PXBR_BASE_MASK (0xffff << PXBR_BASE_OFFS) -#define PXBR_BASE_ALIGNMET (1 << PXBR_BASE_OFFS) - - -/* PCI Express BAR1 (High) Register*/ -/* PCI Express BAR2 (High) Register*/ -/*PEX BAR1_REG_HIGH (PXBRH)*/ -/*PEX BAR2_REG_HIGH (PXBRH)*/ - -#define PXBRH_BASE_OFFS 0 /* Base address. Address bits [63:32] */ -#define PXBRH_BASE_MASK (0xffffffff << PXBRH_BASE_OFFS) - -/* PCI Express Expansion ROM BAR Register*/ -/*PEX_EXPANSION_ROM_BASE_ADDR_REG (PXERBAR)*/ - -#define PXERBAR_EXPROMEN BIT0 /* Expansion ROM Enable */ - -#define PXERBAR_BASE_512K_OFFS 19 /* Expansion ROM Base Address */ -#define PXERBAR_BASE_512K_MASK (0x1fff << PXERBAR_BASE_512K_OFFS) - -#define PXERBAR_BASE_1MB_OFFS 20 /* Expansion ROM Base Address */ -#define PXERBAR_BASE_1MB_MASK (0xfff << PXERBAR_BASE_1MB_OFFS) - -#define PXERBAR_BASE_2MB_OFFS 21 /* Expansion ROM Base Address */ -#define PXERBAR_BASE_2MB_MASK (0x7ff << PXERBAR_BASE_2MB_OFFS) - -#define PXERBAR_BASE_4MB_OFFS 22 /* Expansion ROM Base Address */ -#define PXERBAR_BASE_4MB_MASK (0x3ff << PXERBAR_BASE_4MB_OFFS) - -/* PEX Bar attributes */ -typedef struct _mvPexBar -{ - MV_ADDR_WIN addrWin; /* An address window*/ - MV_BOOL enable; /* Address decode window is enabled/disabled */ - -}MV_PEX_BAR; - -/* PEX Remap Window attributes */ -typedef struct _mvPexRemapWin -{ - MV_ADDR_WIN addrWin; /* An address window*/ - MV_BOOL enable; /* Address decode window is enabled/disabled */ - -}MV_PEX_REMAP_WIN; - -/* PEX Remap Window attributes */ -typedef struct _mvPexDecWin -{ - MV_TARGET target; - MV_ADDR_WIN addrWin; /* An address window*/ - MV_U32 targetBar; - MV_U8 attrib; /* chip select attributes */ - MV_TARGET_ID targetId; /* Target Id of this MV_TARGET */ - MV_BOOL enable; /* Address decode window is enabled/disabled */ - -}MV_PEX_DEC_WIN; - -/* Global Functions prototypes */ -/* mvPexHalInit - Initialize PEX interfaces*/ -MV_STATUS mvPexInit(MV_U32 pexIf, MV_PEX_TYPE pexType); - - -/* mvPexTargetWinSet - Set PEX to peripheral target address window BAR*/ -MV_STATUS mvPexTargetWinSet(MV_U32 pexIf, MV_U32 winNum, - MV_PEX_DEC_WIN *pAddrDecWin); - -/* mvPexTargetWinGet - Get PEX to peripheral target address window*/ -MV_STATUS mvPexTargetWinGet(MV_U32 pexIf, MV_U32 winNum, - MV_PEX_DEC_WIN *pAddrDecWin); - -/* mvPexTargetWinEnable - Enable/disable a PEX BAR window*/ -MV_STATUS mvPexTargetWinEnable(MV_U32 pexIf,MV_U32 winNum, MV_BOOL enable); - -/* mvPexTargetWinRemap - Set PEX to target address window remap.*/ -MV_STATUS mvPexTargetWinRemap(MV_U32 pexIf, MV_U32 winNum, - MV_PEX_REMAP_WIN *pAddrWin); - -/* mvPexTargetWinRemapEnable -enable\disable a PEX Window remap.*/ -MV_STATUS mvPexTargetWinRemapEnable(MV_U32 pexIf, MV_U32 winNum, - MV_BOOL enable); - -/* mvPexBarSet - Set PEX bar address and size */ -MV_STATUS mvPexBarSet(MV_U32 pexIf, MV_U32 barNum, MV_PEX_BAR *addrWin); - -/* mvPexBarGet - Get PEX bar address and size */ -MV_STATUS mvPexBarGet(MV_U32 pexIf, MV_U32 barNum, MV_PEX_BAR *addrWin); - -/* mvPexBarEnable - enable\disable a PEX bar*/ -MV_STATUS mvPexBarEnable(MV_U32 pexIf, MV_U32 barNum, MV_BOOL enable); - -/* mvPexAddrDecShow - Display address decode windows attributes */ -MV_VOID mvPexAddrDecShow(MV_VOID); - -#endif diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysSata.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysSata.c deleted file mode 100644 index f100a12..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysSata.c +++ /dev/null @@ -1,430 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -#include "mvTypes.h" -#include "mvCommon.h" -#include "mvOs.h" -#include "ctrlEnv/mvCtrlEnvLib.h" -#include "cpu/mvCpu.h" -#include "ctrlEnv/sys/mvCpuIf.h" -#include "sata/CoreDriver/mvRegs.h" -#include "ctrlEnv/sys/mvSysSata.h" - -MV_TARGET sataAddrDecPrioTab[] = -{ -#if defined(MV_INCLUDE_SDRAM_CS0) - SDRAM_CS0, -#endif -#if defined(MV_INCLUDE_SDRAM_CS1) - SDRAM_CS1, -#endif -#if defined(MV_INCLUDE_SDRAM_CS2) - SDRAM_CS2, -#endif -#if defined(MV_INCLUDE_SDRAM_CS3) - SDRAM_CS3, -#endif -#if defined(MV_INCLUDE_PEX) - PEX0_MEM, -#endif - TBL_TERM -}; - - -/******************************************************************************* -* sataWinOverlapDetect - Detect SATA address windows overlapping -* -* DESCRIPTION: -* An unpredicted behaviur is expected in case SATA address decode -* windows overlapps. -* This function detects SATA address decode windows overlapping of a -* specified window. The function does not check the window itself for -* overlapping. The function also skipps disabled address decode windows. -* -* INPUT: -* winNum - address decode window number. -* pAddrDecWin - An address decode window struct. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_TRUE if the given address window overlap current address -* decode map, MV_FALSE otherwise, MV_ERROR if reading invalid data -* from registers. -* -*******************************************************************************/ -static MV_STATUS sataWinOverlapDetect(int dev, MV_U32 winNum, - MV_ADDR_WIN *pAddrWin) -{ - MV_U32 winNumIndex; - MV_SATA_DEC_WIN addrDecWin; - - for(winNumIndex=0; winNumIndex<MV_SATA_MAX_ADDR_DECODE_WIN; winNumIndex++) - { - /* Do not check window itself */ - if (winNumIndex == winNum) - { - continue; - } - - /* Get window parameters */ - if (MV_OK != mvSataWinGet(dev, winNumIndex, &addrDecWin)) - { - mvOsPrintf("%s: ERR. TargetWinGet failed\n", __FUNCTION__); - return MV_ERROR; - } - - /* Do not check disabled windows */ - if(addrDecWin.enable == MV_FALSE) - { - continue; - } - - if (MV_TRUE == ctrlWinOverlapTest(pAddrWin, &(addrDecWin.addrWin))) - { - return MV_TRUE; - } - } - return MV_FALSE; -} - - -/******************************************************************************* -* mvSataWinSet - Set SATA target address window -* -* DESCRIPTION: -* This function sets a peripheral target (e.g. SDRAM bank0, PCI_MEM0) -* address window, also known as address decode window. -* After setting this target window, the SATA will be able to access the -* target within the address window. -* -* INPUT: -* winNum - SATA target address decode window number. -* pAddrDecWin - SATA target window data structure. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_ERROR if address window overlapps with other address decode windows. -* MV_BAD_PARAM if base address is invalid parameter or target is -* unknown. -* -*******************************************************************************/ -MV_STATUS mvSataWinSet(int dev, MV_U32 winNum, MV_SATA_DEC_WIN *pAddrDecWin) -{ - MV_TARGET_ATTRIB targetAttribs; - MV_DEC_REGS decRegs; - - /* Parameter checking */ - if (winNum >= MV_SATA_MAX_ADDR_DECODE_WIN) - { - mvOsPrintf("%s: ERR. Invalid win num %d\n",__FUNCTION__, winNum); - return MV_BAD_PARAM; - } - - /* Check if the requested window overlapps with current windows */ - if (MV_TRUE == sataWinOverlapDetect(dev, winNum, &pAddrDecWin->addrWin)) - { - mvOsPrintf("%s: ERR. Window %d overlap\n", __FUNCTION__, winNum); - return MV_ERROR; - } - - /* check if address is aligned to the size */ - if(MV_IS_NOT_ALIGN(pAddrDecWin->addrWin.baseLow, pAddrDecWin->addrWin.size)) - { - mvOsPrintf("mvSataWinSet:Error setting SATA window %d to "\ - "target %s.\nAddress 0x%08x is unaligned to size 0x%x.\n", - winNum, - mvCtrlTargetNameGet(pAddrDecWin->target), - pAddrDecWin->addrWin.baseLow, - pAddrDecWin->addrWin.size); - return MV_ERROR; - } - - decRegs.baseReg = 0; - decRegs.sizeReg = 0; - - if (MV_OK != mvCtrlAddrDecToReg(&(pAddrDecWin->addrWin),&decRegs)) - { - mvOsPrintf("%s: mvCtrlAddrDecToReg Failed\n", __FUNCTION__); - return MV_ERROR; - } - - mvCtrlAttribGet(pAddrDecWin->target, &targetAttribs); - - /* set attributes */ - decRegs.sizeReg &= ~MV_SATA_WIN_ATTR_MASK; - decRegs.sizeReg |= (targetAttribs.attrib << MV_SATA_WIN_ATTR_OFFSET); - - /* set target ID */ - decRegs.sizeReg &= ~MV_SATA_WIN_TARGET_MASK; - decRegs.sizeReg |= (targetAttribs.targetId << MV_SATA_WIN_TARGET_OFFSET); - - if (pAddrDecWin->enable == MV_TRUE) - { - decRegs.sizeReg |= MV_SATA_WIN_ENABLE_MASK; - } - else - { - decRegs.sizeReg &= ~MV_SATA_WIN_ENABLE_MASK; - } - - MV_REG_WRITE( MV_SATA_WIN_CTRL_REG(dev, winNum), decRegs.sizeReg); - MV_REG_WRITE( MV_SATA_WIN_BASE_REG(dev, winNum), decRegs.baseReg); - - return MV_OK; -} - -/******************************************************************************* -* mvSataWinGet - Get SATA peripheral target address window. -* -* DESCRIPTION: -* Get SATA peripheral target address window. -* -* INPUT: -* winNum - SATA target address decode window number. -* -* OUTPUT: -* pAddrDecWin - SATA target window data structure. -* -* RETURN: -* MV_ERROR if register parameters are invalid. -* -*******************************************************************************/ -MV_STATUS mvSataWinGet(int dev, MV_U32 winNum, MV_SATA_DEC_WIN *pAddrDecWin) -{ - MV_DEC_REGS decRegs; - MV_TARGET_ATTRIB targetAttrib; - - /* Parameter checking */ - if (winNum >= MV_SATA_MAX_ADDR_DECODE_WIN) - { - mvOsPrintf("%s (dev=%d): ERR. Invalid winNum %d\n", - __FUNCTION__, dev, winNum); - return MV_NOT_SUPPORTED; - } - - decRegs.baseReg = MV_REG_READ( MV_SATA_WIN_BASE_REG(dev, winNum) ); - decRegs.sizeReg = MV_REG_READ( MV_SATA_WIN_CTRL_REG(dev, winNum) ); - - if (MV_OK != mvCtrlRegToAddrDec(&decRegs, &pAddrDecWin->addrWin) ) - { - mvOsPrintf("%s: mvCtrlRegToAddrDec Failed\n", __FUNCTION__); - return MV_ERROR; - } - - /* attrib and targetId */ - targetAttrib.attrib = (decRegs.sizeReg & MV_SATA_WIN_ATTR_MASK) >> - MV_SATA_WIN_ATTR_OFFSET; - targetAttrib.targetId = (decRegs.sizeReg & MV_SATA_WIN_TARGET_MASK) >> - MV_SATA_WIN_TARGET_OFFSET; - - pAddrDecWin->target = mvCtrlTargetGet(&targetAttrib); - - /* Check if window is enabled */ - if(decRegs.sizeReg & MV_SATA_WIN_ENABLE_MASK) - { - pAddrDecWin->enable = MV_TRUE; - } - else - { - pAddrDecWin->enable = MV_FALSE; - } - return MV_OK; -} -/******************************************************************************* -* mvSataAddrDecShow - Print the SATA address decode map. -* -* DESCRIPTION: -* This function print the SATA address decode map. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_VOID mvSataAddrDecShow(MV_VOID) -{ - - MV_SATA_DEC_WIN win; - int i,j; - - - - for( j = 0; j < MV_SATA_MAX_CHAN; j++ ) - { - if (MV_FALSE == mvCtrlPwrClckGet(SATA_UNIT_ID, j)) - return; - - mvOsOutput( "\n" ); - mvOsOutput( "SATA %d:\n", j ); - mvOsOutput( "----\n" ); - - for( i = 0; i < MV_SATA_MAX_ADDR_DECODE_WIN; i++ ) - { - memset( &win, 0, sizeof(MV_SATA_DEC_WIN) ); - - mvOsOutput( "win%d - ", i ); - - if( mvSataWinGet(j, i, &win ) == MV_OK ) - { - if( win.enable ) - { - mvOsOutput( "%s base %08x, ", - mvCtrlTargetNameGet(win.target), win.addrWin.baseLow ); - mvOsOutput( "...." ); - - mvSizePrint( win.addrWin.size ); - - mvOsOutput( "\n" ); - } - else - mvOsOutput( "disable\n" ); - } - } - } -} - - -/******************************************************************************* -* mvSataWinInit - Initialize the integrated SATA target address window. -* -* DESCRIPTION: -* Initialize the SATA peripheral target address window. -* -* INPUT: -* -* -* OUTPUT: -* -* -* RETURN: -* MV_ERROR if register parameters are invalid. -* -*******************************************************************************/ -MV_STATUS mvSataWinInit(MV_VOID) -{ - int winNum; - MV_SATA_DEC_WIN sataWin; - MV_CPU_DEC_WIN cpuAddrDecWin; - MV_U32 status, winPrioIndex = 0; - - /* Initiate Sata address decode */ - - /* First disable all address decode windows */ - for(winNum = 0; winNum < MV_SATA_MAX_ADDR_DECODE_WIN; winNum++) - { - MV_U32 regVal = MV_REG_READ(MV_SATA_WIN_CTRL_REG(0, winNum)); - regVal &= ~MV_SATA_WIN_ENABLE_MASK; - MV_REG_WRITE(MV_SATA_WIN_CTRL_REG(0, winNum), regVal); - } - - winNum = 0; - while( (sataAddrDecPrioTab[winPrioIndex] != TBL_TERM) && - (winNum < MV_SATA_MAX_ADDR_DECODE_WIN) ) - { - /* first get attributes from CPU If */ - status = mvCpuIfTargetWinGet(sataAddrDecPrioTab[winPrioIndex], - &cpuAddrDecWin); - - if(MV_NO_SUCH == status) - { - winPrioIndex++; - continue; - } - if (MV_OK != status) - { - mvOsPrintf("%s: ERR. mvCpuIfTargetWinGet failed\n", __FUNCTION__); - return MV_ERROR; - } - - if (cpuAddrDecWin.enable == MV_TRUE) - { - sataWin.addrWin.baseHigh = cpuAddrDecWin.addrWin.baseHigh; - sataWin.addrWin.baseLow = cpuAddrDecWin.addrWin.baseLow; - sataWin.addrWin.size = cpuAddrDecWin.addrWin.size; - sataWin.enable = MV_TRUE; - sataWin.target = sataAddrDecPrioTab[winPrioIndex]; - - if(MV_OK != mvSataWinSet(0/*dev*/, winNum, &sataWin)) - { - return MV_ERROR; - } - winNum++; - } - winPrioIndex++; - } - return MV_OK; -} - - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysSata.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysSata.h deleted file mode 100644 index 611f577..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysSata.h +++ /dev/null @@ -1,128 +0,0 @@ - -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ -#ifndef __INCMVSysSataAddrDech -#define __INCMVSysSataAddrDech - -#include "mvCommon.h" -#include "ctrlEnv/mvCtrlEnvLib.h" -#include "ctrlEnv/sys/mvCpuIf.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct _mvSataDecWin -{ - MV_TARGET target; - MV_ADDR_WIN addrWin; /* An address window*/ - MV_BOOL enable; /* Address decode window is enabled/disabled */ - -} MV_SATA_DEC_WIN; - - -#define MV_SATA_MAX_ADDR_DECODE_WIN 4 - -#define MV_SATA_WIN_CTRL_REG(dev, win) (SATA_REG_BASE + 0x30 + ((win)<<4)) -#define MV_SATA_WIN_BASE_REG(dev, win) (SATA_REG_BASE + 0x34 + ((win)<<4)) - -/* BITs in Bridge Interrupt Cause and Mask registers */ -#define MV_SATA_ADDR_DECODE_ERROR_BIT 0 -#define MV_SATA_ADDR_DECODE_ERROR_MASK (1<<MV_SATA_ADDR_DECODE_ERROR_BIT) - -/* BITs in Windows 0-3 Control and Base Registers */ -#define MV_SATA_WIN_ENABLE_BIT 0 -#define MV_SATA_WIN_ENABLE_MASK (1<<MV_SATA_WIN_ENABLE_BIT) - -#define MV_SATA_WIN_TARGET_OFFSET 4 -#define MV_SATA_WIN_TARGET_MASK (0xF<<MV_SATA_WIN_TARGET_OFFSET) - -#define MV_SATA_WIN_ATTR_OFFSET 8 -#define MV_SATA_WIN_ATTR_MASK (0xFF<<MV_SATA_WIN_ATTR_OFFSET) - -#define MV_SATA_WIN_SIZE_OFFSET 16 -#define MV_SATA_WIN_SIZE_MASK (0xFFFF<<MV_SATA_WIN_SIZE_OFFSET) - -#define MV_SATA_WIN_BASE_OFFSET 16 -#define MV_SATA_WIN_BASE_MASK (0xFFFF<<MV_SATA_WIN_BASE_OFFSET) - -MV_STATUS mvSataWinGet(int dev, MV_U32 winNum, MV_SATA_DEC_WIN *pAddrDecWin); -MV_STATUS mvSataWinSet(int dev, MV_U32 winNum, MV_SATA_DEC_WIN *pAddrDecWin); -MV_STATUS mvSataWinByTargetGet(MV_TARGET target, MV_SATA_DEC_WIN *pAddrDecWin); -MV_STATUS mvSataWinInit(MV_VOID); -MV_VOID mvSataAddrDecShow(MV_VOID); - - -#ifdef __cplusplus -} -#endif - - -#endif - - - - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysSdmmc.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysSdmmc.c deleted file mode 100644 index 6d2a919..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysSdmmc.c +++ /dev/null @@ -1,427 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -#include "mvTypes.h" -#include "mvCommon.h" -#include "mvOs.h" -#include "ctrlEnv/mvCtrlEnvLib.h" -#include "cpu/mvCpu.h" -#include "ctrlEnv/sys/mvCpuIf.h" -#include "mvRegs.h" -#include "ctrlEnv/sys/mvSysSdmmc.h" - -MV_TARGET sdmmcAddrDecPrioTab[] = -{ -#if defined(MV_INCLUDE_SDRAM_CS0) - SDRAM_CS0, -#endif -#if defined(MV_INCLUDE_SDRAM_CS1) - SDRAM_CS1, -#endif -#if defined(MV_INCLUDE_SDRAM_CS2) - SDRAM_CS2, -#endif -#if defined(MV_INCLUDE_SDRAM_CS3) - SDRAM_CS3, -#endif -#if defined(MV_INCLUDE_PEX) - PEX0_MEM, -#endif - TBL_TERM -}; - - -/******************************************************************************* -* sdmmcWinOverlapDetect - Detect SDMMC address windows overlapping -* -* DESCRIPTION: -* An unpredicted behaviur is expected in case SDMMC address decode -* windows overlapps. -* This function detects SDMMC address decode windows overlapping of a -* specified window. The function does not check the window itself for -* overlapping. The function also skipps disabled address decode windows. -* -* INPUT: -* winNum - address decode window number. -* pAddrDecWin - An address decode window struct. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_TRUE if the given address window overlap current address -* decode map, MV_FALSE otherwise, MV_ERROR if reading invalid data -* from registers. -* -*******************************************************************************/ -static MV_STATUS sdmmcWinOverlapDetect(int dev, MV_U32 winNum, - MV_ADDR_WIN *pAddrWin) -{ - MV_U32 winNumIndex; - MV_SDMMC_DEC_WIN addrDecWin; - - for(winNumIndex=0; winNumIndex<MV_SDMMC_MAX_ADDR_DECODE_WIN; winNumIndex++) - { - /* Do not check window itself */ - if (winNumIndex == winNum) - { - continue; - } - - /* Get window parameters */ - if (MV_OK != mvSdmmcWinGet(dev, winNumIndex, &addrDecWin)) - { - mvOsPrintf("%s: ERR. TargetWinGet failed\n", __FUNCTION__); - return MV_ERROR; - } - - /* Do not check disabled windows */ - if(addrDecWin.enable == MV_FALSE) - { - continue; - } - - if (MV_TRUE == ctrlWinOverlapTest(pAddrWin, &(addrDecWin.addrWin))) - { - return MV_TRUE; - } - } - return MV_FALSE; -} - - -/******************************************************************************* -* mvSdmmcWinSet - Set SDMMC target address window -* -* DESCRIPTION: -* This function sets a peripheral target (e.g. SDRAM bank0, PCI_MEM0) -* address window, also known as address decode window. -* After setting this target window, the SDMMC will be able to access the -* target within the address window. -* -* INPUT: -* winNum - SDMMC target address decode window number. -* pAddrDecWin - SDMMC target window data structure. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_ERROR if address window overlapps with other address decode windows. -* MV_BAD_PARAM if base address is invalid parameter or target is -* unknown. -* -*******************************************************************************/ -MV_STATUS mvSdmmcWinSet(int dev, MV_U32 winNum, MV_SDMMC_DEC_WIN *pAddrDecWin) -{ - MV_TARGET_ATTRIB targetAttribs; - MV_DEC_REGS decRegs; - - /* Parameter checking */ - if (winNum >= MV_SDMMC_MAX_ADDR_DECODE_WIN) - { - mvOsPrintf("%s: ERR. Invalid win num %d\n",__FUNCTION__, winNum); - return MV_BAD_PARAM; - } - - /* Check if the requested window overlapps with current windows */ - if (MV_TRUE == sdmmcWinOverlapDetect(dev, winNum, &pAddrDecWin->addrWin)) - { - mvOsPrintf("%s: ERR. Window %d overlap\n", __FUNCTION__, winNum); - return MV_ERROR; - } - - /* check if address is aligned to the size */ - if(MV_IS_NOT_ALIGN(pAddrDecWin->addrWin.baseLow, pAddrDecWin->addrWin.size)) - { - mvOsPrintf("mvSdmmcWinSet:Error setting SDMMC window %d to "\ - "target %s.\nAddress 0x%08x is unaligned to size 0x%x.\n", - winNum, - mvCtrlTargetNameGet(pAddrDecWin->target), - pAddrDecWin->addrWin.baseLow, - pAddrDecWin->addrWin.size); - return MV_ERROR; - } - - decRegs.baseReg = 0; - decRegs.sizeReg = 0; - - if (MV_OK != mvCtrlAddrDecToReg(&(pAddrDecWin->addrWin),&decRegs)) - { - mvOsPrintf("%s: mvCtrlAddrDecToReg Failed\n", __FUNCTION__); - return MV_ERROR; - } - - mvCtrlAttribGet(pAddrDecWin->target, &targetAttribs); - - /* set attributes */ - decRegs.sizeReg &= ~MV_SDMMC_WIN_ATTR_MASK; - decRegs.sizeReg |= (targetAttribs.attrib << MV_SDMMC_WIN_ATTR_OFFSET); - - /* set target ID */ - decRegs.sizeReg &= ~MV_SDMMC_WIN_TARGET_MASK; - decRegs.sizeReg |= (targetAttribs.targetId << MV_SDMMC_WIN_TARGET_OFFSET); - - if (pAddrDecWin->enable == MV_TRUE) - { - decRegs.sizeReg |= MV_SDMMC_WIN_ENABLE_MASK; - } - else - { - decRegs.sizeReg &= ~MV_SDMMC_WIN_ENABLE_MASK; - } - - MV_REG_WRITE( MV_SDMMC_WIN_CTRL_REG(dev, winNum), decRegs.sizeReg); - MV_REG_WRITE( MV_SDMMC_WIN_BASE_REG(dev, winNum), decRegs.baseReg); - - return MV_OK; -} - -/******************************************************************************* -* mvSdmmcWinGet - Get SDMMC peripheral target address window. -* -* DESCRIPTION: -* Get SDMMC peripheral target address window. -* -* INPUT: -* winNum - SDMMC target address decode window number. -*d -* OUTPUT: -* pAddrDecWin - SDMMC target window data structure. -* -* RETURN: -* MV_ERROR if register parameters are invalid. -* -*******************************************************************************/ -MV_STATUS mvSdmmcWinGet(int dev, MV_U32 winNum, MV_SDMMC_DEC_WIN *pAddrDecWin) -{ - MV_DEC_REGS decRegs; - MV_TARGET_ATTRIB targetAttrib; - - /* Parameter checking */ - if (winNum >= MV_SDMMC_MAX_ADDR_DECODE_WIN) - { - mvOsPrintf("%s (dev=%d): ERR. Invalid winNum %d\n", - __FUNCTION__, dev, winNum); - return MV_NOT_SUPPORTED; - } - - decRegs.baseReg = MV_REG_READ( MV_SDMMC_WIN_BASE_REG(dev, winNum) ); - decRegs.sizeReg = MV_REG_READ( MV_SDMMC_WIN_CTRL_REG(dev, winNum) ); - - if (MV_OK != mvCtrlRegToAddrDec(&decRegs, &pAddrDecWin->addrWin) ) - { - mvOsPrintf("%s: mvCtrlRegToAddrDec Failed\n", __FUNCTION__); - return MV_ERROR; - } - - /* attrib and targetId */ - targetAttrib.attrib = (decRegs.sizeReg & MV_SDMMC_WIN_ATTR_MASK) >> - MV_SDMMC_WIN_ATTR_OFFSET; - targetAttrib.targetId = (decRegs.sizeReg & MV_SDMMC_WIN_TARGET_MASK) >> - MV_SDMMC_WIN_TARGET_OFFSET; - - pAddrDecWin->target = mvCtrlTargetGet(&targetAttrib); - - /* Check if window is enabled */ - if(decRegs.sizeReg & MV_SDMMC_WIN_ENABLE_MASK) - { - pAddrDecWin->enable = MV_TRUE; - } - else - { - pAddrDecWin->enable = MV_FALSE; - } - return MV_OK; -} -/******************************************************************************* -* mvSdmmcAddrDecShow - Print the SDMMC address decode map. -* -* DESCRIPTION: -* This function print the SDMMC address decode map. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_VOID mvSdmmcAddrDecShow(MV_VOID) -{ - - MV_SDMMC_DEC_WIN win; - int i,j=0; - - - - if (MV_FALSE == mvCtrlPwrClckGet(SDIO_UNIT_ID, 0)) - return; - - mvOsOutput( "\n" ); - mvOsOutput( "SDMMC %d:\n", j ); - mvOsOutput( "----\n" ); - - for( i = 0; i < MV_SDMMC_MAX_ADDR_DECODE_WIN; i++ ) - { - memset( &win, 0, sizeof(MV_SDMMC_DEC_WIN) ); - - mvOsOutput( "win%d - ", i ); - - if( mvSdmmcWinGet(j, i, &win ) == MV_OK ) - { - if( win.enable ) - { - mvOsOutput( "%s base %08x, ", - mvCtrlTargetNameGet(win.target), win.addrWin.baseLow ); - mvOsOutput( "...." ); - - mvSizePrint( win.addrWin.size ); - - mvOsOutput( "\n" ); - } - else - mvOsOutput( "disable\n" ); - } - } -} - - -/******************************************************************************* -* mvSdmmcWinInit - Initialize the integrated SDMMC target address window. -* -* DESCRIPTION: -* Initialize the SDMMC peripheral target address window. -* -* INPUT: -* -* -* OUTPUT: -* -* -* RETURN: -* MV_ERROR if register parameters are invalid. -* -*******************************************************************************/ -MV_STATUS mvSdmmcWinInit(MV_VOID) -{ - int winNum; - MV_SDMMC_DEC_WIN sdmmcWin; - MV_CPU_DEC_WIN cpuAddrDecWin; - MV_U32 status, winPrioIndex = 0; - - /* Initiate Sdmmc address decode */ - - /* First disable all address decode windows */ - for(winNum = 0; winNum < MV_SDMMC_MAX_ADDR_DECODE_WIN; winNum++) - { - MV_U32 regVal = MV_REG_READ(MV_SDMMC_WIN_CTRL_REG(0, winNum)); - regVal &= ~MV_SDMMC_WIN_ENABLE_MASK; - MV_REG_WRITE(MV_SDMMC_WIN_CTRL_REG(0, winNum), regVal); - } - - winNum = 0; - while( (sdmmcAddrDecPrioTab[winPrioIndex] != TBL_TERM) && - (winNum < MV_SDMMC_MAX_ADDR_DECODE_WIN) ) - { - /* first get attributes from CPU If */ - status = mvCpuIfTargetWinGet(sdmmcAddrDecPrioTab[winPrioIndex], - &cpuAddrDecWin); - - if(MV_NO_SUCH == status) - { - winPrioIndex++; - continue; - } - if (MV_OK != status) - { - mvOsPrintf("%s: ERR. mvCpuIfTargetWinGet failed\n", __FUNCTION__); - return MV_ERROR; - } - - if (cpuAddrDecWin.enable == MV_TRUE) - { - sdmmcWin.addrWin.baseHigh = cpuAddrDecWin.addrWin.baseHigh; - sdmmcWin.addrWin.baseLow = cpuAddrDecWin.addrWin.baseLow; - sdmmcWin.addrWin.size = cpuAddrDecWin.addrWin.size; - sdmmcWin.enable = MV_TRUE; - sdmmcWin.target = sdmmcAddrDecPrioTab[winPrioIndex]; - - if(MV_OK != mvSdmmcWinSet(0/*dev*/, winNum, &sdmmcWin)) - { - return MV_ERROR; - } - winNum++; - } - winPrioIndex++; - } - return MV_OK; -} - - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysSdmmc.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysSdmmc.h deleted file mode 100644 index c2f9f79..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysSdmmc.h +++ /dev/null @@ -1,125 +0,0 @@ - -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ -#ifndef __INCMVSysSdmmcAddrDech -#define __INCMVSysSdmmcAddrDech - -#include "mvCommon.h" -#include "ctrlEnv/mvCtrlEnvLib.h" -#include "ctrlEnv/sys/mvCpuIf.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct _mvSdmmcDecWin -{ - MV_TARGET target; - MV_ADDR_WIN addrWin; /* An address window*/ - MV_BOOL enable; /* Address decode window is enabled/disabled */ - -} MV_SDMMC_DEC_WIN; - - -#define MV_SDMMC_MAX_ADDR_DECODE_WIN 4 - -#define MV_SDMMC_WIN_CTRL_REG(dev, win) (MV_SDIO_REG_BASE + 0x108 + ((win)<<3)) -#define MV_SDMMC_WIN_BASE_REG(dev, win) (MV_SDIO_REG_BASE + 0x10c + ((win)<<3)) - - -/* BITs in Windows 0-3 Control and Base Registers */ -#define MV_SDMMC_WIN_ENABLE_BIT 0 -#define MV_SDMMC_WIN_ENABLE_MASK (1<<MV_SDMMC_WIN_ENABLE_BIT) - -#define MV_SDMMC_WIN_TARGET_OFFSET 4 -#define MV_SDMMC_WIN_TARGET_MASK (0xF<<MV_SDMMC_WIN_TARGET_OFFSET) - -#define MV_SDMMC_WIN_ATTR_OFFSET 8 -#define MV_SDMMC_WIN_ATTR_MASK (0xFF<<MV_SDMMC_WIN_ATTR_OFFSET) - -#define MV_SDMMC_WIN_SIZE_OFFSET 16 -#define MV_SDMMC_WIN_SIZE_MASK (0xFFFF<<MV_SDMMC_WIN_SIZE_OFFSET) - -#define MV_SDMMC_WIN_BASE_OFFSET 16 -#define MV_SDMMC_WIN_BASE_MASK (0xFFFF<<MV_SDMMC_WIN_BASE_OFFSET) - -MV_STATUS mvSdmmcWinGet(int dev, MV_U32 winNum, MV_SDMMC_DEC_WIN *pAddrDecWin); -MV_STATUS mvSdmmcWinSet(int dev, MV_U32 winNum, MV_SDMMC_DEC_WIN *pAddrDecWin); -MV_STATUS mvSdmmcWinByTargetGet(MV_TARGET target, MV_SDMMC_DEC_WIN *pAddrDecWin); -MV_STATUS mvSdmmcWinInit(MV_VOID); -MV_VOID mvSdmmcAddrDecShow(MV_VOID); - - -#ifdef __cplusplus -} -#endif - - -#endif - - - - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysTdm.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysTdm.c deleted file mode 100644 index 27b961a..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysTdm.c +++ /dev/null @@ -1,462 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#include "mvSysTdm.h" - - -/* defines */ -#ifdef MV_DEBUG - #define DB(x) x -#else - #define DB(x) -#endif - -static MV_TARGET tdmAddrDecPrioTap[] = -{ - PEX0_MEM, - SDRAM_CS0, - SDRAM_CS1, - SDRAM_CS2, - SDRAM_CS3, - DEVICE_CS0, - DEVICE_CS1, - DEVICE_CS2, - DEV_BOOCS, - PEX0_IO, - TBL_TERM -}; - -static MV_STATUS tdmWinOverlapDetect(MV_U32 winNum, MV_ADDR_WIN *pAddrWin); - -/******************************************************************************* -* mvTdmWinInit - Initialize TDM address decode windows -* -* DESCRIPTION: -* This function initialize TDM window decode unit. It set the -* default address decode -* windows of the unit. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_ERROR if setting fail. -*******************************************************************************/ - -MV_STATUS mvTdmWinInit(void) -{ - MV_U32 winNum; - MV_U32 winPrioIndex = 0; - MV_CPU_DEC_WIN cpuAddrDecWin; - MV_TDM_DEC_WIN tdmWin; - MV_STATUS status; - - /*Disable all windows*/ - for (winNum = 0; winNum < TDM_MBUS_MAX_WIN; winNum++) - { - mvTdmWinEnable(winNum, MV_FALSE); - } - - for (winNum = 0; ((tdmAddrDecPrioTap[winPrioIndex] != TBL_TERM) && - (winNum < TDM_MBUS_MAX_WIN)); ) - { - status = mvCpuIfTargetWinGet(tdmAddrDecPrioTap[winPrioIndex], - &cpuAddrDecWin); - if (MV_NO_SUCH == status) - { - winPrioIndex++; - continue; - } - if (MV_OK != status) - { - mvOsPrintf("mvTdmInit: ERR. mvCpuIfTargetWinGet failed\n"); - return MV_ERROR; - } - - if (cpuAddrDecWin.enable == MV_TRUE) - { - tdmWin.addrWin.baseHigh = cpuAddrDecWin.addrWin.baseHigh; - tdmWin.addrWin.baseLow = cpuAddrDecWin.addrWin.baseLow; - tdmWin.addrWin.size = cpuAddrDecWin.addrWin.size; - tdmWin.enable = MV_TRUE; - tdmWin.target = tdmAddrDecPrioTap[winPrioIndex]; - if (MV_OK != mvTdmWinSet(winNum, &tdmWin)) - { - return MV_ERROR; - } - winNum++; - } - winPrioIndex++; - } - return MV_OK; -} - -/******************************************************************************* -* mvTdmWinSet - Set TDM target address window -* -* DESCRIPTION: -* This function sets a peripheral target (e.g. SDRAM bank0, PCI_MEM0) -* address window, also known as address decode window. -* After setting this target window, the TDM will be able to access the -* target within the address window. -* -* INPUT: -* winNum - TDM to target address decode window number. -* pAddrDecWin - TDM target window data structure. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_ERROR if address window overlapps with other address decode windows. -* MV_BAD_PARAM if base address is invalid parameter or target is -* unknown. -* -*******************************************************************************/ - -MV_STATUS mvTdmWinSet(MV_U32 winNum, MV_TDM_DEC_WIN *pAddrDecWin) -{ - MV_TARGET_ATTRIB targetAttribs; - MV_DEC_REGS decRegs; - MV_U32 ctrlReg = 0; - - /* Parameter checking */ - if (winNum >= TDM_MBUS_MAX_WIN) - { - mvOsPrintf("mvTdmWinSet: ERR. Invalid win num %d\n",winNum); - return MV_BAD_PARAM; - } - - /* Check if the requested window overlapps with current windows */ - if (MV_TRUE == tdmWinOverlapDetect(winNum, &pAddrDecWin->addrWin)) - { - mvOsPrintf("mvTdmWinSet: ERR. Window %d overlap\n", winNum); - return MV_ERROR; - } - - /* check if address is aligned to the size */ - if (MV_IS_NOT_ALIGN(pAddrDecWin->addrWin.baseLow, pAddrDecWin->addrWin.size)) - { - mvOsPrintf("mvTdmWinSet: Error setting TDM window %d to "\ - "target %s.\nAddress 0x%08x is unaligned to size 0x%x.\n", - winNum, - mvCtrlTargetNameGet(pAddrDecWin->target), - pAddrDecWin->addrWin.baseLow, - pAddrDecWin->addrWin.size); - return MV_ERROR; - } - - decRegs.baseReg = MV_REG_READ(TDM_WIN_BASE_REG(winNum)); - decRegs.sizeReg = (MV_REG_READ(TDM_WIN_CTRL_REG(winNum)) & TDM_WIN_SIZE_MASK) >> TDM_WIN_SIZE_OFFS; - - if (MV_OK != mvCtrlAddrDecToReg(&(pAddrDecWin->addrWin),&decRegs)) - { - mvOsPrintf("mvTdmWinSet: mvCtrlAddrDecToReg Failed\n"); - return MV_ERROR; - } - - mvCtrlAttribGet(pAddrDecWin->target, &targetAttribs); - - /* for the safe side we disable the window before writing the new - values */ - mvTdmWinEnable(winNum, MV_FALSE); - - ctrlReg |= (targetAttribs.attrib << TDM_WIN_ATTRIB_OFFS); - ctrlReg |= (targetAttribs.targetId << TDM_WIN_TARGET_OFFS); - ctrlReg |= (decRegs.sizeReg & TDM_WIN_SIZE_MASK); - - /* Write to address base and control registers */ - MV_REG_WRITE(TDM_WIN_BASE_REG(winNum), decRegs.baseReg); - MV_REG_WRITE(TDM_WIN_CTRL_REG(winNum), ctrlReg); - /* Enable address decode target window */ - if (pAddrDecWin->enable == MV_TRUE) - { - mvTdmWinEnable(winNum, MV_TRUE); - } - return MV_OK; -} - -/******************************************************************************* -* mvTdmWinGet - Get peripheral target address window. -* -* DESCRIPTION: -* Get TDM peripheral target address window. -* -* INPUT: -* winNum - TDM to target address decode window number. -* -* OUTPUT: -* pAddrDecWin - TDM target window data structure. -* -* RETURN: -* MV_ERROR if register parameters are invalid. -* -*******************************************************************************/ - -MV_STATUS mvTdmWinGet(MV_U32 winNum, MV_TDM_DEC_WIN *pAddrDecWin) -{ - - MV_DEC_REGS decRegs; - MV_TARGET_ATTRIB targetAttrib; - - /* Parameter checking */ - if (winNum >= TDM_MBUS_MAX_WIN) - { - mvOsPrintf("mvTdmWinGet: ERR. Invalid winNum %d\n", winNum); - return MV_NOT_SUPPORTED; - } - - decRegs.baseReg = MV_REG_READ(TDM_WIN_BASE_REG(winNum)); - decRegs.sizeReg = (MV_REG_READ(TDM_WIN_CTRL_REG(winNum)) & TDM_WIN_SIZE_MASK) >> TDM_WIN_SIZE_OFFS; - - if (MV_OK != mvCtrlRegToAddrDec(&decRegs,&(pAddrDecWin->addrWin))) - { - mvOsPrintf("mvTdmWinGet: mvCtrlRegToAddrDec Failed \n"); - return MV_ERROR; - } - - /* attrib and targetId */ - targetAttrib.attrib = - (MV_REG_READ(TDM_WIN_CTRL_REG(winNum)) & TDM_WIN_ATTRIB_MASK) >> TDM_WIN_ATTRIB_OFFS; - targetAttrib.targetId = - (MV_REG_READ(TDM_WIN_CTRL_REG(winNum)) & TDM_WIN_TARGET_MASK) >> TDM_WIN_TARGET_OFFS; - - pAddrDecWin->target = mvCtrlTargetGet(&targetAttrib); - - /* Check if window is enabled */ - if (MV_REG_READ(TDM_WIN_CTRL_REG(winNum)) & TDM_WIN_ENABLE_MASK) - { - pAddrDecWin->enable = MV_TRUE; - } - else - { - pAddrDecWin->enable = MV_FALSE; - } - - return MV_OK; -} - -/******************************************************************************* -* mvTdmWinEnable - Enable/disable a TDM to target address window -* -* DESCRIPTION: -* This function enable/disable a TDM to target address window. -* According to parameter 'enable' the routine will enable the -* window, thus enabling TDM accesses (before enabling the window it is -* tested for overlapping). Otherwise, the window will be disabled. -* -* INPUT: -* winNum - TDM to target address decode window number. -* enable - Enable/disable parameter. -* -* OUTPUT: -* N/A -* -* RETURN: -* MV_ERROR if decode window number was wrong or enabled window overlapps. -* -*******************************************************************************/ -MV_STATUS mvTdmWinEnable(int winNum, MV_BOOL enable) -{ - MV_TDM_DEC_WIN addrDecWin; - - if (MV_TRUE == enable) - { - if (winNum >= TDM_MBUS_MAX_WIN) - { - mvOsPrintf("mvTdmWinEnable:ERR. Invalid winNum%d\n",winNum); - return MV_ERROR; - } - - /* First check for overlap with other enabled windows */ - /* Get current window */ - if (MV_OK != mvTdmWinGet(winNum, &addrDecWin)) - { - mvOsPrintf("mvTdmWinEnable:ERR. targetWinGet fail\n"); - return MV_ERROR; - } - /* Check for overlapping */ - if (MV_FALSE == tdmWinOverlapDetect(winNum, &(addrDecWin.addrWin))) - { - /* No Overlap. Enable address decode target window */ - MV_REG_BIT_SET(TDM_WIN_CTRL_REG(winNum), TDM_WIN_ENABLE_MASK); - } - else - { /* Overlap detected */ - mvOsPrintf("mvTdmWinEnable:ERR. Overlap detected\n"); - return MV_ERROR; - } - } - else - { - MV_REG_BIT_RESET(TDM_WIN_CTRL_REG(winNum), TDM_WIN_ENABLE_MASK); - } - return MV_OK; -} - - -/******************************************************************************* -* tdmWinOverlapDetect - Detect TDM address windows overlapping -* -* DESCRIPTION: -* An unpredicted behaviour is expected in case TDM address decode -* windows overlapps. -* This function detects TDM address decode windows overlapping of a -* specified window. The function does not check the window itself for -* overlapping. The function also skipps disabled address decode windows. -* -* INPUT: -* winNum - address decode window number. -* pAddrDecWin - An address decode window struct. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_TRUE if the given address window overlap current address -* decode map, MV_FALSE otherwise, MV_ERROR if reading invalid data -* from registers. -* -*******************************************************************************/ -static MV_STATUS tdmWinOverlapDetect(MV_U32 winNum, MV_ADDR_WIN *pAddrWin) -{ - MV_U32 winNumIndex; - MV_TDM_DEC_WIN addrDecWin; - - for (winNumIndex = 0; winNumIndex < TDM_MBUS_MAX_WIN; winNumIndex++) - { - /* Do not check window itself */ - if (winNumIndex == winNum) - { - continue; - } - /* Do not check disabled windows */ - if (MV_REG_READ(TDM_WIN_CTRL_REG(winNum)) & TDM_WIN_ENABLE_MASK) - { - /* Get window parameters */ - if (MV_OK != mvTdmWinGet(winNumIndex, &addrDecWin)) - { - DB(mvOsPrintf("dmaWinOverlapDetect: ERR. TargetWinGet failed\n")); - return MV_ERROR; - } - - if (MV_TRUE == ctrlWinOverlapTest(pAddrWin, &(addrDecWin.addrWin))) - { - return MV_TRUE; - } - } - } - return MV_FALSE; -} - -/******************************************************************************* -* mvTdmAddrDecShow - Print the TDM address decode map. -* -* DESCRIPTION: -* This function print the TDM address decode map. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_VOID mvTdmAddrDecShow(MV_VOID) -{ - MV_TDM_DEC_WIN win; - int i; - - mvOsOutput( "\n" ); - mvOsOutput( "TDM:\n" ); - mvOsOutput( "----\n" ); - - for( i = 0; i < TDM_MBUS_MAX_WIN; i++ ) - { - memset( &win, 0, sizeof(MV_TDM_DEC_WIN) ); - - mvOsOutput( "win%d - ", i ); - - if (mvTdmWinGet(i, &win ) == MV_OK ) - { - if( win.enable ) - { - mvOsOutput( "%s base %08x, ", - mvCtrlTargetNameGet(win.target), win.addrWin.baseLow); - mvOsOutput( "...." ); - mvSizePrint( win.addrWin.size ); - mvOsOutput( "\n" ); - } - else - mvOsOutput( "disable\n" ); - } - } -} - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysTdm.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysTdm.h deleted file mode 100644 index 0d3140f..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysTdm.h +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCmvSysTdmh -#define __INCmvSysTdmh - -#include "ctrlEnv/sys/mvCpuIf.h" -#include "ctrlEnv/mvCtrlEnvLib.h" -#include "ctrlEnv/mvCtrlEnvAddrDec.h" - -typedef struct _mvTdmDecWin -{ - MV_TARGET target; - MV_ADDR_WIN addrWin; /* An address window*/ - MV_BOOL enable; /* Address decode window is enabled/disabled */ -} MV_TDM_DEC_WIN; - -MV_STATUS mvTdmWinInit(MV_VOID); -MV_STATUS mvTdmWinSet(MV_U32 winNum, MV_TDM_DEC_WIN *pAddrDecWin); -MV_STATUS mvTdmWinGet(MV_U32 winNum, MV_TDM_DEC_WIN *pAddrDecWin); -MV_STATUS mvTdmWinEnable(int winNum, MV_BOOL enable); -MV_VOID mvTdmAddrDecShow(MV_VOID); - - -#define TDM_MBUS_MAX_WIN 4 -#define TDM_WIN_CTRL_REG(win) ((TDM_REG_BASE + 0x4030) + (win<<4)) -#define TDM_WIN_BASE_REG(win) ((TDM_REG_BASE +0x4034) + (win<<4)) - -/* TDM_WIN_CTRL_REG bits */ -#define TDM_WIN_ENABLE_OFFS 0 -#define TDM_WIN_ENABLE_MASK (1<<TDM_WIN_ENABLE_OFFS) -#define TDM_WIN_ENABLE 1 -#define TDM_WIN_TARGET_OFFS 4 -#define TDM_WIN_TARGET_MASK (0xf<<TDM_WIN_TARGET_OFFS) -#define TDM_WIN_ATTRIB_OFFS 8 -#define TDM_WIN_ATTRIB_MASK (0xff<<TDM_WIN_ATTRIB_OFFS) -#define TDM_WIN_SIZE_OFFS 16 -#define TDM_WIN_SIZE_MASK (0xffff<<TDM_WIN_SIZE_OFFS) - -/* TDM_WIN_BASE_REG bits */ -#define TDM_BASE_OFFS 16 -#define TDM_BASE_MASK (0xffff<<TDM_BASE_OFFS) - -#endif /*__INCmvSysTdmh*/ - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysTs.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysTs.c deleted file mode 100644 index 4415c7c..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysTs.c +++ /dev/null @@ -1,591 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -#include "ctrlEnv/sys/mvSysTs.h" - - -typedef struct _mvTsuDecWin -{ - MV_TARGET target; - MV_ADDR_WIN addrWin; /* An address window*/ - MV_BOOL enable; /* Address decode window is enabled/disabled */ - -}MV_TSU_DEC_WIN; - - -MV_TARGET tsuAddrDecPrioTap[] = -{ -#if defined(MV_INCLUDE_PEX) - PEX0_MEM, -#endif -#if defined(MV_INCLUDE_PCI) - PCI0_MEM, -#endif -#if defined(MV_INCLUDE_SDRAM_CS0) - SDRAM_CS0, -#endif -#if defined(MV_INCLUDE_SDRAM_CS1) - SDRAM_CS1, -#endif -#if defined(MV_INCLUDE_SDRAM_CS2) - SDRAM_CS2, -#endif -#if defined(MV_INCLUDE_SDRAM_CS3) - SDRAM_CS3, -#endif -#if defined(MV_INCLUDE_DEVICE_CS0) - DEVICE_CS0, -#endif -#if defined(MV_INCLUDE_DEVICE_CS1) - DEVICE_CS1, -#endif -#if defined(MV_INCLUDE_DEVICE_CS2) - DEVICE_CS2, -#endif -#if defined(MV_INCLUDE_DEVICE_CS3) - DEVICE_CS3, -#endif -#if defined(MV_INCLUDE_PEX) - PEX0_IO, -#endif -#if defined(MV_INCLUDE_PCI) - PCI0_IO, -#endif - TBL_TERM -}; - -static MV_STATUS tsuWinOverlapDetect(MV_U32 winNum, MV_ADDR_WIN *pAddrWin); -static MV_STATUS mvTsuWinSet(MV_U32 winNum, MV_TSU_DEC_WIN *pAddrDecWin); -static MV_STATUS mvTsuWinGet(MV_U32 winNum, MV_TSU_DEC_WIN *pAddrDecWin); -MV_STATUS mvTsuWinEnable(MV_U32 winNum,MV_BOOL enable); - -/******************************************************************************* -* mvTsuWinInit -* -* DESCRIPTION: -* Initialize the TSU unit address decode windows. -* -* INPUT: -* None. -* OUTPUT: -* None. -* RETURN: -* MV_OK - on success, -* -*******************************************************************************/ -MV_STATUS mvTsuWinInit(void) -{ - MV_U32 winNum, status, winPrioIndex=0; - MV_TSU_DEC_WIN tsuWin; - MV_CPU_DEC_WIN cpuAddrDecWin; - - /* First disable all address decode windows */ - for(winNum = 0; winNum < TSU_MAX_DECODE_WIN; winNum++) - { - MV_REG_BIT_RESET(MV_TSU_WIN_CTRL_REG(winNum), - TSU_WIN_CTRL_EN_MASK); - } - - /* Go through all windows in user table until table terminator */ - for(winNum = 0; ((tsuAddrDecPrioTap[winPrioIndex] != TBL_TERM) && - (winNum < TSU_MAX_DECODE_WIN));) - { - /* first get attributes from CPU If */ - status = mvCpuIfTargetWinGet(tsuAddrDecPrioTap[winPrioIndex], - &cpuAddrDecWin); - - if(MV_NO_SUCH == status) - { - winPrioIndex++; - continue; - } - if(MV_OK != status) - { - mvOsPrintf("mvTsuWinInit: ERR. mvCpuIfTargetWinGet failed\n"); - return MV_ERROR; - } - - if (cpuAddrDecWin.enable == MV_TRUE) - { - tsuWin.addrWin.baseHigh = cpuAddrDecWin.addrWin.baseHigh; - tsuWin.addrWin.baseLow = cpuAddrDecWin.addrWin.baseLow; - tsuWin.addrWin.size = cpuAddrDecWin.addrWin.size; - tsuWin.enable = MV_TRUE; - tsuWin.target = tsuAddrDecPrioTap[winPrioIndex]; - - if(MV_OK != mvTsuWinSet(winNum, &tsuWin)) - { - mvOsPrintf("mvTsuWinInit: ERR. mvTsuWinSet failed winNum=%d\n", - winNum); - return MV_ERROR; - } - winNum++; - } - winPrioIndex ++; - } - - return MV_OK; -} - - -/******************************************************************************* -* mvTsuWinSet -* -* DESCRIPTION: -* This function sets a peripheral target (e.g. SDRAM bank0, PCI_MEM0) -* address window, also known as address decode window. -* After setting this target window, the TSU will be able to access the -* target within the address window. -* -* INPUT: -* winNum - TSU to target address decode window number. -* pAddrDecWin - TSU target window data structure. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_ERROR - if address window overlapps with other address decode -* windows. -* MV_BAD_PARAM - if base address is invalid parameter or target is -* unknown. -* -*******************************************************************************/ -MV_STATUS mvTsuWinSet(MV_U32 winNum, MV_TSU_DEC_WIN *pAddrDecWin) -{ - MV_TARGET_ATTRIB targetAttribs; - MV_DEC_REGS decRegs; - - /* Parameter checking */ - if(winNum >= TSU_MAX_DECODE_WIN) - { - mvOsPrintf("mvTsuWinSet: ERR. Invalid win num %d\n",winNum); - return MV_BAD_PARAM; - } - - /* Check if the requested window overlapps with current windows */ - if(MV_TRUE == tsuWinOverlapDetect(winNum, &pAddrDecWin->addrWin)) - { - mvOsPrintf("mvTsuWinSet: ERR. Window %d overlap\n", winNum); - return MV_ERROR; - } - - /* check if address is aligned to the size */ - if(MV_IS_NOT_ALIGN(pAddrDecWin->addrWin.baseLow,pAddrDecWin->addrWin.size)) - { - mvOsPrintf("mvTsuWinSet: Error setting TSU window %d to target " - "%s.\nAddress 0x%08x is unaligned to size 0x%x.\n", - winNum, mvCtrlTargetNameGet(pAddrDecWin->target), - pAddrDecWin->addrWin.baseLow, - pAddrDecWin->addrWin.size); - return MV_ERROR; - } - - decRegs.baseReg = MV_REG_READ(MV_TSU_WIN_BASE_REG(winNum)); - decRegs.sizeReg = MV_REG_READ(MV_TSU_WIN_CTRL_REG(winNum)); - - if(MV_OK != mvCtrlAddrDecToReg(&(pAddrDecWin->addrWin),&decRegs)) - { - mvOsPrintf("mvTsuWinSet: mvCtrlAddrDecToReg Failed\n"); - return MV_ERROR; - } - - mvCtrlAttribGet(pAddrDecWin->target,&targetAttribs); - - /* set attributes */ - decRegs.sizeReg &= ~TSU_WIN_CTRL_ATTR_MASK; - decRegs.sizeReg |= targetAttribs.attrib << TSU_WIN_CTRL_ATTR_OFFS; - /* set target ID */ - decRegs.sizeReg &= ~TSU_WIN_CTRL_TARGET_MASK; - decRegs.sizeReg |= targetAttribs.targetId << TSU_WIN_CTRL_TARGET_OFFS; - - /* for the safe side we disable the window before writing the new */ - /* values */ - mvTsuWinEnable(winNum, MV_FALSE); - MV_REG_WRITE(MV_TSU_WIN_CTRL_REG(winNum),decRegs.sizeReg); - - /* Write to address decode Size Register */ - MV_REG_WRITE(MV_TSU_WIN_BASE_REG(winNum), decRegs.baseReg); - - /* Enable address decode target window */ - if(pAddrDecWin->enable == MV_TRUE) - { - mvTsuWinEnable(winNum,MV_TRUE); - } - - return MV_OK; -} - - -/******************************************************************************* -* mvTsuWinGet -* -* DESCRIPTION: -* Get TSU peripheral target address window. -* -* INPUT: -* winNum - TSU to target address decode window number. -* -* OUTPUT: -* pAddrDecWin - TSU target window data structure. -* -* RETURN: -* MV_ERROR if register parameters are invalid. -* -*******************************************************************************/ -MV_STATUS mvTsuWinGet(MV_U32 winNum, MV_TSU_DEC_WIN *pAddrDecWin) -{ - MV_DEC_REGS decRegs; - MV_TARGET_ATTRIB targetAttrib; - - /* Parameter checking */ - if(winNum >= TSU_MAX_DECODE_WIN) - { - mvOsPrintf("mvTsuWinGet: ERR. Invalid winNum %d\n", winNum); - return MV_NOT_SUPPORTED; - } - - decRegs.baseReg = MV_REG_READ(MV_TSU_WIN_BASE_REG(winNum)); - decRegs.sizeReg = MV_REG_READ(MV_TSU_WIN_CTRL_REG(winNum)); - - if(MV_OK != mvCtrlRegToAddrDec(&decRegs,&(pAddrDecWin->addrWin))) - { - mvOsPrintf("mvTsuWinGet: mvCtrlRegToAddrDec Failed \n"); - return MV_ERROR; - } - - /* attrib and targetId */ - targetAttrib.attrib = - (decRegs.sizeReg & TSU_WIN_CTRL_ATTR_MASK) >> TSU_WIN_CTRL_ATTR_OFFS; - targetAttrib.targetId = - (decRegs.sizeReg & TSU_WIN_CTRL_TARGET_MASK) >> TSU_WIN_CTRL_TARGET_OFFS; - - pAddrDecWin->target = mvCtrlTargetGet(&targetAttrib); - - /* Check if window is enabled */ - if((MV_REG_READ(MV_TSU_WIN_CTRL_REG(winNum)) & TSU_WIN_CTRL_EN_MASK)) - { - pAddrDecWin->enable = MV_TRUE; - } - else - { - pAddrDecWin->enable = MV_FALSE; - } - - return MV_OK; -} - - -/******************************************************************************* -* mvTsuWinEnable -* -* DESCRIPTION: -* This function enable/disable a TSU to target address window. -* According to parameter 'enable' the routine will enable the -* window, thus enabling TSU accesses (before enabling the window it is -* tested for overlapping). Otherwise, the window will be disabled. -* -* INPUT: -* winNum - TSU to target address decode window number. -* enable - Enable / disable parameter. -* -* OUTPUT: -* N/A -* -* RETURN: -* MV_ERROR if decode window number was wrong or enabled window overlapps. -* -*******************************************************************************/ -MV_STATUS mvTsuWinEnable(MV_U32 winNum,MV_BOOL enable) -{ - MV_TSU_DEC_WIN addrDecWin; - - /* Parameter checking */ - if(winNum >= TSU_MAX_DECODE_WIN) - { - mvOsPrintf("mvTsuWinEnable: ERR. Invalid winNum%d\n",winNum); - return MV_ERROR; - } - - if(enable == MV_TRUE) - { - /* First check for overlap with other enabled windows */ - /* Get current window. */ - if(MV_OK != mvTsuWinGet(winNum,&addrDecWin)) - { - mvOsPrintf("mvTsuWinEnable: ERR. targetWinGet fail\n"); - return MV_ERROR; - } - /* Check for overlapping. */ - if(MV_FALSE == tsuWinOverlapDetect(winNum,&(addrDecWin.addrWin))) - { - /* No Overlap. Enable address decode target window */ - MV_REG_BIT_SET(MV_TSU_WIN_CTRL_REG(winNum), - TSU_WIN_CTRL_EN_MASK); - } - else - { - /* Overlap detected */ - mvOsPrintf("mvTsuWinEnable: ERR. Overlap detected\n"); - return MV_ERROR; - } - } - else - { - /* Disable address decode target window */ - MV_REG_BIT_RESET(MV_TSU_WIN_CTRL_REG(winNum), - TSU_WIN_CTRL_EN_MASK); - } - return MV_OK; -} - -/******************************************************************************* -* mvTsuWinTargetGet -* -* DESCRIPTION: -* Get Window number associated with target -* -* INPUT: -* target - Target ID to get the window number for. -* OUTPUT: -* -* RETURN: -* window number or 0xFFFFFFFF on error. -* -*******************************************************************************/ -MV_U32 mvTsuWinTargetGet(MV_TARGET target) -{ - MV_TSU_DEC_WIN decWin; - MV_U32 winNum; - - /* Check parameters */ - if(target >= MAX_TARGETS) - { - mvOsPrintf("mvTsuWinTargetGet: target %d is Illigal\n", target); - return 0xffffffff; - } - - for(winNum = 0; winNum < TSU_MAX_DECODE_WIN; winNum++) - { - if(mvTsuWinGet(winNum,&decWin) != MV_OK) - { - mvOsPrintf("mvTsuWinGet: window returned error\n"); - return 0xffffffff; - } - - if (decWin.enable == MV_TRUE) - { - if(decWin.target == target) - { - return winNum; - } - } - } - return 0xFFFFFFFF; -} - - -/******************************************************************************* -* tsuWinOverlapDetect -* -* DESCRIPTION: -* Detect TSU address windows overlapping -* An unpredicted behaviur is expected in case TSU address decode -* windows overlapps. -* This function detects TSU address decode windows overlapping of a -* specified window. The function does not check the window itself for -* overlapping. The function also skipps disabled address decode windows. -* -* INPUT: -* winNum - address decode window number. -* pAddrDecWin - An address decode window struct. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_TRUE if the given address window overlap current address -* decode map, MV_FALSE otherwise, MV_ERROR if reading invalid data -* from registers. -* -*******************************************************************************/ -static MV_STATUS tsuWinOverlapDetect(MV_U32 winNum, MV_ADDR_WIN *pAddrWin) -{ - MV_U32 ctrlReg; - MV_U32 winNumIndex; - MV_TSU_DEC_WIN addrDecWin; - - for(winNumIndex = 0; winNumIndex < TSU_MAX_DECODE_WIN; winNumIndex++) - { - /* Do not check window itself */ - if(winNumIndex == winNum) - { - continue; - } - - /* Do not check disabled windows */ - ctrlReg = MV_REG_READ(MV_TSU_WIN_CTRL_REG(winNumIndex)); - if((ctrlReg & TSU_WIN_CTRL_EN_MASK) == 0) - { - continue; - } - - /* Get window parameters */ - if (MV_OK != mvTsuWinGet(winNumIndex, &addrDecWin)) - { - mvOsPrintf("tsuWinOverlapDetect: ERR. mvTsuWinGet failed\n"); - return MV_ERROR; - } - - if (MV_TRUE == ctrlWinOverlapTest(pAddrWin, &(addrDecWin.addrWin))) - { - return MV_TRUE; - } - } - return MV_FALSE; -} - - -/******************************************************************************* -* mvTsuAddrDecShow -* -* DESCRIPTION: -* Print the TSU address decode map. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -void mvTsuAddrDecShow(void) -{ - MV_TSU_DEC_WIN win; - int i; - - if (MV_FALSE == mvCtrlPwrClckGet(TS_UNIT_ID, 0)) - return; - - mvOsOutput( "\n" ); - mvOsOutput( "TSU:\n"); - mvOsOutput( "----\n" ); - - for(i = 0; i < TSU_MAX_DECODE_WIN; i++) - { - memset(&win, 0, sizeof(TSU_MAX_DECODE_WIN)); - mvOsOutput( "win%d - ", i ); - - if(mvTsuWinGet(i, &win ) == MV_OK ) - { - if(win.enable == MV_TRUE) - { - mvOsOutput("%s base %08x, ", - mvCtrlTargetNameGet(win.target), - win.addrWin.baseLow); - mvOsOutput( "...." ); - mvSizePrint(win.addrWin.size ); - mvOsOutput( "\n" ); - } - else - { - mvOsOutput( "disable\n" ); - } - } - } - return; -} - - -/******************************************************************************* -* mvTsuInit -* -* DESCRIPTION: -* Initialize the TSU unit, and get unit out of reset. -* -* INPUT: -* coreClock - The core clock at which the TSU should operate. -* mode - The mode on configure the unit into (serial/parallel). -* memHandle - Memory handle used for memory allocations. -* OUTPUT: -* None. -* RETURN: -* MV_OK - on success, -* -*******************************************************************************/ -MV_STATUS mvTsuInit(MV_TSU_CORE_CLOCK coreClock, MV_TSU_PORTS_MODE mode, - void *osHandle) -{ - MV_STATUS status; - - status = mvTsuWinInit(); - if(status == MV_OK) - status = mvTsuHalInit(coreClock,mode,osHandle); - - return status; -} diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysTs.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysTs.h deleted file mode 100644 index 4282589..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysTs.h +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCmvSysTsh -#define __INCmvSysTsh - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* includes */ -#include "ts/mvTsu.h" -#include "ctrlEnv/sys/mvCpuIf.h" -#include "ctrlEnv/mvCtrlEnvLib.h" -#include "ctrlEnv/mvCtrlEnvAddrDec.h" - -#define TSU_MAX_DECODE_WIN 4 - - -/*******************************************/ -/* TSU Windows Registers */ -/*******************************************/ -#define MV_TSU_WIN_CTRL_REG(win) (TSU_GLOBAL_REG_BASE +0x30 + 0x10 * win) -#define MV_TSU_WIN_BASE_REG(win) (TSU_GLOBAL_REG_BASE +0x34 + 0x10 * win) - -/* TSU windows control register. */ -#define TSU_WIN_CTRL_EN_MASK (0x1 << 0) -#define TSU_WIN_CTRL_TARGET_OFFS 4 -#define TSU_WIN_CTRL_TARGET_MASK (0xF << TSU_WIN_CTRL_TARGET_OFFS) -#define TSU_WIN_CTRL_ATTR_OFFS 8 -#define TSU_WIN_CTRL_ATTR_MASK (0xFF << TSU_WIN_CTRL_ATTR_OFFS) -#define TSU_WIN_CTRL_SIZE_OFFS 16 -#define TSU_WIN_CTRL_SIZE_MASK (0xFFFF << TSU_WIN_CTRL_SIZE_OFFS) - -/* TSU windows base register. */ -#define TSU_WIN_BASE_OFFS 16 -#define TSU_WIN_BASE_MASK (0xFFFF << TSU_WIN_BASE_OFFS) - -MV_STATUS mvTsuWinInit(void); - -void mvTsuAddrDecShow(void); -MV_STATUS mvTsuInit(MV_TSU_CORE_CLOCK coreClock, MV_TSU_PORTS_MODE mode, - void *osHandle); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __INCmvTsh */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysUsb.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysUsb.c deleted file mode 100644 index 195b5e1..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysUsb.c +++ /dev/null @@ -1,497 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#include "ctrlEnv/sys/mvSysUsb.h" - -MV_TARGET usbAddrDecPrioTab[] = -{ -#if defined(MV_INCLUDE_SDRAM_CS0) - SDRAM_CS0, -#endif -#if defined(MV_INCLUDE_SDRAM_CS1) - SDRAM_CS1, -#endif -#if defined(MV_INCLUDE_SDRAM_CS2) - SDRAM_CS2, -#endif -#if defined(MV_INCLUDE_SDRAM_CS3) - SDRAM_CS3, -#endif -#if defined(MV_INCLUDE_CESA) && defined(USB_UNDERRUN_WA) - CRYPT_ENG, -#endif -#if defined(MV_INCLUDE_PEX) - PEX0_MEM, -#endif - TBL_TERM -}; - - - -MV_STATUS mvUsbInit(int dev, MV_BOOL isHost) -{ - MV_STATUS status; - - status = mvUsbWinInit(dev); - if(status != MV_OK) - return status; - - return mvUsbHalInit(dev, isHost); -} - - -/******************************************************************************* -* usbWinOverlapDetect - Detect USB address windows overlapping -* -* DESCRIPTION: -* An unpredicted behaviur is expected in case USB address decode -* windows overlapps. -* This function detects USB address decode windows overlapping of a -* specified window. The function does not check the window itself for -* overlapping. The function also skipps disabled address decode windows. -* -* INPUT: -* winNum - address decode window number. -* pAddrDecWin - An address decode window struct. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_TRUE if the given address window overlap current address -* decode map, MV_FALSE otherwise, MV_ERROR if reading invalid data -* from registers. -* -*******************************************************************************/ -static MV_STATUS usbWinOverlapDetect(int dev, MV_U32 winNum, - MV_ADDR_WIN *pAddrWin) -{ - MV_U32 winNumIndex; - MV_DEC_WIN addrDecWin; - - for(winNumIndex=0; winNumIndex<MV_USB_MAX_ADDR_DECODE_WIN; winNumIndex++) - { - /* Do not check window itself */ - if (winNumIndex == winNum) - { - continue; - } - - /* Get window parameters */ - if (MV_OK != mvUsbWinGet(dev, winNumIndex, &addrDecWin)) - { - mvOsPrintf("%s: ERR. TargetWinGet failed\n", __FUNCTION__); - return MV_ERROR; - } - - /* Do not check disabled windows */ - if(addrDecWin.enable == MV_FALSE) - { - continue; - } - - if (MV_TRUE == ctrlWinOverlapTest(pAddrWin, &(addrDecWin.addrWin))) - { - return MV_TRUE; - } - } - return MV_FALSE; -} - -/******************************************************************************* -* mvUsbWinSet - Set USB target address window -* -* DESCRIPTION: -* This function sets a peripheral target (e.g. SDRAM bank0, PCI_MEM0) -* address window, also known as address decode window. -* After setting this target window, the USB will be able to access the -* target within the address window. -* -* INPUT: -* winNum - USB target address decode window number. -* pAddrDecWin - USB target window data structure. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_ERROR if address window overlapps with other address decode windows. -* MV_BAD_PARAM if base address is invalid parameter or target is -* unknown. -* -*******************************************************************************/ -MV_STATUS mvUsbWinSet(int dev, MV_U32 winNum, MV_DEC_WIN *pDecWin) -{ - MV_DEC_WIN_PARAMS winParams; - MV_U32 sizeReg, baseReg; - - /* Parameter checking */ - if (winNum >= MV_USB_MAX_ADDR_DECODE_WIN) - { - mvOsPrintf("%s: ERR. Invalid win num %d\n",__FUNCTION__, winNum); - return MV_BAD_PARAM; - } - - /* Check if the requested window overlapps with current windows */ - if (MV_TRUE == usbWinOverlapDetect(dev, winNum, &pDecWin->addrWin)) - { - mvOsPrintf("%s: ERR. Window %d overlap\n", __FUNCTION__, winNum); - return MV_ERROR; - } - - /* check if address is aligned to the size */ - if(MV_IS_NOT_ALIGN(pDecWin->addrWin.baseLow, pDecWin->addrWin.size)) - { - mvOsPrintf("mvUsbWinSet:Error setting USB window %d to "\ - "target %s.\nAddress 0x%08x is unaligned to size 0x%x.\n", - winNum, - mvCtrlTargetNameGet(pDecWin->target), - pDecWin->addrWin.baseLow, - pDecWin->addrWin.size); - return MV_ERROR; - } - - if(MV_OK != mvCtrlAddrDecToParams(pDecWin, &winParams)) - { - mvOsPrintf("%s: mvCtrlAddrDecToParams Failed\n", __FUNCTION__); - return MV_ERROR; - } - - /* set Size, Attributes and TargetID */ - sizeReg = (((winParams.targetId << MV_USB_WIN_TARGET_OFFSET) & MV_USB_WIN_TARGET_MASK) | - ((winParams.attrib << MV_USB_WIN_ATTR_OFFSET) & MV_USB_WIN_ATTR_MASK) | - ((winParams.size << MV_USB_WIN_SIZE_OFFSET) & MV_USB_WIN_SIZE_MASK)); - -#if defined(MV645xx) || defined(MV646xx) - /* If window is DRAM with HW cache coherency, make sure bit2 is set */ - sizeReg &= ~MV_USB_WIN_BURST_WR_LIMIT_MASK; - - if((MV_TARGET_IS_DRAM(pDecWin->target)) && - (pDecWin->addrWinAttr.cachePolicy != NO_COHERENCY)) - { - sizeReg |= MV_USB_WIN_BURST_WR_32BIT_LIMIT; - } - else - { - sizeReg |= MV_USB_WIN_BURST_WR_NO_LIMIT; - } -#endif /* MV645xx || MV646xx */ - - if (pDecWin->enable == MV_TRUE) - { - sizeReg |= MV_USB_WIN_ENABLE_MASK; - } - else - { - sizeReg &= ~MV_USB_WIN_ENABLE_MASK; - } - - /* Update Base value */ - baseReg = (winParams.baseAddr & MV_USB_WIN_BASE_MASK); - - MV_REG_WRITE( MV_USB_WIN_CTRL_REG(dev, winNum), sizeReg); - MV_REG_WRITE( MV_USB_WIN_BASE_REG(dev, winNum), baseReg); - - return MV_OK; -} - -/******************************************************************************* -* mvUsbWinGet - Get USB peripheral target address window. -* -* DESCRIPTION: -* Get USB peripheral target address window. -* -* INPUT: -* winNum - USB target address decode window number. -* -* OUTPUT: -* pDecWin - USB target window data structure. -* -* RETURN: -* MV_ERROR if register parameters are invalid. -* -*******************************************************************************/ -MV_STATUS mvUsbWinGet(int dev, MV_U32 winNum, MV_DEC_WIN *pDecWin) -{ - MV_DEC_WIN_PARAMS winParam; - MV_U32 sizeReg, baseReg; - - /* Parameter checking */ - if (winNum >= MV_USB_MAX_ADDR_DECODE_WIN) - { - mvOsPrintf("%s (dev=%d): ERR. Invalid winNum %d\n", - __FUNCTION__, dev, winNum); - return MV_NOT_SUPPORTED; - } - - baseReg = MV_REG_READ( MV_USB_WIN_BASE_REG(dev, winNum) ); - sizeReg = MV_REG_READ( MV_USB_WIN_CTRL_REG(dev, winNum) ); - - /* Check if window is enabled */ - if(sizeReg & MV_USB_WIN_ENABLE_MASK) - { - pDecWin->enable = MV_TRUE; - - /* Extract window parameters from registers */ - winParam.targetId = (sizeReg & MV_USB_WIN_TARGET_MASK) >> MV_USB_WIN_TARGET_OFFSET; - winParam.attrib = (sizeReg & MV_USB_WIN_ATTR_MASK) >> MV_USB_WIN_ATTR_OFFSET; - winParam.size = (sizeReg & MV_USB_WIN_SIZE_MASK) >> MV_USB_WIN_SIZE_OFFSET; - winParam.baseAddr = (baseReg & MV_USB_WIN_BASE_MASK); - - /* Translate the decode window parameters to address decode struct */ - if (MV_OK != mvCtrlParamsToAddrDec(&winParam, pDecWin)) - { - mvOsPrintf("Failed to translate register parameters to USB address" \ - " decode window structure\n"); - return MV_ERROR; - } - } - else - { - pDecWin->enable = MV_FALSE; - } - return MV_OK; -} - -/******************************************************************************* -* mvUsbWinInit - -* -* INPUT: -* -* OUTPUT: -* -* RETURN: -* MV_ERROR if register parameters are invalid. -* -*******************************************************************************/ -MV_STATUS mvUsbWinInit(int dev) -{ - MV_STATUS status; - MV_DEC_WIN usbWin; - MV_CPU_DEC_WIN cpuAddrDecWin; - int winNum; - MV_U32 winPrioIndex = 0; - - /* First disable all address decode windows */ - for(winNum = 0; winNum < MV_USB_MAX_ADDR_DECODE_WIN; winNum++) - { - MV_REG_BIT_RESET(MV_USB_WIN_CTRL_REG(dev, winNum), MV_USB_WIN_ENABLE_MASK); - } - - /* Go through all windows in user table until table terminator */ - winNum = 0; - while( (usbAddrDecPrioTab[winPrioIndex] != TBL_TERM) && - (winNum < MV_USB_MAX_ADDR_DECODE_WIN) ) - { - /* first get attributes from CPU If */ - status = mvCpuIfTargetWinGet(usbAddrDecPrioTab[winPrioIndex], - &cpuAddrDecWin); - - if(MV_NO_SUCH == status) - { - winPrioIndex++; - continue; - } - if (MV_OK != status) - { - mvOsPrintf("%s: ERR. mvCpuIfTargetWinGet failed\n", __FUNCTION__); - return MV_ERROR; - } - - if (cpuAddrDecWin.enable == MV_TRUE) - { - usbWin.addrWin.baseHigh = cpuAddrDecWin.addrWin.baseHigh; - usbWin.addrWin.baseLow = cpuAddrDecWin.addrWin.baseLow; - usbWin.addrWin.size = cpuAddrDecWin.addrWin.size; - usbWin.enable = MV_TRUE; - usbWin.target = usbAddrDecPrioTab[winPrioIndex]; - -#if defined(MV645xx) || defined(MV646xx) - /* Get the default attributes for that target window */ - mvCtrlDefAttribGet(usbWin.target, &usbWin.addrWinAttr); -#endif /* MV645xx || MV646xx */ - - if(MV_OK != mvUsbWinSet(dev, winNum, &usbWin)) - { - return MV_ERROR; - } - winNum++; - } - winPrioIndex++; - } - return MV_OK; -} - -/******************************************************************************* -* mvUsbAddrDecShow - Print the USB address decode map. -* -* DESCRIPTION: -* This function print the USB address decode map. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_VOID mvUsbAddrDecShow(MV_VOID) -{ - MV_DEC_WIN addrDecWin; - int i, winNum; - - mvOsOutput( "\n" ); - mvOsOutput( "USB:\n" ); - mvOsOutput( "----\n" ); - - for(i=0; i<mvCtrlUsbMaxGet(); i++) - { - mvOsOutput( "Device %d:\n", i); - - for(winNum = 0; winNum < MV_USB_MAX_ADDR_DECODE_WIN; winNum++) - { - memset(&addrDecWin, 0, sizeof(MV_DEC_WIN) ); - - mvOsOutput( "win%d - ", winNum ); - - if( mvUsbWinGet(i, winNum, &addrDecWin ) == MV_OK ) - { - if( addrDecWin.enable ) - { - mvOsOutput( "%s base %08x, ", - mvCtrlTargetNameGet(addrDecWin.target), addrDecWin.addrWin.baseLow ); - - mvSizePrint( addrDecWin.addrWin.size ); - -#if defined(MV645xx) || defined(MV646xx) - switch( addrDecWin.addrWinAttr.swapType) - { - case MV_BYTE_SWAP: - mvOsOutput( "BYTE_SWAP, " ); - break; - case MV_NO_SWAP: - mvOsOutput( "NO_SWAP , " ); - break; - case MV_BYTE_WORD_SWAP: - mvOsOutput( "BYTE_WORD_SWAP, " ); - break; - case MV_WORD_SWAP: - mvOsOutput( "WORD_SWAP, " ); - break; - default: - mvOsOutput( "SWAP N/A , " ); - } - - switch( addrDecWin.addrWinAttr.cachePolicy ) - { - case NO_COHERENCY: - mvOsOutput( "NO_COHERENCY , " ); - break; - case WT_COHERENCY: - mvOsOutput( "WT_COHERENCY , " ); - break; - case WB_COHERENCY: - mvOsOutput( "WB_COHERENCY , " ); - break; - default: - mvOsOutput( "COHERENCY N/A, " ); - } - - switch( addrDecWin.addrWinAttr.pcixNoSnoop ) - { - case 0: - mvOsOutput( "PCI-X NS inactive, " ); - break; - case 1: - mvOsOutput( "PCI-X NS active , " ); - break; - default: - mvOsOutput( "PCI-X NS N/A , " ); - } - - switch( addrDecWin.addrWinAttr.p2pReq64 ) - { - case 0: - mvOsOutput( "REQ64 force" ); - break; - case 1: - mvOsOutput( "REQ64 detect" ); - break; - default: - mvOsOutput( "REQ64 N/A" ); - } -#endif /* MV645xx || MV646xx */ - mvOsOutput( "\n" ); - } - else - mvOsOutput( "disable\n" ); - } - } - } -} - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysUsb.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysUsb.h deleted file mode 100644 index 07f98de..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysUsb.h +++ /dev/null @@ -1,125 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCmvSysUsbh -#define __INCmvSysUsbh - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* includes */ -#include "usb/mvUsb.h" -#include "ctrlEnv/sys/mvCpuIf.h" -#include "ctrlEnv/mvCtrlEnvLib.h" -#include "ctrlEnv/mvCtrlEnvAddrDec.h" - -#define MV_USB_MAX_ADDR_DECODE_WIN 4 - -/*******************************************/ -/* USB Bridge Registers */ -/*******************************************/ -#define MV_USB_BRIDGE_CTRL_REG(dev) (USB_REG_BASE(dev) + 0x300) - -#define MV_USB_WIN_CTRL_REG(dev, win) (USB_REG_BASE(dev) + 0x320 + ((win)<<4)) -#define MV_USB_WIN_BASE_REG(dev, win) (USB_REG_BASE(dev) + 0x324 + ((win)<<4)) - -/* BITs in Windows 0-3 Control and Base Registers */ -#define MV_USB_WIN_ENABLE_BIT 0 -#define MV_USB_WIN_ENABLE_MASK (1 << MV_USB_WIN_ENABLE_BIT) - -#define MV_USB_WIN_BURST_WR_LIMIT_BIT 1 -#define MV_USB_WIN_BURST_WR_LIMIT_MASK (1 << MV_USB_WIN_BURST_WR_LIMIT_BIT) -#define MV_USB_WIN_BURST_WR_NO_LIMIT (0 << MV_USB_WIN_BURST_WR_LIMIT_BIT) -#define MV_USB_WIN_BURST_WR_32BIT_LIMIT (1 << MV_USB_WIN_BURST_WR_LIMIT_BIT) - -#define MV_USB_WIN_TARGET_OFFSET 4 -#define MV_USB_WIN_TARGET_MASK (0xF << MV_USB_WIN_TARGET_OFFSET) - -#define MV_USB_WIN_ATTR_OFFSET 8 -#define MV_USB_WIN_ATTR_MASK (0xFF << MV_USB_WIN_ATTR_OFFSET) - -#define MV_USB_WIN_SIZE_OFFSET 16 -#define MV_USB_WIN_SIZE_MASK (0xFFFF << MV_USB_WIN_SIZE_OFFSET) - -#define MV_USB_WIN_BASE_OFFSET 16 -#define MV_USB_WIN_BASE_MASK (0xFFFF << MV_USB_WIN_BASE_OFFSET) - - -#define MV_USB_BRIDGE_IPG_REG(dev) (USB_REG_BASE(dev) + 0x360) - - -MV_STATUS mvUsbInit(int dev, MV_BOOL isHost); - -MV_STATUS mvUsbWinInit(int dev); -MV_STATUS mvUsbWinSet(int dev, MV_U32 winNum, MV_DEC_WIN *pAddrWin); -MV_STATUS mvUsbWinGet(int dev, MV_U32 winNum, MV_DEC_WIN *pAddrWin); - -void mvUsbAddrDecShow(void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __INCmvUsbh */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysXor.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysXor.c deleted file mode 100644 index f9d0ab3..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysXor.c +++ /dev/null @@ -1,662 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#include "xor/mvXor.h" -#include "mvSysXor.h" - -/* defines */ -#ifdef MV_DEBUG - #define DB(x) x -#else - #define DB(x) -#endif - - -static MV_STATUS xorWinOverlapDetect(MV_U32 unit,MV_U32 winNum, MV_ADDR_WIN *pAddrWin); - -MV_TARGET xorAddrDecPrioTap[] = -{ -#if defined(MV_INCLUDE_DEVICE_CS0) - DEVICE_CS0, -#endif -#if defined(MV_INCLUDE_PEX) - PEX0_MEM, -#endif -#if defined(MV_INCLUDE_SDRAM_CS0) - SDRAM_CS0, -#endif -#if defined(MV_INCLUDE_SDRAM_CS1) - SDRAM_CS1, -#endif -#if defined(MV_INCLUDE_SDRAM_CS2) - SDRAM_CS2, -#endif -#if defined(MV_INCLUDE_SDRAM_CS3) - SDRAM_CS3, -#endif -#if defined(MV_INCLUDE_DEVICE_CS1) - DEVICE_CS1, -#endif -#if defined(MV_INCLUDE_CESA) - CRYPT_ENG, -#endif - TBL_TERM -}; -static MV_STATUS mvXorInitWinsUnit (MV_U32 unit) -{ - MV_U32 winNum; - MV_XOR_DEC_WIN addrDecWin; - MV_CPU_DEC_WIN cpuAddrDecWin; - MV_U32 status; - MV_U32 winPrioIndex=0; - - /* Initiate XOR address decode */ - - /* First disable all address decode windows */ - for(winNum = 0; winNum < XOR_MAX_ADDR_DEC_WIN; winNum++) - { - mvXorTargetWinEnable(unit,winNum, MV_FALSE); - } - - /* Go through all windows in user table until table terminator */ - for (winNum = 0; ((xorAddrDecPrioTap[winPrioIndex] != TBL_TERM) && - (winNum < XOR_MAX_ADDR_DEC_WIN));) - { - /* first get attributes from CPU If */ - status = mvCpuIfTargetWinGet(xorAddrDecPrioTap[winPrioIndex], - &cpuAddrDecWin); - - if(MV_NO_SUCH == status) - { - winPrioIndex++; - continue; - } - if (MV_OK != status) - { - mvOsPrintf("%s: ERR. mvCpuIfTargetWinGet failed\n", __FUNCTION__); - return MV_ERROR; - } - - - if (cpuAddrDecWin.enable == MV_TRUE) - { - - addrDecWin.target = xorAddrDecPrioTap[winPrioIndex]; - addrDecWin.addrWin.baseLow = cpuAddrDecWin.addrWin.baseLow; - addrDecWin.addrWin.baseHigh = cpuAddrDecWin.addrWin.baseHigh; - addrDecWin.addrWin.size = cpuAddrDecWin.addrWin.size; - addrDecWin.enable = MV_TRUE; - - if (MV_OK != mvXorTargetWinSet(unit,winNum, &addrDecWin)) - { - DB(mvOsPrintf("mvXorInit: ERR. mvDmaTargetWinSet failed\n")); - return MV_ERROR; - } - winNum++; - } - winPrioIndex++; - - } - - return MV_OK; -} - - -/******************************************************************************* -* mvXorInit - Initialize XOR engine -* -* DESCRIPTION: -* This function initialize XOR unit. It set the default address decode -* windows of the unit. -* Note that if the address window is disabled in xorAddrDecMap, the -* window parameters will be set but the window will remain disabled. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM if parameters to function invalid, MV_OK otherwise. -*******************************************************************************/ -MV_STATUS mvXorInit (MV_VOID) -{ - MV_U32 i; - - /* Initiate XOR address decode */ - for(i = 0; i < MV_XOR_MAX_UNIT; i++) - mvXorInitWinsUnit(i); - - mvXorHalInit(MV_XOR_MAX_CHAN); - - return MV_OK; -} - -/******************************************************************************* -* mvXorTargetWinSet - Set XOR target address window -* -* DESCRIPTION: -* This function sets a peripheral target (e.g. SDRAM bank0, PCI_MEM0) -* address window. After setting this target window, the XOR will be -* able to access the target within the address window. -* -* INPUT: -* winNum - One of the possible XOR memory decode windows. -* target - Peripheral target enumerator. -* base - Window base address. -* size - Window size. -* enable - Window enable/disable. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM if parameters to function invalid, MV_OK otherwise. -* -*******************************************************************************/ -MV_STATUS mvXorTargetWinSet(MV_U32 unit, MV_U32 winNum, MV_XOR_DEC_WIN *pAddrDecWin) -{ - MV_DEC_REGS xorDecRegs; - MV_TARGET_ATTRIB targetAttribs; - MV_U32 chan; - - /* Parameter checking */ - if (winNum >= XOR_MAX_ADDR_DEC_WIN) - { - DB(mvOsPrintf("%s: ERR. Invalid win num %d\n",__FUNCTION__, winNum)); - return MV_BAD_PARAM; - } - if (pAddrDecWin == NULL) - { - DB(mvOsPrintf("%s: ERR. pAddrDecWin is NULL pointer\n", __FUNCTION__ )); - return MV_BAD_PTR; - } - /* Check if the requested window overlaps with current windows */ - if (MV_TRUE == xorWinOverlapDetect(unit, winNum, &pAddrDecWin->addrWin)) - { - DB(mvOsPrintf("%s: ERR. Window %d overlap\n",__FUNCTION__,winNum)); - return MV_ERROR; - } - - xorDecRegs.baseReg = MV_REG_READ(XOR_BASE_ADDR_REG(unit,winNum)); - xorDecRegs.sizeReg = MV_REG_READ(XOR_SIZE_MASK_REG(unit,winNum)); - - /* Get Base Address and size registers values */ - if(MV_OK != mvCtrlAddrDecToReg(&pAddrDecWin->addrWin, &xorDecRegs)) - { - DB(mvOsPrintf("%s: ERR. Invalid addr dec window\n",__FUNCTION__)); - return MV_BAD_PARAM; - } - - - mvCtrlAttribGet(pAddrDecWin->target,&targetAttribs); - - /* set attributes */ - xorDecRegs.baseReg &= ~XEBARX_ATTR_MASK; - xorDecRegs.baseReg |= targetAttribs.attrib << XEBARX_ATTR_OFFS; - /* set target ID */ - xorDecRegs.baseReg &= ~XEBARX_TARGET_MASK; - xorDecRegs.baseReg |= targetAttribs.targetId << XEBARX_TARGET_OFFS; - - - /* Write to address decode Base Address Register */ - MV_REG_WRITE(XOR_BASE_ADDR_REG(unit,winNum), xorDecRegs.baseReg); - - /* Write to Size Register */ - MV_REG_WRITE(XOR_SIZE_MASK_REG(unit,winNum), xorDecRegs.sizeReg); - - for (chan = 0; chan < MV_XOR_MAX_CHAN_PER_UNIT; chan++) - { - if (pAddrDecWin->enable) - { - MV_REG_BIT_SET(XOR_WINDOW_CTRL_REG(unit,chan), - XEXWCR_WIN_EN_MASK(winNum)); - } - else - { - MV_REG_BIT_RESET(XOR_WINDOW_CTRL_REG(unit,chan), - XEXWCR_WIN_EN_MASK(winNum)); - } - } - return MV_OK; -} - -/******************************************************************************* -* mvXorTargetWinGet - Get xor peripheral target address window. -* -* DESCRIPTION: -* Get xor peripheral target address window. -* -* INPUT: -* winNum - One of the possible XOR memory decode windows. -* -* OUTPUT: -* base - Window base address. -* size - Window size. -* enable - window enable/disable. -* -* RETURN: -* MV_BAD_PARAM if parameters to function invalid, MV_OK otherwise. -* -*******************************************************************************/ -MV_STATUS mvXorTargetWinGet(MV_U32 unit,MV_U32 winNum, MV_XOR_DEC_WIN *pAddrDecWin) -{ - MV_DEC_REGS xorDecRegs; - MV_TARGET_ATTRIB targetAttrib; - MV_U32 chan=0,chanWinEn; - - /* Parameter checking */ - if (winNum >= XOR_MAX_ADDR_DEC_WIN) - { - DB(mvOsPrintf("%s: ERR. Invalid win num %d\n",__FUNCTION__ , winNum)); - return MV_ERROR; - } - - if (NULL == pAddrDecWin) - { - DB(mvOsPrintf("%s: ERR. pAddrDecWin is NULL pointer\n", __FUNCTION__ )); - return MV_BAD_PTR; - } - - chanWinEn = MV_REG_READ(XOR_WINDOW_CTRL_REG(unit,0)) & XEXWCR_WIN_EN_MASK(winNum); - - for (chan = 0; chan < MV_XOR_MAX_CHAN_PER_UNIT; chan++) /* we should scan here all channels per unit */ - { - /* Check if enable bit is equal for all channels */ - if ((MV_REG_READ(XOR_WINDOW_CTRL_REG(unit,chan)) & - XEXWCR_WIN_EN_MASK(winNum)) != chanWinEn) - { - mvOsPrintf("%s: ERR. Window enable field must be equal in " - "all channels(chan=%d)\n",__FUNCTION__, chan); - return MV_ERROR; - } - } - - - - xorDecRegs.baseReg = MV_REG_READ(XOR_BASE_ADDR_REG(unit,winNum)); - xorDecRegs.sizeReg = MV_REG_READ(XOR_SIZE_MASK_REG(unit,winNum)); - - if (MV_OK != mvCtrlRegToAddrDec(&xorDecRegs, &pAddrDecWin->addrWin)) - { - mvOsPrintf("%s: ERR. mvCtrlRegToAddrDec failed\n", __FUNCTION__); - return MV_ERROR; - } - - /* attrib and targetId */ - targetAttrib.attrib = - (xorDecRegs.baseReg & XEBARX_ATTR_MASK) >> XEBARX_ATTR_OFFS; - targetAttrib.targetId = - (xorDecRegs.baseReg & XEBARX_TARGET_MASK) >> XEBARX_TARGET_OFFS; - - - pAddrDecWin->target = mvCtrlTargetGet(&targetAttrib); - - if(chanWinEn) - { - pAddrDecWin->enable = MV_TRUE; - } - else pAddrDecWin->enable = MV_FALSE; - - return MV_OK; -} - -/******************************************************************************* -* mvXorTargetWinEnable - Enable/disable a Xor address decode window -* -* DESCRIPTION: -* This function enable/disable a XOR address decode window. -* if parameter 'enable' == MV_TRUE the routine will enable the -* window, thus enabling XOR accesses (before enabling the window it is -* tested for overlapping). Otherwise, the window will be disabled. -* -* INPUT: -* winNum - Decode window number. -* enable - Enable/disable parameter. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM if parameters to function invalid, MV_OK otherwise. -* -*******************************************************************************/ -MV_STATUS mvXorTargetWinEnable(MV_U32 unit,MV_U32 winNum, MV_BOOL enable) -{ - MV_XOR_DEC_WIN addrDecWin; - MV_U32 chan; - - /* Parameter checking */ - if (winNum >= XOR_MAX_ADDR_DEC_WIN) - { - DB(mvOsPrintf("%s: ERR. Invalid winNum%d\n", __FUNCTION__, winNum)); - return MV_ERROR; - } - - if (enable == MV_TRUE) - { - /* Get current window */ - if (MV_OK != mvXorTargetWinGet(unit,winNum, &addrDecWin)) - { - DB(mvOsPrintf("%s: ERR. targetWinGet fail\n", __FUNCTION__)); - return MV_ERROR; - } - - /* Check for overlapping */ - if (MV_TRUE == xorWinOverlapDetect(unit,winNum, &(addrDecWin.addrWin))) - { - /* Overlap detected */ - DB(mvOsPrintf("%s: ERR. Overlap detected\n", __FUNCTION__)); - return MV_ERROR; - } - - /* No Overlap. Enable address decode target window */ - for (chan = 0; chan < MV_XOR_MAX_CHAN_PER_UNIT; chan++) - { - MV_REG_BIT_SET(XOR_WINDOW_CTRL_REG(unit,chan), - XEXWCR_WIN_EN_MASK(winNum)); - } - - } - else - { - /* Disable address decode target window */ - - for (chan = 0; chan < MV_XOR_MAX_CHAN_PER_UNIT; chan++) - { - MV_REG_BIT_RESET(XOR_WINDOW_CTRL_REG(unit,chan), - XEXWCR_WIN_EN_MASK(winNum)); - } - - } - - return MV_OK; -} - -/******************************************************************************* -* mvXorSetProtWinSet - Configure access attributes of a XOR engine -* to one of the XOR memory windows. -* -* DESCRIPTION: -* Each engine can be configured with access attributes for each of the -* memory spaces. This function sets access attributes -* to a given window for the given engine -* -* INPUTS: -* chan - One of the possible engines. -* winNum - One of the possible XOR memory spaces. -* access - Protection access rights. -* write - Write rights. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM if parameters to function invalid, MV_OK otherwise. -* -*******************************************************************************/ -MV_STATUS mvXorProtWinSet (MV_U32 unit,MV_U32 chan, MV_U32 winNum, MV_BOOL access, - MV_BOOL write) -{ - MV_U32 temp; - - /* Parameter checking */ - if (chan >= MV_XOR_MAX_CHAN_PER_UNIT) - { - DB(mvOsPrintf("%s: ERR. Invalid chan num %d\n", __FUNCTION__ , chan)); - return MV_BAD_PARAM; - } - if (winNum >= XOR_MAX_ADDR_DEC_WIN) - { - DB(mvOsPrintf("%s: ERR. Invalid win num %d\n", __FUNCTION__, winNum)); - return MV_BAD_PARAM; - } - - temp = MV_REG_READ(XOR_WINDOW_CTRL_REG(unit,chan)) & - (~XEXWCR_WIN_ACC_MASK(winNum)); - - /* if access is disable */ - if (!access) - { - /* disable access */ - temp |= XEXWCR_WIN_ACC_NO_ACC(winNum); - } - /* if access is enable */ - else - { - /* if write is enable */ - if (write) - { - /* enable write */ - temp |= XEXWCR_WIN_ACC_RW(winNum); - } - /* if write is disable */ - else - { - /* disable write */ - temp |= XEXWCR_WIN_ACC_RO(winNum); - } - } - MV_REG_WRITE(XOR_WINDOW_CTRL_REG(unit,chan),temp); - return MV_OK; -} - -/******************************************************************************* -* mvXorPciRemap - Set XOR remap register for PCI address windows. -* -* DESCRIPTION: -* only Windows 0-3 can be remapped. -* -* INPUT: -* winNum - window number -* pAddrDecWin - pointer to address space window structure -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM if parameters to function invalid, MV_OK otherwise. -* -*******************************************************************************/ -MV_STATUS mvXorPciRemap(MV_U32 unit,MV_U32 winNum, MV_U32 addrHigh) -{ - /* Parameter checking */ - if (winNum >= XOR_MAX_REMAP_WIN) - { - DB(mvOsPrintf("%s: ERR. Invalid win num %d\n", __FUNCTION__, winNum)); - return MV_BAD_PARAM; - } - - MV_REG_WRITE(XOR_HIGH_ADDR_REMAP_REG(unit,winNum), addrHigh); - - return MV_OK; -} - -/******************************************************************************* -* xorWinOverlapDetect - Detect XOR address windows overlaping -* -* DESCRIPTION: -* An unpredicted behaviour is expected in case XOR address decode -* windows overlaps. -* This function detects XOR address decode windows overlaping of a -* specified window. The function does not check the window itself for -* overlaping. The function also skipps disabled address decode windows. -* -* INPUT: -* winNum - address decode window number. -* pAddrDecWin - An address decode window struct. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_TRUE if the given address window overlap current address -* decode map, MV_FALSE otherwise, MV_ERROR if reading invalid data -* from registers. -* -*******************************************************************************/ -static MV_STATUS xorWinOverlapDetect(MV_U32 unit,MV_U32 winNum, MV_ADDR_WIN *pAddrWin) -{ - MV_U32 baseAddrEnableReg; - MV_U32 winNumIndex,chan; - MV_XOR_DEC_WIN addrDecWin; - - if (pAddrWin == NULL) - { - DB(mvOsPrintf("%s: ERR. pAddrWin is NULL pointer\n", __FUNCTION__ )); - return MV_BAD_PTR; - } - - for (chan = 0; chan < MV_XOR_MAX_CHAN_PER_UNIT; chan++) - { - /* Read base address enable register. Do not check disabled windows */ - baseAddrEnableReg = MV_REG_READ(XOR_WINDOW_CTRL_REG(unit,chan)); - - for (winNumIndex = 0; winNumIndex < XOR_MAX_ADDR_DEC_WIN; winNumIndex++) - { - /* Do not check window itself */ - if (winNumIndex == winNum) - { - continue; - } - - /* Do not check disabled windows */ - if ((baseAddrEnableReg & XEXWCR_WIN_EN_MASK(winNumIndex)) == 0) - { - continue; - } - - /* Get window parameters */ - if (MV_OK != mvXorTargetWinGet(unit,winNumIndex, &addrDecWin)) - { - DB(mvOsPrintf("%s: ERR. TargetWinGet failed\n", __FUNCTION__ )); - return MV_ERROR; - } - - if (MV_TRUE == ctrlWinOverlapTest(pAddrWin, &(addrDecWin.addrWin))) - { - return MV_TRUE; - } - } - } - - return MV_FALSE; -} - -static MV_VOID mvXorAddrDecShowUnit(MV_U32 unit) -{ - MV_XOR_DEC_WIN win; - int i; - - mvOsOutput( "\n" ); - mvOsOutput( "XOR %d:\n", unit ); - mvOsOutput( "----\n" ); - - for( i = 0; i < XOR_MAX_ADDR_DEC_WIN; i++ ) - { - memset( &win, 0, sizeof(MV_XOR_DEC_WIN) ); - - mvOsOutput( "win%d - ", i ); - - if( mvXorTargetWinGet(unit, i, &win ) == MV_OK ) - { - if( win.enable ) - { - mvOsOutput( "%s base %x, ", - mvCtrlTargetNameGet(win.target), win.addrWin.baseLow ); - - mvSizePrint( win.addrWin.size ); - - mvOsOutput( "\n" ); - } - else - mvOsOutput( "disable\n" ); - } - } -} - -/******************************************************************************* -* mvXorAddrDecShow - Print the XOR address decode map. -* -* DESCRIPTION: -* This function print the XOR address decode map. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_VOID mvXorAddrDecShow(MV_VOID) -{ - int i; - - for( i = 0; i < MV_XOR_MAX_UNIT; i++ ) - mvXorAddrDecShowUnit(i); - -} diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysXor.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysXor.h deleted file mode 100644 index 73b2d9e..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/ctrlEnv/sys/mvSysXor.h +++ /dev/null @@ -1,140 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCMVSysXorh -#define __INCMVSysXorh - - -#ifdef __cplusplus -extern "C" { -#endif - -#include "ctrlEnv/sys/mvCpuIf.h" - -#include "ctrlEnv/mvCtrlEnvLib.h" -#include "ctrlEnv/mvCtrlEnvAddrDec.h" - -#define XOR_MAX_ADDR_DEC_WIN 8 /* Maximum address decode windows */ -#define XOR_MAX_REMAP_WIN 4 /* Maximum address arbiter windows */ - -/* XOR Engine Address Decoding Register Map */ -#define XOR_WINDOW_CTRL_REG(unit,chan) (XOR_UNIT_BASE(unit)+(0x240 + ((chan) * 4))) -#define XOR_BASE_ADDR_REG(unit,winNum) (XOR_UNIT_BASE(unit)+(0x250 + ((winNum) * 4))) -#define XOR_SIZE_MASK_REG(unit,winNum) (XOR_UNIT_BASE(unit)+(0x270 + ((winNum) * 4))) -#define XOR_HIGH_ADDR_REMAP_REG(unit,winNum) (XOR_UNIT_BASE(unit)+(0x290 + ((winNum) * 4))) - -/* XOR Engine [0..1] Window Control Registers (XExWCR) */ -#define XEXWCR_WIN_EN_OFFS(winNum) (winNum) -#define XEXWCR_WIN_EN_MASK(winNum) (1 << (XEXWCR_WIN_EN_OFFS(winNum))) -#define XEXWCR_WIN_EN_ENABLE(winNum) (1 << (XEXWCR_WIN_EN_OFFS(winNum))) -#define XEXWCR_WIN_EN_DISABLE(winNum) (0 << (XEXWCR_WIN_EN_OFFS(winNum))) - -#define XEXWCR_WIN_ACC_OFFS(winNum) ((2 * winNum) + 16) -#define XEXWCR_WIN_ACC_MASK(winNum) (3 << (XEXWCR_WIN_ACC_OFFS(winNum))) -#define XEXWCR_WIN_ACC_NO_ACC(winNum) (0 << (XEXWCR_WIN_ACC_OFFS(winNum))) -#define XEXWCR_WIN_ACC_RO(winNum) (1 << (XEXWCR_WIN_ACC_OFFS(winNum))) -#define XEXWCR_WIN_ACC_RW(winNum) (3 << (XEXWCR_WIN_ACC_OFFS(winNum))) - -/* XOR Engine Base Address Registers (XEBARx) */ -#define XEBARX_TARGET_OFFS (0) -#define XEBARX_TARGET_MASK (0xF << XEBARX_TARGET_OFFS) -#define XEBARX_ATTR_OFFS (8) -#define XEBARX_ATTR_MASK (0xFF << XEBARX_ATTR_OFFS) -#define XEBARX_BASE_OFFS (16) -#define XEBARX_BASE_MASK (0xFFFF << XEBARX_BASE_OFFS) - -/* XOR Engine Size Mask Registers (XESMRx) */ -#define XESMRX_SIZE_MASK_OFFS (16) -#define XESMRX_SIZE_MASK_MASK (0xFFFF << XESMRX_SIZE_MASK_OFFS) - -/* XOR Engine High Address Remap Register (XEHARRx1) */ -#define XEHARRX_REMAP_OFFS (0) -#define XEHARRX_REMAP_MASK (0xFFFFFFFF << XEHARRX_REMAP_OFFS) - -typedef struct _mvXorDecWin -{ - MV_TARGET target; - MV_ADDR_WIN addrWin; /* An address window*/ - MV_BOOL enable; /* Address decode window is enabled/disabled */ - -}MV_XOR_DEC_WIN; - -MV_STATUS mvXorInit (MV_VOID); -MV_STATUS mvXorTargetWinSet(MV_U32 unit, MV_U32 winNum, - MV_XOR_DEC_WIN *pAddrDecWin); -MV_STATUS mvXorTargetWinGet(MV_U32 unit, MV_U32 winNum, - MV_XOR_DEC_WIN *pAddrDecWin); -MV_STATUS mvXorTargetWinEnable(MV_U32 unit, - MV_U32 winNum, MV_BOOL enable); -MV_STATUS mvXorProtWinSet (MV_U32 unit,MV_U32 chan, MV_U32 winNum, MV_BOOL access, - MV_BOOL write); -MV_STATUS mvXorPciRemap(MV_U32 unit, MV_U32 winNum, MV_U32 addrHigh); - -MV_VOID mvXorAddrDecShow(MV_VOID); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/device/mvDevice.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/device/mvDevice.c deleted file mode 100644 index 80325fc..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/device/mvDevice.c +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#include "device/mvDevice.h" - -/* defines */ -#ifdef MV_DEBUG - #define DB(x) x -#else - #define DB(x) -#endif - - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/device/mvDevice.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/device/mvDevice.h deleted file mode 100644 index 9350779..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/device/mvDevice.h +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCmvDeviceH -#define __INCmvDeviceH - -#include "mvCommon.h" -#include "mvOs.h" -#include "ctrlEnv/mvCtrlEnvSpec.h" -#include "device/mvDeviceRegs.h" - - -#endif /* #ifndef __INCmvDeviceH */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/device/mvDeviceRegs.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/device/mvDeviceRegs.h deleted file mode 100644 index 80778ad..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/kw_family/device/mvDeviceRegs.h +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCmvDeviceRegsH -#define __INCmvDeviceRegsH - -#ifndef MV_ASMLANGUAGE -#include "ctrlEnv/mvCtrlEnvLib.h" -/* This enumerator describes the Marvell controller possible devices that */ -/* can be connected to its device interface. */ -typedef enum _mvDevice -{ -#if defined(MV_INCLUDE_DEVICE_CS0) - DEV_CS0 = 0, /* Device connected to dev CS[0] */ -#endif -#if defined(MV_INCLUDE_DEVICE_CS1) - DEV_CS1 = 1, /* Device connected to dev CS[1] */ -#endif -#if defined(MV_INCLUDE_DEVICE_CS2) - DEV_CS2 = 2, /* Device connected to dev CS[2] */ -#endif -#if defined(MV_INCLUDE_DEVICE_CS3) - DEV_CS3 = 3, /* Device connected to dev CS[2] */ -#endif -#if defined(MV_INCLUDE_DEVICE_CS4) - DEV_CS4 = 4, /* Device connected to BOOT dev */ -#endif - MV_DEV_MAX_CS = MV_DEVICE_MAX_CS -}MV_DEVICE; - - -#endif /* MV_ASMLANGUAGE */ - - -#define NAND_CTRL_REG 0x10470 - -#define NAND_ACTCEBOOT_BIT BIT1 - - -#endif /* #ifndef __INCmvDeviceRegsH */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/linux_oss/mvOs.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/linux_oss/mvOs.c deleted file mode 100644 index 75f7e88..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/linux_oss/mvOs.c +++ /dev/null @@ -1,211 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -*******************************************************************************/ -/******************************************************************************* -* mvOsCpuArchLib.c - Marvell CPU architecture library -* -* DESCRIPTION: -* This library introduce Marvell API for OS dependent CPU architecture -* APIs. This library introduce single CPU architecture services APKI -* cross OS. -* -* DEPENDENCIES: -* None. -* -*******************************************************************************/ - -/* includes */ -#include <asm/processor.h> -#include "mvOs.h" - -static MV_U32 read_p15_c0 (void); - -/* defines */ -#define ARM_ID_REVISION_OFFS 0 -#define ARM_ID_REVISION_MASK (0xf << ARM_ID_REVISION_OFFS) - -#define ARM_ID_PART_NUM_OFFS 4 -#define ARM_ID_PART_NUM_MASK (0xfff << ARM_ID_PART_NUM_OFFS) - -#define ARM_ID_ARCH_OFFS 16 -#define ARM_ID_ARCH_MASK (0xf << ARM_ID_ARCH_OFFS) - -#define ARM_ID_VAR_OFFS 20 -#define ARM_ID_VAR_MASK (0xf << ARM_ID_VAR_OFFS) - -#define ARM_ID_ASCII_OFFS 24 -#define ARM_ID_ASCII_MASK (0xff << ARM_ID_ASCII_OFFS) - - - -void* mvOsIoCachedMalloc( void* osHandle, MV_U32 size, MV_ULONG* pPhyAddr, - MV_U32 *memHandle) -{ - void *p = kmalloc( size, GFP_KERNEL ); - *pPhyAddr = pci_map_single( osHandle, p, 0, PCI_DMA_BIDIRECTIONAL ); - return p; -} -void* mvOsIoUncachedMalloc( void* osHandle, MV_U32 size, MV_ULONG* pPhyAddr, - MV_U32 *memHandle) -{ - return pci_alloc_consistent( osHandle, size, (dma_addr_t *)pPhyAddr ); -} - -void mvOsIoUncachedFree( void* osHandle, MV_U32 size, MV_ULONG phyAddr, void* pVirtAddr, - MV_U32 memHandle) -{ - return pci_free_consistent( osHandle, size, pVirtAddr, (dma_addr_t)phyAddr ); -} - -void mvOsIoCachedFree( void* osHandle, MV_U32 size, MV_ULONG phyAddr, void* pVirtAddr, - MV_U32 memHandle ) -{ - return kfree( pVirtAddr ); -} - -int mvOsRand(void) -{ - int rand; - get_random_bytes(&rand, sizeof(rand) ); - return rand; -} - -/******************************************************************************* -* mvOsCpuVerGet() - -* -* DESCRIPTION: -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* 32bit CPU Revision -* -*******************************************************************************/ -MV_U32 mvOsCpuRevGet( MV_VOID ) -{ - return ((read_p15_c0() & ARM_ID_REVISION_MASK ) >> ARM_ID_REVISION_OFFS); -} -/******************************************************************************* -* mvOsCpuPartGet() - -* -* DESCRIPTION: -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* 32bit CPU Part number -* -*******************************************************************************/ -MV_U32 mvOsCpuPartGet( MV_VOID ) -{ - return ((read_p15_c0() & ARM_ID_PART_NUM_MASK ) >> ARM_ID_PART_NUM_OFFS); -} -/******************************************************************************* -* mvOsCpuArchGet() - -* -* DESCRIPTION: -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* 32bit CPU Architicture number -* -*******************************************************************************/ -MV_U32 mvOsCpuArchGet( MV_VOID ) -{ - return ((read_p15_c0() & ARM_ID_ARCH_MASK ) >> ARM_ID_ARCH_OFFS); -} -/******************************************************************************* -* mvOsCpuVarGet() - -* -* DESCRIPTION: -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* 32bit CPU Variant number -* -*******************************************************************************/ -MV_U32 mvOsCpuVarGet( MV_VOID ) -{ - return ((read_p15_c0() & ARM_ID_VAR_MASK ) >> ARM_ID_VAR_OFFS); -} -/******************************************************************************* -* mvOsCpuAsciiGet() - -* -* DESCRIPTION: -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* 32bit CPU Variant number -* -*******************************************************************************/ -MV_U32 mvOsCpuAsciiGet( MV_VOID ) -{ - return ((read_p15_c0() & ARM_ID_ASCII_MASK ) >> ARM_ID_ASCII_OFFS); -} - - - -/* -static unsigned long read_p15_c0 (void) -*/ -/* read co-processor 15, register #0 (ID register) */ -static MV_U32 read_p15_c0 (void) -{ - MV_U32 value; - - __asm__ __volatile__( - "mrc p15, 0, %0, c0, c0, 0 @ read control reg\n" - : "=r" (value) - : - : "memory"); - - return value; -} - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/linux_oss/mvOs.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/linux_oss/mvOs.h deleted file mode 100644 index 8da562a..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/linux_oss/mvOs.h +++ /dev/null @@ -1,423 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -*******************************************************************************/ -#ifndef _MV_OS_LNX_H_ -#define _MV_OS_LNX_H_ - - -#ifdef __KERNEL__ -/* for kernel space */ -#include <linux/autoconf.h> -#include <linux/interrupt.h> -#include <linux/stddef.h> -#include <linux/kernel.h> -#include <linux/init.h> -#include <linux/errno.h> -#include <linux/reboot.h> -#include <linux/pci.h> -#include <linux/kdev_t.h> -#include <linux/major.h> -#include <linux/blkdev.h> -#include <linux/console.h> -#include <linux/delay.h> -#include <linux/seq_file.h> -#include <linux/string.h> -#include <linux/slab.h> -#include <linux/kernel.h> -#include <linux/string.h> -#include <linux/slab.h> -#include <linux/mm.h> - -#include <asm/system.h> -#include <asm/pgtable.h> -#include <asm/page.h> -#include <asm/hardirq.h> -#include <asm/dma.h> -#include <asm/io.h> - -#include <linux/random.h> - -#include "dbg-trace.h" - -extern void mv_early_printk(char *fmt,...); - -#define MV_ASM __asm__ __volatile__ -#define INLINE inline -#define MV_TRC_REC TRC_REC -#define mvOsPrintf printk -#define mvOsEarlyPrintf mv_early_printk -#define mvOsOutput printk -#define mvOsSPrintf sprintf -#define mvOsMalloc(_size_) kmalloc(_size_,GFP_ATOMIC) -#define mvOsFree kfree -#define mvOsMemcpy memcpy -#define mvOsSleep(_mils_) mdelay(_mils_) -#define mvOsTaskLock() -#define mvOsTaskUnlock() -#define strtol simple_strtoul -#define mvOsDelay(x) mdelay(x) -#define mvOsUDelay(x) udelay(x) -#define mvCopyFromOs copy_from_user -#define mvCopyToOs copy_to_user - - -#include "mvTypes.h" -#include "mvCommon.h" - -#ifdef MV_NDEBUG -#define mvOsAssert(cond) -#else -#define mvOsAssert(cond) { do { if(!(cond)) { BUG(); } }while(0); } -#endif /* MV_NDEBUG */ - -#else /* __KERNEL__ */ - -/* for user space applications */ -#include <stdlib.h> -#include <stdio.h> -#include <assert.h> -#include <string.h> - -#define INLINE inline -#define mvOsPrintf printf -#define mvOsOutput printf -#define mvOsMalloc(_size_) malloc(_size_) -#define mvOsFree free -#define mvOsAssert(cond) assert(cond) - -#endif /* __KERNEL__ */ -#define mvOsIoVirtToPhy(pDev, pVirtAddr) \ - pci_map_single( (pDev), (pVirtAddr), 0, PCI_DMA_BIDIRECTIONAL ) - -#define mvOsCacheClear(pDev, p, size ) \ - pci_map_single( (pDev), (p), (size), PCI_DMA_BIDIRECTIONAL) - -#define mvOsCacheFlush(pDev, p, size ) \ - pci_map_single( (pDev), (p), (size), PCI_DMA_TODEVICE) - -#define mvOsCacheInvalidate(pDev, p, size) \ - pci_map_single( (pDev), (p), (size), PCI_DMA_FROMDEVICE ) - -#define mvOsCacheUnmap(pDev, phys, size) \ - pci_unmap_single( (pDev), (dma_addr_t)(phys), (size), PCI_DMA_FROMDEVICE ) - - -#define CPU_PHY_MEM(x) (MV_U32)x -#define CPU_MEMIO_CACHED_ADDR(x) (void*)x -#define CPU_MEMIO_UNCACHED_ADDR(x) (void*)x - - -/* CPU architecture dependent 32, 16, 8 bit read/write IO addresses */ -#define MV_MEMIO32_WRITE(addr, data) \ - ((*((volatile unsigned int*)(addr))) = ((unsigned int)(data))) - -#define MV_MEMIO32_READ(addr) \ - ((*((volatile unsigned int*)(addr)))) - -#define MV_MEMIO16_WRITE(addr, data) \ - ((*((volatile unsigned short*)(addr))) = ((unsigned short)(data))) - -#define MV_MEMIO16_READ(addr) \ - ((*((volatile unsigned short*)(addr)))) - -#define MV_MEMIO8_WRITE(addr, data) \ - ((*((volatile unsigned char*)(addr))) = ((unsigned char)(data))) - -#define MV_MEMIO8_READ(addr) \ - ((*((volatile unsigned char*)(addr)))) - - -/* No Fast Swap implementation (in assembler) for ARM */ -#define MV_32BIT_LE_FAST(val) MV_32BIT_LE(val) -#define MV_16BIT_LE_FAST(val) MV_16BIT_LE(val) -#define MV_32BIT_BE_FAST(val) MV_32BIT_BE(val) -#define MV_16BIT_BE_FAST(val) MV_16BIT_BE(val) - -/* 32 and 16 bit read/write in big/little endian mode */ - -/* 16bit write in little endian mode */ -#define MV_MEMIO_LE16_WRITE(addr, data) \ - MV_MEMIO16_WRITE(addr, MV_16BIT_LE_FAST(data)) - -/* 16bit read in little endian mode */ -static __inline MV_U16 MV_MEMIO_LE16_READ(MV_U32 addr) -{ - MV_U16 data; - - data= (MV_U16)MV_MEMIO16_READ(addr); - - return (MV_U16)MV_16BIT_LE_FAST(data); -} - -/* 32bit write in little endian mode */ -#define MV_MEMIO_LE32_WRITE(addr, data) \ - MV_MEMIO32_WRITE(addr, MV_32BIT_LE_FAST(data)) - -/* 32bit read in little endian mode */ -static __inline MV_U32 MV_MEMIO_LE32_READ(MV_U32 addr) -{ - MV_U32 data; - - data= (MV_U32)MV_MEMIO32_READ(addr); - - return (MV_U32)MV_32BIT_LE_FAST(data); -} - -static __inline void mvOsBCopy(char* srcAddr, char* dstAddr, int byteCount) -{ - while(byteCount != 0) - { - *dstAddr = *srcAddr; - dstAddr++; - srcAddr++; - byteCount--; - } -} - -static INLINE MV_U64 mvOsDivMod64(MV_U64 divided, MV_U64 divisor, MV_U64* modulu) -{ - MV_U64 division = 0; - - if(divisor == 1) - return divided; - - while(divided >= divisor) - { - division++; - divided -= divisor; - } - if (modulu != NULL) - *modulu = divided; - - return division; -} - -#if defined(MV_BRIDGE_SYNC_REORDER) -extern MV_U32 *mvUncachedParam; - -static __inline void mvOsBridgeReorderWA(void) -{ - volatile MV_U32 val = 0; - - val = mvUncachedParam[0]; -} -#endif - - -/* Flash APIs */ -#define MV_FL_8_READ MV_MEMIO8_READ -#define MV_FL_16_READ MV_MEMIO_LE16_READ -#define MV_FL_32_READ MV_MEMIO_LE32_READ -#define MV_FL_8_DATA_READ MV_MEMIO8_READ -#define MV_FL_16_DATA_READ MV_MEMIO16_READ -#define MV_FL_32_DATA_READ MV_MEMIO32_READ -#define MV_FL_8_WRITE MV_MEMIO8_WRITE -#define MV_FL_16_WRITE MV_MEMIO_LE16_WRITE -#define MV_FL_32_WRITE MV_MEMIO_LE32_WRITE -#define MV_FL_8_DATA_WRITE MV_MEMIO8_WRITE -#define MV_FL_16_DATA_WRITE MV_MEMIO16_WRITE -#define MV_FL_32_DATA_WRITE MV_MEMIO32_WRITE - - -/* CPU cache information */ -#define CPU_I_CACHE_LINE_SIZE 32 /* 2do: replace 32 with linux core macro */ -#define CPU_D_CACHE_LINE_SIZE 32 /* 2do: replace 32 with linux core macro */ - -#ifdef CONFIG_L2_CACHE_ENABLE -/* Data cache flush one line */ -#define mvOsCacheLineFlushInv(handle, addr) \ -{ \ - __asm__ __volatile__ ("mcr p15, 0, %0, c7, c14, 1" : : "r" (addr));\ - __asm__ __volatile__ ("mcr p15, 1, %0, c15, c10, 1" : : "r" (addr));\ - __asm__ __volatile__ ("mcr p15, 0, r0, c7, c10, 4"); \ -} - -#else - -/* Data cache flush one line */ -#define mvOsCacheLineFlushInv(handle, addr) \ -{ \ - __asm__ __volatile__ ("mcr p15, 0, %0, c7, c14, 1" : : "r" (addr));\ - __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" : : "r" (addr)); \ -} -#endif - -#ifdef CONFIG_L2_CACHE_ENABLE -#define mvOsCacheLineInv(handle,addr) \ -{ \ - __asm__ __volatile__ ("mcr p15, 0, %0, c7, c6, 1" : : "r" (addr)); \ - __asm__ __volatile__ ("mcr p15, 1, %0, c15, c11, 1" : : "r" (addr)); \ -} -#else -#define mvOsCacheLineInv(handle,addr) \ -{ \ - __asm__ __volatile__ ("mcr p15, 0, %0, c7, c6, 1" : : "r" (addr)); \ -} -#endif - -#ifdef CONFIG_L2_CACHE_ENABLE -/* Data cache flush one line */ -#define mvOsCacheLineFlush(handle, addr) \ -{ \ - __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 1" : : "r" (addr));\ - __asm__ __volatile__ ("mcr p15, 1, %0, c15, c9, 1" : : "r" (addr));\ - __asm__ __volatile__ ("mcr p15, 0, r0, c7, c10, 4"); \ -} - -#else -/* Data cache flush one line */ -#define mvOsCacheLineFlush(handle, addr) \ -{ \ - __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 1" : : "r" (addr));\ - __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" : : "r" (addr)); \ -} -#endif - -static __inline void mvOsPrefetch(const void *ptr) -{ -#ifdef CONFIG_USE_DSP - __asm__ __volatile__( - "pld\t%0" - : - : "o" (*(char *)ptr) - : "cc"); -#else - return; -#endif -} - - -/* Flush CPU pipe */ -#define CPU_PIPE_FLUSH - - - - - -/* register manipulations */ - -/****************************************************************************** -* This debug function enable the write of each register that u-boot access to -* to an array in the DRAM, the function record only MV_REG_WRITE access. -* The function could not be operate when booting from flash. -* In order to print the array we use the printreg command. -******************************************************************************/ -/* #define REG_DEBUG */ -#if defined(REG_DEBUG) -extern int reg_arry[2048][2]; -extern int reg_arry_index; -#endif - -/* Marvell controller register read/write macros */ -#define MV_REG_VALUE(offset) \ - (MV_MEMIO32_READ((INTER_REGS_BASE | (offset)))) - -#define MV_REG_READ(offset) \ - (MV_MEMIO_LE32_READ(INTER_REGS_BASE | (offset))) - -#if defined(REG_DEBUG) -#define MV_REG_WRITE(offset, val) \ - MV_MEMIO_LE32_WRITE((INTER_REGS_BASE | (offset)), (val)); \ - { \ - reg_arry[reg_arry_index][0] = (INTER_REGS_BASE | (offset));\ - reg_arry[reg_arry_index][1] = (val);\ - reg_arry_index++;\ - } -#else -#define MV_REG_WRITE(offset, val) \ - MV_MEMIO_LE32_WRITE((INTER_REGS_BASE | (offset)), (val)); -#endif - -#define MV_REG_BYTE_READ(offset) \ - (MV_MEMIO8_READ((INTER_REGS_BASE | (offset)))) - -#if defined(REG_DEBUG) -#define MV_REG_BYTE_WRITE(offset, val) \ - MV_MEMIO8_WRITE((INTER_REGS_BASE | (offset)), (val)); \ - { \ - reg_arry[reg_arry_index][0] = (INTER_REGS_BASE | (offset));\ - reg_arry[reg_arry_index][1] = (val);\ - reg_arry_index++;\ - } -#else -#define MV_REG_BYTE_WRITE(offset, val) \ - MV_MEMIO8_WRITE((INTER_REGS_BASE | (offset)), (val)) -#endif - -#if defined(REG_DEBUG) -#define MV_REG_BIT_SET(offset, bitMask) \ - (MV_MEMIO32_WRITE((INTER_REGS_BASE | (offset)), \ - (MV_MEMIO32_READ(INTER_REGS_BASE | (offset)) | \ - MV_32BIT_LE_FAST(bitMask)))); \ - { \ - reg_arry[reg_arry_index][0] = (INTER_REGS_BASE | (offset));\ - reg_arry[reg_arry_index][1] = (MV_MEMIO32_READ(INTER_REGS_BASE | (offset)));\ - reg_arry_index++;\ - } -#else -#define MV_REG_BIT_SET(offset, bitMask) \ - (MV_MEMIO32_WRITE((INTER_REGS_BASE | (offset)), \ - (MV_MEMIO32_READ(INTER_REGS_BASE | (offset)) | \ - MV_32BIT_LE_FAST(bitMask)))) -#endif - -#if defined(REG_DEBUG) -#define MV_REG_BIT_RESET(offset,bitMask) \ - (MV_MEMIO32_WRITE((INTER_REGS_BASE | (offset)), \ - (MV_MEMIO32_READ(INTER_REGS_BASE | (offset)) & \ - MV_32BIT_LE_FAST(~bitMask)))); \ - { \ - reg_arry[reg_arry_index][0] = (INTER_REGS_BASE | (offset));\ - reg_arry[reg_arry_index][1] = (MV_MEMIO32_READ(INTER_REGS_BASE | (offset)));\ - reg_arry_index++;\ - } -#else -#define MV_REG_BIT_RESET(offset,bitMask) \ - (MV_MEMIO32_WRITE((INTER_REGS_BASE | (offset)), \ - (MV_MEMIO32_READ(INTER_REGS_BASE | (offset)) & \ - MV_32BIT_LE_FAST(~bitMask)))) -#endif - - - -/* ARM architecture APIs */ -MV_U32 mvOsCpuRevGet (MV_VOID); -MV_U32 mvOsCpuPartGet (MV_VOID); -MV_U32 mvOsCpuArchGet (MV_VOID); -MV_U32 mvOsCpuVarGet (MV_VOID); -MV_U32 mvOsCpuAsciiGet (MV_VOID); - -/* Other APIs */ -void* mvOsIoCachedMalloc( void* osHandle, MV_U32 size, MV_ULONG* pPhyAddr, MV_U32 *memHandle); -void* mvOsIoUncachedMalloc( void* osHandle, MV_U32 size, MV_ULONG* pPhyAddr, MV_U32 *memHandle ); -void mvOsIoUncachedFree( void* osHandle, MV_U32 size, MV_ULONG phyAddr, void* pVirtAddr, MV_U32 memHandle ); -void mvOsIoCachedFree( void* osHandle, MV_U32 size, MV_ULONG phyAddr, void* pVirtAddr, MV_U32 memHandle ); -int mvOsRand(void); - -#endif /* _MV_OS_LNX_H_ */ - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/linux_oss/mvOsSata.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/linux_oss/mvOsSata.h deleted file mode 100644 index c925a9e..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/linux_oss/mvOsSata.h +++ /dev/null @@ -1,158 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -*******************************************************************************/ -/******************************************************************************* -* mvOsLinux.h - O.S. interface header file for Linux -* -* DESCRIPTION: -* This header file contains OS dependent definition under Linux -* -* DEPENDENCIES: -* Linux kernel header files. -* -* FILE REVISION NUMBER: -* $Revision: 1.1 $ -*******************************************************************************/ - -#ifndef __INCmvOsLinuxh -#define __INCmvOsLinuxh - -/* Includes */ -#include <linux/autoconf.h> -#include <linux/module.h> -#include <linux/types.h> -#include <linux/string.h> -#include <linux/kernel.h> -#include <linux/timer.h> -#include <linux/mm.h> -#include <linux/interrupt.h> -#include <linux/major.h> -#include <linux/errno.h> -#include <linux/genhd.h> -#include <linux/slab.h> -#include <linux/delay.h> -#include <linux/ide.h> -#include <linux/pci.h> - -#include <asm/byteorder.h> -#include <asm/irq.h> -#include <asm/uaccess.h> -#include <asm/io.h> -#include "mvOs.h" - - -/* Definitions */ -#define MV_DEFAULT_QUEUE_DEPTH 2 -#define MV_SATA_SUPPORT_EDMA_SINGLE_DATA_REGION -#define MV_SATA_SUPPORT_GEN2E_128_QUEUE_LEN - -#ifdef CONFIG_MV88F6082 - #define MV_SATA_OVERRIDE_SW_QUEUE_SIZE - #define MV_SATA_REQUESTED_SW_QUEUE_SIZE 2 - #undef MV_SATA_SUPPORT_GEN2E_128_QUEUE_LEN -#endif - -/* System dependent macro for flushing CPU write cache */ -#if defined (MV_BRIDGE_SYNC_REORDER) -#define MV_CPU_WRITE_BUFFER_FLUSH() do { \ - wmb(); \ - mvOsBridgeReorderWA(); \ - } while (0) -#else -#define MV_CPU_WRITE_BUFFER_FLUSH() wmb() -#endif /* CONFIG_MV78XX0 */ - -/* System dependent little endian from / to CPU conversions */ -#define MV_CPU_TO_LE16(x) cpu_to_le16(x) -#define MV_CPU_TO_LE32(x) cpu_to_le32(x) - -#define MV_LE16_TO_CPU(x) le16_to_cpu(x) -#define MV_LE32_TO_CPU(x) le32_to_cpu(x) - -#ifdef __BIG_ENDIAN_BITFIELD -#define MV_BIG_ENDIAN_BITFIELD -#endif - -/* System dependent register read / write in byte/word/dword variants */ -#define MV_REG_WRITE_BYTE(base, offset, val) writeb(val, base + offset) -#define MV_REG_WRITE_WORD(base, offset, val) writew(val, base + offset) -#define MV_REG_WRITE_DWORD(base, offset, val) writel(val, base + offset) -#define MV_REG_READ_BYTE(base, offset) readb(base + offset) -#define MV_REG_READ_WORD(base, offset) readw(base + offset) -#define MV_REG_READ_DWORD(base, offset) readl(base + offset) - - -/* Typedefs */ - -/* System dependant typedefs */ -typedef void *MV_VOID_PTR; -typedef u32 *MV_U32_PTR; -typedef u16 *MV_U16_PTR; -typedef u8 *MV_U8_PTR; -typedef char *MV_CHAR_PTR; -typedef void *MV_BUS_ADDR_T; -typedef unsigned long MV_CPU_FLAGS; - - -/* Structures */ -/* System dependent structure */ -typedef struct mvOsSemaphore -{ - int notUsed; -} MV_OS_SEMAPHORE; - - -/* Functions (User implemented)*/ - -/* Semaphore init, take and release */ -#define mvOsSemInit(x) MV_TRUE -#define mvOsSemTake(x) -#define mvOsSemRelease(x) - -/* Interrupt masking and unmasking functions */ -MV_CPU_FLAGS mvOsSaveFlagsAndMaskCPUInterrupts(MV_VOID); -MV_VOID mvOsRestoreFlags(MV_CPU_FLAGS); - -/* Delay function in micro seconds resolution */ -void mvMicroSecondsDelay(MV_VOID_PTR, MV_U32); - -/* Typedefs */ -typedef enum mvBoolean -{ - MV_SFALSE, MV_STRUE -} MV_BOOLEAN; - -/* System logging function */ -#include "mvLog.h" -/* Enable READ/WRITE Long SCSI command only when driver is compiled for debugging */ -#ifdef MV_LOGGER -#define MV_SATA_SUPPORT_READ_WRITE_LONG -#endif - -#define MV_IAL_LOG_ID 3 - -#endif /* __INCmvOsLinuxh */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mvSysHwConfig.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mvSysHwConfig.h deleted file mode 100644 index d761060..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mvSysHwConfig.h +++ /dev/null @@ -1,375 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. - -*******************************************************************************/ -/******************************************************************************* -* mvSysHwCfg.h - Marvell system HW configuration file -* -* DESCRIPTION: -* None. -* -* DEPENDENCIES: -* None. -* -*******************************************************************************/ - -#ifndef __INCmvSysHwConfigh -#define __INCmvSysHwConfigh - -#include "../../../../include/linux/autoconf.h" - -#define CONFIG_MARVELL 1 - -/* includes */ -#define _1K 0x00000400 -#define _4K 0x00001000 -#define _8K 0x00002000 -#define _16K 0x00004000 -#define _32K 0x00008000 -#define _64K 0x00010000 -#define _128K 0x00020000 -#define _256K 0x00040000 -#define _512K 0x00080000 - -#define _1M 0x00100000 -#define _2M 0x00200000 -#define _4M 0x00400000 -#define _8M 0x00800000 -#define _16M 0x01000000 -#define _32M 0x02000000 -#define _64M 0x04000000 -#define _128M 0x08000000 -#define _256M 0x10000000 -#define _512M 0x20000000 - -#define _1G 0x40000000 -#define _2G 0x80000000 - -/****************************************/ -/* Soc supporeted Units definitions */ -/****************************************/ - -#ifdef CONFIG_MV_INCLUDE_PEX -#define MV_INCLUDE_PEX -#endif -#ifdef CONFIG_MV_INCLUDE_TWSI -#define MV_INCLUDE_TWSI -#endif -#ifdef CONFIG_MV_INCLUDE_CESA -#define MV_INCLUDE_CESA -#endif -#ifdef CONFIG_MV_INCLUDE_GIG_ETH -#define MV_INCLUDE_GIG_ETH -#endif -#ifdef CONFIG_MV_INCLUDE_INTEG_SATA -#define MV_INCLUDE_INTEG_SATA -#define MV_INCLUDE_SATA -#endif -#ifdef CONFIG_MV_INCLUDE_USB -#define MV_INCLUDE_USB -#define MV_USB_VOLTAGE_FIX -#endif -#ifdef CONFIG_MV_INCLUDE_NAND -#define MV_INCLUDE_NAND -#endif -#ifdef CONFIG_MV_INCLUDE_TDM -#define MV_INCLUDE_TDM -#endif -#ifdef CONFIG_MV_INCLUDE_XOR -#define MV_INCLUDE_XOR -#endif -#ifdef CONFIG_MV_INCLUDE_TWSI -#define MV_INCLUDE_TWSI -#endif -#ifdef CONFIG_MV_INCLUDE_UART -#define MV_INCLUDE_UART -#endif -#ifdef CONFIG_MV_INCLUDE_SPI -#define MV_INCLUDE_SPI -#endif -#ifdef CONFIG_MV_INCLUDE_SFLASH_MTD -#define MV_INCLUDE_SFLASH_MTD -#endif -#ifdef CONFIG_MV_INCLUDE_AUDIO -#define MV_INCLUDE_AUDIO -#endif -#ifdef CONFIG_MV_INCLUDE_TS -#define MV_INCLUDE_TS -#endif -#ifdef CONFIG_MV_INCLUDE_SDIO -#define MV_INCLUDE_SDIO -#endif - - -/* NAND flash stuff */ -#ifdef CONFIG_MV_NAND_BOOT -#define MV_NAND_BOOT -#endif -#ifdef CONFIG_MV_NAND -#define MV_NAND -#endif - -/* SPI flash stuff */ -#ifdef CONFIG_MV_SPI_BOOT -#define MV_SPI_BOOT -#endif - - -/****************************************************************/ -/************* General configuration ********************/ -/****************************************************************/ - -/* Enable Clock Power Control */ -#define MV_INCLUDE_CLK_PWR_CNTRL - -/* Disable the DEVICE BAR in the PEX */ -#define MV_DISABLE_PEX_DEVICE_BAR - -/* Allow the usage of early printings during initialization */ -#define MV_INCLUDE_EARLY_PRINTK - -/****************************************************************/ -/************* NFP configuration ********************************/ -/****************************************************************/ -#define MV_NFP_SEC_Q_SIZE 64 -#define MV_NFP_SEC_REQ_Q_SIZE 1000 - - - -/****************************************************************/ -/************* CESA configuration ********************/ -/****************************************************************/ - -#ifdef MV_INCLUDE_CESA - -#define MV_CESA_MAX_CHAN 4 - -/* Use 2K of SRAM */ -#define MV_CESA_MAX_BUF_SIZE 1600 - -#endif /* MV_INCLUDE_CESA */ - -#if defined(CONFIG_MV_INCLUDE_GIG_ETH) - -#ifdef CONFIG_MV_NFP_STATS -#define MV_FP_STATISTICS -#else -#undef MV_FP_STATISTICS -#endif -/* Default configuration for SKB_REUSE: 0 - Disabled, 1 - Enabled */ -#define MV_ETH_SKB_REUSE_DEFAULT 1 -/* Default configuration for TX_EN workaround: 0 - Disabled, 1 - Enabled */ -#define MV_ETH_TX_EN_DEFAULT 0 - -/* un-comment if you want to perform tx_done from within the poll function */ -/* #define ETH_TX_DONE_ISR */ - -/* put descriptors in uncached memory */ -/* #define ETH_DESCR_UNCACHED */ - -/* Descriptors location: DRAM/internal-SRAM */ -#define ETH_DESCR_IN_SDRAM -#undef ETH_DESCR_IN_SRAM /* No integrated SRAM in 88Fxx81 devices */ - -#if defined(ETH_DESCR_IN_SRAM) -#if defined(ETH_DESCR_UNCACHED) - #define ETH_DESCR_CONFIG_STR "Uncached descriptors in integrated SRAM" -#else - #define ETH_DESCR_CONFIG_STR "Cached descriptors in integrated SRAM" -#endif -#elif defined(ETH_DESCR_IN_SDRAM) -#if defined(ETH_DESCR_UNCACHED) - #define ETH_DESCR_CONFIG_STR "Uncached descriptors in DRAM" -#else - #define ETH_DESCR_CONFIG_STR "Cached descriptors in DRAM" -#endif -#else - #error "Ethernet descriptors location undefined" -#endif /* ETH_DESCR_IN_SRAM or ETH_DESCR_IN_SDRAM*/ - -/* SW Sync-Barrier: not relevant for 88fxx81*/ -/* Reasnable to define this macro when descriptors in SRAM and buffers in DRAM */ -/* In RX the CPU theoretically might see himself as the descriptor owner, */ -/* although the buffer hadn't been written to DRAM yet. Performance cost. */ -/* #define INCLUDE_SYNC_BARR */ - -/* Buffers cache coherency method (buffers in DRAM) */ -#ifndef MV_CACHE_COHER_SW -/* Taken from mvCommon.h */ -/* Memory uncached, HW or SW cache coherency is not needed */ -#define MV_UNCACHED 0 -/* Memory cached, HW cache coherency supported in WriteThrough mode */ -#define MV_CACHE_COHER_HW_WT 1 -/* Memory cached, HW cache coherency supported in WriteBack mode */ -#define MV_CACHE_COHER_HW_WB 2 -/* Memory cached, No HW cache coherency, Cache coherency must be in SW */ -#define MV_CACHE_COHER_SW 3 - -#endif - -/* DRAM cache coherency configuration */ -#define MV_CACHE_COHERENCY MV_CACHE_COHER_SW - - -#define ETHER_DRAM_COHER MV_CACHE_COHER_SW /* No HW coherency in 88Fxx81 devices */ - -#if (ETHER_DRAM_COHER == MV_CACHE_COHER_HW_WB) - #define ETH_SDRAM_CONFIG_STR "DRAM HW cache coherency (write-back)" -#elif (ETHER_DRAM_COHER == MV_CACHE_COHER_HW_WT) - #define ETH_SDRAM_CONFIG_STR "DRAM HW cache coherency (write-through)" -#elif (ETHER_DRAM_COHER == MV_CACHE_COHER_SW) - #define ETH_SDRAM_CONFIG_STR "DRAM SW cache-coherency" -#elif (ETHER_DRAM_COHER == MV_UNCACHED) -# define ETH_SDRAM_CONFIG_STR "DRAM uncached" -#else - #error "Ethernet-DRAM undefined" -#endif /* ETHER_DRAM_COHER */ - - -/****************************************************************/ -/************* Ethernet driver configuration ********************/ -/****************************************************************/ - -/* port's default queueus */ -#define ETH_DEF_TXQ 0 -#define ETH_DEF_RXQ 0 - -#define MV_ETH_RX_Q_NUM CONFIG_MV_ETH_RX_Q_NUM -#define MV_ETH_TX_Q_NUM CONFIG_MV_ETH_TX_Q_NUM - -/* interrupt coalescing setting */ -#define ETH_TX_COAL 200 -#define ETH_RX_COAL 200 - -/* Checksum offloading */ -#define TX_CSUM_OFFLOAD -#define RX_CSUM_OFFLOAD - -#endif /* CONFIG_MV_INCLUDE_GIG_ETH */ - -/****************************************************************/ -/*************** Telephony configuration ************************/ -/****************************************************************/ -#if defined(CONFIG_MV_TDM_LINEAR_MODE) - #define MV_TDM_LINEAR_MODE -#elif defined(CONFIG_MV_TDM_ULAW_MODE) - #define MV_TDM_ULAW_MODE -#endif - -#if defined(CONFIG_MV_TDM_5CHANNELS) - #define MV_TDM_5CHANNELS -#endif - -#if defined(CONFIG_MV_TDM_USE_EXTERNAL_PCLK_SOURCE) - #define MV_TDM_USE_EXTERNAL_PCLK_SOURCE -#endif - -/* We use the following registers to store DRAM interface pre configuration */ -/* auto-detection results */ -/* IMPORTANT: We are using mask register for that purpose. Before writing */ -/* to units mask register, make sure main maks register is set to disable */ -/* all interrupts. */ -#define DRAM_BUF_REG0 0x30810 /* sdram bank 0 size */ -#define DRAM_BUF_REG1 0x30820 /* sdram config */ -#define DRAM_BUF_REG2 0x30830 /* sdram mode */ -#define DRAM_BUF_REG3 0x308c4 /* dunit control low */ -#define DRAM_BUF_REG4 0x60a90 /* sdram address control */ -#define DRAM_BUF_REG5 0x60a94 /* sdram timing control low */ -#define DRAM_BUF_REG6 0x60a98 /* sdram timing control high */ -#define DRAM_BUF_REG7 0x60a9c /* sdram ODT control low */ -#define DRAM_BUF_REG8 0x60b90 /* sdram ODT control high */ -#define DRAM_BUF_REG9 0x60b94 /* sdram Dunit ODT control */ -#define DRAM_BUF_REG10 0x60b98 /* sdram Extended Mode */ -#define DRAM_BUF_REG11 0x60b9c /* sdram Ddr2 Time Low Reg */ -#define DRAM_BUF_REG12 0x60a00 /* sdram Ddr2 Time High Reg */ -#define DRAM_BUF_REG13 0x60a04 /* dunit Ctrl High */ -#define DRAM_BUF_REG14 0x60b00 /* sdram second DIMM exist */ - -/* Following the pre-configuration registers default values restored after */ -/* auto-detection is done */ -#define DRAM_BUF_REG_DV 0 - -/* System Mapping */ -#define SDRAM_CS0_BASE 0x00000000 -#define SDRAM_CS0_SIZE _256M - -#define SDRAM_CS1_BASE 0x10000000 -#define SDRAM_CS1_SIZE _256M - -#define SDRAM_CS2_BASE 0x20000000 -#define SDRAM_CS2_SIZE _256M - -#define SDRAM_CS3_BASE 0x30000000 -#define SDRAM_CS3_SIZE _256M - -/* PEX */ -#define PEX0_MEM_BASE 0xe8000000 -#define PEX0_MEM_SIZE _128M - -#define PEX0_IO_BASE 0xf2000000 -#define PEX0_IO_SIZE _1M - -/* Device Chip Selects */ -#define NFLASH_CS_BASE 0xfa000000 -#define NFLASH_CS_SIZE _2M - -#define SPI_CS_BASE 0xf4000000 -#define SPI_CS_SIZE _16M - -#define CRYPT_ENG_BASE 0xf0000000 -#define CRYPT_ENG_SIZE _2M - -#define BOOTDEV_CS_BASE 0xff800000 -#define BOOTDEV_CS_SIZE _8M - -/* CS2 - BOOTROM */ -#define DEVICE_CS2_BASE 0xff900000 -#define DEVICE_CS2_SIZE _1M - -/* PEX Work arround */ -/* the target we will use for the workarround */ -#define PEX_CONFIG_RW_WA_TARGET PEX0_MEM -/*a flag that indicates if we are going to use the -size and base of the target we using for the workarround -window */ -#define PEX_CONFIG_RW_WA_USE_ORIGINAL_WIN_VALUES 1 -/* if the above flag is 0 then the following values -will be used for the workarround window base and size, -otherwise the following defines will be ignored */ -#define PEX_CONFIG_RW_WA_BASE 0xF3000000 -#define PEX_CONFIG_RW_WA_SIZE _16M - -/* Internal registers: size is defined in Controllerenvironment */ -#define INTER_REGS_BASE 0xFEE00000 - -/* DRAM detection stuff */ -#define MV_DRAM_AUTO_SIZE - -/* Board clock detection */ -#define TCLK_AUTO_DETECT /* Use Tclk auto detection */ -#define SYSCLK_AUTO_DETECT /* Use SysClk auto detection */ -#define PCLCK_AUTO_DETECT /* Use PClk auto detection */ -#define L2CLK_AUTO_DETECT /* Use L2Clk auto detection */ - -/* PEX-PCI\PCI-PCI Bridge*/ -#define PCI0_IF_PTP 0 /* Bridge exist on pciIf0*/ - - - -#endif /* __INCmvSysHwConfigh */ - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/cntmr/mvCntmr.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/cntmr/mvCntmr.c deleted file mode 100644 index 717c150..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/cntmr/mvCntmr.c +++ /dev/null @@ -1,376 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#include "mvCntmr.h" -#include "cpu/mvCpu.h" - -/* defines */ -#ifdef MV_DEBUG - #define DB(x) x -#else - #define DB(x) -#endif - -extern unsigned int whoAmI(void); - -/******************************************************************************* -* mvCntmrLoad - -* -* DESCRIPTION: -* Load an init Value to a given counter/timer -* -* INPUT: -* countNum - counter number -* value - value to be loaded -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM on bad parameters , MV_ERROR on error ,MV_OK on sucess -*******************************************************************************/ -MV_STATUS mvCntmrLoad(MV_U32 countNum, MV_U32 value) -{ - if (countNum >= MV_CNTMR_MAX_COUNTER ) - { - - mvOsPrintf(("mvCntmrLoad: Err. Illigal counter number \n")); - return MV_BAD_PARAM;; - - } - - MV_REG_WRITE(CNTMR_RELOAD_REG(countNum),value); - MV_REG_WRITE(CNTMR_VAL_REG(countNum),value); - - return MV_OK; -} - -/******************************************************************************* -* mvCntmrRead - -* -* DESCRIPTION: -* Returns the value of the given Counter/Timer -* -* INPUT: -* countNum - counter number -* -* OUTPUT: -* None. -* -* RETURN: -* MV_U32 counter value -*******************************************************************************/ -MV_U32 mvCntmrRead(MV_U32 countNum) -{ - return MV_REG_READ(CNTMR_VAL_REG(countNum)); -} - -/******************************************************************************* -* mvCntmrWrite - -* -* DESCRIPTION: -* Returns the value of the given Counter/Timer -* -* INPUT: -* countNum - counter number -* countVal - value to write -* -* OUTPUT: -* None. -* -* RETURN: -* None -*******************************************************************************/ -void mvCntmrWrite(MV_U32 countNum,MV_U32 countVal) -{ - MV_REG_WRITE(CNTMR_VAL_REG(countNum),countVal); -} - -/******************************************************************************* -* mvCntmrCtrlSet - -* -* DESCRIPTION: -* Set the Control to a given counter/timer -* -* INPUT: -* countNum - counter number -* pCtrl - pointer to MV_CNTMR_CTRL structure -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM on bad parameters , MV_ERROR on error ,MV_OK on sucess -*******************************************************************************/ -MV_STATUS mvCntmrCtrlSet(MV_U32 countNum, MV_CNTMR_CTRL *pCtrl) -{ - MV_U32 cntmrCtrl; - - if (countNum >= MV_CNTMR_MAX_COUNTER ) - { - - DB(mvOsPrintf(("mvCntmrCtrlSet: Err. Illigal counter number \n"))); - return MV_BAD_PARAM;; - - } - - /* read control register */ - cntmrCtrl = MV_REG_READ(CNTMR_CTRL_REG); - - - if (pCtrl->enable) /* enable counter\timer */ - { - cntmrCtrl |= CTCR_ARM_TIMER_EN(countNum); - } - else /* disable counter\timer */ - { - cntmrCtrl &= ~CTCR_ARM_TIMER_EN(countNum); - } - - if ( pCtrl->autoEnable ) /* Auto mode */ - { - cntmrCtrl |= CTCR_ARM_TIMER_AUTO_EN(countNum); - - } - else /* no auto mode */ - { - cntmrCtrl &= ~CTCR_ARM_TIMER_AUTO_EN(countNum); - } - - MV_REG_WRITE(CNTMR_CTRL_REG,cntmrCtrl); - - return MV_OK; - -} - -/******************************************************************************* -* mvCntmrCtrlGet - -* -* DESCRIPTION: -* Get the Control value of a given counter/timer -* -* INPUT: -* countNum - counter number -* pCtrl - pointer to MV_CNTMR_CTRL structure -* -* OUTPUT: -* Counter\Timer control value -* -* RETURN: -* MV_BAD_PARAM on bad parameters , MV_ERROR on error ,MV_OK on sucess -*******************************************************************************/ -MV_STATUS mvCntmrCtrlGet(MV_U32 countNum, MV_CNTMR_CTRL *pCtrl) -{ - MV_U32 cntmrCtrl; - - if (countNum >= MV_CNTMR_MAX_COUNTER ) - { - DB(mvOsPrintf(("mvCntmrCtrlGet: Err. Illigal counter number \n"))); - return MV_BAD_PARAM;; - } - - /* read control register */ - cntmrCtrl = MV_REG_READ(CNTMR_CTRL_REG); - - /* enable counter\timer */ - if (cntmrCtrl & CTCR_ARM_TIMER_EN(countNum)) - { - pCtrl->enable = MV_TRUE; - } - else - { - pCtrl->enable = MV_FALSE; - } - - /* counter mode */ - if (cntmrCtrl & CTCR_ARM_TIMER_AUTO_EN(countNum)) - { - pCtrl->autoEnable = MV_TRUE; - } - else - { - pCtrl->autoEnable = MV_FALSE; - } - - return MV_OK; -} - -/******************************************************************************* -* mvCntmrEnable - -* -* DESCRIPTION: -* Set the Enable-Bit to logic '1' ==> starting the counter -* -* INPUT: -* countNum - counter number -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM on bad parameters , MV_ERROR on error ,MV_OK on sucess -*******************************************************************************/ -MV_STATUS mvCntmrEnable(MV_U32 countNum) -{ - MV_U32 cntmrCtrl; - - if (countNum >= MV_CNTMR_MAX_COUNTER ) - { - - DB(mvOsPrintf(("mvCntmrEnable: Err. Illigal counter number \n"))); - return MV_BAD_PARAM;; - - } - - /* read control register */ - cntmrCtrl = MV_REG_READ(CNTMR_CTRL_REG); - - /* enable counter\timer */ - cntmrCtrl |= CTCR_ARM_TIMER_EN(countNum); - - - MV_REG_WRITE(CNTMR_CTRL_REG,cntmrCtrl); - - return MV_OK; -} - -/******************************************************************************* -* mvCntmrDisable - -* -* DESCRIPTION: -* Stop the counter/timer running, and returns its Value -* -* INPUT: -* countNum - counter number -* -* OUTPUT: -* None. -* -* RETURN: -* MV_U32 counter\timer value -*******************************************************************************/ -MV_STATUS mvCntmrDisable(MV_U32 countNum) -{ - MV_U32 cntmrCtrl; - - if (countNum >= MV_CNTMR_MAX_COUNTER ) - { - - DB(mvOsPrintf(("mvCntmrDisable: Err. Illigal counter number \n"))); - return MV_BAD_PARAM;; - - } - - /* read control register */ - cntmrCtrl = MV_REG_READ(CNTMR_CTRL_REG); - - /* disable counter\timer */ - cntmrCtrl &= ~CTCR_ARM_TIMER_EN(countNum); - - MV_REG_WRITE(CNTMR_CTRL_REG,cntmrCtrl); - - return MV_OK; -} - -/******************************************************************************* -* mvCntmrStart - -* -* DESCRIPTION: -* Combined all the sub-operations above to one function: Load,setMode,Enable -* -* INPUT: -* countNum - counter number -* value - value of the counter\timer to be set -* pCtrl - pointer to MV_CNTMR_CTRL structure -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM on bad parameters , MV_ERROR on error ,MV_OK on sucess -*******************************************************************************/ -MV_STATUS mvCntmrStart(MV_U32 countNum, MV_U32 value, - MV_CNTMR_CTRL *pCtrl) -{ - - if (countNum >= MV_CNTMR_MAX_COUNTER ) - { - - mvOsPrintf(("mvCntmrDisable: Err. Illigal counter number \n")); - return MV_BAD_PARAM;; - - } - - /* load value onto counter\timer */ - mvCntmrLoad(countNum,value); - - /* set the counter to load in the first time */ - mvCntmrWrite(countNum,value); - - /* set control for timer \ cunter and enable */ - mvCntmrCtrlSet(countNum,pCtrl); - - return MV_OK; -} - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/cntmr/mvCntmr.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/cntmr/mvCntmr.h deleted file mode 100644 index b911d0f..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/cntmr/mvCntmr.h +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCmvTmrWtdgh -#define __INCmvTmrWtdgh - -/* includes */ -#include "mvCommon.h" -#include "mvOs.h" -#include "cntmr/mvCntmrRegs.h" -#include "ctrlEnv/mvCtrlEnvSpec.h" - - -/* This enumerator describe counters\watchdog numbers */ -typedef enum _mvCntmrID -{ - TIMER0 = 0, - TIMER1, - WATCHDOG, - TIMER2, - TIMER3, -}MV_CNTMR_ID; - - -/* Counter / Timer control structure */ -typedef struct _mvCntmrCtrl -{ - MV_BOOL enable; /* enable */ - MV_BOOL autoEnable; /* counter/Timer */ -}MV_CNTMR_CTRL; - - -/* Functions */ - -/* Load an init Value to a given counter/timer */ -MV_STATUS mvCntmrLoad(MV_U32 countNum, MV_U32 value); - -/* Returns the value of the given Counter/Timer */ -MV_U32 mvCntmrRead(MV_U32 countNum); - -/* Write a value of the given Counter/Timer */ -void mvCntmrWrite(MV_U32 countNum,MV_U32 countVal); - -/* Set the Control to a given counter/timer */ -MV_STATUS mvCntmrCtrlSet(MV_U32 countNum, MV_CNTMR_CTRL *pCtrl); - -/* Get the value of a given counter/timer */ -MV_STATUS mvCntmrCtrlGet(MV_U32 countNum, MV_CNTMR_CTRL *pCtrl); - -/* Set the Enable-Bit to logic '1' ==> starting the counter. */ -MV_STATUS mvCntmrEnable(MV_U32 countNum); - -/* Stop the counter/timer running, and returns its Value. */ -MV_STATUS mvCntmrDisable(MV_U32 countNum); - -/* Combined all the sub-operations above to one function: Load,setMode,Enable */ -MV_STATUS mvCntmrStart(MV_U32 countNum, MV_U32 value, - MV_CNTMR_CTRL *pCtrl); - -#endif /* __INCmvTmrWtdgh */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/cntmr/mvCntmrRegs.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/cntmr/mvCntmrRegs.h deleted file mode 100644 index b69bc66..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/cntmr/mvCntmrRegs.h +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCmvTmrwtdgRegsh -#define __INCmvTmrwtdgRegsh - -/*******************************************/ -/* ARM Timers Registers Map */ -/*******************************************/ - -#define CNTMR_RELOAD_REG(tmrNum) (CNTMR_BASE + 0x10 + (tmrNum)*8 + \ - (((tmrNum) <= 3)?0:8)) -#define CNTMR_VAL_REG(tmrNum) (CNTMR_BASE + 0x14 + (tmrNum)*8 + \ - (((tmrNum) <= 3)?0:8)) -#define CNTMR_CTRL_REG (CNTMR_BASE) - -/*For MV78XX0*/ -#define CNTMR_CAUSE_REG (CPU_AHB_MBUS_CAUSE_INT_REG(whoAmI())) -#define CNTMR_MASK_REG (CPU_AHB_MBUS_MASK_INT_REG(whoAmI())) - -/* ARM Timers Registers Map */ -/*******************************************/ - - -/* ARM Timers Control Register */ -/* CPU_TIMERS_CTRL_REG (CTCR) */ - -#define TIMER0_NUM 0 -#define TIMER1_NUM 1 -#define WATCHDOG_NUM 2 -#define TIMER2_NUM 3 -#define TIMER3_NUM 4 - -#define CTCR_ARM_TIMER_EN_OFFS(cntr) (cntr * 2) -#define CTCR_ARM_TIMER_EN_MASK(cntr) (1 << CTCR_ARM_TIMER_EN_OFFS) -#define CTCR_ARM_TIMER_EN(cntr) (1 << CTCR_ARM_TIMER_EN_OFFS(cntr)) -#define CTCR_ARM_TIMER_DIS(cntr) (0 << CTCR_ARM_TIMER_EN_OFFS(cntr)) - -#define CTCR_ARM_TIMER_AUTO_OFFS(cntr) ((cntr * 2) + 1) -#define CTCR_ARM_TIMER_AUTO_MASK(cntr) BIT1 -#define CTCR_ARM_TIMER_AUTO_EN(cntr) (1 << CTCR_ARM_TIMER_AUTO_OFFS(cntr)) -#define CTCR_ARM_TIMER_AUTO_DIS(cntr) (0 << CTCR_ARM_TIMER_AUTO_OFFS(cntr)) - - -/* ARM Timer\Watchdog Reload Register */ -/* CNTMR_RELOAD_REG (TRR) */ - -#define TRG_ARM_TIMER_REL_OFFS 0 -#define TRG_ARM_TIMER_REL_MASK 0xffffffff - -/* ARM Timer\Watchdog Register */ -/* CNTMR_VAL_REG (TVRG) */ - -#define TVR_ARM_TIMER_OFFS 0 -#define TVR_ARM_TIMER_MASK 0xffffffff -#define TVR_ARM_TIMER_MAX 0xffffffff - - - -#endif /* __INCmvTmrwtdgRegsh */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/cpu/mvCpuCntrs.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/cpu/mvCpuCntrs.c deleted file mode 100644 index 609e674..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/cpu/mvCpuCntrs.c +++ /dev/null @@ -1,207 +0,0 @@ -/* - * 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 - */ - -#include "mvOs.h" -#include "mvCpuCntrs.h" - - -const static MV_CPU_CNTRS_OPS mvCpuCntrsOpsTbl[MV_CPU_CNTRS_NUM][MV_CPU_CNTRS_OPS_NUM] = -{ - /*0*/ - { - MV_CPU_CNTRS_CYCLES, MV_CPU_CNTRS_DCACHE_READ_HIT, MV_CPU_CNTRS_DCACHE_READ_MISS, - MV_CPU_CNTRS_DCACHE_WRITE_HIT, MV_CPU_CNTRS_DCACHE_WRITE_MISS, MV_CPU_CNTRS_INSTRUCTIONS, - MV_CPU_CNTRS_INVALID, MV_CPU_CNTRS_INVALID, MV_CPU_CNTRS_INVALID, - MV_CPU_CNTRS_MMU_READ_LATENCY, MV_CPU_CNTRS_ICACHE_READ_LATENCY, MV_CPU_CNTRS_WB_WRITE_LATENCY, - MV_CPU_CNTRS_LDM_STM_HOLD, MV_CPU_CNTRS_INVALID, MV_CPU_CNTRS_INVALID, - MV_CPU_CNTRS_DATA_WRITE_ACCESS, MV_CPU_CNTRS_DATA_READ_ACCESS, MV_CPU_CNTRS_INVALID, - MV_CPU_CNTRS_BRANCH_PREDICT_COUNT, - }, - /*1*/ - { - MV_CPU_CNTRS_CYCLES, MV_CPU_CNTRS_ICACHE_READ_MISS, MV_CPU_CNTRS_DCACHE_READ_MISS, - MV_CPU_CNTRS_DCACHE_WRITE_MISS, MV_CPU_CNTRS_ITLB_MISS, MV_CPU_CNTRS_SINGLE_ISSUE, - MV_CPU_CNTRS_INVALID, MV_CPU_CNTRS_BRANCH_RETIRED, MV_CPU_CNTRS_INVALID, - MV_CPU_CNTRS_MMU_READ_BEAT, MV_CPU_CNTRS_ICACHE_READ_LATENCY, MV_CPU_CNTRS_WB_WRITE_BEAT, - MV_CPU_CNTRS_INVALID, MV_CPU_CNTRS_IS_HOLD, MV_CPU_CNTRS_DATA_READ_ACCESS, - MV_CPU_CNTRS_INVALID, MV_CPU_CNTRS_INVALID, MV_CPU_CNTRS_INVALID, - MV_CPU_CNTRS_INVALID, - }, - /*2*/ - { - MV_CPU_CNTRS_CYCLES, MV_CPU_CNTRS_INVALID, MV_CPU_CNTRS_DCACHE_ACCESS, - MV_CPU_CNTRS_DTLB_MISS, MV_CPU_CNTRS_INVALID, MV_CPU_CNTRS_INVALID, - MV_CPU_CNTRS_INVALID, MV_CPU_CNTRS_BRANCH_PREDICT_MISS, MV_CPU_CNTRS_WB_WRITE_BEAT, - MV_CPU_CNTRS_INVALID, MV_CPU_CNTRS_DCACHE_READ_LATENCY, MV_CPU_CNTRS_DCACHE_WRITE_LATENCY, - MV_CPU_CNTRS_INVALID, MV_CPU_CNTRS_INVALID, MV_CPU_CNTRS_BIU_SIMULT_ACCESS, - MV_CPU_CNTRS_INVALID, MV_CPU_CNTRS_INVALID, MV_CPU_CNTRS_INVALID, - MV_CPU_CNTRS_INVALID, - }, - /*3*/ - { - MV_CPU_CNTRS_CYCLES, MV_CPU_CNTRS_DCACHE_READ_MISS, MV_CPU_CNTRS_DCACHE_WRITE_MISS, - MV_CPU_CNTRS_TLB_MISS, MV_CPU_CNTRS_INVALID, MV_CPU_CNTRS_INVALID, - MV_CPU_CNTRS_INVALID, MV_CPU_CNTRS_BRANCH_TAKEN, MV_CPU_CNTRS_WB_FULL_CYCLES, - MV_CPU_CNTRS_INVALID, MV_CPU_CNTRS_DCACHE_READ_BEAT, MV_CPU_CNTRS_DCACHE_WRITE_BEAT, - MV_CPU_CNTRS_INVALID, MV_CPU_CNTRS_INVALID, MV_CPU_CNTRS_BIU_ANY_ACCESS, - MV_CPU_CNTRS_INVALID, MV_CPU_CNTRS_INVALID, MV_CPU_CNTRS_DATA_WRITE_ACCESS, - MV_CPU_CNTRS_INVALID, - } -}; - -MV_CPU_CNTRS_ENTRY mvCpuCntrsTbl[MV_CPU_CNTRS_NUM]; - -MV_CPU_CNTRS_EVENT* mvCpuCntrsEventTbl[128]; - -void mvCpuCntrsReset(void) -{ - MV_U32 reg = 0; - - MV_ASM ("mcr p15, 0, %0, c15, c13, 0" : : "r" (reg)); - MV_ASM ("mcr p15, 0, %0, c15, c13, 1" : : "r" (reg)); - MV_ASM ("mcr p15, 0, %0, c15, c13, 2" : : "r" (reg)); - MV_ASM ("mcr p15, 0, %0, c15, c13, 3" : : "r" (reg)); - MV_ASM ("mcr p15, 0, %0, c15, c13, 4" : : "r" (reg)); - MV_ASM ("mcr p15, 0, %0, c15, c13, 5" : : "r" (reg)); - MV_ASM ("mcr p15, 0, %0, c15, c13, 6" : : "r" (reg)); - MV_ASM ("mcr p15, 0, %0, c15, c13, 7" : : "r" (reg)); -} - -void program_counter(int counter, int op) -{ - MV_U32 reg = (1 << op) | 0x1; /*enable*/ - - switch(counter) - { - case 0: - __asm__ __volatile__ ("mcr p15, 0, %0, c15, c12, 0" : : "r" (reg)); - return; - - case 1: - __asm__ __volatile__ ("mcr p15, 0, %0, c15, c12, 1" : : "r" (reg)); - return; - - case 2: - __asm__ __volatile__ ("mcr p15, 0, %0, c15, c12, 2" : : "r" (reg)); - return; - - case 3: - __asm__ __volatile__ ("mcr p15, 0, %0, c15, c12, 3" : : "r" (reg)); - return; - - default: - mvOsPrintf("error in program_counter: bad counter number (%d)\n", counter); - } - return; -} - -void mvCpuCntrsEventClear(MV_CPU_CNTRS_EVENT* pEvent) -{ - int i; - - for(i=0; i<MV_CPU_CNTRS_NUM; i++) - { - pEvent->counters_sum[i] = 0; - } - pEvent->num_of_measurements = 0; -} - - -MV_CPU_CNTRS_EVENT* mvCpuCntrsEventCreate(char* name, MV_U32 print_threshold) -{ - int i; - MV_CPU_CNTRS_EVENT* event = mvOsMalloc(sizeof(MV_CPU_CNTRS_EVENT)); - - if(event) - { - strncpy(event->name, name, sizeof(event->name)); - event->num_of_measurements = 0; - event->avg_sample_count = print_threshold; - for(i=0; i<MV_CPU_CNTRS_NUM; i++) - { - event->counters_before[i] = 0; - event->counters_after[i] = 0; - event->counters_sum[i] = 0; - } - } - return event; -} - -void mvCpuCntrsEventDelete(MV_CPU_CNTRS_EVENT* event) -{ - if(event != NULL) - mvOsFree(event); -} - - -MV_STATUS mvCpuCntrsProgram(int counter, MV_CPU_CNTRS_OPS op, - char* name, MV_U32 overhead) -{ - int i; - - /* Find required operations */ - for(i=0; i<MV_CPU_CNTRS_OPS_NUM; i++) - { - if( mvCpuCntrsOpsTbl[counter][i] == op) - { - strncpy(mvCpuCntrsTbl[counter].name, name, sizeof(mvCpuCntrsTbl[counter].name)); - mvCpuCntrsTbl[counter].operation = op; - mvCpuCntrsTbl[counter].opIdx = i+1; - mvCpuCntrsTbl[counter].overhead = overhead; - program_counter(counter, mvCpuCntrsTbl[counter].opIdx); - mvOsPrintf("Counter=%d, opIdx=%d, overhead=%d\n", - counter, mvCpuCntrsTbl[counter].opIdx, mvCpuCntrsTbl[counter].overhead); - return MV_OK; - } - } - return MV_NOT_FOUND; -} - -void mvCpuCntrsShow(MV_CPU_CNTRS_EVENT* pEvent) -{ - int i; - MV_U64 counters_avg; - - if(pEvent->num_of_measurements < pEvent->avg_sample_count) - return; - - mvOsPrintf("%16s: ", pEvent->name); - for(i=0; i<MV_CPU_CNTRS_NUM; i++) - { - counters_avg = mvOsDivMod64(pEvent->counters_sum[i], - pEvent->num_of_measurements, NULL); - if(counters_avg >= mvCpuCntrsTbl[i].overhead) - counters_avg -= mvCpuCntrsTbl[i].overhead; - else - counters_avg = 0; - - mvOsPrintf("%s=%5llu, ", mvCpuCntrsTbl[i].name, counters_avg); - } - mvOsPrintf("\n"); - mvCpuCntrsEventClear(pEvent); - mvCpuCntrsReset(); -} - -void mvCpuCntrsStatus(void) -{ - int i; - - for(i=0; i<MV_CPU_CNTRS_NUM; i++) - { - mvOsPrintf("#%d: %s, overhead=%d\n", - i, mvCpuCntrsTbl[i].name, mvCpuCntrsTbl[i].overhead); - } -} diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/cpu/mvCpuCntrs.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/cpu/mvCpuCntrs.h deleted file mode 100644 index 8d49af0..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/cpu/mvCpuCntrs.h +++ /dev/null @@ -1,213 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -*******************************************************************************/ -#ifndef __mvCpuCntrs_h__ -#define __mvCpuCntrs_h__ - -#include "mvTypes.h" -#include "mvOs.h" - - -#define MV_CPU_CNTRS_NUM 4 -#define MV_CPU_CNTRS_OPS_NUM 32 - -typedef enum -{ - MV_CPU_CNTRS_INVALID = 0, - MV_CPU_CNTRS_CYCLES, - MV_CPU_CNTRS_ICACHE_READ_MISS, - MV_CPU_CNTRS_DCACHE_ACCESS, - MV_CPU_CNTRS_DCACHE_READ_MISS, - MV_CPU_CNTRS_DCACHE_READ_HIT, - MV_CPU_CNTRS_DCACHE_WRITE_MISS, - MV_CPU_CNTRS_DCACHE_WRITE_HIT, - MV_CPU_CNTRS_DTLB_MISS, - MV_CPU_CNTRS_TLB_MISS, - MV_CPU_CNTRS_ITLB_MISS, - MV_CPU_CNTRS_INSTRUCTIONS, - MV_CPU_CNTRS_SINGLE_ISSUE, - MV_CPU_CNTRS_MMU_READ_LATENCY, - MV_CPU_CNTRS_MMU_READ_BEAT, - MV_CPU_CNTRS_BRANCH_RETIRED, - MV_CPU_CNTRS_BRANCH_TAKEN, - MV_CPU_CNTRS_BRANCH_PREDICT_MISS, - MV_CPU_CNTRS_BRANCH_PREDICT_COUNT, - MV_CPU_CNTRS_WB_FULL_CYCLES, - MV_CPU_CNTRS_WB_WRITE_LATENCY, - MV_CPU_CNTRS_WB_WRITE_BEAT, - MV_CPU_CNTRS_ICACHE_READ_LATENCY, - MV_CPU_CNTRS_ICACHE_READ_BEAT, - MV_CPU_CNTRS_DCACHE_READ_LATENCY, - MV_CPU_CNTRS_DCACHE_READ_BEAT, - MV_CPU_CNTRS_DCACHE_WRITE_LATENCY, - MV_CPU_CNTRS_DCACHE_WRITE_BEAT, - MV_CPU_CNTRS_LDM_STM_HOLD, - MV_CPU_CNTRS_IS_HOLD, - MV_CPU_CNTRS_DATA_WRITE_ACCESS, - MV_CPU_CNTRS_DATA_READ_ACCESS, - MV_CPU_CNTRS_BIU_SIMULT_ACCESS, - MV_CPU_CNTRS_BIU_ANY_ACCESS, - -} MV_CPU_CNTRS_OPS; - -typedef struct -{ - char name[16]; - MV_CPU_CNTRS_OPS operation; - int opIdx; - MV_U32 overhead; - -} MV_CPU_CNTRS_ENTRY; - - -typedef struct -{ - char name[16]; - MV_U32 num_of_measurements; - MV_U32 avg_sample_count; - MV_U64 counters_before[MV_CPU_CNTRS_NUM]; - MV_U64 counters_after[MV_CPU_CNTRS_NUM]; - MV_U64 counters_sum[MV_CPU_CNTRS_NUM]; - -} MV_CPU_CNTRS_EVENT; - -extern MV_CPU_CNTRS_ENTRY mvCpuCntrsTbl[MV_CPU_CNTRS_NUM]; - - -MV_STATUS mvCpuCntrsProgram(int counter, MV_CPU_CNTRS_OPS op, - char* name, MV_U32 overhead); -void mvCpuCntrsInit(void); -MV_CPU_CNTRS_EVENT* mvCpuCntrsEventCreate(char* name, MV_U32 print_threshold); -void mvCpuCntrsEventDelete(MV_CPU_CNTRS_EVENT* event); -void mvCpuCntrsReset(void); -void mvCpuCntrsShow(MV_CPU_CNTRS_EVENT* pEvent); -void mvCpuCntrsEventClear(MV_CPU_CNTRS_EVENT* pEvent); - -/* internal */ -void program_counter(int counter, int op); - -static INLINE MV_U64 mvCpuCntrsRead(const int counter) -{ - MV_U32 low = 0, high = 0; - MV_U32 ll = 0; - - switch(counter) - { - case 0: - MV_ASM ("mcr p15, 0, %0, c15, c12, 0" : : "r" (ll)); - MV_ASM ("mrc p15, 0, %0, c15, c13, 0" : "=r" (low)); - MV_ASM ("mrc p15, 0, %0, c15, c13, 1" : "=r" (high)); - break; - - case 1: - MV_ASM ("mcr p15, 0, %0, c15, c12, 1" : : "r" (ll)); - MV_ASM ("mrc p15, 0, %0, c15, c13, 2" : "=r" (low)); - MV_ASM ("mrc p15, 0, %0, c15, c13, 3" : "=r" (high)); - break; - - case 2: - MV_ASM ("mcr p15, 0, %0, c15, c12, 2" : : "r" (ll)); - MV_ASM ("mrc p15, 0, %0, c15, c13, 4" : "=r" (low)); - MV_ASM ("mrc p15, 0, %0, c15, c13, 5" : "=r" (high)); - break; - - case 3: - MV_ASM ("mcr p15, 0, %0, c15, c12, 3" : : "r" (ll)); - MV_ASM ("mrc p15, 0, %0, c15, c13, 6" : "=r" (low)); - MV_ASM ("mrc p15, 0, %0, c15, c13, 7" : "=r" (high)); - break; - - default: - mvOsPrintf("mv_cpu_cntrs_read: bad counter number (%d)\n", counter); - } - program_counter(counter, mvCpuCntrsTbl[counter].opIdx); - return (((MV_U64)high << 32 ) | low); - -} - - -static INLINE void mvCpuCntrsReadBefore(MV_CPU_CNTRS_EVENT* pEvent) -{ -#if 0 - int i; - - /* order is important - we want to measure the cycle count last here! */ - for(i=0; i<MV_CPU_CNTRS_NUM; i++) - pEvent->counters_before[i] = mvCpuCntrsRead(i); -#else - pEvent->counters_before[1] = mvCpuCntrsRead(1); - pEvent->counters_before[3] = mvCpuCntrsRead(3); - pEvent->counters_before[0] = mvCpuCntrsRead(0); - pEvent->counters_before[2] = mvCpuCntrsRead(2); -#endif -} - -static INLINE void mvCpuCntrsReadAfter(MV_CPU_CNTRS_EVENT* pEvent) -{ - int i; - -#if 0 - /* order is important - we want to measure the cycle count first here! */ - for(i=0; i<MV_CPU_CNTRS_NUM; i++) - pEvent->counters_after[i] = mvCpuCntrsRead(i); -#else - pEvent->counters_after[2] = mvCpuCntrsRead(2); - pEvent->counters_after[0] = mvCpuCntrsRead(0); - pEvent->counters_after[3] = mvCpuCntrsRead(3); - pEvent->counters_after[1] = mvCpuCntrsRead(1); -#endif - - for(i=0; i<MV_CPU_CNTRS_NUM; i++) - { - pEvent->counters_sum[i] += (pEvent->counters_after[i] - pEvent->counters_before[i]); - } - pEvent->num_of_measurements++; -} - - -#ifdef CONFIG_MV_CPU_PERF_CNTRS - -#define MV_CPU_CNTRS_READ(counter) mvCpuCntrsRead(counter) - -#define MV_CPU_CNTRS_START(event) mvCpuCntrsReadBefore(event) - -#define MV_CPU_CNTRS_STOP(event) mvCpuCntrsReadAfter(event) - -#define MV_CPU_CNTRS_SHOW(event) mvCpuCntrsShow(event) - -#else - -#define MV_CPU_CNTRS_READ(counter) -#define MV_CPU_CNTRS_START(event) -#define MV_CPU_CNTRS_STOP(event) -#define MV_CPU_CNTRS_SHOW(event) - -#endif /* CONFIG_MV_CPU_PERF_CNTRS */ - - -#endif /* __mvCpuCntrs_h__ */ - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/cpu/mvCpuL2Cntrs.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/cpu/mvCpuL2Cntrs.c deleted file mode 100644 index 0333862..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/cpu/mvCpuL2Cntrs.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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 - */ - -#include "mvOs.h" -#include "mvCpuL2Cntrs.h" - - - -MV_CPU_L2_CNTRS_ENTRY mvCpuL2CntrsTbl[MV_CPU_L2_CNTRS_NUM]; - -MV_CPU_L2_CNTRS_EVENT* mvCpuL2CntrsEventTbl[128]; - -void mvCpuL2CntrsReset(void) -{ - MV_U32 reg = 0; - - MV_ASM ("mcr p15, 6, %0, c15, c13, 0" : : "r" (reg)); - MV_ASM ("mcr p15, 6, %0, c15, c13, 1" : : "r" (reg)); - MV_ASM ("mcr p15, 6, %0, c15, c13, 2" : : "r" (reg)); - MV_ASM ("mcr p15, 6, %0, c15, c13, 3" : : "r" (reg)); -} - -static void mvCpuL2CntrConfig(int counter, int op) -{ - MV_U32 reg = (1 << op) | 0x1; /*enable*/ - - switch(counter) - { - case 0: - MV_ASM ("mcr p15, 6, %0, c15, c12, 0" : : "r" (reg)); - return; - - case 1: - MV_ASM ("mcr p15, 6, %0, c15, c12, 1" : : "r" (reg)); - return; - - default: - mvOsPrintf("mvCpuL2CntrConfig: bad counter number (%d)\n", counter); - } - return; -} - -void mvCpuL2CntrsEventClear(MV_CPU_L2_CNTRS_EVENT* pEvent) -{ - int i; - - for(i=0; i<MV_CPU_L2_CNTRS_NUM; i++) - { - pEvent->counters_sum[i] = 0; - } - pEvent->num_of_measurements = 0; -} - - -MV_CPU_L2_CNTRS_EVENT* mvCpuL2CntrsEventCreate(char* name, MV_U32 print_threshold) -{ - int i; - MV_CPU_L2_CNTRS_EVENT* event = mvOsMalloc(sizeof(MV_CPU_L2_CNTRS_EVENT)); - - if(event) - { - strncpy(event->name, name, sizeof(event->name)); - event->num_of_measurements = 0; - event->avg_sample_count = print_threshold; - for(i=0; i<MV_CPU_L2_CNTRS_NUM; i++) - { - event->counters_before[i] = 0; - event->counters_after[i] = 0; - event->counters_sum[i] = 0; - } - } - return event; -} - -void mvCpuL2CntrsEventDelete(MV_CPU_L2_CNTRS_EVENT* event) -{ - if(event != NULL) - mvOsFree(event); -} - - -MV_STATUS mvCpuL2CntrsProgram(int counter, MV_CPU_L2_CNTRS_OPS op, - char* name, MV_U32 overhead) -{ - strncpy(mvCpuL2CntrsTbl[counter].name, name, sizeof(mvCpuL2CntrsTbl[counter].name)); - mvCpuL2CntrsTbl[counter].operation = op; - mvCpuL2CntrsTbl[counter].opIdx = op; - mvCpuL2CntrsTbl[counter].overhead = overhead; - mvCpuL2CntrConfig(counter, op); - mvOsPrintf("CPU L2 Counter %d: operation=%d, overhead=%d\n", - counter, op, overhead); - return MV_OK; -} - -void mvCpuL2CntrsShow(MV_CPU_L2_CNTRS_EVENT* pEvent) -{ - int i; - MV_U64 counters_avg; - - if(pEvent->num_of_measurements < pEvent->avg_sample_count) - return; - - mvOsPrintf("%16s: ", pEvent->name); - for(i=0; i<MV_CPU_L2_CNTRS_NUM; i++) - { - counters_avg = mvOsDivMod64(pEvent->counters_sum[i], - pEvent->num_of_measurements, NULL); - - if(counters_avg >= mvCpuL2CntrsTbl[i].overhead) - counters_avg -= mvCpuL2CntrsTbl[i].overhead; - else - counters_avg = 0; - - mvOsPrintf("%s=%5llu, ", mvCpuL2CntrsTbl[i].name, counters_avg); - } - mvOsPrintf("\n"); - mvCpuL2CntrsEventClear(pEvent); - mvCpuL2CntrsReset(); -} - -void mvCpuL2CntrsStatus(void) -{ - int i; - - for(i=0; i<MV_CPU_L2_CNTRS_NUM; i++) - { - mvOsPrintf("#%d: %s, overhead=%d\n", - i, mvCpuL2CntrsTbl[i].name, mvCpuL2CntrsTbl[i].overhead); - } -} diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/cpu/mvCpuL2Cntrs.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/cpu/mvCpuL2Cntrs.h deleted file mode 100644 index 570d701..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/cpu/mvCpuL2Cntrs.h +++ /dev/null @@ -1,151 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -*******************************************************************************/ -#ifndef __mvCpuL2Cntrs_h__ -#define __mvCpuL2Cntrs_h__ - -#include "mvTypes.h" -#include "mvOs.h" - - -#define MV_CPU_L2_CNTRS_NUM 2 - -typedef enum -{ - MV_CPU_L2_CNTRS_ENABLE = 0, - MV_CPU_L2_CNTRS_DATA_REQ, - MV_CPU_L2_CNTRS_DATA_MISS_REQ, - MV_CPU_L2_CNTRS_INST_REQ, - MV_CPU_L2_CNTRS_INST_MISS_REQ, - MV_CPU_L2_CNTRS_DATA_READ_REQ, - MV_CPU_L2_CNTRS_DATA_READ_MISS_REQ, - MV_CPU_L2_CNTRS_DATA_WRITE_REQ, - MV_CPU_L2_CNTRS_DATA_WRITE_MISS_REQ, - MV_CPU_L2_CNTRS_RESERVED, - MV_CPU_L2_CNTRS_DIRTY_EVICT_REQ, - MV_CPU_L2_CNTRS_EVICT_BUFF_STALL, - MV_CPU_L2_CNTRS_ACTIVE_CYCLES, - -} MV_CPU_L2_CNTRS_OPS; - -typedef struct -{ - char name[16]; - MV_CPU_L2_CNTRS_OPS operation; - int opIdx; - MV_U32 overhead; - -} MV_CPU_L2_CNTRS_ENTRY; - - -typedef struct -{ - char name[16]; - MV_U32 num_of_measurements; - MV_U32 avg_sample_count; - MV_U64 counters_before[MV_CPU_L2_CNTRS_NUM]; - MV_U64 counters_after[MV_CPU_L2_CNTRS_NUM]; - MV_U64 counters_sum[MV_CPU_L2_CNTRS_NUM]; - -} MV_CPU_L2_CNTRS_EVENT; - - -MV_STATUS mvCpuL2CntrsProgram(int counter, MV_CPU_L2_CNTRS_OPS op, - char* name, MV_U32 overhead); -void mvCpuL2CntrsInit(void); -MV_CPU_L2_CNTRS_EVENT* mvCpuL2CntrsEventCreate(char* name, MV_U32 print_threshold); -void mvCpuL2CntrsEventDelete(MV_CPU_L2_CNTRS_EVENT* event); -void mvCpuL2CntrsReset(void); -void mvCpuL2CntrsShow(MV_CPU_L2_CNTRS_EVENT* pEvent); -void mvCpuL2CntrsEventClear(MV_CPU_L2_CNTRS_EVENT* pEvent); - -static INLINE MV_U64 mvCpuL2CntrsRead(const int counter) -{ - MV_U32 low = 0, high = 0; - - switch(counter) - { - case 0: - MV_ASM ("mrc p15, 6, %0, c15, c13, 0" : "=r" (low)); - MV_ASM ("mrc p15, 6, %0, c15, c13, 1" : "=r" (high)); - break; - - case 1: - MV_ASM ("mrc p15, 6, %0, c15, c13, 2" : "=r" (low)); - MV_ASM ("mrc p15, 6, %0, c15, c13, 3" : "=r" (high)); - break; - - default: - mvOsPrintf("mvCpuL2CntrsRead: bad counter number (%d)\n", counter); - } - return (((MV_U64)high << 32 ) | low); - -} - -static INLINE void mvCpuL2CntrsReadBefore(MV_CPU_L2_CNTRS_EVENT* pEvent) -{ - int i; - - for(i=0; i<MV_CPU_L2_CNTRS_NUM; i++) - pEvent->counters_before[i] = mvCpuL2CntrsRead(i); -} - -static INLINE void mvCpuL2CntrsReadAfter(MV_CPU_L2_CNTRS_EVENT* pEvent) -{ - int i; - - for(i=0; i<MV_CPU_L2_CNTRS_NUM; i++) - { - pEvent->counters_after[i] = mvCpuL2CntrsRead(i); - pEvent->counters_sum[i] += (pEvent->counters_after[i] - pEvent->counters_before[i]); - } - pEvent->num_of_measurements++; -} - - -#ifdef CONFIG_MV_CPU_L2_PERF_CNTRS - -#define MV_CPU_L2_CNTRS_READ(counter) mvCpuL2CntrsRead(counter) - -#define MV_CPU_L2_CNTRS_START(event) mvCpuL2CntrsReadBefore(event) - -#define MV_CPU_L2_CNTRS_STOP(event) mvCpuL2CntrsReadAfter(event) - -#define MV_CPU_L2_CNTRS_SHOW(event) mvCpuL2CntrsShow(event) - -#else - -#define MV_CPU_L2_CNTRS_READ(counter) -#define MV_CPU_L2_CNTRS_START(event) -#define MV_CPU_L2_CNTRS_STOP(event) -#define MV_CPU_L2_CNTRS_SHOW(event) - -#endif /* CONFIG_MV_CPU_L2_PERF_CNTRS */ - - -#endif /* __mvCpuL2Cntrs_h__ */ - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr1_2/mvDram.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr1_2/mvDram.c deleted file mode 100644 index d1b8a3d..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr1_2/mvDram.c +++ /dev/null @@ -1,1479 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#include "ddr1_2/mvDram.h" -#include "boardEnv/mvBoardEnvLib.h" - -#undef MV_DEBUG -#ifdef MV_DEBUG -#define DB(x) x -#else -#define DB(x) -#endif - -static MV_VOID cpyDimm2BankInfo(MV_DIMM_INFO *pDimmInfo, - MV_DRAM_BANK_INFO *pBankInfo); -static MV_U32 cas2ps(MV_U8 spd_byte); -/******************************************************************************* -* mvDramBankGet - Get the DRAM bank paramters. -* -* DESCRIPTION: -* This function retrieves DRAM bank parameters as described in -* DRAM_BANK_INFO struct to the controller DRAM unit. In case the board -* has its DRAM on DIMMs it will use its EEPROM to extract SPD data -* from it. Otherwise, if the DRAM is soldered on board, the function -* should insert its bank information into MV_DRAM_BANK_INFO struct. -* -* INPUT: -* bankNum - Board DRAM bank number. -* -* OUTPUT: -* pBankInfo - DRAM bank information struct. -* -* RETURN: -* MV_FAIL - Bank parameters could not be read. -* -*******************************************************************************/ -MV_STATUS mvDramBankInfoGet(MV_U32 bankNum, MV_DRAM_BANK_INFO *pBankInfo) -{ - MV_DIMM_INFO dimmInfo; - - DB(mvOsPrintf("Dram: mvDramBankInfoGet bank %d\n", bankNum)); - /* zero pBankInfo structure */ - memset(pBankInfo, 0, sizeof(*pBankInfo)); - - if((NULL == pBankInfo) || (bankNum >= MV_DRAM_MAX_CS )) - { - DB(mvOsPrintf("Dram: mvDramBankInfoGet bad params \n")); - return MV_BAD_PARAM; - } - if( MV_OK != dimmSpdGet((MV_U32)(bankNum/2), &dimmInfo)) - { - DB(mvOsPrintf("Dram: ERR dimmSpdGet failed to get dimm info \n")); - return MV_FAIL; - } - if((dimmInfo.numOfModuleBanks == 1) && ((bankNum % 2) == 1)) - { - DB(mvOsPrintf("Dram: ERR dimmSpdGet. Can't find DIMM bank 2 \n")); - return MV_FAIL; - } - - /* convert Dimm info to Bank info */ - cpyDimm2BankInfo(&dimmInfo, pBankInfo); - - return MV_OK; -} - -/******************************************************************************* -* cpyDimm2BankInfo - Convert a Dimm info struct into a bank info struct. -* -* DESCRIPTION: -* Convert a Dimm info struct into a bank info struct. -* -* INPUT: -* pDimmInfo - DIMM information structure. -* -* OUTPUT: -* pBankInfo - DRAM bank information struct. -* -* RETURN: -* None. -* -*******************************************************************************/ -static MV_VOID cpyDimm2BankInfo(MV_DIMM_INFO *pDimmInfo, - MV_DRAM_BANK_INFO *pBankInfo) -{ - pBankInfo->memoryType = pDimmInfo->memoryType; - - /* DIMM dimensions */ - pBankInfo->numOfRowAddr = pDimmInfo->numOfRowAddr; - pBankInfo->numOfColAddr = pDimmInfo->numOfColAddr; - pBankInfo->dataWidth = pDimmInfo->dataWidth; - pBankInfo->errorCheckType = pDimmInfo->errorCheckType; - pBankInfo->sdramWidth = pDimmInfo->sdramWidth; - pBankInfo->errorCheckDataWidth = pDimmInfo->errorCheckDataWidth; - pBankInfo->numOfBanksOnEachDevice = pDimmInfo->numOfBanksOnEachDevice; - pBankInfo->suportedCasLatencies = pDimmInfo->suportedCasLatencies; - pBankInfo->refreshInterval = pDimmInfo->refreshInterval; - - /* DIMM timing parameters */ - pBankInfo->minCycleTimeAtMaxCasLatPs = pDimmInfo->minCycleTimeAtMaxCasLatPs; - pBankInfo->minCycleTimeAtMaxCasLatMinus1Ps = - pDimmInfo->minCycleTimeAtMaxCasLatMinus1Ps; - pBankInfo->minCycleTimeAtMaxCasLatMinus2Ps = - pDimmInfo->minCycleTimeAtMaxCasLatMinus2Ps; - - pBankInfo->minRowPrechargeTime = pDimmInfo->minRowPrechargeTime; - pBankInfo->minRowActiveToRowActive = pDimmInfo->minRowActiveToRowActive; - pBankInfo->minRasToCasDelay = pDimmInfo->minRasToCasDelay; - pBankInfo->minRasPulseWidth = pDimmInfo->minRasPulseWidth; - pBankInfo->minWriteRecoveryTime = pDimmInfo->minWriteRecoveryTime; - pBankInfo->minWriteToReadCmdDelay = pDimmInfo->minWriteToReadCmdDelay; - pBankInfo->minReadToPrechCmdDelay = pDimmInfo->minReadToPrechCmdDelay; - pBankInfo->minRefreshToActiveCmd = pDimmInfo->minRefreshToActiveCmd; - - /* Parameters calculated from the extracted DIMM information */ - pBankInfo->size = pDimmInfo->size/pDimmInfo->numOfModuleBanks; - pBankInfo->deviceDensity = pDimmInfo->deviceDensity; - pBankInfo->numberOfDevices = pDimmInfo->numberOfDevices / - pDimmInfo->numOfModuleBanks; - - /* DIMM attributes (MV_TRUE for yes) */ - - if ((pDimmInfo->memoryType == MEM_TYPE_SDRAM) || - (pDimmInfo->memoryType == MEM_TYPE_DDR1) ) - { - if (pDimmInfo->dimmAttributes & BIT1) - pBankInfo->registeredAddrAndControlInputs = MV_TRUE; - else - pBankInfo->registeredAddrAndControlInputs = MV_FALSE; - } - else /* pDimmInfo->memoryType == MEM_TYPE_DDR2 */ - { - if (pDimmInfo->dimmTypeInfo & (BIT0 | BIT4)) - pBankInfo->registeredAddrAndControlInputs = MV_TRUE; - else - pBankInfo->registeredAddrAndControlInputs = MV_FALSE; - } - - return; -} - -/******************************************************************************* -* dimmSpdCpy - Cpy SPD parameters from dimm 0 to dimm 1. -* -* DESCRIPTION: -* Read the DIMM SPD parameters from dimm 0 into dimm 1 SPD. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_TRUE if function could read DIMM parameters, MV_FALSE otherwise. -* -*******************************************************************************/ -MV_STATUS dimmSpdCpy(MV_VOID) -{ - MV_U32 i; - MV_U32 spdChecksum; - - MV_TWSI_SLAVE twsiSlave; - MV_U8 data[SPD_SIZE]; - - /* zero dimmInfo structure */ - memset(data, 0, SPD_SIZE); - - /* read the dimm eeprom */ - DB(mvOsPrintf("DRAM: Read Dimm eeprom\n")); - twsiSlave.slaveAddr.address = MV_BOARD_DIMM0_I2C_ADDR; - twsiSlave.slaveAddr.type = ADDR7_BIT; - twsiSlave.validOffset = MV_TRUE; - twsiSlave.offset = 0; - twsiSlave.moreThen256 = MV_FALSE; - - if( MV_OK != mvTwsiRead (MV_BOARD_DIMM_I2C_CHANNEL, - &twsiSlave, data, SPD_SIZE) ) - { - DB(mvOsPrintf("DRAM: ERR. no DIMM in dimmNum 0\n")); - return MV_FAIL; - } - DB(puts("DRAM: Reading dimm info succeded.\n")); - - /* calculate SPD checksum */ - spdChecksum = 0; - - for(i = 0 ; i <= 62 ; i++) - { - spdChecksum += data[i]; - } - - if ((spdChecksum & 0xff) != data[63]) - { - DB(mvOsPrintf("DRAM: Warning. Wrong SPD Checksum %2x, expValue=%2x\n", - (MV_U32)(spdChecksum & 0xff), data[63])); - } - else - { - DB(mvOsPrintf("DRAM: SPD Checksum ok!\n")); - } - - /* copy the SPD content 1:1 into the DIMM 1 SPD */ - twsiSlave.slaveAddr.address = MV_BOARD_DIMM1_I2C_ADDR; - twsiSlave.slaveAddr.type = ADDR7_BIT; - twsiSlave.validOffset = MV_TRUE; - twsiSlave.offset = 0; - twsiSlave.moreThen256 = MV_FALSE; - - for(i = 0 ; i < SPD_SIZE ; i++) - { - twsiSlave.offset = i; - if( MV_OK != mvTwsiWrite (MV_BOARD_DIMM_I2C_CHANNEL, - &twsiSlave, &data[i], 1) ) - { - mvOsPrintf("DRAM: ERR. no DIMM in dimmNum 1 byte %d \n",i); - return MV_FAIL; - } - mvOsDelay(5); - } - - DB(puts("DRAM: Reading dimm info succeded.\n")); - return MV_OK; -} - -/******************************************************************************* -* dimmSpdGet - Get the SPD parameters. -* -* DESCRIPTION: -* Read the DIMM SPD parameters into given struct parameter. -* -* INPUT: -* dimmNum - DIMM number. See MV_BOARD_DIMM_NUM enumerator. -* -* OUTPUT: -* pDimmInfo - DIMM information structure. -* -* RETURN: -* MV_TRUE if function could read DIMM parameters, MV_FALSE otherwise. -* -*******************************************************************************/ -MV_STATUS dimmSpdGet(MV_U32 dimmNum, MV_DIMM_INFO *pDimmInfo) -{ - MV_U32 i; - MV_U32 density = 1; - MV_U32 spdChecksum; - - MV_TWSI_SLAVE twsiSlave; - MV_U8 data[SPD_SIZE]; - - if((NULL == pDimmInfo)|| (dimmNum >= MAX_DIMM_NUM)) - { - DB(mvOsPrintf("Dram: mvDramBankInfoGet bad params \n")); - return MV_BAD_PARAM; - } - - /* zero dimmInfo structure */ - memset(data, 0, SPD_SIZE); - - /* read the dimm eeprom */ - DB(mvOsPrintf("DRAM: Read Dimm eeprom\n")); - twsiSlave.slaveAddr.address = (dimmNum == 0) ? - MV_BOARD_DIMM0_I2C_ADDR : MV_BOARD_DIMM1_I2C_ADDR; - twsiSlave.slaveAddr.type = ADDR7_BIT; - twsiSlave.validOffset = MV_TRUE; - twsiSlave.offset = 0; - twsiSlave.moreThen256 = MV_FALSE; - - if( MV_OK != mvTwsiRead (MV_BOARD_DIMM_I2C_CHANNEL, - &twsiSlave, data, SPD_SIZE) ) - { - DB(mvOsPrintf("DRAM: ERR. no DIMM in dimmNum %d \n", dimmNum)); - return MV_FAIL; - } - DB(puts("DRAM: Reading dimm info succeded.\n")); - - /* calculate SPD checksum */ - spdChecksum = 0; - - for(i = 0 ; i <= 62 ; i++) - { - spdChecksum += data[i]; - } - - if ((spdChecksum & 0xff) != data[63]) - { - DB(mvOsPrintf("DRAM: Warning. Wrong SPD Checksum %2x, expValue=%2x\n", - (MV_U32)(spdChecksum & 0xff), data[63])); - } - else - { - DB(mvOsPrintf("DRAM: SPD Checksum ok!\n")); - } - - /* copy the SPD content 1:1 into the dimmInfo structure*/ - for(i = 0 ; i < SPD_SIZE ; i++) - { - pDimmInfo->spdRawData[i] = data[i]; - DB(mvOsPrintf("SPD-EEPROM Byte %3d = %3x (%3d)\n",i, data[i], data[i])); - } - - DB(mvOsPrintf("DRAM SPD Information:\n")); - - /* Memory type (DDR / SDRAM) */ - switch (data[DIMM_MEM_TYPE]) - { - case (DIMM_MEM_TYPE_SDRAM): - pDimmInfo->memoryType = MEM_TYPE_SDRAM; - DB(mvOsPrintf("DRAM Memeory type SDRAM\n")); - break; - case (DIMM_MEM_TYPE_DDR1): - pDimmInfo->memoryType = MEM_TYPE_DDR1; - DB(mvOsPrintf("DRAM Memeory type DDR1\n")); - break; - case (DIMM_MEM_TYPE_DDR2): - pDimmInfo->memoryType = MEM_TYPE_DDR2; - DB(mvOsPrintf("DRAM Memeory type DDR2\n")); - break; - default: - mvOsPrintf("ERROR: Undefined memory type!\n"); - return MV_ERROR; - } - - - /* Number Of Row Addresses */ - pDimmInfo->numOfRowAddr = data[DIMM_ROW_NUM]; - DB(mvOsPrintf("DRAM numOfRowAddr[3] %d\n",pDimmInfo->numOfRowAddr)); - - /* Number Of Column Addresses */ - pDimmInfo->numOfColAddr = data[DIMM_COL_NUM]; - DB(mvOsPrintf("DRAM numOfColAddr[4] %d\n",pDimmInfo->numOfColAddr)); - - /* Number Of Module Banks */ - pDimmInfo->numOfModuleBanks = data[DIMM_MODULE_BANK_NUM]; - DB(mvOsPrintf("DRAM numOfModuleBanks[5] 0x%x\n", - pDimmInfo->numOfModuleBanks)); - - /* Number of module banks encoded differently for DDR2 */ - if (pDimmInfo->memoryType == MEM_TYPE_DDR2) - pDimmInfo->numOfModuleBanks = (pDimmInfo->numOfModuleBanks & 0x7)+1; - - /* Data Width */ - pDimmInfo->dataWidth = data[DIMM_DATA_WIDTH]; - DB(mvOsPrintf("DRAM dataWidth[6] 0x%x\n", pDimmInfo->dataWidth)); - - /* Minimum Cycle Time At Max CasLatancy */ - pDimmInfo->minCycleTimeAtMaxCasLatPs = cas2ps(data[DIMM_MIN_CC_AT_MAX_CAS]); - - /* Error Check Type */ - pDimmInfo->errorCheckType = data[DIMM_ERR_CHECK_TYPE]; - DB(mvOsPrintf("DRAM errorCheckType[11] 0x%x\n", - pDimmInfo->errorCheckType)); - - /* Refresh Interval */ - pDimmInfo->refreshInterval = data[DIMM_REFRESH_INTERVAL]; - DB(mvOsPrintf("DRAM refreshInterval[12] 0x%x\n", - pDimmInfo->refreshInterval)); - - /* Sdram Width */ - pDimmInfo->sdramWidth = data[DIMM_SDRAM_WIDTH]; - DB(mvOsPrintf("DRAM sdramWidth[13] 0x%x\n",pDimmInfo->sdramWidth)); - - /* Error Check Data Width */ - pDimmInfo->errorCheckDataWidth = data[DIMM_ERR_CHECK_DATA_WIDTH]; - DB(mvOsPrintf("DRAM errorCheckDataWidth[14] 0x%x\n", - pDimmInfo->errorCheckDataWidth)); - - /* Burst Length Supported */ - /* SDRAM/DDR1: - *******-******-******-******-******-******-******-******* - * bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 * - *******-******-******-******-******-******-******-******* - burst length = * Page | TBD | TBD | TBD | 8 | 4 | 2 | 1 * - *********************************************************/ - /* DDR2: - *******-******-******-******-******-******-******-******* - * bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 * - *******-******-******-******-******-******-******-******* - burst length = * Page | TBD | TBD | TBD | 8 | 4 | TBD | TBD * - *********************************************************/ - - pDimmInfo->burstLengthSupported = data[DIMM_BURST_LEN_SUP]; - DB(mvOsPrintf("DRAM burstLengthSupported[16] 0x%x\n", - pDimmInfo->burstLengthSupported)); - - /* Number Of Banks On Each Device */ - pDimmInfo->numOfBanksOnEachDevice = data[DIMM_DEV_BANK_NUM]; - DB(mvOsPrintf("DRAM numOfBanksOnEachDevice[17] 0x%x\n", - pDimmInfo->numOfBanksOnEachDevice)); - - /* Suported Cas Latencies */ - - /* SDRAM: - *******-******-******-******-******-******-******-******* - * bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 * - *******-******-******-******-******-******-******-******* - CAS = * TBD | 7 | 6 | 5 | 4 | 3 | 2 | 1 * - ********************************************************/ - - /* DDR 1: - *******-******-******-******-******-******-******-******* - * bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 * - *******-******-******-******-******-******-******-******* - CAS = * TBD | 4 | 3.5 | 3 | 2.5 | 2 | 1.5 | 1 * - *********************************************************/ - - /* DDR 2: - *******-******-******-******-******-******-******-******* - * bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 * - *******-******-******-******-******-******-******-******* - CAS = * TBD | TBD | 5 | 4 | 3 | 2 | TBD | TBD * - *********************************************************/ - - pDimmInfo->suportedCasLatencies = data[DIMM_SUP_CAL]; - DB(mvOsPrintf("DRAM suportedCasLatencies[18] 0x%x\n", - pDimmInfo->suportedCasLatencies)); - - /* For DDR2 only, get the DIMM type information */ - if (pDimmInfo->memoryType == MEM_TYPE_DDR2) - { - pDimmInfo->dimmTypeInfo = data[DIMM_DDR2_TYPE_INFORMATION]; - DB(mvOsPrintf("DRAM dimmTypeInfo[20] (DDR2) 0x%x\n", - pDimmInfo->dimmTypeInfo)); - } - - /* SDRAM Modules Attributes */ - pDimmInfo->dimmAttributes = data[DIMM_BUF_ADDR_CONT_IN]; - DB(mvOsPrintf("DRAM dimmAttributes[21] 0x%x\n", - pDimmInfo->dimmAttributes)); - - /* Minimum Cycle Time At Max CasLatancy Minus 1*/ - pDimmInfo->minCycleTimeAtMaxCasLatMinus1Ps = - cas2ps(data[DIMM_MIN_CC_AT_MAX_CAS_MINUS1]); - - /* Minimum Cycle Time At Max CasLatancy Minus 2*/ - pDimmInfo->minCycleTimeAtMaxCasLatMinus2Ps = - cas2ps(data[DIMM_MIN_CC_AT_MAX_CAS_MINUS2]); - - pDimmInfo->minRowPrechargeTime = data[DIMM_MIN_ROW_PRECHARGE_TIME]; - DB(mvOsPrintf("DRAM minRowPrechargeTime[27] 0x%x\n", - pDimmInfo->minRowPrechargeTime)); - pDimmInfo->minRowActiveToRowActive = data[DIMM_MIN_ROW_ACTIVE_TO_ROW_ACTIVE]; - DB(mvOsPrintf("DRAM minRowActiveToRowActive[28] 0x%x\n", - pDimmInfo->minRowActiveToRowActive)); - pDimmInfo->minRasToCasDelay = data[DIMM_MIN_RAS_TO_CAS_DELAY]; - DB(mvOsPrintf("DRAM minRasToCasDelay[29] 0x%x\n", - pDimmInfo->minRasToCasDelay)); - pDimmInfo->minRasPulseWidth = data[DIMM_MIN_RAS_PULSE_WIDTH]; - DB(mvOsPrintf("DRAM minRasPulseWidth[30] 0x%x\n", - pDimmInfo->minRasPulseWidth)); - - /* DIMM Bank Density */ - pDimmInfo->dimmBankDensity = data[DIMM_BANK_DENSITY]; - DB(mvOsPrintf("DRAM dimmBankDensity[31] 0x%x\n", - pDimmInfo->dimmBankDensity)); - - /* Only DDR2 includes Write Recovery Time field. Other SDRAM ignore */ - pDimmInfo->minWriteRecoveryTime = data[DIMM_MIN_WRITE_RECOVERY_TIME]; - DB(mvOsPrintf("DRAM minWriteRecoveryTime[36] 0x%x\n", - pDimmInfo->minWriteRecoveryTime)); - - /* Only DDR2 includes Internal Write To Read Command Delay field. */ - pDimmInfo->minWriteToReadCmdDelay = data[DIMM_MIN_WRITE_TO_READ_CMD_DELAY]; - DB(mvOsPrintf("DRAM minWriteToReadCmdDelay[37] 0x%x\n", - pDimmInfo->minWriteToReadCmdDelay)); - - /* Only DDR2 includes Internal Read To Precharge Command Delay field. */ - pDimmInfo->minReadToPrechCmdDelay = data[DIMM_MIN_READ_TO_PRECH_CMD_DELAY]; - DB(mvOsPrintf("DRAM minReadToPrechCmdDelay[38] 0x%x\n", - pDimmInfo->minReadToPrechCmdDelay)); - - /* Only DDR2 includes Minimum Refresh to Activate/Refresh Command field */ - pDimmInfo->minRefreshToActiveCmd = data[DIMM_MIN_REFRESH_TO_ACTIVATE_CMD]; - DB(mvOsPrintf("DRAM minRefreshToActiveCmd[42] 0x%x\n", - pDimmInfo->minRefreshToActiveCmd)); - - /* calculating the sdram density. Representing device density from */ - /* bit 20 to allow representation of 4GB and above. */ - /* For example, if density is 512Mbit 0x20000000, will be represent in */ - /* deviceDensity by 0x20000000 >> 16 --> 0x00000200. Another example */ - /* is density 8GB 0x200000000 >> 16 --> 0x00002000. */ - density = (1 << ((pDimmInfo->numOfRowAddr + pDimmInfo->numOfColAddr) - 20)); - pDimmInfo->deviceDensity = density * - pDimmInfo->numOfBanksOnEachDevice * - pDimmInfo->sdramWidth; - DB(mvOsPrintf("DRAM deviceDensity %d\n",pDimmInfo->deviceDensity)); - - /* Number of devices includeing Error correction */ - pDimmInfo->numberOfDevices = (pDimmInfo->dataWidth/pDimmInfo->sdramWidth) * - pDimmInfo->numOfModuleBanks; - DB(mvOsPrintf("DRAM numberOfDevices %d\n", - pDimmInfo->numberOfDevices)); - - pDimmInfo->size = 0; - - /* Note that pDimmInfo->size is in MB units */ - if (pDimmInfo->memoryType == MEM_TYPE_SDRAM) - { - if (pDimmInfo->dimmBankDensity & BIT0) - pDimmInfo->size += 1024; /* Equal to 1GB */ - else if (pDimmInfo->dimmBankDensity & BIT1) - pDimmInfo->size += 8; /* Equal to 8MB */ - else if (pDimmInfo->dimmBankDensity & BIT2) - pDimmInfo->size += 16; /* Equal to 16MB */ - else if (pDimmInfo->dimmBankDensity & BIT3) - pDimmInfo->size += 32; /* Equal to 32MB */ - else if (pDimmInfo->dimmBankDensity & BIT4) - pDimmInfo->size += 64; /* Equal to 64MB */ - else if (pDimmInfo->dimmBankDensity & BIT5) - pDimmInfo->size += 128; /* Equal to 128MB */ - else if (pDimmInfo->dimmBankDensity & BIT6) - pDimmInfo->size += 256; /* Equal to 256MB */ - else if (pDimmInfo->dimmBankDensity & BIT7) - pDimmInfo->size += 512; /* Equal to 512MB */ - } - else if (pDimmInfo->memoryType == MEM_TYPE_DDR1) - { - if (pDimmInfo->dimmBankDensity & BIT0) - pDimmInfo->size += 1024; /* Equal to 1GB */ - else if (pDimmInfo->dimmBankDensity & BIT1) - pDimmInfo->size += 2048; /* Equal to 2GB */ - else if (pDimmInfo->dimmBankDensity & BIT2) - pDimmInfo->size += 16; /* Equal to 16MB */ - else if (pDimmInfo->dimmBankDensity & BIT3) - pDimmInfo->size += 32; /* Equal to 32MB */ - else if (pDimmInfo->dimmBankDensity & BIT4) - pDimmInfo->size += 64; /* Equal to 64MB */ - else if (pDimmInfo->dimmBankDensity & BIT5) - pDimmInfo->size += 128; /* Equal to 128MB */ - else if (pDimmInfo->dimmBankDensity & BIT6) - pDimmInfo->size += 256; /* Equal to 256MB */ - else if (pDimmInfo->dimmBankDensity & BIT7) - pDimmInfo->size += 512; /* Equal to 512MB */ - } - else /* if (dimmInfo.memoryType == MEM_TYPE_DDR2) */ - { - if (pDimmInfo->dimmBankDensity & BIT0) - pDimmInfo->size += 1024; /* Equal to 1GB */ - else if (pDimmInfo->dimmBankDensity & BIT1) - pDimmInfo->size += 2048; /* Equal to 2GB */ - else if (pDimmInfo->dimmBankDensity & BIT2) - pDimmInfo->size += 4096; /* Equal to 4GB */ - else if (pDimmInfo->dimmBankDensity & BIT3) - pDimmInfo->size += 8192; /* Equal to 8GB */ - else if (pDimmInfo->dimmBankDensity & BIT4) - pDimmInfo->size += 16384; /* Equal to 16GB */ - else if (pDimmInfo->dimmBankDensity & BIT5) - pDimmInfo->size += 128; /* Equal to 128MB */ - else if (pDimmInfo->dimmBankDensity & BIT6) - pDimmInfo->size += 256; /* Equal to 256MB */ - else if (pDimmInfo->dimmBankDensity & BIT7) - pDimmInfo->size += 512; /* Equal to 512MB */ - } - - pDimmInfo->size *= pDimmInfo->numOfModuleBanks; - - DB(mvOsPrintf("Dram: dimm size %dMB \n",pDimmInfo->size)); - - return MV_OK; -} - -/******************************************************************************* -* dimmSpdPrint - Print the SPD parameters. -* -* DESCRIPTION: -* Print the Dimm SPD parameters. -* -* INPUT: -* pDimmInfo - DIMM information structure. -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_VOID dimmSpdPrint(MV_U32 dimmNum) -{ - MV_DIMM_INFO dimmInfo; - MV_U32 i, temp = 0; - MV_U32 k, maskLeftOfPoint = 0, maskRightOfPoint = 0; - MV_U32 rightOfPoint = 0,leftOfPoint = 0, div, time_tmp, shift; - MV_U32 busClkPs; - MV_U8 trp_clocks=0, trcd_clocks, tras_clocks, trrd_clocks, - temp_buf[40], *spdRawData; - - busClkPs = 1000000000 / (mvBoardSysClkGet() / 100); /* in 10 ps units */ - - spdRawData = dimmInfo.spdRawData; - - if(MV_OK != dimmSpdGet(dimmNum, &dimmInfo)) - { - mvOsOutput("ERROR: Could not read SPD information!\n"); - return; - } - - /* find Manufactura of Dimm Module */ - mvOsOutput("\nManufacturer's JEDEC ID Code: "); - for(i = 0 ; i < DIMM_MODULE_MANU_SIZE ; i++) - { - mvOsOutput("%x",spdRawData[DIMM_MODULE_MANU_OFFS + i]); - } - mvOsOutput("\n"); - - /* Manufacturer's Specific Data */ - for(i = 0 ; i < DIMM_MODULE_ID_SIZE ; i++) - { - temp_buf[i] = spdRawData[DIMM_MODULE_ID_OFFS + i]; - } - mvOsOutput("Manufacturer's Specific Data: %s\n", temp_buf); - - /* Module Part Number */ - for(i = 0 ; i < DIMM_MODULE_VEN_SIZE ; i++) - { - temp_buf[i] = spdRawData[DIMM_MODULE_VEN_OFFS + i]; - } - mvOsOutput("Module Part Number: %s\n", temp_buf); - - /* Module Serial Number */ - for(i = 0; i < sizeof(MV_U32); i++) - { - temp |= spdRawData[95+i] << 8*i; - } - mvOsOutput("DIMM Serial No. %ld (%lx)\n", (long)temp, - (long)temp); - - /* find Manufac-Data of Dimm Module */ - mvOsOutput("Manufactoring Date: Year 20%d%d/ ww %d%d\n", - ((spdRawData[93] & 0xf0) >> 4), (spdRawData[93] & 0xf), - ((spdRawData[94] & 0xf0) >> 4), (spdRawData[94] & 0xf)); - /* find modul_revision of Dimm Module */ - mvOsOutput("Module Revision: %d.%d\n", - spdRawData[91], spdRawData[92]); - - /* find manufac_place of Dimm Module */ - mvOsOutput("manufac_place: %d\n", spdRawData[72]); - - /* go over the first 35 I2C data bytes */ - for(i = 2 ; i <= 35 ; i++) - switch(i) - { - case 2: /* Memory type (DDR1/2 / SDRAM) */ - if (dimmInfo.memoryType == MEM_TYPE_SDRAM) - mvOsOutput("Dram Type is: SDRAM\n"); - else if (dimmInfo.memoryType == MEM_TYPE_DDR1) - mvOsOutput("Dram Type is: SDRAM DDR1\n"); - else if (dimmInfo.memoryType == MEM_TYPE_DDR2) - mvOsOutput("Dram Type is: SDRAM DDR2\n"); - else - mvOsOutput("Dram Type unknown\n"); - break; -/*----------------------------------------------------------------------------*/ - - case 3: /* Number Of Row Addresses */ - mvOsOutput("Module Number of row addresses: %d\n", - dimmInfo.numOfRowAddr); - break; -/*----------------------------------------------------------------------------*/ - - case 4: /* Number Of Column Addresses */ - mvOsOutput("Module Number of col addresses: %d\n", - dimmInfo.numOfColAddr); - break; -/*----------------------------------------------------------------------------*/ - - case 5: /* Number Of Module Banks */ - mvOsOutput("Number of Banks on Mod.: %d\n", - dimmInfo.numOfModuleBanks); - break; -/*----------------------------------------------------------------------------*/ - - case 6: /* Data Width */ - mvOsOutput("Module Data Width: %d bit\n", - dimmInfo.dataWidth); - break; -/*----------------------------------------------------------------------------*/ - - case 8: /* Voltage Interface */ - switch(spdRawData[i]) - { - case 0x0: - mvOsOutput("Module is TTL_5V_TOLERANT\n"); - break; - case 0x1: - mvOsOutput("Module is LVTTL\n"); - break; - case 0x2: - mvOsOutput("Module is HSTL_1_5V\n"); - break; - case 0x3: - mvOsOutput("Module is SSTL_3_3V\n"); - break; - case 0x4: - mvOsOutput("Module is SSTL_2_5V\n"); - break; - case 0x5: - if (dimmInfo.memoryType != MEM_TYPE_SDRAM) - { - mvOsOutput("Module is SSTL_1_8V\n"); - break; - } - default: - mvOsOutput("Module is VOLTAGE_UNKNOWN\n"); - break; - } - break; -/*----------------------------------------------------------------------------*/ - - case 9: /* Minimum Cycle Time At Max CasLatancy */ - leftOfPoint = (spdRawData[i] & 0xf0) >> 4; - rightOfPoint = (spdRawData[i] & 0x0f) * 10; - - /* DDR2 addition of right of point */ - if ((spdRawData[i] & 0x0f) == 0xA) - { - rightOfPoint = 25; - } - if ((spdRawData[i] & 0x0f) == 0xB) - { - rightOfPoint = 33; - } - if ((spdRawData[i] & 0x0f) == 0xC) - { - rightOfPoint = 66; - } - if ((spdRawData[i] & 0x0f) == 0xD) - { - rightOfPoint = 75; - } - mvOsOutput("Minimum Cycle Time At Max CL: %d.%d [ns]\n", - leftOfPoint, rightOfPoint); - break; -/*----------------------------------------------------------------------------*/ - - case 10: /* Clock To Data Out */ - div = (dimmInfo.memoryType == MEM_TYPE_SDRAM)? 10:100; - time_tmp = (((spdRawData[i] & 0xf0) >> 4)*10) + - ((spdRawData[i] & 0x0f)); - leftOfPoint = time_tmp / div; - rightOfPoint = time_tmp % div; - mvOsOutput("Clock To Data Out: %d.%d [ns]\n", - leftOfPoint, rightOfPoint); - break; -/*----------------------------------------------------------------------------*/ - - case 11: /* Error Check Type */ - mvOsOutput("Error Check Type (0=NONE): %d\n", - dimmInfo.errorCheckType); - break; -/*----------------------------------------------------------------------------*/ - - case 12: /* Refresh Interval */ - mvOsOutput("Refresh Rate: %x\n", - dimmInfo.refreshInterval); - break; -/*----------------------------------------------------------------------------*/ - - case 13: /* Sdram Width */ - mvOsOutput("Sdram Width: %d bits\n", - dimmInfo.sdramWidth); - break; -/*----------------------------------------------------------------------------*/ - - case 14: /* Error Check Data Width */ - mvOsOutput("Error Check Data Width: %d bits\n", - dimmInfo.errorCheckDataWidth); - break; -/*----------------------------------------------------------------------------*/ - - case 15: /* Minimum Clock Delay is unsupported */ - if ((dimmInfo.memoryType == MEM_TYPE_SDRAM) || - (dimmInfo.memoryType == MEM_TYPE_DDR1)) - { - mvOsOutput("Minimum Clk Delay back to back: %d\n", - spdRawData[i]); - } - break; -/*----------------------------------------------------------------------------*/ - - case 16: /* Burst Length Supported */ - /* SDRAM/DDR1: - *******-******-******-******-******-******-******-******* - * bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 * - *******-******-******-******-******-******-******-******* - burst length = * Page | TBD | TBD | TBD | 8 | 4 | 2 | 1 * - *********************************************************/ - /* DDR2: - *******-******-******-******-******-******-******-******* - * bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 * - *******-******-******-******-******-******-******-******* - burst length = * Page | TBD | TBD | TBD | 8 | 4 | TBD | TBD * - *********************************************************/ - mvOsOutput("Burst Length Supported: "); - if ((dimmInfo.memoryType == MEM_TYPE_SDRAM) || - (dimmInfo.memoryType == MEM_TYPE_DDR1)) - { - if (dimmInfo.burstLengthSupported & BIT0) - mvOsOutput("1, "); - if (dimmInfo.burstLengthSupported & BIT1) - mvOsOutput("2, "); - } - if (dimmInfo.burstLengthSupported & BIT2) - mvOsOutput("4, "); - if (dimmInfo.burstLengthSupported & BIT3) - mvOsOutput("8, "); - - mvOsOutput(" Bit \n"); - break; -/*----------------------------------------------------------------------------*/ - - case 17: /* Number Of Banks On Each Device */ - mvOsOutput("Number Of Banks On Each Chip: %d\n", - dimmInfo.numOfBanksOnEachDevice); - break; -/*----------------------------------------------------------------------------*/ - - case 18: /* Suported Cas Latencies */ - - /* SDRAM: - *******-******-******-******-******-******-******-******* - * bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 * - *******-******-******-******-******-******-******-******* - CAS = * TBD | 7 | 6 | 5 | 4 | 3 | 2 | 1 * - ********************************************************/ - - /* DDR 1: - *******-******-******-******-******-******-******-******* - * bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 * - *******-******-******-******-******-******-******-******* - CAS = * TBD | 4 | 3.5 | 3 | 2.5 | 2 | 1.5 | 1 * - *********************************************************/ - - /* DDR 2: - *******-******-******-******-******-******-******-******* - * bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 * - *******-******-******-******-******-******-******-******* - CAS = * TBD | TBD | 5 | 4 | 3 | 2 | TBD | TBD * - *********************************************************/ - - mvOsOutput("Suported Cas Latencies: (CL) "); - if (dimmInfo.memoryType == MEM_TYPE_SDRAM) - { - for (k = 0; k <=7; k++) - { - if (dimmInfo.suportedCasLatencies & (1 << k)) - mvOsOutput("%d, ", k+1); - } - } - else if (dimmInfo.memoryType == MEM_TYPE_DDR1) - { - if (dimmInfo.suportedCasLatencies & BIT0) - mvOsOutput("1, "); - if (dimmInfo.suportedCasLatencies & BIT1) - mvOsOutput("1.5, "); - if (dimmInfo.suportedCasLatencies & BIT2) - mvOsOutput("2, "); - if (dimmInfo.suportedCasLatencies & BIT3) - mvOsOutput("2.5, "); - if (dimmInfo.suportedCasLatencies & BIT4) - mvOsOutput("3, "); - if (dimmInfo.suportedCasLatencies & BIT5) - mvOsOutput("3.5, "); - } - else if (dimmInfo.memoryType == MEM_TYPE_DDR2) - { - if (dimmInfo.suportedCasLatencies & BIT2) - mvOsOutput("2, "); - if (dimmInfo.suportedCasLatencies & BIT3) - mvOsOutput("3, "); - if (dimmInfo.suportedCasLatencies & BIT4) - mvOsOutput("4, "); - if (dimmInfo.suportedCasLatencies & BIT5) - mvOsOutput("5, "); - } - else - mvOsOutput("?.?, "); - mvOsOutput("\n"); - break; -/*----------------------------------------------------------------------------*/ - - case 20: /* DDR2 DIMM type info */ - if (dimmInfo.memoryType == MEM_TYPE_DDR2) - { - if (dimmInfo.dimmTypeInfo & (BIT0 | BIT4)) - mvOsOutput("Registered DIMM (RDIMM)\n"); - else if (dimmInfo.dimmTypeInfo & (BIT1 | BIT5)) - mvOsOutput("Unbuffered DIMM (UDIMM)\n"); - else - mvOsOutput("Unknown DIMM type.\n"); - } - - break; -/*----------------------------------------------------------------------------*/ - - case 21: /* SDRAM Modules Attributes */ - mvOsOutput("\nModule Attributes (SPD Byte 21): \n"); - - if (dimmInfo.memoryType == MEM_TYPE_SDRAM) - { - if (dimmInfo.dimmAttributes & BIT0) - mvOsOutput(" Buffered Addr/Control Input: Yes\n"); - else - mvOsOutput(" Buffered Addr/Control Input: No\n"); - - if (dimmInfo.dimmAttributes & BIT1) - mvOsOutput(" Registered Addr/Control Input: Yes\n"); - else - mvOsOutput(" Registered Addr/Control Input: No\n"); - - if (dimmInfo.dimmAttributes & BIT2) - mvOsOutput(" On-Card PLL (clock): Yes \n"); - else - mvOsOutput(" On-Card PLL (clock): No \n"); - - if (dimmInfo.dimmAttributes & BIT3) - mvOsOutput(" Bufferd DQMB Input: Yes \n"); - else - mvOsOutput(" Bufferd DQMB Inputs: No \n"); - - if (dimmInfo.dimmAttributes & BIT4) - mvOsOutput(" Registered DQMB Inputs: Yes \n"); - else - mvOsOutput(" Registered DQMB Inputs: No \n"); - - if (dimmInfo.dimmAttributes & BIT5) - mvOsOutput(" Differential Clock Input: Yes \n"); - else - mvOsOutput(" Differential Clock Input: No \n"); - - if (dimmInfo.dimmAttributes & BIT6) - mvOsOutput(" redundant Row Addressing: Yes \n"); - else - mvOsOutput(" redundant Row Addressing: No \n"); - } - else if (dimmInfo.memoryType == MEM_TYPE_DDR1) - { - if (dimmInfo.dimmAttributes & BIT0) - mvOsOutput(" Buffered Addr/Control Input: Yes\n"); - else - mvOsOutput(" Buffered Addr/Control Input: No\n"); - - if (dimmInfo.dimmAttributes & BIT1) - mvOsOutput(" Registered Addr/Control Input: Yes\n"); - else - mvOsOutput(" Registered Addr/Control Input: No\n"); - - if (dimmInfo.dimmAttributes & BIT2) - mvOsOutput(" On-Card PLL (clock): Yes \n"); - else - mvOsOutput(" On-Card PLL (clock): No \n"); - - if (dimmInfo.dimmAttributes & BIT3) - mvOsOutput(" FET Switch On-Card Enabled: Yes \n"); - else - mvOsOutput(" FET Switch On-Card Enabled: No \n"); - - if (dimmInfo.dimmAttributes & BIT4) - mvOsOutput(" FET Switch External Enabled: Yes \n"); - else - mvOsOutput(" FET Switch External Enabled: No \n"); - - if (dimmInfo.dimmAttributes & BIT5) - mvOsOutput(" Differential Clock Input: Yes \n"); - else - mvOsOutput(" Differential Clock Input: No \n"); - } - else /* if (dimmInfo.memoryType == MEM_TYPE_DDR2) */ - { - mvOsOutput(" Number of Active Registers on the DIMM: %d\n", - (dimmInfo.dimmAttributes & 0x3) + 1); - - mvOsOutput(" Number of PLLs on the DIMM: %d\n", - ((dimmInfo.dimmAttributes) >> 2) & 0x3); - - if (dimmInfo.dimmAttributes & BIT4) - mvOsOutput(" FET Switch External Enabled: Yes \n"); - else - mvOsOutput(" FET Switch External Enabled: No \n"); - - if (dimmInfo.dimmAttributes & BIT6) - mvOsOutput(" Analysis probe installed: Yes \n"); - else - mvOsOutput(" Analysis probe installed: No \n"); - } - - break; -/*----------------------------------------------------------------------------*/ - - case 22: /* Suported AutoPreCharge */ - mvOsOutput("\nModul Attributes (SPD Byte 22): \n"); - if (dimmInfo.memoryType == MEM_TYPE_SDRAM) - { - if ( spdRawData[i] & BIT0 ) - mvOsOutput(" Early Ras Precharge: Yes \n"); - else - mvOsOutput(" Early Ras Precharge: No \n"); - - if ( spdRawData[i] & BIT1 ) - mvOsOutput(" AutoPreCharge: Yes \n"); - else - mvOsOutput(" AutoPreCharge: No \n"); - - if ( spdRawData[i] & BIT2 ) - mvOsOutput(" Precharge All: Yes \n"); - else - mvOsOutput(" Precharge All: No \n"); - - if ( spdRawData[i] & BIT3 ) - mvOsOutput(" Write 1/ReadBurst: Yes \n"); - else - mvOsOutput(" Write 1/ReadBurst: No \n"); - - if ( spdRawData[i] & BIT4 ) - mvOsOutput(" lower VCC tolerance: 5%%\n"); - else - mvOsOutput(" lower VCC tolerance: 10%%\n"); - - if ( spdRawData[i] & BIT5 ) - mvOsOutput(" upper VCC tolerance: 5%%\n"); - else - mvOsOutput(" upper VCC tolerance: 10%%\n"); - } - else if (dimmInfo.memoryType == MEM_TYPE_DDR1) - { - if ( spdRawData[i] & BIT0 ) - mvOsOutput(" Supports Weak Driver: Yes \n"); - else - mvOsOutput(" Supports Weak Driver: No \n"); - - if ( !(spdRawData[i] & BIT4) ) - mvOsOutput(" lower VCC tolerance: 0.2V\n"); - - if ( !(spdRawData[i] & BIT5) ) - mvOsOutput(" upper VCC tolerance: 0.2V\n"); - - if ( spdRawData[i] & BIT6 ) - mvOsOutput(" Concurrent Auto Preharge: Yes \n"); - else - mvOsOutput(" Concurrent Auto Preharge: No \n"); - - if ( spdRawData[i] & BIT7 ) - mvOsOutput(" Supports Fast AP: Yes \n"); - else - mvOsOutput(" Supports Fast AP: No \n"); - } - else if (dimmInfo.memoryType == MEM_TYPE_DDR2) - { - if ( spdRawData[i] & BIT0 ) - mvOsOutput(" Supports Weak Driver: Yes \n"); - else - mvOsOutput(" Supports Weak Driver: No \n"); - } - break; -/*----------------------------------------------------------------------------*/ - - case 23: - /* Minimum Cycle Time At Maximum Cas Latancy Minus 1 (2nd highest CL) */ - leftOfPoint = (spdRawData[i] & 0xf0) >> 4; - rightOfPoint = (spdRawData[i] & 0x0f) * 10; - - /* DDR2 addition of right of point */ - if ((spdRawData[i] & 0x0f) == 0xA) - { - rightOfPoint = 25; - } - if ((spdRawData[i] & 0x0f) == 0xB) - { - rightOfPoint = 33; - } - if ((spdRawData[i] & 0x0f) == 0xC) - { - rightOfPoint = 66; - } - if ((spdRawData[i] & 0x0f) == 0xD) - { - rightOfPoint = 75; - } - - mvOsOutput("Minimum Cycle Time At 2nd highest CasLatancy" - "(0 = Not supported): %d.%d [ns]\n", - leftOfPoint, rightOfPoint ); - break; -/*----------------------------------------------------------------------------*/ - - case 24: /* Clock To Data Out 2nd highest Cas Latency Value*/ - div = (dimmInfo.memoryType == MEM_TYPE_SDRAM) ? 10:100; - time_tmp = (((spdRawData[i] & 0xf0) >> 4)*10) + - ((spdRawData[i] & 0x0f)); - leftOfPoint = time_tmp / div; - rightOfPoint = time_tmp % div; - mvOsOutput("Clock To Data Out (2nd CL value): %d.%d [ns]\n", - leftOfPoint, rightOfPoint); - break; -/*----------------------------------------------------------------------------*/ - - case 25: - /* Minimum Cycle Time At Maximum Cas Latancy Minus 2 (3rd highest CL) */ - if (dimmInfo.memoryType == MEM_TYPE_SDRAM) - { - leftOfPoint = (spdRawData[i] & 0xfc) >> 2; - rightOfPoint = (spdRawData[i] & 0x3) * 25; - } - else /* DDR1 or DDR2 */ - { - leftOfPoint = (spdRawData[i] & 0xf0) >> 4; - rightOfPoint = (spdRawData[i] & 0x0f) * 10; - - /* DDR2 addition of right of point */ - if ((spdRawData[i] & 0x0f) == 0xA) - { - rightOfPoint = 25; - } - if ((spdRawData[i] & 0x0f) == 0xB) - { - rightOfPoint = 33; - } - if ((spdRawData[i] & 0x0f) == 0xC) - { - rightOfPoint = 66; - } - if ((spdRawData[i] & 0x0f) == 0xD) - { - rightOfPoint = 75; - } - } - mvOsOutput("Minimum Cycle Time At 3rd highest CasLatancy" - "(0 = Not supported): %d.%d [ns]\n", - leftOfPoint, rightOfPoint ); - break; -/*----------------------------------------------------------------------------*/ - - case 26: /* Clock To Data Out 3rd highest Cas Latency Value*/ - if (dimmInfo.memoryType == MEM_TYPE_SDRAM) - { - leftOfPoint = (spdRawData[i] & 0xfc) >> 2; - rightOfPoint = (spdRawData[i] & 0x3) * 25; - } - else /* DDR1 or DDR2 */ - { - time_tmp = (((spdRawData[i] & 0xf0) >> 4)*10) + - ((spdRawData[i] & 0x0f)); - leftOfPoint = 0; - rightOfPoint = time_tmp; - } - mvOsOutput("Clock To Data Out (3rd CL value): %d.%2d[ns]\n", - leftOfPoint, rightOfPoint ); - break; -/*----------------------------------------------------------------------------*/ - - case 27: /* Minimum Row Precharge Time */ - shift = (dimmInfo.memoryType == MEM_TYPE_SDRAM)? 0:2; - maskLeftOfPoint = (dimmInfo.memoryType == MEM_TYPE_SDRAM) ? - 0xff : 0xfc; - maskRightOfPoint = (dimmInfo.memoryType == MEM_TYPE_SDRAM) ? - 0x00 : 0x03; - leftOfPoint = ((spdRawData[i] & maskLeftOfPoint) >> shift); - rightOfPoint = (spdRawData[i] & maskRightOfPoint)*25; - temp = ((leftOfPoint*100) + rightOfPoint);/* in 10ps Intervals*/ - trp_clocks = (temp + (busClkPs-1)) / busClkPs; - mvOsOutput("Minimum Row Precharge Time [ns]: %d.%d = " - "in Clk cycles %d\n", - leftOfPoint, rightOfPoint, trp_clocks); - break; -/*----------------------------------------------------------------------------*/ - - case 28: /* Minimum Row Active to Row Active Time */ - shift = (dimmInfo.memoryType == MEM_TYPE_SDRAM)? 0:2; - maskLeftOfPoint = (dimmInfo.memoryType == MEM_TYPE_SDRAM) ? - 0xff : 0xfc; - maskRightOfPoint = (dimmInfo.memoryType == MEM_TYPE_SDRAM) ? - 0x00 : 0x03; - leftOfPoint = ((spdRawData[i] & maskLeftOfPoint) >> shift); - rightOfPoint = (spdRawData[i] & maskRightOfPoint)*25; - temp = ((leftOfPoint*100) + rightOfPoint);/* in 100ns Interval*/ - trrd_clocks = (temp + (busClkPs-1)) / busClkPs; - mvOsOutput("Minimum Row Active -To- Row Active Delay [ns]: " - "%d.%d = in Clk cycles %d\n", - leftOfPoint, rightOfPoint, trp_clocks); - break; -/*----------------------------------------------------------------------------*/ - - case 29: /* Minimum Ras-To-Cas Delay */ - shift = (dimmInfo.memoryType == MEM_TYPE_SDRAM)? 0:2; - maskLeftOfPoint = (dimmInfo.memoryType == MEM_TYPE_SDRAM) ? - 0xff : 0xfc; - maskRightOfPoint = (dimmInfo.memoryType == MEM_TYPE_SDRAM) ? - 0x00 : 0x03; - leftOfPoint = ((spdRawData[i] & maskLeftOfPoint) >> shift); - rightOfPoint = (spdRawData[i] & maskRightOfPoint)*25; - temp = ((leftOfPoint*100) + rightOfPoint);/* in 100ns Interval*/ - trcd_clocks = (temp + (busClkPs-1) )/ busClkPs; - mvOsOutput("Minimum Ras-To-Cas Delay [ns]: %d.%d = " - "in Clk cycles %d\n", - leftOfPoint, rightOfPoint, trp_clocks); - break; -/*----------------------------------------------------------------------------*/ - - case 30: /* Minimum Ras Pulse Width */ - tras_clocks = (cas2ps(spdRawData[i])+(busClkPs-1)) / busClkPs; - mvOsOutput("Minimum Ras Pulse Width [ns]: %d = " - "in Clk cycles %d\n", spdRawData[i], tras_clocks); - break; -/*----------------------------------------------------------------------------*/ - - case 31: /* Module Bank Density */ - mvOsOutput("Module Bank Density (more than 1= Multisize-Module):"); - - if (dimmInfo.memoryType == MEM_TYPE_SDRAM) - { - if (dimmInfo.dimmBankDensity & BIT0) - mvOsOutput("1GB, "); - if (dimmInfo.dimmBankDensity & BIT1) - mvOsOutput("8MB, "); - if (dimmInfo.dimmBankDensity & BIT2) - mvOsOutput("16MB, "); - if (dimmInfo.dimmBankDensity & BIT3) - mvOsOutput("32MB, "); - if (dimmInfo.dimmBankDensity & BIT4) - mvOsOutput("64MB, "); - if (dimmInfo.dimmBankDensity & BIT5) - mvOsOutput("128MB, "); - if (dimmInfo.dimmBankDensity & BIT6) - mvOsOutput("256MB, "); - if (dimmInfo.dimmBankDensity & BIT7) - mvOsOutput("512MB, "); - } - else if (dimmInfo.memoryType == MEM_TYPE_DDR1) - { - if (dimmInfo.dimmBankDensity & BIT0) - mvOsOutput("1GB, "); - if (dimmInfo.dimmBankDensity & BIT1) - mvOsOutput("2GB, "); - if (dimmInfo.dimmBankDensity & BIT2) - mvOsOutput("16MB, "); - if (dimmInfo.dimmBankDensity & BIT3) - mvOsOutput("32MB, "); - if (dimmInfo.dimmBankDensity & BIT4) - mvOsOutput("64MB, "); - if (dimmInfo.dimmBankDensity & BIT5) - mvOsOutput("128MB, "); - if (dimmInfo.dimmBankDensity & BIT6) - mvOsOutput("256MB, "); - if (dimmInfo.dimmBankDensity & BIT7) - mvOsOutput("512MB, "); - } - else /* if (dimmInfo.memoryType == MEM_TYPE_DDR2) */ - { - if (dimmInfo.dimmBankDensity & BIT0) - mvOsOutput("1GB, "); - if (dimmInfo.dimmBankDensity & BIT1) - mvOsOutput("2GB, "); - if (dimmInfo.dimmBankDensity & BIT2) - mvOsOutput("4GB, "); - if (dimmInfo.dimmBankDensity & BIT3) - mvOsOutput("8GB, "); - if (dimmInfo.dimmBankDensity & BIT4) - mvOsOutput("16GB, "); - if (dimmInfo.dimmBankDensity & BIT5) - mvOsOutput("128MB, "); - if (dimmInfo.dimmBankDensity & BIT6) - mvOsOutput("256MB, "); - if (dimmInfo.dimmBankDensity & BIT7) - mvOsOutput("512MB, "); - } - mvOsOutput("\n"); - break; -/*----------------------------------------------------------------------------*/ - - case 32: /* Address And Command Setup Time (measured in ns/1000) */ - if (dimmInfo.memoryType == MEM_TYPE_SDRAM) - { - rightOfPoint = (spdRawData[i] & 0x0f); - leftOfPoint = (spdRawData[i] & 0xf0) >> 4; - if(leftOfPoint > 7) - { - leftOfPoint *= -1; - } - } - else /* DDR1 or DDR2 */ - { - time_tmp = (((spdRawData[i] & 0xf0) >> 4)*10) + - ((spdRawData[i] & 0x0f)); - leftOfPoint = time_tmp / 100; - rightOfPoint = time_tmp % 100; - } - mvOsOutput("Address And Command Setup Time [ns]: %d.%d\n", - leftOfPoint, rightOfPoint); - break; -/*----------------------------------------------------------------------------*/ - - case 33: /* Address And Command Hold Time */ - if (dimmInfo.memoryType == MEM_TYPE_SDRAM) - { - rightOfPoint = (spdRawData[i] & 0x0f); - leftOfPoint = (spdRawData[i] & 0xf0) >> 4; - if(leftOfPoint > 7) - { - leftOfPoint *= -1; - } - } - else /* DDR1 or DDR2 */ - { - time_tmp = (((spdRawData[i] & 0xf0) >> 4)*10) + - ((spdRawData[i] & 0x0f)); - leftOfPoint = time_tmp / 100; - rightOfPoint = time_tmp % 100; - } - mvOsOutput("Address And Command Hold Time [ns]: %d.%d\n", - leftOfPoint, rightOfPoint); - break; -/*----------------------------------------------------------------------------*/ - - case 34: /* Data Input Setup Time */ - if (dimmInfo.memoryType == MEM_TYPE_SDRAM) - { - rightOfPoint = (spdRawData[i] & 0x0f); - leftOfPoint = (spdRawData[i] & 0xf0) >> 4; - if(leftOfPoint > 7) - { - leftOfPoint *= -1; - } - } - else /* DDR1 or DDR2 */ - { - time_tmp = (((spdRawData[i] & 0xf0) >> 4)*10) + - ((spdRawData[i] & 0x0f)); - leftOfPoint = time_tmp / 100; - rightOfPoint = time_tmp % 100; - } - mvOsOutput("Data Input Setup Time [ns]: %d.%d\n", - leftOfPoint, rightOfPoint); - break; -/*----------------------------------------------------------------------------*/ - - case 35: /* Data Input Hold Time */ - if (dimmInfo.memoryType == MEM_TYPE_SDRAM) - { - rightOfPoint = (spdRawData[i] & 0x0f); - leftOfPoint = (spdRawData[i] & 0xf0) >> 4; - if(leftOfPoint > 7) - { - leftOfPoint *= -1; - } - } - else /* DDR1 or DDR2 */ - { - time_tmp = (((spdRawData[i] & 0xf0) >> 4)*10) + - ((spdRawData[i] & 0x0f)); - leftOfPoint = time_tmp / 100; - rightOfPoint = time_tmp % 100; - } - mvOsOutput("Data Input Hold Time [ns]: %d.%d\n\n", - leftOfPoint, rightOfPoint); - break; -/*----------------------------------------------------------------------------*/ - - case 36: /* Relevant for DDR2 only: Write Recovery Time */ - leftOfPoint = ((spdRawData[i] & maskLeftOfPoint) >> 2); - rightOfPoint = (spdRawData[i] & maskRightOfPoint) * 25; - mvOsOutput("Write Recovery Time [ns]: %d.%d\n", - leftOfPoint, rightOfPoint); - break; -/*----------------------------------------------------------------------------*/ - } - -} - - -/* - * translate ns.ns/10 coding of SPD timing values - * into ps unit values - */ -/******************************************************************************* -* cas2ps - Translate x.y ns parameter to pico-seconds values -* -* DESCRIPTION: -* This function translates x.y nano seconds to its value in pico seconds. -* For example 3.75ns will return 3750. -* -* INPUT: -* spd_byte - DIMM SPD byte. -* -* OUTPUT: -* None. -* -* RETURN: -* value in pico seconds. -* -*******************************************************************************/ -static MV_U32 cas2ps(MV_U8 spd_byte) -{ - MV_U32 ns, ns10; - - /* isolate upper nibble */ - ns = (spd_byte >> 4) & 0x0F; - /* isolate lower nibble */ - ns10 = (spd_byte & 0x0F); - - if( ns10 < 10 ) { - ns10 *= 10; - } - else if( ns10 == 10 ) - ns10 = 25; - else if( ns10 == 11 ) - ns10 = 33; - else if( ns10 == 12 ) - ns10 = 66; - else if( ns10 == 13 ) - ns10 = 75; - else - { - mvOsOutput("cas2ps Err. unsupported cycle time.\n"); - } - - return (ns*1000 + ns10*10); -} - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr1_2/mvDram.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr1_2/mvDram.h deleted file mode 100644 index 678e224..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr1_2/mvDram.h +++ /dev/null @@ -1,191 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCmvDram -#define __INCmvDram - -#include "ddr1_2/mvDramIf.h" -#include "twsi/mvTwsi.h" - -#define MAX_DIMM_NUM 2 -#define SPD_SIZE 128 - -/* Dimm spd offsets */ -#define DIMM_MEM_TYPE 2 -#define DIMM_ROW_NUM 3 -#define DIMM_COL_NUM 4 -#define DIMM_MODULE_BANK_NUM 5 -#define DIMM_DATA_WIDTH 6 -#define DIMM_VOLT_IF 8 -#define DIMM_MIN_CC_AT_MAX_CAS 9 -#define DIMM_ERR_CHECK_TYPE 11 -#define DIMM_REFRESH_INTERVAL 12 -#define DIMM_SDRAM_WIDTH 13 -#define DIMM_ERR_CHECK_DATA_WIDTH 14 -#define DIMM_MIN_CLK_DEL 15 -#define DIMM_BURST_LEN_SUP 16 -#define DIMM_DEV_BANK_NUM 17 -#define DIMM_SUP_CAL 18 -#define DIMM_DDR2_TYPE_INFORMATION 20 /* DDR2 only */ -#define DIMM_BUF_ADDR_CONT_IN 21 -#define DIMM_MIN_CC_AT_MAX_CAS_MINUS1 23 -#define DIMM_MIN_CC_AT_MAX_CAS_MINUS2 25 -#define DIMM_MIN_ROW_PRECHARGE_TIME 27 -#define DIMM_MIN_ROW_ACTIVE_TO_ROW_ACTIVE 28 -#define DIMM_MIN_RAS_TO_CAS_DELAY 29 -#define DIMM_MIN_RAS_PULSE_WIDTH 30 -#define DIMM_BANK_DENSITY 31 -#define DIMM_MIN_WRITE_RECOVERY_TIME 36 -#define DIMM_MIN_WRITE_TO_READ_CMD_DELAY 37 -#define DIMM_MIN_READ_TO_PRECH_CMD_DELAY 38 -#define DIMM_MIN_REFRESH_TO_ACTIVATE_CMD 42 - -/* Dimm Memory Type values */ -#define DIMM_MEM_TYPE_SDRAM 0x4 -#define DIMM_MEM_TYPE_DDR1 0x7 -#define DIMM_MEM_TYPE_DDR2 0x8 - -#define DIMM_MODULE_MANU_OFFS 64 -#define DIMM_MODULE_MANU_SIZE 8 -#define DIMM_MODULE_VEN_OFFS 73 -#define DIMM_MODULE_VEN_SIZE 25 -#define DIMM_MODULE_ID_OFFS 99 -#define DIMM_MODULE_ID_SIZE 18 - -/* enumeration for voltage levels. */ -typedef enum _mvDimmVoltageIf -{ - TTL_5V_TOLERANT, - LVTTL, - HSTL_1_5V, - SSTL_3_3V, - SSTL_2_5V, - VOLTAGE_UNKNOWN, -} MV_DIMM_VOLTAGE_IF; - - -/* enumaration for SDRAM CAS Latencies. */ -typedef enum _mvDimmSdramCas -{ - SD_CL_1 =1, - SD_CL_2, - SD_CL_3, - SD_CL_4, - SD_CL_5, - SD_CL_6, - SD_CL_7, - SD_FAULT -}MV_DIMM_SDRAM_CAS; - - -/* DIMM information structure */ -typedef struct _mvDimmInfo -{ - MV_MEMORY_TYPE memoryType; /* DDR or SDRAM */ - - MV_U8 spdRawData[SPD_SIZE]; /* Content of SPD-EEPROM copied 1:1 */ - - /* DIMM dimensions */ - MV_U32 numOfRowAddr; - MV_U32 numOfColAddr; - MV_U32 numOfModuleBanks; - MV_U32 dataWidth; - MV_U32 errorCheckType; /* ECC , PARITY..*/ - MV_U32 sdramWidth; /* 4,8,16 or 32 */ - MV_U32 errorCheckDataWidth; /* 0 - no, 1 - Yes */ - MV_U32 burstLengthSupported; - MV_U32 numOfBanksOnEachDevice; - MV_U32 suportedCasLatencies; - MV_U32 refreshInterval; - MV_U32 dimmBankDensity; - MV_U32 dimmTypeInfo; /* DDR2 only */ - MV_U32 dimmAttributes; - - /* DIMM timing parameters */ - MV_U32 minCycleTimeAtMaxCasLatPs; - MV_U32 minCycleTimeAtMaxCasLatMinus1Ps; - MV_U32 minCycleTimeAtMaxCasLatMinus2Ps; - MV_U32 minRowPrechargeTime; - MV_U32 minRowActiveToRowActive; - MV_U32 minRasToCasDelay; - MV_U32 minRasPulseWidth; - MV_U32 minWriteRecoveryTime; /* DDR2 only */ - MV_U32 minWriteToReadCmdDelay; /* DDR2 only */ - MV_U32 minReadToPrechCmdDelay; /* DDR2 only */ - MV_U32 minRefreshToActiveCmd; /* DDR2 only */ - - /* Parameters calculated from the extracted DIMM information */ - MV_U32 size; /* 16,64,128,256 or 512 MByte in MB units */ - MV_U32 deviceDensity; /* 16,64,128,256 or 512 Mbit in MB units */ - MV_U32 numberOfDevices; - -} MV_DIMM_INFO; - - -MV_STATUS mvDramBankInfoGet(MV_U32 bankNum, MV_DRAM_BANK_INFO *pBankInfo); -MV_STATUS dimmSpdGet(MV_U32 dimmNum, MV_DIMM_INFO *pDimmInfo); -MV_VOID dimmSpdPrint(MV_U32 dimmNum); -MV_STATUS dimmSpdCpy(MV_VOID); - -#endif /* __INCmvDram */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr1_2/mvDramIf.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr1_2/mvDramIf.c deleted file mode 100644 index 12fb26a..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr1_2/mvDramIf.c +++ /dev/null @@ -1,1599 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -/* includes */ -#include "ddr1_2/mvDramIf.h" -#include "ctrlEnv/sys/mvCpuIf.h" - - - -#ifdef MV_DEBUG -#define DB(x) x -#else -#define DB(x) -#endif - -/* DRAM bank presence encoding */ -#define BANK_PRESENT_CS0 0x1 -#define BANK_PRESENT_CS0_CS1 0x3 -#define BANK_PRESENT_CS0_CS2 0x5 -#define BANK_PRESENT_CS0_CS1_CS2 0x7 -#define BANK_PRESENT_CS0_CS2_CS3 0xd -#define BANK_PRESENT_CS0_CS2_CS3_CS4 0xf - -/* locals */ -static MV_BOOL sdramIfWinOverlap(MV_TARGET target, MV_ADDR_WIN *pAddrWin); -#if defined(MV_INC_BOARD_DDIM) -static void sdramDDr2OdtConfig(MV_DRAM_BANK_INFO *pBankInfo); -static MV_U32 dunitCtrlLowRegCalc(MV_DRAM_BANK_INFO *pBankInfo, MV_U32 minCas); -static MV_U32 sdramModeRegCalc(MV_U32 minCas); -static MV_U32 sdramExtModeRegCalc(MV_DRAM_BANK_INFO *pBankInfo); -static MV_U32 sdramAddrCtrlRegCalc(MV_DRAM_BANK_INFO *pBankInfo); -static MV_U32 sdramConfigRegCalc(MV_DRAM_BANK_INFO *pBankInfo, MV_U32 busClk); -static MV_U32 minCasCalc(MV_DRAM_BANK_INFO *pBankInfo, MV_U32 busClk, - MV_U32 forcedCl); -static MV_U32 sdramTimeCtrlLowRegCalc(MV_DRAM_BANK_INFO *pBankInfo, - MV_U32 minCas, MV_U32 busClk); -static MV_U32 sdramTimeCtrlHighRegCalc(MV_DRAM_BANK_INFO *pBankInfo, - MV_U32 busClk); - -/******************************************************************************* -* mvDramIfDetect - Prepare DRAM interface configuration values. -* -* DESCRIPTION: -* This function implements the full DRAM detection and timing -* configuration for best system performance. -* Since this routine runs from a ROM device (Boot Flash), its stack -* resides on RAM, that might be the system DRAM. Changing DRAM -* configuration values while keeping vital data in DRAM is risky. That -* is why the function does not preform the configuration setting but -* prepare those in predefined 32bit registers (in this case IDMA -* registers are used) for other routine to perform the settings. -* The function will call for board DRAM SPD information for each DRAM -* chip select. The function will then analyze those SPD parameters of -* all DRAM banks in order to decide on DRAM configuration compatible -* for all DRAM banks. -* The function will set the CPU DRAM address decode registers. -* Note: This routine prepares values that will overide configuration of -* mvDramBasicAsmInit(). -* -* INPUT: -* forcedCl - Forced CAL Latency. If equal to zero, do not force. -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_STATUS mvDramIfDetect(MV_U32 forcedCl) -{ - MV_U32 retVal = MV_OK; /* return value */ - MV_DRAM_BANK_INFO bankInfo[MV_DRAM_MAX_CS]; - MV_U32 busClk, size, base = 0, i, temp, deviceW, dimmW; - MV_U8 minCas; - MV_DRAM_DEC_WIN dramDecWin; - - dramDecWin.addrWin.baseHigh = 0; - - busClk = mvBoardSysClkGet(); - - if (0 == busClk) - { - mvOsPrintf("Dram: ERR. Can't detect system clock! \n"); - return MV_ERROR; - } - - /* Close DRAM banks except bank 0 (in case code is excecuting from it...) */ -#if defined(MV_INCLUDE_SDRAM_CS1) - for(i= SDRAM_CS1; i < MV_DRAM_MAX_CS; i++) - mvCpuIfTargetWinEnable(i, MV_FALSE); -#endif - - /* we will use bank 0 as the representative of the all the DRAM banks, */ - /* since bank 0 must exist. */ - for(i = 0; i < MV_DRAM_MAX_CS; i++) - { - /* if Bank exist */ - if(MV_OK == mvDramBankInfoGet(i, &bankInfo[i])) - { - /* check it isn't SDRAM */ - if(bankInfo[i].memoryType == MEM_TYPE_SDRAM) - { - mvOsPrintf("Dram: ERR. SDRAM type not supported !!!\n"); - return MV_ERROR; - } - /* All banks must support registry in order to activate it */ - if(bankInfo[i].registeredAddrAndControlInputs != - bankInfo[0].registeredAddrAndControlInputs) - { - mvOsPrintf("Dram: ERR. different Registered settings !!!\n"); - return MV_ERROR; - } - - /* Init the CPU window decode */ - /* Note that the size in Bank info is in MB units */ - /* Note that the Dimm width might be different then the device DRAM width */ - temp = MV_REG_READ(SDRAM_CONFIG_REG); - - deviceW = ((temp & SDRAM_DWIDTH_MASK) == SDRAM_DWIDTH_16BIT )? 16 : 32; - dimmW = bankInfo[0].dataWidth - (bankInfo[0].dataWidth % 16); - size = ((bankInfo[i].size << 20) / (dimmW/deviceW)); - - /* We can not change DRAM window settings while excecuting */ - /* code from it. That is why we skip the DRAM CS[0], saving */ - /* it to the ROM configuration routine */ - if(i == SDRAM_CS0) - { - MV_U32 sizeToReg; - - /* Translate the given window size to register format */ - sizeToReg = ctrlSizeToReg(size, SCSR_SIZE_ALIGNMENT); - - /* Size parameter validity check. */ - if (-1 == sizeToReg) - { - mvOsPrintf("mvCtrlAddrDecToReg: ERR. Win %d size invalid.\n" - ,i); - return MV_BAD_PARAM; - } - - /* Size is located at upper 16 bits */ - sizeToReg <<= SCSR_SIZE_OFFS; - - /* enable it */ - sizeToReg |= SCSR_WIN_EN; - - MV_REG_WRITE(DRAM_BUF_REG0, sizeToReg); - } - else - { - dramDecWin.addrWin.baseLow = base; - dramDecWin.addrWin.size = size; - dramDecWin.enable = MV_TRUE; - - if (MV_OK != mvDramIfWinSet(SDRAM_CS0 + i, &dramDecWin)) - { - mvOsPrintf("Dram: ERR. Fail to set bank %d!!!\n", - SDRAM_CS0 + i); - return MV_ERROR; - } - } - - base += size; - - /* update the suportedCasLatencies mask */ - bankInfo[0].suportedCasLatencies &= bankInfo[i].suportedCasLatencies; - - } - else - { - if( i == 0 ) /* bank 0 doesn't exist */ - { - mvOsPrintf("Dram: ERR. Fail to detect bank 0 !!!\n"); - return MV_ERROR; - } - else - { - DB(mvOsPrintf("Dram: Could not find bank %d\n", i)); - bankInfo[i].size = 0; /* Mark this bank as non exist */ - } - } - } - - /* calculate minimum CAS */ - minCas = minCasCalc(&bankInfo[0], busClk, forcedCl); - if (0 == minCas) - { - mvOsOutput("Dram: Warn: Could not find CAS compatible to SysClk %dMhz\n", - (busClk / 1000000)); - - if (MV_REG_READ(SDRAM_CONFIG_REG) & SDRAM_DTYPE_DDR2) - { - minCas = DDR2_CL_4; /* Continue with this CAS */ - mvOsPrintf("Set default CAS latency 4\n"); - } - else - { - minCas = DDR1_CL_3; /* Continue with this CAS */ - mvOsPrintf("Set default CAS latency 3\n"); - } - } - - /* calc SDRAM_CONFIG_REG and save it to temp register */ - temp = sdramConfigRegCalc(&bankInfo[0], busClk); - if(-1 == temp) - { - mvOsPrintf("Dram: ERR. sdramConfigRegCalc failed !!!\n"); - return MV_ERROR; - } - MV_REG_WRITE(DRAM_BUF_REG1, temp); - - /* calc SDRAM_MODE_REG and save it to temp register */ - temp = sdramModeRegCalc(minCas); - if(-1 == temp) - { - mvOsPrintf("Dram: ERR. sdramModeRegCalc failed !!!\n"); - return MV_ERROR; - } - MV_REG_WRITE(DRAM_BUF_REG2, temp); - - /* calc SDRAM_EXTENDED_MODE_REG and save it to temp register */ - temp = sdramExtModeRegCalc(&bankInfo[0]); - if(-1 == temp) - { - mvOsPrintf("Dram: ERR. sdramModeRegCalc failed !!!\n"); - return MV_ERROR; - } - MV_REG_WRITE(DRAM_BUF_REG10, temp); - - /* calc D_UNIT_CONTROL_LOW and save it to temp register */ - temp = dunitCtrlLowRegCalc(&bankInfo[0], minCas); - if(-1 == temp) - { - mvOsPrintf("Dram: ERR. dunitCtrlLowRegCalc failed !!!\n"); - return MV_ERROR; - } - MV_REG_WRITE(DRAM_BUF_REG3, temp); - - /* calc SDRAM_ADDR_CTRL_REG and save it to temp register */ - temp = sdramAddrCtrlRegCalc(&bankInfo[0]); - if(-1 == temp) - { - mvOsPrintf("Dram: ERR. sdramAddrCtrlRegCalc failed !!!\n"); - return MV_ERROR; - } - MV_REG_WRITE(DRAM_BUF_REG4, temp); - - /* calc SDRAM_TIMING_CTRL_LOW_REG and save it to temp register */ - temp = sdramTimeCtrlLowRegCalc(&bankInfo[0], minCas, busClk); - if(-1 == temp) - { - mvOsPrintf("Dram: ERR. sdramTimeCtrlLowRegCalc failed !!!\n"); - return MV_ERROR; - } - MV_REG_WRITE(DRAM_BUF_REG5, temp); - - /* calc SDRAM_TIMING_CTRL_HIGH_REG and save it to temp register */ - temp = sdramTimeCtrlHighRegCalc(&bankInfo[0], busClk); - if(-1 == temp) - { - mvOsPrintf("Dram: ERR. sdramTimeCtrlHighRegCalc failed !!!\n"); - return MV_ERROR; - } - MV_REG_WRITE(DRAM_BUF_REG6, temp); - - /* Config DDR2 On Die Termination (ODT) registers */ - if (MV_REG_READ(SDRAM_CONFIG_REG) & SDRAM_DTYPE_DDR2) - { - sdramDDr2OdtConfig(bankInfo); - } - - /* Note that DDR SDRAM Address/Control and Data pad calibration */ - /* settings is done in mvSdramIfConfig.s */ - - return retVal; -} - -/******************************************************************************* -* minCasCalc - Calculate the Minimum CAS latency which can be used. -* -* DESCRIPTION: -* Calculate the minimum CAS latency that can be used, base on the DRAM -* parameters and the SDRAM bus Clock freq. -* -* INPUT: -* busClk - the DRAM bus Clock. -* pBankInfo - bank info parameters. -* -* OUTPUT: -* None -* -* RETURN: -* The minimum CAS Latency. The function returns 0 if max CAS latency -* supported by banks is incompatible with system bus clock frequancy. -* -*******************************************************************************/ -static MV_U32 minCasCalc(MV_DRAM_BANK_INFO *pBankInfo, MV_U32 busClk, - MV_U32 forcedCl) -{ - MV_U32 count = 1, j; - MV_U32 busClkPs = 1000000000 / (busClk / 1000); /* in ps units */ - MV_U32 startBit, stopBit; - - /* DDR 1: - *******-******-******-******-******-******-******-******* - * bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 * - *******-******-******-******-******-******-******-******* - CAS = * TBD | 4 | 3.5 | 3 | 2.5 | 2 | 1.5 | 1 * - *********************************************************/ - - /* DDR 2: - *******-******-******-******-******-******-******-******* - * bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 * - *******-******-******-******-******-******-******-******* - CAS = * TBD | TBD | 5 | 4 | 3 | 2 | TBD | TBD * - *********************************************************/ - - - /* If we are asked to use the forced CAL */ - if (forcedCl) - { - mvOsPrintf("DRAM: Using forced CL %d.%d\n", (forcedCl / 10), - (forcedCl % 10)); - - if (MV_REG_READ(SDRAM_CONFIG_REG) & SDRAM_DTYPE_DDR2) - { - if (forcedCl == 30) - pBankInfo->suportedCasLatencies = 0x08; - else if (forcedCl == 40) - pBankInfo->suportedCasLatencies = 0x10; - else - { - mvOsPrintf("Forced CL %d.%d not supported. Set default CL 4\n", - (forcedCl / 10), (forcedCl % 10)); - pBankInfo->suportedCasLatencies = 0x10; - } - } - else - { - if (forcedCl == 15) - pBankInfo->suportedCasLatencies = 0x02; - else if (forcedCl == 20) - pBankInfo->suportedCasLatencies = 0x04; - else if (forcedCl == 25) - pBankInfo->suportedCasLatencies = 0x08; - else if (forcedCl == 30) - pBankInfo->suportedCasLatencies = 0x10; - else if (forcedCl == 40) - pBankInfo->suportedCasLatencies = 0x40; - else - { - mvOsPrintf("Forced CL %d.%d not supported. Set default CL 3\n", - (forcedCl / 10), (forcedCl % 10)); - pBankInfo->suportedCasLatencies = 0x10; - } - } - - return pBankInfo->suportedCasLatencies; - } - - /* go over the supported cas mask from Max Cas down and check if the */ - /* SysClk stands in its time requirments. */ - - - DB(mvOsPrintf("Dram: minCasCalc supported mask = %x busClkPs = %x \n", - pBankInfo->suportedCasLatencies,busClkPs )); - for(j = 7; j > 0; j--) - { - if((pBankInfo->suportedCasLatencies >> j) & BIT0 ) - { - /* Reset the bits for CL incompatible for the sysClk */ - switch (count) - { - case 1: - if (pBankInfo->minCycleTimeAtMaxCasLatPs > busClkPs) - pBankInfo->suportedCasLatencies &= ~(BIT0 << j); - count++; - break; - case 2: - if (pBankInfo->minCycleTimeAtMaxCasLatMinus1Ps > busClkPs) - pBankInfo->suportedCasLatencies &= ~(BIT0 << j); - count++; - break; - case 3: - if (pBankInfo->minCycleTimeAtMaxCasLatMinus2Ps > busClkPs) - pBankInfo->suportedCasLatencies &= ~(BIT0 << j); - count++; - break; - default: - pBankInfo->suportedCasLatencies &= ~(BIT0 << j); - break; - } - } - } - - DB(mvOsPrintf("Dram: minCasCalc support = %x (after SysCC calc)\n", - pBankInfo->suportedCasLatencies )); - - /* SDRAM DDR1 controller supports CL 1.5 to 3.5 */ - /* SDRAM DDR2 controller supports CL 3 to 5 */ - if (MV_REG_READ(SDRAM_CONFIG_REG) & SDRAM_DTYPE_DDR2) - { - startBit = 3; /* DDR2 support CL start with CL3 (bit 3) */ - stopBit = 5; /* DDR2 support CL stops with CL5 (bit 5) */ - } - else - { - startBit = 1; /* DDR1 support CL start with CL1.5 (bit 3) */ - stopBit = 4; /* DDR1 support CL stops with CL3 (bit 4) */ - } - - for(j = startBit; j <= stopBit ; j++) - { - if((pBankInfo->suportedCasLatencies >> j) & BIT0 ) - { - DB(mvOsPrintf("Dram: minCasCalc choose CAS %x \n",(BIT0 << j))); - return (BIT0 << j); - } - } - - return 0; -} - -/******************************************************************************* -* sdramConfigRegCalc - Calculate sdram config register -* -* DESCRIPTION: Calculate sdram config register optimized value based -* on the bank info parameters. -* -* INPUT: -* pBankInfo - sdram bank parameters -* -* OUTPUT: -* None -* -* RETURN: -* sdram config reg value. -* -*******************************************************************************/ -static MV_U32 sdramConfigRegCalc(MV_DRAM_BANK_INFO *pBankInfo, MV_U32 busClk) -{ - MV_U32 sdramConfig = 0; - MV_U32 refreshPeriod; - - busClk /= 1000000; /* we work with busClk in MHz */ - - sdramConfig = MV_REG_READ(SDRAM_CONFIG_REG); - - /* figure out the memory refresh internal */ - switch (pBankInfo->refreshInterval & 0xf) - { - case 0x0: /* refresh period is 15.625 usec */ - refreshPeriod = 15625; - break; - case 0x1: /* refresh period is 3.9 usec */ - refreshPeriod = 3900; - break; - case 0x2: /* refresh period is 7.8 usec */ - refreshPeriod = 7800; - break; - case 0x3: /* refresh period is 31.3 usec */ - refreshPeriod = 31300; - break; - case 0x4: /* refresh period is 62.5 usec */ - refreshPeriod = 62500; - break; - case 0x5: /* refresh period is 125 usec */ - refreshPeriod = 125000; - break; - default: /* refresh period undefined */ - mvOsPrintf("Dram: ERR. DRAM refresh period is unknown!\n"); - return -1; - } - - /* Now the refreshPeriod is in register format value */ - refreshPeriod = (busClk * refreshPeriod) / 1000; - - DB(mvOsPrintf("Dram: sdramConfigRegCalc calculated refresh interval %0x\n", - refreshPeriod)); - - /* make sure the refresh value is only 14 bits */ - if(refreshPeriod > SDRAM_REFRESH_MAX) - { - refreshPeriod = SDRAM_REFRESH_MAX; - DB(mvOsPrintf("Dram: sdramConfigRegCalc adjusted refresh interval %0x\n", - refreshPeriod)); - } - - /* Clear the refresh field */ - sdramConfig &= ~SDRAM_REFRESH_MASK; - - /* Set new value to refresh field */ - sdramConfig |= (refreshPeriod & SDRAM_REFRESH_MASK); - - /* registered DRAM ? */ - if ( pBankInfo->registeredAddrAndControlInputs ) - { - /* it's registered DRAM, so set the reg. DRAM bit */ - sdramConfig |= SDRAM_REGISTERED; - mvOsPrintf("DRAM Attribute: Registered address and control inputs.\n"); - } - - /* set DDR SDRAM devices configuration */ - sdramConfig &= ~SDRAM_DCFG_MASK; /* Clear Dcfg field */ - - switch (pBankInfo->sdramWidth) - { - case 8: /* memory is x8 */ - sdramConfig |= SDRAM_DCFG_X8_DEV; - DB(mvOsPrintf("Dram: sdramConfigRegCalc SDRAM device width x8\n")); - break; - case 16: - sdramConfig |= SDRAM_DCFG_X16_DEV; - DB(mvOsPrintf("Dram: sdramConfigRegCalc SDRAM device width x16\n")); - break; - default: /* memory width unsupported */ - mvOsPrintf("Dram: ERR. DRAM chip width is unknown!\n"); - return -1; - } - - /* Set static default settings */ - sdramConfig |= SDRAM_CONFIG_DV; - - DB(mvOsPrintf("Dram: sdramConfigRegCalc set sdramConfig to 0x%x\n", - sdramConfig)); - - return sdramConfig; -} - -/******************************************************************************* -* sdramModeRegCalc - Calculate sdram mode register -* -* DESCRIPTION: Calculate sdram mode register optimized value based -* on the bank info parameters and the minCas. -* -* INPUT: -* minCas - minimum CAS supported. -* -* OUTPUT: -* None -* -* RETURN: -* sdram mode reg value. -* -*******************************************************************************/ -static MV_U32 sdramModeRegCalc(MV_U32 minCas) -{ - MV_U32 sdramMode; - - sdramMode = MV_REG_READ(SDRAM_MODE_REG); - - /* Clear CAS Latency field */ - sdramMode &= ~SDRAM_CL_MASK; - - mvOsPrintf("DRAM CAS Latency "); - - if (MV_REG_READ(SDRAM_CONFIG_REG) & SDRAM_DTYPE_DDR2) - { - switch (minCas) - { - case DDR2_CL_3: - sdramMode |= SDRAM_DDR2_CL_3; - mvOsPrintf("3.\n"); - break; - case DDR2_CL_4: - sdramMode |= SDRAM_DDR2_CL_4; - mvOsPrintf("4.\n"); - break; - case DDR2_CL_5: - sdramMode |= SDRAM_DDR2_CL_5; - mvOsPrintf("5.\n"); - break; - default: - mvOsPrintf("\nsdramModeRegCalc ERROR: Max. CL out of range\n"); - return -1; - } - sdramMode |= DDR2_MODE_REG_DV; - } - else /* DDR1 */ - { - switch (minCas) - { - case DDR1_CL_1_5: - sdramMode |= SDRAM_DDR1_CL_1_5; - mvOsPrintf("1.5\n"); - break; - case DDR1_CL_2: - sdramMode |= SDRAM_DDR1_CL_2; - mvOsPrintf("2\n"); - break; - case DDR1_CL_2_5: - sdramMode |= SDRAM_DDR1_CL_2_5; - mvOsPrintf("2.5\n"); - break; - case DDR1_CL_3: - sdramMode |= SDRAM_DDR1_CL_3; - mvOsPrintf("3\n"); - break; - case DDR1_CL_4: - sdramMode |= SDRAM_DDR1_CL_4; - mvOsPrintf("4\n"); - break; - default: - mvOsPrintf("\nsdramModeRegCalc ERROR: Max. CL out of range\n"); - return -1; - } - sdramMode |= DDR1_MODE_REG_DV; - } - - DB(mvOsPrintf("nsdramModeRegCalc register 0x%x\n", sdramMode )); - - return sdramMode; -} - -/******************************************************************************* -* sdramExtModeRegCalc - Calculate sdram Extended mode register -* -* DESCRIPTION: -* Return sdram Extended mode register value based -* on the bank info parameters and bank presence. -* -* INPUT: -* pBankInfo - sdram bank parameters -* -* OUTPUT: -* None -* -* RETURN: -* sdram Extended mode reg value. -* -*******************************************************************************/ -static MV_U32 sdramExtModeRegCalc(MV_DRAM_BANK_INFO *pBankInfo) -{ - MV_U32 populateBanks = 0; - int bankNum; - if (MV_REG_READ(SDRAM_CONFIG_REG) & SDRAM_DTYPE_DDR2) - { - /* Represent the populate banks in binary form */ - for(bankNum = 0; bankNum < MV_DRAM_MAX_CS; bankNum++) - { - if (0 != pBankInfo[bankNum].size) - { - populateBanks |= (1 << bankNum); - } - } - - switch(populateBanks) - { - case(BANK_PRESENT_CS0): - return DDR_SDRAM_EXT_MODE_CS0_DV; - - case(BANK_PRESENT_CS0_CS1): - return DDR_SDRAM_EXT_MODE_CS0_DV; - - case(BANK_PRESENT_CS0_CS2): - return DDR_SDRAM_EXT_MODE_CS0_CS2_DV; - - case(BANK_PRESENT_CS0_CS1_CS2): - return DDR_SDRAM_EXT_MODE_CS0_CS2_DV; - - case(BANK_PRESENT_CS0_CS2_CS3): - return DDR_SDRAM_EXT_MODE_CS0_CS2_DV; - - case(BANK_PRESENT_CS0_CS2_CS3_CS4): - return DDR_SDRAM_EXT_MODE_CS0_CS2_DV; - - default: - mvOsPrintf("sdramExtModeRegCalc: Invalid DRAM bank presence\n"); - return -1; - } - } - return 0; -} - -/******************************************************************************* -* dunitCtrlLowRegCalc - Calculate sdram dunit control low register -* -* DESCRIPTION: Calculate sdram dunit control low register optimized value based -* on the bank info parameters and the minCas. -* -* INPUT: -* pBankInfo - sdram bank parameters -* minCas - minimum CAS supported. -* -* OUTPUT: -* None -* -* RETURN: -* sdram dunit control low reg value. -* -*******************************************************************************/ -static MV_U32 dunitCtrlLowRegCalc(MV_DRAM_BANK_INFO *pBankInfo, MV_U32 minCas) -{ - MV_U32 dunitCtrlLow; - - dunitCtrlLow = MV_REG_READ(SDRAM_DUNIT_CTRL_REG); - - /* Clear StBurstDel field */ - dunitCtrlLow &= ~SDRAM_ST_BURST_DEL_MASK; - -#ifdef MV_88W8660 - /* Clear address/control output timing field */ - dunitCtrlLow &= ~SDRAM_CTRL_POS_RISE; -#endif /* MV_88W8660 */ - - DB(mvOsPrintf("Dram: dunitCtrlLowRegCalc\n")); - - /* For proper sample of read data set the Dunit Control register's */ - /* stBurstDel bits [27:24] */ - /********-********-********-********-********-********* - * CL=1.5 | CL=2 | CL=2.5 | CL=3 | CL=4 | CL=5 * - *********-********-********-********-********-********* -Not Reg. * 0011 | 0011 | 0100 | 0100 | 0101 | TBD * - *********-********-********-********-********-********* -Registered * 0100 | 0100 | 0101 | 0101 | 0110 | TBD * - *********-********-********-********-********-*********/ - - if (MV_REG_READ(SDRAM_CONFIG_REG) & SDRAM_DTYPE_DDR2) - { - switch (minCas) - { - case DDR2_CL_3: - /* registerd DDR SDRAM? */ - if (pBankInfo->registeredAddrAndControlInputs == MV_TRUE) - dunitCtrlLow |= 0x5 << SDRAM_ST_BURST_DEL_OFFS; - else - dunitCtrlLow |= 0x4 << SDRAM_ST_BURST_DEL_OFFS; - break; - case DDR2_CL_4: - /* registerd DDR SDRAM? */ - if (pBankInfo->registeredAddrAndControlInputs == MV_TRUE) - dunitCtrlLow |= 0x6 << SDRAM_ST_BURST_DEL_OFFS; - else - dunitCtrlLow |= 0x5 << SDRAM_ST_BURST_DEL_OFFS; - break; - default: - mvOsPrintf("Dram: dunitCtrlLowRegCalc Max. CL out of range %d\n", - minCas); - return -1; - } - } - else /* DDR1 */ - { - switch (minCas) - { - case DDR1_CL_1_5: - /* registerd DDR SDRAM? */ - if (pBankInfo->registeredAddrAndControlInputs == MV_TRUE) - dunitCtrlLow |= 0x4 << SDRAM_ST_BURST_DEL_OFFS; - else - dunitCtrlLow |= 0x3 << SDRAM_ST_BURST_DEL_OFFS; - break; - case DDR1_CL_2: - /* registerd DDR SDRAM? */ - if (pBankInfo->registeredAddrAndControlInputs == MV_TRUE) - dunitCtrlLow |= 0x4 << SDRAM_ST_BURST_DEL_OFFS; - else - dunitCtrlLow |= 0x3 << SDRAM_ST_BURST_DEL_OFFS; - break; - case DDR1_CL_2_5: - /* registerd DDR SDRAM? */ - if (pBankInfo->registeredAddrAndControlInputs == MV_TRUE) - dunitCtrlLow |= 0x5 << SDRAM_ST_BURST_DEL_OFFS; - else - dunitCtrlLow |= 0x4 << SDRAM_ST_BURST_DEL_OFFS; - break; - case DDR1_CL_3: - /* registerd DDR SDRAM? */ - if (pBankInfo->registeredAddrAndControlInputs == MV_TRUE) - dunitCtrlLow |= 0x5 << SDRAM_ST_BURST_DEL_OFFS; - else - dunitCtrlLow |= 0x4 << SDRAM_ST_BURST_DEL_OFFS; - break; - case DDR1_CL_4: - /* registerd DDR SDRAM? */ - if (pBankInfo->registeredAddrAndControlInputs == MV_TRUE) - dunitCtrlLow |= 0x6 << SDRAM_ST_BURST_DEL_OFFS; - else - dunitCtrlLow |= 0x5 << SDRAM_ST_BURST_DEL_OFFS; - break; - default: - mvOsPrintf("Dram: dunitCtrlLowRegCalc Max. CL out of range %d\n", - minCas); - return -1; - } - - } - DB(mvOsPrintf("Dram: Reg dunit control low = %x\n", dunitCtrlLow )); - - return dunitCtrlLow; -} - -/******************************************************************************* -* sdramAddrCtrlRegCalc - Calculate sdram address control register -* -* DESCRIPTION: Calculate sdram address control register optimized value based -* on the bank info parameters and the minCas. -* -* INPUT: -* pBankInfo - sdram bank parameters -* -* OUTPUT: -* None -* -* RETURN: -* sdram address control reg value. -* -*******************************************************************************/ -static MV_U32 sdramAddrCtrlRegCalc(MV_DRAM_BANK_INFO *pBankInfo) -{ - MV_U32 addrCtrl = 0; - - /* Set Address Control register static configuration bits */ - addrCtrl = MV_REG_READ(SDRAM_ADDR_CTRL_REG); - - /* Set address control default value */ - addrCtrl |= SDRAM_ADDR_CTRL_DV; - - /* Clear DSize field */ - addrCtrl &= ~SDRAM_DSIZE_MASK; - - /* Note that density is in MB units */ - switch (pBankInfo->deviceDensity) - { - case 128: /* 128 Mbit */ - DB(mvOsPrintf("DRAM Device Density 128Mbit\n")); - addrCtrl |= SDRAM_DSIZE_128Mb; - break; - case 256: /* 256 Mbit */ - DB(mvOsPrintf("DRAM Device Density 256Mbit\n")); - addrCtrl |= SDRAM_DSIZE_256Mb; - break; - case 512: /* 512 Mbit */ - DB(mvOsPrintf("DRAM Device Density 512Mbit\n")); - addrCtrl |= SDRAM_DSIZE_512Mb; - break; - default: - mvOsPrintf("Dram: sdramAddrCtrl unsupported RAM-Device size %d\n", - pBankInfo->deviceDensity); - return -1; - } - - /* SDRAM address control */ - DB(mvOsPrintf("Dram: setting sdram address control with: %x \n", addrCtrl)); - - return addrCtrl; -} - -/******************************************************************************* -* sdramTimeCtrlLowRegCalc - Calculate sdram timing control low register -* -* DESCRIPTION: -* This function calculates sdram timing control low register -* optimized value based on the bank info parameters and the minCas. -* -* INPUT: -* pBankInfo - sdram bank parameters -* busClk - Bus clock -* -* OUTPUT: -* None -* -* RETURN: -* sdram timinf control low reg value. -* -*******************************************************************************/ -static MV_U32 sdramTimeCtrlLowRegCalc(MV_DRAM_BANK_INFO *pBankInfo, - MV_U32 minCas, MV_U32 busClk) -{ - MV_U32 tRp = 0; - MV_U32 tRrd = 0; - MV_U32 tRcd = 0; - MV_U32 tRas = 0; - MV_U32 tWr = 0; - MV_U32 tWtr = 0; - MV_U32 tRtp = 0; - - MV_U32 bankNum; - - busClk = busClk / 1000000; /* In MHz */ - - /* Scan all DRAM banks to find maximum timing values */ - for (bankNum = 0; bankNum < MV_DRAM_MAX_CS; bankNum++) - { - tRp = MV_MAX(tRp, pBankInfo[bankNum].minRowPrechargeTime); - tRrd = MV_MAX(tRrd, pBankInfo[bankNum].minRowActiveToRowActive); - tRcd = MV_MAX(tRcd, pBankInfo[bankNum].minRasToCasDelay); - tRas = MV_MAX(tRas, pBankInfo[bankNum].minRasPulseWidth); - } - - /* Extract timing (in ns) from SPD value. We ignore the tenth ns part. */ - /* by shifting the data two bits right. */ - tRp = tRp >> 2; /* For example 0x50 -> 20ns */ - tRrd = tRrd >> 2; - tRcd = tRcd >> 2; - - /* Extract clock cycles from time parameter. We need to round up */ - tRp = ((busClk * tRp) / 1000) + (((busClk * tRp) % 1000) ? 1 : 0); - /* Micron work around for 133MHz */ - if (busClk == 133) - tRp += 1; - DB(mvOsPrintf("Dram Timing Low: tRp = %d ", tRp)); - tRrd = ((busClk * tRrd) / 1000) + (((busClk * tRrd) % 1000) ? 1 : 0); - /* JEDEC min reqeirments tRrd = 2 */ - if (tRrd < 2) - tRrd = 2; - DB(mvOsPrintf("tRrd = %d ", tRrd)); - tRcd = ((busClk * tRcd) / 1000) + (((busClk * tRcd) % 1000) ? 1 : 0); - DB(mvOsPrintf("tRcd = %d ", tRcd)); - tRas = ((busClk * tRas) / 1000) + (((busClk * tRas) % 1000) ? 1 : 0); - DB(mvOsPrintf("tRas = %d ", tRas)); - - /* tWr and tWtr is different for DDR1 and DDR2. tRtp is only for DDR2 */ - if (MV_REG_READ(SDRAM_CONFIG_REG) & SDRAM_DTYPE_DDR2) - { - /* Scan all DRAM banks to find maximum timing values */ - for (bankNum = 0; bankNum < MV_DRAM_MAX_CS; bankNum++) - { - tWr = MV_MAX(tWr, pBankInfo[bankNum].minWriteRecoveryTime); - tWtr = MV_MAX(tWtr, pBankInfo[bankNum].minWriteToReadCmdDelay); - tRtp = MV_MAX(tRtp, pBankInfo[bankNum].minReadToPrechCmdDelay); - } - - /* Extract timing (in ns) from SPD value. We ignore the tenth ns */ - /* part by shifting the data two bits right. */ - tWr = tWr >> 2; /* For example 0x50 -> 20ns */ - tWtr = tWtr >> 2; - tRtp = tRtp >> 2; - - /* Extract clock cycles from time parameter. We need to round up */ - tWr = ((busClk * tWr) / 1000) + (((busClk * tWr) % 1000) ? 1 : 0); - DB(mvOsPrintf("tWr = %d ", tWr)); - tWtr = ((busClk * tWtr) / 1000) + (((busClk * tWtr) % 1000) ? 1 : 0); - /* JEDEC min reqeirments tWtr = 2 */ - if (tWtr < 2) - tWtr = 2; - DB(mvOsPrintf("tWtr = %d ", tWtr)); - tRtp = ((busClk * tRtp) / 1000) + (((busClk * tRtp) % 1000) ? 1 : 0); - /* JEDEC min reqeirments tRtp = 2 */ - if (tRtp < 2) - tRtp = 2; - DB(mvOsPrintf("tRtp = %d ", tRtp)); - } - else - { - tWr = ((busClk*SDRAM_TWR) / 1000) + (((busClk*SDRAM_TWR) % 1000)?1:0); - - if ((200 == busClk) || ((100 == busClk) && (DDR1_CL_1_5 == minCas))) - { - tWtr = 2; - } - else - { - tWtr = 1; - } - - tRtp = 2; /* Must be set to 0x1 (two cycles) when using DDR1 */ - } - - DB(mvOsPrintf("tWtr = %d\n", tWtr)); - - /* Note: value of 0 in register means one cycle, 1 means two and so on */ - return (((tRp - 1) << SDRAM_TRP_OFFS) | - ((tRrd - 1) << SDRAM_TRRD_OFFS) | - ((tRcd - 1) << SDRAM_TRCD_OFFS) | - ((tRas - 1) << SDRAM_TRAS_OFFS) | - ((tWr - 1) << SDRAM_TWR_OFFS) | - ((tWtr - 1) << SDRAM_TWTR_OFFS) | - ((tRtp - 1) << SDRAM_TRTP_OFFS)); -} - -/******************************************************************************* -* sdramTimeCtrlHighRegCalc - Calculate sdram timing control high register -* -* DESCRIPTION: -* This function calculates sdram timing control high register -* optimized value based on the bank info parameters and the bus clock. -* -* INPUT: -* pBankInfo - sdram bank parameters -* busClk - Bus clock -* -* OUTPUT: -* None -* -* RETURN: -* sdram timinf control high reg value. -* -*******************************************************************************/ -static MV_U32 sdramTimeCtrlHighRegCalc(MV_DRAM_BANK_INFO *pBankInfo, - MV_U32 busClk) -{ - MV_U32 tRfc; - MV_U32 timeNs = 0; - int bankNum; - MV_U32 sdramTw2wCyc = 0; - - busClk = busClk / 1000000; /* In MHz */ - - /* tRfc is different for DDR1 and DDR2. */ - if (MV_REG_READ(SDRAM_CONFIG_REG) & SDRAM_DTYPE_DDR2) - { - MV_U32 bankNum; - - /* Scan all DRAM banks to find maximum timing values */ - for (bankNum = 0; bankNum < MV_DRAM_MAX_CS; bankNum++) - timeNs = MV_MAX(timeNs, pBankInfo[bankNum].minRefreshToActiveCmd); - } - else - { - if (pBankInfo[0].deviceDensity == _1G) - { - timeNs = SDRAM_TRFC_1G; - } - else - { - if (200 == busClk) - { - timeNs = SDRAM_TRFC_64_512M_AT_200MHZ; - } - else - { - timeNs = SDRAM_TRFC_64_512M; - } - } - } - - tRfc = ((busClk * timeNs) / 1000) + (((busClk * timeNs) % 1000) ? 1 : 0); - - DB(mvOsPrintf("Dram Timing High: tRfc = %d\n", tRfc)); - - - /* Represent the populate banks in binary form */ - for(bankNum = 0; bankNum < MV_DRAM_MAX_CS; bankNum++) - { - if (0 != pBankInfo[bankNum].size) - sdramTw2wCyc++; - } - - /* If we have more the 1 bank then we need the TW2W in 1 for ODT switch */ - if (sdramTw2wCyc > 1) - sdramTw2wCyc = 1; - else - sdramTw2wCyc = 0; - - /* Note: value of 0 in register means one cycle, 1 means two and so on */ - return ((((tRfc - 1) & SDRAM_TRFC_MASK) << SDRAM_TRFC_OFFS) | - ((SDRAM_TR2R_CYC - 1) << SDRAM_TR2R_OFFS) | - ((SDRAM_TR2WW2R_CYC - 1) << SDRAM_TR2W_W2R_OFFS) | - (((tRfc - 1) >> 4) << SDRAM_TRFC_EXT_OFFS) | - (sdramTw2wCyc << SDRAM_TW2W_OFFS)); - -} - -/******************************************************************************* -* sdramDDr2OdtConfig - Set DRAM DDR2 On Die Termination registers. -* -* DESCRIPTION: -* This function config DDR2 On Die Termination (ODT) registers. -* ODT configuration is done according to DIMM presence: -* -* Presence Ctrl Low Ctrl High Dunit Ctrl Ext Mode -* CS0 0x84210000 0x00000000 0x0000780F 0x00000440 -* CS0+CS1 0x84210000 0x00000000 0x0000780F 0x00000440 -* CS0+CS2 0x030C030C 0x00000000 0x0000740F 0x00000404 -* CS0+CS1+CS2 0x030C030C 0x00000000 0x0000740F 0x00000404 -* CS0+CS2+CS3 0x030C030C 0x00000000 0x0000740F 0x00000404 -* CS0+CS1+CS2+CS3 0x030C030C 0x00000000 0x0000740F 0x00000404 -* -* INPUT: -* pBankInfo - bank info parameters. -* -* OUTPUT: -* None -* -* RETURN: -* None -*******************************************************************************/ -static void sdramDDr2OdtConfig(MV_DRAM_BANK_INFO *pBankInfo) -{ - MV_U32 populateBanks = 0; - MV_U32 odtCtrlLow, odtCtrlHigh, dunitOdtCtrl; - int bankNum; - - /* Represent the populate banks in binary form */ - for(bankNum = 0; bankNum < MV_DRAM_MAX_CS; bankNum++) - { - if (0 != pBankInfo[bankNum].size) - { - populateBanks |= (1 << bankNum); - } - } - - switch(populateBanks) - { - case(BANK_PRESENT_CS0): - odtCtrlLow = DDR2_ODT_CTRL_LOW_CS0_DV; - odtCtrlHigh = DDR2_ODT_CTRL_HIGH_CS0_DV; - dunitOdtCtrl = DDR2_DUNIT_ODT_CTRL_CS0_DV; - break; - case(BANK_PRESENT_CS0_CS1): - odtCtrlLow = DDR2_ODT_CTRL_LOW_CS0_DV; - odtCtrlHigh = DDR2_ODT_CTRL_HIGH_CS0_DV; - dunitOdtCtrl = DDR2_DUNIT_ODT_CTRL_CS0_DV; - break; - case(BANK_PRESENT_CS0_CS2): - odtCtrlLow = DDR2_ODT_CTRL_LOW_CS0_CS2_DV; - odtCtrlHigh = DDR2_ODT_CTRL_HIGH_CS0_CS2_DV; - dunitOdtCtrl = DDR2_DUNIT_ODT_CTRL_CS0_CS2_DV; - break; - case(BANK_PRESENT_CS0_CS1_CS2): - odtCtrlLow = DDR2_ODT_CTRL_LOW_CS0_CS2_DV; - odtCtrlHigh = DDR2_ODT_CTRL_HIGH_CS0_CS2_DV; - dunitOdtCtrl = DDR2_DUNIT_ODT_CTRL_CS0_CS2_DV; - break; - case(BANK_PRESENT_CS0_CS2_CS3): - odtCtrlLow = DDR2_ODT_CTRL_LOW_CS0_CS2_DV; - odtCtrlHigh = DDR2_ODT_CTRL_HIGH_CS0_CS2_DV; - dunitOdtCtrl = DDR2_DUNIT_ODT_CTRL_CS0_CS2_DV; - break; - case(BANK_PRESENT_CS0_CS2_CS3_CS4): - odtCtrlLow = DDR2_ODT_CTRL_LOW_CS0_CS2_DV; - odtCtrlHigh = DDR2_ODT_CTRL_HIGH_CS0_CS2_DV; - dunitOdtCtrl = DDR2_DUNIT_ODT_CTRL_CS0_CS2_DV; - break; - default: - mvOsPrintf("sdramDDr2OdtConfig: Invalid DRAM bank presence\n"); - return; - } - MV_REG_WRITE(DRAM_BUF_REG7, odtCtrlLow); - MV_REG_WRITE(DRAM_BUF_REG8, odtCtrlHigh); - MV_REG_WRITE(DRAM_BUF_REG9, dunitOdtCtrl); - return; -} -#endif /* defined(MV_INC_BOARD_DDIM) */ - -/******************************************************************************* -* mvDramIfWinSet - Set DRAM interface address decode window -* -* DESCRIPTION: -* This function sets DRAM interface address decode window. -* -* INPUT: -* target - System target. Use only SDRAM targets. -* pAddrDecWin - SDRAM address window structure. -* -* OUTPUT: -* None -* -* RETURN: -* MV_BAD_PARAM if parameters are invalid or window is invalid, MV_OK -* otherwise. -*******************************************************************************/ -MV_STATUS mvDramIfWinSet(MV_TARGET target, MV_DRAM_DEC_WIN *pAddrDecWin) -{ - MV_U32 baseReg=0,sizeReg=0; - MV_U32 baseToReg=0 , sizeToReg=0; - - /* Check parameters */ - if (!MV_TARGET_IS_DRAM(target)) - { - mvOsPrintf("mvDramIfWinSet: target %d is not SDRAM\n", target); - return MV_BAD_PARAM; - } - - /* Check if the requested window overlaps with current enabled windows */ - if (MV_TRUE == sdramIfWinOverlap(target, &pAddrDecWin->addrWin)) - { - mvOsPrintf("mvDramIfWinSet: ERR. Target %d overlaps\n", target); - return MV_BAD_PARAM; - } - - /* check if address is aligned to the size */ - if(MV_IS_NOT_ALIGN(pAddrDecWin->addrWin.baseLow, pAddrDecWin->addrWin.size)) - { - mvOsPrintf("mvDramIfWinSet:Error setting DRAM interface window %d."\ - "\nAddress 0x%08x is unaligned to size 0x%x.\n", - target, - pAddrDecWin->addrWin.baseLow, - pAddrDecWin->addrWin.size); - return MV_ERROR; - } - - /* read base register*/ - baseReg = MV_REG_READ(SDRAM_BASE_ADDR_REG(target)); - - /* read size register */ - sizeReg = MV_REG_READ(SDRAM_SIZE_REG(target)); - - /* BaseLow[31:16] => base register [31:16] */ - baseToReg = pAddrDecWin->addrWin.baseLow & SCBAR_BASE_MASK; - - /* Write to address decode Base Address Register */ - baseReg &= ~SCBAR_BASE_MASK; - baseReg |= baseToReg; - - /* Translate the given window size to register format */ - sizeToReg = ctrlSizeToReg(pAddrDecWin->addrWin.size, SCSR_SIZE_ALIGNMENT); - - /* Size parameter validity check. */ - if (-1 == sizeToReg) - { - mvOsPrintf("mvCtrlAddrDecToReg: ERR. Win %d size invalid.\n",target); - return MV_BAD_PARAM; - } - - /* set size */ - sizeReg &= ~SCSR_SIZE_MASK; - /* Size is located at upper 16 bits */ - sizeReg |= (sizeToReg << SCSR_SIZE_OFFS); - - /* enable/Disable */ - if (MV_TRUE == pAddrDecWin->enable) - { - sizeReg |= SCSR_WIN_EN; - } - else - { - sizeReg &= ~SCSR_WIN_EN; - } - - /* 3) Write to address decode Base Address Register */ - MV_REG_WRITE(SDRAM_BASE_ADDR_REG(target), baseReg); - - /* Write to address decode Size Register */ - MV_REG_WRITE(SDRAM_SIZE_REG(target), sizeReg); - - return MV_OK; -} -/******************************************************************************* -* mvDramIfWinGet - Get DRAM interface address decode window -* -* DESCRIPTION: -* This function gets DRAM interface address decode window. -* -* INPUT: -* target - System target. Use only SDRAM targets. -* -* OUTPUT: -* pAddrDecWin - SDRAM address window structure. -* -* RETURN: -* MV_BAD_PARAM if parameters are invalid or window is invalid, MV_OK -* otherwise. -*******************************************************************************/ -MV_STATUS mvDramIfWinGet(MV_TARGET target, MV_DRAM_DEC_WIN *pAddrDecWin) -{ - MV_U32 baseReg,sizeReg; - MV_U32 sizeRegVal; - - /* Check parameters */ - if (!MV_TARGET_IS_DRAM(target)) - { - mvOsPrintf("mvDramIfWinGet: target %d is Illigal\n", target); - return MV_ERROR; - } - - /* Read base and size registers */ - sizeReg = MV_REG_READ(SDRAM_SIZE_REG(target)); - baseReg = MV_REG_READ(SDRAM_BASE_ADDR_REG(target)); - - sizeRegVal = (sizeReg & SCSR_SIZE_MASK) >> SCSR_SIZE_OFFS; - - pAddrDecWin->addrWin.size = ctrlRegToSize(sizeRegVal, - SCSR_SIZE_ALIGNMENT); - - /* Check if ctrlRegToSize returned OK */ - if (-1 == pAddrDecWin->addrWin.size) - { - mvOsPrintf("mvDramIfWinGet: size of target %d is Illigal\n", target); - return MV_ERROR; - } - - /* Extract base address */ - /* Base register [31:16] ==> baseLow[31:16] */ - pAddrDecWin->addrWin.baseLow = baseReg & SCBAR_BASE_MASK; - - pAddrDecWin->addrWin.baseHigh = 0; - - - if (sizeReg & SCSR_WIN_EN) - { - pAddrDecWin->enable = MV_TRUE; - } - else - { - pAddrDecWin->enable = MV_FALSE; - } - - return MV_OK; -} -/******************************************************************************* -* mvDramIfWinEnable - Enable/Disable SDRAM address decode window -* -* DESCRIPTION: -* This function enable/Disable SDRAM address decode window. -* -* INPUT: -* target - System target. Use only SDRAM targets. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_ERROR in case function parameter are invalid, MV_OK otherewise. -* -*******************************************************************************/ -MV_STATUS mvDramIfWinEnable(MV_TARGET target,MV_BOOL enable) -{ - MV_DRAM_DEC_WIN addrDecWin; - - /* Check parameters */ - if (!MV_TARGET_IS_DRAM(target)) - { - mvOsPrintf("mvDramIfWinEnable: target %d is Illigal\n", target); - return MV_ERROR; - } - - if (enable == MV_TRUE) - { /* First check for overlap with other enabled windows */ - if (MV_OK != mvDramIfWinGet(target, &addrDecWin)) - { - mvOsPrintf("mvDramIfWinEnable:ERR. Getting target %d failed.\n", - target); - return MV_ERROR; - } - /* Check for overlapping */ - if (MV_FALSE == sdramIfWinOverlap(target, &(addrDecWin.addrWin))) - { - /* No Overlap. Enable address decode winNum window */ - MV_REG_BIT_SET(SDRAM_SIZE_REG(target), SCSR_WIN_EN); - } - else - { /* Overlap detected */ - mvOsPrintf("mvDramIfWinEnable: ERR. Target %d overlap detect\n", - target); - return MV_ERROR; - } - } - else - { /* Disable address decode winNum window */ - MV_REG_BIT_RESET(SDRAM_SIZE_REG(target), SCSR_WIN_EN); - } - - return MV_OK; -} - -/******************************************************************************* -* sdramIfWinOverlap - Check if an address window overlap an SDRAM address window -* -* DESCRIPTION: -* This function scan each SDRAM address decode window to test if it -* overlapps the given address windoow -* -* INPUT: -* target - SDRAM target where the function skips checking. -* pAddrDecWin - The tested address window for overlapping with -* SDRAM windows. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_TRUE if the given address window overlaps any enabled address -* decode map, MV_FALSE otherwise. -* -*******************************************************************************/ -static MV_BOOL sdramIfWinOverlap(MV_TARGET target, MV_ADDR_WIN *pAddrWin) -{ - MV_TARGET targetNum; - MV_DRAM_DEC_WIN addrDecWin; - - for(targetNum = SDRAM_CS0; targetNum < MV_DRAM_MAX_CS ; targetNum++) - { - /* don't check our winNum or illegal targets */ - if (targetNum == target) - { - continue; - } - - /* Get window parameters */ - if (MV_OK != mvDramIfWinGet(targetNum, &addrDecWin)) - { - mvOsPrintf("sdramIfWinOverlap: ERR. TargetWinGet failed\n"); - return MV_ERROR; - } - - /* Do not check disabled windows */ - if (MV_FALSE == addrDecWin.enable) - { - continue; - } - - if(MV_TRUE == ctrlWinOverlapTest(pAddrWin, &addrDecWin.addrWin)) - { - mvOsPrintf( - "sdramIfWinOverlap: Required target %d overlap winNum %d\n", - target, targetNum); - return MV_TRUE; - } - } - - return MV_FALSE; -} - -/******************************************************************************* -* mvDramIfBankSizeGet - Get DRAM interface bank size. -* -* DESCRIPTION: -* This function returns the size of a given DRAM bank. -* -* INPUT: -* bankNum - Bank number. -* -* OUTPUT: -* None. -* -* RETURN: -* DRAM bank size. If bank is disabled the function return '0'. In case -* or paramter is invalid, the function returns -1. -* -*******************************************************************************/ -MV_32 mvDramIfBankSizeGet(MV_U32 bankNum) -{ - MV_DRAM_DEC_WIN addrDecWin; - - /* Check parameters */ - if (!MV_TARGET_IS_DRAM(bankNum)) - { - mvOsPrintf("mvDramIfBankBaseGet: bankNum %d is invalid\n", bankNum); - return -1; - } - /* Get window parameters */ - if (MV_OK != mvDramIfWinGet(bankNum, &addrDecWin)) - { - mvOsPrintf("sdramIfWinOverlap: ERR. TargetWinGet failed\n"); - return -1; - } - - if (MV_TRUE == addrDecWin.enable) - { - return addrDecWin.addrWin.size; - } - else - { - return 0; - } -} - - -/******************************************************************************* -* mvDramIfSizeGet - Get DRAM interface total size. -* -* DESCRIPTION: -* This function get the DRAM total size. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* DRAM total size. In case or paramter is invalid, the function -* returns -1. -* -*******************************************************************************/ -MV_32 mvDramIfSizeGet(MV_VOID) -{ - MV_U32 totalSize = 0, bankSize = 0, bankNum; - - for(bankNum = 0; bankNum < MV_DRAM_MAX_CS; bankNum++) - { - bankSize = mvDramIfBankSizeGet(bankNum); - - if (-1 == bankSize) - { - mvOsPrintf("Dram: mvDramIfSizeGet error with bank %d \n",bankNum); - return -1; - } - else - { - totalSize += bankSize; - } - } - - DB(mvOsPrintf("Dram: Total DRAM size is 0x%x \n",totalSize)); - - return totalSize; -} - -/******************************************************************************* -* mvDramIfBankBaseGet - Get DRAM interface bank base. -* -* DESCRIPTION: -* This function returns the 32 bit base address of a given DRAM bank. -* -* INPUT: -* bankNum - Bank number. -* -* OUTPUT: -* None. -* -* RETURN: -* DRAM bank size. If bank is disabled or paramter is invalid, the -* function returns -1. -* -*******************************************************************************/ -MV_32 mvDramIfBankBaseGet(MV_U32 bankNum) -{ - MV_DRAM_DEC_WIN addrDecWin; - - /* Check parameters */ - if (!MV_TARGET_IS_DRAM(bankNum)) - { - mvOsPrintf("mvDramIfBankBaseGet: bankNum %d is invalid\n", bankNum); - return -1; - } - /* Get window parameters */ - if (MV_OK != mvDramIfWinGet(bankNum, &addrDecWin)) - { - mvOsPrintf("sdramIfWinOverlap: ERR. TargetWinGet failed\n"); - return -1; - } - - if (MV_TRUE == addrDecWin.enable) - { - return addrDecWin.addrWin.baseLow; - } - else - { - return -1; - } -} - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr1_2/mvDramIf.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr1_2/mvDramIf.h deleted file mode 100644 index 8bfa3e8..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr1_2/mvDramIf.h +++ /dev/null @@ -1,179 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -#ifndef __INCmvDramIfh -#define __INCmvDramIfh - -/* includes */ -#include "ddr1_2/mvDramIfRegs.h" -#include "ddr1_2/mvDramIfConfig.h" -#include "ctrlEnv/mvCtrlEnvLib.h" - -/* defines */ -/* DRAM Timing parameters */ -#define SDRAM_TWR 15 /* ns tWr */ -#define SDRAM_TRFC_64_512M_AT_200MHZ 70 /* ns tRfc for dens 64-512 @ 200MHz */ -#define SDRAM_TRFC_64_512M 75 /* ns tRfc for dens 64-512 */ -#define SDRAM_TRFC_1G 120 /* ns tRfc for dens 1GB */ -#define SDRAM_TR2R_CYC 1 /* cycle for tR2r */ -#define SDRAM_TR2WW2R_CYC 1 /* cycle for tR2wW2r */ - -/* typedefs */ - -/* enumeration for memory types */ -typedef enum _mvMemoryType -{ - MEM_TYPE_SDRAM, - MEM_TYPE_DDR1, - MEM_TYPE_DDR2 -}MV_MEMORY_TYPE; - -/* enumeration for DDR1 supported CAS Latencies */ -typedef enum _mvDimmDdr1Cas -{ - DDR1_CL_1_5 = 0x02, - DDR1_CL_2 = 0x04, - DDR1_CL_2_5 = 0x08, - DDR1_CL_3 = 0x10, - DDR1_CL_4 = 0x40, - DDR1_CL_FAULT -} MV_DIMM_DDR1_CAS; - -/* enumeration for DDR2 supported CAS Latencies */ -typedef enum _mvDimmDdr2Cas -{ - DDR2_CL_3 = 0x08, - DDR2_CL_4 = 0x10, - DDR2_CL_5 = 0x20, - DDR2_CL_FAULT -} MV_DIMM_DDR2_CAS; - - -typedef struct _mvDramBankInfo -{ - MV_MEMORY_TYPE memoryType; /* DDR1, DDR2 or SDRAM */ - - /* DIMM dimensions */ - MV_U32 numOfRowAddr; - MV_U32 numOfColAddr; - MV_U32 dataWidth; - MV_U32 errorCheckType; /* ECC , PARITY..*/ - MV_U32 sdramWidth; /* 4,8,16 or 32 */ - MV_U32 errorCheckDataWidth; /* 0 - no, 1 - Yes */ - MV_U32 burstLengthSupported; - MV_U32 numOfBanksOnEachDevice; - MV_U32 suportedCasLatencies; - MV_U32 refreshInterval; - - /* DIMM timing parameters */ - MV_U32 minCycleTimeAtMaxCasLatPs; - MV_U32 minCycleTimeAtMaxCasLatMinus1Ps; - MV_U32 minCycleTimeAtMaxCasLatMinus2Ps; - MV_U32 minRowPrechargeTime; - MV_U32 minRowActiveToRowActive; - MV_U32 minRasToCasDelay; - MV_U32 minRasPulseWidth; - MV_U32 minWriteRecoveryTime; /* DDR2 only */ - MV_U32 minWriteToReadCmdDelay; /* DDR2 only */ - MV_U32 minReadToPrechCmdDelay; /* DDR2 only */ - MV_U32 minRefreshToActiveCmd; /* DDR2 only */ - - /* Parameters calculated from the extracted DIMM information */ - MV_U32 size; - MV_U32 deviceDensity; /* 16,64,128,256 or 512 Mbit */ - MV_U32 numberOfDevices; - - /* DIMM attributes (MV_TRUE for yes) */ - MV_BOOL registeredAddrAndControlInputs; - -}MV_DRAM_BANK_INFO; - -/* This structure describes CPU interface address decode window */ -typedef struct _mvDramIfDecWin -{ - MV_ADDR_WIN addrWin; /* An address window*/ - MV_BOOL enable; /* Address decode window is enabled/disabled */ -}MV_DRAM_DEC_WIN; - -#include "ddr1_2/mvDram.h" - -/* mvDramIf.h API list */ -MV_VOID mvDramIfBasicAsmInit(MV_VOID); -MV_STATUS mvDramIfDetect(MV_U32 forcedCl); -MV_VOID _mvDramIfConfig(MV_VOID); - -MV_STATUS mvDramIfWinSet(MV_TARGET target, MV_DRAM_DEC_WIN *pAddrDecWin); -MV_STATUS mvDramIfWinGet(MV_TARGET target, MV_DRAM_DEC_WIN *pAddrDecWin); -MV_STATUS mvDramIfWinEnable(MV_TARGET target,MV_BOOL enable); -MV_32 mvDramIfBankSizeGet(MV_U32 bankNum); -MV_32 mvDramIfBankBaseGet(MV_U32 bankNum); -MV_32 mvDramIfSizeGet(MV_VOID); - -#if 0 -MV_STATUS mvDramIfMbusCtrlSet(MV_XBAR_TARGET *pPizzaArbArray); -MV_STATUS mvDramIfMbusToutSet(MV_U32 timeout, MV_BOOL enable); -#endif - -#endif /* __INCmvDramIfh */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr1_2/mvDramIfConfig.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr1_2/mvDramIfConfig.h deleted file mode 100644 index a7c6644..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr1_2/mvDramIfConfig.h +++ /dev/null @@ -1,192 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -#ifndef __INCmvDramIfConfigh -#define __INCmvDramIfConfigh - -/* includes */ - -/* defines */ - -/* registers defaults values */ - -#define SDRAM_CONFIG_DV \ - (SDRAM_PERR_WRITE | \ - SDRAM_SRMODE | \ - SDRAM_SRCLK_GATED) - -#define SDRAM_DUNIT_CTRL_LOW_DV \ - (SDRAM_CTRL_POS_RISE | \ - SDRAM_CLK1DRV_NORMAL | \ - SDRAM_LOCKEN_ENABLE) - -#define SDRAM_ADDR_CTRL_DV 0 - -#define SDRAM_TIMING_CTRL_LOW_REG_DV \ - ((0x2 << SDRAM_TRCD_OFFS) | \ - (0x2 << SDRAM_TRP_OFFS) | \ - (0x1 << SDRAM_TWR_OFFS) | \ - (0x0 << SDRAM_TWTR_OFFS) | \ - (0x5 << SDRAM_TRAS_OFFS) | \ - (0x1 << SDRAM_TRRD_OFFS)) -/* TRFC 0x27, TW2W 0x1 */ -#define SDRAM_TIMING_CTRL_HIGH_REG_DV (( 0x7 << SDRAM_TRFC_OFFS ) |\ - ( 0x2 << SDRAM_TRFC_EXT_OFFS) |\ - ( 0x1 << SDRAM_TW2W_OFFS)) - -#define SDRAM_OPEN_PAGES_CTRL_REG_DV SDRAM_OPEN_PAGE_EN - -/* DDR2 ODT default register values */ - -/* Presence Ctrl Low Ctrl High Dunit Ctrl Ext Mode */ -/* CS0 0x84210000 0x00000000 0x0000780F 0x00000440 */ -/* CS0+CS1 0x84210000 0x00000000 0x0000780F 0x00000440 */ -/* CS0+CS2 0x030C030C 0x00000000 0x0000740F 0x00000404 */ -/* CS0+CS1+CS2 0x030C030C 0x00000000 0x0000740F 0x00000404 */ -/* CS0+CS2+CS3 0x030C030C 0x00000000 0x0000740F 0x00000404 */ -/* CS0+CS1+CS2+CS3 0x030C030C 0x00000000 0x0000740F 0x00000404 */ - -#define DDR2_ODT_CTRL_LOW_CS0_DV 0x84210000 -#define DDR2_ODT_CTRL_HIGH_CS0_DV 0x00000000 -#define DDR2_DUNIT_ODT_CTRL_CS0_DV 0x0000780F -#define DDR_SDRAM_EXT_MODE_CS0_DV 0x00000440 - -#define DDR2_ODT_CTRL_LOW_CS0_CS2_DV 0x030C030C -#define DDR2_ODT_CTRL_HIGH_CS0_CS2_DV 0x00000000 -#define DDR2_DUNIT_ODT_CTRL_CS0_CS2_DV 0x0000740F -#define DDR_SDRAM_EXT_MODE_CS0_CS2_DV 0x00000404 - - -/* DDR SDRAM Adderss/Control and Data Pads Calibration default values */ -#define DDR1_ADDR_CTRL_PAD_STRENGTH_TYPICAL_DV \ - (1 << SDRAM_PRE_DRIVER_STRENGTH_OFFS) -#define DDR2_ADDR_CTRL_PAD_STRENGTH_TYPICAL_DV \ - (3 << SDRAM_PRE_DRIVER_STRENGTH_OFFS) - - -#define DDR1_DATA_PAD_STRENGTH_TYPICAL_DV \ - (1 << SDRAM_PRE_DRIVER_STRENGTH_OFFS) -#define DDR2_DATA_PAD_STRENGTH_TYPICAL_DV \ - (3 << SDRAM_PRE_DRIVER_STRENGTH_OFFS) - -/* DDR SDRAM Mode Register default value */ -#define DDR1_MODE_REG_DV 0x00000000 -#define DDR2_MODE_REG_DV 0x00000400 - -/* DDR SDRAM Timing parameter default values */ -#define DDR1_TIMING_LOW_DV 0x11602220 -#define DDR1_TIMING_HIGH_DV 0x0000000d - -#define DDR2_TIMING_LOW_DV 0x11812220 -#define DDR2_TIMING_HIGH_DV 0x0000030f - -/* For Guideline (GL# MEM-4) DQS Reference Delay Tuning */ -#define FTDLL_DDR1_166MHZ ((0x1 << 0) | \ - (0x7F<< 12) | \ - (0x1 << 22)) - -#define FTDLL_DDR1_133MHZ FTDLL_DDR1_166MHZ - -#define FTDLL_DDR1_200MHZ ((0x1 << 0) | \ - (0x1 << 12) | \ - (0x3 << 14) | \ - (0x1 << 18) | \ - (0x1 << 22)) - - -#define FTDLL_DDR2_166MHZ ((0x1 << 0) | \ - (0x1 << 12) | \ - (0x1 << 14) | \ - (0x1 << 16) | \ - (0x1 << 19) | \ - (0xF << 20)) - -#define FTDLL_DDR2_133MHZ FTDLL_DDR2_166MHZ - -#define FTDLL_DDR2_200MHZ ((0x1 << 0) | \ - (0x1 << 12) | \ - (0x1 << 14) | \ - (0x1 << 16) | \ - (0x1 << 19) | \ - (0xF << 20)) - -#define FTDLL_DDR2_250MHZ 0x445001 - -/* Orion 1 B1 and above */ -#define FTDLL_DDR1_166MHZ_5181_B1 0x45D001 - -/* Orion nas */ -#define FTDLL_DDR2_166MHZ_5182 0x597001 - -/* Orion 2 D0 and above */ -#define FTDLL_DDR1_166MHZ_5281_D0 0x8D0001 -#define FTDLL_DDR1_200MHZ_5281_D0 0x8D0001 -#define FTDLL_DDR2_166MHZ_5281_D0 0x485001 -#define FTDLL_DDR2_200MHZ_5281_D0 0x485001 -#define FTDLL_DDR2_250MHZ_5281_D0 0x445001 -#define FTDLL_DDR2_200MHZ_5281_D1 0x995001 -#define FTDLL_DDR2_250MHZ_5281_D1 0x984801 - -#endif /* __INCmvDramIfh */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr1_2/mvDramIfRegs.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr1_2/mvDramIfRegs.h deleted file mode 100644 index e9cd7c4..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr1_2/mvDramIfRegs.h +++ /dev/null @@ -1,306 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCmvDramIfRegsh -#define __INCmvDramIfRegsh - - -/* DDR SDRAM Controller Address Decode Registers */ -/* SDRAM CSn Base Address Register (SCBAR) */ -#define SDRAM_BASE_ADDR_REG(csNum) (0x1500 + (csNum * 8)) -#define SCBAR_BASE_OFFS 16 -#define SCBAR_BASE_MASK (0xffff << SCBAR_BASE_OFFS) -#define SCBAR_BASE_ALIGNMENT 0x10000 - -/* SDRAM CSn Size Register (SCSR) */ -#define SDRAM_SIZE_REG(csNum) (0x1504 + (csNum * 8)) -#define SCSR_WIN_EN BIT0 -#define SCSR_SIZE_OFFS 16 -#define SCSR_SIZE_MASK (0xffff << SCSR_SIZE_OFFS) -#define SCSR_SIZE_ALIGNMENT 0x10000 - -/* configuration register */ -#define SDRAM_CONFIG_REG 0x1400 -#define SDRAM_REFRESH_OFFS 0 -#define SDRAM_REFRESH_MAX 0x3000 -#define SDRAM_REFRESH_MASK (SDRAM_REFRESH_MAX << SDRAM_REFRESH_OFFS) -#define SDRAM_DWIDTH_OFFS 14 -#define SDRAM_DWIDTH_MASK (3 << SDRAM_DWIDTH_OFFS) -#define SDRAM_DWIDTH_16BIT (1 << SDRAM_DWIDTH_OFFS) -#define SDRAM_DWIDTH_32BIT (2 << SDRAM_DWIDTH_OFFS) -#define SDRAM_DTYPE_OFFS 16 -#define SDRAM_DTYPE_MASK (1 << SDRAM_DTYPE_OFFS) -#define SDRAM_DTYPE_DDR1 (0 << SDRAM_DTYPE_OFFS) -#define SDRAM_DTYPE_DDR2 (1 << SDRAM_DTYPE_OFFS) -#define SDRAM_REGISTERED (1 << 17) -#define SDRAM_PERR_OFFS 18 -#define SDRAM_PERR_MASK (1 << SDRAM_PERR_OFFS) -#define SDRAM_PERR_NO_WRITE (0 << SDRAM_PERR_OFFS) -#define SDRAM_PERR_WRITE (1 << SDRAM_PERR_OFFS) -#define SDRAM_DCFG_OFFS 20 -#define SDRAM_DCFG_MASK (0x3 << SDRAM_DCFG_OFFS) -#define SDRAM_DCFG_X16_DEV (1 << SDRAM_DCFG_OFFS) -#define SDRAM_DCFG_X8_DEV (2 << SDRAM_DCFG_OFFS) -#define SDRAM_SRMODE (1 << 24) -#define SDRAM_SRCLK_OFFS 25 -#define SDRAM_SRCLK_MASK (1 << SDRAM_SRCLK_OFFS) -#define SDRAM_SRCLK_KEPT (0 << SDRAM_SRCLK_OFFS) -#define SDRAM_SRCLK_GATED (1 << SDRAM_SRCLK_OFFS) -#define SDRAM_CATTH_OFFS 26 -#define SDRAM_CATTHR_EN (1 << SDRAM_CATTH_OFFS) - - -/* dunit control register */ -#define SDRAM_DUNIT_CTRL_REG 0x1404 -#define SDRAM_CTRL_POS_OFFS 6 -#define SDRAM_CTRL_POS_FALL (0 << SDRAM_CTRL_POS_OFFS) -#define SDRAM_CTRL_POS_RISE (1 << SDRAM_CTRL_POS_OFFS) -#define SDRAM_CLK1DRV_OFFS 12 -#define SDRAM_CLK1DRV_MASK (1 << SDRAM_CLK1DRV_OFFS) -#define SDRAM_CLK1DRV_HIGH_Z (0 << SDRAM_CLK1DRV_OFFS) -#define SDRAM_CLK1DRV_NORMAL (1 << SDRAM_CLK1DRV_OFFS) -#define SDRAM_LOCKEN_OFFS 18 -#define SDRAM_LOCKEN_MASK (1 << SDRAM_LOCKEN_OFFS) -#define SDRAM_LOCKEN_DISABLE (0 << SDRAM_LOCKEN_OFFS) -#define SDRAM_LOCKEN_ENABLE (1 << SDRAM_LOCKEN_OFFS) -#define SDRAM_ST_BURST_DEL_OFFS 24 -#define SDRAM_ST_BURST_DEL_MAX 0xf -#define SDRAM_ST_BURST_DEL_MASK (SDRAM_ST_BURST_DEL_MAX<<SDRAM_ST_BURST_DEL_OFFS) - -/* sdram timing control low register */ -#define SDRAM_TIMING_CTRL_LOW_REG 0x1408 -#define SDRAM_TRCD_OFFS 4 -#define SDRAM_TRCD_MASK (0xF << SDRAM_TRCD_OFFS) -#define SDRAM_TRP_OFFS 8 -#define SDRAM_TRP_MASK (0xF << SDRAM_TRP_OFFS) -#define SDRAM_TWR_OFFS 12 -#define SDRAM_TWR_MASK (0xF << SDRAM_TWR_OFFS) -#define SDRAM_TWTR_OFFS 16 -#define SDRAM_TWTR_MASK (0xF << SDRAM_TWTR_OFFS) -#define SDRAM_TRAS_OFFS 20 -#define SDRAM_TRAS_MASK (0xF << SDRAM_TRAS_OFFS) -#define SDRAM_TRRD_OFFS 24 -#define SDRAM_TRRD_MASK (0xF << SDRAM_TRRD_OFFS) -#define SDRAM_TRTP_OFFS 28 -#define SDRAM_TRTP_MASK (0xF << SDRAM_TRTP_OFFS) - -/* sdram timing control high register */ -#define SDRAM_TIMING_CTRL_HIGH_REG 0x140c -#define SDRAM_TRFC_OFFS 0 -#define SDRAM_TRFC_MASK (0xF << SDRAM_TRFC_OFFS) -#define SDRAM_TR2R_OFFS 4 -#define SDRAM_TR2R_MASK (0x3 << SDRAM_TR2R_OFFS) -#define SDRAM_TR2W_W2R_OFFS 6 -#define SDRAM_TR2W_W2R_MASK (0x3 << SDRAM_TR2W_W2R_OFFS) -#define SDRAM_TRFC_EXT_OFFS 8 -#define SDRAM_TRFC_EXT_MASK (0x1 << SDRAM_TRFC_EXT_OFFS) -#define SDRAM_TW2W_OFFS 10 -#define SDRAM_TW2W_MASK (0x1 << SDRAM_TW2W_OFFS) - -/* address control register */ -#define SDRAM_ADDR_CTRL_REG 0x1410 -#define SDRAM_DSIZE_OFFS 4 -#define SDRAM_DSIZE_MASK (0x3 << SDRAM_DSIZE_OFFS) -#define SDRAM_DSIZE_128Mb (0x0 << SDRAM_DSIZE_OFFS) -#define SDRAM_DSIZE_256Mb (0x1 << SDRAM_DSIZE_OFFS) -#define SDRAM_DSIZE_512Mb (0x2 << SDRAM_DSIZE_OFFS) - -/* SDRAM Open Pages Control registers */ -#define SDRAM_OPEN_PAGE_CTRL_REG 0x1414 -#define SDRAM_OPEN_PAGE_EN (0 << 0) -#define SDRAM_OPEN_PAGE_DIS (1 << 0) - -/* sdram opertion register */ -#define SDRAM_OPERATION_REG 0x1418 -#define SDRAM_CMD_OFFS 0 -#define SDRAM_CMD_MASK (0x7 << SDRAM_CMD_OFFS) -#define SDRAM_CMD_NORMAL (0x0 << SDRAM_CMD_OFFS) -#define SDRAM_CMD_PRECHARGE_ALL (0x1 << SDRAM_CMD_OFFS) -#define SDRAM_CMD_REFRESH_ALL (0x2 << SDRAM_CMD_OFFS) -#define SDRAM_CMD_REG_SET_CMD (0x3 << SDRAM_CMD_OFFS) -#define SDRAM_CMD_EXT_MODE_SET (0x4 << SDRAM_CMD_OFFS) -#define SDRAM_CMD_NOP (0x5 << SDRAM_CMD_OFFS) -#define SDRAM_CMD_SLF_RFRSH (0x7 << SDRAM_CMD_OFFS) -#define SDRAM_CMD_EMRS2_CMD (0x8 << SDRAM_CMD_OFFS) -#define SDRAM_CMD_EMRS3_CMD (0x9 << SDRAM_CMD_OFFS) - -/* sdram mode register */ -#define SDRAM_MODE_REG 0x141c -#define SDRAM_BURST_LEN_OFFS 0 -#define SDRAM_BURST_LEN_MASK (0x7 << SDRAM_BURST_LEN_OFFS) -#define SDRAM_BURST_LEN_4 (0x2 << SDRAM_BURST_LEN_OFFS) -#define SDRAM_CL_OFFS 4 -#define SDRAM_CL_MASK (0x7 << SDRAM_CL_OFFS) -#define SDRAM_DDR1_CL_2 (0x2 << SDRAM_CL_OFFS) -#define SDRAM_DDR1_CL_3 (0x3 << SDRAM_CL_OFFS) -#define SDRAM_DDR1_CL_4 (0x4 << SDRAM_CL_OFFS) -#define SDRAM_DDR1_CL_1_5 (0x5 << SDRAM_CL_OFFS) -#define SDRAM_DDR1_CL_2_5 (0x6 << SDRAM_CL_OFFS) -#define SDRAM_DDR2_CL_3 (0x3 << SDRAM_CL_OFFS) -#define SDRAM_DDR2_CL_4 (0x4 << SDRAM_CL_OFFS) -#define SDRAM_DDR2_CL_5 (0x5 << SDRAM_CL_OFFS) -#define SDRAM_TM_OFFS 7 -#define SDRAM_TM_MASK (1 << SDRAM_TM_OFFS) -#define SDRAM_TM_NORMAL (0 << SDRAM_TM_OFFS) -#define SDRAM_TM_TEST_MODE (1 << SDRAM_TM_OFFS) -#define SDRAM_DLL_OFFS 8 -#define SDRAM_DLL_MASK (1 << SDRAM_DLL_OFFS) -#define SDRAM_DLL_NORMAL (0 << SDRAM_DLL_OFFS) -#define SDRAM_DLL_RESET (1 << SDRAM_DLL_OFFS) -#define SDRAM_WR_OFFS 11 -#define SDRAM_WR_MAX 7 -#define SDRAM_WR_MASK (SDRAM_WR_MAX << SDRAM_WR_OFFS) -#define SDRAM_PD_OFFS 12 -#define SDRAM_PD_MASK (1 << SDRAM_PD_OFFS) -#define SDRAM_PD_FAST_EXIT (0 << SDRAM_PD_OFFS) -#define SDRAM_PD_SLOW_EXIT (1 << SDRAM_PD_OFFS) - -/* DDR SDRAM Extended Mode register (DSEMR) */ -#define SDRAM_EXTENDED_MODE_REG 0x1420 -#define DSEMR_DLL_ENABLE (1 << 0) -#define DSEMR_DS_OFFS 1 -#define DSEMR_DS_MASK (1 << DSEMR_DS_OFFS) -#define DSEMR_DS_NORMAL (0 << DSEMR_DS_OFFS) -#define DSEMR_DS_REDUCED (1 << DSEMR_DS_OFFS) -#define DSEMR_RTT0_OFFS 2 -#define DSEMR_RTT1_OFFS 6 -#define DSEMR_RTT_ODT_DISABLE ((0 << DSEMR_RTT0_OFFS)||(0 << DSEMR_RTT1_OFFS)) -#define DSEMR_RTT_ODT_75_OHM ((1 << DSEMR_RTT0_OFFS)||(0 << DSEMR_RTT1_OFFS)) -#define DSEMR_RTT_ODT_150_OHM ((0 << DSEMR_RTT0_OFFS)||(1 << DSEMR_RTT1_OFFS)) -#define DSEMR_OCD_OFFS 7 -#define DSEMR_OCD_MASK (0x7 << DSEMR_OCD_OFFS) -#define DSEMR_OCD_EXIT_CALIB (0 << DSEMR_OCD_OFFS) -#define DSEMR_OCD_DRIVE1 (1 << DSEMR_OCD_OFFS) -#define DSEMR_OCD_DRIVE0 (2 << DSEMR_OCD_OFFS) -#define DSEMR_OCD_ADJUST_MODE (4 << DSEMR_OCD_OFFS) -#define DSEMR_OCD_CALIB_DEFAULT (7 << DSEMR_OCD_OFFS) -#define DSEMR_DQS_OFFS 10 -#define DSEMR_DQS_MASK (1 << DSEMR_DQS_OFFS) -#define DSEMR_DQS_DIFFERENTIAL (0 << DSEMR_DQS_OFFS) -#define DSEMR_DQS_SINGLE_ENDED (0 << DSEMR_DQS_OFFS) -#define DSEMR_RDQS_ENABLE (1 << 11) -#define DSEMR_QOFF_OUTPUT_BUFF_EN (1 << 12) - -/* DDR SDRAM Operation Control Register */ -#define SDRAM_OPERATION_CTRL_REG 0x142c - -/* Dunit FTDLL Configuration Register */ -#define SDRAM_FTDLL_CONFIG_REG 0x1484 - -/* Pads Calibration register */ -#define SDRAM_ADDR_CTRL_PADS_CAL_REG 0x14c0 -#define SDRAM_DATA_PADS_CAL_REG 0x14c4 -#define SDRAM_DRVN_OFFS 0 -#define SDRAM_DRVN_MASK (0x3F << SDRAM_DRVN_OFFS) -#define SDRAM_DRVP_OFFS 6 -#define SDRAM_DRVP_MASK (0x3F << SDRAM_DRVP_OFFS) -#define SDRAM_PRE_DRIVER_STRENGTH_OFFS 12 -#define SDRAM_PRE_DRIVER_STRENGTH_MASK (3 << SDRAM_PRE_DRIVER_STRENGTH_OFFS) -#define SDRAM_TUNE_EN BIT16 -#define SDRAM_LOCK_OFFS 17 -#define SDRAM_LOCK_MAKS (0x1F << SDRAM_LOCK_OFFS) -#define SDRAM_LOCKN_OFFS 17 -#define SDRAM_LOCKN_MAKS (0x3F << SDRAM_LOCKN_OFFS) -#define SDRAM_LOCKP_OFFS 23 -#define SDRAM_LOCKP_MAKS (0x3F << SDRAM_LOCKP_OFFS) -#define SDRAM_WR_EN (1 << 31) - -/* DDR2 SDRAM ODT Control (Low) Register (DSOCLR) */ -#define DDR2_SDRAM_ODT_CTRL_LOW_REG 0x1494 -#define DSOCLR_ODT_RD_OFFS(odtNum) (odtNum * 4) -#define DSOCLR_ODT_RD_MASK(odtNum) (0xf << DSOCLR_ODT_RD_OFFS(odtNum)) -#define DSOCLR_ODT_RD(odtNum, bank) ((1 << bank) << DSOCLR_ODT_RD_OFFS(odtNum)) -#define DSOCLR_ODT_WR_OFFS(odtNum) (16 + (odtNum * 4)) -#define DSOCLR_ODT_WR_MASK(odtNum) (0xf << DSOCLR_ODT_WR_OFFS(odtNum)) -#define DSOCLR_ODT_WD(odtNum, bank) ((1 << bank) << DSOCLR_ODT_WR_OFFS(odtNum)) - -/* DDR2 SDRAM ODT Control (High) Register (DSOCHR) */ -#define DDR2_SDRAM_ODT_CTRL_HIGH_REG 0x1498 -/* Optional control values to DSOCHR_ODT_EN macro */ -#define DDR2_ODT_CTRL_DUNIT 0 -#define DDR2_ODT_CTRL_NEVER 1 -#define DDR2_ODT_CTRL_ALWAYS 3 -#define DSOCHR_ODT_EN_OFFS(odtNum) (odtNum * 2) -#define DSOCHR_ODT_EN_MASK(odtNum) (0x3 << DSOCHR_ODT_EN_OFFS(odtNum)) -#define DSOCHR_ODT_EN(odtNum, ctrl) ((1 << ctrl) << DSOCHR_ODT_RD_OFFS(odtNum)) - -/* DDR2 Dunit ODT Control Register (DDOCR)*/ -#define DDR2_DUNIT_ODT_CONTROL_REG 0x149c -#define DDOCR_ODT_RD_OFFS 0 -#define DDOCR_ODT_RD_MASK (0xf << DDOCR_ODT_RD_OFFS) -#define DDOCR_ODT_RD(bank) ((1 << bank) << DDOCR_ODT_RD_OFFS) -#define DDOCR_ODT_WR_OFFS 4 -#define DDOCR_ODT_WR_MASK (0xf << DDOCR_ODT_WR_OFFS) -#define DDOCR_ODT_WR(bank) ((1 << bank) << DDOCR_ODT_WR_OFFS) -#define DSOCR_ODT_EN_OFFS 8 -#define DSOCR_ODT_EN_MASK (0x3 << DSOCR_ODT_EN_OFFS) -#define DSOCR_ODT_EN(ctrl) ((1 << ctrl) << DSOCR_ODT_EN_OFFS) -#define DSOCR_ODT_SEL_OFFS 10 -#define DSOCR_ODT_SEL_MASK (0x3 << DSOCR_ODT_SEL_OFFS) - -/* DDR SDRAM Initialization Control Register (DSICR) */ -#define DDR_SDRAM_INIT_CTRL_REG 0x1480 -#define DSICR_INIT_EN (1 << 0) - -#endif /* __INCmvDramIfRegsh */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr2/mvDramIf.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr2/mvDramIf.c deleted file mode 100644 index a214c95..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr2/mvDramIf.c +++ /dev/null @@ -1,1855 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -/* includes */ -#include "ddr2/mvDramIf.h" -#include "ctrlEnv/sys/mvCpuIf.h" - -#include "ddr2/mvDramIfStaticInit.h" - -/* #define MV_DEBUG */ -#ifdef MV_DEBUG -#define DB(x) x -#else -#define DB(x) -#endif - -/* DRAM bank presence encoding */ -#define BANK_PRESENT_CS0 0x1 -#define BANK_PRESENT_CS0_CS1 0x3 -#define BANK_PRESENT_CS0_CS2 0x5 -#define BANK_PRESENT_CS0_CS1_CS2 0x7 -#define BANK_PRESENT_CS0_CS2_CS3 0xd -#define BANK_PRESENT_CS0_CS2_CS3_CS4 0xf - -/* locals */ -#ifndef MV_STATIC_DRAM_ON_BOARD -static void sdramDDr2OdtConfig(MV_DRAM_BANK_INFO *pBankInfo); -static MV_U32 dunitCtrlLowRegCalc(MV_DRAM_BANK_INFO *pBankInfo, MV_U32 minCas, MV_U32 busClk, MV_STATUS TTmode ); -static MV_U32 dunitCtrlHighRegCalc(MV_DRAM_BANK_INFO *pBankInfo, MV_U32 busClk); -static MV_U32 sdramModeRegCalc(MV_U32 minCas); -static MV_U32 sdramExtModeRegCalc(MV_DRAM_BANK_INFO *pBankInfo, MV_U32 busClk); -static MV_U32 sdramAddrCtrlRegCalc(MV_DRAM_BANK_INFO *pBankInfo, MV_DRAM_BANK_INFO *pBankInfoDIMM1); -static MV_U32 sdramConfigRegCalc(MV_DRAM_BANK_INFO *pBankInfo, MV_DRAM_BANK_INFO *pBankInfo2, MV_U32 busClk); -static MV_U32 minCasCalc(MV_DRAM_BANK_INFO *pBankInfo,MV_DRAM_BANK_INFO *pBankInfo2, MV_U32 busClk, MV_U32 forcedCl); -static MV_U32 sdramTimeCtrlLowRegCalc(MV_DRAM_BANK_INFO *pBankInfo, MV_U32 minCas, MV_U32 busClk); -static MV_U32 sdramTimeCtrlHighRegCalc(MV_DRAM_BANK_INFO *pBankInfo, MV_U32 busClk); -static MV_U32 sdramDdr2TimeLoRegCalc(MV_U32 minCas); -static MV_U32 sdramDdr2TimeHiRegCalc(MV_U32 minCas); -#endif -MV_32 DRAM_CS_Order[MV_DRAM_MAX_CS] = {N_A - -#ifdef MV_INCLUDE_SDRAM_CS1 - ,N_A -#endif -#ifdef MV_INCLUDE_SDRAM_CS2 - ,N_A -#endif -#ifdef MV_INCLUDE_SDRAM_CS3 - ,N_A -#endif - }; -/* Get DRAM size of CS num */ -MV_U32 mvDramCsSizeGet(MV_U32 csNum) -{ - MV_DRAM_BANK_INFO bankInfo; - MV_U32 size, deviceW, dimmW; -#ifdef MV78XX0 - MV_U32 temp; -#endif - - if(MV_OK == mvDramBankInfoGet(csNum, &bankInfo)) - { - if (0 == bankInfo.size) - return 0; - - /* Note that the Dimm width might be different then the device DRAM width */ -#ifdef MV78XX0 - temp = MV_REG_READ(SDRAM_CONFIG_REG); - deviceW = ((temp & SDRAM_DWIDTH_MASK) == SDRAM_DWIDTH_32BIT )? 32 : 64; -#else - deviceW = 16 /* KW family */; -#endif - dimmW = bankInfo.dataWidth - (bankInfo.dataWidth % 16); - size = ((bankInfo.size << 20) / (dimmW/deviceW)); - return size; - } - else - return 0; -} -/******************************************************************************* -* mvDramIfDetect - Prepare DRAM interface configuration values. -* -* DESCRIPTION: -* This function implements the full DRAM detection and timing -* configuration for best system performance. -* Since this routine runs from a ROM device (Boot Flash), its stack -* resides on RAM, that might be the system DRAM. Changing DRAM -* configuration values while keeping vital data in DRAM is risky. That -* is why the function does not preform the configuration setting but -* prepare those in predefined 32bit registers (in this case IDMA -* registers are used) for other routine to perform the settings. -* The function will call for board DRAM SPD information for each DRAM -* chip select. The function will then analyze those SPD parameters of -* all DRAM banks in order to decide on DRAM configuration compatible -* for all DRAM banks. -* The function will set the CPU DRAM address decode registers. -* Note: This routine prepares values that will overide configuration of -* mvDramBasicAsmInit(). -* -* INPUT: -* forcedCl - Forced CAL Latency. If equal to zero, do not force. -* eccDisable - Force down the ECC. -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_STATUS mvDramIfDetect(MV_U32 forcedCl, MV_BOOL eccDisable) -{ - MV_32 MV_DRAM_CS_order[MV_DRAM_MAX_CS] = { - SDRAM_CS0 -#ifdef MV_INCLUDE_SDRAM_CS1 - ,SDRAM_CS1 -#endif -#ifdef MV_INCLUDE_SDRAM_CS2 - ,SDRAM_CS2 -#endif -#ifdef MV_INCLUDE_SDRAM_CS3 - ,SDRAM_CS3 -#endif - }; - MV_U32 busClk, deviceW, dimmW; - MV_U32 numOfAllDevices = 0; - MV_STATUS TTMode; -#ifndef MV_STATIC_DRAM_ON_BOARD - MV_DRAM_BANK_INFO bankInfo[MV_DRAM_MAX_CS]; - MV_U32 size, base = 0, i, j, temp, busClkPs; - MV_U8 minCas; - MV_CPU_DEC_WIN dramDecWin; - dramDecWin.addrWin.baseHigh = 0; -#endif - - busClk = mvBoardSysClkGet(); - - if (0 == busClk) - { - mvOsPrintf("Dram: ERR. Can't detect system clock! \n"); - return MV_ERROR; - } - -#ifndef MV_STATIC_DRAM_ON_BOARD - - busClkPs = 1000000000 / (busClk / 1000); /* in ps units */ - /* we will use bank 0 as the representative of the all the DRAM banks, */ - /* since bank 0 must exist. */ - for(i = 0; i < MV_DRAM_MAX_CS; i++) - { - /* if Bank exist */ - if(MV_OK == mvDramBankInfoGet(i, &bankInfo[i])) - { - DB(mvOsPrintf("Dram: Find bank %d\n", i)); - /* check it isn't SDRAM */ - if(bankInfo[i].memoryType != MEM_TYPE_DDR2) - { - mvOsOutput("Dram: ERR. SDRAM type not supported !!!\n"); - return MV_ERROR; - } - - /* All banks must support the Mclk freqency */ - if(bankInfo[i].minCycleTimeAtMaxCasLatPs > busClkPs) - { - mvOsOutput("Dram: ERR. Bank %d doesn't support memory clock!!!\n", i); - return MV_ERROR; - } - - /* All banks must support registry in order to activate it */ - if(bankInfo[i].registeredAddrAndControlInputs != - bankInfo[0].registeredAddrAndControlInputs) - { - mvOsOutput("Dram: ERR. different Registered settings !!!\n"); - return MV_ERROR; - } - - /* All banks must support same ECC mode */ - if(bankInfo[i].errorCheckType != - bankInfo[0].errorCheckType) - { - mvOsOutput("Dram: ERR. different ECC settings !!!\n"); - return MV_ERROR; - } - - } - else - { - if( i == 0 ) /* bank 0 doesn't exist */ - { - mvOsOutput("Dram: ERR. Fail to detect bank 0 !!!\n"); - return MV_ERROR; - } - else - { - DB(mvOsPrintf("Dram: Could not find bank %d\n", i)); - bankInfo[i].size = 0; /* Mark this bank as non exist */ - } - } - } - -#ifdef MV_INCLUDE_SDRAM_CS2 - if (bankInfo[SDRAM_CS0].size < bankInfo[SDRAM_CS2].size) - { - MV_DRAM_CS_order[0] = SDRAM_CS2; - MV_DRAM_CS_order[1] = SDRAM_CS3; - MV_DRAM_CS_order[2] = SDRAM_CS0; - MV_DRAM_CS_order[3] = SDRAM_CS1; - DRAM_CS_Order[0] = SDRAM_CS2; - DRAM_CS_Order[1] = SDRAM_CS3; - DRAM_CS_Order[2] = SDRAM_CS0; - DRAM_CS_Order[3] = SDRAM_CS1; - - } - else -#endif - { - MV_DRAM_CS_order[0] = SDRAM_CS0; - MV_DRAM_CS_order[1] = SDRAM_CS1; - DRAM_CS_Order[0] = SDRAM_CS0; - DRAM_CS_Order[1] = SDRAM_CS1; -#ifdef MV_INCLUDE_SDRAM_CS2 - MV_DRAM_CS_order[2] = SDRAM_CS2; - MV_DRAM_CS_order[3] = SDRAM_CS3; - DRAM_CS_Order[2] = SDRAM_CS2; - DRAM_CS_Order[3] = SDRAM_CS3; -#endif - } - - for(j = 0; j < MV_DRAM_MAX_CS; j++) - { - i = MV_DRAM_CS_order[j]; - - if (0 == bankInfo[i].size) - continue; - - /* Init the CPU window decode */ - /* Note that the Dimm width might be different then the device DRAM width */ -#ifdef MV78XX0 - temp = MV_REG_READ(SDRAM_CONFIG_REG); - deviceW = ((temp & SDRAM_DWIDTH_MASK) == SDRAM_DWIDTH_32BIT )? 32 : 64; -#else - deviceW = 16 /* KW family */; -#endif - dimmW = bankInfo[0].dataWidth - (bankInfo[0].dataWidth % 16); - size = ((bankInfo[i].size << 20) / (dimmW/deviceW)); - - /* We can not change DRAM window settings while excecuting */ - /* code from it. That is why we skip the DRAM CS[0], saving */ - /* it to the ROM configuration routine */ - - numOfAllDevices += bankInfo[i].numberOfDevices; - if (i == MV_DRAM_CS_order[0]) - { - MV_U32 sizeToReg; - /* Translate the given window size to register format */ - sizeToReg = ctrlSizeToReg(size, SCSR_SIZE_ALIGNMENT); - /* Size parameter validity check. */ - if (-1 == sizeToReg) - { - mvOsOutput("DRAM: mvCtrlAddrDecToReg: ERR. Win %d size invalid.\n" - ,i); - return MV_BAD_PARAM; - } - - DB(mvOsPrintf("Dram: Bank 0 Size - %x\n",sizeToReg);) - sizeToReg = (sizeToReg << SCSR_SIZE_OFFS); - sizeToReg |= SCSR_WIN_EN; - MV_REG_WRITE(DRAM_BUF_REG0, sizeToReg); - } - else - { - dramDecWin.addrWin.baseLow = base; - dramDecWin.addrWin.size = size; - dramDecWin.enable = MV_TRUE; - DB(mvOsPrintf("Dram: Enable window %d base 0x%x, size=0x%x\n",i, base, size)); - - /* Check if the DRAM size is more then 3GByte */ - if (base < 0xC0000000) - { - DB(mvOsPrintf("Dram: Enable window %d base 0x%x, size=0x%x\n",i, base, size)); - if (MV_OK != mvCpuIfTargetWinSet(i, &dramDecWin)) - { - mvOsPrintf("Dram: ERR. Fail to set bank %d!!!\n", SDRAM_CS0 + i); - return MV_ERROR; - } - } - } - - base += size; - - /* update the suportedCasLatencies mask */ - bankInfo[0].suportedCasLatencies &= bankInfo[i].suportedCasLatencies; - } - - /* calculate minimum CAS */ - minCas = minCasCalc(&bankInfo[0], &bankInfo[2], busClk, forcedCl); - if (0 == minCas) - { - mvOsOutput("Dram: Warn: Could not find CAS compatible to SysClk %dMhz\n", - (busClk / 1000000)); - - minCas = DDR2_CL_4; /* Continue with this CAS */ - mvOsOutput("Set default CAS latency 4\n"); - } - - /* calc SDRAM_CONFIG_REG and save it to temp register */ - temp = sdramConfigRegCalc(&bankInfo[0],&bankInfo[2], busClk); - if(-1 == temp) - { - mvOsOutput("Dram: ERR. sdramConfigRegCalc failed !!!\n"); - return MV_ERROR; - } - - /* check if ECC is enabled by the user */ - if(eccDisable) - { - /* turn off ECC*/ - temp &= ~BIT18; - } - DB(mvOsPrintf("Dram: sdramConfigRegCalc - %x\n",temp);) - MV_REG_WRITE(DRAM_BUF_REG1, temp); - - /* calc SDRAM_MODE_REG and save it to temp register */ - temp = sdramModeRegCalc(minCas); - if(-1 == temp) - { - mvOsOutput("Dram: ERR. sdramModeRegCalc failed !!!\n"); - return MV_ERROR; - } - DB(mvOsPrintf("Dram: sdramModeRegCalc - %x\n",temp);) - MV_REG_WRITE(DRAM_BUF_REG2, temp); - - /* calc SDRAM_EXTENDED_MODE_REG and save it to temp register */ - temp = sdramExtModeRegCalc(&bankInfo[0], busClk); - if(-1 == temp) - { - mvOsOutput("Dram: ERR. sdramExtModeRegCalc failed !!!\n"); - return MV_ERROR; - } - DB(mvOsPrintf("Dram: sdramExtModeRegCalc - %x\n",temp);) - MV_REG_WRITE(DRAM_BUF_REG10, temp); - - /* calc D_UNIT_CONTROL_LOW and save it to temp register */ - TTMode = MV_FALSE; - DB(mvOsPrintf("Dram: numOfAllDevices = %x\n",numOfAllDevices);) - if( (numOfAllDevices > 9) && (bankInfo[0].registeredAddrAndControlInputs == MV_FALSE) ) - { - if ( ( (numOfAllDevices > 9) && (busClk > MV_BOARD_SYSCLK_200MHZ) ) || - (numOfAllDevices > 18) ) - { - mvOsOutput("Enable 2T "); - TTMode = MV_TRUE; - } - } - - temp = dunitCtrlLowRegCalc(&bankInfo[0], minCas, busClk, TTMode ); - if(-1 == temp) - { - mvOsOutput("Dram: ERR. dunitCtrlLowRegCalc failed !!!\n"); - return MV_ERROR; - } - DB(mvOsPrintf("Dram: dunitCtrlLowRegCalc - %x\n",temp);) - MV_REG_WRITE(DRAM_BUF_REG3, temp); - - /* calc D_UNIT_CONTROL_HIGH and save it to temp register */ - temp = dunitCtrlHighRegCalc(&bankInfo[0], busClk); - if(-1 == temp) - { - mvOsOutput("Dram: ERR. dunitCtrlHighRegCalc failed !!!\n"); - return MV_ERROR; - } - DB(mvOsPrintf("Dram: dunitCtrlHighRegCalc - %x\n",temp);) - /* check if ECC is enabled by the user */ - if(eccDisable) - { - /* turn off sample stage if no ecc */ - temp &= ~SDRAM__D2P_EN;; - } - MV_REG_WRITE(DRAM_BUF_REG13, temp); - - /* calc SDRAM_ADDR_CTRL_REG and save it to temp register */ - temp = sdramAddrCtrlRegCalc(&bankInfo[0],&bankInfo[2]); - if(-1 == temp) - { - mvOsOutput("Dram: ERR. sdramAddrCtrlRegCalc failed !!!\n"); - return MV_ERROR; - } - DB(mvOsPrintf("Dram: sdramAddrCtrlRegCalc - %x\n",temp);) - MV_REG_WRITE(DRAM_BUF_REG4, temp); - - /* calc SDRAM_TIMING_CTRL_LOW_REG and save it to temp register */ - temp = sdramTimeCtrlLowRegCalc(&bankInfo[0], minCas, busClk); - if(-1 == temp) - { - mvOsOutput("Dram: ERR. sdramTimeCtrlLowRegCalc failed !!!\n"); - return MV_ERROR; - } - DB(mvOsPrintf("Dram: sdramTimeCtrlLowRegCalc - %x\n",temp);) - MV_REG_WRITE(DRAM_BUF_REG5, temp); - - /* calc SDRAM_TIMING_CTRL_HIGH_REG and save it to temp register */ - temp = sdramTimeCtrlHighRegCalc(&bankInfo[0], busClk); - if(-1 == temp) - { - mvOsOutput("Dram: ERR. sdramTimeCtrlHighRegCalc failed !!!\n"); - return MV_ERROR; - } - DB(mvOsPrintf("Dram: sdramTimeCtrlHighRegCalc - %x\n",temp);) - MV_REG_WRITE(DRAM_BUF_REG6, temp); - - sdramDDr2OdtConfig(bankInfo); - - /* calc DDR2_SDRAM_TIMING_LOW_REG and save it to temp register */ - temp = sdramDdr2TimeLoRegCalc(minCas); - if(-1 == temp) - { - mvOsOutput("Dram: ERR. sdramDdr2TimeLoRegCalc failed !!!\n"); - return MV_ERROR; - } - DB(mvOsPrintf("Dram: sdramDdr2TimeLoRegCalc - %x\n",temp);) - MV_REG_WRITE(DRAM_BUF_REG11, temp); - - /* calc DDR2_SDRAM_TIMING_HIGH_REG and save it to temp register */ - temp = sdramDdr2TimeHiRegCalc(minCas); - if(-1 == temp) - { - mvOsOutput("Dram: ERR. sdramDdr2TimeHiRegCalc failed !!!\n"); - return MV_ERROR; - } - DB(mvOsPrintf("Dram: sdramDdr2TimeHiRegCalc - %x\n",temp);) - MV_REG_WRITE(DRAM_BUF_REG12, temp); -#endif - - /* Note that DDR SDRAM Address/Control and Data pad calibration */ - /* settings is done in mvSdramIfConfig.s */ - - return MV_OK; -} - - -/******************************************************************************* -* mvDramIfBankBaseGet - Get DRAM interface bank base. -* -* DESCRIPTION: -* This function returns the 32 bit base address of a given DRAM bank. -* -* INPUT: -* bankNum - Bank number. -* -* OUTPUT: -* None. -* -* RETURN: -* DRAM bank size. If bank is disabled or paramter is invalid, the -* function returns -1. -* -*******************************************************************************/ -MV_U32 mvDramIfBankBaseGet(MV_U32 bankNum) -{ - DB(mvOsPrintf("Dram: mvDramIfBankBaseGet Bank %d base addr is %x \n", - bankNum, mvCpuIfTargetWinBaseLowGet(SDRAM_CS0 + bankNum))); - return mvCpuIfTargetWinBaseLowGet(SDRAM_CS0 + bankNum); -} - -/******************************************************************************* -* mvDramIfBankSizeGet - Get DRAM interface bank size. -* -* DESCRIPTION: -* This function returns the size of a given DRAM bank. -* -* INPUT: -* bankNum - Bank number. -* -* OUTPUT: -* None. -* -* RETURN: -* DRAM bank size. If bank is disabled the function return '0'. In case -* or paramter is invalid, the function returns -1. -* -*******************************************************************************/ -MV_U32 mvDramIfBankSizeGet(MV_U32 bankNum) -{ - DB(mvOsPrintf("Dram: mvDramIfBankSizeGet Bank %d size is %x \n", - bankNum, mvCpuIfTargetWinSizeGet(SDRAM_CS0 + bankNum))); - return mvCpuIfTargetWinSizeGet(SDRAM_CS0 + bankNum); -} - - -/******************************************************************************* -* mvDramIfSizeGet - Get DRAM interface total size. -* -* DESCRIPTION: -* This function get the DRAM total size. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* DRAM total size. In case or paramter is invalid, the function -* returns -1. -* -*******************************************************************************/ -MV_U32 mvDramIfSizeGet(MV_VOID) -{ - MV_U32 size = 0, i; - - for(i = 0; i < MV_DRAM_MAX_CS; i++) - size += mvDramIfBankSizeGet(i); - - DB(mvOsPrintf("Dram: mvDramIfSizeGet size is %x \n",size)); - return size; -} - -/******************************************************************************* -* mvDramIfSingleBitErrThresholdSet - Set single bit ECC threshold. -* -* DESCRIPTION: -* The ECC single bit error threshold is the number of single bit -* errors to happen before the Dunit generates an interrupt. -* This function set single bit ECC threshold. -* -* INPUT: -* threshold - threshold. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM if threshold is to big, MV_OK otherwise. -* -*******************************************************************************/ -MV_STATUS mvDramIfSingleBitErrThresholdSet(MV_U32 threshold) -{ - MV_U32 regVal; - - if (threshold > SECR_THRECC_MAX) - { - return MV_BAD_PARAM; - } - - regVal = MV_REG_READ(SDRAM_ECC_CONTROL_REG); - regVal &= ~SECR_THRECC_MASK; - regVal |= ((SECR_THRECC(threshold) & SECR_THRECC_MASK)); - MV_REG_WRITE(SDRAM_ECC_CONTROL_REG, regVal); - - return MV_OK; -} - -#ifndef MV_STATIC_DRAM_ON_BOARD -/******************************************************************************* -* minCasCalc - Calculate the Minimum CAS latency which can be used. -* -* DESCRIPTION: -* Calculate the minimum CAS latency that can be used, base on the DRAM -* parameters and the SDRAM bus Clock freq. -* -* INPUT: -* busClk - the DRAM bus Clock. -* pBankInfo - bank info parameters. -* forcedCl - Forced CAS Latency multiplied by 10. If equal to zero, do not force. -* -* OUTPUT: -* None -* -* RETURN: -* The minimum CAS Latency. The function returns 0 if max CAS latency -* supported by banks is incompatible with system bus clock frequancy. -* -*******************************************************************************/ - -static MV_U32 minCasCalc(MV_DRAM_BANK_INFO *pBankInfo,MV_DRAM_BANK_INFO *pBankInfo2, MV_U32 busClk, MV_U32 forcedCl) -{ - MV_U32 count = 1, j; - MV_U32 busClkPs = 1000000000 / (busClk / 1000); /* in ps units */ - MV_U32 startBit, stopBit; - MV_U32 minCas0 = 0, minCas2 = 0; - - - /* DDR 2: - *******-******-******-******-******-******-******-******* - * bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 * - *******-******-******-******-******-******-******-******* - CAS = * TBD | TBD | 5 | 4 | 3 | 2 | TBD | TBD * - Disco VI= * TBD | TBD | 5 | 4 | 3 | TBD | TBD | TBD * - Disco Duo= * TBD | 6 | 5 | 4 | 3 | TBD | TBD | TBD * - *********************************************************/ - - - /* If we are asked to use the forced CAL we change the suported CAL to be forcedCl only */ - if (forcedCl) - { - mvOsOutput("DRAM: Using forced CL %d.%d\n", (forcedCl / 10), (forcedCl % 10)); - - if (forcedCl == 30) - pBankInfo->suportedCasLatencies = 0x08; - else if (forcedCl == 40) - pBankInfo->suportedCasLatencies = 0x10; - else if (forcedCl == 50) - pBankInfo->suportedCasLatencies = 0x20; - else if (forcedCl == 60) - pBankInfo->suportedCasLatencies = 0x40; - else - { - mvOsPrintf("Forced CL %d.%d not supported. Set default CL 4\n", - (forcedCl / 10), (forcedCl % 10)); - pBankInfo->suportedCasLatencies = 0x10; - } - - return pBankInfo->suportedCasLatencies; - } - - /* go over the supported cas mask from Max Cas down and check if the */ - /* SysClk stands in its time requirments. */ - - DB(mvOsPrintf("Dram: minCasCalc supported mask = %x busClkPs = %x \n", - pBankInfo->suportedCasLatencies,busClkPs )); - count = 1; - for(j = 7; j > 0; j--) - { - if((pBankInfo->suportedCasLatencies >> j) & BIT0 ) - { - /* Reset the bits for CL incompatible for the sysClk */ - switch (count) - { - case 1: - if (pBankInfo->minCycleTimeAtMaxCasLatPs > busClkPs) - pBankInfo->suportedCasLatencies &= ~(BIT0 << j); - count++; - break; - case 2: - if (pBankInfo->minCycleTimeAtMaxCasLatMinus1Ps > busClkPs) - pBankInfo->suportedCasLatencies &= ~(BIT0 << j); - count++; - break; - case 3: - if (pBankInfo->minCycleTimeAtMaxCasLatMinus2Ps > busClkPs) - pBankInfo->suportedCasLatencies &= ~(BIT0 << j); - count++; - break; - default: - pBankInfo->suportedCasLatencies &= ~(BIT0 << j); - break; - } - } - } - - DB(mvOsPrintf("Dram: minCasCalc support = %x (after SysCC calc)\n", - pBankInfo->suportedCasLatencies )); - - count = 1; - DB(mvOsPrintf("Dram2: minCasCalc supported mask = %x busClkPs = %x \n", - pBankInfo2->suportedCasLatencies,busClkPs )); - for(j = 7; j > 0; j--) - { - if((pBankInfo2->suportedCasLatencies >> j) & BIT0 ) - { - /* Reset the bits for CL incompatible for the sysClk */ - switch (count) - { - case 1: - if (pBankInfo2->minCycleTimeAtMaxCasLatPs > busClkPs) - pBankInfo2->suportedCasLatencies &= ~(BIT0 << j); - count++; - break; - case 2: - if (pBankInfo2->minCycleTimeAtMaxCasLatMinus1Ps > busClkPs) - pBankInfo2->suportedCasLatencies &= ~(BIT0 << j); - count++; - break; - case 3: - if (pBankInfo2->minCycleTimeAtMaxCasLatMinus2Ps > busClkPs) - pBankInfo2->suportedCasLatencies &= ~(BIT0 << j); - count++; - break; - default: - pBankInfo2->suportedCasLatencies &= ~(BIT0 << j); - break; - } - } - } - - DB(mvOsPrintf("Dram2: minCasCalc support = %x (after SysCC calc)\n", - pBankInfo2->suportedCasLatencies )); - - startBit = 3; /* DDR2 support CL start with CL3 (bit 3) */ - stopBit = 6; /* DDR2 support CL stops with CL6 (bit 6) */ - - for(j = startBit; j <= stopBit ; j++) - { - if((pBankInfo->suportedCasLatencies >> j) & BIT0 ) - { - DB(mvOsPrintf("Dram: minCasCalc choose CAS %x \n",(BIT0 << j))); - minCas0 = (BIT0 << j); - break; - } - } - - for(j = startBit; j <= stopBit ; j++) - { - if((pBankInfo2->suportedCasLatencies >> j) & BIT0 ) - { - DB(mvOsPrintf("Dram: minCasCalc choose CAS %x \n",(BIT0 << j))); - minCas2 = (BIT0 << j); - break; - } - } - - if (minCas2 > minCas0) - return minCas2; - else - return minCas0; - - return 0; -} - -/******************************************************************************* -* sdramConfigRegCalc - Calculate sdram config register -* -* DESCRIPTION: Calculate sdram config register optimized value based -* on the bank info parameters. -* -* INPUT: -* busClk - the DRAM bus Clock. -* pBankInfo - sdram bank parameters -* -* OUTPUT: -* None -* -* RETURN: -* sdram config reg value. -* -*******************************************************************************/ -static MV_U32 sdramConfigRegCalc(MV_DRAM_BANK_INFO *pBankInfo,MV_DRAM_BANK_INFO *pBankInfo2, MV_U32 busClk) -{ - MV_U32 sdramConfig = 0; - MV_U32 refreshPeriod; - - busClk /= 1000000; /* we work with busClk in MHz */ - - sdramConfig = MV_REG_READ(SDRAM_CONFIG_REG); - - /* figure out the memory refresh internal */ - switch (pBankInfo->refreshInterval & 0xf) - { - case 0x0: /* refresh period is 15.625 usec */ - refreshPeriod = 15625; - break; - case 0x1: /* refresh period is 3.9 usec */ - refreshPeriod = 3900; - break; - case 0x2: /* refresh period is 7.8 usec */ - refreshPeriod = 7800; - break; - case 0x3: /* refresh period is 31.3 usec */ - refreshPeriod = 31300; - break; - case 0x4: /* refresh period is 62.5 usec */ - refreshPeriod = 62500; - break; - case 0x5: /* refresh period is 125 usec */ - refreshPeriod = 125000; - break; - default: /* refresh period undefined */ - mvOsPrintf("Dram: ERR. DRAM refresh period is unknown!\n"); - return -1; - } - - /* Now the refreshPeriod is in register format value */ - refreshPeriod = (busClk * refreshPeriod) / 1000; - - DB(mvOsPrintf("Dram: sdramConfigRegCalc calculated refresh interval %0x\n", - refreshPeriod)); - - /* make sure the refresh value is only 14 bits */ - if(refreshPeriod > SDRAM_REFRESH_MAX) - { - refreshPeriod = SDRAM_REFRESH_MAX; - DB(mvOsPrintf("Dram: sdramConfigRegCalc adjusted refresh interval %0x\n", - refreshPeriod)); - } - - /* Clear the refresh field */ - sdramConfig &= ~SDRAM_REFRESH_MASK; - - /* Set new value to refresh field */ - sdramConfig |= (refreshPeriod & SDRAM_REFRESH_MASK); - - /* registered DRAM ? */ - if ( pBankInfo->registeredAddrAndControlInputs ) - { - /* it's registered DRAM, so set the reg. DRAM bit */ - sdramConfig |= SDRAM_REGISTERED; - DB(mvOsPrintf("DRAM Attribute: Registered address and control inputs.\n");) - } - - /* ECC and IERR support */ - sdramConfig &= ~SDRAM_ECC_MASK; /* Clear ECC field */ - sdramConfig &= ~SDRAM_IERR_MASK; /* Clear IErr field */ - - if ( pBankInfo->errorCheckType ) - { - sdramConfig |= SDRAM_ECC_EN; - sdramConfig |= SDRAM_IERR_REPORTE; - DB(mvOsPrintf("Dram: mvDramIfDetect Enabling ECC\n")); - } - else - { - sdramConfig |= SDRAM_ECC_DIS; - sdramConfig |= SDRAM_IERR_IGNORE; - DB(mvOsPrintf("Dram: mvDramIfDetect Disabling ECC!\n")); - } - /* Set static default settings */ - sdramConfig |= SDRAM_CONFIG_DV; - - DB(mvOsPrintf("Dram: sdramConfigRegCalc set sdramConfig to 0x%x\n", - sdramConfig)); - - return sdramConfig; -} - -/******************************************************************************* -* sdramModeRegCalc - Calculate sdram mode register -* -* DESCRIPTION: Calculate sdram mode register optimized value based -* on the bank info parameters and the minCas. -* -* INPUT: -* minCas - minimum CAS supported. -* -* OUTPUT: -* None -* -* RETURN: -* sdram mode reg value. -* -*******************************************************************************/ -static MV_U32 sdramModeRegCalc(MV_U32 minCas) -{ - MV_U32 sdramMode; - - sdramMode = MV_REG_READ(SDRAM_MODE_REG); - - /* Clear CAS Latency field */ - sdramMode &= ~SDRAM_CL_MASK; - - DB(mvOsPrintf("DRAM CAS Latency ");) - - switch (minCas) - { - case DDR2_CL_3: - sdramMode |= SDRAM_DDR2_CL_3; - DB(mvOsPrintf("3.\n");) - break; - case DDR2_CL_4: - sdramMode |= SDRAM_DDR2_CL_4; - DB(mvOsPrintf("4.\n");) - break; - case DDR2_CL_5: - sdramMode |= SDRAM_DDR2_CL_5; - DB(mvOsPrintf("5.\n");) - break; - case DDR2_CL_6: - sdramMode |= SDRAM_DDR2_CL_6; - DB(mvOsPrintf("6.\n");) - break; - default: - mvOsOutput("\nsdramModeRegCalc ERROR: Max. CL out of range\n"); - return -1; - } - - DB(mvOsPrintf("\nsdramModeRegCalc register 0x%x\n", sdramMode )); - - return sdramMode; -} -/******************************************************************************* -* sdramExtModeRegCalc - Calculate sdram Extended mode register -* -* DESCRIPTION: -* Return sdram Extended mode register value based -* on the bank info parameters and bank presence. -* -* INPUT: -* pBankInfo - sdram bank parameters -* busClk - DRAM frequency -* -* OUTPUT: -* None -* -* RETURN: -* sdram Extended mode reg value. -* -*******************************************************************************/ -static MV_U32 sdramExtModeRegCalc(MV_DRAM_BANK_INFO *pBankInfo, MV_U32 busClk) -{ - MV_U32 populateBanks = 0; - int bankNum; - - /* Represent the populate banks in binary form */ - for(bankNum = 0; bankNum < MV_DRAM_MAX_CS; bankNum++) - { - if (0 != pBankInfo[bankNum].size) - { - populateBanks |= (1 << bankNum); - } - } - - switch(populateBanks) - { - case(BANK_PRESENT_CS0): - case(BANK_PRESENT_CS0_CS1): - return DDR_SDRAM_EXT_MODE_CS0_CS1_DV; - - case(BANK_PRESENT_CS0_CS2): - case(BANK_PRESENT_CS0_CS1_CS2): - case(BANK_PRESENT_CS0_CS2_CS3): - case(BANK_PRESENT_CS0_CS2_CS3_CS4): - if (busClk >= MV_BOARD_SYSCLK_267MHZ) - return DDR_SDRAM_EXT_MODE_FAST_CS0_CS1_CS2_CS3_DV; - else - return DDR_SDRAM_EXT_MODE_CS0_CS1_CS2_CS3_DV; - - default: - mvOsOutput("sdramExtModeRegCalc: Invalid DRAM bank presence\n"); - return -1; - } - return 0; -} - -/******************************************************************************* -* dunitCtrlLowRegCalc - Calculate sdram dunit control low register -* -* DESCRIPTION: Calculate sdram dunit control low register optimized value based -* on the bank info parameters and the minCas. -* -* INPUT: -* pBankInfo - sdram bank parameters -* minCas - minimum CAS supported. -* -* OUTPUT: -* None -* -* RETURN: -* sdram dunit control low reg value. -* -*******************************************************************************/ -static MV_U32 dunitCtrlLowRegCalc(MV_DRAM_BANK_INFO *pBankInfo, MV_U32 minCas, MV_U32 busClk, MV_STATUS TTMode) -{ - MV_U32 dunitCtrlLow, cl; - MV_U32 sbOutR[4]={3,5,7,9} ; - MV_U32 sbOutU[4]={1,3,5,7} ; - - dunitCtrlLow = MV_REG_READ(SDRAM_DUNIT_CTRL_REG); - - DB(mvOsPrintf("Dram: dunitCtrlLowRegCalc\n")); - - /* Clear StBurstOutDel field */ - dunitCtrlLow &= ~SDRAM_SB_OUT_MASK; - - /* Clear StBurstInDel field */ - dunitCtrlLow &= ~SDRAM_SB_IN_MASK; - - /* Clear CtrlPos field */ - dunitCtrlLow &= ~SDRAM_CTRL_POS_MASK; - - /* Clear 2T field */ - dunitCtrlLow &= ~SDRAM_2T_MASK; - if (TTMode == MV_TRUE) - { - dunitCtrlLow |= SDRAM_2T_MODE; - } - - /* For proper sample of read data set the Dunit Control register's */ - /* stBurstInDel bits [27:24] */ - /* 200MHz - 267MHz None reg = CL + 1 */ - /* 200MHz - 267MHz reg = CL + 2 */ - /* > 267MHz None reg = CL + 2 */ - /* > 267MHz reg = CL + 3 */ - - /* For proper sample of read data set the Dunit Control register's */ - /* stBurstOutDel bits [23:20] */ - /********-********-********-********- - * CL=3 | CL=4 | CL=5 | CL=6 | - *********-********-********-********- - Not Reg. * 0001 | 0011 | 0101 | 0111 | - *********-********-********-********- - Registered * 0011 | 0101 | 0111 | 1001 | - *********-********-********-********/ - - /* Set Dunit Control low default value */ - dunitCtrlLow |= SDRAM_DUNIT_CTRL_LOW_DDR2_DV; - - switch (minCas) - { - case DDR2_CL_3: cl = 3; break; - case DDR2_CL_4: cl = 4; break; - case DDR2_CL_5: cl = 5; break; - case DDR2_CL_6: cl = 6; break; - default: - mvOsOutput("Dram: dunitCtrlLowRegCalc Max. CL out of range %d\n", minCas); - return -1; - } - - /* registerd DDR SDRAM? */ - if (pBankInfo->registeredAddrAndControlInputs == MV_TRUE) - { - dunitCtrlLow |= (sbOutR[cl-3]) << SDRAM_SB_OUT_DEL_OFFS; - } - else - { - dunitCtrlLow |= (sbOutU[cl-3]) << SDRAM_SB_OUT_DEL_OFFS; - } - - DB(mvOsPrintf("\n\ndunitCtrlLowRegCalc: CL = %d, frequencies=%d\n", cl, busClk)); - - if (busClk <= MV_BOARD_SYSCLK_267MHZ) - { - if (pBankInfo->registeredAddrAndControlInputs == MV_TRUE) - cl = cl + 2; - else - cl = cl + 1; - } - else - { - if (pBankInfo->registeredAddrAndControlInputs == MV_TRUE) - cl = cl + 3; - else - cl = cl + 2; - } - - DB(mvOsPrintf("dunitCtrlLowRegCalc: SDRAM_SB_IN_DEL_OFFS = %d \n", cl)); - dunitCtrlLow |= cl << SDRAM_SB_IN_DEL_OFFS; - - DB(mvOsPrintf("Dram: Reg dunit control low = %x\n", dunitCtrlLow )); - - return dunitCtrlLow; -} - -/******************************************************************************* -* dunitCtrlHighRegCalc - Calculate sdram dunit control high register -* -* DESCRIPTION: Calculate sdram dunit control high register optimized value based -* on the bus clock. -* -* INPUT: -* busClk - DRAM frequency. -* -* OUTPUT: -* None -* -* RETURN: -* sdram dunit control high reg value. -* -*******************************************************************************/ -static MV_U32 dunitCtrlHighRegCalc(MV_DRAM_BANK_INFO *pBankInfo, MV_U32 busClk) -{ - MV_U32 dunitCtrlHigh; - dunitCtrlHigh = MV_REG_READ(SDRAM_DUNIT_CTRL_HI_REG); - if(busClk > MV_BOARD_SYSCLK_300MHZ) - dunitCtrlHigh |= SDRAM__P2D_EN; - else - dunitCtrlHigh &= ~SDRAM__P2D_EN; - - if(busClk > MV_BOARD_SYSCLK_267MHZ) - dunitCtrlHigh |= (SDRAM__WR_MESH_DELAY_EN | SDRAM__PUP_ZERO_SKEW_EN | SDRAM__ADD_HALF_FCC_EN); - - /* If ECC support we turn on D2P sample */ - dunitCtrlHigh &= ~SDRAM__D2P_EN; /* Clear D2P bit */ - if (( pBankInfo->errorCheckType ) && (busClk > MV_BOARD_SYSCLK_267MHZ)) - dunitCtrlHigh |= SDRAM__D2P_EN; - - return dunitCtrlHigh; -} - -/******************************************************************************* -* sdramAddrCtrlRegCalc - Calculate sdram address control register -* -* DESCRIPTION: Calculate sdram address control register optimized value based -* on the bank info parameters and the minCas. -* -* INPUT: -* pBankInfo - sdram bank parameters -* -* OUTPUT: -* None -* -* RETURN: -* sdram address control reg value. -* -*******************************************************************************/ -static MV_U32 sdramAddrCtrlRegCalc(MV_DRAM_BANK_INFO *pBankInfo, MV_DRAM_BANK_INFO *pBankInfoDIMM1) -{ - MV_U32 addrCtrl = 0; - - if (pBankInfoDIMM1->size) - { - switch (pBankInfoDIMM1->sdramWidth) - { - case 4: /* memory is x4 */ - mvOsOutput("sdramAddrCtrlRegCalc: Error - x4 not supported!\n"); - return -1; - break; - case 8: /* memory is x8 */ - addrCtrl |= SDRAM_ADDRSEL_X8(2) | SDRAM_ADDRSEL_X8(3); - DB(mvOsPrintf("sdramAddrCtrlRegCalc: sdramAddrCtrlRegCalc SDRAM device DIMM2 width x8\n")); - break; - case 16: - addrCtrl |= SDRAM_ADDRSEL_X16(2) | SDRAM_ADDRSEL_X16(3); - DB(mvOsPrintf("sdramAddrCtrlRegCalc: sdramAddrCtrlRegCalc SDRAM device DIMM2 width x16\n")); - break; - default: /* memory width unsupported */ - mvOsOutput("sdramAddrCtrlRegCalc: ERR. DRAM chip width is unknown!\n"); - return -1; - } - } - - switch (pBankInfo->sdramWidth) - { - case 4: /* memory is x4 */ - mvOsOutput("sdramAddrCtrlRegCalc: Error - x4 not supported!\n"); - return -1; - break; - case 8: /* memory is x8 */ - addrCtrl |= SDRAM_ADDRSEL_X8(0) | SDRAM_ADDRSEL_X8(1); - DB(mvOsPrintf("sdramAddrCtrlRegCalc: sdramAddrCtrlRegCalc SDRAM device width x8\n")); - break; - case 16: - addrCtrl |= SDRAM_ADDRSEL_X16(0) | SDRAM_ADDRSEL_X16(1); - DB(mvOsPrintf("sdramAddrCtrlRegCalc: sdramAddrCtrlRegCalc SDRAM device width x16\n")); - break; - default: /* memory width unsupported */ - mvOsOutput("sdramAddrCtrlRegCalc: ERR. DRAM chip width is unknown!\n"); - return -1; - } - - /* Note that density is in MB units */ - switch (pBankInfo->deviceDensity) - { - case 256: /* 256 Mbit */ - DB(mvOsPrintf("DRAM Device Density 256Mbit\n")); - addrCtrl |= SDRAM_DSIZE_256Mb(0) | SDRAM_DSIZE_256Mb(1); - break; - case 512: /* 512 Mbit */ - DB(mvOsPrintf("DRAM Device Density 512Mbit\n")); - addrCtrl |= SDRAM_DSIZE_512Mb(0) | SDRAM_DSIZE_512Mb(1); - break; - case 1024: /* 1 Gbit */ - DB(mvOsPrintf("DRAM Device Density 1Gbit\n")); - addrCtrl |= SDRAM_DSIZE_1Gb(0) | SDRAM_DSIZE_1Gb(1); - break; - case 2048: /* 2 Gbit */ - DB(mvOsPrintf("DRAM Device Density 2Gbit\n")); - addrCtrl |= SDRAM_DSIZE_2Gb(0) | SDRAM_DSIZE_2Gb(1); - break; - default: - mvOsOutput("Dram: sdramAddrCtrl unsupported RAM-Device size %d\n", - pBankInfo->deviceDensity); - return -1; - } - - if (pBankInfoDIMM1->size) - { - switch (pBankInfoDIMM1->deviceDensity) - { - case 256: /* 256 Mbit */ - DB(mvOsPrintf("DIMM2: DRAM Device Density 256Mbit\n")); - addrCtrl |= SDRAM_DSIZE_256Mb(2) | SDRAM_DSIZE_256Mb(3); - break; - case 512: /* 512 Mbit */ - DB(mvOsPrintf("DIMM2: DRAM Device Density 512Mbit\n")); - addrCtrl |= SDRAM_DSIZE_512Mb(2) | SDRAM_DSIZE_512Mb(3); - break; - case 1024: /* 1 Gbit */ - DB(mvOsPrintf("DIMM2: DRAM Device Density 1Gbit\n")); - addrCtrl |= SDRAM_DSIZE_1Gb(2) | SDRAM_DSIZE_1Gb(3); - break; - case 2048: /* 2 Gbit */ - DB(mvOsPrintf("DIMM2: DRAM Device Density 2Gbit\n")); - addrCtrl |= SDRAM_DSIZE_2Gb(2) | SDRAM_DSIZE_2Gb(3); - break; - default: - mvOsOutput("DIMM2: Dram: sdramAddrCtrl unsupported RAM-Device size %d\n", - pBankInfoDIMM1->deviceDensity); - return -1; - } - } - /* SDRAM address control */ - DB(mvOsPrintf("Dram: setting sdram address control with: %x \n", addrCtrl)); - - return addrCtrl; -} - -/******************************************************************************* -* sdramTimeCtrlLowRegCalc - Calculate sdram timing control low register -* -* DESCRIPTION: -* This function calculates sdram timing control low register -* optimized value based on the bank info parameters and the minCas. -* -* INPUT: -* pBankInfo - sdram bank parameters -* minCas - minimum CAS supported. -* busClk - Bus clock -* -* OUTPUT: -* None -* -* RETURN: -* sdram timing control low reg value. -* -*******************************************************************************/ -static MV_U32 sdramTimeCtrlLowRegCalc(MV_DRAM_BANK_INFO *pBankInfo, MV_U32 minCas, MV_U32 busClk) -{ - MV_U32 tRp = 0; - MV_U32 tRrd = 0; - MV_U32 tRcd = 0; - MV_U32 tRas = 0; - MV_U32 tWr = 0; - MV_U32 tWtr = 0; - MV_U32 tRtp = 0; - MV_U32 timeCtrlLow = 0; - - MV_U32 bankNum; - - busClk = busClk / 1000000; /* In MHz */ - - /* Scan all DRAM banks to find maximum timing values */ - for (bankNum = 0; bankNum < MV_DRAM_MAX_CS; bankNum++) - { - tRp = MV_MAX(tRp, pBankInfo[bankNum].minRowPrechargeTime); - tRrd = MV_MAX(tRrd, pBankInfo[bankNum].minRowActiveToRowActive); - tRcd = MV_MAX(tRcd, pBankInfo[bankNum].minRasToCasDelay); - tRas = MV_MAX(tRas, pBankInfo[bankNum].minRasPulseWidth); - } - - /* Extract timing (in ns) from SPD value. We ignore the tenth ns part. */ - /* by shifting the data two bits right. */ - tRp = tRp >> 2; /* For example 0x50 -> 20ns */ - tRrd = tRrd >> 2; - tRcd = tRcd >> 2; - - /* Extract clock cycles from time parameter. We need to round up */ - tRp = ((busClk * tRp) / 1000) + (((busClk * tRp) % 1000) ? 1 : 0); - DB(mvOsPrintf("Dram Timing Low: tRp = %d ", tRp)); - tRrd = ((busClk * tRrd) / 1000) + (((busClk * tRrd) % 1000) ? 1 : 0); - /* JEDEC min reqeirments tRrd = 2 */ - if (tRrd < 2) - tRrd = 2; - DB(mvOsPrintf("tRrd = %d ", tRrd)); - tRcd = ((busClk * tRcd) / 1000) + (((busClk * tRcd) % 1000) ? 1 : 0); - DB(mvOsPrintf("tRcd = %d ", tRcd)); - tRas = ((busClk * tRas) / 1000) + (((busClk * tRas) % 1000) ? 1 : 0); - DB(mvOsPrintf("tRas = %d ", tRas)); - - /* tWr and tWtr is different for DDR1 and DDR2. tRtp is only for DDR2 */ - /* Scan all DRAM banks to find maximum timing values */ - for (bankNum = 0; bankNum < MV_DRAM_MAX_CS; bankNum++) - { - tWr = MV_MAX(tWr, pBankInfo[bankNum].minWriteRecoveryTime); - tWtr = MV_MAX(tWtr, pBankInfo[bankNum].minWriteToReadCmdDelay); - tRtp = MV_MAX(tRtp, pBankInfo[bankNum].minReadToPrechCmdDelay); - } - - /* Extract timing (in ns) from SPD value. We ignore the tenth ns */ - /* part by shifting the data two bits right. */ - tWr = tWr >> 2; /* For example 0x50 -> 20ns */ - tWtr = tWtr >> 2; - tRtp = tRtp >> 2; - /* Extract clock cycles from time parameter. We need to round up */ - tWr = ((busClk * tWr) / 1000) + (((busClk * tWr) % 1000) ? 1 : 0); - DB(mvOsPrintf("tWr = %d ", tWr)); - tWtr = ((busClk * tWtr) / 1000) + (((busClk * tWtr) % 1000) ? 1 : 0); - /* JEDEC min reqeirments tWtr = 2 */ - if (tWtr < 2) - tWtr = 2; - DB(mvOsPrintf("tWtr = %d ", tWtr)); - tRtp = ((busClk * tRtp) / 1000) + (((busClk * tRtp) % 1000) ? 1 : 0); - /* JEDEC min reqeirments tRtp = 2 */ - if (tRtp < 2) - tRtp = 2; - DB(mvOsPrintf("tRtp = %d ", tRtp)); - - /* Note: value of 0 in register means one cycle, 1 means two and so on */ - timeCtrlLow = (((tRp - 1) << SDRAM_TRP_OFFS) | - ((tRrd - 1) << SDRAM_TRRD_OFFS) | - ((tRcd - 1) << SDRAM_TRCD_OFFS) | - (((tRas - 1) << SDRAM_TRAS_OFFS) & SDRAM_TRAS_MASK)| - ((tWr - 1) << SDRAM_TWR_OFFS) | - ((tWtr - 1) << SDRAM_TWTR_OFFS) | - ((tRtp - 1) << SDRAM_TRTP_OFFS)); - - /* Check extended tRas bit */ - if ((tRas - 1) & BIT4) - timeCtrlLow |= (1 << SDRAM_EXT_TRAS_OFFS); - - return timeCtrlLow; -} - -/******************************************************************************* -* sdramTimeCtrlHighRegCalc - Calculate sdram timing control high register -* -* DESCRIPTION: -* This function calculates sdram timing control high register -* optimized value based on the bank info parameters and the bus clock. -* -* INPUT: -* pBankInfo - sdram bank parameters -* busClk - Bus clock -* -* OUTPUT: -* None -* -* RETURN: -* sdram timing control high reg value. -* -*******************************************************************************/ -static MV_U32 sdramTimeCtrlHighRegCalc(MV_DRAM_BANK_INFO *pBankInfo, MV_U32 busClk) -{ - MV_U32 tRfc; - MV_U32 timingHigh; - MV_U32 timeNs = 0; - MV_U32 bankNum; - - busClk = busClk / 1000000; /* In MHz */ - - /* Set DDR timing high register static configuration bits */ - timingHigh = MV_REG_READ(SDRAM_TIMING_CTRL_HIGH_REG); - - /* Set DDR timing high register default value */ - timingHigh |= SDRAM_TIMING_CTRL_HIGH_REG_DV; - - /* Clear tRfc field */ - timingHigh &= ~SDRAM_TRFC_MASK; - - /* Scan all DRAM banks to find maximum timing values */ - for (bankNum = 0; bankNum < MV_DRAM_MAX_CS; bankNum++) - { - timeNs = MV_MAX(timeNs, pBankInfo[bankNum].minRefreshToActiveCmd); - DB(mvOsPrintf("Dram: Timing High: minRefreshToActiveCmd = %d\n", - pBankInfo[bankNum].minRefreshToActiveCmd)); - } - if(busClk >= 333 && mvCtrlModelGet() == MV_78XX0_A1_REV) - { - timingHigh |= 0x1 << SDRAM_TR2W_W2R_OFFS; - } - - tRfc = ((busClk * timeNs) / 1000) + (((busClk * timeNs) % 1000) ? 1 : 0); - /* Note: value of 0 in register means one cycle, 1 means two and so on */ - DB(mvOsPrintf("Dram: Timing High: tRfc = %d\n", tRfc)); - timingHigh |= (((tRfc - 1) & SDRAM_TRFC_MASK) << SDRAM_TRFC_OFFS); - DB(mvOsPrintf("Dram: Timing High: tRfc = %d\n", tRfc)); - - /* SDRAM timing high */ - DB(mvOsPrintf("Dram: setting timing high with: %x \n", timingHigh)); - - return timingHigh; -} -/******************************************************************************* -* sdramDDr2OdtConfig - Set DRAM DDR2 On Die Termination registers. -* -* DESCRIPTION: -* This function config DDR2 On Die Termination (ODT) registers. -* -* INPUT: -* pBankInfo - bank info parameters. -* -* OUTPUT: -* None -* -* RETURN: -* None -*******************************************************************************/ -static void sdramDDr2OdtConfig(MV_DRAM_BANK_INFO *pBankInfo) -{ - MV_U32 populateBanks = 0; - MV_U32 odtCtrlLow, odtCtrlHigh, dunitOdtCtrl; - int bankNum; - - /* Represent the populate banks in binary form */ - for(bankNum = 0; bankNum < MV_DRAM_MAX_CS; bankNum++) - { - if (0 != pBankInfo[bankNum].size) - { - populateBanks |= (1 << bankNum); - } - } - - switch(populateBanks) - { - case(BANK_PRESENT_CS0): - case(BANK_PRESENT_CS0_CS1): - odtCtrlLow = DDR2_ODT_CTRL_LOW_CS0_CS1_DV; - odtCtrlHigh = DDR2_ODT_CTRL_HIGH_CS0_CS1_DV; - dunitOdtCtrl = DDR2_DUNIT_ODT_CTRL_CS0_CS1_DV; - break; - case(BANK_PRESENT_CS0_CS2): - case(BANK_PRESENT_CS0_CS1_CS2): - case(BANK_PRESENT_CS0_CS2_CS3): - case(BANK_PRESENT_CS0_CS2_CS3_CS4): - odtCtrlLow = DDR2_ODT_CTRL_LOW_CS0_CS1_CS2_CS3_DV; - odtCtrlHigh = DDR2_ODT_CTRL_HIGH_CS0_CS1_CS2_CS3_DV; - dunitOdtCtrl = DDR2_DUNIT_ODT_CTRL_CS0_CS1_CS2_CS3_DV; - break; - default: - DB(mvOsPrintf("sdramDDr2OdtConfig: Invalid DRAM bank presence\n")); - return; - } - /* DDR2 SDRAM ODT ctrl low */ - DB(mvOsPrintf("Dram: DDR2 setting ODT ctrl low with: %x \n", odtCtrlLow)); - MV_REG_WRITE(DRAM_BUF_REG7, odtCtrlLow); - - /* DDR2 SDRAM ODT ctrl high */ - DB(mvOsPrintf("Dram: DDR2 setting ODT ctrl high with: %x \n", odtCtrlHigh)); - MV_REG_WRITE(DRAM_BUF_REG8, odtCtrlHigh); - - /* DDR2 DUNIT ODT ctrl */ - if ( ((mvCtrlModelGet() == MV_78XX0_DEV_ID) && (mvCtrlRevGet() == MV_78XX0_Y0_REV)) || - (mvCtrlModelGet() == MV_76100_DEV_ID) || - (mvCtrlModelGet() == MV_78100_DEV_ID) || - (mvCtrlModelGet() == MV_78200_DEV_ID) ) - dunitOdtCtrl &= ~(BIT9|BIT8); /* Clear ODT always on */ - - DB(mvOsPrintf("DUNIT: DDR2 setting ODT ctrl with: %x \n", dunitOdtCtrl)); - MV_REG_WRITE(DRAM_BUF_REG9, dunitOdtCtrl); - return; -} -/******************************************************************************* -* sdramDdr2TimeLoRegCalc - Set DDR2 DRAM Timing Low registers. -* -* DESCRIPTION: -* This function config DDR2 DRAM Timing low registers. -* -* INPUT: -* minCas - minimum CAS supported. -* -* OUTPUT: -* None -* -* RETURN: -* DDR2 sdram timing low reg value. -*******************************************************************************/ -static MV_U32 sdramDdr2TimeLoRegCalc(MV_U32 minCas) -{ - MV_U8 cl = -1; - MV_U32 ddr2TimeLoReg; - - /* read and clear the feilds we are going to set */ - ddr2TimeLoReg = MV_REG_READ(SDRAM_DDR2_TIMING_LO_REG); - ddr2TimeLoReg &= ~(SD2TLR_TODT_ON_RD_MASK | - SD2TLR_TODT_OFF_RD_MASK | - SD2TLR_TODT_ON_CTRL_RD_MASK | - SD2TLR_TODT_OFF_CTRL_RD_MASK); - - if( minCas == DDR2_CL_3 ) - { - cl = 3; - } - else if( minCas == DDR2_CL_4 ) - { - cl = 4; - } - else if( minCas == DDR2_CL_5 ) - { - cl = 5; - } - else if( minCas == DDR2_CL_6 ) - { - cl = 6; - } - else - { - DB(mvOsPrintf("sdramDdr2TimeLoRegCalc: CAS latency %d unsupported. using CAS latency 4\n", - minCas)); - cl = 4; - } - - ddr2TimeLoReg |= ((cl-3) << SD2TLR_TODT_ON_RD_OFFS); - ddr2TimeLoReg |= ( cl << SD2TLR_TODT_OFF_RD_OFFS); - ddr2TimeLoReg |= ( cl << SD2TLR_TODT_ON_CTRL_RD_OFFS); - ddr2TimeLoReg |= ((cl+3) << SD2TLR_TODT_OFF_CTRL_RD_OFFS); - - /* DDR2 SDRAM timing low */ - DB(mvOsPrintf("Dram: DDR2 setting timing low with: %x \n", ddr2TimeLoReg)); - - return ddr2TimeLoReg; -} - -/******************************************************************************* -* sdramDdr2TimeHiRegCalc - Set DDR2 DRAM Timing High registers. -* -* DESCRIPTION: -* This function config DDR2 DRAM Timing high registers. -* -* INPUT: -* minCas - minimum CAS supported. -* -* OUTPUT: -* None -* -* RETURN: -* DDR2 sdram timing high reg value. -*******************************************************************************/ -static MV_U32 sdramDdr2TimeHiRegCalc(MV_U32 minCas) -{ - MV_U8 cl = -1; - MV_U32 ddr2TimeHiReg; - - /* read and clear the feilds we are going to set */ - ddr2TimeHiReg = MV_REG_READ(SDRAM_DDR2_TIMING_HI_REG); - ddr2TimeHiReg &= ~(SD2THR_TODT_ON_WR_MASK | - SD2THR_TODT_OFF_WR_MASK | - SD2THR_TODT_ON_CTRL_WR_MASK | - SD2THR_TODT_OFF_CTRL_WR_MASK); - - if( minCas == DDR2_CL_3 ) - { - cl = 3; - } - else if( minCas == DDR2_CL_4 ) - { - cl = 4; - } - else if( minCas == DDR2_CL_5 ) - { - cl = 5; - } - else if( minCas == DDR2_CL_6 ) - { - cl = 6; - } - else - { - mvOsOutput("sdramDdr2TimeHiRegCalc: CAS latency %d unsupported. using CAS latency 4\n", - minCas); - cl = 4; - } - - ddr2TimeHiReg |= ((cl-3) << SD2THR_TODT_ON_WR_OFFS); - ddr2TimeHiReg |= ( cl << SD2THR_TODT_OFF_WR_OFFS); - ddr2TimeHiReg |= ( cl << SD2THR_TODT_ON_CTRL_WR_OFFS); - ddr2TimeHiReg |= ((cl+3) << SD2THR_TODT_OFF_CTRL_WR_OFFS); - - /* DDR2 SDRAM timin high */ - DB(mvOsPrintf("Dram: DDR2 setting timing high with: %x \n", ddr2TimeHiReg)); - - return ddr2TimeHiReg; -} -#endif - -/******************************************************************************* -* mvDramIfCalGet - Get CAS Latency -* -* DESCRIPTION: -* This function get the CAS Latency. -* -* INPUT: -* None -* -* OUTPUT: -* None -* -* RETURN: -* CAS latency times 10 (to avoid using floating point). -* -*******************************************************************************/ -MV_U32 mvDramIfCalGet(void) -{ - MV_U32 sdramCasLat, casLatMask; - - casLatMask = (MV_REG_READ(SDRAM_MODE_REG) & SDRAM_CL_MASK); - - switch (casLatMask) - { - case SDRAM_DDR2_CL_3: - sdramCasLat = 30; - break; - case SDRAM_DDR2_CL_4: - sdramCasLat = 40; - break; - case SDRAM_DDR2_CL_5: - sdramCasLat = 50; - break; - case SDRAM_DDR2_CL_6: - sdramCasLat = 60; - break; - default: - mvOsOutput("mvDramIfCalGet: Err, unknown DDR2 CAL\n"); - return -1; - } - - return sdramCasLat; -} - - -/******************************************************************************* -* mvDramIfSelfRefreshSet - Put the dram in self refresh mode - -* -* DESCRIPTION: -* add support in power management. -* -* -* INPUT: -* None -* -* OUTPUT: -* None -* -* RETURN: -* None -* -*******************************************************************************/ - -MV_VOID mvDramIfSelfRefreshSet() -{ - MV_U32 operReg; - - operReg = MV_REG_READ(SDRAM_OPERATION_REG); - MV_REG_WRITE(SDRAM_OPERATION_REG ,operReg |SDRAM_CMD_SLF_RFRSH); - /* Read until register is reset to 0 */ - while(MV_REG_READ(SDRAM_OPERATION_REG)); -} -/******************************************************************************* -* mvDramIfDimGetSPDversion - return DIMM SPD version. -* -* DESCRIPTION: -* This function prints the DRAM controller information. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -static void mvDramIfDimGetSPDversion(MV_U32 *pMajor, MV_U32 *pMinor, MV_U32 bankNum) -{ - MV_DIMM_INFO dimmInfo; - if (bankNum >= MV_DRAM_MAX_CS ) - { - DB(mvOsPrintf("Dram: mvDramIfDimGetSPDversion bad params \n")); - return ; - } - memset(&dimmInfo,0,sizeof(dimmInfo)); - if ( MV_OK != dimmSpdGet((MV_U32)(bankNum/2), &dimmInfo)) - { - DB(mvOsPrintf("Dram: ERR dimmSpdGet failed to get dimm info \n")); - return ; - } - *pMajor = dimmInfo.spdRawData[DIMM_SPD_VERSION]/10; - *pMinor = dimmInfo.spdRawData[DIMM_SPD_VERSION]%10; -} -/******************************************************************************* -* mvDramIfShow - Show DRAM controller information. -* -* DESCRIPTION: -* This function prints the DRAM controller information. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -void mvDramIfShow(void) -{ - int i, sdramCasLat, sdramCsSize; - MV_U32 Major=0, Minor=0; - - mvOsOutput("DRAM Controller info:\n"); - - mvOsOutput("Total DRAM "); - mvSizePrint(mvDramIfSizeGet()); - mvOsOutput("\n"); - - for(i = 0; i < MV_DRAM_MAX_CS; i++) - { - sdramCsSize = mvDramIfBankSizeGet(i); - if (sdramCsSize) - { - if (0 == (i & 1)) - { - mvDramIfDimGetSPDversion(&Major, &Minor,i); - mvOsOutput("DIMM %d version %d.%d\n", i/2, Major, Minor); - } - mvOsOutput("\tDRAM CS[%d] ", i); - mvSizePrint(sdramCsSize); - mvOsOutput("\n"); - } - } - sdramCasLat = mvDramIfCalGet(); - - if (MV_REG_READ(SDRAM_CONFIG_REG) & SDRAM_ECC_EN) - { - mvOsOutput("ECC enabled, "); - } - else - { - mvOsOutput("ECC Disabled, "); - } - - if (MV_REG_READ(SDRAM_CONFIG_REG) & SDRAM_REGISTERED) - { - mvOsOutput("Registered DIMM\n"); - } - else - { - mvOsOutput("Non registered DIMM\n"); - } - - mvOsOutput("Configured CAS Latency %d.%d\n", sdramCasLat/10, sdramCasLat%10); -} -/******************************************************************************* -* mvDramIfGetFirstCS - find the DRAM bank on the lower address -* -* -* DESCRIPTION: -* This function return the fisrt CS on address 0 -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* SDRAM_CS0 or SDRAM_CS2 -* -*******************************************************************************/ -MV_U32 mvDramIfGetFirstCS(void) -{ - MV_DRAM_BANK_INFO bankInfo[MV_DRAM_MAX_CS]; - - if (DRAM_CS_Order[0] == N_A) - { - mvDramBankInfoGet(SDRAM_CS0, &bankInfo[SDRAM_CS0]); -#ifdef MV_INCLUDE_SDRAM_CS2 - mvDramBankInfoGet(SDRAM_CS2, &bankInfo[SDRAM_CS2]); -#endif - -#ifdef MV_INCLUDE_SDRAM_CS2 - if (bankInfo[SDRAM_CS0].size < bankInfo[SDRAM_CS2].size) - { - DRAM_CS_Order[0] = SDRAM_CS2; - DRAM_CS_Order[1] = SDRAM_CS3; - DRAM_CS_Order[2] = SDRAM_CS0; - DRAM_CS_Order[3] = SDRAM_CS1; - - return SDRAM_CS2; - } -#endif - DRAM_CS_Order[0] = SDRAM_CS0; - DRAM_CS_Order[1] = SDRAM_CS1; -#ifdef MV_INCLUDE_SDRAM_CS2 - DRAM_CS_Order[2] = SDRAM_CS2; - DRAM_CS_Order[3] = SDRAM_CS3; -#endif - return SDRAM_CS0; - } - return DRAM_CS_Order[0]; -} -/******************************************************************************* -* mvDramIfGetCSorder - -* -* -* DESCRIPTION: -* This function return the fisrt CS on address 0 -* -* INPUT: -* CS number. -* -* OUTPUT: -* CS order. -* -* RETURN: -* SDRAM_CS0 or SDRAM_CS2 -* -* NOTE: mvDramIfGetFirstCS must be caled before this subroutine -*******************************************************************************/ -MV_U32 mvDramIfGetCSorder(MV_U32 csOrder ) -{ - return DRAM_CS_Order[csOrder]; -} - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr2/mvDramIf.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr2/mvDramIf.h deleted file mode 100644 index 23f2e54..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr2/mvDramIf.h +++ /dev/null @@ -1,172 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -#ifndef __INCmvDramIfh -#define __INCmvDramIfh - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* includes */ -#include "ddr2/mvDramIfRegs.h" -#include "ddr2/mvDramIfConfig.h" -#include "ctrlEnv/mvCtrlEnvLib.h" - -/* defines */ -/* DRAM Timing parameters */ -#define SDRAM_TWR 15 /* ns tWr */ -#define SDRAM_TRFC_64_512M_AT_200MHZ 70 /* ns tRfc for dens 64-512 @ 200MHz */ -#define SDRAM_TRFC_64_512M 75 /* ns tRfc for dens 64-512 */ -#define SDRAM_TRFC_1G 120 /* ns tRfc for dens 1GB */ -#define SDRAM_TR2R_CYC 1 /* cycle for tR2r */ - -#define CAL_AUTO_DETECT 0 /* Do not force CAS latancy (mvDramIfDetect) */ -#define ECC_DISABLE 1 /* Force ECC to Disable */ -#define ECC_ENABLE 0 /* Force ECC to ENABLE */ -/* typedefs */ - -/* enumeration for memory types */ -typedef enum _mvMemoryType -{ - MEM_TYPE_SDRAM, - MEM_TYPE_DDR1, - MEM_TYPE_DDR2 -}MV_MEMORY_TYPE; - -/* enumeration for DDR2 supported CAS Latencies */ -typedef enum _mvDimmDdr2Cas -{ - DDR2_CL_3 = 0x08, - DDR2_CL_4 = 0x10, - DDR2_CL_5 = 0x20, - DDR2_CL_6 = 0x40, - DDR2_CL_FAULT -} MV_DIMM_DDR2_CAS; - - -typedef struct _mvDramBankInfo -{ - MV_MEMORY_TYPE memoryType; /* DDR1, DDR2 or SDRAM */ - - /* DIMM dimensions */ - MV_U32 numOfRowAddr; - MV_U32 numOfColAddr; - MV_U32 dataWidth; - MV_U32 errorCheckType; /* ECC , PARITY..*/ - MV_U32 sdramWidth; /* 4,8,16 or 32 */ - MV_U32 errorCheckDataWidth; /* 0 - no, 1 - Yes */ - MV_U32 burstLengthSupported; - MV_U32 numOfBanksOnEachDevice; - MV_U32 suportedCasLatencies; - MV_U32 refreshInterval; - - /* DIMM timing parameters */ - MV_U32 minCycleTimeAtMaxCasLatPs; - MV_U32 minCycleTimeAtMaxCasLatMinus1Ps; - MV_U32 minCycleTimeAtMaxCasLatMinus2Ps; - MV_U32 minRowPrechargeTime; - MV_U32 minRowActiveToRowActive; - MV_U32 minRasToCasDelay; - MV_U32 minRasPulseWidth; - MV_U32 minWriteRecoveryTime; /* DDR2 only */ - MV_U32 minWriteToReadCmdDelay; /* DDR2 only */ - MV_U32 minReadToPrechCmdDelay; /* DDR2 only */ - MV_U32 minRefreshToActiveCmd; /* DDR2 only */ - - /* Parameters calculated from the extracted DIMM information */ - MV_U32 size; - MV_U32 deviceDensity; /* 16,64,128,256 or 512 Mbit */ - MV_U32 numberOfDevices; - - /* DIMM attributes (MV_TRUE for yes) */ - MV_BOOL registeredAddrAndControlInputs; - MV_BOOL registeredDQMBinputs; - -}MV_DRAM_BANK_INFO; - -#include "ddr2/spd/mvSpd.h" - -/* mvDramIf.h API list */ -MV_VOID mvDramIfBasicAsmInit(MV_VOID); -MV_STATUS mvDramIfDetect(MV_U32 forcedCl, MV_BOOL eccDisable); -MV_VOID _mvDramIfConfig(int entryNum); - -MV_U32 mvDramIfBankSizeGet(MV_U32 bankNum); -MV_U32 mvDramIfBankBaseGet(MV_U32 bankNum); -MV_U32 mvDramIfSizeGet(MV_VOID); -MV_U32 mvDramIfCalGet(void); -MV_STATUS mvDramIfSingleBitErrThresholdSet(MV_U32 threshold); -MV_VOID mvDramIfSelfRefreshSet(void); -void mvDramIfShow(void); -MV_U32 mvDramIfGetFirstCS(void); -MV_U32 mvDramIfGetCSorder(MV_U32 csOrder ); -MV_U32 mvDramCsSizeGet(MV_U32 csNum); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __INCmvDramIfh */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr2/mvDramIfConfig.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr2/mvDramIfConfig.h deleted file mode 100644 index 6141c46..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr2/mvDramIfConfig.h +++ /dev/null @@ -1,157 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -#ifndef __INCmvDramIfConfigh -#define __INCmvDramIfConfigh - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* includes */ - -/* defines */ - -/* registers defaults values */ - -#define SDRAM_CONFIG_DV (SDRAM_SRMODE_DRAM | BIT25 | BIT30) - -#define SDRAM_DUNIT_CTRL_LOW_DDR2_DV \ - (SDRAM_SRCLK_KEPT | \ - SDRAM_CLK1DRV_NORMAL | \ - (BIT28 | BIT29)) - -#define SDRAM_ADDR_CTRL_DV 2 - -#define SDRAM_TIMING_CTRL_LOW_REG_DV \ - ((0x2 << SDRAM_TRCD_OFFS) | \ - (0x2 << SDRAM_TRP_OFFS) | \ - (0x1 << SDRAM_TWR_OFFS) | \ - (0x0 << SDRAM_TWTR_OFFS) | \ - (0x5 << SDRAM_TRAS_OFFS) | \ - (0x1 << SDRAM_TRRD_OFFS)) - -/* Note: value of 0 in register means one cycle, 1 means two and so on */ -#define SDRAM_TIMING_CTRL_HIGH_REG_DV \ - ((0x0 << SDRAM_TR2R_OFFS) | \ - (0x0 << SDRAM_TR2W_W2R_OFFS) | \ - (0x1 << SDRAM_TW2W_OFFS)) - -#define SDRAM_OPEN_PAGES_CTRL_REG_DV SDRAM_OPEN_PAGE_EN - -/* Presence Ctrl Low Ctrl High Dunit Ctrl Ext Mode */ -/* CS0 0x84210000 0x00000000 0x0000780F 0x00000440 */ -/* CS0+CS1 0x84210000 0x00000000 0x0000780F 0x00000440 */ -/* CS0+CS2 0x030C030C 0x00000000 0x0000740F 0x00000404 */ -/* CS0+CS1+CS2 0x030C030C 0x00000000 0x0000740F 0x00000404 */ -/* CS0+CS2+CS3 0x030C030C 0x00000000 0x0000740F 0x00000404 */ -/* CS0+CS1+CS2+CS3 0x030C030C 0x00000000 0x0000740F 0x00000404 */ - -#define DDR2_ODT_CTRL_LOW_CS0_CS1_DV 0x84210000 -#define DDR2_ODT_CTRL_HIGH_CS0_CS1_DV 0x00000000 -#define DDR2_DUNIT_ODT_CTRL_CS0_CS1_DV 0x0000E80F -#ifdef MV78XX0 -#define DDR_SDRAM_EXT_MODE_CS0_CS1_DV 0x00000040 -#else -#define DDR_SDRAM_EXT_MODE_CS0_CS1_DV 0x00000440 -#endif - -#define DDR2_ODT_CTRL_LOW_CS0_CS1_CS2_CS3_DV 0x030C030C -#define DDR2_ODT_CTRL_HIGH_CS0_CS1_CS2_CS3_DV 0x00000000 -#define DDR2_DUNIT_ODT_CTRL_CS0_CS1_CS2_CS3_DV 0x0000F40F -#ifdef MV78XX0 -#define DDR_SDRAM_EXT_MODE_CS0_CS1_CS2_CS3_DV 0x00000004 -#define DDR_SDRAM_EXT_MODE_FAST_CS0_CS1_CS2_CS3_DV 0x00000044 -#else -#define DDR_SDRAM_EXT_MODE_CS0_CS1_CS2_CS3_DV 0x00000404 -#define DDR_SDRAM_EXT_MODE_FAST_CS0_CS1_CS2_CS3_DV 0x00000444 -#endif - -/* DDR SDRAM Adderss/Control and Data Pads Calibration default values */ -#define DDR2_ADDR_CTRL_PAD_STRENGTH_TYPICAL_DV \ - (3 << SDRAM_PRE_DRIVER_STRENGTH_OFFS) - -#define DDR2_DATA_PAD_STRENGTH_TYPICAL_DV \ - (3 << SDRAM_PRE_DRIVER_STRENGTH_OFFS) - -/* DDR SDRAM Mode Register default value */ -#define DDR2_MODE_REG_DV (SDRAM_BURST_LEN_4 | SDRAM_WR_3_CYC) -/* DDR SDRAM Timing parameter default values */ -#define SDRAM_TIMING_CTRL_LOW_REG_DEFAULT 0x33136552 -#define SDRAM_TRFC_DEFAULT_VALUE 0x34 -#define SDRAM_TRFC_DEFAULT SDRAM_TRFC_DEFAULT_VALUE -#define SDRAM_TW2W_DEFALT (0x1 << SDRAM_TW2W_OFFS) - -#define SDRAM_TIMING_CTRL_HIGH_REG_DEFAULT (SDRAM_TRFC_DEFAULT | SDRAM_TW2W_DEFALT) - -#define SDRAM_FTDLL_REG_DEFAULT_LEFT 0x88C800 -#define SDRAM_FTDLL_REG_DEFAULT_RIGHT 0x88C800 -#define SDRAM_FTDLL_REG_DEFAULT_UP 0x88C800 - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __INCmvDramIfh */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr2/mvDramIfRegs.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr2/mvDramIfRegs.h deleted file mode 100644 index 369eda6..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr2/mvDramIfRegs.h +++ /dev/null @@ -1,423 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCmvDramIfRegsh -#define __INCmvDramIfRegsh - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* DDR SDRAM Controller Address Decode Registers */ - /* SDRAM CSn Base Address Register (SCBAR) */ -#define SDRAM_BASE_ADDR_REG(cpu,csNum) (0x1500 + ((csNum) * 8) + ((cpu) * 0x70)) -#define SCBAR_BASE_OFFS 16 -#define SCBAR_BASE_MASK (0xffff << SCBAR_BASE_OFFS) -#define SCBAR_BASE_ALIGNMENT 0x10000 - -/* SDRAM CSn Size Register (SCSR) */ -#define SDRAM_SIZE_REG(cpu,csNum) (0x1504 + ((csNum) * 8) + ((cpu) * 0x70)) -#define SCSR_SIZE_OFFS 24 -#define SCSR_SIZE_MASK (0xff << SCSR_SIZE_OFFS) -#define SCSR_SIZE_ALIGNMENT 0x1000000 -#define SCSR_WIN_EN BIT0 - -/* configuration register */ -#define SDRAM_CONFIG_REG (DRAM_BASE + 0x1400) -#define SDRAM_REFRESH_OFFS 0 -#define SDRAM_REFRESH_MAX 0x3FFF -#define SDRAM_REFRESH_MASK (SDRAM_REFRESH_MAX << SDRAM_REFRESH_OFFS) -#define SDRAM_DWIDTH_OFFS 15 -#define SDRAM_DWIDTH_MASK (1 << SDRAM_DWIDTH_OFFS) -#define SDRAM_DWIDTH_32BIT (0 << SDRAM_DWIDTH_OFFS) -#define SDRAM_DWIDTH_64BIT (1 << SDRAM_DWIDTH_OFFS) -#define SDRAM_REGISTERED (1 << 17) -#define SDRAM_ECC_OFFS 18 -#define SDRAM_ECC_MASK (1 << SDRAM_ECC_OFFS) -#define SDRAM_ECC_DIS (0 << SDRAM_ECC_OFFS) -#define SDRAM_ECC_EN (1 << SDRAM_ECC_OFFS) -#define SDRAM_IERR_OFFS 19 -#define SDRAM_IERR_MASK (1 << SDRAM_IERR_OFFS) -#define SDRAM_IERR_REPORTE (0 << SDRAM_IERR_OFFS) -#define SDRAM_IERR_IGNORE (1 << SDRAM_IERR_OFFS) -#define SDRAM_SRMODE_OFFS 24 -#define SDRAM_SRMODE_MASK (1 << SDRAM_SRMODE_OFFS) -#define SDRAM_SRMODE_POWER (0 << SDRAM_SRMODE_OFFS) -#define SDRAM_SRMODE_DRAM (1 << SDRAM_SRMODE_OFFS) - -/* dunit control low register */ -#define SDRAM_DUNIT_CTRL_REG (DRAM_BASE + 0x1404) -#define SDRAM_2T_OFFS 4 -#define SDRAM_2T_MASK (1 << SDRAM_2T_OFFS) -#define SDRAM_2T_MODE (1 << SDRAM_2T_OFFS) - -#define SDRAM_SRCLK_OFFS 5 -#define SDRAM_SRCLK_MASK (1 << SDRAM_SRCLK_OFFS) -#define SDRAM_SRCLK_KEPT (0 << SDRAM_SRCLK_OFFS) -#define SDRAM_SRCLK_GATED (1 << SDRAM_SRCLK_OFFS) -#define SDRAM_CTRL_POS_OFFS 6 -#define SDRAM_CTRL_POS_MASK (1 << SDRAM_CTRL_POS_OFFS) -#define SDRAM_CTRL_POS_FALL (0 << SDRAM_CTRL_POS_OFFS) -#define SDRAM_CTRL_POS_RISE (1 << SDRAM_CTRL_POS_OFFS) -#define SDRAM_CLK1DRV_OFFS 12 -#define SDRAM_CLK1DRV_MASK (1 << SDRAM_CLK1DRV_OFFS) -#define SDRAM_CLK1DRV_HIGH_Z (0 << SDRAM_CLK1DRV_OFFS) -#define SDRAM_CLK1DRV_NORMAL (1 << SDRAM_CLK1DRV_OFFS) -#define SDRAM_CLK2DRV_OFFS 13 -#define SDRAM_CLK2DRV_MASK (1 << SDRAM_CLK2DRV_OFFS) -#define SDRAM_CLK2DRV_HIGH_Z (0 << SDRAM_CLK2DRV_OFFS) -#define SDRAM_CLK2DRV_NORMAL (1 << SDRAM_CLK2DRV_OFFS) -#define SDRAM_SB_OUT_DEL_OFFS 20 -#define SDRAM_SB_OUT_DEL_MAX 0xf -#define SDRAM_SB_OUT_MASK (SDRAM_SB_OUT_DEL_MAX<<SDRAM_SB_OUT_DEL_OFFS) -#define SDRAM_SB_IN_DEL_OFFS 24 -#define SDRAM_SB_IN_DEL_MAX 0xf -#define SDRAM_SB_IN_MASK (SDRAM_SB_IN_DEL_MAX<<SDRAM_SB_IN_DEL_OFFS) - -/* dunit control hight register */ -#define SDRAM_DUNIT_CTRL_HI_REG (DRAM_BASE + 0x1424) -#define SDRAM__D2P_OFFS 7 -#define SDRAM__D2P_EN (1 << SDRAM__D2P_OFFS) -#define SDRAM__P2D_OFFS 8 -#define SDRAM__P2D_EN (1 << SDRAM__P2D_OFFS) -#define SDRAM__ADD_HALF_FCC_OFFS 9 -#define SDRAM__ADD_HALF_FCC_EN (1 << SDRAM__ADD_HALF_FCC_OFFS) -#define SDRAM__PUP_ZERO_SKEW_OFFS 10 -#define SDRAM__PUP_ZERO_SKEW_EN (1 << SDRAM__PUP_ZERO_SKEW_OFFS) -#define SDRAM__WR_MESH_DELAY_OFFS 11 -#define SDRAM__WR_MESH_DELAY_EN (1 << SDRAM__WR_MESH_DELAY_OFFS) - -/* sdram timing control low register */ -#define SDRAM_TIMING_CTRL_LOW_REG (DRAM_BASE + 0x1408) -#define SDRAM_TRCD_OFFS 4 -#define SDRAM_TRCD_MASK (0xF << SDRAM_TRCD_OFFS) -#define SDRAM_TRP_OFFS 8 -#define SDRAM_TRP_MASK (0xF << SDRAM_TRP_OFFS) -#define SDRAM_TWR_OFFS 12 -#define SDRAM_TWR_MASK (0xF << SDRAM_TWR_OFFS) -#define SDRAM_TWTR_OFFS 16 -#define SDRAM_TWTR_MASK (0xF << SDRAM_TWTR_OFFS) -#define SDRAM_TRAS_OFFS 0 -#define SDRAM_TRAS_MASK (0xF << SDRAM_TRAS_OFFS) -#define SDRAM_EXT_TRAS_OFFS 20 -#define SDRAM_EXT_TRAS_MASK (0x1 << SDRAM_EXT_TRAS_OFFS) -#define SDRAM_TRRD_OFFS 24 -#define SDRAM_TRRD_MASK (0xF << SDRAM_TRRD_OFFS) -#define SDRAM_TRTP_OFFS 28 -#define SDRAM_TRTP_MASK (0xF << SDRAM_TRTP_OFFS) -#define SDRAM_TRTP_DDR1 (0x1 << SDRAM_TRTP_OFFS) - -/* sdram timing control high register */ -#define SDRAM_TIMING_CTRL_HIGH_REG (DRAM_BASE + 0x140c) -#define SDRAM_TRFC_OFFS 0 -#define SDRAM_TRFC_MASK (0x3F << SDRAM_TRFC_OFFS) -#define SDRAM_TR2R_OFFS 7 -#define SDRAM_TR2R_MASK (0x3 << SDRAM_TR2R_OFFS) -#define SDRAM_TR2W_W2R_OFFS 9 -#define SDRAM_TR2W_W2R_MASK (0x3 << SDRAM_TR2W_W2R_OFFS) -#define SDRAM_TW2W_OFFS 11 -#define SDRAM_TW2W_MASK (0x3 << SDRAM_TW2W_OFFS) - -/* sdram DDR2 timing low register (SD2TLR) */ -#define SDRAM_DDR2_TIMING_LO_REG (DRAM_BASE + 0x1428) -#define SD2TLR_TODT_ON_RD_OFFS 4 -#define SD2TLR_TODT_ON_RD_MASK (0xF << SD2TLR_TODT_ON_RD_OFFS) -#define SD2TLR_TODT_OFF_RD_OFFS 8 -#define SD2TLR_TODT_OFF_RD_MASK (0xF << SD2TLR_TODT_OFF_RD_OFFS) -#define SD2TLR_TODT_ON_CTRL_RD_OFFS 12 -#define SD2TLR_TODT_ON_CTRL_RD_MASK (0xF << SD2TLR_TODT_ON_CTRL_RD_OFFS) -#define SD2TLR_TODT_OFF_CTRL_RD_OFFS 16 -#define SD2TLR_TODT_OFF_CTRL_RD_MASK (0xF << SD2TLR_TODT_OFF_CTRL_RD_OFFS) - -/* sdram DDR2 timing high register (SD2TLR) */ -#define SDRAM_DDR2_TIMING_HI_REG (DRAM_BASE + 0x147C) -#define SD2THR_TODT_ON_WR_OFFS 0 -#define SD2THR_TODT_ON_WR_MASK (0xF << SD2THR_TODT_ON_WR_OFFS) -#define SD2THR_TODT_OFF_WR_OFFS 4 -#define SD2THR_TODT_OFF_WR_MASK (0xF << SD2THR_TODT_OFF_WR_OFFS) -#define SD2THR_TODT_ON_CTRL_WR_OFFS 8 -#define SD2THR_TODT_ON_CTRL_WR_MASK (0xF << SD2THR_TODT_ON_CTRL_WR_OFFS) -#define SD2THR_TODT_OFF_CTRL_WR_OFFS 12 -#define SD2THR_TODT_OFF_CTRL_WR_MASK (0xF << SD2THR_TODT_OFF_CTRL_WR_OFFS) - -/* address control register */ -#define SDRAM_ADDR_CTRL_REG (DRAM_BASE + 0x1410) -#define SDRAM_ADDRSEL_OFFS(cs) (4 * (cs)) -#define SDRAM_ADDRSEL_MASK(cs) (0x3 << SDRAM_ADDRSEL_OFFS(cs)) -#define SDRAM_ADDRSEL_X8(cs) (0x0 << SDRAM_ADDRSEL_OFFS(cs)) -#define SDRAM_ADDRSEL_X16(cs) (0x1 << SDRAM_ADDRSEL_OFFS(cs)) -#define SDRAM_DSIZE_OFFS(cs) (2 + 4 * (cs)) -#define SDRAM_DSIZE_MASK(cs) (0x3 << SDRAM_DSIZE_OFFS(cs)) -#define SDRAM_DSIZE_256Mb(cs) (0x1 << SDRAM_DSIZE_OFFS(cs)) -#define SDRAM_DSIZE_512Mb(cs) (0x2 << SDRAM_DSIZE_OFFS(cs)) -#define SDRAM_DSIZE_1Gb(cs) (0x3 << SDRAM_DSIZE_OFFS(cs)) -#define SDRAM_DSIZE_2Gb(cs) (0x0 << SDRAM_DSIZE_OFFS(cs)) - -/* SDRAM Open Pages Control registers */ -#define SDRAM_OPEN_PAGE_CTRL_REG (DRAM_BASE + 0x1414) -#define SDRAM_OPEN_PAGE_EN (0 << 0) -#define SDRAM_OPEN_PAGE_DIS (1 << 0) - -/* sdram opertion register */ -#define SDRAM_OPERATION_REG (DRAM_BASE + 0x1418) -#define SDRAM_CMD_OFFS 0 -#define SDRAM_CMD_MASK (0xF << SDRAM_CMD_OFFS) -#define SDRAM_CMD_NORMAL (0x0 << SDRAM_CMD_OFFS) -#define SDRAM_CMD_PRECHARGE_ALL (0x1 << SDRAM_CMD_OFFS) -#define SDRAM_CMD_REFRESH_ALL (0x2 << SDRAM_CMD_OFFS) -#define SDRAM_CMD_REG_SET_CMD (0x3 << SDRAM_CMD_OFFS) -#define SDRAM_CMD_EXT_MODE_SET (0x4 << SDRAM_CMD_OFFS) -#define SDRAM_CMD_NOP (0x5 << SDRAM_CMD_OFFS) -#define SDRAM_CMD_SLF_RFRSH (0x7 << SDRAM_CMD_OFFS) -#define SDRAM_CMD_EMRS2_CMD (0x8 << SDRAM_CMD_OFFS) -#define SDRAM_CMD_EMRS3_CMD (0x9 << SDRAM_CMD_OFFS) - -/* sdram mode register */ -#define SDRAM_MODE_REG (DRAM_BASE + 0x141c) -#define SDRAM_BURST_LEN_OFFS 0 -#define SDRAM_BURST_LEN_MASK (0x7 << SDRAM_BURST_LEN_OFFS) -#define SDRAM_BURST_LEN_4 (0x2 << SDRAM_BURST_LEN_OFFS) -#define SDRAM_CL_OFFS 4 -#define SDRAM_CL_MASK (0x7 << SDRAM_CL_OFFS) -#define SDRAM_DDR2_CL_3 (0x3 << SDRAM_CL_OFFS) -#define SDRAM_DDR2_CL_4 (0x4 << SDRAM_CL_OFFS) -#define SDRAM_DDR2_CL_5 (0x5 << SDRAM_CL_OFFS) -#define SDRAM_DDR2_CL_6 (0x6 << SDRAM_CL_OFFS) - -#define SDRAM_TM_OFFS 7 -#define SDRAM_TM_MASK (1 << SDRAM_TM_OFFS) -#define SDRAM_TM_NORMAL (0 << SDRAM_TM_OFFS) -#define SDRAM_TM_TEST_MODE (1 << SDRAM_TM_OFFS) -#define SDRAM_DLL_OFFS 8 -#define SDRAM_DLL_MASK (1 << SDRAM_DLL_OFFS) -#define SDRAM_DLL_NORMAL (0 << SDRAM_DLL_OFFS) -#define SDRAM_DLL_RESET (1 << SDRAM_DLL_OFFS) -#define SDRAM_WR_OFFS 9 -#define SDRAM_WR_MAX 7 -#define SDRAM_WR_MASK (SDRAM_WR_MAX << SDRAM_WR_OFFS) -#define SDRAM_WR_2_CYC (1 << SDRAM_WR_OFFS) -#define SDRAM_WR_3_CYC (2 << SDRAM_WR_OFFS) -#define SDRAM_WR_4_CYC (3 << SDRAM_WR_OFFS) -#define SDRAM_WR_5_CYC (4 << SDRAM_WR_OFFS) -#define SDRAM_WR_6_CYC (5 << SDRAM_WR_OFFS) -#define SDRAM_PD_OFFS 12 -#define SDRAM_PD_MASK (1 << SDRAM_PD_OFFS) -#define SDRAM_PD_FAST_EXIT (0 << SDRAM_PD_OFFS) -#define SDRAM_PD_SLOW_EXIT (1 << SDRAM_PD_OFFS) - -/* DDR SDRAM Extended Mode register (DSEMR) */ -#define SDRAM_EXTENDED_MODE_REG (DRAM_BASE + 0x1420) -#define DSEMR_DLL_ENABLE 0 -#define DSEMR_DLL_DISABLE 1 -#define DSEMR_DS_OFFS 1 -#define DSEMR_DS_MASK (1 << DSEMR_DS_OFFS) -#define DSEMR_DS_NORMAL (0 << DSEMR_DS_OFFS) -#define DSEMR_DS_REDUCED (1 << DSEMR_DS_OFFS) -#define DSEMR_QOFF_OUTPUT_BUFF_EN (0 << 12) -#define DSEMR_RTT0_OFFS 2 -#define DSEMR_RTT1_OFFS 6 -#define DSEMR_RTT_ODT_DISABLE ((0 << DSEMR_RTT0_OFFS)||(0 << DSEMR_RTT1_OFFS)) -#define DSEMR_RTT_ODT_75_OHM ((1 << DSEMR_RTT0_OFFS)||(0 << DSEMR_RTT1_OFFS)) -#define DSEMR_RTT_ODT_150_OHM ((0 << DSEMR_RTT0_OFFS)||(1 << DSEMR_RTT1_OFFS)) -#define DSEMR_RTT_ODT_50_OHM ((1 << DSEMR_RTT0_OFFS)||(1 << DSEMR_RTT1_OFFS)) -#define DSEMR_DQS_OFFS 10 -#define DSEMR_DQS_MASK (1 << DSEMR_DQS_OFFS) -#define DSEMR_DQS_DIFFERENTIAL (0 << DSEMR_DQS_OFFS) -#define DSEMR_DQS_SINGLE_ENDED (1 << DSEMR_DQS_OFFS) -#define DSEMR_RDQS_ENABLE (1 << 11) -#define DSEMR_QOFF_OUTPUT_BUFF_EN (0 << 12) -#define DSEMR_QOFF_OUTPUT_BUFF_DIS (1 << 12) - -/* DDR SDRAM Operation Control Register */ -#define SDRAM_OPERATION_CTRL_REG (DRAM_BASE + 0x142c) - -/* Dunit FTDLL Configuration Register */ -#define SDRAM_FTDLL_CONFIG_LEFT_REG (DRAM_BASE + 0x1484) -#define SDRAM_FTDLL_CONFIG_RIGHT_REG (DRAM_BASE + 0x161C) -#define SDRAM_FTDLL_CONFIG_UP_REG (DRAM_BASE + 0x1620) - -/* Pads Calibration register */ -#define SDRAM_ADDR_CTRL_PADS_CAL_REG (DRAM_BASE + 0x14c0) -#define SDRAM_DATA_PADS_CAL_REG (DRAM_BASE + 0x14c4) -#define SDRAM_DRVN_OFFS 0 -#define SDRAM_DRVN_MASK (0x3F << SDRAM_DRVN_OFFS) -#define SDRAM_DRVP_OFFS 6 -#define SDRAM_DRVP_MASK (0x3F << SDRAM_DRVP_OFFS) -#define SDRAM_PRE_DRIVER_STRENGTH_OFFS 12 -#define SDRAM_PRE_DRIVER_STRENGTH_MASK (3 << SDRAM_PRE_DRIVER_STRENGTH_OFFS) -#define SDRAM_TUNE_EN BIT16 -#define SDRAM_LOCKN_OFFS 17 -#define SDRAM_LOCKN_MAKS (0x3F << SDRAM_LOCKN_OFFS) -#define SDRAM_LOCKP_OFFS 23 -#define SDRAM_LOCKP_MAKS (0x3F << SDRAM_LOCKP_OFFS) -#define SDRAM_WR_EN (1 << 31) - -/* DDR2 SDRAM ODT Control (Low) Register (DSOCLR) */ -#define DDR2_SDRAM_ODT_CTRL_LOW_REG (DRAM_BASE + 0x1494) -#define DSOCLR_ODT_RD_OFFS(odtNum) (odtNum * 4) -#define DSOCLR_ODT_RD_MASK(odtNum) (0xf << DSOCLR_ODT_RD_OFFS(odtNum)) -#define DSOCLR_ODT_RD(odtNum, bank) ((1 << bank) << DSOCLR_ODT_RD_OFFS(odtNum)) -#define DSOCLR_ODT_WR_OFFS(odtNum) (16 + (odtNum * 4)) -#define DSOCLR_ODT_WR_MASK(odtNum) (0xf << DSOCLR_ODT_WR_OFFS(odtNum)) -#define DSOCLR_ODT_WR(odtNum, bank) ((1 << bank) << DSOCLR_ODT_WR_OFFS(odtNum)) - -/* DDR2 SDRAM ODT Control (High) Register (DSOCHR) */ -#define DDR2_SDRAM_ODT_CTRL_HIGH_REG (DRAM_BASE + 0x1498) -/* Optional control values to DSOCHR_ODT_EN macro */ -#define DDR2_ODT_CTRL_DUNIT 0 -#define DDR2_ODT_CTRL_NEVER 1 -#define DDR2_ODT_CTRL_ALWAYS 3 -#define DSOCHR_ODT_EN_OFFS(odtNum) (odtNum * 2) -#define DSOCHR_ODT_EN_MASK(odtNum) (0x3 << DSOCHR_ODT_EN_OFFS(odtNum)) -#define DSOCHR_ODT_EN(odtNum, ctrl) (ctrl << DSOCHR_ODT_EN_OFFS(odtNum)) - -/* DDR2 Dunit ODT Control Register (DDOCR)*/ -#define DDR2_DUNIT_ODT_CONTROL_REG (DRAM_BASE + 0x149c) -#define DDOCR_ODT_RD_OFFS 0 -#define DDOCR_ODT_RD_MASK (0xf << DDOCR_ODT_RD_OFFS) -#define DDOCR_ODT_RD(bank) ((1 << bank) << DDOCR_ODT_RD_OFFS) -#define DDOCR_ODT_WR_OFFS 4 -#define DDOCR_ODT_WR_MASK (0xf << DDOCR_ODT_WR_OFFS) -#define DDOCR_ODT_WR(bank) ((1 << bank) << DDOCR_ODT_WR_OFFS) -#define DSOCR_ODT_EN_OFFS 8 -#define DSOCR_ODT_EN_MASK (0x3 << DSOCR_ODT_EN_OFFS) -/* For ctrl parameters see DDR2 SDRAM ODT Control (High) Register (0x1498) above. */ -#define DSOCR_ODT_EN(ctrl) (ctrl << DSOCR_ODT_EN_OFFS) -#define DSOCR_ODT_SEL_DISABLE 0 -#define DSOCR_ODT_SEL_75_OHM 2 -#define DSOCR_ODT_SEL_150_OHM 1 -#define DSOCR_ODT_SEL_50_OHM 3 -#define DSOCR_DQ_ODT_SEL_OFFS 10 -#define DSOCR_DQ_ODT_SEL_MASK (0x3 << DSOCR_DQ_ODT_SEL_OFFS) -#define DSOCR_DQ_ODT_SEL(odtSel) (odtSel << DSOCR_DQ_ODT_SEL_OFFS) -#define DSOCR_ST_ODT_SEL_OFFS 12 -#define DSOCR_ST_ODT_SEL_MASK (0x3 << DSOCR_ST_ODT_SEL_OFFS) -#define DSOCR_ST_ODT_SEL(odtSel) (odtSel << DSOCR_ST_ODT_SEL_OFFS) -#define DSOCR_ST_ODT_EN (1 << 14) - -/* DDR SDRAM Initialization Control Register (DSICR) */ -#define DDR_SDRAM_INIT_CTRL_REG (DRAM_BASE + 0x1480) -#define DSICR_INIT_EN (1 << 0) -#define DSICR_T200_SET (1 << 8) - -/* sdram extended mode2 register (SEM2R) */ -#define SDRAM_EXTENDED_MODE2_REG (DRAM_BASE + 0x148C) -#define SEM2R_EMRS2_DDR2_OFFS 0 -#define SEM2R_EMRS2_DDR2_MASK (0x7FFF << SEM2R_EMRS2_DDR2_OFFS) - -/* sdram extended mode3 register (SEM3R) */ -#define SDRAM_EXTENDED_MODE3_REG (DRAM_BASE + 0x1490) -#define SEM3R_EMRS3_DDR2_OFFS 0 -#define SEM3R_EMRS3_DDR2_MASK (0x7FFF << SEM3R_EMRS3_DDR2_OFFS) - -/* sdram error registers */ -#define SDRAM_ERROR_CAUSE_REG (DRAM_BASE + 0x14d0) -#define SDRAM_ERROR_MASK_REG (DRAM_BASE + 0x14d4) -#define SDRAM_ERROR_DATA_LOW_REG (DRAM_BASE + 0x1444) -#define SDRAM_ERROR_DATA_HIGH_REG (DRAM_BASE + 0x1440) -#define SDRAM_ERROR_ADDR_REG (DRAM_BASE + 0x1450) -#define SDRAM_ERROR_ECC_REG (DRAM_BASE + 0x1448) -#define SDRAM_CALC_ECC_REG (DRAM_BASE + 0x144c) -#define SDRAM_ECC_CONTROL_REG (DRAM_BASE + 0x1454) -#define SDRAM_SINGLE_BIT_ERR_CNTR_REG (DRAM_BASE + 0x1458) -#define SDRAM_DOUBLE_BIT_ERR_CNTR_REG (DRAM_BASE + 0x145c) - -/* SDRAM Error Cause Register (SECR) */ -#define SECR_SINGLE_BIT_ERR BIT0 -#define SECR_DOUBLE_BIT_ERR BIT1 -#define SECR_DATA_PATH_PARITY_ERR BIT2 -/* SDRAM Error Address Register (SEAR) */ -#define SEAR_ERR_TYPE_OFFS 0 -#define SEAR_ERR_TYPE_MASK (1 << SEAR_ERR_TYPE_OFFS) -#define SEAR_ERR_TYPE_SINGLE 0 -#define SEAR_ERR_TYPE_DOUBLE (1 << SEAR_ERR_TYPE_OFFS) -#define SEAR_ERR_CS_OFFS 1 -#define SEAR_ERR_CS_MASK (3 << SEAR_ERR_CS_OFFS) -#define SEAR_ERR_CS(csNum) (csNum << SEAR_ERR_CS_OFFS) -#define SEAR_ERR_ADDR_OFFS 3 -#define SEAR_ERR_ADDR_MASK (0x1FFFFFFF << SEAR_ERR_ADDR_OFFS) - -/* SDRAM ECC Control Register (SECR) */ -#define SECR_FORCEECC_OFFS 0 -#define SECR_FORCEECC_MASK (0xFF << SECR_FORCEECC_OFFS) -#define SECR_FORCEEN_OFFS 8 -#define SECR_FORCEEN_MASK (1 << SECR_FORCEEN_OFFS) -#define SECR_ECC_CALC_MASK (0 << SECR_FORCEEN_OFFS) -#define SECR_ECC_USER_MASK (1 << SECR_FORCEEN_OFFS) -#define SECR_PERRPROP_EN BIT9 -#define SECR_CNTMODE_OFFS 10 -#define SECR_CNTMODE_MASK (1 << SECR_CNTMODE_OFFS) -#define SECR_ALL_IN_CS0 (0 << SECR_CNTMODE_OFFS) -#define SECR_NORMAL_COUNTER (1 << SECR_CNTMODE_OFFS) -#define SECR_THRECC_OFFS 16 -#define SECR_THRECC_MAX 0xFF -#define SECR_THRECC_MASK (SECR_THRECC_MAX << SECR_THRECC_OFFS) -#define SECR_THRECC(threshold) (threshold << SECR_THRECC_OFFS) - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __INCmvDramIfRegsh */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr2/mvDramIfStaticInit.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr2/mvDramIfStaticInit.h deleted file mode 100644 index f3bf83b..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr2/mvDramIfStaticInit.h +++ /dev/null @@ -1,179 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -#ifndef __INCmvDramIfStaticInith -#define __INCmvDramIfStaticInith - -#ifdef MV_STATIC_DRAM_ON_BOARD -#define STATIC_DRAM_BANK_1 -#undef STATIC_DRAM_BANK_2 -#undef STATIC_DRAM_BANK_3 -#undef STATIC_DRAM_BANK_4 - - -#ifdef MV_DIMM_TS256MLQ72V5U -#define STATIC_DRAM_BANK_2 -#define STATIC_DRAM_BANK_3 -#undef STATIC_DRAM_BANK_4 - -#define STATIC_SDRAM_CONFIG_REG 0x4724481A /* offset 0x1400 - DMA reg-0xf1000814 */ -#define STATIC_SDRAM_DUNIT_CTRL_REG 0x37707450 /* offset 0x1404 - DMA reg-0xf100081c */ -#define STATIC_SDRAM_TIMING_CTRL_LOW_REG 0x11A13330 /* offset 0x1408 - DMA reg-0xf1000824 */ -#define STATIC_SDRAM_TIMING_CTRL_HIGH_REG 0x00000601 /* offset 0x140c - DMA reg-0xf1000828 */ -#define STATIC_SDRAM_ADDR_CTRL_REG 0x00001CB2 /* offset 0x1410 - DMA reg-0xf1000820 */ -#define STATIC_SDRAM_MODE_REG 0x00000642 /* offset 0x141c - DMA reg-0xf1000818 */ -#define STATIC_SDRAM_ODT_CTRL_LOW 0x030C030C /* 0x1494 */ -#define STATIC_SDRAM_ODT_CTRL_HI 0x00000000 /* 0x1498 */ -#define STATIC_SDRAM_DUNIT_ODT_CTRL 0x0000740F /* 0x149c */ -#define STATIC_SDRAM_EXT_MODE 0x00000404 /* 0x1420 */ -#define STATIC_SDRAM_DDR2_TIMING_LO 0x00074410 /* 0x1428 */ -#define STATIC_SDRAM_DDR2_TIMING_HI 0x00007441 /* 0x147C */ - -#define STATIC_SDRAM_RANK0_SIZE_DIMM0 0x3FFF /* size bank0 dimm0 - DMA reg-0xf1000810 */ -#define STATIC_SDRAM_RANK1_SIZE_DIMM0 0x3FFF /* size bank1 dimm0 */ -#define STATIC_SDRAM_RANK0_SIZE_DIMM1 0x3FFF /* size bank0 dimm1 */ -#define STATIC_SDRAM_RANK1_SIZE_DIMM1 0x0 /* size bank1 dimm1 */ - -#endif /* TS256MLQ72V5U */ - - -#ifdef MV_MT9VDDT3272AG -/* one DIMM 256M */ -#define STATIC_SDRAM_CONFIG_REG 0x5820040d /* offset 0x1400 - DMA reg-0xf1000814 */ -#define STATIC_SDRAM_DUNIT_CTRL_REG 0xC4000540 /* offset 0x1404 - DMA reg-0xf100081c */ -#define STATIC_SDRAM_TIMING_CTRL_LOW_REG 0x01602220 /* offset 0x1408 - DMA reg-0xf1000824 */ -#define STATIC_SDRAM_TIMING_CTRL_HIGH_REG 0x0000000b /* offset 0x140c - DMA reg-0xf1000828 */ -#define STATIC_SDRAM_ADDR_CTRL_REG 0x00000012 /* offset 0x1410 - DMA reg-0xf1000820 */ -#define STATIC_SDRAM_MODE_REG 0x00000062 /* offset 0x141c - DMA reg-0xf1000818 */ -#define STATIC_SDRAM_RANK0_SIZE_DIMM0 0x0fff /* size bank0 dimm0 - DMA reg-0xf1000810 */ -#define STATIC_SDRAM_RANK0_SIZE_DIMM1 0x0 /* size bank0 dimm1 */ - -#endif /* MV_MT9VDDT3272AG */ - - - -#ifdef MV_D27RB12P -/* -Two DIMM 512M + ECC enabled, Registered DIMM CAS Latency 2.5 -*/ - -#define STATIC_SDRAM_CONFIG_REG 0x6826081E /* offset 0x1400 - DMA reg-0xf1000814 */ -#define STATIC_SDRAM_DUNIT_CTRL_REG 0xC5000540 /* offset 0x1404 - DMA reg-0xf100081c */ -#define STATIC_SDRAM_TIMING_CTRL_LOW_REG 0x01501220 /* offset 0x1408 - DMA reg-0xf1000824 */ -#define STATIC_SDRAM_TIMING_CTRL_HIGH_REG 0x00000009 /* offset 0x140c - DMA reg-0xf1000828 */ -#define STATIC_SDRAM_ADDR_CTRL_REG 0x00000012 /* offset 0x1410 - DMA reg-0xf1000820 */ -#define STATIC_SDRAM_MODE_REG 0x00000062 /* offset 0x141c - DMA reg-0xf1000818 */ -#define STATIC_SDRAM_RANK0_SIZE_DIMM0 0x0FFF /* size bank0 dimm0 - DMA reg-0xf1000810 */ -#define STATIC_SDRAM_RANK0_SIZE_DIMM1 0x0FFF /* size bank0 dimm1 */ - -#define STATIC_DRAM_BANK_2 - -#define STATIC_DRAM_BANK_3 -#define STATIC_DRAM_BANK_4 - -#endif /* mv_D27RB12P */ - -#ifdef RD_MV645XX - -#define STATIC_MEM_TYPE MEM_TYPE_DDR2 -#define STATIC_DIMM_INFO_BANK0_SIZE 256 -/* DDR2 boards 256 MB*/ - -#define STATIC_SDRAM_RANK0_SIZE_DIMM0 0x00000fff /* size bank0 dimm0 - DMA reg-0xf1000810 */ -#define STATIC_SDRAM_CONFIG_REG 0x07190618 -#define STATIC_SDRAM_MODE_REG 0x00000432 -#define STATIC_SDRAM_DUNIT_CTRL_REG 0xf4a03440 -#define STATIC_SDRAM_ADDR_CTRL_REG 0x00000022 -#define STATIC_SDRAM_TIMING_CTRL_LOW_REG 0x11712220 -#define STATIC_SDRAM_TIMING_CTRL_HIGH_REG 0x00000504 -#define STATIC_SDRAM_ODT_CTRL_LOW 0x84210000 -#define STATIC_SDRAM_ODT_CTRL_HI 0x00000000 -#define STATIC_SDRAM_DUNIT_ODT_CTRL 0x0000780f -#define STATIC_SDRAM_EXT_MODE 0x00000440 -#define STATIC_SDRAM_DDR2_TIMING_LO 0x00063300 -#define STATIC_SDRAM_DDR2_TIMING_HI 0x00006330 -#endif /* RD_MV645XX */ - -#if MV_DIMM_M3783354CZ3_CE6 - -#define STATIC_SDRAM_RANK0_SIZE_DIMM0 0x00000FFF /* 0x2010 size bank0 dimm0 - DMA reg-0xf1000810 */ -#define STATIC_SDRAM_CONFIG_REG 0x07190618 /* 0x1400 */ -#define STATIC_SDRAM_MODE_REG 0x00000432 /* 0x141c */ -#define STATIC_SDRAM_DUNIT_CTRL_REG 0xf4a03440 /* 0x1404 */ -#define STATIC_SDRAM_ADDR_CTRL_REG 0x00000022 /* 0x1410 */ -#define STATIC_SDRAM_TIMING_CTRL_LOW_REG 0x11712220 /* 0x1408 */ -#define STATIC_SDRAM_TIMING_CTRL_HIGH_REG 0x00000504 /* 0x140c */ -#define STATIC_SDRAM_ODT_CTRL_LOW 0x84210000 /* 0x1494 */ -#define STATIC_SDRAM_ODT_CTRL_HI 0x00000000 /* 0x1498 */ -#define STATIC_SDRAM_DUNIT_ODT_CTRL 0x0000780f /* 0x149c */ -#define STATIC_SDRAM_EXT_MODE 0x00000440 /* 0x1420 */ -#define STATIC_SDRAM_DDR2_TIMING_LO 0x00063300 /* 0x1428 */ -#define STATIC_SDRAM_DDR2_TIMING_HI 0x00006330 /* 0x147C */ - -#endif /* MV_DIMM_M3783354CZ3_CE6 */ - -#endif /* MV_STATIC_DRAM_ON_BOARD */ -#endif /* __INCmvDramIfStaticInith */ - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr2/spd/mvSpd.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr2/spd/mvSpd.c deleted file mode 100644 index 7a26f90..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr2/spd/mvSpd.c +++ /dev/null @@ -1,1474 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#include "ddr2/spd/mvSpd.h" -#include "boardEnv/mvBoardEnvLib.h" - -/* #define MV_DEBUG */ -#ifdef MV_DEBUG -#define DB(x) x -#else -#define DB(x) -#endif - -static MV_VOID cpyDimm2BankInfo(MV_DIMM_INFO *pDimmInfo, - MV_DRAM_BANK_INFO *pBankInfo); -static MV_U32 cas2ps(MV_U8 spd_byte); -/******************************************************************************* -* mvDramBankGet - Get the DRAM bank paramters. -* -* DESCRIPTION: -* This function retrieves DRAM bank parameters as described in -* DRAM_BANK_INFO struct to the controller DRAM unit. In case the board -* has its DRAM on DIMMs it will use its EEPROM to extract SPD data -* from it. Otherwise, if the DRAM is soldered on board, the function -* should insert its bank information into MV_DRAM_BANK_INFO struct. -* -* INPUT: -* bankNum - Board DRAM bank number. -* -* OUTPUT: -* pBankInfo - DRAM bank information struct. -* -* RETURN: -* MV_FAIL - Bank parameters could not be read. -* -*******************************************************************************/ -MV_STATUS mvDramBankInfoGet(MV_U32 bankNum, MV_DRAM_BANK_INFO *pBankInfo) -{ - MV_DIMM_INFO dimmInfo; - - DB(mvOsPrintf("Dram: mvDramBankInfoGet bank %d\n", bankNum)); - /* zero pBankInfo structure */ - - if((NULL == pBankInfo) || (bankNum >= MV_DRAM_MAX_CS )) - { - DB(mvOsPrintf("Dram: mvDramBankInfoGet bad params \n")); - return MV_BAD_PARAM; - } - memset(pBankInfo, 0, sizeof(*pBankInfo)); - - if ( MV_OK != dimmSpdGet((MV_U32)(bankNum/2), &dimmInfo)) - { - DB(mvOsPrintf("Dram: ERR dimmSpdGet failed to get dimm info \n")); - return MV_FAIL; - } - if ((dimmInfo.numOfModuleBanks == 1) && ((bankNum % 2) == 1)) - { - DB(mvOsPrintf("Dram: ERR dimmSpdGet. Can't find DIMM bank 2 \n")); - return MV_FAIL; - } - /* convert Dimm info to Bank info */ - cpyDimm2BankInfo(&dimmInfo, pBankInfo); - return MV_OK; -} - -/******************************************************************************* -* cpyDimm2BankInfo - Convert a Dimm info struct into a bank info struct. -* -* DESCRIPTION: -* Convert a Dimm info struct into a bank info struct. -* -* INPUT: -* pDimmInfo - DIMM information structure. -* -* OUTPUT: -* pBankInfo - DRAM bank information struct. -* -* RETURN: -* None. -* -*******************************************************************************/ -static MV_VOID cpyDimm2BankInfo(MV_DIMM_INFO *pDimmInfo, - MV_DRAM_BANK_INFO *pBankInfo) -{ - pBankInfo->memoryType = pDimmInfo->memoryType; - - /* DIMM dimensions */ - pBankInfo->numOfRowAddr = pDimmInfo->numOfRowAddr; - pBankInfo->numOfColAddr = pDimmInfo->numOfColAddr; - pBankInfo->dataWidth = pDimmInfo->dataWidth; - pBankInfo->errorCheckType = pDimmInfo->errorCheckType; - pBankInfo->sdramWidth = pDimmInfo->sdramWidth; - pBankInfo->errorCheckDataWidth = pDimmInfo->errorCheckDataWidth; - pBankInfo->numOfBanksOnEachDevice = pDimmInfo->numOfBanksOnEachDevice; - pBankInfo->suportedCasLatencies = pDimmInfo->suportedCasLatencies; - pBankInfo->refreshInterval = pDimmInfo->refreshInterval; - - /* DIMM timing parameters */ - pBankInfo->minCycleTimeAtMaxCasLatPs = pDimmInfo->minCycleTimeAtMaxCasLatPs; - pBankInfo->minCycleTimeAtMaxCasLatMinus1Ps = - pDimmInfo->minCycleTimeAtMaxCasLatMinus1Ps; - pBankInfo->minCycleTimeAtMaxCasLatMinus2Ps = - pDimmInfo->minCycleTimeAtMaxCasLatMinus2Ps; - - pBankInfo->minRowPrechargeTime = pDimmInfo->minRowPrechargeTime; - pBankInfo->minRowActiveToRowActive = pDimmInfo->minRowActiveToRowActive; - pBankInfo->minRasToCasDelay = pDimmInfo->minRasToCasDelay; - pBankInfo->minRasPulseWidth = pDimmInfo->minRasPulseWidth; - pBankInfo->minWriteRecoveryTime = pDimmInfo->minWriteRecoveryTime; - pBankInfo->minWriteToReadCmdDelay = pDimmInfo->minWriteToReadCmdDelay; - pBankInfo->minReadToPrechCmdDelay = pDimmInfo->minReadToPrechCmdDelay; - pBankInfo->minRefreshToActiveCmd = pDimmInfo->minRefreshToActiveCmd; - - /* Parameters calculated from the extracted DIMM information */ - pBankInfo->size = pDimmInfo->size/pDimmInfo->numOfModuleBanks; - pBankInfo->deviceDensity = pDimmInfo->deviceDensity; - pBankInfo->numberOfDevices = pDimmInfo->numberOfDevices / - pDimmInfo->numOfModuleBanks; - - /* DIMM attributes (MV_TRUE for yes) */ - - if ((pDimmInfo->memoryType == MEM_TYPE_SDRAM) || - (pDimmInfo->memoryType == MEM_TYPE_DDR1) ) - { - if (pDimmInfo->dimmAttributes & BIT1) - pBankInfo->registeredAddrAndControlInputs = MV_TRUE; - else - pBankInfo->registeredAddrAndControlInputs = MV_FALSE; - } - else /* pDimmInfo->memoryType == MEM_TYPE_DDR2 */ - { - if (pDimmInfo->dimmTypeInfo & (BIT0 | BIT4)) - pBankInfo->registeredAddrAndControlInputs = MV_TRUE; - else - pBankInfo->registeredAddrAndControlInputs = MV_FALSE; - } - - return; -} -/******************************************************************************* -* dimmSpdCpy - Cpy SPD parameters from dimm 0 to dimm 1. -* -* DESCRIPTION: -* Read the DIMM SPD parameters from dimm 0 into dimm 1 SPD. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_TRUE if function could read DIMM parameters, MV_FALSE otherwise. -* -*******************************************************************************/ -MV_STATUS dimmSpdCpy(MV_VOID) -{ - MV_U32 i; - MV_U32 spdChecksum; - - MV_TWSI_SLAVE twsiSlave; - MV_U8 data[SPD_SIZE]; - - /* zero dimmInfo structure */ - memset(data, 0, SPD_SIZE); - - /* read the dimm eeprom */ - DB(mvOsPrintf("DRAM: Read Dimm eeprom\n")); - twsiSlave.slaveAddr.address = MV_BOARD_DIMM0_I2C_ADDR; - twsiSlave.slaveAddr.type = ADDR7_BIT; - twsiSlave.validOffset = MV_TRUE; - twsiSlave.offset = 0; - twsiSlave.moreThen256 = MV_FALSE; - - if( MV_OK != mvTwsiRead (MV_BOARD_DIMM_I2C_CHANNEL, &twsiSlave, data, SPD_SIZE) ) - { - DB(mvOsPrintf("DRAM: ERR. no DIMM in dimmNum 0\n")); - return MV_FAIL; - } - DB(puts("DRAM: Reading dimm info succeded.\n")); - - /* calculate SPD checksum */ - spdChecksum = 0; - - for(i = 0 ; i <= 62 ; i++) - { - spdChecksum += data[i]; - } - - if ((spdChecksum & 0xff) != data[63]) - { - DB(mvOsPrintf("DRAM: Warning. Wrong SPD Checksum %2x, expValue=%2x\n", - (MV_U32)(spdChecksum & 0xff), data[63])); - } - else - { - DB(mvOsPrintf("DRAM: SPD Checksum ok!\n")); - } - - /* copy the SPD content 1:1 into the DIMM 1 SPD */ - twsiSlave.slaveAddr.address = MV_BOARD_DIMM1_I2C_ADDR; - twsiSlave.slaveAddr.type = ADDR7_BIT; - twsiSlave.validOffset = MV_TRUE; - twsiSlave.offset = 0; - twsiSlave.moreThen256 = MV_FALSE; - - for(i = 0 ; i < SPD_SIZE ; i++) - { - twsiSlave.offset = i; - if( MV_OK != mvTwsiWrite (MV_BOARD_DIMM_I2C_CHANNEL, &twsiSlave, &data[i], 1) ) - { - mvOsPrintf("DRAM: ERR. no DIMM in dimmNum 1 byte %d \n",i); - return MV_FAIL; - } - mvOsDelay(5); - } - - DB(puts("DRAM: Reading dimm info succeded.\n")); - return MV_OK; -} - -/******************************************************************************* -* dimmSpdGet - Get the SPD parameters. -* -* DESCRIPTION: -* Read the DIMM SPD parameters into given struct parameter. -* -* INPUT: -* dimmNum - DIMM number. See MV_BOARD_DIMM_NUM enumerator. -* -* OUTPUT: -* pDimmInfo - DIMM information structure. -* -* RETURN: -* MV_TRUE if function could read DIMM parameters, MV_FALSE otherwise. -* -*******************************************************************************/ -MV_STATUS dimmSpdGet(MV_U32 dimmNum, MV_DIMM_INFO *pDimmInfo) -{ - MV_U32 i; - MV_U32 density = 1; - MV_U32 spdChecksum; - - MV_TWSI_SLAVE twsiSlave; - MV_U8 data[SPD_SIZE]; - - if((NULL == pDimmInfo)|| (dimmNum >= MAX_DIMM_NUM)) - { - DB(mvOsPrintf("Dram: mvDramBankInfoGet bad params \n")); - return MV_BAD_PARAM; - } - - /* zero dimmInfo structure */ - memset(data, 0, SPD_SIZE); - - /* read the dimm eeprom */ - DB(mvOsPrintf("DRAM: Read Dimm eeprom\n")); - twsiSlave.slaveAddr.address = (dimmNum == 0) ? - MV_BOARD_DIMM0_I2C_ADDR : MV_BOARD_DIMM1_I2C_ADDR; - twsiSlave.slaveAddr.type = ADDR7_BIT; - twsiSlave.validOffset = MV_TRUE; - twsiSlave.offset = 0; - twsiSlave.moreThen256 = MV_FALSE; - - if( MV_OK != mvTwsiRead (MV_BOARD_DIMM_I2C_CHANNEL, &twsiSlave, data, SPD_SIZE) ) - { - DB(mvOsPrintf("DRAM: ERR. no DIMM in dimmNum %d \n", dimmNum)); - return MV_FAIL; - } - DB(puts("DRAM: Reading dimm info succeded.\n")); - - /* calculate SPD checksum */ - spdChecksum = 0; - - for(i = 0 ; i <= 62 ; i++) - { - spdChecksum += data[i]; - } - - if ((spdChecksum & 0xff) != data[63]) - { - DB(mvOsPrintf("DRAM: Warning. Wrong SPD Checksum %2x, expValue=%2x\n", - (MV_U32)(spdChecksum & 0xff), data[63])); - } - else - { - DB(mvOsPrintf("DRAM: SPD Checksum ok!\n")); - } - - /* copy the SPD content 1:1 into the dimmInfo structure*/ - for(i = 0 ; i < SPD_SIZE ; i++) - { - pDimmInfo->spdRawData[i] = data[i]; - DB(mvOsPrintf("SPD-EEPROM Byte %3d = %3x (%3d)\n",i, data[i], data[i])); - } - - DB(mvOsPrintf("DRAM SPD Information:\n")); - - /* Memory type (DDR / SDRAM) */ - switch (data[DIMM_MEM_TYPE]) - { - case (DIMM_MEM_TYPE_SDRAM): - pDimmInfo->memoryType = MEM_TYPE_SDRAM; - DB(mvOsPrintf("DRAM Memeory type SDRAM\n")); - break; - case (DIMM_MEM_TYPE_DDR1): - pDimmInfo->memoryType = MEM_TYPE_DDR1; - DB(mvOsPrintf("DRAM Memeory type DDR1\n")); - break; - case (DIMM_MEM_TYPE_DDR2): - pDimmInfo->memoryType = MEM_TYPE_DDR2; - DB(mvOsPrintf("DRAM Memeory type DDR2\n")); - break; - default: - mvOsPrintf("ERROR: Undefined memory type!\n"); - return MV_ERROR; - } - - - /* Number Of Row Addresses */ - pDimmInfo->numOfRowAddr = data[DIMM_ROW_NUM]; - DB(mvOsPrintf("DRAM numOfRowAddr[3] %d\n",pDimmInfo->numOfRowAddr)); - - /* Number Of Column Addresses */ - pDimmInfo->numOfColAddr = data[DIMM_COL_NUM]; - DB(mvOsPrintf("DRAM numOfColAddr[4] %d\n",pDimmInfo->numOfColAddr)); - - /* Number Of Module Banks */ - pDimmInfo->numOfModuleBanks = data[DIMM_MODULE_BANK_NUM]; - DB(mvOsPrintf("DRAM numOfModuleBanks[5] 0x%x\n", - pDimmInfo->numOfModuleBanks)); - - /* Number of module banks encoded differently for DDR2 */ - if (pDimmInfo->memoryType == MEM_TYPE_DDR2) - pDimmInfo->numOfModuleBanks = (pDimmInfo->numOfModuleBanks & 0x7)+1; - - /* Data Width */ - pDimmInfo->dataWidth = data[DIMM_DATA_WIDTH]; - DB(mvOsPrintf("DRAM dataWidth[6] 0x%x\n", pDimmInfo->dataWidth)); - - /* Minimum Cycle Time At Max CasLatancy */ - pDimmInfo->minCycleTimeAtMaxCasLatPs = cas2ps(data[DIMM_MIN_CC_AT_MAX_CAS]); - - /* Error Check Type */ - pDimmInfo->errorCheckType = data[DIMM_ERR_CHECK_TYPE]; - DB(mvOsPrintf("DRAM errorCheckType[11] 0x%x\n", - pDimmInfo->errorCheckType)); - - /* Refresh Interval */ - pDimmInfo->refreshInterval = data[DIMM_REFRESH_INTERVAL]; - DB(mvOsPrintf("DRAM refreshInterval[12] 0x%x\n", - pDimmInfo->refreshInterval)); - - /* Sdram Width */ - pDimmInfo->sdramWidth = data[DIMM_SDRAM_WIDTH]; - DB(mvOsPrintf("DRAM sdramWidth[13] 0x%x\n",pDimmInfo->sdramWidth)); - - /* Error Check Data Width */ - pDimmInfo->errorCheckDataWidth = data[DIMM_ERR_CHECK_DATA_WIDTH]; - DB(mvOsPrintf("DRAM errorCheckDataWidth[14] 0x%x\n", - pDimmInfo->errorCheckDataWidth)); - - /* Burst Length Supported */ - /* SDRAM/DDR1: - *******-******-******-******-******-******-******-******* - * bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 * - *******-******-******-******-******-******-******-******* - burst length = * Page | TBD | TBD | TBD | 8 | 4 | 2 | 1 * - *********************************************************/ - /* DDR2: - *******-******-******-******-******-******-******-******* - * bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 * - *******-******-******-******-******-******-******-******* - burst length = * Page | TBD | TBD | TBD | 8 | 4 | TBD | TBD * - *********************************************************/ - - pDimmInfo->burstLengthSupported = data[DIMM_BURST_LEN_SUP]; - DB(mvOsPrintf("DRAM burstLengthSupported[16] 0x%x\n", - pDimmInfo->burstLengthSupported)); - - /* Number Of Banks On Each Device */ - pDimmInfo->numOfBanksOnEachDevice = data[DIMM_DEV_BANK_NUM]; - DB(mvOsPrintf("DRAM numOfBanksOnEachDevice[17] 0x%x\n", - pDimmInfo->numOfBanksOnEachDevice)); - - /* Suported Cas Latencies */ - - /* SDRAM: - *******-******-******-******-******-******-******-******* - * bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 * - *******-******-******-******-******-******-******-******* - CAS = * TBD | 7 | 6 | 5 | 4 | 3 | 2 | 1 * - ********************************************************/ - - /* DDR 1: - *******-******-******-******-******-******-******-******* - * bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 * - *******-******-******-******-******-******-******-******* - CAS = * TBD | 4 | 3.5 | 3 | 2.5 | 2 | 1.5 | 1 * - *********************************************************/ - - /* DDR 2: - *******-******-******-******-******-******-******-******* - * bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 * - *******-******-******-******-******-******-******-******* - CAS = * TBD | TBD | 5 | 4 | 3 | 2 | TBD | TBD * - *********************************************************/ - - pDimmInfo->suportedCasLatencies = data[DIMM_SUP_CAL]; - DB(mvOsPrintf("DRAM suportedCasLatencies[18] 0x%x\n", - pDimmInfo->suportedCasLatencies)); - - /* For DDR2 only, get the DIMM type information */ - if (pDimmInfo->memoryType == MEM_TYPE_DDR2) - { - pDimmInfo->dimmTypeInfo = data[DIMM_DDR2_TYPE_INFORMATION]; - DB(mvOsPrintf("DRAM dimmTypeInfo[20] (DDR2) 0x%x\n", - pDimmInfo->dimmTypeInfo)); - } - - /* SDRAM Modules Attributes */ - pDimmInfo->dimmAttributes = data[DIMM_BUF_ADDR_CONT_IN]; - DB(mvOsPrintf("DRAM dimmAttributes[21] 0x%x\n", - pDimmInfo->dimmAttributes)); - - /* Minimum Cycle Time At Max CasLatancy Minus 1*/ - pDimmInfo->minCycleTimeAtMaxCasLatMinus1Ps = - cas2ps(data[DIMM_MIN_CC_AT_MAX_CAS_MINUS1]); - - /* Minimum Cycle Time At Max CasLatancy Minus 2*/ - pDimmInfo->minCycleTimeAtMaxCasLatMinus2Ps = - cas2ps(data[DIMM_MIN_CC_AT_MAX_CAS_MINUS2]); - - pDimmInfo->minRowPrechargeTime = data[DIMM_MIN_ROW_PRECHARGE_TIME]; - DB(mvOsPrintf("DRAM minRowPrechargeTime[27] 0x%x\n", - pDimmInfo->minRowPrechargeTime)); - pDimmInfo->minRowActiveToRowActive = data[DIMM_MIN_ROW_ACTIVE_TO_ROW_ACTIVE]; - DB(mvOsPrintf("DRAM minRowActiveToRowActive[28] 0x%x\n", - pDimmInfo->minRowActiveToRowActive)); - pDimmInfo->minRasToCasDelay = data[DIMM_MIN_RAS_TO_CAS_DELAY]; - DB(mvOsPrintf("DRAM minRasToCasDelay[29] 0x%x\n", - pDimmInfo->minRasToCasDelay)); - pDimmInfo->minRasPulseWidth = data[DIMM_MIN_RAS_PULSE_WIDTH]; - DB(mvOsPrintf("DRAM minRasPulseWidth[30] 0x%x\n", - pDimmInfo->minRasPulseWidth)); - - /* DIMM Bank Density */ - pDimmInfo->dimmBankDensity = data[DIMM_BANK_DENSITY]; - DB(mvOsPrintf("DRAM dimmBankDensity[31] 0x%x\n", - pDimmInfo->dimmBankDensity)); - - /* Only DDR2 includes Write Recovery Time field. Other SDRAM ignore */ - pDimmInfo->minWriteRecoveryTime = data[DIMM_MIN_WRITE_RECOVERY_TIME]; - DB(mvOsPrintf("DRAM minWriteRecoveryTime[36] 0x%x\n", - pDimmInfo->minWriteRecoveryTime)); - - /* Only DDR2 includes Internal Write To Read Command Delay field. */ - pDimmInfo->minWriteToReadCmdDelay = data[DIMM_MIN_WRITE_TO_READ_CMD_DELAY]; - DB(mvOsPrintf("DRAM minWriteToReadCmdDelay[37] 0x%x\n", - pDimmInfo->minWriteToReadCmdDelay)); - - /* Only DDR2 includes Internal Read To Precharge Command Delay field. */ - pDimmInfo->minReadToPrechCmdDelay = data[DIMM_MIN_READ_TO_PRECH_CMD_DELAY]; - DB(mvOsPrintf("DRAM minReadToPrechCmdDelay[38] 0x%x\n", - pDimmInfo->minReadToPrechCmdDelay)); - - /* Only DDR2 includes Minimum Refresh to Activate/Refresh Command field */ - pDimmInfo->minRefreshToActiveCmd = data[DIMM_MIN_REFRESH_TO_ACTIVATE_CMD]; - DB(mvOsPrintf("DRAM minRefreshToActiveCmd[42] 0x%x\n", - pDimmInfo->minRefreshToActiveCmd)); - - /* calculating the sdram density. Representing device density from */ - /* bit 20 to allow representation of 4GB and above. */ - /* For example, if density is 512Mbit 0x20000000, will be represent in */ - /* deviceDensity by 0x20000000 >> 16 --> 0x00000200. Another example */ - /* is density 8GB 0x200000000 >> 16 --> 0x00002000. */ - density = (1 << ((pDimmInfo->numOfRowAddr + pDimmInfo->numOfColAddr) - 20)); - pDimmInfo->deviceDensity = density * - pDimmInfo->numOfBanksOnEachDevice * - pDimmInfo->sdramWidth; - DB(mvOsPrintf("DRAM deviceDensity %d\n",pDimmInfo->deviceDensity)); - - /* Number of devices includeing Error correction */ - pDimmInfo->numberOfDevices = (pDimmInfo->dataWidth/pDimmInfo->sdramWidth) * - pDimmInfo->numOfModuleBanks; - DB(mvOsPrintf("DRAM numberOfDevices %d\n", - pDimmInfo->numberOfDevices)); - - pDimmInfo->size = 0; - - /* Note that pDimmInfo->size is in MB units */ - if (pDimmInfo->memoryType == MEM_TYPE_SDRAM) - { - if (pDimmInfo->dimmBankDensity & BIT0) - pDimmInfo->size += 1024; /* Equal to 1GB */ - else if (pDimmInfo->dimmBankDensity & BIT1) - pDimmInfo->size += 8; /* Equal to 8MB */ - else if (pDimmInfo->dimmBankDensity & BIT2) - pDimmInfo->size += 16; /* Equal to 16MB */ - else if (pDimmInfo->dimmBankDensity & BIT3) - pDimmInfo->size += 32; /* Equal to 32MB */ - else if (pDimmInfo->dimmBankDensity & BIT4) - pDimmInfo->size += 64; /* Equal to 64MB */ - else if (pDimmInfo->dimmBankDensity & BIT5) - pDimmInfo->size += 128; /* Equal to 128MB */ - else if (pDimmInfo->dimmBankDensity & BIT6) - pDimmInfo->size += 256; /* Equal to 256MB */ - else if (pDimmInfo->dimmBankDensity & BIT7) - pDimmInfo->size += 512; /* Equal to 512MB */ - } - else if (pDimmInfo->memoryType == MEM_TYPE_DDR1) - { - if (pDimmInfo->dimmBankDensity & BIT0) - pDimmInfo->size += 1024; /* Equal to 1GB */ - else if (pDimmInfo->dimmBankDensity & BIT1) - pDimmInfo->size += 2048; /* Equal to 2GB */ - else if (pDimmInfo->dimmBankDensity & BIT2) - pDimmInfo->size += 16; /* Equal to 16MB */ - else if (pDimmInfo->dimmBankDensity & BIT3) - pDimmInfo->size += 32; /* Equal to 32MB */ - else if (pDimmInfo->dimmBankDensity & BIT4) - pDimmInfo->size += 64; /* Equal to 64MB */ - else if (pDimmInfo->dimmBankDensity & BIT5) - pDimmInfo->size += 128; /* Equal to 128MB */ - else if (pDimmInfo->dimmBankDensity & BIT6) - pDimmInfo->size += 256; /* Equal to 256MB */ - else if (pDimmInfo->dimmBankDensity & BIT7) - pDimmInfo->size += 512; /* Equal to 512MB */ - } - else /* if (dimmInfo.memoryType == MEM_TYPE_DDR2) */ - { - if (pDimmInfo->dimmBankDensity & BIT0) - pDimmInfo->size += 1024; /* Equal to 1GB */ - else if (pDimmInfo->dimmBankDensity & BIT1) - pDimmInfo->size += 2048; /* Equal to 2GB */ - else if (pDimmInfo->dimmBankDensity & BIT2) - pDimmInfo->size += 4096; /* Equal to 4GB */ - else if (pDimmInfo->dimmBankDensity & BIT3) - pDimmInfo->size += 8192; /* Equal to 8GB */ - else if (pDimmInfo->dimmBankDensity & BIT4) - pDimmInfo->size += 16384; /* Equal to 16GB */ - else if (pDimmInfo->dimmBankDensity & BIT5) - pDimmInfo->size += 128; /* Equal to 128MB */ - else if (pDimmInfo->dimmBankDensity & BIT6) - pDimmInfo->size += 256; /* Equal to 256MB */ - else if (pDimmInfo->dimmBankDensity & BIT7) - pDimmInfo->size += 512; /* Equal to 512MB */ - } - - pDimmInfo->size *= pDimmInfo->numOfModuleBanks; - - DB(mvOsPrintf("Dram: dimm size %dMB \n",pDimmInfo->size)); - - return MV_OK; -} - -/******************************************************************************* -* dimmSpdPrint - Print the SPD parameters. -* -* DESCRIPTION: -* Print the Dimm SPD parameters. -* -* INPUT: -* pDimmInfo - DIMM information structure. -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_VOID dimmSpdPrint(MV_U32 dimmNum) -{ - MV_DIMM_INFO dimmInfo; - MV_U32 i, temp = 0; - MV_U32 k, maskLeftOfPoint = 0, maskRightOfPoint = 0; - MV_U32 rightOfPoint = 0,leftOfPoint = 0, div, time_tmp, shift; - MV_U32 busClkPs; - MV_U8 trp_clocks=0, trcd_clocks, tras_clocks, trrd_clocks, - temp_buf[40], *spdRawData; - - busClkPs = 1000000000 / (mvBoardSysClkGet() / 100); /* in 10 ps units */ - - spdRawData = dimmInfo.spdRawData; - - if(MV_OK != dimmSpdGet(dimmNum, &dimmInfo)) - { - mvOsOutput("ERROR: Could not read SPD information!\n"); - return; - } - - /* find Manufactura of Dimm Module */ - mvOsOutput("\nManufacturer's JEDEC ID Code: "); - for(i = 0 ; i < DIMM_MODULE_MANU_SIZE ; i++) - { - mvOsOutput("%x",spdRawData[DIMM_MODULE_MANU_OFFS + i]); - } - mvOsOutput("\n"); - - /* Manufacturer's Specific Data */ - for(i = 0 ; i < DIMM_MODULE_ID_SIZE ; i++) - { - temp_buf[i] = spdRawData[DIMM_MODULE_ID_OFFS + i]; - } - mvOsOutput("Manufacturer's Specific Data: %s\n", temp_buf); - - /* Module Part Number */ - for(i = 0 ; i < DIMM_MODULE_VEN_SIZE ; i++) - { - temp_buf[i] = spdRawData[DIMM_MODULE_VEN_OFFS + i]; - } - mvOsOutput("Module Part Number: %s\n", temp_buf); - - /* Module Serial Number */ - for(i = 0; i < sizeof(MV_U32); i++) - { - temp |= spdRawData[95+i] << 8*i; - } - mvOsOutput("DIMM Serial No. %ld (%lx)\n", (long)temp, - (long)temp); - - /* find Manufac-Data of Dimm Module */ - mvOsOutput("Manufactoring Date: Year 20%d%d/ ww %d%d\n", - ((spdRawData[93] & 0xf0) >> 4), (spdRawData[93] & 0xf), - ((spdRawData[94] & 0xf0) >> 4), (spdRawData[94] & 0xf)); - /* find modul_revision of Dimm Module */ - mvOsOutput("Module Revision: %d.%d\n", - spdRawData[62]/10, spdRawData[62]%10); - - /* find manufac_place of Dimm Module */ - mvOsOutput("manufac_place: %d\n", spdRawData[72]); - - /* go over the first 35 I2C data bytes */ - for(i = 2 ; i <= 35 ; i++) - switch(i) - { - case 2: /* Memory type (DDR1/2 / SDRAM) */ - if (dimmInfo.memoryType == MEM_TYPE_SDRAM) - mvOsOutput("Dram Type is: SDRAM\n"); - else if (dimmInfo.memoryType == MEM_TYPE_DDR1) - mvOsOutput("Dram Type is: SDRAM DDR1\n"); - else if (dimmInfo.memoryType == MEM_TYPE_DDR2) - mvOsOutput("Dram Type is: SDRAM DDR2\n"); - else - mvOsOutput("Dram Type unknown\n"); - break; -/*----------------------------------------------------------------------------*/ - - case 3: /* Number Of Row Addresses */ - mvOsOutput("Module Number of row addresses: %d\n", - dimmInfo.numOfRowAddr); - break; -/*----------------------------------------------------------------------------*/ - - case 4: /* Number Of Column Addresses */ - mvOsOutput("Module Number of col addresses: %d\n", - dimmInfo.numOfColAddr); - break; -/*----------------------------------------------------------------------------*/ - - case 5: /* Number Of Module Banks */ - mvOsOutput("Number of Banks on Mod.: %d\n", - dimmInfo.numOfModuleBanks); - break; -/*----------------------------------------------------------------------------*/ - - case 6: /* Data Width */ - mvOsOutput("Module Data Width: %d bit\n", - dimmInfo.dataWidth); - break; -/*----------------------------------------------------------------------------*/ - - case 8: /* Voltage Interface */ - switch(spdRawData[i]) - { - case 0x0: - mvOsOutput("Module is TTL_5V_TOLERANT\n"); - break; - case 0x1: - mvOsOutput("Module is LVTTL\n"); - break; - case 0x2: - mvOsOutput("Module is HSTL_1_5V\n"); - break; - case 0x3: - mvOsOutput("Module is SSTL_3_3V\n"); - break; - case 0x4: - mvOsOutput("Module is SSTL_2_5V\n"); - break; - case 0x5: - if (dimmInfo.memoryType != MEM_TYPE_SDRAM) - { - mvOsOutput("Module is SSTL_1_8V\n"); - break; - } - default: - mvOsOutput("Module is VOLTAGE_UNKNOWN\n"); - break; - } - break; -/*----------------------------------------------------------------------------*/ - - case 9: /* Minimum Cycle Time At Max CasLatancy */ - leftOfPoint = (spdRawData[i] & 0xf0) >> 4; - rightOfPoint = (spdRawData[i] & 0x0f) * 10; - - /* DDR2 addition of right of point */ - if ((spdRawData[i] & 0x0f) == 0xA) - { - rightOfPoint = 25; - } - if ((spdRawData[i] & 0x0f) == 0xB) - { - rightOfPoint = 33; - } - if ((spdRawData[i] & 0x0f) == 0xC) - { - rightOfPoint = 66; - } - if ((spdRawData[i] & 0x0f) == 0xD) - { - rightOfPoint = 75; - } - mvOsOutput("Minimum Cycle Time At Max CL: %d.%d [ns]\n", - leftOfPoint, rightOfPoint); - break; -/*----------------------------------------------------------------------------*/ - - case 10: /* Clock To Data Out */ - div = (dimmInfo.memoryType == MEM_TYPE_SDRAM)? 10:100; - time_tmp = (((spdRawData[i] & 0xf0) >> 4)*10) + - ((spdRawData[i] & 0x0f)); - leftOfPoint = time_tmp / div; - rightOfPoint = time_tmp % div; - mvOsOutput("Clock To Data Out: %d.%d [ns]\n", - leftOfPoint, rightOfPoint); - break; -/*----------------------------------------------------------------------------*/ - - case 11: /* Error Check Type */ - mvOsOutput("Error Check Type (0=NONE): %d\n", - dimmInfo.errorCheckType); - break; -/*----------------------------------------------------------------------------*/ - - case 12: /* Refresh Interval */ - mvOsOutput("Refresh Rate: %x\n", - dimmInfo.refreshInterval); - break; -/*----------------------------------------------------------------------------*/ - - case 13: /* Sdram Width */ - mvOsOutput("Sdram Width: %d bits\n", - dimmInfo.sdramWidth); - break; -/*----------------------------------------------------------------------------*/ - - case 14: /* Error Check Data Width */ - mvOsOutput("Error Check Data Width: %d bits\n", - dimmInfo.errorCheckDataWidth); - break; -/*----------------------------------------------------------------------------*/ - - case 15: /* Minimum Clock Delay is unsupported */ - if ((dimmInfo.memoryType == MEM_TYPE_SDRAM) || - (dimmInfo.memoryType == MEM_TYPE_DDR1)) - { - mvOsOutput("Minimum Clk Delay back to back: %d\n", - spdRawData[i]); - } - break; -/*----------------------------------------------------------------------------*/ - - case 16: /* Burst Length Supported */ - /* SDRAM/DDR1: - *******-******-******-******-******-******-******-******* - * bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 * - *******-******-******-******-******-******-******-******* - burst length = * Page | TBD | TBD | TBD | 8 | 4 | 2 | 1 * - *********************************************************/ - /* DDR2: - *******-******-******-******-******-******-******-******* - * bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 * - *******-******-******-******-******-******-******-******* - burst length = * Page | TBD | TBD | TBD | 8 | 4 | TBD | TBD * - *********************************************************/ - mvOsOutput("Burst Length Supported: "); - if ((dimmInfo.memoryType == MEM_TYPE_SDRAM) || - (dimmInfo.memoryType == MEM_TYPE_DDR1)) - { - if (dimmInfo.burstLengthSupported & BIT0) - mvOsOutput("1, "); - if (dimmInfo.burstLengthSupported & BIT1) - mvOsOutput("2, "); - } - if (dimmInfo.burstLengthSupported & BIT2) - mvOsOutput("4, "); - if (dimmInfo.burstLengthSupported & BIT3) - mvOsOutput("8, "); - - mvOsOutput(" Bit \n"); - break; -/*----------------------------------------------------------------------------*/ - - case 17: /* Number Of Banks On Each Device */ - mvOsOutput("Number Of Banks On Each Chip: %d\n", - dimmInfo.numOfBanksOnEachDevice); - break; -/*----------------------------------------------------------------------------*/ - - case 18: /* Suported Cas Latencies */ - - /* SDRAM: - *******-******-******-******-******-******-******-******* - * bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 * - *******-******-******-******-******-******-******-******* - CAS = * TBD | 7 | 6 | 5 | 4 | 3 | 2 | 1 * - ********************************************************/ - - /* DDR 1: - *******-******-******-******-******-******-******-******* - * bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 * - *******-******-******-******-******-******-******-******* - CAS = * TBD | 4 | 3.5 | 3 | 2.5 | 2 | 1.5 | 1 * - *********************************************************/ - - /* DDR 2: - *******-******-******-******-******-******-******-******* - * bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 * - *******-******-******-******-******-******-******-******* - CAS = * TBD | TBD | 5 | 4 | 3 | 2 | TBD | TBD * - *********************************************************/ - - mvOsOutput("Suported Cas Latencies: (CL) "); - if (dimmInfo.memoryType == MEM_TYPE_SDRAM) - { - for (k = 0; k <=7; k++) - { - if (dimmInfo.suportedCasLatencies & (1 << k)) - mvOsOutput("%d, ", k+1); - } - } - else if (dimmInfo.memoryType == MEM_TYPE_DDR1) - { - if (dimmInfo.suportedCasLatencies & BIT0) - mvOsOutput("1, "); - if (dimmInfo.suportedCasLatencies & BIT1) - mvOsOutput("1.5, "); - if (dimmInfo.suportedCasLatencies & BIT2) - mvOsOutput("2, "); - if (dimmInfo.suportedCasLatencies & BIT3) - mvOsOutput("2.5, "); - if (dimmInfo.suportedCasLatencies & BIT4) - mvOsOutput("3, "); - if (dimmInfo.suportedCasLatencies & BIT5) - mvOsOutput("3.5, "); - } - else if (dimmInfo.memoryType == MEM_TYPE_DDR2) - { - if (dimmInfo.suportedCasLatencies & BIT2) - mvOsOutput("2, "); - if (dimmInfo.suportedCasLatencies & BIT3) - mvOsOutput("3, "); - if (dimmInfo.suportedCasLatencies & BIT4) - mvOsOutput("4, "); - if (dimmInfo.suportedCasLatencies & BIT5) - mvOsOutput("5, "); - } - else - mvOsOutput("?.?, "); - mvOsOutput("\n"); - break; -/*----------------------------------------------------------------------------*/ - - case 20: /* DDR2 DIMM type info */ - if (dimmInfo.memoryType == MEM_TYPE_DDR2) - { - if (dimmInfo.dimmTypeInfo & (BIT0 | BIT4)) - mvOsOutput("Registered DIMM (RDIMM)\n"); - else if (dimmInfo.dimmTypeInfo & (BIT1 | BIT5)) - mvOsOutput("Unbuffered DIMM (UDIMM)\n"); - else - mvOsOutput("Unknown DIMM type.\n"); - } - - break; -/*----------------------------------------------------------------------------*/ - - case 21: /* SDRAM Modules Attributes */ - mvOsOutput("\nModule Attributes (SPD Byte 21): \n"); - - if (dimmInfo.memoryType == MEM_TYPE_SDRAM) - { - if (dimmInfo.dimmAttributes & BIT0) - mvOsOutput(" Buffered Addr/Control Input: Yes\n"); - else - mvOsOutput(" Buffered Addr/Control Input: No\n"); - - if (dimmInfo.dimmAttributes & BIT1) - mvOsOutput(" Registered Addr/Control Input: Yes\n"); - else - mvOsOutput(" Registered Addr/Control Input: No\n"); - - if (dimmInfo.dimmAttributes & BIT2) - mvOsOutput(" On-Card PLL (clock): Yes \n"); - else - mvOsOutput(" On-Card PLL (clock): No \n"); - - if (dimmInfo.dimmAttributes & BIT3) - mvOsOutput(" Bufferd DQMB Input: Yes \n"); - else - mvOsOutput(" Bufferd DQMB Inputs: No \n"); - - if (dimmInfo.dimmAttributes & BIT4) - mvOsOutput(" Registered DQMB Inputs: Yes \n"); - else - mvOsOutput(" Registered DQMB Inputs: No \n"); - - if (dimmInfo.dimmAttributes & BIT5) - mvOsOutput(" Differential Clock Input: Yes \n"); - else - mvOsOutput(" Differential Clock Input: No \n"); - - if (dimmInfo.dimmAttributes & BIT6) - mvOsOutput(" redundant Row Addressing: Yes \n"); - else - mvOsOutput(" redundant Row Addressing: No \n"); - } - else if (dimmInfo.memoryType == MEM_TYPE_DDR1) - { - if (dimmInfo.dimmAttributes & BIT0) - mvOsOutput(" Buffered Addr/Control Input: Yes\n"); - else - mvOsOutput(" Buffered Addr/Control Input: No\n"); - - if (dimmInfo.dimmAttributes & BIT1) - mvOsOutput(" Registered Addr/Control Input: Yes\n"); - else - mvOsOutput(" Registered Addr/Control Input: No\n"); - - if (dimmInfo.dimmAttributes & BIT2) - mvOsOutput(" On-Card PLL (clock): Yes \n"); - else - mvOsOutput(" On-Card PLL (clock): No \n"); - - if (dimmInfo.dimmAttributes & BIT3) - mvOsOutput(" FET Switch On-Card Enabled: Yes \n"); - else - mvOsOutput(" FET Switch On-Card Enabled: No \n"); - - if (dimmInfo.dimmAttributes & BIT4) - mvOsOutput(" FET Switch External Enabled: Yes \n"); - else - mvOsOutput(" FET Switch External Enabled: No \n"); - - if (dimmInfo.dimmAttributes & BIT5) - mvOsOutput(" Differential Clock Input: Yes \n"); - else - mvOsOutput(" Differential Clock Input: No \n"); - } - else /* if (dimmInfo.memoryType == MEM_TYPE_DDR2) */ - { - mvOsOutput(" Number of Active Registers on the DIMM: %d\n", - (dimmInfo.dimmAttributes & 0x3) + 1); - - mvOsOutput(" Number of PLLs on the DIMM: %d\n", - ((dimmInfo.dimmAttributes) >> 2) & 0x3); - - if (dimmInfo.dimmAttributes & BIT4) - mvOsOutput(" FET Switch External Enabled: Yes \n"); - else - mvOsOutput(" FET Switch External Enabled: No \n"); - - if (dimmInfo.dimmAttributes & BIT6) - mvOsOutput(" Analysis probe installed: Yes \n"); - else - mvOsOutput(" Analysis probe installed: No \n"); - } - - break; -/*----------------------------------------------------------------------------*/ - - case 22: /* Suported AutoPreCharge */ - mvOsOutput("\nModul Attributes (SPD Byte 22): \n"); - if (dimmInfo.memoryType == MEM_TYPE_SDRAM) - { - if ( spdRawData[i] & BIT0 ) - mvOsOutput(" Early Ras Precharge: Yes \n"); - else - mvOsOutput(" Early Ras Precharge: No \n"); - - if ( spdRawData[i] & BIT1 ) - mvOsOutput(" AutoPreCharge: Yes \n"); - else - mvOsOutput(" AutoPreCharge: No \n"); - - if ( spdRawData[i] & BIT2 ) - mvOsOutput(" Precharge All: Yes \n"); - else - mvOsOutput(" Precharge All: No \n"); - - if ( spdRawData[i] & BIT3 ) - mvOsOutput(" Write 1/ReadBurst: Yes \n"); - else - mvOsOutput(" Write 1/ReadBurst: No \n"); - - if ( spdRawData[i] & BIT4 ) - mvOsOutput(" lower VCC tolerance: 5%%\n"); - else - mvOsOutput(" lower VCC tolerance: 10%%\n"); - - if ( spdRawData[i] & BIT5 ) - mvOsOutput(" upper VCC tolerance: 5%%\n"); - else - mvOsOutput(" upper VCC tolerance: 10%%\n"); - } - else if (dimmInfo.memoryType == MEM_TYPE_DDR1) - { - if ( spdRawData[i] & BIT0 ) - mvOsOutput(" Supports Weak Driver: Yes \n"); - else - mvOsOutput(" Supports Weak Driver: No \n"); - - if ( !(spdRawData[i] & BIT4) ) - mvOsOutput(" lower VCC tolerance: 0.2V\n"); - - if ( !(spdRawData[i] & BIT5) ) - mvOsOutput(" upper VCC tolerance: 0.2V\n"); - - if ( spdRawData[i] & BIT6 ) - mvOsOutput(" Concurrent Auto Preharge: Yes \n"); - else - mvOsOutput(" Concurrent Auto Preharge: No \n"); - - if ( spdRawData[i] & BIT7 ) - mvOsOutput(" Supports Fast AP: Yes \n"); - else - mvOsOutput(" Supports Fast AP: No \n"); - } - else if (dimmInfo.memoryType == MEM_TYPE_DDR2) - { - if ( spdRawData[i] & BIT0 ) - mvOsOutput(" Supports Weak Driver: Yes \n"); - else - mvOsOutput(" Supports Weak Driver: No \n"); - } - break; -/*----------------------------------------------------------------------------*/ - - case 23: - /* Minimum Cycle Time At Maximum Cas Latancy Minus 1 (2nd highest CL) */ - leftOfPoint = (spdRawData[i] & 0xf0) >> 4; - rightOfPoint = (spdRawData[i] & 0x0f) * 10; - - /* DDR2 addition of right of point */ - if ((spdRawData[i] & 0x0f) == 0xA) - { - rightOfPoint = 25; - } - if ((spdRawData[i] & 0x0f) == 0xB) - { - rightOfPoint = 33; - } - if ((spdRawData[i] & 0x0f) == 0xC) - { - rightOfPoint = 66; - } - if ((spdRawData[i] & 0x0f) == 0xD) - { - rightOfPoint = 75; - } - - mvOsOutput("Minimum Cycle Time At 2nd highest CasLatancy" - "(0 = Not supported): %d.%d [ns]\n", - leftOfPoint, rightOfPoint ); - break; -/*----------------------------------------------------------------------------*/ - - case 24: /* Clock To Data Out 2nd highest Cas Latency Value*/ - div = (dimmInfo.memoryType == MEM_TYPE_SDRAM) ? 10:100; - time_tmp = (((spdRawData[i] & 0xf0) >> 4)*10) + - ((spdRawData[i] & 0x0f)); - leftOfPoint = time_tmp / div; - rightOfPoint = time_tmp % div; - mvOsOutput("Clock To Data Out (2nd CL value): %d.%d [ns]\n", - leftOfPoint, rightOfPoint); - break; -/*----------------------------------------------------------------------------*/ - - case 25: - /* Minimum Cycle Time At Maximum Cas Latancy Minus 2 (3rd highest CL) */ - if (dimmInfo.memoryType == MEM_TYPE_SDRAM) - { - leftOfPoint = (spdRawData[i] & 0xfc) >> 2; - rightOfPoint = (spdRawData[i] & 0x3) * 25; - } - else /* DDR1 or DDR2 */ - { - leftOfPoint = (spdRawData[i] & 0xf0) >> 4; - rightOfPoint = (spdRawData[i] & 0x0f) * 10; - - /* DDR2 addition of right of point */ - if ((spdRawData[i] & 0x0f) == 0xA) - { - rightOfPoint = 25; - } - if ((spdRawData[i] & 0x0f) == 0xB) - { - rightOfPoint = 33; - } - if ((spdRawData[i] & 0x0f) == 0xC) - { - rightOfPoint = 66; - } - if ((spdRawData[i] & 0x0f) == 0xD) - { - rightOfPoint = 75; - } - } - mvOsOutput("Minimum Cycle Time At 3rd highest CasLatancy" - "(0 = Not supported): %d.%d [ns]\n", - leftOfPoint, rightOfPoint ); - break; -/*----------------------------------------------------------------------------*/ - - case 26: /* Clock To Data Out 3rd highest Cas Latency Value*/ - if (dimmInfo.memoryType == MEM_TYPE_SDRAM) - { - leftOfPoint = (spdRawData[i] & 0xfc) >> 2; - rightOfPoint = (spdRawData[i] & 0x3) * 25; - } - else /* DDR1 or DDR2 */ - { - time_tmp = (((spdRawData[i] & 0xf0) >> 4)*10) + - ((spdRawData[i] & 0x0f)); - leftOfPoint = 0; - rightOfPoint = time_tmp; - } - mvOsOutput("Clock To Data Out (3rd CL value): %d.%2d[ns]\n", - leftOfPoint, rightOfPoint ); - break; -/*----------------------------------------------------------------------------*/ - - case 27: /* Minimum Row Precharge Time */ - shift = (dimmInfo.memoryType == MEM_TYPE_SDRAM)? 0:2; - maskLeftOfPoint = (dimmInfo.memoryType == MEM_TYPE_SDRAM) ? - 0xff : 0xfc; - maskRightOfPoint = (dimmInfo.memoryType == MEM_TYPE_SDRAM) ? - 0x00 : 0x03; - leftOfPoint = ((spdRawData[i] & maskLeftOfPoint) >> shift); - rightOfPoint = (spdRawData[i] & maskRightOfPoint)*25; - temp = ((leftOfPoint*100) + rightOfPoint);/* in 10ps Intervals*/ - trp_clocks = (temp + (busClkPs-1)) / busClkPs; - mvOsOutput("Minimum Row Precharge Time [ns]: %d.%d = " - "in Clk cycles %d\n", - leftOfPoint, rightOfPoint, trp_clocks); - break; -/*----------------------------------------------------------------------------*/ - - case 28: /* Minimum Row Active to Row Active Time */ - shift = (dimmInfo.memoryType == MEM_TYPE_SDRAM)? 0:2; - maskLeftOfPoint = (dimmInfo.memoryType == MEM_TYPE_SDRAM) ? - 0xff : 0xfc; - maskRightOfPoint = (dimmInfo.memoryType == MEM_TYPE_SDRAM) ? - 0x00 : 0x03; - leftOfPoint = ((spdRawData[i] & maskLeftOfPoint) >> shift); - rightOfPoint = (spdRawData[i] & maskRightOfPoint)*25; - temp = ((leftOfPoint*100) + rightOfPoint);/* in 100ns Interval*/ - trrd_clocks = (temp + (busClkPs-1)) / busClkPs; - mvOsOutput("Minimum Row Active -To- Row Active Delay [ns]: " - "%d.%d = in Clk cycles %d\n", - leftOfPoint, rightOfPoint, trp_clocks); - break; -/*----------------------------------------------------------------------------*/ - - case 29: /* Minimum Ras-To-Cas Delay */ - shift = (dimmInfo.memoryType == MEM_TYPE_SDRAM)? 0:2; - maskLeftOfPoint = (dimmInfo.memoryType == MEM_TYPE_SDRAM) ? - 0xff : 0xfc; - maskRightOfPoint = (dimmInfo.memoryType == MEM_TYPE_SDRAM) ? - 0x00 : 0x03; - leftOfPoint = ((spdRawData[i] & maskLeftOfPoint) >> shift); - rightOfPoint = (spdRawData[i] & maskRightOfPoint)*25; - temp = ((leftOfPoint*100) + rightOfPoint);/* in 100ns Interval*/ - trcd_clocks = (temp + (busClkPs-1) )/ busClkPs; - mvOsOutput("Minimum Ras-To-Cas Delay [ns]: %d.%d = " - "in Clk cycles %d\n", - leftOfPoint, rightOfPoint, trp_clocks); - break; -/*----------------------------------------------------------------------------*/ - - case 30: /* Minimum Ras Pulse Width */ - tras_clocks = (cas2ps(spdRawData[i])+(busClkPs-1)) / busClkPs; - mvOsOutput("Minimum Ras Pulse Width [ns]: %d = " - "in Clk cycles %d\n", spdRawData[i], tras_clocks); - break; -/*----------------------------------------------------------------------------*/ - - case 31: /* Module Bank Density */ - mvOsOutput("Module Bank Density (more than 1= Multisize-Module):"); - - if (dimmInfo.memoryType == MEM_TYPE_SDRAM) - { - if (dimmInfo.dimmBankDensity & BIT0) - mvOsOutput("1GB, "); - if (dimmInfo.dimmBankDensity & BIT1) - mvOsOutput("8MB, "); - if (dimmInfo.dimmBankDensity & BIT2) - mvOsOutput("16MB, "); - if (dimmInfo.dimmBankDensity & BIT3) - mvOsOutput("32MB, "); - if (dimmInfo.dimmBankDensity & BIT4) - mvOsOutput("64MB, "); - if (dimmInfo.dimmBankDensity & BIT5) - mvOsOutput("128MB, "); - if (dimmInfo.dimmBankDensity & BIT6) - mvOsOutput("256MB, "); - if (dimmInfo.dimmBankDensity & BIT7) - mvOsOutput("512MB, "); - } - else if (dimmInfo.memoryType == MEM_TYPE_DDR1) - { - if (dimmInfo.dimmBankDensity & BIT0) - mvOsOutput("1GB, "); - if (dimmInfo.dimmBankDensity & BIT1) - mvOsOutput("2GB, "); - if (dimmInfo.dimmBankDensity & BIT2) - mvOsOutput("16MB, "); - if (dimmInfo.dimmBankDensity & BIT3) - mvOsOutput("32MB, "); - if (dimmInfo.dimmBankDensity & BIT4) - mvOsOutput("64MB, "); - if (dimmInfo.dimmBankDensity & BIT5) - mvOsOutput("128MB, "); - if (dimmInfo.dimmBankDensity & BIT6) - mvOsOutput("256MB, "); - if (dimmInfo.dimmBankDensity & BIT7) - mvOsOutput("512MB, "); - } - else /* if (dimmInfo.memoryType == MEM_TYPE_DDR2) */ - { - if (dimmInfo.dimmBankDensity & BIT0) - mvOsOutput("1GB, "); - if (dimmInfo.dimmBankDensity & BIT1) - mvOsOutput("2GB, "); - if (dimmInfo.dimmBankDensity & BIT2) - mvOsOutput("4GB, "); - if (dimmInfo.dimmBankDensity & BIT3) - mvOsOutput("8GB, "); - if (dimmInfo.dimmBankDensity & BIT4) - mvOsOutput("16GB, "); - if (dimmInfo.dimmBankDensity & BIT5) - mvOsOutput("128MB, "); - if (dimmInfo.dimmBankDensity & BIT6) - mvOsOutput("256MB, "); - if (dimmInfo.dimmBankDensity & BIT7) - mvOsOutput("512MB, "); - } - mvOsOutput("\n"); - break; -/*----------------------------------------------------------------------------*/ - - case 32: /* Address And Command Setup Time (measured in ns/1000) */ - if (dimmInfo.memoryType == MEM_TYPE_SDRAM) - { - rightOfPoint = (spdRawData[i] & 0x0f); - leftOfPoint = (spdRawData[i] & 0xf0) >> 4; - if(leftOfPoint > 7) - { - leftOfPoint *= -1; - } - } - else /* DDR1 or DDR2 */ - { - time_tmp = (((spdRawData[i] & 0xf0) >> 4)*10) + - ((spdRawData[i] & 0x0f)); - leftOfPoint = time_tmp / 100; - rightOfPoint = time_tmp % 100; - } - mvOsOutput("Address And Command Setup Time [ns]: %d.%d\n", - leftOfPoint, rightOfPoint); - break; -/*----------------------------------------------------------------------------*/ - - case 33: /* Address And Command Hold Time */ - if (dimmInfo.memoryType == MEM_TYPE_SDRAM) - { - rightOfPoint = (spdRawData[i] & 0x0f); - leftOfPoint = (spdRawData[i] & 0xf0) >> 4; - if(leftOfPoint > 7) - { - leftOfPoint *= -1; - } - } - else /* DDR1 or DDR2 */ - { - time_tmp = (((spdRawData[i] & 0xf0) >> 4)*10) + - ((spdRawData[i] & 0x0f)); - leftOfPoint = time_tmp / 100; - rightOfPoint = time_tmp % 100; - } - mvOsOutput("Address And Command Hold Time [ns]: %d.%d\n", - leftOfPoint, rightOfPoint); - break; -/*----------------------------------------------------------------------------*/ - - case 34: /* Data Input Setup Time */ - if (dimmInfo.memoryType == MEM_TYPE_SDRAM) - { - rightOfPoint = (spdRawData[i] & 0x0f); - leftOfPoint = (spdRawData[i] & 0xf0) >> 4; - if(leftOfPoint > 7) - { - leftOfPoint *= -1; - } - } - else /* DDR1 or DDR2 */ - { - time_tmp = (((spdRawData[i] & 0xf0) >> 4)*10) + - ((spdRawData[i] & 0x0f)); - leftOfPoint = time_tmp / 100; - rightOfPoint = time_tmp % 100; - } - mvOsOutput("Data Input Setup Time [ns]: %d.%d\n", - leftOfPoint, rightOfPoint); - break; -/*----------------------------------------------------------------------------*/ - - case 35: /* Data Input Hold Time */ - if (dimmInfo.memoryType == MEM_TYPE_SDRAM) - { - rightOfPoint = (spdRawData[i] & 0x0f); - leftOfPoint = (spdRawData[i] & 0xf0) >> 4; - if(leftOfPoint > 7) - { - leftOfPoint *= -1; - } - } - else /* DDR1 or DDR2 */ - { - time_tmp = (((spdRawData[i] & 0xf0) >> 4)*10) + - ((spdRawData[i] & 0x0f)); - leftOfPoint = time_tmp / 100; - rightOfPoint = time_tmp % 100; - } - mvOsOutput("Data Input Hold Time [ns]: %d.%d\n\n", - leftOfPoint, rightOfPoint); - break; -/*----------------------------------------------------------------------------*/ - - case 36: /* Relevant for DDR2 only: Write Recovery Time */ - leftOfPoint = ((spdRawData[i] & maskLeftOfPoint) >> 2); - rightOfPoint = (spdRawData[i] & maskRightOfPoint) * 25; - mvOsOutput("Write Recovery Time [ns]: %d.%d\n", - leftOfPoint, rightOfPoint); - break; -/*----------------------------------------------------------------------------*/ - } - -} - - -/* - * translate ns.ns/10 coding of SPD timing values - * into ps unit values - */ -/******************************************************************************* -* cas2ps - Translate x.y ns parameter to pico-seconds values -* -* DESCRIPTION: -* This function translates x.y nano seconds to its value in pico seconds. -* For example 3.75ns will return 3750. -* -* INPUT: -* spd_byte - DIMM SPD byte. -* -* OUTPUT: -* None. -* -* RETURN: -* value in pico seconds. -* -*******************************************************************************/ -static MV_U32 cas2ps(MV_U8 spd_byte) -{ - MV_U32 ns, ns10; - - /* isolate upper nibble */ - ns = (spd_byte >> 4) & 0x0F; - /* isolate lower nibble */ - ns10 = (spd_byte & 0x0F); - - if( ns10 < 10 ) { - ns10 *= 10; - } - else if( ns10 == 10 ) - ns10 = 25; - else if( ns10 == 11 ) - ns10 = 33; - else if( ns10 == 12 ) - ns10 = 66; - else if( ns10 == 13 ) - ns10 = 75; - else - { - mvOsOutput("cas2ps Err. unsupported cycle time.\n"); - } - - return (ns*1000 + ns10*10); -} - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr2/spd/mvSpd.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr2/spd/mvSpd.h deleted file mode 100644 index f955466..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/ddr2/spd/mvSpd.h +++ /dev/null @@ -1,192 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCmvDram -#define __INCmvDram - -#include "ddr2/mvDramIf.h" -#include "twsi/mvTwsi.h" - -#define MAX_DIMM_NUM 2 -#define SPD_SIZE 128 - -/* Dimm spd offsets */ -#define DIMM_MEM_TYPE 2 -#define DIMM_ROW_NUM 3 -#define DIMM_COL_NUM 4 -#define DIMM_MODULE_BANK_NUM 5 -#define DIMM_DATA_WIDTH 6 -#define DIMM_VOLT_IF 8 -#define DIMM_MIN_CC_AT_MAX_CAS 9 -#define DIMM_ERR_CHECK_TYPE 11 -#define DIMM_REFRESH_INTERVAL 12 -#define DIMM_SDRAM_WIDTH 13 -#define DIMM_ERR_CHECK_DATA_WIDTH 14 -#define DIMM_MIN_CLK_DEL 15 -#define DIMM_BURST_LEN_SUP 16 -#define DIMM_DEV_BANK_NUM 17 -#define DIMM_SUP_CAL 18 -#define DIMM_DDR2_TYPE_INFORMATION 20 /* DDR2 only */ -#define DIMM_BUF_ADDR_CONT_IN 21 -#define DIMM_MIN_CC_AT_MAX_CAS_MINUS1 23 -#define DIMM_MIN_CC_AT_MAX_CAS_MINUS2 25 -#define DIMM_MIN_ROW_PRECHARGE_TIME 27 -#define DIMM_MIN_ROW_ACTIVE_TO_ROW_ACTIVE 28 -#define DIMM_MIN_RAS_TO_CAS_DELAY 29 -#define DIMM_MIN_RAS_PULSE_WIDTH 30 -#define DIMM_BANK_DENSITY 31 -#define DIMM_MIN_WRITE_RECOVERY_TIME 36 -#define DIMM_MIN_WRITE_TO_READ_CMD_DELAY 37 -#define DIMM_MIN_READ_TO_PRECH_CMD_DELAY 38 -#define DIMM_MIN_REFRESH_TO_ACTIVATE_CMD 42 -#define DIMM_SPD_VERSION 62 - -/* Dimm Memory Type values */ -#define DIMM_MEM_TYPE_SDRAM 0x4 -#define DIMM_MEM_TYPE_DDR1 0x7 -#define DIMM_MEM_TYPE_DDR2 0x8 - -#define DIMM_MODULE_MANU_OFFS 64 -#define DIMM_MODULE_MANU_SIZE 8 -#define DIMM_MODULE_VEN_OFFS 73 -#define DIMM_MODULE_VEN_SIZE 25 -#define DIMM_MODULE_ID_OFFS 99 -#define DIMM_MODULE_ID_SIZE 18 - -/* enumeration for voltage levels. */ -typedef enum _mvDimmVoltageIf -{ - TTL_5V_TOLERANT, - LVTTL, - HSTL_1_5V, - SSTL_3_3V, - SSTL_2_5V, - VOLTAGE_UNKNOWN, -} MV_DIMM_VOLTAGE_IF; - - -/* enumaration for SDRAM CAS Latencies. */ -typedef enum _mvDimmSdramCas -{ - SD_CL_1 =1, - SD_CL_2, - SD_CL_3, - SD_CL_4, - SD_CL_5, - SD_CL_6, - SD_CL_7, - SD_FAULT -}MV_DIMM_SDRAM_CAS; - - -/* DIMM information structure */ -typedef struct _mvDimmInfo -{ - MV_MEMORY_TYPE memoryType; /* DDR or SDRAM */ - - MV_U8 spdRawData[SPD_SIZE]; /* Content of SPD-EEPROM copied 1:1 */ - - /* DIMM dimensions */ - MV_U32 numOfRowAddr; - MV_U32 numOfColAddr; - MV_U32 numOfModuleBanks; - MV_U32 dataWidth; - MV_U32 errorCheckType; /* ECC , PARITY..*/ - MV_U32 sdramWidth; /* 4,8,16 or 32 */ - MV_U32 errorCheckDataWidth; /* 0 - no, 1 - Yes */ - MV_U32 burstLengthSupported; - MV_U32 numOfBanksOnEachDevice; - MV_U32 suportedCasLatencies; - MV_U32 refreshInterval; - MV_U32 dimmBankDensity; - MV_U32 dimmTypeInfo; /* DDR2 only */ - MV_U32 dimmAttributes; - - /* DIMM timing parameters */ - MV_U32 minCycleTimeAtMaxCasLatPs; - MV_U32 minCycleTimeAtMaxCasLatMinus1Ps; - MV_U32 minCycleTimeAtMaxCasLatMinus2Ps; - MV_U32 minRowPrechargeTime; - MV_U32 minRowActiveToRowActive; - MV_U32 minRasToCasDelay; - MV_U32 minRasPulseWidth; - MV_U32 minWriteRecoveryTime; /* DDR2 only */ - MV_U32 minWriteToReadCmdDelay; /* DDR2 only */ - MV_U32 minReadToPrechCmdDelay; /* DDR2 only */ - MV_U32 minRefreshToActiveCmd; /* DDR2 only */ - - /* Parameters calculated from the extracted DIMM information */ - MV_U32 size; /* 16,64,128,256 or 512 MByte in MB units */ - MV_U32 deviceDensity; /* 16,64,128,256 or 512 Mbit in MB units */ - MV_U32 numberOfDevices; - -} MV_DIMM_INFO; - - -MV_STATUS mvDramBankInfoGet(MV_U32 bankNum, MV_DRAM_BANK_INFO *pBankInfo); -MV_STATUS dimmSpdGet(MV_U32 dimmNum, MV_DIMM_INFO *pDimmInfo); -MV_VOID dimmSpdPrint(MV_U32 dimmNum); -MV_STATUS dimmSpdCpy(MV_VOID); - -#endif /* __INCmvDram */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/eth/gbe/mvEth.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/eth/gbe/mvEth.c deleted file mode 100644 index d24e788..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/eth/gbe/mvEth.c +++ /dev/null @@ -1,2952 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -/******************************************************************************* -* mvEth.c - Marvell's Gigabit Ethernet controller low level driver -* -* DESCRIPTION: -* This file introduce OS independent APIs to Marvell's Gigabit Ethernet -* controller. This Gigabit Ethernet Controller driver API controls -* 1) Operations (i.e. port Init, Finish, Up, Down, PhyReset etc'). -* 2) Data flow (i.e. port Send, Receive etc'). -* 3) MAC Filtering functions (ethSetMcastAddr, ethSetRxFilterMode, etc.) -* 4) MIB counters support (ethReadMibCounter) -* 5) Debug functions (ethPortRegs, ethPortCounters, ethPortQueues, etc.) -* Each Gigabit Ethernet port is controlled via ETH_PORT_CTRL struct. -* This struct includes configuration information as well as driver -* internal data needed for its operations. -* -* Supported Features: -* - OS independent. All required OS services are implemented via external -* OS dependent components (like osLayer or ethOsg) -* - The user is free from Rx/Tx queue managing. -* - Simple Gigabit Ethernet port operation API. -* - Simple Gigabit Ethernet port data flow API. -* - Data flow and operation API support per queue functionality. -* - Support cached descriptors for better performance. -* - PHY access and control API. -* - Port Configuration API. -* - Full control over Special and Other Multicast MAC tables. -* -*******************************************************************************/ -/* includes */ -#include "mvTypes.h" -#include "mv802_3.h" -#include "mvDebug.h" -#include "mvCommon.h" -#include "mvOs.h" -#include "ctrlEnv/mvCtrlEnvLib.h" -#include "eth-phy/mvEthPhy.h" -#include "eth/mvEth.h" -#include "eth/gbe/mvEthGbe.h" -#include "cpu/mvCpu.h" - -#ifdef INCLUDE_SYNC_BARR -#include "sys/mvCpuIf.h" -#endif - -#ifdef MV_RT_DEBUG -# define ETH_DEBUG -#endif - - -/* locals */ -MV_BOOL ethDescInSram; -MV_BOOL ethDescSwCoher; - -/* This array holds the control structure of each port */ -ETH_PORT_CTRL* ethPortCtrl[MV_ETH_MAX_PORTS]; - -/* Ethernet Port Local routines */ - -static void ethInitRxDescRing(ETH_PORT_CTRL* pPortCtrl, int queue); - -static void ethInitTxDescRing(ETH_PORT_CTRL* pPortCtrl, int queue); - -static void ethSetUcastTable(int portNo, int queue); - -static MV_BOOL ethSetUcastAddr (int ethPortNum, MV_U8 lastNibble, int queue); -static MV_BOOL ethSetSpecialMcastAddr(int ethPortNum, MV_U8 lastByte, int queue); -static MV_BOOL ethSetOtherMcastAddr(int ethPortNum, MV_U8 crc8, int queue); - -static void ethFreeDescrMemory(ETH_PORT_CTRL* pEthPortCtrl, MV_BUF_INFO* pDescBuf); -static MV_U8* ethAllocDescrMemory(ETH_PORT_CTRL* pEthPortCtrl, int size, - MV_ULONG* pPhysAddr, MV_U32 *memHandle); - -static MV_U32 mvEthMruGet(MV_U32 maxRxPktSize); - -static void mvEthPortSgmiiConfig(int port); - - - -/******************************************************************************/ -/* EthDrv Initialization functions */ -/******************************************************************************/ - -/******************************************************************************* -* mvEthHalInit - Initialize the Giga Ethernet unit -* -* DESCRIPTION: -* This function initialize the Giga Ethernet unit. -* 1) Configure Address decode windows of the unit -* 2) Set registers to HW default values. -* 3) Clear and Disable interrupts -* -* INPUT: NONE -* -* RETURN: NONE -* -* NOTE: this function is called once in the boot process. -*******************************************************************************/ -void mvEthHalInit(void) -{ - int port; - - /* Init static data structures */ - for (port=0; port<MV_ETH_MAX_PORTS; port++) - { - ethPortCtrl[port] = NULL; - } - /* Power down all existing ports */ - for(port=0; port<mvCtrlEthMaxPortGet(); port++) - { - -#if defined (MV78200) - /* Skip ports mapped to another CPU*/ - if (MV_FALSE == mvSocUnitIsMappedToThisCpu(GIGA0+port)) - { - continue; - } -#endif - - /* Skip power down ports */ - if (MV_FALSE == mvCtrlPwrClckGet(ETH_GIG_UNIT_ID, port)) continue; - - /* Disable Giga Ethernet Unit interrupts */ - MV_REG_WRITE(ETH_UNIT_INTR_MASK_REG(port), 0); - - /* Clear ETH_UNIT_INTR_CAUSE_REG register */ - MV_REG_WRITE(ETH_UNIT_INTR_CAUSE_REG(port), 0); - - } - - mvEthMemAttrGet(ðDescInSram, ðDescSwCoher); - -#if defined(ETH_DESCR_IN_SRAM) - if(ethDescInSram == MV_FALSE) - { - mvOsPrintf("ethDrv: WARNING! Descriptors will be allocated in DRAM instead of SRAM.\n"); - } -#endif /* ETH_DESCR_IN_SRAM */ -} - -/******************************************************************************* -* mvEthMemAttrGet - Define properties (SRAM/DRAM, SW_COHER / HW_COHER / UNCACHED) -* of of memory location for RX and TX descriptors. -* -* DESCRIPTION: -* This function allocates memory for RX and TX descriptors. -* - If ETH_DESCR_IN_SRAM defined, allocate from SRAM memory. -* - If ETH_DESCR_IN_SDRAM defined, allocate from SDRAM memory. -* -* INPUT: -* MV_BOOL* pIsSram - place of descriptors: -* MV_TRUE - in SRAM -* MV_FALSE - in DRAM -* MV_BOOL* pIsSwCoher - cache coherency of descriptors: -* MV_TRUE - driver is responsible for cache coherency -* MV_FALSE - driver is not responsible for cache coherency -* -* RETURN: -* -*******************************************************************************/ -void mvEthMemAttrGet(MV_BOOL* pIsSram, MV_BOOL* pIsSwCoher) -{ - MV_BOOL isSram, isSwCoher; - - isSram = MV_FALSE; -#if (ETHER_DRAM_COHER == MV_CACHE_COHER_SW) - isSwCoher = MV_TRUE; -#else - isSwCoher = MV_FALSE; -#endif - -#if defined(ETH_DESCR_IN_SRAM) - if( mvCtrlSramSizeGet() > 0) - { - isSram = MV_TRUE; - #if (INTEG_SRAM_COHER == MV_CACHE_COHER_SW) - isSwCoher = MV_TRUE; - #else - isSwCoher = MV_FALSE; - #endif - } -#endif /* ETH_DESCR_IN_SRAM */ - - if(pIsSram != NULL) - *pIsSram = isSram; - - if(pIsSwCoher != NULL) - *pIsSwCoher = isSwCoher; -} - - - -/******************************************************************************/ -/* Port Initialization functions */ -/******************************************************************************/ - -/******************************************************************************* -* mvEthPortInit - Initialize the Ethernet port driver -* -* DESCRIPTION: -* This function initialize the ethernet port. -* 1) Allocate and initialize internal port Control structure. -* 2) Create RX and TX descriptor rings for default RX and TX queues -* 3) Disable RX and TX operations, clear cause registers and -* mask all interrupts. -* 4) Set all registers to default values and clean all MAC tables. -* -* INPUT: -* int portNo - Ethernet port number -* ETH_PORT_INIT *pEthPortInit - Ethernet port init structure -* -* RETURN: -* void* - ethernet port handler, that should be passed to the most other -* functions dealing with this port. -* -* NOTE: This function is called once per port when loading the eth module. -*******************************************************************************/ -void* mvEthPortInit(int portNo, MV_ETH_PORT_INIT *pEthPortInit) -{ - int queue, descSize; - ETH_PORT_CTRL* pPortCtrl; - - /* Check validity of parameters */ - if( (portNo >= (int)mvCtrlEthMaxPortGet()) || - (pEthPortInit->rxDefQ >= MV_ETH_RX_Q_NUM) || - (pEthPortInit->maxRxPktSize < 1518) ) - { - mvOsPrintf("EthPort #%d: Bad initialization parameters\n", portNo); - return NULL; - } - if( (pEthPortInit->rxDescrNum[pEthPortInit->rxDefQ]) == 0) - { - mvOsPrintf("EthPort #%d: rxDefQ (%d) must be created\n", - portNo, pEthPortInit->rxDefQ); - return NULL; - } - - pPortCtrl = (ETH_PORT_CTRL*)mvOsMalloc( sizeof(ETH_PORT_CTRL) ); - if(pPortCtrl == NULL) - { - mvOsPrintf("EthDrv: Can't allocate %dB for port #%d control structure!\n", - (int)sizeof(ETH_PORT_CTRL), portNo); - return NULL; - } - - memset(pPortCtrl, 0, sizeof(ETH_PORT_CTRL) ); - ethPortCtrl[portNo] = pPortCtrl; - - pPortCtrl->portState = MV_UNDEFINED_STATE; - - pPortCtrl->portNo = portNo; - - pPortCtrl->osHandle = pEthPortInit->osHandle; - - /* Copy Configuration parameters */ - pPortCtrl->portConfig.maxRxPktSize = pEthPortInit->maxRxPktSize; - pPortCtrl->portConfig.rxDefQ = pEthPortInit->rxDefQ; - pPortCtrl->portConfig.ejpMode = 0; - - for( queue=0; queue<MV_ETH_RX_Q_NUM; queue++ ) - { - pPortCtrl->rxQueueConfig[queue].descrNum = pEthPortInit->rxDescrNum[queue]; - } - for( queue=0; queue<MV_ETH_TX_Q_NUM; queue++ ) - { - pPortCtrl->txQueueConfig[queue].descrNum = pEthPortInit->txDescrNum[queue]; - } - - mvEthPortDisable(pPortCtrl); - - /* Set the board information regarding PHY address */ - mvEthPhyAddrSet(pPortCtrl, mvBoardPhyAddrGet(portNo) ); - - /* Create all requested RX queues */ - for(queue=0; queue<MV_ETH_RX_Q_NUM; queue++) - { - if(pPortCtrl->rxQueueConfig[queue].descrNum == 0) - continue; - - /* Allocate memory for RX descriptors */ - descSize = ((pPortCtrl->rxQueueConfig[queue].descrNum * ETH_RX_DESC_ALIGNED_SIZE) + - CPU_D_CACHE_LINE_SIZE); - - pPortCtrl->rxQueue[queue].descBuf.bufVirtPtr = - ethAllocDescrMemory(pPortCtrl, descSize, - &pPortCtrl->rxQueue[queue].descBuf.bufPhysAddr, - &pPortCtrl->rxQueue[queue].descBuf.memHandle); - pPortCtrl->rxQueue[queue].descBuf.bufSize = descSize; - if(pPortCtrl->rxQueue[queue].descBuf.bufVirtPtr == NULL) - { - mvOsPrintf("EthPort #%d, rxQ=%d: Can't allocate %d bytes in %s for %d RX descr\n", - pPortCtrl->portNo, queue, descSize, - ethDescInSram ? "SRAM" : "DRAM", - pPortCtrl->rxQueueConfig[queue].descrNum); - return NULL; - } - - ethInitRxDescRing(pPortCtrl, queue); - } - /* Create TX queues */ - for(queue=0; queue<MV_ETH_TX_Q_NUM; queue++) - { - if(pPortCtrl->txQueueConfig[queue].descrNum == 0) - continue; - - /* Allocate memory for TX descriptors */ - descSize = ((pPortCtrl->txQueueConfig[queue].descrNum * ETH_TX_DESC_ALIGNED_SIZE) + - CPU_D_CACHE_LINE_SIZE); - - pPortCtrl->txQueue[queue].descBuf.bufVirtPtr = - ethAllocDescrMemory(pPortCtrl, descSize, - &pPortCtrl->txQueue[queue].descBuf.bufPhysAddr, - &pPortCtrl->txQueue[queue].descBuf.memHandle); - pPortCtrl->txQueue[queue].descBuf.bufSize = descSize; - if(pPortCtrl->txQueue[queue].descBuf.bufVirtPtr == NULL) - { - mvOsPrintf("EthPort #%d, txQ=%d: Can't allocate %d bytes in %s for %d TX descr\n", - pPortCtrl->portNo, queue, descSize, ethDescInSram ? "SRAM" : "DRAM", - pPortCtrl->txQueueConfig[queue].descrNum); - return NULL; - } - - ethInitTxDescRing(pPortCtrl, queue); - } - mvEthDefaultsSet(pPortCtrl); - - pPortCtrl->portState = MV_IDLE; - return pPortCtrl; -} - -/******************************************************************************* -* ethPortFinish - Finish the Ethernet port driver -* -* DESCRIPTION: -* This function finish the ethernet port. -* 1) Down ethernet port if needed. -* 2) Delete RX and TX descriptor rings for all created RX and TX queues -* 3) Free internal port Control structure. -* -* INPUT: -* void* pEthPortHndl - Ethernet port handler -* -* RETURN: NONE. -* -*******************************************************************************/ -void mvEthPortFinish(void* pPortHndl) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHndl; - int queue, portNo = pPortCtrl->portNo; - - if(pPortCtrl->portState == MV_ACTIVE) - { - mvOsPrintf("ethPort #%d: Warning !!! Finish port in Active state\n", - portNo); - mvEthPortDisable(pPortHndl); - } - - /* Free all allocated RX queues */ - for(queue=0; queue<MV_ETH_RX_Q_NUM; queue++) - { - ethFreeDescrMemory(pPortCtrl, &pPortCtrl->rxQueue[queue].descBuf); - } - - /* Free all allocated TX queues */ - for(queue=0; queue<MV_ETH_TX_Q_NUM; queue++) - { - ethFreeDescrMemory(pPortCtrl, &pPortCtrl->txQueue[queue].descBuf); - } - - /* Free port control structure */ - mvOsFree(pPortCtrl); - - ethPortCtrl[portNo] = NULL; -} - -/******************************************************************************* -* mvEthDefaultsSet - Set defaults to the ethernet port -* -* DESCRIPTION: -* This function set default values to the ethernet port. -* 1) Clear Cause registers and Mask all interrupts -* 2) Clear all MAC tables -* 3) Set defaults to all registers -* 4) Reset all created RX and TX descriptors ring -* 5) Reset PHY -* -* INPUT: -* void* pEthPortHndl - Ethernet port handler -* -* RETURN: MV_STATUS -* MV_OK - Success, Others - Failure -* NOTE: -* This function update all the port configuration except those set -* Initialy by the OsGlue by MV_ETH_PORT_INIT. -* This function can be called after portDown to return the port setting -* to defaults. -*******************************************************************************/ -MV_STATUS mvEthDefaultsSet(void* pPortHndl) -{ - int ethPortNo, queue; - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHndl; - ETH_QUEUE_CTRL* pQueueCtrl; - MV_U32 txPrio; - MV_U32 portCfgReg, portCfgExtReg, portSerialCtrlReg, portSerialCtrl1Reg, portSdmaCfgReg; - MV_BOARD_MAC_SPEED boardMacCfg; - - ethPortNo = pPortCtrl->portNo; - - /* Clear Cause registers */ - MV_REG_WRITE(ETH_INTR_CAUSE_REG(ethPortNo),0); - MV_REG_WRITE(ETH_INTR_CAUSE_EXT_REG(ethPortNo),0); - - /* Mask all interrupts */ - MV_REG_WRITE(ETH_INTR_MASK_REG(ethPortNo),0); - MV_REG_WRITE(ETH_INTR_MASK_EXT_REG(ethPortNo),0); - - portCfgReg = PORT_CONFIG_VALUE; - portCfgExtReg = PORT_CONFIG_EXTEND_VALUE; - - boardMacCfg = mvBoardMacSpeedGet(ethPortNo); - - if(boardMacCfg == BOARD_MAC_SPEED_100M) - { - portSerialCtrlReg = PORT_SERIAL_CONTROL_100MB_FORCE_VALUE; - } - else if(boardMacCfg == BOARD_MAC_SPEED_1000M) - { - portSerialCtrlReg = PORT_SERIAL_CONTROL_1000MB_FORCE_VALUE; - } - else - { - portSerialCtrlReg = PORT_SERIAL_CONTROL_VALUE; - } - - /* build PORT_SDMA_CONFIG_REG */ - portSdmaCfgReg = ETH_TX_INTR_COAL_MASK(0); - portSdmaCfgReg |= ETH_TX_BURST_SIZE_MASK(ETH_BURST_SIZE_16_64BIT_VALUE); - -#if ( (ETHER_DRAM_COHER == MV_CACHE_COHER_HW_WB) || \ - (ETHER_DRAM_COHER == MV_CACHE_COHER_HW_WT) ) - /* some devices have restricted RX burst size when using HW coherency */ - portSdmaCfgReg |= ETH_RX_BURST_SIZE_MASK(ETH_BURST_SIZE_4_64BIT_VALUE); -#else - portSdmaCfgReg |= ETH_RX_BURST_SIZE_MASK(ETH_BURST_SIZE_16_64BIT_VALUE); -#endif - -#if defined(MV_CPU_BE) - /* big endian */ -# if defined(MV_ARM) - portSdmaCfgReg |= (ETH_RX_NO_DATA_SWAP_MASK | - ETH_TX_NO_DATA_SWAP_MASK | - ETH_DESC_SWAP_MASK); -# elif defined(MV_PPC) - portSdmaCfgReg |= (ETH_RX_DATA_SWAP_MASK | - ETH_TX_DATA_SWAP_MASK | - ETH_NO_DESC_SWAP_MASK); -# else -# error "Giga Ethernet Swap policy is not defined for the CPU_ARCH" -# endif /* MV_ARM / MV_PPC */ - -#else /* MV_CPU_LE */ - /* little endian */ - portSdmaCfgReg |= (ETH_RX_NO_DATA_SWAP_MASK | - ETH_TX_NO_DATA_SWAP_MASK | - ETH_NO_DESC_SWAP_MASK); -#endif /* MV_CPU_BE / MV_CPU_LE */ - - pPortCtrl->portRxQueueCmdReg = 0; - pPortCtrl->portTxQueueCmdReg = 0; - -#if (MV_ETH_VERSION >= 4) - if(pPortCtrl->portConfig.ejpMode == MV_TRUE) - { - MV_REG_WRITE(ETH_TXQ_CMD_1_REG(ethPortNo), ETH_TX_EJP_ENABLE_MASK); - } - else - { - MV_REG_WRITE(ETH_TXQ_CMD_1_REG(ethPortNo), 0) - } -#endif /* (MV_ETH_VERSION >= 4) */ - - ethSetUcastTable(ethPortNo, -1); - mvEthSetSpecialMcastTable(ethPortNo, -1); - mvEthSetOtherMcastTable(ethPortNo, -1); - - portSerialCtrlReg &= ~ETH_MAX_RX_PACKET_SIZE_MASK; - - portSerialCtrlReg |= mvEthMruGet(pPortCtrl->portConfig.maxRxPktSize); - - MV_REG_WRITE(ETH_PORT_SERIAL_CTRL_REG(ethPortNo), portSerialCtrlReg); - - /* Update value of PortConfig register accordingly with all RxQueue types */ - pPortCtrl->portConfig.rxArpQ = pPortCtrl->portConfig.rxDefQ; - pPortCtrl->portConfig.rxBpduQ = pPortCtrl->portConfig.rxDefQ; - pPortCtrl->portConfig.rxTcpQ = pPortCtrl->portConfig.rxDefQ; - pPortCtrl->portConfig.rxUdpQ = pPortCtrl->portConfig.rxDefQ; - - portCfgReg &= ~ETH_DEF_RX_QUEUE_ALL_MASK; - portCfgReg |= ETH_DEF_RX_QUEUE_MASK(pPortCtrl->portConfig.rxDefQ); - - portCfgReg &= ~ETH_DEF_RX_ARP_QUEUE_ALL_MASK; - portCfgReg |= ETH_DEF_RX_ARP_QUEUE_MASK(pPortCtrl->portConfig.rxArpQ); - - portCfgReg &= ~ETH_DEF_RX_BPDU_QUEUE_ALL_MASK; - portCfgReg |= ETH_DEF_RX_BPDU_QUEUE_MASK(pPortCtrl->portConfig.rxBpduQ); - - portCfgReg &= ~ETH_DEF_RX_TCP_QUEUE_ALL_MASK; - portCfgReg |= ETH_DEF_RX_TCP_QUEUE_MASK(pPortCtrl->portConfig.rxTcpQ); - - portCfgReg &= ~ETH_DEF_RX_UDP_QUEUE_ALL_MASK; - portCfgReg |= ETH_DEF_RX_UDP_QUEUE_MASK(pPortCtrl->portConfig.rxUdpQ); - - /* Assignment of Tx CTRP of given queue */ - txPrio = 0; - - for(queue=0; queue<MV_ETH_TX_Q_NUM; queue++) - { - pQueueCtrl = &pPortCtrl->txQueue[queue]; - - if(pQueueCtrl->pFirstDescr != NULL) - { - ethResetTxDescRing(pPortCtrl, queue); - - MV_REG_WRITE(ETH_TXQ_TOKEN_COUNT_REG(ethPortNo, queue), - 0x3fffffff); - MV_REG_WRITE(ETH_TXQ_TOKEN_CFG_REG(ethPortNo, queue), - 0x03ffffff); - } - else - { - MV_REG_WRITE(ETH_TXQ_TOKEN_COUNT_REG(ethPortNo, queue), 0x0); - MV_REG_WRITE(ETH_TXQ_TOKEN_CFG_REG(ethPortNo, queue), 0x0); - } - } - - /* Assignment of Rx CRDP of given queue */ - for(queue=0; queue<MV_ETH_RX_Q_NUM; queue++) - { - ethResetRxDescRing(pPortCtrl, queue); - } - - /* Allow receiving packes with odd number of preamble nibbles */ - portSerialCtrl1Reg = MV_REG_READ(ETH_PORT_SERIAL_CTRL_1_REG(ethPortNo)); - portSerialCtrl1Reg |= ETH_EN_MII_ODD_PRE_MASK; - MV_REG_WRITE(ETH_PORT_SERIAL_CTRL_1_REG(ethPortNo), portSerialCtrl1Reg); - - /* Assign port configuration and command. */ - MV_REG_WRITE(ETH_PORT_CONFIG_REG(ethPortNo), portCfgReg); - - MV_REG_WRITE(ETH_PORT_CONFIG_EXTEND_REG(ethPortNo), portCfgExtReg); - - /* Assign port SDMA configuration */ - MV_REG_WRITE(ETH_SDMA_CONFIG_REG(ethPortNo), portSdmaCfgReg); - - /* Turn off the port/queue bandwidth limitation */ - MV_REG_WRITE(ETH_MAX_TRANSMIT_UNIT_REG(ethPortNo), 0x0); - - return MV_OK; -} - -/******************************************************************************* -* ethPortUp - Start the Ethernet port RX and TX activity. -* -* DESCRIPTION: -* This routine start Rx and Tx activity: -* -* Note: Each Rx and Tx queue descriptor's list must be initialized prior -* to calling this function (use etherInitTxDescRing for Tx queues and -* etherInitRxDescRing for Rx queues). -* -* INPUT: -* void* pEthPortHndl - Ethernet port handler -* -* RETURN: MV_STATUS -* MV_OK - Success, Others - Failure. -* -* NOTE : used for port link up. -*******************************************************************************/ -MV_STATUS mvEthPortUp(void* pEthPortHndl) -{ - int ethPortNo; - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pEthPortHndl; - - ethPortNo = pPortCtrl->portNo; - - if( (pPortCtrl->portState != MV_ACTIVE) && - (pPortCtrl->portState != MV_PAUSED) ) - { - mvOsPrintf("ethDrv port%d: Unexpected port state %d\n", - ethPortNo, pPortCtrl->portState); - return MV_BAD_STATE; - } - - ethPortNo = pPortCtrl->portNo; - - /* Enable port RX. */ - MV_REG_WRITE(ETH_RX_QUEUE_COMMAND_REG(ethPortNo), pPortCtrl->portRxQueueCmdReg); - - /* Enable port TX. */ - MV_REG_VALUE(ETH_TX_QUEUE_COMMAND_REG(ethPortNo)) = pPortCtrl->portTxQueueCmdReg; - - pPortCtrl->portState = MV_ACTIVE; - - return MV_OK; -} - -/******************************************************************************* -* ethPortDown - Stop the Ethernet port activity. -* -* DESCRIPTION: -* -* INPUT: -* void* pEthPortHndl - Ethernet port handler -* -* RETURN: MV_STATUS -* MV_OK - Success, Others - Failure. -* -* NOTE : used for port link down. -*******************************************************************************/ -MV_STATUS mvEthPortDown(void* pEthPortHndl) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pEthPortHndl; - int ethPortNum = pPortCtrl->portNo; - unsigned int regData; - volatile int uDelay, mDelay; - - /* Stop Rx port activity. Check port Rx activity. */ - regData = (MV_REG_READ(ETH_RX_QUEUE_COMMAND_REG(ethPortNum))) & ETH_RXQ_ENABLE_MASK; - if(regData != 0) - { - /* Issue stop command for active channels only */ - MV_REG_WRITE(ETH_RX_QUEUE_COMMAND_REG(ethPortNum), (regData << ETH_RXQ_DISABLE_OFFSET)); - } - - /* Stop Tx port activity. Check port Tx activity. */ - regData = (MV_REG_READ(ETH_TX_QUEUE_COMMAND_REG(ethPortNum))) & ETH_TXQ_ENABLE_MASK; - if(regData != 0) - { - /* Issue stop command for active channels only */ - MV_REG_WRITE(ETH_TX_QUEUE_COMMAND_REG(ethPortNum), - (regData << ETH_TXQ_DISABLE_OFFSET) ); - } - - /* Force link down */ -/* - regData = MV_REG_READ(ETH_PORT_SERIAL_CTRL_REG(ethPortNum)); - regData &= ~(ETH_DO_NOT_FORCE_LINK_FAIL_MASK); - MV_REG_WRITE(ETH_PORT_SERIAL_CTRL_REG(ethPortNum), regData); -*/ - /* Wait for all Rx activity to terminate. */ - mDelay = 0; - do - { - if(mDelay >= RX_DISABLE_TIMEOUT_MSEC) - { - mvOsPrintf("ethPort_%d: TIMEOUT for RX stopped !!! rxQueueCmd - 0x08%x\n", - ethPortNum, regData); - break; - } - mvOsDelay(1); - mDelay++; - - /* Check port RX Command register that all Rx queues are stopped */ - regData = MV_REG_READ(ETH_RX_QUEUE_COMMAND_REG(ethPortNum)); - } - while(regData & 0xFF); - - /* Wait for all Tx activity to terminate. */ - mDelay = 0; - do - { - if(mDelay >= TX_DISABLE_TIMEOUT_MSEC) - { - mvOsPrintf("ethPort_%d: TIMEOUT for TX stoped !!! txQueueCmd - 0x08%x\n", - ethPortNum, regData); - break; - } - mvOsDelay(1); - mDelay++; - - /* Check port TX Command register that all Tx queues are stopped */ - regData = MV_REG_READ(ETH_TX_QUEUE_COMMAND_REG(ethPortNum)); - } - while(regData & 0xFF); - - /* Double check to Verify that TX FIFO is Empty */ - mDelay = 0; - while(MV_TRUE) - { - do - { - if(mDelay >= TX_FIFO_EMPTY_TIMEOUT_MSEC) - { - mvOsPrintf("\n ethPort_%d: TIMEOUT for TX FIFO empty !!! portStatus - 0x08%x\n", - ethPortNum, regData); - break; - } - mvOsDelay(1); - mDelay++; - - regData = MV_REG_READ(ETH_PORT_STATUS_REG(ethPortNum)); - } - while( ((regData & ETH_TX_FIFO_EMPTY_MASK) == 0) || - ((regData & ETH_TX_IN_PROGRESS_MASK) != 0) ); - - if(mDelay >= TX_FIFO_EMPTY_TIMEOUT_MSEC) - break; - - /* Double check */ - regData = MV_REG_READ(ETH_PORT_STATUS_REG(ethPortNum)); - if( ((regData & ETH_TX_FIFO_EMPTY_MASK) != 0) && - ((regData & ETH_TX_IN_PROGRESS_MASK) == 0) ) - { - break; - } - else - mvOsPrintf("ethPort_%d: TX FIFO Empty double check failed. %d msec, portStatus=0x%x\n", - ethPortNum, mDelay, regData); - } - - /* Do NOT force link down */ -/* - regData = MV_REG_READ(ETH_PORT_SERIAL_CTRL_REG(ethPortNum)); - regData |= (ETH_DO_NOT_FORCE_LINK_FAIL_MASK); - MV_REG_WRITE(ETH_PORT_SERIAL_CTRL_REG(ethPortNum), regData); -*/ - /* Wait about 2500 tclk cycles */ - uDelay = (PORT_DISABLE_WAIT_TCLOCKS/(mvBoardTclkGet()/1000000)); - mvOsUDelay(uDelay); - - pPortCtrl->portState = MV_PAUSED; - - return MV_OK; -} - - -/******************************************************************************* -* ethPortEnable - Enable the Ethernet port and Start RX and TX. -* -* DESCRIPTION: -* This routine enable the Ethernet port and Rx and Tx activity: -* -* Note: Each Rx and Tx queue descriptor's list must be initialized prior -* to calling this function (use etherInitTxDescRing for Tx queues and -* etherInitRxDescRing for Rx queues). -* -* INPUT: -* void* pEthPortHndl - Ethernet port handler -* -* RETURN: MV_STATUS -* MV_OK - Success, Others - Failure. -* -* NOTE: main usage is to enable the port after ifconfig up. -*******************************************************************************/ -MV_STATUS mvEthPortEnable(void* pEthPortHndl) -{ - int ethPortNo; - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pEthPortHndl; - MV_U32 portSerialCtrlReg; - - ethPortNo = pPortCtrl->portNo; - - /* Enable port */ - portSerialCtrlReg = MV_REG_READ(ETH_PORT_SERIAL_CTRL_REG(ethPortNo)); - portSerialCtrlReg |= (ETH_DO_NOT_FORCE_LINK_FAIL_MASK | ETH_PORT_ENABLE_MASK); - - MV_REG_WRITE(ETH_PORT_SERIAL_CTRL_REG(ethPortNo), portSerialCtrlReg); - - mvEthMibCountersClear(pEthPortHndl); - - pPortCtrl->portState = MV_PAUSED; - - /* If Link is UP, Start RX and TX traffic */ - if( MV_REG_READ( ETH_PORT_STATUS_REG(ethPortNo) ) & ETH_LINK_UP_MASK) - return( mvEthPortUp(pEthPortHndl) ); - - return MV_NOT_READY; -} - - -/******************************************************************************* -* mvEthPortDisable - Stop RX and TX activities and Disable the Ethernet port. -* -* DESCRIPTION: -* -* INPUT: -* void* pEthPortHndl - Ethernet port handler -* -* RETURN: MV_STATUS -* MV_OK - Success, Others - Failure. -* -* NOTE: main usage is to disable the port after ifconfig down. -*******************************************************************************/ -MV_STATUS mvEthPortDisable(void* pEthPortHndl) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pEthPortHndl; - int ethPortNum = pPortCtrl->portNo; - unsigned int regData; - volatile int mvDelay; - - if(pPortCtrl->portState == MV_ACTIVE) - { - /* Stop RX and TX activities */ - mvEthPortDown(pEthPortHndl); - } - - /* Reset the Enable bit in the Serial Control Register */ - regData = MV_REG_READ(ETH_PORT_SERIAL_CTRL_REG(ethPortNum)); - regData &= ~(ETH_PORT_ENABLE_MASK); - MV_REG_WRITE(ETH_PORT_SERIAL_CTRL_REG(ethPortNum), regData); - - /* Wait about 2500 tclk cycles */ - mvDelay = (PORT_DISABLE_WAIT_TCLOCKS*(mvCpuPclkGet()/mvBoardTclkGet())); - for(mvDelay; mvDelay>0; mvDelay--); - - pPortCtrl->portState = MV_IDLE; - return MV_OK; -} - -/******************************************************************************* -* mvEthPortForceTxDone - Get next buffer from TX queue in spite of buffer ownership. -* -* DESCRIPTION: -* This routine used to free buffers attached to the Tx ring and should -* be called only when Giga Ethernet port is Down -* -* INPUT: -* void* pEthPortHndl - Ethernet Port handler. -* int txQueue - Number of TX queue. -* -* OUTPUT: -* MV_PKT_INFO *pPktInfo - Pointer to packet was sent. -* -* RETURN: -* MV_EMPTY - There is no more buffers in this queue. -* MV_OK - Buffer detached from the queue and pPktInfo structure -* filled with relevant information. -* -*******************************************************************************/ -MV_PKT_INFO* mvEthPortForceTxDone(void* pEthPortHndl, int txQueue) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pEthPortHndl; - ETH_QUEUE_CTRL* pQueueCtrl; - MV_PKT_INFO* pPktInfo; - ETH_TX_DESC* pTxDesc; - int port = pPortCtrl->portNo; - - pQueueCtrl = &pPortCtrl->txQueue[txQueue]; - - while( (pQueueCtrl->pUsedDescr != pQueueCtrl->pCurrentDescr) || - (pQueueCtrl->resource == 0) ) - { - /* Free next descriptor */ - pQueueCtrl->resource++; - pTxDesc = (ETH_TX_DESC*)pQueueCtrl->pUsedDescr; - - /* pPktInfo is available only in descriptors which are last descriptors */ - pPktInfo = (MV_PKT_INFO*)pTxDesc->returnInfo; - if (pPktInfo) - pPktInfo->status = pTxDesc->cmdSts; - - pTxDesc->cmdSts = 0x0; - pTxDesc->returnInfo = 0x0; - ETH_DESCR_FLUSH_INV(pPortCtrl, pTxDesc); - - pQueueCtrl->pUsedDescr = TX_NEXT_DESC_PTR(pTxDesc, pQueueCtrl); - - if (pPktInfo) - if (pPktInfo->status & ETH_TX_LAST_DESC_MASK) - return pPktInfo; - } - MV_REG_WRITE( ETH_TX_CUR_DESC_PTR_REG(port, txQueue), - (MV_U32)ethDescVirtToPhy(pQueueCtrl, pQueueCtrl->pCurrentDescr) ); - return NULL; -} - - - -/******************************************************************************* -* mvEthPortForceRx - Get next buffer from RX queue in spite of buffer ownership. -* -* DESCRIPTION: -* This routine used to free buffers attached to the Rx ring and should -* be called only when Giga Ethernet port is Down -* -* INPUT: -* void* pEthPortHndl - Ethernet Port handler. -* int rxQueue - Number of Rx queue. -* -* OUTPUT: -* MV_PKT_INFO *pPktInfo - Pointer to received packet. -* -* RETURN: -* MV_EMPTY - There is no more buffers in this queue. -* MV_OK - Buffer detached from the queue and pBufInfo structure -* filled with relevant information. -* -*******************************************************************************/ -MV_PKT_INFO* mvEthPortForceRx(void* pEthPortHndl, int rxQueue) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pEthPortHndl; - ETH_QUEUE_CTRL* pQueueCtrl; - ETH_RX_DESC* pRxDesc; - MV_PKT_INFO* pPktInfo; - int port = pPortCtrl->portNo; - - pQueueCtrl = &pPortCtrl->rxQueue[rxQueue]; - - if(pQueueCtrl->resource == 0) - { - MV_REG_WRITE( ETH_RX_CUR_DESC_PTR_REG(port, rxQueue), - (MV_U32)ethDescVirtToPhy(pQueueCtrl, pQueueCtrl->pCurrentDescr) ); - - return NULL; - } - /* Free next descriptor */ - pQueueCtrl->resource--; - pRxDesc = (ETH_RX_DESC*)pQueueCtrl->pCurrentDescr; - pPktInfo = (MV_PKT_INFO*)pRxDesc->returnInfo; - - pPktInfo->status = pRxDesc->cmdSts; - pRxDesc->cmdSts = 0x0; - pRxDesc->returnInfo = 0x0; - ETH_DESCR_FLUSH_INV(pPortCtrl, pRxDesc); - - pQueueCtrl->pCurrentDescr = RX_NEXT_DESC_PTR(pRxDesc, pQueueCtrl); - return pPktInfo; -} - - -/******************************************************************************/ -/* Port Configuration functions */ -/******************************************************************************/ -/******************************************************************************* -* mvEthMruGet - Get MRU configuration for Max Rx packet size. -* -* INPUT: -* MV_U32 maxRxPktSize - max packet size. -* -* RETURN: MV_U32 - MRU configuration. -* -*******************************************************************************/ -static MV_U32 mvEthMruGet(MV_U32 maxRxPktSize) -{ - MV_U32 portSerialCtrlReg = 0; - - if(maxRxPktSize > 9192) - portSerialCtrlReg |= ETH_MAX_RX_PACKET_9700BYTE; - else if(maxRxPktSize > 9022) - portSerialCtrlReg |= ETH_MAX_RX_PACKET_9192BYTE; - else if(maxRxPktSize > 1552) - portSerialCtrlReg |= ETH_MAX_RX_PACKET_9022BYTE; - else if(maxRxPktSize > 1522) - portSerialCtrlReg |= ETH_MAX_RX_PACKET_1552BYTE; - else if(maxRxPktSize > 1518) - portSerialCtrlReg |= ETH_MAX_RX_PACKET_1522BYTE; - else - portSerialCtrlReg |= ETH_MAX_RX_PACKET_1518BYTE; - - return portSerialCtrlReg; -} - -/******************************************************************************* -* mvEthRxCoalSet - Sets coalescing interrupt mechanism on RX path -* -* DESCRIPTION: -* This routine sets the RX coalescing interrupt mechanism parameter. -* This parameter is a timeout counter, that counts in 64 tClk -* chunks, that when timeout event occurs a maskable interrupt occurs. -* The parameter is calculated using the tCLK frequency of the -* MV-64xxx chip, and the required number is in micro seconds. -* -* INPUT: -* void* pPortHndl - Ethernet Port handler. -* MV_U32 uSec - Number of micro seconds between -* RX interrupts -* -* RETURN: -* None. -* -* COMMENT: -* 1 sec - TCLK_RATE clocks -* 1 uSec - TCLK_RATE / 1,000,000 clocks -* -* Register Value for N micro seconds - ((N * ( (TCLK_RATE / 1,000,000)) / 64) -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_U32 mvEthRxCoalSet (void* pPortHndl, MV_U32 uSec) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHndl; - MV_U32 coal = ((uSec * (mvBoardTclkGet() / 1000000)) / 64); - MV_U32 portSdmaCfgReg; - - portSdmaCfgReg = MV_REG_READ(ETH_SDMA_CONFIG_REG(pPortCtrl->portNo)); - portSdmaCfgReg &= ~ETH_RX_INTR_COAL_ALL_MASK; - - portSdmaCfgReg |= ETH_RX_INTR_COAL_MASK(coal); - -#if (MV_ETH_VERSION >= 2) - /* Set additional bit if needed ETH_RX_INTR_COAL_MSB_BIT (25) */ - if(ETH_RX_INTR_COAL_MASK(coal) > ETH_RX_INTR_COAL_ALL_MASK) - portSdmaCfgReg |= ETH_RX_INTR_COAL_MSB_MASK; -#endif /* MV_ETH_VERSION >= 2 */ - - MV_REG_WRITE (ETH_SDMA_CONFIG_REG(pPortCtrl->portNo), portSdmaCfgReg); - return coal; -} - -/******************************************************************************* -* mvEthTxCoalSet - Sets coalescing interrupt mechanism on TX path -* -* DESCRIPTION: -* This routine sets the TX coalescing interrupt mechanism parameter. -* This parameter is a timeout counter, that counts in 64 tClk -* chunks, that when timeout event occurs a maskable interrupt -* occurs. -* The parameter is calculated using the tCLK frequency of the -* MV-64xxx chip, and the required number is in micro seconds. -* -* INPUT: -* void* pPortHndl - Ethernet Port handler. -* MV_U32 uSec - Number of micro seconds between -* RX interrupts -* -* RETURN: -* None. -* -* COMMENT: -* 1 sec - TCLK_RATE clocks -* 1 uSec - TCLK_RATE / 1,000,000 clocks -* -* Register Value for N micro seconds - ((N * ( (TCLK_RATE / 1,000,000)) / 64) -* -*******************************************************************************/ -MV_U32 mvEthTxCoalSet(void* pPortHndl, MV_U32 uSec) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHndl; - MV_U32 coal = ((uSec * (mvBoardTclkGet() / 1000000)) / 64); - MV_U32 regVal; - - regVal = MV_REG_READ(ETH_TX_FIFO_URGENT_THRESH_REG(pPortCtrl->portNo)); - regVal &= ~ETH_TX_INTR_COAL_ALL_MASK; - regVal |= ETH_TX_INTR_COAL_MASK(coal); - - /* Set TX Coalescing mechanism */ - MV_REG_WRITE (ETH_TX_FIFO_URGENT_THRESH_REG(pPortCtrl->portNo), regVal); - return coal; -} - -/******************************************************************************* -* mvEthCoalGet - Gets RX and TX coalescing values in micro seconds -* -* DESCRIPTION: -* This routine gets the RX and TX coalescing interrupt values. -* The parameter is calculated using the tCLK frequency of the -* MV-64xxx chip, and the returned numbers are in micro seconds. -* -* INPUTs: -* void* pPortHndl - Ethernet Port handler. -* -* OUTPUTs: -* MV_U32* pRxCoal - Number of micro seconds between RX interrupts -* MV_U32* pTxCoal - Number of micro seconds between TX interrupts -* -* RETURN: -* MV_STATUS MV_OK - success -* Others - failure. -* -* COMMENT: -* 1 sec - TCLK_RATE clocks -* 1 uSec - TCLK_RATE / 1,000,000 clocks -* -* Register Value for N micro seconds - ((N * ( (TCLK_RATE / 1,000,000)) / 64) -* -*******************************************************************************/ -MV_STATUS mvEthCoalGet(void* pPortHndl, MV_U32* pRxCoal, MV_U32* pTxCoal) -{ - MV_U32 regVal, coal, usec; - - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHndl; - - /* get TX Coalescing */ - regVal = MV_REG_READ (ETH_TX_FIFO_URGENT_THRESH_REG(pPortCtrl->portNo)); - coal = ((regVal & ETH_TX_INTR_COAL_ALL_MASK) >> ETH_TX_INTR_COAL_OFFSET); - - usec = (coal * 64) / (mvBoardTclkGet() / 1000000); - if(pTxCoal != NULL) - *pTxCoal = usec; - - /* Get RX Coalescing */ - regVal = MV_REG_READ(ETH_SDMA_CONFIG_REG(pPortCtrl->portNo)); - coal = ((regVal & ETH_RX_INTR_COAL_ALL_MASK) >> ETH_RX_INTR_COAL_OFFSET); - -#if (MV_ETH_VERSION >= 2) - if(regVal & ETH_RX_INTR_COAL_MSB_MASK) - { - /* Add MSB */ - coal |= (ETH_RX_INTR_COAL_ALL_MASK + 1); - } -#endif /* MV_ETH_VERSION >= 2 */ - - usec = (coal * 64) / (mvBoardTclkGet() / 1000000); - if(pRxCoal != NULL) - *pRxCoal = usec; - - return MV_OK; -} - -/******************************************************************************* -* mvEthMaxRxSizeSet - -* -* DESCRIPTION: -* Change maximum receive size of the port. This configuration will take place -* after next call of ethPortSetDefaults() function. -* -* INPUT: -* -* RETURN: -*******************************************************************************/ -MV_STATUS mvEthMaxRxSizeSet(void* pPortHndl, int maxRxSize) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHndl; - MV_U32 portSerialCtrlReg; - - if((maxRxSize < 1518) || (maxRxSize & ~ETH_RX_BUFFER_MASK)) - return MV_BAD_PARAM; - - pPortCtrl->portConfig.maxRxPktSize = maxRxSize; - - portSerialCtrlReg = MV_REG_READ(ETH_PORT_SERIAL_CTRL_REG(pPortCtrl->portNo)); - portSerialCtrlReg &= ~ETH_MAX_RX_PACKET_SIZE_MASK; - portSerialCtrlReg |= mvEthMruGet(pPortCtrl->portConfig.maxRxPktSize); - MV_REG_WRITE(ETH_PORT_SERIAL_CTRL_REG(pPortCtrl->portNo), portSerialCtrlReg); - - return MV_OK; -} - - -/******************************************************************************/ -/* MAC Filtering functions */ -/******************************************************************************/ - -/******************************************************************************* -* mvEthRxFilterModeSet - Configure Fitering mode of Ethernet port -* -* DESCRIPTION: -* This routine used to free buffers attached to the Rx ring and should -* be called only when Giga Ethernet port is Down -* -* INPUT: -* void* pEthPortHndl - Ethernet Port handler. -* MV_BOOL isPromisc - Promiscous mode -* MV_TRUE - accept all Broadcast, Multicast -* and Unicast packets -* MV_FALSE - accept all Broadcast, -* specially added Multicast and -* single Unicast packets -* -* RETURN: MV_STATUS MV_OK - Success, Other - Failure -* -*******************************************************************************/ -MV_STATUS mvEthRxFilterModeSet(void* pEthPortHndl, MV_BOOL isPromisc) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pEthPortHndl; - int queue; - MV_U32 portCfgReg; - - portCfgReg = MV_REG_READ(ETH_PORT_CONFIG_REG(pPortCtrl->portNo)); - /* Set / Clear UPM bit in port configuration register */ - if(isPromisc) - { - /* Accept all multicast packets to RX default queue */ - queue = pPortCtrl->portConfig.rxDefQ; - portCfgReg |= ETH_UNICAST_PROMISCUOUS_MODE_MASK; - memset(pPortCtrl->mcastCount, 1, sizeof(pPortCtrl->mcastCount)); - MV_REG_WRITE(ETH_MAC_ADDR_LOW_REG(pPortCtrl->portNo),0xFFFF); - MV_REG_WRITE(ETH_MAC_ADDR_HIGH_REG(pPortCtrl->portNo),0xFFFFFFFF); - } - else - { - /* Reject all Multicast addresses */ - queue = -1; - portCfgReg &= ~ETH_UNICAST_PROMISCUOUS_MODE_MASK; - /* Clear all mcastCount */ - memset(pPortCtrl->mcastCount, 0, sizeof(pPortCtrl->mcastCount)); - } - MV_REG_WRITE(ETH_PORT_CONFIG_REG(pPortCtrl->portNo), portCfgReg); - - /* Set Special Multicast and Other Multicast tables */ - mvEthSetSpecialMcastTable(pPortCtrl->portNo, queue); - mvEthSetOtherMcastTable(pPortCtrl->portNo, queue); - ethSetUcastTable(pPortCtrl->portNo, queue); - - return MV_OK; -} - -/******************************************************************************* -* mvEthMacAddrSet - This function Set the port Unicast address. -* -* DESCRIPTION: -* This function Set the port Ethernet MAC address. This address -* will be used to send Pause frames if enabled. Packets with this -* address will be accepted and dispatched to default RX queue -* -* INPUT: -* void* pEthPortHndl - Ethernet port handler. -* char* pAddr - Address to be set -* -* RETURN: MV_STATUS -* MV_OK - Success, Other - Faulure -* -*******************************************************************************/ -MV_STATUS mvEthMacAddrSet(void* pPortHndl, unsigned char *pAddr, int queue) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHndl; - unsigned int macH; - unsigned int macL; - - if(queue >= MV_ETH_RX_Q_NUM) - { - mvOsPrintf("ethDrv: RX queue #%d is out of range\n", queue); - return MV_BAD_PARAM; - } - - if(queue != -1) - { - macL = (pAddr[4] << 8) | (pAddr[5]); - macH = (pAddr[0] << 24)| (pAddr[1] << 16) | - (pAddr[2] << 8) | (pAddr[3] << 0); - - MV_REG_WRITE(ETH_MAC_ADDR_LOW_REG(pPortCtrl->portNo), macL); - MV_REG_WRITE(ETH_MAC_ADDR_HIGH_REG(pPortCtrl->portNo), macH); - } - - /* Accept frames of this address */ - ethSetUcastAddr(pPortCtrl->portNo, pAddr[5], queue); - - return MV_OK; -} - -/******************************************************************************* -* mvEthMacAddrGet - This function returns the port Unicast address. -* -* DESCRIPTION: -* This function returns the port Ethernet MAC address. -* -* INPUT: -* int portNo - Ethernet port number. -* char* pAddr - Pointer where address will be written to -* -* RETURN: MV_STATUS -* MV_OK - Success, Other - Faulure -* -*******************************************************************************/ -MV_STATUS mvEthMacAddrGet(int portNo, unsigned char *pAddr) -{ - unsigned int macH; - unsigned int macL; - - if(pAddr == NULL) - { - mvOsPrintf("mvEthMacAddrGet: NULL pointer.\n"); - return MV_BAD_PARAM; - } - - macH = MV_REG_READ(ETH_MAC_ADDR_HIGH_REG(portNo)); - macL = MV_REG_READ(ETH_MAC_ADDR_LOW_REG(portNo)); - pAddr[0] = (macH >> 24) & 0xff; - pAddr[1] = (macH >> 16) & 0xff; - pAddr[2] = (macH >> 8) & 0xff; - pAddr[3] = macH & 0xff; - pAddr[4] = (macL >> 8) & 0xff; - pAddr[5] = macL & 0xff; - - return MV_OK; -} - -/******************************************************************************* -* mvEthMcastCrc8Get - Calculate CRC8 of MAC address. -* -* DESCRIPTION: -* -* INPUT: -* MV_U8* pAddr - Address to calculate CRC-8 -* -* RETURN: MV_U8 - CRC-8 of this MAC address -* -*******************************************************************************/ -MV_U8 mvEthMcastCrc8Get(MV_U8* pAddr) -{ - unsigned int macH; - unsigned int macL; - int macArray[48]; - int crc[8]; - int i; - unsigned char crcResult = 0; - - /* Calculate CRC-8 out of the given address */ - macH = (pAddr[0] << 8) | (pAddr[1]); - macL = (pAddr[2] << 24)| (pAddr[3] << 16) | - (pAddr[4] << 8) | (pAddr[5] << 0); - - for(i=0; i<32; i++) - macArray[i] = (macL >> i) & 0x1; - - for(i=32; i<48; i++) - macArray[i] = (macH >> (i - 32)) & 0x1; - - crc[0] = macArray[45] ^ macArray[43] ^ macArray[40] ^ macArray[39] ^ - macArray[35] ^ macArray[34] ^ macArray[31] ^ macArray[30] ^ - macArray[28] ^ macArray[23] ^ macArray[21] ^ macArray[19] ^ - macArray[18] ^ macArray[16] ^ macArray[14] ^ macArray[12] ^ - macArray[8] ^ macArray[7] ^ macArray[6] ^ macArray[0]; - - crc[1] = macArray[46] ^ macArray[45] ^ macArray[44] ^ macArray[43] ^ - macArray[41] ^ macArray[39] ^ macArray[36] ^ macArray[34] ^ - macArray[32] ^ macArray[30] ^ macArray[29] ^ macArray[28] ^ - macArray[24] ^ macArray[23] ^ macArray[22] ^ macArray[21] ^ - macArray[20] ^ macArray[18] ^ macArray[17] ^ macArray[16] ^ - macArray[15] ^ macArray[14] ^ macArray[13] ^ macArray[12] ^ - macArray[9] ^ macArray[6] ^ macArray[1] ^ macArray[0]; - - crc[2] = macArray[47] ^ macArray[46] ^ macArray[44] ^ macArray[43] ^ - macArray[42] ^ macArray[39] ^ macArray[37] ^ macArray[34] ^ - macArray[33] ^ macArray[29] ^ macArray[28] ^ macArray[25] ^ - macArray[24] ^ macArray[22] ^ macArray[17] ^ macArray[15] ^ - macArray[13] ^ macArray[12] ^ macArray[10] ^ macArray[8] ^ - macArray[6] ^ macArray[2] ^ macArray[1] ^ macArray[0]; - - crc[3] = macArray[47] ^ macArray[45] ^ macArray[44] ^ macArray[43] ^ - macArray[40] ^ macArray[38] ^ macArray[35] ^ macArray[34] ^ - macArray[30] ^ macArray[29] ^ macArray[26] ^ macArray[25] ^ - macArray[23] ^ macArray[18] ^ macArray[16] ^ macArray[14] ^ - macArray[13] ^ macArray[11] ^ macArray[9] ^ macArray[7] ^ - macArray[3] ^ macArray[2] ^ macArray[1]; - - crc[4] = macArray[46] ^ macArray[45] ^ macArray[44] ^ macArray[41] ^ - macArray[39] ^ macArray[36] ^ macArray[35] ^ macArray[31] ^ - macArray[30] ^ macArray[27] ^ macArray[26] ^ macArray[24] ^ - macArray[19] ^ macArray[17] ^ macArray[15] ^ macArray[14] ^ - macArray[12] ^ macArray[10] ^ macArray[8] ^ macArray[4] ^ - macArray[3] ^ macArray[2]; - - crc[5] = macArray[47] ^ macArray[46] ^ macArray[45] ^ macArray[42] ^ - macArray[40] ^ macArray[37] ^ macArray[36] ^ macArray[32] ^ - macArray[31] ^ macArray[28] ^ macArray[27] ^ macArray[25] ^ - macArray[20] ^ macArray[18] ^ macArray[16] ^ macArray[15] ^ - macArray[13] ^ macArray[11] ^ macArray[9] ^ macArray[5] ^ - macArray[4] ^ macArray[3]; - - crc[6] = macArray[47] ^ macArray[46] ^ macArray[43] ^ macArray[41] ^ - macArray[38] ^ macArray[37] ^ macArray[33] ^ macArray[32] ^ - macArray[29] ^ macArray[28] ^ macArray[26] ^ macArray[21] ^ - macArray[19] ^ macArray[17] ^ macArray[16] ^ macArray[14] ^ - macArray[12] ^ macArray[10] ^ macArray[6] ^ macArray[5] ^ - macArray[4]; - - crc[7] = macArray[47] ^ macArray[44] ^ macArray[42] ^ macArray[39] ^ - macArray[38] ^ macArray[34] ^ macArray[33] ^ macArray[30] ^ - macArray[29] ^ macArray[27] ^ macArray[22] ^ macArray[20] ^ - macArray[18] ^ macArray[17] ^ macArray[15] ^ macArray[13] ^ - macArray[11] ^ macArray[7] ^ macArray[6] ^ macArray[5]; - - for(i=0; i<8; i++) - crcResult = crcResult | (crc[i] << i); - - return crcResult; -} -/******************************************************************************* -* mvEthMcastAddrSet - Multicast address settings. -* -* DESCRIPTION: -* This API controls the MV device MAC multicast support. -* The MV device supports multicast using two tables: -* 1) Special Multicast Table for MAC addresses of the form -* 0x01-00-5E-00-00-XX (where XX is between 0x00 and 0xFF). -* The MAC DA[7:0] bits are used as a pointer to the Special Multicast -* Table entries in the DA-Filter table. -* In this case, the function calls ethPortSmcAddr() routine to set the -* Special Multicast Table. -* 2) Other Multicast Table for multicast of another type. A CRC-8bit -* is used as an index to the Other Multicast Table entries in the -* DA-Filter table. -* In this case, the function calculates the CRC-8bit value and calls -* ethPortOmcAddr() routine to set the Other Multicast Table. -* -* INPUT: -* void* pEthPortHndl - Ethernet port handler. -* MV_U8* pAddr - Address to be set -* int queue - RX queue to capture all packets with this -* Multicast MAC address. -* -1 means delete this Multicast address. -* -* RETURN: MV_STATUS -* MV_TRUE - Success, Other - Failure -* -*******************************************************************************/ -MV_STATUS mvEthMcastAddrSet(void* pPortHndl, MV_U8 *pAddr, int queue) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHndl; - unsigned char crcResult = 0; - - if(queue >= MV_ETH_RX_Q_NUM) - { - mvOsPrintf("ethPort %d: RX queue #%d is out of range\n", - pPortCtrl->portNo, queue); - return MV_BAD_PARAM; - } - - if((pAddr[0] == 0x01) && - (pAddr[1] == 0x00) && - (pAddr[2] == 0x5E) && - (pAddr[3] == 0x00) && - (pAddr[4] == 0x00)) - { - ethSetSpecialMcastAddr(pPortCtrl->portNo, pAddr[5], queue); - } - else - { - crcResult = mvEthMcastCrc8Get(pAddr); - - /* Check Add counter for this CRC value */ - if(queue == -1) - { - if(pPortCtrl->mcastCount[crcResult] == 0) - { - mvOsPrintf("ethPort #%d: No valid Mcast for crc8=0x%02x\n", - pPortCtrl->portNo, (unsigned)crcResult); - return MV_NO_SUCH; - } - - pPortCtrl->mcastCount[crcResult]--; - if(pPortCtrl->mcastCount[crcResult] != 0) - { - mvOsPrintf("ethPort #%d: After delete there are %d valid Mcast for crc8=0x%02x\n", - pPortCtrl->portNo, pPortCtrl->mcastCount[crcResult], - (unsigned)crcResult); - return MV_NO_CHANGE; - } - } - else - { - pPortCtrl->mcastCount[crcResult]++; - if(pPortCtrl->mcastCount[crcResult] > 1) - { - mvOsPrintf("ethPort #%d: Valid Mcast for crc8=0x%02x already exists\n", - pPortCtrl->portNo, (unsigned)crcResult); - return MV_NO_CHANGE; - } - } - ethSetOtherMcastAddr(pPortCtrl->portNo, crcResult, queue); - } - return MV_OK; -} - -/******************************************************************************* -* ethSetUcastTable - Unicast address settings. -* -* DESCRIPTION: -* Set all entries in the Unicast MAC Table queue==-1 means reject all -* INPUT: -* -* RETURN: -* -*******************************************************************************/ -static void ethSetUcastTable(int portNo, int queue) -{ - int offset; - MV_U32 regValue; - - if(queue == -1) - { - regValue = 0; - } - else - { - regValue = (((0x01 | (queue<<1)) << 0) | - ((0x01 | (queue<<1)) << 8) | - ((0x01 | (queue<<1)) << 16) | - ((0x01 | (queue<<1)) << 24)); - } - - for (offset=0; offset<=0xC; offset+=4) - MV_REG_WRITE((ETH_DA_FILTER_UCAST_BASE(portNo) + offset), regValue); -} - -/******************************************************************************* -* mvEthSetSpecialMcastTable - Special Multicast address settings. -* -* DESCRIPTION: -* Set all entries to the Special Multicast MAC Table. queue==-1 means reject all -* INPUT: -* -* RETURN: -* -*******************************************************************************/ -MV_VOID mvEthSetSpecialMcastTable(int portNo, int queue) -{ - int offset; - MV_U32 regValue; - - if(queue == -1) - { - regValue = 0; - } - else - { - regValue = (((0x01 | (queue<<1)) << 0) | - ((0x01 | (queue<<1)) << 8) | - ((0x01 | (queue<<1)) << 16) | - ((0x01 | (queue<<1)) << 24)); - } - - for (offset=0; offset<=0xFC; offset+=4) - { - MV_REG_WRITE((ETH_DA_FILTER_SPEC_MCAST_BASE(portNo) + - offset), regValue); - } -} - -/******************************************************************************* -* mvEthSetOtherMcastTable - Other Multicast address settings. -* -* DESCRIPTION: -* Set all entries to the Other Multicast MAC Table. queue==-1 means reject all -* INPUT: -* -* RETURN: -* -*******************************************************************************/ -MV_VOID mvEthSetOtherMcastTable(int portNo, int queue) -{ - int offset; - MV_U32 regValue; - - if(queue == -1) - { - regValue = 0; - } - else - { - regValue = (((0x01 | (queue<<1)) << 0) | - ((0x01 | (queue<<1)) << 8) | - ((0x01 | (queue<<1)) << 16) | - ((0x01 | (queue<<1)) << 24)); - } - - for (offset=0; offset<=0xFC; offset+=4) - { - MV_REG_WRITE((ETH_DA_FILTER_OTH_MCAST_BASE(portNo) + - offset), regValue); - } -} - -/******************************************************************************* -* ethSetUcastAddr - This function Set the port unicast address table -* -* DESCRIPTION: -* This function locates the proper entry in the Unicast table for the -* specified MAC nibble and sets its properties according to function -* parameters. -* -* INPUT: -* int ethPortNum - Port number. -* MV_U8 lastNibble - Unicast MAC Address last nibble. -* int queue - Rx queue number for this MAC address. -* value "-1" means remove address -* -* OUTPUT: -* This function add/removes MAC addresses from the port unicast address -* table. -* -* RETURN: -* MV_TRUE is output succeeded. -* MV_FALSE if option parameter is invalid. -* -*******************************************************************************/ -static MV_BOOL ethSetUcastAddr(int portNo, MV_U8 lastNibble, int queue) -{ - unsigned int unicastReg; - unsigned int tblOffset; - unsigned int regOffset; - - /* Locate the Unicast table entry */ - lastNibble = (0xf & lastNibble); - tblOffset = (lastNibble / 4) * 4; /* Register offset from unicast table base*/ - regOffset = lastNibble % 4; /* Entry offset within the above register */ - - - unicastReg = MV_REG_READ( (ETH_DA_FILTER_UCAST_BASE(portNo) + - tblOffset)); - - - if(queue == -1) - { - /* Clear accepts frame bit at specified unicast DA table entry */ - unicastReg &= ~(0xFF << (8*regOffset)); - } - else - { - unicastReg &= ~(0xFF << (8*regOffset)); - unicastReg |= ((0x01 | (queue<<1)) << (8*regOffset)); - } - MV_REG_WRITE( (ETH_DA_FILTER_UCAST_BASE(portNo) + tblOffset), - unicastReg); - - return MV_TRUE; -} - -/******************************************************************************* -* ethSetSpecialMcastAddr - Special Multicast address settings. -* -* DESCRIPTION: -* This routine controls the MV device special MAC multicast support. -* The Special Multicast Table for MAC addresses supports MAC of the form -* 0x01-00-5E-00-00-XX (where XX is between 0x00 and 0xFF). -* The MAC DA[7:0] bits are used as a pointer to the Special Multicast -* Table entries in the DA-Filter table. -* This function set the Special Multicast Table appropriate entry -* according to the argument given. -* -* INPUT: -* int ethPortNum Port number. -* unsigned char mcByte Multicast addr last byte (MAC DA[7:0] bits). -* int queue Rx queue number for this MAC address. -* int option 0 = Add, 1 = remove address. -* -* OUTPUT: -* See description. -* -* RETURN: -* MV_TRUE is output succeeded. -* MV_FALSE if option parameter is invalid. -* -*******************************************************************************/ -static MV_BOOL ethSetSpecialMcastAddr(int ethPortNum, MV_U8 lastByte, int queue) -{ - unsigned int smcTableReg; - unsigned int tblOffset; - unsigned int regOffset; - - /* Locate the SMC table entry */ - tblOffset = (lastByte / 4); /* Register offset from SMC table base */ - regOffset = lastByte % 4; /* Entry offset within the above register */ - - smcTableReg = MV_REG_READ((ETH_DA_FILTER_SPEC_MCAST_BASE(ethPortNum) + tblOffset*4)); - - if(queue == -1) - { - /* Clear accepts frame bit at specified Special DA table entry */ - smcTableReg &= ~(0xFF << (8 * regOffset)); - } - else - { - smcTableReg &= ~(0xFF << (8 * regOffset)); - smcTableReg |= ((0x01 | (queue<<1)) << (8 * regOffset)); - } - MV_REG_WRITE((ETH_DA_FILTER_SPEC_MCAST_BASE(ethPortNum) + - tblOffset*4), smcTableReg); - - return MV_TRUE; -} - -/******************************************************************************* -* ethSetOtherMcastAddr - Multicast address settings. -* -* DESCRIPTION: -* This routine controls the MV device Other MAC multicast support. -* The Other Multicast Table is used for multicast of another type. -* A CRC-8bit is used as an index to the Other Multicast Table entries -* in the DA-Filter table. -* The function gets the CRC-8bit value from the calling routine and -* set the Other Multicast Table appropriate entry according to the -* CRC-8 argument given. -* -* INPUT: -* int ethPortNum Port number. -* MV_U8 crc8 A CRC-8bit (Polynomial: x^8+x^2+x^1+1). -* int queue Rx queue number for this MAC address. -* -* OUTPUT: -* See description. -* -* RETURN: -* MV_TRUE is output succeeded. -* MV_FALSE if option parameter is invalid. -* -*******************************************************************************/ -static MV_BOOL ethSetOtherMcastAddr(int ethPortNum, MV_U8 crc8, int queue) -{ - unsigned int omcTableReg; - unsigned int tblOffset; - unsigned int regOffset; - - /* Locate the OMC table entry */ - tblOffset = (crc8 / 4) * 4; /* Register offset from OMC table base */ - regOffset = crc8 % 4; /* Entry offset within the above register */ - - omcTableReg = MV_REG_READ( - (ETH_DA_FILTER_OTH_MCAST_BASE(ethPortNum) + tblOffset)); - - if(queue == -1) - { - /* Clear accepts frame bit at specified Other DA table entry */ - omcTableReg &= ~(0xFF << (8 * regOffset)); - } - else - { - omcTableReg &= ~(0xFF << (8 * regOffset)); - omcTableReg |= ((0x01 | (queue<<1)) << (8 * regOffset)); - } - - MV_REG_WRITE((ETH_DA_FILTER_OTH_MCAST_BASE(ethPortNum) + tblOffset), - omcTableReg); - - return MV_TRUE; -} - - -/******************************************************************************/ -/* MIB Counters functions */ -/******************************************************************************/ - - -/******************************************************************************* -* mvEthMibCounterRead - Read a MIB counter -* -* DESCRIPTION: -* This function reads a MIB counter of a specific ethernet port. -* NOTE - Read from ETH_MIB_GOOD_OCTETS_RECEIVED_LOW or -* ETH_MIB_GOOD_OCTETS_SENT_LOW counters will return 64 bits value, -* so pHigh32 pointer should not be NULL in this case. -* -* INPUT: -* int ethPortNum - Ethernet Port number. -* unsigned int mibOffset - MIB counter offset. -* -* OUTPUT: -* MV_U32* pHigh32 - pointer to place where 32 most significant bits -* of the counter will be stored. -* -* RETURN: -* 32 low sgnificant bits of MIB counter value. -* -*******************************************************************************/ -MV_U32 mvEthMibCounterRead(void* pPortHandle, unsigned int mibOffset, - MV_U32* pHigh32) -{ - int portNo; - MV_U32 valLow32, valHigh32; - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHandle; - - portNo = pPortCtrl->portNo; - - valLow32 = MV_REG_READ(ETH_MIB_COUNTERS_BASE(portNo) + mibOffset); - - /* Implement FEr ETH. Erroneous Value when Reading the Upper 32-bits */ - /* of a 64-bit MIB Counter. */ - if( (mibOffset == ETH_MIB_GOOD_OCTETS_RECEIVED_LOW) || - (mibOffset == ETH_MIB_GOOD_OCTETS_SENT_LOW) ) - { - valHigh32 = MV_REG_READ(ETH_MIB_COUNTERS_BASE(portNo) + mibOffset + 4); - if(pHigh32 != NULL) - *pHigh32 = valHigh32; - } - return valLow32; -} - -/******************************************************************************* -* mvEthMibCountersClear - Clear all MIB counters -* -* DESCRIPTION: -* This function clears all MIB counters -* -* INPUT: -* int ethPortNum - Ethernet Port number. -* -* -* RETURN: void -* -*******************************************************************************/ -void mvEthMibCountersClear(void* pPortHandle) -{ - int i, portNo; - unsigned int dummy; - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHandle; - - portNo = pPortCtrl->portNo; - - /* Perform dummy reads from MIB counters */ - for(i=ETH_MIB_GOOD_OCTETS_RECEIVED_LOW; i<ETH_MIB_LATE_COLLISION; i+=4) - dummy = MV_REG_READ((ETH_MIB_COUNTERS_BASE(portNo) + i)); -} - - -/******************************************************************************/ -/* RX Dispatching configuration routines */ -/******************************************************************************/ - -int mvEthTosToRxqGet(void* pPortHandle, int tos) -{ - MV_U32 regValue; - int regIdx, regOffs, rxq; - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHandle; - - if(tos > 0xFF) - { - mvOsPrintf("eth_%d: tos=0x%x is out of range\n", pPortCtrl->portNo, tos); - return -1; - } - regIdx = mvOsDivide(tos>>2, 10); - regOffs = mvOsReminder(tos>>2, 10); - - regValue = MV_REG_READ(ETH_DIFF_SERV_PRIO_REG(pPortCtrl->portNo, regIdx) ); - rxq = (regValue >> (regOffs*3)); - rxq &= 0x7; - - return rxq; -} - -/******************************************************************************* -* mvEthTosToRxqSet - Map packets with special TOS value to special RX queue -* -* DESCRIPTION: -* -* INPUT: -* void* pPortHandle - Pointer to port specific handler; -* int tos - TOS value in the IP header of the packet -* int rxq - RX Queue for packets with the configured TOS value -* Negative value (-1) means no special processing for these packets, -* so they will be processed as regular packets. -* -* RETURN: MV_STATUS -*******************************************************************************/ -MV_STATUS mvEthTosToRxqSet(void* pPortHandle, int tos, int rxq) -{ - MV_U32 regValue; - int regIdx, regOffs; - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHandle; - - if( (rxq < 0) || (rxq >= MV_ETH_RX_Q_NUM) ) - { - mvOsPrintf("eth_%d: RX queue #%d is out of range\n", pPortCtrl->portNo, rxq); - return MV_BAD_PARAM; - } - if(tos > 0xFF) - { - mvOsPrintf("eth_%d: tos=0x%x is out of range\n", pPortCtrl->portNo, tos); - return MV_BAD_PARAM; - } - regIdx = mvOsDivide(tos>>2, 10); - regOffs = mvOsReminder(tos>>2, 10); - - regValue = MV_REG_READ(ETH_DIFF_SERV_PRIO_REG(pPortCtrl->portNo, regIdx) ); - regValue &= ~(0x7 << (regOffs*3)); - regValue |= (rxq << (regOffs*3)); - - MV_REG_WRITE(ETH_DIFF_SERV_PRIO_REG(pPortCtrl->portNo, regIdx), regValue); - return MV_OK; -} - -/******************************************************************************* -* mvEthVlanPrioRxQueue - Configure RX queue to capture VLAN tagged packets with -* special priority bits [0-2] -* -* DESCRIPTION: -* -* INPUT: -* void* pPortHandle - Pointer to port specific handler; -* int bpduQueue - Special queue to capture VLAN tagged packets with special -* priority. -* Negative value (-1) means no special processing for these packets, -* so they will be processed as regular packets. -* -* RETURN: MV_STATUS -* MV_OK - Success -* MV_FAIL - Failed. -* -*******************************************************************************/ -MV_STATUS mvEthVlanPrioRxQueue(void* pPortHandle, int vlanPrio, int vlanPrioQueue) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHandle; - MV_U32 vlanPrioReg; - - if(vlanPrioQueue >= MV_ETH_RX_Q_NUM) - { - mvOsPrintf("ethDrv: RX queue #%d is out of range\n", vlanPrioQueue); - return MV_BAD_PARAM; - } - if(vlanPrio >= 8) - { - mvOsPrintf("ethDrv: vlanPrio=%d is out of range\n", vlanPrio); - return MV_BAD_PARAM; - } - - vlanPrioReg = MV_REG_READ(ETH_VLAN_TAG_TO_PRIO_REG(pPortCtrl->portNo)); - vlanPrioReg &= ~(0x7 << (vlanPrio*3)); - vlanPrioReg |= (vlanPrioQueue << (vlanPrio*3)); - MV_REG_WRITE(ETH_VLAN_TAG_TO_PRIO_REG(pPortCtrl->portNo), vlanPrioReg); - - return MV_OK; -} - - -/******************************************************************************* -* mvEthBpduRxQueue - Configure RX queue to capture BPDU packets. -* -* DESCRIPTION: -* This function defines processing of BPDU packets. -* BPDU packets can be accepted and captured to one of RX queues -* or can be processing as regular Multicast packets. -* -* INPUT: -* void* pPortHandle - Pointer to port specific handler; -* int bpduQueue - Special queue to capture BPDU packets (DA is equal to -* 01-80-C2-00-00-00 through 01-80-C2-00-00-FF, -* except for the Flow-Control Pause packets). -* Negative value (-1) means no special processing for BPDU, -* packets so they will be processed as regular Multicast packets. -* -* RETURN: MV_STATUS -* MV_OK - Success -* MV_FAIL - Failed. -* -*******************************************************************************/ -MV_STATUS mvEthBpduRxQueue(void* pPortHandle, int bpduQueue) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHandle; - MV_U32 portCfgReg; - MV_U32 portCfgExtReg; - - if(bpduQueue >= MV_ETH_RX_Q_NUM) - { - mvOsPrintf("ethDrv: RX queue #%d is out of range\n", bpduQueue); - return MV_BAD_PARAM; - } - - portCfgExtReg = MV_REG_READ(ETH_PORT_CONFIG_EXTEND_REG(pPortCtrl->portNo)); - - portCfgReg = MV_REG_READ(ETH_PORT_CONFIG_REG(pPortCtrl->portNo)); - if(bpduQueue >= 0) - { - pPortCtrl->portConfig.rxBpduQ = bpduQueue; - - portCfgReg &= ~ETH_DEF_RX_BPDU_QUEUE_ALL_MASK; - portCfgReg |= ETH_DEF_RX_BPDU_QUEUE_MASK(pPortCtrl->portConfig.rxBpduQ); - - MV_REG_WRITE(ETH_PORT_CONFIG_REG(pPortCtrl->portNo), portCfgReg); - - portCfgExtReg |= ETH_CAPTURE_SPAN_BPDU_ENABLE_MASK; - } - else - { - pPortCtrl->portConfig.rxBpduQ = -1; - /* no special processing for BPDU packets */ - portCfgExtReg &= (~ETH_CAPTURE_SPAN_BPDU_ENABLE_MASK); - } - - MV_REG_WRITE(ETH_PORT_CONFIG_EXTEND_REG(pPortCtrl->portNo), portCfgExtReg); - - return MV_OK; -} - - -/******************************************************************************* -* mvEthArpRxQueue - Configure RX queue to capture ARP packets. -* -* DESCRIPTION: -* This function defines processing of ARP (type=0x0806) packets. -* ARP packets can be accepted and captured to one of RX queues -* or can be processed as other Broadcast packets. -* -* INPUT: -* void* pPortHandle - Pointer to port specific handler; -* int arpQueue - Special queue to capture ARP packets (type=0x806). -* Negative value (-1) means discard ARP packets -* -* RETURN: MV_STATUS -* MV_OK - Success -* MV_FAIL - Failed. -* -*******************************************************************************/ -MV_STATUS mvEthArpRxQueue(void* pPortHandle, int arpQueue) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHandle; - MV_U32 portCfgReg; - - if(arpQueue >= MV_ETH_RX_Q_NUM) - { - mvOsPrintf("ethDrv: RX queue #%d is out of range\n", arpQueue); - return MV_BAD_PARAM; - } - - portCfgReg = MV_REG_READ(ETH_PORT_CONFIG_REG(pPortCtrl->portNo)); - - if(arpQueue >= 0) - { - pPortCtrl->portConfig.rxArpQ = arpQueue; - portCfgReg &= ~ETH_DEF_RX_ARP_QUEUE_ALL_MASK; - portCfgReg |= ETH_DEF_RX_ARP_QUEUE_MASK(pPortCtrl->portConfig.rxArpQ); - - portCfgReg &= (~ETH_REJECT_ARP_BCAST_MASK); - } - else - { - pPortCtrl->portConfig.rxArpQ = -1; - portCfgReg |= ETH_REJECT_ARP_BCAST_MASK; - } - - MV_REG_WRITE(ETH_PORT_CONFIG_REG(pPortCtrl->portNo), portCfgReg); - - return MV_OK; -} - - -/******************************************************************************* -* mvEthTcpRxQueue - Configure RX queue to capture TCP packets. -* -* DESCRIPTION: -* This function defines processing of TCP packets. -* TCP packets can be accepted and captured to one of RX queues -* or can be processed as regular Unicast packets. -* -* INPUT: -* void* pPortHandle - Pointer to port specific handler; -* int tcpQueue - Special queue to capture TCP packets. Value "-1" -* means no special processing for TCP packets, -* so they will be processed as regular -* -* RETURN: MV_STATUS -* MV_OK - Success -* MV_FAIL - Failed. -* -*******************************************************************************/ -MV_STATUS mvEthTcpRxQueue(void* pPortHandle, int tcpQueue) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHandle; - MV_U32 portCfgReg; - - if(tcpQueue >= MV_ETH_RX_Q_NUM) - { - mvOsPrintf("ethDrv: RX queue #%d is out of range\n", tcpQueue); - return MV_BAD_PARAM; - } - portCfgReg = MV_REG_READ(ETH_PORT_CONFIG_REG(pPortCtrl->portNo)); - - if(tcpQueue >= 0) - { - pPortCtrl->portConfig.rxTcpQ = tcpQueue; - portCfgReg &= ~ETH_DEF_RX_TCP_QUEUE_ALL_MASK; - portCfgReg |= ETH_DEF_RX_TCP_QUEUE_MASK(pPortCtrl->portConfig.rxTcpQ); - - portCfgReg |= ETH_CAPTURE_TCP_FRAMES_ENABLE_MASK; - } - else - { - pPortCtrl->portConfig.rxTcpQ = -1; - portCfgReg &= (~ETH_CAPTURE_TCP_FRAMES_ENABLE_MASK); - } - - MV_REG_WRITE(ETH_PORT_CONFIG_REG(pPortCtrl->portNo), portCfgReg); - - return MV_OK; -} - - -/******************************************************************************* -* mvEthUdpRxQueue - Configure RX queue to capture UDP packets. -* -* DESCRIPTION: -* This function defines processing of UDP packets. -* TCP packets can be accepted and captured to one of RX queues -* or can be processed as regular Unicast packets. -* -* INPUT: -* void* pPortHandle - Pointer to port specific handler; -* int udpQueue - Special queue to capture UDP packets. Value "-1" -* means no special processing for UDP packets, -* so they will be processed as regular -* -* RETURN: MV_STATUS -* MV_OK - Success -* MV_FAIL - Failed. -* -*******************************************************************************/ -MV_STATUS mvEthUdpRxQueue(void* pPortHandle, int udpQueue) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHandle; - MV_U32 portCfgReg; - - if(udpQueue >= MV_ETH_RX_Q_NUM) - { - mvOsPrintf("ethDrv: RX queue #%d is out of range\n", udpQueue); - return MV_BAD_PARAM; - } - - portCfgReg = MV_REG_READ(ETH_PORT_CONFIG_REG(pPortCtrl->portNo)); - - if(udpQueue >= 0) - { - pPortCtrl->portConfig.rxUdpQ = udpQueue; - portCfgReg &= ~ETH_DEF_RX_UDP_QUEUE_ALL_MASK; - portCfgReg |= ETH_DEF_RX_UDP_QUEUE_MASK(pPortCtrl->portConfig.rxUdpQ); - - portCfgReg |= ETH_CAPTURE_UDP_FRAMES_ENABLE_MASK; - } - else - { - pPortCtrl->portConfig.rxUdpQ = -1; - portCfgReg &= ~ETH_CAPTURE_UDP_FRAMES_ENABLE_MASK; - } - - MV_REG_WRITE(ETH_PORT_CONFIG_REG(pPortCtrl->portNo), portCfgReg); - - return MV_OK; -} - - -/******************************************************************************/ -/* Speed, Duplex, FlowControl routines */ -/******************************************************************************/ - -/******************************************************************************* -* mvEthSpeedDuplexSet - Set Speed and Duplex of the port. -* -* DESCRIPTION: -* This function configure the port to work with desirable Duplex and Speed. -* Changing of these parameters are allowed only when port is disabled. -* This function disable the port if was enabled, change duplex and speed -* and, enable the port back if needed. -* -* INPUT: -* void* pPortHandle - Pointer to port specific handler; -* ETH_PORT_SPEED speed - Speed of the port. -* ETH_PORT_SPEED duplex - Duplex of the port. -* -* RETURN: MV_STATUS -* MV_OK - Success -* MV_OUT_OF_RANGE - Failed. Port is out of valid range -* MV_NOT_FOUND - Failed. Port is not initialized. -* MV_BAD_PARAM - Input parameters (speed/duplex) in conflict. -* MV_BAD_VALUE - Value of one of input parameters (speed, duplex) -* is not valid -* -*******************************************************************************/ -MV_STATUS mvEthSpeedDuplexSet(void* pPortHandle, MV_ETH_PORT_SPEED speed, - MV_ETH_PORT_DUPLEX duplex) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHandle; - int port = pPortCtrl->portNo; - MV_U32 portSerialCtrlReg; - - if( (port < 0) || (port >= (int)mvCtrlEthMaxPortGet()) ) - return MV_OUT_OF_RANGE; - - pPortCtrl = ethPortCtrl[port]; - if(pPortCtrl == NULL) - return MV_NOT_FOUND; - - /* Check validity */ - if( (speed == MV_ETH_SPEED_1000) && (duplex == MV_ETH_DUPLEX_HALF) ) - return MV_BAD_PARAM; - - portSerialCtrlReg = MV_REG_READ(ETH_PORT_SERIAL_CTRL_REG(port)); - /* Set Speed */ - switch(speed) - { - case MV_ETH_SPEED_AN: - portSerialCtrlReg &= ~ETH_DISABLE_SPEED_AUTO_NEG_MASK; - break; - - case MV_ETH_SPEED_10: - portSerialCtrlReg |= ETH_DISABLE_SPEED_AUTO_NEG_MASK; - portSerialCtrlReg &= ~ETH_SET_GMII_SPEED_1000_MASK; - portSerialCtrlReg &= ~ETH_SET_MII_SPEED_100_MASK; - break; - - case MV_ETH_SPEED_100: - portSerialCtrlReg |= ETH_DISABLE_SPEED_AUTO_NEG_MASK; - portSerialCtrlReg &= ~ETH_SET_GMII_SPEED_1000_MASK; - portSerialCtrlReg |= ETH_SET_MII_SPEED_100_MASK; - break; - - case MV_ETH_SPEED_1000: - portSerialCtrlReg |= ETH_DISABLE_SPEED_AUTO_NEG_MASK; - portSerialCtrlReg |= ETH_SET_GMII_SPEED_1000_MASK; - break; - - default: - mvOsPrintf("ethDrv: Unexpected Speed value %d\n", speed); - return MV_BAD_VALUE; - } - /* Set duplex */ - switch(duplex) - { - case MV_ETH_DUPLEX_AN: - portSerialCtrlReg &= ~ETH_DISABLE_DUPLEX_AUTO_NEG_MASK; - break; - - case MV_ETH_DUPLEX_HALF: - portSerialCtrlReg |= ETH_DISABLE_DUPLEX_AUTO_NEG_MASK; - portSerialCtrlReg &= ~ETH_SET_FULL_DUPLEX_MASK; - break; - - case MV_ETH_DUPLEX_FULL: - portSerialCtrlReg |= ETH_DISABLE_DUPLEX_AUTO_NEG_MASK; - portSerialCtrlReg |= ETH_SET_FULL_DUPLEX_MASK; - break; - - default: - mvOsPrintf("ethDrv: Unexpected Duplex value %d\n", duplex); - return MV_BAD_VALUE; - } - MV_REG_WRITE(ETH_PORT_SERIAL_CTRL_REG(port), portSerialCtrlReg); - - return MV_OK; -} - -/******************************************************************************* -* mvEthFlowCtrlSet - Set Flow Control of the port. -* -* DESCRIPTION: -* This function configure the port to work with desirable Duplex and -* Speed. Changing of these parameters are allowed only when port is -* disabled. This function disable the port if was enabled, change -* duplex and speed and, enable the port back if needed. -* -* INPUT: -* void* pPortHandle - Pointer to port specific handler; -* MV_ETH_PORT_FC flowControl - Flow control of the port. -* -* RETURN: MV_STATUS -* MV_OK - Success -* MV_OUT_OF_RANGE - Failed. Port is out of valid range -* MV_NOT_FOUND - Failed. Port is not initialized. -* MV_BAD_VALUE - Value flowControl parameters is not valid -* -*******************************************************************************/ -MV_STATUS mvEthFlowCtrlSet(void* pPortHandle, MV_ETH_PORT_FC flowControl) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHandle; - int port = pPortCtrl->portNo; - MV_U32 portSerialCtrlReg; - - if( (port < 0) || (port >= (int)mvCtrlEthMaxPortGet() ) ) - return MV_OUT_OF_RANGE; - - pPortCtrl = ethPortCtrl[port]; - if(pPortCtrl == NULL) - return MV_NOT_FOUND; - - portSerialCtrlReg = MV_REG_READ(ETH_PORT_SERIAL_CTRL_REG(port)); - switch(flowControl) - { - case MV_ETH_FC_AN_ADV_DIS: - portSerialCtrlReg &= ~ETH_DISABLE_FC_AUTO_NEG_MASK; - portSerialCtrlReg &= ~ETH_ADVERTISE_SYM_FC_MASK; - break; - - case MV_ETH_FC_AN_ADV_SYM: - portSerialCtrlReg &= ~ETH_DISABLE_FC_AUTO_NEG_MASK; - portSerialCtrlReg |= ETH_ADVERTISE_SYM_FC_MASK; - break; - - case MV_ETH_FC_DISABLE: - portSerialCtrlReg |= ETH_DISABLE_FC_AUTO_NEG_MASK; - portSerialCtrlReg &= ~ETH_SET_FLOW_CTRL_MASK; - break; - - case MV_ETH_FC_ENABLE: - portSerialCtrlReg |= ETH_DISABLE_FC_AUTO_NEG_MASK; - portSerialCtrlReg |= ETH_SET_FLOW_CTRL_MASK; - break; - - default: - mvOsPrintf("ethDrv: Unexpected FlowControl value %d\n", flowControl); - return MV_BAD_VALUE; - } - MV_REG_WRITE(ETH_PORT_SERIAL_CTRL_REG(port), portSerialCtrlReg); - - return MV_OK; -} - -/******************************************************************************* -* mvEthHeaderModeSet - Set port header mode. -* -* DESCRIPTION: -* This function configures the port to work in Marvell-Header mode. -* -* INPUT: -* void* pPortHandle - Pointer to port specific handler; -* MV_ETH_HEADER_MODE headerMode - The header mode to set the port in. -* -* RETURN: MV_STATUS -* MV_OK - Success -* MV_NOT_SUPPORTED- Feature not supported. -* MV_OUT_OF_RANGE - Failed. Port is out of valid range -* MV_NOT_FOUND - Failed. Port is not initialized. -* MV_BAD_VALUE - Value of headerMode or numRxQueue parameter is not valid. -* -*******************************************************************************/ -MV_STATUS mvEthHeaderModeSet(void* pPortHandle, MV_ETH_HEADER_MODE headerMode) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHandle; - int port = pPortCtrl->portNo; - MV_U32 mvHeaderReg; - MV_U32 numRxQ = MV_ETH_RX_Q_NUM; - - if((port < 0) || (port >= mvCtrlEthMaxPortGet())) - return MV_OUT_OF_RANGE; - - pPortCtrl = ethPortCtrl[port]; - if(pPortCtrl == NULL) - return MV_NOT_FOUND; - - mvHeaderReg = MV_REG_READ(ETH_PORT_MARVELL_HEADER_REG(port)); - /* Disable header mode. */ - mvHeaderReg &= ~ETH_MVHDR_EN_MASK; - - if(headerMode != MV_ETH_DISABLE_HEADER_MODE) - { - /* Enable Header mode. */ - mvHeaderReg |= ETH_MVHDR_EN_MASK; - - /* Clear DA-Prefix & MHMask fields.*/ - mvHeaderReg &= ~(ETH_MVHDR_DAPREFIX_MASK | ETH_MVHDR_MHMASK_MASK); - - if(numRxQ > 1) - { - switch (headerMode) - { - case(MV_ETH_ENABLE_HEADER_MODE_PRI_2_1): - mvHeaderReg |= ETH_MVHDR_DAPREFIX_PRI_1_2; - break; - case(MV_ETH_ENABLE_HEADER_MODE_PRI_DBNUM): - mvHeaderReg |= ETH_MVHDR_DAPREFIX_DBNUM_PRI; - break; - case(MV_ETH_ENABLE_HEADER_MODE_PRI_SPID): - mvHeaderReg |= ETH_MVHDR_DAPREFIX_SPID_PRI; - break; - default: - break; - } - - switch (numRxQ) - { - case (4): - mvHeaderReg |= ETH_MVHDR_MHMASK_4_QUEUE; - break; - case (8): - mvHeaderReg |= ETH_MVHDR_MHMASK_8_QUEUE; - break; - default: - break; - } - } - } - - MV_REG_WRITE(ETH_PORT_MARVELL_HEADER_REG(port), mvHeaderReg); - - return MV_OK; -} - -#if (MV_ETH_VERSION >= 4) -/******************************************************************************* -* mvEthEjpModeSet - Enable / Disable EJP policy for TX. -* -* DESCRIPTION: -* This function -* -* INPUT: -* void* pPortHandle - Pointer to port specific handler; -* MV_BOOL TRUE - enable EJP mode -* FALSE - disable EJP mode -* -* OUTPUT: MV_STATUS -* MV_OK - Success -* Other - Failure -* -* RETURN: None. -* -*******************************************************************************/ -MV_STATUS mvEthEjpModeSet(void* pPortHandle, int mode) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHandle; - int port = pPortCtrl->portNo; - - if((port < 0) || (port >= mvCtrlEthMaxPortGet())) - return MV_OUT_OF_RANGE; - - pPortCtrl = ethPortCtrl[port]; - if(pPortCtrl == NULL) - return MV_NOT_FOUND; - - pPortCtrl->portConfig.ejpMode = mode; - if(mode) - { - /* EJP enabled */ - MV_REG_WRITE(ETH_TXQ_CMD_1_REG(port), ETH_TX_EJP_ENABLE_MASK); - } - else - { - /* EJP disabled */ - MV_REG_WRITE(ETH_TXQ_CMD_1_REG(port), 0); - } - mvOsPrintf("eth_%d: EJP %s - ETH_TXQ_CMD_1_REG: 0x%x = 0x%08x\n", - port, mode ? "Enabled" : "Disabled", ETH_TXQ_CMD_1_REG(port), - MV_REG_READ(ETH_TXQ_CMD_1_REG(port))); - - return MV_OK; -} -#endif /* MV_ETH_VERSION >= 4 */ - -/******************************************************************************* -* mvEthStatusGet - Get major properties of the port . -* -* DESCRIPTION: -* This function get major properties of the port (link, speed, duplex, -* flowControl, etc) and return them using the single structure. -* -* INPUT: -* void* pPortHandle - Pointer to port specific handler; -* -* OUTPUT: -* MV_ETH_PORT_STATUS* pStatus - Pointer to structure, were port status -* will be placed. -* -* RETURN: None. -* -*******************************************************************************/ -void mvEthStatusGet(void* pPortHandle, MV_ETH_PORT_STATUS* pStatus) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHandle; - int port = pPortCtrl->portNo; - - MV_U32 regValue; - - regValue = MV_REG_READ( ETH_PORT_STATUS_REG(port) ); - - if(regValue & ETH_GMII_SPEED_1000_MASK) - pStatus->speed = MV_ETH_SPEED_1000; - else if(regValue & ETH_MII_SPEED_100_MASK) - pStatus->speed = MV_ETH_SPEED_100; - else - pStatus->speed = MV_ETH_SPEED_10; - - if(regValue & ETH_LINK_UP_MASK) - pStatus->isLinkUp = MV_TRUE; - else - pStatus->isLinkUp = MV_FALSE; - - if(regValue & ETH_FULL_DUPLEX_MASK) - pStatus->duplex = MV_ETH_DUPLEX_FULL; - else - pStatus->duplex = MV_ETH_DUPLEX_HALF; - - - if(regValue & ETH_ENABLE_RCV_FLOW_CTRL_MASK) - pStatus->flowControl = MV_ETH_FC_ENABLE; - else - pStatus->flowControl = MV_ETH_FC_DISABLE; -} - - -/******************************************************************************/ -/* PHY Control Functions */ -/******************************************************************************/ - - -/******************************************************************************* -* mvEthPhyAddrSet - Set the ethernet port PHY address. -* -* DESCRIPTION: -* This routine set the ethernet port PHY address according to given -* parameter. -* -* INPUT: -* void* pPortHandle - Pointer to port specific handler; -* int phyAddr - PHY address -* -* RETURN: -* None. -* -*******************************************************************************/ -void mvEthPhyAddrSet(void* pPortHandle, int phyAddr) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHandle; - int port = pPortCtrl->portNo; - unsigned int regData; - - regData = MV_REG_READ(ETH_PHY_ADDR_REG(port)); - - regData &= ~ETH_PHY_ADDR_MASK; - regData |= phyAddr; - - MV_REG_WRITE(ETH_PHY_ADDR_REG(port), regData); - - return; -} - -/******************************************************************************* -* mvEthPhyAddrGet - Get the ethernet port PHY address. -* -* DESCRIPTION: -* This routine returns the given ethernet port PHY address. -* -* INPUT: -* void* pPortHandle - Pointer to port specific handler; -* -* -* RETURN: int - PHY address. -* -*******************************************************************************/ -int mvEthPhyAddrGet(void* pPortHandle) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHandle; - int port = pPortCtrl->portNo; - unsigned int regData; - - regData = MV_REG_READ(ETH_PHY_ADDR_REG(port)); - - return ((regData >> (5 * port)) & 0x1f); -} - -/******************************************************************************/ -/* Descriptor handling Functions */ -/******************************************************************************/ - -/******************************************************************************* -* etherInitRxDescRing - Curve a Rx chain desc list and buffer in memory. -* -* DESCRIPTION: -* This function prepares a Rx chained list of descriptors and packet -* buffers in a form of a ring. The routine must be called after port -* initialization routine and before port start routine. -* The Ethernet SDMA engine uses CPU bus addresses to access the various -* devices in the system (i.e. DRAM). This function uses the ethernet -* struct 'virtual to physical' routine (set by the user) to set the ring -* with physical addresses. -* -* INPUT: -* ETH_QUEUE_CTRL *pEthPortCtrl Ethernet Port Control srtuct. -* int rxQueue Number of Rx queue. -* int rxDescNum Number of Rx descriptors -* MV_U8* rxDescBaseAddr Rx descriptors memory area base addr. -* -* OUTPUT: -* The routine updates the Ethernet port control struct with information -* regarding the Rx descriptors and buffers. -* -* RETURN: None -* -*******************************************************************************/ -static void ethInitRxDescRing(ETH_PORT_CTRL* pPortCtrl, int queue) -{ - ETH_RX_DESC *pRxDescBase, *pRxDesc, *pRxPrevDesc; - int ix, rxDescNum = pPortCtrl->rxQueueConfig[queue].descrNum; - ETH_QUEUE_CTRL *pQueueCtrl = &pPortCtrl->rxQueue[queue]; - - /* Make sure descriptor address is cache line size aligned */ - pRxDescBase = (ETH_RX_DESC*)MV_ALIGN_UP((MV_ULONG)pQueueCtrl->descBuf.bufVirtPtr, - CPU_D_CACHE_LINE_SIZE); - - pRxDesc = (ETH_RX_DESC*)pRxDescBase; - pRxPrevDesc = pRxDesc; - - /* initialize the Rx descriptors ring */ - for (ix=0; ix<rxDescNum; ix++) - { - pRxDesc->bufSize = 0x0; - pRxDesc->byteCnt = 0x0; - pRxDesc->cmdSts = ETH_BUFFER_OWNED_BY_HOST; - pRxDesc->bufPtr = 0x0; - pRxDesc->returnInfo = 0x0; - pRxPrevDesc = pRxDesc; - if(ix == (rxDescNum-1)) - { - /* Closing Rx descriptors ring */ - pRxPrevDesc->nextDescPtr = (MV_U32)ethDescVirtToPhy(pQueueCtrl, (void*)pRxDescBase); - } - else - { - pRxDesc = (ETH_RX_DESC*)((MV_ULONG)pRxDesc + ETH_RX_DESC_ALIGNED_SIZE); - pRxPrevDesc->nextDescPtr = (MV_U32)ethDescVirtToPhy(pQueueCtrl, (void*)pRxDesc); - } - ETH_DESCR_FLUSH_INV(pPortCtrl, pRxPrevDesc); - } - - pQueueCtrl->pCurrentDescr = pRxDescBase; - pQueueCtrl->pUsedDescr = pRxDescBase; - - pQueueCtrl->pFirstDescr = pRxDescBase; - pQueueCtrl->pLastDescr = pRxDesc; - pQueueCtrl->resource = 0; -} - -void ethResetRxDescRing(void* pPortHndl, int queue) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHndl; - ETH_QUEUE_CTRL* pQueueCtrl = &pPortCtrl->rxQueue[queue]; - ETH_RX_DESC* pRxDesc = (ETH_RX_DESC*)pQueueCtrl->pFirstDescr; - - pQueueCtrl->resource = 0; - if(pQueueCtrl->pFirstDescr != NULL) - { - while(MV_TRUE) - { - pRxDesc->bufSize = 0x0; - pRxDesc->byteCnt = 0x0; - pRxDesc->cmdSts = ETH_BUFFER_OWNED_BY_HOST; - pRxDesc->bufPtr = 0x0; - pRxDesc->returnInfo = 0x0; - ETH_DESCR_FLUSH_INV(pPortCtrl, pRxDesc); - if( (void*)pRxDesc == pQueueCtrl->pLastDescr) - break; - pRxDesc = RX_NEXT_DESC_PTR(pRxDesc, pQueueCtrl); - } - pQueueCtrl->pCurrentDescr = pQueueCtrl->pFirstDescr; - pQueueCtrl->pUsedDescr = pQueueCtrl->pFirstDescr; - - /* Update RX Command register */ - pPortCtrl->portRxQueueCmdReg |= (1 << queue); - - /* update HW */ - MV_REG_WRITE( ETH_RX_CUR_DESC_PTR_REG(pPortCtrl->portNo, queue), - (MV_U32)ethDescVirtToPhy(pQueueCtrl, pQueueCtrl->pCurrentDescr) ); - } - else - { - /* Update RX Command register */ - pPortCtrl->portRxQueueCmdReg &= ~(1 << queue); - - /* update HW */ - MV_REG_WRITE( ETH_RX_CUR_DESC_PTR_REG(pPortCtrl->portNo, queue), 0); - } -} - -/******************************************************************************* -* etherInitTxDescRing - Curve a Tx chain desc list and buffer in memory. -* -* DESCRIPTION: -* This function prepares a Tx chained list of descriptors and packet -* buffers in a form of a ring. The routine must be called after port -* initialization routine and before port start routine. -* The Ethernet SDMA engine uses CPU bus addresses to access the various -* devices in the system (i.e. DRAM). This function uses the ethernet -* struct 'virtual to physical' routine (set by the user) to set the ring -* with physical addresses. -* -* INPUT: -* ETH_PORT_CTRL *pEthPortCtrl Ethernet Port Control srtuct. -* int txQueue Number of Tx queue. -* int txDescNum Number of Tx descriptors -* int txBuffSize Size of Tx buffer -* MV_U8* pTxDescBase Tx descriptors memory area base addr. -* -* OUTPUT: -* The routine updates the Ethernet port control struct with information -* regarding the Tx descriptors and buffers. -* -* RETURN: None. -* -*******************************************************************************/ -static void ethInitTxDescRing(ETH_PORT_CTRL* pPortCtrl, int queue) -{ - ETH_TX_DESC *pTxDescBase, *pTxDesc, *pTxPrevDesc; - int ix, txDescNum = pPortCtrl->txQueueConfig[queue].descrNum; - ETH_QUEUE_CTRL *pQueueCtrl = &pPortCtrl->txQueue[queue]; - - /* Make sure descriptor address is cache line size aligned */ - pTxDescBase = (ETH_TX_DESC*)MV_ALIGN_UP((MV_ULONG)pQueueCtrl->descBuf.bufVirtPtr, - CPU_D_CACHE_LINE_SIZE); - - pTxDesc = (ETH_TX_DESC*)pTxDescBase; - pTxPrevDesc = pTxDesc; - - /* initialize the Tx descriptors ring */ - for (ix=0; ix<txDescNum; ix++) - { - pTxDesc->byteCnt = 0x0000; - pTxDesc->L4iChk = 0x0000; - pTxDesc->cmdSts = ETH_BUFFER_OWNED_BY_HOST; - pTxDesc->bufPtr = 0x0; - pTxDesc->returnInfo = 0x0; - - pTxPrevDesc = pTxDesc; - - if(ix == (txDescNum-1)) - { - /* Closing Tx descriptors ring */ - pTxPrevDesc->nextDescPtr = (MV_U32)ethDescVirtToPhy(pQueueCtrl, (void*)pTxDescBase); - } - else - { - pTxDesc = (ETH_TX_DESC*)((MV_ULONG)pTxDesc + ETH_TX_DESC_ALIGNED_SIZE); - pTxPrevDesc->nextDescPtr = (MV_U32)ethDescVirtToPhy(pQueueCtrl, (void*)pTxDesc); - } - ETH_DESCR_FLUSH_INV(pPortCtrl, pTxPrevDesc); - } - - pQueueCtrl->pCurrentDescr = pTxDescBase; - pQueueCtrl->pUsedDescr = pTxDescBase; - - pQueueCtrl->pFirstDescr = pTxDescBase; - pQueueCtrl->pLastDescr = pTxDesc; - /* Leave one TX descriptor out of use */ - pQueueCtrl->resource = txDescNum - 1; -} - -void ethResetTxDescRing(void* pPortHndl, int queue) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHndl; - ETH_QUEUE_CTRL* pQueueCtrl = &pPortCtrl->txQueue[queue]; - ETH_TX_DESC* pTxDesc = (ETH_TX_DESC*)pQueueCtrl->pFirstDescr; - - pQueueCtrl->resource = 0; - if(pQueueCtrl->pFirstDescr != NULL) - { - while(MV_TRUE) - { - pTxDesc->byteCnt = 0x0000; - pTxDesc->L4iChk = 0x0000; - pTxDesc->cmdSts = ETH_BUFFER_OWNED_BY_HOST; - pTxDesc->bufPtr = 0x0; - pTxDesc->returnInfo = 0x0; - ETH_DESCR_FLUSH_INV(pPortCtrl, pTxDesc); - pQueueCtrl->resource++; - if( (void*)pTxDesc == pQueueCtrl->pLastDescr) - break; - pTxDesc = TX_NEXT_DESC_PTR(pTxDesc, pQueueCtrl); - } - /* Leave one TX descriptor out of use */ - pQueueCtrl->resource--; - pQueueCtrl->pCurrentDescr = pQueueCtrl->pFirstDescr; - pQueueCtrl->pUsedDescr = pQueueCtrl->pFirstDescr; - - /* Update TX Command register */ - pPortCtrl->portTxQueueCmdReg |= MV_32BIT_LE_FAST(1 << queue); - /* update HW */ - MV_REG_WRITE( ETH_TX_CUR_DESC_PTR_REG(pPortCtrl->portNo, queue), - (MV_U32)ethDescVirtToPhy(pQueueCtrl, pQueueCtrl->pCurrentDescr) ); - } - else - { - /* Update TX Command register */ - pPortCtrl->portTxQueueCmdReg &= MV_32BIT_LE_FAST(~(1 << queue)); - /* update HW */ - MV_REG_WRITE( ETH_TX_CUR_DESC_PTR_REG(pPortCtrl->portNo, queue), 0 ); - } -} - -/******************************************************************************* -* ethAllocDescrMemory - Free memory allocated for RX and TX descriptors. -* -* DESCRIPTION: -* This function allocates memory for RX and TX descriptors. -* - If ETH_DESCR_IN_SRAM defined, allocate memory from SRAM. -* - If ETH_DESCR_IN_SDRAM defined, allocate memory in SDRAM. -* -* INPUT: -* int size - size of memory should be allocated. -* -* RETURN: None -* -*******************************************************************************/ -static MV_U8* ethAllocDescrMemory(ETH_PORT_CTRL* pPortCtrl, int descSize, - MV_ULONG* pPhysAddr, MV_U32 *memHandle) -{ - MV_U8* pVirt; - -#if defined(ETH_DESCR_IN_SRAM) - if(ethDescInSram == MV_TRUE) - pVirt = (char*)mvSramMalloc(descSize, pPhysAddr); - else -#endif /* ETH_DESCR_IN_SRAM */ - { -#ifdef ETH_DESCR_UNCACHED - pVirt = (MV_U8*)mvOsIoUncachedMalloc(pPortCtrl->osHandle, descSize, - pPhysAddr,memHandle); -#else - pVirt = (MV_U8*)mvOsIoCachedMalloc(pPortCtrl->osHandle, descSize, - pPhysAddr, memHandle); -#endif /* ETH_DESCR_UNCACHED */ - } - memset(pVirt, 0, descSize); - - return pVirt; -} - -/******************************************************************************* -* ethFreeDescrMemory - Free memory allocated for RX and TX descriptors. -* -* DESCRIPTION: -* This function frees memory allocated for RX and TX descriptors. -* - If ETH_DESCR_IN_SRAM defined, free memory using gtSramFree() function. -* - If ETH_DESCR_IN_SDRAM defined, free memory using mvOsFree() function. -* -* INPUT: -* void* pVirtAddr - virtual pointer to memory allocated for RX and TX -* desriptors. -* -* RETURN: None -* -*******************************************************************************/ -void ethFreeDescrMemory(ETH_PORT_CTRL* pPortCtrl, MV_BUF_INFO* pDescBuf) -{ - if( (pDescBuf == NULL) || (pDescBuf->bufVirtPtr == NULL) ) - return; - -#if defined(ETH_DESCR_IN_SRAM) - if( ethDescInSram ) - { - mvSramFree(pDescBuf->bufSize, pDescBuf->bufPhysAddr, pDescBuf->bufVirtPtr); - return; - } -#endif /* ETH_DESCR_IN_SRAM */ - -#ifdef ETH_DESCR_UNCACHED - mvOsIoUncachedFree(pPortCtrl->osHandle, pDescBuf->bufSize, pDescBuf->bufPhysAddr, - pDescBuf->bufVirtPtr,pDescBuf->memHandle); -#else - mvOsIoCachedFree(pPortCtrl->osHandle, pDescBuf->bufSize, pDescBuf->bufPhysAddr, - pDescBuf->bufVirtPtr,pDescBuf->memHandle); -#endif /* ETH_DESCR_UNCACHED */ -} - -/******************************************************************************/ -/* Other Functions */ -/******************************************************************************/ - -void mvEthPortPowerUp(int port) -{ - MV_U32 regVal; - - /* MAC Cause register should be cleared */ - MV_REG_WRITE(ETH_UNIT_INTR_CAUSE_REG(port), 0); - - if (mvBoardIsPortInSgmii(port)) - mvEthPortSgmiiConfig(port); - - /* Cancel Port Reset */ - regVal = MV_REG_READ(ETH_PORT_SERIAL_CTRL_1_REG(port)); - regVal &= (~ETH_PORT_RESET_MASK); - MV_REG_WRITE(ETH_PORT_SERIAL_CTRL_1_REG(port), regVal); - while( (MV_REG_READ(ETH_PORT_SERIAL_CTRL_1_REG(port)) & ETH_PORT_RESET_MASK) != 0); -} - -void mvEthPortPowerDown(int port) -{ - MV_U32 regVal; - - /* Port must be DISABLED */ - regVal = MV_REG_READ(ETH_PORT_SERIAL_CTRL_REG(port)); - if( (regVal & ETH_PORT_ENABLE_MASK) != 0) - { - mvOsPrintf("ethPort #%d: PowerDown - port must be Disabled (PSC=0x%x)\n", - port, regVal); - return; - } - - /* Port Reset (Read after write the register as a precaution) */ - regVal = MV_REG_READ(ETH_PORT_SERIAL_CTRL_1_REG(port)); - MV_REG_WRITE(ETH_PORT_SERIAL_CTRL_1_REG(port), regVal | ETH_PORT_RESET_MASK); - while((MV_REG_READ(ETH_PORT_SERIAL_CTRL_1_REG(port)) & ETH_PORT_RESET_MASK) == 0); -} - -static void mvEthPortSgmiiConfig(int port) -{ - MV_U32 regVal; - - regVal = MV_REG_READ(ETH_PORT_SERIAL_CTRL_1_REG(port)); - - regVal |= (ETH_SGMII_MODE_MASK /*| ETH_INBAND_AUTO_NEG_ENABLE_MASK */); - regVal &= (~ETH_INBAND_AUTO_NEG_BYPASS_MASK); - - MV_REG_WRITE(ETH_PORT_SERIAL_CTRL_1_REG(port), regVal); -} - - - - - - - - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/eth/gbe/mvEthDebug.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/eth/gbe/mvEthDebug.c deleted file mode 100644 index eabac5a..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/eth/gbe/mvEthDebug.c +++ /dev/null @@ -1,748 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -/******************************************************************************* -* mvEthDebug.c - Source file for user friendly debug functions -* -* DESCRIPTION: -* -* DEPENDENCIES: -* None. -* -*******************************************************************************/ - -#include "mvOs.h" -#include "mvCommon.h" -#include "mvTypes.h" -#include "mv802_3.h" -#include "mvDebug.h" -#include "ctrlEnv/mvCtrlEnvLib.h" -#include "eth-phy/mvEthPhy.h" -#include "eth/mvEth.h" -#include "eth/gbe/mvEthDebug.h" - -/* #define mvOsPrintf printf */ - -void mvEthPortShow(void* pHndl); -void mvEthQueuesShow(void* pHndl, int rxQueue, int txQueue, int mode); - -/******************************************************************************/ -/* Debug functions */ -/******************************************************************************/ -void ethRxCoal(int port, int usec) -{ - void* pHndl; - - pHndl = mvEthPortHndlGet(port); - if(pHndl != NULL) - { - mvEthRxCoalSet(pHndl, usec); - } -} - -void ethTxCoal(int port, int usec) -{ - void* pHndl; - - pHndl = mvEthPortHndlGet(port); - if(pHndl != NULL) - { - mvEthTxCoalSet(pHndl, usec); - } -} - -#if (MV_ETH_VERSION >= 4) -void ethEjpModeSet(int port, int mode) -{ - void* pHndl; - - pHndl = mvEthPortHndlGet(port); - if(pHndl != NULL) - { - mvEthEjpModeSet(pHndl, mode); - } -} -#endif /* (MV_ETH_VERSION >= 4) */ - -void ethBpduRxQ(int port, int bpduQueue) -{ - void* pHndl; - - pHndl = mvEthPortHndlGet(port); - if(pHndl != NULL) - { - mvEthBpduRxQueue(pHndl, bpduQueue); - } -} - -void ethArpRxQ(int port, int arpQueue) -{ - void* pHndl; - - pHndl = mvEthPortHndlGet(port); - if(pHndl != NULL) - { - mvEthArpRxQueue(pHndl, arpQueue); - } -} - -void ethTcpRxQ(int port, int tcpQueue) -{ - void* pHndl; - - pHndl = mvEthPortHndlGet(port); - if(pHndl != NULL) - { - mvEthTcpRxQueue(pHndl, tcpQueue); - } -} - -void ethUdpRxQ(int port, int udpQueue) -{ - void* pHndl; - - pHndl = mvEthPortHndlGet(port); - if(pHndl != NULL) - { - mvEthUdpRxQueue(pHndl, udpQueue); - } -} - -void ethTxPolicyRegs(int port) -{ - int queue; - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)mvEthPortHndlGet(port); - - if(pPortCtrl == NULL) - { - return; - } - mvOsPrintf("Port #%d TX Policy: EJP=%d, TXQs: ", - port, pPortCtrl->portConfig.ejpMode); - for(queue=0; queue<MV_ETH_TX_Q_NUM; queue++) - { - if(pPortCtrl->txQueueConfig[queue].descrNum > 0) - mvOsPrintf("%d, ", queue); - } - mvOsPrintf("\n"); - - mvOsPrintf("\n\t TX policy Port #%d configuration registers\n", port); - - mvOsPrintf("ETH_TX_QUEUE_COMMAND_REG : 0x%X = 0x%08x\n", - ETH_TX_QUEUE_COMMAND_REG(port), - MV_REG_READ( ETH_TX_QUEUE_COMMAND_REG(port) ) ); - - mvOsPrintf("ETH_TX_FIXED_PRIO_CFG_REG : 0x%X = 0x%08x\n", - ETH_TX_FIXED_PRIO_CFG_REG(port), - MV_REG_READ( ETH_TX_FIXED_PRIO_CFG_REG(port) ) ); - - mvOsPrintf("ETH_TX_TOKEN_RATE_CFG_REG : 0x%X = 0x%08x\n", - ETH_TX_TOKEN_RATE_CFG_REG(port), - MV_REG_READ( ETH_TX_TOKEN_RATE_CFG_REG(port) ) ); - - mvOsPrintf("ETH_MAX_TRANSMIT_UNIT_REG : 0x%X = 0x%08x\n", - ETH_MAX_TRANSMIT_UNIT_REG(port), - MV_REG_READ( ETH_MAX_TRANSMIT_UNIT_REG(port) ) ); - - mvOsPrintf("ETH_TX_TOKEN_BUCKET_SIZE_REG : 0x%X = 0x%08x\n", - ETH_TX_TOKEN_BUCKET_SIZE_REG(port), - MV_REG_READ( ETH_TX_TOKEN_BUCKET_SIZE_REG(port) ) ); - - mvOsPrintf("ETH_TX_TOKEN_BUCKET_COUNT_REG : 0x%X = 0x%08x\n", - ETH_TX_TOKEN_BUCKET_COUNT_REG(port), - MV_REG_READ( ETH_TX_TOKEN_BUCKET_COUNT_REG(port) ) ); - - for(queue=0; queue<MV_ETH_MAX_TXQ; queue++) - { - mvOsPrintf("\n\t TX policy Port #%d, Queue #%d configuration registers\n", port, queue); - - mvOsPrintf("ETH_TXQ_TOKEN_COUNT_REG : 0x%X = 0x%08x\n", - ETH_TXQ_TOKEN_COUNT_REG(port, queue), - MV_REG_READ( ETH_TXQ_TOKEN_COUNT_REG(port, queue) ) ); - - mvOsPrintf("ETH_TXQ_TOKEN_CFG_REG : 0x%X = 0x%08x\n", - ETH_TXQ_TOKEN_CFG_REG(port, queue), - MV_REG_READ( ETH_TXQ_TOKEN_CFG_REG(port, queue) ) ); - - mvOsPrintf("ETH_TXQ_ARBITER_CFG_REG : 0x%X = 0x%08x\n", - ETH_TXQ_ARBITER_CFG_REG(port, queue), - MV_REG_READ( ETH_TXQ_ARBITER_CFG_REG(port, queue) ) ); - } - mvOsPrintf("\n"); -} - -/* Print important registers of Ethernet port */ -void ethPortRegs(int port) -{ - mvOsPrintf("\n\t ethGiga #%d port Registers:\n", port); - - mvOsPrintf("ETH_PORT_STATUS_REG : 0x%X = 0x%08x\n", - ETH_PORT_STATUS_REG(port), - MV_REG_READ( ETH_PORT_STATUS_REG(port) ) ); - - mvOsPrintf("ETH_PORT_SERIAL_CTRL_REG : 0x%X = 0x%08x\n", - ETH_PORT_SERIAL_CTRL_REG(port), - MV_REG_READ( ETH_PORT_SERIAL_CTRL_REG(port) ) ); - - mvOsPrintf("ETH_PORT_CONFIG_REG : 0x%X = 0x%08x\n", - ETH_PORT_CONFIG_REG(port), - MV_REG_READ( ETH_PORT_CONFIG_REG(port) ) ); - - mvOsPrintf("ETH_PORT_CONFIG_EXTEND_REG : 0x%X = 0x%08x\n", - ETH_PORT_CONFIG_EXTEND_REG(port), - MV_REG_READ( ETH_PORT_CONFIG_EXTEND_REG(port) ) ); - - mvOsPrintf("ETH_SDMA_CONFIG_REG : 0x%X = 0x%08x\n", - ETH_SDMA_CONFIG_REG(port), - MV_REG_READ( ETH_SDMA_CONFIG_REG(port) ) ); - - mvOsPrintf("ETH_TX_FIFO_URGENT_THRESH_REG : 0x%X = 0x%08x\n", - ETH_TX_FIFO_URGENT_THRESH_REG(port), - MV_REG_READ( ETH_TX_FIFO_URGENT_THRESH_REG(port) ) ); - - mvOsPrintf("ETH_RX_QUEUE_COMMAND_REG : 0x%X = 0x%08x\n", - ETH_RX_QUEUE_COMMAND_REG(port), - MV_REG_READ( ETH_RX_QUEUE_COMMAND_REG(port) ) ); - - mvOsPrintf("ETH_TX_QUEUE_COMMAND_REG : 0x%X = 0x%08x\n", - ETH_TX_QUEUE_COMMAND_REG(port), - MV_REG_READ( ETH_TX_QUEUE_COMMAND_REG(port) ) ); - - mvOsPrintf("ETH_INTR_CAUSE_REG : 0x%X = 0x%08x\n", - ETH_INTR_CAUSE_REG(port), - MV_REG_READ( ETH_INTR_CAUSE_REG(port) ) ); - - mvOsPrintf("ETH_INTR_EXTEND_CAUSE_REG : 0x%X = 0x%08x\n", - ETH_INTR_CAUSE_EXT_REG(port), - MV_REG_READ( ETH_INTR_CAUSE_EXT_REG(port) ) ); - - mvOsPrintf("ETH_INTR_MASK_REG : 0x%X = 0x%08x\n", - ETH_INTR_MASK_REG(port), - MV_REG_READ( ETH_INTR_MASK_REG(port) ) ); - - mvOsPrintf("ETH_INTR_EXTEND_MASK_REG : 0x%X = 0x%08x\n", - ETH_INTR_MASK_EXT_REG(port), - MV_REG_READ( ETH_INTR_MASK_EXT_REG(port) ) ); - - mvOsPrintf("ETH_RX_DESCR_STAT_CMD_REG : 0x%X = 0x%08x\n", - ETH_RX_DESCR_STAT_CMD_REG(port, 0), - MV_REG_READ( ETH_RX_DESCR_STAT_CMD_REG(port, 0) ) ); - - mvOsPrintf("ETH_RX_BYTE_COUNT_REG : 0x%X = 0x%08x\n", - ETH_RX_BYTE_COUNT_REG(port, 0), - MV_REG_READ( ETH_RX_BYTE_COUNT_REG(port, 0) ) ); - - mvOsPrintf("ETH_RX_BUF_PTR_REG : 0x%X = 0x%08x\n", - ETH_RX_BUF_PTR_REG(port, 0), - MV_REG_READ( ETH_RX_BUF_PTR_REG(port, 0) ) ); - - mvOsPrintf("ETH_RX_CUR_DESC_PTR_REG : 0x%X = 0x%08x\n", - ETH_RX_CUR_DESC_PTR_REG(port, 0), - MV_REG_READ( ETH_RX_CUR_DESC_PTR_REG(port, 0) ) ); -} - - -/* Print Giga Ethernet UNIT registers */ -void ethRegs(int port) -{ - mvOsPrintf("ETH_PHY_ADDR_REG : 0x%X = 0x%08x\n", - ETH_PHY_ADDR_REG(port), - MV_REG_READ(ETH_PHY_ADDR_REG(port)) ); - - mvOsPrintf("ETH_UNIT_INTR_CAUSE_REG : 0x%X = 0x%08x\n", - ETH_UNIT_INTR_CAUSE_REG(port), - MV_REG_READ( ETH_UNIT_INTR_CAUSE_REG(port)) ); - - mvOsPrintf("ETH_UNIT_INTR_MASK_REG : 0x%X = 0x%08x\n", - ETH_UNIT_INTR_MASK_REG(port), - MV_REG_READ( ETH_UNIT_INTR_MASK_REG(port)) ); - - mvOsPrintf("ETH_UNIT_ERROR_ADDR_REG : 0x%X = 0x%08x\n", - ETH_UNIT_ERROR_ADDR_REG(port), - MV_REG_READ(ETH_UNIT_ERROR_ADDR_REG(port)) ); - - mvOsPrintf("ETH_UNIT_INT_ADDR_ERROR_REG : 0x%X = 0x%08x\n", - ETH_UNIT_INT_ADDR_ERROR_REG(port), - MV_REG_READ(ETH_UNIT_INT_ADDR_ERROR_REG(port)) ); - -} - -/******************************************************************************/ -/* MIB Counters functions */ -/******************************************************************************/ - -/******************************************************************************* -* ethClearMibCounters - Clear all MIB counters -* -* DESCRIPTION: -* This function clears all MIB counters of a specific ethernet port. -* A read from the MIB counter will reset the counter. -* -* INPUT: -* int port - Ethernet Port number. -* -* RETURN: None -* -*******************************************************************************/ -void ethClearCounters(int port) -{ - void* pHndl; - - pHndl = mvEthPortHndlGet(port); - if(pHndl != NULL) - mvEthMibCountersClear(pHndl); - - return; -} - - -/* Print counters of the Ethernet port */ -void ethPortCounters(int port) -{ - MV_U32 regValue, regValHigh; - void* pHndl; - - pHndl = mvEthPortHndlGet(port); - if(pHndl == NULL) - return; - - mvOsPrintf("\n\t Port #%d MIB Counters\n\n", port); - - mvOsPrintf("GoodFramesReceived = %u\n", - mvEthMibCounterRead(pHndl, ETH_MIB_GOOD_FRAMES_RECEIVED, NULL)); - mvOsPrintf("BadFramesReceived = %u\n", - mvEthMibCounterRead(pHndl, ETH_MIB_BAD_FRAMES_RECEIVED, NULL)); - mvOsPrintf("BroadcastFramesReceived = %u\n", - mvEthMibCounterRead(pHndl, ETH_MIB_BROADCAST_FRAMES_RECEIVED, NULL)); - mvOsPrintf("MulticastFramesReceived = %u\n", - mvEthMibCounterRead(pHndl, ETH_MIB_MULTICAST_FRAMES_RECEIVED, NULL)); - - regValue = mvEthMibCounterRead(pHndl, ETH_MIB_GOOD_OCTETS_RECEIVED_LOW, - ®ValHigh); - mvOsPrintf("GoodOctetsReceived = 0x%08x%08x\n", - regValHigh, regValue); - - mvOsPrintf("\n"); - mvOsPrintf("GoodFramesSent = %u\n", - mvEthMibCounterRead(pHndl, ETH_MIB_GOOD_FRAMES_SENT, NULL)); - mvOsPrintf("BroadcastFramesSent = %u\n", - mvEthMibCounterRead(pHndl, ETH_MIB_BROADCAST_FRAMES_SENT, NULL)); - mvOsPrintf("MulticastFramesSent = %u\n", - mvEthMibCounterRead(pHndl, ETH_MIB_MULTICAST_FRAMES_SENT, NULL)); - - regValue = mvEthMibCounterRead(pHndl, ETH_MIB_GOOD_OCTETS_SENT_LOW, - ®ValHigh); - mvOsPrintf("GoodOctetsSent = 0x%08x%08x\n", regValHigh, regValue); - - - mvOsPrintf("\n\t FC Control Counters\n"); - - regValue = mvEthMibCounterRead(pHndl, ETH_MIB_UNREC_MAC_CONTROL_RECEIVED, NULL); - mvOsPrintf("UnrecogMacControlReceived = %u\n", regValue); - - regValue = mvEthMibCounterRead(pHndl, ETH_MIB_GOOD_FC_RECEIVED, NULL); - mvOsPrintf("GoodFCFramesReceived = %u\n", regValue); - - regValue = mvEthMibCounterRead(pHndl, ETH_MIB_BAD_FC_RECEIVED, NULL); - mvOsPrintf("BadFCFramesReceived = %u\n", regValue); - - regValue = mvEthMibCounterRead(pHndl, ETH_MIB_FC_SENT, NULL); - mvOsPrintf("FCFramesSent = %u\n", regValue); - - - mvOsPrintf("\n\t RX Errors\n"); - - regValue = mvEthMibCounterRead(pHndl, ETH_MIB_BAD_OCTETS_RECEIVED, NULL); - mvOsPrintf("BadOctetsReceived = %u\n", regValue); - - regValue = mvEthMibCounterRead(pHndl, ETH_MIB_UNDERSIZE_RECEIVED, NULL); - mvOsPrintf("UndersizeFramesReceived = %u\n", regValue); - - regValue = mvEthMibCounterRead(pHndl, ETH_MIB_FRAGMENTS_RECEIVED, NULL); - mvOsPrintf("FragmentsReceived = %u\n", regValue); - - regValue = mvEthMibCounterRead(pHndl, ETH_MIB_OVERSIZE_RECEIVED, NULL); - mvOsPrintf("OversizeFramesReceived = %u\n", regValue); - - regValue = mvEthMibCounterRead(pHndl, ETH_MIB_JABBER_RECEIVED, NULL); - mvOsPrintf("JabbersReceived = %u\n", regValue); - - regValue = mvEthMibCounterRead(pHndl, ETH_MIB_MAC_RECEIVE_ERROR, NULL); - mvOsPrintf("MacReceiveErrors = %u\n", regValue); - - regValue = mvEthMibCounterRead(pHndl, ETH_MIB_BAD_CRC_EVENT, NULL); - mvOsPrintf("BadCrcReceived = %u\n", regValue); - - mvOsPrintf("\n\t TX Errors\n"); - - regValue = mvEthMibCounterRead(pHndl, ETH_MIB_INTERNAL_MAC_TRANSMIT_ERR, NULL); - mvOsPrintf("TxMacErrors = %u\n", regValue); - - regValue = mvEthMibCounterRead(pHndl, ETH_MIB_EXCESSIVE_COLLISION, NULL); - mvOsPrintf("TxExcessiveCollisions = %u\n", regValue); - - regValue = mvEthMibCounterRead(pHndl, ETH_MIB_COLLISION, NULL); - mvOsPrintf("TxCollisions = %u\n", regValue); - - regValue = mvEthMibCounterRead(pHndl, ETH_MIB_LATE_COLLISION, NULL); - mvOsPrintf("TxLateCollisions = %u\n", regValue); - - - mvOsPrintf("\n"); - regValue = MV_REG_READ( ETH_RX_DISCARD_PKTS_CNTR_REG(port)); - mvOsPrintf("Rx Discard packets counter = %u\n", regValue); - - regValue = MV_REG_READ(ETH_RX_OVERRUN_PKTS_CNTR_REG(port)); - mvOsPrintf("Rx Overrun packets counter = %u\n", regValue); -} - -/* Print RMON counters of the Ethernet port */ -void ethPortRmonCounters(int port) -{ - void* pHndl; - - pHndl = mvEthPortHndlGet(port); - if(pHndl == NULL) - return; - - mvOsPrintf("\n\t Port #%d RMON MIB Counters\n\n", port); - - mvOsPrintf("64 ByteFramesReceived = %u\n", - mvEthMibCounterRead(pHndl, ETH_MIB_FRAMES_64_OCTETS, NULL)); - mvOsPrintf("65...127 ByteFramesReceived = %u\n", - mvEthMibCounterRead(pHndl, ETH_MIB_FRAMES_65_TO_127_OCTETS, NULL)); - mvOsPrintf("128...255 ByteFramesReceived = %u\n", - mvEthMibCounterRead(pHndl, ETH_MIB_FRAMES_128_TO_255_OCTETS, NULL)); - mvOsPrintf("256...511 ByteFramesReceived = %u\n", - mvEthMibCounterRead(pHndl, ETH_MIB_FRAMES_256_TO_511_OCTETS, NULL)); - mvOsPrintf("512...1023 ByteFramesReceived = %u\n", - mvEthMibCounterRead(pHndl, ETH_MIB_FRAMES_512_TO_1023_OCTETS, NULL)); - mvOsPrintf("1024...Max ByteFramesReceived = %u\n", - mvEthMibCounterRead(pHndl, ETH_MIB_FRAMES_1024_TO_MAX_OCTETS, NULL)); -} - -/* Print port information */ -void ethPortStatus(int port) -{ - void* pHndl; - - pHndl = mvEthPortHndlGet(port); - if(pHndl != NULL) - { - mvEthPortShow(pHndl); - } -} - -/* Print port queues information */ -void ethPortQueues(int port, int rxQueue, int txQueue, int mode) -{ - void* pHndl; - - pHndl = mvEthPortHndlGet(port); - if(pHndl != NULL) - { - mvEthQueuesShow(pHndl, rxQueue, txQueue, mode); - } -} - -void ethUcastSet(int port, char* macStr, int queue) -{ - void* pHndl; - MV_U8 macAddr[MV_MAC_ADDR_SIZE]; - - pHndl = mvEthPortHndlGet(port); - if(pHndl != NULL) - { - mvMacStrToHex(macStr, macAddr); - mvEthMacAddrSet(pHndl, macAddr, queue); - } -} - - -void ethPortUcastShow(int port) -{ - MV_U32 unicastReg, macL, macH; - int i, j; - - macL = MV_REG_READ(ETH_MAC_ADDR_LOW_REG(port)); - macH = MV_REG_READ(ETH_MAC_ADDR_HIGH_REG(port)); - - mvOsPrintf("\n\t Port #%d Unicast MAC table: %02x:%02x:%02x:%02x:%02x:%02x\n\n", - port, ((macH >> 24) & 0xff), ((macH >> 16) & 0xff), - ((macH >> 8) & 0xff), (macH & 0xff), - ((macL >> 8) & 0xff), (macL & 0xff) ); - - for (i=0; i<4; i++) - { - unicastReg = MV_REG_READ( (ETH_DA_FILTER_UCAST_BASE(port) + i*4)); - for(j=0; j<4; j++) - { - MV_U8 macEntry = (unicastReg >> (8*j)) & 0xFF; - - mvOsPrintf("%X: %8s, Q = %d\n", i*4+j, - (macEntry & BIT0) ? "Accept" : "Reject", (macEntry >> 1) & 0x7); - } - } -} - -void ethMcastAdd(int port, char* macStr, int queue) -{ - void* pHndl; - MV_U8 macAddr[MV_MAC_ADDR_SIZE]; - - pHndl = mvEthPortHndlGet(port); - if(pHndl != NULL) - { - mvMacStrToHex(macStr, macAddr); - mvEthMcastAddrSet(pHndl, macAddr, queue); - } -} - -void ethPortMcast(int port) -{ - int tblIdx, regIdx; - MV_U32 regVal; - - mvOsPrintf("\n\t Port #%d Special (IP) Multicast table: 01:00:5E:00:00:XX\n\n", - port); - - for(tblIdx=0; tblIdx<(256/4); tblIdx++) - { - regVal = MV_REG_READ((ETH_DA_FILTER_SPEC_MCAST_BASE(port) + tblIdx*4)); - for(regIdx=0; regIdx<4; regIdx++) - { - if((regVal & (0x01 << (regIdx*8))) != 0) - { - mvOsPrintf("0x%02X: Accepted, rxQ = %d\n", - tblIdx*4+regIdx, ((regVal >> (regIdx*8+1)) & 0x07)); - } - } - } - mvOsPrintf("\n\t Port #%d Other Multicast table\n\n", port); - for(tblIdx=0; tblIdx<(256/4); tblIdx++) - { - regVal = MV_REG_READ((ETH_DA_FILTER_OTH_MCAST_BASE(port) + tblIdx*4)); - for(regIdx=0; regIdx<4; regIdx++) - { - if((regVal & (0x01 << (regIdx*8))) != 0) - { - mvOsPrintf("Crc8=0x%02X: Accepted, rxQ = %d\n", - tblIdx*4+regIdx, ((regVal >> (regIdx*8+1)) & 0x07)); - } - } - } -} - - -/* Print status of Ethernet port */ -void mvEthPortShow(void* pHndl) -{ - MV_U32 regValue, rxCoal, txCoal; - int speed, queue, port; - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pHndl; - - port = pPortCtrl->portNo; - - regValue = MV_REG_READ( ETH_PORT_STATUS_REG(port) ); - - mvOsPrintf("\n\t ethGiga #%d port Status: 0x%04x = 0x%08x\n\n", - port, ETH_PORT_STATUS_REG(port), regValue); - - mvOsPrintf("descInSram=%d, descSwCoher=%d\n", - ethDescInSram, ethDescSwCoher); - - if(regValue & ETH_GMII_SPEED_1000_MASK) - speed = 1000; - else if(regValue & ETH_MII_SPEED_100_MASK) - speed = 100; - else - speed = 10; - - mvEthCoalGet(pPortCtrl, &rxCoal, &txCoal); - - /* Link, Speed, Duplex, FlowControl */ - mvOsPrintf("Link=%s, Speed=%d, Duplex=%s, RxFlowControl=%s", - (regValue & ETH_LINK_UP_MASK) ? "UP" : "DOWN", - speed, - (regValue & ETH_FULL_DUPLEX_MASK) ? "FULL" : "HALF", - (regValue & ETH_ENABLE_RCV_FLOW_CTRL_MASK) ? "ENABLE" : "DISABLE"); - - mvOsPrintf("\n"); - - mvOsPrintf("RxCoal = %d usec, TxCoal = %d usec\n", - rxCoal, txCoal); - - mvOsPrintf("rxDefQ=%d, arpQ=%d, bpduQ=%d, tcpQ=%d, udpQ=%d\n\n", - pPortCtrl->portConfig.rxDefQ, pPortCtrl->portConfig.rxArpQ, - pPortCtrl->portConfig.rxBpduQ, - pPortCtrl->portConfig.rxTcpQ, pPortCtrl->portConfig.rxUdpQ); - - /* Print all RX and TX queues */ - for(queue=0; queue<MV_ETH_RX_Q_NUM; queue++) - { - mvOsPrintf("RX Queue #%d: base=0x%lx, free=%d\n", - queue, (MV_ULONG)pPortCtrl->rxQueue[queue].pFirstDescr, - mvEthRxResourceGet(pPortCtrl, queue) ); - } - mvOsPrintf("\n"); - for(queue=0; queue<MV_ETH_TX_Q_NUM; queue++) - { - mvOsPrintf("TX Queue #%d: base=0x%lx, free=%d\n", - queue, (MV_ULONG)pPortCtrl->txQueue[queue].pFirstDescr, - mvEthTxResourceGet(pPortCtrl, queue) ); - } -} - -/* Print RX and TX queue of the Ethernet port */ -void mvEthQueuesShow(void* pHndl, int rxQueue, int txQueue, int mode) -{ - ETH_PORT_CTRL *pPortCtrl = (ETH_PORT_CTRL*)pHndl; - ETH_QUEUE_CTRL *pQueueCtrl; - MV_U32 regValue; - ETH_RX_DESC *pRxDescr; - ETH_TX_DESC *pTxDescr; - int i, port = pPortCtrl->portNo; - - if( (rxQueue >=0) && (rxQueue < MV_ETH_RX_Q_NUM) ) - { - pQueueCtrl = &(pPortCtrl->rxQueue[rxQueue]); - mvOsPrintf("Port #%d, RX Queue #%d\n\n", port, rxQueue); - - mvOsPrintf("CURR_RX_DESC_PTR : 0x%X = 0x%08x\n", - ETH_RX_CUR_DESC_PTR_REG(port, rxQueue), - MV_REG_READ( ETH_RX_CUR_DESC_PTR_REG(port, rxQueue))); - - - if(pQueueCtrl->pFirstDescr != NULL) - { - mvOsPrintf("pFirstDescr=0x%lx, pLastDescr=0x%lx, numOfResources=%d\n", - (MV_ULONG)pQueueCtrl->pFirstDescr, (MV_ULONG)pQueueCtrl->pLastDescr, - pQueueCtrl->resource); - mvOsPrintf("pCurrDescr: 0x%lx, pUsedDescr: 0x%lx\n", - (MV_ULONG)pQueueCtrl->pCurrentDescr, - (MV_ULONG)pQueueCtrl->pUsedDescr); - - if(mode == 1) - { - pRxDescr = (ETH_RX_DESC*)pQueueCtrl->pFirstDescr; - i = 0; - do - { - mvOsPrintf("%3d. desc=%08x (%08x), cmd=%08x, data=%4d, buf=%4d, buf=%08x, pkt=%lx, os=%lx\n", - i, (MV_U32)pRxDescr, (MV_U32)ethDescVirtToPhy(pQueueCtrl, (MV_U8*)pRxDescr), - pRxDescr->cmdSts, pRxDescr->byteCnt, (MV_U32)pRxDescr->bufSize, - (unsigned int)pRxDescr->bufPtr, (MV_ULONG)pRxDescr->returnInfo, - ((MV_PKT_INFO*)pRxDescr->returnInfo)->osInfo); - - ETH_DESCR_INV(pPortCtrl, pRxDescr); - pRxDescr = RX_NEXT_DESC_PTR(pRxDescr, pQueueCtrl); - i++; - } while (pRxDescr != pQueueCtrl->pFirstDescr); - } - } - else - mvOsPrintf("RX Queue #%d is NOT CREATED\n", rxQueue); - } - - if( (txQueue >=0) && (txQueue < MV_ETH_TX_Q_NUM) ) - { - pQueueCtrl = &(pPortCtrl->txQueue[txQueue]); - mvOsPrintf("Port #%d, TX Queue #%d\n\n", port, txQueue); - - regValue = MV_REG_READ( ETH_TX_CUR_DESC_PTR_REG(port, txQueue)); - mvOsPrintf("CURR_TX_DESC_PTR : 0x%X = 0x%08x\n", - ETH_TX_CUR_DESC_PTR_REG(port, txQueue), regValue); - - if(pQueueCtrl->pFirstDescr != NULL) - { - mvOsPrintf("pFirstDescr=0x%lx, pLastDescr=0x%lx, numOfResources=%d\n", - (MV_ULONG)pQueueCtrl->pFirstDescr, - (MV_ULONG)pQueueCtrl->pLastDescr, - pQueueCtrl->resource); - mvOsPrintf("pCurrDescr: 0x%lx, pUsedDescr: 0x%lx\n", - (MV_ULONG)pQueueCtrl->pCurrentDescr, - (MV_ULONG)pQueueCtrl->pUsedDescr); - - if(mode == 1) - { - pTxDescr = (ETH_TX_DESC*)pQueueCtrl->pFirstDescr; - i = 0; - do - { - mvOsPrintf("%3d. desc=%08x (%08x), cmd=%08x, data=%4d, buf=%08x, pkt=%lx, os=%lx\n", - i, (MV_U32)pTxDescr, (MV_U32)ethDescVirtToPhy(pQueueCtrl, (MV_U8*)pTxDescr), - pTxDescr->cmdSts, pTxDescr->byteCnt, - (MV_U32)pTxDescr->bufPtr, (MV_ULONG)pTxDescr->returnInfo, - pTxDescr->returnInfo ? (((MV_PKT_INFO*)pTxDescr->returnInfo)->osInfo) : 0x0); - - ETH_DESCR_INV(pPortCtrl, pTxDescr); - pTxDescr = TX_NEXT_DESC_PTR(pTxDescr, pQueueCtrl); - i++; - } while (pTxDescr != pQueueCtrl->pFirstDescr); - } - } - else - mvOsPrintf("TX Queue #%d is NOT CREATED\n", txQueue); - } -} diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/eth/gbe/mvEthDebug.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/eth/gbe/mvEthDebug.h deleted file mode 100644 index 6db85f7..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/eth/gbe/mvEthDebug.h +++ /dev/null @@ -1,146 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ -#ifndef __MV_ETH_DEBUG_H__ -#define __MV_ETH_DEBUG_H__ - -#if 0 -/* - ** Externs - */ -void ethBpduRxQ(int port, int bpduQueue); -void ethArpRxQ(int port, int bpduQueue); -void ethTcpRxQ(int port, int bpduQueue); -void ethUdpRxQ(int port, int bpduQueue); -void ethMcastAdd(int port, char* macStr, int queue); - -#ifdef INCLUDE_MULTI_QUEUE -void ethRxPolicy( int port); -void ethTxPolicy( int port); -void ethTxPolDA(int port, char* macStr, int txQ, char* headerHexStr); -void ethRxPolMode(int port, MV_ETH_PRIO_MODE prioMode); -void ethRxPolQ(int port, int rxQueue, int rxQuota); -#endif /* INCLUDE_MULTI_QUEUE */ - -void print_egiga_stat(void *sc, unsigned int port); -void ethPortStatus (int port); -void ethPortQueues( int port, int rxQueue, int txQueue, int mode); -void ethPortMcast(int port); -void ethPortRegs(int port); -void ethPortCounters(int port); -void ethPortRmonCounters(int port); -void ethRxCoal(int port, int usec); -void ethTxCoal(int port, int usec); - -void ethRegs(int port); -void ethClearCounters(int port); -void ethUcastSet(int port, char* macStr, int queue); -void ethPortUcastShow(int port); - -#ifdef CONFIG_MV_ETH_HEADER -void run_com_header(const char *buffer); -#endif - -#ifdef INCLUDE_MULTI_QUEUE -void ethRxPolMode(int port, MV_ETH_PRIO_MODE prioMode); -void ethRxPolQ(int port, int queue, int quota); -void ethRxPolicy(int port); -void ethTxPolDef(int port, int txQ, char* headerHexStr); -void ethTxPolDA(int port, char* macStr, int txQ, char* headerHexStr); -void ethTxPolicy(int port); -#endif /* INCLUDE_MULTI_QUEUE */ - -#if (MV_ETH_VERSION >= 4) -void ethEjpModeSet(int port, int mode) -#endif -#endif /* 0 */ - - - - -void ethRxCoal(int port, int usec); -void ethTxCoal(int port, int usec); -#if (MV_ETH_VERSION >= 4) -void ethEjpModeSet(int port, int mode); -#endif /* (MV_ETH_VERSION >= 4) */ - -void ethBpduRxQ(int port, int bpduQueue); -void ethArpRxQ(int port, int arpQueue); -void ethTcpRxQ(int port, int tcpQueue); -void ethUdpRxQ(int port, int udpQueue); -void ethTxPolicyRegs(int port); -void ethPortRegs(int port); -void ethRegs(int port); -void ethClearCounters(int port); -void ethPortCounters(int port); -void ethPortRmonCounters(int port); -void ethPortStatus(int port); -void ethPortQueues(int port, int rxQueue, int txQueue, int mode); -void ethUcastSet(int port, char* macStr, int queue); -void ethPortUcastShow(int port); -void ethMcastAdd(int port, char* macStr, int queue); -void ethPortMcast(int port); -void mvEthPortShow(void* pHndl); -void mvEthQueuesShow(void* pHndl, int rxQueue, int txQueue, int mode); - -#endif diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/eth/gbe/mvEthGbe.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/eth/gbe/mvEthGbe.h deleted file mode 100644 index f4cae50..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/eth/gbe/mvEthGbe.h +++ /dev/null @@ -1,751 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -/******************************************************************************* -* mvEth.h - Header File for : Marvell Gigabit Ethernet Controller -* -* DESCRIPTION: -* This header file contains macros typedefs and function declaration specific to -* the Marvell Gigabit Ethernet Controller. -* -* DEPENDENCIES: -* None. -* -*******************************************************************************/ - -#ifndef __mvEthGbe_h__ -#define __mvEthGbe_h__ - -extern MV_BOOL ethDescInSram; -extern MV_BOOL ethDescSwCoher; -extern ETH_PORT_CTRL* ethPortCtrl[]; - -static INLINE MV_ULONG ethDescVirtToPhy(ETH_QUEUE_CTRL* pQueueCtrl, MV_U8* pDesc) -{ -#if defined (ETH_DESCR_IN_SRAM) - if( ethDescInSram ) - return mvSramVirtToPhy(pDesc); - else -#endif /* ETH_DESCR_IN_SRAM */ - return (pQueueCtrl->descBuf.bufPhysAddr + (pDesc - pQueueCtrl->descBuf.bufVirtPtr)); -} -/* Return port handler */ -#define mvEthPortHndlGet(port) ethPortCtrl[port] - -/* Used as WA for HW/SW race on TX */ -static INLINE int mvEthPortTxEnable(void* pPortHndl, int queue, int max_deep) -{ - int deep = 0; - MV_U32 txCurrReg, txEnReg; - ETH_TX_DESC* pTxLastDesc; - ETH_QUEUE_CTRL* pQueueCtrl; - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHndl; - - txEnReg = MV_REG_VALUE(ETH_TX_QUEUE_COMMAND_REG(pPortCtrl->portNo)); - if( (txEnReg & MV_32BIT_LE_FAST(ETH_TXQ_ENABLE_MASK)) == 0) - { - MV_REG_VALUE(ETH_TX_QUEUE_COMMAND_REG(pPortCtrl->portNo)) = pPortCtrl->portTxQueueCmdReg; - return 0; - } - - pQueueCtrl = &pPortCtrl->txQueue[queue]; - pTxLastDesc = pQueueCtrl->pCurrentDescr; - txCurrReg = MV_REG_READ(ETH_TX_CUR_DESC_PTR_REG(pPortCtrl->portNo, queue)); - if(ethDescVirtToPhy(pQueueCtrl, (MV_U8*)pTxLastDesc) == txCurrReg) - { - /* All descriptors are processed, no chance for race */ - return 0; - } - - /* Check distance betwee HW and SW location: */ - /* If distance between HW and SW pointers is less than max_deep descriptors */ - /* Race condition is possible, so wait end of TX and restart TXQ */ - while(deep < max_deep) - { - pTxLastDesc = TX_PREV_DESC_PTR(pTxLastDesc, pQueueCtrl); - if(ethDescVirtToPhy(pQueueCtrl, (MV_U8*)pTxLastDesc) == txCurrReg) - { - int count = 0; - - while( (txEnReg & MV_32BIT_LE_FAST(ETH_TXQ_ENABLE_MASK)) != 0) - { - count++; - if(count > 10000) - { - mvOsPrintf("mvEthPortTxEnable: timeout - TXQ_CMD=0x%08x\n", - MV_REG_READ(ETH_TX_QUEUE_COMMAND_REG(pPortCtrl->portNo)) ); - break; - } - txEnReg = MV_REG_VALUE(ETH_TX_QUEUE_COMMAND_REG(pPortCtrl->portNo)); - } - - MV_REG_VALUE(ETH_TX_QUEUE_COMMAND_REG(pPortCtrl->portNo)) = pPortCtrl->portTxQueueCmdReg; - return count; - } - deep++; - } - /* Distance between HW and SW pointers is more than max_deep descriptors, */ - /* So NO race condition - do nothing */ - return -1; -} - - -/* defines */ -#define ETH_CSUM_MIN_BYTE_COUNT 72 - -/* Tailgate and Kirwood have only 2K TX FIFO */ -#if (MV_ETH_VERSION == 2) || (MV_ETH_VERSION == 4) -#define ETH_CSUM_MAX_BYTE_COUNT 1600 -#else -#define ETH_CSUM_MAX_BYTE_COUNT 9*1024 -#endif /* MV_ETH_VERSION */ - -#define ETH_MV_HEADER_SIZE 2 -#define ETH_MV_TX_EN - -/* An offest in Tx descriptors to store data for buffers less than 8 Bytes */ -#define MIN_TX_BUFF_LOAD 8 -#define TX_BUF_OFFSET_IN_DESC (ETH_TX_DESC_ALIGNED_SIZE - MIN_TX_BUFF_LOAD) - -/* Default port configuration value */ -#define PORT_CONFIG_VALUE \ - ETH_DEF_RX_QUEUE_MASK(0) | \ - ETH_DEF_RX_ARP_QUEUE_MASK(0) | \ - ETH_DEF_RX_TCP_QUEUE_MASK(0) | \ - ETH_DEF_RX_UDP_QUEUE_MASK(0) | \ - ETH_DEF_RX_BPDU_QUEUE_MASK(0) | \ - ETH_RX_CHECKSUM_WITH_PSEUDO_HDR - -/* Default port extend configuration value */ -#define PORT_CONFIG_EXTEND_VALUE 0 - -#define PORT_SERIAL_CONTROL_VALUE \ - ETH_DISABLE_FC_AUTO_NEG_MASK | \ - BIT9 | \ - ETH_DO_NOT_FORCE_LINK_FAIL_MASK | \ - ETH_MAX_RX_PACKET_1552BYTE | \ - ETH_SET_FULL_DUPLEX_MASK - -#define PORT_SERIAL_CONTROL_100MB_FORCE_VALUE \ - ETH_FORCE_LINK_PASS_MASK | \ - ETH_DISABLE_DUPLEX_AUTO_NEG_MASK | \ - ETH_DISABLE_FC_AUTO_NEG_MASK | \ - BIT9 | \ - ETH_DO_NOT_FORCE_LINK_FAIL_MASK | \ - ETH_DISABLE_SPEED_AUTO_NEG_MASK | \ - ETH_SET_FULL_DUPLEX_MASK | \ - ETH_SET_MII_SPEED_100_MASK | \ - ETH_MAX_RX_PACKET_1552BYTE - - -#define PORT_SERIAL_CONTROL_1000MB_FORCE_VALUE \ - ETH_FORCE_LINK_PASS_MASK | \ - ETH_DISABLE_DUPLEX_AUTO_NEG_MASK | \ - ETH_DISABLE_FC_AUTO_NEG_MASK | \ - BIT9 | \ - ETH_DO_NOT_FORCE_LINK_FAIL_MASK | \ - ETH_DISABLE_SPEED_AUTO_NEG_MASK | \ - ETH_SET_FULL_DUPLEX_MASK | \ - ETH_SET_GMII_SPEED_1000_MASK | \ - ETH_MAX_RX_PACKET_1552BYTE - -#define PORT_SERIAL_CONTROL_SGMII_IBAN_VALUE \ - ETH_DISABLE_FC_AUTO_NEG_MASK | \ - BIT9 | \ - ETH_IN_BAND_AN_EN_MASK | \ - ETH_DO_NOT_FORCE_LINK_FAIL_MASK | \ - ETH_MAX_RX_PACKET_1552BYTE - -/* Function headers: */ -MV_VOID mvEthSetSpecialMcastTable(int portNo, int queue); -MV_STATUS mvEthArpRxQueue(void* pPortHandle, int arpQueue); -MV_STATUS mvEthUdpRxQueue(void* pPortHandle, int udpQueue); -MV_STATUS mvEthTcpRxQueue(void* pPortHandle, int tcpQueue); -MV_STATUS mvEthMacAddrGet(int portNo, unsigned char *pAddr); -MV_VOID mvEthSetOtherMcastTable(int portNo, int queue); -MV_STATUS mvEthHeaderModeSet(void* pPortHandle, MV_ETH_HEADER_MODE headerMode); -/* Interrupt Coalesting functions */ -MV_U32 mvEthRxCoalSet(void* pPortHndl, MV_U32 uSec); -MV_U32 mvEthTxCoalSet(void* pPortHndl, MV_U32 uSec); -MV_STATUS mvEthCoalGet(void* pPortHndl, MV_U32* pRxCoal, MV_U32* pTxCoal); - -/******************************************************************************/ -/* Data Flow functions */ -/******************************************************************************/ -static INLINE void mvEthPortTxRestart(void* pPortHndl) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHndl; - - MV_REG_VALUE(ETH_TX_QUEUE_COMMAND_REG(pPortCtrl->portNo)) = pPortCtrl->portTxQueueCmdReg; -} - -/* Get number of Free resources in specific TX queue */ -static INLINE int mvEthTxResourceGet(void* pPortHndl, int txQueue) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHndl; - - return (pPortCtrl->txQueue[txQueue].resource); -} - -/* Get number of Free resources in specific RX queue */ -static INLINE int mvEthRxResourceGet(void* pPortHndl, int rxQueue) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHndl; - - return (pPortCtrl->rxQueue[rxQueue].resource); -} - -static INLINE int mvEthTxQueueIsFull(void* pPortHndl, int txQueue) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHndl; - - if(pPortCtrl->txQueue[txQueue].resource == 0) - return MV_TRUE; - - return MV_FALSE; -} - -/* Get number of Free resources in specific RX queue */ -static INLINE int mvEthRxQueueIsFull(void* pPortHndl, int rxQueue) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHndl; - ETH_QUEUE_CTRL* pQueueCtrl = &pPortCtrl->rxQueue[rxQueue]; - - if( (pQueueCtrl->pUsedDescr == pQueueCtrl->pCurrentDescr) && - (pQueueCtrl->resource != 0) ) - return MV_TRUE; - - return MV_FALSE; -} - -static INLINE int mvEthTxQueueIsEmpty(void* pPortHndl, int txQueue) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHndl; - ETH_QUEUE_CTRL* pQueueCtrl = &pPortCtrl->txQueue[txQueue]; - - if( (pQueueCtrl->pUsedDescr == pQueueCtrl->pCurrentDescr) && - (pQueueCtrl->resource != 0) ) - { - return MV_TRUE; - } - return MV_FALSE; -} - -/* Get number of Free resources in specific RX queue */ -static INLINE int mvEthRxQueueIsEmpty(void* pPortHndl, int rxQueue) -{ - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pPortHndl; - - if(pPortCtrl->rxQueue[rxQueue].resource == 0) - return MV_TRUE; - - return MV_FALSE; -} - -/******************************************************************************* -* mvEthPortTx - Send an Ethernet packet -* -* DESCRIPTION: -* This routine send a given packet described by pPktInfo parameter. -* Single buffer only. -* -* INPUT: -* void* pEthPortHndl - Ethernet Port handler. -* int txQueue - Number of Tx queue. -* MV_PKT_INFO *pPktInfo - User packet to send. -* -* RETURN: -* MV_NO_RESOURCE - No enough resources to send this packet. -* MV_ERROR - Unexpected Fatal error. -* MV_OK - Packet send successfully. -* -*******************************************************************************/ -static INLINE MV_STATUS mvEthPortTx(void* pEthPortHndl, int txQueue, MV_PKT_INFO* pPktInfo) -{ - ETH_TX_DESC* pTxCurrDesc; - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pEthPortHndl; - ETH_QUEUE_CTRL* pQueueCtrl; - int portNo; - MV_BUF_INFO* pBufInfo = pPktInfo->pFrags; - -#ifdef ETH_DEBUG - if(pPortCtrl->portState != MV_ACTIVE) - return MV_BAD_STATE; -#endif /* ETH_DEBUG */ - - portNo = pPortCtrl->portNo; - pQueueCtrl = &pPortCtrl->txQueue[txQueue]; - - /* Get the Tx Desc ring indexes */ - pTxCurrDesc = pQueueCtrl->pCurrentDescr; - - /* Check if there is enough resources to send the packet */ - if(pQueueCtrl->resource == 0) - return MV_NO_RESOURCE; - - pTxCurrDesc->byteCnt = pBufInfo->dataSize; - - /* Flash Buffer */ - if(pPktInfo->pktSize != 0) - { -#ifdef MV_NETBSD - pTxCurrDesc->bufPtr = pBufInfo->bufPhysAddr; - ETH_PACKET_CACHE_FLUSH(pBufInfo->bufVirtPtr, pPktInfo->pktSize); -#else - pTxCurrDesc->bufPtr = ETH_PACKET_CACHE_FLUSH(pBufInfo->bufVirtPtr, pPktInfo->pktSize); -#endif - pPktInfo->pktSize = 0; - } - else - pTxCurrDesc->bufPtr = pBufInfo->bufPhysAddr; - - pTxCurrDesc->returnInfo = (MV_ULONG)pPktInfo; - - /* There is only one buffer in the packet */ - /* The OSG might set some bits for checksum offload, so add them to first descriptor */ - pTxCurrDesc->cmdSts = pPktInfo->status | - ETH_BUFFER_OWNED_BY_DMA | - ETH_TX_GENERATE_CRC_MASK | - ETH_TX_ENABLE_INTERRUPT_MASK | - ETH_TX_ZERO_PADDING_MASK | - ETH_TX_FIRST_DESC_MASK | - ETH_TX_LAST_DESC_MASK; - - ETH_DESCR_FLUSH_INV(pPortCtrl, pTxCurrDesc); - - pQueueCtrl->resource--; - pQueueCtrl->pCurrentDescr = TX_NEXT_DESC_PTR(pTxCurrDesc, pQueueCtrl); - - /* Apply send command */ - MV_REG_VALUE(ETH_TX_QUEUE_COMMAND_REG(portNo)) = pPortCtrl->portTxQueueCmdReg; - - return MV_OK; -} - - -/******************************************************************************* -* mvEthPortSgTx - Send an Ethernet packet -* -* DESCRIPTION: -* This routine send a given packet described by pBufInfo parameter. It -* supports transmitting of a packet spaned over multiple buffers. -* -* INPUT: -* void* pEthPortHndl - Ethernet Port handler. -* int txQueue - Number of Tx queue. -* MV_PKT_INFO *pPktInfo - User packet to send. -* -* RETURN: -* MV_NO_RESOURCE - No enough resources to send this packet. -* MV_ERROR - Unexpected Fatal error. -* MV_OK - Packet send successfully. -* -*******************************************************************************/ -static INLINE MV_STATUS mvEthPortSgTx(void* pEthPortHndl, int txQueue, MV_PKT_INFO* pPktInfo) -{ - ETH_TX_DESC* pTxFirstDesc; - ETH_TX_DESC* pTxCurrDesc; - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pEthPortHndl; - ETH_QUEUE_CTRL* pQueueCtrl; - int portNo, bufCount; - MV_BUF_INFO* pBufInfo = pPktInfo->pFrags; - MV_U8* pTxBuf; - -#ifdef ETH_DEBUG - if(pPortCtrl->portState != MV_ACTIVE) - return MV_BAD_STATE; -#endif /* ETH_DEBUG */ - - portNo = pPortCtrl->portNo; - pQueueCtrl = &pPortCtrl->txQueue[txQueue]; - - /* Get the Tx Desc ring indexes */ - pTxCurrDesc = pQueueCtrl->pCurrentDescr; - - /* Check if there is enough resources to send the packet */ - if(pQueueCtrl->resource < pPktInfo->numFrags) - return MV_NO_RESOURCE; - - /* Remember first desc */ - pTxFirstDesc = pTxCurrDesc; - - bufCount = 0; - while(MV_TRUE) - { - if(pBufInfo[bufCount].dataSize <= MIN_TX_BUFF_LOAD) - { - /* Buffers with a payload smaller than MIN_TX_BUFF_LOAD (8 bytes) must be aligned */ - /* to 64-bit boundary. Two options here: */ - /* 1) Usually, copy the payload to the reserved 8 bytes inside descriptor. */ - /* 2) In the Half duplex workaround, the reserved 8 bytes inside descriptor are used */ - /* as a pointer to the aligned buffer, copy the small payload to this buffer. */ - pTxBuf = ((MV_U8*)pTxCurrDesc)+TX_BUF_OFFSET_IN_DESC; - mvOsBCopy(pBufInfo[bufCount].bufVirtPtr, pTxBuf, pBufInfo[bufCount].dataSize); - pTxCurrDesc->bufPtr = ethDescVirtToPhy(pQueueCtrl, pTxBuf); - } - else - { - /* Flash Buffer */ -#ifdef MV_NETBSD - pTxCurrDesc->bufPtr = pBufInfo[bufCount].bufPhysAddr; - ETH_PACKET_CACHE_FLUSH(pBufInfo[bufCount].bufVirtPtr, pBufInfo[bufCount].dataSize); -#else - pTxCurrDesc->bufPtr = ETH_PACKET_CACHE_FLUSH(pBufInfo[bufCount].bufVirtPtr, pBufInfo[bufCount].dataSize); -#endif - } - - pTxCurrDesc->byteCnt = pBufInfo[bufCount].dataSize; - bufCount++; - - if(bufCount >= pPktInfo->numFrags) - break; - - if(bufCount > 1) - { - /* There is middle buffer of the packet Not First and Not Last */ - pTxCurrDesc->cmdSts = ETH_BUFFER_OWNED_BY_DMA; - ETH_DESCR_FLUSH_INV(pPortCtrl, pTxCurrDesc); - } - /* Go to next descriptor and next buffer */ - pTxCurrDesc = TX_NEXT_DESC_PTR(pTxCurrDesc, pQueueCtrl); - } - /* Set last desc with DMA ownership and interrupt enable. */ - pTxCurrDesc->returnInfo = (MV_ULONG)pPktInfo; - if(bufCount == 1) - { - /* There is only one buffer in the packet */ - /* The OSG might set some bits for checksum offload, so add them to first descriptor */ - pTxCurrDesc->cmdSts = pPktInfo->status | - ETH_BUFFER_OWNED_BY_DMA | - ETH_TX_GENERATE_CRC_MASK | - ETH_TX_ENABLE_INTERRUPT_MASK | - ETH_TX_ZERO_PADDING_MASK | - ETH_TX_FIRST_DESC_MASK | - ETH_TX_LAST_DESC_MASK; - - ETH_DESCR_FLUSH_INV(pPortCtrl, pTxCurrDesc); - } - else - { - /* Last but not First */ - pTxCurrDesc->cmdSts = ETH_BUFFER_OWNED_BY_DMA | - ETH_TX_ENABLE_INTERRUPT_MASK | - ETH_TX_ZERO_PADDING_MASK | - ETH_TX_LAST_DESC_MASK; - - ETH_DESCR_FLUSH_INV(pPortCtrl, pTxCurrDesc); - - /* Update First when more than one buffer in the packet */ - /* The OSG might set some bits for checksum offload, so add them to first descriptor */ - pTxFirstDesc->cmdSts = pPktInfo->status | - ETH_BUFFER_OWNED_BY_DMA | - ETH_TX_GENERATE_CRC_MASK | - ETH_TX_FIRST_DESC_MASK; - - ETH_DESCR_FLUSH_INV(pPortCtrl, pTxFirstDesc); - } - /* Update txQueue state */ - pQueueCtrl->resource -= bufCount; - pQueueCtrl->pCurrentDescr = TX_NEXT_DESC_PTR(pTxCurrDesc, pQueueCtrl); - - /* Apply send command */ - MV_REG_VALUE(ETH_TX_QUEUE_COMMAND_REG(portNo)) = pPortCtrl->portTxQueueCmdReg; - - return MV_OK; -} - -/******************************************************************************* -* mvEthPortTxDone - Free all used Tx descriptors and mBlks. -* -* DESCRIPTION: -* This routine returns the transmitted packet information to the caller. -* -* INPUT: -* void* pEthPortHndl - Ethernet Port handler. -* int txQueue - Number of Tx queue. -* -* OUTPUT: -* MV_PKT_INFO *pPktInfo - Pointer to packet was sent. -* -* RETURN: -* MV_NOT_FOUND - No transmitted packets to return. Transmit in progress. -* MV_EMPTY - No transmitted packets to return. TX Queue is empty. -* MV_ERROR - Unexpected Fatal error. -* MV_OK - There is transmitted packet in the queue, -* 'pPktInfo' filled with relevant information. -* -*******************************************************************************/ -static INLINE MV_PKT_INFO* mvEthPortTxDone(void* pEthPortHndl, int txQueue) -{ - ETH_TX_DESC* pTxCurrDesc; - ETH_TX_DESC* pTxUsedDesc; - ETH_QUEUE_CTRL* pQueueCtrl; - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pEthPortHndl; - MV_PKT_INFO* pPktInfo; - MV_U32 commandStatus; - - pQueueCtrl = &pPortCtrl->txQueue[txQueue]; - - pTxUsedDesc = pQueueCtrl->pUsedDescr; - pTxCurrDesc = pQueueCtrl->pCurrentDescr; - - while(MV_TRUE) - { - /* No more used descriptors */ - commandStatus = pTxUsedDesc->cmdSts; - if (commandStatus & (ETH_BUFFER_OWNED_BY_DMA)) - { - ETH_DESCR_INV(pPortCtrl, pTxUsedDesc); - return NULL; - } - if( (pTxUsedDesc == pTxCurrDesc) && - (pQueueCtrl->resource != 0) ) - { - return NULL; - } - pQueueCtrl->resource++; - pQueueCtrl->pUsedDescr = TX_NEXT_DESC_PTR(pTxUsedDesc, pQueueCtrl); - if(commandStatus & (ETH_TX_LAST_DESC_MASK)) - { - pPktInfo = (MV_PKT_INFO*)pTxUsedDesc->returnInfo; - pPktInfo->status = commandStatus; - return pPktInfo; - } - pTxUsedDesc = pQueueCtrl->pUsedDescr; - } -} - -/******************************************************************************* -* mvEthPortRx - Get new received packets from Rx queue. -* -* DESCRIPTION: -* This routine returns the received data to the caller. There is no -* data copying during routine operation. All information is returned -* using pointer to packet information struct passed from the caller. -* -* INPUT: -* void* pEthPortHndl - Ethernet Port handler. -* int rxQueue - Number of Rx queue. -* -* OUTPUT: -* MV_PKT_INFO *pPktInfo - Pointer to received packet. -* -* RETURN: -* MV_NO_RESOURCE - No free resources in RX queue. -* MV_ERROR - Unexpected Fatal error. -* MV_OK - New packet received and 'pBufInfo' structure filled -* with relevant information. -* -*******************************************************************************/ -static INLINE MV_PKT_INFO* mvEthPortRx(void* pEthPortHndl, int rxQueue) -{ - ETH_RX_DESC *pRxCurrDesc; - MV_U32 commandStatus; - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pEthPortHndl; - ETH_QUEUE_CTRL* pQueueCtrl; - MV_PKT_INFO* pPktInfo; - - pQueueCtrl = &(pPortCtrl->rxQueue[rxQueue]); - - /* Check resources */ - if(pQueueCtrl->resource == 0) - { - mvOsPrintf("ethPortRx: no more resources\n"); - return NULL; - } - while(MV_TRUE) - { - /* Get the Rx Desc ring 'curr and 'used' indexes */ - pRxCurrDesc = pQueueCtrl->pCurrentDescr; - - commandStatus = pRxCurrDesc->cmdSts; - if (commandStatus & (ETH_BUFFER_OWNED_BY_DMA)) - { - /* Nothing to receive... */ - ETH_DESCR_INV(pPortCtrl, pRxCurrDesc); - return NULL; - } - - /* Valid RX only if FIRST and LAST bits are set */ - if( (commandStatus & (ETH_RX_LAST_DESC_MASK | ETH_RX_FIRST_DESC_MASK)) == - (ETH_RX_LAST_DESC_MASK | ETH_RX_FIRST_DESC_MASK) ) - { - pPktInfo = (MV_PKT_INFO*)pRxCurrDesc->returnInfo; - pPktInfo->pFrags->dataSize = pRxCurrDesc->byteCnt - 4; - pPktInfo->status = commandStatus; - pPktInfo->fragIP = pRxCurrDesc->bufSize & ETH_RX_IP_FRAGMENTED_FRAME_MASK; - - pQueueCtrl->resource--; - /* Update 'curr' in data structure */ - pQueueCtrl->pCurrentDescr = RX_NEXT_DESC_PTR(pRxCurrDesc, pQueueCtrl); - -#ifdef INCLUDE_SYNC_BARR - mvCpuIfSyncBarr(DRAM_TARGET); -#endif - return pPktInfo; - } - else - { - ETH_RX_DESC* pRxUsedDesc = pQueueCtrl->pUsedDescr; - -#ifdef ETH_DEBUG - mvOsPrintf("ethDrv: Unexpected Jumbo frame: " - "status=0x%08x, byteCnt=%d, pData=0x%x\n", - commandStatus, pRxCurrDesc->byteCnt, pRxCurrDesc->bufPtr); -#endif /* ETH_DEBUG */ - - /* move buffer from pCurrentDescr position to pUsedDescr position */ - pRxUsedDesc->bufPtr = pRxCurrDesc->bufPtr; - pRxUsedDesc->returnInfo = pRxCurrDesc->returnInfo; - pRxUsedDesc->bufSize = pRxCurrDesc->bufSize & ETH_RX_BUFFER_MASK; - - /* Return the descriptor to DMA ownership */ - pRxUsedDesc->cmdSts = ETH_BUFFER_OWNED_BY_DMA | - ETH_RX_ENABLE_INTERRUPT_MASK; - - /* Flush descriptor and CPU pipe */ - ETH_DESCR_FLUSH_INV(pPortCtrl, pRxUsedDesc); - - /* Move the used descriptor pointer to the next descriptor */ - pQueueCtrl->pUsedDescr = RX_NEXT_DESC_PTR(pRxUsedDesc, pQueueCtrl); - pQueueCtrl->pCurrentDescr = RX_NEXT_DESC_PTR(pRxCurrDesc, pQueueCtrl); - } - } -} - -/******************************************************************************* -* mvEthPortRxDone - Returns a Rx buffer back to the Rx ring. -* -* DESCRIPTION: -* This routine returns a Rx buffer back to the Rx ring. -* -* INPUT: -* void* pEthPortHndl - Ethernet Port handler. -* int rxQueue - Number of Rx queue. -* MV_PKT_INFO *pPktInfo - Pointer to received packet. -* -* RETURN: -* MV_ERROR - Unexpected Fatal error. -* MV_OUT_OF_RANGE - RX queue is already FULL, so this buffer can't be -* returned to this queue. -* MV_FULL - Buffer returned successfully and RX queue became full. -* More buffers should not be returned at the time. -* MV_OK - Buffer returned successfully and there are more free -* places in the queue. -* -*******************************************************************************/ -static INLINE MV_STATUS mvEthPortRxDone(void* pEthPortHndl, int rxQueue, MV_PKT_INFO *pPktInfo) -{ - ETH_RX_DESC* pRxUsedDesc; - ETH_QUEUE_CTRL* pQueueCtrl; - ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)pEthPortHndl; - - pQueueCtrl = &pPortCtrl->rxQueue[rxQueue]; - - /* Get 'used' Rx descriptor */ - pRxUsedDesc = pQueueCtrl->pUsedDescr; - - /* Check that ring is not FULL */ - if( (pQueueCtrl->pUsedDescr == pQueueCtrl->pCurrentDescr) && - (pQueueCtrl->resource != 0) ) - { - mvOsPrintf("%s %d: out of range Error resource=%d, curr=%p, used=%p\n", - __FUNCTION__, pPortCtrl->portNo, pQueueCtrl->resource, - pQueueCtrl->pCurrentDescr, pQueueCtrl->pUsedDescr); - return MV_OUT_OF_RANGE; - } - - pRxUsedDesc->bufPtr = pPktInfo->pFrags->bufPhysAddr; - pRxUsedDesc->returnInfo = (MV_ULONG)pPktInfo; - pRxUsedDesc->bufSize = pPktInfo->pFrags->bufSize & ETH_RX_BUFFER_MASK; - - /* Invalidate data buffer accordingly with pktSize */ - if(pPktInfo->pktSize != 0) - { - ETH_PACKET_CACHE_INVALIDATE(pPktInfo->pFrags->bufVirtPtr, pPktInfo->pktSize); - pPktInfo->pktSize = 0; - } - - /* Return the descriptor to DMA ownership */ - pRxUsedDesc->cmdSts = ETH_BUFFER_OWNED_BY_DMA | ETH_RX_ENABLE_INTERRUPT_MASK; - - /* Flush descriptor and CPU pipe */ - ETH_DESCR_FLUSH_INV(pPortCtrl, pRxUsedDesc); - - pQueueCtrl->resource++; - - /* Move the used descriptor pointer to the next descriptor */ - pQueueCtrl->pUsedDescr = RX_NEXT_DESC_PTR(pRxUsedDesc, pQueueCtrl); - - /* If ring became Full return MV_FULL */ - if(pQueueCtrl->pUsedDescr == pQueueCtrl->pCurrentDescr) - return MV_FULL; - - return MV_OK; -} - - -#endif /* __mvEthGbe_h__ */ - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/eth/gbe/mvEthRegs.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/eth/gbe/mvEthRegs.h deleted file mode 100644 index 7b9f052..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/eth/gbe/mvEthRegs.h +++ /dev/null @@ -1,700 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -#ifndef __INCmvEthRegsh -#define __INCmvEthRegsh - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include "ctrlEnv/mvCtrlEnvSpec.h" - -/****************************************/ -/* Ethernet Unit Registers */ -/****************************************/ -#define ETH_REG_BASE MV_ETH_REG_BASE - -#define ETH_PHY_ADDR_REG(port) (ETH_REG_BASE(port) + 0x000) -#define ETH_SMI_REG(port) (ETH_REG_BASE(port) + 0x004) -#define ETH_UNIT_DEF_ADDR_REG(port) (ETH_REG_BASE(port) + 0x008) -#define ETH_UNIT_DEF_ID_REG(port) (ETH_REG_BASE(port) + 0x00c) -#define ETH_UNIT_RESERVED(port) (ETH_REG_BASE(port) + 0x014) -#define ETH_UNIT_INTR_CAUSE_REG(port) (ETH_REG_BASE(port) + 0x080) -#define ETH_UNIT_INTR_MASK_REG(port) (ETH_REG_BASE(port) + 0x084) - - -#define ETH_UNIT_ERROR_ADDR_REG(port) (ETH_REG_BASE(port) + 0x094) -#define ETH_UNIT_INT_ADDR_ERROR_REG(port) (ETH_REG_BASE(port) + 0x098) -#define ETH_UNIT_CONTROL_REG(port) (ETH_REG_BASE(port) + 0x0B0) - -#define ETH_PORT_CONFIG_REG(port) (ETH_REG_BASE(port) + 0x400) -#define ETH_PORT_CONFIG_EXTEND_REG(port) (ETH_REG_BASE(port) + 0x404) -#define ETH_MII_SERIAL_PARAM_REG(port) (ETH_REG_BASE(port) + 0x408) -#define ETH_GMII_SERIAL_PARAM_REG(port) (ETH_REG_BASE(port) + 0x40c) -#define ETH_VLAN_ETHER_TYPE_REG(port) (ETH_REG_BASE(port) + 0x410) -#define ETH_MAC_ADDR_LOW_REG(port) (ETH_REG_BASE(port) + 0x414) -#define ETH_MAC_ADDR_HIGH_REG(port) (ETH_REG_BASE(port) + 0x418) -#define ETH_SDMA_CONFIG_REG(port) (ETH_REG_BASE(port) + 0x41c) -#define ETH_DIFF_SERV_PRIO_REG(port, code) (ETH_REG_BASE(port) + 0x420 + ((code)<<2)) -#define ETH_PORT_SERIAL_CTRL_REG(port) (ETH_REG_BASE(port) + 0x43c) -#define ETH_VLAN_TAG_TO_PRIO_REG(port) (ETH_REG_BASE(port) + 0x440) -#define ETH_PORT_STATUS_REG(port) (ETH_REG_BASE(port) + 0x444) - -#define ETH_RX_QUEUE_COMMAND_REG(port) (ETH_REG_BASE(port) + 0x680) -#define ETH_TX_QUEUE_COMMAND_REG(port) (ETH_REG_BASE(port) + 0x448) - -#define ETH_PORT_SERIAL_CTRL_1_REG(port) (ETH_REG_BASE(port) + 0x44c) -#define ETH_PORT_STATUS_1_REG(port) (ETH_REG_BASE(port) + 0x450) -#define ETH_PORT_MARVELL_HEADER_REG(port) (ETH_REG_BASE(port) + 0x454) -#define ETH_PORT_FIFO_PARAMS_REG(port) (ETH_REG_BASE(port) + 0x458) -#define ETH_MAX_TOKEN_BUCKET_SIZE_REG(port) (ETH_REG_BASE(port) + 0x45c) -#define ETH_INTR_CAUSE_REG(port) (ETH_REG_BASE(port) + 0x460) -#define ETH_INTR_CAUSE_EXT_REG(port) (ETH_REG_BASE(port) + 0x464) -#define ETH_INTR_MASK_REG(port) (ETH_REG_BASE(port) + 0x468) -#define ETH_INTR_MASK_EXT_REG(port) (ETH_REG_BASE(port) + 0x46c) -#define ETH_TX_FIFO_URGENT_THRESH_REG(port) (ETH_REG_BASE(port) + 0x474) -#define ETH_RX_MINIMAL_FRAME_SIZE_REG(port) (ETH_REG_BASE(port) + 0x47c) -#define ETH_RX_DISCARD_PKTS_CNTR_REG(port) (ETH_REG_BASE(port) + 0x484) -#define ETH_RX_OVERRUN_PKTS_CNTR_REG(port) (ETH_REG_BASE(port) + 0x488) -#define ETH_INTERNAL_ADDR_ERROR_REG(port) (ETH_REG_BASE(port) + 0x494) -#define ETH_TX_FIXED_PRIO_CFG_REG(port) (ETH_REG_BASE(port) + 0x4dc) -#define ETH_TX_TOKEN_RATE_CFG_REG(port) (ETH_REG_BASE(port) + 0x4e0) -#define ETH_TX_QUEUE_COMMAND1_REG(port) (ETH_REG_BASE(port) + 0x4e4) -#define ETH_MAX_TRANSMIT_UNIT_REG(port) (ETH_REG_BASE(port) + 0x4e8) -#define ETH_TX_TOKEN_BUCKET_SIZE_REG(port) (ETH_REG_BASE(port) + 0x4ec) -#define ETH_TX_TOKEN_BUCKET_COUNT_REG(port) (ETH_REG_BASE(port) + 0x780) -#define ETH_RX_DESCR_STAT_CMD_REG(port, q) (ETH_REG_BASE(port) + 0x600 + ((q)<<4)) -#define ETH_RX_BYTE_COUNT_REG(port, q) (ETH_REG_BASE(port) + 0x604 + ((q)<<4)) -#define ETH_RX_BUF_PTR_REG(port, q) (ETH_REG_BASE(port) + 0x608 + ((q)<<4)) -#define ETH_RX_CUR_DESC_PTR_REG(port, q) (ETH_REG_BASE(port) + 0x60c + ((q)<<4)) -#define ETH_TX_CUR_DESC_PTR_REG(port, q) (ETH_REG_BASE(port) + 0x6c0 + ((q)<<2)) - -#define ETH_TXQ_TOKEN_COUNT_REG(port, q) (ETH_REG_BASE(port) + 0x700 + ((q)<<4)) -#define ETH_TXQ_TOKEN_CFG_REG(port, q) (ETH_REG_BASE(port) + 0x704 + ((q)<<4)) -#define ETH_TXQ_ARBITER_CFG_REG(port, q) (ETH_REG_BASE(port) + 0x708 + ((q)<<4)) - -#if (MV_ETH_VERSION >= 4) -#define ETH_TXQ_CMD_1_REG(port) (ETH_REG_BASE(port) + 0x4E4) -#define ETH_EJP_TX_HI_IPG_REG(port) (ETH_REG_BASE(port) + 0x7A8) -#define ETH_EJP_TX_LO_IPG_REG(port) (ETH_REG_BASE(port) + 0x7B8) -#define ETH_EJP_HI_TKN_LO_PKT_REG(port) (ETH_REG_BASE(port) + 0x7C0) -#define ETH_EJP_HI_TKN_ASYNC_PKT_REG(port) (ETH_REG_BASE(port) + 0x7C4) -#define ETH_EJP_LO_TKN_ASYNC_PKT_REG(port) (ETH_REG_BASE(port) + 0x7C8) -#define ETH_EJP_TX_SPEED_REG(port) (ETH_REG_BASE(port) + 0x7D0) -#endif /* MV_ETH_VERSION >= 4 */ - -#define ETH_MIB_COUNTERS_BASE(port) (ETH_REG_BASE(port) + 0x1000) -#define ETH_DA_FILTER_SPEC_MCAST_BASE(port) (ETH_REG_BASE(port) + 0x1400) -#define ETH_DA_FILTER_OTH_MCAST_BASE(port) (ETH_REG_BASE(port) + 0x1500) -#define ETH_DA_FILTER_UCAST_BASE(port) (ETH_REG_BASE(port) + 0x1600) - -/* Phy address register definitions */ -#define ETH_PHY_ADDR_OFFS 0 -#define ETH_PHY_ADDR_MASK (0x1f <<ETH_PHY_ADDR_OFFS) - -/* MIB Counters register definitions */ -#define ETH_MIB_GOOD_OCTETS_RECEIVED_LOW 0x0 -#define ETH_MIB_GOOD_OCTETS_RECEIVED_HIGH 0x4 -#define ETH_MIB_BAD_OCTETS_RECEIVED 0x8 -#define ETH_MIB_INTERNAL_MAC_TRANSMIT_ERR 0xc -#define ETH_MIB_GOOD_FRAMES_RECEIVED 0x10 -#define ETH_MIB_BAD_FRAMES_RECEIVED 0x14 -#define ETH_MIB_BROADCAST_FRAMES_RECEIVED 0x18 -#define ETH_MIB_MULTICAST_FRAMES_RECEIVED 0x1c -#define ETH_MIB_FRAMES_64_OCTETS 0x20 -#define ETH_MIB_FRAMES_65_TO_127_OCTETS 0x24 -#define ETH_MIB_FRAMES_128_TO_255_OCTETS 0x28 -#define ETH_MIB_FRAMES_256_TO_511_OCTETS 0x2c -#define ETH_MIB_FRAMES_512_TO_1023_OCTETS 0x30 -#define ETH_MIB_FRAMES_1024_TO_MAX_OCTETS 0x34 -#define ETH_MIB_GOOD_OCTETS_SENT_LOW 0x38 -#define ETH_MIB_GOOD_OCTETS_SENT_HIGH 0x3c -#define ETH_MIB_GOOD_FRAMES_SENT 0x40 -#define ETH_MIB_EXCESSIVE_COLLISION 0x44 -#define ETH_MIB_MULTICAST_FRAMES_SENT 0x48 -#define ETH_MIB_BROADCAST_FRAMES_SENT 0x4c -#define ETH_MIB_UNREC_MAC_CONTROL_RECEIVED 0x50 -#define ETH_MIB_FC_SENT 0x54 -#define ETH_MIB_GOOD_FC_RECEIVED 0x58 -#define ETH_MIB_BAD_FC_RECEIVED 0x5c -#define ETH_MIB_UNDERSIZE_RECEIVED 0x60 -#define ETH_MIB_FRAGMENTS_RECEIVED 0x64 -#define ETH_MIB_OVERSIZE_RECEIVED 0x68 -#define ETH_MIB_JABBER_RECEIVED 0x6c -#define ETH_MIB_MAC_RECEIVE_ERROR 0x70 -#define ETH_MIB_BAD_CRC_EVENT 0x74 -#define ETH_MIB_COLLISION 0x78 -#define ETH_MIB_LATE_COLLISION 0x7c - - -/****************************************/ -/* Ethernet Unit Register BITs */ -/****************************************/ - -#define ETH_RXQ_ENABLE_OFFSET 0 -#define ETH_RXQ_ENABLE_MASK (0x000000FF << ETH_RXQ_ENABLE_OFFSET) - -#define ETH_RXQ_DISABLE_OFFSET 8 -#define ETH_RXQ_DISABLE_MASK (0x000000FF << ETH_RXQ_DISABLE_OFFSET) - -/***** BITs of Transmit Queue Command (TQC) register *****/ -#define ETH_TXQ_ENABLE_OFFSET 0 -#define ETH_TXQ_ENABLE_MASK (0x000000FF << ETH_TXQ_ENABLE_OFFSET) - -#define ETH_TXQ_DISABLE_OFFSET 8 -#define ETH_TXQ_DISABLE_MASK (0x000000FF << ETH_TXQ_DISABLE_OFFSET) - -#if (MV_ETH_VERSION >= 4) -#define ETH_TX_EJP_RESET_BIT 0 -#define ETH_TX_EJP_RESET_MASK (1 << ETH_TX_EJP_RESET_BIT) - -#define ETH_TX_EJP_ENABLE_BIT 2 -#define ETH_TX_EJP_ENABLE_MASK (1 << ETH_TX_EJP_ENABLE_BIT) - -#define ETH_TX_LEGACY_WRR_BIT 3 -#define ETH_TX_LEGACY_WRR_MASK (1 << ETH_TX_LEGACY_WRR_BIT) -#endif /* (MV_ETH_VERSION >= 4) */ - -/***** BITs of Ethernet Port Status reg (PSR) *****/ -#define ETH_LINK_UP_BIT 1 -#define ETH_LINK_UP_MASK (1<<ETH_LINK_UP_BIT) - -#define ETH_FULL_DUPLEX_BIT 2 -#define ETH_FULL_DUPLEX_MASK (1<<ETH_FULL_DUPLEX_BIT) - -#define ETH_ENABLE_RCV_FLOW_CTRL_BIT 3 -#define ETH_ENABLE_RCV_FLOW_CTRL_MASK (1<<ETH_ENABLE_RCV_FLOW_CTRL_BIT) - -#define ETH_GMII_SPEED_1000_BIT 4 -#define ETH_GMII_SPEED_1000_MASK (1<<ETH_GMII_SPEED_1000_BIT) - -#define ETH_MII_SPEED_100_BIT 5 -#define ETH_MII_SPEED_100_MASK (1<<ETH_MII_SPEED_100_BIT) - -#define ETH_TX_IN_PROGRESS_BIT 7 -#define ETH_TX_IN_PROGRESS_MASK (1<<ETH_TX_IN_PROGRESS_BIT) - -#define ETH_TX_FIFO_EMPTY_BIT 10 -#define ETH_TX_FIFO_EMPTY_MASK (1<<ETH_TX_FIFO_EMPTY_BIT) - -/***** BITs of Ethernet Port Status 1 reg (PS1R) *****/ -#define ETH_AUTO_NEG_DONE_BIT 4 -#define ETH_AUTO_NEG_DONE_MASK (1<<ETH_AUTO_NEG_DONE_BIT) - -#define ETH_SERDES_PLL_LOCKED_BIT 6 -#define ETH_SERDES_PLL_LOCKED_MASK (1<<ETH_SERDES_PLL_LOCKED_BIT) - -/***** BITs of Port Configuration reg (PxCR) *****/ -#define ETH_UNICAST_PROMISCUOUS_MODE_BIT 0 -#define ETH_UNICAST_PROMISCUOUS_MODE_MASK (1<<ETH_UNICAST_PROMISCUOUS_MODE_BIT) - -#define ETH_DEF_RX_QUEUE_OFFSET 1 -#define ETH_DEF_RX_QUEUE_ALL_MASK (0x7<<ETH_DEF_RX_QUEUE_OFFSET) -#define ETH_DEF_RX_QUEUE_MASK(queue) ((queue)<<ETH_DEF_RX_QUEUE_OFFSET) - -#define ETH_DEF_RX_ARP_QUEUE_OFFSET 4 -#define ETH_DEF_RX_ARP_QUEUE_ALL_MASK (0x7<<ETH_DEF_RX_ARP_QUEUE_OFFSET) -#define ETH_DEF_RX_ARP_QUEUE_MASK(queue) ((queue)<<ETH_DEF_RX_ARP_QUEUE_OFFSET) - -#define ETH_REJECT_NOT_IP_ARP_BCAST_BIT 7 -#define ETH_REJECT_NOT_IP_ARP_BCAST_MASK (1<<ETH_REJECT_NOT_IP_ARP_BCAST_BIT) - -#define ETH_REJECT_IP_BCAST_BIT 8 -#define ETH_REJECT_IP_BCAST_MASK (1<<ETH_REJECT_IP_BCAST_BIT) - -#define ETH_REJECT_ARP_BCAST_BIT 9 -#define ETH_REJECT_ARP_BCAST_MASK (1<<ETH_REJECT_ARP_BCAST_BIT) - -#define ETH_TX_NO_SET_ERROR_SUMMARY_BIT 12 -#define ETH_TX_NO_SET_ERROR_SUMMARY_MASK (1<<ETH_TX_NO_SET_ERROR_SUMMARY_BIT) - -#define ETH_CAPTURE_TCP_FRAMES_ENABLE_BIT 14 -#define ETH_CAPTURE_TCP_FRAMES_ENABLE_MASK (1<<ETH_CAPTURE_TCP_FRAMES_ENABLE_BIT) - -#define ETH_CAPTURE_UDP_FRAMES_ENABLE_BIT 15 -#define ETH_CAPTURE_UDP_FRAMES_ENABLE_MASK (1<<ETH_CAPTURE_UDP_FRAMES_ENABLE_BIT) - -#define ETH_DEF_RX_TCP_QUEUE_OFFSET 16 -#define ETH_DEF_RX_TCP_QUEUE_ALL_MASK (0x7<<ETH_DEF_RX_TCP_QUEUE_OFFSET) -#define ETH_DEF_RX_TCP_QUEUE_MASK(queue) ((queue)<<ETH_DEF_RX_TCP_QUEUE_OFFSET) - -#define ETH_DEF_RX_UDP_QUEUE_OFFSET 19 -#define ETH_DEF_RX_UDP_QUEUE_ALL_MASK (0x7<<ETH_DEF_RX_UDP_QUEUE_OFFSET) -#define ETH_DEF_RX_UDP_QUEUE_MASK(queue) ((queue)<<ETH_DEF_RX_UDP_QUEUE_OFFSET) - -#define ETH_DEF_RX_BPDU_QUEUE_OFFSET 22 -#define ETH_DEF_RX_BPDU_QUEUE_ALL_MASK (0x7<<ETH_DEF_RX_BPDU_QUEUE_OFFSET) -#define ETH_DEF_RX_BPDU_QUEUE_MASK(queue) ((queue)<<ETH_DEF_RX_BPDU_QUEUE_OFFSET) - -#define ETH_RX_CHECKSUM_MODE_OFFSET 25 -#define ETH_RX_CHECKSUM_NO_PSEUDO_HDR (0<<ETH_RX_CHECKSUM_MODE_OFFSET) -#define ETH_RX_CHECKSUM_WITH_PSEUDO_HDR (1<<ETH_RX_CHECKSUM_MODE_OFFSET) - -/***** BITs of Port Configuration Extend reg (PxCXR) *****/ -#define ETH_CAPTURE_SPAN_BPDU_ENABLE_BIT 1 -#define ETH_CAPTURE_SPAN_BPDU_ENABLE_MASK (1<<ETH_CAPTURE_SPAN_BPDU_ENABLE_BIT) - -#define ETH_TX_DISABLE_GEN_CRC_BIT 3 -#define ETH_TX_DISABLE_GEN_CRC_MASK (1<<ETH_TX_DISABLE_GEN_CRC_BIT) - -/***** BITs of Tx/Rx queue command reg (RQCR/TQCR) *****/ -#define ETH_QUEUE_ENABLE_OFFSET 0 -#define ETH_QUEUE_ENABLE_ALL_MASK (0xFF<<ETH_QUEUE_ENABLE_OFFSET) -#define ETH_QUEUE_ENABLE_MASK(queue) (1<<((queue)+ETH_QUEUE_ENABLE_OFFSET)) - -#define ETH_QUEUE_DISABLE_OFFSET 8 -#define ETH_QUEUE_DISABLE_ALL_MASK (0xFF<<ETH_QUEUE_DISABLE_OFFSET) -#define ETH_QUEUE_DISABLE_MASK(queue) (1<<((queue)+ETH_QUEUE_DISABLE_OFFSET)) - - -/***** BITs of Port Sdma Configuration reg (SDCR) *****/ -#define ETH_RX_FRAME_INTERRUPT_BIT 0 -#define ETH_RX_FRAME_INTERRUPT_MASK (1<<ETH_RX_FRAME_INTERRUPT_BIT) - -#define ETH_BURST_SIZE_1_64BIT_VALUE 0 -#define ETH_BURST_SIZE_2_64BIT_VALUE 1 -#define ETH_BURST_SIZE_4_64BIT_VALUE 2 -#define ETH_BURST_SIZE_8_64BIT_VALUE 3 -#define ETH_BURST_SIZE_16_64BIT_VALUE 4 - -#define ETH_RX_BURST_SIZE_OFFSET 1 -#define ETH_RX_BURST_SIZE_ALL_MASK (0x7<<ETH_RX_BURST_SIZE_OFFSET) -#define ETH_RX_BURST_SIZE_MASK(burst) ((burst)<<ETH_RX_BURST_SIZE_OFFSET) - -#define ETH_RX_NO_DATA_SWAP_BIT 4 -#define ETH_RX_NO_DATA_SWAP_MASK (1<<ETH_RX_NO_DATA_SWAP_BIT) -#define ETH_RX_DATA_SWAP_MASK (0<<ETH_RX_NO_DATA_SWAP_BIT) - -#define ETH_TX_NO_DATA_SWAP_BIT 5 -#define ETH_TX_NO_DATA_SWAP_MASK (1<<ETH_TX_NO_DATA_SWAP_BIT) -#define ETH_TX_DATA_SWAP_MASK (0<<ETH_TX_NO_DATA_SWAP_BIT) - -#define ETH_DESC_SWAP_BIT 6 -#define ETH_DESC_SWAP_MASK (1<<ETH_DESC_SWAP_BIT) -#define ETH_NO_DESC_SWAP_MASK (0<<ETH_DESC_SWAP_BIT) - -#define ETH_RX_INTR_COAL_OFFSET 7 -#define ETH_RX_INTR_COAL_ALL_MASK (0x3fff<<ETH_RX_INTR_COAL_OFFSET) -#define ETH_RX_INTR_COAL_MASK(value) (((value)<<ETH_RX_INTR_COAL_OFFSET) \ - & ETH_RX_INTR_COAL_ALL_MASK) - -#define ETH_TX_BURST_SIZE_OFFSET 22 -#define ETH_TX_BURST_SIZE_ALL_MASK (0x7<<ETH_TX_BURST_SIZE_OFFSET) -#define ETH_TX_BURST_SIZE_MASK(burst) ((burst)<<ETH_TX_BURST_SIZE_OFFSET) - -#define ETH_RX_INTR_COAL_MSB_BIT 25 -#define ETH_RX_INTR_COAL_MSB_MASK (1<<ETH_RX_INTR_COAL_MSB_BIT) - -/* BITs Port #x Tx FIFO Urgent Threshold (PxTFUT) */ -#define ETH_TX_INTR_COAL_OFFSET 4 -#define ETH_TX_INTR_COAL_ALL_MASK (0x3fff << ETH_TX_INTR_COAL_OFFSET) -#define ETH_TX_INTR_COAL_MASK(value) (((value) << ETH_TX_INTR_COAL_OFFSET) \ - & ETH_TX_INTR_COAL_ALL_MASK) - -/* BITs of Port Serial Control reg (PSCR) */ -#define ETH_PORT_ENABLE_BIT 0 -#define ETH_PORT_ENABLE_MASK (1<<ETH_PORT_ENABLE_BIT) - -#define ETH_FORCE_LINK_PASS_BIT 1 -#define ETH_FORCE_LINK_PASS_MASK (1<<ETH_FORCE_LINK_PASS_BIT) - -#define ETH_DISABLE_DUPLEX_AUTO_NEG_BIT 2 -#define ETH_DISABLE_DUPLEX_AUTO_NEG_MASK (1<<ETH_DISABLE_DUPLEX_AUTO_NEG_BIT) - -#define ETH_DISABLE_FC_AUTO_NEG_BIT 3 -#define ETH_DISABLE_FC_AUTO_NEG_MASK (1<<ETH_DISABLE_FC_AUTO_NEG_BIT) - -#define ETH_ADVERTISE_SYM_FC_BIT 4 -#define ETH_ADVERTISE_SYM_FC_MASK (1<<ETH_ADVERTISE_SYM_FC_BIT) - -#define ETH_TX_FC_MODE_OFFSET 5 -#define ETH_TX_FC_MODE_MASK (3<<ETH_TX_FC_MODE_OFFSET) -#define ETH_TX_FC_NO_PAUSE (0<<ETH_TX_FC_MODE_OFFSET) -#define ETH_TX_FC_SEND_PAUSE (1<<ETH_TX_FC_MODE_OFFSET) - -#define ETH_TX_BP_MODE_OFFSET 7 -#define ETH_TX_BP_MODE_MASK (3<<ETH_TX_BP_MODE_OFFSET) -#define ETH_TX_BP_NO_JAM (0<<ETH_TX_BP_MODE_OFFSET) -#define ETH_TX_BP_SEND_JAM (1<<ETH_TX_BP_MODE_OFFSET) - -#define ETH_DO_NOT_FORCE_LINK_FAIL_BIT 10 -#define ETH_DO_NOT_FORCE_LINK_FAIL_MASK (1<<ETH_DO_NOT_FORCE_LINK_FAIL_BIT) - -#define ETH_RETRANSMIT_FOREVER_BIT 11 -#define ETH_RETRANSMIT_FOREVER_MASK (1<<ETH_RETRANSMIT_FOREVER_BIT) - -#define ETH_DISABLE_SPEED_AUTO_NEG_BIT 13 -#define ETH_DISABLE_SPEED_AUTO_NEG_MASK (1<<ETH_DISABLE_SPEED_AUTO_NEG_BIT) - -#define ETH_DTE_ADVERT_BIT 14 -#define ETH_DTE_ADVERT_MASK (1<<ETH_DTE_ADVERT_BIT) - -#define ETH_MII_PHY_MODE_BIT 15 -#define ETH_MII_PHY_MODE_MAC (0<<ETH_MII_PHY_MODE_BIT) -#define ETH_MII_PHY_MODE_PHY (1<<ETH_MII_PHY_MODE_BIT) - -#define ETH_MII_SOURCE_SYNCH_BIT 16 -#define ETH_MII_STANDARD_SYNCH (0<<ETH_MII_SOURCE_SYNCH_BIT) -#define ETH_MII_400Mbps_SYNCH (1<<ETH_MII_SOURCE_CLK_BIT) - -#define ETH_MAX_RX_PACKET_SIZE_OFFSET 17 -#define ETH_MAX_RX_PACKET_SIZE_MASK (7<<ETH_MAX_RX_PACKET_SIZE_OFFSET) -#define ETH_MAX_RX_PACKET_1518BYTE (0<<ETH_MAX_RX_PACKET_SIZE_OFFSET) -#define ETH_MAX_RX_PACKET_1522BYTE (1<<ETH_MAX_RX_PACKET_SIZE_OFFSET) -#define ETH_MAX_RX_PACKET_1552BYTE (2<<ETH_MAX_RX_PACKET_SIZE_OFFSET) -#define ETH_MAX_RX_PACKET_9022BYTE (3<<ETH_MAX_RX_PACKET_SIZE_OFFSET) -#define ETH_MAX_RX_PACKET_9192BYTE (4<<ETH_MAX_RX_PACKET_SIZE_OFFSET) -#define ETH_MAX_RX_PACKET_9700BYTE (5<<ETH_MAX_RX_PACKET_SIZE_OFFSET) - -#define ETH_SET_FULL_DUPLEX_BIT 21 -#define ETH_SET_FULL_DUPLEX_MASK (1<<ETH_SET_FULL_DUPLEX_BIT) - -#define ETH_SET_FLOW_CTRL_BIT 22 -#define ETH_SET_FLOW_CTRL_MASK (1<<ETH_SET_FLOW_CTRL_BIT) - -#define ETH_SET_GMII_SPEED_1000_BIT 23 -#define ETH_SET_GMII_SPEED_1000_MASK (1<<ETH_SET_GMII_SPEED_1000_BIT) - -#define ETH_SET_MII_SPEED_100_BIT 24 -#define ETH_SET_MII_SPEED_100_MASK (1<<ETH_SET_MII_SPEED_100_BIT) - -/* BITs of Port Serial Control 1 reg (PSC1R) */ -#define ETH_PSC_ENABLE_BIT 2 -#define ETH_PSC_ENABLE_MASK (1<<ETH_PSC_ENABLE_BIT) - -#define ETH_RGMII_ENABLE_BIT 3 -#define ETH_RGMII_ENABLE_MASK (1<<ETH_RGMII_ENABLE_BIT) - -#define ETH_PORT_RESET_BIT 4 -#define ETH_PORT_RESET_MASK (1<<ETH_PORT_RESET_BIT) - -#define ETH_INBAND_AUTO_NEG_ENABLE_BIT 6 -#define ETH_INBAND_AUTO_NEG_ENABLE_MASK (1<<ETH_INBAND_AUTO_NEG_ENABLE_BIT) - -#define ETH_INBAND_AUTO_NEG_BYPASS_BIT 7 -#define ETH_INBAND_AUTO_NEG_BYPASS_MASK (1<<ETH_INBAND_AUTO_NEG_BYPASS_BIT) - -#define ETH_INBAND_AUTO_NEG_START_BIT 8 -#define ETH_INBAND_AUTO_NEG_START_MASK (1<<ETH_INBAND_AUTO_NEG_START_BIT) - -#define ETH_PORT_TYPE_BIT 11 -#define ETH_PORT_TYPE_1000BasedX_MASK (1<<ETH_PORT_TYPE_BIT) - -#define ETH_SGMII_MODE_BIT 12 -#define ETH_1000BaseX_MODE_MASK (0<<ETH_SGMII_MODE_BIT) -#define ETH_SGMII_MODE_MASK (1<<ETH_SGMII_MODE_BIT) - -#define ETH_MGMII_MODE_BIT 13 - -#define ETH_EN_MII_ODD_PRE_BIT 22 -#define ETH_EN_MII_ODD_PRE_MASK (1<<ETH_EN_MII_ODD_PRE_BIT) - -/* BITs of SDMA Descriptor Command/Status field */ -#if defined(MV_CPU_BE) -typedef struct _ethRxDesc -{ - MV_U16 byteCnt ; /* Descriptor buffer byte count */ - MV_U16 bufSize ; /* Buffer size */ - MV_U32 cmdSts ; /* Descriptor command status */ - MV_U32 nextDescPtr; /* Next descriptor pointer */ - MV_U32 bufPtr ; /* Descriptor buffer pointer */ - MV_ULONG returnInfo ; /* User resource return information */ -} ETH_RX_DESC; - -typedef struct _ethTxDesc -{ - MV_U16 byteCnt ; /* Descriptor buffer byte count */ - MV_U16 L4iChk ; /* CPU provided TCP Checksum */ - MV_U32 cmdSts ; /* Descriptor command status */ - MV_U32 nextDescPtr; /* Next descriptor pointer */ - MV_U32 bufPtr ; /* Descriptor buffer pointer */ - MV_ULONG returnInfo ; /* User resource return information */ - MV_U8* alignBufPtr; /* Pointer to 8 byte aligned buffer */ -} ETH_TX_DESC; - -#elif defined(MV_CPU_LE) - -typedef struct _ethRxDesc -{ - MV_U32 cmdSts ; /* Descriptor command status */ - MV_U16 bufSize ; /* Buffer size */ - MV_U16 byteCnt ; /* Descriptor buffer byte count */ - MV_U32 bufPtr ; /* Descriptor buffer pointer */ - MV_U32 nextDescPtr; /* Next descriptor pointer */ - MV_ULONG returnInfo ; /* User resource return information */ -} ETH_RX_DESC; - -typedef struct _ethTxDesc -{ - MV_U32 cmdSts ; /* Descriptor command status */ - MV_U16 L4iChk ; /* CPU provided TCP Checksum */ - MV_U16 byteCnt ; /* Descriptor buffer byte count */ - MV_U32 bufPtr ; /* Descriptor buffer pointer */ - MV_U32 nextDescPtr; /* Next descriptor pointer */ - MV_ULONG returnInfo ; /* User resource return information */ - MV_U8* alignBufPtr; /* Pointer to 32 byte aligned buffer */ -} ETH_TX_DESC; - -#else -#error "MV_CPU_BE or MV_CPU_LE must be defined" -#endif /* MV_CPU_BE || MV_CPU_LE */ - -/* Buffer offset from buffer pointer */ -#define ETH_RX_BUF_OFFSET 0x2 - - -/* Tx & Rx descriptor bits */ -#define ETH_ERROR_SUMMARY_BIT 0 -#define ETH_ERROR_SUMMARY_MASK (1<<ETH_ERROR_SUMMARY_BIT) - -#define ETH_BUFFER_OWNER_BIT 31 -#define ETH_BUFFER_OWNED_BY_DMA (1<<ETH_BUFFER_OWNER_BIT) -#define ETH_BUFFER_OWNED_BY_HOST (0<<ETH_BUFFER_OWNER_BIT) - -/* Tx descriptor bits */ -#define ETH_TX_ERROR_CODE_OFFSET 1 -#define ETH_TX_ERROR_CODE_MASK (3<<ETH_TX_ERROR_CODE_OFFSET) -#define ETH_TX_LATE_COLLISION_ERROR (0<<ETH_TX_ERROR_CODE_OFFSET) -#define ETH_TX_UNDERRUN_ERROR (1<<ETH_TX_ERROR_CODE_OFFSET) -#define ETH_TX_EXCESSIVE_COLLISION_ERROR (2<<ETH_TX_ERROR_CODE_OFFSET) - -#define ETH_TX_LLC_SNAP_FORMAT_BIT 9 -#define ETH_TX_LLC_SNAP_FORMAT_MASK (1<<ETH_TX_LLC_SNAP_FORMAT_BIT) - -#define ETH_TX_IP_FRAG_BIT 10 -#define ETH_TX_IP_FRAG_MASK (1<<ETH_TX_IP_FRAG_BIT) -#define ETH_TX_IP_FRAG (0<<ETH_TX_IP_FRAG_BIT) -#define ETH_TX_IP_NO_FRAG (1<<ETH_TX_IP_FRAG_BIT) - -#define ETH_TX_IP_HEADER_LEN_OFFSET 11 -#define ETH_TX_IP_HEADER_LEN_ALL_MASK (0xF<<ETH_TX_IP_HEADER_LEN_OFFSET) -#define ETH_TX_IP_HEADER_LEN_MASK(len) ((len)<<ETH_TX_IP_HEADER_LEN_OFFSET) - -#define ETH_TX_VLAN_TAGGED_FRAME_BIT 15 -#define ETH_TX_VLAN_TAGGED_FRAME_MASK (1<<ETH_TX_VLAN_TAGGED_FRAME_BIT) - -#define ETH_TX_L4_TYPE_BIT 16 -#define ETH_TX_L4_TCP_TYPE (0<<ETH_TX_L4_TYPE_BIT) -#define ETH_TX_L4_UDP_TYPE (1<<ETH_TX_L4_TYPE_BIT) - -#define ETH_TX_GENERATE_L4_CHKSUM_BIT 17 -#define ETH_TX_GENERATE_L4_CHKSUM_MASK (1<<ETH_TX_GENERATE_L4_CHKSUM_BIT) - -#define ETH_TX_GENERATE_IP_CHKSUM_BIT 18 -#define ETH_TX_GENERATE_IP_CHKSUM_MASK (1<<ETH_TX_GENERATE_IP_CHKSUM_BIT) - -#define ETH_TX_ZERO_PADDING_BIT 19 -#define ETH_TX_ZERO_PADDING_MASK (1<<ETH_TX_ZERO_PADDING_BIT) - -#define ETH_TX_LAST_DESC_BIT 20 -#define ETH_TX_LAST_DESC_MASK (1<<ETH_TX_LAST_DESC_BIT) - -#define ETH_TX_FIRST_DESC_BIT 21 -#define ETH_TX_FIRST_DESC_MASK (1<<ETH_TX_FIRST_DESC_BIT) - -#define ETH_TX_GENERATE_CRC_BIT 22 -#define ETH_TX_GENERATE_CRC_MASK (1<<ETH_TX_GENERATE_CRC_BIT) - -#define ETH_TX_ENABLE_INTERRUPT_BIT 23 -#define ETH_TX_ENABLE_INTERRUPT_MASK (1<<ETH_TX_ENABLE_INTERRUPT_BIT) - -#define ETH_TX_AUTO_MODE_BIT 30 -#define ETH_TX_AUTO_MODE_MASK (1<<ETH_TX_AUTO_MODE_BIT) - - -/* Rx descriptor bits */ -#define ETH_RX_ERROR_CODE_OFFSET 1 -#define ETH_RX_ERROR_CODE_MASK (3<<ETH_RX_ERROR_CODE_OFFSET) -#define ETH_RX_CRC_ERROR (0<<ETH_RX_ERROR_CODE_OFFSET) -#define ETH_RX_OVERRUN_ERROR (1<<ETH_RX_ERROR_CODE_OFFSET) -#define ETH_RX_MAX_FRAME_LEN_ERROR (2<<ETH_RX_ERROR_CODE_OFFSET) -#define ETH_RX_RESOURCE_ERROR (3<<ETH_RX_ERROR_CODE_OFFSET) - -#define ETH_RX_L4_CHECKSUM_OFFSET 3 -#define ETH_RX_L4_CHECKSUM_MASK (0xffff<<ETH_RX_L4_CHECKSUM_OFFSET) - -#define ETH_RX_VLAN_TAGGED_FRAME_BIT 19 -#define ETH_RX_VLAN_TAGGED_FRAME_MASK (1<<ETH_RX_VLAN_TAGGED_FRAME_BIT) - -#define ETH_RX_BPDU_FRAME_BIT 20 -#define ETH_RX_BPDU_FRAME_MASK (1<<ETH_RX_BPDU_FRAME_BIT) - -#define ETH_RX_L4_TYPE_OFFSET 21 -#define ETH_RX_L4_TYPE_MASK (3<<ETH_RX_L4_TYPE_OFFSET) -#define ETH_RX_L4_TCP_TYPE (0<<ETH_RX_L4_TYPE_OFFSET) -#define ETH_RX_L4_UDP_TYPE (1<<ETH_RX_L4_TYPE_OFFSET) -#define ETH_RX_L4_OTHER_TYPE (2<<ETH_RX_L4_TYPE_OFFSET) - -#define ETH_RX_NOT_LLC_SNAP_FORMAT_BIT 23 -#define ETH_RX_NOT_LLC_SNAP_FORMAT_MASK (1<<ETH_RX_NOT_LLC_SNAP_FORMAT_BIT) - -#define ETH_RX_IP_FRAME_TYPE_BIT 24 -#define ETH_RX_IP_FRAME_TYPE_MASK (1<<ETH_RX_IP_FRAME_TYPE_BIT) - -#define ETH_RX_IP_HEADER_OK_BIT 25 -#define ETH_RX_IP_HEADER_OK_MASK (1<<ETH_RX_IP_HEADER_OK_BIT) - -#define ETH_RX_LAST_DESC_BIT 26 -#define ETH_RX_LAST_DESC_MASK (1<<ETH_RX_LAST_DESC_BIT) - -#define ETH_RX_FIRST_DESC_BIT 27 -#define ETH_RX_FIRST_DESC_MASK (1<<ETH_RX_FIRST_DESC_BIT) - -#define ETH_RX_UNKNOWN_DA_BIT 28 -#define ETH_RX_UNKNOWN_DA_MASK (1<<ETH_RX_UNKNOWN_DA_BIT) - -#define ETH_RX_ENABLE_INTERRUPT_BIT 29 -#define ETH_RX_ENABLE_INTERRUPT_MASK (1<<ETH_RX_ENABLE_INTERRUPT_BIT) - -#define ETH_RX_L4_CHECKSUM_OK_BIT 30 -#define ETH_RX_L4_CHECKSUM_OK_MASK (1<<ETH_RX_L4_CHECKSUM_OK_BIT) - -/* Rx descriptor bufSize field */ -#define ETH_RX_IP_FRAGMENTED_FRAME_BIT 2 -#define ETH_RX_IP_FRAGMENTED_FRAME_MASK (1<<ETH_RX_IP_FRAGMENTED_FRAME_BIT) - -#define ETH_RX_BUFFER_MASK 0xFFF8 - - -/* Ethernet Cause Register BITs */ -#define ETH_CAUSE_RX_READY_SUM_BIT 0 -#define ETH_CAUSE_EXTEND_BIT 1 - -#define ETH_CAUSE_RX_READY_OFFSET 2 -#define ETH_CAUSE_RX_READY_BIT(queue) (ETH_CAUSE_RX_READY_OFFSET + (queue)) -#define ETH_CAUSE_RX_READY_MASK(queue) (1 << (ETH_CAUSE_RX_READY_BIT(queue))) - -#define ETH_CAUSE_RX_ERROR_SUM_BIT 10 -#define ETH_CAUSE_RX_ERROR_OFFSET 11 -#define ETH_CAUSE_RX_ERROR_BIT(queue) (ETH_CAUSE_RX_ERROR_OFFSET + (queue)) -#define ETH_CAUSE_RX_ERROR_MASK(queue) (1 << (ETH_CAUSE_RX_ERROR_BIT(queue))) - -#define ETH_CAUSE_TX_END_BIT 19 -#define ETH_CAUSE_SUM_BIT 31 - -/* Ethernet Cause Extended Register BITs */ -#define ETH_CAUSE_TX_BUF_OFFSET 0 -#define ETH_CAUSE_TX_BUF_BIT(queue) (ETH_CAUSE_TX_BUF_OFFSET + (queue)) -#define ETH_CAUSE_TX_BUF_MASK(queue) (1 << (ETH_CAUSE_TX_BUF_BIT(queue))) - -#define ETH_CAUSE_TX_ERROR_OFFSET 8 -#define ETH_CAUSE_TX_ERROR_BIT(queue) (ETH_CAUSE_TX_ERROR_OFFSET + (queue)) -#define ETH_CAUSE_TX_ERROR_MASK(queue) (1 << (ETH_CAUSE_TX_ERROR_BIT(queue))) - -#define ETH_CAUSE_PHY_STATUS_CHANGE_BIT 16 -#define ETH_CAUSE_RX_OVERRUN_BIT 18 -#define ETH_CAUSE_TX_UNDERRUN_BIT 19 -#define ETH_CAUSE_LINK_STATE_CHANGE_BIT 20 -#define ETH_CAUSE_INTERNAL_ADDR_ERR_BIT 23 -#define ETH_CAUSE_EXTEND_SUM_BIT 31 - -/* Marvell Header Register */ -/* Marvell Header register bits */ -#define ETH_MVHDR_EN_BIT 0 -#define ETH_MVHDR_EN_MASK (1 << ETH_MVHDR_EN_BIT) - -#define ETH_MVHDR_DAPREFIX_BIT 1 -#define ETH_MVHDR_DAPREFIX_MASK (0x3 << ETH_MVHDR_DAPREFIX_BIT) -#define ETH_MVHDR_DAPREFIX_PRI_1_2 (0x1 << ETH_MVHDR_DAPREFIX_BIT) -#define ETH_MVHDR_DAPREFIX_DBNUM_PRI (0x2 << ETH_MVHDR_DAPREFIX_BIT) -#define ETH_MVHDR_DAPREFIX_SPID_PRI (0x3 << ETH_MVHDR_DAPREFIX_BIT) - -#define ETH_MVHDR_MHMASK_BIT 8 -#define ETH_MVHDR_MHMASK_MASK (0x3 << ETH_MVHDR_MHMASK_BIT) -#define ETH_MVHDR_MHMASK_8_QUEUE (0x0 << ETH_MVHDR_MHMASK_BIT) -#define ETH_MVHDR_MHMASK_4_QUEUE (0x1 << ETH_MVHDR_MHMASK_BIT) -#define ETH_MVHDR_MHMASK_2_QUEUE (0x3 << ETH_MVHDR_MHMASK_BIT) - - -/* Relevant for 6183 ONLY */ -#define ETH_UNIT_PORTS_PADS_CALIB_0_REG (MV_ETH_REG_BASE(0) + 0x0A0) -#define ETH_UNIT_PORTS_PADS_CALIB_1_REG (MV_ETH_REG_BASE(0) + 0x0A4) -#define ETH_UNIT_PORTS_PADS_CALIB_2_REG (MV_ETH_REG_BASE(0) + 0x0A8) -/* Ethernet Unit Ports Pads Calibration_REG (ETH_UNIT_PORTS_PADS_CALIB_x_REG) */ -#define ETH_ETHERNET_PAD_CLIB_DRVN_OFFS 0 -#define ETH_ETHERNET_PAD_CLIB_DRVN_MASK (0x1F << ETH_ETHERNET_PAD_CLIB_DRVN_OFFS) - -#define ETH_ETHERNET_PAD_CLIB_DRVP_OFFS 5 -#define ETH_ETHERNET_PAD_CLIB_DRVP_MASK (0x1F << ETH_ETHERNET_PAD_CLIB_DRVP_OFFS) - -#define ETH_ETHERNET_PAD_CLIB_TUNEEN_OFFS 16 -#define ETH_ETHERNET_PAD_CLIB_TUNEEN_MASK (0x1 << ETH_ETHERNET_PAD_CLIB_TUNEEN_OFFS) - -#define ETH_ETHERNET_PAD_CLIB_LOCKN_OFFS 17 -#define ETH_ETHERNET_PAD_CLIB_LOCKN_MASK (0x1F << ETH_ETHERNET_PAD_CLIB_LOCKN_OFFS) - -#define ETH_ETHERNET_PAD_CLIB_OFFST_OFFS 24 -#define ETH_ETHERNET_PAD_CLIB_OFFST_MASK (0x1F << ETH_ETHERNET_PAD_CLIB_OFFST_OFFS) - -#define ETH_ETHERNET_PAD_CLIB_WR_EN_OFFS 31 -#define ETH_ETHERNET_PAD_CLIB_WR_EN_MASK (0x1 << ETH_ETHERNET_PAD_CLIB_WR_EN_OFFS) - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __INCmvEthRegsh */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/eth/mvEth.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/eth/mvEth.h deleted file mode 100644 index c42ed1a..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/eth/mvEth.h +++ /dev/null @@ -1,356 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -/******************************************************************************* -* mvEth.h - Header File for : Ethernet Controller -* -* DESCRIPTION: -* This header file contains macros typedefs and function declaration for -* Marvell Gigabit Ethernet Controllers. -* -* DEPENDENCIES: -* None. -* -*******************************************************************************/ - -#ifndef __mvEth_h__ -#define __mvEth_h__ - -/* includes */ -#include "mvTypes.h" -#include "mv802_3.h" -#include "ctrlEnv/mvCtrlEnvLib.h" -#include "ctrlEnv/mvCtrlEnvAddrDec.h" -#include "eth/gbe/mvEthRegs.h" -#include "mvSysHwConfig.h" - -/* defines */ - -#define MV_ETH_EXTRA_FRAGS_NUM 2 - - -typedef enum -{ - MV_ETH_SPEED_AN, - MV_ETH_SPEED_10, - MV_ETH_SPEED_100, - MV_ETH_SPEED_1000 - -} MV_ETH_PORT_SPEED; - -typedef enum -{ - MV_ETH_DUPLEX_AN, - MV_ETH_DUPLEX_HALF, - MV_ETH_DUPLEX_FULL - -} MV_ETH_PORT_DUPLEX; - -typedef enum -{ - MV_ETH_FC_AN_ADV_DIS, - MV_ETH_FC_AN_ADV_SYM, - MV_ETH_FC_DISABLE, - MV_ETH_FC_ENABLE - -} MV_ETH_PORT_FC; - -typedef enum -{ - MV_ETH_PRIO_FIXED = 0, /* Fixed priority mode */ - MV_ETH_PRIO_WRR = 1 /* Weighted round robin priority mode */ -} MV_ETH_PRIO_MODE; - -/* Ethernet port specific infomation */ -typedef struct -{ - int maxRxPktSize; - int rxDefQ; - int rxBpduQ; - int rxArpQ; - int rxTcpQ; - int rxUdpQ; - int ejpMode; -} MV_ETH_PORT_CFG; - -typedef struct -{ - int descrNum; -} MV_ETH_RX_Q_CFG; - -typedef struct -{ - int descrNum; - MV_ETH_PRIO_MODE prioMode; - int quota; -} MV_ETH_TX_Q_CFG; - -typedef struct -{ - int maxRxPktSize; - int rxDefQ; - int txDescrNum[MV_ETH_TX_Q_NUM]; - int rxDescrNum[MV_ETH_RX_Q_NUM]; - void *osHandle; -} MV_ETH_PORT_INIT; - -typedef struct -{ - MV_BOOL isLinkUp; - MV_ETH_PORT_SPEED speed; - MV_ETH_PORT_DUPLEX duplex; - MV_ETH_PORT_FC flowControl; - -} MV_ETH_PORT_STATUS; - -typedef enum -{ - MV_ETH_DISABLE_HEADER_MODE = 0, - MV_ETH_ENABLE_HEADER_MODE_PRI_2_1 = 1, - MV_ETH_ENABLE_HEADER_MODE_PRI_DBNUM = 2, - MV_ETH_ENABLE_HEADER_MODE_PRI_SPID = 3 -} MV_ETH_HEADER_MODE; - - -/* ethernet.h API list */ -void mvEthHalInit(void); -void mvEthMemAttrGet(MV_BOOL* pIsSram, MV_BOOL* pIsSwCoher); - -/* Port Initalization routines */ -void* mvEthPortInit (int port, MV_ETH_PORT_INIT *pPortInit); -void ethResetTxDescRing(void* pPortHndl, int queue); -void ethResetRxDescRing(void* pPortHndl, int queue); - -void* mvEthPortHndlGet(int port); - -void mvEthPortFinish(void* pEthPortHndl); -MV_STATUS mvEthPortDown(void* pEthPortHndl); -MV_STATUS mvEthPortDisable(void* pEthPortHndl); -MV_STATUS mvEthPortUp(void* pEthPortHndl); -MV_STATUS mvEthPortEnable(void* pEthPortHndl); - -/* Port data flow routines */ -MV_PKT_INFO *mvEthPortForceTxDone(void* pEthPortHndl, int txQueue); -MV_PKT_INFO *mvEthPortForceRx(void* pEthPortHndl, int rxQueue); - -/* Port Configuration routines */ -MV_STATUS mvEthDefaultsSet(void* pEthPortHndl); -MV_STATUS mvEthMaxRxSizeSet(void* pPortHndl, int maxRxSize); - -/* Port RX MAC Filtering control routines */ -MV_U8 mvEthMcastCrc8Get(MV_U8* pAddr); -MV_STATUS mvEthRxFilterModeSet(void* pPortHndl, MV_BOOL isPromisc); -MV_STATUS mvEthMacAddrSet(void* pPortHandle, MV_U8* pMacAddr, int queue); -MV_STATUS mvEthMcastAddrSet(void* pPortHandle, MV_U8 *pAddr, int queue); - -/* MIB Counters APIs */ -MV_U32 mvEthMibCounterRead(void* pPortHndl, unsigned int mibOffset, - MV_U32* pHigh32); -void mvEthMibCountersClear(void* pPortHandle); - -/* TX Scheduling configuration routines */ -MV_STATUS mvEthTxQueueConfig(void* pPortHandle, int txQueue, - MV_ETH_PRIO_MODE txPrioMode, int txQuota); - -/* RX Dispatching configuration routines */ -MV_STATUS mvEthBpduRxQueue(void* pPortHandle, int bpduQueue); -MV_STATUS mvEthVlanPrioRxQueue(void* pPortHandle, int vlanPrio, int vlanPrioQueue); -MV_STATUS mvEthTosToRxqSet(void* pPortHandle, int tos, int rxq); -int mvEthTosToRxqGet(void* pPortHandle, int tos); - -/* Speed, Duplex, FlowControl routines */ -MV_STATUS mvEthSpeedDuplexSet(void* pPortHandle, MV_ETH_PORT_SPEED speed, - MV_ETH_PORT_DUPLEX duplex); - -MV_STATUS mvEthFlowCtrlSet(void* pPortHandle, MV_ETH_PORT_FC flowControl); - -#if (MV_ETH_VERSION >= 4) -MV_STATUS mvEthEjpModeSet(void* pPortHandle, int mode); -#endif /* (MV_ETH_VERSION >= 4) */ - -void mvEthStatusGet(void* pPortHandle, MV_ETH_PORT_STATUS* pStatus); - -/* Marvell Header control */ -MV_STATUS mvEthHeaderModeSet(void* pPortHandle, MV_ETH_HEADER_MODE headerMode); - -/* PHY routines */ -void mvEthPhyAddrSet(void* pPortHandle, int phyAddr); -int mvEthPhyAddrGet(void* pPortHandle); - -/* Power management routines */ -void mvEthPortPowerDown(int port); -void mvEthPortPowerUp(int port); - -/******************** ETH PRIVATE ************************/ - -/*#define UNCACHED_TX_BUFFERS*/ -/*#define UNCACHED_RX_BUFFERS*/ - - -/* Port attributes */ -/* Size of a Tx/Rx descriptor used in chain list data structure */ -#define ETH_RX_DESC_ALIGNED_SIZE 32 -#define ETH_TX_DESC_ALIGNED_SIZE 32 - -#define TX_DISABLE_TIMEOUT_MSEC 1000 -#define RX_DISABLE_TIMEOUT_MSEC 1000 -#define TX_FIFO_EMPTY_TIMEOUT_MSEC 10000 -#define PORT_DISABLE_WAIT_TCLOCKS 5000 - -/* Macros that save access to desc in order to find next desc pointer */ -#define RX_NEXT_DESC_PTR(pRxDescr, pQueueCtrl) \ - ((pRxDescr) == (pQueueCtrl)->pLastDescr) ? \ - (ETH_RX_DESC*)((pQueueCtrl)->pFirstDescr) : \ - (ETH_RX_DESC*)(((MV_ULONG)(pRxDescr)) + ETH_RX_DESC_ALIGNED_SIZE) - -#define TX_NEXT_DESC_PTR(pTxDescr, pQueueCtrl) \ - ((pTxDescr) == (pQueueCtrl)->pLastDescr) ? \ - (ETH_TX_DESC*)((pQueueCtrl)->pFirstDescr) : \ - (ETH_TX_DESC*)(((MV_ULONG)(pTxDescr)) + ETH_TX_DESC_ALIGNED_SIZE) - -#define RX_PREV_DESC_PTR(pRxDescr, pQueueCtrl) \ - ((pRxDescr) == (pQueueCtrl)->pFirstDescr) ? \ - (ETH_RX_DESC*)((pQueueCtrl)->pLastDescr) : \ - (ETH_RX_DESC*)(((MV_ULONG)(pRxDescr)) - ETH_RX_DESC_ALIGNED_SIZE) - -#define TX_PREV_DESC_PTR(pTxDescr, pQueueCtrl) \ - ((pTxDescr) == (pQueueCtrl)->pFirstDescr) ? \ - (ETH_TX_DESC*)((pQueueCtrl)->pLastDescr) : \ - (ETH_TX_DESC*)(((MV_ULONG)(pTxDescr)) - ETH_TX_DESC_ALIGNED_SIZE) - - -/* Queue specific information */ -typedef struct -{ - void* pFirstDescr; - void* pLastDescr; - void* pCurrentDescr; - void* pUsedDescr; - int resource; - MV_BUF_INFO descBuf; -} ETH_QUEUE_CTRL; - - -/* Ethernet port specific infomation */ -typedef struct _ethPortCtrl -{ - int portNo; - ETH_QUEUE_CTRL rxQueue[MV_ETH_RX_Q_NUM]; /* Rx ring resource */ - ETH_QUEUE_CTRL txQueue[MV_ETH_TX_Q_NUM]; /* Tx ring resource */ - - MV_ETH_PORT_CFG portConfig; - MV_ETH_RX_Q_CFG rxQueueConfig[MV_ETH_RX_Q_NUM]; - MV_ETH_TX_Q_CFG txQueueConfig[MV_ETH_TX_Q_NUM]; - - /* Register images - For DP */ - MV_U32 portTxQueueCmdReg; /* Port active Tx queues summary */ - MV_U32 portRxQueueCmdReg; /* Port active Rx queues summary */ - - MV_STATE portState; - - MV_U8 mcastCount[256]; - MV_U32* hashPtr; - void *osHandle; -} ETH_PORT_CTRL; - -/************** MACROs ****************/ - -/* MACROs to Flush / Invalidate TX / RX Buffers */ -#if (ETHER_DRAM_COHER == MV_CACHE_COHER_SW) && !defined(UNCACHED_TX_BUFFERS) -# define ETH_PACKET_CACHE_FLUSH(pAddr, size) \ - mvOsCacheClear(NULL, (pAddr), (size)); \ - /*CPU_PIPE_FLUSH;*/ -#else -# define ETH_PACKET_CACHE_FLUSH(pAddr, size) \ - mvOsIoVirtToPhy(NULL, (pAddr)); -#endif /* ETHER_DRAM_COHER == MV_CACHE_COHER_SW */ - -#if ( (ETHER_DRAM_COHER == MV_CACHE_COHER_SW) && !defined(UNCACHED_RX_BUFFERS) ) -# define ETH_PACKET_CACHE_INVALIDATE(pAddr, size) \ - mvOsCacheInvalidate (NULL, (pAddr), (size)); \ - /*CPU_PIPE_FLUSH;*/ -#else -# define ETH_PACKET_CACHE_INVALIDATE(pAddr, size) -#endif /* ETHER_DRAM_COHER == MV_CACHE_COHER_SW && !UNCACHED_RX_BUFFERS */ - -#ifdef ETH_DESCR_UNCACHED - -#define ETH_DESCR_FLUSH_INV(pPortCtrl, pDescr) -#define ETH_DESCR_INV(pPortCtrl, pDescr) - -#else - -#define ETH_DESCR_FLUSH_INV(pPortCtrl, pDescr) \ - mvOsCacheLineFlushInv(pPortCtrl->osHandle, (MV_ULONG)(pDescr)) - -#define ETH_DESCR_INV(pPortCtrl, pDescr) \ - mvOsCacheLineInv(pPortCtrl->osHandle, (MV_ULONG)(pDescr)) - -#endif /* ETH_DESCR_UNCACHED */ - -#include "eth/gbe/mvEthGbe.h" - -#endif /* __mvEth_h__ */ - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/gpp/mvGpp.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/gpp/mvGpp.c deleted file mode 100644 index 889d4d9..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/gpp/mvGpp.c +++ /dev/null @@ -1,362 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#include "gpp/mvGpp.h" -#include "ctrlEnv/mvCtrlEnvLib.h" -/* defines */ -#ifdef MV_DEBUG - #define DB(x) x -#else - #define DB(x) -#endif - -static MV_VOID gppRegSet(MV_U32 group, MV_U32 regOffs,MV_U32 mask,MV_U32 value); - -/******************************************************************************* -* mvGppTypeSet - Enable a GPP (OUT) pin -* -* DESCRIPTION: -* -* INPUT: -* group - GPP group number -* mask - 32bit mask value. Each set bit in the mask means that the type -* of corresponding GPP will be set. Other GPPs are ignored. -* value - 32bit value that describes GPP type per pin. -* -* OUTPUT: -* None. -* -* EXAMPLE: -* Set GPP8 to input and GPP15 to output. -* mvGppTypeSet(0, (GPP8 | GPP15), -* ((MV_GPP_IN & GPP8) | (MV_GPP_OUT & GPP15)) ); -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_STATUS mvGppTypeSet(MV_U32 group, MV_U32 mask, MV_U32 value) -{ - if (group >= MV_GPP_MAX_GROUP) - { - DB(mvOsPrintf("mvGppTypeSet: ERR. invalid group number \n")); - return MV_BAD_PARAM; - } - - gppRegSet(group, GPP_DATA_OUT_EN_REG(group), mask, value); - - /* Workaround for Erratum FE-MISC-70*/ - if(mvCtrlRevGet()==MV_88F6XXX_A0_REV && (group == 1)) - { - mask &= 0x2; - gppRegSet(0, GPP_DATA_OUT_EN_REG(0), mask, value); - } /*End of WA*/ - - return MV_OK; - -} - -/******************************************************************************* -* mvGppBlinkEn - Set a GPP (IN) Pin list to blink every ~100ms -* -* DESCRIPTION: -* -* INPUT: -* group - GPP group number -* mask - 32bit mask value. Each set bit in the mask means that the type -* of corresponding GPP will be set. Other GPPs are ignored. -* value - 32bit value that describes GPP blink per pin. -* -* OUTPUT: -* None. -* -* EXAMPLE: -* Set GPP8 to be static and GPP15 to be blinking. -* mvGppBlinkEn(0, (GPP8 | GPP15), -* ((MV_GPP_OUT_STATIC & GPP8) | (MV_GPP_OUT_BLINK & GPP15)) ); -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_STATUS mvGppBlinkEn(MV_U32 group, MV_U32 mask, MV_U32 value) -{ - if (group >= MV_GPP_MAX_GROUP) - { - DB(mvOsPrintf("mvGppBlinkEn: ERR. invalid group number \n")); - return MV_BAD_PARAM; - } - - gppRegSet(group, GPP_BLINK_EN_REG(group), mask, value); - - return MV_OK; - -} -/******************************************************************************* -* mvGppPolaritySet - Set a GPP (IN) Pin list Polarity mode -* -* DESCRIPTION: -* -* INPUT: -* group - GPP group number -* mask - 32bit mask value. Each set bit in the mask means that the type -* of corresponding GPP will be set. Other GPPs are ignored. -* value - 32bit value that describes GPP polarity per pin. -* -* OUTPUT: -* None. -* -* EXAMPLE: -* Set GPP8 to the actual pin value and GPP15 to be inverted. -* mvGppPolaritySet(0, (GPP8 | GPP15), -* ((MV_GPP_IN_ORIGIN & GPP8) | (MV_GPP_IN_INVERT & GPP15)) ); -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_STATUS mvGppPolaritySet(MV_U32 group, MV_U32 mask, MV_U32 value) -{ - if (group >= MV_GPP_MAX_GROUP) - { - DB(mvOsPrintf("mvGppPolaritySet: ERR. invalid group number \n")); - return MV_BAD_PARAM; - } - - gppRegSet(group, GPP_DATA_IN_POL_REG(group), mask, value); - - return MV_OK; - -} - -/******************************************************************************* -* mvGppPolarityGet - Get a value of relevant bits from GPP Polarity register. -* -* DESCRIPTION: -* -* INPUT: -* group - GPP group number -* mask - 32bit mask value. Each set bit in the mask means that the -* returned value is valid for it. -* -* OUTPUT: -* None. -* -* EXAMPLE: -* Get GPP8 and GPP15 value. -* mvGppPolarityGet(0, (GPP8 | GPP15)); -* -* RETURN: -* 32bit value that describes GPP polatity mode per pin. -* -*******************************************************************************/ -MV_U32 mvGppPolarityGet(MV_U32 group, MV_U32 mask) -{ - MV_U32 regVal; - - if (group >= MV_GPP_MAX_GROUP) - { - DB(mvOsPrintf("mvGppActiveSet: Error invalid group number \n")); - return MV_ERROR; - } - regVal = MV_REG_READ(GPP_DATA_IN_POL_REG(group)); - - return (regVal & mask); -} - -/******************************************************************************* -* mvGppValueGet - Get a GPP Pin list value. -* -* DESCRIPTION: -* This function get GPP value. -* -* INPUT: -* group - GPP group number -* mask - 32bit mask value. Each set bit in the mask means that the -* returned value is valid for it. -* -* OUTPUT: -* None. -* -* EXAMPLE: -* Get GPP8 and GPP15 value. -* mvGppValueGet(0, (GPP8 | GPP15)); -* -* RETURN: -* 32bit value that describes GPP activity mode per pin. -* -*******************************************************************************/ -MV_U32 mvGppValueGet(MV_U32 group, MV_U32 mask) -{ - MV_U32 gppData; - - gppData = MV_REG_READ(GPP_DATA_IN_REG(group)); - - gppData &= mask; - - return gppData; - -} - -/******************************************************************************* -* mvGppValueSet - Set a GPP Pin list value. -* -* DESCRIPTION: -* This function set value for given GPP pin list. -* -* INPUT: -* group - GPP group number -* mask - 32bit mask value. Each set bit in the mask means that the -* value of corresponding GPP will be set accordingly. Other GPP -* are not affected. -* value - 32bit value that describes GPP value per pin. -* -* OUTPUT: -* None. -* -* EXAMPLE: -* Set GPP8 value of '0' and GPP15 value of '1'. -* mvGppActiveSet(0, (GPP8 | GPP15), ((0 & GPP8) | (GPP15)) ); -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_STATUS mvGppValueSet (MV_U32 group, MV_U32 mask, MV_U32 value) -{ - MV_U32 outEnable, tmp; - MV_U32 i; - - if (group >= MV_GPP_MAX_GROUP) - { - DB(mvOsPrintf("mvGppValueSet: Error invalid group number \n")); - return MV_BAD_PARAM; - } - - /* verify that the gpp pin is configured as output */ - /* Note that in the register out enabled -> bit = '0'. */ - outEnable = ~MV_REG_READ(GPP_DATA_OUT_EN_REG(group)); - - /* Workaround for Erratum FE-MISC-70*/ - if(mvCtrlRevGet()==MV_88F6XXX_A0_REV && (group == 1)) - { - tmp = ~MV_REG_READ(GPP_DATA_OUT_EN_REG(0)); - outEnable &= 0xfffffffd; - outEnable |= (tmp & 0x2); - } /*End of WA*/ - - for (i = 0 ; i < 32 ;i++) - { - if (((mask & (1 << i)) & (outEnable & (1 << i))) != (mask & (1 << i))) - { - mvOsPrintf("mvGppValueSet: Err. An attempt to set output "\ - "value to GPP %d in input mode.\n", i); - return MV_ERROR; - } - } - - gppRegSet(group, GPP_DATA_OUT_REG(group), mask, value); - - return MV_OK; - -} -/******************************************************************************* -* gppRegSet - Set a specific GPP pin on a specific GPP register -* -* DESCRIPTION: -* This function set a specific GPP pin on a specific GPP register -* -* INPUT: -* regOffs - GPP Register offset -* group - GPP group number -* mask - 32bit mask value. Each set bit in the mask means that the -* value of corresponding GPP will be set accordingly. Other GPP -* are not affected. -* value - 32bit value that describes GPP value per pin. -* -* OUTPUT: -* None. -* -* EXAMPLE: -* Set GPP8 value of '0' and GPP15 value of '1'. -* mvGppActiveSet(0, (GPP8 | GPP15), ((0 & GPP8) | (1 & GPP15)) ); -* -* RETURN: -* None. -* -*******************************************************************************/ -static MV_VOID gppRegSet (MV_U32 group, MV_U32 regOffs,MV_U32 mask,MV_U32 value) -{ - MV_U32 gppData; - - gppData = MV_REG_READ(regOffs); - - gppData &= ~mask; - - gppData |= (value & mask); - - MV_REG_WRITE(regOffs, gppData); -} - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/gpp/mvGpp.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/gpp/mvGpp.h deleted file mode 100644 index 526d324..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/gpp/mvGpp.h +++ /dev/null @@ -1,118 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCmvGppH -#define __INCmvGppH - -#include "mvCommon.h" -#include "mvOs.h" -#include "ctrlEnv/mvCtrlEnvSpec.h" -#include "gpp/mvGppRegs.h" - -/* These macros describes the GPP type. Each of the GPPs pins can */ -/* be assigned to act as a general purpose input or output pin. */ -#define MV_GPP_IN 0xFFFFFFFF /* GPP input */ -#define MV_GPP_OUT 0 /* GPP output */ - - -/* These macros describes the GPP Out Enable. */ -#define MV_GPP_OUT_DIS 0xFFFFFFFF /* Out pin disabled*/ -#define MV_GPP_OUT_EN 0 /* Out pin enabled*/ - -/* These macros describes the GPP Out Blinking. */ -/* When set and the corresponding bit in GPIO Data Out Enable Control */ -/* Register is enabled, the GPIO pin blinks every ~100 ms (a period of */ -/* 2^24 TCLK clocks). */ -#define MV_GPP_OUT_BLINK 0xFFFFFFFF /* Out pin blinking*/ -#define MV_GPP_OUT_STATIC 0 /* Out pin static*/ - - -/* These macros describes the GPP Polarity. */ -/* When set to 1 GPIO Data In Register reflects the inverted value of the */ -/* corresponding pin. */ - -#define MV_GPP_IN_INVERT 0xFFFFFFFF /* Inverted value is got*/ -#define MV_GPP_IN_ORIGIN 0 /* original value is got*/ - -/* mvGppTypeSet - Set PP pin mode (IN or OUT) */ -MV_STATUS mvGppTypeSet(MV_U32 group, MV_U32 mask, MV_U32 value); - -/* mvGppBlinkEn - Set a GPP (IN) Pin list to blink every ~100ms */ -MV_STATUS mvGppBlinkEn(MV_U32 group, MV_U32 mask, MV_U32 value); - -/* mvGppPolaritySet - Set a GPP (IN) Pin list Polarity mode. */ -MV_STATUS mvGppPolaritySet(MV_U32 group, MV_U32 mask, MV_U32 value); - -/* mvGppPolarityGet - Get the Polarity of a GPP Pin */ -MV_U32 mvGppPolarityGet(MV_U32 group, MV_U32 mask); - -/* mvGppValueGet - Get a GPP Pin list value.*/ -MV_U32 mvGppValueGet(MV_U32 group, MV_U32 mask); - - -/* mvGppValueSet - Set a GPP Pin list value. */ -MV_STATUS mvGppValueSet (MV_U32 group, MV_U32 mask, MV_U32 value); - -#endif /* #ifndef __INCmvGppH */ - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/gpp/mvGppRegs.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/gpp/mvGppRegs.h deleted file mode 100644 index b6fec34..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/gpp/mvGppRegs.h +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCmvGppRegsH -#define __INCmvGppRegsH - -#define MV_GPP0 BIT0 -#define MV_GPP1 BIT1 -#define MV_GPP2 BIT2 -#define MV_GPP3 BIT3 -#define MV_GPP4 BIT4 -#define MV_GPP5 BIT5 -#define MV_GPP6 BIT6 -#define MV_GPP7 BIT7 -#define MV_GPP8 BIT8 -#define MV_GPP9 BIT9 -#define MV_GPP10 BIT10 -#define MV_GPP11 BIT11 -#define MV_GPP12 BIT12 -#define MV_GPP13 BIT13 -#define MV_GPP14 BIT14 -#define MV_GPP15 BIT15 -#define MV_GPP16 BIT16 -#define MV_GPP17 BIT17 -#define MV_GPP18 BIT18 -#define MV_GPP19 BIT19 -#define MV_GPP20 BIT20 -#define MV_GPP21 BIT21 -#define MV_GPP22 BIT22 -#define MV_GPP23 BIT23 -#define MV_GPP24 BIT24 -#define MV_GPP25 BIT25 -#define MV_GPP26 BIT26 -#define MV_GPP27 BIT27 -#define MV_GPP28 BIT28 -#define MV_GPP29 BIT29 -#define MV_GPP30 BIT30 -#define MV_GPP31 BIT31 - - -/* registers offsets */ - -#define GPP_DATA_OUT_REG(grp) ((grp == 0) ? 0x10100 : 0x10140) -#define GPP_DATA_OUT_EN_REG(grp) ((grp == 0) ? 0x10104 : 0x10144) -#define GPP_BLINK_EN_REG(grp) ((grp == 0) ? 0x10108 : 0x10148) -#define GPP_DATA_IN_POL_REG(grp) ((grp == 0) ? 0x1010C : 0x1014c) -#define GPP_DATA_IN_REG(grp) ((grp == 0) ? 0x10110 : 0x10150) -#define GPP_INT_CAUSE_REG(grp) ((grp == 0) ? 0x10114 : 0x10154) -#define GPP_INT_MASK_REG(grp) ((grp == 0) ? 0x10118 : 0x10158) -#define GPP_INT_LVL_REG(grp) ((grp == 0) ? 0x1011c : 0x1015c) - -#define GPP_DATA_OUT_SET_REG 0x10120 -#define GPP_DATA_OUT_CLEAR_REG 0x10124 - -#endif /* #ifndef __INCmvGppRegsH */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pci-if/mvPciIf.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pci-if/mvPciIf.c deleted file mode 100644 index 672d3e3..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pci-if/mvPciIf.c +++ /dev/null @@ -1,669 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#include "mvPciIf.h" -#include "ctrlEnv/sys/mvSysPex.h" - -#if defined(MV_INCLUDE_PCI) -#include "ctrlEnv/sys/mvSysPci.h" -#endif - - -/* defines */ -#ifdef MV_DEBUG - #define DB(x) x -#else - #define DB(x) -#endif - - -/******************************************************************************* -* mvPciInit - Initialize PCI interfaces -* -* DESCRIPTION: -* -* INPUT: -* -* -* OUTPUT: -* None. -* -* RETURN: -* MV_OK if function success otherwise MV_ERROR or MV_BAD_PARAM -* -*******************************************************************************/ - - -MV_STATUS mvPciIfInit(MV_U32 pciIf, PCI_IF_MODE pciIfmode) -{ - PCI_IF_TYPE pciIfType = mvPciIfTypeGet(pciIf); - - if (PCI_IF_TYPE_CONVEN_PCIX == pciIfType) - { - #if defined(MV_INCLUDE_PCI) - - MV_PCI_MOD pciMod; - - if (PCI_IF_MODE_HOST == pciIfmode) - { - pciMod = MV_PCI_MOD_HOST; - } - else if (PCI_IF_MODE_DEVICE == pciIfmode) - { - pciMod = MV_PCI_MOD_DEVICE; - } - else - { - mvOsPrintf("%s: ERROR!!! Bus %d mode %d neither host nor device!\n", - __FUNCTION__, pciIf, pciIfmode); - return MV_FAIL; - } - - return mvPciInit(pciIf - MV_PCI_START_IF, pciMod); - #else - return MV_OK; - #endif - } - else if (PCI_IF_TYPE_PEX == pciIfType) - { - #if defined(MV_INCLUDE_PEX) - - MV_PEX_TYPE pexType; - - if (PCI_IF_MODE_HOST == pciIfmode) - { - pexType = MV_PEX_ROOT_COMPLEX; - } - else if (PCI_IF_MODE_DEVICE == pciIfmode) - { - pexType = MV_PEX_END_POINT; - } - else - { - mvOsPrintf("%s: ERROR!!! Bus %d type %d neither root complex nor" \ - " end point\n", __FUNCTION__, pciIf, pciIfmode); - return MV_FAIL; - } - return mvPexInit(pciIf - MV_PEX_START_IF, pexType); - - #else - return MV_OK; - #endif - - } - else - { - mvOsPrintf("%s: ERROR!!! Invalid pciIf %d\n", __FUNCTION__, pciIf); - } - - return MV_FAIL; - -} - -/* PCI configuration space read write */ - -/******************************************************************************* -* mvPciConfigRead - Read from configuration space -* -* DESCRIPTION: -* This function performs a 32 bit read from PCI configuration space. -* It supports both type 0 and type 1 of Configuration Transactions -* (local and over bridge). In order to read from local bus segment, use -* bus number retrieved from mvPciLocalBusNumGet(). Other bus numbers -* will result configuration transaction of type 1 (over bridge). -* -* INPUT: -* pciIf - PCI interface number. -* bus - PCI segment bus number. -* dev - PCI device number. -* func - Function number. -* regOffs - Register offset. -* -* OUTPUT: -* None. -* -* RETURN: -* 32bit register data, 0xffffffff on error -* -*******************************************************************************/ -MV_U32 mvPciIfConfigRead (MV_U32 pciIf, MV_U32 bus, MV_U32 dev, MV_U32 func, - MV_U32 regOff) -{ - PCI_IF_TYPE pciIfType = mvPciIfTypeGet(pciIf); - - if (PCI_IF_TYPE_CONVEN_PCIX == pciIfType) - { - #if defined(MV_INCLUDE_PCI) - return mvPciConfigRead(pciIf - MV_PCI_START_IF, - bus, - dev, - func, - regOff); - #else - return 0xffffffff; - #endif - } - else if (PCI_IF_TYPE_PEX == pciIfType) - { - #if defined(MV_INCLUDE_PEX) - return mvPexConfigRead(pciIf - MV_PEX_START_IF, - bus, - dev, - func, - regOff); - #else - return 0xffffffff; - #endif - - } - else - { - mvOsPrintf("%s: ERROR!!! Invalid pciIf %d\n", __FUNCTION__, pciIf); - } - - return 0; - -} - -/******************************************************************************* -* mvPciConfigWrite - Write to configuration space -* -* DESCRIPTION: -* This function performs a 32 bit write to PCI configuration space. -* It supports both type 0 and type 1 of Configuration Transactions -* (local and over bridge). In order to write to local bus segment, use -* bus number retrieved from mvPciLocalBusNumGet(). Other bus numbers -* will result configuration transaction of type 1 (over bridge). -* -* INPUT: -* pciIf - PCI interface number. -* bus - PCI segment bus number. -* dev - PCI device number. -* func - Function number. -* regOffs - Register offset. -* data - 32bit data. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM for bad parameters ,MV_ERROR on error ! otherwise MV_OK -* -*******************************************************************************/ -MV_STATUS mvPciIfConfigWrite(MV_U32 pciIf, MV_U32 bus, MV_U32 dev, - MV_U32 func, MV_U32 regOff, MV_U32 data) -{ - PCI_IF_TYPE pciIfType = mvPciIfTypeGet(pciIf); - - if (PCI_IF_TYPE_CONVEN_PCIX == pciIfType) - { - #if defined(MV_INCLUDE_PCI) - return mvPciConfigWrite(pciIf - MV_PCI_START_IF, - bus, - dev, - func, - regOff, - data); - #else - return MV_OK; - #endif - } - else if (PCI_IF_TYPE_PEX == pciIfType) - { - #if defined(MV_INCLUDE_PEX) - return mvPexConfigWrite(pciIf - MV_PEX_START_IF, - bus, - dev, - func, - regOff, - data); - #else - return MV_OK; - #endif - - } - else - { - mvOsPrintf("%s: ERROR!!! Invalid pciIf %d\n", __FUNCTION__, pciIf); - } - - return MV_FAIL; - -} - -/******************************************************************************* -* mvPciMasterEnable - Enable/disale PCI interface master transactions. -* -* DESCRIPTION: -* This function performs read modified write to PCI command status -* (offset 0x4) to set/reset bit 2. After this bit is set, the PCI -* master is allowed to gain ownership on the bus, otherwise it is -* incapable to do so. -* -* INPUT: -* pciIf - PCI interface number. -* enable - Enable/disable parameter. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM for bad parameters ,MV_ERROR on error ! otherwise MV_OK -* -*******************************************************************************/ -MV_STATUS mvPciIfMasterEnable(MV_U32 pciIf, MV_BOOL enable) -{ - - PCI_IF_TYPE pciIfType = mvPciIfTypeGet(pciIf); - - if (PCI_IF_TYPE_CONVEN_PCIX == pciIfType) - { - #if defined(MV_INCLUDE_PCI) - return mvPciMasterEnable(pciIf - MV_PCI_START_IF, - enable); - #else - return MV_OK; - #endif - } - else if (PCI_IF_TYPE_PEX == pciIfType) - { - #if defined(MV_INCLUDE_PEX) - return mvPexMasterEnable(pciIf - MV_PEX_START_IF, - enable); - #else - return MV_OK; - #endif - } - else - { - mvOsPrintf("%s: ERROR!!! Invalid pciIf %d\n", __FUNCTION__, pciIf); - } - - return MV_FAIL; - -} - - -/******************************************************************************* -* mvPciSlaveEnable - Enable/disale PCI interface slave transactions. -* -* DESCRIPTION: -* This function performs read modified write to PCI command status -* (offset 0x4) to set/reset bit 0 and 1. After those bits are set, -* the PCI slave is allowed to respond to PCI IO space access (bit 0) -* and PCI memory space access (bit 1). -* -* INPUT: -* pciIf - PCI interface number. -* dev - PCI device number. -* enable - Enable/disable parameter. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM for bad parameters ,MV_ERROR on error ! otherwise MV_OK -* -*******************************************************************************/ -MV_STATUS mvPciIfSlaveEnable(MV_U32 pciIf,MV_U32 bus, MV_U32 dev, MV_BOOL enable) -{ - - PCI_IF_TYPE pciIfType = mvPciIfTypeGet(pciIf); - - if (PCI_IF_TYPE_CONVEN_PCIX == pciIfType) - { - #if defined(MV_INCLUDE_PCI) - return mvPciSlaveEnable(pciIf - MV_PCI_START_IF,bus,dev, - enable); - #else - return MV_OK; - #endif - } - else if (PCI_IF_TYPE_PEX == pciIfType) - { - #if defined(MV_INCLUDE_PEX) - return mvPexSlaveEnable(pciIf - MV_PEX_START_IF,bus,dev, - enable); - #else - return MV_OK; - #endif - } - else - { - mvOsPrintf("%s: ERROR!!! Invalid pciIf %d\n", __FUNCTION__, pciIf); - } - - return MV_FAIL; - -} - -/******************************************************************************* -* mvPciLocalBusNumSet - Set PCI interface local bus number. -* -* DESCRIPTION: -* This function sets given PCI interface its local bus number. -* Note: In case the PCI interface is PCI-X, the information is read-only. -* -* INPUT: -* pciIf - PCI interface number. -* busNum - Bus number. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_NOT_ALLOWED in case PCI interface is PCI-X. -* MV_BAD_PARAM on bad parameters , -* otherwise MV_OK -* -*******************************************************************************/ -MV_STATUS mvPciIfLocalBusNumSet(MV_U32 pciIf, MV_U32 busNum) -{ - PCI_IF_TYPE pciIfType = mvPciIfTypeGet(pciIf); - - if (PCI_IF_TYPE_CONVEN_PCIX == pciIfType) - { - #if defined(MV_INCLUDE_PCI) - return mvPciLocalBusNumSet(pciIf - MV_PCI_START_IF, - busNum); - #else - return MV_OK; - #endif - } - else if (PCI_IF_TYPE_PEX == pciIfType) - { - #if defined(MV_INCLUDE_PEX) - return mvPexLocalBusNumSet(pciIf - MV_PEX_START_IF, - busNum); - #else - return MV_OK; - #endif - } - else - { - mvOsPrintf("%s: ERROR!!! Invalid pciIf %d\n", __FUNCTION__, pciIf); - } - - return MV_FAIL; - -} - -/******************************************************************************* -* mvPciLocalBusNumGet - Get PCI interface local bus number. -* -* DESCRIPTION: -* This function gets the local bus number of a given PCI interface. -* -* INPUT: -* pciIf - PCI interface number. -* -* OUTPUT: -* None. -* -* RETURN: -* Local bus number.0xffffffff on Error -* -*******************************************************************************/ -MV_U32 mvPciIfLocalBusNumGet(MV_U32 pciIf) -{ - PCI_IF_TYPE pciIfType = mvPciIfTypeGet(pciIf); - - if (PCI_IF_TYPE_CONVEN_PCIX == pciIfType) - { - #if defined(MV_INCLUDE_PCI) - return mvPciLocalBusNumGet(pciIf - MV_PCI_START_IF); - #else - return 0xFFFFFFFF; - #endif - } - else if (PCI_IF_TYPE_PEX == pciIfType) - { - #if defined(MV_INCLUDE_PEX) - return mvPexLocalBusNumGet(pciIf - MV_PEX_START_IF); - #else - return 0xFFFFFFFF; - #endif - - } - else - { - mvOsPrintf("%s: ERROR!!! Invalid pciIf %d\n",__FUNCTION__, pciIf); - } - - return 0; - -} - - -/******************************************************************************* -* mvPciLocalDevNumSet - Set PCI interface local device number. -* -* DESCRIPTION: -* This function sets given PCI interface its local device number. -* Note: In case the PCI interface is PCI-X, the information is read-only. -* -* INPUT: -* pciIf - PCI interface number. -* devNum - Device number. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_NOT_ALLOWED in case PCI interface is PCI-X. MV_BAD_PARAM on bad parameters , -* otherwise MV_OK -* -*******************************************************************************/ -MV_STATUS mvPciIfLocalDevNumSet(MV_U32 pciIf, MV_U32 devNum) -{ - PCI_IF_TYPE pciIfType = mvPciIfTypeGet(pciIf); - - if (PCI_IF_TYPE_CONVEN_PCIX == pciIfType) - { - #if defined(MV_INCLUDE_PCI) - return mvPciLocalDevNumSet(pciIf - MV_PCI_START_IF, - devNum); - #else - return MV_OK; - #endif - } - else if (PCI_IF_TYPE_PEX == pciIfType) - { - #if defined(MV_INCLUDE_PEX) - return mvPexLocalDevNumSet(pciIf - MV_PEX_START_IF, - devNum); - #else - return MV_OK; - #endif - } - else - { - mvOsPrintf("%s: ERROR!!! Invalid pciIf %d\n", __FUNCTION__, pciIf); - } - - return MV_FAIL; - -} - -/******************************************************************************* -* mvPciLocalDevNumGet - Get PCI interface local device number. -* -* DESCRIPTION: -* This function gets the local device number of a given PCI interface. -* -* INPUT: -* pciIf - PCI interface number. -* -* OUTPUT: -* None. -* -* RETURN: -* Local device number. 0xffffffff on Error -* -*******************************************************************************/ -MV_U32 mvPciIfLocalDevNumGet(MV_U32 pciIf) -{ - PCI_IF_TYPE pciIfType = mvPciIfTypeGet(pciIf); - - if (PCI_IF_TYPE_CONVEN_PCIX == pciIfType) - { - #if defined(MV_INCLUDE_PCI) - return mvPciLocalDevNumGet(pciIf - MV_PCI_START_IF); - #else - return 0xFFFFFFFF; - #endif - } - else if (PCI_IF_TYPE_PEX == pciIfType) - { - #if defined(MV_INCLUDE_PEX) - return mvPexLocalDevNumGet(pciIf - MV_PEX_START_IF); - #else - return 0xFFFFFFFF; - #endif - - } - else - { - mvOsPrintf("%s: ERROR!!! Invalid pciIf %d\n", __FUNCTION__, pciIf); - } - - return 0; - -} - -/******************************************************************************* -* mvPciIfTypeGet - -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* None. -* -* RETURN: -* -*******************************************************************************/ - -PCI_IF_TYPE mvPciIfTypeGet(MV_U32 pciIf) -{ - - if ((pciIf >= MV_PCI_START_IF)&&(pciIf < MV_PCI_MAX_IF + MV_PCI_START_IF)) - { - return PCI_IF_TYPE_CONVEN_PCIX; - } - else if ((pciIf >= MV_PEX_START_IF) && - (pciIf < MV_PEX_MAX_IF + MV_PEX_START_IF)) - { - return PCI_IF_TYPE_PEX; - - } - else - { - mvOsPrintf("%s: ERROR!!! Invalid pciIf %d\n", __FUNCTION__, pciIf); - } - - return 0xffffffff; - -} - -/******************************************************************************* -* mvPciIfTypeGet - -* -* DESCRIPTION: -* -* INPUT: -* -* OUTPUT: -* None. -* -* RETURN: -* -*******************************************************************************/ - -MV_U32 mvPciRealIfNumGet(MV_U32 pciIf) -{ - - PCI_IF_TYPE pciIfType = mvPciIfTypeGet(pciIf); - - if (PCI_IF_TYPE_CONVEN_PCIX == pciIfType) - { - return (pciIf - MV_PCI_START_IF); - } - else if (PCI_IF_TYPE_PEX == pciIfType) - { - return (pciIf - MV_PEX_START_IF); - - } - else - { - mvOsPrintf("%s: ERROR!!! Invalid pciIf %d\n", __FUNCTION__, pciIf); - } - - return 0xffffffff; - -} - - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pci-if/mvPciIf.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pci-if/mvPciIf.h deleted file mode 100644 index 9c2d160..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pci-if/mvPciIf.h +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCPCIIFH -#define __INCPCIIFH - -#include "mvSysHwConfig.h" -#include "pci-if/mvPciIfRegs.h" -#if defined(MV_INCLUDE_PEX) -#include "pex/mvPex.h" -#endif -#if defined(MV_INCLUDE_PCI) -#include "pci/mvPci.h" -#endif -#include "ctrlEnv/mvCtrlEnvLib.h" -#include "ctrlEnv/mvCtrlEnvAddrDec.h" - -typedef enum _mvPCIIfType -{ - PCI_IF_TYPE_CONVEN_PCIX, - PCI_IF_TYPE_PEX - -}PCI_IF_TYPE; - -typedef enum _mvPCIIfMode -{ - PCI_IF_MODE_HOST, - PCI_IF_MODE_DEVICE -}PCI_IF_MODE; - - -/* Global Functions prototypes */ - -/* mvPciIfInit - Initialize PCI interfaces*/ -MV_STATUS mvPciIfInit(MV_U32 pciIf, PCI_IF_MODE pciIfmode); - -/* mvPciIfConfigRead - Read from configuration space */ -MV_U32 mvPciIfConfigRead (MV_U32 pciIf, MV_U32 bus, MV_U32 dev, - MV_U32 func,MV_U32 regOff); - -/* mvPciIfConfigWrite - Write to configuration space */ -MV_STATUS mvPciIfConfigWrite(MV_U32 pciIf, MV_U32 bus, MV_U32 dev, - MV_U32 func, MV_U32 regOff, MV_U32 data); - -/* mvPciIfMasterEnable - Enable/disale PCI interface master transactions.*/ -MV_STATUS mvPciIfMasterEnable(MV_U32 pciIf, MV_BOOL enable); - -/* mvPciIfSlaveEnable - Enable/disale PCI interface slave transactions.*/ -MV_STATUS mvPciIfSlaveEnable(MV_U32 pciIf,MV_U32 bus, MV_U32 dev, - MV_BOOL enable); - -/* mvPciIfLocalBusNumSet - Set PCI interface local bus number.*/ -MV_STATUS mvPciIfLocalBusNumSet(MV_U32 pciIf, MV_U32 busNum); - -/* mvPciIfLocalBusNumGet - Get PCI interface local bus number.*/ -MV_U32 mvPciIfLocalBusNumGet(MV_U32 pciIf); - -/* mvPciIfLocalDevNumSet - Set PCI interface local device number.*/ -MV_STATUS mvPciIfLocalDevNumSet(MV_U32 pciIf, MV_U32 devNum); - -/* mvPciIfLocalDevNumGet - Get PCI interface local device number.*/ -MV_U32 mvPciIfLocalDevNumGet(MV_U32 pciIf); - -/* mvPciIfTypeGet - Get PCI If type*/ -PCI_IF_TYPE mvPciIfTypeGet(MV_U32 pciIf); - -MV_U32 mvPciRealIfNumGet(MV_U32 pciIf); - -/* mvPciIfAddrDecShow - Display address decode windows attributes */ -MV_VOID mvPciIfAddrDecShow(MV_VOID); - -#endif /* #ifndef __INCPCIIFH */ - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pci-if/mvPciIfRegs.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pci-if/mvPciIfRegs.h deleted file mode 100644 index 08d4d2d..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pci-if/mvPciIfRegs.h +++ /dev/null @@ -1,245 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCPCIIFREGSH -#define __INCPCIIFREGSH - - -/* defines */ -#define MAX_PCI_DEVICES 32 -#define MAX_PCI_FUNCS 8 -#define MAX_PCI_BUSSES 128 - -/***************************************/ -/* PCI Configuration registers */ -/***************************************/ - -/*********************************************/ -/* PCI Configuration, Function 0, Registers */ -/*********************************************/ - - -/* Standard registers */ -#define PCI_DEVICE_AND_VENDOR_ID 0x000 -#define PCI_STATUS_AND_COMMAND 0x004 -#define PCI_CLASS_CODE_AND_REVISION_ID 0x008 -#define PCI_BIST_HDR_TYPE_LAT_TMR_CACHE_LINE 0x00C -#define PCI_MEMORY_BAR_BASE_ADDR(barNum) (0x010 + ((barNum) << 2)) -#define PCI_SUBSYS_ID_AND_SUBSYS_VENDOR_ID 0x02C -#define PCI_EXPANSION_ROM_BASE_ADDR_REG 0x030 -#define PCI_CAPABILTY_LIST_POINTER 0x034 -#define PCI_INTERRUPT_PIN_AND_LINE 0x03C - - -/* PCI Device and Vendor ID Register (PDVIR) */ -#define PDVIR_VEN_ID_OFFS 0 /* Vendor ID */ -#define PDVIR_VEN_ID_MASK (0xffff << PDVIR_VEN_ID_OFFS) - -#define PDVIR_DEV_ID_OFFS 16 /* Device ID */ -#define PDVIR_DEV_ID_MASK (0xffff << PDVIR_DEV_ID_OFFS) - -/* PCI Status and Command Register (PSCR) */ -#define PSCR_IO_EN BIT0 /* IO Enable */ -#define PSCR_MEM_EN BIT1 /* Memory Enable */ -#define PSCR_MASTER_EN BIT2 /* Master Enable */ -#define PSCR_SPECIAL_EN BIT3 /* Special Cycle Enable */ -#define PSCR_MEM_WRI_INV BIT4 /* Memory Write and Invalidate Enable */ -#define PSCR_VGA BIT5 /* VGA Palette Snoops */ -#define PSCR_PERR_EN BIT6 /* Parity Errors Respond Enable */ -#define PSCR_ADDR_STEP BIT7 /* Address Stepping Enable (Wait Cycle En)*/ -#define PSCR_SERR_EN BIT8 /* Ability to assert SERR# line */ -#define PSCR_FAST_BTB_EN BIT9 /* generate fast back-to-back transactions*/ -#define PSCR_CAP_LIST BIT20 /* Capability List Support */ -#define PSCR_66MHZ_EN BIT21 /* 66 MHz Capable */ -#define PSCR_UDF_EN BIT22 /* User definable features */ -#define PSCR_TAR_FAST_BB BIT23 /* fast back-to-back transactions capable */ -#define PSCR_DATA_PERR BIT24 /* Data Parity reported */ - -#define PSCR_DEVSEL_TIM_OFFS 25 /* DEVSEL timing */ -#define PSCR_DEVSEL_TIM_MASK (0x3 << PSCR_DEVSEL_TIM_OFFS) -#define PSCR_DEVSEL_TIM_FAST (0x0 << PSCR_DEVSEL_TIM_OFFS) -#define PSCR_DEVSEL_TIM_MED (0x1 << PSCR_DEVSEL_TIM_OFFS) -#define PSCR_DEVSEL_TIM_SLOW (0x2 << PSCR_DEVSEL_TIM_OFFS) - -#define PSCR_SLAVE_TABORT BIT27 /* Signalled Target Abort */ -#define PSCR_MASTER_TABORT BIT28 /* Recieved Target Abort */ -#define PSCR_MABORT BIT29 /* Recieved Master Abort */ -#define PSCR_SYSERR BIT30 /* Signalled system error */ -#define PSCR_DET_PARERR BIT31 /* Detect Parity Error */ - -/* PCI configuration register offset=0x08 fields - (PCI_CLASS_CODE_AND_REVISION_ID)(PCCRI) */ - -#define PCCRIR_REVID_OFFS 0 /* Revision ID */ -#define PCCRIR_REVID_MASK (0xff << PCCRIR_REVID_OFFS) - -#define PCCRIR_FULL_CLASS_OFFS 8 /* Full Class Code */ -#define PCCRIR_FULL_CLASS_MASK (0xffffff << PCCRIR_FULL_CLASS_OFFS) - -#define PCCRIR_PROGIF_OFFS 8 /* Prog .I/F*/ -#define PCCRIR_PROGIF_MASK (0xff << PCCRIR_PROGIF_OFFS) - -#define PCCRIR_SUB_CLASS_OFFS 16 /* Sub Class*/ -#define PCCRIR_SUB_CLASS_MASK (0xff << PCCRIR_SUB_CLASS_OFFS) - -#define PCCRIR_BASE_CLASS_OFFS 24 /* Base Class*/ -#define PCCRIR_BASE_CLASS_MASK (0xff << PCCRIR_BASE_CLASS_OFFS) - -/* PCI configuration register offset=0x0C fields - (PCI_BIST_HEADER_TYPE_LATENCY_TIMER_CACHE_LINE)(PBHTLTCL) */ - -#define PBHTLTCLR_CACHELINE_OFFS 0 /* Specifies the cache line size */ -#define PBHTLTCLR_CACHELINE_MASK (0xff << PBHTLTCLR_CACHELINE_OFFS) - -#define PBHTLTCLR_LATTIMER_OFFS 8 /* latency timer */ -#define PBHTLTCLR_LATTIMER_MASK (0xff << PBHTLTCLR_LATTIMER_OFFS) - -#define PBHTLTCLR_HEADTYPE_FULL_OFFS 16 /* Full Header Type */ -#define PBHTLTCLR_HEADTYPE_FULL_MASK (0xff << PBHTLTCLR_HEADTYPE_FULL_OFFS) - -#define PBHTLTCLR_MULTI_FUNC BIT23 /* Multi/Single function */ - -#define PBHTLTCLR_HEADER_OFFS 16 /* Header type */ -#define PBHTLTCLR_HEADER_MASK (0x7f << PBHTLTCLR_HEADER_OFFS) -#define PBHTLTCLR_HEADER_STANDARD (0x0 << PBHTLTCLR_HEADER_OFFS) -#define PBHTLTCLR_HEADER_PCI2PCI_BRIDGE (0x1 << PBHTLTCLR_HEADER_OFFS) - - -#define PBHTLTCLR_BISTCOMP_OFFS 24 /* BIST Completion Code */ -#define PBHTLTCLR_BISTCOMP_MASK (0xf << PBHTLTCLR_BISTCOMP_OFFS) - -#define PBHTLTCLR_BISTACT BIT30 /* BIST Activate bit */ -#define PBHTLTCLR_BISTCAP BIT31 /* BIST Capable Bit */ - - -/* PCI Bar Base Low Register (PBBLR) */ -#define PBBLR_IOSPACE BIT0 /* Memory Space Indicator */ - -#define PBBLR_TYPE_OFFS 1 /* BAR Type/Init Val. */ -#define PBBLR_TYPE_MASK (0x3 << PBBLR_TYPE_OFFS) -#define PBBLR_TYPE_32BIT_ADDR (0x0 << PBBLR_TYPE_OFFS) -#define PBBLR_TYPE_64BIT_ADDR (0x2 << PBBLR_TYPE_OFFS) - -#define PBBLR_PREFETCH_EN BIT3 /* Prefetch Enable */ - - -#define PBBLR_MEM_BASE_OFFS 4 /* Memory Bar Base address. Corresponds to - address bits [31:4] */ -#define PBBLR_MEM_BASE_MASK (0xfffffff << PBBLR_MEM_BASE_OFFS) - -#define PBBLR_IO_BASE_OFFS 2 /* IO Bar Base address. Corresponds to - address bits [31:2] */ -#define PBBLR_IO_BASE_MASK (0x3fffffff << PBBLR_IO_BASE_OFFS) - - -#define PBBLR_BASE_OFFS 12 /* Base address. Address bits [31:12] */ -#define PBBLR_BASE_MASK (0xfffff << PBBLR_BASE_OFFS) -#define PBBLR_BASE_ALIGNMET (1 << PBBLR_BASE_OFFS) - - -/* PCI Bar Base High Fegister (PBBHR) */ -#define PBBHR_BASE_OFFS 0 /* Base address. Address bits [31:12] */ -#define PBBHR_BASE_MASK (0xffffffff << PBBHR_BASE_OFFS) - - -/* PCI configuration register offset=0x2C fields - (PCI_SUBSYSTEM_ID_AND_SUBSYSTEM_VENDOR_ID)(PSISVI) */ - -#define PSISVIR_VENID_OFFS 0 /* Subsystem Manufacturer Vendor ID Number */ -#define PSISVIR_VENID_MASK (0xffff << PSISVIR_VENID_OFFS) - -#define PSISVIR_DEVID_OFFS 16 /* Subsystem Device ID Number */ -#define PSISVIR_DEVID_MASK (0xffff << PSISVIR_DEVID_OFFS) - -/* PCI configuration register offset=0x30 fields - (PCI_EXPANSION_ROM_BASE_ADDR_REG)(PERBA) */ - -#define PERBAR_EXPROMEN BIT0 /* Expansion ROM Enable */ - -#define PERBAR_BASE_OFFS 12 /* Expansion ROM Base Address */ -#define PERBAR_BASE_MASK (0xfffff << PERBAR_BASE_OFFS) - -/* PCI configuration register offset=0x34 fields - (PCI_CAPABILTY_LIST_POINTER)(PCLP) */ - -#define PCLPR_CAPPTR_OFFS 0 /* Capability List Pointer */ -#define PCLPR_CAPPTR_MASK (0xff << PCLPR_CAPPTR_OFFS) - -/* PCI configuration register offset=0x3C fields - (PCI_INTERRUPT_PIN_AND_LINE)(PIPL) */ - -#define PIPLR_INTLINE_OFFS 0 /* Interrupt line (IRQ) */ -#define PIPLR_INTLINE_MASK (0xff << PIPLR_INTLINE_OFFS) - -#define PIPLR_INTPIN_OFFS 8 /* interrupt pin (A,B,C,D) */ -#define PIPLR_INTPIN_MASK (0xff << PIPLR_INTPIN_OFFS) - -#define PIPLR_MINGRANT_OFFS 16 /* Minimum Grant on 250 nano seconds units */ -#define PIPLR_MINGRANT_MASK (0xff << PIPLR_MINGRANT_OFFS) - -#define PIPLR_MAXLATEN_OFFS 24 /* Maximum latency on 250 nano seconds units */ -#define PIPLR_MAXLATEN_MASK (0xff << PIPLR_MAXLATEN_OFFS) - -#endif /* #ifndef __INCPCIIFREGSH */ - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pci-if/pci_util/mvPciUtils.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pci-if/pci_util/mvPciUtils.c deleted file mode 100644 index f216979..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pci-if/pci_util/mvPciUtils.c +++ /dev/null @@ -1,1006 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -/* includes */ -#include "mvPciUtils.h" - -#include "ctrlEnv/mvCtrlEnvLib.h" - -/* #define MV_DEBUG */ -/* defines */ -#ifdef MV_DEBUG - #define DB(x) x - #define mvOsPrintf printf -#else - #define DB(x) -#endif - -/* -This module only support scanning of Header type 00h of pci devices -There is no suppotr for Header type 01h of pci devices ( PCI bridges ) -*/ - - -static MV_STATUS pciDetectDevice(MV_U32 pciIf, - MV_U32 bus, - MV_U32 dev, - MV_U32 func, - MV_PCI_DEVICE *pPciAgent); - -static MV_U32 pciDetectDeviceBars(MV_U32 pciIf, - MV_U32 bus, - MV_U32 dev, - MV_U32 func, - MV_PCI_DEVICE *pPciAgent); - - - - - - -/******************************************************************************* -* mvPciScan - Scan a PCI interface bus -* -* DESCRIPTION: -* Performs a full scan on a PCI interface and returns all possible details -* on the agents found on the bus. -* -* INPUT: -* pciIf - PCI Interface -* pPciAgents - Pointer to an Array of the pci agents to be detected -* pPciAgentsNum - pPciAgents array maximum number of elements -* -* OUTPUT: -* pPciAgents - Array of the pci agents detected on the bus -* pPciAgentsNum - Number of pci agents detected on the bus -* -* RETURN: -* MV_BAD_PARAM for bad parameters ,MV_ERROR on error ! otherwise MV_OK -* -*******************************************************************************/ - -MV_STATUS mvPciScan(MV_U32 pciIf, - MV_PCI_DEVICE *pPciAgents, - MV_U32 *pPciAgentsNum) -{ - - MV_U32 devIndex,funcIndex=0,busIndex=0,detectedDevNum=0; - MV_U32 localBus=mvPciIfLocalBusNumGet(pciIf); - MV_PCI_DEVICE *pPciDevice; - MV_PCI_DEVICE *pMainDevice; - - DB(mvOsPrintf("mvPciScan: PCI interface num %d\n", pciIf)); - /* Parameter checking */ - if (pciIf >= mvCtrlPexMaxIfGet()) - { - DB(mvOsPrintf("mvPciScan: ERR. Invalid PCI interface num %d\n", pciIf)); - return MV_BAD_PARAM; - } - if (NULL == pPciAgents) - { - DB(mvOsPrintf("mvPciScan: ERR. pPciAgents=NULL \n")); - return MV_BAD_PARAM; - } - if (NULL == pPciAgentsNum) - { - DB(mvOsPrintf("mvPciScan: ERR. pPciAgentsNum=NULL \n")); - return MV_BAD_PARAM; - } - - - DB(mvOsPrintf("mvPciScan: PCI interface num %d mvPciMasterEnable\n", pciIf)); - /* Master enable the MV PCI master */ - if (MV_OK != mvPciIfMasterEnable(pciIf,MV_TRUE)) - { - DB(mvOsPrintf("mvPciScan: ERR. mvPciMasterEnable failed \n")); - return MV_ERROR; - - } - - DB(mvOsPrintf("mvPciScan: PCI interface num scan%d\n", pciIf)); - - /* go through all busses */ - for (busIndex=localBus ; busIndex < MAX_PCI_BUSSES ; busIndex++) - { - /* go through all possible devices on the local bus */ - for (devIndex=0 ; devIndex < MAX_PCI_DEVICES ; devIndex++) - { - /* always start with function equal to zero */ - funcIndex=0; - - pPciDevice=&pPciAgents[detectedDevNum]; - DB(mvOsPrintf("mvPciScan: PCI interface num scan%d:%d\n", busIndex, devIndex)); - - if (MV_ERROR == pciDetectDevice(pciIf, - busIndex, - devIndex, - funcIndex, - pPciDevice)) - { - /* no device detected , try the next address */ - continue; - } - - /* We are here ! means we have detected a device*/ - /* always we start with only one function per device */ - pMainDevice = pPciDevice; - pPciDevice->funtionsNum = 1; - - - /* move on */ - detectedDevNum++; - - - /* check if we have no more room for a new device */ - if (detectedDevNum == *pPciAgentsNum) - { - DB(mvOsPrintf("mvPciScan: ERR. array passed too small \n")); - return MV_ERROR; - } - - /* check the detected device if it is a multi functional device then - scan all device functions*/ - if (pPciDevice->isMultiFunction == MV_TRUE) - { - /* start with function number 1 because we have already detected - function 0 */ - for (funcIndex=1; funcIndex<MAX_PCI_FUNCS ; funcIndex++) - { - pPciDevice=&pPciAgents[detectedDevNum]; - - if (MV_ERROR == pciDetectDevice(pciIf, - busIndex, - devIndex, - funcIndex, - pPciDevice)) - { - /* no device detected means no more functions !*/ - continue; - } - /* We are here ! means we have detected a device */ - - /* move on */ - pMainDevice->funtionsNum++; - detectedDevNum++; - - /* check if we have no more room for a new device */ - if (detectedDevNum == *pPciAgentsNum) - { - DB(mvOsPrintf("mvPciScan: ERR. Array too small\n")); - return MV_ERROR; - } - - - } - } - - } - - } - - /* return the number of devices actually detected on the bus ! */ - *pPciAgentsNum = detectedDevNum; - - return MV_OK; - -} - - -/******************************************************************************* -* pciDetectDevice - Detect a pci device parameters -* -* DESCRIPTION: -* This function detect if a pci agent exist on certain address ! -* and if exists then it fills all possible information on the -* agent -* -* INPUT: -* pciIf - PCI Interface -* bus - Bus number -* dev - Device number -* func - Function number -* -* -* -* OUTPUT: -* pPciAgent - pointer to the pci agent filled with its information -* -* RETURN: -* MV_ERROR if no device , MV_OK otherwise -* -*******************************************************************************/ - -static MV_STATUS pciDetectDevice(MV_U32 pciIf, - MV_U32 bus, - MV_U32 dev, - MV_U32 func, - MV_PCI_DEVICE *pPciAgent) -{ - MV_U32 pciData; - - /* no Parameters checking ! because it is static function and it is assumed - that all parameters were checked in the calling function */ - - - /* Try read the PCI Vendor ID and Device ID */ - - /* We will scan only ourselves and the PCI slots that exist on the - board, because we may have a case that we have one slot that has - a Cardbus connector, and because CardBus answers all IDsels we want - to scan only this slot and ourseleves. - - */ - #if defined(MV_INCLUDE_PCI) - if ((PCI_IF_TYPE_CONVEN_PCIX == mvPciIfTypeGet(pciIf)) && - (DB_88F5181_DDR1_PRPMC != mvBoardIdGet()) && - (DB_88F5181_DDR1_PEXPCI != mvBoardIdGet()) && - (DB_88F5181_DDR1_MNG != mvBoardIdGet())) - { - - if (mvBoardIsOurPciSlot(bus, dev) == MV_FALSE) - { - return MV_ERROR; - } - } - #endif /* defined(MV_INCLUDE_PCI) */ - - pciData = mvPciIfConfigRead(pciIf, bus,dev,func, PCI_DEVICE_AND_VENDOR_ID); - - if (PCI_ERROR_CODE == pciData) - { - /* no device exist */ - return MV_ERROR; - } - - /* we are here ! means a device is detected */ - - /* fill basic information */ - pPciAgent->busNumber=bus; - pPciAgent->deviceNum=dev; - pPciAgent->function=func; - - /* Fill the PCI Vendor ID and Device ID */ - - pPciAgent->venID = (pciData & PDVIR_VEN_ID_MASK) >> PDVIR_VEN_ID_OFFS; - pPciAgent->deviceID = (pciData & PDVIR_DEV_ID_MASK) >> PDVIR_DEV_ID_OFFS; - - /* Read Status and command */ - pciData = mvPciIfConfigRead(pciIf, - bus,dev,func, - PCI_STATUS_AND_COMMAND); - - - /* Fill related Status and Command information*/ - - if (pciData & PSCR_TAR_FAST_BB) - { - pPciAgent->isFastB2BCapable = MV_TRUE; - } - else - { - pPciAgent->isFastB2BCapable = MV_FALSE; - } - - if (pciData & PSCR_CAP_LIST) - { - pPciAgent->isCapListSupport=MV_TRUE; - } - else - { - pPciAgent->isCapListSupport=MV_FALSE; - } - - if (pciData & PSCR_66MHZ_EN) - { - pPciAgent->is66MHZCapable=MV_TRUE; - } - else - { - pPciAgent->is66MHZCapable=MV_FALSE; - } - - /* Read Class Code and Revision */ - pciData = mvPciIfConfigRead(pciIf, - bus,dev,func, - PCI_CLASS_CODE_AND_REVISION_ID); - - - pPciAgent->baseClassCode = - (pciData & PCCRIR_BASE_CLASS_MASK) >> PCCRIR_BASE_CLASS_OFFS; - - pPciAgent->subClassCode = - (pciData & PCCRIR_SUB_CLASS_MASK) >> PCCRIR_SUB_CLASS_OFFS; - - pPciAgent->progIf = - (pciData & PCCRIR_PROGIF_MASK) >> PCCRIR_PROGIF_OFFS; - - pPciAgent->revisionID = - (pciData & PCCRIR_REVID_MASK) >> PCCRIR_REVID_OFFS; - - /* Read PCI_BIST_HDR_TYPE_LAT_TMR_CACHE_LINE */ - pciData = mvPciIfConfigRead(pciIf, - bus,dev,func, - PCI_BIST_HDR_TYPE_LAT_TMR_CACHE_LINE); - - - - pPciAgent->pciCacheLine= - (pciData & PBHTLTCLR_CACHELINE_MASK ) >> PBHTLTCLR_CACHELINE_OFFS; - pPciAgent->pciLatencyTimer= - (pciData & PBHTLTCLR_LATTIMER_MASK) >> PBHTLTCLR_LATTIMER_OFFS; - - switch (pciData & PBHTLTCLR_HEADER_MASK) - { - case PBHTLTCLR_HEADER_STANDARD: - - pPciAgent->pciHeader=MV_PCI_STANDARD; - break; - case PBHTLTCLR_HEADER_PCI2PCI_BRIDGE: - - pPciAgent->pciHeader=MV_PCI_PCI2PCI_BRIDGE; - break; - - } - - if (pciData & PBHTLTCLR_MULTI_FUNC) - { - pPciAgent->isMultiFunction=MV_TRUE; - } - else - { - pPciAgent->isMultiFunction=MV_FALSE; - } - - if (pciData & PBHTLTCLR_BISTCAP) - { - pPciAgent->isBISTCapable=MV_TRUE; - } - else - { - pPciAgent->isBISTCapable=MV_FALSE; - } - - - /* read this device pci bars */ - - pciDetectDeviceBars(pciIf, - bus,dev,func, - pPciAgent); - - - /* check if we are bridge*/ - if ((pPciAgent->baseClassCode == PCI_BRIDGE_CLASS)&& - (pPciAgent->subClassCode == P2P_BRIDGE_SUB_CLASS_CODE)) - { - - /* Read P2P_BUSSES_NUM */ - pciData = mvPciIfConfigRead(pciIf, - bus,dev,func, - P2P_BUSSES_NUM); - - pPciAgent->p2pPrimBusNum = - (pciData & PBM_PRIME_BUS_NUM_MASK) >> PBM_PRIME_BUS_NUM_OFFS; - - pPciAgent->p2pSecBusNum = - (pciData & PBM_SEC_BUS_NUM_MASK) >> PBM_SEC_BUS_NUM_OFFS; - - pPciAgent->p2pSubBusNum = - (pciData & PBM_SUB_BUS_NUM_MASK) >> PBM_SUB_BUS_NUM_OFFS; - - pPciAgent->p2pSecLatencyTimer = - (pciData & PBM_SEC_LAT_TMR_MASK) >> PBM_SEC_LAT_TMR_OFFS; - - /* Read P2P_IO_BASE_LIMIT_SEC_STATUS */ - pciData = mvPciIfConfigRead(pciIf, - bus,dev,func, - P2P_IO_BASE_LIMIT_SEC_STATUS); - - pPciAgent->p2pSecStatus = - (pciData & PIBLSS_SEC_STATUS_MASK) >> PIBLSS_SEC_STATUS_OFFS; - - - pPciAgent->p2pIObase = - (pciData & PIBLSS_IO_BASE_MASK) << PIBLSS_IO_LIMIT_OFFS; - - /* clear low address (should be zero)*/ - pPciAgent->p2pIObase &= PIBLSS_HIGH_ADDR_MASK; - - pPciAgent->p2pIOLimit = - (pciData & PIBLSS_IO_LIMIT_MASK); - - /* fill low address with 0xfff */ - pPciAgent->p2pIOLimit |= PIBLSS_LOW_ADDR_MASK; - - - switch ((pciData & PIBLSS_ADD_CAP_MASK) >> PIBLSS_ADD_CAP_OFFS) - { - case PIBLSS_ADD_CAP_16BIT: - - pPciAgent->bIO32 = MV_FALSE; - - break; - case PIBLSS_ADD_CAP_32BIT: - - pPciAgent->bIO32 = MV_TRUE; - - /* Read P2P_IO_BASE_LIMIT_UPPER_16 */ - pciData = mvPciIfConfigRead(pciIf, - bus,dev,func, - P2P_IO_BASE_LIMIT_UPPER_16); - - pPciAgent->p2pIObase |= - (pciData & PRBU_IO_UPP_BASE_MASK) << PRBU_IO_UPP_LIMIT_OFFS; - - - pPciAgent->p2pIOLimit |= - (pciData & PRBU_IO_UPP_LIMIT_MASK); - - break; - - } - - - /* Read P2P_MEM_BASE_LIMIT */ - pciData = mvPciIfConfigRead(pciIf, - bus,dev,func, - P2P_MEM_BASE_LIMIT); - - pPciAgent->p2pMemBase = - (pciData & PMBL_MEM_BASE_MASK) << PMBL_MEM_LIMIT_OFFS; - - /* clear low address */ - pPciAgent->p2pMemBase &= PMBL_HIGH_ADDR_MASK; - - pPciAgent->p2pMemLimit = - (pciData & PMBL_MEM_LIMIT_MASK); - - /* add 0xfffff */ - pPciAgent->p2pMemLimit |= PMBL_LOW_ADDR_MASK; - - - /* Read P2P_PREF_MEM_BASE_LIMIT */ - pciData = mvPciIfConfigRead(pciIf, - bus,dev,func, - P2P_PREF_MEM_BASE_LIMIT); - - - pPciAgent->p2pPrefMemBase = - (pciData & PRMBL_PREF_MEM_BASE_MASK) << PRMBL_PREF_MEM_LIMIT_OFFS; - - /* get high address only */ - pPciAgent->p2pPrefMemBase &= PRMBL_HIGH_ADDR_MASK; - - - - pPciAgent->p2pPrefMemLimit = - (pciData & PRMBL_PREF_MEM_LIMIT_MASK); - - /* add 0xfffff */ - pPciAgent->p2pPrefMemLimit |= PRMBL_LOW_ADDR_MASK; - - switch (pciData & PRMBL_ADD_CAP_MASK) - { - case PRMBL_ADD_CAP_32BIT: - - pPciAgent->bPrefMem64 = MV_FALSE; - - /* Read P2P_PREF_BASE_UPPER_32 */ - pPciAgent->p2pPrefBaseUpper32Bits = 0; - - /* Read P2P_PREF_LIMIT_UPPER_32 */ - pPciAgent->p2pPrefLimitUpper32Bits = 0; - - break; - case PRMBL_ADD_CAP_64BIT: - - pPciAgent->bPrefMem64 = MV_TRUE; - - /* Read P2P_PREF_BASE_UPPER_32 */ - pPciAgent->p2pPrefBaseUpper32Bits = mvPciIfConfigRead(pciIf, - bus,dev,func, - P2P_PREF_BASE_UPPER_32); - - /* Read P2P_PREF_LIMIT_UPPER_32 */ - pPciAgent->p2pPrefLimitUpper32Bits = mvPciIfConfigRead(pciIf, - bus,dev,func, - P2P_PREF_LIMIT_UPPER_32); - - break; - - } - - } - else /* no bridge */ - { - /* Read PCI_SUBSYS_ID_AND_SUBSYS_VENDOR_ID */ - pciData = mvPciIfConfigRead(pciIf, - bus,dev,func, - PCI_SUBSYS_ID_AND_SUBSYS_VENDOR_ID); - - - pPciAgent->subSysVenID = - (pciData & PSISVIR_VENID_MASK) >> PSISVIR_VENID_OFFS; - pPciAgent->subSysID = - (pciData & PSISVIR_DEVID_MASK) >> PSISVIR_DEVID_OFFS; - - - /* Read PCI_EXPANSION_ROM_BASE_ADDR_REG */ - pciData = mvPciIfConfigRead(pciIf, - bus,dev,func, - PCI_EXPANSION_ROM_BASE_ADDR_REG); - - - if (pciData & PERBAR_EXPROMEN) - { - pPciAgent->isExpRom = MV_TRUE; - } - else - { - pPciAgent->isExpRom = MV_FALSE; - } - - pPciAgent->expRomAddr = - (pciData & PERBAR_BASE_MASK) >> PERBAR_BASE_OFFS; - - } - - - if (MV_TRUE == pPciAgent->isCapListSupport) - { - /* Read PCI_CAPABILTY_LIST_POINTER */ - pciData = mvPciIfConfigRead(pciIf, - bus,dev,func, - PCI_CAPABILTY_LIST_POINTER); - - pPciAgent->capListPointer = - (pciData & PCLPR_CAPPTR_MASK) >> PCLPR_CAPPTR_OFFS; - - } - - /* Read PCI_INTERRUPT_PIN_AND_LINE */ - pciData = mvPciIfConfigRead(pciIf, - bus,dev,func, - PCI_INTERRUPT_PIN_AND_LINE); - - - pPciAgent->irqLine= - (pciData & PIPLR_INTLINE_MASK) >> PIPLR_INTLINE_OFFS; - - pPciAgent->intPin= - (MV_PCI_INT_PIN)(pciData & PIPLR_INTPIN_MASK) >> PIPLR_INTPIN_OFFS; - - pPciAgent->minGrant= - (pciData & PIPLR_MINGRANT_MASK) >> PIPLR_MINGRANT_OFFS; - pPciAgent->maxLatency= - (pciData & PIPLR_MAXLATEN_MASK) >> PIPLR_MAXLATEN_OFFS; - - mvPciClassNameGet(pPciAgent->baseClassCode, - (MV_8 *)pPciAgent->type); - - return MV_OK; - - -} - -/******************************************************************************* -* pciDetectDeviceBars - Detect a pci device bars -* -* DESCRIPTION: -* This function detects all pci agent bars -* -* INPUT: -* pciIf - PCI Interface -* bus - Bus number -* dev - Device number -* func - Function number -* -* -* -* OUTPUT: -* pPciAgent - pointer to the pci agent filled with its information -* -* RETURN: -* detected bars number -* -*******************************************************************************/ -static MV_U32 pciDetectDeviceBars(MV_U32 pciIf, - MV_U32 bus, - MV_U32 dev, - MV_U32 func, - MV_PCI_DEVICE *pPciAgent) -{ - MV_U32 pciData,barIndex,detectedBar=0; - MV_U32 tmpBaseHigh=0,tmpBaseLow=0; - MV_U32 pciMaxBars=0; - - pPciAgent->barsNum=0; - - /* check if we are bridge*/ - if ((pPciAgent->baseClassCode == PCI_BRIDGE_CLASS)&& - (pPciAgent->subClassCode == P2P_BRIDGE_SUB_CLASS_CODE)) - { - pciMaxBars = 2; - } - else /* no bridge */ - { - pciMaxBars = 6; - } - - /* read this device pci bars */ - for (barIndex = 0 ; barIndex < pciMaxBars ; barIndex++ ) - { - /* Read PCI_MEMORY_BAR_BASE_ADDR */ - tmpBaseLow = pciData = mvPciIfConfigRead(pciIf, - bus,dev,func, - PCI_MEMORY_BAR_BASE_ADDR(barIndex)); - - pPciAgent->pciBar[detectedBar].barOffset = - PCI_MEMORY_BAR_BASE_ADDR(barIndex); - - /* check if the bar is 32bit or 64bit bar */ - switch (pciData & PBBLR_TYPE_MASK) - { - case PBBLR_TYPE_32BIT_ADDR: - pPciAgent->pciBar[detectedBar].barType = PCI_32BIT_BAR; - break; - case PBBLR_TYPE_64BIT_ADDR: - pPciAgent->pciBar[detectedBar].barType = PCI_64BIT_BAR; - break; - - } - - /* check if it is memory or IO bar */ - if (pciData & PBBLR_IOSPACE) - { - pPciAgent->pciBar[detectedBar].barMapping=PCI_IO_BAR; - } - else - { - pPciAgent->pciBar[detectedBar].barMapping=PCI_MEMORY_BAR; - } - - /* if it is memory bar then check if it is prefetchable */ - if (PCI_MEMORY_BAR == pPciAgent->pciBar[detectedBar].barMapping) - { - if (pciData & PBBLR_PREFETCH_EN) - { - pPciAgent->pciBar[detectedBar].isPrefetchable = MV_TRUE; - } - else - { - pPciAgent->pciBar[detectedBar].isPrefetchable = MV_FALSE; - } - - pPciAgent->pciBar[detectedBar].barBaseLow = - pciData & PBBLR_MEM_BASE_MASK; - - - } - else /* IO Bar */ - { - pPciAgent->pciBar[detectedBar].barBaseLow = - pciData & PBBLR_IO_BASE_MASK; - - } - - pPciAgent->pciBar[detectedBar].barBaseHigh=0; - - if (PCI_64BIT_BAR == pPciAgent->pciBar[detectedBar].barType) - { - barIndex++; - - tmpBaseHigh = pPciAgent->pciBar[detectedBar].barBaseHigh = - mvPciIfConfigRead(pciIf, - bus,dev,func, - PCI_MEMORY_BAR_BASE_ADDR(barIndex)); - - - } - - /* calculating full base address (64bit) */ - pPciAgent->pciBar[detectedBar].barBaseAddr = - (MV_U64)pPciAgent->pciBar[detectedBar].barBaseHigh; - - pPciAgent->pciBar[detectedBar].barBaseAddr <<= 32; - - pPciAgent->pciBar[detectedBar].barBaseAddr |= - (MV_U64)pPciAgent->pciBar[detectedBar].barBaseLow; - - - - /* get the sizes of the the bar */ - - pPciAgent->pciBar[detectedBar].barSizeHigh=0; - - if ((PCI_64BIT_BAR == pPciAgent->pciBar[detectedBar].barType) && - (PCI_MEMORY_BAR == pPciAgent->pciBar[detectedBar].barMapping)) - - { - /* write oxffffffff to the bar to get the size */ - /* start with sizelow ( original value was saved in tmpBaseLow ) */ - mvPciIfConfigWrite(pciIf, - bus,dev,func, - PCI_MEMORY_BAR_BASE_ADDR(barIndex-1), - 0xffffffff); - - /* read size */ - pPciAgent->pciBar[detectedBar].barSizeLow = - mvPciIfConfigRead(pciIf, - bus,dev,func, - PCI_MEMORY_BAR_BASE_ADDR(barIndex-1)); - - - - /* restore original value */ - mvPciIfConfigWrite(pciIf, - bus,dev,func, - PCI_MEMORY_BAR_BASE_ADDR(barIndex-1), - tmpBaseLow); - - - /* now do the same for BaseHigh */ - - /* write oxffffffff to the bar to get the size */ - mvPciIfConfigWrite(pciIf, - bus,dev,func, - PCI_MEMORY_BAR_BASE_ADDR(barIndex), - 0xffffffff); - - /* read size */ - pPciAgent->pciBar[detectedBar].barSizeHigh = - mvPciIfConfigRead(pciIf, - bus,dev,func, - PCI_MEMORY_BAR_BASE_ADDR(barIndex)); - - /* restore original value */ - mvPciIfConfigWrite(pciIf, - bus,dev,func, - PCI_MEMORY_BAR_BASE_ADDR(barIndex), - tmpBaseHigh); - - if ((0 == pPciAgent->pciBar[detectedBar].barSizeLow)&& - (0 == pPciAgent->pciBar[detectedBar].barSizeHigh)) - { - /* this bar is not applicable for this device, - ignore all previous settings and check the next bar*/ - - /* we though this was a 64bit bar , and it seems this - was wrong ! so decrement barIndex */ - barIndex--; - continue; - } - - /* calculate the full 64 bit size */ - - if (0 != pPciAgent->pciBar[detectedBar].barSizeHigh) - { - pPciAgent->pciBar[detectedBar].barSizeLow &= PBBLR_MEM_BASE_MASK; - - pPciAgent->pciBar[detectedBar].barSizeLow = - ~pPciAgent->pciBar[detectedBar].barSizeLow + 1; - - pPciAgent->pciBar[detectedBar].barSizeHigh = 0; - - } - else - { - - pPciAgent->pciBar[detectedBar].barSizeLow &= PBBLR_MEM_BASE_MASK; - - pPciAgent->pciBar[detectedBar].barSizeLow = - ~pPciAgent->pciBar[detectedBar].barSizeLow + 1; - - pPciAgent->pciBar[detectedBar].barSizeHigh = 0; - - } - - - - } - else /* 32bit bar */ - { - /* write oxffffffff to the bar to get the size */ - mvPciIfConfigWrite(pciIf, - bus,dev,func, - PCI_MEMORY_BAR_BASE_ADDR(barIndex), - 0xffffffff); - - /* read size */ - pPciAgent->pciBar[detectedBar].barSizeLow = - mvPciIfConfigRead(pciIf, - bus,dev,func, - PCI_MEMORY_BAR_BASE_ADDR(barIndex)); - - if (0 == pPciAgent->pciBar[detectedBar].barSizeLow) - { - /* this bar is not applicable for this device, - ignore all previous settings and check the next bar*/ - continue; - } - - - /* restore original value */ - mvPciIfConfigWrite(pciIf, - bus,dev,func, - PCI_MEMORY_BAR_BASE_ADDR(barIndex), - tmpBaseLow); - - /* calculate size low */ - - if (PCI_MEMORY_BAR == pPciAgent->pciBar[detectedBar].barMapping) - { - pPciAgent->pciBar[detectedBar].barSizeLow &= PBBLR_MEM_BASE_MASK; - } - else - { - pPciAgent->pciBar[detectedBar].barSizeLow &= PBBLR_IO_BASE_MASK; - } - - pPciAgent->pciBar[detectedBar].barSizeLow = - ~pPciAgent->pciBar[detectedBar].barSizeLow + 1; - - pPciAgent->pciBar[detectedBar].barSizeHigh = 0; - pPciAgent->pciBar[detectedBar].barSize = - (MV_U64)pPciAgent->pciBar[detectedBar].barSizeLow; - - - } - - /* we are here ! this means we have already detected a bar for - this device , now move on */ - - detectedBar++; - pPciAgent->barsNum++; - } - - return detectedBar; -} - - -/******************************************************************************* -* mvPciClassNameGet - get PCI class name -* -* DESCRIPTION: -* This function returns the PCI class name -* -* INPUT: -* baseClassCode - Base Class Code. -* -* OUTPUT: -* pType - the class name -* -* RETURN: -* MV_BAD_PARAM for bad parameters ,MV_ERROR on error ! otherwise MV_OK -* -*******************************************************************************/ -MV_STATUS mvPciClassNameGet(MV_U32 baseClassCode, MV_8 *pType) -{ - - switch(baseClassCode) - { - case 0x0: - strcpy(pType,"Old generation device"); - break; - case 0x1: - strcpy(pType,"Mass storage controller"); - break; - case 0x2: - strcpy(pType,"Network controller"); - break; - case 0x3: - strcpy(pType,"Display controller"); - break; - case 0x4: - strcpy(pType,"Multimedia device"); - break; - case 0x5: - strcpy(pType,"Memory controller"); - break; - case 0x6: - strcpy(pType,"Bridge Device"); - break; - case 0x7: - strcpy(pType,"Simple Communication controllers"); - break; - case 0x8: - strcpy(pType,"Base system peripherals"); - break; - case 0x9: - strcpy(pType,"Input Devices"); - break; - case 0xa: - strcpy(pType,"Docking stations"); - break; - case 0xb: - strcpy(pType,"Processors"); - break; - case 0xc: - strcpy(pType,"Serial bus controllers"); - break; - case 0xd: - strcpy(pType,"Wireless controllers"); - break; - case 0xe: - strcpy(pType,"Intelligent I/O controllers"); - break; - case 0xf: - strcpy(pType,"Satellite communication controllers"); - break; - case 0x10: - strcpy(pType,"Encryption/Decryption controllers"); - break; - case 0x11: - strcpy(pType,"Data acquisition and signal processing controllers"); - break; - default: - strcpy(pType,"Unknown device"); - break; - } - - return MV_OK; - -} - - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pci-if/pci_util/mvPciUtils.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pci-if/pci_util/mvPciUtils.h deleted file mode 100644 index 2ee0b17..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pci-if/pci_util/mvPciUtils.h +++ /dev/null @@ -1,323 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCmvPciUtilsh -#define __INCmvPciUtilsh - -/* -This module only support scanning of Header type 00h of pci devices -There is no suppotr for Header type 01h of pci devices ( PCI bridges ) -*/ - -/* includes */ -#include "mvSysHwConfig.h" -#include "pci-if/mvPciIf.h" -#include "pci/mvPciRegs.h" - - - -/* PCI base address low bar mask */ -#define PCI_ERROR_CODE 0xffffffff - -#define PCI_BRIDGE_CLASS 0x6 -#define P2P_BRIDGE_SUB_CLASS_CODE 0x4 - - -#define P2P_BUSSES_NUM 0x18 -#define P2P_IO_BASE_LIMIT_SEC_STATUS 0x1C -#define P2P_MEM_BASE_LIMIT 0x20 -#define P2P_PREF_MEM_BASE_LIMIT 0x24 -#define P2P_PREF_BASE_UPPER_32 0x28 -#define P2P_PREF_LIMIT_UPPER_32 0x2C -#define P2P_IO_BASE_LIMIT_UPPER_16 0x30 -#define P2P_EXP_ROM 0x38 - -/* P2P_BUSSES_NUM (PBM) */ - -#define PBM_PRIME_BUS_NUM_OFFS 0 -#define PBM_PRIME_BUS_NUM_MASK (0xff << PBM_PRIME_BUS_NUM_OFFS) - -#define PBM_SEC_BUS_NUM_OFFS 8 -#define PBM_SEC_BUS_NUM_MASK (0xff << PBM_SEC_BUS_NUM_OFFS) - -#define PBM_SUB_BUS_NUM_OFFS 16 -#define PBM_SUB_BUS_NUM_MASK (0xff << PBM_SUB_BUS_NUM_OFFS) - -#define PBM_SEC_LAT_TMR_OFFS 24 -#define PBM_SEC_LAT_TMR_MASK (0xff << PBM_SEC_LAT_TMR_OFFS) - -/* P2P_IO_BASE_LIMIT_SEC_STATUS (PIBLSS) */ - -#define PIBLSS_IO_BASE_OFFS 0 -#define PIBLSS_IO_BASE_MASK (0xff << PIBLSS_IO_BASE_OFFS) - -#define PIBLSS_ADD_CAP_OFFS 0 -#define PIBLSS_ADD_CAP_MASK (0x3 << PIBLSS_ADD_CAP_OFFS) -#define PIBLSS_ADD_CAP_16BIT (0x0 << PIBLSS_ADD_CAP_OFFS) -#define PIBLSS_ADD_CAP_32BIT (0x1 << PIBLSS_ADD_CAP_OFFS) - -#define PIBLSS_LOW_ADDR_OFFS 0 -#define PIBLSS_LOW_ADDR_MASK (0xFFF << PIBLSS_LOW_ADDR_OFFS) - -#define PIBLSS_HIGH_ADDR_OFFS 12 -#define PIBLSS_HIGH_ADDR_MASK (0xF << PIBLSS_HIGH_ADDR_OFFS) - -#define PIBLSS_IO_LIMIT_OFFS 8 -#define PIBLSS_IO_LIMIT_MASK (0xff << PIBLSS_IO_LIMIT_OFFS) - -#define PIBLSS_SEC_STATUS_OFFS 16 -#define PIBLSS_SEC_STATUS_MASK (0xffff << PIBLSS_SEC_STATUS_OFFS) - - -/* P2P_MEM_BASE_LIMIT (PMBL)*/ - -#define PMBL_MEM_BASE_OFFS 0 -#define PMBL_MEM_BASE_MASK (0xffff << PMBL_MEM_BASE_OFFS) - -#define PMBL_MEM_LIMIT_OFFS 16 -#define PMBL_MEM_LIMIT_MASK (0xffff << PMBL_MEM_LIMIT_OFFS) - - -#define PMBL_LOW_ADDR_OFFS 0 -#define PMBL_LOW_ADDR_MASK (0xFFFFF << PMBL_LOW_ADDR_OFFS) - -#define PMBL_HIGH_ADDR_OFFS 20 -#define PMBL_HIGH_ADDR_MASK (0xFFF << PMBL_HIGH_ADDR_OFFS) - - -/* P2P_PREF_MEM_BASE_LIMIT (PRMBL) */ - -#define PRMBL_PREF_MEM_BASE_OFFS 0 -#define PRMBL_PREF_MEM_BASE_MASK (0xffff << PRMBL_PREF_MEM_BASE_OFFS) - -#define PRMBL_PREF_MEM_LIMIT_OFFS 16 -#define PRMBL_PREF_MEM_LIMIT_MASK (0xffff<<PRMBL_PREF_MEM_LIMIT_OFFS) - -#define PRMBL_LOW_ADDR_OFFS 0 -#define PRMBL_LOW_ADDR_MASK (0xFFFFF << PRMBL_LOW_ADDR_OFFS) - -#define PRMBL_HIGH_ADDR_OFFS 20 -#define PRMBL_HIGH_ADDR_MASK (0xFFF << PRMBL_HIGH_ADDR_OFFS) - -#define PRMBL_ADD_CAP_OFFS 0 -#define PRMBL_ADD_CAP_MASK (0xf << PRMBL_ADD_CAP_OFFS) -#define PRMBL_ADD_CAP_32BIT (0x0 << PRMBL_ADD_CAP_OFFS) -#define PRMBL_ADD_CAP_64BIT (0x1 << PRMBL_ADD_CAP_OFFS) - -/* P2P_IO_BASE_LIMIT_UPPER_16 (PIBLU) */ - -#define PRBU_IO_UPP_BASE_OFFS 0 -#define PRBU_IO_UPP_BASE_MASK (0xffff << PRBU_IO_UPP_BASE_OFFS) - -#define PRBU_IO_UPP_LIMIT_OFFS 16 -#define PRBU_IO_UPP_LIMIT_MASK (0xffff << PRBU_IO_UPP_LIMIT_OFFS) - - -/* typedefs */ - -typedef enum _mvPciBarMapping -{ - PCI_MEMORY_BAR, - PCI_IO_BAR, - PCI_NO_MAPPING -}MV_PCI_BAR_MAPPING; - -typedef enum _mvPciBarType -{ - PCI_32BIT_BAR, - PCI_64BIT_BAR -}MV_PCI_BAR_TYPE; - -typedef enum _mvPciIntPin -{ - MV_PCI_INTA = 1, - MV_PCI_INTB = 2, - MV_PCI_INTC = 3, - MV_PCI_INTD = 4 -}MV_PCI_INT_PIN; - -typedef enum _mvPciHeader -{ - MV_PCI_STANDARD, - MV_PCI_PCI2PCI_BRIDGE - -}MV_PCI_HEADER; - - -/* BAR structure */ -typedef struct _pciBar -{ - MV_U32 barOffset; - MV_U32 barBaseLow; - MV_U32 barBaseHigh; - MV_U32 barSizeLow; - MV_U32 barSizeHigh; - /* The 'barBaseAddr' is a 64-bit variable - that will contain the TOTAL base address - value achived by combining both the 'barBaseLow' - and the 'barBaseHigh' parameters as follows: - - BIT: 63 31 0 - | | | - barBaseHigh barBaseLow */ - MV_U64 barBaseAddr; - /* The 'barSize' is a 64-bit variable - that will contain the TOTAL size achived - by combining both the 'barSizeLow' and - the 'barSizeHigh' parameters as follows: - - BIT: 63 31 0 - | | | - barSizeHigh barSizeLow - - NOTE: The total size described above - is AFTER the size calculation as - described in PCI spec rev2.2 */ - MV_U64 barSize; - MV_BOOL isPrefetchable; - MV_PCI_BAR_TYPE barType; - MV_PCI_BAR_MAPPING barMapping; - - -} PCI_BAR; - -/* Device information structure */ -typedef struct _mvPciDevice -{ - /* Device specific information */ - MV_U32 busNumber; /* Pci agent bus number */ - MV_U32 deviceNum; /* Pci agent device number */ - MV_U32 function; /* Pci agent function number */ - - MV_U32 venID; /* Pci agent Vendor ID */ - MV_U32 deviceID; /* Pci agent Device ID */ - - MV_BOOL isFastB2BCapable; /* Capability of Fast Back to Back - transactions */ - MV_BOOL isCapListSupport; /* Support of Capability list */ - MV_BOOL is66MHZCapable; /* 66MHZ support */ - - MV_U32 baseClassCode; /* Pci agent base Class Code */ - MV_U32 subClassCode; /* Pci agent sub Class Code */ - MV_U32 progIf; /* Pci agent Programing interface */ - MV_U32 revisionID; - - PCI_BAR pciBar[6]; /* Pci agent bar list */ - - MV_U32 p2pPrimBusNum; /* P2P Primary Bus number*/ - MV_U32 p2pSecBusNum; /* P2P Secondary Bus Number*/ - MV_U32 p2pSubBusNum; /* P2P Subordinate bus Number */ - MV_U32 p2pSecLatencyTimer; /* P2P Econdary Latency Timer*/ - MV_U32 p2pIObase; /* P2P IO Base */ - MV_U32 p2pIOLimit; /* P2P IO Linit */ - MV_BOOL bIO32; - MV_U32 p2pSecStatus; /* P2P Secondary Status */ - MV_U32 p2pMemBase; /* P2P Memory Space */ - MV_U32 p2pMemLimit; /* P2P Memory Limit*/ - MV_U32 p2pPrefMemBase; /* P2P Prefetchable Mem Base*/ - MV_U32 p2pPrefMemLimit; /* P2P Prefetchable Memory Limit*/ - MV_BOOL bPrefMem64; - MV_U32 p2pPrefBaseUpper32Bits;/* P2P Prefetchable upper 32 bits*/ - MV_U32 p2pPrefLimitUpper32Bits;/* P2P prefetchable limit upper 32*/ - - - MV_U32 pciCacheLine; /* Pci agent cache line */ - MV_U32 pciLatencyTimer; /* Pci agent Latency timer */ - MV_PCI_HEADER pciHeader; /* Pci agent header type*/ - MV_BOOL isMultiFunction; /* Multi function support */ - MV_BOOL isBISTCapable; /* Self test capable */ - - MV_U32 subSysID; /* Sub System ID */ - MV_U32 subSysVenID; /* Sub System Vendor ID */ - - MV_BOOL isExpRom; /* Expantion Rom support */ - MV_U32 expRomAddr; /* Expantion Rom pointer */ - - MV_U32 capListPointer; /* Capability list pointer */ - - MV_U32 irqLine; /* IRQ line */ - MV_PCI_INT_PIN intPin; /* Interrupt pin */ - MV_U32 minGrant; /* Minimum grant*/ - MV_U32 maxLatency; /* Maximum latency*/ - - MV_U32 funtionsNum; /* pci agent total functions number */ - - MV_U32 barsNum; - MV_U8 type[60]; /* class name of the pci agent */ - - -} MV_PCI_DEVICE; - -/* PCI gloabl functions */ -MV_STATUS mvPciClassNameGet(MV_U32 classCode, MV_8 *pType); - - -/* Performs a full scan on both PCIs and returns all possible details on the - agents found on the bus. */ -MV_STATUS mvPciScan(MV_U32 pciIf, - MV_PCI_DEVICE *pPciAgents, - MV_U32 *pPciAgentsNum); - - -#endif /* #ifndef __INCmvPciUtilsh */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pci/mvPci.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pci/mvPci.c deleted file mode 100644 index 4a08734..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pci/mvPci.c +++ /dev/null @@ -1,1047 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ -#include "pci/mvPci.h" - -#include "ctrlEnv/mvCtrlEnvLib.h" - -/* defines */ -#ifdef MV_DEBUG - #define DB(x) x -#else - #define DB(x) -#endif - - - -MV_VOID mvPciHalInit(MV_U32 pciIf, MV_PCI_MOD pciIfmod) -{ - if (MV_PCI_MOD_HOST == pciIfmod) - { - - mvPciLocalBusNumSet(pciIf, PCI_HOST_BUS_NUM(pciIf)); - mvPciLocalDevNumSet(pciIf, PCI_HOST_DEV_NUM(pciIf)); - - /* Local device master Enable */ - mvPciMasterEnable(pciIf, MV_TRUE); - - /* Local device slave Enable */ - mvPciSlaveEnable(pciIf, mvPciLocalBusNumGet(pciIf), - mvPciLocalDevNumGet(pciIf), MV_TRUE); - } - /* enable CPU-2-PCI ordering */ - MV_REG_BIT_SET(PCI_CMD_REG(0), PCR_CPU_TO_PCI_ORDER_EN); -} - -/******************************************************************************* -* mvPciCommandSet - Set PCI comman register value. -* -* DESCRIPTION: -* This function sets a given PCI interface with its command register -* value. -* -* INPUT: -* pciIf - PCI interface number. -* command - 32bit value to be written to comamnd register. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM if pciIf is not in range otherwise MV_OK -* -*******************************************************************************/ -MV_STATUS mvPciCommandSet(MV_U32 pciIf, MV_U32 command) -{ - MV_U32 locBusNum, locDevNum, regVal; - - locBusNum = mvPciLocalBusNumGet(pciIf); - locDevNum = mvPciLocalDevNumGet(pciIf); - - /* Parameter checking */ - if (pciIf >= mvCtrlPciMaxIfGet()) - { - mvOsPrintf("mvPciCommandSet: ERR. Invalid PCI IF num %d\n", pciIf); - return MV_BAD_PARAM; - } - - /* Set command register */ - MV_REG_WRITE(PCI_CMD_REG(pciIf), command); - - /* Upodate device max outstanding split tarnsaction */ - if ((command & PCR_CPU_TO_PCI_ORDER_EN) && - (command & PCR_PCI_TO_CPU_ORDER_EN)) - { - /* Read PCI-X command register */ - regVal = mvPciConfigRead (pciIf, locBusNum, locDevNum, 0, PCIX_COMMAND); - - /* clear bits 22:20 */ - regVal &= 0xff8fffff; - - /* set reset value */ - regVal |= (0x3 << 20); - - /* Write back the value */ - mvPciConfigWrite (pciIf, locBusNum, locDevNum, 0, PCIX_COMMAND, regVal); - } - - return MV_OK; - - -} - - -/******************************************************************************* -* mvPciModeGet - Get PCI interface mode. -* -* DESCRIPTION: -* This function returns the given PCI interface mode. -* -* INPUT: -* pciIf - PCI interface number. -* -* OUTPUT: -* pPciMode - Pointer to PCI mode structure. -* -* RETURN: -* MV_BAD_PARAM for bad parameters ,MV_ERROR on error ! otherwise MV_OK -* -*******************************************************************************/ -MV_STATUS mvPciModeGet(MV_U32 pciIf, MV_PCI_MODE *pPciMode) -{ - MV_U32 pciMode; - - /* Parameter checking */ - if (pciIf >= mvCtrlPciMaxIfGet()) - { - mvOsPrintf("mvPciModeGet: ERR. Invalid PCI interface %d\n", pciIf); - return MV_BAD_PARAM; - } - if (NULL == pPciMode) - { - mvOsPrintf("mvPciModeGet: ERR. pPciMode = NULL \n"); - return MV_BAD_PARAM; - } - - /* Read pci mode register */ - pciMode = MV_REG_READ(PCI_MODE_REG(pciIf)); - - switch (pciMode & PMR_PCI_MODE_MASK) - { - case PMR_PCI_MODE_CONV: - pPciMode->pciType = MV_PCI_CONV; - - if (MV_REG_READ(PCI_DLL_CTRL_REG(pciIf)) & PDC_DLL_EN) - { - pPciMode->pciSpeed = 66000000; /* 66MHZ */ - } - else - { - pPciMode->pciSpeed = 33000000; /* 33MHZ */ - } - - break; - - case PMR_PCI_MODE_PCIX_66MHZ: - pPciMode->pciType = MV_PCIX; - pPciMode->pciSpeed = 66000000; /* 66MHZ */ - break; - - case PMR_PCI_MODE_PCIX_100MHZ: - pPciMode->pciType = MV_PCIX; - pPciMode->pciSpeed = 100000000; /* 100MHZ */ - break; - - case PMR_PCI_MODE_PCIX_133MHZ: - pPciMode->pciType = MV_PCIX; - pPciMode->pciSpeed = 133000000; /* 133MHZ */ - break; - - default: - { - mvOsPrintf("mvPciModeGet: ERR. Non existing mode !!\n"); - return MV_ERROR; - } - } - - switch (pciMode & PMR_PCI_64_MASK) - { - case PMR_PCI_64_64BIT: - pPciMode->pciWidth = MV_PCI_64; - break; - - case PMR_PCI_64_32BIT: - pPciMode->pciWidth = MV_PCI_32; - break; - - default: - { - mvOsPrintf("mvPciModeGet: ERR. Non existing mode !!\n"); - return MV_ERROR; - } - } - - return MV_OK; -} - -/******************************************************************************* -* mvPciRetrySet - Set PCI retry counters -* -* DESCRIPTION: -* This function specifies the number of times the PCI controller -* retries a transaction before it quits. -* Applies to the PCI Master when acting as a requester. -* Applies to the PCI slave when acting as a completer (PCI-X mode). -* A 0x00 value means a "retry forever". -* -* INPUT: -* pciIf - PCI interface number. -* counter - Number of times PCI controller retry. Use counter value -* up to PRR_RETRY_CNTR_MAX. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM for bad parameters ,MV_ERROR on error ! otherwise MV_OK -* -*******************************************************************************/ -MV_STATUS mvPciRetrySet(MV_U32 pciIf, MV_U32 counter) -{ - MV_U32 pciRetry; - - /* Parameter checking */ - if (pciIf >= mvCtrlPciMaxIfGet()) - { - mvOsPrintf("mvPciRetrySet: ERR. Invalid PCI interface %d\n", pciIf); - return MV_BAD_PARAM; - } - - if (counter >= PRR_RETRY_CNTR_MAX) - { - mvOsPrintf("mvPciRetrySet: ERR. Invalid counter: %d\n", counter); - return MV_BAD_PARAM; - - } - - /* Reading PCI retry register */ - pciRetry = MV_REG_READ(PCI_RETRY_REG(pciIf)); - - pciRetry &= ~PRR_RETRY_CNTR_MASK; - - pciRetry |= (counter << PRR_RETRY_CNTR_OFFS); - - /* write new value */ - MV_REG_WRITE(PCI_RETRY_REG(pciIf), pciRetry); - - return MV_OK; -} - - -/******************************************************************************* -* mvPciDiscardTimerSet - Set PCI discard timer -* -* DESCRIPTION: -* This function set PCI discard timer. -* In conventional PCI mode: -* Specifies the number of PCLK cycles the PCI slave keeps a non-accessed -* read buffers (non-completed delayed read) before invalidate the buffer. -* Set to '0' to disable the timer. The PCI slave waits for delayed -* read completion forever. -* In PCI-X mode: -* Specifies the number of PCLK cycles the PCI master waits for split -* completion transaction, before it invalidates the pre-allocated read -* buffer. -* Set to '0' to disable the timer. The PCI master waits for split -* completion forever. -* NOTE: Must be set to a number greater than MV_PCI_MAX_DISCARD_CLK, -* unless using the "wait for ever" setting 0x0. -* NOTE: Must not be updated while there are pending read requests. -* -* INPUT: -* pciIf - PCI interface number. -* pClkCycles - Number of PCI clock cycles. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM for bad parameters ,MV_ERROR on error ! otherwise MV_OK -* -*******************************************************************************/ -MV_STATUS mvPciDiscardTimerSet(MV_U32 pciIf, MV_U32 pClkCycles) -{ - MV_U32 pciDiscardTimer; - - /* Parameter checking */ - if (pciIf >= mvCtrlPciMaxIfGet()) - { - mvOsPrintf("mvPciDiscardTimerSet: ERR. Invalid PCI interface %d\n", - pciIf); - return MV_BAD_PARAM; - } - - if (pClkCycles >= PDTR_TIMER_MIN) - { - mvOsPrintf("mvPciDiscardTimerSet: ERR. Invalid Clk value: %d\n", - pClkCycles); - return MV_BAD_PARAM; - - } - - /* Read PCI Discard Timer */ - pciDiscardTimer = MV_REG_READ(PCI_DISCARD_TIMER_REG(pciIf)); - - pciDiscardTimer &= ~PDTR_TIMER_MASK; - - pciDiscardTimer |= (pClkCycles << PDTR_TIMER_OFFS); - - /* Write new value */ - MV_REG_WRITE(PCI_DISCARD_TIMER_REG(pciIf), pciDiscardTimer); - - return MV_OK; - -} - -/* PCI Arbiter routines */ - -/******************************************************************************* -* mvPciArbEnable - PCI arbiter enable/disable -* -* DESCRIPTION: -* This fuction enable/disables a given PCI interface arbiter. -* NOTE: Arbiter setting can not be changed while in work. It should only -* be set once. -* INPUT: -* pciIf - PCI interface number. -* enable - Enable/disable parameter. If enable = MV_TRUE then enable. -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_STATUS mvPciArbEnable(MV_U32 pciIf, MV_BOOL enable) -{ - MV_U32 regVal; - - /* Parameter checking */ - if (pciIf >= mvCtrlPciMaxIfGet()) - { - mvOsPrintf("mvPciArbEnable: ERR. Invalid PCI interface %d\n", pciIf); - return MV_ERROR; - } - - /* Set PCI Arbiter Control register according to default configuration */ - regVal = MV_REG_READ(PCI_ARBITER_CTRL_REG(pciIf)); - - /* Make sure arbiter disabled before changing its values */ - MV_REG_BIT_RESET(PCI_ARBITER_CTRL_REG(pciIf), PACR_ARB_ENABLE); - - regVal &= ~PCI_ARBITER_CTRL_DEFAULT_MASK; - - regVal |= PCI_ARBITER_CTRL_DEFAULT; /* Set default configuration */ - - if (MV_TRUE == enable) - { - regVal |= PACR_ARB_ENABLE; - } - else - { - regVal &= ~PACR_ARB_ENABLE; - } - - /* Write to register */ - MV_REG_WRITE(PCI_ARBITER_CTRL_REG(pciIf), regVal); - - return MV_OK; -} - - -/******************************************************************************* -* mvPciArbParkDis - Disable arbiter parking on agent -* -* DESCRIPTION: -* This function disables the PCI arbiter from parking on the given agent -* list. -* -* INPUT: -* pciIf - PCI interface number. -* pciAgentMask - When a bit in the mask is set to '1', parking on -* the associated PCI master is disabled. Mask bit -* refers to bit 0 - 6. For example disable parking on PCI -* agent 3 set pciAgentMask 0x4 (bit 3 is set). -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -MV_STATUS mvPciArbParkDis(MV_U32 pciIf, MV_U32 pciAgentMask) -{ - MV_U32 pciArbiterCtrl; - - /* Parameter checking */ - if (pciIf >= mvCtrlPciMaxIfGet()) - { - mvOsPrintf("mvPciArbParkDis: ERR. Invalid PCI interface %d\n", pciIf); - return MV_ERROR; - } - - /* Reading Arbiter Control register */ - pciArbiterCtrl = MV_REG_READ(PCI_ARBITER_CTRL_REG(pciIf)); - - /* Arbiter must be disabled before changing parking */ - MV_REG_BIT_RESET(PCI_ARBITER_CTRL_REG(pciIf), PACR_ARB_ENABLE); - - /* do the change */ - pciArbiterCtrl &= ~PACR_PARK_DIS_MASK; - pciArbiterCtrl |= (pciAgentMask << PACR_PARK_DIS_OFFS); - - /* writing new value ( if th earbiter was enabled before the change */ - /* here it will be reenabled */ - MV_REG_WRITE(PCI_ARBITER_CTRL_REG(pciIf), pciArbiterCtrl); - - return MV_OK; -} - - -/******************************************************************************* -* mvPciArbBrokDetectSet - Set PCI arbiter broken detection -* -* DESCRIPTION: -* This function sets the maximum number of cycles that the arbiter -* waits for a PCI master to respond to its grant assertion. If a -* PCI agent fails to respond within this time, the PCI arbiter aborts -* the transaction and performs a new arbitration cycle. -* NOTE: Value must be greater than '1' for conventional PCI and -* greater than '5' for PCI-X. -* -* INPUT: -* pciIf - PCI interface number. -* pClkCycles - Number of PCI clock cycles. If equal to '0' the broken -* master detection is disabled. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM for bad parameters ,MV_ERROR on error ! otherwise MV_OK -* -*******************************************************************************/ -MV_STATUS mvPciArbBrokDetectSet(MV_U32 pciIf, MV_U32 pClkCycles) -{ - MV_U32 pciArbiterCtrl; - MV_U32 pciMode; - - /* Parameter checking */ - if (pciIf >= mvCtrlPciMaxIfGet()) - { - mvOsPrintf("mvPciArbBrokDetectSet: ERR. Invalid PCI interface %d\n", - pciIf); - return MV_BAD_PARAM; - } - - /* Checking PCI mode and if pClkCycles is legal value */ - pciMode = MV_REG_READ(PCI_MODE_REG(pciIf)); - pciMode &= PMR_PCI_MODE_MASK; - - if (PMR_PCI_MODE_CONV == pciMode) - { - if (pClkCycles < PACR_BROKEN_VAL_CONV_MIN) - return MV_ERROR; - } - else - { - if (pClkCycles < PACR_BROKEN_VAL_PCIX_MIN) - return MV_ERROR; - } - - pClkCycles <<= PACR_BROKEN_VAL_OFFS; - - /* Reading Arbiter Control register */ - pciArbiterCtrl = MV_REG_READ(PCI_ARBITER_CTRL_REG(pciIf)); - pciArbiterCtrl &= ~PACR_BROKEN_VAL_MASK; - pciArbiterCtrl |= pClkCycles; - - /* Arbiter must be disabled before changing broken detection */ - MV_REG_BIT_RESET(PCI_ARBITER_CTRL_REG(pciIf), PACR_ARB_ENABLE); - - /* writing new value ( if th earbiter was enabled before the change */ - /* here it will be reenabled */ - - MV_REG_WRITE(PCI_ARBITER_CTRL_REG(pciIf), pciArbiterCtrl); - - return MV_OK; -} - -/* PCI configuration space read write */ - -/******************************************************************************* -* mvPciConfigRead - Read from configuration space -* -* DESCRIPTION: -* This function performs a 32 bit read from PCI configuration space. -* It supports both type 0 and type 1 of Configuration Transactions -* (local and over bridge). In order to read from local bus segment, use -* bus number retrieved from mvPciLocalBusNumGet(). Other bus numbers -* will result configuration transaction of type 1 (over bridge). -* -* INPUT: -* pciIf - PCI interface number. -* bus - PCI segment bus number. -* dev - PCI device number. -* func - Function number. -* regOffs - Register offset. -* -* OUTPUT: -* None. -* -* RETURN: -* 32bit register data, 0xffffffff on error -* -*******************************************************************************/ -MV_U32 mvPciConfigRead (MV_U32 pciIf, MV_U32 bus, MV_U32 dev, MV_U32 func, - MV_U32 regOff) -{ - MV_U32 pciData = 0; - - /* Parameter checking */ - if (PCI_DEFAULT_IF != pciIf) - { - if (pciIf >= mvCtrlPciMaxIfGet()) - { - mvOsPrintf("mvPciConfigRead: ERR. Invalid PCI interface %d\n",pciIf); - return 0xFFFFFFFF; - } - } - - if (dev >= MAX_PCI_DEVICES) - { - DB(mvOsPrintf("mvPciConfigRead: ERR. device number illigal %d\n", dev)); - return 0xFFFFFFFF; - } - - if (func >= MAX_PCI_FUNCS) - { - DB(mvOsPrintf("mvPciConfigRead: ERR. function number illigal %d\n", func)); - return 0xFFFFFFFF; - } - - if (bus >= MAX_PCI_BUSSES) - { - DB(mvOsPrintf("mvPciConfigRead: ERR. bus number illigal %d\n", bus)); - return MV_ERROR; - } - - - /* Creating PCI address to be passed */ - pciData |= (bus << PCAR_BUS_NUM_OFFS); - pciData |= (dev << PCAR_DEVICE_NUM_OFFS); - pciData |= (func << PCAR_FUNC_NUM_OFFS); - pciData |= (regOff & PCAR_REG_NUM_MASK); - - pciData |= PCAR_CONFIG_EN; - - /* Write the address to the PCI configuration address register */ - MV_REG_WRITE(PCI_CONFIG_ADDR_REG(pciIf), pciData); - - /* In order to let the PCI controller absorbed the address of the read */ - /* transaction we perform a validity check that the address was written */ - if(pciData != MV_REG_READ(PCI_CONFIG_ADDR_REG(pciIf))) - { - return MV_ERROR; - } - /* Read the Data returned in the PCI Data register */ - pciData = MV_REG_READ(PCI_CONFIG_DATA_REG(pciIf)); - - return pciData; -} - -/******************************************************************************* -* mvPciConfigWrite - Write to configuration space -* -* DESCRIPTION: -* This function performs a 32 bit write to PCI configuration space. -* It supports both type 0 and type 1 of Configuration Transactions -* (local and over bridge). In order to write to local bus segment, use -* bus number retrieved from mvPciLocalBusNumGet(). Other bus numbers -* will result configuration transaction of type 1 (over bridge). -* -* INPUT: -* pciIf - PCI interface number. -* bus - PCI segment bus number. -* dev - PCI device number. -* func - Function number. -* regOffs - Register offset. -* data - 32bit data. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM for bad parameters ,MV_ERROR on error ! otherwise MV_OK -* -*******************************************************************************/ -MV_STATUS mvPciConfigWrite(MV_U32 pciIf, MV_U32 bus, MV_U32 dev, - MV_U32 func, MV_U32 regOff, MV_U32 data) -{ - MV_U32 pciData = 0; - - /* Parameter checking */ - if (PCI_DEFAULT_IF != pciIf) - { - if (pciIf >= mvCtrlPciMaxIfGet()) - { - mvOsPrintf("mvPciConfigWrite: ERR. Invalid PCI interface %d\n", - pciIf); - return 0xFFFFFFFF; - } - } - - if (dev >= MAX_PCI_DEVICES) - { - mvOsPrintf("mvPciConfigWrite: ERR. device number illigal %d\n",dev); - return MV_BAD_PARAM; - } - - if (func >= MAX_PCI_FUNCS) - { - mvOsPrintf("mvPciConfigWrite: ERR. function number illigal %d\n", func); - return MV_ERROR; - } - - if (bus >= MAX_PCI_BUSSES) - { - mvOsPrintf("mvPciConfigWrite: ERR. bus number illigal %d\n", bus); - return MV_ERROR; - } - - /* Creating PCI address to be passed */ - pciData |= (bus << PCAR_BUS_NUM_OFFS); - pciData |= (dev << PCAR_DEVICE_NUM_OFFS); - pciData |= (func << PCAR_FUNC_NUM_OFFS); - pciData |= (regOff & PCAR_REG_NUM_MASK); - - pciData |= PCAR_CONFIG_EN; - - /* Write the address to the PCI configuration address register */ - MV_REG_WRITE(PCI_CONFIG_ADDR_REG(pciIf), pciData); - - /* In order to let the PCI controller absorbed the address of the read */ - /* transaction we perform a validity check that the address was written */ - if(pciData != MV_REG_READ(PCI_CONFIG_ADDR_REG(pciIf))) - { - return MV_ERROR; - } - - /* Write the Data passed to the PCI Data register */ - MV_REG_WRITE(PCI_CONFIG_DATA_REG(pciIf), data); - - return MV_OK; -} - -/******************************************************************************* -* mvPciMasterEnable - Enable/disale PCI interface master transactions. -* -* DESCRIPTION: -* This function performs read modified write to PCI command status -* (offset 0x4) to set/reset bit 2. After this bit is set, the PCI -* master is allowed to gain ownership on the bus, otherwise it is -* incapable to do so. -* -* INPUT: -* pciIf - PCI interface number. -* enable - Enable/disable parameter. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM for bad parameters ,MV_ERROR on error ! otherwise MV_OK -* -*******************************************************************************/ -MV_STATUS mvPciMasterEnable(MV_U32 pciIf, MV_BOOL enable) -{ - MV_U32 pciCommandStatus; - MV_U32 RegOffs; - MV_U32 localBus; - MV_U32 localDev; - - /* Parameter checking */ - if (pciIf >= mvCtrlPciMaxIfGet()) - { - mvOsPrintf("mvPciMasterEnable: ERR. Invalid PCI interface %d\n", pciIf); - return MV_ERROR; - } - - localBus = mvPciLocalBusNumGet(pciIf); - localDev = mvPciLocalDevNumGet(pciIf); - - RegOffs = PCI_STATUS_AND_COMMAND; - - pciCommandStatus = mvPciConfigRead(pciIf, localBus, localDev, 0, RegOffs); - - if (MV_TRUE == enable) - { - pciCommandStatus |= PSCR_MASTER_EN; - } - else - { - pciCommandStatus &= ~PSCR_MASTER_EN; - } - - mvPciConfigWrite(pciIf, localBus, localDev, 0, RegOffs, pciCommandStatus); - - return MV_OK; -} - - -/******************************************************************************* -* mvPciSlaveEnable - Enable/disale PCI interface slave transactions. -* -* DESCRIPTION: -* This function performs read modified write to PCI command status -* (offset 0x4) to set/reset bit 0 and 1. After those bits are set, -* the PCI slave is allowed to respond to PCI IO space access (bit 0) -* and PCI memory space access (bit 1). -* -* INPUT: -* pciIf - PCI interface number. -* dev - PCI device number. -* enable - Enable/disable parameter. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM for bad parameters ,MV_ERROR on error ! otherwise MV_OK -* -*******************************************************************************/ -MV_STATUS mvPciSlaveEnable(MV_U32 pciIf, MV_U32 bus, MV_U32 dev, MV_BOOL enable) -{ - MV_U32 pciCommandStatus; - MV_U32 RegOffs; - - /* Parameter checking */ - if (pciIf >= mvCtrlPciMaxIfGet()) - { - mvOsPrintf("mvPciSlaveEnable: ERR. Invalid PCI interface %d\n", pciIf); - return MV_BAD_PARAM; - } - if (dev >= MAX_PCI_DEVICES) - { - mvOsPrintf("mvPciLocalDevNumSet: ERR. device number illigal %d\n", dev); - return MV_BAD_PARAM; - - } - - RegOffs = PCI_STATUS_AND_COMMAND; - - pciCommandStatus=mvPciConfigRead(pciIf, bus, dev, 0, RegOffs); - - if (MV_TRUE == enable) - { - pciCommandStatus |= (PSCR_IO_EN | PSCR_MEM_EN); - } - else - { - pciCommandStatus &= ~(PSCR_IO_EN | PSCR_MEM_EN); - } - - mvPciConfigWrite(pciIf, bus, dev, 0, RegOffs, pciCommandStatus); - - return MV_OK; -} - -/******************************************************************************* -* mvPciLocalBusNumSet - Set PCI interface local bus number. -* -* DESCRIPTION: -* This function sets given PCI interface its local bus number. -* Note: In case the PCI interface is PCI-X, the information is read-only. -* -* INPUT: -* pciIf - PCI interface number. -* busNum - Bus number. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_NOT_ALLOWED in case PCI interface is PCI-X. -* MV_BAD_PARAM on bad parameters , -* otherwise MV_OK -* -*******************************************************************************/ -MV_STATUS mvPciLocalBusNumSet(MV_U32 pciIf, MV_U32 busNum) -{ - MV_U32 pciP2PConfig; - MV_PCI_MODE pciMode; - MV_U32 localBus; - MV_U32 localDev; - - - /* Parameter checking */ - if (pciIf >= mvCtrlPciMaxIfGet()) - { - mvOsPrintf("mvPciLocalBusNumSet: ERR. Invalid PCI interface %d\n",pciIf); - return MV_BAD_PARAM; - } - if (busNum >= MAX_PCI_BUSSES) - { - mvOsPrintf("mvPciLocalBusNumSet: ERR. bus number illigal %d\n", busNum); - return MV_ERROR; - - } - - localBus = mvPciLocalBusNumGet(pciIf); - localDev = mvPciLocalDevNumGet(pciIf); - - - /* PCI interface mode */ - mvPciModeGet(pciIf, &pciMode); - - /* if PCI type is PCI-X then it is not allowed to change the dev number */ - if (MV_PCIX == pciMode.pciType) - { - pciP2PConfig = mvPciConfigRead(pciIf, localBus, localDev, 0, PCIX_STATUS ); - - pciP2PConfig &= ~PXS_BN_MASK; - - pciP2PConfig |= (busNum << PXS_BN_OFFS) & PXS_BN_MASK; - - mvPciConfigWrite(pciIf, localBus, localDev, 0, PCIX_STATUS,pciP2PConfig ); - - } - else - { - pciP2PConfig = MV_REG_READ(PCI_P2P_CONFIG_REG(pciIf)); - - pciP2PConfig &= ~PPCR_BUS_NUM_MASK; - - pciP2PConfig |= (busNum << PPCR_BUS_NUM_OFFS) & PPCR_BUS_NUM_MASK; - - MV_REG_WRITE(PCI_P2P_CONFIG_REG(pciIf), pciP2PConfig); - - } - - - return MV_OK; -} - - -/******************************************************************************* -* mvPciLocalBusNumGet - Get PCI interface local bus number. -* -* DESCRIPTION: -* This function gets the local bus number of a given PCI interface. -* -* INPUT: -* pciIf - PCI interface number. -* -* OUTPUT: -* None. -* -* RETURN: -* Local bus number.0xffffffff on Error -* -*******************************************************************************/ -MV_U32 mvPciLocalBusNumGet(MV_U32 pciIf) -{ - MV_U32 pciP2PConfig; - - /* Parameter checking */ - if (PCI_DEFAULT_IF != pciIf) - { - if (pciIf >= mvCtrlPciMaxIfGet()) - { - mvOsPrintf("mvPciLocalBusNumGet: ERR. Invalid PCI interface %d\n", - pciIf); - return 0xFFFFFFFF; - } - } - - pciP2PConfig = MV_REG_READ(PCI_P2P_CONFIG_REG(pciIf)); - pciP2PConfig &= PPCR_BUS_NUM_MASK; - return (pciP2PConfig >> PPCR_BUS_NUM_OFFS); -} - - -/******************************************************************************* -* mvPciLocalDevNumSet - Set PCI interface local device number. -* -* DESCRIPTION: -* This function sets given PCI interface its local device number. -* Note: In case the PCI interface is PCI-X, the information is read-only. -* -* INPUT: -* pciIf - PCI interface number. -* devNum - Device number. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_NOT_ALLOWED in case PCI interface is PCI-X. MV_BAD_PARAM on bad parameters , -* otherwise MV_OK -* -*******************************************************************************/ -MV_STATUS mvPciLocalDevNumSet(MV_U32 pciIf, MV_U32 devNum) -{ - MV_U32 pciP2PConfig; - MV_PCI_MODE pciMode; - MV_U32 localBus; - MV_U32 localDev; - - /* Parameter checking */ - if (pciIf >= mvCtrlPciMaxIfGet()) - { - mvOsPrintf("mvPciLocalDevNumSet: ERR. Invalid PCI interface %d\n",pciIf); - return MV_BAD_PARAM; - } - if (devNum >= MAX_PCI_DEVICES) - { - mvOsPrintf("mvPciLocalDevNumSet: ERR. device number illigal %d\n", - devNum); - return MV_BAD_PARAM; - - } - - localBus = mvPciLocalBusNumGet(pciIf); - localDev = mvPciLocalDevNumGet(pciIf); - - /* PCI interface mode */ - mvPciModeGet(pciIf, &pciMode); - - /* if PCI type is PCIX then it is not allowed to change the dev number */ - if (MV_PCIX == pciMode.pciType) - { - pciP2PConfig = mvPciConfigRead(pciIf, localBus, localDev, 0, PCIX_STATUS ); - - pciP2PConfig &= ~PXS_DN_MASK; - - pciP2PConfig |= (devNum << PXS_DN_OFFS) & PXS_DN_MASK; - - mvPciConfigWrite(pciIf,localBus, localDev, 0, PCIX_STATUS,pciP2PConfig ); - } - else - { - pciP2PConfig = MV_REG_READ(PCI_P2P_CONFIG_REG(pciIf)); - - pciP2PConfig &= ~PPCR_DEV_NUM_MASK; - - pciP2PConfig |= (devNum << PPCR_DEV_NUM_OFFS) & PPCR_DEV_NUM_MASK; - - MV_REG_WRITE(PCI_P2P_CONFIG_REG(pciIf), pciP2PConfig); - } - - return MV_OK; -} - -/******************************************************************************* -* mvPciLocalDevNumGet - Get PCI interface local device number. -* -* DESCRIPTION: -* This function gets the local device number of a given PCI interface. -* -* INPUT: -* pciIf - PCI interface number. -* -* OUTPUT: -* None. -* -* RETURN: -* Local device number. 0xffffffff on Error -* -*******************************************************************************/ -MV_U32 mvPciLocalDevNumGet(MV_U32 pciIf) -{ - MV_U32 pciP2PConfig; - - /* Parameter checking */ - - if (PCI_DEFAULT_IF != pciIf) - { - if (pciIf >= mvCtrlPciMaxIfGet()) - { - mvOsPrintf("mvPciLocalDevNumGet: ERR. Invalid PCI interface %d\n", - pciIf); - return 0xFFFFFFFF; - } - } - - pciP2PConfig = MV_REG_READ(PCI_P2P_CONFIG_REG(pciIf)); - - pciP2PConfig &= PPCR_DEV_NUM_MASK; - - return (pciP2PConfig >> PPCR_DEV_NUM_OFFS); -} - - - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pci/mvPci.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pci/mvPci.h deleted file mode 100644 index 4746336..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pci/mvPci.h +++ /dev/null @@ -1,185 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -#ifndef __INCPCIH -#define __INCPCIH - -#include "mvCommon.h" -#include "mvOs.h" -#include "ctrlEnv/mvCtrlEnvSpec.h" -#include "pci/mvPciRegs.h" - - -/* NOTE not supported in this driver: - - Built In Self Test (BIST) - Vital Product Data (VPD) - Message Signaled Interrupt (MSI) - Power Management - Compact PCI Hot Swap - Header retarget - -Registers not supported: -1) PCI DLL Status and Control (PCI0 0x1D20, PCI1 0x1DA0) -2) PCI/MPP Pads Calibration (CI0/MPP[31:16] 0x1D1C, PCI1/MPP[15:0] 0X1D9C) -*/ - -/* defines */ -/* The number of supported PCI interfaces depend on Marvell controller */ -/* device number. This device number ID is located on the PCI unit */ -/* configuration header. This creates a loop where calling PCI */ -/* configuration read/write routine results a call to get PCI configuration */ -/* information etc. This macro defines a default PCI interface. This PCI */ -/* interface is sure to exist. */ -#define PCI_DEFAULT_IF 0 - - -/* typedefs */ -/* The Marvell controller supports both conventional PCI and PCI-X. */ -/* This enumeration describes the PCI type. */ -typedef enum _mvPciType -{ - MV_PCI_CONV, /* Conventional PCI */ - MV_PCIX /* PCI-X */ -}MV_PCI_TYPE; - -typedef enum _mvPciMod -{ - MV_PCI_MOD_HOST, - MV_PCI_MOD_DEVICE -}MV_PCI_MOD; - - -/* The Marvell controller supports both PCI width of 32 and 64 bit. */ -/* This enumerator describes PCI width */ -typedef enum _mvPciWidth -{ - MV_PCI_32, /* PCI width 32bit */ - MV_PCI_64 /* PCI width 64bit */ -}MV_PCI_WIDTH; - -/* This structure describes the PCI unit configured type, speed and width. */ -typedef struct _mvPciMode -{ - MV_PCI_TYPE pciType; /* PCI type */ - MV_U32 pciSpeed; /* Assuming PCI base clock on board is 33MHz */ - MV_PCI_WIDTH pciWidth; /* PCI bus width */ -}MV_PCI_MODE; - -/* mvPciInit - Initialize PCI interfaces*/ -MV_VOID mvPciHalInit(MV_U32 pciIf, MV_PCI_MOD pciIfmod); - -/* mvPciCommandSet - Set PCI comman register value.*/ -MV_STATUS mvPciCommandSet(MV_U32 pciIf, MV_U32 command); - -/* mvPciModeGet - Get PCI interface mode.*/ -MV_STATUS mvPciModeGet(MV_U32 pciIf, MV_PCI_MODE *pPciMode); - -/* mvPciRetrySet - Set PCI retry counters*/ -MV_STATUS mvPciRetrySet(MV_U32 pciIf, MV_U32 counter); - -/* mvPciDiscardTimerSet - Set PCI discard timer*/ -MV_STATUS mvPciDiscardTimerSet(MV_U32 pciIf, MV_U32 pClkCycles); - -/* mvPciArbEnable - PCI arbiter enable/disable*/ -MV_STATUS mvPciArbEnable(MV_U32 pciIf, MV_BOOL enable); - -/* mvPciArbParkDis - Disable arbiter parking on agent */ -MV_STATUS mvPciArbParkDis(MV_U32 pciIf, MV_U32 pciAgentMask); - -/* mvPciArbBrokDetectSet - Set PCI arbiter broken detection */ -MV_STATUS mvPciArbBrokDetectSet(MV_U32 pciIf, MV_U32 pClkCycles); - -/* mvPciConfigRead - Read from configuration space */ -MV_U32 mvPciConfigRead (MV_U32 pciIf, MV_U32 bus, MV_U32 dev, - MV_U32 func,MV_U32 regOff); - -/* mvPciConfigWrite - Write to configuration space */ -MV_STATUS mvPciConfigWrite(MV_U32 pciIf, MV_U32 bus, MV_U32 dev, - MV_U32 func, MV_U32 regOff, MV_U32 data); - -/* mvPciMasterEnable - Enable/disale PCI interface master transactions.*/ -MV_STATUS mvPciMasterEnable(MV_U32 pciIf, MV_BOOL enable); - -/* mvPciSlaveEnable - Enable/disale PCI interface slave transactions.*/ -MV_STATUS mvPciSlaveEnable(MV_U32 pciIf, MV_U32 bus, MV_U32 dev,MV_BOOL enable); - -/* mvPciLocalBusNumSet - Set PCI interface local bus number.*/ -MV_STATUS mvPciLocalBusNumSet(MV_U32 pciIf, MV_U32 busNum); - -/* mvPciLocalBusNumGet - Get PCI interface local bus number.*/ -MV_U32 mvPciLocalBusNumGet(MV_U32 pciIf); - -/* mvPciLocalDevNumSet - Set PCI interface local device number.*/ -MV_STATUS mvPciLocalDevNumSet(MV_U32 pciIf, MV_U32 devNum); - -/* mvPciLocalDevNumGet - Get PCI interface local device number.*/ -MV_U32 mvPciLocalDevNumGet(MV_U32 pciIf); - - -#endif /* #ifndef __INCPCIH */ - - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pci/mvPciRegs.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pci/mvPciRegs.h deleted file mode 100644 index 89d0ef1..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pci/mvPciRegs.h +++ /dev/null @@ -1,411 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCPCIREGSH -#define __INCPCIREGSH - - -#include "pci-if/mvPciIfRegs.h" -/* defines */ -#define MAX_PCI_DEVICES 32 -#define MAX_PCI_FUNCS 8 -#define MAX_PCI_BUSSES 128 - -/* enumerators */ - -/* This enumerator described the possible PCI slave targets. */ -/* PCI slave targets are designated memory/IO address spaces that the */ -/* PCI slave targets can access. They are also refered as "targets" */ -/* this enumeratoe order is determined by the content of : - PCI_BASE_ADDR_ENABLE_REG */ - - -/* registers offsetes defines */ - - - -/*************************/ -/* PCI control registers */ -/*************************/ -/* maen : should add new registers */ -#define PCI_CMD_REG(pciIf) (0x30c00 + ((pciIf) * 0x80)) -#define PCI_MODE_REG(pciIf) (0x30d00 + ((pciIf) * 0x80)) -#define PCI_RETRY_REG(pciIf) (0x30c04 + ((pciIf) * 0x80)) -#define PCI_DISCARD_TIMER_REG(pciIf) (0x30d04 + ((pciIf) * 0x80)) -#define PCI_ARBITER_CTRL_REG(pciIf) (0x31d00 + ((pciIf) * 0x80)) -#define PCI_P2P_CONFIG_REG(pciIf) (0x31d14 + ((pciIf) * 0x80)) -#define PCI_ACCESS_CTRL_BASEL_REG(pciIf, targetWin) \ - (0x31e00 + ((pciIf) * 0x80) + ((targetWin) * 0x10)) -#define PCI_ACCESS_CTRL_BASEH_REG(pciIf, targetWin) \ - (0x31e04 + ((pciIf) * 0x80) + ((targetWin) * 0x10)) -#define PCI_ACCESS_CTRL_SIZE_REG(pciIf, targetWin) \ - (0x31e08 + ((pciIf) * 0x80) + ((targetWin) * 0x10)) - -#define PCI_DLL_CTRL_REG(pciIf) (0x31d20 + ((pciIf) * 0x80)) - -/* PCI Dll Control (PDC)*/ -#define PDC_DLL_EN BIT0 - - -/* PCI Command Register (PCR) */ -#define PCR_MASTER_BYTE_SWAP_EN BIT0 -#define PCR_MASTER_WR_COMBINE_EN BIT4 -#define PCR_MASTER_RD_COMBINE_EN BIT5 -#define PCR_MASTER_WR_TRIG_WHOLE BIT6 -#define PCR_MASTER_RD_TRIG_WHOLE BIT7 -#define PCR_MASTER_MEM_RD_LINE_EN BIT8 -#define PCR_MASTER_MEM_RD_MULT_EN BIT9 -#define PCR_MASTER_WORD_SWAP_EN BIT10 -#define PCR_SLAVE_WORD_SWAP_EN BIT11 -#define PCR_NS_ACCORDING_RCV_TRANS BIT14 -#define PCR_MASTER_PCIX_REQ64N_EN BIT15 -#define PCR_SLAVE_BYTE_SWAP_EN BIT16 -#define PCR_MASTER_DAC_EN BIT17 -#define PCR_MASTER_M64_ALLIGN BIT18 -#define PCR_ERRORS_PROPAGATION_EN BIT19 -#define PCR_SLAVE_SWAP_ENABLE BIT20 -#define PCR_MASTER_SWAP_ENABLE BIT21 -#define PCR_MASTER_INT_SWAP_EN BIT22 -#define PCR_LOOP_BACK_ENABLE BIT23 -#define PCR_SLAVE_INTREG_SWAP_OFFS 24 -#define PCR_SLAVE_INTREG_SWAP_MASK 0x3 -#define PCR_SLAVE_INTREG_BYTE_SWAP \ - (MV_BYTE_SWAP << PCR_SLAVE_INT_REG_SWAP_MASK) -#define PCR_SLAVE_INTREG_NO_SWAP \ - (MV_NO_SWAP << PCR_SLAVE_INT_REG_SWAP_MASK) -#define PCR_SLAVE_INTREG_BYTE_WORD \ - (MV_BYTE_WORD_SWAP << PCR_SLAVE_INT_REG_SWAP_MASK) -#define PCR_SLAVE_INTREG_WORD_SWAP \ - (MV_WORD_SWAP << PCR_SLAVE_INT_REG_SWAP_MASK) -#define PCR_RESET_REASSERTION_EN BIT26 -#define PCR_PCI_TO_CPU_REG_ORDER_EN BIT28 -#define PCR_CPU_TO_PCI_ORDER_EN BIT29 -#define PCR_PCI_TO_CPU_ORDER_EN BIT30 - -/* PCI Mode Register (PMR) */ -#define PMR_PCI_ID_OFFS 0 /* PCI Interface ID */ -#define PMR_PCI_ID_MASK (0x1 << PMR_PCI_ID_OFFS) -#define PMR_PCI_ID_PCI(pciNum) ((pciNum) << PCI_MODE_PCIID_OFFS) - -#define PMR_PCI_64_OFFS 2 /* 64-bit PCI Interface */ -#define PMR_PCI_64_MASK (0x1 << PMR_PCI_64_OFFS) -#define PMR_PCI_64_64BIT (0x1 << PMR_PCI_64_OFFS) -#define PMR_PCI_64_32BIT (0x0 << PMR_PCI_64_OFFS) - -#define PMR_PCI_MODE_OFFS 4 /* PCI interface mode of operation */ -#define PMR_PCI_MODE_MASK (0x3 << PMR_PCI_MODE_OFFS) -#define PMR_PCI_MODE_CONV (0x0 << PMR_PCI_MODE_OFFS) -#define PMR_PCI_MODE_PCIX_66MHZ (0x1 << PMR_PCI_MODE_OFFS) -#define PMR_PCI_MODE_PCIX_100MHZ (0x2 << PMR_PCI_MODE_OFFS) -#define PMR_PCI_MODE_PCIX_133MHZ (0x3 << PMR_PCI_MODE_OFFS) - -#define PMR_EXP_ROM_SUPPORT BIT8 /* Expansion ROM Active */ - -#define PMR_PCI_RESET_OFFS 31 /* PCI Interface Reset Indication */ -#define PMR_PCI_RESET_MASK (0x1 << PMR_PCI_RESET_OFFS) -#define PMR_PCI_RESET_PCIXRST (0x0 << PMR_PCI_RESET_OFFS) - - -/* PCI Retry Register (PRR) */ -#define PRR_RETRY_CNTR_OFFS 16 /* Retry Counter */ -#define PRR_RETRY_CNTR_MAX 0xff -#define PRR_RETRY_CNTR_MASK (PRR_RETRY_CNTR_MAX << PRR_RETRY_CNTR_OFFS) - - -/* PCI Discard Timer Register (PDTR) */ -#define PDTR_TIMER_OFFS 0 /* Timer */ -#define PDTR_TIMER_MAX 0xffff -#define PDTR_TIMER_MIN 0x7F -#define PDTR_TIMER_MASK (PDTR_TIMER_MAX << PDTR_TIMER_OFFS) - - -/* PCI Arbiter Control Register (PACR) */ -#define PACR_BROKEN_DETECT_EN BIT1 /* Broken Detection Enable */ - -#define PACR_BROKEN_VAL_OFFS 3 /* Broken Value */ -#define PACR_BROKEN_VAL_MASK (0xf << PACR_BROKEN_VAL_OFFS) -#define PACR_BROKEN_VAL_CONV_MIN 0x2 -#define PACR_BROKEN_VAL_PCIX_MIN 0x6 - -#define PACR_PARK_DIS_OFFS 14 /* Parking Disable */ -#define PACR_PARK_DIS_MAX_AGENT 0x3f -#define PACR_PARK_DIS_MASK (PACR_PARK_DIS_MAX_AGENT<<PACR_PARK_DIS_OFFS) -#define PACR_PARK_DIS(agent) ((1 << (agent)) << PACR_PARK_DIS_OFFS) - -#define PACR_ARB_ENABLE BIT31 /* Enable Internal Arbiter */ - - -/* PCI P2P Configuration Register (PPCR) */ -#define PPCR_2ND_BUS_L_OFFS 0 /* 2nd PCI Interface Bus Range Lower */ -#define PPCR_2ND_BUS_L_MASK (0xff << PPCR_2ND_BUS_L_OFFS) - -#define PPCR_2ND_BUS_H_OFFS 8 /* 2nd PCI Interface Bus Range Upper */ -#define PPCR_2ND_BUS_H_MASK (0xff << PPCR_2ND_BUS_H_OFFS) - -#define PPCR_BUS_NUM_OFFS 16 /* The PCI interface's Bus number */ -#define PPCR_BUS_NUM_MASK (0xff << PPCR_BUS_NUM_OFFS) - -#define PPCR_DEV_NUM_OFFS 24 /* The PCI interface’s Device number */ -#define PPCR_DEV_NUM_MASK (0xff << PPCR_DEV_NUM_OFFS) - - -/* PCI Access Control Base Low Register (PACBLR) */ -#define PACBLR_EN BIT0 /* Access control window enable */ - -#define PACBLR_ACCPROT BIT4 /* Access Protect */ -#define PACBLR_WRPROT BIT5 /* Write Protect */ - -#define PACBLR_PCISWAP_OFFS 6 /* PCI slave Data Swap Control */ -#define PACBLR_PCISWAP_MASK (0x3 << PACBLR_PCISWAP_OFFS) -#define PACBLR_PCISWAP_BYTE (0x0 << PACBLR_PCISWAP_OFFS) -#define PACBLR_PCISWAP_NO_SWAP (0x1 << PACBLR_PCISWAP_OFFS) -#define PACBLR_PCISWAP_BYTE_WORD (0x2 << PACBLR_PCISWAP_OFFS) -#define PACBLR_PCISWAP_WORD (0x3 << PACBLR_PCISWAP_OFFS) - -#define PACBLR_RDMBURST_OFFS 8 /* Read Max Burst */ -#define PACBLR_RDMBURST_MASK (0x3 << PACBLR_RDMBURST_OFFS) -#define PACBLR_RDMBURST_32BYTE (0x0 << PACBLR_RDMBURST_OFFS) -#define PACBLR_RDMBURST_64BYTE (0x1 << PACBLR_RDMBURST_OFFS) -#define PACBLR_RDMBURST_128BYTE (0x2 << PACBLR_RDMBURST_OFFS) - -#define PACBLR_RDSIZE_OFFS 10 /* Typical PCI read transaction Size. */ -#define PACBLR_RDSIZE_MASK (0x3 << PACBLR_RDSIZE_OFFS) -#define PACBLR_RDSIZE_32BYTE (0x0 << PACBLR_RDSIZE_OFFS) -#define PACBLR_RDSIZE_64BYTE (0x1 << PACBLR_RDSIZE_OFFS) -#define PACBLR_RDSIZE_128BYTE (0x2 << PACBLR_RDSIZE_OFFS) -#define PACBLR_RDSIZE_256BYTE (0x3 << PACBLR_RDSIZE_OFFS) - -#define PACBLR_BASE_L_OFFS 12 /* Corresponds to address bits [31:12] */ -#define PACBLR_BASE_L_MASK (0xfffff << PACBLR_BASE_L_OFFS) -#define PACBLR_BASE_L_ALIGNMENT (1 << PACBLR_BASE_L_OFFS) -#define PACBLR_BASE_ALIGN_UP(base) \ - ((base+PACBLR_BASE_L_ALIGNMENT)&PACBLR_BASE_L_MASK) -#define PACBLR_BASE_ALIGN_DOWN(base) (base & PACBLR_BASE_L_MASK) - - -/* PCI Access Control Base High Register (PACBHR) */ -#define PACBHR_BASE_H_OFFS 0 /* Corresponds to address bits [63:32] */ -#define PACBHR_CTRL_BASE_H_MASK (0xffffffff << PACBHR_BASE_H_OFFS) - -/* PCI Access Control Size Register (PACSR) */ -#define PACSR_WRMBURST_OFFS 8 /* Write Max Burst */ -#define PACSR_WRMBURST_MASK (0x3 << PACSR_WRMBURST_OFFS) -#define PACSR_WRMBURST_32BYTE (0x0 << PACSR_WRMBURST_OFFS) -#define PACSR_WRMBURST_64BYTE (0x1 << PACSR_WRMBURST_OFFS) -#define PACSR_WRMBURST_128BYTE (0x2 << PACSR_WRMBURST_OFFS) - -#define PACSR_PCI_ORDERING BIT11 /* PCI Ordering required */ - -#define PACSR_SIZE_OFFS 12 /* PCI access window size */ -#define PACSR_SIZE_MASK (0xfffff << PACSR_SIZE_OFFS) -#define PACSR_SIZE_ALIGNMENT (1 << PACSR_SIZE_OFFS) -#define PACSR_SIZE_ALIGN_UP(size) \ - ((size+PACSR_SIZE_ALIGNMENT)&PACSR_SIZE_MASK) -#define PACSR_SIZE_ALIGN_DOWN(size) (size & PACSR_SIZE_MASK) - - -/***************************************/ -/* PCI Configuration Access Registers */ -/***************************************/ - -#define PCI_CONFIG_ADDR_REG(pciIf) (0x30C78 - ((pciIf) * 0x80) ) -#define PCI_CONFIG_DATA_REG(pciIf) (0x30C7C - ((pciIf) * 0x80) ) -#define PCI_INT_ACK_REG(pciIf) (0x30C34 + ((pciIf) * 0x80) ) - -/* PCI Configuration Address Register (PCAR) */ -#define PCAR_REG_NUM_OFFS 2 -#define PCAR_REG_NUM_MASK (0x3F << PCAR_REG_NUM_OFFS) - -#define PCAR_FUNC_NUM_OFFS 8 -#define PCAR_FUNC_NUM_MASK (0x7 << PCAR_FUNC_NUM_OFFS) - -#define PCAR_DEVICE_NUM_OFFS 11 -#define PCAR_DEVICE_NUM_MASK (0x1F << PCAR_DEVICE_NUM_OFFS) - -#define PCAR_BUS_NUM_OFFS 16 -#define PCAR_BUS_NUM_MASK (0xFF << PCAR_BUS_NUM_OFFS) - -#define PCAR_CONFIG_EN BIT31 - - -/***************************************/ -/* PCI Configuration registers */ -/***************************************/ - -/*********************************************/ -/* PCI Configuration, Function 0, Registers */ -/*********************************************/ - -/* Marvell Specific */ -#define PCI_SCS0_BASE_ADDR_LOW 0x010 -#define PCI_SCS0_BASE_ADDR_HIGH 0x014 -#define PCI_SCS1_BASE_ADDR_LOW 0x018 -#define PCI_SCS1_BASE_ADDR_HIGH 0x01C -#define PCI_INTER_REG_MEM_MAPPED_BASE_ADDR_L 0x020 -#define PCI_INTER_REG_MEM_MAPPED_BASE_ADDR_H 0x024 - -/* capability list */ -#define PCI_POWER_MNG_CAPABILITY 0x040 -#define PCI_POWER_MNG_STATUS_CONTROL 0x044 -#define PCI_VPD_ADDRESS_REG 0x048 -#define PCI_VPD_DATA_REG 0x04c -#define PCI_MSI_MESSAGE_CONTROL 0x050 -#define PCI_MSI_MESSAGE_ADDR 0x054 -#define PCI_MSI_MESSAGE_UPPER_ADDR 0x058 -#define PCI_MSI_MESSAGE_DATA 0x05c -#define PCIX_COMMAND 0x060 -#define PCIX_STATUS 0x064 -#define PCI_COMPACT_PCI_HOT_SWAP 0x068 - - -/*********************************************/ -/* PCI Configuration, Function 1, Registers */ -/*********************************************/ - -#define PCI_SCS2_BASE_ADDR_LOW 0x10 -#define PCI_SCS2_BASE_ADDR_HIGH 0x14 -#define PCI_SCS3_BASE_ADDR_LOW 0x18 -#define PCI_SCS3_BASE_ADDR_HIGH 0x1c - - -/***********************************************/ -/* PCI Configuration, Function 2, Registers */ -/***********************************************/ - -#define PCI_DEVCS0_BASE_ADDR_LOW 0x10 -#define PCI_DEVCS0_BASE_ADDR_HIGH 0x14 -#define PCI_DEVCS1_BASE_ADDR_LOW 0x18 -#define PCI_DEVCS1_BASE_ADDR_HIGH 0x1c -#define PCI_DEVCS2_BASE_ADDR_LOW 0x20 -#define PCI_DEVCS2_BASE_ADDR_HIGH 0x24 - -/***********************************************/ -/* PCI Configuration, Function 3, Registers */ -/***********************************************/ - -#define PCI_BOOTCS_BASE_ADDR_LOW 0x18 -#define PCI_BOOTCS_BASE_ADDR_HIGH 0x1c - -/***********************************************/ -/* PCI Configuration, Function 4, Registers */ -/***********************************************/ - -#define PCI_P2P_MEM0_BASE_ADDR_LOW 0x10 -#define PCI_P2P_MEM0_BASE_ADDR_HIGH 0x14 -#define PCI_P2P_IO_BASE_ADDR 0x20 -#define PCI_INTER_REGS_IO_MAPPED_BASE_ADDR 0x24 - -/* PCIX_STATUS register fields (PXS) */ - -#define PXS_FN_OFFS 0 /* Description Number */ -#define PXS_FN_MASK (0x7 << PXS_FN_OFFS) - -#define PXS_DN_OFFS 3 /* Device Number */ -#define PXS_DN_MASK (0x1f << PXS_DN_OFFS) - -#define PXS_BN_OFFS 8 /* Bus Number */ -#define PXS_BN_MASK (0xff << PXS_BN_OFFS) - - -/* PCI Error Report Register Map */ -#define PCI_SERRN_MASK_REG(pciIf) (0x30c28 + (pciIf * 0x80)) -#define PCI_CAUSE_REG(pciIf) (0x31d58 + (pciIf * 0x80)) -#define PCI_MASK_REG(pciIf) (0x31d5C + (pciIf * 0x80)) -#define PCI_ERROR_ADDR_LOW_REG(pciIf) (0x31d40 + (pciIf * 0x80)) -#define PCI_ERROR_ADDR_HIGH_REG(pciIf) (0x31d44 + (pciIf * 0x80)) -#define PCI_ERROR_ATTRIBUTE_REG(pciIf) (0x31d48 + (pciIf * 0x80)) -#define PCI_ERROR_COMMAND_REG(pciIf) (0x31d50 + (pciIf * 0x80)) - -/* PCI Interrupt Cause Register (PICR) */ -#define PICR_ERR_SEL_OFFS 27 -#define PICR_ERR_SEL_MASK (0x1f << PICR_ERR_SEL_OFFS) - -/* PCI Error Command Register (PECR) */ -#define PECR_ERR_CMD_OFFS 0 -#define PECR_ERR_CMD_MASK (0xf << PECR_ERR_CMD_OFFS) -#define PECR_DAC BIT4 - - -/* defaults */ -/* Set bits means value is about to change according to new value */ -#define PCI_COMMAND_DEFAULT_MASK 0xffffdff1 -#define PCI_COMMAND_DEFAULT \ - (PCR_MASTER_WR_TRIG_WHOLE | \ - PCR_MASTER_RD_TRIG_WHOLE | \ - PCR_MASTER_MEM_RD_LINE_EN | \ - PCR_MASTER_MEM_RD_MULT_EN | \ - PCR_NS_ACCORDING_RCV_TRANS | \ - PCR_MASTER_PCIX_REQ64N_EN | \ - PCR_MASTER_DAC_EN | \ - PCR_MASTER_M64_ALLIGN | \ - PCR_ERRORS_PROPAGATION_EN) - - -#define PCI_ARBITER_CTRL_DEFAULT_MASK 0x801fc07a -#define PCI_ARBITER_CTRL_DEFAULT \ - (PACR_BROKEN_VAL_PCIX_MIN << PACR_BROKEN_VAL_OFFS) - - -#endif /* #ifndef __INCPCIREGSH */ - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pex/mvPex.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pex/mvPex.c deleted file mode 100644 index 068aac2..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pex/mvPex.c +++ /dev/null @@ -1,1143 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#include "pex/mvPex.h" - -#include "ctrlEnv/mvCtrlEnvLib.h" - -/* defines */ -#ifdef MV_DEBUG -#define DB(x) x -#else -#define DB(x) -#endif - -MV_STATUS mvPexHalInit(MV_U32 pexIf, MV_PEX_TYPE pexType) -{ - MV_PEX_MODE pexMode; - MV_U32 regVal; - MV_U32 status; - - /* First implement Guideline (GL# PCI Express-2) Wrong Default Value */ - /* to Transmitter Output Current (TXAMP) Relevant for: 88F5181-A1/B0/B1 */ - /* and 88F5281-B0 and above, 88F5182, 88F5082, 88F5181L, 88F6082/L */ - - if ((mvCtrlModelGet() != MV_1281_DEV_ID) && - (mvCtrlModelGet() != MV_6281_DEV_ID) && - (mvCtrlModelGet() != MV_6192_DEV_ID) && - (mvCtrlModelGet() != MV_6190_DEV_ID) && - (mvCtrlModelGet() != MV_6180_DEV_ID) && - (mvCtrlModelGet() != MV_6183_DEV_ID) && - (mvCtrlModelGet() != MV_6183L_DEV_ID) && - (mvCtrlModelGet() != MV_78100_DEV_ID) && - (mvCtrlModelGet() != MV_78200_DEV_ID) && - (mvCtrlModelGet() != MV_76100_DEV_ID) && - (mvCtrlModelGet() != MV_78XX0_DEV_ID)) - { - - /* Read current value of TXAMP */ - MV_REG_WRITE(0x41b00, 0x80820000); /* Write the read command */ - - regVal = MV_REG_READ(0x41b00); /* Extract the data */ - - /* Prepare new data for write */ - regVal &= ~0x7; /* Clear bits [2:0] */ - regVal |= 0x4; /* Set the new value */ - regVal &= ~0x80000000; /* Set "write" command */ - MV_REG_WRITE(0x41b00, regVal); /* Write the write command */ - - } - else - { - /* Implement 1.0V termination GL for 88F1281 device only */ - /* BIT0 - Common mode feedback */ - /* BIT3 - TxBuf, extra drive for 1.0V termination */ - if (mvCtrlModelGet() == MV_1281_DEV_ID) - { - MV_REG_WRITE(0x41b00, 0x80860000); /* Write the read command */ - regVal = MV_REG_READ(0x41b00); /* Extract the data */ - regVal |= (BIT0 | BIT3); - regVal &= ~0x80000000; /* Set "write" command */ - MV_REG_WRITE(0x41b00, regVal); /* Write the write command */ - - MV_REG_WRITE(0x31b00, 0x80860000); /* Write the read command */ - regVal = MV_REG_READ(0x31b00); /* Extract the data */ - regVal |= (BIT0 | BIT3); - regVal &= ~0x80000000; /* Set "write" command */ - MV_REG_WRITE(0x31b00, regVal); /* Write the write command */ - } - } - - if( mvPexModeGet(pexIf, &pexMode) != MV_OK) - { - mvOsPrintf("PEX init ERR. mvPexModeGet failed (pexType=%d)\n",pexMode.pexType); - return MV_ERROR; - } - - /* Check that required PEX type is the one set in reset time */ - if (pexType != pexMode.pexType) - { - /* No Link. Shut down the Phy */ - mvPexPowerDown(pexIf); - mvOsPrintf("PEX init ERR. PEX type sampled mismatch (%d,%d)\n",pexType,pexMode.pexType); - return MV_ERROR; - } - - if (MV_PEX_ROOT_COMPLEX == pexType) - { - mvPexLocalBusNumSet(pexIf, PEX_HOST_BUS_NUM(pexIf)); - mvPexLocalDevNumSet(pexIf, PEX_HOST_DEV_NUM(pexIf)); - - /* Local device master Enable */ - mvPexMasterEnable(pexIf, MV_TRUE); - - /* Local device slave Enable */ - mvPexSlaveEnable(pexIf, mvPexLocalBusNumGet(pexIf), - mvPexLocalDevNumGet(pexIf), MV_TRUE); - /* Interrupt disable */ - status = MV_REG_READ(PEX_CFG_DIRECT_ACCESS(pexIf, PEX_STATUS_AND_COMMAND)); - status |= PXSAC_INT_DIS; - MV_REG_WRITE(PEX_CFG_DIRECT_ACCESS(pexIf, PEX_STATUS_AND_COMMAND), status); - } - - /* now wait 500 ms to be sure the link is valid (spec compliant) */ - mvOsDelay(500); - /* Check if we have link */ - if (MV_REG_READ(PEX_STATUS_REG(pexIf)) & PXSR_DL_DOWN) - { - mvOsPrintf("PEX%d interface detected no Link.\n",pexIf); - return MV_NO_SUCH; - } - - if (MV_PEX_WITDH_X1 == pexMode.pexWidth) - { - mvOsPrintf("PEX%d interface detected Link X1\n",pexIf); - } - else - { - mvOsPrintf("PEX%d interface detected Link X4\n",pexIf); - } - -#ifdef PCIE_VIRTUAL_BRIDGE_SUPPORT - mvPexVrtBrgInit(pexIf); -#endif - return MV_OK; -} - -/******************************************************************************* -* mvPexModeGet - Get Pex Mode -* -* DESCRIPTION: -* -* INPUT: -* pexIf - PEX interface number. -* -* OUTPUT: -* pexMode - Pex mode structure -* -* RETURN: -* MV_OK on success , MV_ERROR otherwise -* -*******************************************************************************/ -MV_U32 mvPexModeGet(MV_U32 pexIf,MV_PEX_MODE *pexMode) -{ - MV_U32 pexData; - - /* Parameter checking */ - if (PEX_DEFAULT_IF != pexIf) - { - if (pexIf >= mvCtrlPexMaxIfGet()) - { - mvOsPrintf("mvPexModeGet: ERR. Invalid PEX interface %d\n",pexIf); - return MV_ERROR; - } - } - - pexData = MV_REG_READ(PEX_CTRL_REG(pexIf)); - - switch (pexData & PXCR_DEV_TYPE_CTRL_MASK) - { - case PXCR_DEV_TYPE_CTRL_CMPLX: - pexMode->pexType = MV_PEX_ROOT_COMPLEX; - break; - case PXCR_DEV_TYPE_CTRL_POINT: - pexMode->pexType = MV_PEX_END_POINT; - break; - - } - - /* Check if we have link */ - if (MV_REG_READ(PEX_STATUS_REG(pexIf)) & PXSR_DL_DOWN) - { - pexMode->pexLinkUp = MV_FALSE; - - /* If there is no link, the auto negotiation data is worthless */ - pexMode->pexWidth = MV_PEX_WITDH_INVALID; - } - else - { - pexMode->pexLinkUp = MV_TRUE; - - /* We have link. The link width is now valid */ - pexData = MV_REG_READ(PEX_CFG_DIRECT_ACCESS(pexIf, PEX_LINK_CTRL_STAT_REG)); - pexMode->pexWidth = ((pexData & PXLCSR_NEG_LNK_WDTH_MASK) >> - PXLCSR_NEG_LNK_WDTH_OFFS); - } - - return MV_OK; -} - - -/* PEX configuration space read write */ - -/******************************************************************************* -* mvPexConfigRead - Read from configuration space -* -* DESCRIPTION: -* This function performs a 32 bit read from PEX configuration space. -* It supports both type 0 and type 1 of Configuration Transactions -* (local and over bridge). In order to read from local bus segment, use -* bus number retrieved from mvPexLocalBusNumGet(). Other bus numbers -* will result configuration transaction of type 1 (over bridge). -* -* INPUT: -* pexIf - PEX interface number. -* bus - PEX segment bus number. -* dev - PEX device number. -* func - Function number. -* regOffs - Register offset. -* -* OUTPUT: -* None. -* -* RETURN: -* 32bit register data, 0xffffffff on error -* -*******************************************************************************/ -MV_U32 mvPexConfigRead (MV_U32 pexIf, MV_U32 bus, MV_U32 dev, MV_U32 func, - MV_U32 regOff) -{ -#if defined(PCIE_VIRTUAL_BRIDGE_SUPPORT) - return mvPexVrtBrgConfigRead (pexIf, bus, dev, func, regOff); -} - -MV_U32 mvPexHwConfigRead (MV_U32 pexIf, MV_U32 bus, MV_U32 dev, MV_U32 func, - MV_U32 regOff) -{ -#endif - MV_U32 pexData = 0; - MV_U32 localDev,localBus; - - /* Parameter checking */ - if (PEX_DEFAULT_IF != pexIf) - { - if (pexIf >= mvCtrlPexMaxIfGet()) - { - mvOsPrintf("mvPexConfigRead: ERR. Invalid PEX interface %d\n",pexIf); - return 0xFFFFFFFF; - } - } - - if (dev >= MAX_PEX_DEVICES) - { - DB(mvOsPrintf("mvPexConfigRead: ERR. device number illigal %d\n", dev)); - return 0xFFFFFFFF; - } - - if (func >= MAX_PEX_FUNCS) - { - DB(mvOsPrintf("mvPexConfigRead: ERR. function num illigal %d\n", func)); - return 0xFFFFFFFF; - } - - if (bus >= MAX_PEX_BUSSES) - { - DB(mvOsPrintf("mvPexConfigRead: ERR. bus number illigal %d\n", bus)); - return MV_ERROR; - } - - DB(mvOsPrintf("mvPexConfigRead: pexIf %d, bus %d, dev %d, func %d, regOff 0x%x\n", - pexIf, bus, dev, func, regOff)); - - localDev = mvPexLocalDevNumGet(pexIf); - localBus = mvPexLocalBusNumGet(pexIf); - - /* Speed up the process. In case on no link, return MV_ERROR */ - if ((dev != localDev) || (bus != localBus)) - { - pexData = MV_REG_READ(PEX_STATUS_REG(pexIf)); - - if ((pexData & PXSR_DL_DOWN)) - { - return MV_ERROR; - } - } - - /* in PCI Express we have only one device number */ - /* and this number is the first number we encounter - else that the localDev*/ - /* spec pex define return on config read/write on any device */ - if (bus == localBus) - { - if (localDev == 0) - { - /* if local dev is 0 then the first number we encounter - after 0 is 1 */ - if ((dev != 1)&&(dev != localDev)) - { - return MV_ERROR; - } - } - else - { - /* if local dev is not 0 then the first number we encounter - is 0 */ - - if ((dev != 0)&&(dev != localDev)) - { - return MV_ERROR; - } - } - if(func != 0 ) /* i.e bridge */ - { - return MV_ERROR; - } - } - - - /* Creating PEX address to be passed */ - pexData = (bus << PXCAR_BUS_NUM_OFFS); - pexData |= (dev << PXCAR_DEVICE_NUM_OFFS); - pexData |= (func << PXCAR_FUNC_NUM_OFFS); - pexData |= (regOff & PXCAR_REG_NUM_MASK); /* lgacy register space */ - /* extended register space */ - pexData |=(((regOff & PXCAR_REAL_EXT_REG_NUM_MASK) >> - PXCAR_REAL_EXT_REG_NUM_OFFS) << PXCAR_EXT_REG_NUM_OFFS); - - pexData |= PXCAR_CONFIG_EN; - - /* Write the address to the PEX configuration address register */ - MV_REG_WRITE(PEX_CFG_ADDR_REG(pexIf), pexData); - - DB(mvOsPrintf("mvPexConfigRead:address pexData=%x ",pexData)); - - - /* In order to let the PEX controller absorbed the address of the read */ - /* transaction we perform a validity check that the address was written */ - if(pexData != MV_REG_READ(PEX_CFG_ADDR_REG(pexIf))) - { - return MV_ERROR; - } - - /* cleaning Master Abort */ - MV_REG_BIT_SET(PEX_CFG_DIRECT_ACCESS(pexIf,PEX_STATUS_AND_COMMAND), - PXSAC_MABORT); -#if 0 - /* Guideline (GL# PCI Express-1) Erroneous Read Data on Configuration */ - /* This guideline is relevant for all devices except of the following devices: - 88F5281-BO and above, 88F5181L-A0 and above, 88F1281 A0 and above - 88F6183 A0 and above, 88F6183L */ - if ( ( (dev != localDev) || (bus != localBus) ) && - ( - !(MV_5281_DEV_ID == mvCtrlModelGet())&& - !((MV_5181_DEV_ID == mvCtrlModelGet())&& (mvCtrlRevGet() >= MV_5181L_A0_REV))&& - !(MV_1281_DEV_ID == mvCtrlModelGet())&& - !(MV_6183_DEV_ID == mvCtrlModelGet())&& - !(MV_6183L_DEV_ID == mvCtrlModelGet())&& - !(MV_6281_DEV_ID == mvCtrlModelGet())&& - !(MV_6192_DEV_ID == mvCtrlModelGet())&& - !(MV_6190_DEV_ID == mvCtrlModelGet())&& - !(MV_6180_DEV_ID == mvCtrlModelGet())&& - !(MV_78XX0_DEV_ID == mvCtrlModelGet()) - )) - { - - /* PCI-Express configuration read work-around */ - - /* we will use one of the Punit (AHBToMbus) windows to access the xbar - and read the data from there */ - /* - Need to configure the 2 free Punit (AHB to MBus bridge) - address decoding windows: - Configure the flash Window to handle Configuration space requests - for PEX0/1: - 1. write 0x7931/0x7941 to the flash window and the size, - 79-xbar attr (pci cfg), 3/4-xbar target (pex0/1), 1-WinEn - 2. write base to flash window - - Configuration transactions from the CPU should write/read the data - to/from address of the form: - addr[31:28] = 0x5 (for PEX0) or 0x6 (for PEX1) - addr[27:24] = extended register number - addr[23:16] = bus number - addr[15:11] = device number - addr[10:8] = function number - addr[7:0] = register number - */ - - #include "ctrlEnv/sys/mvAhbToMbus.h" - { - MV_U32 winNum; - MV_AHB_TO_MBUS_DEC_WIN originWin; - MV_U32 pciAddr=0; - MV_U32 remapLow=0,remapHigh=0; - - /* - We will use DEV_CS2\Flash window for this workarround - */ - - winNum = mvAhbToMbusWinTargetGet(PEX_CONFIG_RW_WA_TARGET); - - /* save remap values if exist */ - if ((1 == winNum)||(0 == winNum)) - { - remapLow = MV_REG_READ(AHB_TO_MBUS_WIN_REMAP_LOW_REG(winNum)); - remapHigh = MV_REG_READ(AHB_TO_MBUS_WIN_REMAP_HIGH_REG(winNum)); - - } - - - /* save the original window values */ - mvAhbToMbusWinGet(winNum,&originWin); - - if (PEX_CONFIG_RW_WA_USE_ORIGINAL_WIN_VALUES) - { - /* set the window as xbar window */ - if (pexIf) - { - MV_REG_WRITE(AHB_TO_MBUS_WIN_CTRL_REG(winNum), - (0x7931 | (((originWin.addrWin.size >> 16)-1) ) << 16)); - } - else - { - MV_REG_WRITE(AHB_TO_MBUS_WIN_CTRL_REG(winNum), - (0x7941 | (((originWin.addrWin.size >> 16)-1) ) << 16)); - } - - MV_REG_WRITE(AHB_TO_MBUS_WIN_BASE_REG(winNum), - originWin.addrWin.baseLow); - - /*pciAddr = originWin.addrWin.baseLow;*/ - pciAddr = (MV_U32)CPU_MEMIO_UNCACHED_ADDR( - (MV_U32)originWin.addrWin.baseLow); - - } - else - { - /* set the window as xbar window */ - if (pexIf) - { - MV_REG_WRITE(AHB_TO_MBUS_WIN_CTRL_REG(winNum), - (0x7931 | (((PEX_CONFIG_RW_WA_SIZE >> 16)-1) ) << 16)); - } - else - { - MV_REG_WRITE(AHB_TO_MBUS_WIN_CTRL_REG(winNum), - (0x7941 | (((PEX_CONFIG_RW_WA_SIZE >> 16)-1) ) << 16)); - } - - MV_REG_WRITE(AHB_TO_MBUS_WIN_BASE_REG(winNum), - PEX_CONFIG_RW_WA_BASE); - - pciAddr = (MV_U32)CPU_MEMIO_UNCACHED_ADDR(PEX_CONFIG_RW_WA_BASE); - } - - - /* remap should be as base */ - if ((1 == winNum)||(0 == winNum)) - { - MV_REG_WRITE(AHB_TO_MBUS_WIN_REMAP_LOW_REG(winNum),pciAddr); - MV_REG_WRITE(AHB_TO_MBUS_WIN_REMAP_HIGH_REG(winNum),0); - - } - - /* extended register space */ - pciAddr |= (bus << 16); - pciAddr |= (dev << 11); - pciAddr |= (func << 8); - pciAddr |= (regOff & PXCAR_REG_NUM_MASK); /* lgacy register space */ - - pexData = *(MV_U32*)pciAddr; - pexData = MV_32BIT_LE(pexData); /* Data always in LE */ - - /* restore the original window values */ - mvAhbToMbusWinSet(winNum,&originWin); - - /* restore original remap values*/ - if ((1 == winNum)||(0 == winNum)) - { - MV_REG_WRITE(AHB_TO_MBUS_WIN_REMAP_LOW_REG(winNum),remapLow); - MV_REG_WRITE(AHB_TO_MBUS_WIN_REMAP_HIGH_REG(winNum),remapHigh); - - } - } - } - else -#endif - { - /* Read the Data returned in the PEX Data register */ - pexData = MV_REG_READ(PEX_CFG_DATA_REG(pexIf)); - - } - - DB(mvOsPrintf("mvPexConfigRead: got : %x \n",pexData)); - - return pexData; - -} - -/******************************************************************************* -* mvPexConfigWrite - Write to configuration space -* -* DESCRIPTION: -* This function performs a 32 bit write to PEX configuration space. -* It supports both type 0 and type 1 of Configuration Transactions -* (local and over bridge). In order to write to local bus segment, use -* bus number retrieved from mvPexLocalBusNumGet(). Other bus numbers -* will result configuration transaction of type 1 (over bridge). -* -* INPUT: -* pexIf - PEX interface number. -* bus - PEX segment bus number. -* dev - PEX device number. -* func - Function number. -* regOffs - Register offset. -* data - 32bit data. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM for bad parameters ,MV_ERROR on error ! otherwise MV_OK -* -*******************************************************************************/ -MV_STATUS mvPexConfigWrite(MV_U32 pexIf, MV_U32 bus, MV_U32 dev, - MV_U32 func, MV_U32 regOff, MV_U32 data) -{ -#if defined(PCIE_VIRTUAL_BRIDGE_SUPPORT) - return mvPexVrtBrgConfigWrite (pexIf, bus, dev, func, regOff, data); -} - -MV_STATUS mvPexHwConfigWrite(MV_U32 pexIf, MV_U32 bus, MV_U32 dev, - MV_U32 func, MV_U32 regOff, MV_U32 data) -{ -#endif - MV_U32 pexData = 0; - MV_U32 localDev,localBus; - - /* Parameter checking */ - if (PEX_DEFAULT_IF != pexIf) - { - if (pexIf >= mvCtrlPexMaxIfGet()) - { - mvOsPrintf("mvPexConfigWrite: ERR. Invalid PEX interface %d\n", - pexIf); - return MV_ERROR; - } - } - - if (dev >= MAX_PEX_DEVICES) - { - mvOsPrintf("mvPexConfigWrite: ERR. device number illigal %d\n",dev); - return MV_BAD_PARAM; - } - - if (func >= MAX_PEX_FUNCS) - { - mvOsPrintf("mvPexConfigWrite: ERR. function number illigal %d\n", func); - return MV_ERROR; - } - - if (bus >= MAX_PEX_BUSSES) - { - mvOsPrintf("mvPexConfigWrite: ERR. bus number illigal %d\n", bus); - return MV_ERROR; - } - - - - localDev = mvPexLocalDevNumGet(pexIf); - localBus = mvPexLocalBusNumGet(pexIf); - - - /* in PCI Express we have only one device number other than ourselves*/ - /* and this number is the first number we encounter - else than the localDev that can be any valid dev number*/ - /* pex spec define return on config read/write on any device */ - if (bus == localBus) - { - - if (localDev == 0) - { - /* if local dev is 0 then the first number we encounter - after 0 is 1 */ - if ((dev != 1)&&(dev != localDev)) - { - return MV_ERROR; - } - - } - else - { - /* if local dev is not 0 then the first number we encounter - is 0 */ - - if ((dev != 0)&&(dev != localDev)) - { - return MV_ERROR; - } - } - - - } - - /* if we are not accessing ourselves , then check the link */ - if ((dev != localDev) || (bus != localBus) ) - { - /* workarround */ - /* when no link return MV_ERROR */ - - pexData = MV_REG_READ(PEX_STATUS_REG(pexIf)); - - if ((pexData & PXSR_DL_DOWN)) - { - return MV_ERROR; - } - - } - - pexData =0; - - /* Creating PEX address to be passed */ - pexData |= (bus << PXCAR_BUS_NUM_OFFS); - pexData |= (dev << PXCAR_DEVICE_NUM_OFFS); - pexData |= (func << PXCAR_FUNC_NUM_OFFS); - pexData |= (regOff & PXCAR_REG_NUM_MASK); /* lgacy register space */ - /* extended register space */ - pexData |=(((regOff & PXCAR_REAL_EXT_REG_NUM_MASK) >> - PXCAR_REAL_EXT_REG_NUM_OFFS) << PXCAR_EXT_REG_NUM_OFFS); - pexData |= PXCAR_CONFIG_EN; - - DB(mvOsPrintf("mvPexConfigWrite: If=%x bus=%x func=%x dev=%x regOff=%x data=%x \n", - pexIf,bus,func,dev,regOff,data,pexData) ); - - /* Write the address to the PEX configuration address register */ - MV_REG_WRITE(PEX_CFG_ADDR_REG(pexIf), pexData); - - /* Clear CPU pipe. Important where CPU can perform OOO execution */ - CPU_PIPE_FLUSH; - - /* In order to let the PEX controller absorbed the address of the read */ - /* transaction we perform a validity check that the address was written */ - if(pexData != MV_REG_READ(PEX_CFG_ADDR_REG(pexIf))) - { - return MV_ERROR; - } - - /* Write the Data passed to the PEX Data register */ - MV_REG_WRITE(PEX_CFG_DATA_REG(pexIf), data); - - return MV_OK; - -} - -/******************************************************************************* -* mvPexMasterEnable - Enable/disale PEX interface master transactions. -* -* DESCRIPTION: -* This function performs read modified write to PEX command status -* (offset 0x4) to set/reset bit 2. After this bit is set, the PEX -* master is allowed to gain ownership on the bus, otherwise it is -* incapable to do so. -* -* INPUT: -* pexIf - PEX interface number. -* enable - Enable/disable parameter. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM for bad parameters ,MV_ERROR on error ! otherwise MV_OK -* -*******************************************************************************/ -MV_STATUS mvPexMasterEnable(MV_U32 pexIf, MV_BOOL enable) -{ - MV_U32 pexCommandStatus; - MV_U32 localBus; - MV_U32 localDev; - - /* Parameter checking */ - if (pexIf >= mvCtrlPexMaxIfGet()) - { - mvOsPrintf("mvPexMasterEnable: ERR. Invalid PEX interface %d\n", pexIf); - return MV_ERROR; - } - - localBus = mvPexLocalBusNumGet(pexIf); - localDev = mvPexLocalDevNumGet(pexIf); - - pexCommandStatus = MV_REG_READ(PEX_CFG_DIRECT_ACCESS(pexIf, - PEX_STATUS_AND_COMMAND)); - - - if (MV_TRUE == enable) - { - pexCommandStatus |= PXSAC_MASTER_EN; - } - else - { - pexCommandStatus &= ~PXSAC_MASTER_EN; - } - - - MV_REG_WRITE(PEX_CFG_DIRECT_ACCESS(pexIf,PEX_STATUS_AND_COMMAND), - pexCommandStatus); - - return MV_OK; -} - - -/******************************************************************************* -* mvPexSlaveEnable - Enable/disale PEX interface slave transactions. -* -* DESCRIPTION: -* This function performs read modified write to PEX command status -* (offset 0x4) to set/reset bit 0 and 1. After those bits are set, -* the PEX slave is allowed to respond to PEX IO space access (bit 0) -* and PEX memory space access (bit 1). -* -* INPUT: -* pexIf - PEX interface number. -* dev - PEX device number. -* enable - Enable/disable parameter. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_BAD_PARAM for bad parameters ,MV_ERROR on error ! otherwise MV_OK -* -*******************************************************************************/ -MV_STATUS mvPexSlaveEnable(MV_U32 pexIf, MV_U32 bus,MV_U32 dev, MV_BOOL enable) -{ - MV_U32 pexCommandStatus; - MV_U32 RegOffs; - - /* Parameter checking */ - if (pexIf >= mvCtrlPexMaxIfGet()) - { - mvOsPrintf("mvPexSlaveEnable: ERR. Invalid PEX interface %d\n", pexIf); - return MV_BAD_PARAM; - } - if (dev >= MAX_PEX_DEVICES) - { - mvOsPrintf("mvPexLocalDevNumSet: ERR. device number illigal %d\n", dev); - return MV_BAD_PARAM; - - } - - - RegOffs = PEX_STATUS_AND_COMMAND; - - pexCommandStatus = mvPexConfigRead(pexIf, bus, dev, 0, RegOffs); - - if (MV_TRUE == enable) - { - pexCommandStatus |= (PXSAC_IO_EN | PXSAC_MEM_EN); - } - else - { - pexCommandStatus &= ~(PXSAC_IO_EN | PXSAC_MEM_EN); - } - - mvPexConfigWrite(pexIf, bus, dev, 0, RegOffs, pexCommandStatus); - - return MV_OK; - -} - -/******************************************************************************* -* mvPexLocalBusNumSet - Set PEX interface local bus number. -* -* DESCRIPTION: -* This function sets given PEX interface its local bus number. -* Note: In case the PEX interface is PEX-X, the information is read-only. -* -* INPUT: -* pexIf - PEX interface number. -* busNum - Bus number. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_NOT_ALLOWED in case PEX interface is PEX-X. -* MV_BAD_PARAM on bad parameters , -* otherwise MV_OK -* -*******************************************************************************/ -MV_STATUS mvPexLocalBusNumSet(MV_U32 pexIf, MV_U32 busNum) -{ - MV_U32 pexStatus; - MV_U32 localBus; - MV_U32 localDev; - - - /* Parameter checking */ - if (pexIf >= mvCtrlPexMaxIfGet()) - { - mvOsPrintf("mvPexLocalBusNumSet: ERR. Invalid PEX interface %d\n",pexIf); - return MV_BAD_PARAM; - } - if (busNum >= MAX_PEX_BUSSES) - { - mvOsPrintf("mvPexLocalBusNumSet: ERR. bus number illigal %d\n", busNum); - return MV_ERROR; - - } - - localBus = mvPexLocalBusNumGet(pexIf); - localDev = mvPexLocalDevNumGet(pexIf); - - - - pexStatus = MV_REG_READ(PEX_STATUS_REG(pexIf)); - - pexStatus &= ~PXSR_PEX_BUS_NUM_MASK; - - pexStatus |= (busNum << PXSR_PEX_BUS_NUM_OFFS) & PXSR_PEX_BUS_NUM_MASK; - - MV_REG_WRITE(PEX_STATUS_REG(pexIf), pexStatus); - - - return MV_OK; -} - - -/******************************************************************************* -* mvPexLocalBusNumGet - Get PEX interface local bus number. -* -* DESCRIPTION: -* This function gets the local bus number of a given PEX interface. -* -* INPUT: -* pexIf - PEX interface number. -* -* OUTPUT: -* None. -* -* RETURN: -* Local bus number.0xffffffff on Error -* -*******************************************************************************/ -MV_U32 mvPexLocalBusNumGet(MV_U32 pexIf) -{ - MV_U32 pexStatus; - - /* Parameter checking */ - if (PEX_DEFAULT_IF != pexIf) - { - if (pexIf >= mvCtrlPexMaxIfGet()) - { - mvOsPrintf("mvPexLocalBusNumGet: ERR. Invalid PEX interface %d\n",pexIf); - return 0xFFFFFFFF; - } - } - - - pexStatus = MV_REG_READ(PEX_STATUS_REG(pexIf)); - - pexStatus &= PXSR_PEX_BUS_NUM_MASK; - - return (pexStatus >> PXSR_PEX_BUS_NUM_OFFS); - -} - - -/******************************************************************************* -* mvPexLocalDevNumSet - Set PEX interface local device number. -* -* DESCRIPTION: -* This function sets given PEX interface its local device number. -* Note: In case the PEX interface is PEX-X, the information is read-only. -* -* INPUT: -* pexIf - PEX interface number. -* devNum - Device number. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_NOT_ALLOWED in case PEX interface is PEX-X. -* MV_BAD_PARAM on bad parameters , -* otherwise MV_OK -* -*******************************************************************************/ -MV_STATUS mvPexLocalDevNumSet(MV_U32 pexIf, MV_U32 devNum) -{ - MV_U32 pexStatus; - MV_U32 localBus; - MV_U32 localDev; - - /* Parameter checking */ - if (pexIf >= mvCtrlPexMaxIfGet()) - { - mvOsPrintf("mvPexLocalDevNumSet: ERR. Invalid PEX interface %d\n",pexIf); - return MV_BAD_PARAM; - } - if (devNum >= MAX_PEX_DEVICES) - { - mvOsPrintf("mvPexLocalDevNumSet: ERR. device number illigal %d\n", - devNum); - return MV_BAD_PARAM; - - } - - localBus = mvPexLocalBusNumGet(pexIf); - localDev = mvPexLocalDevNumGet(pexIf); - - - pexStatus = MV_REG_READ(PEX_STATUS_REG(pexIf)); - - pexStatus &= ~PXSR_PEX_DEV_NUM_MASK; - - pexStatus |= (devNum << PXSR_PEX_DEV_NUM_OFFS) & PXSR_PEX_DEV_NUM_MASK; - - MV_REG_WRITE(PEX_STATUS_REG(pexIf), pexStatus); - - - return MV_OK; -} - -/******************************************************************************* -* mvPexLocalDevNumGet - Get PEX interface local device number. -* -* DESCRIPTION: -* This function gets the local device number of a given PEX interface. -* -* INPUT: -* pexIf - PEX interface number. -* -* OUTPUT: -* None. -* -* RETURN: -* Local device number. 0xffffffff on Error -* -*******************************************************************************/ -MV_U32 mvPexLocalDevNumGet(MV_U32 pexIf) -{ - MV_U32 pexStatus; - - /* Parameter checking */ - - if (PEX_DEFAULT_IF != pexIf) - { - if (pexIf >= mvCtrlPexMaxIfGet()) - { - mvOsPrintf("mvPexLocalDevNumGet: ERR. Invalid PEX interface %d\n", - pexIf); - return 0xFFFFFFFF; - } - } - - pexStatus = MV_REG_READ(PEX_STATUS_REG(pexIf)); - - pexStatus &= PXSR_PEX_DEV_NUM_MASK; - - return (pexStatus >> PXSR_PEX_DEV_NUM_OFFS); -} - -MV_VOID mvPexPhyRegRead(MV_U32 pexIf, MV_U32 regOffset, MV_U16 *value) -{ - - MV_U32 regAddr; - if (pexIf >= mvCtrlPexMaxIfGet()) - { - mvOsPrintf("mvPexPhyRegRead: ERR. Invalid PEX interface %d\n", pexIf); - return; - } - regAddr = (BIT31 | ((regOffset & 0x3fff) << 16)); - MV_REG_WRITE(PEX_PHY_ACCESS_REG(pexIf), regAddr); - *value = MV_REG_READ(PEX_PHY_ACCESS_REG(pexIf)); -} - - -MV_VOID mvPexPhyRegWrite(MV_U32 pexIf, MV_U32 regOffset, MV_U16 value) -{ - - MV_U32 regAddr; - if(pexIf >= mvCtrlPexMaxIfGet()) - { - mvOsPrintf("mvPexPhyRegWrite: ERR. Invalid PEX interface %d\n", pexIf); - return; - } - regAddr = (((regOffset & 0x3fff) << 16) | value); - MV_REG_WRITE(PEX_PHY_ACCESS_REG(pexIf), regAddr); -} - -/******************************************************************************* -* mvPexActiveStateLinkPMEnable -* -* DESCRIPTION: -* Enable Active Link State Power Management -* -* INPUT: -* pexIf - PEX interface number. -* enable - MV_TRUE to enable ASPM, MV_FALSE to disable. -* -* OUTPUT: -* None -* -* RETURN: -* MV_OK on success , MV_ERROR otherwise -* -*******************************************************************************/ -MV_STATUS mvPexActiveStateLinkPMEnable(MV_U32 pexIf, MV_BOOL enable) -{ - MV_U32 reg; - - if(pexIf >= mvCtrlPexMaxIfGet()) - { - mvOsPrintf("mvPexActiveStateLinkPMEnable: ERR. Invalid PEX interface %d\n", pexIf); - return MV_ERROR; - } - - reg = MV_REG_READ(PEX_PWR_MNG_EXT_REG(pexIf)) & ~PXPMER_L1_ASPM_EN_MASK; - if(enable == MV_TRUE) - reg |= PXPMER_L1_ASPM_EN_MASK; - MV_REG_WRITE(PEX_PWR_MNG_EXT_REG(pexIf), reg); - - /* Enable / Disable L0/1 entry */ - reg = MV_REG_READ(PEX_CFG_DIRECT_ACCESS(pexIf, PEX_LINK_CTRL_STAT_REG)) - & ~PXLCSR_ASPM_CNT_MASK; - if(enable == MV_TRUE) - reg |= PXLCSR_ASPM_CNT_L0S_L1S_ENT_SUPP; - MV_REG_WRITE(PEX_CFG_DIRECT_ACCESS(pexIf, PEX_LINK_CTRL_STAT_REG), reg); - - return MV_OK; -} - - -/******************************************************************************* -* mvPexForceX1 -* -* DESCRIPTION: -* shut down lanes 1-3 if recognize that attached to an x1 end-point -* INPUT: -* pexIf - PEX interface number. -* -* OUTPUT: -* None -* -* RETURN: -* MV_OK on success , MV_ERROR otherwise -* -*******************************************************************************/ -MV_U32 mvPexForceX1(MV_U32 pexIf) -{ - MV_U32 regData = 0; - if(pexIf >= mvCtrlPexMaxIfGet()) - { - mvOsPrintf("mvPexForceX1: ERR. Invalid PEX interface %d\n", pexIf); - return MV_BAD_PARAM; - } - - regData = MV_REG_READ(PEX_CTRL_REG(pexIf)) & ~(PXCR_CONF_LINK_MASK) ; - regData |= PXCR_CONF_LINK_X1; - - MV_REG_WRITE(PEX_CTRL_REG(pexIf), regData); - return MV_OK; -} - -MV_BOOL mvPexIsPowerUp(MV_U32 pexIf) -{ - if(pexIf >= mvCtrlPexMaxIfGet()) - { - mvOsPrintf("mvPexIsPowerUp: ERR. Invalid PEX interface %d\n", pexIf); - return MV_FALSE; - } - return mvCtrlPwrClckGet(PEX_UNIT_ID, pexIf); -} - - -MV_VOID mvPexPowerDown(MV_U32 pexIf) -{ - if ( (mvCtrlModelGet() == MV_78XX0_DEV_ID) || - (mvCtrlModelGet() == MV_76100_DEV_ID) || - (mvCtrlModelGet() == MV_78100_DEV_ID) || - (mvCtrlModelGet() == MV_78200_DEV_ID) ) - { - mvCtrlPwrClckSet(PEX_UNIT_ID, pexIf, MV_FALSE); - } - else - { - MV_REG_WRITE((0x41B00 -(pexIf)*0x10000), 0x20800087); - } -} - - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pex/mvPex.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pex/mvPex.h deleted file mode 100644 index d8f1cdd..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pex/mvPex.h +++ /dev/null @@ -1,168 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCPEXH -#define __INCPEXH - -#include "mvCommon.h" -#include "mvOs.h" -#include "pex/mvPexRegs.h" -#include "ctrlEnv/mvCtrlEnvSpec.h" - - - -/* NOTE not supported in this driver:*/ - - -/* defines */ -/* The number of supported PEX interfaces depend on Marvell controller */ -/* device number. This device number ID is located on the PEX unit */ -/* configuration header. This creates a loop where calling PEX */ -/* configuration read/write routine results a call to get PEX configuration */ -/* information etc. This macro defines a default PEX interface. This PEX */ -/* interface is sure to exist. */ -#define PEX_DEFAULT_IF 0 - - -/* typedefs */ -/* The Marvell controller supports both root complex and end point devices */ -/* This enumeration describes the PEX type. */ -typedef enum _mvPexType -{ - MV_PEX_ROOT_COMPLEX, /* root complex device */ - MV_PEX_END_POINT /* end point device */ -}MV_PEX_TYPE; - -typedef enum _mvPexWidth -{ - MV_PEX_WITDH_X1 = 1, - MV_PEX_WITDH_X2, - MV_PEX_WITDH_X3, - MV_PEX_WITDH_X4, - MV_PEX_WITDH_INVALID -}MV_PEX_WIDTH; - -/* PEX Bar attributes */ -typedef struct _mvPexMode -{ - MV_PEX_TYPE pexType; - MV_PEX_WIDTH pexWidth; - MV_BOOL pexLinkUp; -}MV_PEX_MODE; - - - -/* Global Functions prototypes */ -/* mvPexInit - Initialize PEX interfaces*/ -MV_STATUS mvPexHalInit(MV_U32 pexIf, MV_PEX_TYPE pexType); - -/* mvPexModeGet - Get Pex If mode */ -MV_U32 mvPexModeGet(MV_U32 pexIf,MV_PEX_MODE *pexMode); - -/* mvPexConfigRead - Read from configuration space */ -MV_U32 mvPexConfigRead (MV_U32 pexIf, MV_U32 bus, MV_U32 dev, - MV_U32 func,MV_U32 regOff); - -/* mvPexConfigWrite - Write to configuration space */ -MV_STATUS mvPexConfigWrite(MV_U32 pexIf, MV_U32 bus, MV_U32 dev, - MV_U32 func, MV_U32 regOff, MV_U32 data); - -/* mvPexMasterEnable - Enable/disale PEX interface master transactions.*/ -MV_STATUS mvPexMasterEnable(MV_U32 pexIf, MV_BOOL enable); - -/* mvPexSlaveEnable - Enable/disale PEX interface slave transactions.*/ -MV_STATUS mvPexSlaveEnable(MV_U32 pexIf, MV_U32 bus,MV_U32 dev, MV_BOOL enable); - -/* mvPexLocalBusNumSet - Set PEX interface local bus number.*/ -MV_STATUS mvPexLocalBusNumSet(MV_U32 pexIf, MV_U32 busNum); - -/* mvPexLocalBusNumGet - Get PEX interface local bus number.*/ -MV_U32 mvPexLocalBusNumGet(MV_U32 pexIf); - -/* mvPexLocalDevNumSet - Set PEX interface local device number.*/ -MV_STATUS mvPexLocalDevNumSet(MV_U32 pexIf, MV_U32 devNum); - -/* mvPexLocalDevNumGet - Get PEX interface local device number.*/ -MV_U32 mvPexLocalDevNumGet(MV_U32 pexIf); -/* mvPexForceX1 - Force PEX interface to X1 mode. */ -MV_U32 mvPexForceX1(MV_U32 pexIf); - -/* mvPexIsPowerUp - Is PEX interface Power up? */ -MV_BOOL mvPexIsPowerUp(MV_U32 pexIf); - -/* mvPexPowerDown - Power Down */ -MV_VOID mvPexPowerDown(MV_U32 pexIf); - -/* mvPexPowerUp - Power Up */ -MV_VOID mvPexPowerUp(MV_U32 pexIf); - -/* mvPexPhyRegRead - Pex phy read */ -MV_VOID mvPexPhyRegRead(MV_U32 pexIf, MV_U32 regOffset, MV_U16 *value); - -/* mvPexPhyRegWrite - Pex phy write */ -MV_VOID mvPexPhyRegWrite(MV_U32 pexIf, MV_U32 regOffset, MV_U16 value); - -MV_STATUS mvPexActiveStateLinkPMEnable(MV_U32 pexIf, MV_BOOL enable); - -#endif /* #ifndef __INCPEXH */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pex/mvPexRegs.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pex/mvPexRegs.h deleted file mode 100644 index 8ac1698..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pex/mvPexRegs.h +++ /dev/null @@ -1,751 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCPEXREGSH -#define __INCPEXREGSH - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* defines */ -#define MAX_PEX_DEVICES 32 -#define MAX_PEX_FUNCS 8 -#define MAX_PEX_BUSSES 256 - - - -/*********************************************************/ -/* PCI Express Configuration Cycles Generation Registers */ -/*********************************************************/ - -#define PEX_CFG_ADDR_REG(pexIf) ((PEX_IF_BASE(pexIf)) + 0x18F8) -#define PEX_CFG_DATA_REG(pexIf) ((PEX_IF_BASE(pexIf)) + 0x18FC) -#define PEX_PHY_ACCESS_REG(pexIf) ((PEX_IF_BASE(pexIf)) + 0x1B00) -/* PCI Express Configuration Address Register */ -/* PEX_CFG_ADDR_REG (PXCAR)*/ - -#define PXCAR_REG_NUM_OFFS 2 -#define PXCAR_REG_NUM_MAX 0x3F -#define PXCAR_REG_NUM_MASK (PXCAR_REG_NUM_MAX << PXCAR_REG_NUM_OFFS) -#define PXCAR_FUNC_NUM_OFFS 8 -#define PXCAR_FUNC_NUM_MAX 0x7 -#define PXCAR_FUNC_NUM_MASK (PXCAR_FUNC_NUM_MAX << PXCAR_FUNC_NUM_OFFS) -#define PXCAR_DEVICE_NUM_OFFS 11 -#define PXCAR_DEVICE_NUM_MAX 0x1F -#define PXCAR_DEVICE_NUM_MASK (PXCAR_DEVICE_NUM_MAX << PXCAR_DEVICE_NUM_OFFS) -#define PXCAR_BUS_NUM_OFFS 16 -#define PXCAR_BUS_NUM_MAX 0xFF -#define PXCAR_BUS_NUM_MASK (PXCAR_BUS_NUM_MAX << PXCAR_BUS_NUM_OFFS) -#define PXCAR_EXT_REG_NUM_OFFS 24 -#define PXCAR_EXT_REG_NUM_MAX 0xF - -/* in pci express register address is now the legacy register address (8 bits) -with the new extended register address (more 4 bits) , below is the mask of -the upper 4 bits of the full register address */ - -#define PXCAR_REAL_EXT_REG_NUM_OFFS 8 -#define PXCAR_EXT_REG_NUM_MASK (PXCAR_EXT_REG_NUM_MAX << PXCAR_EXT_REG_NUM_OFFS) -#define PXCAR_CONFIG_EN BIT31 - -#define PXCAR_REAL_EXT_REG_NUM_OFFS 8 -#define PXCAR_REAL_EXT_REG_NUM_MASK (0xF << PXCAR_REAL_EXT_REG_NUM_OFFS) - -/* The traditional PCI spec defined 6-bit field to describe register offset.*/ -/* The new PCI Express extend the register offset by an extra 4-bits. */ -/* The below macro assign 10-bit register offset into the apprpreate */ -/* fields in the CFG_ADDR_REG */ -#define PXCAR_REG_OFFS_SET(regOffs) \ - ( (regOff & PXCAR_REG_NUM_MASK) | \ - ( ((regOff & PXCAR_REAL_EXT_REG_NUM_MASK) >> PXCAR_REAL_EXT_REG_NUM_OFFS) << PXCAR_EXT_REG_NUM_OFFS) ) - -/***********************************/ -/* PCI Express Interrupt registers */ -/***********************************/ -#define PEX_CAUSE_REG(pexIf) ((PEX_IF_BASE(pexIf)) + 0x1900) -#define PEX_MASK_REG(pexIf) ((PEX_IF_BASE(pexIf)) + 0x1910) - -#define PXICR_TX_REQ_IN_DLDOWN_ERR BIT0 /* Transmit request while field */ - /* <DLDown> of the PCI Express */ -/* PCI Express Interrupt Cause */ -/* PEX_INT_CAUSE_REG (PXICR)*/ -/* PEX_INT_MASK_REG*/ -/* -NOTE:All bits except bits[27:24] are Read/Write Clear only. A cause bit sets -upon an error event occurrence. A write of 0 clears the bit. A write of 1 has -no affect. Bits[24:27} are set and cleared upon reception of interrupt -emulation messages. - -Mask bit per cause bit. If a bit is set to 1, the corresponding event is -enabled. Mask does not affect setting of the Interrupt Cause register bits; -it only affects the assertion of the interrupt .*/ - - -#define PXICR_MDIS_CAUSE BIT1 /* Attempt to generate PCI transaction - while master is disabled */ -#define PXICR_ERR_WRTO_REG_CAUSE BIT3 /* Erroneous write attempt to - PCI Express internal register*/ -#define PXICR_HIT_DFLT_WIN_ERR BIT4 /* Hit Default Window Error */ -#define PXICR_RX_RAM_PAR_ERR BIT6 /* Rx RAM Parity Error */ -#define PXICR_TX_RAM_PAR_ERR BIT7 /* Tx RAM Parity Error */ -#define PXICR_COR_ERR_DET BIT8 /* Correctable Error Detected*/ -#define PXICR_NF_ERR_DET BIT9 /* Non-Fatal Error Detected*/ -#define PXICR_FERR_DET BIT10 /* Fatal Error Detected*/ -#define PXICR_DSTATE_CHANGE BIT11 /* Dstate Change Indication*/ -#define PXICR_BIST BIT12 /* PCI-Express BIST activated*/ -#define PXICR_FLW_CTRL_PROT BIT14 /* Flow Control Protocol Error */ - -#define PXICR_RCV_UR_CA_ERR BIT15 /* Received UR or CA status. */ -#define PXICR_RCV_ERR_FATAL BIT16 /* Received ERR_FATAL message.*/ -#define PXICR_RCV_ERR_NON_FATAL BIT17 /* Received ERR_NONFATAL message*/ -#define PXICR_RCV_ERR_COR BIT18 /* Received ERR_COR message.*/ -#define PXICR_RCV_CRS BIT19 /* Received CRS completion status*/ -#define PXICR_SLV_HOT_RESET BIT20 /* Received Hot Reset Indication*/ -#define PXICR_SLV_DIS_LINK BIT21 /* Slave Disable Link Indication*/ -#define PXICR_SLV_LB BIT22 /* Slave Loopback Indication*/ -#define PXICR_LINK_FAIL BIT23 /* Link Failure indication.*/ -#define PXICR_RCV_INTA BIT24 /* IntA status.*/ -#define PXICR_RCV_INTB BIT25 /* IntB status.*/ -#define PXICR_RCV_INTC BIT26 /* IntC status.*/ -#define PXICR_RCV_INTD BIT27 /* IntD status.*/ -#define PXICR_RCV_PM_PME BIT28 /* Received PM_PME message. */ - - -/********************************************/ -/* PCI Express Control and Status Registers */ -/********************************************/ -#define PEX_CTRL_REG(pexIf) ((PEX_IF_BASE(pexIf)) + 0x1A00) -#define PEX_STATUS_REG(pexIf) ((PEX_IF_BASE(pexIf)) + 0x1A04) -#define PEX_COMPLT_TMEOUT_REG(pexIf) ((PEX_IF_BASE(pexIf)) + 0x1A10) -#define PEX_PWR_MNG_EXT_REG(pexIf) ((PEX_IF_BASE(pexIf)) + 0x1A18) -#define PEX_FLOW_CTRL_REG(pexIf) ((PEX_IF_BASE(pexIf)) + 0x1A20) -#define PEX_ACK_TMR_4X_REG(pexIf) ((PEX_IF_BASE(pexIf)) + 0x1A30) -#define PEX_ACK_TMR_1X_REG(pexIf) ((PEX_IF_BASE(pexIf)) + 0x1A40) -#define PEX_TL_CTRL_REG(pexIf) ((PEX_IF_BASE(pexIf)) + 0x1AB0) - - -#define PEX_RAM_PARITY_CTRL_REG(pexIf) ((PEX_IF_BASE(pexIf)) + 0x1A50) -/* PCI Express Control Register */ -/* PEX_CTRL_REG (PXCR) */ - -#define PXCR_CONF_LINK_OFFS 0 -#define PXCR_CONF_LINK_MASK (1 << PXCR_CONF_LINK_OFFS) -#define PXCR_CONF_LINK_X4 (0 << PXCR_CONF_LINK_OFFS) -#define PXCR_CONF_LINK_X1 (1 << PXCR_CONF_LINK_OFFS) -#define PXCR_DEV_TYPE_CTRL_OFFS 1 /*PCI ExpressDevice Type Control*/ -#define PXCR_DEV_TYPE_CTRL_MASK BIT1 -#define PXCR_DEV_TYPE_CTRL_CMPLX (1 << PXCR_DEV_TYPE_CTRL_OFFS) -#define PXCR_DEV_TYPE_CTRL_POINT (0 << PXCR_DEV_TYPE_CTRL_OFFS) -#define PXCR_CFG_MAP_TO_MEM_EN BIT2 /* Configuration Header Mapping - to Memory Space Enable */ - -#define PXCR_CFG_MAP_TO_MEM_EN BIT2 /* Configuration Header Mapping - to Memory Space Enable*/ - -#define PXCR_RSRV1_OFFS 5 -#define PXCR_RSRV1_MASK (0x7 << PXCR_RSRV1_OFFS) -#define PXCR_RSRV1_VAL (0x0 << PXCR_RSRV1_OFFS) - -#define PXCR_CONF_MAX_OUTSTND_OFFS 8 /*Maximum outstanding NP requests as a master*/ -#define PXCR_CONF_MAX_OUTSTND_MASK (0x3 << PXCR_CONF_MAX_OUTSTND_OFFS) - - -#define PXCR_CONF_NFTS_OFFS 16 /*number of FTS Ordered-Sets*/ -#define PXCR_CONF_NFTS_MASK (0xff << PXCR_CONF_NFTS_OFFS) - -#define PXCR_CONF_MSTR_HOT_RESET BIT24 /*Master Hot-Reset.*/ -#define PXCR_CONF_MSTR_LB BIT26 /* Master Loopback */ -#define PXCR_CONF_MSTR_DIS_SCRMB BIT27 /* Master Disable Scrambling*/ -#define PXCR_CONF_DIRECT_DIS_SCRMB BIT28 /* Direct Disable Scrambling*/ - -/* PCI Express Status Register */ -/* PEX_STATUS_REG (PXSR) */ - -#define PXSR_DL_DOWN BIT0 /* DL_Down indication.*/ - -#define PXSR_PEX_BUS_NUM_OFFS 8 /* Bus Number Indication */ -#define PXSR_PEX_BUS_NUM_MASK (0xff << PXSR_PEX_BUS_NUM_OFFS) - -#define PXSR_PEX_DEV_NUM_OFFS 16 /* Device Number Indication */ -#define PXSR_PEX_DEV_NUM_MASK (0x1f << PXSR_PEX_DEV_NUM_OFFS) - -#define PXSR_PEX_SLV_HOT_RESET BIT24 /* Slave Hot Reset Indication*/ -#define PXSR_PEX_SLV_DIS_LINK BIT25 /* Slave Disable Link Indication*/ -#define PXSR_PEX_SLV_LB BIT26 /* Slave Loopback Indication*/ -#define PXSR_PEX_SLV_DIS_SCRMB BIT27 /* Slave Disable Scrambling Indication*/ - - -/* PCI Express Completion Timeout Register */ -/* PEX_COMPLT_TMEOUT_REG (PXCTR)*/ - -#define PXCTR_CMP_TO_THRSHLD_OFFS 0 /* Completion Timeout Threshold */ -#define PXCTR_CMP_TO_THRSHLD_MASK (0xffff << PXCTR_CMP_TO_THRSHLD_OFFS) - -/* PCI Express Power Management Extended Register */ -/* PEX_PWR_MNG_EXT_REG (PXPMER) */ - -#define PXPMER_L1_ASPM_EN_OFFS 1 -#define PXPMER_L1_ASPM_EN_MASK (0x1 << PXPMER_L1_ASPM_EN_OFFS) - -/* PCI Express Flow Control Register */ -/* PEX_FLOW_CTRL_REG (PXFCR)*/ - -#define PXFCR_PH_INIT_FC_OFFS 0 /*Posted Headers Flow Control Credit - Initial Value.*/ -#define PXFCR_PH_INIT_FC_MASK (0xff << PXFCR_PH_INIT_FC_OFFS) - - -#define PXFCR_NPH_INIT_FC_OFFS 8 /* Classified Non-Posted Headers - Flow Control Credit Initial Value*/ -#define PXFCR_NPH_INIT_FC_MASK (0xff << PXFCR_NPH_INIT_FC_OFFS) - -#define PXFCR_CH_INIT_FC_OFFS 16 /* Completion Headers Flow Control - Credit Initial Value Infinite*/ - -#define PXFCR_CH_INIT_FC_MASK (0xff << PXFCR_CH_INIT_FC_OFFS) - -#define PXFCR_FC_UPDATE_TO_OFFS 24 /* Flow Control Update Timeout */ -#define PXFCR_FC_UPDATE_TO_MASK (0xff << PXFCR_FC_UPDATE_TO_OFFS) - -/* PCI Express Acknowledge Timers (4X) Register */ -/* PEX_ACK_TMR_4X_REG (PXAT4R) */ -#define PXAT1R_ACK_LAT_TOX4_OFFS 0 /* Ack Latency Timer Timeout Value */ -#define PXAT1R_ACK_LAT_TOX4_MASK (0xffff << PXAT4R_ACK_LAT_TOX1_OFFS) -#define PXAT1R_ACK_RPLY_TOX4_OFFS 16 /* Ack Replay Timer Timeout Value */ -#define PXAT1R_ACK_RPLY_TOX4_MASK (0xffff << PXAT1R_ACK_RPLY_TOX1_OFFS) - -/* PCI Express Acknowledge Timers (1X) Register */ -/* PEX_ACK_TMR_1X_REG (PXAT1R) */ - -#define PXAT1R_ACK_LAT_TOX1_OFFS 0 /* Acknowledge Latency Timer Timeout - Value for 1X Link*/ -#define PXAT1R_ACK_LAT_TOX1_MASK (0xffff << PXAT1R_ACK_LAT_TOX1_OFFS) - -#define PXAT1R_ACK_RPLY_TOX1_OFFS 16 /* Acknowledge Replay Timer Timeout - Value for 1X*/ -#define PXAT1R_ACK_RPLY_TOX1_MASK (0xffff << PXAT1R_ACK_RPLY_TOX1_OFFS) - - -/* PCI Express TL Control Register */ -/* PEX_TL_CTRL_REG (PXTCR) */ - -#define PXTCR_TX_CMP_BUFF_NO_OFFS 8 /*Number of completion buffers in Tx*/ -#define PXTCR_TX_CMP_BUFF_NO_MASK (0xf << PXTCR_TX_CMP_BUFF_NO_OFFS) - -/* PCI Express Debug MAC Control Register */ -/* PEX_DEBUG_MAC_CTRL_REG (PXDMCR) */ - -#define PXDMCR_LINKUP BIT4 - - - -/**********************************************/ -/* PCI Express Configuration Header Registers */ -/**********************************************/ -#define PEX_CFG_DIRECT_ACCESS(pexIf,cfgReg) ((PEX_IF_BASE(pexIf)) + (cfgReg)) - -#define PEX_DEVICE_AND_VENDOR_ID 0x000 -#define PEX_STATUS_AND_COMMAND 0x004 -#define PEX_CLASS_CODE_AND_REVISION_ID 0x008 -#define PEX_BIST_HDR_TYPE_LAT_TMR_CACHE_LINE 0x00C -#define PEX_MEMORY_BAR_BASE_ADDR(barNum) (0x010 + ((barNum) << 2)) -#define PEX_MV_BAR_BASE(barNum) (0x010 + (barNum) * 8) -#define PEX_MV_BAR_BASE_HIGH(barNum) (0x014 + (barNum) * 8) -#define PEX_BAR0_INTER_REG 0x010 -#define PEX_BAR0_INTER_REG_HIGH 0x014 -#define PEX_BAR1_REG 0x018 -#define PEX_BAR1_REG_HIGH 0x01C -#define PEX_BAR2_REG 0x020 -#define PEX_BAR2_REG_HIGH 0x024 - -#define PEX_SUBSYS_ID_AND_SUBSYS_VENDOR_ID 0x02C -#define PEX_EXPANSION_ROM_BASE_ADDR_REG 0x030 -#define PEX_CAPABILTY_LIST_POINTER 0x034 -#define PEX_INTERRUPT_PIN_AND_LINE 0x03C - -/* capability list */ -#define PEX_POWER_MNG_CAPABILITY 0x040 -#define PEX_POWER_MNG_STATUS_CONTROL 0x044 - -#define PEX_MSI_MESSAGE_CONTROL 0x050 -#define PEX_MSI_MESSAGE_ADDR 0x054 -#define PEX_MSI_MESSAGE_HIGH_ADDR 0x058 -#define PEX_MSI_MESSAGE_DATA 0x05C - -#define PEX_CAPABILITY_REG 0x60 -#define PEX_DEV_CAPABILITY_REG 0x64 -#define PEX_DEV_CTRL_STAT_REG 0x68 -#define PEX_LINK_CAPABILITY_REG 0x6C -#define PEX_LINK_CTRL_STAT_REG 0x70 - -#define PEX_ADV_ERR_RPRT_HDR_TRGT_REG 0x100 -#define PEX_UNCORRECT_ERR_STAT_REG 0x104 -#define PEX_UNCORRECT_ERR_MASK_REG 0x108 -#define PEX_UNCORRECT_ERR_SERVITY_REG 0x10C -#define PEX_CORRECT_ERR_STAT_REG 0x110 -#define PEX_CORRECT_ERR_MASK_REG 0x114 -#define PEX_ADV_ERR_CAPABILITY_CTRL_REG 0x118 -#define PEX_HDR_LOG_FIRST_DWORD_REG 0x11C -#define PEX_HDR_LOG_SECOND_DWORD_REG 0x120 -#define PEX_HDR_LOG_THIRD_DWORD_REG 0x124 -#define PEX_HDR_LOG_FOURTH_DWORD_REG 0x128 - - - -/* PCI Express Device and Vendor ID Register*/ -/*PEX_DEVICE_AND_VENDOR_ID (PXDAVI)*/ - -#define PXDAVI_VEN_ID_OFFS 0 /* Vendor ID */ -#define PXDAVI_VEN_ID_MASK (0xffff << PXDAVI_VEN_ID_OFFS) - -#define PXDAVI_DEV_ID_OFFS 16 /* Device ID */ -#define PXDAVI_DEV_ID_MASK (0xffff << PXDAVI_DEV_ID_OFFS) - - -/* PCI Express Command and Status Register*/ -/*PEX_STATUS_AND_COMMAND (PXSAC)*/ - -#define PXSAC_IO_EN BIT0 /* IO Enable */ -#define PXSAC_MEM_EN BIT1 /* Memory Enable */ -#define PXSAC_MASTER_EN BIT2 /* Master Enable */ -#define PXSAC_PERR_EN BIT6 /* Parity Errors Respond Enable */ -#define PXSAC_SERR_EN BIT8 /* Ability to assert SERR# line */ -#define PXSAC_INT_DIS BIT10 /* Interrupt Disable */ -#define PXSAC_INT_STAT BIT19 /* Interrupt Status */ -#define PXSAC_CAP_LIST BIT20 /* Capability List Support */ -#define PXSAC_MAS_DATA_PERR BIT24 /* Master Data Parity Error */ -#define PXSAC_SLAVE_TABORT BIT27 /* Signalled Target Abort */ -#define PXSAC_RT_ABORT BIT28 /* Recieved Target Abort */ -#define PXSAC_MABORT BIT29 /* Recieved Master Abort */ -#define PXSAC_SYSERR BIT30 /* Signalled system error */ -#define PXSAC_DET_PARERR BIT31 /* Detect Parity Error */ - - -/* PCI Express Class Code and Revision ID Register*/ -/*PEX_CLASS_CODE_AND_REVISION_ID (PXCCARI)*/ - -#define PXCCARI_REVID_OFFS 0 /* Revision ID */ -#define PXCCARI_REVID_MASK (0xff << PXCCARI_REVID_OFFS) - -#define PXCCARI_FULL_CLASS_OFFS 8 /* Full Class Code */ -#define PXCCARI_FULL_CLASS_MASK (0xffffff << PXCCARI_FULL_CLASS_OFFS) - -#define PXCCARI_PROGIF_OFFS 8 /* Prog .I/F*/ -#define PXCCARI_PROGIF_MASK (0xff << PXCCARI_PROGIF_OFFS) - -#define PXCCARI_SUB_CLASS_OFFS 16 /* Sub Class*/ -#define PXCCARI_SUB_CLASS_MASK (0xff << PXCCARI_SUB_CLASS_OFFS) - -#define PXCCARI_BASE_CLASS_OFFS 24 /* Base Class*/ -#define PXCCARI_BASE_CLASS_MASK (0xff << PXCCARI_BASE_CLASS_OFFS) - - -/* PCI Express BIST, Header Type and Cache Line Size Register*/ -/*PEX_BIST_HDR_TYPE_LAT_TMR_CACHE_LINE (PXBHTLTCL)*/ - -#define PXBHTLTCL_CACHELINE_OFFS 0 /* Specifies the cache line size */ -#define PXBHTLTCL_CACHELINE_MASK (0xff << PXBHTLTCL_CACHELINE_OFFS) - -#define PXBHTLTCL_HEADTYPE_FULL_OFFS 16 /* Full Header Type */ -#define PXBHTLTCL_HEADTYPE_FULL_MASK (0xff << PXBHTLTCL_HEADTYPE_FULL_OFFS) - -#define PXBHTLTCL_MULTI_FUNC BIT23 /* Multi/Single function */ - -#define PXBHTLTCL_HEADER_OFFS 16 /* Header type */ -#define PXBHTLTCL_HEADER_MASK (0x7f << PXBHTLTCL_HEADER_OFFS) -#define PXBHTLTCL_HEADER_STANDARD (0x0 << PXBHTLTCL_HEADER_OFFS) -#define PXBHTLTCL_HEADER_PCI2PCI_BRIDGE (0x1 << PXBHTLTCL_HEADER_OFFS) - - -#define PXBHTLTCL_BISTCOMP_OFFS 24 /* BIST Completion Code */ -#define PXBHTLTCL_BISTCOMP_MASK (0xf << PXBHTLTCL_BISTCOMP_OFFS) - -#define PXBHTLTCL_BISTACT BIT30 /* BIST Activate bit */ -#define PXBHTLTCL_BISTCAP BIT31 /* BIST Capable Bit */ -#define PXBHTLTCL_BISTCAP_OFFS 31 -#define PXBHTLTCL_BISTCAP_MASK BIT31 -#define PXBHTLTCL_BISTCAP_VAL 0 - - -/* PCI Express Subsystem Device and Vendor ID */ -/*PEX_SUBSYS_ID_AND_SUBSYS_VENDOR_ID (PXSIASVI)*/ - -#define PXSIASVI_VENID_OFFS 0 /* Subsystem Manufacturer Vendor ID Number */ -#define PXSIASVI_VENID_MASK (0xffff << PXSIASVI_VENID_OFFS) - -#define PXSIASVI_DEVID_OFFS 16 /* Subsystem Device ID Number */ -#define PXSIASVI_DEVID_MASK (0xffff << PXSIASVI_DEVID_OFFS) - - -/* PCI Express Capability List Pointer Register*/ -/*PEX_CAPABILTY_LIST_POINTER (PXCLP)*/ - -#define PXCLP_CAPPTR_OFFS 0 /* Capability List Pointer */ -#define PXCLP_CAPPTR_MASK (0xff << PXCLP_CAPPTR_OFFS) - -/* PCI Express Interrupt Pin and Line Register */ -/*PEX_INTERRUPT_PIN_AND_LINE (PXIPAL)*/ - -#define PXIPAL_INTLINE_OFFS 0 /* Interrupt line (IRQ) */ -#define PXIPAL_INTLINE_MASK (0xff << PXIPAL_INTLINE_OFFS) - -#define PXIPAL_INTPIN_OFFS 8 /* interrupt pin (A,B,C,D) */ -#define PXIPAL_INTPIN_MASK (0xff << PXIPAL_INTPIN_OFFS) - - -/* PCI Express Power Management Capability Header Register*/ -/*PEX_POWER_MNG_CAPABILITY (PXPMC)*/ - -#define PXPMC_CAP_ID_OFFS 0 /* Capability ID */ -#define PXPMC_CAP_ID_MASK (0xff << PXPMC_CAP_ID_OFFS) - -#define PXPMC_NEXT_PTR_OFFS 8 /* Next Item Pointer */ -#define PXPMC_NEXT_PTR_MASK (0xff << PXPMC_NEXT_PTR_OFFS) - -#define PXPMC_PMC_VER_OFFS 16 /* PCI Power Management Capability Version*/ -#define PXPMC_PMC_VER_MASK (0x7 << PXPMC_PMC_VER_OFFS) - -#define PXPMC_DSI BIT21/* Device Specific Initialization */ - -#define PXPMC_AUX_CUR_OFFS 22 /* Auxiliary Current Requirements */ -#define PXPMC_AUX_CUR_MASK (0x7 << PXPMC_AUX_CUR_OFFS) - -#define PXPMC_D1_SUP BIT25 /* D1 Power Management support*/ - -#define PXPMC_D2_SUP BIT26 /* D2 Power Management support*/ - -#define PXPMC_PME_SUP_OFFS 27 /* PM Event generation support*/ -#define PXPMC_PME_SUP_MASK (0x1f << PXPMC_PME_SUP_OFFS) - -/* PCI Express Power Management Control and Status Register*/ -/*PEX_POWER_MNG_STATUS_CONTROL (PXPMSC)*/ - -#define PXPMSC_PM_STATE_OFFS 0 /* Power State */ -#define PXPMSC_PM_STATE_MASK (0x3 << PXPMSC_PM_STATE_OFFS) -#define PXPMSC_PM_STATE_D0 (0x0 << PXPMSC_PM_STATE_OFFS) -#define PXPMSC_PM_STATE_D1 (0x1 << PXPMSC_PM_STATE_OFFS) -#define PXPMSC_PM_STATE_D2 (0x2 << PXPMSC_PM_STATE_OFFS) -#define PXPMSC_PM_STATE_D3 (0x3 << PXPMSC_PM_STATE_OFFS) - -#define PXPMSC_PME_EN BIT8/* PM_PME Message Generation Enable */ - -#define PXPMSC_PM_DATA_SEL_OFFS 9 /* Data Select*/ -#define PXPMSC_PM_DATA_SEL_MASK (0xf << PXPMSC_PM_DATA_SEL_OFFS) - -#define PXPMSC_PM_DATA_SCALE_OFFS 13 /* Data Scale */ -#define PXPMSC_PM_DATA_SCALE_MASK (0x3 << PXPMSC_PM_DATA_SCALE_OFFS) - -#define PXPMSC_PME_STAT BIT15/* PME Status */ - -#define PXPMSC_PM_DATA_OFFS 24 /* State Data */ -#define PXPMSC_PM_DATA_MASK (0xff << PXPMSC_PM_DATA_OFFS) - - -/* PCI Express MSI Message Control Register*/ -/*PEX_MSI_MESSAGE_CONTROL (PXMMC)*/ - -#define PXMMC_CAP_ID_OFFS 0 /* Capability ID */ -#define PXMMC_CAP_ID_MASK (0xff << PXMMC_CAP_ID_OFFS) - -#define PXMMC_NEXT_PTR_OFFS 8 /* Next Item Pointer */ -#define PXMMC_NEXT_PTR_MASK (0xff << PXMMC_NEXT_PTR_OFFS) - -#define PXMMC_MSI_EN BIT18 /* MSI Enable */ - -#define PXMMC_MULTI_CAP_OFFS 17 /* Multiple Message Capable */ -#define PXMMC_MULTI_CAP_MASK (0x7 << PXMMC_MULTI_CAP_OFFS) - -#define PXMMC_MULTI_EN_OFFS 20 /* Multiple Messages Enable */ -#define PXMMC_MULTI_EN_MASK (0x7 << PXMMC_MULTI_EN_OFFS) - -#define PXMMC_ADDR64 BIT23 /* 64-bit Addressing Capable */ - - -/* PCI Express MSI Message Address Register*/ -/*PEX_MSI_MESSAGE_ADDR (PXMMA)*/ - -#define PXMMA_MSI_ADDR_OFFS 2 /* Message Address corresponds to - Address[31:2] of the MSI MWr TLP*/ -#define PXMMA_MSI_ADDR_MASK (0x3fffffff << PXMMA_MSI_ADDR_OFFS) - - -/* PCI Express MSI Message Address (High) Register */ -/*PEX_MSI_MESSAGE_HIGH_ADDR (PXMMHA)*/ - -#define PXMMA_MSI_ADDR_H_OFFS 0 /* Message Upper Address corresponds to - Address[63:32] of the MSI MWr TLP*/ -#define PXMMA_MSI_ADDR_H_MASK (0xffffffff << PXMMA_MSI_ADDR_H_OFFS ) - - -/* PCI Express MSI Message Data Register*/ -/*PEX_MSI_MESSAGE_DATA (PXMMD)*/ - -#define PXMMD_MSI_DATA_OFFS 0 /* Message Data */ -#define PXMMD_MSI_DATA_MASK (0xffff << PXMMD_MSI_DATA_OFFS ) - - -/* PCI Express Capability Register*/ -/*PEX_CAPABILITY_REG (PXCR)*/ - -#define PXCR_CAP_ID_OFFS 0 /* Capability ID*/ -#define PXCR_CAP_ID_MASK (0xff << PXCR_CAP_ID_OFFS) - -#define PXCR_NEXT_PTR_OFFS 8 /* Next Item Pointer*/ -#define PXCR_NEXT_PTR_MASK (0xff << PXCR_NEXT_PTR_OFFS) - -#define PXCR_CAP_VER_OFFS 16 /* Capability Version*/ -#define PXCR_CAP_VER_MASK (0xf << PXCR_CAP_VER_OFFS) - -#define PXCR_DEV_TYPE_OFFS 20 /* Device/Port Type*/ -#define PXCR_DEV_TYPE_MASK (0xf << PXCR_DEV_TYPE_OFFS) - -#define PXCR_SLOT_IMP BIT24 /* Slot Implemented*/ - -#define PXCR_INT_MSG_NUM_OFFS 25 /* Interrupt Message Number*/ -#define PXCR_INT_MSG_NUM_MASK (0x1f << PXCR_INT_MSG_NUM_OFFS) - - -/* PCI Express Device Capabilities Register */ -/*PEX_DEV_CAPABILITY_REG (PXDCR)*/ - -#define PXDCR_MAX_PLD_SIZE_SUP_OFFS 0 /* Maximum Payload Size Supported*/ -#define PXDCR_MAX_PLD_SIZE_SUP_MASK (0x7 << PXDCR_MAX_PLD_SIZE_SUP_OFFS) - -#define PXDCR_EP_L0S_ACC_LAT_OFFS 6/* Endpoint L0s Acceptable Latency*/ -#define PXDCR_EP_L0S_ACC_LAT_MASK (0x7 << PXDCR_EP_L0S_ACC_LAT_OFFS) -#define PXDCR_EP_L0S_ACC_LAT_64NS_LESS (0x0 << PXDCR_EP_L0S_ACC_LAT_OFFS) -#define PXDCR_EP_L0S_ACC_LAT_64NS_128NS (0x1 << PXDCR_EP_L0S_ACC_LAT_OFFS) -#define PXDCR_EP_L0S_ACC_LAT_128NS_256NS (0x2 << PXDCR_EP_L0S_ACC_LAT_OFFS) -#define PXDCR_EP_L0S_ACC_LAT_256NS_512NS (0x3 << PXDCR_EP_L0S_ACC_LAT_OFFS) -#define PXDCR_EP_L0S_ACC_LAT_512NS_1US (0x4 << PXDCR_EP_L0S_ACC_LAT_OFFS) -#define PXDCR_EP_L0S_ACC_LAT_1US_2US (0x5 << PXDCR_EP_L0S_ACC_LAT_OFFS) -#define PXDCR_EP_L0S_ACC_LAT_2US_4US (0x6 << PXDCR_EP_L0S_ACC_LAT_OFFS) -#define PXDCR_EP_L0S_ACC_LAT_4US_MORE (0x7 << PXDCR_EP_L0S_ACC_LAT_OFFS) - -#define PXDCR_EP_L1_ACC_LAT_OFFS 9 /* Endpoint L1 Acceptable Latency*/ -#define PXDCR_EP_L1_ACC_LAT_MASK (0x7 << PXDCR_EP_L1_ACC_LAT_OFFS) -#define PXDCR_EP_L1_ACC_LAT_64NS_LESS (0x0 << PXDCR_EP_L1_ACC_LAT_OFFS) -#define PXDCR_EP_L1_ACC_LAT_64NS_128NS (0x1 << PXDCR_EP_L1_ACC_LAT_OFFS) -#define PXDCR_EP_L1_ACC_LAT_128NS_256NS (0x2 << PXDCR_EP_L1_ACC_LAT_OFFS) -#define PXDCR_EP_L1_ACC_LAT_256NS_512NS (0x3 << PXDCR_EP_L1_ACC_LAT_OFFS) -#define PXDCR_EP_L1_ACC_LAT_512NS_1US (0x4 << PXDCR_EP_L1_ACC_LAT_OFFS) -#define PXDCR_EP_L1_ACC_LAT_1US_2US (0x5 << PXDCR_EP_L1_ACC_LAT_OFFS) -#define PXDCR_EP_L1_ACC_LAT_2US_4US (0x6 << PXDCR_EP_L1_ACC_LAT_OFFS) -#define PXDCR_EP_L1_ACC_LAT_4US_MORE (0x7 << PXDCR_EP_L1_ACC_LAT_OFFS) - - -#define PXDCR_ATT_BUT_PRS_OFFS 12 /* Attention Button Present*/ -#define PXDCR_ATT_BUT_PRS_MASK BIT12 -#define PXDCR_ATT_BUT_PRS_IMPLEMENTED BIT12 - -#define PXDCR_ATT_IND_PRS_OFFS 13 /* Attention Indicator Present*/ -#define PXDCR_ATT_IND_PRS_MASK BIT13 -#define PXDCR_ATT_IND_PRS_IMPLEMENTED BIT13 - -#define PXDCR_PWR_IND_PRS_OFFS 14/* Power Indicator Present*/ -#define PXDCR_PWR_IND_PRS_MASK BIT14 -#define PXDCR_PWR_IND_PRS_IMPLEMENTED BIT14 - -#define PXDCR_CAP_SPL_VAL_OFFS 18 /*Captured Slot Power Limit - Value*/ -#define PXDCR_CAP_SPL_VAL_MASK (0xff << PXDCR_CAP_SPL_VAL_OFFS) - -#define PXDCR_CAP_SP_LSCL_OFFS 26 /* Captured Slot Power Limit - Scale */ -#define PXDCR_CAP_SP_LSCL_MASK (0x3 << PXDCR_CAP_SP_LSCL_OFFS) - -/* PCI Express Device Control Status Register */ -/*PEX_DEV_CTRL_STAT_REG (PXDCSR)*/ - -#define PXDCSR_COR_ERR_REP_EN BIT0 /* Correctable Error Reporting Enable*/ -#define PXDCSR_NF_ERR_REP_EN BIT1 /* Non-Fatal Error Reporting Enable*/ -#define PXDCSR_F_ERR_REP_EN BIT2 /* Fatal Error Reporting Enable*/ -#define PXDCSR_UR_REP_EN BIT3 /* Unsupported Request (UR) - Reporting Enable*/ -#define PXDCSR_EN_RO BIT4 /* Enable Relaxed Ordering*/ - -#define PXDCSR_MAX_PLD_SZ_OFFS 5 /* Maximum Payload Size*/ -#define PXDCSR_MAX_PLD_SZ_MASK (0x7 << PXDCSR_MAX_PLD_SZ_OFFS) -#define PXDCSR_MAX_PLD_SZ_128B (0x0 << PXDCSR_MAX_PLD_SZ_OFFS) -#define PXDCSR_EN_NS BIT11 /* Enable No Snoop*/ - -#define PXDCSR_MAX_RD_RQ_SZ_OFFS 12 /* Maximum Read Request Size*/ -#define PXDCSR_MAX_RD_RQ_SZ_MASK (0x7 << PXDCSR_MAX_RD_RQ_SZ_OFFS) -#define PXDCSR_MAX_RD_RQ_SZ_128B (0x0 << PXDCSR_MAX_RD_RQ_SZ_OFFS) -#define PXDCSR_MAX_RD_RQ_SZ_256B (0x1 << PXDCSR_MAX_RD_RQ_SZ_OFFS) -#define PXDCSR_MAX_RD_RQ_SZ_512B (0x2 << PXDCSR_MAX_RD_RQ_SZ_OFFS) -#define PXDCSR_MAX_RD_RQ_SZ_1KB (0x3 << PXDCSR_MAX_RD_RQ_SZ_OFFS) -#define PXDCSR_MAX_RD_RQ_SZ_2KB (0x4 << PXDCSR_MAX_RD_RQ_SZ_OFFS) -#define PXDCSR_MAX_RD_RQ_SZ_4KB (0x5 << PXDCSR_MAX_RD_RQ_SZ_OFFS) - -#define PXDCSR_COR_ERR_DET BIT16 /* Correctable Error Detected*/ -#define PXDCSR_NF_ERR_DET BIT17 /* Non-Fatal Error Detected.*/ -#define PXDCSR_F_ERR_DET BIT18 /* Fatal Error Detected.*/ -#define PXDCSR_UR_DET BIT19 /* Unsupported Request Detected */ -#define PXDCSR_AUX_PWR_DET BIT20 /* Reserved*/ - -#define PXDCSR_TRANS_PEND_OFFS 21 /* Transactions Pending*/ -#define PXDCSR_TRANS_PEND_MASK BIT21 -#define PXDCSR_TRANS_PEND_NOT_COMPLETED (0x1 << PXDCSR_TRANS_PEND_OFFS) - - -/* PCI Express Link Capabilities Register*/ -/*PEX_LINK_CAPABILITY_REG (PXLCR)*/ - -#define PXLCR_MAX_LINK_SPD_OFFS 0 /* Maximum Link Speed*/ -#define PXLCR_MAX_LINK_SPD_MASK (0xf << PXLCR_MAX_LINK_SPD_OFFS) - -#define PXLCR_MAX_LNK_WDTH_OFFS 3 /* Maximum Link Width*/ -#define PXLCR_MAX_LNK_WDTH_MASK (0x3f << PXLCR_MAX_LNK_WDTH_OFFS) - -#define PXLCR_ASPM_SUP_OFFS 10 /* Active State Link PM Support*/ -#define PXLCR_ASPM_SUP_MASK (0x3 << PXLCR_ASPM_SUP_OFFS) - -#define PXLCR_L0S_EXT_LAT_OFFS 12 /* L0s Exit Latency*/ -#define PXLCR_L0S_EXT_LAT_MASK (0x7 << PXLCR_L0S_EXT_LAT_OFFS) -#define PXLCR_L0S_EXT_LAT_64NS_LESS (0x0 << PXDCR_EP_L1_ACC_LAT_OFFS) -#define PXLCR_L0S_EXT_LAT_64NS_128NS (0x1 << PXDCR_EP_L1_ACC_LAT_OFFS) -#define PXLCR_L0S_EXT_LAT_128NS_256NS (0x2 << PXDCR_EP_L1_ACC_LAT_OFFS) -#define PXLCR_L0S_EXT_LAT_256NS_512NS (0x3 << PXDCR_EP_L1_ACC_LAT_OFFS) -#define PXLCR_L0S_EXT_LAT_512NS_1US (0x4 << PXDCR_EP_L1_ACC_LAT_OFFS) -#define PXLCR_L0S_EXT_LAT_1US_2US (0x5 << PXDCR_EP_L1_ACC_LAT_OFFS) -#define PXLCR_L0S_EXT_LAT_2US_4US (0x6 << PXDCR_EP_L1_ACC_LAT_OFFS) - -#define PXLCR_POR_TNUM_OFFS 24 /* Port Number */ -#define PXLCR_POR_TNUM_MASK (0xff << PXLCR_POR_TNUM_OFFS) - -/* PCI Express Link Control Status Register */ -/*PEX_LINK_CTRL_STAT_REG (PXLCSR)*/ - -#define PXLCSR_ASPM_CNT_OFFS 0 /* Active State Link PM Control */ -#define PXLCSR_ASPM_CNT_MASK (0x3 << PXLCSR_ASPM_CNT_OFFS) -#define PXLCSR_ASPM_CNT_DISABLED (0x0 << PXLCSR_ASPM_CNT_OFFS) -#define PXLCSR_ASPM_CNT_L0S_ENT_SUPP (0x1 << PXLCSR_ASPM_CNT_OFFS) -#define PXLCSR_ASPM_CNT_L1S_ENT_SUPP (0x2 << PXLCSR_ASPM_CNT_OFFS) -#define PXLCSR_ASPM_CNT_L0S_L1S_ENT_SUPP (0x3 << PXLCSR_ASPM_CNT_OFFS) - -#define PXLCSR_RCB_OFFS 3 /* Read Completion Boundary */ -#define PXLCSR_RCB_MASK BIT3 -#define PXLCSR_RCB_64B (0 << PXLCSR_RCB_OFFS) -#define PXLCSR_RCB_128B (1 << PXLCSR_RCB_OFFS) - -#define PXLCSR_LNK_DIS BIT4 /* Link Disable */ -#define PXLCSR_RETRN_LNK BIT5 /* Retrain Link */ -#define PXLCSR_CMN_CLK_CFG BIT6 /* Common Clock Configuration */ -#define PXLCSR_EXTD_SNC BIT7 /* Extended Sync */ - -#define PXLCSR_LNK_SPD_OFFS 16 /* Link Speed */ -#define PXLCSR_LNK_SPD_MASK (0xf << PXLCSR_LNK_SPD_OFFS) - -#define PXLCSR_NEG_LNK_WDTH_OFFS 20 /* Negotiated Link Width */ -#define PXLCSR_NEG_LNK_WDTH_MASK (0x3f << PXLCSR_NEG_LNK_WDTH_OFFS) -#define PXLCSR_NEG_LNK_WDTH_X1 (0x1 << PXLCSR_NEG_LNK_WDTH_OFFS) - -#define PXLCSR_LNK_TRN BIT27 /* Link Training */ - -#define PXLCSR_SLT_CLK_CFG_OFFS 28 /* Slot Clock Configuration */ -#define PXLCSR_SLT_CLK_CFG_MASK BIT28 -#define PXLCSR_SLT_CLK_CFG_INDPNT (0x0 << PXLCSR_SLT_CLK_CFG_OFFS) -#define PXLCSR_SLT_CLK_CFG_REF (0x1 << PXLCSR_SLT_CLK_CFG_OFFS) - -/* PCI Express Advanced Error Report Header Register */ -/*PEX_ADV_ERR_RPRT_HDR_TRGT_REG (PXAERHTR)*/ - -/* PCI Express Uncorrectable Error Status Register*/ -/*PEX_UNCORRECT_ERR_STAT_REG (PXUESR)*/ - -/* PCI Express Uncorrectable Error Mask Register */ -/*PEX_UNCORRECT_ERR_MASK_REG (PXUEMR)*/ - -/* PCI Express Uncorrectable Error Severity Register */ -/*PEX_UNCORRECT_ERR_SERVITY_REG (PXUESR)*/ - -/* PCI Express Correctable Error Status Register */ -/*PEX_CORRECT_ERR_STAT_REG (PXCESR)*/ - -/* PCI Express Correctable Error Mask Register */ -/*PEX_CORRECT_ERR_MASK_REG (PXCEMR)*/ - -/* PCI Express Advanced Error Capability and Control Register*/ -/*PEX_ADV_ERR_CAPABILITY_CTRL_REG (PXAECCR)*/ - -/* PCI Express Header Log First DWORD Register*/ -/*PEX_HDR_LOG_FIRST_DWORD_REG (PXHLFDR)*/ - -/* PCI Express Header Log Second DWORD Register*/ -/*PEX_HDR_LOG_SECOND_DWORD_REG (PXHLSDR)*/ - -/* PCI Express Header Log Third DWORD Register*/ -/*PEX_HDR_LOG_THIRD_DWORD_REG (PXHLTDR)*/ - -/* PCI Express Header Log Fourth DWORD Register*/ -/*PEX_HDR_LOG_FOURTH_DWORD_REG (PXHLFDR)*/ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* #ifndef __INCPEXREGSH */ - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pex/mvVrtBrgPex.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pex/mvVrtBrgPex.c deleted file mode 100644 index 13d2f87..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pex/mvVrtBrgPex.c +++ /dev/null @@ -1,313 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#include "mvPex.h" - -//#define MV_DEBUG -/* defines */ -#ifdef MV_DEBUG - #define DB(x) x -#else - #define DB(x) -#endif - -/* locals */ -typedef struct -{ - MV_U32 data; - MV_U32 mask; -}PEX_HEADER_DATA; - -/* local function forwad decleration */ -MV_U32 mvPexHwConfigRead (MV_U32 pexIf, MV_U32 bus, MV_U32 dev, MV_U32 func, - MV_U32 regOff); -MV_STATUS mvPexHwConfigWrite(MV_U32 pexIf, MV_U32 bus, MV_U32 dev, - MV_U32 func, MV_U32 regOff, MV_U32 data); -void resetPexConfig(MV_U32 pexIf, MV_U32 bus, MV_U32 dev); - - -PEX_HEADER_DATA configHdr[16] = -{ -{0x888811ab, 0x00000000}, /*[device ID, vendor ID] */ -{0x00100007, 0x0000ffff}, /*[status register, command register] */ -{0x0604000e, 0x00000000}, /*[programming interface, sub class code, class code, revision ID] */ -{0x00010008, 0x00000000}, /*[BIST, header type, latency time, cache line] */ -{0x00000000, 0x00000000}, /*[base address 0] */ -{0x00000000, 0x00000000}, /*[base address 1] */ -{0x00000000, 0x00ffffff}, /*[secondary latency timersubordinate bus number, secondary bus number, primary bus number] */ -{0x0000f101, 0x00000000}, /*[secondary status ,IO limit, IO base] */ -{0x9ff0a000, 0x00000000}, /*[memory limit, memory base] */ -{0x0001fff1, 0x00000000}, /*[prefetch memory limit, prefetch memory base] */ -{0xffffffff, 0x00000000}, /*[prefetch memory base upper] */ -{0x00000000, 0x00000000}, /*[prefetch memory limit upper] */ -{0xeffff000, 0x00000000}, /*[IO limit upper 16 bits, IO base upper 16 bits] */ -{0x00000000, 0x00000000}, /*[reserved, capability pointer] */ -{0x00000000, 0x00000000}, /*[expansion ROM base address] */ -{0x00000000, 0x000000FF}, /*[bridge control, interrupt pin, interrupt line] */ -}; - - -#define HEADER_WRITE(data, offset) configHdr[offset/4].data = ((configHdr[offset/4].data & ~configHdr[offset/4].mask) | \ - (data & configHdr[offset/4].mask)) -#define HEADER_READ(offset) configHdr[offset/4].data - -/******************************************************************************* -* mvVrtBrgPexInit - Initialize PEX interfaces -* -* DESCRIPTION: -* -* This function is responsible of intialization of the Pex Interface , It -* configure the Pex Bars and Windows in the following manner: -* -* Assumptions : -* Bar0 is always internal registers bar -* Bar1 is always the DRAM bar -* Bar2 is always the Device bar -* -* 1) Sets the Internal registers bar base by obtaining the base from -* the CPU Interface -* 2) Sets the DRAM bar base and size by getting the base and size from -* the CPU Interface when the size is the sum of all enabled DRAM -* chip selects and the base is the base of CS0 . -* 3) Sets the Device bar base and size by getting these values from the -* CPU Interface when the base is the base of the lowest base of the -* Device chip selects, and the -* -* -* INPUT: -* -* pexIf - PEX interface number. -* -* -* OUTPUT: -* None. -* -* RETURN: -* MV_OK if function success otherwise MV_ERROR or MV_BAD_PARAM -* -*******************************************************************************/ -MV_STATUS mvPexVrtBrgInit(MV_U32 pexIf) -{ - /* reset PEX tree to recover previous U-boot/Boot configurations */ - MV_U32 localBus = mvPexLocalBusNumGet(pexIf); - - - resetPexConfig(pexIf, localBus, 1); - return MV_OK; -} - - -MV_U32 mvPexVrtBrgConfigRead (MV_U32 pexIf, MV_U32 bus, MV_U32 dev, MV_U32 func, - MV_U32 regOff) -{ - - MV_U32 localBus = mvPexLocalBusNumGet(pexIf); - MV_U32 localDev = mvPexLocalDevNumGet(pexIf); - MV_U32 val; - if(bus == localBus) - { - if(dev > 1) - { -/* on the local device allow only device #0 & #1 */ - return 0xffffffff; - } - else - if (dev == localDev) - { - /* read the memory controller registers */ - return mvPexHwConfigRead (pexIf, bus, dev, func, regOff); - } - else - { - /* access the virtual brg header */ - return HEADER_READ(regOff); - } - } - else - if(bus == (localBus + 1)) - { - /* access the device behind the virtual bridge */ - if((dev == localDev) || (dev > 1)) - { - return 0xffffffff; - } - else - { - /* access the device behind the virtual bridge, in this case - * change the bus number to the local bus number in order to - * generate type 0 config cycle - */ - mvPexLocalBusNumSet(pexIf, bus); - mvPexLocalDevNumSet(pexIf, 1); - val = mvPexHwConfigRead (pexIf, bus, 0, func, regOff); - mvPexLocalBusNumSet(pexIf, localBus); - mvPexLocalDevNumSet(pexIf, localDev); - return val; - } - } - /* for all other devices use the HW function to get the - * requested registers - */ - mvPexLocalDevNumSet(pexIf, 1); - val = mvPexHwConfigRead (pexIf, bus, dev, func, regOff); - mvPexLocalDevNumSet(pexIf, localDev); - return val; -} - - -MV_STATUS mvPexVrtBrgConfigWrite(MV_U32 pexIf, MV_U32 bus, MV_U32 dev, - MV_U32 func, MV_U32 regOff, MV_U32 data) -{ - MV_U32 localBus = mvPexLocalBusNumGet(pexIf); - MV_U32 localDev = mvPexLocalDevNumGet(pexIf); - MV_STATUS status; - - if(bus == localBus) - { - if(dev > 1) - { - /* on the local device allow only device #0 & #1 */ - return MV_ERROR; - } - else - if (dev == localDev) - { - /* read the memory controller registers */ - return mvPexHwConfigWrite (pexIf, bus, dev, func, regOff, data); - } - else - { - /* access the virtual brg header */ - HEADER_WRITE(data, regOff); - return MV_OK; - } - } - else - if(bus == (localBus + 1)) - { - /* access the device behind the virtual bridge */ - if((dev == localDev) || (dev > 1)) - { - return MV_ERROR; - } - else - { - /* access the device behind the virtual bridge, in this case - * change the bus number to the local bus number in order to - * generate type 0 config cycle - */ - //return mvPexHwConfigWrite (pexIf, localBus, dev, func, regOff, data); - mvPexLocalBusNumSet(pexIf, bus); - mvPexLocalDevNumSet(pexIf, 1); - status = mvPexHwConfigWrite (pexIf, bus, 0, func, regOff, data); - mvPexLocalBusNumSet(pexIf, localBus); - mvPexLocalDevNumSet(pexIf, localDev); - return status; - - } - } - /* for all other devices use the HW function to get the - * requested registers - */ - mvPexLocalDevNumSet(pexIf, 1); - status = mvPexHwConfigWrite (pexIf, bus, dev, func, regOff, data); - mvPexLocalDevNumSet(pexIf, localDev); - return status; -} - - - - -void resetPexConfig(MV_U32 pexIf, MV_U32 bus, MV_U32 dev) -{ - MV_U32 tData; - MV_U32 i; - - /* restore the PEX configuration to initialization state */ - /* in case PEX P2P call recursive and reset config */ - tData = mvPexHwConfigRead (pexIf, bus, dev, 0x0, 0x0); - if(tData != 0xffffffff) - { - /* agent had been found - check whether P2P */ - tData = mvPexHwConfigRead (pexIf, bus, dev, 0x0, 0x8); - if((tData & 0xffff0000) == 0x06040000) - {/* P2P */ - /* get the sec bus and the subordinate */ - MV_U32 secBus; - tData = mvPexHwConfigRead (pexIf, bus, dev, 0x0, 0x18); - secBus = ((tData >> 8) & 0xff); - /* now scan on sec bus */ - for(i = 0;i < 0xff;i++) - { - resetPexConfig(pexIf, secBus, i); - } - /* now reset this device */ - DB(mvOsPrintf("Reset bus %d dev %d\n", bus, dev)); - mvPexHwConfigWrite(pexIf, bus, dev, 0x0, 0x18, 0x0); - DB(mvOsPrintf("Reset bus %d dev %d\n", bus, dev)); - } - } -} - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pex/mvVrtBrgPex.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pex/mvVrtBrgPex.h deleted file mode 100644 index d01f024..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/pex/mvVrtBrgPex.h +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCVRTBRGPEXH -#define __INCVRTBRGPEXH - - -/* Global Functions prototypes */ -/* mvPexInit - Initialize PEX interfaces*/ -MV_STATUS mvPexVrtBrgInit(MV_U32 pexIf); - -/* mvPexConfigRead - Read from configuration space */ -MV_U32 mvPexVrtBrgConfigRead (MV_U32 pexIf, MV_U32 bus, MV_U32 dev, - MV_U32 func,MV_U32 regOff); - -/* mvPexConfigWrite - Write to configuration space */ -MV_STATUS mvPexVrtBrgConfigWrite(MV_U32 pexIf, MV_U32 bus, MV_U32 dev, - MV_U32 func, MV_U32 regOff, MV_U32 data); - - -#endif /* #ifndef __INCPEXH */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/sflash/mvSFlash.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/sflash/mvSFlash.c deleted file mode 100644 index 6c5bc19..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/sflash/mvSFlash.c +++ /dev/null @@ -1,1522 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ -#include "mvOs.h" -#include "sflash/mvSFlash.h" -#include "sflash/mvSFlashSpec.h" -#include "spi/mvSpi.h" -#include "spi/mvSpiCmnd.h" -#include "ctrlEnv/mvCtrlEnvLib.h" - -/*#define MV_DEBUG*/ -#ifdef MV_DEBUG -#define DB(x) x -#else -#define DB(x) -#endif - -/* Globals */ -static MV_SFLASH_DEVICE_PARAMS sflash[] = { - /* ST M25P32 SPI flash, 4MB, 64 sectors of 64K each */ - { - MV_M25P_WREN_CMND_OPCD, - MV_M25P_WRDI_CMND_OPCD, - MV_M25P_RDID_CMND_OPCD, - MV_M25P_RDSR_CMND_OPCD, - MV_M25P_WRSR_CMND_OPCD, - MV_M25P_READ_CMND_OPCD, - MV_M25P_FAST_RD_CMND_OPCD, - MV_M25P_PP_CMND_OPCD, - MV_M25P_SE_CMND_OPCD, - MV_M25P_BE_CMND_OPCD, - MV_M25P_RES_CMND_OPCD, - MV_SFLASH_NO_SPECIFIC_OPCD, /* power save not supported */ - MV_M25P32_SECTOR_SIZE, - MV_M25P32_SECTOR_NUMBER, - MV_M25P_PAGE_SIZE, - "ST M25P32", - MV_M25PXXX_ST_MANF_ID, - MV_M25P32_DEVICE_ID, - MV_M25P32_MAX_SPI_FREQ, - MV_M25P32_MAX_FAST_SPI_FREQ, - MV_M25P32_FAST_READ_DUMMY_BYTES - }, - /* ST M25P64 SPI flash, 8MB, 128 sectors of 64K each */ - { - MV_M25P_WREN_CMND_OPCD, - MV_M25P_WRDI_CMND_OPCD, - MV_M25P_RDID_CMND_OPCD, - MV_M25P_RDSR_CMND_OPCD, - MV_M25P_WRSR_CMND_OPCD, - MV_M25P_READ_CMND_OPCD, - MV_M25P_FAST_RD_CMND_OPCD, - MV_M25P_PP_CMND_OPCD, - MV_M25P_SE_CMND_OPCD, - MV_M25P_BE_CMND_OPCD, - MV_M25P_RES_CMND_OPCD, - MV_SFLASH_NO_SPECIFIC_OPCD, /* power save not supported */ - MV_M25P64_SECTOR_SIZE, - MV_M25P64_SECTOR_NUMBER, - MV_M25P_PAGE_SIZE, - "ST M25P64", - MV_M25PXXX_ST_MANF_ID, - MV_M25P64_DEVICE_ID, - MV_M25P64_MAX_SPI_FREQ, - MV_M25P64_MAX_FAST_SPI_FREQ, - MV_M25P64_FAST_READ_DUMMY_BYTES - }, - /* ST M25P128 SPI flash, 16MB, 64 sectors of 256K each */ - { - MV_M25P_WREN_CMND_OPCD, - MV_M25P_WRDI_CMND_OPCD, - MV_M25P_RDID_CMND_OPCD, - MV_M25P_RDSR_CMND_OPCD, - MV_M25P_WRSR_CMND_OPCD, - MV_M25P_READ_CMND_OPCD, - MV_M25P_FAST_RD_CMND_OPCD, - MV_M25P_PP_CMND_OPCD, - MV_M25P_SE_CMND_OPCD, - MV_M25P_BE_CMND_OPCD, - MV_M25P_RES_CMND_OPCD, - MV_SFLASH_NO_SPECIFIC_OPCD, /* power save not supported */ - MV_M25P128_SECTOR_SIZE, - MV_M25P128_SECTOR_NUMBER, - MV_M25P_PAGE_SIZE, - "ST M25P128", - MV_M25PXXX_ST_MANF_ID, - MV_M25P128_DEVICE_ID, - MV_M25P128_MAX_SPI_FREQ, - MV_M25P128_MAX_FAST_SPI_FREQ, - MV_M25P128_FAST_READ_DUMMY_BYTES - }, - /* Macronix MXIC MX25L6405 SPI flash, 8MB, 128 sectors of 64K each */ - { - MV_MX25L_WREN_CMND_OPCD, - MV_MX25L_WRDI_CMND_OPCD, - MV_MX25L_RDID_CMND_OPCD, - MV_MX25L_RDSR_CMND_OPCD, - MV_MX25L_WRSR_CMND_OPCD, - MV_MX25L_READ_CMND_OPCD, - MV_MX25L_FAST_RD_CMND_OPCD, - MV_MX25L_PP_CMND_OPCD, - MV_MX25L_SE_CMND_OPCD, - MV_MX25L_BE_CMND_OPCD, - MV_MX25L_RES_CMND_OPCD, - MV_MX25L_DP_CMND_OPCD, - MV_MX25L6405_SECTOR_SIZE, - MV_MX25L6405_SECTOR_NUMBER, - MV_MXIC_PAGE_SIZE, - "MXIC MX25L6405", - MV_MXIC_MANF_ID, - MV_MX25L6405_DEVICE_ID, - MV_MX25L6405_MAX_SPI_FREQ, - MV_MX25L6405_MAX_FAST_SPI_FREQ, - MV_MX25L6405_FAST_READ_DUMMY_BYTES - }, - /* SPANSION S25FL128P SPI flash, 16MB, 64 sectors of 256K each */ - { - MV_S25FL_WREN_CMND_OPCD, - MV_S25FL_WRDI_CMND_OPCD, - MV_S25FL_RDID_CMND_OPCD, - MV_S25FL_RDSR_CMND_OPCD, - MV_S25FL_WRSR_CMND_OPCD, - MV_S25FL_READ_CMND_OPCD, - MV_S25FL_FAST_RD_CMND_OPCD, - MV_S25FL_PP_CMND_OPCD, - MV_S25FL_SE_CMND_OPCD, - MV_S25FL_BE_CMND_OPCD, - MV_S25FL_RES_CMND_OPCD, - MV_S25FL_DP_CMND_OPCD, - MV_S25FL128_SECTOR_SIZE, - MV_S25FL128_SECTOR_NUMBER, - MV_S25FL_PAGE_SIZE, - "SPANSION S25FL128", - MV_SPANSION_MANF_ID, - MV_S25FL128_DEVICE_ID, - MV_S25FL128_MAX_SPI_FREQ, - MV_M25P128_MAX_FAST_SPI_FREQ, - MV_M25P128_FAST_READ_DUMMY_BYTES - } -}; - -/* Static Functions */ -static MV_STATUS mvWriteEnable (MV_SFLASH_INFO * pFlinfo); -static MV_STATUS mvStatusRegGet (MV_SFLASH_INFO * pFlinfo, MV_U8 * pStatReg); -static MV_STATUS mvStatusRegSet (MV_SFLASH_INFO * pFlinfo, MV_U8 sr); -static MV_STATUS mvWaitOnWipClear(MV_SFLASH_INFO * pFlinfo); -static MV_STATUS mvSFlashPageWr (MV_SFLASH_INFO * pFlinfo, MV_U32 offset, \ - MV_U8* pPageBuff, MV_U32 buffSize); -static MV_STATUS mvSFlashWithDefaultsIdGet (MV_SFLASH_INFO * pFlinfo, \ - MV_U8* manId, MV_U16* devId); - -/******************************************************************************* -* mvWriteEnable - serialize the write enable sequence -* -* DESCRIPTION: -* transmit the sequence for write enable -* -********************************************************************************/ -static MV_STATUS mvWriteEnable(MV_SFLASH_INFO * pFlinfo) -{ - MV_U8 cmd[MV_SFLASH_WREN_CMND_LENGTH]; - - - cmd[0] = sflash[pFlinfo->index].opcdWREN; - - return mvSpiWriteThenRead(cmd, MV_SFLASH_WREN_CMND_LENGTH, NULL, 0, 0); -} - -/******************************************************************************* -* mvStatusRegGet - Retrieve the value of the status register -* -* DESCRIPTION: -* perform the RDSR sequence to get the 8bit status register -* -********************************************************************************/ -static MV_STATUS mvStatusRegGet(MV_SFLASH_INFO * pFlinfo, MV_U8 * pStatReg) -{ - MV_STATUS ret; - MV_U8 cmd[MV_SFLASH_RDSR_CMND_LENGTH]; - MV_U8 sr[MV_SFLASH_RDSR_REPLY_LENGTH]; - - - - - cmd[0] = sflash[pFlinfo->index].opcdRDSR; - - if ((ret = mvSpiWriteThenRead(cmd, MV_SFLASH_RDSR_CMND_LENGTH, sr, - MV_SFLASH_RDSR_REPLY_LENGTH,0)) != MV_OK) - return ret; - - *pStatReg = sr[0]; - - return MV_OK; -} - -/******************************************************************************* -* mvWaitOnWipClear - Block waiting for the WIP (write in progress) to be cleared -* -* DESCRIPTION: -* Block waiting for the WIP (write in progress) to be cleared -* -********************************************************************************/ -static MV_STATUS mvWaitOnWipClear(MV_SFLASH_INFO * pFlinfo) -{ - MV_STATUS ret; - MV_U32 i; - MV_U8 stat; - - for (i=0; i<MV_SFLASH_MAX_WAIT_LOOP; i++) - { - if ((ret = mvStatusRegGet(pFlinfo, &stat)) != MV_OK) - return ret; - - if ((stat & MV_SFLASH_STATUS_REG_WIP_MASK) == 0) - return MV_OK; - } - - DB(mvOsPrintf("%s WARNING: Write Timeout!\n", __FUNCTION__);) - return MV_TIMEOUT; -} - -/******************************************************************************* -* mvWaitOnChipEraseDone - Block waiting for the WIP (write in progress) to be -* cleared after a chip erase command which is supposed -* to take about 2:30 minutes -* -* DESCRIPTION: -* Block waiting for the WIP (write in progress) to be cleared -* -********************************************************************************/ -static MV_STATUS mvWaitOnChipEraseDone(MV_SFLASH_INFO * pFlinfo) -{ - MV_STATUS ret; - MV_U32 i; - MV_U8 stat; - - for (i=0; i<MV_SFLASH_CHIP_ERASE_MAX_WAIT_LOOP; i++) - { - if ((ret = mvStatusRegGet(pFlinfo, &stat)) != MV_OK) - return ret; - - if ((stat & MV_SFLASH_STATUS_REG_WIP_MASK) == 0) - return MV_OK; - } - - DB(mvOsPrintf("%s WARNING: Write Timeout!\n", __FUNCTION__);) - return MV_TIMEOUT; -} - -/******************************************************************************* -* mvStatusRegSet - Set the value of the 8bit status register -* -* DESCRIPTION: -* Set the value of the 8bit status register -* -********************************************************************************/ -static MV_STATUS mvStatusRegSet(MV_SFLASH_INFO * pFlinfo, MV_U8 sr) -{ - MV_STATUS ret; - MV_U8 cmd[MV_SFLASH_WRSR_CMND_LENGTH]; - - - /* Issue the Write enable command prior the WRSR command */ - if ((ret = mvWriteEnable(pFlinfo)) != MV_OK) - return ret; - - /* Write the SR with the new values */ - cmd[0] = sflash[pFlinfo->index].opcdWRSR; - cmd[1] = sr; - - if ((ret = mvSpiWriteThenRead(cmd, MV_SFLASH_WRSR_CMND_LENGTH, NULL, 0, 0)) != MV_OK) - return ret; - - if ((ret = mvWaitOnWipClear(pFlinfo)) != MV_OK) - return ret; - - mvOsDelay(1); - - return MV_OK; -} - -/******************************************************************************* -* mvSFlashPageWr - Write up to 256 Bytes in the same page -* -* DESCRIPTION: -* Write a buffer up to the page size in length provided that the whole address -* range is within the same page (alligned to page bounderies) -* -*******************************************************************************/ -static MV_STATUS mvSFlashPageWr (MV_SFLASH_INFO * pFlinfo, MV_U32 offset, - MV_U8* pPageBuff, MV_U32 buffSize) -{ - MV_STATUS ret; - MV_U8 cmd[MV_SFLASH_PP_CMND_LENGTH]; - - - /* Protection - check if the model was detected */ - if (pFlinfo->index >= MV_ARRAY_SIZE(sflash)) - { - DB(mvOsPrintf("%s WARNING: Invalid parameter device index!\n", __FUNCTION__);) - return MV_BAD_PARAM; - } - - /* check that we do not cross the page bounderies */ - if (((offset & (sflash[pFlinfo->index].pageSize - 1)) + buffSize) > - sflash[pFlinfo->index].pageSize) - { - DB(mvOsPrintf("%s WARNING: Page allignment problem!\n", __FUNCTION__);) - return MV_OUT_OF_RANGE; - } - - /* Issue the Write enable command prior the page program command */ - if ((ret = mvWriteEnable(pFlinfo)) != MV_OK) - return ret; - - cmd[0] = sflash[pFlinfo->index].opcdPP; - cmd[1] = ((offset >> 16) & 0xFF); - cmd[2] = ((offset >> 8) & 0xFF); - cmd[3] = (offset & 0xFF); - - if ((ret = mvSpiWriteThenWrite(cmd, MV_SFLASH_PP_CMND_LENGTH, pPageBuff, buffSize)) != MV_OK) - return ret; - - if ((ret = mvWaitOnWipClear(pFlinfo)) != MV_OK) - return ret; - - return MV_OK; -} - -/******************************************************************************* -* mvSFlashWithDefaultsIdGet - Try to read the manufacturer and Device IDs from -* the device using the default RDID opcode and the default WREN opcode. -* -* DESCRIPTION: -* This is used to detect a generic device that uses the default opcodes -* for the WREN and RDID. -* -********************************************************************************/ -static MV_STATUS mvSFlashWithDefaultsIdGet (MV_SFLASH_INFO * pFlinfo, MV_U8* manId, MV_U16* devId) -{ - MV_STATUS ret; - MV_U8 cmdRDID[MV_SFLASH_RDID_CMND_LENGTH]; - MV_U8 id[MV_SFLASH_RDID_REPLY_LENGTH]; - - - - /* Use the default RDID opcode to read the IDs */ - cmdRDID[0] = MV_SFLASH_DEFAULT_RDID_OPCD; /* unknown model try default */ - if ((ret = mvSpiWriteThenRead(cmdRDID, MV_SFLASH_RDID_CMND_LENGTH, id, MV_SFLASH_RDID_REPLY_LENGTH, 0)) != MV_OK) - return ret; - - *manId = id[0]; - *devId = 0; - *devId |= (id[1] << 8); - *devId |= id[2]; - - return MV_OK; -} - -/* -##################################################################################### -##################################################################################### -*/ - -/******************************************************************************* -* mvSFlashInit - Initialize the serial flash device -* -* DESCRIPTION: -* Perform the neccessary initialization and configuration -* -* INPUT: -* pFlinfo: pointer to the Flash information structure -* pFlinfo->baseAddr: base address in fast mode. -* pFlinfo->index: Index of the flash in the sflash tabel. If the SPI -* flash device does not support read Id command with -* the standard opcode, then the user should supply this -* as an input to skip the autodetection process!!!! -* -* OUTPUT: -* pFlinfo: pointer to the Flash information structure after detection -* pFlinfo->manufacturerId: Manufacturer ID -* pFlinfo->deviceId: Device ID -* pFlinfo->sectorSize: size of the sector (all sectors are the same). -* pFlinfo->sectorNumber: number of sectors. -* pFlinfo->pageSize: size of the page. -* pFlinfo->index: Index of the detected flash in the sflash tabel -* -* RETURN: -* Success or Error code. -* -* -*******************************************************************************/ -MV_STATUS mvSFlashInit (MV_SFLASH_INFO * pFlinfo) -{ - MV_STATUS ret; - MV_U8 manf; - MV_U16 dev; - MV_U32 indx; - MV_BOOL detectFlag = MV_FALSE; - - /* check for NULL pointer */ - if (pFlinfo == NULL) - { - mvOsPrintf("%s ERROR: Null pointer parameter!\n", __FUNCTION__); - return MV_BAD_PARAM; - } - - /* Initialize the SPI interface with low frequency to make sure that the read ID succeeds */ - if ((ret = mvSpiInit(MV_SFLASH_BASIC_SPI_FREQ)) != MV_OK) - { - mvOsPrintf("%s ERROR: Failed to initialize the SPI interface!\n", __FUNCTION__); - return ret; - } - - /* First try to read the Manufacturer and Device IDs */ - if ((ret = mvSFlashIdGet(pFlinfo, &manf, &dev)) != MV_OK) - { - mvOsPrintf("%s ERROR: Failed to get the SFlash ID!\n", __FUNCTION__); - return ret; - } - - /* loop over the whole table and look for the appropriate SFLASH */ - for (indx=0; indx<MV_ARRAY_SIZE(sflash); indx++) - { - if ((manf == sflash[indx].manufacturerId) && (dev == sflash[indx].deviceId)) - { - pFlinfo->manufacturerId = manf; - pFlinfo->deviceId = dev; - pFlinfo->index = indx; - detectFlag = MV_TRUE; - } - } - - if(!detectFlag) - { - mvOsPrintf("%s ERROR: Unknown SPI flash device!\n", __FUNCTION__); - return MV_FAIL; - } - - /* fill the info based on the model detected */ - pFlinfo->sectorSize = sflash[pFlinfo->index].sectorSize; - pFlinfo->sectorNumber = sflash[pFlinfo->index].sectorNumber; - pFlinfo->pageSize = sflash[pFlinfo->index].pageSize; - - /* Set the SPI frequency to the MAX allowed for the device for best performance */ - if ((ret = mvSpiBaudRateSet(sflash[pFlinfo->index].spiMaxFreq)) != MV_OK) - { - mvOsPrintf("%s ERROR: Failed to set the SPI frequency!\n", __FUNCTION__); - return ret; - } - - /* As default lock the SR */ - if ((ret = mvSFlashStatRegLock(pFlinfo, MV_TRUE)) != MV_OK) - return ret; - - return MV_OK; -} - -/******************************************************************************* -* mvSFlashSectorErase - Erasse a single sector of the serial flash -* -* DESCRIPTION: -* Issue the erase sector command and address -* -* INPUT: -* pFlinfo: pointer to the Flash information structure -* secNumber: sector Number to erase (0 -> (sectorNumber-1)) -* -* OUTPUT: -* None -* -* RETURN: -* Success or Error code. -* -* -*******************************************************************************/ -MV_STATUS mvSFlashSectorErase (MV_SFLASH_INFO * pFlinfo, MV_U32 secNumber) -{ - MV_STATUS ret; - MV_U8 cmd[MV_SFLASH_SE_CMND_LENGTH]; - - MV_U32 secAddr = (secNumber * pFlinfo->sectorSize); -#if 0 - MV_U32 i; - MV_U32 * pW = (MV_U32*) (secAddr + pFlinfo->baseAddr); - MV_U32 erasedWord = 0xFFFFFFFF; - MV_U32 wordsPerSector = (pFlinfo->sectorSize / sizeof(MV_U32)); - MV_BOOL eraseNeeded = MV_FALSE; -#endif - /* check for NULL pointer */ - if (pFlinfo == NULL) - { - mvOsPrintf("%s ERROR: Null pointer parameter!\n", __FUNCTION__); - return MV_BAD_PARAM; - } - - /* Protection - check if the model was detected */ - if (pFlinfo->index >= MV_ARRAY_SIZE(sflash)) - { - DB(mvOsPrintf("%s WARNING: Invaild parameter index!\n", __FUNCTION__);) - return MV_BAD_PARAM; - } - - /* check that the sector number is valid */ - if (secNumber >= pFlinfo->sectorNumber) - { - DB(mvOsPrintf("%s WARNING: Invaild parameter sector number!\n", __FUNCTION__);) - return MV_BAD_PARAM; - } - - /* we don't want to access SPI in direct mode from in-direct API, - becasue of timing issue between CS asserts. */ -#if 0 - /* First compare to FF and check if erase is needed */ - for (i=0; i<wordsPerSector; i++) - { - if (memcmp(pW, &erasedWord, sizeof(MV_U32)) != 0) - { - eraseNeeded = MV_TRUE; - break; - } - - ++pW; - } - if (!eraseNeeded) - return MV_OK; -#endif - - cmd[0] = sflash[pFlinfo->index].opcdSE; - cmd[1] = ((secAddr >> 16) & 0xFF); - cmd[2] = ((secAddr >> 8) & 0xFF); - cmd[3] = (secAddr & 0xFF); - - /* Issue the Write enable command prior the sector erase command */ - if ((ret = mvWriteEnable(pFlinfo)) != MV_OK) - return ret; - - if ((ret = mvSpiWriteThenWrite(cmd, MV_SFLASH_SE_CMND_LENGTH, NULL, 0)) != MV_OK) - return ret; - - if ((ret = mvWaitOnWipClear(pFlinfo)) != MV_OK) - return ret; - - return MV_OK; -} - -/******************************************************************************* -* mvSFlashChipErase - Erasse the whole serial flash -* -* DESCRIPTION: -* Issue the bulk (chip) erase command -* -* INPUT: -* pFlinfo: pointer to the Flash information structure -* -* OUTPUT: -* None -* -* RETURN: -* Success or Error code. -* -* -*******************************************************************************/ -MV_STATUS mvSFlashChipErase (MV_SFLASH_INFO * pFlinfo) -{ - MV_STATUS ret; - MV_U8 cmd[MV_SFLASH_BE_CMND_LENGTH]; - - - /* check for NULL pointer */ - if (pFlinfo == NULL) - { - mvOsPrintf("%s ERROR: Null pointer parameter!\n", __FUNCTION__); - return MV_BAD_PARAM; - } - - /* Protection - check if the model was detected */ - if (pFlinfo->index >= MV_ARRAY_SIZE(sflash)) - { - DB(mvOsPrintf("%s WARNING: Invaild parameter index!\n", __FUNCTION__);) - return MV_BAD_PARAM; - } - - cmd[0] = sflash[pFlinfo->index].opcdBE; - - /* Issue the Write enable command prior the Bulk erase command */ - if ((ret = mvWriteEnable(pFlinfo)) != MV_OK) - return ret; - - if ((ret = mvSpiWriteThenWrite(cmd, MV_SFLASH_BE_CMND_LENGTH, NULL, 0)) != MV_OK) - return ret; - - if ((ret = mvWaitOnChipEraseDone(pFlinfo)) != MV_OK) - return ret; - - return MV_OK; -} - -/******************************************************************************* -* mvSFlashBlockRd - Read from the serial flash -* -* DESCRIPTION: -* Issue the read command and address then perfom the needed read -* -* INPUT: -* pFlinfo: pointer to the Flash information structure -* offset: byte offset with the flash to start reading from -* pReadBuff: pointer to the buffer to read the data in -* buffSize: size of the buffer to read. -* -* OUTPUT: -* pReadBuff: pointer to the buffer containing the read data -* -* RETURN: -* Success or Error code. -* -* -*******************************************************************************/ -MV_STATUS mvSFlashBlockRd (MV_SFLASH_INFO * pFlinfo, MV_U32 offset, - MV_U8* pReadBuff, MV_U32 buffSize) -{ - MV_U8 cmd[MV_SFLASH_READ_CMND_LENGTH]; - - - /* check for NULL pointer */ - if ((pFlinfo == NULL) || (pReadBuff == NULL)) - { - mvOsPrintf("%s ERROR: Null pointer parameter!\n", __FUNCTION__); - return MV_BAD_PARAM; - } - - /* Protection - check if the model was detected */ - if (pFlinfo->index >= MV_ARRAY_SIZE(sflash)) - { - DB(mvOsPrintf("%s WARNING: Invaild parameter index!\n", __FUNCTION__);) - return MV_BAD_PARAM; - } - - cmd[0] = sflash[pFlinfo->index].opcdREAD; - cmd[1] = ((offset >> 16) & 0xFF); - cmd[2] = ((offset >> 8) & 0xFF); - cmd[3] = (offset & 0xFF); - - return mvSpiWriteThenRead(cmd, MV_SFLASH_READ_CMND_LENGTH, pReadBuff, buffSize, 0); -} - -/******************************************************************************* -* mvSFlashFastBlockRd - Fast read from the serial flash -* -* DESCRIPTION: -* Issue the fast read command and address then perfom the needed read -* -* INPUT: -* pFlinfo: pointer to the Flash information structure -* offset: byte offset with the flash to start reading from -* pReadBuff: pointer to the buffer to read the data in -* buffSize: size of the buffer to read. -* -* OUTPUT: -* pReadBuff: pointer to the buffer containing the read data -* -* RETURN: -* Success or Error code. -* -* -*******************************************************************************/ -MV_STATUS mvSFlashFastBlockRd (MV_SFLASH_INFO * pFlinfo, MV_U32 offset, - MV_U8* pReadBuff, MV_U32 buffSize) -{ - MV_U8 cmd[MV_SFLASH_READ_CMND_LENGTH]; - MV_STATUS ret; - - /* check for NULL pointer */ - if ((pFlinfo == NULL) || (pReadBuff == NULL)) - { - mvOsPrintf("%s ERROR: Null pointer parameter!\n", __FUNCTION__); - return MV_BAD_PARAM; - } - - /* Protection - check if the model was detected */ - if (pFlinfo->index >= MV_ARRAY_SIZE(sflash)) - { - DB(mvOsPrintf("%s WARNING: Invaild parameter index!\n", __FUNCTION__);) - return MV_BAD_PARAM; - } - - /* Set the SPI frequency to the MAX allowed for fast-read operations */ - mvOsPrintf("Setting freq to %d.\n",sflash[pFlinfo->index].spiMaxFastFreq); - if ((ret = mvSpiBaudRateSet(sflash[pFlinfo->index].spiMaxFastFreq)) != MV_OK) - { - mvOsPrintf("%s ERROR: Failed to set the SPI fast frequency!\n", __FUNCTION__); - return ret; - } - - cmd[0] = sflash[pFlinfo->index].opcdFSTRD; - cmd[1] = ((offset >> 16) & 0xFF); - cmd[2] = ((offset >> 8) & 0xFF); - cmd[3] = (offset & 0xFF); - - - ret = mvSpiWriteThenRead(cmd, MV_SFLASH_READ_CMND_LENGTH, pReadBuff, buffSize, - sflash[pFlinfo->index].spiFastRdDummyBytes); - - /* Reset the SPI frequency to the MAX allowed for the device for best performance */ - if ((ret = mvSpiBaudRateSet(sflash[pFlinfo->index].spiMaxFreq)) != MV_OK) - { - mvOsPrintf("%s ERROR: Failed to set the SPI frequency!\n", __FUNCTION__); - return ret; - } - - return ret; -} - - -/******************************************************************************* -* mvSFlashBlockWr - Write a buffer with any size -* -* DESCRIPTION: -* write regardless of the page boundaries and size limit per Page -* program command -* -* INPUT: -* pFlinfo: pointer to the Flash information structure -* offset: byte offset within the flash region -* pWriteBuff: pointer to the buffer holding the data to program -* buffSize: size of the buffer to write -* -* OUTPUT: -* None -* -* RETURN: -* Success or Error code. -* -* -*******************************************************************************/ -MV_STATUS mvSFlashBlockWr (MV_SFLASH_INFO * pFlinfo, MV_U32 offset, - MV_U8* pWriteBuff, MV_U32 buffSize) -{ - MV_STATUS ret; - MV_U32 data2write = buffSize; - MV_U32 preAllOffset = (offset & MV_SFLASH_PAGE_ALLIGN_MASK(MV_M25P_PAGE_SIZE)); - MV_U32 preAllSz = (preAllOffset ? (MV_M25P_PAGE_SIZE - preAllOffset) : 0); - MV_U32 writeOffset = offset; - - /* check for NULL pointer */ -#ifndef CONFIG_MARVELL - if(NULL == pWriteBuff) - { - mvOsPrintf("%s ERROR: Null pointer parameter!\n", __FUNCTION__); - return MV_BAD_PARAM; - } -#endif - - if (pFlinfo == NULL) - { - mvOsPrintf("%s ERROR: Null pointer parameter!\n", __FUNCTION__); - return MV_BAD_PARAM; - } - - /* Protection - check if the model was detected */ - if (pFlinfo->index >= MV_ARRAY_SIZE(sflash)) - { - DB(mvOsPrintf("%s WARNING: Invaild parameter index!\n", __FUNCTION__);) - return MV_BAD_PARAM; - } - - /* check that the buffer size does not exceed the flash size */ - if ((offset + buffSize) > mvSFlashSizeGet(pFlinfo)) - { - DB(mvOsPrintf("%s WARNING: Write exceeds flash size!\n", __FUNCTION__);) - return MV_OUT_OF_RANGE; - } - - /* check if the total block size is less than the first chunk remainder */ - if (data2write < preAllSz) - preAllSz = data2write; - - /* check if programing does not start at a 64byte alligned offset */ - if (preAllSz) - { - if ((ret = mvSFlashPageWr(pFlinfo, writeOffset, pWriteBuff, preAllSz)) != MV_OK) - return ret; - - /* increment pointers and counters */ - writeOffset += preAllSz; - data2write -= preAllSz; - pWriteBuff += preAllSz; - } - - /* program the data that fits in complete page chunks */ - while (data2write >= sflash[pFlinfo->index].pageSize) - { - if ((ret = mvSFlashPageWr(pFlinfo, writeOffset, pWriteBuff, sflash[pFlinfo->index].pageSize)) != MV_OK) - return ret; - - /* increment pointers and counters */ - writeOffset += sflash[pFlinfo->index].pageSize; - data2write -= sflash[pFlinfo->index].pageSize; - pWriteBuff += sflash[pFlinfo->index].pageSize; - } - - /* program the last partial chunk */ - if (data2write) - { - if ((ret = mvSFlashPageWr(pFlinfo, writeOffset, pWriteBuff, data2write)) != MV_OK) - return ret; - } - - return MV_OK; -} - -/******************************************************************************* -* mvSFlashIdGet - Get the manufacturer and device IDs. -* -* DESCRIPTION: -* Get the Manufacturer and device IDs from the serial flash through -* writing the RDID command then reading 3 bytes of data. In case that -* this command was called for the first time in order to detect the -* manufacturer and device IDs, then the default RDID opcode will be used -* unless the device index is indicated by the user (in case the SPI flash -* does not use the default RDID opcode). -* -* INPUT: -* pFlinfo: pointer to the Flash information structure -* pManId: pointer to the 8bit variable to hold the manufacturing ID -* pDevId: pointer to the 16bit variable to hold the device ID -* -* OUTPUT: -* pManId: pointer to the 8bit variable holding the manufacturing ID -* pDevId: pointer to the 16bit variable holding the device ID -* -* RETURN: -* Success or Error code. -* -* -*******************************************************************************/ -MV_STATUS mvSFlashIdGet (MV_SFLASH_INFO * pFlinfo, MV_U8* pManId, MV_U16* pDevId) -{ - MV_STATUS ret; - MV_U8 cmd[MV_SFLASH_RDID_CMND_LENGTH]; - MV_U8 id[MV_SFLASH_RDID_REPLY_LENGTH]; - - - - /* check for NULL pointer */ - if ((pFlinfo == NULL) || (pManId == NULL) || (pDevId == NULL)) - { - mvOsPrintf("%s ERROR: Null pointer parameter!\n", __FUNCTION__); - return MV_BAD_PARAM; - } - - if (pFlinfo->index >= MV_ARRAY_SIZE(sflash)) - return mvSFlashWithDefaultsIdGet(pFlinfo, pManId, pDevId); - else - cmd[0] = sflash[pFlinfo->index].opcdRDID; - - if ((ret = mvSpiWriteThenRead(cmd, MV_SFLASH_RDID_CMND_LENGTH, id, MV_SFLASH_RDID_REPLY_LENGTH, 0)) != MV_OK) - return ret; - - *pManId = id[0]; - *pDevId = 0; - *pDevId |= (id[1] << 8); - *pDevId |= id[2]; - - return MV_OK; -} - -/******************************************************************************* -* mvSFlashWpRegionSet - Set the Write-Protected region -* -* DESCRIPTION: -* Set the Write-Protected region -* -* INPUT: -* pFlinfo: pointer to the Flash information structure -* wpRegion: which region will be protected -* -* OUTPUT: -* None -* -* RETURN: -* Success or Error code. -* -* -*******************************************************************************/ -MV_STATUS mvSFlashWpRegionSet (MV_SFLASH_INFO * pFlinfo, MV_SFLASH_WP_REGION wpRegion) -{ - MV_U8 wpMask; - - /* check for NULL pointer */ - if (pFlinfo == NULL) - { - mvOsPrintf("%s ERROR: Null pointer parameter!\n", __FUNCTION__); - return MV_BAD_PARAM; - } - - /* Protection - check if the model was detected */ - if (pFlinfo->index >= MV_ARRAY_SIZE(sflash)) - { - DB(mvOsPrintf("%s WARNING: Invaild parameter index!\n", __FUNCTION__);) - return MV_BAD_PARAM; - } - - /* Check if the chip is an ST flash; then WP supports only 3 bits */ - if (pFlinfo->manufacturerId == MV_M25PXXX_ST_MANF_ID) - { - switch (wpRegion) - { - case MV_WP_NONE: - wpMask = MV_M25P_STATUS_BP_NONE; - break; - - case MV_WP_UPR_1OF128: - DB(mvOsPrintf("%s WARNING: Invaild option for this flash chip!\n", __FUNCTION__);) - return MV_NOT_SUPPORTED; - - case MV_WP_UPR_1OF64: - wpMask = MV_M25P_STATUS_BP_1_OF_64; - break; - - case MV_WP_UPR_1OF32: - wpMask = MV_M25P_STATUS_BP_1_OF_32; - break; - - case MV_WP_UPR_1OF16: - wpMask = MV_M25P_STATUS_BP_1_OF_16; - break; - - case MV_WP_UPR_1OF8: - wpMask = MV_M25P_STATUS_BP_1_OF_8; - break; - - case MV_WP_UPR_1OF4: - wpMask = MV_M25P_STATUS_BP_1_OF_4; - break; - - case MV_WP_UPR_1OF2: - wpMask = MV_M25P_STATUS_BP_1_OF_2; - break; - - case MV_WP_ALL: - wpMask = MV_M25P_STATUS_BP_ALL; - break; - - default: - DB(mvOsPrintf("%s WARNING: Invaild parameter WP region!\n", __FUNCTION__);) - return MV_BAD_PARAM; - } - } - /* check if the manufacturer is MXIC then the WP is 4bits */ - else if (pFlinfo->manufacturerId == MV_MXIC_MANF_ID) - { - switch (wpRegion) - { - case MV_WP_NONE: - wpMask = MV_MX25L_STATUS_BP_NONE; - break; - - case MV_WP_UPR_1OF128: - wpMask = MV_MX25L_STATUS_BP_1_OF_128; - break; - - case MV_WP_UPR_1OF64: - wpMask = MV_MX25L_STATUS_BP_1_OF_64; - break; - - case MV_WP_UPR_1OF32: - wpMask = MV_MX25L_STATUS_BP_1_OF_32; - break; - - case MV_WP_UPR_1OF16: - wpMask = MV_MX25L_STATUS_BP_1_OF_16; - break; - - case MV_WP_UPR_1OF8: - wpMask = MV_MX25L_STATUS_BP_1_OF_8; - break; - - case MV_WP_UPR_1OF4: - wpMask = MV_MX25L_STATUS_BP_1_OF_4; - break; - - case MV_WP_UPR_1OF2: - wpMask = MV_MX25L_STATUS_BP_1_OF_2; - break; - - case MV_WP_ALL: - wpMask = MV_MX25L_STATUS_BP_ALL; - break; - - default: - DB(mvOsPrintf("%s WARNING: Invaild parameter WP region!\n", __FUNCTION__);) - return MV_BAD_PARAM; - } - } - /* check if the manufacturer is SPANSION then the WP is 4bits */ - else if (pFlinfo->manufacturerId == MV_SPANSION_MANF_ID) - { - switch (wpRegion) - { - case MV_WP_NONE: - wpMask = MV_S25FL_STATUS_BP_NONE; - break; - - case MV_WP_UPR_1OF128: - DB(mvOsPrintf("%s WARNING: Invaild option for this flash chip!\n", __FUNCTION__);) - return MV_NOT_SUPPORTED; - - case MV_WP_UPR_1OF64: - wpMask = MV_S25FL_STATUS_BP_1_OF_64; - break; - - case MV_WP_UPR_1OF32: - wpMask = MV_S25FL_STATUS_BP_1_OF_32; - break; - - case MV_WP_UPR_1OF16: - wpMask = MV_S25FL_STATUS_BP_1_OF_16; - break; - - case MV_WP_UPR_1OF8: - wpMask = MV_S25FL_STATUS_BP_1_OF_8; - break; - - case MV_WP_UPR_1OF4: - wpMask = MV_S25FL_STATUS_BP_1_OF_4; - break; - - case MV_WP_UPR_1OF2: - wpMask = MV_S25FL_STATUS_BP_1_OF_2; - break; - - case MV_WP_ALL: - wpMask = MV_S25FL_STATUS_BP_ALL; - break; - - - default: - DB(mvOsPrintf("%s WARNING: Invaild parameter WP region!\n", __FUNCTION__);) - return MV_BAD_PARAM; - } - } - else - { - DB(mvOsPrintf("%s WARNING: Invaild parameter Manufacturer ID!\n", __FUNCTION__);) - return MV_BAD_PARAM; - } - - /* Verify that the SRWD bit is always set - register is s/w locked */ - wpMask |= MV_SFLASH_STATUS_REG_SRWD_MASK; - - return mvStatusRegSet(pFlinfo, wpMask); -} - -/******************************************************************************* -* mvSFlashWpRegionGet - Get the Write-Protected region configured -* -* DESCRIPTION: -* Get from the chip the Write-Protected region configured -* -* INPUT: -* pFlinfo: pointer to the Flash information structure -* pWpRegion: pointer to the variable to return the WP region in -* -* OUTPUT: -* wpRegion: pointer to the variable holding the WP region configured -* -* RETURN: -* Success or Error code. -* -* -*******************************************************************************/ -MV_STATUS mvSFlashWpRegionGet (MV_SFLASH_INFO * pFlinfo, MV_SFLASH_WP_REGION * pWpRegion) -{ - MV_STATUS ret; - MV_U8 reg; - - /* check for NULL pointer */ - if ((pFlinfo == NULL) || (pWpRegion == NULL)) - { - mvOsPrintf("%s ERROR: Null pointer parameter!\n", __FUNCTION__); - return MV_BAD_PARAM; - } - - /* Protection - check if the model was detected */ - if (pFlinfo->index >= MV_ARRAY_SIZE(sflash)) - { - DB(mvOsPrintf("%s WARNING: Invaild parameter index!\n", __FUNCTION__);) - return MV_BAD_PARAM; - } - - if ((ret = mvStatusRegGet(pFlinfo, ®)) != MV_OK) - return ret; - - /* Check if the chip is an ST flash; then WP supports only 3 bits */ - if (pFlinfo->manufacturerId == MV_M25PXXX_ST_MANF_ID) - { - switch ((reg & MV_M25P_STATUS_REG_WP_MASK)) - { - case MV_M25P_STATUS_BP_NONE: - *pWpRegion = MV_WP_NONE; - break; - - case MV_M25P_STATUS_BP_1_OF_64: - *pWpRegion = MV_WP_UPR_1OF64; - break; - - case MV_M25P_STATUS_BP_1_OF_32: - *pWpRegion = MV_WP_UPR_1OF32; - break; - - case MV_M25P_STATUS_BP_1_OF_16: - *pWpRegion = MV_WP_UPR_1OF16; - break; - - case MV_M25P_STATUS_BP_1_OF_8: - *pWpRegion = MV_WP_UPR_1OF8; - break; - - case MV_M25P_STATUS_BP_1_OF_4: - *pWpRegion = MV_WP_UPR_1OF4; - break; - - case MV_M25P_STATUS_BP_1_OF_2: - *pWpRegion = MV_WP_UPR_1OF2; - break; - - case MV_M25P_STATUS_BP_ALL: - *pWpRegion = MV_WP_ALL; - break; - - default: - DB(mvOsPrintf("%s WARNING: Unidentified WP region in h/w!\n", __FUNCTION__);) - return MV_BAD_VALUE; - } - } - /* check if the manufacturer is MXIC then the WP is 4bits */ - else if (pFlinfo->manufacturerId == MV_MXIC_MANF_ID) - { - switch ((reg & MV_MX25L_STATUS_REG_WP_MASK)) - { - case MV_MX25L_STATUS_BP_NONE: - *pWpRegion = MV_WP_NONE; - break; - - case MV_MX25L_STATUS_BP_1_OF_128: - *pWpRegion = MV_WP_UPR_1OF128; - break; - - case MV_MX25L_STATUS_BP_1_OF_64: - *pWpRegion = MV_WP_UPR_1OF64; - break; - - case MV_MX25L_STATUS_BP_1_OF_32: - *pWpRegion = MV_WP_UPR_1OF32; - break; - - case MV_MX25L_STATUS_BP_1_OF_16: - *pWpRegion = MV_WP_UPR_1OF16; - break; - - case MV_MX25L_STATUS_BP_1_OF_8: - *pWpRegion = MV_WP_UPR_1OF8; - break; - - case MV_MX25L_STATUS_BP_1_OF_4: - *pWpRegion = MV_WP_UPR_1OF4; - break; - - case MV_MX25L_STATUS_BP_1_OF_2: - *pWpRegion = MV_WP_UPR_1OF2; - break; - - case MV_MX25L_STATUS_BP_ALL: - *pWpRegion = MV_WP_ALL; - break; - - default: - DB(mvOsPrintf("%s WARNING: Unidentified WP region in h/w!\n", __FUNCTION__);) - return MV_BAD_VALUE; - } - } - /* Check if the chip is an SPANSION flash; then WP supports only 3 bits */ - else if (pFlinfo->manufacturerId == MV_SPANSION_MANF_ID) - { - switch ((reg & MV_S25FL_STATUS_REG_WP_MASK)) - { - case MV_S25FL_STATUS_BP_NONE: - *pWpRegion = MV_WP_NONE; - break; - - case MV_S25FL_STATUS_BP_1_OF_64: - *pWpRegion = MV_WP_UPR_1OF64; - break; - - case MV_S25FL_STATUS_BP_1_OF_32: - *pWpRegion = MV_WP_UPR_1OF32; - break; - - case MV_S25FL_STATUS_BP_1_OF_16: - *pWpRegion = MV_WP_UPR_1OF16; - break; - - case MV_S25FL_STATUS_BP_1_OF_8: - *pWpRegion = MV_WP_UPR_1OF8; - break; - - case MV_S25FL_STATUS_BP_1_OF_4: - *pWpRegion = MV_WP_UPR_1OF4; - break; - - case MV_S25FL_STATUS_BP_1_OF_2: - *pWpRegion = MV_WP_UPR_1OF2; - break; - - case MV_S25FL_STATUS_BP_ALL: - *pWpRegion = MV_WP_ALL; - break; - - default: - DB(mvOsPrintf("%s WARNING: Unidentified WP region in h/w!\n", __FUNCTION__);) - return MV_BAD_VALUE; - } - } - else - { - DB(mvOsPrintf("%s WARNING: Invaild parameter Manufacturer ID!\n", __FUNCTION__);) - return MV_BAD_PARAM; - } - - return MV_OK; -} - -/******************************************************************************* -* mvSFlashStatRegLock - Lock the status register for writing - W/Vpp -* pin should be low to take effect -* -* DESCRIPTION: -* Lock the access to the Status Register for writing. This will -* cause the flash to enter the hardware protection mode if the W/Vpp -* is low. If the W/Vpp is hi, the chip will be in soft protection mode, but -* the register will continue to be writable if WREN sequence was used. -* -* INPUT: -* pFlinfo: pointer to the Flash information structure -* srLock: enable/disable (MV_TRUE/MV_FALSE) status registor lock mechanism -* -* OUTPUT: -* None -* -* RETURN: -* Success or Error code. -* -* -*******************************************************************************/ -MV_STATUS mvSFlashStatRegLock (MV_SFLASH_INFO * pFlinfo, MV_BOOL srLock) -{ - MV_STATUS ret; - MV_U8 reg; - - /* check for NULL pointer */ - if (pFlinfo == NULL) - { - mvOsPrintf("%s ERROR: Null pointer parameter!\n", __FUNCTION__); - return MV_BAD_PARAM; - } - - /* Protection - check if the model was detected */ - if (pFlinfo->index >= MV_ARRAY_SIZE(sflash)) - { - DB(mvOsPrintf("%s WARNING: Invaild parameter index!\n", __FUNCTION__);) - return MV_BAD_PARAM; - } - - if ((ret = mvStatusRegGet(pFlinfo, ®)) != MV_OK) - return ret; - - if (srLock) - reg |= MV_SFLASH_STATUS_REG_SRWD_MASK; - else - reg &= ~MV_SFLASH_STATUS_REG_SRWD_MASK; - - return mvStatusRegSet(pFlinfo, reg); -} - -/******************************************************************************* -* mvSFlashSizeGet - Get the size of the SPI flash -* -* DESCRIPTION: -* based on the sector number and size of each sector calculate the total -* size of the flash memory. -* -* INPUT: -* pFlinfo: pointer to the Flash information structure -* -* OUTPUT: -* None. -* -* RETURN: -* Size of the flash in bytes. -* -* -*******************************************************************************/ -MV_U32 mvSFlashSizeGet (MV_SFLASH_INFO * pFlinfo) -{ - /* check for NULL pointer */ - if (pFlinfo == NULL) - { - mvOsPrintf("%s ERROR: Null pointer parameter!\n", __FUNCTION__); - return 0; - } - - return (pFlinfo->sectorSize * pFlinfo->sectorNumber); -} - -/******************************************************************************* -* mvSFlashPowerSaveEnter - Cause the falsh device to go into power save mode -* -* DESCRIPTION: -* Enter a special power save mode. -* -* INPUT: -* pFlinfo: pointer to the Flash information structure -* -* OUTPUT: -* None. -* -* RETURN: -* Size of the flash in bytes. -* -* -*******************************************************************************/ -MV_STATUS mvSFlashPowerSaveEnter(MV_SFLASH_INFO * pFlinfo) -{ - MV_STATUS ret; - MV_U8 cmd[MV_SFLASH_DP_CMND_LENGTH]; - - - /* check for NULL pointer */ - if (pFlinfo == NULL) - { - mvOsPrintf("%s ERROR: Null pointer parameter!\n", __FUNCTION__); - return 0; - } - - /* Protection - check if the model was detected */ - if (pFlinfo->index >= MV_ARRAY_SIZE(sflash)) - { - DB(mvOsPrintf("%s WARNING: Invaild parameter index!\n", __FUNCTION__);) - return MV_BAD_PARAM; - } - - /* check that power save mode is supported in the specific device */ - if (sflash[pFlinfo->index].opcdPwrSave == MV_SFLASH_NO_SPECIFIC_OPCD) - { - DB(mvOsPrintf("%s WARNING: Power save not supported for this device!\n", __FUNCTION__);) - return MV_NOT_SUPPORTED; - } - - cmd[0] = sflash[pFlinfo->index].opcdPwrSave; - - if ((ret = mvSpiWriteThenWrite(cmd, MV_SFLASH_DP_CMND_LENGTH, NULL, 0)) != MV_OK) - return ret; - - return MV_OK; - -} - -/******************************************************************************* -* mvSFlashPowerSaveExit - Cause the falsh device to exit the power save mode -* -* DESCRIPTION: -* Exit the deep power save mode. -* -* INPUT: -* pFlinfo: pointer to the Flash information structure -* -* OUTPUT: -* None. -* -* RETURN: -* Size of the flash in bytes. -* -* -*******************************************************************************/ -MV_STATUS mvSFlashPowerSaveExit (MV_SFLASH_INFO * pFlinfo) -{ - MV_STATUS ret; - MV_U8 cmd[MV_SFLASH_RES_CMND_LENGTH]; - - - /* check for NULL pointer */ - if (pFlinfo == NULL) - { - mvOsPrintf("%s ERROR: Null pointer parameter!\n", __FUNCTION__); - return 0; - } - - /* Protection - check if the model was detected */ - if (pFlinfo->index >= MV_ARRAY_SIZE(sflash)) - { - DB(mvOsPrintf("%s WARNING: Invaild parameter index!\n", __FUNCTION__);) - return MV_BAD_PARAM; - } - - /* check that power save mode is supported in the specific device */ - if (sflash[pFlinfo->index].opcdRES == MV_SFLASH_NO_SPECIFIC_OPCD) - { - DB(mvOsPrintf("%s WARNING: Read Electronic Signature not supported for this device!\n", __FUNCTION__);) - return MV_NOT_SUPPORTED; - } - - cmd[0] = sflash[pFlinfo->index].opcdRES; - - if ((ret = mvSpiWriteThenWrite(cmd, MV_SFLASH_RES_CMND_LENGTH, NULL, 0)) != MV_OK) - return ret; - - /* add the delay needed for the device to wake up */ - mvOsDelay(MV_MXIC_DP_EXIT_DELAY); /* 30 ms */ - - return MV_OK; - -} - -/******************************************************************************* -* mvSFlashModelGet - Retreive the string with the device manufacturer and model -* -* DESCRIPTION: -* Retreive the string with the device manufacturer and model -* -* INPUT: -* pFlinfo: pointer to the Flash information structure -* -* OUTPUT: -* None. -* -* RETURN: -* pointer to the string indicating the device manufacturer and model -* -* -*******************************************************************************/ -const MV_8 * mvSFlashModelGet (MV_SFLASH_INFO * pFlinfo) -{ - static const MV_8 * unknModel = (const MV_8 *)"Unknown"; - - /* check for NULL pointer */ - if (pFlinfo == NULL) - { - mvOsPrintf("%s ERROR: Null pointer parameter!\n", __FUNCTION__); - return 0; - } - - /* Protection - check if the model was detected */ - if (pFlinfo->index >= MV_ARRAY_SIZE(sflash)) - { - DB(mvOsPrintf("%s WARNING: Invaild parameter index!\n", __FUNCTION__);) - return unknModel; - } - - return sflash[pFlinfo->index].deviceModel; -} - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/sflash/mvSFlash.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/sflash/mvSFlash.h deleted file mode 100644 index f441a5c..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/sflash/mvSFlash.h +++ /dev/null @@ -1,166 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCmvSFlashH -#define __INCmvSFlashH - -#include "mvTypes.h" - -/* MCAROS */ -#define MV_SFLASH_PAGE_ALLIGN_MASK(pgSz) (pgSz-1) -#define MV_ARRAY_SIZE(a) ((sizeof(a)) / (sizeof(a[0]))) - -/* Constants */ -#define MV_INVALID_DEVICE_NUMBER 0xFFFFFFFF -/* 10 MHz is the minimum possible SPI frequency when tclk is set 200MHz*/ -#define MV_SFLASH_BASIC_SPI_FREQ 10000000 -/* enumerations */ -typedef enum -{ - MV_WP_NONE, /* Unprotect the whole chip */ - MV_WP_UPR_1OF128, /* Write protect the upper 1/128 part */ - MV_WP_UPR_1OF64, /* Write protect the upper 1/64 part */ - MV_WP_UPR_1OF32, /* Write protect the upper 1/32 part */ - MV_WP_UPR_1OF16, /* Write protect the upper 1/16 part */ - MV_WP_UPR_1OF8, /* Write protect the upper 1/8 part */ - MV_WP_UPR_1OF4, /* Write protect the upper 1/4 part */ - MV_WP_UPR_1OF2, /* Write protect the upper 1/2 part */ - MV_WP_ALL /* Write protect the whole chip */ -} MV_SFLASH_WP_REGION; - -/* Type Definitions */ -typedef struct -{ - MV_U8 opcdWREN; /* Write enable opcode */ - MV_U8 opcdWRDI; /* Write disable opcode */ - MV_U8 opcdRDID; /* Read ID opcode */ - MV_U8 opcdRDSR; /* Read Status Register opcode */ - MV_U8 opcdWRSR; /* Write Status register opcode */ - MV_U8 opcdREAD; /* Read opcode */ - MV_U8 opcdFSTRD; /* Fast Read opcode */ - MV_U8 opcdPP; /* Page program opcode */ - MV_U8 opcdSE; /* Sector erase opcode */ - MV_U8 opcdBE; /* Bulk erase opcode */ - MV_U8 opcdRES; /* Read electronic signature */ - MV_U8 opcdPwrSave; /* Go into power save mode */ - MV_U32 sectorSize; /* Size of each sector */ - MV_U32 sectorNumber; /* Number of sectors */ - MV_U32 pageSize; /* size of each page */ - const char * deviceModel; /* string with the device model */ - MV_U32 manufacturerId; /* The manufacturer ID */ - MV_U32 deviceId; /* Device ID */ - MV_U32 spiMaxFreq; /* The MAX frequency that can be used with the device */ - MV_U32 spiMaxFastFreq; /* The MAX frequency that can be used with the device for fast reads */ - MV_U32 spiFastRdDummyBytes; /* Number of dumy bytes to read before real data when working in fast read mode. */ -} MV_SFLASH_DEVICE_PARAMS; - -typedef struct -{ - MV_U32 baseAddr; /* Flash Base Address used in fast mode */ - MV_U8 manufacturerId; /* Manufacturer ID */ - MV_U16 deviceId; /* Device ID */ - MV_U32 sectorSize; /* Size of each sector - all the same */ - MV_U32 sectorNumber; /* Number of sectors */ - MV_U32 pageSize; /* Page size - affect allignment */ - MV_U32 index; /* index of the device in the sflash table (internal parameter) */ -} MV_SFLASH_INFO; - -/* Function Prototypes */ -/* Init */ -MV_STATUS mvSFlashInit (MV_SFLASH_INFO * pFlinfo); - -/* erase */ -MV_STATUS mvSFlashSectorErase (MV_SFLASH_INFO * pFlinfo, MV_U32 secNumber); -MV_STATUS mvSFlashChipErase (MV_SFLASH_INFO * pFlinfo); - -/* Read */ -MV_STATUS mvSFlashBlockRd (MV_SFLASH_INFO * pFlinfo, MV_U32 offset, - MV_U8* pReadBuff, MV_U32 buffSize); -MV_STATUS mvSFlashFastBlockRd (MV_SFLASH_INFO * pFlinfo, MV_U32 offset, - MV_U8* pReadBuff, MV_U32 buffSize); - -/* write regardless of the page boundaries and size limit per Page program command */ -MV_STATUS mvSFlashBlockWr (MV_SFLASH_INFO * pFlinfo, MV_U32 offset, - MV_U8* pWriteBuff, MV_U32 buffSize); -/* Get IDs */ -MV_STATUS mvSFlashIdGet (MV_SFLASH_INFO * pFlinfo, MV_U8* pManId, MV_U16* pDevId); - -/* Set and Get the Write Protection region - if the Status register is not locked */ -MV_STATUS mvSFlashWpRegionSet (MV_SFLASH_INFO * pFlinfo, MV_SFLASH_WP_REGION wpRegion); -MV_STATUS mvSFlashWpRegionGet (MV_SFLASH_INFO * pFlinfo, MV_SFLASH_WP_REGION * pWpRegion); - -/* Lock the status register for writing - W/Vpp pin should be low to take effect */ -MV_STATUS mvSFlashStatRegLock (MV_SFLASH_INFO * pFlinfo, MV_BOOL srLock); - -/* Get the regions sizes */ -MV_U32 mvSFlashSizeGet (MV_SFLASH_INFO * pFlinfo); - -/* Cause the falsh device to go into power save mode */ -MV_STATUS mvSFlashPowerSaveEnter(MV_SFLASH_INFO * pFlinfo); -MV_STATUS mvSFlashPowerSaveExit (MV_SFLASH_INFO * pFlinfo); - -/* Retreive the string with the device manufacturer and model */ -const MV_8 * mvSFlashModelGet (MV_SFLASH_INFO * pFlinfo); - -#endif /* __INCmvSFlashH */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/sflash/mvSFlashSpec.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/sflash/mvSFlashSpec.h deleted file mode 100644 index eeb4426..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/sflash/mvSFlashSpec.h +++ /dev/null @@ -1,233 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCmvSFlashSpecH -#define __INCmvSFlashSpecH - -/* Constants */ -#define MV_SFLASH_READ_CMND_LENGTH 4 /* 1B opcode + 3B address */ -#define MV_SFLASH_SE_CMND_LENGTH 4 /* 1B opcode + 3B address */ -#define MV_SFLASH_BE_CMND_LENGTH 1 /* 1B opcode */ -#define MV_SFLASH_PP_CMND_LENGTH 4 /* 1B opcode + 3B address */ -#define MV_SFLASH_WREN_CMND_LENGTH 1 /* 1B opcode */ -#define MV_SFLASH_WRDI_CMND_LENGTH 1 /* 1B opcode */ -#define MV_SFLASH_RDID_CMND_LENGTH 1 /* 1B opcode */ -#define MV_SFLASH_RDID_REPLY_LENGTH 3 /* 1B manf ID and 2B device ID */ -#define MV_SFLASH_RDSR_CMND_LENGTH 1 /* 1B opcode */ -#define MV_SFLASH_RDSR_REPLY_LENGTH 1 /* 1B status */ -#define MV_SFLASH_WRSR_CMND_LENGTH 2 /* 1B opcode + 1B status value */ -#define MV_SFLASH_DP_CMND_LENGTH 1 /* 1B opcode */ -#define MV_SFLASH_RES_CMND_LENGTH 1 /* 1B opcode */ - -/* Status Register Bit Masks */ -#define MV_SFLASH_STATUS_REG_WIP_OFFSET 0 /* bit 0; write in progress */ -#define MV_SFLASH_STATUS_REG_WP_OFFSET 2 /* bit 2-4; write protect option */ -#define MV_SFLASH_STATUS_REG_SRWD_OFFSET 7 /* bit 7; lock status register write */ -#define MV_SFLASH_STATUS_REG_WIP_MASK (0x1 << MV_SFLASH_STATUS_REG_WIP_OFFSET) -#define MV_SFLASH_STATUS_REG_SRWD_MASK (0x1 << MV_SFLASH_STATUS_REG_SRWD_OFFSET) - -#define MV_SFLASH_MAX_WAIT_LOOP 1000000 -#define MV_SFLASH_CHIP_ERASE_MAX_WAIT_LOOP 0x50000000 - -#define MV_SFLASH_DEFAULT_RDID_OPCD 0x9F /* Default Read ID */ -#define MV_SFLASH_DEFAULT_WREN_OPCD 0x06 /* Default Write Enable */ -#define MV_SFLASH_NO_SPECIFIC_OPCD 0x00 - -/********************************/ -/* ST M25Pxxx Device Specific */ -/********************************/ - -/* Manufacturer IDs and Device IDs for SFLASHs supported by the driver */ -#define MV_M25PXXX_ST_MANF_ID 0x20 -#define MV_M25P32_DEVICE_ID 0x2016 -#define MV_M25P32_MAX_SPI_FREQ 20000000 /* 20MHz */ -#define MV_M25P32_MAX_FAST_SPI_FREQ 50000000 /* 50MHz */ -#define MV_M25P32_FAST_READ_DUMMY_BYTES 1 -#define MV_M25P64_DEVICE_ID 0x2017 -#define MV_M25P64_MAX_SPI_FREQ 20000000 /* 20MHz */ -#define MV_M25P64_MAX_FAST_SPI_FREQ 50000000 /* 50MHz */ -#define MV_M25P64_FAST_READ_DUMMY_BYTES 1 -#define MV_M25P128_DEVICE_ID 0x2018 -#define MV_M25P128_MAX_SPI_FREQ 20000000 /* 20MHz */ -#define MV_M25P128_MAX_FAST_SPI_FREQ 50000000 /* 50MHz */ -#define MV_M25P128_FAST_READ_DUMMY_BYTES 1 - - -/* Sector Sizes and population per device model*/ -#define MV_M25P32_SECTOR_SIZE 0x10000 /* 64K */ -#define MV_M25P64_SECTOR_SIZE 0x10000 /* 64K */ -#define MV_M25P128_SECTOR_SIZE 0x40000 /* 256K */ -#define MV_M25P32_SECTOR_NUMBER 64 -#define MV_M25P64_SECTOR_NUMBER 128 -#define MV_M25P128_SECTOR_NUMBER 64 -#define MV_M25P_PAGE_SIZE 0x100 /* 256 byte */ - -#define MV_M25P_WREN_CMND_OPCD 0x06 /* Write Enable */ -#define MV_M25P_WRDI_CMND_OPCD 0x04 /* Write Disable */ -#define MV_M25P_RDID_CMND_OPCD 0x9F /* Read ID */ -#define MV_M25P_RDSR_CMND_OPCD 0x05 /* Read Status Register */ -#define MV_M25P_WRSR_CMND_OPCD 0x01 /* Write Status Register */ -#define MV_M25P_READ_CMND_OPCD 0x03 /* Sequential Read */ -#define MV_M25P_FAST_RD_CMND_OPCD 0x0B /* Fast Read */ -#define MV_M25P_PP_CMND_OPCD 0x02 /* Page Program */ -#define MV_M25P_SE_CMND_OPCD 0xD8 /* Sector Erase */ -#define MV_M25P_BE_CMND_OPCD 0xC7 /* Bulk Erase */ -#define MV_M25P_RES_CMND_OPCD 0xAB /* Read Electronic Signature */ - -/* Status Register Write Protect Bit Masks - 3bits */ -#define MV_M25P_STATUS_REG_WP_MASK (0x07 << MV_SFLASH_STATUS_REG_WP_OFFSET) -#define MV_M25P_STATUS_BP_NONE (0x00 << MV_SFLASH_STATUS_REG_WP_OFFSET) -#define MV_M25P_STATUS_BP_1_OF_64 (0x01 << MV_SFLASH_STATUS_REG_WP_OFFSET) -#define MV_M25P_STATUS_BP_1_OF_32 (0x02 << MV_SFLASH_STATUS_REG_WP_OFFSET) -#define MV_M25P_STATUS_BP_1_OF_16 (0x03 << MV_SFLASH_STATUS_REG_WP_OFFSET) -#define MV_M25P_STATUS_BP_1_OF_8 (0x04 << MV_SFLASH_STATUS_REG_WP_OFFSET) -#define MV_M25P_STATUS_BP_1_OF_4 (0x05 << MV_SFLASH_STATUS_REG_WP_OFFSET) -#define MV_M25P_STATUS_BP_1_OF_2 (0x06 << MV_SFLASH_STATUS_REG_WP_OFFSET) -#define MV_M25P_STATUS_BP_ALL (0x07 << MV_SFLASH_STATUS_REG_WP_OFFSET) - -/************************************/ -/* MXIC MX25L6405 Device Specific */ -/************************************/ - -/* Manufacturer IDs and Device IDs for SFLASHs supported by the driver */ -#define MV_MXIC_MANF_ID 0xC2 -#define MV_MX25L6405_DEVICE_ID 0x2017 -#define MV_MX25L6405_MAX_SPI_FREQ 20000000 /* 20MHz */ -#define MV_MX25L6405_MAX_FAST_SPI_FREQ 50000000 /* 50MHz */ -#define MV_MX25L6405_FAST_READ_DUMMY_BYTES 1 -#define MV_MXIC_DP_EXIT_DELAY 30 /* 30 ms */ - -/* Sector Sizes and population per device model*/ -#define MV_MX25L6405_SECTOR_SIZE 0x10000 /* 64K */ -#define MV_MX25L6405_SECTOR_NUMBER 128 -#define MV_MXIC_PAGE_SIZE 0x100 /* 256 byte */ - -#define MV_MX25L_WREN_CMND_OPCD 0x06 /* Write Enable */ -#define MV_MX25L_WRDI_CMND_OPCD 0x04 /* Write Disable */ -#define MV_MX25L_RDID_CMND_OPCD 0x9F /* Read ID */ -#define MV_MX25L_RDSR_CMND_OPCD 0x05 /* Read Status Register */ -#define MV_MX25L_WRSR_CMND_OPCD 0x01 /* Write Status Register */ -#define MV_MX25L_READ_CMND_OPCD 0x03 /* Sequential Read */ -#define MV_MX25L_FAST_RD_CMND_OPCD 0x0B /* Fast Read */ -#define MV_MX25L_PP_CMND_OPCD 0x02 /* Page Program */ -#define MV_MX25L_SE_CMND_OPCD 0xD8 /* Sector Erase */ -#define MV_MX25L_BE_CMND_OPCD 0xC7 /* Bulk Erase */ -#define MV_MX25L_DP_CMND_OPCD 0xB9 /* Deep Power Down */ -#define MV_MX25L_RES_CMND_OPCD 0xAB /* Read Electronic Signature */ - -/* Status Register Write Protect Bit Masks - 4bits */ -#define MV_MX25L_STATUS_REG_WP_MASK (0x0F << MV_SFLASH_STATUS_REG_WP_OFFSET) -#define MV_MX25L_STATUS_BP_NONE (0x00 << MV_SFLASH_STATUS_REG_WP_OFFSET) -#define MV_MX25L_STATUS_BP_1_OF_128 (0x01 << MV_SFLASH_STATUS_REG_WP_OFFSET) -#define MV_MX25L_STATUS_BP_1_OF_64 (0x02 << MV_SFLASH_STATUS_REG_WP_OFFSET) -#define MV_MX25L_STATUS_BP_1_OF_32 (0x03 << MV_SFLASH_STATUS_REG_WP_OFFSET) -#define MV_MX25L_STATUS_BP_1_OF_16 (0x04 << MV_SFLASH_STATUS_REG_WP_OFFSET) -#define MV_MX25L_STATUS_BP_1_OF_8 (0x05 << MV_SFLASH_STATUS_REG_WP_OFFSET) -#define MV_MX25L_STATUS_BP_1_OF_4 (0x06 << MV_SFLASH_STATUS_REG_WP_OFFSET) -#define MV_MX25L_STATUS_BP_1_OF_2 (0x07 << MV_SFLASH_STATUS_REG_WP_OFFSET) -#define MV_MX25L_STATUS_BP_ALL (0x0F << MV_SFLASH_STATUS_REG_WP_OFFSET) - -/************************************/ -/* SPANSION S25FL128P Device Specific */ -/************************************/ - -/* Manufacturer IDs and Device IDs for SFLASHs supported by the driver */ -#define MV_SPANSION_MANF_ID 0x01 -#define MV_S25FL128_DEVICE_ID 0x2018 -#define MV_S25FL128_MAX_SPI_FREQ 33000000 /* 33MHz */ -#define MV_S25FL128_MAX_FAST_SPI_FREQ 104000000 /* 104MHz */ -#define MV_S25FL128_FAST_READ_DUMMY_BYTES 1 - -/* Sector Sizes and population per device model*/ -#define MV_S25FL128_SECTOR_SIZE 0x40000 /* 256K */ -#define MV_S25FL128_SECTOR_NUMBER 64 -#define MV_S25FL_PAGE_SIZE 0x100 /* 256 byte */ - -#define MV_S25FL_WREN_CMND_OPCD 0x06 /* Write Enable */ -#define MV_S25FL_WRDI_CMND_OPCD 0x04 /* Write Disable */ -#define MV_S25FL_RDID_CMND_OPCD 0x9F /* Read ID */ -#define MV_S25FL_RDSR_CMND_OPCD 0x05 /* Read Status Register */ -#define MV_S25FL_WRSR_CMND_OPCD 0x01 /* Write Status Register */ -#define MV_S25FL_READ_CMND_OPCD 0x03 /* Sequential Read */ -#define MV_S25FL_FAST_RD_CMND_OPCD 0x0B /* Fast Read */ -#define MV_S25FL_PP_CMND_OPCD 0x02 /* Page Program */ -#define MV_S25FL_SE_CMND_OPCD 0xD8 /* Sector Erase */ -#define MV_S25FL_BE_CMND_OPCD 0xC7 /* Bulk Erase */ -#define MV_S25FL_DP_CMND_OPCD 0xB9 /* Deep Power Down */ -#define MV_S25FL_RES_CMND_OPCD 0xAB /* Read Electronic Signature */ - -/* Status Register Write Protect Bit Masks - 4bits */ -#define MV_S25FL_STATUS_REG_WP_MASK (0x0F << MV_SFLASH_STATUS_REG_WP_OFFSET) -#define MV_S25FL_STATUS_BP_NONE (0x00 << MV_SFLASH_STATUS_REG_WP_OFFSET) -#define MV_S25FL_STATUS_BP_1_OF_128 (0x01 << MV_SFLASH_STATUS_REG_WP_OFFSET) -#define MV_S25FL_STATUS_BP_1_OF_64 (0x02 << MV_SFLASH_STATUS_REG_WP_OFFSET) -#define MV_S25FL_STATUS_BP_1_OF_32 (0x03 << MV_SFLASH_STATUS_REG_WP_OFFSET) -#define MV_S25FL_STATUS_BP_1_OF_16 (0x04 << MV_SFLASH_STATUS_REG_WP_OFFSET) -#define MV_S25FL_STATUS_BP_1_OF_8 (0x05 << MV_SFLASH_STATUS_REG_WP_OFFSET) -#define MV_S25FL_STATUS_BP_1_OF_4 (0x06 << MV_SFLASH_STATUS_REG_WP_OFFSET) -#define MV_S25FL_STATUS_BP_1_OF_2 (0x07 << MV_SFLASH_STATUS_REG_WP_OFFSET) -#define MV_S25FL_STATUS_BP_ALL (0x0F << MV_SFLASH_STATUS_REG_WP_OFFSET) - -#endif /* __INCmvSFlashSpecH */ - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/spi/mvSpi.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/spi/mvSpi.c deleted file mode 100644 index 39e0b72..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/spi/mvSpi.c +++ /dev/null @@ -1,576 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#include "spi/mvSpi.h" -#include "spi/mvSpiSpec.h" - -#include "ctrlEnv/mvCtrlEnvLib.h" - -/* #define MV_DEBUG */ -#ifdef MV_DEBUG -#define DB(x) x -#define mvOsPrintf printf -#else -#define DB(x) -#endif - - -/******************************************************************************* -* mvSpi16bitDataTxRx - Transmt and receive data -* -* DESCRIPTION: -* Tx data and block waiting for data to be transmitted -* -********************************************************************************/ -static MV_STATUS mvSpi16bitDataTxRx (MV_U16 txData, MV_U16 * pRxData) -{ - MV_U32 i; - MV_BOOL ready = MV_FALSE; - - /* First clear the bit in the interrupt cause register */ - MV_REG_WRITE(MV_SPI_INT_CAUSE_REG, 0x0); - - /* Transmit data */ - MV_REG_WRITE(MV_SPI_DATA_OUT_REG, MV_16BIT_LE(txData)); - - /* wait with timeout for memory ready */ - for (i=0; i<MV_SPI_WAIT_RDY_MAX_LOOP; i++) - { - if (MV_REG_READ(MV_SPI_INT_CAUSE_REG)) - { - ready = MV_TRUE; - break; - } -#ifdef MV_SPI_SLEEP_ON_WAIT - mvOsSleep(1); -#endif /* MV_SPI_SLEEP_ON_WAIT */ - } - - if (!ready) - return MV_TIMEOUT; - - /* check that the RX data is needed */ - if (pRxData) - { - if ((MV_U32)pRxData & 0x1) /* check if address is not alligned to 16bit */ - { -#if defined(MV_CPU_LE) - /* perform the data write to the buffer in two stages with 8bit each */ - MV_U8 * bptr = (MV_U8*)pRxData; - MV_U16 data = MV_16BIT_LE(MV_REG_READ(MV_SPI_DATA_IN_REG)); - *bptr = (data & 0xFF); - ++bptr; - *bptr = ((data >> 8) & 0xFF); - -#elif defined(MV_CPU_BE) - - /* perform the data write to the buffer in two stages with 8bit each */ - MV_U8 * bptr = (MV_U8 *)pRxData; - MV_U16 data = MV_16BIT_LE(MV_REG_READ(MV_SPI_DATA_IN_REG)); - *bptr = ((data >> 8) & 0xFF); - ++bptr; - *bptr = (data & 0xFF); - -#else - #error "CPU endianess isn't defined!\n" -#endif - - } - else - *pRxData = MV_16BIT_LE(MV_REG_READ(MV_SPI_DATA_IN_REG)); - } - - return MV_OK; -} - - -/******************************************************************************* -* mvSpi8bitDataTxRx - Transmt and receive data (8bits) -* -* DESCRIPTION: -* Tx data and block waiting for data to be transmitted -* -********************************************************************************/ -static MV_STATUS mvSpi8bitDataTxRx (MV_U8 txData, MV_U8 * pRxData) -{ - MV_U32 i; - MV_BOOL ready = MV_FALSE; - - /* First clear the bit in the interrupt cause register */ - MV_REG_WRITE(MV_SPI_INT_CAUSE_REG, 0x0); - - /* Transmit data */ - MV_REG_WRITE(MV_SPI_DATA_OUT_REG, txData); - - /* wait with timeout for memory ready */ - for (i=0; i<MV_SPI_WAIT_RDY_MAX_LOOP; i++) - { - if (MV_REG_READ(MV_SPI_INT_CAUSE_REG)) - { - ready = MV_TRUE; - break; - } -#ifdef MV_SPI_SLEEP_ON_WAIT - mvOsSleep(1); -#endif /* MV_SPI_SLEEP_ON_WAIT */ - } - - if (!ready) - return MV_TIMEOUT; - - /* check that the RX data is needed */ - if (pRxData) - *pRxData = MV_REG_READ(MV_SPI_DATA_IN_REG); - - return MV_OK; -} - -/* -##################################################################################### -##################################################################################### -*/ - -/******************************************************************************* -* mvSpiInit - Initialize the SPI controller -* -* DESCRIPTION: -* Perform the neccessary initialization in order to be able to send an -* receive over the SPI interface. -* -* INPUT: -* serialBaudRate: Baud rate (SPI clock frequency) -* use16BitMode: Whether to use 2bytes (MV_TRUE) or 1bytes (MV_FALSE) -* -* OUTPUT: -* None. -* -* RETURN: -* Success or Error code. -* -* -*******************************************************************************/ -MV_STATUS mvSpiInit (MV_U32 serialBaudRate) -{ - MV_STATUS ret; - - /* Set the serial clock */ - if ((ret = mvSpiBaudRateSet(serialBaudRate)) != MV_OK) - return ret; - - /* For devices in which the SPI is muxed on the MPP with other interfaces*/ - mvMPPConfigToSPI(); - - /* Configure the default SPI mode to be 16bit */ - MV_REG_BIT_SET(MV_SPI_IF_CONFIG_REG, MV_SPI_BYTE_LENGTH_MASK); - - /* Fix ac timing on SPI in 6183, 6183L and 78x00 only */ - if ( (mvCtrlModelGet() == MV_6183_DEV_ID) || - (mvCtrlModelGet() == MV_6183L_DEV_ID) || - (mvCtrlModelGet() == MV_78100_DEV_ID) || - (mvCtrlModelGet() == MV_78200_DEV_ID) || - (mvCtrlModelGet() == MV_76100_DEV_ID)) - MV_REG_BIT_SET(MV_SPI_IF_CONFIG_REG, BIT14); - - /* Verify that the CS is deasserted */ - mvSpiCsDeassert(); - - return MV_OK; -} - -/******************************************************************************* -* mvSpiBaudRateSet - Set the Frequency of the SPI clock -* -* DESCRIPTION: -* Set the Prescale bits to adapt to the requested baud rate (the clock -* used for thr SPI). -* -* INPUT: -* serialBaudRate: Baud rate (SPI clock frequency) -* -* OUTPUT: -* None. -* -* RETURN: -* Success or Error code. -* -* -*******************************************************************************/ -MV_STATUS mvSpiBaudRateSet (MV_U32 serialBaudRate) -{ - MV_U8 i; - /* MV_U8 preScale[32] = {1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 2, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30}; - */ - MV_U8 preScale[14] = { 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30}; - MV_U8 bestPrescaleIndx = 100; - MV_U32 minBaudOffset = 0xFFFFFFFF; - MV_U32 cpuClk = mvBoardTclkGet(); /*mvCpuPclkGet();*/ - MV_U32 tempReg; - - /* Find the best prescale configuration - less or equal */ - for (i=0; i<14; i++) - { - /* check for higher - irrelevent */ - if ((cpuClk / preScale[i]) > serialBaudRate) - continue; - - /* check for exact fit */ - if ((cpuClk / preScale[i]) == serialBaudRate) - { - bestPrescaleIndx = i; - break; - } - - /* check if this is better than the previous one */ - if ((serialBaudRate - (cpuClk / preScale[i])) < minBaudOffset) - { - minBaudOffset = (serialBaudRate - (cpuClk / preScale[i])); - bestPrescaleIndx = i; - } - } - - if (bestPrescaleIndx > 14) - { - mvOsPrintf("%s ERROR: SPI baud rate prescale error!\n", __FUNCTION__); - return MV_OUT_OF_RANGE; - } - - /* configure the Prescale */ - tempReg = MV_REG_READ(MV_SPI_IF_CONFIG_REG); - tempReg = ((tempReg & ~MV_SPI_CLK_PRESCALE_MASK) | (bestPrescaleIndx + 0x12)); - MV_REG_WRITE(MV_SPI_IF_CONFIG_REG, tempReg); - - return MV_OK; -} - -/******************************************************************************* -* mvSpiCsAssert - Assert the Chip Select pin indicating a new transfer -* -* DESCRIPTION: -* Assert The chip select - used to select an external SPI device -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* Success or Error code. -* -********************************************************************************/ -MV_VOID mvSpiCsAssert(MV_VOID) -{ - /* For devices in which the SPI is muxed on the MPP with other interfaces*/ - mvMPPConfigToSPI(); - mvOsUDelay(1); - MV_REG_BIT_SET(MV_SPI_IF_CTRL_REG, MV_SPI_CS_ENABLE_MASK); -} - -/******************************************************************************* -* mvSpiCsDeassert - DeAssert the Chip Select pin indicating the end of a -* SPI transfer sequence -* -* DESCRIPTION: -* DeAssert the chip select pin -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* Success or Error code. -* -********************************************************************************/ -MV_VOID mvSpiCsDeassert(MV_VOID) -{ - MV_REG_BIT_RESET(MV_SPI_IF_CTRL_REG, MV_SPI_CS_ENABLE_MASK); - - /* For devices in which the SPI is muxed on the MPP with other interfaces*/ - mvMPPConfigToDefault(); -} - -/******************************************************************************* -* mvSpiRead - Read a buffer over the SPI interface -* -* DESCRIPTION: -* Receive (read) a buffer over the SPI interface in 16bit chunks. If the -* buffer size is odd, then the last chunk will be 8bits. Chip select is not -* handled at this level. -* -* INPUT: -* pRxBuff: Pointer to the buffer to hold the received data -* buffSize: length of the pRxBuff -* -* OUTPUT: -* pRxBuff: Pointer to the buffer with the received data -* -* RETURN: -* Success or Error code. -* -* -*******************************************************************************/ -MV_STATUS mvSpiRead (MV_U8* pRxBuff, MV_U32 buffSize) -{ - MV_STATUS ret; - MV_U32 bytesLeft = buffSize; - MV_U16* rxPtr = (MV_U16*)pRxBuff; - - /* check for null parameters */ - if (pRxBuff == NULL) - { - mvOsPrintf("%s ERROR: Null pointer parameter!\n", __FUNCTION__); - return MV_BAD_PARAM; - } - - /* Check that the buffer pointer and the buffer size are 16bit aligned */ - if ((((MV_U32)buffSize & 1) == 0) && (((MV_U32)pRxBuff & 1) == 0)) - { - /* Verify that the SPI mode is in 16bit mode */ - MV_REG_BIT_SET(MV_SPI_IF_CONFIG_REG, MV_SPI_BYTE_LENGTH_MASK); - - /* TX/RX as long we have complete 16bit chunks */ - while (bytesLeft >= MV_SPI_16_BIT_CHUNK_SIZE) - { - /* Transmitted and wait for the transfer to be completed */ - if ((ret = mvSpi16bitDataTxRx(MV_SPI_DUMMY_WRITE_16BITS, rxPtr)) != MV_OK) - return ret; - - /* increment the pointers */ - rxPtr++; - bytesLeft -= MV_SPI_16_BIT_CHUNK_SIZE; - } - - } - else - { - /* Verify that the SPI mode is in 8bit mode */ - MV_REG_BIT_RESET(MV_SPI_IF_CONFIG_REG, MV_SPI_BYTE_LENGTH_MASK); - - /* TX/RX in 8bit chanks */ - while (bytesLeft > 0) - { - /* Transmitted and wait for the transfer to be completed */ - if ((ret = mvSpi8bitDataTxRx(MV_SPI_DUMMY_WRITE_8BITS, pRxBuff)) != MV_OK) - return ret; - /* increment the pointers */ - pRxBuff++; - bytesLeft--; - } - } - - return MV_OK; -} - -/******************************************************************************* -* mvSpiWrite - Transmit a buffer over the SPI interface -* -* DESCRIPTION: -* Transmit a buffer over the SPI interface in 16bit chunks. If the -* buffer size is odd, then the last chunk will be 8bits. No chip select -* action is taken. -* -* INPUT: -* pTxBuff: Pointer to the buffer holding the TX data -* buffSize: length of the pTxBuff -* -* OUTPUT: -* None. -* -* RETURN: -* Success or Error code. -* -* -*******************************************************************************/ -MV_STATUS mvSpiWrite(MV_U8* pTxBuff, MV_U32 buffSize) -{ - MV_STATUS ret; - MV_U32 bytesLeft = buffSize; - MV_U16* txPtr = (MV_U16*)pTxBuff; - - /* check for null parameters */ - if (pTxBuff == NULL) - { - mvOsPrintf("%s ERROR: Null pointer parameter!\n", __FUNCTION__); - return MV_BAD_PARAM; - } - - /* Check that the buffer pointer and the buffer size are 16bit aligned */ - if ((((MV_U32)buffSize & 1) == 0) && (((MV_U32)pTxBuff & 1) == 0)) - { - /* Verify that the SPI mode is in 16bit mode */ - MV_REG_BIT_SET(MV_SPI_IF_CONFIG_REG, MV_SPI_BYTE_LENGTH_MASK); - - /* TX/RX as long we have complete 16bit chunks */ - while (bytesLeft >= MV_SPI_16_BIT_CHUNK_SIZE) - { - /* Transmitted and wait for the transfer to be completed */ - if ((ret = mvSpi16bitDataTxRx(*txPtr, NULL)) != MV_OK) - return ret; - - /* increment the pointers */ - txPtr++; - bytesLeft -= MV_SPI_16_BIT_CHUNK_SIZE; - } - } - else - { - - /* Verify that the SPI mode is in 8bit mode */ - MV_REG_BIT_RESET(MV_SPI_IF_CONFIG_REG, MV_SPI_BYTE_LENGTH_MASK); - - /* TX/RX in 8bit chanks */ - while (bytesLeft > 0) - { - /* Transmitted and wait for the transfer to be completed */ - if ((ret = mvSpi8bitDataTxRx(*pTxBuff, NULL)) != MV_OK) - return ret; - - /* increment the pointers */ - pTxBuff++; - bytesLeft--; - } - } - - return MV_OK; -} - - -/******************************************************************************* -* mvSpiReadWrite - Read and Write a buffer simultanuosely -* -* DESCRIPTION: -* Transmit and receive a buffer over the SPI in 16bit chunks. If the -* buffer size is odd, then the last chunk will be 8bits. The SPI chip -* select is not handled implicitely. -* -* INPUT: -* pRxBuff: Pointer to the buffer to write the RX info in -* pTxBuff: Pointer to the buffer holding the TX info -* buffSize: length of both the pTxBuff and pRxBuff -* -* OUTPUT: -* pRxBuff: Pointer of the buffer holding the RX data -* -* RETURN: -* Success or Error code. -* -* -*******************************************************************************/ -MV_STATUS mvSpiReadWrite(MV_U8* pRxBuff, MV_U8* pTxBuff, MV_U32 buffSize) -{ - MV_STATUS ret; - MV_U32 bytesLeft = buffSize; - MV_U16* txPtr = (MV_U16*)pTxBuff; - MV_U16* rxPtr = (MV_U16*)pRxBuff; - - /* check for null parameters */ - if ((pRxBuff == NULL) || (pTxBuff == NULL)) - { - mvOsPrintf("%s ERROR: Null pointer parameter!\n", __FUNCTION__); - return MV_BAD_PARAM; - } - - /* Check that the buffer pointer and the buffer size are 16bit aligned */ - if ((((MV_U32)buffSize & 1) == 0) && (((MV_U32)pTxBuff & 1) == 0) && (((MV_U32)pRxBuff & 1) == 0)) - { - /* Verify that the SPI mode is in 16bit mode */ - MV_REG_BIT_SET(MV_SPI_IF_CONFIG_REG, MV_SPI_BYTE_LENGTH_MASK); - - /* TX/RX as long we have complete 16bit chunks */ - while (bytesLeft >= MV_SPI_16_BIT_CHUNK_SIZE) - { - /* Transmitted and wait for the transfer to be completed */ - if ((ret = mvSpi16bitDataTxRx(*txPtr, rxPtr)) != MV_OK) - return ret; - - /* increment the pointers */ - txPtr++; - rxPtr++; - bytesLeft -= MV_SPI_16_BIT_CHUNK_SIZE; - } - } - else - { - /* Verify that the SPI mode is in 8bit mode */ - MV_REG_BIT_RESET(MV_SPI_IF_CONFIG_REG, MV_SPI_BYTE_LENGTH_MASK); - - /* TX/RX in 8bit chanks */ - while (bytesLeft > 0) - { - /* Transmitted and wait for the transfer to be completed */ - if ( (ret = mvSpi8bitDataTxRx(*pTxBuff, pRxBuff) ) != MV_OK) - return ret; - pRxBuff++; - pTxBuff++; - bytesLeft--; - } - } - - return MV_OK; -} - - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/spi/mvSpi.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/spi/mvSpi.h deleted file mode 100644 index 74859f0..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/spi/mvSpi.h +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCmvSpihH -#define __INCmvSpihH - -#include "mvCommon.h" -#include "mvOs.h" -#include "ctrlEnv/mvCtrlEnvSpec.h" - -/* Function Prototypes */ -/* Init */ -MV_STATUS mvSpiInit (MV_U32 serialBaudRate); - -/* Set the Frequency of the Spi clock */ -MV_STATUS mvSpiBaudRateSet(MV_U32 serialBaudRate); - -/* Assert the SPI chip select */ -MV_VOID mvSpiCsAssert (MV_VOID); - -/* De-assert the SPI chip select */ -MV_VOID mvSpiCsDeassert (MV_VOID); - -/* Simultanuous Read and write */ -MV_STATUS mvSpiReadWrite (MV_U8* pRxBuff, MV_U8* pTxBuff, MV_U32 buffSize); - -/* serialize a buffer on the TX line - Rx is ignored */ -MV_STATUS mvSpiWrite (MV_U8* pTxBuff, MV_U32 buffSize); - -/* read from the RX line by writing dummy values to the TX line */ -MV_STATUS mvSpiRead (MV_U8* pRxBuff, MV_U32 buffSize); - -#endif /* __INCmvSpihH */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/spi/mvSpiCmnd.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/spi/mvSpiCmnd.c deleted file mode 100644 index a5d5a64..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/spi/mvSpiCmnd.c +++ /dev/null @@ -1,249 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#include "spi/mvSpi.h" -#include "spi/mvSpiSpec.h" - -/*#define MV_DEBUG*/ -#ifdef MV_DEBUG -#define DB(x) x -#else -#define DB(x) -#endif - - -/******************************************************************************* -* mvSpiReadAndWrite - Read and Write a buffer simultanuousely -* -* DESCRIPTION: -* Transmit and receive a buffer over the SPI in 16bit chunks. If the -* buffer size is odd, then the last chunk will be 8bits. -* -* INPUT: -* pRxBuff: Pointer to the buffer to write the RX info in -* pTxBuff: Pointer to the buffer holding the TX info -* buffSize: length of both the pTxBuff and pRxBuff -* -* OUTPUT: -* pRxBuff: Pointer of the buffer holding the RX data -* -* RETURN: -* Success or Error code. -* -* -*******************************************************************************/ -MV_STATUS mvSpiReadAndWrite(MV_U8* pRxBuff, MV_U8* pTxBuff, MV_U32 buffSize) -{ - MV_STATUS ret; - - /* check for null parameters */ - if ((pRxBuff == NULL) || (pTxBuff == NULL) || (buffSize == 0)) - { - mvOsPrintf("%s ERROR: Null pointer parameter!\n", __FUNCTION__); - return MV_BAD_PARAM; - } - - /* First assert the chip select */ - mvSpiCsAssert(); - - ret = mvSpiReadWrite(pRxBuff, pTxBuff, buffSize); - - /* Finally deassert the chip select */ - mvSpiCsDeassert(); - - return ret; -} - -/******************************************************************************* -* mvSpiWriteThenWrite - Serialize a command followed by the data over the TX line -* -* DESCRIPTION: -* Assert the chip select line. Transmit the command buffer followed by -* the data buffer. Then deassert the CS line. -* -* INPUT: -* pCmndBuff: Pointer to the command buffer to transmit -* cmndSize: length of the command size -* pTxDataBuff: Pointer to the data buffer to transmit -* txDataSize: length of the data buffer -* -* OUTPUT: -* None. -* -* RETURN: -* Success or Error code. -* -* -*******************************************************************************/ -MV_STATUS mvSpiWriteThenWrite (MV_U8* pCmndBuff, MV_U32 cmndSize, MV_U8* pTxDataBuff, - MV_U32 txDataSize) -{ - MV_STATUS ret = MV_OK, tempRet; - - /* check for null parameters */ -#ifndef CONFIG_MARVELL - if(NULL == pTxDataBuff) - { - mvOsPrintf("%s ERROR: Null pointer parameter!\n", __FUNCTION__); - return MV_BAD_PARAM; - } -#endif - - if (pCmndBuff == NULL) - { - mvOsPrintf("%s ERROR: Null pointer parameter!\n", __FUNCTION__); - return MV_BAD_PARAM; - } - - /* First assert the chip select */ - mvSpiCsAssert(); - - /* first write the command */ - if ((cmndSize) && (pCmndBuff != NULL)) - { - if ((tempRet = mvSpiWrite(pCmndBuff, cmndSize)) != MV_OK) - ret = tempRet; - } - - /* Then write the data buffer */ -#ifndef CONFIG_MARVELL - if (txDataSize) -#else - if ((txDataSize) && (pTxDataBuff != NULL)) -#endif - { - if ((tempRet = mvSpiWrite(pTxDataBuff, txDataSize)) != MV_OK) - ret = tempRet; - } - - /* Finally deassert the chip select */ - mvSpiCsDeassert(); - - return ret; -} - -/******************************************************************************* -* mvSpiWriteThenRead - Serialize a command then read a data buffer -* -* DESCRIPTION: -* Assert the chip select line. Transmit the command buffer then read -* the data buffer. Then deassert the CS line. -* -* INPUT: -* pCmndBuff: Pointer to the command buffer to transmit -* cmndSize: length of the command size -* pRxDataBuff: Pointer to the buffer to read the data in -* txDataSize: length of the data buffer -* -* OUTPUT: -* pRxDataBuff: Pointer to the buffer holding the data -* -* RETURN: -* Success or Error code. -* -* -*******************************************************************************/ -MV_STATUS mvSpiWriteThenRead (MV_U8* pCmndBuff, MV_U32 cmndSize, MV_U8* pRxDataBuff, - MV_U32 rxDataSize,MV_U32 dummyBytesToRead) -{ - MV_STATUS ret = MV_OK, tempRet; - MV_U8 dummyByte; - - /* check for null parameters */ - if ((pCmndBuff == NULL) && (pRxDataBuff == NULL)) - { - mvOsPrintf("%s ERROR: Null pointer parameter!\n", __FUNCTION__); - return MV_BAD_PARAM; - } - - /* First assert the chip select */ - mvSpiCsAssert(); - - /* first write the command */ - if ((cmndSize) && (pCmndBuff != NULL)) - { - if ((tempRet = mvSpiWrite(pCmndBuff, cmndSize)) != MV_OK) - ret = tempRet; - } - - /* Read dummy bytes before real data. */ - while(dummyBytesToRead) - { - mvSpiRead(&dummyByte,1); - dummyBytesToRead--; - } - - /* Then write the data buffer */ - if ((rxDataSize) && (pRxDataBuff != NULL)) - { - if ((tempRet = mvSpiRead(pRxDataBuff, rxDataSize)) != MV_OK) - ret = tempRet; - } - - /* Finally deassert the chip select */ - mvSpiCsDeassert(); - - return ret; -} - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/spi/mvSpiCmnd.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/spi/mvSpiCmnd.h deleted file mode 100644 index 329e26b..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/spi/mvSpiCmnd.h +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCmvSpiCmndhH -#define __INCmvSpiCmndhH - -#include "mvTypes.h" - -/* Function Prototypes */ - -/* Simultanuous Read and write */ -MV_STATUS mvSpiReadAndWrite (MV_U8* pRxBuff, MV_U8* pTxBuff, MV_U32 buffSize); - -/* write command - write a command and then write data */ -MV_STATUS mvSpiWriteThenWrite (MV_U8* pCmndBuff, MV_U32 cmndSize, MV_U8* pTxDataBuff, MV_U32 txDataSize); - -/* read command - write a command and then read data by writing dummy data */ -MV_STATUS mvSpiWriteThenRead (MV_U8* pCmndBuff, MV_U32 cmndSize, MV_U8* pRxDataBuff, - MV_U32 rxDataSize,MV_U32 dummyBytesToRead); - -#endif /* __INCmvSpiCmndhH */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/spi/mvSpiSpec.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/spi/mvSpiSpec.h deleted file mode 100644 index 658159a..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/spi/mvSpiSpec.h +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - -#ifndef __INCmvSpiSpecH -#define __INCmvSpiSpecH - -/* Constants */ -#define MV_SPI_WAIT_RDY_MAX_LOOP 100000 -#define MV_SPI_16_BIT_CHUNK_SIZE 2 -#define MV_SPI_DUMMY_WRITE_16BITS 0xFFFF -#define MV_SPI_DUMMY_WRITE_8BITS 0xFF - -/* Marvell Flash Device Controller Registers */ -#define MV_SPI_CTRLR_OFST 0x10600 -#define MV_SPI_IF_CTRL_REG (MV_SPI_CTRLR_OFST + 0x00) -#define MV_SPI_IF_CONFIG_REG (MV_SPI_CTRLR_OFST + 0x04) -#define MV_SPI_DATA_OUT_REG (MV_SPI_CTRLR_OFST + 0x08) -#define MV_SPI_DATA_IN_REG (MV_SPI_CTRLR_OFST + 0x0c) -#define MV_SPI_INT_CAUSE_REG (MV_SPI_CTRLR_OFST + 0x10) -#define MV_SPI_INT_CAUSE_MASK_REG (MV_SPI_CTRLR_OFST + 0x14) - -/* Serial Memory Interface Control Register Masks */ -#define MV_SPI_CS_ENABLE_OFFSET 0 /* bit 0 */ -#define MV_SPI_MEMORY_READY_OFFSET 1 /* bit 1 */ -#define MV_SPI_CS_ENABLE_MASK (0x1 << MV_SPI_CS_ENABLE_OFFSET) -#define MV_SPI_MEMORY_READY_MASK (0x1 << MV_SPI_MEMORY_READY_OFFSET) - -/* Serial Memory Interface Configuration Register Masks */ -#define MV_SPI_CLK_PRESCALE_OFFSET 0 /* bit 0-4 */ -#define MV_SPI_BYTE_LENGTH_OFFSET 5 /* bit 5 */ -#define MV_SPI_ADDRESS_BURST_LENGTH_OFFSET 8 /* bit 8-9 */ -#define MV_SPI_CLK_PRESCALE_MASK (0x1F << MV_SPI_CLK_PRESCALE_OFFSET) -#define MV_SPI_BYTE_LENGTH_MASK (0x1 << MV_SPI_BYTE_LENGTH_OFFSET) -#define MV_SPI_ADDRESS_BURST_LENGTH_MASK (0x3 << MV_SPI_ADDRESS_BURST_LENGTH_OFFSET) - -#endif /* __INCmvSpiSpecH */ - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/twsi/mvTwsi.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/twsi/mvTwsi.c deleted file mode 100644 index 0bf8b75..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/twsi/mvTwsi.c +++ /dev/null @@ -1,1023 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -#include "mvTwsi.h" -#include "mvTwsiSpec.h" -#include "cpu/mvCpu.h" - - -/*#define MV_DEBUG*/ -#ifdef MV_DEBUG -#define DB(x) x -#else -#define DB(x) -#endif - -static MV_VOID twsiIntFlgClr(MV_U8 chanNum); -static MV_BOOL twsiMainIntGet(MV_U8 chanNum); -static MV_VOID twsiAckBitSet(MV_U8 chanNum); -static MV_U32 twsiStsGet(MV_U8 chanNum); -static MV_VOID twsiReset(MV_U8 chanNum); -static MV_STATUS twsiAddr7BitSet(MV_U8 chanNum, MV_U32 deviceAddress,MV_TWSI_CMD command); -static MV_STATUS twsiAddr10BitSet(MV_U8 chanNum, MV_U32 deviceAddress,MV_TWSI_CMD command); -static MV_STATUS twsiDataTransmit(MV_U8 chanNum, MV_U8 *pBlock, MV_U32 blockSize); -static MV_STATUS twsiDataReceive(MV_U8 chanNum, MV_U8 *pBlock, MV_U32 blockSize); -static MV_STATUS twsiTargetOffsSet(MV_U8 chanNum, MV_U32 offset,MV_BOOL moreThen256); - - -static MV_BOOL twsiTimeoutChk(MV_U32 timeout, const MV_8 *pString) -{ - if(timeout >= TWSI_TIMEOUT_VALUE) - { - DB(mvOsPrintf("%s",pString)); - return MV_TRUE; - } - return MV_FALSE; - -} -/******************************************************************************* -* mvTwsiStartBitSet - Set start bit on the bus -* -* DESCRIPTION: -* This routine sets the start bit on the TWSI bus. -* The routine first checks for interrupt flag condition, then it sets -* the start bit in the TWSI Control register. -* If the interrupt flag condition check previously was set, the function -* will clear it. -* The function then wait for the start bit to be cleared by the HW. -* Then it waits for the interrupt flag to be set and eventually, the -* TWSI status is checked to be 0x8 or 0x10(repeated start bit). -* -* INPUT: -* chanNum - TWSI channel. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_OK is start bit was set successfuly on the bus. -* MV_FAIL if interrupt flag was set before setting start bit. -* -*******************************************************************************/ -MV_STATUS mvTwsiStartBitSet(MV_U8 chanNum) -{ - MV_BOOL isIntFlag = MV_FALSE; - MV_U32 timeout, temp; - - DB(mvOsPrintf("TWSI: mvTwsiStartBitSet \n")); - /* check Int flag */ - if(twsiMainIntGet(chanNum)) - isIntFlag = MV_TRUE; - /* set start Bit */ - temp = MV_REG_READ(TWSI_CONTROL_REG(chanNum)); - MV_REG_WRITE(TWSI_CONTROL_REG(chanNum), temp | TWSI_CONTROL_START_BIT); - - /* in case that the int flag was set before i.e. repeated start bit */ - if(isIntFlag){ - DB(mvOsPrintf("TWSI: mvTwsiStartBitSet repeated start Bit\n")); - twsiIntFlgClr(chanNum); - } - - /* wait for interrupt */ - timeout = 0; - while(!twsiMainIntGet(chanNum) && (timeout++ < TWSI_TIMEOUT_VALUE)); - - /* check for timeout */ - if(MV_TRUE == twsiTimeoutChk(timeout,"TWSI: mvTwsiStartBitSet ERROR - Start Clear bit TimeOut .\n")) - return MV_TIMEOUT; - - - /* check that start bit went down */ - if((MV_REG_READ(TWSI_CONTROL_REG(chanNum)) & TWSI_CONTROL_START_BIT) != 0) - { - mvOsPrintf("TWSI: mvTwsiStartBitSet ERROR - start bit didn't went down\n"); - return MV_FAIL; - } - - /* check the status */ - temp = twsiStsGet(chanNum); - if(( temp != TWSI_START_CON_TRA ) && ( temp != TWSI_REPEATED_START_CON_TRA )) - { - mvOsPrintf("TWSI: mvTwsiStartBitSet ERROR - status %x after Set Start Bit. \n",temp); - return MV_FAIL; - } - - return MV_OK; - -} - -/******************************************************************************* -* mvTwsiStopBitSet - Set stop bit on the bus -* -* DESCRIPTION: -* This routine set the stop bit on the TWSI bus. -* The function then wait for the stop bit to be cleared by the HW. -* Finally the function checks for status of 0xF8. -* -* INPUT: -* chanNum - TWSI channel -* -* OUTPUT: -* None. -* -* RETURN: -* MV_TRUE is stop bit was set successfuly on the bus. -* -*******************************************************************************/ -MV_STATUS mvTwsiStopBitSet(MV_U8 chanNum) -{ - MV_U32 timeout, temp; - - /* Generate stop bit */ - temp = MV_REG_READ(TWSI_CONTROL_REG(chanNum)); - MV_REG_WRITE(TWSI_CONTROL_REG(chanNum), temp | TWSI_CONTROL_STOP_BIT); - - twsiIntFlgClr(chanNum); - - /* wait for stop bit to come down */ - timeout = 0; - while( ((MV_REG_READ(TWSI_CONTROL_REG(chanNum)) & TWSI_CONTROL_STOP_BIT) != 0) && (timeout++ < TWSI_TIMEOUT_VALUE)); - - /* check for timeout */ - if(MV_TRUE == twsiTimeoutChk(timeout,"TWSI: mvTwsiStopBitSet ERROR - Stop bit TimeOut .\n")) - return MV_TIMEOUT; - - /* check that the stop bit went down */ - if((MV_REG_READ(TWSI_CONTROL_REG(chanNum)) & TWSI_CONTROL_STOP_BIT) != 0) - { - mvOsPrintf("TWSI: mvTwsiStopBitSet ERROR - stop bit didn't went down. \n"); - return MV_FAIL; - } - - /* check the status */ - temp = twsiStsGet(chanNum); - if( temp != TWSI_NO_REL_STS_INT_FLAG_IS_KEPT_0){ - mvOsPrintf("TWSI: mvTwsiStopBitSet ERROR - status %x after Stop Bit. \n", temp); - return MV_FAIL; - } - - return MV_OK; -} - -/******************************************************************************* -* twsiMainIntGet - Get twsi bit from main Interrupt cause. -* -* DESCRIPTION: -* This routine returns the twsi interrupt flag value. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_TRUE is interrupt flag is set, MV_FALSE otherwise. -* -*******************************************************************************/ -static MV_BOOL twsiMainIntGet(MV_U8 chanNum) -{ - MV_U32 temp; - - /* get the int flag bit */ - - temp = MV_REG_READ(TWSI_CPU_MAIN_INT_CAUSE_REG); - if (temp & (TWSI0_CPU_MAIN_INT_BIT << chanNum)) - return MV_TRUE; - - return MV_FALSE; -} -/******************************************************************************* -* twsiIntFlgClr - Clear Interrupt flag. -* -* DESCRIPTION: -* This routine clears the interrupt flag. It does NOT poll the interrupt -* to make sure the clear. After clearing the interrupt, it waits for at -* least 1 miliseconds. -* -* INPUT: -* chanNum - TWSI channel -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -static MV_VOID twsiIntFlgClr(MV_U8 chanNum) -{ - MV_U32 temp; - - /* wait for 1 mili to prevent TWSI register write after write problems */ - mvOsDelay(1); - /* clear the int flag bit */ - temp = MV_REG_READ(TWSI_CONTROL_REG(chanNum)); - MV_REG_WRITE(TWSI_CONTROL_REG(chanNum),temp & ~(TWSI_CONTROL_INT_FLAG_SET)); - - /* wait for 1 mili sec for the clear to take effect */ - mvOsDelay(1); - - return; -} - - -/******************************************************************************* -* twsiAckBitSet - Set acknowledge bit on the bus -* -* DESCRIPTION: -* This routine set the acknowledge bit on the TWSI bus. -* -* INPUT: -* None. -* -* OUTPUT: -* None. -* -* RETURN: -* None. -* -*******************************************************************************/ -static MV_VOID twsiAckBitSet(MV_U8 chanNum) -{ - MV_U32 temp; - - /*Set the Ack bit */ - temp = MV_REG_READ(TWSI_CONTROL_REG(chanNum)); - MV_REG_WRITE(TWSI_CONTROL_REG(chanNum), temp | TWSI_CONTROL_ACK); - - /* Add delay of 1ms */ - mvOsDelay(1); - return; -} - - -/******************************************************************************* -* twsiInit - Initialize TWSI interface -* -* DESCRIPTION: -* This routine: -* -Reset the TWSI. -* -Initialize the TWSI clock baud rate according to given frequancy -* parameter based on Tclk frequancy and enables TWSI slave. -* -Set the ack bit. -* -Assign the TWSI slave address according to the TWSI address Type. -* -* -* INPUT: -* chanNum - TWSI channel -* frequancy - TWSI frequancy in KHz. (up to 100KHZ) -* -* OUTPUT: -* None. -* -* RETURN: -* Actual frequancy. -* -*******************************************************************************/ -MV_U32 mvTwsiInit(MV_U8 chanNum, MV_HZ frequancy, MV_U32 Tclk, MV_TWSI_ADDR *pTwsiAddr, MV_BOOL generalCallEnable) -{ - MV_U32 n,m,freq,margin,minMargin = 0xffffffff; - MV_U32 power; - MV_U32 actualFreq = 0,actualN = 0,actualM = 0,val; - - if(frequancy > 100000) - { - mvOsPrintf("Warning TWSI frequancy is too high, please use up tp 100Khz. \n"); - } - - DB(mvOsPrintf("TWSI: mvTwsiInit - Tclk = %d freq = %d\n",Tclk,frequancy)); - /* Calucalte N and M for the TWSI clock baud rate */ - for(n = 0 ; n < 8 ; n++) - { - for(m = 0 ; m < 16 ; m++) - { - power = 2 << n; /* power = 2^(n+1) */ - freq = Tclk/(10*(m+1)*power); - margin = MV_ABS(frequancy - freq); - if(margin < minMargin) - { - minMargin = margin; - actualFreq = freq; - actualN = n; - actualM = m; - } - } - } - DB(mvOsPrintf("TWSI: mvTwsiInit - actN %d actM %d actFreq %d\n",actualN , actualM, actualFreq)); - /* Reset the TWSI logic */ - twsiReset(chanNum); - - /* Set the baud rate */ - val = ((actualM<< TWSI_BAUD_RATE_M_OFFS) | actualN << TWSI_BAUD_RATE_N_OFFS); - MV_REG_WRITE(TWSI_STATUS_BAUDE_RATE_REG(chanNum),val); - - /* Enable the TWSI and slave */ - MV_REG_WRITE(TWSI_CONTROL_REG(chanNum), TWSI_CONTROL_ENA | TWSI_CONTROL_ACK); - - /* set the TWSI slave address */ - if( pTwsiAddr->type == ADDR10_BIT )/* 10 Bit deviceAddress */ - { - /* writing the 2 most significant bits of the 10 bit address*/ - val = ((pTwsiAddr->address & TWSI_SLAVE_ADDR_10BIT_MASK) >> TWSI_SLAVE_ADDR_10BIT_OFFS ); - /* bits 7:3 must be 0x11110 */ - val |= TWSI_SLAVE_ADDR_10BIT_CONST; - /* set GCE bit */ - if(generalCallEnable) - val |= TWSI_SLAVE_ADDR_GCE_ENA; - /* write slave address */ - MV_REG_WRITE(TWSI_SLAVE_ADDR_REG(chanNum),val); - - /* writing the 8 least significant bits of the 10 bit address*/ - val = (pTwsiAddr->address << TWSI_EXTENDED_SLAVE_OFFS) & TWSI_EXTENDED_SLAVE_MASK; - MV_REG_WRITE(TWSI_EXTENDED_SLAVE_ADDR_REG(chanNum), val); - } - else /*7 bit address*/ - { - /* set the 7 Bits address */ - MV_REG_WRITE(TWSI_EXTENDED_SLAVE_ADDR_REG(chanNum),0x0); - val = (pTwsiAddr->address << TWSI_SLAVE_ADDR_7BIT_OFFS) & TWSI_SLAVE_ADDR_7BIT_MASK; - MV_REG_WRITE(TWSI_SLAVE_ADDR_REG(chanNum), val); - } - - /* unmask twsi int */ - val = MV_REG_READ(TWSI_CONTROL_REG(chanNum)); - MV_REG_WRITE(TWSI_CONTROL_REG(chanNum), val | TWSI_CONTROL_INT_ENA); - /* Add delay of 1ms */ - mvOsDelay(1); - - return actualFreq; -} - - -/******************************************************************************* -* twsiStsGet - Get the TWSI status value. -* -* DESCRIPTION: -* This routine returns the TWSI status value. -* -* INPUT: -* chanNum - TWSI channel -* -* OUTPUT: -* None. -* -* RETURN: -* MV_U32 - the TWSI status. -* -*******************************************************************************/ -static MV_U32 twsiStsGet(MV_U8 chanNum) -{ - return MV_REG_READ(TWSI_STATUS_BAUDE_RATE_REG(chanNum)); - -} - -/******************************************************************************* -* twsiReset - Reset the TWSI. -* -* DESCRIPTION: -* Resets the TWSI logic and sets all TWSI registers to their reset values. -* -* INPUT: -* chanNum - TWSI channel -* -* OUTPUT: -* None. -* -* RETURN: -* None -* -*******************************************************************************/ -static MV_VOID twsiReset(MV_U8 chanNum) -{ - /* Reset the TWSI logic */ - MV_REG_WRITE(TWSI_SOFT_RESET_REG(chanNum),0); - - /* wait for 2 mili sec */ - mvOsDelay(2); - - return; -} - - - - -/******************************* POLICY ****************************************/ - - - -/******************************************************************************* -* mvTwsiAddrSet - Set address on TWSI bus. -* -* DESCRIPTION: -* This function Set address (7 or 10 Bit address) on the Twsi Bus. -* -* INPUT: -* chanNum - TWSI channel -* pTwsiAddr - twsi address. -* command - read / write . -* -* OUTPUT: -* None. -* -* RETURN: -* MV_OK - if setting the address completed succesfully. -* MV_FAIL otherwmise. -* -*******************************************************************************/ -MV_STATUS mvTwsiAddrSet(MV_U8 chanNum, MV_TWSI_ADDR *pTwsiAddr, MV_TWSI_CMD command) -{ - DB(mvOsPrintf("TWSI: mvTwsiAddr7BitSet addr %x , type %d, cmd is %s\n",pTwsiAddr->address,\ - pTwsiAddr->type, ((command==MV_TWSI_WRITE)?"Write":"Read") )); - /* 10 Bit address */ - if(pTwsiAddr->type == ADDR10_BIT) - { - return twsiAddr10BitSet(chanNum, pTwsiAddr->address,command); - } - /* 7 Bit address */ - else - { - return twsiAddr7BitSet(chanNum, pTwsiAddr->address,command); - } - -} - -/******************************************************************************* -* twsiAddr10BitSet - Set 10 Bit address on TWSI bus. -* -* DESCRIPTION: -* There are two address phases: -* 1) Write '11110' to data register bits [7:3] and 10-bit address MSB -* (bits [9:8]) to data register bits [2:1] plus a write(0) or read(1) bit -* to the Data register. Then it clears interrupt flag which drive -* the address on the TWSI bus. The function then waits for interrupt -* flag to be active and status 0x18 (write) or 0x40 (read) to be set. -* 2) write the rest of 10-bit address to data register and clears -* interrupt flag which drive the address on the TWSI bus. The -* function then waits for interrupt flag to be active and status -* 0xD0 (write) or 0xE0 (read) to be set. -* -* INPUT: -* chanNum - TWSI channel -* deviceAddress - twsi address. -* command - read / write . -* -* OUTPUT: -* None. -* -* RETURN: -* MV_OK - if setting the address completed succesfully. -* MV_FAIL otherwmise. -* -*******************************************************************************/ -static MV_STATUS twsiAddr10BitSet(MV_U8 chanNum, MV_U32 deviceAddress,MV_TWSI_CMD command) -{ - MV_U32 val,timeout; - - /* writing the 2 most significant bits of the 10 bit address*/ - val = ((deviceAddress & TWSI_DATA_ADDR_10BIT_MASK) >> TWSI_DATA_ADDR_10BIT_OFFS ); - /* bits 7:3 must be 0x11110 */ - val |= TWSI_DATA_ADDR_10BIT_CONST; - /* set command */ - val |= command; - MV_REG_WRITE(TWSI_DATA_REG(chanNum), val); - /* WA add a delay */ - mvOsDelay(1); - - /* clear Int flag */ - twsiIntFlgClr(chanNum); - - /* wait for Int to be Set */ - timeout = 0; - while( !twsiMainIntGet(chanNum) && (timeout++ < TWSI_TIMEOUT_VALUE)); - - /* check for timeout */ - if(MV_TRUE == twsiTimeoutChk(timeout,"TWSI: twsiAddr10BitSet ERROR - 1st addr (10Bit) Int TimeOut.\n")) - return MV_TIMEOUT; - - /* check the status */ - val = twsiStsGet(chanNum); - if(( (val != TWSI_AD_PLS_RD_BIT_TRA_ACK_REC) && (command == MV_TWSI_READ ) ) || - ( (val != TWSI_AD_PLS_WR_BIT_TRA_ACK_REC) && (command == MV_TWSI_WRITE) )) - { - mvOsPrintf("TWSI: twsiAddr10BitSet ERROR - status %x 1st addr (10 Bit) in %s mode.\n"\ - ,val, ((command==MV_TWSI_WRITE)?"Write":"Read") ); - return MV_FAIL; - } - - /* set 8 LSB of the address */ - val = (deviceAddress << TWSI_DATA_ADDR_7BIT_OFFS) & TWSI_DATA_ADDR_7BIT_MASK; - MV_REG_WRITE(TWSI_DATA_REG(chanNum), val); - - /* clear Int flag */ - twsiIntFlgClr(chanNum); - - /* wait for Int to be Set */ - timeout = 0; - while( !twsiMainIntGet(chanNum) && (timeout++ < TWSI_TIMEOUT_VALUE)); - - /* check for timeout */ - if(MV_TRUE == twsiTimeoutChk(timeout,"TWSI: twsiAddr10BitSet ERROR - 2nd (10 Bit) Int TimOut.\n")) - return MV_TIMEOUT; - - /* check the status */ - val = twsiStsGet(chanNum); - if(( (val != TWSI_SEC_AD_PLS_RD_BIT_TRA_ACK_REC) && (command == MV_TWSI_READ ) ) || - ( (val != TWSI_SEC_AD_PLS_WR_BIT_TRA_ACK_REC) && (command == MV_TWSI_WRITE) )) - { - mvOsPrintf("TWSI: twsiAddr10BitSet ERROR - status %x 2nd addr(10 Bit) in %s mode.\n"\ - ,val, ((command==MV_TWSI_WRITE)?"Write":"Read") ); - return MV_FAIL; - } - - return MV_OK; -} - -/******************************************************************************* -* twsiAddr7BitSet - Set 7 Bit address on TWSI bus. -* -* DESCRIPTION: -* This function writes 7 bit address plus a write or read bit to the -* Data register. Then it clears interrupt flag which drive the address on -* the TWSI bus. The function then waits for interrupt flag to be active -* and status 0x18 (write) or 0x40 (read) to be set. -* -* INPUT: -* chanNum - TWSI channel -* deviceAddress - twsi address. -* command - read / write . -* -* OUTPUT: -* None. -* -* RETURN: -* MV_OK - if setting the address completed succesfully. -* MV_FAIL otherwmise. -* -*******************************************************************************/ -static MV_STATUS twsiAddr7BitSet(MV_U8 chanNum, MV_U32 deviceAddress,MV_TWSI_CMD command) -{ - MV_U32 val,timeout; - - /* set the address */ - val = (deviceAddress << TWSI_DATA_ADDR_7BIT_OFFS) & TWSI_DATA_ADDR_7BIT_MASK; - /* set command */ - val |= command; - MV_REG_WRITE(TWSI_DATA_REG(chanNum), val); - /* WA add a delay */ - mvOsDelay(1); - - /* clear Int flag */ - twsiIntFlgClr(chanNum); - - /* wait for Int to be Set */ - timeout = 0; - while( !twsiMainIntGet(chanNum) && (timeout++ < TWSI_TIMEOUT_VALUE)); - - /* check for timeout */ - if(MV_TRUE == twsiTimeoutChk(timeout,"TWSI: twsiAddr7BitSet ERROR - Addr (7 Bit) int TimeOut.\n")) - return MV_TIMEOUT; - - /* check the status */ - val = twsiStsGet(chanNum); - if(( (val != TWSI_AD_PLS_RD_BIT_TRA_ACK_REC) && (command == MV_TWSI_READ ) ) || - ( (val != TWSI_AD_PLS_WR_BIT_TRA_ACK_REC) && (command == MV_TWSI_WRITE) )) - { - /* only in debug, since in boot we try to read the SPD of both DRAM, and we don't - want error messeges in case DIMM doesn't exist. */ - DB(mvOsPrintf("TWSI: twsiAddr7BitSet ERROR - status %x addr (7 Bit) in %s mode.\n"\ - ,val,((command==MV_TWSI_WRITE)?"Write":"Read") )); - return MV_FAIL; - } - - return MV_OK; -} - -/******************************************************************************* -* twsiDataWrite - Trnasmit a data block over TWSI bus. -* -* DESCRIPTION: -* This function writes a given data block to TWSI bus in 8 bit granularity. -* first The function waits for interrupt flag to be active then -* For each 8-bit data: -* The function writes data to data register. It then clears -* interrupt flag which drives the data on the TWSI bus. -* The function then waits for interrupt flag to be active and status -* 0x28 to be set. -* -* -* INPUT: -* chanNum - TWSI channel -* pBlock - Data block. -* blockSize - number of chars in pBlock. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_OK - if transmiting the block completed succesfully, -* MV_BAD_PARAM - if pBlock is NULL, -* MV_FAIL otherwmise. -* -*******************************************************************************/ -static MV_STATUS twsiDataTransmit(MV_U8 chanNum, MV_U8 *pBlock, MV_U32 blockSize) -{ - MV_U32 timeout, temp, blockSizeWr = blockSize; - - if(NULL == pBlock) - return MV_BAD_PARAM; - - /* wait for Int to be Set */ - timeout = 0; - while( !twsiMainIntGet(chanNum) && (timeout++ < TWSI_TIMEOUT_VALUE)); - - /* check for timeout */ - if(MV_TRUE == twsiTimeoutChk(timeout,"TWSI: twsiDataTransmit ERROR - Read Data Int TimeOut.\n")) - return MV_TIMEOUT; - - while(blockSizeWr) - { - /* write the data*/ - MV_REG_WRITE(TWSI_DATA_REG(chanNum),(MV_U32)*pBlock); - DB(mvOsPrintf("TWSI: twsiDataTransmit place = %d write %x \n",\ - blockSize - blockSizeWr, *pBlock)); - pBlock++; - blockSizeWr--; - - twsiIntFlgClr(chanNum); - - /* wait for Int to be Set */ - timeout = 0; - while( !twsiMainIntGet(chanNum) && (timeout++ < TWSI_TIMEOUT_VALUE)); - - /* check for timeout */ - if(MV_TRUE == twsiTimeoutChk(timeout,"TWSI: twsiDataTransmit ERROR - Read Data Int TimeOut.\n")) - return MV_TIMEOUT; - - /* check the status */ - temp = twsiStsGet(chanNum); - if(temp != TWSI_M_TRAN_DATA_BYTE_ACK_REC) - { - mvOsPrintf("TWSI: twsiDataTransmit ERROR - status %x in write trans\n",temp); - return MV_FAIL; - } - - } - - return MV_OK; -} - -/******************************************************************************* -* twsiDataReceive - Receive data block from TWSI bus. -* -* DESCRIPTION: -* This function receive data block from TWSI bus in 8bit granularity -* into pBlock buffer. -* first The function waits for interrupt flag to be active then -* For each 8-bit data: -* It clears the interrupt flag which allows the next data to be -* received from TWSI bus. -* The function waits for interrupt flag to be active, -* and status reg is 0x50. -* Then the function reads data from data register, and copies it to -* the given buffer. -* -* INPUT: -* chanNum - TWSI channel -* blockSize - number of bytes to read. -* -* OUTPUT: -* pBlock - Data block. -* -* RETURN: -* MV_OK - if receive transaction completed succesfully, -* MV_BAD_PARAM - if pBlock is NULL, -* MV_FAIL otherwmise. -* -*******************************************************************************/ -static MV_STATUS twsiDataReceive(MV_U8 chanNum, MV_U8 *pBlock, MV_U32 blockSize) -{ - MV_U32 timeout, temp, blockSizeRd = blockSize; - if(NULL == pBlock) - return MV_BAD_PARAM; - - /* wait for Int to be Set */ - timeout = 0; - while( !twsiMainIntGet(chanNum) && (timeout++ < TWSI_TIMEOUT_VALUE)); - - /* check for timeout */ - if(MV_TRUE == twsiTimeoutChk(timeout,"TWSI: twsiDataReceive ERROR - Read Data int Time out .\n")) - return MV_TIMEOUT; - - while(blockSizeRd) - { - if(blockSizeRd == 1) - { - /* clear ack and Int flag */ - temp = MV_REG_READ(TWSI_CONTROL_REG(chanNum)); - temp &= ~(TWSI_CONTROL_ACK); - MV_REG_WRITE(TWSI_CONTROL_REG(chanNum), temp); - } - twsiIntFlgClr(chanNum); - /* wait for Int to be Set */ - timeout = 0; - while( (!twsiMainIntGet(chanNum)) && (timeout++ < TWSI_TIMEOUT_VALUE)); - - /* check for timeout */ - if(MV_TRUE == twsiTimeoutChk(timeout,"TWSI: twsiDataReceive ERROR - Read Data Int Time out .\n")) - return MV_TIMEOUT; - - /* check the status */ - temp = twsiStsGet(chanNum); - if((temp != TWSI_M_REC_RD_DATA_ACK_TRA) && (blockSizeRd !=1)) - { - mvOsPrintf("TWSI: twsiDataReceive ERROR - status %x in read trans \n",temp); - return MV_FAIL; - } - else if((temp != TWSI_M_REC_RD_DATA_ACK_NOT_TRA) && (blockSizeRd ==1)) - { - mvOsPrintf("TWSI: twsiDataReceive ERROR - status %x in Rd Terminate\n",temp); - return MV_FAIL; - } - - /* read the data*/ - *pBlock = (MV_U8)MV_REG_READ(TWSI_DATA_REG(chanNum)); - DB(mvOsPrintf("TWSI: twsiDataReceive place %d read %x \n",\ - blockSize - blockSizeRd,*pBlock)); - pBlock++; - blockSizeRd--; - } - - return MV_OK; -} - - - -/******************************************************************************* -* twsiTargetOffsSet - Set TWST target offset on TWSI bus. -* -* DESCRIPTION: -* The function support TWSI targets that have inside address space (for -* example EEPROMs). The function: -* 1) Convert the given offset into pBlock and size. -* in case the offset should be set to a TWSI slave which support -* more then 256 bytes offset, the offset setting will be done -* in 2 transactions. -* 2) Use twsiDataTransmit to place those on the bus. -* -* INPUT: -* chanNum - TWSI channel -* offset - offset to be set on the EEPROM device. -* moreThen256 - whether the EEPROM device support more then 256 byte offset. -* -* OUTPUT: -* None. -* -* RETURN: -* MV_OK - if setting the offset completed succesfully. -* MV_FAIL otherwmise. -* -*******************************************************************************/ -static MV_STATUS twsiTargetOffsSet(MV_U8 chanNum, MV_U32 offset, MV_BOOL moreThen256) -{ - MV_U8 offBlock[2]; - MV_U32 offSize; - - if(moreThen256 == MV_TRUE) - { - offBlock[0] = (offset >> 8) & 0xff; - offBlock[1] = offset & 0xff; - offSize = 2; - } - else - { - offBlock[0] = offset & 0xff; - offSize = 1; - } - DB(mvOsPrintf("TWSI: twsiTargetOffsSet offSize = %x addr1 = %x addr2 = %x\n",\ - offSize,offBlock[0],offBlock[1])); - return twsiDataTransmit(chanNum, offBlock, offSize); - -} - -/******************************************************************************* -* mvTwsiRead - Read data block from a TWSI Slave. -* -* DESCRIPTION: -* The function calls the following functions: -* -) mvTwsiStartBitSet(); -* if(EEPROM device) -* -) mvTwsiAddrSet(w); -* -) twsiTargetOffsSet(); -* -) mvTwsiStartBitSet(); -* -) mvTwsiAddrSet(r); -* -) twsiDataReceive(); -* -) mvTwsiStopBitSet(); -* -* INPUT: -* chanNum - TWSI channel -* pTwsiSlave - Twsi Slave structure. -* blockSize - number of bytes to read. -* -* OUTPUT: -* pBlock - Data block. -* -* RETURN: -* MV_OK - if EEPROM read transaction completed succesfully, -* MV_BAD_PARAM - if pBlock is NULL, -* MV_FAIL otherwmise. -* -*******************************************************************************/ -MV_STATUS mvTwsiRead(MV_U8 chanNum, MV_TWSI_SLAVE *pTwsiSlave, MV_U8 *pBlock, MV_U32 blockSize) -{ - if((NULL == pBlock) || (NULL == pTwsiSlave)) - return MV_BAD_PARAM; - if(MV_OK != mvTwsiStartBitSet(chanNum)) - { - mvTwsiStopBitSet(chanNum); - return MV_FAIL; - } - - DB(mvOsPrintf("TWSI: mvTwsiEepromRead after mvTwsiStartBitSet\n")); - - /* in case offset exsist (i.e. eeprom ) */ - if(MV_TRUE == pTwsiSlave->validOffset) - { - if(MV_OK != mvTwsiAddrSet(chanNum, &(pTwsiSlave->slaveAddr), MV_TWSI_WRITE)) - { - mvTwsiStopBitSet(chanNum); - return MV_FAIL; - } - DB(mvOsPrintf("TWSI: mvTwsiEepromRead after mvTwsiAddrSet\n")); - if(MV_OK != twsiTargetOffsSet(chanNum, pTwsiSlave->offset, pTwsiSlave->moreThen256)) - { - mvTwsiStopBitSet(chanNum); - return MV_FAIL; - } - DB(mvOsPrintf("TWSI: mvTwsiEepromRead after twsiTargetOffsSet\n")); - if(MV_OK != mvTwsiStartBitSet(chanNum)) - { - mvTwsiStopBitSet(chanNum); - return MV_FAIL; - } - DB(mvOsPrintf("TWSI: mvTwsiEepromRead after mvTwsiStartBitSet\n")); - } - if(MV_OK != mvTwsiAddrSet(chanNum, &(pTwsiSlave->slaveAddr), MV_TWSI_READ)) - { - mvTwsiStopBitSet(chanNum); - return MV_FAIL; - } - DB(mvOsPrintf("TWSI: mvTwsiEepromRead after mvTwsiAddrSet\n")); - if(MV_OK != twsiDataReceive(chanNum, pBlock, blockSize)) - { - mvTwsiStopBitSet(chanNum); - return MV_FAIL; - } - DB(mvOsPrintf("TWSI: mvTwsiEepromRead after twsiDataReceive\n")); - - if(MV_OK != mvTwsiStopBitSet(chanNum)) - { - return MV_FAIL; - } - - twsiAckBitSet(chanNum); - - DB(mvOsPrintf("TWSI: mvTwsiEepromRead after mvTwsiStopBitSet\n")); - - return MV_OK; -} - -/******************************************************************************* -* mvTwsiWrite - Write data block to a TWSI Slave. -* -* DESCRIPTION: -* The function calls the following functions: -* -) mvTwsiStartBitSet(); -* -) mvTwsiAddrSet(); -* -)if(EEPROM device) -* -) twsiTargetOffsSet(); -* -) twsiDataTransmit(); -* -) mvTwsiStopBitSet(); -* -* INPUT: -* chanNum - TWSI channel -* eepromAddress - eeprom address. -* blockSize - number of bytes to write. -* pBlock - Data block. -* -* OUTPUT: -* None -* -* RETURN: -* MV_OK - if EEPROM read transaction completed succesfully. -* MV_BAD_PARAM - if pBlock is NULL, -* MV_FAIL otherwmise. -* -* NOTE: Part of the EEPROM, required that the offset will be aligned to the -* max write burst supported. -*******************************************************************************/ -MV_STATUS mvTwsiWrite(MV_U8 chanNum, MV_TWSI_SLAVE *pTwsiSlave, MV_U8 *pBlock, MV_U32 blockSize) -{ - if((NULL == pBlock) || (NULL == pTwsiSlave)) - return MV_BAD_PARAM; - - if(MV_OK != mvTwsiStartBitSet(chanNum)) - { - mvTwsiStopBitSet(chanNum); - return MV_FAIL; - } - - DB(mvOsPrintf("TWSI: mvTwsiEepromWrite after mvTwsiStartBitSet\n")); - if(MV_OK != mvTwsiAddrSet(chanNum, &(pTwsiSlave->slaveAddr), MV_TWSI_WRITE)) - { - mvTwsiStopBitSet(chanNum); - return MV_FAIL; - } - DB(mvOsPrintf("TWSI :mvTwsiEepromWrite after mvTwsiAddrSet\n")); - - /* in case offset exsist (i.e. eeprom ) */ - if(MV_TRUE == pTwsiSlave->validOffset) - { - if(MV_OK != twsiTargetOffsSet(chanNum, pTwsiSlave->offset, pTwsiSlave->moreThen256)) - { - mvTwsiStopBitSet(chanNum); - return MV_FAIL; - } - DB(mvOsPrintf("TWSI: mvTwsiEepromWrite after twsiTargetOffsSet\n")); - } - if(MV_OK != twsiDataTransmit(chanNum, pBlock, blockSize)) - { - mvTwsiStopBitSet(chanNum); - return MV_FAIL; - } - DB(mvOsPrintf("TWSI: mvTwsiEepromWrite after twsiDataTransmit\n")); - if(MV_OK != mvTwsiStopBitSet(chanNum)) - { - return MV_FAIL; - } - DB(mvOsPrintf("TWSI: mvTwsiEepromWrite after mvTwsiStopBitSet\n")); - - return MV_OK; -} diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/twsi/mvTwsi.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/twsi/mvTwsi.h deleted file mode 100644 index bd5b6d0..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/twsi/mvTwsi.h +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ -#ifndef __INCmvTwsiH -#define __INCmvTwsiH - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* need to update this includes */ -#include "twsi/mvTwsiSpec.h" -#include "ctrlEnv/mvCtrlEnvLib.h" - - -/* The TWSI interface supports both 7-bit and 10-bit addressing. */ -/* This enumerator describes addressing type. */ -typedef enum _mvTwsiAddrType -{ - ADDR7_BIT, /* 7 bit address */ - ADDR10_BIT /* 10 bit address */ -}MV_TWSI_ADDR_TYPE; - -/* This structure describes TWSI address. */ -typedef struct _mvTwsiAddr -{ - MV_U32 address; /* address */ - MV_TWSI_ADDR_TYPE type; /* Address type */ -}MV_TWSI_ADDR; - -/* This structure describes a TWSI slave. */ -typedef struct _mvTwsiSlave -{ - MV_TWSI_ADDR slaveAddr; - MV_BOOL validOffset; /* whether the slave has offset (i.e. Eeprom etc.) */ - MV_U32 offset; /* offset in the slave. */ - MV_BOOL moreThen256; /* whether the ofset is bigger then 256 */ -}MV_TWSI_SLAVE; - -/* This enumerator describes TWSI protocol commands. */ -typedef enum _mvTwsiCmd -{ - MV_TWSI_WRITE, /* TWSI write command - 0 according to spec */ - MV_TWSI_READ /* TWSI read command - 1 according to spec */ -}MV_TWSI_CMD; - -MV_STATUS mvTwsiStartBitSet(MV_U8 chanNum); -MV_STATUS mvTwsiStopBitSet(MV_U8 chanNum); -MV_STATUS mvTwsiAddrSet(MV_U8 chanNum, MV_TWSI_ADDR *twsiAddr, MV_TWSI_CMD command); - -MV_U32 mvTwsiInit(MV_U8 chanNum, MV_KHZ frequancy, MV_U32 Tclk, MV_TWSI_ADDR *twsiAddr, MV_BOOL generalCallEnable); -MV_STATUS mvTwsiRead (MV_U8 chanNum, MV_TWSI_SLAVE *twsiSlave, MV_U8 *pBlock, MV_U32 blockSize); -MV_STATUS mvTwsiWrite(MV_U8 chanNum, MV_TWSI_SLAVE *twsiSlave, MV_U8 *pBlock, MV_U32 blockSize); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __INCmvTwsiH */ - diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/twsi/mvTwsiSpec.h b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/twsi/mvTwsiSpec.h deleted file mode 100644 index d0c2b9e..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/mvHal/mv_hal/twsi/mvTwsiSpec.h +++ /dev/null @@ -1,160 +0,0 @@ -/******************************************************************************* -Copyright (C) Marvell International Ltd. and its affiliates - -This software file (the "File") is owned and distributed by Marvell -International Ltd. and/or its affiliates ("Marvell") under the following -alternative licensing terms. Once you have made an election to distribute the -File under one of the following license alternatives, please (i) delete this -introductory statement regarding license alternatives, (ii) delete the two -license alternatives that you have not elected to use and (iii) preserve the -Marvell copyright notice above. - -******************************************************************************** -Marvell Commercial License Option - -If you received this File from Marvell and you have entered into a commercial -license agreement (a "Commercial License") with Marvell, the File is licensed -to you under the terms of the applicable Commercial License. - -******************************************************************************** -Marvell GPL License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File in accordance with the terms and conditions of the General -Public License Version 2, June 1991 (the "GPL License"), a copy of which is -available along with the File in the license.txt file or by writing to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or -on the worldwide web at http://www.gnu.org/licenses/gpl.txt. - -THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED -WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY -DISCLAIMED. The GPL License provides additional details about this warranty -disclaimer. -******************************************************************************** -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ -/****************************************/ -/* TWSI Registers */ -/****************************************/ -#ifndef __INCmvTwsiSpech -#define __INCmvTwsiSpech - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* defines */ -#define TWSI_SLAVE_ADDR_REG(chanNum) (TWSI_SLAVE_BASE(chanNum)+ 0x00) - -#define TWSI_SLAVE_ADDR_GCE_ENA BIT0 -#define TWSI_SLAVE_ADDR_7BIT_OFFS 0x1 -#define TWSI_SLAVE_ADDR_7BIT_MASK (0xFF << TWSI_SLAVE_ADDR_7BIT_OFFS) -#define TWSI_SLAVE_ADDR_10BIT_OFFS 0x7 -#define TWSI_SLAVE_ADDR_10BIT_MASK 0x300 -#define TWSI_SLAVE_ADDR_10BIT_CONST 0xF0 - - -#define TWSI_EXTENDED_SLAVE_ADDR_REG(chanNum) (TWSI_SLAVE_BASE(chanNum) + 0x10) -#define TWSI_EXTENDED_SLAVE_OFFS 0 -#define TWSI_EXTENDED_SLAVE_MASK (0xFF << TWSI_EXTENDED_SLAVE_OFFS) - - -#define TWSI_DATA_REG(chanNum) (TWSI_SLAVE_BASE(chanNum) + 0x04) -#define TWSI_DATA_COMMAND_OFFS 0x0 -#define TWSI_DATA_COMMAND_MASK (0x1 << TWSI_DATA_COMMAND_OFFS) -#define TWSI_DATA_COMMAND_WR (0x1 << TWSI_DATA_COMMAND_OFFS) -#define TWSI_DATA_COMMAND_RD (0x0 << TWSI_DATA_COMMAND_OFFS) -#define TWSI_DATA_ADDR_7BIT_OFFS 0x1 -#define TWSI_DATA_ADDR_7BIT_MASK (0xFF << TWSI_DATA_ADDR_7BIT_OFFS) -#define TWSI_DATA_ADDR_10BIT_OFFS 0x7 -#define TWSI_DATA_ADDR_10BIT_MASK 0x300 -#define TWSI_DATA_ADDR_10BIT_CONST 0xF0 - - -#define TWSI_CONTROL_REG(chanNum) (TWSI_SLAVE_BASE(chanNum) + 0x08) -#define TWSI_CONTROL_ACK BIT2 -#define TWSI_CONTROL_INT_FLAG_SET BIT3 -#define TWSI_CONTROL_STOP_BIT BIT4 -#define TWSI_CONTROL_START_BIT BIT5 -#define TWSI_CONTROL_ENA BIT6 -#define TWSI_CONTROL_INT_ENA BIT7 - - -#define TWSI_STATUS_BAUDE_RATE_REG(chanNum) (TWSI_SLAVE_BASE(chanNum) + 0x0c) -#define TWSI_BAUD_RATE_N_OFFS 0 -#define TWSI_BAUD_RATE_N_MASK (0x7 << TWSI_BAUD_RATE_N_OFFS) -#define TWSI_BAUD_RATE_M_OFFS 3 -#define TWSI_BAUD_RATE_M_MASK (0xF << TWSI_BAUD_RATE_M_OFFS) - -#define TWSI_SOFT_RESET_REG(chanNum) (TWSI_SLAVE_BASE(chanNum) + 0x1c) - -/* defines */ -#define TWSI_TIMEOUT_VALUE 0x500 - -/* TWSI status codes */ -#define TWSI_BUS_ERROR 0x00 -#define TWSI_START_CON_TRA 0x08 -#define TWSI_REPEATED_START_CON_TRA 0x10 -#define TWSI_AD_PLS_WR_BIT_TRA_ACK_REC 0x18 -#define TWSI_AD_PLS_WR_BIT_TRA_ACK_NOT_REC 0x20 -#define TWSI_M_TRAN_DATA_BYTE_ACK_REC 0x28 -#define TWSI_M_TRAN_DATA_BYTE_ACK_NOT_REC 0x30 -#define TWSI_M_LOST_ARB_DUR_AD_OR_DATA_TRA 0x38 -#define TWSI_AD_PLS_RD_BIT_TRA_ACK_REC 0x40 -#define TWSI_AD_PLS_RD_BIT_TRA_ACK_NOT_REC 0x48 -#define TWSI_M_REC_RD_DATA_ACK_TRA 0x50 -#define TWSI_M_REC_RD_DATA_ACK_NOT_TRA 0x58 -#define TWSI_SLA_REC_AD_PLS_WR_BIT_ACK_TRA 0x60 -#define TWSI_M_LOST_ARB_DUR_AD_TRA_AD_IS_TRGT_TO_SLA_ACK_TRA_W 0x68 -#define TWSI_GNL_CALL_REC_ACK_TRA 0x70 -#define TWSI_M_LOST_ARB_DUR_AD_TRA_GNL_CALL_AD_REC_ACK_TRA 0x78 -#define TWSI_SLA_REC_WR_DATA_AF_REC_SLA_AD_ACK_TRAN 0x80 -#define TWSI_SLA_REC_WR_DATA_AF_REC_SLA_AD_ACK_NOT_TRAN 0x88 -#define TWSI_SLA_REC_WR_DATA_AF_REC_GNL_CALL_ACK_TRAN 0x90 -#define TWSI_SLA_REC_WR_DATA_AF_REC_GNL_CALL_ACK_NOT_TRAN 0x98 -#define TWSI_SLA_REC_STOP_OR_REPEATED_STRT_CON 0xA0 -#define TWSI_SLA_REC_AD_PLS_RD_BIT_ACK_TRA 0xA8 -#define TWSI_M_LOST_ARB_DUR_AD_TRA_AD_IS_TRGT_TO_SLA_ACK_TRA_R 0xB0 -#define TWSI_SLA_TRA_RD_DATA_ACK_REC 0xB8 -#define TWSI_SLA_TRA_RD_DATA_ACK_NOT_REC 0xC0 -#define TWSI_SLA_TRA_LAST_RD_DATA_ACK_REC 0xC8 -#define TWSI_SEC_AD_PLS_WR_BIT_TRA_ACK_REC 0xD0 -#define TWSI_SEC_AD_PLS_WR_BIT_TRA_ACK_NOT_REC 0xD8 -#define TWSI_SEC_AD_PLS_RD_BIT_TRA_ACK_REC 0xE0 -#define TWSI_SEC_AD_PLS_RD_BIT_TRA_ACK_NOT_REC 0xE8 -#define TWSI_NO_REL_STS_INT_FLAG_IS_KEPT_0 0xF8 - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __INCmvTwsiSpech */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/ocf-bench.c b/target/linux/generic-2.4/files/crypto/ocf/ocf-bench.c deleted file mode 100644 index d325231..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/ocf-bench.c +++ /dev/null @@ -1,436 +0,0 @@ -/* - * A loadable module that benchmarks the OCF crypto speed from kernel space. - * - * Copyright (C) 2004-2010 David McCullough <david_mccullough@mcafee.com> - * - * LICENSE TERMS - * - * The free distribution and use of this software in both source and binary - * form is allowed (with or without changes) provided that: - * - * 1. distributions of this source code include the above copyright - * notice, this list of conditions and the following disclaimer; - * - * 2. distributions in binary form include the above copyright - * notice, this list of conditions and the following disclaimer - * in the documentation and/or other associated materials; - * - * 3. the copyright holder's name is not used to endorse products - * built using this software without specific written permission. - * - * ALTERNATIVELY, provided that this notice is retained in full, this product - * may be distributed under the terms of the GNU General Public License (GPL), - * in which case the provisions of the GPL apply INSTEAD OF those given above. - * - * DISCLAIMER - * - * This software is provided 'as is' with no explicit or implied warranties - * in respect of its properties, including, but not limited to, correctness - * and/or fitness for purpose. - */ - - -#ifndef AUTOCONF_INCLUDED -#include <linux/config.h> -#endif -#include <linux/module.h> -#include <linux/init.h> -#include <linux/list.h> -#include <linux/slab.h> -#include <linux/wait.h> -#include <linux/sched.h> -#include <linux/spinlock.h> -#include <linux/version.h> -#include <linux/interrupt.h> -#include <cryptodev.h> - -#ifdef I_HAVE_AN_XSCALE_WITH_INTEL_SDK -#define BENCH_IXP_ACCESS_LIB 1 -#endif -#ifdef BENCH_IXP_ACCESS_LIB -#include <IxTypes.h> -#include <IxOsBuffMgt.h> -#include <IxNpeDl.h> -#include <IxCryptoAcc.h> -#include <IxQMgr.h> -#include <IxOsServices.h> -#include <IxOsCacheMMU.h> -#endif - -/* - * support for access lib version 1.4 - */ -#ifndef IX_MBUF_PRIV -#define IX_MBUF_PRIV(x) ((x)->priv) -#endif - -/* - * the number of simultaneously active requests - */ -static int request_q_len = 20; -module_param(request_q_len, int, 0); -MODULE_PARM_DESC(request_q_len, "Number of outstanding requests"); -/* - * how many requests we want to have processed - */ -static int request_num = 1024; -module_param(request_num, int, 0); -MODULE_PARM_DESC(request_num, "run for at least this many requests"); -/* - * the size of each request - */ -static int request_size = 1500; -module_param(request_size, int, 0); -MODULE_PARM_DESC(request_size, "size of each request"); - -/* - * a structure for each request - */ -typedef struct { - struct work_struct work; -#ifdef BENCH_IXP_ACCESS_LIB - IX_MBUF mbuf; -#endif - unsigned char *buffer; -} request_t; - -static request_t *requests; - -static int outstanding; -static int total; - -/*************************************************************************/ -/* - * OCF benchmark routines - */ - -static uint64_t ocf_cryptoid; -static int ocf_init(void); -static int ocf_cb(struct cryptop *crp); -static void ocf_request(void *arg); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) -static void ocf_request_wq(struct work_struct *work); -#endif - -static int -ocf_init(void) -{ - int error; - struct cryptoini crie, cria; - struct cryptodesc crda, crde; - - memset(&crie, 0, sizeof(crie)); - memset(&cria, 0, sizeof(cria)); - memset(&crde, 0, sizeof(crde)); - memset(&crda, 0, sizeof(crda)); - - cria.cri_alg = CRYPTO_SHA1_HMAC; - cria.cri_klen = 20 * 8; - cria.cri_key = "0123456789abcdefghij"; - - crie.cri_alg = CRYPTO_3DES_CBC; - crie.cri_klen = 24 * 8; - crie.cri_key = "0123456789abcdefghijklmn"; - - crie.cri_next = &cria; - - error = crypto_newsession(&ocf_cryptoid, &crie, 0); - if (error) { - printk("crypto_newsession failed %d\n", error); - return -1; - } - return 0; -} - -static int -ocf_cb(struct cryptop *crp) -{ - request_t *r = (request_t *) crp->crp_opaque; - - if (crp->crp_etype) - printk("Error in OCF processing: %d\n", crp->crp_etype); - total++; - crypto_freereq(crp); - crp = NULL; - - if (total > request_num) { - outstanding--; - return 0; - } - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) - INIT_WORK(&r->work, ocf_request_wq); -#else - INIT_WORK(&r->work, ocf_request, r); -#endif - schedule_work(&r->work); - return 0; -} - - -static void -ocf_request(void *arg) -{ - request_t *r = arg; - struct cryptop *crp = crypto_getreq(2); - struct cryptodesc *crde, *crda; - - if (!crp) { - outstanding--; - return; - } - - crde = crp->crp_desc; - crda = crde->crd_next; - - crda->crd_skip = 0; - crda->crd_flags = 0; - crda->crd_len = request_size; - crda->crd_inject = request_size; - crda->crd_alg = CRYPTO_SHA1_HMAC; - crda->crd_key = "0123456789abcdefghij"; - crda->crd_klen = 20 * 8; - - crde->crd_skip = 0; - crde->crd_flags = CRD_F_IV_EXPLICIT | CRD_F_ENCRYPT; - crde->crd_len = request_size; - crde->crd_inject = request_size; - crde->crd_alg = CRYPTO_3DES_CBC; - crde->crd_key = "0123456789abcdefghijklmn"; - crde->crd_klen = 24 * 8; - - crp->crp_ilen = request_size + 64; - crp->crp_flags = CRYPTO_F_CBIMM; - crp->crp_buf = (caddr_t) r->buffer; - crp->crp_callback = ocf_cb; - crp->crp_sid = ocf_cryptoid; - crp->crp_opaque = (caddr_t) r; - crypto_dispatch(crp); -} - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) -static void -ocf_request_wq(struct work_struct *work) -{ - request_t *r = container_of(work, request_t, work); - ocf_request(r); -} -#endif - -/*************************************************************************/ -#ifdef BENCH_IXP_ACCESS_LIB -/*************************************************************************/ -/* - * CryptoAcc benchmark routines - */ - -static IxCryptoAccCtx ixp_ctx; -static UINT32 ixp_ctx_id; -static IX_MBUF ixp_pri; -static IX_MBUF ixp_sec; -static int ixp_registered = 0; - -static void ixp_register_cb(UINT32 ctx_id, IX_MBUF *bufp, - IxCryptoAccStatus status); -static void ixp_perform_cb(UINT32 ctx_id, IX_MBUF *sbufp, IX_MBUF *dbufp, - IxCryptoAccStatus status); -static void ixp_request(void *arg); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) -static void ixp_request_wq(struct work_struct *work); -#endif - -static int -ixp_init(void) -{ - IxCryptoAccStatus status; - - ixp_ctx.cipherCtx.cipherAlgo = IX_CRYPTO_ACC_CIPHER_3DES; - ixp_ctx.cipherCtx.cipherMode = IX_CRYPTO_ACC_MODE_CBC; - ixp_ctx.cipherCtx.cipherKeyLen = 24; - ixp_ctx.cipherCtx.cipherBlockLen = IX_CRYPTO_ACC_DES_BLOCK_64; - ixp_ctx.cipherCtx.cipherInitialVectorLen = IX_CRYPTO_ACC_DES_IV_64; - memcpy(ixp_ctx.cipherCtx.key.cipherKey, "0123456789abcdefghijklmn", 24); - - ixp_ctx.authCtx.authAlgo = IX_CRYPTO_ACC_AUTH_SHA1; - ixp_ctx.authCtx.authDigestLen = 12; - ixp_ctx.authCtx.aadLen = 0; - ixp_ctx.authCtx.authKeyLen = 20; - memcpy(ixp_ctx.authCtx.key.authKey, "0123456789abcdefghij", 20); - - ixp_ctx.useDifferentSrcAndDestMbufs = 0; - ixp_ctx.operation = IX_CRYPTO_ACC_OP_ENCRYPT_AUTH ; - - IX_MBUF_MLEN(&ixp_pri) = IX_MBUF_PKT_LEN(&ixp_pri) = 128; - IX_MBUF_MDATA(&ixp_pri) = (unsigned char *) kmalloc(128, SLAB_ATOMIC); - IX_MBUF_MLEN(&ixp_sec) = IX_MBUF_PKT_LEN(&ixp_sec) = 128; - IX_MBUF_MDATA(&ixp_sec) = (unsigned char *) kmalloc(128, SLAB_ATOMIC); - - status = ixCryptoAccCtxRegister(&ixp_ctx, &ixp_pri, &ixp_sec, - ixp_register_cb, ixp_perform_cb, &ixp_ctx_id); - - if (IX_CRYPTO_ACC_STATUS_SUCCESS == status) { - while (!ixp_registered) - schedule(); - return ixp_registered < 0 ? -1 : 0; - } - - printk("ixp: ixCryptoAccCtxRegister failed %d\n", status); - return -1; -} - -static void -ixp_register_cb(UINT32 ctx_id, IX_MBUF *bufp, IxCryptoAccStatus status) -{ - if (bufp) { - IX_MBUF_MLEN(bufp) = IX_MBUF_PKT_LEN(bufp) = 0; - kfree(IX_MBUF_MDATA(bufp)); - IX_MBUF_MDATA(bufp) = NULL; - } - - if (IX_CRYPTO_ACC_STATUS_WAIT == status) - return; - if (IX_CRYPTO_ACC_STATUS_SUCCESS == status) - ixp_registered = 1; - else - ixp_registered = -1; -} - -static void -ixp_perform_cb( - UINT32 ctx_id, - IX_MBUF *sbufp, - IX_MBUF *dbufp, - IxCryptoAccStatus status) -{ - request_t *r = NULL; - - total++; - if (total > request_num) { - outstanding--; - return; - } - - if (!sbufp || !(r = IX_MBUF_PRIV(sbufp))) { - printk("crappo %p %p\n", sbufp, r); - outstanding--; - return; - } - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) - INIT_WORK(&r->work, ixp_request_wq); -#else - INIT_WORK(&r->work, ixp_request, r); -#endif - schedule_work(&r->work); -} - -static void -ixp_request(void *arg) -{ - request_t *r = arg; - IxCryptoAccStatus status; - - memset(&r->mbuf, 0, sizeof(r->mbuf)); - IX_MBUF_MLEN(&r->mbuf) = IX_MBUF_PKT_LEN(&r->mbuf) = request_size + 64; - IX_MBUF_MDATA(&r->mbuf) = r->buffer; - IX_MBUF_PRIV(&r->mbuf) = r; - status = ixCryptoAccAuthCryptPerform(ixp_ctx_id, &r->mbuf, NULL, - 0, request_size, 0, request_size, request_size, r->buffer); - if (IX_CRYPTO_ACC_STATUS_SUCCESS != status) { - printk("status1 = %d\n", status); - outstanding--; - return; - } - return; -} - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) -static void -ixp_request_wq(struct work_struct *work) -{ - request_t *r = container_of(work, request_t, work); - ixp_request(r); -} -#endif - -/*************************************************************************/ -#endif /* BENCH_IXP_ACCESS_LIB */ -/*************************************************************************/ - -int -ocfbench_init(void) -{ - int i, jstart, jstop; - - printk("Crypto Speed tests\n"); - - requests = kmalloc(sizeof(request_t) * request_q_len, GFP_KERNEL); - if (!requests) { - printk("malloc failed\n"); - return -EINVAL; - } - - for (i = 0; i < request_q_len; i++) { - /* +64 for return data */ - requests[i].buffer = kmalloc(request_size + 128, GFP_DMA); - if (!requests[i].buffer) { - printk("malloc failed\n"); - return -EINVAL; - } - memset(requests[i].buffer, '0' + i, request_size + 128); - } - - /* - * OCF benchmark - */ - printk("OCF: testing ...\n"); - ocf_init(); - total = outstanding = 0; - jstart = jiffies; - for (i = 0; i < request_q_len; i++) { - outstanding++; - ocf_request(&requests[i]); - } - while (outstanding > 0) - schedule(); - jstop = jiffies; - - printk("OCF: %d requests of %d bytes in %d jiffies\n", total, request_size, - jstop - jstart); - -#ifdef BENCH_IXP_ACCESS_LIB - /* - * IXP benchmark - */ - printk("IXP: testing ...\n"); - ixp_init(); - total = outstanding = 0; - jstart = jiffies; - for (i = 0; i < request_q_len; i++) { - outstanding++; - ixp_request(&requests[i]); - } - while (outstanding > 0) - schedule(); - jstop = jiffies; - - printk("IXP: %d requests of %d bytes in %d jiffies\n", total, request_size, - jstop - jstart); -#endif /* BENCH_IXP_ACCESS_LIB */ - - for (i = 0; i < request_q_len; i++) - kfree(requests[i].buffer); - kfree(requests); - return -EINVAL; /* always fail to load so it can be re-run quickly ;-) */ -} - -static void __exit ocfbench_exit(void) -{ -} - -module_init(ocfbench_init); -module_exit(ocfbench_exit); - -MODULE_LICENSE("BSD"); -MODULE_AUTHOR("David McCullough <david_mccullough@mcafee.com>"); -MODULE_DESCRIPTION("Benchmark various in-kernel crypto speeds"); diff --git a/target/linux/generic-2.4/files/crypto/ocf/ocf-compat.h b/target/linux/generic-2.4/files/crypto/ocf/ocf-compat.h deleted file mode 100644 index 212f971..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/ocf-compat.h +++ /dev/null @@ -1,294 +0,0 @@ -#ifndef _BSD_COMPAT_H_ -#define _BSD_COMPAT_H_ 1 -/****************************************************************************/ -/* - * Provide compat routines for older linux kernels and BSD kernels - * - * Written by David McCullough <david_mccullough@mcafee.com> - * Copyright (C) 2010 David McCullough <david_mccullough@mcafee.com> - * - * LICENSE TERMS - * - * The free distribution and use of this software in both source and binary - * form is allowed (with or without changes) provided that: - * - * 1. distributions of this source code include the above copyright - * notice, this list of conditions and the following disclaimer; - * - * 2. distributions in binary form include the above copyright - * notice, this list of conditions and the following disclaimer - * in the documentation and/or other associated materials; - * - * 3. the copyright holder's name is not used to endorse products - * built using this software without specific written permission. - * - * ALTERNATIVELY, provided that this notice is retained in full, this file - * may be distributed under the terms of the GNU General Public License (GPL), - * in which case the provisions of the GPL apply INSTEAD OF those given above. - * - * DISCLAIMER - * - * This software is provided 'as is' with no explicit or implied warranties - * in respect of its properties, including, but not limited to, correctness - * and/or fitness for purpose. - */ -/****************************************************************************/ -#ifdef __KERNEL__ -/* - * fake some BSD driver interface stuff specifically for OCF use - */ - -typedef struct ocf_device *device_t; - -typedef struct { - int (*cryptodev_newsession)(device_t dev, u_int32_t *sidp, struct cryptoini *cri); - int (*cryptodev_freesession)(device_t dev, u_int64_t tid); - int (*cryptodev_process)(device_t dev, struct cryptop *crp, int hint); - int (*cryptodev_kprocess)(device_t dev, struct cryptkop *krp, int hint); -} device_method_t; -#define DEVMETHOD(id, func) id: func - -struct ocf_device { - char name[32]; /* the driver name */ - char nameunit[32]; /* the driver name + HW instance */ - int unit; - device_method_t methods; - void *softc; -}; - -#define CRYPTODEV_NEWSESSION(dev, sid, cri) \ - ((*(dev)->methods.cryptodev_newsession)(dev,sid,cri)) -#define CRYPTODEV_FREESESSION(dev, sid) \ - ((*(dev)->methods.cryptodev_freesession)(dev, sid)) -#define CRYPTODEV_PROCESS(dev, crp, hint) \ - ((*(dev)->methods.cryptodev_process)(dev, crp, hint)) -#define CRYPTODEV_KPROCESS(dev, krp, hint) \ - ((*(dev)->methods.cryptodev_kprocess)(dev, krp, hint)) - -#define device_get_name(dev) ((dev)->name) -#define device_get_nameunit(dev) ((dev)->nameunit) -#define device_get_unit(dev) ((dev)->unit) -#define device_get_softc(dev) ((dev)->softc) - -#define softc_device_decl \ - struct ocf_device _device; \ - device_t - -#define softc_device_init(_sc, _name, _unit, _methods) \ - if (1) {\ - strncpy((_sc)->_device.name, _name, sizeof((_sc)->_device.name) - 1); \ - snprintf((_sc)->_device.nameunit, sizeof((_sc)->_device.name), "%s%d", _name, _unit); \ - (_sc)->_device.unit = _unit; \ - (_sc)->_device.methods = _methods; \ - (_sc)->_device.softc = (void *) _sc; \ - *(device_t *)((softc_get_device(_sc))+1) = &(_sc)->_device; \ - } else - -#define softc_get_device(_sc) (&(_sc)->_device) - -/* - * iomem support for 2.4 and 2.6 kernels - */ -#include <linux/version.h> -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) -#define ocf_iomem_t unsigned long - -/* - * implement simple workqueue like support for older kernels - */ - -#include <linux/tqueue.h> - -#define work_struct tq_struct - -#define INIT_WORK(wp, fp, ap) \ - do { \ - (wp)->sync = 0; \ - (wp)->routine = (fp); \ - (wp)->data = (ap); \ - } while (0) - -#define schedule_work(wp) \ - do { \ - queue_task((wp), &tq_immediate); \ - mark_bh(IMMEDIATE_BH); \ - } while (0) - -#define flush_scheduled_work() run_task_queue(&tq_immediate) - -#else -#define ocf_iomem_t void __iomem * - -#include <linux/workqueue.h> - -#endif - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26) -#include <linux/fdtable.h> -#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11) -#define files_fdtable(files) (files) -#endif - -#ifdef MODULE_PARM -#undef module_param /* just in case */ -#define module_param(a,b,c) MODULE_PARM(a,"i") -#endif - -#define bzero(s,l) memset(s,0,l) -#define bcopy(s,d,l) memcpy(d,s,l) -#define bcmp(x, y, l) memcmp(x,y,l) - -#define MIN(x,y) ((x) < (y) ? (x) : (y)) - -#define device_printf(dev, a...) ({ \ - printk("%s: ", device_get_nameunit(dev)); printk(a); \ - }) - -#undef printf -#define printf(fmt...) printk(fmt) - -#define KASSERT(c,p) if (!(c)) { printk p ; } else - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) -#define ocf_daemonize(str) \ - daemonize(); \ - spin_lock_irq(¤t->sigmask_lock); \ - sigemptyset(¤t->blocked); \ - recalc_sigpending(current); \ - spin_unlock_irq(¤t->sigmask_lock); \ - sprintf(current->comm, str); -#else -#define ocf_daemonize(str) daemonize(str); -#endif - -#define TAILQ_INSERT_TAIL(q,d,m) list_add_tail(&(d)->m, (q)) -#define TAILQ_EMPTY(q) list_empty(q) -#define TAILQ_FOREACH(v, q, m) list_for_each_entry(v, q, m) - -#define read_random(p,l) get_random_bytes(p,l) - -#define DELAY(x) ((x) > 2000 ? mdelay((x)/1000) : udelay(x)) -#define strtoul simple_strtoul - -#define pci_get_vendor(dev) ((dev)->vendor) -#define pci_get_device(dev) ((dev)->device) - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) -#define pci_set_consistent_dma_mask(dev, mask) (0) -#endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) -#define pci_dma_sync_single_for_cpu pci_dma_sync_single -#endif - -#ifndef DMA_32BIT_MASK -#define DMA_32BIT_MASK 0x00000000ffffffffULL -#endif - -#ifndef htole32 -#define htole32(x) cpu_to_le32(x) -#endif -#ifndef htobe32 -#define htobe32(x) cpu_to_be32(x) -#endif -#ifndef htole16 -#define htole16(x) cpu_to_le16(x) -#endif -#ifndef htobe16 -#define htobe16(x) cpu_to_be16(x) -#endif - -/* older kernels don't have these */ - -#include <asm/irq.h> -#if !defined(IRQ_NONE) && !defined(IRQ_RETVAL) -#define IRQ_NONE -#define IRQ_HANDLED -#define IRQ_WAKE_THREAD -#define IRQ_RETVAL -#define irqreturn_t void -typedef irqreturn_t (*irq_handler_t)(int irq, void *arg, struct pt_regs *regs); -#endif -#ifndef IRQF_SHARED -#define IRQF_SHARED SA_SHIRQ -#endif - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -# define strlcpy(dest,src,len) \ - ({strncpy(dest,src,(len)-1); ((char *)dest)[(len)-1] = '\0'; }) -#endif - -#ifndef MAX_ERRNO -#define MAX_ERRNO 4095 -#endif -#ifndef IS_ERR_VALUE -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,5) -#include <linux/err.h> -#endif -#ifndef IS_ERR_VALUE -#define IS_ERR_VALUE(x) ((unsigned long)(x) >= (unsigned long)-MAX_ERRNO) -#endif -#endif - -/* - * common debug for all - */ -#if 1 -#define dprintk(a...) do { if (debug) printk(a); } while(0) -#else -#define dprintk(a...) -#endif - -#ifndef SLAB_ATOMIC -/* Changed in 2.6.20, must use GFP_ATOMIC now */ -#define SLAB_ATOMIC GFP_ATOMIC -#endif - -/* - * need some additional support for older kernels */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,2) -#define pci_register_driver_compat(driver, rc) \ - do { \ - if ((rc) > 0) { \ - (rc) = 0; \ - } else if (rc == 0) { \ - (rc) = -ENODEV; \ - } else { \ - pci_unregister_driver(driver); \ - } \ - } while (0) -#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) -#define pci_register_driver_compat(driver,rc) ((rc) = (rc) < 0 ? (rc) : 0) -#else -#define pci_register_driver_compat(driver,rc) -#endif - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) - -#include <linux/mm.h> -#include <asm/scatterlist.h> - -static inline void sg_set_page(struct scatterlist *sg, struct page *page, - unsigned int len, unsigned int offset) -{ - sg->page = page; - sg->offset = offset; - sg->length = len; -} - -static inline void *sg_virt(struct scatterlist *sg) -{ - return page_address(sg->page) + sg->offset; -} - -#define sg_init_table(sg, n) - -#endif - -#ifndef late_initcall -#define late_initcall(init) module_init(init) -#endif - -#endif /* __KERNEL__ */ - -/****************************************************************************/ -#endif /* _BSD_COMPAT_H_ */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/ocfnull/Makefile b/target/linux/generic-2.4/files/crypto/ocf/ocfnull/Makefile deleted file mode 100644 index 044bcac..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/ocfnull/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# for SGlinux builds --include $(ROOTDIR)/modules/.config - -obj-$(CONFIG_OCF_OCFNULL) += ocfnull.o - -obj ?= . -EXTRA_CFLAGS += -I$(obj)/.. - -ifdef TOPDIR --include $(TOPDIR)/Rules.make -endif - diff --git a/target/linux/generic-2.4/files/crypto/ocf/ocfnull/ocfnull.c b/target/linux/generic-2.4/files/crypto/ocf/ocfnull/ocfnull.c deleted file mode 100644 index a6b76cd..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/ocfnull/ocfnull.c +++ /dev/null @@ -1,203 +0,0 @@ -/* - * An OCF module for determining the cost of crypto versus the cost of - * IPSec processing outside of OCF. This modules gives us the effect of - * zero cost encryption, of course you will need to run it at both ends - * since it does no crypto at all. - * - * Written by David McCullough <david_mccullough@mcafee.com> - * Copyright (C) 2006-2010 David McCullough - * - * LICENSE TERMS - * - * The free distribution and use of this software in both source and binary - * form is allowed (with or without changes) provided that: - * - * 1. distributions of this source code include the above copyright - * notice, this list of conditions and the following disclaimer; - * - * 2. distributions in binary form include the above copyright - * notice, this list of conditions and the following disclaimer - * in the documentation and/or other associated materials; - * - * 3. the copyright holder's name is not used to endorse products - * built using this software without specific written permission. - * - * ALTERNATIVELY, provided that this notice is retained in full, this product - * may be distributed under the terms of the GNU General Public License (GPL), - * in which case the provisions of the GPL apply INSTEAD OF those given above. - * - * DISCLAIMER - * - * This software is provided 'as is' with no explicit or implied warranties - * in respect of its properties, including, but not limited to, correctness - * and/or fitness for purpose. - */ - -#ifndef AUTOCONF_INCLUDED -#include <linux/config.h> -#endif -#include <linux/module.h> -#include <linux/init.h> -#include <linux/list.h> -#include <linux/slab.h> -#include <linux/sched.h> -#include <linux/wait.h> -#include <linux/crypto.h> -#include <linux/interrupt.h> - -#include <cryptodev.h> -#include <uio.h> - -static int32_t null_id = -1; -static u_int32_t null_sesnum = 0; - -static int null_process(device_t, struct cryptop *, int); -static int null_newsession(device_t, u_int32_t *, struct cryptoini *); -static int null_freesession(device_t, u_int64_t); - -#define debug ocfnull_debug -int ocfnull_debug = 0; -module_param(ocfnull_debug, int, 0644); -MODULE_PARM_DESC(ocfnull_debug, "Enable debug"); - -/* - * dummy device structure - */ - -static struct { - softc_device_decl sc_dev; -} nulldev; - -static device_method_t null_methods = { - /* crypto device methods */ - DEVMETHOD(cryptodev_newsession, null_newsession), - DEVMETHOD(cryptodev_freesession,null_freesession), - DEVMETHOD(cryptodev_process, null_process), -}; - -/* - * Generate a new software session. - */ -static int -null_newsession(device_t arg, u_int32_t *sid, struct cryptoini *cri) -{ - dprintk("%s()\n", __FUNCTION__); - if (sid == NULL || cri == NULL) { - dprintk("%s,%d - EINVAL\n", __FILE__, __LINE__); - return EINVAL; - } - - if (null_sesnum == 0) - null_sesnum++; - *sid = null_sesnum++; - return 0; -} - - -/* - * Free a session. - */ -static int -null_freesession(device_t arg, u_int64_t tid) -{ - u_int32_t sid = CRYPTO_SESID2LID(tid); - - dprintk("%s()\n", __FUNCTION__); - if (sid > null_sesnum) { - dprintk("%s,%d: EINVAL\n", __FILE__, __LINE__); - return EINVAL; - } - - /* Silently accept and return */ - if (sid == 0) - return 0; - return 0; -} - - -/* - * Process a request. - */ -static int -null_process(device_t arg, struct cryptop *crp, int hint) -{ - unsigned int lid; - - dprintk("%s()\n", __FUNCTION__); - - /* Sanity check */ - if (crp == NULL) { - dprintk("%s,%d: EINVAL\n", __FILE__, __LINE__); - return EINVAL; - } - - crp->crp_etype = 0; - - if (crp->crp_desc == NULL || crp->crp_buf == NULL) { - dprintk("%s,%d: EINVAL\n", __FILE__, __LINE__); - crp->crp_etype = EINVAL; - goto done; - } - - /* - * find the session we are using - */ - - lid = crp->crp_sid & 0xffffffff; - if (lid >= null_sesnum || lid == 0) { - crp->crp_etype = ENOENT; - dprintk("%s,%d: ENOENT\n", __FILE__, __LINE__); - goto done; - } - -done: - crypto_done(crp); - return 0; -} - - -/* - * our driver startup and shutdown routines - */ - -static int -null_init(void) -{ - dprintk("%s(%p)\n", __FUNCTION__, null_init); - - memset(&nulldev, 0, sizeof(nulldev)); - softc_device_init(&nulldev, "ocfnull", 0, null_methods); - - null_id = crypto_get_driverid(softc_get_device(&nulldev), - CRYPTOCAP_F_HARDWARE); - if (null_id < 0) - panic("ocfnull: crypto device cannot initialize!"); - -#define REGISTER(alg) \ - crypto_register(null_id,alg,0,0) - REGISTER(CRYPTO_DES_CBC); - REGISTER(CRYPTO_3DES_CBC); - REGISTER(CRYPTO_RIJNDAEL128_CBC); - REGISTER(CRYPTO_MD5); - REGISTER(CRYPTO_SHA1); - REGISTER(CRYPTO_MD5_HMAC); - REGISTER(CRYPTO_SHA1_HMAC); -#undef REGISTER - - return 0; -} - -static void -null_exit(void) -{ - dprintk("%s()\n", __FUNCTION__); - crypto_unregister_all(null_id); - null_id = -1; -} - -module_init(null_init); -module_exit(null_exit); - -MODULE_LICENSE("Dual BSD/GPL"); -MODULE_AUTHOR("David McCullough <david_mccullough@mcafee.com>"); -MODULE_DESCRIPTION("ocfnull - claims a lot but does nothing"); diff --git a/target/linux/generic-2.4/files/crypto/ocf/pasemi/Makefile b/target/linux/generic-2.4/files/crypto/ocf/pasemi/Makefile deleted file mode 100644 index b0a3980..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/pasemi/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# for SGlinux builds --include $(ROOTDIR)/modules/.config - -obj-$(CONFIG_OCF_PASEMI) += pasemi.o - -obj ?= . -EXTRA_CFLAGS += -I$(obj)/.. -I$(obj)/ - -ifdef TOPDIR --include $(TOPDIR)/Rules.make -endif - diff --git a/target/linux/generic-2.4/files/crypto/ocf/pasemi/pasemi.c b/target/linux/generic-2.4/files/crypto/ocf/pasemi/pasemi.c deleted file mode 100644 index c3bb931..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/pasemi/pasemi.c +++ /dev/null @@ -1,1009 +0,0 @@ -/* - * Copyright (C) 2007 PA Semi, Inc - * - * Driver for the PA Semi PWRficient DMA Crypto Engine - * - * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef AUTOCONF_INCLUDED -#include <linux/config.h> -#endif -#include <linux/module.h> -#include <linux/init.h> -#include <linux/interrupt.h> -#include <linux/timer.h> -#include <linux/random.h> -#include <linux/skbuff.h> -#include <asm/scatterlist.h> -#include <linux/moduleparam.h> -#include <linux/pci.h> -#include <cryptodev.h> -#include <uio.h> -#include "pasemi_fnu.h" - -#define DRV_NAME "pasemi" - -#define TIMER_INTERVAL 1000 - -static void __devexit pasemi_dma_remove(struct pci_dev *pdev); -static struct pasdma_status volatile * dma_status; - -static int debug; -module_param(debug, int, 0644); -MODULE_PARM_DESC(debug, "Enable debug"); - -static void pasemi_desc_start(struct pasemi_desc *desc, u64 hdr) -{ - desc->postop = 0; - desc->quad[0] = hdr; - desc->quad_cnt = 1; - desc->size = 1; -} - -static void pasemi_desc_build(struct pasemi_desc *desc, u64 val) -{ - desc->quad[desc->quad_cnt++] = val; - desc->size = (desc->quad_cnt + 1) / 2; -} - -static void pasemi_desc_hdr(struct pasemi_desc *desc, u64 hdr) -{ - desc->quad[0] |= hdr; -} - -static int pasemi_desc_size(struct pasemi_desc *desc) -{ - return desc->size; -} - -static void pasemi_ring_add_desc( - struct pasemi_fnu_txring *ring, - struct pasemi_desc *desc, - struct cryptop *crp) { - int i; - int ring_index = 2 * (ring->next_to_fill & (TX_RING_SIZE-1)); - - TX_DESC_INFO(ring, ring->next_to_fill).desc_size = desc->size; - TX_DESC_INFO(ring, ring->next_to_fill).desc_postop = desc->postop; - TX_DESC_INFO(ring, ring->next_to_fill).cf_crp = crp; - - for (i = 0; i < desc->quad_cnt; i += 2) { - ring_index = 2 * (ring->next_to_fill & (TX_RING_SIZE-1)); - ring->desc[ring_index] = desc->quad[i]; - ring->desc[ring_index + 1] = desc->quad[i + 1]; - ring->next_to_fill++; - } - - if (desc->quad_cnt & 1) - ring->desc[ring_index + 1] = 0; -} - -static void pasemi_ring_incr(struct pasemi_softc *sc, int chan_index, int incr) -{ - out_le32(sc->dma_regs + PAS_DMA_TXCHAN_INCR(sc->base_chan + chan_index), - incr); -} - -/* - * Generate a new software session. - */ -static int -pasemi_newsession(device_t dev, u_int32_t *sidp, struct cryptoini *cri) -{ - struct cryptoini *c, *encini = NULL, *macini = NULL; - struct pasemi_softc *sc = device_get_softc(dev); - struct pasemi_session *ses = NULL, **sespp; - int sesn, blksz = 0; - u64 ccmd = 0; - unsigned long flags; - struct pasemi_desc init_desc; - struct pasemi_fnu_txring *txring; - - DPRINTF("%s()\n", __FUNCTION__); - if (sidp == NULL || cri == NULL || sc == NULL) { - DPRINTF("%s,%d - EINVAL\n", __FILE__, __LINE__); - return -EINVAL; - } - for (c = cri; c != NULL; c = c->cri_next) { - if (ALG_IS_SIG(c->cri_alg)) { - if (macini) - return -EINVAL; - macini = c; - } else if (ALG_IS_CIPHER(c->cri_alg)) { - if (encini) - return -EINVAL; - encini = c; - } else { - DPRINTF("UNKNOWN c->cri_alg %d\n", c->cri_alg); - return -EINVAL; - } - } - if (encini == NULL && macini == NULL) - return -EINVAL; - if (encini) { - /* validate key length */ - switch (encini->cri_alg) { - case CRYPTO_DES_CBC: - if (encini->cri_klen != 64) - return -EINVAL; - ccmd = DMA_CALGO_DES; - break; - case CRYPTO_3DES_CBC: - if (encini->cri_klen != 192) - return -EINVAL; - ccmd = DMA_CALGO_3DES; - break; - case CRYPTO_AES_CBC: - if (encini->cri_klen != 128 && - encini->cri_klen != 192 && - encini->cri_klen != 256) - return -EINVAL; - ccmd = DMA_CALGO_AES; - break; - case CRYPTO_ARC4: - if (encini->cri_klen != 128) - return -EINVAL; - ccmd = DMA_CALGO_ARC; - break; - default: - DPRINTF("UNKNOWN encini->cri_alg %d\n", - encini->cri_alg); - return -EINVAL; - } - } - - if (macini) { - switch (macini->cri_alg) { - case CRYPTO_MD5: - case CRYPTO_MD5_HMAC: - blksz = 16; - break; - case CRYPTO_SHA1: - case CRYPTO_SHA1_HMAC: - blksz = 20; - break; - default: - DPRINTF("UNKNOWN macini->cri_alg %d\n", - macini->cri_alg); - return -EINVAL; - } - if (((macini->cri_klen + 7) / 8) > blksz) { - DPRINTF("key length %d bigger than blksize %d not supported\n", - ((macini->cri_klen + 7) / 8), blksz); - return -EINVAL; - } - } - - for (sesn = 0; sesn < sc->sc_nsessions; sesn++) { - if (sc->sc_sessions[sesn] == NULL) { - sc->sc_sessions[sesn] = (struct pasemi_session *) - kzalloc(sizeof(struct pasemi_session), GFP_ATOMIC); - ses = sc->sc_sessions[sesn]; - break; - } else if (sc->sc_sessions[sesn]->used == 0) { - ses = sc->sc_sessions[sesn]; - break; - } - } - - if (ses == NULL) { - sespp = (struct pasemi_session **) - kzalloc(sc->sc_nsessions * 2 * - sizeof(struct pasemi_session *), GFP_ATOMIC); - if (sespp == NULL) - return -ENOMEM; - memcpy(sespp, sc->sc_sessions, - sc->sc_nsessions * sizeof(struct pasemi_session *)); - kfree(sc->sc_sessions); - sc->sc_sessions = sespp; - sesn = sc->sc_nsessions; - ses = sc->sc_sessions[sesn] = (struct pasemi_session *) - kzalloc(sizeof(struct pasemi_session), GFP_ATOMIC); - if (ses == NULL) - return -ENOMEM; - sc->sc_nsessions *= 2; - } - - ses->used = 1; - - ses->dma_addr = pci_map_single(sc->dma_pdev, (void *) ses->civ, - sizeof(struct pasemi_session), DMA_TO_DEVICE); - - /* enter the channel scheduler */ - spin_lock_irqsave(&sc->sc_chnlock, flags); - - /* ARC4 has to be processed by the even channel */ - if (encini && (encini->cri_alg == CRYPTO_ARC4)) - ses->chan = sc->sc_lastchn & ~1; - else - ses->chan = sc->sc_lastchn; - sc->sc_lastchn = (sc->sc_lastchn + 1) % sc->sc_num_channels; - - spin_unlock_irqrestore(&sc->sc_chnlock, flags); - - txring = &sc->tx[ses->chan]; - - if (encini) { - ses->ccmd = ccmd; - - /* get an IV */ - /* XXX may read fewer than requested */ - get_random_bytes(ses->civ, sizeof(ses->civ)); - - ses->keysz = (encini->cri_klen - 63) / 64; - memcpy(ses->key, encini->cri_key, (ses->keysz + 1) * 8); - - pasemi_desc_start(&init_desc, - XCT_CTRL_HDR(ses->chan, (encini && macini) ? 0x68 : 0x40, DMA_FN_CIV0)); - pasemi_desc_build(&init_desc, - XCT_FUN_SRC_PTR((encini && macini) ? 0x68 : 0x40, ses->dma_addr)); - } - if (macini) { - if (macini->cri_alg == CRYPTO_MD5_HMAC || - macini->cri_alg == CRYPTO_SHA1_HMAC) - memcpy(ses->hkey, macini->cri_key, blksz); - else { - /* Load initialization constants(RFC 1321, 3174) */ - ses->hiv[0] = 0x67452301efcdab89ULL; - ses->hiv[1] = 0x98badcfe10325476ULL; - ses->hiv[2] = 0xc3d2e1f000000000ULL; - } - ses->hseq = 0ULL; - } - - spin_lock_irqsave(&txring->fill_lock, flags); - - if (((txring->next_to_fill + pasemi_desc_size(&init_desc)) - - txring->next_to_clean) > TX_RING_SIZE) { - spin_unlock_irqrestore(&txring->fill_lock, flags); - return ERESTART; - } - - if (encini) { - pasemi_ring_add_desc(txring, &init_desc, NULL); - pasemi_ring_incr(sc, ses->chan, - pasemi_desc_size(&init_desc)); - } - - txring->sesn = sesn; - spin_unlock_irqrestore(&txring->fill_lock, flags); - - *sidp = PASEMI_SID(sesn); - return 0; -} - -/* - * Deallocate a session. - */ -static int -pasemi_freesession(device_t dev, u_int64_t tid) -{ - struct pasemi_softc *sc = device_get_softc(dev); - int session; - u_int32_t sid = ((u_int32_t) tid) & 0xffffffff; - - DPRINTF("%s()\n", __FUNCTION__); - - if (sc == NULL) - return -EINVAL; - session = PASEMI_SESSION(sid); - if (session >= sc->sc_nsessions || !sc->sc_sessions[session]) - return -EINVAL; - - pci_unmap_single(sc->dma_pdev, - sc->sc_sessions[session]->dma_addr, - sizeof(struct pasemi_session), DMA_TO_DEVICE); - memset(sc->sc_sessions[session], 0, - sizeof(struct pasemi_session)); - - return 0; -} - -static int -pasemi_process(device_t dev, struct cryptop *crp, int hint) -{ - - int err = 0, ivsize, srclen = 0, reinit = 0, reinit_size = 0, chsel; - struct pasemi_softc *sc = device_get_softc(dev); - struct cryptodesc *crd1, *crd2, *maccrd, *enccrd; - caddr_t ivp; - struct pasemi_desc init_desc, work_desc; - struct pasemi_session *ses; - struct sk_buff *skb; - struct uio *uiop; - unsigned long flags; - struct pasemi_fnu_txring *txring; - - DPRINTF("%s()\n", __FUNCTION__); - - if (crp == NULL || crp->crp_callback == NULL || sc == NULL) - return -EINVAL; - - crp->crp_etype = 0; - if (PASEMI_SESSION(crp->crp_sid) >= sc->sc_nsessions) - return -EINVAL; - - ses = sc->sc_sessions[PASEMI_SESSION(crp->crp_sid)]; - - crd1 = crp->crp_desc; - if (crd1 == NULL) { - err = -EINVAL; - goto errout; - } - crd2 = crd1->crd_next; - - if (ALG_IS_SIG(crd1->crd_alg)) { - maccrd = crd1; - if (crd2 == NULL) - enccrd = NULL; - else if (ALG_IS_CIPHER(crd2->crd_alg) && - (crd2->crd_flags & CRD_F_ENCRYPT) == 0) - enccrd = crd2; - else - goto erralg; - } else if (ALG_IS_CIPHER(crd1->crd_alg)) { - enccrd = crd1; - if (crd2 == NULL) - maccrd = NULL; - else if (ALG_IS_SIG(crd2->crd_alg) && - (crd1->crd_flags & CRD_F_ENCRYPT)) - maccrd = crd2; - else - goto erralg; - } else - goto erralg; - - chsel = ses->chan; - - txring = &sc->tx[chsel]; - - if (enccrd && !maccrd) { - if (enccrd->crd_alg == CRYPTO_ARC4) - reinit = 1; - reinit_size = 0x40; - srclen = crp->crp_ilen; - - pasemi_desc_start(&work_desc, XCT_FUN_O | XCT_FUN_I - | XCT_FUN_FUN(chsel)); - if (enccrd->crd_flags & CRD_F_ENCRYPT) - pasemi_desc_hdr(&work_desc, XCT_FUN_CRM_ENC); - else - pasemi_desc_hdr(&work_desc, XCT_FUN_CRM_DEC); - } else if (enccrd && maccrd) { - if (enccrd->crd_alg == CRYPTO_ARC4) - reinit = 1; - reinit_size = 0x68; - - if (enccrd->crd_flags & CRD_F_ENCRYPT) { - /* Encrypt -> Authenticate */ - pasemi_desc_start(&work_desc, XCT_FUN_O | XCT_FUN_I | XCT_FUN_CRM_ENC_SIG - | XCT_FUN_A | XCT_FUN_FUN(chsel)); - srclen = maccrd->crd_skip + maccrd->crd_len; - } else { - /* Authenticate -> Decrypt */ - pasemi_desc_start(&work_desc, XCT_FUN_O | XCT_FUN_I | XCT_FUN_CRM_SIG_DEC - | XCT_FUN_24BRES | XCT_FUN_FUN(chsel)); - pasemi_desc_build(&work_desc, 0); - pasemi_desc_build(&work_desc, 0); - pasemi_desc_build(&work_desc, 0); - work_desc.postop = PASEMI_CHECK_SIG; - srclen = crp->crp_ilen; - } - - pasemi_desc_hdr(&work_desc, XCT_FUN_SHL(maccrd->crd_skip / 4)); - pasemi_desc_hdr(&work_desc, XCT_FUN_CHL(enccrd->crd_skip - maccrd->crd_skip)); - } else if (!enccrd && maccrd) { - srclen = maccrd->crd_len; - - pasemi_desc_start(&init_desc, - XCT_CTRL_HDR(chsel, 0x58, DMA_FN_HKEY0)); - pasemi_desc_build(&init_desc, - XCT_FUN_SRC_PTR(0x58, ((struct pasemi_session *)ses->dma_addr)->hkey)); - - pasemi_desc_start(&work_desc, XCT_FUN_O | XCT_FUN_I | XCT_FUN_CRM_SIG - | XCT_FUN_A | XCT_FUN_FUN(chsel)); - } - - if (enccrd) { - switch (enccrd->crd_alg) { - case CRYPTO_3DES_CBC: - pasemi_desc_hdr(&work_desc, XCT_FUN_ALG_3DES | - XCT_FUN_BCM_CBC); - ivsize = sizeof(u64); - break; - case CRYPTO_DES_CBC: - pasemi_desc_hdr(&work_desc, XCT_FUN_ALG_DES | - XCT_FUN_BCM_CBC); - ivsize = sizeof(u64); - break; - case CRYPTO_AES_CBC: - pasemi_desc_hdr(&work_desc, XCT_FUN_ALG_AES | - XCT_FUN_BCM_CBC); - ivsize = 2 * sizeof(u64); - break; - case CRYPTO_ARC4: - pasemi_desc_hdr(&work_desc, XCT_FUN_ALG_ARC); - ivsize = 0; - break; - default: - printk(DRV_NAME ": unimplemented enccrd->crd_alg %d\n", - enccrd->crd_alg); - err = -EINVAL; - goto errout; - } - - ivp = (ivsize == sizeof(u64)) ? (caddr_t) &ses->civ[1] : (caddr_t) &ses->civ[0]; - if (enccrd->crd_flags & CRD_F_ENCRYPT) { - if (enccrd->crd_flags & CRD_F_IV_EXPLICIT) - memcpy(ivp, enccrd->crd_iv, ivsize); - /* If IV is not present in the buffer already, it has to be copied there */ - if ((enccrd->crd_flags & CRD_F_IV_PRESENT) == 0) - crypto_copyback(crp->crp_flags, crp->crp_buf, - enccrd->crd_inject, ivsize, ivp); - } else { - if (enccrd->crd_flags & CRD_F_IV_EXPLICIT) - /* IV is provided expicitly in descriptor */ - memcpy(ivp, enccrd->crd_iv, ivsize); - else - /* IV is provided in the packet */ - crypto_copydata(crp->crp_flags, crp->crp_buf, - enccrd->crd_inject, ivsize, - ivp); - } - } - - if (maccrd) { - switch (maccrd->crd_alg) { - case CRYPTO_MD5: - pasemi_desc_hdr(&work_desc, XCT_FUN_SIG_MD5 | - XCT_FUN_HSZ((crp->crp_ilen - maccrd->crd_inject) / 4)); - break; - case CRYPTO_SHA1: - pasemi_desc_hdr(&work_desc, XCT_FUN_SIG_SHA1 | - XCT_FUN_HSZ((crp->crp_ilen - maccrd->crd_inject) / 4)); - break; - case CRYPTO_MD5_HMAC: - pasemi_desc_hdr(&work_desc, XCT_FUN_SIG_HMAC_MD5 | - XCT_FUN_HSZ((crp->crp_ilen - maccrd->crd_inject) / 4)); - break; - case CRYPTO_SHA1_HMAC: - pasemi_desc_hdr(&work_desc, XCT_FUN_SIG_HMAC_SHA1 | - XCT_FUN_HSZ((crp->crp_ilen - maccrd->crd_inject) / 4)); - break; - default: - printk(DRV_NAME ": unimplemented maccrd->crd_alg %d\n", - maccrd->crd_alg); - err = -EINVAL; - goto errout; - } - } - - if (crp->crp_flags & CRYPTO_F_SKBUF) { - /* using SKB buffers */ - skb = (struct sk_buff *)crp->crp_buf; - if (skb_shinfo(skb)->nr_frags) { - printk(DRV_NAME ": skb frags unimplemented\n"); - err = -EINVAL; - goto errout; - } - pasemi_desc_build( - &work_desc, - XCT_FUN_DST_PTR(skb->len, pci_map_single( - sc->dma_pdev, skb->data, - skb->len, DMA_TO_DEVICE))); - pasemi_desc_build( - &work_desc, - XCT_FUN_SRC_PTR( - srclen, pci_map_single( - sc->dma_pdev, skb->data, - srclen, DMA_TO_DEVICE))); - pasemi_desc_hdr(&work_desc, XCT_FUN_LLEN(srclen)); - } else if (crp->crp_flags & CRYPTO_F_IOV) { - /* using IOV buffers */ - uiop = (struct uio *)crp->crp_buf; - if (uiop->uio_iovcnt > 1) { - printk(DRV_NAME ": iov frags unimplemented\n"); - err = -EINVAL; - goto errout; - } - - /* crp_olen is never set; always use crp_ilen */ - pasemi_desc_build( - &work_desc, - XCT_FUN_DST_PTR(crp->crp_ilen, pci_map_single( - sc->dma_pdev, - uiop->uio_iov->iov_base, - crp->crp_ilen, DMA_TO_DEVICE))); - pasemi_desc_hdr(&work_desc, XCT_FUN_LLEN(srclen)); - - pasemi_desc_build( - &work_desc, - XCT_FUN_SRC_PTR(srclen, pci_map_single( - sc->dma_pdev, - uiop->uio_iov->iov_base, - srclen, DMA_TO_DEVICE))); - } else { - /* using contig buffers */ - pasemi_desc_build( - &work_desc, - XCT_FUN_DST_PTR(crp->crp_ilen, pci_map_single( - sc->dma_pdev, - crp->crp_buf, - crp->crp_ilen, DMA_TO_DEVICE))); - pasemi_desc_build( - &work_desc, - XCT_FUN_SRC_PTR(srclen, pci_map_single( - sc->dma_pdev, - crp->crp_buf, srclen, - DMA_TO_DEVICE))); - pasemi_desc_hdr(&work_desc, XCT_FUN_LLEN(srclen)); - } - - spin_lock_irqsave(&txring->fill_lock, flags); - - if (txring->sesn != PASEMI_SESSION(crp->crp_sid)) { - txring->sesn = PASEMI_SESSION(crp->crp_sid); - reinit = 1; - } - - if (enccrd) { - pasemi_desc_start(&init_desc, - XCT_CTRL_HDR(chsel, reinit ? reinit_size : 0x10, DMA_FN_CIV0)); - pasemi_desc_build(&init_desc, - XCT_FUN_SRC_PTR(reinit ? reinit_size : 0x10, ses->dma_addr)); - } - - if (((txring->next_to_fill + pasemi_desc_size(&init_desc) + - pasemi_desc_size(&work_desc)) - - txring->next_to_clean) > TX_RING_SIZE) { - spin_unlock_irqrestore(&txring->fill_lock, flags); - err = ERESTART; - goto errout; - } - - pasemi_ring_add_desc(txring, &init_desc, NULL); - pasemi_ring_add_desc(txring, &work_desc, crp); - - pasemi_ring_incr(sc, chsel, - pasemi_desc_size(&init_desc) + - pasemi_desc_size(&work_desc)); - - spin_unlock_irqrestore(&txring->fill_lock, flags); - - mod_timer(&txring->crypto_timer, jiffies + TIMER_INTERVAL); - - return 0; - -erralg: - printk(DRV_NAME ": unsupported algorithm or algorithm order alg1 %d alg2 %d\n", - crd1->crd_alg, crd2->crd_alg); - err = -EINVAL; - -errout: - if (err != ERESTART) { - crp->crp_etype = err; - crypto_done(crp); - } - return err; -} - -static int pasemi_clean_tx(struct pasemi_softc *sc, int chan) -{ - int i, j, ring_idx; - struct pasemi_fnu_txring *ring = &sc->tx[chan]; - u16 delta_cnt; - int flags, loops = 10; - int desc_size; - struct cryptop *crp; - - spin_lock_irqsave(&ring->clean_lock, flags); - - while ((delta_cnt = (dma_status->tx_sta[sc->base_chan + chan] - & PAS_STATUS_PCNT_M) - ring->total_pktcnt) - && loops--) { - - for (i = 0; i < delta_cnt; i++) { - desc_size = TX_DESC_INFO(ring, ring->next_to_clean).desc_size; - crp = TX_DESC_INFO(ring, ring->next_to_clean).cf_crp; - if (crp) { - ring_idx = 2 * (ring->next_to_clean & (TX_RING_SIZE-1)); - if (TX_DESC_INFO(ring, ring->next_to_clean).desc_postop & PASEMI_CHECK_SIG) { - /* Need to make sure signature matched, - * if not - return error */ - if (!(ring->desc[ring_idx + 1] & (1ULL << 63))) - crp->crp_etype = -EINVAL; - } - crypto_done(TX_DESC_INFO(ring, - ring->next_to_clean).cf_crp); - TX_DESC_INFO(ring, ring->next_to_clean).cf_crp = NULL; - pci_unmap_single( - sc->dma_pdev, - XCT_PTR_ADDR_LEN(ring->desc[ring_idx + 1]), - PCI_DMA_TODEVICE); - - ring->desc[ring_idx] = ring->desc[ring_idx + 1] = 0; - - ring->next_to_clean++; - for (j = 1; j < desc_size; j++) { - ring_idx = 2 * - (ring->next_to_clean & - (TX_RING_SIZE-1)); - pci_unmap_single( - sc->dma_pdev, - XCT_PTR_ADDR_LEN(ring->desc[ring_idx]), - PCI_DMA_TODEVICE); - if (ring->desc[ring_idx + 1]) - pci_unmap_single( - sc->dma_pdev, - XCT_PTR_ADDR_LEN( - ring->desc[ - ring_idx + 1]), - PCI_DMA_TODEVICE); - ring->desc[ring_idx] = - ring->desc[ring_idx + 1] = 0; - ring->next_to_clean++; - } - } else { - for (j = 0; j < desc_size; j++) { - ring_idx = 2 * (ring->next_to_clean & (TX_RING_SIZE-1)); - ring->desc[ring_idx] = - ring->desc[ring_idx + 1] = 0; - ring->next_to_clean++; - } - } - } - - ring->total_pktcnt += delta_cnt; - } - spin_unlock_irqrestore(&ring->clean_lock, flags); - - return 0; -} - -static void sweepup_tx(struct pasemi_softc *sc) -{ - int i; - - for (i = 0; i < sc->sc_num_channels; i++) - pasemi_clean_tx(sc, i); -} - -static irqreturn_t pasemi_intr(int irq, void *arg, struct pt_regs *regs) -{ - struct pasemi_softc *sc = arg; - unsigned int reg; - int chan = irq - sc->base_irq; - int chan_index = sc->base_chan + chan; - u64 stat = dma_status->tx_sta[chan_index]; - - DPRINTF("%s()\n", __FUNCTION__); - - if (!(stat & PAS_STATUS_CAUSE_M)) - return IRQ_NONE; - - pasemi_clean_tx(sc, chan); - - stat = dma_status->tx_sta[chan_index]; - - reg = PAS_IOB_DMA_TXCH_RESET_PINTC | - PAS_IOB_DMA_TXCH_RESET_PCNT(sc->tx[chan].total_pktcnt); - - if (stat & PAS_STATUS_SOFT) - reg |= PAS_IOB_DMA_RXCH_RESET_SINTC; - - out_le32(sc->iob_regs + PAS_IOB_DMA_TXCH_RESET(chan_index), reg); - - - return IRQ_HANDLED; -} - -static int pasemi_dma_setup_tx_resources(struct pasemi_softc *sc, int chan) -{ - u32 val; - int chan_index = chan + sc->base_chan; - int ret; - struct pasemi_fnu_txring *ring; - - ring = &sc->tx[chan]; - - spin_lock_init(&ring->fill_lock); - spin_lock_init(&ring->clean_lock); - - ring->desc_info = kzalloc(sizeof(struct pasemi_desc_info) * - TX_RING_SIZE, GFP_KERNEL); - if (!ring->desc_info) - return -ENOMEM; - - /* Allocate descriptors */ - ring->desc = dma_alloc_coherent(&sc->dma_pdev->dev, - TX_RING_SIZE * - 2 * sizeof(u64), - &ring->dma, GFP_KERNEL); - if (!ring->desc) - return -ENOMEM; - - memset((void *) ring->desc, 0, TX_RING_SIZE * 2 * sizeof(u64)); - - out_le32(sc->iob_regs + PAS_IOB_DMA_TXCH_RESET(chan_index), 0x30); - - ring->total_pktcnt = 0; - - out_le32(sc->dma_regs + PAS_DMA_TXCHAN_BASEL(chan_index), - PAS_DMA_TXCHAN_BASEL_BRBL(ring->dma)); - - val = PAS_DMA_TXCHAN_BASEU_BRBH(ring->dma >> 32); - val |= PAS_DMA_TXCHAN_BASEU_SIZ(TX_RING_SIZE >> 2); - - out_le32(sc->dma_regs + PAS_DMA_TXCHAN_BASEU(chan_index), val); - - out_le32(sc->dma_regs + PAS_DMA_TXCHAN_CFG(chan_index), - PAS_DMA_TXCHAN_CFG_TY_FUNC | - PAS_DMA_TXCHAN_CFG_TATTR(chan) | - PAS_DMA_TXCHAN_CFG_WT(2)); - - /* enable tx channel */ - out_le32(sc->dma_regs + - PAS_DMA_TXCHAN_TCMDSTA(chan_index), - PAS_DMA_TXCHAN_TCMDSTA_EN); - - out_le32(sc->iob_regs + PAS_IOB_DMA_TXCH_CFG(chan_index), - PAS_IOB_DMA_TXCH_CFG_CNTTH(1000)); - - ring->next_to_fill = 0; - ring->next_to_clean = 0; - - snprintf(ring->irq_name, sizeof(ring->irq_name), - "%s%d", "crypto", chan); - - ring->irq = irq_create_mapping(NULL, sc->base_irq + chan); - ret = request_irq(ring->irq, (irq_handler_t) - pasemi_intr, IRQF_DISABLED, ring->irq_name, sc); - if (ret) { - printk(KERN_ERR DRV_NAME ": failed to hook irq %d ret %d\n", - ring->irq, ret); - ring->irq = -1; - return ret; - } - - setup_timer(&ring->crypto_timer, (void *) sweepup_tx, (unsigned long) sc); - - return 0; -} - -static device_method_t pasemi_methods = { - /* crypto device methods */ - DEVMETHOD(cryptodev_newsession, pasemi_newsession), - DEVMETHOD(cryptodev_freesession, pasemi_freesession), - DEVMETHOD(cryptodev_process, pasemi_process), -}; - -/* Set up the crypto device structure, private data, - * and anything else we need before we start */ - -static int __devinit -pasemi_dma_probe(struct pci_dev *pdev, const struct pci_device_id *ent) -{ - struct pasemi_softc *sc; - int ret, i; - - DPRINTF(KERN_ERR "%s()\n", __FUNCTION__); - - sc = kzalloc(sizeof(*sc), GFP_KERNEL); - if (!sc) - return -ENOMEM; - - softc_device_init(sc, DRV_NAME, 1, pasemi_methods); - - pci_set_drvdata(pdev, sc); - - spin_lock_init(&sc->sc_chnlock); - - sc->sc_sessions = (struct pasemi_session **) - kzalloc(PASEMI_INITIAL_SESSIONS * - sizeof(struct pasemi_session *), GFP_ATOMIC); - if (sc->sc_sessions == NULL) { - ret = -ENOMEM; - goto out; - } - - sc->sc_nsessions = PASEMI_INITIAL_SESSIONS; - sc->sc_lastchn = 0; - sc->base_irq = pdev->irq + 6; - sc->base_chan = 6; - sc->sc_cid = -1; - sc->dma_pdev = pdev; - - sc->iob_pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa001, NULL); - if (!sc->iob_pdev) { - dev_err(&pdev->dev, "Can't find I/O Bridge\n"); - ret = -ENODEV; - goto out; - } - - /* This is hardcoded and ugly, but we have some firmware versions - * who don't provide the register space in the device tree. Luckily - * they are at well-known locations so we can just do the math here. - */ - sc->dma_regs = - ioremap(0xe0000000 + (sc->dma_pdev->devfn << 12), 0x2000); - sc->iob_regs = - ioremap(0xe0000000 + (sc->iob_pdev->devfn << 12), 0x2000); - if (!sc->dma_regs || !sc->iob_regs) { - dev_err(&pdev->dev, "Can't map registers\n"); - ret = -ENODEV; - goto out; - } - - dma_status = __ioremap(0xfd800000, 0x1000, 0); - if (!dma_status) { - ret = -ENODEV; - dev_err(&pdev->dev, "Can't map dmastatus space\n"); - goto out; - } - - sc->tx = (struct pasemi_fnu_txring *) - kzalloc(sizeof(struct pasemi_fnu_txring) - * 8, GFP_KERNEL); - if (!sc->tx) { - ret = -ENOMEM; - goto out; - } - - /* Initialize the h/w */ - out_le32(sc->dma_regs + PAS_DMA_COM_CFG, - (in_le32(sc->dma_regs + PAS_DMA_COM_CFG) | - PAS_DMA_COM_CFG_FWF)); - out_le32(sc->dma_regs + PAS_DMA_COM_TXCMD, PAS_DMA_COM_TXCMD_EN); - - for (i = 0; i < PASEMI_FNU_CHANNELS; i++) { - sc->sc_num_channels++; - ret = pasemi_dma_setup_tx_resources(sc, i); - if (ret) - goto out; - } - - sc->sc_cid = crypto_get_driverid(softc_get_device(sc), - CRYPTOCAP_F_HARDWARE); - if (sc->sc_cid < 0) { - printk(KERN_ERR DRV_NAME ": could not get crypto driver id\n"); - ret = -ENXIO; - goto out; - } - - /* register algorithms with the framework */ - printk(DRV_NAME ":"); - - crypto_register(sc->sc_cid, CRYPTO_DES_CBC, 0, 0); - crypto_register(sc->sc_cid, CRYPTO_3DES_CBC, 0, 0); - crypto_register(sc->sc_cid, CRYPTO_AES_CBC, 0, 0); - crypto_register(sc->sc_cid, CRYPTO_ARC4, 0, 0); - crypto_register(sc->sc_cid, CRYPTO_SHA1, 0, 0); - crypto_register(sc->sc_cid, CRYPTO_MD5, 0, 0); - crypto_register(sc->sc_cid, CRYPTO_SHA1_HMAC, 0, 0); - crypto_register(sc->sc_cid, CRYPTO_MD5_HMAC, 0, 0); - - return 0; - -out: - pasemi_dma_remove(pdev); - return ret; -} - -#define MAX_RETRIES 5000 - -static void pasemi_free_tx_resources(struct pasemi_softc *sc, int chan) -{ - struct pasemi_fnu_txring *ring = &sc->tx[chan]; - int chan_index = chan + sc->base_chan; - int retries; - u32 stat; - - /* Stop the channel */ - out_le32(sc->dma_regs + - PAS_DMA_TXCHAN_TCMDSTA(chan_index), - PAS_DMA_TXCHAN_TCMDSTA_ST); - - for (retries = 0; retries < MAX_RETRIES; retries++) { - stat = in_le32(sc->dma_regs + - PAS_DMA_TXCHAN_TCMDSTA(chan_index)); - if (!(stat & PAS_DMA_TXCHAN_TCMDSTA_ACT)) - break; - cond_resched(); - } - - if (stat & PAS_DMA_TXCHAN_TCMDSTA_ACT) - dev_err(&sc->dma_pdev->dev, "Failed to stop tx channel %d\n", - chan_index); - - /* Disable the channel */ - out_le32(sc->dma_regs + - PAS_DMA_TXCHAN_TCMDSTA(chan_index), - 0); - - if (ring->desc_info) - kfree((void *) ring->desc_info); - if (ring->desc) - dma_free_coherent(&sc->dma_pdev->dev, - TX_RING_SIZE * - 2 * sizeof(u64), - (void *) ring->desc, ring->dma); - if (ring->irq != -1) - free_irq(ring->irq, sc); - - del_timer(&ring->crypto_timer); -} - -static void __devexit pasemi_dma_remove(struct pci_dev *pdev) -{ - struct pasemi_softc *sc = pci_get_drvdata(pdev); - int i; - - DPRINTF("%s()\n", __FUNCTION__); - - if (sc->sc_cid >= 0) { - crypto_unregister_all(sc->sc_cid); - } - - if (sc->tx) { - for (i = 0; i < sc->sc_num_channels; i++) - pasemi_free_tx_resources(sc, i); - - kfree(sc->tx); - } - if (sc->sc_sessions) { - for (i = 0; i < sc->sc_nsessions; i++) - kfree(sc->sc_sessions[i]); - kfree(sc->sc_sessions); - } - if (sc->iob_pdev) - pci_dev_put(sc->iob_pdev); - if (sc->dma_regs) - iounmap(sc->dma_regs); - if (sc->iob_regs) - iounmap(sc->iob_regs); - kfree(sc); -} - -static struct pci_device_id pasemi_dma_pci_tbl[] = { - { PCI_DEVICE(PCI_VENDOR_ID_PASEMI, 0xa007) }, -}; - -MODULE_DEVICE_TABLE(pci, pasemi_dma_pci_tbl); - -static struct pci_driver pasemi_dma_driver = { - .name = "pasemi_dma", - .id_table = pasemi_dma_pci_tbl, - .probe = pasemi_dma_probe, - .remove = __devexit_p(pasemi_dma_remove), -}; - -static void __exit pasemi_dma_cleanup_module(void) -{ - pci_unregister_driver(&pasemi_dma_driver); - __iounmap(dma_status); - dma_status = NULL; -} - -int pasemi_dma_init_module(void) -{ - return pci_register_driver(&pasemi_dma_driver); -} - -module_init(pasemi_dma_init_module); -module_exit(pasemi_dma_cleanup_module); - -MODULE_LICENSE("Dual BSD/GPL"); -MODULE_AUTHOR("Egor Martovetsky egor@pasemi.com"); -MODULE_DESCRIPTION("OCF driver for PA Semi PWRficient DMA Crypto Engine"); diff --git a/target/linux/generic-2.4/files/crypto/ocf/pasemi/pasemi_fnu.h b/target/linux/generic-2.4/files/crypto/ocf/pasemi/pasemi_fnu.h deleted file mode 100644 index 1a0dcc8..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/pasemi/pasemi_fnu.h +++ /dev/null @@ -1,410 +0,0 @@ -/* - * Copyright (C) 2007 PA Semi, Inc - * - * Driver for the PA Semi PWRficient DMA Crypto Engine, soft state and - * hardware register layouts. - * - * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef PASEMI_FNU_H -#define PASEMI_FNU_H - -#include <linux/spinlock.h> - -#define PASEMI_SESSION(sid) ((sid) & 0xffffffff) -#define PASEMI_SID(sesn) ((sesn) & 0xffffffff) -#define DPRINTF(a...) if (debug) { printk(DRV_NAME ": " a); } - -/* Must be a power of two */ -#define RX_RING_SIZE 512 -#define TX_RING_SIZE 512 -#define TX_DESC(ring, num) ((ring)->desc[2 * (num & (TX_RING_SIZE-1))]) -#define TX_DESC_INFO(ring, num) ((ring)->desc_info[(num) & (TX_RING_SIZE-1)]) -#define MAX_DESC_SIZE 8 -#define PASEMI_INITIAL_SESSIONS 10 -#define PASEMI_FNU_CHANNELS 8 - -/* DMA descriptor */ -struct pasemi_desc { - u64 quad[2*MAX_DESC_SIZE]; - int quad_cnt; - int size; - int postop; -}; - -/* - * Holds per descriptor data - */ -struct pasemi_desc_info { - int desc_size; - int desc_postop; -#define PASEMI_CHECK_SIG 0x1 - - struct cryptop *cf_crp; -}; - -/* - * Holds per channel data - */ -struct pasemi_fnu_txring { - volatile u64 *desc; - volatile struct - pasemi_desc_info *desc_info; - dma_addr_t dma; - struct timer_list crypto_timer; - spinlock_t fill_lock; - spinlock_t clean_lock; - unsigned int next_to_fill; - unsigned int next_to_clean; - u16 total_pktcnt; - int irq; - int sesn; - char irq_name[10]; -}; - -/* - * Holds data specific to a single pasemi device. - */ -struct pasemi_softc { - softc_device_decl sc_cdev; - struct pci_dev *dma_pdev; /* device backpointer */ - struct pci_dev *iob_pdev; /* device backpointer */ - void __iomem *dma_regs; - void __iomem *iob_regs; - int base_irq; - int base_chan; - int32_t sc_cid; /* crypto tag */ - int sc_nsessions; - struct pasemi_session **sc_sessions; - int sc_num_channels;/* number of crypto channels */ - - /* pointer to the array of txring datastructures, one txring per channel */ - struct pasemi_fnu_txring *tx; - - /* - * mutual exclusion for the channel scheduler - */ - spinlock_t sc_chnlock; - /* last channel used, for now use round-robin to allocate channels */ - int sc_lastchn; -}; - -struct pasemi_session { - u64 civ[2]; - u64 keysz; - u64 key[4]; - u64 ccmd; - u64 hkey[4]; - u64 hseq; - u64 giv[2]; - u64 hiv[4]; - - int used; - dma_addr_t dma_addr; - int chan; -}; - -/* status register layout in IOB region, at 0xfd800000 */ -struct pasdma_status { - u64 rx_sta[64]; - u64 tx_sta[20]; -}; - -#define ALG_IS_CIPHER(alg) ((alg == CRYPTO_DES_CBC) || \ - (alg == CRYPTO_3DES_CBC) || \ - (alg == CRYPTO_AES_CBC) || \ - (alg == CRYPTO_ARC4) || \ - (alg == CRYPTO_NULL_CBC)) - -#define ALG_IS_SIG(alg) ((alg == CRYPTO_MD5) || \ - (alg == CRYPTO_MD5_HMAC) || \ - (alg == CRYPTO_SHA1) || \ - (alg == CRYPTO_SHA1_HMAC) || \ - (alg == CRYPTO_NULL_HMAC)) - -enum { - PAS_DMA_COM_TXCMD = 0x100, /* Transmit Command Register */ - PAS_DMA_COM_TXSTA = 0x104, /* Transmit Status Register */ - PAS_DMA_COM_RXCMD = 0x108, /* Receive Command Register */ - PAS_DMA_COM_RXSTA = 0x10c, /* Receive Status Register */ - PAS_DMA_COM_CFG = 0x114, /* DMA Configuration Register */ -}; - -/* All these registers live in the PCI configuration space for the DMA PCI - * device. Use the normal PCI config access functions for them. - */ - -#define PAS_DMA_COM_CFG_FWF 0x18000000 - -#define PAS_DMA_COM_TXCMD_EN 0x00000001 /* enable */ -#define PAS_DMA_COM_TXSTA_ACT 0x00000001 /* active */ -#define PAS_DMA_COM_RXCMD_EN 0x00000001 /* enable */ -#define PAS_DMA_COM_RXSTA_ACT 0x00000001 /* active */ - -#define _PAS_DMA_TXCHAN_STRIDE 0x20 /* Size per channel */ -#define _PAS_DMA_TXCHAN_TCMDSTA 0x300 /* Command / Status */ -#define _PAS_DMA_TXCHAN_CFG 0x304 /* Configuration */ -#define _PAS_DMA_TXCHAN_DSCRBU 0x308 /* Descriptor BU Allocation */ -#define _PAS_DMA_TXCHAN_INCR 0x310 /* Descriptor increment */ -#define _PAS_DMA_TXCHAN_CNT 0x314 /* Descriptor count/offset */ -#define _PAS_DMA_TXCHAN_BASEL 0x318 /* Descriptor ring base (low) */ -#define _PAS_DMA_TXCHAN_BASEU 0x31c /* (high) */ -#define PAS_DMA_TXCHAN_TCMDSTA(c) (0x300+(c)*_PAS_DMA_TXCHAN_STRIDE) -#define PAS_DMA_TXCHAN_TCMDSTA_EN 0x00000001 /* Enabled */ -#define PAS_DMA_TXCHAN_TCMDSTA_ST 0x00000002 /* Stop interface */ -#define PAS_DMA_TXCHAN_TCMDSTA_ACT 0x00010000 /* Active */ -#define PAS_DMA_TXCHAN_CFG(c) (0x304+(c)*_PAS_DMA_TXCHAN_STRIDE) -#define PAS_DMA_TXCHAN_CFG_TY_FUNC 0x00000002 /* Type = interface */ -#define PAS_DMA_TXCHAN_CFG_TY_IFACE 0x00000000 /* Type = interface */ -#define PAS_DMA_TXCHAN_CFG_TATTR_M 0x0000003c -#define PAS_DMA_TXCHAN_CFG_TATTR_S 2 -#define PAS_DMA_TXCHAN_CFG_TATTR(x) (((x) << PAS_DMA_TXCHAN_CFG_TATTR_S) & \ - PAS_DMA_TXCHAN_CFG_TATTR_M) -#define PAS_DMA_TXCHAN_CFG_WT_M 0x000001c0 -#define PAS_DMA_TXCHAN_CFG_WT_S 6 -#define PAS_DMA_TXCHAN_CFG_WT(x) (((x) << PAS_DMA_TXCHAN_CFG_WT_S) & \ - PAS_DMA_TXCHAN_CFG_WT_M) -#define PAS_DMA_TXCHAN_CFG_LPSQ_FAST 0x00000400 -#define PAS_DMA_TXCHAN_CFG_LPDQ_FAST 0x00000800 -#define PAS_DMA_TXCHAN_CFG_CF 0x00001000 /* Clean first line */ -#define PAS_DMA_TXCHAN_CFG_CL 0x00002000 /* Clean last line */ -#define PAS_DMA_TXCHAN_CFG_UP 0x00004000 /* update tx descr when sent */ -#define PAS_DMA_TXCHAN_INCR(c) (0x310+(c)*_PAS_DMA_TXCHAN_STRIDE) -#define PAS_DMA_TXCHAN_BASEL(c) (0x318+(c)*_PAS_DMA_TXCHAN_STRIDE) -#define PAS_DMA_TXCHAN_BASEL_BRBL_M 0xffffffc0 -#define PAS_DMA_TXCHAN_BASEL_BRBL_S 0 -#define PAS_DMA_TXCHAN_BASEL_BRBL(x) (((x) << PAS_DMA_TXCHAN_BASEL_BRBL_S) & \ - PAS_DMA_TXCHAN_BASEL_BRBL_M) -#define PAS_DMA_TXCHAN_BASEU(c) (0x31c+(c)*_PAS_DMA_TXCHAN_STRIDE) -#define PAS_DMA_TXCHAN_BASEU_BRBH_M 0x00000fff -#define PAS_DMA_TXCHAN_BASEU_BRBH_S 0 -#define PAS_DMA_TXCHAN_BASEU_BRBH(x) (((x) << PAS_DMA_TXCHAN_BASEU_BRBH_S) & \ - PAS_DMA_TXCHAN_BASEU_BRBH_M) -/* # of cache lines worth of buffer ring */ -#define PAS_DMA_TXCHAN_BASEU_SIZ_M 0x3fff0000 -#define PAS_DMA_TXCHAN_BASEU_SIZ_S 16 /* 0 = 16K */ -#define PAS_DMA_TXCHAN_BASEU_SIZ(x) (((x) << PAS_DMA_TXCHAN_BASEU_SIZ_S) & \ - PAS_DMA_TXCHAN_BASEU_SIZ_M) - -#define PAS_STATUS_PCNT_M 0x000000000000ffffull -#define PAS_STATUS_PCNT_S 0 -#define PAS_STATUS_DCNT_M 0x00000000ffff0000ull -#define PAS_STATUS_DCNT_S 16 -#define PAS_STATUS_BPCNT_M 0x0000ffff00000000ull -#define PAS_STATUS_BPCNT_S 32 -#define PAS_STATUS_CAUSE_M 0xf000000000000000ull -#define PAS_STATUS_TIMER 0x1000000000000000ull -#define PAS_STATUS_ERROR 0x2000000000000000ull -#define PAS_STATUS_SOFT 0x4000000000000000ull -#define PAS_STATUS_INT 0x8000000000000000ull - -#define PAS_IOB_DMA_RXCH_CFG(i) (0x1100 + (i)*4) -#define PAS_IOB_DMA_RXCH_CFG_CNTTH_M 0x00000fff -#define PAS_IOB_DMA_RXCH_CFG_CNTTH_S 0 -#define PAS_IOB_DMA_RXCH_CFG_CNTTH(x) (((x) << PAS_IOB_DMA_RXCH_CFG_CNTTH_S) & \ - PAS_IOB_DMA_RXCH_CFG_CNTTH_M) -#define PAS_IOB_DMA_TXCH_CFG(i) (0x1200 + (i)*4) -#define PAS_IOB_DMA_TXCH_CFG_CNTTH_M 0x00000fff -#define PAS_IOB_DMA_TXCH_CFG_CNTTH_S 0 -#define PAS_IOB_DMA_TXCH_CFG_CNTTH(x) (((x) << PAS_IOB_DMA_TXCH_CFG_CNTTH_S) & \ - PAS_IOB_DMA_TXCH_CFG_CNTTH_M) -#define PAS_IOB_DMA_RXCH_STAT(i) (0x1300 + (i)*4) -#define PAS_IOB_DMA_RXCH_STAT_INTGEN 0x00001000 -#define PAS_IOB_DMA_RXCH_STAT_CNTDEL_M 0x00000fff -#define PAS_IOB_DMA_RXCH_STAT_CNTDEL_S 0 -#define PAS_IOB_DMA_RXCH_STAT_CNTDEL(x) (((x) << PAS_IOB_DMA_RXCH_STAT_CNTDEL_S) &\ - PAS_IOB_DMA_RXCH_STAT_CNTDEL_M) -#define PAS_IOB_DMA_TXCH_STAT(i) (0x1400 + (i)*4) -#define PAS_IOB_DMA_TXCH_STAT_INTGEN 0x00001000 -#define PAS_IOB_DMA_TXCH_STAT_CNTDEL_M 0x00000fff -#define PAS_IOB_DMA_TXCH_STAT_CNTDEL_S 0 -#define PAS_IOB_DMA_TXCH_STAT_CNTDEL(x) (((x) << PAS_IOB_DMA_TXCH_STAT_CNTDEL_S) &\ - PAS_IOB_DMA_TXCH_STAT_CNTDEL_M) -#define PAS_IOB_DMA_RXCH_RESET(i) (0x1500 + (i)*4) -#define PAS_IOB_DMA_RXCH_RESET_PCNT_M 0xffff0000 -#define PAS_IOB_DMA_RXCH_RESET_PCNT_S 16 -#define PAS_IOB_DMA_RXCH_RESET_PCNT(x) (((x) << PAS_IOB_DMA_RXCH_RESET_PCNT_S) & \ - PAS_IOB_DMA_RXCH_RESET_PCNT_M) -#define PAS_IOB_DMA_RXCH_RESET_PCNTRST 0x00000020 -#define PAS_IOB_DMA_RXCH_RESET_DCNTRST 0x00000010 -#define PAS_IOB_DMA_RXCH_RESET_TINTC 0x00000008 -#define PAS_IOB_DMA_RXCH_RESET_DINTC 0x00000004 -#define PAS_IOB_DMA_RXCH_RESET_SINTC 0x00000002 -#define PAS_IOB_DMA_RXCH_RESET_PINTC 0x00000001 -#define PAS_IOB_DMA_TXCH_RESET(i) (0x1600 + (i)*4) -#define PAS_IOB_DMA_TXCH_RESET_PCNT_M 0xffff0000 -#define PAS_IOB_DMA_TXCH_RESET_PCNT_S 16 -#define PAS_IOB_DMA_TXCH_RESET_PCNT(x) (((x) << PAS_IOB_DMA_TXCH_RESET_PCNT_S) & \ - PAS_IOB_DMA_TXCH_RESET_PCNT_M) -#define PAS_IOB_DMA_TXCH_RESET_PCNTRST 0x00000020 -#define PAS_IOB_DMA_TXCH_RESET_DCNTRST 0x00000010 -#define PAS_IOB_DMA_TXCH_RESET_TINTC 0x00000008 -#define PAS_IOB_DMA_TXCH_RESET_DINTC 0x00000004 -#define PAS_IOB_DMA_TXCH_RESET_SINTC 0x00000002 -#define PAS_IOB_DMA_TXCH_RESET_PINTC 0x00000001 - -#define PAS_IOB_DMA_COM_TIMEOUTCFG 0x1700 -#define PAS_IOB_DMA_COM_TIMEOUTCFG_TCNT_M 0x00ffffff -#define PAS_IOB_DMA_COM_TIMEOUTCFG_TCNT_S 0 -#define PAS_IOB_DMA_COM_TIMEOUTCFG_TCNT(x) (((x) << PAS_IOB_DMA_COM_TIMEOUTCFG_TCNT_S) & \ - PAS_IOB_DMA_COM_TIMEOUTCFG_TCNT_M) - -/* Transmit descriptor fields */ -#define XCT_MACTX_T 0x8000000000000000ull -#define XCT_MACTX_ST 0x4000000000000000ull -#define XCT_MACTX_NORES 0x0000000000000000ull -#define XCT_MACTX_8BRES 0x1000000000000000ull -#define XCT_MACTX_24BRES 0x2000000000000000ull -#define XCT_MACTX_40BRES 0x3000000000000000ull -#define XCT_MACTX_I 0x0800000000000000ull -#define XCT_MACTX_O 0x0400000000000000ull -#define XCT_MACTX_E 0x0200000000000000ull -#define XCT_MACTX_VLAN_M 0x0180000000000000ull -#define XCT_MACTX_VLAN_NOP 0x0000000000000000ull -#define XCT_MACTX_VLAN_REMOVE 0x0080000000000000ull -#define XCT_MACTX_VLAN_INSERT 0x0100000000000000ull -#define XCT_MACTX_VLAN_REPLACE 0x0180000000000000ull -#define XCT_MACTX_CRC_M 0x0060000000000000ull -#define XCT_MACTX_CRC_NOP 0x0000000000000000ull -#define XCT_MACTX_CRC_INSERT 0x0020000000000000ull -#define XCT_MACTX_CRC_PAD 0x0040000000000000ull -#define XCT_MACTX_CRC_REPLACE 0x0060000000000000ull -#define XCT_MACTX_SS 0x0010000000000000ull -#define XCT_MACTX_LLEN_M 0x00007fff00000000ull -#define XCT_MACTX_LLEN_S 32ull -#define XCT_MACTX_LLEN(x) ((((long)(x)) << XCT_MACTX_LLEN_S) & \ - XCT_MACTX_LLEN_M) -#define XCT_MACTX_IPH_M 0x00000000f8000000ull -#define XCT_MACTX_IPH_S 27ull -#define XCT_MACTX_IPH(x) ((((long)(x)) << XCT_MACTX_IPH_S) & \ - XCT_MACTX_IPH_M) -#define XCT_MACTX_IPO_M 0x0000000007c00000ull -#define XCT_MACTX_IPO_S 22ull -#define XCT_MACTX_IPO(x) ((((long)(x)) << XCT_MACTX_IPO_S) & \ - XCT_MACTX_IPO_M) -#define XCT_MACTX_CSUM_M 0x0000000000000060ull -#define XCT_MACTX_CSUM_NOP 0x0000000000000000ull -#define XCT_MACTX_CSUM_TCP 0x0000000000000040ull -#define XCT_MACTX_CSUM_UDP 0x0000000000000060ull -#define XCT_MACTX_V6 0x0000000000000010ull -#define XCT_MACTX_C 0x0000000000000004ull -#define XCT_MACTX_AL2 0x0000000000000002ull - -#define XCT_PTR_T 0x8000000000000000ull -#define XCT_PTR_LEN_M 0x7ffff00000000000ull -#define XCT_PTR_LEN_S 44 -#define XCT_PTR_LEN(x) ((((long)(x)) << XCT_PTR_LEN_S) & \ - XCT_PTR_LEN_M) -#define XCT_PTR_ADDR_M 0x00000fffffffffffull -#define XCT_PTR_ADDR_S 0 -#define XCT_PTR_ADDR(x) ((((long)(x)) << XCT_PTR_ADDR_S) & \ - XCT_PTR_ADDR_M) - -/* Function descriptor fields */ -#define XCT_FUN_T 0x8000000000000000ull -#define XCT_FUN_ST 0x4000000000000000ull -#define XCT_FUN_NORES 0x0000000000000000ull -#define XCT_FUN_8BRES 0x1000000000000000ull -#define XCT_FUN_24BRES 0x2000000000000000ull -#define XCT_FUN_40BRES 0x3000000000000000ull -#define XCT_FUN_I 0x0800000000000000ull -#define XCT_FUN_O 0x0400000000000000ull -#define XCT_FUN_E 0x0200000000000000ull -#define XCT_FUN_FUN_S 54 -#define XCT_FUN_FUN_M 0x01c0000000000000ull -#define XCT_FUN_FUN(num) ((((long)(num)) << XCT_FUN_FUN_S) & \ - XCT_FUN_FUN_M) -#define XCT_FUN_CRM_NOP 0x0000000000000000ull -#define XCT_FUN_CRM_SIG 0x0008000000000000ull -#define XCT_FUN_CRM_ENC 0x0010000000000000ull -#define XCT_FUN_CRM_DEC 0x0018000000000000ull -#define XCT_FUN_CRM_SIG_ENC 0x0020000000000000ull -#define XCT_FUN_CRM_ENC_SIG 0x0028000000000000ull -#define XCT_FUN_CRM_SIG_DEC 0x0030000000000000ull -#define XCT_FUN_CRM_DEC_SIG 0x0038000000000000ull -#define XCT_FUN_LLEN_M 0x0007ffff00000000ull -#define XCT_FUN_LLEN_S 32ULL -#define XCT_FUN_LLEN(x) ((((long)(x)) << XCT_FUN_LLEN_S) & \ - XCT_FUN_LLEN_M) -#define XCT_FUN_SHL_M 0x00000000f8000000ull -#define XCT_FUN_SHL_S 27ull -#define XCT_FUN_SHL(x) ((((long)(x)) << XCT_FUN_SHL_S) & \ - XCT_FUN_SHL_M) -#define XCT_FUN_CHL_M 0x0000000007c00000ull -#define XCT_FUN_CHL_S 22ull -#define XCT_FUN_CHL(x) ((((long)(x)) << XCT_FUN_CHL_S) & \ - XCT_FUN_CHL_M) -#define XCT_FUN_HSZ_M 0x00000000003c0000ull -#define XCT_FUN_HSZ_S 18ull -#define XCT_FUN_HSZ(x) ((((long)(x)) << XCT_FUN_HSZ_S) & \ - XCT_FUN_HSZ_M) -#define XCT_FUN_ALG_DES 0x0000000000000000ull -#define XCT_FUN_ALG_3DES 0x0000000000008000ull -#define XCT_FUN_ALG_AES 0x0000000000010000ull -#define XCT_FUN_ALG_ARC 0x0000000000018000ull -#define XCT_FUN_ALG_KASUMI 0x0000000000020000ull -#define XCT_FUN_BCM_ECB 0x0000000000000000ull -#define XCT_FUN_BCM_CBC 0x0000000000001000ull -#define XCT_FUN_BCM_CFB 0x0000000000002000ull -#define XCT_FUN_BCM_OFB 0x0000000000003000ull -#define XCT_FUN_BCM_CNT 0x0000000000003800ull -#define XCT_FUN_BCM_KAS_F8 0x0000000000002800ull -#define XCT_FUN_BCM_KAS_F9 0x0000000000001800ull -#define XCT_FUN_BCP_NO_PAD 0x0000000000000000ull -#define XCT_FUN_BCP_ZRO 0x0000000000000200ull -#define XCT_FUN_BCP_PL 0x0000000000000400ull -#define XCT_FUN_BCP_INCR 0x0000000000000600ull -#define XCT_FUN_SIG_MD5 (0ull << 4) -#define XCT_FUN_SIG_SHA1 (2ull << 4) -#define XCT_FUN_SIG_HMAC_MD5 (8ull << 4) -#define XCT_FUN_SIG_HMAC_SHA1 (10ull << 4) -#define XCT_FUN_A 0x0000000000000008ull -#define XCT_FUN_C 0x0000000000000004ull -#define XCT_FUN_AL2 0x0000000000000002ull -#define XCT_FUN_SE 0x0000000000000001ull - -#define XCT_FUN_SRC_PTR(len, addr) (XCT_PTR_LEN(len) | XCT_PTR_ADDR(addr)) -#define XCT_FUN_DST_PTR(len, addr) (XCT_FUN_SRC_PTR(len, addr) | \ - 0x8000000000000000ull) - -#define XCT_CTRL_HDR_FUN_NUM_M 0x01c0000000000000ull -#define XCT_CTRL_HDR_FUN_NUM_S 54 -#define XCT_CTRL_HDR_LEN_M 0x0007ffff00000000ull -#define XCT_CTRL_HDR_LEN_S 32 -#define XCT_CTRL_HDR_REG_M 0x00000000000000ffull -#define XCT_CTRL_HDR_REG_S 0 - -#define XCT_CTRL_HDR(funcN,len,reg) (0x9400000000000000ull | \ - ((((long)(funcN)) << XCT_CTRL_HDR_FUN_NUM_S) \ - & XCT_CTRL_HDR_FUN_NUM_M) | \ - ((((long)(len)) << \ - XCT_CTRL_HDR_LEN_S) & XCT_CTRL_HDR_LEN_M) | \ - ((((long)(reg)) << \ - XCT_CTRL_HDR_REG_S) & XCT_CTRL_HDR_REG_M)) - -/* Function config command options */ -#define DMA_CALGO_DES 0x00 -#define DMA_CALGO_3DES 0x01 -#define DMA_CALGO_AES 0x02 -#define DMA_CALGO_ARC 0x03 - -#define DMA_FN_CIV0 0x02 -#define DMA_FN_CIV1 0x03 -#define DMA_FN_HKEY0 0x0a - -#define XCT_PTR_ADDR_LEN(ptr) ((ptr) & XCT_PTR_ADDR_M), \ - (((ptr) & XCT_PTR_LEN_M) >> XCT_PTR_LEN_S) - -#endif /* PASEMI_FNU_H */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/random.c b/target/linux/generic-2.4/files/crypto/ocf/random.c deleted file mode 100644 index 38dad13..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/random.c +++ /dev/null @@ -1,322 +0,0 @@ -/* - * A system independant way of adding entropy to the kernels pool - * this way the drivers can focus on the real work and we can take - * care of pushing it to the appropriate place in the kernel. - * - * This should be fast and callable from timers/interrupts - * - * Written by David McCullough <david_mccullough@mcafee.com> - * Copyright (C) 2006-2010 David McCullough - * Copyright (C) 2004-2005 Intel Corporation. - * - * LICENSE TERMS - * - * The free distribution and use of this software in both source and binary - * form is allowed (with or without changes) provided that: - * - * 1. distributions of this source code include the above copyright - * notice, this list of conditions and the following disclaimer; - * - * 2. distributions in binary form include the above copyright - * notice, this list of conditions and the following disclaimer - * in the documentation and/or other associated materials; - * - * 3. the copyright holder's name is not used to endorse products - * built using this software without specific written permission. - * - * ALTERNATIVELY, provided that this notice is retained in full, this product - * may be distributed under the terms of the GNU General Public License (GPL), - * in which case the provisions of the GPL apply INSTEAD OF those given above. - * - * DISCLAIMER - * - * This software is provided 'as is' with no explicit or implied warranties - * in respect of its properties, including, but not limited to, correctness - * and/or fitness for purpose. - */ - -#ifndef AUTOCONF_INCLUDED -#include <linux/config.h> -#endif -#include <linux/module.h> -#include <linux/init.h> -#include <linux/list.h> -#include <linux/slab.h> -#include <linux/wait.h> -#include <linux/sched.h> -#include <linux/spinlock.h> -#include <linux/version.h> -#include <linux/unistd.h> -#include <linux/poll.h> -#include <linux/random.h> -#include <cryptodev.h> - -#ifdef CONFIG_OCF_FIPS -#include "rndtest.h" -#endif - -#ifndef HAS_RANDOM_INPUT_WAIT -#error "Please do not enable OCF_RANDOMHARVEST unless you have applied patches" -#endif - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) -#include <linux/sched.h> -#define kill_proc(p,s,v) send_sig(s,find_task_by_vpid(p),0) -#endif - -/* - * a hack to access the debug levels from the crypto driver - */ -extern int crypto_debug; -#define debug crypto_debug - -/* - * a list of all registered random providers - */ -static LIST_HEAD(random_ops); -static int started = 0; -static int initted = 0; - -struct random_op { - struct list_head random_list; - u_int32_t driverid; - int (*read_random)(void *arg, u_int32_t *buf, int len); - void *arg; -}; - -static int random_proc(void *arg); - -static pid_t randomproc = (pid_t) -1; -static spinlock_t random_lock; - -/* - * just init the spin locks - */ -static int -crypto_random_init(void) -{ - spin_lock_init(&random_lock); - initted = 1; - return(0); -} - -/* - * Add the given random reader to our list (if not present) - * and start the thread (if not already started) - * - * we have to assume that driver id is ok for now - */ -int -crypto_rregister( - u_int32_t driverid, - int (*read_random)(void *arg, u_int32_t *buf, int len), - void *arg) -{ - unsigned long flags; - int ret = 0; - struct random_op *rops, *tmp; - - dprintk("%s,%d: %s(0x%x, %p, %p)\n", __FILE__, __LINE__, - __FUNCTION__, driverid, read_random, arg); - - if (!initted) - crypto_random_init(); - -#if 0 - struct cryptocap *cap; - - cap = crypto_checkdriver(driverid); - if (!cap) - return EINVAL; -#endif - - list_for_each_entry_safe(rops, tmp, &random_ops, random_list) { - if (rops->driverid == driverid && rops->read_random == read_random) - return EEXIST; - } - - rops = (struct random_op *) kmalloc(sizeof(*rops), GFP_KERNEL); - if (!rops) - return ENOMEM; - - rops->driverid = driverid; - rops->read_random = read_random; - rops->arg = arg; - - spin_lock_irqsave(&random_lock, flags); - list_add_tail(&rops->random_list, &random_ops); - if (!started) { - randomproc = kernel_thread(random_proc, NULL, CLONE_FS|CLONE_FILES); - if (randomproc < 0) { - ret = randomproc; - printk("crypto: crypto_rregister cannot start random thread; " - "error %d", ret); - } else - started = 1; - } - spin_unlock_irqrestore(&random_lock, flags); - - return ret; -} -EXPORT_SYMBOL(crypto_rregister); - -int -crypto_runregister_all(u_int32_t driverid) -{ - struct random_op *rops, *tmp; - unsigned long flags; - - dprintk("%s,%d: %s(0x%x)\n", __FILE__, __LINE__, __FUNCTION__, driverid); - - list_for_each_entry_safe(rops, tmp, &random_ops, random_list) { - if (rops->driverid == driverid) { - list_del(&rops->random_list); - kfree(rops); - } - } - - spin_lock_irqsave(&random_lock, flags); - if (list_empty(&random_ops) && started) - kill_proc(randomproc, SIGKILL, 1); - spin_unlock_irqrestore(&random_lock, flags); - return(0); -} -EXPORT_SYMBOL(crypto_runregister_all); - -/* - * while we can add entropy to random.c continue to read random data from - * the drivers and push it to random. - */ -static int -random_proc(void *arg) -{ - int n; - int wantcnt; - int bufcnt = 0; - int retval = 0; - int *buf = NULL; - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) - daemonize(); - spin_lock_irq(¤t->sigmask_lock); - sigemptyset(¤t->blocked); - recalc_sigpending(current); - spin_unlock_irq(¤t->sigmask_lock); - sprintf(current->comm, "ocf-random"); -#else - daemonize("ocf-random"); - allow_signal(SIGKILL); -#endif - - (void) get_fs(); - set_fs(get_ds()); - -#ifdef CONFIG_OCF_FIPS -#define NUM_INT (RNDTEST_NBYTES/sizeof(int)) -#else -#define NUM_INT 32 -#endif - - /* - * some devices can transferr their RNG data direct into memory, - * so make sure it is device friendly - */ - buf = kmalloc(NUM_INT * sizeof(int), GFP_DMA); - if (NULL == buf) { - printk("crypto: RNG could not allocate memory\n"); - retval = -ENOMEM; - goto bad_alloc; - } - - wantcnt = NUM_INT; /* start by adding some entropy */ - - /* - * its possible due to errors or driver removal that we no longer - * have anything to do, if so exit or we will consume all the CPU - * doing nothing - */ - while (!list_empty(&random_ops)) { - struct random_op *rops, *tmp; - -#ifdef CONFIG_OCF_FIPS - if (wantcnt) - wantcnt = NUM_INT; /* FIPs mode can do 20000 bits or none */ -#endif - - /* see if we can get enough entropy to make the world - * a better place. - */ - while (bufcnt < wantcnt && bufcnt < NUM_INT) { - list_for_each_entry_safe(rops, tmp, &random_ops, random_list) { - - n = (*rops->read_random)(rops->arg, &buf[bufcnt], - NUM_INT - bufcnt); - - /* on failure remove the random number generator */ - if (n == -1) { - list_del(&rops->random_list); - printk("crypto: RNG (driverid=0x%x) failed, disabling\n", - rops->driverid); - kfree(rops); - } else if (n > 0) - bufcnt += n; - } - /* give up CPU for a bit, just in case as this is a loop */ - schedule(); - } - - -#ifdef CONFIG_OCF_FIPS - if (bufcnt > 0 && rndtest_buf((unsigned char *) &buf[0])) { - dprintk("crypto: buffer had fips errors, discarding\n"); - bufcnt = 0; - } -#endif - - /* - * if we have a certified buffer, we can send some data - * to /dev/random and move along - */ - if (bufcnt > 0) { - /* add what we have */ - random_input_words(buf, bufcnt, bufcnt*sizeof(int)*8); - bufcnt = 0; - } - - /* give up CPU for a bit so we don't hog while filling */ - schedule(); - - /* wait for needing more */ - wantcnt = random_input_wait(); - - if (wantcnt <= 0) - wantcnt = 0; /* try to get some info again */ - else - /* round up to one word or we can loop forever */ - wantcnt = (wantcnt + (sizeof(int)*8)) / (sizeof(int)*8); - if (wantcnt > NUM_INT) { - wantcnt = NUM_INT; - } - - if (signal_pending(current)) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) - spin_lock_irq(¤t->sigmask_lock); -#endif - flush_signals(current); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) - spin_unlock_irq(¤t->sigmask_lock); -#endif - } - } - - kfree(buf); - -bad_alloc: - spin_lock_irq(&random_lock); - randomproc = (pid_t) -1; - started = 0; - spin_unlock_irq(&random_lock); - - return retval; -} - diff --git a/target/linux/generic-2.4/files/crypto/ocf/rndtest.c b/target/linux/generic-2.4/files/crypto/ocf/rndtest.c deleted file mode 100644 index b31e1a6..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/rndtest.c +++ /dev/null @@ -1,300 +0,0 @@ -/* $OpenBSD$ */ - -/* - * OCF/Linux port done by David McCullough <david_mccullough@mcafee.com> - * Copyright (C) 2006-2010 David McCullough - * Copyright (C) 2004-2005 Intel Corporation. - * The license and original author are listed below. - * - * Copyright (c) 2002 Jason L. Wright (jason@thought.net) - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Jason L. Wright - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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 AUTOCONF_INCLUDED -#include <linux/config.h> -#endif -#include <linux/module.h> -#include <linux/list.h> -#include <linux/wait.h> -#include <linux/time.h> -#include <linux/version.h> -#include <linux/unistd.h> -#include <linux/kernel.h> -#include <linux/string.h> -#include <linux/time.h> -#include <cryptodev.h> -#include "rndtest.h" - -static struct rndtest_stats rndstats; - -static void rndtest_test(struct rndtest_state *); - -/* The tests themselves */ -static int rndtest_monobit(struct rndtest_state *); -static int rndtest_runs(struct rndtest_state *); -static int rndtest_longruns(struct rndtest_state *); -static int rndtest_chi_4(struct rndtest_state *); - -static int rndtest_runs_check(struct rndtest_state *, int, int *); -static void rndtest_runs_record(struct rndtest_state *, int, int *); - -static const struct rndtest_testfunc { - int (*test)(struct rndtest_state *); -} rndtest_funcs[] = { - { rndtest_monobit }, - { rndtest_runs }, - { rndtest_chi_4 }, - { rndtest_longruns }, -}; - -#define RNDTEST_NTESTS (sizeof(rndtest_funcs)/sizeof(rndtest_funcs[0])) - -static void -rndtest_test(struct rndtest_state *rsp) -{ - int i, rv = 0; - - rndstats.rst_tests++; - for (i = 0; i < RNDTEST_NTESTS; i++) - rv |= (*rndtest_funcs[i].test)(rsp); - rsp->rs_discard = (rv != 0); -} - - -extern int crypto_debug; -#define rndtest_verbose 2 -#define rndtest_report(rsp, failure, fmt, a...) \ - { if (failure || crypto_debug) { printk("rng_test: " fmt "\n", a); } else; } - -#define RNDTEST_MONOBIT_MINONES 9725 -#define RNDTEST_MONOBIT_MAXONES 10275 - -static int -rndtest_monobit(struct rndtest_state *rsp) -{ - int i, ones = 0, j; - u_int8_t r; - - for (i = 0; i < RNDTEST_NBYTES; i++) { - r = rsp->rs_buf[i]; - for (j = 0; j < 8; j++, r <<= 1) - if (r & 0x80) - ones++; - } - if (ones > RNDTEST_MONOBIT_MINONES && - ones < RNDTEST_MONOBIT_MAXONES) { - if (rndtest_verbose > 1) - rndtest_report(rsp, 0, "monobit pass (%d < %d < %d)", - RNDTEST_MONOBIT_MINONES, ones, - RNDTEST_MONOBIT_MAXONES); - return (0); - } else { - if (rndtest_verbose) - rndtest_report(rsp, 1, - "monobit failed (%d ones)", ones); - rndstats.rst_monobit++; - return (-1); - } -} - -#define RNDTEST_RUNS_NINTERVAL 6 - -static const struct rndtest_runs_tabs { - u_int16_t min, max; -} rndtest_runs_tab[] = { - { 2343, 2657 }, - { 1135, 1365 }, - { 542, 708 }, - { 251, 373 }, - { 111, 201 }, - { 111, 201 }, -}; - -static int -rndtest_runs(struct rndtest_state *rsp) -{ - int i, j, ones, zeros, rv = 0; - int onei[RNDTEST_RUNS_NINTERVAL], zeroi[RNDTEST_RUNS_NINTERVAL]; - u_int8_t c; - - bzero(onei, sizeof(onei)); - bzero(zeroi, sizeof(zeroi)); - ones = zeros = 0; - for (i = 0; i < RNDTEST_NBYTES; i++) { - c = rsp->rs_buf[i]; - for (j = 0; j < 8; j++, c <<= 1) { - if (c & 0x80) { - ones++; - rndtest_runs_record(rsp, zeros, zeroi); - zeros = 0; - } else { - zeros++; - rndtest_runs_record(rsp, ones, onei); - ones = 0; - } - } - } - rndtest_runs_record(rsp, ones, onei); - rndtest_runs_record(rsp, zeros, zeroi); - - rv |= rndtest_runs_check(rsp, 0, zeroi); - rv |= rndtest_runs_check(rsp, 1, onei); - - if (rv) - rndstats.rst_runs++; - - return (rv); -} - -static void -rndtest_runs_record(struct rndtest_state *rsp, int len, int *intrv) -{ - if (len == 0) - return; - if (len > RNDTEST_RUNS_NINTERVAL) - len = RNDTEST_RUNS_NINTERVAL; - len -= 1; - intrv[len]++; -} - -static int -rndtest_runs_check(struct rndtest_state *rsp, int val, int *src) -{ - int i, rv = 0; - - for (i = 0; i < RNDTEST_RUNS_NINTERVAL; i++) { - if (src[i] < rndtest_runs_tab[i].min || - src[i] > rndtest_runs_tab[i].max) { - rndtest_report(rsp, 1, - "%s interval %d failed (%d, %d-%d)", - val ? "ones" : "zeros", - i + 1, src[i], rndtest_runs_tab[i].min, - rndtest_runs_tab[i].max); - rv = -1; - } else { - rndtest_report(rsp, 0, - "runs pass %s interval %d (%d < %d < %d)", - val ? "ones" : "zeros", - i + 1, rndtest_runs_tab[i].min, src[i], - rndtest_runs_tab[i].max); - } - } - return (rv); -} - -static int -rndtest_longruns(struct rndtest_state *rsp) -{ - int i, j, ones = 0, zeros = 0, maxones = 0, maxzeros = 0; - u_int8_t c; - - for (i = 0; i < RNDTEST_NBYTES; i++) { - c = rsp->rs_buf[i]; - for (j = 0; j < 8; j++, c <<= 1) { - if (c & 0x80) { - zeros = 0; - ones++; - if (ones > maxones) - maxones = ones; - } else { - ones = 0; - zeros++; - if (zeros > maxzeros) - maxzeros = zeros; - } - } - } - - if (maxones < 26 && maxzeros < 26) { - rndtest_report(rsp, 0, "longruns pass (%d ones, %d zeros)", - maxones, maxzeros); - return (0); - } else { - rndtest_report(rsp, 1, "longruns fail (%d ones, %d zeros)", - maxones, maxzeros); - rndstats.rst_longruns++; - return (-1); - } -} - -/* - * chi^2 test over 4 bits: (this is called the poker test in FIPS 140-2, - * but it is really the chi^2 test over 4 bits (the poker test as described - * by Knuth vol 2 is something different, and I take him as authoritative - * on nomenclature over NIST). - */ -#define RNDTEST_CHI4_K 16 -#define RNDTEST_CHI4_K_MASK (RNDTEST_CHI4_K - 1) - -/* - * The unnormalized values are used so that we don't have to worry about - * fractional precision. The "real" value is found by: - * (V - 1562500) * (16 / 5000) = Vn (where V is the unnormalized value) - */ -#define RNDTEST_CHI4_VMIN 1563181 /* 2.1792 */ -#define RNDTEST_CHI4_VMAX 1576929 /* 46.1728 */ - -static int -rndtest_chi_4(struct rndtest_state *rsp) -{ - unsigned int freq[RNDTEST_CHI4_K], i, sum; - - for (i = 0; i < RNDTEST_CHI4_K; i++) - freq[i] = 0; - - /* Get number of occurances of each 4 bit pattern */ - for (i = 0; i < RNDTEST_NBYTES; i++) { - freq[(rsp->rs_buf[i] >> 4) & RNDTEST_CHI4_K_MASK]++; - freq[(rsp->rs_buf[i] >> 0) & RNDTEST_CHI4_K_MASK]++; - } - - for (i = 0, sum = 0; i < RNDTEST_CHI4_K; i++) - sum += freq[i] * freq[i]; - - if (sum >= 1563181 && sum <= 1576929) { - rndtest_report(rsp, 0, "chi^2(4): pass (sum %u)", sum); - return (0); - } else { - rndtest_report(rsp, 1, "chi^2(4): failed (sum %u)", sum); - rndstats.rst_chi++; - return (-1); - } -} - -int -rndtest_buf(unsigned char *buf) -{ - struct rndtest_state rsp; - - memset(&rsp, 0, sizeof(rsp)); - rsp.rs_buf = buf; - rndtest_test(&rsp); - return(rsp.rs_discard); -} - diff --git a/target/linux/generic-2.4/files/crypto/ocf/rndtest.h b/target/linux/generic-2.4/files/crypto/ocf/rndtest.h deleted file mode 100644 index e9d8ec8..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/rndtest.h +++ /dev/null @@ -1,54 +0,0 @@ -/* $FreeBSD: src/sys/dev/rndtest/rndtest.h,v 1.1 2003/03/11 22:54:44 sam Exp $ */ -/* $OpenBSD$ */ - -/* - * Copyright (c) 2002 Jason L. Wright (jason@thought.net) - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Jason L. Wright - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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. - */ - - -/* Some of the tests depend on these values */ -#define RNDTEST_NBYTES 2500 -#define RNDTEST_NBITS (8 * RNDTEST_NBYTES) - -struct rndtest_state { - int rs_discard; /* discard/accept random data */ - u_int8_t *rs_buf; -}; - -struct rndtest_stats { - u_int32_t rst_discard; /* number of bytes discarded */ - u_int32_t rst_tests; /* number of test runs */ - u_int32_t rst_monobit; /* monobit test failures */ - u_int32_t rst_runs; /* 0/1 runs failures */ - u_int32_t rst_longruns; /* longruns failures */ - u_int32_t rst_chi; /* chi^2 failures */ -}; - -extern int rndtest_buf(unsigned char *buf); diff --git a/target/linux/generic-2.4/files/crypto/ocf/safe/Makefile b/target/linux/generic-2.4/files/crypto/ocf/safe/Makefile deleted file mode 100644 index 9a36b08..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/safe/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# for SGlinux builds --include $(ROOTDIR)/modules/.config - -obj-$(CONFIG_OCF_SAFE) += safe.o - -obj ?= . -EXTRA_CFLAGS += -I$(obj)/.. -I$(obj)/ - -ifdef TOPDIR --include $(TOPDIR)/Rules.make -endif - diff --git a/target/linux/generic-2.4/files/crypto/ocf/safe/md5.c b/target/linux/generic-2.4/files/crypto/ocf/safe/md5.c deleted file mode 100644 index 077c42e..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/safe/md5.c +++ /dev/null @@ -1,308 +0,0 @@ -/* $KAME: md5.c,v 1.5 2000/11/08 06:13:08 itojun Exp $ */ -/* - * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. - * 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. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT 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 PROJECT 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. - */ - -#if 0 -#include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/crypto/md5.c,v 1.9 2004/01/27 19:49:19 des Exp $"); - -#include <sys/types.h> -#include <sys/cdefs.h> -#include <sys/time.h> -#include <sys/systm.h> -#include <crypto/md5.h> -#endif - -#define SHIFT(X, s) (((X) << (s)) | ((X) >> (32 - (s)))) - -#define F(X, Y, Z) (((X) & (Y)) | ((~X) & (Z))) -#define G(X, Y, Z) (((X) & (Z)) | ((Y) & (~Z))) -#define H(X, Y, Z) ((X) ^ (Y) ^ (Z)) -#define I(X, Y, Z) ((Y) ^ ((X) | (~Z))) - -#define ROUND1(a, b, c, d, k, s, i) { \ - (a) = (a) + F((b), (c), (d)) + X[(k)] + T[(i)]; \ - (a) = SHIFT((a), (s)); \ - (a) = (b) + (a); \ -} - -#define ROUND2(a, b, c, d, k, s, i) { \ - (a) = (a) + G((b), (c), (d)) + X[(k)] + T[(i)]; \ - (a) = SHIFT((a), (s)); \ - (a) = (b) + (a); \ -} - -#define ROUND3(a, b, c, d, k, s, i) { \ - (a) = (a) + H((b), (c), (d)) + X[(k)] + T[(i)]; \ - (a) = SHIFT((a), (s)); \ - (a) = (b) + (a); \ -} - -#define ROUND4(a, b, c, d, k, s, i) { \ - (a) = (a) + I((b), (c), (d)) + X[(k)] + T[(i)]; \ - (a) = SHIFT((a), (s)); \ - (a) = (b) + (a); \ -} - -#define Sa 7 -#define Sb 12 -#define Sc 17 -#define Sd 22 - -#define Se 5 -#define Sf 9 -#define Sg 14 -#define Sh 20 - -#define Si 4 -#define Sj 11 -#define Sk 16 -#define Sl 23 - -#define Sm 6 -#define Sn 10 -#define So 15 -#define Sp 21 - -#define MD5_A0 0x67452301 -#define MD5_B0 0xefcdab89 -#define MD5_C0 0x98badcfe -#define MD5_D0 0x10325476 - -/* Integer part of 4294967296 times abs(sin(i)), where i is in radians. */ -static const u_int32_t T[65] = { - 0, - 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, - 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, - 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, - 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821, - - 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, - 0xd62f105d, 0x2441453, 0xd8a1e681, 0xe7d3fbc8, - 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, - 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a, - - 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, - 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70, - 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x4881d05, - 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665, - - 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, - 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1, - 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, - 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391, -}; - -static const u_int8_t md5_paddat[MD5_BUFLEN] = { - 0x80, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, -}; - -static void md5_calc(u_int8_t *, md5_ctxt *); - -void md5_init(ctxt) - md5_ctxt *ctxt; -{ - ctxt->md5_n = 0; - ctxt->md5_i = 0; - ctxt->md5_sta = MD5_A0; - ctxt->md5_stb = MD5_B0; - ctxt->md5_stc = MD5_C0; - ctxt->md5_std = MD5_D0; - bzero(ctxt->md5_buf, sizeof(ctxt->md5_buf)); -} - -void md5_loop(ctxt, input, len) - md5_ctxt *ctxt; - u_int8_t *input; - u_int len; /* number of bytes */ -{ - u_int gap, i; - - ctxt->md5_n += len * 8; /* byte to bit */ - gap = MD5_BUFLEN - ctxt->md5_i; - - if (len >= gap) { - bcopy((void *)input, (void *)(ctxt->md5_buf + ctxt->md5_i), - gap); - md5_calc(ctxt->md5_buf, ctxt); - - for (i = gap; i + MD5_BUFLEN <= len; i += MD5_BUFLEN) { - md5_calc((u_int8_t *)(input + i), ctxt); - } - - ctxt->md5_i = len - i; - bcopy((void *)(input + i), (void *)ctxt->md5_buf, ctxt->md5_i); - } else { - bcopy((void *)input, (void *)(ctxt->md5_buf + ctxt->md5_i), - len); - ctxt->md5_i += len; - } -} - -void md5_pad(ctxt) - md5_ctxt *ctxt; -{ - u_int gap; - - /* Don't count up padding. Keep md5_n. */ - gap = MD5_BUFLEN - ctxt->md5_i; - if (gap > 8) { - bcopy(md5_paddat, - (void *)(ctxt->md5_buf + ctxt->md5_i), - gap - sizeof(ctxt->md5_n)); - } else { - /* including gap == 8 */ - bcopy(md5_paddat, (void *)(ctxt->md5_buf + ctxt->md5_i), - gap); - md5_calc(ctxt->md5_buf, ctxt); - bcopy((md5_paddat + gap), - (void *)ctxt->md5_buf, - MD5_BUFLEN - sizeof(ctxt->md5_n)); - } - - /* 8 byte word */ -#if BYTE_ORDER == LITTLE_ENDIAN - bcopy(&ctxt->md5_n8[0], &ctxt->md5_buf[56], 8); -#endif -#if BYTE_ORDER == BIG_ENDIAN - ctxt->md5_buf[56] = ctxt->md5_n8[7]; - ctxt->md5_buf[57] = ctxt->md5_n8[6]; - ctxt->md5_buf[58] = ctxt->md5_n8[5]; - ctxt->md5_buf[59] = ctxt->md5_n8[4]; - ctxt->md5_buf[60] = ctxt->md5_n8[3]; - ctxt->md5_buf[61] = ctxt->md5_n8[2]; - ctxt->md5_buf[62] = ctxt->md5_n8[1]; - ctxt->md5_buf[63] = ctxt->md5_n8[0]; -#endif - - md5_calc(ctxt->md5_buf, ctxt); -} - -void md5_result(digest, ctxt) - u_int8_t *digest; - md5_ctxt *ctxt; -{ - /* 4 byte words */ -#if BYTE_ORDER == LITTLE_ENDIAN - bcopy(&ctxt->md5_st8[0], digest, 16); -#endif -#if BYTE_ORDER == BIG_ENDIAN - digest[ 0] = ctxt->md5_st8[ 3]; digest[ 1] = ctxt->md5_st8[ 2]; - digest[ 2] = ctxt->md5_st8[ 1]; digest[ 3] = ctxt->md5_st8[ 0]; - digest[ 4] = ctxt->md5_st8[ 7]; digest[ 5] = ctxt->md5_st8[ 6]; - digest[ 6] = ctxt->md5_st8[ 5]; digest[ 7] = ctxt->md5_st8[ 4]; - digest[ 8] = ctxt->md5_st8[11]; digest[ 9] = ctxt->md5_st8[10]; - digest[10] = ctxt->md5_st8[ 9]; digest[11] = ctxt->md5_st8[ 8]; - digest[12] = ctxt->md5_st8[15]; digest[13] = ctxt->md5_st8[14]; - digest[14] = ctxt->md5_st8[13]; digest[15] = ctxt->md5_st8[12]; -#endif -} - -static void md5_calc(b64, ctxt) - u_int8_t *b64; - md5_ctxt *ctxt; -{ - u_int32_t A = ctxt->md5_sta; - u_int32_t B = ctxt->md5_stb; - u_int32_t C = ctxt->md5_stc; - u_int32_t D = ctxt->md5_std; -#if BYTE_ORDER == LITTLE_ENDIAN - u_int32_t *X = (u_int32_t *)b64; -#endif -#if BYTE_ORDER == BIG_ENDIAN - /* 4 byte words */ - /* what a brute force but fast! */ - u_int32_t X[16]; - u_int8_t *y = (u_int8_t *)X; - y[ 0] = b64[ 3]; y[ 1] = b64[ 2]; y[ 2] = b64[ 1]; y[ 3] = b64[ 0]; - y[ 4] = b64[ 7]; y[ 5] = b64[ 6]; y[ 6] = b64[ 5]; y[ 7] = b64[ 4]; - y[ 8] = b64[11]; y[ 9] = b64[10]; y[10] = b64[ 9]; y[11] = b64[ 8]; - y[12] = b64[15]; y[13] = b64[14]; y[14] = b64[13]; y[15] = b64[12]; - y[16] = b64[19]; y[17] = b64[18]; y[18] = b64[17]; y[19] = b64[16]; - y[20] = b64[23]; y[21] = b64[22]; y[22] = b64[21]; y[23] = b64[20]; - y[24] = b64[27]; y[25] = b64[26]; y[26] = b64[25]; y[27] = b64[24]; - y[28] = b64[31]; y[29] = b64[30]; y[30] = b64[29]; y[31] = b64[28]; - y[32] = b64[35]; y[33] = b64[34]; y[34] = b64[33]; y[35] = b64[32]; - y[36] = b64[39]; y[37] = b64[38]; y[38] = b64[37]; y[39] = b64[36]; - y[40] = b64[43]; y[41] = b64[42]; y[42] = b64[41]; y[43] = b64[40]; - y[44] = b64[47]; y[45] = b64[46]; y[46] = b64[45]; y[47] = b64[44]; - y[48] = b64[51]; y[49] = b64[50]; y[50] = b64[49]; y[51] = b64[48]; - y[52] = b64[55]; y[53] = b64[54]; y[54] = b64[53]; y[55] = b64[52]; - y[56] = b64[59]; y[57] = b64[58]; y[58] = b64[57]; y[59] = b64[56]; - y[60] = b64[63]; y[61] = b64[62]; y[62] = b64[61]; y[63] = b64[60]; -#endif - - ROUND1(A, B, C, D, 0, Sa, 1); ROUND1(D, A, B, C, 1, Sb, 2); - ROUND1(C, D, A, B, 2, Sc, 3); ROUND1(B, C, D, A, 3, Sd, 4); - ROUND1(A, B, C, D, 4, Sa, 5); ROUND1(D, A, B, C, 5, Sb, 6); - ROUND1(C, D, A, B, 6, Sc, 7); ROUND1(B, C, D, A, 7, Sd, 8); - ROUND1(A, B, C, D, 8, Sa, 9); ROUND1(D, A, B, C, 9, Sb, 10); - ROUND1(C, D, A, B, 10, Sc, 11); ROUND1(B, C, D, A, 11, Sd, 12); - ROUND1(A, B, C, D, 12, Sa, 13); ROUND1(D, A, B, C, 13, Sb, 14); - ROUND1(C, D, A, B, 14, Sc, 15); ROUND1(B, C, D, A, 15, Sd, 16); - - ROUND2(A, B, C, D, 1, Se, 17); ROUND2(D, A, B, C, 6, Sf, 18); - ROUND2(C, D, A, B, 11, Sg, 19); ROUND2(B, C, D, A, 0, Sh, 20); - ROUND2(A, B, C, D, 5, Se, 21); ROUND2(D, A, B, C, 10, Sf, 22); - ROUND2(C, D, A, B, 15, Sg, 23); ROUND2(B, C, D, A, 4, Sh, 24); - ROUND2(A, B, C, D, 9, Se, 25); ROUND2(D, A, B, C, 14, Sf, 26); - ROUND2(C, D, A, B, 3, Sg, 27); ROUND2(B, C, D, A, 8, Sh, 28); - ROUND2(A, B, C, D, 13, Se, 29); ROUND2(D, A, B, C, 2, Sf, 30); - ROUND2(C, D, A, B, 7, Sg, 31); ROUND2(B, C, D, A, 12, Sh, 32); - - ROUND3(A, B, C, D, 5, Si, 33); ROUND3(D, A, B, C, 8, Sj, 34); - ROUND3(C, D, A, B, 11, Sk, 35); ROUND3(B, C, D, A, 14, Sl, 36); - ROUND3(A, B, C, D, 1, Si, 37); ROUND3(D, A, B, C, 4, Sj, 38); - ROUND3(C, D, A, B, 7, Sk, 39); ROUND3(B, C, D, A, 10, Sl, 40); - ROUND3(A, B, C, D, 13, Si, 41); ROUND3(D, A, B, C, 0, Sj, 42); - ROUND3(C, D, A, B, 3, Sk, 43); ROUND3(B, C, D, A, 6, Sl, 44); - ROUND3(A, B, C, D, 9, Si, 45); ROUND3(D, A, B, C, 12, Sj, 46); - ROUND3(C, D, A, B, 15, Sk, 47); ROUND3(B, C, D, A, 2, Sl, 48); - - ROUND4(A, B, C, D, 0, Sm, 49); ROUND4(D, A, B, C, 7, Sn, 50); - ROUND4(C, D, A, B, 14, So, 51); ROUND4(B, C, D, A, 5, Sp, 52); - ROUND4(A, B, C, D, 12, Sm, 53); ROUND4(D, A, B, C, 3, Sn, 54); - ROUND4(C, D, A, B, 10, So, 55); ROUND4(B, C, D, A, 1, Sp, 56); - ROUND4(A, B, C, D, 8, Sm, 57); ROUND4(D, A, B, C, 15, Sn, 58); - ROUND4(C, D, A, B, 6, So, 59); ROUND4(B, C, D, A, 13, Sp, 60); - ROUND4(A, B, C, D, 4, Sm, 61); ROUND4(D, A, B, C, 11, Sn, 62); - ROUND4(C, D, A, B, 2, So, 63); ROUND4(B, C, D, A, 9, Sp, 64); - - ctxt->md5_sta += A; - ctxt->md5_stb += B; - ctxt->md5_stc += C; - ctxt->md5_std += D; -} diff --git a/target/linux/generic-2.4/files/crypto/ocf/safe/md5.h b/target/linux/generic-2.4/files/crypto/ocf/safe/md5.h deleted file mode 100644 index 690f5bf..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/safe/md5.h +++ /dev/null @@ -1,76 +0,0 @@ -/* $FreeBSD: src/sys/crypto/md5.h,v 1.4 2002/03/20 05:13:50 alfred Exp $ */ -/* $KAME: md5.h,v 1.4 2000/03/27 04:36:22 sumikawa Exp $ */ - -/* - * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. - * 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. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT 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 PROJECT 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 _NETINET6_MD5_H_ -#define _NETINET6_MD5_H_ - -#define MD5_BUFLEN 64 - -typedef struct { - union { - u_int32_t md5_state32[4]; - u_int8_t md5_state8[16]; - } md5_st; - -#define md5_sta md5_st.md5_state32[0] -#define md5_stb md5_st.md5_state32[1] -#define md5_stc md5_st.md5_state32[2] -#define md5_std md5_st.md5_state32[3] -#define md5_st8 md5_st.md5_state8 - - union { - u_int64_t md5_count64; - u_int8_t md5_count8[8]; - } md5_count; -#define md5_n md5_count.md5_count64 -#define md5_n8 md5_count.md5_count8 - - u_int md5_i; - u_int8_t md5_buf[MD5_BUFLEN]; -} md5_ctxt; - -extern void md5_init(md5_ctxt *); -extern void md5_loop(md5_ctxt *, u_int8_t *, u_int); -extern void md5_pad(md5_ctxt *); -extern void md5_result(u_int8_t *, md5_ctxt *); - -/* compatibility */ -#define MD5_CTX md5_ctxt -#define MD5Init(x) md5_init((x)) -#define MD5Update(x, y, z) md5_loop((x), (y), (z)) -#define MD5Final(x, y) \ -do { \ - md5_pad((y)); \ - md5_result((x), (y)); \ -} while (0) - -#endif /* ! _NETINET6_MD5_H_*/ diff --git a/target/linux/generic-2.4/files/crypto/ocf/safe/safe.c b/target/linux/generic-2.4/files/crypto/ocf/safe/safe.c deleted file mode 100644 index 7e65101..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/safe/safe.c +++ /dev/null @@ -1,2288 +0,0 @@ -/*- - * Linux port done by David McCullough <david_mccullough@mcafee.com> - * Copyright (C) 2004-2010 David McCullough - * The license and original author are listed below. - * - * Copyright (c) 2003 Sam Leffler, Errno Consulting - * Copyright (c) 2003 Global Technology Associates, 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 THE AUTHOR 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 AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * -__FBSDID("$FreeBSD: src/sys/dev/safe/safe.c,v 1.18 2007/03/21 03:42:50 sam Exp $"); - */ - -#ifndef AUTOCONF_INCLUDED -#include <linux/config.h> -#endif -#include <linux/module.h> -#include <linux/kernel.h> -#include <linux/init.h> -#include <linux/list.h> -#include <linux/slab.h> -#include <linux/wait.h> -#include <linux/sched.h> -#include <linux/pci.h> -#include <linux/delay.h> -#include <linux/interrupt.h> -#include <linux/spinlock.h> -#include <linux/random.h> -#include <linux/version.h> -#include <linux/skbuff.h> -#include <asm/io.h> - -/* - * SafeNet SafeXcel-1141 hardware crypto accelerator - */ - -#include <cryptodev.h> -#include <uio.h> -#include <safe/safereg.h> -#include <safe/safevar.h> - -#if 1 -#define DPRINTF(a) do { \ - if (debug) { \ - printk("%s: ", sc ? \ - device_get_nameunit(sc->sc_dev) : "safe"); \ - printk a; \ - } \ - } while (0) -#else -#define DPRINTF(a) -#endif - -/* - * until we find a cleaner way, include the BSD md5/sha1 code - * here - */ -#define HMAC_HACK 1 -#ifdef HMAC_HACK -#define LITTLE_ENDIAN 1234 -#define BIG_ENDIAN 4321 -#ifdef __LITTLE_ENDIAN -#define BYTE_ORDER LITTLE_ENDIAN -#endif -#ifdef __BIG_ENDIAN -#define BYTE_ORDER BIG_ENDIAN -#endif -#include <safe/md5.h> -#include <safe/md5.c> -#include <safe/sha1.h> -#include <safe/sha1.c> - -u_int8_t hmac_ipad_buffer[64] = { - 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, - 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, - 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, - 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, - 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, - 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, - 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, - 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36 -}; - -u_int8_t hmac_opad_buffer[64] = { - 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, - 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, - 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, - 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, - 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, - 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, - 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, - 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C -}; -#endif /* HMAC_HACK */ - -/* add proc entry for this */ -struct safe_stats safestats; - -#define debug safe_debug -int safe_debug = 0; -module_param(safe_debug, int, 0644); -MODULE_PARM_DESC(safe_debug, "Enable debug"); - -static void safe_callback(struct safe_softc *, struct safe_ringentry *); -static void safe_feed(struct safe_softc *, struct safe_ringentry *); -#if defined(CONFIG_OCF_RANDOMHARVEST) && !defined(SAFE_NO_RNG) -static void safe_rng_init(struct safe_softc *); -int safe_rngbufsize = 8; /* 32 bytes each read */ -module_param(safe_rngbufsize, int, 0644); -MODULE_PARM_DESC(safe_rngbufsize, "RNG polling buffer size (32-bit words)"); -int safe_rngmaxalarm = 8; /* max alarms before reset */ -module_param(safe_rngmaxalarm, int, 0644); -MODULE_PARM_DESC(safe_rngmaxalarm, "RNG max alarms before reset"); -#endif /* SAFE_NO_RNG */ - -static void safe_totalreset(struct safe_softc *sc); -static int safe_dmamap_aligned(struct safe_softc *sc, const struct safe_operand *op); -static int safe_dmamap_uniform(struct safe_softc *sc, const struct safe_operand *op); -static int safe_free_entry(struct safe_softc *sc, struct safe_ringentry *re); -static int safe_kprocess(device_t dev, struct cryptkop *krp, int hint); -static int safe_kstart(struct safe_softc *sc); -static int safe_ksigbits(struct safe_softc *sc, struct crparam *cr); -static void safe_kfeed(struct safe_softc *sc); -static void safe_kpoll(unsigned long arg); -static void safe_kload_reg(struct safe_softc *sc, u_int32_t off, - u_int32_t len, struct crparam *n); - -static int safe_newsession(device_t, u_int32_t *, struct cryptoini *); -static int safe_freesession(device_t, u_int64_t); -static int safe_process(device_t, struct cryptop *, int); - -static device_method_t safe_methods = { - /* crypto device methods */ - DEVMETHOD(cryptodev_newsession, safe_newsession), - DEVMETHOD(cryptodev_freesession,safe_freesession), - DEVMETHOD(cryptodev_process, safe_process), - DEVMETHOD(cryptodev_kprocess, safe_kprocess), -}; - -#define READ_REG(sc,r) readl((sc)->sc_base_addr + (r)) -#define WRITE_REG(sc,r,val) writel((val), (sc)->sc_base_addr + (r)) - -#define SAFE_MAX_CHIPS 8 -static struct safe_softc *safe_chip_idx[SAFE_MAX_CHIPS]; - -/* - * split our buffers up into safe DMAable byte fragments to avoid lockup - * bug in 1141 HW on rev 1.0. - */ - -static int -pci_map_linear( - struct safe_softc *sc, - struct safe_operand *buf, - void *addr, - int len) -{ - dma_addr_t tmp; - int chunk, tlen = len; - - tmp = pci_map_single(sc->sc_pcidev, addr, len, PCI_DMA_BIDIRECTIONAL); - - buf->mapsize += len; - while (len > 0) { - chunk = (len > sc->sc_max_dsize) ? sc->sc_max_dsize : len; - buf->segs[buf->nsegs].ds_addr = tmp; - buf->segs[buf->nsegs].ds_len = chunk; - buf->segs[buf->nsegs].ds_tlen = tlen; - buf->nsegs++; - tmp += chunk; - len -= chunk; - tlen = 0; - } - return 0; -} - -/* - * map in a given uio buffer (great on some arches :-) - */ - -static int -pci_map_uio(struct safe_softc *sc, struct safe_operand *buf, struct uio *uio) -{ - struct iovec *iov = uio->uio_iov; - int n; - - DPRINTF(("%s()\n", __FUNCTION__)); - - buf->mapsize = 0; - buf->nsegs = 0; - - for (n = 0; n < uio->uio_iovcnt; n++) { - pci_map_linear(sc, buf, iov->iov_base, iov->iov_len); - iov++; - } - - /* identify this buffer by the first segment */ - buf->map = (void *) buf->segs[0].ds_addr; - return(0); -} - -/* - * map in a given sk_buff - */ - -static int -pci_map_skb(struct safe_softc *sc,struct safe_operand *buf,struct sk_buff *skb) -{ - int i; - - DPRINTF(("%s()\n", __FUNCTION__)); - - buf->mapsize = 0; - buf->nsegs = 0; - - pci_map_linear(sc, buf, skb->data, skb_headlen(skb)); - - for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { - pci_map_linear(sc, buf, - page_address(skb_shinfo(skb)->frags[i].page) + - skb_shinfo(skb)->frags[i].page_offset, - skb_shinfo(skb)->frags[i].size); - } - - /* identify this buffer by the first segment */ - buf->map = (void *) buf->segs[0].ds_addr; - return(0); -} - - -#if 0 /* not needed at this time */ -static void -pci_sync_operand(struct safe_softc *sc, struct safe_operand *buf) -{ - int i; - - DPRINTF(("%s()\n", __FUNCTION__)); - for (i = 0; i < buf->nsegs; i++) - pci_dma_sync_single_for_cpu(sc->sc_pcidev, buf->segs[i].ds_addr, - buf->segs[i].ds_len, PCI_DMA_BIDIRECTIONAL); -} -#endif - -static void -pci_unmap_operand(struct safe_softc *sc, struct safe_operand *buf) -{ - int i; - DPRINTF(("%s()\n", __FUNCTION__)); - for (i = 0; i < buf->nsegs; i++) { - if (buf->segs[i].ds_tlen) { - DPRINTF(("%s - unmap %d 0x%x %d\n", __FUNCTION__, i, buf->segs[i].ds_addr, buf->segs[i].ds_tlen)); - pci_unmap_single(sc->sc_pcidev, buf->segs[i].ds_addr, - buf->segs[i].ds_tlen, PCI_DMA_BIDIRECTIONAL); - DPRINTF(("%s - unmap %d 0x%x %d done\n", __FUNCTION__, i, buf->segs[i].ds_addr, buf->segs[i].ds_tlen)); - } - buf->segs[i].ds_addr = 0; - buf->segs[i].ds_len = 0; - buf->segs[i].ds_tlen = 0; - } - buf->nsegs = 0; - buf->mapsize = 0; - buf->map = 0; -} - - -/* - * SafeXcel Interrupt routine - */ -static irqreturn_t -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19) -safe_intr(int irq, void *arg) -#else -safe_intr(int irq, void *arg, struct pt_regs *regs) -#endif -{ - struct safe_softc *sc = arg; - int stat; - unsigned long flags; - - stat = READ_REG(sc, SAFE_HM_STAT); - - DPRINTF(("%s(stat=0x%x)\n", __FUNCTION__, stat)); - - if (stat == 0) /* shared irq, not for us */ - return IRQ_NONE; - - WRITE_REG(sc, SAFE_HI_CLR, stat); /* IACK */ - - if ((stat & SAFE_INT_PE_DDONE)) { - /* - * Descriptor(s) done; scan the ring and - * process completed operations. - */ - spin_lock_irqsave(&sc->sc_ringmtx, flags); - while (sc->sc_back != sc->sc_front) { - struct safe_ringentry *re = sc->sc_back; - -#ifdef SAFE_DEBUG - if (debug) { - safe_dump_ringstate(sc, __func__); - safe_dump_request(sc, __func__, re); - } -#endif - /* - * safe_process marks ring entries that were allocated - * but not used with a csr of zero. This insures the - * ring front pointer never needs to be set backwards - * in the event that an entry is allocated but not used - * because of a setup error. - */ - DPRINTF(("%s re->re_desc.d_csr=0x%x\n", __FUNCTION__, re->re_desc.d_csr)); - if (re->re_desc.d_csr != 0) { - if (!SAFE_PE_CSR_IS_DONE(re->re_desc.d_csr)) { - DPRINTF(("%s !CSR_IS_DONE\n", __FUNCTION__)); - break; - } - if (!SAFE_PE_LEN_IS_DONE(re->re_desc.d_len)) { - DPRINTF(("%s !LEN_IS_DONE\n", __FUNCTION__)); - break; - } - sc->sc_nqchip--; - safe_callback(sc, re); - } - if (++(sc->sc_back) == sc->sc_ringtop) - sc->sc_back = sc->sc_ring; - } - spin_unlock_irqrestore(&sc->sc_ringmtx, flags); - } - - /* - * Check to see if we got any DMA Error - */ - if (stat & SAFE_INT_PE_ERROR) { - printk("%s: dmaerr dmastat %08x\n", device_get_nameunit(sc->sc_dev), - (int)READ_REG(sc, SAFE_PE_DMASTAT)); - safestats.st_dmaerr++; - safe_totalreset(sc); -#if 0 - safe_feed(sc); -#endif - } - - if (sc->sc_needwakeup) { /* XXX check high watermark */ - int wakeup = sc->sc_needwakeup & (CRYPTO_SYMQ|CRYPTO_ASYMQ); - DPRINTF(("%s: wakeup crypto %x\n", __func__, - sc->sc_needwakeup)); - sc->sc_needwakeup &= ~wakeup; - crypto_unblock(sc->sc_cid, wakeup); - } - - return IRQ_HANDLED; -} - -/* - * safe_feed() - post a request to chip - */ -static void -safe_feed(struct safe_softc *sc, struct safe_ringentry *re) -{ - DPRINTF(("%s()\n", __FUNCTION__)); -#ifdef SAFE_DEBUG - if (debug) { - safe_dump_ringstate(sc, __func__); - safe_dump_request(sc, __func__, re); - } -#endif - sc->sc_nqchip++; - if (sc->sc_nqchip > safestats.st_maxqchip) - safestats.st_maxqchip = sc->sc_nqchip; - /* poke h/w to check descriptor ring, any value can be written */ - WRITE_REG(sc, SAFE_HI_RD_DESCR, 0); -} - -#define N(a) (sizeof(a) / sizeof (a[0])) -static void -safe_setup_enckey(struct safe_session *ses, caddr_t key) -{ - int i; - - bcopy(key, ses->ses_key, ses->ses_klen / 8); - - /* PE is little-endian, insure proper byte order */ - for (i = 0; i < N(ses->ses_key); i++) - ses->ses_key[i] = htole32(ses->ses_key[i]); -} - -static void -safe_setup_mackey(struct safe_session *ses, int algo, caddr_t key, int klen) -{ -#ifdef HMAC_HACK - MD5_CTX md5ctx; - SHA1_CTX sha1ctx; - int i; - - - for (i = 0; i < klen; i++) - key[i] ^= HMAC_IPAD_VAL; - - if (algo == CRYPTO_MD5_HMAC) { - MD5Init(&md5ctx); - MD5Update(&md5ctx, key, klen); - MD5Update(&md5ctx, hmac_ipad_buffer, MD5_HMAC_BLOCK_LEN - klen); - bcopy(md5ctx.md5_st8, ses->ses_hminner, sizeof(md5ctx.md5_st8)); - } else { - SHA1Init(&sha1ctx); - SHA1Update(&sha1ctx, key, klen); - SHA1Update(&sha1ctx, hmac_ipad_buffer, - SHA1_HMAC_BLOCK_LEN - klen); - bcopy(sha1ctx.h.b32, ses->ses_hminner, sizeof(sha1ctx.h.b32)); - } - - for (i = 0; i < klen; i++) - key[i] ^= (HMAC_IPAD_VAL ^ HMAC_OPAD_VAL); - - if (algo == CRYPTO_MD5_HMAC) { - MD5Init(&md5ctx); - MD5Update(&md5ctx, key, klen); - MD5Update(&md5ctx, hmac_opad_buffer, MD5_HMAC_BLOCK_LEN - klen); - bcopy(md5ctx.md5_st8, ses->ses_hmouter, sizeof(md5ctx.md5_st8)); - } else { - SHA1Init(&sha1ctx); - SHA1Update(&sha1ctx, key, klen); - SHA1Update(&sha1ctx, hmac_opad_buffer, - SHA1_HMAC_BLOCK_LEN - klen); - bcopy(sha1ctx.h.b32, ses->ses_hmouter, sizeof(sha1ctx.h.b32)); - } - - for (i = 0; i < klen; i++) - key[i] ^= HMAC_OPAD_VAL; - -#if 0 - /* - * this code prevents SHA working on a BE host, - * so it is obviously wrong. I think the byte - * swap setup we do with the chip fixes this for us - */ - - /* PE is little-endian, insure proper byte order */ - for (i = 0; i < N(ses->ses_hminner); i++) { - ses->ses_hminner[i] = htole32(ses->ses_hminner[i]); - ses->ses_hmouter[i] = htole32(ses->ses_hmouter[i]); - } -#endif -#else /* HMAC_HACK */ - printk("safe: md5/sha not implemented\n"); -#endif /* HMAC_HACK */ -} -#undef N - -/* - * Allocate a new 'session' and return an encoded session id. 'sidp' - * contains our registration id, and should contain an encoded session - * id on successful allocation. - */ -static int -safe_newsession(device_t dev, u_int32_t *sidp, struct cryptoini *cri) -{ - struct safe_softc *sc = device_get_softc(dev); - struct cryptoini *c, *encini = NULL, *macini = NULL; - struct safe_session *ses = NULL; - int sesn; - - DPRINTF(("%s()\n", __FUNCTION__)); - - if (sidp == NULL || cri == NULL || sc == NULL) - return (EINVAL); - - for (c = cri; c != NULL; c = c->cri_next) { - if (c->cri_alg == CRYPTO_MD5_HMAC || - c->cri_alg == CRYPTO_SHA1_HMAC || - c->cri_alg == CRYPTO_NULL_HMAC) { - if (macini) - return (EINVAL); - macini = c; - } else if (c->cri_alg == CRYPTO_DES_CBC || - c->cri_alg == CRYPTO_3DES_CBC || - c->cri_alg == CRYPTO_AES_CBC || - c->cri_alg == CRYPTO_NULL_CBC) { - if (encini) - return (EINVAL); - encini = c; - } else - return (EINVAL); - } - if (encini == NULL && macini == NULL) - return (EINVAL); - if (encini) { /* validate key length */ - switch (encini->cri_alg) { - case CRYPTO_DES_CBC: - if (encini->cri_klen != 64) - return (EINVAL); - break; - case CRYPTO_3DES_CBC: - if (encini->cri_klen != 192) - return (EINVAL); - break; - case CRYPTO_AES_CBC: - if (encini->cri_klen != 128 && - encini->cri_klen != 192 && - encini->cri_klen != 256) - return (EINVAL); - break; - } - } - - if (sc->sc_sessions == NULL) { - ses = sc->sc_sessions = (struct safe_session *) - kmalloc(sizeof(struct safe_session), SLAB_ATOMIC); - if (ses == NULL) - return (ENOMEM); - memset(ses, 0, sizeof(struct safe_session)); - sesn = 0; - sc->sc_nsessions = 1; - } else { - for (sesn = 0; sesn < sc->sc_nsessions; sesn++) { - if (sc->sc_sessions[sesn].ses_used == 0) { - ses = &sc->sc_sessions[sesn]; - break; - } - } - - if (ses == NULL) { - sesn = sc->sc_nsessions; - ses = (struct safe_session *) - kmalloc((sesn + 1) * sizeof(struct safe_session), SLAB_ATOMIC); - if (ses == NULL) - return (ENOMEM); - memset(ses, 0, (sesn + 1) * sizeof(struct safe_session)); - bcopy(sc->sc_sessions, ses, sesn * - sizeof(struct safe_session)); - bzero(sc->sc_sessions, sesn * - sizeof(struct safe_session)); - kfree(sc->sc_sessions); - sc->sc_sessions = ses; - ses = &sc->sc_sessions[sesn]; - sc->sc_nsessions++; - } - } - - bzero(ses, sizeof(struct safe_session)); - ses->ses_used = 1; - - if (encini) { - /* get an IV */ - /* XXX may read fewer than requested */ - read_random(ses->ses_iv, sizeof(ses->ses_iv)); - - ses->ses_klen = encini->cri_klen; - if (encini->cri_key != NULL) - safe_setup_enckey(ses, encini->cri_key); - } - - if (macini) { - ses->ses_mlen = macini->cri_mlen; - if (ses->ses_mlen == 0) { - if (macini->cri_alg == CRYPTO_MD5_HMAC) - ses->ses_mlen = MD5_HASH_LEN; - else - ses->ses_mlen = SHA1_HASH_LEN; - } - - if (macini->cri_key != NULL) { - safe_setup_mackey(ses, macini->cri_alg, macini->cri_key, - macini->cri_klen / 8); - } - } - - *sidp = SAFE_SID(device_get_unit(sc->sc_dev), sesn); - return (0); -} - -/* - * Deallocate a session. - */ -static int -safe_freesession(device_t dev, u_int64_t tid) -{ - struct safe_softc *sc = device_get_softc(dev); - int session, ret; - u_int32_t sid = ((u_int32_t) tid) & 0xffffffff; - - DPRINTF(("%s()\n", __FUNCTION__)); - - if (sc == NULL) - return (EINVAL); - - session = SAFE_SESSION(sid); - if (session < sc->sc_nsessions) { - bzero(&sc->sc_sessions[session], sizeof(sc->sc_sessions[session])); - ret = 0; - } else - ret = EINVAL; - return (ret); -} - - -static int -safe_process(device_t dev, struct cryptop *crp, int hint) -{ - struct safe_softc *sc = device_get_softc(dev); - int err = 0, i, nicealign, uniform; - struct cryptodesc *crd1, *crd2, *maccrd, *enccrd; - int bypass, oplen, ivsize; - caddr_t iv; - int16_t coffset; - struct safe_session *ses; - struct safe_ringentry *re; - struct safe_sarec *sa; - struct safe_pdesc *pd; - u_int32_t cmd0, cmd1, staterec; - unsigned long flags; - - DPRINTF(("%s()\n", __FUNCTION__)); - - if (crp == NULL || crp->crp_callback == NULL || sc == NULL) { - safestats.st_invalid++; - return (EINVAL); - } - if (SAFE_SESSION(crp->crp_sid) >= sc->sc_nsessions) { - safestats.st_badsession++; - return (EINVAL); - } - - spin_lock_irqsave(&sc->sc_ringmtx, flags); - if (sc->sc_front == sc->sc_back && sc->sc_nqchip != 0) { - safestats.st_ringfull++; - sc->sc_needwakeup |= CRYPTO_SYMQ; - spin_unlock_irqrestore(&sc->sc_ringmtx, flags); - return (ERESTART); - } - re = sc->sc_front; - - staterec = re->re_sa.sa_staterec; /* save */ - /* NB: zero everything but the PE descriptor */ - bzero(&re->re_sa, sizeof(struct safe_ringentry) - sizeof(re->re_desc)); - re->re_sa.sa_staterec = staterec; /* restore */ - - re->re_crp = crp; - re->re_sesn = SAFE_SESSION(crp->crp_sid); - - re->re_src.nsegs = 0; - re->re_dst.nsegs = 0; - - if (crp->crp_flags & CRYPTO_F_SKBUF) { - re->re_src_skb = (struct sk_buff *)crp->crp_buf; - re->re_dst_skb = (struct sk_buff *)crp->crp_buf; - } else if (crp->crp_flags & CRYPTO_F_IOV) { - re->re_src_io = (struct uio *)crp->crp_buf; - re->re_dst_io = (struct uio *)crp->crp_buf; - } else { - safestats.st_badflags++; - err = EINVAL; - goto errout; /* XXX we don't handle contiguous blocks! */ - } - - sa = &re->re_sa; - ses = &sc->sc_sessions[re->re_sesn]; - - crd1 = crp->crp_desc; - if (crd1 == NULL) { - safestats.st_nodesc++; - err = EINVAL; - goto errout; - } - crd2 = crd1->crd_next; - - cmd0 = SAFE_SA_CMD0_BASIC; /* basic group operation */ - cmd1 = 0; - if (crd2 == NULL) { - if (crd1->crd_alg == CRYPTO_MD5_HMAC || - crd1->crd_alg == CRYPTO_SHA1_HMAC || - crd1->crd_alg == CRYPTO_NULL_HMAC) { - maccrd = crd1; - enccrd = NULL; - cmd0 |= SAFE_SA_CMD0_OP_HASH; - } else if (crd1->crd_alg == CRYPTO_DES_CBC || - crd1->crd_alg == CRYPTO_3DES_CBC || - crd1->crd_alg == CRYPTO_AES_CBC || - crd1->crd_alg == CRYPTO_NULL_CBC) { - maccrd = NULL; - enccrd = crd1; - cmd0 |= SAFE_SA_CMD0_OP_CRYPT; - } else { - safestats.st_badalg++; - err = EINVAL; - goto errout; - } - } else { - if ((crd1->crd_alg == CRYPTO_MD5_HMAC || - crd1->crd_alg == CRYPTO_SHA1_HMAC || - crd1->crd_alg == CRYPTO_NULL_HMAC) && - (crd2->crd_alg == CRYPTO_DES_CBC || - crd2->crd_alg == CRYPTO_3DES_CBC || - crd2->crd_alg == CRYPTO_AES_CBC || - crd2->crd_alg == CRYPTO_NULL_CBC) && - ((crd2->crd_flags & CRD_F_ENCRYPT) == 0)) { - maccrd = crd1; - enccrd = crd2; - } else if ((crd1->crd_alg == CRYPTO_DES_CBC || - crd1->crd_alg == CRYPTO_3DES_CBC || - crd1->crd_alg == CRYPTO_AES_CBC || - crd1->crd_alg == CRYPTO_NULL_CBC) && - (crd2->crd_alg == CRYPTO_MD5_HMAC || - crd2->crd_alg == CRYPTO_SHA1_HMAC || - crd2->crd_alg == CRYPTO_NULL_HMAC) && - (crd1->crd_flags & CRD_F_ENCRYPT)) { - enccrd = crd1; - maccrd = crd2; - } else { - safestats.st_badalg++; - err = EINVAL; - goto errout; - } - cmd0 |= SAFE_SA_CMD0_OP_BOTH; - } - - if (enccrd) { - if (enccrd->crd_flags & CRD_F_KEY_EXPLICIT) - safe_setup_enckey(ses, enccrd->crd_key); - - if (enccrd->crd_alg == CRYPTO_DES_CBC) { - cmd0 |= SAFE_SA_CMD0_DES; - cmd1 |= SAFE_SA_CMD1_CBC; - ivsize = 2*sizeof(u_int32_t); - } else if (enccrd->crd_alg == CRYPTO_3DES_CBC) { - cmd0 |= SAFE_SA_CMD0_3DES; - cmd1 |= SAFE_SA_CMD1_CBC; - ivsize = 2*sizeof(u_int32_t); - } else if (enccrd->crd_alg == CRYPTO_AES_CBC) { - cmd0 |= SAFE_SA_CMD0_AES; - cmd1 |= SAFE_SA_CMD1_CBC; - if (ses->ses_klen == 128) - cmd1 |= SAFE_SA_CMD1_AES128; - else if (ses->ses_klen == 192) - cmd1 |= SAFE_SA_CMD1_AES192; - else - cmd1 |= SAFE_SA_CMD1_AES256; - ivsize = 4*sizeof(u_int32_t); - } else { - cmd0 |= SAFE_SA_CMD0_CRYPT_NULL; - ivsize = 0; - } - - /* - * Setup encrypt/decrypt state. When using basic ops - * we can't use an inline IV because hash/crypt offset - * must be from the end of the IV to the start of the - * crypt data and this leaves out the preceding header - * from the hash calculation. Instead we place the IV - * in the state record and set the hash/crypt offset to - * copy both the header+IV. - */ - if (enccrd->crd_flags & CRD_F_ENCRYPT) { - cmd0 |= SAFE_SA_CMD0_OUTBOUND; - - if (enccrd->crd_flags & CRD_F_IV_EXPLICIT) - iv = enccrd->crd_iv; - else - iv = (caddr_t) ses->ses_iv; - if ((enccrd->crd_flags & CRD_F_IV_PRESENT) == 0) { - crypto_copyback(crp->crp_flags, crp->crp_buf, - enccrd->crd_inject, ivsize, iv); - } - bcopy(iv, re->re_sastate.sa_saved_iv, ivsize); - /* make iv LE */ - for (i = 0; i < ivsize/sizeof(re->re_sastate.sa_saved_iv[0]); i++) - re->re_sastate.sa_saved_iv[i] = - cpu_to_le32(re->re_sastate.sa_saved_iv[i]); - cmd0 |= SAFE_SA_CMD0_IVLD_STATE | SAFE_SA_CMD0_SAVEIV; - re->re_flags |= SAFE_QFLAGS_COPYOUTIV; - } else { - cmd0 |= SAFE_SA_CMD0_INBOUND; - - if (enccrd->crd_flags & CRD_F_IV_EXPLICIT) { - bcopy(enccrd->crd_iv, - re->re_sastate.sa_saved_iv, ivsize); - } else { - crypto_copydata(crp->crp_flags, crp->crp_buf, - enccrd->crd_inject, ivsize, - (caddr_t)re->re_sastate.sa_saved_iv); - } - /* make iv LE */ - for (i = 0; i < ivsize/sizeof(re->re_sastate.sa_saved_iv[0]); i++) - re->re_sastate.sa_saved_iv[i] = - cpu_to_le32(re->re_sastate.sa_saved_iv[i]); - cmd0 |= SAFE_SA_CMD0_IVLD_STATE; - } - /* - * For basic encryption use the zero pad algorithm. - * This pads results to an 8-byte boundary and - * suppresses padding verification for inbound (i.e. - * decrypt) operations. - * - * NB: Not sure if the 8-byte pad boundary is a problem. - */ - cmd0 |= SAFE_SA_CMD0_PAD_ZERO; - - /* XXX assert key bufs have the same size */ - bcopy(ses->ses_key, sa->sa_key, sizeof(sa->sa_key)); - } - - if (maccrd) { - if (maccrd->crd_flags & CRD_F_KEY_EXPLICIT) { - safe_setup_mackey(ses, maccrd->crd_alg, - maccrd->crd_key, maccrd->crd_klen / 8); - } - - if (maccrd->crd_alg == CRYPTO_MD5_HMAC) { - cmd0 |= SAFE_SA_CMD0_MD5; - cmd1 |= SAFE_SA_CMD1_HMAC; /* NB: enable HMAC */ - } else if (maccrd->crd_alg == CRYPTO_SHA1_HMAC) { - cmd0 |= SAFE_SA_CMD0_SHA1; - cmd1 |= SAFE_SA_CMD1_HMAC; /* NB: enable HMAC */ - } else { - cmd0 |= SAFE_SA_CMD0_HASH_NULL; - } - /* - * Digest data is loaded from the SA and the hash - * result is saved to the state block where we - * retrieve it for return to the caller. - */ - /* XXX assert digest bufs have the same size */ - bcopy(ses->ses_hminner, sa->sa_indigest, - sizeof(sa->sa_indigest)); - bcopy(ses->ses_hmouter, sa->sa_outdigest, - sizeof(sa->sa_outdigest)); - - cmd0 |= SAFE_SA_CMD0_HSLD_SA | SAFE_SA_CMD0_SAVEHASH; - re->re_flags |= SAFE_QFLAGS_COPYOUTICV; - } - - if (enccrd && maccrd) { - /* - * The offset from hash data to the start of - * crypt data is the difference in the skips. - */ - bypass = maccrd->crd_skip; - coffset = enccrd->crd_skip - maccrd->crd_skip; - if (coffset < 0) { - DPRINTF(("%s: hash does not precede crypt; " - "mac skip %u enc skip %u\n", - __func__, maccrd->crd_skip, enccrd->crd_skip)); - safestats.st_skipmismatch++; - err = EINVAL; - goto errout; - } - oplen = enccrd->crd_skip + enccrd->crd_len; - if (maccrd->crd_skip + maccrd->crd_len != oplen) { - DPRINTF(("%s: hash amount %u != crypt amount %u\n", - __func__, maccrd->crd_skip + maccrd->crd_len, - oplen)); - safestats.st_lenmismatch++; - err = EINVAL; - goto errout; - } -#ifdef SAFE_DEBUG - if (debug) { - printf("mac: skip %d, len %d, inject %d\n", - maccrd->crd_skip, maccrd->crd_len, - maccrd->crd_inject); - printf("enc: skip %d, len %d, inject %d\n", - enccrd->crd_skip, enccrd->crd_len, - enccrd->crd_inject); - printf("bypass %d coffset %d oplen %d\n", - bypass, coffset, oplen); - } -#endif - if (coffset & 3) { /* offset must be 32-bit aligned */ - DPRINTF(("%s: coffset %u misaligned\n", - __func__, coffset)); - safestats.st_coffmisaligned++; - err = EINVAL; - goto errout; - } - coffset >>= 2; - if (coffset > 255) { /* offset must be <256 dwords */ - DPRINTF(("%s: coffset %u too big\n", - __func__, coffset)); - safestats.st_cofftoobig++; - err = EINVAL; - goto errout; - } - /* - * Tell the hardware to copy the header to the output. - * The header is defined as the data from the end of - * the bypass to the start of data to be encrypted. - * Typically this is the inline IV. Note that you need - * to do this even if src+dst are the same; it appears - * that w/o this bit the crypted data is written - * immediately after the bypass data. - */ - cmd1 |= SAFE_SA_CMD1_HDRCOPY; - /* - * Disable IP header mutable bit handling. This is - * needed to get correct HMAC calculations. - */ - cmd1 |= SAFE_SA_CMD1_MUTABLE; - } else { - if (enccrd) { - bypass = enccrd->crd_skip; - oplen = bypass + enccrd->crd_len; - } else { - bypass = maccrd->crd_skip; - oplen = bypass + maccrd->crd_len; - } - coffset = 0; - } - /* XXX verify multiple of 4 when using s/g */ - if (bypass > 96) { /* bypass offset must be <= 96 bytes */ - DPRINTF(("%s: bypass %u too big\n", __func__, bypass)); - safestats.st_bypasstoobig++; - err = EINVAL; - goto errout; - } - - if (crp->crp_flags & CRYPTO_F_SKBUF) { - if (pci_map_skb(sc, &re->re_src, re->re_src_skb)) { - safestats.st_noload++; - err = ENOMEM; - goto errout; - } - } else if (crp->crp_flags & CRYPTO_F_IOV) { - if (pci_map_uio(sc, &re->re_src, re->re_src_io)) { - safestats.st_noload++; - err = ENOMEM; - goto errout; - } - } - nicealign = safe_dmamap_aligned(sc, &re->re_src); - uniform = safe_dmamap_uniform(sc, &re->re_src); - - DPRINTF(("src nicealign %u uniform %u nsegs %u\n", - nicealign, uniform, re->re_src.nsegs)); - if (re->re_src.nsegs > 1) { - re->re_desc.d_src = sc->sc_spalloc.dma_paddr + - ((caddr_t) sc->sc_spfree - (caddr_t) sc->sc_spring); - for (i = 0; i < re->re_src_nsegs; i++) { - /* NB: no need to check if there's space */ - pd = sc->sc_spfree; - if (++(sc->sc_spfree) == sc->sc_springtop) - sc->sc_spfree = sc->sc_spring; - - KASSERT((pd->pd_flags&3) == 0 || - (pd->pd_flags&3) == SAFE_PD_DONE, - ("bogus source particle descriptor; flags %x", - pd->pd_flags)); - pd->pd_addr = re->re_src_segs[i].ds_addr; - pd->pd_size = re->re_src_segs[i].ds_len; - pd->pd_flags = SAFE_PD_READY; - } - cmd0 |= SAFE_SA_CMD0_IGATHER; - } else { - /* - * No need for gather, reference the operand directly. - */ - re->re_desc.d_src = re->re_src_segs[0].ds_addr; - } - - if (enccrd == NULL && maccrd != NULL) { - /* - * Hash op; no destination needed. - */ - } else { - if (crp->crp_flags & (CRYPTO_F_IOV|CRYPTO_F_SKBUF)) { - if (!nicealign) { - safestats.st_iovmisaligned++; - err = EINVAL; - goto errout; - } - if (uniform != 1) { - device_printf(sc->sc_dev, "!uniform source\n"); - if (!uniform) { - /* - * There's no way to handle the DMA - * requirements with this uio. We - * could create a separate DMA area for - * the result and then copy it back, - * but for now we just bail and return - * an error. Note that uio requests - * > SAFE_MAX_DSIZE are handled because - * the DMA map and segment list for the - * destination wil result in a - * destination particle list that does - * the necessary scatter DMA. - */ - safestats.st_iovnotuniform++; - err = EINVAL; - goto errout; - } - } else - re->re_dst = re->re_src; - } else { - safestats.st_badflags++; - err = EINVAL; - goto errout; - } - - if (re->re_dst.nsegs > 1) { - re->re_desc.d_dst = sc->sc_dpalloc.dma_paddr + - ((caddr_t) sc->sc_dpfree - (caddr_t) sc->sc_dpring); - for (i = 0; i < re->re_dst_nsegs; i++) { - pd = sc->sc_dpfree; - KASSERT((pd->pd_flags&3) == 0 || - (pd->pd_flags&3) == SAFE_PD_DONE, - ("bogus dest particle descriptor; flags %x", - pd->pd_flags)); - if (++(sc->sc_dpfree) == sc->sc_dpringtop) - sc->sc_dpfree = sc->sc_dpring; - pd->pd_addr = re->re_dst_segs[i].ds_addr; - pd->pd_flags = SAFE_PD_READY; - } - cmd0 |= SAFE_SA_CMD0_OSCATTER; - } else { - /* - * No need for scatter, reference the operand directly. - */ - re->re_desc.d_dst = re->re_dst_segs[0].ds_addr; - } - } - - /* - * All done with setup; fillin the SA command words - * and the packet engine descriptor. The operation - * is now ready for submission to the hardware. - */ - sa->sa_cmd0 = cmd0 | SAFE_SA_CMD0_IPCI | SAFE_SA_CMD0_OPCI; - sa->sa_cmd1 = cmd1 - | (coffset << SAFE_SA_CMD1_OFFSET_S) - | SAFE_SA_CMD1_SAREV1 /* Rev 1 SA data structure */ - | SAFE_SA_CMD1_SRPCI - ; - /* - * NB: the order of writes is important here. In case the - * chip is scanning the ring because of an outstanding request - * it might nab this one too. In that case we need to make - * sure the setup is complete before we write the length - * field of the descriptor as it signals the descriptor is - * ready for processing. - */ - re->re_desc.d_csr = SAFE_PE_CSR_READY | SAFE_PE_CSR_SAPCI; - if (maccrd) - re->re_desc.d_csr |= SAFE_PE_CSR_LOADSA | SAFE_PE_CSR_HASHFINAL; - wmb(); - re->re_desc.d_len = oplen - | SAFE_PE_LEN_READY - | (bypass << SAFE_PE_LEN_BYPASS_S) - ; - - safestats.st_ipackets++; - safestats.st_ibytes += oplen; - - if (++(sc->sc_front) == sc->sc_ringtop) - sc->sc_front = sc->sc_ring; - - /* XXX honor batching */ - safe_feed(sc, re); - spin_unlock_irqrestore(&sc->sc_ringmtx, flags); - return (0); - -errout: - if (re->re_src.map != re->re_dst.map) - pci_unmap_operand(sc, &re->re_dst); - if (re->re_src.map) - pci_unmap_operand(sc, &re->re_src); - spin_unlock_irqrestore(&sc->sc_ringmtx, flags); - if (err != ERESTART) { - crp->crp_etype = err; - crypto_done(crp); - } else { - sc->sc_needwakeup |= CRYPTO_SYMQ; - } - return (err); -} - -static void -safe_callback(struct safe_softc *sc, struct safe_ringentry *re) -{ - struct cryptop *crp = (struct cryptop *)re->re_crp; - struct cryptodesc *crd; - - DPRINTF(("%s()\n", __FUNCTION__)); - - safestats.st_opackets++; - safestats.st_obytes += re->re_dst.mapsize; - - if (re->re_desc.d_csr & SAFE_PE_CSR_STATUS) { - device_printf(sc->sc_dev, "csr 0x%x cmd0 0x%x cmd1 0x%x\n", - re->re_desc.d_csr, - re->re_sa.sa_cmd0, re->re_sa.sa_cmd1); - safestats.st_peoperr++; - crp->crp_etype = EIO; /* something more meaningful? */ - } - - if (re->re_dst.map != NULL && re->re_dst.map != re->re_src.map) - pci_unmap_operand(sc, &re->re_dst); - pci_unmap_operand(sc, &re->re_src); - - /* - * If result was written to a differet mbuf chain, swap - * it in as the return value and reclaim the original. - */ - if ((crp->crp_flags & CRYPTO_F_SKBUF) && re->re_src_skb != re->re_dst_skb) { - device_printf(sc->sc_dev, "no CRYPTO_F_SKBUF swapping support\n"); - /* kfree_skb(skb) */ - /* crp->crp_buf = (caddr_t)re->re_dst_skb */ - return; - } - - if (re->re_flags & SAFE_QFLAGS_COPYOUTIV) { - /* copy out IV for future use */ - for (crd = crp->crp_desc; crd; crd = crd->crd_next) { - int i; - int ivsize; - - if (crd->crd_alg == CRYPTO_DES_CBC || - crd->crd_alg == CRYPTO_3DES_CBC) { - ivsize = 2*sizeof(u_int32_t); - } else if (crd->crd_alg == CRYPTO_AES_CBC) { - ivsize = 4*sizeof(u_int32_t); - } else - continue; - crypto_copydata(crp->crp_flags, crp->crp_buf, - crd->crd_skip + crd->crd_len - ivsize, ivsize, - (caddr_t)sc->sc_sessions[re->re_sesn].ses_iv); - for (i = 0; - i < ivsize/sizeof(sc->sc_sessions[re->re_sesn].ses_iv[0]); - i++) - sc->sc_sessions[re->re_sesn].ses_iv[i] = - cpu_to_le32(sc->sc_sessions[re->re_sesn].ses_iv[i]); - break; - } - } - - if (re->re_flags & SAFE_QFLAGS_COPYOUTICV) { - /* copy out ICV result */ - for (crd = crp->crp_desc; crd; crd = crd->crd_next) { - if (!(crd->crd_alg == CRYPTO_MD5_HMAC || - crd->crd_alg == CRYPTO_SHA1_HMAC || - crd->crd_alg == CRYPTO_NULL_HMAC)) - continue; - if (crd->crd_alg == CRYPTO_SHA1_HMAC) { - /* - * SHA-1 ICV's are byte-swapped; fix 'em up - * before copy them to their destination. - */ - re->re_sastate.sa_saved_indigest[0] = - cpu_to_be32(re->re_sastate.sa_saved_indigest[0]); - re->re_sastate.sa_saved_indigest[1] = - cpu_to_be32(re->re_sastate.sa_saved_indigest[1]); - re->re_sastate.sa_saved_indigest[2] = - cpu_to_be32(re->re_sastate.sa_saved_indigest[2]); - } else { - re->re_sastate.sa_saved_indigest[0] = - cpu_to_le32(re->re_sastate.sa_saved_indigest[0]); - re->re_sastate.sa_saved_indigest[1] = - cpu_to_le32(re->re_sastate.sa_saved_indigest[1]); - re->re_sastate.sa_saved_indigest[2] = - cpu_to_le32(re->re_sastate.sa_saved_indigest[2]); - } - crypto_copyback(crp->crp_flags, crp->crp_buf, - crd->crd_inject, - sc->sc_sessions[re->re_sesn].ses_mlen, - (caddr_t)re->re_sastate.sa_saved_indigest); - break; - } - } - crypto_done(crp); -} - - -#if defined(CONFIG_OCF_RANDOMHARVEST) && !defined(SAFE_NO_RNG) -#define SAFE_RNG_MAXWAIT 1000 - -static void -safe_rng_init(struct safe_softc *sc) -{ - u_int32_t w, v; - int i; - - DPRINTF(("%s()\n", __FUNCTION__)); - - WRITE_REG(sc, SAFE_RNG_CTRL, 0); - /* use default value according to the manual */ - WRITE_REG(sc, SAFE_RNG_CNFG, 0x834); /* magic from SafeNet */ - WRITE_REG(sc, SAFE_RNG_ALM_CNT, 0); - - /* - * There is a bug in rev 1.0 of the 1140 that when the RNG - * is brought out of reset the ready status flag does not - * work until the RNG has finished its internal initialization. - * - * So in order to determine the device is through its - * initialization we must read the data register, using the - * status reg in the read in case it is initialized. Then read - * the data register until it changes from the first read. - * Once it changes read the data register until it changes - * again. At this time the RNG is considered initialized. - * This could take between 750ms - 1000ms in time. - */ - i = 0; - w = READ_REG(sc, SAFE_RNG_OUT); - do { - v = READ_REG(sc, SAFE_RNG_OUT); - if (v != w) { - w = v; - break; - } - DELAY(10); - } while (++i < SAFE_RNG_MAXWAIT); - - /* Wait Until data changes again */ - i = 0; - do { - v = READ_REG(sc, SAFE_RNG_OUT); - if (v != w) - break; - DELAY(10); - } while (++i < SAFE_RNG_MAXWAIT); -} - -static __inline void -safe_rng_disable_short_cycle(struct safe_softc *sc) -{ - DPRINTF(("%s()\n", __FUNCTION__)); - - WRITE_REG(sc, SAFE_RNG_CTRL, - READ_REG(sc, SAFE_RNG_CTRL) &~ SAFE_RNG_CTRL_SHORTEN); -} - -static __inline void -safe_rng_enable_short_cycle(struct safe_softc *sc) -{ - DPRINTF(("%s()\n", __FUNCTION__)); - - WRITE_REG(sc, SAFE_RNG_CTRL, - READ_REG(sc, SAFE_RNG_CTRL) | SAFE_RNG_CTRL_SHORTEN); -} - -static __inline u_int32_t -safe_rng_read(struct safe_softc *sc) -{ - int i; - - i = 0; - while (READ_REG(sc, SAFE_RNG_STAT) != 0 && ++i < SAFE_RNG_MAXWAIT) - ; - return READ_REG(sc, SAFE_RNG_OUT); -} - -static int -safe_read_random(void *arg, u_int32_t *buf, int maxwords) -{ - struct safe_softc *sc = (struct safe_softc *) arg; - int i, rc; - - DPRINTF(("%s()\n", __FUNCTION__)); - - safestats.st_rng++; - /* - * Fetch the next block of data. - */ - if (maxwords > safe_rngbufsize) - maxwords = safe_rngbufsize; - if (maxwords > SAFE_RNG_MAXBUFSIZ) - maxwords = SAFE_RNG_MAXBUFSIZ; -retry: - /* read as much as we can */ - for (rc = 0; rc < maxwords; rc++) { - if (READ_REG(sc, SAFE_RNG_STAT) != 0) - break; - buf[rc] = READ_REG(sc, SAFE_RNG_OUT); - } - if (rc == 0) - return 0; - /* - * Check the comparator alarm count and reset the h/w if - * it exceeds our threshold. This guards against the - * hardware oscillators resonating with external signals. - */ - if (READ_REG(sc, SAFE_RNG_ALM_CNT) > safe_rngmaxalarm) { - u_int32_t freq_inc, w; - - DPRINTF(("%s: alarm count %u exceeds threshold %u\n", __func__, - (unsigned)READ_REG(sc, SAFE_RNG_ALM_CNT), safe_rngmaxalarm)); - safestats.st_rngalarm++; - safe_rng_enable_short_cycle(sc); - freq_inc = 18; - for (i = 0; i < 64; i++) { - w = READ_REG(sc, SAFE_RNG_CNFG); - freq_inc = ((w + freq_inc) & 0x3fL); - w = ((w & ~0x3fL) | freq_inc); - WRITE_REG(sc, SAFE_RNG_CNFG, w); - - WRITE_REG(sc, SAFE_RNG_ALM_CNT, 0); - - (void) safe_rng_read(sc); - DELAY(25); - - if (READ_REG(sc, SAFE_RNG_ALM_CNT) == 0) { - safe_rng_disable_short_cycle(sc); - goto retry; - } - freq_inc = 1; - } - safe_rng_disable_short_cycle(sc); - } else - WRITE_REG(sc, SAFE_RNG_ALM_CNT, 0); - - return(rc); -} -#endif /* defined(CONFIG_OCF_RANDOMHARVEST) && !defined(SAFE_NO_RNG) */ - - -/* - * Resets the board. Values in the regesters are left as is - * from the reset (i.e. initial values are assigned elsewhere). - */ -static void -safe_reset_board(struct safe_softc *sc) -{ - u_int32_t v; - /* - * Reset the device. The manual says no delay - * is needed between marking and clearing reset. - */ - DPRINTF(("%s()\n", __FUNCTION__)); - - v = READ_REG(sc, SAFE_PE_DMACFG) &~ - (SAFE_PE_DMACFG_PERESET | SAFE_PE_DMACFG_PDRRESET | - SAFE_PE_DMACFG_SGRESET); - WRITE_REG(sc, SAFE_PE_DMACFG, v - | SAFE_PE_DMACFG_PERESET - | SAFE_PE_DMACFG_PDRRESET - | SAFE_PE_DMACFG_SGRESET); - WRITE_REG(sc, SAFE_PE_DMACFG, v); -} - -/* - * Initialize registers we need to touch only once. - */ -static void -safe_init_board(struct safe_softc *sc) -{ - u_int32_t v, dwords; - - DPRINTF(("%s()\n", __FUNCTION__)); - - v = READ_REG(sc, SAFE_PE_DMACFG); - v &=~ ( SAFE_PE_DMACFG_PEMODE - | SAFE_PE_DMACFG_FSENA /* failsafe enable */ - | SAFE_PE_DMACFG_GPRPCI /* gather ring on PCI */ - | SAFE_PE_DMACFG_SPRPCI /* scatter ring on PCI */ - | SAFE_PE_DMACFG_ESDESC /* endian-swap descriptors */ - | SAFE_PE_DMACFG_ESPDESC /* endian-swap part. desc's */ - | SAFE_PE_DMACFG_ESSA /* endian-swap SA's */ - | SAFE_PE_DMACFG_ESPACKET /* swap the packet data */ - ); - v |= SAFE_PE_DMACFG_FSENA /* failsafe enable */ - | SAFE_PE_DMACFG_GPRPCI /* gather ring on PCI */ - | SAFE_PE_DMACFG_SPRPCI /* scatter ring on PCI */ - | SAFE_PE_DMACFG_ESDESC /* endian-swap descriptors */ - | SAFE_PE_DMACFG_ESPDESC /* endian-swap part. desc's */ - | SAFE_PE_DMACFG_ESSA /* endian-swap SA's */ -#if 0 - | SAFE_PE_DMACFG_ESPACKET /* swap the packet data */ -#endif - ; - WRITE_REG(sc, SAFE_PE_DMACFG, v); - -#ifdef __BIG_ENDIAN - /* tell the safenet that we are 4321 and not 1234 */ - WRITE_REG(sc, SAFE_ENDIAN, 0xe4e41b1b); -#endif - - if (sc->sc_chiprev == SAFE_REV(1,0)) { - /* - * Avoid large PCI DMA transfers. Rev 1.0 has a bug where - * "target mode transfers" done while the chip is DMA'ing - * >1020 bytes cause the hardware to lockup. To avoid this - * we reduce the max PCI transfer size and use small source - * particle descriptors (<= 256 bytes). - */ - WRITE_REG(sc, SAFE_DMA_CFG, 256); - device_printf(sc->sc_dev, - "Reduce max DMA size to %u words for rev %u.%u WAR\n", - (unsigned) ((READ_REG(sc, SAFE_DMA_CFG)>>2) & 0xff), - (unsigned) SAFE_REV_MAJ(sc->sc_chiprev), - (unsigned) SAFE_REV_MIN(sc->sc_chiprev)); - sc->sc_max_dsize = 256; - } else { - sc->sc_max_dsize = SAFE_MAX_DSIZE; - } - - /* NB: operands+results are overlaid */ - WRITE_REG(sc, SAFE_PE_PDRBASE, sc->sc_ringalloc.dma_paddr); - WRITE_REG(sc, SAFE_PE_RDRBASE, sc->sc_ringalloc.dma_paddr); - /* - * Configure ring entry size and number of items in the ring. - */ - KASSERT((sizeof(struct safe_ringentry) % sizeof(u_int32_t)) == 0, - ("PE ring entry not 32-bit aligned!")); - dwords = sizeof(struct safe_ringentry) / sizeof(u_int32_t); - WRITE_REG(sc, SAFE_PE_RINGCFG, - (dwords << SAFE_PE_RINGCFG_OFFSET_S) | SAFE_MAX_NQUEUE); - WRITE_REG(sc, SAFE_PE_RINGPOLL, 0); /* disable polling */ - - WRITE_REG(sc, SAFE_PE_GRNGBASE, sc->sc_spalloc.dma_paddr); - WRITE_REG(sc, SAFE_PE_SRNGBASE, sc->sc_dpalloc.dma_paddr); - WRITE_REG(sc, SAFE_PE_PARTSIZE, - (SAFE_TOTAL_DPART<<16) | SAFE_TOTAL_SPART); - /* - * NB: destination particles are fixed size. We use - * an mbuf cluster and require all results go to - * clusters or smaller. - */ - WRITE_REG(sc, SAFE_PE_PARTCFG, sc->sc_max_dsize); - - /* it's now safe to enable PE mode, do it */ - WRITE_REG(sc, SAFE_PE_DMACFG, v | SAFE_PE_DMACFG_PEMODE); - - /* - * Configure hardware to use level-triggered interrupts and - * to interrupt after each descriptor is processed. - */ - WRITE_REG(sc, SAFE_HI_CFG, SAFE_HI_CFG_LEVEL); - WRITE_REG(sc, SAFE_HI_CLR, 0xffffffff); - WRITE_REG(sc, SAFE_HI_DESC_CNT, 1); - WRITE_REG(sc, SAFE_HI_MASK, SAFE_INT_PE_DDONE | SAFE_INT_PE_ERROR); -} - - -/* - * Clean up after a chip crash. - * It is assumed that the caller in splimp() - */ -static void -safe_cleanchip(struct safe_softc *sc) -{ - DPRINTF(("%s()\n", __FUNCTION__)); - - if (sc->sc_nqchip != 0) { - struct safe_ringentry *re = sc->sc_back; - - while (re != sc->sc_front) { - if (re->re_desc.d_csr != 0) - safe_free_entry(sc, re); - if (++re == sc->sc_ringtop) - re = sc->sc_ring; - } - sc->sc_back = re; - sc->sc_nqchip = 0; - } -} - -/* - * free a safe_q - * It is assumed that the caller is within splimp(). - */ -static int -safe_free_entry(struct safe_softc *sc, struct safe_ringentry *re) -{ - struct cryptop *crp; - - DPRINTF(("%s()\n", __FUNCTION__)); - - /* - * Free header MCR - */ - if ((re->re_dst_skb != NULL) && (re->re_src_skb != re->re_dst_skb)) -#ifdef NOTYET - m_freem(re->re_dst_m); -#else - printk("%s,%d: SKB not supported\n", __FILE__, __LINE__); -#endif - - crp = (struct cryptop *)re->re_crp; - - re->re_desc.d_csr = 0; - - crp->crp_etype = EFAULT; - crypto_done(crp); - return(0); -} - -/* - * Routine to reset the chip and clean up. - * It is assumed that the caller is in splimp() - */ -static void -safe_totalreset(struct safe_softc *sc) -{ - DPRINTF(("%s()\n", __FUNCTION__)); - - safe_reset_board(sc); - safe_init_board(sc); - safe_cleanchip(sc); -} - -/* - * Is the operand suitable aligned for direct DMA. Each - * segment must be aligned on a 32-bit boundary and all - * but the last segment must be a multiple of 4 bytes. - */ -static int -safe_dmamap_aligned(struct safe_softc *sc, const struct safe_operand *op) -{ - int i; - - DPRINTF(("%s()\n", __FUNCTION__)); - - for (i = 0; i < op->nsegs; i++) { - if (op->segs[i].ds_addr & 3) - return (0); - if (i != (op->nsegs - 1) && (op->segs[i].ds_len & 3)) - return (0); - } - return (1); -} - -/* - * Is the operand suitable for direct DMA as the destination - * of an operation. The hardware requires that each ``particle'' - * but the last in an operation result have the same size. We - * fix that size at SAFE_MAX_DSIZE bytes. This routine returns - * 0 if some segment is not a multiple of of this size, 1 if all - * segments are exactly this size, or 2 if segments are at worst - * a multple of this size. - */ -static int -safe_dmamap_uniform(struct safe_softc *sc, const struct safe_operand *op) -{ - int result = 1; - - DPRINTF(("%s()\n", __FUNCTION__)); - - if (op->nsegs > 0) { - int i; - - for (i = 0; i < op->nsegs-1; i++) { - if (op->segs[i].ds_len % sc->sc_max_dsize) - return (0); - if (op->segs[i].ds_len != sc->sc_max_dsize) - result = 2; - } - } - return (result); -} - -static int -safe_kprocess(device_t dev, struct cryptkop *krp, int hint) -{ - struct safe_softc *sc = device_get_softc(dev); - struct safe_pkq *q; - unsigned long flags; - - DPRINTF(("%s()\n", __FUNCTION__)); - - if (sc == NULL) { - krp->krp_status = EINVAL; - goto err; - } - - if (krp->krp_op != CRK_MOD_EXP) { - krp->krp_status = EOPNOTSUPP; - goto err; - } - - q = (struct safe_pkq *) kmalloc(sizeof(*q), GFP_KERNEL); - if (q == NULL) { - krp->krp_status = ENOMEM; - goto err; - } - memset(q, 0, sizeof(*q)); - q->pkq_krp = krp; - INIT_LIST_HEAD(&q->pkq_list); - - spin_lock_irqsave(&sc->sc_pkmtx, flags); - list_add_tail(&q->pkq_list, &sc->sc_pkq); - safe_kfeed(sc); - spin_unlock_irqrestore(&sc->sc_pkmtx, flags); - return (0); - -err: - crypto_kdone(krp); - return (0); -} - -#define SAFE_CRK_PARAM_BASE 0 -#define SAFE_CRK_PARAM_EXP 1 -#define SAFE_CRK_PARAM_MOD 2 - -static int -safe_kstart(struct safe_softc *sc) -{ - struct cryptkop *krp = sc->sc_pkq_cur->pkq_krp; - int exp_bits, mod_bits, base_bits; - u_int32_t op, a_off, b_off, c_off, d_off; - - DPRINTF(("%s()\n", __FUNCTION__)); - - if (krp->krp_iparams < 3 || krp->krp_oparams != 1) { - krp->krp_status = EINVAL; - return (1); - } - - base_bits = safe_ksigbits(sc, &krp->krp_param[SAFE_CRK_PARAM_BASE]); - if (base_bits > 2048) - goto too_big; - if (base_bits <= 0) /* 5. base not zero */ - goto too_small; - - exp_bits = safe_ksigbits(sc, &krp->krp_param[SAFE_CRK_PARAM_EXP]); - if (exp_bits > 2048) - goto too_big; - if (exp_bits <= 0) /* 1. exponent word length > 0 */ - goto too_small; /* 4. exponent not zero */ - - mod_bits = safe_ksigbits(sc, &krp->krp_param[SAFE_CRK_PARAM_MOD]); - if (mod_bits > 2048) - goto too_big; - if (mod_bits <= 32) /* 2. modulus word length > 1 */ - goto too_small; /* 8. MSW of modulus != zero */ - if (mod_bits < exp_bits) /* 3 modulus len >= exponent len */ - goto too_small; - if ((krp->krp_param[SAFE_CRK_PARAM_MOD].crp_p[0] & 1) == 0) - goto bad_domain; /* 6. modulus is odd */ - if (mod_bits > krp->krp_param[krp->krp_iparams].crp_nbits) - goto too_small; /* make sure result will fit */ - - /* 7. modulus > base */ - if (mod_bits < base_bits) - goto too_small; - if (mod_bits == base_bits) { - u_int8_t *basep, *modp; - int i; - - basep = krp->krp_param[SAFE_CRK_PARAM_BASE].crp_p + - ((base_bits + 7) / 8) - 1; - modp = krp->krp_param[SAFE_CRK_PARAM_MOD].crp_p + - ((mod_bits + 7) / 8) - 1; - - for (i = 0; i < (mod_bits + 7) / 8; i++, basep--, modp--) { - if (*modp < *basep) - goto too_small; - if (*modp > *basep) - break; - } - } - - /* And on the 9th step, he rested. */ - - WRITE_REG(sc, SAFE_PK_A_LEN, (exp_bits + 31) / 32); - WRITE_REG(sc, SAFE_PK_B_LEN, (mod_bits + 31) / 32); - if (mod_bits > 1024) { - op = SAFE_PK_FUNC_EXP4; - a_off = 0x000; - b_off = 0x100; - c_off = 0x200; - d_off = 0x300; - } else { - op = SAFE_PK_FUNC_EXP16; - a_off = 0x000; - b_off = 0x080; - c_off = 0x100; - d_off = 0x180; - } - sc->sc_pk_reslen = b_off - a_off; - sc->sc_pk_resoff = d_off; - - /* A is exponent, B is modulus, C is base, D is result */ - safe_kload_reg(sc, a_off, b_off - a_off, - &krp->krp_param[SAFE_CRK_PARAM_EXP]); - WRITE_REG(sc, SAFE_PK_A_ADDR, a_off >> 2); - safe_kload_reg(sc, b_off, b_off - a_off, - &krp->krp_param[SAFE_CRK_PARAM_MOD]); - WRITE_REG(sc, SAFE_PK_B_ADDR, b_off >> 2); - safe_kload_reg(sc, c_off, b_off - a_off, - &krp->krp_param[SAFE_CRK_PARAM_BASE]); - WRITE_REG(sc, SAFE_PK_C_ADDR, c_off >> 2); - WRITE_REG(sc, SAFE_PK_D_ADDR, d_off >> 2); - - WRITE_REG(sc, SAFE_PK_FUNC, op | SAFE_PK_FUNC_RUN); - - return (0); - -too_big: - krp->krp_status = E2BIG; - return (1); -too_small: - krp->krp_status = ERANGE; - return (1); -bad_domain: - krp->krp_status = EDOM; - return (1); -} - -static int -safe_ksigbits(struct safe_softc *sc, struct crparam *cr) -{ - u_int plen = (cr->crp_nbits + 7) / 8; - int i, sig = plen * 8; - u_int8_t c, *p = cr->crp_p; - - DPRINTF(("%s()\n", __FUNCTION__)); - - for (i = plen - 1; i >= 0; i--) { - c = p[i]; - if (c != 0) { - while ((c & 0x80) == 0) { - sig--; - c <<= 1; - } - break; - } - sig -= 8; - } - return (sig); -} - -static void -safe_kfeed(struct safe_softc *sc) -{ - struct safe_pkq *q, *tmp; - - DPRINTF(("%s()\n", __FUNCTION__)); - - if (list_empty(&sc->sc_pkq) && sc->sc_pkq_cur == NULL) - return; - if (sc->sc_pkq_cur != NULL) - return; - list_for_each_entry_safe(q, tmp, &sc->sc_pkq, pkq_list) { - sc->sc_pkq_cur = q; - list_del(&q->pkq_list); - if (safe_kstart(sc) != 0) { - crypto_kdone(q->pkq_krp); - kfree(q); - sc->sc_pkq_cur = NULL; - } else { - /* op started, start polling */ - mod_timer(&sc->sc_pkto, jiffies + 1); - break; - } - } -} - -static void -safe_kpoll(unsigned long arg) -{ - struct safe_softc *sc = NULL; - struct safe_pkq *q; - struct crparam *res; - int i; - u_int32_t buf[64]; - unsigned long flags; - - DPRINTF(("%s()\n", __FUNCTION__)); - - if (arg >= SAFE_MAX_CHIPS) - return; - sc = safe_chip_idx[arg]; - if (!sc) { - DPRINTF(("%s() - bad callback\n", __FUNCTION__)); - return; - } - - spin_lock_irqsave(&sc->sc_pkmtx, flags); - if (sc->sc_pkq_cur == NULL) - goto out; - if (READ_REG(sc, SAFE_PK_FUNC) & SAFE_PK_FUNC_RUN) { - /* still running, check back later */ - mod_timer(&sc->sc_pkto, jiffies + 1); - goto out; - } - - q = sc->sc_pkq_cur; - res = &q->pkq_krp->krp_param[q->pkq_krp->krp_iparams]; - bzero(buf, sizeof(buf)); - bzero(res->crp_p, (res->crp_nbits + 7) / 8); - for (i = 0; i < sc->sc_pk_reslen >> 2; i++) - buf[i] = le32_to_cpu(READ_REG(sc, SAFE_PK_RAM_START + - sc->sc_pk_resoff + (i << 2))); - bcopy(buf, res->crp_p, (res->crp_nbits + 7) / 8); - /* - * reduce the bits that need copying if possible - */ - res->crp_nbits = min(res->crp_nbits,sc->sc_pk_reslen * 8); - res->crp_nbits = safe_ksigbits(sc, res); - - for (i = SAFE_PK_RAM_START; i < SAFE_PK_RAM_END; i += 4) - WRITE_REG(sc, i, 0); - - crypto_kdone(q->pkq_krp); - kfree(q); - sc->sc_pkq_cur = NULL; - - safe_kfeed(sc); -out: - spin_unlock_irqrestore(&sc->sc_pkmtx, flags); -} - -static void -safe_kload_reg(struct safe_softc *sc, u_int32_t off, u_int32_t len, - struct crparam *n) -{ - u_int32_t buf[64], i; - - DPRINTF(("%s()\n", __FUNCTION__)); - - bzero(buf, sizeof(buf)); - bcopy(n->crp_p, buf, (n->crp_nbits + 7) / 8); - - for (i = 0; i < len >> 2; i++) - WRITE_REG(sc, SAFE_PK_RAM_START + off + (i << 2), - cpu_to_le32(buf[i])); -} - -#ifdef SAFE_DEBUG -static void -safe_dump_dmastatus(struct safe_softc *sc, const char *tag) -{ - printf("%s: ENDIAN 0x%x SRC 0x%x DST 0x%x STAT 0x%x\n" - , tag - , READ_REG(sc, SAFE_DMA_ENDIAN) - , READ_REG(sc, SAFE_DMA_SRCADDR) - , READ_REG(sc, SAFE_DMA_DSTADDR) - , READ_REG(sc, SAFE_DMA_STAT) - ); -} - -static void -safe_dump_intrstate(struct safe_softc *sc, const char *tag) -{ - printf("%s: HI_CFG 0x%x HI_MASK 0x%x HI_DESC_CNT 0x%x HU_STAT 0x%x HM_STAT 0x%x\n" - , tag - , READ_REG(sc, SAFE_HI_CFG) - , READ_REG(sc, SAFE_HI_MASK) - , READ_REG(sc, SAFE_HI_DESC_CNT) - , READ_REG(sc, SAFE_HU_STAT) - , READ_REG(sc, SAFE_HM_STAT) - ); -} - -static void -safe_dump_ringstate(struct safe_softc *sc, const char *tag) -{ - u_int32_t estat = READ_REG(sc, SAFE_PE_ERNGSTAT); - - /* NB: assume caller has lock on ring */ - printf("%s: ERNGSTAT %x (next %u) back %lu front %lu\n", - tag, - estat, (estat >> SAFE_PE_ERNGSTAT_NEXT_S), - (unsigned long)(sc->sc_back - sc->sc_ring), - (unsigned long)(sc->sc_front - sc->sc_ring)); -} - -static void -safe_dump_request(struct safe_softc *sc, const char* tag, struct safe_ringentry *re) -{ - int ix, nsegs; - - ix = re - sc->sc_ring; - printf("%s: %p (%u): csr %x src %x dst %x sa %x len %x\n" - , tag - , re, ix - , re->re_desc.d_csr - , re->re_desc.d_src - , re->re_desc.d_dst - , re->re_desc.d_sa - , re->re_desc.d_len - ); - if (re->re_src.nsegs > 1) { - ix = (re->re_desc.d_src - sc->sc_spalloc.dma_paddr) / - sizeof(struct safe_pdesc); - for (nsegs = re->re_src.nsegs; nsegs; nsegs--) { - printf(" spd[%u] %p: %p size %u flags %x" - , ix, &sc->sc_spring[ix] - , (caddr_t)(uintptr_t) sc->sc_spring[ix].pd_addr - , sc->sc_spring[ix].pd_size - , sc->sc_spring[ix].pd_flags - ); - if (sc->sc_spring[ix].pd_size == 0) - printf(" (zero!)"); - printf("\n"); - if (++ix == SAFE_TOTAL_SPART) - ix = 0; - } - } - if (re->re_dst.nsegs > 1) { - ix = (re->re_desc.d_dst - sc->sc_dpalloc.dma_paddr) / - sizeof(struct safe_pdesc); - for (nsegs = re->re_dst.nsegs; nsegs; nsegs--) { - printf(" dpd[%u] %p: %p flags %x\n" - , ix, &sc->sc_dpring[ix] - , (caddr_t)(uintptr_t) sc->sc_dpring[ix].pd_addr - , sc->sc_dpring[ix].pd_flags - ); - if (++ix == SAFE_TOTAL_DPART) - ix = 0; - } - } - printf("sa: cmd0 %08x cmd1 %08x staterec %x\n", - re->re_sa.sa_cmd0, re->re_sa.sa_cmd1, re->re_sa.sa_staterec); - printf("sa: key %x %x %x %x %x %x %x %x\n" - , re->re_sa.sa_key[0] - , re->re_sa.sa_key[1] - , re->re_sa.sa_key[2] - , re->re_sa.sa_key[3] - , re->re_sa.sa_key[4] - , re->re_sa.sa_key[5] - , re->re_sa.sa_key[6] - , re->re_sa.sa_key[7] - ); - printf("sa: indigest %x %x %x %x %x\n" - , re->re_sa.sa_indigest[0] - , re->re_sa.sa_indigest[1] - , re->re_sa.sa_indigest[2] - , re->re_sa.sa_indigest[3] - , re->re_sa.sa_indigest[4] - ); - printf("sa: outdigest %x %x %x %x %x\n" - , re->re_sa.sa_outdigest[0] - , re->re_sa.sa_outdigest[1] - , re->re_sa.sa_outdigest[2] - , re->re_sa.sa_outdigest[3] - , re->re_sa.sa_outdigest[4] - ); - printf("sr: iv %x %x %x %x\n" - , re->re_sastate.sa_saved_iv[0] - , re->re_sastate.sa_saved_iv[1] - , re->re_sastate.sa_saved_iv[2] - , re->re_sastate.sa_saved_iv[3] - ); - printf("sr: hashbc %u indigest %x %x %x %x %x\n" - , re->re_sastate.sa_saved_hashbc - , re->re_sastate.sa_saved_indigest[0] - , re->re_sastate.sa_saved_indigest[1] - , re->re_sastate.sa_saved_indigest[2] - , re->re_sastate.sa_saved_indigest[3] - , re->re_sastate.sa_saved_indigest[4] - ); -} - -static void -safe_dump_ring(struct safe_softc *sc, const char *tag) -{ - unsigned long flags; - - spin_lock_irqsave(&sc->sc_ringmtx, flags); - printf("\nSafeNet Ring State:\n"); - safe_dump_intrstate(sc, tag); - safe_dump_dmastatus(sc, tag); - safe_dump_ringstate(sc, tag); - if (sc->sc_nqchip) { - struct safe_ringentry *re = sc->sc_back; - do { - safe_dump_request(sc, tag, re); - if (++re == sc->sc_ringtop) - re = sc->sc_ring; - } while (re != sc->sc_front); - } - spin_unlock_irqrestore(&sc->sc_ringmtx, flags); -} -#endif /* SAFE_DEBUG */ - - -static int safe_probe(struct pci_dev *dev, const struct pci_device_id *ent) -{ - struct safe_softc *sc = NULL; - u32 mem_start, mem_len, cmd; - int i, rc, devinfo; - dma_addr_t raddr; - static int num_chips = 0; - - DPRINTF(("%s()\n", __FUNCTION__)); - - if (pci_enable_device(dev) < 0) - return(-ENODEV); - - if (!dev->irq) { - printk("safe: found device with no IRQ assigned. check BIOS settings!"); - pci_disable_device(dev); - return(-ENODEV); - } - - if (pci_set_mwi(dev)) { - printk("safe: pci_set_mwi failed!"); - return(-ENODEV); - } - - sc = (struct safe_softc *) kmalloc(sizeof(*sc), GFP_KERNEL); - if (!sc) - return(-ENOMEM); - memset(sc, 0, sizeof(*sc)); - - softc_device_init(sc, "safe", num_chips, safe_methods); - - sc->sc_irq = -1; - sc->sc_cid = -1; - sc->sc_pcidev = dev; - if (num_chips < SAFE_MAX_CHIPS) { - safe_chip_idx[device_get_unit(sc->sc_dev)] = sc; - num_chips++; - } - - INIT_LIST_HEAD(&sc->sc_pkq); - spin_lock_init(&sc->sc_pkmtx); - - pci_set_drvdata(sc->sc_pcidev, sc); - - /* we read its hardware registers as memory */ - mem_start = pci_resource_start(sc->sc_pcidev, 0); - mem_len = pci_resource_len(sc->sc_pcidev, 0); - - sc->sc_base_addr = (ocf_iomem_t) ioremap(mem_start, mem_len); - if (!sc->sc_base_addr) { - device_printf(sc->sc_dev, "failed to ioremap 0x%x-0x%x\n", - mem_start, mem_start + mem_len - 1); - goto out; - } - - /* fix up the bus size */ - if (pci_set_dma_mask(sc->sc_pcidev, DMA_32BIT_MASK)) { - device_printf(sc->sc_dev, "No usable DMA configuration, aborting.\n"); - goto out; - } - if (pci_set_consistent_dma_mask(sc->sc_pcidev, DMA_32BIT_MASK)) { - device_printf(sc->sc_dev, "No usable consistent DMA configuration, aborting.\n"); - goto out; - } - - pci_set_master(sc->sc_pcidev); - - pci_read_config_dword(sc->sc_pcidev, PCI_COMMAND, &cmd); - - if (!(cmd & PCI_COMMAND_MEMORY)) { - device_printf(sc->sc_dev, "failed to enable memory mapping\n"); - goto out; - } - - if (!(cmd & PCI_COMMAND_MASTER)) { - device_printf(sc->sc_dev, "failed to enable bus mastering\n"); - goto out; - } - - rc = request_irq(dev->irq, safe_intr, IRQF_SHARED, "safe", sc); - if (rc) { - device_printf(sc->sc_dev, "failed to hook irq %d\n", sc->sc_irq); - goto out; - } - sc->sc_irq = dev->irq; - - sc->sc_chiprev = READ_REG(sc, SAFE_DEVINFO) & - (SAFE_DEVINFO_REV_MAJ | SAFE_DEVINFO_REV_MIN); - - /* - * Allocate packet engine descriptors. - */ - sc->sc_ringalloc.dma_vaddr = pci_alloc_consistent(sc->sc_pcidev, - SAFE_MAX_NQUEUE * sizeof (struct safe_ringentry), - &sc->sc_ringalloc.dma_paddr); - if (!sc->sc_ringalloc.dma_vaddr) { - device_printf(sc->sc_dev, "cannot allocate PE descriptor ring\n"); - goto out; - } - - /* - * Hookup the static portion of all our data structures. - */ - sc->sc_ring = (struct safe_ringentry *) sc->sc_ringalloc.dma_vaddr; - sc->sc_ringtop = sc->sc_ring + SAFE_MAX_NQUEUE; - sc->sc_front = sc->sc_ring; - sc->sc_back = sc->sc_ring; - raddr = sc->sc_ringalloc.dma_paddr; - bzero(sc->sc_ring, SAFE_MAX_NQUEUE * sizeof(struct safe_ringentry)); - for (i = 0; i < SAFE_MAX_NQUEUE; i++) { - struct safe_ringentry *re = &sc->sc_ring[i]; - - re->re_desc.d_sa = raddr + - offsetof(struct safe_ringentry, re_sa); - re->re_sa.sa_staterec = raddr + - offsetof(struct safe_ringentry, re_sastate); - - raddr += sizeof (struct safe_ringentry); - } - spin_lock_init(&sc->sc_ringmtx); - - /* - * Allocate scatter and gather particle descriptors. - */ - sc->sc_spalloc.dma_vaddr = pci_alloc_consistent(sc->sc_pcidev, - SAFE_TOTAL_SPART * sizeof (struct safe_pdesc), - &sc->sc_spalloc.dma_paddr); - if (!sc->sc_spalloc.dma_vaddr) { - device_printf(sc->sc_dev, "cannot allocate source particle descriptor ring\n"); - goto out; - } - sc->sc_spring = (struct safe_pdesc *) sc->sc_spalloc.dma_vaddr; - sc->sc_springtop = sc->sc_spring + SAFE_TOTAL_SPART; - sc->sc_spfree = sc->sc_spring; - bzero(sc->sc_spring, SAFE_TOTAL_SPART * sizeof(struct safe_pdesc)); - - sc->sc_dpalloc.dma_vaddr = pci_alloc_consistent(sc->sc_pcidev, - SAFE_TOTAL_DPART * sizeof (struct safe_pdesc), - &sc->sc_dpalloc.dma_paddr); - if (!sc->sc_dpalloc.dma_vaddr) { - device_printf(sc->sc_dev, "cannot allocate destination particle descriptor ring\n"); - goto out; - } - sc->sc_dpring = (struct safe_pdesc *) sc->sc_dpalloc.dma_vaddr; - sc->sc_dpringtop = sc->sc_dpring + SAFE_TOTAL_DPART; - sc->sc_dpfree = sc->sc_dpring; - bzero(sc->sc_dpring, SAFE_TOTAL_DPART * sizeof(struct safe_pdesc)); - - sc->sc_cid = crypto_get_driverid(softc_get_device(sc), CRYPTOCAP_F_HARDWARE); - if (sc->sc_cid < 0) { - device_printf(sc->sc_dev, "could not get crypto driver id\n"); - goto out; - } - - printf("%s:", device_get_nameunit(sc->sc_dev)); - - devinfo = READ_REG(sc, SAFE_DEVINFO); - if (devinfo & SAFE_DEVINFO_RNG) { - sc->sc_flags |= SAFE_FLAGS_RNG; - printf(" rng"); - } - if (devinfo & SAFE_DEVINFO_PKEY) { - printf(" key"); - sc->sc_flags |= SAFE_FLAGS_KEY; - crypto_kregister(sc->sc_cid, CRK_MOD_EXP, 0); -#if 0 - crypto_kregister(sc->sc_cid, CRK_MOD_EXP_CRT, 0); -#endif - init_timer(&sc->sc_pkto); - sc->sc_pkto.function = safe_kpoll; - sc->sc_pkto.data = (unsigned long) device_get_unit(sc->sc_dev); - } - if (devinfo & SAFE_DEVINFO_DES) { - printf(" des/3des"); - crypto_register(sc->sc_cid, CRYPTO_3DES_CBC, 0, 0); - crypto_register(sc->sc_cid, CRYPTO_DES_CBC, 0, 0); - } - if (devinfo & SAFE_DEVINFO_AES) { - printf(" aes"); - crypto_register(sc->sc_cid, CRYPTO_AES_CBC, 0, 0); - } - if (devinfo & SAFE_DEVINFO_MD5) { - printf(" md5"); - crypto_register(sc->sc_cid, CRYPTO_MD5_HMAC, 0, 0); - } - if (devinfo & SAFE_DEVINFO_SHA1) { - printf(" sha1"); - crypto_register(sc->sc_cid, CRYPTO_SHA1_HMAC, 0, 0); - } - printf(" null"); - crypto_register(sc->sc_cid, CRYPTO_NULL_CBC, 0, 0); - crypto_register(sc->sc_cid, CRYPTO_NULL_HMAC, 0, 0); - /* XXX other supported algorithms */ - printf("\n"); - - safe_reset_board(sc); /* reset h/w */ - safe_init_board(sc); /* init h/w */ - -#if defined(CONFIG_OCF_RANDOMHARVEST) && !defined(SAFE_NO_RNG) - if (sc->sc_flags & SAFE_FLAGS_RNG) { - safe_rng_init(sc); - crypto_rregister(sc->sc_cid, safe_read_random, sc); - } -#endif /* SAFE_NO_RNG */ - - return (0); - -out: - if (sc->sc_cid >= 0) - crypto_unregister_all(sc->sc_cid); - if (sc->sc_irq != -1) - free_irq(sc->sc_irq, sc); - if (sc->sc_ringalloc.dma_vaddr) - pci_free_consistent(sc->sc_pcidev, - SAFE_MAX_NQUEUE * sizeof (struct safe_ringentry), - sc->sc_ringalloc.dma_vaddr, sc->sc_ringalloc.dma_paddr); - if (sc->sc_spalloc.dma_vaddr) - pci_free_consistent(sc->sc_pcidev, - SAFE_TOTAL_DPART * sizeof (struct safe_pdesc), - sc->sc_spalloc.dma_vaddr, sc->sc_spalloc.dma_paddr); - if (sc->sc_dpalloc.dma_vaddr) - pci_free_consistent(sc->sc_pcidev, - SAFE_TOTAL_DPART * sizeof (struct safe_pdesc), - sc->sc_dpalloc.dma_vaddr, sc->sc_dpalloc.dma_paddr); - kfree(sc); - return(-ENODEV); -} - -static void safe_remove(struct pci_dev *dev) -{ - struct safe_softc *sc = pci_get_drvdata(dev); - - DPRINTF(("%s()\n", __FUNCTION__)); - - /* XXX wait/abort active ops */ - - WRITE_REG(sc, SAFE_HI_MASK, 0); /* disable interrupts */ - - del_timer_sync(&sc->sc_pkto); - - crypto_unregister_all(sc->sc_cid); - - safe_cleanchip(sc); - - if (sc->sc_irq != -1) - free_irq(sc->sc_irq, sc); - if (sc->sc_ringalloc.dma_vaddr) - pci_free_consistent(sc->sc_pcidev, - SAFE_MAX_NQUEUE * sizeof (struct safe_ringentry), - sc->sc_ringalloc.dma_vaddr, sc->sc_ringalloc.dma_paddr); - if (sc->sc_spalloc.dma_vaddr) - pci_free_consistent(sc->sc_pcidev, - SAFE_TOTAL_DPART * sizeof (struct safe_pdesc), - sc->sc_spalloc.dma_vaddr, sc->sc_spalloc.dma_paddr); - if (sc->sc_dpalloc.dma_vaddr) - pci_free_consistent(sc->sc_pcidev, - SAFE_TOTAL_DPART * sizeof (struct safe_pdesc), - sc->sc_dpalloc.dma_vaddr, sc->sc_dpalloc.dma_paddr); - sc->sc_irq = -1; - sc->sc_ringalloc.dma_vaddr = NULL; - sc->sc_spalloc.dma_vaddr = NULL; - sc->sc_dpalloc.dma_vaddr = NULL; -} - -static struct pci_device_id safe_pci_tbl[] = { - { PCI_VENDOR_SAFENET, PCI_PRODUCT_SAFEXCEL, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, - { }, -}; -MODULE_DEVICE_TABLE(pci, safe_pci_tbl); - -static struct pci_driver safe_driver = { - .name = "safe", - .id_table = safe_pci_tbl, - .probe = safe_probe, - .remove = safe_remove, - /* add PM stuff here one day */ -}; - -static int __init safe_init (void) -{ - struct safe_softc *sc = NULL; - int rc; - - DPRINTF(("%s(%p)\n", __FUNCTION__, safe_init)); - - rc = pci_register_driver(&safe_driver); - pci_register_driver_compat(&safe_driver, rc); - - return rc; -} - -static void __exit safe_exit (void) -{ - pci_unregister_driver(&safe_driver); -} - -module_init(safe_init); -module_exit(safe_exit); - -MODULE_LICENSE("BSD"); -MODULE_AUTHOR("David McCullough <david_mccullough@mcafee.com>"); -MODULE_DESCRIPTION("OCF driver for safenet PCI crypto devices"); diff --git a/target/linux/generic-2.4/files/crypto/ocf/safe/safereg.h b/target/linux/generic-2.4/files/crypto/ocf/safe/safereg.h deleted file mode 100644 index dbaf98f..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/safe/safereg.h +++ /dev/null @@ -1,421 +0,0 @@ -/*- - * Copyright (c) 2003 Sam Leffler, Errno Consulting - * Copyright (c) 2003 Global Technology Associates, 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 THE AUTHOR 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 AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: src/sys/dev/safe/safereg.h,v 1.1 2003/07/21 21:46:07 sam Exp $ - */ -#ifndef _SAFE_SAFEREG_H_ -#define _SAFE_SAFEREG_H_ - -/* - * Register definitions for SafeNet SafeXcel-1141 crypto device. - * Definitions from revision 1.3 (Nov 6 2002) of the User's Manual. - */ - -#define BS_BAR 0x10 /* DMA base address register */ -#define BS_TRDY_TIMEOUT 0x40 /* TRDY timeout */ -#define BS_RETRY_TIMEOUT 0x41 /* DMA retry timeout */ - -#define PCI_VENDOR_SAFENET 0x16ae /* SafeNet, Inc. */ - -/* SafeNet */ -#define PCI_PRODUCT_SAFEXCEL 0x1141 /* 1141 */ - -#define SAFE_PE_CSR 0x0000 /* Packet Enginge Ctrl/Status */ -#define SAFE_PE_SRC 0x0004 /* Packet Engine Source */ -#define SAFE_PE_DST 0x0008 /* Packet Engine Destination */ -#define SAFE_PE_SA 0x000c /* Packet Engine SA */ -#define SAFE_PE_LEN 0x0010 /* Packet Engine Length */ -#define SAFE_PE_DMACFG 0x0040 /* Packet Engine DMA Configuration */ -#define SAFE_PE_DMASTAT 0x0044 /* Packet Engine DMA Status */ -#define SAFE_PE_PDRBASE 0x0048 /* Packet Engine Descriptor Ring Base */ -#define SAFE_PE_RDRBASE 0x004c /* Packet Engine Result Ring Base */ -#define SAFE_PE_RINGCFG 0x0050 /* Packet Engine Ring Configuration */ -#define SAFE_PE_RINGPOLL 0x0054 /* Packet Engine Ring Poll */ -#define SAFE_PE_IRNGSTAT 0x0058 /* Packet Engine Internal Ring Status */ -#define SAFE_PE_ERNGSTAT 0x005c /* Packet Engine External Ring Status */ -#define SAFE_PE_IOTHRESH 0x0060 /* Packet Engine I/O Threshold */ -#define SAFE_PE_GRNGBASE 0x0064 /* Packet Engine Gather Ring Base */ -#define SAFE_PE_SRNGBASE 0x0068 /* Packet Engine Scatter Ring Base */ -#define SAFE_PE_PARTSIZE 0x006c /* Packet Engine Particlar Ring Size */ -#define SAFE_PE_PARTCFG 0x0070 /* Packet Engine Particle Ring Config */ -#define SAFE_CRYPTO_CTRL 0x0080 /* Crypto Control */ -#define SAFE_DEVID 0x0084 /* Device ID */ -#define SAFE_DEVINFO 0x0088 /* Device Info */ -#define SAFE_HU_STAT 0x00a0 /* Host Unmasked Status */ -#define SAFE_HM_STAT 0x00a4 /* Host Masked Status (read-only) */ -#define SAFE_HI_CLR 0x00a4 /* Host Clear Interrupt (write-only) */ -#define SAFE_HI_MASK 0x00a8 /* Host Mask Control */ -#define SAFE_HI_CFG 0x00ac /* Interrupt Configuration */ -#define SAFE_HI_RD_DESCR 0x00b4 /* Force Descriptor Read */ -#define SAFE_HI_DESC_CNT 0x00b8 /* Host Descriptor Done Count */ -#define SAFE_DMA_ENDIAN 0x00c0 /* Master Endian Status */ -#define SAFE_DMA_SRCADDR 0x00c4 /* DMA Source Address Status */ -#define SAFE_DMA_DSTADDR 0x00c8 /* DMA Destination Address Status */ -#define SAFE_DMA_STAT 0x00cc /* DMA Current Status */ -#define SAFE_DMA_CFG 0x00d4 /* DMA Configuration/Status */ -#define SAFE_ENDIAN 0x00e0 /* Endian Configuration */ -#define SAFE_PK_A_ADDR 0x0800 /* Public Key A Address */ -#define SAFE_PK_B_ADDR 0x0804 /* Public Key B Address */ -#define SAFE_PK_C_ADDR 0x0808 /* Public Key C Address */ -#define SAFE_PK_D_ADDR 0x080c /* Public Key D Address */ -#define SAFE_PK_A_LEN 0x0810 /* Public Key A Length */ -#define SAFE_PK_B_LEN 0x0814 /* Public Key B Length */ -#define SAFE_PK_SHIFT 0x0818 /* Public Key Shift */ -#define SAFE_PK_FUNC 0x081c /* Public Key Function */ -#define SAFE_PK_RAM_START 0x1000 /* Public Key RAM start address */ -#define SAFE_PK_RAM_END 0x1fff /* Public Key RAM end address */ - -#define SAFE_RNG_OUT 0x0100 /* RNG Output */ -#define SAFE_RNG_STAT 0x0104 /* RNG Status */ -#define SAFE_RNG_CTRL 0x0108 /* RNG Control */ -#define SAFE_RNG_A 0x010c /* RNG A */ -#define SAFE_RNG_B 0x0110 /* RNG B */ -#define SAFE_RNG_X_LO 0x0114 /* RNG X [31:0] */ -#define SAFE_RNG_X_MID 0x0118 /* RNG X [63:32] */ -#define SAFE_RNG_X_HI 0x011c /* RNG X [80:64] */ -#define SAFE_RNG_X_CNTR 0x0120 /* RNG Counter */ -#define SAFE_RNG_ALM_CNT 0x0124 /* RNG Alarm Count */ -#define SAFE_RNG_CNFG 0x0128 /* RNG Configuration */ -#define SAFE_RNG_LFSR1_LO 0x012c /* RNG LFSR1 [31:0] */ -#define SAFE_RNG_LFSR1_HI 0x0130 /* RNG LFSR1 [47:32] */ -#define SAFE_RNG_LFSR2_LO 0x0134 /* RNG LFSR1 [31:0] */ -#define SAFE_RNG_LFSR2_HI 0x0138 /* RNG LFSR1 [47:32] */ - -#define SAFE_PE_CSR_READY 0x00000001 /* ready for processing */ -#define SAFE_PE_CSR_DONE 0x00000002 /* h/w completed processing */ -#define SAFE_PE_CSR_LOADSA 0x00000004 /* load SA digests */ -#define SAFE_PE_CSR_HASHFINAL 0x00000010 /* do hash pad & write result */ -#define SAFE_PE_CSR_SABUSID 0x000000c0 /* bus id for SA */ -#define SAFE_PE_CSR_SAPCI 0x00000040 /* PCI bus id for SA */ -#define SAFE_PE_CSR_NXTHDR 0x0000ff00 /* next hdr value for IPsec */ -#define SAFE_PE_CSR_FPAD 0x0000ff00 /* fixed pad for basic ops */ -#define SAFE_PE_CSR_STATUS 0x00ff0000 /* operation result status */ -#define SAFE_PE_CSR_AUTH_FAIL 0x00010000 /* ICV mismatch (inbound) */ -#define SAFE_PE_CSR_PAD_FAIL 0x00020000 /* pad verify fail (inbound) */ -#define SAFE_PE_CSR_SEQ_FAIL 0x00040000 /* sequence number (inbound) */ -#define SAFE_PE_CSR_XERROR 0x00080000 /* extended error follows */ -#define SAFE_PE_CSR_XECODE 0x00f00000 /* extended error code */ -#define SAFE_PE_CSR_XECODE_S 20 -#define SAFE_PE_CSR_XECODE_BADCMD 0 /* invalid command */ -#define SAFE_PE_CSR_XECODE_BADALG 1 /* invalid algorithm */ -#define SAFE_PE_CSR_XECODE_ALGDIS 2 /* algorithm disabled */ -#define SAFE_PE_CSR_XECODE_ZEROLEN 3 /* zero packet length */ -#define SAFE_PE_CSR_XECODE_DMAERR 4 /* bus DMA error */ -#define SAFE_PE_CSR_XECODE_PIPEABORT 5 /* secondary bus DMA error */ -#define SAFE_PE_CSR_XECODE_BADSPI 6 /* IPsec SPI mismatch */ -#define SAFE_PE_CSR_XECODE_TIMEOUT 10 /* failsafe timeout */ -#define SAFE_PE_CSR_PAD 0xff000000 /* ESP padding control/status */ -#define SAFE_PE_CSR_PAD_MIN 0x00000000 /* minimum IPsec padding */ -#define SAFE_PE_CSR_PAD_16 0x08000000 /* pad to 16-byte boundary */ -#define SAFE_PE_CSR_PAD_32 0x10000000 /* pad to 32-byte boundary */ -#define SAFE_PE_CSR_PAD_64 0x20000000 /* pad to 64-byte boundary */ -#define SAFE_PE_CSR_PAD_128 0x40000000 /* pad to 128-byte boundary */ -#define SAFE_PE_CSR_PAD_256 0x80000000 /* pad to 256-byte boundary */ - -/* - * Check the CSR to see if the PE has returned ownership to - * the host. Note that before processing a descriptor this - * must be done followed by a check of the SAFE_PE_LEN register - * status bits to avoid premature processing of a descriptor - * on its way back to the host. - */ -#define SAFE_PE_CSR_IS_DONE(_csr) \ - (((_csr) & (SAFE_PE_CSR_READY | SAFE_PE_CSR_DONE)) == SAFE_PE_CSR_DONE) - -#define SAFE_PE_LEN_LENGTH 0x000fffff /* total length (bytes) */ -#define SAFE_PE_LEN_READY 0x00400000 /* ready for processing */ -#define SAFE_PE_LEN_DONE 0x00800000 /* h/w completed processing */ -#define SAFE_PE_LEN_BYPASS 0xff000000 /* bypass offset (bytes) */ -#define SAFE_PE_LEN_BYPASS_S 24 - -#define SAFE_PE_LEN_IS_DONE(_len) \ - (((_len) & (SAFE_PE_LEN_READY | SAFE_PE_LEN_DONE)) == SAFE_PE_LEN_DONE) - -/* NB: these apply to HU_STAT, HM_STAT, HI_CLR, and HI_MASK */ -#define SAFE_INT_PE_CDONE 0x00000002 /* PE context done */ -#define SAFE_INT_PE_DDONE 0x00000008 /* PE descriptor done */ -#define SAFE_INT_PE_ERROR 0x00000010 /* PE error */ -#define SAFE_INT_PE_ODONE 0x00000020 /* PE operation done */ - -#define SAFE_HI_CFG_PULSE 0x00000001 /* use pulse interrupt */ -#define SAFE_HI_CFG_LEVEL 0x00000000 /* use level interrupt */ -#define SAFE_HI_CFG_AUTOCLR 0x00000002 /* auto-clear pulse interrupt */ - -#define SAFE_ENDIAN_PASS 0x000000e4 /* straight pass-thru */ -#define SAFE_ENDIAN_SWAB 0x0000001b /* swap bytes in 32-bit word */ - -#define SAFE_PE_DMACFG_PERESET 0x00000001 /* reset packet engine */ -#define SAFE_PE_DMACFG_PDRRESET 0x00000002 /* reset PDR counters/ptrs */ -#define SAFE_PE_DMACFG_SGRESET 0x00000004 /* reset scatter/gather cache */ -#define SAFE_PE_DMACFG_FSENA 0x00000008 /* enable failsafe reset */ -#define SAFE_PE_DMACFG_PEMODE 0x00000100 /* packet engine mode */ -#define SAFE_PE_DMACFG_SAPREC 0x00000200 /* SA precedes packet */ -#define SAFE_PE_DMACFG_PKFOLL 0x00000400 /* packet follows descriptor */ -#define SAFE_PE_DMACFG_GPRBID 0x00003000 /* gather particle ring busid */ -#define SAFE_PE_DMACFG_GPRPCI 0x00001000 /* PCI gather particle ring */ -#define SAFE_PE_DMACFG_SPRBID 0x0000c000 /* scatter part. ring busid */ -#define SAFE_PE_DMACFG_SPRPCI 0x00004000 /* PCI scatter part. ring */ -#define SAFE_PE_DMACFG_ESDESC 0x00010000 /* endian swap descriptors */ -#define SAFE_PE_DMACFG_ESSA 0x00020000 /* endian swap SA data */ -#define SAFE_PE_DMACFG_ESPACKET 0x00040000 /* endian swap packet data */ -#define SAFE_PE_DMACFG_ESPDESC 0x00080000 /* endian swap particle desc. */ -#define SAFE_PE_DMACFG_NOPDRUP 0x00100000 /* supp. PDR ownership update */ -#define SAFE_PD_EDMACFG_PCIMODE 0x01000000 /* PCI target mode */ - -#define SAFE_PE_DMASTAT_PEIDONE 0x00000001 /* PE core input done */ -#define SAFE_PE_DMASTAT_PEODONE 0x00000002 /* PE core output done */ -#define SAFE_PE_DMASTAT_ENCDONE 0x00000004 /* encryption done */ -#define SAFE_PE_DMASTAT_IHDONE 0x00000008 /* inner hash done */ -#define SAFE_PE_DMASTAT_OHDONE 0x00000010 /* outer hash (HMAC) done */ -#define SAFE_PE_DMASTAT_PADFLT 0x00000020 /* crypto pad fault */ -#define SAFE_PE_DMASTAT_ICVFLT 0x00000040 /* ICV fault */ -#define SAFE_PE_DMASTAT_SPIMIS 0x00000080 /* SPI mismatch */ -#define SAFE_PE_DMASTAT_CRYPTO 0x00000100 /* crypto engine timeout */ -#define SAFE_PE_DMASTAT_CQACT 0x00000200 /* command queue active */ -#define SAFE_PE_DMASTAT_IRACT 0x00000400 /* input request active */ -#define SAFE_PE_DMASTAT_ORACT 0x00000800 /* output request active */ -#define SAFE_PE_DMASTAT_PEISIZE 0x003ff000 /* PE input size:32-bit words */ -#define SAFE_PE_DMASTAT_PEOSIZE 0xffc00000 /* PE out. size:32-bit words */ - -#define SAFE_PE_RINGCFG_SIZE 0x000003ff /* ring size (descriptors) */ -#define SAFE_PE_RINGCFG_OFFSET 0xffff0000 /* offset btw desc's (dwords) */ -#define SAFE_PE_RINGCFG_OFFSET_S 16 - -#define SAFE_PE_RINGPOLL_POLL 0x00000fff /* polling frequency/divisor */ -#define SAFE_PE_RINGPOLL_RETRY 0x03ff0000 /* polling frequency/divisor */ -#define SAFE_PE_RINGPOLL_CONT 0x80000000 /* continuously poll */ - -#define SAFE_PE_IRNGSTAT_CQAVAIL 0x00000001 /* command queue available */ - -#define SAFE_PE_ERNGSTAT_NEXT 0x03ff0000 /* index of next packet desc. */ -#define SAFE_PE_ERNGSTAT_NEXT_S 16 - -#define SAFE_PE_IOTHRESH_INPUT 0x000003ff /* input threshold (dwords) */ -#define SAFE_PE_IOTHRESH_OUTPUT 0x03ff0000 /* output threshold (dwords) */ - -#define SAFE_PE_PARTCFG_SIZE 0x0000ffff /* scatter particle size */ -#define SAFE_PE_PARTCFG_GBURST 0x00030000 /* gather particle burst */ -#define SAFE_PE_PARTCFG_GBURST_2 0x00000000 -#define SAFE_PE_PARTCFG_GBURST_4 0x00010000 -#define SAFE_PE_PARTCFG_GBURST_8 0x00020000 -#define SAFE_PE_PARTCFG_GBURST_16 0x00030000 -#define SAFE_PE_PARTCFG_SBURST 0x000c0000 /* scatter particle burst */ -#define SAFE_PE_PARTCFG_SBURST_2 0x00000000 -#define SAFE_PE_PARTCFG_SBURST_4 0x00040000 -#define SAFE_PE_PARTCFG_SBURST_8 0x00080000 -#define SAFE_PE_PARTCFG_SBURST_16 0x000c0000 - -#define SAFE_PE_PARTSIZE_SCAT 0xffff0000 /* scatter particle ring size */ -#define SAFE_PE_PARTSIZE_GATH 0x0000ffff /* gather particle ring size */ - -#define SAFE_CRYPTO_CTRL_3DES 0x00000001 /* enable 3DES support */ -#define SAFE_CRYPTO_CTRL_PKEY 0x00010000 /* enable public key support */ -#define SAFE_CRYPTO_CTRL_RNG 0x00020000 /* enable RNG support */ - -#define SAFE_DEVINFO_REV_MIN 0x0000000f /* minor rev for chip */ -#define SAFE_DEVINFO_REV_MAJ 0x000000f0 /* major rev for chip */ -#define SAFE_DEVINFO_REV_MAJ_S 4 -#define SAFE_DEVINFO_DES 0x00000100 /* DES/3DES support present */ -#define SAFE_DEVINFO_ARC4 0x00000200 /* ARC4 support present */ -#define SAFE_DEVINFO_AES 0x00000400 /* AES support present */ -#define SAFE_DEVINFO_MD5 0x00001000 /* MD5 support present */ -#define SAFE_DEVINFO_SHA1 0x00002000 /* SHA-1 support present */ -#define SAFE_DEVINFO_RIPEMD 0x00004000 /* RIPEMD support present */ -#define SAFE_DEVINFO_DEFLATE 0x00010000 /* Deflate support present */ -#define SAFE_DEVINFO_SARAM 0x00100000 /* on-chip SA RAM present */ -#define SAFE_DEVINFO_EMIBUS 0x00200000 /* EMI bus present */ -#define SAFE_DEVINFO_PKEY 0x00400000 /* public key support present */ -#define SAFE_DEVINFO_RNG 0x00800000 /* RNG present */ - -#define SAFE_REV(_maj, _min) (((_maj) << SAFE_DEVINFO_REV_MAJ_S) | (_min)) -#define SAFE_REV_MAJ(_chiprev) \ - (((_chiprev) & SAFE_DEVINFO_REV_MAJ) >> SAFE_DEVINFO_REV_MAJ_S) -#define SAFE_REV_MIN(_chiprev) ((_chiprev) & SAFE_DEVINFO_REV_MIN) - -#define SAFE_PK_FUNC_MULT 0x00000001 /* Multiply function */ -#define SAFE_PK_FUNC_SQUARE 0x00000004 /* Square function */ -#define SAFE_PK_FUNC_ADD 0x00000010 /* Add function */ -#define SAFE_PK_FUNC_SUB 0x00000020 /* Subtract function */ -#define SAFE_PK_FUNC_LSHIFT 0x00000040 /* Left-shift function */ -#define SAFE_PK_FUNC_RSHIFT 0x00000080 /* Right-shift function */ -#define SAFE_PK_FUNC_DIV 0x00000100 /* Divide function */ -#define SAFE_PK_FUNC_CMP 0x00000400 /* Compare function */ -#define SAFE_PK_FUNC_COPY 0x00000800 /* Copy function */ -#define SAFE_PK_FUNC_EXP16 0x00002000 /* Exponentiate (4-bit ACT) */ -#define SAFE_PK_FUNC_EXP4 0x00004000 /* Exponentiate (2-bit ACT) */ -#define SAFE_PK_FUNC_RUN 0x00008000 /* start/status */ - -#define SAFE_RNG_STAT_BUSY 0x00000001 /* busy, data not valid */ - -#define SAFE_RNG_CTRL_PRE_LFSR 0x00000001 /* enable output pre-LFSR */ -#define SAFE_RNG_CTRL_TST_MODE 0x00000002 /* enable test mode */ -#define SAFE_RNG_CTRL_TST_RUN 0x00000004 /* start test state machine */ -#define SAFE_RNG_CTRL_ENA_RING1 0x00000008 /* test entropy oscillator #1 */ -#define SAFE_RNG_CTRL_ENA_RING2 0x00000010 /* test entropy oscillator #2 */ -#define SAFE_RNG_CTRL_DIS_ALARM 0x00000020 /* disable RNG alarm reports */ -#define SAFE_RNG_CTRL_TST_CLOCK 0x00000040 /* enable test clock */ -#define SAFE_RNG_CTRL_SHORTEN 0x00000080 /* shorten state timers */ -#define SAFE_RNG_CTRL_TST_ALARM 0x00000100 /* simulate alarm state */ -#define SAFE_RNG_CTRL_RST_LFSR 0x00000200 /* reset LFSR */ - -/* - * Packet engine descriptor. Note that d_csr is a copy of the - * SAFE_PE_CSR register and all definitions apply, and d_len - * is a copy of the SAFE_PE_LEN register and all definitions apply. - * d_src and d_len may point directly to contiguous data or to a - * list of ``particle descriptors'' when using scatter/gather i/o. - */ -struct safe_desc { - u_int32_t d_csr; /* per-packet control/status */ - u_int32_t d_src; /* source address */ - u_int32_t d_dst; /* destination address */ - u_int32_t d_sa; /* SA address */ - u_int32_t d_len; /* length, bypass, status */ -}; - -/* - * Scatter/Gather particle descriptor. - * - * NB: scatter descriptors do not specify a size; this is fixed - * by the setting of the SAFE_PE_PARTCFG register. - */ -struct safe_pdesc { - u_int32_t pd_addr; /* particle address */ -#ifdef __BIG_ENDIAN - u_int16_t pd_flags; /* control word */ - u_int16_t pd_size; /* particle size (bytes) */ -#else - u_int16_t pd_flags; /* control word */ - u_int16_t pd_size; /* particle size (bytes) */ -#endif -}; - -#define SAFE_PD_READY 0x0001 /* ready for processing */ -#define SAFE_PD_DONE 0x0002 /* h/w completed processing */ - -/* - * Security Association (SA) Record (Rev 1). One of these is - * required for each operation processed by the packet engine. - */ -struct safe_sarec { - u_int32_t sa_cmd0; - u_int32_t sa_cmd1; - u_int32_t sa_resv0; - u_int32_t sa_resv1; - u_int32_t sa_key[8]; /* DES/3DES/AES key */ - u_int32_t sa_indigest[5]; /* inner digest */ - u_int32_t sa_outdigest[5]; /* outer digest */ - u_int32_t sa_spi; /* SPI */ - u_int32_t sa_seqnum; /* sequence number */ - u_int32_t sa_seqmask[2]; /* sequence number mask */ - u_int32_t sa_resv2; - u_int32_t sa_staterec; /* address of state record */ - u_int32_t sa_resv3[2]; - u_int32_t sa_samgmt0; /* SA management field 0 */ - u_int32_t sa_samgmt1; /* SA management field 0 */ -}; - -#define SAFE_SA_CMD0_OP 0x00000007 /* operation code */ -#define SAFE_SA_CMD0_OP_CRYPT 0x00000000 /* encrypt/decrypt (basic) */ -#define SAFE_SA_CMD0_OP_BOTH 0x00000001 /* encrypt-hash/hash-decrypto */ -#define SAFE_SA_CMD0_OP_HASH 0x00000003 /* hash (outbound-only) */ -#define SAFE_SA_CMD0_OP_ESP 0x00000000 /* ESP in/out (proto) */ -#define SAFE_SA_CMD0_OP_AH 0x00000001 /* AH in/out (proto) */ -#define SAFE_SA_CMD0_INBOUND 0x00000008 /* inbound operation */ -#define SAFE_SA_CMD0_OUTBOUND 0x00000000 /* outbound operation */ -#define SAFE_SA_CMD0_GROUP 0x00000030 /* operation group */ -#define SAFE_SA_CMD0_BASIC 0x00000000 /* basic operation */ -#define SAFE_SA_CMD0_PROTO 0x00000010 /* protocol/packet operation */ -#define SAFE_SA_CMD0_BUNDLE 0x00000020 /* bundled operation (resvd) */ -#define SAFE_SA_CMD0_PAD 0x000000c0 /* crypto pad method */ -#define SAFE_SA_CMD0_PAD_IPSEC 0x00000000 /* IPsec padding */ -#define SAFE_SA_CMD0_PAD_PKCS7 0x00000040 /* PKCS#7 padding */ -#define SAFE_SA_CMD0_PAD_CONS 0x00000080 /* constant padding */ -#define SAFE_SA_CMD0_PAD_ZERO 0x000000c0 /* zero padding */ -#define SAFE_SA_CMD0_CRYPT_ALG 0x00000f00 /* symmetric crypto algorithm */ -#define SAFE_SA_CMD0_DES 0x00000000 /* DES crypto algorithm */ -#define SAFE_SA_CMD0_3DES 0x00000100 /* 3DES crypto algorithm */ -#define SAFE_SA_CMD0_AES 0x00000300 /* AES crypto algorithm */ -#define SAFE_SA_CMD0_CRYPT_NULL 0x00000f00 /* null crypto algorithm */ -#define SAFE_SA_CMD0_HASH_ALG 0x0000f000 /* hash algorithm */ -#define SAFE_SA_CMD0_MD5 0x00000000 /* MD5 hash algorithm */ -#define SAFE_SA_CMD0_SHA1 0x00001000 /* SHA-1 hash algorithm */ -#define SAFE_SA_CMD0_HASH_NULL 0x0000f000 /* null hash algorithm */ -#define SAFE_SA_CMD0_HDR_PROC 0x00080000 /* header processing */ -#define SAFE_SA_CMD0_IBUSID 0x00300000 /* input bus id */ -#define SAFE_SA_CMD0_IPCI 0x00100000 /* PCI input bus id */ -#define SAFE_SA_CMD0_OBUSID 0x00c00000 /* output bus id */ -#define SAFE_SA_CMD0_OPCI 0x00400000 /* PCI output bus id */ -#define SAFE_SA_CMD0_IVLD 0x03000000 /* IV loading */ -#define SAFE_SA_CMD0_IVLD_NONE 0x00000000 /* IV no load (reuse) */ -#define SAFE_SA_CMD0_IVLD_IBUF 0x01000000 /* IV load from input buffer */ -#define SAFE_SA_CMD0_IVLD_STATE 0x02000000 /* IV load from state */ -#define SAFE_SA_CMD0_HSLD 0x0c000000 /* hash state loading */ -#define SAFE_SA_CMD0_HSLD_SA 0x00000000 /* hash state load from SA */ -#define SAFE_SA_CMD0_HSLD_STATE 0x08000000 /* hash state load from state */ -#define SAFE_SA_CMD0_HSLD_NONE 0x0c000000 /* hash state no load */ -#define SAFE_SA_CMD0_SAVEIV 0x10000000 /* save IV */ -#define SAFE_SA_CMD0_SAVEHASH 0x20000000 /* save hash state */ -#define SAFE_SA_CMD0_IGATHER 0x40000000 /* input gather */ -#define SAFE_SA_CMD0_OSCATTER 0x80000000 /* output scatter */ - -#define SAFE_SA_CMD1_HDRCOPY 0x00000002 /* copy header to output */ -#define SAFE_SA_CMD1_PAYCOPY 0x00000004 /* copy payload to output */ -#define SAFE_SA_CMD1_PADCOPY 0x00000008 /* copy pad to output */ -#define SAFE_SA_CMD1_IPV4 0x00000000 /* IPv4 protocol */ -#define SAFE_SA_CMD1_IPV6 0x00000010 /* IPv6 protocol */ -#define SAFE_SA_CMD1_MUTABLE 0x00000020 /* mutable bit processing */ -#define SAFE_SA_CMD1_SRBUSID 0x000000c0 /* state record bus id */ -#define SAFE_SA_CMD1_SRPCI 0x00000040 /* state record from PCI */ -#define SAFE_SA_CMD1_CRMODE 0x00000300 /* crypto mode */ -#define SAFE_SA_CMD1_ECB 0x00000000 /* ECB crypto mode */ -#define SAFE_SA_CMD1_CBC 0x00000100 /* CBC crypto mode */ -#define SAFE_SA_CMD1_OFB 0x00000200 /* OFB crypto mode */ -#define SAFE_SA_CMD1_CFB 0x00000300 /* CFB crypto mode */ -#define SAFE_SA_CMD1_CRFEEDBACK 0x00000c00 /* crypto feedback mode */ -#define SAFE_SA_CMD1_64BIT 0x00000000 /* 64-bit crypto feedback */ -#define SAFE_SA_CMD1_8BIT 0x00000400 /* 8-bit crypto feedback */ -#define SAFE_SA_CMD1_1BIT 0x00000800 /* 1-bit crypto feedback */ -#define SAFE_SA_CMD1_128BIT 0x00000c00 /* 128-bit crypto feedback */ -#define SAFE_SA_CMD1_OPTIONS 0x00001000 /* HMAC/options mutable bit */ -#define SAFE_SA_CMD1_HMAC SAFE_SA_CMD1_OPTIONS -#define SAFE_SA_CMD1_SAREV1 0x00008000 /* SA Revision 1 */ -#define SAFE_SA_CMD1_OFFSET 0x00ff0000 /* hash/crypto offset(dwords) */ -#define SAFE_SA_CMD1_OFFSET_S 16 -#define SAFE_SA_CMD1_AESKEYLEN 0x0f000000 /* AES key length */ -#define SAFE_SA_CMD1_AES128 0x02000000 /* 128-bit AES key */ -#define SAFE_SA_CMD1_AES192 0x03000000 /* 192-bit AES key */ -#define SAFE_SA_CMD1_AES256 0x04000000 /* 256-bit AES key */ - -/* - * Security Associate State Record (Rev 1). - */ -struct safe_sastate { - u_int32_t sa_saved_iv[4]; /* saved IV (DES/3DES/AES) */ - u_int32_t sa_saved_hashbc; /* saved hash byte count */ - u_int32_t sa_saved_indigest[5]; /* saved inner digest */ -}; -#endif /* _SAFE_SAFEREG_H_ */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/safe/safevar.h b/target/linux/generic-2.4/files/crypto/ocf/safe/safevar.h deleted file mode 100644 index 9039a5d..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/safe/safevar.h +++ /dev/null @@ -1,230 +0,0 @@ -/*- - * The linux port of this code done by David McCullough - * Copyright (C) 2004-2010 David McCullough <david_mccullough@mcafee.com> - * The license and original author are listed below. - * - * Copyright (c) 2003 Sam Leffler, Errno Consulting - * Copyright (c) 2003 Global Technology Associates, 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 THE AUTHOR 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 AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: src/sys/dev/safe/safevar.h,v 1.2 2006/05/17 18:34:26 pjd Exp $ - */ -#ifndef _SAFE_SAFEVAR_H_ -#define _SAFE_SAFEVAR_H_ - -/* Maximum queue length */ -#ifndef SAFE_MAX_NQUEUE -#define SAFE_MAX_NQUEUE 60 -#endif - -#define SAFE_MAX_PART 64 /* Maximum scatter/gather depth */ -#define SAFE_DMA_BOUNDARY 0 /* No boundary for source DMA ops */ -#define SAFE_MAX_DSIZE 2048 /* MCLBYTES Fixed scatter particle size */ -#define SAFE_MAX_SSIZE 0x0ffff /* Maximum gather particle size */ -#define SAFE_MAX_DMA 0xfffff /* Maximum PE operand size (20 bits) */ -/* total src+dst particle descriptors */ -#define SAFE_TOTAL_DPART (SAFE_MAX_NQUEUE * SAFE_MAX_PART) -#define SAFE_TOTAL_SPART (SAFE_MAX_NQUEUE * SAFE_MAX_PART) - -#define SAFE_RNG_MAXBUFSIZ 128 /* 32-bit words */ - -#define SAFE_CARD(sid) (((sid) & 0xf0000000) >> 28) -#define SAFE_SESSION(sid) ( (sid) & 0x0fffffff) -#define SAFE_SID(crd, sesn) (((crd) << 28) | ((sesn) & 0x0fffffff)) - -#define SAFE_DEF_RTY 0xff /* PCI Retry Timeout */ -#define SAFE_DEF_TOUT 0xff /* PCI TRDY Timeout */ -#define SAFE_DEF_CACHELINE 0x01 /* Cache Line setting */ - -#ifdef __KERNEL__ -/* - * State associated with the allocation of each chunk - * of memory setup for DMA. - */ -struct safe_dma_alloc { - dma_addr_t dma_paddr; - void *dma_vaddr; -}; - -/* - * Cryptographic operand state. One of these exists for each - * source and destination operand passed in from the crypto - * subsystem. When possible source and destination operands - * refer to the same memory. More often they are distinct. - * We track the virtual address of each operand as well as - * where each is mapped for DMA. - */ -struct safe_operand { - union { - struct sk_buff *skb; - struct uio *io; - } u; - void *map; - int mapsize; /* total number of bytes in segs */ - struct { - dma_addr_t ds_addr; - int ds_len; - int ds_tlen; - } segs[SAFE_MAX_PART]; - int nsegs; -}; - -/* - * Packet engine ring entry and cryptographic operation state. - * The packet engine requires a ring of descriptors that contain - * pointers to various cryptographic state. However the ring - * configuration register allows you to specify an arbitrary size - * for ring entries. We use this feature to collect most of the - * state for each cryptographic request into one spot. Other than - * ring entries only the ``particle descriptors'' (scatter/gather - * lists) and the actual operand data are kept separate. The - * particle descriptors must also be organized in rings. The - * operand data can be located aribtrarily (modulo alignment constraints). - * - * Note that the descriptor ring is mapped onto the PCI bus so - * the hardware can DMA data. This means the entire ring must be - * contiguous. - */ -struct safe_ringentry { - struct safe_desc re_desc; /* command descriptor */ - struct safe_sarec re_sa; /* SA record */ - struct safe_sastate re_sastate; /* SA state record */ - - struct cryptop *re_crp; /* crypto operation */ - - struct safe_operand re_src; /* source operand */ - struct safe_operand re_dst; /* destination operand */ - - int re_sesn; /* crypto session ID */ - int re_flags; -#define SAFE_QFLAGS_COPYOUTIV 0x1 /* copy back on completion */ -#define SAFE_QFLAGS_COPYOUTICV 0x2 /* copy back on completion */ -}; - -#define re_src_skb re_src.u.skb -#define re_src_io re_src.u.io -#define re_src_map re_src.map -#define re_src_nsegs re_src.nsegs -#define re_src_segs re_src.segs -#define re_src_mapsize re_src.mapsize - -#define re_dst_skb re_dst.u.skb -#define re_dst_io re_dst.u.io -#define re_dst_map re_dst.map -#define re_dst_nsegs re_dst.nsegs -#define re_dst_segs re_dst.segs -#define re_dst_mapsize re_dst.mapsize - -struct rndstate_test; - -struct safe_session { - u_int32_t ses_used; - u_int32_t ses_klen; /* key length in bits */ - u_int32_t ses_key[8]; /* DES/3DES/AES key */ - u_int32_t ses_mlen; /* hmac length in bytes */ - u_int32_t ses_hminner[5]; /* hmac inner state */ - u_int32_t ses_hmouter[5]; /* hmac outer state */ - u_int32_t ses_iv[4]; /* DES/3DES/AES iv */ -}; - -struct safe_pkq { - struct list_head pkq_list; - struct cryptkop *pkq_krp; -}; - -struct safe_softc { - softc_device_decl sc_dev; - u32 sc_irq; - - struct pci_dev *sc_pcidev; - ocf_iomem_t sc_base_addr; - - u_int sc_chiprev; /* major/minor chip revision */ - int sc_flags; /* device specific flags */ -#define SAFE_FLAGS_KEY 0x01 /* has key accelerator */ -#define SAFE_FLAGS_RNG 0x02 /* hardware rng */ - int sc_suspended; - int sc_needwakeup; /* notify crypto layer */ - int32_t sc_cid; /* crypto tag */ - - struct safe_dma_alloc sc_ringalloc; /* PE ring allocation state */ - struct safe_ringentry *sc_ring; /* PE ring */ - struct safe_ringentry *sc_ringtop; /* PE ring top */ - struct safe_ringentry *sc_front; /* next free entry */ - struct safe_ringentry *sc_back; /* next pending entry */ - int sc_nqchip; /* # passed to chip */ - spinlock_t sc_ringmtx; /* PE ring lock */ - struct safe_pdesc *sc_spring; /* src particle ring */ - struct safe_pdesc *sc_springtop; /* src particle ring top */ - struct safe_pdesc *sc_spfree; /* next free src particle */ - struct safe_dma_alloc sc_spalloc; /* src particle ring state */ - struct safe_pdesc *sc_dpring; /* dest particle ring */ - struct safe_pdesc *sc_dpringtop; /* dest particle ring top */ - struct safe_pdesc *sc_dpfree; /* next free dest particle */ - struct safe_dma_alloc sc_dpalloc; /* dst particle ring state */ - int sc_nsessions; /* # of sessions */ - struct safe_session *sc_sessions; /* sessions */ - - struct timer_list sc_pkto; /* PK polling */ - spinlock_t sc_pkmtx; /* PK lock */ - struct list_head sc_pkq; /* queue of PK requests */ - struct safe_pkq *sc_pkq_cur; /* current processing request */ - u_int32_t sc_pk_reslen, sc_pk_resoff; - - int sc_max_dsize; /* maximum safe DMA size */ -}; -#endif /* __KERNEL__ */ - -struct safe_stats { - u_int64_t st_ibytes; - u_int64_t st_obytes; - u_int32_t st_ipackets; - u_int32_t st_opackets; - u_int32_t st_invalid; /* invalid argument */ - u_int32_t st_badsession; /* invalid session id */ - u_int32_t st_badflags; /* flags indicate !(mbuf | uio) */ - u_int32_t st_nodesc; /* op submitted w/o descriptors */ - u_int32_t st_badalg; /* unsupported algorithm */ - u_int32_t st_ringfull; /* PE descriptor ring full */ - u_int32_t st_peoperr; /* PE marked error */ - u_int32_t st_dmaerr; /* PE DMA error */ - u_int32_t st_bypasstoobig; /* bypass > 96 bytes */ - u_int32_t st_skipmismatch; /* enc part begins before auth part */ - u_int32_t st_lenmismatch; /* enc length different auth length */ - u_int32_t st_coffmisaligned; /* crypto offset not 32-bit aligned */ - u_int32_t st_cofftoobig; /* crypto offset > 255 words */ - u_int32_t st_iovmisaligned; /* iov op not aligned */ - u_int32_t st_iovnotuniform; /* iov op not suitable */ - u_int32_t st_unaligned; /* unaligned src caused copy */ - u_int32_t st_notuniform; /* non-uniform src caused copy */ - u_int32_t st_nomap; /* bus_dmamap_create failed */ - u_int32_t st_noload; /* bus_dmamap_load_* failed */ - u_int32_t st_nombuf; /* MGET* failed */ - u_int32_t st_nomcl; /* MCLGET* failed */ - u_int32_t st_maxqchip; /* max mcr1 ops out for processing */ - u_int32_t st_rng; /* RNG requests */ - u_int32_t st_rngalarm; /* RNG alarm requests */ - u_int32_t st_noicvcopy; /* ICV data copies suppressed */ -}; -#endif /* _SAFE_SAFEVAR_H_ */ diff --git a/target/linux/generic-2.4/files/crypto/ocf/safe/sha1.c b/target/linux/generic-2.4/files/crypto/ocf/safe/sha1.c deleted file mode 100644 index 4e360e2..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/safe/sha1.c +++ /dev/null @@ -1,279 +0,0 @@ -/* $KAME: sha1.c,v 1.5 2000/11/08 06:13:08 itojun Exp $ */ -/* - * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. - * 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. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT 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 PROJECT 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. - */ - -/* - * FIPS pub 180-1: Secure Hash Algorithm (SHA-1) - * based on: http://csrc.nist.gov/fips/fip180-1.txt - * implemented by Jun-ichiro itojun Itoh <itojun@itojun.org> - */ - -#if 0 -#include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/crypto/sha1.c,v 1.9 2003/06/10 21:36:57 obrien Exp $"); - -#include <sys/types.h> -#include <sys/cdefs.h> -#include <sys/time.h> -#include <sys/systm.h> - -#include <crypto/sha1.h> -#endif - -/* sanity check */ -#if BYTE_ORDER != BIG_ENDIAN -# if BYTE_ORDER != LITTLE_ENDIAN -# define unsupported 1 -# endif -#endif - -#ifndef unsupported - -/* constant table */ -static u_int32_t _K[] = { 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6 }; -#define K(t) _K[(t) / 20] - -#define F0(b, c, d) (((b) & (c)) | ((~(b)) & (d))) -#define F1(b, c, d) (((b) ^ (c)) ^ (d)) -#define F2(b, c, d) (((b) & (c)) | ((b) & (d)) | ((c) & (d))) -#define F3(b, c, d) (((b) ^ (c)) ^ (d)) - -#define S(n, x) (((x) << (n)) | ((x) >> (32 - n))) - -#undef H -#define H(n) (ctxt->h.b32[(n)]) -#define COUNT (ctxt->count) -#define BCOUNT (ctxt->c.b64[0] / 8) -#define W(n) (ctxt->m.b32[(n)]) - -#define PUTBYTE(x) { \ - ctxt->m.b8[(COUNT % 64)] = (x); \ - COUNT++; \ - COUNT %= 64; \ - ctxt->c.b64[0] += 8; \ - if (COUNT % 64 == 0) \ - sha1_step(ctxt); \ - } - -#define PUTPAD(x) { \ - ctxt->m.b8[(COUNT % 64)] = (x); \ - COUNT++; \ - COUNT %= 64; \ - if (COUNT % 64 == 0) \ - sha1_step(ctxt); \ - } - -static void sha1_step(struct sha1_ctxt *); - -static void -sha1_step(ctxt) - struct sha1_ctxt *ctxt; -{ - u_int32_t a, b, c, d, e; - size_t t, s; - u_int32_t tmp; - -#if BYTE_ORDER == LITTLE_ENDIAN - struct sha1_ctxt tctxt; - bcopy(&ctxt->m.b8[0], &tctxt.m.b8[0], 64); - ctxt->m.b8[0] = tctxt.m.b8[3]; ctxt->m.b8[1] = tctxt.m.b8[2]; - ctxt->m.b8[2] = tctxt.m.b8[1]; ctxt->m.b8[3] = tctxt.m.b8[0]; - ctxt->m.b8[4] = tctxt.m.b8[7]; ctxt->m.b8[5] = tctxt.m.b8[6]; - ctxt->m.b8[6] = tctxt.m.b8[5]; ctxt->m.b8[7] = tctxt.m.b8[4]; - ctxt->m.b8[8] = tctxt.m.b8[11]; ctxt->m.b8[9] = tctxt.m.b8[10]; - ctxt->m.b8[10] = tctxt.m.b8[9]; ctxt->m.b8[11] = tctxt.m.b8[8]; - ctxt->m.b8[12] = tctxt.m.b8[15]; ctxt->m.b8[13] = tctxt.m.b8[14]; - ctxt->m.b8[14] = tctxt.m.b8[13]; ctxt->m.b8[15] = tctxt.m.b8[12]; - ctxt->m.b8[16] = tctxt.m.b8[19]; ctxt->m.b8[17] = tctxt.m.b8[18]; - ctxt->m.b8[18] = tctxt.m.b8[17]; ctxt->m.b8[19] = tctxt.m.b8[16]; - ctxt->m.b8[20] = tctxt.m.b8[23]; ctxt->m.b8[21] = tctxt.m.b8[22]; - ctxt->m.b8[22] = tctxt.m.b8[21]; ctxt->m.b8[23] = tctxt.m.b8[20]; - ctxt->m.b8[24] = tctxt.m.b8[27]; ctxt->m.b8[25] = tctxt.m.b8[26]; - ctxt->m.b8[26] = tctxt.m.b8[25]; ctxt->m.b8[27] = tctxt.m.b8[24]; - ctxt->m.b8[28] = tctxt.m.b8[31]; ctxt->m.b8[29] = tctxt.m.b8[30]; - ctxt->m.b8[30] = tctxt.m.b8[29]; ctxt->m.b8[31] = tctxt.m.b8[28]; - ctxt->m.b8[32] = tctxt.m.b8[35]; ctxt->m.b8[33] = tctxt.m.b8[34]; - ctxt->m.b8[34] = tctxt.m.b8[33]; ctxt->m.b8[35] = tctxt.m.b8[32]; - ctxt->m.b8[36] = tctxt.m.b8[39]; ctxt->m.b8[37] = tctxt.m.b8[38]; - ctxt->m.b8[38] = tctxt.m.b8[37]; ctxt->m.b8[39] = tctxt.m.b8[36]; - ctxt->m.b8[40] = tctxt.m.b8[43]; ctxt->m.b8[41] = tctxt.m.b8[42]; - ctxt->m.b8[42] = tctxt.m.b8[41]; ctxt->m.b8[43] = tctxt.m.b8[40]; - ctxt->m.b8[44] = tctxt.m.b8[47]; ctxt->m.b8[45] = tctxt.m.b8[46]; - ctxt->m.b8[46] = tctxt.m.b8[45]; ctxt->m.b8[47] = tctxt.m.b8[44]; - ctxt->m.b8[48] = tctxt.m.b8[51]; ctxt->m.b8[49] = tctxt.m.b8[50]; - ctxt->m.b8[50] = tctxt.m.b8[49]; ctxt->m.b8[51] = tctxt.m.b8[48]; - ctxt->m.b8[52] = tctxt.m.b8[55]; ctxt->m.b8[53] = tctxt.m.b8[54]; - ctxt->m.b8[54] = tctxt.m.b8[53]; ctxt->m.b8[55] = tctxt.m.b8[52]; - ctxt->m.b8[56] = tctxt.m.b8[59]; ctxt->m.b8[57] = tctxt.m.b8[58]; - ctxt->m.b8[58] = tctxt.m.b8[57]; ctxt->m.b8[59] = tctxt.m.b8[56]; - ctxt->m.b8[60] = tctxt.m.b8[63]; ctxt->m.b8[61] = tctxt.m.b8[62]; - ctxt->m.b8[62] = tctxt.m.b8[61]; ctxt->m.b8[63] = tctxt.m.b8[60]; -#endif - - a = H(0); b = H(1); c = H(2); d = H(3); e = H(4); - - for (t = 0; t < 20; t++) { - s = t & 0x0f; - if (t >= 16) { - W(s) = S(1, W((s+13) & 0x0f) ^ W((s+8) & 0x0f) ^ W((s+2) & 0x0f) ^ W(s)); - } - tmp = S(5, a) + F0(b, c, d) + e + W(s) + K(t); - e = d; d = c; c = S(30, b); b = a; a = tmp; - } - for (t = 20; t < 40; t++) { - s = t & 0x0f; - W(s) = S(1, W((s+13) & 0x0f) ^ W((s+8) & 0x0f) ^ W((s+2) & 0x0f) ^ W(s)); - tmp = S(5, a) + F1(b, c, d) + e + W(s) + K(t); - e = d; d = c; c = S(30, b); b = a; a = tmp; - } - for (t = 40; t < 60; t++) { - s = t & 0x0f; - W(s) = S(1, W((s+13) & 0x0f) ^ W((s+8) & 0x0f) ^ W((s+2) & 0x0f) ^ W(s)); - tmp = S(5, a) + F2(b, c, d) + e + W(s) + K(t); - e = d; d = c; c = S(30, b); b = a; a = tmp; - } - for (t = 60; t < 80; t++) { - s = t & 0x0f; - W(s) = S(1, W((s+13) & 0x0f) ^ W((s+8) & 0x0f) ^ W((s+2) & 0x0f) ^ W(s)); - tmp = S(5, a) + F3(b, c, d) + e + W(s) + K(t); - e = d; d = c; c = S(30, b); b = a; a = tmp; - } - - H(0) = H(0) + a; - H(1) = H(1) + b; - H(2) = H(2) + c; - H(3) = H(3) + d; - H(4) = H(4) + e; - - bzero(&ctxt->m.b8[0], 64); -} - -/*------------------------------------------------------------*/ - -void -sha1_init(ctxt) - struct sha1_ctxt *ctxt; -{ - bzero(ctxt, sizeof(struct sha1_ctxt)); - H(0) = 0x67452301; - H(1) = 0xefcdab89; - H(2) = 0x98badcfe; - H(3) = 0x10325476; - H(4) = 0xc3d2e1f0; -} - -void -sha1_pad(ctxt) - struct sha1_ctxt *ctxt; -{ - size_t padlen; /*pad length in bytes*/ - size_t padstart; - - PUTPAD(0x80); - - padstart = COUNT % 64; - padlen = 64 - padstart; - if (padlen < 8) { - bzero(&ctxt->m.b8[padstart], padlen); - COUNT += padlen; - COUNT %= 64; - sha1_step(ctxt); - padstart = COUNT % 64; /* should be 0 */ - padlen = 64 - padstart; /* should be 64 */ - } - bzero(&ctxt->m.b8[padstart], padlen - 8); - COUNT += (padlen - 8); - COUNT %= 64; -#if BYTE_ORDER == BIG_ENDIAN - PUTPAD(ctxt->c.b8[0]); PUTPAD(ctxt->c.b8[1]); - PUTPAD(ctxt->c.b8[2]); PUTPAD(ctxt->c.b8[3]); - PUTPAD(ctxt->c.b8[4]); PUTPAD(ctxt->c.b8[5]); - PUTPAD(ctxt->c.b8[6]); PUTPAD(ctxt->c.b8[7]); -#else - PUTPAD(ctxt->c.b8[7]); PUTPAD(ctxt->c.b8[6]); - PUTPAD(ctxt->c.b8[5]); PUTPAD(ctxt->c.b8[4]); - PUTPAD(ctxt->c.b8[3]); PUTPAD(ctxt->c.b8[2]); - PUTPAD(ctxt->c.b8[1]); PUTPAD(ctxt->c.b8[0]); -#endif -} - -void -sha1_loop(ctxt, input, len) - struct sha1_ctxt *ctxt; - const u_int8_t *input; - size_t len; -{ - size_t gaplen; - size_t gapstart; - size_t off; - size_t copysiz; - - off = 0; - - while (off < len) { - gapstart = COUNT % 64; - gaplen = 64 - gapstart; - - copysiz = (gaplen < len - off) ? gaplen : len - off; - bcopy(&input[off], &ctxt->m.b8[gapstart], copysiz); - COUNT += copysiz; - COUNT %= 64; - ctxt->c.b64[0] += copysiz * 8; - if (COUNT % 64 == 0) - sha1_step(ctxt); - off += copysiz; - } -} - -void -sha1_result(ctxt, digest0) - struct sha1_ctxt *ctxt; - caddr_t digest0; -{ - u_int8_t *digest; - - digest = (u_int8_t *)digest0; - sha1_pad(ctxt); -#if BYTE_ORDER == BIG_ENDIAN - bcopy(&ctxt->h.b8[0], digest, 20); -#else - digest[0] = ctxt->h.b8[3]; digest[1] = ctxt->h.b8[2]; - digest[2] = ctxt->h.b8[1]; digest[3] = ctxt->h.b8[0]; - digest[4] = ctxt->h.b8[7]; digest[5] = ctxt->h.b8[6]; - digest[6] = ctxt->h.b8[5]; digest[7] = ctxt->h.b8[4]; - digest[8] = ctxt->h.b8[11]; digest[9] = ctxt->h.b8[10]; - digest[10] = ctxt->h.b8[9]; digest[11] = ctxt->h.b8[8]; - digest[12] = ctxt->h.b8[15]; digest[13] = ctxt->h.b8[14]; - digest[14] = ctxt->h.b8[13]; digest[15] = ctxt->h.b8[12]; - digest[16] = ctxt->h.b8[19]; digest[17] = ctxt->h.b8[18]; - digest[18] = ctxt->h.b8[17]; digest[19] = ctxt->h.b8[16]; -#endif -} - -#endif /*unsupported*/ diff --git a/target/linux/generic-2.4/files/crypto/ocf/safe/sha1.h b/target/linux/generic-2.4/files/crypto/ocf/safe/sha1.h deleted file mode 100644 index 0e19d90..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/safe/sha1.h +++ /dev/null @@ -1,72 +0,0 @@ -/* $FreeBSD: src/sys/crypto/sha1.h,v 1.8 2002/03/20 05:13:50 alfred Exp $ */ -/* $KAME: sha1.h,v 1.5 2000/03/27 04:36:23 sumikawa Exp $ */ - -/* - * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. - * 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. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT 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 PROJECT 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. - */ -/* - * FIPS pub 180-1: Secure Hash Algorithm (SHA-1) - * based on: http://csrc.nist.gov/fips/fip180-1.txt - * implemented by Jun-ichiro itojun Itoh <itojun@itojun.org> - */ - -#ifndef _NETINET6_SHA1_H_ -#define _NETINET6_SHA1_H_ - -struct sha1_ctxt { - union { - u_int8_t b8[20]; - u_int32_t b32[5]; - } h; - union { - u_int8_t b8[8]; - u_int64_t b64[1]; - } c; - union { - u_int8_t b8[64]; - u_int32_t b32[16]; - } m; - u_int8_t count; -}; - -#ifdef __KERNEL__ -extern void sha1_init(struct sha1_ctxt *); -extern void sha1_pad(struct sha1_ctxt *); -extern void sha1_loop(struct sha1_ctxt *, const u_int8_t *, size_t); -extern void sha1_result(struct sha1_ctxt *, caddr_t); - -/* compatibilty with other SHA1 source codes */ -typedef struct sha1_ctxt SHA1_CTX; -#define SHA1Init(x) sha1_init((x)) -#define SHA1Update(x, y, z) sha1_loop((x), (y), (z)) -#define SHA1Final(x, y) sha1_result((y), (x)) -#endif /* __KERNEL__ */ - -#define SHA1_RESULTLEN (160/8) - -#endif /*_NETINET6_SHA1_H_*/ diff --git a/target/linux/generic-2.4/files/crypto/ocf/talitos/Makefile b/target/linux/generic-2.4/files/crypto/ocf/talitos/Makefile deleted file mode 100644 index 2591b8a..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/talitos/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# for SGlinux builds --include $(ROOTDIR)/modules/.config - -obj-$(CONFIG_OCF_TALITOS) += talitos.o - -obj ?= . -EXTRA_CFLAGS += -I$(obj)/.. -I$(obj)/ - -ifdef TOPDIR --include $(TOPDIR)/Rules.make -endif - diff --git a/target/linux/generic-2.4/files/crypto/ocf/talitos/talitos.c b/target/linux/generic-2.4/files/crypto/ocf/talitos/talitos.c deleted file mode 100644 index 9404634..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/talitos/talitos.c +++ /dev/null @@ -1,1359 +0,0 @@ -/* - * crypto/ocf/talitos/talitos.c - * - * An OCF-Linux module that uses Freescale's SEC to do the crypto. - * Based on crypto/ocf/hifn and crypto/ocf/safe OCF drivers - * - * Copyright (c) 2006 Freescale Semiconductor, Inc. - * - * This code written by Kim A. B. Phillips <kim.phillips@freescale.com> - * some code copied from files with the following: - * Copyright (C) 2004-2007 David McCullough <david_mccullough@mcafee.com> - * - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR 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. - * - * --------------------------------------------------------------------------- - * - * NOTES: - * - * The Freescale SEC (also known as 'talitos') resides on the - * internal bus, and runs asynchronous to the processor core. It has - * a wide gamut of cryptographic acceleration features, including single- - * pass IPsec (also known as algorithm chaining). To properly utilize - * all of the SEC's performance enhancing features, further reworking - * of higher level code (framework, applications) will be necessary. - * - * The following table shows which SEC version is present in which devices: - * - * Devices SEC version - * - * 8272, 8248 SEC 1.0 - * 885, 875 SEC 1.2 - * 8555E, 8541E SEC 2.0 - * 8349E SEC 2.01 - * 8548E SEC 2.1 - * - * The following table shows the features offered by each SEC version: - * - * Max. chan- - * version Bus I/F Clock nels DEU AESU AFEU MDEU PKEU RNG KEU - * - * SEC 1.0 internal 64b 100MHz 4 1 1 1 1 1 1 0 - * SEC 1.2 internal 32b 66MHz 1 1 1 0 1 0 0 0 - * SEC 2.0 internal 64b 166MHz 4 1 1 1 1 1 1 0 - * SEC 2.01 internal 64b 166MHz 4 1 1 1 1 1 1 0 - * SEC 2.1 internal 64b 333MHz 4 1 1 1 1 1 1 1 - * - * Each execution unit in the SEC has two modes of execution; channel and - * slave/debug. This driver employs the channel infrastructure in the - * device for convenience. Only the RNG is directly accessed due to the - * convenience of its random fifo pool. The relationship between the - * channels and execution units is depicted in the following diagram: - * - * ------- ------------ - * ---| ch0 |---| | - * ------- | | - * | |------+-------+-------+-------+------------ - * ------- | | | | | | | - * ---| ch1 |---| | | | | | | - * ------- | | ------ ------ ------ ------ ------ - * |controller| |DEU | |AESU| |MDEU| |PKEU| ... |RNG | - * ------- | | ------ ------ ------ ------ ------ - * ---| ch2 |---| | | | | | | - * ------- | | | | | | | - * | |------+-------+-------+-------+------------ - * ------- | | - * ---| ch3 |---| | - * ------- ------------ - * - * Channel ch0 may drive an aes operation to the aes unit (AESU), - * and, at the same time, ch1 may drive a message digest operation - * to the mdeu. Each channel has an input descriptor FIFO, and the - * FIFO can contain, e.g. on the 8541E, up to 24 entries, before a - * a buffer overrun error is triggered. The controller is responsible - * for fetching the data from descriptor pointers, and passing the - * data to the appropriate EUs. The controller also writes the - * cryptographic operation's result to memory. The SEC notifies - * completion by triggering an interrupt and/or setting the 1st byte - * of the hdr field to 0xff. - * - * TODO: - * o support more algorithms - * o support more versions of the SEC - * o add support for linux 2.4 - * o scatter-gather (sg) support - * o add support for public key ops (PKEU) - * o add statistics - */ - -#ifndef AUTOCONF_INCLUDED -#include <linux/config.h> -#endif -#include <linux/module.h> -#include <linux/init.h> -#include <linux/interrupt.h> -#include <linux/spinlock.h> -#include <linux/random.h> -#include <linux/skbuff.h> -#include <asm/scatterlist.h> -#include <linux/dma-mapping.h> /* dma_map_single() */ -#include <linux/moduleparam.h> - -#include <linux/version.h> -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15) -#include <linux/platform_device.h> -#endif - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19) -#include <linux/of_platform.h> -#endif - -#include <cryptodev.h> -#include <uio.h> - -#define DRV_NAME "talitos" - -#include "talitos_dev.h" -#include "talitos_soft.h" - -#define read_random(p,l) get_random_bytes(p,l) - -const char talitos_driver_name[] = "Talitos OCF"; -const char talitos_driver_version[] = "0.2"; - -static int talitos_newsession(device_t dev, u_int32_t *sidp, - struct cryptoini *cri); -static int talitos_freesession(device_t dev, u_int64_t tid); -static int talitos_process(device_t dev, struct cryptop *crp, int hint); -static void dump_talitos_status(struct talitos_softc *sc); -static int talitos_submit(struct talitos_softc *sc, struct talitos_desc *td, - int chsel); -static void talitos_doneprocessing(struct talitos_softc *sc); -static void talitos_init_device(struct talitos_softc *sc); -static void talitos_reset_device_master(struct talitos_softc *sc); -static void talitos_reset_device(struct talitos_softc *sc); -static void talitos_errorprocessing(struct talitos_softc *sc); -#ifdef CONFIG_PPC_MERGE -static int talitos_probe(struct of_device *ofdev, const struct of_device_id *match); -static int talitos_remove(struct of_device *ofdev); -#else -static int talitos_probe(struct platform_device *pdev); -static int talitos_remove(struct platform_device *pdev); -#endif -#ifdef CONFIG_OCF_RANDOMHARVEST -static int talitos_read_random(void *arg, u_int32_t *buf, int maxwords); -static void talitos_rng_init(struct talitos_softc *sc); -#endif - -static device_method_t talitos_methods = { - /* crypto device methods */ - DEVMETHOD(cryptodev_newsession, talitos_newsession), - DEVMETHOD(cryptodev_freesession,talitos_freesession), - DEVMETHOD(cryptodev_process, talitos_process), -}; - -#define debug talitos_debug -int talitos_debug = 0; -module_param(talitos_debug, int, 0644); -MODULE_PARM_DESC(talitos_debug, "Enable debug"); - -static inline void talitos_write(volatile unsigned *addr, u32 val) -{ - out_be32(addr, val); -} - -static inline u32 talitos_read(volatile unsigned *addr) -{ - u32 val; - val = in_be32(addr); - return val; -} - -static void dump_talitos_status(struct talitos_softc *sc) -{ - unsigned int v, v_hi, i, *ptr; - v = talitos_read(sc->sc_base_addr + TALITOS_MCR); - v_hi = talitos_read(sc->sc_base_addr + TALITOS_MCR_HI); - printk(KERN_INFO "%s: MCR 0x%08x_%08x\n", - device_get_nameunit(sc->sc_cdev), v, v_hi); - v = talitos_read(sc->sc_base_addr + TALITOS_IMR); - v_hi = talitos_read(sc->sc_base_addr + TALITOS_IMR_HI); - printk(KERN_INFO "%s: IMR 0x%08x_%08x\n", - device_get_nameunit(sc->sc_cdev), v, v_hi); - v = talitos_read(sc->sc_base_addr + TALITOS_ISR); - v_hi = talitos_read(sc->sc_base_addr + TALITOS_ISR_HI); - printk(KERN_INFO "%s: ISR 0x%08x_%08x\n", - device_get_nameunit(sc->sc_cdev), v, v_hi); - for (i = 0; i < sc->sc_num_channels; i++) { - v = talitos_read(sc->sc_base_addr + i*TALITOS_CH_OFFSET + - TALITOS_CH_CDPR); - v_hi = talitos_read(sc->sc_base_addr + i*TALITOS_CH_OFFSET + - TALITOS_CH_CDPR_HI); - printk(KERN_INFO "%s: CDPR ch%d 0x%08x_%08x\n", - device_get_nameunit(sc->sc_cdev), i, v, v_hi); - } - for (i = 0; i < sc->sc_num_channels; i++) { - v = talitos_read(sc->sc_base_addr + i*TALITOS_CH_OFFSET + - TALITOS_CH_CCPSR); - v_hi = talitos_read(sc->sc_base_addr + i*TALITOS_CH_OFFSET + - TALITOS_CH_CCPSR_HI); - printk(KERN_INFO "%s: CCPSR ch%d 0x%08x_%08x\n", - device_get_nameunit(sc->sc_cdev), i, v, v_hi); - } - ptr = sc->sc_base_addr + TALITOS_CH_DESCBUF; - for (i = 0; i < 16; i++) { - v = talitos_read(ptr++); v_hi = talitos_read(ptr++); - printk(KERN_INFO "%s: DESCBUF ch0 0x%08x_%08x (tdp%02d)\n", - device_get_nameunit(sc->sc_cdev), v, v_hi, i); - } - return; -} - - -#ifdef CONFIG_OCF_RANDOMHARVEST -/* - * pull random numbers off the RNG FIFO, not exceeding amount available - */ -static int -talitos_read_random(void *arg, u_int32_t *buf, int maxwords) -{ - struct talitos_softc *sc = (struct talitos_softc *) arg; - int rc; - u_int32_t v; - - DPRINTF("%s()\n", __FUNCTION__); - - /* check for things like FIFO underflow */ - v = talitos_read(sc->sc_base_addr + TALITOS_RNGISR_HI); - if (unlikely(v)) { - printk(KERN_ERR "%s: RNGISR_HI error %08x\n", - device_get_nameunit(sc->sc_cdev), v); - return 0; - } - /* - * OFL is number of available 64-bit words, - * shift and convert to a 32-bit word count - */ - v = talitos_read(sc->sc_base_addr + TALITOS_RNGSR_HI); - v = (v & TALITOS_RNGSR_HI_OFL) >> (16 - 1); - if (maxwords > v) - maxwords = v; - for (rc = 0; rc < maxwords; rc++) { - buf[rc] = talitos_read(sc->sc_base_addr + - TALITOS_RNG_FIFO + rc*sizeof(u_int32_t)); - } - if (maxwords & 1) { - /* - * RNG will complain with an AE in the RNGISR - * if we don't complete the pairs of 32-bit reads - * to its 64-bit register based FIFO - */ - v = talitos_read(sc->sc_base_addr + - TALITOS_RNG_FIFO + rc*sizeof(u_int32_t)); - } - - return rc; -} - -static void -talitos_rng_init(struct talitos_softc *sc) -{ - u_int32_t v; - - DPRINTF("%s()\n", __FUNCTION__); - /* reset RNG EU */ - v = talitos_read(sc->sc_base_addr + TALITOS_RNGRCR_HI); - v |= TALITOS_RNGRCR_HI_SR; - talitos_write(sc->sc_base_addr + TALITOS_RNGRCR_HI, v); - while ((talitos_read(sc->sc_base_addr + TALITOS_RNGSR_HI) - & TALITOS_RNGSR_HI_RD) == 0) - cpu_relax(); - /* - * we tell the RNG to start filling the RNG FIFO - * by writing the RNGDSR - */ - v = talitos_read(sc->sc_base_addr + TALITOS_RNGDSR_HI); - talitos_write(sc->sc_base_addr + TALITOS_RNGDSR_HI, v); - /* - * 64 bits of data will be pushed onto the FIFO every - * 256 SEC cycles until the FIFO is full. The RNG then - * attempts to keep the FIFO full. - */ - v = talitos_read(sc->sc_base_addr + TALITOS_RNGISR_HI); - if (v) { - printk(KERN_ERR "%s: RNGISR_HI error %08x\n", - device_get_nameunit(sc->sc_cdev), v); - return; - } - /* - * n.b. we need to add a FIPS test here - if the RNG is going - * to fail, it's going to fail at reset time - */ - return; -} -#endif /* CONFIG_OCF_RANDOMHARVEST */ - -/* - * Generate a new software session. - */ -static int -talitos_newsession(device_t dev, u_int32_t *sidp, struct cryptoini *cri) -{ - struct cryptoini *c, *encini = NULL, *macini = NULL; - struct talitos_softc *sc = device_get_softc(dev); - struct talitos_session *ses = NULL; - int sesn; - - DPRINTF("%s()\n", __FUNCTION__); - if (sidp == NULL || cri == NULL || sc == NULL) { - DPRINTF("%s,%d - EINVAL\n", __FILE__, __LINE__); - return EINVAL; - } - for (c = cri; c != NULL; c = c->cri_next) { - if (c->cri_alg == CRYPTO_MD5 || - c->cri_alg == CRYPTO_MD5_HMAC || - c->cri_alg == CRYPTO_SHA1 || - c->cri_alg == CRYPTO_SHA1_HMAC || - c->cri_alg == CRYPTO_NULL_HMAC) { - if (macini) - return EINVAL; - macini = c; - } else if (c->cri_alg == CRYPTO_DES_CBC || - c->cri_alg == CRYPTO_3DES_CBC || - c->cri_alg == CRYPTO_AES_CBC || - c->cri_alg == CRYPTO_NULL_CBC) { - if (encini) - return EINVAL; - encini = c; - } else { - DPRINTF("UNKNOWN c->cri_alg %d\n", encini->cri_alg); - return EINVAL; - } - } - if (encini == NULL && macini == NULL) - return EINVAL; - if (encini) { - /* validate key length */ - switch (encini->cri_alg) { - case CRYPTO_DES_CBC: - if (encini->cri_klen != 64) - return EINVAL; - break; - case CRYPTO_3DES_CBC: - if (encini->cri_klen != 192) { - return EINVAL; - } - break; - case CRYPTO_AES_CBC: - if (encini->cri_klen != 128 && - encini->cri_klen != 192 && - encini->cri_klen != 256) - return EINVAL; - break; - default: - DPRINTF("UNKNOWN encini->cri_alg %d\n", - encini->cri_alg); - return EINVAL; - } - } - - if (sc->sc_sessions == NULL) { - ses = sc->sc_sessions = (struct talitos_session *) - kmalloc(sizeof(struct talitos_session), SLAB_ATOMIC); - if (ses == NULL) - return ENOMEM; - memset(ses, 0, sizeof(struct talitos_session)); - sesn = 0; - sc->sc_nsessions = 1; - } else { - for (sesn = 0; sesn < sc->sc_nsessions; sesn++) { - if (sc->sc_sessions[sesn].ses_used == 0) { - ses = &sc->sc_sessions[sesn]; - break; - } - } - - if (ses == NULL) { - /* allocating session */ - sesn = sc->sc_nsessions; - ses = (struct talitos_session *) kmalloc( - (sesn + 1) * sizeof(struct talitos_session), - SLAB_ATOMIC); - if (ses == NULL) - return ENOMEM; - memset(ses, 0, - (sesn + 1) * sizeof(struct talitos_session)); - memcpy(ses, sc->sc_sessions, - sesn * sizeof(struct talitos_session)); - memset(sc->sc_sessions, 0, - sesn * sizeof(struct talitos_session)); - kfree(sc->sc_sessions); - sc->sc_sessions = ses; - ses = &sc->sc_sessions[sesn]; - sc->sc_nsessions++; - } - } - - ses->ses_used = 1; - - if (encini) { - /* get an IV */ - /* XXX may read fewer than requested */ - read_random(ses->ses_iv, sizeof(ses->ses_iv)); - - ses->ses_klen = (encini->cri_klen + 7) / 8; - memcpy(ses->ses_key, encini->cri_key, ses->ses_klen); - if (macini) { - /* doing hash on top of cipher */ - ses->ses_hmac_len = (macini->cri_klen + 7) / 8; - memcpy(ses->ses_hmac, macini->cri_key, - ses->ses_hmac_len); - } - } else if (macini) { - /* doing hash */ - ses->ses_klen = (macini->cri_klen + 7) / 8; - memcpy(ses->ses_key, macini->cri_key, ses->ses_klen); - } - - /* back compat way of determining MSC result len */ - if (macini) { - ses->ses_mlen = macini->cri_mlen; - if (ses->ses_mlen == 0) { - if (macini->cri_alg == CRYPTO_MD5_HMAC) - ses->ses_mlen = MD5_HASH_LEN; - else - ses->ses_mlen = SHA1_HASH_LEN; - } - } - - /* really should make up a template td here, - * and only fill things like i/o and direction in process() */ - - /* assign session ID */ - *sidp = TALITOS_SID(sc->sc_num, sesn); - return 0; -} - -/* - * Deallocate a session. - */ -static int -talitos_freesession(device_t dev, u_int64_t tid) -{ - struct talitos_softc *sc = device_get_softc(dev); - int session, ret; - u_int32_t sid = ((u_int32_t) tid) & 0xffffffff; - - if (sc == NULL) - return EINVAL; - session = TALITOS_SESSION(sid); - if (session < sc->sc_nsessions) { - memset(&sc->sc_sessions[session], 0, - sizeof(sc->sc_sessions[session])); - ret = 0; - } else - ret = EINVAL; - return ret; -} - -/* - * launch device processing - it will come back with done notification - * in the form of an interrupt and/or HDR_DONE_BITS in header - */ -static int -talitos_submit( - struct talitos_softc *sc, - struct talitos_desc *td, - int chsel) -{ - u_int32_t v; - - v = dma_map_single(NULL, td, sizeof(*td), DMA_TO_DEVICE); - talitos_write(sc->sc_base_addr + - chsel*TALITOS_CH_OFFSET + TALITOS_CH_FF, 0); - talitos_write(sc->sc_base_addr + - chsel*TALITOS_CH_OFFSET + TALITOS_CH_FF_HI, v); - return 0; -} - -static int -talitos_process(device_t dev, struct cryptop *crp, int hint) -{ - int i, err = 0, ivsize; - struct talitos_softc *sc = device_get_softc(dev); - struct cryptodesc *crd1, *crd2, *maccrd, *enccrd; - caddr_t iv; - struct talitos_session *ses; - struct talitos_desc *td; - unsigned long flags; - /* descriptor mappings */ - int hmac_key, hmac_data, cipher_iv, cipher_key, - in_fifo, out_fifo, cipher_iv_out; - static int chsel = -1; - - DPRINTF("%s()\n", __FUNCTION__); - - if (crp == NULL || crp->crp_callback == NULL || sc == NULL) { - return EINVAL; - } - crp->crp_etype = 0; - if (TALITOS_SESSION(crp->crp_sid) >= sc->sc_nsessions) { - return EINVAL; - } - - ses = &sc->sc_sessions[TALITOS_SESSION(crp->crp_sid)]; - - /* enter the channel scheduler */ - spin_lock_irqsave(&sc->sc_chnfifolock[sc->sc_num_channels], flags); - - /* reuse channel that already had/has requests for the required EU */ - for (i = 0; i < sc->sc_num_channels; i++) { - if (sc->sc_chnlastalg[i] == crp->crp_desc->crd_alg) - break; - } - if (i == sc->sc_num_channels) { - /* - * haven't seen this algo the last sc_num_channels or more - * use round robin in this case - * nb: sc->sc_num_channels must be power of 2 - */ - chsel = (chsel + 1) & (sc->sc_num_channels - 1); - } else { - /* - * matches channel with same target execution unit; - * use same channel in this case - */ - chsel = i; - } - sc->sc_chnlastalg[chsel] = crp->crp_desc->crd_alg; - - /* release the channel scheduler lock */ - spin_unlock_irqrestore(&sc->sc_chnfifolock[sc->sc_num_channels], flags); - - /* acquire the selected channel fifo lock */ - spin_lock_irqsave(&sc->sc_chnfifolock[chsel], flags); - - /* find and reserve next available descriptor-cryptop pair */ - for (i = 0; i < sc->sc_chfifo_len; i++) { - if (sc->sc_chnfifo[chsel][i].cf_desc.hdr == 0) { - /* - * ensure correct descriptor formation by - * avoiding inadvertently setting "optional" entries - * e.g. not using "optional" dptr2 for MD/HMAC descs - */ - memset(&sc->sc_chnfifo[chsel][i].cf_desc, - 0, sizeof(*td)); - /* reserve it with done notification request bit */ - sc->sc_chnfifo[chsel][i].cf_desc.hdr |= - TALITOS_DONE_NOTIFY; - break; - } - } - spin_unlock_irqrestore(&sc->sc_chnfifolock[chsel], flags); - - if (i == sc->sc_chfifo_len) { - /* fifo full */ - err = ERESTART; - goto errout; - } - - td = &sc->sc_chnfifo[chsel][i].cf_desc; - sc->sc_chnfifo[chsel][i].cf_crp = crp; - - crd1 = crp->crp_desc; - if (crd1 == NULL) { - err = EINVAL; - goto errout; - } - crd2 = crd1->crd_next; - /* prevent compiler warning */ - hmac_key = 0; - hmac_data = 0; - if (crd2 == NULL) { - td->hdr |= TD_TYPE_COMMON_NONSNOOP_NO_AFEU; - /* assign descriptor dword ptr mappings for this desc. type */ - cipher_iv = 1; - cipher_key = 2; - in_fifo = 3; - cipher_iv_out = 5; - if (crd1->crd_alg == CRYPTO_MD5_HMAC || - crd1->crd_alg == CRYPTO_SHA1_HMAC || - crd1->crd_alg == CRYPTO_SHA1 || - crd1->crd_alg == CRYPTO_MD5) { - out_fifo = 5; - maccrd = crd1; - enccrd = NULL; - } else if (crd1->crd_alg == CRYPTO_DES_CBC || - crd1->crd_alg == CRYPTO_3DES_CBC || - crd1->crd_alg == CRYPTO_AES_CBC || - crd1->crd_alg == CRYPTO_ARC4) { - out_fifo = 4; - maccrd = NULL; - enccrd = crd1; - } else { - DPRINTF("UNKNOWN crd1->crd_alg %d\n", crd1->crd_alg); - err = EINVAL; - goto errout; - } - } else { - if (sc->sc_desc_types & TALITOS_HAS_DT_IPSEC_ESP) { - td->hdr |= TD_TYPE_IPSEC_ESP; - } else { - DPRINTF("unimplemented: multiple descriptor ipsec\n"); - err = EINVAL; - goto errout; - } - /* assign descriptor dword ptr mappings for this desc. type */ - hmac_key = 0; - hmac_data = 1; - cipher_iv = 2; - cipher_key = 3; - in_fifo = 4; - out_fifo = 5; - cipher_iv_out = 6; - if ((crd1->crd_alg == CRYPTO_MD5_HMAC || - crd1->crd_alg == CRYPTO_SHA1_HMAC || - crd1->crd_alg == CRYPTO_MD5 || - crd1->crd_alg == CRYPTO_SHA1) && - (crd2->crd_alg == CRYPTO_DES_CBC || - crd2->crd_alg == CRYPTO_3DES_CBC || - crd2->crd_alg == CRYPTO_AES_CBC || - crd2->crd_alg == CRYPTO_ARC4) && - ((crd2->crd_flags & CRD_F_ENCRYPT) == 0)) { - maccrd = crd1; - enccrd = crd2; - } else if ((crd1->crd_alg == CRYPTO_DES_CBC || - crd1->crd_alg == CRYPTO_ARC4 || - crd1->crd_alg == CRYPTO_3DES_CBC || - crd1->crd_alg == CRYPTO_AES_CBC) && - (crd2->crd_alg == CRYPTO_MD5_HMAC || - crd2->crd_alg == CRYPTO_SHA1_HMAC || - crd2->crd_alg == CRYPTO_MD5 || - crd2->crd_alg == CRYPTO_SHA1) && - (crd1->crd_flags & CRD_F_ENCRYPT)) { - enccrd = crd1; - maccrd = crd2; - } else { - /* We cannot order the SEC as requested */ - printk("%s: cannot do the order\n", - device_get_nameunit(sc->sc_cdev)); - err = EINVAL; - goto errout; - } - } - /* assign in_fifo and out_fifo based on input/output struct type */ - if (crp->crp_flags & CRYPTO_F_SKBUF) { - /* using SKB buffers */ - struct sk_buff *skb = (struct sk_buff *)crp->crp_buf; - if (skb_shinfo(skb)->nr_frags) { - printk("%s: skb frags unimplemented\n", - device_get_nameunit(sc->sc_cdev)); - err = EINVAL; - goto errout; - } - td->ptr[in_fifo].ptr = dma_map_single(NULL, skb->data, - skb->len, DMA_TO_DEVICE); - td->ptr[in_fifo].len = skb->len; - td->ptr[out_fifo].ptr = dma_map_single(NULL, skb->data, - skb->len, DMA_TO_DEVICE); - td->ptr[out_fifo].len = skb->len; - td->ptr[hmac_data].ptr = dma_map_single(NULL, skb->data, - skb->len, DMA_TO_DEVICE); - } else if (crp->crp_flags & CRYPTO_F_IOV) { - /* using IOV buffers */ - struct uio *uiop = (struct uio *)crp->crp_buf; - if (uiop->uio_iovcnt > 1) { - printk("%s: iov frags unimplemented\n", - device_get_nameunit(sc->sc_cdev)); - err = EINVAL; - goto errout; - } - td->ptr[in_fifo].ptr = dma_map_single(NULL, - uiop->uio_iov->iov_base, crp->crp_ilen, DMA_TO_DEVICE); - td->ptr[in_fifo].len = crp->crp_ilen; - /* crp_olen is never set; always use crp_ilen */ - td->ptr[out_fifo].ptr = dma_map_single(NULL, - uiop->uio_iov->iov_base, - crp->crp_ilen, DMA_TO_DEVICE); - td->ptr[out_fifo].len = crp->crp_ilen; - } else { - /* using contig buffers */ - td->ptr[in_fifo].ptr = dma_map_single(NULL, - crp->crp_buf, crp->crp_ilen, DMA_TO_DEVICE); - td->ptr[in_fifo].len = crp->crp_ilen; - td->ptr[out_fifo].ptr = dma_map_single(NULL, - crp->crp_buf, crp->crp_ilen, DMA_TO_DEVICE); - td->ptr[out_fifo].len = crp->crp_ilen; - } - if (enccrd) { - switch (enccrd->crd_alg) { - case CRYPTO_3DES_CBC: - td->hdr |= TALITOS_MODE0_DEU_3DES; - /* FALLTHROUGH */ - case CRYPTO_DES_CBC: - td->hdr |= TALITOS_SEL0_DEU - | TALITOS_MODE0_DEU_CBC; - if (enccrd->crd_flags & CRD_F_ENCRYPT) - td->hdr |= TALITOS_MODE0_DEU_ENC; - ivsize = 2*sizeof(u_int32_t); - DPRINTF("%cDES ses %d ch %d len %d\n", - (td->hdr & TALITOS_MODE0_DEU_3DES)?'3':'1', - (u32)TALITOS_SESSION(crp->crp_sid), - chsel, td->ptr[in_fifo].len); - break; - case CRYPTO_AES_CBC: - td->hdr |= TALITOS_SEL0_AESU - | TALITOS_MODE0_AESU_CBC; - if (enccrd->crd_flags & CRD_F_ENCRYPT) - td->hdr |= TALITOS_MODE0_AESU_ENC; - ivsize = 4*sizeof(u_int32_t); - DPRINTF("AES ses %d ch %d len %d\n", - (u32)TALITOS_SESSION(crp->crp_sid), - chsel, td->ptr[in_fifo].len); - break; - default: - printk("%s: unimplemented enccrd->crd_alg %d\n", - device_get_nameunit(sc->sc_cdev), enccrd->crd_alg); - err = EINVAL; - goto errout; - } - /* - * Setup encrypt/decrypt state. When using basic ops - * we can't use an inline IV because hash/crypt offset - * must be from the end of the IV to the start of the - * crypt data and this leaves out the preceding header - * from the hash calculation. Instead we place the IV - * in the state record and set the hash/crypt offset to - * copy both the header+IV. - */ - if (enccrd->crd_flags & CRD_F_ENCRYPT) { - td->hdr |= TALITOS_DIR_OUTBOUND; - if (enccrd->crd_flags & CRD_F_IV_EXPLICIT) - iv = enccrd->crd_iv; - else - iv = (caddr_t) ses->ses_iv; - if ((enccrd->crd_flags & CRD_F_IV_PRESENT) == 0) { - crypto_copyback(crp->crp_flags, crp->crp_buf, - enccrd->crd_inject, ivsize, iv); - } - } else { - td->hdr |= TALITOS_DIR_INBOUND; - if (enccrd->crd_flags & CRD_F_IV_EXPLICIT) { - iv = enccrd->crd_iv; - bcopy(enccrd->crd_iv, iv, ivsize); - } else { - iv = (caddr_t) ses->ses_iv; - crypto_copydata(crp->crp_flags, crp->crp_buf, - enccrd->crd_inject, ivsize, iv); - } - } - td->ptr[cipher_iv].ptr = dma_map_single(NULL, iv, ivsize, - DMA_TO_DEVICE); - td->ptr[cipher_iv].len = ivsize; - /* - * we don't need the cipher iv out length/pointer - * field to do ESP IPsec. Therefore we set the len field as 0, - * which tells the SEC not to do anything with this len/ptr - * field. Previously, when length/pointer as pointing to iv, - * it gave us corruption of packets. - */ - td->ptr[cipher_iv_out].len = 0; - } - if (enccrd && maccrd) { - /* this is ipsec only for now */ - td->hdr |= TALITOS_SEL1_MDEU - | TALITOS_MODE1_MDEU_INIT - | TALITOS_MODE1_MDEU_PAD; - switch (maccrd->crd_alg) { - case CRYPTO_MD5: - td->hdr |= TALITOS_MODE1_MDEU_MD5; - break; - case CRYPTO_MD5_HMAC: - td->hdr |= TALITOS_MODE1_MDEU_MD5_HMAC; - break; - case CRYPTO_SHA1: - td->hdr |= TALITOS_MODE1_MDEU_SHA1; - break; - case CRYPTO_SHA1_HMAC: - td->hdr |= TALITOS_MODE1_MDEU_SHA1_HMAC; - break; - default: - /* We cannot order the SEC as requested */ - printk("%s: cannot do the order\n", - device_get_nameunit(sc->sc_cdev)); - err = EINVAL; - goto errout; - } - if ((maccrd->crd_alg == CRYPTO_MD5_HMAC) || - (maccrd->crd_alg == CRYPTO_SHA1_HMAC)) { - /* - * The offset from hash data to the start of - * crypt data is the difference in the skips. - */ - /* ipsec only for now */ - td->ptr[hmac_key].ptr = dma_map_single(NULL, - ses->ses_hmac, ses->ses_hmac_len, DMA_TO_DEVICE); - td->ptr[hmac_key].len = ses->ses_hmac_len; - td->ptr[in_fifo].ptr += enccrd->crd_skip; - td->ptr[in_fifo].len = enccrd->crd_len; - td->ptr[out_fifo].ptr += enccrd->crd_skip; - td->ptr[out_fifo].len = enccrd->crd_len; - /* bytes of HMAC to postpend to ciphertext */ - td->ptr[out_fifo].extent = ses->ses_mlen; - td->ptr[hmac_data].ptr += maccrd->crd_skip; - td->ptr[hmac_data].len = enccrd->crd_skip - maccrd->crd_skip; - } - if (enccrd->crd_flags & CRD_F_KEY_EXPLICIT) { - printk("%s: CRD_F_KEY_EXPLICIT unimplemented\n", - device_get_nameunit(sc->sc_cdev)); - } - } - if (!enccrd && maccrd) { - /* single MD5 or SHA */ - td->hdr |= TALITOS_SEL0_MDEU - | TALITOS_MODE0_MDEU_INIT - | TALITOS_MODE0_MDEU_PAD; - switch (maccrd->crd_alg) { - case CRYPTO_MD5: - td->hdr |= TALITOS_MODE0_MDEU_MD5; - DPRINTF("MD5 ses %d ch %d len %d\n", - (u32)TALITOS_SESSION(crp->crp_sid), - chsel, td->ptr[in_fifo].len); - break; - case CRYPTO_MD5_HMAC: - td->hdr |= TALITOS_MODE0_MDEU_MD5_HMAC; - break; - case CRYPTO_SHA1: - td->hdr |= TALITOS_MODE0_MDEU_SHA1; - DPRINTF("SHA1 ses %d ch %d len %d\n", - (u32)TALITOS_SESSION(crp->crp_sid), - chsel, td->ptr[in_fifo].len); - break; - case CRYPTO_SHA1_HMAC: - td->hdr |= TALITOS_MODE0_MDEU_SHA1_HMAC; - break; - default: - /* We cannot order the SEC as requested */ - DPRINTF("cannot do the order\n"); - err = EINVAL; - goto errout; - } - - if (crp->crp_flags & CRYPTO_F_IOV) - td->ptr[out_fifo].ptr += maccrd->crd_inject; - - if ((maccrd->crd_alg == CRYPTO_MD5_HMAC) || - (maccrd->crd_alg == CRYPTO_SHA1_HMAC)) { - td->ptr[hmac_key].ptr = dma_map_single(NULL, - ses->ses_hmac, ses->ses_hmac_len, - DMA_TO_DEVICE); - td->ptr[hmac_key].len = ses->ses_hmac_len; - } - } - else { - /* using process key (session data has duplicate) */ - td->ptr[cipher_key].ptr = dma_map_single(NULL, - enccrd->crd_key, (enccrd->crd_klen + 7) / 8, - DMA_TO_DEVICE); - td->ptr[cipher_key].len = (enccrd->crd_klen + 7) / 8; - } - /* descriptor complete - GO! */ - return talitos_submit(sc, td, chsel); - -errout: - if (err != ERESTART) { - crp->crp_etype = err; - crypto_done(crp); - } - return err; -} - -/* go through all channels descriptors, notifying OCF what has - * _and_hasn't_ successfully completed and reset the device - * (otherwise it's up to decoding desc hdrs!) - */ -static void talitos_errorprocessing(struct talitos_softc *sc) -{ - unsigned long flags; - int i, j; - - /* disable further scheduling until under control */ - spin_lock_irqsave(&sc->sc_chnfifolock[sc->sc_num_channels], flags); - - if (debug) dump_talitos_status(sc); - /* go through descriptors, try and salvage those successfully done, - * and EIO those that weren't - */ - for (i = 0; i < sc->sc_num_channels; i++) { - spin_lock_irqsave(&sc->sc_chnfifolock[i], flags); - for (j = 0; j < sc->sc_chfifo_len; j++) { - if (sc->sc_chnfifo[i][j].cf_desc.hdr) { - if ((sc->sc_chnfifo[i][j].cf_desc.hdr - & TALITOS_HDR_DONE_BITS) - != TALITOS_HDR_DONE_BITS) { - /* this one didn't finish */ - /* signify in crp->etype */ - sc->sc_chnfifo[i][j].cf_crp->crp_etype - = EIO; - } - } else - continue; /* free entry */ - /* either way, notify ocf */ - crypto_done(sc->sc_chnfifo[i][j].cf_crp); - /* and tag it available again - * - * memset to ensure correct descriptor formation by - * avoiding inadvertently setting "optional" entries - * e.g. not using "optional" dptr2 MD/HMAC processing - */ - memset(&sc->sc_chnfifo[i][j].cf_desc, - 0, sizeof(struct talitos_desc)); - } - spin_unlock_irqrestore(&sc->sc_chnfifolock[i], flags); - } - /* reset and initialize the SEC h/w device */ - talitos_reset_device(sc); - talitos_init_device(sc); -#ifdef CONFIG_OCF_RANDOMHARVEST - if (sc->sc_exec_units & TALITOS_HAS_EU_RNG) - talitos_rng_init(sc); -#endif - - /* Okay. Stand by. */ - spin_unlock_irqrestore(&sc->sc_chnfifolock[sc->sc_num_channels], flags); - - return; -} - -/* go through all channels descriptors, notifying OCF what's been done */ -static void talitos_doneprocessing(struct talitos_softc *sc) -{ - unsigned long flags; - int i, j; - - /* go through descriptors looking for done bits */ - for (i = 0; i < sc->sc_num_channels; i++) { - spin_lock_irqsave(&sc->sc_chnfifolock[i], flags); - for (j = 0; j < sc->sc_chfifo_len; j++) { - /* descriptor has done bits set? */ - if ((sc->sc_chnfifo[i][j].cf_desc.hdr - & TALITOS_HDR_DONE_BITS) - == TALITOS_HDR_DONE_BITS) { - /* notify ocf */ - crypto_done(sc->sc_chnfifo[i][j].cf_crp); - /* and tag it available again - * - * memset to ensure correct descriptor formation by - * avoiding inadvertently setting "optional" entries - * e.g. not using "optional" dptr2 MD/HMAC processing - */ - memset(&sc->sc_chnfifo[i][j].cf_desc, - 0, sizeof(struct talitos_desc)); - } - } - spin_unlock_irqrestore(&sc->sc_chnfifolock[i], flags); - } - return; -} - -static irqreturn_t -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19) -talitos_intr(int irq, void *arg) -#else -talitos_intr(int irq, void *arg, struct pt_regs *regs) -#endif -{ - struct talitos_softc *sc = arg; - u_int32_t v, v_hi; - - /* ack */ - v = talitos_read(sc->sc_base_addr + TALITOS_ISR); - v_hi = talitos_read(sc->sc_base_addr + TALITOS_ISR_HI); - talitos_write(sc->sc_base_addr + TALITOS_ICR, v); - talitos_write(sc->sc_base_addr + TALITOS_ICR_HI, v_hi); - - if (unlikely(v & TALITOS_ISR_ERROR)) { - /* Okay, Houston, we've had a problem here. */ - printk(KERN_DEBUG "%s: got error interrupt - ISR 0x%08x_%08x\n", - device_get_nameunit(sc->sc_cdev), v, v_hi); - talitos_errorprocessing(sc); - } else - if (likely(v & TALITOS_ISR_DONE)) { - talitos_doneprocessing(sc); - } - return IRQ_HANDLED; -} - -/* - * Initialize registers we need to touch only once. - */ -static void -talitos_init_device(struct talitos_softc *sc) -{ - u_int32_t v; - int i; - - DPRINTF("%s()\n", __FUNCTION__); - - /* init all channels */ - for (i = 0; i < sc->sc_num_channels; i++) { - v = talitos_read(sc->sc_base_addr + - i*TALITOS_CH_OFFSET + TALITOS_CH_CCCR_HI); - v |= TALITOS_CH_CCCR_HI_CDWE - | TALITOS_CH_CCCR_HI_CDIE; /* invoke interrupt if done */ - talitos_write(sc->sc_base_addr + - i*TALITOS_CH_OFFSET + TALITOS_CH_CCCR_HI, v); - } - /* enable all interrupts */ - v = talitos_read(sc->sc_base_addr + TALITOS_IMR); - v |= TALITOS_IMR_ALL; - talitos_write(sc->sc_base_addr + TALITOS_IMR, v); - v = talitos_read(sc->sc_base_addr + TALITOS_IMR_HI); - v |= TALITOS_IMR_HI_ERRONLY; - talitos_write(sc->sc_base_addr + TALITOS_IMR_HI, v); - return; -} - -/* - * set the master reset bit on the device. - */ -static void -talitos_reset_device_master(struct talitos_softc *sc) -{ - u_int32_t v; - - /* Reset the device by writing 1 to MCR:SWR and waiting 'til cleared */ - v = talitos_read(sc->sc_base_addr + TALITOS_MCR); - talitos_write(sc->sc_base_addr + TALITOS_MCR, v | TALITOS_MCR_SWR); - - while (talitos_read(sc->sc_base_addr + TALITOS_MCR) & TALITOS_MCR_SWR) - cpu_relax(); - - return; -} - -/* - * Resets the device. Values in the registers are left as is - * from the reset (i.e. initial values are assigned elsewhere). - */ -static void -talitos_reset_device(struct talitos_softc *sc) -{ - u_int32_t v; - int i; - - DPRINTF("%s()\n", __FUNCTION__); - - /* - * Master reset - * errata documentation: warning: certain SEC interrupts - * are not fully cleared by writing the MCR:SWR bit, - * set bit twice to completely reset - */ - talitos_reset_device_master(sc); /* once */ - talitos_reset_device_master(sc); /* and once again */ - - /* reset all channels */ - for (i = 0; i < sc->sc_num_channels; i++) { - v = talitos_read(sc->sc_base_addr + i*TALITOS_CH_OFFSET + - TALITOS_CH_CCCR); - talitos_write(sc->sc_base_addr + i*TALITOS_CH_OFFSET + - TALITOS_CH_CCCR, v | TALITOS_CH_CCCR_RESET); - } -} - -/* Set up the crypto device structure, private data, - * and anything else we need before we start */ -#ifdef CONFIG_PPC_MERGE -static int talitos_probe(struct of_device *ofdev, const struct of_device_id *match) -#else -static int talitos_probe(struct platform_device *pdev) -#endif -{ - struct talitos_softc *sc = NULL; - struct resource *r; -#ifdef CONFIG_PPC_MERGE - struct device *device = &ofdev->dev; - struct device_node *np = ofdev->node; - const unsigned int *prop; - int err; - struct resource res; -#endif - static int num_chips = 0; - int rc; - int i; - - DPRINTF("%s()\n", __FUNCTION__); - - sc = (struct talitos_softc *) kmalloc(sizeof(*sc), GFP_KERNEL); - if (!sc) - return -ENOMEM; - memset(sc, 0, sizeof(*sc)); - - softc_device_init(sc, DRV_NAME, num_chips, talitos_methods); - - sc->sc_irq = -1; - sc->sc_cid = -1; -#ifndef CONFIG_PPC_MERGE - sc->sc_dev = pdev; -#endif - sc->sc_num = num_chips++; - -#ifdef CONFIG_PPC_MERGE - dev_set_drvdata(device, sc); -#else - platform_set_drvdata(sc->sc_dev, sc); -#endif - - /* get the irq line */ -#ifdef CONFIG_PPC_MERGE - err = of_address_to_resource(np, 0, &res); - if (err) - return -EINVAL; - r = &res; - - sc->sc_irq = irq_of_parse_and_map(np, 0); -#else - /* get a pointer to the register memory */ - r = platform_get_resource(pdev, IORESOURCE_MEM, 0); - - sc->sc_irq = platform_get_irq(pdev, 0); -#endif - rc = request_irq(sc->sc_irq, talitos_intr, 0, - device_get_nameunit(sc->sc_cdev), sc); - if (rc) { - printk(KERN_ERR "%s: failed to hook irq %d\n", - device_get_nameunit(sc->sc_cdev), sc->sc_irq); - sc->sc_irq = -1; - goto out; - } - - sc->sc_base_addr = (ocf_iomem_t) ioremap(r->start, (r->end - r->start)); - if (!sc->sc_base_addr) { - printk(KERN_ERR "%s: failed to ioremap\n", - device_get_nameunit(sc->sc_cdev)); - goto out; - } - - /* figure out our SEC's properties and capabilities */ - sc->sc_chiprev = (u64)talitos_read(sc->sc_base_addr + TALITOS_ID) << 32 - | talitos_read(sc->sc_base_addr + TALITOS_ID_HI); - DPRINTF("sec id 0x%llx\n", sc->sc_chiprev); - -#ifdef CONFIG_PPC_MERGE - /* get SEC properties from device tree, defaulting to SEC 2.0 */ - - prop = of_get_property(np, "num-channels", NULL); - sc->sc_num_channels = prop ? *prop : TALITOS_NCHANNELS_SEC_2_0; - - prop = of_get_property(np, "channel-fifo-len", NULL); - sc->sc_chfifo_len = prop ? *prop : TALITOS_CHFIFOLEN_SEC_2_0; - - prop = of_get_property(np, "exec-units-mask", NULL); - sc->sc_exec_units = prop ? *prop : TALITOS_HAS_EUS_SEC_2_0; - - prop = of_get_property(np, "descriptor-types-mask", NULL); - sc->sc_desc_types = prop ? *prop : TALITOS_HAS_DESCTYPES_SEC_2_0; -#else - /* bulk should go away with openfirmware flat device tree support */ - if (sc->sc_chiprev & TALITOS_ID_SEC_2_0) { - sc->sc_num_channels = TALITOS_NCHANNELS_SEC_2_0; - sc->sc_chfifo_len = TALITOS_CHFIFOLEN_SEC_2_0; - sc->sc_exec_units = TALITOS_HAS_EUS_SEC_2_0; - sc->sc_desc_types = TALITOS_HAS_DESCTYPES_SEC_2_0; - } else { - printk(KERN_ERR "%s: failed to id device\n", - device_get_nameunit(sc->sc_cdev)); - goto out; - } -#endif - - /* + 1 is for the meta-channel lock used by the channel scheduler */ - sc->sc_chnfifolock = (spinlock_t *) kmalloc( - (sc->sc_num_channels + 1) * sizeof(spinlock_t), GFP_KERNEL); - if (!sc->sc_chnfifolock) - goto out; - for (i = 0; i < sc->sc_num_channels + 1; i++) { - spin_lock_init(&sc->sc_chnfifolock[i]); - } - - sc->sc_chnlastalg = (int *) kmalloc( - sc->sc_num_channels * sizeof(int), GFP_KERNEL); - if (!sc->sc_chnlastalg) - goto out; - memset(sc->sc_chnlastalg, 0, sc->sc_num_channels * sizeof(int)); - - sc->sc_chnfifo = (struct desc_cryptop_pair **) kmalloc( - sc->sc_num_channels * sizeof(struct desc_cryptop_pair *), - GFP_KERNEL); - if (!sc->sc_chnfifo) - goto out; - for (i = 0; i < sc->sc_num_channels; i++) { - sc->sc_chnfifo[i] = (struct desc_cryptop_pair *) kmalloc( - sc->sc_chfifo_len * sizeof(struct desc_cryptop_pair), - GFP_KERNEL); - if (!sc->sc_chnfifo[i]) - goto out; - memset(sc->sc_chnfifo[i], 0, - sc->sc_chfifo_len * sizeof(struct desc_cryptop_pair)); - } - - /* reset and initialize the SEC h/w device */ - talitos_reset_device(sc); - talitos_init_device(sc); - - sc->sc_cid = crypto_get_driverid(softc_get_device(sc),CRYPTOCAP_F_HARDWARE); - if (sc->sc_cid < 0) { - printk(KERN_ERR "%s: could not get crypto driver id\n", - device_get_nameunit(sc->sc_cdev)); - goto out; - } - - /* register algorithms with the framework */ - printk("%s:", device_get_nameunit(sc->sc_cdev)); - - if (sc->sc_exec_units & TALITOS_HAS_EU_RNG) { - printk(" rng"); -#ifdef CONFIG_OCF_RANDOMHARVEST - talitos_rng_init(sc); - crypto_rregister(sc->sc_cid, talitos_read_random, sc); -#endif - } - if (sc->sc_exec_units & TALITOS_HAS_EU_DEU) { - printk(" des/3des"); - crypto_register(sc->sc_cid, CRYPTO_3DES_CBC, 0, 0); - crypto_register(sc->sc_cid, CRYPTO_DES_CBC, 0, 0); - } - if (sc->sc_exec_units & TALITOS_HAS_EU_AESU) { - printk(" aes"); - crypto_register(sc->sc_cid, CRYPTO_AES_CBC, 0, 0); - } - if (sc->sc_exec_units & TALITOS_HAS_EU_MDEU) { - printk(" md5"); - crypto_register(sc->sc_cid, CRYPTO_MD5, 0, 0); - /* HMAC support only with IPsec for now */ - crypto_register(sc->sc_cid, CRYPTO_MD5_HMAC, 0, 0); - printk(" sha1"); - crypto_register(sc->sc_cid, CRYPTO_SHA1, 0, 0); - /* HMAC support only with IPsec for now */ - crypto_register(sc->sc_cid, CRYPTO_SHA1_HMAC, 0, 0); - } - printk("\n"); - return 0; - -out: -#ifndef CONFIG_PPC_MERGE - talitos_remove(pdev); -#endif - return -ENOMEM; -} - -#ifdef CONFIG_PPC_MERGE -static int talitos_remove(struct of_device *ofdev) -#else -static int talitos_remove(struct platform_device *pdev) -#endif -{ -#ifdef CONFIG_PPC_MERGE - struct talitos_softc *sc = dev_get_drvdata(&ofdev->dev); -#else - struct talitos_softc *sc = platform_get_drvdata(pdev); -#endif - int i; - - DPRINTF("%s()\n", __FUNCTION__); - if (sc->sc_cid >= 0) - crypto_unregister_all(sc->sc_cid); - if (sc->sc_chnfifo) { - for (i = 0; i < sc->sc_num_channels; i++) - if (sc->sc_chnfifo[i]) - kfree(sc->sc_chnfifo[i]); - kfree(sc->sc_chnfifo); - } - if (sc->sc_chnlastalg) - kfree(sc->sc_chnlastalg); - if (sc->sc_chnfifolock) - kfree(sc->sc_chnfifolock); - if (sc->sc_irq != -1) - free_irq(sc->sc_irq, sc); - if (sc->sc_base_addr) - iounmap((void *) sc->sc_base_addr); - kfree(sc); - return 0; -} - -#ifdef CONFIG_PPC_MERGE -static struct of_device_id talitos_match[] = { - { - .type = "crypto", - .compatible = "talitos", - }, - {}, -}; - -MODULE_DEVICE_TABLE(of, talitos_match); - -static struct of_platform_driver talitos_driver = { - .name = DRV_NAME, - .match_table = talitos_match, - .probe = talitos_probe, - .remove = talitos_remove, -}; - -static int __init talitos_init(void) -{ - return of_register_platform_driver(&talitos_driver); -} - -static void __exit talitos_exit(void) -{ - of_unregister_platform_driver(&talitos_driver); -} -#else -/* Structure for a platform device driver */ -static struct platform_driver talitos_driver = { - .probe = talitos_probe, - .remove = talitos_remove, - .driver = { - .name = "fsl-sec2", - } -}; - -static int __init talitos_init(void) -{ - return platform_driver_register(&talitos_driver); -} - -static void __exit talitos_exit(void) -{ - platform_driver_unregister(&talitos_driver); -} -#endif - -module_init(talitos_init); -module_exit(talitos_exit); - -MODULE_LICENSE("Dual BSD/GPL"); -MODULE_AUTHOR("kim.phillips@freescale.com"); -MODULE_DESCRIPTION("OCF driver for Freescale SEC (talitos)"); diff --git a/target/linux/generic-2.4/files/crypto/ocf/talitos/talitos_dev.h b/target/linux/generic-2.4/files/crypto/ocf/talitos/talitos_dev.h deleted file mode 100644 index a8b0479..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/talitos/talitos_dev.h +++ /dev/null @@ -1,277 +0,0 @@ -/* - * Freescale SEC (talitos) device dependent data structures - * - * Copyright (c) 2006 Freescale Semiconductor, Inc. - * - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR 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. - * - */ - -/* device ID register values */ -#define TALITOS_ID_SEC_2_0 0x40 -#define TALITOS_ID_SEC_2_1 0x40 /* cross ref with IP block revision reg */ - -/* - * following num_channels, channel-fifo-depth, exec-unit-mask, and - * descriptor-types-mask are for forward-compatibility with openfirmware - * flat device trees - */ - -/* - * num_channels : the number of channels available in each SEC version. - */ - -/* n.b. this driver requires these values be a power of 2 */ -#define TALITOS_NCHANNELS_SEC_1_0 4 -#define TALITOS_NCHANNELS_SEC_1_2 1 -#define TALITOS_NCHANNELS_SEC_2_0 4 -#define TALITOS_NCHANNELS_SEC_2_01 4 -#define TALITOS_NCHANNELS_SEC_2_1 4 -#define TALITOS_NCHANNELS_SEC_2_4 4 - -/* - * channel-fifo-depth : The number of descriptor - * pointers a channel fetch fifo can hold. - */ -#define TALITOS_CHFIFOLEN_SEC_1_0 1 -#define TALITOS_CHFIFOLEN_SEC_1_2 1 -#define TALITOS_CHFIFOLEN_SEC_2_0 24 -#define TALITOS_CHFIFOLEN_SEC_2_01 24 -#define TALITOS_CHFIFOLEN_SEC_2_1 24 -#define TALITOS_CHFIFOLEN_SEC_2_4 24 - -/* - * exec-unit-mask : The bitmask representing what Execution Units (EUs) - * are available. EU information should be encoded following the SEC's - * EU_SEL0 bitfield documentation, i.e. as follows: - * - * bit 31 = set if SEC permits no-EU selection (should be always set) - * bit 30 = set if SEC has the ARC4 EU (AFEU) - * bit 29 = set if SEC has the des/3des EU (DEU) - * bit 28 = set if SEC has the message digest EU (MDEU) - * bit 27 = set if SEC has the random number generator EU (RNG) - * bit 26 = set if SEC has the public key EU (PKEU) - * bit 25 = set if SEC has the aes EU (AESU) - * bit 24 = set if SEC has the Kasumi EU (KEU) - * - */ -#define TALITOS_HAS_EU_NONE (1<<0) -#define TALITOS_HAS_EU_AFEU (1<<1) -#define TALITOS_HAS_EU_DEU (1<<2) -#define TALITOS_HAS_EU_MDEU (1<<3) -#define TALITOS_HAS_EU_RNG (1<<4) -#define TALITOS_HAS_EU_PKEU (1<<5) -#define TALITOS_HAS_EU_AESU (1<<6) -#define TALITOS_HAS_EU_KEU (1<<7) - -/* the corresponding masks for each SEC version */ -#define TALITOS_HAS_EUS_SEC_1_0 0x7f -#define TALITOS_HAS_EUS_SEC_1_2 0x4d -#define TALITOS_HAS_EUS_SEC_2_0 0x7f -#define TALITOS_HAS_EUS_SEC_2_01 0x7f -#define TALITOS_HAS_EUS_SEC_2_1 0xff -#define TALITOS_HAS_EUS_SEC_2_4 0x7f - -/* - * descriptor-types-mask : The bitmask representing what descriptors - * are available. Descriptor type information should be encoded - * following the SEC's Descriptor Header Dword DESC_TYPE field - * documentation, i.e. as follows: - * - * bit 0 = set if SEC supports the aesu_ctr_nonsnoop desc. type - * bit 1 = set if SEC supports the ipsec_esp descriptor type - * bit 2 = set if SEC supports the common_nonsnoop desc. type - * bit 3 = set if SEC supports the 802.11i AES ccmp desc. type - * bit 4 = set if SEC supports the hmac_snoop_no_afeu desc. type - * bit 5 = set if SEC supports the srtp descriptor type - * bit 6 = set if SEC supports the non_hmac_snoop_no_afeu desc.type - * bit 7 = set if SEC supports the pkeu_assemble descriptor type - * bit 8 = set if SEC supports the aesu_key_expand_output desc.type - * bit 9 = set if SEC supports the pkeu_ptmul descriptor type - * bit 10 = set if SEC supports the common_nonsnoop_afeu desc. type - * bit 11 = set if SEC supports the pkeu_ptadd_dbl descriptor type - * - * ..and so on and so forth. - */ -#define TALITOS_HAS_DT_AESU_CTR_NONSNOOP (1<<0) -#define TALITOS_HAS_DT_IPSEC_ESP (1<<1) -#define TALITOS_HAS_DT_COMMON_NONSNOOP (1<<2) - -/* the corresponding masks for each SEC version */ -#define TALITOS_HAS_DESCTYPES_SEC_2_0 0x01010ebf -#define TALITOS_HAS_DESCTYPES_SEC_2_1 0x012b0ebf - -/* - * a TALITOS_xxx_HI address points to the low data bits (32-63) of the register - */ - -/* global register offset addresses */ -#define TALITOS_ID 0x1020 -#define TALITOS_ID_HI 0x1024 -#define TALITOS_MCR 0x1030 /* master control register */ -#define TALITOS_MCR_HI 0x1038 /* master control register */ -#define TALITOS_MCR_SWR 0x1 -#define TALITOS_IMR 0x1008 /* interrupt mask register */ -#define TALITOS_IMR_ALL 0x00010fff /* enable all interrupts mask */ -#define TALITOS_IMR_ERRONLY 0x00010aaa /* enable error interrupts */ -#define TALITOS_IMR_HI 0x100C /* interrupt mask register */ -#define TALITOS_IMR_HI_ALL 0x00323333 /* enable all interrupts mask */ -#define TALITOS_IMR_HI_ERRONLY 0x00222222 /* enable error interrupts */ -#define TALITOS_ISR 0x1010 /* interrupt status register */ -#define TALITOS_ISR_ERROR 0x00010faa /* errors mask */ -#define TALITOS_ISR_DONE 0x00000055 /* channel(s) done mask */ -#define TALITOS_ISR_HI 0x1014 /* interrupt status register */ -#define TALITOS_ICR 0x1018 /* interrupt clear register */ -#define TALITOS_ICR_HI 0x101C /* interrupt clear register */ - -/* channel register address stride */ -#define TALITOS_CH_OFFSET 0x100 - -/* channel register offset addresses and bits */ -#define TALITOS_CH_CCCR 0x1108 /* Crypto-Channel Config Register */ -#define TALITOS_CH_CCCR_RESET 0x1 /* Channel Reset bit */ -#define TALITOS_CH_CCCR_HI 0x110c /* Crypto-Channel Config Register */ -#define TALITOS_CH_CCCR_HI_CDWE 0x10 /* Channel done writeback enable bit */ -#define TALITOS_CH_CCCR_HI_NT 0x4 /* Notification type bit */ -#define TALITOS_CH_CCCR_HI_CDIE 0x2 /* Channel Done Interrupt Enable bit */ -#define TALITOS_CH_CCPSR 0x1110 /* Crypto-Channel Pointer Status Reg */ -#define TALITOS_CH_CCPSR_HI 0x1114 /* Crypto-Channel Pointer Status Reg */ -#define TALITOS_CH_FF 0x1148 /* Fetch FIFO */ -#define TALITOS_CH_FF_HI 0x114c /* Fetch FIFO's FETCH_ADRS */ -#define TALITOS_CH_CDPR 0x1140 /* Crypto-Channel Pointer Status Reg */ -#define TALITOS_CH_CDPR_HI 0x1144 /* Crypto-Channel Pointer Status Reg */ -#define TALITOS_CH_DESCBUF 0x1180 /* (thru 11bf) Crypto-Channel - * Descriptor Buffer (debug) */ - -/* execution unit register offset addresses and bits */ -#define TALITOS_DEUSR 0x2028 /* DEU status register */ -#define TALITOS_DEUSR_HI 0x202c /* DEU status register */ -#define TALITOS_DEUISR 0x2030 /* DEU interrupt status register */ -#define TALITOS_DEUISR_HI 0x2034 /* DEU interrupt status register */ -#define TALITOS_DEUICR 0x2038 /* DEU interrupt control register */ -#define TALITOS_DEUICR_HI 0x203c /* DEU interrupt control register */ -#define TALITOS_AESUISR 0x4030 /* AESU interrupt status register */ -#define TALITOS_AESUISR_HI 0x4034 /* AESU interrupt status register */ -#define TALITOS_AESUICR 0x4038 /* AESU interrupt control register */ -#define TALITOS_AESUICR_HI 0x403c /* AESU interrupt control register */ -#define TALITOS_MDEUISR 0x6030 /* MDEU interrupt status register */ -#define TALITOS_MDEUISR_HI 0x6034 /* MDEU interrupt status register */ -#define TALITOS_RNGSR 0xa028 /* RNG status register */ -#define TALITOS_RNGSR_HI 0xa02c /* RNG status register */ -#define TALITOS_RNGSR_HI_RD 0x1 /* RNG Reset done */ -#define TALITOS_RNGSR_HI_OFL 0xff0000/* number of dwords in RNG output FIFO*/ -#define TALITOS_RNGDSR 0xa010 /* RNG data size register */ -#define TALITOS_RNGDSR_HI 0xa014 /* RNG data size register */ -#define TALITOS_RNG_FIFO 0xa800 /* RNG FIFO - pool of random numbers */ -#define TALITOS_RNGISR 0xa030 /* RNG Interrupt status register */ -#define TALITOS_RNGISR_HI 0xa034 /* RNG Interrupt status register */ -#define TALITOS_RNGRCR 0xa018 /* RNG Reset control register */ -#define TALITOS_RNGRCR_HI 0xa01c /* RNG Reset control register */ -#define TALITOS_RNGRCR_HI_SR 0x1 /* RNG RNGRCR:Software Reset */ - -/* descriptor pointer entry */ -struct talitos_desc_ptr { - u16 len; /* length */ - u8 extent; /* jump (to s/g link table) and extent */ - u8 res; /* reserved */ - u32 ptr; /* pointer */ -}; - -/* descriptor */ -struct talitos_desc { - u32 hdr; /* header */ - u32 res; /* reserved */ - struct talitos_desc_ptr ptr[7]; /* ptr/len pair array */ -}; - -/* talitos descriptor header (hdr) bits */ - -/* primary execution unit select */ -#define TALITOS_SEL0_AFEU 0x10000000 -#define TALITOS_SEL0_DEU 0x20000000 -#define TALITOS_SEL0_MDEU 0x30000000 -#define TALITOS_SEL0_RNG 0x40000000 -#define TALITOS_SEL0_PKEU 0x50000000 -#define TALITOS_SEL0_AESU 0x60000000 - -/* primary execution unit mode (MODE0) and derivatives */ -#define TALITOS_MODE0_AESU_CBC 0x00200000 -#define TALITOS_MODE0_AESU_ENC 0x00100000 -#define TALITOS_MODE0_DEU_CBC 0x00400000 -#define TALITOS_MODE0_DEU_3DES 0x00200000 -#define TALITOS_MODE0_DEU_ENC 0x00100000 -#define TALITOS_MODE0_MDEU_INIT 0x01000000 /* init starting regs */ -#define TALITOS_MODE0_MDEU_HMAC 0x00800000 -#define TALITOS_MODE0_MDEU_PAD 0x00400000 /* PD */ -#define TALITOS_MODE0_MDEU_MD5 0x00200000 -#define TALITOS_MODE0_MDEU_SHA256 0x00100000 -#define TALITOS_MODE0_MDEU_SHA1 0x00000000 /* SHA-160 */ -#define TALITOS_MODE0_MDEU_MD5_HMAC \ - (TALITOS_MODE0_MDEU_MD5 | TALITOS_MODE0_MDEU_HMAC) -#define TALITOS_MODE0_MDEU_SHA256_HMAC \ - (TALITOS_MODE0_MDEU_SHA256 | TALITOS_MODE0_MDEU_HMAC) -#define TALITOS_MODE0_MDEU_SHA1_HMAC \ - (TALITOS_MODE0_MDEU_SHA1 | TALITOS_MODE0_MDEU_HMAC) - -/* secondary execution unit select (SEL1) */ -/* it's MDEU or nothing */ -#define TALITOS_SEL1_MDEU 0x00030000 - -/* secondary execution unit mode (MODE1) and derivatives */ -#define TALITOS_MODE1_MDEU_INIT 0x00001000 /* init starting regs */ -#define TALITOS_MODE1_MDEU_HMAC 0x00000800 -#define TALITOS_MODE1_MDEU_PAD 0x00000400 /* PD */ -#define TALITOS_MODE1_MDEU_MD5 0x00000200 -#define TALITOS_MODE1_MDEU_SHA256 0x00000100 -#define TALITOS_MODE1_MDEU_SHA1 0x00000000 /* SHA-160 */ -#define TALITOS_MODE1_MDEU_MD5_HMAC \ - (TALITOS_MODE1_MDEU_MD5 | TALITOS_MODE1_MDEU_HMAC) -#define TALITOS_MODE1_MDEU_SHA256_HMAC \ - (TALITOS_MODE1_MDEU_SHA256 | TALITOS_MODE1_MDEU_HMAC) -#define TALITOS_MODE1_MDEU_SHA1_HMAC \ - (TALITOS_MODE1_MDEU_SHA1 | TALITOS_MODE1_MDEU_HMAC) - -/* direction of overall data flow (DIR) */ -#define TALITOS_DIR_OUTBOUND 0x00000000 -#define TALITOS_DIR_INBOUND 0x00000002 - -/* done notification (DN) */ -#define TALITOS_DONE_NOTIFY 0x00000001 - -/* descriptor types */ -/* odd numbers here are valid on SEC2 and greater only (e.g. ipsec_esp) */ -#define TD_TYPE_AESU_CTR_NONSNOOP (0 << 3) -#define TD_TYPE_IPSEC_ESP (1 << 3) -#define TD_TYPE_COMMON_NONSNOOP_NO_AFEU (2 << 3) -#define TD_TYPE_HMAC_SNOOP_NO_AFEU (4 << 3) - -#define TALITOS_HDR_DONE_BITS 0xff000000 - -#define DPRINTF(a...) do { \ - if (debug) { \ - printk("%s: ", sc ? \ - device_get_nameunit(sc->sc_cdev) : "talitos"); \ - printk(a); \ - } \ - } while (0) diff --git a/target/linux/generic-2.4/files/crypto/ocf/talitos/talitos_soft.h b/target/linux/generic-2.4/files/crypto/ocf/talitos/talitos_soft.h deleted file mode 100644 index 79efdbd..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/talitos/talitos_soft.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Freescale SEC data structures for integration with ocf-linux - * - * Copyright (c) 2006 Freescale Semiconductor, Inc. - * - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR 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. - */ - -/* - * paired descriptor and associated crypto operation - */ -struct desc_cryptop_pair { - struct talitos_desc cf_desc; /* descriptor ptr */ - struct cryptop *cf_crp; /* cryptop ptr */ -}; - -/* - * Holds data specific to a single talitos device. - */ -struct talitos_softc { - softc_device_decl sc_cdev; - struct platform_device *sc_dev; /* device backpointer */ - ocf_iomem_t sc_base_addr; - int sc_irq; - int sc_num; /* if we have multiple chips */ - int32_t sc_cid; /* crypto tag */ - u64 sc_chiprev; /* major/minor chip revision */ - int sc_nsessions; - struct talitos_session *sc_sessions; - int sc_num_channels;/* number of crypto channels */ - int sc_chfifo_len; /* channel fetch fifo len */ - int sc_exec_units; /* execution units mask */ - int sc_desc_types; /* descriptor types mask */ - /* - * mutual exclusion for intra-channel resources, e.g. fetch fifos - * the last entry is a meta-channel lock used by the channel scheduler - */ - spinlock_t *sc_chnfifolock; - /* sc_chnlastalgo contains last algorithm for that channel */ - int *sc_chnlastalg; - /* sc_chnfifo holds pending descriptor--crypto operation pairs */ - struct desc_cryptop_pair **sc_chnfifo; -}; - -struct talitos_session { - u_int32_t ses_used; - u_int32_t ses_klen; /* key length in bits */ - u_int32_t ses_key[8]; /* DES/3DES/AES key */ - u_int32_t ses_hmac[5]; /* hmac inner state */ - u_int32_t ses_hmac_len; /* hmac length */ - u_int32_t ses_iv[4]; /* DES/3DES/AES iv */ - u_int32_t ses_mlen; /* desired hash result len (12=ipsec or 16) */ -}; - -#define TALITOS_SESSION(sid) ((sid) & 0x0fffffff) -#define TALITOS_SID(crd, sesn) (((crd) << 28) | ((sesn) & 0x0fffffff)) diff --git a/target/linux/generic-2.4/files/crypto/ocf/uio.h b/target/linux/generic-2.4/files/crypto/ocf/uio.h deleted file mode 100644 index 03a6249..0000000 --- a/target/linux/generic-2.4/files/crypto/ocf/uio.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef _OCF_UIO_H_ -#define _OCF_UIO_H_ - -#include <linux/uio.h> - -/* - * The linux uio.h doesn't have all we need. To be fully api compatible - * with the BSD cryptodev, we need to keep this around. Perhaps this can - * be moved back into the linux/uio.h - * - * Linux port done by David McCullough <david_mccullough@mcafee.com> - * Copyright (C) 2006-2010 David McCullough - * Copyright (C) 2004-2005 Intel Corporation. - * - * LICENSE TERMS - * - * The free distribution and use of this software in both source and binary - * form is allowed (with or without changes) provided that: - * - * 1. distributions of this source code include the above copyright - * notice, this list of conditions and the following disclaimer; - * - * 2. distributions in binary form include the above copyright - * notice, this list of conditions and the following disclaimer - * in the documentation and/or other associated materials; - * - * 3. the copyright holder's name is not used to endorse products - * built using this software without specific written permission. - * - * ALTERNATIVELY, provided that this notice is retained in full, this product - * may be distributed under the terms of the GNU General Public License (GPL), - * in which case the provisions of the GPL apply INSTEAD OF those given above. - * - * DISCLAIMER - * - * This software is provided 'as is' with no explicit or implied warranties - * in respect of its properties, including, but not limited to, correctness - * and/or fitness for purpose. - * --------------------------------------------------------------------------- - */ - -struct uio { - struct iovec *uio_iov; - int uio_iovcnt; - off_t uio_offset; - int uio_resid; -#if 0 - enum uio_seg uio_segflg; - enum uio_rw uio_rw; - struct thread *uio_td; -#endif -}; - -#endif diff --git a/target/linux/generic-2.4/image b/target/linux/generic-2.4/image deleted file mode 120000 index a96fdd0..0000000 --- a/target/linux/generic-2.4/image +++ /dev/null @@ -1 +0,0 @@ -../generic-2.6/image/
\ No newline at end of file diff --git a/target/linux/generic-2.4/patches/000-linux_mips.patch b/target/linux/generic-2.4/patches/000-linux_mips.patch deleted file mode 100644 index 0def0d6..0000000 --- a/target/linux/generic-2.4/patches/000-linux_mips.patch +++ /dev/null @@ -1,27704 +0,0 @@ ---- a/arch/mips/au1000/common/au1xxx_irqmap.c -+++ b/arch/mips/au1000/common/au1xxx_irqmap.c -@@ -172,14 +172,14 @@ au1xxx_irq_map_t au1xxx_ic0_map[] = { - { AU1550_PSC1_INT, INTC_INT_HIGH_LEVEL, 0}, - { AU1550_PSC2_INT, INTC_INT_HIGH_LEVEL, 0}, - { AU1550_PSC3_INT, INTC_INT_HIGH_LEVEL, 0}, -- { AU1550_TOY_INT, INTC_INT_RISE_EDGE, 0 }, -- { AU1550_TOY_MATCH0_INT, INTC_INT_RISE_EDGE, 0 }, -- { AU1550_TOY_MATCH1_INT, INTC_INT_RISE_EDGE, 0 }, -- { AU1550_TOY_MATCH2_INT, INTC_INT_RISE_EDGE, 1 }, -- { AU1550_RTC_INT, INTC_INT_RISE_EDGE, 0 }, -- { AU1550_RTC_MATCH0_INT, INTC_INT_RISE_EDGE, 0 }, -- { AU1550_RTC_MATCH1_INT, INTC_INT_RISE_EDGE, 0 }, -- { AU1550_RTC_MATCH2_INT, INTC_INT_RISE_EDGE, 0 }, -+ { AU1000_TOY_INT, INTC_INT_RISE_EDGE, 0 }, -+ { AU1000_TOY_MATCH0_INT, INTC_INT_RISE_EDGE, 0 }, -+ { AU1000_TOY_MATCH1_INT, INTC_INT_RISE_EDGE, 0 }, -+ { AU1000_TOY_MATCH2_INT, INTC_INT_RISE_EDGE, 1 }, -+ { AU1000_RTC_INT, INTC_INT_RISE_EDGE, 0 }, -+ { AU1000_RTC_MATCH0_INT, INTC_INT_RISE_EDGE, 0 }, -+ { AU1000_RTC_MATCH1_INT, INTC_INT_RISE_EDGE, 0 }, -+ { AU1000_RTC_MATCH2_INT, INTC_INT_RISE_EDGE, 0 }, - { AU1550_NAND_INT, INTC_INT_RISE_EDGE, 0}, - { AU1550_USB_DEV_REQ_INT, INTC_INT_HIGH_LEVEL, 0 }, - { AU1550_USB_DEV_SUS_INT, INTC_INT_RISE_EDGE, 0 }, -@@ -200,14 +200,14 @@ au1xxx_irq_map_t au1xxx_ic0_map[] = { - { AU1200_PSC1_INT, INTC_INT_HIGH_LEVEL, 0}, - { AU1200_AES_INT, INTC_INT_HIGH_LEVEL, 0}, - { AU1200_CAMERA_INT, INTC_INT_HIGH_LEVEL, 0}, -- { AU1200_TOY_INT, INTC_INT_RISE_EDGE, 0 }, -- { AU1200_TOY_MATCH0_INT, INTC_INT_RISE_EDGE, 0 }, -- { AU1200_TOY_MATCH1_INT, INTC_INT_RISE_EDGE, 0 }, -- { AU1200_TOY_MATCH2_INT, INTC_INT_RISE_EDGE, 1 }, -- { AU1200_RTC_INT, INTC_INT_RISE_EDGE, 0 }, -- { AU1200_RTC_MATCH0_INT, INTC_INT_RISE_EDGE, 0 }, -- { AU1200_RTC_MATCH1_INT, INTC_INT_RISE_EDGE, 0 }, -- { AU1200_RTC_MATCH2_INT, INTC_INT_RISE_EDGE, 0 }, -+ { AU1000_TOY_INT, INTC_INT_RISE_EDGE, 0 }, -+ { AU1000_TOY_MATCH0_INT, INTC_INT_RISE_EDGE, 0 }, -+ { AU1000_TOY_MATCH1_INT, INTC_INT_RISE_EDGE, 0 }, -+ { AU1000_TOY_MATCH2_INT, INTC_INT_RISE_EDGE, 1 }, -+ { AU1000_RTC_INT, INTC_INT_RISE_EDGE, 0 }, -+ { AU1000_RTC_MATCH0_INT, INTC_INT_RISE_EDGE, 0 }, -+ { AU1000_RTC_MATCH1_INT, INTC_INT_RISE_EDGE, 0 }, -+ { AU1000_RTC_MATCH2_INT, INTC_INT_RISE_EDGE, 0 }, - { AU1200_NAND_INT, INTC_INT_RISE_EDGE, 0}, - { AU1200_USB_INT, INTC_INT_HIGH_LEVEL, 0 }, - { AU1200_LCD_INT, INTC_INT_HIGH_LEVEL, 0}, ---- a/arch/mips/au1000/common/cputable.c -+++ b/arch/mips/au1000/common/cputable.c -@@ -39,7 +39,8 @@ struct cpu_spec cpu_specs[] = { - { 0xffffffff, 0x02030203, "Au1100 BD", 0, 1 }, - { 0xffffffff, 0x02030204, "Au1100 BE", 0, 1 }, - { 0xffffffff, 0x03030200, "Au1550 AA", 0, 1 }, -- { 0xffffffff, 0x04030200, "Au1200 AA", 0, 1 }, -+ { 0xffffffff, 0x04030200, "Au1200 AB", 0, 0 }, -+ { 0xffffffff, 0x04030201, "Au1200 AC", 0, 0 }, - { 0x00000000, 0x00000000, "Unknown Au1xxx", 1, 0 }, - }; - ---- a/arch/mips/au1000/common/dbdma.c -+++ b/arch/mips/au1000/common/dbdma.c -@@ -41,6 +41,8 @@ - #include <asm/au1xxx_dbdma.h> - #include <asm/system.h> - -+#include <linux/module.h> -+ - #if defined(CONFIG_SOC_AU1550) || defined(CONFIG_SOC_AU1200) - - /* -@@ -60,37 +62,10 @@ static spinlock_t au1xxx_dbdma_spin_lock - */ - #define ALIGN_ADDR(x, a) ((((u32)(x)) + (a-1)) & ~(a-1)) - --static volatile dbdma_global_t *dbdma_gptr = (dbdma_global_t *)DDMA_GLOBAL_BASE; --static int dbdma_initialized; -+static dbdma_global_t *dbdma_gptr = (dbdma_global_t *)DDMA_GLOBAL_BASE; -+static int dbdma_initialized=0; - static void au1xxx_dbdma_init(void); - --typedef struct dbdma_device_table { -- u32 dev_id; -- u32 dev_flags; -- u32 dev_tsize; -- u32 dev_devwidth; -- u32 dev_physaddr; /* If FIFO */ -- u32 dev_intlevel; -- u32 dev_intpolarity; --} dbdev_tab_t; -- --typedef struct dbdma_chan_config { -- u32 chan_flags; -- u32 chan_index; -- dbdev_tab_t *chan_src; -- dbdev_tab_t *chan_dest; -- au1x_dma_chan_t *chan_ptr; -- au1x_ddma_desc_t *chan_desc_base; -- au1x_ddma_desc_t *get_ptr, *put_ptr, *cur_ptr; -- void *chan_callparam; -- void (*chan_callback)(int, void *, struct pt_regs *); --} chan_tab_t; -- --#define DEV_FLAGS_INUSE (1 << 0) --#define DEV_FLAGS_ANYUSE (1 << 1) --#define DEV_FLAGS_OUT (1 << 2) --#define DEV_FLAGS_IN (1 << 3) -- - static dbdev_tab_t dbdev_tab[] = { - #ifdef CONFIG_SOC_AU1550 - /* UARTS */ -@@ -156,13 +131,13 @@ static dbdev_tab_t dbdev_tab[] = { - { DSCR_CMD0_MAE_BOTH, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 }, - { DSCR_CMD0_LCD, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 }, - -- { DSCR_CMD0_SDMS_TX0, DEV_FLAGS_OUT, 0, 0, 0x00000000, 0, 0 }, -- { DSCR_CMD0_SDMS_RX0, DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 }, -- { DSCR_CMD0_SDMS_TX1, DEV_FLAGS_OUT, 0, 0, 0x00000000, 0, 0 }, -- { DSCR_CMD0_SDMS_RX1, DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 }, -+ { DSCR_CMD0_SDMS_TX0, DEV_FLAGS_OUT, 4, 8, 0x10600000, 0, 0 }, -+ { DSCR_CMD0_SDMS_RX0, DEV_FLAGS_IN, 4, 8, 0x10600004, 0, 0 }, -+ { DSCR_CMD0_SDMS_TX1, DEV_FLAGS_OUT, 4, 8, 0x10680000, 0, 0 }, -+ { DSCR_CMD0_SDMS_RX1, DEV_FLAGS_IN, 4, 8, 0x10680004, 0, 0 }, - -- { DSCR_CMD0_AES_TX, DEV_FLAGS_OUT, 0, 0, 0x00000000, 0, 0 }, -- { DSCR_CMD0_AES_RX, DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 }, -+ { DSCR_CMD0_AES_RX, DEV_FLAGS_IN , 4, 32, 0x10300008, 0, 0 }, -+ { DSCR_CMD0_AES_TX, DEV_FLAGS_OUT, 4, 32, 0x10300004, 0, 0 }, - - { DSCR_CMD0_PSC0_TX, DEV_FLAGS_OUT, 0, 0, 0x11a0001c, 0, 0 }, - { DSCR_CMD0_PSC0_RX, DEV_FLAGS_IN, 0, 0, 0x11a0001c, 0, 0 }, -@@ -172,9 +147,9 @@ static dbdev_tab_t dbdev_tab[] = { - { DSCR_CMD0_PSC1_RX, DEV_FLAGS_IN, 0, 0, 0x11b0001c, 0, 0 }, - { DSCR_CMD0_PSC1_SYNC, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 }, - -- { DSCR_CMD0_CIM_RXA, DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 }, -- { DSCR_CMD0_CIM_RXB, DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 }, -- { DSCR_CMD0_CIM_RXC, DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 }, -+ { DSCR_CMD0_CIM_RXA, DEV_FLAGS_IN, 0, 32, 0x14004020, 0, 0 }, -+ { DSCR_CMD0_CIM_RXB, DEV_FLAGS_IN, 0, 32, 0x14004040, 0, 0 }, -+ { DSCR_CMD0_CIM_RXC, DEV_FLAGS_IN, 0, 32, 0x14004060, 0, 0 }, - { DSCR_CMD0_CIM_SYNC, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 }, - - { DSCR_CMD0_NAND_FLASH, DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 }, -@@ -183,6 +158,24 @@ static dbdev_tab_t dbdev_tab[] = { - - { DSCR_CMD0_THROTTLE, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 }, - { DSCR_CMD0_ALWAYS, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 }, -+ -+ /* Provide 16 user definable device types */ -+ { 0, 0, 0, 0, 0, 0, 0 }, -+ { 0, 0, 0, 0, 0, 0, 0 }, -+ { 0, 0, 0, 0, 0, 0, 0 }, -+ { 0, 0, 0, 0, 0, 0, 0 }, -+ { 0, 0, 0, 0, 0, 0, 0 }, -+ { 0, 0, 0, 0, 0, 0, 0 }, -+ { 0, 0, 0, 0, 0, 0, 0 }, -+ { 0, 0, 0, 0, 0, 0, 0 }, -+ { 0, 0, 0, 0, 0, 0, 0 }, -+ { 0, 0, 0, 0, 0, 0, 0 }, -+ { 0, 0, 0, 0, 0, 0, 0 }, -+ { 0, 0, 0, 0, 0, 0, 0 }, -+ { 0, 0, 0, 0, 0, 0, 0 }, -+ { 0, 0, 0, 0, 0, 0, 0 }, -+ { 0, 0, 0, 0, 0, 0, 0 }, -+ { 0, 0, 0, 0, 0, 0, 0 }, - }; - - #define DBDEV_TAB_SIZE (sizeof(dbdev_tab) / sizeof(dbdev_tab_t)) -@@ -202,6 +195,30 @@ find_dbdev_id (u32 id) - return NULL; - } - -+u32 -+au1xxx_ddma_add_device(dbdev_tab_t *dev) -+{ -+ u32 ret = 0; -+ dbdev_tab_t *p=NULL; -+ static u16 new_id=0x1000; -+ -+ p = find_dbdev_id(0); -+ if ( NULL != p ) -+ { -+ memcpy(p, dev, sizeof(dbdev_tab_t)); -+ p->dev_id = DSCR_DEV2CUSTOM_ID(new_id,dev->dev_id); -+ ret = p->dev_id; -+ new_id++; -+#if 0 -+ printk("add_device: id:%x flags:%x padd:%x\n", -+ p->dev_id, p->dev_flags, p->dev_physaddr ); -+#endif -+ } -+ -+ return ret; -+} -+EXPORT_SYMBOL(au1xxx_ddma_add_device); -+ - /* Allocate a channel and return a non-zero descriptor if successful. - */ - u32 -@@ -214,7 +231,7 @@ au1xxx_dbdma_chan_alloc(u32 srcid, u32 d - int i; - dbdev_tab_t *stp, *dtp; - chan_tab_t *ctp; -- volatile au1x_dma_chan_t *cp; -+ au1x_dma_chan_t *cp; - - /* We do the intialization on the first channel allocation. - * We have to wait because of the interrupt handler initialization -@@ -224,9 +241,6 @@ au1xxx_dbdma_chan_alloc(u32 srcid, u32 d - au1xxx_dbdma_init(); - dbdma_initialized = 1; - -- if ((srcid > DSCR_NDEV_IDS) || (destid > DSCR_NDEV_IDS)) -- return 0; -- - if ((stp = find_dbdev_id(srcid)) == NULL) return 0; - if ((dtp = find_dbdev_id(destid)) == NULL) return 0; - -@@ -268,9 +282,9 @@ au1xxx_dbdma_chan_alloc(u32 srcid, u32 d - /* If kmalloc fails, it is caught below same - * as a channel not available. - */ -- ctp = (chan_tab_t *)kmalloc(sizeof(chan_tab_t), GFP_KERNEL); -+ ctp = (chan_tab_t *) -+ kmalloc(sizeof(chan_tab_t), GFP_KERNEL); - chan_tab_ptr[i] = ctp; -- ctp->chan_index = chan = i; - break; - } - } -@@ -278,10 +292,11 @@ au1xxx_dbdma_chan_alloc(u32 srcid, u32 d - - if (ctp != NULL) { - memset(ctp, 0, sizeof(chan_tab_t)); -+ ctp->chan_index = chan = i; - dcp = DDMA_CHANNEL_BASE; - dcp += (0x0100 * chan); - ctp->chan_ptr = (au1x_dma_chan_t *)dcp; -- cp = (volatile au1x_dma_chan_t *)dcp; -+ cp = (au1x_dma_chan_t *)dcp; - ctp->chan_src = stp; - ctp->chan_dest = dtp; - ctp->chan_callback = callback; -@@ -298,6 +313,9 @@ au1xxx_dbdma_chan_alloc(u32 srcid, u32 d - i |= DDMA_CFG_DED; - if (dtp->dev_intpolarity) - i |= DDMA_CFG_DP; -+ if ((stp->dev_flags & DEV_FLAGS_SYNC) || -+ (dtp->dev_flags & DEV_FLAGS_SYNC)) -+ i |= DDMA_CFG_SYNC; - cp->ddma_cfg = i; - au_sync(); - -@@ -308,14 +326,14 @@ au1xxx_dbdma_chan_alloc(u32 srcid, u32 d - rv = (u32)(&chan_tab_ptr[chan]); - } - else { -- /* Release devices. -- */ -+ /* Release devices */ - stp->dev_flags &= ~DEV_FLAGS_INUSE; - dtp->dev_flags &= ~DEV_FLAGS_INUSE; - } - } - return rv; - } -+EXPORT_SYMBOL(au1xxx_dbdma_chan_alloc); - - /* Set the device width if source or destination is a FIFO. - * Should be 8, 16, or 32 bits. -@@ -343,6 +361,7 @@ au1xxx_dbdma_set_devwidth(u32 chanid, in - - return rv; - } -+EXPORT_SYMBOL(au1xxx_dbdma_set_devwidth); - - /* Allocate a descriptor ring, initializing as much as possible. - */ -@@ -369,7 +388,8 @@ au1xxx_dbdma_ring_alloc(u32 chanid, int - * and if we try that first we are likely to not waste larger - * slabs of memory. - */ -- desc_base = (u32)kmalloc(entries * sizeof(au1x_ddma_desc_t), GFP_KERNEL); -+ desc_base = (u32)kmalloc(entries * sizeof(au1x_ddma_desc_t), -+ GFP_KERNEL|GFP_DMA); - if (desc_base == 0) - return 0; - -@@ -380,7 +400,7 @@ au1xxx_dbdma_ring_alloc(u32 chanid, int - kfree((const void *)desc_base); - i = entries * sizeof(au1x_ddma_desc_t); - i += (sizeof(au1x_ddma_desc_t) - 1); -- if ((desc_base = (u32)kmalloc(i, GFP_KERNEL)) == 0) -+ if ((desc_base = (u32)kmalloc(i, GFP_KERNEL|GFP_DMA)) == 0) - return 0; - - desc_base = ALIGN_ADDR(desc_base, sizeof(au1x_ddma_desc_t)); -@@ -460,9 +480,14 @@ au1xxx_dbdma_ring_alloc(u32 chanid, int - /* If source input is fifo, set static address. - */ - if (stp->dev_flags & DEV_FLAGS_IN) { -- src0 = stp->dev_physaddr; -- src1 |= DSCR_SRC1_SAM(DSCR_xAM_STATIC); -+ if ( stp->dev_flags & DEV_FLAGS_BURSTABLE ) -+ src1 |= DSCR_SRC1_SAM(DSCR_xAM_BURST); -+ else -+ src1 |= DSCR_SRC1_SAM(DSCR_xAM_STATIC); -+ - } -+ if (stp->dev_physaddr) -+ src0 = stp->dev_physaddr; - - /* Set up dest1. For now, assume no stride and increment. - * A channel attribute update can change this later. -@@ -486,10 +511,18 @@ au1xxx_dbdma_ring_alloc(u32 chanid, int - /* If destination output is fifo, set static address. - */ - if (dtp->dev_flags & DEV_FLAGS_OUT) { -- dest0 = dtp->dev_physaddr; -+ if ( dtp->dev_flags & DEV_FLAGS_BURSTABLE ) -+ dest1 |= DSCR_DEST1_DAM(DSCR_xAM_BURST); -+ else - dest1 |= DSCR_DEST1_DAM(DSCR_xAM_STATIC); - } -+ if (dtp->dev_physaddr) -+ dest0 = dtp->dev_physaddr; - -+#if 0 -+ printk("did:%x sid:%x cmd0:%x cmd1:%x source0:%x source1:%x dest0:%x dest1:%x\n", -+ dtp->dev_id, stp->dev_id, cmd0, cmd1, src0, src1, dest0, dest1 ); -+#endif - for (i=0; i<entries; i++) { - dp->dscr_cmd0 = cmd0; - dp->dscr_cmd1 = cmd1; -@@ -498,6 +531,7 @@ au1xxx_dbdma_ring_alloc(u32 chanid, int - dp->dscr_dest0 = dest0; - dp->dscr_dest1 = dest1; - dp->dscr_stat = 0; -+ dp->sw_context = dp->sw_status = 0; - dp->dscr_nxtptr = DSCR_NXTPTR(virt_to_phys(dp + 1)); - dp++; - } -@@ -510,13 +544,14 @@ au1xxx_dbdma_ring_alloc(u32 chanid, int - - return (u32)(ctp->chan_desc_base); - } -+EXPORT_SYMBOL(au1xxx_dbdma_ring_alloc); - - /* Put a source buffer into the DMA ring. - * This updates the source pointer and byte count. Normally used - * for memory to fifo transfers. - */ - u32 --au1xxx_dbdma_put_source(u32 chanid, void *buf, int nbytes) -+_au1xxx_dbdma_put_source(u32 chanid, void *buf, int nbytes, u32 flags) - { - chan_tab_t *ctp; - au1x_ddma_desc_t *dp; -@@ -543,24 +578,40 @@ au1xxx_dbdma_put_source(u32 chanid, void - */ - dp->dscr_source0 = virt_to_phys(buf); - dp->dscr_cmd1 = nbytes; -- dp->dscr_cmd0 |= DSCR_CMD0_V; /* Let it rip */ -- ctp->chan_ptr->ddma_dbell = 0xffffffff; /* Make it go */ -- -+ /* Check flags */ -+ if (flags & DDMA_FLAGS_IE) -+ dp->dscr_cmd0 |= DSCR_CMD0_IE; -+ if (flags & DDMA_FLAGS_NOIE) -+ dp->dscr_cmd0 &= ~DSCR_CMD0_IE; - /* Get next descriptor pointer. - */ - ctp->put_ptr = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr)); - -+ /* -+ * There is an errata on the Au1200/Au1550 parts that could result -+ * in "stale" data being DMA'd. It has to do with the snoop logic on -+ * the dache eviction buffer. NONCOHERENT_IO is on by default for -+ * these parts. If it is fixedin the future, these dma_cache_inv will -+ * just be nothing more than empty macros. See io.h. -+ * */ -+ dma_cache_wback_inv(buf,nbytes); -+ dp->dscr_cmd0 |= DSCR_CMD0_V; /* Let it rip */ -+ au_sync(); -+ dma_cache_wback_inv(dp, sizeof(dp)); -+ ctp->chan_ptr->ddma_dbell = 0; -+ - /* return something not zero. - */ - return nbytes; - } -+EXPORT_SYMBOL(_au1xxx_dbdma_put_source); - - /* Put a destination buffer into the DMA ring. - * This updates the destination pointer and byte count. Normally used - * to place an empty buffer into the ring for fifo to memory transfers. - */ - u32 --au1xxx_dbdma_put_dest(u32 chanid, void *buf, int nbytes) -+_au1xxx_dbdma_put_dest(u32 chanid, void *buf, int nbytes, u32 flags) - { - chan_tab_t *ctp; - au1x_ddma_desc_t *dp; -@@ -582,11 +633,33 @@ au1xxx_dbdma_put_dest(u32 chanid, void * - if (dp->dscr_cmd0 & DSCR_CMD0_V) - return 0; - -- /* Load up buffer address and byte count. -- */ -+ /* Load up buffer address and byte count */ -+ -+ /* Check flags */ -+ if (flags & DDMA_FLAGS_IE) -+ dp->dscr_cmd0 |= DSCR_CMD0_IE; -+ if (flags & DDMA_FLAGS_NOIE) -+ dp->dscr_cmd0 &= ~DSCR_CMD0_IE; -+ - dp->dscr_dest0 = virt_to_phys(buf); - dp->dscr_cmd1 = nbytes; -+#if 0 -+ printk("cmd0:%x cmd1:%x source0:%x source1:%x dest0:%x dest1:%x\n", -+ dp->dscr_cmd0, dp->dscr_cmd1, dp->dscr_source0, -+ dp->dscr_source1, dp->dscr_dest0, dp->dscr_dest1 ); -+#endif -+ /* -+ * There is an errata on the Au1200/Au1550 parts that could result in -+ * "stale" data being DMA'd. It has to do with the snoop logic on the -+ * dache eviction buffer. NONCOHERENT_IO is on by default for these -+ * parts. If it is fixedin the future, these dma_cache_inv will just -+ * be nothing more than empty macros. See io.h. -+ * */ -+ dma_cache_inv(buf,nbytes); - dp->dscr_cmd0 |= DSCR_CMD0_V; /* Let it rip */ -+ au_sync(); -+ dma_cache_wback_inv(dp, sizeof(dp)); -+ ctp->chan_ptr->ddma_dbell = 0; - - /* Get next descriptor pointer. - */ -@@ -596,6 +669,7 @@ au1xxx_dbdma_put_dest(u32 chanid, void * - */ - return nbytes; - } -+EXPORT_SYMBOL(_au1xxx_dbdma_put_dest); - - /* Get a destination buffer into the DMA ring. - * Normally used to get a full buffer from the ring during fifo -@@ -645,7 +719,7 @@ void - au1xxx_dbdma_stop(u32 chanid) - { - chan_tab_t *ctp; -- volatile au1x_dma_chan_t *cp; -+ au1x_dma_chan_t *cp; - int halt_timeout = 0; - - ctp = *((chan_tab_t **)chanid); -@@ -665,6 +739,7 @@ au1xxx_dbdma_stop(u32 chanid) - cp->ddma_stat |= (DDMA_STAT_DB | DDMA_STAT_V); - au_sync(); - } -+EXPORT_SYMBOL(au1xxx_dbdma_stop); - - /* Start using the current descriptor pointer. If the dbdma encounters - * a not valid descriptor, it will stop. In this case, we can just -@@ -674,17 +749,17 @@ void - au1xxx_dbdma_start(u32 chanid) - { - chan_tab_t *ctp; -- volatile au1x_dma_chan_t *cp; -+ au1x_dma_chan_t *cp; - - ctp = *((chan_tab_t **)chanid); -- - cp = ctp->chan_ptr; - cp->ddma_desptr = virt_to_phys(ctp->cur_ptr); - cp->ddma_cfg |= DDMA_CFG_EN; /* Enable channel */ - au_sync(); -- cp->ddma_dbell = 0xffffffff; /* Make it go */ -+ cp->ddma_dbell = 0; - au_sync(); - } -+EXPORT_SYMBOL(au1xxx_dbdma_start); - - void - au1xxx_dbdma_reset(u32 chanid) -@@ -703,15 +778,21 @@ au1xxx_dbdma_reset(u32 chanid) - - do { - dp->dscr_cmd0 &= ~DSCR_CMD0_V; -+ /* reset our SW status -- this is used to determine -+ * if a descriptor is in use by upper level SW. Since -+ * posting can reset 'V' bit. -+ */ -+ dp->sw_status = 0; - dp = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr)); - } while (dp != ctp->chan_desc_base); - } -+EXPORT_SYMBOL(au1xxx_dbdma_reset); - - u32 - au1xxx_get_dma_residue(u32 chanid) - { - chan_tab_t *ctp; -- volatile au1x_dma_chan_t *cp; -+ au1x_dma_chan_t *cp; - u32 rv; - - ctp = *((chan_tab_t **)chanid); -@@ -746,15 +827,16 @@ au1xxx_dbdma_chan_free(u32 chanid) - - kfree(ctp); - } -+EXPORT_SYMBOL(au1xxx_dbdma_chan_free); - - static void - dbdma_interrupt(int irq, void *dev_id, struct pt_regs *regs) - { -- u32 intstat; -+ u32 intstat, flags; - u32 chan_index; - chan_tab_t *ctp; - au1x_ddma_desc_t *dp; -- volatile au1x_dma_chan_t *cp; -+ au1x_dma_chan_t *cp; - - intstat = dbdma_gptr->ddma_intstat; - au_sync(); -@@ -773,18 +855,26 @@ dbdma_interrupt(int irq, void *dev_id, s - (ctp->chan_callback)(irq, ctp->chan_callparam, regs); - - ctp->cur_ptr = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr)); -- - } - --static void --au1xxx_dbdma_init(void) -+static void au1xxx_dbdma_init(void) - { -+ int irq_nr; -+ - dbdma_gptr->ddma_config = 0; - dbdma_gptr->ddma_throttle = 0; - dbdma_gptr->ddma_inten = 0xffff; - au_sync(); - -- if (request_irq(AU1550_DDMA_INT, dbdma_interrupt, SA_INTERRUPT, -+#if defined(CONFIG_SOC_AU1550) -+ irq_nr = AU1550_DDMA_INT; -+#elif defined(CONFIG_SOC_AU1200) -+ irq_nr = AU1200_DDMA_INT; -+#else -+ #error Unknown Au1x00 SOC -+#endif -+ -+ if (request_irq(irq_nr, dbdma_interrupt, SA_INTERRUPT, - "Au1xxx dbdma", (void *)dbdma_gptr)) - printk("Can't get 1550 dbdma irq"); - } -@@ -795,7 +885,8 @@ au1xxx_dbdma_dump(u32 chanid) - chan_tab_t *ctp; - au1x_ddma_desc_t *dp; - dbdev_tab_t *stp, *dtp; -- volatile au1x_dma_chan_t *cp; -+ au1x_dma_chan_t *cp; -+ u32 i = 0; - - ctp = *((chan_tab_t **)chanid); - stp = ctp->chan_src; -@@ -820,15 +911,64 @@ au1xxx_dbdma_dump(u32 chanid) - dp = ctp->chan_desc_base; - - do { -- printk("dp %08x, cmd0 %08x, cmd1 %08x\n", -- (u32)dp, dp->dscr_cmd0, dp->dscr_cmd1); -- printk("src0 %08x, src1 %08x, dest0 %08x\n", -- dp->dscr_source0, dp->dscr_source1, dp->dscr_dest0); -- printk("dest1 %08x, stat %08x, nxtptr %08x\n", -- dp->dscr_dest1, dp->dscr_stat, dp->dscr_nxtptr); -+ printk("Dp[%d]= %08x, cmd0 %08x, cmd1 %08x\n", -+ i++, (u32)dp, dp->dscr_cmd0, dp->dscr_cmd1); -+ printk("src0 %08x, src1 %08x, dest0 %08x, dest1 %08x\n", -+ dp->dscr_source0, dp->dscr_source1, dp->dscr_dest0, dp->dscr_dest1); -+ printk("stat %08x, nxtptr %08x\n", -+ dp->dscr_stat, dp->dscr_nxtptr); - dp = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr)); - } while (dp != ctp->chan_desc_base); - } - -+/* Put a descriptor into the DMA ring. -+ * This updates the source/destination pointers and byte count. -+ */ -+u32 -+au1xxx_dbdma_put_dscr(u32 chanid, au1x_ddma_desc_t *dscr ) -+{ -+ chan_tab_t *ctp; -+ au1x_ddma_desc_t *dp; -+ u32 nbytes=0; -+ -+ /* I guess we could check this to be within the -+ * range of the table...... -+ */ -+ ctp = *((chan_tab_t **)chanid); -+ -+ /* We should have multiple callers for a particular channel, -+ * an interrupt doesn't affect this pointer nor the descriptor, -+ * so no locking should be needed. -+ */ -+ dp = ctp->put_ptr; -+ -+ /* If the descriptor is valid, we are way ahead of the DMA -+ * engine, so just return an error condition. -+ */ -+ if (dp->dscr_cmd0 & DSCR_CMD0_V) -+ return 0; -+ -+ /* Load up buffer addresses and byte count. -+ */ -+ dp->dscr_dest0 = dscr->dscr_dest0; -+ dp->dscr_source0 = dscr->dscr_source0; -+ dp->dscr_dest1 = dscr->dscr_dest1; -+ dp->dscr_source1 = dscr->dscr_source1; -+ dp->dscr_cmd1 = dscr->dscr_cmd1; -+ nbytes = dscr->dscr_cmd1; -+ /* Allow the caller to specifiy if an interrupt is generated */ -+ dp->dscr_cmd0 &= ~DSCR_CMD0_IE; -+ dp->dscr_cmd0 |= dscr->dscr_cmd0 | DSCR_CMD0_V; -+ ctp->chan_ptr->ddma_dbell = 0; -+ -+ /* Get next descriptor pointer. -+ */ -+ ctp->put_ptr = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr)); -+ -+ /* return something not zero. -+ */ -+ return nbytes; -+} -+ - #endif /* defined(CONFIG_SOC_AU1550) || defined(CONFIG_SOC_AU1200) */ - ---- /dev/null -+++ b/arch/mips/au1000/common/gpio.c -@@ -0,0 +1,118 @@ -+/* -+ * 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 SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN -+ * NO EVENT SHALL THE AUTHOR 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. -+ * -+ * You should have received a copy of the GNU General Public License along -+ * with this program; if not, write to the Free Software Foundation, Inc., -+ * 675 Mass Ave, Cambridge, MA 02139, USA. -+ */ -+ -+#include <asm/au1000.h> -+#include <asm/au1xxx_gpio.h> -+ -+#define gpio1 sys -+#if !defined(CONFIG_SOC_AU1000) -+static AU1X00_GPIO2 * const gpio2 = (AU1X00_GPIO2 *)GPIO2_BASE; -+ -+#define GPIO2_OUTPUT_ENABLE_MASK 0x00010000 -+ -+int au1xxx_gpio2_read(int signal) -+{ -+ signal -= 200; -+/* gpio2->dir &= ~(0x01 << signal); //Set GPIO to input */ -+ return ((gpio2->pinstate >> signal) & 0x01); -+} -+ -+void au1xxx_gpio2_write(int signal, int value) -+{ -+ signal -= 200; -+ -+ gpio2->output = (GPIO2_OUTPUT_ENABLE_MASK << signal) | -+ (value << signal); -+} -+ -+void au1xxx_gpio2_tristate(int signal) -+{ -+ signal -= 200; -+ gpio2->dir &= ~(0x01 << signal); /* Set GPIO to input */ -+} -+#endif -+ -+int au1xxx_gpio1_read(int signal) -+{ -+/* gpio1->trioutclr |= (0x01 << signal); */ -+ return ((gpio1->pinstaterd >> signal) & 0x01); -+} -+ -+void au1xxx_gpio1_write(int signal, int value) -+{ -+ if(value) -+ gpio1->outputset = (0x01 << signal); -+ else -+ gpio1->outputclr = (0x01 << signal); /* Output a Zero */ -+} -+ -+void au1xxx_gpio1_tristate(int signal) -+{ -+ gpio1->trioutclr = (0x01 << signal); /* Tristate signal */ -+} -+ -+ -+int au1xxx_gpio_read(int signal) -+{ -+ if(signal >= 200) -+#if defined(CONFIG_SOC_AU1000) -+ return 0; -+#else -+ return au1xxx_gpio2_read(signal); -+#endif -+ else -+ return au1xxx_gpio1_read(signal); -+} -+ -+void au1xxx_gpio_write(int signal, int value) -+{ -+ if(signal >= 200) -+#if defined(CONFIG_SOC_AU1000) -+ ; -+#else -+ au1xxx_gpio2_write(signal, value); -+#endif -+ else -+ au1xxx_gpio1_write(signal, value); -+} -+ -+void au1xxx_gpio_tristate(int signal) -+{ -+ if(signal >= 200) -+#if defined(CONFIG_SOC_AU1000) -+ ; -+#else -+ au1xxx_gpio2_tristate(signal); -+#endif -+ else -+ au1xxx_gpio1_tristate(signal); -+} -+ -+void au1xxx_gpio1_set_inputs(void) -+{ -+ gpio1->pininputen = 0; -+} -+ -+EXPORT_SYMBOL(au1xxx_gpio1_set_inputs); -+EXPORT_SYMBOL(au1xxx_gpio_tristate); -+EXPORT_SYMBOL(au1xxx_gpio_write); -+EXPORT_SYMBOL(au1xxx_gpio_read); ---- a/arch/mips/au1000/common/irq.c -+++ b/arch/mips/au1000/common/irq.c -@@ -303,8 +303,30 @@ static struct hw_interrupt_type level_ir - }; - - #ifdef CONFIG_PM --void startup_match20_interrupt(void) -+void startup_match20_interrupt(void (*handler)(int, void *, struct pt_regs *)) - { -+ static struct irqaction action; -+ /* This is a big problem.... since we didn't use request_irq -+ when kernel/irq.c calls probe_irq_xxx this interrupt will -+ be probed for usage. This will end up disabling the device :( -+ -+ Give it a bogus "action" pointer -- this will keep it from -+ getting auto-probed! -+ -+ By setting the status to match that of request_irq() we -+ can avoid it. --cgray -+ */ -+ action.dev_id = handler; -+ action.flags = 0; -+ action.mask = 0; -+ action.name = "Au1xxx TOY"; -+ action.handler = handler; -+ action.next = NULL; -+ -+ irq_desc[AU1000_TOY_MATCH2_INT].action = &action; -+ irq_desc[AU1000_TOY_MATCH2_INT].status -+ &= ~(IRQ_DISABLED | IRQ_AUTODETECT | IRQ_WAITING | IRQ_INPROGRESS); -+ - local_enable_irq(AU1000_TOY_MATCH2_INT); - } - #endif -@@ -508,6 +530,7 @@ void intc0_req0_irqdispatch(struct pt_re - - if (!intc0_req0) return; - -+#ifdef AU1000_USB_DEV_REQ_INT - /* - * Because of the tight timing of SETUP token to reply - * transactions, the USB devices-side packet complete -@@ -518,6 +541,7 @@ void intc0_req0_irqdispatch(struct pt_re - do_IRQ(AU1000_USB_DEV_REQ_INT, regs); - return; - } -+#endif - - irq = au_ffs(intc0_req0) - 1; - intc0_req0 &= ~(1<<irq); -@@ -536,17 +560,7 @@ void intc0_req1_irqdispatch(struct pt_re - - irq = au_ffs(intc0_req1) - 1; - intc0_req1 &= ~(1<<irq); --#ifdef CONFIG_PM -- if (irq == AU1000_TOY_MATCH2_INT) { -- mask_and_ack_rise_edge_irq(irq); -- counter0_irq(irq, NULL, regs); -- local_enable_irq(irq); -- } -- else --#endif -- { -- do_IRQ(irq, regs); -- } -+ do_IRQ(irq, regs); - } - - ---- a/arch/mips/au1000/common/Makefile -+++ b/arch/mips/au1000/common/Makefile -@@ -19,9 +19,9 @@ O_TARGET := au1000.o - export-objs = prom.o clocks.o power.o usbdev.o - - obj-y := prom.o int-handler.o irq.o puts.o time.o reset.o cputable.o \ -- au1xxx_irqmap.o clocks.o power.o setup.o sleeper.o dma.o dbdma.o -+ au1xxx_irqmap.o clocks.o power.o setup.o sleeper.o dma.o dbdma.o gpio.o - --export-objs += dma.o dbdma.o -+export-objs += dma.o dbdma.o gpio.o - - obj-$(CONFIG_AU1X00_USB_DEVICE) += usbdev.o - obj-$(CONFIG_KGDB) += dbg_io.o ---- a/arch/mips/au1000/common/pci_fixup.c -+++ b/arch/mips/au1000/common/pci_fixup.c -@@ -75,9 +75,13 @@ void __init pcibios_fixup(void) - - #ifdef CONFIG_NONCOHERENT_IO - /* -- * Set the NC bit in controller for pre-AC silicon -+ * Set the NC bit in controller for Au1500 pre-AC silicon - */ -- au_writel( 1<<16 | au_readl(Au1500_PCI_CFG), Au1500_PCI_CFG); -+ u32 prid = read_c0_prid(); -+ if ( (prid & 0xFF000000) == 0x01000000 && prid < 0x01030202) { -+ au_writel( 1<<16 | au_readl(Au1500_PCI_CFG), Au1500_PCI_CFG); -+ printk("Non-coherent PCI accesses enabled\n"); -+ } - printk("Non-coherent PCI accesses enabled\n"); - #endif - ---- a/arch/mips/au1000/common/pci_ops.c -+++ b/arch/mips/au1000/common/pci_ops.c -@@ -162,6 +162,7 @@ unsigned long last_entryLo0, last_entryL - static int config_access(unsigned char access_type, struct pci_dev *dev, - unsigned char where, u32 * data) - { -+ int error = PCIBIOS_SUCCESSFUL; - #if defined( CONFIG_SOC_AU1500 ) || defined( CONFIG_SOC_AU1550 ) - unsigned char bus = dev->bus->number; - unsigned int dev_fn = dev->devfn; -@@ -170,7 +171,6 @@ static int config_access(unsigned char a - unsigned long offset, status; - unsigned long cfg_base; - unsigned long flags; -- int error = PCIBIOS_SUCCESSFUL; - unsigned long entryLo0, entryLo1; - - if (device > 19) { -@@ -205,9 +205,8 @@ static int config_access(unsigned char a - last_entryLo0 = last_entryLo1 = 0xffffffff; - } - -- /* Since the Au1xxx doesn't do the idsel timing exactly to spec, -- * many board vendors implement their own off-chip idsel, so call -- * it now. If it doesn't succeed, may as well bail out at this point. -+ /* Allow board vendors to implement their own off-chip idsel. -+ * If it doesn't succeed, may as well bail out at this point. - */ - if (board_pci_idsel) { - if (board_pci_idsel(device, 1) == 0) { -@@ -271,8 +270,11 @@ static int config_access(unsigned char a - } - - local_irq_restore(flags); -- return error; -+#else -+ /* Fake out Config space access with no responder */ -+ *data = 0xFFFFFFFF; - #endif -+ return error; - } - #endif - ---- a/arch/mips/au1000/common/power.c -+++ b/arch/mips/au1000/common/power.c -@@ -50,7 +50,6 @@ - - static void calibrate_delay(void); - --extern void set_au1x00_speed(unsigned int new_freq); - extern unsigned int get_au1x00_speed(void); - extern unsigned long get_au1x00_uart_baud_base(void); - extern void set_au1x00_uart_baud_base(unsigned long new_baud_base); -@@ -116,6 +115,7 @@ save_core_regs(void) - sleep_uart0_clkdiv = au_readl(UART0_ADDR + UART_CLK); - sleep_uart0_enable = au_readl(UART0_ADDR + UART_MOD_CNTRL); - -+#ifndef CONFIG_SOC_AU1200 - /* Shutdown USB host/device. - */ - sleep_usbhost_enable = au_readl(USB_HOST_CONFIG); -@@ -127,6 +127,7 @@ save_core_regs(void) - - sleep_usbdev_enable = au_readl(USBD_ENABLE); - au_writel(0, USBD_ENABLE); au_sync(); -+#endif - - /* Save interrupt controller state. - */ -@@ -212,14 +213,12 @@ void wakeup_from_suspend(void) - int au_sleep(void) - { - unsigned long wakeup, flags; -- extern void save_and_sleep(void); -+ extern unsigned int save_and_sleep(void); - - spin_lock_irqsave(&pm_lock,flags); - - save_core_regs(); - -- flush_cache_all(); -- - /** The code below is all system dependent and we should probably - ** have a function call out of here to set this up. You need - ** to configure the GPIO or timer interrupts that will bring -@@ -227,27 +226,26 @@ int au_sleep(void) - ** For testing, the TOY counter wakeup is useful. - **/ - --#if 0 -+#if 1 - au_writel(au_readl(SYS_PINSTATERD) & ~(1 << 11), SYS_PINSTATERD); - - /* gpio 6 can cause a wake up event */ - wakeup = au_readl(SYS_WAKEMSK); - wakeup &= ~(1 << 8); /* turn off match20 wakeup */ -- wakeup |= 1 << 6; /* turn on gpio 6 wakeup */ -+ wakeup = 1 << 5; /* turn on gpio 6 wakeup */ - #else -- /* For testing, allow match20 to wake us up. -- */ -+ /* For testing, allow match20 to wake us up. */ - #ifdef SLEEP_TEST_TIMEOUT - wakeup_counter0_set(sleep_ticks); - #endif - wakeup = 1 << 8; /* turn on match20 wakeup */ - wakeup = 0; - #endif -- au_writel(1, SYS_WAKESRC); /* clear cause */ -+ au_writel(0, SYS_WAKESRC); /* clear cause */ - au_sync(); - au_writel(wakeup, SYS_WAKEMSK); - au_sync(); -- -+ DPRINTK("Entering sleep!\n"); - save_and_sleep(); - - /* after a wakeup, the cpu vectors back to 0x1fc00000 so -@@ -255,6 +253,7 @@ int au_sleep(void) - */ - restore_core_regs(); - spin_unlock_irqrestore(&pm_lock, flags); -+ DPRINTK("Leaving sleep!\n"); - return 0; - } - -@@ -285,7 +284,6 @@ static int pm_do_sleep(ctl_table * ctl, - - if (retval) - return retval; -- - au_sleep(); - retval = pm_send_all(PM_RESUME, (void *) 0); - } -@@ -296,7 +294,6 @@ static int pm_do_suspend(ctl_table * ctl - void *buffer, size_t * len) - { - int retval = 0; -- void au1k_wait(void); - - if (!write) { - *len = 0; -@@ -305,119 +302,9 @@ static int pm_do_suspend(ctl_table * ctl - if (retval) - return retval; - suspend_mode = 1; -- au1k_wait(); -- retval = pm_send_all(PM_RESUME, (void *) 0); -- } -- return retval; --} - -- --static int pm_do_freq(ctl_table * ctl, int write, struct file *file, -- void *buffer, size_t * len) --{ -- int retval = 0, i; -- unsigned long val, pll; --#define TMPBUFLEN 64 --#define MAX_CPU_FREQ 396 -- char buf[TMPBUFLEN], *p; -- unsigned long flags, intc0_mask, intc1_mask; -- unsigned long old_baud_base, old_cpu_freq, baud_rate, old_clk, -- old_refresh; -- unsigned long new_baud_base, new_cpu_freq, new_clk, new_refresh; -- -- spin_lock_irqsave(&pm_lock, flags); -- if (!write) { -- *len = 0; -- } else { -- /* Parse the new frequency */ -- if (*len > TMPBUFLEN - 1) { -- spin_unlock_irqrestore(&pm_lock, flags); -- return -EFAULT; -- } -- if (copy_from_user(buf, buffer, *len)) { -- spin_unlock_irqrestore(&pm_lock, flags); -- return -EFAULT; -- } -- buf[*len] = 0; -- p = buf; -- val = simple_strtoul(p, &p, 0); -- if (val > MAX_CPU_FREQ) { -- spin_unlock_irqrestore(&pm_lock, flags); -- return -EFAULT; -- } -- -- pll = val / 12; -- if ((pll > 33) || (pll < 7)) { /* 396 MHz max, 84 MHz min */ -- /* revisit this for higher speed cpus */ -- spin_unlock_irqrestore(&pm_lock, flags); -- return -EFAULT; -- } -- -- old_baud_base = get_au1x00_uart_baud_base(); -- old_cpu_freq = get_au1x00_speed(); -- -- new_cpu_freq = pll * 12 * 1000000; -- new_baud_base = (new_cpu_freq / (2 * ((int)(au_readl(SYS_POWERCTRL)&0x03) + 2) * 16)); -- set_au1x00_speed(new_cpu_freq); -- set_au1x00_uart_baud_base(new_baud_base); -- -- old_refresh = au_readl(MEM_SDREFCFG) & 0x1ffffff; -- new_refresh = -- ((old_refresh * new_cpu_freq) / -- old_cpu_freq) | (au_readl(MEM_SDREFCFG) & ~0x1ffffff); -- -- au_writel(pll, SYS_CPUPLL); -- au_sync_delay(1); -- au_writel(new_refresh, MEM_SDREFCFG); -- au_sync_delay(1); -- -- for (i = 0; i < 4; i++) { -- if (au_readl -- (UART_BASE + UART_MOD_CNTRL + -- i * 0x00100000) == 3) { -- old_clk = -- au_readl(UART_BASE + UART_CLK + -- i * 0x00100000); -- // baud_rate = baud_base/clk -- baud_rate = old_baud_base / old_clk; -- /* we won't get an exact baud rate and the error -- * could be significant enough that our new -- * calculation will result in a clock that will -- * give us a baud rate that's too far off from -- * what we really want. -- */ -- if (baud_rate > 100000) -- baud_rate = 115200; -- else if (baud_rate > 50000) -- baud_rate = 57600; -- else if (baud_rate > 30000) -- baud_rate = 38400; -- else if (baud_rate > 17000) -- baud_rate = 19200; -- else -- (baud_rate = 9600); -- // new_clk = new_baud_base/baud_rate -- new_clk = new_baud_base / baud_rate; -- au_writel(new_clk, -- UART_BASE + UART_CLK + -- i * 0x00100000); -- au_sync_delay(10); -- } -- } -+ retval = pm_send_all(PM_RESUME, (void *) 0); - } -- -- -- /* We don't want _any_ interrupts other than -- * match20. Otherwise our calibrate_delay() -- * calculation will be off, potentially a lot. -- */ -- intc0_mask = save_local_and_disable(0); -- intc1_mask = save_local_and_disable(1); -- local_enable_irq(AU1000_TOY_MATCH2_INT); -- spin_unlock_irqrestore(&pm_lock, flags); -- calibrate_delay(); -- restore_local_and_enable(0, intc0_mask); -- restore_local_and_enable(1, intc1_mask); - return retval; - } - -@@ -425,7 +312,6 @@ static int pm_do_freq(ctl_table * ctl, i - static struct ctl_table pm_table[] = { - {ACPI_S1_SLP_TYP, "suspend", NULL, 0, 0600, NULL, &pm_do_suspend}, - {ACPI_SLEEP, "sleep", NULL, 0, 0600, NULL, &pm_do_sleep}, -- {CTL_ACPI, "freq", NULL, 0, 0600, NULL, &pm_do_freq}, - {0} - }; - ---- a/arch/mips/au1000/common/reset.c -+++ b/arch/mips/au1000/common/reset.c -@@ -37,8 +37,6 @@ - #include <asm/system.h> - #include <asm/au1000.h> - --extern int au_sleep(void); -- - void au1000_restart(char *command) - { - /* Set all integrated peripherals to disabled states */ -@@ -144,6 +142,26 @@ void au1000_restart(char *command) - au_writel(0x00, 0xb1900064); /* sys_auxpll */ - au_writel(0x00, 0xb1900100); /* sys_pininputen */ - break; -+ case 0x04000000: /* Au1200 */ -+ au_writel(0x00, 0xb400300c); /* ddma */ -+ au_writel(0x00, 0xb1a00004); /* psc 0 */ -+ au_writel(0x00, 0xb1b00004); /* psc 1 */ -+ au_writel(0x00d02000, 0xb4020004); /* ehci, ohci, udc, otg */ -+ au_writel(0x00, 0xb5000004); /* lcd */ -+ au_writel(0x00, 0xb060000c); /* sd0 */ -+ au_writel(0x00, 0xb068000c); /* sd1 */ -+ au_writel(0x00, 0xb1100100); /* swcnt */ -+ au_writel(0x00, 0xb0300000); /* aes */ -+ au_writel(0x00, 0xb4004000); /* cim */ -+ au_writel(0x00, 0xb1100100); /* uart0_enable */ -+ au_writel(0x00, 0xb1200100); /* uart1_enable */ -+ au_writel(0x00, 0xb1900020); /* sys_freqctrl0 */ -+ au_writel(0x00, 0xb1900024); /* sys_freqctrl1 */ -+ au_writel(0x00, 0xb1900028); /* sys_clksrc */ -+ au_writel(0x10, 0xb1900060); /* sys_cpupll */ -+ au_writel(0x00, 0xb1900064); /* sys_auxpll */ -+ au_writel(0x00, 0xb1900100); /* sys_pininputen */ -+ break; - - default: - break; -@@ -163,32 +181,23 @@ void au1000_restart(char *command) - - void au1000_halt(void) - { --#if defined(CONFIG_MIPS_PB1550) -- /* power off system */ -- printk("\n** Powering off Pb1550\n"); -- au_writew(au_readw(0xAF00001C) | (3<<14), 0xAF00001C); -- au_sync(); -- while(1); /* should not get here */ --#endif -- printk(KERN_NOTICE "\n** You can safely turn off the power\n"); --#ifdef CONFIG_MIPS_MIRAGE -- au_writel((1 << 26) | (1 << 10), GPIO2_OUTPUT); --#endif --#ifdef CONFIG_PM -- au_sleep(); -- -- /* should not get here */ -- printk(KERN_ERR "Unable to put cpu in sleep mode\n"); -- while(1); --#else -- while (1) -+ /* Use WAIT in a low-power infinite spin loop */ -+ while (1) { - __asm__(".set\tmips3\n\t" - "wait\n\t" - ".set\tmips0"); --#endif -+ } - } - - void au1000_power_off(void) - { -+ extern void board_power_off (void); -+ -+ printk(KERN_NOTICE "\n** You can safely turn off the power\n"); -+ -+ /* Give board a chance to power-off */ -+ board_power_off(); -+ -+ /* If board can't power-off, spin forever */ - au1000_halt(); - } ---- a/arch/mips/au1000/common/setup.c -+++ b/arch/mips/au1000/common/setup.c -@@ -174,6 +174,40 @@ void __init au1x00_setup(void) - initrd_end = (unsigned long)&__rd_end; - #endif - -+#if defined(CONFIG_SOC_AU1200) -+#ifdef CONFIG_USB_EHCI_HCD -+ if ((argptr = strstr(argptr, "usb_ehci=")) == NULL) { -+ char usb_args[80]; -+ argptr = prom_getcmdline(); -+ memset(usb_args, 0, sizeof(usb_args)); -+ sprintf(usb_args, " usb_ehci=base:0x%x,len:0x%x,irq:%d", -+ USB_EHCI_BASE, USB_EHCI_LEN, AU1000_USB_HOST_INT); -+ strcat(argptr, usb_args); -+ } -+#ifdef CONFIG_USB_AMD5536UDC -+ /* enable EHC + OHC + UDC clocks, memory and bus mastering */ -+/* au_writel( 0x00DF207F, USB_MSR_BASE + 4); */ -+ au_writel( 0xC0DF207F, USB_MSR_BASE + 4); // incl. prefetch -+#else -+ /* enable EHC + OHC clocks, memory and bus mastering */ -+/* au_writel( 0x00DB200F, USB_MSR_BASE + 4); */ -+ au_writel( 0xC0DB200F, USB_MSR_BASE + 4); /* incl. prefetch */ -+#endif -+ udelay(1000); -+ -+#else /* CONFIG_USB_EHCI_HCD */ -+ -+#ifdef CONFIG_USB_AMD5536UDC -+#ifndef CONFIG_USB_OHCI -+ /* enable UDC clocks, memory and bus mastering */ -+/* au_writel( 0x00DC2070, USB_MSR_BASE + 4); */ -+ au_writel( 0xC0DC2070, USB_MSR_BASE + 4); // incl. prefetch -+ udelay(1000); -+#endif -+#endif -+#endif /* CONFIG_USB_EHCI_HCD */ -+#endif /* CONFIG_SOC_AU1200 */ -+ - #if defined (CONFIG_USB_OHCI) || defined (CONFIG_AU1X00_USB_DEVICE) - #ifdef CONFIG_USB_OHCI - if ((argptr = strstr(argptr, "usb_ohci=")) == NULL) { -@@ -187,19 +221,38 @@ void __init au1x00_setup(void) - #endif - - #ifdef CONFIG_USB_OHCI -- // enable host controller and wait for reset done -+#if defined(CONFIG_SOC_AU1200) -+#ifndef CONFIG_USB_EHCI_HCD -+#ifdef CONFIG_USB_AMD5536UDC -+ /* enable OHC + UDC clocks, memory and bus mastering */ -+/* au_writel( 0x00DD2073, USB_MSR_BASE + 4); */ -+ au_writel( 0xC0DD2073, USB_MSR_BASE + 4); // incl. prefetch -+#else -+ /* enable OHC clocks, memory and bus mastering */ -+ au_writel( 0x00D12003, USB_MSR_BASE + 4); -+#endif -+ udelay(1000); -+printk("DEBUG: Reading Au1200 USB2 reg 0x%x\n", au_readl(USB_MSR_BASE + 4)); -+#endif -+#else -+ /* Au1000, Au1500, Au1100, Au1550 */ -+ /* enable host controller and wait for reset done */ - au_writel(0x08, USB_HOST_CONFIG); - udelay(1000); - au_writel(0x0E, USB_HOST_CONFIG); - udelay(1000); -- au_readl(USB_HOST_CONFIG); // throw away first read -+ au_readl(USB_HOST_CONFIG); /* throw away first read */ - while (!(au_readl(USB_HOST_CONFIG) & 0x10)) - au_readl(USB_HOST_CONFIG); -+#endif /* CONFIG_SOC_AU1200 */ - #endif --#endif // defined (CONFIG_USB_OHCI) || defined (CONFIG_AU1X00_USB_DEVICE) -+#else -+ -+#endif /* defined (CONFIG_USB_OHCI) || defined (CONFIG_AU1X00_USB_DEVICE) */ -+ - - #ifdef CONFIG_FB -- // Needed if PCI video card in use -+ /* Needed if PCI video card in use */ - conswitchp = &dummy_con; - #endif - -@@ -209,8 +262,7 @@ void __init au1x00_setup(void) - #endif - - #ifdef CONFIG_BLK_DEV_IDE -- /* Board setup takes precedence for unique devices. -- */ -+ /* Board setup takes precedence for unique devices. */ - if ((ide_ops == NULL) || (ide_ops == &no_ide_ops)) - ide_ops = &std_ide_ops; - #endif ---- a/arch/mips/au1000/common/sleeper.S -+++ b/arch/mips/au1000/common/sleeper.S -@@ -15,17 +15,48 @@ - #include <asm/addrspace.h> - #include <asm/regdef.h> - #include <asm/stackframe.h> -+#include <asm/au1000.h> -+ -+/* -+ * Note: This file is *not* conditional on CONFIG_PM since Alchemy sleep -+ * need not be tied to any particular power management scheme. -+ */ -+ -+ .extern ___flush_cache_all - - .text -- .set macro -- .set noat - .align 5 - --/* Save all of the processor general registers and go to sleep. -- * A wakeup condition will get us back here to restore the registers. -+/* -+ * Save the processor general registers and go to sleep. A wakeup -+ * condition will get us back here to restore the registers. - */ --LEAF(save_and_sleep) - -+/* still need to fix alignment issues here */ -+save_and_sleep_frmsz = 48 -+NESTED(save_and_sleep, save_and_sleep_frmsz, ra) -+ .set noreorder -+ .set nomacro -+ .set noat -+ subu sp, save_and_sleep_frmsz -+ sw ra, save_and_sleep_frmsz-4(sp) -+ sw s0, save_and_sleep_frmsz-8(sp) -+ sw s1, save_and_sleep_frmsz-12(sp) -+ sw s2, save_and_sleep_frmsz-16(sp) -+ sw s3, save_and_sleep_frmsz-20(sp) -+ sw s4, save_and_sleep_frmsz-24(sp) -+ sw s5, save_and_sleep_frmsz-28(sp) -+ sw s6, save_and_sleep_frmsz-32(sp) -+ sw s7, save_and_sleep_frmsz-36(sp) -+ sw s8, save_and_sleep_frmsz-40(sp) -+ sw gp, save_and_sleep_frmsz-44(sp) -+ -+ /* We only need to save the registers that the calling function -+ * hasn't saved for us. 0 is always zero. 8 - 15, 24 and 25 are -+ * temporaries and can be used without saving. 26 and 27 are reserved -+ * for interrupt/trap handling and expected to change. 29 is the -+ * stack pointer which is handled as a special case here. -+ */ - subu sp, PT_SIZE - sw $1, PT_R1(sp) - sw $2, PT_R2(sp) -@@ -34,14 +65,6 @@ LEAF(save_and_sleep) - sw $5, PT_R5(sp) - sw $6, PT_R6(sp) - sw $7, PT_R7(sp) -- sw $8, PT_R8(sp) -- sw $9, PT_R9(sp) -- sw $10, PT_R10(sp) -- sw $11, PT_R11(sp) -- sw $12, PT_R12(sp) -- sw $13, PT_R13(sp) -- sw $14, PT_R14(sp) -- sw $15, PT_R15(sp) - sw $16, PT_R16(sp) - sw $17, PT_R17(sp) - sw $18, PT_R18(sp) -@@ -50,32 +73,47 @@ LEAF(save_and_sleep) - sw $21, PT_R21(sp) - sw $22, PT_R22(sp) - sw $23, PT_R23(sp) -- sw $24, PT_R24(sp) -- sw $25, PT_R25(sp) -- sw $26, PT_R26(sp) -- sw $27, PT_R27(sp) - sw $28, PT_R28(sp) -- sw $29, PT_R29(sp) - sw $30, PT_R30(sp) - sw $31, PT_R31(sp) -+#define PT_C0STATUS PT_LO -+#define PT_CONTEXT PT_HI -+#define PT_PAGEMASK PT_EPC -+#define PT_CONFIG PT_BVADDR - mfc0 k0, CP0_STATUS -- sw k0, 0x20(sp) -+ sw k0, PT_C0STATUS(sp) // 0x20 - mfc0 k0, CP0_CONTEXT -- sw k0, 0x1c(sp) -+ sw k0, PT_CONTEXT(sp) // 0x1c - mfc0 k0, CP0_PAGEMASK -- sw k0, 0x18(sp) -+ sw k0, PT_PAGEMASK(sp) // 0x18 - mfc0 k0, CP0_CONFIG -- sw k0, 0x14(sp) -+ sw k0, PT_CONFIG(sp) // 0x14 -+ -+ .set macro -+ .set at -+ -+ li t0, SYS_SLPPWR -+ sw zero, 0(t0) /* Get the processor ready to sleep */ -+ sync - - /* Now set up the scratch registers so the boot rom will - * return to this point upon wakeup. -+ * sys_scratch0 : SP -+ * sys_scratch1 : RA -+ */ -+ li t0, SYS_SCRATCH0 -+ li t1, SYS_SCRATCH1 -+ sw sp, 0(t0) -+ la k0, resume_from_sleep -+ sw k0, 0(t1) -+ -+/* -+ * Flush DCACHE to make sure context is in memory - */ -- la k0, 1f -- lui k1, 0xb190 -- ori k1, 0x18 -- sw sp, 0(k1) -- ori k1, 0x1c -- sw k0, 0(k1) -+ la t1,___flush_cache_all /* _flush_cache_all is a function pointer */ -+ lw t0,0(t1) -+ jal t0 -+ nop - - /* Put SDRAM into self refresh. Preload instructions into cache, - * issue a precharge, then auto refresh, then sleep commands to it. -@@ -88,30 +126,65 @@ LEAF(save_and_sleep) - cache 0x14, 96(t0) - .set mips0 - -+ /* Put SDRAM to sleep */ - sdsleep: -- lui k0, 0xb400 -- sw zero, 0x001c(k0) /* Precharge */ -- sw zero, 0x0020(k0) /* Auto refresh */ -- sw zero, 0x0030(k0) /* SDRAM sleep */ -+ li a0, MEM_PHYS_ADDR -+ or a0, a0, 0xA0000000 -+#if defined(CONFIG_SOC_AU1000) || defined(CONFIG_SOC_AU1100) || defined(CONFIG_SOC_AU1500) -+ lw k0, MEM_SDMODE0(a0) -+ sw zero, MEM_SDPRECMD(a0) /* Precharge */ -+ sw zero, MEM_SDAUTOREF(a0) /* Auto Refresh */ -+ sw zero, MEM_SDSLEEP(a0) /* Sleep */ - sync -- -- lui k1, 0xb190 -- sw zero, 0x0078(k1) /* get ready to sleep */ -+#endif -+#if defined(CONFIG_SOC_AU1550) || defined(CONFIG_SOC_AU1200) -+ sw zero, MEM_SDPRECMD(a0) /* Precharge */ -+ sw zero, MEM_SDSREF(a0) -+ -+ #lw t0, MEM_SDSTAT(a0) -+ #and t0, t0, 0x01000000 -+ li t0, 0x01000000 -+refresh_not_set: -+ lw t1, MEM_SDSTAT(a0) -+ and t2, t1, t0 -+ beq zero, t2, refresh_not_set -+ nop -+ -+ li t0, ~0x30000000 -+ lw t1, MEM_SDCONFIGA(a0) -+ and t1, t0, t1 -+ sw t1, MEM_SDCONFIGA(a0) - sync -- sw zero, 0x007c(k1) /* Put processor to sleep */ -+#endif -+ -+ li t0, SYS_SLEEP -+ sw zero, 0(t0) /* Put processor to sleep */ - sync -+ nop -+ nop -+ nop -+ nop -+ nop -+ nop -+ nop -+ nop -+ - - /* This is where we return upon wakeup. - * Reload all of the registers and return. - */ --1: nop -- lw k0, 0x20(sp) -+resume_from_sleep: -+ nop -+ .set nomacro -+ .set noat -+ -+ lw k0, PT_C0STATUS(sp) // 0x20 - mtc0 k0, CP0_STATUS -- lw k0, 0x1c(sp) -+ lw k0, PT_CONTEXT(sp) // 0x1c - mtc0 k0, CP0_CONTEXT -- lw k0, 0x18(sp) -+ lw k0, PT_PAGEMASK(sp) // 0x18 - mtc0 k0, CP0_PAGEMASK -- lw k0, 0x14(sp) -+ lw k0, PT_CONFIG(sp) // 0x14 - mtc0 k0, CP0_CONFIG - lw $1, PT_R1(sp) - lw $2, PT_R2(sp) -@@ -120,14 +193,6 @@ sdsleep: - lw $5, PT_R5(sp) - lw $6, PT_R6(sp) - lw $7, PT_R7(sp) -- lw $8, PT_R8(sp) -- lw $9, PT_R9(sp) -- lw $10, PT_R10(sp) -- lw $11, PT_R11(sp) -- lw $12, PT_R12(sp) -- lw $13, PT_R13(sp) -- lw $14, PT_R14(sp) -- lw $15, PT_R15(sp) - lw $16, PT_R16(sp) - lw $17, PT_R17(sp) - lw $18, PT_R18(sp) -@@ -136,15 +201,36 @@ sdsleep: - lw $21, PT_R21(sp) - lw $22, PT_R22(sp) - lw $23, PT_R23(sp) -- lw $24, PT_R24(sp) -- lw $25, PT_R25(sp) -- lw $26, PT_R26(sp) -- lw $27, PT_R27(sp) - lw $28, PT_R28(sp) -- lw $29, PT_R29(sp) - lw $30, PT_R30(sp) - lw $31, PT_R31(sp) -+ -+ .set macro -+ .set at -+ -+ /* clear the wake source, but save it as the return value of the function */ -+ li t0, SYS_WAKESRC -+ lw v0, 0(t0) -+ sw v0, PT_R2(sp) -+ sw zero, 0(t0) -+ - addiu sp, PT_SIZE - -+ lw gp, save_and_sleep_frmsz-44(sp) -+ lw s8, save_and_sleep_frmsz-40(sp) -+ lw s7, save_and_sleep_frmsz-36(sp) -+ lw s6, save_and_sleep_frmsz-32(sp) -+ lw s5, save_and_sleep_frmsz-28(sp) -+ lw s4, save_and_sleep_frmsz-24(sp) -+ lw s3, save_and_sleep_frmsz-20(sp) -+ lw s2, save_and_sleep_frmsz-16(sp) -+ lw s1, save_and_sleep_frmsz-12(sp) -+ lw s0, save_and_sleep_frmsz-8(sp) -+ lw ra, save_and_sleep_frmsz-4(sp) -+ -+ addu sp, save_and_sleep_frmsz - jr ra -+ nop -+ .set reorder - END(save_and_sleep) -+ ---- a/arch/mips/au1000/common/time.c -+++ b/arch/mips/au1000/common/time.c -@@ -50,7 +50,6 @@ - #include <linux/mc146818rtc.h> - #include <linux/timex.h> - --extern void startup_match20_interrupt(void); - extern void do_softirq(void); - extern volatile unsigned long wall_jiffies; - unsigned long missed_heart_beats = 0; -@@ -59,14 +58,14 @@ static unsigned long r4k_offset; /* Amou - static unsigned long r4k_cur; /* What counter should be at next timer irq */ - extern rwlock_t xtime_lock; - int no_au1xxx_32khz; --void (*au1k_wait_ptr)(void); -+extern int allow_au1k_wait; /* default off for CP0 Counter */ - - /* Cycle counter value at the previous timer interrupt.. */ - static unsigned int timerhi = 0, timerlo = 0; - - #ifdef CONFIG_PM - #define MATCH20_INC 328 --extern void startup_match20_interrupt(void); -+extern void startup_match20_interrupt(void (*handler)(int, void *, struct pt_regs *)); - static unsigned long last_pc0, last_match20; - #endif - -@@ -385,7 +384,6 @@ void __init au1xxx_timer_setup(void) - { - unsigned int est_freq; - extern unsigned long (*do_gettimeoffset)(void); -- extern void au1k_wait(void); - - printk("calculating r4koff... "); - r4k_offset = cal_r4koff(); -@@ -437,9 +435,6 @@ void __init au1xxx_timer_setup(void) - au_writel(0, SYS_TOYWRITE); - while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C0S); - -- au_writel(au_readl(SYS_WAKEMSK) | (1<<8), SYS_WAKEMSK); -- au_writel(~0, SYS_WAKESRC); -- au_sync(); - while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M20); - - /* setup match20 to interrupt once every 10ms */ -@@ -447,13 +442,13 @@ void __init au1xxx_timer_setup(void) - au_writel(last_match20 + MATCH20_INC, SYS_TOYMATCH2); - au_sync(); - while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M20); -- startup_match20_interrupt(); -+ startup_match20_interrupt(counter0_irq); - - do_gettimeoffset = do_fast_pm_gettimeoffset; - - /* We can use the real 'wait' instruction. - */ -- au1k_wait_ptr = au1k_wait; -+ allow_au1k_wait = 1; - } - - #else ---- a/arch/mips/au1000/db1x00/board_setup.c -+++ b/arch/mips/au1000/db1x00/board_setup.c -@@ -46,10 +46,22 @@ - #include <asm/au1000.h> - #include <asm/db1x00.h> - --extern struct rtc_ops no_rtc_ops; -+#if defined(CONFIG_BLK_DEV_IDE_AU1XXX) && defined(CONFIG_MIPS_DB1550) -+#include <asm/au1xxx_dbdma.h> -+extern struct ide_ops *ide_ops; -+extern struct ide_ops au1xxx_ide_ops; -+extern u32 au1xxx_ide_virtbase; -+extern u64 au1xxx_ide_physbase; -+extern int au1xxx_ide_irq; -+ -+/* Ddma */ -+chan_tab_t *ide_read_ch, *ide_write_ch; -+u32 au1xxx_ide_ddma_enable = 0, switch4ddma = 1; // PIO+ddma -+ -+dbdev_tab_t new_dbdev_tab_element = { DSCR_CMD0_THROTTLE, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 }; -+#endif /* end CONFIG_BLK_DEV_IDE_AU1XXX */ - --/* not correct for db1550 */ --static BCSR * const bcsr = (BCSR *)0xAE000000; -+extern struct rtc_ops no_rtc_ops; - - void board_reset (void) - { -@@ -57,6 +69,13 @@ void board_reset (void) - au_writel(0x00000000, 0xAE00001C); - } - -+void board_power_off (void) -+{ -+#ifdef CONFIG_MIPS_MIRAGE -+ au_writel((1 << 26) | (1 << 10), GPIO2_OUTPUT); -+#endif -+} -+ - void __init board_setup(void) - { - u32 pin_func; -@@ -108,8 +127,42 @@ void __init board_setup(void) - au_writel(0x02000200, GPIO2_OUTPUT); - #endif - -+#if defined(CONFIG_AU1XXX_SMC91111) -+#define CPLD_CONTROL (0xAF00000C) -+ { -+ extern uint32_t au1xxx_smc91111_base; -+ extern unsigned int au1xxx_smc91111_irq; -+ extern int au1xxx_smc91111_nowait; -+ -+ au1xxx_smc91111_base = 0xAC000300; -+ au1xxx_smc91111_irq = AU1000_GPIO_8; -+ au1xxx_smc91111_nowait = 1; -+ -+ /* set up the Static Bus timing - only 396Mhz */ -+ bcsr->resets |= 0x7; -+ au_writel(0x00010003, MEM_STCFG0); -+ au_writel(0x000c00c0, MEM_STCFG2); -+ au_writel(0x85E1900D, MEM_STTIME2); -+ } -+#endif /* end CONFIG_SMC91111 */ - au_sync(); - -+#if defined(CONFIG_BLK_DEV_IDE_AU1XXX) && defined(CONFIG_MIPS_DB1550) -+ /* -+ * Iniz IDE parameters -+ */ -+ ide_ops = &au1xxx_ide_ops; -+ au1xxx_ide_irq = DAUGHTER_CARD_IRQ; -+ au1xxx_ide_physbase = AU1XXX_ATA_PHYS_ADDR; -+ au1xxx_ide_virtbase = KSEG1ADDR(AU1XXX_ATA_PHYS_ADDR); -+ -+ /* -+ * change PIO or PIO+Ddma -+ * check the GPIO-6 pin condition. db1550:s6_dot -+ */ -+ switch4ddma = (au_readl(SYS_PINSTATERD) & (1 << 6)) ? 1 : 0; -+#endif -+ - #ifdef CONFIG_MIPS_DB1000 - printk("AMD Alchemy Au1000/Db1000 Board\n"); - #endif ---- a/arch/mips/au1000/db1x00/irqmap.c -+++ b/arch/mips/au1000/db1x00/irqmap.c -@@ -53,6 +53,7 @@ au1xxx_irq_map_t au1xxx_irq_map[] = { - #ifdef CONFIG_MIPS_DB1550 - { AU1000_GPIO_3, INTC_INT_LOW_LEVEL, 0 }, // PCMCIA Card 0 IRQ# - { AU1000_GPIO_5, INTC_INT_LOW_LEVEL, 0 }, // PCMCIA Card 1 IRQ# -+ { AU1000_GPIO_8, INTC_INT_LOW_LEVEL, 0 }, // Daughtercard IRQ# - #else - { AU1000_GPIO_0, INTC_INT_LOW_LEVEL, 0 }, // PCMCIA Card 0 Fully_Interted# - { AU1000_GPIO_1, INTC_INT_LOW_LEVEL, 0 }, // PCMCIA Card 0 STSCHG# ---- a/arch/mips/au1000/db1x00/Makefile -+++ b/arch/mips/au1000/db1x00/Makefile -@@ -17,4 +17,11 @@ O_TARGET := db1x00.o - obj-y := init.o board_setup.o irqmap.o - obj-$(CONFIG_WM97XX_COMODULE) += mirage_ts.o - -+ifdef CONFIG_MIPS_DB1100 -+ifdef CONFIG_MMC -+obj-y += mmc_support.o -+export-objs += mmc_support.o -+endif -+endif -+ - include $(TOPDIR)/Rules.make ---- /dev/null -+++ b/arch/mips/au1000/db1x00/mmc_support.c -@@ -0,0 +1,126 @@ -+/* -+ * BRIEF MODULE DESCRIPTION -+ * -+ * MMC support routines for DB1100. -+ * -+ * -+ * Copyright (c) 2003-2004 Embedded Edge, LLC. -+ * Author: Embedded Edge, LLC. -+ * Contact: dan@embeddededge.com -+ * -+ * This program is free software; you can redistribute it and/or modify it -+ * under the terms of the GNU General Public License as published by the -+ * Free Software Foundation; either version 2 of the License, or (at your -+ * option) any later version. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN -+ * NO EVENT SHALL THE AUTHOR 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. -+ * -+ * You should have received a copy of the GNU General Public License along -+ * with this program; if not, write to the Free Software Foundation, Inc., -+ * 675 Mass Ave, Cambridge, MA 02139, USA. -+ * -+ */ -+ -+ -+#include <linux/config.h> -+#include <linux/kernel.h> -+#include <linux/module.h> -+#include <linux/init.h> -+ -+#include <asm/irq.h> -+#include <asm/au1000.h> -+#include <asm/au1100_mmc.h> -+#include <asm/db1x00.h> -+ -+ -+/* SD/MMC controller support functions */ -+ -+/* -+ * Detect card. -+ */ -+void mmc_card_inserted(int _n_, int *_res_) -+{ -+ u32 gpios = au_readl(SYS_PINSTATERD); -+ u32 emptybit = (_n_) ? (1<<20) : (1<<19); -+ *_res_ = ((gpios & emptybit) == 0); -+} -+ -+/* -+ * Check card write protection. -+ */ -+void mmc_card_writable(int _n_, int *_res_) -+{ -+ BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR; -+ unsigned long mmc_wp, board_specific; -+ -+ if (_n_) { -+ mmc_wp = BCSR_BOARD_SD1_WP; -+ } else { -+ mmc_wp = BCSR_BOARD_SD0_WP; -+ } -+ -+ board_specific = au_readl((unsigned long)(&bcsr->specific)); -+ -+ if (!(board_specific & mmc_wp)) {/* low means card writable */ -+ *_res_ = 1; -+ } else { -+ *_res_ = 0; -+ } -+} -+ -+/* -+ * Apply power to card slot. -+ */ -+void mmc_power_on(int _n_) -+{ -+ BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR; -+ unsigned long mmc_pwr, board_specific; -+ -+ if (_n_) { -+ mmc_pwr = BCSR_BOARD_SD1_PWR; -+ } else { -+ mmc_pwr = BCSR_BOARD_SD0_PWR; -+ } -+ -+ board_specific = au_readl((unsigned long)(&bcsr->specific)); -+ board_specific |= mmc_pwr; -+ -+ au_writel(board_specific, (int)(&bcsr->specific)); -+ au_sync_delay(1); -+} -+ -+/* -+ * Remove power from card slot. -+ */ -+void mmc_power_off(int _n_) -+{ -+ BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR; -+ unsigned long mmc_pwr, board_specific; -+ -+ if (_n_) { -+ mmc_pwr = BCSR_BOARD_SD1_PWR; -+ } else { -+ mmc_pwr = BCSR_BOARD_SD0_PWR; -+ } -+ -+ board_specific = au_readl((unsigned long)(&bcsr->specific)); -+ board_specific &= ~mmc_pwr; -+ -+ au_writel(board_specific, (int)(&bcsr->specific)); -+ au_sync_delay(1); -+} -+ -+EXPORT_SYMBOL(mmc_card_inserted); -+EXPORT_SYMBOL(mmc_card_writable); -+EXPORT_SYMBOL(mmc_power_on); -+EXPORT_SYMBOL(mmc_power_off); -+ ---- /dev/null -+++ b/arch/mips/au1000/ficmmp/au1200_ibutton.c -@@ -0,0 +1,270 @@ -+/* ---------------------------------------------------------------------- -+ * mtwilson_keys.c -+ * -+ * Copyright (C) 2003 Intrinsyc Software Inc. -+ * -+ * Intel Personal Media Player buttons -+ * -+ * 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. -+ * -+ * May 02, 2003 : Initial version [FB] -+ * -+ ------------------------------------------------------------------------*/ -+ -+#include <linux/config.h> -+#include <linux/module.h> -+#include <linux/kernel.h> -+#include <linux/init.h> -+#include <linux/fs.h> -+#include <linux/sched.h> -+#include <linux/miscdevice.h> -+#include <linux/errno.h> -+#include <linux/poll.h> -+#include <linux/delay.h> -+#include <linux/input.h> -+ -+#include <asm/au1000.h> -+#include <asm/uaccess.h> -+#include <asm/au1xxx_gpio.h> -+#include <asm/irq.h> -+#include <asm/keyboard.h> -+#include <linux/time.h> -+ -+#define DRIVER_VERSION "V1.0" -+#define DRIVER_AUTHOR "FIC" -+#define DRIVER_DESC "FIC Travis Media Player Button Driver" -+#define DRIVER_NAME "Au1200Button" -+ -+#define BUTTON_MAIN (1<<1) -+#define BUTTON_SELECT (1<<6) -+#define BUTTON_GUIDE (1<<12) -+#define BUTTON_DOWN (1<<17) -+#define BUTTON_LEFT (1<<19) -+#define BUTTON_RIGHT (1<<26) -+#define BUTTON_UP (1<<28) -+ -+#define BUTTON_MASK (\ -+ BUTTON_MAIN \ -+ | BUTTON_SELECT \ -+ | BUTTON_GUIDE \ -+ | BUTTON_DOWN \ -+ | BUTTON_LEFT \ -+ | BUTTON_RIGHT \ -+ | BUTTON_UP \ -+ ) -+ -+#define BUTTON_INVERT (\ -+ BUTTON_MAIN \ -+ | 0 \ -+ | BUTTON_GUIDE \ -+ | 0 \ -+ | 0 \ -+ | 0 \ -+ | 0 \ -+ ) -+ -+char button_map[32]={0,KEY_S,0,0,0,0,KEY_ENTER,0,0,0,0,0,KEY_G,0,0,0,0,KEY_DOWN,0,KEY_LEFT,0,0,0,0,0,0,KEY_RIGHT,0,KEY_UP,0,0,0}; -+//char button_map[32]={0,0,0,0,0,0,KEY_ENTER,0,0,0,0,0,KEY_G,0,0,0,0,KEY_DOWN,0,KEY_LEFT,0,0,0,0,0,0,KEY_RIGHT,0,KEY_UP,0,0,0}; -+ -+//char button_map[32]={0,KEY_TAB,0,0,0,0,KEY_M,0,0,0,0,0,KEY_S,0,0,0,0,KEY_DOWN,0,KEY_LEFT,0,0,0,0,0,0,KEY_RIGHT,0,KEY_UP,0,0,0}; -+//char button_map[32]={0,0,0,0,0,0,KEY_M,0,0,0,0,0,KEY_S,0,0,0,0,KEY_DOWN,0,KEY_LEFT,0,0,0,0,0,0,KEY_RIGHT,0,KEY_UP,0,0,0}; -+ -+#define BUTTON_COUNT (sizeof (button_map) / sizeof (button_map[0])) -+ -+struct input_dev dev; -+struct timeval cur_tv; -+ -+static unsigned int old_tv_usec = 0; -+ -+static unsigned int read_button_state(void) -+{ -+ unsigned int state; -+ -+ state = au_readl(SYS_PINSTATERD) & BUTTON_MASK; /* get gpio status */ -+ -+ state ^= BUTTON_INVERT; /* invert main & guide button */ -+ -+ /* printk("au1200_ibutton.c: button state [0x%X]\r\n",state); */ -+ return state; -+} -+ -+//This function returns 0 if the allowed microseconds have elapsed since the last call to ths function, otherwise it returns 1 to indicate a bounce condition -+static unsigned int bounce() -+{ -+ -+ unsigned int elapsed_time; -+ -+ do_gettimeofday (&cur_tv); -+ -+ if (!old_tv_usec) { -+ old_tv_usec = cur_tv.tv_usec; -+ return 0; -+ } -+ -+ if(cur_tv.tv_usec > old_tv_usec) { -+ /* If there hasn't been rollover */ -+ elapsed_time = ((cur_tv.tv_usec - old_tv_usec)); -+ } -+ else { -+ /* Accounting for rollover */ -+ elapsed_time = ((1000000 - old_tv_usec + cur_tv.tv_usec)); -+ } -+ -+ if (elapsed_time > 250000) { -+ old_tv_usec = 0; /* reset the bounce time */ -+ return 0; -+ } -+ -+ return 1; -+} -+ -+/* button interrupt handler */ -+static void button_interrupt(int irq, void *dev, struct pt_regs *regs) -+{ -+ -+ unsigned int i,bit_mask, key_choice; -+ u32 button_state; -+ -+ /* Report state to upper level */ -+ -+ button_state = read_button_state() & BUTTON_MASK; /* get new gpio status */ -+ -+ /* Return if this is a repeated (bouncing) event */ -+ if(bounce()) -+ return; -+ -+ /* we want to make keystrokes */ -+ for( i=0; i< BUTTON_COUNT; i++) { -+ bit_mask = 1<<i; -+ if (button_state & bit_mask) { -+ key_choice = button_map[i]; -+ /* toggle key down */ -+ input_report_key(dev, key_choice, 1); -+ /* toggle key up */ -+ input_report_key(dev, key_choice, 0); -+ printk("ibutton gpio %d stat %x scan code %d\r\n", -+ i, button_state, key_choice); -+ /* Only report the first key event; it doesn't make -+ * sense for two keys to be pressed at the same time, -+ * and causes problems with the directional keys -+ * return; -+ */ -+ } -+ } -+} -+ -+static int -+button_translate(unsigned char scancode, unsigned char *keycode, char raw_mode) -+{ -+ static int prev_scancode; -+ -+ printk( "ibutton.c: translate: scancode=%x raw_mode=%x\n", -+ scancode, raw_mode); -+ -+ if (scancode == 0xe0 || scancode == 0xe1) { -+ prev_scancode = scancode; -+ return 0; -+ } -+ -+ if (scancode == 0x00 || scancode == 0xff) { -+ prev_scancode = 0; -+ return 0; -+ } -+ -+ *keycode = scancode; -+ -+ return 1; -+} -+ -+/* init button hardware */ -+static int button_hw_init(void) -+{ -+ unsigned int ipinfunc=0; -+ -+ printk("au1200_ibutton.c: Initializing buttons hardware\n"); -+ -+ // initialize GPIO pin function assignments -+ -+ ipinfunc = au_readl(SYS_PINFUNC); -+ -+ ipinfunc &= ~(SYS_PINFUNC_DMA | SYS_PINFUNC_S0A | SYS_PINFUNC_S0B); -+ au_writel( ipinfunc ,SYS_PINFUNC); -+ -+ ipinfunc |= (SYS_PINFUNC_S0C); -+ au_writel( ipinfunc ,SYS_PINFUNC); -+ -+ return 0; -+} -+ -+/* button driver init */ -+static int __init button_init(void) -+{ -+ int ret, i; -+ unsigned int flag=0; -+ -+ printk("au1200_ibutton.c: button_init()\r\n"); -+ -+ button_hw_init(); -+ -+ /* register all button irq handler */ -+ -+ for(i=0; i< sizeof(button_map)/sizeof(button_map[0]); i++) -+ { -+ /* register irq <-- gpio 1 ,6 ,12 , 17 ,19 , 26 ,28 */ -+ if(button_map[i] != 0) -+ { -+ ret = request_irq(AU1000_GPIO_0 + i , -+ &button_interrupt , SA_INTERRUPT , -+ DRIVER_NAME , &dev); -+ if(ret) flag |= 1<<i; -+ } -+ } -+ -+ printk("au1200_ibutton.c: request_irq,ret:0x%x\r\n",ret); -+ -+ if (ret) { -+ printk("au1200_ibutton.c: request_irq:%X failed\r\n",flag); -+ return ret; -+ } -+ -+ dev.name = DRIVER_NAME; -+ dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); -+ -+ for (i=0;i<sizeof(button_map)/sizeof(button_map[0]);i++) -+ { -+ dev.keybit[LONG(button_map[i])] |= BIT(button_map[i]); -+ } -+ -+ input_register_device(&dev); -+ -+ /* ready to receive interrupts */ -+ -+ return 0; -+} -+ -+/* button driver exit */ -+static void __exit button_exit(void) -+{ -+ int i; -+ -+ for(i=0;i<sizeof(button_map)/sizeof(button_map[0]);i++) -+ { -+ if(button_map[i] != 0) -+ { -+ free_irq( AU1000_GPIO_0 + i, &dev); -+ } -+ } -+ -+ input_unregister_device(&dev); -+ -+ printk("au1200_ibutton.c: button_exit()\r\n"); -+} -+ -+module_init(button_init); -+module_exit(button_exit); -+ -+MODULE_AUTHOR( DRIVER_AUTHOR ); -+MODULE_DESCRIPTION( DRIVER_DESC ); -+MODULE_LICENSE("GPL"); ---- /dev/null -+++ b/arch/mips/au1000/ficmmp/au1xxx_dock.c -@@ -0,0 +1,261 @@ -+/* -+ * Copyright (C) 2003 Metrowerks, 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/config.h> -+#include <linux/module.h> -+#include <linux/init.h> -+#include <linux/fs.h> -+#include <linux/sched.h> -+#include <linux/miscdevice.h> -+#include <linux/errno.h> -+#include <linux/poll.h> -+#include <asm/au1000.h> -+#include <asm/uaccess.h> -+#include <asm/au1xxx_gpio.h> -+ -+ -+#if defined(CONFIG_MIPS_FICMMP) -+ #define DOCK_GPIO 215 -+#else -+ #error Unsupported Au1xxx Platform -+#endif -+ -+#define MAKE_FLAG 0x20 -+ -+#undef DEBUG -+ -+#define DEBUG 0 -+//#define DEBUG 1 -+ -+#if DEBUG -+#define DPRINTK(format, args...) printk(__FUNCTION__ ": " format, ## args) -+#else -+#define DPRINTK(format, args...) do { } while (0) -+#endif -+ -+/* Please note that this driver is based on a timer and is not interrupt -+ * driven. If you are going to make use of this driver, you will need to have -+ * your application open the dock listing from the /dev directory first. -+ */ -+ -+struct au1xxx_dock { -+ struct fasync_struct *fasync; -+ wait_queue_head_t read_wait; -+ int open_count; -+ unsigned int debounce; -+ unsigned int current; -+ unsigned int last; -+}; -+ -+static struct au1xxx_dock dock_info; -+ -+ -+static void dock_timer_periodic(void *data); -+ -+static struct tq_struct dock_task = { -+ routine: dock_timer_periodic, -+ data: NULL -+}; -+ -+static int cleanup_flag = 0; -+static DECLARE_WAIT_QUEUE_HEAD(cleanup_wait_queue); -+ -+ -+static unsigned int read_dock_state(void) -+{ -+ u32 state; -+ -+ state = au1xxx_gpio_read(DOCK_GPIO); -+ -+ /* printk( "Current Dock State: %d\n", state ); */ -+ -+ return state; -+} -+ -+ -+static void dock_timer_periodic(void *data) -+{ -+ struct au1xxx_dock *dock = (struct au1xxx_dock *)data; -+ unsigned long dock_state; -+ -+ /* If cleanup wants us to die */ -+ if (cleanup_flag) { -+ /* now cleanup_module can return */ -+ wake_up(&cleanup_wait_queue); -+ } else { -+ /* put ourselves back in the task queue */ -+ queue_task(&dock_task, &tq_timer); -+ } -+ -+ /* read current dock */ -+ dock_state = read_dock_state(); -+ -+ /* if dock states hasn't changed */ -+ /* save time and be done. */ -+ if (dock_state == dock->current) { -+ return; -+ } -+ -+ if (dock_state == dock->debounce) { -+ dock->current = dock_state; -+ } else { -+ dock->debounce = dock_state; -+ } -+ if (dock->current != dock->last) { -+ if (waitqueue_active(&dock->read_wait)) { -+ wake_up_interruptible(&dock->read_wait); -+ } -+ } -+} -+ -+ -+static ssize_t au1xxx_dock_read(struct file *filp, char *buffer, size_t count, loff_t *ppos) -+{ -+ struct au1xxx_dock *dock = filp->private_data; -+ char event[3]; -+ int last; -+ int cur; -+ int err; -+ -+try_again: -+ -+ while (dock->current == dock->last) { -+ if (filp->f_flags & O_NONBLOCK) { -+ return -EAGAIN; -+ } -+ interruptible_sleep_on(&dock->read_wait); -+ if (signal_pending(current)) { -+ return -ERESTARTSYS; -+ } -+ } -+ -+ cur = dock->current; -+ last = dock->last; -+ -+ if(cur != last) -+ { -+ event[0] = cur ? 'D' : 'U'; -+ event[1] = '\r'; -+ event[2] = '\n'; -+ } -+ else -+ goto try_again; -+ -+ dock->last = cur; -+ err = copy_to_user(buffer, &event, 3); -+ if (err) { -+ return err; -+ } -+ -+ return 3; -+} -+ -+ -+static int au1xxx_dock_open(struct inode *inode, struct file *filp) -+{ -+ struct au1xxx_dock *dock = &dock_info; -+ -+ MOD_INC_USE_COUNT; -+ -+ filp->private_data = dock; -+ -+ if (dock->open_count++ == 0) { -+ dock_task.data = dock; -+ cleanup_flag = 0; -+ queue_task(&dock_task, &tq_timer); -+ } -+ -+ return 0; -+} -+ -+ -+static unsigned int au1xxx_dock_poll(struct file *filp, poll_table *wait) -+{ -+ struct au1xxx_dock *dock = filp->private_data; -+ int ret = 0; -+ -+ DPRINTK("start\n"); -+ poll_wait(filp, &dock->read_wait, wait); -+ if (dock->current != dock->last) { -+ ret = POLLIN | POLLRDNORM; -+ } -+ return ret; -+} -+ -+ -+static int au1xxx_dock_release(struct inode *inode, struct file *filp) -+{ -+ struct au1xxx_dock *dock = filp->private_data; -+ -+ DPRINTK("start\n"); -+ -+ if (--dock->open_count == 0) { -+ cleanup_flag = 1; -+ sleep_on(&cleanup_wait_queue); -+ } -+ MOD_DEC_USE_COUNT; -+ -+ return 0; -+} -+ -+ -+ -+static struct file_operations au1xxx_dock_fops = { -+ owner: THIS_MODULE, -+ read: au1xxx_dock_read, -+ poll: au1xxx_dock_poll, -+ open: au1xxx_dock_open, -+ release: au1xxx_dock_release, -+}; -+ -+/* -+ * The au1xxx dock is a misc device: -+ * Major 10 char -+ * Minor 22 /dev/dock -+ * -+ * This is /dev/misc/dock if devfs is used. -+ */ -+ -+static struct miscdevice au1xxx_dock_dev = { -+ minor: 23, -+ name: "dock", -+ fops: &au1xxx_dock_fops, -+}; -+ -+static int __init au1xxx_dock_init(void) -+{ -+ struct au1xxx_dock *dock = &dock_info; -+ int ret; -+ -+ DPRINTK("Initializing dock driver\n"); -+ dock->open_count = 0; -+ cleanup_flag = 0; -+ init_waitqueue_head(&dock->read_wait); -+ -+ -+ /* yamon configures GPIO pins for the dock -+ * no initialization needed -+ */ -+ -+ ret = misc_register(&au1xxx_dock_dev); -+ -+ DPRINTK("dock driver fully initialized.\n"); -+ -+ return ret; -+} -+ -+ -+static void __exit au1xxx_dock_exit(void) -+{ -+ DPRINTK("unloading dock driver\n"); -+ misc_deregister(&au1xxx_dock_dev); -+} -+ -+ -+module_init(au1xxx_dock_init); -+module_exit(au1xxx_dock_exit); ---- /dev/null -+++ b/arch/mips/au1000/ficmmp/board_setup.c -@@ -0,0 +1,226 @@ -+/* -+ * -+ * BRIEF MODULE DESCRIPTION -+ * Alchemy Pb1200 board setup. -+ * -+ * 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 SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN -+ * NO EVENT SHALL THE AUTHOR 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. -+ * -+ * You should have received a copy of the GNU General Public License along -+ * with this program; if not, write to the Free Software Foundation, Inc., -+ * 675 Mass Ave, Cambridge, MA 02139, USA. -+ */ -+#include <linux/config.h> -+#include <linux/init.h> -+#include <linux/sched.h> -+#include <linux/ioport.h> -+#include <linux/mm.h> -+#include <linux/console.h> -+#include <linux/mc146818rtc.h> -+#include <linux/delay.h> -+#include <linux/ide.h> -+ -+#if defined(CONFIG_BLK_DEV_IDE_AU1XXX) -+#include <linux/ide.h> -+#endif -+ -+#include <asm/cpu.h> -+#include <asm/bootinfo.h> -+#include <asm/irq.h> -+#include <asm/keyboard.h> -+#include <asm/mipsregs.h> -+#include <asm/reboot.h> -+#include <asm/pgtable.h> -+#include <asm/au1000.h> -+#include <asm/ficmmp.h> -+#include <asm/au1xxx_dbdma.h> -+#include <asm/au1xxx_gpio.h> -+ -+extern struct rtc_ops no_rtc_ops; -+ -+/* value currently in the board configuration register */ -+u16 ficmmp_config = 0; -+ -+#if defined(CONFIG_BLK_DEV_IDE_AU1XXX) -+extern struct ide_ops *ide_ops; -+extern struct ide_ops au1xxx_ide_ops; -+extern u32 au1xxx_ide_virtbase; -+extern u64 au1xxx_ide_physbase; -+extern int au1xxx_ide_irq; -+ -+u32 led_base_addr; -+/* Ddma */ -+chan_tab_t *ide_read_ch, *ide_write_ch; -+u32 au1xxx_ide_ddma_enable = 0, switch4ddma = 1; // PIO+ddma -+ -+dbdev_tab_t new_dbdev_tab_element = { DSCR_CMD0_THROTTLE, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 }; -+#endif /* end CONFIG_BLK_DEV_IDE_AU1XXX */ -+ -+void board_reset (void) -+{ -+ au_writel(0, 0xAD80001C); -+} -+ -+void board_power_off (void) -+{ -+} -+ -+void __init board_setup(void) -+{ -+ char *argptr = NULL; -+ u32 pin_func; -+ rtc_ops = &no_rtc_ops; -+ -+ ficmmp_config_init(); //Initialize FIC control register -+ -+#if 0 -+ /* Enable PSC1 SYNC for AC97. Normaly done in audio driver, -+ * but it is board specific code, so put it here. -+ */ -+ pin_func = au_readl(SYS_PINFUNC); -+ au_sync(); -+ pin_func |= SYS_PF_MUST_BE_SET | SYS_PF_PSC1_S1; -+ au_writel(pin_func, SYS_PINFUNC); -+ -+ au_writel(0, (u32)bcsr|0x10); /* turn off pcmcia power */ -+ au_sync(); -+#endif -+ -+#if defined( CONFIG_I2C_ALGO_AU1550 ) -+ { -+ u32 freq0, clksrc; -+ -+ /* Select SMBUS in CPLD */ -+ /* bcsr->resets &= ~(BCSR_RESETS_PCS0MUX); */ -+ -+ pin_func = au_readl(SYS_PINFUNC); -+ au_sync(); -+ pin_func &= ~(3<<17 | 1<<4); -+ /* Set GPIOs correctly */ -+ pin_func |= 2<<17; -+ au_writel(pin_func, SYS_PINFUNC); -+ au_sync(); -+ -+ /* The i2c driver depends on 50Mhz clock */ -+ freq0 = au_readl(SYS_FREQCTRL0); -+ au_sync(); -+ freq0 &= ~(SYS_FC_FRDIV1_MASK | SYS_FC_FS1 | SYS_FC_FE1); -+ freq0 |= (3<<SYS_FC_FRDIV1_BIT); -+ /* 396Mhz / (3+1)*2 == 49.5Mhz */ -+ au_writel(freq0, SYS_FREQCTRL0); -+ au_sync(); -+ freq0 |= SYS_FC_FE1; -+ au_writel(freq0, SYS_FREQCTRL0); -+ au_sync(); -+ -+ clksrc = au_readl(SYS_CLKSRC); -+ au_sync(); -+ clksrc &= ~0x01f00000; -+ /* bit 22 is EXTCLK0 for PSC0 */ -+ clksrc |= (0x3 << 22); -+ au_writel(clksrc, SYS_CLKSRC); -+ au_sync(); -+ } -+#endif -+ -+#ifdef CONFIG_FB_AU1200 -+ argptr = prom_getcmdline(); -+ strcat(argptr, " video=au1200fb:"); -+#endif -+ -+#if defined(CONFIG_BLK_DEV_IDE_AU1XXX) -+ /* -+ * Iniz IDE parameters -+ */ -+ ide_ops = &au1xxx_ide_ops; -+ au1xxx_ide_irq = FICMMP_IDE_INT; -+ au1xxx_ide_physbase = AU1XXX_ATA_PHYS_ADDR; -+ au1xxx_ide_virtbase = KSEG1ADDR(AU1XXX_ATA_PHYS_ADDR); -+ switch4ddma = 0; -+ /* -+ ide_ops = &au1xxx_ide_ops; -+ au1xxx_ide_irq = FICMMP_IDE_INT; -+ au1xxx_ide_base = KSEG1ADDR(AU1XXX_ATA_BASE); -+ */ -+ au1xxx_gpio_write(9, 1); -+ printk("B4001010: %X\n", *((u32*)0xB4001010)); -+ printk("B4001014: %X\n", *((u32*)0xB4001014)); -+ printk("B4001018: %X\n", *((u32*)0xB4001018)); -+ printk("B1900100: %X\n", *((u32*)0xB1900100)); -+ -+#if 0 -+ ficmmp_config_clear(FICMMP_CONFIG_IDERST); -+ mdelay(100); -+ ficmmp_config_set(FICMMP_CONFIG_IDERST); -+ mdelay(100); -+#endif -+ /* -+ * change PIO or PIO+Ddma -+ * check the GPIO-5 pin condition. pb1200:s18_dot -+ */ -+/* switch4ddma = 0; //(au_readl(SYS_PINSTATERD) & (1 << 5)) ? 1 : 0; */ -+#endif -+ -+ /* The Pb1200 development board uses external MUX for PSC0 to -+ support SMB/SPI. bcsr->resets bit 12: 0=SMB 1=SPI -+ */ -+#if defined(CONFIG_AU1550_PSC_SPI) && defined(CONFIG_I2C_ALGO_AU1550) -+ #error I2C and SPI are mutually exclusive. Both are physically connected to PSC0.\ -+ Refer to Pb1200 documentation. -+#elif defined( CONFIG_AU1550_PSC_SPI ) -+ //bcsr->resets |= BCSR_RESETS_PCS0MUX; -+#elif defined( CONFIG_I2C_ALGO_AU1550 ) -+ //bcsr->resets &= (~BCSR_RESETS_PCS0MUX); -+#endif -+ au_sync(); -+ -+ printk("FIC Multimedia Player Board\n"); -+ au1xxx_gpio_tristate(5); -+ printk("B1900100: %X\n", *((volatile u32*)0xB1900100)); -+ printk("B190002C: %X\n", *((volatile u32*)0xB190002C)); -+} -+ -+int -+board_au1200fb_panel (void) -+{ -+ au1xxx_gpio_tristate(6); -+ -+ if (au1xxx_gpio_read(12) == 0) -+ return 9; /* FS453_640x480 (Composite/S-Video) */ -+ else -+ return 7; /* Sharp 320x240 TFT */ -+} -+ -+int -+board_au1200fb_panel_init (void) -+{ -+ /*Enable data buffers*/ -+ ficmmp_config_clear(FICMMP_CONFIG_LCMDATAOUT); -+ /*Take LCD out of reset*/ -+ ficmmp_config_set(FICMMP_CONFIG_LCMPWREN | FICMMP_CONFIG_LCMEN); -+ return 0; -+} -+ -+int -+board_au1200fb_panel_shutdown (void) -+{ -+ /*Disable data buffers*/ -+ ficmmp_config_set(FICMMP_CONFIG_LCMDATAOUT); -+ /*Put LCD in reset, remove power*/ -+ ficmmp_config_clear(FICMMP_CONFIG_LCMEN | FICMMP_CONFIG_LCMPWREN); -+ return 0; -+} -+ ---- /dev/null -+++ b/arch/mips/au1000/ficmmp/init.c -@@ -0,0 +1,76 @@ -+/* -+ * -+ * BRIEF MODULE DESCRIPTION -+ * PB1200 board setup -+ * -+ * 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 SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN -+ * NO EVENT SHALL THE AUTHOR 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. -+ * -+ * You should have received a copy of the GNU General Public License along -+ * with this program; if not, write to the Free Software Foundation, Inc., -+ * 675 Mass Ave, Cambridge, MA 02139, USA. -+ */ -+ -+#include <linux/init.h> -+#include <linux/mm.h> -+#include <linux/sched.h> -+#include <linux/bootmem.h> -+#include <asm/addrspace.h> -+#include <asm/bootinfo.h> -+#include <linux/config.h> -+#include <linux/string.h> -+#include <linux/kernel.h> -+#include <linux/sched.h> -+ -+int prom_argc; -+char **prom_argv, **prom_envp; -+extern void __init prom_init_cmdline(void); -+extern char *prom_getenv(char *envname); -+ -+const char *get_system_type(void) -+{ -+ return "FIC Multimedia Player (Au1200)"; -+} -+ -+u32 mae_memsize = 0; -+ -+int __init prom_init(int argc, char **argv, char **envp, int *prom_vec) -+{ -+ unsigned char *memsize_str; -+ unsigned long memsize; -+ -+ prom_argc = argc; -+ prom_argv = argv; -+ prom_envp = envp; -+ -+ mips_machgroup = MACH_GROUP_ALCHEMY; -+ mips_machtype = MACH_PB1000; /* set the platform # */ -+ prom_init_cmdline(); -+ -+ memsize_str = prom_getenv("memsize"); -+ if (!memsize_str) { -+ memsize = 0x08000000; -+ } else { -+ memsize = simple_strtol(memsize_str, NULL, 0); -+ } -+ -+ /* reserved 32MB for MAE driver */ -+ memsize -= (32 * 1024 * 1024); -+ add_memory_region(0, memsize, BOOT_MEM_RAM); -+ mae_memsize = memsize; /* for drivers/char/au1xxx_mae.c */ -+ return 0; -+} -+ ---- /dev/null -+++ b/arch/mips/au1000/ficmmp/irqmap.c -@@ -0,0 +1,61 @@ -+/* -+ * BRIEF MODULE DESCRIPTION -+ * Au1xxx irq map table -+ * -+ * 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 SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN -+ * NO EVENT SHALL THE AUTHOR 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. -+ * -+ * You should have received a copy of the GNU General Public License along -+ * with this program; if not, write to the Free Software Foundation, Inc., -+ * 675 Mass Ave, Cambridge, MA 02139, USA. -+ */ -+#include <linux/errno.h> -+#include <linux/init.h> -+#include <linux/irq.h> -+#include <linux/kernel_stat.h> -+#include <linux/module.h> -+#include <linux/signal.h> -+#include <linux/sched.h> -+#include <linux/types.h> -+#include <linux/interrupt.h> -+#include <linux/ioport.h> -+#include <linux/timex.h> -+#include <linux/slab.h> -+#include <linux/random.h> -+#include <linux/delay.h> -+ -+#include <asm/bitops.h> -+#include <asm/bootinfo.h> -+#include <asm/io.h> -+#include <asm/mipsregs.h> -+#include <asm/system.h> -+#include <asm/au1000.h> -+#include <asm/ficmmp.h> -+ -+au1xxx_irq_map_t au1xxx_irq_map[] = { -+ { FICMMP_IDE_INT, INTC_INT_HIGH_LEVEL, 0 }, -+ { AU1XXX_SMC91111_IRQ, INTC_INT_HIGH_LEVEL, 0 }, -+ { AU1000_GPIO_1 , INTC_INT_FALL_EDGE, 0 }, // main button -+ { AU1000_GPIO_6 , INTC_INT_RISE_EDGE, 0 }, // select button -+ { AU1000_GPIO_12, INTC_INT_FALL_EDGE, 0 }, // guide button -+ { AU1000_GPIO_17, INTC_INT_RISE_EDGE, 0 }, // down button -+ { AU1000_GPIO_19, INTC_INT_RISE_EDGE, 0 }, // left button -+ { AU1000_GPIO_26, INTC_INT_RISE_EDGE, 0 }, // right button -+ { AU1000_GPIO_28, INTC_INT_RISE_EDGE, 0 }, // up button -+}; -+ -+int au1xxx_nr_irqs = sizeof(au1xxx_irq_map)/sizeof(au1xxx_irq_map_t); -+ ---- /dev/null -+++ b/arch/mips/au1000/ficmmp/Makefile -@@ -0,0 +1,25 @@ -+# -+# Copyright 2000 MontaVista Software Inc. -+# Author: MontaVista Software, Inc. -+# ppopov@mvista.com or source@mvista.com -+# -+# Makefile for the Alchemy Semiconductor FIC board. -+# -+# Note! Dependencies are done automagically by 'make dep', which also -+# removes any old dependencies. DON'T put your own dependencies here -+# unless it's something special (ie not a .c file). -+# -+ -+USE_STANDARD_AS_RULE := true -+ -+O_TARGET := ficmmp.o -+ -+obj-y := init.o board_setup.o irqmap.o au1200_ibutton.o au1xxx_dock.o -+ -+ifdef CONFIG_MMC -+obj-y += mmc_support.o -+export-objs +=mmc_support.o -+endif -+ -+ -+include $(TOPDIR)/Rules.make ---- a/arch/mips/au1000/hydrogen3/board_setup.c -+++ b/arch/mips/au1000/hydrogen3/board_setup.c -@@ -51,12 +51,19 @@ void board_reset (void) - { - } - -+void board_power_off (void) -+{ -+} -+ - void __init board_setup(void) - { - u32 pin_func; - - rtc_ops = &no_rtc_ops; - -+ /* Set GPIO14 high to make CD/DAT1 high for MMC to work */ -+ au_writel(1<<14, SYS_OUTPUTSET); -+ - #ifdef CONFIG_AU1X00_USB_DEVICE - // 2nd USB port is USB device - pin_func = au_readl(SYS_PINFUNC) & (u32)(~0x8000); ---- /dev/null -+++ b/arch/mips/au1000/hydrogen3/buttons.c -@@ -0,0 +1,308 @@ -+/* -+ * Copyright (C) 2003 Metrowerks, 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/config.h> -+#include <linux/module.h> -+#include <linux/init.h> -+#include <linux/fs.h> -+#include <linux/sched.h> -+#include <linux/miscdevice.h> -+#include <linux/errno.h> -+#include <linux/poll.h> -+#include <asm/au1000.h> -+#include <asm/uaccess.h> -+ -+#define BUTTON_SELECT (1<<1) -+#define BUTTON_1 (1<<2) -+#define BUTTON_2 (1<<3) -+#define BUTTON_ONOFF (1<<6) -+#define BUTTON_3 (1<<7) -+#define BUTTON_4 (1<<8) -+#define BUTTON_LEFT (1<<9) -+#define BUTTON_DOWN (1<<10) -+#define BUTTON_RIGHT (1<<11) -+#define BUTTON_UP (1<<12) -+ -+#define BUTTON_MASK (\ -+ BUTTON_SELECT \ -+ | BUTTON_1 \ -+ | BUTTON_2 \ -+ | BUTTON_ONOFF \ -+ | BUTTON_3 \ -+ | BUTTON_4 \ -+ | BUTTON_LEFT \ -+ | BUTTON_DOWN \ -+ | BUTTON_RIGHT \ -+ | BUTTON_UP \ -+ ) -+ -+#define BUTTON_INVERT (\ -+ BUTTON_SELECT \ -+ | BUTTON_1 \ -+ | BUTTON_2 \ -+ | BUTTON_3 \ -+ | BUTTON_4 \ -+ | BUTTON_LEFT \ -+ | BUTTON_DOWN \ -+ | BUTTON_RIGHT \ -+ | BUTTON_UP \ -+ ) -+ -+ -+ -+#define MAKE_FLAG 0x20 -+ -+#undef DEBUG -+ -+#define DEBUG 0 -+//#define DEBUG 1 -+ -+#if DEBUG -+#define DPRINTK(format, args...) printk(__FUNCTION__ ": " format, ## args) -+#else -+#define DPRINTK(format, args...) do { } while (0) -+#endif -+ -+/* Please note that this driver is based on a timer and is not interrupt -+ * driven. If you are going to make use of this driver, you will need to have -+ * your application open the buttons listing from the /dev directory first. -+ */ -+ -+struct hydrogen3_buttons { -+ struct fasync_struct *fasync; -+ wait_queue_head_t read_wait; -+ int open_count; -+ unsigned int debounce; -+ unsigned int current; -+ unsigned int last; -+}; -+ -+static struct hydrogen3_buttons buttons_info; -+ -+ -+static void button_timer_periodic(void *data); -+ -+static struct tq_struct button_task = { -+ routine: button_timer_periodic, -+ data: NULL -+}; -+ -+static int cleanup_flag = 0; -+static DECLARE_WAIT_QUEUE_HEAD(cleanup_wait_queue); -+ -+ -+static unsigned int read_button_state(void) -+{ -+ unsigned long state; -+ -+ state = inl(SYS_PINSTATERD) & BUTTON_MASK; -+ state ^= BUTTON_INVERT; -+ -+ DPRINTK( "Current Button State: %d\n", state ); -+ -+ return state; -+} -+ -+ -+static void button_timer_periodic(void *data) -+{ -+ struct hydrogen3_buttons *buttons = (struct hydrogen3_buttons *)data; -+ unsigned long button_state; -+ -+ // If cleanup wants us to die -+ if (cleanup_flag) { -+ wake_up(&cleanup_wait_queue); // now cleanup_module can return -+ } else { -+ queue_task(&button_task, &tq_timer); // put ourselves back in the task queue -+ } -+ -+ // read current buttons -+ button_state = read_button_state(); -+ -+ // if no buttons are down and nothing to do then -+ // save time and be done. -+ if ((button_state == 0) && (buttons->current == 0)) { -+ return; -+ } -+ -+ if (button_state == buttons->debounce) { -+ buttons->current = button_state; -+ } else { -+ buttons->debounce = button_state; -+ } -+// printk("0x%04x\n", button_state); -+ if (buttons->current != buttons->last) { -+ if (waitqueue_active(&buttons->read_wait)) { -+ wake_up_interruptible(&buttons->read_wait); -+ } -+ } -+} -+ -+ -+static ssize_t hydrogen3_buttons_read(struct file *filp, char *buffer, size_t count, loff_t *ppos) -+{ -+ struct hydrogen3_buttons *buttons = filp->private_data; -+ char events[16]; -+ int index; -+ int last; -+ int cur; -+ int bit; -+ int bit_mask; -+ int err; -+ -+ DPRINTK("start\n"); -+ -+try_again: -+ -+ while (buttons->current == buttons->last) { -+ if (filp->f_flags & O_NONBLOCK) { -+ return -EAGAIN; -+ } -+ interruptible_sleep_on(&buttons->read_wait); -+ if (signal_pending(current)) { -+ return -ERESTARTSYS; -+ } -+ } -+ -+ cur = buttons->current; -+ last = buttons->last; -+ -+ index = 0; -+ bit_mask = 1; -+ for (bit = 0; (bit < 16) && count; bit++) { -+ if ((cur ^ last) & bit_mask) { -+ if (cur & bit_mask) { -+ events[index] = (bit | MAKE_FLAG) + 'A'; -+ last |= bit_mask; -+ } else { -+ events[index] = bit + 'A'; -+ last &= ~bit_mask; -+ } -+ index++; -+ count--; -+ } -+ bit_mask <<= 1; -+ } -+ buttons->last = last; -+ -+ if (index == 0) { -+ goto try_again; -+ } -+ -+ err = copy_to_user(buffer, events, index); -+ if (err) { -+ return err; -+ } -+ -+ return index; -+} -+ -+ -+static int hydrogen3_buttons_open(struct inode *inode, struct file *filp) -+{ -+ struct hydrogen3_buttons *buttons = &buttons_info; -+ -+ DPRINTK("start\n"); -+ MOD_INC_USE_COUNT; -+ -+ filp->private_data = buttons; -+ -+ if (buttons->open_count++ == 0) { -+ button_task.data = buttons; -+ cleanup_flag = 0; -+ queue_task(&button_task, &tq_timer); -+ } -+ -+ return 0; -+} -+ -+ -+static unsigned int hydrogen3_buttons_poll(struct file *filp, poll_table *wait) -+{ -+ struct hydrogen3_buttons *buttons = filp->private_data; -+ int ret = 0; -+ -+ DPRINTK("start\n"); -+ poll_wait(filp, &buttons->read_wait, wait); -+ if (buttons->current != buttons->last) { -+ ret = POLLIN | POLLRDNORM; -+ } -+ return ret; -+} -+ -+ -+static int hydrogen3_buttons_release(struct inode *inode, struct file *filp) -+{ -+ struct hydrogen3_buttons *buttons = filp->private_data; -+ -+ DPRINTK("start\n"); -+ -+ if (--buttons->open_count == 0) { -+ cleanup_flag = 1; -+ sleep_on(&cleanup_wait_queue); -+ } -+ MOD_DEC_USE_COUNT; -+ -+ return 0; -+} -+ -+ -+ -+static struct file_operations hydrogen3_buttons_fops = { -+ owner: THIS_MODULE, -+ read: hydrogen3_buttons_read, -+ poll: hydrogen3_buttons_poll, -+ open: hydrogen3_buttons_open, -+ release: hydrogen3_buttons_release, -+}; -+ -+/* -+ * The hydrogen3 buttons is a misc device: -+ * Major 10 char -+ * Minor 22 /dev/buttons -+ * -+ * This is /dev/misc/buttons if devfs is used. -+ */ -+ -+static struct miscdevice hydrogen3_buttons_dev = { -+ minor: 22, -+ name: "buttons", -+ fops: &hydrogen3_buttons_fops, -+}; -+ -+static int __init hydrogen3_buttons_init(void) -+{ -+ struct hydrogen3_buttons *buttons = &buttons_info; -+ int ret; -+ -+ DPRINTK("Initializing buttons driver\n"); -+ buttons->open_count = 0; -+ cleanup_flag = 0; -+ init_waitqueue_head(&buttons->read_wait); -+ -+ -+ // yamon configures GPIO pins for the buttons -+ // no initialization needed -+ -+ ret = misc_register(&hydrogen3_buttons_dev); -+ -+ DPRINTK("Buttons driver fully initialized.\n"); -+ -+ return ret; -+} -+ -+ -+static void __exit hydrogen3_buttons_exit(void) -+{ -+ DPRINTK("unloading buttons driver\n"); -+ misc_deregister(&hydrogen3_buttons_dev); -+} -+ -+ -+module_init(hydrogen3_buttons_init); -+module_exit(hydrogen3_buttons_exit); ---- a/arch/mips/au1000/hydrogen3/Makefile -+++ b/arch/mips/au1000/hydrogen3/Makefile -@@ -14,6 +14,11 @@ USE_STANDARD_AS_RULE := true - - O_TARGET := hydrogen3.o - --obj-y := init.o board_setup.o irqmap.o -+obj-y := init.o board_setup.o irqmap.o buttons.o -+ -+ifdef CONFIG_MMC -+obj-y += mmc_support.o -+export-objs +=mmc_support.o -+endif - - include $(TOPDIR)/Rules.make ---- /dev/null -+++ b/arch/mips/au1000/hydrogen3/mmc_support.c -@@ -0,0 +1,89 @@ -+/* -+ * BRIEF MODULE DESCRIPTION -+ * -+ * MMC support routines for Hydrogen3. -+ * -+ * -+ * Copyright (c) 2003-2004 Embedded Edge, LLC. -+ * Author: Embedded Edge, LLC. -+ * Contact: dan@embeddededge.com -+ * -+ * This program is free software; you can redistribute it and/or modify it -+ * under the terms of the GNU General Public License as published by the -+ * Free Software Foundation; either version 2 of the License, or (at your -+ * option) any later version. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN -+ * NO EVENT SHALL THE AUTHOR 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. -+ * -+ * You should have received a copy of the GNU General Public License along -+ * with this program; if not, write to the Free Software Foundation, Inc., -+ * 675 Mass Ave, Cambridge, MA 02139, USA. -+ * -+ */ -+ -+ -+#include <linux/config.h> -+#include <linux/kernel.h> -+#include <linux/module.h> -+#include <linux/init.h> -+ -+#include <asm/irq.h> -+#include <asm/au1000.h> -+#include <asm/au1100_mmc.h> -+ -+#define GPIO_17_WP 0x20000 -+ -+/* SD/MMC controller support functions */ -+ -+/* -+ * Detect card. -+ */ -+void mmc_card_inserted(int _n_, int *_res_) -+{ -+ u32 gpios = au_readl(SYS_PINSTATERD); -+ u32 emptybit = (1<<16); -+ *_res_ = ((gpios & emptybit) == 0); -+} -+ -+/* -+ * Check card write protection. -+ */ -+void mmc_card_writable(int _n_, int *_res_) -+{ -+ unsigned long mmc_wp, board_specific; -+ board_specific = au_readl(SYS_OUTPUTSET); -+ mmc_wp=GPIO_17_WP; -+ if (!(board_specific & mmc_wp)) {/* low means card writable */ -+ *_res_ = 1; -+ } else { -+ *_res_ = 0; -+ } -+} -+/* -+ * Apply power to card slot. -+ */ -+void mmc_power_on(int _n_) -+{ -+} -+ -+/* -+ * Remove power from card slot. -+ */ -+void mmc_power_off(int _n_) -+{ -+} -+ -+EXPORT_SYMBOL(mmc_card_inserted); -+EXPORT_SYMBOL(mmc_card_writable); -+EXPORT_SYMBOL(mmc_power_on); -+EXPORT_SYMBOL(mmc_power_off); -+ ---- a/arch/mips/au1000/mtx-1/board_setup.c -+++ b/arch/mips/au1000/mtx-1/board_setup.c -@@ -48,6 +48,12 @@ - - extern struct rtc_ops no_rtc_ops; - -+void board_reset (void) -+{ -+ /* Hit BCSR.SYSTEM_CONTROL[SW_RST] */ -+ au_writel(0x00000000, 0xAE00001C); -+} -+ - void __init board_setup(void) - { - rtc_ops = &no_rtc_ops; ---- a/arch/mips/au1000/mtx-1/irqmap.c -+++ b/arch/mips/au1000/mtx-1/irqmap.c -@@ -72,10 +72,10 @@ au1xxx_pci_irqmap(struct pci_dev *dev, u - * A B C D - */ - { -- {INTA, INTB, INTC, INTD}, /* IDSEL 0 */ -- {INTA, INTB, INTC, INTD}, /* IDSEL 1 */ -- {INTA, INTB, INTC, INTD}, /* IDSEL 2 */ -- {INTA, INTB, INTC, INTD}, /* IDSEL 3 */ -+ {INTA, INTB, INTX, INTX}, /* IDSEL 0 */ -+ {INTB, INTA, INTX, INTX}, /* IDSEL 1 */ -+ {INTC, INTD, INTX, INTX}, /* IDSEL 2 */ -+ {INTD, INTC, INTX, INTX}, /* IDSEL 3 */ - }; - const long min_idsel = 0, max_idsel = 3, irqs_per_slot = 4; - return PCI_IRQ_TABLE_LOOKUP; ---- a/arch/mips/au1000/pb1000/board_setup.c -+++ b/arch/mips/au1000/pb1000/board_setup.c -@@ -58,6 +58,10 @@ void board_reset (void) - { - } - -+void board_power_off (void) -+{ -+} -+ - void __init board_setup(void) - { - u32 pin_func, static_cfg0; ---- a/arch/mips/au1000/pb1100/board_setup.c -+++ b/arch/mips/au1000/pb1100/board_setup.c -@@ -62,6 +62,10 @@ void board_reset (void) - au_writel(0x00000000, 0xAE00001C); - } - -+void board_power_off (void) -+{ -+} -+ - void __init board_setup(void) - { - u32 pin_func; ---- a/arch/mips/au1000/pb1100/Makefile -+++ b/arch/mips/au1000/pb1100/Makefile -@@ -16,4 +16,10 @@ O_TARGET := pb1100.o - - obj-y := init.o board_setup.o irqmap.o - -+ -+ifdef CONFIG_MMC -+obj-y += mmc_support.o -+export-objs += mmc_support.o -+endif -+ - include $(TOPDIR)/Rules.make ---- /dev/null -+++ b/arch/mips/au1000/pb1100/mmc_support.c -@@ -0,0 +1,126 @@ -+/* -+ * BRIEF MODULE DESCRIPTION -+ * -+ * MMC support routines for PB1100. -+ * -+ * -+ * Copyright (c) 2003-2004 Embedded Edge, LLC. -+ * Author: Embedded Edge, LLC. -+ * Contact: dan@embeddededge.com -+ * -+ * This program is free software; you can redistribute it and/or modify it -+ * under the terms of the GNU General Public License as published by the -+ * Free Software Foundation; either version 2 of the License, or (at your -+ * option) any later version. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN -+ * NO EVENT SHALL THE AUTHOR 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. -+ * -+ * You should have received a copy of the GNU General Public License along -+ * with this program; if not, write to the Free Software Foundation, Inc., -+ * 675 Mass Ave, Cambridge, MA 02139, USA. -+ * -+ */ -+ -+ -+#include <linux/config.h> -+#include <linux/kernel.h> -+#include <linux/module.h> -+#include <linux/init.h> -+ -+#include <asm/irq.h> -+#include <asm/au1000.h> -+#include <asm/au1100_mmc.h> -+#include <asm/pb1100.h> -+ -+ -+/* SD/MMC controller support functions */ -+ -+/* -+ * Detect card. -+ */ -+void mmc_card_inserted(int _n_, int *_res_) -+{ -+ u32 gpios = au_readl(SYS_PINSTATERD); -+ u32 emptybit = (_n_) ? (1<<15) : (1<<14); -+ *_res_ = ((gpios & emptybit) == 0); -+} -+ -+/* -+ * Check card write protection. -+ */ -+void mmc_card_writable(int _n_, int *_res_) -+{ -+ BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR; -+ unsigned long mmc_wp, board_specific; -+ -+ if (_n_) { -+ mmc_wp = BCSR_PCMCIA_SD1_WP; -+ } else { -+ mmc_wp = BCSR_PCMCIA_SD0_WP; -+ } -+ -+ board_specific = au_readl((unsigned long)(&bcsr->pcmcia)); -+ -+ if (!(board_specific & mmc_wp)) {/* low means card writable */ -+ *_res_ = 1; -+ } else { -+ *_res_ = 0; -+ } -+} -+ -+/* -+ * Apply power to card slot. -+ */ -+void mmc_power_on(int _n_) -+{ -+ BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR; -+ unsigned long mmc_pwr, board_specific; -+ -+ if (_n_) { -+ mmc_pwr = BCSR_PCMCIA_SD1_PWR; -+ } else { -+ mmc_pwr = BCSR_PCMCIA_SD0_PWR; -+ } -+ -+ board_specific = au_readl((unsigned long)(&bcsr->pcmcia)); -+ board_specific |= mmc_pwr; -+ -+ au_writel(board_specific, (int)(&bcsr->pcmcia)); -+ au_sync_delay(1); -+} -+ -+/* -+ * Remove power from card slot. -+ */ -+void mmc_power_off(int _n_) -+{ -+ BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR; -+ unsigned long mmc_pwr, board_specific; -+ -+ if (_n_) { -+ mmc_pwr = BCSR_PCMCIA_SD1_PWR; -+ } else { -+ mmc_pwr = BCSR_PCMCIA_SD0_PWR; -+ } -+ -+ board_specific = au_readl((unsigned long)(&bcsr->pcmcia)); -+ board_specific &= ~mmc_pwr; -+ -+ au_writel(board_specific, (int)(&bcsr->pcmcia)); -+ au_sync_delay(1); -+} -+ -+EXPORT_SYMBOL(mmc_card_inserted); -+EXPORT_SYMBOL(mmc_card_writable); -+EXPORT_SYMBOL(mmc_power_on); -+EXPORT_SYMBOL(mmc_power_off); -+ ---- /dev/null -+++ b/arch/mips/au1000/pb1200/board_setup.c -@@ -0,0 +1,221 @@ -+/* -+ * -+ * BRIEF MODULE DESCRIPTION -+ * Alchemy Pb1200 board setup. -+ * -+ * 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 SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN -+ * NO EVENT SHALL THE AUTHOR 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. -+ * -+ * You should have received a copy of the GNU General Public License along -+ * with this program; if not, write to the Free Software Foundation, Inc., -+ * 675 Mass Ave, Cambridge, MA 02139, USA. -+ */ -+#include <linux/config.h> -+#include <linux/init.h> -+#include <linux/sched.h> -+#include <linux/ioport.h> -+#include <linux/mm.h> -+#include <linux/console.h> -+#include <linux/mc146818rtc.h> -+#include <linux/delay.h> -+ -+#if defined(CONFIG_BLK_DEV_IDE_AU1XXX) -+#include <linux/ide.h> -+#endif -+ -+#include <asm/cpu.h> -+#include <asm/bootinfo.h> -+#include <asm/irq.h> -+#include <asm/keyboard.h> -+#include <asm/mipsregs.h> -+#include <asm/reboot.h> -+#include <asm/pgtable.h> -+#include <asm/au1000.h> -+#include <asm/au1xxx_dbdma.h> -+ -+#ifdef CONFIG_MIPS_PB1200 -+#include <asm/pb1200.h> -+#endif -+ -+#ifdef CONFIG_MIPS_DB1200 -+#include <asm/db1200.h> -+#define PB1200_ETH_INT DB1200_ETH_INT -+#define PB1200_IDE_INT DB1200_IDE_INT -+#endif -+ -+extern struct rtc_ops no_rtc_ops; -+ -+extern void _board_init_irq(void); -+extern void (*board_init_irq)(void); -+ -+#ifdef CONFIG_BLK_DEV_IDE_AU1XXX -+extern struct ide_ops *ide_ops; -+extern struct ide_ops au1xxx_ide_ops; -+extern u32 au1xxx_ide_virtbase; -+extern u64 au1xxx_ide_physbase; -+extern int au1xxx_ide_irq; -+ -+u32 led_base_addr; -+/* Ddma */ -+chan_tab_t *ide_read_ch, *ide_write_ch; -+u32 au1xxx_ide_ddma_enable = 0, switch4ddma = 1; // PIO+ddma -+ -+dbdev_tab_t new_dbdev_tab_element = { DSCR_CMD0_THROTTLE, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 }; -+#endif /* end CONFIG_BLK_DEV_IDE_AU1XXX */ -+ -+void board_reset (void) -+{ -+ bcsr->resets = 0; -+} -+ -+void board_power_off (void) -+{ -+ bcsr->resets = 0xC000; -+} -+ -+void __init board_setup(void) -+{ -+ char *argptr = NULL; -+ u32 pin_func; -+ rtc_ops = &no_rtc_ops; -+ -+#if 0 -+ /* Enable PSC1 SYNC for AC97. Normaly done in audio driver, -+ * but it is board specific code, so put it here. -+ */ -+ pin_func = au_readl(SYS_PINFUNC); -+ au_sync(); -+ pin_func |= SYS_PF_MUST_BE_SET | SYS_PF_PSC1_S1; -+ au_writel(pin_func, SYS_PINFUNC); -+ -+ au_writel(0, (u32)bcsr|0x10); /* turn off pcmcia power */ -+ au_sync(); -+#endif -+ -+#if defined( CONFIG_I2C_ALGO_AU1550 ) -+ { -+ u32 freq0, clksrc; -+ -+ /* Select SMBUS in CPLD */ -+ bcsr->resets &= ~(BCSR_RESETS_PCS0MUX); -+ -+ pin_func = au_readl(SYS_PINFUNC); -+ au_sync(); -+ pin_func &= ~(3<<17 | 1<<4); -+ /* Set GPIOs correctly */ -+ pin_func |= 2<<17; -+ au_writel(pin_func, SYS_PINFUNC); -+ au_sync(); -+ -+ /* The i2c driver depends on 50Mhz clock */ -+ freq0 = au_readl(SYS_FREQCTRL0); -+ au_sync(); -+ freq0 &= ~(SYS_FC_FRDIV1_MASK | SYS_FC_FS1 | SYS_FC_FE1); -+ freq0 |= (3<<SYS_FC_FRDIV1_BIT); -+ /* 396Mhz / (3+1)*2 == 49.5Mhz */ -+ au_writel(freq0, SYS_FREQCTRL0); -+ au_sync(); -+ freq0 |= SYS_FC_FE1; -+ au_writel(freq0, SYS_FREQCTRL0); -+ au_sync(); -+ -+ clksrc = au_readl(SYS_CLKSRC); -+ au_sync(); -+ clksrc &= ~0x01f00000; -+ /* bit 22 is EXTCLK0 for PSC0 */ -+ clksrc |= (0x3 << 22); -+ au_writel(clksrc, SYS_CLKSRC); -+ au_sync(); -+ } -+#endif -+ -+#ifdef CONFIG_FB_AU1200 -+ argptr = prom_getcmdline(); -+ strcat(argptr, " video=au1200fb:"); -+#endif -+ -+#if defined(CONFIG_BLK_DEV_IDE_AU1XXX) -+ /* -+ * Iniz IDE parameters -+ */ -+ ide_ops = &au1xxx_ide_ops; -+ au1xxx_ide_irq = PB1200_IDE_INT; -+ au1xxx_ide_physbase = AU1XXX_ATA_PHYS_ADDR; -+ au1xxx_ide_virtbase = KSEG1ADDR(AU1XXX_ATA_PHYS_ADDR); -+ /* -+ * change PIO or PIO+Ddma -+ * check the GPIO-5 pin condition. pb1200:s18_dot */ -+ switch4ddma = (au_readl(SYS_PINSTATERD) & (1 << 5)) ? 1 : 0; -+#endif -+ -+ /* The Pb1200 development board uses external MUX for PSC0 to -+ support SMB/SPI. bcsr->resets bit 12: 0=SMB 1=SPI -+ */ -+#if defined(CONFIG_AU1550_PSC_SPI) && defined(CONFIG_I2C_ALGO_AU1550) -+ #error I2C and SPI are mutually exclusive. Both are physically connected to PSC0.\ -+ Refer to Pb1200/Db1200 documentation. -+#elif defined( CONFIG_AU1550_PSC_SPI ) -+ bcsr->resets |= BCSR_RESETS_PCS0MUX; -+#elif defined( CONFIG_I2C_ALGO_AU1550 ) -+ bcsr->resets &= (~BCSR_RESETS_PCS0MUX); -+#endif -+ au_sync(); -+ -+#ifdef CONFIG_MIPS_PB1200 -+ printk("AMD Alchemy Pb1200 Board\n"); -+#endif -+#ifdef CONFIG_MIPS_DB1200 -+ printk("AMD Alchemy Db1200 Board\n"); -+#endif -+ -+ /* Setup Pb1200 External Interrupt Controller */ -+ { -+ extern void (*board_init_irq)(void); -+ extern void _board_init_irq(void); -+ board_init_irq = _board_init_irq; -+ } -+} -+ -+int -+board_au1200fb_panel (void) -+{ -+ BCSR *bcsr = (BCSR *)BCSR_KSEG1_ADDR; -+ int p; -+ -+ p = bcsr->switches; -+ p >>= 8; -+ p &= 0x0F; -+ return p; -+} -+ -+int -+board_au1200fb_panel_init (void) -+{ -+ /* Apply power */ -+ BCSR *bcsr = (BCSR *)BCSR_KSEG1_ADDR; -+ bcsr->board |= (BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD | BCSR_BOARD_LCDBL); -+ return 0; -+} -+ -+int -+board_au1200fb_panel_shutdown (void) -+{ -+ /* Remove power */ -+ BCSR *bcsr = (BCSR *)BCSR_KSEG1_ADDR; -+ bcsr->board &= ~(BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD | BCSR_BOARD_LCDBL); -+ return 0; -+} -+ ---- /dev/null -+++ b/arch/mips/au1000/pb1200/init.c -@@ -0,0 +1,72 @@ -+/* -+ * -+ * BRIEF MODULE DESCRIPTION -+ * PB1200 board setup -+ * -+ * 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 SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN -+ * NO EVENT SHALL THE AUTHOR 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. -+ * -+ * You should have received a copy of the GNU General Public License along -+ * with this program; if not, write to the Free Software Foundation, Inc., -+ * 675 Mass Ave, Cambridge, MA 02139, USA. -+ */ -+ -+#include <linux/init.h> -+#include <linux/mm.h> -+#include <linux/sched.h> -+#include <linux/bootmem.h> -+#include <asm/addrspace.h> -+#include <asm/bootinfo.h> -+#include <linux/config.h> -+#include <linux/string.h> -+#include <linux/kernel.h> -+#include <linux/sched.h> -+ -+int prom_argc; -+char **prom_argv, **prom_envp; -+extern void __init prom_init_cmdline(void); -+extern char *prom_getenv(char *envname); -+ -+const char *get_system_type(void) -+{ -+ return "AMD Alchemy Au1200/Pb1200"; -+} -+ -+u32 mae_memsize = 0; -+ -+int __init prom_init(int argc, char **argv, char **envp, int *prom_vec) -+{ -+ unsigned char *memsize_str; -+ unsigned long memsize; -+ -+ prom_argc = argc; -+ prom_argv = argv; -+ prom_envp = envp; -+ -+ mips_machgroup = MACH_GROUP_ALCHEMY; -+ mips_machtype = MACH_PB1000; /* set the platform # */ -+ prom_init_cmdline(); -+ -+ memsize_str = prom_getenv("memsize"); -+ if (!memsize_str) { -+ memsize = 0x08000000; -+ } else { -+ memsize = simple_strtol(memsize_str, NULL, 0); -+ } -+ add_memory_region(0, memsize, BOOT_MEM_RAM); -+ return 0; -+} -+ ---- /dev/null -+++ b/arch/mips/au1000/pb1200/irqmap.c -@@ -0,0 +1,180 @@ -+/* -+ * BRIEF MODULE DESCRIPTION -+ * Au1xxx irq map table -+ * -+ * 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 SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN -+ * NO EVENT SHALL THE AUTHOR 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. -+ * -+ * You should have received a copy of the GNU General Public License along -+ * with this program; if not, write to the Free Software Foundation, Inc., -+ * 675 Mass Ave, Cambridge, MA 02139, USA. -+ */ -+#include <linux/errno.h> -+#include <linux/init.h> -+#include <linux/irq.h> -+#include <linux/kernel_stat.h> -+#include <linux/module.h> -+#include <linux/signal.h> -+#include <linux/sched.h> -+#include <linux/types.h> -+#include <linux/interrupt.h> -+#include <linux/ioport.h> -+#include <linux/timex.h> -+#include <linux/slab.h> -+#include <linux/random.h> -+#include <linux/delay.h> -+ -+#include <asm/bitops.h> -+#include <asm/bootinfo.h> -+#include <asm/io.h> -+#include <asm/mipsregs.h> -+#include <asm/system.h> -+#include <asm/au1000.h> -+ -+#ifdef CONFIG_MIPS_PB1200 -+#include <asm/pb1200.h> -+#endif -+ -+#ifdef CONFIG_MIPS_DB1200 -+#include <asm/db1200.h> -+#define PB1200_INT_BEGIN DB1200_INT_BEGIN -+#define PB1200_INT_END DB1200_INT_END -+#endif -+ -+au1xxx_irq_map_t au1xxx_irq_map[] = { -+ { AU1000_GPIO_7, INTC_INT_LOW_LEVEL, 0 }, // This is exteranl interrupt cascade -+}; -+ -+int au1xxx_nr_irqs = sizeof(au1xxx_irq_map)/sizeof(au1xxx_irq_map_t); -+ -+/* -+ * Support for External interrupts on the PbAu1200 Development platform. -+ */ -+static volatile int pb1200_cascade_en=0; -+ -+void pb1200_cascade_handler( int irq, void *dev_id, struct pt_regs *regs) -+{ -+ unsigned short bisr = bcsr->int_status; -+ int extirq_nr = 0; -+ -+ /* Clear all the edge interrupts. This has no effect on level */ -+ bcsr->int_status = bisr; -+ for( ; bisr; bisr &= (bisr-1) ) -+ { -+ extirq_nr = (PB1200_INT_BEGIN-1) + au_ffs(bisr); -+ /* Ack and dispatch IRQ */ -+ do_IRQ(extirq_nr,regs); -+ } -+} -+ -+inline void pb1200_enable_irq(unsigned int irq_nr) -+{ -+ bcsr->intset_mask = 1<<(irq_nr - PB1200_INT_BEGIN); -+ bcsr->intset = 1<<(irq_nr - PB1200_INT_BEGIN); -+} -+ -+inline void pb1200_disable_irq(unsigned int irq_nr) -+{ -+ bcsr->intclr_mask = 1<<(irq_nr - PB1200_INT_BEGIN); -+ bcsr->intclr = 1<<(irq_nr - PB1200_INT_BEGIN); -+} -+ -+static unsigned int pb1200_startup_irq( unsigned int irq_nr ) -+{ -+ if (++pb1200_cascade_en == 1) -+ { -+ request_irq(AU1000_GPIO_7, &pb1200_cascade_handler, -+ 0, "Pb1200 Cascade", &pb1200_cascade_handler ); -+#ifdef CONFIG_MIPS_PB1200 -+ /* We have a problem with CPLD rev3. Enable a workaround */ -+ if( ((bcsr->whoami & BCSR_WHOAMI_CPLD)>>4) <= 3) -+ { -+ printk("\nWARNING!!!\n"); -+ printk("\nWARNING!!!\n"); -+ printk("\nWARNING!!!\n"); -+ printk("\nWARNING!!!\n"); -+ printk("\nWARNING!!!\n"); -+ printk("\nWARNING!!!\n"); -+ printk("Pb1200 must be at CPLD rev4. Please have Pb1200\n"); -+ printk("updated to latest revision. This software will not\n"); -+ printk("work on anything less than CPLD rev4\n"); -+ printk("\nWARNING!!!\n"); -+ printk("\nWARNING!!!\n"); -+ printk("\nWARNING!!!\n"); -+ printk("\nWARNING!!!\n"); -+ printk("\nWARNING!!!\n"); -+ printk("\nWARNING!!!\n"); -+ while(1); -+ } -+#endif -+ } -+ pb1200_enable_irq(irq_nr); -+ return 0; -+} -+ -+static void pb1200_shutdown_irq( unsigned int irq_nr ) -+{ -+ pb1200_disable_irq(irq_nr); -+ if (--pb1200_cascade_en == 0) -+ { -+ free_irq(AU1000_GPIO_7,&pb1200_cascade_handler ); -+ } -+ return; -+} -+ -+static inline void pb1200_mask_and_ack_irq(unsigned int irq_nr) -+{ -+ pb1200_disable_irq( irq_nr ); -+} -+ -+static void pb1200_end_irq(unsigned int irq_nr) -+{ -+ if (!(irq_desc[irq_nr].status & (IRQ_DISABLED|IRQ_INPROGRESS))) { -+ pb1200_enable_irq(irq_nr); -+ } -+} -+ -+static struct hw_interrupt_type external_irq_type = -+{ -+#ifdef CONFIG_MIPS_PB1200 -+ "Pb1200 Ext", -+#endif -+#ifdef CONFIG_MIPS_DB1200 -+ "Db1200 Ext", -+#endif -+ pb1200_startup_irq, -+ pb1200_shutdown_irq, -+ pb1200_enable_irq, -+ pb1200_disable_irq, -+ pb1200_mask_and_ack_irq, -+ pb1200_end_irq, -+ NULL -+}; -+ -+void _board_init_irq(void) -+{ -+ int irq_nr; -+ -+ for (irq_nr = PB1200_INT_BEGIN; irq_nr <= PB1200_INT_END; irq_nr++) -+ { -+ irq_desc[irq_nr].handler = &external_irq_type; -+ pb1200_disable_irq(irq_nr); -+ } -+ -+ /* GPIO_7 can not be hooked here, so it is hooked upon first -+ request of any source attached to the cascade */ -+} -+ ---- /dev/null -+++ b/arch/mips/au1000/pb1200/Makefile -@@ -0,0 +1,25 @@ -+# -+# Copyright 2000 MontaVista Software Inc. -+# Author: MontaVista Software, Inc. -+# ppopov@mvista.com or source@mvista.com -+# -+# Makefile for the Alchemy Semiconductor PB1000 board. -+# -+# Note! Dependencies are done automagically by 'make dep', which also -+# removes any old dependencies. DON'T put your own dependencies here -+# unless it's something special (ie not a .c file). -+# -+ -+USE_STANDARD_AS_RULE := true -+ -+O_TARGET := pb1200.o -+ -+obj-y := init.o board_setup.o irqmap.o -+ -+ifdef CONFIG_MMC -+obj-y += mmc_support.o -+export-objs +=mmc_support.o -+endif -+ -+ -+include $(TOPDIR)/Rules.make ---- /dev/null -+++ b/arch/mips/au1000/pb1200/mmc_support.c -@@ -0,0 +1,141 @@ -+/* -+ * BRIEF MODULE DESCRIPTION -+ * -+ * MMC support routines for PB1200. -+ * -+ * -+ * Copyright (c) 2003-2004 Embedded Edge, LLC. -+ * Author: Embedded Edge, LLC. -+ * Contact: dan@embeddededge.com -+ * -+ * This program is free software; you can redistribute it and/or modify it -+ * under the terms of the GNU General Public License as published by the -+ * Free Software Foundation; either version 2 of the License, or (at your -+ * option) any later version. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN -+ * NO EVENT SHALL THE AUTHOR 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. -+ * -+ * You should have received a copy of the GNU General Public License along -+ * with this program; if not, write to the Free Software Foundation, Inc., -+ * 675 Mass Ave, Cambridge, MA 02139, USA. -+ * -+ */ -+ -+ -+#include <linux/config.h> -+#include <linux/kernel.h> -+#include <linux/module.h> -+#include <linux/init.h> -+ -+#include <asm/irq.h> -+#include <asm/au1000.h> -+#include <asm/au1100_mmc.h> -+ -+#ifdef CONFIG_MIPS_PB1200 -+#include <asm/pb1200.h> -+#endif -+ -+#ifdef CONFIG_MIPS_DB1200 -+/* NOTE: DB1200 only has SD0 pinned out and usable */ -+#include <asm/db1200.h> -+#endif -+ -+/* SD/MMC controller support functions */ -+ -+/* -+ * Detect card. -+ */ -+void mmc_card_inserted(int socket, int *result) -+{ -+ u16 mask; -+ -+ if (socket) -+#ifdef CONFIG_MIPS_DB1200 -+ mask = 0; -+#else -+ mask = BCSR_INT_SD1INSERT; -+#endif -+ else -+ mask = BCSR_INT_SD0INSERT; -+ -+ *result = ((bcsr->sig_status & mask) != 0); -+} -+ -+/* -+ * Check card write protection. -+ */ -+void mmc_card_writable(int socket, int *result) -+{ -+ u16 mask; -+ -+ if (socket) -+#ifdef CONFIG_MIPS_DB1200 -+ mask = 0; -+#else -+ mask = BCSR_STATUS_SD1WP; -+#endif -+ else -+ mask = BCSR_STATUS_SD0WP; -+ -+ /* low means card writable */ -+ if (!(bcsr->status & mask)) { -+ *result = 1; -+ } else { -+ *result = 0; -+ } -+} -+ -+/* -+ * Apply power to card slot. -+ */ -+void mmc_power_on(int socket) -+{ -+ u16 mask; -+ -+ if (socket) -+#ifdef CONFIG_MIPS_DB1200 -+ mask = 0; -+#else -+ mask = BCSR_BOARD_SD1PWR; -+#endif -+ else -+ mask = BCSR_BOARD_SD0PWR; -+ -+ bcsr->board |= mask; -+ au_sync_delay(1); -+} -+ -+/* -+ * Remove power from card slot. -+ */ -+void mmc_power_off(int socket) -+{ -+ u16 mask; -+ -+ if (socket) -+#ifdef CONFIG_MIPS_DB1200 -+ mask = 0; -+#else -+ mask = BCSR_BOARD_SD1PWR; -+#endif -+ else -+ mask = BCSR_BOARD_SD0PWR; -+ -+ bcsr->board &= ~mask; -+ au_sync_delay(1); -+} -+ -+EXPORT_SYMBOL(mmc_card_inserted); -+EXPORT_SYMBOL(mmc_card_writable); -+EXPORT_SYMBOL(mmc_power_on); -+EXPORT_SYMBOL(mmc_power_off); -+ ---- a/arch/mips/au1000/pb1500/board_setup.c -+++ b/arch/mips/au1000/pb1500/board_setup.c -@@ -62,6 +62,10 @@ void board_reset (void) - au_writel(0x00000000, 0xAE00001C); - } - -+void board_power_off (void) -+{ -+} -+ - void __init board_setup(void) - { - u32 pin_func; ---- a/arch/mips/au1000/pb1550/board_setup.c -+++ b/arch/mips/au1000/pb1550/board_setup.c -@@ -48,12 +48,31 @@ - - extern struct rtc_ops no_rtc_ops; - -+#if defined(CONFIG_BLK_DEV_IDE_AU1XXX) -+extern struct ide_ops *ide_ops; -+extern struct ide_ops au1xxx_ide_ops; -+extern u32 au1xxx_ide_virtbase; -+extern u64 au1xxx_ide_physbase; -+extern unsigned int au1xxx_ide_irq; -+ -+u32 au1xxx_ide_ddma_enable = 0, switch4ddma = 1; // PIO+ddma -+#endif /* end CONFIG_BLK_DEV_IDE_AU1XXX */ -+ - void board_reset (void) - { - /* Hit BCSR.SYSTEM_CONTROL[SW_RST] */ - au_writew(au_readw(0xAF00001C) & ~(1<<15), 0xAF00001C); - } - -+void board_power_off (void) -+{ -+ /* power off system */ -+ printk("\n** Powering off Pb1550\n"); -+ au_writew(au_readw(0xAF00001C) | (3<<14), 0xAF00001C); -+ au_sync(); -+ while(1); /* should not get here */ -+} -+ - void __init board_setup(void) - { - u32 pin_func; -@@ -78,5 +97,36 @@ void __init board_setup(void) - au_writel(0, (u32)bcsr|0x10); /* turn off pcmcia power */ - au_sync(); - -+#if defined(CONFIG_AU1XXX_SMC91111) -+#if defined(CONFIG_BLK_DEV_IDE_AU1XXX) -+#error "Resource conflict occured. Disable either Ethernet or IDE daughter card." -+#else -+#define CPLD_CONTROL (0xAF00000C) -+ { -+ /* set up the Static Bus timing */ -+ /* only 396Mhz */ -+ /* reset the DC */ -+ au_writew(au_readw(CPLD_CONTROL) | 0x0f, CPLD_CONTROL); -+ au_writel(0x00010003, MEM_STCFG0); -+ au_writel(0x000c00c0, MEM_STCFG2); -+ au_writel(0x85E1900D, MEM_STTIME2); -+ } -+#endif -+#endif /* end CONFIG_SMC91111 */ -+ -+#if defined(CONFIG_BLK_DEV_IDE_AU1XXX) -+ /* -+ * Iniz IDE parameters -+ */ -+ ide_ops = &au1xxx_ide_ops; -+ au1xxx_ide_irq = DAUGHTER_CARD_IRQ;; -+ au1xxx_ide_physbase = AU1XXX_ATA_PHYS_ADDR; -+ au1xxx_ide_virtbase = KSEG1ADDR(AU1XXX_ATA_PHYS_ADDR); -+ /* -+ * change PIO or PIO+Ddma -+ * check the GPIO-6 pin condition. pb1550:s15_dot -+ */ -+ switch4ddma = (au_readl(SYS_PINSTATERD) & (1 << 6)) ? 1 : 0; -+#endif - printk("AMD Alchemy Pb1550 Board\n"); - } ---- a/arch/mips/au1000/pb1550/irqmap.c -+++ b/arch/mips/au1000/pb1550/irqmap.c -@@ -50,6 +50,9 @@ - au1xxx_irq_map_t au1xxx_irq_map[] = { - { AU1000_GPIO_0, INTC_INT_LOW_LEVEL, 0 }, - { AU1000_GPIO_1, INTC_INT_LOW_LEVEL, 0 }, -+#ifdef CONFIG_AU1XXX_SMC91111 -+ { AU1000_GPIO_3, INTC_INT_LOW_LEVEL, 0 }, -+#endif - }; - - int au1xxx_nr_irqs = sizeof(au1xxx_irq_map)/sizeof(au1xxx_irq_map_t); ---- a/arch/mips/config-shared.in -+++ b/arch/mips/config-shared.in -@@ -21,16 +21,19 @@ mainmenu_option next_comment - comment 'Machine selection' - dep_bool 'Support for Acer PICA 1 chipset (EXPERIMENTAL)' CONFIG_ACER_PICA_61 $CONFIG_EXPERIMENTAL - dep_bool 'Support for Alchemy Bosporus board' CONFIG_MIPS_BOSPORUS $CONFIG_MIPS32 -+dep_bool 'Support for FIC Multimedia Player board' CONFIG_MIPS_FICMMP $CONFIG_MIPS32 - dep_bool 'Support for Alchemy Mirage board' CONFIG_MIPS_MIRAGE $CONFIG_MIPS32 - dep_bool 'Support for Alchemy Db1000 board' CONFIG_MIPS_DB1000 $CONFIG_MIPS32 - dep_bool 'Support for Alchemy Db1100 board' CONFIG_MIPS_DB1100 $CONFIG_MIPS32 - dep_bool 'Support for Alchemy Db1500 board' CONFIG_MIPS_DB1500 $CONFIG_MIPS32 - dep_bool 'Support for Alchemy Db1550 board' CONFIG_MIPS_DB1550 $CONFIG_MIPS32 -+dep_bool 'Support for Alchemy Db1200 board' CONFIG_MIPS_DB1200 $CONFIG_MIPS32 - dep_bool 'Support for Alchemy PB1000 board' CONFIG_MIPS_PB1000 $CONFIG_MIPS32 - dep_bool 'Support for Alchemy PB1100 board' CONFIG_MIPS_PB1100 $CONFIG_MIPS32 - dep_bool 'Support for Alchemy PB1500 board' CONFIG_MIPS_PB1500 $CONFIG_MIPS32 --dep_bool 'Support for Alchemy Hydrogen3 board' CONFIG_MIPS_HYDROGEN3 $CONFIG_MIPS32 - dep_bool 'Support for Alchemy PB1550 board' CONFIG_MIPS_PB1550 $CONFIG_MIPS32 -+dep_bool 'Support for Alchemy PB1200 board' CONFIG_MIPS_PB1200 $CONFIG_MIPS32 -+dep_bool 'Support for Alchemy Hydrogen3 board' CONFIG_MIPS_HYDROGEN3 $CONFIG_MIPS32 - dep_bool 'Support for MyCable XXS1500 board' CONFIG_MIPS_XXS1500 $CONFIG_MIPS32 - dep_bool 'Support for 4G Systems MTX-1 board' CONFIG_MIPS_MTX1 $CONFIG_MIPS32 - dep_bool 'Support for Cogent CSB250 board' CONFIG_COGENT_CSB250 $CONFIG_MIPS32 -@@ -249,6 +252,12 @@ if [ "$CONFIG_MIPS_MIRAGE" = "y" ]; then - define_bool CONFIG_PC_KEYB y - define_bool CONFIG_NONCOHERENT_IO y - fi -+if [ "$CONFIG_MIPS_FICMMP" = "y" ]; then -+ define_bool CONFIG_SOC_AU1X00 y -+ define_bool CONFIG_SOC_AU1200 y -+ define_bool CONFIG_NONCOHERENT_IO y -+ define_bool CONFIG_PC_KEYB y -+fi - if [ "$CONFIG_MIPS_BOSPORUS" = "y" ]; then - define_bool CONFIG_SOC_AU1X00 y - define_bool CONFIG_SOC_AU1500 y -@@ -263,6 +272,12 @@ if [ "$CONFIG_MIPS_PB1000" = "y" ]; then - define_bool CONFIG_SWAP_IO_SPACE_W y - define_bool CONFIG_SWAP_IO_SPACE_L y - fi -+if [ "$CONFIG_MIPS_PB1500" = "y" ]; then -+ define_bool CONFIG_SOC_AU1X00 y -+ define_bool CONFIG_SOC_AU1500 y -+ define_bool CONFIG_NONCOHERENT_IO y -+ define_bool CONFIG_PC_KEYB y -+fi - if [ "$CONFIG_MIPS_PB1100" = "y" ]; then - define_bool CONFIG_SOC_AU1X00 y - define_bool CONFIG_SOC_AU1100 y -@@ -271,9 +286,15 @@ if [ "$CONFIG_MIPS_PB1100" = "y" ]; then - define_bool CONFIG_SWAP_IO_SPACE_W y - define_bool CONFIG_SWAP_IO_SPACE_L y - fi --if [ "$CONFIG_MIPS_PB1500" = "y" ]; then -+if [ "$CONFIG_MIPS_PB1550" = "y" ]; then - define_bool CONFIG_SOC_AU1X00 y -- define_bool CONFIG_SOC_AU1500 y -+ define_bool CONFIG_SOC_AU1550 y -+ define_bool CONFIG_NONCOHERENT_IO n -+ define_bool CONFIG_PC_KEYB y -+fi -+if [ "$CONFIG_MIPS_PB1200" = "y" ]; then -+ define_bool CONFIG_SOC_AU1X00 y -+ define_bool CONFIG_SOC_AU1200 y - define_bool CONFIG_NONCOHERENT_IO y - define_bool CONFIG_PC_KEYB y - fi -@@ -290,18 +311,24 @@ if [ "$CONFIG_MIPS_DB1500" = "y" ]; then - define_bool CONFIG_NONCOHERENT_IO y - define_bool CONFIG_PC_KEYB y - fi -+if [ "$CONFIG_MIPS_DB1100" = "y" ]; then -+ define_bool CONFIG_SOC_AU1X00 y -+ define_bool CONFIG_SOC_AU1100 y -+ define_bool CONFIG_NONCOHERENT_IO y -+ define_bool CONFIG_PC_KEYB y -+ define_bool CONFIG_SWAP_IO_SPACE y -+fi - if [ "$CONFIG_MIPS_DB1550" = "y" ]; then - define_bool CONFIG_SOC_AU1X00 y - define_bool CONFIG_SOC_AU1550 y - define_bool CONFIG_NONCOHERENT_IO y - define_bool CONFIG_PC_KEYB y - fi --if [ "$CONFIG_MIPS_DB1100" = "y" ]; then -+if [ "$CONFIG_MIPS_DB1200" = "y" ]; then - define_bool CONFIG_SOC_AU1X00 y -- define_bool CONFIG_SOC_AU1100 y -+ define_bool CONFIG_SOC_AU1200 y - define_bool CONFIG_NONCOHERENT_IO y - define_bool CONFIG_PC_KEYB y -- define_bool CONFIG_SWAP_IO_SPACE y - fi - if [ "$CONFIG_MIPS_HYDROGEN3" = "y" ]; then - define_bool CONFIG_SOC_AU1X00 y -@@ -327,12 +354,6 @@ if [ "$CONFIG_COGENT_CSB250" = "y" ]; th - define_bool CONFIG_NONCOHERENT_IO y - define_bool CONFIG_PC_KEYB y - fi --if [ "$CONFIG_MIPS_PB1550" = "y" ]; then -- define_bool CONFIG_SOC_AU1X00 y -- define_bool CONFIG_SOC_AU1550 y -- define_bool CONFIG_NONCOHERENT_IO n -- define_bool CONFIG_PC_KEYB y --fi - if [ "$CONFIG_MIPS_COBALT" = "y" ]; then - define_bool CONFIG_BOOT_ELF32 y - define_bool CONFIG_COBALT_LCD y -@@ -729,6 +750,13 @@ if [ "$CONFIG_ACER_PICA_61" = "y" -o \ - "$CONFIG_MIPS_PB1000" = "y" -o \ - "$CONFIG_MIPS_PB1100" = "y" -o \ - "$CONFIG_MIPS_PB1500" = "y" -o \ -+ "$CONFIG_MIPS_PB1550" = "y" -o \ -+ "$CONFIG_MIPS_PB1200" = "y" -o \ -+ "$CONFIG_MIPS_DB1000" = "y" -o \ -+ "$CONFIG_MIPS_DB1100" = "y" -o \ -+ "$CONFIG_MIPS_DB1500" = "y" -o \ -+ "$CONFIG_MIPS_DB1550" = "y" -o \ -+ "$CONFIG_MIPS_DB1200" = "y" -o \ - "$CONFIG_NEC_OSPREY" = "y" -o \ - "$CONFIG_NEC_EAGLE" = "y" -o \ - "$CONFIG_NINO" = "y" -o \ ---- a/arch/mips/defconfig -+++ b/arch/mips/defconfig -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -235,11 +235,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -319,9 +314,11 @@ CONFIG_SGIWD93_SCSI=y - # CONFIG_SCSI_MEGARAID is not set - # CONFIG_SCSI_MEGARAID2 is not set - # CONFIG_SCSI_SATA is not set -+# CONFIG_SCSI_SATA_AHCI is not set - # CONFIG_SCSI_SATA_SVW is not set - # CONFIG_SCSI_ATA_PIIX is not set - # CONFIG_SCSI_SATA_NV is not set -+# CONFIG_SCSI_SATA_QSTOR is not set - # CONFIG_SCSI_SATA_PROMISE is not set - # CONFIG_SCSI_SATA_SX4 is not set - # CONFIG_SCSI_SATA_SIL is not set -@@ -465,7 +462,6 @@ CONFIG_VT_CONSOLE=y - # CONFIG_SERIAL is not set - # CONFIG_SERIAL_EXTENDED is not set - # CONFIG_SERIAL_NONSTANDARD is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips/defconfig-atlas -+++ b/arch/mips/defconfig-atlas -@@ -28,8 +28,8 @@ CONFIG_EXPERIMENTAL=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -235,11 +235,6 @@ CONFIG_IP_PNP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -317,9 +312,11 @@ CONFIG_SD_EXTRA_DEVS=40 - # CONFIG_SCSI_MEGARAID is not set - # CONFIG_SCSI_MEGARAID2 is not set - # CONFIG_SCSI_SATA is not set -+# CONFIG_SCSI_SATA_AHCI is not set - # CONFIG_SCSI_SATA_SVW is not set - # CONFIG_SCSI_ATA_PIIX is not set - # CONFIG_SCSI_SATA_NV is not set -+# CONFIG_SCSI_SATA_QSTOR is not set - # CONFIG_SCSI_SATA_PROMISE is not set - # CONFIG_SCSI_SATA_SX4 is not set - # CONFIG_SCSI_SATA_SIL is not set -@@ -528,7 +525,6 @@ CONFIG_SERIAL=y - CONFIG_SERIAL_CONSOLE=y - # CONFIG_SERIAL_EXTENDED is not set - # CONFIG_SERIAL_NONSTANDARD is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips/defconfig-bosporus -+++ b/arch/mips/defconfig-bosporus -@@ -30,8 +30,8 @@ CONFIG_MIPS_BOSPORUS=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -208,9 +208,7 @@ CONFIG_MTD_CFI_AMDSTD=y - CONFIG_MTD_BOSPORUS=y - # CONFIG_MTD_XXS1500 is not set - # CONFIG_MTD_MTX1 is not set --# CONFIG_MTD_DB1X00 is not set - # CONFIG_MTD_PB1550 is not set --# CONFIG_MTD_HYDROGEN3 is not set - # CONFIG_MTD_MIRAGE is not set - # CONFIG_MTD_CSTM_MIPS_IXX is not set - # CONFIG_MTD_OCELOT is not set -@@ -229,7 +227,6 @@ CONFIG_MTD_BOSPORUS=y - # - # Disk-On-Chip Device Drivers - # --# CONFIG_MTD_DOC1000 is not set - # CONFIG_MTD_DOC2000 is not set - # CONFIG_MTD_DOC2001 is not set - # CONFIG_MTD_DOCPROBE is not set -@@ -373,11 +370,6 @@ CONFIG_IP_NF_MANGLE=m - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -457,9 +449,11 @@ CONFIG_SCSI_CONSTANTS=y - # CONFIG_SCSI_MEGARAID is not set - # CONFIG_SCSI_MEGARAID2 is not set - # CONFIG_SCSI_SATA is not set -+# CONFIG_SCSI_SATA_AHCI is not set - # CONFIG_SCSI_SATA_SVW is not set - # CONFIG_SCSI_ATA_PIIX is not set - # CONFIG_SCSI_SATA_NV is not set -+# CONFIG_SCSI_SATA_QSTOR is not set - # CONFIG_SCSI_SATA_PROMISE is not set - # CONFIG_SCSI_SATA_SX4 is not set - # CONFIG_SCSI_SATA_SIL is not set -@@ -681,7 +675,6 @@ CONFIG_AU1X00_SERIAL_CONSOLE=y - # CONFIG_AU1X00_USB_TTY is not set - # CONFIG_AU1X00_USB_RAW is not set - # CONFIG_TXX927_SERIAL is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips/defconfig-capcella -+++ b/arch/mips/defconfig-capcella -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -228,11 +228,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -472,7 +467,6 @@ CONFIG_SERIAL=y - CONFIG_SERIAL_CONSOLE=y - # CONFIG_SERIAL_EXTENDED is not set - # CONFIG_SERIAL_NONSTANDARD is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - # CONFIG_VR41XX_KIU is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 ---- a/arch/mips/defconfig-cobalt -+++ b/arch/mips/defconfig-cobalt -@@ -28,8 +28,8 @@ CONFIG_EXPERIMENTAL=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -222,11 +222,6 @@ CONFIG_INET=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -505,7 +500,6 @@ CONFIG_SERIAL=y - CONFIG_SERIAL_CONSOLE=y - # CONFIG_SERIAL_EXTENDED is not set - # CONFIG_SERIAL_NONSTANDARD is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=16 - ---- a/arch/mips/defconfig-csb250 -+++ b/arch/mips/defconfig-csb250 -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - CONFIG_COGENT_CSB250=y -@@ -268,11 +268,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -556,7 +551,6 @@ CONFIG_AU1X00_SERIAL_CONSOLE=y - # CONFIG_AU1X00_USB_TTY is not set - # CONFIG_AU1X00_USB_RAW is not set - # CONFIG_TXX927_SERIAL is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips/defconfig-db1000 -+++ b/arch/mips/defconfig-db1000 -@@ -30,8 +30,8 @@ CONFIG_MIPS_DB1000=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -214,11 +214,7 @@ CONFIG_MTD_CFI_AMDSTD=y - # CONFIG_MTD_BOSPORUS is not set - # CONFIG_MTD_XXS1500 is not set - # CONFIG_MTD_MTX1 is not set --CONFIG_MTD_DB1X00=y --CONFIG_MTD_DB1X00_BOOT=y --CONFIG_MTD_DB1X00_USER=y - # CONFIG_MTD_PB1550 is not set --# CONFIG_MTD_HYDROGEN3 is not set - # CONFIG_MTD_MIRAGE is not set - # CONFIG_MTD_CSTM_MIPS_IXX is not set - # CONFIG_MTD_OCELOT is not set -@@ -237,7 +233,6 @@ CONFIG_MTD_DB1X00_USER=y - # - # Disk-On-Chip Device Drivers - # --# CONFIG_MTD_DOC1000 is not set - # CONFIG_MTD_DOC2000 is not set - # CONFIG_MTD_DOC2001 is not set - # CONFIG_MTD_DOCPROBE is not set -@@ -342,11 +337,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -636,7 +626,6 @@ CONFIG_AU1X00_SERIAL_CONSOLE=y - # CONFIG_AU1X00_USB_TTY is not set - # CONFIG_AU1X00_USB_RAW is not set - # CONFIG_TXX927_SERIAL is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips/defconfig-db1100 -+++ b/arch/mips/defconfig-db1100 -@@ -30,8 +30,8 @@ CONFIG_MIPS_DB1100=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -214,11 +214,7 @@ CONFIG_MTD_CFI_AMDSTD=y - # CONFIG_MTD_BOSPORUS is not set - # CONFIG_MTD_XXS1500 is not set - # CONFIG_MTD_MTX1 is not set --CONFIG_MTD_DB1X00=y --# CONFIG_MTD_DB1X00_BOOT is not set --CONFIG_MTD_DB1X00_USER=y - # CONFIG_MTD_PB1550 is not set --# CONFIG_MTD_HYDROGEN3 is not set - # CONFIG_MTD_MIRAGE is not set - # CONFIG_MTD_CSTM_MIPS_IXX is not set - # CONFIG_MTD_OCELOT is not set -@@ -237,7 +233,6 @@ CONFIG_MTD_DB1X00_USER=y - # - # Disk-On-Chip Device Drivers - # --# CONFIG_MTD_DOC1000 is not set - # CONFIG_MTD_DOC2000 is not set - # CONFIG_MTD_DOC2001 is not set - # CONFIG_MTD_DOCPROBE is not set -@@ -342,11 +337,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -636,7 +626,6 @@ CONFIG_AU1X00_SERIAL_CONSOLE=y - # CONFIG_AU1X00_USB_TTY is not set - # CONFIG_AU1X00_USB_RAW is not set - # CONFIG_TXX927_SERIAL is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - -@@ -884,6 +873,7 @@ CONFIG_DUMMY_CONSOLE=y - # CONFIG_FB_PM2 is not set - # CONFIG_FB_PM3 is not set - # CONFIG_FB_CYBER2000 is not set -+CONFIG_FB_AU1100=y - # CONFIG_FB_MATROX is not set - # CONFIG_FB_ATY is not set - # CONFIG_FB_RADEON is not set -@@ -895,7 +885,6 @@ CONFIG_DUMMY_CONSOLE=y - # CONFIG_FB_VOODOO1 is not set - # CONFIG_FB_TRIDENT is not set - # CONFIG_FB_E1356 is not set --CONFIG_FB_AU1100=y - # CONFIG_FB_IT8181 is not set - # CONFIG_FB_VIRTUAL is not set - CONFIG_FBCON_ADVANCED=y ---- /dev/null -+++ b/arch/mips/defconfig-db1200 -@@ -0,0 +1,1032 @@ -+# -+# Automatically generated make config: don't edit -+# -+CONFIG_MIPS=y -+CONFIG_MIPS32=y -+# CONFIG_MIPS64 is not set -+ -+# -+# Code maturity level options -+# -+CONFIG_EXPERIMENTAL=y -+ -+# -+# Loadable module support -+# -+CONFIG_MODULES=y -+# CONFIG_MODVERSIONS is not set -+CONFIG_KMOD=y -+ -+# -+# Machine selection -+# -+# CONFIG_ACER_PICA_61 is not set -+# CONFIG_MIPS_BOSPORUS is not set -+# CONFIG_MIPS_MIRAGE is not set -+# CONFIG_MIPS_DB1000 is not set -+# CONFIG_MIPS_DB1100 is not set -+# CONFIG_MIPS_DB1500 is not set -+# CONFIG_MIPS_DB1550 is not set -+# CONFIG_MIPS_PB1000 is not set -+# CONFIG_MIPS_PB1100 is not set -+# CONFIG_MIPS_PB1500 is not set -+# CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set -+# CONFIG_MIPS_XXS1500 is not set -+# CONFIG_MIPS_MTX1 is not set -+# CONFIG_COGENT_CSB250 is not set -+# CONFIG_BAGET_MIPS is not set -+# CONFIG_CASIO_E55 is not set -+# CONFIG_MIPS_COBALT is not set -+# CONFIG_DECSTATION is not set -+# CONFIG_MIPS_EV64120 is not set -+# CONFIG_MIPS_EV96100 is not set -+# CONFIG_MIPS_IVR is not set -+# CONFIG_HP_LASERJET is not set -+# CONFIG_IBM_WORKPAD is not set -+# CONFIG_LASAT is not set -+# CONFIG_MIPS_ITE8172 is not set -+# CONFIG_MIPS_ATLAS is not set -+# CONFIG_MIPS_MAGNUM_4000 is not set -+# CONFIG_MIPS_MALTA is not set -+# CONFIG_MIPS_SEAD is not set -+# CONFIG_MOMENCO_OCELOT is not set -+# CONFIG_MOMENCO_OCELOT_G is not set -+# CONFIG_MOMENCO_OCELOT_C is not set -+# CONFIG_MOMENCO_JAGUAR_ATX is not set -+# CONFIG_PMC_BIG_SUR is not set -+# CONFIG_PMC_STRETCH is not set -+# CONFIG_PMC_YOSEMITE is not set -+# CONFIG_DDB5074 is not set -+# CONFIG_DDB5476 is not set -+# CONFIG_DDB5477 is not set -+# CONFIG_NEC_OSPREY is not set -+# CONFIG_NEC_EAGLE is not set -+# CONFIG_OLIVETTI_M700 is not set -+# CONFIG_NINO is not set -+# CONFIG_SGI_IP22 is not set -+# CONFIG_SGI_IP27 is not set -+# CONFIG_SIBYTE_SB1xxx_SOC is not set -+# CONFIG_SNI_RM200_PCI is not set -+# CONFIG_TANBAC_TB0226 is not set -+# CONFIG_TANBAC_TB0229 is not set -+# CONFIG_TOSHIBA_JMR3927 is not set -+# CONFIG_TOSHIBA_RBTX4927 is not set -+# CONFIG_VICTOR_MPC30X is not set -+# CONFIG_ZAO_CAPCELLA is not set -+# CONFIG_HIGHMEM is not set -+CONFIG_RWSEM_GENERIC_SPINLOCK=y -+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set -+# CONFIG_MIPS_AU1000 is not set -+ -+# -+# CPU selection -+# -+CONFIG_CPU_MIPS32=y -+# CONFIG_CPU_MIPS64 is not set -+# CONFIG_CPU_R3000 is not set -+# CONFIG_CPU_TX39XX is not set -+# CONFIG_CPU_VR41XX is not set -+# CONFIG_CPU_R4300 is not set -+# CONFIG_CPU_R4X00 is not set -+# CONFIG_CPU_TX49XX is not set -+# CONFIG_CPU_R5000 is not set -+# CONFIG_CPU_R5432 is not set -+# CONFIG_CPU_R6000 is not set -+# CONFIG_CPU_NEVADA is not set -+# CONFIG_CPU_R8000 is not set -+# CONFIG_CPU_R10000 is not set -+# CONFIG_CPU_RM7000 is not set -+# CONFIG_CPU_RM9000 is not set -+# CONFIG_CPU_SB1 is not set -+CONFIG_PAGE_SIZE_4KB=y -+# CONFIG_PAGE_SIZE_16KB is not set -+# CONFIG_PAGE_SIZE_64KB is not set -+CONFIG_CPU_HAS_PREFETCH=y -+# CONFIG_VTAG_ICACHE is not set -+CONFIG_64BIT_PHYS_ADDR=y -+# CONFIG_CPU_ADVANCED is not set -+CONFIG_CPU_HAS_LLSC=y -+# CONFIG_CPU_HAS_LLDSCD is not set -+# CONFIG_CPU_HAS_WB is not set -+CONFIG_CPU_HAS_SYNC=y -+ -+# -+# General setup -+# -+CONFIG_CPU_LITTLE_ENDIAN=y -+# CONFIG_BUILD_ELF64 is not set -+CONFIG_NET=y -+CONFIG_PCI=y -+CONFIG_PCI_NEW=y -+CONFIG_PCI_AUTO=y -+# CONFIG_PCI_NAMES is not set -+# CONFIG_ISA is not set -+# CONFIG_TC is not set -+# CONFIG_MCA is not set -+# CONFIG_SBUS is not set -+CONFIG_HOTPLUG=y -+ -+# -+# PCMCIA/CardBus support -+# -+CONFIG_PCMCIA=m -+# CONFIG_CARDBUS is not set -+# CONFIG_TCIC is not set -+# CONFIG_I82092 is not set -+# CONFIG_I82365 is not set -+ -+# -+# PCI Hotplug Support -+# -+# CONFIG_HOTPLUG_PCI is not set -+# CONFIG_HOTPLUG_PCI_COMPAQ is not set -+# CONFIG_HOTPLUG_PCI_COMPAQ_NVRAM is not set -+# CONFIG_HOTPLUG_PCI_SHPC is not set -+# CONFIG_HOTPLUG_PCI_SHPC_POLL_EVENT_MODE is not set -+# CONFIG_HOTPLUG_PCI_PCIE is not set -+# CONFIG_HOTPLUG_PCI_PCIE_POLL_EVENT_MODE is not set -+CONFIG_SYSVIPC=y -+# CONFIG_BSD_PROCESS_ACCT is not set -+CONFIG_SYSCTL=y -+CONFIG_KCORE_ELF=y -+# CONFIG_KCORE_AOUT is not set -+# CONFIG_BINFMT_AOUT is not set -+CONFIG_BINFMT_ELF=y -+# CONFIG_MIPS32_COMPAT is not set -+# CONFIG_MIPS32_O32 is not set -+# CONFIG_MIPS32_N32 is not set -+# CONFIG_BINFMT_ELF32 is not set -+# CONFIG_BINFMT_MISC is not set -+# CONFIG_OOM_KILLER is not set -+CONFIG_CMDLINE_BOOL=y -+CONFIG_CMDLINE="mem=96M" -+ -+# -+# Memory Technology Devices (MTD) -+# -+# CONFIG_MTD is not set -+ -+# -+# Parallel port support -+# -+# CONFIG_PARPORT is not set -+ -+# -+# Plug and Play configuration -+# -+# CONFIG_PNP is not set -+# CONFIG_ISAPNP is not set -+ -+# -+# Block devices -+# -+# CONFIG_BLK_DEV_FD is not set -+# CONFIG_BLK_DEV_XD is not set -+# CONFIG_PARIDE is not set -+# CONFIG_BLK_CPQ_DA is not set -+# CONFIG_BLK_CPQ_CISS_DA is not set -+# CONFIG_CISS_SCSI_TAPE is not set -+# CONFIG_CISS_MONITOR_THREAD is not set -+# CONFIG_BLK_DEV_DAC960 is not set -+# CONFIG_BLK_DEV_UMEM is not set -+# CONFIG_BLK_DEV_SX8 is not set -+CONFIG_BLK_DEV_LOOP=y -+# CONFIG_BLK_DEV_NBD is not set -+# CONFIG_BLK_DEV_RAM is not set -+# CONFIG_BLK_DEV_INITRD is not set -+# CONFIG_BLK_STATS is not set -+ -+# -+# Multi-device support (RAID and LVM) -+# -+# CONFIG_MD is not set -+# CONFIG_BLK_DEV_MD is not set -+# CONFIG_MD_LINEAR is not set -+# CONFIG_MD_RAID0 is not set -+# CONFIG_MD_RAID1 is not set -+# CONFIG_MD_RAID5 is not set -+# CONFIG_MD_MULTIPATH is not set -+# CONFIG_BLK_DEV_LVM is not set -+ -+# -+# Networking options -+# -+CONFIG_PACKET=y -+# CONFIG_PACKET_MMAP is not set -+# CONFIG_NETLINK_DEV is not set -+CONFIG_NETFILTER=y -+# CONFIG_NETFILTER_DEBUG is not set -+CONFIG_FILTER=y -+CONFIG_UNIX=y -+CONFIG_INET=y -+CONFIG_IP_MULTICAST=y -+# CONFIG_IP_ADVANCED_ROUTER is not set -+CONFIG_IP_PNP=y -+# CONFIG_IP_PNP_DHCP is not set -+CONFIG_IP_PNP_BOOTP=y -+# CONFIG_IP_PNP_RARP is not set -+# CONFIG_NET_IPIP is not set -+# CONFIG_NET_IPGRE is not set -+# CONFIG_IP_MROUTE is not set -+# CONFIG_ARPD is not set -+# CONFIG_INET_ECN is not set -+# CONFIG_SYN_COOKIES is not set -+ -+# -+# IP: Netfilter Configuration -+# -+# CONFIG_IP_NF_CONNTRACK is not set -+# CONFIG_IP_NF_QUEUE is not set -+# CONFIG_IP_NF_IPTABLES is not set -+# CONFIG_IP_NF_ARPTABLES is not set -+# CONFIG_IP_NF_COMPAT_IPCHAINS is not set -+# CONFIG_IP_NF_COMPAT_IPFWADM is not set -+ -+# -+# IP: Virtual Server Configuration -+# -+# CONFIG_IP_VS is not set -+# CONFIG_IPV6 is not set -+# CONFIG_KHTTPD is not set -+ -+# -+# SCTP Configuration (EXPERIMENTAL) -+# -+# CONFIG_IP_SCTP is not set -+# CONFIG_ATM is not set -+# CONFIG_VLAN_8021Q is not set -+ -+# -+# -+# -+# CONFIG_IPX is not set -+# CONFIG_ATALK is not set -+# CONFIG_DECNET is not set -+# CONFIG_BRIDGE is not set -+# CONFIG_X25 is not set -+# CONFIG_LAPB is not set -+# CONFIG_LLC is not set -+# CONFIG_NET_DIVERT is not set -+# CONFIG_ECONET is not set -+# CONFIG_WAN_ROUTER is not set -+# CONFIG_NET_FASTROUTE is not set -+# CONFIG_NET_HW_FLOWCONTROL is not set -+ -+# -+# QoS and/or fair queueing -+# -+# CONFIG_NET_SCHED is not set -+ -+# -+# Network testing -+# -+# CONFIG_NET_PKTGEN is not set -+ -+# -+# Telephony Support -+# -+# CONFIG_PHONE is not set -+# CONFIG_PHONE_IXJ is not set -+# CONFIG_PHONE_IXJ_PCMCIA is not set -+ -+# -+# ATA/IDE/MFM/RLL support -+# -+CONFIG_IDE=y -+ -+# -+# IDE, ATA and ATAPI Block devices -+# -+CONFIG_BLK_DEV_IDE=y -+ -+# -+# Please see Documentation/ide.txt for help/info on IDE drives -+# -+# CONFIG_BLK_DEV_HD_IDE is not set -+# CONFIG_BLK_DEV_HD is not set -+# CONFIG_BLK_DEV_IDE_SATA is not set -+CONFIG_BLK_DEV_IDEDISK=y -+CONFIG_IDEDISK_MULTI_MODE=y -+CONFIG_IDEDISK_STROKE=y -+CONFIG_BLK_DEV_IDECS=m -+# CONFIG_BLK_DEV_DELKIN is not set -+# CONFIG_BLK_DEV_IDECD is not set -+# CONFIG_BLK_DEV_IDETAPE is not set -+# CONFIG_BLK_DEV_IDEFLOPPY is not set -+# CONFIG_BLK_DEV_IDESCSI is not set -+# CONFIG_IDE_TASK_IOCTL is not set -+ -+# -+# IDE chipset support/bugfixes -+# -+# CONFIG_BLK_DEV_CMD640 is not set -+# CONFIG_BLK_DEV_CMD640_ENHANCED is not set -+# CONFIG_BLK_DEV_ISAPNP is not set -+# CONFIG_BLK_DEV_IDEPCI is not set -+# CONFIG_IDE_CHIPSETS is not set -+# CONFIG_IDEDMA_AUTO is not set -+# CONFIG_DMA_NONPCI is not set -+# CONFIG_BLK_DEV_ATARAID is not set -+# CONFIG_BLK_DEV_ATARAID_PDC is not set -+# CONFIG_BLK_DEV_ATARAID_HPT is not set -+# CONFIG_BLK_DEV_ATARAID_MEDLEY is not set -+# CONFIG_BLK_DEV_ATARAID_SII is not set -+ -+# -+# SCSI support -+# -+CONFIG_SCSI=y -+ -+# -+# SCSI support type (disk, tape, CD-ROM) -+# -+CONFIG_BLK_DEV_SD=y -+CONFIG_SD_EXTRA_DEVS=40 -+CONFIG_CHR_DEV_ST=y -+# CONFIG_CHR_DEV_OSST is not set -+CONFIG_BLK_DEV_SR=y -+# CONFIG_BLK_DEV_SR_VENDOR is not set -+CONFIG_SR_EXTRA_DEVS=2 -+# CONFIG_CHR_DEV_SG is not set -+ -+# -+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs -+# -+# CONFIG_SCSI_DEBUG_QUEUES is not set -+# CONFIG_SCSI_MULTI_LUN is not set -+CONFIG_SCSI_CONSTANTS=y -+# CONFIG_SCSI_LOGGING is not set -+ -+# -+# SCSI low-level drivers -+# -+# CONFIG_BLK_DEV_3W_XXXX_RAID is not set -+# CONFIG_SCSI_7000FASST is not set -+# CONFIG_SCSI_ACARD is not set -+# CONFIG_SCSI_AHA152X is not set -+# CONFIG_SCSI_AHA1542 is not set -+# CONFIG_SCSI_AHA1740 is not set -+# CONFIG_SCSI_AACRAID is not set -+# CONFIG_SCSI_AIC7XXX is not set -+# CONFIG_SCSI_AIC79XX is not set -+# CONFIG_SCSI_AIC7XXX_OLD is not set -+# CONFIG_SCSI_DPT_I2O is not set -+# CONFIG_SCSI_ADVANSYS is not set -+# CONFIG_SCSI_IN2000 is not set -+# CONFIG_SCSI_AM53C974 is not set -+# CONFIG_SCSI_MEGARAID is not set -+# CONFIG_SCSI_MEGARAID2 is not set -+# CONFIG_SCSI_SATA is not set -+# CONFIG_SCSI_SATA_AHCI is not set -+# CONFIG_SCSI_SATA_SVW is not set -+# CONFIG_SCSI_ATA_PIIX is not set -+# CONFIG_SCSI_SATA_NV is not set -+# CONFIG_SCSI_SATA_QSTOR is not set -+# CONFIG_SCSI_SATA_PROMISE is not set -+# CONFIG_SCSI_SATA_SX4 is not set -+# CONFIG_SCSI_SATA_SIL is not set -+# CONFIG_SCSI_SATA_SIS is not set -+# CONFIG_SCSI_SATA_ULI is not set -+# CONFIG_SCSI_SATA_VIA is not set -+# CONFIG_SCSI_SATA_VITESSE is not set -+# CONFIG_SCSI_BUSLOGIC is not set -+# CONFIG_SCSI_CPQFCTS is not set -+# CONFIG_SCSI_DMX3191D is not set -+# CONFIG_SCSI_DTC3280 is not set -+# CONFIG_SCSI_EATA is not set -+# CONFIG_SCSI_EATA_DMA is not set -+# CONFIG_SCSI_EATA_PIO is not set -+# CONFIG_SCSI_FUTURE_DOMAIN is not set -+# CONFIG_SCSI_GDTH is not set -+# CONFIG_SCSI_GENERIC_NCR5380 is not set -+# CONFIG_SCSI_INITIO is not set -+# CONFIG_SCSI_INIA100 is not set -+# CONFIG_SCSI_NCR53C406A is not set -+# CONFIG_SCSI_NCR53C7xx is not set -+# CONFIG_SCSI_SYM53C8XX_2 is not set -+# CONFIG_SCSI_NCR53C8XX is not set -+# CONFIG_SCSI_SYM53C8XX is not set -+# CONFIG_SCSI_PAS16 is not set -+# CONFIG_SCSI_PCI2000 is not set -+# CONFIG_SCSI_PCI2220I is not set -+# CONFIG_SCSI_PSI240I is not set -+# CONFIG_SCSI_QLOGIC_FAS is not set -+# CONFIG_SCSI_QLOGIC_ISP is not set -+# CONFIG_SCSI_QLOGIC_FC is not set -+# CONFIG_SCSI_QLOGIC_1280 is not set -+# CONFIG_SCSI_SIM710 is not set -+# CONFIG_SCSI_SYM53C416 is not set -+# CONFIG_SCSI_DC390T is not set -+# CONFIG_SCSI_T128 is not set -+# CONFIG_SCSI_U14_34F is not set -+# CONFIG_SCSI_NSP32 is not set -+# CONFIG_SCSI_DEBUG is not set -+ -+# -+# PCMCIA SCSI adapter support -+# -+# CONFIG_SCSI_PCMCIA is not set -+ -+# -+# Fusion MPT device support -+# -+# CONFIG_FUSION is not set -+# CONFIG_FUSION_BOOT is not set -+# CONFIG_FUSION_ISENSE is not set -+# CONFIG_FUSION_CTL is not set -+# CONFIG_FUSION_LAN is not set -+ -+# -+# IEEE 1394 (FireWire) support (EXPERIMENTAL) -+# -+# CONFIG_IEEE1394 is not set -+ -+# -+# I2O device support -+# -+# CONFIG_I2O is not set -+# CONFIG_I2O_PCI is not set -+# CONFIG_I2O_BLOCK is not set -+# CONFIG_I2O_LAN is not set -+# CONFIG_I2O_SCSI is not set -+# CONFIG_I2O_PROC is not set -+ -+# -+# Network device support -+# -+CONFIG_NETDEVICES=y -+ -+# -+# ARCnet devices -+# -+# CONFIG_ARCNET is not set -+# CONFIG_DUMMY is not set -+# CONFIG_BONDING is not set -+# CONFIG_EQUALIZER is not set -+# CONFIG_TUN is not set -+# CONFIG_ETHERTAP is not set -+ -+# -+# Ethernet (10 or 100Mbit) -+# -+CONFIG_NET_ETHERNET=y -+# CONFIG_SUNLANCE is not set -+# CONFIG_HAPPYMEAL is not set -+# CONFIG_SUNBMAC is not set -+# CONFIG_SUNQE is not set -+# CONFIG_SUNGEM is not set -+# CONFIG_NET_VENDOR_3COM is not set -+# CONFIG_LANCE is not set -+# CONFIG_NET_VENDOR_SMC is not set -+# CONFIG_NET_VENDOR_RACAL is not set -+# CONFIG_HP100 is not set -+# CONFIG_NET_ISA is not set -+# CONFIG_NET_PCI is not set -+# CONFIG_NET_POCKET is not set -+ -+# -+# Ethernet (1000 Mbit) -+# -+# CONFIG_ACENIC is not set -+# CONFIG_DL2K is not set -+# CONFIG_E1000 is not set -+# CONFIG_MYRI_SBUS is not set -+# CONFIG_NS83820 is not set -+# CONFIG_HAMACHI is not set -+# CONFIG_YELLOWFIN is not set -+# CONFIG_R8169 is not set -+# CONFIG_SK98LIN is not set -+# CONFIG_TIGON3 is not set -+# CONFIG_FDDI is not set -+# CONFIG_HIPPI is not set -+# CONFIG_PLIP is not set -+# CONFIG_PPP is not set -+# CONFIG_SLIP is not set -+ -+# -+# Wireless LAN (non-hamradio) -+# -+# CONFIG_NET_RADIO is not set -+ -+# -+# Token Ring devices -+# -+# CONFIG_TR is not set -+# CONFIG_NET_FC is not set -+# CONFIG_RCPCI is not set -+# CONFIG_SHAPER is not set -+ -+# -+# Wan interfaces -+# -+# CONFIG_WAN is not set -+ -+# -+# PCMCIA network device support -+# -+# CONFIG_NET_PCMCIA is not set -+ -+# -+# Amateur Radio support -+# -+# CONFIG_HAMRADIO is not set -+ -+# -+# IrDA (infrared) support -+# -+# CONFIG_IRDA is not set -+ -+# -+# ISDN subsystem -+# -+# CONFIG_ISDN is not set -+ -+# -+# Input core support -+# -+CONFIG_INPUT=y -+CONFIG_INPUT_KEYBDEV=y -+CONFIG_INPUT_MOUSEDEV=y -+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024 -+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768 -+# CONFIG_INPUT_JOYDEV is not set -+CONFIG_INPUT_EVDEV=y -+# CONFIG_INPUT_UINPUT is not set -+ -+# -+# Character devices -+# -+CONFIG_VT=y -+# CONFIG_VT_CONSOLE is not set -+# CONFIG_SERIAL is not set -+# CONFIG_SERIAL_EXTENDED is not set -+CONFIG_SERIAL_NONSTANDARD=y -+# CONFIG_COMPUTONE is not set -+# CONFIG_ROCKETPORT is not set -+# CONFIG_CYCLADES is not set -+# CONFIG_DIGIEPCA is not set -+# CONFIG_DIGI is not set -+# CONFIG_ESPSERIAL is not set -+# CONFIG_MOXA_INTELLIO is not set -+# CONFIG_MOXA_SMARTIO is not set -+# CONFIG_ISI is not set -+# CONFIG_SYNCLINK is not set -+# CONFIG_SYNCLINKMP is not set -+# CONFIG_N_HDLC is not set -+# CONFIG_RISCOM8 is not set -+# CONFIG_SPECIALIX is not set -+# CONFIG_SX is not set -+# CONFIG_RIO is not set -+# CONFIG_STALDRV is not set -+# CONFIG_SERIAL_TX3912 is not set -+# CONFIG_SERIAL_TX3912_CONSOLE is not set -+# CONFIG_SERIAL_TXX9 is not set -+# CONFIG_SERIAL_TXX9_CONSOLE is not set -+# CONFIG_TXX927_SERIAL is not set -+CONFIG_UNIX98_PTYS=y -+CONFIG_UNIX98_PTY_COUNT=256 -+ -+# -+# I2C support -+# -+# CONFIG_I2C is not set -+ -+# -+# Mice -+# -+# CONFIG_BUSMOUSE is not set -+# CONFIG_MOUSE is not set -+ -+# -+# Joysticks -+# -+# CONFIG_INPUT_GAMEPORT is not set -+# CONFIG_INPUT_NS558 is not set -+# CONFIG_INPUT_LIGHTNING is not set -+# CONFIG_INPUT_PCIGAME is not set -+# CONFIG_INPUT_CS461X is not set -+# CONFIG_INPUT_EMU10K1 is not set -+# CONFIG_INPUT_SERIO is not set -+# CONFIG_INPUT_SERPORT is not set -+ -+# -+# Joysticks -+# -+# CONFIG_INPUT_ANALOG is not set -+# CONFIG_INPUT_A3D is not set -+# CONFIG_INPUT_ADI is not set -+# CONFIG_INPUT_COBRA is not set -+# CONFIG_INPUT_GF2K is not set -+# CONFIG_INPUT_GRIP is not set -+# CONFIG_INPUT_INTERACT is not set -+# CONFIG_INPUT_TMDC is not set -+# CONFIG_INPUT_SIDEWINDER is not set -+# CONFIG_INPUT_IFORCE_USB is not set -+# CONFIG_INPUT_IFORCE_232 is not set -+# CONFIG_INPUT_WARRIOR is not set -+# CONFIG_INPUT_MAGELLAN is not set -+# CONFIG_INPUT_SPACEORB is not set -+# CONFIG_INPUT_SPACEBALL is not set -+# CONFIG_INPUT_STINGER is not set -+# CONFIG_INPUT_DB9 is not set -+# CONFIG_INPUT_GAMECON is not set -+# CONFIG_INPUT_TURBOGRAFX is not set -+# CONFIG_QIC02_TAPE is not set -+# CONFIG_IPMI_HANDLER is not set -+# CONFIG_IPMI_PANIC_EVENT is not set -+# CONFIG_IPMI_DEVICE_INTERFACE is not set -+# CONFIG_IPMI_KCS is not set -+# CONFIG_IPMI_WATCHDOG is not set -+ -+# -+# Watchdog Cards -+# -+# CONFIG_WATCHDOG is not set -+# CONFIG_SCx200 is not set -+# CONFIG_SCx200_GPIO is not set -+# CONFIG_AMD_PM768 is not set -+# CONFIG_NVRAM is not set -+# CONFIG_RTC is not set -+# CONFIG_DTLK is not set -+# CONFIG_R3964 is not set -+# CONFIG_APPLICOM is not set -+ -+# -+# Ftape, the floppy tape device driver -+# -+# CONFIG_FTAPE is not set -+# CONFIG_AGP is not set -+ -+# -+# Direct Rendering Manager (XFree86 DRI support) -+# -+# CONFIG_DRM is not set -+ -+# -+# PCMCIA character devices -+# -+# CONFIG_PCMCIA_SERIAL_CS is not set -+# CONFIG_SYNCLINK_CS is not set -+ -+# -+# File systems -+# -+# CONFIG_QUOTA is not set -+# CONFIG_QFMT_V2 is not set -+CONFIG_AUTOFS_FS=y -+# CONFIG_AUTOFS4_FS is not set -+# CONFIG_REISERFS_FS is not set -+# CONFIG_REISERFS_CHECK is not set -+# CONFIG_REISERFS_PROC_INFO is not set -+# CONFIG_ADFS_FS is not set -+# CONFIG_ADFS_FS_RW is not set -+# CONFIG_AFFS_FS is not set -+# CONFIG_HFS_FS is not set -+# CONFIG_HFSPLUS_FS is not set -+# CONFIG_BEFS_FS is not set -+# CONFIG_BEFS_DEBUG is not set -+# CONFIG_BFS_FS is not set -+CONFIG_EXT3_FS=y -+CONFIG_JBD=y -+# CONFIG_JBD_DEBUG is not set -+CONFIG_FAT_FS=y -+CONFIG_MSDOS_FS=y -+# CONFIG_UMSDOS_FS is not set -+CONFIG_VFAT_FS=y -+# CONFIG_EFS_FS is not set -+# CONFIG_JFFS_FS is not set -+# CONFIG_JFFS2_FS is not set -+# CONFIG_CRAMFS is not set -+CONFIG_TMPFS=y -+CONFIG_RAMFS=y -+# CONFIG_ISO9660_FS is not set -+# CONFIG_JOLIET is not set -+# CONFIG_ZISOFS is not set -+# CONFIG_JFS_FS is not set -+# CONFIG_JFS_DEBUG is not set -+# CONFIG_JFS_STATISTICS is not set -+# CONFIG_MINIX_FS is not set -+# CONFIG_VXFS_FS is not set -+# CONFIG_NTFS_FS is not set -+# CONFIG_NTFS_RW is not set -+# CONFIG_HPFS_FS is not set -+CONFIG_PROC_FS=y -+# CONFIG_DEVFS_FS is not set -+# CONFIG_DEVFS_MOUNT is not set -+# CONFIG_DEVFS_DEBUG is not set -+CONFIG_DEVPTS_FS=y -+# CONFIG_QNX4FS_FS is not set -+# CONFIG_QNX4FS_RW is not set -+# CONFIG_ROMFS_FS is not set -+CONFIG_EXT2_FS=y -+# CONFIG_SYSV_FS is not set -+# CONFIG_UDF_FS is not set -+# CONFIG_UDF_RW is not set -+# CONFIG_UFS_FS is not set -+# CONFIG_UFS_FS_WRITE is not set -+# CONFIG_XFS_FS is not set -+# CONFIG_XFS_QUOTA is not set -+# CONFIG_XFS_RT is not set -+# CONFIG_XFS_TRACE is not set -+# CONFIG_XFS_DEBUG is not set -+ -+# -+# Network File Systems -+# -+# CONFIG_CODA_FS is not set -+# CONFIG_INTERMEZZO_FS is not set -+CONFIG_NFS_FS=y -+CONFIG_NFS_V3=y -+# CONFIG_NFS_DIRECTIO is not set -+CONFIG_ROOT_NFS=y -+# CONFIG_NFSD is not set -+# CONFIG_NFSD_V3 is not set -+# CONFIG_NFSD_TCP is not set -+CONFIG_SUNRPC=y -+CONFIG_LOCKD=y -+CONFIG_LOCKD_V4=y -+# CONFIG_SMB_FS is not set -+# CONFIG_NCP_FS is not set -+# CONFIG_NCPFS_PACKET_SIGNING is not set -+# CONFIG_NCPFS_IOCTL_LOCKING is not set -+# CONFIG_NCPFS_STRONG is not set -+# CONFIG_NCPFS_NFS_NS is not set -+# CONFIG_NCPFS_OS2_NS is not set -+# CONFIG_NCPFS_SMALLDOS is not set -+# CONFIG_NCPFS_NLS is not set -+# CONFIG_NCPFS_EXTRAS is not set -+# CONFIG_ZISOFS_FS is not set -+ -+# -+# Partition Types -+# -+# CONFIG_PARTITION_ADVANCED is not set -+CONFIG_MSDOS_PARTITION=y -+# CONFIG_SMB_NLS is not set -+CONFIG_NLS=y -+ -+# -+# Native Language Support -+# -+CONFIG_NLS_DEFAULT="iso8859-1" -+# CONFIG_NLS_CODEPAGE_437 is not set -+# CONFIG_NLS_CODEPAGE_737 is not set -+# CONFIG_NLS_CODEPAGE_775 is not set -+# CONFIG_NLS_CODEPAGE_850 is not set -+# CONFIG_NLS_CODEPAGE_852 is not set -+# CONFIG_NLS_CODEPAGE_855 is not set -+# CONFIG_NLS_CODEPAGE_857 is not set -+# CONFIG_NLS_CODEPAGE_860 is not set -+# CONFIG_NLS_CODEPAGE_861 is not set -+# CONFIG_NLS_CODEPAGE_862 is not set -+# CONFIG_NLS_CODEPAGE_863 is not set -+# CONFIG_NLS_CODEPAGE_864 is not set -+# CONFIG_NLS_CODEPAGE_865 is not set -+# CONFIG_NLS_CODEPAGE_866 is not set -+# CONFIG_NLS_CODEPAGE_869 is not set -+# CONFIG_NLS_CODEPAGE_936 is not set -+# CONFIG_NLS_CODEPAGE_950 is not set -+# CONFIG_NLS_CODEPAGE_932 is not set -+# CONFIG_NLS_CODEPAGE_949 is not set -+# CONFIG_NLS_CODEPAGE_874 is not set -+# CONFIG_NLS_ISO8859_8 is not set -+# CONFIG_NLS_CODEPAGE_1250 is not set -+# CONFIG_NLS_CODEPAGE_1251 is not set -+# CONFIG_NLS_ISO8859_1 is not set -+# CONFIG_NLS_ISO8859_2 is not set -+# CONFIG_NLS_ISO8859_3 is not set -+# CONFIG_NLS_ISO8859_4 is not set -+# CONFIG_NLS_ISO8859_5 is not set -+# CONFIG_NLS_ISO8859_6 is not set -+# CONFIG_NLS_ISO8859_7 is not set -+# CONFIG_NLS_ISO8859_9 is not set -+# CONFIG_NLS_ISO8859_13 is not set -+# CONFIG_NLS_ISO8859_14 is not set -+# CONFIG_NLS_ISO8859_15 is not set -+# CONFIG_NLS_KOI8_R is not set -+# CONFIG_NLS_KOI8_U is not set -+# CONFIG_NLS_UTF8 is not set -+ -+# -+# Multimedia devices -+# -+# CONFIG_VIDEO_DEV is not set -+ -+# -+# Console drivers -+# -+# CONFIG_VGA_CONSOLE is not set -+# CONFIG_MDA_CONSOLE is not set -+ -+# -+# Frame-buffer support -+# -+CONFIG_FB=y -+CONFIG_DUMMY_CONSOLE=y -+# CONFIG_FB_RIVA is not set -+# CONFIG_FB_CLGEN is not set -+# CONFIG_FB_PM2 is not set -+# CONFIG_FB_PM3 is not set -+# CONFIG_FB_CYBER2000 is not set -+# CONFIG_FB_MATROX is not set -+# CONFIG_FB_ATY is not set -+# CONFIG_FB_RADEON is not set -+# CONFIG_FB_ATY128 is not set -+# CONFIG_FB_INTEL is not set -+# CONFIG_FB_SIS is not set -+# CONFIG_FB_NEOMAGIC is not set -+# CONFIG_FB_3DFX is not set -+# CONFIG_FB_VOODOO1 is not set -+# CONFIG_FB_TRIDENT is not set -+# CONFIG_FB_E1356 is not set -+# CONFIG_FB_IT8181 is not set -+# CONFIG_FB_VIRTUAL is not set -+CONFIG_FBCON_ADVANCED=y -+# CONFIG_FBCON_MFB is not set -+# CONFIG_FBCON_CFB2 is not set -+# CONFIG_FBCON_CFB4 is not set -+# CONFIG_FBCON_CFB8 is not set -+CONFIG_FBCON_CFB16=y -+# CONFIG_FBCON_CFB24 is not set -+CONFIG_FBCON_CFB32=y -+# CONFIG_FBCON_AFB is not set -+# CONFIG_FBCON_ILBM is not set -+# CONFIG_FBCON_IPLAN2P2 is not set -+# CONFIG_FBCON_IPLAN2P4 is not set -+# CONFIG_FBCON_IPLAN2P8 is not set -+# CONFIG_FBCON_MAC is not set -+# CONFIG_FBCON_VGA_PLANES is not set -+# CONFIG_FBCON_VGA is not set -+# CONFIG_FBCON_HGA is not set -+# CONFIG_FBCON_FONTWIDTH8_ONLY is not set -+CONFIG_FBCON_FONTS=y -+CONFIG_FONT_8x8=y -+CONFIG_FONT_8x16=y -+# CONFIG_FONT_SUN8x16 is not set -+# CONFIG_FONT_SUN12x22 is not set -+# CONFIG_FONT_6x11 is not set -+# CONFIG_FONT_PEARL_8x8 is not set -+# CONFIG_FONT_ACORN_8x8 is not set -+ -+# -+# Sound -+# -+CONFIG_SOUND=y -+# CONFIG_SOUND_ALI5455 is not set -+# CONFIG_SOUND_BT878 is not set -+# CONFIG_SOUND_CMPCI is not set -+# CONFIG_SOUND_EMU10K1 is not set -+# CONFIG_MIDI_EMU10K1 is not set -+# CONFIG_SOUND_FUSION is not set -+# CONFIG_SOUND_CS4281 is not set -+# CONFIG_SOUND_ES1370 is not set -+# CONFIG_SOUND_ES1371 is not set -+# CONFIG_SOUND_ESSSOLO1 is not set -+# CONFIG_SOUND_MAESTRO is not set -+# CONFIG_SOUND_MAESTRO3 is not set -+# CONFIG_SOUND_FORTE is not set -+# CONFIG_SOUND_ICH is not set -+# CONFIG_SOUND_RME96XX is not set -+# CONFIG_SOUND_SONICVIBES is not set -+# CONFIG_SOUND_TRIDENT is not set -+# CONFIG_SOUND_MSNDCLAS is not set -+# CONFIG_SOUND_MSNDPIN is not set -+# CONFIG_SOUND_VIA82CXXX is not set -+# CONFIG_MIDI_VIA82CXXX is not set -+# CONFIG_SOUND_OSS is not set -+# CONFIG_SOUND_TVMIXER is not set -+# CONFIG_SOUND_AD1980 is not set -+# CONFIG_SOUND_WM97XX is not set -+ -+# -+# USB support -+# -+CONFIG_USB=y -+# CONFIG_USB_DEBUG is not set -+ -+# -+# Miscellaneous USB options -+# -+CONFIG_USB_DEVICEFS=y -+# CONFIG_USB_BANDWIDTH is not set -+ -+# -+# USB Host Controller Drivers -+# -+# CONFIG_USB_EHCI_HCD is not set -+# CONFIG_USB_UHCI is not set -+# CONFIG_USB_UHCI_ALT is not set -+CONFIG_USB_OHCI=y -+ -+# -+# USB Device Class drivers -+# -+# CONFIG_USB_AUDIO is not set -+# CONFIG_USB_EMI26 is not set -+# CONFIG_USB_BLUETOOTH is not set -+# CONFIG_USB_MIDI is not set -+CONFIG_USB_STORAGE=y -+# CONFIG_USB_STORAGE_DEBUG is not set -+# CONFIG_USB_STORAGE_DATAFAB is not set -+# CONFIG_USB_STORAGE_FREECOM is not set -+# CONFIG_USB_STORAGE_ISD200 is not set -+# CONFIG_USB_STORAGE_DPCM is not set -+# CONFIG_USB_STORAGE_HP8200e is not set -+# CONFIG_USB_STORAGE_SDDR09 is not set -+# CONFIG_USB_STORAGE_SDDR55 is not set -+# CONFIG_USB_STORAGE_JUMPSHOT is not set -+# CONFIG_USB_ACM is not set -+# CONFIG_USB_PRINTER is not set -+ -+# -+# USB Human Interface Devices (HID) -+# -+CONFIG_USB_HID=y -+CONFIG_USB_HIDINPUT=y -+CONFIG_USB_HIDDEV=y -+# CONFIG_USB_AIPTEK is not set -+# CONFIG_USB_WACOM is not set -+# CONFIG_USB_KBTAB is not set -+# CONFIG_USB_POWERMATE is not set -+ -+# -+# USB Imaging devices -+# -+# CONFIG_USB_DC2XX is not set -+# CONFIG_USB_MDC800 is not set -+# CONFIG_USB_SCANNER is not set -+# CONFIG_USB_MICROTEK is not set -+# CONFIG_USB_HPUSBSCSI is not set -+ -+# -+# USB Multimedia devices -+# -+ -+# -+# Video4Linux support is needed for USB Multimedia device support -+# -+ -+# -+# USB Network adaptors -+# -+# CONFIG_USB_PEGASUS is not set -+# CONFIG_USB_RTL8150 is not set -+# CONFIG_USB_KAWETH is not set -+# CONFIG_USB_CATC is not set -+# CONFIG_USB_CDCETHER is not set -+# CONFIG_USB_USBNET is not set -+ -+# -+# USB port drivers -+# -+# CONFIG_USB_USS720 is not set -+ -+# -+# USB Serial Converter support -+# -+# CONFIG_USB_SERIAL is not set -+ -+# -+# USB Miscellaneous drivers -+# -+# CONFIG_USB_RIO500 is not set -+# CONFIG_USB_AUERSWALD is not set -+# CONFIG_USB_TIGL is not set -+# CONFIG_USB_BRLVGER is not set -+# CONFIG_USB_LCD is not set -+ -+# -+# Support for USB gadgets -+# -+# CONFIG_USB_GADGET is not set -+ -+# -+# Bluetooth support -+# -+# CONFIG_BLUEZ is not set -+ -+# -+# Kernel hacking -+# -+CONFIG_CROSSCOMPILE=y -+# CONFIG_RUNTIME_DEBUG is not set -+# CONFIG_KGDB is not set -+# CONFIG_GDB_CONSOLE is not set -+# CONFIG_DEBUG_INFO is not set -+# CONFIG_MAGIC_SYSRQ is not set -+# CONFIG_MIPS_UNCACHED is not set -+CONFIG_LOG_BUF_SHIFT=0 -+ -+# -+# Cryptographic options -+# -+# CONFIG_CRYPTO is not set -+ -+# -+# Library routines -+# -+# CONFIG_CRC32 is not set -+CONFIG_ZLIB_INFLATE=m -+CONFIG_ZLIB_DEFLATE=m -+# CONFIG_FW_LOADER is not set ---- a/arch/mips/defconfig-db1500 -+++ b/arch/mips/defconfig-db1500 -@@ -30,8 +30,8 @@ CONFIG_MIPS_DB1500=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -267,11 +267,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -555,7 +550,6 @@ CONFIG_AU1X00_SERIAL_CONSOLE=y - # CONFIG_AU1X00_USB_TTY is not set - # CONFIG_AU1X00_USB_RAW is not set - # CONFIG_TXX927_SERIAL is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips/defconfig-db1550 -+++ b/arch/mips/defconfig-db1550 -@@ -30,8 +30,8 @@ CONFIG_MIPS_DB1550=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -213,11 +213,9 @@ CONFIG_MTD_CFI_AMDSTD=y - # CONFIG_MTD_BOSPORUS is not set - # CONFIG_MTD_XXS1500 is not set - # CONFIG_MTD_MTX1 is not set --# CONFIG_MTD_DB1X00 is not set - CONFIG_MTD_PB1550=y - CONFIG_MTD_PB1550_BOOT=y - CONFIG_MTD_PB1550_USER=y --# CONFIG_MTD_HYDROGEN3 is not set - # CONFIG_MTD_MIRAGE is not set - # CONFIG_MTD_CSTM_MIPS_IXX is not set - # CONFIG_MTD_OCELOT is not set -@@ -236,7 +234,6 @@ CONFIG_MTD_PB1550_USER=y - # - # Disk-On-Chip Device Drivers - # --# CONFIG_MTD_DOC1000 is not set - # CONFIG_MTD_DOC2000 is not set - # CONFIG_MTD_DOC2001 is not set - # CONFIG_MTD_DOCPROBE is not set -@@ -343,11 +340,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -633,7 +625,6 @@ CONFIG_AU1X00_SERIAL_CONSOLE=y - # CONFIG_AU1X00_USB_TTY is not set - # CONFIG_AU1X00_USB_RAW is not set - # CONFIG_TXX927_SERIAL is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips/defconfig-ddb5476 -+++ b/arch/mips/defconfig-ddb5476 -@@ -28,8 +28,8 @@ CONFIG_EXPERIMENTAL=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -226,11 +226,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -517,7 +512,6 @@ CONFIG_SERIAL=y - CONFIG_SERIAL_CONSOLE=y - # CONFIG_SERIAL_EXTENDED is not set - # CONFIG_SERIAL_NONSTANDARD is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips/defconfig-ddb5477 -+++ b/arch/mips/defconfig-ddb5477 -@@ -28,8 +28,8 @@ CONFIG_EXPERIMENTAL=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -226,11 +226,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -434,7 +429,6 @@ CONFIG_SERIAL=y - CONFIG_SERIAL_CONSOLE=y - # CONFIG_SERIAL_EXTENDED is not set - # CONFIG_SERIAL_NONSTANDARD is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips/defconfig-decstation -+++ b/arch/mips/defconfig-decstation -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -223,11 +223,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -306,9 +301,11 @@ CONFIG_SCSI_DECNCR=y - # CONFIG_SCSI_MEGARAID is not set - # CONFIG_SCSI_MEGARAID2 is not set - # CONFIG_SCSI_SATA is not set -+# CONFIG_SCSI_SATA_AHCI is not set - # CONFIG_SCSI_SATA_SVW is not set - # CONFIG_SCSI_ATA_PIIX is not set - # CONFIG_SCSI_SATA_NV is not set -+# CONFIG_SCSI_SATA_QSTOR is not set - # CONFIG_SCSI_SATA_PROMISE is not set - # CONFIG_SCSI_SATA_SX4 is not set - # CONFIG_SCSI_SATA_SIL is not set -@@ -477,7 +474,6 @@ CONFIG_SERIAL_DEC=y - CONFIG_SERIAL_DEC_CONSOLE=y - CONFIG_DZ=y - CONFIG_ZS=y --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips/defconfig-e55 -+++ b/arch/mips/defconfig-e55 -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -222,11 +222,6 @@ CONFIG_IP_MULTICAST=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -426,7 +421,6 @@ CONFIG_SERIAL_MANY_PORTS=y - # CONFIG_SERIAL_MULTIPORT is not set - # CONFIG_HUB6 is not set - # CONFIG_SERIAL_NONSTANDARD is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - # CONFIG_VR41XX_KIU is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 ---- a/arch/mips/defconfig-eagle -+++ b/arch/mips/defconfig-eagle -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -208,8 +208,8 @@ CONFIG_MTD_CFI_INTELEXT=y - # Mapping drivers for chip access - # - CONFIG_MTD_PHYSMAP=y --CONFIG_MTD_PHYSMAP_START=1c000000 --CONFIG_MTD_PHYSMAP_LEN=2000000 -+CONFIG_MTD_PHYSMAP_START=0x1c000000 -+CONFIG_MTD_PHYSMAP_LEN=0x2000000 - CONFIG_MTD_PHYSMAP_BUSWIDTH=4 - # CONFIG_MTD_PB1000 is not set - # CONFIG_MTD_PB1500 is not set -@@ -217,9 +217,7 @@ CONFIG_MTD_PHYSMAP_BUSWIDTH=4 - # CONFIG_MTD_BOSPORUS is not set - # CONFIG_MTD_XXS1500 is not set - # CONFIG_MTD_MTX1 is not set --# CONFIG_MTD_DB1X00 is not set - # CONFIG_MTD_PB1550 is not set --# CONFIG_MTD_HYDROGEN3 is not set - # CONFIG_MTD_MIRAGE is not set - # CONFIG_MTD_CSTM_MIPS_IXX is not set - # CONFIG_MTD_OCELOT is not set -@@ -238,7 +236,6 @@ CONFIG_MTD_PHYSMAP_BUSWIDTH=4 - # - # Disk-On-Chip Device Drivers - # --# CONFIG_MTD_DOC1000 is not set - # CONFIG_MTD_DOC2000 is not set - # CONFIG_MTD_DOC2001 is not set - # CONFIG_MTD_DOCPROBE is not set -@@ -327,11 +324,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -587,7 +579,6 @@ CONFIG_SERIAL=y - CONFIG_SERIAL_CONSOLE=y - # CONFIG_SERIAL_EXTENDED is not set - # CONFIG_SERIAL_NONSTANDARD is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - # CONFIG_VR41XX_KIU is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 ---- a/arch/mips/defconfig-ev64120 -+++ b/arch/mips/defconfig-ev64120 -@@ -30,8 +30,8 @@ CONFIG_MODULES=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -230,11 +230,6 @@ CONFIG_IP_PNP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -443,7 +438,6 @@ CONFIG_SERIAL=y - # CONFIG_SERIAL_CONSOLE is not set - # CONFIG_SERIAL_EXTENDED is not set - # CONFIG_SERIAL_NONSTANDARD is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips/defconfig-ev96100 -+++ b/arch/mips/defconfig-ev96100 -@@ -30,8 +30,8 @@ CONFIG_MODULES=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -232,11 +232,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -441,7 +436,6 @@ CONFIG_SERIAL=y - CONFIG_SERIAL_CONSOLE=y - # CONFIG_SERIAL_EXTENDED is not set - # CONFIG_SERIAL_NONSTANDARD is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- /dev/null -+++ b/arch/mips/defconfig-ficmmp -@@ -0,0 +1,862 @@ -+# -+# Automatically generated make config: don't edit -+# -+CONFIG_MIPS=y -+CONFIG_MIPS32=y -+# CONFIG_MIPS64 is not set -+ -+# -+# Code maturity level options -+# -+CONFIG_EXPERIMENTAL=y -+ -+# -+# Loadable module support -+# -+CONFIG_MODULES=y -+# CONFIG_MODVERSIONS is not set -+CONFIG_KMOD=y -+ -+# -+# Machine selection -+# -+# CONFIG_ACER_PICA_61 is not set -+# CONFIG_MIPS_BOSPORUS is not set -+# CONFIG_MIPS_MIRAGE is not set -+# CONFIG_MIPS_DB1000 is not set -+# CONFIG_MIPS_DB1100 is not set -+# CONFIG_MIPS_DB1500 is not set -+# CONFIG_MIPS_DB1550 is not set -+# CONFIG_MIPS_PB1000 is not set -+# CONFIG_MIPS_PB1100 is not set -+# CONFIG_MIPS_PB1500 is not set -+# CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set -+# CONFIG_MIPS_XXS1500 is not set -+# CONFIG_MIPS_MTX1 is not set -+# CONFIG_COGENT_CSB250 is not set -+# CONFIG_BAGET_MIPS is not set -+# CONFIG_CASIO_E55 is not set -+# CONFIG_MIPS_COBALT is not set -+# CONFIG_DECSTATION is not set -+# CONFIG_MIPS_EV64120 is not set -+# CONFIG_MIPS_EV96100 is not set -+# CONFIG_MIPS_IVR is not set -+# CONFIG_HP_LASERJET is not set -+# CONFIG_IBM_WORKPAD is not set -+# CONFIG_LASAT is not set -+# CONFIG_MIPS_ITE8172 is not set -+# CONFIG_MIPS_ATLAS is not set -+# CONFIG_MIPS_MAGNUM_4000 is not set -+# CONFIG_MIPS_MALTA is not set -+# CONFIG_MIPS_SEAD is not set -+# CONFIG_MOMENCO_OCELOT is not set -+# CONFIG_MOMENCO_OCELOT_G is not set -+# CONFIG_MOMENCO_OCELOT_C is not set -+# CONFIG_MOMENCO_JAGUAR_ATX is not set -+# CONFIG_PMC_BIG_SUR is not set -+# CONFIG_PMC_STRETCH is not set -+# CONFIG_PMC_YOSEMITE is not set -+# CONFIG_DDB5074 is not set -+# CONFIG_DDB5476 is not set -+# CONFIG_DDB5477 is not set -+# CONFIG_NEC_OSPREY is not set -+# CONFIG_NEC_EAGLE is not set -+# CONFIG_OLIVETTI_M700 is not set -+# CONFIG_NINO is not set -+# CONFIG_SGI_IP22 is not set -+# CONFIG_SGI_IP27 is not set -+# CONFIG_SIBYTE_SB1xxx_SOC is not set -+# CONFIG_SNI_RM200_PCI is not set -+# CONFIG_TANBAC_TB0226 is not set -+# CONFIG_TANBAC_TB0229 is not set -+# CONFIG_TOSHIBA_JMR3927 is not set -+# CONFIG_TOSHIBA_RBTX4927 is not set -+# CONFIG_VICTOR_MPC30X is not set -+# CONFIG_ZAO_CAPCELLA is not set -+# CONFIG_HIGHMEM is not set -+CONFIG_RWSEM_GENERIC_SPINLOCK=y -+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set -+# CONFIG_MIPS_AU1000 is not set -+ -+# -+# CPU selection -+# -+CONFIG_CPU_MIPS32=y -+# CONFIG_CPU_MIPS64 is not set -+# CONFIG_CPU_R3000 is not set -+# CONFIG_CPU_TX39XX is not set -+# CONFIG_CPU_VR41XX is not set -+# CONFIG_CPU_R4300 is not set -+# CONFIG_CPU_R4X00 is not set -+# CONFIG_CPU_TX49XX is not set -+# CONFIG_CPU_R5000 is not set -+# CONFIG_CPU_R5432 is not set -+# CONFIG_CPU_R6000 is not set -+# CONFIG_CPU_NEVADA is not set -+# CONFIG_CPU_R8000 is not set -+# CONFIG_CPU_R10000 is not set -+# CONFIG_CPU_RM7000 is not set -+# CONFIG_CPU_RM9000 is not set -+# CONFIG_CPU_SB1 is not set -+CONFIG_PAGE_SIZE_4KB=y -+# CONFIG_PAGE_SIZE_16KB is not set -+# CONFIG_PAGE_SIZE_64KB is not set -+CONFIG_CPU_HAS_PREFETCH=y -+# CONFIG_VTAG_ICACHE is not set -+CONFIG_64BIT_PHYS_ADDR=y -+# CONFIG_CPU_ADVANCED is not set -+CONFIG_CPU_HAS_LLSC=y -+# CONFIG_CPU_HAS_LLDSCD is not set -+# CONFIG_CPU_HAS_WB is not set -+CONFIG_CPU_HAS_SYNC=y -+ -+# -+# General setup -+# -+CONFIG_CPU_LITTLE_ENDIAN=y -+# CONFIG_BUILD_ELF64 is not set -+CONFIG_NET=y -+# CONFIG_PCI is not set -+# CONFIG_PCI_NEW is not set -+CONFIG_PCI_AUTO=y -+# CONFIG_ISA is not set -+# CONFIG_TC is not set -+# CONFIG_MCA is not set -+# CONFIG_SBUS is not set -+# CONFIG_HOTPLUG is not set -+# CONFIG_PCMCIA is not set -+# CONFIG_HOTPLUG_PCI is not set -+CONFIG_SYSVIPC=y -+# CONFIG_BSD_PROCESS_ACCT is not set -+CONFIG_SYSCTL=y -+CONFIG_KCORE_ELF=y -+# CONFIG_KCORE_AOUT is not set -+# CONFIG_BINFMT_AOUT is not set -+CONFIG_BINFMT_ELF=y -+# CONFIG_MIPS32_COMPAT is not set -+# CONFIG_MIPS32_O32 is not set -+# CONFIG_MIPS32_N32 is not set -+# CONFIG_BINFMT_ELF32 is not set -+# CONFIG_BINFMT_MISC is not set -+# CONFIG_OOM_KILLER is not set -+CONFIG_CMDLINE_BOOL=y -+CONFIG_CMDLINE="ide3=dma mem=96M root=/dev/hda2 rootflags=data=journal" -+ -+# -+# Memory Technology Devices (MTD) -+# -+# CONFIG_MTD is not set -+ -+# -+# Parallel port support -+# -+# CONFIG_PARPORT is not set -+ -+# -+# Plug and Play configuration -+# -+# CONFIG_PNP is not set -+# CONFIG_ISAPNP is not set -+ -+# -+# Block devices -+# -+# CONFIG_BLK_DEV_FD is not set -+# CONFIG_BLK_DEV_XD is not set -+# CONFIG_PARIDE is not set -+# CONFIG_BLK_CPQ_DA is not set -+# CONFIG_BLK_CPQ_CISS_DA is not set -+# CONFIG_CISS_SCSI_TAPE is not set -+# CONFIG_CISS_MONITOR_THREAD is not set -+# CONFIG_BLK_DEV_DAC960 is not set -+# CONFIG_BLK_DEV_UMEM is not set -+# CONFIG_BLK_DEV_SX8 is not set -+CONFIG_BLK_DEV_LOOP=y -+# CONFIG_BLK_DEV_NBD is not set -+# CONFIG_BLK_DEV_RAM is not set -+# CONFIG_BLK_DEV_INITRD is not set -+# CONFIG_BLK_STATS is not set -+ -+# -+# Multi-device support (RAID and LVM) -+# -+# CONFIG_MD is not set -+# CONFIG_BLK_DEV_MD is not set -+# CONFIG_MD_LINEAR is not set -+# CONFIG_MD_RAID0 is not set -+# CONFIG_MD_RAID1 is not set -+# CONFIG_MD_RAID5 is not set -+# CONFIG_MD_MULTIPATH is not set -+# CONFIG_BLK_DEV_LVM is not set -+ -+# -+# Networking options -+# -+CONFIG_PACKET=y -+# CONFIG_PACKET_MMAP is not set -+# CONFIG_NETLINK_DEV is not set -+CONFIG_NETFILTER=y -+# CONFIG_NETFILTER_DEBUG is not set -+CONFIG_FILTER=y -+CONFIG_UNIX=y -+CONFIG_INET=y -+CONFIG_IP_MULTICAST=y -+# CONFIG_IP_ADVANCED_ROUTER is not set -+# CONFIG_IP_PNP is not set -+# CONFIG_NET_IPIP is not set -+# CONFIG_NET_IPGRE is not set -+# CONFIG_IP_MROUTE is not set -+# CONFIG_ARPD is not set -+# CONFIG_INET_ECN is not set -+# CONFIG_SYN_COOKIES is not set -+ -+# -+# IP: Netfilter Configuration -+# -+# CONFIG_IP_NF_CONNTRACK is not set -+# CONFIG_IP_NF_QUEUE is not set -+# CONFIG_IP_NF_IPTABLES is not set -+# CONFIG_IP_NF_ARPTABLES is not set -+# CONFIG_IP_NF_COMPAT_IPCHAINS is not set -+# CONFIG_IP_NF_COMPAT_IPFWADM is not set -+ -+# -+# IP: Virtual Server Configuration -+# -+# CONFIG_IP_VS is not set -+# CONFIG_IPV6 is not set -+# CONFIG_KHTTPD is not set -+ -+# -+# SCTP Configuration (EXPERIMENTAL) -+# -+# CONFIG_IP_SCTP is not set -+# CONFIG_ATM is not set -+# CONFIG_VLAN_8021Q is not set -+ -+# -+# -+# -+# CONFIG_IPX is not set -+# CONFIG_ATALK is not set -+# CONFIG_DECNET is not set -+# CONFIG_BRIDGE is not set -+# CONFIG_X25 is not set -+# CONFIG_LAPB is not set -+# CONFIG_LLC is not set -+# CONFIG_NET_DIVERT is not set -+# CONFIG_ECONET is not set -+# CONFIG_WAN_ROUTER is not set -+# CONFIG_NET_FASTROUTE is not set -+# CONFIG_NET_HW_FLOWCONTROL is not set -+ -+# -+# QoS and/or fair queueing -+# -+# CONFIG_NET_SCHED is not set -+ -+# -+# Network testing -+# -+# CONFIG_NET_PKTGEN is not set -+ -+# -+# Telephony Support -+# -+# CONFIG_PHONE is not set -+# CONFIG_PHONE_IXJ is not set -+# CONFIG_PHONE_IXJ_PCMCIA is not set -+ -+# -+# ATA/IDE/MFM/RLL support -+# -+CONFIG_IDE=y -+ -+# -+# IDE, ATA and ATAPI Block devices -+# -+CONFIG_BLK_DEV_IDE=y -+ -+# -+# Please see Documentation/ide.txt for help/info on IDE drives -+# -+CONFIG_BLK_DEV_HD_IDE=y -+CONFIG_BLK_DEV_HD=y -+# CONFIG_BLK_DEV_IDE_SATA is not set -+CONFIG_BLK_DEV_IDEDISK=y -+CONFIG_IDEDISK_MULTI_MODE=y -+CONFIG_IDEDISK_STROKE=y -+# CONFIG_BLK_DEV_IDECS is not set -+# CONFIG_BLK_DEV_DELKIN is not set -+# CONFIG_BLK_DEV_IDECD is not set -+# CONFIG_BLK_DEV_IDETAPE is not set -+# CONFIG_BLK_DEV_IDEFLOPPY is not set -+# CONFIG_BLK_DEV_IDESCSI is not set -+# CONFIG_IDE_TASK_IOCTL is not set -+ -+# -+# IDE chipset support/bugfixes -+# -+# CONFIG_BLK_DEV_CMD640 is not set -+# CONFIG_BLK_DEV_CMD640_ENHANCED is not set -+# CONFIG_BLK_DEV_ISAPNP is not set -+# CONFIG_IDE_CHIPSETS is not set -+# CONFIG_IDEDMA_AUTO is not set -+# CONFIG_DMA_NONPCI is not set -+# CONFIG_BLK_DEV_ATARAID is not set -+# CONFIG_BLK_DEV_ATARAID_PDC is not set -+# CONFIG_BLK_DEV_ATARAID_HPT is not set -+# CONFIG_BLK_DEV_ATARAID_MEDLEY is not set -+# CONFIG_BLK_DEV_ATARAID_SII is not set -+ -+# -+# SCSI support -+# -+CONFIG_SCSI=y -+ -+# -+# SCSI support type (disk, tape, CD-ROM) -+# -+CONFIG_BLK_DEV_SD=y -+CONFIG_SD_EXTRA_DEVS=40 -+CONFIG_CHR_DEV_ST=y -+# CONFIG_CHR_DEV_OSST is not set -+CONFIG_BLK_DEV_SR=y -+# CONFIG_BLK_DEV_SR_VENDOR is not set -+CONFIG_SR_EXTRA_DEVS=2 -+# CONFIG_CHR_DEV_SG is not set -+ -+# -+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs -+# -+# CONFIG_SCSI_DEBUG_QUEUES is not set -+# CONFIG_SCSI_MULTI_LUN is not set -+CONFIG_SCSI_CONSTANTS=y -+# CONFIG_SCSI_LOGGING is not set -+ -+# -+# SCSI low-level drivers -+# -+# CONFIG_SCSI_7000FASST is not set -+# CONFIG_SCSI_ACARD is not set -+# CONFIG_SCSI_AHA152X is not set -+# CONFIG_SCSI_AHA1542 is not set -+# CONFIG_SCSI_AHA1740 is not set -+# CONFIG_SCSI_AACRAID is not set -+# CONFIG_SCSI_AIC7XXX is not set -+# CONFIG_SCSI_AIC79XX is not set -+# CONFIG_SCSI_AIC7XXX_OLD is not set -+# CONFIG_SCSI_DPT_I2O is not set -+# CONFIG_SCSI_ADVANSYS is not set -+# CONFIG_SCSI_IN2000 is not set -+# CONFIG_SCSI_AM53C974 is not set -+# CONFIG_SCSI_MEGARAID is not set -+# CONFIG_SCSI_MEGARAID2 is not set -+# CONFIG_SCSI_SATA is not set -+# CONFIG_SCSI_SATA_AHCI is not set -+# CONFIG_SCSI_SATA_SVW is not set -+# CONFIG_SCSI_ATA_PIIX is not set -+# CONFIG_SCSI_SATA_NV is not set -+# CONFIG_SCSI_SATA_QSTOR is not set -+# CONFIG_SCSI_SATA_PROMISE is not set -+# CONFIG_SCSI_SATA_SX4 is not set -+# CONFIG_SCSI_SATA_SIL is not set -+# CONFIG_SCSI_SATA_SIS is not set -+# CONFIG_SCSI_SATA_ULI is not set -+# CONFIG_SCSI_SATA_VIA is not set -+# CONFIG_SCSI_SATA_VITESSE is not set -+# CONFIG_SCSI_BUSLOGIC is not set -+# CONFIG_SCSI_DMX3191D is not set -+# CONFIG_SCSI_DTC3280 is not set -+# CONFIG_SCSI_EATA is not set -+# CONFIG_SCSI_EATA_DMA is not set -+# CONFIG_SCSI_EATA_PIO is not set -+# CONFIG_SCSI_FUTURE_DOMAIN is not set -+# CONFIG_SCSI_GDTH is not set -+# CONFIG_SCSI_GENERIC_NCR5380 is not set -+# CONFIG_SCSI_INITIO is not set -+# CONFIG_SCSI_INIA100 is not set -+# CONFIG_SCSI_NCR53C406A is not set -+# CONFIG_SCSI_NCR53C7xx is not set -+# CONFIG_SCSI_PAS16 is not set -+# CONFIG_SCSI_PCI2000 is not set -+# CONFIG_SCSI_PCI2220I is not set -+# CONFIG_SCSI_PSI240I is not set -+# CONFIG_SCSI_QLOGIC_FAS is not set -+# CONFIG_SCSI_SIM710 is not set -+# CONFIG_SCSI_SYM53C416 is not set -+# CONFIG_SCSI_T128 is not set -+# CONFIG_SCSI_U14_34F is not set -+# CONFIG_SCSI_NSP32 is not set -+# CONFIG_SCSI_DEBUG is not set -+ -+# -+# Fusion MPT device support -+# -+# CONFIG_FUSION is not set -+# CONFIG_FUSION_BOOT is not set -+# CONFIG_FUSION_ISENSE is not set -+# CONFIG_FUSION_CTL is not set -+# CONFIG_FUSION_LAN is not set -+ -+# -+# Network device support -+# -+CONFIG_NETDEVICES=y -+ -+# -+# ARCnet devices -+# -+# CONFIG_ARCNET is not set -+# CONFIG_DUMMY is not set -+# CONFIG_BONDING is not set -+# CONFIG_EQUALIZER is not set -+# CONFIG_TUN is not set -+# CONFIG_ETHERTAP is not set -+ -+# -+# Ethernet (10 or 100Mbit) -+# -+CONFIG_NET_ETHERNET=y -+# CONFIG_SUNLANCE is not set -+# CONFIG_SUNBMAC is not set -+# CONFIG_SUNQE is not set -+# CONFIG_SUNGEM is not set -+# CONFIG_NET_VENDOR_3COM is not set -+# CONFIG_LANCE is not set -+# CONFIG_NET_VENDOR_SMC is not set -+# CONFIG_NET_VENDOR_RACAL is not set -+# CONFIG_NET_ISA is not set -+# CONFIG_NET_PCI is not set -+# CONFIG_NET_POCKET is not set -+ -+# -+# Ethernet (1000 Mbit) -+# -+# CONFIG_ACENIC is not set -+# CONFIG_DL2K is not set -+# CONFIG_E1000 is not set -+# CONFIG_MYRI_SBUS is not set -+# CONFIG_NS83820 is not set -+# CONFIG_HAMACHI is not set -+# CONFIG_YELLOWFIN is not set -+# CONFIG_R8169 is not set -+# CONFIG_SK98LIN is not set -+# CONFIG_TIGON3 is not set -+# CONFIG_FDDI is not set -+# CONFIG_HIPPI is not set -+# CONFIG_PLIP is not set -+# CONFIG_PPP is not set -+# CONFIG_SLIP is not set -+ -+# -+# Wireless LAN (non-hamradio) -+# -+# CONFIG_NET_RADIO is not set -+ -+# -+# Token Ring devices -+# -+# CONFIG_TR is not set -+# CONFIG_NET_FC is not set -+# CONFIG_RCPCI is not set -+# CONFIG_SHAPER is not set -+ -+# -+# Wan interfaces -+# -+# CONFIG_WAN is not set -+ -+# -+# Amateur Radio support -+# -+# CONFIG_HAMRADIO is not set -+ -+# -+# IrDA (infrared) support -+# -+# CONFIG_IRDA is not set -+ -+# -+# ISDN subsystem -+# -+# CONFIG_ISDN is not set -+ -+# -+# Input core support -+# -+CONFIG_INPUT=y -+CONFIG_INPUT_KEYBDEV=y -+CONFIG_INPUT_MOUSEDEV=y -+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024 -+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768 -+# CONFIG_INPUT_JOYDEV is not set -+CONFIG_INPUT_EVDEV=y -+# CONFIG_INPUT_UINPUT is not set -+ -+# -+# Character devices -+# -+CONFIG_VT=y -+CONFIG_VT_CONSOLE=y -+# CONFIG_SERIAL is not set -+# CONFIG_SERIAL_EXTENDED is not set -+CONFIG_SERIAL_NONSTANDARD=y -+# CONFIG_COMPUTONE is not set -+# CONFIG_ROCKETPORT is not set -+# CONFIG_CYCLADES is not set -+# CONFIG_DIGIEPCA is not set -+# CONFIG_DIGI is not set -+# CONFIG_ESPSERIAL is not set -+# CONFIG_MOXA_INTELLIO is not set -+# CONFIG_MOXA_SMARTIO is not set -+# CONFIG_ISI is not set -+# CONFIG_SYNCLINK is not set -+# CONFIG_SYNCLINKMP is not set -+# CONFIG_N_HDLC is not set -+# CONFIG_RISCOM8 is not set -+# CONFIG_SPECIALIX is not set -+# CONFIG_SX is not set -+# CONFIG_RIO is not set -+# CONFIG_STALDRV is not set -+# CONFIG_SERIAL_TX3912 is not set -+# CONFIG_SERIAL_TX3912_CONSOLE is not set -+# CONFIG_SERIAL_TXX9 is not set -+# CONFIG_SERIAL_TXX9_CONSOLE is not set -+# CONFIG_TXX927_SERIAL is not set -+CONFIG_UNIX98_PTYS=y -+CONFIG_UNIX98_PTY_COUNT=256 -+ -+# -+# I2C support -+# -+CONFIG_I2C=y -+# CONFIG_I2C_ALGOBIT is not set -+# CONFIG_SCx200_ACB is not set -+# CONFIG_I2C_ALGOPCF is not set -+# CONFIG_I2C_CHARDEV is not set -+# CONFIG_I2C_PROC is not set -+ -+# -+# Mice -+# -+# CONFIG_BUSMOUSE is not set -+# CONFIG_MOUSE is not set -+ -+# -+# Joysticks -+# -+# CONFIG_INPUT_GAMEPORT is not set -+# CONFIG_INPUT_NS558 is not set -+# CONFIG_INPUT_LIGHTNING is not set -+# CONFIG_INPUT_PCIGAME is not set -+# CONFIG_INPUT_CS461X is not set -+# CONFIG_INPUT_EMU10K1 is not set -+# CONFIG_INPUT_SERIO is not set -+# CONFIG_INPUT_SERPORT is not set -+ -+# -+# Joysticks -+# -+# CONFIG_INPUT_ANALOG is not set -+# CONFIG_INPUT_A3D is not set -+# CONFIG_INPUT_ADI is not set -+# CONFIG_INPUT_COBRA is not set -+# CONFIG_INPUT_GF2K is not set -+# CONFIG_INPUT_GRIP is not set -+# CONFIG_INPUT_INTERACT is not set -+# CONFIG_INPUT_TMDC is not set -+# CONFIG_INPUT_SIDEWINDER is not set -+# CONFIG_INPUT_IFORCE_USB is not set -+# CONFIG_INPUT_IFORCE_232 is not set -+# CONFIG_INPUT_WARRIOR is not set -+# CONFIG_INPUT_MAGELLAN is not set -+# CONFIG_INPUT_SPACEORB is not set -+# CONFIG_INPUT_SPACEBALL is not set -+# CONFIG_INPUT_STINGER is not set -+# CONFIG_INPUT_DB9 is not set -+# CONFIG_INPUT_GAMECON is not set -+# CONFIG_INPUT_TURBOGRAFX is not set -+# CONFIG_QIC02_TAPE is not set -+# CONFIG_IPMI_HANDLER is not set -+# CONFIG_IPMI_PANIC_EVENT is not set -+# CONFIG_IPMI_DEVICE_INTERFACE is not set -+# CONFIG_IPMI_KCS is not set -+# CONFIG_IPMI_WATCHDOG is not set -+ -+# -+# Watchdog Cards -+# -+# CONFIG_WATCHDOG is not set -+# CONFIG_SCx200 is not set -+# CONFIG_SCx200_GPIO is not set -+# CONFIG_AMD_PM768 is not set -+# CONFIG_NVRAM is not set -+# CONFIG_RTC is not set -+# CONFIG_DTLK is not set -+# CONFIG_R3964 is not set -+# CONFIG_APPLICOM is not set -+ -+# -+# Ftape, the floppy tape device driver -+# -+# CONFIG_FTAPE is not set -+# CONFIG_AGP is not set -+ -+# -+# Direct Rendering Manager (XFree86 DRI support) -+# -+# CONFIG_DRM is not set -+ -+# -+# File systems -+# -+# CONFIG_QUOTA is not set -+# CONFIG_QFMT_V2 is not set -+CONFIG_AUTOFS_FS=y -+# CONFIG_AUTOFS4_FS is not set -+# CONFIG_REISERFS_FS is not set -+# CONFIG_REISERFS_CHECK is not set -+# CONFIG_REISERFS_PROC_INFO is not set -+# CONFIG_ADFS_FS is not set -+# CONFIG_ADFS_FS_RW is not set -+# CONFIG_AFFS_FS is not set -+# CONFIG_HFS_FS is not set -+# CONFIG_HFSPLUS_FS is not set -+# CONFIG_BEFS_FS is not set -+# CONFIG_BEFS_DEBUG is not set -+# CONFIG_BFS_FS is not set -+CONFIG_EXT3_FS=y -+CONFIG_JBD=y -+# CONFIG_JBD_DEBUG is not set -+CONFIG_FAT_FS=y -+CONFIG_MSDOS_FS=y -+# CONFIG_UMSDOS_FS is not set -+CONFIG_VFAT_FS=y -+# CONFIG_EFS_FS is not set -+# CONFIG_JFFS_FS is not set -+# CONFIG_JFFS2_FS is not set -+# CONFIG_CRAMFS is not set -+# CONFIG_TMPFS is not set -+CONFIG_RAMFS=y -+# CONFIG_ISO9660_FS is not set -+# CONFIG_JOLIET is not set -+# CONFIG_ZISOFS is not set -+# CONFIG_JFS_FS is not set -+# CONFIG_JFS_DEBUG is not set -+# CONFIG_JFS_STATISTICS is not set -+# CONFIG_MINIX_FS is not set -+# CONFIG_VXFS_FS is not set -+# CONFIG_NTFS_FS is not set -+# CONFIG_NTFS_RW is not set -+# CONFIG_HPFS_FS is not set -+CONFIG_PROC_FS=y -+# CONFIG_DEVFS_FS is not set -+# CONFIG_DEVFS_MOUNT is not set -+# CONFIG_DEVFS_DEBUG is not set -+CONFIG_DEVPTS_FS=y -+# CONFIG_QNX4FS_FS is not set -+# CONFIG_QNX4FS_RW is not set -+# CONFIG_ROMFS_FS is not set -+CONFIG_EXT2_FS=y -+# CONFIG_SYSV_FS is not set -+# CONFIG_UDF_FS is not set -+# CONFIG_UDF_RW is not set -+# CONFIG_UFS_FS is not set -+# CONFIG_UFS_FS_WRITE is not set -+# CONFIG_XFS_FS is not set -+# CONFIG_XFS_QUOTA is not set -+# CONFIG_XFS_RT is not set -+# CONFIG_XFS_TRACE is not set -+# CONFIG_XFS_DEBUG is not set -+ -+# -+# Network File Systems -+# -+# CONFIG_CODA_FS is not set -+# CONFIG_INTERMEZZO_FS is not set -+# CONFIG_NFS_FS is not set -+# CONFIG_NFS_V3 is not set -+# CONFIG_NFS_DIRECTIO is not set -+# CONFIG_ROOT_NFS is not set -+# CONFIG_NFSD is not set -+# CONFIG_NFSD_V3 is not set -+# CONFIG_NFSD_TCP is not set -+# CONFIG_SUNRPC is not set -+# CONFIG_LOCKD is not set -+# CONFIG_SMB_FS is not set -+# CONFIG_NCP_FS is not set -+# CONFIG_NCPFS_PACKET_SIGNING is not set -+# CONFIG_NCPFS_IOCTL_LOCKING is not set -+# CONFIG_NCPFS_STRONG is not set -+# CONFIG_NCPFS_NFS_NS is not set -+# CONFIG_NCPFS_OS2_NS is not set -+# CONFIG_NCPFS_SMALLDOS is not set -+# CONFIG_NCPFS_NLS is not set -+# CONFIG_NCPFS_EXTRAS is not set -+# CONFIG_ZISOFS_FS is not set -+ -+# -+# Partition Types -+# -+# CONFIG_PARTITION_ADVANCED is not set -+CONFIG_MSDOS_PARTITION=y -+# CONFIG_SMB_NLS is not set -+CONFIG_NLS=y -+ -+# -+# Native Language Support -+# -+CONFIG_NLS_DEFAULT="iso8859-1" -+# CONFIG_NLS_CODEPAGE_437 is not set -+# CONFIG_NLS_CODEPAGE_737 is not set -+# CONFIG_NLS_CODEPAGE_775 is not set -+# CONFIG_NLS_CODEPAGE_850 is not set -+# CONFIG_NLS_CODEPAGE_852 is not set -+# CONFIG_NLS_CODEPAGE_855 is not set -+# CONFIG_NLS_CODEPAGE_857 is not set -+# CONFIG_NLS_CODEPAGE_860 is not set -+# CONFIG_NLS_CODEPAGE_861 is not set -+# CONFIG_NLS_CODEPAGE_862 is not set -+# CONFIG_NLS_CODEPAGE_863 is not set -+# CONFIG_NLS_CODEPAGE_864 is not set -+# CONFIG_NLS_CODEPAGE_865 is not set -+# CONFIG_NLS_CODEPAGE_866 is not set -+# CONFIG_NLS_CODEPAGE_869 is not set -+# CONFIG_NLS_CODEPAGE_936 is not set -+# CONFIG_NLS_CODEPAGE_950 is not set -+# CONFIG_NLS_CODEPAGE_932 is not set -+# CONFIG_NLS_CODEPAGE_949 is not set -+# CONFIG_NLS_CODEPAGE_874 is not set -+# CONFIG_NLS_ISO8859_8 is not set -+# CONFIG_NLS_CODEPAGE_1250 is not set -+# CONFIG_NLS_CODEPAGE_1251 is not set -+# CONFIG_NLS_ISO8859_1 is not set -+# CONFIG_NLS_ISO8859_2 is not set -+# CONFIG_NLS_ISO8859_3 is not set -+# CONFIG_NLS_ISO8859_4 is not set -+# CONFIG_NLS_ISO8859_5 is not set -+# CONFIG_NLS_ISO8859_6 is not set -+# CONFIG_NLS_ISO8859_7 is not set -+# CONFIG_NLS_ISO8859_9 is not set -+# CONFIG_NLS_ISO8859_13 is not set -+# CONFIG_NLS_ISO8859_14 is not set -+# CONFIG_NLS_ISO8859_15 is not set -+# CONFIG_NLS_KOI8_R is not set -+# CONFIG_NLS_KOI8_U is not set -+# CONFIG_NLS_UTF8 is not set -+ -+# -+# Multimedia devices -+# -+# CONFIG_VIDEO_DEV is not set -+ -+# -+# Console drivers -+# -+# CONFIG_VGA_CONSOLE is not set -+# CONFIG_MDA_CONSOLE is not set -+ -+# -+# Frame-buffer support -+# -+CONFIG_FB=y -+CONFIG_DUMMY_CONSOLE=y -+# CONFIG_FB_CYBER2000 is not set -+# CONFIG_FB_VIRTUAL is not set -+CONFIG_FBCON_ADVANCED=y -+# CONFIG_FBCON_MFB is not set -+# CONFIG_FBCON_CFB2 is not set -+# CONFIG_FBCON_CFB4 is not set -+# CONFIG_FBCON_CFB8 is not set -+CONFIG_FBCON_CFB16=y -+# CONFIG_FBCON_CFB24 is not set -+# CONFIG_FBCON_CFB32 is not set -+# CONFIG_FBCON_AFB is not set -+# CONFIG_FBCON_ILBM is not set -+# CONFIG_FBCON_IPLAN2P2 is not set -+# CONFIG_FBCON_IPLAN2P4 is not set -+# CONFIG_FBCON_IPLAN2P8 is not set -+# CONFIG_FBCON_MAC is not set -+# CONFIG_FBCON_VGA_PLANES is not set -+# CONFIG_FBCON_VGA is not set -+# CONFIG_FBCON_HGA is not set -+# CONFIG_FBCON_FONTWIDTH8_ONLY is not set -+CONFIG_FBCON_FONTS=y -+CONFIG_FONT_8x8=y -+CONFIG_FONT_8x16=y -+# CONFIG_FONT_SUN8x16 is not set -+# CONFIG_FONT_SUN12x22 is not set -+# CONFIG_FONT_6x11 is not set -+# CONFIG_FONT_PEARL_8x8 is not set -+# CONFIG_FONT_ACORN_8x8 is not set -+ -+# -+# Sound -+# -+CONFIG_SOUND=y -+# CONFIG_SOUND_ALI5455 is not set -+# CONFIG_SOUND_BT878 is not set -+# CONFIG_SOUND_CMPCI is not set -+# CONFIG_SOUND_EMU10K1 is not set -+# CONFIG_MIDI_EMU10K1 is not set -+# CONFIG_SOUND_FUSION is not set -+# CONFIG_SOUND_CS4281 is not set -+# CONFIG_SOUND_ES1370 is not set -+# CONFIG_SOUND_ES1371 is not set -+# CONFIG_SOUND_ESSSOLO1 is not set -+# CONFIG_SOUND_MAESTRO is not set -+# CONFIG_SOUND_MAESTRO3 is not set -+# CONFIG_SOUND_FORTE is not set -+# CONFIG_SOUND_ICH is not set -+# CONFIG_SOUND_RME96XX is not set -+# CONFIG_SOUND_SONICVIBES is not set -+# CONFIG_SOUND_TRIDENT is not set -+# CONFIG_SOUND_MSNDCLAS is not set -+# CONFIG_SOUND_MSNDPIN is not set -+# CONFIG_SOUND_VIA82CXXX is not set -+# CONFIG_MIDI_VIA82CXXX is not set -+# CONFIG_SOUND_OSS is not set -+# CONFIG_SOUND_TVMIXER is not set -+# CONFIG_SOUND_AD1980 is not set -+# CONFIG_SOUND_WM97XX is not set -+ -+# -+# USB support -+# -+# CONFIG_USB is not set -+ -+# -+# Support for USB gadgets -+# -+# CONFIG_USB_GADGET is not set -+ -+# -+# Bluetooth support -+# -+# CONFIG_BLUEZ is not set -+ -+# -+# Kernel hacking -+# -+CONFIG_CROSSCOMPILE=y -+# CONFIG_RUNTIME_DEBUG is not set -+# CONFIG_KGDB is not set -+# CONFIG_GDB_CONSOLE is not set -+# CONFIG_DEBUG_INFO is not set -+# CONFIG_MAGIC_SYSRQ is not set -+# CONFIG_MIPS_UNCACHED is not set -+CONFIG_LOG_BUF_SHIFT=0 -+ -+# -+# Cryptographic options -+# -+# CONFIG_CRYPTO is not set -+ -+# -+# Library routines -+# -+# CONFIG_CRC32 is not set -+CONFIG_ZLIB_INFLATE=m -+CONFIG_ZLIB_DEFLATE=m ---- a/arch/mips/defconfig-hp-lj -+++ b/arch/mips/defconfig-hp-lj -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -184,8 +184,8 @@ CONFIG_MTD_CFI_AMDSTD=y - # Mapping drivers for chip access - # - CONFIG_MTD_PHYSMAP=y --CONFIG_MTD_PHYSMAP_START=10040000 --CONFIG_MTD_PHYSMAP_LEN=00fc0000 -+CONFIG_MTD_PHYSMAP_START=0x10040000 -+CONFIG_MTD_PHYSMAP_LEN=0x00fc0000 - CONFIG_MTD_PHYSMAP_BUSWIDTH=4 - # CONFIG_MTD_PB1000 is not set - # CONFIG_MTD_PB1500 is not set -@@ -193,9 +193,7 @@ CONFIG_MTD_PHYSMAP_BUSWIDTH=4 - # CONFIG_MTD_BOSPORUS is not set - # CONFIG_MTD_XXS1500 is not set - # CONFIG_MTD_MTX1 is not set --# CONFIG_MTD_DB1X00 is not set - # CONFIG_MTD_PB1550 is not set --# CONFIG_MTD_HYDROGEN3 is not set - # CONFIG_MTD_MIRAGE is not set - # CONFIG_MTD_CSTM_MIPS_IXX is not set - # CONFIG_MTD_OCELOT is not set -@@ -214,7 +212,6 @@ CONFIG_MTD_PHYSMAP_BUSWIDTH=4 - # - # Disk-On-Chip Device Drivers - # --# CONFIG_MTD_DOC1000 is not set - # CONFIG_MTD_DOC2000 is not set - # CONFIG_MTD_DOC2001 is not set - # CONFIG_MTD_DOCPROBE is not set -@@ -304,11 +301,6 @@ CONFIG_IP_PNP_DHCP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -604,7 +596,6 @@ CONFIG_SERIAL=y - CONFIG_SERIAL_CONSOLE=y - # CONFIG_SERIAL_EXTENDED is not set - # CONFIG_SERIAL_NONSTANDARD is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - # CONFIG_UNIX98_PTYS is not set - - # ---- a/arch/mips/defconfig-hydrogen3 -+++ b/arch/mips/defconfig-hydrogen3 -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --CONFIG_MIPS_HYDROGEN3=y - # CONFIG_MIPS_PB1550 is not set -+CONFIG_MIPS_HYDROGEN3=y - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -214,9 +214,7 @@ CONFIG_MTD_CFI_AMDSTD=y - # CONFIG_MTD_BOSPORUS is not set - # CONFIG_MTD_XXS1500 is not set - # CONFIG_MTD_MTX1 is not set --# CONFIG_MTD_DB1X00 is not set - # CONFIG_MTD_PB1550 is not set --CONFIG_MTD_HYDROGEN3=y - # CONFIG_MTD_MIRAGE is not set - # CONFIG_MTD_CSTM_MIPS_IXX is not set - # CONFIG_MTD_OCELOT is not set -@@ -235,7 +233,6 @@ CONFIG_MTD_HYDROGEN3=y - # - # Disk-On-Chip Device Drivers - # --# CONFIG_MTD_DOC1000 is not set - # CONFIG_MTD_DOC2000 is not set - # CONFIG_MTD_DOC2001 is not set - # CONFIG_MTD_DOCPROBE is not set -@@ -340,11 +337,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -590,7 +582,6 @@ CONFIG_AU1X00_SERIAL_CONSOLE=y - # CONFIG_AU1X00_USB_TTY is not set - # CONFIG_AU1X00_USB_RAW is not set - # CONFIG_TXX927_SERIAL is not set --CONFIG_MIPS_HYDROGEN3_BUTTONS=y - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - -@@ -838,6 +829,7 @@ CONFIG_DUMMY_CONSOLE=y - # CONFIG_FB_PM2 is not set - # CONFIG_FB_PM3 is not set - # CONFIG_FB_CYBER2000 is not set -+CONFIG_FB_AU1100=y - # CONFIG_FB_MATROX is not set - # CONFIG_FB_ATY is not set - # CONFIG_FB_RADEON is not set -@@ -849,7 +841,6 @@ CONFIG_DUMMY_CONSOLE=y - # CONFIG_FB_VOODOO1 is not set - # CONFIG_FB_TRIDENT is not set - # CONFIG_FB_E1356 is not set --CONFIG_FB_AU1100=y - # CONFIG_FB_IT8181 is not set - # CONFIG_FB_VIRTUAL is not set - CONFIG_FBCON_ADVANCED=y ---- a/arch/mips/defconfig-ip22 -+++ b/arch/mips/defconfig-ip22 -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -235,11 +235,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -319,9 +314,11 @@ CONFIG_SGIWD93_SCSI=y - # CONFIG_SCSI_MEGARAID is not set - # CONFIG_SCSI_MEGARAID2 is not set - # CONFIG_SCSI_SATA is not set -+# CONFIG_SCSI_SATA_AHCI is not set - # CONFIG_SCSI_SATA_SVW is not set - # CONFIG_SCSI_ATA_PIIX is not set - # CONFIG_SCSI_SATA_NV is not set -+# CONFIG_SCSI_SATA_QSTOR is not set - # CONFIG_SCSI_SATA_PROMISE is not set - # CONFIG_SCSI_SATA_SX4 is not set - # CONFIG_SCSI_SATA_SIL is not set -@@ -465,7 +462,6 @@ CONFIG_VT_CONSOLE=y - # CONFIG_SERIAL is not set - # CONFIG_SERIAL_EXTENDED is not set - # CONFIG_SERIAL_NONSTANDARD is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips/defconfig-it8172 -+++ b/arch/mips/defconfig-it8172 -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -186,8 +186,8 @@ CONFIG_MTD_CFI_INTELEXT=y - # Mapping drivers for chip access - # - CONFIG_MTD_PHYSMAP=y --CONFIG_MTD_PHYSMAP_START=8000000 --CONFIG_MTD_PHYSMAP_LEN=2000000 -+CONFIG_MTD_PHYSMAP_START=0x8000000 -+CONFIG_MTD_PHYSMAP_LEN=0x2000000 - CONFIG_MTD_PHYSMAP_BUSWIDTH=4 - # CONFIG_MTD_PB1000 is not set - # CONFIG_MTD_PB1500 is not set -@@ -195,9 +195,7 @@ CONFIG_MTD_PHYSMAP_BUSWIDTH=4 - # CONFIG_MTD_BOSPORUS is not set - # CONFIG_MTD_XXS1500 is not set - # CONFIG_MTD_MTX1 is not set --# CONFIG_MTD_DB1X00 is not set - # CONFIG_MTD_PB1550 is not set --# CONFIG_MTD_HYDROGEN3 is not set - # CONFIG_MTD_MIRAGE is not set - # CONFIG_MTD_CSTM_MIPS_IXX is not set - # CONFIG_MTD_OCELOT is not set -@@ -216,7 +214,6 @@ CONFIG_MTD_PHYSMAP_BUSWIDTH=4 - # - # Disk-On-Chip Device Drivers - # --# CONFIG_MTD_DOC1000 is not set - # CONFIG_MTD_DOC2000 is not set - # CONFIG_MTD_DOC2001 is not set - # CONFIG_MTD_DOCPROBE is not set -@@ -304,11 +301,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -592,7 +584,6 @@ CONFIG_SERIAL_CONSOLE=y - CONFIG_PC_KEYB=y - # CONFIG_IT8172_SCR0 is not set - # CONFIG_IT8172_SCR1 is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips/defconfig-ivr -+++ b/arch/mips/defconfig-ivr -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -226,11 +226,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -516,7 +511,6 @@ CONFIG_SERIAL_CONSOLE=y - CONFIG_QTRONIX_KEYBOARD=y - CONFIG_IT8172_CIR=y - # CONFIG_IT8172_SCR0 is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips/defconfig-jmr3927 -+++ b/arch/mips/defconfig-jmr3927 -@@ -28,8 +28,8 @@ CONFIG_EXPERIMENTAL=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -225,11 +225,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -454,7 +449,6 @@ CONFIG_SERIAL_NONSTANDARD=y - # CONFIG_SERIAL_TXX9_CONSOLE is not set - CONFIG_TXX927_SERIAL=y - CONFIG_TXX927_SERIAL_CONSOLE=y --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - # CONFIG_UNIX98_PTYS is not set - - # ---- a/arch/mips/defconfig-lasat -+++ b/arch/mips/defconfig-lasat -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -198,9 +198,7 @@ CONFIG_MTD_CFI_AMDSTD=y - # CONFIG_MTD_BOSPORUS is not set - # CONFIG_MTD_XXS1500 is not set - # CONFIG_MTD_MTX1 is not set --# CONFIG_MTD_DB1X00 is not set - # CONFIG_MTD_PB1550 is not set --# CONFIG_MTD_HYDROGEN3 is not set - # CONFIG_MTD_MIRAGE is not set - # CONFIG_MTD_CSTM_MIPS_IXX is not set - # CONFIG_MTD_OCELOT is not set -@@ -219,7 +217,6 @@ CONFIG_MTD_LASAT=y - # - # Disk-On-Chip Device Drivers - # --# CONFIG_MTD_DOC1000 is not set - # CONFIG_MTD_DOC2000 is not set - # CONFIG_MTD_DOC2001 is not set - # CONFIG_MTD_DOCPROBE is not set -@@ -303,11 +300,6 @@ CONFIG_INET=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -584,7 +576,6 @@ CONFIG_SERIAL=y - CONFIG_SERIAL_CONSOLE=y - # CONFIG_SERIAL_EXTENDED is not set - # CONFIG_SERIAL_NONSTANDARD is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips/defconfig-malta -+++ b/arch/mips/defconfig-malta -@@ -22,16 +22,19 @@ CONFIG_KMOD=y - # - # CONFIG_ACER_PICA_61 is not set - # CONFIG_MIPS_BOSPORUS is not set -+# CONFIG_MIPS_FICMMP is not set - # CONFIG_MIPS_MIRAGE is not set - # CONFIG_MIPS_DB1000 is not set - # CONFIG_MIPS_DB1100 is not set - # CONFIG_MIPS_DB1500 is not set - # CONFIG_MIPS_DB1550 is not set -+# CONFIG_MIPS_DB1200 is not set - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_PB1200 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -237,11 +240,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -273,8 +271,83 @@ CONFIG_IP_PNP_BOOTP=y - # - # ATA/IDE/MFM/RLL support - # --# CONFIG_IDE is not set -+CONFIG_IDE=y -+ -+# -+# IDE, ATA and ATAPI Block devices -+# -+CONFIG_BLK_DEV_IDE=y -+ -+# -+# Please see Documentation/ide.txt for help/info on IDE drives -+# -+# CONFIG_BLK_DEV_HD_IDE is not set - # CONFIG_BLK_DEV_HD is not set -+# CONFIG_BLK_DEV_IDE_SATA is not set -+CONFIG_BLK_DEV_IDEDISK=y -+# CONFIG_IDEDISK_MULTI_MODE is not set -+# CONFIG_IDEDISK_STROKE is not set -+# CONFIG_BLK_DEV_IDECS is not set -+# CONFIG_BLK_DEV_DELKIN is not set -+CONFIG_BLK_DEV_IDECD=y -+CONFIG_BLK_DEV_IDETAPE=y -+CONFIG_BLK_DEV_IDEFLOPPY=y -+CONFIG_BLK_DEV_IDESCSI=y -+# CONFIG_IDE_TASK_IOCTL is not set -+ -+# -+# IDE chipset support/bugfixes -+# -+# CONFIG_BLK_DEV_CMD640 is not set -+# CONFIG_BLK_DEV_CMD640_ENHANCED is not set -+# CONFIG_BLK_DEV_ISAPNP is not set -+CONFIG_BLK_DEV_IDEPCI=y -+CONFIG_BLK_DEV_GENERIC=y -+CONFIG_IDEPCI_SHARE_IRQ=y -+CONFIG_BLK_DEV_IDEDMA_PCI=y -+# CONFIG_BLK_DEV_OFFBOARD is not set -+CONFIG_BLK_DEV_IDEDMA_FORCED=y -+CONFIG_IDEDMA_PCI_AUTO=y -+# CONFIG_IDEDMA_ONLYDISK is not set -+CONFIG_BLK_DEV_IDEDMA=y -+# CONFIG_IDEDMA_PCI_WIP is not set -+# CONFIG_BLK_DEV_ADMA100 is not set -+# CONFIG_BLK_DEV_AEC62XX is not set -+# CONFIG_BLK_DEV_ALI15X3 is not set -+# CONFIG_WDC_ALI15X3 is not set -+# CONFIG_BLK_DEV_AMD74XX is not set -+# CONFIG_AMD74XX_OVERRIDE is not set -+# CONFIG_BLK_DEV_ATIIXP is not set -+# CONFIG_BLK_DEV_CMD64X is not set -+# CONFIG_BLK_DEV_TRIFLEX is not set -+# CONFIG_BLK_DEV_CY82C693 is not set -+# CONFIG_BLK_DEV_CS5530 is not set -+# CONFIG_BLK_DEV_HPT34X is not set -+# CONFIG_HPT34X_AUTODMA is not set -+# CONFIG_BLK_DEV_HPT366 is not set -+CONFIG_BLK_DEV_PIIX=y -+# CONFIG_BLK_DEV_NS87415 is not set -+# CONFIG_BLK_DEV_OPTI621 is not set -+# CONFIG_BLK_DEV_PDC202XX_OLD is not set -+# CONFIG_PDC202XX_BURST is not set -+# CONFIG_BLK_DEV_PDC202XX_NEW is not set -+# CONFIG_BLK_DEV_RZ1000 is not set -+# CONFIG_BLK_DEV_SC1200 is not set -+# CONFIG_BLK_DEV_SVWKS is not set -+# CONFIG_BLK_DEV_SIIMAGE is not set -+# CONFIG_BLK_DEV_SIS5513 is not set -+# CONFIG_BLK_DEV_SLC90E66 is not set -+# CONFIG_BLK_DEV_TRM290 is not set -+# CONFIG_BLK_DEV_VIA82CXXX is not set -+# CONFIG_IDE_CHIPSETS is not set -+CONFIG_IDEDMA_AUTO=y -+# CONFIG_IDEDMA_IVB is not set -+# CONFIG_DMA_NONPCI is not set -+# CONFIG_BLK_DEV_ATARAID is not set -+# CONFIG_BLK_DEV_ATARAID_PDC is not set -+# CONFIG_BLK_DEV_ATARAID_HPT is not set -+# CONFIG_BLK_DEV_ATARAID_MEDLEY is not set -+# CONFIG_BLK_DEV_ATARAID_SII is not set - - # - # SCSI support -@@ -319,9 +392,11 @@ CONFIG_SD_EXTRA_DEVS=40 - # CONFIG_SCSI_MEGARAID is not set - # CONFIG_SCSI_MEGARAID2 is not set - # CONFIG_SCSI_SATA is not set -+# CONFIG_SCSI_SATA_AHCI is not set - # CONFIG_SCSI_SATA_SVW is not set - # CONFIG_SCSI_ATA_PIIX is not set - # CONFIG_SCSI_SATA_NV is not set -+# CONFIG_SCSI_SATA_QSTOR is not set - # CONFIG_SCSI_SATA_PROMISE is not set - # CONFIG_SCSI_SATA_SX4 is not set - # CONFIG_SCSI_SATA_SIL is not set -@@ -524,7 +599,6 @@ CONFIG_SERIAL=y - CONFIG_SERIAL_CONSOLE=y - # CONFIG_SERIAL_EXTENDED is not set - # CONFIG_SERIAL_NONSTANDARD is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips/defconfig-mirage -+++ b/arch/mips/defconfig-mirage -@@ -30,8 +30,8 @@ CONFIG_MIPS_MIRAGE=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -209,9 +209,7 @@ CONFIG_MTD_CFI_AMDSTD=y - # CONFIG_MTD_BOSPORUS is not set - # CONFIG_MTD_XXS1500 is not set - # CONFIG_MTD_MTX1 is not set --# CONFIG_MTD_DB1X00 is not set - # CONFIG_MTD_PB1550 is not set --# CONFIG_MTD_HYDROGEN3 is not set - CONFIG_MTD_MIRAGE=y - # CONFIG_MTD_CSTM_MIPS_IXX is not set - # CONFIG_MTD_OCELOT is not set -@@ -230,7 +228,6 @@ CONFIG_MTD_MIRAGE=y - # - # Disk-On-Chip Device Drivers - # --# CONFIG_MTD_DOC1000 is not set - # CONFIG_MTD_DOC2000 is not set - # CONFIG_MTD_DOC2001 is not set - # CONFIG_MTD_DOCPROBE is not set -@@ -335,11 +332,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -560,7 +552,6 @@ CONFIG_AU1X00_SERIAL_CONSOLE=y - # CONFIG_AU1X00_USB_TTY is not set - # CONFIG_AU1X00_USB_RAW is not set - # CONFIG_TXX927_SERIAL is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips/defconfig-mpc30x -+++ b/arch/mips/defconfig-mpc30x -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -228,11 +228,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -400,7 +395,6 @@ CONFIG_SERIAL=y - CONFIG_SERIAL_CONSOLE=y - # CONFIG_SERIAL_EXTENDED is not set - # CONFIG_SERIAL_NONSTANDARD is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - # CONFIG_VR41XX_KIU is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 ---- a/arch/mips/defconfig-mtx-1 -+++ b/arch/mips/defconfig-mtx-1 -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - CONFIG_MIPS_MTX1=y - # CONFIG_COGENT_CSB250 is not set -@@ -193,9 +193,7 @@ CONFIG_MTD_CFI_AMDSTD=y - # CONFIG_MTD_BOSPORUS is not set - # CONFIG_MTD_XXS1500 is not set - CONFIG_MTD_MTX1=y --# CONFIG_MTD_DB1X00 is not set - # CONFIG_MTD_PB1550 is not set --# CONFIG_MTD_HYDROGEN3 is not set - # CONFIG_MTD_MIRAGE is not set - # CONFIG_MTD_CSTM_MIPS_IXX is not set - # CONFIG_MTD_OCELOT is not set -@@ -214,7 +212,6 @@ CONFIG_MTD_MTX1=y - # - # Disk-On-Chip Device Drivers - # --# CONFIG_MTD_DOC1000 is not set - # CONFIG_MTD_DOC2000 is not set - # CONFIG_MTD_DOC2001 is not set - # CONFIG_MTD_DOCPROBE is not set -@@ -371,11 +368,6 @@ CONFIG_VLAN_8021Q=m - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - CONFIG_BRIDGE=m - # CONFIG_X25 is not set -@@ -479,9 +471,11 @@ CONFIG_SR_EXTRA_DEVS=2 - # CONFIG_SCSI_MEGARAID is not set - # CONFIG_SCSI_MEGARAID2 is not set - # CONFIG_SCSI_SATA is not set -+# CONFIG_SCSI_SATA_AHCI is not set - # CONFIG_SCSI_SATA_SVW is not set - # CONFIG_SCSI_ATA_PIIX is not set - # CONFIG_SCSI_SATA_NV is not set -+# CONFIG_SCSI_SATA_QSTOR is not set - # CONFIG_SCSI_SATA_PROMISE is not set - # CONFIG_SCSI_SATA_SX4 is not set - # CONFIG_SCSI_SATA_SIL is not set -@@ -700,7 +694,6 @@ CONFIG_AU1X00_SERIAL_CONSOLE=y - # CONFIG_AU1X00_USB_TTY is not set - # CONFIG_AU1X00_USB_RAW is not set - # CONFIG_TXX927_SERIAL is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips/defconfig-nino -+++ b/arch/mips/defconfig-nino -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -226,11 +226,6 @@ CONFIG_INET=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -339,7 +334,6 @@ CONFIG_SERIAL_TX3912_CONSOLE=y - # CONFIG_SERIAL_TXX9 is not set - # CONFIG_SERIAL_TXX9_CONSOLE is not set - # CONFIG_TXX927_SERIAL is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - # CONFIG_UNIX98_PTYS is not set - - # ---- a/arch/mips/defconfig-ocelot -+++ b/arch/mips/defconfig-ocelot -@@ -28,8 +28,8 @@ CONFIG_EXPERIMENTAL=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -194,9 +194,7 @@ CONFIG_MTD_JEDEC=y - # CONFIG_MTD_BOSPORUS is not set - # CONFIG_MTD_XXS1500 is not set - # CONFIG_MTD_MTX1 is not set --# CONFIG_MTD_DB1X00 is not set - # CONFIG_MTD_PB1550 is not set --# CONFIG_MTD_HYDROGEN3 is not set - # CONFIG_MTD_MIRAGE is not set - # CONFIG_MTD_CSTM_MIPS_IXX is not set - CONFIG_MTD_OCELOT=y -@@ -215,7 +213,6 @@ CONFIG_MTD_OCELOT=y - # - # Disk-On-Chip Device Drivers - # --# CONFIG_MTD_DOC1000 is not set - CONFIG_MTD_DOC2000=y - # CONFIG_MTD_DOC2001 is not set - CONFIG_MTD_DOCPROBE=y -@@ -307,11 +304,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -513,7 +505,6 @@ CONFIG_SERIAL=y - CONFIG_SERIAL_CONSOLE=y - # CONFIG_SERIAL_EXTENDED is not set - # CONFIG_SERIAL_NONSTANDARD is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips/defconfig-osprey -+++ b/arch/mips/defconfig-osprey -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -227,11 +227,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -388,7 +383,6 @@ CONFIG_SERIAL_MANY_PORTS=y - # CONFIG_SERIAL_MULTIPORT is not set - # CONFIG_HUB6 is not set - # CONFIG_SERIAL_NONSTANDARD is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - # CONFIG_VR41XX_KIU is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 ---- a/arch/mips/defconfig-pb1000 -+++ b/arch/mips/defconfig-pb1000 -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - CONFIG_MIPS_PB1000=y - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -215,9 +215,7 @@ CONFIG_MTD_PB1000=y - # CONFIG_MTD_BOSPORUS is not set - # CONFIG_MTD_XXS1500 is not set - # CONFIG_MTD_MTX1 is not set --# CONFIG_MTD_DB1X00 is not set - # CONFIG_MTD_PB1550 is not set --# CONFIG_MTD_HYDROGEN3 is not set - # CONFIG_MTD_MIRAGE is not set - # CONFIG_MTD_CSTM_MIPS_IXX is not set - # CONFIG_MTD_OCELOT is not set -@@ -236,7 +234,6 @@ CONFIG_MTD_PB1000=y - # - # Disk-On-Chip Device Drivers - # --# CONFIG_MTD_DOC1000 is not set - # CONFIG_MTD_DOC2000 is not set - # CONFIG_MTD_DOC2001 is not set - # CONFIG_MTD_DOCPROBE is not set -@@ -324,11 +321,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -622,7 +614,6 @@ CONFIG_AU1X00_SERIAL_CONSOLE=y - # CONFIG_AU1X00_USB_TTY is not set - # CONFIG_AU1X00_USB_RAW is not set - # CONFIG_TXX927_SERIAL is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - -@@ -707,7 +698,7 @@ CONFIG_UNIX98_PTY_COUNT=256 - # - # CONFIG_PCMCIA_SERIAL_CS is not set - # CONFIG_SYNCLINK_CS is not set --CONFIG_AU1X00_GPIO=m -+CONFIG_AU1X00_GPIO=y - # CONFIG_TS_AU1X00_ADS7846 is not set - - # ---- a/arch/mips/defconfig-pb1100 -+++ b/arch/mips/defconfig-pb1100 -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - CONFIG_MIPS_PB1100=y - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -198,9 +198,7 @@ CONFIG_MTD_PB1100=y - # CONFIG_MTD_MTX1 is not set - CONFIG_MTD_PB1500_BOOT=y - CONFIG_MTD_PB1500_USER=y --# CONFIG_MTD_DB1X00 is not set - # CONFIG_MTD_PB1550 is not set --# CONFIG_MTD_HYDROGEN3 is not set - # CONFIG_MTD_MIRAGE is not set - # CONFIG_MTD_CSTM_MIPS_IXX is not set - # CONFIG_MTD_OCELOT is not set -@@ -219,7 +217,6 @@ CONFIG_MTD_PB1500_USER=y - # - # Disk-On-Chip Device Drivers - # --# CONFIG_MTD_DOC1000 is not set - # CONFIG_MTD_DOC2000 is not set - # CONFIG_MTD_DOC2001 is not set - # CONFIG_MTD_DOCPROBE is not set -@@ -324,11 +321,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -613,7 +605,6 @@ CONFIG_AU1X00_SERIAL_CONSOLE=y - # CONFIG_AU1X00_USB_TTY is not set - # CONFIG_AU1X00_USB_RAW is not set - # CONFIG_TXX927_SERIAL is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - -@@ -859,6 +850,7 @@ CONFIG_DUMMY_CONSOLE=y - # CONFIG_FB_PM2 is not set - # CONFIG_FB_PM3 is not set - # CONFIG_FB_CYBER2000 is not set -+CONFIG_FB_AU1100=y - # CONFIG_FB_MATROX is not set - # CONFIG_FB_ATY is not set - # CONFIG_FB_RADEON is not set -@@ -870,7 +862,6 @@ CONFIG_DUMMY_CONSOLE=y - # CONFIG_FB_VOODOO1 is not set - # CONFIG_FB_TRIDENT is not set - # CONFIG_FB_E1356 is not set --CONFIG_FB_AU1100=y - # CONFIG_FB_IT8181 is not set - # CONFIG_FB_VIRTUAL is not set - CONFIG_FBCON_ADVANCED=y ---- /dev/null -+++ b/arch/mips/defconfig-pb1200 -@@ -0,0 +1,1060 @@ -+# -+# Automatically generated make config: don't edit -+# -+CONFIG_MIPS=y -+CONFIG_MIPS32=y -+# CONFIG_MIPS64 is not set -+ -+# -+# Code maturity level options -+# -+CONFIG_EXPERIMENTAL=y -+ -+# -+# Loadable module support -+# -+CONFIG_MODULES=y -+# CONFIG_MODVERSIONS is not set -+CONFIG_KMOD=y -+ -+# -+# Machine selection -+# -+# CONFIG_ACER_PICA_61 is not set -+# CONFIG_MIPS_BOSPORUS is not set -+# CONFIG_MIPS_MIRAGE is not set -+# CONFIG_MIPS_DB1000 is not set -+# CONFIG_MIPS_DB1100 is not set -+# CONFIG_MIPS_DB1500 is not set -+# CONFIG_MIPS_DB1550 is not set -+# CONFIG_MIPS_PB1000 is not set -+# CONFIG_MIPS_PB1100 is not set -+# CONFIG_MIPS_PB1500 is not set -+# CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set -+# CONFIG_MIPS_XXS1500 is not set -+# CONFIG_MIPS_MTX1 is not set -+# CONFIG_COGENT_CSB250 is not set -+# CONFIG_BAGET_MIPS is not set -+# CONFIG_CASIO_E55 is not set -+# CONFIG_MIPS_COBALT is not set -+# CONFIG_DECSTATION is not set -+# CONFIG_MIPS_EV64120 is not set -+# CONFIG_MIPS_EV96100 is not set -+# CONFIG_MIPS_IVR is not set -+# CONFIG_HP_LASERJET is not set -+# CONFIG_IBM_WORKPAD is not set -+# CONFIG_LASAT is not set -+# CONFIG_MIPS_ITE8172 is not set -+# CONFIG_MIPS_ATLAS is not set -+# CONFIG_MIPS_MAGNUM_4000 is not set -+# CONFIG_MIPS_MALTA is not set -+# CONFIG_MIPS_SEAD is not set -+# CONFIG_MOMENCO_OCELOT is not set -+# CONFIG_MOMENCO_OCELOT_G is not set -+# CONFIG_MOMENCO_OCELOT_C is not set -+# CONFIG_MOMENCO_JAGUAR_ATX is not set -+# CONFIG_PMC_BIG_SUR is not set -+# CONFIG_PMC_STRETCH is not set -+# CONFIG_PMC_YOSEMITE is not set -+# CONFIG_DDB5074 is not set -+# CONFIG_DDB5476 is not set -+# CONFIG_DDB5477 is not set -+# CONFIG_NEC_OSPREY is not set -+# CONFIG_NEC_EAGLE is not set -+# CONFIG_OLIVETTI_M700 is not set -+# CONFIG_NINO is not set -+# CONFIG_SGI_IP22 is not set -+# CONFIG_SGI_IP27 is not set -+# CONFIG_SIBYTE_SB1xxx_SOC is not set -+# CONFIG_SNI_RM200_PCI is not set -+# CONFIG_TANBAC_TB0226 is not set -+# CONFIG_TANBAC_TB0229 is not set -+# CONFIG_TOSHIBA_JMR3927 is not set -+# CONFIG_TOSHIBA_RBTX4927 is not set -+# CONFIG_VICTOR_MPC30X is not set -+# CONFIG_ZAO_CAPCELLA is not set -+# CONFIG_HIGHMEM is not set -+CONFIG_RWSEM_GENERIC_SPINLOCK=y -+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set -+CONFIG_SOC_AU1X00=y -+CONFIG_SOC_AU1200=y -+CONFIG_NONCOHERENT_IO=y -+CONFIG_PC_KEYB=y -+# CONFIG_MIPS_AU1000 is not set -+ -+# -+# CPU selection -+# -+CONFIG_CPU_MIPS32=y -+# CONFIG_CPU_MIPS64 is not set -+# CONFIG_CPU_R3000 is not set -+# CONFIG_CPU_TX39XX is not set -+# CONFIG_CPU_VR41XX is not set -+# CONFIG_CPU_R4300 is not set -+# CONFIG_CPU_R4X00 is not set -+# CONFIG_CPU_TX49XX is not set -+# CONFIG_CPU_R5000 is not set -+# CONFIG_CPU_R5432 is not set -+# CONFIG_CPU_R6000 is not set -+# CONFIG_CPU_NEVADA is not set -+# CONFIG_CPU_R8000 is not set -+# CONFIG_CPU_R10000 is not set -+# CONFIG_CPU_RM7000 is not set -+# CONFIG_CPU_RM9000 is not set -+# CONFIG_CPU_SB1 is not set -+CONFIG_PAGE_SIZE_4KB=y -+# CONFIG_PAGE_SIZE_16KB is not set -+# CONFIG_PAGE_SIZE_64KB is not set -+CONFIG_CPU_HAS_PREFETCH=y -+# CONFIG_VTAG_ICACHE is not set -+CONFIG_64BIT_PHYS_ADDR=y -+# CONFIG_CPU_ADVANCED is not set -+CONFIG_CPU_HAS_LLSC=y -+# CONFIG_CPU_HAS_LLDSCD is not set -+# CONFIG_CPU_HAS_WB is not set -+CONFIG_CPU_HAS_SYNC=y -+ -+# -+# General setup -+# -+CONFIG_CPU_LITTLE_ENDIAN=y -+# CONFIG_BUILD_ELF64 is not set -+CONFIG_NET=y -+CONFIG_PCI=y -+CONFIG_PCI_NEW=y -+CONFIG_PCI_AUTO=y -+# CONFIG_PCI_NAMES is not set -+# CONFIG_ISA is not set -+# CONFIG_TC is not set -+# CONFIG_MCA is not set -+# CONFIG_SBUS is not set -+CONFIG_HOTPLUG=y -+ -+# -+# PCMCIA/CardBus support -+# -+CONFIG_PCMCIA=m -+# CONFIG_CARDBUS is not set -+# CONFIG_TCIC is not set -+# CONFIG_I82092 is not set -+# CONFIG_I82365 is not set -+CONFIG_PCMCIA_AU1X00=m -+ -+# -+# PCI Hotplug Support -+# -+# CONFIG_HOTPLUG_PCI is not set -+# CONFIG_HOTPLUG_PCI_COMPAQ is not set -+# CONFIG_HOTPLUG_PCI_COMPAQ_NVRAM is not set -+# CONFIG_HOTPLUG_PCI_SHPC is not set -+# CONFIG_HOTPLUG_PCI_SHPC_POLL_EVENT_MODE is not set -+# CONFIG_HOTPLUG_PCI_PCIE is not set -+# CONFIG_HOTPLUG_PCI_PCIE_POLL_EVENT_MODE is not set -+CONFIG_SYSVIPC=y -+# CONFIG_BSD_PROCESS_ACCT is not set -+CONFIG_SYSCTL=y -+CONFIG_KCORE_ELF=y -+# CONFIG_KCORE_AOUT is not set -+# CONFIG_BINFMT_AOUT is not set -+CONFIG_BINFMT_ELF=y -+# CONFIG_MIPS32_COMPAT is not set -+# CONFIG_MIPS32_O32 is not set -+# CONFIG_MIPS32_N32 is not set -+# CONFIG_BINFMT_ELF32 is not set -+# CONFIG_BINFMT_MISC is not set -+# CONFIG_OOM_KILLER is not set -+CONFIG_CMDLINE_BOOL=y -+CONFIG_CMDLINE="mem=96M" -+# CONFIG_PM is not set -+ -+# -+# Memory Technology Devices (MTD) -+# -+# CONFIG_MTD is not set -+ -+# -+# Parallel port support -+# -+# CONFIG_PARPORT is not set -+ -+# -+# Plug and Play configuration -+# -+# CONFIG_PNP is not set -+# CONFIG_ISAPNP is not set -+ -+# -+# Block devices -+# -+# CONFIG_BLK_DEV_FD is not set -+# CONFIG_BLK_DEV_XD is not set -+# CONFIG_PARIDE is not set -+# CONFIG_BLK_CPQ_DA is not set -+# CONFIG_BLK_CPQ_CISS_DA is not set -+# CONFIG_CISS_SCSI_TAPE is not set -+# CONFIG_CISS_MONITOR_THREAD is not set -+# CONFIG_BLK_DEV_DAC960 is not set -+# CONFIG_BLK_DEV_UMEM is not set -+# CONFIG_BLK_DEV_SX8 is not set -+CONFIG_BLK_DEV_LOOP=y -+# CONFIG_BLK_DEV_NBD is not set -+# CONFIG_BLK_DEV_RAM is not set -+# CONFIG_BLK_DEV_INITRD is not set -+# CONFIG_BLK_STATS is not set -+ -+# -+# Multi-device support (RAID and LVM) -+# -+# CONFIG_MD is not set -+# CONFIG_BLK_DEV_MD is not set -+# CONFIG_MD_LINEAR is not set -+# CONFIG_MD_RAID0 is not set -+# CONFIG_MD_RAID1 is not set -+# CONFIG_MD_RAID5 is not set -+# CONFIG_MD_MULTIPATH is not set -+# CONFIG_BLK_DEV_LVM is not set -+ -+# -+# Networking options -+# -+CONFIG_PACKET=y -+# CONFIG_PACKET_MMAP is not set -+# CONFIG_NETLINK_DEV is not set -+CONFIG_NETFILTER=y -+# CONFIG_NETFILTER_DEBUG is not set -+CONFIG_FILTER=y -+CONFIG_UNIX=y -+CONFIG_INET=y -+CONFIG_IP_MULTICAST=y -+# CONFIG_IP_ADVANCED_ROUTER is not set -+CONFIG_IP_PNP=y -+# CONFIG_IP_PNP_DHCP is not set -+CONFIG_IP_PNP_BOOTP=y -+# CONFIG_IP_PNP_RARP is not set -+# CONFIG_NET_IPIP is not set -+# CONFIG_NET_IPGRE is not set -+# CONFIG_IP_MROUTE is not set -+# CONFIG_ARPD is not set -+# CONFIG_INET_ECN is not set -+# CONFIG_SYN_COOKIES is not set -+ -+# -+# IP: Netfilter Configuration -+# -+# CONFIG_IP_NF_CONNTRACK is not set -+# CONFIG_IP_NF_QUEUE is not set -+# CONFIG_IP_NF_IPTABLES is not set -+# CONFIG_IP_NF_ARPTABLES is not set -+# CONFIG_IP_NF_COMPAT_IPCHAINS is not set -+# CONFIG_IP_NF_COMPAT_IPFWADM is not set -+ -+# -+# IP: Virtual Server Configuration -+# -+# CONFIG_IP_VS is not set -+# CONFIG_IPV6 is not set -+# CONFIG_KHTTPD is not set -+ -+# -+# SCTP Configuration (EXPERIMENTAL) -+# -+# CONFIG_IP_SCTP is not set -+# CONFIG_ATM is not set -+# CONFIG_VLAN_8021Q is not set -+ -+# -+# -+# -+# CONFIG_IPX is not set -+# CONFIG_ATALK is not set -+# CONFIG_DECNET is not set -+# CONFIG_BRIDGE is not set -+# CONFIG_X25 is not set -+# CONFIG_LAPB is not set -+# CONFIG_LLC is not set -+# CONFIG_NET_DIVERT is not set -+# CONFIG_ECONET is not set -+# CONFIG_WAN_ROUTER is not set -+# CONFIG_NET_FASTROUTE is not set -+# CONFIG_NET_HW_FLOWCONTROL is not set -+ -+# -+# QoS and/or fair queueing -+# -+# CONFIG_NET_SCHED is not set -+ -+# -+# Network testing -+# -+# CONFIG_NET_PKTGEN is not set -+ -+# -+# Telephony Support -+# -+# CONFIG_PHONE is not set -+# CONFIG_PHONE_IXJ is not set -+# CONFIG_PHONE_IXJ_PCMCIA is not set -+ -+# -+# ATA/IDE/MFM/RLL support -+# -+CONFIG_IDE=y -+ -+# -+# IDE, ATA and ATAPI Block devices -+# -+CONFIG_BLK_DEV_IDE=y -+ -+# -+# Please see Documentation/ide.txt for help/info on IDE drives -+# -+# CONFIG_BLK_DEV_HD_IDE is not set -+# CONFIG_BLK_DEV_HD is not set -+# CONFIG_BLK_DEV_IDE_SATA is not set -+CONFIG_BLK_DEV_IDEDISK=y -+CONFIG_IDEDISK_MULTI_MODE=y -+CONFIG_IDEDISK_STROKE=y -+CONFIG_BLK_DEV_IDECS=m -+# CONFIG_BLK_DEV_DELKIN is not set -+# CONFIG_BLK_DEV_IDECD is not set -+# CONFIG_BLK_DEV_IDETAPE is not set -+# CONFIG_BLK_DEV_IDEFLOPPY is not set -+# CONFIG_BLK_DEV_IDESCSI is not set -+# CONFIG_IDE_TASK_IOCTL is not set -+ -+# -+# IDE chipset support/bugfixes -+# -+# CONFIG_BLK_DEV_CMD640 is not set -+# CONFIG_BLK_DEV_CMD640_ENHANCED is not set -+# CONFIG_BLK_DEV_ISAPNP is not set -+# CONFIG_BLK_DEV_IDEPCI is not set -+# CONFIG_IDE_CHIPSETS is not set -+# CONFIG_IDEDMA_AUTO is not set -+# CONFIG_DMA_NONPCI is not set -+# CONFIG_BLK_DEV_ATARAID is not set -+# CONFIG_BLK_DEV_ATARAID_PDC is not set -+# CONFIG_BLK_DEV_ATARAID_HPT is not set -+# CONFIG_BLK_DEV_ATARAID_MEDLEY is not set -+# CONFIG_BLK_DEV_ATARAID_SII is not set -+ -+# -+# SCSI support -+# -+CONFIG_SCSI=y -+ -+# -+# SCSI support type (disk, tape, CD-ROM) -+# -+CONFIG_BLK_DEV_SD=y -+CONFIG_SD_EXTRA_DEVS=40 -+CONFIG_CHR_DEV_ST=y -+# CONFIG_CHR_DEV_OSST is not set -+CONFIG_BLK_DEV_SR=y -+# CONFIG_BLK_DEV_SR_VENDOR is not set -+CONFIG_SR_EXTRA_DEVS=2 -+# CONFIG_CHR_DEV_SG is not set -+ -+# -+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs -+# -+# CONFIG_SCSI_DEBUG_QUEUES is not set -+# CONFIG_SCSI_MULTI_LUN is not set -+CONFIG_SCSI_CONSTANTS=y -+# CONFIG_SCSI_LOGGING is not set -+ -+# -+# SCSI low-level drivers -+# -+# CONFIG_BLK_DEV_3W_XXXX_RAID is not set -+# CONFIG_SCSI_7000FASST is not set -+# CONFIG_SCSI_ACARD is not set -+# CONFIG_SCSI_AHA152X is not set -+# CONFIG_SCSI_AHA1542 is not set -+# CONFIG_SCSI_AHA1740 is not set -+# CONFIG_SCSI_AACRAID is not set -+# CONFIG_SCSI_AIC7XXX is not set -+# CONFIG_SCSI_AIC79XX is not set -+# CONFIG_SCSI_AIC7XXX_OLD is not set -+# CONFIG_SCSI_DPT_I2O is not set -+# CONFIG_SCSI_ADVANSYS is not set -+# CONFIG_SCSI_IN2000 is not set -+# CONFIG_SCSI_AM53C974 is not set -+# CONFIG_SCSI_MEGARAID is not set -+# CONFIG_SCSI_MEGARAID2 is not set -+# CONFIG_SCSI_SATA is not set -+# CONFIG_SCSI_SATA_AHCI is not set -+# CONFIG_SCSI_SATA_SVW is not set -+# CONFIG_SCSI_ATA_PIIX is not set -+# CONFIG_SCSI_SATA_NV is not set -+# CONFIG_SCSI_SATA_QSTOR is not set -+# CONFIG_SCSI_SATA_PROMISE is not set -+# CONFIG_SCSI_SATA_SX4 is not set -+# CONFIG_SCSI_SATA_SIL is not set -+# CONFIG_SCSI_SATA_SIS is not set -+# CONFIG_SCSI_SATA_ULI is not set -+# CONFIG_SCSI_SATA_VIA is not set -+# CONFIG_SCSI_SATA_VITESSE is not set -+# CONFIG_SCSI_BUSLOGIC is not set -+# CONFIG_SCSI_CPQFCTS is not set -+# CONFIG_SCSI_DMX3191D is not set -+# CONFIG_SCSI_DTC3280 is not set -+# CONFIG_SCSI_EATA is not set -+# CONFIG_SCSI_EATA_DMA is not set -+# CONFIG_SCSI_EATA_PIO is not set -+# CONFIG_SCSI_FUTURE_DOMAIN is not set -+# CONFIG_SCSI_GDTH is not set -+# CONFIG_SCSI_GENERIC_NCR5380 is not set -+# CONFIG_SCSI_INITIO is not set -+# CONFIG_SCSI_INIA100 is not set -+# CONFIG_SCSI_NCR53C406A is not set -+# CONFIG_SCSI_NCR53C7xx is not set -+# CONFIG_SCSI_SYM53C8XX_2 is not set -+# CONFIG_SCSI_NCR53C8XX is not set -+# CONFIG_SCSI_SYM53C8XX is not set -+# CONFIG_SCSI_PAS16 is not set -+# CONFIG_SCSI_PCI2000 is not set -+# CONFIG_SCSI_PCI2220I is not set -+# CONFIG_SCSI_PSI240I is not set -+# CONFIG_SCSI_QLOGIC_FAS is not set -+# CONFIG_SCSI_QLOGIC_ISP is not set -+# CONFIG_SCSI_QLOGIC_FC is not set -+# CONFIG_SCSI_QLOGIC_1280 is not set -+# CONFIG_SCSI_SIM710 is not set -+# CONFIG_SCSI_SYM53C416 is not set -+# CONFIG_SCSI_DC390T is not set -+# CONFIG_SCSI_T128 is not set -+# CONFIG_SCSI_U14_34F is not set -+# CONFIG_SCSI_NSP32 is not set -+# CONFIG_SCSI_DEBUG is not set -+ -+# -+# PCMCIA SCSI adapter support -+# -+# CONFIG_SCSI_PCMCIA is not set -+ -+# -+# Fusion MPT device support -+# -+# CONFIG_FUSION is not set -+# CONFIG_FUSION_BOOT is not set -+# CONFIG_FUSION_ISENSE is not set -+# CONFIG_FUSION_CTL is not set -+# CONFIG_FUSION_LAN is not set -+ -+# -+# IEEE 1394 (FireWire) support (EXPERIMENTAL) -+# -+# CONFIG_IEEE1394 is not set -+ -+# -+# I2O device support -+# -+# CONFIG_I2O is not set -+# CONFIG_I2O_PCI is not set -+# CONFIG_I2O_BLOCK is not set -+# CONFIG_I2O_LAN is not set -+# CONFIG_I2O_SCSI is not set -+# CONFIG_I2O_PROC is not set -+ -+# -+# Network device support -+# -+CONFIG_NETDEVICES=y -+ -+# -+# ARCnet devices -+# -+# CONFIG_ARCNET is not set -+# CONFIG_DUMMY is not set -+# CONFIG_BONDING is not set -+# CONFIG_EQUALIZER is not set -+# CONFIG_TUN is not set -+# CONFIG_ETHERTAP is not set -+ -+# -+# Ethernet (10 or 100Mbit) -+# -+CONFIG_NET_ETHERNET=y -+# CONFIG_MIPS_AU1X00_ENET is not set -+# CONFIG_SUNLANCE is not set -+# CONFIG_HAPPYMEAL is not set -+# CONFIG_SUNBMAC is not set -+# CONFIG_SUNQE is not set -+# CONFIG_SUNGEM is not set -+# CONFIG_NET_VENDOR_3COM is not set -+# CONFIG_LANCE is not set -+# CONFIG_NET_VENDOR_SMC is not set -+# CONFIG_NET_VENDOR_RACAL is not set -+# CONFIG_HP100 is not set -+# CONFIG_NET_ISA is not set -+# CONFIG_NET_PCI is not set -+# CONFIG_NET_POCKET is not set -+ -+# -+# Ethernet (1000 Mbit) -+# -+# CONFIG_ACENIC is not set -+# CONFIG_DL2K is not set -+# CONFIG_E1000 is not set -+# CONFIG_MYRI_SBUS is not set -+# CONFIG_NS83820 is not set -+# CONFIG_HAMACHI is not set -+# CONFIG_YELLOWFIN is not set -+# CONFIG_R8169 is not set -+# CONFIG_SK98LIN is not set -+# CONFIG_TIGON3 is not set -+# CONFIG_FDDI is not set -+# CONFIG_HIPPI is not set -+# CONFIG_PLIP is not set -+CONFIG_PPP=m -+CONFIG_PPP_MULTILINK=y -+# CONFIG_PPP_FILTER is not set -+CONFIG_PPP_ASYNC=m -+# CONFIG_PPP_SYNC_TTY is not set -+CONFIG_PPP_DEFLATE=m -+# CONFIG_PPP_BSDCOMP is not set -+CONFIG_PPPOE=m -+# CONFIG_SLIP is not set -+ -+# -+# Wireless LAN (non-hamradio) -+# -+# CONFIG_NET_RADIO is not set -+ -+# -+# Token Ring devices -+# -+# CONFIG_TR is not set -+# CONFIG_NET_FC is not set -+# CONFIG_RCPCI is not set -+# CONFIG_SHAPER is not set -+ -+# -+# Wan interfaces -+# -+# CONFIG_WAN is not set -+ -+# -+# PCMCIA network device support -+# -+# CONFIG_NET_PCMCIA is not set -+ -+# -+# Amateur Radio support -+# -+# CONFIG_HAMRADIO is not set -+ -+# -+# IrDA (infrared) support -+# -+# CONFIG_IRDA is not set -+ -+# -+# ISDN subsystem -+# -+# CONFIG_ISDN is not set -+ -+# -+# Input core support -+# -+CONFIG_INPUT=y -+CONFIG_INPUT_KEYBDEV=y -+CONFIG_INPUT_MOUSEDEV=y -+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024 -+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768 -+# CONFIG_INPUT_JOYDEV is not set -+CONFIG_INPUT_EVDEV=y -+# CONFIG_INPUT_UINPUT is not set -+ -+# -+# Character devices -+# -+CONFIG_VT=y -+# CONFIG_VT_CONSOLE is not set -+# CONFIG_SERIAL is not set -+# CONFIG_SERIAL_EXTENDED is not set -+CONFIG_SERIAL_NONSTANDARD=y -+# CONFIG_COMPUTONE is not set -+# CONFIG_ROCKETPORT is not set -+# CONFIG_CYCLADES is not set -+# CONFIG_DIGIEPCA is not set -+# CONFIG_DIGI is not set -+# CONFIG_ESPSERIAL is not set -+# CONFIG_MOXA_INTELLIO is not set -+# CONFIG_MOXA_SMARTIO is not set -+# CONFIG_ISI is not set -+# CONFIG_SYNCLINK is not set -+# CONFIG_SYNCLINKMP is not set -+# CONFIG_N_HDLC is not set -+# CONFIG_RISCOM8 is not set -+# CONFIG_SPECIALIX is not set -+# CONFIG_SX is not set -+# CONFIG_RIO is not set -+# CONFIG_STALDRV is not set -+# CONFIG_SERIAL_TX3912 is not set -+# CONFIG_SERIAL_TX3912_CONSOLE is not set -+# CONFIG_SERIAL_TXX9 is not set -+# CONFIG_SERIAL_TXX9_CONSOLE is not set -+CONFIG_AU1X00_UART=y -+CONFIG_AU1X00_SERIAL_CONSOLE=y -+# CONFIG_AU1X00_USB_TTY is not set -+# CONFIG_AU1X00_USB_RAW is not set -+# CONFIG_TXX927_SERIAL is not set -+CONFIG_UNIX98_PTYS=y -+CONFIG_UNIX98_PTY_COUNT=256 -+ -+# -+# I2C support -+# -+CONFIG_I2C=y -+# CONFIG_I2C_ALGOBIT is not set -+# CONFIG_SCx200_ACB is not set -+# CONFIG_I2C_ALGOPCF is not set -+# CONFIG_I2C_CHARDEV is not set -+CONFIG_I2C_PROC=y -+ -+# -+# Mice -+# -+# CONFIG_BUSMOUSE is not set -+# CONFIG_MOUSE is not set -+ -+# -+# Joysticks -+# -+# CONFIG_INPUT_GAMEPORT is not set -+# CONFIG_INPUT_NS558 is not set -+# CONFIG_INPUT_LIGHTNING is not set -+# CONFIG_INPUT_PCIGAME is not set -+# CONFIG_INPUT_CS461X is not set -+# CONFIG_INPUT_EMU10K1 is not set -+# CONFIG_INPUT_SERIO is not set -+# CONFIG_INPUT_SERPORT is not set -+ -+# -+# Joysticks -+# -+# CONFIG_INPUT_ANALOG is not set -+# CONFIG_INPUT_A3D is not set -+# CONFIG_INPUT_ADI is not set -+# CONFIG_INPUT_COBRA is not set -+# CONFIG_INPUT_GF2K is not set -+# CONFIG_INPUT_GRIP is not set -+# CONFIG_INPUT_INTERACT is not set -+# CONFIG_INPUT_TMDC is not set -+# CONFIG_INPUT_SIDEWINDER is not set -+# CONFIG_INPUT_IFORCE_USB is not set -+# CONFIG_INPUT_IFORCE_232 is not set -+# CONFIG_INPUT_WARRIOR is not set -+# CONFIG_INPUT_MAGELLAN is not set -+# CONFIG_INPUT_SPACEORB is not set -+# CONFIG_INPUT_SPACEBALL is not set -+# CONFIG_INPUT_STINGER is not set -+# CONFIG_INPUT_DB9 is not set -+# CONFIG_INPUT_GAMECON is not set -+# CONFIG_INPUT_TURBOGRAFX is not set -+# CONFIG_QIC02_TAPE is not set -+# CONFIG_IPMI_HANDLER is not set -+# CONFIG_IPMI_PANIC_EVENT is not set -+# CONFIG_IPMI_DEVICE_INTERFACE is not set -+# CONFIG_IPMI_KCS is not set -+# CONFIG_IPMI_WATCHDOG is not set -+ -+# -+# Watchdog Cards -+# -+# CONFIG_WATCHDOG is not set -+# CONFIG_SCx200 is not set -+# CONFIG_SCx200_GPIO is not set -+# CONFIG_AMD_PM768 is not set -+# CONFIG_NVRAM is not set -+# CONFIG_RTC is not set -+# CONFIG_DTLK is not set -+# CONFIG_R3964 is not set -+# CONFIG_APPLICOM is not set -+ -+# -+# Ftape, the floppy tape device driver -+# -+# CONFIG_FTAPE is not set -+# CONFIG_AGP is not set -+ -+# -+# Direct Rendering Manager (XFree86 DRI support) -+# -+# CONFIG_DRM is not set -+ -+# -+# PCMCIA character devices -+# -+# CONFIG_PCMCIA_SERIAL_CS is not set -+# CONFIG_SYNCLINK_CS is not set -+# CONFIG_AU1X00_GPIO is not set -+# CONFIG_TS_AU1X00_ADS7846 is not set -+ -+# -+# File systems -+# -+# CONFIG_QUOTA is not set -+# CONFIG_QFMT_V2 is not set -+CONFIG_AUTOFS_FS=y -+# CONFIG_AUTOFS4_FS is not set -+# CONFIG_REISERFS_FS is not set -+# CONFIG_REISERFS_CHECK is not set -+# CONFIG_REISERFS_PROC_INFO is not set -+# CONFIG_ADFS_FS is not set -+# CONFIG_ADFS_FS_RW is not set -+# CONFIG_AFFS_FS is not set -+# CONFIG_HFS_FS is not set -+# CONFIG_HFSPLUS_FS is not set -+# CONFIG_BEFS_FS is not set -+# CONFIG_BEFS_DEBUG is not set -+# CONFIG_BFS_FS is not set -+CONFIG_EXT3_FS=y -+CONFIG_JBD=y -+# CONFIG_JBD_DEBUG is not set -+CONFIG_FAT_FS=y -+CONFIG_MSDOS_FS=y -+# CONFIG_UMSDOS_FS is not set -+CONFIG_VFAT_FS=y -+# CONFIG_EFS_FS is not set -+# CONFIG_JFFS_FS is not set -+# CONFIG_JFFS2_FS is not set -+# CONFIG_CRAMFS is not set -+CONFIG_TMPFS=y -+CONFIG_RAMFS=y -+# CONFIG_ISO9660_FS is not set -+# CONFIG_JOLIET is not set -+# CONFIG_ZISOFS is not set -+# CONFIG_JFS_FS is not set -+# CONFIG_JFS_DEBUG is not set -+# CONFIG_JFS_STATISTICS is not set -+# CONFIG_MINIX_FS is not set -+# CONFIG_VXFS_FS is not set -+# CONFIG_NTFS_FS is not set -+# CONFIG_NTFS_RW is not set -+# CONFIG_HPFS_FS is not set -+CONFIG_PROC_FS=y -+# CONFIG_DEVFS_FS is not set -+# CONFIG_DEVFS_MOUNT is not set -+# CONFIG_DEVFS_DEBUG is not set -+CONFIG_DEVPTS_FS=y -+# CONFIG_QNX4FS_FS is not set -+# CONFIG_QNX4FS_RW is not set -+# CONFIG_ROMFS_FS is not set -+CONFIG_EXT2_FS=y -+# CONFIG_SYSV_FS is not set -+# CONFIG_UDF_FS is not set -+# CONFIG_UDF_RW is not set -+# CONFIG_UFS_FS is not set -+# CONFIG_UFS_FS_WRITE is not set -+# CONFIG_XFS_FS is not set -+# CONFIG_XFS_QUOTA is not set -+# CONFIG_XFS_RT is not set -+# CONFIG_XFS_TRACE is not set -+# CONFIG_XFS_DEBUG is not set -+ -+# -+# Network File Systems -+# -+# CONFIG_CODA_FS is not set -+# CONFIG_INTERMEZZO_FS is not set -+CONFIG_NFS_FS=y -+CONFIG_NFS_V3=y -+# CONFIG_NFS_DIRECTIO is not set -+CONFIG_ROOT_NFS=y -+# CONFIG_NFSD is not set -+# CONFIG_NFSD_V3 is not set -+# CONFIG_NFSD_TCP is not set -+CONFIG_SUNRPC=y -+CONFIG_LOCKD=y -+CONFIG_LOCKD_V4=y -+# CONFIG_SMB_FS is not set -+# CONFIG_NCP_FS is not set -+# CONFIG_NCPFS_PACKET_SIGNING is not set -+# CONFIG_NCPFS_IOCTL_LOCKING is not set -+# CONFIG_NCPFS_STRONG is not set -+# CONFIG_NCPFS_NFS_NS is not set -+# CONFIG_NCPFS_OS2_NS is not set -+# CONFIG_NCPFS_SMALLDOS is not set -+# CONFIG_NCPFS_NLS is not set -+# CONFIG_NCPFS_EXTRAS is not set -+# CONFIG_ZISOFS_FS is not set -+ -+# -+# Partition Types -+# -+# CONFIG_PARTITION_ADVANCED is not set -+CONFIG_MSDOS_PARTITION=y -+# CONFIG_SMB_NLS is not set -+CONFIG_NLS=y -+ -+# -+# Native Language Support -+# -+CONFIG_NLS_DEFAULT="iso8859-1" -+# CONFIG_NLS_CODEPAGE_437 is not set -+# CONFIG_NLS_CODEPAGE_737 is not set -+# CONFIG_NLS_CODEPAGE_775 is not set -+# CONFIG_NLS_CODEPAGE_850 is not set -+# CONFIG_NLS_CODEPAGE_852 is not set -+# CONFIG_NLS_CODEPAGE_855 is not set -+# CONFIG_NLS_CODEPAGE_857 is not set -+# CONFIG_NLS_CODEPAGE_860 is not set -+# CONFIG_NLS_CODEPAGE_861 is not set -+# CONFIG_NLS_CODEPAGE_862 is not set -+# CONFIG_NLS_CODEPAGE_863 is not set -+# CONFIG_NLS_CODEPAGE_864 is not set -+# CONFIG_NLS_CODEPAGE_865 is not set -+# CONFIG_NLS_CODEPAGE_866 is not set -+# CONFIG_NLS_CODEPAGE_869 is not set -+# CONFIG_NLS_CODEPAGE_936 is not set -+# CONFIG_NLS_CODEPAGE_950 is not set -+# CONFIG_NLS_CODEPAGE_932 is not set -+# CONFIG_NLS_CODEPAGE_949 is not set -+# CONFIG_NLS_CODEPAGE_874 is not set -+# CONFIG_NLS_ISO8859_8 is not set -+# CONFIG_NLS_CODEPAGE_1250 is not set -+# CONFIG_NLS_CODEPAGE_1251 is not set -+# CONFIG_NLS_ISO8859_1 is not set -+# CONFIG_NLS_ISO8859_2 is not set -+# CONFIG_NLS_ISO8859_3 is not set -+# CONFIG_NLS_ISO8859_4 is not set -+# CONFIG_NLS_ISO8859_5 is not set -+# CONFIG_NLS_ISO8859_6 is not set -+# CONFIG_NLS_ISO8859_7 is not set -+# CONFIG_NLS_ISO8859_9 is not set -+# CONFIG_NLS_ISO8859_13 is not set -+# CONFIG_NLS_ISO8859_14 is not set -+# CONFIG_NLS_ISO8859_15 is not set -+# CONFIG_NLS_KOI8_R is not set -+# CONFIG_NLS_KOI8_U is not set -+# CONFIG_NLS_UTF8 is not set -+ -+# -+# Multimedia devices -+# -+# CONFIG_VIDEO_DEV is not set -+ -+# -+# Console drivers -+# -+# CONFIG_VGA_CONSOLE is not set -+# CONFIG_MDA_CONSOLE is not set -+ -+# -+# Frame-buffer support -+# -+CONFIG_FB=y -+CONFIG_DUMMY_CONSOLE=y -+# CONFIG_FB_RIVA is not set -+# CONFIG_FB_CLGEN is not set -+# CONFIG_FB_PM2 is not set -+# CONFIG_FB_PM3 is not set -+# CONFIG_FB_CYBER2000 is not set -+# CONFIG_FB_MATROX is not set -+# CONFIG_FB_ATY is not set -+# CONFIG_FB_RADEON is not set -+# CONFIG_FB_ATY128 is not set -+# CONFIG_FB_INTEL is not set -+# CONFIG_FB_SIS is not set -+# CONFIG_FB_NEOMAGIC is not set -+# CONFIG_FB_3DFX is not set -+# CONFIG_FB_VOODOO1 is not set -+# CONFIG_FB_TRIDENT is not set -+# CONFIG_FB_E1356 is not set -+# CONFIG_FB_IT8181 is not set -+# CONFIG_FB_VIRTUAL is not set -+CONFIG_FBCON_ADVANCED=y -+# CONFIG_FBCON_MFB is not set -+# CONFIG_FBCON_CFB2 is not set -+# CONFIG_FBCON_CFB4 is not set -+# CONFIG_FBCON_CFB8 is not set -+CONFIG_FBCON_CFB16=y -+# CONFIG_FBCON_CFB24 is not set -+CONFIG_FBCON_CFB32=y -+# CONFIG_FBCON_AFB is not set -+# CONFIG_FBCON_ILBM is not set -+# CONFIG_FBCON_IPLAN2P2 is not set -+# CONFIG_FBCON_IPLAN2P4 is not set -+# CONFIG_FBCON_IPLAN2P8 is not set -+# CONFIG_FBCON_MAC is not set -+# CONFIG_FBCON_VGA_PLANES is not set -+# CONFIG_FBCON_VGA is not set -+# CONFIG_FBCON_HGA is not set -+# CONFIG_FBCON_FONTWIDTH8_ONLY is not set -+CONFIG_FBCON_FONTS=y -+CONFIG_FONT_8x8=y -+CONFIG_FONT_8x16=y -+# CONFIG_FONT_SUN8x16 is not set -+# CONFIG_FONT_SUN12x22 is not set -+# CONFIG_FONT_6x11 is not set -+# CONFIG_FONT_PEARL_8x8 is not set -+# CONFIG_FONT_ACORN_8x8 is not set -+ -+# -+# Sound -+# -+CONFIG_SOUND=y -+# CONFIG_SOUND_ALI5455 is not set -+# CONFIG_SOUND_BT878 is not set -+# CONFIG_SOUND_CMPCI is not set -+# CONFIG_SOUND_EMU10K1 is not set -+# CONFIG_MIDI_EMU10K1 is not set -+# CONFIG_SOUND_FUSION is not set -+# CONFIG_SOUND_CS4281 is not set -+# CONFIG_SOUND_ES1370 is not set -+# CONFIG_SOUND_ES1371 is not set -+# CONFIG_SOUND_ESSSOLO1 is not set -+# CONFIG_SOUND_MAESTRO is not set -+# CONFIG_SOUND_MAESTRO3 is not set -+# CONFIG_SOUND_FORTE is not set -+# CONFIG_SOUND_ICH is not set -+# CONFIG_SOUND_RME96XX is not set -+# CONFIG_SOUND_SONICVIBES is not set -+# CONFIG_SOUND_AU1X00 is not set -+CONFIG_SOUND_AU1550_PSC=y -+# CONFIG_SOUND_AU1550_I2S is not set -+# CONFIG_SOUND_TRIDENT is not set -+# CONFIG_SOUND_MSNDCLAS is not set -+# CONFIG_SOUND_MSNDPIN is not set -+# CONFIG_SOUND_VIA82CXXX is not set -+# CONFIG_MIDI_VIA82CXXX is not set -+# CONFIG_SOUND_OSS is not set -+# CONFIG_SOUND_TVMIXER is not set -+# CONFIG_SOUND_AD1980 is not set -+# CONFIG_SOUND_WM97XX is not set -+ -+# -+# USB support -+# -+CONFIG_USB=y -+# CONFIG_USB_DEBUG is not set -+ -+# -+# Miscellaneous USB options -+# -+CONFIG_USB_DEVICEFS=y -+# CONFIG_USB_BANDWIDTH is not set -+ -+# -+# USB Host Controller Drivers -+# -+# CONFIG_USB_EHCI_HCD is not set -+# CONFIG_USB_UHCI is not set -+# CONFIG_USB_UHCI_ALT is not set -+CONFIG_USB_OHCI=y -+ -+# -+# USB Device Class drivers -+# -+# CONFIG_USB_AUDIO is not set -+# CONFIG_USB_EMI26 is not set -+# CONFIG_USB_BLUETOOTH is not set -+# CONFIG_USB_MIDI is not set -+CONFIG_USB_STORAGE=y -+# CONFIG_USB_STORAGE_DEBUG is not set -+# CONFIG_USB_STORAGE_DATAFAB is not set -+# CONFIG_USB_STORAGE_FREECOM is not set -+# CONFIG_USB_STORAGE_ISD200 is not set -+# CONFIG_USB_STORAGE_DPCM is not set -+# CONFIG_USB_STORAGE_HP8200e is not set -+# CONFIG_USB_STORAGE_SDDR09 is not set -+# CONFIG_USB_STORAGE_SDDR55 is not set -+# CONFIG_USB_STORAGE_JUMPSHOT is not set -+# CONFIG_USB_ACM is not set -+# CONFIG_USB_PRINTER is not set -+ -+# -+# USB Human Interface Devices (HID) -+# -+CONFIG_USB_HID=y -+CONFIG_USB_HIDINPUT=y -+CONFIG_USB_HIDDEV=y -+# CONFIG_USB_AIPTEK is not set -+# CONFIG_USB_WACOM is not set -+# CONFIG_USB_KBTAB is not set -+# CONFIG_USB_POWERMATE is not set -+ -+# -+# USB Imaging devices -+# -+# CONFIG_USB_DC2XX is not set -+# CONFIG_USB_MDC800 is not set -+# CONFIG_USB_SCANNER is not set -+# CONFIG_USB_MICROTEK is not set -+# CONFIG_USB_HPUSBSCSI is not set -+ -+# -+# USB Multimedia devices -+# -+ -+# -+# Video4Linux support is needed for USB Multimedia device support -+# -+ -+# -+# USB Network adaptors -+# -+# CONFIG_USB_PEGASUS is not set -+# CONFIG_USB_RTL8150 is not set -+# CONFIG_USB_KAWETH is not set -+# CONFIG_USB_CATC is not set -+# CONFIG_USB_CDCETHER is not set -+# CONFIG_USB_USBNET is not set -+ -+# -+# USB port drivers -+# -+# CONFIG_USB_USS720 is not set -+ -+# -+# USB Serial Converter support -+# -+# CONFIG_USB_SERIAL is not set -+ -+# -+# USB Miscellaneous drivers -+# -+# CONFIG_USB_RIO500 is not set -+# CONFIG_USB_AUERSWALD is not set -+# CONFIG_USB_TIGL is not set -+# CONFIG_USB_BRLVGER is not set -+# CONFIG_USB_LCD is not set -+ -+# -+# Support for USB gadgets -+# -+# CONFIG_USB_GADGET is not set -+ -+# -+# Bluetooth support -+# -+# CONFIG_BLUEZ is not set -+ -+# -+# Kernel hacking -+# -+CONFIG_CROSSCOMPILE=y -+# CONFIG_RUNTIME_DEBUG is not set -+# CONFIG_KGDB is not set -+# CONFIG_GDB_CONSOLE is not set -+# CONFIG_DEBUG_INFO is not set -+# CONFIG_MAGIC_SYSRQ is not set -+# CONFIG_MIPS_UNCACHED is not set -+CONFIG_LOG_BUF_SHIFT=0 -+ -+# -+# Cryptographic options -+# -+# CONFIG_CRYPTO is not set -+ -+# -+# Library routines -+# -+# CONFIG_CRC32 is not set -+CONFIG_ZLIB_INFLATE=m -+CONFIG_ZLIB_DEFLATE=m -+# CONFIG_FW_LOADER is not set ---- a/arch/mips/defconfig-pb1500 -+++ b/arch/mips/defconfig-pb1500 -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - CONFIG_MIPS_PB1500=y --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -215,9 +215,7 @@ CONFIG_MTD_PB1500=y - # CONFIG_MTD_MTX1 is not set - CONFIG_MTD_PB1500_BOOT=y - # CONFIG_MTD_PB1500_USER is not set --# CONFIG_MTD_DB1X00 is not set - # CONFIG_MTD_PB1550 is not set --# CONFIG_MTD_HYDROGEN3 is not set - # CONFIG_MTD_MIRAGE is not set - # CONFIG_MTD_CSTM_MIPS_IXX is not set - # CONFIG_MTD_OCELOT is not set -@@ -236,7 +234,6 @@ CONFIG_MTD_PB1500_BOOT=y - # - # Disk-On-Chip Device Drivers - # --# CONFIG_MTD_DOC1000 is not set - # CONFIG_MTD_DOC2000 is not set - # CONFIG_MTD_DOC2001 is not set - # CONFIG_MTD_DOCPROBE is not set -@@ -341,11 +338,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -675,7 +667,6 @@ CONFIG_AU1X00_SERIAL_CONSOLE=y - # CONFIG_AU1X00_USB_TTY is not set - # CONFIG_AU1X00_USB_RAW is not set - # CONFIG_TXX927_SERIAL is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips/defconfig-pb1550 -+++ b/arch/mips/defconfig-pb1550 -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - CONFIG_MIPS_PB1550=y -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -213,11 +213,9 @@ CONFIG_MTD_CFI_AMDSTD=y - # CONFIG_MTD_BOSPORUS is not set - # CONFIG_MTD_XXS1500 is not set - # CONFIG_MTD_MTX1 is not set --# CONFIG_MTD_DB1X00 is not set - CONFIG_MTD_PB1550=y - CONFIG_MTD_PB1550_BOOT=y - CONFIG_MTD_PB1550_USER=y --# CONFIG_MTD_HYDROGEN3 is not set - # CONFIG_MTD_MIRAGE is not set - # CONFIG_MTD_CSTM_MIPS_IXX is not set - # CONFIG_MTD_OCELOT is not set -@@ -236,7 +234,6 @@ CONFIG_MTD_PB1550_USER=y - # - # Disk-On-Chip Device Drivers - # --# CONFIG_MTD_DOC1000 is not set - # CONFIG_MTD_DOC2000 is not set - # CONFIG_MTD_DOC2001 is not set - # CONFIG_MTD_DOCPROBE is not set -@@ -343,11 +340,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -633,7 +625,6 @@ CONFIG_AU1X00_SERIAL_CONSOLE=y - # CONFIG_AU1X00_USB_TTY is not set - # CONFIG_AU1X00_USB_RAW is not set - # CONFIG_TXX927_SERIAL is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips/defconfig-rbtx4927 -+++ b/arch/mips/defconfig-rbtx4927 -@@ -28,8 +28,8 @@ CONFIG_EXPERIMENTAL=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -223,11 +223,6 @@ CONFIG_IP_PNP_DHCP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -466,7 +461,6 @@ CONFIG_SERIAL_NONSTANDARD=y - CONFIG_SERIAL_TXX9=y - CONFIG_SERIAL_TXX9_CONSOLE=y - # CONFIG_TXX927_SERIAL is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - # CONFIG_UNIX98_PTYS is not set - - # ---- a/arch/mips/defconfig-rm200 -+++ b/arch/mips/defconfig-rm200 -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -229,11 +229,6 @@ CONFIG_INET=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -340,7 +335,6 @@ CONFIG_VT_CONSOLE=y - # CONFIG_SERIAL is not set - # CONFIG_SERIAL_EXTENDED is not set - # CONFIG_SERIAL_NONSTANDARD is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips/defconfig-sb1250-swarm -+++ b/arch/mips/defconfig-sb1250-swarm -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -90,6 +90,7 @@ CONFIG_SIBYTE_CFE=y - # CONFIG_SIBYTE_TBPROF is not set - CONFIG_SIBYTE_GENBUS_IDE=y - CONFIG_SMP_CAPABLE=y -+CONFIG_MIPS_RTC=y - # CONFIG_SNI_RM200_PCI is not set - # CONFIG_TANBAC_TB0226 is not set - # CONFIG_TANBAC_TB0229 is not set -@@ -253,11 +254,6 @@ CONFIG_INET=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -469,7 +465,6 @@ CONFIG_SERIAL_NONSTANDARD=y - CONFIG_SIBYTE_SB1250_DUART=y - CONFIG_SIBYTE_SB1250_DUART_CONSOLE=y - CONFIG_SERIAL_CONSOLE=y --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips/defconfig-sead -+++ b/arch/mips/defconfig-sead -@@ -28,8 +28,8 @@ CONFIG_EXPERIMENTAL=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -244,7 +244,6 @@ CONFIG_SERIAL=y - CONFIG_SERIAL_CONSOLE=y - # CONFIG_SERIAL_EXTENDED is not set - # CONFIG_SERIAL_NONSTANDARD is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - # CONFIG_UNIX98_PTYS is not set - - # ---- a/arch/mips/defconfig-stretch -+++ b/arch/mips/defconfig-stretch -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -240,11 +240,6 @@ CONFIG_IP_PNP_DHCP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -324,9 +319,11 @@ CONFIG_CHR_DEV_SG=y - # CONFIG_SCSI_MEGARAID is not set - # CONFIG_SCSI_MEGARAID2 is not set - # CONFIG_SCSI_SATA is not set -+# CONFIG_SCSI_SATA_AHCI is not set - # CONFIG_SCSI_SATA_SVW is not set - # CONFIG_SCSI_ATA_PIIX is not set - # CONFIG_SCSI_SATA_NV is not set -+# CONFIG_SCSI_SATA_QSTOR is not set - # CONFIG_SCSI_SATA_PROMISE is not set - # CONFIG_SCSI_SATA_SX4 is not set - # CONFIG_SCSI_SATA_SIL is not set -@@ -516,7 +513,6 @@ CONFIG_SERIAL_NONSTANDARD=y - # CONFIG_SERIAL_TXX9 is not set - # CONFIG_SERIAL_TXX9_CONSOLE is not set - # CONFIG_TXX927_SERIAL is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips/defconfig-tb0226 -+++ b/arch/mips/defconfig-tb0226 -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -228,11 +228,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -312,9 +307,11 @@ CONFIG_SCSI_CONSTANTS=y - # CONFIG_SCSI_MEGARAID is not set - # CONFIG_SCSI_MEGARAID2 is not set - # CONFIG_SCSI_SATA is not set -+# CONFIG_SCSI_SATA_AHCI is not set - # CONFIG_SCSI_SATA_SVW is not set - # CONFIG_SCSI_ATA_PIIX is not set - # CONFIG_SCSI_SATA_NV is not set -+# CONFIG_SCSI_SATA_QSTOR is not set - # CONFIG_SCSI_SATA_PROMISE is not set - # CONFIG_SCSI_SATA_SX4 is not set - # CONFIG_SCSI_SATA_SIL is not set -@@ -518,7 +515,6 @@ CONFIG_SERIAL=y - CONFIG_SERIAL_CONSOLE=y - # CONFIG_SERIAL_EXTENDED is not set - # CONFIG_SERIAL_NONSTANDARD is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - # CONFIG_VR41XX_KIU is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 ---- a/arch/mips/defconfig-tb0229 -+++ b/arch/mips/defconfig-tb0229 -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -230,11 +230,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -445,7 +440,6 @@ CONFIG_SERIAL=y - CONFIG_SERIAL_CONSOLE=y - # CONFIG_SERIAL_EXTENDED is not set - # CONFIG_SERIAL_NONSTANDARD is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - # CONFIG_VR41XX_KIU is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 ---- a/arch/mips/defconfig-ti1500 -+++ b/arch/mips/defconfig-ti1500 -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - CONFIG_MIPS_XXS1500=y - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -213,9 +213,7 @@ CONFIG_MTD_CFI_AMDSTD=y - # CONFIG_MTD_BOSPORUS is not set - CONFIG_MTD_XXS1500=y - # CONFIG_MTD_MTX1 is not set --# CONFIG_MTD_DB1X00 is not set - # CONFIG_MTD_PB1550 is not set --# CONFIG_MTD_HYDROGEN3 is not set - # CONFIG_MTD_MIRAGE is not set - # CONFIG_MTD_CSTM_MIPS_IXX is not set - # CONFIG_MTD_OCELOT is not set -@@ -234,7 +232,6 @@ CONFIG_MTD_XXS1500=y - # - # Disk-On-Chip Device Drivers - # --# CONFIG_MTD_DOC1000 is not set - # CONFIG_MTD_DOC2000 is not set - # CONFIG_MTD_DOC2001 is not set - # CONFIG_MTD_DOCPROBE is not set -@@ -339,11 +336,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -600,7 +592,6 @@ CONFIG_AU1X00_SERIAL_CONSOLE=y - # CONFIG_AU1X00_USB_TTY is not set - # CONFIG_AU1X00_USB_RAW is not set - # CONFIG_TXX927_SERIAL is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips/defconfig-workpad -+++ b/arch/mips/defconfig-workpad -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -222,11 +222,6 @@ CONFIG_IP_MULTICAST=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -426,7 +421,6 @@ CONFIG_SERIAL_MANY_PORTS=y - # CONFIG_SERIAL_MULTIPORT is not set - # CONFIG_HUB6 is not set - # CONFIG_SERIAL_NONSTANDARD is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - # CONFIG_VR41XX_KIU is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 ---- a/arch/mips/defconfig-xxs1500 -+++ b/arch/mips/defconfig-xxs1500 -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - CONFIG_MIPS_XXS1500=y - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -213,9 +213,7 @@ CONFIG_MTD_CFI_AMDSTD=y - # CONFIG_MTD_BOSPORUS is not set - CONFIG_MTD_XXS1500=y - # CONFIG_MTD_MTX1 is not set --# CONFIG_MTD_DB1X00 is not set - # CONFIG_MTD_PB1550 is not set --# CONFIG_MTD_HYDROGEN3 is not set - # CONFIG_MTD_MIRAGE is not set - # CONFIG_MTD_CSTM_MIPS_IXX is not set - # CONFIG_MTD_OCELOT is not set -@@ -234,7 +232,6 @@ CONFIG_MTD_XXS1500=y - # - # Disk-On-Chip Device Drivers - # --# CONFIG_MTD_DOC1000 is not set - # CONFIG_MTD_DOC2000 is not set - # CONFIG_MTD_DOC2001 is not set - # CONFIG_MTD_DOCPROBE is not set -@@ -339,11 +336,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -671,7 +663,6 @@ CONFIG_AU1X00_SERIAL_CONSOLE=y - # CONFIG_AU1X00_USB_TTY is not set - # CONFIG_AU1X00_USB_RAW is not set - # CONFIG_TXX927_SERIAL is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips/defconfig-yosemite -+++ b/arch/mips/defconfig-yosemite -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -227,11 +227,6 @@ CONFIG_IP_PNP_DHCP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -310,9 +305,11 @@ CONFIG_CHR_DEV_SG=y - # CONFIG_SCSI_MEGARAID is not set - # CONFIG_SCSI_MEGARAID2 is not set - # CONFIG_SCSI_SATA is not set -+# CONFIG_SCSI_SATA_AHCI is not set - # CONFIG_SCSI_SATA_SVW is not set - # CONFIG_SCSI_ATA_PIIX is not set - # CONFIG_SCSI_SATA_NV is not set -+# CONFIG_SCSI_SATA_QSTOR is not set - # CONFIG_SCSI_SATA_PROMISE is not set - # CONFIG_SCSI_SATA_SX4 is not set - # CONFIG_SCSI_SATA_SIL is not set -@@ -477,7 +474,6 @@ CONFIG_SERIAL_NONSTANDARD=y - # CONFIG_SERIAL_TXX9 is not set - # CONFIG_SERIAL_TXX9_CONSOLE is not set - # CONFIG_TXX927_SERIAL is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips/kernel/cpu-probe.c -+++ b/arch/mips/kernel/cpu-probe.c -@@ -34,21 +34,16 @@ static void r4k_wait(void) - ".set\tmips0"); - } - --/* The Au1xxx wait is available only if we run CONFIG_PM and -- * the timer setup found we had a 32KHz counter available. -- * There are still problems with functions that may call au1k_wait -- * directly, but that will be discovered pretty quickly. -- */ --extern void (*au1k_wait_ptr)(void); --void au1k_wait(void) -+/* The Au1xxx wait is available only if using 32khz counter or -+ * external timer source, but specifically not CP0 Counter. */ -+int allow_au1k_wait; -+ -+static void au1k_wait(void) - { --#ifdef CONFIG_PM -- unsigned long addr; - /* using the wait instruction makes CP0 counter unusable */ -- __asm__("la %0,au1k_wait\n\t" -- ".set mips3\n\t" -- "cache 0x14,0(%0)\n\t" -- "cache 0x14,32(%0)\n\t" -+ __asm__(".set mips3\n\t" -+ "cache 0x14, 0(%0)\n\t" -+ "cache 0x14, 32(%0)\n\t" - "sync\n\t" - "nop\n\t" - "wait\n\t" -@@ -57,11 +52,7 @@ void au1k_wait(void) - "nop\n\t" - "nop\n\t" - ".set mips0\n\t" -- : : "r" (addr)); --#else -- __asm__("nop\n\t" -- "nop"); --#endif -+ : : "r" (au1k_wait)); - } - - static inline void check_wait(void) -@@ -100,20 +91,17 @@ static inline void check_wait(void) - cpu_wait = r4k_wait; - printk(" available.\n"); - break; --#ifdef CONFIG_PM - case CPU_AU1000: - case CPU_AU1100: - case CPU_AU1500: - case CPU_AU1550: -- if (au1k_wait_ptr != NULL) { -- cpu_wait = au1k_wait_ptr; -+ case CPU_AU1200: -+ if (allow_au1k_wait) { -+ cpu_wait = au1k_wait; - printk(" available.\n"); -- } -- else { -+ } else - printk(" unavailable.\n"); -- } - break; --#endif - default: - printk(" unavailable.\n"); - break; ---- a/arch/mips/kernel/head.S -+++ b/arch/mips/kernel/head.S -@@ -43,9 +43,9 @@ - - /* Cache Error */ - LEAF(except_vec2_generic) -+ .set push - .set noreorder - .set noat -- .set mips0 - /* - * This is a very bad place to be. Our cache error - * detection has triggered. If we have write-back data -@@ -64,10 +64,9 @@ - - j cache_parity_error - nop -+ .set pop - END(except_vec2_generic) - -- .set at -- - /* - * Special interrupt vector for embedded MIPS. This is a - * dedicated interrupt vector which reduces interrupt processing -@@ -76,8 +75,11 @@ - * size! - */ - NESTED(except_vec4, 0, sp) -+ .set push -+ .set noreorder - 1: j 1b /* Dummy, will be replaced */ - nop -+ .set pop - END(except_vec4) - - /* -@@ -87,8 +89,11 @@ - * unconditional jump to this vector. - */ - NESTED(except_vec_ejtag_debug, 0, sp) -+ .set push -+ .set noreorder - j ejtag_debug_handler - nop -+ .set pop - END(except_vec_ejtag_debug) - - __FINIT -@@ -97,6 +102,7 @@ - * EJTAG debug exception handler. - */ - NESTED(ejtag_debug_handler, PT_SIZE, sp) -+ .set push - .set noat - .set noreorder - mtc0 k0, CP0_DESAVE -@@ -120,7 +126,7 @@ ejtag_return: - deret - .set mips0 - nop -- .set at -+ .set pop - END(ejtag_debug_handler) - - __INIT -@@ -132,13 +138,17 @@ ejtag_return: - * unconditional jump to this vector. - */ - NESTED(except_vec_nmi, 0, sp) -+ .set push -+ .set noreorder - j nmi_handler - nop -+ .set pop - END(except_vec_nmi) - - __FINIT - - NESTED(nmi_handler, PT_SIZE, sp) -+ .set push - .set noat - .set noreorder - .set mips3 -@@ -147,8 +157,7 @@ ejtag_return: - move a0, sp - RESTORE_ALL - eret -- .set at -- .set mips0 -+ .set pop - END(nmi_handler) - - __INIT -@@ -157,7 +166,20 @@ ejtag_return: - * Kernel entry point - */ - NESTED(kernel_entry, 16, sp) -+ .set push -+ /* -+ * For the moment disable interrupts and mark the kernel mode. -+ * A full initialization of the CPU's status register is done -+ * later in per_cpu_trap_init(). -+ */ -+ mfc0 t0, CP0_STATUS -+ or t0, ST0_CU0|0x1f -+ xor t0, 0x1f -+ mtc0 t0, CP0_STATUS -+ - .set noreorder -+ sll zero,3 # ehb -+ .set reorder - - /* - * The firmware/bootloader passes argc/argp/envp -@@ -170,8 +192,8 @@ ejtag_return: - la t1, (_end - 4) - 1: - addiu t0, 4 -+ sw zero, (t0) - bne t0, t1, 1b -- sw zero, (t0) - - /* - * Stack for kernel and init, current variable -@@ -182,7 +204,7 @@ ejtag_return: - sw t0, kernelsp - - jal init_arch -- nop -+ .set pop - END(kernel_entry) - - -@@ -193,17 +215,26 @@ ejtag_return: - * function after setting up the stack and gp registers. - */ - LEAF(smp_bootstrap) -- .set push -- .set noreorder -- mtc0 zero, CP0_WIRED -- CLI -+ .set push -+ /* -+ * For the moment disable interrupts and bootstrap exception -+ * vectors and mark the kernel mode. A full initialization of -+ * the CPU's status register is done later in -+ * per_cpu_trap_init(). -+ */ - mfc0 t0, CP0_STATUS -- li t1, ~(ST0_CU1|ST0_CU2|ST0_CU3|ST0_KX|ST0_SX|ST0_UX) -- and t0, t1 -- or t0, (ST0_CU0); -+ or t0, ST0_CU0|ST0_BEV|0x1f -+ xor t0, ST0_BEV|0x1f -+ mtc0 t0, CP0_STATUS -+ -+ .set noreorder -+ sll zero,3 # ehb -+ .set reorder -+ -+ mtc0 zero, CP0_WIRED -+ - jal start_secondary -- mtc0 t0, CP0_STATUS -- .set pop -+ .set pop - END(smp_bootstrap) - #endif - ---- a/arch/mips/kernel/process.c -+++ b/arch/mips/kernel/process.c -@@ -128,6 +128,26 @@ int dump_fpu(struct pt_regs *regs, elf_f - return 1; - } - -+void dump_regs(elf_greg_t *gp, struct pt_regs *regs) -+{ -+ int i; -+ -+ for (i = 0; i < EF_REG0; i++) -+ gp[i] = 0; -+ gp[EF_REG0] = 0; -+ for (i = 1; i <= 31; i++) -+ gp[EF_REG0 + i] = regs->regs[i]; -+ gp[EF_REG26] = 0; -+ gp[EF_REG27] = 0; -+ gp[EF_LO] = regs->lo; -+ gp[EF_HI] = regs->hi; -+ gp[EF_CP0_EPC] = regs->cp0_epc; -+ gp[EF_CP0_BADVADDR] = regs->cp0_badvaddr; -+ gp[EF_CP0_STATUS] = regs->cp0_status; -+ gp[EF_CP0_CAUSE] = regs->cp0_cause; -+ gp[EF_UNUSED0] = 0; -+} -+ - /* - * Create a kernel thread - */ ---- a/arch/mips/kernel/scall_o32.S -+++ b/arch/mips/kernel/scall_o32.S -@@ -121,15 +121,14 @@ reschedule: - - trace_a_syscall: - SAVE_STATIC -- sw t2, PT_R1(sp) -+ move s0, t2 - jal syscall_trace -- lw t2, PT_R1(sp) - - lw a0, PT_R4(sp) # Restore argument registers - lw a1, PT_R5(sp) - lw a2, PT_R6(sp) - lw a3, PT_R7(sp) -- jalr t2 -+ jalr s0 - - li t0, -EMAXERRNO - 1 # error? - sltu t0, t0, v0 ---- a/arch/mips/kernel/setup.c -+++ b/arch/mips/kernel/setup.c -@@ -5,7 +5,7 @@ - * - * Copyright (C) 1995 Linus Torvalds - * Copyright (C) 1995 Waldorf Electronics -- * Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001 Ralf Baechle -+ * Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 01, 05 Ralf Baechle - * Copyright (C) 1996 Stoned Elipot - * Copyright (C) 2000, 2001, 2002 Maciej W. Rozycki - */ -@@ -71,6 +71,8 @@ extern void * __rd_start, * __rd_end; - extern struct rtc_ops no_rtc_ops; - struct rtc_ops *rtc_ops; - -+EXPORT_SYMBOL(rtc_ops); -+ - #ifdef CONFIG_PC_KEYB - struct kbd_ops *kbd_ops; - #endif -@@ -132,10 +134,6 @@ init_arch(int argc, char **argv, char ** - */ - load_mmu(); - -- /* Disable coprocessors and set FPU for 16/32 FPR register model */ -- clear_c0_status(ST0_CU1|ST0_CU2|ST0_CU3|ST0_KX|ST0_SX|ST0_FR); -- set_c0_status(ST0_CU0); -- - start_kernel(); - } - ---- a/arch/mips/kernel/traps.c -+++ b/arch/mips/kernel/traps.c -@@ -452,9 +452,10 @@ static inline void simulate_ll(struct pt - } - ll_task = current; - -+ compute_return_epc(regs); -+ - regs->regs[(opcode & RT) >> 16] = value; - -- compute_return_epc(regs); - return; - - sig: -@@ -485,8 +486,8 @@ static inline void simulate_sc(struct pt - goto sig; - } - if (ll_bit == 0 || ll_task != current) { -- regs->regs[reg] = 0; - compute_return_epc(regs); -+ regs->regs[reg] = 0; - return; - } - -@@ -495,9 +496,9 @@ static inline void simulate_sc(struct pt - goto sig; - } - -+ compute_return_epc(regs); - regs->regs[reg] = 1; - -- compute_return_epc(regs); - return; - - sig: -@@ -887,12 +888,18 @@ extern asmlinkage int fpu_emulator_resto - void __init per_cpu_trap_init(void) - { - unsigned int cpu = smp_processor_id(); -+ unsigned int status_set = ST0_CU0; - -- /* Some firmware leaves the BEV flag set, clear it. */ -- clear_c0_status(ST0_CU3|ST0_CU2|ST0_CU1|ST0_BEV|ST0_KX|ST0_SX|ST0_UX); -- -+ /* -+ * Disable coprocessors and 64-bit addressing and set FPU for -+ * the 16/32 FPR register model. Reset the BEV flag that some -+ * firmware may have left set and the TS bit (for IP27). Set -+ * XX for ISA IV code to work. -+ */ - if (current_cpu_data.isa_level == MIPS_CPU_ISA_IV) -- set_c0_status(ST0_XX); -+ status_set |= ST0_XX; -+ change_c0_status(ST0_CU|ST0_FR|ST0_BEV|ST0_TS|ST0_KX|ST0_SX|ST0_UX, -+ status_set); - - /* - * Some MIPS CPUs have a dedicated interrupt vector which reduces the -@@ -902,7 +909,7 @@ void __init per_cpu_trap_init(void) - set_c0_cause(CAUSEF_IV); - - cpu_data[cpu].asid_cache = ASID_FIRST_VERSION; -- write_c0_context(cpu << 23); -+ TLBMISS_HANDLER_SETUP(); - - atomic_inc(&init_mm.mm_count); - current->active_mm = &init_mm; -@@ -918,8 +925,6 @@ void __init trap_init(void) - extern char except_vec4; - unsigned long i; - -- per_cpu_trap_init(); -- - /* Copy the generic exception handler code to it's final destination. */ - memcpy((void *)(KSEG0 + 0x80), &except_vec1_generic, 0x80); - -@@ -1020,10 +1025,5 @@ void __init trap_init(void) - - flush_icache_range(KSEG0, KSEG0 + 0x400); - -- atomic_inc(&init_mm.mm_count); /* XXX UP? */ -- current->active_mm = &init_mm; -- -- /* XXX Must be done for all CPUs */ -- current_cpu_data.asid_cache = ASID_FIRST_VERSION; -- TLBMISS_HANDLER_SETUP(); -+ per_cpu_trap_init(); - } ---- a/arch/mips/lib/rtc-no.c -+++ b/arch/mips/lib/rtc-no.c -@@ -6,10 +6,9 @@ - * Stub RTC routines to keep Linux from crashing on machine which don't - * have a RTC chip. - * -- * Copyright (C) 1998, 2001 by Ralf Baechle -+ * Copyright (C) 1998, 2001, 2005 by Ralf Baechle - */ - #include <linux/kernel.h> --#include <linux/module.h> - #include <linux/mc146818rtc.h> - - static unsigned int shouldnt_happen(void) -@@ -29,5 +28,3 @@ struct rtc_ops no_rtc_ops = { - .rtc_write_data = (void *) &shouldnt_happen, - .rtc_bcd_mode = (void *) &shouldnt_happen - }; -- --EXPORT_SYMBOL(rtc_ops); ---- a/arch/mips/lib/rtc-std.c -+++ b/arch/mips/lib/rtc-std.c -@@ -5,9 +5,8 @@ - * - * RTC routines for PC style attached Dallas chip. - * -- * Copyright (C) 1998, 2001 by Ralf Baechle -+ * Copyright (C) 1998, 2001, 05 by Ralf Baechle - */ --#include <linux/module.h> - #include <linux/mc146818rtc.h> - #include <asm/io.h> - -@@ -33,5 +32,3 @@ struct rtc_ops std_rtc_ops = { - &std_rtc_write_data, - &std_rtc_bcd_mode - }; -- --EXPORT_SYMBOL(rtc_ops); ---- a/arch/mips/Makefile -+++ b/arch/mips/Makefile -@@ -209,7 +209,7 @@ LOADADDR := 0x80080000 - endif - - # --# Au1000 (Alchemy Semi PB1000) eval board -+# Au1x AMD Alchemy eval boards - # - ifdef CONFIG_MIPS_PB1000 - LIBS += arch/mips/au1000/pb1000/pb1000.o \ -@@ -218,9 +218,6 @@ SUBDIRS += arch/mips/au1000/pb1000 arch - LOADADDR := 0x80100000 - endif - --# --# Au1100 (Alchemy Semi PB1100) eval board --# - ifdef CONFIG_MIPS_PB1100 - LIBS += arch/mips/au1000/pb1100/pb1100.o \ - arch/mips/au1000/common/au1000.o -@@ -228,9 +225,6 @@ SUBDIRS += arch/mips/au1000/pb1100 - LOADADDR += 0x80100000 - endif - --# --# Au1500 (Alchemy Semi PB1500) eval board --# - ifdef CONFIG_MIPS_PB1500 - LIBS += arch/mips/au1000/pb1500/pb1500.o \ - arch/mips/au1000/common/au1000.o -@@ -238,9 +232,6 @@ SUBDIRS += arch/mips/au1000/pb1500 arch - LOADADDR := 0x80100000 - endif - --# --# Au1x00 (AMD/Alchemy) eval boards --# - ifdef CONFIG_MIPS_DB1000 - LIBS += arch/mips/au1000/db1x00/db1x00.o \ - arch/mips/au1000/common/au1000.o -@@ -311,6 +302,27 @@ SUBDIRS += arch/mips/au1000/pb1550 - LOADADDR += 0x80100000 - endif - -+ifdef CONFIG_MIPS_PB1200 -+LIBS += arch/mips/au1000/pb1200/pb1200.o \ -+ arch/mips/au1000/common/au1000.o -+SUBDIRS += arch/mips/au1000/pb1200 arch/mips/au1000/common -+LOADADDR += 0x80100000 -+endif -+ -+ifdef CONFIG_MIPS_DB1200 -+LIBS += arch/mips/au1000/pb1200/pb1200.o \ -+ arch/mips/au1000/common/au1000.o -+SUBDIRS += arch/mips/au1000/pb1200 arch/mips/au1000/common -+LOADADDR += 0x80100000 -+endif -+ -+ifdef CONFIG_MIPS_FICMMP -+LIBS += arch/mips/au1000/ficmmp/ficmmp.o \ -+ arch/mips/au1000/common/au1000.o -+SUBDIRS += arch/mips/au1000/ficmmp arch/mips/au1000/common -+LOADADDR += 0x80100000 -+endif -+ - - # - # Cogent CSB250 ---- a/arch/mips/mm/cerr-sb1.c -+++ b/arch/mips/mm/cerr-sb1.c -@@ -252,14 +252,14 @@ static const uint8_t parity[256] = { - - /* Masks to select bits for Hamming parity, mask_72_64[i] for bit[i] */ - static const uint64_t mask_72_64[8] = { -- 0x0738C808099264FFL, -- 0x38C808099264FF07L, -- 0xC808099264FF0738L, -- 0x08099264FF0738C8L, -- 0x099264FF0738C808L, -- 0x9264FF0738C80809L, -- 0x64FF0738C8080992L, -- 0xFF0738C808099264L -+ 0x0738C808099264FFULL, -+ 0x38C808099264FF07ULL, -+ 0xC808099264FF0738ULL, -+ 0x08099264FF0738C8ULL, -+ 0x099264FF0738C808ULL, -+ 0x9264FF0738C80809ULL, -+ 0x64FF0738C8080992ULL, -+ 0xFF0738C808099264ULL - }; - - /* Calculate the parity on a range of bits */ -@@ -331,9 +331,9 @@ static uint32_t extract_ic(unsigned shor - ((lru >> 4) & 0x3), - ((lru >> 6) & 0x3)); - } -- va = (taglo & 0xC0000FFFFFFFE000) | addr; -+ va = (taglo & 0xC0000FFFFFFFE000ULL) | addr; - if ((taglo & (1 << 31)) && (((taglo >> 62) & 0x3) == 3)) -- va |= 0x3FFFF00000000000; -+ va |= 0x3FFFF00000000000ULL; - valid = ((taghi >> 29) & 1); - if (valid) { - tlo_tmp = taglo & 0xfff3ff; -@@ -474,7 +474,7 @@ static uint32_t extract_dc(unsigned shor - : "r" ((way << 13) | addr)); - - taglo = ((unsigned long long)taglohi << 32) | taglolo; -- pa = (taglo & 0xFFFFFFE000) | addr; -+ pa = (taglo & 0xFFFFFFE000ULL) | addr; - if (way == 0) { - lru = (taghi >> 14) & 0xff; - prom_printf("[Bank %d Set 0x%02x] LRU > %d %d %d %d > MRU\n", ---- a/arch/mips/mm/c-r4k.c -+++ b/arch/mips/mm/c-r4k.c -@@ -867,9 +867,16 @@ static void __init probe_pcache(void) - * normally they'd suffer from aliases but magic in the hardware deals - * with that for us so we don't need to take care ourselves. - */ -- if (c->cputype != CPU_R10000 && c->cputype != CPU_R12000) -- if (c->dcache.waysize > PAGE_SIZE) -- c->dcache.flags |= MIPS_CACHE_ALIASES; -+ switch (c->cputype) { -+ case CPU_R10000: -+ case CPU_R12000: -+ break; -+ case CPU_24K: -+ if (!(read_c0_config7() & (1 << 16))) -+ default: -+ if (c->dcache.waysize > PAGE_SIZE) -+ c->dcache.flags |= MIPS_CACHE_ALIASES; -+ } - - switch (c->cputype) { - case CPU_20KC: -@@ -1069,9 +1076,6 @@ void __init ld_mmu_r4xx0(void) - probe_pcache(); - setup_scache(); - -- if (c->dcache.sets * c->dcache.ways > PAGE_SIZE) -- c->dcache.flags |= MIPS_CACHE_ALIASES; -- - r4k_blast_dcache_page_setup(); - r4k_blast_dcache_page_indexed_setup(); - r4k_blast_dcache_setup(); ---- a/arch/mips/mm/tlbex-mips32.S -+++ b/arch/mips/mm/tlbex-mips32.S -@@ -196,7 +196,7 @@ - .set noat; \ - SAVE_ALL; \ - mfc0 a2, CP0_BADVADDR; \ -- STI; \ -+ KMODE; \ - .set at; \ - move a0, sp; \ - jal do_page_fault; \ ---- a/arch/mips/mm/tlbex-r4k.S -+++ b/arch/mips/mm/tlbex-r4k.S -@@ -184,13 +184,10 @@ - P_MTC0 k0, CP0_ENTRYLO0 # load it - PTE_SRL k1, k1, 6 # convert to entrylo1 - P_MTC0 k1, CP0_ENTRYLO1 # load it -- b 1f -- rm9000_tlb_hazard -+ mtc0_tlbw_hazard - tlbwr # write random tlb entry --1: -- nop -- rm9000_tlb_hazard -- eret # return from trap -+ tlbw_eret_hazard -+ eret - END(except_vec0_r4000) - - /* TLB refill, EXL == 0, R4600 version */ -@@ -468,13 +465,9 @@ invalid_tlbl: - PTE_PRESENT(k0, k1, nopage_tlbl) - PTE_MAKEVALID(k0, k1) - PTE_RELOAD(k1, k0) -- rm9000_tlb_hazard -- nop -- b 1f -- tlbwi --1: -- nop -- rm9000_tlb_hazard -+ mtc0_tlbw_hazard -+ tlbwi -+ tlbw_eret_hazard - .set mips3 - eret - .set mips0 -@@ -496,13 +489,9 @@ nopage_tlbl: - PTE_WRITABLE(k0, k1, nopage_tlbs) - PTE_MAKEWRITE(k0, k1) - PTE_RELOAD(k1, k0) -- rm9000_tlb_hazard -- nop -- b 1f -- tlbwi --1: -- nop -- rm9000_tlb_hazard -+ mtc0_tlbw_hazard -+ tlbwi -+ tlbw_eret_hazard - .set mips3 - eret - .set mips0 -@@ -529,13 +518,9 @@ nopage_tlbs: - - /* Now reload the entry into the tlb. */ - PTE_RELOAD(k1, k0) -- rm9000_tlb_hazard -- nop -- b 1f -- tlbwi --1: -- rm9000_tlb_hazard -- nop -+ mtc0_tlbw_hazard -+ tlbwi -+ tlbw_eret_hazard - .set mips3 - eret - .set mips0 ---- a/arch/mips/mm/tlb-r4k.c -+++ b/arch/mips/mm/tlb-r4k.c -@@ -3,17 +3,12 @@ - * License. See the file "COPYING" in the main directory of this archive - * for more details. - * -- * r4xx0.c: R4000 processor variant specific MMU/Cache routines. -- * - * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) - * Copyright (C) 1997, 1998, 1999, 2000 Ralf Baechle ralf@gnu.org -- * -- * To do: -- * -- * - this code is a overbloated pig -- * - many of the bug workarounds are not efficient at all, but at -- * least they are functional ... -+ * Carsten Langgaard, carstenl@mips.com -+ * Copyright (C) 2002 MIPS Technologies, Inc. All rights reserved. - */ -+#include <linux/config.h> - #include <linux/init.h> - #include <linux/sched.h> - #include <linux/mm.h> -@@ -25,9 +20,6 @@ - #include <asm/pgtable.h> - #include <asm/system.h> - --#undef DEBUG_TLB --#undef DEBUG_TLBUPDATE -- - extern char except_vec0_nevada, except_vec0_r4000, except_vec0_r4600; - - /* CP0 hazard avoidance. */ -@@ -41,33 +33,23 @@ void local_flush_tlb_all(void) - unsigned long old_ctx; - int entry; - --#ifdef DEBUG_TLB -- printk("[tlball]"); --#endif -- - local_irq_save(flags); - /* Save old context and create impossible VPN2 value */ - old_ctx = read_c0_entryhi(); - write_c0_entrylo0(0); - write_c0_entrylo1(0); -- BARRIER; - - entry = read_c0_wired(); - - /* Blast 'em all away. */ - while (entry < current_cpu_data.tlbsize) { -- /* -- * Make sure all entries differ. If they're not different -- * MIPS32 will take revenge ... -- */ - write_c0_entryhi(KSEG0 + entry*0x2000); - write_c0_index(entry); -- BARRIER; -+ mtc0_tlbw_hazard(); - tlb_write_indexed(); -- BARRIER; - entry++; - } -- BARRIER; -+ tlbw_use_hazard(); - write_c0_entryhi(old_ctx); - local_irq_restore(flags); - } -@@ -76,12 +58,8 @@ void local_flush_tlb_mm(struct mm_struct - { - int cpu = smp_processor_id(); - -- if (cpu_context(cpu, mm) != 0) { --#ifdef DEBUG_TLB -- printk("[tlbmm<%d>]", cpu_context(cpu, mm)); --#endif -+ if (cpu_context(cpu, mm) != 0) - drop_mmu_context(mm,cpu); -- } - } - - void local_flush_tlb_range(struct mm_struct *mm, unsigned long start, -@@ -93,10 +71,6 @@ void local_flush_tlb_range(struct mm_str - unsigned long flags; - int size; - --#ifdef DEBUG_TLB -- printk("[tlbrange<%02x,%08lx,%08lx>]", -- cpu_asid(cpu, mm), start, end); --#endif - local_irq_save(flags); - size = (end - start + (PAGE_SIZE - 1)) >> PAGE_SHIFT; - size = (size + 1) >> 1; -@@ -112,7 +86,7 @@ void local_flush_tlb_range(struct mm_str - - write_c0_entryhi(start | newpid); - start += (PAGE_SIZE << 1); -- BARRIER; -+ mtc0_tlbw_hazard(); - tlb_probe(); - BARRIER; - idx = read_c0_index(); -@@ -122,10 +96,10 @@ void local_flush_tlb_range(struct mm_str - continue; - /* Make sure all entries differ. */ - write_c0_entryhi(KSEG0 + idx*0x2000); -- BARRIER; -+ mtc0_tlbw_hazard(); - tlb_write_indexed(); -- BARRIER; - } -+ tlbw_use_hazard(); - write_c0_entryhi(oldpid); - } else { - drop_mmu_context(mm, cpu); -@@ -138,34 +112,30 @@ void local_flush_tlb_page(struct vm_area - { - int cpu = smp_processor_id(); - -- if (!vma || cpu_context(cpu, vma->vm_mm) != 0) { -+ if (cpu_context(cpu, vma->vm_mm) != 0) { - unsigned long flags; -- int oldpid, newpid, idx; -+ unsigned long oldpid, newpid, idx; - --#ifdef DEBUG_TLB -- printk("[tlbpage<%d,%08lx>]", cpu_context(cpu, vma->vm_mm), -- page); --#endif - newpid = cpu_asid(cpu, vma->vm_mm); - page &= (PAGE_MASK << 1); - local_irq_save(flags); - oldpid = read_c0_entryhi(); - write_c0_entryhi(page | newpid); -- BARRIER; -+ mtc0_tlbw_hazard(); - tlb_probe(); - BARRIER; - idx = read_c0_index(); - write_c0_entrylo0(0); - write_c0_entrylo1(0); -- if(idx < 0) -+ if (idx < 0) - goto finish; - /* Make sure all entries differ. */ - write_c0_entryhi(KSEG0+idx*0x2000); -- BARRIER; -+ mtc0_tlbw_hazard(); - tlb_write_indexed(); -+ tlbw_use_hazard(); - - finish: -- BARRIER; - write_c0_entryhi(oldpid); - local_irq_restore(flags); - } -@@ -185,7 +155,7 @@ void local_flush_tlb_one(unsigned long p - - local_irq_save(flags); - write_c0_entryhi(page); -- BARRIER; -+ mtc0_tlbw_hazard(); - tlb_probe(); - BARRIER; - idx = read_c0_index(); -@@ -194,18 +164,19 @@ void local_flush_tlb_one(unsigned long p - if (idx >= 0) { - /* Make sure all entries differ. */ - write_c0_entryhi(KSEG0+idx*0x2000); -+ mtc0_tlbw_hazard(); - tlb_write_indexed(); -+ tlbw_use_hazard(); - } -- BARRIER; - write_c0_entryhi(oldpid); -+ - local_irq_restore(flags); - } - - EXPORT_SYMBOL(local_flush_tlb_one); - --/* We will need multiple versions of update_mmu_cache(), one that just -- * updates the TLB with the new pte(s), and another which also checks -- * for the R4k "end of page" hardware bug and does the needy. -+/* -+ * Updates the TLB with the new pte(s). - */ - void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte) - { -@@ -223,25 +194,16 @@ void __update_tlb(struct vm_area_struct - - pid = read_c0_entryhi() & ASID_MASK; - --#ifdef DEBUG_TLB -- if ((pid != cpu_asid(cpu, vma->vm_mm)) || -- (cpu_context(vma->vm_mm) == 0)) { -- printk("update_mmu_cache: Wheee, bogus tlbpid mmpid=%d " -- "tlbpid=%d\n", (int) (cpu_asid(cpu, vma->vm_mm)), pid); -- } --#endif -- - local_irq_save(flags); - address &= (PAGE_MASK << 1); - write_c0_entryhi(address | pid); - pgdp = pgd_offset(vma->vm_mm, address); -- BARRIER; -+ mtc0_tlbw_hazard(); - tlb_probe(); - BARRIER; - pmdp = pmd_offset(pgdp, address); - idx = read_c0_index(); - ptep = pte_offset(pmdp, address); -- BARRIER; - #if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32) - write_c0_entrylo0(ptep->pte_high); - ptep++; -@@ -251,15 +213,13 @@ void __update_tlb(struct vm_area_struct - write_c0_entrylo1(pte_val(*ptep) >> 6); - #endif - write_c0_entryhi(address | pid); -- BARRIER; -- if (idx < 0) { -+ mtc0_tlbw_hazard(); -+ if (idx < 0) - tlb_write_random(); -- } else { -+ else - tlb_write_indexed(); -- } -- BARRIER; -+ tlbw_use_hazard(); - write_c0_entryhi(pid); -- BARRIER; - local_irq_restore(flags); - } - -@@ -279,24 +239,26 @@ static void r4k_update_mmu_cache_hwbug(s - asid = read_c0_entryhi() & ASID_MASK; - write_c0_entryhi(address | asid); - pgdp = pgd_offset(vma->vm_mm, address); -+ mtc0_tlbw_hazard(); - tlb_probe(); -+ BARRIER; - pmdp = pmd_offset(pgdp, address); - idx = read_c0_index(); - ptep = pte_offset(pmdp, address); - write_c0_entrylo0(pte_val(*ptep++) >> 6); - write_c0_entrylo1(pte_val(*ptep) >> 6); -- BARRIER; -+ mtc0_tlbw_hazard(); - if (idx < 0) - tlb_write_random(); - else - tlb_write_indexed(); -- BARRIER; -+ tlbw_use_hazard(); - local_irq_restore(flags); - } - #endif - - void __init add_wired_entry(unsigned long entrylo0, unsigned long entrylo1, -- unsigned long entryhi, unsigned long pagemask) -+ unsigned long entryhi, unsigned long pagemask) - { - unsigned long flags; - unsigned long wired; -@@ -315,9 +277,9 @@ void __init add_wired_entry(unsigned lon - write_c0_entryhi(entryhi); - write_c0_entrylo0(entrylo0); - write_c0_entrylo1(entrylo1); -- BARRIER; -+ mtc0_tlbw_hazard(); - tlb_write_indexed(); -- BARRIER; -+ tlbw_use_hazard(); - - write_c0_entryhi(old_ctx); - BARRIER; -@@ -355,17 +317,15 @@ __init int add_temporary_entry(unsigned - } - - write_c0_index(temp_tlb_entry); -- BARRIER; - write_c0_pagemask(pagemask); - write_c0_entryhi(entryhi); - write_c0_entrylo0(entrylo0); - write_c0_entrylo1(entrylo1); -- BARRIER; -+ mtc0_tlbw_hazard(); - tlb_write_indexed(); -- BARRIER; -+ tlbw_use_hazard(); - - write_c0_entryhi(old_ctx); -- BARRIER; - write_c0_pagemask(old_pagemask); - out: - local_irq_restore(flags); -@@ -375,7 +335,7 @@ out: - static void __init probe_tlb(unsigned long config) - { - struct cpuinfo_mips *c = ¤t_cpu_data; -- unsigned int reg; -+ unsigned int config1; - - /* - * If this isn't a MIPS32 / MIPS64 compliant CPU. Config 1 register -@@ -385,16 +345,16 @@ static void __init probe_tlb(unsigned lo - if ((c->processor_id & 0xff0000) == PRID_COMP_LEGACY) - return; - -- reg = read_c0_config1(); -+ config1 = read_c0_config1(); - if (!((config >> 7) & 3)) - panic("No TLB present"); - -- c->tlbsize = ((reg >> 25) & 0x3f) + 1; -+ c->tlbsize = ((config1 >> 25) & 0x3f) + 1; - } - - void __init r4k_tlb_init(void) - { -- u32 config = read_c0_config(); -+ unsigned int config = read_c0_config(); - - /* - * You should never change this register: ---- a/arch/mips64/defconfig -+++ b/arch/mips64/defconfig -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -470,9 +470,11 @@ CONFIG_SCSI_LOGGING=y - # CONFIG_SCSI_MEGARAID is not set - # CONFIG_SCSI_MEGARAID2 is not set - # CONFIG_SCSI_SATA is not set -+# CONFIG_SCSI_SATA_AHCI is not set - # CONFIG_SCSI_SATA_SVW is not set - # CONFIG_SCSI_ATA_PIIX is not set - # CONFIG_SCSI_SATA_NV is not set -+# CONFIG_SCSI_SATA_QSTOR is not set - # CONFIG_SCSI_SATA_PROMISE is not set - # CONFIG_SCSI_SATA_SX4 is not set - # CONFIG_SCSI_SATA_SIL is not set -@@ -658,7 +660,6 @@ CONFIG_SERIAL=y - CONFIG_SERIAL_CONSOLE=y - # CONFIG_SERIAL_EXTENDED is not set - # CONFIG_SERIAL_NONSTANDARD is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips64/defconfig-atlas -+++ b/arch/mips64/defconfig-atlas -@@ -28,8 +28,8 @@ CONFIG_EXPERIMENTAL=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -232,11 +232,6 @@ CONFIG_IP_PNP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -314,9 +309,11 @@ CONFIG_SD_EXTRA_DEVS=40 - # CONFIG_SCSI_MEGARAID is not set - # CONFIG_SCSI_MEGARAID2 is not set - # CONFIG_SCSI_SATA is not set -+# CONFIG_SCSI_SATA_AHCI is not set - # CONFIG_SCSI_SATA_SVW is not set - # CONFIG_SCSI_ATA_PIIX is not set - # CONFIG_SCSI_SATA_NV is not set -+# CONFIG_SCSI_SATA_QSTOR is not set - # CONFIG_SCSI_SATA_PROMISE is not set - # CONFIG_SCSI_SATA_SX4 is not set - # CONFIG_SCSI_SATA_SIL is not set -@@ -474,7 +471,6 @@ CONFIG_SERIAL=y - CONFIG_SERIAL_CONSOLE=y - # CONFIG_SERIAL_EXTENDED is not set - # CONFIG_SERIAL_NONSTANDARD is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips64/defconfig-decstation -+++ b/arch/mips64/defconfig-decstation -@@ -28,8 +28,8 @@ CONFIG_EXPERIMENTAL=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -224,11 +224,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -307,9 +302,11 @@ CONFIG_SCSI_DECNCR=y - # CONFIG_SCSI_MEGARAID is not set - # CONFIG_SCSI_MEGARAID2 is not set - # CONFIG_SCSI_SATA is not set -+# CONFIG_SCSI_SATA_AHCI is not set - # CONFIG_SCSI_SATA_SVW is not set - # CONFIG_SCSI_ATA_PIIX is not set - # CONFIG_SCSI_SATA_NV is not set -+# CONFIG_SCSI_SATA_QSTOR is not set - # CONFIG_SCSI_SATA_PROMISE is not set - # CONFIG_SCSI_SATA_SX4 is not set - # CONFIG_SCSI_SATA_SIL is not set -@@ -477,7 +474,6 @@ CONFIG_SERIAL_DEC=y - CONFIG_SERIAL_DEC_CONSOLE=y - # CONFIG_DZ is not set - CONFIG_ZS=y --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips64/defconfig-ip22 -+++ b/arch/mips64/defconfig-ip22 -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -235,11 +235,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -319,9 +314,11 @@ CONFIG_SGIWD93_SCSI=y - # CONFIG_SCSI_MEGARAID is not set - # CONFIG_SCSI_MEGARAID2 is not set - # CONFIG_SCSI_SATA is not set -+# CONFIG_SCSI_SATA_AHCI is not set - # CONFIG_SCSI_SATA_SVW is not set - # CONFIG_SCSI_ATA_PIIX is not set - # CONFIG_SCSI_SATA_NV is not set -+# CONFIG_SCSI_SATA_QSTOR is not set - # CONFIG_SCSI_SATA_PROMISE is not set - # CONFIG_SCSI_SATA_SX4 is not set - # CONFIG_SCSI_SATA_SIL is not set -@@ -488,7 +485,6 @@ CONFIG_SERIAL_NONSTANDARD=y - # CONFIG_SERIAL_TXX9_CONSOLE is not set - # CONFIG_TXX927_SERIAL is not set - CONFIG_IP22_SERIAL=y --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips64/defconfig-ip27 -+++ b/arch/mips64/defconfig-ip27 -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -470,9 +470,11 @@ CONFIG_SCSI_LOGGING=y - # CONFIG_SCSI_MEGARAID is not set - # CONFIG_SCSI_MEGARAID2 is not set - # CONFIG_SCSI_SATA is not set -+# CONFIG_SCSI_SATA_AHCI is not set - # CONFIG_SCSI_SATA_SVW is not set - # CONFIG_SCSI_ATA_PIIX is not set - # CONFIG_SCSI_SATA_NV is not set -+# CONFIG_SCSI_SATA_QSTOR is not set - # CONFIG_SCSI_SATA_PROMISE is not set - # CONFIG_SCSI_SATA_SX4 is not set - # CONFIG_SCSI_SATA_SIL is not set -@@ -658,7 +660,6 @@ CONFIG_SERIAL=y - CONFIG_SERIAL_CONSOLE=y - # CONFIG_SERIAL_EXTENDED is not set - # CONFIG_SERIAL_NONSTANDARD is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips64/defconfig-jaguar -+++ b/arch/mips64/defconfig-jaguar -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -227,11 +227,6 @@ CONFIG_IP_PNP_DHCP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -403,7 +398,6 @@ CONFIG_SERIAL_NONSTANDARD=y - # CONFIG_SERIAL_TXX9 is not set - # CONFIG_SERIAL_TXX9_CONSOLE is not set - # CONFIG_TXX927_SERIAL is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips64/defconfig-malta -+++ b/arch/mips64/defconfig-malta -@@ -22,16 +22,19 @@ CONFIG_KMOD=y - # - # CONFIG_ACER_PICA_61 is not set - # CONFIG_MIPS_BOSPORUS is not set -+# CONFIG_MIPS_FICMMP is not set - # CONFIG_MIPS_MIRAGE is not set - # CONFIG_MIPS_DB1000 is not set - # CONFIG_MIPS_DB1100 is not set - # CONFIG_MIPS_DB1500 is not set - # CONFIG_MIPS_DB1550 is not set -+# CONFIG_MIPS_DB1200 is not set - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_PB1200 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -146,9 +149,9 @@ CONFIG_KCORE_ELF=y - CONFIG_BINFMT_ELF=y - CONFIG_MIPS32_COMPAT=y - CONFIG_MIPS32_O32=y --# CONFIG_MIPS32_N32 is not set -+CONFIG_MIPS32_N32=y - CONFIG_BINFMT_ELF32=y --# CONFIG_BINFMT_MISC is not set -+CONFIG_BINFMT_MISC=y - # CONFIG_OOM_KILLER is not set - # CONFIG_CMDLINE_BOOL is not set - -@@ -235,11 +238,6 @@ CONFIG_IP_PNP_BOOTP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -271,8 +269,83 @@ CONFIG_IP_PNP_BOOTP=y - # - # ATA/IDE/MFM/RLL support - # --# CONFIG_IDE is not set -+CONFIG_IDE=y -+ -+# -+# IDE, ATA and ATAPI Block devices -+# -+CONFIG_BLK_DEV_IDE=y -+ -+# -+# Please see Documentation/ide.txt for help/info on IDE drives -+# -+# CONFIG_BLK_DEV_HD_IDE is not set - # CONFIG_BLK_DEV_HD is not set -+# CONFIG_BLK_DEV_IDE_SATA is not set -+CONFIG_BLK_DEV_IDEDISK=y -+# CONFIG_IDEDISK_MULTI_MODE is not set -+# CONFIG_IDEDISK_STROKE is not set -+# CONFIG_BLK_DEV_IDECS is not set -+# CONFIG_BLK_DEV_DELKIN is not set -+CONFIG_BLK_DEV_IDECD=y -+CONFIG_BLK_DEV_IDETAPE=y -+CONFIG_BLK_DEV_IDEFLOPPY=y -+# CONFIG_BLK_DEV_IDESCSI is not set -+# CONFIG_IDE_TASK_IOCTL is not set -+ -+# -+# IDE chipset support/bugfixes -+# -+# CONFIG_BLK_DEV_CMD640 is not set -+# CONFIG_BLK_DEV_CMD640_ENHANCED is not set -+# CONFIG_BLK_DEV_ISAPNP is not set -+CONFIG_BLK_DEV_IDEPCI=y -+CONFIG_BLK_DEV_GENERIC=y -+CONFIG_IDEPCI_SHARE_IRQ=y -+CONFIG_BLK_DEV_IDEDMA_PCI=y -+# CONFIG_BLK_DEV_OFFBOARD is not set -+CONFIG_BLK_DEV_IDEDMA_FORCED=y -+CONFIG_IDEDMA_PCI_AUTO=y -+# CONFIG_IDEDMA_ONLYDISK is not set -+CONFIG_BLK_DEV_IDEDMA=y -+# CONFIG_IDEDMA_PCI_WIP is not set -+# CONFIG_BLK_DEV_ADMA100 is not set -+# CONFIG_BLK_DEV_AEC62XX is not set -+# CONFIG_BLK_DEV_ALI15X3 is not set -+# CONFIG_WDC_ALI15X3 is not set -+# CONFIG_BLK_DEV_AMD74XX is not set -+# CONFIG_AMD74XX_OVERRIDE is not set -+# CONFIG_BLK_DEV_ATIIXP is not set -+# CONFIG_BLK_DEV_CMD64X is not set -+# CONFIG_BLK_DEV_TRIFLEX is not set -+# CONFIG_BLK_DEV_CY82C693 is not set -+# CONFIG_BLK_DEV_CS5530 is not set -+# CONFIG_BLK_DEV_HPT34X is not set -+# CONFIG_HPT34X_AUTODMA is not set -+# CONFIG_BLK_DEV_HPT366 is not set -+CONFIG_BLK_DEV_PIIX=y -+# CONFIG_BLK_DEV_NS87415 is not set -+# CONFIG_BLK_DEV_OPTI621 is not set -+# CONFIG_BLK_DEV_PDC202XX_OLD is not set -+# CONFIG_PDC202XX_BURST is not set -+# CONFIG_BLK_DEV_PDC202XX_NEW is not set -+# CONFIG_BLK_DEV_RZ1000 is not set -+# CONFIG_BLK_DEV_SC1200 is not set -+# CONFIG_BLK_DEV_SVWKS is not set -+# CONFIG_BLK_DEV_SIIMAGE is not set -+# CONFIG_BLK_DEV_SIS5513 is not set -+# CONFIG_BLK_DEV_SLC90E66 is not set -+# CONFIG_BLK_DEV_TRM290 is not set -+# CONFIG_BLK_DEV_VIA82CXXX is not set -+# CONFIG_IDE_CHIPSETS is not set -+CONFIG_IDEDMA_AUTO=y -+# CONFIG_IDEDMA_IVB is not set -+# CONFIG_DMA_NONPCI is not set -+# CONFIG_BLK_DEV_ATARAID is not set -+# CONFIG_BLK_DEV_ATARAID_PDC is not set -+# CONFIG_BLK_DEV_ATARAID_HPT is not set -+# CONFIG_BLK_DEV_ATARAID_MEDLEY is not set -+# CONFIG_BLK_DEV_ATARAID_SII is not set - - # - # SCSI support -@@ -317,9 +390,11 @@ CONFIG_SD_EXTRA_DEVS=40 - # CONFIG_SCSI_MEGARAID is not set - # CONFIG_SCSI_MEGARAID2 is not set - # CONFIG_SCSI_SATA is not set -+# CONFIG_SCSI_SATA_AHCI is not set - # CONFIG_SCSI_SATA_SVW is not set - # CONFIG_SCSI_ATA_PIIX is not set - # CONFIG_SCSI_SATA_NV is not set -+# CONFIG_SCSI_SATA_QSTOR is not set - # CONFIG_SCSI_SATA_PROMISE is not set - # CONFIG_SCSI_SATA_SX4 is not set - # CONFIG_SCSI_SATA_SIL is not set -@@ -477,7 +552,6 @@ CONFIG_SERIAL=y - CONFIG_SERIAL_CONSOLE=y - # CONFIG_SERIAL_EXTENDED is not set - # CONFIG_SERIAL_NONSTANDARD is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips64/defconfig-ocelotc -+++ b/arch/mips64/defconfig-ocelotc -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -231,11 +231,6 @@ CONFIG_IP_PNP_DHCP=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -453,7 +448,6 @@ CONFIG_SERIAL_NONSTANDARD=y - # CONFIG_SERIAL_TXX9 is not set - # CONFIG_SERIAL_TXX9_CONSOLE is not set - # CONFIG_TXX927_SERIAL is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips64/defconfig-sb1250-swarm -+++ b/arch/mips64/defconfig-sb1250-swarm -@@ -30,8 +30,8 @@ CONFIG_KMOD=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -90,6 +90,7 @@ CONFIG_SIBYTE_CFE=y - # CONFIG_SIBYTE_TBPROF is not set - CONFIG_SIBYTE_GENBUS_IDE=y - CONFIG_SMP_CAPABLE=y -+CONFIG_MIPS_RTC=y - # CONFIG_SNI_RM200_PCI is not set - # CONFIG_TANBAC_TB0226 is not set - # CONFIG_TANBAC_TB0229 is not set -@@ -253,11 +254,6 @@ CONFIG_INET=y - # - # CONFIG_IPX is not set - # CONFIG_ATALK is not set -- --# --# Appletalk devices --# --# CONFIG_DEV_APPLETALK is not set - # CONFIG_DECNET is not set - # CONFIG_BRIDGE is not set - # CONFIG_X25 is not set -@@ -432,7 +428,6 @@ CONFIG_SERIAL_NONSTANDARD=y - CONFIG_SIBYTE_SB1250_DUART=y - CONFIG_SIBYTE_SB1250_DUART_CONSOLE=y - CONFIG_SERIAL_CONSOLE=y --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - CONFIG_UNIX98_PTYS=y - CONFIG_UNIX98_PTY_COUNT=256 - ---- a/arch/mips64/defconfig-sead -+++ b/arch/mips64/defconfig-sead -@@ -28,8 +28,8 @@ CONFIG_EXPERIMENTAL=y - # CONFIG_MIPS_PB1000 is not set - # CONFIG_MIPS_PB1100 is not set - # CONFIG_MIPS_PB1500 is not set --# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_PB1550 is not set -+# CONFIG_MIPS_HYDROGEN3 is not set - # CONFIG_MIPS_XXS1500 is not set - # CONFIG_MIPS_MTX1 is not set - # CONFIG_COGENT_CSB250 is not set -@@ -242,7 +242,6 @@ CONFIG_SERIAL=y - CONFIG_SERIAL_CONSOLE=y - # CONFIG_SERIAL_EXTENDED is not set - # CONFIG_SERIAL_NONSTANDARD is not set --# CONFIG_MIPS_HYDROGEN3_BUTTONS is not set - # CONFIG_UNIX98_PTYS is not set - - # ---- a/arch/mips64/kernel/binfmt_elfn32.c -+++ b/arch/mips64/kernel/binfmt_elfn32.c -@@ -116,4 +116,7 @@ MODULE_AUTHOR("Ralf Baechle (ralf@linux- - #undef MODULE_DESCRIPTION - #undef MODULE_AUTHOR - -+#undef TASK_SIZE -+#define TASK_SIZE TASK_SIZE32 -+ - #include "../../../fs/binfmt_elf.c" ---- a/arch/mips64/kernel/binfmt_elfo32.c -+++ b/arch/mips64/kernel/binfmt_elfo32.c -@@ -137,4 +137,7 @@ MODULE_AUTHOR("Ralf Baechle (ralf@linux- - #undef MODULE_DESCRIPTION - #undef MODULE_AUTHOR - -+#undef TASK_SIZE -+#define TASK_SIZE TASK_SIZE32 -+ - #include "../../../fs/binfmt_elf.c" ---- a/arch/mips64/kernel/head.S -+++ b/arch/mips64/kernel/head.S -@@ -91,6 +91,21 @@ EXPORT(_stext) - __INIT - - NESTED(kernel_entry, 16, sp) # kernel entry point -+ .set push -+ /* -+ * For the moment disable interrupts, mark the kernel mode and -+ * set ST0_KX so that the CPU does not spit fire when using -+ * 64-bit addresses. A full initialization of the CPU's status -+ * register is done later in per_cpu_trap_init(). -+ */ -+ mfc0 t0, CP0_STATUS -+ or t0, ST0_CU0|ST0_KX|0x1f -+ xor t0, 0x1f -+ mtc0 t0, CP0_STATUS -+ -+ .set noreorder -+ sll zero,3 # ehb -+ .set reorder - - ori sp, 0xf # align stack on 16 byte. - xori sp, 0xf -@@ -103,8 +118,6 @@ NESTED(kernel_entry, 16, sp) # kernel - - ARC64_TWIDDLE_PC - -- CLI # disable interrupts -- - /* - * The firmware/bootloader passes argc/argp/envp - * to us as arguments. But clear bss first because -@@ -125,6 +138,7 @@ NESTED(kernel_entry, 16, sp) # kernel - dsubu sp, 4*SZREG # init stack pointer - - j init_arch -+ .set pop - END(kernel_entry) - - #ifdef CONFIG_SMP -@@ -133,6 +147,23 @@ NESTED(kernel_entry, 16, sp) # kernel - * function after setting up the stack and gp registers. - */ - NESTED(smp_bootstrap, 16, sp) -+ .set push -+ /* -+ * For the moment disable interrupts and bootstrap exception -+ * vectors, mark the kernel mode and set ST0_KX so that the CPU -+ * does not spit fire when using 64-bit addresses. A full -+ * initialization of the CPU's status register is done later in -+ * per_cpu_trap_init(). -+ */ -+ mfc0 t0, CP0_STATUS -+ or t0, ST0_CU0|ST0_BEV|ST0_KX|0x1f -+ xor t0, ST0_BEV|0x1f -+ mtc0 t0, CP0_STATUS -+ -+ .set noreorder -+ sll zero,3 # ehb -+ .set reorder -+ - #ifdef CONFIG_SGI_IP27 - GET_NASID_ASM t1 - dli t0, KLDIR_OFFSET + (KLI_KERN_VARS * KLDIR_ENT_SIZE) + \ -@@ -146,19 +177,8 @@ NESTED(smp_bootstrap, 16, sp) - ARC64_TWIDDLE_PC - #endif /* CONFIG_SGI_IP27 */ - -- CLI -- -- /* -- * For the moment set ST0_KU so the CPU will not spit fire when -- * executing 64-bit instructions. The full initialization of the -- * CPU's status register is done later in per_cpu_trap_init(). -- */ -- mfc0 t0, CP0_STATUS -- or t0, ST0_KX -- mtc0 t0, CP0_STATUS -- - jal start_secondary # XXX: IP27: cboot -- -+ .set pop - END(smp_bootstrap) - #endif /* CONFIG_SMP */ - ---- a/arch/mips64/kernel/ioctl32.c -+++ b/arch/mips64/kernel/ioctl32.c -@@ -2352,7 +2352,7 @@ static struct ioctl32_list ioctl32_handl - IOCTL32_HANDLER(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout), - IOCTL32_DEFAULT(AUTOFS_IOC_EXPIRE), - IOCTL32_DEFAULT(AUTOFS_IOC_EXPIRE_MULTI), -- IOCTL32_DEFAULT(AUTOFS_IOC_PROTSUBVER), -+ IOCTL32_DEFAULT(AUTOFS_IOC_PROTOSUBVER), - IOCTL32_DEFAULT(AUTOFS_IOC_ASKREGHOST), - IOCTL32_DEFAULT(AUTOFS_IOC_TOGGLEREGHOST), - IOCTL32_DEFAULT(AUTOFS_IOC_ASKUMOUNT), ---- a/arch/mips64/kernel/linux32.c -+++ b/arch/mips64/kernel/linux32.c -@@ -1101,6 +1101,7 @@ do_readv_writev32(int type, struct file - * specially as they have atomicity guarantees and can handle - * iovec's natively - */ -+ inode = file->f_dentry->d_inode; - if (inode->i_sock) { - int err; - err = sock_readv_writev(type, inode, file, iov, count, tot_len); -@@ -1187,72 +1188,19 @@ bad_file: - lseek back to original location. They fail just like lseek does on - non-seekable files. */ - --asmlinkage ssize_t sys32_pread(unsigned int fd, char * buf, -- size_t count, u32 unused, u64 a4, u64 a5) -+asmlinkage ssize_t sys32_pread(unsigned int fd, char *buf, -+ size_t count, u32 unused, u64 a4, u64 a5) - { -- ssize_t ret; -- struct file * file; -- ssize_t (*read)(struct file *, char *, size_t, loff_t *); -- loff_t pos; -- -- ret = -EBADF; -- file = fget(fd); -- if (!file) -- goto bad_file; -- if (!(file->f_mode & FMODE_READ)) -- goto out; -- pos = merge_64(a4, a5); -- ret = locks_verify_area(FLOCK_VERIFY_READ, file->f_dentry->d_inode, -- file, pos, count); -- if (ret) -- goto out; -- ret = -EINVAL; -- if (!file->f_op || !(read = file->f_op->read)) -- goto out; -- if (pos < 0) -- goto out; -- ret = read(file, buf, count, &pos); -- if (ret > 0) -- dnotify_parent(file->f_dentry, DN_ACCESS); --out: -- fput(file); --bad_file: -- return ret; -+ return sys_pread(fd, buf, count, merge_64(a4, a5)); - } - - asmlinkage ssize_t sys32_pwrite(unsigned int fd, const char * buf, - size_t count, u32 unused, u64 a4, u64 a5) - { -- ssize_t ret; -- struct file * file; -- ssize_t (*write)(struct file *, const char *, size_t, loff_t *); -- loff_t pos; -+ return sys_pwrite(fd, buf, count, merge_64(a4, a5)); -+} - -- ret = -EBADF; -- file = fget(fd); -- if (!file) -- goto bad_file; -- if (!(file->f_mode & FMODE_WRITE)) -- goto out; -- pos = merge_64(a4, a5); -- ret = locks_verify_area(FLOCK_VERIFY_WRITE, file->f_dentry->d_inode, -- file, pos, count); -- if (ret) -- goto out; -- ret = -EINVAL; -- if (!file->f_op || !(write = file->f_op->write)) -- goto out; -- if (pos < 0) -- goto out; - -- ret = write(file, buf, count, &pos); -- if (ret > 0) -- dnotify_parent(file->f_dentry, DN_MODIFY); --out: -- fput(file); --bad_file: -- return ret; --} - /* - * Ooo, nasty. We need here to frob 32-bit unsigned longs to - * 64-bit unsigned longs. ---- a/arch/mips64/kernel/process.c -+++ b/arch/mips64/kernel/process.c -@@ -125,6 +125,25 @@ int dump_fpu(struct pt_regs *regs, elf_f - return 1; - } - -+void dump_regs(elf_greg_t *gp, struct pt_regs *regs) -+{ -+ int i; -+ -+ for (i = 0; i < EF_REG0; i++) -+ gp[i] = 0; -+ gp[EF_REG0] = 0; -+ for (i = 1; i <= 31; i++) -+ gp[EF_REG0 + i] = regs->regs[i]; -+ gp[EF_REG26] = 0; -+ gp[EF_REG27] = 0; -+ gp[EF_LO] = regs->lo; -+ gp[EF_HI] = regs->hi; -+ gp[EF_CP0_EPC] = regs->cp0_epc; -+ gp[EF_CP0_BADVADDR] = regs->cp0_badvaddr; -+ gp[EF_CP0_STATUS] = regs->cp0_status; -+ gp[EF_CP0_CAUSE] = regs->cp0_cause; -+} -+ - /* - * Create a kernel thread - */ ---- a/arch/mips64/kernel/scall_64.S -+++ b/arch/mips64/kernel/scall_64.S -@@ -102,15 +102,14 @@ _64_reschedule: - - trace_a_syscall: - SAVE_STATIC -- sd t2,PT_R1(sp) -+ move s0, t2 - jal syscall_trace -- ld t2,PT_R1(sp) - - ld a0, PT_R4(sp) # Restore argument registers - ld a1, PT_R5(sp) - ld a2, PT_R6(sp) - ld a3, PT_R7(sp) -- jalr t2 -+ jalr s0 - - li t0, -EMAXERRNO - 1 # error? - sltu t0, t0, v0 ---- a/arch/mips64/kernel/scall_n32.S -+++ b/arch/mips64/kernel/scall_n32.S -@@ -106,15 +106,14 @@ n32_reschedule: - - trace_a_syscall: - SAVE_STATIC -- sd t2,PT_R1(sp) -+ move s0, t2 - jal syscall_trace -- ld t2,PT_R1(sp) - - ld a0, PT_R4(sp) # Restore argument registers - ld a1, PT_R5(sp) - ld a2, PT_R6(sp) - ld a3, PT_R7(sp) -- jalr t2 -+ jalr s0 - - li t0, -EMAXERRNO - 1 # error? - sltu t0, t0, v0 ---- a/arch/mips64/kernel/scall_o32.S -+++ b/arch/mips64/kernel/scall_o32.S -@@ -118,9 +118,8 @@ trace_a_syscall: - sd a6, PT_R10(sp) - sd a7, PT_R11(sp) - -- sd t2,PT_R1(sp) -+ move s0, t2 - jal syscall_trace -- ld t2,PT_R1(sp) - - ld a0, PT_R4(sp) # Restore argument registers - ld a1, PT_R5(sp) -@@ -129,7 +128,7 @@ trace_a_syscall: - ld a4, PT_R8(sp) - ld a5, PT_R9(sp) - -- jalr t2 -+ jalr s0 - - li t0, -EMAXERRNO - 1 # error? - sltu t0, t0, v0 -@@ -576,6 +575,8 @@ out: jr ra - sys_call_table: - syscalltable - -+ .purgem sys -+ - .macro sys function, nargs - .byte \nargs - .endm ---- a/arch/mips64/kernel/setup.c -+++ b/arch/mips64/kernel/setup.c -@@ -129,14 +129,6 @@ asmlinkage void __init init_arch(int arg - */ - load_mmu(); - -- /* -- * On IP27, I am seeing the TS bit set when the kernel is loaded. -- * Maybe because the kernel is in ckseg0 and not xkphys? Clear it -- * anyway ... -- */ -- clear_c0_status(ST0_BEV|ST0_TS|ST0_CU1|ST0_CU2|ST0_CU3); -- set_c0_status(ST0_CU0|ST0_KX|ST0_SX|ST0_FR); -- - start_kernel(); - } - ---- a/arch/mips64/kernel/signal_n32.c -+++ b/arch/mips64/kernel/signal_n32.c -@@ -68,7 +68,7 @@ struct rt_sigframe_n32 { - }; - - extern asmlinkage int restore_sigcontext(struct pt_regs *regs, struct sigcontext *sc); --extern int inline setup_sigcontext(struct pt_regs *regs, struct sigcontext *sc); -+extern int setup_sigcontext(struct pt_regs *regs, struct sigcontext *sc); - - asmlinkage void sysn32_rt_sigreturn(abi64_no_regargs, struct pt_regs regs) - { ---- a/arch/mips64/kernel/traps.c -+++ b/arch/mips64/kernel/traps.c -@@ -462,9 +462,10 @@ static inline void simulate_ll(struct pt - } - ll_task = current; - -+ compute_return_epc(regs); -+ - regs->regs[(opcode & RT) >> 16] = value; - -- compute_return_epc(regs); - return; - - sig: -@@ -495,8 +496,8 @@ static inline void simulate_sc(struct pt - goto sig; - } - if (ll_bit == 0 || ll_task != current) { -- regs->regs[reg] = 0; - compute_return_epc(regs); -+ regs->regs[reg] = 0; - return; - } - -@@ -505,9 +506,9 @@ static inline void simulate_sc(struct pt - goto sig; - } - -+ compute_return_epc(regs); - regs->regs[reg] = 1; - -- compute_return_epc(regs); - return; - - sig: -@@ -809,13 +810,18 @@ extern asmlinkage int fpu_emulator_resto - void __init per_cpu_trap_init(void) - { - unsigned int cpu = smp_processor_id(); -+ unsigned int status_set = ST0_CU0|ST0_FR|ST0_KX|ST0_SX|ST0_UX; - -- /* Some firmware leaves the BEV flag set, clear it. */ -- clear_c0_status(ST0_CU1|ST0_CU2|ST0_CU3|ST0_BEV); -- set_c0_status(ST0_CU0|ST0_FR|ST0_KX|ST0_SX|ST0_UX); -- -+ /* -+ * Disable coprocessors, enable 64-bit addressing and set FPU -+ * for the 32/32 FPR register model. Reset the BEV flag that -+ * some firmware may have left set and the TS bit (for IP27). -+ * Set XX for ISA IV code to work. -+ */ - if (current_cpu_data.isa_level == MIPS_CPU_ISA_IV) -- set_c0_status(ST0_XX); -+ status_set |= ST0_XX; -+ change_c0_status(ST0_CU|ST0_FR|ST0_BEV|ST0_TS|ST0_KX|ST0_SX|ST0_UX, -+ status_set); - - /* - * Some MIPS CPUs have a dedicated interrupt vector which reduces the -@@ -825,13 +831,11 @@ void __init per_cpu_trap_init(void) - set_c0_cause(CAUSEF_IV); - - cpu_data[cpu].asid_cache = ASID_FIRST_VERSION; -- write_c0_context(((long)(&pgd_current[cpu])) << 23); -- write_c0_wired(0); -+ TLBMISS_HANDLER_SETUP(); - - atomic_inc(&init_mm.mm_count); - current->active_mm = &init_mm; -- if (current->mm) -- BUG(); -+ BUG_ON(current->mm); - enter_lazy_tlb(&init_mm, current, cpu); - } - -@@ -842,8 +846,6 @@ void __init trap_init(void) - extern char except_vec4; - unsigned long i; - -- per_cpu_trap_init(); -- - /* Copy the generic exception handlers to their final destination. */ - memcpy((void *) KSEG0 , &except_vec0_generic, 0x80); - memcpy((void *)(KSEG0 + 0x180), &except_vec3_generic, 0x80); -@@ -933,6 +935,5 @@ void __init trap_init(void) - - flush_icache_range(KSEG0, KSEG0 + 0x400); - -- atomic_inc(&init_mm.mm_count); /* XXX UP? */ -- current->active_mm = &init_mm; -+ per_cpu_trap_init(); - } ---- a/arch/mips64/mm/cerr-sb1.c -+++ b/arch/mips64/mm/cerr-sb1.c -@@ -252,14 +252,14 @@ static const uint8_t parity[256] = { - - /* Masks to select bits for Hamming parity, mask_72_64[i] for bit[i] */ - static const uint64_t mask_72_64[8] = { -- 0x0738C808099264FFL, -- 0x38C808099264FF07L, -- 0xC808099264FF0738L, -- 0x08099264FF0738C8L, -- 0x099264FF0738C808L, -- 0x9264FF0738C80809L, -- 0x64FF0738C8080992L, -- 0xFF0738C808099264L -+ 0x0738C808099264FFULL, -+ 0x38C808099264FF07ULL, -+ 0xC808099264FF0738ULL, -+ 0x08099264FF0738C8ULL, -+ 0x099264FF0738C808ULL, -+ 0x9264FF0738C80809ULL, -+ 0x64FF0738C8080992ULL, -+ 0xFF0738C808099264ULL - }; - - /* Calculate the parity on a range of bits */ -@@ -331,9 +331,9 @@ static uint32_t extract_ic(unsigned shor - ((lru >> 4) & 0x3), - ((lru >> 6) & 0x3)); - } -- va = (taglo & 0xC0000FFFFFFFE000) | addr; -+ va = (taglo & 0xC0000FFFFFFFE000ULL) | addr; - if ((taglo & (1 << 31)) && (((taglo >> 62) & 0x3) == 3)) -- va |= 0x3FFFF00000000000; -+ va |= 0x3FFFF00000000000ULL; - valid = ((taghi >> 29) & 1); - if (valid) { - tlo_tmp = taglo & 0xfff3ff; -@@ -474,7 +474,7 @@ static uint32_t extract_dc(unsigned shor - : "r" ((way << 13) | addr)); - - taglo = ((unsigned long long)taglohi << 32) | taglolo; -- pa = (taglo & 0xFFFFFFE000) | addr; -+ pa = (taglo & 0xFFFFFFE000ULL) | addr; - if (way == 0) { - lru = (taghi >> 14) & 0xff; - prom_printf("[Bank %d Set 0x%02x] LRU > %d %d %d %d > MRU\n", ---- a/arch/mips64/mm/c-r4k.c -+++ b/arch/mips64/mm/c-r4k.c -@@ -867,9 +867,16 @@ static void __init probe_pcache(void) - * normally they'd suffer from aliases but magic in the hardware deals - * with that for us so we don't need to take care ourselves. - */ -- if (c->cputype != CPU_R10000 && c->cputype != CPU_R12000) -- if (c->dcache.waysize > PAGE_SIZE) -- c->dcache.flags |= MIPS_CACHE_ALIASES; -+ switch (c->cputype) { -+ case CPU_R10000: -+ case CPU_R12000: -+ break; -+ case CPU_24K: -+ if (!(read_c0_config7() & (1 << 16))) -+ default: -+ if (c->dcache.waysize > PAGE_SIZE) -+ c->dcache.flags |= MIPS_CACHE_ALIASES; -+ } - - switch (c->cputype) { - case CPU_20KC: -@@ -1070,9 +1077,6 @@ void __init ld_mmu_r4xx0(void) - setup_scache(); - coherency_setup(); - -- if (c->dcache.sets * c->dcache.ways > PAGE_SIZE) -- c->dcache.flags |= MIPS_CACHE_ALIASES; -- - r4k_blast_dcache_page_setup(); - r4k_blast_dcache_page_indexed_setup(); - r4k_blast_dcache_setup(); ---- a/arch/mips64/mm/tlbex-r4k.S -+++ b/arch/mips64/mm/tlbex-r4k.S -@@ -125,6 +125,33 @@ LEAF(except_vec1_r4k) - nop - END(except_vec1_r4k) - -+ __FINIT -+ -+ .align 5 -+LEAF(handle_vec1_r4k) -+ .set noat -+ LOAD_PTE2 k1 k0 9f -+ ld k0, 0(k1) # get even pte -+ ld k1, 8(k1) # get odd pte -+ PTE_RELOAD k0 k1 -+ mtc0_tlbw_hazard -+ tlbwr -+ tlbw_eret_hazard -+ eret -+ -+9: # handle the vmalloc range -+ LOAD_KPTE2 k1 k0 invalid_vmalloc_address -+ ld k0, 0(k1) # get even pte -+ ld k1, 8(k1) # get odd pte -+ PTE_RELOAD k0 k1 -+ mtc0_tlbw_hazard -+ tlbwr -+ tlbw_eret_hazard -+ eret -+END(handle_vec1_r4k) -+ -+ __INIT -+ - LEAF(except_vec1_sb1) - #if BCM1250_M3_WAR - dmfc0 k0, CP0_BADVADDR -@@ -134,28 +161,24 @@ LEAF(except_vec1_sb1) - bnez k0, 1f - #endif - .set noat -- dla k0, handle_vec1_r4k -+ dla k0, handle_vec1_sb1 - jr k0 - nop - - 1: eret -- nop - END(except_vec1_sb1) - - __FINIT - - .align 5 --LEAF(handle_vec1_r4k) -+LEAF(handle_vec1_sb1) - .set noat - LOAD_PTE2 k1 k0 9f - ld k0, 0(k1) # get even pte - ld k1, 8(k1) # get odd pte - PTE_RELOAD k0 k1 -- rm9000_tlb_hazard -- b 1f -- tlbwr --1: nop -- rm9000_tlb_hazard -+ mtc0_tlbw_hazard -+ tlbwr - eret - - 9: # handle the vmalloc range -@@ -163,13 +186,10 @@ LEAF(handle_vec1_r4k) - ld k0, 0(k1) # get even pte - ld k1, 8(k1) # get odd pte - PTE_RELOAD k0 k1 -- rm9000_tlb_hazard -- b 1f -- tlbwr --1: nop -- rm9000_tlb_hazard -+ mtc0_tlbw_hazard -+ tlbwr - eret --END(handle_vec1_r4k) -+END(handle_vec1_sb1) - - - __INIT -@@ -195,10 +215,8 @@ LEAF(handle_vec1_r10k) - ld k0, 0(k1) # get even pte - ld k1, 8(k1) # get odd pte - PTE_RELOAD k0 k1 -- rm9000_tlb_hazard -- nop -+ mtc0_tlbw_hazard - tlbwr -- rm9000_tlb_hazard - eret - - 9: # handle the vmalloc range -@@ -206,10 +224,8 @@ LEAF(handle_vec1_r10k) - ld k0, 0(k1) # get even pte - ld k1, 8(k1) # get odd pte - PTE_RELOAD k0 k1 -- rm9000_tlb_hazard -- nop -+ mtc0_tlbw_hazard - tlbwr -- rm9000_tlb_hazard - eret - END(handle_vec1_r10k) - ---- a/arch/mips64/mm/tlb-r4k.c -+++ b/arch/mips64/mm/tlb-r4k.c -@@ -1,24 +1,12 @@ - /* -- * Carsten Langgaard, carstenl@mips.com -- * Copyright (C) 2002 MIPS Technologies, Inc. All rights reserved. -- * -- * This program is free software; you can distribute 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 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 -+ * 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. - * -- * 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. -- * -- * MIPS64 CPU variant specific MMU routines. -- * These routine are not optimized in any way, they are done in a generic way -- * so they can be used on all MIPS64 compliant CPUs, and also done in an -- * attempt not to break anything for the R4xx0 style CPUs. -+ * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) -+ * Copyright (C) 1997, 1998, 1999, 2000 Ralf Baechle ralf@gnu.org -+ * Carsten Langgaard, carstenl@mips.com -+ * Copyright (C) 2002 MIPS Technologies, Inc. All rights reserved. - */ - #include <linux/init.h> - #include <linux/sched.h> -@@ -30,9 +18,6 @@ - #include <asm/pgtable.h> - #include <asm/system.h> - --#undef DEBUG_TLB --#undef DEBUG_TLBUPDATE -- - extern void except_vec1_r4k(void); - - /* CP0 hazard avoidance. */ -@@ -46,31 +31,23 @@ void local_flush_tlb_all(void) - unsigned long old_ctx; - int entry; - --#ifdef DEBUG_TLB -- printk("[tlball]"); --#endif -- - local_irq_save(flags); - /* Save old context and create impossible VPN2 value */ - old_ctx = read_c0_entryhi(); -- write_c0_entryhi(XKPHYS); - write_c0_entrylo0(0); - write_c0_entrylo1(0); -- BARRIER; - - entry = read_c0_wired(); - - /* Blast 'em all away. */ -- while(entry < current_cpu_data.tlbsize) { -- /* Make sure all entries differ. */ -- write_c0_entryhi(XKPHYS+entry*0x2000); -+ while (entry < current_cpu_data.tlbsize) { -+ write_c0_entryhi(XKPHYS + entry*0x2000); - write_c0_index(entry); -- BARRIER; -+ mtc0_tlbw_hazard(); - tlb_write_indexed(); -- BARRIER; - entry++; - } -- BARRIER; -+ tlbw_use_hazard(); - write_c0_entryhi(old_ctx); - local_irq_restore(flags); - } -@@ -79,12 +56,8 @@ void local_flush_tlb_mm(struct mm_struct - { - int cpu = smp_processor_id(); - -- if (cpu_context(cpu, mm) != 0) { --#ifdef DEBUG_TLB -- printk("[tlbmm<%d>]", mm->context); --#endif -+ if (cpu_context(cpu, mm) != 0) - drop_mmu_context(mm,cpu); -- } - } - - void local_flush_tlb_range(struct mm_struct *mm, unsigned long start, -@@ -96,10 +69,6 @@ void local_flush_tlb_range(struct mm_str - unsigned long flags; - int size; - --#ifdef DEBUG_TLB -- printk("[tlbrange<%02x,%08lx,%08lx>]", (mm->context & ASID_MASK), -- start, end); --#endif - local_irq_save(flags); - size = (end - start + (PAGE_SIZE - 1)) >> PAGE_SHIFT; - size = (size + 1) >> 1; -@@ -110,25 +79,25 @@ void local_flush_tlb_range(struct mm_str - start &= (PAGE_MASK << 1); - end += ((PAGE_SIZE << 1) - 1); - end &= (PAGE_MASK << 1); -- while(start < end) { -+ while (start < end) { - int idx; - - write_c0_entryhi(start | newpid); - start += (PAGE_SIZE << 1); -- BARRIER; -+ mtc0_tlbw_hazard(); - tlb_probe(); - BARRIER; - idx = read_c0_index(); - write_c0_entrylo0(0); - write_c0_entrylo1(0); -- if(idx < 0) -+ if (idx < 0) - continue; - /* Make sure all entries differ. */ - write_c0_entryhi(XKPHYS+idx*0x2000); -- BARRIER; -+ mtc0_tlbw_hazard(); - tlb_write_indexed(); -- BARRIER; - } -+ tlbw_use_hazard(); - write_c0_entryhi(oldpid); - } else { - drop_mmu_context(mm, cpu); -@@ -145,28 +114,26 @@ void local_flush_tlb_page(struct vm_area - unsigned long flags; - unsigned long oldpid, newpid, idx; - --#ifdef DEBUG_TLB -- printk("[tlbpage<%d,%08lx>]", vma->vm_mm->context, page); --#endif - newpid = cpu_asid(cpu, vma->vm_mm); - page &= (PAGE_MASK << 1); - local_irq_save(flags); - oldpid = read_c0_entryhi(); - write_c0_entryhi(page | newpid); -- BARRIER; -+ mtc0_tlbw_hazard(); - tlb_probe(); - BARRIER; - idx = read_c0_index(); - write_c0_entrylo0(0); - write_c0_entrylo1(0); -- if(idx < 0) -+ if (idx < 0) - goto finish; - /* Make sure all entries differ. */ - write_c0_entryhi(XKPHYS+idx*0x2000); -- BARRIER; -+ mtc0_tlbw_hazard(); - tlb_write_indexed(); -+ tlbw_use_hazard(); -+ - finish: -- BARRIER; - write_c0_entryhi(oldpid); - local_irq_restore(flags); - } -@@ -186,7 +153,7 @@ void local_flush_tlb_one(unsigned long p - - local_irq_save(flags); - write_c0_entryhi(page); -- BARRIER; -+ mtc0_tlbw_hazard(); - tlb_probe(); - BARRIER; - idx = read_c0_index(); -@@ -195,10 +162,12 @@ void local_flush_tlb_one(unsigned long p - if (idx >= 0) { - /* Make sure all entries differ. */ - write_c0_entryhi(KSEG0+idx*0x2000); -+ mtc0_tlbw_hazard(); - tlb_write_indexed(); -+ tlbw_use_hazard(); - } -- BARRIER; - write_c0_entryhi(oldpid); -+ - local_irq_restore(flags); - } - -@@ -208,7 +177,6 @@ void local_flush_tlb_one(unsigned long p - void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte) - { - unsigned long flags; -- unsigned int asid; - pgd_t *pgdp; - pmd_t *pmdp; - pte_t *ptep; -@@ -222,70 +190,58 @@ void __update_tlb(struct vm_area_struct - - pid = read_c0_entryhi() & ASID_MASK; - --#ifdef DEBUG_TLB -- if ((pid != (cpu_asid(smp_processor_id(), vma->vm_mm))) || -- (cpu_context(smp_processor_id(), vma->vm_mm) == 0)) { -- printk("update_mmu_cache: Wheee, bogus tlbpid mmpid=%d" -- "tlbpid=%d\n", (int) (cpu_context(smp_processor_id(), -- vma->vm_mm) & ASID_MASK), pid); -- } --#endif -- - local_irq_save(flags); - address &= (PAGE_MASK << 1); -- write_c0_entryhi(address | (pid)); -+ write_c0_entryhi(address | pid); - pgdp = pgd_offset(vma->vm_mm, address); -- BARRIER; -+ mtc0_tlbw_hazard(); - tlb_probe(); - BARRIER; - pmdp = pmd_offset(pgdp, address); - idx = read_c0_index(); - ptep = pte_offset(pmdp, address); -- BARRIER; - write_c0_entrylo0(pte_val(*ptep++) >> 6); - write_c0_entrylo1(pte_val(*ptep) >> 6); -- write_c0_entryhi(address | (pid)); -- BARRIER; -- if(idx < 0) { -+ write_c0_entryhi(address | pid); -+ mtc0_tlbw_hazard(); -+ if (idx < 0) - tlb_write_random(); -- } else { -+ else - tlb_write_indexed(); -- } -- BARRIER; -+ tlbw_use_hazard(); - write_c0_entryhi(pid); -- BARRIER; - local_irq_restore(flags); - } - --void add_wired_entry(unsigned long entrylo0, unsigned long entrylo1, -- unsigned long entryhi, unsigned long pagemask) -+void __init add_wired_entry(unsigned long entrylo0, unsigned long entrylo1, -+ unsigned long entryhi, unsigned long pagemask) - { -- unsigned long flags; -- unsigned long wired; -- unsigned long old_pagemask; -- unsigned long old_ctx; -- -- local_irq_save(flags); -- /* Save old context and create impossible VPN2 value */ -- old_ctx = (read_c0_entryhi() & ASID_MASK); -- old_pagemask = read_c0_pagemask(); -- wired = read_c0_wired(); -- write_c0_wired(wired + 1); -- write_c0_index(wired); -- BARRIER; -- write_c0_pagemask(pagemask); -- write_c0_entryhi(entryhi); -- write_c0_entrylo0(entrylo0); -- write_c0_entrylo1(entrylo1); -- BARRIER; -- tlb_write_indexed(); -- BARRIER; -- -- write_c0_entryhi(old_ctx); -- BARRIER; -- write_c0_pagemask(old_pagemask); -- local_flush_tlb_all(); -- local_irq_restore(flags); -+ unsigned long flags; -+ unsigned long wired; -+ unsigned long old_pagemask; -+ unsigned long old_ctx; -+ -+ local_irq_save(flags); -+ /* Save old context and create impossible VPN2 value */ -+ old_ctx = read_c0_entryhi() & ASID_MASK; -+ old_pagemask = read_c0_pagemask(); -+ wired = read_c0_wired(); -+ write_c0_wired(wired + 1); -+ write_c0_index(wired); -+ BARRIER; -+ write_c0_pagemask(pagemask); -+ write_c0_entryhi(entryhi); -+ write_c0_entrylo0(entrylo0); -+ write_c0_entrylo1(entrylo1); -+ mtc0_tlbw_hazard(); -+ tlb_write_indexed(); -+ tlbw_use_hazard(); -+ -+ write_c0_entryhi(old_ctx); -+ BARRIER; -+ write_c0_pagemask(old_pagemask); -+ local_flush_tlb_all(); -+ local_irq_restore(flags); - } - - /* -@@ -317,17 +273,15 @@ __init int add_temporary_entry(unsigned - } - - write_c0_index(temp_tlb_entry); -- BARRIER; - write_c0_pagemask(pagemask); - write_c0_entryhi(entryhi); - write_c0_entrylo0(entrylo0); - write_c0_entrylo1(entrylo1); -- BARRIER; -+ mtc0_tlbw_hazard(); - tlb_write_indexed(); -- BARRIER; -+ tlbw_use_hazard(); - - write_c0_entryhi(old_ctx); -- BARRIER; - write_c0_pagemask(old_pagemask); - out: - local_irq_restore(flags); -@@ -348,15 +302,23 @@ static void __init probe_tlb(unsigned lo - return; - - config1 = read_c0_config1(); -- if (!((config1 >> 7) & 3)) -- panic("No MMU present"); -+ if (!((config >> 7) & 3)) -+ panic("No TLB present"); - - c->tlbsize = ((config1 >> 25) & 0x3f) + 1; - } - - void __init r4k_tlb_init(void) - { -- unsigned long config = read_c0_config(); -+ unsigned int config = read_c0_config(); -+ -+ /* -+ * You should never change this register: -+ * - On R4600 1.7 the tlbp never hits for pages smaller than -+ * the value in the c0_pagemask register. -+ * - The entire mm handling assumes the c0_pagemask register to -+ * be set for 4kb pages. -+ */ - probe_tlb(config); - write_c0_pagemask(PM_DEFAULT_MASK); - write_c0_wired(0); ---- a/drivers/char/au1000_gpio.c -+++ b/drivers/char/au1000_gpio.c -@@ -246,7 +246,7 @@ static struct file_operations au1000gpio - - static struct miscdevice au1000gpio_miscdev = - { -- GPIO_MINOR, -+ MISC_DYNAMIC_MINOR, - "au1000_gpio", - &au1000gpio_fops - }; ---- /dev/null -+++ b/drivers/char/au1550_psc_spi.c -@@ -0,0 +1,466 @@ -+/* -+ * Driver for Alchemy Au1550 SPI on the PSC. -+ * -+ * Copyright 2004 Embedded Edge, LLC. -+ * dan@embeddededge.com -+ * -+ * This program is free software; you can redistribute it and/or modify it -+ * under the terms of the GNU General Public License as published by the -+ * Free Software Foundation; either version 2 of the License, or (at your -+ * option) any later version. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN -+ * NO EVENT SHALL THE AUTHOR 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. -+ * -+ * You should have received a copy of the GNU General Public License along -+ * with this program; if not, write to the Free Software Foundation, Inc., -+ * 675 Mass Ave, Cambridge, MA 02139, USA. -+ */ -+ -+#include <linux/module.h> -+#include <linux/config.h> -+#include <linux/types.h> -+#include <linux/kernel.h> -+#include <linux/miscdevice.h> -+#include <linux/init.h> -+#include <asm/uaccess.h> -+#include <asm/io.h> -+#include <asm/au1000.h> -+#include <asm/au1550_spi.h> -+#include <asm/au1xxx_psc.h> -+ -+#ifdef CONFIG_MIPS_PB1550 -+#include <asm/pb1550.h> -+#endif -+ -+#ifdef CONFIG_MIPS_DB1550 -+#include <asm/db1x00.h> -+#endif -+ -+#ifdef CONFIG_MIPS_PB1200 -+#include <asm/pb1200.h> -+#endif -+ -+/* This is just a simple programmed I/O SPI interface on the PSC of the 1550. -+ * We support open, close, write, and ioctl. The SPI is a full duplex -+ * interface, you can't read without writing. So, the write system call -+ * copies the bytes out to the SPI, and whatever is returned is placed -+ * in the same buffer. Kinda weird, maybe we'll change it, but for now -+ * it works OK. -+ * I didn't implement any DMA yet, and it's a debate about the necessity. -+ * The SPI clocks are usually quite fast, so data is sent/received as -+ * quickly as you can stuff the FIFO. The overhead of DMA and interrupts -+ * are usually far greater than the data transfer itself. If, however, -+ * we find applications that move large amounts of data, we may choose -+ * use the overhead of buffering and DMA to do the work. -+ */ -+ -+/* The maximum clock rate specified in the manual is 2mHz. -+*/ -+#define MAX_BAUD_RATE (2 * 1000000) -+#define PSC_INTCLK_RATE (32 * 1000000) -+ -+static int inuse; -+ -+/* We have to know what the user requested for the data length -+ * so we know how to stuff the fifo. The FIFO is 32 bits wide, -+ * and we have to load it with the bits to go in a single transfer. -+ */ -+static uint spi_datalen; -+ -+static int -+au1550spi_master_done( int ms ) -+{ -+ int timeout=ms; -+ volatile psc_spi_t *sp; -+ -+ sp = (volatile psc_spi_t *)SPI_PSC_BASE; -+ -+ /* Loop until MD is set or timeout has expired */ -+ while(!(sp->psc_spievent & PSC_SPIEVNT_MD) && timeout--) udelay(1000); -+ -+ if ( !timeout ) -+ return 0; -+ else -+ sp->psc_spievent |= PSC_SPIEVNT_MD; -+ -+ return 1; -+} -+ -+static int -+au1550spi_open(struct inode *inode, struct file *file) -+{ -+ if (inuse) -+ return -EBUSY; -+ -+ inuse = 1; -+ -+ MOD_INC_USE_COUNT; -+ -+ return 0; -+} -+ -+static ssize_t -+au1550spi_write(struct file *fp, const char *bp, size_t count, loff_t *ppos) -+{ -+ int bytelen, i; -+ size_t rcount, retval; -+ unsigned char sb, *rp, *wp; -+ uint fifoword, pcr, stat; -+ volatile psc_spi_t *sp; -+ -+ /* Get the number of bytes per transfer. -+ */ -+ bytelen = ((spi_datalen - 1) / 8) + 1; -+ -+ /* User needs to send us multiple of this count. -+ */ -+ if ((count % bytelen) != 0) -+ return -EINVAL; -+ -+ rp = wp = (unsigned char *)bp; -+ retval = rcount = count; -+ -+ /* Reset the FIFO. -+ */ -+ sp = (volatile psc_spi_t *)SPI_PSC_BASE; -+ sp->psc_spipcr = (PSC_SPIPCR_RC | PSC_SPIPCR_TC); -+ au_sync(); -+ do { -+ pcr = sp->psc_spipcr; -+ au_sync(); -+ } while (pcr != 0); -+ -+ /* Prime the transmit FIFO. -+ */ -+ while (count > 0) { -+ fifoword = 0; -+ for (i=0; i<bytelen; i++) { -+ fifoword <<= 8; -+ if (get_user(sb, wp) < 0) -+ return -EFAULT; -+ fifoword |= sb; -+ wp++; -+ } -+ count -= bytelen; -+ if (count <= 0) -+ fifoword |= PSC_SPITXRX_LC; -+ sp->psc_spitxrx = fifoword; -+ au_sync(); -+ stat = sp->psc_spistat; -+ au_sync(); -+ if (stat & PSC_SPISTAT_TF) -+ break; -+ } -+ -+ /* Start the transfer. -+ */ -+ sp->psc_spipcr = PSC_SPIPCR_MS; -+ au_sync(); -+ -+ /* Now, just keep the transmit fifo full and empty the receive. -+ */ -+ while (count > 0) { -+ stat = sp->psc_spistat; -+ au_sync(); -+ while ((stat & PSC_SPISTAT_RE) == 0) { -+ fifoword = sp->psc_spitxrx; -+ au_sync(); -+ for (i=0; i<bytelen; i++) { -+ sb = fifoword & 0xff; -+ if (put_user(sb, rp) < 0) -+ return -EFAULT; -+ fifoword >>= 8; -+ rp++; -+ } -+ rcount -= bytelen; -+ stat = sp->psc_spistat; -+ au_sync(); -+ } -+ if ((stat & PSC_SPISTAT_TF) == 0) { -+ fifoword = 0; -+ for (i=0; i<bytelen; i++) { -+ fifoword <<= 8; -+ if (get_user(sb, wp) < 0) -+ return -EFAULT; -+ fifoword |= sb; -+ wp++; -+ } -+ count -= bytelen; -+ if (count <= 0) -+ fifoword |= PSC_SPITXRX_LC; -+ sp->psc_spitxrx = fifoword; -+ au_sync(); -+ } -+ } -+ -+ /* All of the bytes for transmit have been written. Hang -+ * out waiting for any residual bytes that are yet to be -+ * read from the fifo. -+ */ -+ while (rcount > 0) { -+ stat = sp->psc_spistat; -+ au_sync(); -+ if ((stat & PSC_SPISTAT_RE) == 0) { -+ fifoword = sp->psc_spitxrx; -+ au_sync(); -+ for (i=0; i<bytelen; i++) { -+ sb = fifoword & 0xff; -+ if (put_user(sb, rp) < 0) -+ return -EFAULT; -+ fifoword >>= 8; -+ rp++; -+ } -+ rcount -= bytelen; -+ } -+ } -+ -+ /* Wait for MasterDone event. 30ms timeout */ -+ if (!au1550spi_master_done(30) ) retval = -EFAULT; -+ return retval; -+} -+ -+static int -+au1550spi_release(struct inode *inode, struct file *file) -+{ -+ MOD_DEC_USE_COUNT; -+ -+ inuse = 0; -+ -+ return 0; -+} -+ -+/* Set the baud rate closest to the request, then return the actual -+ * value we are using. -+ */ -+static uint -+set_baud_rate(uint baud) -+{ -+ uint rate, tmpclk, brg, ctl, stat; -+ volatile psc_spi_t *sp; -+ -+ /* For starters, the input clock is divided by two. -+ */ -+ tmpclk = PSC_INTCLK_RATE/2; -+ -+ rate = tmpclk / baud; -+ -+ /* The dividers work as follows: -+ * baud = tmpclk / (2 * (brg + 1)) -+ */ -+ brg = (rate/2) - 1; -+ -+ /* Test BRG to ensure it will fit into the 6 bits allocated. -+ */ -+ -+ /* Make sure the device is disabled while we make the change. -+ */ -+ sp = (volatile psc_spi_t *)SPI_PSC_BASE; -+ ctl = sp->psc_spicfg; -+ au_sync(); -+ sp->psc_spicfg = ctl & ~PSC_SPICFG_DE_ENABLE; -+ au_sync(); -+ ctl = PSC_SPICFG_CLR_BAUD(ctl); -+ ctl |= PSC_SPICFG_SET_BAUD(brg); -+ sp->psc_spicfg = ctl; -+ au_sync(); -+ -+ /* If the device was running prior to getting here, wait for -+ * it to restart. -+ */ -+ if (ctl & PSC_SPICFG_DE_ENABLE) { -+ do { -+ stat = sp->psc_spistat; -+ au_sync(); -+ } while ((stat & PSC_SPISTAT_DR) == 0); -+ } -+ -+ /* Return the actual value. -+ */ -+ rate = tmpclk / (2 * (brg + 1)); -+ -+ return(rate); -+} -+ -+static uint -+set_word_len(uint len) -+{ -+ uint ctl, stat; -+ volatile psc_spi_t *sp; -+ -+ if ((len < 4) || (len > 24)) -+ return -EINVAL; -+ -+ /* Make sure the device is disabled while we make the change. -+ */ -+ sp = (volatile psc_spi_t *)SPI_PSC_BASE; -+ ctl = sp->psc_spicfg; -+ au_sync(); -+ sp->psc_spicfg = ctl & ~PSC_SPICFG_DE_ENABLE; -+ au_sync(); -+ ctl = PSC_SPICFG_CLR_LEN(ctl); -+ ctl |= PSC_SPICFG_SET_LEN(len); -+ sp->psc_spicfg = ctl; -+ au_sync(); -+ -+ /* If the device was running prior to getting here, wait for -+ * it to restart. -+ */ -+ if (ctl & PSC_SPICFG_DE_ENABLE) { -+ do { -+ stat = sp->psc_spistat; -+ au_sync(); -+ } while ((stat & PSC_SPISTAT_DR) == 0); -+ } -+ -+ return 0; -+} -+ -+static int -+au1550spi_ioctl(struct inode *inode, struct file *file, -+ unsigned int cmd, unsigned long arg) -+{ -+ int status; -+ u32 val; -+ -+ status = 0; -+ -+ switch(cmd) { -+ case AU1550SPI_WORD_LEN: -+ status = set_word_len(arg); -+ break; -+ -+ case AU1550SPI_SET_BAUD: -+ if (get_user(val, (u32 *)arg)) -+ return -EFAULT; -+ -+ val = set_baud_rate(val); -+ if (put_user(val, (u32 *)arg)) -+ return -EFAULT; -+ break; -+ -+ default: -+ status = -ENOIOCTLCMD; -+ -+ } -+ -+ return status; -+} -+ -+ -+static struct file_operations au1550spi_fops = -+{ -+ owner: THIS_MODULE, -+ write: au1550spi_write, -+ ioctl: au1550spi_ioctl, -+ open: au1550spi_open, -+ release: au1550spi_release, -+}; -+ -+ -+static struct miscdevice au1550spi_miscdev = -+{ -+ MISC_DYNAMIC_MINOR, -+ "au1550_spi", -+ &au1550spi_fops -+}; -+ -+ -+int __init -+au1550spi_init(void) -+{ -+ uint clk, rate, stat; -+ volatile psc_spi_t *sp; -+ -+ /* Wire up Freq3 as a clock for the SPI. The PSC does -+ * factor of 2 divisor, so run a higher rate so we can -+ * get some granularity to the clock speeds. -+ * We can't do this in board set up because the frequency -+ * is computed too late. -+ */ -+ rate = get_au1x00_speed(); -+ rate /= PSC_INTCLK_RATE; -+ -+ /* The FRDIV in the frequency control is (FRDIV + 1) * 2 -+ */ -+ rate /=2; -+ rate--; -+ clk = au_readl(SYS_FREQCTRL1); -+ au_sync(); -+ clk &= ~SYS_FC_FRDIV3_MASK; -+ clk |= (rate << SYS_FC_FRDIV3_BIT); -+ clk |= SYS_FC_FE3; -+ au_writel(clk, SYS_FREQCTRL1); -+ au_sync(); -+ -+ /* Set up the clock source routing to get Freq3 to PSC0_intclk. -+ */ -+ clk = au_readl(SYS_CLKSRC); -+ au_sync(); -+ clk &= ~0x03e0; -+ clk |= (5 << 7); -+ au_writel(clk, SYS_CLKSRC); -+ au_sync(); -+ -+ /* Set up GPIO pin function to drive PSC0_SYNC1, which is -+ * the SPI Select. -+ */ -+ clk = au_readl(SYS_PINFUNC); -+ au_sync(); -+ clk |= 1; -+ au_writel(clk, SYS_PINFUNC); -+ au_sync(); -+ -+ /* Now, set up the PSC for SPI PIO mode. -+ */ -+ sp = (volatile psc_spi_t *)SPI_PSC_BASE; -+ sp->psc_ctrl = PSC_CTRL_DISABLE; -+ au_sync(); -+ sp->psc_sel = PSC_SEL_PS_SPIMODE; -+ sp->psc_spicfg = 0; -+ au_sync(); -+ sp->psc_ctrl = PSC_CTRL_ENABLE; -+ au_sync(); -+ do { -+ stat = sp->psc_spistat; -+ au_sync(); -+ } while ((stat & PSC_SPISTAT_SR) == 0); -+ -+ sp->psc_spicfg = (PSC_SPICFG_RT_FIFO8 | PSC_SPICFG_TT_FIFO8 | -+ PSC_SPICFG_DD_DISABLE | PSC_SPICFG_MO); -+ sp->psc_spicfg |= PSC_SPICFG_SET_LEN(8); -+ spi_datalen = 8; -+ sp->psc_spimsk = PSC_SPIMSK_ALLMASK; -+ au_sync(); -+ -+ set_baud_rate(1000000); -+ -+ sp->psc_spicfg |= PSC_SPICFG_DE_ENABLE; -+ do { -+ stat = sp->psc_spistat; -+ au_sync(); -+ } while ((stat & PSC_SPISTAT_DR) == 0); -+ -+ misc_register(&au1550spi_miscdev); -+ printk("Au1550 SPI driver\n"); -+ return 0; -+} -+ -+ -+void __exit -+au1550spi_exit(void) -+{ -+ misc_deregister(&au1550spi_miscdev); -+} -+ -+ -+module_init(au1550spi_init); -+module_exit(au1550spi_exit); ---- a/drivers/char/Config.in -+++ b/drivers/char/Config.in -@@ -322,14 +322,11 @@ fi - if [ "$CONFIG_OBSOLETE" = "y" -a "$CONFIG_ALPHA_BOOK1" = "y" ]; then - bool 'Tadpole ANA H8 Support (OBSOLETE)' CONFIG_H8 - fi --if [ "$CONFIG_MIPS" = "y" -a "$CONFIG_NEW_TIME_C" = "y" ]; then -- tristate 'Generic MIPS RTC Support' CONFIG_MIPS_RTC --fi - if [ "$CONFIG_SGI_IP22" = "y" ]; then -- bool 'SGI DS1286 RTC support' CONFIG_SGI_DS1286 -+ tristate 'Dallas DS1286 RTC support' CONFIG_DS1286 - fi - if [ "$CONFIG_SGI_IP27" = "y" ]; then -- bool 'SGI M48T35 RTC support' CONFIG_SGI_IP27_RTC -+ tristate 'SGI M48T35 RTC support' CONFIG_SGI_IP27_RTC - fi - if [ "$CONFIG_TOSHIBA_RBTX4927" = "y" -o "$CONFIG_TOSHIBA_JMR3927" = "y" ]; then - tristate 'Dallas DS1742 RTC support' CONFIG_DS1742 -@@ -392,6 +389,11 @@ if [ "$CONFIG_DRM" = "y" ]; then - source drivers/char/drm/Config.in - fi - fi -+ -+if [ "$CONFIG_X86" = "y" ]; then -+ tristate 'ACP Modem (Mwave) support' CONFIG_MWAVE -+fi -+ - endmenu - - if [ "$CONFIG_HOTPLUG" = "y" -a "$CONFIG_PCMCIA" != "n" ]; then -@@ -400,6 +402,7 @@ fi - if [ "$CONFIG_SOC_AU1X00" = "y" ]; then - tristate ' Alchemy Au1x00 GPIO device support' CONFIG_AU1X00_GPIO - tristate ' Au1000/ADS7846 touchscreen support' CONFIG_TS_AU1X00_ADS7846 -+ #tristate ' Alchemy Au1550 PSC SPI support' CONFIG_AU1550_PSC_SPI - fi - if [ "$CONFIG_MIPS_ITE8172" = "y" ]; then - tristate ' ITE GPIO' CONFIG_ITE_GPIO ---- a/drivers/char/decserial.c -+++ b/drivers/char/decserial.c -@@ -3,95 +3,105 @@ - * choose the right serial device at boot time - * - * triemer 6-SEP-1998 -- * sercons.c is designed to allow the three different kinds -+ * sercons.c is designed to allow the three different kinds - * of serial devices under the decstation world to co-exist -- * in the same kernel. The idea here is to abstract -+ * in the same kernel. The idea here is to abstract - * the pieces of the drivers that are common to this file - * so that they do not clash at compile time and runtime. - * - * HK 16-SEP-1998 v0.002 - * removed the PROM console as this is not a real serial - * device. Added support for PROM console in drivers/char/tty_io.c -- * instead. Although it may work to enable more than one -+ * instead. Although it may work to enable more than one - * console device I strongly recommend to use only one. -+ * -+ * Copyright (C) 2004 Maciej W. Rozycki - */ - - #include <linux/config.h> -+#include <linux/errno.h> - #include <linux/init.h> -+ - #include <asm/dec/machtype.h> -+#include <asm/dec/serial.h> -+ -+extern int register_zs_hook(unsigned int channel, -+ struct dec_serial_hook *hook); -+extern int unregister_zs_hook(unsigned int channel); -+ -+extern int register_dz_hook(unsigned int channel, -+ struct dec_serial_hook *hook); -+extern int unregister_dz_hook(unsigned int channel); - -+int register_dec_serial_hook(unsigned int channel, -+ struct dec_serial_hook *hook) -+{ - #ifdef CONFIG_ZS --extern int zs_init(void); -+ if (IOASIC) -+ return register_zs_hook(channel, hook); - #endif -- - #ifdef CONFIG_DZ --extern int dz_init(void); -+ if (!IOASIC) -+ return register_dz_hook(channel, hook); - #endif -+ return 0; -+} - --#ifdef CONFIG_SERIAL_DEC_CONSOLE -- -+int unregister_dec_serial_hook(unsigned int channel) -+{ - #ifdef CONFIG_ZS --extern void zs_serial_console_init(void); -+ if (IOASIC) -+ return unregister_zs_hook(channel); - #endif -- - #ifdef CONFIG_DZ --extern void dz_serial_console_init(void); --#endif -- -+ if (!IOASIC) -+ return unregister_dz_hook(channel); - #endif -+ return 0; -+} - --/* rs_init - starts up the serial interface - -- handle normal case of starting up the serial interface */ - --#ifdef CONFIG_SERIAL_DEC -+extern int zs_init(void); -+extern int dz_init(void); - -+/* -+ * rs_init - starts up the serial interface - -+ * handle normal case of starting up the serial interface -+ */ - int __init rs_init(void) - { -- --#if defined(CONFIG_ZS) && defined(CONFIG_DZ) -- if (IOASIC) -- return zs_init(); -- else -- return dz_init(); --#else -- - #ifdef CONFIG_ZS -- return zs_init(); -+ if (IOASIC) -+ return zs_init(); - #endif -- - #ifdef CONFIG_DZ -- return dz_init(); --#endif -- -+ if (!IOASIC) -+ return dz_init(); - #endif -+ return -ENXIO; - } - - __initcall(rs_init); - --#endif - - #ifdef CONFIG_SERIAL_DEC_CONSOLE - --/* dec_serial_console_init handles the special case of starting -- * up the console on the serial port -+extern void zs_serial_console_init(void); -+extern void dz_serial_console_init(void); -+ -+/* -+ * dec_serial_console_init handles the special case of starting -+ * up the console on the serial port - */ - void __init dec_serial_console_init(void) - { --#if defined(CONFIG_ZS) && defined(CONFIG_DZ) -- if (IOASIC) -- zs_serial_console_init(); -- else -- dz_serial_console_init(); --#else -- - #ifdef CONFIG_ZS -- zs_serial_console_init(); -+ if (IOASIC) -+ zs_serial_console_init(); - #endif -- - #ifdef CONFIG_DZ -- dz_serial_console_init(); --#endif -- -+ if (!IOASIC) -+ dz_serial_console_init(); - #endif - } - ---- a/drivers/char/ds1286.c -+++ b/drivers/char/ds1286.c -@@ -1,6 +1,10 @@ - /* - * DS1286 Real Time Clock interface for Linux - * -+ * Copyright (C) 2003 TimeSys Corp. -+ * S. James Hill (James.Hill@timesys.com) -+ * (sjhill@realitydiluted.com) -+ * - * Copyright (C) 1998, 1999, 2000 Ralf Baechle - * - * Based on code written by Paul Gortmaker. -@@ -29,6 +33,7 @@ - #include <linux/types.h> - #include <linux/errno.h> - #include <linux/miscdevice.h> -+#include <linux/module.h> - #include <linux/slab.h> - #include <linux/ioport.h> - #include <linux/fcntl.h> -@@ -95,6 +100,12 @@ static ssize_t ds1286_read(struct file * - return -EIO; - } - -+void rtc_ds1286_wait(void) -+{ -+ unsigned char sec = CMOS_READ(RTC_SECONDS); -+ while (sec == CMOS_READ(RTC_SECONDS)); -+} -+ - static int ds1286_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg) - { -@@ -249,23 +260,22 @@ static int ds1286_open(struct inode *ino - { - spin_lock_irq(&ds1286_lock); - -- if (ds1286_status & RTC_IS_OPEN) -- goto out_busy; -+ if (ds1286_status & RTC_IS_OPEN) { -+ spin_unlock_irq(&ds1286_lock); -+ return -EBUSY; -+ } - - ds1286_status |= RTC_IS_OPEN; - -- spin_lock_irq(&ds1286_lock); -+ spin_unlock_irq(&ds1286_lock); - return 0; -- --out_busy: -- spin_lock_irq(&ds1286_lock); -- return -EBUSY; - } - - static int ds1286_release(struct inode *inode, struct file *file) - { -+ spin_lock_irq(&ds1286_lock); - ds1286_status &= ~RTC_IS_OPEN; -- -+ spin_unlock_irq(&ds1286_lock); - return 0; - } - -@@ -276,32 +286,6 @@ static unsigned int ds1286_poll(struct f - return 0; - } - --/* -- * The various file operations we support. -- */ -- --static struct file_operations ds1286_fops = { -- .llseek = no_llseek, -- .read = ds1286_read, -- .poll = ds1286_poll, -- .ioctl = ds1286_ioctl, -- .open = ds1286_open, -- .release = ds1286_release, --}; -- --static struct miscdevice ds1286_dev= --{ -- .minor = RTC_MINOR, -- .name = "rtc", -- .fops = &ds1286_fops, --}; -- --int __init ds1286_init(void) --{ -- printk(KERN_INFO "DS1286 Real Time Clock Driver v%s\n", DS1286_VERSION); -- return misc_register(&ds1286_dev); --} -- - static char *days[] = { - "***", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" - }; -@@ -528,3 +512,38 @@ void ds1286_get_alm_time(struct rtc_time - BCD_TO_BIN(alm_tm->tm_hour); - alm_tm->tm_sec = 0; - } -+ -+static struct file_operations ds1286_fops = { -+ .owner = THIS_MODULE, -+ .llseek = no_llseek, -+ .read = ds1286_read, -+ .poll = ds1286_poll, -+ .ioctl = ds1286_ioctl, -+ .open = ds1286_open, -+ .release = ds1286_release, -+}; -+ -+static struct miscdevice ds1286_dev = -+{ -+ .minor = RTC_MINOR, -+ .name = "rtc", -+ .fops = &ds1286_fops, -+}; -+ -+static int __init ds1286_init(void) -+{ -+ printk(KERN_INFO "DS1286 Real Time Clock Driver v%s\n", DS1286_VERSION); -+ return misc_register(&ds1286_dev); -+} -+ -+static void __exit ds1286_exit(void) -+{ -+ misc_deregister(&ds1286_dev); -+} -+ -+module_init(ds1286_init); -+module_exit(ds1286_exit); -+EXPORT_NO_SYMBOLS; -+ -+MODULE_AUTHOR("Ralf Baechle"); -+MODULE_LICENSE("GPL"); ---- a/drivers/char/ds1742.c -+++ b/drivers/char/ds1742.c -@@ -142,6 +142,7 @@ static int rtc_ds1742_set_time(unsigned - CMOS_WRITE(RTC_WRITE, RTC_CONTROL); - - /* convert */ -+ memset(&tm, 0, sizeof(struct rtc_time)); - to_tm(t, &tm); - - /* check each field one by one */ -@@ -216,6 +217,7 @@ static int get_ds1742_status(char *buf) - unsigned long curr_time; - - curr_time = rtc_ds1742_get_time(); -+ memset(&tm, 0, sizeof(struct rtc_time)); - to_tm(curr_time, &tm); - - p = buf; -@@ -251,8 +253,8 @@ static int ds1742_read_proc(char *page, - - void rtc_ds1742_wait(void) - { -- while (CMOS_READ(RTC_SECONDS) & 1); -- while (!(CMOS_READ(RTC_SECONDS) & 1)); -+ unsigned char sec = CMOS_READ(RTC_SECONDS); -+ while (sec == CMOS_READ(RTC_SECONDS)); - } - - static int ds1742_ioctl(struct inode *inode, struct file *file, -@@ -264,6 +266,7 @@ static int ds1742_ioctl(struct inode *in - switch (cmd) { - case RTC_RD_TIME: /* Read the time/date from RTC */ - curr_time = rtc_ds1742_get_time(); -+ memset(&rtc_tm, 0, sizeof(struct rtc_time)); - to_tm(curr_time, &rtc_tm); - rtc_tm.tm_year -= 1900; - return copy_to_user((void *) arg, &rtc_tm, sizeof(rtc_tm)) ? ---- a/drivers/char/dummy_keyb.c -+++ b/drivers/char/dummy_keyb.c -@@ -141,3 +141,7 @@ void __init kbd_init_hw(void) - { - printk("Dummy keyboard driver installed.\n"); - } -+#ifdef CONFIG_MAGIC_SYSRQ -+unsigned char kbd_sysrq_key; -+unsigned char kbd_sysrq_xlate[128]; -+#endif ---- a/drivers/char/dz.c -+++ b/drivers/char/dz.c -@@ -1,11 +1,13 @@ - /* -- * dz.c: Serial port driver for DECStations equiped -+ * dz.c: Serial port driver for DECstations equipped - * with the DZ chipset. - * - * Copyright (C) 1998 Olivier A. D. Lebaillif - * - * Email: olivier.lebaillif@ifrsys.com - * -+ * Copyright (C) 2004 Maciej W. Rozycki -+ * - * [31-AUG-98] triemer - * Changed IRQ to use Harald's dec internals interrupts.h - * removed base_addr code - moving address assignment to setup.c -@@ -24,6 +26,7 @@ - #undef DEBUG_DZ - - #include <linux/config.h> -+#include <linux/delay.h> - #include <linux/version.h> - #include <linux/kernel.h> - #include <linux/sched.h> -@@ -54,33 +57,56 @@ - #include <asm/system.h> - #include <asm/uaccess.h> - --#define CONSOLE_LINE (3) /* for definition of struct console */ -+#ifdef CONFIG_MAGIC_SYSRQ -+#include <linux/sysrq.h> -+#endif - - #include "dz.h" - --#define DZ_INTR_DEBUG 1 -- - DECLARE_TASK_QUEUE(tq_serial); - --static struct dz_serial *lines[4]; --static unsigned char tmp_buffer[256]; -+static struct dz_serial multi[DZ_NB_PORT]; /* Four serial lines in the DZ chip */ -+static struct tty_driver serial_driver, callout_driver; -+ -+static struct tty_struct *serial_table[DZ_NB_PORT]; -+static struct termios *serial_termios[DZ_NB_PORT]; -+static struct termios *serial_termios_locked[DZ_NB_PORT]; -+ -+static int serial_refcount; - --#ifdef DEBUG_DZ - /* -- * debugging code to send out chars via prom -+ * tmp_buf is used as a temporary buffer by serial_write. We need to -+ * lock it in case the copy_from_user blocks while swapping in a page, -+ * and some other program tries to do a serial write at the same time. -+ * Since the lock will only come under contention when the system is -+ * swapping and available memory is low, it makes sense to share one -+ * buffer across all the serial ports, since it significantly saves -+ * memory if large numbers of serial ports are open. - */ --static void debug_console(const char *s, int count) --{ -- unsigned i; -+static unsigned char *tmp_buf; -+static DECLARE_MUTEX(tmp_buf_sem); - -- for (i = 0; i < count; i++) { -- if (*s == 10) -- prom_printf("%c", 13); -- prom_printf("%c", *s++); -- } --} -+static char *dz_name __initdata = "DECstation DZ serial driver version "; -+static char *dz_version __initdata = "1.03"; -+ -+static struct dz_serial *lines[DZ_NB_PORT]; -+static unsigned char tmp_buffer[256]; -+ -+#ifdef CONFIG_SERIAL_DEC_CONSOLE -+static struct console dz_sercons; -+#endif -+#if defined(CONFIG_SERIAL_DEC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) && \ -+ !defined(MODULE) -+static unsigned long break_pressed; /* break, really ... */ - #endif - -+static void change_speed (struct dz_serial *); -+ -+static int baud_table[] = { -+ 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, -+ 9600, 0 -+}; -+ - /* - * ------------------------------------------------------------ - * dz_in () and dz_out () -@@ -94,15 +120,16 @@ static inline unsigned short dz_in(struc - { - volatile unsigned short *addr = - (volatile unsigned short *) (info->port + offset); -+ - return *addr; - } - - static inline void dz_out(struct dz_serial *info, unsigned offset, - unsigned short value) - { -- - volatile unsigned short *addr = - (volatile unsigned short *) (info->port + offset); -+ - *addr = value; - } - -@@ -143,25 +170,24 @@ static void dz_start(struct tty_struct * - - tmp |= mask; /* set the TX flag */ - dz_out(info, DZ_TCR, tmp); -- - } - - /* - * ------------------------------------------------------------ -- * Here starts the interrupt handling routines. All of the -- * following subroutines are declared as inline and are folded -- * into dz_interrupt. They were separated out for readability's -- * sake. - * -- * Note: rs_interrupt() is a "fast" interrupt, which means that it -+ * Here starts the interrupt handling routines. All of the following -+ * subroutines are declared as inline and are folded into -+ * dz_interrupt(). They were separated out for readability's sake. -+ * -+ * Note: dz_interrupt() is a "fast" interrupt, which means that it - * runs with interrupts turned off. People who may want to modify -- * rs_interrupt() should try to keep the interrupt handler as fast as -+ * dz_interrupt() should try to keep the interrupt handler as fast as - * possible. After you are done making modifications, it is not a bad - * idea to do: - * - * gcc -S -DKERNEL -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer dz.c - * -- * and look at the resulting assemble code in serial.s. -+ * and look at the resulting assemble code in dz.s. - * - * ------------------------------------------------------------ - */ -@@ -188,101 +214,97 @@ static inline void dz_sched_event(struct - * This routine deals with inputs from any lines. - * ------------------------------------------------------------ - */ --static inline void receive_chars(struct dz_serial *info_in) -+static inline void receive_chars(struct dz_serial *info_in, -+ struct pt_regs *regs) - { -- - struct dz_serial *info; -- struct tty_struct *tty = 0; -+ struct tty_struct *tty; - struct async_icount *icount; -- int ignore = 0; -- unsigned short status, tmp; -- unsigned char ch; -- -- /* this code is going to be a problem... -- the call to tty_flip_buffer is going to need -- to be rethought... -- */ -- do { -- status = dz_in(info_in, DZ_RBUF); -- info = lines[LINE(status)]; -+ int lines_rx[DZ_NB_PORT] = { [0 ... DZ_NB_PORT - 1] = 0 }; -+ unsigned short status; -+ unsigned char ch, flag; -+ int i; - -- /* punt so we don't get duplicate characters */ -- if (!(status & DZ_DVAL)) -- goto ignore_char; -- -- ch = UCHAR(status); /* grab the char */ -- --#if 0 -- if (info->is_console) { -- if (ch == 0) -- return; /* it's a break ... */ -- } --#endif -+ while ((status = dz_in(info_in, DZ_RBUF)) & DZ_DVAL) { -+ info = lines[LINE(status)]; -+ tty = info->tty; /* point to the proper dev */ - -- tty = info->tty; /* now tty points to the proper dev */ -- icount = &info->icount; -+ ch = UCHAR(status); /* grab the char */ - -- if (!tty) -- break; -- if (tty->flip.count >= TTY_FLIPBUF_SIZE) -- break; -+ if (!tty && (!info->hook || !info->hook->rx_char)) -+ continue; - -- *tty->flip.char_buf_ptr = ch; -- *tty->flip.flag_buf_ptr = 0; -+ icount = &info->icount; - icount->rx++; - -- /* keep track of the statistics */ -- if (status & (DZ_OERR | DZ_FERR | DZ_PERR)) { -- if (status & DZ_PERR) /* parity error */ -- icount->parity++; -- else if (status & DZ_FERR) /* frame error */ -- icount->frame++; -- if (status & DZ_OERR) /* overrun error */ -- icount->overrun++; -- -- /* check to see if we should ignore the character -- and mask off conditions that should be ignored -+ flag = 0; -+ if (status & DZ_FERR) { /* frame error */ -+ /* -+ * There is no separate BREAK status bit, so -+ * treat framing errors as BREAKs for Magic SysRq -+ * and SAK; normally, otherwise. - */ -- -- if (status & info->ignore_status_mask) { -- if (++ignore > 100) -- break; -- goto ignore_char; -+#if defined(CONFIG_SERIAL_DEC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) && \ -+ !defined(MODULE) -+ if (info->line == dz_sercons.index) { -+ if (!break_pressed) -+ break_pressed = jiffies; -+ continue; - } -- /* mask off the error conditions we want to ignore */ -- tmp = status & info->read_status_mask; -- -- if (tmp & DZ_PERR) { -- *tty->flip.flag_buf_ptr = TTY_PARITY; --#ifdef DEBUG_DZ -- debug_console("PERR\n", 5); --#endif -- } else if (tmp & DZ_FERR) { -- *tty->flip.flag_buf_ptr = TTY_FRAME; --#ifdef DEBUG_DZ -- debug_console("FERR\n", 5); - #endif -+ flag = TTY_BREAK; -+ if (info->flags & DZ_SAK) -+ do_SAK(tty); -+ else -+ flag = TTY_FRAME; -+ } else if (status & DZ_OERR) /* overrun error */ -+ flag = TTY_OVERRUN; -+ else if (status & DZ_PERR) /* parity error */ -+ flag = TTY_PARITY; -+ -+#if defined(CONFIG_SERIAL_DEC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) && \ -+ !defined(MODULE) -+ if (break_pressed && info->line == dz_sercons.index) { -+ if (time_before(jiffies, break_pressed + HZ * 5)) { -+ handle_sysrq(ch, regs, NULL, NULL); -+ break_pressed = 0; -+ continue; - } -- if (tmp & DZ_OERR) { --#ifdef DEBUG_DZ -- debug_console("OERR\n", 5); -+ break_pressed = 0; -+ } - #endif -- if (tty->flip.count < TTY_FLIPBUF_SIZE) { -- tty->flip.count++; -- tty->flip.flag_buf_ptr++; -- tty->flip.char_buf_ptr++; -- *tty->flip.flag_buf_ptr = TTY_OVERRUN; -- } -- } -+ -+ if (info->hook && info->hook->rx_char) { -+ (*info->hook->rx_char)(ch, flag); -+ return; - } -- tty->flip.flag_buf_ptr++; -- tty->flip.char_buf_ptr++; -- tty->flip.count++; -- ignore_char: -- } while (status & DZ_DVAL); - -- if (tty) -- tty_flip_buffer_push(tty); -+ /* keep track of the statistics */ -+ switch (flag) { -+ case TTY_FRAME: -+ icount->frame++; -+ break; -+ case TTY_PARITY: -+ icount->parity++; -+ break; -+ case TTY_OVERRUN: -+ icount->overrun++; -+ break; -+ case TTY_BREAK: -+ icount->brk++; -+ break; -+ default: -+ break; -+ } -+ -+ if ((status & info->ignore_status_mask) == 0) { -+ tty_insert_flip_char(tty, ch, flag); -+ lines_rx[LINE(status)] = 1; -+ } -+ } -+ for (i = 0; i < DZ_NB_PORT; i++) -+ if (lines_rx[i]) -+ tty_flip_buffer_push(lines[i]->tty); - } - - /* -@@ -292,20 +314,34 @@ static inline void receive_chars(struct - * This routine deals with outputs to any lines. - * ------------------------------------------------------------ - */ --static inline void transmit_chars(struct dz_serial *info) -+static inline void transmit_chars(struct dz_serial *info_in) - { -+ struct dz_serial *info; -+ unsigned short status; - unsigned char tmp; - -+ status = dz_in(info_in, DZ_CSR); -+ info = lines[LINE(status)]; - -+ if (info->hook || !info->tty) { -+ unsigned short mask, tmp; - -- if (info->x_char) { /* XON/XOFF chars */ -+ mask = 1 << info->line; -+ tmp = dz_in(info, DZ_TCR); /* read the TX flag */ -+ tmp &= ~mask; /* clear the TX flag */ -+ dz_out(info, DZ_TCR, tmp); -+ return; -+ } -+ -+ if (info->x_char) { /* XON/XOFF chars */ - dz_out(info, DZ_TDR, info->x_char); - info->icount.tx++; - info->x_char = 0; - return; - } - /* if nothing to do or stopped or hardware stopped */ -- if ((info->xmit_cnt <= 0) || info->tty->stopped || info->tty->hw_stopped) { -+ if (info->xmit_cnt <= 0 || -+ info->tty->stopped || info->tty->hw_stopped) { - dz_stop(info->tty); - return; - } -@@ -359,15 +395,14 @@ static inline void check_modem_status(st - */ - static void dz_interrupt(int irq, void *dev, struct pt_regs *regs) - { -- struct dz_serial *info; -+ struct dz_serial *info = (struct dz_serial *)dev; - unsigned short status; - - /* get the reason why we just got an irq */ -- status = dz_in((struct dz_serial *) dev, DZ_CSR); -- info = lines[LINE(status)]; /* re-arrange info the proper port */ -+ status = dz_in(info, DZ_CSR); - - if (status & DZ_RDONE) -- receive_chars(info); /* the receive function */ -+ receive_chars(info, regs); - - if (status & DZ_TRDY) - transmit_chars(info); -@@ -514,7 +549,7 @@ static void shutdown(struct dz_serial *i - - - info->cflags &= ~DZ_CREAD; /* turn off receive enable flag */ -- dz_out(info, DZ_LPR, info->cflags); -+ dz_out(info, DZ_LPR, info->cflags | info->line); - - if (info->xmit_buf) { /* free Tx buffer */ - free_page((unsigned long) info->xmit_buf); -@@ -545,18 +580,21 @@ static void change_speed(struct dz_seria - { - unsigned long flags; - unsigned cflag; -- int baud; -+ int baud, i; - -- if (!info->tty || !info->tty->termios) -- return; -+ if (!info->hook) { -+ if (!info->tty || !info->tty->termios) -+ return; -+ cflag = info->tty->termios->c_cflag; -+ } else { -+ cflag = info->hook->cflags; -+ } - - save_flags(flags); - cli(); - - info->cflags = info->line; - -- cflag = info->tty->termios->c_cflag; -- - switch (cflag & CSIZE) { - case CS5: - info->cflags |= DZ_CS5; -@@ -579,7 +617,16 @@ static void change_speed(struct dz_seria - if (cflag & PARODD) - info->cflags |= DZ_PARODD; - -- baud = tty_get_baud_rate(info->tty); -+ i = cflag & CBAUD; -+ if (i & CBAUDEX) { -+ i &= ~CBAUDEX; -+ if (!info->hook) -+ info->tty->termios->c_cflag &= ~CBAUDEX; -+ else -+ info->hook->cflags &= ~CBAUDEX; -+ } -+ baud = baud_table[i]; -+ - switch (baud) { - case 50: - info->cflags |= DZ_B50; -@@ -629,16 +676,16 @@ static void change_speed(struct dz_seria - } - - info->cflags |= DZ_RXENAB; -- dz_out(info, DZ_LPR, info->cflags); -+ dz_out(info, DZ_LPR, info->cflags | info->line); - - /* setup accept flag */ - info->read_status_mask = DZ_OERR; -- if (I_INPCK(info->tty)) -+ if (info->tty && I_INPCK(info->tty)) - info->read_status_mask |= (DZ_FERR | DZ_PERR); - - /* characters to ignore */ - info->ignore_status_mask = 0; -- if (I_IGNPAR(info->tty)) -+ if (info->tty && I_IGNPAR(info->tty)) - info->ignore_status_mask |= (DZ_FERR | DZ_PERR); - - restore_flags(flags); -@@ -694,7 +741,7 @@ static int dz_write(struct tty_struct *t - - down(&tmp_buf_sem); - while (1) { -- c = MIN(count, MIN(DZ_XMIT_SIZE - info->xmit_cnt - 1, DZ_XMIT_SIZE - info->xmit_head)); -+ c = min(count, min(DZ_XMIT_SIZE - info->xmit_cnt - 1, DZ_XMIT_SIZE - info->xmit_head)); - if (c <= 0) - break; - -@@ -707,7 +754,7 @@ static int dz_write(struct tty_struct *t - save_flags(flags); - cli(); - -- c = MIN(c, MIN(DZ_XMIT_SIZE - info->xmit_cnt - 1, DZ_XMIT_SIZE - info->xmit_head)); -+ c = min(c, min(DZ_XMIT_SIZE - info->xmit_cnt - 1, DZ_XMIT_SIZE - info->xmit_head)); - memcpy(info->xmit_buf + info->xmit_head, tmp_buf, c); - info->xmit_head = ((info->xmit_head + c) & (DZ_XMIT_SIZE - 1)); - info->xmit_cnt += c; -@@ -727,7 +774,7 @@ static int dz_write(struct tty_struct *t - save_flags(flags); - cli(); - -- c = MIN(count, MIN(DZ_XMIT_SIZE - info->xmit_cnt - 1, DZ_XMIT_SIZE - info->xmit_head)); -+ c = min(count, min(DZ_XMIT_SIZE - info->xmit_cnt - 1, DZ_XMIT_SIZE - info->xmit_head)); - if (c <= 0) { - restore_flags(flags); - break; -@@ -845,7 +892,7 @@ static void dz_send_xchar(struct tty_str - - /* - * ------------------------------------------------------------ -- * rs_ioctl () and friends -+ * dz_ioctl () and friends - * ------------------------------------------------------------ - */ - static int get_serial_info(struct dz_serial *info, -@@ -958,6 +1005,9 @@ static int dz_ioctl(struct tty_struct *t - struct dz_serial *info = (struct dz_serial *) tty->driver_data; - int retval; - -+ if (info->hook) -+ return -ENODEV; -+ - if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && - (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGWILD) && - (cmd != TIOCSERSWILD) && (cmd != TIOCSERGSTRUCT)) { -@@ -1252,19 +1302,14 @@ static int dz_open(struct tty_struct *tt - int retval, line; - - line = MINOR(tty->device) - tty->driver.minor_start; -- -- /* The dz lines for the mouse/keyboard must be -- * opened using their respective drivers. -- */ - if ((line < 0) || (line >= DZ_NB_PORT)) - return -ENODEV; -+ info = lines[line]; - -- if ((line == DZ_KEYBOARD) || (line == DZ_MOUSE)) -+ if (info->hook) - return -ENODEV; - -- info = lines[line]; - info->count++; -- - tty->driver_data = info; - info->tty = tty; - -@@ -1285,14 +1330,21 @@ static int dz_open(struct tty_struct *tt - else - *tty->termios = info->callout_termios; - change_speed(info); -- - } -+#ifdef CONFIG_SERIAL_DEC_CONSOLE -+ if (dz_sercons.cflag && dz_sercons.index == line) { -+ tty->termios->c_cflag = dz_sercons.cflag; -+ dz_sercons.cflag = 0; -+ change_speed(info); -+ } -+#endif -+ - info->session = current->session; - info->pgrp = current->pgrp; - return 0; - } - --static void show_serial_version(void) -+static void __init show_serial_version(void) - { - printk("%s%s\n", dz_name, dz_version); - } -@@ -1300,7 +1352,6 @@ static void show_serial_version(void) - int __init dz_init(void) - { - int i; -- long flags; - struct dz_serial *info; - - /* Setup base handler, and timer table. */ -@@ -1311,9 +1362,9 @@ int __init dz_init(void) - memset(&serial_driver, 0, sizeof(struct tty_driver)); - serial_driver.magic = TTY_DRIVER_MAGIC; - #if (LINUX_VERSION_CODE > 0x2032D && defined(CONFIG_DEVFS_FS)) -- serial_driver.name = "ttyS"; --#else - serial_driver.name = "tts/%d"; -+#else -+ serial_driver.name = "ttyS"; - #endif - serial_driver.major = TTY_MAJOR; - serial_driver.minor_start = 64; -@@ -1352,9 +1403,9 @@ int __init dz_init(void) - */ - callout_driver = serial_driver; - #if (LINUX_VERSION_CODE > 0x2032D && defined(CONFIG_DEVFS_FS)) -- callout_driver.name = "cua"; --#else - callout_driver.name = "cua/%d"; -+#else -+ callout_driver.name = "cua"; - #endif - callout_driver.major = TTYAUX_MAJOR; - callout_driver.subtype = SERIAL_TYPE_CALLOUT; -@@ -1363,25 +1414,27 @@ int __init dz_init(void) - panic("Couldn't register serial driver"); - if (tty_register_driver(&callout_driver)) - panic("Couldn't register callout driver"); -- save_flags(flags); -- cli(); - - for (i = 0; i < DZ_NB_PORT; i++) { - info = &multi[i]; - lines[i] = info; -- info->magic = SERIAL_MAGIC; -- -+ info->tty = 0; -+ info->x_char = 0; - if (mips_machtype == MACH_DS23100 || - mips_machtype == MACH_DS5100) - info->port = (unsigned long) KN01_DZ11_BASE; - else - info->port = (unsigned long) KN02_DZ11_BASE; -- - info->line = i; -- info->tty = 0; -+ -+ if (info->hook && info->hook->init_info) { -+ (*info->hook->init_info)(info); -+ continue; -+ } -+ -+ info->magic = SERIAL_MAGIC; - info->close_delay = 50; - info->closing_wait = 3000; -- info->x_char = 0; - info->event = 0; - info->count = 0; - info->blocked_open = 0; -@@ -1393,25 +1446,16 @@ int __init dz_init(void) - info->normal_termios = serial_driver.init_termios; - init_waitqueue_head(&info->open_wait); - init_waitqueue_head(&info->close_wait); -- -- /* -- * If we are pointing to address zero then punt - not correctly -- * set up in setup.c to handle this. -- */ -- if (!info->port) -- return 0; -- -- printk("ttyS%02d at 0x%08x (irq = %d)\n", info->line, -- info->port, dec_interrupt[DEC_IRQ_DZ11]); -- -+ printk("ttyS%02d at 0x%08x (irq = %d) is a DC7085 DZ\n", -+ info->line, info->port, dec_interrupt[DEC_IRQ_DZ11]); - tty_register_devfs(&serial_driver, 0, -- serial_driver.minor_start + info->line); -+ serial_driver.minor_start + info->line); - tty_register_devfs(&callout_driver, 0, -- callout_driver.minor_start + info->line); -+ callout_driver.minor_start + info->line); - } - -- /* reset the chip */ - #ifndef CONFIG_SERIAL_DEC_CONSOLE -+ /* reset the chip */ - dz_out(info, DZ_CSR, DZ_CLR); - while (dz_in(info, DZ_CSR) & DZ_CLR); - iob(); -@@ -1420,43 +1464,104 @@ int __init dz_init(void) - dz_out(info, DZ_CSR, DZ_MSE); - #endif - -- /* order matters here... the trick is that flags -- is updated... in request_irq - to immediatedly obliterate -- it is unwise. */ -- restore_flags(flags); -- -- - if (request_irq(dec_interrupt[DEC_IRQ_DZ11], dz_interrupt, -- SA_INTERRUPT, "DZ", lines[0])) -+ 0, "DZ", lines[0])) - panic("Unable to register DZ interrupt"); - -+ for (i = 0; i < DZ_NB_PORT; i++) -+ if (lines[i]->hook) { -+ startup(lines[i]); -+ if (lines[i]->hook->init_channel) -+ (*lines[i]->hook->init_channel)(lines[i]); -+ } -+ - return 0; - } - --#ifdef CONFIG_SERIAL_DEC_CONSOLE --static void dz_console_put_char(unsigned char ch) -+/* -+ * polling I/O routines -+ */ -+static int dz_poll_tx_char(void *handle, unsigned char ch) - { - unsigned long flags; -- int loops = 2500; -- unsigned short tmp = ch; -- /* this code sends stuff out to serial device - spinning its -- wheels and waiting. */ -+ struct dz_serial *info = handle; -+ unsigned short csr, tcr, trdy, mask; -+ int loops = 10000; -+ int ret; - -- /* force the issue - point it at lines[3] */ -- dz_console = &multi[CONSOLE_LINE]; -+ local_irq_save(flags); -+ csr = dz_in(info, DZ_CSR); -+ dz_out(info, DZ_CSR, csr & ~DZ_TIE); -+ tcr = dz_in(info, DZ_TCR); -+ tcr |= 1 << info->line; -+ mask = tcr; -+ dz_out(info, DZ_TCR, mask); -+ iob(); -+ local_irq_restore(flags); - -- save_flags(flags); -- cli(); -+ while (loops--) { -+ trdy = dz_in(info, DZ_CSR); -+ if (!(trdy & DZ_TRDY)) -+ continue; -+ trdy = (trdy & DZ_TLINE) >> 8; -+ if (trdy == info->line) -+ break; -+ mask &= ~(1 << trdy); -+ dz_out(info, DZ_TCR, mask); -+ iob(); -+ udelay(2); -+ } - -+ if (loops) { -+ dz_out(info, DZ_TDR, ch); -+ ret = 0; -+ } else -+ ret = -EAGAIN; - -- /* spin our wheels */ -- while (((dz_in(dz_console, DZ_CSR) & DZ_TRDY) != DZ_TRDY) && loops--); -+ dz_out(info, DZ_TCR, tcr); -+ dz_out(info, DZ_CSR, csr); - -- /* Actually transmit the character. */ -- dz_out(dz_console, DZ_TDR, tmp); -+ return ret; -+} - -- restore_flags(flags); -+static int dz_poll_rx_char(void *handle) -+{ -+ return -ENODEV; -+} -+ -+int register_dz_hook(unsigned int channel, struct dec_serial_hook *hook) -+{ -+ struct dz_serial *info = multi + channel; -+ -+ if (info->hook) { -+ printk("%s: line %d has already a hook registered\n", -+ __FUNCTION__, channel); -+ -+ return 0; -+ } else { -+ hook->poll_rx_char = dz_poll_rx_char; -+ hook->poll_tx_char = dz_poll_tx_char; -+ info->hook = hook; -+ -+ return 1; -+ } -+} -+ -+int unregister_dz_hook(unsigned int channel) -+{ -+ struct dz_serial *info = &multi[channel]; -+ -+ if (info->hook) { -+ info->hook = NULL; -+ return 1; -+ } else { -+ printk("%s: trying to unregister hook on line %d," -+ " but none is registered\n", __FUNCTION__, channel); -+ return 0; -+ } - } -+ -+#ifdef CONFIG_SERIAL_DEC_CONSOLE - /* - * ------------------------------------------------------------------- - * dz_console_print () -@@ -1465,17 +1570,19 @@ static void dz_console_put_char(unsigned - * The console must be locked when we get here. - * ------------------------------------------------------------------- - */ --static void dz_console_print(struct console *cons, -+static void dz_console_print(struct console *co, - const char *str, - unsigned int count) - { -+ struct dz_serial *info = multi + co->index; -+ - #ifdef DEBUG_DZ - prom_printf((char *) str); - #endif - while (count--) { - if (*str == '\n') -- dz_console_put_char('\r'); -- dz_console_put_char(*str++); -+ dz_poll_tx_char(info, '\r'); -+ dz_poll_tx_char(info, *str++); - } - } - -@@ -1486,12 +1593,12 @@ static kdev_t dz_console_device(struct c - - static int __init dz_console_setup(struct console *co, char *options) - { -+ struct dz_serial *info = multi + co->index; - int baud = 9600; - int bits = 8; - int parity = 'n'; - int cflag = CREAD | HUPCL | CLOCAL; - char *s; -- unsigned short mask, tmp; - - if (options) { - baud = simple_strtoul(options, NULL, 10); -@@ -1542,44 +1649,31 @@ static int __init dz_console_setup(struc - } - co->cflag = cflag; - -- /* TOFIX: force to console line */ -- dz_console = &multi[CONSOLE_LINE]; - if ((mips_machtype == MACH_DS23100) || (mips_machtype == MACH_DS5100)) -- dz_console->port = KN01_DZ11_BASE; -+ info->port = KN01_DZ11_BASE; - else -- dz_console->port = KN02_DZ11_BASE; -- dz_console->line = CONSOLE_LINE; -+ info->port = KN02_DZ11_BASE; -+ info->line = co->index; - -- dz_out(dz_console, DZ_CSR, DZ_CLR); -- while ((tmp = dz_in(dz_console, DZ_CSR)) & DZ_CLR); -+ dz_out(info, DZ_CSR, DZ_CLR); -+ while (dz_in(info, DZ_CSR) & DZ_CLR); - - /* enable scanning */ -- dz_out(dz_console, DZ_CSR, DZ_MSE); -+ dz_out(info, DZ_CSR, DZ_MSE); - - /* Set up flags... */ -- dz_console->cflags = 0; -- dz_console->cflags |= DZ_B9600; -- dz_console->cflags |= DZ_CS8; -- dz_console->cflags |= DZ_PARENB; -- dz_out(dz_console, DZ_LPR, dz_console->cflags); -- -- mask = 1 << dz_console->line; -- tmp = dz_in(dz_console, DZ_TCR); /* read the TX flag */ -- if (!(tmp & mask)) { -- tmp |= mask; /* set the TX flag */ -- dz_out(dz_console, DZ_TCR, tmp); -- } -+ dz_out(info, DZ_LPR, cflag | info->line); -+ - return 0; - } - --static struct console dz_sercons = --{ -- .name = "ttyS", -- .write = dz_console_print, -- .device = dz_console_device, -- .setup = dz_console_setup, -- .flags = CON_CONSDEV | CON_PRINTBUFFER, -- .index = CONSOLE_LINE, -+static struct console dz_sercons = { -+ .name = "ttyS", -+ .write = dz_console_print, -+ .device = dz_console_device, -+ .setup = dz_console_setup, -+ .flags = CON_PRINTBUFFER, -+ .index = -1, - }; - - void __init dz_serial_console_init(void) ---- a/drivers/char/dz.h -+++ b/drivers/char/dz.h -@@ -10,6 +10,8 @@ - #ifndef DZ_SERIAL_H - #define DZ_SERIAL_H - -+#include <asm/dec/serial.h> -+ - #define SERIAL_MAGIC 0x5301 - - /* -@@ -17,6 +19,7 @@ - */ - #define DZ_TRDY 0x8000 /* Transmitter empty */ - #define DZ_TIE 0x4000 /* Transmitter Interrupt Enable */ -+#define DZ_TLINE 0x0300 /* Transmitter Line Number */ - #define DZ_RDONE 0x0080 /* Receiver data ready */ - #define DZ_RIE 0x0040 /* Receive Interrupt Enable */ - #define DZ_MSE 0x0020 /* Master Scan Enable */ -@@ -37,19 +40,30 @@ - #define UCHAR(x) (unsigned char)(x & DZ_RBUF_MASK) - - /* -- * Definitions for the Transmit Register. -+ * Definitions for the Transmit Control Register. - */ - #define DZ_LINE_KEYBOARD 0x0001 - #define DZ_LINE_MOUSE 0x0002 - #define DZ_LINE_MODEM 0x0004 - #define DZ_LINE_PRINTER 0x0008 - -+#define DZ_MODEM_RTS 0x0800 /* RTS for the modem line (2) */ - #define DZ_MODEM_DTR 0x0400 /* DTR for the modem line (2) */ -+#define DZ_PRINT_RTS 0x0200 /* RTS for the printer line (3) */ -+#define DZ_PRINT_DTR 0x0100 /* DTR for the printer line (3) */ -+#define DZ_LNENB 0x000f /* Transmitter Line Enable */ - - /* - * Definitions for the Modem Status Register. - */ -+#define DZ_MODEM_RI 0x0800 /* RI for the modem line (2) */ -+#define DZ_MODEM_CD 0x0400 /* CD for the modem line (2) */ - #define DZ_MODEM_DSR 0x0200 /* DSR for the modem line (2) */ -+#define DZ_MODEM_CTS 0x0100 /* CTS for the modem line (2) */ -+#define DZ_PRINT_RI 0x0008 /* RI for the printer line (2) */ -+#define DZ_PRINT_CD 0x0004 /* CD for the printer line (2) */ -+#define DZ_PRINT_DSR 0x0002 /* DSR for the printer line (2) */ -+#define DZ_PRINT_CTS 0x0001 /* CTS for the printer line (2) */ - - /* - * Definitions for the Transmit Data Register. -@@ -115,9 +129,6 @@ - - #define DZ_EVENT_WRITE_WAKEUP 0 - --#ifndef MIN --#define MIN(a,b) ((a) < (b) ? (a) : (b)) -- - #define DZ_INITIALIZED 0x80000000 /* Serial port was initialized */ - #define DZ_CALLOUT_ACTIVE 0x40000000 /* Call out device is active */ - #define DZ_NORMAL_ACTIVE 0x20000000 /* Normal device is active */ -@@ -129,6 +140,7 @@ - #define DZ_CLOSING_WAIT_INF 0 - #define DZ_CLOSING_WAIT_NONE 65535 - -+#define DZ_SAK 0x0004 /* Secure Attention Key (Orange book) */ - #define DZ_SPLIT_TERMIOS 0x0008 /* Separate termios for dialin/callout */ - #define DZ_SESSION_LOCKOUT 0x0100 /* Lock out cua opens based on session */ - #define DZ_PGRP_LOCKOUT 0x0200 /* Lock out cua opens based on pgrp */ -@@ -166,79 +178,9 @@ struct dz_serial { - long session; /* Session of opening process */ - long pgrp; /* pgrp of opening process */ - -+ struct dec_serial_hook *hook; /* Hook on this channel. */ - unsigned char is_console; /* flag indicating a serial console */ - unsigned char is_initialized; - }; - --static struct dz_serial multi[DZ_NB_PORT]; /* Four serial lines in the DZ chip */ --static struct dz_serial *dz_console; --static struct tty_driver serial_driver, callout_driver; -- --static struct tty_struct *serial_table[DZ_NB_PORT]; --static struct termios *serial_termios[DZ_NB_PORT]; --static struct termios *serial_termios_locked[DZ_NB_PORT]; -- --static int serial_refcount; -- --/* -- * tmp_buf is used as a temporary buffer by serial_write. We need to -- * lock it in case the copy_from_user blocks while swapping in a page, -- * and some other program tries to do a serial write at the same time. -- * Since the lock will only come under contention when the system is -- * swapping and available memory is low, it makes sense to share one -- * buffer across all the serial ports, since it significantly saves -- * memory if large numbers of serial ports are open. -- */ --static unsigned char *tmp_buf; --static DECLARE_MUTEX(tmp_buf_sem); -- --static char *dz_name = "DECstation DZ serial driver version "; --static char *dz_version = "1.02"; -- --static inline unsigned short dz_in (struct dz_serial *, unsigned); --static inline void dz_out (struct dz_serial *, unsigned, unsigned short); -- --static inline void dz_sched_event (struct dz_serial *, int); --static inline void receive_chars (struct dz_serial *); --static inline void transmit_chars (struct dz_serial *); --static inline void check_modem_status (struct dz_serial *); -- --static void dz_stop (struct tty_struct *); --static void dz_start (struct tty_struct *); --static void dz_interrupt (int, void *, struct pt_regs *); --static void do_serial_bh (void); --static void do_softint (void *); --static void do_serial_hangup (void *); --static void change_speed (struct dz_serial *); --static void dz_flush_chars (struct tty_struct *); --static void dz_console_print (struct console *, const char *, unsigned int); --static void dz_flush_buffer (struct tty_struct *); --static void dz_throttle (struct tty_struct *); --static void dz_unthrottle (struct tty_struct *); --static void dz_send_xchar (struct tty_struct *, char); --static void shutdown (struct dz_serial *); --static void send_break (struct dz_serial *, int); --static void dz_set_termios (struct tty_struct *, struct termios *); --static void dz_close (struct tty_struct *, struct file *); --static void dz_hangup (struct tty_struct *); --static void show_serial_version (void); -- --static int dz_write (struct tty_struct *, int, const unsigned char *, int); --static int dz_write_room (struct tty_struct *); --static int dz_chars_in_buffer (struct tty_struct *); --static int startup (struct dz_serial *); --static int get_serial_info (struct dz_serial *, struct serial_struct *); --static int set_serial_info (struct dz_serial *, struct serial_struct *); --static int get_lsr_info (struct dz_serial *, unsigned int *); --static int dz_ioctl (struct tty_struct *, struct file *, unsigned int, unsigned long); --static int block_til_ready (struct tty_struct *, struct file *, struct dz_serial *); --static int dz_open (struct tty_struct *, struct file *); -- --#ifdef MODULE --int init_module (void) --void cleanup_module (void) --#endif -- --#endif -- - #endif /* DZ_SERIAL_H */ ---- /dev/null -+++ b/drivers/char/ibm_workpad_keymap.map -@@ -0,0 +1,343 @@ -+# Keymap for IBM Workpad z50 -+# US Mapping -+# -+# by Michael Klar <wyldfier@iname.com> -+# -+# This is a great big mess on account of how the Caps Lock key is handled as -+# LeftShift-RightShift. Right shift key had to be broken out, so don't use -+# use this map file as a basis for other keyboards that don't do the same -+# thing with Caps Lock. -+# -+# 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. -+ -+keymaps 0-2,4-5,8,12,32-33,36-37 -+strings as usual -+ -+keycode 0 = F1 F11 Console_13 -+ shiftr keycode 0 = F11 -+ shift shiftr keycode 0 = F11 -+ control keycode 0 = F1 -+ alt keycode 0 = Console_1 -+ control alt keycode 0 = Console_1 -+keycode 1 = F3 F13 Console_15 -+ shiftr keycode 1 = F13 -+ shift shiftr keycode 1 = F13 -+ control keycode 1 = F3 -+ alt keycode 1 = Console_3 -+ control alt keycode 1 = Console_3 -+keycode 2 = F5 F15 Console_17 -+ shiftr keycode 2 = F15 -+ shift shiftr keycode 2 = F15 -+ control keycode 2 = F5 -+ alt keycode 2 = Console_5 -+ control alt keycode 2 = Console_5 -+keycode 3 = F7 F17 Console_19 -+ shiftr keycode 3 = F17 -+ shift shiftr keycode 3 = F17 -+ control keycode 3 = F7 -+ alt keycode 3 = Console_7 -+ control alt keycode 3 = Console_7 -+keycode 4 = F9 F19 Console_21 -+ shiftr keycode 4 = F19 -+ shift shiftr keycode 4 = F19 -+ control keycode 4 = F9 -+ alt keycode 4 = Console_9 -+ control alt keycode 4 = Console_9 -+#keycode 5 is contrast down -+#keycode 6 is contrast up -+keycode 7 = F11 F11 Console_23 -+ shiftr keycode 7 = F11 -+ shift shiftr keycode 7 = F11 -+ control keycode 7 = F11 -+ alt keycode 7 = Console_11 -+ control alt keycode 7 = Console_11 -+keycode 8 = F2 F12 Console_14 -+ shiftr keycode 8 = F12 -+ shift shiftr keycode 8 = F12 -+ control keycode 8 = F2 -+ alt keycode 8 = Console_2 -+ control alt keycode 8 = Console_2 -+keycode 9 = F4 F14 Console_16 -+ shiftr keycode 9 = F14 -+ shift shiftr keycode 9 = F14 -+ control keycode 9 = F4 -+ alt keycode 9 = Console_4 -+ control alt keycode 9 = Console_4 -+keycode 10 = F6 F16 Console_18 -+ shiftr keycode 10 = F16 -+ shift shiftr keycode 10 = F16 -+ control keycode 10 = F6 -+ alt keycode 10 = Console_6 -+ control alt keycode 10 = Console_6 -+keycode 11 = F8 F18 Console_20 -+ shiftr keycode 11 = F18 -+ shift shiftr keycode 11 = F18 -+ control keycode 11 = F8 -+ alt keycode 11 = Console_8 -+ control alt keycode 11 = Console_8 -+keycode 12 = F10 F20 Console_22 -+ shiftr keycode 12 = F20 -+ shift shiftr keycode 12 = F20 -+ control keycode 12 = F10 -+ alt keycode 12 = Console_10 -+ control alt keycode 12 = Console_10 -+#keycode 13 is brightness down -+#keycode 14 is brightness up -+keycode 15 = F12 F12 Console_24 -+ shiftr keycode 15 = F12 -+ shift shiftr keycode 15 = F12 -+ control keycode 15 = F12 -+ alt keycode 15 = Console_12 -+ control alt keycode 15 = Console_12 -+keycode 16 = apostrophe quotedbl -+ shiftr keycode 16 = quotedbl -+ shift shiftr keycode 16 = quotedbl -+ control keycode 16 = Control_g -+ alt keycode 16 = Meta_apostrophe -+keycode 17 = bracketleft braceleft -+ shiftr keycode 17 = braceleft -+ shift shiftr keycode 17 = braceleft -+ control keycode 17 = Escape -+ alt keycode 17 = Meta_bracketleft -+keycode 18 = minus underscore backslash -+ shiftr keycode 18 = underscore -+ shift shiftr keycode 18 = underscore -+ control keycode 18 = Control_underscore -+ shift control keycode 18 = Control_underscore -+ shiftr control keycode 18 = Control_underscore -+ shift shiftr control keycode 18 = Control_underscore -+ alt keycode 18 = Meta_minus -+keycode 19 = zero parenright braceright -+ shiftr keycode 19 = parenright -+ shift shiftr keycode 19 = parenright -+ alt keycode 19 = Meta_zero -+keycode 20 = p -+ shiftr keycode 20 = +P -+ shift shiftr keycode 20 = +p -+keycode 21 = semicolon colon -+ shiftr keycode 21 = colon -+ shift shiftr keycode 21 = colon -+ alt keycode 21 = Meta_semicolon -+keycode 22 = Up Scroll_Backward -+ shiftr keycode 22 = Scroll_Backward -+ shift shiftr keycode 22 = Scroll_Backward -+ alt keycode 22 = Prior -+keycode 23 = slash question -+ shiftr keycode 23 = question -+ shift shiftr keycode 23 = question -+ control keycode 23 = Delete -+ alt keycode 23 = Meta_slash -+ -+keycode 27 = nine parenleft bracketright -+ shiftr keycode 27 = parenleft -+ shift shiftr keycode 27 = parenleft -+ alt keycode 27 = Meta_nine -+keycode 28 = o -+ shiftr keycode 28 = +O -+ shift shiftr keycode 28 = +o -+keycode 29 = l -+ shiftr keycode 29 = +L -+ shift shiftr keycode 29 = +l -+keycode 30 = period greater -+ shiftr keycode 30 = greater -+ shift shiftr keycode 30 = greater -+ control keycode 30 = Compose -+ alt keycode 30 = Meta_period -+ -+keycode 32 = Left Decr_Console -+ shiftr keycode 32 = Decr_Console -+ shift shiftr keycode 32 = Decr_Console -+ alt keycode 32 = Home -+keycode 33 = bracketright braceright asciitilde -+ shiftr keycode 33 = braceright -+ shift shiftr keycode 33 = braceright -+ control keycode 33 = Control_bracketright -+ alt keycode 33 = Meta_bracketright -+keycode 34 = equal plus -+ shiftr keycode 34 = plus -+ shift shiftr keycode 34 = plus -+ alt keycode 34 = Meta_equal -+keycode 35 = eight asterisk bracketleft -+ shiftr keycode 35 = asterisk -+ shift shiftr keycode 35 = asterisk -+ control keycode 35 = Delete -+ alt keycode 35 = Meta_eight -+keycode 36 = i -+ shiftr keycode 36 = +I -+ shift shiftr keycode 36 = +i -+keycode 37 = k -+ shiftr keycode 37 = +K -+ shift shiftr keycode 37 = +k -+keycode 38 = comma less -+ shiftr keycode 38 = less -+ shift shiftr keycode 38 = less -+ alt keycode 38 = Meta_comma -+ -+keycode 40 = h -+ shiftr keycode 40 = +H -+ shift shiftr keycode 40 = +h -+keycode 41 = y -+ shiftr keycode 41 = +Y -+ shift shiftr keycode 41 = +y -+keycode 42 = six asciicircum -+ shiftr keycode 42 = asciicircum -+ shift shiftr keycode 42 = asciicircum -+ control keycode 42 = Control_asciicircum -+ alt keycode 42 = Meta_six -+keycode 43 = seven ampersand braceleft -+ shiftr keycode 43 = ampersand -+ shift shiftr keycode 43 = ampersand -+ control keycode 43 = Control_underscore -+ alt keycode 43 = Meta_seven -+keycode 44 = u -+ shiftr keycode 44 = +U -+ shift shiftr keycode 44 = +u -+keycode 45 = j -+ shiftr keycode 45 = +J -+ shift shiftr keycode 45 = +j -+keycode 46 = m -+ shiftr keycode 46 = +M -+ shift shiftr keycode 46 = +m -+keycode 47 = n -+ shiftr keycode 47 = +N -+ shift shiftr keycode 47 = +n -+ -+# This is the "Backspace" key: -+keycode 49 = Delete Delete -+ shiftr keycode 49 = Delete -+ shift shiftr keycode 49 = Delete -+ control keycode 49 = BackSpace -+ alt keycode 49 = Meta_Delete -+keycode 50 = Num_Lock -+ shift keycode 50 = Bare_Num_Lock -+ shiftr keycode 50 = Bare_Num_Lock -+ shift shiftr keycode 50 = Bare_Num_Lock -+# This is the "Delete" key: -+keycode 51 = Remove -+ control alt keycode 51 = Boot -+ -+keycode 53 = backslash bar -+ shiftr keycode 53 = bar -+ shift shiftr keycode 53 = bar -+ control keycode 53 = Control_backslash -+ alt keycode 53 = Meta_backslash -+keycode 54 = Return -+ alt keycode 54 = Meta_Control_m -+keycode 55 = space space -+ shiftr keycode 55 = space -+ shift shiftr keycode 55 = space -+ control keycode 55 = nul -+ alt keycode 55 = Meta_space -+keycode 56 = g -+ shiftr keycode 56 = +G -+ shift shiftr keycode 56 = +g -+keycode 57 = t -+ shiftr keycode 57 = +T -+ shift shiftr keycode 57 = +t -+keycode 58 = five percent -+ shiftr keycode 58 = percent -+ shift shiftr keycode 58 = percent -+ control keycode 58 = Control_bracketright -+ alt keycode 58 = Meta_five -+keycode 59 = four dollar dollar -+ shiftr keycode 59 = dollar -+ shift shiftr keycode 59 = dollar -+ control keycode 59 = Control_backslash -+ alt keycode 59 = Meta_four -+keycode 60 = r -+ shiftr keycode 60 = +R -+ shift shiftr keycode 60 = +r -+keycode 61 = f -+ shiftr keycode 61 = +F -+ shift shiftr keycode 61 = +f -+ altgr keycode 61 = Hex_F -+keycode 62 = v -+ shiftr keycode 62 = +V -+ shift shiftr keycode 62 = +v -+keycode 63 = b -+ shiftr keycode 63 = +B -+ shift shiftr keycode 63 = +b -+ altgr keycode 63 = Hex_B -+ -+keycode 67 = three numbersign -+ shiftr keycode 67 = numbersign -+ shift shiftr keycode 67 = numbersign -+ control keycode 67 = Escape -+ alt keycode 67 = Meta_three -+keycode 68 = e -+ shiftr keycode 68 = +E -+ shift shiftr keycode 68 = +e -+ altgr keycode 68 = Hex_E -+keycode 69 = d -+ shiftr keycode 69 = +D -+ shift shiftr keycode 69 = +d -+ altgr keycode 69 = Hex_D -+keycode 70 = c -+ shiftr keycode 70 = +C -+ shift shiftr keycode 70 = +c -+ altgr keycode 70 = Hex_C -+keycode 71 = Right Incr_Console -+ shiftr keycode 71 = Incr_Console -+ shift shiftr keycode 71 = Incr_Console -+ alt keycode 71 = End -+ -+keycode 75 = two at at -+ shiftr keycode 75 = at -+ shift shiftr keycode 75 = at -+ control keycode 75 = nul -+ shift control keycode 75 = nul -+ shiftr control keycode 75 = nul -+ shift shiftr control keycode 75 = nul -+ alt keycode 75 = Meta_two -+keycode 76 = w -+ shiftr keycode 76 = +W -+ shift shiftr keycode 76 = +w -+keycode 77 = s -+ shiftr keycode 77 = +S -+ shift shiftr keycode 77 = +s -+keycode 78 = x -+ shiftr keycode 78 = +X -+ shift shiftr keycode 78 = +x -+keycode 79 = Down Scroll_Forward -+ shiftr keycode 79 = Scroll_Forward -+ shift shiftr keycode 79 = Scroll_Forward -+ alt keycode 79 = Next -+keycode 80 = Escape Escape -+ shiftr keycode 80 = Escape -+ shift shiftr keycode 80 = Escape -+ alt keycode 80 = Meta_Escape -+keycode 81 = Tab Tab -+ shiftr keycode 81 = Tab -+ shift shiftr keycode 81 = Tab -+ alt keycode 81 = Meta_Tab -+keycode 82 = grave asciitilde -+ shiftr keycode 82 = asciitilde -+ shift shiftr keycode 82 = asciitilde -+ control keycode 82 = nul -+ alt keycode 82 = Meta_grave -+keycode 83 = one exclam -+ shiftr keycode 83 = exclam -+ shift shiftr keycode 83 = exclam -+ alt keycode 83 = Meta_one -+keycode 84 = q -+ shiftr keycode 84 = +Q -+ shift shiftr keycode 84 = +q -+keycode 85 = a -+ shiftr keycode 85 = +A -+ shift shiftr keycode 85 = +a -+ altgr keycode 85 = Hex_A -+keycode 86 = z -+ shiftr keycode 86 = +Z -+ shift shiftr keycode 86 = +z -+ -+# This is the windows key: -+keycode 88 = Decr_Console -+keycode 89 = Shift -+keycode 90 = Control -+keycode 91 = Control -+keycode 92 = Alt -+keycode 93 = AltGr -+keycode 94 = ShiftR -+ shift keycode 94 = Caps_Lock ---- a/drivers/char/indydog.c -+++ b/drivers/char/indydog.c -@@ -1,5 +1,5 @@ - /* -- * IndyDog 0.2 A Hardware Watchdog Device for SGI IP22 -+ * IndyDog 0.3 A Hardware Watchdog Device for SGI IP22 - * - * (c) Copyright 2002 Guido Guenther <agx@sigxcpu.org>, All Rights Reserved. - * -@@ -7,10 +7,10 @@ - * 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. -- * -+ * - * based on softdog.c by Alan Cox <alan@redhat.com> - */ -- -+ - #include <linux/module.h> - #include <linux/config.h> - #include <linux/types.h> -@@ -19,13 +19,12 @@ - #include <linux/mm.h> - #include <linux/miscdevice.h> - #include <linux/watchdog.h> --#include <linux/smp_lock.h> - #include <linux/init.h> - #include <asm/uaccess.h> - #include <asm/sgi/mc.h> - --static unsigned long indydog_alive; --static int expect_close = 0; -+#define PFX "indydog: " -+static int indydog_alive; - - #ifdef CONFIG_WATCHDOG_NOWAYOUT - static int nowayout = 1; -@@ -33,10 +32,30 @@ static int nowayout = 1; - static int nowayout = 0; - #endif - -+#define WATCHDOG_TIMEOUT 30 /* 30 sec default timeout */ -+ - MODULE_PARM(nowayout,"i"); - MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); - --static inline void indydog_ping(void) -+static void indydog_start(void) -+{ -+ u32 mc_ctrl0 = sgimc->cpuctrl0; -+ -+ mc_ctrl0 = sgimc->cpuctrl0 | SGIMC_CCTRL0_WDOG; -+ sgimc->cpuctrl0 = mc_ctrl0; -+} -+ -+static void indydog_stop(void) -+{ -+ u32 mc_ctrl0 = sgimc->cpuctrl0; -+ -+ mc_ctrl0 &= ~SGIMC_CCTRL0_WDOG; -+ sgimc->cpuctrl0 = mc_ctrl0; -+ -+ printk(KERN_INFO PFX "Stopped watchdog timer.\n"); -+} -+ -+static void indydog_ping(void) - { - sgimc->watchdogt = 0; - } -@@ -46,18 +65,14 @@ static inline void indydog_ping(void) - */ - static int indydog_open(struct inode *inode, struct file *file) - { -- u32 mc_ctrl0; -- -- if (test_and_set_bit(0,&indydog_alive)) -+ if (indydog_alive) - return -EBUSY; - -- if (nowayout) { -+ if (nowayout) - MOD_INC_USE_COUNT; -- } - - /* Activate timer */ -- mc_ctrl0 = sgimc->cpuctrl0 | SGIMC_CCTRL0_WDOG; -- sgimc->cpuctrl0 = mc_ctrl0; -+ indydog_start(); - indydog_ping(); - - indydog_alive = 1; -@@ -69,63 +84,48 @@ static int indydog_open(struct inode *in - static int indydog_release(struct inode *inode, struct file *file) - { - /* Shut off the timer. -- * Lock it in if it's a module and we set nowayout. */ -- lock_kernel(); -- if (expect_close) { -- u32 mc_ctrl0 = sgimc->cpuctrl0; -+ * Lock it in if it's a module and we defined ...NOWAYOUT */ -+ if (!nowayout) { -+ u32 mc_ctrl0 = sgimc->cpuctrl0; - mc_ctrl0 &= ~SGIMC_CCTRL0_WDOG; - sgimc->cpuctrl0 = mc_ctrl0; - printk(KERN_INFO "Stopped watchdog timer.\n"); -- } else -- printk(KERN_CRIT "WDT device closed unexpectedly. WDT will not stop!\n"); -- clear_bit(0, &indydog_alive); -- unlock_kernel(); -+ } -+ indydog_alive = 0; - - return 0; - } - - static ssize_t indydog_write(struct file *file, const char *data, size_t len, loff_t *ppos) - { -- /* Can't seek (pwrite) on this device */ -+ /* Can't seek (pwrite) on this device */ - if (ppos != &file->f_pos) - return -ESPIPE; - -- /* -- * Refresh the timer. -- */ -+ /* Refresh the timer. */ - if (len) { -- if (!nowayout) { -- size_t i; -- -- /* In case it was set long ago */ -- expect_close = 0; -- -- for (i = 0; i != len; i++) { -- char c; -- if (get_user(c, data + i)) -- return -EFAULT; -- if (c == 'V') -- expect_close = 1; -- } -- } - indydog_ping(); -- return 1; - } -- return 0; -+ return len; - } - - static int indydog_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg) - { -+ int options, retval = -EINVAL; - static struct watchdog_info ident = { -- options: WDIOF_MAGICCLOSE, -- identity: "Hardware Watchdog for SGI IP22", -+ .options = WDIOF_KEEPALIVEPING | -+ WDIOF_MAGICCLOSE, -+ .firmware_version = 0, -+ .identity = "Hardware Watchdog for SGI IP22", - }; -+ - switch (cmd) { - default: - return -ENOIOCTLCMD; - case WDIOC_GETSUPPORT: -- if(copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident))) -+ if (copy_to_user((struct watchdog_info *)arg, -+ &ident, sizeof(ident))) - return -EFAULT; - return 0; - case WDIOC_GETSTATUS: -@@ -134,31 +134,53 @@ static int indydog_ioctl(struct inode *i - case WDIOC_KEEPALIVE: - indydog_ping(); - return 0; -+ case WDIOC_GETTIMEOUT: -+ return put_user(WATCHDOG_TIMEOUT,(int *)arg); -+ case WDIOC_SETOPTIONS: -+ { -+ if (get_user(options, (int *)arg)) -+ return -EFAULT; -+ -+ if (options & WDIOS_DISABLECARD) { -+ indydog_stop(); -+ retval = 0; -+ } -+ -+ if (options & WDIOS_ENABLECARD) { -+ indydog_start(); -+ retval = 0; -+ } -+ -+ return retval; -+ } - } - } - - static struct file_operations indydog_fops = { -- owner: THIS_MODULE, -- write: indydog_write, -- ioctl: indydog_ioctl, -- open: indydog_open, -- release: indydog_release, -+ .owner = THIS_MODULE, -+ .write = indydog_write, -+ .ioctl = indydog_ioctl, -+ .open = indydog_open, -+ .release = indydog_release, - }; - - static struct miscdevice indydog_miscdev = { -- minor: WATCHDOG_MINOR, -- name: "watchdog", -- fops: &indydog_fops, -+ .minor = WATCHDOG_MINOR, -+ .name = "watchdog", -+ .fops = &indydog_fops, - }; - --static const char banner[] __initdata = KERN_INFO "Hardware Watchdog Timer for SGI IP22: 0.2\n"; -+static char banner[] __initdata = -+ KERN_INFO PFX "Hardware Watchdog Timer for SGI IP22: 0.3\n"; - - static int __init watchdog_init(void) - { - int ret = misc_register(&indydog_miscdev); -- -- if (ret) -+ if (ret) { -+ printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", -+ WATCHDOG_MINOR, ret); - return ret; -+ } - - printk(banner); - -@@ -172,4 +194,7 @@ static void __exit watchdog_exit(void) - - module_init(watchdog_init); - module_exit(watchdog_exit); -+ -+MODULE_AUTHOR("Guido Guenther <agx@sigxcpu.org>"); -+MODULE_DESCRIPTION("Hardware Watchdog Device for SGI IP22"); - MODULE_LICENSE("GPL"); ---- a/drivers/char/ip27-rtc.c -+++ b/drivers/char/ip27-rtc.c -@@ -44,6 +44,7 @@ - #include <asm/sn/klconfig.h> - #include <asm/sn/sn0/ip27.h> - #include <asm/sn/sn0/hub.h> -+#include <asm/sn/sn_private.h> - - static int rtc_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg); -@@ -209,11 +210,8 @@ static struct miscdevice rtc_dev= - - static int __init rtc_init(void) - { -- nasid_t nid; -- -- nid = get_nasid(); - rtc = (struct m48t35_rtc *) -- (KL_CONFIG_CH_CONS_INFO(nid)->memory_base + IOC3_BYTEBUS_DEV0); -+ (KL_CONFIG_CH_CONS_INFO(master_nasid)->memory_base + IOC3_BYTEBUS_DEV0); - - printk(KERN_INFO "Real Time Clock Driver v%s\n", RTC_VERSION); - if (misc_register(&rtc_dev)) { -@@ -325,3 +323,7 @@ static void get_rtc_time(struct rtc_time - - rtc_tm->tm_mon--; - } -+ -+MODULE_AUTHOR("Ralf Baechle <ralf@linux-mips.org>"); -+MODULE_DESCRIPTION("SGI IP27 M48T35 RTC driver"); -+MODULE_LICENSE("GPL"); ---- a/drivers/char/Makefile -+++ b/drivers/char/Makefile -@@ -48,7 +48,12 @@ ifeq ($(ARCH),mips) - KEYBD = - endif - ifeq ($(CONFIG_VR41XX_KIU),y) -- KEYMAP = -+ ifeq ($(CONFIG_IBM_WORKPAD),y) -+ KEYMAP = ibm_workpad_keymap.o -+ endif -+ ifeq ($(CONFIG_VICTOR_MPC30X),y) -+ KEYMAP = victor_mpc30x_keymap.o -+ endif - KEYBD = vr41xx_keyb.o - endif - endif -@@ -251,7 +256,6 @@ obj-$(CONFIG_MK712_MOUSE) += mk712.o - obj-$(CONFIG_RTC) += rtc.o - obj-$(CONFIG_GEN_RTC) += genrtc.o - obj-$(CONFIG_EFI_RTC) += efirtc.o --obj-$(CONFIG_SGI_DS1286) += ds1286.o - obj-$(CONFIG_MIPS_RTC) += mips_rtc.o - obj-$(CONFIG_SGI_IP27_RTC) += ip27-rtc.o - ifeq ($(CONFIG_PPC),) -@@ -259,6 +263,7 @@ ifeq ($(CONFIG_PPC),) - endif - obj-$(CONFIG_TOSHIBA) += toshiba.o - obj-$(CONFIG_I8K) += i8k.o -+obj-$(CONFIG_DS1286) += ds1286.o - obj-$(CONFIG_DS1620) += ds1620.o - obj-$(CONFIG_DS1742) += ds1742.o - obj-$(CONFIG_INTEL_RNG) += i810_rng.o -@@ -270,6 +275,7 @@ obj-$(CONFIG_BRIQ_PANEL) += briq_panel.o - - obj-$(CONFIG_ITE_GPIO) += ite_gpio.o - obj-$(CONFIG_AU1X00_GPIO) += au1000_gpio.o -+obj-$(CONFIG_AU1550_PSC_SPI) += au1550_psc_spi.o - obj-$(CONFIG_AU1X00_USB_TTY) += au1000_usbtty.o - obj-$(CONFIG_AU1X00_USB_RAW) += au1000_usbraw.o - obj-$(CONFIG_COBALT_LCD) += lcd.o -@@ -357,3 +363,9 @@ defkeymap.c: defkeymap.map - - qtronixmap.c: qtronixmap.map - set -e ; loadkeys --mktable $< | sed -e 's/^static *//' > $@ -+ -+ibm_workpad_keymap.c: ibm_workpad_keymap.map -+ set -e ; loadkeys --mktable $< | sed -e 's/^static *//' > $@ -+ -+victor_mpc30x_keymap.c: victor_mpc30x_keymap.map -+ set -e ; loadkeys --mktable $< | sed -e 's/^static *//' > $@ ---- a/drivers/char/mips_rtc.c -+++ b/drivers/char/mips_rtc.c -@@ -53,14 +53,6 @@ - #include <asm/io.h> - #include <asm/uaccess.h> - #include <asm/system.h> -- --/* -- * Check machine -- */ --#if !defined(CONFIG_MIPS) || !defined(CONFIG_NEW_TIME_C) --#error "This driver is for MIPS machines with CONFIG_NEW_TIME_C defined" --#endif -- - #include <asm/time.h> - - static unsigned long rtc_status = 0; /* bitmapped status byte. */ ---- a/drivers/char/sb1250_duart.c -+++ b/drivers/char/sb1250_duart.c -@@ -328,10 +328,11 @@ static int duart_write(struct tty_struct - if (c <= 0) break; - - if (from_user) { -+ spin_unlock_irqrestore(&us->outp_lock, flags); - if (copy_from_user(us->outp_buf + us->outp_tail, buf, c)) { -- spin_unlock_irqrestore(&us->outp_lock, flags); - return -EFAULT; - } -+ spin_lock_irqsave(&us->outp_lock, flags); - } else { - memcpy(us->outp_buf + us->outp_tail, buf, c); - } -@@ -498,9 +499,31 @@ static void duart_set_termios(struct tty - duart_set_cflag(us->line, tty->termios->c_cflag); - } - -+static int get_serial_info(uart_state_t *us, struct serial_struct * retinfo) { -+ -+ struct serial_struct tmp; -+ -+ memset(&tmp, 0, sizeof(tmp)); -+ -+ tmp.type=PORT_SB1250; -+ tmp.line=us->line; -+ tmp.port=A_DUART_CHANREG(tmp.line,0); -+ tmp.irq=K_INT_UART_0 + tmp.line; -+ tmp.xmit_fifo_size=16; /* fixed by hw */ -+ tmp.baud_base=5000000; -+ tmp.io_type=SERIAL_IO_MEM; -+ -+ if (copy_to_user(retinfo,&tmp,sizeof(*retinfo))) -+ return -EFAULT; -+ -+ return 0; -+} -+ - static int duart_ioctl(struct tty_struct *tty, struct file * file, - unsigned int cmd, unsigned long arg) - { -+ uart_state_t *us = (uart_state_t *) tty->driver_data; -+ - /* if (serial_paranoia_check(info, tty->device, "rs_ioctl")) - return -ENODEV;*/ - switch (cmd) { -@@ -517,7 +540,7 @@ static int duart_ioctl(struct tty_struct - printk("Ignoring TIOCMSET\n"); - break; - case TIOCGSERIAL: -- printk("Ignoring TIOCGSERIAL\n"); -+ return get_serial_info(us,(struct serial_struct *) arg); - break; - case TIOCSSERIAL: - printk("Ignoring TIOCSSERIAL\n"); ---- a/drivers/char/serial.c -+++ b/drivers/char/serial.c -@@ -62,6 +62,12 @@ - * Robert Schwebel <robert@schwebel.de>, - * Juergen Beisert <jbeisert@eurodsn.de>, - * Theodore Ts'o <tytso@mit.edu> -+ * -+ * 10/00: Added suport for MIPS Atlas board. -+ * 11/00: Hooks for serial kernel debug port support added. -+ * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, -+ * carstenl@mips.com -+ * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved. - */ - - static char *serial_version = "5.05c"; -@@ -413,6 +419,22 @@ static inline int serial_paranoia_check( - return 0; - } - -+#if defined(CONFIG_MIPS_ATLAS) || defined(CONFIG_MIPS_SEAD) -+ -+#include <asm/mips-boards/atlas.h> -+ -+static _INLINE_ unsigned int serial_in(struct async_struct *info, int offset) -+{ -+ return (*(volatile unsigned int *)(mips_io_port_base + ATLAS_UART_REGS_BASE + offset*8) & 0xff); -+} -+ -+static _INLINE_ void serial_out(struct async_struct *info, int offset, int value) -+{ -+ *(volatile unsigned int *)(mips_io_port_base + ATLAS_UART_REGS_BASE + offset*8) = value; -+} -+ -+#else -+ - static _INLINE_ unsigned int serial_in(struct async_struct *info, int offset) - { - switch (info->io_type) { -@@ -447,6 +469,8 @@ static _INLINE_ void serial_out(struct a - outb(value, info->port+offset); - } - } -+#endif -+ - - /* - * We used to support using pause I/O for certain machines. We ---- /dev/null -+++ b/drivers/char/victor_mpc30x_keymap.map -@@ -0,0 +1,102 @@ -+# Victor Interlink MP-C303/304 keyboard keymap -+# -+# Copyright (C) 2003 Yoichi Yuasa <yuasa@hh.iij4u.or.jp> -+# -+# 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. -+keymaps 0-1,4-5,8-9,12 -+alt_is_meta -+strings as usual -+compose as usual for "iso-8859-1" -+ -+# First line -+keycode 89 = Escape -+keycode 9 = Delete -+ -+# 2nd line -+keycode 73 = one exclam -+keycode 18 = two quotedbl -+keycode 92 = three numbersign -+ control keycode 92 = Escape -+keycode 53 = four dollar -+ control keycode 53 = Control_backslash -+keycode 21 = five percent -+ control keycode 21 = Control_bracketright -+keycode 50 = six ampersand -+ control keycode 50 = Control_underscore -+keycode 48 = seven apostrophe -+keycode 51 = eight parenleft -+keycode 16 = nine parenright -+keycode 80 = zero asciitilde -+ control keycode 80 = nul -+keycode 49 = minus equal -+keycode 30 = asciicircum asciitilde -+ control keycode 30 = Control_asciicircum -+keycode 5 = backslash bar -+ control keycode 5 = Control_backslash -+keycode 13 = BackSpace -+# 3rd line -+keycode 57 = Tab -+keycode 74 = q -+keycode 26 = w -+keycode 81 = e -+keycode 29 = r -+keycode 37 = t -+keycode 45 = y -+keycode 72 = u -+keycode 24 = i -+keycode 32 = o -+keycode 41 = p -+keycode 1 = at grave -+ control keycode 1 = nul -+keycode 54 = bracketleft braceleft -+keycode 63 = Return -+ alt keycode 63 = Meta_Control_m -+# 4th line -+keycode 23 = Caps_Lock -+keycode 34 = a -+keycode 66 = s -+keycode 52 = d -+keycode 20 = f -+keycode 84 = g -+keycode 67 = h -+keycode 64 = j -+keycode 17 = k -+keycode 83 = l -+keycode 22 = semicolon plus -+keycode 61 = colon asterisk -+ control keycode 61 = Control_g -+keycode 65 = bracketright braceright -+ control keycode 65 = Control_bracketright -+# 5th line -+keycode 91 = Shift -+keycode 76 = z -+keycode 68 = x -+keycode 28 = c -+keycode 36 = v -+keycode 44 = b -+keycode 19 = n -+keycode 27 = m -+keycode 35 = comma less -+keycode 3 = period greater -+ control keycode 3 = Compose -+keycode 38 = slash question -+ control keycode 38 = Delete -+ shift control keycode 38 = Delete -+keycode 6 = backslash underscore -+ control keycode 6 = Control_backslash -+keycode 55 = Up -+ alt keycode 55 = PageUp -+keycode 14 = Shift -+# 6th line -+keycode 56 = Control -+keycode 42 = Alt -+keycode 33 = space -+ control keycode 33 = nul -+keycode 7 = Left -+ alt keycode 7 = Home -+keycode 31 = Down -+ alt keycode 31 = PageDown -+keycode 47 = Right -+ alt keycode 47 = End ---- a/drivers/char/vr41xx_keyb.c -+++ b/drivers/char/vr41xx_keyb.c -@@ -308,7 +308,7 @@ void __devinit kbd_init_hw(void) - if (found != 0) { - kiu_base = VRC4173_KIU_OFFSET; - mkiuintreg = VRC4173_MKIUINTREG_OFFSET; -- vrc4173_clock_supply(VRC4173_KIU_CLOCK); -+ vrc4173_supply_clock(VRC4173_KIU_CLOCK); - } - } - #endif -@@ -325,7 +325,7 @@ void __devinit kbd_init_hw(void) - - if (current_cpu_data.cputype == CPU_VR4111 || - current_cpu_data.cputype == CPU_VR4121) -- vr41xx_clock_supply(KIU_CLOCK); -+ vr41xx_supply_clock(KIU_CLOCK); - - kiu_writew(KIURST_KIURST, KIURST); - ---- a/drivers/i2c/Config.in -+++ b/drivers/i2c/Config.in -@@ -57,6 +57,10 @@ if [ "$CONFIG_I2C" != "n" ]; then - if [ "$CONFIG_SGI_IP22" = "y" ]; then - dep_tristate 'I2C SGI interfaces' CONFIG_I2C_ALGO_SGI $CONFIG_I2C - fi -+ -+ if [ "$CONFIG_SOC_AU1550" = "y" -o "$CONFIG_SOC_AU1200" ]; then -+ dep_tristate 'Au1550/Au1200 SMBus interface' CONFIG_I2C_ALGO_AU1550 $CONFIG_I2C -+ fi - - # This is needed for automatic patch generation: sensors code starts here - # This is needed for automatic patch generation: sensors code ends here ---- /dev/null -+++ b/drivers/i2c/i2c-algo-au1550.c -@@ -0,0 +1,340 @@ -+/* -+ * i2c-algo-au1550.c: SMBus (i2c) driver algorithms for Alchemy PSC interface -+ * Copyright (C) 2004 Embedded Edge, LLC <dan@embeddededge.com> -+ * -+ * The documentation describes this as an SMBus controller, but it doesn't -+ * understand any of the SMBus protocol in hardware. It's really an I2C -+ * controller that could emulate most of the SMBus in software. -+ */ -+ -+#include <linux/kernel.h> -+#include <linux/module.h> -+#include <linux/init.h> -+#include <linux/errno.h> -+#include <linux/delay.h> -+ -+#include <asm/au1000.h> -+#include <asm/au1xxx_psc.h> -+ -+#include <linux/i2c.h> -+#include <linux/i2c-algo-au1550.h> -+ -+static int -+wait_xfer_done(struct i2c_algo_au1550_data *adap) -+{ -+ u32 stat; -+ int i; -+ volatile psc_smb_t *sp; -+ -+ sp = (volatile psc_smb_t *)(adap->psc_base); -+ -+ /* Wait for Tx FIFO Underflow. -+ */ -+ for (i = 0; i < adap->xfer_timeout; i++) { -+ stat = sp->psc_smbevnt; -+ au_sync(); -+ if ((stat & PSC_SMBEVNT_TU) != 0) { -+ /* Clear it. */ -+ sp->psc_smbevnt = PSC_SMBEVNT_TU; -+ au_sync(); -+ return 0; -+ } -+ udelay(1); -+ } -+ -+ return -ETIMEDOUT; -+} -+ -+static int -+wait_ack(struct i2c_algo_au1550_data *adap) -+{ -+ u32 stat; -+ volatile psc_smb_t *sp; -+ -+ if (wait_xfer_done(adap)) -+ return -ETIMEDOUT; -+ -+ sp = (volatile psc_smb_t *)(adap->psc_base); -+ -+ stat = sp->psc_smbevnt; -+ au_sync(); -+ -+ if ((stat & (PSC_SMBEVNT_DN | PSC_SMBEVNT_AN | PSC_SMBEVNT_AL)) != 0) -+ return -ETIMEDOUT; -+ -+ return 0; -+} -+ -+static int -+wait_master_done(struct i2c_algo_au1550_data *adap) -+{ -+ u32 stat; -+ int i; -+ volatile psc_smb_t *sp; -+ -+ sp = (volatile psc_smb_t *)(adap->psc_base); -+ -+ /* Wait for Master Done. -+ */ -+ for (i = 0; i < adap->xfer_timeout; i++) { -+ stat = sp->psc_smbevnt; -+ au_sync(); -+ if ((stat & PSC_SMBEVNT_MD) != 0) -+ return 0; -+ udelay(1); -+ } -+ -+ return -ETIMEDOUT; -+} -+ -+static int -+do_address(struct i2c_algo_au1550_data *adap, unsigned int addr, int rd) -+{ -+ volatile psc_smb_t *sp; -+ u32 stat; -+ -+ sp = (volatile psc_smb_t *)(adap->psc_base); -+ -+ /* Reset the FIFOs, clear events. -+ */ -+ sp->psc_smbpcr = PSC_SMBPCR_DC; -+ sp->psc_smbevnt = PSC_SMBEVNT_ALLCLR; -+ au_sync(); -+ do { -+ stat = sp->psc_smbpcr; -+ au_sync(); -+ } while ((stat & PSC_SMBPCR_DC) != 0); -+ -+ /* Write out the i2c chip address and specify operation -+ */ -+ addr <<= 1; -+ if (rd) -+ addr |= 1; -+ -+ /* Put byte into fifo, start up master. -+ */ -+ sp->psc_smbtxrx = addr; -+ au_sync(); -+ sp->psc_smbpcr = PSC_SMBPCR_MS; -+ au_sync(); -+ if (wait_ack(adap)) -+ return -EIO; -+ return 0; -+} -+ -+static u32 -+wait_for_rx_byte(struct i2c_algo_au1550_data *adap, u32 *ret_data) -+{ -+ int j; -+ u32 data, stat; -+ volatile psc_smb_t *sp; -+ -+ if (wait_xfer_done(adap)) -+ return -EIO; -+ -+ sp = (volatile psc_smb_t *)(adap->psc_base); -+ -+ j = adap->xfer_timeout * 100; -+ do { -+ j--; -+ if (j <= 0) -+ return -EIO; -+ -+ stat = sp->psc_smbstat; -+ au_sync(); -+ if ((stat & PSC_SMBSTAT_RE) == 0) -+ j = 0; -+ else -+ udelay(1); -+ } while (j > 0); -+ data = sp->psc_smbtxrx; -+ au_sync(); -+ *ret_data = data; -+ -+ return 0; -+} -+ -+static int -+i2c_read(struct i2c_algo_au1550_data *adap, unsigned char *buf, -+ unsigned int len) -+{ -+ int i; -+ u32 data; -+ volatile psc_smb_t *sp; -+ -+ if (len == 0) -+ return 0; -+ -+ /* A read is performed by stuffing the transmit fifo with -+ * zero bytes for timing, waiting for bytes to appear in the -+ * receive fifo, then reading the bytes. -+ */ -+ -+ sp = (volatile psc_smb_t *)(adap->psc_base); -+ -+ i = 0; -+ while (i < (len-1)) { -+ sp->psc_smbtxrx = 0; -+ au_sync(); -+ if (wait_for_rx_byte(adap, &data)) -+ return -EIO; -+ -+ buf[i] = data; -+ i++; -+ } -+ -+ /* The last byte has to indicate transfer done. -+ */ -+ sp->psc_smbtxrx = PSC_SMBTXRX_STP; -+ au_sync(); -+ if (wait_master_done(adap)) -+ return -EIO; -+ -+ data = sp->psc_smbtxrx; -+ au_sync(); -+ buf[i] = data; -+ return 0; -+} -+ -+static int -+i2c_write(struct i2c_algo_au1550_data *adap, unsigned char *buf, -+ unsigned int len) -+{ -+ int i; -+ u32 data; -+ volatile psc_smb_t *sp; -+ -+ if (len == 0) -+ return 0; -+ -+ sp = (volatile psc_smb_t *)(adap->psc_base); -+ -+ i = 0; -+ while (i < (len-1)) { -+ data = buf[i]; -+ sp->psc_smbtxrx = data; -+ au_sync(); -+ if (wait_ack(adap)) -+ return -EIO; -+ i++; -+ } -+ -+ /* The last byte has to indicate transfer done. -+ */ -+ data = buf[i]; -+ data |= PSC_SMBTXRX_STP; -+ sp->psc_smbtxrx = data; -+ au_sync(); -+ if (wait_master_done(adap)) -+ return -EIO; -+ return 0; -+} -+ -+static int -+au1550_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], int num) -+{ -+ struct i2c_algo_au1550_data *adap = i2c_adap->algo_data; -+ struct i2c_msg *p; -+ int i, err = 0; -+ -+ for (i = 0; !err && i < num; i++) { -+ p = &msgs[i]; -+ err = do_address(adap, p->addr, p->flags & I2C_M_RD); -+ if (err || !p->len) -+ continue; -+ if (p->flags & I2C_M_RD) -+ err = i2c_read(adap, p->buf, p->len); -+ else -+ err = i2c_write(adap, p->buf, p->len); -+ } -+ -+ /* Return the number of messages processed, or the error code. -+ */ -+ if (err == 0) -+ err = num; -+ return err; -+} -+ -+static u32 -+au1550_func(struct i2c_adapter *adap) -+{ -+ return I2C_FUNC_I2C; -+} -+ -+static struct i2c_algorithm au1550_algo = { -+ .name = "Au1550 algorithm", -+ .id = I2C_ALGO_AU1550, -+ .master_xfer = au1550_xfer, -+ .functionality = au1550_func, -+}; -+ -+/* -+ * registering functions to load algorithms at runtime -+ * Prior to calling us, the 50MHz clock frequency and routing -+ * must have been set up for the PSC indicated by the adapter. -+ */ -+int -+i2c_au1550_add_bus(struct i2c_adapter *i2c_adap) -+{ -+ struct i2c_algo_au1550_data *adap = i2c_adap->algo_data; -+ volatile psc_smb_t *sp; -+ u32 stat; -+ -+ i2c_adap->algo = &au1550_algo; -+ -+ /* Now, set up the PSC for SMBus PIO mode. -+ */ -+ sp = (volatile psc_smb_t *)(adap->psc_base); -+ sp->psc_ctrl = PSC_CTRL_DISABLE; -+ au_sync(); -+ sp->psc_sel = PSC_SEL_PS_SMBUSMODE; -+ sp->psc_smbcfg = 0; -+ au_sync(); -+ sp->psc_ctrl = PSC_CTRL_ENABLE; -+ au_sync(); -+ do { -+ stat = sp->psc_smbstat; -+ au_sync(); -+ } while ((stat & PSC_SMBSTAT_SR) == 0); -+ -+ sp->psc_smbcfg = (PSC_SMBCFG_RT_FIFO8 | PSC_SMBCFG_TT_FIFO8 | -+ PSC_SMBCFG_DD_DISABLE); -+ -+ /* Divide by 8 to get a 6.25 MHz clock. The later protocol -+ * timings are based on this clock. -+ */ -+ sp->psc_smbcfg |= PSC_SMBCFG_SET_DIV(PSC_SMBCFG_DIV2); -+ sp->psc_smbmsk = PSC_SMBMSK_ALLMASK; -+ au_sync(); -+ -+ /* Set the protocol timer values. See Table 71 in the -+ * Au1550 Data Book for standard timing values. -+ */ -+ sp->psc_smbtmr = PSC_SMBTMR_SET_TH(2) | PSC_SMBTMR_SET_PS(15) | \ -+ PSC_SMBTMR_SET_PU(11) | PSC_SMBTMR_SET_SH(11) | \ -+ PSC_SMBTMR_SET_SU(11) | PSC_SMBTMR_SET_CL(15) | \ -+ PSC_SMBTMR_SET_CH(11); -+ au_sync(); -+ -+ sp->psc_smbcfg |= PSC_SMBCFG_DE_ENABLE; -+ do { -+ stat = sp->psc_smbstat; -+ au_sync(); -+ } while ((stat & PSC_SMBSTAT_DR) == 0); -+ -+ return i2c_add_adapter(i2c_adap); -+} -+ -+ -+int -+i2c_au1550_del_bus(struct i2c_adapter *adap) -+{ -+ return i2c_del_adapter(adap); -+} -+ -+EXPORT_SYMBOL(i2c_au1550_add_bus); -+EXPORT_SYMBOL(i2c_au1550_del_bus); -+ -+MODULE_AUTHOR("Dan Malek <dan@embeddededge.com>"); -+MODULE_DESCRIPTION("SMBus Au1550 algorithm"); -+MODULE_LICENSE("GPL"); ---- /dev/null -+++ b/drivers/i2c/i2c-au1550.c -@@ -0,0 +1,154 @@ -+/* -+ * i2c-au1550.c: SMBus (i2c) adapter for Alchemy PSC interface -+ * Copyright (C) 2004 Embedded Edge, LLC <dan@embeddededge.com> -+ * -+ * This is just a skeleton adapter to use with the Au1550 PSC -+ * algorithm. It was developed for the Pb1550, but will work with -+ * any Au1550 board that has a similar PSC configuration. -+ * -+ * 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. -+ */ -+ -+#include <linux/config.h> -+#include <linux/kernel.h> -+#include <linux/module.h> -+#include <linux/init.h> -+#include <linux/errno.h> -+ -+#include <asm/au1000.h> -+#include <asm/au1xxx_psc.h> -+#if defined( CONFIG_MIPS_PB1550 ) -+ #include <asm/pb1550.h> -+#endif -+#if defined( CONFIG_MIPS_PB1200 ) -+ #include <asm/pb1200.h> -+#endif -+#if defined( CONFIG_MIPS_DB1200 ) -+ #include <asm/db1200.h> -+#endif -+#if defined( CONFIG_MIPS_FICMMP ) -+ #include <asm/ficmmp.h> -+#endif -+ -+#include <linux/i2c.h> -+#include <linux/i2c-algo-au1550.h> -+ -+ -+ -+static int -+pb1550_reg(struct i2c_client *client) -+{ -+ return 0; -+} -+ -+static int -+pb1550_unreg(struct i2c_client *client) -+{ -+ return 0; -+} -+ -+static void -+pb1550_inc_use(struct i2c_adapter *adap) -+{ -+#ifdef MODULE -+ MOD_INC_USE_COUNT; -+#endif -+} -+ -+static void -+pb1550_dec_use(struct i2c_adapter *adap) -+{ -+#ifdef MODULE -+ MOD_DEC_USE_COUNT; -+#endif -+} -+ -+static struct i2c_algo_au1550_data pb1550_i2c_info = { -+ SMBUS_PSC_BASE, 200, 200 -+}; -+ -+static struct i2c_adapter pb1550_board_adapter = { -+ name: "pb1550 adapter", -+ id: I2C_HW_AU1550_PSC, -+ algo: NULL, -+ algo_data: &pb1550_i2c_info, -+ inc_use: pb1550_inc_use, -+ dec_use: pb1550_dec_use, -+ client_register: pb1550_reg, -+ client_unregister: pb1550_unreg, -+ client_count: 0, -+}; -+ -+int __init -+i2c_pb1550_init(void) -+{ -+ /* This is where we would set up a 50MHz clock source -+ * and routing. On the Pb1550, the SMBus is PSC2, which -+ * uses a shared clock with USB. This has been already -+ * configured by Yamon as a 48MHz clock, close enough -+ * for our work. -+ */ -+ if (i2c_au1550_add_bus(&pb1550_board_adapter) < 0) -+ return -ENODEV; -+ -+ return 0; -+} -+ -+/* BIG hack to support the control interface on the Wolfson WM8731 -+ * audio codec on the Pb1550 board. We get an address and two data -+ * bytes to write, create an i2c message, and send it across the -+ * i2c transfer function. We do this here because we have access to -+ * the i2c adapter structure. -+ */ -+static struct i2c_msg wm_i2c_msg; /* We don't want this stuff on the stack */ -+static u8 i2cbuf[2]; -+ -+int -+pb1550_wm_codec_write(u8 addr, u8 reg, u8 val) -+{ -+ wm_i2c_msg.addr = addr; -+ wm_i2c_msg.flags = 0; -+ wm_i2c_msg.buf = i2cbuf; -+ wm_i2c_msg.len = 2; -+ i2cbuf[0] = reg; -+ i2cbuf[1] = val; -+ -+ return pb1550_board_adapter.algo->master_xfer(&pb1550_board_adapter, &wm_i2c_msg, 1); -+} -+ -+/* the next function is needed by DVB driver. */ -+int pb1550_i2c_xfer(struct i2c_msg msgs[], int num) -+{ -+ return pb1550_board_adapter.algo->master_xfer(&pb1550_board_adapter, msgs, num); -+} -+ -+EXPORT_SYMBOL(pb1550_wm_codec_write); -+EXPORT_SYMBOL(pb1550_i2c_xfer); -+ -+MODULE_AUTHOR("Dan Malek, Embedded Edge, LLC."); -+MODULE_DESCRIPTION("SMBus adapter Alchemy pb1550"); -+MODULE_LICENSE("GPL"); -+ -+int -+init_module(void) -+{ -+ return i2c_pb1550_init(); -+} -+ -+void -+cleanup_module(void) -+{ -+ i2c_au1550_del_bus(&pb1550_board_adapter); -+} ---- a/drivers/i2c/i2c-core.c -+++ b/drivers/i2c/i2c-core.c -@@ -1277,6 +1277,9 @@ static int __init i2c_init(void) - #ifdef CONFIG_I2C_MAX1617 - extern int i2c_max1617_init(void); - #endif -+#ifdef CONFIG_I2C_ALGO_AU1550 -+ extern int i2c_pb1550_init(void); -+#endif - - #ifdef CONFIG_I2C_PROC - extern int sensors_init(void); -@@ -1332,6 +1335,10 @@ int __init i2c_init_all(void) - i2c_max1617_init(); - #endif - -+#ifdef CONFIG_I2C_ALGO_AU1550 -+ i2c_pb1550_init(); -+#endif -+ - /* -------------- proc interface ---- */ - #ifdef CONFIG_I2C_PROC - sensors_init(); ---- a/drivers/i2c/Makefile -+++ b/drivers/i2c/Makefile -@@ -6,7 +6,7 @@ O_TARGET := i2c.o - - export-objs := i2c-core.o i2c-algo-bit.o i2c-algo-pcf.o \ - i2c-algo-ite.o i2c-algo-sibyte.o i2c-algo-sgi.o \ -- i2c-proc.o -+ i2c-algo-au1550.o i2c-proc.o i2c-au1550.o - - obj-$(CONFIG_I2C) += i2c-core.o - obj-$(CONFIG_I2C_CHARDEV) += i2c-dev.o -@@ -25,6 +25,7 @@ obj-$(CONFIG_I2C_KEYWEST) += i2c-keywest - obj-$(CONFIG_I2C_ALGO_SIBYTE) += i2c-algo-sibyte.o i2c-sibyte.o - obj-$(CONFIG_I2C_MAX1617) += i2c-max1617.o - obj-$(CONFIG_I2C_ALGO_SGI) += i2c-algo-sgi.o -+obj-$(CONFIG_I2C_ALGO_AU1550) += i2c-algo-au1550.o i2c-au1550.o - - # This is needed for automatic patch generation: sensors code starts here - # This is needed for automatic patch generation: sensors code ends here ---- a/drivers/media/video/indycam.c -+++ b/drivers/media/video/indycam.c -@@ -50,13 +50,14 @@ static int indycam_attach(struct i2c_ada - 0x80, /* INDYCAM_GAMMA */ - }; - -- int err = 0; - struct indycam *camera; - struct i2c_client *client; -+ int err = 0; - - client = kmalloc(sizeof(*client), GFP_KERNEL); -- if (!client) -+ if (!client) - return -ENOMEM; -+ - camera = kmalloc(sizeof(*camera), GFP_KERNEL); - if (!camera) { - err = -ENOMEM; -@@ -67,7 +68,7 @@ static int indycam_attach(struct i2c_ada - client->adapter = adap; - client->addr = addr; - client->driver = &i2c_driver_indycam; -- strcpy(client->name, "IndyCam client"); -+ strcpy(client->name, "IndyCam client"); - camera->client = client; - - err = i2c_attach_client(client); -@@ -75,18 +76,18 @@ static int indycam_attach(struct i2c_ada - goto out_free_camera; - - camera->version = i2c_smbus_read_byte_data(client, INDYCAM_VERSION); -- if (camera->version != CAMERA_VERSION_INDY && -- camera->version != CAMERA_VERSION_MOOSE) { -+ if ((camera->version != CAMERA_VERSION_INDY) && -+ (camera->version != CAMERA_VERSION_MOOSE)) { - err = -ENODEV; - goto out_detach_client; - } -- printk(KERN_INFO "Indycam v%d.%d detected.\n", -+ printk(KERN_INFO "IndyCam v%d.%d detected.\n", - INDYCAM_VERSION_MAJOR(camera->version), - INDYCAM_VERSION_MINOR(camera->version)); - - err = i2c_master_send(client, initseq, sizeof(initseq)); - if (err) -- printk(KERN_INFO "IndyCam initalization failed\n"); -+ printk(KERN_ERR "IndyCam initalization failed.\n"); - - MOD_INC_USE_COUNT; - return 0; ---- a/drivers/media/video/vino.c -+++ b/drivers/media/video/vino.c -@@ -5,6 +5,8 @@ - * License version 2 as published by the Free Software Foundation. - * - * Copyright (C) 2003 Ladislav Michl <ladis@linux-mips.org> -+ * Copyright (C) 2004 Mikael Nousiainen <tmnousia@cc.hut.fi> -+ * - */ - - #include <linux/module.h> -@@ -37,13 +39,23 @@ - #define DEBUG(x...) - #endif - -+/* Channels (who could have guessed) */ -+#define VINO_CHAN_NONE 0 -+#define VINO_CHAN_A 1 -+#define VINO_CHAN_B 2 -+ - /* VINO video size */ - #define VINO_PAL_WIDTH 768 - #define VINO_PAL_HEIGHT 576 - #define VINO_NTSC_WIDTH 646 - #define VINO_NTSC_HEIGHT 486 - --/* set this to some sensible values. note: VINO_MIN_WIDTH has to be 8*x */ -+/* Minimum value for Y-clipping (for smaller values the images -+ * will be corrupted) */ -+#define VINO_MIN_Y_CLIPPING 2 -+ -+/* Set these to some sensible values. -+ * Note: the picture width has to be divisible by 8 */ - #define VINO_MIN_WIDTH 32 - #define VINO_MIN_HEIGHT 32 - -@@ -64,9 +76,7 @@ static int threshold_b = 512; - - struct vino_device { - struct video_device vdev; --#define VINO_CHAN_A 1 --#define VINO_CHAN_B 2 -- int chan; -+ int chan; /* VINO_CHAN_NONE, VINO_CHAN_A or VINO_CHAN_B */ - int alpha; - /* clipping... */ - unsigned int left, right, top, bottom; -@@ -106,7 +116,7 @@ struct vino_device { - - struct vino_client { - struct i2c_client *driver; -- int owner; -+ int owner; /* VINO_CHAN_NONE, VINO_CHAN_A or VINO_CHAN_B */ - }; - - struct vino_video { -@@ -362,6 +372,7 @@ static int set_scaling(struct vino_devic - static int dma_setup(struct vino_device *v) - { - u32 ctrl, intr; -+ int ofs; - struct sgi_vino_channel *ch; - - ch = (v->chan == VINO_CHAN_A) ? &vino->a : &vino->b; -@@ -377,14 +388,24 @@ static int dma_setup(struct vino_device - ch->line_size = v->line_size - 8; - /* set the alpha register */ - ch->alpha = v->alpha; -- /* set cliping registers */ -- ch->clip_start = VINO_CLIP_ODD(v->top) | VINO_CLIP_EVEN(v->top+1) | -+ /* Set the clipping registers, this is the constant source of fun :) -+ * Y clipping start has to be >= 2 and end has to be start + height/2 -+ * The values of top and bottom are even so dividing is not a problem -+ * -+ * The docs say that clipping values for the even field should be -+ * odd_end + something_to_skip_vertical_blanking + some_lines and -+ * even_start + height/2, though the image is good this way also -+ * -+ * TODO: for analog sources (SAA7191), the clipping values are a bit -+ * different and that case isn't yet handled -+ */ -+ ofs = VINO_MIN_Y_CLIPPING; /* Should depend on input source */ -+ ch->clip_start = VINO_CLIP_ODD(ofs + v->top / 2) | -+ VINO_CLIP_EVEN(ofs + v->top / 2 + 1) | - VINO_CLIP_X(v->left); -- ch->clip_end = VINO_CLIP_ODD(v->bottom) | VINO_CLIP_EVEN(v->bottom+1) | -+ ch->clip_end = VINO_CLIP_ODD(ofs + v->bottom / 2 - 1) | -+ VINO_CLIP_EVEN(ofs + v->bottom / 2) | - VINO_CLIP_X(v->right); -- /* FIXME: end-of-field bug workaround -- VINO_CLIP_X(VINO_PAL_WIDTH); -- */ - /* init the frame rate and norm (full frame rate only for now...) */ - ch->frame_rate = VINO_FRAMERT_RT(0x1fff) | - (get_capture_norm(v) == VIDEO_MODE_PAL ? -@@ -510,6 +531,7 @@ static void field_done(struct vino_devic - static void vino_interrupt(int irq, void *dev_id, struct pt_regs *regs) - { - u32 intr, ctrl; -+ int a_eof, b_eof; - - spin_lock(&Vino->vino_lock); - ctrl = vino->control; -@@ -525,12 +547,14 @@ static void vino_interrupt(int irq, void - vino->control = ctrl; - clear_eod(&Vino->chB); - } -+ a_eof = intr & VINO_INTSTAT_A_EOF; -+ b_eof = intr & VINO_INTSTAT_B_EOF; - vino->intr_status = ~intr; - spin_unlock(&Vino->vino_lock); -- /* FIXME: For now we are assuming that interrupt means that frame is -- * done. That's not true, but we can live with such brokeness for -- * a while ;-) */ -- field_done(&Vino->chA); -+ if (a_eof) -+ field_done(&Vino->chA); -+ if (b_eof) -+ field_done(&Vino->chB); - } - - static int vino_grab(struct vino_device *v, int frame) ---- a/drivers/mtd/devices/docprobe.c -+++ b/drivers/mtd/devices/docprobe.c -@@ -89,10 +89,10 @@ static unsigned long __initdata doc_loca - 0xe4000000, - #elif defined(CONFIG_MOMENCO_OCELOT) - 0x2f000000, -- 0xff000000, -+ 0xff000000, - #elif defined(CONFIG_MOMENCO_OCELOT_G) || defined (CONFIG_MOMENCO_OCELOT_C) -- 0xff000000, --##else -+ 0xff000000, -+#else - #warning Unknown architecture for DiskOnChip. No default probe locations defined - #endif - 0 }; ---- a/drivers/mtd/devices/ms02-nv.c -+++ b/drivers/mtd/devices/ms02-nv.c -@@ -1,10 +1,10 @@ - /* -- * Copyright (c) 2001 Maciej W. Rozycki -+ * Copyright (c) 2001 Maciej W. Rozycki - * -- * 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 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. - * - * $Id: ms02-nv.c,v 1.2 2003/01/24 14:05:17 dwmw2 Exp $ - */ -@@ -29,18 +29,18 @@ - - - static char version[] __initdata = -- "ms02-nv.c: v.1.0.0 13 Aug 2001 Maciej W. Rozycki.\n"; -+ "ms02-nv.c: v.1.0.0 13 Aug 2001 Maciej W. Rozycki.\n"; - --MODULE_AUTHOR("Maciej W. Rozycki <macro@ds2.pg.gda.pl>"); -+MODULE_AUTHOR("Maciej W. Rozycki <macro@linux-mips.org>"); - MODULE_DESCRIPTION("DEC MS02-NV NVRAM module driver"); - MODULE_LICENSE("GPL"); - - - /* - * Addresses we probe for an MS02-NV at. Modules may be located -- * at any 8MB boundary within a 0MB up to 112MB range or at any 32MB -- * boundary within a 0MB up to 448MB range. We don't support a module -- * at 0MB, though. -+ * at any 8MiB boundary within a 0MiB up to 112MiB range or at any 32MiB -+ * boundary within a 0MiB up to 448MiB range. We don't support a module -+ * at 0MiB, though. - */ - static ulong ms02nv_addrs[] __initdata = { - 0x07000000, 0x06800000, 0x06000000, 0x05800000, 0x05000000, -@@ -130,7 +130,7 @@ static int __init ms02nv_init_one(ulong - - int ret = -ENODEV; - -- /* The module decodes 8MB of address space. */ -+ /* The module decodes 8MiB of address space. */ - mod_res = kmalloc(sizeof(*mod_res), GFP_KERNEL); - if (!mod_res) - return -ENOMEM; -@@ -233,7 +233,7 @@ static int __init ms02nv_init_one(ulong - goto err_out_csr_res; - } - -- printk(KERN_INFO "mtd%d: %s at 0x%08lx, size %uMB.\n", -+ printk(KERN_INFO "mtd%d: %s at 0x%08lx, size %uMiB.\n", - mtd->index, ms02nv_name, addr, size >> 20); - - mp->next = root_ms02nv_mtd; -@@ -293,12 +293,12 @@ static int __init ms02nv_init(void) - - switch (mips_machtype) { - case MACH_DS5000_200: -- csr = (volatile u32 *)KN02_CSR_ADDR; -+ csr = (volatile u32 *)KN02_CSR_BASE; - if (*csr & KN02_CSR_BNK32M) - stride = 2; - break; - case MACH_DS5000_2X0: -- case MACH_DS5000: -+ case MACH_DS5900: - csr = (volatile u32 *)KN03_MCR_BASE; - if (*csr & KN03_MCR_BNK32M) - stride = 2; ---- a/drivers/mtd/devices/ms02-nv.h -+++ b/drivers/mtd/devices/ms02-nv.h -@@ -1,32 +1,96 @@ - /* -- * Copyright (c) 2001 Maciej W. Rozycki -+ * Copyright (c) 2001, 2003 Maciej W. Rozycki - * -- * 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. -+ * DEC MS02-NV (54-20948-01) battery backed-up NVRAM module for -+ * DECstation/DECsystem 5000/2x0 and DECsystem 5900 and 5900/260 -+ * 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. -+ * -+ * $Id: ms02-nv.h,v 1.3 2003/08/19 09:25:36 dwmw2 Exp $ - */ - - #include <linux/ioport.h> - #include <linux/mtd/mtd.h> - -+/* -+ * Addresses are decoded as follows: -+ * -+ * 0x000000 - 0x3fffff SRAM -+ * 0x400000 - 0x7fffff CSR -+ * -+ * Within the SRAM area the following ranges are forced by the system -+ * firmware: -+ * -+ * 0x000000 - 0x0003ff diagnostic area, destroyed upon a reboot -+ * 0x000400 - ENDofRAM storage area, available to operating systems -+ * -+ * but we can't really use the available area right from 0x000400 as -+ * the first word is used by the firmware as a status flag passed -+ * from an operating system. If anything but the valid data magic -+ * ID value is found, the firmware considers the SRAM clean, i.e. -+ * containing no valid data, and disables the battery resulting in -+ * data being erased as soon as power is switched off. So the choice -+ * for the start address of the user-available is 0x001000 which is -+ * nicely page aligned. The area between 0x000404 and 0x000fff may -+ * be used by the driver for own needs. -+ * -+ * The diagnostic area defines two status words to be read by an -+ * operating system, a magic ID to distinguish a MS02-NV board from -+ * anything else and a status information providing results of tests -+ * as well as the size of SRAM available, which can be 1MiB or 2MiB -+ * (that's what the firmware handles; no idea if 2MiB modules ever -+ * existed). -+ * -+ * The firmware only handles the MS02-NV board if installed in the -+ * last (15th) slot, so for any other location the status information -+ * stored in the SRAM cannot be relied upon. But from the hardware -+ * point of view there is no problem using up to 14 such boards in a -+ * system -- only the 1st slot needs to be filled with a DRAM module. -+ * The MS02-NV board is ECC-protected, like other MS02 memory boards. -+ * -+ * The state of the battery as provided by the CSR is reflected on -+ * the two onboard LEDs. When facing the battery side of the board, -+ * with the LEDs at the top left and the battery at the bottom right -+ * (i.e. looking from the back side of the system box), their meaning -+ * is as follows (the system has to be powered on): -+ * -+ * left LED battery disable status: lit = enabled -+ * right LED battery condition status: lit = OK -+ */ -+ - /* MS02-NV iomem register offsets. */ - #define MS02NV_CSR 0x400000 /* control & status register */ - -+/* MS02-NV CSR status bits. */ -+#define MS02NV_CSR_BATT_OK 0x01 /* battery OK */ -+#define MS02NV_CSR_BATT_OFF 0x02 /* battery disabled */ -+ -+ - /* MS02-NV memory offsets. */ - #define MS02NV_DIAG 0x0003f8 /* diagnostic status */ - #define MS02NV_MAGIC 0x0003fc /* MS02-NV magic ID */ --#define MS02NV_RAM 0x000400 /* general-purpose RAM start */ -+#define MS02NV_VALID 0x000400 /* valid data magic ID */ -+#define MS02NV_RAM 0x001000 /* user-exposed RAM start */ - --/* MS02-NV diagnostic status constants. */ --#define MS02NV_DIAG_SIZE_MASK 0xf0 /* RAM size mask */ --#define MS02NV_DIAG_SIZE_SHIFT 0x10 /* RAM size shift (left) */ -+/* MS02-NV diagnostic status bits. */ -+#define MS02NV_DIAG_TEST 0x01 /* SRAM test done (?) */ -+#define MS02NV_DIAG_RO 0x02 /* SRAM r/o test done */ -+#define MS02NV_DIAG_RW 0x04 /* SRAM r/w test done */ -+#define MS02NV_DIAG_FAIL 0x08 /* SRAM test failed */ -+#define MS02NV_DIAG_SIZE_MASK 0xf0 /* SRAM size mask */ -+#define MS02NV_DIAG_SIZE_SHIFT 0x10 /* SRAM size shift (left) */ - - /* MS02-NV general constants. */ - #define MS02NV_ID 0x03021966 /* MS02-NV magic ID value */ -+#define MS02NV_VALID_ID 0xbd100248 /* valid data magic ID value */ - #define MS02NV_SLOT_SIZE 0x800000 /* size of the address space - decoded by the module */ - -+ - typedef volatile u32 ms02nv_uint; - - struct ms02nv_private { ---- a/drivers/mtd/maps/Config.in -+++ b/drivers/mtd/maps/Config.in -@@ -51,11 +51,26 @@ if [ "$CONFIG_MIPS" = "y" ]; then - dep_tristate ' Pb1000 MTD support' CONFIG_MTD_PB1000 $CONFIG_MIPS_PB1000 - dep_tristate ' Pb1500 MTD support' CONFIG_MTD_PB1500 $CONFIG_MIPS_PB1500 - dep_tristate ' Pb1100 MTD support' CONFIG_MTD_PB1100 $CONFIG_MIPS_PB1100 -+ dep_tristate ' Bosporus MTD support' CONFIG_MTD_BOSPORUS $CONFIG_MIPS_BOSPORUS -+ dep_tristate ' XXS1500 boot flash device' CONFIG_MTD_XXS1500 $CONFIG_MIPS_XXS1500 -+ dep_tristate ' MTX-1 flash device' CONFIG_MTD_MTX1 $CONFIG_MIPS_MTX1 - if [ "$CONFIG_MTD_PB1500" = "y" -o "$CONFIG_MTD_PB1500" = "m" \ - -o "$CONFIG_MTD_PB1100" = "y" -o "$CONFIG_MTD_PB1100" = "m" ]; then - bool ' Pb[15]00 boot flash device' CONFIG_MTD_PB1500_BOOT - bool ' Pb[15]00 user flash device (2nd 32MiB bank)' CONFIG_MTD_PB1500_USER - fi -+ tristate ' Db1x00 MTD support' CONFIG_MTD_DB1X00 -+ if [ "$CONFIG_MTD_DB1X00" = "y" -o "$CONFIG_MTD_DB1X00" = "m" ]; then -+ bool ' Db1x00 boot flash device' CONFIG_MTD_DB1X00_BOOT -+ bool ' Db1x00 user flash device (2nd bank)' CONFIG_MTD_DB1X00_USER -+ fi -+ tristate ' Pb1550 MTD support' CONFIG_MTD_PB1550 -+ if [ "$CONFIG_MTD_PB1550" = "y" -o "$CONFIG_MTD_PB1550" = "m" ]; then -+ bool ' Pb1550 Boot Flash' CONFIG_MTD_PB1550_BOOT -+ bool ' Pb1550 User Parameter Flash' CONFIG_MTD_PB1550_USER -+ fi -+ dep_tristate ' Hydrogen 3 MTD support' CONFIG_MTD_HYDROGEN3 $CONFIG_MIPS_HYDROGEN3 -+ dep_tristate ' Mirage MTD support' CONFIG_MTD_MIRAGE $CONFIG_MIPS_MIRAGE - dep_tristate ' Flash chip mapping on ITE QED-4N-S01B, Globespan IVR or custom board' CONFIG_MTD_CSTM_MIPS_IXX $CONFIG_MTD_CFI $CONFIG_MTD_JEDEC $CONFIG_MTD_PARTITIONS - if [ "$CONFIG_MTD_CSTM_MIPS_IXX" = "y" -o "$CONFIG_MTD_CSTM_MIPS_IXX" = "m" ]; then - hex ' Physical start address of flash mapping' CONFIG_MTD_CSTM_MIPS_IXX_START 0x8000000 ---- /dev/null -+++ b/drivers/mtd/maps/db1x00-flash.c -@@ -0,0 +1,283 @@ -+/* -+ * Flash memory access on Alchemy Db1xxx boards -+ * -+ * (C) 2003 Pete Popov <ppopov@pacbell.net> -+ * -+ */ -+ -+#include <linux/config.h> -+#include <linux/module.h> -+#include <linux/types.h> -+#include <linux/kernel.h> -+ -+#include <linux/mtd/mtd.h> -+#include <linux/mtd/map.h> -+#include <linux/mtd/partitions.h> -+ -+#include <asm/io.h> -+#include <asm/au1000.h> -+#include <asm/db1x00.h> -+ -+#ifdef DEBUG_RW -+#define DBG(x...) printk(x) -+#else -+#define DBG(x...) -+#endif -+ -+static unsigned long window_addr; -+static unsigned long window_size; -+static unsigned long flash_size; -+ -+__u8 physmap_read8(struct map_info *map, unsigned long ofs) -+{ -+ __u8 ret; -+ ret = __raw_readb(map->map_priv_1 + ofs); -+ DBG("read8 from %x, %x\n", (unsigned)(map->map_priv_1 + ofs), ret); -+ return ret; -+} -+ -+__u16 physmap_read16(struct map_info *map, unsigned long ofs) -+{ -+ __u16 ret; -+ ret = __raw_readw(map->map_priv_1 + ofs); -+ DBG("read16 from %x, %x\n", (unsigned)(map->map_priv_1 + ofs), ret); -+ return ret; -+} -+ -+__u32 physmap_read32(struct map_info *map, unsigned long ofs) -+{ -+ __u32 ret; -+ ret = __raw_readl(map->map_priv_1 + ofs); -+ DBG("read32 from %x, %x\n", (unsigned)(map->map_priv_1 + ofs), ret); -+ return ret; -+} -+ -+void physmap_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len) -+{ -+ DBG("physmap_copy from %x to %x\n", (unsigned)from, (unsigned)to); -+ memcpy_fromio(to, map->map_priv_1 + from, len); -+} -+ -+void physmap_write8(struct map_info *map, __u8 d, unsigned long adr) -+{ -+ DBG("write8 at %x, %x\n", (unsigned)(map->map_priv_1 + adr), d); -+ __raw_writeb(d, map->map_priv_1 + adr); -+ mb(); -+} -+ -+void physmap_write16(struct map_info *map, __u16 d, unsigned long adr) -+{ -+ DBG("write16 at %x, %x\n", (unsigned)(map->map_priv_1 + adr), d); -+ __raw_writew(d, map->map_priv_1 + adr); -+ mb(); -+} -+ -+void physmap_write32(struct map_info *map, __u32 d, unsigned long adr) -+{ -+ DBG("write32 at %x, %x\n", (unsigned)(map->map_priv_1 + adr), d); -+ __raw_writel(d, map->map_priv_1 + adr); -+ mb(); -+} -+ -+void physmap_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len) -+{ -+ DBG("physmap_copy_to %x from %x\n", (unsigned)to, (unsigned)from); -+ memcpy_toio(map->map_priv_1 + to, from, len); -+} -+ -+static struct map_info db1x00_map = { -+ name: "Db1x00 flash", -+ read8: physmap_read8, -+ read16: physmap_read16, -+ read32: physmap_read32, -+ copy_from: physmap_copy_from, -+ write8: physmap_write8, -+ write16: physmap_write16, -+ write32: physmap_write32, -+ copy_to: physmap_copy_to, -+}; -+ -+static unsigned char flash_buswidth = 4; -+ -+/* -+ * The Db1x boards support different flash densities. We setup -+ * the mtd_partition structures below for default of 64Mbit -+ * flash densities, and override the partitions sizes, if -+ * necessary, after we check the board status register. -+ */ -+ -+#ifdef DB1X00_BOTH_BANKS -+/* both banks will be used. Combine the first bank and the first -+ * part of the second bank together into a single jffs/jffs2 -+ * partition. -+ */ -+static struct mtd_partition db1x00_partitions[] = { -+ { -+ name: "User FS", -+ size: 0x1c00000, -+ offset: 0x0000000 -+ },{ -+ name: "yamon", -+ size: 0x0100000, -+ offset: MTDPART_OFS_APPEND, -+ mask_flags: MTD_WRITEABLE -+ },{ -+ name: "raw kernel", -+ size: (0x300000-0x40000), /* last 256KB is yamon env */ -+ offset: MTDPART_OFS_APPEND, -+ } -+}; -+#elif defined(DB1X00_BOOT_ONLY) -+static struct mtd_partition db1x00_partitions[] = { -+ { -+ name: "User FS", -+ size: 0x00c00000, -+ offset: 0x0000000 -+ },{ -+ name: "yamon", -+ size: 0x0100000, -+ offset: MTDPART_OFS_APPEND, -+ mask_flags: MTD_WRITEABLE -+ },{ -+ name: "raw kernel", -+ size: (0x300000-0x40000), /* last 256KB is yamon env */ -+ offset: MTDPART_OFS_APPEND, -+ } -+}; -+#elif defined(DB1X00_USER_ONLY) -+static struct mtd_partition db1x00_partitions[] = { -+ { -+ name: "User FS", -+ size: 0x0e00000, -+ offset: 0x0000000 -+ },{ -+ name: "raw kernel", -+ size: MTDPART_SIZ_FULL, -+ offset: MTDPART_OFS_APPEND, -+ } -+}; -+#else -+#error MTD_DB1X00 define combo error /* should never happen */ -+#endif -+ -+ -+#define NB_OF(x) (sizeof(x)/sizeof(x[0])) -+ -+static struct mtd_partition *parsed_parts; -+static struct mtd_info *mymtd; -+ -+/* -+ * Probe the flash density and setup window address and size -+ * based on user CONFIG options. There are times when we don't -+ * want the MTD driver to be probing the boot or user flash, -+ * so having the option to enable only one bank is important. -+ */ -+int setup_flash_params() -+{ -+ switch ((bcsr->status >> 14) & 0x3) { -+ case 0: /* 64Mbit devices */ -+ flash_size = 0x800000; /* 8MB per part */ -+#if defined(DB1X00_BOTH_BANKS) -+ window_addr = 0x1E000000; -+ window_size = 0x2000000; -+#elif defined(DB1X00_BOOT_ONLY) -+ window_addr = 0x1F000000; -+ window_size = 0x1000000; -+#else /* USER ONLY */ -+ window_addr = 0x1E000000; -+ window_size = 0x1000000; -+#endif -+ break; -+ case 1: -+ /* 128 Mbit devices */ -+ flash_size = 0x1000000; /* 16MB per part */ -+#if defined(DB1X00_BOTH_BANKS) -+ window_addr = 0x1C000000; -+ window_size = 0x4000000; -+ /* USERFS from 0x1C00 0000 to 0x1FC0 0000 */ -+ db1x00_partitions[0].size = 0x3C00000; -+#elif defined(DB1X00_BOOT_ONLY) -+ window_addr = 0x1E000000; -+ window_size = 0x2000000; -+ /* USERFS from 0x1E00 0000 to 0x1FC0 0000 */ -+ db1x00_partitions[0].size = 0x1C00000; -+#else /* USER ONLY */ -+ window_addr = 0x1C000000; -+ window_size = 0x2000000; -+ /* USERFS from 0x1C00 0000 to 0x1DE00000 */ -+ db1x00_partitions[0].size = 0x1DE0000; -+#endif -+ break; -+ case 2: -+ /* 256 Mbit devices */ -+ flash_size = 0x4000000; /* 64MB per part */ -+#if defined(DB1X00_BOTH_BANKS) -+ return 1; -+#elif defined(DB1X00_BOOT_ONLY) -+ /* Boot ROM flash bank only; no user bank */ -+ window_addr = 0x1C000000; -+ window_size = 0x4000000; -+ /* USERFS from 0x1C00 0000 to 0x1FC00000 */ -+ db1x00_partitions[0].size = 0x3C00000; -+#else /* USER ONLY */ -+ return 1; -+#endif -+ break; -+ default: -+ return 1; -+ } -+ return 0; -+} -+ -+int __init db1x00_mtd_init(void) -+{ -+ struct mtd_partition *parts; -+ int nb_parts = 0; -+ char *part_type; -+ -+ /* Default flash buswidth */ -+ db1x00_map.buswidth = flash_buswidth; -+ -+ if (setup_flash_params()) -+ return -ENXIO; -+ -+ /* -+ * Static partition definition selection -+ */ -+ part_type = "static"; -+ parts = db1x00_partitions; -+ nb_parts = NB_OF(db1x00_partitions); -+ db1x00_map.size = window_size; -+ -+ /* -+ * Now let's probe for the actual flash. Do it here since -+ * specific machine settings might have been set above. -+ */ -+ printk(KERN_NOTICE "Db1xxx flash: probing %d-bit flash bus\n", -+ db1x00_map.buswidth*8); -+ db1x00_map.map_priv_1 = -+ (unsigned long)ioremap(window_addr, window_size); -+ mymtd = do_map_probe("cfi_probe", &db1x00_map); -+ if (!mymtd) return -ENXIO; -+ mymtd->module = THIS_MODULE; -+ -+ add_mtd_partitions(mymtd, parts, nb_parts); -+ return 0; -+} -+ -+static void __exit db1x00_mtd_cleanup(void) -+{ -+ if (mymtd) { -+ del_mtd_partitions(mymtd); -+ map_destroy(mymtd); -+ if (parsed_parts) -+ kfree(parsed_parts); -+ } -+} -+ -+module_init(db1x00_mtd_init); -+module_exit(db1x00_mtd_cleanup); -+ -+MODULE_AUTHOR("Pete Popov"); -+MODULE_DESCRIPTION("Db1x00 mtd map driver"); -+MODULE_LICENSE("GPL"); ---- /dev/null -+++ b/drivers/mtd/maps/hydrogen3-flash.c -@@ -0,0 +1,189 @@ -+/* -+ * Flash memory access on Alchemy HydrogenIII boards -+ * -+ * (C) 2003 Pete Popov <ppopov@pacbell.net> -+ * -+ */ -+ -+#include <linux/config.h> -+#include <linux/module.h> -+#include <linux/types.h> -+#include <linux/kernel.h> -+ -+#include <linux/mtd/mtd.h> -+#include <linux/mtd/map.h> -+#include <linux/mtd/partitions.h> -+ -+#include <asm/io.h> -+#include <asm/au1000.h> -+ -+#ifdef DEBUG_RW -+#define DBG(x...) printk(x) -+#else -+#define DBG(x...) -+#endif -+ -+#define WINDOW_ADDR 0x1E000000 -+#define WINDOW_SIZE 0x02000000 -+ -+ -+__u8 physmap_read8(struct map_info *map, unsigned long ofs) -+{ -+ __u8 ret; -+ ret = __raw_readb(map->map_priv_1 + ofs); -+ DBG("read8 from %x, %x\n", (unsigned)(map->map_priv_1 + ofs), ret); -+ return ret; -+} -+ -+__u16 physmap_read16(struct map_info *map, unsigned long ofs) -+{ -+ __u16 ret; -+ ret = __raw_readw(map->map_priv_1 + ofs); -+ DBG("read16 from %x, %x\n", (unsigned)(map->map_priv_1 + ofs), ret); -+ return ret; -+} -+ -+__u32 physmap_read32(struct map_info *map, unsigned long ofs) -+{ -+ __u32 ret; -+ ret = __raw_readl(map->map_priv_1 + ofs); -+ DBG("read32 from %x, %x\n", (unsigned)(map->map_priv_1 + ofs), ret); -+ return ret; -+} -+ -+void physmap_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len) -+{ -+ DBG("physmap_copy from %x to %x\n", (unsigned)from, (unsigned)to); -+ memcpy_fromio(to, map->map_priv_1 + from, len); -+} -+ -+void physmap_write8(struct map_info *map, __u8 d, unsigned long adr) -+{ -+ DBG("write8 at %x, %x\n", (unsigned)(map->map_priv_1 + adr), d); -+ __raw_writeb(d, map->map_priv_1 + adr); -+ mb(); -+} -+ -+void physmap_write16(struct map_info *map, __u16 d, unsigned long adr) -+{ -+ DBG("write16 at %x, %x\n", (unsigned)(map->map_priv_1 + adr), d); -+ __raw_writew(d, map->map_priv_1 + adr); -+ mb(); -+} -+ -+void physmap_write32(struct map_info *map, __u32 d, unsigned long adr) -+{ -+ DBG("write32 at %x, %x\n", (unsigned)(map->map_priv_1 + adr), d); -+ __raw_writel(d, map->map_priv_1 + adr); -+ mb(); -+} -+ -+void physmap_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len) -+{ -+ DBG("physmap_copy_to %x from %x\n", (unsigned)to, (unsigned)from); -+ memcpy_toio(map->map_priv_1 + to, from, len); -+} -+ -+static struct map_info hydrogen3_map = { -+ name: "HydrogenIII flash", -+ read8: physmap_read8, -+ read16: physmap_read16, -+ read32: physmap_read32, -+ copy_from: physmap_copy_from, -+ write8: physmap_write8, -+ write16: physmap_write16, -+ write32: physmap_write32, -+ copy_to: physmap_copy_to, -+}; -+ -+static unsigned char flash_buswidth = 4; -+ -+/* MTDPART_OFS_APPEND is vastly preferred to any attempt at statically lining -+ * up the offsets. */ -+static struct mtd_partition hydrogen3_partitions[] = { -+ { -+ name: "User FS", -+ size: 0x1c00000, -+ offset: 0x0000000 -+ },{ -+ name: "yamon", -+ size: 0x0100000, -+ offset: MTDPART_OFS_APPEND, -+ mask_flags: MTD_WRITEABLE -+ },{ -+ name: "raw kernel", -+ size: 0x02c0000, -+ offset: MTDPART_OFS_APPEND -+ } -+}; -+ -+#define NB_OF(x) (sizeof(x)/sizeof(x[0])) -+ -+static struct mtd_partition *parsed_parts; -+static struct mtd_info *mymtd; -+ -+int __init hydrogen3_mtd_init(void) -+{ -+ struct mtd_partition *parts; -+ int nb_parts = 0; -+ char *part_type; -+ -+ /* Default flash buswidth */ -+ hydrogen3_map.buswidth = flash_buswidth; -+ -+ /* -+ * Static partition definition selection -+ */ -+ part_type = "static"; -+ parts = hydrogen3_partitions; -+ nb_parts = NB_OF(hydrogen3_partitions); -+ hydrogen3_map.size = WINDOW_SIZE; -+ -+ /* -+ * Now let's probe for the actual flash. Do it here since -+ * specific machine settings might have been set above. -+ */ -+ printk(KERN_NOTICE "HydrogenIII flash: probing %d-bit flash bus\n", -+ hydrogen3_map.buswidth*8); -+ hydrogen3_map.map_priv_1 = -+ (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE); -+ mymtd = do_map_probe("cfi_probe", &hydrogen3_map); -+ if (!mymtd) return -ENXIO; -+ mymtd->module = THIS_MODULE; -+ -+ add_mtd_partitions(mymtd, parts, nb_parts); -+ return 0; -+} -+ -+static void __exit hydrogen3_mtd_cleanup(void) -+{ -+ if (mymtd) { -+ del_mtd_partitions(mymtd); -+ map_destroy(mymtd); -+ if (parsed_parts) -+ kfree(parsed_parts); -+ } -+} -+ -+/*#ifndef MODULE -+ -+static int __init _bootflashonly(char *str) -+{ -+ bootflashonly = simple_strtol(str, NULL, 0); -+ return 1; -+} -+ -+ -+__setup("bootflashonly=", _bootflashonly); -+ -+#endif*/ -+ -+ -+module_init(hydrogen3_mtd_init); -+module_exit(hydrogen3_mtd_cleanup); -+ -+MODULE_PARM(bootflashonly, "i"); -+MODULE_PARM_DESC(bootflashonly, "1=use \"boot flash only\""); -+MODULE_AUTHOR("Pete Popov"); -+MODULE_DESCRIPTION("HydrogenIII mtd map driver"); -+MODULE_LICENSE("GPL"); ---- a/drivers/mtd/maps/lasat.c -+++ b/drivers/mtd/maps/lasat.c -@@ -1,15 +1,6 @@ - /* - * Flash device on lasat 100 and 200 boards - * -- * Presumably (C) 2002 Brian Murphy <brian@murphy.dk> or whoever he -- * works for. -- * -- * 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. -- * -- * $Id: lasat.c,v 1.1 2003/01/24 14:26:38 dwmw2 Exp $ -- * - */ - - #include <linux/module.h> -@@ -21,7 +12,6 @@ - #include <linux/mtd/partitions.h> - #include <linux/config.h> - #include <asm/lasat/lasat.h> --#include <asm/lasat/lasat_mtd.h> - - static struct mtd_info *mymtd; - -@@ -69,30 +59,33 @@ static void sp_copy_to(struct map_info * - } - - static struct map_info sp_map = { -- .name = "SP flash", -- .buswidth = 4, -- .read8 = sp_read8, -- .read16 = sp_read16, -- .read32 = sp_read32, -- .copy_from = sp_copy_from, -- .write8 = sp_write8, -- .write16 = sp_write16, -- .write32 = sp_write32, -- .copy_to = sp_copy_to -+ name: "SP flash", -+ buswidth: 4, -+ read8: sp_read8, -+ read16: sp_read16, -+ read32: sp_read32, -+ copy_from: sp_copy_from, -+ write8: sp_write8, -+ write16: sp_write16, -+ write32: sp_write32, -+ copy_to: sp_copy_to - }; - - static struct mtd_partition partition_info[LASAT_MTD_LAST]; --static char *lasat_mtd_partnames[] = {"Bootloader", "Service", "Normal", "Filesystem", "Config"}; -+static char *lasat_mtd_partnames[] = {"Bootloader", "Service", "Normal", "Config", "Filesystem"}; - - static int __init init_sp(void) - { - int i; -+ int nparts = 0; - /* this does not play well with the old flash code which - * protects and uprotects the flash when necessary */ - printk(KERN_NOTICE "Unprotecting flash\n"); - *lasat_misc->flash_wp_reg |= 1 << lasat_misc->flash_wp_bit; - -- sp_map.map_priv_1 = lasat_flash_partition_start(LASAT_MTD_BOOTLOADER); -+ sp_map.map_priv_1 = ioremap_nocache( -+ lasat_flash_partition_start(LASAT_MTD_BOOTLOADER), -+ lasat_board_info.li_flash_size); - sp_map.size = lasat_board_info.li_flash_size; - - printk(KERN_NOTICE "sp flash device: %lx at %lx\n", -@@ -109,12 +102,15 @@ static int __init init_sp(void) - - for (i=0; i < LASAT_MTD_LAST; i++) { - size = lasat_flash_partition_size(i); -- partition_info[i].size = size; -- partition_info[i].offset = offset; -- offset += size; -+ if (size != 0) { -+ nparts++; -+ partition_info[i].size = size; -+ partition_info[i].offset = offset; -+ offset += size; -+ } - } - -- add_mtd_partitions( mymtd, partition_info, LASAT_MTD_LAST ); -+ add_mtd_partitions( mymtd, partition_info, nparts ); - return 0; - } - -@@ -124,11 +120,11 @@ static int __init init_sp(void) - static void __exit cleanup_sp(void) - { - if (mymtd) { -- del_mtd_partitions(mymtd); -- map_destroy(mymtd); -+ del_mtd_partitions(mymtd); -+ map_destroy(mymtd); - } - if (sp_map.map_priv_1) { -- sp_map.map_priv_1 = 0; -+ sp_map.map_priv_1 = 0; - } - } - ---- a/drivers/mtd/maps/Makefile -+++ b/drivers/mtd/maps/Makefile -@@ -52,7 +52,13 @@ obj-$(CONFIG_MTD_PCI) += pci.o - obj-$(CONFIG_MTD_PB1000) += pb1xxx-flash.o - obj-$(CONFIG_MTD_PB1100) += pb1xxx-flash.o - obj-$(CONFIG_MTD_PB1500) += pb1xxx-flash.o -+obj-$(CONFIG_MTD_XXS1500) += xxs1500.o -+obj-$(CONFIG_MTD_MTX1) += mtx-1.o - obj-$(CONFIG_MTD_LASAT) += lasat.o -+obj-$(CONFIG_MTD_DB1X00) += db1x00-flash.o -+obj-$(CONFIG_MTD_PB1550) += pb1550-flash.o -+obj-$(CONFIG_MTD_HYDROGEN3) += hydrogen3-flash.o -+obj-$(CONFIG_MTD_BOSPORUS) += pb1xxx-flash.o - obj-$(CONFIG_MTD_AUTCPU12) += autcpu12-nvram.o - obj-$(CONFIG_MTD_EDB7312) += edb7312.o - obj-$(CONFIG_MTD_IMPA7) += impa7.o -@@ -61,5 +67,6 @@ obj-$(CONFIG_MTD_REDWOOD) += redwood.o - obj-$(CONFIG_MTD_UCLINUX) += uclinux.o - obj-$(CONFIG_MTD_NETtel) += nettel.o - obj-$(CONFIG_MTD_SCB2_FLASH) += scb2_flash.o -+obj-$(CONFIG_MTD_MIRAGE) += mirage-flash.o - - include $(TOPDIR)/Rules.make ---- /dev/null -+++ b/drivers/mtd/maps/mirage-flash.c -@@ -0,0 +1,194 @@ -+/* -+ * Flash memory access on AMD Mirage board. -+ * -+ * (C) 2003 Embedded Edge -+ * based on mirage-flash.c: -+ * (C) 2003 Pete Popov <ppopov@pacbell.net> -+ * -+ */ -+ -+#include <linux/config.h> -+#include <linux/module.h> -+#include <linux/types.h> -+#include <linux/kernel.h> -+ -+#include <linux/mtd/mtd.h> -+#include <linux/mtd/map.h> -+#include <linux/mtd/partitions.h> -+ -+#include <asm/io.h> -+#include <asm/au1000.h> -+//#include <asm/mirage.h> -+ -+#ifdef DEBUG_RW -+#define DBG(x...) printk(x) -+#else -+#define DBG(x...) -+#endif -+ -+static unsigned long window_addr; -+static unsigned long window_size; -+static unsigned long flash_size; -+ -+__u8 physmap_read8(struct map_info *map, unsigned long ofs) -+{ -+ __u8 ret; -+ ret = __raw_readb(map->map_priv_1 + ofs); -+ DBG("read8 from %x, %x\n", (unsigned)(map->map_priv_1 + ofs), ret); -+ return ret; -+} -+ -+__u16 physmap_read16(struct map_info *map, unsigned long ofs) -+{ -+ __u16 ret; -+ ret = __raw_readw(map->map_priv_1 + ofs); -+ DBG("read16 from %x, %x\n", (unsigned)(map->map_priv_1 + ofs), ret); -+ return ret; -+} -+ -+__u32 physmap_read32(struct map_info *map, unsigned long ofs) -+{ -+ __u32 ret; -+ ret = __raw_readl(map->map_priv_1 + ofs); -+ DBG("read32 from %x, %x\n", (unsigned)(map->map_priv_1 + ofs), ret); -+ return ret; -+} -+ -+void physmap_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len) -+{ -+ DBG("physmap_copy from %x to %x\n", (unsigned)from, (unsigned)to); -+ memcpy_fromio(to, map->map_priv_1 + from, len); -+} -+ -+void physmap_write8(struct map_info *map, __u8 d, unsigned long adr) -+{ -+ DBG("write8 at %x, %x\n", (unsigned)(map->map_priv_1 + adr), d); -+ __raw_writeb(d, map->map_priv_1 + adr); -+ mb(); -+} -+ -+void physmap_write16(struct map_info *map, __u16 d, unsigned long adr) -+{ -+ DBG("write16 at %x, %x\n", (unsigned)(map->map_priv_1 + adr), d); -+ __raw_writew(d, map->map_priv_1 + adr); -+ mb(); -+} -+ -+void physmap_write32(struct map_info *map, __u32 d, unsigned long adr) -+{ -+ DBG("write32 at %x, %x\n", (unsigned)(map->map_priv_1 + adr), d); -+ __raw_writel(d, map->map_priv_1 + adr); -+ mb(); -+} -+ -+void physmap_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len) -+{ -+ DBG("physmap_copy_to %x from %x\n", (unsigned)to, (unsigned)from); -+ memcpy_toio(map->map_priv_1 + to, from, len); -+} -+ -+static struct map_info mirage_map = { -+ name: "Mirage flash", -+ read8: physmap_read8, -+ read16: physmap_read16, -+ read32: physmap_read32, -+ copy_from: physmap_copy_from, -+ write8: physmap_write8, -+ write16: physmap_write16, -+ write32: physmap_write32, -+ copy_to: physmap_copy_to, -+}; -+ -+static unsigned char flash_buswidth = 4; -+ -+static struct mtd_partition mirage_partitions[] = { -+ { -+ name: "User FS", -+ size: 0x1c00000, -+ offset: 0x0000000 -+ },{ -+ name: "yamon", -+ size: 0x0100000, -+ offset: MTDPART_OFS_APPEND, -+ mask_flags: MTD_WRITEABLE -+ },{ -+ name: "raw kernel", -+ size: (0x300000-0x40000), /* last 256KB is yamon env */ -+ offset: MTDPART_OFS_APPEND, -+ } -+}; -+ -+#define NB_OF(x) (sizeof(x)/sizeof(x[0])) -+ -+static struct mtd_partition *parsed_parts; -+static struct mtd_info *mymtd; -+ -+/* -+ * Probe the flash density and setup window address and size -+ * based on user CONFIG options. There are times when we don't -+ * want the MTD driver to be probing the boot or user flash, -+ * so having the option to enable only one bank is important. -+ */ -+int setup_flash_params() -+{ -+ flash_size = 0x4000000; /* 64MB per part */ -+ /* Boot ROM flash bank only; no user bank */ -+ window_addr = 0x1C000000; -+ window_size = 0x4000000; -+ /* USERFS from 0x1C00 0000 to 0x1FC00000 */ -+ mirage_partitions[0].size = 0x3C00000; -+ return 0; -+} -+ -+int __init mirage_mtd_init(void) -+{ -+ struct mtd_partition *parts; -+ int nb_parts = 0; -+ char *part_type; -+ -+ /* Default flash buswidth */ -+ mirage_map.buswidth = flash_buswidth; -+ -+ if (setup_flash_params()) -+ return -ENXIO; -+ -+ /* -+ * Static partition definition selection -+ */ -+ part_type = "static"; -+ parts = mirage_partitions; -+ nb_parts = NB_OF(mirage_partitions); -+ mirage_map.size = window_size; -+ -+ /* -+ * Now let's probe for the actual flash. Do it here since -+ * specific machine settings might have been set above. -+ */ -+ printk(KERN_NOTICE "Mirage flash: probing %d-bit flash bus\n", -+ mirage_map.buswidth*8); -+ mirage_map.map_priv_1 = -+ (unsigned long)ioremap(window_addr, window_size); -+ mymtd = do_map_probe("cfi_probe", &mirage_map); -+ if (!mymtd) return -ENXIO; -+ mymtd->module = THIS_MODULE; -+ -+ add_mtd_partitions(mymtd, parts, nb_parts); -+ return 0; -+} -+ -+static void __exit mirage_mtd_cleanup(void) -+{ -+ if (mymtd) { -+ del_mtd_partitions(mymtd); -+ map_destroy(mymtd); -+ if (parsed_parts) -+ kfree(parsed_parts); -+ } -+} -+ -+module_init(mirage_mtd_init); -+module_exit(mirage_mtd_cleanup); -+ -+MODULE_AUTHOR("Embedded Edge"); -+MODULE_DESCRIPTION("Mirage mtd map driver"); -+MODULE_LICENSE("GPL"); ---- /dev/null -+++ b/drivers/mtd/maps/mtx-1.c -@@ -0,0 +1,181 @@ -+/* -+ * Flash memory access on 4G Systems MTX-1 board -+ * -+ * (C) 2003 Pete Popov <ppopov@mvista.com> -+ * Bruno Randolf <bruno.randolf@4g-systems.de> -+ */ -+ -+#include <linux/config.h> -+#include <linux/module.h> -+#include <linux/types.h> -+#include <linux/kernel.h> -+ -+#include <linux/mtd/mtd.h> -+#include <linux/mtd/map.h> -+#include <linux/mtd/partitions.h> -+ -+#include <asm/io.h> -+#include <asm/au1000.h> -+ -+#ifdef DEBUG_RW -+#define DBG(x...) printk(x) -+#else -+#define DBG(x...) -+#endif -+ -+#ifdef CONFIG_MIPS_MTX1 -+#define WINDOW_ADDR 0x1E000000 -+#define WINDOW_SIZE 0x2000000 -+#endif -+ -+__u8 physmap_read8(struct map_info *map, unsigned long ofs) -+{ -+ __u8 ret; -+ ret = __raw_readb(map->map_priv_1 + ofs); -+ DBG("read8 from %x, %x\n", (unsigned)(map->map_priv_1 + ofs), ret); -+ return ret; -+} -+ -+__u16 physmap_read16(struct map_info *map, unsigned long ofs) -+{ -+ __u16 ret; -+ ret = __raw_readw(map->map_priv_1 + ofs); -+ DBG("read16 from %x, %x\n", (unsigned)(map->map_priv_1 + ofs), ret); -+ return ret; -+} -+ -+__u32 physmap_read32(struct map_info *map, unsigned long ofs) -+{ -+ __u32 ret; -+ ret = __raw_readl(map->map_priv_1 + ofs); -+ DBG("read32 from %x, %x\n", (unsigned)(map->map_priv_1 + ofs), ret); -+ return ret; -+} -+ -+void physmap_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len) -+{ -+ DBG("physmap_copy from %x to %x\n", (unsigned)from, (unsigned)to); -+ memcpy_fromio(to, map->map_priv_1 + from, len); -+} -+ -+void physmap_write8(struct map_info *map, __u8 d, unsigned long adr) -+{ -+ DBG("write8 at %x, %x\n", (unsigned)(map->map_priv_1 + adr), d); -+ __raw_writeb(d, map->map_priv_1 + adr); -+ mb(); -+} -+ -+void physmap_write16(struct map_info *map, __u16 d, unsigned long adr) -+{ -+ DBG("write16 at %x, %x\n", (unsigned)(map->map_priv_1 + adr), d); -+ __raw_writew(d, map->map_priv_1 + adr); -+ mb(); -+} -+ -+void physmap_write32(struct map_info *map, __u32 d, unsigned long adr) -+{ -+ DBG("write32 at %x, %x\n", (unsigned)(map->map_priv_1 + adr), d); -+ __raw_writel(d, map->map_priv_1 + adr); -+ mb(); -+} -+ -+void physmap_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len) -+{ -+ DBG("physmap_copy_to %x from %x\n", (unsigned)to, (unsigned)from); -+ memcpy_toio(map->map_priv_1 + to, from, len); -+} -+ -+ -+ -+static struct map_info mtx1_map = { -+ name: "MTX-1 flash", -+ read8: physmap_read8, -+ read16: physmap_read16, -+ read32: physmap_read32, -+ copy_from: physmap_copy_from, -+ write8: physmap_write8, -+ write16: physmap_write16, -+ write32: physmap_write32, -+ copy_to: physmap_copy_to, -+}; -+ -+ -+static unsigned long flash_size = 0x01000000; -+static unsigned char flash_buswidth = 4; -+static struct mtd_partition mtx1_partitions[] = { -+ { -+ name: "user fs", -+ size: 0x1c00000, -+ offset: 0, -+ },{ -+ name: "yamon", -+ size: 0x0100000, -+ offset: MTDPART_OFS_APPEND, -+ mask_flags: MTD_WRITEABLE -+ },{ -+ name: "raw kernel", -+ size: 0x02c0000, -+ offset: MTDPART_OFS_APPEND, -+ },{ -+ name: "yamon env vars", -+ size: 0x0040000, -+ offset: MTDPART_OFS_APPEND, -+ mask_flags: MTD_WRITEABLE -+ } -+}; -+ -+ -+#define NB_OF(x) (sizeof(x)/sizeof(x[0])) -+ -+static struct mtd_partition *parsed_parts; -+static struct mtd_info *mymtd; -+ -+int __init mtx1_mtd_init(void) -+{ -+ struct mtd_partition *parts; -+ int nb_parts = 0; -+ char *part_type; -+ -+ /* Default flash buswidth */ -+ mtx1_map.buswidth = flash_buswidth; -+ -+ /* -+ * Static partition definition selection -+ */ -+ part_type = "static"; -+ parts = mtx1_partitions; -+ nb_parts = NB_OF(mtx1_partitions); -+ mtx1_map.size = flash_size; -+ -+ /* -+ * Now let's probe for the actual flash. Do it here since -+ * specific machine settings might have been set above. -+ */ -+ printk(KERN_NOTICE "MTX-1 flash: probing %d-bit flash bus\n", -+ mtx1_map.buswidth*8); -+ mtx1_map.map_priv_1 = -+ (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE); -+ mymtd = do_map_probe("cfi_probe", &mtx1_map); -+ if (!mymtd) return -ENXIO; -+ mymtd->module = THIS_MODULE; -+ -+ add_mtd_partitions(mymtd, parts, nb_parts); -+ return 0; -+} -+ -+static void __exit mtx1_mtd_cleanup(void) -+{ -+ if (mymtd) { -+ del_mtd_partitions(mymtd); -+ map_destroy(mymtd); -+ if (parsed_parts) -+ kfree(parsed_parts); -+ } -+} -+ -+module_init(mtx1_mtd_init); -+module_exit(mtx1_mtd_cleanup); -+ -+MODULE_AUTHOR("Pete Popov"); -+MODULE_DESCRIPTION("MTX-1 CFI map driver"); -+MODULE_LICENSE("GPL"); ---- /dev/null -+++ b/drivers/mtd/maps/pb1550-flash.c -@@ -0,0 +1,270 @@ -+/* -+ * Flash memory access on Alchemy Pb1550 board -+ * -+ * (C) 2004 Embedded Edge, LLC, based on pb1550-flash.c: -+ * (C) 2003 Pete Popov <ppopov@pacbell.net> -+ * -+ */ -+ -+#include <linux/config.h> -+#include <linux/module.h> -+#include <linux/types.h> -+#include <linux/kernel.h> -+ -+#include <linux/mtd/mtd.h> -+#include <linux/mtd/map.h> -+#include <linux/mtd/partitions.h> -+ -+#include <asm/io.h> -+#include <asm/au1000.h> -+#include <asm/pb1550.h> -+ -+#ifdef DEBUG_RW -+#define DBG(x...) printk(x) -+#else -+#define DBG(x...) -+#endif -+ -+static unsigned long window_addr; -+static unsigned long window_size; -+ -+__u8 physmap_read8(struct map_info *map, unsigned long ofs) -+{ -+ __u8 ret; -+ ret = __raw_readb(map->map_priv_1 + ofs); -+ DBG("read8 from %x, %x\n", (unsigned)(map->map_priv_1 + ofs), ret); -+ return ret; -+} -+ -+__u16 physmap_read16(struct map_info *map, unsigned long ofs) -+{ -+ __u16 ret; -+ ret = __raw_readw(map->map_priv_1 + ofs); -+ DBG("read16 from %x, %x\n", (unsigned)(map->map_priv_1 + ofs), ret); -+ return ret; -+} -+ -+__u32 physmap_read32(struct map_info *map, unsigned long ofs) -+{ -+ __u32 ret; -+ ret = __raw_readl(map->map_priv_1 + ofs); -+ DBG("read32 from %x, %x\n", (unsigned)(map->map_priv_1 + ofs), ret); -+ return ret; -+} -+ -+void physmap_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len) -+{ -+ DBG("physmap_copy from %x to %x\n", (unsigned)from, (unsigned)to); -+ memcpy_fromio(to, map->map_priv_1 + from, len); -+} -+ -+void physmap_write8(struct map_info *map, __u8 d, unsigned long adr) -+{ -+ DBG("write8 at %x, %x\n", (unsigned)(map->map_priv_1 + adr), d); -+ __raw_writeb(d, map->map_priv_1 + adr); -+ mb(); -+} -+ -+void physmap_write16(struct map_info *map, __u16 d, unsigned long adr) -+{ -+ DBG("write16 at %x, %x\n", (unsigned)(map->map_priv_1 + adr), d); -+ __raw_writew(d, map->map_priv_1 + adr); -+ mb(); -+} -+ -+void physmap_write32(struct map_info *map, __u32 d, unsigned long adr) -+{ -+ DBG("write32 at %x, %x\n", (unsigned)(map->map_priv_1 + adr), d); -+ __raw_writel(d, map->map_priv_1 + adr); -+ mb(); -+} -+ -+void physmap_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len) -+{ -+ DBG("physmap_copy_to %x from %x\n", (unsigned)to, (unsigned)from); -+ memcpy_toio(map->map_priv_1 + to, from, len); -+} -+ -+static struct map_info pb1550_map = { -+ name: "Pb1550 flash", -+ read8: physmap_read8, -+ read16: physmap_read16, -+ read32: physmap_read32, -+ copy_from: physmap_copy_from, -+ write8: physmap_write8, -+ write16: physmap_write16, -+ write32: physmap_write32, -+ copy_to: physmap_copy_to, -+}; -+ -+static unsigned char flash_buswidth = 4; -+ -+/* -+ * Support only 64MB NOR Flash parts -+ */ -+ -+#ifdef PB1550_BOTH_BANKS -+/* both banks will be used. Combine the first bank and the first -+ * part of the second bank together into a single jffs/jffs2 -+ * partition. -+ */ -+static struct mtd_partition pb1550_partitions[] = { -+ /* assume boot[2:0]:swap is '0000' or '1000', which translates to: -+ * 1C00 0000 1FFF FFFF CE0 64MB Boot NOR Flash -+ * 1800 0000 1BFF FFFF CE0 64MB Param NOR Flash -+ */ -+ { -+ name: "User FS", -+ size: (0x1FC00000 - 0x18000000), -+ offset: 0x0000000 -+ },{ -+ name: "yamon", -+ size: 0x0100000, -+ offset: MTDPART_OFS_APPEND, -+ mask_flags: MTD_WRITEABLE -+ },{ -+ name: "raw kernel", -+ size: (0x300000 - 0x40000), /* last 256KB is yamon env */ -+ offset: MTDPART_OFS_APPEND, -+ } -+}; -+#elif defined(PB1550_BOOT_ONLY) -+static struct mtd_partition pb1550_partitions[] = { -+ /* assume boot[2:0]:swap is '0000' or '1000', which translates to: -+ * 1C00 0000 1FFF FFFF CE0 64MB Boot NOR Flash -+ */ -+ { -+ name: "User FS", -+ size: 0x03c00000, -+ offset: 0x0000000 -+ },{ -+ name: "yamon", -+ size: 0x0100000, -+ offset: MTDPART_OFS_APPEND, -+ mask_flags: MTD_WRITEABLE -+ },{ -+ name: "raw kernel", -+ size: (0x300000-0x40000), /* last 256KB is yamon env */ -+ offset: MTDPART_OFS_APPEND, -+ } -+}; -+#elif defined(PB1550_USER_ONLY) -+static struct mtd_partition pb1550_partitions[] = { -+ /* assume boot[2:0]:swap is '0000' or '1000', which translates to: -+ * 1800 0000 1BFF FFFF CE0 64MB Param NOR Flash -+ */ -+ { -+ name: "User FS", -+ size: (0x4000000 - 0x200000), /* reserve 2MB for raw kernel */ -+ offset: 0x0000000 -+ },{ -+ name: "raw kernel", -+ size: MTDPART_SIZ_FULL, -+ offset: MTDPART_OFS_APPEND, -+ } -+}; -+#else -+#error MTD_PB1550 define combo error /* should never happen */ -+#endif -+ -+#define NB_OF(x) (sizeof(x)/sizeof(x[0])) -+ -+static struct mtd_partition *parsed_parts; -+static struct mtd_info *mymtd; -+ -+/* -+ * Probe the flash density and setup window address and size -+ * based on user CONFIG options. There are times when we don't -+ * want the MTD driver to be probing the boot or user flash, -+ * so having the option to enable only one bank is important. -+ */ -+int setup_flash_params() -+{ -+ u16 boot_swapboot; -+ boot_swapboot = (au_readl(MEM_STSTAT) & (0x7<<1)) | -+ ((bcsr->status >> 6) & 0x1); -+ printk("Pb1550 MTD: boot:swap %d\n", boot_swapboot); -+ -+ switch (boot_swapboot) { -+ case 0: /* 512Mbit devices, both enabled */ -+ case 1: -+ case 8: -+ case 9: -+#if defined(PB1550_BOTH_BANKS) -+ window_addr = 0x18000000; -+ window_size = 0x8000000; -+#elif defined(PB1550_BOOT_ONLY) -+ window_addr = 0x1C000000; -+ window_size = 0x4000000; -+#else /* USER ONLY */ -+ window_addr = 0x1E000000; -+ window_size = 0x1000000; -+#endif -+ break; -+ case 0xC: -+ case 0xD: -+ case 0xE: -+ case 0xF: -+ /* 64 MB Boot NOR Flash is disabled */ -+ /* and the start address is moved to 0x0C00000 */ -+ window_addr = 0x0C000000; -+ window_size = 0x4000000; -+ default: -+ printk("Pb1550 MTD: unsupported boot:swap setting\n"); -+ return 1; -+ } -+ return 0; -+} -+ -+int __init pb1550_mtd_init(void) -+{ -+ struct mtd_partition *parts; -+ int nb_parts = 0; -+ char *part_type; -+ -+ /* Default flash buswidth */ -+ pb1550_map.buswidth = flash_buswidth; -+ -+ if (setup_flash_params()) -+ return -ENXIO; -+ -+ /* -+ * Static partition definition selection -+ */ -+ part_type = "static"; -+ parts = pb1550_partitions; -+ nb_parts = NB_OF(pb1550_partitions); -+ pb1550_map.size = window_size; -+ -+ /* -+ * Now let's probe for the actual flash. Do it here since -+ * specific machine settings might have been set above. -+ */ -+ printk(KERN_NOTICE "Pb1550 flash: probing %d-bit flash bus\n", -+ pb1550_map.buswidth*8); -+ pb1550_map.map_priv_1 = -+ (unsigned long)ioremap(window_addr, window_size); -+ mymtd = do_map_probe("cfi_probe", &pb1550_map); -+ if (!mymtd) return -ENXIO; -+ mymtd->module = THIS_MODULE; -+ -+ add_mtd_partitions(mymtd, parts, nb_parts); -+ return 0; -+} -+ -+static void __exit pb1550_mtd_cleanup(void) -+{ -+ if (mymtd) { -+ del_mtd_partitions(mymtd); -+ map_destroy(mymtd); -+ if (parsed_parts) -+ kfree(parsed_parts); -+ } -+} -+ -+module_init(pb1550_mtd_init); -+module_exit(pb1550_mtd_cleanup); -+ -+MODULE_AUTHOR("Embedded Edge, LLC"); -+MODULE_DESCRIPTION("Pb1550 mtd map driver"); -+MODULE_LICENSE("GPL"); ---- a/drivers/mtd/maps/pb1xxx-flash.c -+++ b/drivers/mtd/maps/pb1xxx-flash.c -@@ -192,6 +192,34 @@ static struct mtd_partition pb1xxx_parti - #else - #error MTD_PB1500 define combo error /* should never happen */ - #endif -+#elif defined(CONFIG_MTD_BOSPORUS) -+static unsigned char flash_buswidth = 2; -+static unsigned long flash_size = 0x02000000; -+#define WINDOW_ADDR 0x1F000000 -+#define WINDOW_SIZE 0x2000000 -+static struct mtd_partition pb1xxx_partitions[] = { -+ { -+ name: "User FS", -+ size: 0x00400000, -+ offset: 0x00000000, -+ },{ -+ name: "Yamon-2", -+ size: 0x00100000, -+ offset: 0x00400000, -+ },{ -+ name: "Root FS", -+ size: 0x00700000, -+ offset: 0x00500000, -+ },{ -+ name: "Yamon-1", -+ size: 0x00100000, -+ offset: 0x00C00000, -+ },{ -+ name: "Kernel", -+ size: 0x00300000, -+ offset: 0x00D00000, -+ } -+}; - #else - #error Unsupported board - #endif ---- /dev/null -+++ b/drivers/mtd/maps/xxs1500.c -@@ -0,0 +1,186 @@ -+/* -+ * Flash memory access on MyCable XXS1500 board -+ * -+ * (C) 2003 Pete Popov <ppopov@mvista.com> -+ * -+ * $Id: xxs1500.c,v 1.1.2.1 2003/06/13 21:15:46 ppopov Exp $ -+ */ -+ -+#include <linux/config.h> -+#include <linux/module.h> -+#include <linux/types.h> -+#include <linux/kernel.h> -+ -+#include <linux/mtd/mtd.h> -+#include <linux/mtd/map.h> -+#include <linux/mtd/partitions.h> -+ -+#include <asm/io.h> -+#include <asm/au1000.h> -+ -+#ifdef DEBUG_RW -+#define DBG(x...) printk(x) -+#else -+#define DBG(x...) -+#endif -+ -+#ifdef CONFIG_MIPS_XXS1500 -+#define WINDOW_ADDR 0x1F000000 -+#define WINDOW_SIZE 0x1000000 -+#endif -+ -+__u8 physmap_read8(struct map_info *map, unsigned long ofs) -+{ -+ __u8 ret; -+ ret = __raw_readb(map->map_priv_1 + ofs); -+ DBG("read8 from %x, %x\n", (unsigned)(map->map_priv_1 + ofs), ret); -+ return ret; -+} -+ -+__u16 physmap_read16(struct map_info *map, unsigned long ofs) -+{ -+ __u16 ret; -+ ret = __raw_readw(map->map_priv_1 + ofs); -+ DBG("read16 from %x, %x\n", (unsigned)(map->map_priv_1 + ofs), ret); -+ return ret; -+} -+ -+__u32 physmap_read32(struct map_info *map, unsigned long ofs) -+{ -+ __u32 ret; -+ ret = __raw_readl(map->map_priv_1 + ofs); -+ DBG("read32 from %x, %x\n", (unsigned)(map->map_priv_1 + ofs), ret); -+ return ret; -+} -+ -+void physmap_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len) -+{ -+ DBG("physmap_copy from %x to %x\n", (unsigned)from, (unsigned)to); -+ memcpy_fromio(to, map->map_priv_1 + from, len); -+} -+ -+void physmap_write8(struct map_info *map, __u8 d, unsigned long adr) -+{ -+ DBG("write8 at %x, %x\n", (unsigned)(map->map_priv_1 + adr), d); -+ __raw_writeb(d, map->map_priv_1 + adr); -+ mb(); -+} -+ -+void physmap_write16(struct map_info *map, __u16 d, unsigned long adr) -+{ -+ DBG("write16 at %x, %x\n", (unsigned)(map->map_priv_1 + adr), d); -+ __raw_writew(d, map->map_priv_1 + adr); -+ mb(); -+} -+ -+void physmap_write32(struct map_info *map, __u32 d, unsigned long adr) -+{ -+ DBG("write32 at %x, %x\n", (unsigned)(map->map_priv_1 + adr), d); -+ __raw_writel(d, map->map_priv_1 + adr); -+ mb(); -+} -+ -+void physmap_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len) -+{ -+ DBG("physmap_copy_to %x from %x\n", (unsigned)to, (unsigned)from); -+ memcpy_toio(map->map_priv_1 + to, from, len); -+} -+ -+ -+ -+static struct map_info xxs1500_map = { -+ name: "XXS1500 flash", -+ read8: physmap_read8, -+ read16: physmap_read16, -+ read32: physmap_read32, -+ copy_from: physmap_copy_from, -+ write8: physmap_write8, -+ write16: physmap_write16, -+ write32: physmap_write32, -+ copy_to: physmap_copy_to, -+}; -+ -+ -+static unsigned long flash_size = 0x00800000; -+static unsigned char flash_buswidth = 4; -+static struct mtd_partition xxs1500_partitions[] = { -+ { -+ name: "kernel image", -+ size: 0x00200000, -+ offset: 0, -+ },{ -+ name: "user fs 0", -+ size: (0x00C00000-0x200000), -+ offset: MTDPART_OFS_APPEND, -+ },{ -+ name: "yamon", -+ size: 0x00100000, -+ offset: MTDPART_OFS_APPEND, -+ mask_flags: MTD_WRITEABLE -+ },{ -+ name: "user fs 1", -+ size: 0x2c0000, -+ offset: MTDPART_OFS_APPEND, -+ },{ -+ name: "yamon env vars", -+ size: 0x040000, -+ offset: MTDPART_OFS_APPEND, -+ mask_flags: MTD_WRITEABLE -+ } -+}; -+ -+ -+#define NB_OF(x) (sizeof(x)/sizeof(x[0])) -+ -+static struct mtd_partition *parsed_parts; -+static struct mtd_info *mymtd; -+ -+int __init xxs1500_mtd_init(void) -+{ -+ struct mtd_partition *parts; -+ int nb_parts = 0; -+ char *part_type; -+ -+ /* Default flash buswidth */ -+ xxs1500_map.buswidth = flash_buswidth; -+ -+ /* -+ * Static partition definition selection -+ */ -+ part_type = "static"; -+ parts = xxs1500_partitions; -+ nb_parts = NB_OF(xxs1500_partitions); -+ xxs1500_map.size = flash_size; -+ -+ /* -+ * Now let's probe for the actual flash. Do it here since -+ * specific machine settings might have been set above. -+ */ -+ printk(KERN_NOTICE "XXS1500 flash: probing %d-bit flash bus\n", -+ xxs1500_map.buswidth*8); -+ xxs1500_map.map_priv_1 = -+ (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE); -+ mymtd = do_map_probe("cfi_probe", &xxs1500_map); -+ if (!mymtd) return -ENXIO; -+ mymtd->module = THIS_MODULE; -+ -+ add_mtd_partitions(mymtd, parts, nb_parts); -+ return 0; -+} -+ -+static void __exit xxs1500_mtd_cleanup(void) -+{ -+ if (mymtd) { -+ del_mtd_partitions(mymtd); -+ map_destroy(mymtd); -+ if (parsed_parts) -+ kfree(parsed_parts); -+ } -+} -+ -+module_init(xxs1500_mtd_init); -+module_exit(xxs1500_mtd_cleanup); -+ -+MODULE_AUTHOR("Pete Popov"); -+MODULE_DESCRIPTION("XXS1500 CFI map driver"); -+MODULE_LICENSE("GPL"); ---- a/drivers/net/defxx.c -+++ b/drivers/net/defxx.c -@@ -10,24 +10,18 @@ - * - * Abstract: - * A Linux device driver supporting the Digital Equipment Corporation -- * FDDI EISA and PCI controller families. Supported adapters include: -+ * FDDI TURBOchannel, EISA and PCI controller families. Supported -+ * adapters include: - * -- * DEC FDDIcontroller/EISA (DEFEA) -- * DEC FDDIcontroller/PCI (DEFPA) -+ * DEC FDDIcontroller/TURBOchannel (DEFTA) -+ * DEC FDDIcontroller/EISA (DEFEA) -+ * DEC FDDIcontroller/PCI (DEFPA) - * -- * Maintainers: -- * LVS Lawrence V. Stefani -- * -- * Contact: -- * The author may be reached at: -+ * The original author: -+ * LVS Lawrence V. Stefani <lstefani@yahoo.com> - * -- * Inet: stefani@lkg.dec.com -- * (NOTE! this address no longer works -jgarzik) -- * -- * Mail: Digital Equipment Corporation -- * 550 King Street -- * M/S: LKG1-3/M07 -- * Littleton, MA 01460 -+ * Maintainers: -+ * macro Maciej W. Rozycki <macro@linux-mips.org> - * - * Credits: - * I'd like to thank Patricia Cross for helping me get started with -@@ -197,16 +191,16 @@ - * Sep 2000 tjeerd Fix leak on unload, cosmetic code cleanup - * Feb 2001 Skb allocation fixes - * Feb 2001 davej PCI enable cleanups. -+ * 04 Aug 2003 macro Converted to the DMA API. -+ * 14 Aug 2004 macro Fix device names reported. -+ * 26 Sep 2004 macro TURBOchannel support. - */ - - /* Include files */ - - #include <linux/module.h> -- - #include <linux/kernel.h> --#include <linux/sched.h> - #include <linux/string.h> --#include <linux/ptrace.h> - #include <linux/errno.h> - #include <linux/ioport.h> - #include <linux/slab.h> -@@ -215,19 +209,33 @@ - #include <linux/delay.h> - #include <linux/init.h> - #include <linux/netdevice.h> -+#include <linux/fddidevice.h> -+#include <linux/skbuff.h> -+ - #include <asm/byteorder.h> - #include <asm/bitops.h> - #include <asm/io.h> - --#include <linux/fddidevice.h> --#include <linux/skbuff.h> -+#ifdef CONFIG_TC -+#include <asm/dec/tc.h> -+#else -+static int search_tc_card(const char *name) { return -ENODEV; } -+static void claim_tc_card(int slot) { } -+static void release_tc_card(int slot) { } -+static unsigned long get_tc_base_addr(int slot) { return 0; } -+static unsigned long get_tc_irq_nr(int slot) { return -1; } -+#endif - - #include "defxx.h" - --/* Version information string - should be updated prior to each new release!!! */ -+/* Version information string should be updated prior to each new release! */ -+#define DRV_NAME "defxx" -+#define DRV_VERSION "v1.07T" -+#define DRV_RELDATE "2004/09/26" - - static char version[] __devinitdata = -- "defxx.c:v1.05e 2001/02/03 Lawrence V. Stefani and others\n"; -+ DRV_NAME ": " DRV_VERSION " " DRV_RELDATE -+ " Lawrence V. Stefani and others\n"; - - #define DYNAMIC_BUFFERS 1 - -@@ -243,7 +251,7 @@ static char version[] __devinitdata = - static void dfx_bus_init(struct net_device *dev); - static void dfx_bus_config_check(DFX_board_t *bp); - --static int dfx_driver_init(struct net_device *dev); -+static int dfx_driver_init(struct net_device *dev, const char *print_name); - static int dfx_adap_init(DFX_board_t *bp, int get_buffers); - - static int dfx_open(struct net_device *dev); -@@ -337,48 +345,84 @@ static inline void dfx_port_write_byte( - int offset, - u8 data - ) -+{ -+ if (bp->bus_type == DFX_BUS_TYPE_TC) -+ { -+ volatile u8 *addr = (void *)(bp->base_addr + offset); - -+ *addr = data; -+ mb(); -+ } -+ else - { - u16 port = bp->base_addr + offset; - - outb(data, port); - } -+} - - static inline void dfx_port_read_byte( - DFX_board_t *bp, - int offset, - u8 *data - ) -+{ -+ if (bp->bus_type == DFX_BUS_TYPE_TC) -+ { -+ volatile u8 *addr = (void *)(bp->base_addr + offset); - -+ mb(); -+ *data = *addr; -+ } -+ else - { - u16 port = bp->base_addr + offset; - - *data = inb(port); - } -+} - - static inline void dfx_port_write_long( - DFX_board_t *bp, - int offset, - u32 data - ) -+{ -+ if (bp->bus_type == DFX_BUS_TYPE_TC) -+ { -+ volatile u32 *addr = (void *)(bp->base_addr + offset); - -+ *addr = data; -+ mb(); -+ } -+ else - { - u16 port = bp->base_addr + offset; - - outl(data, port); - } -+} - - static inline void dfx_port_read_long( - DFX_board_t *bp, - int offset, - u32 *data - ) -+{ -+ if (bp->bus_type == DFX_BUS_TYPE_TC) -+ { -+ volatile u32 *addr = (void *)(bp->base_addr + offset); - -+ mb(); -+ *data = *addr; -+ } -+ else - { - u16 port = bp->base_addr + offset; - - *data = inl(port); - } -+} - - - /* -@@ -393,8 +437,9 @@ static inline void dfx_port_read_long( - * Condition code - * - * Arguments: -- * pdev - pointer to pci device information (NULL for EISA) -- * ioaddr - pointer to port (NULL for PCI) -+ * pdev - pointer to pci device information (NULL for EISA or TURBOchannel) -+ * bus_type - bus type (one of DFX_BUS_TYPE_*) -+ * handle - bus-specific data: slot (TC), pointer to port (EISA), NULL (PCI) - * - * Functional Description: - * -@@ -410,54 +455,68 @@ static inline void dfx_port_read_long( - * initialized and the board resources are read and stored in - * the device structure. - */ --static int __devinit dfx_init_one_pci_or_eisa(struct pci_dev *pdev, long ioaddr) -+static int __devinit dfx_init_one_pci_or_eisa(struct pci_dev *pdev, u32 bus_type, long handle) - { -+ static int version_disp; -+ char *print_name = DRV_NAME; - struct net_device *dev; - DFX_board_t *bp; /* board pointer */ -+ long ioaddr; /* pointer to port */ -+ unsigned long len; /* resource length */ -+ int alloc_size; /* total buffer size used */ - int err; - --#ifndef MODULE -- static int version_disp; -- -- if (!version_disp) /* display version info if adapter is found */ -- { -+ if (!version_disp) { /* display version info if adapter is found */ - version_disp = 1; /* set display flag to TRUE so that */ - printk(version); /* we only display this string ONCE */ - } --#endif - -- /* -- * init_fddidev() allocates a device structure with private data, clears the device structure and private data, -- * and calls fddi_setup() and register_netdev(). Not much left to do for us here. -- */ -- dev = init_fddidev(NULL, sizeof(*bp)); -+ if (pdev != NULL) -+ print_name = pdev->slot_name; -+ -+ dev = alloc_fddidev(sizeof(*bp)); - if (!dev) { -- printk (KERN_ERR "defxx: unable to allocate fddidev, aborting\n"); -+ printk(KERN_ERR "%s: unable to allocate fddidev, aborting\n", -+ print_name); - return -ENOMEM; - } - - /* Enable PCI device. */ -- if (pdev != NULL) { -+ if (bus_type == DFX_BUS_TYPE_PCI) { - err = pci_enable_device (pdev); - if (err) goto err_out; - ioaddr = pci_resource_start (pdev, 1); - } - - SET_MODULE_OWNER(dev); -+ SET_NETDEV_DEV(dev, &pdev->dev); - - bp = dev->priv; - -- if (!request_region (ioaddr, pdev ? PFI_K_CSR_IO_LEN : PI_ESIC_K_CSR_IO_LEN, dev->name)) { -- printk (KERN_ERR "%s: Cannot reserve I/O resource 0x%x @ 0x%lx, aborting\n", -- dev->name, PFI_K_CSR_IO_LEN, ioaddr); -+ if (bus_type == DFX_BUS_TYPE_TC) { -+ /* TURBOchannel board */ -+ bp->slot = handle; -+ claim_tc_card(bp->slot); -+ ioaddr = get_tc_base_addr(handle) + PI_TC_K_CSR_OFFSET; -+ len = PI_TC_K_CSR_LEN; -+ } else if (bus_type == DFX_BUS_TYPE_EISA) { -+ /* EISA board */ -+ ioaddr = handle; -+ len = PI_ESIC_K_CSR_IO_LEN; -+ } else -+ /* PCI board */ -+ len = PFI_K_CSR_IO_LEN; -+ dev->base_addr = ioaddr; /* save port (I/O) base address */ -+ -+ if (!request_region(ioaddr, len, print_name)) { -+ printk(KERN_ERR "%s: Cannot reserve I/O resource " -+ "0x%lx @ 0x%lx, aborting\n", print_name, len, ioaddr); - err = -EBUSY; - goto err_out; - } - - /* Initialize new device structure */ - -- dev->base_addr = ioaddr; /* save port (I/O) base address */ -- - dev->get_stats = dfx_ctl_get_stats; - dev->open = dfx_open; - dev->stop = dfx_close; -@@ -465,37 +524,54 @@ static int __devinit dfx_init_one_pci_or - dev->set_multicast_list = dfx_ctl_set_multicast_list; - dev->set_mac_address = dfx_ctl_set_mac_address; - -- if (pdev == NULL) { -- /* EISA board */ -- bp->bus_type = DFX_BUS_TYPE_EISA; -+ bp->bus_type = bus_type; -+ if (bus_type == DFX_BUS_TYPE_TC || bus_type == DFX_BUS_TYPE_EISA) { -+ /* TURBOchannel or EISA board */ - bp->next = root_dfx_eisa_dev; - root_dfx_eisa_dev = dev; - } else { - /* PCI board */ -- bp->bus_type = DFX_BUS_TYPE_PCI; - bp->pci_dev = pdev; - pci_set_drvdata (pdev, dev); - pci_set_master (pdev); - } - -- if (dfx_driver_init(dev) != DFX_K_SUCCESS) { -+ -+ if (dfx_driver_init(dev, print_name) != DFX_K_SUCCESS) { - err = -ENODEV; - goto err_out_region; - } - -+ err = register_netdev(dev); -+ if (err) -+ goto err_out_kfree; -+ -+ printk("%s: registered as %s\n", print_name, dev->name); - return 0; - -+err_out_kfree: -+ alloc_size = sizeof(PI_DESCR_BLOCK) + -+ PI_CMD_REQ_K_SIZE_MAX + PI_CMD_RSP_K_SIZE_MAX + -+#ifndef DYNAMIC_BUFFERS -+ (bp->rcv_bufs_to_post * PI_RCV_DATA_K_SIZE_MAX) + -+#endif -+ sizeof(PI_CONSUMER_BLOCK) + -+ (PI_ALIGN_K_DESC_BLK - 1); -+ if (bp->kmalloced) -+ pci_free_consistent(pdev, alloc_size, -+ bp->kmalloced, bp->kmalloced_dma); - err_out_region: -- release_region(ioaddr, pdev ? PFI_K_CSR_IO_LEN : PI_ESIC_K_CSR_IO_LEN); -+ release_region(ioaddr, len); - err_out: -- unregister_netdev(dev); -- kfree(dev); -+ if (bp->bus_type == DFX_BUS_TYPE_TC) -+ release_tc_card(bp->slot); -+ free_netdev(dev); - return err; - } - - static int __devinit dfx_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) - { -- return dfx_init_one_pci_or_eisa(pdev, 0); -+ return dfx_init_one_pci_or_eisa(pdev, DFX_BUS_TYPE_PCI, 0); - } - - static int __init dfx_eisa_init(void) -@@ -507,6 +583,7 @@ static int __init dfx_eisa_init(void) - - DBG_printk("In dfx_eisa_init...\n"); - -+#ifdef CONFIG_EISA - /* Scan for FDDI EISA controllers */ - - for (i=0; i < DFX_MAX_EISA_SLOTS; i++) /* only scan for up to 16 EISA slots */ -@@ -517,9 +594,27 @@ static int __init dfx_eisa_init(void) - { - port = (i << 12); /* recalc base addr */ - -- if (dfx_init_one_pci_or_eisa(NULL, port) == 0) rc = 0; -+ if (dfx_init_one_pci_or_eisa(NULL, DFX_BUS_TYPE_EISA, port) == 0) rc = 0; - } - } -+#endif -+ return rc; -+} -+ -+static int __init dfx_tc_init(void) -+{ -+ int rc = -ENODEV; -+ int slot; /* TC slot number */ -+ -+ DBG_printk("In dfx_tc_init...\n"); -+ -+ /* Scan for FDDI TC controllers */ -+ while ((slot = search_tc_card("PMAF-F")) >= 0) { -+ if (dfx_init_one_pci_or_eisa(NULL, DFX_BUS_TYPE_TC, slot) == 0) -+ rc = 0; -+ else -+ break; -+ } - return rc; - } - -@@ -583,8 +678,9 @@ static void __devinit dfx_bus_init(struc - - /* Initialize adapter based on bus type */ - -- if (bp->bus_type == DFX_BUS_TYPE_EISA) -- { -+ if (bp->bus_type == DFX_BUS_TYPE_TC) { -+ dev->irq = get_tc_irq_nr(bp->slot); -+ } else if (bp->bus_type == DFX_BUS_TYPE_EISA) { - /* Get the interrupt level from the ESIC chip */ - - dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &val); -@@ -766,6 +862,7 @@ static void __devinit dfx_bus_config_che - * - * Arguments: - * dev - pointer to device information -+ * print_name - printable device name - * - * Functional Description: - * This function allocates additional resources such as the host memory -@@ -780,20 +877,21 @@ static void __devinit dfx_bus_config_che - * or read adapter MAC address - * - * Assumptions: -- * Memory allocated from kmalloc() call is physically contiguous, locked -- * memory whose physical address equals its virtual address. -+ * Memory allocated from pci_alloc_consistent() call is physically -+ * contiguous, locked memory. - * - * Side Effects: - * Adapter is reset and should be in DMA_UNAVAILABLE state before - * returning from this routine. - */ - --static int __devinit dfx_driver_init(struct net_device *dev) -+static int __devinit dfx_driver_init(struct net_device *dev, -+ const char *print_name) - { - DFX_board_t *bp = dev->priv; - int alloc_size; /* total buffer size needed */ - char *top_v, *curr_v; /* virtual addrs into memory block */ -- u32 top_p, curr_p; /* physical addrs into memory block */ -+ dma_addr_t top_p, curr_p; /* physical addrs into memory block */ - u32 data; /* host data register value */ - - DBG_printk("In dfx_driver_init...\n"); -@@ -837,26 +935,20 @@ static int __devinit dfx_driver_init(str - - /* Read the factory MAC address from the adapter then save it */ - -- if (dfx_hw_port_ctrl_req(bp, -- PI_PCTRL_M_MLA, -- PI_PDATA_A_MLA_K_LO, -- 0, -- &data) != DFX_K_SUCCESS) -- { -- printk("%s: Could not read adapter factory MAC address!\n", dev->name); -+ if (dfx_hw_port_ctrl_req(bp, PI_PCTRL_M_MLA, PI_PDATA_A_MLA_K_LO, 0, -+ &data) != DFX_K_SUCCESS) { -+ printk("%s: Could not read adapter factory MAC address!\n", -+ print_name); - return(DFX_K_FAILURE); -- } -+ } - memcpy(&bp->factory_mac_addr[0], &data, sizeof(u32)); - -- if (dfx_hw_port_ctrl_req(bp, -- PI_PCTRL_M_MLA, -- PI_PDATA_A_MLA_K_HI, -- 0, -- &data) != DFX_K_SUCCESS) -- { -- printk("%s: Could not read adapter factory MAC address!\n", dev->name); -+ if (dfx_hw_port_ctrl_req(bp, PI_PCTRL_M_MLA, PI_PDATA_A_MLA_K_HI, 0, -+ &data) != DFX_K_SUCCESS) { -+ printk("%s: Could not read adapter factory MAC address!\n", -+ print_name); - return(DFX_K_FAILURE); -- } -+ } - memcpy(&bp->factory_mac_addr[4], &data, sizeof(u16)); - - /* -@@ -867,28 +959,27 @@ static int __devinit dfx_driver_init(str - */ - - memcpy(dev->dev_addr, bp->factory_mac_addr, FDDI_K_ALEN); -- if (bp->bus_type == DFX_BUS_TYPE_EISA) -- printk("%s: DEFEA at I/O addr = 0x%lX, IRQ = %d, Hardware addr = %02X-%02X-%02X-%02X-%02X-%02X\n", -- dev->name, -- dev->base_addr, -- dev->irq, -- dev->dev_addr[0], -- dev->dev_addr[1], -- dev->dev_addr[2], -- dev->dev_addr[3], -- dev->dev_addr[4], -- dev->dev_addr[5]); -+ if (bp->bus_type == DFX_BUS_TYPE_TC) -+ printk("%s: DEFTA at addr = 0x%lX, IRQ = %d, " -+ "Hardware addr = %02X-%02X-%02X-%02X-%02X-%02X\n", -+ print_name, dev->base_addr, dev->irq, -+ dev->dev_addr[0], dev->dev_addr[1], -+ dev->dev_addr[2], dev->dev_addr[3], -+ dev->dev_addr[4], dev->dev_addr[5]); -+ else if (bp->bus_type == DFX_BUS_TYPE_EISA) -+ printk("%s: DEFEA at I/O addr = 0x%lX, IRQ = %d, " -+ "Hardware addr = %02X-%02X-%02X-%02X-%02X-%02X\n", -+ print_name, dev->base_addr, dev->irq, -+ dev->dev_addr[0], dev->dev_addr[1], -+ dev->dev_addr[2], dev->dev_addr[3], -+ dev->dev_addr[4], dev->dev_addr[5]); - else -- printk("%s: DEFPA at I/O addr = 0x%lX, IRQ = %d, Hardware addr = %02X-%02X-%02X-%02X-%02X-%02X\n", -- dev->name, -- dev->base_addr, -- dev->irq, -- dev->dev_addr[0], -- dev->dev_addr[1], -- dev->dev_addr[2], -- dev->dev_addr[3], -- dev->dev_addr[4], -- dev->dev_addr[5]); -+ printk("%s: DEFPA at I/O addr = 0x%lX, IRQ = %d, " -+ "Hardware addr = %02X-%02X-%02X-%02X-%02X-%02X\n", -+ print_name, dev->base_addr, dev->irq, -+ dev->dev_addr[0], dev->dev_addr[1], -+ dev->dev_addr[2], dev->dev_addr[3], -+ dev->dev_addr[4], dev->dev_addr[5]); - - /* - * Get memory for descriptor block, consumer block, and other buffers -@@ -903,14 +994,15 @@ static int __devinit dfx_driver_init(str - #endif - sizeof(PI_CONSUMER_BLOCK) + - (PI_ALIGN_K_DESC_BLK - 1); -- bp->kmalloced = top_v = (char *) kmalloc(alloc_size, GFP_KERNEL); -- if (top_v == NULL) -- { -- printk("%s: Could not allocate memory for host buffers and structures!\n", dev->name); -+ bp->kmalloced = top_v = pci_alloc_consistent(bp->pci_dev, alloc_size, -+ &bp->kmalloced_dma); -+ if (top_v == NULL) { -+ printk("%s: Could not allocate memory for host buffers " -+ "and structures!\n", print_name); - return(DFX_K_FAILURE); -- } -+ } - memset(top_v, 0, alloc_size); /* zero out memory before continuing */ -- top_p = virt_to_bus(top_v); /* get physical address of buffer */ -+ top_p = bp->kmalloced_dma; /* get physical address of buffer */ - - /* - * To guarantee the 8K alignment required for the descriptor block, 8K - 1 -@@ -924,7 +1016,7 @@ static int __devinit dfx_driver_init(str - * for allocating the needed memory. - */ - -- curr_p = (u32) (ALIGN(top_p, PI_ALIGN_K_DESC_BLK)); -+ curr_p = ALIGN(top_p, PI_ALIGN_K_DESC_BLK); - curr_v = top_v + (curr_p - top_p); - - /* Reserve space for descriptor block */ -@@ -965,14 +1057,20 @@ static int __devinit dfx_driver_init(str - - /* Display virtual and physical addresses if debug driver */ - -- DBG_printk("%s: Descriptor block virt = %0lX, phys = %0X\n", dev->name, (long)bp->descr_block_virt, bp->descr_block_phys); -- DBG_printk("%s: Command Request buffer virt = %0lX, phys = %0X\n", dev->name, (long)bp->cmd_req_virt, bp->cmd_req_phys); -- DBG_printk("%s: Command Response buffer virt = %0lX, phys = %0X\n", dev->name, (long)bp->cmd_rsp_virt, bp->cmd_rsp_phys); -- DBG_printk("%s: Receive buffer block virt = %0lX, phys = %0X\n", dev->name, (long)bp->rcv_block_virt, bp->rcv_block_phys); -- DBG_printk("%s: Consumer block virt = %0lX, phys = %0X\n", dev->name, (long)bp->cons_block_virt, bp->cons_block_phys); -+ DBG_printk("%s: Descriptor block virt = %0lX, phys = %0X\n", -+ print_name, -+ (long)bp->descr_block_virt, bp->descr_block_phys); -+ DBG_printk("%s: Command Request buffer virt = %0lX, phys = %0X\n", -+ print_name, (long)bp->cmd_req_virt, bp->cmd_req_phys); -+ DBG_printk("%s: Command Response buffer virt = %0lX, phys = %0X\n", -+ print_name, (long)bp->cmd_rsp_virt, bp->cmd_rsp_phys); -+ DBG_printk("%s: Receive buffer block virt = %0lX, phys = %0X\n", -+ print_name, (long)bp->rcv_block_virt, bp->rcv_block_phys); -+ DBG_printk("%s: Consumer block virt = %0lX, phys = %0X\n", -+ print_name, (long)bp->cons_block_virt, bp->cons_block_phys); - - return(DFX_K_SUCCESS); -- } -+} - - - /* -@@ -1218,7 +1316,9 @@ static int dfx_open(struct net_device *d - - /* Register IRQ - support shared interrupts by passing device ptr */ - -- ret = request_irq(dev->irq, (void *)dfx_interrupt, SA_SHIRQ, dev->name, dev); -+ ret = request_irq(dev->irq, (void *)dfx_interrupt, -+ (bp->bus_type == DFX_BUS_TYPE_TC) ? 0 : SA_SHIRQ, -+ dev->name, dev); - if (ret) { - printk(KERN_ERR "%s: Requested IRQ %d is busy\n", dev->name, dev->irq); - return ret; -@@ -1737,7 +1837,7 @@ static void dfx_interrupt(int irq, void - dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL, - (PFI_MODE_M_PDQ_INT_ENB + PFI_MODE_M_DMA_ENB)); - } -- else -+ else if (bp->bus_type == DFX_BUS_TYPE_EISA) - { - /* Disable interrupts at the ESIC */ - -@@ -1755,6 +1855,13 @@ static void dfx_interrupt(int irq, void - tmp |= PI_CONFIG_STAT_0_M_INT_ENB; - dfx_port_write_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, tmp); - } -+ else { -+ /* TC doesn't share interrupts so no need to disable them */ -+ -+ /* Call interrupt service routine for this adapter */ -+ -+ dfx_int_common(dev); -+ } - - spin_unlock(&bp->lock); - } -@@ -2663,12 +2770,12 @@ static int dfx_hw_dma_uninit(DFX_board_t - - static void my_skb_align(struct sk_buff *skb, int n) - { -- u32 x=(u32)skb->data; /* We only want the low bits .. */ -- u32 v; -+ unsigned long x = (unsigned long)skb->data; -+ unsigned long v; - -- v=(x+n-1)&~(n-1); /* Where we want to be */ -+ v = ALIGN(x, n); /* Where we want to be */ - -- skb_reserve(skb, v-x); -+ skb_reserve(skb, v - x); - } - - -@@ -2745,7 +2852,10 @@ static int dfx_rcv_init(DFX_board_t *bp, - */ - - my_skb_align(newskb, 128); -- bp->descr_block_virt->rcv_data[i+j].long_1 = virt_to_bus(newskb->data); -+ bp->descr_block_virt->rcv_data[i + j].long_1 = -+ (u32)pci_map_single(bp->pci_dev, newskb->data, -+ NEW_SKB_SIZE, -+ PCI_DMA_FROMDEVICE); - /* - * p_rcv_buff_va is only used inside the - * kernel so we put the skb pointer here. -@@ -2859,9 +2969,17 @@ static void dfx_rcv_queue_process( - - my_skb_align(newskb, 128); - skb = (struct sk_buff *)bp->p_rcv_buff_va[entry]; -+ pci_unmap_single(bp->pci_dev, -+ bp->descr_block_virt->rcv_data[entry].long_1, -+ NEW_SKB_SIZE, -+ PCI_DMA_FROMDEVICE); - skb_reserve(skb, RCV_BUFF_K_PADDING); - bp->p_rcv_buff_va[entry] = (char *)newskb; -- bp->descr_block_virt->rcv_data[entry].long_1 = virt_to_bus(newskb->data); -+ bp->descr_block_virt->rcv_data[entry].long_1 = -+ (u32)pci_map_single(bp->pci_dev, -+ newskb->data, -+ NEW_SKB_SIZE, -+ PCI_DMA_FROMDEVICE); - } else - skb = NULL; - } else -@@ -2934,7 +3052,7 @@ static void dfx_rcv_queue_process( - * is contained in a single physically contiguous buffer - * in which the virtual address of the start of packet - * (skb->data) can be converted to a physical address -- * by using virt_to_bus(). -+ * by using pci_map_single(). - * - * Since the adapter architecture requires a three byte - * packet request header to prepend the start of packet, -@@ -3082,12 +3200,13 @@ static int dfx_xmt_queue_pkt( - * skb->data. - * 6. The physical address of the start of packet - * can be determined from the virtual address -- * by using virt_to_bus() and is only 32-bits -+ * by using pci_map_single() and is only 32-bits - * wide. - */ - - p_xmt_descr->long_0 = (u32) (PI_XMT_DESCR_M_SOP | PI_XMT_DESCR_M_EOP | ((skb->len) << PI_XMT_DESCR_V_SEG_LEN)); -- p_xmt_descr->long_1 = (u32) virt_to_bus(skb->data); -+ p_xmt_descr->long_1 = (u32)pci_map_single(bp->pci_dev, skb->data, -+ skb->len, PCI_DMA_TODEVICE); - - /* - * Verify that descriptor is actually available -@@ -3171,6 +3290,7 @@ static int dfx_xmt_done(DFX_board_t *bp) - { - XMT_DRIVER_DESCR *p_xmt_drv_descr; /* ptr to transmit driver descriptor */ - PI_TYPE_2_CONSUMER *p_type_2_cons; /* ptr to rcv/xmt consumer block register */ -+ u8 comp; /* local transmit completion index */ - int freed = 0; /* buffers freed */ - - /* Service all consumed transmit frames */ -@@ -3188,7 +3308,11 @@ static int dfx_xmt_done(DFX_board_t *bp) - bp->xmt_total_bytes += p_xmt_drv_descr->p_skb->len; - - /* Return skb to operating system */ -- -+ comp = bp->rcv_xmt_reg.index.xmt_comp; -+ pci_unmap_single(bp->pci_dev, -+ bp->descr_block_virt->xmt_data[comp].long_1, -+ p_xmt_drv_descr->p_skb->len, -+ PCI_DMA_TODEVICE); - dev_kfree_skb_irq(p_xmt_drv_descr->p_skb); - - /* -@@ -3297,6 +3421,7 @@ static void dfx_xmt_flush( DFX_board_t * - { - u32 prod_cons; /* rcv/xmt consumer block longword */ - XMT_DRIVER_DESCR *p_xmt_drv_descr; /* ptr to transmit driver descriptor */ -+ u8 comp; /* local transmit completion index */ - - /* Flush all outstanding transmit frames */ - -@@ -3307,7 +3432,11 @@ static void dfx_xmt_flush( DFX_board_t * - p_xmt_drv_descr = &(bp->xmt_drv_descr_blk[bp->rcv_xmt_reg.index.xmt_comp]); - - /* Return skb to operating system */ -- -+ comp = bp->rcv_xmt_reg.index.xmt_comp; -+ pci_unmap_single(bp->pci_dev, -+ bp->descr_block_virt->xmt_data[comp].long_1, -+ p_xmt_drv_descr->p_skb->len, -+ PCI_DMA_TODEVICE); - dev_kfree_skb(p_xmt_drv_descr->p_skb); - - /* Increment transmit error counter */ -@@ -3337,12 +3466,36 @@ static void dfx_xmt_flush( DFX_board_t * - - static void __devexit dfx_remove_one_pci_or_eisa(struct pci_dev *pdev, struct net_device *dev) - { -- DFX_board_t *bp = dev->priv; -+ DFX_board_t *bp = dev->priv; -+ unsigned long len; /* resource length */ -+ int alloc_size; /* total buffer size used */ - -+ if (bp->bus_type == DFX_BUS_TYPE_TC) { -+ /* TURBOchannel board */ -+ len = PI_TC_K_CSR_LEN; -+ } else if (bp->bus_type == DFX_BUS_TYPE_EISA) { -+ /* EISA board */ -+ len = PI_ESIC_K_CSR_IO_LEN; -+ } else { -+ len = PFI_K_CSR_IO_LEN; -+ } - unregister_netdev(dev); -- release_region(dev->base_addr, pdev ? PFI_K_CSR_IO_LEN : PI_ESIC_K_CSR_IO_LEN ); -- if (bp->kmalloced) kfree(bp->kmalloced); -- kfree(dev); -+ release_region(dev->base_addr, len); -+ -+ if (bp->bus_type == DFX_BUS_TYPE_TC) -+ release_tc_card(bp->slot); -+ -+ alloc_size = sizeof(PI_DESCR_BLOCK) + -+ PI_CMD_REQ_K_SIZE_MAX + PI_CMD_RSP_K_SIZE_MAX + -+#ifndef DYNAMIC_BUFFERS -+ (bp->rcv_bufs_to_post * PI_RCV_DATA_K_SIZE_MAX) + -+#endif -+ sizeof(PI_CONSUMER_BLOCK) + -+ (PI_ALIGN_K_DESC_BLK - 1); -+ if (bp->kmalloced) -+ pci_free_consistent(pdev, alloc_size, bp->kmalloced, -+ bp->kmalloced_dma); -+ free_netdev(dev); - } - - static void __devexit dfx_remove_one (struct pci_dev *pdev) -@@ -3353,21 +3506,22 @@ static void __devexit dfx_remove_one (st - pci_set_drvdata(pdev, NULL); - } - --static struct pci_device_id dfx_pci_tbl[] __devinitdata = { -+static struct pci_device_id dfx_pci_tbl[] = { - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_FDDI, PCI_ANY_ID, PCI_ANY_ID, }, - { 0, } - }; - MODULE_DEVICE_TABLE(pci, dfx_pci_tbl); - - static struct pci_driver dfx_driver = { -- name: "defxx", -- probe: dfx_init_one, -- remove: __devexit_p(dfx_remove_one), -- id_table: dfx_pci_tbl, -+ .name = "defxx", -+ .probe = dfx_init_one, -+ .remove = __devexit_p(dfx_remove_one), -+ .id_table = dfx_pci_tbl, - }; - - static int dfx_have_pci; - static int dfx_have_eisa; -+static int dfx_have_tc; - - - static void __exit dfx_eisa_cleanup(void) -@@ -3388,12 +3542,7 @@ static void __exit dfx_eisa_cleanup(void - - static int __init dfx_init(void) - { -- int rc_pci, rc_eisa; -- --/* when a module, this is printed whether or not devices are found in probe */ --#ifdef MODULE -- printk(version); --#endif -+ int rc_pci, rc_eisa, rc_tc; - - rc_pci = pci_module_init(&dfx_driver); - if (rc_pci >= 0) dfx_have_pci = 1; -@@ -3401,20 +3550,27 @@ static int __init dfx_init(void) - rc_eisa = dfx_eisa_init(); - if (rc_eisa >= 0) dfx_have_eisa = 1; - -- return ((rc_eisa < 0) ? 0 : rc_eisa) + ((rc_pci < 0) ? 0 : rc_pci); -+ rc_tc = dfx_tc_init(); -+ if (rc_tc >= 0) dfx_have_tc = 1; -+ -+ return ((rc_tc < 0) ? 0 : rc_tc) + -+ ((rc_eisa < 0) ? 0 : rc_eisa) + -+ ((rc_pci < 0) ? 0 : rc_pci); - } - - static void __exit dfx_cleanup(void) - { - if (dfx_have_pci) - pci_unregister_driver(&dfx_driver); -- if (dfx_have_eisa) -+ if (dfx_have_eisa || dfx_have_tc) - dfx_eisa_cleanup(); -- - } - - module_init(dfx_init); - module_exit(dfx_cleanup); -+MODULE_AUTHOR("Lawrence V. Stefani"); -+MODULE_DESCRIPTION("DEC FDDIcontroller EISA/PCI (DEFEA/DEFPA) driver " -+ DRV_VERSION " " DRV_RELDATE); - MODULE_LICENSE("GPL"); - - ---- a/drivers/net/defxx.h -+++ b/drivers/net/defxx.h -@@ -12,17 +12,11 @@ - * Contains all definitions specified by port specification and required - * by the defxx.c driver. - * -- * Maintainers: -- * LVS Lawrence V. Stefani -- * -- * Contact: -- * The author may be reached at: -+ * The original author: -+ * LVS Lawrence V. Stefani <lstefani@yahoo.com> - * -- * Inet: stefani@lkg.dec.com -- * Mail: Digital Equipment Corporation -- * 550 King Street -- * M/S: LKG1-3/M07 -- * Littleton, MA 01460 -+ * Maintainers: -+ * macro Maciej W. Rozycki <macro@linux-mips.org> - * - * Modification History: - * Date Name Description -@@ -30,6 +24,7 @@ - * 09-Sep-96 LVS Added group_prom field. Moved read/write I/O - * macros to DEFXX.C. - * 12-Sep-96 LVS Removed packet request header pointers. -+ * 04 Aug 2003 macro Converted to the DMA API. - */ - - #ifndef _DEFXX_H_ -@@ -1467,6 +1462,11 @@ typedef union - - #endif /* #ifndef BIG_ENDIAN */ - -+/* Define TC PDQ CSR offset and length */ -+ -+#define PI_TC_K_CSR_OFFSET 0x100000 -+#define PI_TC_K_CSR_LEN 0x80 /* 128 bytes */ -+ - /* Define EISA controller register offsets */ - - #define PI_ESIC_K_BURST_HOLDOFF 0x040 -@@ -1634,6 +1634,7 @@ typedef union - - #define DFX_BUS_TYPE_PCI 0 /* type code for DEC FDDIcontroller/PCI */ - #define DFX_BUS_TYPE_EISA 1 /* type code for DEC FDDIcontroller/EISA */ -+#define DFX_BUS_TYPE_TC 2 /* type code for DEC FDDIcontroller/TURBOchannel */ - - #define DFX_FC_PRH2_PRH1_PRH0 0x54003820 /* Packet Request Header bytes + FC */ - #define DFX_PRH0_BYTE 0x20 /* Packet Request Header byte 0 */ -@@ -1704,17 +1705,19 @@ typedef struct DFX_board_tag - { - /* Keep virtual and physical pointers to locked, physically contiguous memory */ - -- char *kmalloced; /* kfree this on unload */ -+ char *kmalloced; /* pci_free_consistent this on unload */ -+ dma_addr_t kmalloced_dma; -+ /* DMA handle for the above */ - PI_DESCR_BLOCK *descr_block_virt; /* PDQ descriptor block virt address */ -- u32 descr_block_phys; /* PDQ descriptor block phys address */ -+ dma_addr_t descr_block_phys; /* PDQ descriptor block phys address */ - PI_DMA_CMD_REQ *cmd_req_virt; /* Command request buffer virt address */ -- u32 cmd_req_phys; /* Command request buffer phys address */ -+ dma_addr_t cmd_req_phys; /* Command request buffer phys address */ - PI_DMA_CMD_RSP *cmd_rsp_virt; /* Command response buffer virt address */ -- u32 cmd_rsp_phys; /* Command response buffer phys address */ -+ dma_addr_t cmd_rsp_phys; /* Command response buffer phys address */ - char *rcv_block_virt; /* LLC host receive queue buf blk virt */ -- u32 rcv_block_phys; /* LLC host receive queue buf blk phys */ -+ dma_addr_t rcv_block_phys; /* LLC host receive queue buf blk phys */ - PI_CONSUMER_BLOCK *cons_block_virt; /* PDQ consumer block virt address */ -- u32 cons_block_phys; /* PDQ consumer block phys address */ -+ dma_addr_t cons_block_phys; /* PDQ consumer block phys address */ - - /* Keep local copies of Type 1 and Type 2 register data */ - -@@ -1758,8 +1761,9 @@ typedef struct DFX_board_tag - - struct net_device *dev; /* pointer to device structure */ - struct net_device *next; -- u32 bus_type; /* bus type (0 == PCI, 1 == EISA) */ -- u16 base_addr; /* base I/O address (same as dev->base_addr) */ -+ u32 bus_type; /* bus type (0 == PCI, 1 == EISA, 2 == TC) */ -+ long base_addr; /* base I/O address (same as dev->base_addr) */ -+ int slot; /* TC slot number */ - struct pci_dev * pci_dev; - u32 full_duplex_enb; /* FDDI Full Duplex enable (1 == on, 2 == off) */ - u32 req_ttrt; /* requested TTRT value (in 80ns units) */ ---- a/drivers/net/hamradio/hdlcdrv.c -+++ b/drivers/net/hamradio/hdlcdrv.c -@@ -587,6 +587,8 @@ static int hdlcdrv_close(struct net_devi - return -EINVAL; - s = (struct hdlcdrv_state *)dev->priv; - -+ netif_stop_queue(dev); -+ - if (s->ops && s->ops->close) - i = s->ops->close(dev); - if (s->skb) ---- a/drivers/net/irda/au1k_ir.c -+++ b/drivers/net/irda/au1k_ir.c -@@ -81,10 +81,6 @@ static char version[] __devinitdata = - - #define RUN_AT(x) (jiffies + (x)) - --#if defined(CONFIG_MIPS_DB1000) || defined(CONFIG_MIPS_DB1100) --static BCSR * const bcsr = (BCSR *)0xAE000000; --#endif -- - static spinlock_t ir_lock = SPIN_LOCK_UNLOCKED; - - /* ---- a/drivers/net/sgiseeq.c -+++ b/drivers/net/sgiseeq.c -@@ -24,16 +24,16 @@ - #include <asm/io.h> - #include <asm/system.h> - #include <asm/bitops.h> -+#include <asm/paccess.h> - #include <asm/page.h> - #include <asm/pgtable.h> -+#include <asm/sgi/mc.h> - #include <asm/sgi/hpc3.h> - #include <asm/sgi/ip22.h> - #include <asm/sgialib.h> - - #include "sgiseeq.h" - --static char *version = "sgiseeq.c: David S. Miller (dm@engr.sgi.com)\n"; -- - static char *sgiseeqstr = "SGI Seeq8003"; - - /* -@@ -113,9 +113,9 @@ static struct net_device *root_sgiseeq_d - - static inline void hpc3_eth_reset(struct hpc3_ethregs *hregs) - { -- hregs->rx_reset = HPC3_ERXRST_CRESET | HPC3_ERXRST_CLRIRQ; -+ hregs->reset = HPC3_ERST_CRESET | HPC3_ERST_CLRIRQ; - udelay(20); -- hregs->rx_reset = 0; -+ hregs->reset = 0; - } - - static inline void reset_hpc3_and_seeq(struct hpc3_ethregs *hregs, -@@ -238,7 +238,6 @@ void sgiseeq_dump_rings(void) - - #define TSTAT_INIT_SEEQ (SEEQ_TCMD_IPT|SEEQ_TCMD_I16|SEEQ_TCMD_IC|SEEQ_TCMD_IUF) - #define TSTAT_INIT_EDLC ((TSTAT_INIT_SEEQ) | SEEQ_TCMD_RB2) --#define RDMACFG_INIT (HPC3_ERXDCFG_FRXDC | HPC3_ERXDCFG_FEOP | HPC3_ERXDCFG_FIRQ) - - static int init_seeq(struct net_device *dev, struct sgiseeq_private *sp, - struct sgiseeq_regs *sregs) -@@ -260,8 +259,6 @@ static int init_seeq(struct net_device * - sregs->tstat = TSTAT_INIT_SEEQ; - } - -- hregs->rx_dconfig |= RDMACFG_INIT; -- - hregs->rx_ndptr = PHYSADDR(&sp->srings.rx_desc[0]); - hregs->tx_ndptr = PHYSADDR(&sp->srings.tx_desc[0]); - -@@ -432,7 +429,7 @@ static void sgiseeq_interrupt(int irq, v - spin_lock(&sp->tx_lock); - - /* Ack the IRQ and set software state. */ -- hregs->rx_reset = HPC3_ERXRST_CLRIRQ; -+ hregs->reset = HPC3_ERST_CLRIRQ; - - /* Always check for received packets. */ - sgiseeq_rx(dev, sp, hregs, sregs); -@@ -616,7 +613,7 @@ static inline void setup_rx_ring(struct - - #define ALIGNED(x) ((((unsigned long)(x)) + 0xf) & ~(0xf)) - --int sgiseeq_init(struct hpc3_regs* regs, int irq) -+int sgiseeq_init(struct hpc3_regs* hpcregs, int irq, int has_eeprom) - { - struct net_device *dev; - struct sgiseeq_private *sp; -@@ -629,7 +626,7 @@ int sgiseeq_init(struct hpc3_regs* regs, - goto err_out; - } - /* Make private data page aligned */ -- sp = (struct sgiseeq_private *) get_zeroed_page(GFP_KERNEL); -+ sp = (struct sgiseeq_private *) get_zeroed_page(GFP_KERNEL); - if (!sp) { - printk(KERN_ERR "Sgiseeq: Page alloc failed, aborting.\n"); - err = -ENOMEM; -@@ -644,7 +641,9 @@ int sgiseeq_init(struct hpc3_regs* regs, - - #define EADDR_NVOFS 250 - for (i = 0; i < 3; i++) { -- unsigned short tmp = ip22_nvram_read(EADDR_NVOFS / 2 + i); -+ unsigned short tmp = has_eeprom ? -+ ip22_eeprom_read(&hpcregs->eeprom, EADDR_NVOFS / 2+i) : -+ ip22_nvram_read(EADDR_NVOFS / 2+i); - - dev->dev_addr[2 * i] = tmp >> 8; - dev->dev_addr[2 * i + 1] = tmp & 0xff; -@@ -654,8 +653,8 @@ int sgiseeq_init(struct hpc3_regs* regs, - gpriv = sp; - gdev = dev; - #endif -- sp->sregs = (struct sgiseeq_regs *) &hpc3c0->eth_ext[0]; -- sp->hregs = &hpc3c0->ethregs; -+ sp->sregs = (struct sgiseeq_regs *) &hpcregs->eth_ext[0]; -+ sp->hregs = &hpcregs->ethregs; - sp->name = sgiseeqstr; - sp->mode = SEEQ_RCMD_RBCAST; - -@@ -672,6 +671,11 @@ int sgiseeq_init(struct hpc3_regs* regs, - setup_rx_ring(sp->srings.rx_desc, SEEQ_RX_BUFFERS); - setup_tx_ring(sp->srings.tx_desc, SEEQ_TX_BUFFERS); - -+ /* Setup PIO and DMA transfer timing */ -+ sp->hregs->pconfig = 0x161; -+ sp->hregs->dconfig = HPC3_EDCFG_FIRQ | HPC3_EDCFG_FEOP | -+ HPC3_EDCFG_FRXDC | HPC3_EDCFG_PTO | 0x026; -+ - /* Reset the chip. */ - hpc3_eth_reset(sp->hregs); - -@@ -699,7 +703,7 @@ int sgiseeq_init(struct hpc3_regs* regs, - goto err_out_free_irq; - } - -- printk(KERN_INFO "%s: SGI Seeq8003 ", dev->name); -+ printk(KERN_INFO "%s: %s ", dev->name, sgiseeqstr); - for (i = 0; i < 6; i++) - printk("%2.2x%c", dev->dev_addr[i], i == 5 ? '\n' : ':'); - -@@ -721,10 +725,22 @@ err_out: - - static int __init sgiseeq_probe(void) - { -- printk(version); -+ unsigned int tmp, ret1, ret2 = 0; - - /* On board adapter on 1st HPC is always present */ -- return sgiseeq_init(hpc3c0, SGI_ENET_IRQ); -+ ret1 = sgiseeq_init(hpc3c0, SGI_ENET_IRQ, 0); -+ /* Let's see if second HPC is there */ -+ if (!(ip22_is_fullhouse()) && -+ get_dbe(tmp, (unsigned int *)&hpc3c1->pbdma[1]) == 0) { -+ sgimc->giopar |= SGIMC_GIOPAR_MASTEREXP1 | -+ SGIMC_GIOPAR_EXP164 | -+ SGIMC_GIOPAR_HPC264; -+ hpc3c1->pbus_piocfg[0][0] = 0x3ffff; -+ /* interrupt/config register on Challenge S Mezz board */ -+ hpc3c1->pbus_extregs[0][0] = 0x30; -+ ret2 = sgiseeq_init(hpc3c1, SGI_GIO_0_IRQ, 1); -+ } -+ return (ret1 & ret2) ? ret1 : 0; - } - - static void __exit sgiseeq_exit(void) -@@ -747,4 +763,6 @@ static void __exit sgiseeq_exit(void) - module_init(sgiseeq_probe); - module_exit(sgiseeq_exit); - -+MODULE_DESCRIPTION("SGI Seeq 8003 driver"); -+MODULE_AUTHOR("David S. Miller"); - MODULE_LICENSE("GPL"); ---- a/drivers/pci/pci.c -+++ b/drivers/pci/pci.c -@@ -1281,11 +1281,17 @@ static int __devinit pci_scan_bridge(str - { - unsigned int buses; - unsigned short cr; -+ unsigned short bctl; - struct pci_bus *child; - int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS); - - pci_read_config_dword(dev, PCI_PRIMARY_BUS, &buses); - DBG("Scanning behind PCI bridge %s, config %06x, pass %d\n", dev->slot_name, buses & 0xffffff, pass); -+ /* Disable MasterAbortMode during probing to avoid reporting -+ of bus errors (in some architectures) */ -+ pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &bctl); -+ pci_write_config_word(dev, PCI_BRIDGE_CONTROL, -+ bctl & ~PCI_BRIDGE_CTL_MASTER_ABORT); - if ((buses & 0xffff00) && !pcibios_assign_all_busses()) { - /* - * Bus already configured by firmware, process it in the first -@@ -1351,6 +1357,7 @@ static int __devinit pci_scan_bridge(str - pci_write_config_byte(dev, PCI_SUBORDINATE_BUS, max); - pci_write_config_word(dev, PCI_COMMAND, cr); - } -+ pci_write_config_word(dev, PCI_BRIDGE_CONTROL, bctl); - sprintf(child->name, (is_cardbus ? "PCI CardBus #%02x" : "PCI Bus #%02x"), child->number); - return max; - } ---- a/drivers/pcmcia/au1000_db1x00.c -+++ b/drivers/pcmcia/au1000_db1x00.c -@@ -1,6 +1,6 @@ - /* - * -- * Alchemy Semi Db1x00 boards specific pcmcia routines. -+ * AMD Alchemy DUAL-SLOT Db1x00 boards' specific pcmcia routines. - * - * Copyright 2002 MontaVista Software Inc. - * Author: MontaVista Software, Inc. -@@ -54,9 +54,20 @@ - #include <asm/au1000.h> - #include <asm/au1000_pcmcia.h> - -+#if defined(CONFIG_MIPS_PB1200) -+#include <asm/pb1200.h> -+#elif defined(CONFIG_MIPS_DB1200) -+#include <asm/db1200.h> -+#else - #include <asm/db1x00.h> -+#endif - --static BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR; -+#define PCMCIA_MAX_SOCK 1 -+#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK+1) -+ -+/* VPP/VCC */ -+#define SET_VCC_VPP(VCC, VPP, SLOT)\ -+ ((((VCC)<<2) | ((VPP)<<0)) << ((SLOT)*8)) - - static int db1x00_pcmcia_init(struct pcmcia_init *init) - { -@@ -76,7 +87,7 @@ static int - db1x00_pcmcia_socket_state(unsigned sock, struct pcmcia_state *state) - { - u32 inserted; -- unsigned char vs; -+ u16 vs; - - if(sock > PCMCIA_MAX_SOCK) return -1; - -@@ -87,11 +98,11 @@ db1x00_pcmcia_socket_state(unsigned sock - - if (sock == 0) { - vs = bcsr->status & 0x3; -- inserted = !(bcsr->status & (1<<4)); -+ inserted = BOARD_CARD_INSERTED(0); - } - else { - vs = (bcsr->status & 0xC)>>2; -- inserted = !(bcsr->status & (1<<5)); -+ inserted = BOARD_CARD_INSERTED(1); - } - - DEBUG(KERN_DEBUG "db1x00 socket %d: inserted %d, vs %d\n", -@@ -144,16 +155,9 @@ static int db1x00_pcmcia_get_irq_info(st - if(info->sock > PCMCIA_MAX_SOCK) return -1; - - if(info->sock == 0) --#ifdef CONFIG_MIPS_DB1550 -- info->irq = AU1000_GPIO_3; -+ info->irq = BOARD_PC0_INT; - else -- info->irq = AU1000_GPIO_5; --#else -- info->irq = AU1000_GPIO_2; -- else -- info->irq = AU1000_GPIO_5; --#endif -- -+ info->irq = BOARD_PC1_INT; - return 0; - } - ---- a/drivers/pcmcia/Config.in -+++ b/drivers/pcmcia/Config.in -@@ -30,16 +30,14 @@ if [ "$CONFIG_PCMCIA" != "n" ]; then - dep_tristate ' M8xx support' CONFIG_PCMCIA_M8XX $CONFIG_PCMCIA - fi - if [ "$CONFIG_SOC_AU1X00" = "y" ]; then -- dep_tristate ' Au1x00 PCMCIA support' CONFIG_PCMCIA_AU1X00 $CONFIG_PCMCIA -- if [ "$CONFIG_PCMCIA_AU1X00" != "n" ]; then -- bool ' Pb1x00 board support' CONFIG_PCMCIA_PB1X00 -- bool ' Db1x00 board support' CONFIG_PCMCIA_DB1X00 -- bool ' XXS1500 board support' CONFIG_PCMCIA_XXS1500 -- fi -+ dep_tristate ' Au1x00 PCMCIA support' CONFIG_PCMCIA_AU1X00 $CONFIG_PCMCIA - fi - if [ "$CONFIG_SIBYTE_SB1xxx_SOC" = "y" ]; then - dep_bool ' SiByte PCMCIA support' CONFIG_PCMCIA_SIBYTE $CONFIG_PCMCIA $CONFIG_BLK_DEV_IDE_SIBYTE - fi -+ if [ "$CONFIG_VRC4171" = "y" -o "$CONFIG_VRC4171" = "m" ]; then -+ dep_tristate ' NEC VRC4171 Card Controllers support' CONFIG_PCMCIA_VRC4171 $CONFIG_PCMCIA -+ fi - if [ "$CONFIG_VRC4173" = "y" -o "$CONFIG_VRC4173" = "m" ]; then - dep_tristate ' NEC VRC4173 CARDU support' CONFIG_PCMCIA_VRC4173 $CONFIG_PCMCIA - fi ---- a/drivers/pcmcia/Makefile -+++ b/drivers/pcmcia/Makefile -@@ -61,9 +61,18 @@ endif - - obj-$(CONFIG_PCMCIA_AU1X00) += au1x00_ss.o - au1000_ss-objs-y := au1000_generic.o --au1000_ss-objs-$(CONFIG_PCMCIA_PB1X00) += au1000_pb1x00.o --au1000_ss-objs-$(CONFIG_PCMCIA_DB1X00) += au1000_db1x00.o --au1000_ss-objs-$(CONFIG_PCMCIA_XXS1500) += au1000_xxs1500.o -+au1000_ss-objs-$(CONFIG_MIPS_PB1000) += au1000_pb1x00.o -+au1000_ss-objs-$(CONFIG_MIPS_PB1100) += au1000_pb1x00.o -+au1000_ss-objs-$(CONFIG_MIPS_PB1500) += au1000_pb1x00.o -+au1000_ss-objs-$(CONFIG_MIPS_PB1550) += au1000_pb1550.o -+au1000_ss-objs-$(CONFIG_MIPS_PB1200) += au1000_db1x00.o -+au1000_ss-objs-$(CONFIG_MIPS_DB1000) += au1000_db1x00.o -+au1000_ss-objs-$(CONFIG_MIPS_DB1100) += au1000_db1x00.o -+au1000_ss-objs-$(CONFIG_MIPS_DB1500) += au1000_db1x00.o -+au1000_ss-objs-$(CONFIG_MIPS_DB1550) += au1000_db1x00.o -+au1000_ss-objs-$(CONFIG_MIPS_DB1200) += au1000_db1x00.o -+au1000_ss-objs-$(CONFIG_MIPS_HYDROGEN3) += au1000_hydrogen3.o -+au1000_ss-objs-$(CONFIG_MIPS_XXS1500) += au1000_xxs1500.o - - obj-$(CONFIG_PCMCIA_SA1100) += sa1100_cs.o - obj-$(CONFIG_PCMCIA_M8XX) += m8xx_pcmcia.o -@@ -89,6 +98,7 @@ sa1100_cs-objs-$(CONFIG_SA1100_STORK) + - sa1100_cs-objs-$(CONFIG_SA1100_XP860) += sa1100_xp860.o sa1111_generic.o - sa1100_cs-objs-$(CONFIG_SA1100_YOPY) += sa1100_yopy.o - -+obj-$(CONFIG_PCMCIA_VRC4171) += vrc4171_card.o - obj-$(CONFIG_PCMCIA_VRC4173) += vrc4173_cardu.o - - include $(TOPDIR)/Rules.make ---- /dev/null -+++ b/drivers/pcmcia/vrc4171_card.c -@@ -0,0 +1,886 @@ -+/* -+ * vrc4171_card.c, NEC VRC4171 Card Controller driver for Socket Services. -+ * -+ * Copyright (C) 2003 Yoichi Yuasa <yuasa@hh.iij4u.or.jp> -+ * -+ * 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 -+ */ -+#include <linux/init.h> -+#include <linux/ioport.h> -+#include <linux/irq.h> -+#include <linux/module.h> -+#include <linux/spinlock.h> -+#include <linux/sched.h> -+#include <linux/types.h> -+ -+#include <asm/io.h> -+#include <asm/vr41xx/vrc4171.h> -+ -+#include <pcmcia/ss.h> -+ -+#include "i82365.h" -+ -+MODULE_DESCRIPTION("NEC VRC4171 Card Controllers driver for Socket Services"); -+MODULE_AUTHOR("Yoichi Yuasa <yuasa@hh.iij4u.or.jp>"); -+MODULE_LICENSE("GPL"); -+ -+#define CARD_MAX_SLOTS 2 -+#define CARD_SLOTA 0 -+#define CARD_SLOTB 1 -+#define CARD_SLOTB_OFFSET 0x40 -+ -+#define CARD_MEM_START 0x10000000 -+#define CARD_MEM_END 0x13ffffff -+#define CARD_MAX_MEM_OFFSET 0x3ffffff -+#define CARD_MAX_MEM_SPEED 1000 -+ -+#define CARD_CONTROLLER_INDEX 0x03e0 -+#define CARD_CONTROLLER_DATA 0x03e1 -+#define CARD_CONTROLLER_SIZE 2 -+ /* Power register */ -+ #define VPP_GET_VCC 0x01 -+ #define POWER_ENABLE 0x10 -+ #define CARD_VOLTAGE_SENSE 0x1f -+ #define VCC_3VORXV_CAPABLE 0x00 -+ #define VCC_XV_ONLY 0x01 -+ #define VCC_3V_CAPABLE 0x02 -+ #define VCC_5V_ONLY 0x03 -+ #define CARD_VOLTAGE_SELECT 0x2f -+ #define VCC_3V 0x01 -+ #define VCC_5V 0x00 -+ #define VCC_XV 0x02 -+ #define VCC_STATUS_3V 0x02 -+ #define VCC_STATUS_5V 0x01 -+ #define VCC_STATUS_XV 0x03 -+ #define GLOBAL_CONTROL 0x1e -+ #define EXWRBK 0x04 -+ #define IRQPM_EN 0x08 -+ #define CLRPMIRQ 0x10 -+ -+#define IO_MAX_MAPS 2 -+#define MEM_MAX_MAPS 5 -+ -+enum { -+ SLOTB_PROBE = 0, -+ SLOTB_NOPROBE_IO, -+ SLOTB_NOPROBE_MEM, -+ SLOTB_NOPROBE_ALL -+}; -+ -+typedef struct vrc4171_socket { -+ int noprobe; -+ void (*handler)(void *, unsigned int); -+ void *info; -+ socket_cap_t cap; -+ spinlock_t event_lock; -+ uint16_t events; -+ struct socket_info_t *pcmcia_socket; -+ struct tq_struct tq_task; -+ char name[24]; -+ int csc_irq; -+ int io_irq; -+} vrc4171_socket_t; -+ -+static vrc4171_socket_t vrc4171_sockets[CARD_MAX_SLOTS]; -+static int vrc4171_slotb = SLOTB_IS_NONE; -+static unsigned int vrc4171_irq; -+static uint16_t vrc4171_irq_mask = 0xdeb8; -+ -+extern struct socket_info_t *pcmcia_register_socket(int slot, -+ struct pccard_operations *vtable, -+ int use_bus_pm); -+extern void pcmcia_unregister_socket(struct socket_info_t *s); -+ -+static inline uint8_t exca_read_byte(int slot, uint8_t index) -+{ -+ if (slot == CARD_SLOTB) -+ index += CARD_SLOTB_OFFSET; -+ -+ outb(index, CARD_CONTROLLER_INDEX); -+ return inb(CARD_CONTROLLER_DATA); -+} -+ -+static inline uint16_t exca_read_word(int slot, uint8_t index) -+{ -+ uint16_t data; -+ -+ if (slot == CARD_SLOTB) -+ index += CARD_SLOTB_OFFSET; -+ -+ outb(index++, CARD_CONTROLLER_INDEX); -+ data = inb(CARD_CONTROLLER_DATA); -+ -+ outb(index, CARD_CONTROLLER_INDEX); -+ data |= ((uint16_t)inb(CARD_CONTROLLER_DATA)) << 8; -+ -+ return data; -+} -+ -+static inline uint8_t exca_write_byte(int slot, uint8_t index, uint8_t data) -+{ -+ if (slot == CARD_SLOTB) -+ index += CARD_SLOTB_OFFSET; -+ -+ outb(index, CARD_CONTROLLER_INDEX); -+ outb(data, CARD_CONTROLLER_DATA); -+ -+ return data; -+} -+ -+static inline uint16_t exca_write_word(int slot, uint8_t index, uint16_t data) -+{ -+ if (slot == CARD_SLOTB) -+ index += CARD_SLOTB_OFFSET; -+ -+ outb(index++, CARD_CONTROLLER_INDEX); -+ outb(data, CARD_CONTROLLER_DATA); -+ -+ outb(index, CARD_CONTROLLER_INDEX); -+ outb((uint8_t)(data >> 8), CARD_CONTROLLER_DATA); -+ -+ return data; -+} -+ -+static inline int search_nonuse_irq(void) -+{ -+ int i; -+ -+ for (i = 0; i < 16; i++) { -+ if (vrc4171_irq_mask & (1 << i)) { -+ vrc4171_irq_mask &= ~(1 << i); -+ return i; -+ } -+ } -+ -+ return -1; -+} -+ -+static int pccard_init(unsigned int slot) -+{ -+ vrc4171_socket_t *socket = &vrc4171_sockets[slot]; -+ -+ socket->cap.features |= SS_CAP_PCCARD | SS_CAP_PAGE_REGS; -+ socket->cap.irq_mask = 0; -+ socket->cap.pci_irq = vrc4171_irq; -+ socket->cap.map_size = 0x1000; -+ socket->events = 0; -+ spin_lock_init(socket->event_lock); -+ socket->csc_irq = search_nonuse_irq(); -+ socket->io_irq = search_nonuse_irq(); -+ -+ return 0; -+} -+ -+static int pccard_suspend(unsigned int slot) -+{ -+ return -EINVAL; -+} -+ -+static int pccard_register_callback(unsigned int slot, -+ void (*handler)(void *, unsigned int), -+ void *info) -+{ -+ vrc4171_socket_t *socket; -+ -+ if (slot >= CARD_MAX_SLOTS) -+ return -EINVAL; -+ -+ socket = &vrc4171_sockets[slot]; -+ -+ socket->handler = handler; -+ socket->info = info; -+ -+ if (handler) -+ MOD_INC_USE_COUNT; -+ else -+ MOD_DEC_USE_COUNT; -+ -+ return 0; -+} -+ -+static int pccard_inquire_socket(unsigned int slot, socket_cap_t *cap) -+{ -+ vrc4171_socket_t *socket; -+ -+ if (slot >= CARD_MAX_SLOTS || cap == NULL) -+ return -EINVAL; -+ -+ socket = &vrc4171_sockets[slot]; -+ -+ *cap = socket->cap; -+ -+ return 0; -+} -+ -+static int pccard_get_status(unsigned int slot, u_int *value) -+{ -+ uint8_t status, sense; -+ u_int val = 0; -+ -+ if (slot >= CARD_MAX_SLOTS || value == NULL) -+ return -EINVAL; -+ -+ status = exca_read_byte(slot, I365_STATUS); -+ if (exca_read_byte(slot, I365_INTCTL) & I365_PC_IOCARD) { -+ if (status & I365_CS_STSCHG) -+ val |= SS_STSCHG; -+ } else { -+ if (!(status & I365_CS_BVD1)) -+ val |= SS_BATDEAD; -+ else if ((status & (I365_CS_BVD1 | I365_CS_BVD2)) == I365_CS_BVD1) -+ val |= SS_BATWARN; -+ } -+ if ((status & I365_CS_DETECT) == I365_CS_DETECT) -+ val |= SS_DETECT; -+ if (status & I365_CS_WRPROT) -+ val |= SS_WRPROT; -+ if (status & I365_CS_READY) -+ val |= SS_READY; -+ if (status & I365_CS_POWERON) -+ val |= SS_POWERON; -+ -+ sense = exca_read_byte(slot, CARD_VOLTAGE_SENSE); -+ switch (sense) { -+ case VCC_3VORXV_CAPABLE: -+ val |= SS_3VCARD | SS_XVCARD; -+ break; -+ case VCC_XV_ONLY: -+ val |= SS_XVCARD; -+ break; -+ case VCC_3V_CAPABLE: -+ val |= SS_3VCARD; -+ break; -+ default: -+ /* 5V only */ -+ break; -+ } -+ -+ *value = val; -+ -+ return 0; -+} -+ -+static inline u_char get_Vcc_value(uint8_t voltage) -+{ -+ switch (voltage) { -+ case VCC_STATUS_3V: -+ return 33; -+ case VCC_STATUS_5V: -+ return 50; -+ default: -+ break; -+ } -+ -+ return 0; -+} -+ -+static inline u_char get_Vpp_value(uint8_t power, u_char Vcc) -+{ -+ if ((power & 0x03) == 0x01 || (power & 0x03) == 0x02) -+ return Vcc; -+ -+ return 0; -+} -+ -+static int pccard_get_socket(unsigned int slot, socket_state_t *state) -+{ -+ vrc4171_socket_t *socket; -+ uint8_t power, voltage, control, cscint; -+ -+ if (slot >= CARD_MAX_SLOTS || state == NULL) -+ return -EINVAL; -+ -+ socket = &vrc4171_sockets[slot]; -+ -+ power = exca_read_byte(slot, I365_POWER); -+ voltage = exca_read_byte(slot, CARD_VOLTAGE_SELECT); -+ -+ state->Vcc = get_Vcc_value(voltage); -+ state->Vpp = get_Vpp_value(power, state->Vcc); -+ -+ state->flags = 0; -+ if (power & POWER_ENABLE) -+ state->flags |= SS_PWR_AUTO; -+ if (power & I365_PWR_OUT) -+ state->flags |= SS_OUTPUT_ENA; -+ -+ control = exca_read_byte(slot, I365_INTCTL); -+ if (control & I365_PC_IOCARD) -+ state->flags |= SS_IOCARD; -+ if (!(control & I365_PC_RESET)) -+ state->flags |= SS_RESET; -+ -+ cscint = exca_read_byte(slot, I365_CSCINT); -+ state->csc_mask = 0; -+ if (state->flags & SS_IOCARD) { -+ if (cscint & I365_CSC_STSCHG) -+ state->flags |= SS_STSCHG; -+ } else { -+ if (cscint & I365_CSC_BVD1) -+ state->csc_mask |= SS_BATDEAD; -+ if (cscint & I365_CSC_BVD2) -+ state->csc_mask |= SS_BATWARN; -+ } -+ if (cscint & I365_CSC_READY) -+ state->csc_mask |= SS_READY; -+ if (cscint & I365_CSC_DETECT) -+ state->csc_mask |= SS_DETECT; -+ -+ return 0; -+} -+ -+static inline uint8_t set_Vcc_value(u_char Vcc) -+{ -+ switch (Vcc) { -+ case 33: -+ return VCC_3V; -+ case 50: -+ return VCC_5V; -+ } -+ -+ /* Small voltage is chosen for safety. */ -+ return VCC_3V; -+} -+ -+static int pccard_set_socket(unsigned int slot, socket_state_t *state) -+{ -+ vrc4171_socket_t *socket; -+ uint8_t voltage, power, control, cscint; -+ -+ if (slot >= CARD_MAX_SLOTS || -+ (state->Vpp != state->Vcc && state->Vpp != 0) || -+ (state->Vcc != 50 && state->Vcc != 33 && state->Vcc != 0)) -+ return -EINVAL; -+ -+ socket = &vrc4171_sockets[slot]; -+ -+ spin_lock_irq(&socket->event_lock); -+ -+ voltage = set_Vcc_value(state->Vcc); -+ exca_write_byte(slot, CARD_VOLTAGE_SELECT, voltage); -+ -+ power = POWER_ENABLE; -+ if (state->Vpp == state->Vcc) -+ power |= VPP_GET_VCC; -+ if (state->flags & SS_OUTPUT_ENA) -+ power |= I365_PWR_OUT; -+ exca_write_byte(slot, I365_POWER, power); -+ -+ control = 0; -+ if (state->io_irq != 0) -+ control |= socket->io_irq; -+ if (state->flags & SS_IOCARD) -+ control |= I365_PC_IOCARD; -+ if (state->flags & SS_RESET) -+ control &= ~I365_PC_RESET; -+ else -+ control |= I365_PC_RESET; -+ exca_write_byte(slot, I365_INTCTL, control); -+ -+ cscint = 0; -+ exca_write_byte(slot, I365_CSCINT, cscint); -+ exca_read_byte(slot, I365_CSC); /* clear CardStatus change */ -+ if (state->csc_mask != 0) -+ cscint |= socket->csc_irq << 8; -+ if (state->flags & SS_IOCARD) { -+ if (state->csc_mask & SS_STSCHG) -+ cscint |= I365_CSC_STSCHG; -+ } else { -+ if (state->csc_mask & SS_BATDEAD) -+ cscint |= I365_CSC_BVD1; -+ if (state->csc_mask & SS_BATWARN) -+ cscint |= I365_CSC_BVD2; -+ } -+ if (state->csc_mask & SS_READY) -+ cscint |= I365_CSC_READY; -+ if (state->csc_mask & SS_DETECT) -+ cscint |= I365_CSC_DETECT; -+ exca_write_byte(slot, I365_CSCINT, cscint); -+ -+ spin_unlock_irq(&socket->event_lock); -+ -+ return 0; -+} -+ -+static int pccard_get_io_map(unsigned int slot, struct pccard_io_map *io) -+{ -+ vrc4171_socket_t *socket; -+ uint8_t ioctl, addrwin; -+ u_char map; -+ -+ if (slot >= CARD_MAX_SLOTS || io == NULL || -+ io->map >= IO_MAX_MAPS) -+ return -EINVAL; -+ -+ socket = &vrc4171_sockets[slot]; -+ map = io->map; -+ -+ io->start = exca_read_word(slot, I365_IO(map)+I365_W_START); -+ io->stop = exca_read_word(slot, I365_IO(map)+I365_W_STOP); -+ -+ ioctl = exca_read_byte(slot, I365_IOCTL); -+ if (io->flags & I365_IOCTL_WAIT(map)) -+ io->speed = 1; -+ else -+ io->speed = 0; -+ -+ io->flags = 0; -+ if (ioctl & I365_IOCTL_16BIT(map)) -+ io->flags |= MAP_16BIT; -+ if (ioctl & I365_IOCTL_IOCS16(map)) -+ io->flags |= MAP_AUTOSZ; -+ if (ioctl & I365_IOCTL_0WS(map)) -+ io->flags |= MAP_0WS; -+ -+ addrwin = exca_read_byte(slot, I365_ADDRWIN); -+ if (addrwin & I365_ENA_IO(map)) -+ io->flags |= MAP_ACTIVE; -+ -+ return 0; -+} -+ -+static int pccard_set_io_map(unsigned int slot, struct pccard_io_map *io) -+{ -+ vrc4171_socket_t *socket; -+ uint8_t ioctl, addrwin; -+ u_char map; -+ -+ if (slot >= CARD_MAX_SLOTS || -+ io == NULL || io->map >= IO_MAX_MAPS || -+ io->start > 0xffff || io->stop > 0xffff || io->start > io->stop) -+ return -EINVAL; -+ -+ socket = &vrc4171_sockets[slot]; -+ map = io->map; -+ -+ addrwin = exca_read_byte(slot, I365_ADDRWIN); -+ if (addrwin & I365_ENA_IO(map)) { -+ addrwin &= ~I365_ENA_IO(map); -+ exca_write_byte(slot, I365_ADDRWIN, addrwin); -+ } -+ -+ exca_write_word(slot, I365_IO(map)+I365_W_START, io->start); -+ exca_write_word(slot, I365_IO(map)+I365_W_STOP, io->stop); -+ -+ ioctl = 0; -+ if (io->speed > 0) -+ ioctl |= I365_IOCTL_WAIT(map); -+ if (io->flags & MAP_16BIT) -+ ioctl |= I365_IOCTL_16BIT(map); -+ if (io->flags & MAP_AUTOSZ) -+ ioctl |= I365_IOCTL_IOCS16(map); -+ if (io->flags & MAP_0WS) -+ ioctl |= I365_IOCTL_0WS(map); -+ exca_write_byte(slot, I365_IOCTL, ioctl); -+ -+ if (io->flags & MAP_ACTIVE) { -+ addrwin |= I365_ENA_IO(map); -+ exca_write_byte(slot, I365_ADDRWIN, addrwin); -+ } -+ -+ return 0; -+} -+ -+static int pccard_get_mem_map(unsigned int slot, struct pccard_mem_map *mem) -+{ -+ vrc4171_socket_t *socket; -+ uint8_t addrwin; -+ u_long start, stop; -+ u_int offset; -+ u_char map; -+ -+ if (slot >= CARD_MAX_SLOTS || mem == NULL || mem->map >= MEM_MAX_MAPS) -+ return -EINVAL; -+ -+ socket = &vrc4171_sockets[slot]; -+ map = mem->map; -+ -+ mem->flags = 0; -+ mem->speed = 0; -+ -+ addrwin = exca_read_byte(slot, I365_ADDRWIN); -+ if (addrwin & I365_ENA_MEM(map)) -+ mem->flags |= MAP_ACTIVE; -+ -+ start = exca_read_word(slot, I365_MEM(map)+I365_W_START); -+ if (start & I365_MEM_16BIT) -+ mem->flags |= MAP_16BIT; -+ mem->sys_start = (start & 0x3fffUL) << 12; -+ -+ stop = exca_read_word(slot, I365_MEM(map)+I365_W_STOP); -+ if (start & I365_MEM_WS0) -+ mem->speed += 1; -+ if (start & I365_MEM_WS1) -+ mem->speed += 2; -+ mem->sys_stop = ((stop & 0x3fffUL) << 12) + 0xfffUL; -+ -+ offset = exca_read_word(slot, I365_MEM(map)+I365_W_OFF); -+ if (offset & I365_MEM_REG) -+ mem->flags |= MAP_ATTRIB; -+ if (offset & I365_MEM_WRPROT) -+ mem->flags |= MAP_WRPROT; -+ mem->card_start = (offset & 0x3fffUL) << 12; -+ -+ mem->sys_start += CARD_MEM_START; -+ mem->sys_stop += CARD_MEM_START; -+ -+ return 0; -+} -+ -+static int pccard_set_mem_map(unsigned int slot, struct pccard_mem_map *mem) -+{ -+ vrc4171_socket_t *socket; -+ uint16_t start, stop, offset; -+ uint8_t addrwin; -+ u_char map; -+ -+ if (slot >= CARD_MAX_SLOTS || -+ mem == NULL || mem->map >= MEM_MAX_MAPS || -+ mem->sys_start < CARD_MEM_START || mem->sys_start > CARD_MEM_END || -+ mem->sys_stop < CARD_MEM_START || mem->sys_stop > CARD_MEM_END || -+ mem->sys_start > mem->sys_stop || -+ mem->card_start > CARD_MAX_MEM_OFFSET || -+ mem->speed > CARD_MAX_MEM_SPEED) -+ return -EINVAL; -+ -+ socket = &vrc4171_sockets[slot]; -+ map = mem->map; -+ -+ addrwin = exca_read_byte(slot, I365_ADDRWIN); -+ if (addrwin & I365_ENA_MEM(map)) { -+ addrwin &= ~I365_ENA_MEM(map); -+ exca_write_byte(slot, I365_ADDRWIN, addrwin); -+ } -+ -+ start = (mem->sys_start >> 12) & 0x3fff; -+ if (mem->flags & MAP_16BIT) -+ start |= I365_MEM_16BIT; -+ exca_write_word(slot, I365_MEM(map)+I365_W_START, start); -+ -+ stop = (mem->sys_stop >> 12) & 0x3fff; -+ switch (mem->speed) { -+ case 0: -+ break; -+ case 1: -+ stop |= I365_MEM_WS0; -+ break; -+ case 2: -+ stop |= I365_MEM_WS1; -+ break; -+ default: -+ stop |= I365_MEM_WS0 | I365_MEM_WS1; -+ break; -+ } -+ exca_write_word(slot, I365_MEM(map)+I365_W_STOP, stop); -+ -+ offset = (mem->card_start >> 12) & 0x3fff; -+ if (mem->flags & MAP_ATTRIB) -+ offset |= I365_MEM_REG; -+ if (mem->flags & MAP_WRPROT) -+ offset |= I365_MEM_WRPROT; -+ exca_write_word(slot, I365_MEM(map)+I365_W_OFF, offset); -+ -+ if (mem->flags & MAP_ACTIVE) { -+ addrwin |= I365_ENA_MEM(map); -+ exca_write_byte(slot, I365_ADDRWIN, addrwin); -+ } -+ -+ return 0; -+} -+ -+static void pccard_proc_setup(unsigned int slot, struct proc_dir_entry *base) -+{ -+} -+ -+static struct pccard_operations vrc4171_pccard_operations = { -+ .init = pccard_init, -+ .suspend = pccard_suspend, -+ .register_callback = pccard_register_callback, -+ .inquire_socket = pccard_inquire_socket, -+ .get_status = pccard_get_status, -+ .get_socket = pccard_get_socket, -+ .set_socket = pccard_set_socket, -+ .get_io_map = pccard_get_io_map, -+ .set_io_map = pccard_set_io_map, -+ .get_mem_map = pccard_get_mem_map, -+ .set_mem_map = pccard_set_mem_map, -+ .proc_setup = pccard_proc_setup, -+}; -+ -+static void pccard_bh(void *data) -+{ -+ vrc4171_socket_t *socket = (vrc4171_socket_t *)data; -+ uint16_t events; -+ -+ spin_lock_irq(&socket->event_lock); -+ events = socket->events; -+ socket->events = 0; -+ spin_unlock_irq(&socket->event_lock); -+ -+ if (socket->handler) -+ socket->handler(socket->info, events); -+} -+ -+static inline uint16_t get_events(int slot) -+{ -+ uint16_t events = 0; -+ uint8_t status, csc; -+ -+ status = exca_read_byte(slot, I365_STATUS); -+ csc = exca_read_byte(slot, I365_CSC); -+ -+ if (exca_read_byte(slot, I365_INTCTL) & I365_PC_IOCARD) { -+ if ((csc & I365_CSC_STSCHG) && (status & I365_CS_STSCHG)) -+ events |= SS_STSCHG; -+ } else { -+ if (csc & (I365_CSC_BVD1 | I365_CSC_BVD2)) { -+ if (!(status & I365_CS_BVD1)) -+ events |= SS_BATDEAD; -+ else if ((status & (I365_CS_BVD1 | I365_CS_BVD2)) == I365_CS_BVD1) -+ events |= SS_BATWARN; -+ } -+ } -+ if ((csc & I365_CSC_READY) && (status & I365_CS_READY)) -+ events |= SS_READY; -+ if ((csc & I365_CSC_DETECT) && ((status & I365_CS_DETECT) == I365_CS_DETECT)) -+ events |= SS_DETECT; -+ -+ return events; -+} -+ -+static void pccard_status_change(int slot, vrc4171_socket_t *socket) -+{ -+ uint16_t events; -+ -+ socket->tq_task.routine = pccard_bh; -+ socket->tq_task.data = socket; -+ -+ events = get_events(slot); -+ if (events) { -+ spin_lock(&socket->event_lock); -+ socket->events |= events; -+ spin_unlock(&socket->event_lock); -+ schedule_task(&socket->tq_task); -+ } -+} -+ -+static void pccard_interrupt(int irq, void *dev_id, struct pt_regs *regs) -+{ -+ vrc4171_socket_t *socket; -+ uint16_t status; -+ -+ status = vrc4171_get_irq_status(); -+ if (status & IRQ_A) { -+ socket = &vrc4171_sockets[CARD_SLOTA]; -+ if (socket->noprobe == SLOTB_PROBE) { -+ if (status & (1 << socket->csc_irq)) -+ pccard_status_change(CARD_SLOTA, socket); -+ } -+ } -+ -+ if (status & IRQ_B) { -+ socket = &vrc4171_sockets[CARD_SLOTB]; -+ if (socket->noprobe == SLOTB_PROBE) { -+ if (status & (1 << socket->csc_irq)) -+ pccard_status_change(CARD_SLOTB, socket); -+ } -+ } -+} -+ -+static inline void reserve_using_irq(int slot) -+{ -+ unsigned int irq; -+ -+ irq = exca_read_byte(slot, I365_INTCTL); -+ irq &= 0x0f; -+ vrc4171_irq_mask &= ~(1 << irq); -+ -+ irq = exca_read_byte(slot, I365_CSCINT); -+ irq = (irq & 0xf0) >> 4; -+ vrc4171_irq_mask &= ~(1 << irq); -+} -+ -+static int __devinit vrc4171_add_socket(int slot) -+{ -+ vrc4171_socket_t *socket; -+ -+ if (slot >= CARD_MAX_SLOTS) -+ return -EINVAL; -+ -+ socket = &vrc4171_sockets[slot]; -+ if (socket->noprobe != SLOTB_PROBE) { -+ uint8_t addrwin; -+ -+ switch (socket->noprobe) { -+ case SLOTB_NOPROBE_MEM: -+ addrwin = exca_read_byte(slot, I365_ADDRWIN); -+ addrwin &= 0x1f; -+ exca_write_byte(slot, I365_ADDRWIN, addrwin); -+ break; -+ case SLOTB_NOPROBE_IO: -+ addrwin = exca_read_byte(slot, I365_ADDRWIN); -+ addrwin &= 0xc0; -+ exca_write_byte(slot, I365_ADDRWIN, addrwin); -+ break; -+ default: -+ break; -+ } -+ -+ reserve_using_irq(slot); -+ -+ return 0; -+ } -+ -+ sprintf(socket->name, "NEC VRC4171 Card Slot %1c", 'A' + slot); -+ -+ socket->pcmcia_socket = pcmcia_register_socket(slot, &vrc4171_pccard_operations, 1); -+ if (socket->pcmcia_socket == NULL) -+ return -ENOMEM; -+ -+ exca_write_byte(slot, I365_ADDRWIN, 0); -+ -+ exca_write_byte(slot, GLOBAL_CONTROL, 0); -+ -+ return 0; -+} -+ -+static void vrc4171_remove_socket(int slot) -+{ -+ vrc4171_socket_t *socket; -+ -+ if (slot >= CARD_MAX_SLOTS) -+ return; -+ -+ socket = &vrc4171_sockets[slot]; -+ -+ if (socket->pcmcia_socket != NULL) { -+ pcmcia_unregister_socket(socket->pcmcia_socket); -+ socket->pcmcia_socket = NULL; -+ } -+} -+ -+static int __devinit vrc4171_card_setup(char *options) -+{ -+ if (options == NULL || *options == '\0') -+ return 0; -+ -+ if (strncmp(options, "irq:", 4) == 0) { -+ int irq; -+ options += 4; -+ irq = simple_strtoul(options, &options, 0); -+ if (irq >= 0 && irq < NR_IRQS) -+ vrc4171_irq = irq; -+ -+ if (*options != ',') -+ return 0; -+ options++; -+ } -+ -+ if (strncmp(options, "slota:", 6) == 0) { -+ options += 6; -+ if (*options != '\0') { -+ if (strncmp(options, "noprobe", 7) == 0) { -+ vrc4171_sockets[CARD_SLOTA].noprobe = 1; -+ options += 7; -+ } -+ -+ if (*options != ',') -+ return 0; -+ options++; -+ } else -+ return 0; -+ -+ } -+ -+ if (strncmp(options, "slotb:", 6) == 0) { -+ options += 6; -+ if (*options != '\0') { -+ if (strncmp(options, "pccard", 6) == 0) { -+ vrc4171_slotb = SLOTB_IS_PCCARD; -+ options += 6; -+ } else if (strncmp(options, "cf", 2) == 0) { -+ vrc4171_slotb = SLOTB_IS_CF; -+ options += 2; -+ } else if (strncmp(options, "flashrom", 8) == 0) { -+ vrc4171_slotb = SLOTB_IS_FLASHROM; -+ options += 8; -+ } else if (strncmp(options, "none", 4) == 0) { -+ vrc4171_slotb = SLOTB_IS_NONE; -+ options += 4; -+ } -+ -+ if (*options != ',') -+ return 0; -+ options++; -+ -+ if ( strncmp(options, "memnoprobe", 10) == 0) -+ vrc4171_sockets[CARD_SLOTB].noprobe = SLOTB_NOPROBE_MEM; -+ if ( strncmp(options, "ionoprobe", 9) == 0) -+ vrc4171_sockets[CARD_SLOTB].noprobe = SLOTB_NOPROBE_IO; -+ if ( strncmp(options, "noprobe", 7) == 0) -+ vrc4171_sockets[CARD_SLOTB].noprobe = SLOTB_NOPROBE_ALL; -+ } -+ } -+ -+ return 0; -+} -+ -+__setup("vrc4171_card=", vrc4171_card_setup); -+ -+static int __devinit vrc4171_card_init(void) -+{ -+ int retval, slot; -+ -+ vrc4171_set_multifunction_pin(vrc4171_slotb); -+ -+ if (request_region(CARD_CONTROLLER_INDEX, CARD_CONTROLLER_SIZE, -+ "NEC VRC4171 Card Controller") == NULL) -+ return -EBUSY; -+ -+ for (slot = 0; slot < CARD_MAX_SLOTS; slot++) { -+ if (slot == CARD_SLOTB && vrc4171_slotb == SLOTB_IS_NONE) -+ break; -+ -+ retval = vrc4171_add_socket(slot); -+ if (retval != 0) -+ return retval; -+ } -+ -+ retval = request_irq(vrc4171_irq, pccard_interrupt, SA_SHIRQ, -+ "NEC VRC4171 Card Controller", vrc4171_sockets); -+ if (retval < 0) { -+ for (slot = 0; slot < CARD_MAX_SLOTS; slot++) -+ vrc4171_remove_socket(slot); -+ -+ return retval; -+ } -+ -+ printk(KERN_INFO "NEC VRC4171 Card Controller, connected to IRQ %d\n", vrc4171_irq); -+ -+ return 0; -+} -+ -+static void __devexit vrc4171_card_exit(void) -+{ -+ int slot; -+ -+ for (slot = 0; slot < CARD_MAX_SLOTS; slot++) -+ vrc4171_remove_socket(slot); -+ -+ release_region(CARD_CONTROLLER_INDEX, CARD_CONTROLLER_SIZE); -+} -+ -+module_init(vrc4171_card_init); -+module_exit(vrc4171_card_exit); ---- a/drivers/scsi/NCR53C9x.h -+++ b/drivers/scsi/NCR53C9x.h -@@ -144,12 +144,7 @@ - - #ifndef MULTIPLE_PAD_SIZES - --#ifdef CONFIG_CPU_HAS_WB --#include <asm/wbflush.h> --#define esp_write(__reg, __val) do{(__reg) = (__val); wbflush();} while(0) --#else --#define esp_write(__reg, __val) ((__reg) = (__val)) --#endif -+#define esp_write(__reg, __val) do{(__reg) = (__val); iob();} while(0) - #define esp_read(__reg) (__reg) - - struct ESP_regs { ---- a/drivers/sound/au1550_i2s.c -+++ b/drivers/sound/au1550_i2s.c -@@ -41,6 +41,7 @@ - * 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ -+ - #include <linux/version.h> - #include <linux/module.h> - #include <linux/string.h> -@@ -62,7 +63,45 @@ - #include <asm/uaccess.h> - #include <asm/hardirq.h> - #include <asm/au1000.h> -+ -+#if defined(CONFIG_SOC_AU1550) - #include <asm/pb1550.h> -+#endif -+ -+#if defined(CONFIG_MIPS_PB1200) -+#define WM8731 -+#define WM_MODE_USB -+#include <asm/pb1200.h> -+#endif -+ -+#if defined(CONFIG_MIPS_FICMMP) -+#define WM8721 -+#define WM_MODE_NORMAL -+#include <asm/ficmmp.h> -+#endif -+ -+ -+#define WM_VOLUME_MIN 47 -+#define WM_VOLUME_SCALE 80 -+ -+#if defined(WM8731) -+ /* OSS interface to the wm i2s.. */ -+ #define CODEC_NAME "Wolfson WM8731 I2S" -+ #define WM_I2S_STEREO_MASK (SOUND_MASK_PCM | SOUND_MASK_LINE) -+ #define WM_I2S_SUPPORTED_MASK (WM_I2S_STEREO_MASK | SOUND_MASK_MIC) -+ #define WM_I2S_RECORD_MASK (SOUND_MASK_MIC | SOUND_MASK_LINE1 | SOUND_MASK_LINE) -+#elif defined(WM8721) -+ #define CODEC_NAME "Wolfson WM8721 I2S" -+ #define WM_I2S_STEREO_MASK (SOUND_MASK_PCM) -+ #define WM_I2S_SUPPORTED_MASK (WM_I2S_STEREO_MASK) -+ #define WM_I2S_RECORD_MASK (0) -+#endif -+ -+ -+#define supported_mixer(FOO) ((FOO >= 0) && \ -+ (FOO < SOUND_MIXER_NRDEVICES) && \ -+ WM_I2S_SUPPORTED_MASK & (1<<FOO) ) -+ - #include <asm/au1xxx_psc.h> - #include <asm/au1xxx_dbdma.h> - -@@ -98,13 +137,51 @@ - * 0 = no VRA, 1 = use VRA if codec supports it - * The framework is here, but we currently force no VRA. - */ -+#if defined(CONFIG_MIPS_PB1200) | defined(CONFIG_MIPS_PB1550) - static int vra = 0; -+#elif defined(CONFIG_MIPS_FICMMP) -+static int vra = 1; -+#endif -+ -+#define WM_REG_L_HEADPHONE_OUT 0x02 -+#define WM_REG_R_HEADPHONE_OUT 0x03 -+#define WM_REG_ANALOGUE_AUDIO_PATH_CTRL 0x04 -+#define WM_REG_DIGITAL_AUDIO_PATH_CTRL 0x05 -+#define WM_REG_POWER_DOWN_CTRL 0x06 -+#define WM_REG_DIGITAL_AUDIO_IF 0x07 -+#define WM_REG_SAMPLING_CONTROL 0x08 -+#define WM_REG_ACTIVE_CTRL 0x09 -+#define WM_REG_RESET 0x0F -+#define WM_SC_SR_96000 (0x7<<2) -+#define WM_SC_SR_88200 (0xF<<2) -+#define WM_SC_SR_48000 (0x0<<2) -+#define WM_SC_SR_44100 (0x8<<2) -+#define WM_SC_SR_32000 (0x6<<2) -+#define WM_SC_SR_8018 (0x9<<2) -+#define WM_SC_SR_8000 (0x1<<2) -+#define WM_SC_MODE_USB 1 -+#define WM_SC_MODE_NORMAL 0 -+#define WM_SC_BOSR_250FS (0<<1) -+#define WM_SC_BOSR_272FS (1<<1) -+#define WM_SC_BOSR_256FS (0<<1) -+#define WM_SC_BOSR_128FS (0<<1) -+#define WM_SC_BOSR_384FS (1<<1) -+#define WM_SC_BOSR_192FS (1<<1) -+ -+#define WS_64FS 31 -+#define WS_96FS 47 -+#define WS_128FS 63 -+#define WS_192FS 95 -+ -+#define MIN_Q_COUNT 2 -+ - MODULE_PARM(vra, "i"); - MODULE_PARM_DESC(vra, "if 1 use VRA if codec supports it"); - - static struct au1550_state { - /* soundcore stuff */ - int dev_audio; -+ int dev_mixer; - - spinlock_t lock; - struct semaphore open_sem; -@@ -114,6 +191,11 @@ static struct au1550_state { - int no_vra; - volatile psc_i2s_t *psc_addr; - -+ int level_line; -+ int level_mic; -+ int level_left; -+ int level_right; -+ - struct dmabuf { - u32 dmanr; - unsigned sample_rate; -@@ -195,60 +277,224 @@ au1550_delay(int msec) - } - } - --/* Just a place holder. The Wolfson codec is a write only device, -- * so we would have to keep a local copy of the data. -- */ --#if 0 --static u8 --rdcodec(u8 addr) --{ -- return 0 /* data */; --} --#endif -- -- - static void --wrcodec(u8 ctlreg, u8 val) -+wrcodec(u8 ctlreg, u16 val) - { - int rcnt; - extern int pb1550_wm_codec_write(u8 addr, u8 reg, u8 val); -- - /* The codec is a write only device, with a 16-bit control/data - * word. Although it is written as two bytes on the I2C, the - * format is actually 7 bits of register and 9 bits of data. - * The ls bit of the first byte is the ms bit of the data. - */ - rcnt = 0; -- while ((pb1550_wm_codec_write((0x36 >> 1), ctlreg, val) != 1) -- && (rcnt < 50)) { -+ while ((pb1550_wm_codec_write((0x36 >> 1), -+ (ctlreg << 1) | ((val >> 8) & 0x01), -+ (u8) (val & 0x00FF)) != 1) && -+ (rcnt < 50)) { - rcnt++; --#if 0 -- printk("Codec write retry %02x %02x\n", ctlreg, val); --#endif - } -+ -+ au1550_delay(10); -+} -+ -+static int -+au1550_open_mixdev(struct inode *inode, struct file *file) -+{ -+ file->private_data = &au1550_state; -+ return 0; -+} -+ -+static int -+au1550_release_mixdev(struct inode *inode, struct file *file) -+{ -+ return 0; -+} -+ -+static int wm_i2s_read_mixer(struct au1550_state *s, int oss_channel) -+{ -+ int ret = 0; -+ -+ if (WM_I2S_STEREO_MASK & (1 << oss_channel)) { -+ /* nice stereo mixers .. */ -+ -+ ret = s->level_left | (s->level_right << 8); -+ } else if (oss_channel == SOUND_MIXER_MIC) { -+ ret = 0; -+ /* TODO: Implement read mixer for input/output codecs */ -+ } -+ -+ return ret; - } - -+static void wm_i2s_write_mixer(struct au1550_state *s, int oss_channel, unsigned int left, unsigned int right) -+{ -+ if (WM_I2S_STEREO_MASK & (1 << oss_channel)) { -+ /* stereo mixers */ -+ s->level_left = left; -+ s->level_right = right; -+ -+ right = (right * WM_VOLUME_SCALE) / 100; -+ left = (left * WM_VOLUME_SCALE) / 100; -+ if (right > WM_VOLUME_SCALE) -+ right = WM_VOLUME_SCALE; -+ if (left > WM_VOLUME_SCALE) -+ left = WM_VOLUME_SCALE; -+ -+ right += WM_VOLUME_MIN; -+ left += WM_VOLUME_MIN; -+ -+ wrcodec(WM_REG_L_HEADPHONE_OUT, left); -+ wrcodec(WM_REG_R_HEADPHONE_OUT, right); -+ -+ }else if (oss_channel == SOUND_MIXER_MIC) { -+ /* TODO: implement write mixer for input/output codecs */ -+ } -+} -+ -+/* a thin wrapper for write_mixer */ -+static void wm_i2s_set_mixer(struct au1550_state *s, unsigned int oss_mixer, unsigned int val ) -+{ -+ unsigned int left,right; -+ -+ /* cleanse input a little */ -+ right = ((val >> 8) & 0xff) ; -+ left = (val & 0xff) ; -+ -+ if (right > 100) right = 100; -+ if (left > 100) left = 100; -+ -+ wm_i2s_write_mixer(s, oss_mixer, left, right); -+} -+ -+static int -+au1550_ioctl_mixdev(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) -+{ -+ struct au1550_state *s = (struct au1550_state *)file->private_data; -+ -+ int i, val = 0; -+ -+ if (cmd == SOUND_MIXER_INFO) { -+ mixer_info info; -+ strncpy(info.id, CODEC_NAME, sizeof(info.id)); -+ strncpy(info.name, CODEC_NAME, sizeof(info.name)); -+ info.modify_counter = 0; -+ if (copy_to_user((void *)arg, &info, sizeof(info))) -+ return -EFAULT; -+ return 0; -+ } -+ if (cmd == SOUND_OLD_MIXER_INFO) { -+ _old_mixer_info info; -+ strncpy(info.id, CODEC_NAME, sizeof(info.id)); -+ strncpy(info.name, CODEC_NAME, sizeof(info.name)); -+ if (copy_to_user((void *)arg, &info, sizeof(info))) -+ return -EFAULT; -+ return 0; -+ } -+ -+ if (_IOC_TYPE(cmd) != 'M' || _SIOC_SIZE(cmd) != sizeof(int)) -+ return -EINVAL; -+ -+ if (cmd == OSS_GETVERSION) -+ return put_user(SOUND_VERSION, (int *)arg); -+ -+ if (_SIOC_DIR(cmd) == _SIOC_READ) { -+ switch (_IOC_NR(cmd)) { -+ case SOUND_MIXER_RECSRC: /* give them the current record src */ -+ val = 0; -+ /* -+ if (!codec->recmask_io) { -+ val = 0; -+ } else { -+ val = codec->recmask_io(codec, 1, 0); -+ }*/ -+ break; -+ -+ case SOUND_MIXER_DEVMASK: /* give them the supported mixers */ -+ val = WM_I2S_SUPPORTED_MASK; -+ break; -+ -+ case SOUND_MIXER_RECMASK: -+ /* Arg contains a bit for each supported recording -+ * source */ -+ val = WM_I2S_RECORD_MASK; -+ break; -+ -+ case SOUND_MIXER_STEREODEVS: -+ /* Mixer channels supporting stereo */ -+ val = WM_I2S_STEREO_MASK; -+ break; -+ -+ case SOUND_MIXER_CAPS: -+ val = SOUND_CAP_EXCL_INPUT; -+ break; -+ -+ default: /* read a specific mixer */ -+ i = _IOC_NR(cmd); -+ -+ if (!supported_mixer(i)) -+ return -EINVAL; -+ -+ val = wm_i2s_read_mixer(s, i); -+ break; -+ } -+ return put_user(val, (int *)arg); -+ } -+ -+ if (_SIOC_DIR(cmd) == (_SIOC_WRITE|_SIOC_READ)) { -+ if (get_user(val, (int *)arg)) -+ return -EFAULT; -+ -+ switch (_IOC_NR(cmd)) { -+ case SOUND_MIXER_RECSRC: -+ /* Arg contains a bit for each recording source */ -+ if (!WM_I2S_RECORD_MASK) -+ return -EINVAL; -+ if (!val) -+ return 0; -+ if (!(val &= WM_I2S_RECORD_MASK)) -+ return -EINVAL; -+ -+ return 0; -+ default: /* write a specific mixer */ -+ i = _IOC_NR(cmd); -+ -+ if (!supported_mixer(i)) -+ return -EINVAL; -+ -+ wm_i2s_set_mixer(s, i, val); -+ -+ return 0; -+ } -+} -+ return -EINVAL; -+} -+ -+static loff_t -+au1550_llseek(struct file *file, loff_t offset, int origin) -+{ -+ return -ESPIPE; -+} -+ -+static /*const */ struct file_operations au1550_mixer_fops = { -+ owner:THIS_MODULE, -+ llseek:au1550_llseek, -+ ioctl:au1550_ioctl_mixdev, -+ open:au1550_open_mixdev, -+ release:au1550_release_mixdev, -+}; -+ - void --codec_init(void) -+codec_init(struct au1550_state *s) - { -- wrcodec(0x1e, 0x00); /* Reset */ -- au1550_delay(200); -- wrcodec(0x0c, 0x00); /* Power up everything */ -- au1550_delay(10); -- wrcodec(0x12, 0x00); /* Deactivate codec */ -- au1550_delay(10); -- wrcodec(0x08, 0x10); /* Select DAC outputs to line out */ -- au1550_delay(10); -- wrcodec(0x0a, 0x00); /* Disable output mute */ -- au1550_delay(10); -- wrcodec(0x05, 0x70); /* lower output volume on headphone */ -- au1550_delay(10); -- wrcodec(0x0e, 0x02); /* Set slave, 16-bit, I2S modes */ -- au1550_delay(10); -- wrcodec(0x10, 0x01); /* 12MHz (USB), 250fs */ -- au1550_delay(10); -- wrcodec(0x12, 0x01); /* Activate codec */ -- au1550_delay(10); -+ wrcodec(WM_REG_RESET, 0x00); /* Reset */ -+ wrcodec(WM_REG_POWER_DOWN_CTRL, 0x00); /* Power up everything */ -+ wrcodec(WM_REG_ACTIVE_CTRL, 0x00); /* Deactivate codec */ -+ wrcodec(WM_REG_ANALOGUE_AUDIO_PATH_CTRL, 0x10); /* Select DAC outputs to line out */ -+ wrcodec(WM_REG_DIGITAL_AUDIO_PATH_CTRL, 0x00); /* Disable output mute */ -+ wm_i2s_write_mixer(s, SOUND_MIXER_PCM, 74, 74); -+ wrcodec(WM_REG_DIGITAL_AUDIO_IF, 0x02); /* Set slave, 16-bit, I2S modes */ -+ wrcodec(WM_REG_ACTIVE_CTRL, 0x01); /* Activate codec */ - } - - /* stop the ADC before calling */ -@@ -256,27 +502,16 @@ static void - set_adc_rate(struct au1550_state *s, unsigned rate) - { - struct dmabuf *adc = &s->dma_adc; -- struct dmabuf *dac = &s->dma_dac; - -- if (s->no_vra) { -- /* calc SRC factor -- */ -+ #if defined(WM_MODE_USB) - adc->src_factor = (((SAMP_RATE*2) / rate) + 1) >> 1; - adc->sample_rate = SAMP_RATE / adc->src_factor; - return; -- } -+ #else -+ //TODO: Need code for normal mode -+ #endif - - adc->src_factor = 1; -- -- --#if 0 -- rate = rate > SAMP_RATE ? SAMP_RATE : rate; -- -- wrcodec(0, 0); /* I don't yet know what to write here if we vra */ -- -- adc->sample_rate = rate; -- dac->sample_rate = rate; --#endif - } - - /* stop the DAC before calling */ -@@ -284,26 +519,89 @@ static void - set_dac_rate(struct au1550_state *s, unsigned rate) - { - struct dmabuf *dac = &s->dma_dac; -- struct dmabuf *adc = &s->dma_adc; - -- if (s->no_vra) { -- /* calc SRC factor -- */ -- dac->src_factor = (((SAMP_RATE*2) / rate) + 1) >> 1; -- dac->sample_rate = SAMP_RATE / dac->src_factor; -- return; -+ u16 sr, ws, div, bosr, mode; -+ volatile psc_i2s_t* ip = (volatile psc_i2s_t *)I2S_PSC_BASE; -+ u32 cfg; -+ -+ #if defined(CONFIG_MIPS_FICMMP) -+ rate = ficmmp_set_i2s_sample_rate(rate); -+ #endif -+ -+ switch(rate) -+ { -+ case 96000: -+ sr = WM_SC_SR_96000; -+ ws = WS_64FS; -+ div = PSC_I2SCFG_DIV2; -+ break; -+ case 88200: -+ sr = WM_SC_SR_88200; -+ ws = WS_64FS; -+ div = PSC_I2SCFG_DIV2; -+ break; -+ case 44100: -+ sr = WM_SC_SR_44100; -+ ws = WS_128FS; -+ div = PSC_I2SCFG_DIV2; -+ break; -+ case 48000: -+ sr = WM_SC_SR_48000; -+ ws = WS_128FS; -+ div = PSC_I2SCFG_DIV2; -+ break; -+ case 32000: -+ sr = WM_SC_SR_32000; -+ ws = WS_96FS; -+ div = PSC_I2SCFG_DIV4; -+ break; -+ case 8018: -+ sr = WM_SC_SR_8018; -+ ws = WS_128FS; -+ div = PSC_I2SCFG_DIV2; -+ break; -+ case 8000: -+ default: -+ sr = WM_SC_SR_8000; -+ ws = WS_96FS; -+ div = PSC_I2SCFG_DIV16; -+ break; - } - -+ #if defined(WM_MODE_USB) -+ mode = WM_SC_MODE_USB; -+ #else -+ mode = WM_SC_MODE_NORMAL; -+ #endif -+ -+ bosr = 0; -+ - dac->src_factor = 1; -+ dac->sample_rate = rate; - --#if 0 -- rate = rate > SAMP_RATE ? SAMP_RATE : rate; -+ /* Deactivate codec */ -+ wrcodec(WM_REG_ACTIVE_CTRL, 0x00); - -- wrcodec(0, 0); /* I don't yet know what to write here if we vra */ -+ /* Disable I2S controller */ -+ ip->psc_i2scfg &= ~PSC_I2SCFG_DE_ENABLE; -+ /* Wait for device disabled */ -+ while ((ip->psc_i2sstat & PSC_I2SSTAT_DR) == 1); -+ -+ cfg = ip->psc_i2scfg; -+ /* Clear WS and DIVIDER values */ -+ cfg &= ~(PSC_I2SCFG_WS_MASK | PSC_I2SCFG_DIV_MASK); -+ cfg |= PSC_I2SCFG_WS(ws) | div; -+ /* Reconfigure and enable */ -+ ip->psc_i2scfg = cfg | PSC_I2SCFG_DE_ENABLE; - -- adc->sample_rate = rate; -- dac->sample_rate = rate; --#endif -+ /* Wait for device enabled */ -+ while ((ip->psc_i2sstat & PSC_I2SSTAT_DR) == 0); -+ -+ /* Set appropriate sampling rate */ -+ wrcodec(WM_REG_SAMPLING_CONTROL, bosr | mode | sr); -+ -+ /* Activate codec */ -+ wrcodec(WM_REG_ACTIVE_CTRL, 0x01); - } - - static void -@@ -354,8 +652,7 @@ stop_adc(struct au1550_state *s) - ip->psc_i2spcr = PSC_I2SPCR_RP; - au_sync(); - -- /* Wait for Receive Busy to show disabled. -- */ -+ /* Wait for Receive Busy to show disabled. */ - do { - stat = ip->psc_i2sstat; - au_sync(); -@@ -463,7 +760,6 @@ prog_dmabuf(struct au1550_state *s, stru - if (db->num_channels == 1) - db->cnt_factor *= 2; - db->cnt_factor *= db->src_factor; -- - db->count = 0; - db->dma_qcount = 0; - db->nextIn = db->nextOut = db->rawbuf; -@@ -546,12 +842,13 @@ dac_dma_interrupt(int irq, void *dev_id, - if (i2s_stat & (PSC_I2SSTAT_TF | PSC_I2SSTAT_TR | PSC_I2SSTAT_TF)) - dbg("I2S status = 0x%08x", i2s_stat); - #endif -+ - db->dma_qcount--; - - if (db->count >= db->fragsize) { -- if (au1xxx_dbdma_put_source(db->dmanr, db->nextOut, -- db->fragsize) == 0) { -- err("qcount < 2 and no ring room!"); -+ if (au1xxx_dbdma_put_source(db->dmanr, db->nextOut, db->fragsize) == 0) -+ { -+ err("qcount < MIN_Q_COUNT and no ring room!"); - } - db->nextOut += db->fragsize; - if (db->nextOut >= db->rawbuf + db->dmasize) -@@ -606,65 +903,43 @@ adc_dma_interrupt(int irq, void *dev_id, - - } - --static loff_t --au1550_llseek(struct file *file, loff_t offset, int origin) --{ -- return -ESPIPE; --} -- -- --#if 0 --static int --au1550_open_mixdev(struct inode *inode, struct file *file) --{ -- file->private_data = &au1550_state; -- return 0; --} -- --static int --au1550_release_mixdev(struct inode *inode, struct file *file) --{ -- return 0; --} -- --static int --mixdev_ioctl(struct ac97_codec *codec, unsigned int cmd, -- unsigned long arg) --{ -- return codec->mixer_ioctl(codec, cmd, arg); --} -- --static int --au1550_ioctl_mixdev(struct inode *inode, struct file *file, -- unsigned int cmd, unsigned long arg) --{ -- struct au1550_state *s = (struct au1550_state *)file->private_data; -- struct ac97_codec *codec = s->codec; -- -- return mixdev_ioctl(codec, cmd, arg); --} -- --static /*const */ struct file_operations au1550_mixer_fops = { -- owner:THIS_MODULE, -- llseek:au1550_llseek, -- ioctl:au1550_ioctl_mixdev, -- open:au1550_open_mixdev, -- release:au1550_release_mixdev, --}; --#endif -- - static int - drain_dac(struct au1550_state *s, int nonblock) - { - unsigned long flags; - int count, tmo; - -+ struct dmabuf *db = &s->dma_dac; -+ -+ //DPRINTF(); - if (s->dma_dac.mapped || !s->dma_dac.ready || s->dma_dac.stopped) - return 0; - - for (;;) { - spin_lock_irqsave(&s->lock, flags); -- count = s->dma_dac.count; -+ count = db->count; -+ -+ /* Pad the ddma buffer with zeros if the amount remaining -+ * is not a multiple of fragsize */ -+ if(count % db->fragsize != 0) -+ { -+ int pad = db->fragsize - (count % db->fragsize); -+ char* bufptr = db->nextIn; -+ char* bufend = db->rawbuf + db->dmasize; -+ -+ if((bufend - bufptr) < pad) -+ printk("Error! ddma padding is bigger than available ring space!\n"); -+ else -+ { -+ memset((void*)bufptr, 0, pad); -+ count += pad; -+ db->nextIn += pad; -+ db->count += pad; -+ if (db->dma_qcount == 0) -+ start_dac(s); -+ db->dma_qcount++; -+ } -+ } - spin_unlock_irqrestore(&s->lock, flags); - if (count <= 0) - break; -@@ -672,9 +947,9 @@ drain_dac(struct au1550_state *s, int no - break; - if (nonblock) - return -EBUSY; -- tmo = 1000 * count / (s->no_vra ? -- SAMP_RATE : s->dma_dac.sample_rate); -+ tmo = 1000 * count / s->dma_dac.sample_rate; - tmo /= s->dma_dac.dma_bytes_per_sample; -+ - au1550_delay(tmo); - } - if (signal_pending(current)) -@@ -698,8 +973,7 @@ static inline s16 U8_TO_S16(u8 ch) - * If interpolating (no VRA), duplicate every audio frame src_factor times. - */ - static int --translate_from_user(struct dmabuf *db, char* dmabuf, char* userbuf, -- int dmacount) -+translate_from_user(struct dmabuf *db, char* dmabuf, char* userbuf, int dmacount) - { - int sample, i; - int interp_bytes_per_sample; -@@ -737,11 +1011,12 @@ translate_from_user(struct dmabuf *db, c - - /* duplicate every audio frame src_factor times - */ -- for (i = 0; i < db->src_factor; i++) -+ for (i = 0; i < db->src_factor; i++) { - memcpy(dmabuf, dmasample, db->dma_bytes_per_sample); -+ dmabuf += interp_bytes_per_sample; -+ } - - userbuf += db->user_bytes_per_sample; -- dmabuf += interp_bytes_per_sample; - } - - return num_samples * interp_bytes_per_sample; -@@ -996,15 +1271,14 @@ au1550_write(struct file *file, const ch - * on the dma queue. If the queue count reaches zero, - * we know the dma has stopped. - */ -- while ((db->dma_qcount < 2) && (db->count >= db->fragsize)) { -+ while ((db->dma_qcount < MIN_Q_COUNT) && (db->count >= db->fragsize)) { - if (au1xxx_dbdma_put_source(db->dmanr, db->nextOut, - db->fragsize) == 0) { -- err("qcount < 2 and no ring room!"); -+ err("qcount < MIN_Q_COUNT and no ring room!"); - } - db->nextOut += db->fragsize; - if (db->nextOut >= db->rawbuf + db->dmasize) - db->nextOut -= db->dmasize; -- db->count -= db->fragsize; - db->total_bytes += db->dma_fragsize; - if (db->dma_qcount == 0) - start_dac(s); -@@ -1017,7 +1291,6 @@ au1550_write(struct file *file, const ch - buffer += usercnt; - ret += usercnt; - } /* while (count > 0) */ -- - out: - up(&s->sem); - out2: -@@ -1371,9 +1644,6 @@ au1550_ioctl(struct inode *inode, struct - s->dma_dac.cnt_factor; - abinfo.fragstotal = s->dma_dac.numfrag; - abinfo.fragments = abinfo.bytes >> s->dma_dac.fragshift; --#ifdef AU1000_VERBOSE_DEBUG -- dbg("bytes=%d, fragments=%d", abinfo.bytes, abinfo.fragments); --#endif - return copy_to_user((void *) arg, &abinfo, - sizeof(abinfo)) ? -EFAULT : 0; - -@@ -1536,13 +1806,9 @@ au1550_ioctl(struct inode *inode, struct - case SNDCTL_DSP_SETSYNCRO: - case SOUND_PCM_READ_FILTER: - return -EINVAL; -+ default: break; - } -- --#if 0 -- return mixdev_ioctl(s->codec, cmd, arg); --#else - return 0; --#endif - } - - -@@ -1664,15 +1930,15 @@ static /*const */ struct file_operations - MODULE_AUTHOR("Advanced Micro Devices (AMD), dan@embeddededge.com"); - MODULE_DESCRIPTION("Au1550 Audio Driver"); - -+#if defined(WM_MODE_USB) - /* Set up an internal clock for the PSC3. This will then get - * driven out of the Au1550 as the master. - */ - static void - intclk_setup(void) - { -- uint clk, rate, stat; -- -- /* Wire up Freq4 as a clock for the PSC3. -+ uint clk, rate; -+ /* Wire up Freq4 as a clock for the PSC. - * We know SMBus uses Freq3. - * By making changes to this rate, plus the word strobe - * size, we can make fine adjustments to the actual data rate. -@@ -1700,11 +1966,17 @@ intclk_setup(void) - */ - clk = au_readl(SYS_CLKSRC); - au_sync(); -+#if defined(CONFIG_SOC_AU1550) - clk &= ~0x01f00000; - clk |= (6 << 22); -+#elif defined(CONFIG_SOC_AU1200) -+ clk &= ~0x3e000000; -+ clk |= (6 << 27); -+#endif - au_writel(clk, SYS_CLKSRC); - au_sync(); - } -+#endif - - static int __devinit - au1550_probe(void) -@@ -1724,6 +1996,11 @@ au1550_probe(void) - init_MUTEX(&s->open_sem); - spin_lock_init(&s->lock); - -+ /* CPLD Mux for I2s */ -+ -+#if defined(CONFIG_MIPS_PB1200) -+ bcsr->resets |= BCSR_RESETS_PCS1MUX; -+#endif - - s->psc_addr = (volatile psc_i2s_t *)I2S_PSC_BASE; - ip = s->psc_addr; -@@ -1765,9 +2042,8 @@ au1550_probe(void) - - if ((s->dev_audio = register_sound_dsp(&au1550_audio_fops, -1)) < 0) - goto err_dev1; --#if 0 -- if ((s->codec->dev_mixer = -- register_sound_mixer(&au1550_mixer_fops, -1)) < 0) -+#if 1 -+ if ((s->dev_mixer = register_sound_mixer(&au1550_mixer_fops, -1)) < 0) - goto err_dev2; - #endif - -@@ -1777,7 +2053,6 @@ au1550_probe(void) - proc_au1550_dump, NULL); - #endif /* AU1550_DEBUG */ - -- intclk_setup(); - - /* The GPIO for the appropriate PSC was configured by the - * board specific start up. -@@ -1786,7 +2061,12 @@ au1550_probe(void) - */ - ip->psc_ctrl = PSC_CTRL_DISABLE; /* Disable PSC */ - au_sync(); -+#if defined(WM_MODE_USB) -+ intclk_setup(); - ip->psc_sel = (PSC_SEL_CLK_INTCLK | PSC_SEL_PS_I2SMODE); -+#else -+ ip->psc_sel = (PSC_SEL_CLK_EXTCLK | PSC_SEL_PS_I2SMODE); -+#endif - au_sync(); - - /* Enable PSC -@@ -1806,42 +2086,18 @@ au1550_probe(void) - * Actual I2S mode (first bit delayed by one clock). - * Master mode (We provide the clock from the PSC). - */ -- val = PSC_I2SCFG_SET_LEN(16); --#ifdef TRY_441KHz -- /* This really should be 250, but it appears that all of the -- * PLLs, dividers and so on in the chain shift it. That's the -- * problem with sourceing the clock instead of letting the very -- * stable codec provide it. But, the PSC doesn't appear to want -- * to work in slave mode, so this is what we get. It's not -- * studio quality timing, but it's good enough for listening -- * to mp3s. -- */ -- val |= PSC_I2SCFG_SET_WS(252); --#else -- val |= PSC_I2SCFG_SET_WS(250); --#endif -- val |= PSC_I2SCFG_RT_FIFO8 | PSC_I2SCFG_TT_FIFO8 | \ -+ -+ val = PSC_I2SCFG_SET_LEN(16) | PSC_I2SCFG_WS(WS_128FS) | PSC_I2SCFG_RT_FIFO8 | PSC_I2SCFG_TT_FIFO8 | \ - PSC_I2SCFG_BI | PSC_I2SCFG_XM; - -- ip->psc_i2scfg = val; -- au_sync(); -- val |= PSC_I2SCFG_DE_ENABLE; -- ip->psc_i2scfg = val; -- au_sync(); -+ ip->psc_i2scfg = val | PSC_I2SCFG_DE_ENABLE; - -- /* Wait for Device ready. -- */ -- do { -- val = ip->psc_i2sstat; -- au_sync(); -- } while ((val & PSC_I2SSTAT_DR) == 0); -+ set_dac_rate(s, 8000); //Set default rate - -- val = ip->psc_i2scfg; -- au_sync(); -+ codec_init(s); - -- codec_init(); -+ s->no_vra = vra ? 0 : 1; - -- s->no_vra = 1; - if (s->no_vra) - info("no VRA, interpolating and decimating"); - -@@ -1866,6 +2122,8 @@ au1550_probe(void) - err_dev2: - unregister_sound_dsp(s->dev_audio); - #endif -+ err_dev2: -+ unregister_sound_dsp(s->dev_audio); - err_dev1: - au1xxx_dbdma_chan_free(s->dma_adc.dmanr); - err_dma2: ---- a/drivers/sound/au1550_psc.c -+++ b/drivers/sound/au1550_psc.c -@@ -30,6 +30,7 @@ - * 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ -+ - #include <linux/version.h> - #include <linux/module.h> - #include <linux/string.h> -@@ -63,6 +64,14 @@ - #include <asm/db1x00.h> - #endif - -+#ifdef CONFIG_MIPS_PB1200 -+#include <asm/pb1200.h> -+#endif -+ -+#ifdef CONFIG_MIPS_DB1200 -+#include <asm/db1200.h> -+#endif -+ - #undef OSS_DOCUMENTED_MIXER_SEMANTICS - - #define AU1550_MODULE_NAME "Au1550 psc audio" -@@ -521,7 +530,14 @@ stop_adc(struct au1550_state *s) - spin_unlock_irqrestore(&s->lock, flags); - } - -- -+/* -+ NOTE: The xmit slots cannot be changed on the fly when in full-duplex -+ because the AC'97 block must be stopped/started. When using this driver -+ in full-duplex (in & out at the same time), the DMA engine will stop if -+ you disable the block. -+ TODO: change implementation to properly restart adc/dac after setting -+ xmit slots. -+*/ - static void - set_xmit_slots(int num_channels) - { -@@ -565,6 +581,14 @@ set_xmit_slots(int num_channels) - } while ((stat & PSC_AC97STAT_DR) == 0); - } - -+/* -+ NOTE: The recv slots cannot be changed on the fly when in full-duplex -+ because the AC'97 block must be stopped/started. When using this driver -+ in full-duplex (in & out at the same time), the DMA engine will stop if -+ you disable the block. -+ TODO: change implementation to properly restart adc/dac after setting -+ recv slots. -+*/ - static void - set_recv_slots(int num_channels) - { -@@ -608,7 +632,6 @@ start_dac(struct au1550_state *s) - - spin_lock_irqsave(&s->lock, flags); - -- set_xmit_slots(db->num_channels); - au_writel(PSC_AC97PCR_TC, PSC_AC97PCR); - au_sync(); - au_writel(PSC_AC97PCR_TS, PSC_AC97PCR); -@@ -640,7 +663,6 @@ start_adc(struct au1550_state *s) - db->nextIn -= db->dmasize; - } - -- set_recv_slots(db->num_channels); - au1xxx_dbdma_start(db->dmanr); - au_writel(PSC_AC97PCR_RC, PSC_AC97PCR); - au_sync(); -@@ -752,12 +774,16 @@ dac_dma_interrupt(int irq, void *dev_id, - if (ac97c_stat & (AC97C_XU | AC97C_XO | AC97C_TE)) - dbg("AC97C status = 0x%08x", ac97c_stat); - #endif -+ /* There is a possiblity that we are getting 1 interrupt for -+ multiple descriptors. Use ddma api to find out how many -+ completed. -+ */ - db->dma_qcount--; - - if (db->count >= db->fragsize) { - if (au1xxx_dbdma_put_source(db->dmanr, db->nextOut, - db->fragsize) == 0) { -- err("qcount < 2 and no ring room!"); -+ err("qcount < 2 and no ring room1!"); - } - db->nextOut += db->fragsize; - if (db->nextOut >= db->rawbuf + db->dmasize) -@@ -941,11 +967,12 @@ translate_from_user(struct dmabuf *db, c - - /* duplicate every audio frame src_factor times - */ -- for (i = 0; i < db->src_factor; i++) -+ for (i = 0; i < db->src_factor; i++) { - memcpy(dmabuf, dmasample, db->dma_bytes_per_sample); -+ dmabuf += interp_bytes_per_sample; -+ } - - userbuf += db->user_bytes_per_sample; -- dmabuf += interp_bytes_per_sample; - } - - return num_samples * interp_bytes_per_sample; -@@ -1203,7 +1230,7 @@ au1550_write(struct file *file, const ch - while ((db->dma_qcount < 2) && (db->count >= db->fragsize)) { - if (au1xxx_dbdma_put_source(db->dmanr, db->nextOut, - db->fragsize) == 0) { -- err("qcount < 2 and no ring room!"); -+ err("qcount < 2 and no ring room!0"); - } - db->nextOut += db->fragsize; - if (db->nextOut >= db->rawbuf + db->dmasize) -@@ -1481,6 +1508,7 @@ au1550_ioctl(struct inode *inode, struct - return -EINVAL; - stop_adc(s); - s->dma_adc.num_channels = val; -+ set_recv_slots(val); - if ((ret = prog_dmabuf_adc(s))) - return ret; - } -@@ -1538,6 +1566,7 @@ au1550_ioctl(struct inode *inode, struct - } - - s->dma_dac.num_channels = val; -+ set_xmit_slots(val); - if ((ret = prog_dmabuf_dac(s))) - return ret; - } -@@ -1832,10 +1861,8 @@ au1550_open(struct inode *inode, struct - down(&s->open_sem); - } - -- stop_dac(s); -- stop_adc(s); -- - if (file->f_mode & FMODE_READ) { -+ stop_adc(s); - s->dma_adc.ossfragshift = s->dma_adc.ossmaxfrags = - s->dma_adc.subdivision = s->dma_adc.total_bytes = 0; - s->dma_adc.num_channels = 1; -@@ -1846,6 +1873,7 @@ au1550_open(struct inode *inode, struct - } - - if (file->f_mode & FMODE_WRITE) { -+ stop_dac(s); - s->dma_dac.ossfragshift = s->dma_dac.ossmaxfrags = - s->dma_dac.subdivision = s->dma_dac.total_bytes = 0; - s->dma_dac.num_channels = 1; -@@ -2091,6 +2119,9 @@ au1550_probe(void) - ac97_read_proc, &s->codec); - #endif - -+ set_xmit_slots(1); -+ set_recv_slots(1); -+ - return 0; - - err_dev3: ---- a/drivers/sound/Config.in -+++ b/drivers/sound/Config.in -@@ -72,10 +72,15 @@ fi - if [ "$CONFIG_DDB5477" = "y" ]; then - dep_tristate ' NEC Vrc5477 AC97 sound' CONFIG_SOUND_VRC5477 $CONFIG_SOUND - fi --if [ "$CONFIG_SOC_AU1X00" = "y" -o "$CONFIG_SOC_AU1500" = "y" ]; then -- dep_tristate ' Au1x00 Sound' CONFIG_SOUND_AU1X00 $CONFIG_SOUND -- dep_tristate ' Au1550 PSC Sound' CONFIG_SOUND_AU1550_PSC $CONFIG_SOUND -- dep_tristate ' Au1550 I2S Sound' CONFIG_SOUND_AU1550_I2S $CONFIG_SOUND -+if [ "$CONFIG_SOC_AU1000" = "y" -o \ -+ "$CONFIG_SOC_AU1500" = "y" -o \ -+ "$CONFIG_SOC_AU1100" = "y" ]; then -+ dep_tristate ' Au1x00 AC97 Sound' CONFIG_SOUND_AU1X00 $CONFIG_SOUND -+fi -+if [ "$CONFIG_SOC_AU1550" = "y" -o \ -+ "$CONFIG_SOC_AU1200" = "y" ]; then -+ dep_tristate ' Au1550/Au1200 PSC AC97 Sound' CONFIG_SOUND_AU1550_PSC $CONFIG_SOUND -+ dep_tristate ' Au1550/Au1200 PSC I2S Sound' CONFIG_SOUND_AU1550_I2S $CONFIG_SOUND - fi - - dep_tristate ' Trident 4DWave DX/NX, SiS 7018 or ALi 5451 PCI Audio Core' CONFIG_SOUND_TRIDENT $CONFIG_SOUND $CONFIG_PCI ---- a/drivers/tc/lk201.c -+++ b/drivers/tc/lk201.c -@@ -5,7 +5,7 @@ - * for more details. - * - * Copyright (C) 1999-2002 Harald Koerfgen <hkoerfg@web.de> -- * Copyright (C) 2001, 2002, 2003 Maciej W. Rozycki <macro@ds2.pg.gda.pl> -+ * Copyright (C) 2001, 2002, 2003, 2004 Maciej W. Rozycki - */ - - #include <linux/config.h> -@@ -23,8 +23,8 @@ - #include <asm/keyboard.h> - #include <asm/dec/tc.h> - #include <asm/dec/machtype.h> -+#include <asm/dec/serial.h> - --#include "zs.h" - #include "lk201.h" - - /* -@@ -55,19 +55,20 @@ unsigned char *kbd_sysrq_xlate = lk201_s - unsigned char kbd_sysrq_key = -1; - #endif - --#define KEYB_LINE 3 -+#define KEYB_LINE_ZS 3 -+#define KEYB_LINE_DZ 0 - --static int __init lk201_init(struct dec_serial *); --static void __init lk201_info(struct dec_serial *); --static void lk201_kbd_rx_char(unsigned char, unsigned char); -+static int __init lk201_init(void *); -+static void __init lk201_info(void *); -+static void lk201_rx_char(unsigned char, unsigned char); - --struct zs_hook lk201_kbdhook = { -+static struct dec_serial_hook lk201_hook = { - .init_channel = lk201_init, - .init_info = lk201_info, - .rx_char = NULL, - .poll_rx_char = NULL, - .poll_tx_char = NULL, -- .cflags = B4800 | CS8 | CSTOPB | CLOCAL -+ .cflags = B4800 | CS8 | CSTOPB | CLOCAL, - }; - - /* -@@ -93,28 +94,28 @@ static unsigned char lk201_reset_string[ - LK_CMD_ENB_BELL, LK_PARAM_VOLUME(4), - }; - --static struct dec_serial* lk201kbd_info; -+static void *lk201_handle; - --static int lk201_send(struct dec_serial *info, unsigned char ch) -+static int lk201_send(unsigned char ch) - { -- if (info->hook->poll_tx_char(info, ch)) { -+ if (lk201_hook.poll_tx_char(lk201_handle, ch)) { - printk(KERN_ERR "lk201: transmit timeout\n"); - return -EIO; - } - return 0; - } - --static inline int lk201_get_id(struct dec_serial *info) -+static inline int lk201_get_id(void) - { -- return lk201_send(info, LK_CMD_REQ_ID); -+ return lk201_send(LK_CMD_REQ_ID); - } - --static int lk201_reset(struct dec_serial *info) -+static int lk201_reset(void) - { - int i, r; - - for (i = 0; i < sizeof(lk201_reset_string); i++) { -- r = lk201_send(info, lk201_reset_string[i]); -+ r = lk201_send(lk201_reset_string[i]); - if (r < 0) - return r; - } -@@ -203,24 +204,26 @@ static void parse_kbd_rate(struct kbd_re - - static int write_kbd_rate(struct kbd_repeat *rep) - { -- struct dec_serial* info = lk201kbd_info; - int delay, rate; - int i; - - delay = rep->delay / 5; - rate = rep->rate; - for (i = 0; i < 4; i++) { -- if (info->hook->poll_tx_char(info, LK_CMD_RPT_RATE(i))) -+ if (lk201_hook.poll_tx_char(lk201_handle, -+ LK_CMD_RPT_RATE(i))) - return 1; -- if (info->hook->poll_tx_char(info, LK_PARAM_DELAY(delay))) -+ if (lk201_hook.poll_tx_char(lk201_handle, -+ LK_PARAM_DELAY(delay))) - return 1; -- if (info->hook->poll_tx_char(info, LK_PARAM_RATE(rate))) -+ if (lk201_hook.poll_tx_char(lk201_handle, -+ LK_PARAM_RATE(rate))) - return 1; - } - return 0; - } - --static int lk201kbd_rate(struct kbd_repeat *rep) -+static int lk201_kbd_rate(struct kbd_repeat *rep) - { - if (rep == NULL) - return -EINVAL; -@@ -237,10 +240,8 @@ static int lk201kbd_rate(struct kbd_repe - return 0; - } - --static void lk201kd_mksound(unsigned int hz, unsigned int ticks) -+static void lk201_kd_mksound(unsigned int hz, unsigned int ticks) - { -- struct dec_serial* info = lk201kbd_info; -- - if (!ticks) - return; - -@@ -253,20 +254,19 @@ static void lk201kd_mksound(unsigned int - ticks = 7; - ticks = 7 - ticks; - -- if (info->hook->poll_tx_char(info, LK_CMD_ENB_BELL)) -+ if (lk201_hook.poll_tx_char(lk201_handle, LK_CMD_ENB_BELL)) - return; -- if (info->hook->poll_tx_char(info, LK_PARAM_VOLUME(ticks))) -+ if (lk201_hook.poll_tx_char(lk201_handle, LK_PARAM_VOLUME(ticks))) - return; -- if (info->hook->poll_tx_char(info, LK_CMD_BELL)) -+ if (lk201_hook.poll_tx_char(lk201_handle, LK_CMD_BELL)) - return; - } - - void kbd_leds(unsigned char leds) - { -- struct dec_serial* info = lk201kbd_info; - unsigned char l = 0; - -- if (!info) /* FIXME */ -+ if (!lk201_handle) /* FIXME */ - return; - - /* FIXME -- Only Hold and Lock LEDs for now. --macro */ -@@ -275,13 +275,13 @@ void kbd_leds(unsigned char leds) - if (leds & LED_CAP) - l |= LK_LED_LOCK; - -- if (info->hook->poll_tx_char(info, LK_CMD_LEDS_ON)) -+ if (lk201_hook.poll_tx_char(lk201_handle, LK_CMD_LEDS_ON)) - return; -- if (info->hook->poll_tx_char(info, LK_PARAM_LED_MASK(l))) -+ if (lk201_hook.poll_tx_char(lk201_handle, LK_PARAM_LED_MASK(l))) - return; -- if (info->hook->poll_tx_char(info, LK_CMD_LEDS_OFF)) -+ if (lk201_hook.poll_tx_char(lk201_handle, LK_CMD_LEDS_OFF)) - return; -- if (info->hook->poll_tx_char(info, LK_PARAM_LED_MASK(~l))) -+ if (lk201_hook.poll_tx_char(lk201_handle, LK_PARAM_LED_MASK(~l))) - return; - } - -@@ -307,7 +307,7 @@ char kbd_unexpected_up(unsigned char key - return 0x80; - } - --static void lk201_kbd_rx_char(unsigned char ch, unsigned char stat) -+static void lk201_rx_char(unsigned char ch, unsigned char fl) - { - static unsigned char id[6]; - static int id_i; -@@ -316,9 +316,8 @@ static void lk201_kbd_rx_char(unsigned c - static int prev_scancode; - unsigned char c = scancodeRemap[ch]; - -- if (stat && stat != TTY_OVERRUN) { -- printk(KERN_ERR "lk201: keyboard receive error: 0x%02x\n", -- stat); -+ if (fl != TTY_NORMAL && fl != TTY_OVERRUN) { -+ printk(KERN_ERR "lk201: keyboard receive error: 0x%02x\n", fl); - return; - } - -@@ -335,7 +334,7 @@ static void lk201_kbd_rx_char(unsigned c - /* OK, the power-up concluded. */ - lk201_report(id); - if (id[2] == LK_STAT_PWRUP_OK) -- lk201_get_id(lk201kbd_info); -+ lk201_get_id(); - else { - id_i = 0; - printk(KERN_ERR "lk201: keyboard power-up " -@@ -345,7 +344,7 @@ static void lk201_kbd_rx_char(unsigned c - /* We got the ID; report it and start operation. */ - id_i = 0; - lk201_id(id); -- lk201_reset(lk201kbd_info); -+ lk201_reset(); - } - return; - } -@@ -398,29 +397,28 @@ static void lk201_kbd_rx_char(unsigned c - tasklet_schedule(&keyboard_tasklet); - } - --static void __init lk201_info(struct dec_serial *info) -+static void __init lk201_info(void *handle) - { - } - --static int __init lk201_init(struct dec_serial *info) -+static int __init lk201_init(void *handle) - { - /* First install handlers. */ -- lk201kbd_info = info; -- kbd_rate = lk201kbd_rate; -- kd_mksound = lk201kd_mksound; -+ lk201_handle = handle; -+ kbd_rate = lk201_kbd_rate; -+ kd_mksound = lk201_kd_mksound; - -- info->hook->rx_char = lk201_kbd_rx_char; -+ lk201_hook.rx_char = lk201_rx_char; - - /* Then just issue a reset -- the handlers will do the rest. */ -- lk201_send(info, LK_CMD_POWER_UP); -+ lk201_send(LK_CMD_POWER_UP); - - return 0; - } - - void __init kbd_init_hw(void) - { -- extern int register_zs_hook(unsigned int, struct zs_hook *); -- extern int unregister_zs_hook(unsigned int); -+ int keyb_line; - - /* Maxine uses LK501 at the Access.Bus. */ - if (!LK_IFACE) -@@ -428,19 +426,15 @@ void __init kbd_init_hw(void) - - printk(KERN_INFO "lk201: DECstation LK keyboard driver v0.05.\n"); - -- if (LK_IFACE_ZS) { -- /* -- * kbd_init_hw() is being called before -- * rs_init() so just register the kbd hook -- * and let zs_init do the rest :-) -- */ -- if(!register_zs_hook(KEYB_LINE, &lk201_kbdhook)) -- unregister_zs_hook(KEYB_LINE); -- } else { -- /* -- * TODO: modify dz.c to allow similar hooks -- * for LK201 handling on DS2100, DS3100, and DS5000/200 -- */ -- printk(KERN_ERR "lk201: support for DZ11 not yet ready.\n"); -- } -+ /* -+ * kbd_init_hw() is being called before -+ * rs_init() so just register the kbd hook -+ * and let zs_init do the rest :-) -+ */ -+ if (LK_IFACE_ZS) -+ keyb_line = KEYB_LINE_ZS; -+ else -+ keyb_line = KEYB_LINE_DZ; -+ if (!register_dec_serial_hook(keyb_line, &lk201_hook)) -+ unregister_dec_serial_hook(keyb_line); - } ---- a/drivers/tc/zs.c -+++ b/drivers/tc/zs.c -@@ -68,6 +68,8 @@ - #include <asm/bitops.h> - #include <asm/uaccess.h> - #include <asm/bootinfo.h> -+#include <asm/dec/serial.h> -+ - #ifdef CONFIG_DECSTATION - #include <asm/dec/interrupts.h> - #include <asm/dec/machtype.h> -@@ -160,8 +162,8 @@ struct tty_struct zs_ttys[NUM_CHANNELS]; - #ifdef CONFIG_SERIAL_DEC_CONSOLE - static struct console sercons; - #endif --#if defined(CONFIG_SERIAL_DEC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) \ -- && !defined(MODULE) -+#if defined(CONFIG_SERIAL_DEC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) && \ -+ !defined(MODULE) - static unsigned long break_pressed; /* break, really ... */ - #endif - -@@ -196,7 +198,6 @@ static int serial_refcount; - /* - * Debugging. - */ --#undef SERIAL_DEBUG_INTR - #undef SERIAL_DEBUG_OPEN - #undef SERIAL_DEBUG_FLOW - #undef SERIAL_DEBUG_THROTTLE -@@ -221,10 +222,6 @@ static struct tty_struct *serial_table[N - static struct termios *serial_termios[NUM_CHANNELS]; - static struct termios *serial_termios_locked[NUM_CHANNELS]; - --#ifndef MIN --#define MIN(a,b) ((a) < (b) ? (a) : (b)) --#endif -- - /* - * tmp_buf is used as a temporary buffer by serial_write. We need to - * lock it in case the copy_from_user blocks while swapping in a page, -@@ -386,8 +383,6 @@ static inline void rs_recv_clear(struct - * ----------------------------------------------------------------------- - */ - --static int tty_break; /* Set whenever BREAK condition is detected. */ -- - /* - * This routine is used by the interrupt handler to schedule - * processing in the software interrupt portion of the driver. -@@ -414,20 +409,15 @@ static _INLINE_ void receive_chars(struc - if (!tty && (!info->hook || !info->hook->rx_char)) - continue; - -- if (tty_break) { -- tty_break = 0; --#if defined(CONFIG_SERIAL_DEC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) && !defined(MODULE) -- if (info->line == sercons.index) { -- if (!break_pressed) { -- break_pressed = jiffies; -- goto ignore_char; -- } -- break_pressed = 0; -- } --#endif -+ flag = TTY_NORMAL; -+ if (info->tty_break) { -+ info->tty_break = 0; - flag = TTY_BREAK; - if (info->flags & ZILOG_SAK) - do_SAK(tty); -+ /* Ignore the null char got when BREAK is removed. */ -+ if (ch == 0) -+ continue; - } else { - if (stat & Rx_OVR) { - flag = TTY_OVERRUN; -@@ -435,20 +425,22 @@ static _INLINE_ void receive_chars(struc - flag = TTY_FRAME; - } else if (stat & PAR_ERR) { - flag = TTY_PARITY; -- } else -- flag = 0; -- if (flag) -+ } -+ if (flag != TTY_NORMAL) - /* reset the error indication */ - write_zsreg(info->zs_channel, R0, ERR_RES); - } - --#if defined(CONFIG_SERIAL_DEC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) && !defined(MODULE) -+#if defined(CONFIG_SERIAL_DEC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) && \ -+ !defined(MODULE) - if (break_pressed && info->line == sercons.index) { -- if (ch != 0 && -- time_before(jiffies, break_pressed + HZ*5)) { -+ /* Ignore the null char got when BREAK is removed. */ -+ if (ch == 0) -+ continue; -+ if (time_before(jiffies, break_pressed + HZ * 5)) { - handle_sysrq(ch, regs, NULL, NULL); - break_pressed = 0; -- goto ignore_char; -+ continue; - } - break_pressed = 0; - } -@@ -459,23 +451,7 @@ static _INLINE_ void receive_chars(struc - return; - } - -- if (tty->flip.count >= TTY_FLIPBUF_SIZE) { -- static int flip_buf_ovf; -- ++flip_buf_ovf; -- continue; -- } -- tty->flip.count++; -- { -- static int flip_max_cnt; -- if (flip_max_cnt < tty->flip.count) -- flip_max_cnt = tty->flip.count; -- } -- -- *tty->flip.flag_buf_ptr++ = flag; -- *tty->flip.char_buf_ptr++ = ch; --#if defined(CONFIG_SERIAL_DEC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) && !defined(MODULE) -- ignore_char: --#endif -+ tty_insert_flip_char(tty, ch, flag); - } - if (tty) - tty_flip_buffer_push(tty); -@@ -517,11 +493,15 @@ static _INLINE_ void status_handle(struc - /* Get status from Read Register 0 */ - stat = read_zsreg(info->zs_channel, R0); - -- if (stat & BRK_ABRT) { --#ifdef SERIAL_DEBUG_INTR -- printk("handling break...."); -+ if ((stat & BRK_ABRT) && !(info->read_reg_zero & BRK_ABRT)) { -+#if defined(CONFIG_SERIAL_DEC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) && \ -+ !defined(MODULE) -+ if (info->line == sercons.index) { -+ if (!break_pressed) -+ break_pressed = jiffies; -+ } else - #endif -- tty_break = 1; -+ info->tty_break = 1; - } - - if (info->zs_channel != info->zs_chan_a) { -@@ -957,7 +937,7 @@ static int rs_write(struct tty_struct * - save_flags(flags); - while (1) { - cli(); -- c = MIN(count, MIN(SERIAL_XMIT_SIZE - info->xmit_cnt - 1, -+ c = min(count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1, - SERIAL_XMIT_SIZE - info->xmit_head)); - if (c <= 0) - break; -@@ -965,7 +945,7 @@ static int rs_write(struct tty_struct * - if (from_user) { - down(&tmp_buf_sem); - copy_from_user(tmp_buf, buf, c); -- c = MIN(c, MIN(SERIAL_XMIT_SIZE - info->xmit_cnt - 1, -+ c = min(c, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1, - SERIAL_XMIT_SIZE - info->xmit_head)); - memcpy(info->xmit_buf + info->xmit_head, tmp_buf, c); - up(&tmp_buf_sem); -@@ -1282,46 +1262,48 @@ static int rs_ioctl(struct tty_struct *t - } - - switch (cmd) { -- case TIOCMGET: -- error = verify_area(VERIFY_WRITE, (void *) arg, -- sizeof(unsigned int)); -- if (error) -- return error; -- return get_modem_info(info, (unsigned int *) arg); -- case TIOCMBIS: -- case TIOCMBIC: -- case TIOCMSET: -- return set_modem_info(info, cmd, (unsigned int *) arg); -- case TIOCGSERIAL: -- error = verify_area(VERIFY_WRITE, (void *) arg, -- sizeof(struct serial_struct)); -- if (error) -- return error; -- return get_serial_info(info, -- (struct serial_struct *) arg); -- case TIOCSSERIAL: -- return set_serial_info(info, -- (struct serial_struct *) arg); -- case TIOCSERGETLSR: /* Get line status register */ -- error = verify_area(VERIFY_WRITE, (void *) arg, -- sizeof(unsigned int)); -- if (error) -- return error; -- else -- return get_lsr_info(info, (unsigned int *) arg); -+ case TIOCMGET: -+ error = verify_area(VERIFY_WRITE, (void *)arg, -+ sizeof(unsigned int)); -+ if (error) -+ return error; -+ return get_modem_info(info, (unsigned int *)arg); - -- case TIOCSERGSTRUCT: -- error = verify_area(VERIFY_WRITE, (void *) arg, -- sizeof(struct dec_serial)); -- if (error) -- return error; -- copy_from_user((struct dec_serial *) arg, -- info, sizeof(struct dec_serial)); -- return 0; -+ case TIOCMBIS: -+ case TIOCMBIC: -+ case TIOCMSET: -+ return set_modem_info(info, cmd, (unsigned int *)arg); - -- default: -- return -ENOIOCTLCMD; -- } -+ case TIOCGSERIAL: -+ error = verify_area(VERIFY_WRITE, (void *)arg, -+ sizeof(struct serial_struct)); -+ if (error) -+ return error; -+ return get_serial_info(info, (struct serial_struct *)arg); -+ -+ case TIOCSSERIAL: -+ return set_serial_info(info, (struct serial_struct *)arg); -+ -+ case TIOCSERGETLSR: /* Get line status register */ -+ error = verify_area(VERIFY_WRITE, (void *)arg, -+ sizeof(unsigned int)); -+ if (error) -+ return error; -+ else -+ return get_lsr_info(info, (unsigned int *)arg); -+ -+ case TIOCSERGSTRUCT: -+ error = verify_area(VERIFY_WRITE, (void *)arg, -+ sizeof(struct dec_serial)); -+ if (error) -+ return error; -+ copy_from_user((struct dec_serial *)arg, info, -+ sizeof(struct dec_serial)); -+ return 0; -+ -+ default: -+ return -ENOIOCTLCMD; -+ } - return 0; - } - -@@ -1446,7 +1428,8 @@ static void rs_close(struct tty_struct * - static void rs_wait_until_sent(struct tty_struct *tty, int timeout) - { - struct dec_serial *info = (struct dec_serial *) tty->driver_data; -- unsigned long orig_jiffies, char_time; -+ unsigned long orig_jiffies; -+ int char_time; - - if (serial_paranoia_check(info, tty->device, "rs_wait_until_sent")) - return; -@@ -1462,7 +1445,7 @@ static void rs_wait_until_sent(struct tt - if (char_time == 0) - char_time = 1; - if (timeout) -- char_time = MIN(char_time, timeout); -+ char_time = min(char_time, timeout); - while ((read_zsreg(info->zs_channel, 1) & Tx_BUF_EMP) == 0) { - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(char_time); -@@ -1714,7 +1697,7 @@ int rs_open(struct tty_struct *tty, stru - - static void __init show_serial_version(void) - { -- printk("DECstation Z8530 serial driver version 0.08\n"); -+ printk("DECstation Z8530 serial driver version 0.09\n"); - } - - /* Initialize Z8530s zs_channels -@@ -1994,8 +1977,9 @@ int __init zs_init(void) - * polling I/O routines - */ - static int --zs_poll_tx_char(struct dec_serial *info, unsigned char ch) -+zs_poll_tx_char(void *handle, unsigned char ch) - { -+ struct dec_serial *info = handle; - struct dec_zschannel *chan = info->zs_channel; - int ret; - -@@ -2017,8 +2001,9 @@ zs_poll_tx_char(struct dec_serial *info, - } - - static int --zs_poll_rx_char(struct dec_serial *info) -+zs_poll_rx_char(void *handle) - { -+ struct dec_serial *info = handle; - struct dec_zschannel *chan = info->zs_channel; - int ret; - -@@ -2038,12 +2023,13 @@ zs_poll_rx_char(struct dec_serial *info) - return -ENODEV; - } - --unsigned int register_zs_hook(unsigned int channel, struct zs_hook *hook) -+int register_zs_hook(unsigned int channel, struct dec_serial_hook *hook) - { - struct dec_serial *info = &zs_soft[channel]; - - if (info->hook) { -- printk(__FUNCTION__": line %d has already a hook registered\n", channel); -+ printk("%s: line %d has already a hook registered\n", -+ __FUNCTION__, channel); - - return 0; - } else { -@@ -2055,7 +2041,7 @@ unsigned int register_zs_hook(unsigned i - } - } - --unsigned int unregister_zs_hook(unsigned int channel) -+int unregister_zs_hook(unsigned int channel) - { - struct dec_serial *info = &zs_soft[channel]; - -@@ -2063,8 +2049,8 @@ unsigned int unregister_zs_hook(unsigned - info->hook = NULL; - return 1; - } else { -- printk(__FUNCTION__": trying to unregister hook on line %d," -- " but none is registered\n", channel); -+ printk("%s: trying to unregister hook on line %d," -+ " but none is registered\n", __FUNCTION__, channel); - return 0; - } - } -@@ -2319,22 +2305,23 @@ void kgdb_interruptible(int yes) - write_zsreg(chan, 9, nine); - } - --static int kgdbhook_init_channel(struct dec_serial* info) -+static int kgdbhook_init_channel(void *handle) - { - return 0; - } - --static void kgdbhook_init_info(struct dec_serial* info) -+static void kgdbhook_init_info(void *handle) - { - } - --static void kgdbhook_rx_char(struct dec_serial* info, -- unsigned char ch, unsigned char stat) -+static void kgdbhook_rx_char(void *handle, unsigned char ch, unsigned char fl) - { -+ struct dec_serial *info = handle; -+ -+ if (fl != TTY_NORMAL) -+ return; - if (ch == 0x03 || ch == '$') - breakpoint(); -- if (stat & (Rx_OVR|FRM_ERR|PAR_ERR)) -- write_zsreg(info->zs_channel, 0, ERR_RES); - } - - /* This sets up the serial port we're using, and turns on -@@ -2360,11 +2347,11 @@ static inline void kgdb_chaninit(struct - * for /dev/ttyb which is determined in setup_arch() from the - * boot command line flags. - */ --struct zs_hook zs_kgdbhook = { -- init_channel : kgdbhook_init_channel, -- init_info : kgdbhook_init_info, -- cflags : B38400|CS8|CLOCAL, -- rx_char : kgdbhook_rx_char, -+struct dec_serial_hook zs_kgdbhook = { -+ .init_channel = kgdbhook_init_channel, -+ .init_info = kgdbhook_init_info, -+ .rx_char = kgdbhook_rx_char, -+ .cflags = B38400 | CS8 | CLOCAL, - } - - void __init zs_kgdb_hook(int tty_num) ---- a/drivers/tc/zs.h -+++ b/drivers/tc/zs.h -@@ -1,14 +1,18 @@ - /* -- * macserial.h: Definitions for the Macintosh Z8530 serial driver. -+ * drivers/tc/zs.h: Definitions for the DECstation Z85C30 serial driver. - * - * Adapted from drivers/sbus/char/sunserial.h by Paul Mackerras. -+ * Adapted from drivers/macintosh/macserial.h by Harald Koerfgen. - * - * Copyright (C) 1996 Paul Mackerras (Paul.Mackerras@cs.anu.edu.au) - * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) -+ * Copyright (C) 2004 Maciej W. Rozycki - */ - #ifndef _DECSERIAL_H - #define _DECSERIAL_H - -+#include <asm/dec/serial.h> -+ - #define NUM_ZSREGS 16 - - struct serial_struct { -@@ -89,63 +93,50 @@ struct dec_zschannel { - unsigned char curregs[NUM_ZSREGS]; - }; - --struct dec_serial; -- --struct zs_hook { -- int (*init_channel)(struct dec_serial* info); -- void (*init_info)(struct dec_serial* info); -- void (*rx_char)(unsigned char ch, unsigned char stat); -- int (*poll_rx_char)(struct dec_serial* info); -- int (*poll_tx_char)(struct dec_serial* info, -- unsigned char ch); -- unsigned cflags; --}; -- - struct dec_serial { -- struct dec_serial *zs_next; /* For IRQ servicing chain */ -- struct dec_zschannel *zs_channel; /* Channel registers */ -- struct dec_zschannel *zs_chan_a; /* A side registers */ -- unsigned char read_reg_zero; -- -- char soft_carrier; /* Use soft carrier on this channel */ -- char break_abort; /* Is serial console in, so process brk/abrt */ -- struct zs_hook *hook; /* Hook on this channel */ -- char is_cons; /* Is this our console. */ -- unsigned char tx_active; /* character is being xmitted */ -- unsigned char tx_stopped; /* output is suspended */ -- -- /* We need to know the current clock divisor -- * to read the bps rate the chip has currently -- * loaded. -+ struct dec_serial *zs_next; /* For IRQ servicing chain. */ -+ struct dec_zschannel *zs_channel; /* Channel registers. */ -+ struct dec_zschannel *zs_chan_a; /* A side registers. */ -+ unsigned char read_reg_zero; -+ -+ struct dec_serial_hook *hook; /* Hook on this channel. */ -+ int tty_break; /* Set on BREAK condition. */ -+ int is_cons; /* Is this our console. */ -+ int tx_active; /* Char is being xmitted. */ -+ int tx_stopped; /* Output is suspended. */ -+ -+ /* -+ * We need to know the current clock divisor -+ * to read the bps rate the chip has currently loaded. - */ -- unsigned char clk_divisor; /* May be 1, 16, 32, or 64 */ -- int zs_baud; -+ int clk_divisor; /* May be 1, 16, 32, or 64. */ -+ int zs_baud; - -- char change_needed; -+ char change_needed; - - int magic; - int baud_base; - int port; - int irq; -- int flags; /* defined in tty.h */ -- int type; /* UART type */ -+ int flags; /* Defined in tty.h. */ -+ int type; /* UART type. */ - struct tty_struct *tty; - int read_status_mask; - int ignore_status_mask; - int timeout; - int xmit_fifo_size; - int custom_divisor; -- int x_char; /* xon/xoff character */ -+ int x_char; /* XON/XOFF character. */ - int close_delay; - unsigned short closing_wait; - unsigned short closing_wait2; - unsigned long event; - unsigned long last_active; - int line; -- int count; /* # of fd on device */ -- int blocked_open; /* # of blocked opens */ -- long session; /* Session of opening process */ -- long pgrp; /* pgrp of opening process */ -+ int count; /* # of fds on device. */ -+ int blocked_open; /* # of blocked opens. */ -+ long session; /* Sess of opening process. */ -+ long pgrp; /* Pgrp of opening process. */ - unsigned char *xmit_buf; - int xmit_head; - int xmit_tail; ---- /dev/null -+++ b/drivers/video/au1200fb.c -@@ -0,0 +1,1564 @@ -+/* -+ * BRIEF MODULE DESCRIPTION -+ * Au1200 LCD Driver. -+ * -+ * Copyright 2004 AMD -+ * Author: AMD -+ * -+ * Based on: -+ * linux/drivers/video/skeletonfb.c -- Skeleton for a frame buffer device -+ * Created 28 Dec 1997 by Geert Uytterhoeven -+ * -+ * 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 SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN -+ * NO EVENT SHALL THE AUTHOR 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. -+ * -+ * You should have received a copy of the GNU General Public License along -+ * with this program; if not, write to the Free Software Foundation, Inc., -+ * 675 Mass Ave, Cambridge, MA 02139, USA. -+ */ -+ -+#include <linux/module.h> -+#include <linux/kernel.h> -+#include <linux/errno.h> -+#include <linux/string.h> -+#include <linux/mm.h> -+#include <linux/tty.h> -+#include <linux/slab.h> -+#include <linux/delay.h> -+#include <linux/fb.h> -+#include <linux/init.h> -+#include <asm/uaccess.h> -+ -+#include <asm/au1000.h> -+#include <asm/au1xxx_gpio.h> -+#include "au1200fb.h" -+ -+#include <video/fbcon.h> -+#include <video/fbcon-cfb16.h> -+#include <video/fbcon-cfb32.h> -+#define CMAPSIZE 16 -+ -+#define AU1200_LCD_GET_WINENABLE 1 -+#define AU1200_LCD_SET_WINENABLE 2 -+#define AU1200_LCD_GET_WINLOCATION 3 -+#define AU1200_LCD_SET_WINLOCATION 4 -+#define AU1200_LCD_GET_WINSIZE 5 -+#define AU1200_LCD_SET_WINSIZE 6 -+#define AU1200_LCD_GET_BACKCOLOR 7 -+#define AU1200_LCD_SET_BACKCOLOR 8 -+#define AU1200_LCD_GET_COLORKEY 9 -+#define AU1200_LCD_SET_COLORKEY 10 -+#define AU1200_LCD_GET_PANEL 11 -+#define AU1200_LCD_SET_PANEL 12 -+ -+typedef struct au1200_lcd_getset_t -+{ -+ unsigned int subcmd; -+ union { -+ struct { -+ int enable; -+ } winenable; -+ struct { -+ int x, y; -+ } winlocation; -+ struct { -+ int hsz, vsz; -+ } winsize; -+ struct { -+ unsigned int color; -+ } backcolor; -+ struct { -+ unsigned int key; -+ unsigned int mask; -+ } colorkey; -+ struct { -+ int panel; -+ char desc[80]; -+ } panel; -+ }; -+} au1200_lcd_getset_t; -+ -+AU1200_LCD *lcd = (AU1200_LCD *)AU1200_LCD_ADDR; -+static int window_index = 0; /* default is zero */ -+static int panel_index = -1; /* default is call board_au1200fb_panel */ -+ -+struct window_settings -+{ -+ unsigned char name[64]; -+ uint32 mode_backcolor; -+ uint32 mode_colorkey; -+ uint32 mode_colorkeymsk; -+ struct -+ { -+ int xres; -+ int yres; -+ int xpos; -+ int ypos; -+ uint32 mode_winctrl1; /* winctrl1[FRM,CCO,PO,PIPE] */ -+ uint32 mode_winenable; -+ } w[4]; -+}; -+ -+struct panel_settings -+{ -+ unsigned char name[64]; -+ /* panel physical dimensions */ -+ uint32 Xres; -+ uint32 Yres; -+ /* panel timings */ -+ uint32 mode_screen; -+ uint32 mode_horztiming; -+ uint32 mode_verttiming; -+ uint32 mode_clkcontrol; -+ uint32 mode_pwmdiv; -+ uint32 mode_pwmhi; -+ uint32 mode_outmask; -+ uint32 mode_fifoctrl; -+ uint32 mode_toyclksrc; -+ uint32 mode_backlight; -+ uint32 mode_auxpll; -+ int (*device_init)(void); -+ int (*device_shutdown)(void); -+}; -+ -+#if defined(__BIG_ENDIAN) -+#define LCD_WINCTRL1_PO_16BPP LCD_WINCTRL1_PO_00 -+#else -+#define LCD_WINCTRL1_PO_16BPP LCD_WINCTRL1_PO_01 -+#endif -+ -+extern int board_au1200fb_panel (void); -+extern int board_au1200fb_panel_init (void); -+extern int board_au1200fb_panel_shutdown (void); -+ -+#if defined(CONFIG_FOCUS_ENHANCEMENTS) -+extern int board_au1200fb_focus_init_hdtv(void); -+extern int board_au1200fb_focus_init_component(void); -+extern int board_au1200fb_focus_init_cvsv(void); -+extern int board_au1200fb_focus_shutdown(void); -+#endif -+ -+/* -+ * Default window configurations -+ */ -+static struct window_settings windows[] = -+{ -+ { /* Index 0 */ -+ "0-FS gfx, 1-video, 2-ovly gfx, 3-ovly gfx", -+ /* mode_backcolor */ 0x006600ff, -+ /* mode_colorkey,msk*/ 0, 0, -+ { -+ { -+ /* xres, yres, xpos, ypos */ 0, 0, 0, 0, -+ /* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565|LCD_WINCTRL1_PO_16BPP, -+ /* mode_winenable*/ LCD_WINENABLE_WEN0, -+ }, -+ { -+ /* xres, yres, xpos, ypos */ 0, 0, 0, 0, -+ /* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565|LCD_WINCTRL1_PO_16BPP, -+ /* mode_winenable*/ 0, -+ }, -+ { -+ /* xres, yres, xpos, ypos */ 0, 0, 0, 0, -+ /* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565|LCD_WINCTRL1_PO_16BPP|LCD_WINCTRL1_PIPE, -+ /* mode_winenable*/ 0, -+ }, -+ { -+ /* xres, yres, xpos, ypos */ 0, 0, 0, 0, -+ /* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565|LCD_WINCTRL1_PO_16BPP|LCD_WINCTRL1_PIPE, -+ /* mode_winenable*/ 0, -+ }, -+ }, -+ }, -+ -+ { /* Index 1 */ -+ "0-FS gfx, 1-video, 2-ovly gfx, 3-ovly gfx", -+ /* mode_backcolor */ 0x006600ff, -+ /* mode_colorkey,msk*/ 0, 0, -+ { -+ { -+ /* xres, yres, xpos, ypos */ 320, 240, 5, 5, -+#if 0 -+ /* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565|LCD_WINCTRL1_PO_16BPP, -+#endif -+ /* mode_winctrl1 */ LCD_WINCTRL1_FRM_24BPP|LCD_WINCTRL1_PO_00, -+ /* mode_winenable*/ LCD_WINENABLE_WEN0, -+ }, -+ { -+ /* xres, yres, xpos, ypos */ 0, 0, 0, 0, -+ /* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565|LCD_WINCTRL1_PO_16BPP, -+ /* mode_winenable*/ 0, -+ }, -+ { -+ /* xres, yres, xpos, ypos */ 100, 100, 0, 0, -+ /* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565|LCD_WINCTRL1_PO_16BPP|LCD_WINCTRL1_PIPE, -+ /* mode_winenable*/ 0/*LCD_WINENABLE_WEN2*/, -+ }, -+ { -+ /* xres, yres, xpos, ypos */ 200, 25, 0, 0, -+ /* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565|LCD_WINCTRL1_PO_16BPP|LCD_WINCTRL1_PIPE, -+ /* mode_winenable*/ 0, -+ }, -+ }, -+ }, -+ /* Need VGA 640 @ 24bpp, @ 32bpp */ -+ /* Need VGA 800 @ 24bpp, @ 32bpp */ -+ /* Need VGA 1024 @ 24bpp, @ 32bpp */ -+} ; -+ -+/* -+ * Controller configurations for various panels. -+ */ -+static struct panel_settings panels[] = -+{ -+ { /* Index 0: QVGA 320x240 H:33.3kHz V:110Hz */ -+ "VGA_320x240", -+ 320, 240, -+ /* mode_screen */ LCD_SCREEN_SX_N(320) | LCD_SCREEN_SY_N(240), -+ /* mode_horztiming */ 0x00c4623b, -+ /* mode_verttiming */ 0x00502814, -+ /* mode_clkcontrol */ 0x00020002, /* /4=24Mhz */ -+ /* mode_pwmdiv */ 0x00000000, -+ /* mode_pwmhi */ 0x00000000, -+ /* mode_outmask */ 0x00FFFFFF, -+ /* mode_fifoctrl */ 0x2f2f2f2f, -+ /* mode_toyclksrc */ 0x00000004, /* 96MHz AUXPLL directly */ -+ /* mode_backlight */ 0x00000000, -+ /* mode_auxpll */ 8, /* 96MHz AUXPLL */ -+ /* device_init */ NULL, -+ /* device_shutdown */ NULL, -+ }, -+ -+ { /* Index 1: VGA 640x480 H:30.3kHz V:58Hz */ -+ "VGA_640x480", -+ 640, 480, -+ /* mode_screen */ 0x13f9df80, -+ /* mode_horztiming */ 0x003c5859, -+ /* mode_verttiming */ 0x00741201, -+ /* mode_clkcontrol */ 0x00020001, /* /4=24Mhz */ -+ /* mode_pwmdiv */ 0x00000000, -+ /* mode_pwmhi */ 0x00000000, -+ /* mode_outmask */ 0x00FFFFFF, -+ /* mode_fifoctrl */ 0x2f2f2f2f, -+ /* mode_toyclksrc */ 0x00000004, /* AUXPLL directly */ -+ /* mode_backlight */ 0x00000000, -+ /* mode_auxpll */ 8, /* 96MHz AUXPLL */ -+ /* device_init */ NULL, -+ /* device_shutdown */ NULL, -+ }, -+ -+ { /* Index 2: SVGA 800x600 H:46.1kHz V:69Hz */ -+ "SVGA_800x600", -+ 800, 600, -+ /* mode_screen */ 0x18fa5780, -+ /* mode_horztiming */ 0x00dc7e77, -+ /* mode_verttiming */ 0x00584805, -+ /* mode_clkcontrol */ 0x00020000, /* /2=48Mhz */ -+ /* mode_pwmdiv */ 0x00000000, -+ /* mode_pwmhi */ 0x00000000, -+ /* mode_outmask */ 0x00FFFFFF, -+ /* mode_fifoctrl */ 0x2f2f2f2f, -+ /* mode_toyclksrc */ 0x00000004, /* AUXPLL directly */ -+ /* mode_backlight */ 0x00000000, -+ /* mode_auxpll */ 8, /* 96MHz AUXPLL */ -+ /* device_init */ NULL, -+ /* device_shutdown */ NULL, -+ }, -+ -+ { /* Index 3: XVGA 1024x768 H:56.2kHz V:70Hz */ -+ "XVGA_1024x768", -+ 1024, 768, -+ /* mode_screen */ 0x1ffaff80, -+ /* mode_horztiming */ 0x007d0e57, -+ /* mode_verttiming */ 0x00740a01, -+ /* mode_clkcontrol */ 0x000A0000, /* /1 */ -+ /* mode_pwmdiv */ 0x00000000, -+ /* mode_pwmhi */ 0x00000000, -+ /* mode_outmask */ 0x00FFFFFF, -+ /* mode_fifoctrl */ 0x2f2f2f2f, -+ /* mode_toyclksrc */ 0x00000004, /* AUXPLL directly */ -+ /* mode_backlight */ 0x00000000, -+ /* mode_auxpll */ 6, /* 72MHz AUXPLL */ -+ /* device_init */ NULL, -+ /* device_shutdown */ NULL, -+ }, -+ -+ { /* Index 4: XVGA 1280x1024 H:68.5kHz V:65Hz */ -+ "XVGA_1280x1024", -+ 1280, 1024, -+ /* mode_screen */ 0x27fbff80, -+ /* mode_horztiming */ 0x00cdb2c7, -+ /* mode_verttiming */ 0x00600002, -+ /* mode_clkcontrol */ 0x000A0000, /* /1 */ -+ /* mode_pwmdiv */ 0x00000000, -+ /* mode_pwmhi */ 0x00000000, -+ /* mode_outmask */ 0x00FFFFFF, -+ /* mode_fifoctrl */ 0x2f2f2f2f, -+ /* mode_toyclksrc */ 0x00000004, /* AUXPLL directly */ -+ /* mode_backlight */ 0x00000000, -+ /* mode_auxpll */ 10, /* 120MHz AUXPLL */ -+ /* device_init */ NULL, -+ /* device_shutdown */ NULL, -+ }, -+ -+ { /* Index 5: Samsung 1024x768 TFT */ -+ "Samsung_1024x768_TFT", -+ 1024, 768, -+ /* mode_screen */ 0x1ffaff80, -+ /* mode_horztiming */ 0x018cc677, -+ /* mode_verttiming */ 0x00241217, -+ /* mode_clkcontrol */ 0x00000000, /* SCB 0x1 /4=24Mhz */ -+ /* mode_pwmdiv */ 0x8000063f, /* SCB 0x0 */ -+ /* mode_pwmhi */ 0x03400000, /* SCB 0x0 */ -+ /* mode_outmask */ 0x00fcfcfc, -+ /* mode_fifoctrl */ 0x2f2f2f2f, -+ /* mode_toyclksrc */ 0x00000004, /* 96MHz AUXPLL directly */ -+ /* mode_backlight */ 0x00000000, -+ /* mode_auxpll */ 8, /* 96MHz AUXPLL */ -+ /* device_init */ board_au1200fb_panel_init, -+ /* device_shutdown */ board_au1200fb_panel_shutdown, -+ }, -+ -+ { /* Index 6: Toshiba 640x480 TFT */ -+ "Toshiba_640x480_TFT", -+ 640, 480, -+ /* mode_screen */ LCD_SCREEN_SX_N(640) | LCD_SCREEN_SY_N(480), -+ /* mode_horztiming */ LCD_HORZTIMING_HPW_N(96) | LCD_HORZTIMING_HND1_N(13) | LCD_HORZTIMING_HND2_N(51), -+ /* mode_verttiming */ LCD_VERTTIMING_VPW_N(2) | LCD_VERTTIMING_VND1_N(11) | LCD_VERTTIMING_VND2_N(32) , -+ /* mode_clkcontrol */ 0x00000000, /* /4=24Mhz */ -+ /* mode_pwmdiv */ 0x8000063f, -+ /* mode_pwmhi */ 0x03400000, -+ /* mode_outmask */ 0x00fcfcfc, -+ /* mode_fifoctrl */ 0x2f2f2f2f, -+ /* mode_toyclksrc */ 0x00000004, /* 96MHz AUXPLL directly */ -+ /* mode_backlight */ 0x00000000, -+ /* mode_auxpll */ 8, /* 96MHz AUXPLL */ -+ /* device_init */ board_au1200fb_panel_init, -+ /* device_shutdown */ board_au1200fb_panel_shutdown, -+ }, -+ -+ { /* Index 7: Sharp 320x240 TFT */ -+ "Sharp_320x240_TFT", -+ 320, 240, -+ /* mode_screen */ LCD_SCREEN_SX_N(320) | LCD_SCREEN_SY_N(240), -+ /* mode_horztiming */ LCD_HORZTIMING_HPW_N(60) | LCD_HORZTIMING_HND1_N(13) | LCD_HORZTIMING_HND2_N(2), -+ /* mode_verttiming */ LCD_VERTTIMING_VPW_N(2) | LCD_VERTTIMING_VND1_N(2) | LCD_VERTTIMING_VND2_N(5) , -+ /* mode_clkcontrol */ LCD_CLKCONTROL_PCD_N(7), /* /16=6Mhz */ -+ /* mode_pwmdiv */ 0x8000063f, -+ /* mode_pwmhi */ 0x03400000, -+ /* mode_outmask */ 0x00fcfcfc, -+ /* mode_fifoctrl */ 0x2f2f2f2f, -+ /* mode_toyclksrc */ 0x00000004, /* 96MHz AUXPLL directly */ -+ /* mode_backlight */ 0x00000000, -+ /* mode_auxpll */ 8, /* 96MHz AUXPLL */ -+ /* device_init */ board_au1200fb_panel_init, -+ /* device_shutdown */ board_au1200fb_panel_shutdown, -+ }, -+ { /* Index 8: Toppoly TD070WGCB2 7" 854x480 TFT */ -+ "Toppoly_TD070WGCB2", -+ 854, 480, -+ /* mode_screen */ LCD_SCREEN_SX_N(854) | LCD_SCREEN_SY_N(480), -+ /* mode_horztiming */ LCD_HORZTIMING_HND2_N(44) | LCD_HORZTIMING_HND1_N(44) | LCD_HORZTIMING_HPW_N(114), -+ /* mode_verttiming */ LCD_VERTTIMING_VND2_N(20) | LCD_VERTTIMING_VND1_N(21) | LCD_VERTTIMING_VPW_N(4), -+ /* mode_clkcontrol */ 0x00020001, /* /4=24Mhz */ -+ /* mode_pwmdiv */ 0x8000063f, -+ /* mode_pwmhi */ 0x03400000, -+ /* mode_outmask */ 0x00FCFCFC, -+ /* mode_fifoctrl */ 0x2f2f2f2f, -+ /* mode_toyclksrc */ 0x00000004, /* AUXPLL directly */ -+ /* mode_backlight */ 0x00000000, -+ /* mode_auxpll */ 8, /* 96MHz AUXPLL */ -+ /* device_init */ board_au1200fb_panel_init, -+ /* device_shutdown */ board_au1200fb_panel_shutdown, -+ }, -+#if defined(CONFIG_FOCUS_ENHANCEMENTS) -+ { /* Index 9: Focus FS453 TV-Out 640x480 */ -+ "FS453_640x480 (Composite/S-Video)", -+ 640, 480, -+ /* mode_screen */ LCD_SCREEN_SX_N(640) | LCD_SCREEN_SY_N(480), -+ /* mode_horztiming */ LCD_HORZTIMING_HND2_N(143) | LCD_HORZTIMING_HND1_N(143) | LCD_HORZTIMING_HPW_N(10), -+ /* mode_verttiming */ LCD_VERTTIMING_VND2_N(30) | LCD_VERTTIMING_VND1_N(30) | LCD_VERTTIMING_VPW_N(5), -+ /* mode_clkcontrol */ 0x00480000 | (1<<17) | (1<<18), /* External Clock, 1:1 clock ratio */ -+ /* mode_pwmdiv */ 0x00000000, -+ /* mode_pwmhi */ 0x00000000, -+ /* mode_outmask */ 0x00FFFFFF, -+ /* mode_fifoctrl */ 0x2f2f2f2f, -+ /* mode_toyclksrc */ 0x00000000, -+ /* mode_backlight */ 0x00000000, -+ /* mode_auxpll */ 8, /* 96MHz AUXPLL */ -+ /* device_init */ board_au1200fb_focus_init_cvsv, -+ /* device_shutdown */ board_au1200fb_focus_shutdown, -+ }, -+ -+ { /* Index 10: Focus FS453 TV-Out 640x480 */ -+ "FS453_640x480 (Component Video)", -+ 640, 480, -+ /* mode_screen */ LCD_SCREEN_SX_N(640) | LCD_SCREEN_SY_N(480), -+ /* mode_horztiming */ LCD_HORZTIMING_HND2_N(143) | LCD_HORZTIMING_HND1_N(143) | LCD_HORZTIMING_HPW_N(10), -+ /* mode_verttiming */ LCD_VERTTIMING_VND2_N(30) | LCD_VERTTIMING_VND1_N(30) | LCD_VERTTIMING_VPW_N(5), -+ /* mode_clkcontrol */ 0x00480000 | (1<<17) | (1<<18), /* External Clock, 1:1 clock ratio */ -+ /* mode_pwmdiv */ 0x00000000, -+ /* mode_pwmhi */ 0x00000000, -+ /* mode_outmask */ 0x00FFFFFF, -+ /* mode_fifoctrl */ 0x2f2f2f2f, -+ /* mode_toyclksrc */ 0x00000000, -+ /* mode_backlight */ 0x00000000, -+ /* mode_auxpll */ 8, /* 96MHz AUXPLL */ -+ /* device_init */ board_au1200fb_focus_init_component, -+ /* device_shutdown */ board_au1200fb_focus_shutdown, -+ }, -+ -+ { /* Index 11: Focus FS453 TV-Out 640x480 */ -+ "FS453_640x480 (HDTV)", -+ 720, 480, -+ /* mode_screen */ LCD_SCREEN_SX_N(720) | LCD_SCREEN_SY_N(480), -+ /* mode_horztiming */ LCD_HORZTIMING_HND2_N(28) | LCD_HORZTIMING_HND1_N(46) | LCD_HORZTIMING_HPW_N(64), -+ /* mode_verttiming */ LCD_VERTTIMING_VND2_N(7) | LCD_VERTTIMING_VND1_N(31) | LCD_VERTTIMING_VPW_N(7), -+ /* mode_clkcontrol */ 0x00480000 | (1<<17) | (1<<18), /* External Clock, 1:1 clock ratio */ -+ /* mode_pwmdiv */ 0x00000000, -+ /* mode_pwmhi */ 0x00000000, -+ /* mode_outmask */ 0x00FFFFFF, -+ /* mode_fifoctrl */ 0x2f2f2f2f, -+ /* mode_toyclksrc */ 0x00000000, -+ /* mode_backlight */ 0x00000000, -+ /* mode_auxpll */ 8, /* 96MHz AUXPLL */ -+ /* device_init */ board_au1200fb_focus_init_hdtv, -+ /* device_shutdown */ board_au1200fb_focus_shutdown, -+ }, -+#endif -+}; -+ -+#define NUM_PANELS (sizeof(panels) / sizeof(struct panel_settings)) -+ -+static struct window_settings *win; -+static struct panel_settings *panel; -+ -+struct au1200fb_info { -+ struct fb_info_gen gen; -+ unsigned long fb_virt_start; -+ unsigned long fb_size; -+ unsigned long fb_phys; -+ int mmaped; -+ int nohwcursor; -+ int noblanking; -+ -+ struct { unsigned red, green, blue, pad; } palette[256]; -+ -+#if defined(FBCON_HAS_CFB16) -+ u16 fbcon_cmap16[16]; -+#endif -+#if defined(FBCON_HAS_CFB32) -+ u32 fbcon_cmap32[16]; -+#endif -+}; -+ -+ -+struct au1200fb_par { -+ struct fb_var_screeninfo var; -+ -+ int line_length; /* in bytes */ -+ int cmap_len; /* color-map length */ -+}; -+ -+#ifndef CONFIG_FB_AU1200_DEVS -+#define CONFIG_FB_AU1200_DEVS 1 -+#endif -+ -+static struct au1200fb_info fb_infos[CONFIG_FB_AU1200_DEVS]; -+static struct au1200fb_par fb_pars[CONFIG_FB_AU1200_DEVS]; -+static struct display disps[CONFIG_FB_AU1200_DEVS]; -+ -+int au1200fb_init(void); -+void au1200fb_setup(char *options, int *ints); -+static int au1200fb_mmap(struct fb_info *fb, struct file *file, -+ struct vm_area_struct *vma); -+static int au1200_blank(int blank_mode, struct fb_info_gen *info); -+static int au1200fb_ioctl(struct inode *inode, struct file *file, u_int cmd, -+ u_long arg, int con, struct fb_info *info); -+ -+void au1200_nocursor(struct display *p, int mode, int xx, int yy){}; -+ -+static int au1200_setlocation (int plane, int xpos, int ypos); -+static int au1200_setsize (int plane, int xres, int yres); -+static void au1200_setmode(int plane); -+static void au1200_setpanel (struct panel_settings *newpanel); -+ -+static struct fb_ops au1200fb_ops = { -+ owner: THIS_MODULE, -+ fb_get_fix: fbgen_get_fix, -+ fb_get_var: fbgen_get_var, -+ fb_set_var: fbgen_set_var, -+ fb_get_cmap: fbgen_get_cmap, -+ fb_set_cmap: fbgen_set_cmap, -+ fb_pan_display: fbgen_pan_display, -+ fb_ioctl: au1200fb_ioctl, -+ fb_mmap: au1200fb_mmap, -+}; -+ -+ -+static int -+winbpp (unsigned int winctrl1) -+{ -+ /* how many bytes of memory are needed for each pixel format */ -+ switch (winctrl1 & LCD_WINCTRL1_FRM) -+ { -+ case LCD_WINCTRL1_FRM_1BPP: return 1; break; -+ case LCD_WINCTRL1_FRM_2BPP: return 2; break; -+ case LCD_WINCTRL1_FRM_4BPP: return 4; break; -+ case LCD_WINCTRL1_FRM_8BPP: return 8; break; -+ case LCD_WINCTRL1_FRM_12BPP: return 16; break; -+ case LCD_WINCTRL1_FRM_16BPP655: return 16; break; -+ case LCD_WINCTRL1_FRM_16BPP565: return 16; break; -+ case LCD_WINCTRL1_FRM_16BPP556: return 16; break; -+ case LCD_WINCTRL1_FRM_16BPPI1555: return 16; break; -+ case LCD_WINCTRL1_FRM_16BPPI5551: return 16; break; -+ case LCD_WINCTRL1_FRM_16BPPA1555: return 16; break; -+ case LCD_WINCTRL1_FRM_16BPPA5551: return 16; break; -+ case LCD_WINCTRL1_FRM_24BPP: return 32; break; -+ case LCD_WINCTRL1_FRM_32BPP: return 32; break; -+ default: return 0; break; -+ } -+} -+ -+static int -+fbinfo2index (struct fb_info *fb_info) -+{ -+ int i; -+ for (i = 0; i < CONFIG_FB_AU1200_DEVS; ++i) -+ { -+ if (fb_info == (struct fb_info *)(&fb_infos[i])) -+ return i; -+ } -+ printk("au1200fb: ERROR: fbinfo2index failed!\n"); -+ return -1; -+} -+ -+static void au1200_detect(void) -+{ -+ /* -+ * This function should detect the current video mode settings -+ * and store it as the default video mode -+ * Yeh, well, we're not going to change any settings so we're -+ * always stuck with the default ... -+ */ -+} -+ -+static int au1200_encode_fix(struct fb_fix_screeninfo *fix, -+ const void *_par, struct fb_info_gen *_info) -+{ -+ struct au1200fb_info *info = (struct au1200fb_info *) _info; -+ struct au1200fb_par *par = (struct au1200fb_par *) _par; -+ int plane; -+ -+ plane = fbinfo2index(info); -+ -+ memset(fix, 0, sizeof(struct fb_fix_screeninfo)); -+ -+ fix->smem_start = info->fb_phys; -+ fix->smem_len = info->fb_size; -+ fix->type = FB_TYPE_PACKED_PIXELS; -+ fix->type_aux = 0; -+ fix->visual = (par->var.bits_per_pixel == 8) ? -+ FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; -+ fix->ywrapstep = 0; -+ fix->xpanstep = 1; -+ fix->ypanstep = 1; -+ /* FIX!!!! why doesn't par->line_length work???? it does for au1100 */ -+ fix->line_length = fb_pars[plane].line_length; /*par->line_length;*/ -+ return 0; -+} -+ -+static void set_color_bitfields(struct fb_var_screeninfo *var, int plane) -+{ -+ if (var->bits_per_pixel == 8) -+ { -+ var->red.offset = 0; -+ var->red.length = 8; -+ var->green.offset = 0; -+ var->green.length = 8; -+ var->blue.offset = 0; -+ var->blue.length = 8; -+ var->transp.offset = 0; -+ var->transp.length = 0; -+ } -+ else -+ -+ if (var->bits_per_pixel == 16) -+ { -+ /* FIX!!! How does CCO affect this ? */ -+ /* FIX!!! Not exactly sure how many of these work with FB */ -+ switch (win->w[plane].mode_winctrl1 & LCD_WINCTRL1_FRM) -+ { -+ case LCD_WINCTRL1_FRM_16BPP655: -+ var->red.offset = 10; -+ var->red.length = 6; -+ var->green.offset = 5; -+ var->green.length = 5; -+ var->blue.offset = 0; -+ var->blue.length = 5; -+ var->transp.offset = 0; -+ var->transp.length = 0; -+ break; -+ -+ case LCD_WINCTRL1_FRM_16BPP565: -+ var->red.offset = 11; -+ var->red.length = 5; -+ var->green.offset = 5; -+ var->green.length = 6; -+ var->blue.offset = 0; -+ var->blue.length = 5; -+ var->transp.offset = 0; -+ var->transp.length = 0; -+ break; -+ -+ case LCD_WINCTRL1_FRM_16BPP556: -+ var->red.offset = 11; -+ var->red.length = 5; -+ var->green.offset = 6; -+ var->green.length = 5; -+ var->blue.offset = 0; -+ var->blue.length = 6; -+ var->transp.offset = 0; -+ var->transp.length = 0; -+ break; -+ -+ case LCD_WINCTRL1_FRM_16BPPI1555: -+ var->red.offset = 10; -+ var->red.length = 5; -+ var->green.offset = 5; -+ var->green.length = 5; -+ var->blue.offset = 0; -+ var->blue.length = 5; -+ var->transp.offset = 0; -+ var->transp.length = 0; -+ break; -+ -+ case LCD_WINCTRL1_FRM_16BPPI5551: -+ var->red.offset = 11; -+ var->red.length = 5; -+ var->green.offset = 6; -+ var->green.length = 5; -+ var->blue.offset = 1; -+ var->blue.length = 5; -+ var->transp.offset = 0; -+ var->transp.length = 0; -+ break; -+ -+ case LCD_WINCTRL1_FRM_16BPPA1555: -+ var->red.offset = 10; -+ var->red.length = 5; -+ var->green.offset = 5; -+ var->green.length = 5; -+ var->blue.offset = 0; -+ var->blue.length = 5; -+ var->transp.offset = 15; -+ var->transp.length = 1; -+ break; -+ -+ case LCD_WINCTRL1_FRM_16BPPA5551: -+ var->red.offset = 11; -+ var->red.length = 5; -+ var->green.offset = 6; -+ var->green.length = 5; -+ var->blue.offset = 1; -+ var->blue.length = 5; -+ var->transp.offset = 0; -+ var->transp.length = 1; -+ break; -+ -+ default: -+ printk("ERROR: Invalid PIXEL FORMAT!!!\n"); break; -+ } -+ } -+ else -+ -+ if (var->bits_per_pixel == 32) -+ { -+ switch (win->w[plane].mode_winctrl1 & LCD_WINCTRL1_FRM) -+ { -+ case LCD_WINCTRL1_FRM_24BPP: -+ var->red.offset = 16; -+ var->red.length = 8; -+ var->green.offset = 8; -+ var->green.length = 8; -+ var->blue.offset = 0; -+ var->blue.length = 8; -+ var->transp.offset = 0; -+ var->transp.length = 0; -+ break; -+ -+ case LCD_WINCTRL1_FRM_32BPP: -+ var->red.offset = 16; -+ var->red.length = 8; -+ var->green.offset = 8; -+ var->green.length = 8; -+ var->blue.offset = 0; -+ var->blue.length = 8; -+ var->transp.offset = 24; -+ var->transp.length = 8; -+ break; -+ } -+ } -+ var->red.msb_right = 0; -+ var->green.msb_right = 0; -+ var->blue.msb_right = 0; -+ var->transp.msb_right = 0; -+#if 0 -+printk("set_color_bitfields(a=%d, r=%d..%d, g=%d..%d, b=%d..%d)\n", -+ var->transp.offset, -+ var->red.offset+var->red.length-1, var->red.offset, -+ var->green.offset+var->green.length-1, var->green.offset, -+ var->blue.offset+var->blue.length-1, var->blue.offset); -+#endif -+} -+ -+static int au1200_decode_var(const struct fb_var_screeninfo *var, -+ void *_par, struct fb_info_gen *_info) -+{ -+ struct au1200fb_par *par = (struct au1200fb_par *)_par; -+ int plane, bpp; -+ -+ plane = fbinfo2index((struct fb_info *)_info); -+ -+ /* -+ * Don't allow setting any of these yet: xres and yres don't -+ * make sense for LCD panels. -+ */ -+ if (var->xres != win->w[plane].xres || -+ var->yres != win->w[plane].yres || -+ var->xres != win->w[plane].xres || -+ var->yres != win->w[plane].yres) { -+ return -EINVAL; -+ } -+ -+ bpp = winbpp(win->w[plane].mode_winctrl1); -+ if(var->bits_per_pixel != bpp) { -+ /* on au1200, window pixel format is independent of panel pixel */ -+ printk("WARNING: bits_per_pizel != panel->bpp\n"); -+ } -+ -+ memset(par, 0, sizeof(struct au1200fb_par)); -+ par->var = *var; -+ -+ /* FIX!!! */ -+ switch (var->bits_per_pixel) { -+ case 8: -+ par->var.bits_per_pixel = 8; -+ break; -+ case 16: -+ par->var.bits_per_pixel = 16; -+ break; -+ case 24: -+ case 32: -+ par->var.bits_per_pixel = 32; -+ break; -+ default: -+ printk("color depth %d bpp not supported\n", -+ var->bits_per_pixel); -+ return -EINVAL; -+ -+ } -+ set_color_bitfields(&par->var, plane); -+ /* FIX!!! what is this for 24/32bpp? */ -+ par->cmap_len = (par->var.bits_per_pixel == 8) ? 256 : 16; -+ return 0; -+} -+ -+static int au1200_encode_var(struct fb_var_screeninfo *var, -+ const void *par, struct fb_info_gen *_info) -+{ -+ *var = ((struct au1200fb_par *)par)->var; -+ return 0; -+} -+ -+static void -+au1200_get_par(void *_par, struct fb_info_gen *_info) -+{ -+ int index; -+ -+ index = fbinfo2index((struct fb_info *)_info); -+ *(struct au1200fb_par *)_par = fb_pars[index]; -+} -+ -+static void au1200_set_par(const void *par, struct fb_info_gen *info) -+{ -+ /* nothing to do: we don't change any settings */ -+} -+ -+static int au1200_getcolreg(unsigned regno, unsigned *red, unsigned *green, -+ unsigned *blue, unsigned *transp, -+ struct fb_info *info) -+{ -+ struct au1200fb_info* i = (struct au1200fb_info*)info; -+ -+ if (regno > 255) -+ return 1; -+ -+ *red = i->palette[regno].red; -+ *green = i->palette[regno].green; -+ *blue = i->palette[regno].blue; -+ *transp = 0; -+ -+ return 0; -+} -+ -+static int au1200_setcolreg(unsigned regno, unsigned red, unsigned green, -+ unsigned blue, unsigned transp, -+ struct fb_info *info) -+{ -+ struct au1200fb_info* i = (struct au1200fb_info *)info; -+ u32 rgbcol; -+ int plane, bpp; -+ -+ plane = fbinfo2index((struct fb_info *)info); -+ bpp = winbpp(win->w[plane].mode_winctrl1); -+ -+ if (regno > 255) -+ return 1; -+ -+ i->palette[regno].red = red; -+ i->palette[regno].green = green; -+ i->palette[regno].blue = blue; -+ -+ switch(bpp) { -+#ifdef FBCON_HAS_CFB8 -+ case 8: -+ red >>= 10; -+ green >>= 10; -+ blue >>= 10; -+ panel_reg->lcd_pallettebase[regno] = (blue&0x1f) | -+ ((green&0x3f)<<5) | ((red&0x1f)<<11); -+ break; -+#endif -+#ifdef FBCON_HAS_CFB16 -+/* FIX!!!! depends upon pixel format */ -+ case 16: -+ i->fbcon_cmap16[regno] = -+ ((red & 0xf800) >> 0) | -+ ((green & 0xfc00) >> 5) | -+ ((blue & 0xf800) >> 11); -+ break; -+#endif -+#ifdef FBCON_HAS_CFB32 -+ case 32: -+ i->fbcon_cmap32[regno] = -+ (((u32 )transp & 0xff00) << 16) | -+ (((u32 )red & 0xff00) << 8) | -+ (((u32 )green & 0xff00)) | -+ (((u32 )blue & 0xff00) >> 8); -+ break; -+#endif -+ default: -+ printk("unsupported au1200_setcolreg(%d)\n", bpp); -+ break; -+ } -+ -+ return 0; -+} -+ -+ -+static int au1200_blank(int blank_mode, struct fb_info_gen *_info) -+{ -+ struct au1200fb_info *fb_info = (struct au1200fb_info *)_info; -+ int plane; -+ -+ /* Short-circuit screen blanking */ -+ if (fb_info->noblanking) -+ return 0; -+ -+ plane = fbinfo2index((struct fb_info *)_info); -+ -+ switch (blank_mode) { -+ case VESA_NO_BLANKING: -+ /* printk("turn on panel\n"); */ -+ au1200_setpanel(panel); -+ break; -+ -+ case VESA_VSYNC_SUSPEND: -+ case VESA_HSYNC_SUSPEND: -+ case VESA_POWERDOWN: -+ /* printk("turn off panel\n"); */ -+ au1200_setpanel(NULL); -+ break; -+ default: -+ break; -+ -+ } -+ return 0; -+} -+ -+static void au1200_set_disp(const void *unused, struct display *disp, -+ struct fb_info_gen *info) -+{ -+ struct au1200fb_info *fb_info; -+ int plane; -+ -+ fb_info = (struct au1200fb_info *)info; -+ -+ disp->screen_base = (char *)fb_info->fb_virt_start; -+ -+ switch (disp->var.bits_per_pixel) { -+#ifdef FBCON_HAS_CFB8 -+ case 8: -+ disp->dispsw = &fbcon_cfb8; -+ if (fb_info->nohwcursor) -+ fbcon_cfb8.cursor = au1200_nocursor; -+ break; -+#endif -+#ifdef FBCON_HAS_CFB16 -+ case 16: -+ disp->dispsw = &fbcon_cfb16; -+ disp->dispsw_data = fb_info->fbcon_cmap16; -+ if (fb_info->nohwcursor) -+ fbcon_cfb16.cursor = au1200_nocursor; -+ break; -+#endif -+#ifdef FBCON_HAS_CFB32 -+ case 32: -+ disp->dispsw = &fbcon_cfb32; -+ disp->dispsw_data = fb_info->fbcon_cmap32; -+ if (fb_info->nohwcursor) -+ fbcon_cfb32.cursor = au1200_nocursor; -+ break; -+#endif -+ default: -+ disp->dispsw = &fbcon_dummy; -+ disp->dispsw_data = NULL; -+ break; -+ } -+} -+ -+static int -+au1200fb_mmap(struct fb_info *_fb, -+ struct file *file, -+ struct vm_area_struct *vma) -+{ -+ unsigned int len; -+ unsigned long start=0, off; -+ -+ struct au1200fb_info *fb_info = (struct au1200fb_info *)_fb; -+ -+ if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) { -+ return -EINVAL; -+ } -+ -+ start = fb_info->fb_phys & PAGE_MASK; -+ len = PAGE_ALIGN((start & ~PAGE_MASK) + fb_info->fb_size); -+ -+ off = vma->vm_pgoff << PAGE_SHIFT; -+ -+ if ((vma->vm_end - vma->vm_start + off) > len) { -+ return -EINVAL; -+ } -+ -+ off += start; -+ vma->vm_pgoff = off >> PAGE_SHIFT; -+ -+ pgprot_val(vma->vm_page_prot) &= ~_CACHE_MASK; -+ pgprot_val(vma->vm_page_prot) |= _CACHE_UNCACHED; -+ -+ /* This is an IO map - tell maydump to skip this VMA */ -+ vma->vm_flags |= VM_IO; -+ -+ if (io_remap_page_range(vma->vm_start, off, -+ vma->vm_end - vma->vm_start, -+ vma->vm_page_prot)) { -+ return -EAGAIN; -+ } -+ -+ fb_info->mmaped = 1; -+ return 0; -+} -+ -+int au1200_pan_display(const struct fb_var_screeninfo *var, -+ struct fb_info_gen *info) -+{ -+ return 0; -+} -+ -+ -+static int au1200fb_ioctl(struct inode *inode, struct file *file, u_int cmd, -+ u_long arg, int con, struct fb_info *info) -+{ -+ int plane; -+ -+ plane = fbinfo2index(info); -+ -+ /* printk("au1200fb: ioctl %d on plane %d\n", cmd, plane); */ -+ -+ if (cmd == 0x46FF) -+ { -+ au1200_lcd_getset_t iodata; -+ -+ if (copy_from_user(&iodata, (void *) arg, sizeof(au1200_lcd_getset_t))) -+ return -EFAULT; -+ -+ switch (iodata.subcmd) -+ { -+ case AU1200_LCD_GET_WINENABLE: -+ iodata.winenable.enable = (lcd->winenable & (1<<plane)) ? 1 : 0; -+ break; -+ case AU1200_LCD_SET_WINENABLE: -+ { -+ u32 winenable; -+ winenable = lcd->winenable; -+ winenable &= ~(1<<plane); -+ winenable |= (iodata.winenable.enable) ? (1<<plane) : 0; -+ lcd->winenable = winenable; -+ } -+ break; -+ case AU1200_LCD_GET_WINLOCATION: -+ iodata.winlocation.x = -+ (lcd->window[plane].winctrl0 & LCD_WINCTRL0_OX) >> 21; -+ iodata.winlocation.y = -+ (lcd->window[plane].winctrl0 & LCD_WINCTRL0_OY) >> 10; -+ break; -+ case AU1200_LCD_SET_WINLOCATION: -+ au1200_setlocation(plane, iodata.winlocation.x, iodata.winlocation.y); -+ break; -+ case AU1200_LCD_GET_WINSIZE: -+ iodata.winsize.hsz = -+ (lcd->window[plane].winctrl1 & LCD_WINCTRL1_SZX) >> 11; -+ iodata.winsize.vsz = -+ (lcd->window[plane].winctrl0 & LCD_WINCTRL1_SZY) >> 0; -+ break; -+ case AU1200_LCD_SET_WINSIZE: -+ au1200_setsize(plane, iodata.winsize.hsz, iodata.winsize.vsz); -+ break; -+ case AU1200_LCD_GET_BACKCOLOR: -+ iodata.backcolor.color = lcd->backcolor; -+ break; -+ case AU1200_LCD_SET_BACKCOLOR: -+ lcd->backcolor = iodata.backcolor.color; -+ break; -+ case AU1200_LCD_GET_COLORKEY: -+ iodata.colorkey.key = lcd->colorkey; -+ iodata.colorkey.mask = lcd->colorkeymsk; -+ break; -+ case AU1200_LCD_SET_COLORKEY: -+ lcd->colorkey = iodata.colorkey.key; -+ lcd->colorkeymsk = iodata.colorkey.mask; -+ break; -+ case AU1200_LCD_GET_PANEL: -+ iodata.panel.panel = panel_index; -+ break; -+ case AU1200_LCD_SET_PANEL: -+ if ((iodata.panel.panel >= 0) && (iodata.panel.panel < NUM_PANELS)) -+ { -+ struct panel_settings *newpanel; -+ panel_index = iodata.panel.panel; -+ newpanel = &panels[panel_index]; -+ au1200_setpanel(newpanel); -+ } -+ break; -+ } -+ -+ return copy_to_user((void *) arg, &iodata, sizeof(au1200_lcd_getset_t)) ? -EFAULT : 0; -+ } -+ -+ return -EINVAL; -+} -+ -+static struct fbgen_hwswitch au1200_switch = { -+ au1200_detect, -+ au1200_encode_fix, -+ au1200_decode_var, -+ au1200_encode_var, -+ au1200_get_par, -+ au1200_set_par, -+ au1200_getcolreg, -+ au1200_setcolreg, -+ au1200_pan_display, -+ au1200_blank, -+ au1200_set_disp -+}; -+ -+static void au1200_setpanel (struct panel_settings *newpanel) -+{ -+ /* -+ * Perform global setup/init of LCD controller -+ */ -+ uint32 winenable; -+ -+ /* Make sure all windows disabled */ -+ winenable = lcd->winenable; -+ lcd->winenable = 0; -+ -+ /* -+ * Ensure everything is disabled before reconfiguring -+ */ -+ if (lcd->screen & LCD_SCREEN_SEN) -+ { -+ /* Wait for vertical sync period */ -+ lcd->intstatus = LCD_INT_SS; -+ while ((lcd->intstatus & LCD_INT_SS) == 0) -+ ; -+ -+ lcd->screen &= ~LCD_SCREEN_SEN; /*disable the controller*/ -+ -+ do -+ { -+ lcd->intstatus = lcd->intstatus; /*clear interrupts*/ -+ } -+ /*wait for controller to shut down*/ -+ while ((lcd->intstatus & LCD_INT_SD) == 0); -+ -+ /* Call shutdown of current panel (if up) */ -+ /* this must occur last, because if an external clock is driving -+ the controller, the clock cannot be turned off before first -+ shutting down the controller. -+ */ -+ if (panel->device_shutdown != NULL) panel->device_shutdown(); -+ } -+ -+ /* Check if only needing to turn off panel */ -+ if (panel == NULL) return; -+ -+ panel = newpanel; -+ -+ printk("Panel(%s), %dx%d\n", panel->name, panel->Xres, panel->Yres); -+ -+ /* -+ * Setup clocking if internal LCD clock source (assumes sys_auxpll valid) -+ */ -+ if (!(panel->mode_clkcontrol & LCD_CLKCONTROL_EXT)) -+ { -+ uint32 sys_clksrc; -+ /* WARNING! This should really be a check since other peripherals can -+ be affected by changins sys_auxpll */ -+ au_writel(panel->mode_auxpll, SYS_AUXPLL); -+ sys_clksrc = au_readl(SYS_CLKSRC) & ~0x0000001f; -+ sys_clksrc |= panel->mode_toyclksrc; -+ au_writel(sys_clksrc, SYS_CLKSRC); -+ } -+ -+ /* -+ * Configure panel timings -+ */ -+ lcd->screen = panel->mode_screen; -+ lcd->horztiming = panel->mode_horztiming; -+ lcd->verttiming = panel->mode_verttiming; -+ lcd->clkcontrol = panel->mode_clkcontrol; -+ lcd->pwmdiv = panel->mode_pwmdiv; -+ lcd->pwmhi = panel->mode_pwmhi; -+ lcd->outmask = panel->mode_outmask; -+ lcd->fifoctrl = panel->mode_fifoctrl; -+ au_sync(); -+ -+ /* FIX!!! Check window settings to make sure still valid for new geometry */ -+ au1200_setlocation(0, win->w[0].xpos, win->w[0].ypos); -+ au1200_setlocation(1, win->w[1].xpos, win->w[1].ypos); -+ au1200_setlocation(2, win->w[2].xpos, win->w[2].ypos); -+ au1200_setlocation(3, win->w[3].xpos, win->w[3].ypos); -+ lcd->winenable = winenable; -+ -+ /* -+ * Re-enable screen now that it is configured -+ */ -+ lcd->screen |= LCD_SCREEN_SEN; -+ au_sync(); -+ -+ /* Call init of panel */ -+ if (panel->device_init != NULL) panel->device_init(); -+ -+#if 0 -+#define D(X) printk("%25s: %08X\n", #X, X) -+ D(lcd->screen); -+ D(lcd->horztiming); -+ D(lcd->verttiming); -+ D(lcd->clkcontrol); -+ D(lcd->pwmdiv); -+ D(lcd->pwmhi); -+ D(lcd->outmask); -+ D(lcd->fifoctrl); -+ D(lcd->window[0].winctrl0); -+ D(lcd->window[0].winctrl1); -+ D(lcd->window[0].winctrl2); -+ D(lcd->window[0].winbuf0); -+ D(lcd->window[0].winbuf1); -+ D(lcd->window[0].winbufctrl); -+ D(lcd->window[1].winctrl0); -+ D(lcd->window[1].winctrl1); -+ D(lcd->window[1].winctrl2); -+ D(lcd->window[1].winbuf0); -+ D(lcd->window[1].winbuf1); -+ D(lcd->window[1].winbufctrl); -+ D(lcd->window[2].winctrl0); -+ D(lcd->window[2].winctrl1); -+ D(lcd->window[2].winctrl2); -+ D(lcd->window[2].winbuf0); -+ D(lcd->window[2].winbuf1); -+ D(lcd->window[2].winbufctrl); -+ D(lcd->window[3].winctrl0); -+ D(lcd->window[3].winctrl1); -+ D(lcd->window[3].winctrl2); -+ D(lcd->window[3].winbuf0); -+ D(lcd->window[3].winbuf1); -+ D(lcd->window[3].winbufctrl); -+ D(lcd->winenable); -+ D(lcd->intenable); -+ D(lcd->intstatus); -+ D(lcd->backcolor); -+ D(lcd->winenable); -+ D(lcd->colorkey); -+ D(lcd->colorkeymsk); -+ D(lcd->hwc.cursorctrl); -+ D(lcd->hwc.cursorpos); -+ D(lcd->hwc.cursorcolor0); -+ D(lcd->hwc.cursorcolor1); -+ D(lcd->hwc.cursorcolor2); -+ D(lcd->hwc.cursorcolor3); -+#endif -+} -+ -+static int au1200_setsize (int plane, int xres, int yres) -+{ -+#if 0 -+ uint32 winctrl0, winctrl1, winenable; -+ int xsz, ysz; -+ -+ /* FIX!!! X*Y can not surpass allocated memory */ -+ -+ printk("setsize: x %d y %d\n", xres, yres); -+ winctrl1 = lcd->window[plane].winctrl1; -+ printk("org winctrl1 %08X\n", winctrl1); -+ winctrl1 &= ~(LCD_WINCTRL1_SZX | LCD_WINCTRL1_SZY); -+ -+ xres -= 1; -+ yres -= 1; -+ winctrl1 |= (xres << 11); -+ winctrl1 |= (yres << 0); -+ -+ printk("new winctrl1 %08X\n", winctrl1); -+ -+ /*winenable = lcd->winenable & (1 << plane); */ -+ /*lcd->winenable &= ~(1 << plane); */ -+ lcd->window[plane].winctrl1 = winctrl1; -+ /*lcd->winenable |= winenable; */ -+#endif -+ return 0; -+} -+ -+static int au1200_setlocation (int plane, int xpos, int ypos) -+{ -+ uint32 winctrl0, winctrl1, winenable, fb_offset = 0; -+ int xsz, ysz; -+ -+ /* FIX!!! NOT CHECKING FOR COMPLETE OFFSCREEN YET */ -+ -+ winctrl0 = lcd->window[plane].winctrl0; -+ winctrl1 = lcd->window[plane].winctrl1; -+ winctrl0 &= (LCD_WINCTRL0_A | LCD_WINCTRL0_AEN); -+ winctrl1 &= ~(LCD_WINCTRL1_SZX | LCD_WINCTRL1_SZY); -+ -+ /* Check for off-screen adjustments */ -+ xsz = win->w[plane].xres; -+ ysz = win->w[plane].yres; -+ if ((xpos + win->w[plane].xres) > panel->Xres) -+ { -+ /* Off-screen to the right */ -+ xsz = panel->Xres - xpos; /* off by 1 ??? */ -+ /*printk("off screen right\n");*/ -+ } -+ -+ if ((ypos + win->w[plane].yres) > panel->Yres) -+ { -+ /* Off-screen to the bottom */ -+ ysz = panel->Yres - ypos; /* off by 1 ??? */ -+ /*printk("off screen bottom\n");*/ -+ } -+ -+ if (xpos < 0) -+ { -+ /* Off-screen to the left */ -+ xsz = win->w[plane].xres + xpos; -+ fb_offset += (((0 - xpos) * winbpp(lcd->window[plane].winctrl1))/8); -+ xpos = 0; -+ /*printk("off screen left\n");*/ -+ } -+ -+ if (ypos < 0) -+ { -+ /* Off-screen to the top */ -+ ysz = win->w[plane].yres + ypos; -+ fb_offset += ((0 - ypos) * fb_pars[plane].line_length); -+ ypos = 0; -+ /*printk("off screen top\n");*/ -+ } -+ -+ /* record settings */ -+ win->w[plane].xpos = xpos; -+ win->w[plane].ypos = ypos; -+ -+ xsz -= 1; -+ ysz -= 1; -+ winctrl0 |= (xpos << 21); -+ winctrl0 |= (ypos << 10); -+ winctrl1 |= (xsz << 11); -+ winctrl1 |= (ysz << 0); -+ -+ /* Disable the window while making changes, then restore WINEN */ -+ winenable = lcd->winenable & (1 << plane); -+ lcd->winenable &= ~(1 << plane); -+ lcd->window[plane].winctrl0 = winctrl0; -+ lcd->window[plane].winctrl1 = winctrl1; -+ lcd->window[plane].winbuf0 = -+ lcd->window[plane].winbuf1 = fb_infos[plane].fb_phys + fb_offset; -+ lcd->window[plane].winbufctrl = 0; /* select winbuf0 */ -+ lcd->winenable |= winenable; -+ -+ return 0; -+} -+ -+static void au1200_setmode(int plane) -+{ -+ /* Window/plane setup */ -+ lcd->window[plane].winctrl1 = ( 0 -+ | LCD_WINCTRL1_PRI_N(plane) -+ | win->w[plane].mode_winctrl1 /* FRM,CCO,PO,PIPE */ -+ ) ; -+ -+ au1200_setlocation(plane, win->w[plane].xpos, win->w[plane].ypos); -+ -+ lcd->window[plane].winctrl2 = ( 0 -+ | LCD_WINCTRL2_CKMODE_00 -+ | LCD_WINCTRL2_DBM -+/* | LCD_WINCTRL2_RAM */ -+ | LCD_WINCTRL2_BX_N(fb_pars[plane].line_length) -+ | LCD_WINCTRL2_SCX_1 -+ | LCD_WINCTRL2_SCY_1 -+ ) ; -+ lcd->winenable |= win->w[plane].mode_winenable; -+ au_sync(); -+ -+} -+ -+static unsigned long -+au1200fb_alloc_fbmem (unsigned long size) -+{ -+ /* __get_free_pages() fulfills a max request of 2MB */ -+ /* do multiple requests to obtain large contigous mem */ -+#define MAX_GFP 0x00200000 -+ -+ unsigned long mem, amem, alloced = 0, allocsize; -+ -+ size += 0x1000; -+ allocsize = (size < MAX_GFP) ? size : MAX_GFP; -+ -+ /* Get first chunk */ -+ mem = (unsigned long ) -+ __get_free_pages(GFP_ATOMIC | GFP_DMA, get_order(allocsize)); -+ if (mem != 0) alloced = allocsize; -+ -+ /* Get remaining, contiguous chunks */ -+ while (alloced < size) -+ { -+ amem = (unsigned long ) -+ __get_free_pages(GFP_ATOMIC | GFP_DMA, get_order(allocsize)); -+ if (amem != 0) -+ alloced += allocsize; -+ -+ /* check for contiguous mem alloced */ -+ if ((amem == 0) || (amem + allocsize) != mem) -+ break; -+ else -+ mem = amem; -+ } -+ return mem; -+} -+ -+int __init au1200fb_init(void) -+{ -+ int num_panels = sizeof(panels)/sizeof(struct panel_settings); -+ struct au1200fb_info *fb_info; -+ struct display *disp; -+ struct au1200fb_par *par; -+ unsigned long page; -+ int plane, bpp; -+ -+ /* -+ * Get the panel information/display mode -+ */ -+ if (panel_index < 0) -+ panel_index = board_au1200fb_panel(); -+ if ((panel_index < 0) || (panel_index >= num_panels)) { -+ printk("ERROR: INVALID PANEL %d\n", panel_index); -+ return -EINVAL; -+ } -+ panel = &panels[panel_index]; -+ win = &windows[window_index]; -+ -+ printk("au1200fb: Panel %d %s\n", panel_index, panel->name); -+ printk("au1200fb: Win %d %s\n", window_index, win->name); -+ -+ /* Global setup/init */ -+ au1200_setpanel(panel); -+ lcd->intenable = 0; -+ lcd->intstatus = ~0; -+ lcd->backcolor = win->mode_backcolor; -+ lcd->winenable = 0; -+ -+ /* Setup Color Key - FIX!!! */ -+ lcd->colorkey = win->mode_colorkey; -+ lcd->colorkeymsk = win->mode_colorkeymsk; -+ -+ /* Setup HWCursor - FIX!!! Need to support this eventually */ -+ lcd->hwc.cursorctrl = 0; -+ lcd->hwc.cursorpos = 0; -+ lcd->hwc.cursorcolor0 = 0; -+ lcd->hwc.cursorcolor1 = 0; -+ lcd->hwc.cursorcolor2 = 0; -+ lcd->hwc.cursorcolor3 = 0; -+ -+ /* Register each plane as a frame buffer device */ -+ for (plane = 0; plane < CONFIG_FB_AU1200_DEVS; ++plane) -+ { -+ fb_info = &fb_infos[plane]; -+ disp = &disps[plane]; -+ par = &fb_pars[plane]; -+ -+ bpp = winbpp(win->w[plane].mode_winctrl1); -+ if (win->w[plane].xres == 0) -+ win->w[plane].xres = panel->Xres; -+ if (win->w[plane].yres == 0) -+ win->w[plane].yres = panel->Yres; -+ -+ par->var.xres = -+ par->var.xres_virtual = win->w[plane].xres; -+ par->var.yres = -+ par->var.yres_virtual = win->w[plane].yres; -+ par->var.bits_per_pixel = bpp; -+ par->line_length = win->w[plane].xres * bpp / 8; /* in bytes */ -+ /* -+ * Allocate LCD framebuffer from system memory -+ * Set page reserved so that mmap will work. This is necessary -+ * since we'll be remapping normal memory. -+ */ -+ fb_info->fb_size = (win->w[plane].xres * win->w[plane].yres * bpp) / 8; -+ fb_info->fb_virt_start = au1200fb_alloc_fbmem(fb_info->fb_size); -+ if (!fb_info->fb_virt_start) { -+ printk("Unable to allocate fb memory\n"); -+ return -ENOMEM; -+ } -+ fb_info->fb_phys = virt_to_bus((void *)fb_info->fb_virt_start); -+ for (page = fb_info->fb_virt_start; -+ page < PAGE_ALIGN(fb_info->fb_virt_start + fb_info->fb_size); -+ page += PAGE_SIZE) { -+ SetPageReserved(virt_to_page(page)); -+ } -+ /* Convert to kseg1 */ -+ fb_info->fb_virt_start = -+ (void *)((u32)fb_info->fb_virt_start | 0xA0000000); -+ /* FIX!!! may wish to avoid this to save startup time??? */ -+ memset((void *)fb_info->fb_virt_start, 0, fb_info->fb_size); -+ -+ fb_info->gen.parsize = sizeof(struct au1200fb_par); -+ fb_info->gen.fbhw = &au1200_switch; -+ strcpy(fb_info->gen.info.modename, "Au1200 LCD"); -+ fb_info->gen.info.changevar = NULL; -+ fb_info->gen.info.node = -1; -+ -+ fb_info->gen.info.fbops = &au1200fb_ops; -+ fb_info->gen.info.disp = disp; -+ fb_info->gen.info.switch_con = &fbgen_switch; -+ fb_info->gen.info.updatevar = &fbgen_update_var; -+ fb_info->gen.info.blank = &fbgen_blank; -+ fb_info->gen.info.flags = FBINFO_FLAG_DEFAULT; -+ -+ fb_info->nohwcursor = 1; -+ fb_info->noblanking = 1; -+ -+ /* This should give a reasonable default video mode */ -+ fbgen_get_var(&disp->var, -1, &fb_info->gen.info); -+ fbgen_do_set_var(&disp->var, 1, &fb_info->gen); -+ fbgen_set_disp(-1, &fb_info->gen); -+ fbgen_install_cmap(0, &fb_info->gen); -+ -+ /* Turn on plane */ -+ au1200_setmode(plane); -+ -+ if (register_framebuffer(&fb_info->gen.info) < 0) -+ return -EINVAL; -+ -+ printk(KERN_INFO "fb%d: %s plane %d @ %08X (%d x %d x %d)\n", -+ GET_FB_IDX(fb_info->gen.info.node), -+ fb_info->gen.info.modename, plane, fb_info->fb_phys, -+ win->w[plane].xres, win->w[plane].yres, bpp); -+ } -+ /* uncomment this if your driver cannot be unloaded */ -+ /* MOD_INC_USE_COUNT; */ -+ return 0; -+} -+ -+void au1200fb_setup(char *options, int *ints) -+{ -+ char* this_opt; -+ int i; -+ int num_panels = sizeof(panels)/sizeof(struct panel_settings); -+ -+ if (!options || !*options) -+ return; -+ -+ for(this_opt=strtok(options, ","); this_opt; -+ this_opt=strtok(NULL, ",")) { -+ if (!strncmp(this_opt, "panel:", 6)) { -+ int i; -+ long int li; -+ char *endptr; -+ this_opt += 6; -+ -+ /* Panel name can be name, "bs" for board-switch, or number/index */ -+ li = simple_strtol(this_opt, &endptr, 0); -+ if (*endptr == '\0') { -+ panel_index = (int)li; -+ } -+ else if (strcmp(this_opt, "bs") == 0) { -+ panel_index = board_au1200fb_panel(); -+ } -+ else -+ for (i=0; i<num_panels; i++) { -+ if (!strcmp(this_opt, panels[i].name)) { -+ panel_index = i; -+ break; -+ } -+ } -+ } -+ else if (!strncmp(this_opt, "nohwcursor", 10)) { -+ printk("nohwcursor\n"); -+ fb_infos[0].nohwcursor = 1; -+ } -+ } -+ -+ printk("au1200fb: Panel %d %s\n", panel_index, -+ panels[panel_index].name); -+} -+ -+ -+ -+#ifdef MODULE -+MODULE_LICENSE("GPL"); -+MODULE_DESCRIPTION("Au1200 LCD framebuffer driver"); -+ -+void au1200fb_cleanup(struct fb_info *info) -+{ -+ unregister_framebuffer(info); -+} -+ -+module_init(au1200fb_init); -+module_exit(au1200fb_cleanup); -+#endif /* MODULE */ -+ -+ ---- /dev/null -+++ b/drivers/video/au1200fb.h -@@ -0,0 +1,288 @@ -+/* -+ * BRIEF MODULE DESCRIPTION -+ * Hardware definitions for the Au1200 LCD controller -+ * -+ * Copyright 2004 AMD -+ * Author: AMD -+ * -+ * 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 SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN -+ * NO EVENT SHALL THE AUTHOR 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. -+ * -+ * You should have received a copy of the GNU General Public License along -+ * with this program; if not, write to the Free Software Foundation, Inc., -+ * 675 Mass Ave, Cambridge, MA 02139, USA. -+ */ -+ -+#ifndef _AU1200LCD_H -+#define _AU1200LCD_H -+ -+/********************************************************************/ -+#define AU1200_LCD_ADDR 0xB5000000 -+ -+#define uint8 unsigned char -+#define uint32 unsigned int -+ -+typedef volatile struct -+{ -+ uint32 reserved0; -+ uint32 screen; -+ uint32 backcolor; -+ uint32 horztiming; -+ uint32 verttiming; -+ uint32 clkcontrol; -+ uint32 pwmdiv; -+ uint32 pwmhi; -+ uint32 reserved1; -+ uint32 winenable; -+ uint32 colorkey; -+ uint32 colorkeymsk; -+ struct -+ { -+ uint32 cursorctrl; -+ uint32 cursorpos; -+ uint32 cursorcolor0; -+ uint32 cursorcolor1; -+ uint32 cursorcolor2; -+ uint32 cursorcolor3; -+ } hwc; -+ uint32 intstatus; -+ uint32 intenable; -+ uint32 outmask; -+ uint32 fifoctrl; -+ uint32 reserved2[(0x0100-0x0058)/4]; -+ struct -+ { -+ uint32 winctrl0; -+ uint32 winctrl1; -+ uint32 winctrl2; -+ uint32 winbuf0; -+ uint32 winbuf1; -+ uint32 winbufctrl; -+ uint32 winreserved0; -+ uint32 winreserved1; -+ } window[4]; -+ -+ uint32 reserved3[(0x0400-0x0180)/4]; -+ -+ uint32 palette[(0x0800-0x0400)/4]; -+ -+ uint8 cursorpattern[256]; -+ -+} AU1200_LCD; -+ -+/* lcd_screen */ -+#define LCD_SCREEN_SEN (1<<31) -+#define LCD_SCREEN_SX (0x07FF<<19) -+#define LCD_SCREEN_SY (0x07FF<< 8) -+#define LCD_SCREEN_SWP (1<<7) -+#define LCD_SCREEN_SWD (1<<6) -+#define LCD_SCREEN_ST (7<<0) -+#define LCD_SCREEN_ST_TFT (0<<0) -+#define LCD_SCREEN_SX_N(WIDTH) ((WIDTH-1)<<19) -+#define LCD_SCREEN_SY_N(HEIGHT) ((HEIGHT-1)<<8) -+#define LCD_SCREEN_ST_CSTN (1<<0) -+#define LCD_SCREEN_ST_CDSTN (2<<0) -+#define LCD_SCREEN_ST_M8STN (3<<0) -+#define LCD_SCREEN_ST_M4STN (4<<0) -+ -+/* lcd_backcolor */ -+#define LCD_BACKCOLOR_SBGR (0xFF<<16) -+#define LCD_BACKCOLOR_SBGG (0xFF<<8) -+#define LCD_BACKCOLOR_SBGB (0xFF<<0) -+#define LCD_BACKCOLOR_SBGR_N(N) ((N)<<16) -+#define LCD_BACKCOLOR_SBGG_N(N) ((N)<<8) -+#define LCD_BACKCOLOR_SBGB_N(N) ((N)<<0) -+ -+/* lcd_winenable */ -+#define LCD_WINENABLE_WEN3 (1<<3) -+#define LCD_WINENABLE_WEN2 (1<<2) -+#define LCD_WINENABLE_WEN1 (1<<1) -+#define LCD_WINENABLE_WEN0 (1<<0) -+ -+/* lcd_colorkey */ -+#define LCD_COLORKEY_CKR (0xFF<<16) -+#define LCD_COLORKEY_CKG (0xFF<<8) -+#define LCD_COLORKEY_CKB (0xFF<<0) -+#define LCD_COLORKEY_CKR_N(N) ((N)<<16) -+#define LCD_COLORKEY_CKG_N(N) ((N)<<8) -+#define LCD_COLORKEY_CKB_N(N) ((N)<<0) -+ -+/* lcd_colorkeymsk */ -+#define LCD_COLORKEYMSK_CKMR (0xFF<<16) -+#define LCD_COLORKEYMSK_CKMG (0xFF<<8) -+#define LCD_COLORKEYMSK_CKMB (0xFF<<0) -+#define LCD_COLORKEYMSK_CKMR_N(N) ((N)<<16) -+#define LCD_COLORKEYMSK_CKMG_N(N) ((N)<<8) -+#define LCD_COLORKEYMSK_CKMB_N(N) ((N)<<0) -+ -+/* lcd windows control 0 */ -+#define LCD_WINCTRL0_OX (0x07FF<<21) -+#define LCD_WINCTRL0_OY (0x07FF<<10) -+#define LCD_WINCTRL0_A (0x00FF<<2) -+#define LCD_WINCTRL0_AEN (1<<1) -+#define LCD_WINCTRL0_OX_N(N) ((N)<<21) -+#define LCD_WINCTRL0_OY_N(N) ((N)<<10) -+#define LCD_WINCTRL0_A_N(N) ((N)<<2) -+ -+/* lcd windows control 1 */ -+#define LCD_WINCTRL1_PRI (3<<30) -+#define LCD_WINCTRL1_PIPE (1<<29) -+#define LCD_WINCTRL1_FRM (0xF<<25) -+#define LCD_WINCTRL1_CCO (1<<24) -+#define LCD_WINCTRL1_PO (3<<22) -+#define LCD_WINCTRL1_SZX (0x07FF<<11) -+#define LCD_WINCTRL1_SZY (0x07FF<<0) -+#define LCD_WINCTRL1_FRM_1BPP (0<<25) -+#define LCD_WINCTRL1_FRM_2BPP (1<<25) -+#define LCD_WINCTRL1_FRM_4BPP (2<<25) -+#define LCD_WINCTRL1_FRM_8BPP (3<<25) -+#define LCD_WINCTRL1_FRM_12BPP (4<<25) -+#define LCD_WINCTRL1_FRM_16BPP655 (5<<25) -+#define LCD_WINCTRL1_FRM_16BPP565 (6<<25) -+#define LCD_WINCTRL1_FRM_16BPP556 (7<<25) -+#define LCD_WINCTRL1_FRM_16BPPI1555 (8<<25) -+#define LCD_WINCTRL1_FRM_16BPPI5551 (9<<25) -+#define LCD_WINCTRL1_FRM_16BPPA1555 (10<<25) -+#define LCD_WINCTRL1_FRM_16BPPA5551 (11<<25) -+#define LCD_WINCTRL1_FRM_24BPP (12<<25) -+#define LCD_WINCTRL1_FRM_32BPP (13<<25) -+#define LCD_WINCTRL1_PRI_N(N) ((N)<<30) -+#define LCD_WINCTRL1_PO_00 (0<<22) -+#define LCD_WINCTRL1_PO_01 (1<<22) -+#define LCD_WINCTRL1_PO_10 (2<<22) -+#define LCD_WINCTRL1_PO_11 (3<<22) -+#define LCD_WINCTRL1_SZX_N(N) ((N-1)<<11) -+#define LCD_WINCTRL1_SZY_N(N) ((N-1)<<0) -+ -+/* lcd windows control 2 */ -+#define LCD_WINCTRL2_CKMODE (3<<24) -+#define LCD_WINCTRL2_DBM (1<<23) -+#define LCD_WINCTRL2_RAM (3<<21) -+#define LCD_WINCTRL2_BX (0x1FFF<<8) -+#define LCD_WINCTRL2_SCX (0xF<<4) -+#define LCD_WINCTRL2_SCY (0xF<<0) -+#define LCD_WINCTRL2_CKMODE_00 (0<<24) -+#define LCD_WINCTRL2_CKMODE_01 (1<<24) -+#define LCD_WINCTRL2_CKMODE_10 (2<<24) -+#define LCD_WINCTRL2_CKMODE_11 (3<<24) -+#define LCD_WINCTRL2_RAM_NONE (0<<21) -+#define LCD_WINCTRL2_RAM_PALETTE (1<<21) -+#define LCD_WINCTRL2_RAM_GAMMA (2<<21) -+#define LCD_WINCTRL2_RAM_BUFFER (3<<21) -+#define LCD_WINCTRL2_BX_N(N) ((N)<<8) -+#define LCD_WINCTRL2_SCX_1 (0<<4) -+#define LCD_WINCTRL2_SCX_2 (1<<4) -+#define LCD_WINCTRL2_SCX_4 (2<<4) -+#define LCD_WINCTRL2_SCY_1 (0<<0) -+#define LCD_WINCTRL2_SCY_2 (1<<0) -+#define LCD_WINCTRL2_SCY_4 (2<<0) -+ -+/* lcd windows buffer control */ -+#define LCD_WINBUFCTRL_DB (1<<1) -+#define LCD_WINBUFCTRL_DBN (1<<0) -+ -+/* lcd_intstatus, lcd_intenable */ -+#define LCD_INT_IFO (0xF<<14) -+#define LCD_INT_IFU (0xF<<10) -+#define LCD_INT_OFO (1<<9) -+#define LCD_INT_OFU (1<<8) -+#define LCD_INT_WAIT (1<<3) -+#define LCD_INT_SD (1<<2) -+#define LCD_INT_SA (1<<1) -+#define LCD_INT_SS (1<<0) -+ -+/* lcd_horztiming */ -+#define LCD_HORZTIMING_HND2 (0x1FF<<18) -+#define LCD_HORZTIMING_HND1 (0x1FF<<9) -+#define LCD_HORZTIMING_HPW (0x1FF<<0) -+#define LCD_HORZTIMING_HND2_N(N)(((N)-1)<<18) -+#define LCD_HORZTIMING_HND1_N(N)(((N)-1)<<9) -+#define LCD_HORZTIMING_HPW_N(N) (((N)-1)<<0) -+ -+/* lcd_verttiming */ -+#define LCD_VERTTIMING_VND2 (0x1FF<<18) -+#define LCD_VERTTIMING_VND1 (0x1FF<<9) -+#define LCD_VERTTIMING_VPW (0x1FF<<0) -+#define LCD_VERTTIMING_VND2_N(N)(((N)-1)<<18) -+#define LCD_VERTTIMING_VND1_N(N)(((N)-1)<<9) -+#define LCD_VERTTIMING_VPW_N(N) (((N)-1)<<0) -+ -+/* lcd_clkcontrol */ -+#define LCD_CLKCONTROL_EXT (1<<22) -+#define LCD_CLKCONTROL_DELAY (3<<20) -+#define LCD_CLKCONTROL_CDD (1<<19) -+#define LCD_CLKCONTROL_IB (1<<18) -+#define LCD_CLKCONTROL_IC (1<<17) -+#define LCD_CLKCONTROL_IH (1<<16) -+#define LCD_CLKCONTROL_IV (1<<15) -+#define LCD_CLKCONTROL_BF (0x1F<<10) -+#define LCD_CLKCONTROL_PCD (0x3FF<<0) -+#define LCD_CLKCONTROL_BF_N(N) (((N)-1)<<10) -+#define LCD_CLKCONTROL_PCD_N(N) ((N)<<0) -+ -+/* lcd_pwmdiv */ -+#define LCD_PWMDIV_EN (1<<31) -+#define LCD_PWMDIV_PWMDIV (0x1FFFF<<0) -+#define LCD_PWMDIV_PWMDIV_N(N) ((N)<<0) -+ -+/* lcd_pwmhi */ -+#define LCD_PWMHI_PWMHI1 (0xFFFF<<16) -+#define LCD_PWMHI_PWMHI0 (0xFFFF<<0) -+#define LCD_PWMHI_PWMHI1_N(N) ((N)<<16) -+#define LCD_PWMHI_PWMHI0_N(N) ((N)<<0) -+ -+/* lcd_hwccon */ -+#define LCD_HWCCON_EN (1<<0) -+ -+/* lcd_cursorpos */ -+#define LCD_CURSORPOS_HWCXOFF (0x1F<<27) -+#define LCD_CURSORPOS_HWCXPOS (0x07FF<<16) -+#define LCD_CURSORPOS_HWCYOFF (0x1F<<11) -+#define LCD_CURSORPOS_HWCYPOS (0x07FF<<0) -+#define LCD_CURSORPOS_HWCXOFF_N(N) ((N)<<27) -+#define LCD_CURSORPOS_HWCXPOS_N(N) ((N)<<16) -+#define LCD_CURSORPOS_HWCYOFF_N(N) ((N)<<11) -+#define LCD_CURSORPOS_HWCYPOS_N(N) ((N)<<0) -+ -+/* lcd_cursorcolor */ -+#define LCD_CURSORCOLOR_HWCA (0xFF<<24) -+#define LCD_CURSORCOLOR_HWCR (0xFF<<16) -+#define LCD_CURSORCOLOR_HWCG (0xFF<<8) -+#define LCD_CURSORCOLOR_HWCB (0xFF<<0) -+#define LCD_CURSORCOLOR_HWCA_N(N) ((N)<<24) -+#define LCD_CURSORCOLOR_HWCR_N(N) ((N)<<16) -+#define LCD_CURSORCOLOR_HWCG_N(N) ((N)<<8) -+#define LCD_CURSORCOLOR_HWCB_N(N) ((N)<<0) -+ -+/* lcd_fifoctrl */ -+#define LCD_FIFOCTRL_F3IF (1<<29) -+#define LCD_FIFOCTRL_F3REQ (0x1F<<24) -+#define LCD_FIFOCTRL_F2IF (1<<29) -+#define LCD_FIFOCTRL_F2REQ (0x1F<<16) -+#define LCD_FIFOCTRL_F1IF (1<<29) -+#define LCD_FIFOCTRL_F1REQ (0x1F<<8) -+#define LCD_FIFOCTRL_F0IF (1<<29) -+#define LCD_FIFOCTRL_F0REQ (0x1F<<0) -+#define LCD_FIFOCTRL_F3REQ_N(N) ((N-1)<<24) -+#define LCD_FIFOCTRL_F2REQ_N(N) ((N-1)<<16) -+#define LCD_FIFOCTRL_F1REQ_N(N) ((N-1)<<8) -+#define LCD_FIFOCTRL_F0REQ_N(N) ((N-1)<<0) -+ -+/* lcd_outmask */ -+#define LCD_OUTMASK_MASK (0x00FFFFFF) -+ -+/********************************************************************/ -+#endif /* _AU1200LCD_H */ ---- a/drivers/video/Config.in -+++ b/drivers/video/Config.in -@@ -87,8 +87,8 @@ if [ "$CONFIG_FB" = "y" ]; then - if [ "$CONFIG_HP300" = "y" ]; then - define_bool CONFIG_FB_HP300 y - fi -- if [ "$ARCH" = "alpha" ]; then -- tristate ' TGA framebuffer support' CONFIG_FB_TGA -+ if [ "$ARCH" = "alpha" -o "$CONFIG_TC" = "y" ]; then -+ tristate ' TGA/SFB+ framebuffer support' CONFIG_FB_TGA - fi - if [ "$CONFIG_X86" = "y" ]; then - bool ' VESA VGA graphics console' CONFIG_FB_VESA -@@ -121,6 +121,17 @@ if [ "$CONFIG_FB" = "y" ]; then - hex ' Framebuffer Base Address' CONFIG_E1355_FB_BASE a8200000 - fi - fi -+ if [ "$CONFIG_SOC_AU1100" = "y" ]; then -+ bool ' Au1100 LCD Driver' CONFIG_FB_AU1100 -+ fi -+ -+ if [ "$CONFIG_SOC_AU1200" = "y" ]; then -+ bool ' Au1200 LCD Driver' CONFIG_FB_AU1200 -+ if [ "$CONFIG_FB_AU1200" = "y" ]; then -+ int ' Number of planes (1 to 4)' CONFIG_FB_AU1200_DEVS 1 -+ fi -+ fi -+ - if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then - if [ "$CONFIG_PCI" != "n" ]; then - tristate ' Matrox acceleration (EXPERIMENTAL)' CONFIG_FB_MATROX -@@ -178,9 +189,6 @@ if [ "$CONFIG_FB" = "y" ]; then - bool ' Use CRT on Pb1100 ' CONFIG_PB1500_CRT - bool ' Use TFT Panel on Pb1100 ' CONFIG_PB1500_TFT - fi -- if [ "$CONFIG_SOC_AU1100" = "y" ]; then -- bool ' Au1100 LCD Driver' CONFIG_FB_AU1100 -- fi - fi - fi - fi ---- a/drivers/video/fbmem.c -+++ b/drivers/video/fbmem.c -@@ -139,6 +139,8 @@ extern int e1356fb_init(void); - extern int e1356fb_setup(char*); - extern int au1100fb_init(void); - extern int au1100fb_setup(char*); -+extern int au1200fb_init(void); -+extern int au1200fb_setup(char*); - extern int pvr2fb_init(void); - extern int pvr2fb_setup(char*); - extern int sstfb_init(void); -@@ -331,6 +333,9 @@ static struct { - #ifdef CONFIG_FB_AU1100 - { "au1100fb", au1100fb_init, au1100fb_setup }, - #endif -+#ifdef CONFIG_FB_AU1200 -+ { "au1200fb", au1200fb_init, au1200fb_setup }, -+#endif - #ifdef CONFIG_FB_IT8181 - { "it8181fb", it8181fb_init, it8181fb_setup }, - #endif ---- /dev/null -+++ b/drivers/video/ims332.h -@@ -0,0 +1,275 @@ -+/* -+ * linux/drivers/video/ims332.h -+ * -+ * Copyright 2003 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de> -+ * -+ * 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/types.h> -+ -+/* -+ * IMS332 16-bit wide, 128-bit aligned registers. -+ */ -+struct _ims332_reg { -+ volatile u16 r; -+ u16 pad[7]; -+}; -+ -+struct _ims332_regs { -+#define IMS332_BOOT_PLL_MUTLIPLIER 0x00001f -+#define IMS332_BOOT_CLOCK_SOURCE_SEL 0x000020 -+#define IMS332_BOOT_ADDRESS_ALIGNMENT 0x000040 -+#define IMS332_BOOT_WRITE_ZERO 0xffff80 -+ struct _ims332_reg boot; -+ struct _ims332_reg pad0[0x020 - 0x000]; -+ struct _ims332_reg half_sync; -+ struct _ims332_reg back_porch; -+ struct _ims332_reg display; -+ struct _ims332_reg short_display; -+ struct _ims332_reg broad_pulse; -+ struct _ims332_reg vsync; -+ struct _ims332_reg vpre_equalise; -+ struct _ims332_reg vpost_equalise; -+ struct _ims332_reg vblank; -+ struct _ims332_reg vdisplay; -+ struct _ims332_reg line_time; -+ struct _ims332_reg line_start; -+ struct _ims332_reg mem_init; -+ struct _ims332_reg transfer_delay; -+ struct _ims332_reg pad1[0x03f - 0x02e]; -+ struct _ims332_reg pixel_address_mask; -+ struct _ims332_reg pad2[0x05f - 0x040]; -+ -+#define IMS332_CTRL_A_BOOT_ENABLE_VTG 0x000001 -+#define IMS332_CTRL_A_SCREEN_FORMAT 0x000002 -+#define IMS332_CTRL_A_INTERLACED_STANDARD 0x000004 -+#define IMS332_CTRL_A_OPERATING_MODE 0x000008 -+#define IMS332_CTRL_A_FRAME_FLYBACK_PATTERN 0x000010 -+#define IMS332_CTRL_A_DIGITAL_SYNC_FORMAT 0x000020 -+#define IMS332_CTRL_A_ANALOGUE_VIDEO_FORMAT 0x000040 -+#define IMS332_CTRL_A_BLANK_LEVEL 0x000080 -+#define IMS332_CTRL_A_BLANK_IO 0x000100 -+#define IMS332_CTRL_A_BLANK_FUNCTION_SWITCH 0x000200 -+#define IMS332_CTRL_A_FORCE_BLANKING 0x000400 -+#define IMS332_CTRL_A_TURN_OFF_BLANKING 0x000800 -+#define IMS332_CTRL_A_VRAM_ADDRESS_INCREMENT 0x003000 -+#define IMS332_CTRL_A_TURN_OFF_DMA 0x004000 -+#define IMS332_CTRL_A_SYNC_DELAY 0x038000 -+#define IMS332_CTRL_A_PIXEL_PORT_INTERLEAVING 0x040000 -+#define IMS332_CTRL_A_DELAYED_SAMPLING 0x080000 -+#define IMS332_CTRL_A_BITS_PER_PIXEL 0x700000 -+#define IMS332_CTRL_A_CURSOR_DISABLE 0x800000 -+ struct _ims332_reg config_control_a; -+ struct _ims332_reg pad3[0x06f - 0x060]; -+ -+#define IMS332_CTRL_B_WRITE_ZERO 0xffffff -+ struct _ims332_reg config_control_b; -+ struct _ims332_reg pad4[0x07f - 0x070]; -+ struct _ims332_reg screen_top; -+ struct _ims332_reg pad5[0x0a0 - 0x080]; -+ /* cursor color palette, 3 entries, reg no. 0xa1 - 0xa3 */ -+ struct _ims332_reg cursor_color_palette0; -+ struct _ims332_reg cursor_color_palette1; -+ struct _ims332_reg cursor_color_palette2; -+ struct _ims332_reg pad6[0x0bf - 0x0a3]; -+ struct _ims332_reg rgb_frame_checksum0; -+ struct _ims332_reg rgb_frame_checksum1; -+ struct _ims332_reg rgb_frame_checksum2; -+ struct _ims332_reg pad7[0x0c6 - 0x0c2]; -+ struct _ims332_reg cursor_start; -+ struct _ims332_reg pad8[0x0ff - 0x0c7]; -+ /* color palette, 256 entries of form 0x00BBGGRR, reg no. 0x100 - 0x1ff */ -+ struct _ims332_reg color_palette[0x1ff - 0x0ff]; -+ /* hardware cursor bitmap, reg no. 0x200 - 0x3ff */ -+ struct _ims332_reg cursor_ram[0x3ff - 0x1ff]; -+}; -+ -+/* -+ * In the functions below we use some weird looking helper variables to -+ * access most members of this struct, otherwise the compiler splits -+ * the read/write in two byte accesses. -+ */ -+struct ims332_regs { -+ struct _ims332_regs rw; -+ char pad0[0x80000 - sizeof (struct _ims332_regs)]; -+ struct _ims332_regs r; -+ char pad1[0xa0000 - (sizeof (struct _ims332_regs) + 0x80000)]; -+ struct _ims332_regs w; -+} __attribute__((packed)); -+ -+static inline void ims332_control_reg_bits(struct ims332_regs *regs, u32 mask, -+ u32 val) -+{ -+ volatile u16 *ctr = &(regs->r.config_control_a.r); -+ volatile u16 *ctw = &(regs->w.config_control_a.r); -+ u32 ctrl; -+ -+ mb(); -+ ctrl = *ctr; -+ rmb(); -+ ctrl |= ((regs->rw.boot.r << 8) & 0x00ff0000); -+ ctrl |= val & mask; -+ ctrl &= ~(~val & mask); -+ wmb(); -+ regs->rw.boot.r = (ctrl >> 8) & 0xff00; -+ wmb(); -+ *ctw = ctrl & 0xffff; -+} -+ -+/* FIXME: This is maxinefb specific. */ -+static inline void ims332_bootstrap(struct ims332_regs *regs) -+{ -+ volatile u16 *ctw = &(regs->w.config_control_a.r); -+ u32 ctrl = IMS332_CTRL_A_BOOT_ENABLE_VTG | IMS332_CTRL_A_TURN_OFF_DMA; -+ -+ /* bootstrap sequence */ -+ mb(); -+ regs->rw.boot.r = 0; -+ wmb(); -+ *ctw = 0; -+ -+ /* init control A register */ -+ wmb(); -+ regs->rw.boot.r = (ctrl >> 8) & 0xff00; -+ wmb(); -+ *ctw = ctrl & 0xffff; -+} -+ -+static inline void ims332_blank_screen(struct ims332_regs *regs, int blank) -+{ -+ ims332_control_reg_bits(regs, IMS332_CTRL_A_FORCE_BLANKING, -+ blank ? IMS332_CTRL_A_FORCE_BLANKING : 0); -+} -+ -+static inline void ims332_set_color_depth(struct ims332_regs *regs, u32 depth) -+{ -+ u32 dp; -+ u32 mask = (IMS332_CTRL_A_PIXEL_PORT_INTERLEAVING -+ | IMS332_CTRL_A_DELAYED_SAMPLING -+ | IMS332_CTRL_A_BITS_PER_PIXEL); -+ -+ switch (depth) { -+ case 1: dp = 0 << 20; break; -+ case 2: dp = 1 << 20; break; -+ case 4: dp = 2 << 20; break; -+ case 8: dp = 3 << 20; break; -+ case 15: dp = (4 << 20) | IMS332_CTRL_A_PIXEL_PORT_INTERLEAVING; break; -+ case 16: dp = (5 << 20) | IMS332_CTRL_A_PIXEL_PORT_INTERLEAVING; break; -+ default: return; -+ } -+ ims332_control_reg_bits(regs, mask, dp); -+ -+ if (depth <= 8) { -+ volatile u16 *pmask = &(regs->w.pixel_address_mask.r); -+ u32 dm = (1 << depth) - 1; -+ -+ wmb(); -+ regs->rw.boot.r = dm << 8; -+ wmb(); -+ *pmask = dm << 8 | dm; -+ } -+} -+ -+static inline void ims332_set_screen_top(struct ims332_regs *regs, u16 top) -+{ -+ volatile u16 *st = &(regs->w.screen_top.r); -+ -+ mb(); -+ *st = top & 0xffff; -+} -+ -+static inline void ims332_enable_cursor(struct ims332_regs *regs, int on) -+{ -+ ims332_control_reg_bits(regs, IMS332_CTRL_A_CURSOR_DISABLE, -+ on ? 0 : IMS332_CTRL_A_CURSOR_DISABLE); -+} -+ -+static inline void ims332_position_cursor(struct ims332_regs *regs, -+ u16 x, u16 y) -+{ -+ volatile u16 *cp = &(regs->w.cursor_start.r); -+ u32 val = ((x & 0xfff) << 12) | (y & 0xfff); -+ -+ if (x > 2303 || y > 2303) -+ return; -+ -+ mb(); -+ regs->rw.boot.r = (val >> 8) & 0xff00; -+ wmb(); -+ *cp = val & 0xffff; -+} -+ -+static inline void ims332_set_font(struct ims332_regs *regs, u8 fgc, -+ u16 width, u16 height) -+{ -+ volatile u16 *cp0 = &(regs->w.cursor_color_palette0.r); -+ int i; -+ -+ mb(); -+ for (i = 0; i < 0x200; i++) { -+ volatile u16 *cram = &(regs->w.cursor_ram[i].r); -+ -+ if (height << 6 <= i << 3) -+ *cram = 0x0000; -+ else if (width <= i % 8 << 3) -+ *cram = 0x0000; -+ else if (((width >> 3) & 0xffff) > i % 8) -+ *cram = 0x5555; -+ else -+ *cram = 0x5555 & ~(0xffff << (width % 8 << 1)); -+ wmb(); -+ } -+ regs->rw.boot.r = fgc << 8; -+ wmb(); -+ *cp0 = fgc << 8 | fgc; -+} -+ -+static inline void ims332_read_cmap(struct ims332_regs *regs, u8 reg, -+ u8* red, u8* green, u8* blue) -+{ -+ volatile u16 *rptr = &(regs->r.color_palette[reg].r); -+ u16 val; -+ -+ mb(); -+ val = *rptr; -+ *red = val & 0xff; -+ *green = (val >> 8) & 0xff; -+ rmb(); -+ *blue = (regs->rw.boot.r >> 8) & 0xff; -+} -+ -+static inline void ims332_write_cmap(struct ims332_regs *regs, u8 reg, -+ u8 red, u8 green, u8 blue) -+{ -+ volatile u16 *wptr = &(regs->w.color_palette[reg].r); -+ -+ mb(); -+ regs->rw.boot.r = blue << 8; -+ wmb(); -+ *wptr = (green << 8) + red; -+} -+ -+static inline void ims332_dump_regs(struct ims332_regs *regs) -+{ -+ int i; -+ -+ printk(__FUNCTION__); -+ ims332_control_reg_bits(regs, IMS332_CTRL_A_BOOT_ENABLE_VTG, 0); -+ for (i = 0; i < 0x100; i++) { -+ volatile u16 *cpad = (u16 *)((char *)(®s->r) + sizeof(struct _ims332_reg) * i); -+ u32 val; -+ -+ val = *cpad; -+ rmb(); -+ val |= regs->rw.boot.r << 8; -+ rmb(); -+ if (! (i % 8)) -+ printk("\n%02x:", i); -+ printk(" %06x", val); -+ } -+ ims332_control_reg_bits(regs, IMS332_CTRL_A_BOOT_ENABLE_VTG, -+ IMS332_CTRL_A_BOOT_ENABLE_VTG); -+ printk("\n"); -+} ---- a/drivers/video/Makefile -+++ b/drivers/video/Makefile -@@ -87,6 +87,7 @@ obj-$(CONFIG_FB_PMAGB_B) += pma - obj-$(CONFIG_FB_MAXINE) += maxinefb.o - obj-$(CONFIG_FB_TX3912) += tx3912fb.o - obj-$(CONFIG_FB_AU1100) += au1100fb.o fbgen.o -+obj-$(CONFIG_FB_AU1200) += au1200fb.o fbgen.o - obj-$(CONFIG_FB_IT8181) += it8181fb.o fbgen.o - - subdir-$(CONFIG_STI_CONSOLE) += sti ---- a/drivers/video/maxinefb.h -+++ /dev/null -@@ -1,38 +0,0 @@ --/* -- * linux/drivers/video/maxinefb.h -- * -- * DECstation 5000/xx onboard framebuffer support, Copyright (C) 1999 by -- * Michael Engel <engel@unix-ag.org> and Karsten Merker <merker@guug.de> -- * 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 <asm/addrspace.h> -- --/* -- * IMS332 video controller register base address -- */ --#define MAXINEFB_IMS332_ADDRESS KSEG1ADDR(0x1c140000) -- --/* -- * Begin of DECstation 5000/xx onboard framebuffer memory, default resolution -- * is 1024x768x8 -- */ --#define DS5000_xx_ONBOARD_FBMEM_START KSEG1ADDR(0x0a000000) -- --/* -- * The IMS 332 video controller used in the DECstation 5000/xx series -- * uses 32 bits wide registers; the following defines declare the -- * register numbers, to get the real offset, these have to be multiplied -- * by four. -- */ -- --#define IMS332_REG_CURSOR_RAM 0x200 /* hardware cursor bitmap */ -- --/* -- * The color palette entries have the form 0x00BBGGRR -- */ --#define IMS332_REG_COLOR_PALETTE 0x100 /* color palette, 256 entries */ --#define IMS332_REG_CURSOR_COLOR_PALETTE 0x0a1 /* cursor color palette, */ -- /* 3 entries */ ---- a/drivers/video/newport_con.c -+++ b/drivers/video/newport_con.c -@@ -22,6 +22,7 @@ - #include <linux/module.h> - #include <linux/slab.h> - -+#include <asm/io.h> - #include <asm/uaccess.h> - #include <asm/system.h> - #include <asm/page.h> -@@ -77,7 +78,7 @@ static int newport_set_def_font(int unit - static inline void newport_render_background(int xstart, int ystart, - int xend, int yend, int ci) - { -- newport_wait(); -+ newport_wait(npregs); - npregs->set.wrmask = 0xffffffff; - npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK | - NPORT_DMODE0_DOSETUP | NPORT_DMODE0_STOPX -@@ -94,7 +95,7 @@ static inline void newport_init_cmap(voi - unsigned short i; - - for (i = 0; i < 16; i++) { -- newport_bfwait(); -+ newport_bfwait(npregs); - newport_cmap_setaddr(npregs, color_table[i]); - newport_cmap_setrgb(npregs, - default_red[i], -@@ -107,7 +108,7 @@ static inline void newport_show_logo(voi - unsigned long i; - - for (i = 0; i < LINUX_LOGO_COLORS; i++) { -- newport_bfwait(); -+ newport_bfwait(npregs); - newport_cmap_setaddr(npregs, i + 0x20); - newport_cmap_setrgb(npregs, - linux_logo_red[i], -@@ -115,13 +116,13 @@ static inline void newport_show_logo(voi - linux_logo_blue[i]); - } - -- newport_wait(); -+ newport_wait(npregs); - npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK | - NPORT_DMODE0_CHOST); - - npregs->set.xystarti = ((newport_xsize - LOGO_W) << 16) | (0); - npregs->set.xyendi = ((newport_xsize - 1) << 16); -- newport_wait(); -+ newport_wait(npregs); - - for (i = 0; i < LOGO_W * LOGO_H; i++) - npregs->go.hostrw0 = linux_logo[i] << 24; -@@ -133,7 +134,7 @@ static inline void newport_clear_screen( - if (logo_active) - return; - -- newport_wait(); -+ newport_wait(npregs); - npregs->set.wrmask = 0xffffffff; - npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK | - NPORT_DMODE0_DOSETUP | NPORT_DMODE0_STOPX -@@ -155,7 +156,7 @@ void newport_reset(void) - unsigned short treg; - int i; - -- newport_wait(); -+ newport_wait(npregs); - treg = newport_vc2_get(npregs, VC2_IREG_CONTROL); - newport_vc2_set(npregs, VC2_IREG_CONTROL, - (treg | VC2_CTRL_EVIDEO)); -@@ -165,7 +166,7 @@ void newport_reset(void) - npregs->set.dcbmode = (NPORT_DMODE_AVC2 | VC2_REGADDR_RAM | - NPORT_DMODE_W2 | VC2_PROTOCOL); - for (i = 0; i < 128; i++) { -- newport_bfwait(); -+ newport_bfwait(npregs); - if (i == 92 || i == 94) - npregs->set.dcbdata0.byshort.s1 = 0xff00; - else -@@ -205,7 +206,7 @@ void newport_get_screensize(void) - npregs->set.dcbmode = (NPORT_DMODE_AVC2 | VC2_REGADDR_RAM | - NPORT_DMODE_W2 | VC2_PROTOCOL); - for (i = 0; i < 128; i++) { -- newport_bfwait(); -+ newport_bfwait(npregs); - linetable[i] = npregs->set.dcbdata0.byshort.s1; - } - -@@ -216,12 +217,12 @@ void newport_get_screensize(void) - npregs->set.dcbmode = (NPORT_DMODE_AVC2 | VC2_REGADDR_RAM | - NPORT_DMODE_W2 | VC2_PROTOCOL); - do { -- newport_bfwait(); -+ newport_bfwait(npregs); - treg = npregs->set.dcbdata0.byshort.s1; - if ((treg & 1) == 0) - cols += (treg >> 7) & 0xfe; - if ((treg & 0x80) == 0) { -- newport_bfwait(); -+ newport_bfwait(npregs); - treg = npregs->set.dcbdata0.byshort.s1; - } - } while ((treg & 0x8000) == 0); -@@ -291,16 +292,16 @@ static const char *newport_startup(void) - - if (!sgi_gfxaddr) - return NULL; -- npregs = (struct newport_regs *) (KSEG1 + sgi_gfxaddr); -+ npregs = (struct newport_regs *) /* ioremap cannot fail */ -+ ioremap(sgi_gfxaddr, sizeof(struct newport_regs)); - npregs->cset.config = NPORT_CFG_GD0; - -- if (newport_wait()) { -- return NULL; -- } -+ if (newport_wait(npregs)) -+ goto out_unmap; - - npregs->set.xstarti = TESTVAL; - if (npregs->set._xstart.word != XSTI_TO_FXSTART(TESTVAL)) -- return NULL; -+ goto out_unmap; - - for (i = 0; i < MAX_NR_CONSOLES; i++) - font_data[i] = FONT_DATA; -@@ -310,6 +311,10 @@ static const char *newport_startup(void) - newport_get_screensize(); - - return "SGI Newport"; -+ -+out_unmap: -+ iounmap((void *)npregs); -+ return NULL; - } - - static void newport_init(struct vc_data *vc, int init) -@@ -363,7 +368,7 @@ static void newport_putc(struct vc_data - (charattr & 0xf0) >> 4); - - /* Set the color and drawing mode. */ -- newport_wait(); -+ newport_wait(npregs); - npregs->set.colori = charattr & 0xf; - npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK | - NPORT_DMODE0_STOPX | NPORT_DMODE0_ZPENAB | -@@ -372,7 +377,7 @@ static void newport_putc(struct vc_data - /* Set coordinates for bitmap operation. */ - npregs->set.xystarti = (xpos << 16) | ((ypos + topscan) & 0x3ff); - npregs->set.xyendi = ((xpos + 7) << 16); -- newport_wait(); -+ newport_wait(npregs); - - /* Go, baby, go... */ - RENDER(npregs, p); -@@ -396,7 +401,7 @@ static void newport_putcs(struct vc_data - xpos + ((count - 1) << 3), ypos, - (charattr & 0xf0) >> 4); - -- newport_wait(); -+ newport_wait(npregs); - - /* Set the color and drawing mode. */ - npregs->set.colori = charattr & 0xf; -@@ -407,7 +412,7 @@ static void newport_putcs(struct vc_data - for (i = 0; i < count; i++, xpos += 8) { - p = &font_data[vc->vc_num][(scr_readw(s++) & 0xff) << 4]; - -- newport_wait(); -+ newport_wait(npregs); - - /* Set coordinates for bitmap operation. */ - npregs->set.xystarti = -@@ -689,7 +694,7 @@ static void newport_bmove(struct vc_data - xe = xs; - xs = tmp; - } -- newport_wait(); -+ newport_wait(npregs); - npregs->set.drawmode0 = (NPORT_DMODE0_S2S | NPORT_DMODE0_BLOCK | - NPORT_DMODE0_DOSETUP | NPORT_DMODE0_STOPX - | NPORT_DMODE0_STOPY); -@@ -706,35 +711,35 @@ static int newport_dummy(struct vc_data - #define DUMMY (void *) newport_dummy - - const struct consw newport_con = { -- con_startup: newport_startup, -- con_init: newport_init, -- con_deinit: newport_deinit, -- con_clear: newport_clear, -- con_putc: newport_putc, -- con_putcs: newport_putcs, -- con_cursor: newport_cursor, -- con_scroll: newport_scroll, -- con_bmove: newport_bmove, -- con_switch: newport_switch, -- con_blank: newport_blank, -- con_font_op: newport_font_op, -- con_set_palette: newport_set_palette, -- con_scrolldelta: newport_scrolldelta, -- con_set_origin: DUMMY, -- con_save_screen: DUMMY -+ .con_startup = newport_startup, -+ .con_init = newport_init, -+ .con_deinit = newport_deinit, -+ .con_clear = newport_clear, -+ .con_putc = newport_putc, -+ .con_putcs = newport_putcs, -+ .con_cursor = newport_cursor, -+ .con_scroll = newport_scroll, -+ .con_bmove = newport_bmove, -+ .con_switch = newport_switch, -+ .con_blank = newport_blank, -+ .con_font_op = newport_font_op, -+ .con_set_palette = newport_set_palette, -+ .con_scrolldelta = newport_scrolldelta, -+ .con_set_origin = DUMMY, -+ .con_save_screen = DUMMY - }; - - #ifdef MODULE - static int __init newport_console_init(void) - { - take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1); -- - return 0; - } - - static void __exit newport_console_exit(void) - { - give_up_console(&newport_con); -+ iounmap((void *)npregs); - } - - module_init(newport_console_init); ---- a/drivers/video/tgafb.c -+++ b/drivers/video/tgafb.c -@@ -45,6 +45,15 @@ - #include <linux/console.h> - #include <asm/io.h> - -+#ifdef CONFIG_TC -+#include <asm/dec/tc.h> -+#else -+static int search_tc_card(const char *) { return -1; } -+static void claim_tc_card(int) { } -+static void release_tc_card(int) { } -+static unsigned long get_tc_base_addr(int) { return 0; } -+#endif -+ - #include <video/fbcon.h> - #include <video/fbcon-cfb8.h> - #include <video/fbcon-cfb32.h> -@@ -84,10 +93,10 @@ static unsigned int fb_offset_presets[4] - }; - - static unsigned int deep_presets[4] = { -- 0x00014000, -- 0x0001440d, -+ 0x00004000, -+ 0x0000440d, - 0xffffffff, -- 0x0001441d -+ 0x0000441d - }; - - static unsigned int rasterop_presets[4] = { -@@ -131,6 +140,13 @@ static struct { - 0, - FB_VMODE_NONINTERLACED - }}, -+ { "1280x1024-72", { /* mode #0 of PMAGD boards */ -+ 1280, 1024, 1280, 1024, 0, 0, 0, 0, -+ {0, 8, 0}, {0, 8, 0}, {0, 8, 0}, {0, 0, 0}, -+ 0, 0, -1, -1, FB_ACCELF_TEXT, 7692, 232, 32, 34, 3, 160, 3, -+ FB_SYNC_ON_GREEN, -+ FB_VMODE_NONINTERLACED -+ }}, - { "800x600-56", { - 800, 600, 800, 600, 0, 0, 0, 0, - {0, 8, 0}, {0, 8, 0}, {0, 8, 0}, {0, 0, 0}, -@@ -488,7 +504,8 @@ static void tgafb_set_par(const void *fb - continue; - - mb(); -- TGA_WRITE_REG(deep_presets[fb_info.tga_type], TGA_DEEP_REG); -+ TGA_WRITE_REG(deep_presets[fb_info.tga_type] | -+ (par->sync_on_green ? 0x0 : 0x00010000), TGA_DEEP_REG); - while (TGA_READ_REG(TGA_CMD_STAT_REG) & 1) /* wait for not busy */ - continue; - mb(); -@@ -548,7 +565,7 @@ static void tgafb_set_par(const void *fb - BT463_WRITE(BT463_REG_ACC, BT463_CMD_REG_0, 0x40); - BT463_WRITE(BT463_REG_ACC, BT463_CMD_REG_1, 0x08); - BT463_WRITE(BT463_REG_ACC, BT463_CMD_REG_2, -- (par->sync_on_green ? 0x80 : 0x40)); -+ (par->sync_on_green ? 0xc0 : 0x40)); - - BT463_WRITE(BT463_REG_ACC, BT463_READ_MASK_0, 0xff); - BT463_WRITE(BT463_REG_ACC, BT463_READ_MASK_1, 0xff); -@@ -921,19 +938,34 @@ int __init tgafb_setup(char *options) { - int __init tgafb_init(void) - { - struct pci_dev *pdev; -+ int slot; - - pdev = pci_find_device(PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TGA, NULL); - if (!pdev) -+ slot = search_tc_card("PMAGD"); -+ if (!pdev && slot < 0) - return -ENXIO; - - /* divine board type */ - -- fb_info.tga_mem_base = (unsigned long)ioremap(pdev->resource[0].start, 0); -- fb_info.tga_type = (readl(fb_info.tga_mem_base) >> 12) & 0x0f; -- fb_info.tga_regs_base = fb_info.tga_mem_base + TGA_REGS_OFFSET; -- fb_info.tga_fb_base = (fb_info.tga_mem_base -+ if (pdev) { -+ fb_info.tga_mem_base = (unsigned long)ioremap(pdev->resource[0].start, -+ 0); -+ fb_info.tga_type = (readl(fb_info.tga_mem_base) >> 12) & 0x0f; -+ fb_info.tga_regs_base = fb_info.tga_mem_base + TGA_REGS_OFFSET; -+ fb_info.tga_fb_base = (fb_info.tga_mem_base - + fb_offset_presets[fb_info.tga_type]); -- pci_read_config_byte(pdev, PCI_REVISION_ID, &fb_info.tga_chip_rev); -+ pci_read_config_byte(pdev, PCI_REVISION_ID, &fb_info.tga_chip_rev); -+ -+ } else { -+ claim_tc_card(slot); -+ fb_info.tga_mem_base = get_tc_base_addr(slot); -+ fb_info.tga_type = (readl(fb_info.tga_mem_base) >> 12) & 0x0f; /* ? */ -+ fb_info.tga_regs_base = fb_info.tga_mem_base + TGA_REGS_OFFSET; -+ fb_info.tga_fb_base = (fb_info.tga_mem_base -+ + fb_offset_presets[fb_info.tga_type]); -+ fb_info.tga_chip_rev = TGA_READ_REG(TGA_START_REG) & 0xff; -+ } - - /* setup framebuffer */ - -@@ -950,40 +982,62 @@ int __init tgafb_init(void) - fb_info.gen.fbhw = &tgafb_hwswitch; - fb_info.gen.fbhw->detect(); - -- printk (KERN_INFO "tgafb: DC21030 [TGA] detected, rev=0x%02x\n", fb_info.tga_chip_rev); -- printk (KERN_INFO "tgafb: at PCI bus %d, device %d, function %d\n", -- pdev->bus->number, PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); -+ if (pdev) { -+ printk (KERN_INFO "tgafb: DC21030 [TGA] detected, rev=0x%02x\n", -+ fb_info.tga_chip_rev); -+ printk (KERN_INFO "tgafb: at PCI bus %d, device %d, function %d\n", -+ pdev->bus->number, -+ PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); -+ } else { -+ printk (KERN_INFO "tgafb: SFB+ detected, rev=0x%02x\n", -+ fb_info.tga_chip_rev); -+ } - - switch (fb_info.tga_type) - { - case TGA_TYPE_8PLANE: -- strcpy (fb_info.gen.info.modename,"Digital ZLXp-E1"); -+ if (pdev) -+ strcpy (fb_info.gen.info.modename,"Digital ZLXp-E1"); -+ else -+ strcpy (fb_info.gen.info.modename,"Digital ZLX-E1"); - break; - - case TGA_TYPE_24PLANE: -- strcpy (fb_info.gen.info.modename,"Digital ZLXp-E2"); -+ if (pdev) -+ strcpy (fb_info.gen.info.modename,"Digital ZLXp-E2"); -+ else -+ strcpy (fb_info.gen.info.modename,"Digital ZLX-E2"); - break; - - case TGA_TYPE_24PLUSZ: -- strcpy (fb_info.gen.info.modename,"Digital ZLXp-E3"); -+ if (pdev) -+ strcpy (fb_info.gen.info.modename,"Digital ZLXp-E3"); -+ else -+ strcpy (fb_info.gen.info.modename,"Digital ZLX-E3"); - break; - } - - /* This should give a reasonable default video mode */ - - if (!default_var_valid) { -- default_var = tgafb_predefined[0].var; -+ if (pdev) -+ default_var = tgafb_predefined[0].var; -+ else -+ default_var = tgafb_predefined[1].var; - } - fbgen_get_var(&disp.var, -1, &fb_info.gen.info); - disp.var.activate = FB_ACTIVATE_NOW; - fbgen_do_set_var(&disp.var, 1, &fb_info.gen); - fbgen_set_disp(-1, &fb_info.gen); - fbgen_install_cmap(0, &fb_info.gen); -- if (register_framebuffer(&fb_info.gen.info) < 0) -+ if (register_framebuffer(&fb_info.gen.info) < 0) { -+ if (slot >= 0) -+ release_tc_card(slot); - return -EINVAL; -- printk(KERN_INFO "fb%d: %s frame buffer device at 0x%lx\n", -+ } -+ printk(KERN_INFO "fb%d: %s frame buffer device at 0x%llx\n", - GET_FB_IDX(fb_info.gen.info.node), fb_info.gen.info.modename, -- pdev->resource[0].start); -+ fb_info.tga_mem_base); - return 0; - } - ---- a/drivers/video/tgafb.h -+++ b/drivers/video/tgafb.h -@@ -36,6 +36,7 @@ - #define TGA_RASTEROP_REG 0x0034 - #define TGA_PIXELSHIFT_REG 0x0038 - #define TGA_DEEP_REG 0x0050 -+#define TGA_START_REG 0x0054 - #define TGA_PIXELMASK_REG 0x005c - #define TGA_CURSOR_BASE_REG 0x0060 - #define TGA_HORIZ_REG 0x0064 ---- a/fs/binfmt_elf.c -+++ b/fs/binfmt_elf.c -@@ -665,6 +665,9 @@ static int load_elf_binary(struct linux_ - bprm->argc++; - } - } -+ } else { -+ /* Executables without an interpreter also need a personality */ -+ SET_PERSONALITY(elf_ex, ibcs2_interpreter); - } - - /* Flush all traces of the currently running executable */ -@@ -1225,7 +1228,11 @@ static int elf_core_dump(long signr, str - elf.e_entry = 0; - elf.e_phoff = sizeof(elf); - elf.e_shoff = 0; -+#ifdef ELF_CORE_EFLAGS -+ elf.e_flags = ELF_CORE_EFLAGS; -+#else - elf.e_flags = 0; -+#endif - elf.e_ehsize = sizeof(elf); - elf.e_phentsize = sizeof(struct elf_phdr); - elf.e_phnum = segs+1; /* Include notes */ ---- a/fs/partitions/sgi.c -+++ b/fs/partitions/sgi.c -@@ -17,6 +17,11 @@ - #include "check.h" - #include "sgi.h" - -+#if CONFIG_BLK_DEV_MD -+extern void md_autodetect_dev(kdev_t dev); -+#endif -+ -+ - int sgi_partition(struct gendisk *hd, struct block_device *bdev, unsigned long first_sector, int current_minor) - { - int i, csum, magic; -@@ -77,6 +82,10 @@ int sgi_partition(struct gendisk *hd, st - if(!blocks) - continue; - add_gd_partition(hd, current_minor, start, blocks); -+#ifdef CONFIG_BLK_DEV_MD -+ if (be32_to_cpu(p->type) == LINUX_RAID_PARTITION) -+ md_autodetect_dev(MKDEV(hd->major, current_minor)); -+#endif - current_minor++; - } - printk("\n"); ---- a/fs/proc/array.c -+++ b/fs/proc/array.c -@@ -376,15 +376,15 @@ int proc_pid_stat(struct task_struct *ta - task->cmin_flt, - task->maj_flt, - task->cmaj_flt, -- task->times.tms_utime, -- task->times.tms_stime, -- task->times.tms_cutime, -- task->times.tms_cstime, -+ hz_to_std(task->times.tms_utime), -+ hz_to_std(task->times.tms_stime), -+ hz_to_std(task->times.tms_cutime), -+ hz_to_std(task->times.tms_cstime), - priority, - nice, - 0UL /* removed */, - task->it_real_value, -- task->start_time, -+ hz_to_std(task->start_time), - vsize, - mm ? mm->rss : 0, /* you might want to shift this left 3 */ - task->rlim[RLIMIT_RSS].rlim_cur, -@@ -629,14 +629,14 @@ int proc_pid_cpu(struct task_struct *tas - - len = sprintf(buffer, - "cpu %lu %lu\n", -- task->times.tms_utime, -- task->times.tms_stime); -+ hz_to_std(task->times.tms_utime), -+ hz_to_std(task->times.tms_stime)); - - for (i = 0 ; i < smp_num_cpus; i++) - len += sprintf(buffer + len, "cpu%d %lu %lu\n", - i, -- task->per_cpu_utime[cpu_logical_map(i)], -- task->per_cpu_stime[cpu_logical_map(i)]); -+ hz_to_std(task->per_cpu_utime[cpu_logical_map(i)]), -+ hz_to_std(task->per_cpu_stime[cpu_logical_map(i)])); - - return len; - } ---- a/fs/proc/proc_misc.c -+++ b/fs/proc/proc_misc.c -@@ -308,16 +308,16 @@ static int kstat_read_proc(char *page, c - { - int i, len = 0; - extern unsigned long total_forks; -- unsigned long jif = jiffies; -+ unsigned long jif = hz_to_std(jiffies); - unsigned int sum = 0, user = 0, nice = 0, system = 0; - int major, disk; - - for (i = 0 ; i < smp_num_cpus; i++) { - int cpu = cpu_logical_map(i), j; - -- user += kstat.per_cpu_user[cpu]; -- nice += kstat.per_cpu_nice[cpu]; -- system += kstat.per_cpu_system[cpu]; -+ user += hz_to_std(kstat.per_cpu_user[cpu]); -+ nice += hz_to_std(kstat.per_cpu_nice[cpu]); -+ system += hz_to_std(kstat.per_cpu_system[cpu]); - #if !defined(CONFIG_ARCH_S390) - for (j = 0 ; j < NR_IRQS ; j++) - sum += kstat.irqs[cpu][j]; -@@ -331,10 +331,10 @@ static int kstat_read_proc(char *page, c - proc_sprintf(page, &off, &len, - "cpu%d %u %u %u %lu\n", - i, -- kstat.per_cpu_user[cpu_logical_map(i)], -- kstat.per_cpu_nice[cpu_logical_map(i)], -- kstat.per_cpu_system[cpu_logical_map(i)], -- jif - ( kstat.per_cpu_user[cpu_logical_map(i)] \ -+ hz_to_std(kstat.per_cpu_user[cpu_logical_map(i)]), -+ hz_to_std(kstat.per_cpu_nice[cpu_logical_map(i)]), -+ hz_to_std(kstat.per_cpu_system[cpu_logical_map(i)]), -+ jif - hz_to_std( kstat.per_cpu_user[cpu_logical_map(i)] \ - + kstat.per_cpu_nice[cpu_logical_map(i)] \ - + kstat.per_cpu_system[cpu_logical_map(i)])); - proc_sprintf(page, &off, &len, ---- a/include/asm-alpha/param.h -+++ b/include/asm-alpha/param.h -@@ -13,6 +13,9 @@ - # else - # define HZ 1200 - # endif -+#ifdef __KERNEL__ -+# define hz_to_std(a) (a) -+#endif - #endif - - #define EXEC_PAGESIZE 8192 ---- a/include/asm-i386/param.h -+++ b/include/asm-i386/param.h -@@ -3,6 +3,9 @@ - - #ifndef HZ - #define HZ 100 -+#ifdef __KERNEL__ -+#define hz_to_std(a) (a) -+#endif - #endif - - #define EXEC_PAGESIZE 4096 ---- a/include/asm-ia64/param.h -+++ b/include/asm-ia64/param.h -@@ -7,9 +7,15 @@ - * Based on <asm-i386/param.h>. - * - * Modified 1998, 1999, 2002-2003 -- * David Mosberger-Tang <davidm@hpl.hp.com>, Hewlett-Packard Co -+ * David Mosberger-Tang <davidm@hpl.hp.com>, Hewlett-Packard Co - */ - -+#include <linux/config.h> -+ -+#ifdef __KERNEL__ -+#define hz_to_std(a) (a) -+#endif -+ - #define EXEC_PAGESIZE 65536 - - #ifndef NGROUPS ---- a/include/asm-m68k/param.h -+++ b/include/asm-m68k/param.h -@@ -3,6 +3,9 @@ - - #ifndef HZ - #define HZ 100 -+#ifdef __KERNEL__ -+#define hz_to_std(a) (a) -+#endif - #endif - - #define EXEC_PAGESIZE 8192 ---- a/include/asm-mips/au1000_gpio.h -+++ b/include/asm-mips/au1000_gpio.h -@@ -30,6 +30,13 @@ - * 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -+/* -+ * Revision history -+ * 01/31/02 0.01 Initial release. Steve Longerbeam, MontaVista -+ * 10/12/03 0.1 Added Au1100/Au1500, GPIO2, and bit operations. K.C. Nishio, AMD -+ * 08/05/04 0.11 Added Au1550 and Au1200. K.C. Nishio -+ */ -+ - #ifndef __AU1000_GPIO_H - #define __AU1000_GPIO_H - -@@ -44,13 +51,94 @@ - #define AU1000GPIO_TRISTATE _IOW (AU1000GPIO_IOC_MAGIC, 4, int) - #define AU1000GPIO_AVAIL_MASK _IOR (AU1000GPIO_IOC_MAGIC, 5, int) - -+// bit operations -+#define AU1000GPIO_BIT_READ _IOW (AU1000GPIO_IOC_MAGIC, 6, int) -+#define AU1000GPIO_BIT_SET _IOW (AU1000GPIO_IOC_MAGIC, 7, int) -+#define AU1000GPIO_BIT_CLEAR _IOW (AU1000GPIO_IOC_MAGIC, 8, int) -+#define AU1000GPIO_BIT_TRISTATE _IOW (AU1000GPIO_IOC_MAGIC, 9, int) -+#define AU1000GPIO_BIT_INIT _IOW (AU1000GPIO_IOC_MAGIC, 10, int) -+#define AU1000GPIO_BIT_TERM _IOW (AU1000GPIO_IOC_MAGIC, 11, int) -+ -+/* set this major numer same as the CRIS GPIO driver */ -+#define AU1X00_GPIO_MAJOR (120) -+ -+#define ENABLED_ZERO (0) -+#define ENABLED_ONE (1) -+#define ENABLED_10 (0x2) -+#define ENABLED_11 (0x3) -+#define ENABLED_111 (0x7) -+#define NOT_AVAIL (-1) -+#define AU1X00_MAX_PRIMARY_GPIO (32) -+ -+#define AU1000_GPIO_MINOR_MAX AU1X00_MAX_PRIMARY_GPIO -+/* Au1100, 1500, 1550 and 1200 have the secondary GPIO block */ -+#define AU1XX0_GPIO_MINOR_MAX (48) -+ -+#define AU1X00_GPIO_NAME "gpio" -+ -+/* GPIO pins which are not multiplexed */ -+#if defined(CONFIG_SOC_AU1000) -+ #define NATIVE_GPIOPIN ((1 << 15) | (1 << 8) | (1 << 7) | (1 << 1) | (1 << 0)) -+ #define NATIVE_GPIO2PIN (0) -+#elif defined(CONFIG_SOC_AU1100) -+ #define NATIVE_GPIOPIN ((1 << 23) | (1 << 22) | (1 << 21) | (1 << 20) | (1 << 19) | (1 << 18) | \ -+ (1 << 17) | (1 << 16) | (1 << 7) | (1 << 1) | (1 << 0)) -+ #define NATIVE_GPIO2PIN (0) -+#elif defined(CONFIG_SOC_AU1500) -+ #define NATIVE_GPIOPIN ((1 << 15) | (1 << 8) | (1 << 7) | (1 << 1) | (1 << 0)) -+ /* exclude the PCI reset output signal: GPIO[200], DMA_REQ2 and DMA_REQ3 */ -+ #define NATIVE_GPIO2PIN (0xfffe & ~((1 << 9) | (1 << 8))) -+#elif defined(CONFIG_SOC_AU1550) -+ #define NATIVE_GPIOPIN ((1 << 15) | (1 << 8) | (1 << 7) | (1 << 6) | (1 << 1) | (1 << 0)) -+ /* please refere Au1550 Data Book, chapter 15 */ -+ #define NATIVE_GPIO2PIN (1 << 5) -+#elif defined(CONFIG_SOC_AU1200) -+ #define NATIVE_GPIOPIN ((1 << 7) | (1 << 5)) -+ #define NATIVE_GPIO2PIN (0) -+#endif -+ -+/* minor as u32 */ -+#define MINOR_TO_GPIOPIN(minor) ((minor < AU1X00_MAX_PRIMARY_GPIO) ? minor : (minor - AU1X00_MAX_PRIMARY_GPIO)) -+#define IS_PRIMARY_GPIOPIN(minor) ((minor < AU1X00_MAX_PRIMARY_GPIO) ? 1 : 0) -+ -+/* -+ * pin to minor mapping. -+ * GPIO0-GPIO31, minor=0-31. -+ * GPIO200-GPIO215, minor=32-47. -+ */ -+typedef struct _au1x00_gpio_bit_ctl { -+ int direction; // The direction of this GPIO pin. 0: IN, 1: OUT. -+ int data; // Pin output when itized (0/1), or at the term. 0/1/-1 (tristate). -+} au1x00_gpio_bit_ctl; -+ -+typedef struct _au1x00_gpio_driver { -+ const char *driver_name; -+ const char *name; -+ int name_base; /* offset of printed name */ -+ short major; /* major device number */ -+ short minor_start; /* start of minor device number*/ -+ short num; /* number of devices */ -+} au1x00_gpio_driver; -+ - #ifdef __KERNEL__ --extern u32 get_au1000_avail_gpio_mask(void); --extern int au1000gpio_tristate(u32 data); --extern int au1000gpio_in(u32 *data); --extern int au1000gpio_set(u32 data); --extern int au1000gpio_clear(u32 data); --extern int au1000gpio_out(u32 data); -+extern u32 get_au1000_avail_gpio_mask(u32 *avail_gpio2); -+extern int au1000gpio_tristate(u32 minor, u32 data); -+extern int au1000gpio_in(u32 minor, u32 *data); -+extern int au1000gpio_set(u32 minor, u32 data); -+extern int au1000gpio_clear(u32 minor, u32 data); -+extern int au1000gpio_out(u32 minor, u32 data); -+extern int au1000gpio_bit_read(u32 minor, u32 *read_data); -+extern int au1000gpio_bit_set(u32 minor); -+extern int au1000gpio_bit_clear(u32 minor); -+extern int au1000gpio_bit_tristate(u32 minor); -+extern int check_minor_to_gpio(u32 minor); -+extern int au1000gpio_bit_init(u32 minor, au1x00_gpio_bit_ctl *bit_opt); -+extern int au1000gpio_bit_term(u32 minor, au1x00_gpio_bit_ctl *bit_opt); -+ -+extern void gpio_register_devfs (au1x00_gpio_driver *driver, unsigned int flags, unsigned minor); -+extern void gpio_unregister_devfs (au1x00_gpio_driver *driver, unsigned minor); -+extern int gpio_register_driver(au1x00_gpio_driver *driver); -+extern int gpio_unregister_driver(au1x00_gpio_driver *driver); - #endif - - #endif ---- a/include/asm-mips/au1000.h -+++ b/include/asm-mips/au1000.h -@@ -160,28 +160,356 @@ extern au1xxx_irq_map_t au1xxx_irq_map[] - #define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5) - #endif - --/* SDRAM Controller */ -+/* -+ * SDRAM Register Offsets -+ */ - #if defined(CONFIG_SOC_AU1000) || defined(CONFIG_SOC_AU1500) || defined(CONFIG_SOC_AU1100) --#define MEM_SDMODE0 0xB4000000 --#define MEM_SDMODE1 0xB4000004 --#define MEM_SDMODE2 0xB4000008 -- --#define MEM_SDADDR0 0xB400000C --#define MEM_SDADDR1 0xB4000010 --#define MEM_SDADDR2 0xB4000014 -- --#define MEM_SDREFCFG 0xB4000018 --#define MEM_SDPRECMD 0xB400001C --#define MEM_SDAUTOREF 0xB4000020 -- --#define MEM_SDWRMD0 0xB4000024 --#define MEM_SDWRMD1 0xB4000028 --#define MEM_SDWRMD2 0xB400002C -+#define MEM_SDMODE0 (0x0000) -+#define MEM_SDMODE1 (0x0004) -+#define MEM_SDMODE2 (0x0008) -+#define MEM_SDADDR0 (0x000C) -+#define MEM_SDADDR1 (0x0010) -+#define MEM_SDADDR2 (0x0014) -+#define MEM_SDREFCFG (0x0018) -+#define MEM_SDPRECMD (0x001C) -+#define MEM_SDAUTOREF (0x0020) -+#define MEM_SDWRMD0 (0x0024) -+#define MEM_SDWRMD1 (0x0028) -+#define MEM_SDWRMD2 (0x002C) -+#define MEM_SDSLEEP (0x0030) -+#define MEM_SDSMCKE (0x0034) -+ -+#ifndef ASSEMBLER -+/*typedef volatile struct -+{ -+ uint32 sdmode0; -+ uint32 sdmode1; -+ uint32 sdmode2; -+ uint32 sdaddr0; -+ uint32 sdaddr1; -+ uint32 sdaddr2; -+ uint32 sdrefcfg; -+ uint32 sdautoref; -+ uint32 sdwrmd0; -+ uint32 sdwrmd1; -+ uint32 sdwrmd2; -+ uint32 sdsleep; -+ uint32 sdsmcke; -+ -+} AU1X00_SDRAM;*/ -+#endif -+ -+/* -+ * MEM_SDMODE register content definitions -+ */ -+#define MEM_SDMODE_F (1<<22) -+#define MEM_SDMODE_SR (1<<21) -+#define MEM_SDMODE_BS (1<<20) -+#define MEM_SDMODE_RS (3<<18) -+#define MEM_SDMODE_CS (7<<15) -+#define MEM_SDMODE_TRAS (15<<11) -+#define MEM_SDMODE_TMRD (3<<9) -+#define MEM_SDMODE_TWR (3<<7) -+#define MEM_SDMODE_TRP (3<<5) -+#define MEM_SDMODE_TRCD (3<<3) -+#define MEM_SDMODE_TCL (7<<0) -+ -+#define MEM_SDMODE_BS_2Bank (0<<20) -+#define MEM_SDMODE_BS_4Bank (1<<20) -+#define MEM_SDMODE_RS_11Row (0<<18) -+#define MEM_SDMODE_RS_12Row (1<<18) -+#define MEM_SDMODE_RS_13Row (2<<18) -+#define MEM_SDMODE_RS_N(N) ((N)<<18) -+#define MEM_SDMODE_CS_7Col (0<<15) -+#define MEM_SDMODE_CS_8Col (1<<15) -+#define MEM_SDMODE_CS_9Col (2<<15) -+#define MEM_SDMODE_CS_10Col (3<<15) -+#define MEM_SDMODE_CS_11Col (4<<15) -+#define MEM_SDMODE_CS_N(N) ((N)<<15) -+#define MEM_SDMODE_TRAS_N(N) ((N)<<11) -+#define MEM_SDMODE_TMRD_N(N) ((N)<<9) -+#define MEM_SDMODE_TWR_N(N) ((N)<<7) -+#define MEM_SDMODE_TRP_N(N) ((N)<<5) -+#define MEM_SDMODE_TRCD_N(N) ((N)<<3) -+#define MEM_SDMODE_TCL_N(N) ((N)<<0) -+ -+/* -+ * MEM_SDADDR register contents definitions -+ */ -+#define MEM_SDADDR_E (1<<20) -+#define MEM_SDADDR_CSBA (0x03FF<<10) -+#define MEM_SDADDR_CSMASK (0x03FF<<0) -+#define MEM_SDADDR_CSBA_N(N) ((N)&(0x03FF<<22)>>12) -+#define MEM_SDADDR_CSMASK_N(N) ((N)&(0x03FF<<22)>>22) -+ -+/* -+ * MEM_SDREFCFG register content definitions -+ */ -+#define MEM_SDREFCFG_TRC (15<<28) -+#define MEM_SDREFCFG_TRPM (3<<26) -+#define MEM_SDREFCFG_E (1<<25) -+#define MEM_SDREFCFG_RE (0x1ffffff<<0) -+#define MEM_SDREFCFG_TRC_N(N) ((N)<<MEM_SDREFCFG_TRC) -+#define MEM_SDREFCFG_TRPM_N(N) ((N)<<MEM_SDREFCFG_TRPM) -+#define MEM_SDREFCFG_REF_N(N) (N) -+#endif -+ -+/***********************************************************************/ -+ -+/* -+ * Au1550 SDRAM Register Offsets -+ */ -+ -+/***********************************************************************/ -+ -+#if defined(CONFIG_SOC_AU1550) || defined(CONFIG_SOC_AU1200) -+#define MEM_SDMODE0 (0x0800) -+#define MEM_SDMODE1 (0x0808) -+#define MEM_SDMODE2 (0x0810) -+#define MEM_SDADDR0 (0x0820) -+#define MEM_SDADDR1 (0x0828) -+#define MEM_SDADDR2 (0x0830) -+#define MEM_SDCONFIGA (0x0840) -+#define MEM_SDCONFIGB (0x0848) -+#define MEM_SDSTAT (0x0850) -+#define MEM_SDERRADDR (0x0858) -+#define MEM_SDSTRIDE0 (0x0860) -+#define MEM_SDSTRIDE1 (0x0868) -+#define MEM_SDSTRIDE2 (0x0870) -+#define MEM_SDWRMD0 (0x0880) -+#define MEM_SDWRMD1 (0x0888) -+#define MEM_SDWRMD2 (0x0890) -+#define MEM_SDPRECMD (0x08C0) -+#define MEM_SDAUTOREF (0x08C8) -+#define MEM_SDSREF (0x08D0) -+#define MEM_SDSLEEP MEM_SDSREF -+ -+#ifndef ASSEMBLER -+/*typedef volatile struct -+{ -+ uint32 sdmode0; -+ uint32 reserved0; -+ uint32 sdmode1; -+ uint32 reserved1; -+ uint32 sdmode2; -+ uint32 reserved2[3]; -+ uint32 sdaddr0; -+ uint32 reserved3; -+ uint32 sdaddr1; -+ uint32 reserved4; -+ uint32 sdaddr2; -+ uint32 reserved5[3]; -+ uint32 sdconfiga; -+ uint32 reserved6; -+ uint32 sdconfigb; -+ uint32 reserved7; -+ uint32 sdstat; -+ uint32 reserved8; -+ uint32 sderraddr; -+ uint32 reserved9; -+ uint32 sdstride0; -+ uint32 reserved10; -+ uint32 sdstride1; -+ uint32 reserved11; -+ uint32 sdstride2; -+ uint32 reserved12[3]; -+ uint32 sdwrmd0; -+ uint32 reserved13; -+ uint32 sdwrmd1; -+ uint32 reserved14; -+ uint32 sdwrmd2; -+ uint32 reserved15[11]; -+ uint32 sdprecmd; -+ uint32 reserved16; -+ uint32 sdautoref; -+ uint32 reserved17; -+ uint32 sdsref; -+ -+} AU1550_SDRAM;*/ -+#endif -+#endif -+ -+/* -+ * Physical base addresses for integrated peripherals -+ */ -+ -+#ifdef CONFIG_SOC_AU1000 -+#define MEM_PHYS_ADDR 0x14000000 -+#define STATIC_MEM_PHYS_ADDR 0x14001000 -+#define DMA0_PHYS_ADDR 0x14002000 -+#define DMA1_PHYS_ADDR 0x14002100 -+#define DMA2_PHYS_ADDR 0x14002200 -+#define DMA3_PHYS_ADDR 0x14002300 -+#define DMA4_PHYS_ADDR 0x14002400 -+#define DMA5_PHYS_ADDR 0x14002500 -+#define DMA6_PHYS_ADDR 0x14002600 -+#define DMA7_PHYS_ADDR 0x14002700 -+#define IC0_PHYS_ADDR 0x10400000 -+#define IC1_PHYS_ADDR 0x11800000 -+#define AC97_PHYS_ADDR 0x10000000 -+#define USBH_PHYS_ADDR 0x10100000 -+#define USBD_PHYS_ADDR 0x10200000 -+#define IRDA_PHYS_ADDR 0x10300000 -+#define MAC0_PHYS_ADDR 0x10500000 -+#define MAC1_PHYS_ADDR 0x10510000 -+#define MACEN_PHYS_ADDR 0x10520000 -+#define MACDMA0_PHYS_ADDR 0x14004000 -+#define MACDMA1_PHYS_ADDR 0x14004200 -+#define I2S_PHYS_ADDR 0x11000000 -+#define UART0_PHYS_ADDR 0x11100000 -+#define UART1_PHYS_ADDR 0x11200000 -+#define UART2_PHYS_ADDR 0x11300000 -+#define UART3_PHYS_ADDR 0x11400000 -+#define SSI0_PHYS_ADDR 0x11600000 -+#define SSI1_PHYS_ADDR 0x11680000 -+#define SYS_PHYS_ADDR 0x11900000 -+#define PCMCIA_IO_PHYS_ADDR 0xF00000000 -+#define PCMCIA_ATTR_PHYS_ADDR 0xF40000000 -+#define PCMCIA_MEM_PHYS_ADDR 0xF80000000 -+#endif -+ -+/********************************************************************/ - --#define MEM_SDSLEEP 0xB4000030 --#define MEM_SDSMCKE 0xB4000034 -+#ifdef CONFIG_SOC_AU1500 -+#define MEM_PHYS_ADDR 0x14000000 -+#define STATIC_MEM_PHYS_ADDR 0x14001000 -+#define DMA0_PHYS_ADDR 0x14002000 -+#define DMA1_PHYS_ADDR 0x14002100 -+#define DMA2_PHYS_ADDR 0x14002200 -+#define DMA3_PHYS_ADDR 0x14002300 -+#define DMA4_PHYS_ADDR 0x14002400 -+#define DMA5_PHYS_ADDR 0x14002500 -+#define DMA6_PHYS_ADDR 0x14002600 -+#define DMA7_PHYS_ADDR 0x14002700 -+#define IC0_PHYS_ADDR 0x10400000 -+#define IC1_PHYS_ADDR 0x11800000 -+#define AC97_PHYS_ADDR 0x10000000 -+#define USBH_PHYS_ADDR 0x10100000 -+#define USBD_PHYS_ADDR 0x10200000 -+#define PCI_PHYS_ADDR 0x14005000 -+#define MAC0_PHYS_ADDR 0x11500000 -+#define MAC1_PHYS_ADDR 0x11510000 -+#define MACEN_PHYS_ADDR 0x11520000 -+#define MACDMA0_PHYS_ADDR 0x14004000 -+#define MACDMA1_PHYS_ADDR 0x14004200 -+#define I2S_PHYS_ADDR 0x11000000 -+#define UART0_PHYS_ADDR 0x11100000 -+#define UART3_PHYS_ADDR 0x11400000 -+#define GPIO2_PHYS_ADDR 0x11700000 -+#define SYS_PHYS_ADDR 0x11900000 -+#define PCI_MEM_PHYS_ADDR 0x400000000 -+#define PCI_IO_PHYS_ADDR 0x500000000 -+#define PCI_CONFIG0_PHYS_ADDR 0x600000000 -+#define PCI_CONFIG1_PHYS_ADDR 0x680000000 -+#define PCMCIA_IO_PHYS_ADDR 0xF00000000 -+#define PCMCIA_ATTR_PHYS_ADDR 0xF40000000 -+#define PCMCIA_MEM_PHYS_ADDR 0xF80000000 - #endif - -+/********************************************************************/ -+ -+#ifdef CONFIG_SOC_AU1100 -+#define MEM_PHYS_ADDR 0x14000000 -+#define STATIC_MEM_PHYS_ADDR 0x14001000 -+#define DMA0_PHYS_ADDR 0x14002000 -+#define DMA1_PHYS_ADDR 0x14002100 -+#define DMA2_PHYS_ADDR 0x14002200 -+#define DMA3_PHYS_ADDR 0x14002300 -+#define DMA4_PHYS_ADDR 0x14002400 -+#define DMA5_PHYS_ADDR 0x14002500 -+#define DMA6_PHYS_ADDR 0x14002600 -+#define DMA7_PHYS_ADDR 0x14002700 -+#define IC0_PHYS_ADDR 0x10400000 -+#define SD0_PHYS_ADDR 0x10600000 -+#define SD1_PHYS_ADDR 0x10680000 -+#define IC1_PHYS_ADDR 0x11800000 -+#define AC97_PHYS_ADDR 0x10000000 -+#define USBH_PHYS_ADDR 0x10100000 -+#define USBD_PHYS_ADDR 0x10200000 -+#define IRDA_PHYS_ADDR 0x10300000 -+#define MAC0_PHYS_ADDR 0x10500000 -+#define MACEN_PHYS_ADDR 0x10520000 -+#define MACDMA0_PHYS_ADDR 0x14004000 -+#define MACDMA1_PHYS_ADDR 0x14004200 -+#define I2S_PHYS_ADDR 0x11000000 -+#define UART0_PHYS_ADDR 0x11100000 -+#define UART1_PHYS_ADDR 0x11200000 -+#define UART3_PHYS_ADDR 0x11400000 -+#define SSI0_PHYS_ADDR 0x11600000 -+#define SSI1_PHYS_ADDR 0x11680000 -+#define GPIO2_PHYS_ADDR 0x11700000 -+#define SYS_PHYS_ADDR 0x11900000 -+#define LCD_PHYS_ADDR 0x15000000 -+#define PCMCIA_IO_PHYS_ADDR 0xF00000000 -+#define PCMCIA_ATTR_PHYS_ADDR 0xF40000000 -+#define PCMCIA_MEM_PHYS_ADDR 0xF80000000 -+#endif -+ -+/***********************************************************************/ -+ -+#ifdef CONFIG_SOC_AU1550 -+#define MEM_PHYS_ADDR 0x14000000 -+#define STATIC_MEM_PHYS_ADDR 0x14001000 -+#define IC0_PHYS_ADDR 0x10400000 -+#define IC1_PHYS_ADDR 0x11800000 -+#define USBH_PHYS_ADDR 0x14020000 -+#define USBD_PHYS_ADDR 0x10200000 -+#define PCI_PHYS_ADDR 0x14005000 -+#define MAC0_PHYS_ADDR 0x10500000 -+#define MAC1_PHYS_ADDR 0x10510000 -+#define MACEN_PHYS_ADDR 0x10520000 -+#define MACDMA0_PHYS_ADDR 0x14004000 -+#define MACDMA1_PHYS_ADDR 0x14004200 -+#define UART0_PHYS_ADDR 0x11100000 -+#define UART1_PHYS_ADDR 0x11200000 -+#define UART3_PHYS_ADDR 0x11400000 -+#define GPIO2_PHYS_ADDR 0x11700000 -+#define SYS_PHYS_ADDR 0x11900000 -+#define DDMA_PHYS_ADDR 0x14002000 -+#define PE_PHYS_ADDR 0x14008000 -+#define PSC0_PHYS_ADDR 0x11A00000 -+#define PSC1_PHYS_ADDR 0x11B00000 -+#define PSC2_PHYS_ADDR 0x10A00000 -+#define PSC3_PHYS_ADDR 0x10B00000 -+#define PCI_MEM_PHYS_ADDR 0x400000000 -+#define PCI_IO_PHYS_ADDR 0x500000000 -+#define PCI_CONFIG0_PHYS_ADDR 0x600000000 -+#define PCI_CONFIG1_PHYS_ADDR 0x680000000 -+#define PCMCIA_IO_PHYS_ADDR 0xF00000000 -+#define PCMCIA_ATTR_PHYS_ADDR 0xF40000000 -+#define PCMCIA_MEM_PHYS_ADDR 0xF80000000 -+#endif -+ -+/***********************************************************************/ -+ -+#ifdef CONFIG_SOC_AU1200 -+#define MEM_PHYS_ADDR 0x14000000 -+#define STATIC_MEM_PHYS_ADDR 0x14001000 -+#define AES_PHYS_ADDR 0x10300000 -+#define CIM_PHYS_ADDR 0x14004000 -+#define IC0_PHYS_ADDR 0x10400000 -+#define IC1_PHYS_ADDR 0x11800000 -+#define USBM_PHYS_ADDR 0x14020000 -+#define USBH_PHYS_ADDR 0x14020100 -+#define UART0_PHYS_ADDR 0x11100000 -+#define UART1_PHYS_ADDR 0x11200000 -+#define GPIO2_PHYS_ADDR 0x11700000 -+#define SYS_PHYS_ADDR 0x11900000 -+#define DDMA_PHYS_ADDR 0x14002000 -+#define PSC0_PHYS_ADDR 0x11A00000 -+#define PSC1_PHYS_ADDR 0x11B00000 -+#define PCMCIA_IO_PHYS_ADDR 0xF00000000 -+#define PCMCIA_ATTR_PHYS_ADDR 0xF40000000 -+#define PCMCIA_MEM_PHYS_ADDR 0xF80000000 -+#define SD0_PHYS_ADDR 0x10600000 -+#define SD1_PHYS_ADDR 0x10680000 -+#define LCD_PHYS_ADDR 0x15000000 -+#define SWCNT_PHYS_ADDR 0x1110010C -+#define MAEFE_PHYS_ADDR 0x14012000 -+#define MAEBE_PHYS_ADDR 0x14010000 -+#endif -+ -+ - /* Static Bus Controller */ - #define MEM_STCFG0 0xB4001000 - #define MEM_STTIME0 0xB4001004 -@@ -367,7 +695,7 @@ extern au1xxx_irq_map_t au1xxx_irq_map[] - #define AU1000_MAC0_ENABLE 0xB0520000 - #define AU1000_MAC1_ENABLE 0xB0520004 - #define NUM_ETH_INTERFACES 2 --#endif // CONFIG_SOC_AU1000 -+#endif /* CONFIG_SOC_AU1000 */ - - /* Au1500 */ - #ifdef CONFIG_SOC_AU1500 -@@ -438,7 +766,7 @@ extern au1xxx_irq_map_t au1xxx_irq_map[] - #define AU1500_MAC0_ENABLE 0xB1520000 - #define AU1500_MAC1_ENABLE 0xB1520004 - #define NUM_ETH_INTERFACES 2 --#endif // CONFIG_SOC_AU1500 -+#endif /* CONFIG_SOC_AU1500 */ - - /* Au1100 */ - #ifdef CONFIG_SOC_AU1100 -@@ -483,6 +811,22 @@ extern au1xxx_irq_map_t au1xxx_irq_map[] - #define AU1000_GPIO_13 45 - #define AU1000_GPIO_14 46 - #define AU1000_GPIO_15 47 -+#define AU1000_GPIO_16 48 -+#define AU1000_GPIO_17 49 -+#define AU1000_GPIO_18 50 -+#define AU1000_GPIO_19 51 -+#define AU1000_GPIO_20 52 -+#define AU1000_GPIO_21 53 -+#define AU1000_GPIO_22 54 -+#define AU1000_GPIO_23 55 -+#define AU1000_GPIO_24 56 -+#define AU1000_GPIO_25 57 -+#define AU1000_GPIO_26 58 -+#define AU1000_GPIO_27 59 -+#define AU1000_GPIO_28 60 -+#define AU1000_GPIO_29 61 -+#define AU1000_GPIO_30 62 -+#define AU1000_GPIO_31 63 - - #define UART0_ADDR 0xB1100000 - #define UART1_ADDR 0xB1200000 -@@ -494,7 +838,7 @@ extern au1xxx_irq_map_t au1xxx_irq_map[] - #define AU1100_ETH0_BASE 0xB0500000 - #define AU1100_MAC0_ENABLE 0xB0520000 - #define NUM_ETH_INTERFACES 1 --#endif // CONFIG_SOC_AU1100 -+#endif /* CONFIG_SOC_AU1100 */ - - #ifdef CONFIG_SOC_AU1550 - #define AU1550_UART0_INT 0 -@@ -511,14 +855,14 @@ extern au1xxx_irq_map_t au1xxx_irq_map[] - #define AU1550_PSC1_INT 11 - #define AU1550_PSC2_INT 12 - #define AU1550_PSC3_INT 13 --#define AU1550_TOY_INT 14 --#define AU1550_TOY_MATCH0_INT 15 --#define AU1550_TOY_MATCH1_INT 16 --#define AU1550_TOY_MATCH2_INT 17 --#define AU1550_RTC_INT 18 --#define AU1550_RTC_MATCH0_INT 19 --#define AU1550_RTC_MATCH1_INT 20 --#define AU1550_RTC_MATCH2_INT 21 -+#define AU1000_TOY_INT 14 -+#define AU1000_TOY_MATCH0_INT 15 -+#define AU1000_TOY_MATCH1_INT 16 -+#define AU1000_TOY_MATCH2_INT 17 -+#define AU1000_RTC_INT 18 -+#define AU1000_RTC_MATCH0_INT 19 -+#define AU1000_RTC_MATCH1_INT 20 -+#define AU1000_RTC_MATCH2_INT 21 - #define AU1550_NAND_INT 23 - #define AU1550_USB_DEV_REQ_INT 24 - #define AU1550_USB_DEV_SUS_INT 25 -@@ -573,7 +917,7 @@ extern au1xxx_irq_map_t au1xxx_irq_map[] - #define AU1550_MAC0_ENABLE 0xB0520000 - #define AU1550_MAC1_ENABLE 0xB0520004 - #define NUM_ETH_INTERFACES 2 --#endif // CONFIG_SOC_AU1550 -+#endif /* CONFIG_SOC_AU1550 */ - - #ifdef CONFIG_SOC_AU1200 - #define AU1200_UART0_INT 0 -@@ -590,14 +934,14 @@ extern au1xxx_irq_map_t au1xxx_irq_map[] - #define AU1200_PSC1_INT 11 - #define AU1200_AES_INT 12 - #define AU1200_CAMERA_INT 13 --#define AU1200_TOY_INT 14 --#define AU1200_TOY_MATCH0_INT 15 --#define AU1200_TOY_MATCH1_INT 16 --#define AU1200_TOY_MATCH2_INT 17 --#define AU1200_RTC_INT 18 --#define AU1200_RTC_MATCH0_INT 19 --#define AU1200_RTC_MATCH1_INT 20 --#define AU1200_RTC_MATCH2_INT 21 -+#define AU1000_TOY_INT 14 -+#define AU1000_TOY_MATCH0_INT 15 -+#define AU1000_TOY_MATCH1_INT 16 -+#define AU1000_TOY_MATCH2_INT 17 -+#define AU1000_RTC_INT 18 -+#define AU1000_RTC_MATCH0_INT 19 -+#define AU1000_RTC_MATCH1_INT 20 -+#define AU1000_RTC_MATCH2_INT 21 - #define AU1200_NAND_INT 23 - #define AU1200_GPIO_204 24 - #define AU1200_GPIO_205 25 -@@ -605,6 +949,7 @@ extern au1xxx_irq_map_t au1xxx_irq_map[] - #define AU1200_GPIO_207 27 - #define AU1200_GPIO_208_215 28 // Logical OR of 208:215 - #define AU1200_USB_INT 29 -+#define AU1000_USB_HOST_INT AU1200_USB_INT - #define AU1200_LCD_INT 30 - #define AU1200_MAE_BOTH_INT 31 - #define AU1000_GPIO_0 32 -@@ -643,21 +988,36 @@ extern au1xxx_irq_map_t au1xxx_irq_map[] - #define UART0_ADDR 0xB1100000 - #define UART1_ADDR 0xB1200000 - --#define USB_OHCI_BASE 0x14020000 // phys addr for ioremap --#define USB_HOST_CONFIG 0xB4027ffc -+#define USB_UOC_BASE 0x14020020 -+#define USB_UOC_LEN 0x20 -+#define USB_OHCI_BASE 0x14020100 -+#define USB_OHCI_LEN 0x100 -+#define USB_EHCI_BASE 0x14020200 -+#define USB_EHCI_LEN 0x100 -+#define USB_UDC_BASE 0x14022000 -+#define USB_UDC_LEN 0x2000 -+#define USB_MSR_BASE 0xB4020000 -+#define USB_MSR_MCFG 4 -+#define USBMSRMCFG_OMEMEN 0 -+#define USBMSRMCFG_OBMEN 1 -+#define USBMSRMCFG_EMEMEN 2 -+#define USBMSRMCFG_EBMEN 3 -+#define USBMSRMCFG_DMEMEN 4 -+#define USBMSRMCFG_DBMEN 5 -+#define USBMSRMCFG_GMEMEN 6 -+#define USBMSRMCFG_OHCCLKEN 16 -+#define USBMSRMCFG_EHCCLKEN 17 -+#define USBMSRMCFG_UDCCLKEN 18 -+#define USBMSRMCFG_PHYPLLEN 19 -+#define USBMSRMCFG_RDCOMB 30 -+#define USBMSRMCFG_PFEN 31 - --// these are here for prototyping on au1550 (do not exist on au1200) --#define AU1200_ETH0_BASE 0xB0500000 --#define AU1200_ETH1_BASE 0xB0510000 --#define AU1200_MAC0_ENABLE 0xB0520000 --#define AU1200_MAC1_ENABLE 0xB0520004 --#define NUM_ETH_INTERFACES 2 --#endif // CONFIG_SOC_AU1200 -+#endif /* CONFIG_SOC_AU1200 */ - - #define AU1000_LAST_INTC0_INT 31 -+#define AU1000_LAST_INTC1_INT 63 - #define AU1000_MAX_INTR 63 - -- - /* Programmable Counters 0 and 1 */ - #define SYS_BASE 0xB1900000 - #define SYS_COUNTER_CNTRL (SYS_BASE + 0x14) -@@ -728,6 +1088,8 @@ extern au1xxx_irq_map_t au1xxx_irq_map[] - #define I2S_CONTROL_D (1<<1) - #define I2S_CONTROL_CE (1<<0) - -+#ifndef CONFIG_SOC_AU1200 -+ - /* USB Host Controller */ - #define USB_OHCI_LEN 0x00100000 - -@@ -773,6 +1135,8 @@ extern au1xxx_irq_map_t au1xxx_irq_map[] - #define USBDEV_ENABLE (1<<1) - #define USBDEV_CE (1<<0) - -+#endif /* !CONFIG_SOC_AU1200 */ -+ - /* Ethernet Controllers */ - - /* 4 byte offsets from AU1000_ETH_BASE */ -@@ -1171,6 +1535,37 @@ extern au1xxx_irq_map_t au1xxx_irq_map[] - #define SYS_PF_PSC1_S1 (1 << 1) - #define SYS_PF_MUST_BE_SET ((1 << 5) | (1 << 2)) - -+/* Au1200 Only */ -+#ifdef CONFIG_SOC_AU1200 -+#define SYS_PINFUNC_DMA (1<<31) -+#define SYS_PINFUNC_S0A (1<<30) -+#define SYS_PINFUNC_S1A (1<<29) -+#define SYS_PINFUNC_LP0 (1<<28) -+#define SYS_PINFUNC_LP1 (1<<27) -+#define SYS_PINFUNC_LD16 (1<<26) -+#define SYS_PINFUNC_LD8 (1<<25) -+#define SYS_PINFUNC_LD1 (1<<24) -+#define SYS_PINFUNC_LD0 (1<<23) -+#define SYS_PINFUNC_P1A (3<<21) -+#define SYS_PINFUNC_P1B (1<<20) -+#define SYS_PINFUNC_FS3 (1<<19) -+#define SYS_PINFUNC_P0A (3<<17) -+#define SYS_PINFUNC_CS (1<<16) -+#define SYS_PINFUNC_CIM (1<<15) -+#define SYS_PINFUNC_P1C (1<<14) -+#define SYS_PINFUNC_U1T (1<<12) -+#define SYS_PINFUNC_U1R (1<<11) -+#define SYS_PINFUNC_EX1 (1<<10) -+#define SYS_PINFUNC_EX0 (1<<9) -+#define SYS_PINFUNC_U0R (1<<8) -+#define SYS_PINFUNC_MC (1<<7) -+#define SYS_PINFUNC_S0B (1<<6) -+#define SYS_PINFUNC_S0C (1<<5) -+#define SYS_PINFUNC_P0B (1<<4) -+#define SYS_PINFUNC_U0T (1<<3) -+#define SYS_PINFUNC_S1B (1<<2) -+#endif -+ - #define SYS_TRIOUTRD 0xB1900100 - #define SYS_TRIOUTCLR 0xB1900100 - #define SYS_OUTPUTRD 0xB1900108 -@@ -1298,7 +1693,6 @@ extern au1xxx_irq_map_t au1xxx_irq_map[] - #define SD1_XMIT_FIFO 0xB0680000 - #define SD1_RECV_FIFO 0xB0680004 - -- - #if defined (CONFIG_SOC_AU1500) || defined(CONFIG_SOC_AU1550) - /* Au1500 PCI Controller */ - #define Au1500_CFG_BASE 0xB4005000 // virtual, kseg0 addr -@@ -1388,9 +1782,60 @@ extern au1xxx_irq_map_t au1xxx_irq_map[] - - #endif - -+#ifndef _LANGUAGE_ASSEMBLY -+typedef volatile struct -+{ -+ /* 0x0000 */ u32 toytrim; -+ /* 0x0004 */ u32 toywrite; -+ /* 0x0008 */ u32 toymatch0; -+ /* 0x000C */ u32 toymatch1; -+ /* 0x0010 */ u32 toymatch2; -+ /* 0x0014 */ u32 cntrctrl; -+ /* 0x0018 */ u32 scratch0; -+ /* 0x001C */ u32 scratch1; -+ /* 0x0020 */ u32 freqctrl0; -+ /* 0x0024 */ u32 freqctrl1; -+ /* 0x0028 */ u32 clksrc; -+ /* 0x002C */ u32 pinfunc; -+ /* 0x0030 */ u32 reserved0; -+ /* 0x0034 */ u32 wakemsk; -+ /* 0x0038 */ u32 endian; -+ /* 0x003C */ u32 powerctrl; -+ /* 0x0040 */ u32 toyread; -+ /* 0x0044 */ u32 rtctrim; -+ /* 0x0048 */ u32 rtcwrite; -+ /* 0x004C */ u32 rtcmatch0; -+ /* 0x0050 */ u32 rtcmatch1; -+ /* 0x0054 */ u32 rtcmatch2; -+ /* 0x0058 */ u32 rtcread; -+ /* 0x005C */ u32 wakesrc; -+ /* 0x0060 */ u32 cpupll; -+ /* 0x0064 */ u32 auxpll; -+ /* 0x0068 */ u32 reserved1; -+ /* 0x006C */ u32 reserved2; -+ /* 0x0070 */ u32 reserved3; -+ /* 0x0074 */ u32 reserved4; -+ /* 0x0078 */ u32 slppwr; -+ /* 0x007C */ u32 sleep; -+ /* 0x0080 */ u32 reserved5[32]; -+ /* 0x0100 */ u32 trioutrd; -+#define trioutclr trioutrd -+ /* 0x0104 */ u32 reserved6; -+ /* 0x0108 */ u32 outputrd; -+#define outputset outputrd -+ /* 0x010C */ u32 outputclr; -+ /* 0x0110 */ u32 pinstaterd; -+#define pininputen pinstaterd -+ -+} AU1X00_SYS; -+ -+static AU1X00_SYS* const sys = (AU1X00_SYS *)SYS_BASE; -+ -+#endif - /* Processor information base on prid. - * Copied from PowerPC. - */ -+#ifndef _LANGUAGE_ASSEMBLY - struct cpu_spec { - /* CPU is matched via (PRID & prid_mask) == prid_value */ - unsigned int prid_mask; -@@ -1404,3 +1849,6 @@ struct cpu_spec { - extern struct cpu_spec cpu_specs[]; - extern struct cpu_spec *cur_cpu_spec[]; - #endif -+ -+#endif -+ ---- a/include/asm-mips/au1000_pcmcia.h -+++ b/include/asm-mips/au1000_pcmcia.h -@@ -38,16 +38,41 @@ - #define AU1X_SOCK0_PHYS_MEM 0xF80000000 - - /* pcmcia socket 1 needs external glue logic so the memory map -- * differs from board to board. -+ * differs from board to board. the general rule is that -+ * static bus address bit 26 should be used to decode socket 0 -+ * from socket 1. alas, some boards dont follow this... -+ * These really belong in a board-specific header file... - */ --#if defined(CONFIG_MIPS_PB1000) || defined(CONFIG_MIPS_PB1100) || defined(CONFIG_MIPS_PB1500) --#define AU1X_SOCK1_IO 0xF08000000 --#define AU1X_SOCK1_PHYS_ATTR 0xF48000000 --#define AU1X_SOCK1_PHYS_MEM 0xF88000000 --#elif defined(CONFIG_MIPS_DB1000) || defined(CONFIG_MIPS_DB1100) || defined(CONFIG_MIPS_DB1500) || defined(CONFIG_MIPS_PB1550) || defined(CONFIG_MIPS_DB1550) --#define AU1X_SOCK1_IO 0xF04000000 --#define AU1X_SOCK1_PHYS_ATTR 0xF44000000 --#define AU1X_SOCK1_PHYS_MEM 0xF84000000 -+#ifdef CONFIG_MIPS_PB1000 -+#define SOCK1_DECODE (1<<27) -+#endif -+#ifdef CONFIG_MIPS_DB1000 -+#define SOCK1_DECODE (1<<26) -+#endif -+#ifdef CONFIG_MIPS_DB1500 -+#define SOCK1_DECODE (1<<26) -+#endif -+#ifdef CONFIG_MIPS_DB1100 -+#define SOCK1_DECODE (1<<26) -+#endif -+#ifdef CONFIG_MIPS_DB1550 -+#define SOCK1_DECODE (1<<26) -+#endif -+#ifdef CONFIG_MIPS_DB1200 -+#define SOCK1_DECODE (1<<26) -+#endif -+#ifdef CONFIG_MIPS_PB1550 -+#define SOCK1_DECODE (1<<26) -+#endif -+#ifdef CONFIG_MIPS_PB1200 -+#define SOCK1_DECODE (1<<26) -+#endif -+ -+/* The board has a second PCMCIA socket */ -+#ifdef SOCK1_DECODE -+#define AU1X_SOCK1_IO (0xF00000000|SOCK1_DECODE) -+#define AU1X_SOCK1_PHYS_ATTR (0xF40000000|SOCK1_DECODE) -+#define AU1X_SOCK1_PHYS_MEM (0xF80000000|SOCK1_DECODE) - #endif - - struct pcmcia_state { ---- a/include/asm-mips/au1100_mmc.h -+++ b/include/asm-mips/au1100_mmc.h -@@ -39,16 +39,22 @@ - #define __ASM_AU1100_MMC_H - - --#define NUM_AU1100_MMC_CONTROLLERS 2 -- -- --#define AU1100_SD_IRQ 2 -- -+#if defined(CONFIG_SOC_AU1100) -+#define NUM_MMC_CONTROLLERS 2 -+#define AU1X_MMC_INT AU1100_SD_INT -+#endif -+ -+#if defined(CONFIG_SOC_AU1200) -+#define NUM_MMC_CONTROLLERS 2 -+#define AU1X_MMC_INT AU1200_SD_INT -+#endif - - #define SD0_BASE 0xB0600000 - #define SD1_BASE 0xB0680000 - - -+ -+ - /* - * Register offsets. - */ -@@ -201,5 +207,12 @@ - #define SD_CMD_RT_1B (0x00810000) - - -+/* support routines required on a platform-specific basis */ -+extern void mmc_card_inserted(int _n_, int *_res_); -+extern void mmc_card_writable(int _n_, int *_res_); -+extern void mmc_power_on(int _n_); -+extern void mmc_power_off(int _n_); -+ -+ - #endif /* __ASM_AU1100_MMC_H */ - ---- a/include/asm-mips/au1xxx_dbdma.h -+++ b/include/asm-mips/au1xxx_dbdma.h -@@ -43,7 +43,7 @@ - #define DDMA_GLOBAL_BASE 0xb4003000 - #define DDMA_CHANNEL_BASE 0xb4002000 - --typedef struct dbdma_global { -+typedef volatile struct dbdma_global { - u32 ddma_config; - u32 ddma_intstat; - u32 ddma_throttle; -@@ -60,7 +60,7 @@ typedef struct dbdma_global { - - /* The structure of a DMA Channel. - */ --typedef struct au1xxx_dma_channel { -+typedef volatile struct au1xxx_dma_channel { - u32 ddma_cfg; /* See below */ - u32 ddma_desptr; /* 32-byte aligned pointer to descriptor */ - u32 ddma_statptr; /* word aligned pointer to status word */ -@@ -96,7 +96,7 @@ typedef struct au1xxx_dma_channel { - /* "Standard" DDMA Descriptor. - * Must be 32-byte aligned. - */ --typedef struct au1xxx_ddma_desc { -+typedef volatile struct au1xxx_ddma_desc { - u32 dscr_cmd0; /* See below */ - u32 dscr_cmd1; /* See below */ - u32 dscr_source0; /* source phys address */ -@@ -105,6 +105,12 @@ typedef struct au1xxx_ddma_desc { - u32 dscr_dest1; /* See below */ - u32 dscr_stat; /* completion status */ - u32 dscr_nxtptr; /* Next descriptor pointer (mostly) */ -+ /* First 32bytes are HW specific!!! -+ Lets have some SW data following.. make sure its 32bytes -+ */ -+ u32 sw_status; -+ u32 sw_context; -+ u32 sw_reserved[6]; - } au1x_ddma_desc_t; - - #define DSCR_CMD0_V (1 << 31) /* Descriptor valid */ -@@ -123,6 +129,8 @@ typedef struct au1xxx_ddma_desc { - #define DSCR_CMD0_CV (0x1 << 2) /* Clear Valid when done */ - #define DSCR_CMD0_ST_MASK (0x3 << 0) /* Status instruction */ - -+#define SW_STATUS_INUSE (1<<0) -+ - /* Command 0 device IDs. - */ - #ifdef CONFIG_SOC_AU1550 -@@ -169,8 +177,8 @@ typedef struct au1xxx_ddma_desc { - #define DSCR_CMD0_SDMS_RX0 9 - #define DSCR_CMD0_SDMS_TX1 10 - #define DSCR_CMD0_SDMS_RX1 11 --#define DSCR_CMD0_AES_TX 12 --#define DSCR_CMD0_AES_RX 13 -+#define DSCR_CMD0_AES_TX 13 -+#define DSCR_CMD0_AES_RX 12 - #define DSCR_CMD0_PSC0_TX 14 - #define DSCR_CMD0_PSC0_RX 15 - #define DSCR_CMD0_PSC1_TX 16 -@@ -189,6 +197,10 @@ typedef struct au1xxx_ddma_desc { - #define DSCR_CMD0_THROTTLE 30 - #define DSCR_CMD0_ALWAYS 31 - #define DSCR_NDEV_IDS 32 -+/* THis macro is used to find/create custom device types */ -+#define DSCR_DEV2CUSTOM_ID(x,d) (((((x)&0xFFFF)<<8)|0x32000000)|((d)&0xFF)) -+#define DSCR_CUSTOM2DEV_ID(x) ((x)&0xFF) -+ - - #define DSCR_CMD0_SID(x) (((x) & 0x1f) << 25) - #define DSCR_CMD0_DID(x) (((x) & 0x1f) << 20) -@@ -277,6 +289,43 @@ typedef struct au1xxx_ddma_desc { - */ - #define NUM_DBDMA_CHANS 16 - -+/* -+ * Ddma API definitions -+ * FIXME: may not fit to this header file -+ */ -+typedef struct dbdma_device_table { -+ u32 dev_id; -+ u32 dev_flags; -+ u32 dev_tsize; -+ u32 dev_devwidth; -+ u32 dev_physaddr; /* If FIFO */ -+ u32 dev_intlevel; -+ u32 dev_intpolarity; -+} dbdev_tab_t; -+ -+ -+typedef struct dbdma_chan_config { -+ spinlock_t lock; -+ -+ u32 chan_flags; -+ u32 chan_index; -+ dbdev_tab_t *chan_src; -+ dbdev_tab_t *chan_dest; -+ au1x_dma_chan_t *chan_ptr; -+ au1x_ddma_desc_t *chan_desc_base; -+ au1x_ddma_desc_t *get_ptr, *put_ptr, *cur_ptr; -+ void *chan_callparam; -+ void (*chan_callback)(int, void *, struct pt_regs *); -+} chan_tab_t; -+ -+#define DEV_FLAGS_INUSE (1 << 0) -+#define DEV_FLAGS_ANYUSE (1 << 1) -+#define DEV_FLAGS_OUT (1 << 2) -+#define DEV_FLAGS_IN (1 << 3) -+#define DEV_FLAGS_BURSTABLE (1 << 4) -+#define DEV_FLAGS_SYNC (1 << 5) -+/* end Ddma API definitions */ -+ - /* External functions for drivers to use. - */ - /* Use this to allocate a dbdma channel. The device ids are one of the -@@ -299,8 +348,8 @@ u32 au1xxx_dbdma_ring_alloc(u32 chanid, - - /* Put buffers on source/destination descriptors. - */ --u32 au1xxx_dbdma_put_source(u32 chanid, void *buf, int nbytes); --u32 au1xxx_dbdma_put_dest(u32 chanid, void *buf, int nbytes); -+u32 _au1xxx_dbdma_put_source(u32 chanid, void *buf, int nbytes, u32 flags); -+u32 _au1xxx_dbdma_put_dest(u32 chanid, void *buf, int nbytes, u32 flags); - - /* Get a buffer from the destination descriptor. - */ -@@ -314,5 +363,25 @@ u32 au1xxx_get_dma_residue(u32 chanid); - void au1xxx_dbdma_chan_free(u32 chanid); - void au1xxx_dbdma_dump(u32 chanid); - -+u32 au1xxx_dbdma_put_dscr(u32 chanid, au1x_ddma_desc_t *dscr ); -+ -+u32 au1xxx_ddma_add_device( dbdev_tab_t *dev ); -+ -+/* -+ Some compatibilty macros -- -+ Needed to make changes to API without breaking existing drivers -+*/ -+#define au1xxx_dbdma_put_source(chanid,buf,nbytes)_au1xxx_dbdma_put_source(chanid, buf, nbytes, DDMA_FLAGS_IE) -+#define au1xxx_dbdma_put_source_flags(chanid,buf,nbytes,flags) _au1xxx_dbdma_put_source(chanid, buf, nbytes, flags) -+ -+#define au1xxx_dbdma_put_dest(chanid,buf,nbytes) _au1xxx_dbdma_put_dest(chanid, buf, nbytes, DDMA_FLAGS_IE) -+#define au1xxx_dbdma_put_dest_flags(chanid,buf,nbytes,flags) _au1xxx_dbdma_put_dest(chanid, buf, nbytes, flags) -+ -+/* -+ * Flags for the put_source/put_dest functions. -+ */ -+#define DDMA_FLAGS_IE (1<<0) -+#define DDMA_FLAGS_NOIE (1<<1) -+ - #endif /* _LANGUAGE_ASSEMBLY */ - #endif /* _AU1000_DBDMA_H_ */ ---- /dev/null -+++ b/include/asm-mips/au1xxx_gpio.h -@@ -0,0 +1,22 @@ -+ -+ -+#ifndef __AU1XXX_GPIO_H -+#define __AU1XXX_GPIO_H -+ -+void au1xxx_gpio1_set_inputs(void); -+void au1xxx_gpio_tristate(int signal); -+void au1xxx_gpio_write(int signal, int value); -+int au1xxx_gpio_read(int signal); -+ -+typedef volatile struct -+{ -+ u32 dir; -+ u32 reserved; -+ u32 output; -+ u32 pinstate; -+ u32 inten; -+ u32 enable; -+ -+} AU1X00_GPIO2; -+ -+#endif //__AU1XXX_GPIO_H ---- a/include/asm-mips/au1xxx_psc.h -+++ b/include/asm-mips/au1xxx_psc.h -@@ -41,6 +41,11 @@ - #define PSC3_BASE_ADDR 0xb0d00000 - #endif - -+#ifdef CONFIG_SOC_AU1200 -+#define PSC0_BASE_ADDR 0xb1a00000 -+#define PSC1_BASE_ADDR 0xb1b00000 -+#endif -+ - /* The PSC select and control registers are common to - * all protocols. - */ -@@ -226,6 +231,8 @@ typedef struct psc_i2s { - #define PSC_I2SCFG_DD_DISABLE (1 << 27) - #define PSC_I2SCFG_DE_ENABLE (1 << 26) - #define PSC_I2SCFG_SET_WS(x) (((((x) / 2) - 1) & 0x7f) << 16) -+#define PSC_I2SCFG_WS(n) ((n&0xFF)<<16) -+#define PSC_I2SCFG_WS_MASK (PSC_I2SCFG_WS(0x3F)) - #define PSC_I2SCFG_WI (1 << 15) - - #define PSC_I2SCFG_DIV_MASK (3 << 13) ---- a/include/asm-mips/bootinfo.h -+++ b/include/asm-mips/bootinfo.h -@@ -180,6 +180,9 @@ - #define MACH_MTX1 7 /* 4G MTX-1 Au1500-based board */ - #define MACH_CSB250 8 /* Cogent Au1500 */ - #define MACH_PB1550 9 /* Au1550-based eval board */ -+#define MACH_PB1200 10 /* Au1200-based eval board */ -+#define MACH_DB1550 11 /* Au1550-based eval board */ -+#define MACH_DB1200 12 /* Au1200-based eval board */ - - /* - * Valid machtype for group NEC_VR41XX ---- /dev/null -+++ b/include/asm-mips/db1200.h -@@ -0,0 +1,214 @@ -+/* -+ * AMD Alchemy DB1200 Referrence Board -+ * Board Registers defines. -+ * -+ * ######################################################################## -+ * -+ * This program is free software; you can distribute 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 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 __ASM_DB1200_H -+#define __ASM_DB1200_H -+ -+#include <linux/types.h> -+ -+// This is defined in au1000.h with bogus value -+#undef AU1X00_EXTERNAL_INT -+ -+#define DBDMA_AC97_TX_CHAN DSCR_CMD0_PSC1_TX -+#define DBDMA_AC97_RX_CHAN DSCR_CMD0_PSC1_RX -+#define DBDMA_I2S_TX_CHAN DSCR_CMD0_PSC1_TX -+#define DBDMA_I2S_RX_CHAN DSCR_CMD0_PSC1_RX -+ -+/* SPI and SMB are muxed on the Pb1200 board. -+ Refer to board documentation. -+ */ -+#define SPI_PSC_BASE PSC0_BASE_ADDR -+#define SMBUS_PSC_BASE PSC0_BASE_ADDR -+/* AC97 and I2S are muxed on the Pb1200 board. -+ Refer to board documentation. -+ */ -+#define AC97_PSC_BASE PSC1_BASE_ADDR -+#define I2S_PSC_BASE PSC1_BASE_ADDR -+ -+#define BCSR_KSEG1_ADDR 0xB9800000 -+ -+typedef volatile struct -+{ -+ /*00*/ u16 whoami; -+ u16 reserved0; -+ /*04*/ u16 status; -+ u16 reserved1; -+ /*08*/ u16 switches; -+ u16 reserved2; -+ /*0C*/ u16 resets; -+ u16 reserved3; -+ -+ /*10*/ u16 pcmcia; -+ u16 reserved4; -+ /*14*/ u16 board; -+ u16 reserved5; -+ /*18*/ u16 disk_leds; -+ u16 reserved6; -+ /*1C*/ u16 system; -+ u16 reserved7; -+ -+ /*20*/ u16 intclr; -+ u16 reserved8; -+ /*24*/ u16 intset; -+ u16 reserved9; -+ /*28*/ u16 intclr_mask; -+ u16 reserved10; -+ /*2C*/ u16 intset_mask; -+ u16 reserved11; -+ -+ /*30*/ u16 sig_status; -+ u16 reserved12; -+ /*34*/ u16 int_status; -+ u16 reserved13; -+ /*38*/ u16 reserved14; -+ u16 reserved15; -+ /*3C*/ u16 reserved16; -+ u16 reserved17; -+ -+} BCSR; -+ -+static BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR; -+ -+/* -+ * Register bit definitions for the BCSRs -+ */ -+#define BCSR_WHOAMI_DCID 0x000F -+#define BCSR_WHOAMI_CPLD 0x00F0 -+#define BCSR_WHOAMI_BOARD 0x0F00 -+ -+#define BCSR_STATUS_PCMCIA0VS 0x0003 -+#define BCSR_STATUS_PCMCIA1VS 0x000C -+#define BCSR_STATUS_SWAPBOOT 0x0040 -+#define BCSR_STATUS_FLASHBUSY 0x0100 -+#define BCSR_STATUS_IDECBLID 0x0200 -+#define BCSR_STATUS_SD0WP 0x0400 -+#define BCSR_STATUS_U0RXD 0x1000 -+#define BCSR_STATUS_U1RXD 0x2000 -+ -+#define BCSR_SWITCHES_OCTAL 0x00FF -+#define BCSR_SWITCHES_DIP_1 0x0080 -+#define BCSR_SWITCHES_DIP_2 0x0040 -+#define BCSR_SWITCHES_DIP_3 0x0020 -+#define BCSR_SWITCHES_DIP_4 0x0010 -+#define BCSR_SWITCHES_DIP_5 0x0008 -+#define BCSR_SWITCHES_DIP_6 0x0004 -+#define BCSR_SWITCHES_DIP_7 0x0002 -+#define BCSR_SWITCHES_DIP_8 0x0001 -+#define BCSR_SWITCHES_ROTARY 0x0F00 -+ -+#define BCSR_RESETS_ETH 0x0001 -+#define BCSR_RESETS_CAMERA 0x0002 -+#define BCSR_RESETS_DC 0x0004 -+#define BCSR_RESETS_IDE 0x0008 -+#define BCSR_RESETS_TV 0x0010 -+/* not resets but in the same register */ -+#define BCSR_RESETS_PWMR1mUX 0x0800 -+#define BCSR_RESETS_PCS0MUX 0x1000 -+#define BCSR_RESETS_PCS1MUX 0x2000 -+#define BCSR_RESETS_SPISEL 0x4000 -+ -+#define BCSR_PCMCIA_PC0VPP 0x0003 -+#define BCSR_PCMCIA_PC0VCC 0x000C -+#define BCSR_PCMCIA_PC0DRVEN 0x0010 -+#define BCSR_PCMCIA_PC0RST 0x0080 -+#define BCSR_PCMCIA_PC1VPP 0x0300 -+#define BCSR_PCMCIA_PC1VCC 0x0C00 -+#define BCSR_PCMCIA_PC1DRVEN 0x1000 -+#define BCSR_PCMCIA_PC1RST 0x8000 -+ -+#define BCSR_BOARD_LCDVEE 0x0001 -+#define BCSR_BOARD_LCDVDD 0x0002 -+#define BCSR_BOARD_LCDBL 0x0004 -+#define BCSR_BOARD_CAMSNAP 0x0010 -+#define BCSR_BOARD_CAMPWR 0x0020 -+#define BCSR_BOARD_SD0PWR 0x0040 -+ -+#define BCSR_LEDS_DECIMALS 0x0003 -+#define BCSR_LEDS_LED0 0x0100 -+#define BCSR_LEDS_LED1 0x0200 -+#define BCSR_LEDS_LED2 0x0400 -+#define BCSR_LEDS_LED3 0x0800 -+ -+#define BCSR_SYSTEM_POWEROFF 0x4000 -+#define BCSR_SYSTEM_RESET 0x8000 -+ -+/* Bit positions for the different interrupt sources */ -+#define BCSR_INT_IDE 0x0001 -+#define BCSR_INT_ETH 0x0002 -+#define BCSR_INT_PC0 0x0004 -+#define BCSR_INT_PC0STSCHG 0x0008 -+#define BCSR_INT_PC1 0x0010 -+#define BCSR_INT_PC1STSCHG 0x0020 -+#define BCSR_INT_DC 0x0040 -+#define BCSR_INT_FLASHBUSY 0x0080 -+#define BCSR_INT_PC0INSERT 0x0100 -+#define BCSR_INT_PC0EJECT 0x0200 -+#define BCSR_INT_PC1INSERT 0x0400 -+#define BCSR_INT_PC1EJECT 0x0800 -+#define BCSR_INT_SD0INSERT 0x1000 -+#define BCSR_INT_SD0EJECT 0x2000 -+ -+#define AU1XXX_SMC91111_PHYS_ADDR (0x19000300) -+#define AU1XXX_SMC91111_IRQ DB1200_ETH_INT -+ -+#define AU1XXX_ATA_PHYS_ADDR (0x18800000) -+#define AU1XXX_ATA_PHYS_LEN (0x100) -+#define AU1XXX_ATA_REG_OFFSET (5) -+#define AU1XXX_ATA_INT DB1200_IDE_INT -+#define AU1XXX_ATA_DDMA_REQ DSCR_CMD0_DMA_REQ1; -+#define AU1XXX_ATA_RQSIZE 128 -+ -+#define NAND_PHYS_ADDR 0x20000000 -+ -+/* -+ * External Interrupts for Pb1200 as of 8/6/2004. -+ * Bit positions in the CPLD registers can be calculated by taking -+ * the interrupt define and subtracting the DB1200_INT_BEGIN value. -+ * *example: IDE bis pos is = 64 - 64 -+ ETH bit pos is = 65 - 64 -+ */ -+#define DB1200_INT_BEGIN (AU1000_LAST_INTC1_INT + 1) -+#define DB1200_IDE_INT (DB1200_INT_BEGIN + 0) -+#define DB1200_ETH_INT (DB1200_INT_BEGIN + 1) -+#define DB1200_PC0_INT (DB1200_INT_BEGIN + 2) -+#define DB1200_PC0_STSCHG_INT (DB1200_INT_BEGIN + 3) -+#define DB1200_PC1_INT (DB1200_INT_BEGIN + 4) -+#define DB1200_PC1_STSCHG_INT (DB1200_INT_BEGIN + 5) -+#define DB1200_DC_INT (DB1200_INT_BEGIN + 6) -+#define DB1200_FLASHBUSY_INT (DB1200_INT_BEGIN + 7) -+#define DB1200_PC0_INSERT_INT (DB1200_INT_BEGIN + 8) -+#define DB1200_PC0_EJECT_INT (DB1200_INT_BEGIN + 9) -+#define DB1200_PC1_INSERT_INT (DB1200_INT_BEGIN + 10) -+#define DB1200_PC1_EJECT_INT (DB1200_INT_BEGIN + 11) -+#define DB1200_SD0_INSERT_INT (DB1200_INT_BEGIN + 12) -+#define DB1200_SD0_EJECT_INT (DB1200_INT_BEGIN + 13) -+ -+#define DB1200_INT_END (DB1200_INT_BEGIN + 15) -+ -+/* For drivers/pcmcia/au1000_db1x00.c */ -+#define BOARD_PC0_INT DB1200_PC0_INT -+#define BOARD_PC1_INT DB1200_PC1_INT -+#define BOARD_CARD_INSERTED(SOCKET) bcsr->sig_status & (1<<(8+(2*SOCKET))) -+ -+#endif /* __ASM_DB1200_H */ -+ ---- a/include/asm-mips/db1x00.h -+++ b/include/asm-mips/db1x00.h -@@ -1,5 +1,5 @@ - /* -- * AMD Alchemy DB1x00 Reference Boards -+ * AMD Alchemy DB1x00 Reference Boards (BUT NOT DB1200) - * - * Copyright 2001 MontaVista Software Inc. - * Author: MontaVista Software, Inc. -@@ -36,9 +36,18 @@ - #define AC97_PSC_BASE PSC1_BASE_ADDR - #define SMBUS_PSC_BASE PSC2_BASE_ADDR - #define I2S_PSC_BASE PSC3_BASE_ADDR -+#define NAND_CS 1 -+/* for drivers/pcmcia/au1000_db1x00.c */ -+#define BOARD_PC0_INT AU1000_GPIO_3 -+#define BOARD_PC1_INT AU1000_GPIO_5 -+#define BOARD_CARD_INSERTED(SOCKET) !(bcsr->status & (1<<(4+SOCKET))) - - #else - #define BCSR_KSEG1_ADDR 0xAE000000 -+/* for drivers/pcmcia/au1000_db1x00.c */ -+#define BOARD_PC0_INT AU1000_GPIO_2 -+#define BOARD_PC1_INT AU1000_GPIO_5 -+#define BOARD_CARD_INSERTED(SOCKET) !(bcsr->status & (1<<(4+SOCKET))) - #endif - - /* -@@ -66,6 +75,7 @@ typedef volatile struct - - } BCSR; - -+static BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR; - - /* - * Register/mask bit definitions for the BCSRs -@@ -130,14 +140,6 @@ typedef volatile struct - - #define BCSR_SWRESET_RESET 0x0080 - --/* PCMCIA Db1x00 specific defines */ --#define PCMCIA_MAX_SOCK 1 --#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK+1) -- --/* VPP/VCC */ --#define SET_VCC_VPP(VCC, VPP, SLOT)\ -- ((((VCC)<<2) | ((VPP)<<0)) << ((SLOT)*8)) -- - /* MTD CONFIG OPTIONS */ - #if defined(CONFIG_MTD_DB1X00_BOOT) && defined(CONFIG_MTD_DB1X00_USER) - #define DB1X00_BOTH_BANKS -@@ -147,48 +149,15 @@ typedef volatile struct - #define DB1X00_USER_ONLY - #endif - --/* SD controller macros */ --/* -- * Detect card. -- */ --#define mmc_card_inserted(_n_, _res_) \ -- do { \ -- BCSR * const bcsr = (BCSR *)0xAE000000; \ -- unsigned long mmc_wp, board_specific; \ -- if ((_n_)) { \ -- mmc_wp = BCSR_BOARD_SD1_WP; \ -- } else { \ -- mmc_wp = BCSR_BOARD_SD0_WP; \ -- } \ -- board_specific = au_readl((unsigned long)(&bcsr->specific)); \ -- if (!(board_specific & mmc_wp)) {/* low means card present */ \ -- *(int *)(_res_) = 1; \ -- } else { \ -- *(int *)(_res_) = 0; \ -- } \ -- } while (0) -- -+#if defined(CONFIG_BLK_DEV_IDE_AU1XXX) && defined(CONFIG_MIPS_DB1550) - /* -- * Apply power to card slot(s). -+ * Daughter card information. - */ --#define mmc_power_on(_n_) \ -- do { \ -- BCSR * const bcsr = (BCSR *)0xAE000000; \ -- unsigned long mmc_pwr, mmc_wp, board_specific; \ -- if ((_n_)) { \ -- mmc_pwr = BCSR_BOARD_SD1_PWR; \ -- mmc_wp = BCSR_BOARD_SD1_WP; \ -- } else { \ -- mmc_pwr = BCSR_BOARD_SD0_PWR; \ -- mmc_wp = BCSR_BOARD_SD0_WP; \ -- } \ -- board_specific = au_readl((unsigned long)(&bcsr->specific)); \ -- if (!(board_specific & mmc_wp)) {/* low means card present */ \ -- board_specific |= mmc_pwr; \ -- au_writel(board_specific, (int)(&bcsr->specific)); \ -- au_sync(); \ -- } \ -- } while (0) -+#define DAUGHTER_CARD_IRQ (AU1000_GPIO_8) -+/* DC_IDE */ -+#define AU1XXX_ATA_PHYS_ADDR (0x0C000000) -+#define AU1XXX_ATA_REG_OFFSET (5) -+#endif /* CONFIG_MIPS_DB1550 */ - - #endif /* __ASM_DB1X00_H */ - ---- a/include/asm-mips/elf.h -+++ b/include/asm-mips/elf.h -@@ -66,9 +66,10 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_N - #define USE_ELF_CORE_DUMP - #define ELF_EXEC_PAGESIZE PAGE_SIZE - --#define ELF_CORE_COPY_REGS(_dest,_regs) \ -- memcpy((char *) &_dest, (char *) _regs, \ -- sizeof(struct pt_regs)); -+extern void dump_regs(elf_greg_t *, struct pt_regs *regs); -+ -+#define ELF_CORE_COPY_REGS(elf_regs, regs) \ -+ dump_regs((elf_greg_t *)&(elf_regs), regs); - - /* This yields a mask that user programs can use to figure out what - instruction set this cpu supports. This could be done in userspace, ---- /dev/null -+++ b/include/asm-mips/ficmmp.h -@@ -0,0 +1,156 @@ -+/* -+ * FIC MMP -+ * -+ * ######################################################################## -+ * -+ * This program is free software; you can distribute 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 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 __ASM_FICMMP_H -+#define __ASM_FICMMP_H -+ -+#include <linux/types.h> -+#include <asm/au1000.h> -+#include <asm/au1xxx_gpio.h> -+ -+// This is defined in au1000.h with bogus value -+#undef AU1X00_EXTERNAL_INT -+ -+#define DBDMA_AC97_TX_CHAN DSCR_CMD0_PSC1_TX -+#define DBDMA_AC97_RX_CHAN DSCR_CMD0_PSC1_RX -+#define DBDMA_I2S_TX_CHAN DSCR_CMD0_PSC1_TX -+#define DBDMA_I2S_RX_CHAN DSCR_CMD0_PSC1_RX -+/* SPI and SMB are muxed on the Pb1200 board. -+ Refer to board documentation. -+ */ -+#define SPI_PSC_BASE PSC0_BASE_ADDR -+#define SMBUS_PSC_BASE PSC0_BASE_ADDR -+/* AC97 and I2S are muxed on the Pb1200 board. -+ Refer to board documentation. -+ */ -+#define AC97_PSC_BASE PSC1_BASE_ADDR -+#define I2S_PSC_BASE PSC1_BASE_ADDR -+ -+ -+/* -+ * SMSC LAN91C111 -+ */ -+#define AU1XXX_SMC91111_PHYS_ADDR (0xAC000300) -+#define AU1XXX_SMC91111_IRQ AU1000_GPIO_5 -+ -+/* DC_IDE and DC_ETHERNET */ -+#define FICMMP_IDE_INT AU1000_GPIO_4 -+ -+#define AU1XXX_ATA_PHYS_ADDR (0x0C800000) -+#define AU1XXX_ATA_REG_OFFSET (5) -+/* -+#define AU1XXX_ATA_BASE (0x0C800000) -+#define AU1XXX_ATA_END (0x0CFFFFFF) -+#define AU1XXX_ATA_MEM_SIZE (AU1XXX_ATA_END - AU1XXX_ATA_BASE +1) -+ -+#define AU1XXX_ATA_REG_OFFSET (5) -+*/ -+/* VPP/VCC */ -+#define SET_VCC_VPP(VCC, VPP, SLOT)\ -+ ((((VCC)<<2) | ((VPP)<<0)) << ((SLOT)*8)) -+ -+ -+#define FICMMP_CONFIG_BASE 0xAD000000 -+#define FICMMP_CONFIG_ENABLE 13 -+ -+#define FICMMP_CONFIG_I2SFREQ(N) (N<<0) -+#define FICMMP_CONFIG_I2SXTAL0 (1<<0) -+#define FICMMP_CONFIG_I2SXTAL1 (1<<1) -+#define FICMMP_CONFIG_I2SXTAL2 (1<<2) -+#define FICMMP_CONFIG_I2SXTAL3 (1<<3) -+#define FICMMP_CONFIG_ADV1 (1<<4) -+#define FICMMP_CONFIG_IDERST (1<<5) -+#define FICMMP_CONFIG_LCMEN (1<<6) -+#define FICMMP_CONFIG_CAMPWDN (1<<7) -+#define FICMMP_CONFIG_USBPWREN (1<<8) -+#define FICMMP_CONFIG_LCMPWREN (1<<9) -+#define FICMMP_CONFIG_TVOUTPWREN (1<<10) -+#define FICMMP_CONFIG_RS232PWREN (1<<11) -+#define FICMMP_CONFIG_LCMDATAOUT (1<<12) -+#define FICMMP_CONFIG_TVODATAOUT (1<<13) -+#define FICMMP_CONFIG_ADV3 (1<<14) -+#define FICMMP_CONFIG_ADV4 (1<<15) -+ -+#define I2S_FREQ_8_192 (0x0) -+#define I2S_FREQ_11_2896 (0x1) -+#define I2S_FREQ_12_288 (0x2) -+#define I2S_FREQ_24_576 (0x3) -+//#define I2S_FREQ_12_288 (0x4) -+#define I2S_FREQ_16_9344 (0x5) -+#define I2S_FREQ_18_432 (0x6) -+#define I2S_FREQ_36_864 (0x7) -+#define I2S_FREQ_16_384 (0x8) -+#define I2S_FREQ_22_5792 (0x9) -+//#define I2S_FREQ_24_576 (0x10) -+#define I2S_FREQ_49_152 (0x11) -+//#define I2S_FREQ_24_576 (0x12) -+#define I2S_FREQ_33_8688 (0x13) -+//#define I2S_FREQ_36_864 (0x14) -+#define I2S_FREQ_73_728 (0x15) -+ -+#define FICMMP_IDE_PWR 9 -+#define FICMMP_FOCUS_RST 2 -+ -+static __inline void ficmmp_config_set(u16 bits) -+{ -+ extern u16 ficmmp_config; -+ //printk("set_config: %X, Old: %X, New: %X\n", bits, ficmmp_config, ficmmp_config | bits); -+ ficmmp_config |= bits; -+ *((u16*)FICMMP_CONFIG_BASE) = ficmmp_config; -+} -+ -+static __inline void ficmmp_config_clear(u16 bits) -+{ -+ extern u16 ficmmp_config; -+// printk("clear_config: %X, Old: %X, New: %X\n", bits, ficmmp_config, ficmmp_config & ~bits); -+ ficmmp_config &= ~bits; -+ *((u16*)FICMMP_CONFIG_BASE) = ficmmp_config; -+} -+ -+static __inline void ficmmp_config_init(void) -+{ -+ au1xxx_gpio_write(FICMMP_CONFIG_ENABLE, 0); //Enable configuration latch -+ ficmmp_config_set(FICMMP_CONFIG_LCMDATAOUT | FICMMP_CONFIG_TVODATAOUT | FICMMP_CONFIG_IDERST); //Disable display data buffers -+ ficmmp_config_set(FICMMP_CONFIG_I2SFREQ(I2S_FREQ_36_864)); -+} -+ -+static __inline u32 ficmmp_set_i2s_sample_rate(u32 rate) -+{ -+ u32 freq; -+ -+ switch(rate) -+ { -+ case 88200: -+ case 44100: -+ case 8018: freq = I2S_FREQ_11_2896; break; -+ case 48000: -+ case 32000: //freq = I2S_FREQ_18_432; break; -+ case 8000: freq = I2S_FREQ_12_288; break; -+ default: freq = I2S_FREQ_12_288; rate = 8000; -+ } -+ ficmmp_config_clear(FICMMP_CONFIG_I2SFREQ(0xF)); -+ ficmmp_config_set(FICMMP_CONFIG_I2SFREQ(freq)); -+ return rate; -+} -+ -+#endif /* __ASM_FICMMP_H */ -+ ---- a/include/asm-mips/hazards.h -+++ b/include/asm-mips/hazards.h -@@ -3,7 +3,7 @@ - * License. See the file "COPYING" in the main directory of this archive - * for more details. - * -- * Copyright (C) 2003 Ralf Baechle -+ * Copyright (C) 2003, 2004 Ralf Baechle - */ - #ifndef _ASM_HAZARDS_H - #define _ASM_HAZARDS_H -@@ -12,38 +12,200 @@ - - #ifdef __ASSEMBLY__ - -+ .macro _ssnop -+ sll $0, $0, 1 -+ .endm -+ - /* - * RM9000 hazards. When the JTLB is updated by tlbwi or tlbwr, a subsequent - * use of the JTLB for instructions should not occur for 4 cpu cycles and use - * for data translations should not occur for 3 cpu cycles. - */ - #ifdef CONFIG_CPU_RM9000 --#define rm9000_tlb_hazard \ -+ -+#define mtc0_tlbw_hazard \ - .set push; \ - .set mips32; \ -- ssnop; ssnop; ssnop; ssnop; \ -+ _ssnop; _ssnop; _ssnop; _ssnop; \ - .set pop -+ -+#define tlbw_eret_hazard \ -+ .set push; \ -+ .set mips32; \ -+ _ssnop; _ssnop; _ssnop; _ssnop; \ -+ .set pop -+ - #else --#define rm9000_tlb_hazard -+ -+/* -+ * The taken branch will result in a two cycle penalty for the two killed -+ * instructions on R4000 / R4400. Other processors only have a single cycle -+ * hazard so this is nice trick to have an optimal code for a range of -+ * processors. -+ */ -+#define mtc0_tlbw_hazard \ -+ b . + 8 -+#define tlbw_eret_hazard \ -+ nop - #endif - -+/* -+ * mtc0->mfc0 hazard -+ * The 24K has a 2 cycle mtc0/mfc0 execution hazard. -+ * It is a MIPS32R2 processor so ehb will clear the hazard. -+ */ -+ -+#ifdef CONFIG_CPU_MIPSR2 -+/* -+ * Use a macro for ehb unless explicit support for MIPSR2 is enabled -+ */ -+ .macro ehb -+ sll $0, $0, 3 -+ .endm -+ -+#define irq_enable_hazard \ -+ ehb # irq_enable_hazard -+ -+#define irq_disable_hazard \ -+ ehb # irq_disable_hazard -+ -+#elif defined(CONFIG_CPU_R10000) || defined(CONFIG_CPU_RM9000) -+ -+/* -+ * R10000 rocks - all hazards handled in hardware, so this becomes a nobrainer. -+ */ -+ -+#define irq_enable_hazard -+ -+#define irq_disable_hazard -+ - #else - - /* -+ * Classic MIPS needs 1 - 3 nops or ssnops -+ */ -+#define irq_enable_hazard -+#define irq_disable_hazard \ -+ _ssnop; _ssnop; _ssnop -+ -+#endif -+ -+#else /* __ASSEMBLY__ */ -+ -+/* - * RM9000 hazards. When the JTLB is updated by tlbwi or tlbwr, a subsequent - * use of the JTLB for instructions should not occur for 4 cpu cycles and use - * for data translations should not occur for 3 cpu cycles. - */ - #ifdef CONFIG_CPU_RM9000 --#define rm9000_tlb_hazard() \ -+ -+#define mtc0_tlbw_hazard() \ - __asm__ __volatile__( \ - ".set\tmips32\n\t" \ -- "ssnop; ssnop; ssnop; ssnop\n\t" \ -+ "_ssnop; _ssnop; _ssnop; _ssnop\n\t" \ -+ ".set\tmips0") -+ -+#define tlbw_use_hazard() \ -+ __asm__ __volatile__( \ -+ ".set\tmips32\n\t" \ -+ "_ssnop; _ssnop; _ssnop; _ssnop\n\t" \ - ".set\tmips0") - #else --#define rm9000_tlb_hazard() do { } while (0) -+ -+/* -+ * Overkill warning ... -+ */ -+#define mtc0_tlbw_hazard() \ -+ __asm__ __volatile__( \ -+ ".set noreorder\n\t" \ -+ "nop; nop; nop; nop; nop; nop;\n\t" \ -+ ".set reorder\n\t") -+ -+#define tlbw_use_hazard() \ -+ __asm__ __volatile__( \ -+ ".set noreorder\n\t" \ -+ "nop; nop; nop; nop; nop; nop;\n\t" \ -+ ".set reorder\n\t") -+ - #endif - -+/* -+ * mtc0->mfc0 hazard -+ * The 24K has a 2 cycle mtc0/mfc0 execution hazard. -+ * It is a MIPS32R2 processor so ehb will clear the hazard. -+ */ -+ -+#ifdef CONFIG_CPU_MIPSR2 -+/* -+ * Use a macro for ehb unless explicit support for MIPSR2 is enabled -+ */ -+__asm__( -+ " .macro ehb \n\t" -+ " sll $0, $0, 3 \n\t" -+ " .endm \n\t" -+ " \n\t" -+ " .macro\tirq_enable_hazard \n\t" -+ " ehb \n\t" -+ " .endm \n\t" -+ " \n\t" -+ " .macro\tirq_disable_hazard \n\t" -+ " ehb \n\t" -+ " .endm"); -+ -+#define irq_enable_hazard() \ -+ __asm__ __volatile__( \ -+ "ehb\t\t\t\t# irq_enable_hazard") -+ -+#define irq_disable_hazard() \ -+ __asm__ __volatile__( \ -+ "ehb\t\t\t\t# irq_disable_hazard") -+ -+#elif defined(CONFIG_CPU_R10000) -+ -+/* -+ * R10000 rocks - all hazards handled in hardware, so this becomes a nobrainer. -+ */ -+ -+__asm__( -+ " .macro\tirq_enable_hazard \n\t" -+ " .endm \n\t" -+ " \n\t" -+ " .macro\tirq_disable_hazard \n\t" -+ " .endm"); -+ -+#define irq_enable_hazard() do { } while (0) -+#define irq_disable_hazard() do { } while (0) -+ -+#else -+ -+/* -+ * Default for classic MIPS processors. Assume worst case hazards but don't -+ * care about the irq_enable_hazard - sooner or later the hardware will -+ * enable it and we don't care when exactly. -+ */ -+ -+__asm__( -+ " .macro _ssnop \n\t" -+ " sll $0, $2, 1 \n\t" -+ " .endm \n\t" -+ " \n\t" -+ " # \n\t" -+ " # There is a hazard but we do not care \n\t" -+ " # \n\t" -+ " .macro\tirq_enable_hazard \n\t" -+ " .endm \n\t" -+ " \n\t" -+ " .macro\tirq_disable_hazard \n\t" -+ " _ssnop; _ssnop; _ssnop \n\t" -+ " .endm"); -+ -+#define irq_enable_hazard() do { } while (0) -+#define irq_disable_hazard() \ -+ __asm__ __volatile__( \ -+ "_ssnop; _ssnop; _ssnop;\t\t# irq_disable_hazard") -+ - #endif - -+#endif /* __ASSEMBLY__ */ -+ - #endif /* _ASM_HAZARDS_H */ ---- a/include/asm-mips/ide.h -+++ b/include/asm-mips/ide.h -@@ -32,12 +32,12 @@ struct ide_ops { - - extern struct ide_ops *ide_ops; - --static __inline__ int ide_default_irq(ide_ioreg_t base) -+static inline int ide_default_irq(ide_ioreg_t base) - { - return ide_ops->ide_default_irq(base); - } - --static __inline__ ide_ioreg_t ide_default_io_base(int index) -+static inline ide_ioreg_t ide_default_io_base(int index) - { - return ide_ops->ide_default_io_base(index); - } -@@ -48,7 +48,7 @@ static inline void ide_init_hwif_ports(h - ide_ops->ide_init_hwif_ports(hw, data_port, ctrl_port, irq); - } - --static __inline__ void ide_init_default_hwifs(void) -+static inline void ide_init_default_hwifs(void) - { - #ifndef CONFIG_BLK_DEV_IDEPCI - hw_regs_t hw; -@@ -68,7 +68,89 @@ static __inline__ void ide_init_default_ - #define ide_ack_intr(hwif) ((hwif)->hw.ack_intr ? (hwif)->hw.ack_intr(hwif) : 1) - #endif - --#include <asm-generic/ide_iops.h> -+/* MIPS port and memory-mapped I/O string operations. */ -+ -+static inline void __ide_flush_dcache_range(unsigned long addr, unsigned long size) -+{ -+ if (cpu_has_dc_aliases) { -+ unsigned long end = addr + size; -+ for (; addr < end; addr += PAGE_SIZE) -+ flush_dcache_page(virt_to_page(addr)); -+ } -+} -+ -+static inline void __ide_insw(unsigned long port, void *addr, -+ unsigned int count) -+{ -+ insw(port, addr, count); -+ __ide_flush_dcache_range((unsigned long)addr, count * 2); -+} -+ -+static inline void __ide_insl(unsigned long port, void *addr, unsigned int count) -+{ -+ insl(port, addr, count); -+ __ide_flush_dcache_range((unsigned long)addr, count * 4); -+} -+ -+static inline void __ide_outsw(unsigned long port, const void *addr, -+ unsigned long count) -+{ -+ outsw(port, addr, count); -+ __ide_flush_dcache_range((unsigned long)addr, count * 2); -+} -+ -+static inline void __ide_outsl(unsigned long port, const void *addr, -+ unsigned long count) -+{ -+ outsl(port, addr, count); -+ __ide_flush_dcache_range((unsigned long)addr, count * 4); -+} -+ -+static inline void __ide_mm_insw(unsigned long port, void *addr, u32 count) -+{ -+ unsigned long start = (unsigned long) addr; -+ -+ while (count--) { -+ *(u16 *)addr = readw(port); -+ addr += 2; -+ } -+ __ide_flush_dcache_range(start, count * 2); -+} -+ -+static inline void __ide_mm_insl(unsigned long port, void *addr, u32 count) -+{ -+ unsigned long start = (unsigned long) addr; -+ -+ while (count--) { -+ *(u32 *)addr = readl(port); -+ addr += 4; -+ } -+ __ide_flush_dcache_range(start, count * 4); -+} -+ -+static inline void __ide_mm_outsw(unsigned long port, const void *addr, -+ u32 count) -+{ -+ unsigned long start = (unsigned long) addr; -+ -+ while (count--) { -+ writew(*(u16 *)addr, port); -+ addr += 2; -+ } -+ __ide_flush_dcache_range(start, count * 2); -+} -+ -+static inline void __ide_mm_outsl(unsigned long port, const void *addr, -+ u32 count) -+{ -+ unsigned long start = (unsigned long) addr; -+ -+ while (count--) { -+ writel(*(u32 *)addr, port); -+ addr += 4; -+ } -+ __ide_flush_dcache_range(start, count * 4); -+} - - #endif /* __KERNEL__ */ - ---- a/include/asm-mips/io.h -+++ b/include/asm-mips/io.h -@@ -392,7 +392,8 @@ static inline unsigned int inl_p(unsigne - return __ioswab32(__val); - } - --static inline void __outsb(unsigned long port, void *addr, unsigned int count) -+static inline void __outsb(unsigned long port, const void *addr, -+ unsigned int count) - { - while (count--) { - outb(*(u8 *)addr, port); -@@ -408,7 +409,8 @@ static inline void __insb(unsigned long - } - } - --static inline void __outsw(unsigned long port, void *addr, unsigned int count) -+static inline void __outsw(unsigned long port, const void *addr, -+ unsigned int count) - { - while (count--) { - outw(*(u16 *)addr, port); -@@ -424,7 +426,8 @@ static inline void __insw(unsigned long - } - } - --static inline void __outsl(unsigned long port, void *addr, unsigned int count) -+static inline void __outsl(unsigned long port, const void *addr, -+ unsigned int count) - { - while (count--) { - outl(*(u32 *)addr, port); ---- a/include/asm-mips/mipsregs.h -+++ b/include/asm-mips/mipsregs.h -@@ -757,10 +757,18 @@ do { \ - #define read_c0_config1() __read_32bit_c0_register($16, 1) - #define read_c0_config2() __read_32bit_c0_register($16, 2) - #define read_c0_config3() __read_32bit_c0_register($16, 3) -+#define read_c0_config4() __read_32bit_c0_register($16, 4) -+#define read_c0_config5() __read_32bit_c0_register($16, 5) -+#define read_c0_config6() __read_32bit_c0_register($16, 6) -+#define read_c0_config7() __read_32bit_c0_register($16, 7) - #define write_c0_config(val) __write_32bit_c0_register($16, 0, val) - #define write_c0_config1(val) __write_32bit_c0_register($16, 1, val) - #define write_c0_config2(val) __write_32bit_c0_register($16, 2, val) - #define write_c0_config3(val) __write_32bit_c0_register($16, 3, val) -+#define write_c0_config4(val) __write_32bit_c0_register($16, 4, val) -+#define write_c0_config5(val) __write_32bit_c0_register($16, 5, val) -+#define write_c0_config6(val) __write_32bit_c0_register($16, 6, val) -+#define write_c0_config7(val) __write_32bit_c0_register($16, 7, val) - - /* - * The WatchLo register. There may be upto 8 of them. -@@ -874,42 +882,34 @@ do { \ - */ - static inline void tlb_probe(void) - { -- rm9000_tlb_hazard(); - __asm__ __volatile__( - ".set noreorder\n\t" - "tlbp\n\t" - ".set reorder"); -- rm9000_tlb_hazard(); - } - - static inline void tlb_read(void) - { -- rm9000_tlb_hazard(); - __asm__ __volatile__( - ".set noreorder\n\t" - "tlbr\n\t" - ".set reorder"); -- rm9000_tlb_hazard(); - } - - static inline void tlb_write_indexed(void) - { -- rm9000_tlb_hazard(); - __asm__ __volatile__( - ".set noreorder\n\t" - "tlbwi\n\t" - ".set reorder"); -- rm9000_tlb_hazard(); - } - - static inline void tlb_write_random(void) - { -- rm9000_tlb_hazard(); - __asm__ __volatile__( - ".set noreorder\n\t" - "tlbwr\n\t" - ".set reorder"); -- rm9000_tlb_hazard(); - } - - /* ---- a/include/asm-mips/mmu_context.h -+++ b/include/asm-mips/mmu_context.h -@@ -27,7 +27,7 @@ - #define TLBMISS_HANDLER_SETUP_PGD(pgd) \ - pgd_current[smp_processor_id()] = (unsigned long)(pgd) - #define TLBMISS_HANDLER_SETUP() \ -- write_c0_context((unsigned long) smp_processor_id() << (23 + 3)); \ -+ write_c0_context((unsigned long) smp_processor_id() << 23); \ - TLBMISS_HANDLER_SETUP_PGD(swapper_pg_dir) - extern unsigned long pgd_current[]; - ---- a/include/asm-mips/pb1100.h -+++ b/include/asm-mips/pb1100.h -@@ -1,5 +1,5 @@ - /* -- * Alchemy Semi PB1100 Referrence Board -+ * AMD Alchemy PB1100 Reference Boards - * - * Copyright 2001 MontaVista Software Inc. - * Author: MontaVista Software, Inc. -@@ -27,55 +27,108 @@ - #ifndef __ASM_PB1100_H - #define __ASM_PB1100_H - --#define PB1100_IDENT 0xAE000000 --#define BOARD_STATUS_REG 0xAE000004 -- #define PB1100_ROM_SEL (1<<15) -- #define PB1100_ROM_SIZ (1<<14) -- #define PB1100_SWAP_BOOT (1<<13) -- #define PB1100_FLASH_WP (1<<12) -- #define PB1100_ROM_H_STS (1<<11) -- #define PB1100_ROM_L_STS (1<<10) -- #define PB1100_FLASH_H_STS (1<<9) -- #define PB1100_FLASH_L_STS (1<<8) -- #define PB1100_SRAM_SIZ (1<<7) -- #define PB1100_TSC_BUSY (1<<6) -- #define PB1100_PCMCIA_VS_MASK (3<<4) -- #define PB1100_RS232_CD (1<<3) -- #define PB1100_RS232_CTS (1<<2) -- #define PB1100_RS232_DSR (1<<1) -- #define PB1100_RS232_RI (1<<0) -- --#define PB1100_IRDA_RS232 0xAE00000C -- #define PB1100_IRDA_FULL (0<<14) /* full power */ -- #define PB1100_IRDA_SHUTDOWN (1<<14) -- #define PB1100_IRDA_TT (2<<14) /* 2/3 power */ -- #define PB1100_IRDA_OT (3<<14) /* 1/3 power */ -- #define PB1100_IRDA_FIR (1<<13) -- --#define PCMCIA_BOARD_REG 0xAE000010 -- #define PB1100_SD_WP1_RO (1<<15) /* read only */ -- #define PB1100_SD_WP0_RO (1<<14) /* read only */ -- #define PB1100_SD_PWR1 (1<<11) /* applies power to SD1 */ -- #define PB1100_SD_PWR0 (1<<10) /* applies power to SD0 */ -- #define PB1100_SEL_SD_CONN1 (1<<9) -- #define PB1100_SEL_SD_CONN0 (1<<8) -- #define PC_DEASSERT_RST (1<<7) -- #define PC_DRV_EN (1<<4) -- --#define PB1100_G_CONTROL 0xAE000014 /* graphics control */ -- --#define PB1100_RST_VDDI 0xAE00001C -- #define PB1100_SOFT_RESET (1<<15) /* clear to reset the board */ -- #define PB1100_VDDI_MASK (0x1F) -+#define BCSR_KSEG1_ADDR 0xAE000000 -+ -+/* -+ * Overlay data structure of the Pb1100 board registers. -+ * Registers located at physical 0E0000xx, KSEG1 0xAE0000xx -+ */ -+typedef volatile struct -+{ -+ /*00*/ unsigned short whoami; -+ unsigned short reserved0; -+ /*04*/ unsigned short status; -+ unsigned short reserved1; -+ /*08*/ unsigned short switches; -+ unsigned short reserved2; -+ /*0C*/ unsigned short resets; -+ unsigned short reserved3; -+ /*10*/ unsigned short pcmcia; -+ unsigned short reserved4; -+ /*14*/ unsigned short graphics; -+ unsigned short reserved5; -+ /*18*/ unsigned short leds; -+ unsigned short reserved6; -+ /*1C*/ unsigned short swreset; -+ unsigned short reserved7; -+ -+} BCSR; - --#define PB1100_LEDS 0xAE000018 - --/* 11:8 is 4 discreet LEDs. Clearing a bit illuminates the LED. -- * 7:0 is the LED Display's decimal points. -+/* -+ * Register/mask bit definitions for the BCSRs - */ --#define PB1100_HEX_LED 0xAE000018 -+#define BCSR_WHOAMI_DCID 0x000F -+#define BCSR_WHOAMI_CPLD 0x00F0 -+#define BCSR_WHOAMI_BOARD 0x0F00 -+ -+#define BCSR_STATUS_RS232_RI 0x0001 -+#define BCSR_STATUS_RS232_DSR 0x0002 -+#define BCSR_STATUS_RS232_CTS 0x0004 -+#define BCSR_STATUS_RS232_CD 0x0008 -+#define BCSR_STATUS_PCMCIA_VS_MASK 0x0030 -+#define BCSR_STATUS_TSC_BUSY 0x0040 -+#define BCSR_STATUS_SRAM_SIZ 0x0080 -+#define BCSR_STATUS_FLASH_L_STS 0x0100 -+#define BCSR_STATUS_FLASH_H_STS 0x0200 -+#define BCSR_STATUS_ROM_H_STS 0x0400 -+#define BCSR_STATUS_ROM_L_STS 0x0800 -+#define BCSR_STATUS_FLASH_WP 0x1000 -+#define BCSR_STATUS_SWAP_BOOT 0x2000 -+#define BCSR_STATUS_ROM_SIZ 0x4000 -+#define BCSR_STATUS_ROM_SEL 0x8000 -+ -+#define BCSR_SWITCHES_DIP 0x00FF -+#define BCSR_SWITCHES_DIP_1 0x0080 -+#define BCSR_SWITCHES_DIP_2 0x0040 -+#define BCSR_SWITCHES_DIP_3 0x0020 -+#define BCSR_SWITCHES_DIP_4 0x0010 -+#define BCSR_SWITCHES_DIP_5 0x0008 -+#define BCSR_SWITCHES_DIP_6 0x0004 -+#define BCSR_SWITCHES_DIP_7 0x0002 -+#define BCSR_SWITCHES_DIP_8 0x0001 -+#define BCSR_SWITCHES_ROTARY 0x0F00 -+#define BCSR_SWITCHES_SDO_CL 0x8000 -+ -+#define BCSR_RESETS_PHY0 0x0001 -+#define BCSR_RESETS_PHY1 0x0002 -+#define BCSR_RESETS_DC 0x0004 -+#define BCSR_RESETS_RS232_RTS 0x0100 -+#define BCSR_RESETS_RS232_DTR 0x0200 -+#define BCSR_RESETS_FIR_SEL 0x2000 -+#define BCSR_RESETS_IRDA_MODE_MASK 0xC000 -+#define BCSR_RESETS_IRDA_MODE_FULL 0x0000 -+#define BCSR_RESETS_IRDA_MODE_OFF 0x4000 -+#define BCSR_RESETS_IRDA_MODE_2_3 0x8000 -+#define BCSR_RESETS_IRDA_MODE_1_3 0xC000 -+ -+#define BCSR_PCMCIA_PC0VPP 0x0003 -+#define BCSR_PCMCIA_PC0VCC 0x000C -+#define BCSR_PCMCIA_PC0_DR_VEN 0x0010 -+#define BCSR_PCMCIA_PC0RST 0x0080 -+#define BCSR_PCMCIA_SEL_SD_CON0 0x0100 -+#define BCSR_PCMCIA_SEL_SD_CON1 0x0200 -+#define BCSR_PCMCIA_SD0_PWR 0x0400 -+#define BCSR_PCMCIA_SD1_PWR 0x0800 -+#define BCSR_PCMCIA_SD0_WP 0x4000 -+#define BCSR_PCMCIA_SD1_WP 0x8000 -+ -+#define PB1100_G_CONTROL 0xAE000014 -+#define BCSR_GRAPHICS_GPX_SMPASS 0x0010 -+#define BCSR_GRAPHICS_GPX_BIG_ENDIAN 0x0020 -+#define BCSR_GRAPHICS_GPX_RST 0x0040 -+ -+#define BCSR_LEDS_DECIMALS 0x00FF -+#define BCSR_LEDS_LED0 0x0100 -+#define BCSR_LEDS_LED1 0x0200 -+#define BCSR_LEDS_LED2 0x0400 -+#define BCSR_LEDS_LED3 0x0800 -+ -+#define BCSR_SWRESET_RESET 0x0080 -+#define BCSR_VDDI_VDI 0x001F - --/* PCMCIA PB1100 specific defines */ -+ -+ /* PCMCIA Pb1x00 specific defines */ - #define PCMCIA_MAX_SOCK 0 - #define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK+1) - -@@ -83,3 +136,4 @@ - #define SET_VCC_VPP(VCC, VPP) (((VCC)<<2) | ((VPP)<<0)) - - #endif /* __ASM_PB1100_H */ -+ ---- /dev/null -+++ b/include/asm-mips/pb1200.h -@@ -0,0 +1,244 @@ -+/* -+ * AMD Alchemy PB1200 Referrence Board -+ * Board Registers defines. -+ * -+ * ######################################################################## -+ * -+ * This program is free software; you can distribute 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 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 __ASM_PB1200_H -+#define __ASM_PB1200_H -+ -+#include <linux/types.h> -+ -+// This is defined in au1000.h with bogus value -+#undef AU1X00_EXTERNAL_INT -+ -+#define DBDMA_AC97_TX_CHAN DSCR_CMD0_PSC1_TX -+#define DBDMA_AC97_RX_CHAN DSCR_CMD0_PSC1_RX -+#define DBDMA_I2S_TX_CHAN DSCR_CMD0_PSC1_TX -+#define DBDMA_I2S_RX_CHAN DSCR_CMD0_PSC1_RX -+ -+/* SPI and SMB are muxed on the Pb1200 board. -+ Refer to board documentation. -+ */ -+#define SPI_PSC_BASE PSC0_BASE_ADDR -+#define SMBUS_PSC_BASE PSC0_BASE_ADDR -+/* AC97 and I2S are muxed on the Pb1200 board. -+ Refer to board documentation. -+ */ -+#define AC97_PSC_BASE PSC1_BASE_ADDR -+#define I2S_PSC_BASE PSC1_BASE_ADDR -+ -+#define BCSR_KSEG1_ADDR 0xAD800000 -+ -+typedef volatile struct -+{ -+ /*00*/ u16 whoami; -+ u16 reserved0; -+ /*04*/ u16 status; -+ u16 reserved1; -+ /*08*/ u16 switches; -+ u16 reserved2; -+ /*0C*/ u16 resets; -+ u16 reserved3; -+ -+ /*10*/ u16 pcmcia; -+ u16 reserved4; -+ /*14*/ u16 board; -+ u16 reserved5; -+ /*18*/ u16 disk_leds; -+ u16 reserved6; -+ /*1C*/ u16 system; -+ u16 reserved7; -+ -+ /*20*/ u16 intclr; -+ u16 reserved8; -+ /*24*/ u16 intset; -+ u16 reserved9; -+ /*28*/ u16 intclr_mask; -+ u16 reserved10; -+ /*2C*/ u16 intset_mask; -+ u16 reserved11; -+ -+ /*30*/ u16 sig_status; -+ u16 reserved12; -+ /*34*/ u16 int_status; -+ u16 reserved13; -+ /*38*/ u16 reserved14; -+ u16 reserved15; -+ /*3C*/ u16 reserved16; -+ u16 reserved17; -+ -+} BCSR; -+ -+static BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR; -+ -+/* -+ * Register bit definitions for the BCSRs -+ */ -+#define BCSR_WHOAMI_DCID 0x000F -+#define BCSR_WHOAMI_CPLD 0x00F0 -+#define BCSR_WHOAMI_BOARD 0x0F00 -+ -+#define BCSR_STATUS_PCMCIA0VS 0x0003 -+#define BCSR_STATUS_PCMCIA1VS 0x000C -+#define BCSR_STATUS_SWAPBOOT 0x0040 -+#define BCSR_STATUS_FLASHBUSY 0x0100 -+#define BCSR_STATUS_IDECBLID 0x0200 -+#define BCSR_STATUS_SD0WP 0x0400 -+#define BCSR_STATUS_SD1WP 0x0800 -+#define BCSR_STATUS_U0RXD 0x1000 -+#define BCSR_STATUS_U1RXD 0x2000 -+ -+#define BCSR_SWITCHES_OCTAL 0x00FF -+#define BCSR_SWITCHES_DIP_1 0x0080 -+#define BCSR_SWITCHES_DIP_2 0x0040 -+#define BCSR_SWITCHES_DIP_3 0x0020 -+#define BCSR_SWITCHES_DIP_4 0x0010 -+#define BCSR_SWITCHES_DIP_5 0x0008 -+#define BCSR_SWITCHES_DIP_6 0x0004 -+#define BCSR_SWITCHES_DIP_7 0x0002 -+#define BCSR_SWITCHES_DIP_8 0x0001 -+#define BCSR_SWITCHES_ROTARY 0x0F00 -+ -+#define BCSR_RESETS_ETH 0x0001 -+#define BCSR_RESETS_CAMERA 0x0002 -+#define BCSR_RESETS_DC 0x0004 -+#define BCSR_RESETS_IDE 0x0008 -+/* not resets but in the same register */ -+#define BCSR_RESETS_WSCFSM 0x0800 -+#define BCSR_RESETS_PCS0MUX 0x1000 -+#define BCSR_RESETS_PCS1MUX 0x2000 -+#define BCSR_RESETS_SPISEL 0x4000 -+#define BCSR_RESETS_SD1MUX 0x8000 -+ -+#define BCSR_PCMCIA_PC0VPP 0x0003 -+#define BCSR_PCMCIA_PC0VCC 0x000C -+#define BCSR_PCMCIA_PC0DRVEN 0x0010 -+#define BCSR_PCMCIA_PC0RST 0x0080 -+#define BCSR_PCMCIA_PC1VPP 0x0300 -+#define BCSR_PCMCIA_PC1VCC 0x0C00 -+#define BCSR_PCMCIA_PC1DRVEN 0x1000 -+#define BCSR_PCMCIA_PC1RST 0x8000 -+ -+#define BCSR_BOARD_LCDVEE 0x0001 -+#define BCSR_BOARD_LCDVDD 0x0002 -+#define BCSR_BOARD_LCDBL 0x0004 -+#define BCSR_BOARD_CAMSNAP 0x0010 -+#define BCSR_BOARD_CAMPWR 0x0020 -+#define BCSR_BOARD_SD0PWR 0x0040 -+#define BCSR_BOARD_SD1PWR 0x0080 -+ -+#define BCSR_LEDS_DECIMALS 0x00FF -+#define BCSR_LEDS_LED0 0x0100 -+#define BCSR_LEDS_LED1 0x0200 -+#define BCSR_LEDS_LED2 0x0400 -+#define BCSR_LEDS_LED3 0x0800 -+ -+#define BCSR_SYSTEM_VDDI 0x001F -+#define BCSR_SYSTEM_POWEROFF 0x4000 -+#define BCSR_SYSTEM_RESET 0x8000 -+ -+/* Bit positions for the different interrupt sources */ -+#define BCSR_INT_IDE 0x0001 -+#define BCSR_INT_ETH 0x0002 -+#define BCSR_INT_PC0 0x0004 -+#define BCSR_INT_PC0STSCHG 0x0008 -+#define BCSR_INT_PC1 0x0010 -+#define BCSR_INT_PC1STSCHG 0x0020 -+#define BCSR_INT_DC 0x0040 -+#define BCSR_INT_FLASHBUSY 0x0080 -+#define BCSR_INT_PC0INSERT 0x0100 -+#define BCSR_INT_PC0EJECT 0x0200 -+#define BCSR_INT_PC1INSERT 0x0400 -+#define BCSR_INT_PC1EJECT 0x0800 -+#define BCSR_INT_SD0INSERT 0x1000 -+#define BCSR_INT_SD0EJECT 0x2000 -+#define BCSR_INT_SD1INSERT 0x4000 -+#define BCSR_INT_SD1EJECT 0x8000 -+ -+#define AU1XXX_SMC91111_PHYS_ADDR (0x0D000300) -+#define AU1XXX_SMC91111_IRQ PB1200_ETH_INT -+ -+#define AU1XXX_ATA_PHYS_ADDR (0x0C800000) -+#define AU1XXX_ATA_PHYS_LEN (0x100) -+#define AU1XXX_ATA_REG_OFFSET (5) -+#define AU1XXX_ATA_INT PB1200_IDE_INT -+#define AU1XXX_ATA_DDMA_REQ DSCR_CMD0_DMA_REQ1; -+#define AU1XXX_ATA_RQSIZE 128 -+ -+#define NAND_PHYS_ADDR 0x1C000000 -+ -+/* Timing values as described in databook, * ns value stripped of -+ * lower 2 bits. -+ * These defines are here rather than an SOC1200 generic file because -+ * the parts chosen on another board may be different and may require -+ * different timings. -+ */ -+#define NAND_T_H (18 >> 2) -+#define NAND_T_PUL (30 >> 2) -+#define NAND_T_SU (30 >> 2) -+#define NAND_T_WH (30 >> 2) -+ -+/* Bitfield shift amounts */ -+#define NAND_T_H_SHIFT 0 -+#define NAND_T_PUL_SHIFT 4 -+#define NAND_T_SU_SHIFT 8 -+#define NAND_T_WH_SHIFT 12 -+ -+#define NAND_TIMING ((NAND_T_H & 0xF) << NAND_T_H_SHIFT) | \ -+ ((NAND_T_PUL & 0xF) << NAND_T_PUL_SHIFT) | \ -+ ((NAND_T_SU & 0xF) << NAND_T_SU_SHIFT) | \ -+ ((NAND_T_WH & 0xF) << NAND_T_WH_SHIFT) -+ -+ -+/* -+ * External Interrupts for Pb1200 as of 8/6/2004. -+ * Bit positions in the CPLD registers can be calculated by taking -+ * the interrupt define and subtracting the PB1200_INT_BEGIN value. -+ * *example: IDE bis pos is = 64 - 64 -+ ETH bit pos is = 65 - 64 -+ */ -+#define PB1200_INT_BEGIN (AU1000_LAST_INTC1_INT + 1) -+#define PB1200_IDE_INT (PB1200_INT_BEGIN + 0) -+#define PB1200_ETH_INT (PB1200_INT_BEGIN + 1) -+#define PB1200_PC0_INT (PB1200_INT_BEGIN + 2) -+#define PB1200_PC0_STSCHG_INT (PB1200_INT_BEGIN + 3) -+#define PB1200_PC1_INT (PB1200_INT_BEGIN + 4) -+#define PB1200_PC1_STSCHG_INT (PB1200_INT_BEGIN + 5) -+#define PB1200_DC_INT (PB1200_INT_BEGIN + 6) -+#define PB1200_FLASHBUSY_INT (PB1200_INT_BEGIN + 7) -+#define PB1200_PC0_INSERT_INT (PB1200_INT_BEGIN + 8) -+#define PB1200_PC0_EJECT_INT (PB1200_INT_BEGIN + 9) -+#define PB1200_PC1_INSERT_INT (PB1200_INT_BEGIN + 10) -+#define PB1200_PC1_EJECT_INT (PB1200_INT_BEGIN + 11) -+#define PB1200_SD0_INSERT_INT (PB1200_INT_BEGIN + 12) -+#define PB1200_SD0_EJECT_INT (PB1200_INT_BEGIN + 13) -+#define PB1200_SD1_INSERT_INT (PB1200_INT_BEGIN + 14) -+#define PB1200_SD1_EJECT_INT (PB1200_INT_BEGIN + 15) -+ -+#define PB1200_INT_END (PB1200_INT_BEGIN + 15) -+ -+/* For drivers/pcmcia/au1000_db1x00.c */ -+#define BOARD_PC0_INT PB1200_PC0_INT -+#define BOARD_PC1_INT PB1200_PC1_INT -+#define BOARD_CARD_INSERTED(SOCKET) bcsr->sig_status & (1<<(8+(2*SOCKET))) -+ -+#endif /* __ASM_PB1200_H */ -+ ---- a/include/asm-mips/pb1550.h -+++ b/include/asm-mips/pb1550.h -@@ -30,13 +30,11 @@ - - #define DBDMA_AC97_TX_CHAN DSCR_CMD0_PSC1_TX - #define DBDMA_AC97_RX_CHAN DSCR_CMD0_PSC1_RX --#define DBDMA_I2S_TX_CHAN DSCR_CMD0_PSC3_TX --#define DBDMA_I2S_RX_CHAN DSCR_CMD0_PSC3_RX -- - #define SPI_PSC_BASE PSC0_BASE_ADDR - #define AC97_PSC_BASE PSC1_BASE_ADDR - #define SMBUS_PSC_BASE PSC2_BASE_ADDR - #define I2S_PSC_BASE PSC3_BASE_ADDR -+#define NAND_CS 1 - - #define BCSR_PHYS_ADDR 0xAF000000 - -@@ -160,9 +158,23 @@ static BCSR * const bcsr = (BCSR *)BCSR_ - #define NAND_T_SU_SHIFT 8 - #define NAND_T_WH_SHIFT 12 - --#define NAND_TIMING ((NAND_T_H & 0xF) << NAND_T_H_SHIFT) | \ -- ((NAND_T_PUL & 0xF) << NAND_T_PUL_SHIFT) | \ -- ((NAND_T_SU & 0xF) << NAND_T_SU_SHIFT) | \ -- ((NAND_T_WH & 0xF) << NAND_T_WH_SHIFT) -+#define NAND_TIMING ((NAND_T_H & 0xF) << NAND_T_H_SHIFT) | \ -+ ((NAND_T_PUL & 0xF) << NAND_T_PUL_SHIFT) | \ -+ ((NAND_T_SU & 0xF) << NAND_T_SU_SHIFT) | \ -+ ((NAND_T_WH & 0xF) << NAND_T_WH_SHIFT) -+ -+/* -+ * Daughter card information. -+ */ -+#define DAUGHTER_CARD_BASE (0xAC000000) -+#define DAUGHTER_CARD_MEM_SIZE (0xADFFFFFF - DAUGHTER_CARD_BASE + 1) -+#define DAUGHTER_CARD_IRQ (AU1000_GPIO_3) -+ -+/* DC_IDE and DC_ETHERNET */ -+#define AU1XXX_ATA_PHYS_ADDR (0x0C000000) -+#define AU1XXX_ATA_REG_OFFSET (5) -+ -+#define AU1XXX_SMC91111_PHYS_ADDR (0x0C000300) -+#define AU1XXX_SMC91111_IRQ AU1000_GPIO_3 - - #endif /* __ASM_PB1550_H */ ---- a/include/asm-mips/reg.h -+++ b/include/asm-mips/reg.h -@@ -45,6 +45,9 @@ - /* - * k0/k1 unsaved - */ -+#define EF_REG26 32 -+#define EF_REG27 33 -+ - #define EF_REG28 34 - #define EF_REG29 35 - #define EF_REG30 36 -@@ -60,6 +63,7 @@ - #define EF_CP0_BADVADDR 41 - #define EF_CP0_STATUS 42 - #define EF_CP0_CAUSE 43 -+#define EF_UNUSED0 44 - - #define EF_SIZE 180 /* size in bytes */ - ---- a/include/asm-mips/sgi/hpc3.h -+++ b/include/asm-mips/sgi/hpc3.h -@@ -128,26 +128,26 @@ struct hpc3_ethregs { - volatile u32 rx_gfptr; /* current GIO fifo ptr */ - volatile u32 rx_dfptr; /* current device fifo ptr */ - u32 _unused1; /* padding */ -- volatile u32 rx_reset; /* reset register */ --#define HPC3_ERXRST_CRESET 0x1 /* Reset dma channel and external controller */ --#define HPC3_ERXRST_CLRIRQ 0x2 /* Clear channel interrupt */ --#define HPC3_ERXRST_LBACK 0x4 /* Enable diagnostic loopback mode of Seeq8003 */ -- -- volatile u32 rx_dconfig; /* DMA configuration register */ --#define HPC3_ERXDCFG_D1 0x0000f /* Cycles to spend in D1 state for PIO */ --#define HPC3_ERXDCFG_D2 0x000f0 /* Cycles to spend in D2 state for PIO */ --#define HPC3_ERXDCFG_D3 0x00f00 /* Cycles to spend in D3 state for PIO */ --#define HPC3_ERXDCFG_WCTRL 0x01000 /* Enable writes of desc into ex ctrl port */ --#define HPC3_ERXDCFG_FRXDC 0x02000 /* Clear eop stat bits upon rxdc, hw seeq fix */ --#define HPC3_ERXDCFG_FEOP 0x04000 /* Bad packet marker timeout enable */ --#define HPC3_ERXDCFG_FIRQ 0x08000 /* Another bad packet timeout enable */ --#define HPC3_ERXDCFG_PTO 0x30000 /* Programmed timeout value for above two */ -- -- volatile u32 rx_pconfig; /* PIO configuration register */ --#define HPC3_ERXPCFG_P1 0x000f /* Cycles to spend in P1 state for PIO */ --#define HPC3_ERXPCFG_P2 0x00f0 /* Cycles to spend in P2 state for PIO */ --#define HPC3_ERXPCFG_P3 0x0f00 /* Cycles to spend in P3 state for PIO */ --#define HPC3_ERXPCFG_TST 0x1000 /* Diagnistic ram test feature bit */ -+ volatile u32 reset; /* reset register */ -+#define HPC3_ERST_CRESET 0x1 /* Reset dma channel and external controller */ -+#define HPC3_ERST_CLRIRQ 0x2 /* Clear channel interrupt */ -+#define HPC3_ERST_LBACK 0x4 /* Enable diagnostic loopback mode of Seeq8003 */ -+ -+ volatile u32 dconfig; /* DMA configuration register */ -+#define HPC3_EDCFG_D1 0x0000f /* Cycles to spend in D1 state for PIO */ -+#define HPC3_EDCFG_D2 0x000f0 /* Cycles to spend in D2 state for PIO */ -+#define HPC3_EDCFG_D3 0x00f00 /* Cycles to spend in D3 state for PIO */ -+#define HPC3_EDCFG_WCTRL 0x01000 /* Enable writes of desc into ex ctrl port */ -+#define HPC3_EDCFG_FRXDC 0x02000 /* Clear eop stat bits upon rxdc, hw seeq fix */ -+#define HPC3_EDCFG_FEOP 0x04000 /* Bad packet marker timeout enable */ -+#define HPC3_EDCFG_FIRQ 0x08000 /* Another bad packet timeout enable */ -+#define HPC3_EDCFG_PTO 0x30000 /* Programmed timeout value for above two */ -+ -+ volatile u32 pconfig; /* PIO configuration register */ -+#define HPC3_EPCFG_P1 0x000f /* Cycles to spend in P1 state for PIO */ -+#define HPC3_EPCFG_P2 0x00f0 /* Cycles to spend in P2 state for PIO */ -+#define HPC3_EPCFG_P3 0x0f00 /* Cycles to spend in P3 state for PIO */ -+#define HPC3_EPCFG_TST 0x1000 /* Diagnistic ram test feature bit */ - - u32 _unused2[0x1000/4 - 8]; /* padding */ - -@@ -221,7 +221,7 @@ struct hpc3_regs { - #define HPC3_BESTAT_PIDMASK 0x3f700 /* DMA channel parity identifier */ - - u32 _unused1[0x14000/4 - 5]; /* padding */ -- -+ - /* Now direct PIO per-HPC3 peripheral access to external regs. */ - volatile u32 scsi0_ext[256]; /* SCSI channel 0 external regs */ - u32 _unused2[0x7c00/4]; -@@ -304,7 +304,7 @@ struct hpc3_regs { - volatile u32 bbram[8192-50-14]; /* Battery backed ram */ - }; - --/* -+/* - * It is possible to have two HPC3's within the address space on - * one machine, though only having one is more likely on an Indy. - */ ---- a/include/asm-mips/tx4927/tx4927.h -+++ b/include/asm-mips/tx4927/tx4927.h -@@ -88,8 +88,8 @@ - - - /* TX4927 Configuration registers (64-bit registers) */ --#define TX4927_CONFIG_BASE 0xe300 --#define TX4927_CONFIG_CCFG 0xe300 -+#define TX4927_CONFIG_BASE 0xe000 -+#define TX4927_CONFIG_CCFG 0xe000 - #define TX4927_CONFIG_CCFG_RESERVED_42_63 BM_63_42 - #define TX4927_CONFIG_CCFG_WDRST BM_41_41 - #define TX4927_CONFIG_CCFG_WDREXEN BM_40_40 -@@ -124,14 +124,14 @@ - #define TX4927_CONFIG_CCFG_ENDIAN BM_02_02 - #define TX4927_CONFIG_CCFG_ARMODE BM_01_01 - #define TX4927_CONFIG_CCFG_ACEHOLD BM_00_00 --#define TX4927_CONFIG_REVID 0xe308 -+#define TX4927_CONFIG_REVID 0xe008 - #define TX4927_CONFIG_REVID_RESERVED_32_63 BM_32_63 - #define TX4927_CONFIG_REVID_PCODE BM_16_31 - #define TX4927_CONFIG_REVID_MJERREV BM_12_15 - #define TX4927_CONFIG_REVID_MINEREV BM_08_11 - #define TX4927_CONFIG_REVID_MJREV BM_04_07 - #define TX4927_CONFIG_REVID_MINREV BM_00_03 --#define TX4927_CONFIG_PCFG 0xe310 -+#define TX4927_CONFIG_PCFG 0xe010 - #define TX4927_CONFIG_PCFG_RESERVED_57_63 BM_57_63 - #define TX4927_CONFIG_PCFG_DRVDATA BM_56_56 - #define TX4927_CONFIG_PCFG_DRVCB BM_55_55 -@@ -197,10 +197,10 @@ - #define TX4927_CONFIG_PCFG_DMASEL0_SIO1 BM_00_00 - #define TX4927_CONFIG_PCFG_DMASEL0_ACLC0 BM_01_01 - #define TX4927_CONFIG_PCFG_DMASEL0_ACLC2 BM_00_01 --#define TX4927_CONFIG_TOEA 0xe318 -+#define TX4927_CONFIG_TOEA 0xe018 - #define TX4927_CONFIG_TOEA_RESERVED_36_63 BM_36_63 - #define TX4927_CONFIG_TOEA_TOEA BM_00_35 --#define TX4927_CONFIG_CLKCTR 0xe320 -+#define TX4927_CONFIG_CLKCTR 0xe020 - #define TX4927_CONFIG_CLKCTR_RESERVED_26_63 BM_26_63 - #define TX4927_CONFIG_CLKCTR_ACLCKD BM_25_25 - #define TX4927_CONFIG_CLKCTR_PIOCKD BM_24_24 -@@ -223,7 +223,7 @@ - #define TX4927_CONFIG_CLKCTR_TM2RST BM_02_02 - #define TX4927_CONFIG_CLKCTR_SIO0RST BM_01_01 - #define TX4927_CONFIG_CLKCTR_SIO1RST BM_00_00 --#define TX4927_CONFIG_GARBC 0xe330 -+#define TX4927_CONFIG_GARBC 0xe030 - #define TX4927_CONFIG_GARBC_RESERVED_10_63 BM_10_63 - #define TX4927_CONFIG_GARBC_SET_09 BM_09_09 - #define TX4927_CONFIG_GARBC_ARBMD BM_08_08 -@@ -243,7 +243,7 @@ - #define TX4927_CONFIG_GARBC_PRIORITY_H3_PDMAC BM_00_00 - #define TX4927_CONFIG_GARBC_PRIORITY_H3_DMAC BM_01_01 - #define TX4927_CONFIG_GARBC_PRIORITY_H3_BAD_VALUE BM_00_01 --#define TX4927_CONFIG_RAMP 0xe348 -+#define TX4927_CONFIG_RAMP 0xe048 - #define TX4927_CONFIG_RAMP_RESERVED_20_63 BM_20_63 - #define TX4927_CONFIG_RAMP_RAMP BM_00_19 - #define TX4927_CONFIG_LIMIT 0xefff -@@ -456,7 +456,7 @@ - #define TX4927_ACLC_ACINTSTS 0xf710 - #define TX4927_ACLC_ACINTMSTS 0xf714 - #define TX4927_ACLC_ACINTEN 0xf718 --#define TX4927_ACLC_ACINTDIS 0xfR71c -+#define TX4927_ACLC_ACINTDIS 0xf71c - #define TX4927_ACLC_ACSEMAPH 0xf720 - #define TX4927_ACLC_ACGPIDAT 0xf740 - #define TX4927_ACLC_ACGPODAT 0xf744 ---- a/include/asm-mips/unistd.h -+++ b/include/asm-mips/unistd.h -@@ -760,7 +760,7 @@ type name(void) \ - if (__a3 == 0) \ - return (type) __v0; \ - errno = __v0; \ -- return -1; \ -+ return (type)-1; \ - } - - /* -@@ -788,7 +788,7 @@ type name(atype a) \ - if (__a3 == 0) \ - return (type) __v0; \ - errno = __v0; \ -- return -1; \ -+ return (type)-1; \ - } - - #define _syscall2(type,name,atype,a,btype,b) \ -@@ -813,7 +813,7 @@ type name(atype a, btype b) \ - if (__a3 == 0) \ - return (type) __v0; \ - errno = __v0; \ -- return -1; \ -+ return (type)-1; \ - } - - #define _syscall3(type,name,atype,a,btype,b,ctype,c) \ -@@ -839,7 +839,7 @@ type name(atype a, btype b, ctype c) \ - if (__a3 == 0) \ - return (type) __v0; \ - errno = __v0; \ -- return -1; \ -+ return (type)-1; \ - } - - #define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \ -@@ -865,7 +865,7 @@ type name(atype a, btype b, ctype c, dty - if (__a3 == 0) \ - return (type) __v0; \ - errno = __v0; \ -- return -1; \ -+ return (type)-1; \ - } - - #if (_MIPS_SIM == _MIPS_SIM_ABI32) -@@ -902,7 +902,7 @@ type name(atype a, btype b, ctype c, dty - if (__a3 == 0) \ - return (type) __v0; \ - errno = __v0; \ -- return -1; \ -+ return (type)-1; \ - } - - #define _syscall6(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e,ftype,f) \ -@@ -935,7 +935,7 @@ type name(atype a, btype b, ctype c, dty - if (__a3 == 0) \ - return (type) __v0; \ - errno = __v0; \ -- return -1; \ -+ return (type)-1; \ - } - - #endif /* (_MIPS_SIM == _MIPS_SIM_ABI32) */ -@@ -966,7 +966,7 @@ type name (atype a,btype b,ctype c,dtype - if (__a3 == 0) \ - return (type) __v0; \ - errno = __v0; \ -- return -1; \ -+ return (type)-1; \ - } - - #define _syscall6(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e,ftype,f) \ -@@ -995,7 +995,7 @@ type name (atype a,btype b,ctype c,dtype - if (__a3 == 0) \ - return (type) __v0; \ - errno = __v0; \ -- return -1; \ -+ return (type)-1; \ - } - - #endif /* (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64) */ ---- a/include/asm-mips64/checksum.h -+++ b/include/asm-mips64/checksum.h -@@ -144,7 +144,7 @@ static inline unsigned long csum_tcpudp_ - "daddu\t%0, %4\n\t" - "dsll32\t$1, %0, 0\n\t" - "daddu\t%0, $1\n\t" -- "dsrl32\t%0, %0, 0\n\t" -+ "dsra32\t%0, %0, 0\n\t" - ".set\tat" - : "=&r" (sum) - : "0" (daddr), "r"(saddr), ---- a/include/asm-mips64/elf.h -+++ b/include/asm-mips64/elf.h -@@ -64,9 +64,10 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_N - #define USE_ELF_CORE_DUMP - #define ELF_EXEC_PAGESIZE PAGE_SIZE - --#define ELF_CORE_COPY_REGS(_dest,_regs) \ -- memcpy((char *) &_dest, (char *) _regs, \ -- sizeof(struct pt_regs)); -+extern void dump_regs(elf_greg_t *, struct pt_regs *regs); -+ -+#define ELF_CORE_COPY_REGS(elf_regs, regs) \ -+ dump_regs((elf_greg_t *)&(elf_regs), regs); - - /* This yields a mask that user programs can use to figure out what - instruction set this cpu supports. This could be done in userspace, ---- a/include/asm-mips64/hazards.h -+++ b/include/asm-mips64/hazards.h -@@ -3,7 +3,7 @@ - * License. See the file "COPYING" in the main directory of this archive - * for more details. - * -- * Copyright (C) 2003 Ralf Baechle -+ * Copyright (C) 2003, 2004 Ralf Baechle - */ - #ifndef _ASM_HAZARDS_H - #define _ASM_HAZARDS_H -@@ -12,37 +12,200 @@ - - #ifdef __ASSEMBLY__ - -+ .macro _ssnop -+ sll $0, $0, 1 -+ .endm -+ - /* - * RM9000 hazards. When the JTLB is updated by tlbwi or tlbwr, a subsequent - * use of the JTLB for instructions should not occur for 4 cpu cycles and use - * for data translations should not occur for 3 cpu cycles. - */ - #ifdef CONFIG_CPU_RM9000 --#define rm9000_tlb_hazard \ -+ -+#define mtc0_tlbw_hazard \ -+ .set push; \ - .set mips32; \ -- ssnop; ssnop; ssnop; ssnop; \ -- .set mips0 -+ _ssnop; _ssnop; _ssnop; _ssnop; \ -+ .set pop -+ -+#define tlbw_eret_hazard \ -+ .set push; \ -+ .set mips32; \ -+ _ssnop; _ssnop; _ssnop; _ssnop; \ -+ .set pop -+ - #else --#define rm9000_tlb_hazard -+ -+/* -+ * The taken branch will result in a two cycle penalty for the two killed -+ * instructions on R4000 / R4400. Other processors only have a single cycle -+ * hazard so this is nice trick to have an optimal code for a range of -+ * processors. -+ */ -+#define mtc0_tlbw_hazard \ -+ b . + 8 -+#define tlbw_eret_hazard \ -+ nop - #endif - -+/* -+ * mtc0->mfc0 hazard -+ * The 24K has a 2 cycle mtc0/mfc0 execution hazard. -+ * It is a MIPS32R2 processor so ehb will clear the hazard. -+ */ -+ -+#ifdef CONFIG_CPU_MIPSR2 -+/* -+ * Use a macro for ehb unless explicit support for MIPSR2 is enabled -+ */ -+ .macro ehb -+ sll $0, $0, 3 -+ .endm -+ -+#define irq_enable_hazard \ -+ ehb # irq_enable_hazard -+ -+#define irq_disable_hazard \ -+ ehb # irq_disable_hazard -+ -+#elif defined(CONFIG_CPU_R10000) || defined(CONFIG_CPU_RM9000) -+ -+/* -+ * R10000 rocks - all hazards handled in hardware, so this becomes a nobrainer. -+ */ -+ -+#define irq_enable_hazard -+ -+#define irq_disable_hazard -+ - #else - - /* -+ * Classic MIPS needs 1 - 3 nops or ssnops -+ */ -+#define irq_enable_hazard -+#define irq_disable_hazard \ -+ _ssnop; _ssnop; _ssnop -+ -+#endif -+ -+#else /* __ASSEMBLY__ */ -+ -+/* - * RM9000 hazards. When the JTLB is updated by tlbwi or tlbwr, a subsequent - * use of the JTLB for instructions should not occur for 4 cpu cycles and use - * for data translations should not occur for 3 cpu cycles. - */ - #ifdef CONFIG_CPU_RM9000 --#define rm9000_tlb_hazard() \ -+ -+#define mtc0_tlbw_hazard() \ -+ __asm__ __volatile__( \ -+ ".set\tmips32\n\t" \ -+ "_ssnop; _ssnop; _ssnop; _ssnop\n\t" \ -+ ".set\tmips0") -+ -+#define tlbw_use_hazard() \ - __asm__ __volatile__( \ - ".set\tmips32\n\t" \ -- "ssnop; ssnop; ssnop; ssnop\n\t" \ -+ "_ssnop; _ssnop; _ssnop; _ssnop\n\t" \ - ".set\tmips0") - #else --#define rm9000_tlb_hazard() do { } while (0) -+ -+/* -+ * Overkill warning ... -+ */ -+#define mtc0_tlbw_hazard() \ -+ __asm__ __volatile__( \ -+ ".set noreorder\n\t" \ -+ "nop; nop; nop; nop; nop; nop;\n\t" \ -+ ".set reorder\n\t") -+ -+#define tlbw_use_hazard() \ -+ __asm__ __volatile__( \ -+ ".set noreorder\n\t" \ -+ "nop; nop; nop; nop; nop; nop;\n\t" \ -+ ".set reorder\n\t") -+ - #endif - -+/* -+ * mtc0->mfc0 hazard -+ * The 24K has a 2 cycle mtc0/mfc0 execution hazard. -+ * It is a MIPS32R2 processor so ehb will clear the hazard. -+ */ -+ -+#ifdef CONFIG_CPU_MIPSR2 -+/* -+ * Use a macro for ehb unless explicit support for MIPSR2 is enabled -+ */ -+__asm__( -+ " .macro ehb \n\t" -+ " sll $0, $0, 3 \n\t" -+ " .endm \n\t" -+ " \n\t" -+ " .macro\tirq_enable_hazard \n\t" -+ " ehb \n\t" -+ " .endm \n\t" -+ " \n\t" -+ " .macro\tirq_disable_hazard \n\t" -+ " ehb \n\t" -+ " .endm"); -+ -+#define irq_enable_hazard() \ -+ __asm__ __volatile__( \ -+ "ehb\t\t\t\t# irq_enable_hazard") -+ -+#define irq_disable_hazard() \ -+ __asm__ __volatile__( \ -+ "ehb\t\t\t\t# irq_disable_hazard") -+ -+#elif defined(CONFIG_CPU_R10000) -+ -+/* -+ * R10000 rocks - all hazards handled in hardware, so this becomes a nobrainer. -+ */ -+ -+__asm__( -+ " .macro\tirq_enable_hazard \n\t" -+ " .endm \n\t" -+ " \n\t" -+ " .macro\tirq_disable_hazard \n\t" -+ " .endm"); -+ -+#define irq_enable_hazard() do { } while (0) -+#define irq_disable_hazard() do { } while (0) -+ -+#else -+ -+/* -+ * Default for classic MIPS processors. Assume worst case hazards but don't -+ * care about the irq_enable_hazard - sooner or later the hardware will -+ * enable it and we don't care when exactly. -+ */ -+ -+__asm__( -+ " .macro _ssnop \n\t" -+ " sll $0, $2, 1 \n\t" -+ " .endm \n\t" -+ " \n\t" -+ " # \n\t" -+ " # There is a hazard but we do not care \n\t" -+ " # \n\t" -+ " .macro\tirq_enable_hazard \n\t" -+ " .endm \n\t" -+ " \n\t" -+ " .macro\tirq_disable_hazard \n\t" -+ " _ssnop; _ssnop; _ssnop \n\t" -+ " .endm"); -+ -+#define irq_enable_hazard() do { } while (0) -+#define irq_disable_hazard() \ -+ __asm__ __volatile__( \ -+ "_ssnop; _ssnop; _ssnop;\t\t# irq_disable_hazard") -+ - #endif - -+#endif /* __ASSEMBLY__ */ -+ - #endif /* _ASM_HAZARDS_H */ ---- a/include/asm-mips64/ide.h -+++ b/include/asm-mips64/ide.h -@@ -32,12 +32,12 @@ struct ide_ops { - - extern struct ide_ops *ide_ops; - --static __inline__ int ide_default_irq(ide_ioreg_t base) -+static inline int ide_default_irq(ide_ioreg_t base) - { - return ide_ops->ide_default_irq(base); - } - --static __inline__ ide_ioreg_t ide_default_io_base(int index) -+static inline ide_ioreg_t ide_default_io_base(int index) - { - return ide_ops->ide_default_io_base(index); - } -@@ -48,7 +48,7 @@ static inline void ide_init_hwif_ports(h - ide_ops->ide_init_hwif_ports(hw, data_port, ctrl_port, irq); - } - --static __inline__ void ide_init_default_hwifs(void) -+static inline void ide_init_default_hwifs(void) - { - #ifndef CONFIG_BLK_DEV_IDEPCI - hw_regs_t hw; -@@ -68,7 +68,89 @@ static __inline__ void ide_init_default_ - #define ide_ack_intr(hwif) ((hwif)->hw.ack_intr ? (hwif)->hw.ack_intr(hwif) : 1) - #endif - --#include <asm-generic/ide_iops.h> -+/* MIPS port and memory-mapped I/O string operations. */ -+ -+static inline void __ide_flush_dcache_range(unsigned long addr, unsigned long size) -+{ -+ if (cpu_has_dc_aliases) { -+ unsigned long end = addr + size; -+ for (; addr < end; addr += PAGE_SIZE) -+ flush_dcache_page(virt_to_page(addr)); -+ } -+} -+ -+static inline void __ide_insw(unsigned long port, void *addr, -+ unsigned int count) -+{ -+ insw(port, addr, count); -+ __ide_flush_dcache_range((unsigned long)addr, count * 2); -+} -+ -+static inline void __ide_insl(unsigned long port, void *addr, unsigned int count) -+{ -+ insl(port, addr, count); -+ __ide_flush_dcache_range((unsigned long)addr, count * 4); -+} -+ -+static inline void __ide_outsw(unsigned long port, const void *addr, -+ unsigned long count) -+{ -+ outsw(port, addr, count); -+ __ide_flush_dcache_range((unsigned long)addr, count * 2); -+} -+ -+static inline void __ide_outsl(unsigned long port, const void *addr, -+ unsigned long count) -+{ -+ outsl(port, addr, count); -+ __ide_flush_dcache_range((unsigned long)addr, count * 4); -+} -+ -+static inline void __ide_mm_insw(unsigned long port, void *addr, u32 count) -+{ -+ unsigned long start = (unsigned long) addr; -+ -+ while (count--) { -+ *(u16 *)addr = readw(port); -+ addr += 2; -+ } -+ __ide_flush_dcache_range(start, count * 2); -+} -+ -+static inline void __ide_mm_insl(unsigned long port, void *addr, u32 count) -+{ -+ unsigned long start = (unsigned long) addr; -+ -+ while (count--) { -+ *(u32 *)addr = readl(port); -+ addr += 4; -+ } -+ __ide_flush_dcache_range(start, count * 4); -+} -+ -+static inline void __ide_mm_outsw(unsigned long port, const void *addr, -+ u32 count) -+{ -+ unsigned long start = (unsigned long) addr; -+ -+ while (count--) { -+ writew(*(u16 *)addr, port); -+ addr += 2; -+ } -+ __ide_flush_dcache_range(start, count * 2); -+} -+ -+static inline void __ide_mm_outsl(unsigned long port, const void *addr, -+ u32 count) -+{ -+ unsigned long start = (unsigned long) addr; -+ -+ while (count--) { -+ writel(*(u32 *)addr, port); -+ addr += 4; -+ } -+ __ide_flush_dcache_range(start, count * 4); -+} - - #endif /* __KERNEL__ */ - ---- a/include/asm-mips64/io.h -+++ b/include/asm-mips64/io.h -@@ -414,7 +414,8 @@ static inline unsigned int inl_p(unsigne - return __ioswab32(__val); - } - --static inline void __outsb(unsigned long port, void *addr, unsigned int count) -+static inline void __outsb(unsigned long port, const void *addr, -+ unsigned int count) - { - while (count--) { - outb(*(u8 *)addr, port); -@@ -430,7 +431,8 @@ static inline void __insb(unsigned long - } - } - --static inline void __outsw(unsigned long port, void *addr, unsigned int count) -+static inline void __outsw(unsigned long port, const void *addr, -+ unsigned int count) - { - while (count--) { - outw(*(u16 *)addr, port); -@@ -446,7 +448,8 @@ static inline void __insw(unsigned long - } - } - --static inline void __outsl(unsigned long port, void *addr, unsigned int count) -+static inline void __outsl(unsigned long port, const void *addr, -+ unsigned int count) - { - while (count--) { - outl(*(u32 *)addr, port); ---- a/include/asm-mips64/mipsregs.h -+++ b/include/asm-mips64/mipsregs.h -@@ -757,10 +757,18 @@ do { \ - #define read_c0_config1() __read_32bit_c0_register($16, 1) - #define read_c0_config2() __read_32bit_c0_register($16, 2) - #define read_c0_config3() __read_32bit_c0_register($16, 3) -+#define read_c0_config4() __read_32bit_c0_register($16, 4) -+#define read_c0_config5() __read_32bit_c0_register($16, 5) -+#define read_c0_config6() __read_32bit_c0_register($16, 6) -+#define read_c0_config7() __read_32bit_c0_register($16, 7) - #define write_c0_config(val) __write_32bit_c0_register($16, 0, val) - #define write_c0_config1(val) __write_32bit_c0_register($16, 1, val) - #define write_c0_config2(val) __write_32bit_c0_register($16, 2, val) - #define write_c0_config3(val) __write_32bit_c0_register($16, 3, val) -+#define write_c0_config4(val) __write_32bit_c0_register($16, 4, val) -+#define write_c0_config5(val) __write_32bit_c0_register($16, 5, val) -+#define write_c0_config6(val) __write_32bit_c0_register($16, 6, val) -+#define write_c0_config7(val) __write_32bit_c0_register($16, 7, val) - - /* - * The WatchLo register. There may be upto 8 of them. -@@ -856,42 +864,34 @@ do { \ - */ - static inline void tlb_probe(void) - { -- rm9000_tlb_hazard(); - __asm__ __volatile__( - ".set noreorder\n\t" - "tlbp\n\t" - ".set reorder"); -- rm9000_tlb_hazard(); - } - - static inline void tlb_read(void) - { -- rm9000_tlb_hazard(); - __asm__ __volatile__( - ".set noreorder\n\t" - "tlbr\n\t" - ".set reorder"); -- rm9000_tlb_hazard(); - } - - static inline void tlb_write_indexed(void) - { -- rm9000_tlb_hazard(); - __asm__ __volatile__( - ".set noreorder\n\t" - "tlbwi\n\t" - ".set reorder"); -- rm9000_tlb_hazard(); - } - - static inline void tlb_write_random(void) - { -- rm9000_tlb_hazard(); - __asm__ __volatile__( - ".set noreorder\n\t" - "tlbwr\n\t" - ".set reorder"); -- rm9000_tlb_hazard(); - } - - /* ---- a/include/asm-mips64/reg.h -+++ b/include/asm-mips64/reg.h -@@ -46,6 +46,9 @@ - /* - * k0/k1 unsaved - */ -+#define EF_REG26 26 -+#define EF_REG27 27 -+ - #define EF_REG28 28 - #define EF_REG29 29 - #define EF_REG30 30 ---- a/include/asm-mips64/sgi/hpc3.h -+++ b/include/asm-mips64/sgi/hpc3.h -@@ -128,26 +128,26 @@ struct hpc3_ethregs { - volatile u32 rx_gfptr; /* current GIO fifo ptr */ - volatile u32 rx_dfptr; /* current device fifo ptr */ - u32 _unused1; /* padding */ -- volatile u32 rx_reset; /* reset register */ --#define HPC3_ERXRST_CRESET 0x1 /* Reset dma channel and external controller */ --#define HPC3_ERXRST_CLRIRQ 0x2 /* Clear channel interrupt */ --#define HPC3_ERXRST_LBACK 0x4 /* Enable diagnostic loopback mode of Seeq8003 */ -- -- volatile u32 rx_dconfig; /* DMA configuration register */ --#define HPC3_ERXDCFG_D1 0x0000f /* Cycles to spend in D1 state for PIO */ --#define HPC3_ERXDCFG_D2 0x000f0 /* Cycles to spend in D2 state for PIO */ --#define HPC3_ERXDCFG_D3 0x00f00 /* Cycles to spend in D3 state for PIO */ --#define HPC3_ERXDCFG_WCTRL 0x01000 /* Enable writes of desc into ex ctrl port */ --#define HPC3_ERXDCFG_FRXDC 0x02000 /* Clear eop stat bits upon rxdc, hw seeq fix */ --#define HPC3_ERXDCFG_FEOP 0x04000 /* Bad packet marker timeout enable */ --#define HPC3_ERXDCFG_FIRQ 0x08000 /* Another bad packet timeout enable */ --#define HPC3_ERXDCFG_PTO 0x30000 /* Programmed timeout value for above two */ -- -- volatile u32 rx_pconfig; /* PIO configuration register */ --#define HPC3_ERXPCFG_P1 0x000f /* Cycles to spend in P1 state for PIO */ --#define HPC3_ERXPCFG_P2 0x00f0 /* Cycles to spend in P2 state for PIO */ --#define HPC3_ERXPCFG_P3 0x0f00 /* Cycles to spend in P3 state for PIO */ --#define HPC3_ERXPCFG_TST 0x1000 /* Diagnistic ram test feature bit */ -+ volatile u32 reset; /* reset register */ -+#define HPC3_ERST_CRESET 0x1 /* Reset dma channel and external controller */ -+#define HPC3_ERST_CLRIRQ 0x2 /* Clear channel interrupt */ -+#define HPC3_ERST_LBACK 0x4 /* Enable diagnostic loopback mode of Seeq8003 */ -+ -+ volatile u32 dconfig; /* DMA configuration register */ -+#define HPC3_EDCFG_D1 0x0000f /* Cycles to spend in D1 state for PIO */ -+#define HPC3_EDCFG_D2 0x000f0 /* Cycles to spend in D2 state for PIO */ -+#define HPC3_EDCFG_D3 0x00f00 /* Cycles to spend in D3 state for PIO */ -+#define HPC3_EDCFG_WCTRL 0x01000 /* Enable writes of desc into ex ctrl port */ -+#define HPC3_EDCFG_FRXDC 0x02000 /* Clear eop stat bits upon rxdc, hw seeq fix */ -+#define HPC3_EDCFG_FEOP 0x04000 /* Bad packet marker timeout enable */ -+#define HPC3_EDCFG_FIRQ 0x08000 /* Another bad packet timeout enable */ -+#define HPC3_EDCFG_PTO 0x30000 /* Programmed timeout value for above two */ -+ -+ volatile u32 pconfig; /* PIO configuration register */ -+#define HPC3_EPCFG_P1 0x000f /* Cycles to spend in P1 state for PIO */ -+#define HPC3_EPCFG_P2 0x00f0 /* Cycles to spend in P2 state for PIO */ -+#define HPC3_EPCFG_P3 0x0f00 /* Cycles to spend in P3 state for PIO */ -+#define HPC3_EPCFG_TST 0x1000 /* Diagnistic ram test feature bit */ - - u32 _unused2[0x1000/4 - 8]; /* padding */ - -@@ -221,7 +221,7 @@ struct hpc3_regs { - #define HPC3_BESTAT_PIDMASK 0x3f700 /* DMA channel parity identifier */ - - u32 _unused1[0x14000/4 - 5]; /* padding */ -- -+ - /* Now direct PIO per-HPC3 peripheral access to external regs. */ - volatile u32 scsi0_ext[256]; /* SCSI channel 0 external regs */ - u32 _unused2[0x7c00/4]; -@@ -304,7 +304,7 @@ struct hpc3_regs { - volatile u32 bbram[8192-50-14]; /* Battery backed ram */ - }; - --/* -+/* - * It is possible to have two HPC3's within the address space on - * one machine, though only having one is more likely on an Indy. - */ ---- a/include/asm-mips64/sn/nmi.h -+++ b/include/asm-mips64/sn/nmi.h -@@ -8,7 +8,7 @@ - #ifndef __ASM_SN_NMI_H - #define __ASM_SN_NMI_H - --#ident "$Revision: 1.2.4.2 $" -+#ident "$Revision: 1.2.4.1 $" - - #include <asm/sn/addrs.h> - ---- a/include/asm-mips64/unistd.h -+++ b/include/asm-mips64/unistd.h -@@ -760,7 +760,7 @@ type name(void) \ - if (__a3 == 0) \ - return (type) __v0; \ - errno = __v0; \ -- return -1; \ -+ return (type)-1; \ - } - - /* -@@ -788,7 +788,7 @@ type name(atype a) \ - if (__a3 == 0) \ - return (type) __v0; \ - errno = __v0; \ -- return -1; \ -+ return (type)-1; \ - } - - #define _syscall2(type,name,atype,a,btype,b) \ -@@ -813,7 +813,7 @@ type name(atype a, btype b) \ - if (__a3 == 0) \ - return (type) __v0; \ - errno = __v0; \ -- return -1; \ -+ return (type)-1; \ - } - - #define _syscall3(type,name,atype,a,btype,b,ctype,c) \ -@@ -839,7 +839,7 @@ type name(atype a, btype b, ctype c) \ - if (__a3 == 0) \ - return (type) __v0; \ - errno = __v0; \ -- return -1; \ -+ return (type)-1; \ - } - - #define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \ -@@ -865,7 +865,7 @@ type name(atype a, btype b, ctype c, dty - if (__a3 == 0) \ - return (type) __v0; \ - errno = __v0; \ -- return -1; \ -+ return (type)-1; \ - } - - #if (_MIPS_SIM == _MIPS_SIM_ABI32) -@@ -902,7 +902,7 @@ type name(atype a, btype b, ctype c, dty - if (__a3 == 0) \ - return (type) __v0; \ - errno = __v0; \ -- return -1; \ -+ return (type)-1; \ - } - - #define _syscall6(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e,ftype,f) \ -@@ -935,7 +935,7 @@ type name(atype a, btype b, ctype c, dty - if (__a3 == 0) \ - return (type) __v0; \ - errno = __v0; \ -- return -1; \ -+ return (type)-1; \ - } - - #endif /* (_MIPS_SIM == _MIPS_SIM_ABI32) */ -@@ -966,7 +966,7 @@ type name (atype a,btype b,ctype c,dtype - if (__a3 == 0) \ - return (type) __v0; \ - errno = __v0; \ -- return -1; \ -+ return (type)-1; \ - } - - #define _syscall6(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e,ftype,f) \ -@@ -995,7 +995,7 @@ type name (atype a,btype b,ctype c,dtype - if (__a3 == 0) \ - return (type) __v0; \ - errno = __v0; \ -- return -1; \ -+ return (type)-1; \ - } - - #endif /* (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64) */ ---- a/include/asm-ppc/param.h -+++ b/include/asm-ppc/param.h -@@ -3,6 +3,9 @@ - - #ifndef HZ - #define HZ 100 -+#ifdef __KERNEL__ -+#define hz_to_std(a) (a) -+#endif - #endif - - #define EXEC_PAGESIZE 4096 ---- a/include/asm-s390/param.h -+++ b/include/asm-s390/param.h -@@ -11,6 +11,9 @@ - - #ifndef HZ - #define HZ 100 -+#ifdef __KERNEL__ -+#define hz_to_std(a) (a) -+#endif - #endif - - #define EXEC_PAGESIZE 4096 ---- a/include/asm-sh/param.h -+++ b/include/asm-sh/param.h -@@ -3,6 +3,9 @@ - - #ifndef HZ - #define HZ 100 -+#ifdef __KERNEL__ -+#define hz_to_std(a) (a) -+#endif - #endif - - #define EXEC_PAGESIZE 4096 ---- a/include/asm-sparc/param.h -+++ b/include/asm-sparc/param.h -@@ -4,6 +4,9 @@ - - #ifndef HZ - #define HZ 100 -+#ifdef __KERNEL__ -+#define hz_to_std(a) (a) -+#endif - #endif - - #define EXEC_PAGESIZE 8192 /* Thanks for sun4's we carry baggage... */ ---- a/include/asm-sparc64/param.h -+++ b/include/asm-sparc64/param.h -@@ -4,6 +4,9 @@ - - #ifndef HZ - #define HZ 100 -+#ifdef __KERNEL__ -+#define hz_to_std(a) (a) -+#endif - #endif - - #define EXEC_PAGESIZE 8192 /* Thanks for sun4's we carry baggage... */ ---- /dev/null -+++ b/include/linux/i2c-algo-au1550.h -@@ -0,0 +1,31 @@ -+/* -+ * Copyright (C) 2004 Embedded Edge, LLC <dan@embeddededge.com> -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -+ */ -+ -+#ifndef I2C_ALGO_AU1550_H -+#define I2C_ALGO_AU1550_H 1 -+ -+struct i2c_algo_au1550_data { -+ u32 psc_base; -+ int xfer_timeout; -+ int ack_timeout; -+}; -+ -+int i2c_au1550_add_bus(struct i2c_adapter *); -+int i2c_au1550_del_bus(struct i2c_adapter *); -+ -+#endif /* I2C_ALGO_AU1550_H */ ---- a/include/linux/i2c-id.h -+++ b/include/linux/i2c-id.h -@@ -155,6 +155,8 @@ - #define I2C_ALGO_SIBYTE 0x150000 /* Broadcom SiByte SOCs */ - #define I2C_ALGO_SGI 0x160000 /* SGI algorithm */ - -+#define I2C_ALGO_AU1550 0x140000 /* Alchemy Au1550 PSC */ -+ - #define I2C_ALGO_EXP 0x800000 /* experimental */ - - #define I2C_ALGO_MASK 0xff0000 /* Mask for algorithms */ -@@ -203,6 +205,9 @@ - #define I2C_HW_SGI_VINO 0x00 - #define I2C_HW_SGI_MACE 0x01 - -+/* --- Au1550 PSC adapters */ -+#define I2C_HW_AU1550_PSC 0x00 -+ - /* --- SMBus only adapters */ - #define I2C_HW_SMBUS_PIIX4 0x00 - #define I2C_HW_SMBUS_ALI15X3 0x01 ---- a/include/linux/sched.h -+++ b/include/linux/sched.h -@@ -619,6 +619,10 @@ asmlinkage long sys_wait4(pid_t pid,unsi - extern int in_group_p(gid_t); - extern int in_egroup_p(gid_t); - -+extern ATTRIB_NORET void cpu_idle(void); -+ -+extern void release_task(struct task_struct * p); -+ - extern void proc_caches_init(void); - extern void flush_signals(struct task_struct *); - extern void flush_signal_handlers(struct task_struct *); ---- a/include/linux/serial.h -+++ b/include/linux/serial.h -@@ -75,7 +75,8 @@ struct serial_struct { - #define PORT_16654 11 - #define PORT_16850 12 - #define PORT_RSA 13 /* RSA-DV II/S card */ --#define PORT_MAX 13 -+#define PORT_SB1250 14 -+#define PORT_MAX 14 - - #define SERIAL_IO_PORT 0 - #define SERIAL_IO_HUB6 1 ---- a/include/linux/swap.h -+++ b/include/linux/swap.h -@@ -1,6 +1,12 @@ - #ifndef _LINUX_SWAP_H - #define _LINUX_SWAP_H - -+#include <linux/config.h> -+ -+#define MAX_SWAPFILES 32 -+ -+#ifdef __KERNEL__ -+ - #include <linux/spinlock.h> - #include <asm/page.h> - -@@ -8,8 +14,6 @@ - #define SWAP_FLAG_PRIO_MASK 0x7fff - #define SWAP_FLAG_PRIO_SHIFT 0 - --#define MAX_SWAPFILES 32 -- - /* - * Magic header for a swap area. The first part of the union is - * what the swap magic looks like for the old (limited to 128MB) -@@ -39,8 +43,6 @@ union swap_header { - } info; - }; - --#ifdef __KERNEL__ -- - /* - * Max bad pages in the new format.. - */ ---- a/include/video/newport.h -+++ b/include/video/newport.h -@@ -291,8 +291,6 @@ struct newport_regs { - unsigned int _unused2[0x1ef]; - struct newport_cregs cgo; - }; --extern struct newport_regs *npregs; -- - - typedef struct { - unsigned int drawmode1; -@@ -450,38 +448,26 @@ static __inline__ void newport_cmap_setr - - /* Miscellaneous NEWPORT routines. */ - #define BUSY_TIMEOUT 100000 --static __inline__ int newport_wait(void) -+static __inline__ int newport_wait(struct newport_regs *regs) - { -- int i = 0; -+ int t = BUSY_TIMEOUT; - -- while(i < BUSY_TIMEOUT) -- if(!(npregs->cset.status & NPORT_STAT_GBUSY)) -+ while (t--) -+ if (!(regs->cset.status & NPORT_STAT_GBUSY)) - break; -- if(i == BUSY_TIMEOUT) -- return 1; -- return 0; -+ return !t; - } - --static __inline__ int newport_bfwait(void) -+static __inline__ int newport_bfwait(struct newport_regs *regs) - { -- int i = 0; -+ int t = BUSY_TIMEOUT; - -- while(i < BUSY_TIMEOUT) -- if(!(npregs->cset.status & NPORT_STAT_BBUSY)) -+ while (t--) -+ if(!(regs->cset.status & NPORT_STAT_BBUSY)) - break; -- if(i == BUSY_TIMEOUT) -- return 1; -- return 0; -+ return !t; - } - --/* newport.c and cons_newport.c routines */ --extern struct graphics_ops *newport_probe (int, const char **); -- --void newport_save (void *); --void newport_restore (void *); --void newport_reset (void); --int newport_ioctl (int card, int cmd, unsigned long arg); -- - /* - * DCBMODE register defines: - */ -@@ -564,7 +550,7 @@ xmap9FIFOWait (struct newport_regs *rex) - { - rex->set.dcbmode = DCB_XMAP0 | XM9_CRS_FIFO_AVAIL | - DCB_DATAWIDTH_1 | R_DCB_XMAP9_PROTOCOL; -- newport_bfwait (); -+ newport_bfwait (rex); - - while ((rex->set.dcbdata0.bybytes.b3 & 3) != XM9_FIFO_EMPTY) - ; ---- a/init/main.c -+++ b/init/main.c -@@ -296,7 +296,6 @@ static void __init parse_options(char *l - - - extern void setup_arch(char **); --extern void cpu_idle(void); - - unsigned long wait_init_idle; - ---- a/kernel/exit.c -+++ b/kernel/exit.c -@@ -26,7 +26,7 @@ extern struct task_struct *child_reaper; - - int getrusage(struct task_struct *, int, struct rusage *); - --static void release_task(struct task_struct * p) -+void release_task(struct task_struct * p) - { - if (p != current) { - #ifdef CONFIG_SMP ---- a/kernel/signal.c -+++ b/kernel/signal.c -@@ -14,6 +14,7 @@ - #include <linux/init.h> - #include <linux/sched.h> - -+#include <asm/param.h> - #include <asm/uaccess.h> - - /* -@@ -28,6 +29,14 @@ - #define SIG_SLAB_DEBUG 0 - #endif - -+#define DEBUG_SIG 0 -+ -+#if DEBUG_SIG -+#define SIG_SLAB_DEBUG (SLAB_DEBUG_FREE | SLAB_RED_ZONE /* | SLAB_POISON */) -+#else -+#define SIG_SLAB_DEBUG 0 -+#endif -+ - static kmem_cache_t *sigqueue_cachep; - - atomic_t nr_queued_signals; -@@ -270,6 +279,11 @@ printk("SIG dequeue (%s:%d): %d ", curre - signal_pending(current)); - #endif - -+#if DEBUG_SIG -+printk("SIG dequeue (%s:%d): %d ", current->comm, current->pid, -+ signal_pending(current)); -+#endif -+ - sig = next_signal(current, mask); - if (sig) { - if (current->notifier) { -@@ -293,6 +307,10 @@ printk("SIG dequeue (%s:%d): %d ", curre - printk(" %d -> %d\n", signal_pending(current), sig); - #endif - -+#if DEBUG_SIG -+printk(" %d -> %d\n", signal_pending(current), sig); -+#endif -+ - return sig; - } - -@@ -551,6 +569,11 @@ send_sig_info(int sig, struct siginfo *i - printk("SIG queue (%s:%d): %d ", t->comm, t->pid, sig); - #endif - -+ -+#if DEBUG_SIG -+printk("SIG queue (%s:%d): %d ", t->comm, t->pid, sig); -+#endif -+ - ret = -EINVAL; - if (sig < 0 || sig > _NSIG) - goto out_nolock; -@@ -789,8 +812,8 @@ void do_notify_parent(struct task_struct - info.si_uid = tsk->uid; - - /* FIXME: find out whether or not this is supposed to be c*time. */ -- info.si_utime = tsk->times.tms_utime; -- info.si_stime = tsk->times.tms_stime; -+ info.si_utime = hz_to_std(tsk->times.tms_utime); -+ info.si_stime = hz_to_std(tsk->times.tms_stime); - - status = tsk->exit_code & 0x7f; - why = SI_KERNEL; /* shouldn't happen */ ---- a/kernel/sys.c -+++ b/kernel/sys.c -@@ -801,16 +801,23 @@ asmlinkage long sys_setfsgid(gid_t gid) - - asmlinkage long sys_times(struct tms * tbuf) - { -+ struct tms temp; -+ - /* - * In the SMP world we might just be unlucky and have one of - * the times increment as we use it. Since the value is an - * atomically safe type this is just fine. Conceptually its - * as if the syscall took an instant longer to occur. - */ -- if (tbuf) -- if (copy_to_user(tbuf, ¤t->times, sizeof(struct tms))) -+ if (tbuf) { -+ temp.tms_utime = hz_to_std(current->times.tms_utime); -+ temp.tms_stime = hz_to_std(current->times.tms_stime); -+ temp.tms_cutime = hz_to_std(current->times.tms_cutime); -+ temp.tms_cstime = hz_to_std(current->times.tms_cstime); -+ if (copy_to_user(tbuf, &temp, sizeof(struct tms))) - return -EFAULT; -- return jiffies; -+ } -+ return hz_to_std(jiffies); - } - - /* ---- a/lib/Makefile -+++ b/lib/Makefile -@@ -27,6 +27,7 @@ obj-$(CONFIG_CRC32) += crc32.o - subdir-$(CONFIG_ZLIB_INFLATE) += zlib_inflate - subdir-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate - -+-include $(TOPDIR)/arch/$(ARCH)/Makefile.lib - include $(TOPDIR)/drivers/net/Makefile.lib - include $(TOPDIR)/drivers/usb/Makefile.lib - include $(TOPDIR)/drivers/bluetooth/Makefile.lib ---- a/Makefile -+++ b/Makefile -@@ -476,10 +476,11 @@ mrproper: clean archmrproper - $(MAKE) -C Documentation/DocBook mrproper - - distclean: mrproper -- rm -f core `find . \( -not -type d \) -and \ -- \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ -- -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ -- -o -name '.*.rej' -o -name '.SUMS' -o -size 0 \) -type f -print` TAGS tags cscope* -+ find . \( -not -type d \) -and \ -+ \( -name core -o -name '*.orig' -o -name '*.rej' \ -+ -o -name '*~' -o -name '*.bak' -o -name '#*#' \ -+ -o -name '.*.rej' -o -name '.SUMS' -o -size 0 \ -+ -o -name TAGS -o -name tags -o -name 'cscope*' \) -print | env -i xargs rm -f - - backup: mrproper - cd .. && tar cf - linux/ | gzip -9 > backup.gz -@@ -506,7 +507,7 @@ mandocs: - $(MAKE) -C Documentation/DocBook man - - sums: -- find . -type f -print | sort | xargs sum > .SUMS -+ find . -type f -print | sort | env -i xargs sum > .SUMS - - dep-files: scripts/mkdep archdep include/linux/version.h - rm -f .depend .hdepend diff --git a/target/linux/generic-2.4/patches/001-squashfs.patch b/target/linux/generic-2.4/patches/001-squashfs.patch deleted file mode 100644 index 2e5cefe..0000000 --- a/target/linux/generic-2.4/patches/001-squashfs.patch +++ /dev/null @@ -1,4058 +0,0 @@ ---- a/fs/Config.in -+++ b/fs/Config.in -@@ -51,6 +51,14 @@ if [ "$CONFIG_JFFS2_FS" = "y" -o "$CONFI - int 'JFFS2 debugging verbosity (0 = quiet, 2 = noisy)' CONFIG_JFFS2_FS_DEBUG 0 - fi - tristate 'Compressed ROM file system support' CONFIG_CRAMFS -+tristate 'Squashed file system support' CONFIG_SQUASHFS -+if [ "$CONFIG_SQUASHFS" = "y" -o "$CONFIG_SQUASHFS" = "m" ] ; then -+bool 'Additional options for memory constrained systems ' CONFIG_SQUASHFS_EMBEDDED -+fi -+if [ "$CONFIG_SQUASHFS_EMBEDDED" = "y" ] ; then -+int 'Number of fragments cached' CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE 3 -+bool 'Use Vmalloc rather than Kmalloc' CONFIG_SQUASHFS_VMALLOC -+fi - bool 'Virtual memory file system support (former shm fs)' CONFIG_TMPFS - define_bool CONFIG_RAMFS y - ---- a/fs/Makefile -+++ b/fs/Makefile -@@ -65,6 +65,7 @@ subdir-$(CONFIG_REISERFS_FS) += reiserfs - subdir-$(CONFIG_DEVPTS_FS) += devpts - subdir-$(CONFIG_SUN_OPENPROMFS) += openpromfs - subdir-$(CONFIG_BEFS_FS) += befs -+subdir-$(CONFIG_SQUASHFS) += squashfs - subdir-$(CONFIG_JFS_FS) += jfs - subdir-$(CONFIG_XFS_FS) += xfs - ---- /dev/null -+++ b/fs/squashfs/inode.c -@@ -0,0 +1,2028 @@ -+/* -+ * Squashfs - a compressed read only filesystem for Linux -+ * -+ * Copyright (c) 2002, 2003, 2004, 2005, 2006 -+ * Phillip Lougher <phillip@lougher.org.uk> -+ * -+ * 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, -+ * 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+ * -+ * inode.c -+ */ -+ -+#include <linux/types.h> -+#include <linux/squashfs_fs.h> -+#include <linux/module.h> -+#include <linux/errno.h> -+#include <linux/slab.h> -+#include <linux/fs.h> -+#include <linux/smp_lock.h> -+#include <linux/locks.h> -+#include <linux/init.h> -+#include <linux/dcache.h> -+#include <linux/wait.h> -+#include <linux/zlib.h> -+#include <linux/blkdev.h> -+#include <linux/vmalloc.h> -+#include <asm/uaccess.h> -+#include <asm/semaphore.h> -+ -+#include "squashfs.h" -+ -+static struct super_block *squashfs_read_super(struct super_block *, void *, int); -+static void squashfs_put_super(struct super_block *); -+static int squashfs_statfs(struct super_block *, struct statfs *); -+static int squashfs_symlink_readpage(struct file *file, struct page *page); -+static int squashfs_readpage(struct file *file, struct page *page); -+static int squashfs_readpage4K(struct file *file, struct page *page); -+static int squashfs_readdir(struct file *, void *, filldir_t); -+static struct dentry *squashfs_lookup(struct inode *, struct dentry *); -+static struct inode *squashfs_iget(struct super_block *s, squashfs_inode_t inode); -+static long long read_blocklist(struct inode *inode, int index, -+ int readahead_blks, char *block_list, -+ unsigned short **block_p, unsigned int *bsize); -+ -+static z_stream stream; -+ -+static DECLARE_FSTYPE_DEV(squashfs_fs_type, "squashfs", squashfs_read_super); -+ -+static unsigned char squashfs_filetype_table[] = { -+ DT_UNKNOWN, DT_DIR, DT_REG, DT_LNK, DT_BLK, DT_CHR, DT_FIFO, DT_SOCK -+}; -+ -+static struct super_operations squashfs_ops = { -+ .statfs = squashfs_statfs, -+ .put_super = squashfs_put_super, -+}; -+ -+SQSH_EXTERN struct address_space_operations squashfs_symlink_aops = { -+ .readpage = squashfs_symlink_readpage -+}; -+ -+SQSH_EXTERN struct address_space_operations squashfs_aops = { -+ .readpage = squashfs_readpage -+}; -+ -+SQSH_EXTERN struct address_space_operations squashfs_aops_4K = { -+ .readpage = squashfs_readpage4K -+}; -+ -+static struct file_operations squashfs_dir_ops = { -+ .read = generic_read_dir, -+ .readdir = squashfs_readdir -+}; -+ -+static struct inode_operations squashfs_dir_inode_ops = { -+ .lookup = squashfs_lookup -+}; -+ -+static struct buffer_head *get_block_length(struct super_block *s, -+ int *cur_index, int *offset, int *c_byte) -+{ -+ struct squashfs_sb_info *msblk = &s->u.squashfs_sb; -+ unsigned short temp; -+ struct buffer_head *bh; -+ -+ if (!(bh = sb_bread(s, *cur_index))) -+ goto out; -+ -+ if (msblk->devblksize - *offset == 1) { -+ if (msblk->swap) -+ ((unsigned char *) &temp)[1] = *((unsigned char *) -+ (bh->b_data + *offset)); -+ else -+ ((unsigned char *) &temp)[0] = *((unsigned char *) -+ (bh->b_data + *offset)); -+ brelse(bh); -+ if (!(bh = sb_bread(s, ++(*cur_index)))) -+ goto out; -+ if (msblk->swap) -+ ((unsigned char *) &temp)[0] = *((unsigned char *) -+ bh->b_data); -+ else -+ ((unsigned char *) &temp)[1] = *((unsigned char *) -+ bh->b_data); -+ *c_byte = temp; -+ *offset = 1; -+ } else { -+ if (msblk->swap) { -+ ((unsigned char *) &temp)[1] = *((unsigned char *) -+ (bh->b_data + *offset)); -+ ((unsigned char *) &temp)[0] = *((unsigned char *) -+ (bh->b_data + *offset + 1)); -+ } else { -+ ((unsigned char *) &temp)[0] = *((unsigned char *) -+ (bh->b_data + *offset)); -+ ((unsigned char *) &temp)[1] = *((unsigned char *) -+ (bh->b_data + *offset + 1)); -+ } -+ *c_byte = temp; -+ *offset += 2; -+ } -+ -+ if (SQUASHFS_CHECK_DATA(msblk->sblk.flags)) { -+ if (*offset == msblk->devblksize) { -+ brelse(bh); -+ if (!(bh = sb_bread(s, ++(*cur_index)))) -+ goto out; -+ *offset = 0; -+ } -+ if (*((unsigned char *) (bh->b_data + *offset)) != -+ SQUASHFS_MARKER_BYTE) { -+ ERROR("Metadata block marker corrupt @ %x\n", -+ *cur_index); -+ brelse(bh); -+ goto out; -+ } -+ (*offset)++; -+ } -+ return bh; -+ -+out: -+ return NULL; -+} -+ -+ -+SQSH_EXTERN unsigned int squashfs_read_data(struct super_block *s, char *buffer, -+ long long index, unsigned int length, -+ long long *next_index) -+{ -+ struct squashfs_sb_info *msblk = &s->u.squashfs_sb; -+ struct buffer_head *bh[((SQUASHFS_FILE_MAX_SIZE - 1) >> -+ msblk->devblksize_log2) + 2]; -+ unsigned int offset = index & ((1 << msblk->devblksize_log2) - 1); -+ unsigned int cur_index = index >> msblk->devblksize_log2; -+ int bytes, avail_bytes, b = 0, k; -+ char *c_buffer; -+ unsigned int compressed; -+ unsigned int c_byte = length; -+ -+ if (c_byte) { -+ bytes = msblk->devblksize - offset; -+ compressed = SQUASHFS_COMPRESSED_BLOCK(c_byte); -+ c_buffer = compressed ? msblk->read_data : buffer; -+ c_byte = SQUASHFS_COMPRESSED_SIZE_BLOCK(c_byte); -+ -+ TRACE("Block @ 0x%llx, %scompressed size %d\n", index, compressed -+ ? "" : "un", (unsigned int) c_byte); -+ -+ if (!(bh[0] = sb_getblk(s, cur_index))) -+ goto block_release; -+ -+ for (b = 1; bytes < c_byte; b++) { -+ if (!(bh[b] = sb_getblk(s, ++cur_index))) -+ goto block_release; -+ bytes += msblk->devblksize; -+ } -+ ll_rw_block(READ, b, bh); -+ } else { -+ if (!(bh[0] = get_block_length(s, &cur_index, &offset, -+ &c_byte))) -+ goto read_failure; -+ -+ bytes = msblk->devblksize - offset; -+ compressed = SQUASHFS_COMPRESSED(c_byte); -+ c_buffer = compressed ? msblk->read_data : buffer; -+ c_byte = SQUASHFS_COMPRESSED_SIZE(c_byte); -+ -+ TRACE("Block @ 0x%llx, %scompressed size %d\n", index, compressed -+ ? "" : "un", (unsigned int) c_byte); -+ -+ for (b = 1; bytes < c_byte; b++) { -+ if (!(bh[b] = sb_getblk(s, ++cur_index))) -+ goto block_release; -+ bytes += msblk->devblksize; -+ } -+ ll_rw_block(READ, b - 1, bh + 1); -+ } -+ -+ if (compressed) -+ down(&msblk->read_data_mutex); -+ -+ for (bytes = 0, k = 0; k < b; k++) { -+ avail_bytes = (c_byte - bytes) > (msblk->devblksize - offset) ? -+ msblk->devblksize - offset : -+ c_byte - bytes; -+ wait_on_buffer(bh[k]); -+ if (!buffer_uptodate(bh[k])) -+ goto block_release; -+ memcpy(c_buffer + bytes, bh[k]->b_data + offset, avail_bytes); -+ bytes += avail_bytes; -+ offset = 0; -+ brelse(bh[k]); -+ } -+ -+ /* -+ * uncompress block -+ */ -+ if (compressed) { -+ int zlib_err; -+ -+ stream.next_in = c_buffer; -+ stream.avail_in = c_byte; -+ stream.next_out = buffer; -+ stream.avail_out = msblk->read_size; -+ -+ if (((zlib_err = zlib_inflateInit(&stream)) != Z_OK) || -+ ((zlib_err = zlib_inflate(&stream, Z_FINISH)) -+ != Z_STREAM_END) || ((zlib_err = -+ zlib_inflateEnd(&stream)) != Z_OK)) { -+ ERROR("zlib_fs returned unexpected result 0x%x\n", -+ zlib_err); -+ bytes = 0; -+ } else -+ bytes = stream.total_out; -+ -+ up(&msblk->read_data_mutex); -+ } -+ -+ if (next_index) -+ *next_index = index + c_byte + (length ? 0 : -+ (SQUASHFS_CHECK_DATA(msblk->sblk.flags) -+ ? 3 : 2)); -+ return bytes; -+ -+block_release: -+ while (--b >= 0) -+ brelse(bh[b]); -+ -+read_failure: -+ ERROR("sb_bread failed reading block 0x%x\n", cur_index); -+ return 0; -+} -+ -+ -+SQSH_EXTERN int squashfs_get_cached_block(struct super_block *s, char *buffer, -+ long long block, unsigned int offset, -+ int length, long long *next_block, -+ unsigned int *next_offset) -+{ -+ struct squashfs_sb_info *msblk = &s->u.squashfs_sb; -+ int n, i, bytes, return_length = length; -+ long long next_index; -+ -+ TRACE("Entered squashfs_get_cached_block [%llx:%x]\n", block, offset); -+ -+ while ( 1 ) { -+ for (i = 0; i < SQUASHFS_CACHED_BLKS; i++) -+ if (msblk->block_cache[i].block == block) -+ break; -+ -+ down(&msblk->block_cache_mutex); -+ -+ if (i == SQUASHFS_CACHED_BLKS) { -+ /* read inode header block */ -+ for (i = msblk->next_cache, n = SQUASHFS_CACHED_BLKS; -+ n ; n --, i = (i + 1) % -+ SQUASHFS_CACHED_BLKS) -+ if (msblk->block_cache[i].block != -+ SQUASHFS_USED_BLK) -+ break; -+ -+ if (n == 0) { -+ wait_queue_t wait; -+ -+ init_waitqueue_entry(&wait, current); -+ add_wait_queue(&msblk->waitq, &wait); -+ set_current_state(TASK_UNINTERRUPTIBLE); -+ up(&msblk->block_cache_mutex); -+ schedule(); -+ set_current_state(TASK_RUNNING); -+ remove_wait_queue(&msblk->waitq, &wait); -+ continue; -+ } -+ msblk->next_cache = (i + 1) % SQUASHFS_CACHED_BLKS; -+ -+ if (msblk->block_cache[i].block == -+ SQUASHFS_INVALID_BLK) { -+ if (!(msblk->block_cache[i].data = -+ kmalloc(SQUASHFS_METADATA_SIZE, -+ GFP_KERNEL))) { -+ ERROR("Failed to allocate cache" -+ "block\n"); -+ up(&msblk->block_cache_mutex); -+ goto out; -+ } -+ } -+ -+ msblk->block_cache[i].block = SQUASHFS_USED_BLK; -+ up(&msblk->block_cache_mutex); -+ -+ if (!(msblk->block_cache[i].length = -+ squashfs_read_data(s, -+ msblk->block_cache[i].data, -+ block, 0, &next_index))) { -+ ERROR("Unable to read cache block [%llx:%x]\n", -+ block, offset); -+ goto out; -+ } -+ -+ down(&msblk->block_cache_mutex); -+ wake_up(&msblk->waitq); -+ msblk->block_cache[i].block = block; -+ msblk->block_cache[i].next_index = next_index; -+ TRACE("Read cache block [%llx:%x]\n", block, offset); -+ } -+ -+ if (msblk->block_cache[i].block != block) { -+ up(&msblk->block_cache_mutex); -+ continue; -+ } -+ -+ if ((bytes = msblk->block_cache[i].length - offset) >= length) { -+ if (buffer) -+ memcpy(buffer, msblk->block_cache[i].data + -+ offset, length); -+ if (msblk->block_cache[i].length - offset == length) { -+ *next_block = msblk->block_cache[i].next_index; -+ *next_offset = 0; -+ } else { -+ *next_block = block; -+ *next_offset = offset + length; -+ } -+ up(&msblk->block_cache_mutex); -+ goto finish; -+ } else { -+ if (buffer) { -+ memcpy(buffer, msblk->block_cache[i].data + -+ offset, bytes); -+ buffer += bytes; -+ } -+ block = msblk->block_cache[i].next_index; -+ up(&msblk->block_cache_mutex); -+ length -= bytes; -+ offset = 0; -+ } -+ } -+ -+finish: -+ return return_length; -+out: -+ return 0; -+} -+ -+ -+static int get_fragment_location(struct super_block *s, unsigned int fragment, -+ long long *fragment_start_block, -+ unsigned int *fragment_size) -+{ -+ struct squashfs_sb_info *msblk = &s->u.squashfs_sb; -+ long long start_block = -+ msblk->fragment_index[SQUASHFS_FRAGMENT_INDEX(fragment)]; -+ int offset = SQUASHFS_FRAGMENT_INDEX_OFFSET(fragment); -+ struct squashfs_fragment_entry fragment_entry; -+ -+ if (msblk->swap) { -+ struct squashfs_fragment_entry sfragment_entry; -+ -+ if (!squashfs_get_cached_block(s, (char *) &sfragment_entry, -+ start_block, offset, -+ sizeof(sfragment_entry), &start_block, -+ &offset)) -+ goto out; -+ SQUASHFS_SWAP_FRAGMENT_ENTRY(&fragment_entry, &sfragment_entry); -+ } else -+ if (!squashfs_get_cached_block(s, (char *) &fragment_entry, -+ start_block, offset, -+ sizeof(fragment_entry), &start_block, -+ &offset)) -+ goto out; -+ -+ *fragment_start_block = fragment_entry.start_block; -+ *fragment_size = fragment_entry.size; -+ -+ return 1; -+ -+out: -+ return 0; -+} -+ -+ -+SQSH_EXTERN void release_cached_fragment(struct squashfs_sb_info *msblk, struct -+ squashfs_fragment_cache *fragment) -+{ -+ down(&msblk->fragment_mutex); -+ fragment->locked --; -+ wake_up(&msblk->fragment_wait_queue); -+ up(&msblk->fragment_mutex); -+} -+ -+ -+SQSH_EXTERN struct squashfs_fragment_cache *get_cached_fragment(struct super_block -+ *s, long long start_block, -+ int length) -+{ -+ int i, n; -+ struct squashfs_sb_info *msblk = &s->u.squashfs_sb; -+ -+ while ( 1 ) { -+ down(&msblk->fragment_mutex); -+ -+ for (i = 0; i < SQUASHFS_CACHED_FRAGMENTS && -+ msblk->fragment[i].block != start_block; i++); -+ -+ if (i == SQUASHFS_CACHED_FRAGMENTS) { -+ for (i = msblk->next_fragment, n = -+ SQUASHFS_CACHED_FRAGMENTS; n && -+ msblk->fragment[i].locked; n--, i = (i + 1) % -+ SQUASHFS_CACHED_FRAGMENTS); -+ -+ if (n == 0) { -+ wait_queue_t wait; -+ -+ init_waitqueue_entry(&wait, current); -+ add_wait_queue(&msblk->fragment_wait_queue, -+ &wait); -+ set_current_state(TASK_UNINTERRUPTIBLE); -+ up(&msblk->fragment_mutex); -+ schedule(); -+ set_current_state(TASK_RUNNING); -+ remove_wait_queue(&msblk->fragment_wait_queue, -+ &wait); -+ continue; -+ } -+ msblk->next_fragment = (msblk->next_fragment + 1) % -+ SQUASHFS_CACHED_FRAGMENTS; -+ -+ if (msblk->fragment[i].data == NULL) -+ if (!(msblk->fragment[i].data = SQUASHFS_ALLOC -+ (SQUASHFS_FILE_MAX_SIZE))) { -+ ERROR("Failed to allocate fragment " -+ "cache block\n"); -+ up(&msblk->fragment_mutex); -+ goto out; -+ } -+ -+ msblk->fragment[i].block = SQUASHFS_INVALID_BLK; -+ msblk->fragment[i].locked = 1; -+ up(&msblk->fragment_mutex); -+ -+ if (!(msblk->fragment[i].length = squashfs_read_data(s, -+ msblk->fragment[i].data, -+ start_block, length, NULL))) { -+ ERROR("Unable to read fragment cache block " -+ "[%llx]\n", start_block); -+ msblk->fragment[i].locked = 0; -+ goto out; -+ } -+ -+ msblk->fragment[i].block = start_block; -+ TRACE("New fragment %d, start block %lld, locked %d\n", -+ i, msblk->fragment[i].block, -+ msblk->fragment[i].locked); -+ break; -+ } -+ -+ msblk->fragment[i].locked++; -+ up(&msblk->fragment_mutex); -+ TRACE("Got fragment %d, start block %lld, locked %d\n", i, -+ msblk->fragment[i].block, -+ msblk->fragment[i].locked); -+ break; -+ } -+ -+ return &msblk->fragment[i]; -+ -+out: -+ return NULL; -+} -+ -+ -+static struct inode *squashfs_new_inode(struct super_block *s, -+ struct squashfs_base_inode_header *inodeb) -+{ -+ struct squashfs_sb_info *msblk = &s->u.squashfs_sb; -+ struct inode *i = new_inode(s); -+ -+ if (i) { -+ i->i_ino = inodeb->inode_number; -+ i->i_mtime = inodeb->mtime; -+ i->i_atime = inodeb->mtime; -+ i->i_ctime = inodeb->mtime; -+ i->i_uid = msblk->uid[inodeb->uid]; -+ i->i_mode = inodeb->mode; -+ i->i_size = 0; -+ if (inodeb->guid == SQUASHFS_GUIDS) -+ i->i_gid = i->i_uid; -+ else -+ i->i_gid = msblk->guid[inodeb->guid]; -+ } -+ -+ return i; -+} -+ -+ -+static struct inode *squashfs_iget(struct super_block *s, squashfs_inode_t inode) -+{ -+ struct inode *i; -+ struct squashfs_sb_info *msblk = &s->u.squashfs_sb; -+ struct squashfs_super_block *sblk = &msblk->sblk; -+ long long block = SQUASHFS_INODE_BLK(inode) + -+ sblk->inode_table_start; -+ unsigned int offset = SQUASHFS_INODE_OFFSET(inode); -+ long long next_block; -+ unsigned int next_offset; -+ union squashfs_inode_header id, sid; -+ struct squashfs_base_inode_header *inodeb = &id.base, -+ *sinodeb = &sid.base; -+ -+ TRACE("Entered squashfs_iget\n"); -+ -+ if (msblk->swap) { -+ if (!squashfs_get_cached_block(s, (char *) sinodeb, block, -+ offset, sizeof(*sinodeb), &next_block, -+ &next_offset)) -+ goto failed_read; -+ SQUASHFS_SWAP_BASE_INODE_HEADER(inodeb, sinodeb, -+ sizeof(*sinodeb)); -+ } else -+ if (!squashfs_get_cached_block(s, (char *) inodeb, block, -+ offset, sizeof(*inodeb), &next_block, -+ &next_offset)) -+ goto failed_read; -+ -+ switch(inodeb->inode_type) { -+ case SQUASHFS_FILE_TYPE: { -+ unsigned int frag_size; -+ long long frag_blk; -+ struct squashfs_reg_inode_header *inodep = &id.reg; -+ struct squashfs_reg_inode_header *sinodep = &sid.reg; -+ -+ if (msblk->swap) { -+ if (!squashfs_get_cached_block(s, (char *) -+ sinodep, block, offset, -+ sizeof(*sinodep), &next_block, -+ &next_offset)) -+ goto failed_read; -+ SQUASHFS_SWAP_REG_INODE_HEADER(inodep, sinodep); -+ } else -+ if (!squashfs_get_cached_block(s, (char *) -+ inodep, block, offset, -+ sizeof(*inodep), &next_block, -+ &next_offset)) -+ goto failed_read; -+ -+ frag_blk = SQUASHFS_INVALID_BLK; -+ if (inodep->fragment != SQUASHFS_INVALID_FRAG && -+ !get_fragment_location(s, -+ inodep->fragment, &frag_blk, &frag_size)) -+ goto failed_read; -+ -+ if((i = squashfs_new_inode(s, inodeb)) == NULL) -+ goto failed_read1; -+ -+ i->i_nlink = 1; -+ i->i_size = inodep->file_size; -+ i->i_fop = &generic_ro_fops; -+ i->i_mode |= S_IFREG; -+ i->i_blocks = ((i->i_size - 1) >> 9) + 1; -+ i->i_blksize = PAGE_CACHE_SIZE; -+ SQUASHFS_I(i)->u.s1.fragment_start_block = frag_blk; -+ SQUASHFS_I(i)->u.s1.fragment_size = frag_size; -+ SQUASHFS_I(i)->u.s1.fragment_offset = inodep->offset; -+ SQUASHFS_I(i)->start_block = inodep->start_block; -+ SQUASHFS_I(i)->u.s1.block_list_start = next_block; -+ SQUASHFS_I(i)->offset = next_offset; -+ if (sblk->block_size > 4096) -+ i->i_data.a_ops = &squashfs_aops; -+ else -+ i->i_data.a_ops = &squashfs_aops_4K; -+ -+ TRACE("File inode %x:%x, start_block %llx, " -+ "block_list_start %llx, offset %x\n", -+ SQUASHFS_INODE_BLK(inode), offset, -+ inodep->start_block, next_block, -+ next_offset); -+ break; -+ } -+ case SQUASHFS_LREG_TYPE: { -+ unsigned int frag_size; -+ long long frag_blk; -+ struct squashfs_lreg_inode_header *inodep = &id.lreg; -+ struct squashfs_lreg_inode_header *sinodep = &sid.lreg; -+ -+ if (msblk->swap) { -+ if (!squashfs_get_cached_block(s, (char *) -+ sinodep, block, offset, -+ sizeof(*sinodep), &next_block, -+ &next_offset)) -+ goto failed_read; -+ SQUASHFS_SWAP_LREG_INODE_HEADER(inodep, sinodep); -+ } else -+ if (!squashfs_get_cached_block(s, (char *) -+ inodep, block, offset, -+ sizeof(*inodep), &next_block, -+ &next_offset)) -+ goto failed_read; -+ -+ frag_blk = SQUASHFS_INVALID_BLK; -+ if (inodep->fragment != SQUASHFS_INVALID_FRAG && -+ !get_fragment_location(s, -+ inodep->fragment, &frag_blk, &frag_size)) -+ goto failed_read; -+ -+ if((i = squashfs_new_inode(s, inodeb)) == NULL) -+ goto failed_read1; -+ -+ i->i_nlink = inodep->nlink; -+ i->i_size = inodep->file_size; -+ i->i_fop = &generic_ro_fops; -+ i->i_mode |= S_IFREG; -+ i->i_blocks = ((i->i_size - 1) >> 9) + 1; -+ i->i_blksize = PAGE_CACHE_SIZE; -+ SQUASHFS_I(i)->u.s1.fragment_start_block = frag_blk; -+ SQUASHFS_I(i)->u.s1.fragment_size = frag_size; -+ SQUASHFS_I(i)->u.s1.fragment_offset = inodep->offset; -+ SQUASHFS_I(i)->start_block = inodep->start_block; -+ SQUASHFS_I(i)->u.s1.block_list_start = next_block; -+ SQUASHFS_I(i)->offset = next_offset; -+ if (sblk->block_size > 4096) -+ i->i_data.a_ops = &squashfs_aops; -+ else -+ i->i_data.a_ops = &squashfs_aops_4K; -+ -+ TRACE("File inode %x:%x, start_block %llx, " -+ "block_list_start %llx, offset %x\n", -+ SQUASHFS_INODE_BLK(inode), offset, -+ inodep->start_block, next_block, -+ next_offset); -+ break; -+ } -+ case SQUASHFS_DIR_TYPE: { -+ struct squashfs_dir_inode_header *inodep = &id.dir; -+ struct squashfs_dir_inode_header *sinodep = &sid.dir; -+ -+ if (msblk->swap) { -+ if (!squashfs_get_cached_block(s, (char *) -+ sinodep, block, offset, -+ sizeof(*sinodep), &next_block, -+ &next_offset)) -+ goto failed_read; -+ SQUASHFS_SWAP_DIR_INODE_HEADER(inodep, sinodep); -+ } else -+ if (!squashfs_get_cached_block(s, (char *) -+ inodep, block, offset, -+ sizeof(*inodep), &next_block, -+ &next_offset)) -+ goto failed_read; -+ -+ if((i = squashfs_new_inode(s, inodeb)) == NULL) -+ goto failed_read1; -+ -+ i->i_nlink = inodep->nlink; -+ i->i_size = inodep->file_size; -+ i->i_op = &squashfs_dir_inode_ops; -+ i->i_fop = &squashfs_dir_ops; -+ i->i_mode |= S_IFDIR; -+ SQUASHFS_I(i)->start_block = inodep->start_block; -+ SQUASHFS_I(i)->offset = inodep->offset; -+ SQUASHFS_I(i)->u.s2.directory_index_count = 0; -+ SQUASHFS_I(i)->u.s2.parent_inode = inodep->parent_inode; -+ -+ TRACE("Directory inode %x:%x, start_block %x, offset " -+ "%x\n", SQUASHFS_INODE_BLK(inode), -+ offset, inodep->start_block, -+ inodep->offset); -+ break; -+ } -+ case SQUASHFS_LDIR_TYPE: { -+ struct squashfs_ldir_inode_header *inodep = &id.ldir; -+ struct squashfs_ldir_inode_header *sinodep = &sid.ldir; -+ -+ if (msblk->swap) { -+ if (!squashfs_get_cached_block(s, (char *) -+ sinodep, block, offset, -+ sizeof(*sinodep), &next_block, -+ &next_offset)) -+ goto failed_read; -+ SQUASHFS_SWAP_LDIR_INODE_HEADER(inodep, -+ sinodep); -+ } else -+ if (!squashfs_get_cached_block(s, (char *) -+ inodep, block, offset, -+ sizeof(*inodep), &next_block, -+ &next_offset)) -+ goto failed_read; -+ -+ if((i = squashfs_new_inode(s, inodeb)) == NULL) -+ goto failed_read1; -+ -+ i->i_nlink = inodep->nlink; -+ i->i_size = inodep->file_size; -+ i->i_op = &squashfs_dir_inode_ops; -+ i->i_fop = &squashfs_dir_ops; -+ i->i_mode |= S_IFDIR; -+ SQUASHFS_I(i)->start_block = inodep->start_block; -+ SQUASHFS_I(i)->offset = inodep->offset; -+ SQUASHFS_I(i)->u.s2.directory_index_start = next_block; -+ SQUASHFS_I(i)->u.s2.directory_index_offset = -+ next_offset; -+ SQUASHFS_I(i)->u.s2.directory_index_count = -+ inodep->i_count; -+ SQUASHFS_I(i)->u.s2.parent_inode = inodep->parent_inode; -+ -+ TRACE("Long directory inode %x:%x, start_block %x, " -+ "offset %x\n", -+ SQUASHFS_INODE_BLK(inode), offset, -+ inodep->start_block, inodep->offset); -+ break; -+ } -+ case SQUASHFS_SYMLINK_TYPE: { -+ struct squashfs_symlink_inode_header *inodep = -+ &id.symlink; -+ struct squashfs_symlink_inode_header *sinodep = -+ &sid.symlink; -+ -+ if (msblk->swap) { -+ if (!squashfs_get_cached_block(s, (char *) -+ sinodep, block, offset, -+ sizeof(*sinodep), &next_block, -+ &next_offset)) -+ goto failed_read; -+ SQUASHFS_SWAP_SYMLINK_INODE_HEADER(inodep, -+ sinodep); -+ } else -+ if (!squashfs_get_cached_block(s, (char *) -+ inodep, block, offset, -+ sizeof(*inodep), &next_block, -+ &next_offset)) -+ goto failed_read; -+ -+ if((i = squashfs_new_inode(s, inodeb)) == NULL) -+ goto failed_read1; -+ -+ i->i_nlink = inodep->nlink; -+ i->i_size = inodep->symlink_size; -+ i->i_op = &page_symlink_inode_operations; -+ i->i_data.a_ops = &squashfs_symlink_aops; -+ i->i_mode |= S_IFLNK; -+ SQUASHFS_I(i)->start_block = next_block; -+ SQUASHFS_I(i)->offset = next_offset; -+ -+ TRACE("Symbolic link inode %x:%x, start_block %llx, " -+ "offset %x\n", -+ SQUASHFS_INODE_BLK(inode), offset, -+ next_block, next_offset); -+ break; -+ } -+ case SQUASHFS_BLKDEV_TYPE: -+ case SQUASHFS_CHRDEV_TYPE: { -+ struct squashfs_dev_inode_header *inodep = &id.dev; -+ struct squashfs_dev_inode_header *sinodep = &sid.dev; -+ -+ if (msblk->swap) { -+ if (!squashfs_get_cached_block(s, (char *) -+ sinodep, block, offset, -+ sizeof(*sinodep), &next_block, -+ &next_offset)) -+ goto failed_read; -+ SQUASHFS_SWAP_DEV_INODE_HEADER(inodep, sinodep); -+ } else -+ if (!squashfs_get_cached_block(s, (char *) -+ inodep, block, offset, -+ sizeof(*inodep), &next_block, -+ &next_offset)) -+ goto failed_read; -+ -+ if ((i = squashfs_new_inode(s, inodeb)) == NULL) -+ goto failed_read1; -+ -+ i->i_nlink = inodep->nlink; -+ i->i_mode |= (inodeb->inode_type == -+ SQUASHFS_CHRDEV_TYPE) ? S_IFCHR : -+ S_IFBLK; -+ init_special_inode(i, i->i_mode, inodep->rdev); -+ -+ TRACE("Device inode %x:%x, rdev %x\n", -+ SQUASHFS_INODE_BLK(inode), offset, -+ inodep->rdev); -+ break; -+ } -+ case SQUASHFS_FIFO_TYPE: -+ case SQUASHFS_SOCKET_TYPE: { -+ struct squashfs_ipc_inode_header *inodep = &id.ipc; -+ struct squashfs_ipc_inode_header *sinodep = &sid.ipc; -+ -+ if (msblk->swap) { -+ if (!squashfs_get_cached_block(s, (char *) -+ sinodep, block, offset, -+ sizeof(*sinodep), &next_block, -+ &next_offset)) -+ goto failed_read; -+ SQUASHFS_SWAP_IPC_INODE_HEADER(inodep, sinodep); -+ } else -+ if (!squashfs_get_cached_block(s, (char *) -+ inodep, block, offset, -+ sizeof(*inodep), &next_block, -+ &next_offset)) -+ goto failed_read; -+ -+ if ((i = squashfs_new_inode(s, inodeb)) == NULL) -+ goto failed_read1; -+ -+ i->i_nlink = inodep->nlink; -+ i->i_mode |= (inodeb->inode_type == SQUASHFS_FIFO_TYPE) -+ ? S_IFIFO : S_IFSOCK; -+ init_special_inode(i, i->i_mode, 0); -+ break; -+ } -+ default: -+ ERROR("Unknown inode type %d in squashfs_iget!\n", -+ inodeb->inode_type); -+ goto failed_read1; -+ } -+ -+ insert_inode_hash(i); -+ return i; -+ -+failed_read: -+ ERROR("Unable to read inode [%llx:%x]\n", block, offset); -+ -+failed_read1: -+ return NULL; -+} -+ -+ -+int read_fragment_index_table(struct super_block *s) -+{ -+ struct squashfs_sb_info *msblk = &s->u.squashfs_sb; -+ struct squashfs_super_block *sblk = &msblk->sblk; -+ -+ if (!(msblk->fragment_index = kmalloc(SQUASHFS_FRAGMENT_INDEX_BYTES -+ (sblk->fragments), GFP_KERNEL))) { -+ ERROR("Failed to allocate uid/gid table\n"); -+ return 0; -+ } -+ -+ if (SQUASHFS_FRAGMENT_INDEX_BYTES(sblk->fragments) && -+ !squashfs_read_data(s, (char *) -+ msblk->fragment_index, -+ sblk->fragment_table_start, -+ SQUASHFS_FRAGMENT_INDEX_BYTES -+ (sblk->fragments) | -+ SQUASHFS_COMPRESSED_BIT_BLOCK, NULL)) { -+ ERROR("unable to read fragment index table\n"); -+ return 0; -+ } -+ -+ if (msblk->swap) { -+ int i; -+ long long fragment; -+ -+ for (i = 0; i < SQUASHFS_FRAGMENT_INDEXES(sblk->fragments); -+ i++) { -+ SQUASHFS_SWAP_FRAGMENT_INDEXES((&fragment), -+ &msblk->fragment_index[i], 1); -+ msblk->fragment_index[i] = fragment; -+ } -+ } -+ -+ return 1; -+} -+ -+ -+static int supported_squashfs_filesystem(struct squashfs_sb_info *msblk, int silent) -+{ -+ struct squashfs_super_block *sblk = &msblk->sblk; -+ -+ msblk->iget = squashfs_iget; -+ msblk->read_blocklist = read_blocklist; -+ msblk->read_fragment_index_table = read_fragment_index_table; -+ -+ if (sblk->s_major == 1) { -+ if (!squashfs_1_0_supported(msblk)) { -+ SERROR("Major/Minor mismatch, Squashfs 1.0 filesystems " -+ "are unsupported\n"); -+ SERROR("Please recompile with " -+ "Squashfs 1.0 support enabled\n"); -+ return 0; -+ } -+ } else if (sblk->s_major == 2) { -+ if (!squashfs_2_0_supported(msblk)) { -+ SERROR("Major/Minor mismatch, Squashfs 2.0 filesystems " -+ "are unsupported\n"); -+ SERROR("Please recompile with " -+ "Squashfs 2.0 support enabled\n"); -+ return 0; -+ } -+ } else if(sblk->s_major != SQUASHFS_MAJOR || sblk->s_minor > -+ SQUASHFS_MINOR) { -+ SERROR("Major/Minor mismatch, trying to mount newer %d.%d " -+ "filesystem\n", sblk->s_major, sblk->s_minor); -+ SERROR("Please update your kernel\n"); -+ return 0; -+ } -+ -+ return 1; -+} -+ -+ -+static struct super_block *squashfs_read_super(struct super_block *s, -+ void *data, int silent) -+{ -+ kdev_t dev = s->s_dev; -+ struct squashfs_sb_info *msblk = &s->u.squashfs_sb; -+ struct squashfs_super_block *sblk = &msblk->sblk; -+ int i; -+ struct inode *root; -+ -+ msblk->devblksize = get_hardsect_size(dev); -+ if(msblk->devblksize < BLOCK_SIZE) -+ msblk->devblksize = BLOCK_SIZE; -+ msblk->devblksize_log2 = ffz(~msblk->devblksize); -+ set_blocksize(dev, msblk->devblksize); -+ s->s_blocksize = msblk->devblksize; -+ s->s_blocksize_bits = msblk->devblksize_log2; -+ -+ init_MUTEX(&msblk->read_data_mutex); -+ init_MUTEX(&msblk->read_page_mutex); -+ init_MUTEX(&msblk->block_cache_mutex); -+ init_MUTEX(&msblk->fragment_mutex); -+ -+ init_waitqueue_head(&msblk->waitq); -+ init_waitqueue_head(&msblk->fragment_wait_queue); -+ -+ if (!squashfs_read_data(s, (char *) sblk, SQUASHFS_START, -+ sizeof(struct squashfs_super_block) | -+ SQUASHFS_COMPRESSED_BIT_BLOCK, NULL)) { -+ SERROR("unable to read superblock\n"); -+ goto failed_mount; -+ } -+ -+ /* Check it is a SQUASHFS superblock */ -+ msblk->swap = 0; -+ if ((s->s_magic = sblk->s_magic) != SQUASHFS_MAGIC) { -+ if (sblk->s_magic == SQUASHFS_MAGIC_SWAP) { -+ struct squashfs_super_block ssblk; -+ -+ WARNING("Mounting a different endian SQUASHFS " -+ "filesystem on %s\n", bdevname(dev)); -+ -+ SQUASHFS_SWAP_SUPER_BLOCK(&ssblk, sblk); -+ memcpy(sblk, &ssblk, sizeof(struct squashfs_super_block)); -+ msblk->swap = 1; -+ } else { -+ SERROR("Can't find a SQUASHFS superblock on %s\n", -+ bdevname(dev)); -+ goto failed_mount; -+ } -+ } -+ -+ /* Check the MAJOR & MINOR versions */ -+ if(!supported_squashfs_filesystem(msblk, silent)) -+ goto failed_mount; -+ -+ TRACE("Found valid superblock on %s\n", bdevname(dev)); -+ TRACE("Inodes are %scompressed\n", -+ SQUASHFS_UNCOMPRESSED_INODES -+ (sblk->flags) ? "un" : ""); -+ TRACE("Data is %scompressed\n", -+ SQUASHFS_UNCOMPRESSED_DATA(sblk->flags) -+ ? "un" : ""); -+ TRACE("Check data is %s present in the filesystem\n", -+ SQUASHFS_CHECK_DATA(sblk->flags) ? -+ "" : "not"); -+ TRACE("Filesystem size %lld bytes\n", sblk->bytes_used); -+ TRACE("Block size %d\n", sblk->block_size); -+ TRACE("Number of inodes %d\n", sblk->inodes); -+ if (sblk->s_major > 1) -+ TRACE("Number of fragments %d\n", sblk->fragments); -+ TRACE("Number of uids %d\n", sblk->no_uids); -+ TRACE("Number of gids %d\n", sblk->no_guids); -+ TRACE("sblk->inode_table_start %llx\n", sblk->inode_table_start); -+ TRACE("sblk->directory_table_start %llx\n", sblk->directory_table_start); -+ if (sblk->s_major > 1) -+ TRACE("sblk->fragment_table_start %llx\n", -+ sblk->fragment_table_start); -+ TRACE("sblk->uid_start %llx\n", sblk->uid_start); -+ -+ s->s_flags |= MS_RDONLY; -+ s->s_op = &squashfs_ops; -+ -+ /* Init inode_table block pointer array */ -+ if (!(msblk->block_cache = kmalloc(sizeof(struct squashfs_cache) * -+ SQUASHFS_CACHED_BLKS, GFP_KERNEL))) { -+ ERROR("Failed to allocate block cache\n"); -+ goto failed_mount; -+ } -+ -+ for (i = 0; i < SQUASHFS_CACHED_BLKS; i++) -+ msblk->block_cache[i].block = SQUASHFS_INVALID_BLK; -+ -+ msblk->next_cache = 0; -+ -+ /* Allocate read_data block */ -+ msblk->read_size = (sblk->block_size < SQUASHFS_METADATA_SIZE) ? -+ SQUASHFS_METADATA_SIZE : -+ sblk->block_size; -+ -+ if (!(msblk->read_data = kmalloc(msblk->read_size, GFP_KERNEL))) { -+ ERROR("Failed to allocate read_data block\n"); -+ goto failed_mount; -+ } -+ -+ /* Allocate read_page block */ -+ if (!(msblk->read_page = kmalloc(sblk->block_size, GFP_KERNEL))) { -+ ERROR("Failed to allocate read_page block\n"); -+ goto failed_mount; -+ } -+ -+ /* Allocate uid and gid tables */ -+ if (!(msblk->uid = kmalloc((sblk->no_uids + sblk->no_guids) * -+ sizeof(unsigned int), GFP_KERNEL))) { -+ ERROR("Failed to allocate uid/gid table\n"); -+ goto failed_mount; -+ } -+ msblk->guid = msblk->uid + sblk->no_uids; -+ -+ if (msblk->swap) { -+ unsigned int suid[sblk->no_uids + sblk->no_guids]; -+ -+ if (!squashfs_read_data(s, (char *) &suid, sblk->uid_start, -+ ((sblk->no_uids + sblk->no_guids) * -+ sizeof(unsigned int)) | -+ SQUASHFS_COMPRESSED_BIT_BLOCK, NULL)) { -+ ERROR("unable to read uid/gid table\n"); -+ goto failed_mount; -+ } -+ -+ SQUASHFS_SWAP_DATA(msblk->uid, suid, (sblk->no_uids + -+ sblk->no_guids), (sizeof(unsigned int) * 8)); -+ } else -+ if (!squashfs_read_data(s, (char *) msblk->uid, sblk->uid_start, -+ ((sblk->no_uids + sblk->no_guids) * -+ sizeof(unsigned int)) | -+ SQUASHFS_COMPRESSED_BIT_BLOCK, NULL)) { -+ ERROR("unable to read uid/gid table\n"); -+ goto failed_mount; -+ } -+ -+ -+ if (sblk->s_major == 1 && squashfs_1_0_supported(msblk)) -+ goto allocate_root; -+ -+ if (!(msblk->fragment = kmalloc(sizeof(struct squashfs_fragment_cache) * -+ SQUASHFS_CACHED_FRAGMENTS, GFP_KERNEL))) { -+ ERROR("Failed to allocate fragment block cache\n"); -+ goto failed_mount; -+ } -+ -+ for (i = 0; i < SQUASHFS_CACHED_FRAGMENTS; i++) { -+ msblk->fragment[i].locked = 0; -+ msblk->fragment[i].block = SQUASHFS_INVALID_BLK; -+ msblk->fragment[i].data = NULL; -+ } -+ -+ msblk->next_fragment = 0; -+ -+ /* Allocate fragment index table */ -+ if(msblk->read_fragment_index_table(s) == 0) -+ goto failed_mount; -+ -+allocate_root: -+ if ((root = (msblk->iget)(s, sblk->root_inode)) == NULL) -+ goto failed_mount; -+ -+ if ((s->s_root = d_alloc_root(root)) == NULL) { -+ ERROR("Root inode create failed\n"); -+ iput(root); -+ goto failed_mount; -+ } -+ -+ TRACE("Leaving squashfs_read_super\n"); -+ return s; -+ -+failed_mount: -+ kfree(msblk->fragment_index); -+ kfree(msblk->fragment); -+ kfree(msblk->uid); -+ kfree(msblk->read_page); -+ kfree(msblk->read_data); -+ kfree(msblk->block_cache); -+ kfree(msblk->fragment_index_2); -+ return NULL; -+} -+ -+ -+static int squashfs_statfs(struct super_block *s, struct statfs *buf) -+{ -+ struct squashfs_sb_info *msblk = &s->u.squashfs_sb; -+ struct squashfs_super_block *sblk = &msblk->sblk; -+ -+ TRACE("Entered squashfs_statfs\n"); -+ -+ buf->f_type = SQUASHFS_MAGIC; -+ buf->f_bsize = sblk->block_size; -+ buf->f_blocks = ((sblk->bytes_used - 1) >> sblk->block_log) + 1; -+ buf->f_bfree = buf->f_bavail = 0; -+ buf->f_files = sblk->inodes; -+ buf->f_ffree = 0; -+ buf->f_namelen = SQUASHFS_NAME_LEN; -+ -+ return 0; -+} -+ -+ -+static int squashfs_symlink_readpage(struct file *file, struct page *page) -+{ -+ struct inode *inode = page->mapping->host; -+ int index = page->index << PAGE_CACHE_SHIFT, length, bytes; -+ long long block = SQUASHFS_I(inode)->start_block; -+ int offset = SQUASHFS_I(inode)->offset; -+ void *pageaddr = kmap(page); -+ -+ TRACE("Entered squashfs_symlink_readpage, page index %ld, start block " -+ "%llx, offset %x\n", page->index, -+ SQUASHFS_I(inode)->start_block, -+ SQUASHFS_I(inode)->offset); -+ -+ for (length = 0; length < index; length += bytes) { -+ if (!(bytes = squashfs_get_cached_block(inode->i_sb, NULL, -+ block, offset, PAGE_CACHE_SIZE, &block, -+ &offset))) { -+ ERROR("Unable to read symbolic link [%llx:%x]\n", block, -+ offset); -+ goto skip_read; -+ } -+ } -+ -+ if (length != index) { -+ ERROR("(squashfs_symlink_readpage) length != index\n"); -+ bytes = 0; -+ goto skip_read; -+ } -+ -+ bytes = (i_size_read(inode) - length) > PAGE_CACHE_SIZE ? PAGE_CACHE_SIZE : -+ i_size_read(inode) - length; -+ -+ if (!(bytes = squashfs_get_cached_block(inode->i_sb, pageaddr, block, -+ offset, bytes, &block, &offset))) -+ ERROR("Unable to read symbolic link [%llx:%x]\n", block, offset); -+ -+skip_read: -+ memset(pageaddr + bytes, 0, PAGE_CACHE_SIZE - bytes); -+ kunmap(page); -+ SetPageUptodate(page); -+ UnlockPage(page); -+ -+ return 0; -+} -+ -+ -+struct meta_index *locate_meta_index(struct inode *inode, int index, int offset) -+{ -+ struct meta_index *meta = NULL; -+ struct squashfs_sb_info *msblk = &inode->i_sb->u.squashfs_sb; -+ int i; -+ -+ down(&msblk->meta_index_mutex); -+ -+ TRACE("locate_meta_index: index %d, offset %d\n", index, offset); -+ -+ if(msblk->meta_index == NULL) -+ goto not_allocated; -+ -+ for (i = 0; i < SQUASHFS_META_NUMBER; i ++) -+ if (msblk->meta_index[i].inode_number == inode->i_ino && -+ msblk->meta_index[i].offset >= offset && -+ msblk->meta_index[i].offset <= index && -+ msblk->meta_index[i].locked == 0) { -+ TRACE("locate_meta_index: entry %d, offset %d\n", i, -+ msblk->meta_index[i].offset); -+ meta = &msblk->meta_index[i]; -+ offset = meta->offset; -+ } -+ -+ if (meta) -+ meta->locked = 1; -+ -+not_allocated: -+ up(&msblk->meta_index_mutex); -+ -+ return meta; -+} -+ -+ -+struct meta_index *empty_meta_index(struct inode *inode, int offset, int skip) -+{ -+ struct squashfs_sb_info *msblk = &inode->i_sb->u.squashfs_sb; -+ struct meta_index *meta = NULL; -+ int i; -+ -+ down(&msblk->meta_index_mutex); -+ -+ TRACE("empty_meta_index: offset %d, skip %d\n", offset, skip); -+ -+ if(msblk->meta_index == NULL) { -+ if (!(msblk->meta_index = kmalloc(sizeof(struct meta_index) * -+ SQUASHFS_META_NUMBER, GFP_KERNEL))) { -+ ERROR("Failed to allocate meta_index\n"); -+ goto failed; -+ } -+ for(i = 0; i < SQUASHFS_META_NUMBER; i++) { -+ msblk->meta_index[i].inode_number = 0; -+ msblk->meta_index[i].locked = 0; -+ } -+ msblk->next_meta_index = 0; -+ } -+ -+ for(i = SQUASHFS_META_NUMBER; i && -+ msblk->meta_index[msblk->next_meta_index].locked; i --) -+ msblk->next_meta_index = (msblk->next_meta_index + 1) % -+ SQUASHFS_META_NUMBER; -+ -+ if(i == 0) { -+ TRACE("empty_meta_index: failed!\n"); -+ goto failed; -+ } -+ -+ TRACE("empty_meta_index: returned meta entry %d, %p\n", -+ msblk->next_meta_index, -+ &msblk->meta_index[msblk->next_meta_index]); -+ -+ meta = &msblk->meta_index[msblk->next_meta_index]; -+ msblk->next_meta_index = (msblk->next_meta_index + 1) % -+ SQUASHFS_META_NUMBER; -+ -+ meta->inode_number = inode->i_ino; -+ meta->offset = offset; -+ meta->skip = skip; -+ meta->entries = 0; -+ meta->locked = 1; -+ -+failed: -+ up(&msblk->meta_index_mutex); -+ return meta; -+} -+ -+ -+void release_meta_index(struct inode *inode, struct meta_index *meta) -+{ -+ meta->locked = 0; -+} -+ -+ -+static int read_block_index(struct super_block *s, int blocks, char *block_list, -+ long long *start_block, int *offset) -+{ -+ struct squashfs_sb_info *msblk = &s->u.squashfs_sb; -+ unsigned int *block_listp; -+ int block = 0; -+ -+ if (msblk->swap) { -+ char sblock_list[blocks << 2]; -+ -+ if (!squashfs_get_cached_block(s, sblock_list, *start_block, -+ *offset, blocks << 2, start_block, offset)) { -+ ERROR("Unable to read block list [%llx:%x]\n", -+ *start_block, *offset); -+ goto failure; -+ } -+ SQUASHFS_SWAP_INTS(((unsigned int *)block_list), -+ ((unsigned int *)sblock_list), blocks); -+ } else -+ if (!squashfs_get_cached_block(s, block_list, *start_block, -+ *offset, blocks << 2, start_block, offset)) { -+ ERROR("Unable to read block list [%llx:%x]\n", -+ *start_block, *offset); -+ goto failure; -+ } -+ -+ for (block_listp = (unsigned int *) block_list; blocks; -+ block_listp++, blocks --) -+ block += SQUASHFS_COMPRESSED_SIZE_BLOCK(*block_listp); -+ -+ return block; -+ -+failure: -+ return -1; -+} -+ -+ -+#define SIZE 256 -+ -+static inline int calculate_skip(int blocks) { -+ int skip = (blocks - 1) / ((SQUASHFS_SLOTS * SQUASHFS_META_ENTRIES + 1) * SQUASHFS_META_INDEXES); -+ return skip >= 7 ? 7 : skip + 1; -+} -+ -+ -+static int get_meta_index(struct inode *inode, int index, -+ long long *index_block, int *index_offset, -+ long long *data_block, char *block_list) -+{ -+ struct squashfs_sb_info *msblk = &inode->i_sb->u.squashfs_sb; -+ struct squashfs_super_block *sblk = &msblk->sblk; -+ int skip = calculate_skip(i_size_read(inode) >> sblk->block_log); -+ int offset = 0; -+ struct meta_index *meta; -+ struct meta_entry *meta_entry; -+ long long cur_index_block = SQUASHFS_I(inode)->u.s1.block_list_start; -+ int cur_offset = SQUASHFS_I(inode)->offset; -+ long long cur_data_block = SQUASHFS_I(inode)->start_block; -+ int i; -+ -+ index /= SQUASHFS_META_INDEXES * skip; -+ -+ while ( offset < index ) { -+ meta = locate_meta_index(inode, index, offset + 1); -+ -+ if (meta == NULL) { -+ if ((meta = empty_meta_index(inode, offset + 1, -+ skip)) == NULL) -+ goto all_done; -+ } else { -+ offset = index < meta->offset + meta->entries ? index : -+ meta->offset + meta->entries - 1; -+ meta_entry = &meta->meta_entry[offset - meta->offset]; -+ cur_index_block = meta_entry->index_block + sblk->inode_table_start; -+ cur_offset = meta_entry->offset; -+ cur_data_block = meta_entry->data_block; -+ TRACE("get_meta_index: offset %d, meta->offset %d, " -+ "meta->entries %d\n", offset, meta->offset, -+ meta->entries); -+ TRACE("get_meta_index: index_block 0x%llx, offset 0x%x" -+ " data_block 0x%llx\n", cur_index_block, -+ cur_offset, cur_data_block); -+ } -+ -+ for (i = meta->offset + meta->entries; i <= index && -+ i < meta->offset + SQUASHFS_META_ENTRIES; i++) { -+ int blocks = skip * SQUASHFS_META_INDEXES; -+ -+ while (blocks) { -+ int block = blocks > (SIZE >> 2) ? (SIZE >> 2) : -+ blocks; -+ int res = read_block_index(inode->i_sb, block, -+ block_list, &cur_index_block, -+ &cur_offset); -+ -+ if (res == -1) -+ goto failed; -+ -+ cur_data_block += res; -+ blocks -= block; -+ } -+ -+ meta_entry = &meta->meta_entry[i - meta->offset]; -+ meta_entry->index_block = cur_index_block - sblk->inode_table_start; -+ meta_entry->offset = cur_offset; -+ meta_entry->data_block = cur_data_block; -+ meta->entries ++; -+ offset ++; -+ } -+ -+ TRACE("get_meta_index: meta->offset %d, meta->entries %d\n", -+ meta->offset, meta->entries); -+ -+ release_meta_index(inode, meta); -+ } -+ -+all_done: -+ *index_block = cur_index_block; -+ *index_offset = cur_offset; -+ *data_block = cur_data_block; -+ -+ return offset * SQUASHFS_META_INDEXES * skip; -+ -+failed: -+ release_meta_index(inode, meta); -+ return -1; -+} -+ -+ -+static long long read_blocklist(struct inode *inode, int index, -+ int readahead_blks, char *block_list, -+ unsigned short **block_p, unsigned int *bsize) -+{ -+ long long block_ptr; -+ int offset; -+ long long block; -+ int res = get_meta_index(inode, index, &block_ptr, &offset, &block, -+ block_list); -+ -+ TRACE("read_blocklist: res %d, index %d, block_ptr 0x%llx, offset" -+ " 0x%x, block 0x%llx\n", res, index, block_ptr, offset, -+ block); -+ -+ if(res == -1) -+ goto failure; -+ -+ index -= res; -+ -+ while ( index ) { -+ int blocks = index > (SIZE >> 2) ? (SIZE >> 2) : index; -+ int res = read_block_index(inode->i_sb, blocks, block_list, -+ &block_ptr, &offset); -+ if (res == -1) -+ goto failure; -+ block += res; -+ index -= blocks; -+ } -+ -+ if (read_block_index(inode->i_sb, 1, block_list, -+ &block_ptr, &offset) == -1) -+ goto failure; -+ *bsize = *((unsigned int *) block_list); -+ -+ return block; -+ -+failure: -+ return 0; -+} -+ -+ -+static int squashfs_readpage(struct file *file, struct page *page) -+{ -+ struct inode *inode = page->mapping->host; -+ struct squashfs_sb_info *msblk = &inode->i_sb->u.squashfs_sb; -+ struct squashfs_super_block *sblk = &msblk->sblk; -+ unsigned char block_list[SIZE]; -+ long long block; -+ unsigned int bsize, i = 0, bytes = 0, byte_offset = 0; -+ int index = page->index >> (sblk->block_log - PAGE_CACHE_SHIFT); -+ void *pageaddr; -+ struct squashfs_fragment_cache *fragment = NULL; -+ char *data_ptr = msblk->read_page; -+ -+ int mask = (1 << (sblk->block_log - PAGE_CACHE_SHIFT)) - 1; -+ int start_index = page->index & ~mask; -+ int end_index = start_index | mask; -+ -+ TRACE("Entered squashfs_readpage, page index %lx, start block %llx\n", -+ page->index, -+ SQUASHFS_I(inode)->start_block); -+ -+ if (page->index >= ((i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> -+ PAGE_CACHE_SHIFT)) -+ goto skip_read; -+ -+ if (SQUASHFS_I(inode)->u.s1.fragment_start_block == SQUASHFS_INVALID_BLK -+ || index < (i_size_read(inode) >> -+ sblk->block_log)) { -+ if ((block = (msblk->read_blocklist)(inode, index, 1, -+ block_list, NULL, &bsize)) == 0) -+ goto skip_read; -+ -+ down(&msblk->read_page_mutex); -+ -+ if (!(bytes = squashfs_read_data(inode->i_sb, msblk->read_page, -+ block, bsize, NULL))) { -+ ERROR("Unable to read page, block %llx, size %x\n", block, -+ bsize); -+ up(&msblk->read_page_mutex); -+ goto skip_read; -+ } -+ } else { -+ if ((fragment = get_cached_fragment(inode->i_sb, -+ SQUASHFS_I(inode)-> -+ u.s1.fragment_start_block, -+ SQUASHFS_I(inode)->u.s1.fragment_size)) -+ == NULL) { -+ ERROR("Unable to read page, block %llx, size %x\n", -+ SQUASHFS_I(inode)-> -+ u.s1.fragment_start_block, -+ (int) SQUASHFS_I(inode)-> -+ u.s1.fragment_size); -+ goto skip_read; -+ } -+ bytes = SQUASHFS_I(inode)->u.s1.fragment_offset + -+ (i_size_read(inode) & (sblk->block_size -+ - 1)); -+ byte_offset = SQUASHFS_I(inode)->u.s1.fragment_offset; -+ data_ptr = fragment->data; -+ } -+ -+ for (i = start_index; i <= end_index && byte_offset < bytes; -+ i++, byte_offset += PAGE_CACHE_SIZE) { -+ struct page *push_page; -+ int available_bytes = (bytes - byte_offset) > PAGE_CACHE_SIZE ? -+ PAGE_CACHE_SIZE : bytes - byte_offset; -+ -+ TRACE("bytes %d, i %d, byte_offset %d, available_bytes %d\n", -+ bytes, i, byte_offset, available_bytes); -+ -+ if (i == page->index) { -+ pageaddr = kmap_atomic(page, KM_USER0); -+ memcpy(pageaddr, data_ptr + byte_offset, -+ available_bytes); -+ memset(pageaddr + available_bytes, 0, -+ PAGE_CACHE_SIZE - available_bytes); -+ kunmap_atomic(pageaddr, KM_USER0); -+ flush_dcache_page(page); -+ SetPageUptodate(page); -+ UnlockPage(page); -+ } else if ((push_page = -+ grab_cache_page_nowait(page->mapping, i))) { -+ pageaddr = kmap_atomic(push_page, KM_USER0); -+ -+ memcpy(pageaddr, data_ptr + byte_offset, -+ available_bytes); -+ memset(pageaddr + available_bytes, 0, -+ PAGE_CACHE_SIZE - available_bytes); -+ kunmap_atomic(pageaddr, KM_USER0); -+ flush_dcache_page(push_page); -+ SetPageUptodate(push_page); -+ UnlockPage(push_page); -+ page_cache_release(push_page); -+ } -+ } -+ -+ if (SQUASHFS_I(inode)->u.s1.fragment_start_block == SQUASHFS_INVALID_BLK -+ || index < (i_size_read(inode) >> -+ sblk->block_log)) -+ up(&msblk->read_page_mutex); -+ else -+ release_cached_fragment(msblk, fragment); -+ -+ return 0; -+ -+skip_read: -+ pageaddr = kmap_atomic(page, KM_USER0); -+ memset(pageaddr + bytes, 0, PAGE_CACHE_SIZE - bytes); -+ kunmap_atomic(pageaddr, KM_USER0); -+ flush_dcache_page(page); -+ SetPageUptodate(page); -+ UnlockPage(page); -+ -+ return 0; -+} -+ -+ -+static int squashfs_readpage4K(struct file *file, struct page *page) -+{ -+ struct inode *inode = page->mapping->host; -+ struct squashfs_sb_info *msblk = &inode->i_sb->u.squashfs_sb; -+ struct squashfs_super_block *sblk = &msblk->sblk; -+ unsigned char block_list[SIZE]; -+ long long block; -+ unsigned int bsize, bytes = 0; -+ void *pageaddr; -+ -+ TRACE("Entered squashfs_readpage4K, page index %lx, start block %llx\n", -+ page->index, -+ SQUASHFS_I(inode)->start_block); -+ -+ if (page->index >= ((i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> -+ PAGE_CACHE_SHIFT)) { -+ pageaddr = kmap_atomic(page, KM_USER0); -+ goto skip_read; -+ } -+ -+ if (SQUASHFS_I(inode)->u.s1.fragment_start_block == SQUASHFS_INVALID_BLK -+ || page->index < (i_size_read(inode) >> -+ sblk->block_log)) { -+ block = (msblk->read_blocklist)(inode, page->index, 1, -+ block_list, NULL, &bsize); -+ -+ down(&msblk->read_page_mutex); -+ bytes = squashfs_read_data(inode->i_sb, msblk->read_page, block, -+ bsize, NULL); -+ pageaddr = kmap_atomic(page, KM_USER0); -+ if (bytes) -+ memcpy(pageaddr, msblk->read_page, bytes); -+ else -+ ERROR("Unable to read page, block %llx, size %x\n", -+ block, bsize); -+ up(&msblk->read_page_mutex); -+ } else { -+ struct squashfs_fragment_cache *fragment = -+ get_cached_fragment(inode->i_sb, -+ SQUASHFS_I(inode)-> -+ u.s1.fragment_start_block, -+ SQUASHFS_I(inode)-> u.s1.fragment_size); -+ pageaddr = kmap_atomic(page, KM_USER0); -+ if (fragment) { -+ bytes = i_size_read(inode) & (sblk->block_size - 1); -+ memcpy(pageaddr, fragment->data + SQUASHFS_I(inode)-> -+ u.s1.fragment_offset, bytes); -+ release_cached_fragment(msblk, fragment); -+ } else -+ ERROR("Unable to read page, block %llx, size %x\n", -+ SQUASHFS_I(inode)-> -+ u.s1.fragment_start_block, (int) -+ SQUASHFS_I(inode)-> u.s1.fragment_size); -+ } -+ -+skip_read: -+ memset(pageaddr + bytes, 0, PAGE_CACHE_SIZE - bytes); -+ kunmap_atomic(pageaddr, KM_USER0); -+ flush_dcache_page(page); -+ SetPageUptodate(page); -+ UnlockPage(page); -+ -+ return 0; -+} -+ -+ -+static int get_dir_index_using_offset(struct super_block *s, long long -+ *next_block, unsigned int *next_offset, -+ long long index_start, -+ unsigned int index_offset, int i_count, -+ long long f_pos) -+{ -+ struct squashfs_sb_info *msblk = &s->u.squashfs_sb; -+ struct squashfs_super_block *sblk = &msblk->sblk; -+ int i, length = 0; -+ struct squashfs_dir_index index; -+ -+ TRACE("Entered get_dir_index_using_offset, i_count %d, f_pos %d\n", -+ i_count, (unsigned int) f_pos); -+ -+ f_pos -= 3; -+ if (f_pos == 0) -+ goto finish; -+ -+ for (i = 0; i < i_count; i++) { -+ if (msblk->swap) { -+ struct squashfs_dir_index sindex; -+ squashfs_get_cached_block(s, (char *) &sindex, -+ index_start, index_offset, -+ sizeof(sindex), &index_start, -+ &index_offset); -+ SQUASHFS_SWAP_DIR_INDEX(&index, &sindex); -+ } else -+ squashfs_get_cached_block(s, (char *) &index, -+ index_start, index_offset, -+ sizeof(index), &index_start, -+ &index_offset); -+ -+ if (index.index > f_pos) -+ break; -+ -+ squashfs_get_cached_block(s, NULL, index_start, index_offset, -+ index.size + 1, &index_start, -+ &index_offset); -+ -+ length = index.index; -+ *next_block = index.start_block + sblk->directory_table_start; -+ } -+ -+ *next_offset = (length + *next_offset) % SQUASHFS_METADATA_SIZE; -+ -+finish: -+ return length + 3; -+} -+ -+ -+static int get_dir_index_using_name(struct super_block *s, long long -+ *next_block, unsigned int *next_offset, -+ long long index_start, -+ unsigned int index_offset, int i_count, -+ const char *name, int size) -+{ -+ struct squashfs_sb_info *msblk = &s->u.squashfs_sb; -+ struct squashfs_super_block *sblk = &msblk->sblk; -+ int i, length = 0; -+ char buffer[sizeof(struct squashfs_dir_index) + SQUASHFS_NAME_LEN + 1]; -+ struct squashfs_dir_index *index = (struct squashfs_dir_index *) buffer; -+ char str[SQUASHFS_NAME_LEN + 1]; -+ -+ TRACE("Entered get_dir_index_using_name, i_count %d\n", i_count); -+ -+ strncpy(str, name, size); -+ str[size] = '\0'; -+ -+ for (i = 0; i < i_count; i++) { -+ if (msblk->swap) { -+ struct squashfs_dir_index sindex; -+ squashfs_get_cached_block(s, (char *) &sindex, -+ index_start, index_offset, -+ sizeof(sindex), &index_start, -+ &index_offset); -+ SQUASHFS_SWAP_DIR_INDEX(index, &sindex); -+ } else -+ squashfs_get_cached_block(s, (char *) index, -+ index_start, index_offset, -+ sizeof(struct squashfs_dir_index), -+ &index_start, &index_offset); -+ -+ squashfs_get_cached_block(s, index->name, index_start, -+ index_offset, index->size + 1, -+ &index_start, &index_offset); -+ -+ index->name[index->size + 1] = '\0'; -+ -+ if (strcmp(index->name, str) > 0) -+ break; -+ -+ length = index->index; -+ *next_block = index->start_block + sblk->directory_table_start; -+ } -+ -+ *next_offset = (length + *next_offset) % SQUASHFS_METADATA_SIZE; -+ return length + 3; -+} -+ -+ -+static int squashfs_readdir(struct file *file, void *dirent, filldir_t filldir) -+{ -+ struct inode *i = file->f_dentry->d_inode; -+ struct squashfs_sb_info *msblk = &i->i_sb->u.squashfs_sb; -+ struct squashfs_super_block *sblk = &msblk->sblk; -+ long long next_block = SQUASHFS_I(i)->start_block + -+ sblk->directory_table_start; -+ int next_offset = SQUASHFS_I(i)->offset, length = 0, dirs_read = 0, -+ dir_count; -+ struct squashfs_dir_header dirh; -+ char buffer[sizeof(struct squashfs_dir_entry) + SQUASHFS_NAME_LEN + 1]; -+ struct squashfs_dir_entry *dire = (struct squashfs_dir_entry *) buffer; -+ -+ TRACE("Entered squashfs_readdir [%llx:%x]\n", next_block, next_offset); -+ -+ while(file->f_pos < 3) { -+ char *name; -+ int size, i_ino; -+ -+ if(file->f_pos == 0) { -+ name = "."; -+ size = 1; -+ i_ino = i->i_ino; -+ } else { -+ name = ".."; -+ size = 2; -+ i_ino = SQUASHFS_I(i)->u.s2.parent_inode; -+ } -+ TRACE("Calling filldir(%x, %s, %d, %d, %d, %d)\n", -+ (unsigned int) dirent, name, size, (int) -+ file->f_pos, i_ino, -+ squashfs_filetype_table[1]); -+ -+ if (filldir(dirent, name, size, -+ file->f_pos, i_ino, -+ squashfs_filetype_table[1]) < 0) { -+ TRACE("Filldir returned less than 0\n"); -+ goto finish; -+ } -+ file->f_pos += size; -+ dirs_read++; -+ } -+ -+ length = get_dir_index_using_offset(i->i_sb, &next_block, &next_offset, -+ SQUASHFS_I(i)->u.s2.directory_index_start, -+ SQUASHFS_I(i)->u.s2.directory_index_offset, -+ SQUASHFS_I(i)->u.s2.directory_index_count, -+ file->f_pos); -+ -+ while (length < i_size_read(i)) { -+ /* read directory header */ -+ if (msblk->swap) { -+ struct squashfs_dir_header sdirh; -+ -+ if (!squashfs_get_cached_block(i->i_sb, (char *) &sdirh, -+ next_block, next_offset, sizeof(sdirh), -+ &next_block, &next_offset)) -+ goto failed_read; -+ -+ length += sizeof(sdirh); -+ SQUASHFS_SWAP_DIR_HEADER(&dirh, &sdirh); -+ } else { -+ if (!squashfs_get_cached_block(i->i_sb, (char *) &dirh, -+ next_block, next_offset, sizeof(dirh), -+ &next_block, &next_offset)) -+ goto failed_read; -+ -+ length += sizeof(dirh); -+ } -+ -+ dir_count = dirh.count + 1; -+ while (dir_count--) { -+ if (msblk->swap) { -+ struct squashfs_dir_entry sdire; -+ if (!squashfs_get_cached_block(i->i_sb, (char *) -+ &sdire, next_block, next_offset, -+ sizeof(sdire), &next_block, -+ &next_offset)) -+ goto failed_read; -+ -+ length += sizeof(sdire); -+ SQUASHFS_SWAP_DIR_ENTRY(dire, &sdire); -+ } else { -+ if (!squashfs_get_cached_block(i->i_sb, (char *) -+ dire, next_block, next_offset, -+ sizeof(*dire), &next_block, -+ &next_offset)) -+ goto failed_read; -+ -+ length += sizeof(*dire); -+ } -+ -+ if (!squashfs_get_cached_block(i->i_sb, dire->name, -+ next_block, next_offset, -+ dire->size + 1, &next_block, -+ &next_offset)) -+ goto failed_read; -+ -+ length += dire->size + 1; -+ -+ if (file->f_pos >= length) -+ continue; -+ -+ dire->name[dire->size + 1] = '\0'; -+ -+ TRACE("Calling filldir(%x, %s, %d, %d, %x:%x, %d, %d)\n", -+ (unsigned int) dirent, dire->name, -+ dire->size + 1, (int) file->f_pos, -+ dirh.start_block, dire->offset, -+ dirh.inode_number + dire->inode_number, -+ squashfs_filetype_table[dire->type]); -+ -+ if (filldir(dirent, dire->name, dire->size + 1, -+ file->f_pos, -+ dirh.inode_number + dire->inode_number, -+ squashfs_filetype_table[dire->type]) -+ < 0) { -+ TRACE("Filldir returned less than 0\n"); -+ goto finish; -+ } -+ file->f_pos = length; -+ dirs_read++; -+ } -+ } -+ -+finish: -+ return dirs_read; -+ -+failed_read: -+ ERROR("Unable to read directory block [%llx:%x]\n", next_block, -+ next_offset); -+ return 0; -+} -+ -+ -+static struct dentry *squashfs_lookup(struct inode *i, struct dentry *dentry) -+{ -+ const unsigned char *name = dentry->d_name.name; -+ int len = dentry->d_name.len; -+ struct inode *inode = NULL; -+ struct squashfs_sb_info *msblk = &i->i_sb->u.squashfs_sb; -+ struct squashfs_super_block *sblk = &msblk->sblk; -+ long long next_block = SQUASHFS_I(i)->start_block + -+ sblk->directory_table_start; -+ int next_offset = SQUASHFS_I(i)->offset, length = 0, -+ dir_count; -+ struct squashfs_dir_header dirh; -+ char buffer[sizeof(struct squashfs_dir_entry) + SQUASHFS_NAME_LEN]; -+ struct squashfs_dir_entry *dire = (struct squashfs_dir_entry *) buffer; -+ -+ TRACE("Entered squashfs_lookup [%llx:%x]\n", next_block, next_offset); -+ -+ if (len > SQUASHFS_NAME_LEN) -+ goto exit_loop; -+ -+ length = get_dir_index_using_name(i->i_sb, &next_block, &next_offset, -+ SQUASHFS_I(i)->u.s2.directory_index_start, -+ SQUASHFS_I(i)->u.s2.directory_index_offset, -+ SQUASHFS_I(i)->u.s2.directory_index_count, name, -+ len); -+ -+ while (length < i_size_read(i)) { -+ /* read directory header */ -+ if (msblk->swap) { -+ struct squashfs_dir_header sdirh; -+ if (!squashfs_get_cached_block(i->i_sb, (char *) &sdirh, -+ next_block, next_offset, sizeof(sdirh), -+ &next_block, &next_offset)) -+ goto failed_read; -+ -+ length += sizeof(sdirh); -+ SQUASHFS_SWAP_DIR_HEADER(&dirh, &sdirh); -+ } else { -+ if (!squashfs_get_cached_block(i->i_sb, (char *) &dirh, -+ next_block, next_offset, sizeof(dirh), -+ &next_block, &next_offset)) -+ goto failed_read; -+ -+ length += sizeof(dirh); -+ } -+ -+ dir_count = dirh.count + 1; -+ while (dir_count--) { -+ if (msblk->swap) { -+ struct squashfs_dir_entry sdire; -+ if (!squashfs_get_cached_block(i->i_sb, (char *) -+ &sdire, next_block,next_offset, -+ sizeof(sdire), &next_block, -+ &next_offset)) -+ goto failed_read; -+ -+ length += sizeof(sdire); -+ SQUASHFS_SWAP_DIR_ENTRY(dire, &sdire); -+ } else { -+ if (!squashfs_get_cached_block(i->i_sb, (char *) -+ dire, next_block,next_offset, -+ sizeof(*dire), &next_block, -+ &next_offset)) -+ goto failed_read; -+ -+ length += sizeof(*dire); -+ } -+ -+ if (!squashfs_get_cached_block(i->i_sb, dire->name, -+ next_block, next_offset, dire->size + 1, -+ &next_block, &next_offset)) -+ goto failed_read; -+ -+ length += dire->size + 1; -+ -+ if (name[0] < dire->name[0]) -+ goto exit_loop; -+ -+ if ((len == dire->size + 1) && !strncmp(name, -+ dire->name, len)) { -+ squashfs_inode_t ino = -+ SQUASHFS_MKINODE(dirh.start_block, -+ dire->offset); -+ -+ TRACE("calling squashfs_iget for directory " -+ "entry %s, inode %x:%x, %d\n", name, -+ dirh.start_block, dire->offset, -+ dirh.inode_number + dire->inode_number); -+ -+ inode = (msblk->iget)(i->i_sb, ino); -+ -+ goto exit_loop; -+ } -+ } -+ } -+ -+exit_loop: -+ d_add(dentry, inode); -+ return ERR_PTR(0); -+ -+failed_read: -+ ERROR("Unable to read directory block [%llx:%x]\n", next_block, -+ next_offset); -+ goto exit_loop; -+} -+ -+ -+static void squashfs_put_super(struct super_block *s) -+{ -+ int i; -+ -+ struct squashfs_sb_info *sbi = &s->u.squashfs_sb; -+ if (sbi->block_cache) -+ for (i = 0; i < SQUASHFS_CACHED_BLKS; i++) -+ if (sbi->block_cache[i].block != -+ SQUASHFS_INVALID_BLK) -+ kfree(sbi->block_cache[i].data); -+ if (sbi->fragment) -+ for (i = 0; i < SQUASHFS_CACHED_FRAGMENTS; i++) -+ SQUASHFS_FREE(sbi->fragment[i].data); -+ kfree(sbi->fragment); -+ kfree(sbi->block_cache); -+ kfree(sbi->read_data); -+ kfree(sbi->read_page); -+ kfree(sbi->uid); -+ kfree(sbi->fragment_index); -+ kfree(sbi->fragment_index_2); -+ sbi->block_cache = NULL; -+ sbi->uid = NULL; -+ sbi->read_data = NULL; -+ sbi->read_page = NULL; -+ sbi->fragment = NULL; -+ sbi->fragment_index = NULL; -+ sbi->fragment_index_2 = NULL; -+} -+ -+ -+static int __init init_squashfs_fs(void) -+{ -+ -+ printk(KERN_INFO "squashfs: version 3.0 (2006/03/15) " -+ "Phillip Lougher\n"); -+ -+ if (!(stream.workspace = vmalloc(zlib_inflate_workspacesize()))) { -+ ERROR("Failed to allocate zlib workspace\n"); -+ return -ENOMEM; -+ } -+ return register_filesystem(&squashfs_fs_type); -+} -+ -+ -+static void __exit exit_squashfs_fs(void) -+{ -+ vfree(stream.workspace); -+ unregister_filesystem(&squashfs_fs_type); -+} -+ -+ -+EXPORT_NO_SYMBOLS; -+ -+module_init(init_squashfs_fs); -+module_exit(exit_squashfs_fs); -+MODULE_DESCRIPTION("squashfs, a compressed read-only filesystem"); -+MODULE_AUTHOR("Phillip Lougher <phillip@lougher.org.uk>"); -+MODULE_LICENSE("GPL"); ---- /dev/null -+++ b/fs/squashfs/Makefile -@@ -0,0 +1,11 @@ -+# -+# Makefile for the linux squashfs routines. -+# -+ -+O_TARGET := squashfs.o -+ -+obj-y := inode.o squashfs2_0.o -+ -+obj-m := $(O_TARGET) -+ -+include $(TOPDIR)/Rules.make ---- /dev/null -+++ b/fs/squashfs/squashfs2_0.c -@@ -0,0 +1,751 @@ -+/* -+ * Squashfs - a compressed read only filesystem for Linux -+ * -+ * Copyright (c) 2002, 2003, 2004, 2005, 2006 -+ * Phillip Lougher <phillip@lougher.org.uk> -+ * -+ * 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, -+ * 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+ * -+ * squashfs2_0.c -+ */ -+ -+#include <linux/types.h> -+#include <linux/squashfs_fs.h> -+#include <linux/module.h> -+#include <linux/errno.h> -+#include <linux/slab.h> -+#include <linux/fs.h> -+#include <linux/smp_lock.h> -+#include <linux/locks.h> -+#include <linux/init.h> -+#include <linux/dcache.h> -+#include <linux/wait.h> -+#include <linux/zlib.h> -+#include <linux/blkdev.h> -+#include <linux/vmalloc.h> -+#include <asm/uaccess.h> -+#include <asm/semaphore.h> -+#include "squashfs.h" -+ -+static int squashfs_readdir_2(struct file *file, void *dirent, filldir_t filldir); -+static struct dentry *squashfs_lookup_2(struct inode *i, struct dentry *dentry); -+ -+static struct file_operations squashfs_dir_ops_2 = { -+ .read = generic_read_dir, -+ .readdir = squashfs_readdir_2 -+}; -+ -+static struct inode_operations squashfs_dir_inode_ops_2 = { -+ .lookup = squashfs_lookup_2 -+}; -+ -+static unsigned char squashfs_filetype_table[] = { -+ DT_UNKNOWN, DT_DIR, DT_REG, DT_LNK, DT_BLK, DT_CHR, DT_FIFO, DT_SOCK -+}; -+ -+static int read_fragment_index_table_2(struct super_block *s) -+{ -+ struct squashfs_sb_info *msblk = &s->u.squashfs_sb; -+ struct squashfs_super_block *sblk = &msblk->sblk; -+ -+ if (!(msblk->fragment_index_2 = kmalloc(SQUASHFS_FRAGMENT_INDEX_BYTES_2 -+ (sblk->fragments), GFP_KERNEL))) { -+ ERROR("Failed to allocate uid/gid table\n"); -+ return 0; -+ } -+ -+ if (SQUASHFS_FRAGMENT_INDEX_BYTES_2(sblk->fragments) && -+ !squashfs_read_data(s, (char *) -+ msblk->fragment_index_2, -+ sblk->fragment_table_start, -+ SQUASHFS_FRAGMENT_INDEX_BYTES_2 -+ (sblk->fragments) | -+ SQUASHFS_COMPRESSED_BIT_BLOCK, NULL)) { -+ ERROR("unable to read fragment index table\n"); -+ return 0; -+ } -+ -+ if (msblk->swap) { -+ int i; -+ unsigned int fragment; -+ -+ for (i = 0; i < SQUASHFS_FRAGMENT_INDEXES_2(sblk->fragments); -+ i++) { -+ SQUASHFS_SWAP_FRAGMENT_INDEXES_2((&fragment), -+ &msblk->fragment_index_2[i], 1); -+ msblk->fragment_index_2[i] = fragment; -+ } -+ } -+ -+ return 1; -+} -+ -+ -+static int get_fragment_location_2(struct super_block *s, unsigned int fragment, -+ long long *fragment_start_block, -+ unsigned int *fragment_size) -+{ -+ struct squashfs_sb_info *msblk = &s->u.squashfs_sb; -+ long long start_block = -+ msblk->fragment_index_2[SQUASHFS_FRAGMENT_INDEX_2(fragment)]; -+ int offset = SQUASHFS_FRAGMENT_INDEX_OFFSET_2(fragment); -+ struct squashfs_fragment_entry_2 fragment_entry; -+ -+ if (msblk->swap) { -+ struct squashfs_fragment_entry_2 sfragment_entry; -+ -+ if (!squashfs_get_cached_block(s, (char *) &sfragment_entry, -+ start_block, offset, -+ sizeof(sfragment_entry), &start_block, -+ &offset)) -+ goto out; -+ SQUASHFS_SWAP_FRAGMENT_ENTRY_2(&fragment_entry, &sfragment_entry); -+ } else -+ if (!squashfs_get_cached_block(s, (char *) &fragment_entry, -+ start_block, offset, -+ sizeof(fragment_entry), &start_block, -+ &offset)) -+ goto out; -+ -+ *fragment_start_block = fragment_entry.start_block; -+ *fragment_size = fragment_entry.size; -+ -+ return 1; -+ -+out: -+ return 0; -+} -+ -+ -+static struct inode *squashfs_new_inode(struct super_block *s, -+ struct squashfs_base_inode_header_2 *inodeb, unsigned int ino) -+{ -+ struct squashfs_sb_info *msblk = &s->u.squashfs_sb; -+ struct squashfs_super_block *sblk = &msblk->sblk; -+ struct inode *i = new_inode(s); -+ -+ if (i) { -+ i->i_ino = ino; -+ i->i_mtime = sblk->mkfs_time; -+ i->i_atime = sblk->mkfs_time; -+ i->i_ctime = sblk->mkfs_time; -+ i->i_uid = msblk->uid[inodeb->uid]; -+ i->i_mode = inodeb->mode; -+ i->i_nlink = 1; -+ i->i_size = 0; -+ if (inodeb->guid == SQUASHFS_GUIDS) -+ i->i_gid = i->i_uid; -+ else -+ i->i_gid = msblk->guid[inodeb->guid]; -+ } -+ -+ return i; -+} -+ -+ -+static struct inode *squashfs_iget_2(struct super_block *s, squashfs_inode_t inode) -+{ -+ struct inode *i; -+ struct squashfs_sb_info *msblk = &s->u.squashfs_sb; -+ struct squashfs_super_block *sblk = &msblk->sblk; -+ unsigned int block = SQUASHFS_INODE_BLK(inode) + -+ sblk->inode_table_start; -+ unsigned int offset = SQUASHFS_INODE_OFFSET(inode); -+ unsigned int ino = SQUASHFS_MK_VFS_INODE(block -+ - sblk->inode_table_start, offset); -+ long long next_block; -+ unsigned int next_offset; -+ union squashfs_inode_header_2 id, sid; -+ struct squashfs_base_inode_header_2 *inodeb = &id.base, -+ *sinodeb = &sid.base; -+ -+ TRACE("Entered squashfs_iget\n"); -+ -+ if (msblk->swap) { -+ if (!squashfs_get_cached_block(s, (char *) sinodeb, block, -+ offset, sizeof(*sinodeb), &next_block, -+ &next_offset)) -+ goto failed_read; -+ SQUASHFS_SWAP_BASE_INODE_HEADER_2(inodeb, sinodeb, -+ sizeof(*sinodeb)); -+ } else -+ if (!squashfs_get_cached_block(s, (char *) inodeb, block, -+ offset, sizeof(*inodeb), &next_block, -+ &next_offset)) -+ goto failed_read; -+ -+ switch(inodeb->inode_type) { -+ case SQUASHFS_FILE_TYPE: { -+ struct squashfs_reg_inode_header_2 *inodep = &id.reg; -+ struct squashfs_reg_inode_header_2 *sinodep = &sid.reg; -+ long long frag_blk; -+ unsigned int frag_size; -+ -+ if (msblk->swap) { -+ if (!squashfs_get_cached_block(s, (char *) -+ sinodep, block, offset, -+ sizeof(*sinodep), &next_block, -+ &next_offset)) -+ goto failed_read; -+ SQUASHFS_SWAP_REG_INODE_HEADER_2(inodep, sinodep); -+ } else -+ if (!squashfs_get_cached_block(s, (char *) -+ inodep, block, offset, -+ sizeof(*inodep), &next_block, -+ &next_offset)) -+ goto failed_read; -+ -+ frag_blk = SQUASHFS_INVALID_BLK; -+ if (inodep->fragment != SQUASHFS_INVALID_FRAG && -+ !get_fragment_location_2(s, -+ inodep->fragment, &frag_blk, &frag_size)) -+ goto failed_read; -+ -+ if((i = squashfs_new_inode(s, inodeb, ino)) == NULL) -+ goto failed_read1; -+ -+ i->i_size = inodep->file_size; -+ i->i_fop = &generic_ro_fops; -+ i->i_mode |= S_IFREG; -+ i->i_mtime = inodep->mtime; -+ i->i_atime = inodep->mtime; -+ i->i_ctime = inodep->mtime; -+ i->i_blocks = ((i->i_size - 1) >> 9) + 1; -+ i->i_blksize = PAGE_CACHE_SIZE; -+ SQUASHFS_I(i)->u.s1.fragment_start_block = frag_blk; -+ SQUASHFS_I(i)->u.s1.fragment_size = frag_size; -+ SQUASHFS_I(i)->u.s1.fragment_offset = inodep->offset; -+ SQUASHFS_I(i)->start_block = inodep->start_block; -+ SQUASHFS_I(i)->u.s1.block_list_start = next_block; -+ SQUASHFS_I(i)->offset = next_offset; -+ if (sblk->block_size > 4096) -+ i->i_data.a_ops = &squashfs_aops; -+ else -+ i->i_data.a_ops = &squashfs_aops_4K; -+ -+ TRACE("File inode %x:%x, start_block %x, " -+ "block_list_start %llx, offset %x\n", -+ SQUASHFS_INODE_BLK(inode), offset, -+ inodep->start_block, next_block, -+ next_offset); -+ break; -+ } -+ case SQUASHFS_DIR_TYPE: { -+ struct squashfs_dir_inode_header_2 *inodep = &id.dir; -+ struct squashfs_dir_inode_header_2 *sinodep = &sid.dir; -+ -+ if (msblk->swap) { -+ if (!squashfs_get_cached_block(s, (char *) -+ sinodep, block, offset, -+ sizeof(*sinodep), &next_block, -+ &next_offset)) -+ goto failed_read; -+ SQUASHFS_SWAP_DIR_INODE_HEADER_2(inodep, sinodep); -+ } else -+ if (!squashfs_get_cached_block(s, (char *) -+ inodep, block, offset, -+ sizeof(*inodep), &next_block, -+ &next_offset)) -+ goto failed_read; -+ -+ if((i = squashfs_new_inode(s, inodeb, ino)) == NULL) -+ goto failed_read1; -+ -+ i->i_size = inodep->file_size; -+ i->i_op = &squashfs_dir_inode_ops_2; -+ i->i_fop = &squashfs_dir_ops_2; -+ i->i_mode |= S_IFDIR; -+ i->i_mtime = inodep->mtime; -+ i->i_atime = inodep->mtime; -+ i->i_ctime = inodep->mtime; -+ SQUASHFS_I(i)->start_block = inodep->start_block; -+ SQUASHFS_I(i)->offset = inodep->offset; -+ SQUASHFS_I(i)->u.s2.directory_index_count = 0; -+ SQUASHFS_I(i)->u.s2.parent_inode = 0; -+ -+ TRACE("Directory inode %x:%x, start_block %x, offset " -+ "%x\n", SQUASHFS_INODE_BLK(inode), -+ offset, inodep->start_block, -+ inodep->offset); -+ break; -+ } -+ case SQUASHFS_LDIR_TYPE: { -+ struct squashfs_ldir_inode_header_2 *inodep = &id.ldir; -+ struct squashfs_ldir_inode_header_2 *sinodep = &sid.ldir; -+ -+ if (msblk->swap) { -+ if (!squashfs_get_cached_block(s, (char *) -+ sinodep, block, offset, -+ sizeof(*sinodep), &next_block, -+ &next_offset)) -+ goto failed_read; -+ SQUASHFS_SWAP_LDIR_INODE_HEADER_2(inodep, -+ sinodep); -+ } else -+ if (!squashfs_get_cached_block(s, (char *) -+ inodep, block, offset, -+ sizeof(*inodep), &next_block, -+ &next_offset)) -+ goto failed_read; -+ -+ if((i = squashfs_new_inode(s, inodeb, ino)) == NULL) -+ goto failed_read1; -+ -+ i->i_size = inodep->file_size; -+ i->i_op = &squashfs_dir_inode_ops_2; -+ i->i_fop = &squashfs_dir_ops_2; -+ i->i_mode |= S_IFDIR; -+ i->i_mtime = inodep->mtime; -+ i->i_atime = inodep->mtime; -+ i->i_ctime = inodep->mtime; -+ SQUASHFS_I(i)->start_block = inodep->start_block; -+ SQUASHFS_I(i)->offset = inodep->offset; -+ SQUASHFS_I(i)->u.s2.directory_index_start = next_block; -+ SQUASHFS_I(i)->u.s2.directory_index_offset = -+ next_offset; -+ SQUASHFS_I(i)->u.s2.directory_index_count = -+ inodep->i_count; -+ SQUASHFS_I(i)->u.s2.parent_inode = 0; -+ -+ TRACE("Long directory inode %x:%x, start_block %x, " -+ "offset %x\n", -+ SQUASHFS_INODE_BLK(inode), offset, -+ inodep->start_block, inodep->offset); -+ break; -+ } -+ case SQUASHFS_SYMLINK_TYPE: { -+ struct squashfs_symlink_inode_header_2 *inodep = -+ &id.symlink; -+ struct squashfs_symlink_inode_header_2 *sinodep = -+ &sid.symlink; -+ -+ if (msblk->swap) { -+ if (!squashfs_get_cached_block(s, (char *) -+ sinodep, block, offset, -+ sizeof(*sinodep), &next_block, -+ &next_offset)) -+ goto failed_read; -+ SQUASHFS_SWAP_SYMLINK_INODE_HEADER_2(inodep, -+ sinodep); -+ } else -+ if (!squashfs_get_cached_block(s, (char *) -+ inodep, block, offset, -+ sizeof(*inodep), &next_block, -+ &next_offset)) -+ goto failed_read; -+ -+ if((i = squashfs_new_inode(s, inodeb, ino)) == NULL) -+ goto failed_read1; -+ -+ i->i_size = inodep->symlink_size; -+ i->i_op = &page_symlink_inode_operations; -+ i->i_data.a_ops = &squashfs_symlink_aops; -+ i->i_mode |= S_IFLNK; -+ SQUASHFS_I(i)->start_block = next_block; -+ SQUASHFS_I(i)->offset = next_offset; -+ -+ TRACE("Symbolic link inode %x:%x, start_block %llx, " -+ "offset %x\n", -+ SQUASHFS_INODE_BLK(inode), offset, -+ next_block, next_offset); -+ break; -+ } -+ case SQUASHFS_BLKDEV_TYPE: -+ case SQUASHFS_CHRDEV_TYPE: { -+ struct squashfs_dev_inode_header_2 *inodep = &id.dev; -+ struct squashfs_dev_inode_header_2 *sinodep = &sid.dev; -+ -+ if (msblk->swap) { -+ if (!squashfs_get_cached_block(s, (char *) -+ sinodep, block, offset, -+ sizeof(*sinodep), &next_block, -+ &next_offset)) -+ goto failed_read; -+ SQUASHFS_SWAP_DEV_INODE_HEADER_2(inodep, sinodep); -+ } else -+ if (!squashfs_get_cached_block(s, (char *) -+ inodep, block, offset, -+ sizeof(*inodep), &next_block, -+ &next_offset)) -+ goto failed_read; -+ -+ if ((i = squashfs_new_inode(s, inodeb, ino)) == NULL) -+ goto failed_read1; -+ -+ i->i_mode |= (inodeb->inode_type == -+ SQUASHFS_CHRDEV_TYPE) ? S_IFCHR : -+ S_IFBLK; -+ init_special_inode(i, i->i_mode, inodep->rdev); -+ -+ TRACE("Device inode %x:%x, rdev %x\n", -+ SQUASHFS_INODE_BLK(inode), offset, -+ inodep->rdev); -+ break; -+ } -+ case SQUASHFS_FIFO_TYPE: -+ case SQUASHFS_SOCKET_TYPE: { -+ if ((i = squashfs_new_inode(s, inodeb, ino)) == NULL) -+ goto failed_read1; -+ -+ i->i_mode |= (inodeb->inode_type == SQUASHFS_FIFO_TYPE) -+ ? S_IFIFO : S_IFSOCK; -+ init_special_inode(i, i->i_mode, 0); -+ break; -+ } -+ default: -+ ERROR("Unknown inode type %d in squashfs_iget!\n", -+ inodeb->inode_type); -+ goto failed_read1; -+ } -+ -+ insert_inode_hash(i); -+ return i; -+ -+failed_read: -+ ERROR("Unable to read inode [%x:%x]\n", block, offset); -+ -+failed_read1: -+ return NULL; -+} -+ -+ -+static int get_dir_index_using_offset(struct super_block *s, long long -+ *next_block, unsigned int *next_offset, -+ long long index_start, -+ unsigned int index_offset, int i_count, -+ long long f_pos) -+{ -+ struct squashfs_sb_info *msblk = &s->u.squashfs_sb; -+ struct squashfs_super_block *sblk = &msblk->sblk; -+ int i, length = 0; -+ struct squashfs_dir_index_2 index; -+ -+ TRACE("Entered get_dir_index_using_offset, i_count %d, f_pos %d\n", -+ i_count, (unsigned int) f_pos); -+ -+ if (f_pos == 0) -+ goto finish; -+ -+ for (i = 0; i < i_count; i++) { -+ if (msblk->swap) { -+ struct squashfs_dir_index_2 sindex; -+ squashfs_get_cached_block(s, (char *) &sindex, -+ index_start, index_offset, -+ sizeof(sindex), &index_start, -+ &index_offset); -+ SQUASHFS_SWAP_DIR_INDEX_2(&index, &sindex); -+ } else -+ squashfs_get_cached_block(s, (char *) &index, -+ index_start, index_offset, -+ sizeof(index), &index_start, -+ &index_offset); -+ -+ if (index.index > f_pos) -+ break; -+ -+ squashfs_get_cached_block(s, NULL, index_start, index_offset, -+ index.size + 1, &index_start, -+ &index_offset); -+ -+ length = index.index; -+ *next_block = index.start_block + sblk->directory_table_start; -+ } -+ -+ *next_offset = (length + *next_offset) % SQUASHFS_METADATA_SIZE; -+ -+finish: -+ return length; -+} -+ -+ -+static int get_dir_index_using_name(struct super_block *s, long long -+ *next_block, unsigned int *next_offset, -+ long long index_start, -+ unsigned int index_offset, int i_count, -+ const char *name, int size) -+{ -+ struct squashfs_sb_info *msblk = &s->u.squashfs_sb; -+ struct squashfs_super_block *sblk = &msblk->sblk; -+ int i, length = 0; -+ char buffer[sizeof(struct squashfs_dir_index_2) + SQUASHFS_NAME_LEN + 1]; -+ struct squashfs_dir_index_2 *index = (struct squashfs_dir_index_2 *) buffer; -+ char str[SQUASHFS_NAME_LEN + 1]; -+ -+ TRACE("Entered get_dir_index_using_name, i_count %d\n", i_count); -+ -+ strncpy(str, name, size); -+ str[size] = '\0'; -+ -+ for (i = 0; i < i_count; i++) { -+ if (msblk->swap) { -+ struct squashfs_dir_index_2 sindex; -+ squashfs_get_cached_block(s, (char *) &sindex, -+ index_start, index_offset, -+ sizeof(sindex), &index_start, -+ &index_offset); -+ SQUASHFS_SWAP_DIR_INDEX_2(index, &sindex); -+ } else -+ squashfs_get_cached_block(s, (char *) index, -+ index_start, index_offset, -+ sizeof(struct squashfs_dir_index_2), -+ &index_start, &index_offset); -+ -+ squashfs_get_cached_block(s, index->name, index_start, -+ index_offset, index->size + 1, -+ &index_start, &index_offset); -+ -+ index->name[index->size + 1] = '\0'; -+ -+ if (strcmp(index->name, str) > 0) -+ break; -+ -+ length = index->index; -+ *next_block = index->start_block + sblk->directory_table_start; -+ } -+ -+ *next_offset = (length + *next_offset) % SQUASHFS_METADATA_SIZE; -+ return length; -+} -+ -+ -+static int squashfs_readdir_2(struct file *file, void *dirent, filldir_t filldir) -+{ -+ struct inode *i = file->f_dentry->d_inode; -+ struct squashfs_sb_info *msblk = &i->i_sb->u.squashfs_sb; -+ struct squashfs_super_block *sblk = &msblk->sblk; -+ long long next_block = SQUASHFS_I(i)->start_block + -+ sblk->directory_table_start; -+ int next_offset = SQUASHFS_I(i)->offset, length = 0, dirs_read = 0, -+ dir_count; -+ struct squashfs_dir_header_2 dirh; -+ char buffer[sizeof(struct squashfs_dir_entry_2) + SQUASHFS_NAME_LEN + 1]; -+ struct squashfs_dir_entry_2 *dire = (struct squashfs_dir_entry_2 *) buffer; -+ -+ TRACE("Entered squashfs_readdir_2 [%llx:%x]\n", next_block, next_offset); -+ -+ length = get_dir_index_using_offset(i->i_sb, &next_block, &next_offset, -+ SQUASHFS_I(i)->u.s2.directory_index_start, -+ SQUASHFS_I(i)->u.s2.directory_index_offset, -+ SQUASHFS_I(i)->u.s2.directory_index_count, -+ file->f_pos); -+ -+ while (length < i_size_read(i)) { -+ /* read directory header */ -+ if (msblk->swap) { -+ struct squashfs_dir_header_2 sdirh; -+ -+ if (!squashfs_get_cached_block(i->i_sb, (char *) &sdirh, -+ next_block, next_offset, sizeof(sdirh), -+ &next_block, &next_offset)) -+ goto failed_read; -+ -+ length += sizeof(sdirh); -+ SQUASHFS_SWAP_DIR_HEADER_2(&dirh, &sdirh); -+ } else { -+ if (!squashfs_get_cached_block(i->i_sb, (char *) &dirh, -+ next_block, next_offset, sizeof(dirh), -+ &next_block, &next_offset)) -+ goto failed_read; -+ -+ length += sizeof(dirh); -+ } -+ -+ dir_count = dirh.count + 1; -+ while (dir_count--) { -+ if (msblk->swap) { -+ struct squashfs_dir_entry_2 sdire; -+ if (!squashfs_get_cached_block(i->i_sb, (char *) -+ &sdire, next_block, next_offset, -+ sizeof(sdire), &next_block, -+ &next_offset)) -+ goto failed_read; -+ -+ length += sizeof(sdire); -+ SQUASHFS_SWAP_DIR_ENTRY_2(dire, &sdire); -+ } else { -+ if (!squashfs_get_cached_block(i->i_sb, (char *) -+ dire, next_block, next_offset, -+ sizeof(*dire), &next_block, -+ &next_offset)) -+ goto failed_read; -+ -+ length += sizeof(*dire); -+ } -+ -+ if (!squashfs_get_cached_block(i->i_sb, dire->name, -+ next_block, next_offset, -+ dire->size + 1, &next_block, -+ &next_offset)) -+ goto failed_read; -+ -+ length += dire->size + 1; -+ -+ if (file->f_pos >= length) -+ continue; -+ -+ dire->name[dire->size + 1] = '\0'; -+ -+ TRACE("Calling filldir(%x, %s, %d, %d, %x:%x, %d)\n", -+ (unsigned int) dirent, dire->name, -+ dire->size + 1, (int) file->f_pos, -+ dirh.start_block, dire->offset, -+ squashfs_filetype_table[dire->type]); -+ -+ if (filldir(dirent, dire->name, dire->size + 1, -+ file->f_pos, SQUASHFS_MK_VFS_INODE( -+ dirh.start_block, dire->offset), -+ squashfs_filetype_table[dire->type]) -+ < 0) { -+ TRACE("Filldir returned less than 0\n"); -+ goto finish; -+ } -+ file->f_pos = length; -+ dirs_read++; -+ } -+ } -+ -+finish: -+ return dirs_read; -+ -+failed_read: -+ ERROR("Unable to read directory block [%llx:%x]\n", next_block, -+ next_offset); -+ return 0; -+} -+ -+ -+static struct dentry *squashfs_lookup_2(struct inode *i, struct dentry *dentry) -+{ -+ const unsigned char *name = dentry->d_name.name; -+ int len = dentry->d_name.len; -+ struct inode *inode = NULL; -+ struct squashfs_sb_info *msblk = &i->i_sb->u.squashfs_sb; -+ struct squashfs_super_block *sblk = &msblk->sblk; -+ long long next_block = SQUASHFS_I(i)->start_block + -+ sblk->directory_table_start; -+ int next_offset = SQUASHFS_I(i)->offset, length = 0, -+ dir_count; -+ struct squashfs_dir_header_2 dirh; -+ char buffer[sizeof(struct squashfs_dir_entry_2) + SQUASHFS_NAME_LEN]; -+ struct squashfs_dir_entry_2 *dire = (struct squashfs_dir_entry_2 *) buffer; -+ int sorted = sblk->s_major == 2 && sblk->s_minor >= 1; -+ -+ TRACE("Entered squashfs_lookup [%llx:%x]\n", next_block, next_offset); -+ -+ if (len > SQUASHFS_NAME_LEN) -+ goto exit_loop; -+ -+ length = get_dir_index_using_name(i->i_sb, &next_block, &next_offset, -+ SQUASHFS_I(i)->u.s2.directory_index_start, -+ SQUASHFS_I(i)->u.s2.directory_index_offset, -+ SQUASHFS_I(i)->u.s2.directory_index_count, name, -+ len); -+ -+ while (length < i_size_read(i)) { -+ /* read directory header */ -+ if (msblk->swap) { -+ struct squashfs_dir_header_2 sdirh; -+ if (!squashfs_get_cached_block(i->i_sb, (char *) &sdirh, -+ next_block, next_offset, sizeof(sdirh), -+ &next_block, &next_offset)) -+ goto failed_read; -+ -+ length += sizeof(sdirh); -+ SQUASHFS_SWAP_DIR_HEADER_2(&dirh, &sdirh); -+ } else { -+ if (!squashfs_get_cached_block(i->i_sb, (char *) &dirh, -+ next_block, next_offset, sizeof(dirh), -+ &next_block, &next_offset)) -+ goto failed_read; -+ -+ length += sizeof(dirh); -+ } -+ -+ dir_count = dirh.count + 1; -+ while (dir_count--) { -+ if (msblk->swap) { -+ struct squashfs_dir_entry_2 sdire; -+ if (!squashfs_get_cached_block(i->i_sb, (char *) -+ &sdire, next_block,next_offset, -+ sizeof(sdire), &next_block, -+ &next_offset)) -+ goto failed_read; -+ -+ length += sizeof(sdire); -+ SQUASHFS_SWAP_DIR_ENTRY_2(dire, &sdire); -+ } else { -+ if (!squashfs_get_cached_block(i->i_sb, (char *) -+ dire, next_block,next_offset, -+ sizeof(*dire), &next_block, -+ &next_offset)) -+ goto failed_read; -+ -+ length += sizeof(*dire); -+ } -+ -+ if (!squashfs_get_cached_block(i->i_sb, dire->name, -+ next_block, next_offset, dire->size + 1, -+ &next_block, &next_offset)) -+ goto failed_read; -+ -+ length += dire->size + 1; -+ -+ if (sorted && name[0] < dire->name[0]) -+ goto exit_loop; -+ -+ if ((len == dire->size + 1) && !strncmp(name, -+ dire->name, len)) { -+ squashfs_inode_t ino = -+ SQUASHFS_MKINODE(dirh.start_block, -+ dire->offset); -+ -+ TRACE("calling squashfs_iget for directory " -+ "entry %s, inode %x:%x, %d\n", name, -+ dirh.start_block, dire->offset, ino); -+ -+ inode = (msblk->iget)(i->i_sb, ino); -+ -+ goto exit_loop; -+ } -+ } -+ } -+ -+exit_loop: -+ d_add(dentry, inode); -+ return ERR_PTR(0); -+ -+failed_read: -+ ERROR("Unable to read directory block [%llx:%x]\n", next_block, -+ next_offset); -+ goto exit_loop; -+} -+ -+ -+int squashfs_2_0_supported(struct squashfs_sb_info *msblk) -+{ -+ struct squashfs_super_block *sblk = &msblk->sblk; -+ -+ msblk->iget = squashfs_iget_2; -+ msblk->read_fragment_index_table = read_fragment_index_table_2; -+ -+ sblk->bytes_used = sblk->bytes_used_2; -+ sblk->uid_start = sblk->uid_start_2; -+ sblk->guid_start = sblk->guid_start_2; -+ sblk->inode_table_start = sblk->inode_table_start_2; -+ sblk->directory_table_start = sblk->directory_table_start_2; -+ sblk->fragment_table_start = sblk->fragment_table_start_2; -+ -+ return 1; -+} ---- /dev/null -+++ b/fs/squashfs/squashfs.h -@@ -0,0 +1,85 @@ -+/* -+ * Squashfs - a compressed read only filesystem for Linux -+ * -+ * Copyright (c) 2002, 2003, 2004, 2005, 2006 -+ * Phillip Lougher <phillip@lougher.org.uk> -+ * -+ * 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, -+ * 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+ * -+ * squashfs.h -+ */ -+ -+#ifdef CONFIG_SQUASHFS_1_0_COMPATIBILITY -+#undef CONFIG_SQUASHFS_1_0_COMPATIBILITY -+#endif -+#ifdef SQUASHFS_TRACE -+#define TRACE(s, args...) printk(KERN_NOTICE "SQUASHFS: "s, ## args) -+#else -+#define TRACE(s, args...) {} -+#endif -+ -+#define ERROR(s, args...) printk(KERN_ERR "SQUASHFS error: "s, ## args) -+ -+#define SERROR(s, args...) do { \ -+ if (!silent) \ -+ printk(KERN_ERR "SQUASHFS error: "s, ## args);\ -+ } while(0) -+ -+#define WARNING(s, args...) printk(KERN_WARNING "SQUASHFS: "s, ## args) -+ -+#define SQUASHFS_I(INO) (&INO->u.squashfs_i) -+ -+#define i_size_read(INO) (INO->i_size) -+ -+#if defined(CONFIG_SQUASHFS_1_0_COMPATIBILITY ) || defined(CONFIG_SQUASHFS_2_0_COMPATIBILITY) -+#define SQSH_EXTERN -+extern unsigned int squashfs_read_data(struct super_block *s, char *buffer, -+ long long index, unsigned int length, -+ long long *next_index); -+extern int squashfs_get_cached_block(struct super_block *s, char *buffer, -+ long long block, unsigned int offset, -+ int length, long long *next_block, -+ unsigned int *next_offset); -+extern void release_cached_fragment(struct squashfs_sb_info *msblk, struct -+ squashfs_fragment_cache *fragment); -+extern struct squashfs_fragment_cache *get_cached_fragment(struct super_block -+ *s, long long start_block, -+ int length); -+extern struct address_space_operations squashfs_symlink_aops; -+extern struct address_space_operations squashfs_aops; -+extern struct address_space_operations squashfs_aops_4K; -+extern struct file_operations squashfs_dir_ops; -+extern struct inode_operations squashfs_dir_inode_ops; -+#else -+#define SQSH_EXTERN static -+#endif -+ -+#ifdef CONFIG_SQUASHFS_1_0_COMPATIBILITY -+extern int squashfs_1_0_supported(struct squashfs_sb_info *msblk); -+#else -+static inline int squashfs_1_0_supported(struct squashfs_sb_info *msblk) -+{ -+ return 0; -+} -+#endif -+ -+#ifdef CONFIG_SQUASHFS_2_0_COMPATIBILITY -+extern int squashfs_2_0_supported(struct squashfs_sb_info *msblk); -+#else -+static inline int squashfs_2_0_supported(struct squashfs_sb_info *msblk) -+{ -+ return 0; -+} -+#endif ---- a/include/linux/fs.h -+++ b/include/linux/fs.h -@@ -324,6 +324,7 @@ extern void set_bh_page(struct buffer_he - #include <linux/usbdev_fs_i.h> - #include <linux/jffs2_fs_i.h> - #include <linux/cramfs_fs_sb.h> -+#include <linux/squashfs_fs_i.h> - - /* - * Attribute flags. These should be or-ed together to figure out what -@@ -519,6 +520,7 @@ struct inode { - struct socket socket_i; - struct usbdev_inode_info usbdev_i; - struct jffs2_inode_info jffs2_i; -+ struct squashfs_inode_info squashfs_i; - void *generic_ip; - } u; - }; -@@ -736,6 +738,7 @@ struct nameidata { - #include <linux/usbdev_fs_sb.h> - #include <linux/cramfs_fs_sb.h> - #include <linux/jffs2_fs_sb.h> -+#include <linux/squashfs_fs_sb.h> - - extern struct list_head super_blocks; - extern spinlock_t sb_lock; -@@ -795,6 +798,7 @@ struct super_block { - struct usbdev_sb_info usbdevfs_sb; - struct jffs2_sb_info jffs2_sb; - struct cramfs_sb_info cramfs_sb; -+ struct squashfs_sb_info squashfs_sb; - void *generic_sbp; - } u; - /* ---- /dev/null -+++ b/include/linux/squashfs_fs.h -@@ -0,0 +1,915 @@ -+#ifndef SQUASHFS_FS -+#define SQUASHFS_FS -+ -+/* -+ * Squashfs -+ * -+ * Copyright (c) 2002, 2003, 2004, 2005, 2006 -+ * Phillip Lougher <phillip@lougher.org.uk> -+ * -+ * 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, -+ * 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+ * -+ * squashfs_fs.h -+ */ -+ -+#ifndef CONFIG_SQUASHFS_2_0_COMPATIBILITY -+#define CONFIG_SQUASHFS_2_0_COMPATIBILITY -+#endif -+ -+#ifdef CONFIG_SQUASHFS_VMALLOC -+#define SQUASHFS_ALLOC(a) vmalloc(a) -+#define SQUASHFS_FREE(a) vfree(a) -+#else -+#define SQUASHFS_ALLOC(a) kmalloc(a, GFP_KERNEL) -+#define SQUASHFS_FREE(a) kfree(a) -+#endif -+#ifdef CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE -+#define SQUASHFS_CACHED_FRAGMENTS CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE -+#else -+#define SQUASHFS_CACHED_FRAGMENTS 3 -+#endif -+#define SQUASHFS_MAJOR 3 -+#define SQUASHFS_MINOR 0 -+#define SQUASHFS_MAGIC 0x73717368 -+#define SQUASHFS_MAGIC_SWAP 0x68737173 -+#define SQUASHFS_START 0 -+ -+/* size of metadata (inode and directory) blocks */ -+#define SQUASHFS_METADATA_SIZE 8192 -+#define SQUASHFS_METADATA_LOG 13 -+ -+/* default size of data blocks */ -+#define SQUASHFS_FILE_SIZE 65536 -+#define SQUASHFS_FILE_LOG 16 -+ -+#define SQUASHFS_FILE_MAX_SIZE 65536 -+ -+/* Max number of uids and gids */ -+#define SQUASHFS_UIDS 256 -+#define SQUASHFS_GUIDS 255 -+ -+/* Max length of filename (not 255) */ -+#define SQUASHFS_NAME_LEN 256 -+ -+#define SQUASHFS_INVALID ((long long) 0xffffffffffff) -+#define SQUASHFS_INVALID_FRAG ((unsigned int) 0xffffffff) -+#define SQUASHFS_INVALID_BLK ((long long) -1) -+#define SQUASHFS_USED_BLK ((long long) -2) -+ -+/* Filesystem flags */ -+#define SQUASHFS_NOI 0 -+#define SQUASHFS_NOD 1 -+#define SQUASHFS_CHECK 2 -+#define SQUASHFS_NOF 3 -+#define SQUASHFS_NO_FRAG 4 -+#define SQUASHFS_ALWAYS_FRAG 5 -+#define SQUASHFS_DUPLICATE 6 -+ -+#define SQUASHFS_BIT(flag, bit) ((flag >> bit) & 1) -+ -+#define SQUASHFS_UNCOMPRESSED_INODES(flags) SQUASHFS_BIT(flags, \ -+ SQUASHFS_NOI) -+ -+#define SQUASHFS_UNCOMPRESSED_DATA(flags) SQUASHFS_BIT(flags, \ -+ SQUASHFS_NOD) -+ -+#define SQUASHFS_UNCOMPRESSED_FRAGMENTS(flags) SQUASHFS_BIT(flags, \ -+ SQUASHFS_NOF) -+ -+#define SQUASHFS_NO_FRAGMENTS(flags) SQUASHFS_BIT(flags, \ -+ SQUASHFS_NO_FRAG) -+ -+#define SQUASHFS_ALWAYS_FRAGMENTS(flags) SQUASHFS_BIT(flags, \ -+ SQUASHFS_ALWAYS_FRAG) -+ -+#define SQUASHFS_DUPLICATES(flags) SQUASHFS_BIT(flags, \ -+ SQUASHFS_DUPLICATE) -+ -+#define SQUASHFS_CHECK_DATA(flags) SQUASHFS_BIT(flags, \ -+ SQUASHFS_CHECK) -+ -+#define SQUASHFS_MKFLAGS(noi, nod, check_data, nof, no_frag, always_frag, \ -+ duplicate_checking) (noi | (nod << 1) | (check_data << 2) \ -+ | (nof << 3) | (no_frag << 4) | (always_frag << 5) | \ -+ (duplicate_checking << 6)) -+ -+/* Max number of types and file types */ -+#define SQUASHFS_DIR_TYPE 1 -+#define SQUASHFS_FILE_TYPE 2 -+#define SQUASHFS_SYMLINK_TYPE 3 -+#define SQUASHFS_BLKDEV_TYPE 4 -+#define SQUASHFS_CHRDEV_TYPE 5 -+#define SQUASHFS_FIFO_TYPE 6 -+#define SQUASHFS_SOCKET_TYPE 7 -+#define SQUASHFS_LDIR_TYPE 8 -+#define SQUASHFS_LREG_TYPE 9 -+ -+/* 1.0 filesystem type definitions */ -+#define SQUASHFS_TYPES 5 -+#define SQUASHFS_IPC_TYPE 0 -+ -+/* Flag whether block is compressed or uncompressed, bit is set if block is -+ * uncompressed */ -+#define SQUASHFS_COMPRESSED_BIT (1 << 15) -+ -+#define SQUASHFS_COMPRESSED_SIZE(B) (((B) & ~SQUASHFS_COMPRESSED_BIT) ? \ -+ (B) & ~SQUASHFS_COMPRESSED_BIT : SQUASHFS_COMPRESSED_BIT) -+ -+#define SQUASHFS_COMPRESSED(B) (!((B) & SQUASHFS_COMPRESSED_BIT)) -+ -+#define SQUASHFS_COMPRESSED_BIT_BLOCK (1 << 24) -+ -+#define SQUASHFS_COMPRESSED_SIZE_BLOCK(B) (((B) & \ -+ ~SQUASHFS_COMPRESSED_BIT_BLOCK) ? (B) & \ -+ ~SQUASHFS_COMPRESSED_BIT_BLOCK : SQUASHFS_COMPRESSED_BIT_BLOCK) -+ -+#define SQUASHFS_COMPRESSED_BLOCK(B) (!((B) & SQUASHFS_COMPRESSED_BIT_BLOCK)) -+ -+/* -+ * Inode number ops. Inodes consist of a compressed block number, and an -+ * uncompressed offset within that block -+ */ -+#define SQUASHFS_INODE_BLK(a) ((unsigned int) ((a) >> 16)) -+ -+#define SQUASHFS_INODE_OFFSET(a) ((unsigned int) ((a) & 0xffff)) -+ -+#define SQUASHFS_MKINODE(A, B) ((squashfs_inode_t)(((squashfs_inode_t) (A)\ -+ << 16) + (B))) -+ -+/* Compute 32 bit VFS inode number from squashfs inode number */ -+#define SQUASHFS_MK_VFS_INODE(a, b) ((unsigned int) (((a) << 8) + \ -+ ((b) >> 2) + 1)) -+/* XXX */ -+ -+/* Translate between VFS mode and squashfs mode */ -+#define SQUASHFS_MODE(a) ((a) & 0xfff) -+ -+/* fragment and fragment table defines */ -+#define SQUASHFS_FRAGMENT_BYTES(A) (A * sizeof(struct squashfs_fragment_entry)) -+ -+#define SQUASHFS_FRAGMENT_INDEX(A) (SQUASHFS_FRAGMENT_BYTES(A) / \ -+ SQUASHFS_METADATA_SIZE) -+ -+#define SQUASHFS_FRAGMENT_INDEX_OFFSET(A) (SQUASHFS_FRAGMENT_BYTES(A) % \ -+ SQUASHFS_METADATA_SIZE) -+ -+#define SQUASHFS_FRAGMENT_INDEXES(A) ((SQUASHFS_FRAGMENT_BYTES(A) + \ -+ SQUASHFS_METADATA_SIZE - 1) / \ -+ SQUASHFS_METADATA_SIZE) -+ -+#define SQUASHFS_FRAGMENT_INDEX_BYTES(A) (SQUASHFS_FRAGMENT_INDEXES(A) *\ -+ sizeof(long long)) -+ -+/* cached data constants for filesystem */ -+#define SQUASHFS_CACHED_BLKS 8 -+ -+#define SQUASHFS_MAX_FILE_SIZE_LOG 64 -+ -+#define SQUASHFS_MAX_FILE_SIZE ((long long) 1 << \ -+ (SQUASHFS_MAX_FILE_SIZE_LOG - 2)) -+ -+#define SQUASHFS_MARKER_BYTE 0xff -+ -+/* meta index cache */ -+#define SQUASHFS_META_INDEXES (SQUASHFS_METADATA_SIZE / sizeof(unsigned int)) -+#define SQUASHFS_META_ENTRIES 31 -+#define SQUASHFS_META_NUMBER 8 -+#define SQUASHFS_SLOTS 4 -+ -+struct meta_entry { -+ long long data_block; -+ unsigned int index_block; -+ unsigned short offset; -+ unsigned short pad; -+}; -+ -+struct meta_index { -+ unsigned int inode_number; -+ unsigned int offset; -+ unsigned short entries; -+ unsigned short skip; -+ unsigned short locked; -+ unsigned short pad; -+ struct meta_entry meta_entry[SQUASHFS_META_ENTRIES]; -+}; -+ -+ -+/* -+ * definitions for structures on disk -+ */ -+ -+typedef long long squashfs_block_t; -+typedef long long squashfs_inode_t; -+ -+struct squashfs_super_block { -+ unsigned int s_magic; -+ unsigned int inodes; -+ unsigned int bytes_used_2; -+ unsigned int uid_start_2; -+ unsigned int guid_start_2; -+ unsigned int inode_table_start_2; -+ unsigned int directory_table_start_2; -+ unsigned int s_major:16; -+ unsigned int s_minor:16; -+ unsigned int block_size_1:16; -+ unsigned int block_log:16; -+ unsigned int flags:8; -+ unsigned int no_uids:8; -+ unsigned int no_guids:8; -+ unsigned int mkfs_time /* time of filesystem creation */; -+ squashfs_inode_t root_inode; -+ unsigned int block_size; -+ unsigned int fragments; -+ unsigned int fragment_table_start_2; -+ long long bytes_used; -+ long long uid_start; -+ long long guid_start; -+ long long inode_table_start; -+ long long directory_table_start; -+ long long fragment_table_start; -+ long long unused; -+} __attribute__ ((packed)); -+ -+struct squashfs_dir_index { -+ unsigned int index; -+ unsigned int start_block; -+ unsigned char size; -+ unsigned char name[0]; -+} __attribute__ ((packed)); -+ -+#define SQUASHFS_BASE_INODE_HEADER \ -+ unsigned int inode_type:4; \ -+ unsigned int mode:12; \ -+ unsigned int uid:8; \ -+ unsigned int guid:8; \ -+ unsigned int mtime; \ -+ unsigned int inode_number; -+ -+struct squashfs_base_inode_header { -+ SQUASHFS_BASE_INODE_HEADER; -+} __attribute__ ((packed)); -+ -+struct squashfs_ipc_inode_header { -+ SQUASHFS_BASE_INODE_HEADER; -+ unsigned int nlink; -+} __attribute__ ((packed)); -+ -+struct squashfs_dev_inode_header { -+ SQUASHFS_BASE_INODE_HEADER; -+ unsigned int nlink; -+ unsigned short rdev; -+} __attribute__ ((packed)); -+ -+struct squashfs_symlink_inode_header { -+ SQUASHFS_BASE_INODE_HEADER; -+ unsigned int nlink; -+ unsigned short symlink_size; -+ char symlink[0]; -+} __attribute__ ((packed)); -+ -+struct squashfs_reg_inode_header { -+ SQUASHFS_BASE_INODE_HEADER; -+ squashfs_block_t start_block; -+ unsigned int fragment; -+ unsigned int offset; -+ unsigned int file_size; -+ unsigned short block_list[0]; -+} __attribute__ ((packed)); -+ -+struct squashfs_lreg_inode_header { -+ SQUASHFS_BASE_INODE_HEADER; -+ unsigned int nlink; -+ squashfs_block_t start_block; -+ unsigned int fragment; -+ unsigned int offset; -+ long long file_size; -+ unsigned short block_list[0]; -+} __attribute__ ((packed)); -+ -+struct squashfs_dir_inode_header { -+ SQUASHFS_BASE_INODE_HEADER; -+ unsigned int nlink; -+ unsigned int file_size:19; -+ unsigned int offset:13; -+ unsigned int start_block; -+ unsigned int parent_inode; -+} __attribute__ ((packed)); -+ -+struct squashfs_ldir_inode_header { -+ SQUASHFS_BASE_INODE_HEADER; -+ unsigned int nlink; -+ unsigned int file_size:27; -+ unsigned int offset:13; -+ unsigned int start_block; -+ unsigned int i_count:16; -+ unsigned int parent_inode; -+ struct squashfs_dir_index index[0]; -+} __attribute__ ((packed)); -+ -+union squashfs_inode_header { -+ struct squashfs_base_inode_header base; -+ struct squashfs_dev_inode_header dev; -+ struct squashfs_symlink_inode_header symlink; -+ struct squashfs_reg_inode_header reg; -+ struct squashfs_lreg_inode_header lreg; -+ struct squashfs_dir_inode_header dir; -+ struct squashfs_ldir_inode_header ldir; -+ struct squashfs_ipc_inode_header ipc; -+}; -+ -+struct squashfs_dir_entry { -+ unsigned int offset:13; -+ unsigned int type:3; -+ unsigned int size:8; -+ int inode_number:16; -+ char name[0]; -+} __attribute__ ((packed)); -+ -+struct squashfs_dir_header { -+ unsigned int count:8; -+ unsigned int start_block; -+ unsigned int inode_number; -+} __attribute__ ((packed)); -+ -+struct squashfs_fragment_entry { -+ long long start_block; -+ unsigned int size; -+ unsigned int unused; -+} __attribute__ ((packed)); -+ -+extern int squashfs_uncompress_block(void *d, int dstlen, void *s, int srclen); -+extern int squashfs_uncompress_init(void); -+extern int squashfs_uncompress_exit(void); -+ -+/* -+ * macros to convert each packed bitfield structure from little endian to big -+ * endian and vice versa. These are needed when creating or using a filesystem -+ * on a machine with different byte ordering to the target architecture. -+ * -+ */ -+ -+#define SQUASHFS_SWAP_START \ -+ int bits;\ -+ int b_pos;\ -+ unsigned long long val;\ -+ unsigned char *s;\ -+ unsigned char *d; -+ -+#define SQUASHFS_SWAP_SUPER_BLOCK(s, d) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_super_block));\ -+ SQUASHFS_SWAP((s)->s_magic, d, 0, 32);\ -+ SQUASHFS_SWAP((s)->inodes, d, 32, 32);\ -+ SQUASHFS_SWAP((s)->bytes_used_2, d, 64, 32);\ -+ SQUASHFS_SWAP((s)->uid_start_2, d, 96, 32);\ -+ SQUASHFS_SWAP((s)->guid_start_2, d, 128, 32);\ -+ SQUASHFS_SWAP((s)->inode_table_start_2, d, 160, 32);\ -+ SQUASHFS_SWAP((s)->directory_table_start_2, d, 192, 32);\ -+ SQUASHFS_SWAP((s)->s_major, d, 224, 16);\ -+ SQUASHFS_SWAP((s)->s_minor, d, 240, 16);\ -+ SQUASHFS_SWAP((s)->block_size_1, d, 256, 16);\ -+ SQUASHFS_SWAP((s)->block_log, d, 272, 16);\ -+ SQUASHFS_SWAP((s)->flags, d, 288, 8);\ -+ SQUASHFS_SWAP((s)->no_uids, d, 296, 8);\ -+ SQUASHFS_SWAP((s)->no_guids, d, 304, 8);\ -+ SQUASHFS_SWAP((s)->mkfs_time, d, 312, 32);\ -+ SQUASHFS_SWAP((s)->root_inode, d, 344, 64);\ -+ SQUASHFS_SWAP((s)->block_size, d, 408, 32);\ -+ SQUASHFS_SWAP((s)->fragments, d, 440, 32);\ -+ SQUASHFS_SWAP((s)->fragment_table_start_2, d, 472, 32);\ -+ SQUASHFS_SWAP((s)->bytes_used, d, 504, 64);\ -+ SQUASHFS_SWAP((s)->uid_start, d, 568, 64);\ -+ SQUASHFS_SWAP((s)->guid_start, d, 632, 64);\ -+ SQUASHFS_SWAP((s)->inode_table_start, d, 696, 64);\ -+ SQUASHFS_SWAP((s)->directory_table_start, d, 760, 64);\ -+ SQUASHFS_SWAP((s)->fragment_table_start, d, 824, 64);\ -+ SQUASHFS_SWAP((s)->unused, d, 888, 64);\ -+} -+ -+#define SQUASHFS_SWAP_BASE_INODE_CORE(s, d, n)\ -+ SQUASHFS_MEMSET(s, d, n);\ -+ SQUASHFS_SWAP((s)->inode_type, d, 0, 4);\ -+ SQUASHFS_SWAP((s)->mode, d, 4, 12);\ -+ SQUASHFS_SWAP((s)->uid, d, 16, 8);\ -+ SQUASHFS_SWAP((s)->guid, d, 24, 8);\ -+ SQUASHFS_SWAP((s)->mtime, d, 32, 32);\ -+ SQUASHFS_SWAP((s)->inode_number, d, 64, 32); -+ -+#define SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, n) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, n)\ -+} -+ -+#define SQUASHFS_SWAP_IPC_INODE_HEADER(s, d) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \ -+ sizeof(struct squashfs_ipc_inode_header))\ -+ SQUASHFS_SWAP((s)->nlink, d, 96, 32);\ -+} -+ -+#define SQUASHFS_SWAP_DEV_INODE_HEADER(s, d) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \ -+ sizeof(struct squashfs_dev_inode_header)); \ -+ SQUASHFS_SWAP((s)->nlink, d, 96, 32);\ -+ SQUASHFS_SWAP((s)->rdev, d, 128, 16);\ -+} -+ -+#define SQUASHFS_SWAP_SYMLINK_INODE_HEADER(s, d) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \ -+ sizeof(struct squashfs_symlink_inode_header));\ -+ SQUASHFS_SWAP((s)->nlink, d, 96, 32);\ -+ SQUASHFS_SWAP((s)->symlink_size, d, 128, 16);\ -+} -+ -+#define SQUASHFS_SWAP_REG_INODE_HEADER(s, d) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \ -+ sizeof(struct squashfs_reg_inode_header));\ -+ SQUASHFS_SWAP((s)->start_block, d, 96, 64);\ -+ SQUASHFS_SWAP((s)->fragment, d, 160, 32);\ -+ SQUASHFS_SWAP((s)->offset, d, 192, 32);\ -+ SQUASHFS_SWAP((s)->file_size, d, 224, 32);\ -+} -+ -+#define SQUASHFS_SWAP_LREG_INODE_HEADER(s, d) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \ -+ sizeof(struct squashfs_lreg_inode_header));\ -+ SQUASHFS_SWAP((s)->nlink, d, 96, 32);\ -+ SQUASHFS_SWAP((s)->start_block, d, 128, 64);\ -+ SQUASHFS_SWAP((s)->fragment, d, 192, 32);\ -+ SQUASHFS_SWAP((s)->offset, d, 224, 32);\ -+ SQUASHFS_SWAP((s)->file_size, d, 256, 64);\ -+} -+ -+#define SQUASHFS_SWAP_DIR_INODE_HEADER(s, d) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \ -+ sizeof(struct squashfs_dir_inode_header));\ -+ SQUASHFS_SWAP((s)->nlink, d, 96, 32);\ -+ SQUASHFS_SWAP((s)->file_size, d, 128, 19);\ -+ SQUASHFS_SWAP((s)->offset, d, 147, 13);\ -+ SQUASHFS_SWAP((s)->start_block, d, 160, 32);\ -+ SQUASHFS_SWAP((s)->parent_inode, d, 192, 32);\ -+} -+ -+#define SQUASHFS_SWAP_LDIR_INODE_HEADER(s, d) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \ -+ sizeof(struct squashfs_ldir_inode_header));\ -+ SQUASHFS_SWAP((s)->nlink, d, 96, 32);\ -+ SQUASHFS_SWAP((s)->file_size, d, 128, 27);\ -+ SQUASHFS_SWAP((s)->offset, d, 155, 13);\ -+ SQUASHFS_SWAP((s)->start_block, d, 168, 32);\ -+ SQUASHFS_SWAP((s)->i_count, d, 200, 16);\ -+ SQUASHFS_SWAP((s)->parent_inode, d, 216, 32);\ -+} -+ -+#define SQUASHFS_SWAP_DIR_INDEX(s, d) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_dir_index));\ -+ SQUASHFS_SWAP((s)->index, d, 0, 32);\ -+ SQUASHFS_SWAP((s)->start_block, d, 32, 32);\ -+ SQUASHFS_SWAP((s)->size, d, 64, 8);\ -+} -+ -+#define SQUASHFS_SWAP_DIR_HEADER(s, d) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_dir_header));\ -+ SQUASHFS_SWAP((s)->count, d, 0, 8);\ -+ SQUASHFS_SWAP((s)->start_block, d, 8, 32);\ -+ SQUASHFS_SWAP((s)->inode_number, d, 40, 32);\ -+} -+ -+#define SQUASHFS_SWAP_DIR_ENTRY(s, d) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_dir_entry));\ -+ SQUASHFS_SWAP((s)->offset, d, 0, 13);\ -+ SQUASHFS_SWAP((s)->type, d, 13, 3);\ -+ SQUASHFS_SWAP((s)->size, d, 16, 8);\ -+ SQUASHFS_SWAP((s)->inode_number, d, 24, 16);\ -+} -+ -+#define SQUASHFS_SWAP_FRAGMENT_ENTRY(s, d) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_fragment_entry));\ -+ SQUASHFS_SWAP((s)->start_block, d, 0, 64);\ -+ SQUASHFS_SWAP((s)->size, d, 64, 32);\ -+} -+ -+#define SQUASHFS_SWAP_SHORTS(s, d, n) {\ -+ int entry;\ -+ int bit_position;\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_MEMSET(s, d, n * 2);\ -+ for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += \ -+ 16)\ -+ SQUASHFS_SWAP(s[entry], d, bit_position, 16);\ -+} -+ -+#define SQUASHFS_SWAP_INTS(s, d, n) {\ -+ int entry;\ -+ int bit_position;\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_MEMSET(s, d, n * 4);\ -+ for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += \ -+ 32)\ -+ SQUASHFS_SWAP(s[entry], d, bit_position, 32);\ -+} -+ -+#define SQUASHFS_SWAP_LONG_LONGS(s, d, n) {\ -+ int entry;\ -+ int bit_position;\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_MEMSET(s, d, n * 8);\ -+ for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += \ -+ 64)\ -+ SQUASHFS_SWAP(s[entry], d, bit_position, 64);\ -+} -+ -+#define SQUASHFS_SWAP_DATA(s, d, n, bits) {\ -+ int entry;\ -+ int bit_position;\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_MEMSET(s, d, n * bits / 8);\ -+ for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += \ -+ bits)\ -+ SQUASHFS_SWAP(s[entry], d, bit_position, bits);\ -+} -+ -+#define SQUASHFS_SWAP_FRAGMENT_INDEXES(s, d, n) SQUASHFS_SWAP_LONG_LONGS(s, d, n) -+ -+#ifdef CONFIG_SQUASHFS_1_0_COMPATIBILITY -+ -+struct squashfs_base_inode_header_1 { -+ unsigned int inode_type:4; -+ unsigned int mode:12; /* protection */ -+ unsigned int uid:4; /* index into uid table */ -+ unsigned int guid:4; /* index into guid table */ -+} __attribute__ ((packed)); -+ -+struct squashfs_ipc_inode_header_1 { -+ unsigned int inode_type:4; -+ unsigned int mode:12; /* protection */ -+ unsigned int uid:4; /* index into uid table */ -+ unsigned int guid:4; /* index into guid table */ -+ unsigned int type:4; -+ unsigned int offset:4; -+} __attribute__ ((packed)); -+ -+struct squashfs_dev_inode_header_1 { -+ unsigned int inode_type:4; -+ unsigned int mode:12; /* protection */ -+ unsigned int uid:4; /* index into uid table */ -+ unsigned int guid:4; /* index into guid table */ -+ unsigned short rdev; -+} __attribute__ ((packed)); -+ -+struct squashfs_symlink_inode_header_1 { -+ unsigned int inode_type:4; -+ unsigned int mode:12; /* protection */ -+ unsigned int uid:4; /* index into uid table */ -+ unsigned int guid:4; /* index into guid table */ -+ unsigned short symlink_size; -+ char symlink[0]; -+} __attribute__ ((packed)); -+ -+struct squashfs_reg_inode_header_1 { -+ unsigned int inode_type:4; -+ unsigned int mode:12; /* protection */ -+ unsigned int uid:4; /* index into uid table */ -+ unsigned int guid:4; /* index into guid table */ -+ unsigned int mtime; -+ unsigned int start_block; -+ unsigned int file_size:32; -+ unsigned short block_list[0]; -+} __attribute__ ((packed)); -+ -+struct squashfs_dir_inode_header_1 { -+ unsigned int inode_type:4; -+ unsigned int mode:12; /* protection */ -+ unsigned int uid:4; /* index into uid table */ -+ unsigned int guid:4; /* index into guid table */ -+ unsigned int file_size:19; -+ unsigned int offset:13; -+ unsigned int mtime; -+ unsigned int start_block:24; -+} __attribute__ ((packed)); -+ -+#define SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, n) \ -+ SQUASHFS_MEMSET(s, d, n);\ -+ SQUASHFS_SWAP((s)->inode_type, d, 0, 4);\ -+ SQUASHFS_SWAP((s)->mode, d, 4, 12);\ -+ SQUASHFS_SWAP((s)->uid, d, 16, 4);\ -+ SQUASHFS_SWAP((s)->guid, d, 20, 4); -+ -+#define SQUASHFS_SWAP_BASE_INODE_HEADER_1(s, d, n) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, n)\ -+} -+ -+#define SQUASHFS_SWAP_IPC_INODE_HEADER_1(s, d) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, \ -+ sizeof(struct squashfs_ipc_inode_header_1));\ -+ SQUASHFS_SWAP((s)->type, d, 24, 4);\ -+ SQUASHFS_SWAP((s)->offset, d, 28, 4);\ -+} -+ -+#define SQUASHFS_SWAP_DEV_INODE_HEADER_1(s, d) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, \ -+ sizeof(struct squashfs_dev_inode_header_1));\ -+ SQUASHFS_SWAP((s)->rdev, d, 24, 16);\ -+} -+ -+#define SQUASHFS_SWAP_SYMLINK_INODE_HEADER_1(s, d) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, \ -+ sizeof(struct squashfs_symlink_inode_header_1));\ -+ SQUASHFS_SWAP((s)->symlink_size, d, 24, 16);\ -+} -+ -+#define SQUASHFS_SWAP_REG_INODE_HEADER_1(s, d) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, \ -+ sizeof(struct squashfs_reg_inode_header_1));\ -+ SQUASHFS_SWAP((s)->mtime, d, 24, 32);\ -+ SQUASHFS_SWAP((s)->start_block, d, 56, 32);\ -+ SQUASHFS_SWAP((s)->file_size, d, 88, 32);\ -+} -+ -+#define SQUASHFS_SWAP_DIR_INODE_HEADER_1(s, d) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, \ -+ sizeof(struct squashfs_dir_inode_header_1));\ -+ SQUASHFS_SWAP((s)->file_size, d, 24, 19);\ -+ SQUASHFS_SWAP((s)->offset, d, 43, 13);\ -+ SQUASHFS_SWAP((s)->mtime, d, 56, 32);\ -+ SQUASHFS_SWAP((s)->start_block, d, 88, 24);\ -+} -+ -+#endif -+ -+#ifdef CONFIG_SQUASHFS_2_0_COMPATIBILITY -+ -+struct squashfs_dir_index_2 { -+ unsigned int index:27; -+ unsigned int start_block:29; -+ unsigned char size; -+ unsigned char name[0]; -+} __attribute__ ((packed)); -+ -+struct squashfs_base_inode_header_2 { -+ unsigned int inode_type:4; -+ unsigned int mode:12; /* protection */ -+ unsigned int uid:8; /* index into uid table */ -+ unsigned int guid:8; /* index into guid table */ -+} __attribute__ ((packed)); -+ -+struct squashfs_ipc_inode_header_2 { -+ unsigned int inode_type:4; -+ unsigned int mode:12; /* protection */ -+ unsigned int uid:8; /* index into uid table */ -+ unsigned int guid:8; /* index into guid table */ -+} __attribute__ ((packed)); -+ -+struct squashfs_dev_inode_header_2 { -+ unsigned int inode_type:4; -+ unsigned int mode:12; /* protection */ -+ unsigned int uid:8; /* index into uid table */ -+ unsigned int guid:8; /* index into guid table */ -+ unsigned short rdev; -+} __attribute__ ((packed)); -+ -+struct squashfs_symlink_inode_header_2 { -+ unsigned int inode_type:4; -+ unsigned int mode:12; /* protection */ -+ unsigned int uid:8; /* index into uid table */ -+ unsigned int guid:8; /* index into guid table */ -+ unsigned short symlink_size; -+ char symlink[0]; -+} __attribute__ ((packed)); -+ -+struct squashfs_reg_inode_header_2 { -+ unsigned int inode_type:4; -+ unsigned int mode:12; /* protection */ -+ unsigned int uid:8; /* index into uid table */ -+ unsigned int guid:8; /* index into guid table */ -+ unsigned int mtime; -+ unsigned int start_block; -+ unsigned int fragment; -+ unsigned int offset; -+ unsigned int file_size:32; -+ unsigned short block_list[0]; -+} __attribute__ ((packed)); -+ -+struct squashfs_dir_inode_header_2 { -+ unsigned int inode_type:4; -+ unsigned int mode:12; /* protection */ -+ unsigned int uid:8; /* index into uid table */ -+ unsigned int guid:8; /* index into guid table */ -+ unsigned int file_size:19; -+ unsigned int offset:13; -+ unsigned int mtime; -+ unsigned int start_block:24; -+} __attribute__ ((packed)); -+ -+struct squashfs_ldir_inode_header_2 { -+ unsigned int inode_type:4; -+ unsigned int mode:12; /* protection */ -+ unsigned int uid:8; /* index into uid table */ -+ unsigned int guid:8; /* index into guid table */ -+ unsigned int file_size:27; -+ unsigned int offset:13; -+ unsigned int mtime; -+ unsigned int start_block:24; -+ unsigned int i_count:16; -+ struct squashfs_dir_index_2 index[0]; -+} __attribute__ ((packed)); -+ -+union squashfs_inode_header_2 { -+ struct squashfs_base_inode_header_2 base; -+ struct squashfs_dev_inode_header_2 dev; -+ struct squashfs_symlink_inode_header_2 symlink; -+ struct squashfs_reg_inode_header_2 reg; -+ struct squashfs_dir_inode_header_2 dir; -+ struct squashfs_ldir_inode_header_2 ldir; -+ struct squashfs_ipc_inode_header_2 ipc; -+}; -+ -+struct squashfs_dir_header_2 { -+ unsigned int count:8; -+ unsigned int start_block:24; -+} __attribute__ ((packed)); -+ -+struct squashfs_dir_entry_2 { -+ unsigned int offset:13; -+ unsigned int type:3; -+ unsigned int size:8; -+ char name[0]; -+} __attribute__ ((packed)); -+ -+struct squashfs_fragment_entry_2 { -+ unsigned int start_block; -+ unsigned int size; -+} __attribute__ ((packed)); -+ -+#define SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, n)\ -+ SQUASHFS_MEMSET(s, d, n);\ -+ SQUASHFS_SWAP((s)->inode_type, d, 0, 4);\ -+ SQUASHFS_SWAP((s)->mode, d, 4, 12);\ -+ SQUASHFS_SWAP((s)->uid, d, 16, 8);\ -+ SQUASHFS_SWAP((s)->guid, d, 24, 8);\ -+ -+#define SQUASHFS_SWAP_BASE_INODE_HEADER_2(s, d, n) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, n)\ -+} -+ -+#define SQUASHFS_SWAP_IPC_INODE_HEADER_2(s, d) \ -+ SQUASHFS_SWAP_BASE_INODE_HEADER_2(s, d, sizeof(struct squashfs_ipc_inode_header_2)) -+ -+#define SQUASHFS_SWAP_DEV_INODE_HEADER_2(s, d) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, \ -+ sizeof(struct squashfs_dev_inode_header_2)); \ -+ SQUASHFS_SWAP((s)->rdev, d, 32, 16);\ -+} -+ -+#define SQUASHFS_SWAP_SYMLINK_INODE_HEADER_2(s, d) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, \ -+ sizeof(struct squashfs_symlink_inode_header_2));\ -+ SQUASHFS_SWAP((s)->symlink_size, d, 32, 16);\ -+} -+ -+#define SQUASHFS_SWAP_REG_INODE_HEADER_2(s, d) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, \ -+ sizeof(struct squashfs_reg_inode_header_2));\ -+ SQUASHFS_SWAP((s)->mtime, d, 32, 32);\ -+ SQUASHFS_SWAP((s)->start_block, d, 64, 32);\ -+ SQUASHFS_SWAP((s)->fragment, d, 96, 32);\ -+ SQUASHFS_SWAP((s)->offset, d, 128, 32);\ -+ SQUASHFS_SWAP((s)->file_size, d, 160, 32);\ -+} -+ -+#define SQUASHFS_SWAP_DIR_INODE_HEADER_2(s, d) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, \ -+ sizeof(struct squashfs_dir_inode_header_2));\ -+ SQUASHFS_SWAP((s)->file_size, d, 32, 19);\ -+ SQUASHFS_SWAP((s)->offset, d, 51, 13);\ -+ SQUASHFS_SWAP((s)->mtime, d, 64, 32);\ -+ SQUASHFS_SWAP((s)->start_block, d, 96, 24);\ -+} -+ -+#define SQUASHFS_SWAP_LDIR_INODE_HEADER_2(s, d) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, \ -+ sizeof(struct squashfs_ldir_inode_header_2));\ -+ SQUASHFS_SWAP((s)->file_size, d, 32, 27);\ -+ SQUASHFS_SWAP((s)->offset, d, 59, 13);\ -+ SQUASHFS_SWAP((s)->mtime, d, 72, 32);\ -+ SQUASHFS_SWAP((s)->start_block, d, 104, 24);\ -+ SQUASHFS_SWAP((s)->i_count, d, 128, 16);\ -+} -+ -+#define SQUASHFS_SWAP_DIR_INDEX_2(s, d) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_dir_index_2));\ -+ SQUASHFS_SWAP((s)->index, d, 0, 27);\ -+ SQUASHFS_SWAP((s)->start_block, d, 27, 29);\ -+ SQUASHFS_SWAP((s)->size, d, 56, 8);\ -+} -+#define SQUASHFS_SWAP_DIR_HEADER_2(s, d) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_dir_header_2));\ -+ SQUASHFS_SWAP((s)->count, d, 0, 8);\ -+ SQUASHFS_SWAP((s)->start_block, d, 8, 24);\ -+} -+ -+#define SQUASHFS_SWAP_DIR_ENTRY_2(s, d) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_dir_entry_2));\ -+ SQUASHFS_SWAP((s)->offset, d, 0, 13);\ -+ SQUASHFS_SWAP((s)->type, d, 13, 3);\ -+ SQUASHFS_SWAP((s)->size, d, 16, 8);\ -+} -+ -+#define SQUASHFS_SWAP_FRAGMENT_ENTRY_2(s, d) {\ -+ SQUASHFS_SWAP_START\ -+ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_fragment_entry_2));\ -+ SQUASHFS_SWAP((s)->start_block, d, 0, 32);\ -+ SQUASHFS_SWAP((s)->size, d, 32, 32);\ -+} -+ -+#define SQUASHFS_SWAP_FRAGMENT_INDEXES_2(s, d, n) SQUASHFS_SWAP_INTS(s, d, n) -+ -+/* fragment and fragment table defines */ -+#define SQUASHFS_FRAGMENT_BYTES_2(A) (A * sizeof(struct squashfs_fragment_entry_2)) -+ -+#define SQUASHFS_FRAGMENT_INDEX_2(A) (SQUASHFS_FRAGMENT_BYTES_2(A) / \ -+ SQUASHFS_METADATA_SIZE) -+ -+#define SQUASHFS_FRAGMENT_INDEX_OFFSET_2(A) (SQUASHFS_FRAGMENT_BYTES_2(A) % \ -+ SQUASHFS_METADATA_SIZE) -+ -+#define SQUASHFS_FRAGMENT_INDEXES_2(A) ((SQUASHFS_FRAGMENT_BYTES_2(A) + \ -+ SQUASHFS_METADATA_SIZE - 1) / \ -+ SQUASHFS_METADATA_SIZE) -+ -+#define SQUASHFS_FRAGMENT_INDEX_BYTES_2(A) (SQUASHFS_FRAGMENT_INDEXES_2(A) *\ -+ sizeof(int)) -+ -+#endif -+ -+#ifdef __KERNEL__ -+ -+/* -+ * macros used to swap each structure entry, taking into account -+ * bitfields and different bitfield placing conventions on differing -+ * architectures -+ */ -+ -+#include <asm/byteorder.h> -+ -+#ifdef __BIG_ENDIAN -+ /* convert from little endian to big endian */ -+#define SQUASHFS_SWAP(value, p, pos, tbits) _SQUASHFS_SWAP(value, p, pos, \ -+ tbits, b_pos) -+#else -+ /* convert from big endian to little endian */ -+#define SQUASHFS_SWAP(value, p, pos, tbits) _SQUASHFS_SWAP(value, p, pos, \ -+ tbits, 64 - tbits - b_pos) -+#endif -+ -+#define _SQUASHFS_SWAP(value, p, pos, tbits, SHIFT) {\ -+ b_pos = pos % 8;\ -+ val = 0;\ -+ s = (unsigned char *)p + (pos / 8);\ -+ d = ((unsigned char *) &val) + 7;\ -+ for(bits = 0; bits < (tbits + b_pos); bits += 8) \ -+ *d-- = *s++;\ -+ value = (val >> (SHIFT))/* & ((1 << tbits) - 1)*/;\ -+} -+ -+#define SQUASHFS_MEMSET(s, d, n) memset(s, 0, n); -+ -+#endif -+#endif ---- /dev/null -+++ b/include/linux/squashfs_fs_i.h -@@ -0,0 +1,44 @@ -+#ifndef SQUASHFS_FS_I -+#define SQUASHFS_FS_I -+/* -+ * Squashfs -+ * -+ * Copyright (c) 2002, 2003, 2004, 2005, 2006 -+ * Phillip Lougher <phillip@lougher.org.uk> -+ * -+ * 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, -+ * 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+ * -+ * squashfs_fs_i.h -+ */ -+ -+struct squashfs_inode_info { -+ long long start_block; -+ unsigned int offset; -+ union { -+ struct { -+ long long fragment_start_block; -+ unsigned int fragment_size; -+ unsigned int fragment_offset; -+ long long block_list_start; -+ } s1; -+ struct { -+ long long directory_index_start; -+ unsigned int directory_index_offset; -+ unsigned int directory_index_count; -+ unsigned int parent_inode; -+ } s2; -+ } u; -+}; -+#endif ---- /dev/null -+++ b/include/linux/squashfs_fs_sb.h -@@ -0,0 +1,74 @@ -+#ifndef SQUASHFS_FS_SB -+#define SQUASHFS_FS_SB -+/* -+ * Squashfs -+ * -+ * Copyright (c) 2002, 2003, 2004, 2005, 2006 -+ * Phillip Lougher <phillip@lougher.org.uk> -+ * -+ * 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, -+ * 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+ * -+ * squashfs_fs_sb.h -+ */ -+ -+#include <linux/squashfs_fs.h> -+ -+struct squashfs_cache { -+ long long block; -+ int length; -+ long long next_index; -+ char *data; -+}; -+ -+struct squashfs_fragment_cache { -+ long long block; -+ int length; -+ unsigned int locked; -+ char *data; -+}; -+ -+struct squashfs_sb_info { -+ struct squashfs_super_block sblk; -+ int devblksize; -+ int devblksize_log2; -+ int swap; -+ struct squashfs_cache *block_cache; -+ struct squashfs_fragment_cache *fragment; -+ int next_cache; -+ int next_fragment; -+ int next_meta_index; -+ unsigned int *uid; -+ unsigned int *guid; -+ long long *fragment_index; -+ unsigned int *fragment_index_2; -+ unsigned int read_size; -+ char *read_data; -+ char *read_page; -+ struct semaphore read_data_mutex; -+ struct semaphore read_page_mutex; -+ struct semaphore block_cache_mutex; -+ struct semaphore fragment_mutex; -+ struct semaphore meta_index_mutex; -+ wait_queue_head_t waitq; -+ wait_queue_head_t fragment_wait_queue; -+ struct meta_index *meta_index; -+ struct inode *(*iget)(struct super_block *s, squashfs_inode_t \ -+ inode); -+ long long (*read_blocklist)(struct inode *inode, int \ -+ index, int readahead_blks, char *block_list, \ -+ unsigned short **block_p, unsigned int *bsize); -+ int (*read_fragment_index_table)(struct super_block *s); -+}; -+#endif ---- a/init/do_mounts.c -+++ b/init/do_mounts.c -@@ -16,6 +16,7 @@ - #include <linux/minix_fs.h> - #include <linux/ext2_fs.h> - #include <linux/romfs_fs.h> -+#include <linux/squashfs_fs.h> - #include <linux/cramfs_fs.h> - - #define BUILD_CRAMDISK -@@ -485,6 +486,7 @@ static int __init crd_load(int in_fd, in - * minix - * ext2 - * romfs -+ * squashfs - * cramfs - * gzip - */ -@@ -495,6 +497,7 @@ identify_ramdisk_image(int fd, int start - struct minix_super_block *minixsb; - struct ext2_super_block *ext2sb; - struct romfs_super_block *romfsb; -+ struct squashfs_super_block *squashfsb; - struct cramfs_super *cramfsb; - int nblocks = -1; - unsigned char *buf; -@@ -506,6 +509,7 @@ identify_ramdisk_image(int fd, int start - minixsb = (struct minix_super_block *) buf; - ext2sb = (struct ext2_super_block *) buf; - romfsb = (struct romfs_super_block *) buf; -+ squashfsb = (struct squashfs_super_block *) buf; - cramfsb = (struct cramfs_super *) buf; - memset(buf, 0xe5, size); - -@@ -544,6 +548,15 @@ identify_ramdisk_image(int fd, int start - goto done; - } - -+ /* squashfs is at block zero too */ -+ if (squashfsb->s_magic == SQUASHFS_MAGIC) { -+ printk(KERN_NOTICE -+ "RAMDISK: squashfs filesystem found at block %d\n", -+ start_block); -+ nblocks = (squashfsb->bytes_used+BLOCK_SIZE-1)>>BLOCK_SIZE_BITS; -+ goto done; -+ } -+ - /* - * Read block 1 to test for minix and ext2 superblock - */ ---- a/lib/Config.in -+++ b/lib/Config.in -@@ -10,6 +10,7 @@ tristate 'CRC32 functions' CONFIG_CRC32 - # Do we need the compression support? - # - if [ "$CONFIG_CRAMFS" = "y" -o \ -+ "$CONFIG_SQUASHFS" = "y" -o \ - "$CONFIG_PPP_DEFLATE" = "y" -o \ - "$CONFIG_CRYPTO_DEFLATE" = "y" -o \ - "$CONFIG_JFFS2_FS" = "y" -o \ -@@ -17,6 +18,7 @@ if [ "$CONFIG_CRAMFS" = "y" -o \ - define_tristate CONFIG_ZLIB_INFLATE y - else - if [ "$CONFIG_CRAMFS" = "m" -o \ -+ "$CONFIG_SQUASHFS" = "m" -o \ - "$CONFIG_PPP_DEFLATE" = "m" -o \ - "$CONFIG_CRYPTO_DEFLATE" = "m" -o \ - "$CONFIG_JFFS2_FS" = "m" -o \ diff --git a/target/linux/generic-2.4/patches/002-squashfs_lzma.patch b/target/linux/generic-2.4/patches/002-squashfs_lzma.patch deleted file mode 100644 index 9192493..0000000 --- a/target/linux/generic-2.4/patches/002-squashfs_lzma.patch +++ /dev/null @@ -1,879 +0,0 @@ ---- a/fs/squashfs/inode.c -+++ b/fs/squashfs/inode.c -@@ -4,6 +4,9 @@ - * Copyright (c) 2002, 2003, 2004, 2005, 2006 - * Phillip Lougher <phillip@lougher.org.uk> - * -+ * LZMA decompressor support added by Oleg I. Vdovikin -+ * Copyright (c) 2005 Oleg I.Vdovikin <oleg@cs.msu.su> -+ * - * 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, -@@ -21,6 +24,7 @@ - * inode.c - */ - -+#define SQUASHFS_LZMA - #include <linux/types.h> - #include <linux/squashfs_fs.h> - #include <linux/module.h> -@@ -40,6 +44,20 @@ - - #include "squashfs.h" - -+#ifdef SQUASHFS_LZMA -+#include "LzmaDecode.h" -+ -+/* default LZMA settings, should be in sync with mksquashfs */ -+#define LZMA_LC 3 -+#define LZMA_LP 0 -+#define LZMA_PB 2 -+ -+#define LZMA_WORKSPACE_SIZE ((LZMA_BASE_SIZE + \ -+ (LZMA_LIT_SIZE << (LZMA_LC + LZMA_LP))) * sizeof(CProb)) -+ -+#endif -+ -+ - static struct super_block *squashfs_read_super(struct super_block *, void *, int); - static void squashfs_put_super(struct super_block *); - static int squashfs_statfs(struct super_block *, struct statfs *); -@@ -53,7 +71,11 @@ static long long read_blocklist(struct i - int readahead_blks, char *block_list, - unsigned short **block_p, unsigned int *bsize); - -+#ifdef SQUASHFS_LZMA -+static unsigned char lzma_workspace[LZMA_WORKSPACE_SIZE]; -+#else - static z_stream stream; -+#endif - - static DECLARE_FSTYPE_DEV(squashfs_fs_type, "squashfs", squashfs_read_super); - -@@ -229,6 +251,15 @@ SQSH_EXTERN unsigned int squashfs_read_d - if (compressed) { - int zlib_err; - -+#ifdef SQUASHFS_LZMA -+ if ((zlib_err = LzmaDecode(lzma_workspace, -+ LZMA_WORKSPACE_SIZE, LZMA_LC, LZMA_LP, LZMA_PB, -+ c_buffer, c_byte, buffer, msblk->read_size, &bytes)) != LZMA_RESULT_OK) -+ { -+ ERROR("lzma returned unexpected result 0x%x\n", zlib_err); -+ bytes = 0; -+ } -+#else - stream.next_in = c_buffer; - stream.avail_in = c_byte; - stream.next_out = buffer; -@@ -243,6 +274,7 @@ SQSH_EXTERN unsigned int squashfs_read_d - bytes = 0; - } else - bytes = stream.total_out; -+#endif - - up(&msblk->read_data_mutex); - } -@@ -2004,17 +2036,21 @@ static int __init init_squashfs_fs(void) - printk(KERN_INFO "squashfs: version 3.0 (2006/03/15) " - "Phillip Lougher\n"); - -+#ifndef SQUASHFS_LZMA - if (!(stream.workspace = vmalloc(zlib_inflate_workspacesize()))) { - ERROR("Failed to allocate zlib workspace\n"); - return -ENOMEM; - } -+#endif - return register_filesystem(&squashfs_fs_type); - } - - - static void __exit exit_squashfs_fs(void) - { -+#ifndef SQUASHFS_LZMA - vfree(stream.workspace); -+#endif - unregister_filesystem(&squashfs_fs_type); - } - ---- /dev/null -+++ b/fs/squashfs/LzmaDecode.c -@@ -0,0 +1,663 @@ -+/* -+ LzmaDecode.c -+ LZMA Decoder -+ -+ LZMA SDK 4.05 Copyright (c) 1999-2004 Igor Pavlov (2004-08-25) -+ http://www.7-zip.org/ -+ -+ LZMA SDK is licensed under two licenses: -+ 1) GNU Lesser General Public License (GNU LGPL) -+ 2) Common Public License (CPL) -+ It means that you can select one of these two licenses and -+ follow rules of that license. -+ -+ SPECIAL EXCEPTION: -+ Igor Pavlov, as the author of this code, expressly permits you to -+ statically or dynamically link your code (or bind by name) to the -+ interfaces of this file without subjecting your linked code to the -+ terms of the CPL or GNU LGPL. Any modifications or additions -+ to this file, however, are subject to the LGPL or CPL terms. -+*/ -+ -+#include "LzmaDecode.h" -+ -+#ifndef Byte -+#define Byte unsigned char -+#endif -+ -+#define kNumTopBits 24 -+#define kTopValue ((UInt32)1 << kNumTopBits) -+ -+#define kNumBitModelTotalBits 11 -+#define kBitModelTotal (1 << kNumBitModelTotalBits) -+#define kNumMoveBits 5 -+ -+typedef struct _CRangeDecoder -+{ -+ Byte *Buffer; -+ Byte *BufferLim; -+ UInt32 Range; -+ UInt32 Code; -+ #ifdef _LZMA_IN_CB -+ ILzmaInCallback *InCallback; -+ int Result; -+ #endif -+ int ExtraBytes; -+} CRangeDecoder; -+ -+Byte RangeDecoderReadByte(CRangeDecoder *rd) -+{ -+ if (rd->Buffer == rd->BufferLim) -+ { -+ #ifdef _LZMA_IN_CB -+ UInt32 size; -+ rd->Result = rd->InCallback->Read(rd->InCallback, &rd->Buffer, &size); -+ rd->BufferLim = rd->Buffer + size; -+ if (size == 0) -+ #endif -+ { -+ rd->ExtraBytes = 1; -+ return 0xFF; -+ } -+ } -+ return (*rd->Buffer++); -+} -+ -+/* #define ReadByte (*rd->Buffer++) */ -+#define ReadByte (RangeDecoderReadByte(rd)) -+ -+void RangeDecoderInit(CRangeDecoder *rd, -+ #ifdef _LZMA_IN_CB -+ ILzmaInCallback *inCallback -+ #else -+ Byte *stream, UInt32 bufferSize -+ #endif -+ ) -+{ -+ int i; -+ #ifdef _LZMA_IN_CB -+ rd->InCallback = inCallback; -+ rd->Buffer = rd->BufferLim = 0; -+ #else -+ rd->Buffer = stream; -+ rd->BufferLim = stream + bufferSize; -+ #endif -+ rd->ExtraBytes = 0; -+ rd->Code = 0; -+ rd->Range = (0xFFFFFFFF); -+ for(i = 0; i < 5; i++) -+ rd->Code = (rd->Code << 8) | ReadByte; -+} -+ -+#define RC_INIT_VAR UInt32 range = rd->Range; UInt32 code = rd->Code; -+#define RC_FLUSH_VAR rd->Range = range; rd->Code = code; -+#define RC_NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | ReadByte; } -+ -+UInt32 RangeDecoderDecodeDirectBits(CRangeDecoder *rd, int numTotalBits) -+{ -+ RC_INIT_VAR -+ UInt32 result = 0; -+ int i; -+ for (i = numTotalBits; i > 0; i--) -+ { -+ /* UInt32 t; */ -+ range >>= 1; -+ -+ result <<= 1; -+ if (code >= range) -+ { -+ code -= range; -+ result |= 1; -+ } -+ /* -+ t = (code - range) >> 31; -+ t &= 1; -+ code -= range & (t - 1); -+ result = (result + result) | (1 - t); -+ */ -+ RC_NORMALIZE -+ } -+ RC_FLUSH_VAR -+ return result; -+} -+ -+int RangeDecoderBitDecode(CProb *prob, CRangeDecoder *rd) -+{ -+ UInt32 bound = (rd->Range >> kNumBitModelTotalBits) * *prob; -+ if (rd->Code < bound) -+ { -+ rd->Range = bound; -+ *prob += (kBitModelTotal - *prob) >> kNumMoveBits; -+ if (rd->Range < kTopValue) -+ { -+ rd->Code = (rd->Code << 8) | ReadByte; -+ rd->Range <<= 8; -+ } -+ return 0; -+ } -+ else -+ { -+ rd->Range -= bound; -+ rd->Code -= bound; -+ *prob -= (*prob) >> kNumMoveBits; -+ if (rd->Range < kTopValue) -+ { -+ rd->Code = (rd->Code << 8) | ReadByte; -+ rd->Range <<= 8; -+ } -+ return 1; -+ } -+} -+ -+#define RC_GET_BIT2(prob, mi, A0, A1) \ -+ UInt32 bound = (range >> kNumBitModelTotalBits) * *prob; \ -+ if (code < bound) \ -+ { A0; range = bound; *prob += (kBitModelTotal - *prob) >> kNumMoveBits; mi <<= 1; } \ -+ else \ -+ { A1; range -= bound; code -= bound; *prob -= (*prob) >> kNumMoveBits; mi = (mi + mi) + 1; } \ -+ RC_NORMALIZE -+ -+#define RC_GET_BIT(prob, mi) RC_GET_BIT2(prob, mi, ; , ;) -+ -+int RangeDecoderBitTreeDecode(CProb *probs, int numLevels, CRangeDecoder *rd) -+{ -+ int mi = 1; -+ int i; -+ #ifdef _LZMA_LOC_OPT -+ RC_INIT_VAR -+ #endif -+ for(i = numLevels; i > 0; i--) -+ { -+ #ifdef _LZMA_LOC_OPT -+ CProb *prob = probs + mi; -+ RC_GET_BIT(prob, mi) -+ #else -+ mi = (mi + mi) + RangeDecoderBitDecode(probs + mi, rd); -+ #endif -+ } -+ #ifdef _LZMA_LOC_OPT -+ RC_FLUSH_VAR -+ #endif -+ return mi - (1 << numLevels); -+} -+ -+int RangeDecoderReverseBitTreeDecode(CProb *probs, int numLevels, CRangeDecoder *rd) -+{ -+ int mi = 1; -+ int i; -+ int symbol = 0; -+ #ifdef _LZMA_LOC_OPT -+ RC_INIT_VAR -+ #endif -+ for(i = 0; i < numLevels; i++) -+ { -+ #ifdef _LZMA_LOC_OPT -+ CProb *prob = probs + mi; -+ RC_GET_BIT2(prob, mi, ; , symbol |= (1 << i)) -+ #else -+ int bit = RangeDecoderBitDecode(probs + mi, rd); -+ mi = mi + mi + bit; -+ symbol |= (bit << i); -+ #endif -+ } -+ #ifdef _LZMA_LOC_OPT -+ RC_FLUSH_VAR -+ #endif -+ return symbol; -+} -+ -+Byte LzmaLiteralDecode(CProb *probs, CRangeDecoder *rd) -+{ -+ int symbol = 1; -+ #ifdef _LZMA_LOC_OPT -+ RC_INIT_VAR -+ #endif -+ do -+ { -+ #ifdef _LZMA_LOC_OPT -+ CProb *prob = probs + symbol; -+ RC_GET_BIT(prob, symbol) -+ #else -+ symbol = (symbol + symbol) | RangeDecoderBitDecode(probs + symbol, rd); -+ #endif -+ } -+ while (symbol < 0x100); -+ #ifdef _LZMA_LOC_OPT -+ RC_FLUSH_VAR -+ #endif -+ return symbol; -+} -+ -+Byte LzmaLiteralDecodeMatch(CProb *probs, CRangeDecoder *rd, Byte matchByte) -+{ -+ int symbol = 1; -+ #ifdef _LZMA_LOC_OPT -+ RC_INIT_VAR -+ #endif -+ do -+ { -+ int bit; -+ int matchBit = (matchByte >> 7) & 1; -+ matchByte <<= 1; -+ #ifdef _LZMA_LOC_OPT -+ { -+ CProb *prob = probs + ((1 + matchBit) << 8) + symbol; -+ RC_GET_BIT2(prob, symbol, bit = 0, bit = 1) -+ } -+ #else -+ bit = RangeDecoderBitDecode(probs + ((1 + matchBit) << 8) + symbol, rd); -+ symbol = (symbol << 1) | bit; -+ #endif -+ if (matchBit != bit) -+ { -+ while (symbol < 0x100) -+ { -+ #ifdef _LZMA_LOC_OPT -+ CProb *prob = probs + symbol; -+ RC_GET_BIT(prob, symbol) -+ #else -+ symbol = (symbol + symbol) | RangeDecoderBitDecode(probs + symbol, rd); -+ #endif -+ } -+ break; -+ } -+ } -+ while (symbol < 0x100); -+ #ifdef _LZMA_LOC_OPT -+ RC_FLUSH_VAR -+ #endif -+ return symbol; -+} -+ -+#define kNumPosBitsMax 4 -+#define kNumPosStatesMax (1 << kNumPosBitsMax) -+ -+#define kLenNumLowBits 3 -+#define kLenNumLowSymbols (1 << kLenNumLowBits) -+#define kLenNumMidBits 3 -+#define kLenNumMidSymbols (1 << kLenNumMidBits) -+#define kLenNumHighBits 8 -+#define kLenNumHighSymbols (1 << kLenNumHighBits) -+ -+#define LenChoice 0 -+#define LenChoice2 (LenChoice + 1) -+#define LenLow (LenChoice2 + 1) -+#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits)) -+#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits)) -+#define kNumLenProbs (LenHigh + kLenNumHighSymbols) -+ -+int LzmaLenDecode(CProb *p, CRangeDecoder *rd, int posState) -+{ -+ if(RangeDecoderBitDecode(p + LenChoice, rd) == 0) -+ return RangeDecoderBitTreeDecode(p + LenLow + -+ (posState << kLenNumLowBits), kLenNumLowBits, rd); -+ if(RangeDecoderBitDecode(p + LenChoice2, rd) == 0) -+ return kLenNumLowSymbols + RangeDecoderBitTreeDecode(p + LenMid + -+ (posState << kLenNumMidBits), kLenNumMidBits, rd); -+ return kLenNumLowSymbols + kLenNumMidSymbols + -+ RangeDecoderBitTreeDecode(p + LenHigh, kLenNumHighBits, rd); -+} -+ -+#define kNumStates 12 -+ -+#define kStartPosModelIndex 4 -+#define kEndPosModelIndex 14 -+#define kNumFullDistances (1 << (kEndPosModelIndex >> 1)) -+ -+#define kNumPosSlotBits 6 -+#define kNumLenToPosStates 4 -+ -+#define kNumAlignBits 4 -+#define kAlignTableSize (1 << kNumAlignBits) -+ -+#define kMatchMinLen 2 -+ -+#define IsMatch 0 -+#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax)) -+#define IsRepG0 (IsRep + kNumStates) -+#define IsRepG1 (IsRepG0 + kNumStates) -+#define IsRepG2 (IsRepG1 + kNumStates) -+#define IsRep0Long (IsRepG2 + kNumStates) -+#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax)) -+#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits)) -+#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex) -+#define LenCoder (Align + kAlignTableSize) -+#define RepLenCoder (LenCoder + kNumLenProbs) -+#define Literal (RepLenCoder + kNumLenProbs) -+ -+#if Literal != LZMA_BASE_SIZE -+StopCompilingDueBUG -+#endif -+ -+#ifdef _LZMA_OUT_READ -+ -+typedef struct _LzmaVarState -+{ -+ CRangeDecoder RangeDecoder; -+ Byte *Dictionary; -+ UInt32 DictionarySize; -+ UInt32 DictionaryPos; -+ UInt32 GlobalPos; -+ UInt32 Reps[4]; -+ int lc; -+ int lp; -+ int pb; -+ int State; -+ int PreviousIsMatch; -+ int RemainLen; -+} LzmaVarState; -+ -+int LzmaDecoderInit( -+ unsigned char *buffer, UInt32 bufferSize, -+ int lc, int lp, int pb, -+ unsigned char *dictionary, UInt32 dictionarySize, -+ #ifdef _LZMA_IN_CB -+ ILzmaInCallback *inCallback -+ #else -+ unsigned char *inStream, UInt32 inSize -+ #endif -+ ) -+{ -+ LzmaVarState *vs = (LzmaVarState *)buffer; -+ CProb *p = (CProb *)(buffer + sizeof(LzmaVarState)); -+ UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + lp)); -+ UInt32 i; -+ if (bufferSize < numProbs * sizeof(CProb) + sizeof(LzmaVarState)) -+ return LZMA_RESULT_NOT_ENOUGH_MEM; -+ vs->Dictionary = dictionary; -+ vs->DictionarySize = dictionarySize; -+ vs->DictionaryPos = 0; -+ vs->GlobalPos = 0; -+ vs->Reps[0] = vs->Reps[1] = vs->Reps[2] = vs->Reps[3] = 1; -+ vs->lc = lc; -+ vs->lp = lp; -+ vs->pb = pb; -+ vs->State = 0; -+ vs->PreviousIsMatch = 0; -+ vs->RemainLen = 0; -+ dictionary[dictionarySize - 1] = 0; -+ for (i = 0; i < numProbs; i++) -+ p[i] = kBitModelTotal >> 1; -+ RangeDecoderInit(&vs->RangeDecoder, -+ #ifdef _LZMA_IN_CB -+ inCallback -+ #else -+ inStream, inSize -+ #endif -+ ); -+ return LZMA_RESULT_OK; -+} -+ -+int LzmaDecode(unsigned char *buffer, -+ unsigned char *outStream, UInt32 outSize, -+ UInt32 *outSizeProcessed) -+{ -+ LzmaVarState *vs = (LzmaVarState *)buffer; -+ CProb *p = (CProb *)(buffer + sizeof(LzmaVarState)); -+ CRangeDecoder rd = vs->RangeDecoder; -+ int state = vs->State; -+ int previousIsMatch = vs->PreviousIsMatch; -+ Byte previousByte; -+ UInt32 rep0 = vs->Reps[0], rep1 = vs->Reps[1], rep2 = vs->Reps[2], rep3 = vs->Reps[3]; -+ UInt32 nowPos = 0; -+ UInt32 posStateMask = (1 << (vs->pb)) - 1; -+ UInt32 literalPosMask = (1 << (vs->lp)) - 1; -+ int lc = vs->lc; -+ int len = vs->RemainLen; -+ UInt32 globalPos = vs->GlobalPos; -+ -+ Byte *dictionary = vs->Dictionary; -+ UInt32 dictionarySize = vs->DictionarySize; -+ UInt32 dictionaryPos = vs->DictionaryPos; -+ -+ if (len == -1) -+ { -+ *outSizeProcessed = 0; -+ return LZMA_RESULT_OK; -+ } -+ -+ while(len > 0 && nowPos < outSize) -+ { -+ UInt32 pos = dictionaryPos - rep0; -+ if (pos >= dictionarySize) -+ pos += dictionarySize; -+ outStream[nowPos++] = dictionary[dictionaryPos] = dictionary[pos]; -+ if (++dictionaryPos == dictionarySize) -+ dictionaryPos = 0; -+ len--; -+ } -+ if (dictionaryPos == 0) -+ previousByte = dictionary[dictionarySize - 1]; -+ else -+ previousByte = dictionary[dictionaryPos - 1]; -+#else -+ -+int LzmaDecode( -+ Byte *buffer, UInt32 bufferSize, -+ int lc, int lp, int pb, -+ #ifdef _LZMA_IN_CB -+ ILzmaInCallback *inCallback, -+ #else -+ unsigned char *inStream, UInt32 inSize, -+ #endif -+ unsigned char *outStream, UInt32 outSize, -+ UInt32 *outSizeProcessed) -+{ -+ UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + lp)); -+ CProb *p = (CProb *)buffer; -+ CRangeDecoder rd; -+ UInt32 i; -+ int state = 0; -+ int previousIsMatch = 0; -+ Byte previousByte = 0; -+ UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1; -+ UInt32 nowPos = 0; -+ UInt32 posStateMask = (1 << pb) - 1; -+ UInt32 literalPosMask = (1 << lp) - 1; -+ int len = 0; -+ if (bufferSize < numProbs * sizeof(CProb)) -+ return LZMA_RESULT_NOT_ENOUGH_MEM; -+ for (i = 0; i < numProbs; i++) -+ p[i] = kBitModelTotal >> 1; -+ RangeDecoderInit(&rd, -+ #ifdef _LZMA_IN_CB -+ inCallback -+ #else -+ inStream, inSize -+ #endif -+ ); -+#endif -+ -+ *outSizeProcessed = 0; -+ while(nowPos < outSize) -+ { -+ int posState = (int)( -+ (nowPos -+ #ifdef _LZMA_OUT_READ -+ + globalPos -+ #endif -+ ) -+ & posStateMask); -+ #ifdef _LZMA_IN_CB -+ if (rd.Result != LZMA_RESULT_OK) -+ return rd.Result; -+ #endif -+ if (rd.ExtraBytes != 0) -+ return LZMA_RESULT_DATA_ERROR; -+ if (RangeDecoderBitDecode(p + IsMatch + (state << kNumPosBitsMax) + posState, &rd) == 0) -+ { -+ CProb *probs = p + Literal + (LZMA_LIT_SIZE * -+ ((( -+ (nowPos -+ #ifdef _LZMA_OUT_READ -+ + globalPos -+ #endif -+ ) -+ & literalPosMask) << lc) + (previousByte >> (8 - lc)))); -+ -+ if (state < 4) state = 0; -+ else if (state < 10) state -= 3; -+ else state -= 6; -+ if (previousIsMatch) -+ { -+ Byte matchByte; -+ #ifdef _LZMA_OUT_READ -+ UInt32 pos = dictionaryPos - rep0; -+ if (pos >= dictionarySize) -+ pos += dictionarySize; -+ matchByte = dictionary[pos]; -+ #else -+ matchByte = outStream[nowPos - rep0]; -+ #endif -+ previousByte = LzmaLiteralDecodeMatch(probs, &rd, matchByte); -+ previousIsMatch = 0; -+ } -+ else -+ previousByte = LzmaLiteralDecode(probs, &rd); -+ outStream[nowPos++] = previousByte; -+ #ifdef _LZMA_OUT_READ -+ dictionary[dictionaryPos] = previousByte; -+ if (++dictionaryPos == dictionarySize) -+ dictionaryPos = 0; -+ #endif -+ } -+ else -+ { -+ previousIsMatch = 1; -+ if (RangeDecoderBitDecode(p + IsRep + state, &rd) == 1) -+ { -+ if (RangeDecoderBitDecode(p + IsRepG0 + state, &rd) == 0) -+ { -+ if (RangeDecoderBitDecode(p + IsRep0Long + (state << kNumPosBitsMax) + posState, &rd) == 0) -+ { -+ #ifdef _LZMA_OUT_READ -+ UInt32 pos; -+ #endif -+ if ( -+ (nowPos -+ #ifdef _LZMA_OUT_READ -+ + globalPos -+ #endif -+ ) -+ == 0) -+ return LZMA_RESULT_DATA_ERROR; -+ state = state < 7 ? 9 : 11; -+ #ifdef _LZMA_OUT_READ -+ pos = dictionaryPos - rep0; -+ if (pos >= dictionarySize) -+ pos += dictionarySize; -+ previousByte = dictionary[pos]; -+ dictionary[dictionaryPos] = previousByte; -+ if (++dictionaryPos == dictionarySize) -+ dictionaryPos = 0; -+ #else -+ previousByte = outStream[nowPos - rep0]; -+ #endif -+ outStream[nowPos++] = previousByte; -+ continue; -+ } -+ } -+ else -+ { -+ UInt32 distance; -+ if(RangeDecoderBitDecode(p + IsRepG1 + state, &rd) == 0) -+ distance = rep1; -+ else -+ { -+ if(RangeDecoderBitDecode(p + IsRepG2 + state, &rd) == 0) -+ distance = rep2; -+ else -+ { -+ distance = rep3; -+ rep3 = rep2; -+ } -+ rep2 = rep1; -+ } -+ rep1 = rep0; -+ rep0 = distance; -+ } -+ len = LzmaLenDecode(p + RepLenCoder, &rd, posState); -+ state = state < 7 ? 8 : 11; -+ } -+ else -+ { -+ int posSlot; -+ rep3 = rep2; -+ rep2 = rep1; -+ rep1 = rep0; -+ state = state < 7 ? 7 : 10; -+ len = LzmaLenDecode(p + LenCoder, &rd, posState); -+ posSlot = RangeDecoderBitTreeDecode(p + PosSlot + -+ ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << -+ kNumPosSlotBits), kNumPosSlotBits, &rd); -+ if (posSlot >= kStartPosModelIndex) -+ { -+ int numDirectBits = ((posSlot >> 1) - 1); -+ rep0 = ((2 | ((UInt32)posSlot & 1)) << numDirectBits); -+ if (posSlot < kEndPosModelIndex) -+ { -+ rep0 += RangeDecoderReverseBitTreeDecode( -+ p + SpecPos + rep0 - posSlot - 1, numDirectBits, &rd); -+ } -+ else -+ { -+ rep0 += RangeDecoderDecodeDirectBits(&rd, -+ numDirectBits - kNumAlignBits) << kNumAlignBits; -+ rep0 += RangeDecoderReverseBitTreeDecode(p + Align, kNumAlignBits, &rd); -+ } -+ } -+ else -+ rep0 = posSlot; -+ rep0++; -+ } -+ if (rep0 == (UInt32)(0)) -+ { -+ /* it's for stream version */ -+ len = -1; -+ break; -+ } -+ if (rep0 > nowPos -+ #ifdef _LZMA_OUT_READ -+ + globalPos -+ #endif -+ ) -+ { -+ return LZMA_RESULT_DATA_ERROR; -+ } -+ len += kMatchMinLen; -+ do -+ { -+ #ifdef _LZMA_OUT_READ -+ UInt32 pos = dictionaryPos - rep0; -+ if (pos >= dictionarySize) -+ pos += dictionarySize; -+ previousByte = dictionary[pos]; -+ dictionary[dictionaryPos] = previousByte; -+ if (++dictionaryPos == dictionarySize) -+ dictionaryPos = 0; -+ #else -+ previousByte = outStream[nowPos - rep0]; -+ #endif -+ outStream[nowPos++] = previousByte; -+ len--; -+ } -+ while(len > 0 && nowPos < outSize); -+ } -+ } -+ -+ #ifdef _LZMA_OUT_READ -+ vs->RangeDecoder = rd; -+ vs->DictionaryPos = dictionaryPos; -+ vs->GlobalPos = globalPos + nowPos; -+ vs->Reps[0] = rep0; -+ vs->Reps[1] = rep1; -+ vs->Reps[2] = rep2; -+ vs->Reps[3] = rep3; -+ vs->State = state; -+ vs->PreviousIsMatch = previousIsMatch; -+ vs->RemainLen = len; -+ #endif -+ -+ *outSizeProcessed = nowPos; -+ return LZMA_RESULT_OK; -+} ---- /dev/null -+++ b/fs/squashfs/LzmaDecode.h -@@ -0,0 +1,100 @@ -+/* -+ LzmaDecode.h -+ LZMA Decoder interface -+ -+ LZMA SDK 4.05 Copyright (c) 1999-2004 Igor Pavlov (2004-08-25) -+ http://www.7-zip.org/ -+ -+ LZMA SDK is licensed under two licenses: -+ 1) GNU Lesser General Public License (GNU LGPL) -+ 2) Common Public License (CPL) -+ It means that you can select one of these two licenses and -+ follow rules of that license. -+ -+ SPECIAL EXCEPTION: -+ Igor Pavlov, as the author of this code, expressly permits you to -+ statically or dynamically link your code (or bind by name) to the -+ interfaces of this file without subjecting your linked code to the -+ terms of the CPL or GNU LGPL. Any modifications or additions -+ to this file, however, are subject to the LGPL or CPL terms. -+*/ -+ -+#ifndef __LZMADECODE_H -+#define __LZMADECODE_H -+ -+/* #define _LZMA_IN_CB */ -+/* Use callback for input data */ -+ -+/* #define _LZMA_OUT_READ */ -+/* Use read function for output data */ -+ -+/* #define _LZMA_PROB32 */ -+/* It can increase speed on some 32-bit CPUs, -+ but memory usage will be doubled in that case */ -+ -+/* #define _LZMA_LOC_OPT */ -+/* Enable local speed optimizations inside code */ -+ -+#ifndef UInt32 -+#ifdef _LZMA_UINT32_IS_ULONG -+#define UInt32 unsigned long -+#else -+#define UInt32 unsigned int -+#endif -+#endif -+ -+#ifdef _LZMA_PROB32 -+#define CProb UInt32 -+#else -+#define CProb unsigned short -+#endif -+ -+#define LZMA_RESULT_OK 0 -+#define LZMA_RESULT_DATA_ERROR 1 -+#define LZMA_RESULT_NOT_ENOUGH_MEM 2 -+ -+#ifdef _LZMA_IN_CB -+typedef struct _ILzmaInCallback -+{ -+ int (*Read)(void *object, unsigned char **buffer, UInt32 *bufferSize); -+} ILzmaInCallback; -+#endif -+ -+#define LZMA_BASE_SIZE 1846 -+#define LZMA_LIT_SIZE 768 -+ -+/* -+bufferSize = (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp)))* sizeof(CProb) -+bufferSize += 100 in case of _LZMA_OUT_READ -+by default CProb is unsigned short, -+but if specify _LZMA_PROB_32, CProb will be UInt32(unsigned int) -+*/ -+ -+#ifdef _LZMA_OUT_READ -+int LzmaDecoderInit( -+ unsigned char *buffer, UInt32 bufferSize, -+ int lc, int lp, int pb, -+ unsigned char *dictionary, UInt32 dictionarySize, -+ #ifdef _LZMA_IN_CB -+ ILzmaInCallback *inCallback -+ #else -+ unsigned char *inStream, UInt32 inSize -+ #endif -+); -+#endif -+ -+int LzmaDecode( -+ unsigned char *buffer, -+ #ifndef _LZMA_OUT_READ -+ UInt32 bufferSize, -+ int lc, int lp, int pb, -+ #ifdef _LZMA_IN_CB -+ ILzmaInCallback *inCallback, -+ #else -+ unsigned char *inStream, UInt32 inSize, -+ #endif -+ #endif -+ unsigned char *outStream, UInt32 outSize, -+ UInt32 *outSizeProcessed); -+ -+#endif ---- a/fs/squashfs/Makefile -+++ b/fs/squashfs/Makefile -@@ -4,7 +4,7 @@ - - O_TARGET := squashfs.o - --obj-y := inode.o squashfs2_0.o -+obj-y := inode.o squashfs2_0.o LzmaDecode.o - - obj-m := $(O_TARGET) - diff --git a/target/linux/generic-2.4/patches/003-jffs2_compression.patch b/target/linux/generic-2.4/patches/003-jffs2_compression.patch deleted file mode 100644 index c0eebf8..0000000 --- a/target/linux/generic-2.4/patches/003-jffs2_compression.patch +++ /dev/null @@ -1,9096 +0,0 @@ ---- a/Documentation/Configure.help -+++ b/Documentation/Configure.help -@@ -17592,6 +17592,32 @@ CONFIG_JFFS2_FS_DEBUG - If reporting bugs, please try to have available a full dump of the - messages at debug level 1 while the misbehaviour was occurring. - -+ARMLIB compression support for BBC (EXPERIMENTAL) -+CONFIG_JFFS2_BBC_ARMLIB -+ This enables ARMLIB support for BBC. -+ -+LZO1X-* compression support for BBC (EXPERIMENTAL) -+CONFIG_JFFS2_BBC_LZO -+ This enables LZO1X-1 and LZO1X-999 support for BBC. (fast & good -+ compressor, beats ZLIB in everything) -+ -+LZARI compression support for BBC (EXPERIMENTAL) -+CONFIG_JFFS2_BBC_LZARI -+ This enables LempelZiv-Storer-Szymanski compression for BBC with -+ additional arithmetic coding (damn slow, but best compresor). -+ -+LZHD compression support for BBC (EXPERIMENTAL) -+CONFIG_JFFS2_BBC_LZHD -+ This enables LempelZiv-Storer-Szymanski compression for BBC with -+ additional dynamic Huffman coding (a little faster than LZARI, and -+ it's compression ratio is a little worse than LZARI's) -+ -+LZSS compression support for BBC (EXPERIMENTAL) -+CONFIG_JFFS2_BBC_LZSS -+ This enables simple LempelZiv-Storer-Szymanski compression for BBC -+ (faster than LZHD, and, and has a not-so-good compression ratio, -+ was included just for testing) -+ - JFFS stats available in /proc filesystem - CONFIG_JFFS_PROC_FS - Enabling this option will cause statistics from mounted JFFS file systems ---- a/fs/Config.in -+++ b/fs/Config.in -@@ -50,6 +50,12 @@ dep_tristate 'Journalling Flash File Sys - if [ "$CONFIG_JFFS2_FS" = "y" -o "$CONFIG_JFFS2_FS" = "m" ] ; then - int 'JFFS2 debugging verbosity (0 = quiet, 2 = noisy)' CONFIG_JFFS2_FS_DEBUG 0 - fi -+dep_mbool ' ARMLIB compression support for BBC (EXPERIMENTAL)' CONFIG_JFFS2_BBC_ARMLIB $CONFIG_JFFS2_FS -+dep_mbool ' LZO1X-* compression support for BBC (EXPERIMENTAL)' CONFIG_JFFS2_BBC_LZO $CONFIG_JFFS2_FS -+dep_mbool ' LZARI compression support for BBC (EXPERIMENTAL)' CONFIG_JFFS2_BBC_LZARI $CONFIG_JFFS2_FS -+dep_mbool ' LZHD compression support for BBC (EXPERIMENTAL)' CONFIG_JFFS2_BBC_LZHD $CONFIG_JFFS2_FS -+dep_mbool ' LZSS compression support for BBC (EXPERIMENTAL)' CONFIG_JFFS2_BBC_LZSS $CONFIG_JFFS2_FS -+ - tristate 'Compressed ROM file system support' CONFIG_CRAMFS - tristate 'Squashed file system support' CONFIG_SQUASHFS - if [ "$CONFIG_SQUASHFS" = "y" -o "$CONFIG_SQUASHFS" = "m" ] ; then ---- /dev/null -+++ b/fs/jffs2/Config.in.bbc.inc -@@ -0,0 +1,5 @@ -+dep_mbool ' ARMLIB compression support for BBC (EXPERIMENTAL)' CONFIG_JFFS2_BBC_ARMLIB $CONFIG_JFFS2_FS -+dep_mbool ' LZO1X-* compression support for BBC (EXPERIMENTAL)' CONFIG_JFFS2_BBC_LZO $CONFIG_JFFS2_FS -+dep_mbool ' LZARI compression support for BBC (EXPERIMENTAL)' CONFIG_JFFS2_BBC_LZARI $CONFIG_JFFS2_FS -+dep_mbool ' LZHD compression support for BBC (EXPERIMENTAL)' CONFIG_JFFS2_BBC_LZHD $CONFIG_JFFS2_FS -+dep_mbool ' LZSS compression support for BBC (EXPERIMENTAL)' CONFIG_JFFS2_BBC_LZSS $CONFIG_JFFS2_FS ---- /dev/null -+++ b/fs/jffs2/Configure.help.bbc.inc -@@ -0,0 +1,25 @@ -+ARMLIB compression support for BBC (EXPERIMENTAL) -+CONFIG_JFFS2_BBC_ARMLIB -+ This enables ARMLIB support for BBC. -+ -+LZO1X-* compression support for BBC (EXPERIMENTAL) -+CONFIG_JFFS2_BBC_LZO -+ This enables LZO1X-1 and LZO1X-999 support for BBC. (fast & good -+ compressor, beats ZLIB in everything) -+ -+LZARI compression support for BBC (EXPERIMENTAL) -+CONFIG_JFFS2_BBC_LZARI -+ This enables LempelZiv-Storer-Szymanski compression for BBC with -+ additional arithmetic coding (damn slow, but best compresor). -+ -+LZHD compression support for BBC (EXPERIMENTAL) -+CONFIG_JFFS2_BBC_LZHD -+ This enables LempelZiv-Storer-Szymanski compression for BBC with -+ additional dynamic Huffman coding (a little faster than LZARI, and -+ it's compression ratio is a little worse than LZARI's) -+ -+LZSS compression support for BBC (EXPERIMENTAL) -+CONFIG_JFFS2_BBC_LZSS -+ This enables simple LempelZiv-Storer-Szymanski compression for BBC -+ (faster than LZHD, and, and has a not-so-good compression ratio, -+ was included just for testing) ---- /dev/null -+++ b/fs/jffs2/Kconfig.bbc.inc -@@ -0,0 +1,40 @@ -+config JFFS2_BBC_ARMLIB -+ bool "ARMLIB compression support for BBC (EXPERIMENTAL)" -+ depends on JFFS2_FS && EXPERIMENTAL -+ default y -+ help -+ This enables ARMLIB support for BBC. -+ -+config JFFS2_BBC_LZO -+ bool "LZO1X-* compression support for BBC (EXPERIMENTAL)" -+ depends on JFFS2_FS && EXPERIMENTAL -+ default y -+ help -+ This enables LZO1X-1 and LZO1X-999 support for BBC. (fast & good -+ compressor) -+ -+config JFFS2_BBC_LZARI -+ bool "LZARI compression support for BBC (EXPERIMENTAL)" -+ depends on JFFS2_FS && EXPERIMENTAL -+ default y -+ help -+ This enables LempelZiv-Storer-Szymanski compression for BBC with -+ additional arithmetic coding (damn slow, but best compresor). -+ -+config JFFS2_BBC_LZHD -+ bool "LZHD compression support for BBC (EXPERIMENTAL)" -+ depends on JFFS2_FS && EXPERIMENTAL -+ default y -+ help -+ This enables LempelZiv-Storer-Szymanski compression for BBC with -+ additional dynamic Huffman coding (a little faster than LZARI, and -+ it's compression ratio is a little worse than LZARI's) -+ -+config JFFS2_BBC_LZSS -+ bool "LZSS compression support for BBC (EXPERIMENTAL)" -+ depends on JFFS2_FS && EXPERIMENTAL -+ default y -+ help -+ This enables simple LempelZiv-Storer-Szymanski compression for BBC -+ (faster than LZHD, and, and has a not-so-good compression ratio, -+ was included just for testing) ---- a/fs/jffs2/Makefile -+++ b/fs/jffs2/Makefile -@@ -10,9 +10,23 @@ - # Note 2! The CFLAGS definitions are now in the main makefile... - - -+JFFS2_BBC_KERNEL_OBJS-y = jffs2_bbc_framework.o jffs2_bbc_fs.o -+ -+JFFS2_BBC_KERNEL_OBJS-$(CONFIG_JFFS2_BBC_ARMLIB) += jffs2_bbc_armlib_comp.o -+JFFS2_BBC_KERNEL_OBJS-$(CONFIG_JFFS2_BBC_LZO) += jffs2_bbc_lzo_comp.o -+JFFS2_BBC_KERNEL_OBJS-$(CONFIG_JFFS2_BBC_LZSS) += jffs2_bbc_lzss_comp.o -+JFFS2_BBC_KERNEL_OBJS-$(CONFIG_JFFS2_BBC_LZARI) += jffs2_bbc_lzari_comp.o -+JFFS2_BBC_KERNEL_OBJS-$(CONFIG_JFFS2_BBC_LZHD) += jffs2_bbc_lzhd_comp.o -+ -+JFFS2_BBC_KERNEL_OBJS := $(JFFS2_BBC_KERNEL_OBJS-y) -+ -+JFFS2_BBC_MKFS_OBJS = jffs2_bbc_mkfs.o jffs2_bbc_framework.o jffs2_bbc_armlib_comp.o jffs2_bbc_lzo_comp.o\ -+ jffs2_bbc_lzss_comp.o jffs2_bbc_lzari_comp.o jffs2_bbc_lzhd_comp.o -+ - COMPR_OBJS := compr.o compr_rubin.o compr_rtime.o pushpull.o \ - compr_zlib.o - JFFS2_OBJS := dir.o file.o ioctl.o nodelist.o malloc.o \ -+ $(JFFS2_BBC_KERNEL_OBJS) \ - read.o nodemgmt.o readinode.o super.o write.o scan.o gc.o \ - symlink.o build.o erase.o background.o - ---- /dev/null -+++ b/fs/jffs2/Makefile.bbc.inc -@@ -0,0 +1,12 @@ -+JFFS2_BBC_KERNEL_OBJS-y = jffs2_bbc_framework.o jffs2_bbc_fs.o -+ -+JFFS2_BBC_KERNEL_OBJS-$(CONFIG_JFFS2_BBC_ARMLIB) += jffs2_bbc_armlib_comp.o -+JFFS2_BBC_KERNEL_OBJS-$(CONFIG_JFFS2_BBC_LZO) += jffs2_bbc_lzo_comp.o -+JFFS2_BBC_KERNEL_OBJS-$(CONFIG_JFFS2_BBC_LZSS) += jffs2_bbc_lzss_comp.o -+JFFS2_BBC_KERNEL_OBJS-$(CONFIG_JFFS2_BBC_LZARI) += jffs2_bbc_lzari_comp.o -+JFFS2_BBC_KERNEL_OBJS-$(CONFIG_JFFS2_BBC_LZHD) += jffs2_bbc_lzhd_comp.o -+ -+JFFS2_BBC_KERNEL_OBJS := $(JFFS2_BBC_KERNEL_OBJS-y) -+ -+JFFS2_BBC_MKFS_OBJS = jffs2_bbc_mkfs.o jffs2_bbc_framework.o jffs2_bbc_armlib_comp.o jffs2_bbc_lzo_comp.o\ -+ jffs2_bbc_lzss_comp.o jffs2_bbc_lzari_comp.o jffs2_bbc_lzhd_comp.o ---- a/fs/jffs2/compr_zlib.c -+++ b/fs/jffs2/compr_zlib.c -@@ -85,7 +85,7 @@ void jffs2_zlib_exit(void) - vfree(inflate_workspace); - } - --int zlib_compress(unsigned char *data_in, unsigned char *cpage_out, -+int jffs2_zlib_compress2(unsigned char *data_in, unsigned char *cpage_out, - __u32 *sourcelen, __u32 *dstlen) - { - z_stream strm; -@@ -145,7 +145,7 @@ int zlib_compress(unsigned char *data_in - return 0; - } - --void zlib_decompress(unsigned char *data_in, unsigned char *cpage_out, -+void jffs2_zlib_decompress2(unsigned char *data_in, unsigned char *cpage_out, - __u32 srclen, __u32 destlen) - { - z_stream strm; -@@ -175,3 +175,19 @@ void zlib_decompress(unsigned char *data - zlib_inflateEnd(&strm); - up(&inflate_sem); - } -+ -+extern int jffs2_zlib_compress(unsigned char *data_in, unsigned char *cpage_out, __u32 * sourcelen, __u32 * dstlen); -+extern void jffs2_zlib_decompress(unsigned char *data_in, unsigned char *cpage_out, __u32 srclen, __u32 destlen); -+ -+int zlib_compress(unsigned char *data_in, unsigned char *cpage_out, -+ __u32 *sourcelen, __u32 *dstlen) -+{ -+ return jffs2_zlib_compress(data_in,cpage_out,sourcelen,dstlen); -+} -+ -+void zlib_decompress(unsigned char *data_in, unsigned char *cpage_out, -+ __u32 srclen, __u32 destlen) -+{ -+ jffs2_zlib_decompress(data_in,cpage_out,srclen,destlen); -+} -+ ---- a/fs/jffs2/file.c -+++ b/fs/jffs2/file.c -@@ -35,6 +35,7 @@ - * - */ - -+#include "jffs2_bbc_framework.h" /**BBC**/ - #include <linux/kernel.h> - #include <linux/mtd/compatmac.h> /* for min() */ - #include <linux/slab.h> -@@ -459,6 +460,7 @@ int jffs2_commit_write (struct file *fil - - comprbuf = kmalloc(cdatalen, GFP_KERNEL); - if (comprbuf) { -+ jffs2_bbc_model_set_act_sb(c); /**BBC**/ - comprtype = jffs2_compress(page_address(pg)+ (file_ofs & (PAGE_CACHE_SIZE-1)), comprbuf, &datalen, &cdatalen); - } - if (comprtype == JFFS2_COMPR_NONE) { ---- a/fs/jffs2/gc.c -+++ b/fs/jffs2/gc.c -@@ -35,6 +35,7 @@ - * - */ - -+#include "jffs2_bbc_framework.h" /**BBC**/ - #include <linux/kernel.h> - #include <linux/mtd/mtd.h> - #include <linux/slab.h> -@@ -651,6 +652,7 @@ static int jffs2_garbage_collect_dnode(s - writebuf = pg_ptr + (offset & (PAGE_CACHE_SIZE -1)); - - if (comprbuf) { -+ jffs2_bbc_model_set_act_sb(c); /**BBC**/ - comprtype = jffs2_compress(writebuf, comprbuf, &datalen, &cdatalen); - } - if (comprtype) { ---- /dev/null -+++ b/fs/jffs2/hpatch -@@ -0,0 +1,191 @@ -+#!/usr/bin/perl -+# A patch-like utility -+# Designed for patching different version of jffs2 with the same hpatch file -+# -+# Copyright (C) 2004, Ferenc Havasi -+# -+# 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. -+ -+$filename_tmp1="file1.tmp"; -+$filename_tmp2="file2.tmp"; -+ -+$filename_in=""; -+$filename_out=$filename_tmp1; -+$filename_cnt=0; -+ -+# Modes: -+# 0: expecting = -+# 1: normal_cmd -+# 2: skip until = -+# 3: expecting F (first state) -+$mode=3; -+ -+%rules = (); -+ -+sub file_end { -+ if (($mode!=2)&&($modified==1)) { -+ while (<SRC>) { -+ print DST $_; -+ } -+ close(SRC); -+ close(DST); -+ if ($cmd_name ne "") { $rules{"$cmd_name"}=1; } -+ $filename_result=$filename_out; -+ if ($filename_result ne $filename_in_save) { -+ open(RES,"<$filename_result") or die "Cannot open $filename_result.\n"; -+ open(DST,">$filename_in_save") or die "Cannot open $filename_in_save.\n"; -+ while (<RES>) { -+ print DST $_; -+ } -+ close(DST); -+ close(RES); -+ } -+ unlink($filename_tmp1) && unlink($filename_tmp2); -+ } -+ else { -+ close(SRC); -+ close(DST); -+ $filename_result=$filename_in; -+ if ($filename_result ne $filename_in_save) { -+ open(RES,"<$filename_result") or die "Cannot open $filename_result.\n"; -+ open(DST,">$filename_in_save") or die "Cannot open $filename_in_save.\n"; -+ while (<RES>) { -+ print DST $_; -+ } -+ close(DST); -+ close(RES); -+ } -+ unlink($filename_tmp1); -+ } -+ $modified=0; -+ foreach $rulename (keys %rules) { -+ if ($rules{"$rulename"}==0) { print(STDERR "On $filename_in_save error applying rule $rulename.\n"); } -+ } -+ %rules = (); -+} -+ -+if ($#ARGV<0) { -+ print ("usage: hpatch hpatch_file\n"); -+ exit; -+} -+ -+open(CMD,"<$ARGV[0]") or die "Cannot open $ARGV[0].\n"; -+$cmd_linenum=0; -+ -+while (chomp($cmd_line=<CMD>)) { -+ $cmd_linenum++; -+ if ($cmd_line eq "") {next;} -+ #$cmd_line =~ s/\#.*//; -+ $cmd_line =~ s/\ *$//; -+ if ($cmd_line eq "") {next;} -+ if ($cmd_line =~ /^F(.*)/) { -+ $tmp_filename_in=$1; -+ if ($mode!=3) { -+ file_end(); -+ } -+ $filename_in=$tmp_filename_in; -+ $filename_in_save=$filename_in; -+ open(SRC,"<$filename_in") or die "Cannot open $filename_in.\n"; -+ open(DST,">$filename_out") or die "Cannot open $filename_out.\n";; -+ $modified=0; -+ $mode=0; -+ next; -+ } -+ if ($mode==3) {die "error: F expression expected in line $cmd_linenum\n";} -+ if ($cmd_line =~ /^=(.*)/) { -+ $tmp_cmd_name=$1; -+ if (($mode!=2)&&($modified==1)) { -+ while (<SRC>) { -+ print DST $_; -+ } -+ close(SRC); -+ close(DST); -+ if (($cmd_name ne "")) {$rules{"$cmd_name"}=1;}; -+ $filename_cnt++; -+ if ($filename_cnt%2==1) { -+ $filename_in=$filename_tmp1; -+ $filename_out=$filename_tmp2; -+ } -+ else { -+ $filename_in=$filename_tmp2; -+ $filename_out=$filename_tmp1; -+ } -+ } -+ else { -+ close(SRC); -+ close(DST); -+ } -+ $mode=1; -+ $cmd_name=$tmp_cmd_name; -+ if (($cmd_name ne "")) { -+ if ($rules{"$cmd_name"}==1) { -+ $mode=2; -+ } -+ else { -+ $rules{"$cmd_name"}=0; -+ } -+ } -+ open(SRC,"<$filename_in") or die "Cannot open $filename_in.\n"; -+ open(DST,">$filename_out") or die "Cannot open $filename_out.\n"; -+ $modified=0; -+ next; -+ } -+ if ($mode == 0) {die "error: = expression expected in line $cmd_linenum\n";} -+ if ($mode == 2) {next;} -+ if ($cmd_line =~ /^!(.*)/) { -+ print "$1\n"; -+ $modified=1; -+ next; -+ } -+ if ($cmd_line =~ /^\?(.*)/) { -+ $search_str=$1; -+ $found=0; -+ while (<SRC>) { -+ print DST $_; -+ if (index($_,$search_str)>=0) {$found=1; last;} -+ } -+ if ($found==0) { $mode=2; } -+ next; -+ } -+ if ($cmd_line =~ /^\+(.*)/) { -+ print DST "$1\n"; -+ $modified=1; -+ next; -+ } -+ if ($cmd_line =~ /^\-(.*)/) { -+ $search_str=$1; -+ $found=0; -+ while (<SRC>) { -+ if (index($_,$search_str)>=0) {$saved_line=$_; $found=1; $modified=1; last;} -+ print DST $_; -+ } -+ if ($found==0) { $mode=2; } -+ next; -+ } -+ if ($cmd_line =~ /^i(.*)/) { -+ $filename_inc=$1; -+ open(INCSRC,"<$filename_inc") or die "Cannot open $filename_inc.\n"; -+ while (<INCSRC>) { -+ print DST $_; -+ } -+ next; -+ } -+ if ($cmd_line =~ /^I/) { -+ print DST $saved_line; -+ next; -+ } -+} -+file_end(); -+close(CMD); ---- /dev/null -+++ b/fs/jffs2/jffs2_bbc_armlib_comp.c -@@ -0,0 +1,2224 @@ -+/* -+ * JFFS2-BBC: armlib compressor plugin -+ * -+ * $Id: 301-jffs-compression,v 1.1 2005/03/26 10:33:31 wbx Exp $ -+ * -+ * Copyright (C) 2004, Ferenc Havasi & Tamas Gergely -+ * -+ * 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. -+ * -+ */ -+ -+#include "jffs2_bbc_framework.h" -+ -+#ifdef __KERNEL__ -+#include <linux/string.h> -+#else -+#include <string.h> -+#endif -+ -+//ORIGIN: include/DataStructures/TypeDefs.h -+ -+/******************************************************************************* -+* FILE: TypeDefs.h -+* AUTHOR: Tamás Gergely -+* MODIFIED: $Id: 301-jffs-compression,v 1.1 2005/03/26 10:33:31 wbx Exp $ -+*******************************************************************************/ -+ -+#ifndef TYPEDEFS_H -+#define TYPEDEFS_H -+ -+#pragma pack(4) -+ -+#ifndef bool -+#define bool char -+#define true 1 -+#define false 0 -+#endif -+ -+#ifndef u8 -+#define u8 unsigned char -+#endif -+#ifndef u16 -+#define u16 unsigned short -+#endif -+#ifndef u32 -+#define u32 unsigned long -+#endif -+#ifndef s8 -+#define s8 signed char -+#endif -+#ifndef s16 -+#define s16 signed short -+#endif -+#ifndef s32 -+#define s32 signed long -+#endif -+ -+typedef struct -+{ -+ u32 capacity; -+ u32 size; -+ u32 alloc_size; -+ void *ptr; -+} vector; -+ -+#define VECTOR_P_END(vct) ((void*)(((char*)((vct)->ptr)) + (vct)->size)) -+#define VECTOR_S_END(vct) ((void*)(((char*)((vct).ptr)) + (vct).size)) -+ -+static void vector_clear(vector *); -+#ifdef JFFS2_BBC_ARMLIB_MODELGEN -+static void vector_reset(vector *); -+static void vector_clr_ptr(vector *); -+static void vector_add_u8(vector *, u8); -+static void vector_add_u16(vector *, u16); -+static void vector_add_u32(vector *, u32); -+static void vector_add_s8(vector *, s8); -+static void vector_add_s16(vector *, s16); -+static void vector_add_s32(vector *, s32); -+static void vector_add_ptr(vector *, void *); -+static void vector_concat(vector *, vector *); -+#endif -+ -+#endif -+ -+//ORIGIN: include/DataStructures/DataTypes.h -+ -+/******************************************************************************* -+* FILE: DataTypes.h -+* AUTHOR: Tamás Gergely -+* MODIFIED: $Id: 301-jffs-compression,v 1.1 2005/03/26 10:33:31 wbx Exp $ -+*******************************************************************************/ -+ -+#ifndef DATATYPES_H -+#define DATATYPES_H -+ -+//#include "DataStructures/TypeDefs.h" -+ -+typedef u16 THUMB_DataType; -+typedef u32 ARM_DataType; -+typedef u8 TokenType; -+typedef u8 PredictorType; -+typedef u8 *ProbDist; -+ -+typedef vector RawData; -+typedef vector RawBlocks; -+typedef vector TokenStream; -+typedef vector TokenBlocks; -+typedef vector LatType; -+ -+#define THUMB_DATA_LENGTH 16 -+#define ARM_DATA_LENGTH 32 -+#define TOKEN_LENGTH 8 -+#define TOKEN_MAXVALUE 0xff -+#define PREDICTOR_LENGTH 8 -+#define PREDICTOR_MAXVALUE 0xff -+ -+#endif -+ -+//ORIGIN: include/DataStructures/BitVector.h -+ -+/******************************************************************************* -+* FILE: BitVector.h -+* AUTHOR: Tamás Gergely -+* MODIFIED: $Id: 301-jffs-compression,v 1.1 2005/03/26 10:33:31 wbx Exp $ -+*******************************************************************************/ -+ -+#ifndef BITVECTOR_H -+#define BITVECTOR_H -+ -+//#include "DataStructures/TypeDefs.h" -+ -+typedef vector BitBlocks; -+ -+#pragma pack(4) -+ -+typedef struct -+{ -+ u32 freebits; -+ u32 capacity; -+ u32 size; -+ u8 *base; -+ u8 *ptr; -+} BitVector; -+ -+#ifdef JFFS2_BBC_ARMLIB_MODELGEN -+static void bitblocks_clear(BitBlocks *); -+static void bitvector_clear(BitVector *); -+static void bitvector_W_reset(BitVector *); -+static void bitvector_W_add0(BitVector *); -+static void bitvector_W_add1(BitVector *); -+static void bitvector_W_concat_b(BitVector *, BitVector *); -+static void bitvector_W_concat_v(BitVector *, vector *); -+static void bitvector_W_flush(BitVector *); -+static void bitvector_R_reset(BitVector *); -+static u8 bitvector_R_get1(BitVector *); -+static u8 bitvector_R_get8(BitVector *); -+#endif -+ -+#define BITVECTOR_P_END(bv) ((void*)(((bv)->base)+((bv)->size))) -+#define BITVECTOR_S_END(bv) ((void*)( ((bv).base)+ ((bv).size))) -+#define BITVECTOR_SKIP(bv,num) ((bv)->ptr) += (num) -+ -+#endif -+ -+//ORIGIN: include/DataStructures/DecisionTree.h -+ -+/******************************************************************************* -+* FILE: DecisionTree.h -+* AUTHOR: Tamás Gergely -+* MODIFIED: $Id: 301-jffs-compression,v 1.1 2005/03/26 10:33:31 wbx Exp $ -+*******************************************************************************/ -+ -+#ifndef DECISIONTREE_H -+#define DECISIONTREE_H -+ -+//#include "DataStructures/DataTypes.h" -+ -+#pragma pack(4) -+ -+#define TREENODETYPE_NULLNODE 0 -+#define TREENODETYPE_NODE_BINARY_EQ 1 -+#define TREENODETYPE_LEAF_P 2 -+#define TREENODETYPE_LEAF_C 3 -+#define TREENODETYPE_NODE_BINARY_LT 5 -+#define TREENODETYPE_IS_NODE(n) (((n) == TREENODETYPE_NODE_BINARY_EQ) || \ -+ ((n) == TREENODETYPE_NODE_BINARY_LT)) -+#define TREENODETYPE_IS_NODE_BINARY(n) (((n) == TREENODETYPE_NODE_BINARY_EQ) || \ -+ ((n) == TREENODETYPE_NODE_BINARY_LT)) -+ -+#define TREENODETYPE_IS_LEAF(n) (((n) == TREENODETYPE_LEAF_P) || \ -+ ((n) == TREENODETYPE_LEAF_C)) -+ -+ -+#define TREE_SUBTREE_RELATION_LEFT_EQ != -+#define TREE_SUBTREE_RELATION_RIGHT_EQ == -+#define TREE_SUBTREE_RELATION_LEFT_LT < -+#define TREE_SUBTREE_RELATION_RIGHT_LT >= -+ -+#define GET_NODE_PTR_TYPE(n) (((TreeNodeDummy*)(n))->type) -+ -+typedef struct -+{ -+ u8 type; -+} TreeNodeDummy; -+ -+typedef struct -+{ -+ u8 type; // [TREENODETYPE_NODE_BINARY] -+ u8 attribute; -+ PredictorType value; -+ void *left; -+ void *right; -+} TreeNodeBinary; -+ -+typedef struct -+{ -+ u8 type; // [TREENODETYPE_LEAF_P] -+ u16 pairs; -+ PredictorType *probabilities; -+} TreeLeafP; -+ -+typedef struct -+{ -+ u8 type; // [TREENODETYPE_LEAF_C] -+ PredictorType predicted_class; -+} TreeLeafC; -+ -+typedef struct -+{ -+ u32 high; -+ u32 low; -+ u32 max; -+} ProbabilityType; -+ -+ -+typedef struct -+{ -+ void *root; -+ u16 number_of_classes; -+ u16 number_of_predictors; -+ PredictorType *predictor_max_values; -+} DecisionTree; -+ -+#ifdef JFFS2_BBC_ARMLIB_MODELGEN -+static void decisiontree_delete(DecisionTree *); -+static void decisiontree_get_probability_for_token(void *, PredictorType *, TokenType, ProbabilityType *); -+static TokenType decisiontree_get_token_for_range(void *, PredictorType *, u32, u32, ProbabilityType *); -+#endif -+ -+#endif -+ -+//ORIGIN: include/DataStructures/PredictorTable.h -+ -+/******************************************************************************* -+* FILE: PredictorTable.h -+* AUTHOR: Tamás Gergely -+* MODIFIED: $Id: 301-jffs-compression,v 1.1 2005/03/26 10:33:31 wbx Exp $ -+*******************************************************************************/ -+ -+#ifndef PREDICTORTABLE_H -+#define PREDICTORTABLE_H -+ -+//#include "DataStructures/TypeDefs.h" -+//#include "DataStructures/DataTypes.h" -+////#include "DataStructures/Filter.h" -+////#include "DataStructures/Converter.h" -+////#include "DataStructures/Manipulator.h" -+ -+#define NUMBER_OF_PREDICTORS_ARM 17 -+ -+#ifndef __KERNEL__ -+#define NUMBER_OF_PREDICTORS_TXT 2 -+#else -+#undef TXT_TOKENS -+#endif // __KERNEL__ -+ -+#ifdef TXT_TOKENS -+#define NUMBER_OF_PREDICTORS NUMBER_OF_PREDICTORS_TXT -+#define predictortable_reset predictortable_resetTXT -+#define predictortable_update predictortable_updateTXT -+#define predictortable_minvalue predictortable_minvalueTXT -+#define predictortable_maxvalue predictortable_maxvalueTXT -+#else -+#define NUMBER_OF_PREDICTORS NUMBER_OF_PREDICTORS_ARM -+#define predictortable_reset predictortable_resetARM -+#define predictortable_update predictortable_updateARM -+#define predictortable_minvalue predictortable_minvalueARM -+#define predictortable_maxvalue predictortable_maxvalueARM -+#endif -+ -+ -+#pragma pack(4) -+ -+typedef struct -+{ -+ PredictorType *predictors; -+} PredictorTable; -+ -+#ifdef JFFS2_BBC_ARMLIB_MODELGEN -+static void predictortable_clear(PredictorTable *); -+static void predictortable_free(PredictorTable *); -+static void predictortable_resetARM(PredictorTable *); -+static void predictortable_updateARM(PredictorTable *, TokenType); -+static PredictorType predictortable_minvalueARM(PredictorTable *, u32); -+static PredictorType predictortable_maxvalueARM(PredictorTable *, u32); -+#endif -+ -+#ifndef __KERNEL__ -+/* -+static void predictortable_resetTXT(PredictorTable *); -+static void predictortable_updateTXT(PredictorTable *, TokenType); -+static PredictorType predictortable_minvalueTXT(PredictorTable *, u32); -+static PredictorType predictortable_maxvalueTXT(PredictorTable *, u32); -+*/ -+#endif // __KERNEL__ -+ -+#endif -+ -+//ORIGIN: include/DataStructures/ipack_model.h -+ -+/******************************************************************************* -+* FILE: ipack_model.h -+* AUTHOR: Tamás Gergely -+* MODIFIED: $Id: 301-jffs-compression,v 1.1 2005/03/26 10:33:31 wbx Exp $ -+*******************************************************************************/ -+ -+#ifndef IPACK_MODEL_H -+#define IPACK_MODEL_H -+ -+//#include "DataStructures/DataTypes.h" -+//#include "DataStructures/DecisionTree.h" -+//#include "DataStructures/PredictorTable.h" -+ -+#define PROBABILITY_SHIFT 12 -+#define PROBABILITY_MAX 0x00001000l -+ -+#define NUMBER_OF_TOKENS_ARM 16 -+#define NUMBER_OF_TOKENS_PER_INSTRUCTION_ARM 8 -+ -+#ifndef __KERNEL__ -+#define NUMBER_OF_TOKENS_TXT 256 -+#define NUMBER_OF_TOKENS_PER_INSTRUCTION_TXT 4 -+#else -+#undef TXT_TOKENS -+#endif // __KERNEL__ -+ -+#ifdef TXT_TOKENS -+#define NUMBER_OF_TOKENS NUMBER_OF_TOKENS_TXT -+#define NUMBER_OF_TOKENS_PER_INSTRUCTION NUMBER_OF_TOKENS_PER_INSTRUCTION_TXT -+#else -+#define NUMBER_OF_TOKENS NUMBER_OF_TOKENS_ARM -+#define NUMBER_OF_TOKENS_PER_INSTRUCTION NUMBER_OF_TOKENS_PER_INSTRUCTION_ARM -+#endif -+ -+#pragma pack(4) -+ -+/* -+ Data structure of an internal node of the tree -+*/ -+typedef struct -+{ -+ PredictorType *attribute_ptr; -+ u32 value; // PredictorType -+ void *right_child_ptr; -+} ipack_treenodeBin; -+/* -+ Data structure of a leaf with probabilities -+*/ -+typedef struct -+{ -+ u16 probabilities[0]; // PredictorType[0] -+} ipack_treeleafP; -+/* -+ Data structure of a leaf with class prediction -+*/ -+typedef struct -+{ -+ PredictorType predicted_class; // PredictorType -+} ipack_treeleafC; -+/* -+ Possible data structures of a tree node -+*/ -+typedef union -+{ -+ ipack_treenodeBin nodeBin; -+ ipack_treeleafP leafP; -+ ipack_treeleafC leafC; -+} ipack_node_data; -+/* -+ Tree node -+*/ -+typedef struct -+{ -+ u32 type; // u8 -+ ipack_node_data data; // ipack_node_data -+} ipack_nodetype; -+/* -+ Nullnode -+*/ -+typedef struct -+{ -+ u32 type; -+ u16 probabilities[NUMBER_OF_TOKENS]; -+} ipack_nullnode; -+/* -+ Model for ipack project -+*/ -+typedef struct -+{ -+ char ID[4]; // char[4] -+ char block_sign[4]; // only the first 2 are used! -+ void *tree_root_ptr; // void* -+ void *tree_code; // generated ARM code -+ PredictorType *predictors_ptr; // PredictorType* -+ ipack_nullnode nullnode; -+} ipack_model_type; -+ -+typedef struct -+{ -+ u32 high; -+ u32 low; -+} ipack_probability_type; -+ -+ -+static void ipack_model_get_probability_for_token(ipack_nodetype *, TokenType, ipack_probability_type *); -+static TokenType ipack_model_get_token_for_range(ipack_nodetype *, u32, u32, ipack_probability_type *); -+/*void ipack_model_predictortable_reset (PredictorType*); -+void ipack_model_predictortable_update (PredictorType*, TokenType);*/ -+ -+#ifndef __KERNEL__ -+/*static void ipack_model_printinfo(ipack_model_type *); -+static void ipack_dumpmodel(void *);*/ -+#endif -+ -+#endif -+ -+//ORIGIN: include/Builders/PredictorGenerator.h -+ -+/******************************************************************************* -+* FILE: PredictorGenerator.h -+* AUTHOR: Tamás Gergely -+* MODIFIED: $Id: 301-jffs-compression,v 1.1 2005/03/26 10:33:31 wbx Exp $ -+*******************************************************************************/ -+ -+#ifndef PREDICTORGENERATOR_H -+#define PREDICTORGENERATOR_H -+ -+//#include "DataStructures.h" -+ -+#ifdef JFFS2_BBC_ARMLIB_MODELGEN -+static PredictorTable *predictorgenerator_generate(void); -+#endif -+ -+#endif -+ -+//ORIGIN: include/Builders/Coder.h -+ -+/******************************************************************************* -+* FILE: Coder.h -+* AUTHOR: Tamás Gergely -+* MODIFIED: $Id: 301-jffs-compression,v 1.1 2005/03/26 10:33:31 wbx Exp $ -+*******************************************************************************/ -+ -+#ifndef CODER_H -+#define CODER_H -+ -+#define CODER_VALUEBITS 16 -+#define CODER_VALUEMAX 0x00010000l -+#define CODER_VALUE3RD 0x0000c000l -+#define CODER_VALUEHLF 0x00008000l -+#define CODER_VALUE1ST 0x00004000l -+ -+#endif -+ -+//ORIGIN: DataStructures/src/TypeDefs.c -+ -+/******************************************************************************* -+* FILE: TypeDefs.c -+* AUTHOR: Tamás Gergely -+* MODIFIED: $Id: 301-jffs-compression,v 1.1 2005/03/26 10:33:31 wbx Exp $ -+*******************************************************************************/ -+ -+//#include "ipack_common.h" -+//#include "DataStructures/TypeDefs.h" -+#ifndef __KERNEL__ -+#include <memory.h> -+#endif -+ -+#define VECTOR_ALLOC_SIZE 0x00001000 -+ -+static void vector_clear(vector * vct) -+{ -+ if (vct->ptr) -+ jffs2_bbc_free(vct->ptr); -+ vct->capacity = 0; -+ vct->size = 0; -+ vct->ptr = 0; -+} -+ -+#ifdef JFFS2_BBC_ARMLIB_MODELGEN -+static void vector_extend(vector * vct) -+{ -+ void *tmp; -+ vct->capacity += vct->alloc_size; -+ tmp = jffs2_bbc_malloc(vct->capacity); -+ if (vct->ptr) { -+ memcpy(tmp, vct->ptr, vct->size); -+ jffs2_bbc_free(vct->ptr); -+ } -+ vct->ptr = tmp; -+} -+ -+static void vector_reset(vector * vct) -+{ -+ vct->capacity = 0; -+ vct->size = 0; -+ vct->alloc_size = VECTOR_ALLOC_SIZE; -+ vct->ptr = 0; -+} -+ -+static void vector_clr_ptr(vector * vct) -+{ -+ void **it; -+ void *end_it; -+ for (it = vct->ptr, end_it = (((char *) (vct->ptr)) + vct->size); it != end_it; it++) { -+ vector_clear(*it); -+ jffs2_bbc_free(*it); -+ } -+ if (vct->ptr) -+ jffs2_bbc_free(vct->ptr); -+ vct->capacity = 0; -+ vct->size = 0; -+ vct->ptr = 0; -+} -+ -+static void vector_add_u8(vector * vct, u8 val) -+{ -+ if ((vct->size) + sizeof(u8) > (vct->capacity)) { -+ vector_extend(vct); -+ } -+ *(u8 *) ((char *) (vct->ptr) + (vct->size)) = val; -+ vct->size += sizeof(u8); -+}; -+ -+static void vector_add_u16(vector * vct, u16 val) -+{ -+ if ((vct->size) + sizeof(u16) > (vct->capacity)) { -+ vector_extend(vct); -+ } -+ *(u16 *) ((char *) (vct->ptr) + (vct->size)) = val; -+ vct->size += sizeof(u16); -+}; -+ -+static void vector_add_u32(vector * vct, u32 val) -+{ -+ if ((vct->size) + sizeof(u32) > (vct->capacity)) { -+ vector_extend(vct); -+ } -+ *(u32 *) ((char *) (vct->ptr) + (vct->size)) = val; -+ vct->size += sizeof(u32); -+}; -+ -+static void vector_add_s8(vector * vct, s8 val) -+{ -+ if ((vct->size) + sizeof(s8) > (vct->capacity)) { -+ vector_extend(vct); -+ } -+ *(s8 *) ((char *) (vct->ptr) + (vct->size)) = val; -+ vct->size += sizeof(s8); -+}; -+ -+static void vector_add_s16(vector * vct, s16 val) -+{ -+ if ((vct->size) + sizeof(s16) > (vct->capacity)) { -+ vector_extend(vct); -+ } -+ *(s16 *) ((char *) (vct->ptr) + (vct->size)) = val; -+ vct->size += sizeof(s16); -+}; -+ -+static void vector_add_s32(vector * vct, s32 val) -+{ -+ if ((vct->size) + sizeof(s32) > (vct->capacity)) { -+ vector_extend(vct); -+ } -+ *(s32 *) ((char *) (vct->ptr) + (vct->size)) = val; -+ vct->size += sizeof(s32); -+}; -+ -+static void vector_add_ptr(vector * vct, void *ptr) -+{ -+ if ((vct->size) + sizeof(void *) > (vct->capacity)) { -+ vector_extend(vct); -+ } -+ *(void **) ((char *) (vct->ptr) + (vct->size)) = ptr; -+ vct->size += sizeof(void *); -+} -+ -+static void vector_concat(vector * lhs, vector * rhs) -+{ -+ void *tmp; -+ if (!(rhs->size)) { -+ return; -+ } -+ tmp = lhs->ptr; -+ lhs->capacity = (lhs->size) + (rhs->size); -+ lhs->ptr = jffs2_bbc_malloc(lhs->capacity); -+ if (tmp) { -+ memcpy(lhs->ptr, tmp, lhs->size); -+ jffs2_bbc_free(tmp); -+ } -+ memcpy((((u8 *) lhs->ptr) + lhs->size), rhs->ptr, rhs->size); -+ lhs->size += rhs->size; -+} -+ -+#endif -+ -+//ORIGIN: DataStructures/src/BitVector.c -+ -+/******************************************************************************* -+* FILE: BitVector.c -+* AUTHOR: Tamás Gergely -+* MODIFIED: $Id: 301-jffs-compression,v 1.1 2005/03/26 10:33:31 wbx Exp $ -+*******************************************************************************/ -+ -+//#include "ipack_common.h" -+//#include "DataStructures/BitVector.h" -+#ifndef __KERNEL__ -+#include <memory.h> -+#endif -+ -+#define VECTOR_ALLOC_SIZE 0x00001000 -+ -+#ifdef JFFS2_BBC_ARMLIB_MODELGEN -+ -+static void bitblocks_clear(BitBlocks * this) -+{ -+ BitVector **it; -+ void *end_it; -+ for (it = this->ptr, end_it = VECTOR_P_END(this); it != end_it; it++) { -+ bitvector_clear(*it); -+ jffs2_bbc_free(*it); -+ } -+ jffs2_bbc_free(this->ptr); -+ this->ptr = 0; -+} -+ -+static void bitvector_clear(BitVector * this) -+{ -+ if (this->base) { -+ jffs2_bbc_free(this->base); -+ } -+ this->freebits = 0; -+ this->capacity = 0; -+ this->size = 0; -+ this->base = 0; -+ this->ptr = 0; -+} -+ -+static void bitvector_W_reset(BitVector * this) -+{ -+ this->freebits = 0; -+ this->capacity = 0; -+ this->size = 0; -+ this->base = 0; -+ this->ptr = 0; -+} -+ -+static void bitvector_W_add0(BitVector * this) -+{ -+ if (!(this->freebits)) { -+ if (this->size == this->capacity) { -+ void *tmp = this->base; -+ this->capacity += VECTOR_ALLOC_SIZE; -+ this->base = jffs2_bbc_malloc(this->capacity); -+ this->ptr = ((u8 *) (this->base)) + this->size; -+ memcpy(this->base, tmp, this->size); -+ jffs2_bbc_free(tmp); -+ } -+ else { -+ this->ptr++; -+ } -+ this->size++; -+ this->freebits = 7; -+ *(this->ptr) = 0x00; -+ } -+ else { -+ this->freebits--; -+ (*(this->ptr)) <<= 1; -+ } -+} -+ -+static void bitvector_W_add1(BitVector * this) -+{ -+ if (!(this->freebits)) { -+ if (this->size == this->capacity) { -+ void *tmp = this->base; -+ this->capacity += VECTOR_ALLOC_SIZE; -+ this->base = jffs2_bbc_malloc(this->capacity); -+ this->ptr = ((u8 *) (this->base)) + this->size; -+ memcpy(this->base, tmp, this->size); -+ jffs2_bbc_free(tmp); -+ } -+ else { -+ this->ptr++; -+ } -+ this->size++; -+ this->freebits = 7; -+ *(this->ptr) = 0x01; -+ } -+ else { -+ this->freebits--; -+ (*(this->ptr)) <<= 1; -+ (*(this->ptr)) |= 0x01; -+ } -+} -+ -+static void bitvector_W_concat_b(BitVector * lhs, BitVector * rhs) -+{ -+ void *tmp; -+ if (!(rhs->size)) { -+ return; -+ } -+ tmp = lhs->base; -+ lhs->capacity = ((((lhs->size) + (rhs->size) - 1) / VECTOR_ALLOC_SIZE) + 1) * VECTOR_ALLOC_SIZE; -+ lhs->base = jffs2_bbc_malloc(lhs->capacity); -+ if (tmp) { -+ memcpy(lhs->base, tmp, lhs->size); -+ jffs2_bbc_free(tmp); -+ } -+ memcpy((((u8 *) (lhs->base)) + lhs->size), rhs->base, rhs->size); -+ lhs->freebits = 0; -+ lhs->size += rhs->size; -+ lhs->ptr = ((u8 *) (lhs->base)) + lhs->size; -+} -+ -+static void bitvector_W_concat_v(BitVector * lhs, vector * rhs) -+{ -+ void *tmp; -+ if (!(rhs->size)) { -+ return; -+ } -+ tmp = lhs->base; -+ lhs->capacity = ((((lhs->size) + (rhs->size) - 1) / VECTOR_ALLOC_SIZE) + 1) * VECTOR_ALLOC_SIZE; -+ lhs->base = jffs2_bbc_malloc(lhs->capacity); -+ if (tmp) { -+ memcpy(lhs->base, tmp, lhs->size); -+ jffs2_bbc_free(tmp); -+ } -+ memcpy((((u8 *) (lhs->base)) + lhs->size), rhs->ptr, rhs->size); -+ lhs->freebits = 0; -+ lhs->size += rhs->size; -+ lhs->ptr = ((u8 *) (lhs->base)) + lhs->size; -+} -+ -+static void bitvector_W_flush(BitVector * this) -+{ -+ (*(this->ptr)) <<= this->freebits; -+ this->freebits = 0; -+} -+ -+static void bitvector_R_reset(BitVector * this) -+{ -+ this->freebits = 7; -+ this->ptr = this->base; -+} -+ -+static u8 bitvector_R_get1(BitVector * this) -+{ -+ u8 tmp = ((*(this->ptr)) >> this->freebits) & 0x01; -+ if (!(this->freebits)) { -+ this->freebits = 7; -+ this->ptr++; -+ } -+ else { -+ this->freebits--; -+ } -+ return tmp; -+} -+ -+static u8 bitvector_R_get8(BitVector * this) -+{ -+ u8 tmp = (*(this->ptr)); -+ this->ptr++; -+ return tmp; -+} -+ -+#endif -+ -+//ORIGIN: DataStructures/src/DecisionTree.c -+ -+/******************************************************************************* -+* FILE: DecisionTree.c -+* AUTHOR: Tamás Gergely -+* MODIFIED: $Id: 301-jffs-compression,v 1.1 2005/03/26 10:33:31 wbx Exp $ -+*******************************************************************************/ -+ -+//#include "ipack_common.h" -+//#include "DataStructures/DecisionTree.h" -+ -+static void decisiontree_delete_node(void *root) -+{ -+ u8 tmp = GET_NODE_PTR_TYPE(root); -+ if (TREENODETYPE_IS_NODE_BINARY(tmp)) { -+ decisiontree_delete_node(((TreeNodeBinary *) root)->left); -+ decisiontree_delete_node(((TreeNodeBinary *) root)->right); -+ } -+ else if ((tmp) == TREENODETYPE_LEAF_P) { -+ if (((TreeLeafP *) root)->probabilities) { -+ jffs2_bbc_free(((TreeLeafP *) root)->probabilities); -+ } -+ } -+ else if ((tmp) == TREENODETYPE_LEAF_C) { -+ } -+ jffs2_bbc_free(root); -+} -+ -+#ifdef JFFS2_BBC_ARMLIB_MODELGEN -+ -+static void decisiontree_delete(DecisionTree * dt) -+{ -+ decisiontree_delete_node(dt->root); -+ jffs2_bbc_free(dt->predictor_max_values); -+} -+ -+static void decisiontree_get_probability_for_token(void *root, PredictorType * preds, TokenType token, ProbabilityType * prob) -+{ -+ void *tmp = root; -+ while (TREENODETYPE_IS_NODE(((TreeNodeBinary *) tmp)->type)) { -+ if (((TreeNodeBinary *) tmp)->type == TREENODETYPE_NODE_BINARY_EQ) { -+ if (preds[((TreeNodeBinary *) tmp)->attribute] TREE_SUBTREE_RELATION_LEFT_EQ((TreeNodeBinary *) tmp)->value) { -+ tmp = ((TreeNodeBinary *) tmp)->left; -+ } -+ else { -+ tmp = ((TreeNodeBinary *) tmp)->right; -+ } -+ } -+ else if (((TreeNodeBinary *) tmp)->type == TREENODETYPE_NODE_BINARY_LT) { -+ if (preds[((TreeNodeBinary *) tmp)->attribute] TREE_SUBTREE_RELATION_LEFT_LT((TreeNodeBinary *) tmp)->value) { -+ tmp = ((TreeNodeBinary *) tmp)->left; -+ } -+ else { -+ tmp = ((TreeNodeBinary *) tmp)->right; -+ } -+ } -+ } -+ prob->high = 0; -+ prob->low = 0; -+ prob->max = 0; -+ if (((TreeNodeBinary *) tmp)->type == TREENODETYPE_LEAF_P) { -+ u32 i; -+ u32 lngth = ((TreeLeafP *) tmp)->pairs << 1; -+ for (i = 0; i < lngth;) { -+ TokenType at = ((TreeLeafP *) tmp)->probabilities[i++]; -+ TokenType av = ((TreeLeafP *) tmp)->probabilities[i++]; -+ if (token > at) -+ prob->low += av; -+ if (token >= at) -+ prob->high += av; -+ prob->max += av; -+ } -+ } -+ else if (((TreeNodeBinary *) tmp)->type == TREENODETYPE_LEAF_C) { -+ if (((TreeLeafC *) tmp)->predicted_class == token) { -+ prob->high = TOKEN_MAXVALUE; -+ prob->max = TOKEN_MAXVALUE; -+ } -+ } -+} -+ -+static TokenType decisiontree_get_token_for_range(void *root, PredictorType * preds, u32 value, u32 range, ProbabilityType * prob) -+{ -+ void *tmp = root; -+ TokenType token = 0; -+ while (TREENODETYPE_IS_NODE(((TreeNodeBinary *) tmp)->type)) { -+ if (((TreeNodeBinary *) tmp)->type == TREENODETYPE_NODE_BINARY_EQ) { -+ if (preds[((TreeNodeBinary *) tmp)->attribute] TREE_SUBTREE_RELATION_LEFT_EQ((TreeNodeBinary *) tmp)->value) { -+ tmp = ((TreeNodeBinary *) tmp)->left; -+ } -+ else { -+ tmp = ((TreeNodeBinary *) tmp)->right; -+ } -+ } -+ else if (((TreeNodeBinary *) tmp)->type == TREENODETYPE_NODE_BINARY_LT) { -+ if (preds[((TreeNodeBinary *) tmp)->attribute] TREE_SUBTREE_RELATION_LEFT_LT((TreeNodeBinary *) tmp)->value) { -+ tmp = ((TreeNodeBinary *) tmp)->left; -+ } -+ else { -+ tmp = ((TreeNodeBinary *) tmp)->right; -+ } -+ } -+ } -+ prob->high = 0; -+ prob->low = 0; -+ prob->max = 0; -+ if (((TreeNodeBinary *) tmp)->type == TREENODETYPE_LEAF_P) { -+ u32 i; -+ u32 norm; -+ TokenType at = 0; -+ TokenType av; -+ u32 lngth = ((TreeLeafP *) tmp)->pairs << 1; -+ for (i = 0; i < lngth;) { -+ i++; -+ prob->max += ((TreeLeafP *) tmp)->probabilities[i++]; -+ } -+ norm = (value * prob->max - 1) / range; -+ for (i = 0; prob->high <= norm;) { -+ at = ((TreeLeafP *) tmp)->probabilities[i++]; -+ av = ((TreeLeafP *) tmp)->probabilities[i++]; -+ prob->high += av; -+ if (prob->high <= norm) -+ prob->low += av; -+ } -+ token = at; -+ } -+ else if (((TreeNodeBinary *) tmp)->type == TREENODETYPE_LEAF_C) { -+ token = ((TreeLeafC *) tmp)->predicted_class; -+ prob->high = TOKEN_MAXVALUE; -+ prob->max = TOKEN_MAXVALUE; -+ } -+ return token; -+} -+#endif -+ -+//ORIGIN: DataStructures/src/PredictorTable.c -+ -+/******************************************************************************* -+* FILE: PredictorTable.c -+* AUTHOR: Tamás Gergely -+* MODIFIED: $Id: 301-jffs-compression,v 1.1 2005/03/26 10:33:31 wbx Exp $ -+*******************************************************************************/ -+ -+//#include "ipack_common.h" -+//#include "DataStructures/PredictorTable.h" -+ -+#ifdef JFFS2_BBC_ARMLIB_MODELGEN -+ -+static void predictortable_clear(PredictorTable * table) -+{ -+ table->predictors = 0; -+} -+ -+static void predictortable_free(PredictorTable * table) -+{ -+ if (table->predictors) { -+ jffs2_bbc_free(table->predictors); -+ table->predictors = 0; -+ } -+} -+ -+static void predictortable_resetARM(PredictorTable * table) -+{ -+ register PredictorType *ptr = table->predictors; -+ register PredictorType *end = ptr + NUMBER_OF_PREDICTORS_ARM; -+ while (ptr < end) { -+ *(ptr++) = 0; -+ } -+} -+ -+static void predictortable_updateARM(PredictorTable * table, TokenType token) -+{ -+ register PredictorType *ptr = table->predictors; -+ register u32 ndx = ptr[0] + 1; -+ ptr[ndx + 8] = ptr[ndx]; -+ ptr[ndx] = token; -+ if (ndx == 8) { -+ ptr[0] = 0; -+ } -+ else { -+ ++ptr[0]; -+ } -+} -+ -+static PredictorType predictortable_minvalueARM(PredictorTable * table, u32 index) -+{ -+ return 0; -+} -+ -+static PredictorType predictortable_maxvalueARM(PredictorTable * table, u32 index) -+{ -+ if (index == 0) { -+ return 7; -+ } -+ else { -+ return 15; -+ } -+} -+ -+#endif -+ -+#ifndef __KERNEL__ -+ -+/*static void predictortable_resetTXT(PredictorTable * table) -+{ -+ register PredictorType *ptr = table->predictors; -+ register PredictorType *end = ptr + NUMBER_OF_PREDICTORS_TXT; -+ while (ptr < end) { -+ *(ptr++) = 0; -+ } -+} -+ -+static void predictortable_updateTXT(PredictorTable * table, TokenType token) -+{ //TODO: modify -+ register PredictorType *ptr = table->predictors; -+// register u32 ndx; -+ ptr[0] = token; -+ if ((('a' <= token) && (token <= 'z')) || (('A' <= token) && (token <= 'Z'))) { -+ ++(ptr[1]); -+ } -+ else { -+ ptr[1] = 0; -+ } -+} -+ -+static PredictorType predictortable_minvalueTXT(PredictorTable * table, u32 index) -+{ -+ return 0; -+} -+ -+static PredictorType predictortable_maxvalueTXT(PredictorTable * table, u32 index) -+{ //TODO: modify -+ return 254; -+}*/ -+ -+#endif // __KERNEL__ -+ -+//ORIGIN: DataStructures/src/ipack_model.c -+ -+/******************************************************************************* -+* FILE: ipack_model.c -+* AUTHOR: Tamás Gergely -+* MODIFIED: $Id: 301-jffs-compression,v 1.1 2005/03/26 10:33:31 wbx Exp $ -+*******************************************************************************/ -+ -+//#include "DataStructures/ipack_model.h" -+//#include "measuredef.h" -+//#include "ipack_common.h" -+ -+#ifdef __MEASURE_TIME_MODEL_GETPROB -+#define __MT_P_MAX 256 -+#define __MT_P_DIV 128 -+#define __MT_P_MIN 0 -+#endif -+ -+static void ipack_model_get_probability_for_token(ipack_nodetype * tmp, TokenType token, ipack_probability_type * prob) -+{ -+// register ipack_nodetype* tmp = model->tree_root_ptr; -+// register ipack_nodetype* tmp = root; -+ while (TREENODETYPE_IS_NODE(tmp->type)) { -+ if (tmp->type == TREENODETYPE_NODE_BINARY_EQ) { -+ if (*(tmp->data.nodeBin.attribute_ptr) TREE_SUBTREE_RELATION_LEFT_EQ tmp->data.nodeBin.value) { -+ ((char *) tmp) += sizeof(tmp->type) + sizeof(ipack_treenodeBin); -+ } -+ else { -+ tmp = tmp->data.nodeBin.right_child_ptr; -+ } -+ } -+ else if (tmp->type == TREENODETYPE_NODE_BINARY_LT) { -+ if (*(tmp->data.nodeBin.attribute_ptr) TREE_SUBTREE_RELATION_LEFT_LT tmp->data.nodeBin.value) { -+ ((char *) tmp) += sizeof(tmp->type) + sizeof(ipack_treenodeBin); -+ } -+ else { -+ tmp = tmp->data.nodeBin.right_child_ptr; -+ } -+ } -+ } -+ prob->high = 0; -+ prob->low = 0; -+// prob->max = 0; -+ if (tmp->type == TREENODETYPE_LEAF_P) { -+ if (token) { -+ prob->low = tmp->data.leafP.probabilities[token - 1]; -+ } -+ prob->high = tmp->data.leafP.probabilities[token]; -+// prob->max = tmp->data.leafP.probabilities[15]; -+ } -+ else if (tmp->type == TREENODETYPE_LEAF_C) { -+ if (tmp->data.leafC.predicted_class == token) { -+ prob->high = TOKEN_MAXVALUE; -+// prob->max = TOKEN_MAXVALUE; -+ } -+ } -+} -+ -+#ifndef IPACK_ARM_ASM -+ -+//return ipack_model_get_token_for_range2(tmp,value,range,prob); -+ -+static TokenType ipack_model_get_token_for_range(ipack_nodetype * tmp, u32 value, u32 range, ipack_probability_type * prob) -+{ -+// register ipack_nodetype* tmp = model->tree_root_ptr; -+// register ipack_nodetype* tmp = root; -+ register TokenType token = 0; -+ while (TREENODETYPE_IS_NODE(tmp->type)) { -+ if (tmp->type == TREENODETYPE_NODE_BINARY_EQ) { -+ if (*(tmp->data.nodeBin.attribute_ptr) TREE_SUBTREE_RELATION_LEFT_EQ tmp->data.nodeBin.value) { -+ ((char *) tmp) += sizeof(tmp->type) + sizeof(ipack_treenodeBin); -+ } -+ else { -+ tmp = tmp->data.nodeBin.right_child_ptr; -+ } -+ } -+ else if (tmp->type == TREENODETYPE_NODE_BINARY_LT) { -+ if (*(tmp->data.nodeBin.attribute_ptr) TREE_SUBTREE_RELATION_LEFT_LT tmp->data.nodeBin.value) { -+ ((char *) tmp) += sizeof(tmp->type) + sizeof(ipack_treenodeBin); -+ } -+ else { -+ tmp = tmp->data.nodeBin.right_child_ptr; -+ } -+ } -+ } -+ prob->high = 0; -+ prob->low = 0; -+// prob->max = 0; -+ if (tmp->type == TREENODETYPE_LEAF_P) { -+ u32 i; -+ u32 norm; -+// prob->max = tmp->data.leafP.probabilities[15]; -+/* norm = (value * prob->max -1)/range; -+ for(i = 0; i < 15; ++i) { -+ if(tmp->data.leafP.probabilities[i] > norm) { -+ break; -+ } -+ }*/ -+ norm = ((value << PROBABILITY_SHIFT) - 1); -+ for (i = 0; i < NUMBER_OF_TOKENS; ++i) { -+ if (range * tmp->data.leafP.probabilities[i] > norm) { -+ break; -+ } -+ } -+ token = (TokenType) i; -+ prob->high = tmp->data.leafP.probabilities[i]; -+ if (token) { -+ prob->low = tmp->data.leafP.probabilities[token - 1]; -+ } -+ } -+ else if (tmp->type == TREENODETYPE_LEAF_C) { -+ token = tmp->data.leafC.predicted_class; -+ prob->high = PROBABILITY_MAX; -+// prob->max = PROBABILITY_MAX; -+ } -+ return token; -+} -+#endif -+/* -+void ipack_model_predictortable_reset(PredictorType* ptr) -+{ -+// register PredictorType* ptr = model->predictors_ptr; -+// register PredictorType* ptr = preds; -+ register PredictorType* end = ptr + NUMBER_OF_PREDICTORS; -+ while(ptr < end) { -+ *(ptr++) = 0; -+ } -+} -+ -+void ipack_model_predictortable_update(PredictorType* ptr, TokenType token) -+{ -+// register PredictorType* ptr = model->predictors_ptr; -+// register PredictorType* ptr = preds; -+ register u32 ndx = ptr[0] + 1; -+ ptr[ndx + 8] = ptr[ndx]; -+ ptr[ndx] = token; -+ if(ndx == 8) { -+ ptr[0] = 0; -+ } else { -+ ++ ptr[0]; -+ } -+}*/ -+/****************************************************************************/ -+ -+#ifndef __KERNEL__ -+static void ipack_model_countpreds(void *ptr, ipack_nodetype * node, double *table, double val) -+{ -+ if ((node->type == TREENODETYPE_NODE_BINARY_EQ) || (node->type == TREENODETYPE_NODE_BINARY_LT)) { -+ table[(u32) (node->data.nodeBin.attribute_ptr) - (u32) (ptr)] += val; -+ ipack_model_countpreds(ptr, (void *) (((u8 *) (node)) + sizeof(node->type) + sizeof(ipack_treenodeBin)), table, val / 2); -+ ipack_model_countpreds(ptr, node->data.nodeBin.right_child_ptr, table, val / 2); -+ } -+ else { -+ } -+} -+ -+/*static void ipack_model_printinfo(ipack_model_type * model) -+{ -+ double *prcnt = jffs2_bbc_malloc(sizeof(double) * NUMBER_OF_PREDICTORS); -+ u32 i; -+ for (i = 0; i < NUMBER_OF_PREDICTORS; i++) { -+ prcnt[i] = 0.0; -+ } -+ ipack_model_countpreds(model->predictors_ptr, model->tree_root_ptr, prcnt, 100); -+ for (i = 0; i < NUMBER_OF_PREDICTORS; i++) { -+ jffs2_bbc_print3(" p[%3d] = %10.6lf\n", (int) i, prcnt[i]); -+ } -+ jffs2_bbc_free(prcnt); -+}*/ -+ -+static void ipack_dumpnode(unsigned char **ptr, FILE * file, char *prefs) -+{ -+ switch (*((*ptr)++)) { -+ u32 i; -+ u32 j; -+ u32 x; -+ u32 y; -+ case TREENODETYPE_NODE_BINARY_EQ: -+ x = *((*ptr)++); -+ y = *((*ptr)++); -+ fprintf(file, "%s+->\tBinary node: P[%u] equals %u\n", prefs, (unsigned int)x, (unsigned int)y); -+ for (j = 0; j < 4096 && prefs[j]; ++j); -+ prefs[j] = '\t'; -+ prefs[++j] = '|'; -+ ipack_dumpnode(ptr, file, prefs); -+ prefs[j--] = 0; -+ ipack_dumpnode(ptr, file, prefs); -+ prefs[j] = 0; -+ break; -+ case TREENODETYPE_NODE_BINARY_LT: -+ x = *((*ptr)++); -+ y = *((*ptr)++); -+ fprintf(file, "%s+->\tBinary node: P[%u] greater than %u\n", prefs, (unsigned int)x, (unsigned int)y); -+ for (j = 0; j < 4096 && prefs[j]; ++j); -+ prefs[j] = '\t'; -+ prefs[++j] = '|'; -+ ipack_dumpnode(ptr, file, prefs); -+ prefs[j--] = 0; -+ ipack_dumpnode(ptr, file, prefs); -+ prefs[j] = 0; -+ break; -+ case TREENODETYPE_LEAF_P: -+ x = *((*ptr)++); -+ fprintf(file, "%s+->\tLeaf: %u pairs\n", prefs, (unsigned int)x); -+ (*ptr) += (x << 1); -+ break; -+ case TREENODETYPE_LEAF_C: -+ x = *((*ptr)++); -+ fprintf(file, "%s+->\tLeaf: class %u\n", prefs, (unsigned int)x); -+ break; -+ default: -+ fprintf(file, "%s+->\tLeaf: nullnode\n", prefs); -+ } -+} -+ -+/*static void ipack_dumpmodel(void *model) -+{ -+ unsigned char *tmp_ptr = model; -+ FILE *file; -+ char C[4096]; -+ if ((file = fopen("DUMPED_MODEL", "wa"))) { -+ int i; -+ for (i = 0; i < 4096; C[i++] = 0); -+ tmp_ptr += 8; -+ tmp_ptr += sizeof(u32); -+ ipack_dumpnode(&tmp_ptr, file, C); -+ fclose(file); -+ } -+}*/ -+ -+#endif -+ -+//ORIGIN: Builders/src/PredictorGenerator.c -+ -+/******************************************************************************* -+* FILE: PredictorGenerator.c -+* AUTHOR: Tamás Gergely -+* MODIFIED: $Id: 301-jffs-compression,v 1.1 2005/03/26 10:33:31 wbx Exp $ -+*******************************************************************************/ -+ -+//#include "ipack_common.h" -+//#include "Builders/PredictorGenerator.h" -+ -+#ifdef JFFS2_BBC_ARMLIB_MODELGEN -+static PredictorTable *predictorgenerator_generate( /*PredictorGeneratorSettings* settings */ ) -+{ -+ PredictorTable *ptr = jffs2_bbc_malloc(sizeof(PredictorTable)); -+ predictortable_clear(ptr); -+ ptr->predictors = jffs2_bbc_malloc(NUMBER_OF_PREDICTORS * sizeof(PredictorType)); -+ return ptr; -+} -+#endif -+ -+//ORIGIN: Builders/src/ipack_armlib_compressor.c -+ -+/******************************************************************************* -+* FILE: ipack_armlim_compressor.c -+* AUTHOR: Tamás Gergely -+* MODIFIED: $Id: 301-jffs-compression,v 1.1 2005/03/26 10:33:31 wbx Exp $ -+*******************************************************************************/ -+ -+//#include "ipack_common.h" -+//#include "DataStructures.h" -+//#include "Builders/PredictorGenerator.h" -+//#include "Builders/Tokenizer.h" -+//#include "Builders/Coder.h" -+ -+#define EC_NO_ERROR 0 -+#define EC_NOT_IPMF_FILE -1 -+#define EC_NOT_IPMF_MODEL -2 -+#define EC_NOT_HG_BLOCK -3 -+#define EC_WRONG_INPUT_LENGTH -501 -+#define EC_CODER_WRONG_PROBABILITY 1 -+#define EC_CODER_WRONG_RANGE 2 -+#define EC_BUFFER_OVERFLOW 501 -+#define EC_BUFFER_UNDERFLOW 502 -+#define EC_UNKNOWN_TOKEN_TYPE 1001 -+#define EC_UNKNOWN_FILTER 1002 -+#define EC_UNKNOWN_CONVERTER 1003 -+#define EC_UNKNOWN_MANIPULATOR 1004 -+ -+/******************************************************************************* -+ -+ COMPRESSOR INIT FUNCTIONS -+ -+*******************************************************************************/ -+ -+#define ROUND_UP_TO_DWORD(val) ( ( (val) + 3 ) & 0xfffffffc ) -+ -+#ifndef __KERNEL__ -+int ipack_glb_endian_X; -+#endif -+ -+static int ipack_compressor_init_tree(unsigned char **ptr, ipack_model_type * model, ipack_nodetype * node, void *nullnode) -+{ -+ int retval = 0; -+ node->type = *((*ptr)++); -+ switch (node->type) { -+ u32 i; -+ u32 j; -+ u32 lngth; -+ u32 tmpret; -+ TokenType at; -+ u16 av; -+ case TREENODETYPE_NODE_BINARY_EQ: -+ case TREENODETYPE_NODE_BINARY_LT: -+ node->data.nodeBin.attribute_ptr = (model->predictors_ptr) + (*((*ptr)++)); -+ node->data.nodeBin.value = *((*ptr)++); -+ retval = sizeof(node->data.nodeBin); -+ retval += ipack_compressor_init_tree(ptr, model, (void *) ROUND_UP_TO_DWORD(((u32) node) + sizeof(node->type) + sizeof(node->data.nodeBin)), nullnode); -+ node->data.nodeBin.right_child_ptr = (void *) ROUND_UP_TO_DWORD(((u32) node) + retval + sizeof(node->type)); -+ retval += ipack_compressor_init_tree(ptr, model, node->data.nodeBin.right_child_ptr, nullnode); -+ break; -+ case TREENODETYPE_LEAF_P: -+ lngth = *((*ptr)++); -+ av = 0; -+ for (i = 0, j = 0; i < lngth; ++i) { -+ at = *((*ptr)++); -+ while (j < at) { -+ node->data.leafP.probabilities[j++] = av; -+ } -+ av += *((*ptr)++); -+ } -+ while (j < NUMBER_OF_TOKENS) { -+ node->data.leafP.probabilities[j++] = av; -+ } -+ for (i = 0; i < NUMBER_OF_TOKENS; ++i) { -+ node->data.leafP.probabilities[i] = ((node->data.leafP.probabilities[i] << PROBABILITY_SHIFT) / node->data.leafP.probabilities[NUMBER_OF_TOKENS - 1]); -+ } -+ retval = ROUND_UP_TO_DWORD(NUMBER_OF_TOKENS * sizeof(u16)); -+ break; -+ case TREENODETYPE_LEAF_C: -+ node->data.leafC.predicted_class = *((*ptr)++); -+ retval = sizeof(node->data.leafC); -+ retval = ROUND_UP_TO_DWORD(retval); -+ break; -+ default: -+ return 0; -+ } -+ return retval + sizeof(node->type); -+} -+ -+#define IPACK_TREE_CONVERT_REPLACE 0 -+#define IPACK_TREE_CONVERT_KEEP 1 -+ -+static void *ipack_tree_to_code(ipack_model_type * model, int *code_size); -+ -+static int ipack_armlib_convert_tree_to_code(ipack_model_type * model_img, int mode) -+{ -+#ifdef IPACK_TREE_TO_CODE -+ int tree_size; -+ -+ model_img->tree_code = ipack_tree_to_code(model_img, &tree_size); -+ jffs2_bbc_print2("Convertation done. Code size=%d\n", tree_size); -+ if (mode == IPACK_TREE_CONVERT_REPLACE) { -+ jffs2_bbc_print1("Freeing original tree.\n"); -+ jffs2_bbc_free(model_img->tree_root_ptr); -+ model_img->tree_root_ptr = NULL; -+ } -+#endif -+ return 0; -+} -+ -+ -+static int ipack_armlib_compressor_init(void **model) -+{ -+ int retval = EC_NO_ERROR; -+ unsigned char *tmp_ptr = *model; -+ u32 i; -+ ipack_model_type *model_img; -+ char tmp_c[2]; -+ -+ if (*(tmp_ptr++) != 'i') { -+ return EC_NOT_IPMF_FILE; -+ } -+ else if (*(tmp_ptr++) != 'P') { -+ return EC_NOT_IPMF_FILE; -+ } -+ else if (*(tmp_ptr++) != 'M') { -+ return EC_NOT_IPMF_FILE; -+ } -+ else if (*(tmp_ptr++) != 'F') { -+ return EC_NOT_IPMF_FILE; -+ } -+ tmp_c[0] = *(tmp_ptr++); -+ tmp_c[1] = *(tmp_ptr++); -+ tmp_ptr += 2; -+ -+ //model_img = jffs2_bbc_malloc(*((u32*)tmp_ptr)); -+ model_img = jffs2_bbc_malloc(sizeof(ipack_model_type) + ROUND_UP_TO_DWORD(NUMBER_OF_PREDICTORS)); -+ model_img->tree_root_ptr = jffs2_bbc_malloc(*((u32 *) tmp_ptr)); //it is smaller a little but, but... -+ -+ tmp_ptr += sizeof(u32); -+ -+ model_img->ID[0] = 'i'; -+ model_img->ID[1] = 'P'; -+ model_img->ID[2] = 'M'; -+ model_img->ID[3] = 'F'; -+ -+ model_img->block_sign[0] = tmp_c[0]; -+ model_img->block_sign[1] = tmp_c[1]; -+ -+ model_img->nullnode.type = TREENODETYPE_LEAF_P; -+ for (i = 0; i < NUMBER_OF_TOKENS; ++i) { -+ model_img->nullnode.probabilities[i] = 0; -+ } -+ model_img->predictors_ptr = (void *) (((u32) model_img) + sizeof(ipack_model_type)); -+ //model_img->tree_root_ptr = (void*)ROUND_UP_TO_DWORD(((u32)(model_img->predictors_ptr)) + NUMBER_OF_PREDICTORS);//ALIGN -+ -+ ipack_compressor_init_tree(&tmp_ptr, model_img, model_img->tree_root_ptr, &(model_img->nullnode)); -+ -+#ifdef IPACK_TREE_TO_CODE -+#ifdef IPACK_AUTO_TREE_TO_CODE -+ jffs2_bbc_print1("Automatically converting tree to ARM code...\n"); -+ ipack_armlib_convert_tree_to_code(model_img, IPACK_TREE_CONVERT_REPLACE); -+#else -+ model_img->tree_code = NULL; -+#endif -+#else -+ model_img->tree_code = NULL; -+#endif -+ -+ jffs2_bbc_free(*model); -+ *model = model_img; -+ return retval; -+} -+ -+/******************************************************************************* -+ -+ COMPRESSOR DEINIT FUNCTIONS -+ -+*******************************************************************************/ -+ -+ -+/* Descructor of compressor (model will be freed with jffs2_bbc_free() after it)*/ -+static void ipack_armlib_compressor_deinit(void) -+{ -+} -+ -+/******************************************************************************* -+ -+ COMPRESS FUNCTIONS -+ -+*******************************************************************************/ -+ -+static int writebits0(unsigned char **dest, u8 * freebits, u32 * opposite, unsigned char *end) -+{ -+ if (!(*freebits)) { -+ ++(*dest); -+ *freebits = 7; -+ **dest = 0x00; -+ } -+ else { -+ --(*freebits); -+ (**dest) <<= 1; -+ } -+ if ((*dest == end) && !(*freebits)) { -+ return EC_BUFFER_OVERFLOW; -+ } -+ while (*opposite) { -+ --(*opposite); -+ if (!(*freebits)) { -+ ++(*dest); -+ *freebits = 7; -+ **dest = 0x01; -+ } -+ else { -+ --(*freebits); -+ (**dest) <<= 1; -+ (**dest) |= 0x01; -+ } -+ if ((*dest == end) && !(*freebits)) { -+ return EC_BUFFER_OVERFLOW; -+ } -+ } -+ return 0; -+} -+ -+static int writebits1(unsigned char **dest, u8 * freebits, u32 * opposite, unsigned char *end) -+{ -+ if (!(*freebits)) { -+ ++(*dest); -+ *freebits = 7; -+ **dest = 0x01; -+ } -+ else { -+ --(*freebits); -+ (**dest) <<= 1; -+ (**dest) |= 0x01; -+ } -+ if ((*dest == end) && !(*freebits)) { -+ return EC_BUFFER_OVERFLOW; -+ } -+ while (*opposite) { -+ --(*opposite); -+ if (!(*freebits)) { -+ ++(*dest); -+ *freebits = 7; -+ **dest = 0x00; -+ } -+ else { -+ --(*freebits); -+ (**dest) <<= 1; -+ } -+ if ((*dest == end) && !(*freebits)) { -+ return EC_BUFFER_OVERFLOW; -+ } -+ } -+ return 0; -+} -+ -+ -+ -+ -+/* Compress block -+ * *dstlen bytes are allocated. -+ * if it is not enough write *sourcelen over to the processed amount of data -+ * returns non zero if fails -+ */ -+static int ipack_armlib_compress(void *model, unsigned char *input, unsigned char *output, unsigned long *sourcelen, unsigned long *dstlen) -+{ -+ register u32 coder_high = CODER_VALUEMAX - 1; -+ register u32 coder_low = 0; -+ u32 coder_opbits = 0; -+ u8 bitvector_freebits = 8; -+ unsigned char *bitvector_ptr = output; -+ unsigned char *bitvector_end = output + (*dstlen - 1); -+ ARM_DataType *tmpp; -+ TokenStream tmpv; -+ TokenType *it; -+ void *end_it; -+ -+ ipack_nodetype *treeroot = ((ipack_model_type *) model)->tree_root_ptr; -+ PredictorType *predctrs = ((ipack_model_type *) model)->predictors_ptr; -+ -+#ifdef IPACK_TREE_TO_CODE -+ void (*treefunc) (ipack_nodetype *, TokenType, ipack_probability_type *); -+ -+ treefunc = ((ipack_model_type *) model)->tree_code; -+ if (treefunc != NULL) -+ treefunc += 4; -+#endif -+ -+ if ((*sourcelen % 4) != 0) { -+ return EC_WRONG_INPUT_LENGTH; -+ } -+ if (*dstlen <= 4) { -+ return EC_BUFFER_OVERFLOW; -+ } -+ -+ if (((ipack_model_type *) model)->ID[0] != 'i') { -+ return EC_NOT_IPMF_MODEL; -+ } -+ else if (((ipack_model_type *) model)->ID[1] != 'P') { -+ return EC_NOT_IPMF_MODEL; -+ } -+ else if (((ipack_model_type *) model)->ID[2] != 'M') { -+ return EC_NOT_IPMF_MODEL; -+ } -+ else if (((ipack_model_type *) model)->ID[3] != 'F') { -+ return EC_NOT_IPMF_MODEL; -+ } -+#ifdef TXT_TOKENS -+ tmpv.capacity = (*sourcelen); -+#else -+ tmpv.capacity = (*sourcelen) << 1; -+#endif -+ tmpv.size = tmpv.capacity; -+ tmpv.ptr = jffs2_bbc_malloc(tmpv.size); -+ it = tmpv.ptr; -+ -+#ifndef __KERNEL__ -+ if (ipack_glb_endian_X) { -+ for (tmpp = (void *) input; (u32) tmpp < (u32) (input + *sourcelen); ++tmpp) { -+#ifdef TXT_TOKENS -+ *(it++) = (u8) ((*tmpp & 0xff000000) >> 24); -+ *(it++) = (u8) ((*tmpp & 0x00ff0000) >> 16); -+ *(it++) = (u8) ((*tmpp & 0x0000ff00) >> 8); -+ *(it++) = (u8) ((*tmpp & 0x000000ff)); -+#else -+ *(it++) = (u8) ((*tmpp & 0x0000f000) >> 12); -+ *(it++) = (u8) ((*tmpp & 0x0000000f)); -+ *(it++) = (u8) ((*tmpp & 0xf0000000) >> 28); -+ *(it++) = (u8) ((*tmpp & 0x000f0000) >> 16); -+ *(it++) = (u8) ((*tmpp & 0x00000f00) >> 8); -+ *(it++) = (u8) ((*tmpp & 0x00f00000) >> 20); -+ *(it++) = (u8) ((*tmpp & 0x0f000000) >> 24); -+ *(it++) = (u8) ((*tmpp & 0x000000f0) >> 4); -+#endif //TXT_TOKENS -+ } -+ } -+ else { -+#endif -+ for (tmpp = (void *) input; (u32) tmpp < (u32) (input + *sourcelen); ++tmpp) { -+#ifdef TXT_TOKENS -+ *(it++) = (u8) ((*tmpp & 0x000000ff)); -+ *(it++) = (u8) ((*tmpp & 0x0000ff00) >> 8); -+ *(it++) = (u8) ((*tmpp & 0x00ff0000) >> 16); -+ *(it++) = (u8) ((*tmpp & 0xff000000) >> 24); -+#else -+ *(it++) = (u8) ((*tmpp & 0x00f00000) >> 20); -+ *(it++) = (u8) ((*tmpp & 0x0f000000) >> 24); -+ *(it++) = (u8) ((*tmpp & 0x000000f0) >> 4); -+ *(it++) = (u8) ((*tmpp & 0x00000f00) >> 8); -+ *(it++) = (u8) ((*tmpp & 0x000f0000) >> 16); -+ *(it++) = (u8) ((*tmpp & 0x0000f000) >> 12); -+ *(it++) = (u8) ((*tmpp & 0x0000000f)); -+ *(it++) = (u8) ((*tmpp & 0xf0000000) >> 28); -+#endif //TXT_TOKENS -+ } -+#ifndef __KERNEL__ -+ } -+#endif -+/* -+ ENCODE -+*/ -+ { //predictor reset -+ register PredictorType *ptr = predctrs; -+ register PredictorType *end = ptr + NUMBER_OF_PREDICTORS; -+ while (ptr < end) { -+ *(ptr++) = 0; -+ } -+ } -+ -+ //*(bitvector_ptr++) = 'H'; -+ //*(bitvector_ptr++) = 'G'; -+ *(bitvector_ptr++) = ((ipack_model_type *) model)->block_sign[0]; -+ *(bitvector_ptr++) = ((ipack_model_type *) model)->block_sign[1]; -+ -+ *(bitvector_ptr++) = (unsigned char) (((*sourcelen) >> 8) & 0xff); -+ *(bitvector_ptr++) = (unsigned char) ((*sourcelen) & 0xff); -+ for (it = tmpv.ptr, end_it = VECTOR_S_END(tmpv); it != end_it; ++it) { -+ ipack_probability_type prob; -+ u32 range; -+ -+#ifdef IPACK_TREE_TO_CODE -+ if (treefunc != NULL) -+ (*treefunc) (treeroot, *it, &prob); -+ else -+ ipack_model_get_probability_for_token(treeroot, *it, &prob); -+#else -+ ipack_model_get_probability_for_token(treeroot, *it, &prob); -+#endif -+ -+ if (prob.high == prob.low) { -+ vector_clear(&tmpv); -+ return EC_CODER_WRONG_PROBABILITY; -+ } -+ range = coder_high - coder_low + 1; -+ coder_high = coder_low + ((range * prob.high) >> PROBABILITY_SHIFT) - 1; -+ coder_low += ((range * prob.low) >> PROBABILITY_SHIFT); -+ for (;;) { -+ if (coder_high < CODER_VALUEHLF) { -+ if (writebits0(&bitvector_ptr, &bitvector_freebits, &coder_opbits, bitvector_end)) { -+ vector_clear(&tmpv); -+ return EC_BUFFER_OVERFLOW; -+ } -+ } -+ else if (coder_low >= CODER_VALUEHLF) { -+ if (writebits1(&bitvector_ptr, &bitvector_freebits, &coder_opbits, bitvector_end)) { -+ vector_clear(&tmpv); -+ return EC_BUFFER_OVERFLOW; -+ } -+ coder_high -= CODER_VALUEHLF; -+ coder_low -= CODER_VALUEHLF; -+ } -+ else if ((CODER_VALUE1ST <= coder_low) && (coder_high < CODER_VALUE3RD)) { -+ ++coder_opbits; -+ coder_high -= CODER_VALUE1ST; -+ coder_low -= CODER_VALUE1ST; -+ } -+ else { -+ break; -+ } -+ coder_high <<= 1; -+ ++coder_high; -+ coder_low <<= 1; -+ if (coder_high < coder_low) { -+ vector_clear(&tmpv); -+ return EC_CODER_WRONG_RANGE; -+ } -+ } -+ { -+#ifdef TXT_TOKENS -+// register u32 ndx; -+ predctrs[0] = *it; -+ if ((('a' <= *it) && (*it <= 'z')) || (('A' <= *it) && (*it <= 'Z'))) { -+ ++(predctrs[1]); -+ } -+ else { -+ predctrs[1] = 0; -+ } -+#else -+ register u32 ndx = predctrs[0] + 1; -+ predctrs[ndx + 8] = predctrs[ndx]; -+ predctrs[ndx] = *it; -+ if (ndx == 8) { -+ predctrs[0] = 0; -+ } -+ else { -+ ++predctrs[0]; -+ } -+#endif -+ } -+ -+ } -+ vector_clear(&tmpv); -+ ++coder_opbits; -+ if (coder_low < CODER_VALUE1ST) { -+ if (writebits0(&bitvector_ptr, &bitvector_freebits, &coder_opbits, bitvector_end)) { -+ return EC_BUFFER_OVERFLOW; -+ } -+ } -+ else { -+ if (writebits1(&bitvector_ptr, &bitvector_freebits, &coder_opbits, bitvector_end)) { -+ return EC_BUFFER_OVERFLOW; -+ } -+ } -+ (*(bitvector_ptr)) <<= bitvector_freebits; -+ *dstlen = ((u32) bitvector_ptr - (u32) output + 1); -+ return EC_NO_ERROR; -+} -+ -+/******************************************************************************* -+ -+ DECOMPRESS FUNCTIONS -+ -+*******************************************************************************/ -+ -+typedef struct -+{ -+ u32 high; -+ u32 low; -+ u32 value; -+ u32 overread; -+} ipack_decompressor_values; -+ -+typedef struct -+{ -+ u8 freebits; -+ unsigned char *ptr; -+ unsigned char *end; -+} ipack_decompressor_bitvector; -+ -+static u8 ipack_bitvector_R_get1(ipack_decompressor_bitvector * bv) -+{ -+ u8 tmp; -+ if (bv->ptr == bv->end) { -+ bv->freebits = 0; -+ return 0; -+ } -+ tmp = (*(bv->ptr) >> bv->freebits) & 0x01; -+ if (!(bv->freebits)) { -+ bv->freebits = 7; -+ ++(bv->ptr); -+ } -+ else { -+ --(bv->freebits); -+ } -+ return tmp; -+} -+ -+/* Decompress block -+ * returns non zero if fails -+ */ -+static int ipack_armlib_decompress(void *model, unsigned char *input, unsigned char *output, unsigned long sourcelen, unsigned long dstlen) -+{ -+ ARM_DataType *data; -+ register u32 coder_high = CODER_VALUEMAX - 1; -+ register u32 coder_low = 0; -+ register u32 coder_value = 0; -+ u32 coder_overread = 0; -+ ipack_decompressor_bitvector bitvector; -+ u32 lngth; -+ u32 i; -+ u32 cntbytes; -+ TokenType tkns[8]; -+ TokenType *tptr; -+ -+ ipack_nodetype *treeroot = ((ipack_model_type *) model)->tree_root_ptr; -+ PredictorType *predctrs = ((ipack_model_type *) model)->predictors_ptr; -+ -+#ifdef IPACK_TREE_TO_CODE -+ TokenType(*treefunc) (ipack_nodetype *, u32, u32, ipack_probability_type *); -+ -+ treefunc = ((ipack_model_type *) model)->tree_code; -+#endif -+ -+ -+ if (((ipack_model_type *) model)->ID[0] != 'i') { -+ return EC_NOT_IPMF_MODEL; -+ } -+ else if (((ipack_model_type *) model)->ID[1] != 'P') { -+ return EC_NOT_IPMF_MODEL; -+ } -+ else if (((ipack_model_type *) model)->ID[2] != 'M') { -+ return EC_NOT_IPMF_MODEL; -+ } -+ else if (((ipack_model_type *) model)->ID[3] != 'F') { -+ return EC_NOT_IPMF_MODEL; -+ } -+ -+ bitvector.freebits = 7; -+ bitvector.ptr = input; -+ bitvector.end = input + sourcelen; -+ -+ /*if(*(bitvector.ptr++) != 'H') { -+ return EC_NOT_HG_BLOCK; -+ } else if(*(bitvector.ptr++) != 'G') { -+ return EC_NOT_HG_BLOCK; -+ } */ -+ bitvector.ptr++; -+ bitvector.ptr++; -+ -+ data = (void *) output; -+ cntbytes = *(bitvector.ptr++); -+ cntbytes <<= 8; -+ cntbytes += *(bitvector.ptr++); -+ -+ { //predictor reset -+ register PredictorType *ptr = predctrs; -+ register PredictorType *end = ptr + NUMBER_OF_PREDICTORS; -+ while (ptr < end) { -+ *(ptr++) = 0; -+ } -+ } -+ for (i = 0; i < CODER_VALUEBITS; ++i) { -+ coder_value <<= 1; -+ coder_value += ipack_bitvector_R_get1(&bitvector); -+ } -+ lngth = dstlen >> 2; -+ if (lngth > (cntbytes >> 2)) { -+ lngth = cntbytes >> 2; -+ } -+ for (i = 0; (i < lngth); ++i) { -+ TokenType itoken; -+ u32 j; -+ tptr = tkns; -+ for (j = 0; j < NUMBER_OF_TOKENS_PER_INSTRUCTION; ++j) { -+ ipack_probability_type prob; -+ u32 range = coder_high - coder_low + 1; -+ -+#ifdef IPACK_TREE_TO_CODE -+ if (treefunc != NULL) -+ itoken = (*treefunc) (treeroot, coder_value - coder_low + 1, range, &prob); -+ else -+#endif -+ itoken = ipack_model_get_token_for_range(treeroot, coder_value - coder_low + 1, range, &prob); -+ -+ -+ if (prob.high == prob.low) { -+ return EC_CODER_WRONG_PROBABILITY; -+ } -+ coder_high = coder_low + ((range * prob.high) >> PROBABILITY_SHIFT) - 1; -+ coder_low += ((range * prob.low) >> PROBABILITY_SHIFT); -+ for (;;) { -+ if (coder_high < CODER_VALUEHLF) { -+ } -+ else if (CODER_VALUEHLF <= coder_low) { -+ coder_value -= CODER_VALUEHLF; -+ coder_high -= CODER_VALUEHLF; -+ coder_low -= CODER_VALUEHLF; -+ } -+ else if ((CODER_VALUE1ST <= coder_low) && (coder_high < CODER_VALUE3RD)) { -+ coder_value -= CODER_VALUE1ST; -+ coder_high -= CODER_VALUE1ST; -+ coder_low -= CODER_VALUE1ST; -+ } -+ else { -+ break; -+ } -+ coder_low <<= 1; -+ coder_high <<= 1; -+ ++(coder_high); -+ coder_value <<= 1; -+ if (bitvector.ptr == bitvector.end) { -+ bitvector.freebits = 0; -+ } -+ coder_value += ((*(bitvector.ptr) >> bitvector.freebits) & 0x01); -+ if (bitvector.freebits) { -+ --bitvector.freebits; -+ } -+ else { -+ bitvector.freebits = 7; -+ ++bitvector.ptr; -+ } -+ if (coder_high < coder_low) { -+ return EC_CODER_WRONG_RANGE; -+ } -+ if ((bitvector.ptr == bitvector.end) && !(bitvector.freebits)) { -+ if ((coder_overread++) > CODER_VALUEBITS) { -+ return EC_BUFFER_UNDERFLOW; -+ } -+ } -+ } -+ { -+#ifdef TXT_TOKENS -+// register u32 ndx; -+ predctrs[0] = itoken; -+ if ((('a' <= itoken) && (itoken <= 'z')) || (('A' <= itoken) && (itoken <= 'Z'))) { -+ ++(predctrs[1]); -+ } -+ else { -+ predctrs[1] = 0; -+ } -+ -+#else -+ register u32 ndx = predctrs[0] + 1; -+ predctrs[ndx + 8] = predctrs[ndx]; -+ predctrs[ndx] = itoken; -+ if (ndx == 8) { -+ predctrs[0] = 0; -+ } -+ else { -+ ++predctrs[0]; -+ } -+#endif -+ } -+ -+ (*(tptr++)) = itoken; -+ } -+ tptr = tkns; -+#ifndef __KERNEL__ -+ if (ipack_glb_endian_X) { -+#ifdef TXT_TOKENS -+ (*data) = ((*tptr) << 24); -+ ++tptr; -+ (*data) |= ((*tptr) << 16); -+ ++tptr; -+ (*data) |= ((*tptr) << 8); -+ ++tptr; -+ (*data) |= (*tptr); -+ ++data; -+#else -+ (*data) = (((*tptr) & 0xf) << 12); -+ ++tptr; -+ (*data) |= ((*tptr) & 0xf); -+ ++tptr; -+ (*data) |= (((*tptr) & 0xf) << 28); -+ ++tptr; -+ (*data) |= (((*tptr) & 0xf) << 16); -+ ++tptr; -+ (*data) |= (((*tptr) & 0xf) << 8); -+ ++tptr; -+ (*data) |= (((*tptr) & 0xf) << 20); -+ ++tptr; -+ (*data) |= (((*tptr) & 0xf) << 24); -+ ++tptr; -+ (*data) |= (((*tptr) & 0xf) << 4); -+ ++data; -+#endif -+ } -+ else { -+#endif -+#ifdef TXT_TOKENS -+ (*data) = (*tptr); -+ ++tptr; -+ (*data) |= ((*tptr) << 8); -+ ++tptr; -+ (*data) |= ((*tptr) << 16); -+ ++tptr; -+ (*data) |= ((*tptr) << 24); -+ ++data; -+#else -+ (*data) = (((*tptr) & 0xf) << 20); -+ ++tptr; -+ (*data) |= (((*tptr) & 0xf) << 24); -+ ++tptr; -+ (*data) |= (((*tptr) & 0xf) << 4); -+ ++tptr; -+ (*data) |= (((*tptr) & 0xf) << 8); -+ ++tptr; -+ (*data) |= (((*tptr) & 0xf) << 16); -+ ++tptr; -+ (*data) |= (((*tptr) & 0xf) << 12); -+ ++tptr; -+ (*data) |= ((*tptr) & 0xf); -+ ++tptr; -+ (*data) |= (((*tptr) & 0xf) << 28); -+ ++data; -+#endif -+#ifndef __KERNEL__ -+ } -+#endif -+ } -+ return EC_NO_ERROR; -+} -+ -+static int ipack_armlib_estimate(void *model, unsigned char *input, unsigned long sourcelen, unsigned long *dstlen, unsigned long *readtime, unsigned long *writetime) -+{ -+ int i, tmp, tmp2, max, maxi; -+ int cnt_cond[] = { 0, 0, 0, 0 }; -+ int cnt_inst[] = { 0, 0, 0, 0 }; -+ -+ // TODO: make a more precise estimation!!! -+ *readtime = JFFS2_BBC_ZLIB_READ_TIME * 6; -+ *writetime = JFFS2_BBC_ZLIB_WRITE_TIME * 2; -+ -+ if (sourcelen % 4 != 0) { -+ *dstlen = sourcelen; -+ return 0; -+ } -+ for (i = 0; i < sourcelen; i++, input++) { -+ tmp2 = tmp = *input; -+ tmp = ((tmp) & 0xf0) >> 4; -+ tmp2 = tmp2 & 0xf; -+ if (tmp == 14) -+ cnt_cond[i % 4]++; -+ if ((tmp2 == 2) || (tmp2 == 3)) -+ cnt_inst[i % 4]++; -+ } -+ maxi = -1; -+ max = -1; -+ for (i = 0; i < 4; i++) -+ if (max < cnt_cond[i]) { -+ max = cnt_cond[i]; -+ maxi = i; -+ } -+ /*jffs2_bbc_print("armlib_EST: %d/%d : %d/%d %d/%d %d/%d %d/%d", -+ cnt_cond[maxi],cnt_inst[maxi], -+ cnt_cond[0],cnt_inst[0], -+ cnt_cond[1],cnt_inst[1], -+ cnt_cond[2],cnt_inst[2], -+ cnt_cond[3],cnt_inst[3]); */ -+ -+ if (cnt_cond[maxi] < (sourcelen >> 4)) { -+ *dstlen = sourcelen; -+ } -+ else { -+ *dstlen = sourcelen / 3; -+ } -+ -+ return 0; -+} -+ -+static char *ipack_armlib_proc_info(void); -+static int ipack_armlib_proc_command(char *command); -+static void ipack_armlib_destroy_model(void **model); -+ -+struct jffs2_bbc_compressor_type jffs2_bbc_armlib = { -+ "armlib", -+ 0x464d5069, -+ {0, 0, 0, 0}, -+ NULL, // init -+ ipack_armlib_compressor_init, // init_model -+ ipack_armlib_destroy_model, // destroy_model -+ ipack_armlib_compressor_deinit, // deinit -+ ipack_armlib_compress, -+ ipack_armlib_estimate, -+ ipack_armlib_decompress, -+ ipack_armlib_proc_info, -+ ipack_armlib_proc_command -+}; -+ -+ -+static char *ipack_armlib_proc_info() -+{ -+#ifdef IPACK_TREE_TO_CODE -+#ifdef IPACK_AUTO_TREE_TO_CODE -+ return "automatic tree to code conversion"; -+#else -+ return "manual tree to code conversion possibility"; -+#endif -+#else -+ return "tree in memory version"; -+#endif -+} -+ -+static int ipack_armlib_proc_command(char *command) -+{ -+ struct jffs2_bbc_model_list_node *model; -+ ipack_model_type *armlib_model; -+ -+ if ((*command == 'g') || (*command == 'G')) { -+ jffs2_bbc_print1("Converting tree(s) to ARM code... (keeping original)\n"); -+ model = jffs2_bbc_armlib.models; -+ if (model == NULL) -+ jffs2_bbc_print1("no model found!\n"); -+ while (model != NULL) { -+ armlib_model = model->model; -+ if (armlib_model == NULL) { -+ jffs2_bbc_print1("Error: NULL model!\n"); -+ } -+ else { -+ ipack_armlib_convert_tree_to_code(armlib_model, IPACK_TREE_CONVERT_KEEP); -+ } -+ model = model->next_compr_model; -+ } -+ } -+ else if ((*command == 'r') || (*command == 'R')) { -+ jffs2_bbc_print1("Converting tree(s) to ARM code... (deleting original)\n"); -+ model = jffs2_bbc_armlib.models; -+ if (model == NULL) -+ jffs2_bbc_print1("no model found!\n"); -+ while (model != NULL) { -+ armlib_model = model->model; -+ if (armlib_model == NULL) { -+ jffs2_bbc_print1("Error: NULL model!\n"); -+ } -+ else { -+ //armlib_model->tree_code = ipack_tree_to_code(armlib_model, &tree_size); -+ //jffs2_bbc_print("Convertation done. Code size=%d\n",tree_size); -+ ipack_armlib_convert_tree_to_code(armlib_model, IPACK_TREE_CONVERT_REPLACE); -+ } -+ model = model->next_compr_model; -+ } -+ } -+ else if ((*command == 'c') || (*command == 'C')) { -+ jffs2_bbc_print1("Deleting ARM representation of the tree(s)...\n"); -+ model = jffs2_bbc_armlib.models; -+ if (model == NULL) -+ jffs2_bbc_print1("no model found!\n"); -+ while (model != NULL) { -+ armlib_model = model->model; -+ if (armlib_model == NULL) { -+ jffs2_bbc_print1("Error: NULL model!\n"); -+ } -+ else { -+ if (armlib_model->tree_code == NULL) { -+ jffs2_bbc_print1("already deleted.\n"); -+ } -+ else { -+ if (armlib_model->tree_root_ptr == NULL) { -+ jffs2_bbc_print1("cannot delete this ARM tree - original tree has deleted\n"); -+ } -+ else { -+ jffs2_bbc_print1("deleting..."); -+ jffs2_bbc_free(armlib_model->tree_code); -+ armlib_model->tree_code = NULL; -+ jffs2_bbc_print1("done.\n"); -+ } -+ } -+ } -+ model = model->next_compr_model; -+ } -+ } -+ else if (*command == '?') { -+ jffs2_bbc_print1("ARMLIB commands:\n"); -+ jffs2_bbc_print1(" g: convert TREEs to ARM code and keep the original\n"); -+ jffs2_bbc_print1(" r: convert TREEs to ARM code and remove the original\n"); -+ jffs2_bbc_print1(" c: delete the original TREEs - if there is any\n"); -+ } -+ else { -+ jffs2_bbc_print1("Unknown command.\n"); -+ } -+ return 0; -+} -+ -+static void ipack_armlib_destroy_model(void **model) -+{ -+ ipack_model_type *model_img; -+ -+ model_img = *model; -+ if (model_img == NULL) { -+ jffs2_bbc_print1("jffs2.bbc: armlib: NULL model at destoying model!\n"); -+ return; -+ } -+ if (model_img->tree_code != NULL) { -+ //jffs2_bbc_print1("jffs2.bbc: armlib: debug: freeing code...\n"); -+ jffs2_bbc_free(model_img->tree_code); -+ model_img->tree_code = NULL; -+ } -+ if (model_img->tree_root_ptr != NULL) { -+ //jffs2_bbc_print1("jffs2.bbc: armlib: debug: freeing tree...\n"); -+ jffs2_bbc_free(model_img->tree_root_ptr); -+ model_img->tree_root_ptr = NULL; -+ } -+ -+ jffs2_bbc_free(model_img); -+ *model = NULL; -+} -+ -+struct jffs2_bbc_compressor_type *jffs2_bbc_armlib_init(int mode) -+{ -+ if (jffs2_bbc_register_compressor(&jffs2_bbc_armlib) == 0) -+ return &jffs2_bbc_armlib; -+ else -+ return NULL; -+} -+ -+void jffs2_bbc_armlib_deinit(void) -+{ -+ jffs2_bbc_unregister_compressor(&jffs2_bbc_armlib); -+} -+ -+/*END OF ARMLIB*/ ---- /dev/null -+++ b/fs/jffs2/jffs2_bbc_framework.c -@@ -0,0 +1,1324 @@ -+/* -+ * JFFS2-BBC: Compression Framework -+ * -+ * $Id: 301-jffs-compression,v 1.1 2005/03/26 10:33:31 wbx Exp $ -+ * -+ * Copyright (C) 2004, Ferenc Havasi -+ * -+ * 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. -+ * -+ */ -+ -+/* USE JFFS2_BBC_STANDALONE define if you don't want to compile without JFFS2 */ -+ -+//#define DEBUG_COMPRESSORS -+//#define DEBUG_SHOW_BLOCK_SIZES -+ -+#define JFFS2_BBC_STAT_BUFF_SIZE 8000 -+ -+#ifndef __KERNEL__ -+ -+#include <stdio.h> -+#include <malloc.h> -+typedef unsigned long uint32_t; -+ -+#else -+ -+#include <linux/kernel.h> -+#include <linux/slab.h> -+#include <linux/vmalloc.h> -+ -+#endif -+ -+#define JFFS2_BBC_ZLIB_BLOCK_SIGN_0 (120) -+#define JFFS2_BBC_ZLIB_BLOCK_SIGN_1 (94) -+ -+#define JFFS2_BBC_DUMMY_BLOCKSIGN_0 (0x54) -+#define JFFS2_BBC_DUMMY_BLOCKSIGN_1 (0x01) -+ -+#ifndef NULL -+#define NULL ((void*)(0)) -+#endif -+ -+#include "jffs2_bbc_framework.h" -+ -+/********************************************************************* -+ * Global data * -+ *********************************************************************/ -+ -+static int jffs2_bbc_compression_mode = JFFS2_BBC_ZLIB_MODE; -+static struct jffs2_bbc_compressor_type *jffs2_bbc_manual_compressor = NULL; -+static struct jffs2_bbc_compressor_type *jffs2_bbc_compressors = NULL; -+static struct jffs2_bbc_model_list_node *jffs2_bbc_model_list = NULL; -+static void *last_sb = NULL; /* previously activated sb */ -+ -+/********************************************************************* -+ * Compressor initialization * -+ *********************************************************************/ -+ -+#ifndef JFFS2_BBC_STANDALONE -+ -+#if !defined(__KERNEL__) || defined(CONFIG_JFFS2_BBC_ARMLIB) -+struct jffs2_bbc_compressor_type *jffs2_bbc_armlib_init(void); -+void jffs2_bbc_armlib_deinit(void); -+#endif -+ -+#if !defined(__KERNEL__) || defined(CONFIG_JFFS2_BBC_LZO) -+struct jffs2_bbc_compressor_type *jffs2_bbc_lzo_init(void); -+void jffs2_bbc_lzo_deinit(void); -+#endif -+ -+#if !defined(__KERNEL__) || defined(CONFIG_JFFS2_BBC_LZSS) -+struct jffs2_bbc_compressor_type *jffs2_bbc_lzss_init(void); -+void jffs2_bbc_lzss_deinit(void); -+#endif -+ -+#if !defined(__KERNEL__) || defined(CONFIG_JFFS2_BBC_LZARI) -+struct jffs2_bbc_compressor_type *jffs2_bbc_lzari_init(void); -+void jffs2_bbc_lzari_deinit(void); -+#endif -+ -+#if !defined(__KERNEL__) || defined(CONFIG_JFFS2_BBC_LZHD) -+struct jffs2_bbc_compressor_type *jffs2_bbc_lzhd_init(void); -+void jffs2_bbc_lzhd_deinit(void); -+#endif -+ -+void jffs2_bbc_compressor_init() -+{ -+#if !defined(__KERNEL__) || defined(CONFIG_JFFS2_BBC_ARMLIB) -+ jffs2_bbc_armlib_init(); -+#endif -+#if !defined(__KERNEL__) || defined(CONFIG_JFFS2_BBC_LZO) -+ jffs2_bbc_lzo_init(); -+#endif -+#if !defined(__KERNEL__) || defined(CONFIG_JFFS2_BBC_LZSS) -+ jffs2_bbc_lzss_init(); -+#endif -+#if !defined(__KERNEL__) || defined(CONFIG_JFFS2_BBC_LZARI) -+ jffs2_bbc_lzari_init(); -+#endif -+#if !defined(__KERNEL__) || defined(CONFIG_JFFS2_BBC_LZHD) -+ jffs2_bbc_lzhd_init(); -+#endif -+} -+ -+void jffs2_bbc_compressor_deinit() -+{ -+#if !defined(__KERNEL__) || defined(CONFIG_JFFS2_BBC_LZHD) -+ jffs2_bbc_lzhd_deinit(); -+#endif -+#if !defined(__KERNEL__) || defined(CONFIG_JFFS2_BBC_LZARI) -+ jffs2_bbc_lzari_deinit(); -+#endif -+#if !defined(__KERNEL__) || defined(CONFIG_JFFS2_BBC_LZSS) -+ jffs2_bbc_lzss_deinit(); -+#endif -+#if !defined(__KERNEL__) || defined(CONFIG_JFFS2_BBC_LZO) -+ jffs2_bbc_lzo_deinit(); -+#endif -+#if !defined(__KERNEL__) || defined(CONFIG_JFFS2_BBC_ARMLIB) -+ jffs2_bbc_armlib_deinit(); -+#endif -+} -+ -+#endif -+ -+#ifndef JFFS2_BBC_STANDALONE -+ -+/********************************************************************* -+ * ZLIB COMPRESSOR * -+ *********************************************************************/ -+ -+extern int jffs2_zlib_compress2(unsigned char *data_in, unsigned char *cpage_out, uint32_t * sourcelen, uint32_t * dstlen); -+extern void jffs2_zlib_decompress2(unsigned char *data_in, unsigned char *cpage_out, uint32_t srclen, uint32_t destlen); -+ -+static int jffs2_bbc_zlib_compress(void *model, unsigned char *input, unsigned char *output, unsigned long *sourcelen, unsigned long *dstlen) -+{ -+ return jffs2_zlib_compress2(input, output, sourcelen, dstlen); -+} -+ -+static int jffs2_bbc_zlib_decompress(void *model, unsigned char *input, unsigned char *output, unsigned long sourcelen, unsigned long dstlen) -+{ -+ jffs2_zlib_decompress2(input, output, sourcelen, dstlen); -+ return 0; -+} -+ -+static int jffs2_bbc_zlib_estimate(void *model, unsigned char *input, unsigned long sourcelen, unsigned long *dstlen, unsigned long *readtime, unsigned long *writetime) -+{ -+ *dstlen = sourcelen * 65 / 100; -+ *readtime = JFFS2_BBC_ZLIB_READ_TIME; -+ *writetime = JFFS2_BBC_ZLIB_WRITE_TIME; -+ return 0; -+} -+ -+static struct jffs2_bbc_compressor_type jffs2_bbc_zlib = { -+ "zlib", -+ 0, -+ {JFFS2_BBC_ZLIB_BLOCK_SIGN_0, JFFS2_BBC_ZLIB_BLOCK_SIGN_1, 0, 0}, -+ NULL, -+ NULL, -+ NULL, -+ NULL, -+ jffs2_bbc_zlib_compress, -+ jffs2_bbc_zlib_estimate, -+ jffs2_bbc_zlib_decompress, -+ NULL, -+ NULL, -+ 1 -+}; -+ -+static struct jffs2_bbc_compressor_type *jffs2_bbc_original_compressor = &jffs2_bbc_zlib; -+ -+#endif -+ -+/********************************************************************* -+ * Compression mode handling * -+ *********************************************************************/ -+ -+int jffs2_bbc_get_compression_mode(void) -+{ -+ return jffs2_bbc_compression_mode; -+} -+ -+void jffs2_bbc_set_compression_mode(int mode) -+{ -+ jffs2_bbc_compression_mode = mode; -+} -+ -+void jffs2_bbc_set_manual_compressor(struct jffs2_bbc_compressor_type *c) -+{ -+ jffs2_bbc_manual_compressor = c; -+ jffs2_bbc_set_compression_mode(JFFS2_BBC_MANUAL_MODE); -+} -+ -+int jffs2_bbc_set_manual_compressor_by_name(char *name) -+{ -+ struct jffs2_bbc_compressor_type *l; -+ int i; -+ -+ l = jffs2_bbc_compressors; -+ while (l != NULL) { -+ for (i = 0; i < 1000; i++) { -+ if (l->name[i] == 0) { -+ jffs2_bbc_set_manual_compressor(l); -+ return 0; -+ } -+ else if (name[i] == 0) -+ i = 1000; -+ else if (name[i] != l->name[i]) -+ i = 1000; -+ } -+ l = l->next; -+ } -+ jffs2_bbc_set_manual_compressor(NULL); -+ return 1; -+} -+ -+static struct jffs2_bbc_compressor_type *jffs2_bbc_get_compressor_by_name(char *name) -+{ -+ struct jffs2_bbc_compressor_type *l; -+ int i; -+ -+#ifndef JFFS2_BBC_STANDALONE -+ l = jffs2_bbc_original_compressor; -+ for (i = 0; i < 1000; i++) { -+ if (l->name[i] == 0) { -+ return l; -+ } -+ else if (name[i] == 0) -+ i = 1000; -+ else if (name[i] != l->name[i]) -+ i = 1000; -+ } -+#endif -+ -+ l = jffs2_bbc_compressors; -+ while (l != NULL) { -+ for (i = 0; i < 1000; i++) { -+ if (l->name[i] == 0) { -+ return l; -+ } -+ else if (name[i] == 0) -+ i = 1000; -+ else if (name[i] != l->name[i]) -+ i = 1000; -+ } -+ l = l->next; -+ } -+ -+ return NULL; -+} -+ -+int jffs2_bbc_disable_compressor_by_name(char *name) -+{ -+ struct jffs2_bbc_compressor_type *l; -+ -+ l = jffs2_bbc_get_compressor_by_name(name); -+ if (l == NULL) return 1; -+ l->enabled = 0; -+ return 0; -+} -+ -+int jffs2_bbc_enable_compressor_by_name(char *name) -+{ -+ struct jffs2_bbc_compressor_type *l; -+ -+ l = jffs2_bbc_get_compressor_by_name(name); -+ if (l == NULL) return 1; -+ l->enabled = 1; -+ return 0; -+} -+ -+void jffs2_bbc_compressor_command_by_name(char *name_and_command) -+{ -+ struct jffs2_bbc_compressor_type *l; -+ int i; -+ -+ l = jffs2_bbc_compressors; -+ while (l != NULL) { -+ for (i = 0; i < 1000; i++) { -+ if (l->name[i] == 0) { -+ if (name_and_command[i] != ':') { -+ jffs2_bbc_print1("jffs2.bbc: ':' missing after compressor name\n"); -+ } -+ else { -+ if (l->proc_command != NULL) -+ l->proc_command(name_and_command + i + 1); -+ } -+ i = 1000; -+ return; -+ } -+ else if (name_and_command[i] == 0) { -+ i = 1000; -+ } -+ else if (name_and_command[i] != l->name[i]) { -+ i = 1000; -+ } -+ } -+ l = l->next; -+ } -+} -+ -+struct jffs2_bbc_compressor_type *jffs2_bbc_get_manual_compressor(void) -+{ -+ if (jffs2_bbc_get_compression_mode() != JFFS2_BBC_MANUAL_MODE) { -+ jffs2_bbc_manual_compressor = NULL; -+ } -+ return jffs2_bbc_manual_compressor; -+} -+ -+/********************************************************************* -+ * Compressor handling * -+ *********************************************************************/ -+ -+struct jffs2_bbc_compressor_type *jffs2_bbc_get_compressor_list(void) -+{ -+ return jffs2_bbc_compressors; -+} -+ -+struct jffs2_bbc_model_list_node *jffs2_bbc_get_model_list(void) -+{ -+ return jffs2_bbc_model_list; -+} -+ -+int jffs2_bbc_register_compressor(struct jffs2_bbc_compressor_type *c) -+{ -+ struct jffs2_bbc_compressor_type *l; -+ struct jffs2_bbc_model_list_node *l2; -+ int model_found = 0; -+ -+ l = jffs2_bbc_compressors; -+ /* Check for confilcts */ -+ while (l != NULL) { -+ c->name[15] = 0; -+ /*if (strcmp(c->name,l->name)==0) { -+ jffs2_bbc_print1("jffs2.bbc: compressor is already loaded."); -+ return -1; -+ } */ -+ if ((l->model_file_sign == c->model_file_sign) && (c->model_file_sign != 0)) { -+ jffs2_bbc_print1("jffs2.bbc: already used model file sign. fail."); -+ return -1; -+ } -+ l = l->next; -+ } -+ /* Search and initialize model */ -+ c->models = NULL; -+ c->mounted = 0; -+ if (c->init != NULL) { -+ if (c->init() != 0) { -+ jffs2_bbc_print2("jffs2.bbc: cannot initialize compressor %s.\n", c->name); -+ return -1; -+ } -+ } -+ if (c->model_file_sign != 0) { -+ l2 = jffs2_bbc_model_list; -+ while (1) { -+ if (l2 == NULL) -+ break; -+ if (c->model_file_sign == l2->sign) { -+ if (l2->compressor != NULL) { -+ jffs2_bbc_print2("jffs2.bbc: register for %s: BUG, model file already reserved!!!!\n", c->name); -+ } -+ else { -+ if (c->init_model(&(l2->model)) != 0) { -+ jffs2_bbc_print2("jffs2.bbc: cannot initialize compressor %s for a model", c->name); -+ } -+ else { -+ l2->compressor = c; -+ l2->next_compr_model = c->models; -+ c->models = l2; -+ c->mounted++; -+ model_found++; -+ } -+ } -+ } -+ l2 = l2->next_model; -+ } -+ /*if (model_found==0) { -+ jffs2_bbc_print2("jffs2.bbc: no macthing model file found for %s at this time (maybe later)\n",c->name); -+ } */ -+ } -+ /* Insert to the end of the compressor list */ -+ c->enabled = 1; -+ c->buffer = NULL; -+ c->buffer_size = 0; -+ c->stat_compr_orig = c->stat_compr_new = c->stat_decompr = 0; -+ c->next = NULL; -+ if (jffs2_bbc_compressors == NULL) { -+ jffs2_bbc_compressors = c; -+ } -+ else { -+ l = jffs2_bbc_compressors; -+ while (l->next != NULL) -+ l = l->next; -+ l->next = c; -+ } -+ return 0; -+} -+ -+int jffs2_bbc_unregister_compressor(struct jffs2_bbc_compressor_type *c) -+{ -+ struct jffs2_bbc_compressor_type *l; -+ struct jffs2_bbc_model_list_node *l2; -+ -+ if (c->mounted != 0) { -+ jffs2_bbc_print1("jffs2.bbc: Compressor is in use. Sorry."); -+ return -1; -+ } -+ if (jffs2_bbc_compressors == NULL) { -+ jffs2_bbc_print1("jffs2.bbc: unregister: empty list."); -+ return -1; -+ } -+ else if (jffs2_bbc_compressors == c) { -+ if (c->deinit != NULL) -+ c->deinit(); -+ jffs2_bbc_compressors = c->next; -+ } -+ else { -+ l = jffs2_bbc_compressors; -+ while (l->next != c) { -+ if (l->next == NULL) { -+ jffs2_bbc_print2("jffs2.bbc: unregister: cannot find compressor %s in the list.", c->name); -+ return -1; -+ } -+ l = l->next; -+ } -+ if (c->deinit != NULL) -+ c->deinit(); -+ l->next = c->next; -+ } -+ if (c->buffer != NULL) { -+ jffs2_bbc_free(c->buffer); -+ c->buffer = NULL; -+ c->buffer_size = 0; -+ } -+ -+ l2 = jffs2_bbc_model_list; -+ while (l2 != NULL) { -+ if (l2->compressor == c) { -+ jffs2_bbc_print1("jffs2.bbc: unregister: BUG: model found!!!"); -+ l2->compressor = NULL; -+ l2->next_compr_model = NULL; -+ } -+ l2 = l2->next_model; -+ } -+ -+ return 0; -+} -+ -+int jffs2_bbc_model_new(void *sb, int i_num, void *model) -+{ -+ struct jffs2_bbc_model_list_node *node; -+ struct jffs2_bbc_compressor_type *l; -+ char block_sign[2]; -+ -+ int sign; -+ -+ /* check for conflicts... */ -+ sign = *((int *) model); -+ block_sign[0] = *(((char *) model) + 4); -+ block_sign[1] = *(((char *) model) + 5); -+ node = jffs2_bbc_model_list; -+ while (node != NULL) { -+ if ((node->block_sign[0] == block_sign[0]) && (node->block_sign[1] == block_sign[1]) && (node->sb == sb)) { -+ //jffs2_bbc_print2("jffs2.bbc: model_new: model conflict (inode=%d)!\n",i_num); -+ return -1; -+ } -+ node = node->next_model; -+ } -+ -+ /* insertion */ -+ node = jffs2_bbc_malloc_small((long)sizeof(struct jffs2_bbc_model_list_node)); -+ node->sb = sb; -+ node->model = model; -+ node->sign = *((int *) model); -+ node->block_sign[0] = *(((char *) model) + 4); -+ node->block_sign[1] = *(((char *) model) + 5); -+ node->inode = i_num; -+ node->next_model = jffs2_bbc_model_list; -+ node->compressor = NULL; -+ node->stat_decompr = 0; -+ node->next_compr_model = NULL; -+ jffs2_bbc_model_list = node; -+ -+ /* search for matching compressor */ -+ l = jffs2_bbc_compressors; -+ while (l != NULL) { -+ if (l->model_file_sign == sign) { -+ //jffs2_bbc_print2("jffs2.bbc: compressor for model found: %s ",l->name); -+ if (l->init_model(&(node->model)) != 0) { -+ jffs2_bbc_print1("jffs2.bbc: cannot initialize compressor for a model"); -+ } -+ else { -+ l->mounted++; -+ node->compressor = l; -+ node->next_compr_model = l->models; -+ l->models = node; -+ } -+ break; -+ } -+ l = l->next; -+ } -+ return 0; -+} -+ -+static void jffs2_bbc_model_del_from_compressor(struct jffs2_bbc_model_list_node *node) -+{ -+ struct jffs2_bbc_model_list_node *l; -+ -+ if (node->model != NULL) { -+ if (node->compressor != NULL) { -+ if (node->compressor->destroy_model == NULL) { -+ jffs2_bbc_free(node->model); -+ node->model = NULL; -+ } -+ else { -+ node->compressor->destroy_model(&(node->model)); -+ if (node->model != NULL) -+ jffs2_bbc_print1("jffs2.bbc: warning: not NULL model after destroying!\n"); -+ } -+ } -+ } -+ -+ if (node->compressor == NULL) { -+ jffs2_bbc_print1("jffs2.bbc: jffs2_bbc_model_del_from_compressor: no compressor!\n"); -+ return; -+ } -+ l = node->compressor->models; -+ if (l == NULL) { -+ jffs2_bbc_print1("jffs2.bbc: jffs2_bbc_model_del_from_compressor error, models=NULL!\n"); -+ return; -+ } -+ if (l == node) { -+ node->compressor->models = node->next_compr_model; -+ node->compressor->mounted--; -+ return; -+ } -+ while (1) { -+ if (l->next_compr_model == node) { -+ l->next_compr_model = node->next_compr_model; -+ node->compressor->mounted--; -+ return; -+ } -+ l = l->next_compr_model; -+ if (l == NULL) { -+ jffs2_bbc_print1("jffs2.bbc: jffs2_bbc_model_del_from_compressor: not found\n"); -+ return; -+ } -+ } -+} -+ -+void jffs2_bbc_model_del(void *sb) -+{ -+ struct jffs2_bbc_model_list_node *l, *l2; -+ -+ l = jffs2_bbc_model_list; -+ if (l == NULL) -+ return; -+ if (l->sb == sb) { -+ jffs2_bbc_model_list = l->next_model; -+ jffs2_bbc_model_del_from_compressor(l); -+ jffs2_bbc_free_small(l); -+ jffs2_bbc_model_del(sb); -+ return; -+ } -+ while (1) { -+ if (l->next_model == NULL) { -+ break; -+ } -+ if (l->next_model->sb == sb) { -+ l2 = l->next_model; -+ l->next_model = l->next_model->next_model; -+ jffs2_bbc_model_del_from_compressor(l2); -+ jffs2_bbc_free_small(l2); -+ jffs2_bbc_model_del(sb); -+ return; -+ } -+ l = l->next_model; -+ } -+ last_sb = NULL; -+} -+ -+void jffs2_bbc_model_set_act_sb(void *sb) -+{ -+ last_sb = sb; -+} -+ -+void *jffs2_bbc_model_get_act_sb(void) -+{ -+ return last_sb; -+} -+ -+void *jffs2_bbc_model_get_newest(struct jffs2_bbc_compressor_type *compressor) -+{ -+ struct jffs2_bbc_model_list_node *m, *best_m; -+ int max_sign, sign; -+ -+ if (compressor == NULL) { -+ jffs2_bbc_print1("jffs2.bbc: jffs2_bbc_model_get: NULL!!\n"); -+ return NULL; -+ } -+ -+ best_m = NULL; -+ max_sign = -1; -+ m = compressor->models; -+ while (m != NULL) { -+ if (m->sb == last_sb) { -+ sign = (int) (m->block_sign[0]) * 256 + (int) (m->block_sign[1]); -+ if (sign > max_sign) { -+ max_sign = sign; -+ best_m = m; -+ } -+ } -+ m = m->next_compr_model; -+ } -+ if (best_m != NULL) -+ return best_m->model; -+ else -+ return NULL; -+} -+ -+/********************************************************************* -+ * Statistics * -+ *********************************************************************/ -+ -+static char *jffs2_bbc_stat_buff = NULL; -+ -+char *jffs2_bbc_get_model_stats(void) -+{ -+ char *b; -+ struct jffs2_bbc_model_list_node *m; -+ struct jffs2_bbc_compressor_type *c; -+ -+ if (jffs2_bbc_stat_buff == NULL) -+ jffs2_bbc_stat_buff = jffs2_bbc_malloc(8000); -+ -+ b = jffs2_bbc_stat_buff; -+ -+ b += sprintf(b, "Loaded compressors:"); -+ c = jffs2_bbc_compressors; -+ while (c != NULL) { -+ b += sprintf(b, "\n %s (%d) ", c->name, c->enabled); -+ if (c->model_file_sign != 0) { -+ b += sprintf(b, "m_sign=%d ", c->model_file_sign); -+ b += sprintf(b, "models="); -+ m = c->models; -+ while (m != NULL) { -+ b += sprintf(b, "(inode=%d)", m->inode); -+ m = m->next_compr_model; -+ } -+ } -+ else { -+ b += sprintf(b, "b_sign=(%d,%d) nomodel", (int) (c->block_sign[0]), (int) (c->block_sign[1])); -+ } -+ if (c->proc_info != NULL) { -+ b += sprintf(b, "\n %s", c->proc_info()); -+ } -+ c = c->next; -+ } -+ -+ m = jffs2_bbc_model_list; -+ -+ if (m == NULL) { -+ b += sprintf(b, "\nPresent models: NONE\n"); -+ } -+ else { -+ b += sprintf(b, "\nPresent models:\n"); -+ while (m != NULL) { -+ b += sprintf(b, " b_sign=(%d,%d),inode=%d,decompr=%d", (int) (m->block_sign[0]), (int) (m->block_sign[1]), m->inode, m->stat_decompr); -+ if (m->compressor == NULL) -+ b += sprintf(b, ",compressor=NULL\n"); -+ else -+ b += sprintf(b, ",compressor=%s\n", m->compressor->name); -+ m = m->next_model; -+ } -+ } -+ -+ return jffs2_bbc_stat_buff; -+} -+ -+/********************************************************************* -+ * Memory handling, debug * -+ *********************************************************************/ -+ -+static int jffs2_bbc_mem_counter = 0; -+ -+#ifdef __KERNEL__ -+ -+void *jffs2_bbc_malloc(long size) -+{ -+ void *addr = vmalloc(size); -+ if (addr != NULL) -+ jffs2_bbc_mem_counter++; -+ else { -+ jffs2_bbc_print2("DEBUG: not enough memory (%ld)\n", size); -+ } -+ return addr; -+} -+ -+void jffs2_bbc_free(void *addr) -+{ -+ jffs2_bbc_mem_counter--; -+ vfree(addr); -+} -+ -+void *jffs2_bbc_malloc_small(long size) -+{ -+ void *addr; -+ addr = kmalloc(size, 0); -+ if (addr != NULL) -+ jffs2_bbc_mem_counter++; -+ return addr; -+} -+ -+void jffs2_bbc_free_small(void *addr) -+{ -+ jffs2_bbc_mem_counter--; -+ kfree(addr); -+} -+ -+#else -+ -+void *jffs2_bbc_malloc(long size) -+{ -+ void *addr = malloc(size); -+ if (addr != NULL) -+ jffs2_bbc_mem_counter++; -+ return addr; -+} -+ -+void jffs2_bbc_free(void *addr) -+{ -+ jffs2_bbc_mem_counter--; -+ free(addr); -+} -+ -+void *jffs2_bbc_malloc_small(long size) -+{ -+ return jffs2_bbc_malloc(size); -+} -+ -+void jffs2_bbc_free_small(void *addr) -+{ -+ jffs2_bbc_free(addr); -+} -+ -+#endif -+ -+int jffs2_bbc_test_memory_counter(int verbose) -+{ -+ if (verbose > 0) { -+ jffs2_bbc_print2("jffs2.bbc: mem_counter=%d!\n", jffs2_bbc_mem_counter); -+ } -+ return jffs2_bbc_mem_counter; -+} -+ -+int jffs2_bbc_get_memory_counter(void) -+{ -+ return jffs2_bbc_mem_counter; -+} -+ -+static char mem_stat[200]; -+ -+char *jffs2_bbc_get_mem_stats(void) -+{ -+ sprintf(mem_stat, "Memcounter=%d\n", jffs2_bbc_mem_counter); -+ return mem_stat; -+} -+ -+void jffs2_bbc_print_flush(void) -+{ -+#ifdef __KERNEL__ -+ return; -+#else -+ fflush(stdout); -+ fflush(stderr); -+#endif -+} -+ -+/********************************************************************* -+ * FRAMEWORK - ZLIB REPLACEMENT * -+ *********************************************************************/ -+ -+#ifndef JFFS2_BBC_STANDALONE -+ -+/* Temorary buffers */ -+static char stat_str[JFFS2_BBC_STAT_BUFF_SIZE]; -+static int tmp_buffer_size = 0; -+static char *tmp_buffer = NULL; -+ -+/* Statistic - used by /proc/jffs2_bbc and mkfs.jffs2 */ -+char *jffs2_bbc_get_compr_stats(void) -+{ -+ struct jffs2_bbc_compressor_type *l; -+ char *s = stat_str; -+ -+ s += sprintf(s, "Compression statistics:\n"); -+ l = jffs2_bbc_original_compressor; -+ //s += sprintf(s, " zlib: compr=%d/%d decompr=%d\n", stat_zlib_compr_new, stat_zlib_compr_orig, stat_zlib_decompr); -+ s += sprintf(s, " %s: compr=%d/%d decompr=%d\n", l->name, l->stat_compr_new, l->stat_compr_orig, l->stat_decompr); -+ l = jffs2_bbc_get_compressor_list(); -+ while (l != NULL) { -+ s += sprintf(s, " %s: compr=%d/%d decompr=%d\n", l->name, l->stat_compr_new, l->stat_compr_orig, l->stat_decompr); -+ l = l->next; -+ } -+ return stat_str; -+} -+ -+static void jffs2_bbc_buffer_fill(unsigned char *buff, int size) -+{ -+ for (; size > 0; size--, buff++) -+ *buff = 255; -+} -+ -+ -+static int jffs2_bbc_update_compr_buf(unsigned long size) -+{ -+ struct jffs2_bbc_compressor_type *l; -+ -+ if (size < 5000) -+ size = 5000; -+ if (tmp_buffer == NULL) { -+ tmp_buffer = jffs2_bbc_malloc(size); -+ jffs2_bbc_buffer_fill(tmp_buffer, size); -+ tmp_buffer_size = size; -+ } -+ else if (tmp_buffer_size < size) { -+ jffs2_bbc_free(tmp_buffer); -+ tmp_buffer = jffs2_bbc_malloc(size); -+ jffs2_bbc_buffer_fill(tmp_buffer, size); -+ tmp_buffer_size = size; -+ } -+ l = jffs2_bbc_get_compressor_list(); -+ while (l != NULL) { -+ if (l->buffer == NULL) { -+ l->buffer_size = size; -+ l->buffer = jffs2_bbc_malloc(size); -+ jffs2_bbc_buffer_fill(l->buffer, size); -+ } -+ else if (l->buffer_size < size) { -+ jffs2_bbc_free(l->buffer); -+ l->buffer_size = size; -+ l->buffer = jffs2_bbc_malloc(size); -+ jffs2_bbc_buffer_fill(l->buffer, size); -+ } -+ l = l->next; -+ } -+ return 0; -+} -+ -+#ifdef DEBUG_COMPRESSORS -+ -+static unsigned char *debug_tmp_buff = NULL; -+static long debug_orig_srclen = -1; -+static long debug_orig_dstlen = -1; -+static int debug_mem_counter = -1; -+ -+ -+void debug_before_compress(struct jffs2_bbc_compressor_type *c, void *model, unsigned char *input, unsigned char *output, long *sourcelen, long *dstlen) -+{ -+ -+ debug_orig_srclen = *sourcelen; // for buffer overflow test -+ debug_orig_dstlen = *dstlen; // for buffer overflow test -+ output[debug_orig_dstlen + 1] = 255; -+ -+ debug_mem_counter = jffs2_bbc_get_memory_counter(); // for memory guard -+} -+ -+void debug_after_compress(struct jffs2_bbc_compressor_type *c, int back, void *model, unsigned char *input, unsigned char *output, long *sourcelen, long *dstlen) -+{ -+ long dst_len = *dstlen; -+ long src_len = *sourcelen; -+ int i; -+ -+ // Memory guard -+ if (debug_mem_counter != jffs2_bbc_get_memory_counter()) { -+ jffs2_bbc_print4("!!!!!!!! %s error: possible COMPRESSOR MEMORY LEAK: %d->%d\n", c->name, debug_mem_counter, jffs2_bbc_get_memory_counter()); -+ debug_mem_counter = jffs2_bbc_get_memory_counter(); -+ } -+ -+ // Buffer overflow test -+ if (output[debug_orig_dstlen + 1] != 255) { -+ jffs2_bbc_print7("!!!!!!!! %s error: BUFFER OVERFLOW !!!!!!!!!!!! b[%d]=%d (srclen=%d dstlen=%d, back=%d)\n", c->name, (int) (debug_orig_dstlen + 1), (int) (output[debug_orig_dstlen + 1]), (int) (debug_orig_srclen), (int) (*dstlen), back); -+ } -+ -+ // Decompression check -+ if (back == 0) { -+ if (debug_tmp_buff == NULL) -+ debug_tmp_buff = jffs2_bbc_malloc(17000); -+ for (i = 0; i < src_len; i++) debug_tmp_buff[i] = 0xf6; -+ c->decompress(model, output, debug_tmp_buff, dst_len, src_len); -+ // Memory guard for decompressor -+ if (debug_mem_counter != jffs2_bbc_get_memory_counter()) { -+ jffs2_bbc_print4("!!!!!!!! %s error: possible DECOMPRESSOR MEMORY LEAK: %d->%d\n", c->name, debug_mem_counter, jffs2_bbc_get_memory_counter()); -+ debug_mem_counter = jffs2_bbc_get_memory_counter(); -+ } -+ -+ for (i = 0; i < src_len; i++) -+ if (input[i] != debug_tmp_buff[i]) { -+ jffs2_bbc_print7("!!!!!!!! %s error: BLOCK DECOMPRESSED BADLY (first bad: %d in %d: %d!=%d (compressed size=%d)) !!!!!!!!!!!!\n", c->name, i, src_len, (int)input[i], (int)debug_tmp_buff[i], dst_len); -+ break; -+ } -+ return; -+ } -+ -+ // Return value test -+ //jffs2_bbc_print3("!!!!!!!! %s error: %d !!!!!!!!!!!!\n", c->name, back); -+} -+ -+#endif -+ -+int jffs2_zlib_compress(unsigned char *data_in, unsigned char *cpage_out, uint32_t * sourcelen, uint32_t * dstlen) -+{ -+ struct jffs2_bbc_compressor_type *c; -+ int back, back_zlib, mode, min, i, i2; -+ long tmp = 0, tmp_read_time = 1000, tmp_write_time = 1000, orig_src, orig_dest, src, dest; -+ struct jffs2_bbc_model_list_node *m; -+ void *sb; -+ unsigned char *tmp_p = NULL; -+ -+ sb = jffs2_bbc_model_get_act_sb(); -+ -+ orig_src = *sourcelen; -+ orig_dest = *dstlen; -+ -+ mode = jffs2_bbc_get_compression_mode(); -+ -+ if (mode == JFFS2_BBC_DUMMY_MODE) { -+ i=0; i2=0; -+ if (*dstlen>2) { -+ cpage_out[i++]=JFFS2_BBC_DUMMY_BLOCKSIGN_0; -+ cpage_out[i++]=JFFS2_BBC_DUMMY_BLOCKSIGN_1; -+ i2=i; -+ } -+ for (;((i < *dstlen) && (i < (*sourcelen)+i2));i++) { -+ cpage_out[i] = data_in[i-i2]; -+ } -+ *sourcelen=i-i2; -+ *dstlen=i; -+ return 0; -+ } -+ -+ if (mode == JFFS2_BBC_ZLIB_MODE) { -+ /*if (!jffs2_bbc_original_compressor->enabled) { -+ jffs2_bbc_print2("jffs2.bbc: WARNING: ZLIB mode but %s disabled! Enabling for this procedure...\n",jffs2_bbc_original_compressor->name); -+ }*/ -+ back = jffs2_bbc_original_compressor->compress(NULL, data_in, cpage_out, sourcelen, dstlen); -+ jffs2_bbc_original_compressor->stat_compr_orig += *sourcelen; -+ jffs2_bbc_original_compressor->stat_compr_new += *dstlen; -+ return back; -+ } -+ -+ jffs2_bbc_update_compr_buf(orig_dest); -+ -+ if (mode == JFFS2_BBC_SIZE_MODE) { -+ // Testing all compressors -+ if (!jffs2_bbc_original_compressor->enabled) { -+ min = -1; -+ } -+ else { -+ back_zlib = jffs2_bbc_original_compressor->compress(NULL, data_in, cpage_out, sourcelen, dstlen); -+ min = *dstlen; -+ } -+ c = jffs2_bbc_get_compressor_list(); -+ while (c != NULL) { -+ c->buffer_cnt = -1; -+ if (c->enabled == 0) { -+ c = c->next; -+ continue; -+ } -+ if (c->model_file_sign == 0) { -+ src = orig_src; -+ dest = orig_dest; -+#ifdef DEBUG_COMPRESSORS -+ debug_before_compress(c, NULL, data_in, c->buffer, &src, &dest); -+#endif -+ back = c->compress(NULL, data_in, c->buffer, &src, &dest); -+#ifdef DEBUG_COMPRESSORS -+ debug_after_compress(c, back, NULL, data_in, c->buffer, &src, &dest); -+#endif -+ if (back == 0) { -+ c->buffer_cnt = dest; -+ if ((min < 0) || (min > dest)) -+ min = dest; -+ } -+ } -+ else { -+ m = c->models; -+ while (m != NULL) { -+ src = orig_src; -+ dest = orig_dest; -+ if (m->sb == sb) { -+ if (c->buffer_cnt == -1) { -+#ifdef DEBUG_COMPRESSORS -+ debug_before_compress(c, m->model, data_in, c->buffer, (long *) (&src), (long *) (&dest)); -+#endif -+ back = c->compress(m->model, data_in, c->buffer, (long *) (&src), (long *) (&dest)); -+#ifdef DEBUG_COMPRESSORS -+ debug_after_compress(c, back, m->model, data_in, c->buffer, (long *) (&src), (long *) (&dest)); -+#endif -+ if (back == 0) { -+ c->buffer_cnt = dest; -+ if ((min < 0) || (min > dest)) -+ min = dest; -+ } -+ } -+ else { -+#ifdef DEBUG_COMPRESSORS -+ debug_before_compress(c, m->model, data_in, tmp_buffer, &src, &dest); -+#endif -+ back = c->compress(m->model, data_in, tmp_buffer, &src, &dest); -+#ifdef DEBUG_COMPRESSORS -+ debug_after_compress(c, back, m->model, data_in, tmp_buffer, &src, &dest); -+#endif -+ if (back == 0) { -+ if (c->buffer_cnt > dest) { -+ c->buffer_cnt = dest; -+ tmp_p = c->buffer; -+ c->buffer = tmp_buffer; -+ tmp_buffer = tmp_p; -+ if ((min < 0) || (min > dest)) -+ min = dest; -+ } -+ } -+ } -+ } -+ m = m->next_compr_model; -+ } -+ } -+ c = c->next; -+ } -+ //Finding the best and copy its result -+ -+#ifdef DEBUG_SHOW_BLOCK_SIZES -+ jffs2_bbc_print1("\n"); -+ if (jffs2_bbc_original_compressor->enabled) { -+ if (min == *dstlen) { -+ jffs2_bbc_print3("%s:%d* ", jffs2_bbc_original_compressor->name, (int) (*dstlen)); -+ } -+ else { -+ jffs2_bbc_print3("%s:%d ", jffs2_bbc_original_compressor->name, (int) (*dstlen)); -+ } -+ } -+ c = jffs2_bbc_get_compressor_list(); -+ while (c != NULL) { -+ if (c->enabled == 0) { -+ c = c->next; -+ continue; -+ } -+ if (c->buffer_cnt == min) -+ jffs2_bbc_print3("%s:%d* ", c->name, c->buffer_cnt); -+ else -+ jffs2_bbc_print3("%s:%d ", c->name, c->buffer_cnt); -+ c = c->next; -+ } -+#endif -+ -+ if (min == -1) { -+ return -1; // none of compressors work (maybe too short output buffer) -+ } -+ -+ if (jffs2_bbc_original_compressor->enabled) { -+ if (min == *dstlen) { -+ jffs2_bbc_original_compressor->stat_compr_orig += *sourcelen; -+ jffs2_bbc_original_compressor->stat_compr_new += *dstlen; -+ return back_zlib; -+ } -+ } -+ -+ c = jffs2_bbc_get_compressor_list(); -+ while (c != NULL) { -+ if (c->enabled == 0) { -+ c = c->next; -+ continue; -+ } -+ if (c->buffer_cnt == min) { -+ *dstlen = c->buffer_cnt; -+ *sourcelen = orig_src; -+ for (i = 0; i < *dstlen; i++) { -+ cpage_out[i] = c->buffer[i]; -+ } -+ c->stat_compr_orig += *sourcelen; -+ c->stat_compr_new += *dstlen; -+ return 0; -+ } -+ c = c->next; -+ } -+ jffs2_bbc_print1("jffs2.bbc: compr (full): BUG!!!\n"); -+ return 0; -+ } -+ -+ if ((mode == JFFS2_BBC_FASTR_MODE)||(mode == JFFS2_BBC_FASTW_MODE)||(mode == JFFS2_BBC_FASTS_MODE)) { -+ // Estimating all compressors -+ if (jffs2_bbc_original_compressor->enabled) { -+ back = jffs2_bbc_original_compressor->estimate(NULL, data_in, *sourcelen, &tmp, &tmp_read_time, &tmp_write_time); -+ } -+ else { -+ tmp = -1; -+ tmp_read_time = -1; -+ tmp_write_time = -1; -+ } -+ if (mode == JFFS2_BBC_FASTR_MODE) tmp = tmp_read_time; -+ if (mode == JFFS2_BBC_FASTW_MODE) tmp = tmp_write_time; -+ min = tmp; -+ c = jffs2_bbc_get_compressor_list(); -+ while (c != NULL) { -+ src = orig_src; -+ dest = orig_dest; -+ c->buffer_cnt = -1; -+ if (c->enabled == 0) { -+ c = c->next; -+ continue; -+ } -+ if ((c->model_file_sign == 0) || (jffs2_bbc_model_get_newest(c) != NULL)) { -+ back = c->estimate(jffs2_bbc_model_get_newest(c), data_in, src, &dest, &tmp_read_time, &tmp_write_time); -+ if (mode == JFFS2_BBC_FASTR_MODE) dest = tmp_read_time; -+ if (mode == JFFS2_BBC_FASTW_MODE) dest = tmp_write_time; -+ if (back == 0) { -+ c->buffer_cnt = dest; -+ if ((min < 0) || (min > dest)) -+ min = dest; -+ } -+ else { -+ c->buffer_cnt = -1; -+ } -+ } -+ c = c->next; -+ } -+ // Finding the best and compress with it -+ if (min == -1) { -+ return -1; -+ } -+ if (jffs2_bbc_original_compressor->enabled) { -+ if (min == tmp) { -+ back = jffs2_bbc_original_compressor->compress(NULL, data_in, cpage_out, sourcelen, dstlen); -+ jffs2_bbc_original_compressor->stat_compr_orig += *sourcelen; -+ jffs2_bbc_original_compressor->stat_compr_new += *dstlen; -+ return back; -+ } -+ } -+ c = jffs2_bbc_get_compressor_list(); -+ while (c != NULL) { -+ if (c->enabled == 0) { -+ c = c->next; -+ continue; -+ } -+ if (c->buffer_cnt == min) { -+ back = c->compress(jffs2_bbc_model_get_newest(c), data_in, cpage_out, (unsigned long*)sourcelen, (unsigned long*)dstlen); -+ if ((back == 0) && (*dstlen < orig_dest) && (*dstlen > 4)) { -+ c->stat_compr_orig += *sourcelen; -+ c->stat_compr_new += *dstlen; -+ } -+ else { // fallback will always be available -+ *sourcelen = orig_src; -+ *dstlen = orig_dest; -+ back = jffs2_bbc_original_compressor->compress(NULL, data_in, cpage_out, sourcelen, dstlen); -+ jffs2_bbc_original_compressor->stat_compr_orig += *sourcelen; -+ jffs2_bbc_original_compressor->stat_compr_new += *dstlen; -+ return back; -+ } -+ return 0; -+ } -+ c = c->next; -+ } -+ jffs2_bbc_print1("jffs2.bbc: compress (fastX mode): BUG!!!\n"); -+ return 0; -+ } -+ -+ if (mode == JFFS2_BBC_MANUAL_MODE) { -+ c = jffs2_bbc_get_manual_compressor(); -+ if (c != NULL) { -+ if (c->model_file_sign == 0) { -+ src = orig_src; -+ dest = orig_dest; -+ back = c->compress(NULL, data_in, cpage_out, &src, &dest); -+ if (back == 0) { -+ *dstlen = dest; -+ *sourcelen = src; -+ c->stat_compr_orig += *sourcelen; -+ c->stat_compr_new += *dstlen; -+ return 0; -+ } -+ } -+ else { -+ c->buffer_cnt = -1; -+ m = c->models; -+ min = -1; -+ while (m != NULL) { -+ src = orig_src; -+ dest = orig_dest; -+ if (m->sb == sb) { -+ if (min == -1) { -+ back = c->compress(m->model, data_in, cpage_out, (unsigned long*)sourcelen, (unsigned long*)dstlen); -+ if ((back == 0) && (*dstlen < orig_dest) && (*dstlen > 4)) { -+ min = dest; -+ tmp_p = cpage_out; -+ } -+ } -+ else { -+ back = c->compress(m->model, data_in, tmp_buffer, &src, &dest); -+ if ((back == 0) && (dest < orig_dest) && (dest > 4)) { -+ if (c->buffer_cnt > dest) { -+ if (min > dest) { -+ min = dest; -+ tmp_p = tmp_buffer; -+ } -+ } -+ } -+ } -+ } -+ m = m->next_compr_model; -+ } -+ if (min != -1) { -+ if (tmp_p != cpage_out) { -+ for (i = 0; i < min; i++) -+ cpage_out[i] = tmp_p[i]; -+ *sourcelen = orig_src; -+ *dstlen = min; -+ } -+ c->stat_compr_orig += *sourcelen; -+ c->stat_compr_new += *dstlen; -+ return 0; -+ } -+ } -+ } -+ /*else { -+ jffs2_bbc_print1("iPack: manual mode without selected compressor!\n"); -+ } */ -+ -+ /*if (!jffs2_bbc_original_compressor->enabled) { -+ jffs2_bbc_print2("jffs2.bbc: WARNING: %s must be enabled! Enabling for this procedure...\n",jffs2_bbc_original_compressor->name); -+ }*/ -+ back = jffs2_bbc_original_compressor->compress(NULL, data_in, cpage_out, sourcelen, dstlen); -+ jffs2_bbc_original_compressor->stat_compr_orig += *sourcelen; -+ jffs2_bbc_original_compressor->stat_compr_new += *dstlen; -+ return back; -+ -+ -+ } -+ -+ jffs2_bbc_print1("jffs2.bbc: compress: unimlemented compress mode!!!\n"); -+ return 0; -+} -+ -+void jffs2_zlib_decompress(unsigned char *data_in, unsigned char *cpage_out, uint32_t srclen, uint32_t destlen) -+{ -+ struct jffs2_bbc_model_list_node *m; -+ struct jffs2_bbc_compressor_type *c; -+ char d[2]; -+ void *sb; -+ int i; -+ -+ /* If the input too small... */ -+ if (destlen<=2) { -+ cpage_out[0]=data_in[0]; -+ if (destlen==2) cpage_out[1]=data_in[1]; -+ return; -+ } -+ -+ sb = jffs2_bbc_model_get_act_sb(); -+ d[0] = *(data_in); -+ d[1] = *(data_in + 1); -+ -+ d[0] &= 0x7f; // Variants support... -+ -+ /* Search for model based decompressors... */ -+ m = jffs2_bbc_get_model_list(); -+ while (m != NULL) { -+ if ((d[0] == m->block_sign[0]) && (d[1] == m->block_sign[1]) && (sb == m->sb)) { -+ if (m->compressor == NULL) { -+ jffs2_bbc_print3("jffs2.bbc: decompressor for block_sign (%d,%d) not loaded!\n", (int) (d[0]), (int) (d[1])); -+ } -+ else { -+ m->compressor->decompress(m->model, data_in, cpage_out, srclen, destlen); -+ m->compressor->stat_decompr++; -+ m->stat_decompr++; -+ } -+ return; -+ } -+ m = m->next_model; -+ } -+ /* Is it ZLIB? */ -+ if ((((int) d[0]) == (int)(jffs2_bbc_original_compressor->block_sign[0])) && (((int) d[1]) == (int)(jffs2_bbc_original_compressor->block_sign[1]))) { -+ jffs2_bbc_original_compressor->decompress(NULL, data_in, cpage_out, srclen, destlen); -+ jffs2_bbc_original_compressor->stat_decompr++; -+ return; -+ } -+ /* Search for non model based decompressors... */ -+ c = jffs2_bbc_get_compressor_list(); -+ while (c != NULL) { -+ if (c->model_file_sign == 0) { -+ if (((int) (d[0]) == (int) (c->block_sign[0])) && ((int) (d[1]) == (int) (c->block_sign[1]))) { -+ c->decompress(NULL, data_in, cpage_out, srclen, destlen); -+ c->stat_decompr++; -+ return; -+ } -+ } -+ c = c->next; -+ } -+ /* Is it DUMMY? */ -+ if ((((int) d[0]) == JFFS2_BBC_DUMMY_BLOCKSIGN_0) && (((int) d[1]) == JFFS2_BBC_DUMMY_BLOCKSIGN_1)) { -+ for (i=0;i<destlen;i++) { -+ cpage_out[i]=data_in[i+2]; -+ } -+ return; -+ } -+ /* No matching decompressor found... */ -+ jffs2_bbc_print4("jffs2.bbc: cannot find model for decompress: bsign=(%d,%d),sb=%d. Using zlib.\n", (int) d[0], (int) d[1], (int) sb); -+ jffs2_bbc_original_compressor->decompress(NULL, data_in, cpage_out, srclen, destlen); -+ jffs2_bbc_original_compressor->stat_decompr++; -+} -+ -+#endif ---- /dev/null -+++ b/fs/jffs2/jffs2_bbc_framework.h -@@ -0,0 +1,202 @@ -+/* -+ * JFFS2-BBC: Compression Framework - headers -+ * -+ * $Id: 301-jffs-compression,v 1.1 2005/03/26 10:33:31 wbx Exp $ -+ * -+ * Copyright (C) 2004, Ferenc Havasi -+ * -+ * 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 __JFFS2_BBC_FRAMEWORK_H__ -+ -+#define __JFFS2_BBC_FRAMEWORK_H__ -+ -+#define JFFS2_BBC_VERSION "0.54.3" -+ -+#define JFFS2_BBC_CONFIG_FILE "bbc.conf" -+ -+/********************************************************************* -+ * Compression mode handling * -+ *********************************************************************/ -+ -+#define JFFS2_BBC_ZLIB_MODE 1 -+#define JFFS2_BBC_SIZE_MODE 2 -+#define JFFS2_BBC_FASTR_MODE 3 -+#define JFFS2_BBC_FASTW_MODE 4 -+#define JFFS2_BBC_FASTS_MODE 5 -+#define JFFS2_BBC_MANUAL_MODE 6 -+#define JFFS2_BBC_DUMMY_MODE 7 -+ -+int jffs2_bbc_get_compression_mode(void); -+void jffs2_bbc_set_compression_mode(int mode); -+ -+/********************************************************************* -+ * Read/write speed unit * -+ * everything is relative to the speed of zlib * -+ * bigger number means slower speed! * -+ *********************************************************************/ -+ -+#define JFFS2_BBC_ZLIB_READ_TIME 10000 -+#define JFFS2_BBC_ZLIB_WRITE_TIME 10000 -+ -+/********************************************************************* -+ * Compressor handling * -+ *********************************************************************/ -+ -+struct jffs2_bbc_compressor_type -+{ -+ char name[16]; -+ int model_file_sign; /* 0 for no model file needed */ -+ char block_sign[4]; /* only nomodel compressors, and only the first 2 _bytes are used! */ -+ int (*init)(void); -+ int (*init_model)(void **model); -+ void (*destroy_model)(void **model); -+ void (*deinit)(void); -+ /* Compress block -+ * *dstlen bytes are allocated. -+ * if it is not enough write *sourcelen over to the processed amount of data -+ * returns non zero if fails -+ */ -+ int (*compress)(void *model, unsigned char *input, unsigned char *output, unsigned long *sourcelen, unsigned long *dstlen); -+ int (*estimate)(void *model, unsigned char *input, unsigned long sourcelen, -+ unsigned long *dstlen, unsigned long *readtime, unsigned long *writetime); -+ /* Decompress block -+ * returns non zero if fails -+ */ -+ int (*decompress)(void *model, unsigned char *input, unsigned char *output, unsigned long sourcelen, unsigned long dstlen); -+ char *(*proc_info)(void); -+ int (*proc_command)(char *command); -+ int enabled; /* filled by BBC */ -+ int mounted; /* filled by BBC */ -+ void *models; /* filled by BBC */ -+ char *buffer; /* filled by BBC */ -+ int buffer_size; /* filled by BBC */ -+ int buffer_cnt; /* filled by BBC */ -+ int buffer_tmp; /* filled by BBC */ -+ int stat_compr_orig; /* filled by BBC */ -+ int stat_compr_new; /* filled by BBC */ -+ int stat_decompr; /* filled by BBC */ -+ struct jffs2_bbc_compressor_type *next; /* filled by BBC */ -+}; -+ -+/* It sets the compression mode to JFFS2_BBC_MANUAL_MODE */ -+ -+void jffs2_bbc_set_manual_compressor(struct jffs2_bbc_compressor_type *c); /* NULL = ZLIB */ -+int jffs2_bbc_set_manual_compressor_by_name(char *name); -+int jffs2_bbc_disable_compressor_by_name(char *name); -+int jffs2_bbc_enable_compressor_by_name(char *name); -+void jffs2_bbc_compressor_command_by_name(char *name_and_command); -+ -+/* If the compression mode is JFFS2_BCC_MANUAL_MODE the manually setted -+ compressor can be get using it. Otherwise it returns with NULL. */ -+ -+struct jffs2_bbc_compressor_type *jffs2_bbc_get_manual_compressor(void); -+ -+struct jffs2_bbc_model_list_node -+{ -+ void *sb; /* FS idendifier (JFFS2_SB_INFO(sb) at this moment) */ -+ void *model; /* model data */ -+ int sign; /* sign of the model (first 4 bytes) */ -+ char block_sign[4]; /* block sign - only the first 2 bytes are used! */ -+ int inode; /* inode number of the model file */ -+ int stat_decompr; -+ struct jffs2_bbc_compressor_type *compressor; -+ struct jffs2_bbc_model_list_node *next_model; -+ struct jffs2_bbc_model_list_node *next_compr_model; -+}; -+ -+struct jffs2_bbc_compressor_type *jffs2_bbc_get_compressor_list(void); -+struct jffs2_bbc_model_list_node *jffs2_bbc_get_model_list(void); -+ -+int jffs2_bbc_register_compressor(struct jffs2_bbc_compressor_type *c); -+int jffs2_bbc_unregister_compressor(struct jffs2_bbc_compressor_type *c); -+ -+int jffs2_bbc_model_new(void *sb, int i_num, void *model); -+void jffs2_bbc_model_del(void *sb); -+void jffs2_bbc_model_set_act_sb(void *sb); -+void *jffs2_bbc_model_get_act_sb(void); -+void *jffs2_bbc_model_get_newest(struct jffs2_bbc_compressor_type *compressor); -+ -+/********************************************************************* -+ * Compressor init function * -+ *********************************************************************/ -+ -+void jffs2_bbc_compressor_init(void); -+void jffs2_bbc_compressor_deinit(void); -+ -+/********************************************************************* -+ * Statistics * -+ *********************************************************************/ -+ -+char *jffs2_bbc_get_compr_stats(void); -+char *jffs2_bbc_get_model_stats(void); -+ -+/********************************************************************* -+ * Other * -+ *********************************************************************/ -+ -+ -+void jffs2_bbc_print_flush(void); -+ -+#ifdef __KERNEL__ -+#include <linux/kernel.h> -+#define jffs2_bbc_print1(a) printk(a) -+#define jffs2_bbc_print2(a,b) printk(a,b) -+#define jffs2_bbc_print3(a,b,c) printk(a,b,c) -+#define jffs2_bbc_print4(a,b,c,d) printk(a,b,c,d) -+#define jffs2_bbc_print5(a,b,c,d,e) printk(a,b,c,d,e) -+#define jffs2_bbc_print6(a,b,c,d,e,f) printk(a,b,c,d,e,f) -+#define jffs2_bbc_print7(a,b,c,d,e,f,g) printk(a,b,c,d,e,f,g) -+#define jffs2_bbc_print8(a,b,c,d,e,f,g,h) printk(a,b,c,d,e,f,g,h) -+#define jffs2_bbc_print9(a,b,c,d,e,f,g,h,i) printk(a,b,c,d,e,f,g,h,i) -+#else -+#include <stdio.h> -+#define jffs2_bbc_print1(a) fprintf(stderr,a) -+#define jffs2_bbc_print2(a,b) fprintf(stderr,a,b) -+#define jffs2_bbc_print3(a,b,c) fprintf(stderr,a,b,c) -+#define jffs2_bbc_print4(a,b,c,d) fprintf(stderr,a,b,c,d) -+#define jffs2_bbc_print5(a,b,c,d,e) fprintf(stderr,a,b,c,d,e) -+#define jffs2_bbc_print6(a,b,c,d,e,f) fprintf(stderr,a,b,c,d,e,f) -+#define jffs2_bbc_print7(a,b,c,d,e,f,g) fprintf(stderr,a,b,c,d,e,f,g) -+#define jffs2_bbc_print8(a,b,c,d,e,f,g,h) fprintf(stderr,a,b,c,d,e,f,g,h) -+#define jffs2_bbc_print9(a,b,c,d,e,f,g,h,i) fprintf(stderr,a,b,c,d,e,f,g,h,i) -+#endif -+ -+/* Handle endianness */ -+#ifndef __KERNEL__ -+ -+#define ENDIAN_HOST_AND_TARGET_SAME 0 -+#define ENDIAN_HOST_AND_TARGET_DIFFERENT 1 -+ -+extern int jffs2_bbc_glb_endian_X; -+ -+#endif -+ -+/* Allocating more than one page (tip. 4096 byte) */ -+void *jffs2_bbc_malloc(long size); -+void jffs2_bbc_free(void *addr); -+ -+/* Allocating less than one page (tip. 4096 byte) */ -+void *jffs2_bbc_malloc_small(long size); -+void jffs2_bbc_free_small(void *addr); -+ -+/* Memory guarding */ -+int jffs2_bbc_test_memory_counter(int verbose); -+char *jffs2_bbc_get_mem_stats(void); -+int jffs2_bbc_get_memory_counter(void); -+ -+#endif ---- /dev/null -+++ b/fs/jffs2/jffs2_bbc_fs.c -@@ -0,0 +1,331 @@ -+/* -+ * JFFS2-BBC: File System Extension for Linux Kernel -+ * -+ * $Id: 301-jffs-compression,v 1.1 2005/03/26 10:33:31 wbx Exp $ -+ * -+ * Copyright (C) 2004, Ferenc Havasi -+ * -+ * 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. -+ * -+ */ -+ -+#include <linux/kernel.h> -+#include <linux/fs.h> -+#include <linux/jffs2.h> -+#include <linux/proc_fs.h> -+#include <linux/version.h> -+ -+#include "nodelist.h" -+ -+#include "jffs2_bbc_framework.h" -+ -+struct jffs2_bbc_fs_sb_list { -+ struct super_block *sb; -+ struct jffs2_bbc_fs_sb_list *next; -+}; -+ -+static struct jffs2_bbc_fs_sb_list *sb_list = NULL; -+ -+void jffs2_bbc_proc_init(void); -+void jffs2_bbc_proc_deinit(void); -+ -+void jffs2_bbc_load_model(void *sb_par) { -+ struct jffs2_sb_info *c; -+ //struct jffs2_inode_info *f; -+ struct dentry *config_dentry,*model_dentry; -+ struct qstr config_name,model_name; -+ struct file *config_file,*model_file; -+ char *buff=NULL,*model_buff; -+ int config_size,model_size; -+ int i,prev_i; -+ struct super_block *sb; -+ struct jffs2_bbc_fs_sb_list *sb_l; -+ -+ sb = sb_par; -+ sb_l = jffs2_bbc_malloc_small(sizeof(struct jffs2_bbc_fs_sb_list)); -+ sb_l->sb = sb; -+ sb_l->next = sb_list; -+ sb_list = sb_l; -+ config_name.name = JFFS2_BBC_CONFIG_FILE; -+ config_name.len = strlen(config_name.name); -+ config_name.hash = full_name_hash(config_name.name,config_name.len); -+ config_dentry = d_alloc(sb->s_root,&config_name); -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -+ sb->s_root->d_inode->i_op->lookup(sb->s_root->d_inode,config_dentry); -+#else -+ sb->s_root->d_inode->i_op->lookup(sb->s_root->d_inode,config_dentry,NULL); -+#endif -+ -+ if (config_dentry->d_inode != NULL) { -+ config_size = config_dentry->d_inode->i_size; -+ //printk("config_file_size=%d\n",config_size); -+ if (config_size > 0) { -+ buff = jffs2_bbc_malloc(config_size+1); -+ config_file = dentry_open(config_dentry,NULL,O_RDONLY); -+ kernel_read(config_file,0,buff,config_size); -+ buff[config_size] = 0; -+ for (prev_i = i = 0 ; i < config_size+1 ; i++) { -+ if (buff[i] == '\n') buff[i]=0; -+ if (buff[i] == 0) { -+ if (prev_i != i) { -+ if ((buff[prev_i] == '-') && (buff[prev_i+1] == 0)) break; -+ printk("reading model file %s... ",buff+prev_i); -+ model_name.name = buff+prev_i; -+ model_name.len = strlen(buff+prev_i); -+ model_name.hash = full_name_hash(model_name.name,model_name.len); -+ model_dentry = d_alloc(sb->s_root,&model_name); -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -+ sb->s_root->d_inode->i_op->lookup(sb->s_root->d_inode,model_dentry); -+#else -+ sb->s_root->d_inode->i_op->lookup(sb->s_root->d_inode,model_dentry,NULL); -+#endif -+ if (model_dentry->d_inode != NULL) { -+ c = JFFS2_SB_INFO(model_dentry->d_inode->i_sb); -+ //f = JFFS2_INODE_INFO(model_dentry->d_inode); -+ model_size = model_dentry->d_inode->i_size; -+ model_buff = jffs2_bbc_malloc(model_size); -+ model_file = dentry_open(model_dentry,NULL,O_RDONLY); -+ kernel_read(model_file,0,model_buff,model_size); -+ if (jffs2_bbc_model_new(c,model_dentry->d_inode->i_ino,model_buff) != 0) { -+ printk("already loaded.\n"); -+ jffs2_bbc_free(model_buff); -+ } -+ else { -+ printk("done (%d bytes readed from inode %d).\n",model_size,(int)(model_dentry->d_inode->i_ino)); -+ } -+ } -+ else { -+ printk("not found.\n"); -+ } -+ dput(model_dentry); -+ } -+ prev_i = i+1; -+ } -+ } -+ } -+ } -+ dput(config_dentry); -+ if (buff != NULL) jffs2_bbc_free(buff); -+} -+ -+void jffs2_bbc_unload_model(void *sb_par) -+{ -+ struct jffs2_sb_info *c; -+ struct super_block *sb = sb_par; -+ struct jffs2_bbc_fs_sb_list *sb_l,*sb_l2; -+ int done = 0; -+ -+ c = JFFS2_SB_INFO(sb); -+ jffs2_bbc_model_del(c); -+ if (sb_list == NULL) printk("jffs2.bbc: error! NULL sb list!\n"); -+ else { -+ if (sb_list->sb == sb) { -+ jffs2_bbc_free_small(sb_list); -+ sb_list = NULL; -+ done = 1; -+ } -+ else { -+ sb_l = sb_list; -+ while (sb_l->next != NULL) { -+ if (sb_l->next->sb == sb) { -+ sb_l2 = sb_l->next->next; -+ jffs2_bbc_free_small(sb_l->next); -+ sb_l->next = sb_l2; -+ done = 1; -+ } -+ sb_l = sb_l->next; -+ } -+ -+ } -+ if (done == 0) { -+ printk("jffs2.bbc: cannot delete sb from sblist!\n"); -+ } -+ } -+} -+ -+static int jffs2_bbc_get_mounted(void) { -+ struct jffs2_bbc_fs_sb_list *sb_l; -+ int num = 0; -+ -+ sb_l = sb_list; -+ while (sb_l != NULL) { -+ num++; -+ sb_l = sb_l->next; -+ } -+ return num; -+ -+} -+ -+int jffs2_bbc_proc_read(char *buf, char **start, off_t offset, int count, int *eof, void *data) -+{ -+ int len = 0, mode; -+ -+ mode = jffs2_bbc_get_compression_mode(); -+ len += sprintf(buf + len, "BBC version: %s\n", JFFS2_BBC_VERSION); -+ len += sprintf(buf+len,"Mounted jffs2 filesystems: %d\n",jffs2_bbc_get_mounted()); -+ //len += sprintf(buf+len,"actual model file inode: %d\n",jffs2_bbc_model_get_inum()); -+ len += sprintf(buf + len, "Compression mode: "); -+ if (mode == JFFS2_BBC_ZLIB_MODE) -+ len += sprintf(buf + len, "ZLIB mode"); -+ else if (mode == JFFS2_BBC_SIZE_MODE) -+ len += sprintf(buf + len, "SIZE mode"); -+ else if (mode == JFFS2_BBC_FASTR_MODE) -+ len += sprintf(buf + len, "FASTR mode"); -+ else if (mode == JFFS2_BBC_FASTW_MODE) -+ len += sprintf(buf + len, "FASTW mode"); -+ else if (mode == JFFS2_BBC_FASTS_MODE) -+ len += sprintf(buf + len, "FASTS mode"); -+ else if (mode == JFFS2_BBC_DUMMY_MODE) -+ len += sprintf(buf + len, "DUMMY mode"); -+ else if (mode == JFFS2_BBC_MANUAL_MODE) { -+ len += sprintf(buf + len, "MANUAL mode ("); -+ if (jffs2_bbc_get_manual_compressor() != NULL) -+ len += sprintf(buf + len, "%s)", jffs2_bbc_get_manual_compressor()->name); -+ else -+ len += sprintf(buf + len, "ZLIB)"); -+ } -+ else -+ len += sprintf(buf + len, "unknown mode"); -+ len += sprintf(buf + len, "\n"); -+ len += sprintf(buf + len, "%s", jffs2_bbc_get_compr_stats()); -+ len += sprintf(buf + len, "%s", jffs2_bbc_get_model_stats()); -+ len += sprintf(buf + len, "%s", jffs2_bbc_get_mem_stats()); -+ *eof = 1; -+ return len; -+} -+ -+int jffs2_bbc_proc_write(struct file *file, const char *buffer_orig, unsigned long count, void *data) -+{ -+ char *buffer; -+ int i; -+ struct jffs2_bbc_fs_sb_list *sb_l; -+ -+ if (buffer_orig == NULL) return 0; -+ -+ buffer = jffs2_bbc_malloc(count+2); -+ for (i=0;i<count;i++) buffer[i]=buffer_orig[i]; -+ buffer[count] = 0; -+ if ((*buffer == 'z') || (*buffer == 'Z')) { -+ jffs2_bbc_set_compression_mode(JFFS2_BBC_ZLIB_MODE); -+ jffs2_bbc_print1("jffs2.bbc: ZLIB compression mode activated.\n"); -+ jffs2_bbc_free(buffer); -+ return count; -+ } -+ else if ((*buffer == 's') || (*buffer == 'S')) { -+ jffs2_bbc_set_compression_mode(JFFS2_BBC_SIZE_MODE); -+ jffs2_bbc_print1("jffs2.bbc: SIZE compression mode activated.\n"); -+ jffs2_bbc_free(buffer); -+ return count; -+ } -+ else if ((*buffer == 'd') || (*buffer == 'D')) { -+ jffs2_bbc_set_compression_mode(JFFS2_BBC_DUMMY_MODE); -+ jffs2_bbc_print1("jffs2.bbc: DUMMY compression mode activated.\n"); -+ jffs2_bbc_free(buffer); -+ return count; -+ } -+ else if (((*buffer == 'm') || (*buffer == 'M')) && (count >= 3) && (buffer[1] == ':')) { -+ jffs2_bbc_print1("jffs2.bbc: activating MANUAL mode.\n"); -+ jffs2_bbc_set_manual_compressor_by_name(buffer + 2); -+ jffs2_bbc_free(buffer); -+ return count; -+ } -+ else if (((*buffer == '0')) && (count >= 3) && (buffer[1] == ':')) { -+ jffs2_bbc_print1("jffs2.bbc: disabling a compressor... "); -+ if (jffs2_bbc_disable_compressor_by_name(buffer + 2) == 0) { -+ jffs2_bbc_print1("done.\n"); -+ } -+ else { -+ jffs2_bbc_print1("not found.\n"); -+ } -+ jffs2_bbc_free(buffer); -+ return count; -+ } -+ else if (((*buffer == '1')) && (count >= 3) && (buffer[1] == ':')) { -+ jffs2_bbc_print1("jffs2.bbc: enabling a compressor... "); -+ if (jffs2_bbc_enable_compressor_by_name(buffer + 2) == 0) { -+ jffs2_bbc_print1("done.\n"); -+ } -+ else { -+ jffs2_bbc_print1("not found.\n"); -+ } -+ jffs2_bbc_free(buffer); -+ return count; -+ } -+ else if (((*buffer == 'c') || (*buffer == 'C')) && (count >= 3) && (buffer[1] == ':')) { -+ jffs2_bbc_compressor_command_by_name(buffer + 2); -+ jffs2_bbc_free(buffer); -+ return count; -+ } -+ else if ((*buffer == 'r') || (*buffer == 'R')) { -+ jffs2_bbc_print1("jffs2.bbc: reloading model files:\n"); -+ sb_l = sb_list; -+ while (sb_l != NULL) { -+ jffs2_bbc_unload_model(sb_l->sb); -+ jffs2_bbc_load_model(sb_l->sb); -+ sb_l = sb_l->next; -+ } -+ jffs2_bbc_free(buffer); -+ return count; -+ } -+ else if (((buffer[0] == 'f') || (buffer[0] == 'F'))&&((buffer[1] == 'r') || (buffer[1] == 'R'))) { -+ jffs2_bbc_set_compression_mode(JFFS2_BBC_FASTR_MODE); -+ jffs2_bbc_print1("jffs2.bbc: FASTR compression mode activated.\n"); -+ jffs2_bbc_free(buffer); -+ return count; -+ } -+ else if (((buffer[0] == 'f') || (buffer[0] == 'F'))&&((buffer[1] == 'w') || (buffer[1] == 'W'))) { -+ jffs2_bbc_set_compression_mode(JFFS2_BBC_FASTW_MODE); -+ jffs2_bbc_print1("jffs2.bbc: FASTW compression mode activated.\n"); -+ jffs2_bbc_free(buffer); -+ return count; -+ } -+ else if (((buffer[0] == 'f') || (buffer[0] == 'F'))&&((buffer[1] == 's') || (buffer[1] == 'S'))) { -+ jffs2_bbc_set_compression_mode(JFFS2_BBC_FASTS_MODE); -+ jffs2_bbc_print1("jffs2.bbc: FASTS compression mode activated.\n"); -+ jffs2_bbc_free(buffer); -+ return count; -+ } -+ -+ jffs2_bbc_print1("jffs2.bbc: unkown command. Valid commands are:\n" -+ " z = switch to ZLIB compression mode\n" -+ " s = switch to SIZE compression mode\n" -+ " d = switch to DUMMY compression mode\n" -+ " fr = switch to FASTR compression mode\n" -+ " fw = switch to FASTW compression mode\n" -+ " fs = switch to FASTS compression mode\n" -+ " r = reread model files from actual file system\n" -+ " m:compressor_name = switch to MANUAL compression mode\n" -+ " 0:compressor_name = disable a compressor\n" -+ " 1:compressor_name = enable a compressor\n" -+ " c:compressor_name:command = enable a compressor\n"); -+ jffs2_bbc_free(buffer); -+ return count; -+} -+ -+void jffs2_bbc_proc_init() -+{ -+ struct proc_dir_entry *res = create_proc_entry("jffs2_bbc", 0, NULL); -+ jffs2_bbc_compressor_init(); -+ if (res) { -+ res->read_proc = jffs2_bbc_proc_read; -+ res->write_proc = jffs2_bbc_proc_write; -+ } -+} -+ -+void jffs2_bbc_proc_deinit() -+{ -+ jffs2_bbc_compressor_deinit(); -+ remove_proc_entry("jffs2_bbc", NULL); -+} ---- /dev/null -+++ b/fs/jffs2/jffs2_bbc_fs.h -@@ -0,0 +1,30 @@ -+/* -+ * JFFS2 BBC: File System Extension for Linux Kernel - headers -+ * -+ * $Id: 301-jffs-compression,v 1.1 2005/03/26 10:33:31 wbx Exp $ -+ * -+ * Copyright (C) 2004, Ferenc Havasi -+ * -+ * 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. -+ * -+ */ -+ -+extern int jffs2_bbc_inode_not_found; -+ -+void jffs2_bbc_load_model(void *sb); -+void jffs2_bbc_unload_model(void *sb); -+ -+void jffs2_bbc_proc_init(void); -+void jffs2_bbc_proc_deinit(void); ---- /dev/null -+++ b/fs/jffs2/jffs2_bbc_lzari_comp.c -@@ -0,0 +1,788 @@ -+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ -+ -+/* -+ jffs2_bbc_lzari_comp.c -- Lempel-Ziv-Arithmetic coding compression module for jffs2 -+ Copyright (C) 2004 Patrik Kluba -+ Based on the LZARI source included in LDS (lossless datacompression sources) -+ Block-compression and bitstream modifications by Patrik Kluba -+ $Header: /openwrt/openwrt/package/linux/kernel-patches/301-jffs-compression,v 1.1 2005/03/26 10:33:31 wbx Exp $ -+*/ -+ -+/* -+Original copyright follows: -+ -+************************************************************** -+ LZARI.C -- A Data Compression Program -+ (tab = 4 spaces) -+************************************************************** -+ 4/7/1989 Haruhiko Okumura -+ Use, distribute, and modify this program freely. -+ Please send me your improved versions. -+ PC-VAN SCIENCE -+ NIFTY-Serve PAF01022 -+ CompuServe 74050,1022 -+************************************************************** -+ -+LZARI.C (c)1989 by Haruyasu Yoshizaki, Haruhiko Okumura, and Kenji Rikitake. -+All rights reserved. Permission granted for non-commercial use. -+ -+*/ -+ -+/* -+ -+ 2004-02-18 pajko <pajko(AT)halom(DOT)u-szeged(DOT)hu> -+ Removed unused variables and fixed no return value -+ -+ 2004-02-16 pajko <pajko(AT)halom(DOT)u-szeged(DOT)hu> -+ Initial release -+ -+*/ -+ -+/* lzari.c */ -+ -+#define N 4096 /* size of ring buffer */ -+#define F 60 /* upper limit for match_length */ -+#define THRESHOLD 2 /* encode string into position and length -+ if match_length is greater than this */ -+#define NIL N /* index for root of binary search trees */ -+ -+static unsigned char -+ text_buf[N + F - 1]; /* ring buffer of size N, -+ with extra F-1 bytes to facilitate string comparison */ -+static unsigned long match_position, match_length, /* of longest match. These are -+ set by the InsertNode() procedure. */ -+ lson[N + 1], rson[N + 257], dad[N + 1]; /* left & right children & -+ parents -- These constitute binary search trees. */ -+ -+static void InitTree(void) /* Initialize trees */ -+{ -+ unsigned long i; -+ -+ /* For i = 0 to N - 1, rson[i] and lson[i] will be the right and -+ left children of node i. These nodes need not be initialized. -+ Also, dad[i] is the parent of node i. These are initialized to -+ NIL (= N), which stands for 'not used.' -+ For i = 0 to 255, rson[N + i + 1] is the root of the tree -+ for strings that begin with character i. These are initialized -+ to NIL. Note there are 256 trees. */ -+ -+ for (i = N + 1; i <= N + 256; i++) rson[i] = NIL; /* root */ -+ for (i = 0; i < N; i++) dad[i] = NIL; /* node */ -+} -+ -+static void InsertNode(unsigned long r) -+ /* Inserts string of length F, text_buf[r..r+F-1], into one of the -+ trees (text_buf[r]'th tree) and returns the longest-match position -+ and length via the global variables match_position and match_length. -+ If match_length = F, then removes the old node in favor of the new -+ one, because the old one will be deleted sooner. -+ Note r plays double role, as tree node and position in buffer. */ -+{ -+ unsigned long i, p, temp; -+ unsigned char *key; -+ signed long cmp; -+ -+ cmp = 1; key = &text_buf[r]; p = N + 1 + key[0]; -+ rson[r] = lson[r] = NIL; match_length = 0; -+ for ( ; ; ) { -+ if (cmp >= 0) { -+ if (rson[p] != NIL) p = rson[p]; -+ else { rson[p] = r; dad[r] = p; return; } -+ } else { -+ if (lson[p] != NIL) p = lson[p]; -+ else { lson[p] = r; dad[r] = p; return; } -+ } -+ for (i = 1; i < F; i++) -+ if ((cmp = key[i] - text_buf[p + i]) != 0) break; -+ if (i > THRESHOLD) { -+ if (i > match_length) { -+ match_position = (r - p) & (N - 1); -+ if ((match_length = i) >= F) break; -+ } else if (i == match_length) { -+ if ((temp = (r - p) & (N - 1)) < match_position) -+ match_position = temp; -+ } -+ } -+ } -+ dad[r] = dad[p]; lson[r] = lson[p]; rson[r] = rson[p]; -+ dad[lson[p]] = r; dad[rson[p]] = r; -+ if (rson[dad[p]] == p) rson[dad[p]] = r; -+ else lson[dad[p]] = r; -+ dad[p] = NIL; /* remove p */ -+} -+ -+static void DeleteNode(unsigned long p) /* Delete node p from tree */ -+{ -+ unsigned long q; -+ -+ if (dad[p] == NIL) return; /* not in tree */ -+ if (rson[p] == NIL) q = lson[p]; -+ else if (lson[p] == NIL) q = rson[p]; -+ else { -+ q = lson[p]; -+ if (rson[q] != NIL) { -+ do { q = rson[q]; } while (rson[q] != NIL); -+ rson[dad[q]] = lson[q]; dad[lson[q]] = dad[q]; -+ lson[q] = lson[p]; dad[lson[p]] = q; -+ } -+ rson[q] = rson[p]; dad[rson[p]] = q; -+ } -+ dad[q] = dad[p]; -+ if (rson[dad[p]] == p) rson[dad[p]] = q; -+ else lson[dad[p]] = q; -+ dad[p] = NIL; -+} -+ -+/********** Arithmetic Compression **********/ -+ -+/* If you are not familiar with arithmetic compression, you should read -+ I. E. Witten, R. M. Neal, and J. G. Cleary, -+ Communications of the ACM, Vol. 30, pp. 520-540 (1987), -+ from which much have been borrowed. */ -+ -+#define M 15 -+ -+/* Q1 (= 2 to the M) must be sufficiently large, but not so -+ large as the unsigned long 4 * Q1 * (Q1 - 1) overflows. */ -+ -+#define Q1 (1UL << M) -+#define Q2 (2 * Q1) -+#define Q3 (3 * Q1) -+#define Q4 (4 * Q1) -+#define MAX_CUM (Q1 - 1) -+ -+#define N_CHAR (256 - THRESHOLD + F) -+ /* character code = 0, 1, ..., N_CHAR - 1 */ -+ -+static unsigned long char_to_sym[N_CHAR], sym_to_char[N_CHAR + 1]; -+static unsigned long -+ sym_freq[N_CHAR + 1], /* frequency for symbols */ -+ sym_cum[N_CHAR + 1], /* cumulative freq for symbols */ -+ position_cum[N + 1]; /* cumulative freq for positions */ -+ -+static void StartModel(void) /* Initialize model */ -+{ -+ unsigned long ch, sym, i; -+ -+ sym_cum[N_CHAR] = 0; -+ for (sym = N_CHAR; sym >= 1; sym--) { -+ ch = sym - 1; -+ char_to_sym[ch] = sym; sym_to_char[sym] = ch; -+ sym_freq[sym] = 1; -+ sym_cum[sym - 1] = sym_cum[sym] + sym_freq[sym]; -+ } -+ sym_freq[0] = 0; /* sentinel (!= sym_freq[1]) */ -+ position_cum[N] = 0; -+ for (i = N; i >= 1; i--) -+ position_cum[i - 1] = position_cum[i] + 10000 / (i + 200); -+ /* empirical distribution function (quite tentative) */ -+ /* Please devise a better mechanism! */ -+} -+ -+static void UpdateModel(unsigned long sym) -+{ -+ unsigned long c, ch_i, ch_sym; -+ unsigned long i; -+ if (sym_cum[0] >= MAX_CUM) { -+ c = 0; -+ for (i = N_CHAR; i > 0; i--) { -+ sym_cum[i] = c; -+ c += (sym_freq[i] = (sym_freq[i] + 1) >> 1); -+ } -+ sym_cum[0] = c; -+ } -+ for (i = sym; sym_freq[i] == sym_freq[i - 1]; i--) ; -+ if (i < sym) { -+ ch_i = sym_to_char[i]; ch_sym = sym_to_char[sym]; -+ sym_to_char[i] = ch_sym; sym_to_char[sym] = ch_i; -+ char_to_sym[ch_i] = sym; char_to_sym[ch_sym] = i; -+ } -+ sym_freq[i]++; -+ while (--i > 0) sym_cum[i]++; -+ sym_cum[0]++; -+} -+ -+static unsigned long BinarySearchSym(unsigned long x) -+ /* 1 if x >= sym_cum[1], -+ N_CHAR if sym_cum[N_CHAR] > x, -+ i such that sym_cum[i - 1] > x >= sym_cum[i] otherwise */ -+{ -+ unsigned long i, j, k; -+ -+ i = 1; j = N_CHAR; -+ while (i < j) { -+ k = (i + j) / 2; -+ if (sym_cum[k] > x) i = k + 1; else j = k; -+ } -+ return i; -+} -+ -+unsigned long BinarySearchPos(unsigned long x) -+ /* 0 if x >= position_cum[1], -+ N - 1 if position_cum[N] > x, -+ i such that position_cum[i] > x >= position_cum[i + 1] otherwise */ -+{ -+ unsigned long i, j, k; -+ -+ i = 1; j = N; -+ while (i < j) { -+ k = (i + j) / 2; -+ if (position_cum[k] > x) i = k + 1; else j = k; -+ } -+ return i - 1; -+} -+ -+/* modified for block compression */ -+/* on return, srclen will contain the number of successfully compressed bytes -+ and dstlen will contain completed compressed bytes */ -+ -+static int Encode(unsigned char *srcbuf, unsigned char *dstbuf, unsigned long *srclen, -+ unsigned long *dstlen) -+{ -+ unsigned long c, i, len, r, s, last_match_length, sym, range; -+ unsigned long low = 0; -+ unsigned long high = Q4; -+ unsigned long shifts = 0; /* counts for magnifying low and high around Q2 */ -+ unsigned char *ip, *op; -+ unsigned long written = 0; -+ unsigned long read = 0; -+ unsigned char buffer = 0; -+ unsigned char mask = 128; -+ unsigned char *srcend = srcbuf + *srclen; -+ unsigned char *dstend = dstbuf + *dstlen; -+ ip = srcbuf; -+ op = dstbuf; -+ StartModel(); -+ InitTree(); /* initialize trees */ -+ s = 0; r = N - F; -+ for (i = s; i < r; i++) text_buf[i] = ' '; /* Clear the buffer with -+ any character that will appear often. */ -+ for (len = 0; (len < F) && (ip < srcend); len++) -+ text_buf[r + len] = *(ip++); /* Read F bytes into the last F bytes of -+ the buffer */ -+ read = len; -+ for (i = 1; i <= F; i++) InsertNode(r - i); /* Insert the F strings, -+ each of which begins with one or more 'space' characters. Note -+ the order in which these strings are inserted. This way, -+ degenerate trees will be less likely to occur. */ -+ InsertNode(r); /* Finally, insert the whole string just read. The -+ global variables match_length and match_position are set. */ -+ do { -+ if (match_length > len) match_length = len; /* match_length -+ may be spuriously long near the end of text. */ -+ if (match_length <= THRESHOLD) { -+ match_length = 1; /* Not long enough match. Send one byte. */ -+ sym = char_to_sym[text_buf[r]]; -+ range = high - low; -+ high = low + (range * sym_cum[sym - 1]) / sym_cum[0]; -+ low += (range * sym_cum[sym ]) / sym_cum[0]; -+ for ( ; ; ) { -+ if (high <= Q2) { -+ if ((mask >>= 1) == 0) { -+ if (op >= dstend) { -+ *dstlen = written; -+ return -1; -+ } -+ *(op++) = buffer; -+ buffer = 0; -+ mask = 128; -+ written++; -+ *srclen = read; -+ } -+ for ( ; shifts > 0; shifts--) { -+ buffer |= mask; -+ if ((mask >>= 1) == 0) { -+ if (op >= dstend) { -+ *dstlen = written; -+ return -1; -+ } -+ *(op++) = buffer; -+ buffer = 0; -+ mask = 128; -+ written++; -+ *srclen = read; -+ } -+ } -+ } else if (low >= Q2) { -+ buffer |= mask; -+ if ((mask >>= 1) == 0) { -+ if (op >= dstend) { -+ *dstlen = written; -+ return -1; -+ } -+ *(op++) = buffer; -+ buffer = 0; -+ mask = 128; -+ written++; -+ *srclen = read; -+ } -+ for ( ; shifts > 0; shifts--) { -+ if ((mask >>= 1) == 0) { -+ if (op >= dstend) { -+ *dstlen = written; -+ return -1; -+ } -+ *(op++) = buffer; -+ buffer = 0; -+ mask = 128; -+ written++; -+ *srclen = read; -+ } -+ } -+ low -= Q2; -+ high -= Q2; -+ } else if (low >= Q1 && high <= Q3) { -+ shifts++; -+ low -= Q1; -+ high -= Q1; -+ } else break; -+ low += low; high += high; -+ } -+ UpdateModel(sym); -+ } else { -+ sym = char_to_sym[255 - THRESHOLD + match_length]; -+ range = high - low; -+ high = low + (range * sym_cum[sym - 1]) / sym_cum[0]; -+ low += (range * sym_cum[sym ]) / sym_cum[0]; -+ for ( ; ; ) { -+ if (high <= Q2) { -+ if ((mask >>= 1) == 0) { -+ if (op >= dstend) { -+ *dstlen = written; -+ return -1; -+ } -+ *(op++) = buffer; -+ buffer = 0; -+ mask = 128; -+ written++; -+ *srclen = read; -+ } -+ for ( ; shifts > 0; shifts--) { -+ buffer |= mask; -+ if ((mask >>= 1) == 0) { -+ if (op >= dstend) { -+ *dstlen = written; -+ return -1; -+ } -+ *(op++) = buffer; -+ buffer = 0; -+ mask = 128; -+ written++; -+ *srclen = read; -+ } -+ } -+ } else if (low >= Q2) { -+ buffer |= mask; -+ if ((mask >>= 1) == 0) { -+ if (op >= dstend) { -+ *dstlen = written; -+ return -1; -+ } -+ *(op++) = buffer; -+ buffer = 0; -+ mask = 128; -+ written++; -+ *srclen = read; -+ } -+ for ( ; shifts > 0; shifts--) { -+ if ((mask >>= 1) == 0) { -+ if (op >= dstend) { -+ *dstlen = written; -+ return -1; -+ } -+ *(op++) = buffer; -+ buffer = 0; -+ mask = 128; -+ written++; -+ *srclen = read; -+ } -+ } -+ low -= Q2; -+ high -= Q2; -+ } else if (low >= Q1 && high <= Q3) { -+ shifts++; -+ low -= Q1; -+ high -= Q1; -+ } else break; -+ low += low; high += high; -+ } -+ UpdateModel(sym); -+ range = high - low; -+ high = low + (range * position_cum[match_position - 1]) / position_cum[0]; -+ low += (range * position_cum[match_position ]) / position_cum[0]; -+ for ( ; ; ) { -+ if (high <= Q2) { -+ if ((mask >>= 1) == 0) { -+ if (op >= dstend) { -+ *dstlen = written; -+ return -1; -+ } -+ *(op++) = buffer; -+ buffer = 0; -+ mask = 128; -+ written++; -+ *srclen = read; -+ } -+ for ( ; shifts > 0; shifts--) { -+ buffer |= mask; -+ if ((mask >>= 1) == 0) { -+ if (op >= dstend) { -+ *dstlen = written; -+ return -1; -+ } -+ *(op++) = buffer; -+ buffer = 0; -+ mask = 128; -+ written++; -+ *srclen = read; -+ } -+ } -+ } else { -+ if (low >= Q2) { -+ buffer |= mask; -+ if ((mask >>= 1) == 0) { -+ if (op >= dstend) { -+ *dstlen = written; -+ return -1; -+ } -+ *(op++) = buffer; -+ buffer = 0; -+ mask = 128; -+ written++; -+ *srclen = read; -+ } -+ for ( ; shifts > 0; shifts--) { -+ if ((mask >>= 1) == 0) { -+ if (op >= dstend) { -+ *dstlen = written; -+ return -1; -+ } -+ *(op++) = buffer; -+ buffer = 0; -+ mask = 128; -+ written++; -+ *srclen = read; -+ } -+ } -+ low -= Q2; -+ high -= Q2; -+ } else { -+ if ((low >= Q1) && (high <= Q3)) { -+ shifts++; -+ low -= Q1; -+ high -= Q1; -+ } else { -+ break; -+ } -+ } -+ } -+ low += low; -+ high += high; -+ } -+ } -+ last_match_length = match_length; -+ for (i = 0; (i < last_match_length) && (ip < srcend); i++) { -+ c = *(ip++); -+ DeleteNode(s); -+ text_buf[s] = c; -+ if (s < F - 1) -+ text_buf[s + N] = c; -+ s = (s + 1) & (N - 1); -+ r = (r + 1) & (N - 1); -+ InsertNode(r); -+ } -+ read += i; -+ while (i++ < last_match_length) { -+ DeleteNode(s); -+ s = (s + 1) & (N - 1); -+ r = (r + 1) & (N - 1); -+ if (--len) InsertNode(r); -+ } -+ } while (len > 0); -+ shifts++; -+ if (low < Q1) { -+ if ((mask >>= 1) == 0) { -+ if (op >= dstend) { -+ *dstlen = written; -+ return -1; -+ } -+ *(op++) = buffer; -+ buffer = 0; -+ mask = 128; -+ written++; -+ *srclen = read; -+ } -+ for ( ; shifts > 0; shifts--) { -+ buffer |= mask; -+ if ((mask >>= 1) == 0) { -+ if (op >= dstend) { -+ *dstlen = written; -+ return -1; -+ } -+ *(op++) = buffer; -+ buffer = 0; -+ mask = 128; -+ written++; -+ *srclen = read; -+ } -+ } -+ } else { -+ buffer |= mask; -+ if ((mask >>= 1) == 0) { -+ if (op >= dstend) { -+ *dstlen = written; -+ return -1; -+ } -+ *(op++) = buffer; -+ buffer = 0; -+ mask = 128; -+ written++; -+ *srclen = read; -+ } -+ for ( ; shifts > 0; shifts--) { -+ if ((mask >>= 1) == 0) { -+ if (op >= dstend) { -+ *dstlen = written; -+ return -1; -+ } -+ *(op++) = buffer; -+ buffer = 0; -+ mask = 128; -+ written++; -+ *srclen = read; -+ } -+ } -+ } -+ for (i = 0; i < 7; i++) { -+ if ((mask >>= 1) == 0) { -+ if (op >= dstend) { -+ *dstlen = written; -+ return -1; -+ } -+ *(op++) = buffer; -+ buffer = 0; -+ mask = 128; -+ written++; -+ *srclen = read; -+ } -+ } -+ *dstlen = written; -+ return 0; -+} -+ -+static int Decode(unsigned char *srcbuf, unsigned char *dstbuf, unsigned long srclen, -+ unsigned long dstlen) /* Just the reverse of Encode(). */ -+{ -+ unsigned long i, r, j, k, c, range, sym; -+ unsigned char *ip, *op; -+ unsigned char *srcend = srcbuf + srclen; -+ unsigned char *dstend = dstbuf + dstlen; -+ unsigned char buffer = 0; -+ unsigned char mask = 0; -+ unsigned long low = 0; -+ unsigned long high = Q4; -+ unsigned long value = 0; -+ ip = srcbuf; -+ op = dstbuf; -+ for (i = 0; i < M + 2; i++) { -+ value *= 2; -+ if ((mask >>= 1) == 0) { -+ buffer = (ip >= srcend) ? 0 : *(ip++); -+ mask = 128; -+ } -+ value += ((buffer & mask) != 0); -+ } -+ StartModel(); -+ for (i = 0; i < N - F; i++) text_buf[i] = ' '; -+ r = N - F; -+ while (op < dstend) { -+ range = high - low; -+ sym = BinarySearchSym((unsigned long) -+ (((value - low + 1) * sym_cum[0] - 1) / range)); -+ high = low + (range * sym_cum[sym - 1]) / sym_cum[0]; -+ low += (range * sym_cum[sym ]) / sym_cum[0]; -+ for ( ; ; ) { -+ if (low >= Q2) { -+ value -= Q2; low -= Q2; high -= Q2; -+ } else if (low >= Q1 && high <= Q3) { -+ value -= Q1; low -= Q1; high -= Q1; -+ } else if (high > Q2) break; -+ low += low; high += high; -+ value *= 2; -+ if ((mask >>= 1) == 0) { -+ buffer = (ip >= srcend) ? 0 : *(ip++); -+ mask = 128; -+ } -+ value += ((buffer & mask) != 0); -+ } -+ c = sym_to_char[sym]; -+ UpdateModel(sym); -+ if (c < 256) { -+ if (op >= dstend) return -1; -+ *(op++) = c; -+ text_buf[r++] = c; -+ r &= (N - 1); -+ } else { -+ j = c - 255 + THRESHOLD; -+ range = high - low; -+ i = BinarySearchPos((unsigned long) -+ (((value - low + 1) * position_cum[0] - 1) / range)); -+ high = low + (range * position_cum[i ]) / position_cum[0]; -+ low += (range * position_cum[i + 1]) / position_cum[0]; -+ for ( ; ; ) { -+ if (low >= Q2) { -+ value -= Q2; low -= Q2; high -= Q2; -+ } else if (low >= Q1 && high <= Q3) { -+ value -= Q1; low -= Q1; high -= Q1; -+ } else if (high > Q2) break; -+ low += low; high += high; -+ value *= 2; -+ if ((mask >>= 1) == 0) { -+ buffer = (ip >= srcend) ? 0 : *(ip++); -+ mask = 128; -+ } -+ value += ((buffer & mask) != 0); -+ } -+ i = (r - i - 1) & (N - 1); -+ for (k = 0; k < j; k++) { -+ c = text_buf[(i + k) & (N - 1)]; -+ if (op >= dstend) return -1; -+ *(op++) = c; -+ text_buf[r++] = c; -+ r &= (N - 1); -+ } -+ } -+ } -+ return 0; -+} -+ -+/* interface to jffs2 bbc follows */ -+ -+#include "jffs2_bbc_framework.h" -+ -+#define JFFS2_BBC_LZARI_BLOCK_SIGN {0x73, 0x9a, 0x1c, 0x4d} -+ -+static int -+jffs2_bbc_lzari_compressor_init (void); -+ -+static void -+jffs2_bbc_lzari_compressor_deinit (void); -+ -+static int -+jffs2_bbc_lzari_compress (void *model, unsigned char *input, -+ unsigned char *output, unsigned long *sourcelen, -+ unsigned long *dstlen); -+ -+static int -+jffs2_bbc_lzari_estimate (void *model, unsigned char *input, -+ unsigned long sourcelen, unsigned long *dstlen, -+ unsigned long *readtime, unsigned long *writetime); -+ -+static int -+jffs2_bbc_lzari_decompress (void *model, unsigned char *input, -+ unsigned char *output, unsigned long sourcelen, -+ unsigned long dstlen); -+ -+static char * -+jffs2_bbc_lzari_proc_info (void); -+ -+static int -+jffs2_bbc_lzari_proc_command (char *command); -+ -+struct jffs2_bbc_compressor_type jffs2_bbc_lzari = { -+ "lzari", -+ 0, -+ JFFS2_BBC_LZARI_BLOCK_SIGN, -+ jffs2_bbc_lzari_compressor_init, -+ NULL, -+ NULL, -+ jffs2_bbc_lzari_compressor_deinit, -+ jffs2_bbc_lzari_compress, -+ jffs2_bbc_lzari_estimate, -+ jffs2_bbc_lzari_decompress, -+ jffs2_bbc_lzari_proc_info, -+ jffs2_bbc_lzari_proc_command -+}; -+ -+static int -+jffs2_bbc_lzari_compressor_init (void) -+{ -+ return 0; -+} -+ -+static void -+jffs2_bbc_lzari_compressor_deinit (void) -+{ -+} -+ -+static int -+jffs2_bbc_lzari_compress (void *model, unsigned char *input, -+ unsigned char *output, unsigned long *sourcelen, -+ unsigned long *dstlen) -+{ -+ int retval; -+ unsigned long dst = *dstlen; -+ *(output++) = jffs2_bbc_lzari.block_sign[0]; -+ *(output++) = jffs2_bbc_lzari.block_sign[1]; -+ dst -= 2; -+ retval = Encode(input, output, sourcelen, &dst); -+ dst += 2; -+ *dstlen = dst; -+ return retval; -+} -+ -+static int -+jffs2_bbc_lzari_estimate (void *model, unsigned char *input, -+ unsigned long sourcelen, unsigned long *dstlen, -+ unsigned long *readtime, unsigned long *writetime) -+{ -+ *dstlen = sourcelen / 2; -+ *readtime = JFFS2_BBC_ZLIB_READ_TIME * 15; -+ *writetime = JFFS2_BBC_ZLIB_WRITE_TIME * 7; -+ return 0; -+} -+ -+static int -+jffs2_bbc_lzari_decompress (void *model, unsigned char *input, -+ unsigned char *output, unsigned long sourcelen, -+ unsigned long dstlen) -+{ -+ if ( ( *(input++) != (unsigned char)jffs2_bbc_lzari.block_sign[0] ) || -+ ( *(input++) != (unsigned char)jffs2_bbc_lzari.block_sign[1] ) -+ ) { -+ return -1; -+ } else { -+ return Decode(input, output, sourcelen - 2, dstlen); -+ } -+} -+ -+static char * -+jffs2_bbc_lzari_proc_info (void) -+{ -+ return "Lempel-Ziv-Arithmetic coding compression module"; -+} -+ -+static int -+jffs2_bbc_lzari_proc_command (char *command) -+{ -+ return 0; -+} -+ -+struct jffs2_bbc_compressor_type * -+jffs2_bbc_lzari_init (int mode) -+{ -+ if (jffs2_bbc_register_compressor (&jffs2_bbc_lzari) == 0) -+ { -+ return &jffs2_bbc_lzari; -+ } -+ else -+ { -+ return NULL; -+ } -+} -+ -+void -+jffs2_bbc_lzari_deinit (void) -+{ -+ jffs2_bbc_unregister_compressor (&jffs2_bbc_lzari); -+} ---- /dev/null -+++ b/fs/jffs2/jffs2_bbc_lzhd_comp.c -@@ -0,0 +1,747 @@ -+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ -+ -+/* -+ jffs2_bbc_lzhd_comp.c -- Lempel-Ziv-(dynamic) Huffman compression module for jffs2 -+ Copyright (C) 2004 Patrik Kluba -+ Based on the LZHUF source included in LDS (lossless datacompression sources) -+ Block-compression and bitstream modifications by Patrik Kluba -+ $Header: /openwrt/openwrt/package/linux/kernel-patches/301-jffs-compression,v 1.1 2005/03/26 10:33:31 wbx Exp $ -+*/ -+ -+/* -+Original copyright follows: -+ -+************************************************************** -+ lzhuf.c -+ written by Haruyasu Yoshizaki 11/20/1988 -+ some minor changes 4/6/1989 -+ comments translated by Haruhiko Okumura 4/7/1989 -+************************************************************** -+ -+LZHUF.C (c)1989 by Haruyasu Yoshizaki, Haruhiko Okumura, and Kenji Rikitake. -+All rights reserved. Permission granted for non-commercial use. -+ -+*/ -+ -+/* -+ -+ 2004-02-18 pajko <pajko(AT)halom(DOT)u-szeged(DOT)hu> -+ Replaced name lzh-d with lzhd -+ Fixed no return value -+ -+ 2004-02-16 pajko <pajko(AT)halom(DOT)u-szeged(DOT)hu> -+ Initial release -+ -+*/ -+ -+/* required because of memmove */ -+#ifndef __KERNEL__ -+ #include <string.h> -+#else -+ #include <linux/string.h> -+#endif -+ -+/* lzhuf.c */ -+ -+#define N 4096 /* size of ring buffer */ -+#define F 60 /* upper limit for match_length */ -+#define THRESHOLD 2 /* encode string into position and length -+ if match_length is greater than this */ -+#define NIL N /* index for root of binary search trees */ -+ -+static unsigned char -+ text_buf[N + F - 1]; /* ring buffer of size N, -+ with extra F-1 bytes to facilitate string comparison */ -+static unsigned long match_position, match_length, /* of longest match. These are -+ set by the InsertNode() procedure. */ -+ lson[N + 1], rson[N + 257], dad[N + 1]; /* left & right children & -+ parents -- These constitute binary search trees. */ -+ -+static void InitTree(void) /* initialize trees */ -+{ -+ unsigned long i; -+ -+ /* For i = 0 to N - 1, rson[i] and lson[i] will be the right and -+ left children of node i. These nodes need not be initialized. -+ Also, dad[i] is the parent of node i. These are initialized to -+ NIL (= N), which stands for 'not used.' -+ For i = 0 to 255, rson[N + i + 1] is the root of the tree -+ for strings that begin with character i. These are initialized -+ to NIL. Note there are 256 trees. */ -+ -+ for (i = N + 1; i <= N + 256; i++) rson[i] = NIL; -+ for (i = 0; i < N; i++) dad[i] = NIL; -+} -+ -+static void InsertNode(unsigned long r) -+ /* Inserts string of length F, text_buf[r..r+F-1], into one of the -+ trees (text_buf[r]'th tree) and returns the longest-match position -+ and length via the global variables match_position and match_length. -+ If match_length = F, then removes the old node in favor of the new -+ one, because the old one will be deleted sooner. -+ Note r plays double role, as tree node and position in buffer. */ -+{ -+ unsigned long i, p, c; -+ signed long cmp; -+ unsigned char *key; -+ -+ cmp = 1; key = &text_buf[r]; p = N + 1 + key[0]; -+ rson[r] = lson[r] = NIL; match_length = 0; -+ for ( ; ; ) { -+ if (cmp >= 0) { -+ if (rson[p] != NIL) p = rson[p]; -+ else { rson[p] = r; dad[r] = p; return; } -+ } else { -+ if (lson[p] != NIL) p = lson[p]; -+ else { lson[p] = r; dad[r] = p; return; } -+ } -+ for (i = 1; i < F; i++) -+ if ((cmp = key[i] - text_buf[p + i]) != 0) break; -+ if (i > THRESHOLD) { -+ if (i > match_length) { -+ match_position = ((r - p) & (N - 1)) - 1; -+ if ((match_length = i) >= F) break; -+ } -+ if (i == match_length) { -+ if ((c = ((r - p) & (N - 1)) - 1) < match_position) { -+ match_position = c; -+ } -+ } -+ } -+ } -+ dad[r] = dad[p]; lson[r] = lson[p]; rson[r] = rson[p]; -+ dad[lson[p]] = r; dad[rson[p]] = r; -+ if (rson[dad[p]] == p) rson[dad[p]] = r; -+ else lson[dad[p]] = r; -+ dad[p] = NIL; /* remove p */ -+} -+ -+static void DeleteNode(unsigned long p) /* deletes node p from tree */ -+{ -+ unsigned long q; -+ -+ if (dad[p] == NIL) return; /* not in tree */ -+ if (rson[p] == NIL) q = lson[p]; -+ else if (lson[p] == NIL) q = rson[p]; -+ else { -+ q = lson[p]; -+ if (rson[q] != NIL) { -+ do { q = rson[q]; } while (rson[q] != NIL); -+ rson[dad[q]] = lson[q]; dad[lson[q]] = dad[q]; -+ lson[q] = lson[p]; dad[lson[p]] = q; -+ } -+ rson[q] = rson[p]; dad[rson[p]] = q; -+ } -+ dad[q] = dad[p]; -+ if (rson[dad[p]] == p) rson[dad[p]] = q; else lson[dad[p]] = q; -+ dad[p] = NIL; -+} -+ -+/* Huffman coding */ -+ -+#define N_CHAR (256 - THRESHOLD + F) -+ /* kinds of characters (character code = 0..N_CHAR-1) */ -+#define T (N_CHAR * 2 - 1) /* size of table */ -+#define R (T - 1) /* position of root */ -+#define MAX_FREQ 0x8000 /* updates tree when the */ -+ /* root frequency comes to this value. */ -+ -+typedef unsigned long uchar; // much-much faster -+ -+/* table for encoding and decoding the upper 6 bits of position */ -+ -+/* for encoding */ -+static uchar p_len[64] = { -+ 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, -+ 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, -+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, -+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, -+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, -+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, -+ 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, -+ 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 -+}; -+ -+static uchar p_code[64] = { -+ 0x00, 0x20, 0x30, 0x40, 0x50, 0x58, 0x60, 0x68, -+ 0x70, 0x78, 0x80, 0x88, 0x90, 0x94, 0x98, 0x9C, -+ 0xA0, 0xA4, 0xA8, 0xAC, 0xB0, 0xB4, 0xB8, 0xBC, -+ 0xC0, 0xC2, 0xC4, 0xC6, 0xC8, 0xCA, 0xCC, 0xCE, -+ 0xD0, 0xD2, 0xD4, 0xD6, 0xD8, 0xDA, 0xDC, 0xDE, -+ 0xE0, 0xE2, 0xE4, 0xE6, 0xE8, 0xEA, 0xEC, 0xEE, -+ 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, -+ 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF -+}; -+ -+/* for decoding */ -+static uchar d_code[256] = { -+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, -+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, -+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, -+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, -+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, -+ 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, -+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, -+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, -+ 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, -+ 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, -+ 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, -+ 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, -+ 0x0C, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, -+ 0x0E, 0x0E, 0x0E, 0x0E, 0x0F, 0x0F, 0x0F, 0x0F, -+ 0x10, 0x10, 0x10, 0x10, 0x11, 0x11, 0x11, 0x11, -+ 0x12, 0x12, 0x12, 0x12, 0x13, 0x13, 0x13, 0x13, -+ 0x14, 0x14, 0x14, 0x14, 0x15, 0x15, 0x15, 0x15, -+ 0x16, 0x16, 0x16, 0x16, 0x17, 0x17, 0x17, 0x17, -+ 0x18, 0x18, 0x19, 0x19, 0x1A, 0x1A, 0x1B, 0x1B, -+ 0x1C, 0x1C, 0x1D, 0x1D, 0x1E, 0x1E, 0x1F, 0x1F, -+ 0x20, 0x20, 0x21, 0x21, 0x22, 0x22, 0x23, 0x23, -+ 0x24, 0x24, 0x25, 0x25, 0x26, 0x26, 0x27, 0x27, -+ 0x28, 0x28, 0x29, 0x29, 0x2A, 0x2A, 0x2B, 0x2B, -+ 0x2C, 0x2C, 0x2D, 0x2D, 0x2E, 0x2E, 0x2F, 0x2F, -+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, -+ 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, -+}; -+ -+static uchar d_len[256] = { -+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, -+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, -+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, -+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, -+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, -+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, -+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, -+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, -+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, -+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, -+ 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, -+ 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, -+ 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, -+ 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, -+ 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, -+ 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, -+ 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, -+ 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, -+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, -+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, -+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, -+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, -+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, -+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, -+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, -+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, -+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, -+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, -+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, -+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, -+ 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, -+ 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, -+}; -+ -+static unsigned long freq[T + 1]; /* frequency table */ -+ -+static unsigned long prnt[T + N_CHAR]; /* pointers to parent nodes, except for the */ -+ /* elements [T..T + N_CHAR - 1] which are used to get */ -+ /* the positions of leaves corresponding to the codes. */ -+ -+static unsigned long son[T]; /* pointers to child nodes (son[], son[] + 1) */ -+ -+/* initialization of tree */ -+ -+static void StartHuff(void) -+{ -+ unsigned long i, j; -+ -+ for (i = 0; i < N_CHAR; i++) { -+ freq[i] = 1; -+ son[i] = i + T; -+ prnt[i + T] = i; -+ } -+ i = 0; j = N_CHAR; -+ while (j <= R) { -+ freq[j] = freq[i] + freq[i + 1]; -+ son[j] = i; -+ prnt[i] = prnt[i + 1] = j; -+ i += 2; j++; -+ } -+ freq[T] = 0xffff; -+ prnt[R] = 0; -+} -+ -+/* reconstruction of tree */ -+ -+static void reconst(void) -+{ -+ unsigned long f, l, i, j, k; -+ -+ /* collect leaf nodes in the first half of the table */ -+ /* and replace the freq by (freq + 1) / 2. */ -+ j = 0; -+ for (i = 0; i < T; i++) { -+ if (son[i] >= T) { -+ freq[j] = (freq[i] + 1) / 2; -+ son[j] = son[i]; -+ j++; -+ } -+ } -+ /* begin constructing tree by connecting sons */ -+ for (i = 0, j = N_CHAR; j < T; i += 2, j++) { -+ k = i + 1; -+ f = freq[j] = freq[i] + freq[k]; -+ for (k = j - 1; f < freq[k]; k--); -+ k++; -+ l = (j - k) * 2; -+ memmove(&freq[k + 1], &freq[k], l*sizeof(unsigned long)); -+ freq[k] = f; -+ memmove(&son[k + 1], &son[k], l*sizeof(unsigned long)); -+ son[k] = i; -+ } -+ /* connect prnt */ -+ for (i = 0; i < T; i++) { -+ if ((k = son[i]) >= T) { -+ prnt[k] = i; -+ } else { -+ prnt[k] = prnt[k + 1] = i; -+ } -+ } -+} -+ -+/* increment frequency of given code by one, and update tree */ -+ -+static void update(unsigned long c) -+{ -+ unsigned long i, j, k, l; -+ -+ if (freq[R] == MAX_FREQ) { -+ reconst(); -+ } -+ c = prnt[c + T]; -+ do { -+ k = ++freq[c]; -+ -+ /* if the order is disturbed, exchange nodes */ -+ if (k > freq[l = c + 1]) { -+ while (k > freq[++l]); -+ l--; -+ freq[c] = freq[l]; -+ freq[l] = k; -+ -+ i = son[c]; -+ prnt[i] = l; -+ if (i < T) prnt[i + 1] = l; -+ -+ j = son[l]; -+ son[l] = i; -+ -+ prnt[j] = c; -+ if (j < T) prnt[j + 1] = c; -+ son[c] = j; -+ -+ c = l; -+ } -+ } while (c = prnt[c]); /* repeat up to root */ -+} -+ -+/* modified for block compression */ -+/* on return, srclen will contain the number of successfully compressed bytes -+ and dstlen will contain completed compressed bytes */ -+ -+static int Encode(unsigned char *srcbuf, unsigned char *dstbuf, unsigned long *srclen, -+ unsigned long *dstlen) -+{ -+ unsigned long c, i, j, k, len, r, s, last_match_length, code_buf_ptr; -+ unsigned char code_buf[17], mask; -+ unsigned char *ip, *op; -+ unsigned long written = 0; -+ unsigned long read = 0; -+ unsigned short putbuf = 0; -+ uchar putlen = 0; -+ unsigned char *srcend = srcbuf + *srclen; -+ unsigned char *dstend = dstbuf + *dstlen; -+ ip = srcbuf; -+ op = dstbuf; -+ StartHuff(); -+ InitTree(); /* initialize trees */ -+ code_buf[0] = 0; /* code_buf[1..16] saves eight units of code, and -+ code_buf[0] works as eight flags, "1" representing that the unit -+ is an unencoded letter (1 byte), "0" a position-and-length pair -+ (2 bytes). Thus, eight units require at most 16 bytes of code. */ -+ code_buf_ptr = mask = 1; -+ s = 0; r = N - F; -+ for (i = s; i < r; i++) text_buf[i] = ' '; /* Clear the buffer with -+ any character that will appear often. */ -+ for (len = 0; (len < F) && (ip < srcend); len++) -+ text_buf[r + len] = *(ip++); /* Read F bytes into the last F bytes of -+ the buffer */ -+ read = len; -+ for (i = 1; i <= F; i++) InsertNode(r - i); /* Insert the F strings, -+ each of which begins with one or more 'space' characters. Note -+ the order in which these strings are inserted. This way, -+ degenerate trees will be less likely to occur. */ -+ InsertNode(r); /* Finally, insert the whole string just read. The -+ global variables match_length and match_position are set. */ -+ do { -+ if (match_length > len) match_length = len; /* match_length -+ may be spuriously long near the end of text. */ -+ if (match_length <= THRESHOLD) { -+ match_length = 1; /* Not long enough match. Send one byte. */ -+ c = text_buf[r]; -+ i = 0; j = 0; k = prnt[c + T]; -+ do { -+ i >>= 1; -+ /* if node's address is odd-numbered, choose bigger brother node */ -+ if (k & 1) i |= 0x8000; -+ j++; -+ } while ((k = prnt[k]) != R); -+ putbuf |= i >> putlen; -+ if ((putlen += j) >= 8) { -+ if (op >= dstend) { -+ *dstlen = written; -+ return -1; -+ } -+ *(op++) = putbuf >> 8; -+ if ((putlen -= 8) >= 8) { -+ if (op >= dstend) { -+ *dstlen = written; -+ return -1; -+ } -+ *(op++) = putbuf; -+ written += 2; -+ putlen -= 8; -+ putbuf = i << (j - putlen); /**warm**/ -+ } else { -+ putbuf <<= 8; -+ written++; -+ } -+ *srclen = read; -+ } -+ update(c); -+ } else { -+ c = 255 - THRESHOLD + match_length; -+ i = 0; j = 0; k = prnt[c + T]; -+ do { -+ i >>= 1; -+ /* if node's address is odd-numbered, choose bigger brother node */ -+ if (k & 1) i |= 0x8000; -+ j++; -+ } while ((k = prnt[k]) != R); -+ putbuf |= i >> putlen; -+ if ((putlen += j) >= 8) { -+ if (op >= dstend) { -+ *dstlen = written; -+ return -1; -+ } -+ *(op++) = putbuf >> 8; -+ if ((putlen -= 8) >= 8) { -+ if (op >= dstend) { -+ *dstlen = written; -+ return -1; -+ } -+ *(op++) = putbuf; -+ written += 2; -+ putlen -= 8; -+ putbuf = i << (j - putlen); /**warm**/ -+ } else { -+ putbuf <<= 8; -+ written++; -+ } -+ *srclen = read; -+ } -+ update(c); -+ j = p_len[match_position >> 6]; -+ i = p_code[match_position >> 6] << 8; -+ putbuf |= i >> putlen; -+ if ((putlen += j) >= 8) { -+ if (op >= dstend) { -+ *dstlen = written; -+ return -1; -+ } -+ *(op++) = putbuf >> 8; -+ if ((putlen -= 8) >= 8) { -+ if (op >= dstend) { -+ *dstlen = written; -+ return -1; -+ } -+ *(op++) = putbuf; -+ written += 2; -+ putlen -= 8; -+ putbuf = i << (j - putlen); /**hot**/ -+ } else { -+ putbuf <<= 8; -+ written++; -+ } -+ *srclen = read; -+ } -+ j = 6; -+ i = (match_position & 0x3f) << 10; -+ putbuf |= i >> putlen; -+ if ((putlen += j) >= 8) { -+ if (op >= dstend) { -+ *dstlen = written; -+ return -1; -+ } -+ *(op++) = putbuf >> 8; -+ if ((putlen -= 8) >= 8) { -+ if (op >= dstend) { -+ *dstlen = written; -+ return -1; -+ } -+ *(op++) = putbuf; -+ written += 2; -+ putlen -= 8; -+ putbuf = i << (j - putlen); /**hot**/ -+ } else { -+ putbuf <<= 8; -+ written++; -+ } -+ *srclen = read; -+ } -+ } -+ last_match_length = match_length; -+ for (i = 0; (i < last_match_length) && (ip < srcend); i++) { -+ c = *(ip++); -+ DeleteNode(s); -+ text_buf[s] = c; -+ if (s < F - 1) -+ text_buf[s + N] = c; -+ s = (s + 1) & (N - 1); -+ r = (r + 1) & (N - 1); -+ InsertNode(r); -+ } -+ read += i; -+ while (i++ < last_match_length) { -+ DeleteNode(s); -+ s = (s + 1) & (N - 1); -+ r = (r + 1) & (N - 1); -+ if (--len) InsertNode(r); -+ } -+ } while (len > 0); -+ if (putlen) { -+ if (op >= dstend) { -+ *dstlen = written; -+ return -1; -+ } -+ *(op++) = putbuf >> 8; -+ written++; -+ *srclen = read; -+ } -+ *dstlen = written; -+ return 0; -+} -+ -+static int Decode(unsigned char *srcbuf, unsigned char *dstbuf, unsigned long srclen, -+ unsigned long dstlen) /* Just the reverse of Encode(). */ -+{ -+ unsigned long i, r, j, k, c; -+ unsigned char *ip, *op; -+ unsigned char *srcend = srcbuf + srclen; -+ unsigned char *dstend = dstbuf + dstlen; -+ unsigned short getbuf = 0; -+ uchar getlen = 0; -+ ip = srcbuf; -+ op = dstbuf; -+ StartHuff(); -+ for (i = 0; i < N - F; i++) text_buf[i] = ' '; -+ r = N - F; -+ while (op < dstend) { -+ c = son[R]; -+ /* travel from root to leaf, */ -+ /* choosing the smaller child node (son[]) if the read bit is 0, */ -+ /* the bigger (son[]+1} if 1 */ -+ while (c < T) { -+ while (getlen <= 8) { -+ unsigned short t; -+ t = (ip >= srcend) ? 0 : *(ip++); -+ getbuf |= t << (8 - getlen); -+ getlen += 8; -+ } -+ c += ((signed short)getbuf < 0); -+ getbuf <<= 1; -+ getlen--; -+ c = son[c]; -+ } -+ c -= T; -+ update(c); -+ if (c < 256) { -+ if (op >= dstend) return -1; -+ *(op++) = c; -+ text_buf[r++] = c; -+ r &= (N - 1); -+ } else { -+ j = c - 255 + THRESHOLD; -+ while (getlen <= 8) { -+ unsigned short t; -+ t = (ip >= srcend) ? 0 : *(ip++); -+ getbuf |= t << (8 - getlen); -+ getlen += 8; -+ } -+ i = getbuf >> 8; -+ getbuf <<= 8; -+ getlen -= 8; -+ c = d_code[i] << 6; -+ k = d_len[i]; -+ /* read lower 6 bits verbatim */ -+ k -= 2; -+ while (k--) { -+ while (getlen <= 8) { -+ unsigned short t; -+ t = (ip >= srcend) ? 0 : *(ip++); -+ getbuf |= t << (8 - getlen); -+ getlen += 8; -+ } -+ i = (i << 1) + ((signed short)getbuf < 0); -+ getbuf <<= 1; -+ getlen--; -+ } -+ i = c | (i & 0x3F); -+ i = r - i - 1; -+ i &= (N - 1); -+ for (k = 0; k < j; k++) { -+ c = text_buf[(i + k) & (N - 1)]; -+ if (op >= dstend) return -1; -+ *(op++) = c; -+ text_buf[r++] = c; -+ r &= (N - 1); -+ } -+ } -+ } -+ return 0; -+} -+ -+/* interface to jffs2 bbc follows */ -+ -+#include "jffs2_bbc_framework.h" -+ -+ -+#define JFFS2_BBC_LZHD_BLOCK_SIGN {0x3a, 0x98, 0xf7, 0xda} -+ -+static int -+jffs2_bbc_lzhd_compressor_init (void); -+ -+static void -+jffs2_bbc_lzhd_compressor_deinit (void); -+ -+static int -+jffs2_bbc_lzhd_compress (void *model, unsigned char *input, -+ unsigned char *output, unsigned long *sourcelen, -+ unsigned long *dstlen); -+ -+static int -+jffs2_bbc_lzhd_estimate (void *model, unsigned char *input, -+ unsigned long sourcelen, unsigned long *dstlen, -+ unsigned long *readtime, unsigned long *writetime); -+ -+static int -+jffs2_bbc_lzhd_decompress (void *model, unsigned char *input, -+ unsigned char *output, unsigned long sourcelen, -+ unsigned long dstlen); -+ -+static char * -+jffs2_bbc_lzhd_proc_info (void); -+ -+static int -+jffs2_bbc_lzhd_proc_command (char *command); -+ -+struct jffs2_bbc_compressor_type jffs2_bbc_lzhd = { -+ "lzhd", -+ 0, -+ JFFS2_BBC_LZHD_BLOCK_SIGN, -+ jffs2_bbc_lzhd_compressor_init, -+ NULL, -+ NULL, -+ jffs2_bbc_lzhd_compressor_deinit, -+ jffs2_bbc_lzhd_compress, -+ jffs2_bbc_lzhd_estimate, -+ jffs2_bbc_lzhd_decompress, -+ jffs2_bbc_lzhd_proc_info, -+ jffs2_bbc_lzhd_proc_command -+}; -+ -+static int -+jffs2_bbc_lzhd_compressor_init (void) -+{ -+ return 0; -+} -+ -+static void -+jffs2_bbc_lzhd_compressor_deinit (void) -+{ -+} -+ -+static int -+jffs2_bbc_lzhd_compress (void *model, unsigned char *input, -+ unsigned char *output, unsigned long *sourcelen, -+ unsigned long *dstlen) -+{ -+ int retval; -+ unsigned long dst = *dstlen; -+ *(output++) = jffs2_bbc_lzhd.block_sign[0]; -+ *(output++) = jffs2_bbc_lzhd.block_sign[1]; -+ dst -= 2; -+ retval = Encode(input, output, sourcelen, &dst); -+ dst += 2; -+ *dstlen = dst; -+ return retval; -+} -+ -+static int -+jffs2_bbc_lzhd_estimate (void *model, unsigned char *input, -+ unsigned long sourcelen, unsigned long *dstlen, -+ unsigned long *readtime, unsigned long *writetime) -+{ -+ *dstlen = sourcelen * 55 / 100; -+ *readtime = JFFS2_BBC_ZLIB_READ_TIME * 8; -+ *writetime = JFFS2_BBC_ZLIB_WRITE_TIME * 65 / 10; -+ return 0; -+} -+ -+static int -+jffs2_bbc_lzhd_decompress (void *model, unsigned char *input, -+ unsigned char *output, unsigned long sourcelen, -+ unsigned long dstlen) -+{ -+ if ( ( *(input++) != (unsigned char)jffs2_bbc_lzhd.block_sign[0] ) || -+ ( *(input++) != (unsigned char)jffs2_bbc_lzhd.block_sign[1] ) -+ ) { -+ return -1; -+ } else { -+ return Decode(input, output, sourcelen - 2, dstlen); -+ } -+} -+ -+static char * -+jffs2_bbc_lzhd_proc_info (void) -+{ -+ return "Lempel-Ziv-(dynamic) Huffman compression module"; -+} -+ -+static int -+jffs2_bbc_lzhd_proc_command (char *command) -+{ -+ return 0; -+} -+ -+struct jffs2_bbc_compressor_type * -+jffs2_bbc_lzhd_init (int mode) -+{ -+ if (jffs2_bbc_register_compressor (&jffs2_bbc_lzhd) == 0) -+ { -+ return &jffs2_bbc_lzhd; -+ } -+ else -+ { -+ return NULL; -+ } -+} -+ -+void -+jffs2_bbc_lzhd_deinit (void) -+{ -+ jffs2_bbc_unregister_compressor (&jffs2_bbc_lzhd); -+} ---- /dev/null -+++ b/fs/jffs2/jffs2_bbc_lzo_comp.c -@@ -0,0 +1,2435 @@ -+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ -+ -+/* -+ jffs2_bbc_lzo_comp.c -- LZO1X-1 (and -999) compression module for jffs2 -+ Copyright (C) 2004 Patrik Kluba -+ Based on the original LZO sources -+ $Header: /openwrt/openwrt/package/linux/kernel-patches/301-jffs-compression,v 1.1 2005/03/26 10:33:31 wbx Exp $ -+*/ -+ -+/* -+ Original copyright notice follows: -+ -+ lzo1x_9x.c -- implementation of the LZO1X-999 compression algorithm -+ lzo_ptr.h -- low-level pointer constructs -+ lzo_swd.ch -- sliding window dictionary -+ lzoconf.h -- configuration for the LZO real-time data compression library -+ lzo_mchw.ch -- matching functions using a window -+ minilzo.c -- mini subset of the LZO real-time data compression library -+ config1x.h -- configuration for the LZO1X algorithm -+ lzo1x.h -- public interface of the LZO1X compression algorithm -+ -+ These files are part of the LZO real-time data compression library. -+ -+ Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer -+ All Rights Reserved. -+ -+ The LZO library 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. -+ -+ The LZO 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 General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with the LZO library; see the file COPYING. -+ If not, write to the Free Software Foundation, Inc., -+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+ -+ Markus F.X.J. Oberhumer -+ <markus@oberhumer.com> -+*/ -+ -+/* -+ -+ 2004-02-16 pajko <pajko(AT)halom(DOT)u-szeged(DOT)hu> -+ Initial release -+ -removed all 16 bit code -+ -all sensitive data will be on 4 byte boundary -+ -removed check parts for library use -+ -removed all but LZO1X-* compression -+ -+*/ -+ -+#ifndef __KERNEL__ -+ #include <sys/types.h> -+ #include <stddef.h> -+ #include <string.h> -+ #include <limits.h> -+#else -+ #include <linux/kernel.h> -+ #include <linux/types.h> -+ #include <linux/stddef.h> -+ #include <linux/string.h> -+ #define USHRT_MAX 65535 -+ /* #define UINT_MAX 4294967295U */ -+#endif -+ -+/* data type definitions */ -+#define U32 unsigned long -+#define S32 signed long -+#define I32 long -+#define U16 unsigned short -+#define S16 signed short -+#define I16 short -+#define U8 unsigned char -+#define S8 signed char -+#define I8 char -+ -+/*************************************/ -+ -+/* lzo_swd.ch */ -+ -+#define SWD_N N -+#define SWD_F F -+#define SWD_THRESHOLD THRESHOLD -+ -+/* shortest unsigned int that 2 * SWD_F + SWD_N (currently 53248) fits in */ -+typedef unsigned short swd_uint; -+/* upper limit of that data type */ -+#define SWD_UINT_MAX USHRT_MAX -+ -+/* minilzo.c */ -+ -+#define LZO_VERSION_DATE "Jul 12 2002" -+#define LZO_VERSION_STRING "1.08" -+#define LZO_VERSION 0x1080 -+ -+/* lzo_ptr.h */ -+ -+/* Integral types that have *exactly* the same number of bits as a lzo_voidp */ -+typedef unsigned long lzo_ptr_t; -+typedef long lzo_sptr_t; -+ -+ -+/*************************************/ -+ -+/* config1x.h */ -+ -+#define M1_MAX_OFFSET 0x0400 -+#define M2_MAX_OFFSET 0x0800 -+#define M3_MAX_OFFSET 0x4000 -+#define M4_MAX_OFFSET 0xbfff -+ -+#define MX_MAX_OFFSET (M1_MAX_OFFSET + M2_MAX_OFFSET) -+ -+#define M1_MIN_LEN 2 -+#define M1_MAX_LEN 2 -+#define M2_MIN_LEN 3 -+#define M2_MAX_LEN 8 -+#define M3_MIN_LEN 3 -+#define M3_MAX_LEN 33 -+#define M4_MIN_LEN 3 -+#define M4_MAX_LEN 9 -+ -+#define M1_MARKER 0 -+#define M2_MARKER 64 -+#define M3_MARKER 32 -+#define M4_MARKER 16 -+ -+#define MIN_LOOKAHEAD (M2_MAX_LEN + 1) -+ -+/* minilzo.c */ -+ -+#define LZO_BYTE(x) ((unsigned char) ((x) & 0xff)) -+ -+#define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b)) -+#define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b)) -+#define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c)) -+#define LZO_MIN3(a,b,c) ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c)) -+ -+#define lzo_sizeof(type) ((lzo_uint) (sizeof(type))) -+ -+#define LZO_HIGH(array) ((lzo_uint) (sizeof(array)/sizeof(*(array)))) -+ -+#define LZO_SIZE(bits) (1u << (bits)) -+#define LZO_MASK(bits) (LZO_SIZE(bits) - 1) -+ -+#define LZO_LSIZE(bits) (1ul << (bits)) -+#define LZO_LMASK(bits) (LZO_LSIZE(bits) - 1) -+ -+#define LZO_USIZE(bits) ((lzo_uint) 1 << (bits)) -+#define LZO_UMASK(bits) (LZO_USIZE(bits) - 1) -+ -+#define LZO_STYPE_MAX(b) (((1l << (8*(b)-2)) - 1l) + (1l << (8*(b)-2))) -+#define LZO_UTYPE_MAX(b) (((1ul << (8*(b)-1)) - 1ul) + (1ul << (8*(b)-1))) -+ -+#define _LZO_STRINGIZE(x) #x -+#define _LZO_MEXPAND(x) _LZO_STRINGIZE(x) -+ -+#define _LZO_CONCAT2(a,b) a ## b -+#define _LZO_CONCAT3(a,b,c) a ## b ## c -+#define _LZO_CONCAT4(a,b,c,d) a ## b ## c ## d -+#define _LZO_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e -+ -+#define _LZO_ECONCAT2(a,b) _LZO_CONCAT2(a,b) -+#define _LZO_ECONCAT3(a,b,c) _LZO_CONCAT3(a,b,c) -+#define _LZO_ECONCAT4(a,b,c,d) _LZO_CONCAT4(a,b,c,d) -+#define _LZO_ECONCAT5(a,b,c,d,e) _LZO_CONCAT5(a,b,c,d,e) -+ -+#define lzo_dict_t const lzo_bytep -+#define lzo_dict_p lzo_dict_t * -+#define lzo_moff_t lzo_uint -+ -+#define MEMCPY8_DS(dest,src,len) \ -+ memcpy(dest,src,len); \ -+ dest += len; \ -+ src += len -+ -+#define MEMCPY_DS(dest,src,len) \ -+ do *dest++ = *src++; \ -+ while (--len > 0) -+ -+#define MEMMOVE_DS(dest,src,len) \ -+ do *dest++ = *src++; \ -+ while (--len > 0) -+ -+#define BZERO8_PTR(s,l,n) memset((s),0,(lzo_uint)(l)*(n)) -+ -+#define LZO_BASE 65521u -+#define LZO_NMAX 5552 -+ -+#define LZO_DO1(buf,i) {s1 += buf[i]; s2 += s1;} -+#define LZO_DO2(buf,i) LZO_DO1(buf,i); LZO_DO1(buf,i+1); -+#define LZO_DO4(buf,i) LZO_DO2(buf,i); LZO_DO2(buf,i+2); -+#define LZO_DO8(buf,i) LZO_DO4(buf,i); LZO_DO4(buf,i+4); -+#define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8); -+ -+#define IS_SIGNED(type) (((type) (-1)) < ((type) 0)) -+#define IS_UNSIGNED(type) (((type) (-1)) > ((type) 0)) -+ -+#define IS_POWER_OF_2(x) (((x) & ((x) - 1)) == 0) -+ -+#define D_BITS 14 -+#define D_INDEX1(d,p) d = DM((0x21*DX3(p,5,5,6)) >> 5) -+#define D_INDEX2(d,p) d = (d & (D_MASK & 0x7ff)) ^ (D_HIGH | 0x1f) -+ -+#define LZO_HASH LZO_HASH_LZO_INCREMENTAL_B -+ -+#define DL_MIN_LEN M2_MIN_LEN -+ -+#define D_SIZE LZO_SIZE(D_BITS) -+#define D_MASK LZO_MASK(D_BITS) -+ -+#define D_HIGH ((D_MASK >> 1) + 1) -+ -+#define DINDEX1 D_INDEX1 -+#define DINDEX2 D_INDEX2 -+ -+#define DX2(p,s1,s2) \ -+ (((((lzo_uint32)((p)[2]) << (s2)) ^ (p)[1]) << (s1)) ^ (p)[0]) -+ -+#define DX3(p,s1,s2,s3) ((DX2((p)+1,s2,s3) << (s1)) ^ (p)[0]) -+#define DMS(v,s) ((lzo_uint) (((v) & (D_MASK >> (s))) << (s))) -+#define DM(v) DMS(v,0) -+ -+#define DENTRY(p,in) (p) -+#define GINDEX(m_pos,m_off,dict,dindex,in) m_pos = dict[dindex] -+ -+#define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \ -+ (m_pos == NULL || (m_off = (lzo_moff_t) (ip - m_pos)) > max_offset) -+ -+#define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \ -+ (BOUNDS_CHECKING_OFF_IN_EXPR( \ -+ (PTR_LT(m_pos,in) || \ -+ (m_off = (lzo_moff_t) PTR_DIFF(ip,m_pos)) <= 0 || \ -+ m_off > max_offset) )) -+ -+#define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr) -+ -+#define DD_BITS 0 -+#define DD_SIZE LZO_SIZE(DD_BITS) -+#define DD_MASK LZO_MASK(DD_BITS) -+ -+#define DL_BITS (D_BITS - DD_BITS) -+#define DL_SIZE LZO_SIZE(DL_BITS) -+#define DL_MASK LZO_MASK(DL_BITS) -+ -+#define UPDATE_D(dict,drun,dv,p,in) dict[ DINDEX(dv,p) ] = DENTRY(p,in) -+#define UPDATE_I(dict,drun,index,p,in) dict[index] = DENTRY(p,in) -+#define UPDATE_P(ptr,drun,p,in) (ptr)[0] = DENTRY(p,in) -+ -+#define __COPY4(dst,src) * (lzo_uint32p)(dst) = * (const lzo_uint32p)(src) -+#define COPY4(dst,src) __COPY4((lzo_ptr_t)(dst),(lzo_ptr_t)(src)) -+ -+#define TEST_IP (ip < ip_end) -+#define TEST_OP (op <= op_end) -+ -+#define NEED_IP(x) \ -+ if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun -+#define NEED_OP(x) \ -+ if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun -+#define TEST_LOOKBEHIND(m_pos,out) if (m_pos < out) goto lookbehind_overrun -+ -+/* lzo1x_9x.c */ -+ -+#define LZO_UINT_MAX UINT_MAX -+#define N M4_MAX_OFFSET -+#define THRESHOLD 1 -+#define F 2048 -+ -+#define SWD_BEST_OFF (LZO_MAX3( M2_MAX_LEN, M3_MAX_LEN, M4_MAX_LEN ) + 1) -+ -+/* ../include/lzoconf.h */ -+ -+typedef U32 lzo_uint32; -+typedef I32 lzo_int32; -+typedef U32 lzo_uint; -+typedef I32 lzo_int; -+typedef int lzo_bool; -+ -+#define lzo_byte U8 -+#define lzo_bytep U8 * -+#define lzo_charp char * -+#define lzo_voidp void * -+#define lzo_shortp short * -+#define lzo_ushortp unsigned short * -+#define lzo_uint32p lzo_uint32 * -+#define lzo_int32p lzo_int32 * -+#define lzo_uintp lzo_uint * -+#define lzo_intp lzo_int * -+#define lzo_voidpp lzo_voidp * -+#define lzo_bytepp lzo_bytep * -+#define lzo_sizeof_dict_t sizeof(lzo_bytep) -+ -+#define LZO_E_OK 0 -+#define LZO_E_ERROR (-1) -+#define LZO_E_OUT_OF_MEMORY (-2) /* not used right now */ -+#define LZO_E_NOT_COMPRESSIBLE (-3) /* not used right now */ -+#define LZO_E_INPUT_OVERRUN (-4) -+#define LZO_E_OUTPUT_OVERRUN (-5) -+#define LZO_E_LOOKBEHIND_OVERRUN (-6) -+#define LZO_E_EOF_NOT_FOUND (-7) -+#define LZO_E_INPUT_NOT_CONSUMED (-8) -+ -+#define LZO_PTR_ALIGN_UP(_ptr,_size) \ -+ ((_ptr) + (lzo_uint) __lzo_align_gap((const lzo_voidp)(_ptr),(lzo_uint)(_size))) -+#define LZO_ALIGN(_ptr,_size) LZO_PTR_ALIGN_UP(_ptr,_size) -+ -+typedef int -+ (*lzo_compress_t) (const lzo_byte * src, lzo_uint src_len, -+ lzo_byte * dst, lzo_uintp dst_len, -+ lzo_voidp wrkmem); -+ -+typedef int -+ (*lzo_decompress_t) (const lzo_byte * src, lzo_uint src_len, -+ lzo_byte * dst, lzo_uintp dst_len, -+ lzo_voidp wrkmem); -+ -+typedef int -+ (*lzo_optimize_t) (lzo_byte * src, lzo_uint src_len, -+ lzo_byte * dst, lzo_uintp dst_len, -+ lzo_voidp wrkmem); -+ -+typedef int -+ (*lzo_compress_dict_t) (const lzo_byte * src, lzo_uint src_len, -+ lzo_byte * dst, lzo_uintp dst_len, -+ lzo_voidp wrkmem, -+ const lzo_byte * dict, lzo_uint dict_len); -+ -+typedef int -+ (*lzo_decompress_dict_t) (const lzo_byte * src, lzo_uint src_len, -+ lzo_byte * dst, lzo_uintp dst_len, -+ lzo_voidp wrkmem, -+ const lzo_byte * dict, lzo_uint dict_len); -+ -+typedef int -+ (*lzo_compress_asm_t) (const lzo_byte * src, lzo_uint src_len, -+ lzo_byte * dst, lzo_uintp dst_len, -+ lzo_voidp wrkmem); -+ -+typedef int -+ (*lzo_decompress_asm_t) (const lzo_byte * src, lzo_uint src_len, -+ lzo_byte * dst, lzo_uintp dst_len, -+ lzo_voidp wrkmem); -+ -+typedef void (*lzo_progress_callback_t) (lzo_uint, lzo_uint); -+ -+typedef union -+{ -+ lzo_bytep p; -+ lzo_uint u; -+} __lzo_pu_u; -+typedef union -+{ -+ lzo_bytep p; -+ lzo_uint32 u32; -+} __lzo_pu32_u; -+typedef union -+{ -+ void *vp; -+ lzo_bytep bp; -+ lzo_uint32 u32; -+ long l; -+} lzo_align_t; -+ -+/* lzo1x.h */ -+ -+#define LZO1X_1_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) -+#define LZO1X_999_MEM_COMPRESS ((lzo_uint32) (14 * 16384L * sizeof(short))) -+ -+/* lzo_ptr.h */ -+ -+#define PTR(a) ((lzo_ptr_t) (a)) -+#define PTR_LINEAR(a) PTR(a) -+#define PTR_ALIGNED_4(a) ((PTR_LINEAR(a) & 3) == 0) -+#define PTR_ALIGNED_8(a) ((PTR_LINEAR(a) & 7) == 0) -+#define PTR_ALIGNED2_4(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 3) == 0) -+#define PTR_ALIGNED2_8(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 7) == 0) -+#define PTR_LT(a,b) (PTR(a) < PTR(b)) -+#define PTR_GE(a,b) (PTR(a) >= PTR(b)) -+#define PTR_DIFF(a,b) ((lzo_ptrdiff_t) (PTR(a) - PTR(b))) -+#define pd(a,b) ((lzo_uint) ((a)-(b))) -+ -+typedef ptrdiff_t lzo_ptrdiff_t; -+ -+typedef union -+{ -+ char a_char; -+ unsigned char a_uchar; -+ short a_short; -+ unsigned short a_ushort; -+ int a_int; -+ unsigned int a_uint; -+ long a_long; -+ unsigned long a_ulong; -+ lzo_int a_lzo_int; -+ lzo_uint a_lzo_uint; -+ lzo_int32 a_lzo_int32; -+ lzo_uint32 a_lzo_uint32; -+ ptrdiff_t a_ptrdiff_t; -+ lzo_ptrdiff_t a_lzo_ptrdiff_t; -+ lzo_ptr_t a_lzo_ptr_t; -+ lzo_voidp a_lzo_voidp; -+ void *a_void_p; -+ lzo_bytep a_lzo_bytep; -+ lzo_bytepp a_lzo_bytepp; -+ lzo_uintp a_lzo_uintp; -+ lzo_uint *a_lzo_uint_p; -+ lzo_uint32p a_lzo_uint32p; -+ lzo_uint32 *a_lzo_uint32_p; -+ unsigned char *a_uchar_p; -+ char *a_char_p; -+} -+lzo_full_align_t; -+ -+/* lzo_mchw.ch */ -+ -+typedef struct -+{ -+ int init; -+ -+ lzo_uint look; -+ -+ lzo_uint m_len; -+ lzo_uint m_off; -+ -+ lzo_uint last_m_len; -+ lzo_uint last_m_off; -+ -+ const lzo_byte *bp; -+ const lzo_byte *ip; -+ const lzo_byte *in; -+ const lzo_byte *in_end; -+ lzo_byte *out; -+ -+ lzo_progress_callback_t cb; -+ -+ lzo_uint textsize; -+ lzo_uint codesize; -+ lzo_uint printcount; -+ -+ unsigned long lit_bytes; -+ unsigned long match_bytes; -+ unsigned long rep_bytes; -+ unsigned long lazy; -+ -+ lzo_uint r1_lit; -+ lzo_uint r1_m_len; -+ -+ unsigned long m1a_m, m1b_m, m2_m, m3_m, m4_m; -+ unsigned long lit1_r, lit2_r, lit3_r; -+} -+lzo1x_999_t; -+ -+#define getbyte(c) ((c).ip < (c).in_end ? *((c).ip)++ : (-1)) -+ -+/* lzo_swd.ch */ -+ -+#define SWD_UINT(x) ((swd_uint)(x)) -+#define SWD_HSIZE 16384 -+#define SWD_MAX_CHAIN 2048 -+#define HEAD3(b,p) \ -+ (((0x9f5f*(((((lzo_uint32)b[p]<<5)^b[p+1])<<5)^b[p+2]))>>5) & (SWD_HSIZE-1)) -+#define HEAD2(b,p) (b[p] ^ ((unsigned)b[p+1]<<8)) -+#define NIL2 SWD_UINT_MAX -+ -+typedef struct -+{ -+ lzo_uint n; -+ lzo_uint f; -+ lzo_uint threshold; -+ -+ lzo_uint max_chain; -+ lzo_uint nice_length; -+ lzo_bool use_best_off; -+ lzo_uint lazy_insert; -+ -+ lzo_uint m_len; -+ lzo_uint m_off; -+ lzo_uint look; -+ int b_char; -+ -+ lzo_uint best_off[SWD_BEST_OFF]; -+ -+ lzo1x_999_t *c; -+ lzo_uint m_pos; -+ -+ lzo_uint best_pos[SWD_BEST_OFF]; -+ -+ const lzo_byte *dict; -+ const lzo_byte *dict_end; -+ lzo_uint dict_len; -+ -+ lzo_uint ip; -+ lzo_uint bp; -+ lzo_uint rp; -+ lzo_uint b_size; -+ -+ unsigned char *b_wrap; -+ -+ lzo_uint node_count; -+ lzo_uint first_rp; -+ -+ unsigned char b[SWD_N + SWD_F + SWD_F]; -+ swd_uint head3[SWD_HSIZE]; -+ swd_uint succ3[SWD_N + SWD_F]; -+ swd_uint best3[SWD_N + SWD_F]; -+ swd_uint llen3[SWD_HSIZE]; -+ -+ swd_uint head2[65536L]; -+} -+lzo1x_999_swd_t; -+ -+#define s_head3(s,key) s->head3[key] -+#define swd_pos2off(s,pos) \ -+ (s->bp > (pos) ? s->bp - (pos) : s->b_size - ((pos) - s->bp)) -+ -+static __inline__ void -+swd_getbyte (lzo1x_999_swd_t * s) -+{ -+ int c; -+ -+ if ((c = getbyte (*(s->c))) < 0) -+ { -+ if (s->look > 0) -+ --s->look; -+ } -+ else -+ { -+ s->b[s->ip] = LZO_BYTE (c); -+ if (s->ip < s->f) -+ s->b_wrap[s->ip] = LZO_BYTE (c); -+ } -+ if (++s->ip == s->b_size) -+ s->ip = 0; -+ if (++s->bp == s->b_size) -+ s->bp = 0; -+ if (++s->rp == s->b_size) -+ s->rp = 0; -+} -+ -+static void -+swd_initdict (lzo1x_999_swd_t * s, const lzo_byte * dict, lzo_uint dict_len) -+{ -+ s->dict = s->dict_end = NULL; -+ s->dict_len = 0; -+ -+ if (!dict || dict_len <= 0) -+ return; -+ if (dict_len > s->n) -+ { -+ dict += dict_len - s->n; -+ dict_len = s->n; -+ } -+ -+ s->dict = dict; -+ s->dict_len = dict_len; -+ s->dict_end = dict + dict_len; -+ memcpy (s->b, dict, dict_len); -+ s->ip = dict_len; -+} -+ -+static void -+swd_insertdict (lzo1x_999_swd_t * s, lzo_uint node, lzo_uint len) -+{ -+ lzo_uint key; -+ -+ s->node_count = s->n - len; -+ s->first_rp = node; -+ -+ while (len-- > 0) -+ { -+ key = HEAD3 (s->b, node); -+ s->succ3[node] = s_head3 (s, key); -+ s->head3[key] = SWD_UINT (node); -+ s->best3[node] = SWD_UINT (s->f + 1); -+ s->llen3[key]++; -+ -+ key = HEAD2 (s->b, node); -+ s->head2[key] = SWD_UINT (node); -+ -+ node++; -+ } -+} -+ -+static int -+swd_init (lzo1x_999_swd_t * s, const lzo_byte * dict, lzo_uint dict_len) -+{ -+ -+ s->n = SWD_N; -+ s->f = SWD_F; -+ s->threshold = SWD_THRESHOLD; -+ -+ -+ -+ s->max_chain = SWD_MAX_CHAIN; -+ s->nice_length = SWD_F; -+ s->use_best_off = 0; -+ s->lazy_insert = 0; -+ -+ s->b_size = s->n + s->f; -+ if (2 * s->f >= s->n || s->b_size + s->f >= NIL2) -+ return LZO_E_ERROR; -+ s->b_wrap = s->b + s->b_size; -+ s->node_count = s->n; -+ -+ memset (s->llen3, 0, sizeof (s->llen3[0]) * SWD_HSIZE); -+ memset (s->head2, 0xff, sizeof (s->head2[0]) * 65536L); -+ -+ s->ip = 0; -+ swd_initdict (s, dict, dict_len); -+ s->bp = s->ip; -+ s->first_rp = s->ip; -+ -+ s->look = (lzo_uint) (s->c->in_end - s->c->ip); -+ if (s->look > 0) -+ { -+ if (s->look > s->f) -+ s->look = s->f; -+ memcpy (&s->b[s->ip], s->c->ip, s->look); -+ s->c->ip += s->look; -+ s->ip += s->look; -+ } -+ -+ if (s->ip == s->b_size) -+ s->ip = 0; -+ -+ if (s->look >= 2 && s->dict_len > 0) -+ swd_insertdict (s, 0, s->dict_len); -+ -+ s->rp = s->first_rp; -+ if (s->rp >= s->node_count) -+ s->rp -= s->node_count; -+ else -+ s->rp += s->b_size - s->node_count; -+ -+ return LZO_E_OK; -+} -+ -+static __inline__ void -+swd_remove_node (lzo1x_999_swd_t * s, lzo_uint node) -+{ -+ if (s->node_count == 0) -+ { -+ lzo_uint key; -+ -+ key = HEAD3 (s->b, node); -+ -+ --s->llen3[key]; -+ -+ key = HEAD2 (s->b, node); -+ -+ if ((lzo_uint) s->head2[key] == node) -+ s->head2[key] = NIL2; -+ } -+ else -+ --s->node_count; -+} -+ -+static void -+swd_accept (lzo1x_999_swd_t * s, lzo_uint n) -+{ -+ -+ while (n--) -+ { -+ lzo_uint key; -+ -+ swd_remove_node (s, s->rp); -+ -+ key = HEAD3 (s->b, s->bp); -+ s->succ3[s->bp] = s_head3 (s, key); -+ s->head3[key] = SWD_UINT (s->bp); -+ s->best3[s->bp] = SWD_UINT (s->f + 1); -+ s->llen3[key]++; -+ -+ key = HEAD2 (s->b, s->bp); -+ s->head2[key] = SWD_UINT (s->bp);; -+ -+ swd_getbyte (s); -+ } -+} -+ -+static void -+swd_search (lzo1x_999_swd_t * s, lzo_uint node, lzo_uint cnt) -+{ -+ const unsigned char *p1; -+ const unsigned char *p2; -+ const unsigned char *px; -+ -+ lzo_uint m_len = s->m_len; -+ const unsigned char *b = s->b; -+ const unsigned char *bp = s->b + s->bp; -+ const unsigned char *bx = s->b + s->bp + s->look; -+ unsigned char scan_end1; -+ -+ scan_end1 = bp[m_len - 1]; -+ for (; cnt-- > 0; node = s->succ3[node]) -+ { -+ p1 = bp; -+ p2 = b + node; -+ px = bx; -+ -+ if (p2[m_len - 1] == scan_end1 && -+ p2[m_len] == p1[m_len] && -+ p2[0] == p1[0] && p2[1] == p1[1]) -+ { -+ lzo_uint i; -+ -+ p1 += 2; -+ p2 += 2; -+ do -+ { -+ } -+ while (++p1 < px && *p1 == *++p2); -+ -+ i = p1 - bp; -+ -+ if (i < SWD_BEST_OFF) -+ { -+ if (s->best_pos[i] == 0) -+ s->best_pos[i] = node + 1; -+ } -+ -+ if (i > m_len) -+ { -+ s->m_len = m_len = i; -+ s->m_pos = node; -+ if (m_len == s->look) -+ return; -+ if (m_len >= s->nice_length) -+ return; -+ if (m_len > (lzo_uint) s->best3[node]) -+ return; -+ scan_end1 = bp[m_len - 1]; -+ } -+ } -+ } -+} -+ -+static lzo_bool -+swd_search2 (lzo1x_999_swd_t * s) -+{ -+ lzo_uint key; -+ -+ key = s->head2[HEAD2 (s->b, s->bp)]; -+ if (key == NIL2) -+ return 0; -+ -+ if (s->best_pos[2] == 0) -+ s->best_pos[2] = key + 1; -+ -+ if (s->m_len < 2) -+ { -+ s->m_len = 2; -+ s->m_pos = key; -+ } -+ return 1; -+} -+ -+static void -+swd_findbest (lzo1x_999_swd_t * s) -+{ -+ lzo_uint key; -+ lzo_uint cnt, node; -+ lzo_uint len; -+ -+ key = HEAD3 (s->b, s->bp); -+ node = s->succ3[s->bp] = s_head3 (s, key); -+ cnt = s->llen3[key]++; -+ -+ if (cnt > s->max_chain && s->max_chain > 0) -+ cnt = s->max_chain; -+ s->head3[key] = SWD_UINT (s->bp); -+ -+ s->b_char = s->b[s->bp]; -+ len = s->m_len; -+ if (s->m_len >= s->look) -+ { -+ if (s->look == 0) -+ s->b_char = -1; -+ s->m_off = 0; -+ s->best3[s->bp] = SWD_UINT (s->f + 1); -+ } -+ else -+ { -+ -+ if (swd_search2 (s)) -+ -+ if (s->look >= 3) -+ swd_search (s, node, cnt); -+ if (s->m_len > len) -+ s->m_off = swd_pos2off (s, s->m_pos); -+ s->best3[s->bp] = SWD_UINT (s->m_len); -+ -+ if (s->use_best_off) -+ { -+ int i; -+ for (i = 2; i < SWD_BEST_OFF; i++) -+ if (s->best_pos[i] > 0) -+ s->best_off[i] = -+ swd_pos2off (s, -+ s->best_pos[i] - -+ 1); -+ else -+ s->best_off[i] = 0; -+ } -+ -+ } -+ -+ swd_remove_node (s, s->rp); -+ -+ key = HEAD2 (s->b, s->bp); -+ s->head2[key] = SWD_UINT (s->bp); -+ -+} -+ -+/* lzo_mchw.ch */ -+ -+static int -+init_match (lzo1x_999_t * c, lzo1x_999_swd_t * s, -+ const lzo_byte * dict, lzo_uint dict_len, lzo_uint32 flags) -+{ -+ int r; -+ -+ c->init = 1; -+ -+ s->c = c; -+ -+ c->last_m_len = c->last_m_off = 0; -+ -+ c->textsize = c->codesize = c->printcount = 0; -+ c->lit_bytes = c->match_bytes = c->rep_bytes = 0; -+ c->lazy = 0; -+ -+ r = swd_init (s, dict, dict_len); -+ if (r != 0) -+ return r; -+ -+ s->use_best_off = (flags & 1) ? 1 : 0; -+ return r; -+} -+ -+static int -+find_match (lzo1x_999_t * c, lzo1x_999_swd_t * s, -+ lzo_uint this_len, lzo_uint skip) -+{ -+ if (skip > 0) -+ { -+ swd_accept (s, this_len - skip); -+ c->textsize += this_len - skip + 1; -+ } -+ else -+ { -+ c->textsize += this_len - skip; -+ } -+ -+ s->m_len = 1; -+ s->m_len = 1; -+ -+ if (s->use_best_off) -+ memset (s->best_pos, 0, sizeof (s->best_pos)); -+ -+ swd_findbest (s); -+ c->m_len = s->m_len; -+ c->m_off = s->m_off; -+ -+ swd_getbyte (s); -+ -+ if (s->b_char < 0) -+ { -+ c->look = 0; -+ c->m_len = 0; -+ } -+ else -+ { -+ c->look = s->look + 1; -+ } -+ c->bp = c->ip - c->look; -+ -+ if (c->cb && c->textsize > c->printcount) -+ { -+ (*c->cb) (c->textsize, c->codesize); -+ c->printcount += 1024; -+ } -+ -+ return LZO_E_OK; -+} -+ -+/* lzo1x_9x.c */ -+ -+static lzo_byte * -+code_match (lzo1x_999_t * c, lzo_byte * op, lzo_uint m_len, lzo_uint m_off) -+{ -+ lzo_uint x_len = m_len; -+ lzo_uint x_off = m_off; -+ -+ c->match_bytes += m_len; -+ -+ if (m_len == 2) -+ { -+ m_off -= 1; -+ -+ *op++ = LZO_BYTE (M1_MARKER | ((m_off & 3) << 2)); -+ *op++ = LZO_BYTE (m_off >> 2); -+ -+ c->m1a_m++; -+ } -+ -+ else if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET) -+ -+ { -+ -+ m_off -= 1; -+ *op++ = LZO_BYTE (((m_len - 1) << 5) | ((m_off & 7) << 2)); -+ *op++ = LZO_BYTE (m_off >> 3); -+ c->m2_m++; -+ } -+ else if (m_len == M2_MIN_LEN && m_off <= MX_MAX_OFFSET -+ && c->r1_lit >= 4) -+ { -+ m_off -= 1 + M2_MAX_OFFSET; -+ -+ *op++ = LZO_BYTE (M1_MARKER | ((m_off & 3) << 2)); -+ *op++ = LZO_BYTE (m_off >> 2); -+ -+ c->m1b_m++; -+ } -+ else if (m_off <= M3_MAX_OFFSET) -+ { -+ m_off -= 1; -+ if (m_len <= M3_MAX_LEN) -+ *op++ = LZO_BYTE (M3_MARKER | (m_len - 2)); -+ else -+ { -+ m_len -= M3_MAX_LEN; -+ *op++ = M3_MARKER | 0; -+ while (m_len > 255) -+ { -+ m_len -= 255; -+ *op++ = 0; -+ } -+ *op++ = LZO_BYTE (m_len); -+ } -+ -+ *op++ = LZO_BYTE (m_off << 2); -+ *op++ = LZO_BYTE (m_off >> 6); -+ -+ c->m3_m++; -+ } -+ else -+ { -+ lzo_uint k; -+ -+ m_off -= 0x4000; -+ k = (m_off & 0x4000) >> 11; -+ if (m_len <= M4_MAX_LEN) -+ *op++ = LZO_BYTE (M4_MARKER | k | (m_len - 2)); -+ else -+ { -+ m_len -= M4_MAX_LEN; -+ *op++ = LZO_BYTE (M4_MARKER | k | 0); -+ while (m_len > 255) -+ { -+ m_len -= 255; -+ *op++ = 0; -+ } -+ *op++ = LZO_BYTE (m_len); -+ } -+ -+ *op++ = LZO_BYTE (m_off << 2); -+ *op++ = LZO_BYTE (m_off >> 6); -+ -+ c->m4_m++; -+ } -+ -+ c->last_m_len = x_len; -+ c->last_m_off = x_off; -+ return op; -+} -+ -+static lzo_byte * -+STORE_RUN (lzo1x_999_t * c, lzo_byte * op, const lzo_byte * ii, lzo_uint t) -+{ -+ c->lit_bytes += t; -+ -+ if (op == c->out && t <= 238) -+ { -+ *op++ = LZO_BYTE (17 + t); -+ } -+ else if (t <= 3) -+ { -+ op[-2] |= LZO_BYTE (t); -+ -+ c->lit1_r++; -+ } -+ else if (t <= 18) -+ { -+ *op++ = LZO_BYTE (t - 3); -+ c->lit2_r++; -+ } -+ else -+ { -+ lzo_uint tt = t - 18; -+ -+ *op++ = 0; -+ while (tt > 255) -+ { -+ tt -= 255; -+ *op++ = 0; -+ } -+ *op++ = LZO_BYTE (tt); -+ c->lit3_r++; -+ } -+ do -+ *op++ = *ii++; -+ while (--t > 0); -+ -+ return op; -+} -+ -+static lzo_byte * -+code_run (lzo1x_999_t * c, lzo_byte * op, const lzo_byte * ii, -+ lzo_uint lit, lzo_uint m_len) -+{ -+ if (lit > 0) -+ { -+ op = STORE_RUN (c, op, ii, lit); -+ c->r1_m_len = m_len; -+ c->r1_lit = lit; -+ } -+ else -+ { -+ c->r1_m_len = 0; -+ c->r1_lit = 0; -+ } -+ -+ return op; -+} -+ -+static int -+len_of_coded_match (lzo_uint m_len, lzo_uint m_off, lzo_uint lit) -+{ -+ int n = 4; -+ -+ if (m_len < 2) -+ return -1; -+ if (m_len == 2) -+ return (m_off <= M1_MAX_OFFSET && lit > 0 -+ && lit < 4) ? 2 : -1; -+ if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET) -+ return 2; -+ if (m_len == M2_MIN_LEN && m_off <= MX_MAX_OFFSET && lit >= 4) -+ return 2; -+ if (m_off <= M3_MAX_OFFSET) -+ { -+ if (m_len <= M3_MAX_LEN) -+ return 3; -+ m_len -= M3_MAX_LEN; -+ while (m_len > 255) -+ { -+ m_len -= 255; -+ n++; -+ } -+ return n; -+ } -+ if (m_off <= M4_MAX_OFFSET) -+ { -+ if (m_len <= M4_MAX_LEN) -+ return 3; -+ m_len -= M4_MAX_LEN; -+ while (m_len > 255) -+ { -+ m_len -= 255; -+ n++; -+ } -+ return n; -+ } -+ return -1; -+} -+ -+static lzo_int -+min_gain (lzo_uint ahead, lzo_uint lit1, lzo_uint lit2, int l1, int l2, -+ int l3) -+{ -+ lzo_int lazy_match_min_gain = 0; -+ -+ lazy_match_min_gain += ahead; -+ -+ if (lit1 <= 3) -+ lazy_match_min_gain += (lit2 <= 3) ? 0 : 2; -+ else if (lit1 <= 18) -+ lazy_match_min_gain += (lit2 <= 18) ? 0 : 1; -+ -+ lazy_match_min_gain += (l2 - l1) * 2; -+ if (l3 > 0) -+ lazy_match_min_gain -= (ahead - l3) * 2; -+ -+ if (lazy_match_min_gain < 0) -+ lazy_match_min_gain = 0; -+ -+ return lazy_match_min_gain; -+} -+ -+static void -+better_match (const lzo1x_999_swd_t * swd, lzo_uint * m_len, lzo_uint * m_off) -+{ -+ if (*m_len <= M2_MIN_LEN) -+ return; -+ -+ if (*m_off <= M2_MAX_OFFSET) -+ return; -+ -+ if (*m_off > M2_MAX_OFFSET && -+ *m_len >= M2_MIN_LEN + 1 && *m_len <= M2_MAX_LEN + 1 && -+ swd->best_off[*m_len - 1] -+ && swd->best_off[*m_len - 1] <= M2_MAX_OFFSET) -+ { -+ *m_len = *m_len - 1; -+ *m_off = swd->best_off[*m_len]; -+ return; -+ } -+ -+ if (*m_off > M3_MAX_OFFSET && -+ *m_len >= M4_MAX_LEN + 1 && *m_len <= M2_MAX_LEN + 2 && -+ swd->best_off[*m_len - 2] -+ && swd->best_off[*m_len - 2] <= M2_MAX_OFFSET) -+ { -+ *m_len = *m_len - 2; -+ *m_off = swd->best_off[*m_len]; -+ return; -+ } -+ -+ if (*m_off > M3_MAX_OFFSET && -+ *m_len >= M4_MAX_LEN + 1 && *m_len <= M3_MAX_LEN + 1 && -+ swd->best_off[*m_len - 1] -+ && swd->best_off[*m_len - 1] <= M3_MAX_OFFSET) -+ { -+ *m_len = *m_len - 1; -+ *m_off = swd->best_off[*m_len]; -+ } -+ -+} -+ -+/* minilzo.c */ -+ -+static lzo_bool -+lzo_assert (int expr) -+{ -+ return (expr) ? 1 : 0; -+} -+ -+/* lzo1x_9x.c */ -+ -+static int -+lzo1x_999_compress_internal (const lzo_byte * in, lzo_uint in_len, -+ lzo_byte * out, lzo_uintp out_len, -+ lzo_voidp wrkmem, -+ const lzo_byte * dict, lzo_uint dict_len, -+ lzo_progress_callback_t cb, -+ int try_lazy, -+ lzo_uint good_length, -+ lzo_uint max_lazy, -+ lzo_uint nice_length, -+ lzo_uint max_chain, lzo_uint32 flags) -+{ -+ lzo_byte *op; -+ const lzo_byte *ii; -+ lzo_uint lit; -+ lzo_uint m_len, m_off; -+ lzo1x_999_t cc; -+ lzo1x_999_t *const c = &cc; -+ lzo1x_999_swd_t *const swd = (lzo1x_999_swd_t *) wrkmem; -+ int r; -+ -+ if (!lzo_assert -+ (LZO1X_999_MEM_COMPRESS >= lzo_sizeof (lzo1x_999_swd_t))) -+ return LZO_E_ERROR; -+ -+ if (try_lazy < 0) -+ try_lazy = 1; -+ -+ if (good_length <= 0) -+ good_length = 32; -+ -+ if (max_lazy <= 0) -+ max_lazy = 32; -+ -+ if (nice_length <= 0) -+ nice_length = 0; -+ -+ if (max_chain <= 0) -+ max_chain = SWD_MAX_CHAIN; -+ -+ c->init = 0; -+ c->ip = c->in = in; -+ c->in_end = in + in_len; -+ c->out = out; -+ c->cb = cb; -+ c->m1a_m = c->m1b_m = c->m2_m = c->m3_m = c->m4_m = 0; -+ c->lit1_r = c->lit2_r = c->lit3_r = 0; -+ -+ op = out; -+ ii = c->ip; -+ lit = 0; -+ c->r1_lit = c->r1_m_len = 0; -+ -+ r = init_match (c, swd, dict, dict_len, flags); -+ if (r != 0) -+ return r; -+ if (max_chain > 0) -+ swd->max_chain = max_chain; -+ if (nice_length > 0) -+ swd->nice_length = nice_length; -+ -+ r = find_match (c, swd, 0, 0); -+ if (r != 0) -+ return r; -+ while (c->look > 0) -+ { -+ lzo_uint ahead; -+ lzo_uint max_ahead; -+ int l1, l2, l3; -+ -+ c->codesize = op - out; -+ -+ m_len = c->m_len; -+ m_off = c->m_off; -+ -+ if (lit == 0) -+ ii = c->bp; -+ -+ if (m_len < 2 || -+ (m_len == 2 -+ && (m_off > M1_MAX_OFFSET || lit == 0 || lit >= 4)) -+ || (m_len == 2 && op == out) || (op == out && lit == 0)) -+ { -+ -+ m_len = 0; -+ } -+ else if (m_len == M2_MIN_LEN) -+ { -+ -+ if (m_off > MX_MAX_OFFSET && lit >= 4) -+ m_len = 0; -+ } -+ -+ if (m_len == 0) -+ { -+ -+ lit++; -+ swd->max_chain = max_chain; -+ r = find_match (c, swd, 1, 0); -+ continue; -+ } -+ -+ if (swd->use_best_off) -+ better_match (swd, &m_len, &m_off); -+ -+ ahead = 0; -+ if (try_lazy <= 0 || m_len >= max_lazy) -+ { -+ -+ l1 = 0; -+ max_ahead = 0; -+ } -+ else -+ { -+ -+ l1 = len_of_coded_match (m_len, m_off, lit); -+ -+ max_ahead = LZO_MIN (try_lazy, l1 - 1); -+ -+ } -+ -+ while (ahead < max_ahead && c->look > m_len) -+ { -+ lzo_int lazy_match_min_gain; -+ -+ if (m_len >= good_length) -+ swd->max_chain = max_chain >> 2; -+ else -+ swd->max_chain = max_chain; -+ r = find_match (c, swd, 1, 0); -+ ahead++; -+ -+ if (c->m_len < m_len) -+ continue; -+ -+ if (c->m_len == m_len && c->m_off >= m_off) -+ continue; -+ -+ if (swd->use_best_off) -+ better_match (swd, &c->m_len, &c->m_off); -+ -+ l2 = len_of_coded_match (c->m_len, c->m_off, -+ lit + ahead); -+ if (l2 < 0) -+ continue; -+ -+ l3 = (op == out) ? -1 : len_of_coded_match (ahead, -+ m_off, -+ lit); -+ -+ lazy_match_min_gain = -+ min_gain (ahead, lit, lit + ahead, l1, l2, -+ l3); -+ if (c->m_len >= m_len + lazy_match_min_gain) -+ { -+ c->lazy++; -+ -+ if (l3 > 0) -+ { -+ -+ op = code_run (c, op, ii, lit, ahead); -+ lit = 0; -+ -+ op = code_match (c, op, ahead, m_off); -+ } -+ else -+ { -+ lit += ahead; -+ } -+ goto lazy_match_done; -+ } -+ } -+ -+ op = code_run (c, op, ii, lit, m_len); -+ lit = 0; -+ -+ op = code_match (c, op, m_len, m_off); -+ swd->max_chain = max_chain; -+ r = find_match (c, swd, m_len, 1 + ahead); -+ -+ lazy_match_done:; -+ } -+ -+ if (lit > 0) -+ op = STORE_RUN (c, op, ii, lit); -+ -+ *op++ = M4_MARKER | 1; -+ *op++ = 0; -+ *op++ = 0; -+ -+ c->codesize = op - out; -+ -+ *out_len = op - out; -+ -+ if (c->cb) -+ (*c->cb) (c->textsize, c->codesize); -+ -+ return LZO_E_OK; -+} -+ -+static int -+lzo1x_999_compress_level (const lzo_byte * in, lzo_uint in_len, -+ lzo_byte * out, lzo_uintp out_len, -+ lzo_voidp wrkmem, -+ const lzo_byte * dict, lzo_uint dict_len, -+ lzo_progress_callback_t cb, int compression_level) -+{ -+ static const struct -+ { -+ int try_lazy; -+ lzo_uint good_length; -+ lzo_uint max_lazy; -+ lzo_uint nice_length; -+ lzo_uint max_chain; -+ lzo_uint32 flags; -+ } c[9] = -+ { -+ { -+ 0, 0, 0, 8, 4, 0}, -+ { -+ 0, 0, 0, 16, 8, 0}, -+ { -+ 0, 0, 0, 32, 16, 0}, -+ { -+ 1, 4, 4, 16, 16, 0}, -+ { -+ 1, 8, 16, 32, 32, 0}, -+ { -+ 1, 8, 16, 128, 128, 0}, -+ { -+ 2, 8, 32, 128, 256, 0}, -+ { -+ 2, 32, 128, F, 2048, 1}, -+ { -+ 2, F, F, F, 4096, 1} -+ }; -+ -+ if (compression_level < 1 || compression_level > 9) -+ return LZO_E_ERROR; -+ -+ compression_level -= 1; -+ return lzo1x_999_compress_internal (in, in_len, out, out_len, wrkmem, -+ dict, dict_len, cb, -+ c[compression_level].try_lazy, -+ c[compression_level].good_length, -+ c[compression_level].max_lazy, -+ 0, -+ c[compression_level].max_chain, -+ c[compression_level].flags); -+} -+ -+static int -+lzo1x_999_compress (const lzo_byte * in, lzo_uint in_len, -+ lzo_byte * out, lzo_uintp out_len, lzo_voidp wrkmem) -+{ -+ return lzo1x_999_compress_level (in, in_len, out, out_len, wrkmem, -+ NULL, 0, 0, 8); -+} -+ -+/* minilzo.c */ -+ -+static const lzo_byte __lzo_copyright[] = LZO_VERSION_STRING; -+ -+static lzo_uint -+_lzo1x_1_do_compress (const lzo_byte * in, lzo_uint in_len, -+ lzo_byte * out, lzo_uintp out_len, lzo_voidp wrkmem) -+{ -+ -+ register const lzo_byte *ip; -+ -+ lzo_byte *op; -+ const lzo_byte *const in_end = in + in_len; -+ const lzo_byte *const ip_end = in + in_len - 8 - 5; -+ const lzo_byte *ii; -+ lzo_dict_p const dict = (lzo_dict_p) wrkmem; -+ -+ op = out; -+ ip = in; -+ ii = ip; -+ -+ ip += 4; -+ for (;;) -+ { -+ register const lzo_byte *m_pos; -+ -+ lzo_uint m_off; -+ lzo_uint m_len; -+ lzo_uint dindex; -+ -+ DINDEX1 (dindex, ip); -+ GINDEX (m_pos, m_off, dict, dindex, in); -+ if (LZO_CHECK_MPOS_NON_DET -+ (m_pos, m_off, in, ip, M4_MAX_OFFSET)) -+ goto literal; -+ -+ if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3]) -+ goto try_match; -+ DINDEX2 (dindex, ip); -+ GINDEX (m_pos, m_off, dict, dindex, in); -+ -+ if (LZO_CHECK_MPOS_NON_DET -+ (m_pos, m_off, in, ip, M4_MAX_OFFSET)) -+ goto literal; -+ if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3]) -+ goto try_match; -+ goto literal; -+ -+ try_match: -+ if (m_pos[0] != ip[0] || m_pos[1] != ip[1]) -+ { -+ } -+ else -+ { -+ if (m_pos[2] == ip[2]) -+ { -+ goto match; -+ } -+ else -+ { -+ } -+ } -+ -+ literal: -+ UPDATE_I (dict, 0, dindex, ip, in); -+ ++ip; -+ if (ip >= ip_end) -+ break; -+ continue; -+ -+ match: -+ UPDATE_I (dict, 0, dindex, ip, in); -+ -+ if (pd (ip, ii) > 0) -+ { -+ register lzo_uint t = pd (ip, ii); -+ -+ if (t <= 3) -+ { -+ op[-2] |= LZO_BYTE (t); -+ } -+ else if (t <= 18) -+ *op++ = LZO_BYTE (t - 3); -+ else -+ { -+ register lzo_uint tt = t - 18; -+ -+ *op++ = 0; -+ while (tt > 255) -+ { -+ tt -= 255; -+ *op++ = 0; -+ } -+ *op++ = LZO_BYTE (tt);; -+ } -+ do -+ *op++ = *ii++; -+ while (--t > 0); -+ } -+ -+ ip += 3; -+ if (m_pos[3] != *ip++ || m_pos[4] != *ip++ -+ || m_pos[5] != *ip++ || m_pos[6] != *ip++ -+ || m_pos[7] != *ip++ || m_pos[8] != *ip++) -+ { -+ --ip; -+ m_len = ip - ii; -+ -+ if (m_off <= M2_MAX_OFFSET) -+ { -+ m_off -= 1; -+ -+ *op++ = LZO_BYTE (((m_len - -+ 1) << 5) | ((m_off & 7) << -+ 2)); -+ *op++ = LZO_BYTE (m_off >> 3); -+ } -+ else if (m_off <= M3_MAX_OFFSET) -+ { -+ m_off -= 1; -+ *op++ = LZO_BYTE (M3_MARKER | (m_len - 2)); -+ goto m3_m4_offset; -+ } -+ else -+ -+ { -+ m_off -= 0x4000; -+ -+ *op++ = LZO_BYTE (M4_MARKER | -+ ((m_off & 0x4000) >> 11) | -+ (m_len - 2)); -+ goto m3_m4_offset; -+ } -+ } -+ else -+ { -+ { -+ const lzo_byte *end = in_end; -+ const lzo_byte *m = m_pos + M2_MAX_LEN + 1; -+ while (ip < end && *m == *ip) -+ m++, ip++; -+ m_len = (ip - ii); -+ } -+ -+ -+ if (m_off <= M3_MAX_OFFSET) -+ { -+ m_off -= 1; -+ if (m_len <= 33) -+ *op++ = LZO_BYTE (M3_MARKER | -+ (m_len - 2)); -+ else -+ { -+ m_len -= 33; -+ *op++ = M3_MARKER | 0; -+ goto m3_m4_len; -+ } -+ } -+ else -+ { -+ m_off -= 0x4000; -+ -+ if (m_len <= M4_MAX_LEN) -+ *op++ = LZO_BYTE (M4_MARKER | -+ ((m_off & 0x4000) >> -+ 11) | (m_len - 2)); -+ -+ else -+ { -+ m_len -= M4_MAX_LEN; -+ *op++ = LZO_BYTE (M4_MARKER | -+ ((m_off & 0x4000) >> -+ 11)); -+ m3_m4_len: -+ while (m_len > 255) -+ { -+ m_len -= 255; -+ *op++ = 0; -+ } -+ -+ *op++ = LZO_BYTE (m_len); -+ } -+ } -+ -+ m3_m4_offset: -+ *op++ = LZO_BYTE ((m_off & 63) << 2); -+ *op++ = LZO_BYTE (m_off >> 6); -+ } -+ ii = ip; -+ if (ip >= ip_end) -+ break; -+ } -+ -+ *out_len = op - out; -+ return pd (in_end, ii); -+} -+ -+static int -+lzo1x_1_compress (const lzo_byte * in, lzo_uint in_len, -+ lzo_byte * out, lzo_uintp out_len, lzo_voidp wrkmem) -+{ -+ lzo_byte *op = out; -+ lzo_uint t; -+ -+ if (in_len <= M2_MAX_LEN + 5) -+ t = in_len; -+ else -+ { -+ t = _lzo1x_1_do_compress (in, in_len, op, out_len, wrkmem); -+ op += *out_len; -+ } -+ -+ if (t > 0) -+ { -+ const lzo_byte *ii = in + in_len - t; -+ -+ if (op == out && t <= 238) -+ *op++ = LZO_BYTE (17 + t); -+ else if (t <= 3) -+ op[-2] |= LZO_BYTE (t); -+ else if (t <= 18) -+ *op++ = LZO_BYTE (t - 3); -+ else -+ { -+ lzo_uint tt = t - 18; -+ -+ *op++ = 0; -+ while (tt > 255) -+ { -+ tt -= 255; -+ *op++ = 0; -+ } -+ -+ *op++ = LZO_BYTE (tt); -+ } -+ do -+ *op++ = *ii++; -+ while (--t > 0); -+ } -+ -+ *op++ = M4_MARKER | 1; -+ *op++ = 0; -+ *op++ = 0; -+ -+ *out_len = op - out; -+ return 0; -+} -+ -+static int -+lzo1x_decompress (const lzo_byte * in, lzo_uint in_len, -+ lzo_byte * out, lzo_uintp out_len, lzo_voidp wrkmem) -+{ -+ register lzo_byte *op; -+ register const lzo_byte *ip; -+ register lzo_uint t; -+ -+ register const lzo_byte *m_pos; -+ -+ const lzo_byte *const ip_end = in + in_len; -+ lzo_byte *const op_end = out + *out_len; -+ -+ *out_len = 0; -+ -+ op = out; -+ ip = in; -+ -+ if (*ip > 17) -+ { -+ t = *ip++ - 17; -+ if (t < 4) -+ goto match_next; -+ NEED_OP (t); -+ NEED_IP (t + 1); -+ do -+ *op++ = *ip++; -+ while (--t > 0); -+ goto first_literal_run; -+ } -+ -+ while (TEST_IP && TEST_OP) -+ { -+ t = *ip++; -+ if (t >= 16) -+ goto match; -+ if (t == 0) -+ { -+ NEED_IP (1); -+ while (*ip == 0) -+ { -+ t += 255; -+ ip++; -+ NEED_IP (1); -+ } -+ t += 15 + *ip++; -+ } -+ NEED_OP (t + 3); -+ NEED_IP (t + 4); -+ if (PTR_ALIGNED2_4 (op, ip)) -+ { -+ COPY4 (op, ip); -+ -+ op += 4; -+ ip += 4; -+ if (--t > 0) -+ { -+ if (t >= 4) -+ { -+ do -+ { -+ COPY4 (op, ip); -+ op += 4; -+ ip += 4; -+ t -= 4; -+ } -+ while (t >= 4); -+ if (t > 0) -+ do -+ *op++ = *ip++; -+ while (--t > 0); -+ } -+ else -+ do -+ *op++ = *ip++; -+ while (--t > 0); -+ } -+ } -+ else -+ { -+ *op++ = *ip++; -+ *op++ = *ip++; -+ *op++ = *ip++; -+ do -+ *op++ = *ip++; -+ while (--t > 0); -+ } -+ first_literal_run: -+ -+ t = *ip++; -+ if (t >= 16) -+ goto match; -+ -+ m_pos = op - (1 + M2_MAX_OFFSET); -+ m_pos -= t >> 2; -+ m_pos -= *ip++ << 2; -+ TEST_LOOKBEHIND (m_pos, out); -+ NEED_OP (3); -+ *op++ = *m_pos++; -+ *op++ = *m_pos++; -+ *op++ = *m_pos; -+ -+ goto match_done; -+ -+ while (TEST_IP && TEST_OP) -+ { -+ match: -+ if (t >= 64) -+ { -+ m_pos = op - 1; -+ m_pos -= (t >> 2) & 7; -+ m_pos -= *ip++ << 3; -+ t = (t >> 5) - 1; -+ TEST_LOOKBEHIND (m_pos, out); -+ NEED_OP (t + 3 - 1); -+ goto copy_match; -+ -+ } -+ else if (t >= 32) -+ { -+ t &= 31; -+ if (t == 0) -+ { -+ NEED_IP (1); -+ while (*ip == 0) -+ { -+ t += 255; -+ ip++; -+ NEED_IP (1); -+ } -+ t += 31 + *ip++; -+ } -+ -+ m_pos = op - 1; -+ m_pos -= (ip[0] >> 2) + (ip[1] << 6); -+ -+ ip += 2; -+ } -+ else if (t >= 16) -+ { -+ m_pos = op; -+ m_pos -= (t & 8) << 11; -+ -+ t &= 7; -+ if (t == 0) -+ { -+ NEED_IP (1); -+ while (*ip == 0) -+ { -+ t += 255; -+ ip++; -+ NEED_IP (1); -+ } -+ t += 7 + *ip++; -+ } -+ -+ m_pos -= (ip[0] >> 2) + (ip[1] << 6); -+ -+ ip += 2; -+ if (m_pos == op) -+ goto eof_found; -+ m_pos -= 0x4000; -+ } -+ else -+ { -+ -+ m_pos = op - 1; -+ m_pos -= t >> 2; -+ m_pos -= *ip++ << 2; -+ TEST_LOOKBEHIND (m_pos, out); -+ NEED_OP (2); -+ *op++ = *m_pos++; -+ *op++ = *m_pos; -+ -+ goto match_done; -+ } -+ -+ TEST_LOOKBEHIND (m_pos, out); -+ NEED_OP (t + 3 - 1); -+ if (t >= 2 * 4 - (3 - 1) -+ && PTR_ALIGNED2_4 (op, m_pos)) -+ { -+ COPY4 (op, m_pos); -+ op += 4; -+ m_pos += 4; -+ t -= 4 - (3 - 1); -+ do -+ { -+ COPY4 (op, m_pos); -+ op += 4; -+ m_pos += 4; -+ t -= 4; -+ } -+ while (t >= 4); -+ if (t > 0) -+ do -+ *op++ = *m_pos++; -+ while (--t > 0); -+ } -+ else -+ -+ { -+ copy_match: -+ *op++ = *m_pos++; -+ *op++ = *m_pos++; -+ do -+ *op++ = *m_pos++; -+ while (--t > 0); -+ } -+ -+ match_done: -+ t = ip[-2] & 3; -+ -+ if (t == 0) -+ break; -+ -+ match_next: -+ NEED_OP (t); -+ NEED_IP (t + 1); -+ do -+ *op++ = *ip++; -+ while (--t > 0); -+ t = *ip++; -+ } -+ } -+ *out_len = op - out; -+ return LZO_E_EOF_NOT_FOUND; -+ -+ eof_found: -+ *out_len = op - out; -+ return (ip == ip_end ? LZO_E_OK : -+ (ip < -+ ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); -+ -+ input_overrun: -+ *out_len = op - out; -+ return LZO_E_INPUT_OVERRUN; -+ -+ output_overrun: -+ *out_len = op - out; -+ return LZO_E_OUTPUT_OVERRUN; -+ -+ lookbehind_overrun: -+ *out_len = op - out; -+ return LZO_E_LOOKBEHIND_OVERRUN; -+} -+ -+/* lzo1x_oo.ch */ -+ -+#define NO_LIT LZO_UINT_MAX -+ -+static void -+copy2 (lzo_byte * ip, const lzo_byte * m_pos, lzo_ptrdiff_t off) -+{ -+ ip[0] = m_pos[0]; -+ if (off == 1) -+ ip[1] = m_pos[0]; -+ else -+ ip[1] = m_pos[1]; -+} -+ -+static void -+copy3 (lzo_byte * ip, const lzo_byte * m_pos, lzo_ptrdiff_t off) -+{ -+ ip[0] = m_pos[0]; -+ if (off == 1) -+ { -+ ip[2] = ip[1] = m_pos[0]; -+ } -+ else if (off == 2) -+ { -+ ip[1] = m_pos[1]; -+ ip[2] = m_pos[0]; -+ } -+ else -+ { -+ ip[1] = m_pos[1]; -+ ip[2] = m_pos[2]; -+ } -+} -+ -+static int -+lzo1x_optimize (lzo_byte * in, lzo_uint in_len, -+ lzo_byte * out, lzo_uintp out_len, lzo_voidp wrkmem) -+{ -+ register lzo_byte *op; -+ register lzo_byte *ip; -+ register lzo_uint t; -+ register lzo_byte *m_pos; -+ lzo_uint nl; -+ const lzo_byte *const ip_end = in + in_len; -+ const lzo_byte *const op_end = out + *out_len; -+ lzo_byte *litp = NULL; -+ lzo_uint lit = 0; -+ lzo_uint next_lit = NO_LIT; -+ long o_m1_a = 0, o_m1_b = 0, o_m2 = 0, o_m3_a = 0, o_m3_b = 0; -+ -+ *out_len = 0; -+ -+ op = out; -+ ip = in; -+ -+ if (*ip > 17) -+ { -+ t = *ip++ - 17; -+ if (t < 4) -+ goto match_next; -+ goto first_literal_run; -+ } -+ -+ while (TEST_IP && TEST_OP) -+ { -+ t = *ip++; -+ if (t >= 16) -+ goto match; -+ litp = ip - 1; -+ if (t == 0) -+ { -+ t = 15; -+ while (*ip == 0) -+ t += 255, ip++; -+ t += *ip++; -+ } -+ lit = t + 3; -+ copy_literal_run: -+ *op++ = *ip++; -+ *op++ = *ip++; -+ *op++ = *ip++; -+ first_literal_run: -+ do -+ *op++ = *ip++; -+ while (--t > 0); -+ -+ t = *ip++; -+ -+ if (t >= 16) -+ goto match; -+ m_pos = op - 1 - 0x800; -+ m_pos -= t >> 2; -+ m_pos -= *ip++ << 2; -+ *op++ = *m_pos++; -+ *op++ = *m_pos++; -+ *op++ = *m_pos++; -+ lit = 0; -+ goto match_done; -+ -+ while (TEST_IP && TEST_OP) -+ { -+ if (t < 16) -+ { -+ m_pos = op - 1; -+ m_pos -= t >> 2; -+ m_pos -= *ip++ << 2; -+ -+ if (litp == NULL) -+ goto copy_m1; -+ -+ nl = ip[-2] & 3; -+ if (nl == 0 && lit == 1 && ip[0] >= 16) -+ { -+ next_lit = nl; -+ lit += 2; -+ *litp = LZO_BYTE ((*litp & ~3) | lit); -+ copy2 (ip - 2, m_pos, op - m_pos); -+ o_m1_a++; -+ } -+ else if (nl == 0 && ip[0] < 16 && ip[0] != 0 -+ && (lit + 2 + ip[0] < 16)) -+ { -+ t = *ip++; -+ *litp &= ~3; -+ copy2 (ip - 3 + 1, m_pos, op - m_pos); -+ litp += 2; -+ if (lit > 0) -+ memmove (litp + 1, litp, lit); -+ lit += 2 + t + 3; -+ *litp = LZO_BYTE (lit - 3); -+ -+ o_m1_b++; -+ *op++ = *m_pos++; -+ *op++ = *m_pos++; -+ goto copy_literal_run; -+ } -+ copy_m1: -+ *op++ = *m_pos++; -+ *op++ = *m_pos++; -+ } -+ else -+ { -+ match: -+ if (t >= 64) -+ { -+ m_pos = op - 1; -+ m_pos -= (t >> 2) & 7; -+ m_pos -= *ip++ << 3; -+ t = (t >> 5) - 1; -+ if (litp == NULL) -+ goto copy_m; -+ -+ nl = ip[-2] & 3; -+ if (t == 1 && lit > 3 && nl == 0 && -+ ip[0] < 16 && ip[0] != 0 -+ && (lit + 3 + ip[0] < 16)) -+ { -+ t = *ip++; -+ copy3 (ip - 1 - 2, m_pos, -+ op - m_pos); -+ lit += 3 + t + 3; -+ *litp = LZO_BYTE (lit - 3); -+ o_m2++; -+ *op++ = *m_pos++; -+ *op++ = *m_pos++; -+ *op++ = *m_pos++; -+ goto copy_literal_run; -+ } -+ } -+ else -+ { -+ if (t >= 32) -+ { -+ t &= 31; -+ if (t == 0) -+ { -+ t = 31; -+ while (*ip == 0) -+ t += 255, -+ ip++; -+ t += *ip++; -+ } -+ m_pos = op - 1; -+ m_pos -= *ip++ >> 2; -+ m_pos -= *ip++ << 6; -+ } -+ else -+ { -+ m_pos = op; -+ m_pos -= (t & 8) << 11; -+ t &= 7; -+ if (t == 0) -+ { -+ t = 7; -+ while (*ip == 0) -+ t += 255, -+ ip++; -+ t += *ip++; -+ } -+ m_pos -= *ip++ >> 2; -+ m_pos -= *ip++ << 6; -+ if (m_pos == op) -+ goto eof_found; -+ m_pos -= 0x4000; -+ } -+ if (litp == NULL) -+ goto copy_m; -+ -+ nl = ip[-2] & 3; -+ if (t == 1 && lit == 0 && nl == 0 -+ && ip[0] >= 16) -+ { -+ next_lit = nl; -+ lit += 3; -+ *litp = LZO_BYTE ((*litp & ~3) -+ | lit); -+ copy3 (ip - 3, m_pos, -+ op - m_pos); -+ o_m3_a++; -+ } -+ else if (t == 1 && lit <= 3 && nl == 0 -+ && ip[0] < 16 && ip[0] != 0 -+ && (lit + 3 + ip[0] < 16)) -+ { -+ t = *ip++; -+ *litp &= ~3; -+ copy3 (ip - 4 + 1, m_pos, -+ op - m_pos); -+ litp += 2; -+ if (lit > 0) -+ memmove (litp + 1, -+ litp, lit); -+ lit += 3 + t + 3; -+ *litp = LZO_BYTE (lit - 3); -+ -+ o_m3_b++; -+ *op++ = *m_pos++; -+ *op++ = *m_pos++; -+ *op++ = *m_pos++; -+ goto copy_literal_run; -+ } -+ } -+ copy_m: -+ *op++ = *m_pos++; -+ *op++ = *m_pos++; -+ do -+ *op++ = *m_pos++; -+ while (--t > 0); -+ } -+ -+ match_done: -+ if (next_lit == NO_LIT) -+ { -+ t = ip[-2] & 3; -+ lit = t; -+ litp = ip - 2; -+ } -+ else -+ t = next_lit; -+ next_lit = NO_LIT; -+ if (t == 0) -+ break; -+ match_next: -+ do -+ *op++ = *ip++; -+ while (--t > 0); -+ t = *ip++; -+ } -+ } -+ -+ *out_len = op - out; -+ return LZO_E_EOF_NOT_FOUND; -+ -+ eof_found: -+ *out_len = op - out; -+ return (ip == ip_end ? LZO_E_OK : -+ (ip < -+ ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); -+} -+ -+/* interface to jffs2 bbc follows */ -+ -+#include "jffs2_bbc_framework.h" -+ -+#define BLOCKSIZE 4096 -+#define OUTBLOCKSIZE (BLOCKSIZE + BLOCKSIZE / 64 + 16 + 3) -+ -+#define JFFS2_BBC_LZO_BLOCK_SIGN {0x3f, 0x47, 0x5a, 0x18} -+ -+static int -+jffs2_bbc_lzo_compressor_init (void); -+ -+static void -+jffs2_bbc_lzo_compressor_deinit (void); -+ -+static int -+jffs2_bbc_lzo_compress (void *model, unsigned char *input, -+ unsigned char *output, unsigned long *sourcelen, -+ unsigned long *dstlen); -+ -+static int -+jffs2_bbc_lzo_estimate (void *model, unsigned char *input, -+ unsigned long sourcelen, unsigned long *dstlen, -+ unsigned long *readtime, unsigned long *writetime); -+ -+static int -+jffs2_bbc_lzo_decompress (void *model, unsigned char *input, -+ unsigned char *output, unsigned long sourcelen, -+ unsigned long dstlen); -+ -+static char * -+jffs2_bbc_lzo_proc_info (void); -+ -+static int -+jffs2_bbc_lzo_proc_command (char *command); -+ -+struct jffs2_bbc_compressor_type jffs2_bbc_lzo = { -+ "lzo", -+ 0, -+ JFFS2_BBC_LZO_BLOCK_SIGN, -+ jffs2_bbc_lzo_compressor_init, -+ NULL, -+ NULL, -+ jffs2_bbc_lzo_compressor_deinit, -+ jffs2_bbc_lzo_compress, -+ jffs2_bbc_lzo_estimate, -+ jffs2_bbc_lzo_decompress, -+ jffs2_bbc_lzo_proc_info, -+ jffs2_bbc_lzo_proc_command -+}; -+ -+static int -+no_lzo1x_optimize (lzo_byte * src, lzo_uint src_len, -+ lzo_byte * dst, lzo_uintp dst_len, lzo_voidp wrkmem) -+{ -+ return 0; -+} -+ -+#ifdef __KERNEL__ -+static lzo_compress_t lzo1x_compressor = lzo1x_1_compress; -+static lzo_optimize_t lzo1x_optimizer = no_lzo1x_optimize; -+static int lzo1x_compressor_type = 1; -+static int lzo1x_optimize_type = 0; -+static unsigned long lzo1x_compressor_memsize = LZO1X_1_MEM_COMPRESS; -+#else -+static lzo_compress_t lzo1x_compressor = lzo1x_999_compress; -+static lzo_optimize_t lzo1x_optimizer = lzo1x_optimize; -+static int lzo1x_compressor_type = 999; -+static int lzo1x_optimize_type = 1; -+static unsigned long lzo1x_compressor_memsize = LZO1X_999_MEM_COMPRESS; -+#endif -+ -+static lzo_bytep wrkmem = NULL; /* temporary buffer for compression, used by lzo */ -+static lzo_bytep cmprssmem = NULL; /* temporary buffer for compression, used by interface */ -+ -+static int -+jffs2_bbc_lzo_compressor_init (void) -+{ -+ wrkmem = (lzo_bytep) jffs2_bbc_malloc (lzo1x_compressor_memsize); -+ cmprssmem = (lzo_bytep) jffs2_bbc_malloc (OUTBLOCKSIZE); -+ return !(wrkmem && cmprssmem); -+} -+ -+static void -+jffs2_bbc_lzo_compressor_deinit (void) -+{ -+ jffs2_bbc_free (wrkmem); -+ jffs2_bbc_free (cmprssmem); -+} -+ -+static int -+jffs2_bbc_lzo_compress (void *model, unsigned char *input, -+ unsigned char *output, unsigned long *sourcelen, -+ unsigned long *dstlen) -+{ -+ lzo_uint csize = OUTBLOCKSIZE; -+ lzo_uint isize = *sourcelen; -+ int retval; -+ if ((retval = -+ lzo1x_compressor (input, *sourcelen, cmprssmem, &csize, -+ wrkmem)) != LZO_E_OK) -+ { -+ *sourcelen = *dstlen = 0; -+ return retval; -+ } -+ else -+ { -+ retval = lzo1x_optimizer (cmprssmem, csize, input, &isize, -+ NULL); -+ csize += 2; -+ if (csize <= *dstlen) { -+ *dstlen = csize; -+ *(output++) = jffs2_bbc_lzo.block_sign[0]; -+ *(output++) = jffs2_bbc_lzo.block_sign[1]; -+ memcpy (output, cmprssmem, csize - 2); -+ return retval; -+ } else { -+ *sourcelen = *dstlen = 0; -+ return -1; -+ } -+ } -+} -+ -+static int -+jffs2_bbc_lzo_estimate (void *model, unsigned char *input, -+ unsigned long sourcelen, unsigned long *dstlen, -+ unsigned long *readtime, unsigned long *writetime) -+{ -+ *dstlen = sourcelen * 55 / 100; -+ *readtime = JFFS2_BBC_ZLIB_READ_TIME / 2; -+ *writetime = JFFS2_BBC_ZLIB_WRITE_TIME * 8 / 10; /* LZO1X-1 is much-much faster, -+ but LZO1X-999 is slow. The default mode for inside kernel compression is LZO1X-1 -+ This should be *0.4 really */ -+ return 0; -+} -+ -+static int -+jffs2_bbc_lzo_decompress (void *model, unsigned char *input, -+ unsigned char *output, unsigned long sourcelen, -+ unsigned long dstlen) -+{ -+ lzo_uint outlen = dstlen; -+ if ( ( *(input++) != (unsigned char)jffs2_bbc_lzo.block_sign[0] ) || -+ ( *(input++) != (unsigned char)jffs2_bbc_lzo.block_sign[1] ) -+ ) { -+ return -1; -+ } else { -+ return lzo1x_decompress (input, sourcelen - 2, output, &outlen, NULL); -+ } -+} -+ -+static char * -+jffs2_bbc_lzo_proc_info (void) -+{ -+ if (lzo1x_compressor_type == 1) -+ { -+ if (lzo1x_optimize_type == 1) -+ { -+ return "LZO1X-1 compression with optimization"; -+ } -+ else -+ { -+ return "LZO1X-1 compression without optimization"; -+ } -+ } -+ else if (lzo1x_compressor_type == 999) -+ { -+ if (lzo1x_optimize_type == 1) -+ { -+ return "LZO1X-999 compression with optimization"; -+ } -+ else -+ { -+ return "LZO1X-999 compression without optimization"; -+ } -+ } -+ else -+ { -+ return "Unknown configuration!"; -+ } -+} -+ -+static int -+jffs2_bbc_lzo_proc_command (char *command) -+{ -+ switch (*command) -+ { -+ case 'o': -+ /* switch optimization off */ -+ lzo1x_optimizer = no_lzo1x_optimize; -+ lzo1x_optimize_type = 0; -+ jffs2_bbc_print1 ("Compression optimization switched off.\n"); -+ return 0; -+ case 'O': -+ /* switch optimization on */ -+ lzo1x_optimizer = lzo1x_optimize; -+ lzo1x_optimize_type = 1; -+ jffs2_bbc_print1 ("Compression optimization switched on.\n"); -+ return 0; -+ case '1': -+ /* switch compression to LZO1X-1 */ -+ jffs2_bbc_free (wrkmem); -+ lzo1x_compressor_type = 1; -+ lzo1x_compressor = lzo1x_1_compress; -+ lzo1x_compressor_memsize = LZO1X_1_MEM_COMPRESS; -+ wrkmem = (lzo_bytep) -+ jffs2_bbc_malloc (lzo1x_compressor_memsize); -+ jffs2_bbc_print1 ("Compression type switched to LZO1X-1.\n"); -+ return 0; -+ case '9': -+ /* switch compression to LZO1X-999 */ -+ jffs2_bbc_free (wrkmem); -+ lzo1x_compressor_type = 999; -+ lzo1x_compressor = lzo1x_999_compress; -+ lzo1x_compressor_memsize = LZO1X_999_MEM_COMPRESS; -+ wrkmem = (lzo_bytep) -+ jffs2_bbc_malloc (lzo1x_compressor_memsize); -+ jffs2_bbc_print1 -+ ("Compression type switched to LZO1X-999.\n"); -+ return 0; -+ default: -+ jffs2_bbc_print1 ("Unknown command!\n"); -+ return 0; -+ } -+} -+ -+ -+struct jffs2_bbc_compressor_type * -+jffs2_bbc_lzo_init (int mode) -+{ -+ if (jffs2_bbc_register_compressor (&jffs2_bbc_lzo) == 0) -+ { -+ return &jffs2_bbc_lzo; -+ } -+ else -+ { -+ return NULL; -+ } -+} -+ -+void -+jffs2_bbc_lzo_deinit (void) -+{ -+ jffs2_bbc_unregister_compressor (&jffs2_bbc_lzo); -+} ---- /dev/null -+++ b/fs/jffs2/jffs2_bbc_lzss_comp.c -@@ -0,0 +1,385 @@ -+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ -+ -+/* -+ jffs2_bbc_lzss_comp.c -- Lempel-Ziv-Storer-Szymanski compression module for jffs2 -+ Copyright (C) 2004 Patrik Kluba -+ Based on the LZSS source included in LDS (lossless datacompression sources) -+ Block-compression modifications by Patrik Kluba -+ $Header: /openwrt/openwrt/package/linux/kernel-patches/301-jffs-compression,v 1.1 2005/03/26 10:33:31 wbx Exp $ -+*/ -+ -+/* -+Original copyright follows: -+ -+************************************************************** -+ LZSS.C -- A Data Compression Program -+************************************************************** -+ 4/6/1989 Haruhiko Okumura -+ Use, distribute, and modify this program freely. -+ Please send me your improved versions. -+ PC-VAN SCIENCE -+ NIFTY-Serve PAF01022 -+ CompuServe 74050,1022 -+************************************************************** -+ -+*/ -+ -+/* -+ -+ 2004-02-16 pajko <pajko(AT)halom(DOT)u-szeged(DOT)hu> -+ Initial release -+ -+*/ -+ -+/* lzss.c */ -+ -+#define N 4096 /* size of ring buffer */ -+#define F 18 /* upper limit for match_length */ -+#define THRESHOLD 2 /* encode string into position and length -+ if match_length is greater than this */ -+#define NIL N /* index for root of binary search trees */ -+ -+static unsigned char -+ text_buf[N + F - 1]; /* ring buffer of size N, -+ with extra F-1 bytes to facilitate string comparison */ -+static unsigned long match_position, match_length; /* of longest match. These are -+ set by the InsertNode() procedure. */ -+static unsigned long lson[N + 1], rson[N + 257], dad[N + 1]; /* left & right children & -+ parents -- These constitute binary search trees. */ -+ -+static void InitTree(void) /* initialize trees */ -+{ -+ unsigned long i; -+ -+ /* For i = 0 to N - 1, rson[i] and lson[i] will be the right and -+ left children of node i. These nodes need not be initialized. -+ Also, dad[i] is the parent of node i. These are initialized to -+ NIL (= N), which stands for 'not used.' -+ For i = 0 to 255, rson[N + i + 1] is the root of the tree -+ for strings that begin with character i. These are initialized -+ to NIL. Note there are 256 trees. */ -+ -+ for (i = N + 1; i <= N + 256; i++) rson[i] = NIL; -+ for (i = 0; i < N; i++) dad[i] = NIL; -+} -+ -+static void InsertNode(unsigned long r) -+ /* Inserts string of length F, text_buf[r..r+F-1], into one of the -+ trees (text_buf[r]'th tree) and returns the longest-match position -+ and length via the global variables match_position and match_length. -+ If match_length = F, then removes the old node in favor of the new -+ one, because the old one will be deleted sooner. -+ Note r plays double role, as tree node and position in buffer. */ -+{ -+ unsigned long i, p; -+ unsigned char *key; -+ signed long cmp; -+ -+ cmp = 1; key = &text_buf[r]; p = N + 1 + key[0]; -+ rson[r] = lson[r] = NIL; match_length = 0; -+ for ( ; ; ) { -+ if (cmp >= 0) { -+ if (rson[p] != NIL) p = rson[p]; -+ else { rson[p] = r; dad[r] = p; return; } -+ } else { -+ if (lson[p] != NIL) p = lson[p]; -+ else { lson[p] = r; dad[r] = p; return; } -+ } -+ for (i = 1; i < F; i++) -+ if ((cmp = key[i] - text_buf[p + i]) != 0) break; -+ if (i > match_length) { -+ match_position = p; -+ if ((match_length = i) >= F) break; -+ } -+ } -+ dad[r] = dad[p]; lson[r] = lson[p]; rson[r] = rson[p]; -+ dad[lson[p]] = r; dad[rson[p]] = r; -+ if (rson[dad[p]] == p) rson[dad[p]] = r; -+ else lson[dad[p]] = r; -+ dad[p] = NIL; /* remove p */ -+} -+ -+static void DeleteNode(unsigned long p) /* deletes node p from tree */ -+{ -+ unsigned long q; -+ -+ if (dad[p] == NIL) return; /* not in tree */ -+ if (rson[p] == NIL) q = lson[p]; -+ else if (lson[p] == NIL) q = rson[p]; -+ else { -+ q = lson[p]; -+ if (rson[q] != NIL) { -+ do { q = rson[q]; } while (rson[q] != NIL); -+ rson[dad[q]] = lson[q]; dad[lson[q]] = dad[q]; -+ lson[q] = lson[p]; dad[lson[p]] = q; -+ } -+ rson[q] = rson[p]; dad[rson[p]] = q; -+ } -+ dad[q] = dad[p]; -+ if (rson[dad[p]] == p) rson[dad[p]] = q; else lson[dad[p]] = q; -+ dad[p] = NIL; -+} -+ -+/* modified for block compression */ -+/* on return, srclen will contain the number of successfully compressed bytes -+ and dstlen will contain completed compressed bytes */ -+ -+static int Encode(unsigned char *srcbuf, unsigned char *dstbuf, unsigned long *srclen, -+ unsigned long *dstlen) -+{ -+ unsigned long i, len, r, c, s, last_match_length, code_buf_ptr; -+ unsigned char code_buf[17], mask; -+ unsigned char *ip, *op; -+ unsigned long written = 0; -+ unsigned long read = 0; -+ unsigned char *srcend = srcbuf + *srclen; -+ unsigned char *dstend = dstbuf + *dstlen; -+ ip = srcbuf; -+ op = dstbuf; -+ InitTree(); /* initialize trees */ -+ code_buf[0] = 0; /* code_buf[1..16] saves eight units of code, and -+ code_buf[0] works as eight flags, "1" representing that the unit -+ is an unencoded letter (1 byte), "0" a position-and-length pair -+ (2 bytes). Thus, eight units require at most 16 bytes of code. */ -+ code_buf_ptr = mask = 1; -+ s = 0; r = N - F; -+ for (i = s; i < r; i++) text_buf[i] = ' '; /* Clear the buffer with -+ any character that will appear often. */ -+ for (len = 0; (len < F) && (ip < srcend); len++) -+ text_buf[r + len] = *(ip++); /* Read F bytes into the last F bytes of -+ the buffer */ -+ read = len; -+ for (i = 1; i <= F; i++) InsertNode(r - i); /* Insert the F strings, -+ each of which begins with one or more 'space' characters. Note -+ the order in which these strings are inserted. This way, -+ degenerate trees will be less likely to occur. */ -+ InsertNode(r); /* Finally, insert the whole string just read. The -+ global variables match_length and match_position are set. */ -+ do { -+ if (match_length > len) match_length = len; /* match_length -+ may be spuriously long near the end of text. */ -+ if (match_length <= THRESHOLD) { -+ match_length = 1; /* Not long enough match. Send one byte. */ -+ code_buf[0] |= mask; /* 'send one byte' flag */ -+ code_buf[code_buf_ptr++] = text_buf[r]; /* Send uncoded. */ -+ } else { -+ code_buf[code_buf_ptr++] = match_position; -+ code_buf[code_buf_ptr++] = (((match_position >> 4) & 0xf0) -+ | (match_length - (THRESHOLD + 1))); /* Send position and -+ length pair. Note match_length > THRESHOLD. */ -+ } -+ if ((mask <<= 1) == 0) { /* Shift mask left one bit. */ -+ if ((op + code_buf_ptr) > dstend) { -+ *dstlen = written; /* written contains bytes of complete compressed -+ code */ -+ return -1; -+ }; -+ for (i = 0; i < code_buf_ptr; *(op++) = code_buf[i++]); /* Send at most 8 units of */ -+ /* code together */ -+ written += code_buf_ptr; -+ *srclen = read; /* this many bytes have been successfully compressed */ -+ code_buf[0] = 0; code_buf_ptr = mask = 1; -+ } -+ last_match_length = match_length; -+ for (i = 0; (i < last_match_length) && (ip < srcend); i++) { -+ c = *(ip++); -+ DeleteNode(s); /* Delete old strings and */ -+ text_buf[s] = c; /* read new bytes */ -+ if (s < F - 1) text_buf[s + N] = c; /* If the position is -+ near the end of buffer, extend the buffer to make -+ string comparison easier. */ -+ s = (s + 1) & (N - 1); r = (r + 1) & (N - 1); -+ /* Since this is a ring buffer, increment the position -+ modulo N. */ -+ InsertNode(r); /* Register the string in text_buf[r..r+F-1] */ -+ } -+ read += i; -+ while (i++ < last_match_length) { /* After the end of text, */ -+ DeleteNode(s); /* no need to read, but */ -+ s = (s + 1) & (N - 1); r = (r + 1) & (N - 1); -+ if (--len) InsertNode(r); /* buffer may not be empty. */ -+ } -+ } while (len > 0); /* until length of string to be processed is zero */ -+ if (code_buf_ptr > 1) { /* Send remaining code. */ -+ if ((op + code_buf_ptr) > dstend) { -+ *dstlen = written; -+ return -1; -+ } -+ for (i = 0; i < code_buf_ptr; *(op++) = code_buf[i++]); -+ written += code_buf_ptr; -+ *srclen = read; -+ } -+ *dstlen = written; -+ return 0; -+} -+ -+static int Decode(unsigned char *srcbuf, unsigned char *dstbuf, unsigned long srclen, -+ unsigned long dstlen) /* Just the reverse of Encode(). */ -+{ -+ unsigned long i, r, c, j, k, flags; -+ unsigned char *ip, *op; -+ unsigned long written; -+ unsigned long read; -+ unsigned char *srcend = srcbuf + srclen; -+ unsigned char *dstend = dstbuf + dstlen; -+ read = written = 0; -+ ip = srcbuf; -+ op = dstbuf; -+ for (i = 0; i < N - F; i++) text_buf[i] = ' '; -+ r = N - F; flags = 0; -+ for ( ; ; ) { -+ if (((flags >>= 1) & 256) == 0) { -+ if (ip >= srcend) return 0; -+ c = *(ip++); -+ flags = c | 0xff00; /* uses higher byte cleverly */ -+ } /* to count eight */ -+ if (flags & 1) { -+ if (ip >= srcend) return 0; -+ c = *(ip++); -+ if (op >= dstend) return -1; -+ *(op++) = text_buf[r++] = c; r &= (N - 1); -+ } else { -+ if ((ip + 2) > srcend) return 0; -+ i = *(ip++); -+ j = *(ip++); -+ i |= ((j & 0xf0) << 4); j = (j & 0x0f) + THRESHOLD; -+ if ((op + j + 1) > dstend) return -1; -+ for (k = 0; k <= j; k++) { -+ c = text_buf[(i + k) & (N - 1)]; -+ *(op++) = text_buf[r++] = c; r &= (N - 1); -+ } -+ } -+ } -+} -+ -+/* interface to jffs2 bbc follows */ -+ -+#include "jffs2_bbc_framework.h" -+ -+ -+#define JFFS2_BBC_LZSS_BLOCK_SIGN {0x27, 0x6f, 0x12, 0xc4} -+ -+static int -+jffs2_bbc_lzss_compressor_init (void); -+ -+static void -+jffs2_bbc_lzss_compressor_deinit (void); -+ -+static int -+jffs2_bbc_lzss_compress (void *model, unsigned char *input, -+ unsigned char *output, unsigned long *sourcelen, -+ unsigned long *dstlen); -+ -+static int -+jffs2_bbc_lzss_estimate (void *model, unsigned char *input, -+ unsigned long sourcelen, unsigned long *dstlen, -+ unsigned long *readtime, unsigned long *writetime); -+ -+static int -+jffs2_bbc_lzss_decompress (void *model, unsigned char *input, -+ unsigned char *output, unsigned long sourcelen, -+ unsigned long dstlen); -+ -+static char * -+jffs2_bbc_lzss_proc_info (void); -+ -+static int -+jffs2_bbc_lzss_proc_command (char *command); -+ -+struct jffs2_bbc_compressor_type jffs2_bbc_lzss = { -+ "lzss", -+ 0, -+ JFFS2_BBC_LZSS_BLOCK_SIGN, -+ jffs2_bbc_lzss_compressor_init, -+ NULL, -+ NULL, -+ jffs2_bbc_lzss_compressor_deinit, -+ jffs2_bbc_lzss_compress, -+ jffs2_bbc_lzss_estimate, -+ jffs2_bbc_lzss_decompress, -+ jffs2_bbc_lzss_proc_info, -+ jffs2_bbc_lzss_proc_command -+}; -+ -+static int -+jffs2_bbc_lzss_compressor_init (void) -+{ -+ return 0; -+} -+ -+static void -+jffs2_bbc_lzss_compressor_deinit (void) -+{ -+} -+ -+static int -+jffs2_bbc_lzss_compress (void *model, unsigned char *input, -+ unsigned char *output, unsigned long *sourcelen, -+ unsigned long *dstlen) -+{ -+ int retval; -+ unsigned long dst = *dstlen; -+ *(output++) = jffs2_bbc_lzss.block_sign[0]; -+ *(output++) = jffs2_bbc_lzss.block_sign[1]; -+ dst -= 2; -+ retval = Encode(input, output, sourcelen, &dst); -+ dst += 2; -+ *dstlen = dst; -+ return retval; -+} -+ -+static int -+jffs2_bbc_lzss_estimate (void *model, unsigned char *input, -+ unsigned long sourcelen, unsigned long *dstlen, -+ unsigned long *readtime, unsigned long *writetime) -+{ -+ *dstlen = sourcelen * 60 / 100; -+ *readtime = JFFS2_BBC_ZLIB_READ_TIME * 12 / 10; -+ *writetime = JFFS2_BBC_ZLIB_WRITE_TIME * 3; -+ return 0; -+} -+ -+static int -+jffs2_bbc_lzss_decompress (void *model, unsigned char *input, -+ unsigned char *output, unsigned long sourcelen, -+ unsigned long dstlen) -+{ -+ if ( ( *(input++) != (unsigned char)jffs2_bbc_lzss.block_sign[0] ) || -+ ( *(input++) != (unsigned char)jffs2_bbc_lzss.block_sign[1] ) -+ ) { -+ return -1; -+ } else { -+ return Decode(input, output, sourcelen - 2, dstlen); -+ } -+} -+ -+static char * -+jffs2_bbc_lzss_proc_info (void) -+{ -+ return "Lempel-Ziv-Storer-Szymanski compression module"; -+} -+ -+static int -+jffs2_bbc_lzss_proc_command (char *command) -+{ -+ return 0; -+} -+ -+struct jffs2_bbc_compressor_type * -+jffs2_bbc_lzss_init (int mode) -+{ -+ if (jffs2_bbc_register_compressor (&jffs2_bbc_lzss) == 0) -+ { -+ return &jffs2_bbc_lzss; -+ } -+ else -+ { -+ return NULL; -+ } -+} -+ -+void -+jffs2_bbc_lzss_deinit (void) -+{ -+ jffs2_bbc_unregister_compressor (&jffs2_bbc_lzss); -+} ---- /dev/null -+++ b/fs/jffs2/linux-2.4.25.hpatch -@@ -0,0 +1,97 @@ -+FMakefile -+=BBC insertion -+-COMPR_OBJS -+iMakefile.bbc.inc -++ -+I -+?JFFS2_OBJS -++ $(JFFS2_BBC_KERNEL_OBJS) \ -+ -+F../Config.in -+=BBC insertion -+-tristate 'Compressed ROM file system support' CONFIG_CRAMFS -+iConfig.in.bbc.inc -++ -+I -+F../../Documentation/Configure.help -+=BBC insertion -+-JFFS stats available -+iConfigure.help.bbc.inc -++ -+I -+Fcompr_zlib.c -+=(de)compress->(de)compress2 -+-int zlib_compress(unsigned char *data_in, unsigned char *cpage_out, -++int jffs2_zlib_compress2(unsigned char *data_in, unsigned char *cpage_out, -+-void zlib_decompress(unsigned char *data_in, unsigned char *cpage_out, -++void jffs2_zlib_decompress2(unsigned char *data_in, unsigned char *cpage_out, -+?inflateEnd(&strm); -+?} -++ -++extern int jffs2_zlib_compress(unsigned char *data_in, unsigned char *cpage_out, __u32 * sourcelen, __u32 * dstlen); -++extern void jffs2_zlib_decompress(unsigned char *data_in, unsigned char *cpage_out, __u32 srclen, __u32 destlen); -++ -++int zlib_compress(unsigned char *data_in, unsigned char *cpage_out, -++ __u32 *sourcelen, __u32 *dstlen) -++{ -++ return jffs2_zlib_compress(data_in,cpage_out,sourcelen,dstlen); -++} -++ -++void zlib_decompress(unsigned char *data_in, unsigned char *cpage_out, -++ __u32 srclen, __u32 destlen) -++{ -++ jffs2_zlib_decompress(data_in,cpage_out,srclen,destlen); -++} -++ -+ -+Ffile.c -+=set_act_sb before write -+-#include -++#include "jffs2_bbc_framework.h" /**BBC**/ -+I -+?int jffs2_commit_write -+-jffs2_compress( -++ jffs2_bbc_model_set_act_sb(c); /**BBC**/ -+I -+ -+Fgc.c -+=set_act_sb before write -+-#include -++#include "jffs2_bbc_framework.h" /**BBC**/ -+I -+?int jffs2_garbage_collect_dnode( -+-jffs2_compress( -++ jffs2_bbc_model_set_act_sb(c); /**BBC**/ -+I -+ -+Fread.c -+=set_act_sb before read -+-#include -++#include "jffs2_bbc_framework.h" /**BBC**/ -+I -+?int jffs2_read_dnode( -+-jffs2_decompress( -++ jffs2_bbc_model_set_act_sb(c); /**BBC**/ -+I -+ -+Fsuper.c -+=init, load_model -+-#include -++#include "jffs2_bbc_fs.h" /**BBC**/ -+I -+?struct super_block *jffs2_read_super( -+-return sb; -++ jffs2_bbc_load_model(sb); /**BBC**/ -+I -+?void jffs2_put_super -+?c = JFFS2_SB_INFO -++ jffs2_bbc_unload_model(sb); /**BBC**/ -+?init_jffs2_fs(void) -+?int ret; -++ -++ jffs2_bbc_proc_init(); /**BBC**/ -++ -+?exit_jffs2_fs(void) -+?{ -++ jffs2_bbc_proc_deinit(); /**BBC**/ -++ ---- a/fs/jffs2/read.c -+++ b/fs/jffs2/read.c -@@ -35,6 +35,7 @@ - * - */ - -+#include "jffs2_bbc_framework.h" /**BBC**/ - #include <linux/kernel.h> - #include <linux/slab.h> - #include <linux/jffs2.h> -@@ -140,6 +141,7 @@ int jffs2_read_dnode(struct jffs2_sb_inf - D2(printk(KERN_DEBUG "Data CRC matches calculated CRC %08x\n", crc)); - if (ri->compr != JFFS2_COMPR_NONE) { - D2(printk(KERN_DEBUG "Decompress %d bytes from %p to %d bytes at %p\n", ri->csize, readbuf, ri->dsize, decomprbuf)); -+ jffs2_bbc_model_set_act_sb(c); /**BBC**/ - ret = jffs2_decompress(ri->compr, readbuf, decomprbuf, ri->csize, ri->dsize); - if (ret) { - printk(KERN_WARNING "Error: jffs2_decompress returned %d\n", ret); ---- a/fs/jffs2/super.c -+++ b/fs/jffs2/super.c -@@ -35,6 +35,7 @@ - * - */ - -+#include "jffs2_bbc_fs.h" /**BBC**/ - #include <linux/config.h> - #include <linux/kernel.h> - #include <linux/module.h> -@@ -272,6 +273,7 @@ static struct super_block *jffs2_read_su - sb->s_magic = JFFS2_SUPER_MAGIC; - if (!(sb->s_flags & MS_RDONLY)) - jffs2_start_garbage_collect_thread(c); -+ jffs2_bbc_load_model(sb); /**BBC**/ - return sb; - - out_root_i: -@@ -288,6 +290,7 @@ static struct super_block *jffs2_read_su - void jffs2_put_super (struct super_block *sb) - { - struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); -+ jffs2_bbc_unload_model(sb); /**BBC**/ - - D2(printk(KERN_DEBUG "jffs2: jffs2_put_super()\n")); - -@@ -344,6 +347,9 @@ static int __init init_jffs2_fs(void) - { - int ret; - -+ jffs2_bbc_proc_init(); /**BBC**/ -+ -+ - printk(KERN_NOTICE "JFFS2 version 2.1. (C) 2001 Red Hat, Inc., designed by Axis Communications AB.\n"); - - #ifdef JFFS2_OUT_OF_KERNEL -@@ -388,6 +394,8 @@ static int __init init_jffs2_fs(void) - - static void __exit exit_jffs2_fs(void) - { -+ jffs2_bbc_proc_deinit(); /**BBC**/ -+ - jffs2_destroy_slab_caches(); - jffs2_zlib_exit(); - unregister_filesystem(&jffs2_fs_type); diff --git a/target/linux/generic-2.4/patches/004-exec_pagesize.patch b/target/linux/generic-2.4/patches/004-exec_pagesize.patch deleted file mode 100644 index 2fbe7e3..0000000 --- a/target/linux/generic-2.4/patches/004-exec_pagesize.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/include/asm-mips/param.h -+++ b/include/asm-mips/param.h -@@ -55,7 +55,7 @@ - #endif /* defined(__KERNEL__) */ - #endif /* defined(HZ) */ - --#define EXEC_PAGESIZE 65536 -+#define EXEC_PAGESIZE 4096 - - #ifndef NGROUPS - #define NGROUPS 32 diff --git a/target/linux/generic-2.4/patches/005-mtd_flashtypes.patch b/target/linux/generic-2.4/patches/005-mtd_flashtypes.patch deleted file mode 100644 index 36cce1e..0000000 --- a/target/linux/generic-2.4/patches/005-mtd_flashtypes.patch +++ /dev/null @@ -1,920 +0,0 @@ ---- a/drivers/mtd/chips/Config.in -+++ b/drivers/mtd/chips/Config.in -@@ -45,6 +45,7 @@ fi - dep_tristate ' Support for Intel/Sharp flash chips' CONFIG_MTD_CFI_INTELEXT $CONFIG_MTD_GEN_PROBE - dep_tristate ' Support for AMD/Fujitsu flash chips' CONFIG_MTD_CFI_AMDSTD $CONFIG_MTD_GEN_PROBE - dep_tristate ' Support for ST (Advanced Architecture) flash chips' CONFIG_MTD_CFI_STAA $CONFIG_MTD_GEN_PROBE -+dep_tristate ' Support for SST flash chips' CONFIG_MTD_CFI_SSTSTD $CONFIG_MTD_GEN_PROBE - - dep_tristate ' Support for RAM chips in bus mapping' CONFIG_MTD_RAM $CONFIG_MTD - dep_tristate ' Support for ROM chips in bus mapping' CONFIG_MTD_ROM $CONFIG_MTD ---- a/drivers/mtd/chips/Makefile -+++ b/drivers/mtd/chips/Makefile -@@ -18,6 +18,7 @@ obj-$(CONFIG_MTD) += chipreg.o - obj-$(CONFIG_MTD_AMDSTD) += amd_flash.o - obj-$(CONFIG_MTD_CFI) += cfi_probe.o - obj-$(CONFIG_MTD_CFI_STAA) += cfi_cmdset_0020.o -+obj-$(CONFIG_MTD_CFI_SSTSTD) += cfi_cmdset_0701.o - obj-$(CONFIG_MTD_CFI_AMDSTD) += cfi_cmdset_0002.o - obj-$(CONFIG_MTD_CFI_INTELEXT) += cfi_cmdset_0001.o - obj-$(CONFIG_MTD_GEN_PROBE) += gen_probe.o ---- /dev/null -+++ b/drivers/mtd/chips/cfi_cmdset_0701.c -@@ -0,0 +1,855 @@ -+/* -+ * Common Flash Interface support: -+ * SST Standard Vendor Command Set (ID 0x0701) -+ * -+ * Copyright (C) 2000 Crossnet Co. <info@crossnet.co.jp> -+ * -+ * 2_by_8 routines added by Simon Munton -+ * -+ * This code is GPL -+ * -+ * $Id: cfi_cmdset_0701.c,v 1.1 2005/03/16 13:50:00 wbx Exp $ -+ * -+ */ -+ -+#include <linux/module.h> -+#include <linux/types.h> -+#include <linux/kernel.h> -+#include <linux/sched.h> -+#include <asm/io.h> -+#include <asm/byteorder.h> -+ -+#include <linux/errno.h> -+#include <linux/slab.h> -+#include <linux/delay.h> -+#include <linux/interrupt.h> -+#include <linux/mtd/map.h> -+#include <linux/mtd/cfi.h> -+ -+static int cfi_sststd_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *); -+static int cfi_sststd_write(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); -+static int cfi_sststd_erase_onesize(struct mtd_info *, struct erase_info *); -+static int cfi_sststd_erase_varsize(struct mtd_info *, struct erase_info *); -+static void cfi_sststd_sync (struct mtd_info *); -+static int cfi_sststd_suspend (struct mtd_info *); -+static void cfi_sststd_resume (struct mtd_info *); -+ -+static void cfi_sststd_destroy(struct mtd_info *); -+ -+struct mtd_info *cfi_cmdset_0701(struct map_info *, int); -+static struct mtd_info *cfi_sststd_setup (struct map_info *); -+ -+ -+static struct mtd_chip_driver cfi_sststd_chipdrv = { -+ probe: NULL, /* Not usable directly */ -+ destroy: cfi_sststd_destroy, -+ name: "cfi_cmdset_0701", -+ module: THIS_MODULE -+}; -+ -+struct mtd_info *cfi_cmdset_0701(struct map_info *map, int primary) -+{ -+ struct cfi_private *cfi = map->fldrv_priv; -+ int ofs_factor = cfi->interleave * cfi->device_type; -+ int i; -+ __u8 major, minor; -+ __u32 base = cfi->chips[0].start; -+ -+ if (cfi->cfi_mode==1){ -+ __u16 adr = primary?cfi->cfiq->P_ADR:cfi->cfiq->A_ADR; -+ -+ cfi_send_gen_cmd(0xAA, 0x5555, base, map, cfi, cfi->device_type, NULL); -+ cfi_send_gen_cmd(0x55, 0x2AAA, base, map, cfi, cfi->device_type, NULL); -+ cfi_send_gen_cmd(0x98, 0x5555, base, map, cfi, cfi->device_type, NULL); -+ -+ major = cfi_read_query(map, base + (adr+3)*ofs_factor); -+ minor = cfi_read_query(map, base + (adr+4)*ofs_factor); -+ -+ printk(" SST Query Table v%c.%c at 0x%4.4X\n", -+ major, minor, adr); -+ cfi_send_gen_cmd(0xf0, 0x5555, base, map, cfi, cfi->device_type, NULL); -+ -+ cfi_send_gen_cmd(0xAA, 0x5555, base, map, cfi, cfi->device_type, NULL); -+ cfi_send_gen_cmd(0x55, 0x2AAA, base, map, cfi, cfi->device_type, NULL); -+ cfi_send_gen_cmd(0x90, 0x5555, base, map, cfi, cfi->device_type, NULL); -+ cfi->mfr = cfi_read_query(map, base); -+ cfi->id = cfi_read_query(map, base + ofs_factor); -+ -+ cfi_send_gen_cmd(0xAA, 0x5555, base, map, cfi, cfi->device_type, NULL); -+ cfi_send_gen_cmd(0x55, 0x2AAA, base, map, cfi, cfi->device_type, NULL); -+ cfi_send_gen_cmd(0x98, 0x5555, base, map, cfi, cfi->device_type, NULL); -+ -+ switch (cfi->device_type) { -+ case CFI_DEVICETYPE_X16: -+ cfi->addr_unlock1 = 0x5555; -+ cfi->addr_unlock2 = 0x2AAA; -+ break; -+ default: -+ printk(KERN_NOTICE "Eep. Unknown cfi_cmdset_0701 device type %d\n", cfi->device_type); -+ return NULL; -+ } -+ } /* CFI mode */ -+ -+ for (i=0; i< cfi->numchips; i++) { -+ cfi->chips[i].word_write_time = 1<<cfi->cfiq->WordWriteTimeoutTyp; -+ cfi->chips[i].buffer_write_time = 1<<cfi->cfiq->BufWriteTimeoutTyp; -+ cfi->chips[i].erase_time = 1<<cfi->cfiq->BlockEraseTimeoutTyp; -+ } -+ -+ map->fldrv = &cfi_sststd_chipdrv; -+ MOD_INC_USE_COUNT; -+ -+ cfi_send_gen_cmd(0xf0, 0x5555, base, map, cfi, cfi->device_type, NULL); -+ return cfi_sststd_setup(map); -+} -+ -+static struct mtd_info *cfi_sststd_setup(struct map_info *map) -+{ -+ struct cfi_private *cfi = map->fldrv_priv; -+ struct mtd_info *mtd; -+ unsigned long devsize = (1<<cfi->cfiq->DevSize) * cfi->interleave; -+ -+ mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); -+ printk("number of %s chips: %d\n", (cfi->cfi_mode)?"JEDEC":"CFI",cfi->numchips); -+ -+ if (!mtd) { -+ printk("Failed to allocate memory for MTD device\n"); -+ kfree(cfi->cmdset_priv); -+ return NULL; -+ } -+ -+ memset(mtd, 0, sizeof(*mtd)); -+ mtd->priv = map; -+ mtd->type = MTD_NORFLASH; -+ /* Also select the correct geometry setup too */ -+ mtd->size = devsize * cfi->numchips; -+ -+ if (cfi->cfiq->NumEraseRegions == 1) { -+ /* No need to muck about with multiple erase sizes */ -+ mtd->erasesize = ((cfi->cfiq->EraseRegionInfo[0] >> 8) & ~0xff) * cfi->interleave; -+ } else { -+ unsigned long offset = 0; -+ int i,j; -+ -+ mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips; -+ mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info) * mtd->numeraseregions, GFP_KERNEL); -+ if (!mtd->eraseregions) { -+ printk("Failed to allocate memory for MTD erase region info\n"); -+ kfree(cfi->cmdset_priv); -+ return NULL; -+ } -+ -+ for (i=0; i<cfi->cfiq->NumEraseRegions; i++) { -+ unsigned long ernum, ersize; -+ ersize = ((cfi->cfiq->EraseRegionInfo[i] >> 8) & ~0xff) * cfi->interleave; -+ ernum = (cfi->cfiq->EraseRegionInfo[i] & 0xffff) + 1; -+ -+ if (mtd->erasesize < ersize) { -+ mtd->erasesize = ersize; -+ } -+ for (j=0; j<cfi->numchips; j++) { -+ mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].offset = (j*devsize)+offset; -+ mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].erasesize = ersize; -+ mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].numblocks = ernum; -+ } -+ offset += (ersize * ernum); -+ } -+ -+ // debug -+ for (i=0; i<mtd->numeraseregions;i++){ -+ printk("%d: offset=0x%x,size=0x%x,blocks=%d\n", -+ i,mtd->eraseregions[i].offset, -+ mtd->eraseregions[i].erasesize, -+ mtd->eraseregions[i].numblocks); -+ } -+ } -+ -+ switch (CFIDEV_BUSWIDTH) -+ { -+ case 1: -+ case 2: -+ case 4: -+ if (mtd->numeraseregions > 1) -+ mtd->erase = cfi_sststd_erase_varsize; -+ else -+ mtd->erase = cfi_sststd_erase_onesize; -+ mtd->read = cfi_sststd_read; -+ mtd->write = cfi_sststd_write; -+ break; -+ -+ default: -+ printk("Unsupported buswidth\n"); -+ kfree(mtd); -+ kfree(cfi->cmdset_priv); -+ return NULL; -+ break; -+ } -+ mtd->sync = cfi_sststd_sync; -+ mtd->suspend = cfi_sststd_suspend; -+ mtd->resume = cfi_sststd_resume; -+ mtd->flags = MTD_CAP_NORFLASH; -+ map->fldrv = &cfi_sststd_chipdrv; -+ mtd->name = map->name; -+ MOD_INC_USE_COUNT; -+ return mtd; -+} -+ -+static inline int do_read_onechip(struct map_info *map, struct flchip *chip, loff_t adr, size_t len, u_char *buf) -+{ -+ DECLARE_WAITQUEUE(wait, current); -+ unsigned long timeo = jiffies + HZ; -+ -+ retry: -+ cfi_spin_lock(chip->mutex); -+ -+ if (chip->state != FL_READY){ -+ printk("Waiting for chip to read, status = %d\n", chip->state); -+ set_current_state(TASK_UNINTERRUPTIBLE); -+ add_wait_queue(&chip->wq, &wait); -+ -+ cfi_spin_unlock(chip->mutex); -+ -+ schedule(); -+ remove_wait_queue(&chip->wq, &wait); -+ timeo = jiffies + HZ; -+ -+ goto retry; -+ } -+ -+ adr += chip->start; -+ -+ chip->state = FL_READY; -+ -+ map->copy_from(map, buf, adr, len); -+ -+ wake_up(&chip->wq); -+ cfi_spin_unlock(chip->mutex); -+ -+ return 0; -+} -+ -+static int cfi_sststd_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) -+{ -+ struct map_info *map = mtd->priv; -+ struct cfi_private *cfi = map->fldrv_priv; -+ unsigned long ofs; -+ int chipnum; -+ int ret = 0; -+ -+ /* ofs: offset within the first chip that the first read should start */ -+ -+ chipnum = (from >> cfi->chipshift); -+ ofs = from - (chipnum << cfi->chipshift); -+ -+ -+ *retlen = 0; -+ -+ while (len) { -+ unsigned long thislen; -+ -+ if (chipnum >= cfi->numchips) -+ break; -+ -+ if ((len + ofs -1) >> cfi->chipshift) -+ thislen = (1<<cfi->chipshift) - ofs; -+ else -+ thislen = len; -+ -+ ret = do_read_onechip(map, &cfi->chips[chipnum], ofs, thislen, buf); -+ if (ret) -+ break; -+ -+ *retlen += thislen; -+ len -= thislen; -+ buf += thislen; -+ -+ ofs = 0; -+ chipnum++; -+ } -+ return ret; -+} -+ -+static int do_write_oneword(struct map_info *map, struct flchip *chip, unsigned long adr, __u32 datum, int fast) -+{ -+ unsigned long timeo = jiffies + HZ; -+ unsigned int Last[4]; -+ unsigned long Count = 0; -+ struct cfi_private *cfi = map->fldrv_priv; -+ DECLARE_WAITQUEUE(wait, current); -+ int ret = 0; -+ -+ retry: -+ cfi_spin_lock(chip->mutex); -+ -+ if (chip->state != FL_READY){ -+ printk("Waiting for chip to write, status = %d\n", chip->state); -+ set_current_state(TASK_UNINTERRUPTIBLE); -+ add_wait_queue(&chip->wq, &wait); -+ -+ cfi_spin_unlock(chip->mutex); -+ -+ schedule(); -+ remove_wait_queue(&chip->wq, &wait); -+ printk("Wake up to write:\n"); -+ timeo = jiffies + HZ; -+ -+ goto retry; -+ } -+ -+ chip->state = FL_WRITING; -+ -+ adr += chip->start; -+ ENABLE_VPP(map); -+ cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X16, NULL); -+ cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, CFI_DEVICETYPE_X16, NULL); -+ cfi_send_gen_cmd(0xA0, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X16, NULL); -+ -+ cfi_write(map, datum, adr); -+ -+ cfi_spin_unlock(chip->mutex); -+ cfi_udelay(chip->word_write_time); -+ cfi_spin_lock(chip->mutex); -+ -+ Last[0] = cfi_read(map, adr); -+ // printk("Last[0] is %x\n", Last[0]); -+ Last[1] = cfi_read(map, adr); -+ // printk("Last[1] is %x\n", Last[1]); -+ Last[2] = cfi_read(map, adr); -+ // printk("Last[2] is %x\n", Last[2]); -+ -+ for (Count = 3; Last[(Count - 1) % 4] != Last[(Count - 2) % 4] && Count < 10000; Count++){ -+ cfi_spin_unlock(chip->mutex); -+ cfi_udelay(10); -+ cfi_spin_lock(chip->mutex); -+ -+ Last[Count % 4] = cfi_read(map, adr); -+ // printk("Last[%d%%4] is %x\n", Count, Last[Count%4]); -+ } -+ -+ if (Last[(Count - 1) % 4] != datum){ -+ printk("Last[%ld] is %x, datum is %x\n",(Count - 1) % 4,Last[(Count - 1) % 4],datum); -+ cfi_send_gen_cmd(0xF0, 0, chip->start, map, cfi, cfi->device_type, NULL); -+ DISABLE_VPP(map); -+ ret = -EIO; -+ } -+ DISABLE_VPP(map); -+ chip->state = FL_READY; -+ wake_up(&chip->wq); -+ cfi_spin_unlock(chip->mutex); -+ -+ return ret; -+} -+ -+static int cfi_sststd_write (struct mtd_info *mtd, loff_t to , size_t len, size_t *retlen, const u_char *buf) -+{ -+ struct map_info *map = mtd->priv; -+ struct cfi_private *cfi = map->fldrv_priv; -+ int ret = 0; -+ int chipnum; -+ unsigned long ofs, chipstart; -+ -+ *retlen = 0; -+ if (!len) -+ return 0; -+ -+ chipnum = to >> cfi->chipshift; -+ ofs = to - (chipnum << cfi->chipshift); -+ chipstart = cfi->chips[chipnum].start; -+ -+ /* If it's not bus-aligned, do the first byte write */ -+ if (ofs & (CFIDEV_BUSWIDTH-1)) { -+ unsigned long bus_ofs = ofs & ~(CFIDEV_BUSWIDTH-1); -+ int i = ofs - bus_ofs; -+ int n = 0; -+ u_char tmp_buf[4]; -+ __u32 datum; -+ -+ map->copy_from(map, tmp_buf, bus_ofs + cfi->chips[chipnum].start, CFIDEV_BUSWIDTH); -+ while (len && i < CFIDEV_BUSWIDTH) -+ tmp_buf[i++] = buf[n++], len--; -+ -+ if (cfi_buswidth_is_2()) { -+ datum = *(__u16*)tmp_buf; -+ } else if (cfi_buswidth_is_4()) { -+ datum = *(__u32*)tmp_buf; -+ } else { -+ return -EINVAL; /* should never happen, but be safe */ -+ } -+ -+ ret = do_write_oneword(map, &cfi->chips[chipnum], -+ bus_ofs, datum, 0); -+ if (ret) -+ return ret; -+ -+ ofs += n; -+ buf += n; -+ (*retlen) += n; -+ -+ if (ofs >> cfi->chipshift) { -+ chipnum ++; -+ ofs = 0; -+ if (chipnum == cfi->numchips) -+ return 0; -+ } -+ } -+ -+ /* We are now aligned, write as much as possible */ -+ while(len >= CFIDEV_BUSWIDTH) { -+ __u32 datum; -+ -+ if (cfi_buswidth_is_1()) { -+ datum = *(__u8*)buf; -+ } else if (cfi_buswidth_is_2()) { -+ datum = *(__u16*)buf; -+ } else if (cfi_buswidth_is_4()) { -+ datum = *(__u32*)buf; -+ } else { -+ return -EINVAL; -+ } -+ ret = do_write_oneword(map, &cfi->chips[chipnum], -+ ofs, datum, cfi->fast_prog); -+ if (ret) { -+ return ret; -+ } -+ -+ ofs += CFIDEV_BUSWIDTH; -+ buf += CFIDEV_BUSWIDTH; -+ (*retlen) += CFIDEV_BUSWIDTH; -+ len -= CFIDEV_BUSWIDTH; -+ -+ if (ofs >> cfi->chipshift) { -+ chipnum ++; -+ ofs = 0; -+ if (chipnum == cfi->numchips) -+ return 0; -+ chipstart = cfi->chips[chipnum].start; -+ } -+ } -+ -+ if (len & (CFIDEV_BUSWIDTH-1)) { -+ int i = 0, n = 0; -+ u_char tmp_buf[4]; -+ __u32 datum; -+ -+ map->copy_from(map, tmp_buf, ofs + cfi->chips[chipnum].start, CFIDEV_BUSWIDTH); -+ while (len--) -+ tmp_buf[i++] = buf[n++]; -+ -+ if (cfi_buswidth_is_2()) { -+ datum = *(__u16*)tmp_buf; -+ } else if (cfi_buswidth_is_4()) { -+ datum = *(__u32*)tmp_buf; -+ } else { -+ return -EINVAL; /* should never happen, but be safe */ -+ } -+ -+ ret = do_write_oneword(map, &cfi->chips[chipnum], -+ ofs, datum, 0); -+ if (ret) -+ return ret; -+ -+ (*retlen) += n; -+ } -+ -+ return 0; -+} -+ -+static inline int do_erase_oneblock(struct map_info *map, struct flchip *chip, unsigned long adr) -+{ -+ unsigned int status; -+ unsigned long timeo = jiffies + HZ; -+ struct cfi_private *cfi = map->fldrv_priv; -+ unsigned int rdy_mask; -+ DECLARE_WAITQUEUE(wait, current); -+ -+ retry: -+ cfi_spin_lock(chip->mutex); -+ -+ if (chip->state != FL_READY){ -+ set_current_state(TASK_UNINTERRUPTIBLE); -+ add_wait_queue(&chip->wq, &wait); -+ -+ cfi_spin_unlock(chip->mutex); -+ -+ schedule(); -+ remove_wait_queue(&chip->wq, &wait); -+ timeo = jiffies + HZ; -+ -+ goto retry; -+ } -+ -+ chip->state = FL_ERASING; -+ -+ adr += chip->start; -+ ENABLE_VPP(map); -+ cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X16, NULL); -+ cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, CFI_DEVICETYPE_X16, NULL); -+ cfi_send_gen_cmd(0x80, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X16, NULL); -+ cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X16, NULL); -+ cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, CFI_DEVICETYPE_X16, NULL); -+ cfi_write(map, CMD(0x30), adr); -+ -+ timeo = jiffies + (HZ*20); -+ -+ cfi_spin_unlock(chip->mutex); -+ schedule_timeout(HZ); -+ cfi_spin_lock(chip->mutex); -+ -+ rdy_mask = CMD(0x80); -+ -+ /* Once the state machine's known to be working I'll do that */ -+ -+ while ( ( (status = cfi_read(map,adr)) & rdy_mask ) != rdy_mask ) { -+ static int z=0; -+ -+ if (chip->state != FL_ERASING) { -+ /* Someone's suspended the erase. Sleep */ -+ set_current_state(TASK_UNINTERRUPTIBLE); -+ add_wait_queue(&chip->wq, &wait); -+ -+ cfi_spin_unlock(chip->mutex); -+ printk("erase suspended. Sleeping\n"); -+ -+ schedule(); -+ remove_wait_queue(&chip->wq, &wait); -+ timeo = jiffies + (HZ*2); -+ cfi_spin_lock(chip->mutex); -+ continue; -+ } -+ -+ /* OK Still waiting */ -+ if (time_after(jiffies, timeo)) { -+ chip->state = FL_READY; -+ cfi_spin_unlock(chip->mutex); -+ printk("waiting for erase to complete timed out."); -+ DISABLE_VPP(map); -+ return -EIO; -+ } -+ -+ /* Latency issues. Drop the lock, wait a while and retry */ -+ cfi_spin_unlock(chip->mutex); -+ -+ z++; -+ if ( 0 && !(z % 100 )) -+ printk("chip not ready yet after erase. looping\n"); -+ -+ cfi_udelay(1); -+ -+ cfi_spin_lock(chip->mutex); -+ continue; -+ } -+ -+ /* Done and happy. */ -+ DISABLE_VPP(map); -+ chip->state = FL_READY; -+ wake_up(&chip->wq); -+ cfi_spin_unlock(chip->mutex); -+ return 0; -+} -+ -+static int cfi_sststd_erase_varsize(struct mtd_info *mtd, struct erase_info *instr) -+{ -+ struct map_info *map = mtd->priv; -+ struct cfi_private *cfi = map->fldrv_priv; -+ unsigned long adr, len; -+ int chipnum, ret = 0; -+ int i, first; -+ struct mtd_erase_region_info *regions = mtd->eraseregions; -+ -+ if (instr->addr > mtd->size) -+ return -EINVAL; -+ -+ if ((instr->len + instr->addr) > mtd->size) -+ return -EINVAL; -+ -+ /* Check that both start and end of the requested erase are -+ * aligned with the erasesize at the appropriate addresses. -+ */ -+ -+ i = 0; -+ -+ /* Skip all erase regions which are ended before the start of -+ the requested erase. Actually, to save on the calculations, -+ we skip to the first erase region which starts after the -+ start of the requested erase, and then go back one. -+ */ -+ -+ while (i < mtd->numeraseregions && instr->addr >= regions[i].offset) -+ i++; -+ i--; -+ -+ /* OK, now i is pointing at the erase region in which this -+ erase request starts. Check the start of the requested -+ erase range is aligned with the erase size which is in -+ effect here. -+ */ -+ -+ if (instr->addr & (regions[i].erasesize-1)) -+ return -EINVAL; -+ -+ /* Remember the erase region we start on */ -+ first = i; -+ -+ /* Next, check that the end of the requested erase is aligned -+ * with the erase region at that address. -+ */ -+ -+ while (i<mtd->numeraseregions && (instr->addr + instr->len) >= regions[i].offset) -+ i++; -+ -+ /* As before, drop back one to point at the region in which -+ the address actually falls -+ */ -+ i--; -+ -+ if ((instr->addr + instr->len) & (regions[i].erasesize-1)) -+ return -EINVAL; -+ -+ chipnum = instr->addr >> cfi->chipshift; -+ adr = instr->addr - (chipnum << cfi->chipshift); -+ len = instr->len; -+ -+ i=first; -+ -+ while(len) { -+ ret = do_erase_oneblock(map, &cfi->chips[chipnum], adr); -+ -+ if (ret) -+ return ret; -+ -+ adr += regions[i].erasesize; -+ len -= regions[i].erasesize; -+ -+ if (adr % (1<< cfi->chipshift) == ((regions[i].offset + (regions[i].erasesize * regions[i].numblocks)) %( 1<< cfi->chipshift))) -+ i++; -+ -+ if (adr >> cfi->chipshift) { -+ adr = 0; -+ chipnum++; -+ -+ if (chipnum >= cfi->numchips) -+ break; -+ } -+ } -+ -+ instr->state = MTD_ERASE_DONE; -+ if (instr->callback) -+ instr->callback(instr); -+ -+ return 0; -+} -+ -+static int cfi_sststd_erase_onesize(struct mtd_info *mtd, struct erase_info *instr) -+{ -+ struct map_info *map = mtd->priv; -+ struct cfi_private *cfi = map->fldrv_priv; -+ unsigned long adr, len; -+ int chipnum, ret = 0; -+ -+ if (instr->addr & (mtd->erasesize - 1)) -+ return -EINVAL; -+ -+ if (instr->len & (mtd->erasesize -1)) -+ return -EINVAL; -+ -+ if ((instr->len + instr->addr) > mtd->size) -+ return -EINVAL; -+ -+ chipnum = instr->addr >> cfi->chipshift; -+ adr = instr->addr - (chipnum << cfi->chipshift); -+ len = instr->len; -+ -+ while(len) { -+ ret = do_erase_oneblock(map, &cfi->chips[chipnum], adr); -+ -+ if (ret) -+ return ret; -+ -+ adr += mtd->erasesize; -+ len -= mtd->erasesize; -+ -+ if (adr >> cfi->chipshift) { -+ adr = 0; -+ chipnum++; -+ -+ if (chipnum >= cfi->numchips) -+ break; -+ } -+ } -+ -+ instr->state = MTD_ERASE_DONE; -+ if (instr->callback) -+ instr->callback(instr); -+ -+ return 0; -+} -+ -+static void cfi_sststd_sync (struct mtd_info *mtd) -+{ -+ struct map_info *map = mtd->priv; -+ struct cfi_private *cfi = map->fldrv_priv; -+ int i; -+ struct flchip *chip; -+ int ret = 0; -+ DECLARE_WAITQUEUE(wait, current); -+ -+ for (i=0; !ret && i<cfi->numchips; i++) { -+ chip = &cfi->chips[i]; -+ -+ retry: -+ cfi_spin_lock(chip->mutex); -+ -+ switch(chip->state) { -+ case FL_READY: -+ case FL_STATUS: -+ case FL_CFI_QUERY: -+ case FL_JEDEC_QUERY: -+ chip->oldstate = chip->state; -+ chip->state = FL_SYNCING; -+ /* No need to wake_up() on this state change - -+ * as the whole point is that nobody can do anything -+ * with the chip now anyway. -+ */ -+ case FL_SYNCING: -+ cfi_spin_unlock(chip->mutex); -+ break; -+ -+ default: -+ /* Not an idle state */ -+ add_wait_queue(&chip->wq, &wait); -+ -+ cfi_spin_unlock(chip->mutex); -+ -+ schedule(); -+ -+ remove_wait_queue(&chip->wq, &wait); -+ -+ goto retry; -+ } -+ } -+ -+ /* Unlock the chips again */ -+ -+ for (i--; i >=0; i--) { -+ chip = &cfi->chips[i]; -+ -+ cfi_spin_lock(chip->mutex); -+ -+ if (chip->state == FL_SYNCING) { -+ chip->state = chip->oldstate; -+ wake_up(&chip->wq); -+ } -+ cfi_spin_unlock(chip->mutex); -+ } -+} -+ -+ -+static int cfi_sststd_suspend(struct mtd_info *mtd) -+{ -+ struct map_info *map = mtd->priv; -+ struct cfi_private *cfi = map->fldrv_priv; -+ int i; -+ struct flchip *chip; -+ int ret = 0; -+//printk("suspend\n"); -+ -+ for (i=0; !ret && i<cfi->numchips; i++) { -+ chip = &cfi->chips[i]; -+ -+ cfi_spin_lock(chip->mutex); -+ -+ switch(chip->state) { -+ case FL_READY: -+ case FL_STATUS: -+ case FL_CFI_QUERY: -+ case FL_JEDEC_QUERY: -+ chip->oldstate = chip->state; -+ chip->state = FL_PM_SUSPENDED; -+ /* No need to wake_up() on this state change - -+ * as the whole point is that nobody can do anything -+ * with the chip now anyway. -+ */ -+ case FL_PM_SUSPENDED: -+ break; -+ -+ default: -+ ret = -EAGAIN; -+ break; -+ } -+ cfi_spin_unlock(chip->mutex); -+ } -+ -+ /* Unlock the chips again */ -+ -+ if (ret) { -+ for (i--; i >=0; i--) { -+ chip = &cfi->chips[i]; -+ -+ cfi_spin_lock(chip->mutex); -+ -+ if (chip->state == FL_PM_SUSPENDED) { -+ chip->state = chip->oldstate; -+ wake_up(&chip->wq); -+ } -+ cfi_spin_unlock(chip->mutex); -+ } -+ } -+ -+ return ret; -+} -+ -+static void cfi_sststd_resume(struct mtd_info *mtd) -+{ -+ struct map_info *map = mtd->priv; -+ struct cfi_private *cfi = map->fldrv_priv; -+ int i; -+ struct flchip *chip; -+//printk("resume\n"); -+ -+ for (i=0; i<cfi->numchips; i++) { -+ -+ chip = &cfi->chips[i]; -+ -+ cfi_spin_lock(chip->mutex); -+ -+ if (chip->state == FL_PM_SUSPENDED) { -+ chip->state = FL_READY; -+ cfi_write(map, CMD(0xF0), chip->start); -+ wake_up(&chip->wq); -+ } -+ else -+ printk("Argh. Chip not in PM_SUSPENDED state upon resume()\n"); -+ -+ cfi_spin_unlock(chip->mutex); -+ } -+} -+ -+static void cfi_sststd_destroy(struct mtd_info *mtd) -+{ -+ struct map_info *map = mtd->priv; -+ struct cfi_private *cfi = map->fldrv_priv; -+ kfree(cfi->cmdset_priv); -+ kfree(cfi); -+} -+ -+#if LINUX_VERSION_CODE < 0x20212 && defined(MODULE) -+#define cfi_sststd_init init_module -+#define cfi_sststd_exit cleanup_module -+#endif -+ -+static char im_name[]="cfi_cmdset_0701"; -+ -+mod_init_t cfi_sststd_init(void) -+{ -+ inter_module_register(im_name, THIS_MODULE, &cfi_cmdset_0701); -+ return 0; -+} -+ -+mod_exit_t cfi_sststd_exit(void) -+{ -+ inter_module_unregister(im_name); -+} -+ -+module_init(cfi_sststd_init); -+module_exit(cfi_sststd_exit); -+ ---- a/drivers/mtd/chips/cfi_probe.c -+++ b/drivers/mtd/chips/cfi_probe.c -@@ -67,8 +67,15 @@ static int cfi_probe_chip(struct map_inf - cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL); - cfi_send_gen_cmd(0x98, 0x55, base, map, cfi, cfi->device_type, NULL); - -- if (!qry_present(map,base,cfi)) -- return 0; -+ if (!qry_present(map,base,cfi)) { -+ /* rather broken SST cfi probe (requires SST unlock) */ -+ cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL); -+ cfi_send_gen_cmd(0xAA, 0x5555, base, map, cfi, cfi->device_type, NULL); -+ cfi_send_gen_cmd(0x55, 0x2AAA, base, map, cfi, cfi->device_type, NULL); -+ cfi_send_gen_cmd(0x98, 0x5555, base, map, cfi, cfi->device_type, NULL); -+ if (!qry_present(map,base,cfi)) -+ return 0; -+ } - - if (!cfi->numchips) { - /* This is the first time we're called. Set up the CFI ---- a/drivers/mtd/chips/gen_probe.c -+++ b/drivers/mtd/chips/gen_probe.c -@@ -328,13 +328,18 @@ static struct mtd_info *check_cmd_set(st - return cfi_cmdset_0001(map, primary); - #endif - #ifdef CONFIG_MTD_CFI_AMDSTD -+ case 0x0006: - case 0x0002: - return cfi_cmdset_0002(map, primary); - #endif - #ifdef CONFIG_MTD_CFI_STAA -- case 0x0020: -+ case 0x0020: - return cfi_cmdset_0020(map, primary); - #endif -+#ifdef CONFIG_MTD_CFI_SSTSTD -+ case 0x0701: -+ return cfi_cmdset_0701(map, primary); -+#endif - } - - return cfi_cmdset_unknown(map, primary); diff --git a/target/linux/generic-2.4/patches/008-intel_flashchip_fix.patch b/target/linux/generic-2.4/patches/008-intel_flashchip_fix.patch deleted file mode 100644 index 56cb2a4..0000000 --- a/target/linux/generic-2.4/patches/008-intel_flashchip_fix.patch +++ /dev/null @@ -1,99 +0,0 @@ ---- a/drivers/mtd/chips/cfi_cmdset_0001.c -+++ b/drivers/mtd/chips/cfi_cmdset_0001.c -@@ -28,10 +28,18 @@ - #include <linux/slab.h> - #include <linux/delay.h> - #include <linux/interrupt.h> -+#include <linux/notifier.h> -+#include <linux/reboot.h> - #include <linux/mtd/map.h> - #include <linux/mtd/cfi.h> - #include <linux/mtd/compatmac.h> - -+#ifndef container_of -+#define container_of(ptr, type, member) ({ \ -+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ -+ (type *)( (char *)__mptr - offsetof(type,member) );}) -+#endif -+ - // debugging, turns off buffer write mode #define FORCE_WORD_WRITE - - static int cfi_intelext_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *); -@@ -45,6 +53,7 @@ static int cfi_intelext_lock(struct mtd_ - static int cfi_intelext_unlock(struct mtd_info *mtd, loff_t ofs, size_t len); - static int cfi_intelext_suspend (struct mtd_info *); - static void cfi_intelext_resume (struct mtd_info *); -+static int cfi_intelext_reboot(struct notifier_block *nb, unsigned long val, void *v); - - static void cfi_intelext_destroy(struct mtd_info *); - -@@ -288,6 +297,9 @@ static struct mtd_info *cfi_intelext_set - map->fldrv = &cfi_intelext_chipdrv; - MOD_INC_USE_COUNT; - mtd->name = map->name; -+ mtd->reboot_notifier.notifier_call = cfi_intelext_reboot; -+ register_reboot_notifier(&mtd->reboot_notifier); -+ - return mtd; - - setup_err: -@@ -1961,10 +1973,40 @@ static void cfi_intelext_resume(struct m - } - } - -+ -+static void cfi_intelext_reset(struct mtd_info *mtd) -+{ -+ struct map_info *map = mtd->priv; -+ struct cfi_private *cfi = map->fldrv_priv; -+ int i; -+ struct flchip *chip; -+ -+ cfi_intelext_sync(mtd); -+ for (i=0; i<cfi->numchips; i++) { -+ chip = &cfi->chips[i]; -+ -+ spin_lock(chip->mutex); -+ cfi_write(map, CMD(0xFF), 0); -+ chip->state = FL_READY; -+ spin_unlock(chip->mutex); -+ } -+} -+ -+static int cfi_intelext_reboot(struct notifier_block *nb, unsigned long val, void *v) -+{ -+ struct mtd_info *mtd; -+ -+ mtd = container_of(nb, struct mtd_info, reboot_notifier); -+ cfi_intelext_reset(mtd); -+ return NOTIFY_DONE; -+} -+ - static void cfi_intelext_destroy(struct mtd_info *mtd) - { - struct map_info *map = mtd->priv; - struct cfi_private *cfi = map->fldrv_priv; -+ cfi_intelext_reset(mtd); -+ unregister_reboot_notifier(&mtd->reboot_notifier); - kfree(cfi->cmdset_priv); - kfree(cfi->cfiq); - kfree(cfi); ---- a/include/linux/mtd/mtd.h -+++ b/include/linux/mtd/mtd.h -@@ -10,6 +10,7 @@ - #include <linux/version.h> - #include <linux/types.h> - #include <linux/mtd/compatmac.h> -+#include <linux/notifier.h> - #include <linux/module.h> - #include <linux/uio.h> - -@@ -217,6 +218,8 @@ struct mtd_info { - int (*suspend) (struct mtd_info *mtd); - void (*resume) (struct mtd_info *mtd); - -+ struct notifier_block reboot_notifier; -+ - void *priv; - }; - diff --git a/target/linux/generic-2.4/patches/009-mtd_uaccess.patch b/target/linux/generic-2.4/patches/009-mtd_uaccess.patch deleted file mode 100644 index 0c42f00..0000000 --- a/target/linux/generic-2.4/patches/009-mtd_uaccess.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- a/drivers/mtd/mtdchar.c -+++ b/drivers/mtd/mtdchar.c -@@ -558,13 +558,13 @@ static void mtd_notify_add(struct mtd_in - sprintf(name, "%d", mtd->index); - devfs_rw_handle[mtd->index] = devfs_register(devfs_dir_handle, name, - DEVFS_FL_DEFAULT, MTD_CHAR_MAJOR, mtd->index*2, -- S_IFCHR | S_IRUGO | S_IWUGO, -+ S_IFCHR | S_IRUSR | S_IWUSR, - &mtd_fops, NULL); - - sprintf(name, "%dro", mtd->index); - devfs_ro_handle[mtd->index] = devfs_register(devfs_dir_handle, name, - DEVFS_FL_DEFAULT, MTD_CHAR_MAJOR, mtd->index*2+1, -- S_IFCHR | S_IRUGO, -+ S_IFCHR | S_IRUSR, - &mtd_fops, NULL); - } - ---- a/drivers/mtd/mtdblock.c -+++ b/drivers/mtd/mtdblock.c -@@ -601,7 +601,7 @@ static void mtd_notify_add(struct mtd_in - sprintf(name, "%d", mtd->index); - devfs_rw_handle[mtd->index] = devfs_register(devfs_dir_handle, name, - DEVFS_FL_DEFAULT, MTD_BLOCK_MAJOR, mtd->index, -- S_IFBLK | S_IRUGO | S_IWUGO, -+ S_IFBLK | S_IRUSR | S_IWUSR, - &mtd_fops, NULL); - } - diff --git a/target/linux/generic-2.4/patches/010-disable_old_squashfs_compatibility.patch b/target/linux/generic-2.4/patches/010-disable_old_squashfs_compatibility.patch deleted file mode 100644 index 8ff8c4d..0000000 --- a/target/linux/generic-2.4/patches/010-disable_old_squashfs_compatibility.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/fs/squashfs/Makefile -+++ b/fs/squashfs/Makefile -@@ -4,7 +4,7 @@ - - O_TARGET := squashfs.o - --obj-y := inode.o squashfs2_0.o LzmaDecode.o -+obj-y := inode.o LzmaDecode.o - - obj-m := $(O_TARGET) - ---- a/fs/squashfs/squashfs.h -+++ b/fs/squashfs/squashfs.h -@@ -24,6 +24,9 @@ - #ifdef CONFIG_SQUASHFS_1_0_COMPATIBILITY - #undef CONFIG_SQUASHFS_1_0_COMPATIBILITY - #endif -+#ifdef CONFIG_SQUASHFS_2_0_COMPATIBILITY -+#undef CONFIG_SQUASHFS_2_0_COMPATIBILITY -+#endif - #ifdef SQUASHFS_TRACE - #define TRACE(s, args...) printk(KERN_NOTICE "SQUASHFS: "s, ## args) - #else diff --git a/target/linux/generic-2.4/patches/050-build_flags.patch b/target/linux/generic-2.4/patches/050-build_flags.patch deleted file mode 100644 index dd4b62c..0000000 --- a/target/linux/generic-2.4/patches/050-build_flags.patch +++ /dev/null @@ -1,81 +0,0 @@ ---- a/arch/mips/Makefile -+++ b/arch/mips/Makefile -@@ -44,10 +44,10 @@ MAKEBOOT = $(MAKE) -C arch/$(ARCH)/boot - GCCFLAGS := -I $(TOPDIR)/include/asm/gcc - GCCFLAGS += -G 0 -mno-abicalls -fno-pic -pipe - GCCFLAGS += $(call check_gcc, -finline-limit=100000,) --LINKFLAGS += -G 0 -static -n --MODFLAGS += -mlong-calls -+LINKFLAGS += -G 0 -static -n -nostdlib -+MODFLAGS += -mlong-calls -fno-common - --ifdef CONFIG_DEBUG_INFO -+ifdef CONFIG_REMOTE_DEBUG - GCCFLAGS += -g - ifdef CONFIG_SB1XXX_CORELIS - GCCFLAGS += -mno-sched-prolog -fno-omit-frame-pointer -@@ -69,13 +69,13 @@ endif - set_gccflags = $(shell \ - while :; do \ - cpu=$(1); isa=-$(2); \ -- for gcc_opt in -march= -mcpu=; do \ -+ for gcc_opt in -march= -mtune=; do \ - $(CC) $$gcc_opt$$cpu $$isa -S -o /dev/null \ - -xc /dev/null > /dev/null 2>&1 && \ - break 2; \ - done; \ - cpu=$(3); isa=-$(4); \ -- for gcc_opt in -march= -mcpu=; do \ -+ for gcc_opt in -march= -mtune=; do \ - $(CC) $$gcc_opt$$cpu $$isa -S -o /dev/null \ - -xc /dev/null > /dev/null 2>&1 && \ - break 2; \ -@@ -90,7 +90,7 @@ else \ - fi; \ - gas_abi=-Wa,-32; gas_cpu=$$cpu; gas_isa=-Wa,$$isa; \ - while :; do \ -- for gas_opt in -Wa,-march= -Wa,-mcpu=; do \ -+ for gas_opt in -Wa,-march= -Wa,-mtune=; do \ - $(CC) $$gas_abi $$gas_opt$$cpu $$gas_isa -Wa,-Z -c \ - -o /dev/null -xassembler /dev/null > /dev/null 2>&1 && \ - break 2; \ -@@ -172,6 +172,7 @@ endif - endif - - AFLAGS += $(GCCFLAGS) -+ASFLAGS += $(GCCFLAGS) - CFLAGS += $(GCCFLAGS) - - LD += -m $(ld-emul) ---- a/Makefile -+++ b/Makefile -@@ -17,7 +17,7 @@ HPATH = $(TOPDIR)/include - FINDHPATH = $(HPATH)/asm $(HPATH)/linux $(HPATH)/scsi $(HPATH)/net $(HPATH)/math-emu - - HOSTCC = gcc --HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -+HOSTCFLAGS = -Wall -Wstrict-prototypes -Os -fomit-frame-pointer - - CROSS_COMPILE = - -@@ -88,10 +88,9 @@ export MODLIB - # - # standard CFLAGS - # -- - CPPFLAGS := -D__KERNEL__ -I$(HPATH) - --CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs -O2 \ -+CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs -Os \ - -fno-strict-aliasing -fno-common - CFLAGS += -fno-builtin-strpbrk -fno-builtin-sprintf - ifndef CONFIG_FRAME_POINTER -@@ -108,6 +107,8 @@ CFLAGS += $(call check_gcc,-Wno-pointer- - # disable stupid and dangerous "optimization" in gcc 3.2+ - CFLAGS += $(call check_gcc,-fno-delete-null-pointer-checks,) - -+CFLAGS += $(call check_gcc, -funit-at-a-time,) -+ - # - # ROOT_DEV specifies the default root-device when making the image. - # This can be either FLOPPY, CURRENT, /dev/xxxx or empty, in which case diff --git a/target/linux/generic-2.4/patches/051-parallel_build.patch b/target/linux/generic-2.4/patches/051-parallel_build.patch deleted file mode 100644 index 6509f77..0000000 --- a/target/linux/generic-2.4/patches/051-parallel_build.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/arch/mips/Makefile -+++ b/arch/mips/Makefile -@@ -739,6 +739,7 @@ LINKFLAGS += -T arch/$(ARCH)/ld.script - HEAD := arch/mips/kernel/head.o arch/mips/kernel/init_task.o - - SUBDIRS := $(addprefix arch/mips/, tools) $(SUBDIRS) $(addprefix arch/mips/, kernel mm lib) -+$(SUBDIRS): $(TOPDIR)/include/asm-$(ARCH)/offset.h - CORE_FILES := arch/mips/kernel/kernel.o arch/mips/mm/mm.o $(CORE_FILES) - LIBS := arch/mips/lib/lib.a $(LIBS) - -@@ -785,7 +786,7 @@ archmrproper: - $(MAKE) -C arch/$(ARCH)/tools mrproper - - archdep: -- if [ ! -f $(TOPDIR)/include/asm-$(ARCH)/offset.h ]; then \ -- touch $(TOPDIR)/include/asm-$(ARCH)/offset.h; \ -- fi; - @$(MAKEBOOT) dep -+ -+$(TOPDIR)/include/asm-$(ARCH)/offset.h: -+ @$(MAKE) -C arch/mips/tools diff --git a/target/linux/generic-2.4/patches/051-remove_pcmcia_modinst_compat.patch b/target/linux/generic-2.4/patches/051-remove_pcmcia_modinst_compat.patch deleted file mode 100644 index 41d7cbe..0000000 --- a/target/linux/generic-2.4/patches/051-remove_pcmcia_modinst_compat.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/Makefile -+++ b/Makefile -@@ -435,18 +435,9 @@ else - depmod_opts := -b $(INSTALL_MOD_PATH) -r - endif - .PHONY: _modinst_post --_modinst_post: _modinst_post_pcmcia -+_modinst_post: - if [ -r System.map ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi - --# Backwards compatibilty symlinks for people still using old versions --# of pcmcia-cs with hard coded pathnames on insmod. Remove --# _modinst_post_pcmcia for kernel 2.4.1. --.PHONY: _modinst_post_pcmcia --_modinst_post_pcmcia: -- cd $(MODLIB); \ -- mkdir -p pcmcia; \ -- find kernel -path '*/pcmcia/*' -name '*.o' | xargs -i -r ln -sf ../{} pcmcia -- - .PHONY: $(patsubst %, _modinst_%, $(SUBDIRS)) - $(patsubst %, _modinst_%, $(SUBDIRS)) : - $(MAKE) -C $(patsubst _modinst_%, %, $@) modules_install diff --git a/target/linux/generic-2.4/patches/100-wireless-extension.patch b/target/linux/generic-2.4/patches/100-wireless-extension.patch deleted file mode 100644 index a4eee2d..0000000 --- a/target/linux/generic-2.4/patches/100-wireless-extension.patch +++ /dev/null @@ -1,1116 +0,0 @@ ---- a/include/linux/netdevice.h -+++ b/include/linux/netdevice.h -@@ -295,7 +295,9 @@ struct net_device - - /* List of functions to handle Wireless Extensions (instead of ioctl). - * See <net/iw_handler.h> for details. Jean II */ -- struct iw_handler_def * wireless_handlers; -+ const struct iw_handler_def * wireless_handlers; -+ /* Instance data managed by the core of Wireless Extensions. */ -+ struct iw_public_data * wireless_data; - - struct ethtool_ops *ethtool_ops; - ---- a/include/linux/wireless.h -+++ b/include/linux/wireless.h -@@ -1,10 +1,10 @@ - /* - * This file define a set of standard wireless extensions - * -- * Version : 16 2.4.03 -+ * Version : 18 12.3.05 - * - * Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com> -- * Copyright (c) 1997-2002 Jean Tourrilhes, All Rights Reserved. -+ * Copyright (c) 1997-2005 Jean Tourrilhes, All Rights Reserved. - */ - - #ifndef _LINUX_WIRELESS_H -@@ -47,12 +47,12 @@ - * # include/net/iw_handler.h - * - * Note as well that /proc/net/wireless implementation has now moved in : -- * # include/linux/wireless.c -+ * # net/core/wireless.c - * - * Wireless Events (2002 -> onward) : - * -------------------------------- - * Events are defined at the end of this file, and implemented in : -- * # include/linux/wireless.c -+ * # net/core/wireless.c - * - * Other comments : - * -------------- -@@ -82,7 +82,7 @@ - * (there is some stuff that will be added in the future...) - * I just plan to increment with each new version. - */ --#define WIRELESS_EXT 16 -+#define WIRELESS_EXT 18 - - /* - * Changes : -@@ -175,6 +175,28 @@ - * - Remove IW_MAX_GET_SPY because conflict with enhanced spy support - * - Add SIOCSIWTHRSPY/SIOCGIWTHRSPY and "struct iw_thrspy" - * - Add IW_ENCODE_TEMP and iw_range->encoding_login_index -+ * -+ * V16 to V17 -+ * ---------- -+ * - Add flags to frequency -> auto/fixed -+ * - Document (struct iw_quality *)->updated, add new flags (INVALID) -+ * - Wireless Event capability in struct iw_range -+ * - Add support for relative TxPower (yick !) -+ * -+ * V17 to V18 (From Jouni Malinen <jkmaline@cc.hut.fi>) -+ * ---------- -+ * - Add support for WPA/WPA2 -+ * - Add extended encoding configuration (SIOCSIWENCODEEXT and -+ * SIOCGIWENCODEEXT) -+ * - Add SIOCSIWGENIE/SIOCGIWGENIE -+ * - Add SIOCSIWMLME -+ * - Add SIOCSIWPMKSA -+ * - Add struct iw_range bit field for supported encoding capabilities -+ * - Add optional scan request parameters for SIOCSIWSCAN -+ * - Add SIOCSIWAUTH/SIOCGIWAUTH for setting authentication and WPA -+ * related parameters (extensible up to 4096 parameter values) -+ * - Add wireless events: IWEVGENIE, IWEVMICHAELMICFAILURE, -+ * IWEVASSOCREQIE, IWEVASSOCRESPIE, IWEVPMKIDCAND - */ - - /**************************** CONSTANTS ****************************/ -@@ -249,9 +271,33 @@ - #define SIOCSIWPOWER 0x8B2C /* set Power Management settings */ - #define SIOCGIWPOWER 0x8B2D /* get Power Management settings */ - -+/* WPA : Generic IEEE 802.11 informatiom element (e.g., for WPA/RSN/WMM). -+ * This ioctl uses struct iw_point and data buffer that includes IE id and len -+ * fields. More than one IE may be included in the request. Setting the generic -+ * IE to empty buffer (len=0) removes the generic IE from the driver. Drivers -+ * are allowed to generate their own WPA/RSN IEs, but in these cases, drivers -+ * are required to report the used IE as a wireless event, e.g., when -+ * associating with an AP. */ -+#define SIOCSIWGENIE 0x8B30 /* set generic IE */ -+#define SIOCGIWGENIE 0x8B31 /* get generic IE */ -+ -+/* WPA : IEEE 802.11 MLME requests */ -+#define SIOCSIWMLME 0x8B16 /* request MLME operation; uses -+ * struct iw_mlme */ -+/* WPA : Authentication mode parameters */ -+#define SIOCSIWAUTH 0x8B32 /* set authentication mode params */ -+#define SIOCGIWAUTH 0x8B33 /* get authentication mode params */ -+ -+/* WPA : Extended version of encoding configuration */ -+#define SIOCSIWENCODEEXT 0x8B34 /* set encoding token & mode */ -+#define SIOCGIWENCODEEXT 0x8B35 /* get encoding token & mode */ -+ -+/* WPA2 : PMKSA cache management */ -+#define SIOCSIWPMKSA 0x8B36 /* PMKSA cache operation */ -+ - /* -------------------- DEV PRIVATE IOCTL LIST -------------------- */ - --/* These 16 ioctl are wireless device private. -+/* These 32 ioctl are wireless device private, for 16 commands. - * Each driver is free to use them for whatever purpose it chooses, - * however the driver *must* export the description of those ioctls - * with SIOCGIWPRIV and *must* use arguments as defined below. -@@ -266,8 +312,8 @@ - * We now have 32 commands, so a bit more space ;-). - * Also, all 'odd' commands are only usable by root and don't return the - * content of ifr/iwr to user (but you are not obliged to use the set/get -- * convention, just use every other two command). -- * And I repeat : you are not obliged to use them with iwspy, but you -+ * convention, just use every other two command). More details in iwpriv.c. -+ * And I repeat : you are not forced to use them with iwpriv, but you - * must be compliant with it. - */ - -@@ -290,6 +336,34 @@ - #define IWEVCUSTOM 0x8C02 /* Driver specific ascii string */ - #define IWEVREGISTERED 0x8C03 /* Discovered a new node (AP mode) */ - #define IWEVEXPIRED 0x8C04 /* Expired a node (AP mode) */ -+#define IWEVGENIE 0x8C05 /* Generic IE (WPA, RSN, WMM, ..) -+ * (scan results); This includes id and -+ * length fields. One IWEVGENIE may -+ * contain more than one IE. Scan -+ * results may contain one or more -+ * IWEVGENIE events. */ -+#define IWEVMICHAELMICFAILURE 0x8C06 /* Michael MIC failure -+ * (struct iw_michaelmicfailure) -+ */ -+#define IWEVASSOCREQIE 0x8C07 /* IEs used in (Re)Association Request. -+ * The data includes id and length -+ * fields and may contain more than one -+ * IE. This event is required in -+ * Managed mode if the driver -+ * generates its own WPA/RSN IE. This -+ * should be sent just before -+ * IWEVREGISTERED event for the -+ * association. */ -+#define IWEVASSOCRESPIE 0x8C08 /* IEs used in (Re)Association -+ * Response. The data includes id and -+ * length fields and may contain more -+ * than one IE. This may be sent -+ * between IWEVASSOCREQIE and -+ * IWEVREGISTERED events for the -+ * association. */ -+#define IWEVPMKIDCAND 0x8C09 /* PMKID candidate for RSN -+ * pre-authentication -+ * (struct iw_pmkid_cand) */ - - #define IWEVFIRST 0x8C00 - -@@ -352,6 +426,18 @@ - #define IW_MODE_SECOND 5 /* Secondary master/repeater (backup) */ - #define IW_MODE_MONITOR 6 /* Passive monitor (listen only) */ - -+/* Statistics flags (bitmask in updated) */ -+#define IW_QUAL_QUAL_UPDATED 0x1 /* Value was updated since last read */ -+#define IW_QUAL_LEVEL_UPDATED 0x2 -+#define IW_QUAL_NOISE_UPDATED 0x4 -+#define IW_QUAL_QUAL_INVALID 0x10 /* Driver doesn't provide value */ -+#define IW_QUAL_LEVEL_INVALID 0x20 -+#define IW_QUAL_NOISE_INVALID 0x40 -+ -+/* Frequency flags */ -+#define IW_FREQ_AUTO 0x00 /* Let the driver decides */ -+#define IW_FREQ_FIXED 0x01 /* Force a specific value */ -+ - /* Maximum number of size of encoding token available - * they are listed in the range structure */ - #define IW_MAX_ENCODING_SIZES 8 -@@ -390,6 +476,7 @@ - #define IW_TXPOW_TYPE 0x00FF /* Type of value */ - #define IW_TXPOW_DBM 0x0000 /* Value is in dBm */ - #define IW_TXPOW_MWATT 0x0001 /* Value is in mW */ -+#define IW_TXPOW_RELATIVE 0x0002 /* Value is in arbitrary units */ - #define IW_TXPOW_RANGE 0x1000 /* Range of value between min/max */ - - /* Retry limits and lifetime flags available */ -@@ -412,12 +499,113 @@ - #define IW_SCAN_THIS_MODE 0x0020 /* Scan only this Mode */ - #define IW_SCAN_ALL_RATE 0x0040 /* Scan all Bit-Rates */ - #define IW_SCAN_THIS_RATE 0x0080 /* Scan only this Bit-Rate */ -+/* struct iw_scan_req scan_type */ -+#define IW_SCAN_TYPE_ACTIVE 0 -+#define IW_SCAN_TYPE_PASSIVE 1 - /* Maximum size of returned data */ - #define IW_SCAN_MAX_DATA 4096 /* In bytes */ - - /* Max number of char in custom event - use multiple of them if needed */ - #define IW_CUSTOM_MAX 256 /* In bytes */ - -+/* Generic information element */ -+#define IW_GENERIC_IE_MAX 1024 -+ -+/* MLME requests (SIOCSIWMLME / struct iw_mlme) */ -+#define IW_MLME_DEAUTH 0 -+#define IW_MLME_DISASSOC 1 -+ -+/* SIOCSIWAUTH/SIOCGIWAUTH struct iw_param flags */ -+#define IW_AUTH_INDEX 0x0FFF -+#define IW_AUTH_FLAGS 0xF000 -+/* SIOCSIWAUTH/SIOCGIWAUTH parameters (0 .. 4095) -+ * (IW_AUTH_INDEX mask in struct iw_param flags; this is the index of the -+ * parameter that is being set/get to; value will be read/written to -+ * struct iw_param value field) */ -+#define IW_AUTH_WPA_VERSION 0 -+#define IW_AUTH_CIPHER_PAIRWISE 1 -+#define IW_AUTH_CIPHER_GROUP 2 -+#define IW_AUTH_KEY_MGMT 3 -+#define IW_AUTH_TKIP_COUNTERMEASURES 4 -+#define IW_AUTH_DROP_UNENCRYPTED 5 -+#define IW_AUTH_80211_AUTH_ALG 6 -+#define IW_AUTH_WPA_ENABLED 7 -+#define IW_AUTH_RX_UNENCRYPTED_EAPOL 8 -+#define IW_AUTH_ROAMING_CONTROL 9 -+#define IW_AUTH_PRIVACY_INVOKED 10 -+ -+/* IW_AUTH_WPA_VERSION values (bit field) */ -+#define IW_AUTH_WPA_VERSION_DISABLED 0x00000001 -+#define IW_AUTH_WPA_VERSION_WPA 0x00000002 -+#define IW_AUTH_WPA_VERSION_WPA2 0x00000004 -+ -+/* IW_AUTH_PAIRWISE_CIPHER and IW_AUTH_GROUP_CIPHER values (bit field) */ -+#define IW_AUTH_CIPHER_NONE 0x00000001 -+#define IW_AUTH_CIPHER_WEP40 0x00000002 -+#define IW_AUTH_CIPHER_TKIP 0x00000004 -+#define IW_AUTH_CIPHER_CCMP 0x00000008 -+#define IW_AUTH_CIPHER_WEP104 0x00000010 -+ -+/* IW_AUTH_KEY_MGMT values (bit field) */ -+#define IW_AUTH_KEY_MGMT_802_1X 1 -+#define IW_AUTH_KEY_MGMT_PSK 2 -+ -+/* IW_AUTH_80211_AUTH_ALG values (bit field) */ -+#define IW_AUTH_ALG_OPEN_SYSTEM 0x00000001 -+#define IW_AUTH_ALG_SHARED_KEY 0x00000002 -+#define IW_AUTH_ALG_LEAP 0x00000004 -+ -+/* IW_AUTH_ROAMING_CONTROL values */ -+#define IW_AUTH_ROAMING_ENABLE 0 /* driver/firmware based roaming */ -+#define IW_AUTH_ROAMING_DISABLE 1 /* user space program used for roaming -+ * control */ -+ -+/* SIOCSIWENCODEEXT definitions */ -+#define IW_ENCODE_SEQ_MAX_SIZE 8 -+/* struct iw_encode_ext ->alg */ -+#define IW_ENCODE_ALG_NONE 0 -+#define IW_ENCODE_ALG_WEP 1 -+#define IW_ENCODE_ALG_TKIP 2 -+#define IW_ENCODE_ALG_CCMP 3 -+/* struct iw_encode_ext ->ext_flags */ -+#define IW_ENCODE_EXT_TX_SEQ_VALID 0x00000001 -+#define IW_ENCODE_EXT_RX_SEQ_VALID 0x00000002 -+#define IW_ENCODE_EXT_GROUP_KEY 0x00000004 -+#define IW_ENCODE_EXT_SET_TX_KEY 0x00000008 -+ -+/* IWEVMICHAELMICFAILURE : struct iw_michaelmicfailure ->flags */ -+#define IW_MICFAILURE_KEY_ID 0x00000003 /* Key ID 0..3 */ -+#define IW_MICFAILURE_GROUP 0x00000004 -+#define IW_MICFAILURE_PAIRWISE 0x00000008 -+#define IW_MICFAILURE_STAKEY 0x00000010 -+#define IW_MICFAILURE_COUNT 0x00000060 /* 1 or 2 (0 = count not supported) -+ */ -+ -+/* Bit field values for enc_capa in struct iw_range */ -+#define IW_ENC_CAPA_WPA 0x00000001 -+#define IW_ENC_CAPA_WPA2 0x00000002 -+#define IW_ENC_CAPA_CIPHER_TKIP 0x00000004 -+#define IW_ENC_CAPA_CIPHER_CCMP 0x00000008 -+ -+/* Event capability macros - in (struct iw_range *)->event_capa -+ * Because we have more than 32 possible events, we use an array of -+ * 32 bit bitmasks. Note : 32 bits = 0x20 = 2^5. */ -+#define IW_EVENT_CAPA_BASE(cmd) ((cmd >= SIOCIWFIRSTPRIV) ? \ -+ (cmd - SIOCIWFIRSTPRIV + 0x60) : \ -+ (cmd - SIOCSIWCOMMIT)) -+#define IW_EVENT_CAPA_INDEX(cmd) (IW_EVENT_CAPA_BASE(cmd) >> 5) -+#define IW_EVENT_CAPA_MASK(cmd) (1 << (IW_EVENT_CAPA_BASE(cmd) & 0x1F)) -+/* Event capability constants - event autogenerated by the kernel -+ * This list is valid for most 802.11 devices, customise as needed... */ -+#define IW_EVENT_CAPA_K_0 (IW_EVENT_CAPA_MASK(0x8B04) | \ -+ IW_EVENT_CAPA_MASK(0x8B06) | \ -+ IW_EVENT_CAPA_MASK(0x8B1A)) -+#define IW_EVENT_CAPA_K_1 (IW_EVENT_CAPA_MASK(0x8B2A)) -+/* "Easy" macro to set events in iw_range (less efficient) */ -+#define IW_EVENT_CAPA_SET(event_capa, cmd) (event_capa[IW_EVENT_CAPA_INDEX(cmd)] |= IW_EVENT_CAPA_MASK(cmd)) -+#define IW_EVENT_CAPA_SET_KERNEL(event_capa) {event_capa[0] |= IW_EVENT_CAPA_K_0; event_capa[1] |= IW_EVENT_CAPA_K_1; } -+ -+ - /****************************** TYPES ******************************/ - - /* --------------------------- SUBTYPES --------------------------- */ -@@ -456,7 +644,7 @@ struct iw_freq - __s32 m; /* Mantissa */ - __s16 e; /* Exponent */ - __u8 i; /* List index (when in range struct) */ -- __u8 pad; /* Unused - just for alignement */ -+ __u8 flags; /* Flags (fixed/auto) */ - }; - - /* -@@ -507,6 +695,132 @@ struct iw_thrspy - struct iw_quality high; /* High threshold */ - }; - -+/* -+ * Optional data for scan request -+ * -+ * Note: these optional parameters are controlling parameters for the -+ * scanning behavior, these do not apply to getting scan results -+ * (SIOCGIWSCAN). Drivers are expected to keep a local BSS table and -+ * provide a merged results with all BSSes even if the previous scan -+ * request limited scanning to a subset, e.g., by specifying an SSID. -+ * Especially, scan results are required to include an entry for the -+ * current BSS if the driver is in Managed mode and associated with an AP. -+ */ -+struct iw_scan_req -+{ -+ __u8 scan_type; /* IW_SCAN_TYPE_{ACTIVE,PASSIVE} */ -+ __u8 essid_len; -+ __u8 num_channels; /* num entries in channel_list; -+ * 0 = scan all allowed channels */ -+ __u8 flags; /* reserved as padding; use zero, this may -+ * be used in the future for adding flags -+ * to request different scan behavior */ -+ struct sockaddr bssid; /* ff:ff:ff:ff:ff:ff for broadcast BSSID or -+ * individual address of a specific BSS */ -+ -+ /* -+ * Use this ESSID if IW_SCAN_THIS_ESSID flag is used instead of using -+ * the current ESSID. This allows scan requests for specific ESSID -+ * without having to change the current ESSID and potentially breaking -+ * the current association. -+ */ -+ __u8 essid[IW_ESSID_MAX_SIZE]; -+ -+ /* -+ * Optional parameters for changing the default scanning behavior. -+ * These are based on the MLME-SCAN.request from IEEE Std 802.11. -+ * TU is 1.024 ms. If these are set to 0, driver is expected to use -+ * reasonable default values. min_channel_time defines the time that -+ * will be used to wait for the first reply on each channel. If no -+ * replies are received, next channel will be scanned after this. If -+ * replies are received, total time waited on the channel is defined by -+ * max_channel_time. -+ */ -+ __u32 min_channel_time; /* in TU */ -+ __u32 max_channel_time; /* in TU */ -+ -+ struct iw_freq channel_list[IW_MAX_FREQUENCIES]; -+}; -+ -+/* ------------------------- WPA SUPPORT ------------------------- */ -+ -+/* -+ * Extended data structure for get/set encoding (this is used with -+ * SIOCSIWENCODEEXT/SIOCGIWENCODEEXT. struct iw_point and IW_ENCODE_* -+ * flags are used in the same way as with SIOCSIWENCODE/SIOCGIWENCODE and -+ * only the data contents changes (key data -> this structure, including -+ * key data). -+ * -+ * If the new key is the first group key, it will be set as the default -+ * TX key. Otherwise, default TX key index is only changed if -+ * IW_ENCODE_EXT_SET_TX_KEY flag is set. -+ * -+ * Key will be changed with SIOCSIWENCODEEXT in all cases except for -+ * special "change TX key index" operation which is indicated by setting -+ * key_len = 0 and ext_flags |= IW_ENCODE_EXT_SET_TX_KEY. -+ * -+ * tx_seq/rx_seq are only used when respective -+ * IW_ENCODE_EXT_{TX,RX}_SEQ_VALID flag is set in ext_flags. Normal -+ * TKIP/CCMP operation is to set RX seq with SIOCSIWENCODEEXT and start -+ * TX seq from zero whenever key is changed. SIOCGIWENCODEEXT is normally -+ * used only by an Authenticator (AP or an IBSS station) to get the -+ * current TX sequence number. Using TX_SEQ_VALID for SIOCSIWENCODEEXT and -+ * RX_SEQ_VALID for SIOCGIWENCODEEXT are optional, but can be useful for -+ * debugging/testing. -+ */ -+struct iw_encode_ext -+{ -+ __u32 ext_flags; /* IW_ENCODE_EXT_* */ -+ __u8 tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */ -+ __u8 rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */ -+ struct sockaddr addr; /* ff:ff:ff:ff:ff:ff for broadcast/multicast -+ * (group) keys or unicast address for -+ * individual keys */ -+ __u16 alg; /* IW_ENCODE_ALG_* */ -+ __u16 key_len; -+ __u8 key[0]; -+}; -+ -+/* SIOCSIWMLME data */ -+struct iw_mlme -+{ -+ __u16 cmd; /* IW_MLME_* */ -+ __u16 reason_code; -+ struct sockaddr addr; -+}; -+ -+/* SIOCSIWPMKSA data */ -+#define IW_PMKSA_ADD 1 -+#define IW_PMKSA_REMOVE 2 -+#define IW_PMKSA_FLUSH 3 -+ -+#define IW_PMKID_LEN 16 -+ -+struct iw_pmksa -+{ -+ __u32 cmd; /* IW_PMKSA_* */ -+ struct sockaddr bssid; -+ __u8 pmkid[IW_PMKID_LEN]; -+}; -+ -+/* IWEVMICHAELMICFAILURE data */ -+struct iw_michaelmicfailure -+{ -+ __u32 flags; -+ struct sockaddr src_addr; -+ __u8 tsc[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */ -+}; -+ -+/* IWEVPMKIDCAND data */ -+#define IW_PMKID_CAND_PREAUTH 0x00000001 /* RNS pre-authentication enabled */ -+struct iw_pmkid_cand -+{ -+ __u32 flags; /* IW_PMKID_CAND_* */ -+ __u32 index; /* the smaller the index, the higher the -+ * priority */ -+ struct sockaddr bssid; -+}; -+ - /* ------------------------ WIRELESS STATS ------------------------ */ - /* - * Wireless statistics (used for /proc/net/wireless) -@@ -610,11 +924,12 @@ struct iw_range - /* Old Frequency (backward compat - moved lower ) */ - __u16 old_num_channels; - __u8 old_num_frequency; -- /* Filler to keep "version" at the same offset */ -- __s32 old_freq[6]; -+ -+ /* Wireless event capability bitmasks */ -+ __u32 event_capa[6]; - - /* signal level threshold range */ -- __s32 sensitivity; -+ __s32 sensitivity; - - /* Quality of link & SNR stuff */ - /* Quality range (link, level, noise) -@@ -685,6 +1000,8 @@ struct iw_range - struct iw_freq freq[IW_MAX_FREQUENCIES]; /* list */ - /* Note : this frequency list doesn't need to fit channel numbers, - * because each entry contain its channel index */ -+ -+ __u32 enc_capa; /* IW_ENC_CAPA_* bit field */ - }; - - /* ---- a/include/net/iw_handler.h -+++ b/include/net/iw_handler.h -@@ -1,10 +1,10 @@ - /* - * This file define the new driver API for Wireless Extensions - * -- * Version : 5 4.12.02 -+ * Version : 6 21.6.04 - * - * Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com> -- * Copyright (c) 2001-2002 Jean Tourrilhes, All Rights Reserved. -+ * Copyright (c) 2001-2004 Jean Tourrilhes, All Rights Reserved. - */ - - #ifndef _IW_HANDLER_H -@@ -206,7 +206,7 @@ - * will be needed... - * I just plan to increment with each new version. - */ --#define IW_HANDLER_VERSION 5 -+#define IW_HANDLER_VERSION 6 - - /* - * Changes : -@@ -224,11 +224,18 @@ - * V4 to V5 - * -------- - * - Add new spy support : struct iw_spy_data & prototypes -+ * -+ * V5 to V6 -+ * -------- -+ * - Change the way we get to spy_data method for added safety -+ * - Remove spy #ifdef, they are always on -> cleaner code -+ * - Add IW_DESCR_FLAG_NOMAX flag for very large requests -+ * - Start migrating get_wireless_stats to struct iw_handler_def - */ - - /**************************** CONSTANTS ****************************/ - --/* Enable enhanced spy support. Disable to reduce footprint */ -+/* Enhanced spy support available */ - #define IW_WIRELESS_SPY - #define IW_WIRELESS_THRSPY - -@@ -258,6 +265,7 @@ - #define IW_DESCR_FLAG_EVENT 0x0002 /* Generate an event on SET */ - #define IW_DESCR_FLAG_RESTRICT 0x0004 /* GET : request is ROOT only */ - /* SET : Omit payload from generated iwevent */ -+#define IW_DESCR_FLAG_NOMAX 0x0008 /* GET : no limit on request size */ - /* Driver level flags */ - #define IW_DESCR_FLAG_WAIT 0x0100 /* Wait for driver event */ - -@@ -311,23 +319,25 @@ struct iw_handler_def - /* Array of handlers for standard ioctls - * We will call dev->wireless_handlers->standard[ioctl - SIOCSIWNAME] - */ -- iw_handler * standard; -+ const iw_handler * standard; - - /* Array of handlers for private ioctls - * Will call dev->wireless_handlers->private[ioctl - SIOCIWFIRSTPRIV] - */ -- iw_handler * private; -+ const iw_handler * private; - - /* Arguments of private handler. This one is just a list, so you - * can put it in any order you want and should not leave holes... - * We will automatically export that to user space... */ -- struct iw_priv_args * private_args; -+ const struct iw_priv_args * private_args; - -- /* Driver enhanced spy support */ -- long spy_offset; /* Spy data offset */ -+ /* This field will be *removed* in the next version of WE */ -+ long spy_offset; /* DO NOT USE */ - -- /* In the long term, get_wireless_stats will move from -- * 'struct net_device' to here, to minimise bloat. */ -+ /* New location of get_wireless_stats, to de-bloat struct net_device. -+ * The old pointer in struct net_device will be gradually phased -+ * out, and drivers are encouraged to use this one... */ -+ struct iw_statistics* (*get_wireless_stats)(struct net_device *dev); - }; - - /* ---------------------- IOCTL DESCRIPTION ---------------------- */ -@@ -374,18 +384,29 @@ struct iw_ioctl_description - */ - struct iw_spy_data - { --#ifdef IW_WIRELESS_SPY - /* --- Standard spy support --- */ - int spy_number; - u_char spy_address[IW_MAX_SPY][ETH_ALEN]; - struct iw_quality spy_stat[IW_MAX_SPY]; --#ifdef IW_WIRELESS_THRSPY - /* --- Enhanced spy support (event) */ - struct iw_quality spy_thr_low; /* Low threshold */ - struct iw_quality spy_thr_high; /* High threshold */ - u_char spy_thr_under[IW_MAX_SPY]; --#endif /* IW_WIRELESS_THRSPY */ --#endif /* IW_WIRELESS_SPY */ -+}; -+ -+/* --------------------- DEVICE WIRELESS DATA --------------------- */ -+/* -+ * This is all the wireless data specific to a device instance that -+ * is managed by the core of Wireless Extensions. -+ * We only keep pointer to those structures, so that a driver is free -+ * to share them between instances. -+ * This structure should be initialised before registering the device. -+ * Access to this data follow the same rules as any other struct net_device -+ * data (i.e. valid as long as struct net_device exist, same locking rules). -+ */ -+struct iw_public_data { -+ /* Driver enhanced spy support */ -+ struct iw_spy_data * spy_data; - }; - - /**************************** PROTOTYPES ****************************/ ---- a/net/core/dev.c -+++ b/net/core/dev.c -@@ -2426,7 +2426,7 @@ int dev_ioctl(unsigned int cmd, void *ar - /* Follow me in net/core/wireless.c */ - ret = wireless_process_ioctl(&ifr, cmd); - rtnl_unlock(); -- if (!ret && IW_IS_GET(cmd) && -+ if (IW_IS_GET(cmd) && - copy_to_user(arg, &ifr, sizeof(struct ifreq))) - return -EFAULT; - return ret; ---- a/net/core/wireless.c -+++ b/net/core/wireless.c -@@ -2,7 +2,7 @@ - * This file implement the Wireless Extensions APIs. - * - * Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com> -- * Copyright (c) 1997-2003 Jean Tourrilhes, All Rights Reserved. -+ * Copyright (c) 1997-2005 Jean Tourrilhes, All Rights Reserved. - * - * (As all part of the Linux kernel, this file is GPL) - */ -@@ -48,6 +48,16 @@ - * o Add common spy support : iw_handler_set_spy(), wireless_spy_update() - * o Add enhanced spy support : iw_handler_set_thrspy() and event. - * o Add WIRELESS_EXT version display in /proc/net/wireless -+ * -+ * v6 - 18.06.04 - Jean II -+ * o Change get_spydata() method for added safety -+ * o Remove spy #ifdef, they are always on -> cleaner code -+ * o Allow any size GET request if user specifies length > max -+ * and if request has IW_DESCR_FLAG_NOMAX flag or is SIOCGIWPRIV -+ * o Start migrating get_wireless_stats to struct iw_handler_def -+ * o Add wmb() in iw_handler_set_spy() for non-coherent archs/cpus -+ * Based on patch from Pavel Roskin <proski@gnu.org> : -+ * o Fix kernel data leak to user space in private handler handling - */ - - /***************************** INCLUDES *****************************/ -@@ -64,11 +74,7 @@ - - /**************************** CONSTANTS ****************************/ - --/* Enough lenience, let's make sure things are proper... */ --#define WE_STRICT_WRITE /* Check write buffer size */ --/* I'll probably drop both the define and kernel message in the next version */ -- --/* Debuging stuff */ -+/* Debugging stuff */ - #undef WE_IOCTL_DEBUG /* Debug IOCTL API */ - #undef WE_EVENT_DEBUG /* Debug Event dispatcher */ - #undef WE_SPY_DEBUG /* Debug enhanced spy support */ -@@ -131,14 +137,14 @@ static const struct iw_ioctl_description - { IW_HEADER_TYPE_ADDR, 0, 0, 0, 0, 0}, - /* SIOCGIWAP */ - { IW_HEADER_TYPE_ADDR, 0, 0, 0, 0, IW_DESCR_FLAG_DUMP}, -- /* -- hole -- */ -- { IW_HEADER_TYPE_NULL, 0, 0, 0, 0, 0}, -+ /* SIOCSIWMLME */ -+ { IW_HEADER_TYPE_POINT, 0, 1, sizeof(struct iw_mlme), sizeof(struct iw_mlme), 0}, - /* SIOCGIWAPLIST */ -- { IW_HEADER_TYPE_POINT, 0, (sizeof(struct sockaddr) + sizeof(struct iw_quality)), 0, IW_MAX_AP, 0}, -+ { IW_HEADER_TYPE_POINT, 0, (sizeof(struct sockaddr) + sizeof(struct iw_quality)), 0, IW_MAX_AP, IW_DESCR_FLAG_NOMAX}, - /* SIOCSIWSCAN */ -- { IW_HEADER_TYPE_PARAM, 0, 0, 0, 0, 0}, -+ { IW_HEADER_TYPE_POINT, 0, 1, 0, sizeof(struct iw_scan_req), 0}, - /* SIOCGIWSCAN */ -- { IW_HEADER_TYPE_POINT, 0, 1, 0, IW_SCAN_MAX_DATA, 0}, -+ { IW_HEADER_TYPE_POINT, 0, 1, 0, IW_SCAN_MAX_DATA, IW_DESCR_FLAG_NOMAX}, - /* SIOCSIWESSID */ - { IW_HEADER_TYPE_POINT, 0, 1, 0, IW_ESSID_MAX_SIZE + 1, IW_DESCR_FLAG_EVENT}, - /* SIOCGIWESSID */ -@@ -179,6 +185,25 @@ static const struct iw_ioctl_description - { IW_HEADER_TYPE_PARAM, 0, 0, 0, 0, 0}, - /* SIOCGIWPOWER */ - { IW_HEADER_TYPE_PARAM, 0, 0, 0, 0, 0}, -+ /* -- hole -- */ -+ { IW_HEADER_TYPE_NULL, 0, 0, 0, 0, 0}, -+ /* -- hole -- */ -+ { IW_HEADER_TYPE_NULL, 0, 0, 0, 0, 0}, -+ /* SIOCSIWGENIE */ -+ { IW_HEADER_TYPE_POINT, 0, 1, 0, IW_GENERIC_IE_MAX, 0}, -+ /* SIOCGIWGENIE */ -+ { IW_HEADER_TYPE_POINT, 0, 1, 0, IW_GENERIC_IE_MAX, 0}, -+ /* SIOCSIWAUTH */ -+ { IW_HEADER_TYPE_PARAM, 0, 0, 0, 0, 0}, -+ /* SIOCGIWAUTH */ -+ { IW_HEADER_TYPE_PARAM, 0, 0, 0, 0, 0}, -+ /* SIOCSIWENCODEEXT */ -+ { IW_HEADER_TYPE_POINT, 0, 1, sizeof(struct iw_encode_ext), sizeof(struct iw_encode_ext) + IW_ENCODING_TOKEN_MAX, 0}, -+ /* SIOCGIWENCODEEXT */ -+ { IW_HEADER_TYPE_POINT, 0, 1, sizeof(struct iw_encode_ext), sizeof(struct iw_encode_ext) + IW_ENCODING_TOKEN_MAX, 0}, -+ /* SIOCSIWPMKSA */ -+ { IW_HEADER_TYPE_POINT, 0, 1, sizeof(struct iw_pmksa), sizeof(struct iw_pmksa), 0}, -+ /* -- hole -- */ - }; - static const int standard_ioctl_num = (sizeof(standard_ioctl) / - sizeof(struct iw_ioctl_description)); -@@ -198,12 +223,22 @@ static const struct iw_ioctl_description - { IW_HEADER_TYPE_ADDR, 0, 0, 0, 0, 0}, - /* IWEVEXPIRED */ - { IW_HEADER_TYPE_ADDR, 0, 0, 0, 0, 0}, -+ /* IWEVGENIE */ -+ { IW_HEADER_TYPE_POINT, 0, 1, 0, IW_GENERIC_IE_MAX, 0}, -+ /* IWEVMICHAELMICFAILURE */ -+ { IW_HEADER_TYPE_POINT, 0, 1, 0, sizeof(struct iw_michaelmicfailure), 0}, -+ /* IWEVASSOCREQIE */ -+ { IW_HEADER_TYPE_POINT, 0, 1, 0, IW_GENERIC_IE_MAX, 0}, -+ /* IWEVASSOCRESPIE */ -+ { IW_HEADER_TYPE_POINT, 0, 1, 0, IW_GENERIC_IE_MAX, 0}, -+ /* IWEVPMKIDCAND */ -+ { IW_HEADER_TYPE_POINT, 0, 1, 0, sizeof(struct iw_pmkid_cand), 0}, - }; - static const int standard_event_num = (sizeof(standard_event) / - sizeof(struct iw_ioctl_description)); - - /* Size (in bytes) of the various private data types */ --static const char priv_type_size[] = { -+static const char iw_priv_type_size[] = { - 0, /* IW_PRIV_TYPE_NONE */ - 1, /* IW_PRIV_TYPE_BYTE */ - 1, /* IW_PRIV_TYPE_CHAR */ -@@ -270,12 +305,15 @@ static inline iw_handler get_handler(str - */ - static inline struct iw_statistics *get_wireless_stats(struct net_device *dev) - { -+ /* New location */ -+ if((dev->wireless_handlers != NULL) && -+ (dev->wireless_handlers->get_wireless_stats != NULL)) -+ return dev->wireless_handlers->get_wireless_stats(dev); -+ -+ /* Old location, will be phased out in next WE */ - return (dev->get_wireless_stats ? - dev->get_wireless_stats(dev) : - (struct iw_statistics *) NULL); -- /* In the future, get_wireless_stats may move from 'struct net_device' -- * to 'struct iw_handler_def', to de-bloat struct net_device. -- * Definitely worse a thought... */ - } - - /* ---------------------------------------------------------------- */ -@@ -310,14 +348,32 @@ static inline int call_commit_handler(st - - /* ---------------------------------------------------------------- */ - /* -- * Number of private arguments -+ * Calculate size of private arguments - */ - static inline int get_priv_size(__u16 args) - { - int num = args & IW_PRIV_SIZE_MASK; - int type = (args & IW_PRIV_TYPE_MASK) >> 12; - -- return num * priv_type_size[type]; -+ return num * iw_priv_type_size[type]; -+} -+ -+/* ---------------------------------------------------------------- */ -+/* -+ * Re-calculate the size of private arguments -+ */ -+static inline int adjust_priv_size(__u16 args, -+ union iwreq_data * wrqu) -+{ -+ int num = wrqu->data.length; -+ int max = args & IW_PRIV_SIZE_MASK; -+ int type = (args & IW_PRIV_TYPE_MASK) >> 12; -+ -+ /* Make sure the driver doesn't goof up */ -+ if (max < num) -+ num = max; -+ -+ return num * iw_priv_type_size[type]; - } - - -@@ -350,11 +406,14 @@ static inline int sprintf_wireless_stats - dev->name, - stats->status, - stats->qual.qual, -- stats->qual.updated & 1 ? '.' : ' ', -+ stats->qual.updated & IW_QUAL_QUAL_UPDATED -+ ? '.' : ' ', - ((__u8) stats->qual.level), -- stats->qual.updated & 2 ? '.' : ' ', -+ stats->qual.updated & IW_QUAL_LEVEL_UPDATED -+ ? '.' : ' ', - ((__u8) stats->qual.noise), -- stats->qual.updated & 4 ? '.' : ' ', -+ stats->qual.updated & IW_QUAL_NOISE_UPDATED -+ ? '.' : ' ', - stats->discard.nwid, - stats->discard.code, - stats->discard.fragment, -@@ -470,13 +529,15 @@ static inline int ioctl_export_private(s - /* Check NULL pointer */ - if(iwr->u.data.pointer == NULL) - return -EFAULT; --#ifdef WE_STRICT_WRITE -+ - /* Check if there is enough buffer up there */ - if(iwr->u.data.length < dev->wireless_handlers->num_private_args) { -- printk(KERN_ERR "%s (WE) : Buffer for request SIOCGIWPRIV too small (%d<%d)\n", dev->name, iwr->u.data.length, dev->wireless_handlers->num_private_args); -+ /* User space can't know in advance how large the buffer -+ * needs to be. Give it a hint, so that we can support -+ * any size buffer we want somewhat efficiently... */ -+ iwr->u.data.length = dev->wireless_handlers->num_private_args; - return -E2BIG; - } --#endif /* WE_STRICT_WRITE */ - - /* Set the number of available ioctls. */ - iwr->u.data.length = dev->wireless_handlers->num_private_args; -@@ -505,7 +566,6 @@ static inline int ioctl_standard_call(st - const struct iw_ioctl_description * descr; - struct iw_request_info info; - int ret = -EINVAL; -- int user_size = 0; - - /* Get the description of the IOCTL */ - if((cmd - SIOCIWFIRST) >= standard_ioctl_num) -@@ -536,8 +596,14 @@ static inline int ioctl_standard_call(st - #endif /* WE_SET_EVENT */ - } else { - char * extra; -+ int extra_size; -+ int user_length = 0; - int err; - -+ /* Calculate space needed by arguments. Always allocate -+ * for max space. Easier, and won't last long... */ -+ extra_size = descr->max_tokens * descr->token_size; -+ - /* Check what user space is giving us */ - if(IW_IS_SET(cmd)) { - /* Check NULL pointer */ -@@ -554,18 +620,33 @@ static inline int ioctl_standard_call(st - if(iwr->u.data.pointer == NULL) - return -EFAULT; - /* Save user space buffer size for checking */ -- user_size = iwr->u.data.length; -+ user_length = iwr->u.data.length; -+ -+ /* Don't check if user_length > max to allow forward -+ * compatibility. The test user_length < min is -+ * implied by the test at the end. */ -+ -+ /* Support for very large requests */ -+ if((descr->flags & IW_DESCR_FLAG_NOMAX) && -+ (user_length > descr->max_tokens)) { -+ /* Allow userspace to GET more than max so -+ * we can support any size GET requests. -+ * There is still a limit : -ENOMEM. */ -+ extra_size = user_length * descr->token_size; -+ /* Note : user_length is originally a __u16, -+ * and token_size is controlled by us, -+ * so extra_size won't get negative and -+ * won't overflow... */ -+ } - } - - #ifdef WE_IOCTL_DEBUG - printk(KERN_DEBUG "%s (WE) : Malloc %d bytes\n", -- dev->name, descr->max_tokens * descr->token_size); -+ dev->name, extra_size); - #endif /* WE_IOCTL_DEBUG */ - -- /* Always allocate for max space. Easier, and won't last -- * long... */ -- extra = kmalloc(descr->max_tokens * descr->token_size, -- GFP_KERNEL); -+ /* Create the kernel buffer */ -+ extra = kmalloc(extra_size, GFP_KERNEL); - if (extra == NULL) { - return -ENOMEM; - } -@@ -591,14 +672,11 @@ static inline int ioctl_standard_call(st - - /* If we have something to return to the user */ - if (!ret && IW_IS_GET(cmd)) { --#ifdef WE_STRICT_WRITE - /* Check if there is enough buffer up there */ -- if(user_size < iwr->u.data.length) { -- printk(KERN_ERR "%s (WE) : Buffer for request %04X too small (%d<%d)\n", dev->name, cmd, user_size, iwr->u.data.length); -+ if(user_length < iwr->u.data.length) { - kfree(extra); - return -E2BIG; - } --#endif /* WE_STRICT_WRITE */ - - err = copy_to_user(iwr->u.data.pointer, extra, - iwr->u.data.length * -@@ -661,7 +739,7 @@ static inline int ioctl_private_call(str - iw_handler handler) - { - struct iwreq * iwr = (struct iwreq *) ifr; -- struct iw_priv_args * descr = NULL; -+ const struct iw_priv_args * descr = NULL; - struct iw_request_info info; - int extra_size = 0; - int i; -@@ -701,7 +779,7 @@ static inline int ioctl_private_call(str - ((extra_size + offset) <= IFNAMSIZ)) - extra_size = 0; - } else { -- /* Size of set arguments */ -+ /* Size of get arguments */ - extra_size = get_priv_size(descr->get_args); - - /* Does it fits in iwr ? */ -@@ -771,6 +849,14 @@ static inline int ioctl_private_call(str - - /* If we have something to return to the user */ - if (!ret && IW_IS_GET(cmd)) { -+ -+ /* Adjust for the actual length if it's variable, -+ * avoid leaking kernel bits outside. */ -+ if (!(descr->get_args & IW_PRIV_SIZE_FIXED)) { -+ extra_size = adjust_priv_size(descr->get_args, -+ &(iwr->u)); -+ } -+ - err = copy_to_user(iwr->u.data.pointer, extra, - extra_size); - if (err) -@@ -1043,9 +1129,25 @@ void wireless_send_event(struct net_devi - * One of the main advantage of centralising spy support here is that - * it becomes much easier to improve and extend it without having to touch - * the drivers. One example is the addition of the Spy-Threshold events. -- * Note : IW_WIRELESS_SPY is defined in iw_handler.h - */ - -+/* ---------------------------------------------------------------- */ -+/* -+ * Return the pointer to the spy data in the driver. -+ * Because this is called on the Rx path via wireless_spy_update(), -+ * we want it to be efficient... -+ */ -+static inline struct iw_spy_data * get_spydata(struct net_device *dev) -+{ -+ /* This is the new way */ -+ if(dev->wireless_data) -+ return(dev->wireless_data->spy_data); -+ -+ /* This is the old way. Doesn't work for multi-headed drivers. -+ * It will be removed in the next version of WE. */ -+ return (dev->priv + dev->wireless_handlers->spy_offset); -+} -+ - /*------------------------------------------------------------------*/ - /* - * Standard Wireless Handler : set Spy List -@@ -1055,16 +1157,26 @@ int iw_handler_set_spy(struct net_device - union iwreq_data * wrqu, - char * extra) - { --#ifdef IW_WIRELESS_SPY -- struct iw_spy_data * spydata = (dev->priv + -- dev->wireless_handlers->spy_offset); -+ struct iw_spy_data * spydata = get_spydata(dev); - struct sockaddr * address = (struct sockaddr *) extra; - -+ /* Make sure driver is not buggy or using the old API */ -+ if(!spydata) -+ return -EOPNOTSUPP; -+ - /* Disable spy collection while we copy the addresses. -- * As we don't disable interrupts, we need to do this to avoid races. -- * As we are the only writer, this is good enough. */ -+ * While we copy addresses, any call to wireless_spy_update() -+ * will NOP. This is OK, as anyway the addresses are changing. */ - spydata->spy_number = 0; - -+ /* We want to operate without locking, because wireless_spy_update() -+ * most likely will happen in the interrupt handler, and therefore -+ * have its own locking constraints and needs performance. -+ * The rtnl_lock() make sure we don't race with the other iw_handlers. -+ * This make sure wireless_spy_update() "see" that the spy list -+ * is temporarily disabled. */ -+ wmb(); -+ - /* Are there are addresses to copy? */ - if(wrqu->data.length > 0) { - int i; -@@ -1090,13 +1202,14 @@ int iw_handler_set_spy(struct net_device - spydata->spy_address[i][5]); - #endif /* WE_SPY_DEBUG */ - } -+ -+ /* Make sure above is updated before re-enabling */ -+ wmb(); -+ - /* Enable addresses */ - spydata->spy_number = wrqu->data.length; - - return 0; --#else /* IW_WIRELESS_SPY */ -- return -EOPNOTSUPP; --#endif /* IW_WIRELESS_SPY */ - } - - /*------------------------------------------------------------------*/ -@@ -1108,12 +1221,14 @@ int iw_handler_get_spy(struct net_device - union iwreq_data * wrqu, - char * extra) - { --#ifdef IW_WIRELESS_SPY -- struct iw_spy_data * spydata = (dev->priv + -- dev->wireless_handlers->spy_offset); -+ struct iw_spy_data * spydata = get_spydata(dev); - struct sockaddr * address = (struct sockaddr *) extra; - int i; - -+ /* Make sure driver is not buggy or using the old API */ -+ if(!spydata) -+ return -EOPNOTSUPP; -+ - wrqu->data.length = spydata->spy_number; - - /* Copy addresses. */ -@@ -1130,9 +1245,6 @@ int iw_handler_get_spy(struct net_device - for(i = 0; i < spydata->spy_number; i++) - spydata->spy_stat[i].updated = 0; - return 0; --#else /* IW_WIRELESS_SPY */ -- return -EOPNOTSUPP; --#endif /* IW_WIRELESS_SPY */ - } - - /*------------------------------------------------------------------*/ -@@ -1144,11 +1256,13 @@ int iw_handler_set_thrspy(struct net_dev - union iwreq_data * wrqu, - char * extra) - { --#ifdef IW_WIRELESS_THRSPY -- struct iw_spy_data * spydata = (dev->priv + -- dev->wireless_handlers->spy_offset); -+ struct iw_spy_data * spydata = get_spydata(dev); - struct iw_thrspy * threshold = (struct iw_thrspy *) extra; - -+ /* Make sure driver is not buggy or using the old API */ -+ if(!spydata) -+ return -EOPNOTSUPP; -+ - /* Just do it */ - memcpy(&(spydata->spy_thr_low), &(threshold->low), - 2 * sizeof(struct iw_quality)); -@@ -1161,9 +1275,6 @@ int iw_handler_set_thrspy(struct net_dev - #endif /* WE_SPY_DEBUG */ - - return 0; --#else /* IW_WIRELESS_THRSPY */ -- return -EOPNOTSUPP; --#endif /* IW_WIRELESS_THRSPY */ - } - - /*------------------------------------------------------------------*/ -@@ -1175,22 +1286,20 @@ int iw_handler_get_thrspy(struct net_dev - union iwreq_data * wrqu, - char * extra) - { --#ifdef IW_WIRELESS_THRSPY -- struct iw_spy_data * spydata = (dev->priv + -- dev->wireless_handlers->spy_offset); -+ struct iw_spy_data * spydata = get_spydata(dev); - struct iw_thrspy * threshold = (struct iw_thrspy *) extra; - -+ /* Make sure driver is not buggy or using the old API */ -+ if(!spydata) -+ return -EOPNOTSUPP; -+ - /* Just do it */ - memcpy(&(threshold->low), &(spydata->spy_thr_low), - 2 * sizeof(struct iw_quality)); - - return 0; --#else /* IW_WIRELESS_THRSPY */ -- return -EOPNOTSUPP; --#endif /* IW_WIRELESS_THRSPY */ - } - --#ifdef IW_WIRELESS_THRSPY - /*------------------------------------------------------------------*/ - /* - * Prepare and send a Spy Threshold event -@@ -1228,7 +1337,6 @@ static void iw_send_thrspy_event(struct - /* Send event to user space */ - wireless_send_event(dev, SIOCGIWTHRSPY, &wrqu, (char *) &threshold); - } --#endif /* IW_WIRELESS_THRSPY */ - - /* ---------------------------------------------------------------- */ - /* -@@ -1241,12 +1349,14 @@ void wireless_spy_update(struct net_devi - unsigned char * address, - struct iw_quality * wstats) - { --#ifdef IW_WIRELESS_SPY -- struct iw_spy_data * spydata = (dev->priv + -- dev->wireless_handlers->spy_offset); -+ struct iw_spy_data * spydata = get_spydata(dev); - int i; - int match = -1; - -+ /* Make sure driver is not buggy or using the old API */ -+ if(!spydata) -+ return; -+ - #ifdef WE_SPY_DEBUG - printk(KERN_DEBUG "wireless_spy_update() : offset %ld, spydata %p, address %02X:%02X:%02X:%02X:%02X:%02X\n", dev->wireless_handlers->spy_offset, spydata, address[0], address[1], address[2], address[3], address[4], address[5]); - #endif /* WE_SPY_DEBUG */ -@@ -1258,7 +1368,7 @@ void wireless_spy_update(struct net_devi - sizeof(struct iw_quality)); - match = i; - } --#ifdef IW_WIRELESS_THRSPY -+ - /* Generate an event if we cross the spy threshold. - * To avoid event storms, we have a simple hysteresis : we generate - * event only when we go under the low threshold or above the -@@ -1278,6 +1388,4 @@ void wireless_spy_update(struct net_devi - } - } - } --#endif /* IW_WIRELESS_THRSPY */ --#endif /* IW_WIRELESS_SPY */ - } diff --git a/target/linux/generic-2.4/patches/106-mppe_mppc.patch b/target/linux/generic-2.4/patches/106-mppe_mppc.patch deleted file mode 100644 index afd2e60..0000000 --- a/target/linux/generic-2.4/patches/106-mppe_mppc.patch +++ /dev/null @@ -1,1642 +0,0 @@ -MPPE/MPPC kernel module for Linux - -Microsoft Point-to-Point Encryption / Compression support - - http://www.polbox.com/h/hs001/linux-2.4.29-mppe-mppc-1.3.patch.gz - ---- a/Documentation/Configure.help -+++ b/Documentation/Configure.help -@@ -9986,6 +9986,28 @@ CONFIG_PPP_BSDCOMP - module; it is called bsd_comp.o and will show up in the directory - modules once you have said "make modules". If unsure, say N. - -+Microsoft PPP compression/encryption (MPPC/MPPE) -+CONFIG_PPP_MPPE_MPPC -+ Support for the Microsoft Point-To-Point Compression (RFC2118) and -+ Microsoft Point-To-Point Encryption (RFC3078). These protocols are -+ supported by Microsoft Windows and wide range of "hardware" access -+ servers. MPPE is common protocol in Virtual Private Networks. According -+ to RFC3078, MPPE supports 40, 56 and 128-bit key lengths. Depending on -+ PPP daemon configuration on both ends of the link, following scenarios -+ are possible: -+ - only compression (MPPC) is used, -+ - only encryption (MPPE) is used, -+ - compression and encryption (MPPC+MPPE) are used. -+ -+ Please note that Hi/Fn (http://www.hifn.com) holds patent on MPPC so -+ you should check if this patent is valid in your country in order to -+ avoid legal problems. -+ -+ For more information please visit http://free.polbox.pl/h/hs001 -+ -+ To compile this driver as a module, choose M here. The module will -+ be called ppp_mppe_mppc.o. -+ - PPP over Ethernet - CONFIG_PPPOE - Support for PPP over Ethernet. ---- a/crypto/Config.in -+++ b/crypto/Config.in -@@ -11,7 +11,9 @@ if [ "$CONFIG_INET_AH" = "y" -o \ - "$CONFIG_INET6_AH" = "y" -o \ - "$CONFIG_INET6_AH" = "m" -o \ - "$CONFIG_INET6_ESP" = "y" -o \ -- "$CONFIG_INET6_ESP" = "m" ]; then -+ "$CONFIG_INET6_ESP" = "m" -o \ -+ "$CONFIG_PPP_MPPE_MPPC" = "y" -o \ -+ "$CONFIG_PPP_MPPE_MPPC" = "m" ]; then - define_bool CONFIG_CRYPTO y - else - bool 'Cryptographic API' CONFIG_CRYPTO -@@ -51,11 +53,24 @@ if [ "$CONFIG_CRYPTO" = "y" ]; then - "$CONFIG_INET6_AH" = "y" -o \ - "$CONFIG_INET6_AH" = "m" -o \ - "$CONFIG_INET6_ESP" = "y" -o \ -- "$CONFIG_INET6_ESP" = "m" ]; then -- define_bool CONFIG_CRYPTO_SHA1 y -- else -- tristate ' SHA1 digest algorithm' CONFIG_CRYPTO_SHA1 -+ "$CONFIG_INET6_ESP" = "m" -o \ -+ "$CONFIG_PPP_MPPE_MPPC" = "y" -o \ -+ "$CONFIG_PPP_MPPE_MPPC" = "m" ]; then -+ if [ "$CONFIG_INET_AH" = "y" -o \ -+ "$CONFIG_INET_ESP" = "y" -o \ -+ "$CONFIG_INET6_AH" = "y" -o \ -+ "$CONFIG_INET6_ESP" = "y" -o \ -+ "$CONFIG_PPP_MPPE_MPPC" = "y" ]; then -+ define_tristate CONFIG_CRYPTO_SHA1 y -+ else -+ if [ "$CONFIG_CRYPTO_SHA1" != "y" -a \ -+ "$CONFIG_CRYPTO_SHA1" != "m" ]; then -+ define_tristate CONFIG_CRYPTO_SHA1 m -+ fi -+ fi - fi -+ tristate ' SHA1 digest algorithm' CONFIG_CRYPTO_SHA1 -+ - tristate ' SHA256 digest algorithm' CONFIG_CRYPTO_SHA256 - tristate ' SHA384 and SHA512 digest algorithms' CONFIG_CRYPTO_SHA512 - tristate ' Whirlpool digest algorithms' CONFIG_CRYPTO_WP512 -@@ -76,7 +91,20 @@ if [ "$CONFIG_CRYPTO" = "y" ]; then - tristate ' TEA and XTEA cipher algorithms' CONFIG_CRYPTO_TEA - tristate ' Khazad cipher algorithm' CONFIG_CRYPTO_KHAZAD - tristate ' Anubis cipher algorithm' CONFIG_CRYPTO_ANUBIS -+ -+ if [ "$CONFIG_PPP_MPPE_MPPC" = "y" -o \ -+ "$CONFIG_PPP_MPPE_MPPC" = "m" ]; then -+ if [ "$CONFIG_PPP_MPPE_MPPC" = "y" ]; then -+ define_tristate CONFIG_CRYPTO_ARC4 y -+ else -+ if [ "$CONFIG_CRYPTO_ARC4" != "y" -a \ -+ "$CONFIG_CRYPTO_ARC4" != "m" ]; then -+ define_tristate CONFIG_CRYPTO_ARC4 m -+ fi -+ fi -+ fi - tristate ' ARC4 cipher algorithm' CONFIG_CRYPTO_ARC4 -+ - if [ "$CONFIG_INET_IPCOMP" = "y" -o \ - "$CONFIG_INET_IPCOMP" = "m" -o \ - "$CONFIG_INET6_IPCOMP" = "y" -o \ ---- a/drivers/net/Config.in -+++ b/drivers/net/Config.in -@@ -336,6 +336,7 @@ if [ ! "$CONFIG_PPP" = "n" ]; then - dep_tristate ' PPP support for sync tty ports' CONFIG_PPP_SYNC_TTY $CONFIG_PPP - dep_tristate ' PPP Deflate compression' CONFIG_PPP_DEFLATE $CONFIG_PPP - dep_tristate ' PPP BSD-Compress compression' CONFIG_PPP_BSDCOMP $CONFIG_PPP -+ dep_tristate ' Microsoft PPP compression/encryption (MPPC/MPPE)' CONFIG_PPP_MPPE_MPPC $CONFIG_PPP - if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then - dep_tristate ' PPP over Ethernet (EXPERIMENTAL)' CONFIG_PPPOE $CONFIG_PPP - fi ---- a/drivers/net/Makefile -+++ b/drivers/net/Makefile -@@ -166,6 +166,7 @@ obj-$(CONFIG_PPP_ASYNC) += ppp_async.o - obj-$(CONFIG_PPP_SYNC_TTY) += ppp_synctty.o - obj-$(CONFIG_PPP_DEFLATE) += ppp_deflate.o - obj-$(CONFIG_PPP_BSDCOMP) += bsd_comp.o -+obj-$(CONFIG_PPP_MPPE_MPPC) += ppp_mppe_mppc.o - obj-$(CONFIG_PPPOE) += pppox.o pppoe.o - - obj-$(CONFIG_SLIP) += slip.o ---- a/drivers/net/ppp_generic.c -+++ b/drivers/net/ppp_generic.c -@@ -19,7 +19,7 @@ - * PPP driver, written by Michael Callahan and Al Longyear, and - * subsequently hacked by Paul Mackerras. - * -- * ==FILEVERSION 20020217== -+ * ==FILEVERSION 20040509== - */ - - #include <linux/config.h> -@@ -102,6 +102,7 @@ struct ppp { - spinlock_t rlock; /* lock for receive side 58 */ - spinlock_t wlock; /* lock for transmit side 5c */ - int mru; /* max receive unit 60 */ -+ int mru_alloc; /* MAX(1500,MRU) for dev_alloc_skb() */ - unsigned int flags; /* control bits 64 */ - unsigned int xstate; /* transmit state bits 68 */ - unsigned int rstate; /* receive state bits 6c */ -@@ -552,7 +553,9 @@ static int ppp_ioctl(struct inode *inode - case PPPIOCSMRU: - if (get_user(val, (int *) arg)) - break; -- ppp->mru = val; -+ ppp->mru_alloc = ppp->mru = val; -+ if (ppp->mru_alloc < PPP_MRU) -+ ppp->mru_alloc = PPP_MRU; /* increase for broken peers */ - err = 0; - break; - -@@ -1025,14 +1028,37 @@ ppp_send_frame(struct ppp *ppp, struct s - case PPP_CCP: - /* peek at outbound CCP frames */ - ppp_ccp_peek(ppp, skb, 0); -+ /* -+ * When LZS or MPPE/MPPC has been negotiated we don't send -+ * CCP_RESETACK after receiving CCP_RESETREQ; in fact pppd -+ * sends such a packet but we silently discard it here -+ */ -+ if (CCP_CODE(skb->data+2) == CCP_RESETACK -+ && (ppp->xcomp->compress_proto == CI_MPPE -+ || ppp->xcomp->compress_proto == CI_LZS)) { -+ --ppp->stats.tx_packets; -+ ppp->stats.tx_bytes -= skb->len - 2; -+ kfree_skb(skb); -+ return; -+ } - break; - } - - /* try to do packet compression */ - if ((ppp->xstate & SC_COMP_RUN) && ppp->xc_state != 0 - && proto != PPP_LCP && proto != PPP_CCP) { -- new_skb = alloc_skb(ppp->dev->mtu + ppp->dev->hard_header_len, -- GFP_ATOMIC); -+ int comp_ovhd = 0; -+ /* -+ * because of possible data expansion when MPPC or LZS -+ * is used, allocate compressor's buffer 12.5% bigger -+ * than MTU -+ */ -+ if (ppp->xcomp->compress_proto == CI_MPPE) -+ comp_ovhd = ((ppp->dev->mtu * 9) / 8) + 1 + MPPE_OVHD; -+ else if (ppp->xcomp->compress_proto == CI_LZS) -+ comp_ovhd = ((ppp->dev->mtu * 9) / 8) + 1 + LZS_OVHD; -+ new_skb = alloc_skb(ppp->dev->mtu + ppp->dev->hard_header_len -+ + comp_ovhd, GFP_ATOMIC); - if (new_skb == 0) { - printk(KERN_ERR "PPP: no memory (comp pkt)\n"); - goto drop; -@@ -1050,9 +1076,21 @@ ppp_send_frame(struct ppp *ppp, struct s - skb = new_skb; - skb_put(skb, len); - skb_pull(skb, 2); /* pull off A/C bytes */ -- } else { -+ } else if (len == 0) { - /* didn't compress, or CCP not up yet */ - kfree_skb(new_skb); -+ } else { -+ /* -+ * (len < 0) -+ * MPPE requires that we do not send unencrypted -+ * frames. The compressor will return -1 if we -+ * should drop the frame. We cannot simply test -+ * the compress_proto because MPPE and MPPC share -+ * the same number. -+ */ -+ printk(KERN_ERR "ppp: compressor dropped pkt\n"); -+ kfree_skb(new_skb); -+ goto drop; - } - } - -@@ -1540,14 +1578,15 @@ ppp_decompress_frame(struct ppp *ppp, st - int len; - - if (proto == PPP_COMP) { -- ns = dev_alloc_skb(ppp->mru + PPP_HDRLEN); -+ ns = dev_alloc_skb(ppp->mru_alloc + PPP_HDRLEN); - if (ns == 0) { - printk(KERN_ERR "ppp_decompress_frame: no memory\n"); - goto err; - } - /* the decompressor still expects the A/C bytes in the hdr */ - len = ppp->rcomp->decompress(ppp->rc_state, skb->data - 2, -- skb->len + 2, ns->data, ppp->mru + PPP_HDRLEN); -+ skb->len + 2, ns->data, -+ ppp->mru_alloc + PPP_HDRLEN); - if (len < 0) { - /* Pass the compressed frame to pppd as an - error indication. */ -@@ -1573,7 +1612,14 @@ ppp_decompress_frame(struct ppp *ppp, st - return skb; - - err: -- ppp->rstate |= SC_DC_ERROR; -+ if (ppp->rcomp->compress_proto != CI_MPPE -+ && ppp->rcomp->compress_proto != CI_LZS) { -+ /* -+ * If decompression protocol isn't MPPE/MPPC or LZS, we set -+ * SC_DC_ERROR flag and wait for CCP_RESETACK -+ */ -+ ppp->rstate |= SC_DC_ERROR; -+ } - ppp_receive_error(ppp); - return skb; - } -@@ -2253,6 +2299,7 @@ ppp_create_interface(int unit, int *retp - /* Initialize the new ppp unit */ - ppp->file.index = unit; - ppp->mru = PPP_MRU; -+ ppp->mru_alloc = PPP_MRU; - init_ppp_file(&ppp->file, INTERFACE); - ppp->file.hdrlen = PPP_HDRLEN - 2; /* don't count proto bytes */ - for (i = 0; i < NUM_NP; ++i) ---- /dev/null -+++ b/drivers/net/ppp_mppe_mppc.c -@@ -0,0 +1,1312 @@ -+/* -+ * ppp_mppe_mppc.c - MPPC/MPPE "compressor/decompressor" module. -+ * -+ * Copyright (c) 1994 Árpád Magosányi <mag@bunuel.tii.matav.hu> -+ * Copyright (c) 1999 Tim Hockin, Cobalt Networks Inc. <thockin@cobaltnet.com> -+ * Copyright (c) 2002-2005 Jan Dubiec <jdx@slackware.pl> -+ * -+ * Permission to use, copy, modify, and distribute this software and its -+ * documentation is hereby granted, provided that the above copyright -+ * notice appears in all copies. This software is provided without any -+ * warranty, express or implied. -+ * -+ * The code is based on MPPE kernel module written by Árpád Magosányi and -+ * Tim Hockin which can be found on http://planetmirror.com/pub/mppe/. -+ * I have added MPPC and 56 bit session keys support in MPPE. -+ * -+ * WARNING! Although this is open source code, its usage in some countries -+ * (in particular in the USA) may violate Stac Inc. patent for MPPC. -+ * -+ * ==FILEVERSION 20050202== -+ * -+ */ -+ -+#include <linux/init.h> -+#include <linux/module.h> -+#include <linux/mm.h> -+#include <linux/slab.h> -+#include <asm/scatterlist.h> -+#include <linux/vmalloc.h> -+#include <linux/crypto.h> -+ -+#include <linux/ppp_defs.h> -+#include <linux/ppp-comp.h> -+ -+/* -+ * In 2.4.x kernels macro offset_in_page() is not defined in linux/mm.h so -+ * we define it here; PAGE_MASK is defined in asm/page.h which is included -+ * by linux/mm.h. -+ */ -+#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK) -+ -+/* -+ * State for a mppc/mppe "(de)compressor". -+ */ -+struct ppp_mppe_state { -+ struct crypto_tfm *arc4_tfm; -+ struct crypto_tfm *sha1_tfm; -+ u8 *sha1_digest; -+ u8 master_key[MPPE_MAX_KEY_LEN]; -+ u8 session_key[MPPE_MAX_KEY_LEN]; -+ u8 mppc; /* do we use compression (MPPC)? */ -+ u8 mppe; /* do we use encryption (MPPE)? */ -+ u8 keylen; /* key length in bytes */ -+ u8 bitkeylen; /* key length in bits */ -+ u16 ccount; /* coherency counter */ -+ u16 bits; /* MPPC/MPPE control bits */ -+ u8 stateless; /* do we use stateless mode? */ -+ u8 nextflushed; /* set A bit in the next outgoing packet; -+ used only by compressor*/ -+ u8 flushexpected; /* drop packets until A bit is received; -+ used only by decompressor*/ -+ u8 *hist; /* MPPC history */ -+ u16 *hash; /* Hash table; used only by compressor */ -+ u16 histptr; /* history "cursor" */ -+ int unit; -+ int debug; -+ int mru; -+ struct compstat stats; -+}; -+ -+#define MPPE_HIST_LEN 8192 /* MPPC history size */ -+#define MPPE_MAX_CCOUNT 0x0FFF /* max. coherency counter value */ -+ -+#define MPPE_BIT_FLUSHED 0x80 /* bit A */ -+#define MPPE_BIT_RESET 0x40 /* bit B */ -+#define MPPE_BIT_COMP 0x20 /* bit C */ -+#define MPPE_BIT_ENCRYPTED 0x10 /* bit D */ -+ -+#define MPPE_SALT0 0xD1 /* values used in MPPE key derivation */ -+#define MPPE_SALT1 0x26 /* according to RFC3079 */ -+#define MPPE_SALT2 0x9E -+ -+#define MPPE_CCOUNT(x) ((((x)[4] & 0x0f) << 8) + (x)[5]) -+#define MPPE_BITS(x) ((x)[4] & 0xf0) -+#define MPPE_CTRLHI(x) ((((x)->ccount & 0xf00)>>8)|((x)->bits)) -+#define MPPE_CTRLLO(x) ((x)->ccount & 0xff) -+ -+/* -+ * Kernel Crypto API needs its arguments to be in kmalloc'd memory, not in the -+ * module static data area. That means sha_pad needs to be kmalloc'd. It is done -+ * in mppe_module_init(). This has been pointed out on 30th July 2004 by Oleg -+ * Makarenko on pptpclient-devel mailing list. -+ */ -+#define SHA1_PAD_SIZE 40 -+struct sha_pad { -+ unsigned char sha_pad1[SHA1_PAD_SIZE]; -+ unsigned char sha_pad2[SHA1_PAD_SIZE]; -+}; -+static struct sha_pad *sha_pad; -+ -+static inline void -+setup_sg(struct scatterlist *sg, const void *address, unsigned int length) -+{ -+ sg[0].page = virt_to_page(address); -+ sg[0].offset = offset_in_page(address); -+ sg[0].length = length; -+} -+ -+static inline void -+arc4_setkey(struct ppp_mppe_state *state, const unsigned char *key, -+ const unsigned int keylen) -+{ -+ crypto_cipher_setkey(state->arc4_tfm, key, keylen); -+} -+ -+static inline void -+arc4_encrypt(struct ppp_mppe_state *state, const unsigned char *in, -+ const unsigned int len, unsigned char *out) -+{ -+ struct scatterlist sgin[4], sgout[4]; -+ -+ setup_sg(sgin, in, len); -+ setup_sg(sgout, out, len); -+ crypto_cipher_encrypt(state->arc4_tfm, sgout, sgin, len); -+} -+ -+#define arc4_decrypt arc4_encrypt -+ -+/* -+ * Key Derivation, from RFC 3078, RFC 3079. -+ * Equivalent to Get_Key() for MS-CHAP as described in RFC 3079. -+ */ -+static void -+get_new_key_from_sha(struct ppp_mppe_state *state, unsigned char *interim_key) -+{ -+ struct scatterlist sg[4]; -+ -+ setup_sg(&sg[0], state->master_key, state->keylen); -+ setup_sg(&sg[1], sha_pad->sha_pad1, sizeof(sha_pad->sha_pad1)); -+ setup_sg(&sg[2], state->session_key, state->keylen); -+ setup_sg(&sg[3], sha_pad->sha_pad2, sizeof(sha_pad->sha_pad2)); -+ -+ crypto_digest_digest (state->sha1_tfm, sg, 4, state->sha1_digest); -+ -+ memcpy(interim_key, state->sha1_digest, state->keylen); -+} -+ -+static void -+mppe_change_key(struct ppp_mppe_state *state, int initialize) -+{ -+ unsigned char interim_key[MPPE_MAX_KEY_LEN]; -+ -+ get_new_key_from_sha(state, interim_key); -+ if (initialize) { -+ memcpy(state->session_key, interim_key, state->keylen); -+ } else { -+ arc4_setkey(state, interim_key, state->keylen); -+ arc4_encrypt(state, interim_key, state->keylen, state->session_key); -+ } -+ if (state->keylen == 8) { -+ if (state->bitkeylen == 40) { -+ state->session_key[0] = MPPE_SALT0; -+ state->session_key[1] = MPPE_SALT1; -+ state->session_key[2] = MPPE_SALT2; -+ } else { -+ state->session_key[0] = MPPE_SALT0; -+ } -+ } -+ arc4_setkey(state, state->session_key, state->keylen); -+} -+ -+/* increase 12-bit coherency counter */ -+static inline void -+mppe_increase_ccount(struct ppp_mppe_state *state) -+{ -+ state->ccount = (state->ccount + 1) & MPPE_MAX_CCOUNT; -+ if (state->mppe) { -+ if (state->stateless) { -+ mppe_change_key(state, 0); -+ state->nextflushed = 1; -+ } else { -+ if ((state->ccount & 0xff) == 0xff) { -+ mppe_change_key(state, 0); -+ } -+ } -+ } -+} -+ -+/* allocate space for a MPPE/MPPC (de)compressor. */ -+/* comp != 0 -> init compressor */ -+/* comp = 0 -> init decompressor */ -+static void * -+mppe_alloc(unsigned char *options, int opt_len, int comp) -+{ -+ struct ppp_mppe_state *state; -+ unsigned int digestsize; -+ u8* fname; -+ -+ fname = comp ? "mppe_comp_alloc" : "mppe_decomp_alloc"; -+ -+ /* -+ * Hack warning - additionally to the standard MPPC/MPPE configuration -+ * options, pppd passes to the (de)copressor 8 or 16 byte session key. -+ * Therefore options[1] contains MPPC/MPPE configuration option length -+ * (CILEN_MPPE = 6), but the real options length, depending on the key -+ * length, is 6+8 or 6+16. -+ */ -+ if (opt_len < CILEN_MPPE) { -+ printk(KERN_WARNING "%s: wrong options length: %u\n", fname, opt_len); -+ return NULL; -+ } -+ -+ if (options[0] != CI_MPPE || options[1] != CILEN_MPPE || -+ (options[2] & ~MPPE_STATELESS) != 0 || -+ options[3] != 0 || options[4] != 0 || -+ (options[5] & ~(MPPE_128BIT|MPPE_56BIT|MPPE_40BIT|MPPE_MPPC)) != 0 || -+ (options[5] & (MPPE_128BIT|MPPE_56BIT|MPPE_40BIT|MPPE_MPPC)) == 0) { -+ printk(KERN_WARNING "%s: options rejected: o[0]=%02x, o[1]=%02x, " -+ "o[2]=%02x, o[3]=%02x, o[4]=%02x, o[5]=%02x\n", fname, options[0], -+ options[1], options[2], options[3], options[4], options[5]); -+ return NULL; -+ } -+ -+ state = (struct ppp_mppe_state *)kmalloc(sizeof(*state), GFP_KERNEL); -+ if (state == NULL) { -+ printk(KERN_ERR "%s: cannot allocate space for %scompressor\n", fname, -+ comp ? "" : "de"); -+ return NULL; -+ } -+ memset(state, 0, sizeof(struct ppp_mppe_state)); -+ -+ state->mppc = options[5] & MPPE_MPPC; /* Do we use MPPC? */ -+ state->mppe = options[5] & (MPPE_128BIT | MPPE_56BIT | -+ MPPE_40BIT); /* Do we use MPPE? */ -+ -+ if (state->mppc) { -+ /* allocate MPPC history */ -+ state->hist = (u8*)vmalloc(2*MPPE_HIST_LEN*sizeof(u8)); -+ if (state->hist == NULL) { -+ kfree(state); -+ printk(KERN_ERR "%s: cannot allocate space for MPPC history\n", -+ fname); -+ return NULL; -+ } -+ -+ /* allocate hashtable for MPPC compressor */ -+ if (comp) { -+ state->hash = (u16*)vmalloc(MPPE_HIST_LEN*sizeof(u16)); -+ if (state->hash == NULL) { -+ vfree(state->hist); -+ kfree(state); -+ printk(KERN_ERR "%s: cannot allocate space for MPPC history\n", -+ fname); -+ return NULL; -+ } -+ } -+ } -+ -+ if (state->mppe) { /* specific for MPPE */ -+ /* Load ARC4 algorithm */ -+ state->arc4_tfm = crypto_alloc_tfm("arc4", 0); -+ if (state->arc4_tfm == NULL) { -+ if (state->mppc) { -+ vfree(state->hash); -+ if (comp) -+ vfree(state->hist); -+ } -+ kfree(state); -+ printk(KERN_ERR "%s: cannot load ARC4 module\n", fname); -+ return NULL; -+ } -+ -+ /* Load SHA1 algorithm */ -+ state->sha1_tfm = crypto_alloc_tfm("sha1", 0); -+ if (state->sha1_tfm == NULL) { -+ crypto_free_tfm(state->arc4_tfm); -+ if (state->mppc) { -+ vfree(state->hash); -+ if (comp) -+ vfree(state->hist); -+ } -+ kfree(state); -+ printk(KERN_ERR "%s: cannot load SHA1 module\n", fname); -+ return NULL; -+ } -+ -+ digestsize = crypto_tfm_alg_digestsize(state->sha1_tfm); -+ if (digestsize < MPPE_MAX_KEY_LEN) { -+ crypto_free_tfm(state->sha1_tfm); -+ crypto_free_tfm(state->arc4_tfm); -+ if (state->mppc) { -+ vfree(state->hash); -+ if (comp) -+ vfree(state->hist); -+ } -+ kfree(state); -+ printk(KERN_ERR "%s: CryptoAPI SHA1 digest size too small\n", fname); -+ } -+ -+ state->sha1_digest = kmalloc(digestsize, GFP_KERNEL); -+ if (!state->sha1_digest) { -+ crypto_free_tfm(state->sha1_tfm); -+ crypto_free_tfm(state->arc4_tfm); -+ if (state->mppc) { -+ vfree(state->hash); -+ if (comp) -+ vfree(state->hist); -+ } -+ kfree(state); -+ printk(KERN_ERR "%s: cannot allocate space for SHA1 digest\n", fname); -+ } -+ -+ memcpy(state->master_key, options+CILEN_MPPE, MPPE_MAX_KEY_LEN); -+ memcpy(state->session_key, state->master_key, MPPE_MAX_KEY_LEN); -+ /* initial key generation is done in mppe_init() */ -+ } -+ -+ MOD_INC_USE_COUNT; -+ -+ return (void *) state; -+} -+ -+static void * -+mppe_comp_alloc(unsigned char *options, int opt_len) -+{ -+ return mppe_alloc(options, opt_len, 1); -+} -+ -+static void * -+mppe_decomp_alloc(unsigned char *options, int opt_len) -+{ -+ return mppe_alloc(options, opt_len, 0); -+} -+ -+/* cleanup the (de)compressor */ -+static void -+mppe_comp_free(void *arg) -+{ -+ struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg; -+ -+ if (state != NULL) { -+ if (state->mppe) { -+ if (state->sha1_tfm != NULL) -+ crypto_free_tfm(state->sha1_tfm); -+ if (state->arc4_tfm != NULL) -+ crypto_free_tfm(state->arc4_tfm); -+ } -+ if (state->hist != NULL) -+ vfree(state->hist); -+ if (state->hash != NULL) -+ vfree(state->hash); -+ kfree(state); -+ } -+ -+ MOD_DEC_USE_COUNT; -+} -+ -+/* init MPPC/MPPE (de)compresor */ -+/* comp != 0 -> init compressor */ -+/* comp = 0 -> init decompressor */ -+static int -+mppe_init(void *arg, unsigned char *options, int opt_len, int unit, -+ int hdrlen, int mru, int debug, int comp) -+{ -+ struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg; -+ u8* fname; -+ -+ fname = comp ? "mppe_comp_init" : "mppe_decomp_init"; -+ -+ if (opt_len < CILEN_MPPE) { -+ if (debug) -+ printk(KERN_WARNING "%s: wrong options length: %u\n", -+ fname, opt_len); -+ return 0; -+ } -+ -+ if (options[0] != CI_MPPE || options[1] != CILEN_MPPE || -+ (options[2] & ~MPPE_STATELESS) != 0 || -+ options[3] != 0 || options[4] != 0 || -+ (options[5] & ~(MPPE_56BIT|MPPE_128BIT|MPPE_40BIT|MPPE_MPPC)) != 0 || -+ (options[5] & (MPPE_56BIT|MPPE_128BIT|MPPE_40BIT|MPPE_MPPC)) == 0) { -+ if (debug) -+ printk(KERN_WARNING "%s: options rejected: o[0]=%02x, o[1]=%02x, " -+ "o[2]=%02x, o[3]=%02x, o[4]=%02x, o[5]=%02x\n", fname, -+ options[0], options[1], options[2], options[3], options[4], -+ options[5]); -+ return 0; -+ } -+ -+ if ((options[5] & ~MPPE_MPPC) != MPPE_128BIT && -+ (options[5] & ~MPPE_MPPC) != MPPE_56BIT && -+ (options[5] & ~MPPE_MPPC) != MPPE_40BIT && -+ (options[5] & MPPE_MPPC) != MPPE_MPPC) { -+ if (debug) -+ printk(KERN_WARNING "%s: don't know what to do: o[5]=%02x\n", -+ fname, options[5]); -+ return 0; -+ } -+ -+ state->mppc = options[5] & MPPE_MPPC; /* Do we use MPPC? */ -+ state->mppe = options[5] & (MPPE_128BIT | MPPE_56BIT | -+ MPPE_40BIT); /* Do we use MPPE? */ -+ state->stateless = options[2] & MPPE_STATELESS; /* Do we use stateless mode? */ -+ -+ switch (state->mppe) { -+ case MPPE_40BIT: /* 40 bit key */ -+ state->keylen = 8; -+ state->bitkeylen = 40; -+ break; -+ case MPPE_56BIT: /* 56 bit key */ -+ state->keylen = 8; -+ state->bitkeylen = 56; -+ break; -+ case MPPE_128BIT: /* 128 bit key */ -+ state->keylen = 16; -+ state->bitkeylen = 128; -+ break; -+ default: -+ state->keylen = 0; -+ state->bitkeylen = 0; -+ } -+ -+ state->ccount = MPPE_MAX_CCOUNT; -+ state->bits = 0; -+ state->unit = unit; -+ state->debug = debug; -+ state->histptr = MPPE_HIST_LEN; -+ if (state->mppc) { /* reset history if MPPC was negotiated */ -+ memset(state->hist, 0, 2*MPPE_HIST_LEN*sizeof(u8)); -+ } -+ -+ if (state->mppe) { /* generate initial session keys */ -+ mppe_change_key(state, 1); -+ } -+ -+ if (comp) { /* specific for compressor */ -+ state->nextflushed = 1; -+ } else { /* specific for decompressor */ -+ state->mru = mru; -+ state->flushexpected = 1; -+ } -+ -+ return 1; -+} -+ -+static int -+mppe_comp_init(void *arg, unsigned char *options, int opt_len, int unit, -+ int hdrlen, int debug) -+{ -+ return mppe_init(arg, options, opt_len, unit, hdrlen, 0, debug, 1); -+} -+ -+ -+static int -+mppe_decomp_init(void *arg, unsigned char *options, int opt_len, int unit, -+ int hdrlen, int mru, int debug) -+{ -+ return mppe_init(arg, options, opt_len, unit, hdrlen, mru, debug, 0); -+} -+ -+static void -+mppe_comp_reset(void *arg) -+{ -+ struct ppp_mppe_state *state = (struct ppp_mppe_state *)arg; -+ -+ if (state->debug) -+ printk(KERN_DEBUG "%s%d: resetting MPPC/MPPE compressor\n", -+ __FUNCTION__, state->unit); -+ -+ state->nextflushed = 1; -+ if (state->mppe) -+ arc4_setkey(state, state->session_key, state->keylen); -+} -+ -+static void -+mppe_decomp_reset(void *arg) -+{ -+ /* When MPPC/MPPE is in use, we shouldn't receive any CCP Reset-Ack. -+ But when we receive such a packet, we just ignore it. */ -+ return; -+} -+ -+static void -+mppe_stats(void *arg, struct compstat *stats) -+{ -+ struct ppp_mppe_state *state = (struct ppp_mppe_state *)arg; -+ -+ *stats = state->stats; -+} -+ -+/***************************/ -+/**** Compression stuff ****/ -+/***************************/ -+/* inserts 1 to 8 bits into the output buffer */ -+static inline void putbits8(u8 *buf, u32 val, const u32 n, u32 *i, u32 *l) -+{ -+ buf += *i; -+ if (*l >= n) { -+ *l = (*l) - n; -+ val <<= *l; -+ *buf = *buf | (val & 0xff); -+ if (*l == 0) { -+ *l = 8; -+ (*i)++; -+ *(++buf) = 0; -+ } -+ } else { -+ (*i)++; -+ *l = 8 - n + (*l); -+ val <<= *l; -+ *buf = *buf | ((val >> 8) & 0xff); -+ *(++buf) = val & 0xff; -+ } -+} -+ -+/* inserts 9 to 16 bits into the output buffer */ -+static inline void putbits16(u8 *buf, u32 val, const u32 n, u32 *i, u32 *l) -+{ -+ buf += *i; -+ if (*l >= n - 8) { -+ (*i)++; -+ *l = 8 - n + (*l); -+ val <<= *l; -+ *buf = *buf | ((val >> 8) & 0xff); -+ *(++buf) = val & 0xff; -+ if (*l == 0) { -+ *l = 8; -+ (*i)++; -+ *(++buf) = 0; -+ } -+ } else { -+ (*i)++; (*i)++; -+ *l = 16 - n + (*l); -+ val <<= *l; -+ *buf = *buf | ((val >> 16) & 0xff); -+ *(++buf) = (val >> 8) & 0xff; -+ *(++buf) = val & 0xff; -+ } -+} -+ -+/* inserts 17 to 24 bits into the output buffer */ -+static inline void putbits24(u8 *buf, u32 val, const u32 n, u32 *i, u32 *l) -+{ -+ buf += *i; -+ if (*l >= n - 16) { -+ (*i)++; (*i)++; -+ *l = 16 - n + (*l); -+ val <<= *l; -+ *buf = *buf | ((val >> 16) & 0xff); -+ *(++buf) = (val >> 8) & 0xff; -+ *(++buf) = val & 0xff; -+ if (*l == 0) { -+ *l = 8; -+ (*i)++; -+ *(++buf) = 0; -+ } -+ } else { -+ (*i)++; (*i)++; (*i)++; -+ *l = 24 - n + (*l); -+ val <<= *l; -+ *buf = *buf | ((val >> 24) & 0xff); -+ *(++buf) = (val >> 16) & 0xff; -+ *(++buf) = (val >> 8) & 0xff; -+ *(++buf) = val & 0xff; -+ } -+} -+ -+static int -+mppc_compress(struct ppp_mppe_state *state, unsigned char *ibuf, -+ unsigned char *obuf, int isize, int osize) -+{ -+ u32 olen, off, len, idx, i, l; -+ u8 *hist, *sbuf, *p, *q, *r, *s; -+ -+ /* -+ At this point, to avoid possible buffer overflow caused by packet -+ expansion during/after compression, we should make sure that -+ osize >= (((isize*9)/8)+1)+2, but we don't do that because in -+ ppp_generic.c we simply allocate bigger obuf. -+ -+ Maximum MPPC packet expansion is 12.5%. This is the worst case when -+ all octets in the input buffer are >= 0x80 and we cannot find any -+ repeated tokens. Additionally we have to reserve 2 bytes for MPPE/MPPC -+ status bits and coherency counter. -+ */ -+ -+ hist = state->hist + MPPE_HIST_LEN; -+ /* check if there is enough room at the end of the history */ -+ if (state->histptr + isize >= 2*MPPE_HIST_LEN) { -+ state->bits |= MPPE_BIT_RESET; -+ state->histptr = MPPE_HIST_LEN; -+ memcpy(state->hist, hist, MPPE_HIST_LEN); -+ } -+ /* add packet to the history; isize must be <= MPPE_HIST_LEN */ -+ sbuf = state->hist + state->histptr; -+ memcpy(sbuf, ibuf, isize); -+ state->histptr += isize; -+ -+ /* compress data */ -+ r = sbuf + isize; -+ *obuf = olen = i = 0; -+ l = 8; -+ while (i < isize - 2) { -+ s = q = sbuf + i; -+ idx = ((40543*((((s[0]<<4)^s[1])<<4)^s[2]))>>4) & 0x1fff; -+ p = hist + state->hash[idx]; -+ state->hash[idx] = (u16) (s - hist); -+ off = s - p; -+ if (off > MPPE_HIST_LEN - 1 || off < 1 || *p++ != *s++ || *p++ != *s++ || -+ *p++ != *s++) { -+ /* no match found; encode literal byte */ -+ if (ibuf[i] < 0x80) { /* literal byte < 0x80 */ -+ putbits8(obuf, (u32) ibuf[i], 8, &olen, &l); -+ } else { /* literal byte >= 0x80 */ -+ putbits16(obuf, (u32) (0x100|(ibuf[i]&0x7f)), 9, &olen, &l); -+ } -+ ++i; -+ continue; -+ } -+ if (r - q >= 64) { -+ *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || -+ *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || -+ *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || -+ *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || -+ *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || -+ *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || -+ *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || -+ *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || -+ *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || -+ *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || -+ *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || -+ *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || -+ *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || -+ *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || -+ *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || *p++ != *s++ || -+ *p++ != *s++; -+ if (s - q == 64) { -+ p--; s--; -+ while((*p++ == *s++) && (s < r) && (p < q)); -+ } -+ } else { -+ while((*p++ == *s++) && (s < r) && (p < q)); -+ } -+ len = s - q - 1; -+ i += len; -+ -+ /* at least 3 character match found; code data */ -+ /* encode offset */ -+ if (off < 64) { /* 10-bit offset; 0 <= offset < 64 */ -+ putbits16(obuf, 0x3c0|off, 10, &olen, &l); -+ } else if (off < 320) { /* 12-bit offset; 64 <= offset < 320 */ -+ putbits16(obuf, 0xe00|(off-64), 12, &olen, &l); -+ } else if (off < 8192) { /* 16-bit offset; 320 <= offset < 8192 */ -+ putbits16(obuf, 0xc000|(off-320), 16, &olen, &l); -+ } else { -+ /* This shouldn't happen; we return 0 what means "packet expands", -+ and we send packet uncompressed. */ -+ if (state->debug) -+ printk(KERN_DEBUG "%s%d: wrong offset value: %d\n", -+ __FUNCTION__, state->unit, off); -+ return 0; -+ } -+ /* encode length of match */ -+ if (len < 4) { /* length = 3 */ -+ putbits8(obuf, 0, 1, &olen, &l); -+ } else if (len < 8) { /* 4 <= length < 8 */ -+ putbits8(obuf, 0x08|(len&0x03), 4, &olen, &l); -+ } else if (len < 16) { /* 8 <= length < 16 */ -+ putbits8(obuf, 0x30|(len&0x07), 6, &olen, &l); -+ } else if (len < 32) { /* 16 <= length < 32 */ -+ putbits8(obuf, 0xe0|(len&0x0f), 8, &olen, &l); -+ } else if (len < 64) { /* 32 <= length < 64 */ -+ putbits16(obuf, 0x3c0|(len&0x1f), 10, &olen, &l); -+ } else if (len < 128) { /* 64 <= length < 128 */ -+ putbits16(obuf, 0xf80|(len&0x3f), 12, &olen, &l); -+ } else if (len < 256) { /* 128 <= length < 256 */ -+ putbits16(obuf, 0x3f00|(len&0x7f), 14, &olen, &l); -+ } else if (len < 512) { /* 256 <= length < 512 */ -+ putbits16(obuf, 0xfe00|(len&0xff), 16, &olen, &l); -+ } else if (len < 1024) { /* 512 <= length < 1024 */ -+ putbits24(obuf, 0x3fc00|(len&0x1ff), 18, &olen, &l); -+ } else if (len < 2048) { /* 1024 <= length < 2048 */ -+ putbits24(obuf, 0xff800|(len&0x3ff), 20, &olen, &l); -+ } else if (len < 4096) { /* 2048 <= length < 4096 */ -+ putbits24(obuf, 0x3ff000|(len&0x7ff), 22, &olen, &l); -+ } else if (len < 8192) { /* 4096 <= length < 8192 */ -+ putbits24(obuf, 0xffe000|(len&0xfff), 24, &olen, &l); -+ } else { -+ /* This shouldn't happen; we return 0 what means "packet expands", -+ and send packet uncompressed. */ -+ if (state->debug) -+ printk(KERN_DEBUG "%s%d: wrong length of match value: %d\n", -+ __FUNCTION__, state->unit, len); -+ return 0; -+ } -+ } -+ -+ /* Add remaining octets to the output */ -+ while(isize - i > 0) { -+ if (ibuf[i] < 0x80) { /* literal byte < 0x80 */ -+ putbits8(obuf, (u32) ibuf[i++], 8, &olen, &l); -+ } else { /* literal byte >= 0x80 */ -+ putbits16(obuf, (u32) (0x100|(ibuf[i++]&0x7f)), 9, &olen, &l); -+ } -+ } -+ /* Reset unused bits of the last output octet */ -+ if ((l != 0) && (l != 8)) { -+ putbits8(obuf, 0, l, &olen, &l); -+ } -+ -+ return (int) olen; -+} -+ -+int -+mppe_compress(void *arg, unsigned char *ibuf, unsigned char *obuf, -+ int isize, int osize) -+{ -+ struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg; -+ int proto, olen, complen, off; -+ unsigned char *wptr; -+ -+ /* Check that the protocol is in the range we handle. */ -+ proto = PPP_PROTOCOL(ibuf); -+ if (proto < 0x0021 || proto > 0x00fa) -+ return 0; -+ -+ wptr = obuf; -+ /* Copy over the PPP header */ -+ wptr[0] = PPP_ADDRESS(ibuf); -+ wptr[1] = PPP_CONTROL(ibuf); -+ wptr[2] = PPP_COMP >> 8; -+ wptr[3] = PPP_COMP; -+ wptr += PPP_HDRLEN + (MPPE_OVHD / 2); /* Leave two octets for MPPE/MPPC bits */ -+ -+ /* -+ * In ver. 0.99 protocol field was compressed. Deflate and BSD compress -+ * do PFC before actual compression, RCF2118 and RFC3078 are not precise -+ * on this topic so I decided to do PFC. Unfortunately this change caused -+ * incompatibility with older/other MPPE/MPPC modules. I have received -+ * a lot of complaints from unexperienced users so I have decided to revert -+ * to previous state, i.e. the protocol field is sent uncompressed now. -+ * Although this may be changed in the future. -+ * -+ * Receiving side (mppe_decompress()) still accepts packets with compressed -+ * and uncompressed protocol field so you shouldn't get "Unsupported protocol -+ * 0x2145 received" messages anymore. -+ */ -+ //off = (proto > 0xff) ? 2 : 3; /* PFC - skip first protocol byte if 0 */ -+ off = 2; -+ -+ ibuf += off; -+ -+ mppe_increase_ccount(state); -+ -+ if (state->nextflushed) { -+ state->bits |= MPPE_BIT_FLUSHED; -+ state->nextflushed = 0; -+ if (state->mppe && !state->stateless) { -+ /* -+ * If this is the flag packet, the key has been already changed in -+ * mppe_increase_ccount() so we dont't do it once again. -+ */ -+ if ((state->ccount & 0xff) != 0xff) { -+ arc4_setkey(state, state->session_key, state->keylen); -+ } -+ } -+ if (state->mppc) { /* reset history */ -+ state->bits |= MPPE_BIT_RESET; -+ state->histptr = MPPE_HIST_LEN; -+ memset(state->hist + MPPE_HIST_LEN, 0, MPPE_HIST_LEN*sizeof(u8)); -+ } -+ } -+ -+ if (state->mppc && !state->mppe) { /* Do only compression */ -+ complen = mppc_compress(state, ibuf, wptr, isize - off, -+ osize - PPP_HDRLEN - (MPPE_OVHD / 2)); -+ /* -+ * TODO: Implement an heuristics to handle packet expansion in a smart -+ * way. Now, when a packet expands, we send it as uncompressed and -+ * when next packet is sent we have to reset compressor's history. -+ * Maybe it would be better to send such packet as compressed in order -+ * to keep history's continuity. -+ */ -+ if ((complen > isize) || (complen > osize - PPP_HDRLEN) || -+ (complen == 0)) { -+ /* packet expands */ -+ state->nextflushed = 1; -+ memcpy(wptr, ibuf, isize - off); -+ olen = isize - (off - 2) + MPPE_OVHD; -+ (state->stats).inc_bytes += olen; -+ (state->stats).inc_packets++; -+ } else { -+ state->bits |= MPPE_BIT_COMP; -+ olen = complen + PPP_HDRLEN + (MPPE_OVHD / 2); -+ (state->stats).comp_bytes += olen; -+ (state->stats).comp_packets++; -+ } -+ } else { /* Do encryption with or without compression */ -+ state->bits |= MPPE_BIT_ENCRYPTED; -+ if (!state->mppc && state->mppe) { /* Do only encryption */ -+ /* read from ibuf, write to wptr, adjust for PPP_HDRLEN */ -+ arc4_encrypt(state, ibuf, isize - off, wptr); -+ olen = isize - (off - 2) + MPPE_OVHD; -+ (state->stats).inc_bytes += olen; -+ (state->stats).inc_packets++; -+ } else { /* Do compression and then encryption - RFC3078 */ -+ complen = mppc_compress(state, ibuf, wptr, isize - off, -+ osize - PPP_HDRLEN - (MPPE_OVHD / 2)); -+ /* -+ * TODO: Implement an heuristics to handle packet expansion in a smart -+ * way. Now, when a packet expands, we send it as uncompressed and -+ * when next packet is sent we have to reset compressor's history. -+ * Maybe it would be good to send such packet as compressed in order -+ * to keep history's continuity. -+ */ -+ if ((complen > isize) || (complen > osize - PPP_HDRLEN) || -+ (complen == 0)) { -+ /* packet expands */ -+ state->nextflushed = 1; -+ arc4_encrypt(state, ibuf, isize - off, wptr); -+ olen = isize - (off - 2) + MPPE_OVHD; -+ (state->stats).inc_bytes += olen; -+ (state->stats).inc_packets++; -+ } else { -+ state->bits |= MPPE_BIT_COMP; -+ /* Hack warning !!! RC4 implementation which we use does -+ encryption "in place" - it means that input and output -+ buffers can be *the same* memory area. Therefore we don't -+ need to use a temporary buffer. But be careful - other -+ implementations don't have to be so nice. -+ I used to use ibuf as temporary buffer here, but it led -+ packet sniffers into error. Thanks to Wilfried Weissmann -+ for pointing that. */ -+ arc4_encrypt(state, wptr, complen, wptr); -+ olen = complen + PPP_HDRLEN + (MPPE_OVHD / 2); -+ (state->stats).comp_bytes += olen; -+ (state->stats).comp_packets++; -+ } -+ } -+ } -+ -+ /* write status bits and coherency counter into the output buffer */ -+ wptr = obuf + PPP_HDRLEN; -+ wptr[0] = MPPE_CTRLHI(state); -+ wptr[1] = MPPE_CTRLLO(state); -+ -+ state->bits = 0; -+ -+ (state->stats).unc_bytes += isize; -+ (state->stats).unc_packets++; -+ -+ return olen; -+} -+ -+/***************************/ -+/*** Decompression stuff ***/ -+/***************************/ -+static inline u32 getbits(const u8 *buf, const u32 n, u32 *i, u32 *l) -+{ -+ static const u32 m[] = {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff}; -+ u32 res, ol; -+ -+ ol = *l; -+ if (*l >= n) { -+ *l = (*l) - n; -+ res = (buf[*i] & m[ol]) >> (*l); -+ if (*l == 0) { -+ *l = 8; -+ (*i)++; -+ } -+ } else { -+ *l = 8 - n + (*l); -+ res = (buf[(*i)++] & m[ol]) << 8; -+ res = (res | buf[*i]) >> (*l); -+ } -+ -+ return res; -+} -+ -+static inline u32 getbyte(const u8 *buf, const u32 i, const u32 l) -+{ -+ if (l == 8) { -+ return buf[i]; -+ } else { -+ return (((buf[i] << 8) | buf[i+1]) >> l) & 0xff; -+ } -+} -+ -+static inline void lamecopy(u8 *dst, u8 *src, u32 len) -+{ -+ while (len--) -+ *dst++ = *src++; -+} -+ -+static int -+mppc_decompress(struct ppp_mppe_state *state, unsigned char *ibuf, -+ unsigned char *obuf, int isize, int osize) -+{ -+ u32 olen, off, len, bits, val, sig, i, l; -+ u8 *history, *s; -+ -+ history = state->hist + state->histptr; -+ olen = len = i = 0; -+ l = 8; -+ bits = isize * 8; -+ while (bits >= 8) { -+ val = getbyte(ibuf, i++, l); -+ if (val < 0x80) { /* literal byte < 0x80 */ -+ if (state->histptr < 2*MPPE_HIST_LEN) { -+ /* copy uncompressed byte to the history */ -+ (state->hist)[(state->histptr)++] = (u8) val; -+ } else { -+ /* buffer overflow; drop packet */ -+ if (state->debug) -+ printk(KERN_ERR "%s%d: trying to write outside history " -+ "buffer\n", __FUNCTION__, state->unit); -+ return DECOMP_ERROR; -+ } -+ olen++; -+ bits -= 8; -+ continue; -+ } -+ -+ sig = val & 0xc0; -+ if (sig == 0x80) { /* literal byte >= 0x80 */ -+ if (state->histptr < 2*MPPE_HIST_LEN) { -+ /* copy uncompressed byte to the history */ -+ (state->hist)[(state->histptr)++] = -+ (u8) (0x80|((val&0x3f)<<1)|getbits(ibuf, 1 , &i ,&l)); -+ } else { -+ /* buffer overflow; drop packet */ -+ if (state->debug) -+ printk(KERN_ERR "%s%d: trying to write outside history " -+ "buffer\n", __FUNCTION__, state->unit); -+ return DECOMP_ERROR; -+ } -+ olen++; -+ bits -= 9; -+ continue; -+ } -+ -+ /* Not a literal byte so it must be an (offset,length) pair */ -+ /* decode offset */ -+ sig = val & 0xf0; -+ if (sig == 0xf0) { /* 10-bit offset; 0 <= offset < 64 */ -+ off = (((val&0x0f)<<2)|getbits(ibuf, 2 , &i ,&l)); -+ bits -= 10; -+ } else { -+ if (sig == 0xe0) { /* 12-bit offset; 64 <= offset < 320 */ -+ off = ((((val&0x0f)<<4)|getbits(ibuf, 4 , &i ,&l))+64); -+ bits -= 12; -+ } else { -+ if ((sig&0xe0) == 0xc0) {/* 16-bit offset; 320 <= offset < 8192 */ -+ off = ((((val&0x1f)<<8)|getbyte(ibuf, i++, l))+320); -+ bits -= 16; -+ if (off > MPPE_HIST_LEN - 1) { -+ if (state->debug) -+ printk(KERN_DEBUG "%s%d: too big offset value: %d\n", -+ __FUNCTION__, state->unit, off); -+ return DECOMP_ERROR; -+ } -+ } else { /* this shouldn't happen */ -+ if (state->debug) -+ printk(KERN_DEBUG "%s%d: cannot decode offset value\n", -+ __FUNCTION__, state->unit); -+ return DECOMP_ERROR; -+ } -+ } -+ } -+ /* decode length of match */ -+ val = getbyte(ibuf, i, l); -+ if ((val & 0x80) == 0x00) { /* len = 3 */ -+ len = 3; -+ bits--; -+ getbits(ibuf, 1 , &i ,&l); -+ } else if ((val & 0xc0) == 0x80) { /* 4 <= len < 8 */ -+ len = 0x04 | ((val>>4) & 0x03); -+ bits -= 4; -+ getbits(ibuf, 4 , &i ,&l); -+ } else if ((val & 0xe0) == 0xc0) { /* 8 <= len < 16 */ -+ len = 0x08 | ((val>>2) & 0x07); -+ bits -= 6; -+ getbits(ibuf, 6 , &i ,&l); -+ } else if ((val & 0xf0) == 0xe0) { /* 16 <= len < 32 */ -+ len = 0x10 | (val & 0x0f); -+ bits -= 8; -+ i++; -+ } else { -+ bits -= 8; -+ val = (val << 8) | getbyte(ibuf, ++i, l); -+ if ((val & 0xf800) == 0xf000) { /* 32 <= len < 64 */ -+ len = 0x0020 | ((val >> 6) & 0x001f); -+ bits -= 2; -+ getbits(ibuf, 2 , &i ,&l); -+ } else if ((val & 0xfc00) == 0xf800) { /* 64 <= len < 128 */ -+ len = 0x0040 | ((val >> 4) & 0x003f); -+ bits -= 4; -+ getbits(ibuf, 4 , &i ,&l); -+ } else if ((val & 0xfe00) == 0xfc00) { /* 128 <= len < 256 */ -+ len = 0x0080 | ((val >> 2) & 0x007f); -+ bits -= 6; -+ getbits(ibuf, 6 , &i ,&l); -+ } else if ((val & 0xff00) == 0xfe00) { /* 256 <= len < 512 */ -+ len = 0x0100 | (val & 0x00ff); -+ bits -= 8; -+ i++; -+ } else { -+ bits -= 8; -+ val = (val << 8) | getbyte(ibuf, ++i, l); -+ if ((val & 0xff8000) == 0xff0000) { /* 512 <= len < 1024 */ -+ len = 0x000200 | ((val >> 6) & 0x0001ff); -+ bits -= 2; -+ getbits(ibuf, 2 , &i ,&l); -+ } else if ((val & 0xffc000) == 0xff8000) {/* 1024 <= len < 2048 */ -+ len = 0x000400 | ((val >> 4) & 0x0003ff); -+ bits -= 4; -+ getbits(ibuf, 4 , &i ,&l); -+ } else if ((val & 0xffe000) == 0xffc000) {/* 2048 <= len < 4096 */ -+ len = 0x000800 | ((val >> 2) & 0x0007ff); -+ bits -= 6; -+ getbits(ibuf, 6 , &i ,&l); -+ } else if ((val & 0xfff000) == 0xffe000) {/* 4096 <= len < 8192 */ -+ len = 0x001000 | (val & 0x000fff); -+ bits -= 8; -+ i++; -+ } else { /* this shouldn't happen */ -+ if (state->debug) -+ printk(KERN_DEBUG "%s%d: wrong length code: 0x%X\n", -+ __FUNCTION__, state->unit, val); -+ return DECOMP_ERROR; -+ } -+ } -+ } -+ s = state->hist + state->histptr; -+ state->histptr += len; -+ olen += len; -+ if (state->histptr < 2*MPPE_HIST_LEN) { -+ /* copy uncompressed bytes to the history */ -+ -+ /* In some cases len may be greater than off. It means that memory -+ * areas pointed by s and s-off overlap. I had used memmove() here -+ * because I thought that it acts as libc's version. Unfortunately, -+ * I was wrong. :-) I got strange errors sometimes. Wilfried suggested -+ * using of byte by byte copying here and strange errors disappeared. -+ */ -+ lamecopy(s, s - off, len); -+ } else { -+ /* buffer overflow; drop packet */ -+ if (state->debug) -+ printk(KERN_ERR "%s%d: trying to write outside history " -+ "buffer\n", __FUNCTION__, state->unit); -+ return DECOMP_ERROR; -+ } -+ } -+ -+ /* Do PFC decompression */ -+ len = olen; -+ if ((history[0] & 0x01) != 0) { -+ obuf[0] = 0; -+ obuf++; -+ len++; -+ } -+ -+ if (len <= osize) { -+ /* copy uncompressed packet to the output buffer */ -+ memcpy(obuf, history, olen); -+ } else { -+ /* buffer overflow; drop packet */ -+ if (state->debug) -+ printk(KERN_ERR "%s%d: too big uncompressed packet: %d\n", -+ __FUNCTION__, state->unit, len + (PPP_HDRLEN / 2)); -+ return DECOMP_ERROR; -+ } -+ -+ return (int) len; -+} -+ -+int -+mppe_decompress(void *arg, unsigned char *ibuf, int isize, -+ unsigned char *obuf, int osize) -+{ -+ struct ppp_mppe_state *state = (struct ppp_mppe_state *)arg; -+ int seq, bits, uncomplen; -+ -+ if (isize <= PPP_HDRLEN + MPPE_OVHD) { -+ if (state->debug) { -+ printk(KERN_DEBUG "%s%d: short packet (len=%d)\n", __FUNCTION__, -+ state->unit, isize); -+ } -+ return DECOMP_ERROR; -+ } -+ -+ /* Get coherency counter and control bits from input buffer */ -+ seq = MPPE_CCOUNT(ibuf); -+ bits = MPPE_BITS(ibuf); -+ -+ if (state->stateless) { -+ /* RFC 3078, sec 8.1. */ -+ mppe_increase_ccount(state); -+ if ((seq != state->ccount) && state->debug) -+ printk(KERN_DEBUG "%s%d: bad sequence number: %d, expected: %d\n", -+ __FUNCTION__, state->unit, seq, state->ccount); -+ while (seq != state->ccount) -+ mppe_increase_ccount(state); -+ } else { -+ /* RFC 3078, sec 8.2. */ -+ if (state->flushexpected) { /* discard state */ -+ if ((bits & MPPE_BIT_FLUSHED)) { /* we received expected FLUSH bit */ -+ while (seq != state->ccount) -+ mppe_increase_ccount(state); -+ state->flushexpected = 0; -+ } else /* drop packet*/ -+ return DECOMP_ERROR; -+ } else { /* normal state */ -+ mppe_increase_ccount(state); -+ if (seq != state->ccount) { -+ /* Packet loss detected, enter the discard state. */ -+ if (state->debug) -+ printk(KERN_DEBUG "%s%d: bad sequence number: %d, expected: %d\n", -+ __FUNCTION__, state->unit, seq, state->ccount); -+ state->flushexpected = 1; -+ return DECOMP_ERROR; -+ } -+ } -+ if (state->mppe && (bits & MPPE_BIT_FLUSHED)) { -+ arc4_setkey(state, state->session_key, state->keylen); -+ } -+ } -+ -+ if (state->mppc && (bits & (MPPE_BIT_FLUSHED | MPPE_BIT_RESET))) { -+ state->histptr = MPPE_HIST_LEN; -+ if ((bits & MPPE_BIT_FLUSHED)) { -+ memset(state->hist + MPPE_HIST_LEN, 0, MPPE_HIST_LEN*sizeof(u8)); -+ } else -+ if ((bits & MPPE_BIT_RESET)) { -+ memcpy(state->hist, state->hist + MPPE_HIST_LEN, MPPE_HIST_LEN); -+ } -+ } -+ -+ /* Fill in the first part of the PPP header. The protocol field -+ comes from the decompressed data. */ -+ obuf[0] = PPP_ADDRESS(ibuf); -+ obuf[1] = PPP_CONTROL(ibuf); -+ obuf += PPP_HDRLEN / 2; -+ -+ if (state->mppe) { /* process encrypted packet */ -+ if ((bits & MPPE_BIT_ENCRYPTED)) { -+ /* OK, packet encrypted, so decrypt it */ -+ if (state->mppc && (bits & MPPE_BIT_COMP)) { -+ /* Hack warning !!! RC4 implementation which we use does -+ decryption "in place" - it means that input and output -+ buffers can be *the same* memory area. Therefore we don't -+ need to use a temporary buffer. But be careful - other -+ implementations don't have to be so nice. */ -+ arc4_decrypt(state, ibuf + PPP_HDRLEN + (MPPE_OVHD / 2), isize - -+ PPP_HDRLEN - (MPPE_OVHD / 2), ibuf + PPP_HDRLEN + -+ (MPPE_OVHD / 2)); -+ uncomplen = mppc_decompress(state, ibuf + PPP_HDRLEN + -+ (MPPE_OVHD / 2), obuf, isize - -+ PPP_HDRLEN - (MPPE_OVHD / 2), -+ osize - (PPP_HDRLEN / 2)); -+ if (uncomplen == DECOMP_ERROR) { -+ state->flushexpected = 1; -+ return DECOMP_ERROR; -+ } -+ uncomplen += PPP_HDRLEN / 2; -+ (state->stats).comp_bytes += isize; -+ (state->stats).comp_packets++; -+ } else { -+ uncomplen = isize - MPPE_OVHD; -+ /* Decrypt the first byte in order to check if it is -+ compressed or uncompressed protocol field */ -+ arc4_decrypt(state, ibuf + PPP_HDRLEN + (MPPE_OVHD / 2), 1, obuf); -+ /* Do PFC decompression */ -+ if ((obuf[0] & 0x01) != 0) { -+ obuf[1] = obuf[0]; -+ obuf[0] = 0; -+ obuf++; -+ uncomplen++; -+ } -+ /* And finally, decrypt the rest of the frame. */ -+ arc4_decrypt(state, ibuf + PPP_HDRLEN + (MPPE_OVHD / 2) + 1, -+ isize - PPP_HDRLEN - (MPPE_OVHD / 2) - 1, obuf + 1); -+ (state->stats).inc_bytes += isize; -+ (state->stats).inc_packets++; -+ } -+ } else { /* this shouldn't happen */ -+ if (state->debug) -+ printk(KERN_ERR "%s%d: encryption negotiated but not an " -+ "encrypted packet received\n", __FUNCTION__, state->unit); -+ mppe_change_key(state, 0); -+ state->flushexpected = 1; -+ return DECOMP_ERROR; -+ } -+ } else { -+ if (state->mppc) { /* no MPPE, only MPPC */ -+ if ((bits & MPPE_BIT_COMP)) { -+ uncomplen = mppc_decompress(state, ibuf + PPP_HDRLEN + -+ (MPPE_OVHD / 2), obuf, isize - -+ PPP_HDRLEN - (MPPE_OVHD / 2), -+ osize - (PPP_HDRLEN / 2)); -+ if (uncomplen == DECOMP_ERROR) { -+ state->flushexpected = 1; -+ return DECOMP_ERROR; -+ } -+ uncomplen += PPP_HDRLEN / 2; -+ (state->stats).comp_bytes += isize; -+ (state->stats).comp_packets++; -+ } else { -+ memcpy(obuf, ibuf + PPP_HDRLEN + (MPPE_OVHD / 2), isize - -+ PPP_HDRLEN - (MPPE_OVHD / 2)); -+ uncomplen = isize - MPPE_OVHD; -+ (state->stats).inc_bytes += isize; -+ (state->stats).inc_packets++; -+ } -+ } else { /* this shouldn't happen */ -+ if (state->debug) -+ printk(KERN_ERR "%s%d: error - not an MPPC or MPPE frame " -+ "received\n", __FUNCTION__, state->unit); -+ state->flushexpected = 1; -+ return DECOMP_ERROR; -+ } -+ } -+ -+ (state->stats).unc_bytes += uncomplen; -+ (state->stats).unc_packets++; -+ -+ return uncomplen; -+} -+ -+ -+/************************************************************ -+ * Module interface table -+ ************************************************************/ -+ -+/* These are in ppp_generic.c */ -+extern int ppp_register_compressor (struct compressor *cp); -+extern void ppp_unregister_compressor (struct compressor *cp); -+ -+/* -+ * Functions exported to ppp_generic.c. -+ * -+ * In case of MPPC/MPPE there is no need to process incompressible data -+ * because such a data is sent in MPPC/MPPE frame. Therefore the (*incomp) -+ * callback function isn't needed. -+ */ -+struct compressor ppp_mppe = { -+ CI_MPPE, /* compress_proto */ -+ mppe_comp_alloc, /* comp_alloc */ -+ mppe_comp_free, /* comp_free */ -+ mppe_comp_init, /* comp_init */ -+ mppe_comp_reset, /* comp_reset */ -+ mppe_compress, /* compress */ -+ mppe_stats, /* comp_stat */ -+ mppe_decomp_alloc, /* decomp_alloc */ -+ mppe_comp_free, /* decomp_free */ -+ mppe_decomp_init, /* decomp_init */ -+ mppe_decomp_reset, /* decomp_reset */ -+ mppe_decompress, /* decompress */ -+ NULL, /* incomp */ -+ mppe_stats, /* decomp_stat */ -+}; -+ -+/************************************************************ -+ * Module support routines -+ ************************************************************/ -+ -+int __init mppe_module_init(void) -+{ -+ int answer; -+ -+ /* When the module is compiled into kernel, it is initialized before -+ * CryptoAPI. Therefore the code below reports that there is no crypto -+ * stuff in the kernel. Marlon de Boer who has pointed out the problem, -+ * has sent also a message to CryptoAPI developers, so maybe in the future -+ * the code will be uncommented. -+ * -+ if (!(crypto_alg_available("arc4", 0) && crypto_alg_available("sha1", 0))) { -+ printk(KERN_ERR "Kernel doesn't provide ARC4 and/or SHA1 algorithms " -+ "required by MPPE/MPPC. Check CryptoAPI configuration.\n"); -+ return -ENODEV; -+ } -+ */ -+ -+ /* Allocate space for SHAPad1, SHAPad2 and ... */ -+ sha_pad = kmalloc(sizeof(struct sha_pad), GFP_KERNEL); -+ if (sha_pad == NULL) -+ return -ENOMEM; -+ /* ... initialize them */ -+ memset(sha_pad->sha_pad1, 0x00, sizeof(sha_pad->sha_pad1)); -+ memset(sha_pad->sha_pad2, 0xf2, sizeof(sha_pad->sha_pad2)); -+ -+ answer = ppp_register_compressor(&ppp_mppe); -+ if (answer == 0) { -+ printk(KERN_INFO "MPPE/MPPC encryption/compression module registered\n"); -+ } -+ return answer; -+} -+ -+void __exit mppe_module_cleanup(void) -+{ -+ kfree(sha_pad); -+ ppp_unregister_compressor(&ppp_mppe); -+ printk(KERN_INFO "MPPE/MPPC encryption/compression module unregistered\n"); -+} -+ -+module_init(mppe_module_init); -+module_exit(mppe_module_cleanup); -+ -+MODULE_AUTHOR("Jan Dubiec <jdx@slackware.pl>"); -+MODULE_DESCRIPTION("MPPE/MPPC encryption/compression module for Linux"); -+MODULE_LICENSE("Dual BSD/GPL"); ---- a/include/linux/ppp-comp.h -+++ b/include/linux/ppp-comp.h -@@ -28,7 +28,7 @@ - */ - - /* -- * ==FILEVERSION 980319== -+ * ==FILEVERSION 20040509== - * - * NOTE TO MAINTAINERS: - * If you modify this file at all, please set the above date. -@@ -78,7 +78,7 @@ struct compressor { - - /* Compress a packet */ - int (*compress) (void *state, unsigned char *rptr, -- unsigned char *obuf, int isize, int osize); -+ unsigned char *obuf, int isize, int osize); - - /* Return compression statistics */ - void (*comp_stat) (void *state, struct compstat *stats); -@@ -99,7 +99,7 @@ struct compressor { - - /* Decompress a packet. */ - int (*decompress) (void *state, unsigned char *ibuf, int isize, -- unsigned char *obuf, int osize); -+ unsigned char *obuf, int osize); - - /* Update state for an incompressible packet received */ - void (*incomp) (void *state, unsigned char *ibuf, int icnt); -@@ -187,6 +187,42 @@ struct compressor { - #define DEFLATE_CHK_SEQUENCE 0 - - /* -+ * Definitions for MPPE/MPPC. -+ */ -+ -+#define CI_MPPE 18 /* config option for MPPE */ -+#define CILEN_MPPE 6 /* length of config option */ -+ -+#define MPPE_OVHD 4 /* MPPE overhead */ -+#define MPPE_MAX_KEY_LEN 16 /* largest key length (128-bit) */ -+ -+#define MPPE_STATELESS 0x01 /* configuration bit H */ -+#define MPPE_40BIT 0x20 /* configuration bit L */ -+#define MPPE_56BIT 0x80 /* configuration bit M */ -+#define MPPE_128BIT 0x40 /* configuration bit S */ -+#define MPPE_MPPC 0x01 /* configuration bit C */ -+ -+/* -+ * Definitions for Stac LZS. -+ */ -+ -+#define CI_LZS 17 /* config option for Stac LZS */ -+#define CILEN_LZS 5 /* length of config option */ -+ -+#define LZS_OVHD 4 /* max. LZS overhead */ -+#define LZS_HIST_LEN 2048 /* LZS history size */ -+#define LZS_MAX_CCOUNT 0x0FFF /* max. coherency counter value */ -+ -+#define LZS_MODE_NONE 0 -+#define LZS_MODE_LCB 1 -+#define LZS_MODE_CRC 2 -+#define LZS_MODE_SEQ 3 -+#define LZS_MODE_EXT 4 -+ -+#define LZS_EXT_BIT_FLUSHED 0x80 /* bit A */ -+#define LZS_EXT_BIT_COMP 0x20 /* bit C */ -+ -+/* - * Definitions for other, as yet unsupported, compression methods. - */ - diff --git a/target/linux/generic-2.4/patches/107-cifs.patch b/target/linux/generic-2.4/patches/107-cifs.patch deleted file mode 100644 index e2ff33d..0000000 --- a/target/linux/generic-2.4/patches/107-cifs.patch +++ /dev/null @@ -1,21977 +0,0 @@ ---- a/Documentation/Configure.help -+++ b/Documentation/Configure.help -@@ -18007,6 +18007,34 @@ CONFIG_UNIXWARE_DISKLABEL - - If you don't know what all this is about, say N. - -+CIFS (Common Internet File System) support -+CONFIG_CIFS -+ This is the client VFS module for the Common Internet File System -+ (CIFS) protocol which is the successor to the Server Message Block -+ (SMB) protocol, the native file sharing mechanism for most early -+ PC operating systems. CIFS is fully supported by current network -+ file servers such as Windows 2000, Windows 2003 (including -+ Windows XP) as well by Samba (which provides excellent CIFS -+ server support for Linux and many other operating systems). -+ The smbfs module should be used instead of this cifs module for -+ mounting to older SMB servers such as OS/2. The smbfs and cifs -+ modules can coexist and do not conflict. -+ -+ The intent of this module is to provide the most advanced network -+ file system function for CIFS compliant servers, including better -+ POSIX compliance, secure per-user session establishment, high -+ performance safe distributed caching (oplock), optional packet -+ signing, Unicode support and other internationalization improvements -+ For more information see the project page at -+ http://us1.samba.org/samba/Linux_CIFS_client.html -+ -+CIFS Debugging -+CONFIG_CIFS_DEBUG -+ If you are experiencing any problems with the CIFS filesystem, say -+ Y here. This will result in additional debugging messages to be -+ written to the system log. Under normal circumstances, this -+ results in very little overhead. -+ - SMB file system support (to mount Windows shares etc.) - CONFIG_SMB_FS - SMB (Server Message Block) is the protocol Windows for Workgroups ---- a/Documentation/filesystems/00-INDEX -+++ b/Documentation/filesystems/00-INDEX -@@ -10,6 +10,8 @@ befs.txt - - info for the BeOS file system (BFS) - bfs.txt - - info for the SCO UnixWare Boot Filesystem (BFS). -+cifs.txt -+ - info on the Common Internet File System (CIFS) - coda.txt - - description of the CODA filesystem. - cramfs.txt ---- /dev/null -+++ b/Documentation/filesystems/cifs.txt -@@ -0,0 +1,51 @@ -+ This is the client VFS module for the Common Internet File System -+ (CIFS) protocol which is the successor to the Server Message Block -+ (SMB) protocol, the native file sharing mechanism for most early -+ PC operating systems. CIFS is fully supported by current network -+ file servers such as Windows 2000, Windows 2003 (including -+ Windows XP) as well by Samba (which provides excellent CIFS -+ server support for Linux and many other operating systems), so -+ this network filesystem client can mount to a wide variety of -+ servers. The smbfs module should be used instead of this cifs module -+ for mounting to older SMB servers such as OS/2. The smbfs and cifs -+ modules can coexist and do not conflict. The CIFS VFS filesystem -+ module is designed to work well with servers that implement the -+ newer versions (dialects) of the SMB/CIFS protocol such as Samba, -+ the program written by Andrew Tridgell that turns any Unix host -+ into a SMB/CIFS file server. -+ -+ The intent of this module is to provide the most advanced network -+ file system function for CIFS compliant servers, including better -+ POSIX compliance, secure per-user session establishment, high -+ performance safe distributed caching (oplock), optional packet -+ signing, large files, Unicode support and other internationalization -+ improvements. Since both Samba server and this filesystem client support -+ the CIFS Unix extensions, the combination can provide a reasonable -+ alternative to NFSv4 for fileserving in some Linux to Linux environments, -+ not just in Linux to Windows environments. -+ -+ This filesystem has an optional mount utility (mount.cifs) that can -+ be obtained from the project page and installed in the path in the same -+ directory with the other mount helpers (such as mount.smbfs). -+ Mounting using the cifs filesystem without installing the mount helper -+ requires specifying the server's ip address. -+ -+ For Linux 2.4: -+ mount //anything/here /mnt_target -o -+ user=username,pass=password,unc=//ip_address_of_server/sharename -+ -+ For Linux 2.5: -+ mount //ip_address_of_server/sharename /mnt_target -o user=username, pass=password -+ -+ -+ For more information on the module see the project page at -+ -+ http://us1.samba.org/samba/Linux_CIFS_client.html -+ -+ For more information on CIFS see: -+ -+ http://www.snia.org/tech_activities/CIFS -+ -+ or the Samba site: -+ -+ http://www.samba.org ---- /dev/null -+++ b/fs/cifs/asn1.c -@@ -0,0 +1,614 @@ -+/* -+ * The ASB.1/BER parsing code is derived from ip_nat_snmp_basic.c which was in -+ * turn derived from the gxsnmp package by Gregory McLean & Jochen Friedrich -+ * -+ * Copyright (c) 2000 RP Internet (www.rpi.net.au). -+ * -+ * 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 -+ */ -+ -+#include <linux/config.h> -+#include <linux/module.h> -+#include <linux/types.h> -+#include <linux/kernel.h> -+#include <linux/mm.h> -+#include <linux/slab.h> -+#include "cifspdu.h" -+#include "cifsglob.h" -+#include "cifs_debug.h" -+ -+/***************************************************************************** -+ * -+ * Basic ASN.1 decoding routines (gxsnmp author Dirk Wisse) -+ * -+ *****************************************************************************/ -+ -+/* Class */ -+#define ASN1_UNI 0 /* Universal */ -+#define ASN1_APL 1 /* Application */ -+#define ASN1_CTX 2 /* Context */ -+#define ASN1_PRV 3 /* Private */ -+ -+/* Tag */ -+#define ASN1_EOC 0 /* End Of Contents or N/A */ -+#define ASN1_BOL 1 /* Boolean */ -+#define ASN1_INT 2 /* Integer */ -+#define ASN1_BTS 3 /* Bit String */ -+#define ASN1_OTS 4 /* Octet String */ -+#define ASN1_NUL 5 /* Null */ -+#define ASN1_OJI 6 /* Object Identifier */ -+#define ASN1_OJD 7 /* Object Description */ -+#define ASN1_EXT 8 /* External */ -+#define ASN1_SEQ 16 /* Sequence */ -+#define ASN1_SET 17 /* Set */ -+#define ASN1_NUMSTR 18 /* Numerical String */ -+#define ASN1_PRNSTR 19 /* Printable String */ -+#define ASN1_TEXSTR 20 /* Teletext String */ -+#define ASN1_VIDSTR 21 /* Video String */ -+#define ASN1_IA5STR 22 /* IA5 String */ -+#define ASN1_UNITIM 23 /* Universal Time */ -+#define ASN1_GENTIM 24 /* General Time */ -+#define ASN1_GRASTR 25 /* Graphical String */ -+#define ASN1_VISSTR 26 /* Visible String */ -+#define ASN1_GENSTR 27 /* General String */ -+ -+/* Primitive / Constructed methods*/ -+#define ASN1_PRI 0 /* Primitive */ -+#define ASN1_CON 1 /* Constructed */ -+ -+/* -+ * Error codes. -+ */ -+#define ASN1_ERR_NOERROR 0 -+#define ASN1_ERR_DEC_EMPTY 2 -+#define ASN1_ERR_DEC_EOC_MISMATCH 3 -+#define ASN1_ERR_DEC_LENGTH_MISMATCH 4 -+#define ASN1_ERR_DEC_BADVALUE 5 -+ -+#define SPNEGO_OID_LEN 7 -+#define NTLMSSP_OID_LEN 10 -+unsigned long SPNEGO_OID[7] = { 1, 3, 6, 1, 5, 5, 2 }; -+unsigned long NTLMSSP_OID[10] = { 1, 3, 6, 1, 4, 1, 311, 2, 2, 10 }; -+ -+/* -+ * ASN.1 context. -+ */ -+struct asn1_ctx { -+ int error; /* Error condition */ -+ unsigned char *pointer; /* Octet just to be decoded */ -+ unsigned char *begin; /* First octet */ -+ unsigned char *end; /* Octet after last octet */ -+}; -+ -+/* -+ * Octet string (not null terminated) -+ */ -+struct asn1_octstr { -+ unsigned char *data; -+ unsigned int len; -+}; -+ -+static void -+asn1_open(struct asn1_ctx *ctx, unsigned char *buf, unsigned int len) -+{ -+ ctx->begin = buf; -+ ctx->end = buf + len; -+ ctx->pointer = buf; -+ ctx->error = ASN1_ERR_NOERROR; -+} -+ -+static unsigned char -+asn1_octet_decode(struct asn1_ctx *ctx, unsigned char *ch) -+{ -+ if (ctx->pointer >= ctx->end) { -+ ctx->error = ASN1_ERR_DEC_EMPTY; -+ return 0; -+ } -+ *ch = *(ctx->pointer)++; -+ return 1; -+} -+ -+static unsigned char -+asn1_tag_decode(struct asn1_ctx *ctx, unsigned int *tag) -+{ -+ unsigned char ch; -+ -+ *tag = 0; -+ -+ do { -+ if (!asn1_octet_decode(ctx, &ch)) -+ return 0; -+ *tag <<= 7; -+ *tag |= ch & 0x7F; -+ } while ((ch & 0x80) == 0x80); -+ return 1; -+} -+ -+static unsigned char -+asn1_id_decode(struct asn1_ctx *ctx, -+ unsigned int *cls, unsigned int *con, unsigned int *tag) -+{ -+ unsigned char ch; -+ -+ if (!asn1_octet_decode(ctx, &ch)) -+ return 0; -+ -+ *cls = (ch & 0xC0) >> 6; -+ *con = (ch & 0x20) >> 5; -+ *tag = (ch & 0x1F); -+ -+ if (*tag == 0x1F) { -+ if (!asn1_tag_decode(ctx, tag)) -+ return 0; -+ } -+ return 1; -+} -+ -+static unsigned char -+asn1_length_decode(struct asn1_ctx *ctx, unsigned int *def, unsigned int *len) -+{ -+ unsigned char ch, cnt; -+ -+ if (!asn1_octet_decode(ctx, &ch)) -+ return 0; -+ -+ if (ch == 0x80) -+ *def = 0; -+ else { -+ *def = 1; -+ -+ if (ch < 0x80) -+ *len = ch; -+ else { -+ cnt = (unsigned char) (ch & 0x7F); -+ *len = 0; -+ -+ while (cnt > 0) { -+ if (!asn1_octet_decode(ctx, &ch)) -+ return 0; -+ *len <<= 8; -+ *len |= ch; -+ cnt--; -+ } -+ } -+ } -+ return 1; -+} -+ -+static unsigned char -+asn1_header_decode(struct asn1_ctx *ctx, -+ unsigned char **eoc, -+ unsigned int *cls, unsigned int *con, unsigned int *tag) -+{ -+ unsigned int def, len; -+ -+ if (!asn1_id_decode(ctx, cls, con, tag)) -+ return 0; -+ -+ if (!asn1_length_decode(ctx, &def, &len)) -+ return 0; -+ -+ if (def) -+ *eoc = ctx->pointer + len; -+ else -+ *eoc = NULL; -+ return 1; -+} -+ -+static unsigned char -+asn1_eoc_decode(struct asn1_ctx *ctx, unsigned char *eoc) -+{ -+ unsigned char ch; -+ -+ if (eoc == 0) { -+ if (!asn1_octet_decode(ctx, &ch)) -+ return 0; -+ -+ if (ch != 0x00) { -+ ctx->error = ASN1_ERR_DEC_EOC_MISMATCH; -+ return 0; -+ } -+ -+ if (!asn1_octet_decode(ctx, &ch)) -+ return 0; -+ -+ if (ch != 0x00) { -+ ctx->error = ASN1_ERR_DEC_EOC_MISMATCH; -+ return 0; -+ } -+ return 1; -+ } else { -+ if (ctx->pointer != eoc) { -+ ctx->error = ASN1_ERR_DEC_LENGTH_MISMATCH; -+ return 0; -+ } -+ return 1; -+ } -+} -+ -+/* static unsigned char asn1_null_decode(struct asn1_ctx *ctx, -+ unsigned char *eoc) -+{ -+ ctx->pointer = eoc; -+ return 1; -+} -+ -+static unsigned char asn1_long_decode(struct asn1_ctx *ctx, -+ unsigned char *eoc, long *integer) -+{ -+ unsigned char ch; -+ unsigned int len; -+ -+ if (!asn1_octet_decode(ctx, &ch)) -+ return 0; -+ -+ *integer = (signed char) ch; -+ len = 1; -+ -+ while (ctx->pointer < eoc) { -+ if (++len > sizeof(long)) { -+ ctx->error = ASN1_ERR_DEC_BADVALUE; -+ return 0; -+ } -+ -+ if (!asn1_octet_decode(ctx, &ch)) -+ return 0; -+ -+ *integer <<= 8; -+ *integer |= ch; -+ } -+ return 1; -+} -+ -+static unsigned char asn1_uint_decode(struct asn1_ctx *ctx, -+ unsigned char *eoc, -+ unsigned int *integer) -+{ -+ unsigned char ch; -+ unsigned int len; -+ -+ if (!asn1_octet_decode(ctx, &ch)) -+ return 0; -+ -+ *integer = ch; -+ if (ch == 0) -+ len = 0; -+ else -+ len = 1; -+ -+ while (ctx->pointer < eoc) { -+ if (++len > sizeof(unsigned int)) { -+ ctx->error = ASN1_ERR_DEC_BADVALUE; -+ return 0; -+ } -+ -+ if (!asn1_octet_decode(ctx, &ch)) -+ return 0; -+ -+ *integer <<= 8; -+ *integer |= ch; -+ } -+ return 1; -+} -+ -+static unsigned char asn1_ulong_decode(struct asn1_ctx *ctx, -+ unsigned char *eoc, -+ unsigned long *integer) -+{ -+ unsigned char ch; -+ unsigned int len; -+ -+ if (!asn1_octet_decode(ctx, &ch)) -+ return 0; -+ -+ *integer = ch; -+ if (ch == 0) -+ len = 0; -+ else -+ len = 1; -+ -+ while (ctx->pointer < eoc) { -+ if (++len > sizeof(unsigned long)) { -+ ctx->error = ASN1_ERR_DEC_BADVALUE; -+ return 0; -+ } -+ -+ if (!asn1_octet_decode(ctx, &ch)) -+ return 0; -+ -+ *integer <<= 8; -+ *integer |= ch; -+ } -+ return 1; -+} -+ -+static unsigned char -+asn1_octets_decode(struct asn1_ctx *ctx, -+ unsigned char *eoc, -+ unsigned char **octets, unsigned int *len) -+{ -+ unsigned char *ptr; -+ -+ *len = 0; -+ -+ *octets = kmalloc(eoc - ctx->pointer, GFP_ATOMIC); -+ if (*octets == NULL) { -+ return 0; -+ } -+ -+ ptr = *octets; -+ while (ctx->pointer < eoc) { -+ if (!asn1_octet_decode(ctx, (unsigned char *) ptr++)) { -+ kfree(*octets); -+ *octets = NULL; -+ return 0; -+ } -+ (*len)++; -+ } -+ return 1; -+} */ -+ -+static unsigned char -+asn1_subid_decode(struct asn1_ctx *ctx, unsigned long *subid) -+{ -+ unsigned char ch; -+ -+ *subid = 0; -+ -+ do { -+ if (!asn1_octet_decode(ctx, &ch)) -+ return 0; -+ -+ *subid <<= 7; -+ *subid |= ch & 0x7F; -+ } while ((ch & 0x80) == 0x80); -+ return 1; -+} -+ -+static unsigned char -+asn1_oid_decode(struct asn1_ctx *ctx, -+ unsigned char *eoc, unsigned long **oid, unsigned int *len) -+{ -+ unsigned long subid; -+ unsigned int size; -+ unsigned long *optr; -+ -+ size = eoc - ctx->pointer + 1; -+ *oid = kmalloc(size * sizeof (unsigned long), GFP_ATOMIC); -+ if (*oid == NULL) { -+ return 0; -+ } -+ -+ optr = *oid; -+ -+ if (!asn1_subid_decode(ctx, &subid)) { -+ kfree(*oid); -+ *oid = NULL; -+ return 0; -+ } -+ -+ if (subid < 40) { -+ optr[0] = 0; -+ optr[1] = subid; -+ } else if (subid < 80) { -+ optr[0] = 1; -+ optr[1] = subid - 40; -+ } else { -+ optr[0] = 2; -+ optr[1] = subid - 80; -+ } -+ -+ *len = 2; -+ optr += 2; -+ -+ while (ctx->pointer < eoc) { -+ if (++(*len) > size) { -+ ctx->error = ASN1_ERR_DEC_BADVALUE; -+ kfree(*oid); -+ *oid = NULL; -+ return 0; -+ } -+ -+ if (!asn1_subid_decode(ctx, optr++)) { -+ kfree(*oid); -+ *oid = NULL; -+ return 0; -+ } -+ } -+ return 1; -+} -+ -+static int -+compare_oid(unsigned long *oid1, unsigned int oid1len, -+ unsigned long *oid2, unsigned int oid2len) -+{ -+ unsigned int i; -+ -+ if (oid1len != oid2len) -+ return 0; -+ else { -+ for (i = 0; i < oid1len; i++) { -+ if (oid1[i] != oid2[i]) -+ return 0; -+ } -+ return 1; -+ } -+} -+ -+ /* BB check for endian conversion issues here */ -+ -+int -+decode_negTokenInit(unsigned char *security_blob, int length, -+ enum securityEnum *secType) -+{ -+ struct asn1_ctx ctx; -+ unsigned char *end; -+ unsigned char *sequence_end; -+ unsigned long *oid; -+ unsigned int cls, con, tag, oidlen, rc; -+ int use_ntlmssp = FALSE; -+ -+ *secType = NTLM; /* BB eventually make Kerberos or NLTMSSP the default */ -+ -+ /* cifs_dump_mem(" Received SecBlob ", security_blob, length); */ -+ -+ asn1_open(&ctx, security_blob, length); -+ -+ if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) { -+ cFYI(1, ("Error decoding negTokenInit header ")); -+ return 0; -+ } else if ((cls != ASN1_APL) || (con != ASN1_CON) -+ || (tag != ASN1_EOC)) { -+ cFYI(1, ("cls = %d con = %d tag = %d", cls, con, tag)); -+ return 0; -+ } else { -+ /* remember to free obj->oid */ -+ rc = asn1_header_decode(&ctx, &end, &cls, &con, &tag); -+ if (rc) { -+ if ((tag == ASN1_OJI) && (cls == ASN1_PRI)) { -+ rc = asn1_oid_decode(&ctx, end, &oid, &oidlen); -+ if (rc) { -+ rc = compare_oid(oid, oidlen, -+ SPNEGO_OID, -+ SPNEGO_OID_LEN); -+ kfree(oid); -+ } -+ } else -+ rc = 0; -+ } -+ -+ if (!rc) { -+ cFYI(1, ("Error decoding negTokenInit header")); -+ return 0; -+ } -+ -+ if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) { -+ cFYI(1, ("Error decoding negTokenInit ")); -+ return 0; -+ } else if ((cls != ASN1_CTX) || (con != ASN1_CON) -+ || (tag != ASN1_EOC)) { -+ cFYI(1,("cls = %d con = %d tag = %d end = %p (%d) exit 0", -+ cls, con, tag, end, *end)); -+ return 0; -+ } -+ -+ if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) { -+ cFYI(1, ("Error decoding negTokenInit ")); -+ return 0; -+ } else if ((cls != ASN1_UNI) || (con != ASN1_CON) -+ || (tag != ASN1_SEQ)) { -+ cFYI(1,("cls = %d con = %d tag = %d end = %p (%d) exit 1", -+ cls, con, tag, end, *end)); -+ return 0; -+ } -+ -+ if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) { -+ cFYI(1, ("Error decoding 2nd part of negTokenInit ")); -+ return 0; -+ } else if ((cls != ASN1_CTX) || (con != ASN1_CON) -+ || (tag != ASN1_EOC)) { -+ cFYI(1, -+ ("cls = %d con = %d tag = %d end = %p (%d) exit 0", -+ cls, con, tag, end, *end)); -+ return 0; -+ } -+ -+ if (asn1_header_decode -+ (&ctx, &sequence_end, &cls, &con, &tag) == 0) { -+ cFYI(1, ("Error decoding 2nd part of negTokenInit ")); -+ return 0; -+ } else if ((cls != ASN1_UNI) || (con != ASN1_CON) -+ || (tag != ASN1_SEQ)) { -+ cFYI(1, -+ ("cls = %d con = %d tag = %d end = %p (%d) exit 1", -+ cls, con, tag, end, *end)); -+ return 0; -+ } -+ -+ while (!asn1_eoc_decode(&ctx, sequence_end)) { -+ rc = asn1_header_decode(&ctx, &end, &cls, &con, &tag); -+ if (!rc) { -+ cFYI(1, -+ ("Error 1 decoding negTokenInit header exit 2")); -+ return 0; -+ } -+ if ((tag == ASN1_OJI) && (con == ASN1_PRI)) { -+ asn1_oid_decode(&ctx, end, &oid, &oidlen); -+ cFYI(1, -+ ("OID len = %d oid = 0x%lx 0x%lx 0x%lx 0x%lx", -+ oidlen, *oid, *(oid + 1), *(oid + 2), -+ *(oid + 3))); -+ rc = compare_oid(oid, oidlen, NTLMSSP_OID, -+ NTLMSSP_OID_LEN); -+ kfree(oid); -+ if (rc) -+ use_ntlmssp = TRUE; -+ } else { -+ cFYI(1,("This should be an oid what is going on? ")); -+ } -+ } -+ -+ if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) { -+ cFYI(1, -+ ("Error decoding last part of negTokenInit exit 3")); -+ return 0; -+ } else if ((cls != ASN1_CTX) || (con != ASN1_CON)) { /* tag = 3 indicating mechListMIC */ -+ cFYI(1, -+ ("Exit 4 cls = %d con = %d tag = %d end = %p (%d)", -+ cls, con, tag, end, *end)); -+ return 0; -+ } -+ if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) { -+ cFYI(1, -+ ("Error decoding last part of negTokenInit exit 5")); -+ return 0; -+ } else if ((cls != ASN1_UNI) || (con != ASN1_CON) -+ || (tag != ASN1_SEQ)) { -+ cFYI(1, -+ ("Exit 6 cls = %d con = %d tag = %d end = %p (%d)", -+ cls, con, tag, end, *end)); -+ } -+ -+ if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) { -+ cFYI(1, -+ ("Error decoding last part of negTokenInit exit 7")); -+ return 0; -+ } else if ((cls != ASN1_CTX) || (con != ASN1_CON)) { -+ cFYI(1, -+ ("Exit 8 cls = %d con = %d tag = %d end = %p (%d)", -+ cls, con, tag, end, *end)); -+ return 0; -+ } -+ if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) { -+ cFYI(1, -+ ("Error decoding last part of negTokenInit exit 9")); -+ return 0; -+ } else if ((cls != ASN1_UNI) || (con != ASN1_PRI) -+ || (tag != ASN1_GENSTR)) { -+ cFYI(1, -+ ("Exit 10 cls = %d con = %d tag = %d end = %p (%d)", -+ cls, con, tag, end, *end)); -+ return 0; -+ } -+ cFYI(1, ("Need to call asn1_octets_decode() function for this %s", ctx.pointer)); /* is this UTF-8 or ASCII? */ -+ } -+ -+ /* if (use_kerberos) -+ *secType = Kerberos -+ else */ -+ if (use_ntlmssp) { -+ *secType = NTLMSSP; -+ } -+ -+ return 1; -+} ---- /dev/null -+++ b/fs/cifs/AUTHORS -@@ -0,0 +1,37 @@ -+Original Author -+=============== -+Steve French (sfrench@samba.org) -+ -+The author wishes to express his appreciation and thanks to: -+Andrew Tridgell (Samba team) for his early suggestions about smb/cifs VFS -+improvements. Thanks to IBM for allowing me the time and test resources to pursue -+this project. Jim McDonough from IBM (and the Samba Team) for his help. -+The IBM Linux JFS team for explaining many esoteric Linux filesystem features. -+Dave Boutcher of IBM Rochester (author of the OS/400 smb/cifs filesystem client) -+for proving years ago that a very good smb/cifs client could be done on a Unix like -+operating system. Volker Lendecke, Andrew Tridgell, Urban Widmark, John Newbigin -+and others for their work on the Linux smbfs module over the years. Thanks to -+the other members of the Storage Network Industry Association CIFS Technical -+Workgroup for their work specifying this highly complex protocol and finally -+thanks to the Samba team for their technical advice and encouragement. -+ -+Patch Contributors -+------------------ -+Zwane Mwaikambo -+Andi Kleen -+Amrut Joshi -+Shobhit Dayal -+Sergey Vlasov -+Richard Hughes -+Yury Umanets -+ -+Test case and Bug Report contributors -+------------------------------------- -+Thanks to those in the community who have submitted detailed bug reports -+and debug of problems they have found: Jochen Dolze, David Blaine, -+Rene Scharfe, Martin Josefsson, Alexander Wild, Anthony Liguori, -+Lars Muller, Urban Widmark, Massimiliano Ferrero, Howard Owen, -+Olaf Kirch, Kieron Briggs, Nick Millington and others. -+ -+And thanks to the IBM LTC and Power test teams and SuSE testers for -+finding multiple bugs during excellent stress test runs. ---- /dev/null -+++ b/fs/cifs/CHANGES -@@ -0,0 +1,572 @@ -+Version 1.20 -+------------ -+Make transaction counts more consistent. Merge /proc/fs/cifs/SimultaneousOps -+info into /proc/fs/cifs/DebugData. Fix oops in rare oops in readdir -+(in build_wildcard_path_from_dentry). Fix mknod to pass type field -+(block/char/fifo) properly. Remove spurious mount warning log entry when -+credentials passed as mount argument. Set major/minor device number in -+inode for block and char devices when unix extensions enabled. -+ -+Version 1.19 -+------------ -+Fix /proc/fs/cifs/Stats and DebugData display to handle larger -+amounts of return data. Properly limit requests to MAX_REQ (50 -+is the usual maximum active multiplex SMB/CIFS requests per server). -+Do not kill cifsd (and thus hurt the other SMB session) when more than one -+session to the same server (but with different userids) exists and one -+of the two user's smb sessions is being removed while leaving the other. -+Do not loop reconnecting in cifsd demultiplex thread when admin -+kills the thread without going through unmount. -+ -+Version 1.18 -+------------ -+Do not rename hardlinked files (since that should be a noop). Flush -+cached write behind data when reopening a file after session abend, -+except when already in write. Grab per socket sem during reconnect -+to avoid oops in sendmsg if overlapping with reconnect. Do not -+reset cached inode file size on readdir for files open for write on -+client. -+ -+ -+Version 1.17 -+------------ -+Update number of blocks in file so du command is happier (in Linux a fake -+blocksize of 512 is required for calculating number of blocks in inode). -+Fix prepare write of partial pages to read in data from server if possible. -+Fix race on tcpStatus field between unmount and reconnection code, causing -+cifsd process sometimes to hang around forever. Improve out of memory -+checks in cifs_filldir -+ -+Version 1.16 -+------------ -+Fix incorrect file size in file handle based setattr on big endian hardware. -+Fix oops in build_path_from_dentry when out of memory. Add checks for invalid -+and closing file structs in writepage/partialpagewrite. Add statistics -+for each mounted share (new menuconfig option). Fix endianness problem in -+volume information displayed in /proc/fs/cifs/DebugData (only affects -+affects big endian architectures). Prevent renames while constructing -+path names for open, mkdir and rmdir. -+ -+Version 1.15 -+------------ -+Change to mempools for alloc smb request buffers and multiplex structs -+to better handle low memory problems (and potential deadlocks). -+ -+Version 1.14 -+------------ -+Fix incomplete listings of large directories on Samba servers when Unix -+extensions enabled. Fix oops when smb_buffer can not be allocated. Fix -+rename deadlock when writing out dirty pages at same time. -+ -+Version 1.13 -+------------ -+Fix open of files in which O_CREATE can cause the mode to change in -+some cases. Fix case in which retry of write overlaps file close. -+Fix PPC64 build error. Reduce excessive stack usage in smb password -+hashing. Fix overwrite of Linux user's view of file mode to Windows servers. -+ -+Version 1.12 -+------------ -+Fixes for large file copy, signal handling, socket retry, buffer -+allocation and low memory situations. -+ -+Version 1.11 -+------------ -+Better port 139 support to Windows servers (RFC1001/RFC1002 Session_Initialize) -+also now allowing support for specifying client netbiosname. NT4 support added. -+ -+Version 1.10 -+------------ -+Fix reconnection (and certain failed mounts) to properly wake up the -+blocked users thread so it does not seem hung (in some cases was blocked -+until the cifs receive timeout expired). Fix spurious error logging -+to kernel log when application with open network files killed. -+ -+Version 1.09 -+------------ -+Fix /proc/fs module unload warning message (that could be logged -+to the kernel log). Fix intermittent failure in connectathon -+test7 (hardlink count not immediately refreshed in case in which -+inode metadata can be incorrectly kept cached when time near zero) -+ -+Version 1.08 -+------------ -+Allow file_mode and dir_mode (specified at mount time) to be enforced -+locally (the server already enforced its own ACLs too) for servers -+that do not report the correct mode (do not support the -+CIFS Unix Extensions). -+ -+Version 1.07 -+------------ -+Fix some small memory leaks in some unmount error paths. Fix major leak -+of cache pages in readpages causing multiple read oriented stress -+testcases (including fsx, and even large file copy) to fail over time. -+ -+Version 1.06 -+------------ -+Send NTCreateX with ATTR_POSIX if Linux/Unix extensions negotiated with server. -+This allows files that differ only in case and improves performance of file -+creation and file open to such servers. Fix semaphore conflict which causes -+slow delete of open file to Samba (which unfortunately can cause an oplock -+break to self while vfs_unlink held i_sem) which can hang for 20 seconds. -+ -+Version 1.05 -+------------ -+fixes to cifs_readpages for fsx test case -+ -+Version 1.04 -+------------ -+Fix caching data integrity bug when extending file size especially when no -+oplock on file. Fix spurious logging of valid already parsed mount options -+that are parsed outside of the cifs vfs such as nosuid. -+ -+ -+Version 1.03 -+------------ -+Connect to server when port number override not specified, and tcp port -+unitialized. Reset search to restart at correct file when kernel routine -+filldir returns error during large directory searches (readdir). -+ -+Version 1.02 -+------------ -+Fix caching problem when files opened by multiple clients in which -+page cache could contain stale data, and write through did -+not occur often enough while file was still open when read ahead -+(read oplock) not allowed. Treat "sep=" when first mount option -+as an overrride of comma as the default separator between mount -+options. -+ -+Version 1.01 -+------------ -+Allow passwords longer than 16 bytes. Allow null password string. -+ -+Version 1.00 -+------------ -+Gracefully clean up failed mounts when attempting to mount to servers such as -+Windows 98 that terminate tcp sessions during prototocol negotiation. Handle -+embedded commas in mount parsing of passwords. -+ -+Version 0.99 -+------------ -+Invalidate local inode cached pages on oplock break and when last file -+instance is closed so that the client does not continue using stale local -+copy rather than later modified server copy of file. Do not reconnect -+when server drops the tcp session prematurely before negotiate -+protocol response. Fix oops in roepen_file when dentry freed. Allow -+the support for CIFS Unix Extensions to be disabled via proc interface. -+ -+Version 0.98 -+------------ -+Fix hang in commit_write during reconnection of open files under heavy load. -+Fix unload_nls oops in a mount failure path. Serialize writes to same socket -+which also fixes any possible races when cifs signatures are enabled in SMBs -+being sent out of signature sequence number order. -+ -+Version 0.97 -+------------ -+Fix byte range locking bug (endian problem) causing bad offset and -+length. -+ -+Version 0.96 -+------------ -+Fix oops (in send_sig) caused by CIFS unmount code trying to -+wake up the demultiplex thread after it had exited. Do not log -+error on harmless oplock release of closed handle. -+ -+Version 0.95 -+------------ -+Fix unsafe global variable usage and password hash failure on gcc 3.3.1 -+Fix problem reconnecting secondary mounts to same server after session -+failure. Fix invalid dentry - race in mkdir when directory gets created -+by another client between the lookup and mkdir. -+ -+Version 0.94 -+------------ -+Fix to list processing in reopen_files. Fix reconnection when server hung -+but tcpip session still alive. Set proper timeout on socket read. -+ -+Version 0.93 -+------------ -+Add missing mount options including iocharset. SMP fixes in write and open. -+Fix errors in reconnecting after TCP session failure. Fix module unloading -+of default nls codepage -+ -+Version 0.92 -+------------ -+Active smb transactions should never go negative (fix double FreeXid). Fix -+list processing in file routines. Check return code on kmalloc in open. -+Fix spinlock usage for SMP. -+ -+Version 0.91 -+------------ -+Fix oops in reopen_files when invalid dentry. drop dentry on server rename -+and on revalidate errors. Fix cases where pid is now tgid. Fix return code -+on create hard link when server does not support them. -+ -+Version 0.90 -+------------ -+Fix scheduling while atomic error in getting inode info on newly created file. -+Fix truncate of existing files opened with O_CREAT but not O_TRUNC set. -+ -+Version 0.89 -+------------ -+Fix oops on write to dead tcp session. Remove error log write for case when file open -+O_CREAT but not O_EXCL -+ -+Version 0.88 -+------------ -+Fix non-POSIX behavior on rename of open file and delete of open file by taking -+advantage of trans2 SetFileInfo rename facility if available on target server. -+Retry on ENOSPC and EAGAIN socket errors. -+ -+Version 0.87 -+------------ -+Fix oops on big endian readdir. Set blksize to be even power of two (2**blkbits) to fix -+allocation size miscalculation. After oplock token lost do not read through -+cache. -+ -+Version 0.86 -+------------ -+Fix oops on empty file readahead. Fix for file size handling for locally cached files. -+ -+Version 0.85 -+------------ -+Fix oops in mkdir when server fails to return inode info. Fix oops in reopen_files -+during auto reconnection to server after server recovered from failure. -+ -+Version 0.84 -+------------ -+Finish support for Linux 2.5 open/create changes, which removes the -+redundant NTCreate/QPathInfo/close that was sent during file create. -+Enable oplock by default. Enable packet signing by default (needed to -+access many recent Windows servers) -+ -+Version 0.83 -+------------ -+Fix oops when mounting to long server names caused by inverted parms to kmalloc. -+Fix MultiuserMount (/proc/fs/cifs configuration setting) so that when enabled -+we will choose a cifs user session (smb uid) that better matches the local -+uid if a) the mount uid does not match the current uid and b) we have another -+session to the same server (ip address) for a different mount which -+matches the current local uid. -+ -+Version 0.82 -+------------ -+Add support for mknod of block or character devices. Fix oplock -+code (distributed caching) to properly send response to oplock -+break from server. -+ -+Version 0.81 -+------------ -+Finish up CIFS packet digital signing for the default -+NTLM security case. This should help Windows 2003 -+network interoperability since it is common for -+packet signing to be required now. Fix statfs (stat -f) -+which recently started returning errors due to -+invalid value (-1 instead of 0) being set in the -+struct kstatfs f_ffiles field. -+ -+Version 0.80 -+----------- -+Fix oops on stopping oplock thread when removing cifs when -+built as module. -+ -+Version 0.79 -+------------ -+Fix mount options for ro (readonly), uid, gid and file and directory mode. -+ -+Version 0.78 -+------------ -+Fix errors displayed on failed mounts to be more understandable. -+Fixed various incorrect or misleading smb to posix error code mappings. -+ -+Version 0.77 -+------------ -+Fix display of NTFS DFS junctions to display as symlinks. -+They are the network equivalent. Fix oops in -+cifs_partialpagewrite caused by missing spinlock protection -+of openfile linked list. Allow writebehind caching errors to -+be returned to the application at file close. -+ -+Version 0.76 -+------------ -+Clean up options displayed in /proc/mounts by show_options to -+be more consistent with other filesystems. -+ -+Version 0.75 -+------------ -+Fix delete of readonly file to Windows servers. Reflect -+presence or absence of read only dos attribute in mode -+bits for servers that do not support CIFS Unix extensions. -+Fix shortened results on readdir of large directories to -+servers supporting CIFS Unix extensions (caused by -+incorrect resume key). -+ -+Version 0.74 -+------------ -+Fix truncate bug (set file size) that could cause hangs e.g. running fsx -+ -+Version 0.73 -+------------ -+unload nls if mount fails. -+ -+Version 0.72 -+------------ -+Add resume key support to search (readdir) code to workaround -+Windows bug. Add /proc/fs/cifs/LookupCacheEnable which -+allows disabling caching of attribute information for -+lookups. -+ -+Version 0.71 -+------------ -+Add more oplock handling (distributed caching code). Remove -+dead code. Remove excessive stack space utilization from -+symlink routines. -+ -+Version 0.70 -+------------ -+Fix oops in get dfs referral (triggered when null path sent in to -+mount). Add support for overriding rsize at mount time. -+ -+Version 0.69 -+------------ -+Fix buffer overrun in readdir which caused intermittent kernel oopses. -+Fix writepage code to release kmap on write data. Allow "-ip=" new -+mount option to be passed in on parameter distinct from the first part -+(server name portion of) the UNC name. Allow override of the -+tcp port of the target server via new mount option "-port=" -+ -+Version 0.68 -+------------ -+Fix search handle leak on rewind. Fix setuid and gid so that they are -+reflected in the local inode immediately. Cleanup of whitespace -+to make 2.4 and 2.5 versions more consistent. -+ -+ -+Version 0.67 -+------------ -+Fix signal sending so that captive thread (cifsd) exits on umount -+(which was causing the warning in kmem_cache_free of the request buffers -+at rmmod time). This had broken as a sideeffect of the recent global -+kernel change to daemonize. Fix memory leak in readdir code which -+showed up in "ls -R" (and applications that did search rewinding). -+ -+Version 0.66 -+------------ -+Reconnect tids and fids after session reconnection (still do not -+reconnect byte range locks though). Fix problem caching -+lookup information for directory inodes, improving performance, -+especially in deep directory trees. Fix various build warnings. -+ -+Version 0.65 -+------------ -+Finish fixes to commit write for caching/readahead consistency. fsx -+now works to Samba servers. Fix oops caused when readahead -+was interrupted by a signal. -+ -+Version 0.64 -+------------ -+Fix data corruption (in partial page after truncate) that caused fsx to -+fail to Windows servers. Cleaned up some extraneous error logging in -+common error paths. Add generic sendfile support. -+ -+Version 0.63 -+------------ -+Fix memory leak in AllocMidQEntry. -+Finish reconnection logic, so connection with server can be dropped -+(or server rebooted) and the cifs client will reconnect. -+ -+Version 0.62 -+------------ -+Fix temporary socket leak when bad userid or password specified -+(or other SMBSessSetup failure). Increase maximum buffer size to slightly -+over 16K to allow negotiation of up to Samba and Windows server default read -+sizes. Add support for readpages -+ -+Version 0.61 -+------------ -+Fix oops when username not passed in on mount. Extensive fixes and improvements -+to error logging (strip redundant newlines, change debug macros to ensure newline -+passed in and to be more consistent). Fix writepage wrong file handle problem, -+a readonly file handle could be incorrectly used to attempt to write out -+file updates through the page cache to multiply open files. This could cause -+the iozone benchmark to fail on the fwrite test. Fix bug mounting two different -+shares to the same Windows server when using different usernames -+(doing this to Samba servers worked but Windows was rejecting it) - now it is -+possible to use different userids when connecting to the same server from a -+Linux client. Fix oops when treeDisconnect called during unmount on -+previously freed socket. -+ -+Version 0.60 -+------------ -+Fix oops in readpages caused by not setting address space operations in inode in -+rare code path. -+ -+Version 0.59 -+------------ -+Includes support for deleting of open files and renaming over existing files (per POSIX -+requirement). Add readlink support for Windows junction points (directory symlinks). -+ -+Version 0.58 -+------------ -+Changed read and write to go through pagecache. Added additional address space operations. -+Memory mapped operations now working. -+ -+Version 0.57 -+------------ -+Added writepage code for additional memory mapping support. Fixed leak in xids causing -+the simultaneous operations counter (/proc/fs/cifs/SimultaneousOps) to increase on -+every stat call. Additional formatting cleanup. -+ -+Version 0.56 -+------------ -+Fix bigendian bug in order of time conversion. Merge 2.5 to 2.4 version. Formatting cleanup. -+ -+Version 0.55 -+------------ -+Fixes from Zwane Mwaikambo for adding missing return code checking in a few places. -+Also included a modified version of his fix to protect global list manipulation of -+the smb session and tree connection and mid related global variables. -+ -+Version 0.54 -+------------ -+Fix problem with captive thread hanging around at unmount time. Adjust to 2.5.42-pre -+changes to superblock layout. Remove wasteful allocation of smb buffers (now the send -+buffer is reused for responses). Add more oplock handling. Additional minor cleanup. -+ -+Version 0.53 -+------------ -+More stylistic updates to better match kernel style. Add additional statistics -+for filesystem which can be viewed via /proc/fs/cifs. Add more pieces of NTLMv2 -+and CIFS Packet Signing enablement. -+ -+Version 0.52 -+------------ -+Replace call to sleep_on with safer wait_on_event. -+Make stylistic changes to better match kernel style recommendations. -+Remove most typedef usage (except for the PDUs themselves). -+ -+Version 0.51 -+------------ -+Update mount so the -unc mount option is no longer required (the ip address can be specified -+in a UNC style device name. Implementation of readpage/writepage started. -+ -+Version 0.50 -+------------ -+Fix intermittent problem with incorrect smb header checking on badly -+fragmented tcp responses -+ -+Version 0.49 -+------------ -+Fixes to setting of allocation size and file size. -+ -+Version 0.48 -+------------ -+Various 2.5.38 fixes. Now works on 2.5.38 -+ -+Version 0.47 -+------------ -+Prepare for 2.5 kernel merge. Remove ifdefs. -+ -+Version 0.46 -+------------ -+Socket buffer management fixes. Fix dual free. -+ -+Version 0.45 -+------------ -+Various big endian fixes for hardlinks and symlinks and also for dfs. -+ -+Version 0.44 -+------------ -+Various big endian fixes for servers with Unix extensions such as Samba -+ -+Version 0.43 -+------------ -+Various FindNext fixes for incorrect filenames on large directory searches on big endian -+clients. basic posix file i/o tests now work on big endian machines, not just le -+ -+Version 0.42 -+------------ -+SessionSetup and NegotiateProtocol now work from Big Endian machines. -+Various Big Endian fixes found during testing on the Linux on 390. Various fixes for compatibility with older -+versions of 2.4 kernel (now builds and works again on kernels at least as early as 2.4.7). -+ -+Version 0.41 -+------------ -+Various minor fixes for Connectathon Posix "basic" file i/o test suite. Directory caching fixed so hardlinked -+files now return the correct rumber of links on fstat as they are repeatedly linked and unlinked. -+ -+Version 0.40 -+------------ -+Implemented "Raw" (i.e. not encapsulated in SPNEGO) NTLMSSP (i.e. the Security Provider Interface used to negotiate -+session advanced session authentication). Raw NTLMSSP is preferred by Windows 2000 Professional and Windows XP. -+Began implementing support for SPNEGO encapsulation of NTLMSSP based session authentication blobs -+(which is the mechanism preferred by Windows 2000 server in the absence of Kerberos). -+ -+Version 0.38 -+------------ -+Introduced optional mount helper utility mount.cifs and made coreq changes to cifs vfs to enable -+it. Fixed a few bugs in the DFS code (e.g. bcc two bytes too short and incorrect uid in PDU). -+ -+Version 0.37 -+------------ -+Rewrote much of connection and mount/unmount logic to handle bugs with -+multiple uses to same share, multiple users to same server etc. -+ -+Version 0.36 -+------------ -+Fixed major problem with dentry corruption (missing call to dput) -+ -+Version 0.35 -+------------ -+Rewrite of readdir code to fix bug. Various fixes for bigendian machines. -+Begin adding oplock support. Multiusermount and oplockEnabled flags added to /proc/fs/cifs -+although corresponding function not fully implemented in the vfs yet -+ -+Version 0.34 -+------------ -+Fixed dentry caching bug, misc. cleanup -+ -+Version 0.33 -+------------ -+Fixed 2.5 support to handle build and configure changes as well as misc. 2.5 changes. Now can build -+on current 2.5 beta version (2.5.24) of the Linux kernel as well as on 2.4 Linux kernels. -+Support for STATUS codes (newer 32 bit NT error codes) added. DFS support begun to be added. -+ -+Version 0.32 -+------------ -+Unix extensions (symlink, readlink, hardlink, chmod and some chgrp and chown) implemented -+and tested against Samba 2.2.5 -+ -+ -+Version 0.31 -+------------ -+1) Fixed lockrange to be correct (it was one byte too short) -+ -+2) Fixed GETLK (i.e. the fcntl call to test a range of bytes in a file to see if locked) to correctly -+show range as locked when there is a conflict with an existing lock. -+ -+3) default file perms are now 2767 (indicating support for mandatory locks) instead of 777 for directories -+in most cases. Eventually will offer optional ability to query server for the correct perms. -+ -+3) Fixed eventual trap when mounting twice to different shares on the same server when the first succeeded -+but the second one was invalid and failed (the second one was incorrectly disconnecting the tcp and smb -+session) -+ -+4) Fixed error logging of valid mount options -+ -+5) Removed logging of password field. -+ -+6) Moved negotiate, treeDisconnect and uloggoffX (only tConx and SessSetup remain in connect.c) to cifssmb.c -+and cleaned them up and made them more consistent with other cifs functions. -+ -+7) Server support for Unix extensions is now fully detected and FindFirst is implemented both ways -+(with or without Unix exentions) but FindNext and QueryPathInfo with the Unix extensions are not completed, -+nor is the symlink support using the Unix extensions -+ -+8) Started adding the readlink and follow_link code -+ -+Version 0.3 -+----------- -+Initial drop -+ ---- /dev/null -+++ b/fs/cifs/cifs_debug.c -@@ -0,0 +1,797 @@ -+/* -+ * fs/cifs_debug.c -+ * -+ * Copyright (C) International Business Machines Corp., 2000,2003 -+ * -+ * Modified by Steve French (sfrench@us.ibm.com) -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; 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 -+ */ -+#include <linux/fs.h> -+#include <linux/string.h> -+#include <linux/ctype.h> -+#include <linux/module.h> -+#include <linux/proc_fs.h> -+#include <asm/uaccess.h> -+#include "cifspdu.h" -+#include "cifsglob.h" -+#include "cifsproto.h" -+#include "cifs_debug.h" -+ -+void -+cifs_dump_mem(char *label, void *data, int length) -+{ -+ int i, j; -+ int *intptr = data; -+ char *charptr = data; -+ char buf[10], line[80]; -+ -+ printk(KERN_DEBUG "%s: dump of %d bytes of data at 0x%p\n\n", -+ label, length, data); -+ for (i = 0; i < length; i += 16) { -+ line[0] = 0; -+ for (j = 0; (j < 4) && (i + j * 4 < length); j++) { -+ sprintf(buf, " %08x", intptr[i / 4 + j]); -+ strcat(line, buf); -+ } -+ buf[0] = ' '; -+ buf[2] = 0; -+ for (j = 0; (j < 16) && (i + j < length); j++) { -+ buf[1] = isprint(charptr[i + j]) ? charptr[i + j] : '.'; -+ strcat(line, buf); -+ } -+ printk(KERN_DEBUG "%s\n", line); -+ } -+} -+ -+#ifdef CONFIG_PROC_FS -+int -+cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset, -+ int count, int *eof, void *data) -+{ -+ struct list_head *tmp; -+ struct list_head *tmp1; -+ struct mid_q_entry * mid_entry; -+ struct cifsSesInfo *ses; -+ struct cifsTconInfo *tcon; -+ int i; -+ int length = 0; -+ char * original_buf = buf; -+ -+ *beginBuffer = buf + offset; -+ -+ -+ length = -+ sprintf(buf, -+ "Display Internal CIFS Data Structures for Debugging\n" -+ "---------------------------------------------------\n"); -+ buf += length; -+ -+ length = sprintf(buf, "Servers:\n"); -+ buf += length; -+ -+ i = 0; -+ read_lock(&GlobalSMBSeslock); -+ list_for_each(tmp, &GlobalSMBSessionList) { -+ i++; -+ ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); -+ length = -+ sprintf(buf, -+ "\n%d) Name: %s Domain: %s Mounts: %d ServerOS: %s \n\tServerNOS: %s\tCapabilities: 0x%x\n\tSMB session status: %d\tTCP status: %d", -+ i, ses->serverName, ses->serverDomain, atomic_read(&ses->inUse), -+ ses->serverOS, ses->serverNOS, ses->capabilities,ses->status,ses->server->tcpStatus); -+ buf += length; -+ if(ses->server) { -+ buf += sprintf(buf, "\n\tLocal Users To Server: %d SecMode: 0x%x Req Active: %d", -+ atomic_read(&ses->server->socketUseCount), -+ ses->server->secMode, -+ atomic_read(&ses->server->inFlight)); -+ -+ length = sprintf(buf, "\nMIDs: \n"); -+ buf += length; -+ -+ spin_lock(&GlobalMid_Lock); -+ list_for_each(tmp1, &ses->server->pending_mid_q) { -+ mid_entry = list_entry(tmp1, struct -+ mid_q_entry, -+ qhead); -+ if(mid_entry) { -+ length = sprintf(buf,"State: %d com: %d pid: %d tsk: %p mid %d\n",mid_entry->midState,mid_entry->command,mid_entry->pid,mid_entry->tsk,mid_entry->mid); -+ buf += length; -+ } -+ } -+ spin_unlock(&GlobalMid_Lock); -+ } -+ -+ } -+ read_unlock(&GlobalSMBSeslock); -+ sprintf(buf, "\n"); -+ buf++; -+ -+ length = sprintf(buf, "\nShares:\n"); -+ buf += length; -+ -+ i = 0; -+ read_lock(&GlobalSMBSeslock); -+ list_for_each(tmp, &GlobalTreeConnectionList) { -+ i++; -+ tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); -+ length = -+ sprintf(buf, -+ "\n%d) %s Uses: %d Type: %s Characteristics: 0x%x Attributes: 0x%x\nPathComponentMax: %d Status: %d", -+ i, tcon->treeName, -+ atomic_read(&tcon->useCount), -+ tcon->nativeFileSystem, -+ tcon->fsDevInfo.DeviceCharacteristics, -+ tcon->fsAttrInfo.Attributes, -+ tcon->fsAttrInfo.MaxPathNameComponentLength,tcon->tidStatus); -+ buf += length; -+ if (tcon->fsDevInfo.DeviceType == FILE_DEVICE_DISK) -+ length = sprintf(buf, " type: DISK "); -+ else if (tcon->fsDevInfo.DeviceType == FILE_DEVICE_CD_ROM) -+ length = sprintf(buf, " type: CDROM "); -+ else -+ length = -+ sprintf(buf, " type: %d ", -+ tcon->fsDevInfo.DeviceType); -+ buf += length; -+ if(tcon->tidStatus == CifsNeedReconnect) { -+ buf += sprintf(buf, "\tDISCONNECTED "); -+ length += 14; -+ } -+ } -+ read_unlock(&GlobalSMBSeslock); -+ -+ length = sprintf(buf, "\n"); -+ buf += length; -+ -+ /* BB add code to dump additional info such as TCP session info now */ -+ /* Now calculate total size of returned data */ -+ length = buf - original_buf; -+ -+ if(offset + count >= length) -+ *eof = 1; -+ if(length < offset) { -+ *eof = 1; -+ return 0; -+ } else { -+ length = length - offset; -+ } -+ if (length > count) -+ length = count; -+ -+ return length; -+} -+ -+#ifdef CONFIG_CIFS_STATS -+int -+cifs_stats_read(char *buf, char **beginBuffer, off_t offset, -+ int count, int *eof, void *data) -+{ -+ int item_length,i,length; -+ struct list_head *tmp; -+ struct cifsTconInfo *tcon; -+ -+ *beginBuffer = buf + offset; -+ -+ length = sprintf(buf, -+ "Resources in use\nCIFS Session: %d\n", -+ sesInfoAllocCount.counter); -+ buf += length; -+ item_length = -+ sprintf(buf,"Share (unique mount targets): %d\n", -+ tconInfoAllocCount.counter); -+ length += item_length; -+ buf += item_length; -+ item_length = -+ sprintf(buf,"SMB Request/Response Buffer: %d\n", -+ bufAllocCount.counter); -+ length += item_length; -+ buf += item_length; -+ item_length = -+ sprintf(buf,"Operations (MIDs): %d\n", -+ midCount.counter); -+ length += item_length; -+ buf += item_length; -+ item_length = sprintf(buf, -+ "\n%d session %d share reconnects\n", -+ tcpSesReconnectCount.counter,tconInfoReconnectCount.counter); -+ length += item_length; -+ buf += item_length; -+ -+ item_length = sprintf(buf, -+ "Total vfs operations: %d maximum at one time: %d\n", -+ GlobalCurrentXid,GlobalMaxActiveXid); -+ length += item_length; -+ buf += item_length; -+ -+ i = 0; -+ read_lock(&GlobalSMBSeslock); -+ list_for_each(tmp, &GlobalTreeConnectionList) { -+ i++; -+ tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); -+ item_length = sprintf(buf,"\n%d) %s",i, tcon->treeName); -+ buf += item_length; -+ length += item_length; -+ if(tcon->tidStatus == CifsNeedReconnect) { -+ buf += sprintf(buf, "\tDISCONNECTED "); -+ length += 14; -+ } -+ item_length = sprintf(buf,"\nSMBs: %d Oplock Breaks: %d", -+ atomic_read(&tcon->num_smbs_sent), -+ atomic_read(&tcon->num_oplock_brks)); -+ buf += item_length; -+ length += item_length; -+ item_length = sprintf(buf,"\nReads: %d Bytes %lld", -+ atomic_read(&tcon->num_reads), -+ (long long)(tcon->bytes_read)); -+ buf += item_length; -+ length += item_length; -+ item_length = sprintf(buf,"\nWrites: %d Bytes: %lld", -+ atomic_read(&tcon->num_writes), -+ (long long)(tcon->bytes_written)); -+ buf += item_length; -+ length += item_length; -+ item_length = sprintf(buf, -+ "\nOpens: %d Deletes: %d\nMkdirs: %d Rmdirs: %d", -+ atomic_read(&tcon->num_opens), -+ atomic_read(&tcon->num_deletes), -+ atomic_read(&tcon->num_mkdirs), -+ atomic_read(&tcon->num_rmdirs)); -+ buf += item_length; -+ length += item_length; -+ item_length = sprintf(buf, -+ "\nRenames: %d T2 Renames %d", -+ atomic_read(&tcon->num_renames), -+ atomic_read(&tcon->num_t2renames)); -+ buf += item_length; -+ length += item_length; -+ } -+ read_unlock(&GlobalSMBSeslock); -+ -+ buf += sprintf(buf,"\n"); -+ length++; -+ -+ if(offset + count >= length) -+ *eof = 1; -+ if(length < offset) { -+ *eof = 1; -+ return 0; -+ } else { -+ length = length - offset; -+ } -+ if (length > count) -+ length = count; -+ -+ return length; -+} -+#endif -+ -+struct proc_dir_entry *proc_fs_cifs; -+read_proc_t cifs_txanchor_read; -+static read_proc_t cifsFYI_read; -+static write_proc_t cifsFYI_write; -+static read_proc_t oplockEnabled_read; -+static write_proc_t oplockEnabled_write; -+static read_proc_t lookupFlag_read; -+static write_proc_t lookupFlag_write; -+static read_proc_t traceSMB_read; -+static write_proc_t traceSMB_write; -+static read_proc_t multiuser_mount_read; -+static write_proc_t multiuser_mount_write; -+static read_proc_t extended_security_read; -+static write_proc_t extended_security_write; -+static read_proc_t ntlmv2_enabled_read; -+static write_proc_t ntlmv2_enabled_write; -+static read_proc_t packet_signing_enabled_read; -+static write_proc_t packet_signing_enabled_write; -+static read_proc_t quotaEnabled_read; -+static write_proc_t quotaEnabled_write; -+static read_proc_t linuxExtensionsEnabled_read; -+static write_proc_t linuxExtensionsEnabled_write; -+ -+void -+cifs_proc_init(void) -+{ -+ struct proc_dir_entry *pde; -+ -+ proc_fs_cifs = proc_mkdir("cifs", proc_root_fs); -+ if (proc_fs_cifs == NULL) -+ return; -+ -+ proc_fs_cifs->owner = THIS_MODULE; -+ create_proc_read_entry("DebugData", 0, proc_fs_cifs, -+ cifs_debug_data_read, NULL); -+ -+#ifdef CONFIG_CIFS_STATS -+ create_proc_read_entry("Stats", 0, proc_fs_cifs, -+ cifs_stats_read, NULL); -+#endif -+ pde = create_proc_read_entry("cifsFYI", 0, proc_fs_cifs, -+ cifsFYI_read, NULL); -+ if (pde) -+ pde->write_proc = cifsFYI_write; -+ -+ pde = -+ create_proc_read_entry("traceSMB", 0, proc_fs_cifs, -+ traceSMB_read, NULL); -+ if (pde) -+ pde->write_proc = traceSMB_write; -+ -+ pde = create_proc_read_entry("OplockEnabled", 0, proc_fs_cifs, -+ oplockEnabled_read, NULL); -+ if (pde) -+ pde->write_proc = oplockEnabled_write; -+ -+ pde = create_proc_read_entry("QuotaEnabled", 0, proc_fs_cifs, -+ quotaEnabled_read, NULL); -+ if (pde) -+ pde->write_proc = quotaEnabled_write; -+ -+ pde = create_proc_read_entry("LinuxExtensionsEnabled", 0, proc_fs_cifs, -+ linuxExtensionsEnabled_read, NULL); -+ if (pde) -+ pde->write_proc = linuxExtensionsEnabled_write; -+ -+ pde = -+ create_proc_read_entry("MultiuserMount", 0, proc_fs_cifs, -+ multiuser_mount_read, NULL); -+ if (pde) -+ pde->write_proc = multiuser_mount_write; -+ -+ pde = -+ create_proc_read_entry("ExtendedSecurity", 0, proc_fs_cifs, -+ extended_security_read, NULL); -+ if (pde) -+ pde->write_proc = extended_security_write; -+ -+ pde = -+ create_proc_read_entry("LookupCacheEnabled", 0, proc_fs_cifs, -+ lookupFlag_read, NULL); -+ if (pde) -+ pde->write_proc = lookupFlag_write; -+ -+ pde = -+ create_proc_read_entry("NTLMV2Enabled", 0, proc_fs_cifs, -+ ntlmv2_enabled_read, NULL); -+ if (pde) -+ pde->write_proc = ntlmv2_enabled_write; -+ -+ pde = -+ create_proc_read_entry("PacketSigningEnabled", 0, proc_fs_cifs, -+ packet_signing_enabled_read, NULL); -+ if (pde) -+ pde->write_proc = packet_signing_enabled_write; -+} -+ -+void -+cifs_proc_clean(void) -+{ -+ if (proc_fs_cifs == NULL) -+ return; -+ -+ remove_proc_entry("DebugData", proc_fs_cifs); -+ remove_proc_entry("cifsFYI", proc_fs_cifs); -+ remove_proc_entry("traceSMB", proc_fs_cifs); -+#ifdef CONFIG_CIFS_STATS -+ remove_proc_entry("Stats", proc_fs_cifs); -+#endif -+ remove_proc_entry("MultiuserMount", proc_fs_cifs); -+ remove_proc_entry("OplockEnabled", proc_fs_cifs); -+ remove_proc_entry("NTLMV2Enabled",proc_fs_cifs); -+ remove_proc_entry("ExtendedSecurity",proc_fs_cifs); -+ remove_proc_entry("PacketSigningEnabled",proc_fs_cifs); -+ remove_proc_entry("LinuxExtensionsEnabled",proc_fs_cifs); -+ remove_proc_entry("QuotaEnabled",proc_fs_cifs); -+ remove_proc_entry("LookupCacheEnabled",proc_fs_cifs); -+ remove_proc_entry("cifs", proc_root_fs); -+} -+ -+static int -+cifsFYI_read(char *page, char **start, off_t off, int count, -+ int *eof, void *data) -+{ -+ int len; -+ -+ len = sprintf(page, "%d\n", cifsFYI); -+ -+ len -= off; -+ *start = page + off; -+ -+ if (len > count) -+ len = count; -+ else -+ *eof = 1; -+ -+ if (len < 0) -+ len = 0; -+ -+ return len; -+} -+static int -+cifsFYI_write(struct file *file, const char *buffer, -+ unsigned long count, void *data) -+{ -+ char c; -+ int rc; -+ -+ rc = get_user(c, buffer); -+ if (rc) -+ return rc; -+ if (c == '0' || c == 'n' || c == 'N') -+ cifsFYI = 0; -+ else if (c == '1' || c == 'y' || c == 'Y') -+ cifsFYI = 1; -+ -+ return count; -+} -+ -+static int -+oplockEnabled_read(char *page, char **start, off_t off, -+ int count, int *eof, void *data) -+{ -+ int len; -+ -+ len = sprintf(page, "%d\n", oplockEnabled); -+ -+ len -= off; -+ *start = page + off; -+ -+ if (len > count) -+ len = count; -+ else -+ *eof = 1; -+ -+ if (len < 0) -+ len = 0; -+ -+ return len; -+} -+static int -+oplockEnabled_write(struct file *file, const char *buffer, -+ unsigned long count, void *data) -+{ -+ char c; -+ int rc; -+ -+ rc = get_user(c, buffer); -+ if (rc) -+ return rc; -+ if (c == '0' || c == 'n' || c == 'N') -+ oplockEnabled = 0; -+ else if (c == '1' || c == 'y' || c == 'Y') -+ oplockEnabled = 1; -+ -+ return count; -+} -+ -+static int -+quotaEnabled_read(char *page, char **start, off_t off, -+ int count, int *eof, void *data) -+{ -+ int len; -+ -+ len = sprintf(page, "%d\n", quotaEnabled); -+/* could also check if quotas are enabled in kernel -+ as a whole first */ -+ len -= off; -+ *start = page + off; -+ -+ if (len > count) -+ len = count; -+ else -+ *eof = 1; -+ -+ if (len < 0) -+ len = 0; -+ -+ return len; -+} -+static int -+quotaEnabled_write(struct file *file, const char *buffer, -+ unsigned long count, void *data) -+{ -+ char c; -+ int rc; -+ -+ rc = get_user(c, buffer); -+ if (rc) -+ return rc; -+ if (c == '0' || c == 'n' || c == 'N') -+ quotaEnabled = 0; -+ else if (c == '1' || c == 'y' || c == 'Y') -+ quotaEnabled = 1; -+ -+ return count; -+} -+ -+static int -+linuxExtensionsEnabled_read(char *page, char **start, off_t off, -+ int count, int *eof, void *data) -+{ -+ int len; -+ -+ len = sprintf(page, "%d\n", linuxExtEnabled); -+/* could also check if quotas are enabled in kernel -+ as a whole first */ -+ len -= off; -+ *start = page + off; -+ -+ if (len > count) -+ len = count; -+ else -+ *eof = 1; -+ -+ if (len < 0) -+ len = 0; -+ -+ return len; -+} -+static int -+linuxExtensionsEnabled_write(struct file *file, const char *buffer, -+ unsigned long count, void *data) -+{ -+ char c; -+ int rc; -+ -+ rc = get_user(c, buffer); -+ if (rc) -+ return rc; -+ if (c == '0' || c == 'n' || c == 'N') -+ linuxExtEnabled = 0; -+ else if (c == '1' || c == 'y' || c == 'Y') -+ linuxExtEnabled = 1; -+ -+ return count; -+} -+ -+ -+static int -+lookupFlag_read(char *page, char **start, off_t off, -+ int count, int *eof, void *data) -+{ -+ int len; -+ -+ len = sprintf(page, "%d\n", lookupCacheEnabled); -+ -+ len -= off; -+ *start = page + off; -+ -+ if (len > count) -+ len = count; -+ else -+ *eof = 1; -+ -+ if (len < 0) -+ len = 0; -+ -+ return len; -+} -+static int -+lookupFlag_write(struct file *file, const char *buffer, -+ unsigned long count, void *data) -+{ -+ char c; -+ int rc; -+ -+ rc = get_user(c, buffer); -+ if (rc) -+ return rc; -+ if (c == '0' || c == 'n' || c == 'N') -+ lookupCacheEnabled = 0; -+ else if (c == '1' || c == 'y' || c == 'Y') -+ lookupCacheEnabled = 1; -+ -+ return count; -+} -+static int -+traceSMB_read(char *page, char **start, off_t off, int count, -+ int *eof, void *data) -+{ -+ int len; -+ -+ len = sprintf(page, "%d\n", traceSMB); -+ -+ len -= off; -+ *start = page + off; -+ -+ if (len > count) -+ len = count; -+ else -+ *eof = 1; -+ -+ if (len < 0) -+ len = 0; -+ -+ return len; -+} -+static int -+traceSMB_write(struct file *file, const char *buffer, -+ unsigned long count, void *data) -+{ -+ char c; -+ int rc; -+ -+ rc = get_user(c, buffer); -+ if (rc) -+ return rc; -+ if (c == '0' || c == 'n' || c == 'N') -+ traceSMB = 0; -+ else if (c == '1' || c == 'y' || c == 'Y') -+ traceSMB = 1; -+ -+ return count; -+} -+ -+static int -+multiuser_mount_read(char *page, char **start, off_t off, -+ int count, int *eof, void *data) -+{ -+ int len; -+ -+ len = sprintf(page, "%d\n", multiuser_mount); -+ -+ len -= off; -+ *start = page + off; -+ -+ if (len > count) -+ len = count; -+ else -+ *eof = 1; -+ -+ if (len < 0) -+ len = 0; -+ -+ return len; -+} -+static int -+multiuser_mount_write(struct file *file, const char *buffer, -+ unsigned long count, void *data) -+{ -+ char c; -+ int rc; -+ -+ rc = get_user(c, buffer); -+ if (rc) -+ return rc; -+ if (c == '0' || c == 'n' || c == 'N') -+ multiuser_mount = 0; -+ else if (c == '1' || c == 'y' || c == 'Y') -+ multiuser_mount = 1; -+ -+ return count; -+} -+ -+static int -+extended_security_read(char *page, char **start, off_t off, -+ int count, int *eof, void *data) -+{ -+ int len; -+ -+ len = sprintf(page, "%d\n", extended_security); -+ -+ len -= off; -+ *start = page + off; -+ -+ if (len > count) -+ len = count; -+ else -+ *eof = 1; -+ -+ if (len < 0) -+ len = 0; -+ -+ return len; -+} -+static int -+extended_security_write(struct file *file, const char *buffer, -+ unsigned long count, void *data) -+{ -+ char c; -+ int rc; -+ -+ rc = get_user(c, buffer); -+ if (rc) -+ return rc; -+ if (c == '0' || c == 'n' || c == 'N') -+ extended_security = 0; -+ else if (c == '1' || c == 'y' || c == 'Y') -+ extended_security = 1; -+ -+ return count; -+} -+ -+static int -+ntlmv2_enabled_read(char *page, char **start, off_t off, -+ int count, int *eof, void *data) -+{ -+ int len; -+ -+ len = sprintf(page, "%d\n", ntlmv2_support); -+ -+ len -= off; -+ *start = page + off; -+ -+ if (len > count) -+ len = count; -+ else -+ *eof = 1; -+ -+ if (len < 0) -+ len = 0; -+ -+ return len; -+} -+static int -+ntlmv2_enabled_write(struct file *file, const char *buffer, -+ unsigned long count, void *data) -+{ -+ char c; -+ int rc; -+ -+ rc = get_user(c, buffer); -+ if (rc) -+ return rc; -+ if (c == '0' || c == 'n' || c == 'N') -+ ntlmv2_support = 0; -+ else if (c == '1' || c == 'y' || c == 'Y') -+ ntlmv2_support = 1; -+ -+ return count; -+} -+ -+static int -+packet_signing_enabled_read(char *page, char **start, off_t off, -+ int count, int *eof, void *data) -+{ -+ int len; -+ -+ len = sprintf(page, "%d\n", sign_CIFS_PDUs); -+ -+ len -= off; -+ *start = page + off; -+ -+ if (len > count) -+ len = count; -+ else -+ *eof = 1; -+ -+ if (len < 0) -+ len = 0; -+ -+ return len; -+} -+static int -+packet_signing_enabled_write(struct file *file, const char *buffer, -+ unsigned long count, void *data) -+{ -+ char c; -+ int rc; -+ -+ rc = get_user(c, buffer); -+ if (rc) -+ return rc; -+ if (c == '0' || c == 'n' || c == 'N') -+ sign_CIFS_PDUs = 0; -+ else if (c == '1' || c == 'y' || c == 'Y') -+ sign_CIFS_PDUs = 1; -+ else if (c == '2') -+ sign_CIFS_PDUs = 2; -+ -+ return count; -+} -+ -+ -+#endif ---- /dev/null -+++ b/fs/cifs/cifs_debug.h -@@ -0,0 +1,66 @@ -+/* -+ * -+ * Copyright (c) International Business Machines Corp., 2000,2002 -+ * Modified by Steve French (sfrench@us.ibm.com) -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; 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 -+ * -+*/ -+#define CIFS_DEBUG /* BB temporary */ -+ -+#ifndef _H_CIFS_DEBUG -+#define _H_CIFS_DEBUG -+ -+void cifs_dump_mem(char *label, void *data, int length); -+extern int traceSMB; /* flag which enables the function below */ -+void dump_smb(struct smb_hdr *, int); -+ -+/* -+ * debug ON -+ * -------- -+ */ -+#ifdef CIFS_DEBUG -+ -+ -+/* information message: e.g., configuration, major event */ -+extern int cifsFYI; -+#define cifsfyi(format,arg...) if (cifsFYI) printk(KERN_DEBUG " " __FILE__ ": " format "\n" "" , ## arg) -+ -+#define cFYI(button,prspec) if (button) cifsfyi prspec -+ -+#define cifswarn(format, arg...) printk(KERN_WARNING ": " format "\n" , ## arg) -+ -+/* debug event message: */ -+extern int cifsERROR; -+ -+#define cEVENT(format,arg...) if (cifsERROR) printk(KERN_EVENT __FILE__ ": " format "\n" , ## arg) -+ -+/* error event message: e.g., i/o error */ -+#define cifserror(format,arg...) if (cifsERROR) printk(KERN_ERR " CIFS VFS: " format "\n" "" , ## arg) -+ -+#define cERROR(button, prspec) if (button) cifserror prspec -+ -+/* -+ * debug OFF -+ * --------- -+ */ -+#else /* _CIFS_DEBUG */ -+#define cERROR(button,prspec) -+#define cEVENT(format,arg...) -+#define cFYI(button, prspec) -+#define cifserror(format,arg...) -+#endif /* _CIFS_DEBUG */ -+ -+#endif /* _H_CIFS_DEBUG */ ---- /dev/null -+++ b/fs/cifs/cifsencrypt.c -@@ -0,0 +1,204 @@ -+/* -+ * fs/cifs/cifsencrypt.c -+ * -+ * Copyright (C) International Business Machines Corp., 2003 -+ * Author(s): Steve French (sfrench@us.ibm.com) -+ * -+ * This library is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU Lesser General Public License as published -+ * by the Free Software Foundation; either version 2.1 of the License, or -+ * (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -+ * the GNU Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public License -+ * along with this library; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ */ -+ -+#include <linux/fs.h> -+#include "cifspdu.h" -+#include "cifsglob.h" -+#include "cifs_debug.h" -+#include "md5.h" -+#include "cifs_unicode.h" -+ -+/* Calculate and return the CIFS signature based on the mac key and the smb pdu */ -+/* the 16 byte signature must be allocated by the caller */ -+/* Note we only use the 1st eight bytes */ -+/* Note that the smb header signature field on input contains the -+ sequence number before this function is called */ -+ -+extern void mdfour(unsigned char *out, unsigned char *in, int n); -+extern void E_md4hash(const unsigned char *passwd, unsigned char *p16); -+ -+static int cifs_calculate_signature(const struct smb_hdr * cifs_pdu, const char * key, char * signature) -+{ -+ struct MD5Context context; -+ -+ if((cifs_pdu == NULL) || (signature == NULL)) -+ return -EINVAL; -+ -+ MD5Init(&context); -+ MD5Update(&context,key,CIFS_SESSION_KEY_SIZE+16); -+ MD5Update(&context,cifs_pdu->Protocol,cifs_pdu->smb_buf_length); -+ MD5Final(signature,&context); -+ return 0; -+} -+ -+int cifs_sign_smb(struct smb_hdr * cifs_pdu, struct cifsSesInfo * ses, -+ __u32 * pexpected_response_sequence_number) -+{ -+ int rc = 0; -+ char smb_signature[20]; -+ -+ /* BB remember to initialize sequence number elsewhere and initialize mac_signing key elsewhere BB */ -+ /* BB remember to add code to save expected sequence number in midQ entry BB */ -+ -+ if((cifs_pdu == NULL) || (ses == NULL)) -+ return -EINVAL; -+ -+ if((le32_to_cpu(cifs_pdu->Flags2) & SMBFLG2_SECURITY_SIGNATURE) == 0) -+ return rc; -+ -+ spin_lock(&GlobalMid_Lock); -+ cifs_pdu->Signature.Sequence.SequenceNumber = cpu_to_le32(ses->sequence_number); -+ cifs_pdu->Signature.Sequence.Reserved = 0; -+ -+ *pexpected_response_sequence_number = ses->sequence_number++; -+ ses->sequence_number++; -+ spin_unlock(&GlobalMid_Lock); -+ -+ rc = cifs_calculate_signature(cifs_pdu, ses->mac_signing_key,smb_signature); -+ if(rc) -+ memset(cifs_pdu->Signature.SecuritySignature, 0, 8); -+ else -+ memcpy(cifs_pdu->Signature.SecuritySignature, smb_signature, 8); -+ -+ return rc; -+} -+ -+int cifs_verify_signature(struct smb_hdr * cifs_pdu, const char * mac_key, -+ __u32 expected_sequence_number) -+{ -+ unsigned int rc; -+ char server_response_sig[8]; -+ char what_we_think_sig_should_be[20]; -+ -+ if((cifs_pdu == NULL) || (mac_key == NULL)) -+ return -EINVAL; -+ -+ if (cifs_pdu->Command == SMB_COM_NEGOTIATE) -+ return 0; -+ -+ if (cifs_pdu->Command == SMB_COM_LOCKING_ANDX) { -+ struct smb_com_lock_req * pSMB = (struct smb_com_lock_req *)cifs_pdu; -+ if(pSMB->LockType & LOCKING_ANDX_OPLOCK_RELEASE) -+ return 0; -+ } -+ -+ /* BB what if signatures are supposed to be on for session but server does not -+ send one? BB */ -+ -+ /* Do not need to verify session setups with signature "BSRSPYL " */ -+ if(memcmp(cifs_pdu->Signature.SecuritySignature,"BSRSPYL ",8)==0) -+ cFYI(1,("dummy signature received for smb command 0x%x",cifs_pdu->Command)); -+ -+ expected_sequence_number = cpu_to_le32(expected_sequence_number); -+ -+ /* save off the origiginal signature so we can modify the smb and check -+ its signature against what the server sent */ -+ memcpy(server_response_sig,cifs_pdu->Signature.SecuritySignature,8); -+ -+ cifs_pdu->Signature.Sequence.SequenceNumber = expected_sequence_number; -+ cifs_pdu->Signature.Sequence.Reserved = 0; -+ -+ rc = cifs_calculate_signature(cifs_pdu, mac_key, -+ what_we_think_sig_should_be); -+ -+ if(rc) -+ return rc; -+ -+ -+/* cifs_dump_mem("what we think it should be: ",what_we_think_sig_should_be,16); */ -+ -+ if(memcmp(server_response_sig, what_we_think_sig_should_be, 8)) -+ return -EACCES; -+ else -+ return 0; -+ -+} -+ -+/* We fill in key by putting in 40 byte array which was allocated by caller */ -+int cifs_calculate_mac_key(char * key, const char * rn, const char * password) -+{ -+ char temp_key[16]; -+ if ((key == NULL) || (rn == NULL)) -+ return -EINVAL; -+ -+ E_md4hash(password, temp_key); -+ mdfour(key,temp_key,16); -+ memcpy(key+16,rn, CIFS_SESSION_KEY_SIZE); -+ return 0; -+} -+ -+int CalcNTLMv2_partial_mac_key(struct cifsSesInfo * ses, struct nls_table * nls_info) -+{ -+ char temp_hash[16]; -+ struct HMACMD5Context ctx; -+ char * ucase_buf; -+ wchar_t * unicode_buf; -+ unsigned int i,user_name_len,dom_name_len; -+ -+ if(ses) -+ return -EINVAL; -+ -+ E_md4hash(ses->password, temp_hash); -+ -+ hmac_md5_init_limK_to_64(temp_hash, 16, &ctx); -+ user_name_len = strlen(ses->userName); -+ if(user_name_len > MAX_USERNAME_SIZE) -+ return -EINVAL; -+ dom_name_len = strlen(ses->domainName); -+ if(dom_name_len > MAX_USERNAME_SIZE) -+ return -EINVAL; -+ -+ ucase_buf = kmalloc((MAX_USERNAME_SIZE+1), GFP_KERNEL); -+ unicode_buf = kmalloc((MAX_USERNAME_SIZE+1)*4, GFP_KERNEL); -+ -+ for(i=0;i<user_name_len;i++) -+ ucase_buf[i] = nls_info->charset2upper[(int)ses->userName[i]]; -+ ucase_buf[i] = 0; -+ user_name_len = cifs_strtoUCS(unicode_buf, ucase_buf, MAX_USERNAME_SIZE*2, nls_info); -+ unicode_buf[user_name_len] = 0; -+ user_name_len++; -+ -+ for(i=0;i<dom_name_len;i++) -+ ucase_buf[i] = nls_info->charset2upper[(int)ses->domainName[i]]; -+ ucase_buf[i] = 0; -+ dom_name_len = cifs_strtoUCS(unicode_buf+user_name_len, ucase_buf, MAX_USERNAME_SIZE*2, nls_info); -+ -+ unicode_buf[user_name_len + dom_name_len] = 0; -+ hmac_md5_update((const unsigned char *) unicode_buf, -+ (user_name_len+dom_name_len)*2,&ctx); -+ -+ hmac_md5_final(ses->mac_signing_key,&ctx); -+ kfree(ucase_buf); -+ kfree(unicode_buf); -+ return 0; -+} -+void CalcNTLMv2_response(const struct cifsSesInfo * ses,char * v2_session_response) -+{ -+ struct HMACMD5Context context; -+ memcpy(v2_session_response + 8, ses->server->cryptKey,8); -+ /* gen_blob(v2_session_response + 16); */ -+ hmac_md5_init_limK_to_64(ses->mac_signing_key, 16, &context); -+ -+ hmac_md5_update(ses->server->cryptKey,8,&context); -+/* hmac_md5_update(v2_session_response+16)client thing,8,&context); */ /* BB fix */ -+ -+ hmac_md5_final(v2_session_response,&context); -+} ---- /dev/null -+++ b/fs/cifs/cifserr.c -@@ -0,0 +1,70 @@ -+/* -+ * fs/cifserr.c -+ * -+ * Copyright (c) International Business Machines Corp., 2002 -+ * Author(s): Steve French (sfrench@us.ibm.com) -+ * -+ * This library is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU Lesser General Public License as published -+ * by the Free Software Foundation; either version 2.1 of the License, or -+ * (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -+ * the GNU Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public License -+ * along with this library; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ */ -+ -+#include <linux/errno.h> -+#include <linux/fs.h> -+#include <linux/smbno.h> -+#include "cifsfs.h" -+ -+int map_cifs_error(int error_class, int error_code, -+ int status_codes_negotiated) -+{ -+ -+ -+ if (status_codes_negotiated) { -+ switch (error_code) { -+ default: -+ return EIO; -+ } -+ } else -+ switch (error_class) { -+ case SUCCESS: -+ return 0; -+ -+ case ERRDOS: -+ switch (error_code) { -+ case ERRbadfunc: -+ return EINVAL; -+ default: -+ return EIO; -+ } -+ -+ case ERRSRV: -+ switch (error_code) { -+ default: -+ return EIO; -+ } -+ -+ case ERRHRD: -+ switch (error_code) { -+ default: -+ return EIO; -+ } -+ default: -+ return EIO; -+ } -+ return 0; -+} -+ -+int map_smb_error(int error_class, int error_code) -+{ -+ return map_cifs_error(error_class, error_code, FALSE); -+} ---- /dev/null -+++ b/fs/cifs/cifsfs.c -@@ -0,0 +1,769 @@ -+/* -+ * fs/cifs/cifsfs.c -+ * -+ * Copyright (C) International Business Machines Corp., 2002,2004 -+ * Author(s): Steve French (sfrench@us.ibm.com) -+ * -+ * Common Internet FileSystem (CIFS) client -+ * -+ * This library is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU Lesser General Public License as published -+ * by the Free Software Foundation; either version 2.1 of the License, or -+ * (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -+ * the GNU Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public License -+ * along with this library; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ */ -+ -+/* Note that BB means BUGBUG (ie something to fix eventually) */ -+ -+#include <linux/module.h> -+#include <linux/fs.h> -+#include <linux/mount.h> -+#include <linux/slab.h> -+#include <linux/init.h> -+#include <linux/version.h> -+#include <linux/list.h> -+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,15)) -+#include <linux/seq_file.h> -+#endif -+#include <linux/vfs.h> -+#include "cifsfs.h" -+#include "cifspdu.h" -+#define DECLARE_GLOBALS_HERE -+#include "cifsglob.h" -+#include "cifsproto.h" -+#include "cifs_debug.h" -+#include "cifs_fs_sb.h" -+#include <linux/mm.h> -+#define CIFS_MAGIC_NUMBER 0xFF534D42 /* the first four bytes of SMB PDUs */ -+/* BB when mempool_resize is added back in, we will resize pool on new mount */ -+#define CIFS_MIN_RCV_POOL 11 /* enough for progress to five servers */ -+ -+#ifdef CONFIG_CIFS_QUOTA -+static struct quotactl_ops cifs_quotactl_ops; -+#endif -+ -+extern struct file_system_type cifs_fs_type; -+ -+int cifsFYI = 0; -+int cifsERROR = 1; -+int traceSMB = 0; -+unsigned int oplockEnabled = 1; -+unsigned int quotaEnabled = 0; -+unsigned int linuxExtEnabled = 1; -+unsigned int lookupCacheEnabled = 1; -+unsigned int multiuser_mount = 0; -+unsigned int extended_security = 0; -+unsigned int ntlmv2_support = 0; -+unsigned int sign_CIFS_PDUs = 1; -+unsigned int CIFSMaximumBufferSize = CIFS_MAX_MSGSIZE; -+struct task_struct * oplockThread = NULL; -+ -+extern int cifs_mount(struct super_block *, struct cifs_sb_info *, char *, -+ const char *); -+extern int cifs_umount(struct super_block *, struct cifs_sb_info *); -+void cifs_proc_init(void); -+void cifs_proc_clean(void); -+ -+static DECLARE_COMPLETION(cifs_oplock_exited); -+ -+ -+struct super_block * -+cifs_read_super(struct super_block *sb, void *data, int silent) -+{ -+ struct inode *inode; -+ struct cifs_sb_info *cifs_sb; -+ int rc = 0; -+ -+ sb->s_flags |= MS_NODIRATIME; /* and probably even noatime */ -+ cifs_sb = CIFS_SB(sb); -+ if(cifs_sb == NULL) -+ return 0; -+ else -+ memset(cifs_sb,0,sizeof(struct cifs_sb_info)); -+ -+ -+ rc = cifs_mount(sb, cifs_sb, data, NULL); -+ -+ if (rc) { -+ if (!silent) -+ cERROR(1, -+ ("cifs_mount failed w/return code = %d", rc)); -+ goto out_mount_failed; -+ } -+ -+ sb->s_magic = CIFS_MAGIC_NUMBER; -+ sb->s_op = &cifs_super_ops; -+/* if(cifs_sb->tcon->ses->server->maxBuf > MAX_CIFS_HDR_SIZE + 512) -+ sb->s_blocksize = cifs_sb->tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE; */ -+#ifdef CONFIG_CIFS_QUOTA -+ sb->s_qcop = &cifs_quotactl_ops; -+#endif -+ sb->s_blocksize = CIFS_MAX_MSGSIZE; -+ sb->s_blocksize_bits = 14; /* default 2**14 = CIFS_MAX_MSGSIZE */ -+ inode = iget(sb, ROOT_I); -+ -+ if (!inode) { -+ goto out_no_root; -+ } -+ -+ sb->s_root = d_alloc_root(inode); -+ -+ if (!sb->s_root) { -+ goto out_no_root; -+ } -+ -+ return sb; -+ -+out_no_root: -+ cERROR(1, ("cifs_read_super: get root inode failed")); -+ if (inode) -+ iput(inode); -+ -+out_mount_failed: -+ if(cifs_sb->local_nls) -+ unload_nls(cifs_sb->local_nls); -+ sb->s_dev = 0; -+ return 0; -+} -+ -+static void -+cifs_put_super(struct super_block *sb) -+{ -+ int rc = 0; -+ struct cifs_sb_info *cifs_sb; -+ -+ cFYI(1, ("In cifs_put_super")); -+ cifs_sb = CIFS_SB(sb); -+ if(cifs_sb == NULL) { -+ cFYI(1,("Empty cifs superblock info passed to unmount")); -+ return; -+ } -+ rc = cifs_umount(sb, cifs_sb); -+ if (rc) { -+ cERROR(1, ("cifs_umount failed with return code %d", rc)); -+ } -+ unload_nls(cifs_sb->local_nls); -+ return; -+} -+ -+static int -+cifs_statfs(struct super_block *sb, struct statfs *buf) -+{ -+ int xid, rc; -+ struct cifs_sb_info *cifs_sb; -+ struct cifsTconInfo *pTcon; -+ -+ xid = GetXid(); -+ -+ cifs_sb = CIFS_SB(sb); -+ pTcon = cifs_sb->tcon; -+ -+ buf->f_type = CIFS_MAGIC_NUMBER; -+ -+ /* instead could get the real value via SMB_QUERY_FS_ATTRIBUTE_INFO */ -+ buf->f_namelen = PATH_MAX; /* PATH_MAX may be too long - it would presumably -+ be length of total path, note that some servers may be -+ able to support more than this, but best to be safe -+ since Win2k and others can not handle very long filenames */ -+ buf->f_files = 0; /* undefined */ -+ buf->f_ffree = 0; /* unlimited */ -+ -+ rc = CIFSSMBQFSInfo(xid, pTcon, buf, cifs_sb->local_nls); -+ -+ /* -+ int f_type; -+ __fsid_t f_fsid; -+ int f_namelen; */ -+ /* BB get from info put in tcon struct at mount time with call to QFSAttrInfo */ -+ FreeXid(xid); -+ return 0; /* always return success? what if volume is no longer available? */ -+} -+ -+static int cifs_permission(struct inode * inode, int mask) -+{ -+ /* the server does permission checks, we do not need to do it here */ -+ return 0; -+} -+ -+kmem_cache_t *cifs_req_cachep; -+kmem_cache_t *cifs_mid_cachep; -+kmem_cache_t *cifs_oplock_cachep; -+ -+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) -+static struct inode * -+cifs_alloc_inode(struct super_block *sb) -+{ -+ struct cifsInodeInfo *cifs_inode; -+ cifs_inode = -+ (struct cifsInodeInfo *) kmem_cache_alloc(cifs_inode_cachep, -+ SLAB_KERNEL); -+ if (!cifs_inode) -+ return NULL; -+ cifs_inode->cifsAttrs = 0x20; /* default */ -+ atomic_set(&cifs_inode->inUse, 0); -+ cifs_inode->time = 0; -+ /* Until the file is open and we have gotten oplock -+ info back from the server, can not assume caching of -+ file data or metadata */ -+ cifs_inode->clientCanCacheRead = FALSE; -+ cifs_inode->clientCanCacheAll = FALSE; -+ INIT_LIST_HEAD(&cifs_inode->openFileList); -+ return &cifs_inode->vfs_inode; -+} -+ -+static void -+cifs_destroy_inode(struct inode *inode) -+{ -+ kmem_cache_free(cifs_inode_cachep, CIFS_I(inode)); -+} -+#endif -+ -+/* -+ * cifs_show_options() is for displaying mount options in /proc/mounts. -+ * Not all settable options are displayed but most of the important -+ * ones are. -+ */ -+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,15)) -+static int -+cifs_show_options(struct seq_file *s, struct vfsmount *m) -+{ -+ struct cifs_sb_info *cifs_sb; -+ -+ cifs_sb = CIFS_SB(m->mnt_sb); -+ -+ if (cifs_sb) { -+ if (cifs_sb->tcon) { -+ seq_printf(s, ",unc=%s", cifs_sb->tcon->treeName); -+ if ((cifs_sb->tcon->ses) && (cifs_sb->tcon->ses->userName)) -+ seq_printf(s, ",username=%s", -+ cifs_sb->tcon->ses->userName); -+ if(cifs_sb->tcon->ses->domainName) -+ seq_printf(s, ",domain=%s", -+ cifs_sb->tcon->ses->domainName); -+ } -+ seq_printf(s, ",rsize=%d",cifs_sb->rsize); -+ seq_printf(s, ",wsize=%d",cifs_sb->wsize); -+ } -+ return 0; -+} -+#endif -+ -+#ifdef CONFIG_CIFS_QUOTA -+int cifs_xquota_set(struct super_block * sb, int quota_type, qid_t qid, -+ struct fs_disk_quota * pdquota) -+{ -+ int xid; -+ int rc = 0; -+ struct cifs_sb_info *cifs_sb = CIFS_SB(sb); -+ struct cifsTconInfo *pTcon; -+ -+ if(cifs_sb) -+ pTcon = cifs_sb->tcon; -+ else -+ return -EIO; -+ -+ -+ xid = GetXid(); -+ if(pTcon) { -+ cFYI(1,("set type: 0x%x id: %d",quota_type,qid)); -+ } else { -+ return -EIO; -+ } -+ -+ FreeXid(xid); -+ return rc; -+} -+ -+int cifs_xquota_get(struct super_block * sb, int quota_type, qid_t qid, -+ struct fs_disk_quota * pdquota) -+{ -+ int xid; -+ int rc = 0; -+ struct cifs_sb_info *cifs_sb = CIFS_SB(sb); -+ struct cifsTconInfo *pTcon; -+ -+ if(cifs_sb) -+ pTcon = cifs_sb->tcon; -+ else -+ return -EIO; -+ -+ xid = GetXid(); -+ if(pTcon) { -+ cFYI(1,("set type: 0x%x id: %d",quota_type,qid)); -+ } else { -+ rc = -EIO; -+ } -+ -+ FreeXid(xid); -+ return rc; -+} -+ -+int cifs_xstate_set(struct super_block * sb, unsigned int flags, int operation) -+{ -+ int xid; -+ int rc = 0; -+ struct cifs_sb_info *cifs_sb = CIFS_SB(sb); -+ struct cifsTconInfo *pTcon; -+ -+ if(cifs_sb) -+ pTcon = cifs_sb->tcon; -+ else -+ return -EIO; -+ -+ xid = GetXid(); -+ if(pTcon) { -+ cFYI(1,("flags: 0x%x operation: 0x%x",flags,operation)); -+ } else { -+ rc = -EIO; -+ } -+ -+ FreeXid(xid); -+ return rc; -+} -+ -+int cifs_xstate_get(struct super_block * sb, struct fs_quota_stat *qstats) -+{ -+ int xid; -+ int rc = 0; -+ struct cifs_sb_info *cifs_sb = CIFS_SB(sb); -+ struct cifsTconInfo *pTcon; -+ -+ if(cifs_sb) { -+ pTcon = cifs_sb->tcon; -+ } else { -+ return -EIO; -+ } -+ xid = GetXid(); -+ if(pTcon) { -+ cFYI(1,("pqstats %p",qstats)); -+ } else { -+ rc = -EIO; -+ } -+ -+ FreeXid(xid); -+ return rc; -+} -+ -+static struct quotactl_ops cifs_quotactl_ops = { -+ .set_xquota = cifs_xquota_set, -+ .get_xquota = cifs_xquota_set, -+ .set_xstate = cifs_xstate_set, -+ .get_xstate = cifs_xstate_get, -+}; -+#endif -+ -+static int cifs_remount(struct super_block *sb, int *flags, char *data) -+{ -+ *flags |= MS_NODIRATIME; -+ return 0; -+} -+ -+struct super_operations cifs_super_ops = { -+ .read_inode = cifs_read_inode, -+ .put_super = cifs_put_super, -+ .statfs = cifs_statfs, -+/* .alloc_inode = cifs_alloc_inode, -+ .destroy_inode = cifs_destroy_inode, */ -+/* .drop_inode = generic_delete_inode, -+ .delete_inode = cifs_delete_inode, *//* Do not need the above two functions -+ unless later we add lazy close of inodes or unless the kernel forgets to call -+ us with the same number of releases (closes) as opens */ -+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,15)) -+ .show_options = cifs_show_options, -+#endif -+/* .umount_begin = cifs_umount_begin, *//* consider adding in the future */ -+}; -+ -+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) -+static struct super_block * -+cifs_get_sb(struct file_system_type *fs_type, -+ int flags, const char *dev_name, void *data) -+{ -+ int rc; -+ struct super_block *sb = sget(fs_type, NULL, set_anon_super, NULL); -+ -+ cFYI(1, ("Devname: %s flags: %d ", dev_name, flags)); -+ -+ if (IS_ERR(sb)) -+ return sb; -+ -+ sb->s_flags = flags; -+ -+ rc = cifs_read_super(sb, data, dev_name, flags & MS_VERBOSE ? 1 : 0); -+ if (rc) { -+ up_write(&sb->s_umount); -+ deactivate_super(sb); -+ return ERR_PTR(rc); -+ } -+ sb->s_flags |= MS_ACTIVE; -+ return sb; -+} -+#endif -+ -+static ssize_t -+cifs_read_wrapper(struct file * file, char *read_data, size_t read_size, -+ loff_t * poffset) -+{ -+ if(file == NULL) -+ return -EIO; -+ else if(file->f_dentry == NULL) -+ return -EIO; -+ else if(file->f_dentry->d_inode == NULL) -+ return -EIO; -+ -+ if(CIFS_I(file->f_dentry->d_inode)->clientCanCacheRead) { -+ return generic_file_read(file,read_data,read_size,poffset); -+ } else { -+ /* BB do we need to lock inode from here until after invalidate? */ -+/* if(file->f_dentry->d_inode->i_mapping) { -+ filemap_fdatawrite(file->f_dentry->d_inode->i_mapping); -+ filemap_fdatawait(file->f_dentry->d_inode->i_mapping); -+ }*/ -+/* cifs_revalidate(file->f_dentry);*/ /* BB fixme */ -+ -+ /* BB we should make timer configurable - perhaps -+ by simply calling cifs_revalidate here */ -+ /* invalidate_remote_inode(file->f_dentry->d_inode);*/ -+ return generic_file_read(file,read_data,read_size,poffset); -+ } -+} -+ -+static ssize_t -+cifs_write_wrapper(struct file * file, const char *write_data, -+ size_t write_size, loff_t * poffset) -+{ -+ ssize_t written; -+ -+ if(file == NULL) -+ return -EIO; -+ else if(file->f_dentry == NULL) -+ return -EIO; -+ else if(file->f_dentry->d_inode == NULL) -+ return -EIO; -+ -+ /* check whether we can cache writes locally */ -+ written = generic_file_write(file,write_data,write_size,poffset); -+ if(!CIFS_I(file->f_dentry->d_inode)->clientCanCacheAll) { -+ if(file->f_dentry->d_inode->i_mapping) { -+ filemap_fdatasync(file->f_dentry->d_inode->i_mapping); -+ } -+ } -+ return written; -+} -+ -+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) -+static struct file_system_type cifs_fs_type = { -+ .owner = THIS_MODULE, -+ .name = "cifs", -+ .get_sb = cifs_get_sb, -+ .kill_sb = kill_anon_super, -+ /* .fs_flags */ -+}; -+#endif -+ -+static DECLARE_FSTYPE(cifs_fs_type, "cifs", cifs_read_super,0); -+ -+ -+struct inode_operations cifs_dir_inode_ops = { -+ .create = cifs_create, -+ .lookup = cifs_lookup, -+ .unlink = cifs_unlink, -+ .link = cifs_hardlink, -+ .mkdir = cifs_mkdir, -+ .rmdir = cifs_rmdir, -+ .rename = cifs_rename, -+ .permission = cifs_permission, -+ .revalidate = cifs_revalidate, -+ .setattr = cifs_setattr, -+ .symlink = cifs_symlink, -+ .mknod = cifs_mknod, -+}; -+ -+struct inode_operations cifs_file_inode_ops = { -+ .revalidate = cifs_revalidate, -+ .setattr = cifs_setattr, -+/* .getattr = cifs_getattr,*/ -+ .rename = cifs_rename, -+ .permission = cifs_permission, -+#ifdef CONFIG_CIFS_XATTR -+ .setxattr = cifs_setxattr, -+ .getxattr = cifs_getxattr, -+ .listxattr = cifs_listxattr, -+ .removexattr = cifs_removexattr, -+#endif -+}; -+ -+struct inode_operations cifs_symlink_inode_ops = { -+ .readlink = cifs_readlink, -+ .follow_link = cifs_follow_link, -+ .permission = cifs_permission, -+ /* BB add the following two eventually */ -+ /* revalidate: cifs_revalidate, -+ setattr: cifs_notify_change, *//* BB do we need notify change */ -+#ifdef CONFIG_CIFS_XATTR -+ .setxattr = cifs_setxattr, -+ .getxattr = cifs_getxattr, -+ .listxattr = cifs_listxattr, -+ .removexattr = cifs_removexattr, -+#endif -+}; -+ -+struct file_operations cifs_file_ops = { -+ .read = cifs_read_wrapper, -+ .write = cifs_write_wrapper, -+ .open = cifs_open, -+ .release = cifs_close, -+ .lock = cifs_lock, -+ .fsync = cifs_fsync, -+ .flush = cifs_flush, -+ .mmap = cifs_file_mmap, -+/* .sendfile = generic_file_sendfile,*/ -+#ifdef CONFIG_CIFS_FCNTL -+ .fcntl = cifs_fcntl, -+#endif -+}; -+ -+struct file_operations cifs_dir_ops = { -+ .readdir = cifs_readdir, -+ .release = cifs_closedir, -+ .read = generic_read_dir, -+#ifdef CONFIG_CIFS_FCNTL -+ .fcntl = cifs_fcntl, -+#endif -+}; -+/* -+static void -+cifs_init_once(void *inode, kmem_cache_t * cachep, unsigned long flags) -+{ -+ struct cifsInodeInfo *cifsi = (struct cifsInodeInfo *) inode; -+ -+ if ((flags & (SLAB_CTOR_VERIFY | SLAB_CTOR_CONSTRUCTOR)) == -+ SLAB_CTOR_CONSTRUCTOR) { -+ inode_init_once(&cifsi->vfs_inode); -+ INIT_LIST_HEAD(&cifsi->lockList); -+ } -+} -+ -+static int -+cifs_init_inodecache(void) -+{ -+ cifs_inode_cachep = kmem_cache_create("cifs_inode_cache", -+ sizeof (struct cifsInodeInfo), -+ 0, SLAB_HWCACHE_ALIGN, -+ cifs_init_once, NULL); -+ if (cifs_inode_cachep == NULL) -+ return -ENOMEM; -+ -+ -+ return 0; -+} -+ -+static void -+cifs_destroy_inodecache(void) -+{ -+ if (kmem_cache_destroy(cifs_inode_cachep)) -+ printk(KERN_WARNING "cifs_inode_cache: error freeing\n"); -+} */ -+ -+static int -+cifs_init_request_bufs(void) -+{ -+ cifs_req_cachep = kmem_cache_create("cifs_request", -+ CIFS_MAX_MSGSIZE + -+ MAX_CIFS_HDR_SIZE, 0, -+ SLAB_HWCACHE_ALIGN, NULL, NULL); -+ if (cifs_req_cachep == NULL) -+ return -ENOMEM; -+ -+ return 0; -+} -+ -+static void -+cifs_destroy_request_bufs(void) -+{ -+ if (kmem_cache_destroy(cifs_req_cachep)) -+ printk(KERN_WARNING -+ "cifs_destroy_request_cache: error not all structures were freed\n"); -+} -+ -+static int -+cifs_init_mids(void) -+{ -+ cifs_mid_cachep = kmem_cache_create("cifs_mpx_ids", -+ sizeof (struct mid_q_entry), 0, -+ SLAB_HWCACHE_ALIGN, NULL, NULL); -+ if (cifs_mid_cachep == NULL) -+ return -ENOMEM; -+ cifs_oplock_cachep = kmem_cache_create("cifs_oplock_struct", -+ sizeof (struct oplock_q_entry), 0, -+ SLAB_HWCACHE_ALIGN, NULL, NULL); -+ if (cifs_oplock_cachep == NULL) { -+ kmem_cache_destroy(cifs_mid_cachep); -+ return -ENOMEM; -+ } -+ -+ return 0; -+} -+ -+static void -+cifs_destroy_mids(void) -+{ -+ if (kmem_cache_destroy(cifs_mid_cachep)) -+ printk(KERN_WARNING -+ "cifs_destroy_mids: error not all structures were freed\n"); -+ if (kmem_cache_destroy(cifs_oplock_cachep)) -+ printk(KERN_WARNING -+ "error not all oplock structures were freed\n"); -+} -+ -+static int cifs_oplock_thread(void * dummyarg) -+{ -+ struct oplock_q_entry * oplock_item; -+ struct cifsTconInfo *pTcon; -+ struct inode * inode; -+ __u16 netfid; -+ int rc = 0; -+ -+ daemonize(); -+ sprintf(current->comm,"cifsoplockd"); -+ -+ oplockThread = current; -+ do { -+ set_current_state(TASK_INTERRUPTIBLE); -+ -+ schedule_timeout(1*HZ); -+ spin_lock(&GlobalMid_Lock); -+ if(list_empty(&GlobalOplock_Q)) { -+ spin_unlock(&GlobalMid_Lock); -+ set_current_state(TASK_INTERRUPTIBLE); -+ schedule_timeout(39*HZ); -+ } else { -+ oplock_item = list_entry(GlobalOplock_Q.next, -+ struct oplock_q_entry, qhead); -+ if(oplock_item) { -+ cFYI(1,("found oplock item to write out")); -+ pTcon = oplock_item->tcon; -+ inode = oplock_item->pinode; -+ netfid = oplock_item->netfid; -+ spin_unlock(&GlobalMid_Lock); -+ DeleteOplockQEntry(oplock_item); -+ /* can not grab inode sem here since it would -+ deadlock when oplock received on delete -+ since vfs_unlink holds the i_sem across -+ the call */ -+ /* down(&inode->i_sem);*/ -+ if (S_ISREG(inode->i_mode)) { -+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,17)) -+ rc = filemap_fdatasync(inode->i_mapping); -+ if(rc) -+ CIFS_I(inode)->write_behind_rc = rc; -+#else -+ filemap_fdatasync(inode->i_mapping); -+#endif -+ if(CIFS_I(inode)->clientCanCacheRead == 0) -+ invalidate_inode_pages(inode); -+ } else -+ rc = 0; -+ /* releasing a stale oplock after recent reconnection -+ of smb session using a now incorrect file -+ handle is not a data integrity issue but do -+ not bother sending an oplock release if session -+ to server still is disconnected since oplock -+ already released by the server in that case */ -+ if(pTcon->tidStatus != CifsNeedReconnect) { -+ rc = CIFSSMBLock(0, pTcon, -+ netfid, -+ 0 /* len */ , 0 /* offset */, 0, -+ 0, LOCKING_ANDX_OPLOCK_RELEASE, -+ 0 /* wait flag */); -+ cFYI(1,("Oplock release rc = %d ",rc)); -+ } -+ } else -+ spin_unlock(&GlobalMid_Lock); -+ } -+ } while(!signal_pending(current)); -+ complete_and_exit (&cifs_oplock_exited, 0); -+} -+ -+static int __init -+init_cifs(void) -+{ -+ int rc = 0; -+#if CONFIG_PROC_FS -+ cifs_proc_init(); -+#endif -+ INIT_LIST_HEAD(&GlobalServerList); /* BB not implemented yet */ -+ INIT_LIST_HEAD(&GlobalSMBSessionList); -+ INIT_LIST_HEAD(&GlobalTreeConnectionList); -+ INIT_LIST_HEAD(&GlobalOplock_Q); -+/* -+ * Initialize Global counters -+ */ -+ atomic_set(&sesInfoAllocCount, 0); -+ atomic_set(&tconInfoAllocCount, 0); -+ atomic_set(&tcpSesReconnectCount, 0); -+ atomic_set(&tconInfoReconnectCount, 0); -+ -+ atomic_set(&bufAllocCount, 0); -+ atomic_set(&midCount, 0); -+ GlobalCurrentXid = 0; -+ GlobalTotalActiveXid = 0; -+ GlobalMaxActiveXid = 0; -+ GlobalSMBSeslock = RW_LOCK_UNLOCKED; -+ GlobalMid_Lock = SPIN_LOCK_UNLOCKED; -+ -+/* rc = cifs_init_inodecache();*/ -+ if (!rc) { -+ rc = cifs_init_mids(); -+ if (!rc) { -+ rc = cifs_init_request_bufs(); -+ if (!rc) { -+ rc = register_filesystem(&cifs_fs_type); -+ if (!rc) { -+ kernel_thread(cifs_oplock_thread, NULL, -+ CLONE_FS | CLONE_FILES | CLONE_VM); -+ return rc; /* Success */ -+ } else -+ cifs_destroy_request_bufs(); -+ } -+ cifs_destroy_mids(); -+ } -+/* cifs_destroy_inodecache(); */ -+ } -+#if CONFIG_PROC_FS -+ cifs_proc_clean(); -+#endif -+ return rc; -+} -+ -+static void __exit -+exit_cifs(void) -+{ -+ cFYI(0, ("In unregister ie exit_cifs")); -+#if CONFIG_PROC_FS -+ cifs_proc_clean(); -+#endif -+ unregister_filesystem(&cifs_fs_type); -+/* cifs_destroy_inodecache();*/ -+ cifs_destroy_mids(); -+ cifs_destroy_request_bufs(); -+ if(oplockThread) { -+ send_sig(SIGTERM, oplockThread, 1); -+ wait_for_completion(&cifs_oplock_exited); -+ } -+} -+ -+MODULE_AUTHOR("Steve French <sfrench@us.ibm.com>"); -+MODULE_LICENSE("GPL"); /* combination of LGPL + GPL source behaves as GPL */ -+MODULE_DESCRIPTION -+ ("VFS to access servers complying with the SNIA CIFS Specification e.g. Samba and Windows"); -+module_init(init_cifs) -+module_exit(exit_cifs) ---- /dev/null -+++ b/fs/cifs/cifsfs.h -@@ -0,0 +1,97 @@ -+/* -+ * fs/cifs/cifsfs.h -+ * -+ * Copyright (c) International Business Machines Corp., 2002 -+ * Author(s): Steve French (sfrench@us.ibm.com) -+ * -+ * This library is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU Lesser General Public License as published -+ * by the Free Software Foundation; either version 2.1 of the License, or -+ * (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -+ * the GNU Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public License -+ * along with this library; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ */ -+ -+#ifndef _CIFSFS_H -+#define _CIFSFS_H -+ -+#define ROOT_I 2 -+ -+#ifndef FALSE -+#define FALSE 0 -+#endif -+ -+#ifndef TRUE -+#define TRUE 1 -+#endif -+ -+extern int map_cifs_error(int error_class, int error_code, -+ int status_codes_negotiated); -+ -+extern struct address_space_operations cifs_addr_ops; -+ -+/* Functions related to super block operations */ -+extern struct super_operations cifs_super_ops; -+extern void cifs_put_inode(struct inode *); -+extern void cifs_read_inode(struct inode *); -+extern void cifs_delete_inode(struct inode *); -+/* extern void cifs_write_inode(struct inode *); *//* BB not needed yet */ -+ -+/* Functions related to inodes */ -+extern struct inode_operations cifs_dir_inode_ops; -+extern int cifs_create(struct inode *, struct dentry *, int); -+extern struct dentry *cifs_lookup(struct inode *, struct dentry *); -+extern int cifs_unlink(struct inode *, struct dentry *); -+extern int cifs_hardlink(struct dentry *, struct inode *, struct dentry *); -+extern int cifs_mknod(struct inode *, struct dentry *, int, int); -+extern int cifs_mkdir(struct inode *, struct dentry *, int); -+extern int cifs_rmdir(struct inode *, struct dentry *); -+extern int cifs_rename(struct inode *, struct dentry *, struct inode *, -+ struct dentry *); -+extern int cifs_revalidate(struct dentry *); -+extern int cifs_setattr(struct dentry *, struct iattr *); -+ -+extern struct inode_operations cifs_file_inode_ops; -+extern void cifs_truncate_file(struct inode *); -+extern struct inode_operations cifs_symlink_inode_ops; -+ -+/* Functions related to files and directories */ -+extern struct file_operations cifs_file_ops; -+extern int cifs_open(struct inode *inode, struct file *file); -+extern int cifs_close(struct inode *inode, struct file *file); -+extern int cifs_closedir(struct inode *inode, struct file *file); -+extern ssize_t cifs_read(struct file *file, char *read_data, -+ size_t read_size, loff_t * poffset); -+extern ssize_t cifs_write(struct file *file, const char *write_data, -+ size_t write_size, loff_t * poffset); -+extern int cifs_lock(struct file *, int, struct file_lock *); -+extern int cifs_fsync(struct file *, struct dentry *, int); -+extern int cifs_flush(struct file *); -+extern int cifs_file_mmap(struct file * , struct vm_area_struct *); -+extern struct file_operations cifs_dir_ops; -+extern int cifs_dir_open(struct inode *inode, struct file *file); -+extern int cifs_readdir(struct file *file, void *direntry, filldir_t filldir); -+extern long cifs_fcntl(int, unsigned int, unsigned long, struct file *); -+ -+/* Functions related to dir entries */ -+extern struct dentry_operations cifs_dentry_ops; -+ -+/* Functions related to symlinks */ -+extern int cifs_follow_link(struct dentry *direntry, struct nameidata *nd); -+extern int cifs_readlink(struct dentry *direntry, char *buffer, int buflen); -+extern int cifs_symlink(struct inode *inode, struct dentry *direntry, -+ const char *symname); -+extern int cifs_removexattr(struct dentry *, const char *); -+extern int cifs_setxattr(struct dentry *, const char *, const void *, -+ size_t, int); -+extern ssize_t cifs_getxattr(struct dentry *, const char *, void *, size_t); -+extern ssize_t cifs_listxattr(struct dentry *, char *, size_t); -+#define CIFS_VERSION "1.20" -+#endif /* _CIFSFS_H */ ---- /dev/null -+++ b/fs/cifs/cifs_fs_sb.h -@@ -0,0 +1,32 @@ -+/* -+ * fs/cifs/cifs_fs_sb.h -+ * -+ * Copyright (c) International Business Machines Corp., 2002 -+ * Author(s): Steve French (sfrench@us.ibm.com) -+ * -+ * This library is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU Lesser General Public License as published -+ * by the Free Software Foundation; either version 2.1 of the License, or -+ * (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -+ * the GNU Lesser General Public License for more details. -+ * -+ */ -+#ifndef _CIFS_FS_SB_H -+#define _CIFS_FS_SB_H -+ -+struct cifs_sb_info { -+ struct cifsTconInfo *tcon; /* primary mount */ -+ struct list_head nested_tcon_q; -+ struct nls_table *local_nls; -+ unsigned int rsize; -+ unsigned int wsize; -+ uid_t mnt_uid; -+ gid_t mnt_gid; -+ mode_t mnt_file_mode; -+ mode_t mnt_dir_mode; -+}; -+#endif /* _CIFS_FS_SB_H */ ---- /dev/null -+++ b/fs/cifs/cifsglob.h -@@ -0,0 +1,413 @@ -+/* -+ * fs/cifs/cifsglob.h -+ * -+ * Copyright (C) International Business Machines Corp., 2002,2003 -+ * Author(s): Steve French (sfrench@us.ibm.com) -+ * -+ * This library is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU Lesser General Public License as published -+ * by the Free Software Foundation; either version 2.1 of the License, or -+ * (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -+ * the GNU Lesser General Public License for more details. -+ * -+ */ -+#include <linux/in.h> -+#include <linux/in6.h> -+#include "cifs_fs_sb.h" -+/* -+ * The sizes of various internal tables and strings -+ */ -+#define MAX_UID_INFO 16 -+#define MAX_SES_INFO 2 -+#define MAX_TCON_INFO 4 -+ -+#define MAX_TREE_SIZE 2 + MAX_SERVER_SIZE + 1 + MAX_SHARE_SIZE + 1 -+#define MAX_SERVER_SIZE 15 -+#define MAX_SHARE_SIZE 64 /* used to be 20 - this should still be enough */ -+#define MAX_USERNAME_SIZE 32 /* 32 is to allow for 15 char names + null -+ termination then *2 for unicode versions */ -+#define MAX_PASSWORD_SIZE 16 -+ -+/* -+ * MAX_REQ is the maximum number of requests that WE will send -+ * on one socket concurently. It also matches the most common -+ * value of max multiplex returned by servers. We may -+ * eventually want to use the negotiated value (in case -+ * future servers can handle more) when we are more confident that -+ * we will not have problems oveloading the socket with pending -+ * write data. -+ */ -+#define CIFS_MAX_REQ 50 -+ -+#define SERVER_NAME_LENGTH 15 -+#define SERVER_NAME_LEN_WITH_NULL (SERVER_NAME_LENGTH + 1) -+ -+/* used to define string lengths for reversing unicode strings */ -+/* (256+1)*2 = 514 */ -+/* (max path length + 1 for null) * 2 for unicode */ -+#define MAX_NAME 514 -+ -+#include "cifspdu.h" -+ -+#ifndef FALSE -+#define FALSE 0 -+#endif -+ -+#ifndef TRUE -+#define TRUE 1 -+#endif -+ -+#ifndef XATTR_DOS_ATTRIB -+#define XATTR_DOS_ATTRIB "user.DOSATTRIB" -+#endif -+ -+/* -+ * This information is kept on every Server we know about. -+ * -+ * Some things to note: -+ * -+ */ -+#define SERVER_NAME_LEN_WITH_NULL (SERVER_NAME_LENGTH + 1) -+ -+/* -+ * CIFS vfs client Status information (based on what we know.) -+ */ -+ -+ /* associated with each tcp and smb session */ -+enum statusEnum { -+ CifsNew = 0, -+ CifsGood, -+ CifsExiting, -+ CifsNeedReconnect -+}; -+ -+enum securityEnum { -+ NTLM = 0, /* Legacy NTLM012 auth with NTLM hash */ -+ NTLMv2, /* Legacy NTLM auth with NTLMv2 hash */ -+ RawNTLMSSP, /* NTLMSSP without SPNEGO */ -+ NTLMSSP, /* NTLMSSP via SPNEGO */ -+ Kerberos /* Kerberos via SPNEGO */ -+}; -+ -+enum protocolEnum { -+ IPV4 = 0, -+ IPV6, -+ SCTP -+ /* Netbios frames protocol not supported at this time */ -+}; -+ -+/* -+ ***************************************************************** -+ * Except the CIFS PDUs themselves all the -+ * globally interesting structs should go here -+ ***************************************************************** -+ */ -+ -+struct TCP_Server_Info { -+ char server_Name[SERVER_NAME_LEN_WITH_NULL]; /* 15 chars + X'20'in 16th */ -+ char unicode_server_Name[SERVER_NAME_LEN_WITH_NULL * 2]; /* Unicode version of server_Name */ -+ struct socket *ssocket; -+ union { -+ struct sockaddr_in sockAddr; -+ struct sockaddr_in6 sockAddr6; -+ } addr; -+ wait_queue_head_t response_q; -+ wait_queue_head_t request_q; /* if more than maxmpx to srvr must block*/ -+ struct list_head pending_mid_q; -+ void *Server_NlsInfo; /* BB - placeholder for future NLS info */ -+ unsigned short server_codepage; /* codepage for the server */ -+ unsigned long ip_address; /* IP addr for the server if known */ -+ enum protocolEnum protocolType; -+ char versionMajor; -+ char versionMinor; -+ int svlocal:1; /* local server or remote */ -+ atomic_t socketUseCount; /* number of open cifs sessions on socket */ -+ atomic_t inFlight; /* number of requests on the wire to server */ -+ enum statusEnum tcpStatus; /* what we think the status is */ -+ struct semaphore tcpSem; -+ struct task_struct *tsk; -+ char server_GUID[16]; -+ char secMode; -+ enum securityEnum secType; -+ unsigned int maxReq; /* Clients should submit no more */ -+ /* than maxReq distinct unanswered SMBs to the server when using */ -+ /* multiplexed reads or writes */ -+ unsigned int maxBuf; /* maxBuf specifies the maximum */ -+ /* message size the server can send or receive for non-raw SMBs */ -+ unsigned int maxRw; /* maxRw specifies the maximum */ -+ /* message size the server can send or receive for */ -+ /* SMB_COM_WRITE_RAW or SMB_COM_READ_RAW. */ -+ char sessid[4]; /* unique token id for this session */ -+ /* (returned on Negotiate */ -+ int capabilities; /* allow selective disabling of caps by smb sess */ -+ __u16 timeZone; -+ char cryptKey[CIFS_CRYPTO_KEY_SIZE]; -+ char workstation_RFC1001_name[16]; /* 16th byte is always zero */ -+}; -+ -+/* -+ * The following is our shortcut to user information. We surface the uid, -+ * and name. We always get the password on the fly in case it -+ * has changed. We also hang a list of sessions owned by this user off here. -+ */ -+struct cifsUidInfo { -+ struct list_head userList; -+ struct list_head sessionList; /* SMB sessions for this user */ -+ uid_t linux_uid; -+ char user[MAX_USERNAME_SIZE + 1]; /* ascii name of user */ -+ /* BB may need ptr or callback for PAM or WinBind info */ -+}; -+ -+/* -+ * Session structure. One of these for each uid session with a particular host -+ */ -+struct cifsSesInfo { -+ struct list_head cifsSessionList; -+ struct semaphore sesSem; -+ struct cifsUidInfo *uidInfo; /* pointer to user info */ -+ struct TCP_Server_Info *server; /* pointer to server info */ -+ atomic_t inUse; /* # of mounts (tree connections) on this ses */ -+ enum statusEnum status; -+ __u32 sequence_number; /* needed for CIFS PDU signature */ -+ __u16 ipc_tid; /* special tid for connection to IPC share */ -+ char mac_signing_key[CIFS_SESSION_KEY_SIZE + 16]; -+ char *serverOS; /* name of operating system underlying the server */ -+ char *serverNOS; /* name of network operating system that the server is running */ -+ char *serverDomain; /* security realm of server */ -+ int Suid; /* remote smb uid */ -+ uid_t linux_uid; /* local Linux uid */ -+ int capabilities; -+ char serverName[SERVER_NAME_LEN_WITH_NULL * 2]; /* BB make bigger for tcp names - will ipv6 and sctp addresses fit here?? */ -+ char userName[MAX_USERNAME_SIZE + 1]; -+ char domainName[MAX_USERNAME_SIZE + 1]; -+ char * password; -+}; -+ -+/* -+ * there is one of these for each connection to a resource on a particular -+ * session -+ */ -+struct cifsTconInfo { -+ struct list_head cifsConnectionList; -+ struct list_head openFileList; -+ struct semaphore tconSem; -+ struct cifsSesInfo *ses; /* pointer to session associated with */ -+ char treeName[MAX_TREE_SIZE + 1]; /* UNC name of resource (in ASCII not UTF) */ -+ char *nativeFileSystem; -+ __u16 tid; /* The 2 byte tree id */ -+ __u16 Flags; /* optional support bits */ -+ enum statusEnum tidStatus; -+ atomic_t useCount; /* how many mounts (explicit or implicit) to this share */ -+#ifdef CONFIG_CIFS_STATS -+ atomic_t num_smbs_sent; -+ atomic_t num_writes; -+ atomic_t num_reads; -+ atomic_t num_oplock_brks; -+ atomic_t num_opens; -+ atomic_t num_deletes; -+ atomic_t num_mkdirs; -+ atomic_t num_rmdirs; -+ atomic_t num_renames; -+ atomic_t num_t2renames; -+ __u64 bytes_read; -+ __u64 bytes_written; -+ spinlock_t stat_lock; -+#endif -+ FILE_SYSTEM_DEVICE_INFO fsDevInfo; -+ FILE_SYSTEM_ATTRIBUTE_INFO fsAttrInfo; /* ok if file system name truncated */ -+ FILE_SYSTEM_UNIX_INFO fsUnixInfo; -+ int retry:1; -+ /* BB add field for back pointer to sb struct? */ -+}; -+ -+/* -+ * This info hangs off the cifsFileInfo structure. This is used to track -+ * byte stream locks on the file -+ */ -+struct cifsLockInfo { -+ struct cifsLockInfo *next; -+ int start; -+ int length; -+ int type; -+}; -+ -+/* -+ * One of these for each open instance of a file -+ */ -+struct cifsFileInfo { -+ struct list_head tlist; /* pointer to next fid owned by tcon */ -+ struct list_head flist; /* next fid (file instance) for this inode */ -+ unsigned int uid; /* allows finding which FileInfo structure */ -+ __u32 pid; /* process id who opened file */ -+ __u16 netfid; /* file id from remote */ -+ /* BB add lock scope info here if needed */ ; -+ /* lock scope id (0 if none) */ -+ struct file * pfile; /* needed for writepage */ -+ struct inode * pInode; /* needed for oplock break */ -+ int endOfSearch:1; /* we have reached end of search */ -+ int closePend:1; /* file is marked to close */ -+ int emptyDir:1; -+ int invalidHandle:1; /* file closed via session abend */ -+ struct semaphore fh_sem; /* prevents reopen race after dead ses*/ -+ char * search_resume_name; -+ unsigned int resume_name_length; -+ __u32 resume_key; -+}; -+ -+/* -+ * One of these for each file inode -+ */ -+ -+struct cifsInodeInfo { -+ struct list_head lockList; -+ /* BB add in lists for dirty pages - i.e. write caching info for oplock */ -+ struct list_head openFileList; -+ int write_behind_rc; -+ __u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */ -+ atomic_t inUse; /* num concurrent users (local openers cifs) of file*/ -+ unsigned long time; /* jiffies of last update/check of inode */ -+ int clientCanCacheRead:1; /* read oplock */ -+ int clientCanCacheAll:1; /* read and writebehind oplock */ -+ int oplockPending:1; -+ struct inode vfs_inode; -+}; -+ -+static inline struct cifsInodeInfo * CIFS_I(struct inode *inode) -+{ -+ return (struct cifsInodeInfo *)&(inode->u); -+} -+ -+static inline struct cifs_sb_info * CIFS_SB(struct super_block *sb) -+{ -+ return (struct cifs_sb_info *) &(sb->u); -+} -+ -+ -+/* one of these for every pending CIFS request to the server */ -+struct mid_q_entry { -+ struct list_head qhead; /* mids waiting on reply from this server */ -+ __u16 mid; /* multiplex id */ -+ __u16 pid; /* process id */ -+ __u32 sequence_number; /* for CIFS signing */ -+ __u16 command; /* smb command code */ -+ struct timeval when_sent; /* time when smb sent */ -+ struct cifsSesInfo *ses; /* smb was sent to this server */ -+ struct task_struct *tsk; /* task waiting for response */ -+ struct smb_hdr *resp_buf; /* response buffer */ -+ int midState; /* wish this were enum but can not pass to wait_event */ -+}; -+ -+struct oplock_q_entry { -+ struct list_head qhead; -+ struct inode * pinode; -+ struct cifsTconInfo * tcon; -+ __u16 netfid; -+}; -+ -+#define MID_FREE 0 -+#define MID_REQUEST_ALLOCATED 1 -+#define MID_REQUEST_SUBMITTED 2 -+#define MID_RESPONSE_RECEIVED 4 -+#define MID_RETRY_NEEDED 8 /* session closed while this request out */ -+ -+/* -+ ***************************************************************** -+ * All constants go here -+ ***************************************************************** -+ */ -+ -+#define UID_HASH (16) -+ -+/* -+ * Note that ONE module should define _DECLARE_GLOBALS_HERE to cause the -+ * following to be declared. -+ */ -+ -+/**************************************************************************** -+ * Locking notes. All updates to global variables and lists should be -+ * protected by spinlocks or semaphores. -+ * -+ * Spinlocks -+ * --------- -+ * GlobalMid_Lock protects: -+ * list operations on pending_mid_q and oplockQ -+ * updates to XID counters, multiplex id and SMB sequence numbers -+ * GlobalSMBSesLock protects: -+ * list operations on tcp and SMB session lists and tCon lists -+ * f_owner.lock protects certain per file struct operations -+ * mapping->page_lock protects certain per page operations -+ * -+ * Semaphores -+ * ---------- -+ * sesSem operations on smb session -+ * tconSem operations on tree connection -+ * fh_sem file handle reconnection operations -+ * -+ ****************************************************************************/ -+ -+#ifdef DECLARE_GLOBALS_HERE -+#define GLOBAL_EXTERN -+#else -+#define GLOBAL_EXTERN extern -+#endif -+ -+/* -+ * The list of servers that did not respond with NT LM 0.12. -+ * This list helps improve performance and eliminate the messages indicating -+ * that we had a communications error talking to the server in this list. -+ */ -+GLOBAL_EXTERN struct servers_not_supported *NotSuppList; /*@z4a */ -+ -+/* -+ * The following is a hash table of all the users we know about. -+ */ -+GLOBAL_EXTERN struct smbUidInfo *GlobalUidList[UID_HASH]; -+ -+GLOBAL_EXTERN struct list_head GlobalServerList; /* BB not implemented yet */ -+GLOBAL_EXTERN struct list_head GlobalSMBSessionList; -+GLOBAL_EXTERN struct list_head GlobalTreeConnectionList; -+GLOBAL_EXTERN rwlock_t GlobalSMBSeslock; /* protects list inserts on 3 above */ -+ -+GLOBAL_EXTERN struct list_head GlobalOplock_Q; -+ -+/* -+ * Global transaction id (XID) information -+ */ -+GLOBAL_EXTERN unsigned int GlobalCurrentXid; /* protected by GlobalMid_Sem */ -+GLOBAL_EXTERN unsigned int GlobalTotalActiveXid; /* prot by GlobalMid_Sem */ -+GLOBAL_EXTERN unsigned int GlobalMaxActiveXid; /* prot by GlobalMid_Sem */ -+GLOBAL_EXTERN spinlock_t GlobalMid_Lock; /* protects above and list operations */ -+ /* on midQ entries */ -+GLOBAL_EXTERN char Local_System_Name[15]; -+ -+/* -+ * Global counters, updated atomically -+ */ -+GLOBAL_EXTERN atomic_t sesInfoAllocCount; -+GLOBAL_EXTERN atomic_t tconInfoAllocCount; -+ -+GLOBAL_EXTERN atomic_t tcpSesReconnectCount; -+GLOBAL_EXTERN atomic_t tconInfoReconnectCount; -+ -+/* Various Debug counters to remove someday (BB) */ -+GLOBAL_EXTERN atomic_t bufAllocCount; -+GLOBAL_EXTERN atomic_t midCount; -+ -+/* Misc globals */ -+GLOBAL_EXTERN unsigned int multiuser_mount; /* if enabled allows new sessions -+ to be established on existing mount if we -+ have the uid/password or Kerberos credential -+ or equivalent for current user */ -+GLOBAL_EXTERN unsigned int oplockEnabled; -+GLOBAL_EXTERN unsigned int quotaEnabled; -+GLOBAL_EXTERN unsigned int lookupCacheEnabled; -+GLOBAL_EXTERN unsigned int extended_security; /* if on, session setup sent -+ with more secure ntlmssp2 challenge/resp */ -+GLOBAL_EXTERN unsigned int ntlmv2_support; /* better optional password hash */ -+GLOBAL_EXTERN unsigned int sign_CIFS_PDUs; /* enable smb packet signing */ -+GLOBAL_EXTERN unsigned int linuxExtEnabled; /* enable Linux/Unix CIFS extensions */ -+ ---- /dev/null -+++ b/fs/cifs/cifspdu.h -@@ -0,0 +1,1793 @@ -+/* -+ * fs/cifs/cifspdu.h -+ * -+ * Copyright (c) International Business Machines Corp., 2002 -+ * Author(s): Steve French (sfrench@us.ibm.com) -+ * -+ * This library is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU Lesser General Public License as published -+ * by the Free Software Foundation; either version 2.1 of the License, or -+ * (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -+ * the GNU Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public License -+ * along with this library; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ */ -+ -+#ifndef _CIFSPDU_H -+#define _CIFSPDU_H -+ -+#include <net/sock.h> -+ -+#define CIFS_PROT 0 -+#define BAD_PROT CIFS_PROT+1 -+ -+/* SMB command codes */ -+#define SMB_COM_CREATE_DIRECTORY 0x00 -+#define SMB_COM_DELETE_DIRECTORY 0x01 -+#define SMB_COM_CLOSE 0x04 -+#define SMB_COM_DELETE 0x06 -+#define SMB_COM_RENAME 0x07 -+#define SMB_COM_LOCKING_ANDX 0x24 -+#define SMB_COM_COPY 0x29 -+#define SMB_COM_READ_ANDX 0x2E -+#define SMB_COM_WRITE_ANDX 0x2F -+#define SMB_COM_TRANSACTION2 0x32 -+#define SMB_COM_TRANSACTION2_SECONDARY 0x33 -+#define SMB_COM_FIND_CLOSE2 0x34 -+#define SMB_COM_TREE_DISCONNECT 0x71 -+#define SMB_COM_NEGOTIATE 0x72 -+#define SMB_COM_SESSION_SETUP_ANDX 0x73 -+#define SMB_COM_LOGOFF_ANDX 0x74 -+#define SMB_COM_TREE_CONNECT_ANDX 0x75 -+#define SMB_COM_NT_TRANSACT 0xA0 -+#define SMB_COM_NT_TRANSACT_SECONDARY 0xA1 -+#define SMB_COM_NT_CREATE_ANDX 0xA2 -+#define SMB_COM_NT_RENAME 0xA5 -+ -+/* Transact2 subcommand codes */ -+#define TRANS2_OPEN 0x00 -+#define TRANS2_FIND_FIRST 0x01 -+#define TRANS2_FIND_NEXT 0x02 -+#define TRANS2_QUERY_FS_INFORMATION 0x03 -+#define TRANS2_QUERY_PATH_INFORMATION 0x05 -+#define TRANS2_SET_PATH_INFORMATION 0x06 -+#define TRANS2_QUERY_FILE_INFORMATION 0x07 -+#define TRANS2_SET_FILE_INFORMATION 0x08 -+#define TRANS2_GET_DFS_REFERRAL 0x10 -+#define TRANS2_REPORT_DFS_INCOSISTENCY 0x11 -+ -+/* NT Transact subcommand codes */ -+#define NT_TRANSACT_CREATE 0x01 -+#define NT_TRANSACT_IOCTL 0x02 -+#define NT_TRANSACT_SET_SECURITY_DESC 0x03 -+#define NT_TRANSACT_NOTIFY_CHANGE 0x04 -+#define NT_TRANSACT_RENAME 0x05 -+#define NT_TRANSACT_QUERY_SECURITY_DESC 0x06 -+#define NT_TRANSACT_GET_USER_QUOTA 0x07 -+#define NT_TRANSACT_SET_USER_QUOTA 0x08 -+ -+#define MAX_CIFS_HDR_SIZE 256 /* chained NTCreateXReadX will probably be biggest */ -+ -+/* internal cifs vfs structures */ -+/***************************************************************** -+ * All constants go here -+ ***************************************************************** -+ */ -+ -+/* -+ * Starting value for maximum SMB size negotiation -+ */ -+#define CIFS_MAX_MSGSIZE (4*4096) -+ -+/* -+ * Size of encrypted user password in bytes -+ */ -+#define CIFS_ENCPWD_SIZE (16) -+ -+/* -+ * Size of the crypto key returned on the negotiate SMB in bytes -+ */ -+#define CIFS_CRYPTO_KEY_SIZE (8) -+ -+/* -+ * Size of the session key (crypto key encrypted with the password -+ */ -+#define CIFS_SESSION_KEY_SIZE (24) -+ -+/* -+ * Maximum user name length -+ */ -+#define CIFS_UNLEN (20) -+ -+/* -+ * Flags on SMB open -+ */ -+#define SMBOPEN_WRITE_THROUGH 0x4000 -+#define SMBOPEN_DENY_ALL 0x0010 -+#define SMBOPEN_DENY_WRITE 0x0020 -+#define SMBOPEN_DENY_READ 0x0030 -+#define SMBOPEN_DENY_NONE 0x0040 -+#define SMBOPEN_READ 0x0000 -+#define SMBOPEN_WRITE 0x0001 -+#define SMBOPEN_READWRITE 0x0002 -+#define SMBOPEN_EXECUTE 0x0003 -+ -+#define SMBOPEN_OCREATE 0x0010 -+#define SMBOPEN_OTRUNC 0x0002 -+#define SMBOPEN_OAPPEND 0x0001 -+ -+/* -+ * SMB flag definitions -+ */ -+#define SMBFLG_EXTD_LOCK 0x01 /* server supports lock-read write-unlock primitives */ -+#define SMBFLG_RCV_POSTED 0x02 /* obsolete */ -+#define SMBFLG_RSVD 0x04 -+#define SMBFLG_CASELESS 0x08 /* all pathnames treated as caseless (off implies case sensitive file handling requested) */ -+#define SMBFLG_CANONICAL_PATH_FORMAT 0x10 /* obsolete */ -+#define SMBFLG_OLD_OPLOCK 0x20 /* obsolete */ -+#define SMBFLG_OLD_OPLOCK_NOTIFY 0x40 /* obsolete */ -+#define SMBFLG_RESPONSE 0x80 /* this PDU is a response from server */ -+ -+/* -+ * SMB flag2 definitions -+ */ -+#define SMBFLG2_KNOWS_LONG_NAMES 0x0001 /* can send long (non-8.3) path names in response */ -+#define SMBFLG2_KNOWS_EAS 0x0002 -+#define SMBFLG2_SECURITY_SIGNATURE 0x0004 -+#define SMBFLG2_IS_LONG_NAME 0x0040 -+#define SMBFLG2_EXT_SEC 0x0800 -+#define SMBFLG2_DFS 0x1000 -+#define SMBFLG2_PAGING_IO 0x2000 -+#define SMBFLG2_ERR_STATUS 0x4000 -+#define SMBFLG2_UNICODE 0x8000 -+ -+/* -+ * These are the file access permission bits defined in CIFS for the -+ * NTCreateAndX as well as the level 0x107 -+ * TRANS2_QUERY_PATH_INFORMATION API. The level 0x107, SMB_QUERY_FILE_ALL_INFO -+ * responds with the AccessFlags. -+ * The AccessFlags specifies the access permissions a caller has to the -+ * file and can have any suitable combination of the following values: -+ */ -+ -+#define FILE_READ_DATA 0x00000001 /* Data can be read from the file */ -+#define FILE_WRITE_DATA 0x00000002 /* Data can be written to the file */ -+#define FILE_APPEND_DATA 0x00000004 /* Data can be appended to the file */ -+#define FILE_READ_EA 0x00000008 /* Extended attributes associated */ -+ /* with the file can be read */ -+#define FILE_WRITE_EA 0x00000010 /* Extended attributes associated */ -+ /* with the file can be written */ -+#define FILE_EXECUTE 0x00000020 /*Data can be read into memory from */ -+ /* the file using system paging I/O */ -+#define FILE_DELETE_CHILD 0x00000040 -+#define FILE_READ_ATTRIBUTES 0x00000080 /* Attributes associated with the */ -+ /* file can be read */ -+#define FILE_WRITE_ATTRIBUTES 0x00000100 /* Attributes associated with the */ -+ /* file can be written */ -+#define DELETE 0x00010000 /* The file can be deleted */ -+#define READ_CONTROL 0x00020000 /* The access control list and */ -+ /* ownership associated with the */ -+ /* file can be read */ -+#define WRITE_DAC 0x00040000 /* The access control list and */ -+ /* ownership associated with the */ -+ /* file can be written. */ -+#define WRITE_OWNER 0x00080000 /* Ownership information associated */ -+ /* with the file can be written */ -+#define SYNCHRONIZE 0x00100000 /* The file handle can waited on to */ -+ /* synchronize with the completion */ -+ /* of an input/output request */ -+#define GENERIC_ALL 0x10000000 -+#define GENERIC_EXECUTE 0x20000000 -+#define GENERIC_WRITE 0x40000000 -+#define GENERIC_READ 0x80000000 -+ /* In summary - Relevant file */ -+ /* access flags from CIFS are */ -+ /* file_read_data, file_write_data */ -+ /* file_execute, file_read_attributes */ -+ /* write_dac, and delete. */ -+ -+/* -+ * Invalid readdir handle -+ */ -+#define CIFS_NO_HANDLE 0xFFFF -+ -+/* IPC$ in ASCII */ -+#define CIFS_IPC_RESOURCE "\x49\x50\x43\x24" -+ -+/* IPC$ in Unicode */ -+#define CIFS_IPC_UNICODE_RESOURCE "\x00\x49\x00\x50\x00\x43\x00\x24\x00\x00" -+ -+/* Unicode Null terminate 2 bytes of 0 */ -+#define UNICODE_NULL "\x00\x00" -+#define ASCII_NULL 0x00 -+ -+/* -+ * Server type values (returned on EnumServer API -+ */ -+#define CIFS_SV_TYPE_DC 0x00000008 -+#define CIFS_SV_TYPE_BACKDC 0x00000010 -+ -+/* -+ * Alias type flags (From EnumAlias API call -+ */ -+#define CIFS_ALIAS_TYPE_FILE 0x0001 -+#define CIFS_SHARE_TYPE_FILE 0x0000 -+ -+/* -+ * File Attribute flags -+ */ -+#define ATTR_READONLY 0x0001 -+#define ATTR_HIDDEN 0x0002 -+#define ATTR_SYSTEM 0x0004 -+#define ATTR_VOLUME 0x0008 -+#define ATTR_DIRECTORY 0x0010 -+#define ATTR_ARCHIVE 0x0020 -+#define ATTR_DEVICE 0x0040 -+#define ATTR_NORMAL 0x0080 -+#define ATTR_TEMPORARY 0x0100 -+#define ATTR_SPARSE 0x0200 -+#define ATTR_REPARSE 0x0400 -+#define ATTR_COMPRESSED 0x0800 -+#define ATTR_OFFLINE 0x1000 /* ie file not immediately available - offline storage */ -+#define ATTR_NOT_CONTENT_INDEXED 0x2000 -+#define ATTR_ENCRYPTED 0x4000 -+#define ATTR_POSIX_SEMANTICS 0x01000000 -+#define ATTR_BACKUP_SEMANTICS 0x02000000 -+#define ATTR_DELETE_ON_CLOSE 0x04000000 -+#define ATTR_SEQUENTIAL_SCAN 0x08000000 -+#define ATTR_RANDOM_ACCESS 0x10000000 -+#define ATTR_NO_BUFFERING 0x20000000 -+#define ATTR_WRITE_THROUGH 0x80000000 -+ -+/* ShareAccess flags */ -+#define FILE_NO_SHARE 0x00000000 -+#define FILE_SHARE_READ 0x00000001 -+#define FILE_SHARE_WRITE 0x00000002 -+#define FILE_SHARE_DELETE 0x00000004 -+#define FILE_SHARE_ALL 0x00000007 -+ -+/* CreateDisposition flags */ -+#define FILE_SUPERSEDE 0x00000000 -+#define FILE_OPEN 0x00000001 -+#define FILE_CREATE 0x00000002 -+#define FILE_OPEN_IF 0x00000003 -+#define FILE_OVERWRITE 0x00000004 -+#define FILE_OVERWRITE_IF 0x00000005 -+ -+/* CreateOptions */ -+#define CREATE_NOT_FILE 0x00000001 /* if set must not be file */ -+#define CREATE_WRITE_THROUGH 0x00000002 -+#define CREATE_NOT_DIR 0x00000040 /* if set must not be directory */ -+#define CREATE_RANDOM_ACCESS 0x00000800 -+#define CREATE_DELETE_ON_CLOSE 0x00001000 -+#define OPEN_REPARSE_POINT 0x00200000 -+ -+/* ImpersonationLevel flags */ -+#define SECURITY_ANONYMOUS 0 -+#define SECURITY_IDENTIFICATION 1 -+#define SECURITY_IMPERSONATION 2 -+#define SECURITY_DELEGATION 3 -+ -+/* SecurityFlags */ -+#define SECURITY_CONTEXT_TRACKING 0x01 -+#define SECURITY_EFFECTIVE_ONLY 0x02 -+ -+/* -+ * Default PID value, used in all SMBs where the PID is not important -+ */ -+#define CIFS_DFT_PID 0x1234 -+ -+/* -+ * We use the same routine for Copy and Move SMBs. This flag is used to -+ * distinguish -+ */ -+#define CIFS_COPY_OP 1 -+#define CIFS_RENAME_OP 2 -+ -+#define GETU16(var) (*((__u16 *)var)) /* BB check for endian issues */ -+#define GETU32(var) (*((__u32 *)var)) /* BB check for endian issues */ -+ -+#pragma pack(1) -+ -+struct smb_hdr { -+ __u32 smb_buf_length; /* big endian on wire *//* BB length is only two or three bytes - with one or two byte type preceding it but that is always zero - we could mask the type byte off just in case BB */ -+ __u8 Protocol[4]; -+ __u8 Command; -+ union { -+ struct { -+ __u8 ErrorClass; -+ __u8 Reserved; -+ __u16 Error; /* note: treated as little endian (le) on wire */ -+ } DosError; -+ __u32 CifsError; /* note: le */ -+ } Status; -+ __u8 Flags; -+ __u16 Flags2; /* note: le */ -+ __u16 PidHigh; /* note: le */ -+ union { -+ struct { -+ __u32 SequenceNumber; /* le */ -+ __u32 Reserved; /* zero */ -+ } Sequence; -+ __u8 SecuritySignature[8]; /* le */ -+ } Signature; -+ __u8 pad[2]; -+ __u16 Tid; -+ __u16 Pid; /* note: le */ -+ __u16 Uid; -+ __u16 Mid; -+ __u8 WordCount; -+}; -+/* given a pointer to an smb_hdr retrieve the value of byte count */ -+#define BCC(smb_var) ( *(__u16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) ) ) -+ -+/* given a pointer to an smb_hdr retrieve the pointer to the byte area */ -+#define pByteArea(smb_var) ((char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) + 2 ) -+ -+/* -+ * Computer Name Length -+ */ -+#define CNLEN 15 -+ -+/* -+ * Share Name Length @S8A -+ * Note: This length is limited by the SMB used to get @S8A -+ * the Share info. NetShareEnum only returns 13 @S8A -+ * chars, including the null termination. @S8A -+ */ -+#define SNLEN 12 /*@S8A */ -+ -+/* -+ * Comment Length -+ */ -+#define MAXCOMMENTLEN 40 -+ -+/* -+ * The OS/2 maximum path name -+ */ -+#define MAX_PATHCONF 256 -+ -+/* -+ * SMB frame definitions (following must be packed structs) -+ * See the SNIA CIFS Specification for details. -+ * -+ * The Naming convention is the lower case version of the -+ * smb command code name for the struct and this is typedef to the -+ * uppercase version of the same name with the prefix SMB_ removed -+ * for brevity. Although typedefs are not commonly used for -+ * structure definitions in the Linux kernel, their use in the -+ * CIFS standards document, which this code is based on, may -+ * make this one of the cases where typedefs for structures make -+ * sense to improve readability for readers of the standards doc. -+ * Typedefs can always be removed later if they are too distracting -+ * and they are only used for the CIFSs PDUs themselves, not -+ * internal cifs vfs structures -+ * -+ */ -+ -+typedef struct negotiate_req { -+ struct smb_hdr hdr; /* wct = 0 */ -+ __u16 ByteCount; -+ unsigned char DialectsArray[1]; -+} NEGOTIATE_REQ; -+ -+typedef struct negotiate_rsp { -+ struct smb_hdr hdr; /* wct = 17 */ -+ __u16 DialectIndex; -+ __u8 SecurityMode; -+ __u16 MaxMpxCount; -+ __u16 MaxNumberVcs; -+ __u32 MaxBufferSize; -+ __u32 MaxRawSize; -+ __u32 SessionKey; -+ __u32 Capabilities; /* see below */ -+ __u32 SystemTimeLow; -+ __u32 SystemTimeHigh; -+ __u16 ServerTimeZone; -+ __u8 EncryptionKeyLength; -+ __u16 ByteCount; -+ union { -+ unsigned char EncryptionKey[1]; /* if cap extended security is off */ -+ /* followed by Domain name - if extended security is off */ -+ /* followed by 16 bytes of server GUID */ -+ /* followed by security blob if cap_extended_security negotiated */ -+ struct { -+ unsigned char GUID[16]; -+ unsigned char SecurityBlob[1]; -+ } extended_response; -+ } u; -+} NEGOTIATE_RSP; -+ -+/* SecurityMode bits */ -+#define SECMODE_USER 0x01 /* off indicates share level security */ -+#define SECMODE_PW_ENCRYPT 0x02 -+#define SECMODE_SIGN_ENABLED 0x04 /* SMB security signatures enabled */ -+#define SECMODE_SIGN_REQUIRED 0x08 /* SMB security signatures required */ -+ -+/* Negotiate response Capabilities */ -+#define CAP_RAW_MODE 0x00000001 -+#define CAP_MPX_MODE 0x00000002 -+#define CAP_UNICODE 0x00000004 -+#define CAP_LARGE_FILES 0x00000008 -+#define CAP_NT_SMBS 0x00000010 /* implies CAP_NT_FIND */ -+#define CAP_RPC_REMOTE_APIS 0x00000020 -+#define CAP_STATUS32 0x00000040 -+#define CAP_LEVEL_II_OPLOCKS 0x00000080 -+#define CAP_LOCK_AND_READ 0x00000100 -+#define CAP_NT_FIND 0x00000200 -+#define CAP_DFS 0x00001000 -+#define CAP_INFOLEVEL_PASSTHRU 0x00002000 -+#define CAP_LARGE_READ_X 0x00004000 -+#define CAP_LARGE_WRITE_X 0x00008000 -+#define CAP_UNIX 0x00800000 -+#define CAP_RESERVED 0x02000000 -+#define CAP_BULK_TRANSFER 0x20000000 -+#define CAP_COMPRESSED_DATA 0x40000000 -+#define CAP_EXTENDED_SECURITY 0x80000000 -+ -+typedef union smb_com_session_setup_andx { -+ struct { /* request format */ -+ struct smb_hdr hdr; /* wct = 12 */ -+ __u8 AndXCommand; -+ __u8 AndXReserved; -+ __u16 AndXOffset; -+ __u16 MaxBufferSize; -+ __u16 MaxMpxCount; -+ __u16 VcNumber; -+ __u32 SessionKey; -+ __u16 SecurityBlobLength; -+ __u32 Reserved; -+ __u32 Capabilities; /* see below */ -+ __u16 ByteCount; -+ unsigned char SecurityBlob[1]; /* followed by */ -+ /* STRING NativeOS */ -+ /* STRING NativeLanMan */ -+ } req; /* NTLM request format (with extended security */ -+ -+ struct { /* request format */ -+ struct smb_hdr hdr; /* wct = 13 */ -+ __u8 AndXCommand; -+ __u8 AndXReserved; -+ __u16 AndXOffset; -+ __u16 MaxBufferSize; -+ __u16 MaxMpxCount; -+ __u16 VcNumber; -+ __u32 SessionKey; -+ __u16 CaseInsensitivePasswordLength; /* ASCII password length */ -+ __u16 CaseSensitivePasswordLength; /* Unicode password length */ -+ __u32 Reserved; /* see below */ -+ __u32 Capabilities; -+ __u16 ByteCount; -+ unsigned char CaseInsensitivePassword[1]; /* followed by: */ -+ /* unsigned char * CaseSensitivePassword; */ -+ /* STRING AccountName */ -+ /* STRING PrimaryDomain */ -+ /* STRING NativeOS */ -+ /* STRING NativeLanMan */ -+ } req_no_secext; /* NTLM request format (without extended security */ -+ -+ struct { /* default (NTLM) response format */ -+ struct smb_hdr hdr; /* wct = 4 */ -+ __u8 AndXCommand; -+ __u8 AndXReserved; -+ __u16 AndXOffset; -+ __u16 Action; /* see below */ -+ __u16 SecurityBlobLength; -+ __u16 ByteCount; -+ unsigned char SecurityBlob[1]; /* followed by */ -+/* unsigned char * NativeOS; */ -+/* unsigned char * NativeLanMan; */ -+/* unsigned char * PrimaryDomain; */ -+ } resp; /* NTLM response format (with or without extended security */ -+ -+ struct { /* request format */ -+ struct smb_hdr hdr; /* wct = 10 */ -+ __u8 AndXCommand; -+ __u8 AndXReserved; -+ __u16 AndXOffset; -+ __u16 MaxBufferSize; -+ __u16 MaxMpxCount; -+ __u16 VcNumber; -+ __u32 SessionKey; -+ __u16 PassswordLength; -+ __u32 Reserved; -+ __u16 ByteCount; -+ unsigned char AccountPassword[1]; /* followed by */ -+ /* STRING AccountName */ -+ /* STRING PrimaryDomain */ -+ /* STRING NativeOS */ -+ /* STRING NativeLanMan */ -+ } old_req; /* pre-NTLM (LANMAN2.1) request format */ -+ -+ struct { /* default (NTLM) response format */ -+ struct smb_hdr hdr; /* wct = 3 */ -+ __u8 AndXCommand; -+ __u8 AndXReserved; -+ __u16 AndXOffset; -+ __u16 Action; /* see below */ -+ __u16 ByteCount; -+ unsigned char NativeOS[1]; /* followed by */ -+/* unsigned char * NativeLanMan; */ -+/* unsigned char * PrimaryDomain; */ -+ } old_resp; /* pre-NTLM (LANMAN2.1) response format */ -+} SESSION_SETUP_ANDX; -+ -+#define CIFS_NETWORK_OPSYS "CIFS VFS Client for Linux" -+ -+/* Capabilities bits (for NTLM SessSetup request) */ -+#define CAP_UNICODE 0x00000004 -+#define CAP_LARGE_FILES 0x00000008 -+#define CAP_NT_SMBS 0x00000010 -+#define CAP_STATUS32 0x00000040 -+#define CAP_LEVEL_II_OPLOCKS 0x00000080 -+#define CAP_NT_FIND 0x00000200 /* reserved should be zero (presumably because NT_SMBs implies the same thing) */ -+#define CAP_BULK_TRANSFER 0x20000000 -+#define CAP_EXTENDED_SECURITY 0x80000000 -+ -+/* Action bits */ -+#define GUEST_LOGIN 1 -+ -+typedef struct smb_com_tconx_req { -+ struct smb_hdr hdr; /* wct = 4 */ -+ __u8 AndXCommand; -+ __u8 AndXReserved; -+ __u16 AndXOffset; -+ __u16 Flags; /* see below */ -+ __u16 PasswordLength; -+ __u16 ByteCount; -+ unsigned char Password[1]; /* followed by */ -+/* STRING Path *//* \\server\share name */ -+ /* STRING Service */ -+} TCONX_REQ; -+ -+typedef struct smb_com_tconx_rsp { -+ struct smb_hdr hdr; /* wct = 3 *//* note that Win2000 has sent wct=7 in some cases on responses. Four unspecified words followed OptionalSupport */ -+ __u8 AndXCommand; -+ __u8 AndXReserved; -+ __u16 AndXOffset; -+ __u16 OptionalSupport; /* see below */ -+ __u16 ByteCount; -+ unsigned char Service[1]; /* always ASCII, not Unicode */ -+ /* STRING NativeFileSystem */ -+} TCONX_RSP; -+ -+/* tree connect Flags */ -+#define DISCONNECT_TID 0x0001 -+#define TCON_EXTENDED_SECINFO 0x0008 -+/* OptionalSupport bits */ -+#define SMB_SUPPORT_SEARCH_BITS 0x0001 /* must have bits (exclusive searches suppt. */ -+#define SMB_SHARE_IS_IN_DFS 0x0002 -+ -+typedef struct smb_com_logoff_andx_req { -+ -+ struct smb_hdr hdr; /* wct = 2 */ -+ __u8 AndXCommand; -+ __u8 AndXReserved; -+ __u16 AndXOffset; -+ __u16 ByteCount; -+} LOGOFF_ANDX_REQ; -+ -+typedef struct smb_com_logoff_andx_rsp { -+ struct smb_hdr hdr; /* wct = 2 */ -+ __u8 AndXCommand; -+ __u8 AndXReserved; -+ __u16 AndXOffset; -+ __u16 ByteCount; -+} LOGOFF_ANDX_RSP; -+ -+typedef union smb_com_tree_disconnect { /* as an altetnative can use flag on tree_connect PDU to effect disconnect *//* probably the simplest SMB PDU */ -+ struct { -+ struct smb_hdr hdr; /* wct = 0 */ -+ __u16 ByteCount; /* bcc = 0 */ -+ } req; -+ struct { -+ struct smb_hdr hdr; /* wct = 0 */ -+ __u16 ByteCount; /* bcc = 0 */ -+ } resp; -+} TREE_DISCONNECT; -+ -+typedef struct smb_com_close_req { -+ struct smb_hdr hdr; /* wct = 3 */ -+ __u16 FileID; -+ __u32 LastWriteTime; /* should be zero */ -+ __u16 ByteCount; /* 0 */ -+} CLOSE_REQ; -+ -+typedef struct smb_com_close_rsp { -+ struct smb_hdr hdr; /* wct = 0 */ -+ __u16 ByteCount; /* bct = 0 */ -+} CLOSE_RSP; -+ -+typedef struct smb_com_findclose_req { -+ struct smb_hdr hdr; /* wct = 1 */ -+ __u16 FileID; -+ __u16 ByteCount; /* 0 */ -+} FINDCLOSE_REQ; -+ -+/* OpenFlags */ -+#define REQ_OPLOCK 0x00000002 -+#define REQ_BATCHOPLOCK 0x00000004 -+#define REQ_OPENDIRONLY 0x00000008 -+ -+typedef struct smb_com_open_req { /* also handles create */ -+ struct smb_hdr hdr; /* wct = 24 */ -+ __u8 AndXCommand; -+ __u8 AndXReserved; -+ __u16 AndXOffset; -+ __u8 Reserved; /* Must Be Zero */ -+ __u16 NameLength; -+ __u32 OpenFlags; -+ __u32 RootDirectoryFid; -+ __u32 DesiredAccess; -+ __u64 AllocationSize; -+ __u32 FileAttributes; -+ __u32 ShareAccess; -+ __u32 CreateDisposition; -+ __u32 CreateOptions; -+ __u32 ImpersonationLevel; -+ __u8 SecurityFlags; -+ __u16 ByteCount; -+ char fileName[1]; -+} OPEN_REQ; -+ -+/* open response: oplock levels */ -+#define OPLOCK_NONE 0 -+#define OPLOCK_EXCLUSIVE 1 -+#define OPLOCK_BATCH 2 -+#define OPLOCK_READ 3 /* level 2 oplock */ -+ -+/* open response for CreateAction shifted left */ -+#define CIFS_CREATE_ACTION 0x20000 /* file created */ -+ -+typedef struct smb_com_open_rsp { -+ struct smb_hdr hdr; /* wct = 34 BB */ -+ __u8 AndXCommand; -+ __u8 AndXReserved; -+ __u16 AndXOffset; -+ __u8 OplockLevel; -+ __u16 Fid; -+ __u32 CreateAction; -+ __u64 CreationTime; -+ __u64 LastAccessTime; -+ __u64 LastWriteTime; -+ __u64 ChangeTime; -+ __u32 FileAttributes; -+ __u64 AllocationSize; -+ __u64 EndOfFile; -+ __u16 FileType; -+ __u16 DeviceState; -+ __u8 DirectoryFlag; -+ __u16 ByteCount; /* bct = 0 */ -+} OPEN_RSP; -+ -+typedef struct smb_com_write_req { -+ struct smb_hdr hdr; /* wct = 14 */ -+ __u8 AndXCommand; -+ __u8 AndXReserved; -+ __u16 AndXOffset; -+ __u16 Fid; -+ __u32 OffsetLow; -+ __u32 Reserved; -+ __u16 WriteMode; -+ __u16 Remaining; -+ __u16 DataLengthHigh; -+ __u16 DataLengthLow; -+ __u16 DataOffset; -+ __u32 OffsetHigh; -+ __u16 ByteCount; -+ __u8 Pad; /* BB check for whether padded to DWORD boundary and optimum performance here */ -+ char Data[1]; -+} WRITE_REQ; -+ -+typedef struct smb_com_write_rsp { -+ struct smb_hdr hdr; /* wct = 6 */ -+ __u8 AndXCommand; -+ __u8 AndXReserved; -+ __u16 AndXOffset; -+ __u16 Count; -+ __u16 Remaining; -+ __u32 Reserved; -+ __u16 ByteCount; -+} WRITE_RSP; -+ -+typedef struct smb_com_read_req { -+ struct smb_hdr hdr; /* wct = 12 */ -+ __u8 AndXCommand; -+ __u8 AndXReserved; -+ __u16 AndXOffset; -+ __u16 Fid; -+ __u32 OffsetLow; -+ __u16 MaxCount; -+ __u16 MinCount; /* obsolete */ -+ __u32 MaxCountHigh; -+ __u16 Remaining; -+ __u32 OffsetHigh; -+ __u16 ByteCount; -+} READ_REQ; -+ -+typedef struct smb_com_read_rsp { -+ struct smb_hdr hdr; /* wct = 12 */ -+ __u8 AndXCommand; -+ __u8 AndXReserved; -+ __u16 AndXOffset; -+ __u16 Remaining; -+ __u16 DataCompactionMode; -+ __u16 Reserved; -+ __u16 DataLength; -+ __u16 DataOffset; -+ __u16 DataLengthHigh; -+ __u64 Reserved2; -+ __u16 ByteCount; -+ __u8 Pad; /* BB check for whether padded to DWORD boundary and optimum performance here */ -+ char Data[1]; -+} READ_RSP; -+ -+typedef struct locking_andx_range { -+ __u16 Pid; -+ __u16 Pad; -+ __u32 OffsetHigh; -+ __u32 OffsetLow; -+ __u32 LengthHigh; -+ __u32 LengthLow; -+} LOCKING_ANDX_RANGE; -+ -+#define LOCKING_ANDX_SHARED_LOCK 0x01 -+#define LOCKING_ANDX_OPLOCK_RELEASE 0x02 -+#define LOCKING_ANDX_CHANGE_LOCKTYPE 0x04 -+#define LOCKING_ANDX_CANCEL_LOCK 0x08 -+#define LOCKING_ANDX_LARGE_FILES 0x10 /* always on for us */ -+ -+typedef struct smb_com_lock_req { -+ struct smb_hdr hdr; /* wct = 8 */ -+ __u8 AndXCommand; -+ __u8 AndXReserved; -+ __u16 AndXOffset; -+ __u16 Fid; -+ __u8 LockType; -+ __u8 OplockLevel; -+ __u32 Timeout; -+ __u16 NumberOfUnlocks; -+ __u16 NumberOfLocks; -+ __u16 ByteCount; -+ LOCKING_ANDX_RANGE Locks[1]; -+} LOCK_REQ; -+ -+typedef struct smb_com_lock_rsp { -+ struct smb_hdr hdr; /* wct = 2 */ -+ __u8 AndXCommand; -+ __u8 AndXReserved; -+ __u16 AndXOffset; -+ __u16 ByteCount; -+} LOCK_RSP; -+ -+typedef struct smb_com_rename_req { -+ struct smb_hdr hdr; /* wct = 1 */ -+ __u16 SearchAttributes; /* target file attributes */ -+ __u16 ByteCount; -+ __u8 BufferFormat; /* 4 = ASCII or Unicode */ -+ unsigned char OldFileName[1]; -+ /* followed by __u8 BufferFormat2 */ -+ /* followed by NewFileName */ -+} RENAME_REQ; -+ -+ /* copy request flags */ -+#define COPY_MUST_BE_FILE 0x0001 -+#define COPY_MUST_BE_DIR 0x0002 -+#define COPY_TARGET_MODE_ASCII 0x0004 /* if not set, binary */ -+#define COPY_SOURCE_MODE_ASCII 0x0008 /* if not set, binary */ -+#define COPY_VERIFY_WRITES 0x0010 -+#define COPY_TREE 0x0020 -+ -+typedef struct smb_com_copy_req { -+ struct smb_hdr hdr; /* wct = 3 */ -+ __u16 Tid2; -+ __u16 OpenFunction; -+ __u16 Flags; -+ __u16 ByteCount; -+ __u8 BufferFormat; /* 4 = ASCII or Unicode */ -+ unsigned char OldFileName[1]; -+ /* followed by __u8 BufferFormat2 */ -+ /* followed by NewFileName string */ -+} COPY_REQ; -+ -+typedef struct smb_com_copy_rsp { -+ struct smb_hdr hdr; /* wct = 1 */ -+ __u16 CopyCount; /* number of files copied */ -+ __u16 ByteCount; /* may be zero */ -+ __u8 BufferFormat; /* 0x04 - only present if errored file follows */ -+ unsigned char ErrorFileName[1]; /* only present if error in copy */ -+} COPY_RSP; -+ -+#define CREATE_HARD_LINK 0x103 -+#define MOVEFILE_COPY_ALLOWED 0x0002 -+#define MOVEFILE_REPLACE_EXISTING 0x0001 -+ -+typedef struct smb_com_nt_rename_req { /* A5 - also used for create hardlink */ -+ struct smb_hdr hdr; /* wct = 4 */ -+ __u16 SearchAttributes; /* target file attributes */ -+ __u16 Flags; /* spec says Information Level */ -+ __u32 ClusterCount; -+ __u16 ByteCount; -+ __u8 BufferFormat; /* 4 = ASCII or Unicode */ -+ unsigned char OldFileName[1]; -+ /* followed by __u8 BufferFormat2 */ -+ /* followed by NewFileName */ -+} NT_RENAME_REQ; -+ -+typedef struct smb_com_rename_rsp { -+ struct smb_hdr hdr; /* wct = 0 */ -+ __u16 ByteCount; /* bct = 0 */ -+} RENAME_RSP; -+ -+typedef struct smb_com_delete_file_req { -+ struct smb_hdr hdr; /* wct = 1 */ -+ __u16 SearchAttributes; -+ __u16 ByteCount; -+ __u8 BufferFormat; /* 4 = ASCII */ -+ unsigned char fileName[1]; -+} DELETE_FILE_REQ; -+ -+typedef struct smb_com_delete_file_rsp { -+ struct smb_hdr hdr; /* wct = 0 */ -+ __u16 ByteCount; /* bct = 0 */ -+} DELETE_FILE_RSP; -+ -+typedef struct smb_com_delete_directory_req { -+ struct smb_hdr hdr; /* wct = 0 */ -+ __u16 ByteCount; -+ __u8 BufferFormat; /* 4 = ASCII */ -+ unsigned char DirName[1]; -+} DELETE_DIRECTORY_REQ; -+ -+typedef struct smb_com_delete_directory_rsp { -+ struct smb_hdr hdr; /* wct = 0 */ -+ __u16 ByteCount; /* bct = 0 */ -+} DELETE_DIRECTORY_RSP; -+ -+typedef struct smb_com_create_directory_req { -+ struct smb_hdr hdr; /* wct = 0 */ -+ __u16 ByteCount; -+ __u8 BufferFormat; /* 4 = ASCII */ -+ unsigned char DirName[1]; -+} CREATE_DIRECTORY_REQ; -+ -+typedef struct smb_com_create_directory_rsp { -+ struct smb_hdr hdr; /* wct = 0 */ -+ __u16 ByteCount; /* bct = 0 */ -+} CREATE_DIRECTORY_RSP; -+ -+/***************************************************/ -+/* NT Transact structure defintions follow */ -+/* Currently only ioctl and notify are implemented */ -+/***************************************************/ -+typedef struct smb_com_transaction_ioctl_req { -+ struct smb_hdr hdr; /* wct = 23 */ -+ __u8 MaxSetupCount; -+ __u16 Reserved; -+ __u32 TotalParameterCount; -+ __u32 TotalDataCount; -+ __u32 MaxParameterCount; -+ __u32 MaxDataCount; -+ __u32 ParameterCount; -+ __u32 ParameterOffset; -+ __u32 DataCount; -+ __u32 DataOffset; -+ __u8 SetupCount; /* four setup words follow subcommand */ -+ /* SNIA spec incorrectly included spurious pad here */ -+ __u16 SubCommand;/* 2 = IOCTL/FSCTL */ -+ __u32 FunctionCode; -+ __u16 Fid; -+ __u8 IsFsctl; /* 1 = File System Control, 0 = device control (IOCTL)*/ -+ __u8 IsRootFlag; /* 1 = apply command to root of share (must be DFS share)*/ -+ __u16 ByteCount; -+ __u8 Pad[3]; -+ __u8 Data[1]; -+} TRANSACT_IOCTL_REQ; -+ -+typedef struct smb_com_transaction_ioctl_rsp { -+ struct smb_hdr hdr; /* wct = 19 */ -+ __u8 Reserved[3]; -+ __u32 TotalParameterCount; -+ __u32 TotalDataCount; -+ __u32 ParameterCount; -+ __u32 ParameterOffset; -+ __u32 ParameterDisplacement; -+ __u32 DataCount; -+ __u32 DataOffset; -+ __u32 DataDisplacement; -+ __u8 SetupCount; /* 1 */ -+ __u16 ReturnedDataLen; -+ __u16 ByteCount; -+ __u8 Pad[3]; -+} TRANSACT_IOCTL_RSP; -+ -+typedef struct smb_com_transaction_change_notify_req { -+ struct smb_hdr hdr; /* wct = 23 */ -+ __u8 MaxSetupCount; -+ __u16 Reserved; -+ __u32 TotalParameterCount; -+ __u32 TotalDataCount; -+ __u32 MaxParameterCount; -+ __u32 MaxDataCount; -+ __u32 ParameterCount; -+ __u32 ParameterOffset; -+ __u32 DataCount; -+ __u32 DataOffset; -+ __u8 SetupCount; /* four setup words follow subcommand */ -+ /* SNIA spec incorrectly included spurious pad here */ -+ __u16 SubCommand;/* 4 = Change Notify */ -+ __u32 CompletionFilter; /* operation to monitor */ -+ __u16 Fid; -+ __u8 WatchTree; /* 1 = Monitor subdirectories */ -+ __u8 Reserved2; -+ __u16 ByteCount; -+/* __u8 Pad[3];*/ -+/* __u8 Data[1];*/ -+} TRANSACT_CHANGE_NOTIFY_REQ; -+ -+typedef struct smb_com_transaction_change_notify_rsp { -+ struct smb_hdr hdr; /* wct = 18 */ -+ __u8 Reserved[3]; -+ __u32 TotalParameterCount; -+ __u32 TotalDataCount; -+ __u32 ParameterCount; -+ __u32 ParameterOffset; -+ __u32 ParameterDisplacement; -+ __u32 DataCount; -+ __u32 DataOffset; -+ __u32 DataDisplacement; -+ __u8 SetupCount; /* 0 */ -+ __u16 ByteCount; -+ /* __u8 Pad[3]; */ -+} TRANSACT_CHANGE_NOTIFY_RSP; -+/* Completion Filter flags for Notify */ -+#define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001 -+#define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002 -+#define FILE_NOTIFY_CHANGE_NAME 0x00000003 -+#define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004 -+#define FILE_NOTIFY_CHANGE_SIZE 0x00000008 -+#define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010 -+#define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020 -+#define FILE_NOTIFY_CHANGE_CREATION 0x00000040 -+#define FILE_NOTIFY_CHANGE_EA 0x00000080 -+#define FILE_NOTIFY_CHANGE_SECURITY 0x00000100 -+#define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200 -+#define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400 -+#define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800 -+ -+#define FILE_ACTION_ADDED 0x00000001 -+#define FILE_ACTION_REMOVED 0x00000002 -+#define FILE_ACTION_MODIFIED 0x00000003 -+#define FILE_ACTION_RENAMED_OLD_NAME 0x00000004 -+#define FILE_ACTION_RENAMED_NEW_NAME 0x00000005 -+#define FILE_ACTION_ADDED_STREAM 0x00000006 -+#define FILE_ACTION_REMOVED_STREAM 0x00000007 -+#define FILE_ACTION_MODIFIED_STREAM 0x00000008 -+ -+/* response contains array of the following structures */ -+struct file_notify_information { -+ __u32 NextEntryOffset; -+ __u32 Action; -+ __u32 FileNameLength; -+ __u8 FileName[1]; -+}; -+ -+struct reparse_data { -+ __u32 ReparseTag; -+ __u16 ReparseDataLength; -+ __u16 Reserved; -+ __u16 AltNameOffset; -+ __u16 AltNameLen; -+ __u16 TargetNameOffset; -+ __u16 TargetNameLen; -+ char LinkNamesBuf[1]; -+}; -+ -+struct cifs_quota_data { -+ __u32 rsrvd1; /* 0 */ -+ __u32 sid_size; -+ __u64 rsrvd2; /* 0 */ -+ __u64 space_used; -+ __u64 soft_limit; -+ __u64 hard_limit; -+ char sid[1]; /* variable size? */ -+}; -+ -+/* quota sub commands */ -+#define QUOTA_LIST_CONTINUE 0 -+#define QUOTA_LIST_START 0x100 -+#define QUOTA_FOR_SID 0x101 -+ -+typedef union smb_com_transaction2 { -+ struct { -+ struct smb_hdr hdr; /* wct = 14+ */ -+ __u16 TotalParameterCount; -+ __u16 TotalDataCount; -+ __u16 MaxParameterCount; -+ __u16 MaxDataCount; -+ __u8 MaxSetupCount; -+ __u8 Reserved; -+ __u16 Flags; -+ __u32 Timeout; -+ __u16 Reserved2; -+ __u16 ParameterCount; -+ __u16 ParameterOffset; -+ __u16 DataCount; -+ __u16 DataOffset; -+ __u8 SetupCount; -+ __u8 Reserved3; -+ __u16 SubCommand; /* 1st setup word - can be followed by SetupCount words */ -+ __u16 ByteCount; /* careful - setupcount is not always one */ -+ } req; -+ struct { -+ struct smb_hdr hdr; /* wct = 0 */ -+ __u16 TotalParameterCount; -+ __u16 TotalDataCount; -+ __u16 Reserved; -+ __u16 ParameterCount; -+ __u16 ParamterOffset; -+ __u16 ParameterDisplacement; -+ __u16 DataCount; -+ __u16 DataOffset; -+ __u16 DataDisplacement; -+ __u8 SetupCount; -+ __u8 Reserved1; /* should be zero setup words following */ -+ __u16 ByteCount; -+ __u16 Reserved2; /* parameter word reserved - present for infolevels > 100 */ -+ /* data area follows */ -+ } resp; -+} TRANSACTION2; -+ -+/* PathInfo/FileInfo infolevels */ -+#define SMB_INFO_STANDARD 1 -+#define SMB_INFO_QUERY_EAS_FROM_LIST 3 -+#define SMB_INFO_QUERY_ALL_EAS 4 -+#define SMB_INFO_IS_NAME_VALID 6 -+#define SMB_QUERY_FILE_BASIC_INFO 0x101 -+#define SMB_QUERY_FILE_STANDARD_INFO 0x102 -+#define SMB_QUERY_FILE_EA_INFO 0x103 -+#define SMB_QUERY_FILE_NAME_INFO 0x104 -+#define SMB_QUERY_FILE_ALLOCATION_INFO 0x105 -+#define SMB_QUERY_FILE_END_OF_FILEINFO 0x106 -+#define SMB_QUERY_FILE_ALL_INFO 0x107 -+#define SMB_QUERY_ALT_NAME_INFO 0x108 -+#define SMB_QUERY_FILE_STREAM_INFO 0x109 -+#define SMB_QUERY_FILE_COMPRESSION_INFO 0x10B -+#define SMB_QUERY_FILE_UNIX_BASIC 0x200 -+#define SMB_QUERY_FILE_UNIX_LINK 0x201 -+ -+#define SMB_SET_FILE_BASIC_INFO 0x101 -+#define SMB_SET_FILE_DISPOSITION_INFO 0x102 -+#define SMB_SET_FILE_ALLOCATION_INFO 0x103 -+#define SMB_SET_FILE_END_OF_FILE_INFO 0x104 -+#define SMB_SET_FILE_UNIX_BASIC 0x200 -+#define SMB_SET_FILE_UNIX_LINK 0x201 -+#define SMB_SET_FILE_UNIX_HLINK 0x203 -+#define SMB_SET_FILE_BASIC_INFO2 0x3ec -+#define SMB_SET_FILE_RENAME_INFORMATION 0x3f2 -+#define SMB_FILE_ALL_INFO2 0x3fa -+#define SMB_SET_FILE_ALLOCATION_INFO2 0x3fb -+#define SMB_SET_FILE_END_OF_FILE_INFO2 0x3fc -+#define SMB_FILE_MOVE_CLUSTER_INFO 0x407 -+#define SMB_FILE_QUOTA_INFO 0x408 -+#define SMB_FILE_REPARSEPOINT_INFO 0x409 -+#define SMB_FILE_MAXIMUM_INFO 0x40d -+ -+/* Find File infolevels */ -+#define SMB_FIND_FILE_DIRECTORY_INFO 0x101 -+#define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102 -+#define SMB_FIND_FILE_NAMES_INFO 0x103 -+#define SMB_FIND_FILE_BOTH_DIRECTORY_INFO 0x104 -+#define SMB_FIND_FILE_UNIX 0x202 -+ -+typedef struct smb_com_transaction2_qpi_req { -+ struct smb_hdr hdr; /* wct = 14+ */ -+ __u16 TotalParameterCount; -+ __u16 TotalDataCount; -+ __u16 MaxParameterCount; -+ __u16 MaxDataCount; -+ __u8 MaxSetupCount; -+ __u8 Reserved; -+ __u16 Flags; -+ __u32 Timeout; -+ __u16 Reserved2; -+ __u16 ParameterCount; -+ __u16 ParameterOffset; -+ __u16 DataCount; -+ __u16 DataOffset; -+ __u8 SetupCount; -+ __u8 Reserved3; -+ __u16 SubCommand; /* one setup word */ -+ __u16 ByteCount; -+ __u8 Pad; -+ __u16 InformationLevel; -+ __u32 Reserved4; -+ char FileName[1]; -+} TRANSACTION2_QPI_REQ; -+ -+typedef struct smb_com_transaction2_qpi_rsp { -+ struct smb_hdr hdr; /* wct = 10 + SetupCount */ -+ __u16 TotalParameterCount; -+ __u16 TotalDataCount; -+ __u16 Reserved; -+ __u16 ParameterCount; -+ __u16 ParameterOffset; -+ __u16 ParameterDisplacement; -+ __u16 DataCount; -+ __u16 DataOffset; -+ __u16 DataDisplacement; -+ __u8 SetupCount; -+ __u8 Reserved1; /* should be zero setup words following */ -+ __u16 ByteCount; -+ __u16 Reserved2; /* parameter word reserved - present for infolevels > 100 */ -+} TRANSACTION2_QPI_RSP; -+ -+typedef struct smb_com_transaction2_spi_req { -+ struct smb_hdr hdr; /* wct = 15 */ -+ __u16 TotalParameterCount; -+ __u16 TotalDataCount; -+ __u16 MaxParameterCount; -+ __u16 MaxDataCount; -+ __u8 MaxSetupCount; -+ __u8 Reserved; -+ __u16 Flags; -+ __u32 Timeout; -+ __u16 Reserved2; -+ __u16 ParameterCount; -+ __u16 ParameterOffset; -+ __u16 DataCount; -+ __u16 DataOffset; -+ __u8 SetupCount; -+ __u8 Reserved3; -+ __u16 SubCommand; /* one setup word */ -+ __u16 ByteCount; -+ __u8 Pad; -+ __u16 Pad1; -+ __u16 InformationLevel; -+ __u32 Reserved4; -+ char FileName[1]; -+} TRANSACTION2_SPI_REQ; -+ -+typedef struct smb_com_transaction2_spi_rsp { -+ struct smb_hdr hdr; /* wct = 10 + SetupCount */ -+ __u16 TotalParameterCount; -+ __u16 TotalDataCount; -+ __u16 Reserved; -+ __u16 ParameterCount; -+ __u16 ParameterOffset; -+ __u16 ParameterDisplacement; -+ __u16 DataCount; -+ __u16 DataOffset; -+ __u16 DataDisplacement; -+ __u8 SetupCount; -+ __u8 Reserved1; /* should be zero setup words following */ -+ __u16 ByteCount; -+ __u16 Reserved2; /* parameter word reserved - present for infolevels > 100 */ -+} TRANSACTION2_SPI_RSP; -+ -+struct set_file_rename { -+ __u32 overwrite; /* 1 = overwrite dest */ -+ __u32 root_fid; /* zero */ -+ __u32 target_name_len; -+ char target_name[0]; /* Must be unicode */ -+}; -+ -+struct smb_com_transaction2_sfi_req { -+ struct smb_hdr hdr; /* wct = 15 */ -+ __u16 TotalParameterCount; -+ __u16 TotalDataCount; -+ __u16 MaxParameterCount; -+ __u16 MaxDataCount; -+ __u8 MaxSetupCount; -+ __u8 Reserved; -+ __u16 Flags; -+ __u32 Timeout; -+ __u16 Reserved2; -+ __u16 ParameterCount; -+ __u16 ParameterOffset; -+ __u16 DataCount; -+ __u16 DataOffset; -+ __u8 SetupCount; -+ __u8 Reserved3; -+ __u16 SubCommand; /* one setup word */ -+ __u16 ByteCount; -+ __u8 Pad; -+ __u16 Pad1; -+ __u16 Fid; -+ __u16 InformationLevel; -+ __u16 Reserved4; -+}; -+ -+struct smb_com_transaction2_sfi_rsp { -+ struct smb_hdr hdr; /* wct = 10 + SetupCount */ -+ __u16 TotalParameterCount; -+ __u16 TotalDataCount; -+ __u16 Reserved; -+ __u16 ParameterCount; -+ __u16 ParameterOffset; -+ __u16 ParameterDisplacement; -+ __u16 DataCount; -+ __u16 DataOffset; -+ __u16 DataDisplacement; -+ __u8 SetupCount; -+ __u8 Reserved1; /* should be zero setup words following */ -+ __u16 ByteCount; -+ __u16 Reserved2; /* parameter word reserved - present for infolevels > 100 */ -+}; -+ -+ -+/* -+ * Flags on T2 FINDFIRST and FINDNEXT -+ */ -+#define CIFS_SEARCH_CLOSE_ALWAYS 0x0001 -+#define CIFS_SEARCH_CLOSE_AT_END 0x0002 -+#define CIFS_SEARCH_RETURN_RESUME 0x0004 -+#define CIFS_SEARCH_CONTINUE_FROM_LAST 0x0008 -+#define CIFS_SEARCH_BACKUP_SEARCH 0x0010 -+ -+/* -+ * Size of the resume key on FINDFIRST and FINDNEXT calls -+ */ -+#define CIFS_SMB_RESUME_KEY_SIZE 4 -+ -+typedef struct smb_com_transaction2_ffirst_req { -+ struct smb_hdr hdr; /* wct = 15 */ -+ __u16 TotalParameterCount; -+ __u16 TotalDataCount; -+ __u16 MaxParameterCount; -+ __u16 MaxDataCount; -+ __u8 MaxSetupCount; -+ __u8 Reserved; -+ __u16 Flags; -+ __u32 Timeout; -+ __u16 Reserved2; -+ __u16 ParameterCount; -+ __u16 ParameterOffset; -+ __u16 DataCount; -+ __u16 DataOffset; -+ __u8 SetupCount; /* one */ -+ __u8 Reserved3; -+ __u16 SubCommand; /* TRANS2_FIND_FIRST */ -+ __u16 ByteCount; -+ __u8 Pad; -+ __u16 SearchAttributes; -+ __u16 SearchCount; -+ __u16 SearchFlags; -+ __u16 InformationLevel; -+ __u32 SearchStorageType; -+ char FileName[1]; -+} TRANSACTION2_FFIRST_REQ; -+ -+typedef struct smb_com_transaction2_ffirst_rsp { -+ struct smb_hdr hdr; /* wct = 10 */ -+ __u16 TotalParameterCount; -+ __u16 TotalDataCount; -+ __u16 Reserved; -+ __u16 ParameterCount; -+ __u16 ParameterOffset; -+ __u16 ParameterDisplacement; -+ __u16 DataCount; -+ __u16 DataOffset; -+ __u16 DataDisplacement; -+ __u8 SetupCount; -+ __u8 Reserved1; /* should be zero setup words following */ -+ __u16 ByteCount; -+} TRANSACTION2_FFIRST_RSP; -+ -+typedef struct smb_com_transaction2_ffirst_rsp_parms { -+ __u16 SearchHandle; -+ __u16 SearchCount; -+ __u16 EndofSearch; -+ __u16 EAErrorOffset; -+ __u16 LastNameOffset; -+} T2_FFIRST_RSP_PARMS; -+ -+typedef struct smb_com_transaction2_fnext_req { -+ struct smb_hdr hdr; /* wct = 15 */ -+ __u16 TotalParameterCount; -+ __u16 TotalDataCount; -+ __u16 MaxParameterCount; -+ __u16 MaxDataCount; -+ __u8 MaxSetupCount; -+ __u8 Reserved; -+ __u16 Flags; -+ __u32 Timeout; -+ __u16 Reserved2; -+ __u16 ParameterCount; -+ __u16 ParameterOffset; -+ __u16 DataCount; -+ __u16 DataOffset; -+ __u8 SetupCount; /* one */ -+ __u8 Reserved3; -+ __u16 SubCommand; /* TRANS2_FIND_NEXT */ -+ __u16 ByteCount; -+ __u8 Pad; -+ __u16 SearchHandle; -+ __u16 SearchCount; -+ __u16 InformationLevel; -+ __u32 ResumeKey; -+ __u16 SearchFlags; -+ char ResumeFileName[1]; -+} TRANSACTION2_FNEXT_REQ; -+ -+typedef struct smb_com_transaction2_fnext_rsp { -+ struct smb_hdr hdr; /* wct = 10 */ -+ __u16 TotalParameterCount; -+ __u16 TotalDataCount; -+ __u16 Reserved; -+ __u16 ParameterCount; -+ __u16 ParameterOffset; -+ __u16 ParameterDisplacement; -+ __u16 DataCount; -+ __u16 DataOffset; -+ __u16 DataDisplacement; -+ __u8 SetupCount; -+ __u8 Reserved1; /* should be zero setup words following */ -+ __u16 ByteCount; -+} TRANSACTION2_FNEXT_RSP; -+ -+typedef struct smb_com_transaction2_fnext_rsp_parms { -+ __u16 SearchCount; -+ __u16 EndofSearch; -+ __u16 EAErrorOffset; -+ __u16 LastNameOffset; -+} T2_FNEXT_RSP_PARMS; -+ -+/* QFSInfo Levels */ -+#define SMB_INFO_ALLOCATION 1 -+#define SMB_INFO_VOLUME 2 -+#define SMB_QUERY_FS_VOLUME_INFO 0x102 -+#define SMB_QUERY_FS_SIZE_INFO 0x103 -+#define SMB_QUERY_FS_DEVICE_INFO 0x104 -+#define SMB_QUERY_FS_ATTRIBUTE_INFO 0x105 -+#define SMB_QUERY_CIFS_UNIX_INFO 0x200 -+#define SMB_QUERY_LABEL_INFO 0x3ea -+#define SMB_QUERY_FS_QUOTA_INFO 0x3ee -+ -+typedef struct smb_com_transaction2_qfsi_req { -+ struct smb_hdr hdr; /* wct = 14+ */ -+ __u16 TotalParameterCount; -+ __u16 TotalDataCount; -+ __u16 MaxParameterCount; -+ __u16 MaxDataCount; -+ __u8 MaxSetupCount; -+ __u8 Reserved; -+ __u16 Flags; -+ __u32 Timeout; -+ __u16 Reserved2; -+ __u16 ParameterCount; -+ __u16 ParameterOffset; -+ __u16 DataCount; -+ __u16 DataOffset; -+ __u8 SetupCount; -+ __u8 Reserved3; -+ __u16 SubCommand; /* one setup word */ -+ __u16 ByteCount; -+ __u8 Pad; -+ __u16 InformationLevel; -+} TRANSACTION2_QFSI_REQ; -+ -+typedef struct smb_com_transaction_qfsi_rsp { -+ struct smb_hdr hdr; /* wct = 10 + SetupCount */ -+ __u16 TotalParameterCount; -+ __u16 TotalDataCount; -+ __u16 Reserved; -+ __u16 ParameterCount; -+ __u16 ParameterOffset; -+ __u16 ParameterDisplacement; -+ __u16 DataCount; -+ __u16 DataOffset; -+ __u16 DataDisplacement; -+ __u8 SetupCount; -+ __u8 Reserved1; /* should be zero setup words following */ -+ __u16 ByteCount; -+ __u8 Pad; /* may be three bytes *//* followed by data area */ -+} TRANSACTION2_QFSI_RSP; -+ -+typedef struct smb_com_transaction2_get_dfs_refer_req { -+ struct smb_hdr hdr; /* wct = 15 */ -+ __u16 TotalParameterCount; -+ __u16 TotalDataCount; -+ __u16 MaxParameterCount; -+ __u16 MaxDataCount; -+ __u8 MaxSetupCount; -+ __u8 Reserved; -+ __u16 Flags; -+ __u32 Timeout; -+ __u16 Reserved2; -+ __u16 ParameterCount; -+ __u16 ParameterOffset; -+ __u16 DataCount; -+ __u16 DataOffset; -+ __u8 SetupCount; -+ __u8 Reserved3; -+ __u16 SubCommand; /* one setup word */ -+ __u16 ByteCount; -+ __u8 Pad[3]; /* Win2K has sent 0x0F01 (max resp length perhaps?) followed by one byte pad - doesn't seem to matter though */ -+ __u16 MaxReferralLevel; -+ char RequestFileName[1]; -+} TRANSACTION2_GET_DFS_REFER_REQ; -+ -+typedef struct dfs_referral_level_3 { -+ __u16 VersionNumber; -+ __u16 ReferralSize; -+ __u16 ServerType; /* 0x0001 = CIFS server */ -+ __u16 ReferralFlags; /* or proximity - not clear which since always set to zero - SNIA spec says 0x01 means strip off PathConsumed chars before submitting RequestFileName to remote node */ -+ __u16 TimeToLive; -+ __u16 Proximity; -+ __u16 DfsPathOffset; -+ __u16 DfsAlternatePathOffset; -+ __u16 NetworkAddressOffset; -+} REFERRAL3; -+ -+typedef struct smb_com_transaction_get_dfs_refer_rsp { -+ struct smb_hdr hdr; /* wct = 10 */ -+ __u16 TotalParameterCount; -+ __u16 TotalDataCount; -+ __u16 Reserved; -+ __u16 ParameterCount; -+ __u16 ParameterOffset; -+ __u16 ParameterDisplacement; -+ __u16 DataCount; -+ __u16 DataOffset; -+ __u16 DataDisplacement; -+ __u8 SetupCount; -+ __u8 Reserved1; /* zero setup words following */ -+ __u16 ByteCount; -+ __u8 Pad; -+ __u16 PathConsumed; -+ __u16 NumberOfReferrals; -+ __u16 DFSFlags; -+ __u16 Pad2; -+ REFERRAL3 referrals[1]; /* array of level 3 dfs_referral structures */ -+ /* followed by the strings pointed to by the referral structures */ -+} TRANSACTION2_GET_DFS_REFER_RSP; -+ -+/* DFS Flags */ -+#define DFSREF_REFERRAL_SERVER 0x0001 -+#define DFSREF_STORAGE_SERVER 0x0002 -+ -+/* IOCTL information */ -+/* List of ioctl function codes that look to be of interest to remote clients like this. */ -+/* Need to do some experimentation to make sure they all work remotely. */ -+/* Some of the following such as the encryption/compression ones would be */ -+/* invoked from tools via a specialized hook into the VFS rather than via the */ -+/* standard vfs entry points */ -+#define FSCTL_REQUEST_OPLOCK_LEVEL_1 0x00090000 -+#define FSCTL_REQUEST_OPLOCK_LEVEL_2 0x00090004 -+#define FSCTL_REQUEST_BATCH_OPLOCK 0x00090008 -+#define FSCTL_LOCK_VOLUME 0x00090018 -+#define FSCTL_UNLOCK_VOLUME 0x0009001C -+#define FSCTL_GET_COMPRESSION 0x0009003C -+#define FSCTL_SET_COMPRESSION 0x0009C040 -+#define FSCTL_REQUEST_FILTER_OPLOCK 0x0009008C -+#define FSCTL_FILESYS_GET_STATISTICS 0x00090090 -+#define FSCTL_SET_REPARSE_POINT 0x000900A4 -+#define FSCTL_GET_REPARSE_POINT 0x000900A8 -+#define FSCTL_DELETE_REPARSE_POINT 0x000900AC -+#define FSCTL_SET_SPARSE 0x000900C4 -+#define FSCTL_SET_ZERO_DATA 0x000900C8 -+#define FSCTL_SET_ENCRYPTION 0x000900D7 -+#define FSCTL_ENCRYPTION_FSCTL_IO 0x000900DB -+#define FSCTL_WRITE_RAW_ENCRYPTED 0x000900DF -+#define FSCTL_READ_RAW_ENCRYPTED 0x000900E3 -+#define FSCTL_SIS_COPYFILE 0x00090100 -+#define FSCTL_SIS_LINK_FILES 0x0009C104 -+ -+#define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003 -+#define IO_REPARSE_TAG_HSM 0xC0000004 -+#define IO_REPARSE_TAG_SIS 0x80000007 -+ -+/* -+ ************************************************************************ -+ * All structs for everything above the SMB PDUs themselves -+ * (such as the T2 level specific data) go here -+ ************************************************************************ -+ */ -+ -+/* -+ * Information on a server -+ */ -+ -+struct serverInfo { -+ char name[16]; -+ unsigned char versionMajor; -+ unsigned char versionMinor; -+ unsigned long type; -+ unsigned int commentOffset; -+}; -+ -+/* -+ * The following structure is the format of the data returned on a NetShareEnum -+ * with level "90" (x5A) -+ */ -+ -+struct shareInfo { -+ char shareName[13]; -+ char pad; -+ unsigned short type; -+ unsigned int commentOffset; -+}; -+ -+struct aliasInfo { -+ char aliasName[9]; -+ char pad; -+ unsigned int commentOffset; -+ unsigned char type[2]; -+}; -+ -+struct aliasInfo92 { -+ int aliasNameOffset; -+ int serverNameOffset; -+ int shareNameOffset; -+}; -+ -+typedef struct { -+ __u64 TotalAllocationUnits; -+ __u64 FreeAllocationUnits; -+ __u32 SectorsPerAllocationUnit; -+ __u32 BytesPerSector; -+} FILE_SYSTEM_INFO; /* size info, level 0x103 */ -+ -+typedef struct { -+ __u16 MajorVersionNumber; -+ __u16 MinorVersionNumber; -+ __u64 Capability; -+} FILE_SYSTEM_UNIX_INFO; /* Unix extensions info, level 0x200 */ -+/* Linux/Unix extensions capability flags */ -+#define CIFS_UNIX_FCNTL_CAP 0x00000001 /* support for fcntl locks */ -+#define CIFS_UNIX_POSIX_ACL_CAP 0x00000002 -+ -+/* DeviceType Flags */ -+#define FILE_DEVICE_CD_ROM 0x00000002 -+#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003 -+#define FILE_DEVICE_DFS 0x00000006 -+#define FILE_DEVICE_DISK 0x00000007 -+#define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008 -+#define FILE_DEVICE_FILE_SYSTEM 0x00000009 -+#define FILE_DEVICE_NAMED_PIPE 0x00000011 -+#define FILE_DEVICE_NETWORK 0x00000012 -+#define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014 -+#define FILE_DEVICE_NULL 0x00000015 -+#define FILE_DEVICE_PARALLEL_PORT 0x00000016 -+#define FILE_DEVICE_PRINTER 0x00000018 -+#define FILE_DEVICE_SERIAL_PORT 0x0000001b -+#define FILE_DEVICE_STREAMS 0x0000001e -+#define FILE_DEVICE_TAPE 0x0000001f -+#define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020 -+#define FILE_DEVICE_VIRTUAL_DISK 0x00000024 -+#define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028 -+ -+typedef struct { -+ __u32 DeviceType; -+ __u32 DeviceCharacteristics; -+} FILE_SYSTEM_DEVICE_INFO; /* device info, level 0x104 */ -+ -+typedef struct { -+ __u32 Attributes; -+ __u32 MaxPathNameComponentLength; -+ __u32 FileSystemNameLen; -+ char FileSystemName[52]; /* do not really need to save this - so potentially get only subset of name */ -+} FILE_SYSTEM_ATTRIBUTE_INFO; -+ -+typedef struct { /* data block encoding of response to level 263 QPathInfo */ -+ __u64 CreationTime; -+ __u64 LastAccessTime; -+ __u64 LastWriteTime; -+ __u64 ChangeTime; -+ __u32 Attributes; -+ __u32 Pad1; -+ __u64 AllocationSize; -+ __u64 EndOfFile; /* size ie offset to first free byte in file */ -+ __u32 NumberOfLinks; /* hard links */ -+ __u8 DeletePending; -+ __u8 Directory; -+ __u16 Pad2; -+ __u64 IndexNumber; -+ __u32 EASize; -+ __u32 AccessFlags; -+ __u64 IndexNumber1; -+ __u64 CurrentByteOffset; -+ __u32 Mode; -+ __u32 AlignmentRequirement; -+ __u32 FileNameLength; -+ char FileName[1]; -+} FILE_ALL_INFO; /* level 263 QPathInfo */ -+ -+typedef struct { -+ __u64 EndOfFile; -+ __u64 NumOfBytes; -+ __u64 LastStatusChange; /*SNIA spec says DCE time for the three time fields */ -+ __u64 LastAccessTime; -+ __u64 LastModificationTime; -+ __u64 Uid; -+ __u64 Gid; -+ __u32 Type; -+ __u64 DevMajor; -+ __u64 DevMinor; -+ __u64 UniqueId; -+ __u64 Permissions; -+ __u64 Nlinks; -+} FILE_UNIX_BASIC_INFO; /* level 512 QPathInfo */ -+ -+typedef struct { -+ char LinkDest[1]; -+} FILE_UNIX_LINK_INFO; /* level 513 QPathInfo */ -+ -+/* defines for enumerating possible values of the Unix type field below */ -+#define UNIX_FILE 0 -+#define UNIX_DIR 1 -+#define UNIX_SYMLINK 2 -+#define UNIX_CHARDEV 3 -+#define UNIX_BLOCKDEV 4 -+#define UNIX_FIFO 5 -+#define UNIX_SOCKET 6 -+ -+typedef struct { -+ __u32 NextEntryOffset; -+ __u32 ResumeKey; -+ __u64 EndOfFile; -+ __u64 NumOfBytes; -+ __u64 LastStatusChange; /*SNIA spec says DCE time for the three time fields */ -+ __u64 LastAccessTime; -+ __u64 LastModificationTime; -+ __u64 Uid; -+ __u64 Gid; -+ __u32 Type; -+ __u64 DevMajor; -+ __u64 DevMinor; -+ __u64 UniqueId; -+ __u64 Permissions; -+ __u64 Nlinks; -+ char FileName[1]; -+} FILE_UNIX_INFO; -+ -+typedef struct { -+ __u64 CreationTime; -+ __u64 LastAccessTime; -+ __u64 LastWriteTime; -+ __u64 ChangeTime; -+ __u32 Attributes; -+ __u32 Pad; -+} FILE_BASIC_INFO; /* size info, level 0x101 */ -+ -+struct file_allocation_info { -+ __u64 AllocationSize; -+}; /* size info, level 0x103 */ -+ -+struct file_end_of_file_info { -+ __u64 FileSize; /* offset to end of file */ -+}; /* size info, level 0x104 */ -+ -+typedef struct { -+ __u32 NextEntryOffset; -+ __u32 FileIndex; -+ __u64 CreationTime; -+ __u64 LastAccessTime; -+ __u64 LastWriteTime; -+ __u64 ChangeTime; -+ __u64 EndOfFile; -+ __u64 AllocationSize; -+ __u32 ExtFileAttributes; -+ __u32 FileNameLength; -+ char FileName[1]; -+} FILE_DIRECTORY_INFO; /* level 257 FF response data area */ -+ -+struct gea { -+ unsigned char cbName; -+ char szName[1]; -+}; -+ -+struct gealist { -+ unsigned long cbList; -+ struct gea list[1]; -+}; -+ -+struct fea { -+ unsigned char EA_flags; -+ __u8 name_len; -+ __u16 value_len; -+ char szName[1]; -+ /* optionally followed by value */ -+}; -+/* flags for _FEA.fEA */ -+#define FEA_NEEDEA 0x80 /* need EA bit */ -+ -+struct fealist { -+ __u32 list_len; -+ struct fea list[1]; -+}; -+ -+/* used to hold an arbitrary blob of data */ -+struct data_blob { -+ __u8 *data; -+ size_t length; -+ void (*free) (struct data_blob * data_blob); -+}; -+ -+#ifdef CONFIG_CIFS_POSIX -+/* -+ For better POSIX semantics from Linux client, (even better -+ than the existing CIFS Unix Extensions) we need updated PDUs for: -+ -+ 1) PosixCreateX - to set and return the mode, inode#, device info and -+ perhaps add a CreateDevice - to create Pipes and other special .inodes -+ Also note POSIX open flags -+ 2) Close - to return the last write time to do cache across close more safely -+ 3) PosixQFSInfo - to return statfs info -+ 4) FindFirst return unique inode number - what about resume key, two forms short (matches readdir) and full (enough info to cache inodes) -+ 5) Mkdir - set mode -+ -+ And under consideration: -+ 6) FindClose2 (return nanosecond timestamp ??) -+ 7) Use nanosecond timestamps throughout all time fields if -+ corresponding attribute flag is set -+ 8) sendfile - handle based copy -+ 9) Direct i/o -+ 10) "POSIX ACL" support -+ 11) Misc fcntls? -+ -+ what about fixing 64 bit alignment -+ -+ There are also various legacy SMB/CIFS requests used as is -+ -+ From existing Lanman and NTLM dialects: -+ -------------------------------------- -+ NEGOTIATE -+ SESSION_SETUP_ANDX (BB which?) -+ TREE_CONNECT_ANDX (BB which wct?) -+ TREE_DISCONNECT (BB add volume timestamp on response) -+ LOGOFF_ANDX -+ DELETE (note delete open file behavior) -+ DELETE_DIRECTORY -+ READ_AND_X -+ WRITE_AND_X -+ LOCKING_AND_X (note posix lock semantics) -+ RENAME (note rename across dirs and open file rename posix behaviors) -+ NT_RENAME (for hardlinks) Is this good enough for all features? -+ FIND_CLOSE2 -+ TRANSACTION2 (18 cases) -+ SMB_SET_FILE_END_OF_FILE_INFO2 SMB_SET_PATH_END_OF_FILE_INFO2 -+ (BB verify that never need to set allocation size) -+ SMB_SET_FILE_BASIC_INFO2 (setting times - BB can it be done via Unix ext?) -+ -+ COPY (note support for copy across directories) - FUTURE, OPTIONAL -+ setting/getting OS/2 EAs - FUTURE (BB can this handle -+ setting Linux xattrs perfectly) - OPTIONAL -+ dnotify - FUTURE, OPTIONAL -+ quota - FUTURE, OPTIONAL -+ -+ Note that various requests implemented for NT interop such as -+ NT_TRANSACT (IOCTL) QueryReparseInfo -+ are unneeded to servers compliant with the CIFS POSIX extensions -+ -+ From CIFS Unix Extensions: -+ ------------------------- -+ T2 SET_PATH_INFO (SMB_SET_FILE_UNIX_LINK) for symlinks -+ T2 SET_PATH_INFO (SMB_SET_FILE_BASIC_INFO2) -+ T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_LINK) -+ T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_BASIC) - BB check for missing inode fields -+ Actually need QUERY_FILE_UNIX_INFO since has inode num -+ BB what about a) blksize/blkbits/blocks -+ b) i_version -+ c) i_rdev -+ d) notify mask? -+ e) generation -+ f) size_seqcount -+ T2 FIND_FIRST/FIND_NEXT FIND_FILE_UNIX -+ TRANS2_GET_DFS_REFERRAL - OPTIONAL but recommended -+ T2_QFS_INFO QueryDevice/AttributeInfo - OPTIONAL -+ -+ -+ */ -+#endif -+ -+#pragma pack() /* resume default structure packing */ -+ -+#endif /* _CIFSPDU_H */ ---- /dev/null -+++ b/fs/cifs/cifsproto.h -@@ -0,0 +1,254 @@ -+/* -+ * fs/cifs/cifsproto.h -+ * -+ * Copyright (c) International Business Machines Corp., 2002 -+ * Author(s): Steve French (sfrench@us.ibm.com) -+ * -+ * This library is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU Lesser General Public License as published -+ * by the Free Software Foundation; either version 2.1 of the License, or -+ * (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -+ * the GNU Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public License -+ * along with this library; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ */ -+#ifndef _CIFSPROTO_H -+#define _CIFSPROTO_H -+#include <linux/nls.h> -+ -+struct statfs; -+ -+/* -+ ***************************************************************** -+ * All Prototypes -+ ***************************************************************** -+ */ -+ -+extern struct smb_hdr *cifs_buf_get(void); -+extern void cifs_buf_release(void *); -+extern int smb_send(struct socket *, struct smb_hdr *, -+ unsigned int /* length */ , struct sockaddr *); -+extern unsigned int _GetXid(void); -+extern void _FreeXid(unsigned int); -+#define GetXid() (int)_GetXid(); cFYI(1,("CIFS VFS: in %s as Xid: %d with uid: %d",__FUNCTION__, xid,current->fsuid)); -+#define FreeXid(curr_xid) {_FreeXid(curr_xid); cFYI(1,("CIFS VFS: leaving %s (xid = %d) rc = %d",__FUNCTION__,curr_xid,rc));} -+extern char *build_path_from_dentry(struct dentry *); -+extern char *build_wildcard_path_from_dentry(struct dentry *direntry); -+extern void renew_parental_timestamps(struct dentry *direntry); -+extern int SendReceive(const unsigned int /* xid */ , struct cifsSesInfo *, -+ struct smb_hdr * /* input */ , -+ struct smb_hdr * /* out */ , -+ int * /* bytes returned */ , const int long_op); -+extern int checkSMBhdr(struct smb_hdr *smb, __u16 mid); -+extern int checkSMB(struct smb_hdr *smb, __u16 mid, int length); -+extern int is_valid_oplock_break(struct smb_hdr *smb); -+extern unsigned int smbCalcSize(struct smb_hdr *ptr); -+extern int decode_negTokenInit(unsigned char *security_blob, int length, -+ enum securityEnum *secType); -+extern int map_smb_to_linux_error(struct smb_hdr *smb); -+extern void header_assemble(struct smb_hdr *, char /* command */ , -+ const struct cifsTconInfo *, int -+ /* length of fixed section (word count) in two byte units */ -+ ); -+struct oplock_q_entry * AllocOplockQEntry(struct inode *, u16, struct cifsTconInfo *); -+void DeleteOplockQEntry(struct oplock_q_entry *); -+extern time_t cifs_NTtimeToUnix(u64 /* utc nanoseconds since 1601 */ ); -+extern u64 cifs_UnixTimeToNT(time_t); -+extern int cifs_get_inode_info(struct inode **pinode, -+ const unsigned char *search_path, -+ FILE_ALL_INFO * pfile_info, -+ struct super_block *sb, int xid); -+extern int cifs_get_inode_info_unix(struct inode **pinode, -+ const unsigned char *search_path, -+ struct super_block *sb,int xid); -+ -+extern int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, -+ struct nls_table * nls_info); -+extern int CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses); -+ -+extern int CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, -+ const char *tree, struct cifsTconInfo *tcon, -+ const struct nls_table *); -+ -+extern int CIFSFindFirst(const int xid, struct cifsTconInfo *tcon, -+ const char *searchName, -+ FILE_DIRECTORY_INFO * findData, -+ T2_FFIRST_RSP_PARMS * findParms, -+ const struct nls_table *nls_codepage, -+ int *pUnicodeFlag, -+ int *pUnixFlag /* if Unix extensions used */ ); -+extern int CIFSFindNext(const int xid, struct cifsTconInfo *tcon, -+ FILE_DIRECTORY_INFO * findData, -+ T2_FNEXT_RSP_PARMS * findParms, -+ const __u16 searchHandle, char * resume_name, -+ int name_length, __u32 resume_key, -+ int *UnicodeFlag, int *pUnixFlag); -+ -+extern int CIFSFindClose(const int, struct cifsTconInfo *tcon, -+ const __u16 search_handle); -+ -+extern int CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon, -+ const unsigned char *searchName, -+ FILE_ALL_INFO * findData, -+ const struct nls_table *nls_codepage); -+ -+extern int CIFSSMBUnixQPathInfo(const int xid, -+ struct cifsTconInfo *tcon, -+ const unsigned char *searchName, -+ FILE_UNIX_BASIC_INFO * pFindData, -+ const struct nls_table *nls_codepage); -+ -+extern int CIFSGetDFSRefer(const int xid, struct cifsSesInfo *ses, -+ const unsigned char *searchName, -+ unsigned char **targetUNCs, -+ unsigned int *number_of_UNC_in_array, -+ const struct nls_table *nls_codepage); -+ -+extern int connect_to_dfs_path(int xid, struct cifsSesInfo *pSesInfo, -+ const char *old_path, -+ const struct nls_table *nls_codepage); -+extern int get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, -+ const char *old_path, const struct nls_table *nls_codepage, -+ unsigned int *pnum_referrals, unsigned char ** preferrals); -+extern int CIFSSMBQFSInfo(const int xid, struct cifsTconInfo *tcon, -+ struct statfs *FSData, -+ const struct nls_table *nls_codepage); -+extern int CIFSSMBQFSAttributeInfo(const int xid, -+ struct cifsTconInfo *tcon, -+ const struct nls_table *nls_codepage); -+extern int CIFSSMBQFSDeviceInfo(const int xid, struct cifsTconInfo *tcon, -+ const struct nls_table *nls_codepage); -+extern int CIFSSMBQFSUnixInfo(const int xid, struct cifsTconInfo *tcon, -+ const struct nls_table *nls_codepage); -+ -+extern int CIFSSMBSetTimes(const int xid, struct cifsTconInfo *tcon, -+ char *fileName, FILE_BASIC_INFO * data, -+ const struct nls_table *nls_codepage); -+extern int CIFSSMBSetEOF(const int xid, struct cifsTconInfo *tcon, -+ char *fileName, __u64 size,int setAllocationSizeFlag, -+ const struct nls_table *nls_codepage); -+extern int CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, -+ __u64 size, __u16 fileHandle,__u32 opener_pid, int AllocSizeFlag); -+extern int CIFSSMBUnixSetPerms(const int xid, struct cifsTconInfo *pTcon, -+ char *full_path, __u64 mode, __u64 uid, -+ __u64 gid, dev_t dev, const struct nls_table *nls_codepage); -+ -+extern int CIFSSMBMkDir(const int xid, struct cifsTconInfo *tcon, -+ const char *newName, -+ const struct nls_table *nls_codepage); -+extern int CIFSSMBRmDir(const int xid, struct cifsTconInfo *tcon, -+ const char *name, const struct nls_table *nls_codepage); -+ -+extern int CIFSSMBDelFile(const int xid, struct cifsTconInfo *tcon, -+ const char *name, -+ const struct nls_table *nls_codepage); -+extern int CIFSSMBRename(const int xid, struct cifsTconInfo *tcon, -+ const char *fromName, const char *toName, -+ const struct nls_table *nls_codepage); -+extern int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon, -+ int netfid, char * target_name, const struct nls_table *nls_codepage); -+extern int CIFSCreateHardLink(const int xid, -+ struct cifsTconInfo *tcon, -+ const char *fromName, const char *toName, -+ const struct nls_table *nls_codepage); -+extern int CIFSUnixCreateHardLink(const int xid, -+ struct cifsTconInfo *tcon, -+ const char *fromName, const char *toName, -+ const struct nls_table *nls_codepage); -+extern int CIFSUnixCreateSymLink(const int xid, -+ struct cifsTconInfo *tcon, -+ const char *fromName, const char *toName, -+ const struct nls_table *nls_codepage); -+extern int CIFSSMBUnixQuerySymLink(const int xid, -+ struct cifsTconInfo *tcon, -+ const unsigned char *searchName, -+ char *syminfo, const int buflen, -+ const struct nls_table *nls_codepage); -+extern int CIFSSMBQueryReparseLinkInfo(const int xid, -+ struct cifsTconInfo *tcon, -+ const unsigned char *searchName, -+ char *symlinkinfo, const int buflen, __u16 fid, -+ const struct nls_table *nls_codepage); -+ -+extern int CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon, -+ const char *fileName, const int disposition, -+ const int access_flags, const int omode, -+ __u16 * netfid, int *pOplock, FILE_ALL_INFO *, -+ const struct nls_table *nls_codepage); -+extern int CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, -+ const int smb_file_id); -+ -+extern int CIFSSMBRead(const int xid, struct cifsTconInfo *tcon, -+ const int netfid, unsigned int count, -+ const __u64 lseek, unsigned int *nbytes, char **buf); -+extern int CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon, -+ const int netfid, const unsigned int count, -+ const __u64 lseek, unsigned int *nbytes, -+ const char *buf, const int long_op); -+extern int CIFSSMBLock(const int xid, struct cifsTconInfo *tcon, -+ const __u16 netfid, const __u64 len, -+ const __u64 offset, const __u32 numUnlock, -+ const __u32 numLock, const __u8 lockType, -+ const int waitFlag); -+ -+extern int CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon); -+extern int CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses); -+ -+extern struct cifsSesInfo *sesInfoAlloc(void); -+extern void sesInfoFree(struct cifsSesInfo *); -+extern struct cifsTconInfo *tconInfoAlloc(void); -+extern void tconInfoFree(struct cifsTconInfo *); -+ -+extern int cifs_reconnect(struct TCP_Server_Info *server); -+ -+extern int cifs_sign_smb(struct smb_hdr *, struct cifsSesInfo *,__u32 *); -+extern int cifs_verify_signature(const struct smb_hdr *, const char * mac_key, -+ __u32 expected_sequence_number); -+extern int cifs_calculate_mac_key(char * key,const char * rn,const char * pass); -+extern void CalcNTLMv2_partial_mac_key(struct cifsSesInfo *, struct nls_table *); -+extern void CalcNTLMv2_response(const struct cifsSesInfo *,char * ); -+ -+extern int CIFSBuildServerList(int xid, char *serverBufferList, -+ int recordlength, int *entries, -+ int *totalEntries, int *topoChangedFlag); -+extern int CIFSSMBQueryShares(int xid, struct cifsTconInfo *tcon, -+ struct shareInfo *shareList, int bufferLen, -+ int *entries, int *totalEntries); -+extern int CIFSSMBQueryAlias(int xid, struct cifsTconInfo *tcon, -+ struct aliasInfo *aliasList, int bufferLen, -+ int *entries, int *totalEntries); -+extern int CIFSSMBAliasInfo(int xid, struct cifsTconInfo *tcon, -+ char *aliasName, char *serverName, -+ char *shareName, char *comment); -+extern int CIFSSMBGetShareInfo(int xid, struct cifsTconInfo *tcon, -+ char *share, char *comment); -+extern int CIFSSMBGetUserPerms(int xid, struct cifsTconInfo *tcon, -+ char *userName, char *searchName, int *perms); -+extern int CIFSSMBSync(int xid, struct cifsTconInfo *tcon, int netfid, int pid); -+ -+extern int CIFSSMBSeek(int xid, -+ struct cifsTconInfo *tcon, -+ int netfid, -+ int pid, -+ int whence, unsigned long offset, long long *newoffset); -+ -+extern int CIFSSMBCopy(int xid, -+ struct cifsTconInfo *source_tcon, -+ const char *fromName, -+ const __u16 target_tid, -+ const char *toName, const int flags, -+ const struct nls_table *nls_codepage); -+extern int CIFSSMBNotify(const int xid, struct cifsTconInfo *tcon, -+ const int notify_subdirs,const __u16 netfid,__u32 filter, -+ const struct nls_table *nls_codepage); -+extern int CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon, -+ const unsigned char *searchName, -+ char * EAData, size_t size, -+ const struct nls_table *nls_codepage); -+#endif /* _CIFSPROTO_H */ ---- /dev/null -+++ b/fs/cifs/cifssmb.c -@@ -0,0 +1,3016 @@ -+/* -+ * fs/cifs/cifssmb.c -+ * -+ * Copyright (C) International Business Machines Corp., 2002,2003 -+ * Author(s): Steve French (sfrench@us.ibm.com) -+ * -+ * Contains the routines for constructing the SMB PDUs themselves -+ * -+ * This library is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU Lesser General Public License as published -+ * by the Free Software Foundation; either version 2.1 of the License, or -+ * (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -+ * the GNU Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public License -+ * along with this library; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ */ -+ -+ /* SMB/CIFS PDU handling routines here - except for leftovers in connect.c */ -+ /* These are mostly routines that operate on a pathname, or on a tree id */ -+ /* (mounted volume), but there are eight handle based routines which must be */ -+ /* treated slightly different for reconnection purposes since we never want */ -+ /* to reuse a stale file handle and the caller knows the file handle */ -+ -+#include <linux/fs.h> -+#include <linux/kernel.h> -+#include <linux/vfs.h> -+#include <asm/uaccess.h> -+#include "cifspdu.h" -+#include "cifsglob.h" -+#include "cifsproto.h" -+#include "cifs_unicode.h" -+#include "cifs_debug.h" -+ -+#ifdef CONFIG_CIFS_POSIX -+static struct { -+ int index; -+ char *name; -+} protocols[] = { -+ {CIFS_PROT, "\2NT LM 0.12"}, -+ {CIFS_PROT, "\2POSIX 2"}, -+ {BAD_PROT, "\2"} -+}; -+#else -+static struct { -+ int index; -+ char *name; -+} protocols[] = { -+ {CIFS_PROT, "\2NT LM 0.12"}, -+ {BAD_PROT, "\2"} -+}; -+#endif -+ -+ -+/* Mark as invalid, all open files on tree connections since they -+ were closed when session to server was lost */ -+static void mark_open_files_invalid(struct cifsTconInfo * pTcon) -+{ -+ struct cifsFileInfo *open_file = NULL; -+ struct list_head * tmp; -+ struct list_head * tmp1; -+ -+/* list all files open on tree connection and mark them invalid */ -+ write_lock(&GlobalSMBSeslock); -+ list_for_each_safe(tmp, tmp1, &pTcon->openFileList) { -+ open_file = list_entry(tmp,struct cifsFileInfo, tlist); -+ if(open_file) { -+ open_file->invalidHandle = TRUE; -+ } -+ } -+ write_unlock(&GlobalSMBSeslock); -+ /* BB Add call to invalidate_inodes(sb) for all superblocks mounted to this tcon */ -+} -+ -+static int -+smb_init(int smb_command, int wct, struct cifsTconInfo *tcon, -+ void **request_buf /* returned */ , -+ void **response_buf /* returned */ ) -+{ -+ int rc = 0; -+ int timeout = 10 * HZ; -+ -+ /* SMBs NegProt, SessSetup, uLogoff do not have tcon yet so -+ check for tcp and smb session status done differently -+ for those three - in the calling routine */ -+ if(tcon) { -+ if((tcon->ses) && (tcon->ses->server)){ -+ struct nls_table *nls_codepage; -+ /* Give Demultiplex thread up to 10 seconds to -+ reconnect, should be greater than cifs socket -+ timeout which is 7 seconds */ -+ while(tcon->ses->server->tcpStatus == CifsNeedReconnect) { -+ while ((tcon->ses->server->tcpStatus != CifsGood) && (timeout > 0)){ -+ timeout = interruptible_sleep_on_timeout(&tcon->ses->server->response_q,timeout); -+ } -+ if(tcon->ses->server->tcpStatus == CifsNeedReconnect) { -+ /* on "soft" mounts we wait once */ -+ if((tcon->retry == FALSE) || -+ (tcon->ses->status == CifsExiting)) { -+ cFYI(1,("gave up waiting on reconnect in smb_init")); -+ return -EHOSTDOWN; -+ } /* else "hard" mount - keep retrying until -+ process is killed or server comes back up */ -+ } else /* TCP session is reestablished now */ -+ break; -+ -+ } -+ -+ nls_codepage = load_nls_default(); -+ /* need to prevent multiple threads trying to -+ simultaneously reconnect the same SMB session */ -+ down(&tcon->ses->sesSem); -+ if(tcon->ses->status == CifsNeedReconnect) -+ rc = cifs_setup_session(0, tcon->ses, nls_codepage); -+ if(!rc && (tcon->tidStatus == CifsNeedReconnect)) { -+ mark_open_files_invalid(tcon); -+ rc = CIFSTCon(0, tcon->ses, tcon->treeName, tcon, -+ nls_codepage); -+ up(&tcon->ses->sesSem); -+ if(rc == 0) -+ atomic_inc(&tconInfoReconnectCount); -+ -+ cFYI(1, ("reconnect tcon rc = %d", rc)); -+ /* Removed call to reopen open files here - -+ it is safer (and faster) to reopen files -+ one at a time as needed in read and write */ -+ -+ /* Check if handle based operation so we -+ know whether we can continue or not without -+ returning to caller to reset file handle */ -+ switch(smb_command) { -+ case SMB_COM_READ_ANDX: -+ case SMB_COM_WRITE_ANDX: -+ case SMB_COM_CLOSE: -+ case SMB_COM_FIND_CLOSE2: -+ case SMB_COM_LOCKING_ANDX: { -+ unload_nls(nls_codepage); -+ return -EAGAIN; -+ } -+ } -+ } else { -+ up(&tcon->ses->sesSem); -+ } -+ unload_nls(nls_codepage); -+ -+ } else { -+ return -EIO; -+ } -+ } -+ if(rc) -+ return rc; -+ -+ *request_buf = cifs_buf_get(); -+ if (*request_buf == 0) { -+ /* BB should we add a retry in here if not a writepage? */ -+ return -ENOMEM; -+ } -+ /* Although the original thought was we needed the response buf for */ -+ /* potential retries of smb operations it turns out we can determine */ -+ /* from the mid flags when the request buffer can be resent without */ -+ /* having to use a second distinct buffer for the response */ -+ *response_buf = *request_buf; -+ -+ header_assemble((struct smb_hdr *) *request_buf, smb_command, tcon, -+ wct /*wct */ ); -+ -+#ifdef CONFIG_CIFS_STATS -+ if(tcon != NULL) { -+ atomic_inc(&tcon->num_smbs_sent); -+ } -+#endif -+ return rc; -+} -+ -+int -+CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses) -+{ -+ NEGOTIATE_REQ *pSMB; -+ NEGOTIATE_RSP *pSMBr; -+ int rc = 0; -+ int bytes_returned; -+ struct TCP_Server_Info * server; -+ -+ if(ses->server) -+ server = ses->server; -+ else { -+ rc = -EIO; -+ return rc; -+ } -+ rc = smb_init(SMB_COM_NEGOTIATE, 0, NULL /* no tcon yet */ , -+ (void **) &pSMB, (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ pSMB->hdr.Flags2 |= SMBFLG2_UNICODE; -+ if (extended_security) -+ pSMB->hdr.Flags2 |= SMBFLG2_EXT_SEC; -+ -+ pSMB->ByteCount = strlen(protocols[0].name) + 1; -+ strncpy(pSMB->DialectsArray, protocols[0].name, 30); -+ /* null guaranteed to be at end of source and target buffers anyway */ -+ -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ -+ rc = SendReceive(xid, ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc == 0) { -+ server->secMode = pSMBr->SecurityMode; -+ server->secType = NTLM; /* BB override default for NTLMv2 or krb*/ -+ /* one byte - no need to convert this or EncryptionKeyLen from le,*/ -+ server->maxReq = le16_to_cpu(pSMBr->MaxMpxCount); -+ /* probably no need to store and check maxvcs */ -+ server->maxBuf = -+ min(le32_to_cpu(pSMBr->MaxBufferSize), -+ (__u32) CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE); -+ server->maxRw = le32_to_cpu(pSMBr->MaxRawSize); -+ cFYI(0, ("Max buf = %d ", ses->server->maxBuf)); -+ GETU32(ses->server->sessid) = le32_to_cpu(pSMBr->SessionKey); -+ server->capabilities = le32_to_cpu(pSMBr->Capabilities); -+ server->timeZone = le16_to_cpu(pSMBr->ServerTimeZone); -+ /* BB with UTC do we ever need to be using srvr timezone? */ -+ if (pSMBr->EncryptionKeyLength == CIFS_CRYPTO_KEY_SIZE) { -+ memcpy(server->cryptKey, pSMBr->u.EncryptionKey, -+ CIFS_CRYPTO_KEY_SIZE); -+ } else if ((pSMBr->hdr.Flags2 & SMBFLG2_EXT_SEC) -+ && (pSMBr->EncryptionKeyLength == 0)) { -+ /* decode security blob */ -+ } else -+ rc = -EIO; -+ -+ /* BB might be helpful to save off the domain of server here */ -+ -+ if (pSMBr->hdr.Flags2 & SMBFLG2_EXT_SEC) { -+ if (pSMBr->ByteCount < 16) -+ rc = -EIO; -+ else if (pSMBr->ByteCount == 16) { -+ server->secType = RawNTLMSSP; -+ if (server->socketUseCount.counter > 1) { -+ if (memcmp -+ (server->server_GUID, -+ pSMBr->u.extended_response. -+ GUID, 16) != 0) { -+ cFYI(1, -+ ("UID of server does not match previous connection to same ip address")); -+ memcpy(server-> -+ server_GUID, -+ pSMBr->u. -+ extended_response. -+ GUID, 16); -+ } -+ } else -+ memcpy(server->server_GUID, -+ pSMBr->u.extended_response. -+ GUID, 16); -+ } else { -+ rc = decode_negTokenInit(pSMBr->u. -+ extended_response. -+ SecurityBlob, -+ pSMBr->ByteCount - -+ 16, &server->secType); -+ } -+ } else -+ server->capabilities &= ~CAP_EXTENDED_SECURITY; -+ if(sign_CIFS_PDUs == FALSE) { -+ if(server->secMode & SECMODE_SIGN_REQUIRED) -+ cERROR(1, -+ ("Server requires /proc/fs/cifs/PacketSigningEnabled")); -+ server->secMode &= ~(SECMODE_SIGN_ENABLED | SECMODE_SIGN_REQUIRED); -+ } else if(sign_CIFS_PDUs == 1) { -+ if((server->secMode & SECMODE_SIGN_REQUIRED) == 0) -+ server->secMode &= ~(SECMODE_SIGN_ENABLED | SECMODE_SIGN_REQUIRED); -+ } -+ -+ } -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ return rc; -+} -+ -+int -+CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon) -+{ -+ struct smb_hdr *smb_buffer; -+ struct smb_hdr *smb_buffer_response; -+ int rc = 0; -+ int length; -+ -+ cFYI(1, ("In tree disconnect")); -+ /* -+ * If last user of the connection and -+ * connection alive - disconnect it -+ * If this is the last connection on the server session disconnect it -+ * (and inside session disconnect we should check if tcp socket needs -+ * to be freed and kernel thread woken up). -+ */ -+ if (tcon) -+ down(&tcon->tconSem); -+ else -+ return -EIO; -+ -+ atomic_dec(&tcon->useCount); -+ if (atomic_read(&tcon->useCount) > 0) { -+ up(&tcon->tconSem); -+ return -EBUSY; -+ } -+ -+ /* No need to return error on this operation if tid invalidated and -+ closed on server already e.g. due to tcp session crashing */ -+ if(tcon->tidStatus == CifsNeedReconnect) { -+ up(&tcon->tconSem); -+ return 0; -+ } -+ -+ if((tcon->ses == 0) || (tcon->ses->server == 0)) { -+ up(&tcon->tconSem); -+ return -EIO; -+ } -+ -+ rc = smb_init(SMB_COM_TREE_DISCONNECT, 0, tcon, -+ (void **) &smb_buffer, (void **) &smb_buffer_response); -+ if (rc) { -+ up(&tcon->tconSem); -+ return rc; -+ } -+ rc = SendReceive(xid, tcon->ses, smb_buffer, smb_buffer_response, -+ &length, 0); -+ if (rc) -+ cFYI(1, (" Tree disconnect failed %d", rc)); -+ -+ if (smb_buffer) -+ cifs_buf_release(smb_buffer); -+ up(&tcon->tconSem); -+ -+ /* No need to return error on this operation if tid invalidated and -+ closed on server already e.g. due to tcp session crashing */ -+ if (rc == -EAGAIN) -+ rc = 0; -+ -+ return rc; -+} -+ -+int -+CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses) -+{ -+ struct smb_hdr *smb_buffer_response; -+ LOGOFF_ANDX_REQ *pSMB; -+ int rc = 0; -+ int length; -+ -+ cFYI(1, ("In SMBLogoff for session disconnect")); -+ if (ses) -+ down(&ses->sesSem); -+ else -+ return -EIO; -+ -+ atomic_dec(&ses->inUse); -+ if (atomic_read(&ses->inUse) > 0) { -+ up(&ses->sesSem); -+ return -EBUSY; -+ } -+ -+ rc = smb_init(SMB_COM_LOGOFF_ANDX, 2, NULL /* no tcon anymore */, -+ (void **) &pSMB, (void **) &smb_buffer_response); -+ -+ if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) -+ pSMB->hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE; -+ -+ if (rc) { -+ up(&ses->sesSem); -+ return rc; -+ } -+ -+ pSMB->hdr.Uid = ses->Suid; -+ -+ pSMB->AndXCommand = 0xFF; -+ rc = SendReceive(xid, ses, (struct smb_hdr *) pSMB, -+ smb_buffer_response, &length, 0); -+ if (ses->server) { -+ atomic_dec(&ses->server->socketUseCount); -+ if (atomic_read(&ses->server->socketUseCount) == 0) { -+ spin_lock(&GlobalMid_Lock); -+ ses->server->tcpStatus = CifsExiting; -+ spin_unlock(&GlobalMid_Lock); -+ rc = -ESHUTDOWN; -+ } -+ } -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ up(&ses->sesSem); -+ -+ /* if session dead then we do not need to do ulogoff, -+ since server closed smb session, no sense reporting -+ error */ -+ if (rc == -EAGAIN) -+ rc = 0; -+ return rc; -+} -+ -+int -+CIFSSMBDelFile(const int xid, struct cifsTconInfo *tcon, -+ const char *fileName, const struct nls_table *nls_codepage) -+{ -+ DELETE_FILE_REQ *pSMB = NULL; -+ DELETE_FILE_RSP *pSMBr = NULL; -+ int rc = 0; -+ int bytes_returned; -+ int name_len; -+ -+DelFileRetry: -+ rc = smb_init(SMB_COM_DELETE, 1, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { -+ name_len = -+ cifs_strtoUCS((wchar_t *) pSMB->fileName, fileName, 530 -+ /* find define for this maxpathcomponent */ -+ , nls_codepage); -+ name_len++; /* trailing null */ -+ name_len *= 2; -+ } else { /* BB improve the check for buffer overruns BB */ -+ name_len = strnlen(fileName, 530); -+ name_len++; /* trailing null */ -+ strncpy(pSMB->fileName, fileName, name_len); -+ } -+ pSMB->SearchAttributes = -+ cpu_to_le16(ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM); -+ pSMB->ByteCount = name_len + 1; -+ pSMB->BufferFormat = 0x04; -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc) { -+ cFYI(1, ("Error in RMFile = %d", rc)); -+ } -+#ifdef CONFIG_CIFS_STATS -+ else { -+ atomic_inc(&tcon->num_deletes); -+ } -+#endif -+ -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ if (rc == -EAGAIN) -+ goto DelFileRetry; -+ -+ return rc; -+} -+ -+int -+CIFSSMBRmDir(const int xid, struct cifsTconInfo *tcon, -+ const char *dirName, const struct nls_table *nls_codepage) -+{ -+ DELETE_DIRECTORY_REQ *pSMB = NULL; -+ DELETE_DIRECTORY_RSP *pSMBr = NULL; -+ int rc = 0; -+ int bytes_returned; -+ int name_len; -+ -+ cFYI(1, ("In CIFSSMBRmDir")); -+RmDirRetry: -+ rc = smb_init(SMB_COM_DELETE_DIRECTORY, 0, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { -+ name_len = cifs_strtoUCS((wchar_t *) pSMB->DirName, dirName, 530 -+ /* find define for this maxpathcomponent */ -+ , nls_codepage); -+ name_len++; /* trailing null */ -+ name_len *= 2; -+ } else { /* BB improve the check for buffer overruns BB */ -+ name_len = strnlen(dirName, 530); -+ name_len++; /* trailing null */ -+ strncpy(pSMB->DirName, dirName, name_len); -+ } -+ -+ pSMB->ByteCount = name_len + 1; -+ pSMB->BufferFormat = 0x04; -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc) { -+ cFYI(1, ("Error in RMDir = %d", rc)); -+ } -+#ifdef CONFIG_CIFS_STATS -+ else { -+ atomic_inc(&tcon->num_rmdirs); -+ } -+#endif -+ -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ if (rc == -EAGAIN) -+ goto RmDirRetry; -+ return rc; -+} -+ -+int -+CIFSSMBMkDir(const int xid, struct cifsTconInfo *tcon, -+ const char *name, const struct nls_table *nls_codepage) -+{ -+ int rc = 0; -+ CREATE_DIRECTORY_REQ *pSMB = NULL; -+ CREATE_DIRECTORY_RSP *pSMBr = NULL; -+ int bytes_returned; -+ int name_len; -+ -+ cFYI(1, ("In CIFSSMBMkDir")); -+MkDirRetry: -+ rc = smb_init(SMB_COM_CREATE_DIRECTORY, 0, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { -+ name_len = cifs_strtoUCS((wchar_t *) pSMB->DirName, name, 530 -+ /* find define for this maxpathcomponent */ -+ , nls_codepage); -+ name_len++; /* trailing null */ -+ name_len *= 2; -+ } else { /* BB improve the check for buffer overruns BB */ -+ name_len = strnlen(name, 530); -+ name_len++; /* trailing null */ -+ strncpy(pSMB->DirName, name, name_len); -+ } -+ -+ pSMB->ByteCount = name_len + 1 /* for buf format */ ; -+ pSMB->BufferFormat = 0x04; -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc) { -+ cFYI(1, ("Error in Mkdir = %d", rc)); -+ } -+#ifdef CONFIG_CIFS_STATS -+ else { -+ atomic_inc(&tcon->num_mkdirs); -+ } -+#endif -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ if (rc == -EAGAIN) -+ goto MkDirRetry; -+ return rc; -+} -+ -+int -+CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon, -+ const char *fileName, const int openDisposition, -+ const int access_flags, const int create_options, __u16 * netfid, -+ int *pOplock, FILE_ALL_INFO * pfile_info, -+ const struct nls_table *nls_codepage) -+{ -+ int rc = -EACCES; -+ OPEN_REQ *pSMB = NULL; -+ OPEN_RSP *pSMBr = NULL; -+ int bytes_returned; -+ int name_len; -+ -+openRetry: -+ rc = smb_init(SMB_COM_NT_CREATE_ANDX, 24, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ pSMB->AndXCommand = 0xFF; /* none */ -+ -+ if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { -+ pSMB->ByteCount = 1; /* account for one byte pad to word boundary */ -+ name_len = -+ cifs_strtoUCS((wchar_t *) (pSMB->fileName + 1), -+ fileName, 530 -+ /* find define for this maxpathcomponent */ -+ , nls_codepage); -+ name_len++; /* trailing null */ -+ name_len *= 2; -+ pSMB->NameLength = cpu_to_le16(name_len); -+ } else { /* BB improve the check for buffer overruns BB */ -+ pSMB->ByteCount = 0; /* no pad */ -+ name_len = strnlen(fileName, 530); -+ name_len++; /* trailing null */ -+ pSMB->NameLength = cpu_to_le16(name_len); -+ strncpy(pSMB->fileName, fileName, name_len); -+ } -+ if (*pOplock & REQ_OPLOCK) -+ pSMB->OpenFlags = cpu_to_le32(REQ_OPLOCK); -+ else if (*pOplock & REQ_BATCHOPLOCK) { -+ pSMB->OpenFlags = cpu_to_le32(REQ_BATCHOPLOCK); -+ } -+ pSMB->DesiredAccess = cpu_to_le32(access_flags); -+ pSMB->AllocationSize = 0; -+ pSMB->FileAttributes = ATTR_NORMAL; -+ /* XP does not handle ATTR_POSIX_SEMANTICS */ -+ /* but it helps speed up case sensitive checks for other -+ servers such as Samba */ -+ if (tcon->ses->capabilities & CAP_UNIX) -+ pSMB->FileAttributes |= ATTR_POSIX_SEMANTICS; -+ -+ /* if ((omode & S_IWUGO) == 0) -+ pSMB->FileAttributes |= ATTR_READONLY;*/ -+ /* Above line causes problems due to vfs splitting create into two -+ pieces - need to set mode after file created not while it is -+ being created */ -+ pSMB->FileAttributes = cpu_to_le32(pSMB->FileAttributes); -+ pSMB->ShareAccess = cpu_to_le32(FILE_SHARE_ALL); -+ pSMB->CreateDisposition = cpu_to_le32(openDisposition); -+ pSMB->CreateOptions = cpu_to_le32(create_options); -+ pSMB->ImpersonationLevel = cpu_to_le32(SECURITY_IMPERSONATION); /* BB ??*/ -+ pSMB->SecurityFlags = -+ cpu_to_le32(SECURITY_CONTEXT_TRACKING | SECURITY_EFFECTIVE_ONLY); -+ -+ pSMB->ByteCount += name_len; -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ /* long_op set to 1 to allow for oplock break timeouts */ -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 1); -+ if (rc) { -+ cFYI(1, ("Error in Open = %d", rc)); -+ } else { -+ *pOplock = pSMBr->OplockLevel; /* one byte no need to le_to_cpu */ -+ *netfid = pSMBr->Fid; /* cifs fid stays in le */ -+ /* Let caller know file was created so we can set the mode. */ -+ /* Do we care about the CreateAction in any other cases? */ -+ if(cpu_to_le32(FILE_CREATE) == pSMBr->CreateAction) -+ *pOplock |= CIFS_CREATE_ACTION; -+ if(pfile_info) { -+ memcpy((char *)pfile_info,(char *)&pSMBr->CreationTime, -+ 36 /* CreationTime to Attributes */); -+ /* the file_info buf is endian converted by caller */ -+ pfile_info->AllocationSize = pSMBr->AllocationSize; -+ pfile_info->EndOfFile = pSMBr->EndOfFile; -+ pfile_info->NumberOfLinks = cpu_to_le32(1); -+ } -+ -+#ifdef CONFIG_CIFS_STATS -+ atomic_inc(&tcon->num_opens); -+#endif -+ } -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ if (rc == -EAGAIN) -+ goto openRetry; -+ return rc; -+} -+ -+/* If no buffer passed in, then caller wants to do the copy -+ as in the case of readpages so the SMB buffer must be -+ freed by the caller */ -+ -+int -+CIFSSMBRead(const int xid, struct cifsTconInfo *tcon, -+ const int netfid, const unsigned int count, -+ const __u64 lseek, unsigned int *nbytes, char **buf) -+{ -+ int rc = -EACCES; -+ READ_REQ *pSMB = NULL; -+ READ_RSP *pSMBr = NULL; -+ char *pReadData = NULL; -+ int bytes_returned; -+ -+ *nbytes = 0; -+ rc = smb_init(SMB_COM_READ_ANDX, 12, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ /* tcon and ses pointer are checked in smb_init */ -+ if (tcon->ses->server == NULL) -+ return -ECONNABORTED; -+ -+ pSMB->AndXCommand = 0xFF; /* none */ -+ pSMB->Fid = netfid; -+ pSMB->OffsetLow = cpu_to_le32(lseek & 0xFFFFFFFF); -+ pSMB->OffsetHigh = cpu_to_le32(lseek >> 32); -+ pSMB->Remaining = 0; -+ pSMB->MaxCount = cpu_to_le16(count); -+ pSMB->MaxCountHigh = 0; -+ pSMB->ByteCount = 0; /* no need to do le conversion since it is 0 */ -+ -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc) { -+ cERROR(1, ("Send error in read = %d", rc)); -+ } else { -+ pSMBr->DataLength = le16_to_cpu(pSMBr->DataLength); -+ *nbytes = pSMBr->DataLength; -+ /*check that DataLength would not go beyond end of SMB */ -+ if ((pSMBr->DataLength > CIFS_MAX_MSGSIZE) -+ || (pSMBr->DataLength > count)) { -+ cFYI(1,("bad length %d for count %d",pSMBr->DataLength,count)); -+ rc = -EIO; -+ *nbytes = 0; -+ } else { -+ pReadData = -+ (char *) (&pSMBr->hdr.Protocol) + -+ le16_to_cpu(pSMBr->DataOffset); -+/* if(rc = copy_to_user(buf, pReadData, pSMBr->DataLength)) { -+ cERROR(1,("Faulting on read rc = %d",rc)); -+ rc = -EFAULT; -+ }*/ /* can not use copy_to_user when using page cache*/ -+ if(*buf) -+ memcpy(*buf,pReadData,pSMBr->DataLength); -+ } -+ } -+ if (pSMB) { -+ if(*buf) -+ cifs_buf_release(pSMB); -+ else -+ *buf = (char *)pSMB; -+ } -+ -+ /* Note: On -EAGAIN error only caller can retry on handle based calls -+ since file handle passed in no longer valid */ -+ return rc; -+} -+ -+int -+CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon, -+ const int netfid, const unsigned int count, -+ const __u64 offset, unsigned int *nbytes, const char *buf, -+ const int long_op) -+{ -+ int rc = -EACCES; -+ WRITE_REQ *pSMB = NULL; -+ WRITE_RSP *pSMBr = NULL; -+ int bytes_returned; -+ -+ rc = smb_init(SMB_COM_WRITE_ANDX, 14, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ /* tcon and ses pointer are checked in smb_init */ -+ if (tcon->ses->server == NULL) -+ return -ECONNABORTED; -+ -+ pSMB->AndXCommand = 0xFF; /* none */ -+ pSMB->Fid = netfid; -+ pSMB->OffsetLow = cpu_to_le32(offset & 0xFFFFFFFF); -+ pSMB->OffsetHigh = cpu_to_le32(offset >> 32); -+ pSMB->Remaining = 0; -+ if (count > ((tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) & 0xFFFFFF00)) -+ pSMB->DataLengthLow = -+ (tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) & 0xFFFFFF00; -+ else -+ pSMB->DataLengthLow = count; -+ pSMB->DataLengthHigh = 0; -+ pSMB->DataOffset = -+ cpu_to_le16(offsetof(struct smb_com_write_req,Data) - 4); -+ -+ memcpy(pSMB->Data,buf,pSMB->DataLengthLow); -+ -+ pSMB->ByteCount += pSMB->DataLengthLow + 1 /* pad */ ; -+ pSMB->DataLengthLow = cpu_to_le16(pSMB->DataLengthLow); -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, long_op); -+ if (rc) { -+ cFYI(1, ("Send error in write = %d", rc)); -+ *nbytes = 0; -+ } else -+ *nbytes = le16_to_cpu(pSMBr->Count); -+ -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ -+ /* Note: On -EAGAIN error only caller can retry on handle based calls -+ since file handle passed in no longer valid */ -+ -+ return rc; -+} -+ -+int -+CIFSSMBLock(const int xid, struct cifsTconInfo *tcon, -+ const __u16 smb_file_id, const __u64 len, -+ const __u64 offset, const __u32 numUnlock, -+ const __u32 numLock, const __u8 lockType, const int waitFlag) -+{ -+ int rc = 0; -+ LOCK_REQ *pSMB = NULL; -+ LOCK_RSP *pSMBr = NULL; -+ int bytes_returned; -+ int timeout = 0; -+ __u64 temp; -+ -+ cFYI(1, ("In CIFSSMBLock - timeout %d numLock %d",waitFlag,numLock)); -+ rc = smb_init(SMB_COM_LOCKING_ANDX, 8, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ if(lockType == LOCKING_ANDX_OPLOCK_RELEASE) { -+ timeout = -1; /* no response expected */ -+ pSMB->Timeout = 0; -+ } else if (waitFlag == TRUE) { -+ timeout = 3; /* blocking operation, no timeout */ -+ pSMB->Timeout = -1; /* blocking - do not time out */ -+ } else { -+ pSMB->Timeout = 0; -+ } -+ -+ pSMB->NumberOfLocks = cpu_to_le32(numLock); -+ pSMB->NumberOfUnlocks = cpu_to_le32(numUnlock); -+ pSMB->LockType = lockType; -+ pSMB->AndXCommand = 0xFF; /* none */ -+ pSMB->Fid = smb_file_id; /* netfid stays le */ -+ -+ if(numLock != 0) { -+ pSMB->Locks[0].Pid = cpu_to_le16(current->tgid); -+ /* BB where to store pid high? */ -+ temp = cpu_to_le64(len); -+ pSMB->Locks[0].LengthLow = (__u32)(temp & 0xFFFFFFFF); -+ pSMB->Locks[0].LengthHigh = (__u32)(temp>>32); -+ temp = cpu_to_le64(offset); -+ pSMB->Locks[0].OffsetLow = (__u32)(temp & 0xFFFFFFFF); -+ pSMB->Locks[0].OffsetHigh = (__u32)(temp>>32); -+ pSMB->ByteCount = sizeof (LOCKING_ANDX_RANGE); -+ } else { -+ /* oplock break */ -+ pSMB->ByteCount = 0; -+ } -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, timeout); -+ -+ if (rc) { -+ cFYI(1, ("Send error in Lock = %d", rc)); -+ } -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ -+ /* Note: On -EAGAIN error only caller can retry on handle based calls -+ since file handle passed in no longer valid */ -+ return rc; -+} -+ -+int -+CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, int smb_file_id) -+{ -+ int rc = 0; -+ CLOSE_REQ *pSMB = NULL; -+ CLOSE_RSP *pSMBr = NULL; -+ int bytes_returned; -+ cFYI(1, ("In CIFSSMBClose")); -+ -+/* do not retry on dead session on close */ -+ rc = smb_init(SMB_COM_CLOSE, 3, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if(rc == -EAGAIN) -+ return 0; -+ if (rc) -+ return rc; -+ -+ pSMB->FileID = (__u16) smb_file_id; -+ pSMB->LastWriteTime = 0; -+ pSMB->ByteCount = 0; -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc) { -+ if(rc!=-EINTR) { -+ /* EINTR is expected when user ctl-c to kill app */ -+ cERROR(1, ("Send error in Close = %d", rc)); -+ } -+ } -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ -+ /* Since session is dead, file will be closed on server already */ -+ if(rc == -EAGAIN) -+ rc = 0; -+ -+ return rc; -+} -+ -+int -+CIFSSMBRename(const int xid, struct cifsTconInfo *tcon, -+ const char *fromName, const char *toName, -+ const struct nls_table *nls_codepage) -+{ -+ int rc = 0; -+ RENAME_REQ *pSMB = NULL; -+ RENAME_RSP *pSMBr = NULL; -+ int bytes_returned; -+ int name_len, name_len2; -+ -+ cFYI(1, ("In CIFSSMBRename")); -+renameRetry: -+ rc = smb_init(SMB_COM_RENAME, 1, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ pSMB->BufferFormat = 0x04; -+ pSMB->SearchAttributes = -+ cpu_to_le16(ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM | -+ ATTR_DIRECTORY); -+ -+ if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { -+ name_len = -+ cifs_strtoUCS((wchar_t *) pSMB->OldFileName, fromName, 530 -+ /* find define for this maxpathcomponent */ -+ , nls_codepage); -+ name_len++; /* trailing null */ -+ name_len *= 2; -+ pSMB->OldFileName[name_len] = 0x04; /* pad */ -+ /* protocol requires ASCII signature byte on Unicode string */ -+ pSMB->OldFileName[name_len + 1] = 0x00; -+ name_len2 = -+ cifs_strtoUCS((wchar_t *) & pSMB-> -+ OldFileName[name_len + 2], toName, 530, -+ nls_codepage); -+ name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; -+ name_len2 *= 2; /* convert to bytes */ -+ } else { /* BB improve the check for buffer overruns BB */ -+ name_len = strnlen(fromName, 530); -+ name_len++; /* trailing null */ -+ strncpy(pSMB->OldFileName, fromName, name_len); -+ name_len2 = strnlen(toName, 530); -+ name_len2++; /* trailing null */ -+ pSMB->OldFileName[name_len] = 0x04; /* 2nd buffer format */ -+ strncpy(&pSMB->OldFileName[name_len + 1], toName, name_len2); -+ name_len2++; /* trailing null */ -+ name_len2++; /* signature byte */ -+ } -+ -+ pSMB->ByteCount = 1 /* 1st signature byte */ + name_len + name_len2; -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc) { -+ cFYI(1, ("Send error in rename = %d", rc)); -+ } -+ -+#ifdef CONFIG_CIFS_STATS -+ else { -+ atomic_inc(&tcon->num_renames); -+ } -+#endif -+ -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ -+ if (rc == -EAGAIN) -+ goto renameRetry; -+ -+ return rc; -+} -+ -+int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon, -+ int netfid, char * target_name, const struct nls_table * nls_codepage) -+{ -+ struct smb_com_transaction2_sfi_req *pSMB = NULL; -+ struct smb_com_transaction2_sfi_rsp *pSMBr = NULL; -+ struct set_file_rename * rename_info; -+ char *data_offset; -+ char dummy_string[30]; -+ int rc = 0; -+ int bytes_returned = 0; -+ int len_of_str; -+ -+ cFYI(1, ("Rename to File by handle")); -+ rc = smb_init(SMB_COM_TRANSACTION2, 15, pTcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ pSMB->ParameterCount = 6; -+ pSMB->MaxSetupCount = 0; -+ pSMB->Reserved = 0; -+ pSMB->Flags = 0; -+ pSMB->Timeout = 0; -+ pSMB->Reserved2 = 0; -+ pSMB->ParameterOffset = offsetof(struct smb_com_transaction2_sfi_req, -+ Fid) - 4; -+ pSMB->DataOffset = pSMB->ParameterOffset + pSMB->ParameterCount; -+ -+ data_offset = (char *) (&pSMB->hdr.Protocol) + pSMB->DataOffset; -+ rename_info = (struct set_file_rename *) data_offset; -+ pSMB->MaxParameterCount = cpu_to_le16(2); -+ pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB PDU from sess */ -+ pSMB->SetupCount = 1; -+ pSMB->Reserved3 = 0; -+ pSMB->SubCommand = cpu_to_le16(TRANS2_SET_FILE_INFORMATION); -+ pSMB->ByteCount = 3 /* pad */ + pSMB->ParameterCount; -+ pSMB->ParameterCount = cpu_to_le16(pSMB->ParameterCount); -+ pSMB->TotalParameterCount = pSMB->ParameterCount; -+ pSMB->ParameterOffset = cpu_to_le16(pSMB->ParameterOffset); -+ pSMB->DataOffset = cpu_to_le16(pSMB->DataOffset); -+ /* construct random name ".cifs_tmp<inodenum><mid>" */ -+ rename_info->overwrite = cpu_to_le32(1); -+ rename_info->root_fid = 0; -+ /* unicode only call */ -+ if(target_name == NULL) { -+ sprintf(dummy_string,"cifs%x",pSMB->hdr.Mid); -+ len_of_str = cifs_strtoUCS((wchar_t *) rename_info->target_name, dummy_string, 24, nls_codepage); -+ } else { -+ len_of_str = cifs_strtoUCS((wchar_t *) rename_info->target_name, target_name, 530, nls_codepage); -+ } -+ rename_info->target_name_len = cpu_to_le32(2 * len_of_str); -+ pSMB->DataCount = 12 /* sizeof(struct set_file_rename) */ + (2 * len_of_str) + 2; -+ pSMB->ByteCount += pSMB->DataCount; -+ pSMB->DataCount = cpu_to_le16(pSMB->DataCount); -+ pSMB->TotalDataCount = pSMB->DataCount; -+ pSMB->Fid = netfid; -+ pSMB->InformationLevel = -+ cpu_to_le16(SMB_SET_FILE_RENAME_INFORMATION); -+ pSMB->Reserved4 = 0; -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ rc = SendReceive(xid, pTcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc) { -+ cFYI(1,("Send error in Rename (by file handle) = %d", rc)); -+ } -+#ifdef CONFIG_CIFS_STATS -+ else { -+ atomic_inc(&pTcon->num_t2renames); -+ } -+#endif -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ -+ /* Note: On -EAGAIN error only caller can retry on handle based calls -+ since file handle passed in no longer valid */ -+ -+ return rc; -+} -+ -+int -+CIFSSMBCopy(const int xid, struct cifsTconInfo *tcon, const char * fromName, -+ const __u16 target_tid, const char *toName, const int flags, -+ const struct nls_table *nls_codepage) -+{ -+ int rc = 0; -+ COPY_REQ *pSMB = NULL; -+ COPY_RSP *pSMBr = NULL; -+ int bytes_returned; -+ int name_len, name_len2; -+ -+ cFYI(1, ("In CIFSSMBCopy")); -+copyRetry: -+ rc = smb_init(SMB_COM_COPY, 1, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ pSMB->BufferFormat = 0x04; -+ pSMB->Tid2 = target_tid; -+ -+ if(flags & COPY_TREE) -+ pSMB->Flags |= COPY_TREE; -+ pSMB->Flags = cpu_to_le16(pSMB->Flags); -+ -+ if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { -+ name_len = cifs_strtoUCS((wchar_t *) pSMB->OldFileName, -+ fromName, -+ 530 /* find define for this maxpathcomponent */, -+ nls_codepage); -+ name_len++; /* trailing null */ -+ name_len *= 2; -+ pSMB->OldFileName[name_len] = 0x04; /* pad */ -+ /* protocol requires ASCII signature byte on Unicode string */ -+ pSMB->OldFileName[name_len + 1] = 0x00; -+ name_len2 = cifs_strtoUCS((wchar_t *) & pSMB-> -+ OldFileName[name_len + 2], toName, 530, -+ nls_codepage); -+ name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; -+ name_len2 *= 2; /* convert to bytes */ -+ } else { /* BB improve the check for buffer overruns BB */ -+ name_len = strnlen(fromName, 530); -+ name_len++; /* trailing null */ -+ strncpy(pSMB->OldFileName, fromName, name_len); -+ name_len2 = strnlen(toName, 530); -+ name_len2++; /* trailing null */ -+ pSMB->OldFileName[name_len] = 0x04; /* 2nd buffer format */ -+ strncpy(&pSMB->OldFileName[name_len + 1], toName, name_len2); -+ name_len2++; /* trailing null */ -+ name_len2++; /* signature byte */ -+ } -+ -+ pSMB->ByteCount = 1 /* 1st signature byte */ + name_len + name_len2; -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc) { -+ cFYI(1, ("Send error in copy = %d with %d files copied", -+ rc, pSMBr->CopyCount)); -+ } -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ -+ if (rc == -EAGAIN) -+ goto copyRetry; -+ -+ return rc; -+} -+ -+int -+CIFSUnixCreateSymLink(const int xid, struct cifsTconInfo *tcon, -+ const char *fromName, const char *toName, -+ const struct nls_table *nls_codepage) -+{ -+ TRANSACTION2_SPI_REQ *pSMB = NULL; -+ TRANSACTION2_SPI_RSP *pSMBr = NULL; -+ char *data_offset; -+ int name_len; -+ int name_len_target; -+ int rc = 0; -+ int bytes_returned = 0; -+ -+ cFYI(1, ("In Symlink Unix style")); -+createSymLinkRetry: -+ rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { -+ name_len = -+ cifs_strtoUCS((wchar_t *) pSMB->FileName, fromName, 530 -+ /* find define for this maxpathcomponent */ -+ , nls_codepage); -+ name_len++; /* trailing null */ -+ name_len *= 2; -+ -+ } else { /* BB improve the check for buffer overruns BB */ -+ name_len = strnlen(fromName, 530); -+ name_len++; /* trailing null */ -+ strncpy(pSMB->FileName, fromName, name_len); -+ } -+ pSMB->ParameterCount = 6 + name_len; -+ pSMB->MaxSetupCount = 0; -+ pSMB->Reserved = 0; -+ pSMB->Flags = 0; -+ pSMB->Timeout = 0; -+ pSMB->Reserved2 = 0; -+ pSMB->ParameterOffset = offsetof(struct smb_com_transaction2_spi_req, -+ InformationLevel) - 4; -+ pSMB->DataOffset = pSMB->ParameterOffset + pSMB->ParameterCount; -+ -+ data_offset = (char *) (&pSMB->hdr.Protocol) + pSMB->DataOffset; -+ if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { -+ name_len_target = -+ cifs_strtoUCS((wchar_t *) data_offset, toName, 530 -+ /* find define for this maxpathcomponent */ -+ , nls_codepage); -+ name_len_target++; /* trailing null */ -+ name_len_target *= 2; -+ } else { /* BB improve the check for buffer overruns BB */ -+ name_len_target = strnlen(toName, 530); -+ name_len_target++; /* trailing null */ -+ strncpy(data_offset, toName, name_len_target); -+ } -+ -+ pSMB->DataCount = name_len_target; -+ pSMB->MaxParameterCount = cpu_to_le16(2); -+ /* BB find exact max on data count below from sess */ -+ pSMB->MaxDataCount = cpu_to_le16(1000); -+ pSMB->SetupCount = 1; -+ pSMB->Reserved3 = 0; -+ pSMB->SubCommand = cpu_to_le16(TRANS2_SET_PATH_INFORMATION); -+ pSMB->ByteCount = 3 /* pad */ + pSMB->ParameterCount + pSMB->DataCount; -+ pSMB->DataCount = cpu_to_le16(pSMB->DataCount); -+ pSMB->ParameterCount = cpu_to_le16(pSMB->ParameterCount); -+ pSMB->TotalDataCount = pSMB->DataCount; -+ pSMB->TotalParameterCount = pSMB->ParameterCount; -+ pSMB->ParameterOffset = cpu_to_le16(pSMB->ParameterOffset); -+ pSMB->DataOffset = cpu_to_le16(pSMB->DataOffset); -+ pSMB->InformationLevel = cpu_to_le16(SMB_SET_FILE_UNIX_LINK); -+ pSMB->Reserved4 = 0; -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc) { -+ cFYI(1, -+ ("Send error in SetPathInfo (create symlink) = %d", -+ rc)); -+ } -+ -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ -+ if (rc == -EAGAIN) -+ goto createSymLinkRetry; -+ -+ return rc; -+} -+ -+int -+CIFSUnixCreateHardLink(const int xid, struct cifsTconInfo *tcon, -+ const char *fromName, const char *toName, -+ const struct nls_table *nls_codepage) -+{ -+ TRANSACTION2_SPI_REQ *pSMB = NULL; -+ TRANSACTION2_SPI_RSP *pSMBr = NULL; -+ char *data_offset; -+ int name_len; -+ int name_len_target; -+ int rc = 0; -+ int bytes_returned = 0; -+ -+ cFYI(1, ("In Create Hard link Unix style")); -+createHardLinkRetry: -+ rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { -+ name_len = cifs_strtoUCS((wchar_t *) pSMB->FileName, toName, 530 -+ /* find define for this maxpathcomponent */ -+ , nls_codepage); -+ name_len++; /* trailing null */ -+ name_len *= 2; -+ -+ } else { /* BB improve the check for buffer overruns BB */ -+ name_len = strnlen(toName, 530); -+ name_len++; /* trailing null */ -+ strncpy(pSMB->FileName, toName, name_len); -+ } -+ pSMB->ParameterCount = 6 + name_len; -+ pSMB->MaxSetupCount = 0; -+ pSMB->Reserved = 0; -+ pSMB->Flags = 0; -+ pSMB->Timeout = 0; -+ pSMB->Reserved2 = 0; -+ pSMB->ParameterOffset = offsetof(struct smb_com_transaction2_spi_req, -+ InformationLevel) - 4; -+ pSMB->DataOffset = pSMB->ParameterOffset + pSMB->ParameterCount; -+ -+ data_offset = (char *) (&pSMB->hdr.Protocol) + pSMB->DataOffset; -+ if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { -+ name_len_target = -+ cifs_strtoUCS((wchar_t *) data_offset, fromName, 530 -+ /* find define for this maxpathcomponent */ -+ , nls_codepage); -+ name_len_target++; /* trailing null */ -+ name_len_target *= 2; -+ } else { /* BB improve the check for buffer overruns BB */ -+ name_len_target = strnlen(fromName, 530); -+ name_len_target++; /* trailing null */ -+ strncpy(data_offset, fromName, name_len_target); -+ } -+ -+ pSMB->DataCount = name_len_target; -+ pSMB->MaxParameterCount = cpu_to_le16(2); -+ /* BB find exact max on data count below from sess*/ -+ pSMB->MaxDataCount = cpu_to_le16(1000); -+ pSMB->SetupCount = 1; -+ pSMB->Reserved3 = 0; -+ pSMB->SubCommand = cpu_to_le16(TRANS2_SET_PATH_INFORMATION); -+ pSMB->ByteCount = 3 /* pad */ + pSMB->ParameterCount + pSMB->DataCount; -+ pSMB->ParameterCount = cpu_to_le16(pSMB->ParameterCount); -+ pSMB->TotalParameterCount = pSMB->ParameterCount; -+ pSMB->DataCount = cpu_to_le16(pSMB->DataCount); -+ pSMB->TotalDataCount = pSMB->DataCount; -+ pSMB->ParameterOffset = cpu_to_le16(pSMB->ParameterOffset); -+ pSMB->DataOffset = cpu_to_le16(pSMB->DataOffset); -+ pSMB->InformationLevel = cpu_to_le16(SMB_SET_FILE_UNIX_HLINK); -+ pSMB->Reserved4 = 0; -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc) { -+ cFYI(1, ("Send error in SetPathInfo (hard link) = %d", rc)); -+ } -+ -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ if (rc == -EAGAIN) -+ goto createHardLinkRetry; -+ -+ return rc; -+} -+ -+int -+CIFSCreateHardLink(const int xid, struct cifsTconInfo *tcon, -+ const char *fromName, const char *toName, -+ const struct nls_table *nls_codepage) -+{ -+ int rc = 0; -+ NT_RENAME_REQ *pSMB = NULL; -+ RENAME_RSP *pSMBr = NULL; -+ int bytes_returned; -+ int name_len, name_len2; -+ -+ cFYI(1, ("In CIFSCreateHardLink")); -+winCreateHardLinkRetry: -+ -+ rc = smb_init(SMB_COM_NT_RENAME, 4, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ pSMB->SearchAttributes = -+ cpu_to_le16(ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM | -+ ATTR_DIRECTORY); -+ pSMB->Flags = cpu_to_le16(CREATE_HARD_LINK); -+ pSMB->ClusterCount = 0; -+ -+ pSMB->BufferFormat = 0x04; -+ -+ if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { -+ name_len = -+ cifs_strtoUCS((wchar_t *) pSMB->OldFileName, fromName, 530 -+ /* find define for this maxpathcomponent */ -+ , nls_codepage); -+ name_len++; /* trailing null */ -+ name_len *= 2; -+ pSMB->OldFileName[name_len] = 0; /* pad */ -+ pSMB->OldFileName[name_len + 1] = 0x04; -+ name_len2 = -+ cifs_strtoUCS((wchar_t *) & pSMB-> -+ OldFileName[name_len + 2], toName, 530, -+ nls_codepage); -+ name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; -+ name_len2 *= 2; /* convert to bytes */ -+ } else { /* BB improve the check for buffer overruns BB */ -+ name_len = strnlen(fromName, 530); -+ name_len++; /* trailing null */ -+ strncpy(pSMB->OldFileName, fromName, name_len); -+ name_len2 = strnlen(toName, 530); -+ name_len2++; /* trailing null */ -+ pSMB->OldFileName[name_len] = 0x04; /* 2nd buffer format */ -+ strncpy(&pSMB->OldFileName[name_len + 1], toName, name_len2); -+ name_len2++; /* trailing null */ -+ name_len2++; /* signature byte */ -+ } -+ -+ pSMB->ByteCount = 1 /* string type byte */ + name_len + name_len2; -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc) { -+ cFYI(1, ("Send error in hard link (NT rename) = %d", rc)); -+ } -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ if (rc == -EAGAIN) -+ goto winCreateHardLinkRetry; -+ -+ return rc; -+} -+ -+int -+CIFSSMBUnixQuerySymLink(const int xid, struct cifsTconInfo *tcon, -+ const unsigned char *searchName, -+ char *symlinkinfo, const int buflen, -+ const struct nls_table *nls_codepage) -+{ -+/* SMB_QUERY_FILE_UNIX_LINK */ -+ TRANSACTION2_QPI_REQ *pSMB = NULL; -+ TRANSACTION2_QPI_RSP *pSMBr = NULL; -+ int rc = 0; -+ int bytes_returned; -+ int name_len; -+ -+ cFYI(1, ("In QPathSymLinkInfo (Unix) for path %s", searchName)); -+ -+querySymLinkRetry: -+ rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { -+ name_len = -+ cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, 530 -+ /* find define for this maxpathcomponent */ -+ , nls_codepage); -+ name_len++; /* trailing null */ -+ name_len *= 2; -+ } else { /* BB improve the check for buffer overruns BB */ -+ name_len = strnlen(searchName, 530); -+ name_len++; /* trailing null */ -+ strncpy(pSMB->FileName, searchName, name_len); -+ } -+ -+ pSMB->TotalParameterCount = -+ 2 /* level */ + 4 /* rsrvd */ + name_len /* incl null */ ; -+ pSMB->TotalDataCount = 0; -+ pSMB->MaxParameterCount = cpu_to_le16(2); -+ /* BB find exact max data count below from sess structure BB */ -+ pSMB->MaxDataCount = cpu_to_le16(4000); -+ pSMB->MaxSetupCount = 0; -+ pSMB->Reserved = 0; -+ pSMB->Flags = 0; -+ pSMB->Timeout = 0; -+ pSMB->Reserved2 = 0; -+ pSMB->ParameterOffset = cpu_to_le16(offsetof( -+ struct smb_com_transaction2_qpi_req ,InformationLevel) - 4); -+ pSMB->DataCount = 0; -+ pSMB->DataOffset = 0; -+ pSMB->SetupCount = 1; -+ pSMB->Reserved3 = 0; -+ pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_PATH_INFORMATION); -+ pSMB->ByteCount = pSMB->TotalParameterCount + 1 /* pad */ ; -+ pSMB->TotalParameterCount = cpu_to_le16(pSMB->TotalParameterCount); -+ pSMB->ParameterCount = pSMB->TotalParameterCount; -+ pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_UNIX_LINK); -+ pSMB->Reserved4 = 0; -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc) { -+ cFYI(1, ("Send error in QuerySymLinkInfo = %d", rc)); -+ } else { /* decode response */ -+ pSMBr->DataOffset = le16_to_cpu(pSMBr->DataOffset); -+ pSMBr->DataCount = le16_to_cpu(pSMBr->DataCount); -+ if ((pSMBr->ByteCount < 2) || (pSMBr->DataOffset > 512)) -+ /* BB also check enough total bytes returned */ -+ rc = -EIO; /* bad smb */ -+ else { -+ if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) { -+ name_len = UniStrnlen((wchar_t *) ((char *) -+ &pSMBr->hdr.Protocol +pSMBr->DataOffset), -+ min_t(const int, buflen,pSMBr->DataCount) / 2); -+ cifs_strfromUCS_le(symlinkinfo, -+ (wchar_t *) ((char *)&pSMBr->hdr.Protocol + -+ pSMBr->DataOffset), -+ name_len, nls_codepage); -+ } else { -+ strncpy(symlinkinfo, -+ (char *) &pSMBr->hdr.Protocol + -+ pSMBr->DataOffset, -+ min_t(const int, buflen, pSMBr->DataCount)); -+ } -+ symlinkinfo[buflen] = 0; -+ /* just in case so calling code does not go off the end of buffer */ -+ } -+ } -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ if (rc == -EAGAIN) -+ goto querySymLinkRetry; -+ return rc; -+} -+ -+ -+ -+int -+CIFSSMBQueryReparseLinkInfo(const int xid, struct cifsTconInfo *tcon, -+ const unsigned char *searchName, -+ char *symlinkinfo, const int buflen,__u16 fid, -+ const struct nls_table *nls_codepage) -+{ -+ int rc = 0; -+ int bytes_returned; -+ int name_len; -+ struct smb_com_transaction_ioctl_req * pSMB; -+ struct smb_com_transaction_ioctl_rsp * pSMBr; -+ -+ cFYI(1, ("In Windows reparse style QueryLink for path %s", searchName)); -+ rc = smb_init(SMB_COM_NT_TRANSACT, 23, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ pSMB->TotalParameterCount = 0 ; -+ pSMB->TotalDataCount = 0; -+ pSMB->MaxParameterCount = cpu_to_le32(2); -+ /* BB find exact data count max from sess structure BB */ -+ pSMB->MaxDataCount = cpu_to_le32(4000); -+ pSMB->MaxSetupCount = 4; -+ pSMB->Reserved = 0; -+ pSMB->ParameterOffset = 0; -+ pSMB->DataCount = 0; -+ pSMB->DataOffset = 0; -+ pSMB->SetupCount = 4; -+ pSMB->SubCommand = cpu_to_le16(NT_TRANSACT_IOCTL); -+ pSMB->ParameterCount = pSMB->TotalParameterCount; -+ pSMB->FunctionCode = cpu_to_le32(FSCTL_GET_REPARSE_POINT); -+ pSMB->IsFsctl = 1; /* FSCTL */ -+ pSMB->IsRootFlag = 0; -+ pSMB->Fid = fid; /* file handle always le */ -+ pSMB->ByteCount = 0; -+ -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc) { -+ cFYI(1, ("Send error in QueryReparseLinkInfo = %d", rc)); -+ } else { /* decode response */ -+ pSMBr->DataOffset = le16_to_cpu(pSMBr->DataOffset); -+ pSMBr->DataCount = le16_to_cpu(pSMBr->DataCount); -+ if ((pSMBr->ByteCount < 2) || (pSMBr->DataOffset > 512)) -+ /* BB also check enough total bytes returned */ -+ rc = -EIO; /* bad smb */ -+ else { -+ if(pSMBr->DataCount && (pSMBr->DataCount < 2048)) { -+ /* could also validate reparse tag && better check name length */ -+ struct reparse_data * reparse_buf = (struct reparse_data *) -+ ((char *)&pSMBr->hdr.Protocol + pSMBr->DataOffset); -+ if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) { -+ name_len = UniStrnlen((wchar_t *) -+ (reparse_buf->LinkNamesBuf + -+ reparse_buf->TargetNameOffset), -+ min(buflen/2, reparse_buf->TargetNameLen / 2)); -+ cifs_strfromUCS_le(symlinkinfo, -+ (wchar_t *) (reparse_buf->LinkNamesBuf + -+ reparse_buf->TargetNameOffset), -+ name_len, nls_codepage); -+ } else { /* ASCII names */ -+ strncpy(symlinkinfo,reparse_buf->LinkNamesBuf + -+ reparse_buf->TargetNameOffset, -+ min_t(const int, buflen, reparse_buf->TargetNameLen)); -+ } -+ } else { -+ rc = -EIO; -+ cFYI(1,("Invalid return data count on get reparse info ioctl")); -+ } -+ symlinkinfo[buflen] = 0; /* just in case so the caller -+ does not go off the end of the buffer */ -+ cFYI(1,("readlink result - %s ",symlinkinfo)); -+ } -+ } -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ -+ /* Note: On -EAGAIN error only caller can retry on handle based calls -+ since file handle passed in no longer valid */ -+ -+ return rc; -+} -+ -+int -+CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon, -+ const unsigned char *searchName, -+ FILE_ALL_INFO * pFindData, -+ const struct nls_table *nls_codepage) -+{ -+/* level 263 SMB_QUERY_FILE_ALL_INFO */ -+ TRANSACTION2_QPI_REQ *pSMB = NULL; -+ TRANSACTION2_QPI_RSP *pSMBr = NULL; -+ int rc = 0; -+ int bytes_returned; -+ int name_len; -+ -+ cFYI(1, ("In QPathInfo path %s", searchName)); -+QPathInfoRetry: -+ rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { -+ name_len = -+ cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, 530 -+ /* find define for this maxpathcomponent */ -+ , nls_codepage); -+ name_len++; /* trailing null */ -+ name_len *= 2; -+ } else { /* BB improve the check for buffer overruns BB */ -+ name_len = strnlen(searchName, 530); -+ name_len++; /* trailing null */ -+ strncpy(pSMB->FileName, searchName, name_len); -+ } -+ -+ pSMB->TotalParameterCount = 2 /* level */ + 4 /* reserved */ + -+ name_len /* includes null */ ; -+ pSMB->TotalDataCount = 0; -+ pSMB->MaxParameterCount = cpu_to_le16(2); -+ pSMB->MaxDataCount = cpu_to_le16(4000); /* BB find exact max SMB PDU from sess structure BB */ -+ pSMB->MaxSetupCount = 0; -+ pSMB->Reserved = 0; -+ pSMB->Flags = 0; -+ pSMB->Timeout = 0; -+ pSMB->Reserved2 = 0; -+ pSMB->ParameterOffset = cpu_to_le16(offsetof( -+ struct smb_com_transaction2_qpi_req ,InformationLevel) - 4); -+ pSMB->DataCount = 0; -+ pSMB->DataOffset = 0; -+ pSMB->SetupCount = 1; -+ pSMB->Reserved3 = 0; -+ pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_PATH_INFORMATION); -+ pSMB->ByteCount = pSMB->TotalParameterCount + 1 /* pad */ ; -+ pSMB->TotalParameterCount = cpu_to_le16(pSMB->TotalParameterCount); -+ pSMB->ParameterCount = pSMB->TotalParameterCount; -+ pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_ALL_INFO); -+ pSMB->Reserved4 = 0; -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc) { -+ cFYI(1, ("Send error in QPathInfo = %d", rc)); -+ } else { /* decode response */ -+ pSMBr->DataOffset = le16_to_cpu(pSMBr->DataOffset); -+ /* BB also check enough total bytes returned */ -+ /* BB we need to improve the validity checking -+ of these trans2 responses */ -+ if ((pSMBr->ByteCount < 40) || (pSMBr->DataOffset > 512)) -+ rc = -EIO; /* bad smb */ -+ else if (pFindData){ -+ memcpy((char *) pFindData, -+ (char *) &pSMBr->hdr.Protocol + -+ pSMBr->DataOffset, sizeof (FILE_ALL_INFO)); -+ } else -+ rc = -ENOMEM; -+ } -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ if (rc == -EAGAIN) -+ goto QPathInfoRetry; -+ -+ return rc; -+} -+ -+int -+CIFSSMBUnixQPathInfo(const int xid, struct cifsTconInfo *tcon, -+ const unsigned char *searchName, -+ FILE_UNIX_BASIC_INFO * pFindData, -+ const struct nls_table *nls_codepage) -+{ -+/* SMB_QUERY_FILE_UNIX_BASIC */ -+ TRANSACTION2_QPI_REQ *pSMB = NULL; -+ TRANSACTION2_QPI_RSP *pSMBr = NULL; -+ int rc = 0; -+ int bytes_returned = 0; -+ int name_len; -+ -+ cFYI(1, ("In QPathInfo (Unix) the path %s", searchName)); -+UnixQPathInfoRetry: -+ rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { -+ name_len = -+ cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, 530 -+ /* find define for this maxpathcomponent */ -+ , nls_codepage); -+ name_len++; /* trailing null */ -+ name_len *= 2; -+ } else { /* BB improve the check for buffer overruns BB */ -+ name_len = strnlen(searchName, 530); -+ name_len++; /* trailing null */ -+ strncpy(pSMB->FileName, searchName, name_len); -+ } -+ -+ pSMB->TotalParameterCount = 2 /* level */ + 4 /* reserved */ + -+ name_len /* includes null */ ; -+ pSMB->TotalDataCount = 0; -+ pSMB->MaxParameterCount = cpu_to_le16(2); -+ /* BB find exact max SMB PDU from sess structure BB */ -+ pSMB->MaxDataCount = cpu_to_le16(4000); -+ pSMB->MaxSetupCount = 0; -+ pSMB->Reserved = 0; -+ pSMB->Flags = 0; -+ pSMB->Timeout = 0; -+ pSMB->Reserved2 = 0; -+ pSMB->ParameterOffset = cpu_to_le16(offsetof( -+ struct smb_com_transaction2_qpi_req ,InformationLevel) - 4); -+ pSMB->DataCount = 0; -+ pSMB->DataOffset = 0; -+ pSMB->SetupCount = 1; -+ pSMB->Reserved3 = 0; -+ pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_PATH_INFORMATION); -+ pSMB->ByteCount = pSMB->TotalParameterCount + 1 /* pad */ ; -+ pSMB->TotalParameterCount = cpu_to_le16(pSMB->TotalParameterCount); -+ pSMB->ParameterCount = pSMB->TotalParameterCount; -+ pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_UNIX_BASIC); -+ pSMB->Reserved4 = 0; -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc) { -+ cFYI(1, ("Send error in QPathInfo = %d", rc)); -+ } else { /* decode response */ -+ pSMBr->DataOffset = le16_to_cpu(pSMBr->DataOffset); -+ /* BB also check if enough total bytes returned */ -+ if ((pSMBr->ByteCount < sizeof(FILE_UNIX_BASIC_INFO)) || -+ (pSMBr->DataOffset > 512) || -+ (pSMBr->DataOffset < sizeof(struct smb_hdr))) { -+ cFYI(1,("UnixQPathinfo invalid data offset %d bytes returned %d", -+ (int)pSMBr->DataOffset,bytes_returned)); -+ rc = -EIO; /* bad smb */ -+ } else { -+ memcpy((char *) pFindData, -+ (char *) &pSMBr->hdr.Protocol + -+ pSMBr->DataOffset, -+ sizeof (FILE_UNIX_BASIC_INFO)); -+ } -+ } -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ if (rc == -EAGAIN) -+ goto UnixQPathInfoRetry; -+ -+ return rc; -+} -+ -+int -+CIFSFindSingle(const int xid, struct cifsTconInfo *tcon, -+ const char *searchName, FILE_ALL_INFO * findData, -+ const struct nls_table *nls_codepage) -+{ -+/* level 257 SMB_ */ -+ TRANSACTION2_FFIRST_REQ *pSMB = NULL; -+ TRANSACTION2_FFIRST_RSP *pSMBr = NULL; -+ int rc = 0; -+ int bytes_returned; -+ int name_len; -+ -+ cFYI(1, ("In FindUnique")); -+findUniqueRetry: -+ rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { -+ name_len = -+ cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, 530 -+ /* find define for this maxpathcomponent */ -+ , nls_codepage); -+ name_len++; /* trailing null */ -+ name_len *= 2; -+ } else { /* BB improve the check for buffer overruns BB */ -+ name_len = strnlen(searchName, 530); -+ name_len++; /* trailing null */ -+ strncpy(pSMB->FileName, searchName, name_len); -+ } -+ -+ pSMB->TotalParameterCount = 12 + name_len /* includes null */ ; -+ pSMB->TotalDataCount = 0; /* no EAs */ -+ pSMB->MaxParameterCount = cpu_to_le16(2); -+ pSMB->MaxDataCount = cpu_to_le16(4000); /* BB find exact max SMB PDU from sess structure BB */ -+ pSMB->MaxSetupCount = 0; -+ pSMB->Reserved = 0; -+ pSMB->Flags = 0; -+ pSMB->Timeout = 0; -+ pSMB->Reserved2 = 0; -+ pSMB->ParameterOffset = cpu_to_le16( -+ offsetof(struct smb_com_transaction2_ffirst_req,InformationLevel) - 4); -+ pSMB->DataCount = 0; -+ pSMB->DataOffset = 0; -+ pSMB->SetupCount = 1; /* one byte, no need to le convert */ -+ pSMB->Reserved3 = 0; -+ pSMB->SubCommand = cpu_to_le16(TRANS2_FIND_FIRST); -+ pSMB->ByteCount = pSMB->TotalParameterCount + 1 /* pad */ ; -+ pSMB->TotalParameterCount = cpu_to_le16(pSMB->TotalDataCount); -+ pSMB->ParameterCount = pSMB->TotalParameterCount; -+ pSMB->SearchAttributes = -+ cpu_to_le16(ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM | -+ ATTR_DIRECTORY); -+ pSMB->SearchCount = cpu_to_le16(16); /* BB increase */ -+ pSMB->SearchFlags = cpu_to_le16(1); -+ pSMB->InformationLevel = cpu_to_le16(SMB_FIND_FILE_DIRECTORY_INFO); -+ pSMB->SearchStorageType = 0; /* BB what should we set this to? BB */ -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ -+ if (rc) { -+ cFYI(1, ("Send error in FindFileDirInfo = %d", rc)); -+ } else { /* decode response */ -+ -+ /* BB fill in */ -+ } -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ if (rc == -EAGAIN) -+ goto findUniqueRetry; -+ -+ return rc; -+} -+ -+int -+CIFSFindFirst(const int xid, struct cifsTconInfo *tcon, -+ const char *searchName, FILE_DIRECTORY_INFO * findData, -+ T2_FFIRST_RSP_PARMS * findParms, -+ const struct nls_table *nls_codepage, int *pUnicodeFlag, -+ int *pUnixFlag) -+{ -+/* level 257 SMB_ */ -+ TRANSACTION2_FFIRST_REQ *pSMB = NULL; -+ TRANSACTION2_FFIRST_RSP *pSMBr = NULL; -+ char *response_data; -+ int rc = 0; -+ int bytes_returned; -+ int name_len; -+ -+ cFYI(1, ("In FindFirst")); -+findFirstRetry: -+ rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { -+ name_len = -+ cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, 530 -+ /* find define for this maxpathcomponent */ -+ , nls_codepage); -+ name_len++; /* trailing null */ -+ name_len *= 2; -+ } else { /* BB improve the check for buffer overruns BB */ -+ name_len = strnlen(searchName, 530); -+ name_len++; /* trailing null */ -+ strncpy(pSMB->FileName, searchName, name_len); -+ } -+ -+ pSMB->TotalParameterCount = 12 + name_len /* includes null */ ; -+ pSMB->TotalDataCount = 0; /* no EAs */ -+ pSMB->MaxParameterCount = cpu_to_le16(10); -+ pSMB->MaxDataCount = cpu_to_le16((tcon->ses->server->maxBuf - -+ MAX_CIFS_HDR_SIZE) & 0xFFFFFF00); -+ pSMB->MaxSetupCount = 0; -+ pSMB->Reserved = 0; -+ pSMB->Flags = 0; -+ pSMB->Timeout = 0; -+ pSMB->Reserved2 = 0; -+ pSMB->ByteCount = pSMB->TotalParameterCount + 1 /* pad */ ; -+ pSMB->TotalParameterCount = cpu_to_le16(pSMB->TotalParameterCount); -+ pSMB->ParameterCount = pSMB->TotalParameterCount; -+ pSMB->ParameterOffset = cpu_to_le16(offsetof(struct -+ smb_com_transaction2_ffirst_req, SearchAttributes) - 4); -+ pSMB->DataCount = 0; -+ pSMB->DataOffset = 0; -+ pSMB->SetupCount = 1; /* one byte no need to make endian neutral */ -+ pSMB->Reserved3 = 0; -+ pSMB->SubCommand = cpu_to_le16(TRANS2_FIND_FIRST); -+ pSMB->SearchAttributes = -+ cpu_to_le16(ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM | -+ ATTR_DIRECTORY); -+ pSMB->SearchCount = cpu_to_le16(CIFS_MAX_MSGSIZE / sizeof (FILE_DIRECTORY_INFO)); /* should this be shrunk even more ? */ -+ pSMB->SearchFlags = cpu_to_le16(CIFS_SEARCH_CLOSE_AT_END | CIFS_SEARCH_RETURN_RESUME); -+ -+ /* test for Unix extensions */ -+ if (tcon->ses->capabilities & CAP_UNIX) { -+ pSMB->InformationLevel = cpu_to_le16(SMB_FIND_FILE_UNIX); -+ *pUnixFlag = TRUE; -+ } else { -+ pSMB->InformationLevel = -+ cpu_to_le16(SMB_FIND_FILE_DIRECTORY_INFO); -+ *pUnixFlag = FALSE; -+ } -+ pSMB->SearchStorageType = 0; /* BB what should we set this to? It is not clear if it matters BB */ -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ -+ if (rc) { /* BB add logic to retry regular search if Unix search rejected unexpectedly by server */ -+ cFYI(1, ("Error in FindFirst = %d", rc)); -+ } else { /* decode response */ -+ /* BB add safety checks for these memcpys */ -+ if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) -+ *pUnicodeFlag = TRUE; -+ else -+ *pUnicodeFlag = FALSE; -+ memcpy(findParms, -+ (char *) &pSMBr->hdr.Protocol + -+ le16_to_cpu(pSMBr->ParameterOffset), -+ sizeof (T2_FFIRST_RSP_PARMS)); -+ /* search handle can stay LE and EAoffset not needed so not converted */ -+ findParms->EndofSearch = le16_to_cpu(findParms->EndofSearch); -+ findParms->LastNameOffset = -+ le16_to_cpu(findParms->LastNameOffset); -+ findParms->SearchCount = le16_to_cpu(findParms->SearchCount); -+ response_data = -+ (char *) &pSMBr->hdr.Protocol + -+ le16_to_cpu(pSMBr->DataOffset); -+ memcpy(findData, response_data, le16_to_cpu(pSMBr->DataCount)); -+ } -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ -+ if (rc == -EAGAIN) -+ goto findFirstRetry; -+ -+ return rc; -+} -+ -+int -+CIFSFindNext(const int xid, struct cifsTconInfo *tcon, -+ FILE_DIRECTORY_INFO * findData, T2_FNEXT_RSP_PARMS * findParms, -+ const __u16 searchHandle, char * resume_file_name, int name_len, -+ __u32 resume_key, int *pUnicodeFlag, int *pUnixFlag) -+{ -+/* level 257 SMB_ */ -+ TRANSACTION2_FNEXT_REQ *pSMB = NULL; -+ TRANSACTION2_FNEXT_RSP *pSMBr = NULL; -+ char *response_data; -+ int rc = 0; -+ int bytes_returned; -+ -+ cFYI(1, ("In FindNext")); -+ -+ if(resume_file_name == NULL) { -+ return -EIO; -+ } -+ rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ pSMB->TotalParameterCount = 14; /* includes 2 bytes of null string, converted to LE below */ -+ pSMB->TotalDataCount = 0; /* no EAs */ -+ pSMB->MaxParameterCount = cpu_to_le16(8); -+ pSMB->MaxDataCount = -+ cpu_to_le16((tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) & 0xFFFFFF00); -+ pSMB->MaxSetupCount = 0; -+ pSMB->Reserved = 0; -+ pSMB->Flags = 0; -+ pSMB->Timeout = 0; -+ pSMB->Reserved2 = 0; -+ pSMB->ParameterOffset = cpu_to_le16(offsetof( -+ struct smb_com_transaction2_fnext_req,SearchHandle) - 4); -+ pSMB->DataCount = 0; -+ pSMB->DataOffset = 0; -+ pSMB->SetupCount = 1; -+ pSMB->Reserved3 = 0; -+ pSMB->SubCommand = cpu_to_le16(TRANS2_FIND_NEXT); -+ pSMB->SearchHandle = searchHandle; /* always kept as le */ -+ findParms->SearchCount = 0; /* set to zero in case of error */ -+ pSMB->SearchCount = -+ cpu_to_le16(CIFS_MAX_MSGSIZE / sizeof (FILE_DIRECTORY_INFO)); -+ /* test for Unix extensions */ -+ if (tcon->ses->capabilities & CAP_UNIX) { -+ pSMB->InformationLevel = cpu_to_le16(SMB_FIND_FILE_UNIX); -+ *pUnixFlag = TRUE; -+ } else { -+ pSMB->InformationLevel = -+ cpu_to_le16(SMB_FIND_FILE_DIRECTORY_INFO); -+ *pUnixFlag = FALSE; -+ } -+ pSMB->ResumeKey = resume_key; -+ pSMB->SearchFlags = -+ cpu_to_le16(CIFS_SEARCH_CLOSE_AT_END | CIFS_SEARCH_RETURN_RESUME); -+ /* BB add check to make sure we do not cross end of smb */ -+ if(name_len < CIFS_MAX_MSGSIZE) { -+ memcpy(pSMB->ResumeFileName, resume_file_name, name_len); -+ pSMB->ByteCount += name_len; -+ } -+ pSMB->TotalParameterCount += name_len; -+ pSMB->ByteCount = pSMB->TotalParameterCount + 1 /* pad */ ; -+ pSMB->TotalParameterCount = cpu_to_le16(pSMB->TotalParameterCount); -+ pSMB->ParameterCount = pSMB->TotalParameterCount; -+ /* BB improve error handling here */ -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ -+ if (rc) { -+ if (rc == -EBADF) -+ rc = 0; /* search probably was closed at end of search above */ -+ else -+ cFYI(1, ("FindNext returned = %d", rc)); -+ } else { /* decode response */ -+ /* BB add safety checks for these memcpys */ -+ if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) -+ *pUnicodeFlag = TRUE; -+ else -+ *pUnicodeFlag = FALSE; -+ memcpy(findParms, -+ (char *) &pSMBr->hdr.Protocol + -+ le16_to_cpu(pSMBr->ParameterOffset), -+ sizeof (T2_FNEXT_RSP_PARMS)); -+ findParms->EndofSearch = le16_to_cpu(findParms->EndofSearch); -+ findParms->LastNameOffset = -+ le16_to_cpu(findParms->LastNameOffset); -+ findParms->SearchCount = le16_to_cpu(findParms->SearchCount); -+ response_data = -+ (char *) &pSMBr->hdr.Protocol + -+ le16_to_cpu(pSMBr->DataOffset); -+ memcpy(findData, response_data, le16_to_cpu(pSMBr->DataCount)); -+ } -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ -+ /* Note: On -EAGAIN error only caller can retry on handle based calls -+ since file handle passed in no longer valid */ -+ -+ return rc; -+} -+ -+int -+CIFSFindClose(const int xid, struct cifsTconInfo *tcon, const __u16 searchHandle) -+{ -+ int rc = 0; -+ FINDCLOSE_REQ *pSMB = NULL; -+ CLOSE_RSP *pSMBr = NULL; -+ int bytes_returned; -+ -+ cFYI(1, ("In CIFSSMBFindClose")); -+ rc = smb_init(SMB_COM_FIND_CLOSE2, 1, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ /* no sense returning error if session restarted -+ file handle has been closed */ -+ if(rc == -EAGAIN) -+ return 0; -+ if (rc) -+ return rc; -+ -+ pSMB->FileID = searchHandle; -+ pSMB->ByteCount = 0; -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc) { -+ cERROR(1, ("Send error in FindClose = %d", rc)); -+ } -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ -+ /* Since session is dead, search handle closed on server already */ -+ if (rc == -EAGAIN) -+ rc = 0; -+ -+ return rc; -+} -+ -+int -+CIFSGetDFSRefer(const int xid, struct cifsSesInfo *ses, -+ const unsigned char *searchName, -+ unsigned char **targetUNCs, -+ unsigned int *number_of_UNC_in_array, -+ const struct nls_table *nls_codepage) -+{ -+/* TRANS2_GET_DFS_REFERRAL */ -+ TRANSACTION2_GET_DFS_REFER_REQ *pSMB = NULL; -+ TRANSACTION2_GET_DFS_REFER_RSP *pSMBr = NULL; -+ struct dfs_referral_level_3 * referrals = NULL; -+ int rc = 0; -+ int bytes_returned; -+ int name_len; -+ unsigned int i; -+ char * temp; -+ *number_of_UNC_in_array = 0; -+ *targetUNCs = NULL; -+ -+ cFYI(1, ("In GetDFSRefer the path %s", searchName)); -+ if (ses == NULL) -+ return -ENODEV; -+getDFSRetry: -+ rc = smb_init(SMB_COM_TRANSACTION2, 15, NULL, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ pSMB->hdr.Tid = ses->ipc_tid; -+ pSMB->hdr.Uid = ses->Suid; -+ if (ses->capabilities & CAP_STATUS32) { -+ pSMB->hdr.Flags2 |= SMBFLG2_ERR_STATUS; -+ } -+ if (ses->capabilities & CAP_DFS) { -+ pSMB->hdr.Flags2 |= SMBFLG2_DFS; -+ } -+ -+ if (ses->capabilities & CAP_UNICODE) { -+ pSMB->hdr.Flags2 |= SMBFLG2_UNICODE; -+ name_len = -+ cifs_strtoUCS((wchar_t *) pSMB->RequestFileName, -+ searchName, 530 -+ /* find define for this maxpathcomponent */ -+ , nls_codepage); -+ name_len++; /* trailing null */ -+ name_len *= 2; -+ } else { /* BB improve the check for buffer overruns BB */ -+ name_len = strnlen(searchName, 530); -+ name_len++; /* trailing null */ -+ strncpy(pSMB->RequestFileName, searchName, name_len); -+ } -+ -+ pSMB->ParameterCount = 2 /* level */ + name_len /*includes null */ ; -+ pSMB->TotalDataCount = 0; -+ pSMB->DataCount = 0; -+ pSMB->DataOffset = 0; -+ pSMB->MaxParameterCount = 0; -+ pSMB->MaxDataCount = cpu_to_le16(4000); /* BB find exact max SMB PDU from sess structure BB */ -+ pSMB->MaxSetupCount = 0; -+ pSMB->Reserved = 0; -+ pSMB->Flags = 0; -+ pSMB->Timeout = 0; -+ pSMB->Reserved2 = 0; -+ pSMB->ParameterOffset = cpu_to_le16(offsetof( -+ struct smb_com_transaction2_get_dfs_refer_req, MaxReferralLevel) - 4); -+ pSMB->SetupCount = 1; -+ pSMB->Reserved3 = 0; -+ pSMB->SubCommand = cpu_to_le16(TRANS2_GET_DFS_REFERRAL); -+ pSMB->ByteCount = pSMB->ParameterCount + 3 /* pad */ ; -+ pSMB->ParameterCount = cpu_to_le16(pSMB->ParameterCount); -+ pSMB->TotalParameterCount = pSMB->ParameterCount; -+ pSMB->MaxReferralLevel = cpu_to_le16(3); -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ -+ rc = SendReceive(xid, ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc) { -+ cFYI(1, ("Send error in GetDFSRefer = %d", rc)); -+ } else { /* decode response */ -+/* BB Add logic to parse referrals here */ -+ pSMBr->DataOffset = le16_to_cpu(pSMBr->DataOffset); -+ pSMBr->DataCount = le16_to_cpu(pSMBr->DataCount); -+ cFYI(1, -+ ("Decoding GetDFSRefer response. BCC: %d Offset %d", -+ pSMBr->ByteCount, pSMBr->DataOffset)); -+ if ((pSMBr->ByteCount < 17) || (pSMBr->DataOffset > 512)) /* BB also check enough total bytes returned */ -+ rc = -EIO; /* bad smb */ -+ else { -+ referrals = -+ (struct dfs_referral_level_3 *) -+ (8 /* sizeof start of data block */ + -+ pSMBr->DataOffset + -+ (char *) &pSMBr->hdr.Protocol); -+ cFYI(1,("num_referrals: %d dfs flags: 0x%x ... \nfor referral one refer size: 0x%x srv type: 0x%x refer flags: 0x%x ttl: 0x%x",pSMBr->NumberOfReferrals,pSMBr->DFSFlags, referrals->ReferralSize,referrals->ServerType,referrals->ReferralFlags,referrals->TimeToLive)); -+ /* BB This field is actually two bytes in from start of -+ data block so we could do safety check that DataBlock -+ begins at address of pSMBr->NumberOfReferrals */ -+ *number_of_UNC_in_array = le16_to_cpu(pSMBr->NumberOfReferrals); -+ -+ /* BB Fix below so can return more than one referral */ -+ if(*number_of_UNC_in_array > 1) -+ *number_of_UNC_in_array = 1; -+ -+ /* get the length of the strings describing refs */ -+ name_len = 0; -+ for(i=0;i<*number_of_UNC_in_array;i++) { -+ /* make sure that DfsPathOffset not past end */ -+ referrals->DfsPathOffset = le16_to_cpu(referrals->DfsPathOffset); -+ if(referrals->DfsPathOffset > pSMBr->DataCount) { -+ /* if invalid referral, stop here and do -+ not try to copy any more */ -+ *number_of_UNC_in_array = i; -+ break; -+ } -+ temp = ((char *)referrals) + referrals->DfsPathOffset; -+ -+ if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) { -+ name_len += UniStrnlen((wchar_t *)temp,pSMBr->DataCount); -+ } else { -+ name_len += strnlen(temp,pSMBr->DataCount); -+ } -+ referrals++; -+ /* BB add check that referral pointer does not fall off end PDU */ -+ -+ } -+ /* BB add check for name_len bigger than bcc */ -+ *targetUNCs = -+ kmalloc(name_len+1+ (*number_of_UNC_in_array),GFP_KERNEL); -+ /* copy the ref strings */ -+ referrals = -+ (struct dfs_referral_level_3 *) -+ (8 /* sizeof data hdr */ + -+ pSMBr->DataOffset + -+ (char *) &pSMBr->hdr.Protocol); -+ -+ for(i=0;i<*number_of_UNC_in_array;i++) { -+ temp = ((char *)referrals) + referrals->DfsPathOffset; -+ if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) { -+ cifs_strfromUCS_le(*targetUNCs, -+ (wchar_t *) temp, name_len, nls_codepage); -+ } else { -+ strncpy(*targetUNCs,temp,name_len); -+ } -+ /* BB update target_uncs pointers */ -+ referrals++; -+ } -+ temp = *targetUNCs; -+ temp[name_len] = 0; -+ } -+ -+ } -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ -+ if (rc == -EAGAIN) -+ goto getDFSRetry; -+ -+ return rc; -+} -+ -+int -+CIFSSMBQFSInfo(const int xid, struct cifsTconInfo *tcon, -+ struct statfs *FSData, const struct nls_table *nls_codepage) -+{ -+/* level 0x103 SMB_QUERY_FILE_SYSTEM_INFO */ -+ TRANSACTION2_QFSI_REQ *pSMB = NULL; -+ TRANSACTION2_QFSI_RSP *pSMBr = NULL; -+ FILE_SYSTEM_INFO *response_data; -+ int rc = 0; -+ int bytes_returned = 0; -+ -+ cFYI(1, ("In QFSInfo")); -+QFSInfoRetry: -+ rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ pSMB->TotalParameterCount = 2; /* level */ -+ pSMB->TotalDataCount = 0; -+ pSMB->MaxParameterCount = cpu_to_le16(2); -+ pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find exact max SMB PDU from sess structure BB */ -+ pSMB->MaxSetupCount = 0; -+ pSMB->Reserved = 0; -+ pSMB->Flags = 0; -+ pSMB->Timeout = 0; -+ pSMB->Reserved2 = 0; -+ pSMB->ByteCount = pSMB->TotalParameterCount + 1 /* pad */ ; -+ pSMB->TotalParameterCount = cpu_to_le16(pSMB->TotalParameterCount); -+ pSMB->ParameterCount = pSMB->TotalParameterCount; -+ pSMB->ParameterOffset = cpu_to_le16(offsetof( -+ struct smb_com_transaction2_qfsi_req, InformationLevel) - 4); -+ pSMB->DataCount = 0; -+ pSMB->DataOffset = 0; -+ pSMB->SetupCount = 1; -+ pSMB->Reserved3 = 0; -+ pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_FS_INFORMATION); -+ pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FS_SIZE_INFO); -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc) { -+ cERROR(1, ("Send error in QFSInfo = %d", rc)); -+ } else { /* decode response */ -+ pSMBr->DataOffset = le16_to_cpu(pSMBr->DataOffset); -+ cFYI(1, -+ ("Decoding qfsinfo response. BCC: %d Offset %d", -+ pSMBr->ByteCount, pSMBr->DataOffset)); -+ if ((pSMBr->ByteCount < 24) || (pSMBr->DataOffset > 512)) /* BB also check enough total bytes returned */ -+ rc = -EIO; /* bad smb */ -+ else { -+ response_data = -+ (FILE_SYSTEM_INFO -+ *) (((char *) &pSMBr->hdr.Protocol) + -+ pSMBr->DataOffset); -+ FSData->f_bsize = -+ le32_to_cpu(response_data->BytesPerSector) * -+ le32_to_cpu(response_data-> -+ SectorsPerAllocationUnit); -+ FSData->f_blocks = -+ le64_to_cpu(response_data->TotalAllocationUnits); -+ FSData->f_bfree = FSData->f_bavail = -+ le64_to_cpu(response_data->FreeAllocationUnits); -+ cFYI(1, -+ ("Blocks: %lld Free: %lld Block size %ld", -+ (unsigned long long)FSData->f_blocks, -+ (unsigned long long)FSData->f_bfree, -+ FSData->f_bsize)); -+ } -+ } -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ -+ if (rc == -EAGAIN) -+ goto QFSInfoRetry; -+ -+ return rc; -+} -+ -+int -+CIFSSMBQFSAttributeInfo(int xid, struct cifsTconInfo *tcon, -+ const struct nls_table *nls_codepage) -+{ -+/* level 0x105 SMB_QUERY_FILE_SYSTEM_INFO */ -+ TRANSACTION2_QFSI_REQ *pSMB = NULL; -+ TRANSACTION2_QFSI_RSP *pSMBr = NULL; -+ FILE_SYSTEM_ATTRIBUTE_INFO *response_data; -+ int rc = 0; -+ int bytes_returned = 0; -+ -+ cFYI(1, ("In QFSAttributeInfo")); -+QFSAttributeRetry: -+ rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ pSMB->TotalParameterCount = 2; /* level */ -+ pSMB->TotalDataCount = 0; -+ pSMB->MaxParameterCount = cpu_to_le16(2); -+ pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find exact max SMB PDU from sess structure BB */ -+ pSMB->MaxSetupCount = 0; -+ pSMB->Reserved = 0; -+ pSMB->Flags = 0; -+ pSMB->Timeout = 0; -+ pSMB->Reserved2 = 0; -+ pSMB->ByteCount = pSMB->TotalParameterCount + 1 /* pad */ ; -+ pSMB->TotalParameterCount = cpu_to_le16(pSMB->TotalParameterCount); -+ pSMB->ParameterCount = pSMB->TotalParameterCount; -+ pSMB->ParameterOffset = cpu_to_le16(offsetof( -+ struct smb_com_transaction2_qfsi_req, InformationLevel) - 4); -+ pSMB->DataCount = 0; -+ pSMB->DataOffset = 0; -+ pSMB->SetupCount = 1; -+ pSMB->Reserved3 = 0; -+ pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_FS_INFORMATION); -+ pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FS_ATTRIBUTE_INFO); -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc) { -+ cERROR(1, ("Send error in QFSAttributeInfo = %d", rc)); -+ } else { /* decode response */ -+ pSMBr->DataOffset = le16_to_cpu(pSMBr->DataOffset); -+ if ((pSMBr->ByteCount < 13) || (pSMBr->DataOffset > 512)) { /* BB also check enough bytes returned */ -+ rc = -EIO; /* bad smb */ -+ } else { -+ response_data = -+ (FILE_SYSTEM_ATTRIBUTE_INFO -+ *) (((char *) &pSMBr->hdr.Protocol) + -+ pSMBr->DataOffset); -+ response_data->Attributes = le32_to_cpu(response_data->Attributes); -+ response_data->MaxPathNameComponentLength = -+ le32_to_cpu(response_data->MaxPathNameComponentLength); -+ response_data->FileSystemNameLen = -+ le32_to_cpu(response_data->FileSystemNameLen); -+ memcpy(&tcon->fsAttrInfo, response_data, -+ sizeof (FILE_SYSTEM_ATTRIBUTE_INFO)); -+ } -+ } -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ -+ if (rc == -EAGAIN) -+ goto QFSAttributeRetry; -+ -+ return rc; -+} -+ -+int -+CIFSSMBQFSDeviceInfo(int xid, struct cifsTconInfo *tcon, -+ const struct nls_table *nls_codepage) -+{ -+/* level 0x104 SMB_QUERY_FILE_SYSTEM_INFO */ -+ TRANSACTION2_QFSI_REQ *pSMB = NULL; -+ TRANSACTION2_QFSI_RSP *pSMBr = NULL; -+ FILE_SYSTEM_DEVICE_INFO *response_data; -+ int rc = 0; -+ int bytes_returned = 0; -+ -+ cFYI(1, ("In QFSDeviceInfo")); -+QFSDeviceRetry: -+ rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ pSMB->TotalParameterCount = 2; /* level */ -+ pSMB->TotalDataCount = 0; -+ pSMB->MaxParameterCount = cpu_to_le16(2); -+ pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find exact max SMB PDU from sess structure BB */ -+ pSMB->MaxSetupCount = 0; -+ pSMB->Reserved = 0; -+ pSMB->Flags = 0; -+ pSMB->Timeout = 0; -+ pSMB->Reserved2 = 0; -+ pSMB->ByteCount = pSMB->TotalParameterCount + 1 /* pad */ ; -+ pSMB->TotalParameterCount = cpu_to_le16(pSMB->TotalParameterCount); -+ pSMB->ParameterCount = pSMB->TotalParameterCount; -+ pSMB->ParameterOffset = cpu_to_le16(offsetof( -+ struct smb_com_transaction2_qfsi_req, InformationLevel) - 4); -+ -+ pSMB->DataCount = 0; -+ pSMB->DataOffset = 0; -+ pSMB->SetupCount = 1; -+ pSMB->Reserved3 = 0; -+ pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_FS_INFORMATION); -+ pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FS_DEVICE_INFO); -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc) { -+ cFYI(1, ("Send error in QFSDeviceInfo = %d", rc)); -+ } else { /* decode response */ -+ pSMBr->DataOffset = le16_to_cpu(pSMBr->DataOffset); -+ if ((pSMBr->ByteCount < sizeof (FILE_SYSTEM_DEVICE_INFO)) -+ || (pSMBr->DataOffset > 512)) -+ rc = -EIO; /* bad smb */ -+ else { -+ response_data = -+ (FILE_SYSTEM_DEVICE_INFO -+ *) (((char *) &pSMBr->hdr.Protocol) + -+ pSMBr->DataOffset); -+ response_data->DeviceType = -+ le32_to_cpu(response_data->DeviceType); -+ response_data->DeviceCharacteristics = -+ le32_to_cpu(response_data->DeviceCharacteristics); -+ memcpy(&tcon->fsDevInfo, response_data, -+ sizeof (FILE_SYSTEM_DEVICE_INFO)); -+ } -+ } -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ -+ if (rc == -EAGAIN) -+ goto QFSDeviceRetry; -+ -+ return rc; -+} -+ -+int -+CIFSSMBQFSUnixInfo(int xid, struct cifsTconInfo *tcon, -+ const struct nls_table *nls_codepage) -+{ -+/* level 0x200 SMB_QUERY_CIFS_UNIX_INFO */ -+ TRANSACTION2_QFSI_REQ *pSMB = NULL; -+ TRANSACTION2_QFSI_RSP *pSMBr = NULL; -+ FILE_SYSTEM_UNIX_INFO *response_data; -+ int rc = 0; -+ int bytes_returned = 0; -+ -+ cFYI(1, ("In QFSUnixInfo")); -+QFSUnixRetry: -+ rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ pSMB->ParameterCount = 2; /* level */ -+ pSMB->TotalDataCount = 0; -+ pSMB->DataCount = 0; -+ pSMB->DataOffset = 0; -+ pSMB->MaxParameterCount = cpu_to_le16(2); -+ pSMB->MaxDataCount = cpu_to_le16(100); /* BB find exact max SMB PDU from sess structure BB */ -+ pSMB->MaxSetupCount = 0; -+ pSMB->Reserved = 0; -+ pSMB->Flags = 0; -+ pSMB->Timeout = 0; -+ pSMB->Reserved2 = 0; -+ pSMB->ByteCount = pSMB->ParameterCount + 1 /* pad */ ; -+ pSMB->ParameterCount = cpu_to_le16(pSMB->ParameterCount); -+ pSMB->TotalParameterCount = pSMB->ParameterCount; -+ pSMB->ParameterOffset = cpu_to_le16(offsetof(struct -+ smb_com_transaction2_qfsi_req, InformationLevel) - 4); -+ pSMB->SetupCount = 1; -+ pSMB->Reserved3 = 0; -+ pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_FS_INFORMATION); -+ pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_CIFS_UNIX_INFO); -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc) { -+ cERROR(1, ("Send error in QFSUnixInfo = %d", rc)); -+ } else { /* decode response */ -+ pSMBr->DataOffset = cpu_to_le16(pSMBr->DataOffset); -+ if ((pSMBr->ByteCount < 13) || (pSMBr->DataOffset > 512)) { -+ rc = -EIO; /* bad smb */ -+ } else { -+ response_data = -+ (FILE_SYSTEM_UNIX_INFO -+ *) (((char *) &pSMBr->hdr.Protocol) + -+ pSMBr->DataOffset); -+ response_data->MajorVersionNumber = -+ le16_to_cpu(response_data->MajorVersionNumber); -+ response_data->MinorVersionNumber = -+ le16_to_cpu(response_data->MinorVersionNumber); -+ response_data->Capability = -+ le64_to_cpu(response_data->Capability); -+ memcpy(&tcon->fsUnixInfo, response_data, -+ sizeof (FILE_SYSTEM_UNIX_INFO)); -+ } -+ } -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ -+ if (rc == -EAGAIN) -+ goto QFSUnixRetry; -+ -+ -+ return rc; -+} -+ -+/* We can not use write of zero bytes trick to -+ set file size due to need for large file support. Also note that -+ this SetPathInfo is preferred to SetFileInfo based method in next -+ routine which is only needed to work around a sharing violation bug -+ in Samba which this routine can run into */ -+ -+int -+CIFSSMBSetEOF(int xid, struct cifsTconInfo *tcon, char *fileName, -+ __u64 size, int SetAllocation, const struct nls_table *nls_codepage) -+{ -+ struct smb_com_transaction2_spi_req *pSMB = NULL; -+ struct smb_com_transaction2_spi_rsp *pSMBr = NULL; -+ struct file_end_of_file_info *parm_data; -+ int name_len; -+ int rc = 0; -+ int bytes_returned = 0; -+ -+ cFYI(1, ("In SetEOF")); -+SetEOFRetry: -+ rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { -+ name_len = -+ cifs_strtoUCS((wchar_t *) pSMB->FileName, fileName, 530 -+ /* find define for this maxpathcomponent */ -+ , nls_codepage); -+ name_len++; /* trailing null */ -+ name_len *= 2; -+ } else { /* BB improve the check for buffer overruns BB */ -+ name_len = strnlen(fileName, 530); -+ name_len++; /* trailing null */ -+ strncpy(pSMB->FileName, fileName, name_len); -+ } -+ pSMB->ParameterCount = 6 + name_len; -+ pSMB->DataCount = sizeof (struct file_end_of_file_info); -+ pSMB->MaxParameterCount = cpu_to_le16(2); -+ pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB size from sess */ -+ pSMB->MaxSetupCount = 0; -+ pSMB->Reserved = 0; -+ pSMB->Flags = 0; -+ pSMB->Timeout = 0; -+ pSMB->Reserved2 = 0; -+ pSMB->ParameterOffset = offsetof(struct smb_com_transaction2_spi_req, -+ InformationLevel) - 4; -+ pSMB->DataOffset = pSMB->ParameterOffset + pSMB->ParameterCount; -+ if(SetAllocation) { -+ if (tcon->ses->capabilities & CAP_INFOLEVEL_PASSTHRU) -+ pSMB->InformationLevel = -+ cpu_to_le16(SMB_SET_FILE_ALLOCATION_INFO2); -+ else -+ pSMB->InformationLevel = -+ cpu_to_le16(SMB_SET_FILE_ALLOCATION_INFO); -+ } else /* Set File Size */ { -+ if (tcon->ses->capabilities & CAP_INFOLEVEL_PASSTHRU) -+ pSMB->InformationLevel = -+ cpu_to_le16(SMB_SET_FILE_END_OF_FILE_INFO2); -+ else -+ pSMB->InformationLevel = -+ cpu_to_le16(SMB_SET_FILE_END_OF_FILE_INFO); -+ } -+ -+ parm_data = -+ (struct file_end_of_file_info *) (((char *) &pSMB->hdr.Protocol) + -+ pSMB->DataOffset); -+ pSMB->ParameterOffset = cpu_to_le16(pSMB->ParameterOffset); -+ pSMB->DataOffset = cpu_to_le16(pSMB->DataOffset); -+ pSMB->SetupCount = 1; -+ pSMB->Reserved3 = 0; -+ pSMB->SubCommand = cpu_to_le16(TRANS2_SET_PATH_INFORMATION); -+ pSMB->ByteCount = 3 /* pad */ + pSMB->ParameterCount + pSMB->DataCount; -+ pSMB->DataCount = cpu_to_le16(pSMB->DataCount); -+ pSMB->TotalDataCount = pSMB->DataCount; -+ pSMB->ParameterCount = cpu_to_le16(pSMB->ParameterCount); -+ pSMB->TotalParameterCount = pSMB->ParameterCount; -+ pSMB->Reserved4 = 0; -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ parm_data->FileSize = cpu_to_le64(size); -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc) { -+ cFYI(1, ("SetPathInfo (file size) returned %d", rc)); -+ } -+ -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ -+ if (rc == -EAGAIN) -+ goto SetEOFRetry; -+ -+ return rc; -+} -+ -+int -+CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, __u64 size, -+ __u16 fid, __u32 pid_of_opener, int SetAllocation) -+{ -+ struct smb_com_transaction2_sfi_req *pSMB = NULL; -+ struct smb_com_transaction2_sfi_rsp *pSMBr = NULL; -+ char *data_offset; -+ struct file_end_of_file_info *parm_data; -+ int rc = 0; -+ int bytes_returned = 0; -+ __u32 tmp; -+ -+ cFYI(1, ("SetFileSize (via SetFileInfo) %lld", -+ (long long)size)); -+ rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ tmp = cpu_to_le32(pid_of_opener); /* override pid of current process -+ so network fid will be valid */ -+ pSMB->hdr.Pid = tmp & 0xFFFF; -+ tmp >>= 16; -+ pSMB->hdr.PidHigh = tmp & 0xFFFF; -+ -+ pSMB->ParameterCount = 6; -+ pSMB->MaxSetupCount = 0; -+ pSMB->Reserved = 0; -+ pSMB->Flags = 0; -+ pSMB->Timeout = 0; -+ pSMB->Reserved2 = 0; -+ pSMB->ParameterOffset = offsetof(struct smb_com_transaction2_sfi_req, -+ Fid) - 4; -+ pSMB->DataOffset = pSMB->ParameterOffset + pSMB->ParameterCount; -+ -+ data_offset = (char *) (&pSMB->hdr.Protocol) + pSMB->DataOffset; -+ -+ pSMB->DataCount = sizeof(struct file_end_of_file_info); -+ pSMB->MaxParameterCount = cpu_to_le16(2); -+ pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB PDU from sess */ -+ pSMB->SetupCount = 1; -+ pSMB->Reserved3 = 0; -+ pSMB->SubCommand = cpu_to_le16(TRANS2_SET_FILE_INFORMATION); -+ pSMB->ByteCount = 3 /* pad */ + pSMB->ParameterCount + pSMB->DataCount; -+ pSMB->DataCount = cpu_to_le16(pSMB->DataCount); -+ pSMB->ParameterCount = cpu_to_le16(pSMB->ParameterCount); -+ pSMB->TotalDataCount = pSMB->DataCount; -+ pSMB->TotalParameterCount = pSMB->ParameterCount; -+ pSMB->ParameterOffset = cpu_to_le16(pSMB->ParameterOffset); -+ parm_data = -+ (struct file_end_of_file_info *) (((char *) &pSMB->hdr.Protocol) + -+ pSMB->DataOffset); -+ pSMB->DataOffset = cpu_to_le16(pSMB->DataOffset); /* now safe to change to le */ -+ parm_data->FileSize = cpu_to_le64(size); -+ pSMB->Fid = fid; -+ if(SetAllocation) { -+ if (tcon->ses->capabilities & CAP_INFOLEVEL_PASSTHRU) -+ pSMB->InformationLevel = -+ cpu_to_le16(SMB_SET_FILE_ALLOCATION_INFO2); -+ else -+ pSMB->InformationLevel = -+ cpu_to_le16(SMB_SET_FILE_ALLOCATION_INFO); -+ } else /* Set File Size */ { -+ if (tcon->ses->capabilities & CAP_INFOLEVEL_PASSTHRU) -+ pSMB->InformationLevel = -+ cpu_to_le16(SMB_SET_FILE_END_OF_FILE_INFO2); -+ else -+ pSMB->InformationLevel = -+ cpu_to_le16(SMB_SET_FILE_END_OF_FILE_INFO); -+ } -+ pSMB->Reserved4 = 0; -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc) { -+ cFYI(1, -+ ("Send error in SetFileInfo (SetFileSize) = %d", -+ rc)); -+ } -+ -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ -+ /* Note: On -EAGAIN error only caller can retry on handle based calls -+ since file handle passed in no longer valid */ -+ -+ return rc; -+} -+ -+int -+CIFSSMBSetTimes(int xid, struct cifsTconInfo *tcon, char *fileName, -+ FILE_BASIC_INFO * data, const struct nls_table *nls_codepage) -+{ -+ TRANSACTION2_SPI_REQ *pSMB = NULL; -+ TRANSACTION2_SPI_RSP *pSMBr = NULL; -+ int name_len; -+ int rc = 0; -+ int bytes_returned = 0; -+ char *data_offset; -+ -+ cFYI(1, ("In SetTimes")); -+ -+SetTimesRetry: -+ rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { -+ name_len = -+ cifs_strtoUCS((wchar_t *) pSMB->FileName, fileName, 530 -+ /* find define for this maxpathcomponent */ -+ , nls_codepage); -+ name_len++; /* trailing null */ -+ name_len *= 2; -+ } else { /* BB improve the check for buffer overruns BB */ -+ name_len = strnlen(fileName, 530); -+ name_len++; /* trailing null */ -+ strncpy(pSMB->FileName, fileName, name_len); -+ } -+ -+ pSMB->ParameterCount = 6 + name_len; -+ pSMB->DataCount = sizeof (FILE_BASIC_INFO); -+ pSMB->MaxParameterCount = cpu_to_le16(2); -+ pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find exact max SMB PDU from sess structure BB */ -+ pSMB->MaxSetupCount = 0; -+ pSMB->Reserved = 0; -+ pSMB->Flags = 0; -+ pSMB->Timeout = 0; -+ pSMB->Reserved2 = 0; -+ pSMB->ParameterOffset = offsetof(struct smb_com_transaction2_spi_req, -+ InformationLevel) - 4; -+ pSMB->DataOffset = pSMB->ParameterOffset + pSMB->ParameterCount; -+ data_offset = (char *) (&pSMB->hdr.Protocol) + pSMB->DataOffset; -+ pSMB->ParameterOffset = cpu_to_le16(pSMB->ParameterOffset); -+ pSMB->DataOffset = cpu_to_le16(pSMB->DataOffset); -+ pSMB->SetupCount = 1; -+ pSMB->Reserved3 = 0; -+ pSMB->SubCommand = cpu_to_le16(TRANS2_SET_PATH_INFORMATION); -+ pSMB->ByteCount = 3 /* pad */ + pSMB->ParameterCount + pSMB->DataCount; -+ -+ pSMB->DataCount = cpu_to_le16(pSMB->DataCount); -+ pSMB->ParameterCount = cpu_to_le16(pSMB->ParameterCount); -+ pSMB->TotalDataCount = pSMB->DataCount; -+ pSMB->TotalParameterCount = pSMB->ParameterCount; -+ if (tcon->ses->capabilities & CAP_INFOLEVEL_PASSTHRU) -+ pSMB->InformationLevel = cpu_to_le16(SMB_SET_FILE_BASIC_INFO2); -+ else -+ pSMB->InformationLevel = cpu_to_le16(SMB_SET_FILE_BASIC_INFO); -+ pSMB->Reserved4 = 0; -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ memcpy(data_offset, data, sizeof (FILE_BASIC_INFO)); -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc) { -+ cFYI(1, ("SetPathInfo (times) returned %d", rc)); -+ } -+ -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ -+ if (rc == -EAGAIN) -+ goto SetTimesRetry; -+ -+ return rc; -+} -+ -+int -+CIFSSMBUnixSetPerms(const int xid, struct cifsTconInfo *tcon, -+ char *fileName, __u64 mode, __u64 uid, __u64 gid, -+ dev_t device, const struct nls_table *nls_codepage) -+{ -+ TRANSACTION2_SPI_REQ *pSMB = NULL; -+ TRANSACTION2_SPI_RSP *pSMBr = NULL; -+ int name_len; -+ int rc = 0; -+ int bytes_returned = 0; -+ FILE_UNIX_BASIC_INFO *data_offset; -+ -+ cFYI(1, ("In SetUID/GID/Mode")); -+setPermsRetry: -+ rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { -+ name_len = -+ cifs_strtoUCS((wchar_t *) pSMB->FileName, fileName, 530 -+ /* find define for this maxpathcomponent */ -+ , nls_codepage); -+ name_len++; /* trailing null */ -+ name_len *= 2; -+ } else { /* BB improve the check for buffer overruns BB */ -+ name_len = strnlen(fileName, 530); -+ name_len++; /* trailing null */ -+ strncpy(pSMB->FileName, fileName, name_len); -+ } -+ -+ pSMB->ParameterCount = 6 + name_len; -+ pSMB->DataCount = sizeof (FILE_UNIX_BASIC_INFO); -+ pSMB->MaxParameterCount = cpu_to_le16(2); -+ pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find exact max SMB PDU from sess structure BB */ -+ pSMB->MaxSetupCount = 0; -+ pSMB->Reserved = 0; -+ pSMB->Flags = 0; -+ pSMB->Timeout = 0; -+ pSMB->Reserved2 = 0; -+ pSMB->ParameterOffset = offsetof(struct smb_com_transaction2_spi_req, -+ InformationLevel) - 4; -+ pSMB->DataOffset = pSMB->ParameterOffset + pSMB->ParameterCount; -+ data_offset = -+ (FILE_UNIX_BASIC_INFO *) ((char *) &pSMB->hdr.Protocol + -+ pSMB->DataOffset); -+ pSMB->DataOffset = cpu_to_le16(pSMB->DataOffset); -+ pSMB->ParameterOffset = cpu_to_le16(pSMB->ParameterOffset); -+ pSMB->SetupCount = 1; -+ pSMB->Reserved3 = 0; -+ pSMB->SubCommand = cpu_to_le16(TRANS2_SET_PATH_INFORMATION); -+ pSMB->ByteCount = 3 /* pad */ + pSMB->ParameterCount + pSMB->DataCount; -+ pSMB->ParameterCount = cpu_to_le16(pSMB->ParameterCount); -+ pSMB->DataCount = cpu_to_le16(pSMB->DataCount); -+ pSMB->TotalParameterCount = pSMB->ParameterCount; -+ pSMB->TotalDataCount = pSMB->DataCount; -+ pSMB->InformationLevel = cpu_to_le16(SMB_SET_FILE_UNIX_BASIC); -+ pSMB->Reserved4 = 0; -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ data_offset->Uid = cpu_to_le64(uid); -+ data_offset->Gid = cpu_to_le64(gid); -+ /* better to leave device as zero when it is */ -+ data_offset->DevMajor = cpu_to_le64(MAJOR(device)); -+ data_offset->DevMinor = cpu_to_le64(MINOR(device)); -+ data_offset->Permissions = cpu_to_le64(mode); -+ -+ if(S_ISREG(mode)) -+ data_offset->Type = cpu_to_le32(UNIX_FILE); -+ else if(S_ISDIR(mode)) -+ data_offset->Type = cpu_to_le32(UNIX_DIR); -+ else if(S_ISLNK(mode)) -+ data_offset->Type = cpu_to_le32(UNIX_SYMLINK); -+ else if(S_ISCHR(mode)) -+ data_offset->Type = cpu_to_le32(UNIX_CHARDEV); -+ else if(S_ISBLK(mode)) -+ data_offset->Type = cpu_to_le32(UNIX_BLOCKDEV); -+ else if(S_ISFIFO(mode)) -+ data_offset->Type = cpu_to_le32(UNIX_FIFO); -+ else if(S_ISSOCK(mode)) -+ data_offset->Type = cpu_to_le32(UNIX_SOCKET); -+ -+ -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc) { -+ cFYI(1, ("SetPathInfo (perms) returned %d", rc)); -+ } -+ -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ if (rc == -EAGAIN) -+ goto setPermsRetry; -+ return rc; -+} -+ -+int CIFSSMBNotify(const int xid, struct cifsTconInfo *tcon, -+ const int notify_subdirs, const __u16 netfid, -+ __u32 filter, const struct nls_table *nls_codepage) -+{ -+ int rc = 0; -+ struct smb_com_transaction_change_notify_req * pSMB = NULL; -+ struct smb_com_transaction_change_notify_rsp * pSMBr = NULL; -+ int bytes_returned; -+ -+ cFYI(1, ("In CIFSSMBNotify for file handle %d",(int)netfid)); -+ rc = smb_init(SMB_COM_NT_TRANSACT, 23, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ pSMB->TotalParameterCount = 0 ; -+ pSMB->TotalDataCount = 0; -+ pSMB->MaxParameterCount = cpu_to_le32(2); -+ /* BB find exact data count max from sess structure BB */ -+ pSMB->MaxDataCount = 0; /* same in little endian or be */ -+ pSMB->MaxSetupCount = 4; -+ pSMB->Reserved = 0; -+ pSMB->ParameterOffset = 0; -+ pSMB->DataCount = 0; -+ pSMB->DataOffset = 0; -+ pSMB->SetupCount = 4; /* single byte does not need le conversion */ -+ pSMB->SubCommand = cpu_to_le16(NT_TRANSACT_NOTIFY_CHANGE); -+ pSMB->ParameterCount = pSMB->TotalParameterCount; -+ if(notify_subdirs) -+ pSMB->WatchTree = 1; /* one byte - no le conversion needed */ -+ pSMB->Reserved2 = 0; -+ pSMB->CompletionFilter = cpu_to_le32(filter); -+ pSMB->Fid = netfid; /* file handle always le */ -+ pSMB->ByteCount = 0; -+ -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc) { -+ cFYI(1, ("Error in Notify = %d", rc)); -+ } -+ if (pSMB) -+ cifs_buf_release(pSMB); -+/* if (rc == -EAGAIN) -+ goto NotifyRetry; */ -+ return rc; -+} -+#ifdef CONFIG_CIFS_XATTR -+int -+CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon, -+ const unsigned char *searchName, -+ char * EAData, size_t size, -+ const struct nls_table *nls_codepage) -+{ -+ /* BB assumes one setup word */ -+ TRANSACTION2_QPI_REQ *pSMB = NULL; -+ TRANSACTION2_QPI_RSP *pSMBr = NULL; -+ int rc = 0; -+ int bytes_returned; -+ int name_len; -+ -+ cFYI(1, ("In Query All EAs path %s", searchName)); -+QAllEAsRetry: -+ rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, -+ (void **) &pSMBr); -+ if (rc) -+ return rc; -+ -+ if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { -+ name_len = -+ cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, 530 -+ /* find define for this maxpathcomponent */ -+ , nls_codepage); -+ name_len++; /* trailing null */ -+ name_len *= 2; -+ } else { /* BB improve the check for buffer overruns BB */ -+ name_len = strnlen(searchName, 530); -+ name_len++; /* trailing null */ -+ strncpy(pSMB->FileName, searchName, name_len); -+ } -+ -+ pSMB->TotalParameterCount = 2 /* level */ + 4 /* reserved */ + -+ name_len /* includes null */ ; -+ pSMB->TotalDataCount = 0; -+ pSMB->MaxParameterCount = cpu_to_le16(2); -+ pSMB->MaxDataCount = cpu_to_le16(4000); /* BB find exact max SMB PDU from sess structure BB */ -+ pSMB->MaxSetupCount = 0; -+ pSMB->Reserved = 0; -+ pSMB->Flags = 0; -+ pSMB->Timeout = 0; -+ pSMB->Reserved2 = 0; -+ pSMB->ParameterOffset = cpu_to_le16(offsetof( -+ struct smb_com_transaction2_qpi_req ,InformationLevel) - 4); -+ pSMB->DataCount = 0; -+ pSMB->DataOffset = 0; -+ pSMB->SetupCount = 1; -+ pSMB->Reserved3 = 0; -+ pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_PATH_INFORMATION); -+ pSMB->ByteCount = pSMB->TotalParameterCount + 1 /* pad */ ; -+ pSMB->TotalParameterCount = cpu_to_le16(pSMB->TotalParameterCount); -+ pSMB->ParameterCount = pSMB->TotalParameterCount; -+ pSMB->InformationLevel = cpu_to_le16(SMB_INFO_QUERY_ALL_EAS); -+ pSMB->Reserved4 = 0; -+ pSMB->hdr.smb_buf_length += pSMB->ByteCount; -+ pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); -+ -+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, -+ (struct smb_hdr *) pSMBr, &bytes_returned, 0); -+ if (rc) { -+ cFYI(1, ("Send error in QueryAllEAs = %d", rc)); -+ } else { /* decode response */ -+ pSMBr->DataOffset = le16_to_cpu(pSMBr->DataOffset); -+ /* BB also check enough total bytes returned */ -+ /* BB we need to improve the validity checking -+ of these trans2 responses */ -+ if ((pSMBr->ByteCount < 4) || (pSMBr->DataOffset > 512)) -+ rc = -EIO; /* bad smb */ -+ /* else if (pFindData){ -+ memcpy((char *) pFindData, -+ (char *) &pSMBr->hdr.Protocol + -+ pSMBr->DataOffset, kl); -+ }*/ else { -+ /* check that length of list is not more than bcc */ -+ /* check that each entry does not go beyond length -+ of list */ -+ /* check that each element of each entry does not -+ go beyond end of list */ -+ struct fealist * ea_response_data; -+ rc = 0; -+ /* validate_trans2_offsets() */ -+ /* BB to check if(start of smb + pSMBr->DataOffset > &bcc+ bcc)*/ -+ ea_response_data = (struct fealist *) -+ (((char *) &pSMBr->hdr.Protocol) + -+ pSMBr->DataOffset); -+ cFYI(1,("ea length %d",ea_response_data->list_len)); -+ } -+ } -+ if (pSMB) -+ cifs_buf_release(pSMB); -+ if (rc == -EAGAIN) -+ goto QAllEAsRetry; -+ -+ return rc; -+} -+#endif ---- /dev/null -+++ b/fs/cifs/cifs_unicode.c -@@ -0,0 +1,87 @@ -+/* -+ * fs/cifs/cifs_unicode.c -+ * -+ * Copyright (c) International Business Machines Corp., 2000,2002 -+ * Modified by Steve French (sfrench@us.ibm.com) -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; 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 -+ */ -+#include <linux/fs.h> -+#include "cifs_unicode.h" -+#include "cifs_uniupr.h" -+#include "cifspdu.h" -+#include "cifs_debug.h" -+ -+/* -+ * NAME: cifs_strfromUCS() -+ * -+ * FUNCTION: Convert little-endian unicode string to character string -+ * -+ */ -+int -+cifs_strfromUCS_le(char *to, const wchar_t * from, /* LITTLE ENDIAN */ -+ int len, const struct nls_table *codepage) -+{ -+ int i; -+ int outlen = 0; -+ -+ for (i = 0; (i < len) && from[i]; i++) { -+ int charlen; -+ /* 2.4.0 kernel or greater */ -+ charlen = -+ codepage->uni2char(le16_to_cpu(from[i]), &to[outlen], -+ NLS_MAX_CHARSET_SIZE); -+ if (charlen > 0) { -+ outlen += charlen; -+ } else { -+ to[outlen++] = '?'; -+ } -+ } -+ to[outlen] = 0; -+ return outlen; -+} -+ -+/* -+ * NAME: cifs_strtoUCS() -+ * -+ * FUNCTION: Convert character string to unicode string -+ * -+ */ -+int -+cifs_strtoUCS(wchar_t * to, const char *from, int len, -+ const struct nls_table *codepage) -+{ -+ int charlen; -+ int i; -+ -+ for (i = 0; len && *from; i++, from += charlen, len -= charlen) { -+ -+ /* works for 2.4.0 kernel or later */ -+ charlen = codepage->char2uni(from, len, &to[i]); -+ if (charlen < 1) { -+ cERROR(1, -+ ("cifs_strtoUCS: char2uni returned %d", -+ charlen)); -+ to[i] = cpu_to_le16(0x003f); /* a question mark */ -+ charlen = 1; -+ } -+ to[i] = cpu_to_le16(to[i]); -+ -+ } -+ -+ to[i] = 0; -+ return i; -+} -+ ---- /dev/null -+++ b/fs/cifs/cifs_unicode.h -@@ -0,0 +1,353 @@ -+/* -+ * cifs_unicode: Unicode kernel case support -+ * -+ * Function: -+ * Convert a unicode character to upper or lower case using -+ * compressed tables. -+ * -+ * Copyright (c) International Business Machines Corp., 2000,2002 -+ * -+ * 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 -+ * -+ * -+ * Notes: -+ * These APIs are based on the C library functions. The semantics -+ * should match the C functions but with expanded size operands. -+ * -+ * The upper/lower functions are based on a table created by mkupr. -+ * This is a compressed table of upper and lower case conversion. -+ * -+ */ -+ -+#include <asm/byteorder.h> -+#include <linux/types.h> -+#include <linux/nls.h> -+ -+#define UNIUPR_NOLOWER /* Example to not expand lower case tables */ -+ -+/* Just define what we want from uniupr.h. We don't want to define the tables -+ * in each source file. -+ */ -+#ifndef UNICASERANGE_DEFINED -+struct UniCaseRange { -+ wchar_t start; -+ wchar_t end; -+ signed char *table; -+}; -+#endif /* UNICASERANGE_DEFINED */ -+ -+#ifndef UNIUPR_NOUPPER -+extern signed char CifsUniUpperTable[512]; -+extern const struct UniCaseRange CifsUniUpperRange[]; -+#endif /* UNIUPR_NOUPPER */ -+ -+#ifndef UNIUPR_NOLOWER -+extern signed char UniLowerTable[512]; -+extern struct UniCaseRange UniLowerRange[]; -+#endif /* UNIUPR_NOLOWER */ -+ -+#ifdef __KERNEL__ -+int cifs_strfromUCS_le(char *, const wchar_t *, int, const struct nls_table *); -+int cifs_strtoUCS(wchar_t *, const char *, int, const struct nls_table *); -+#endif -+ -+/* -+ * UniStrcat: Concatenate the second string to the first -+ * -+ * Returns: -+ * Address of the first string -+ */ -+static inline wchar_t * -+UniStrcat(wchar_t * ucs1, const wchar_t * ucs2) -+{ -+ wchar_t *anchor = ucs1; /* save a pointer to start of ucs1 */ -+ -+ while (*ucs1++) ; /* To end of first string */ -+ ucs1--; /* Return to the null */ -+ while ((*ucs1++ = *ucs2++)) ; /* copy string 2 over */ -+ return anchor; -+} -+ -+/* -+ * UniStrchr: Find a character in a string -+ * -+ * Returns: -+ * Address of first occurrence of character in string -+ * or NULL if the character is not in the string -+ */ -+static inline wchar_t * -+UniStrchr(const wchar_t * ucs, wchar_t uc) -+{ -+ while ((*ucs != uc) && *ucs) -+ ucs++; -+ -+ if (*ucs == uc) -+ return (wchar_t *) ucs; -+ return NULL; -+} -+ -+/* -+ * UniStrcmp: Compare two strings -+ * -+ * Returns: -+ * < 0: First string is less than second -+ * = 0: Strings are equal -+ * > 0: First string is greater than second -+ */ -+static inline int -+UniStrcmp(const wchar_t * ucs1, const wchar_t * ucs2) -+{ -+ while ((*ucs1 == *ucs2) && *ucs1) { -+ ucs1++; -+ ucs2++; -+ } -+ return (int) *ucs1 - (int) *ucs2; -+} -+ -+/* -+ * UniStrcpy: Copy a string -+ */ -+static inline wchar_t * -+UniStrcpy(wchar_t * ucs1, const wchar_t * ucs2) -+{ -+ wchar_t *anchor = ucs1; /* save the start of result string */ -+ -+ while ((*ucs1++ = *ucs2++)) ; -+ return anchor; -+} -+ -+/* -+ * UniStrlen: Return the length of a string (in 16 bit Unicode chars not bytes) -+ */ -+static inline size_t -+UniStrlen(const wchar_t * ucs1) -+{ -+ int i = 0; -+ -+ while (*ucs1++) -+ i++; -+ return i; -+} -+ -+/* -+ * UniStrnlen: Return the length (in 16 bit Unicode chars not bytes) of a string (length limited) -+ */ -+static inline size_t -+UniStrnlen(const wchar_t * ucs1, int maxlen) -+{ -+ int i = 0; -+ -+ while (*ucs1++) { -+ i++; -+ if (i >= maxlen) -+ break; -+ } -+ return i; -+} -+ -+/* -+ * UniStrncat: Concatenate length limited string -+ */ -+static inline wchar_t * -+UniStrncat(wchar_t * ucs1, const wchar_t * ucs2, size_t n) -+{ -+ wchar_t *anchor = ucs1; /* save pointer to string 1 */ -+ -+ while (*ucs1++) ; -+ ucs1--; /* point to null terminator of s1 */ -+ while (n-- && (*ucs1 = *ucs2)) { /* copy s2 after s1 */ -+ ucs1++; -+ ucs2++; -+ } -+ *ucs1 = 0; /* Null terminate the result */ -+ return (anchor); -+} -+ -+/* -+ * UniStrncmp: Compare length limited string -+ */ -+static inline int -+UniStrncmp(const wchar_t * ucs1, const wchar_t * ucs2, size_t n) -+{ -+ if (!n) -+ return 0; /* Null strings are equal */ -+ while ((*ucs1 == *ucs2) && *ucs1 && --n) { -+ ucs1++; -+ ucs2++; -+ } -+ return (int) *ucs1 - (int) *ucs2; -+} -+ -+/* -+ * UniStrncmp_le: Compare length limited string - native to little-endian -+ */ -+static inline int -+UniStrncmp_le(const wchar_t * ucs1, const wchar_t * ucs2, size_t n) -+{ -+ if (!n) -+ return 0; /* Null strings are equal */ -+ while ((*ucs1 == __le16_to_cpu(*ucs2)) && *ucs1 && --n) { -+ ucs1++; -+ ucs2++; -+ } -+ return (int) *ucs1 - (int) __le16_to_cpu(*ucs2); -+} -+ -+/* -+ * UniStrncpy: Copy length limited string with pad -+ */ -+static inline wchar_t * -+UniStrncpy(wchar_t * ucs1, const wchar_t * ucs2, size_t n) -+{ -+ wchar_t *anchor = ucs1; -+ -+ while (n-- && *ucs2) /* Copy the strings */ -+ *ucs1++ = *ucs2++; -+ -+ n++; -+ while (n--) /* Pad with nulls */ -+ *ucs1++ = 0; -+ return anchor; -+} -+ -+/* -+ * UniStrncpy_le: Copy length limited string with pad to little-endian -+ */ -+static inline wchar_t * -+UniStrncpy_le(wchar_t * ucs1, const wchar_t * ucs2, size_t n) -+{ -+ wchar_t *anchor = ucs1; -+ -+ while (n-- && *ucs2) /* Copy the strings */ -+ *ucs1++ = __le16_to_cpu(*ucs2++); -+ -+ n++; -+ while (n--) /* Pad with nulls */ -+ *ucs1++ = 0; -+ return anchor; -+} -+ -+/* -+ * UniStrstr: Find a string in a string -+ * -+ * Returns: -+ * Address of first match found -+ * NULL if no matching string is found -+ */ -+static inline wchar_t * -+UniStrstr(const wchar_t * ucs1, const wchar_t * ucs2) -+{ -+ const wchar_t *anchor1 = ucs1; -+ const wchar_t *anchor2 = ucs2; -+ -+ while (*ucs1) { -+ if (*ucs1 == *ucs2) { /* Partial match found */ -+ ucs1++; -+ ucs2++; -+ } else { -+ if (!*ucs2) /* Match found */ -+ return (wchar_t *) anchor1; -+ ucs1 = ++anchor1; /* No match */ -+ ucs2 = anchor2; -+ } -+ } -+ -+ if (!*ucs2) /* Both end together */ -+ return (wchar_t *) anchor1; /* Match found */ -+ return NULL; /* No match */ -+} -+ -+#ifndef UNIUPR_NOUPPER -+/* -+ * UniToupper: Convert a unicode character to upper case -+ */ -+static inline wchar_t -+UniToupper(register wchar_t uc) -+{ -+ register const struct UniCaseRange *rp; -+ -+ if (uc < sizeof (CifsUniUpperTable)) { /* Latin characters */ -+ return uc + CifsUniUpperTable[uc]; /* Use base tables */ -+ } else { -+ rp = CifsUniUpperRange; /* Use range tables */ -+ while (rp->start) { -+ if (uc < rp->start) /* Before start of range */ -+ return uc; /* Uppercase = input */ -+ if (uc <= rp->end) /* In range */ -+ return uc + rp->table[uc - rp->start]; -+ rp++; /* Try next range */ -+ } -+ } -+ return uc; /* Past last range */ -+} -+ -+/* -+ * UniStrupr: Upper case a unicode string -+ */ -+static inline wchar_t * -+UniStrupr(register wchar_t * upin) -+{ -+ register wchar_t *up; -+ -+ up = upin; -+ while (*up) { /* For all characters */ -+ *up = UniToupper(*up); -+ up++; -+ } -+ return upin; /* Return input pointer */ -+} -+#endif /* UNIUPR_NOUPPER */ -+ -+#ifndef UNIUPR_NOLOWER -+/* -+ * UniTolower: Convert a unicode character to lower case -+ */ -+static inline wchar_t -+UniTolower(wchar_t uc) -+{ -+ register struct UniCaseRange *rp; -+ -+ if (uc < sizeof (UniLowerTable)) { /* Latin characters */ -+ return uc + UniLowerTable[uc]; /* Use base tables */ -+ } else { -+ rp = UniLowerRange; /* Use range tables */ -+ while (rp->start) { -+ if (uc < rp->start) /* Before start of range */ -+ return uc; /* Uppercase = input */ -+ if (uc <= rp->end) /* In range */ -+ return uc + rp->table[uc - rp->start]; -+ rp++; /* Try next range */ -+ } -+ } -+ return uc; /* Past last range */ -+} -+ -+/* -+ * UniStrlwr: Lower case a unicode string -+ */ -+static inline wchar_t * -+UniStrlwr(register wchar_t * upin) -+{ -+ register wchar_t *up; -+ -+ up = upin; -+ while (*up) { /* For all characters */ -+ *up = UniTolower(*up); -+ up++; -+ } -+ return upin; /* Return input pointer */ -+} -+ -+#endif ---- /dev/null -+++ b/fs/cifs/cifs_uniupr.h -@@ -0,0 +1,253 @@ -+/* -+ * Copyright (c) International Business Machines Corp., 2000,2002 -+ * -+ * 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 -+ * -+ * uniupr.h - Unicode compressed case ranges -+ * -+*/ -+ -+#ifndef UNIUPR_NOUPPER -+/* -+ * Latin upper case -+ */ -+signed char CifsUniUpperTable[512] = { -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 000-00f */ -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 010-01f */ -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 020-02f */ -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 030-03f */ -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 040-04f */ -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 050-05f */ -+ 0, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, /* 060-06f */ -+ -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, 0, 0, 0, 0, 0, /* 070-07f */ -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 080-08f */ -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 090-09f */ -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0a0-0af */ -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0b0-0bf */ -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0c0-0cf */ -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0d0-0df */ -+ -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, /* 0e0-0ef */ -+ -32, -32, -32, -32, -32, -32, -32, 0, -32, -32, -32, -32, -32, -32, -32, 121, /* 0f0-0ff */ -+ 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, /* 100-10f */ -+ 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, /* 110-11f */ -+ 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, /* 120-12f */ -+ 0, 0, 0, -1, 0, -1, 0, -1, 0, 0, -1, 0, -1, 0, -1, 0, /* 130-13f */ -+ -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, 0, -1, 0, -1, 0, -1, /* 140-14f */ -+ 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, /* 150-15f */ -+ 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, /* 160-16f */ -+ 0, -1, 0, -1, 0, -1, 0, -1, 0, 0, -1, 0, -1, 0, -1, 0, /* 170-17f */ -+ 0, 0, 0, -1, 0, -1, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, /* 180-18f */ -+ 0, 0, -1, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, /* 190-19f */ -+ 0, -1, 0, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, /* 1a0-1af */ -+ -1, 0, 0, 0, -1, 0, -1, 0, 0, -1, 0, 0, 0, -1, 0, 0, /* 1b0-1bf */ -+ 0, 0, 0, 0, 0, -1, -2, 0, -1, -2, 0, -1, -2, 0, -1, 0, /* 1c0-1cf */ -+ -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, -79, 0, -1, /* 1d0-1df */ -+ 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, /* 1e0-1ef */ -+ 0, 0, -1, -2, 0, -1, 0, 0, 0, -1, 0, -1, 0, -1, 0, -1, /* 1f0-1ff */ -+}; -+ -+/* Upper case range - Greek */ -+static signed char UniCaseRangeU03a0[47] = { -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -38, -37, -37, -37, /* 3a0-3af */ -+ 0, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, /* 3b0-3bf */ -+ -32, -32, -31, -32, -32, -32, -32, -32, -32, -32, -32, -32, -64, -+ -63, -63, -+}; -+ -+/* Upper case range - Cyrillic */ -+static signed char UniCaseRangeU0430[48] = { -+ -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, /* 430-43f */ -+ -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, /* 440-44f */ -+ 0, -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, 0, -80, -80, /* 450-45f */ -+}; -+ -+/* Upper case range - Extended cyrillic */ -+static signed char UniCaseRangeU0490[61] = { -+ 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, /* 490-49f */ -+ 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, /* 4a0-4af */ -+ 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, /* 4b0-4bf */ -+ 0, 0, -1, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, -+}; -+ -+/* Upper case range - Extended latin and greek */ -+static signed char UniCaseRangeU1e00[509] = { -+ 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, /* 1e00-1e0f */ -+ 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, /* 1e10-1e1f */ -+ 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, /* 1e20-1e2f */ -+ 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, /* 1e30-1e3f */ -+ 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, /* 1e40-1e4f */ -+ 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, /* 1e50-1e5f */ -+ 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, /* 1e60-1e6f */ -+ 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, /* 1e70-1e7f */ -+ 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, /* 1e80-1e8f */ -+ 0, -1, 0, -1, 0, -1, 0, 0, 0, 0, 0, -59, 0, -1, 0, -1, /* 1e90-1e9f */ -+ 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, /* 1ea0-1eaf */ -+ 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, /* 1eb0-1ebf */ -+ 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, /* 1ec0-1ecf */ -+ 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, /* 1ed0-1edf */ -+ 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, /* 1ee0-1eef */ -+ 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, 0, 0, 0, 0, 0, /* 1ef0-1eff */ -+ 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, /* 1f00-1f0f */ -+ 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 1f10-1f1f */ -+ 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, /* 1f20-1f2f */ -+ 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, /* 1f30-1f3f */ -+ 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 1f40-1f4f */ -+ 0, 8, 0, 8, 0, 8, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, /* 1f50-1f5f */ -+ 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, /* 1f60-1f6f */ -+ 74, 74, 86, 86, 86, 86, 100, 100, 0, 0, 112, 112, 126, 126, 0, 0, /* 1f70-1f7f */ -+ 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, /* 1f80-1f8f */ -+ 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, /* 1f90-1f9f */ -+ 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, /* 1fa0-1faf */ -+ 8, 8, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 1fb0-1fbf */ -+ 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 1fc0-1fcf */ -+ 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 1fd0-1fdf */ -+ 8, 8, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 1fe0-1fef */ -+ 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, -+}; -+ -+/* Upper case range - Wide latin */ -+static signed char UniCaseRangeUff40[27] = { -+ 0, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, /* ff40-ff4f */ -+ -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -+}; -+ -+/* -+ * Upper Case Range -+ */ -+const struct UniCaseRange CifsUniUpperRange[] = { -+ {0x03a0, 0x03ce, UniCaseRangeU03a0}, -+ {0x0430, 0x045f, UniCaseRangeU0430}, -+ {0x0490, 0x04cc, UniCaseRangeU0490}, -+ {0x1e00, 0x1ffc, UniCaseRangeU1e00}, -+ {0xff40, 0xff5a, UniCaseRangeUff40}, -+ {0, 0, NULL} -+}; -+#endif -+ -+#ifndef UNIUPR_NOLOWER -+/* -+ * Latin lower case -+ */ -+static signed char CifsUniLowerTable[512] = { -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 000-00f */ -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 010-01f */ -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 020-02f */ -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 030-03f */ -+ 0, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, /* 040-04f */ -+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 0, 0, 0, 0, 0, /* 050-05f */ -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 060-06f */ -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 070-07f */ -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 080-08f */ -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 090-09f */ -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0a0-0af */ -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0b0-0bf */ -+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, /* 0c0-0cf */ -+ 32, 32, 32, 32, 32, 32, 32, 0, 32, 32, 32, 32, 32, 32, 32, 0, /* 0d0-0df */ -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0e0-0ef */ -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0f0-0ff */ -+ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, /* 100-10f */ -+ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, /* 110-11f */ -+ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, /* 120-12f */ -+ 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, /* 130-13f */ -+ 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, /* 140-14f */ -+ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, /* 150-15f */ -+ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, /* 160-16f */ -+ 1, 0, 1, 0, 1, 0, 1, 0, -121, 1, 0, 1, 0, 1, 0, 0, /* 170-17f */ -+ 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 79, 0, /* 180-18f */ -+ 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, /* 190-19f */ -+ 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, /* 1a0-1af */ -+ 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, /* 1b0-1bf */ -+ 0, 0, 0, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 1, 0, 1, /* 1c0-1cf */ -+ 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, /* 1d0-1df */ -+ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, /* 1e0-1ef */ -+ 0, 2, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, /* 1f0-1ff */ -+}; -+ -+/* Lower case range - Greek */ -+static signed char UniCaseRangeL0380[44] = { -+ 0, 0, 0, 0, 0, 0, 38, 0, 37, 37, 37, 0, 64, 0, 63, 63, /* 380-38f */ -+ 0, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, /* 390-39f */ -+ 32, 32, 0, 32, 32, 32, 32, 32, 32, 32, 32, 32, -+}; -+ -+/* Lower case range - Cyrillic */ -+static signed char UniCaseRangeL0400[48] = { -+ 0, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 0, 80, 80, /* 400-40f */ -+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, /* 410-41f */ -+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, /* 420-42f */ -+}; -+ -+/* Lower case range - Extended cyrillic */ -+static signed char UniCaseRangeL0490[60] = { -+ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, /* 490-49f */ -+ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, /* 4a0-4af */ -+ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, /* 4b0-4bf */ -+ 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, -+}; -+ -+/* Lower case range - Extended latin and greek */ -+static signed char UniCaseRangeL1e00[504] = { -+ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, /* 1e00-1e0f */ -+ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, /* 1e10-1e1f */ -+ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, /* 1e20-1e2f */ -+ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, /* 1e30-1e3f */ -+ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, /* 1e40-1e4f */ -+ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, /* 1e50-1e5f */ -+ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, /* 1e60-1e6f */ -+ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, /* 1e70-1e7f */ -+ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, /* 1e80-1e8f */ -+ 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, /* 1e90-1e9f */ -+ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, /* 1ea0-1eaf */ -+ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, /* 1eb0-1ebf */ -+ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, /* 1ec0-1ecf */ -+ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, /* 1ed0-1edf */ -+ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, /* 1ee0-1eef */ -+ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, /* 1ef0-1eff */ -+ 0, 0, 0, 0, 0, 0, 0, 0, -8, -8, -8, -8, -8, -8, -8, -8, /* 1f00-1f0f */ -+ 0, 0, 0, 0, 0, 0, 0, 0, -8, -8, -8, -8, -8, -8, 0, 0, /* 1f10-1f1f */ -+ 0, 0, 0, 0, 0, 0, 0, 0, -8, -8, -8, -8, -8, -8, -8, -8, /* 1f20-1f2f */ -+ 0, 0, 0, 0, 0, 0, 0, 0, -8, -8, -8, -8, -8, -8, -8, -8, /* 1f30-1f3f */ -+ 0, 0, 0, 0, 0, 0, 0, 0, -8, -8, -8, -8, -8, -8, 0, 0, /* 1f40-1f4f */ -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, -8, 0, -8, 0, -8, 0, -8, /* 1f50-1f5f */ -+ 0, 0, 0, 0, 0, 0, 0, 0, -8, -8, -8, -8, -8, -8, -8, -8, /* 1f60-1f6f */ -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 1f70-1f7f */ -+ 0, 0, 0, 0, 0, 0, 0, 0, -8, -8, -8, -8, -8, -8, -8, -8, /* 1f80-1f8f */ -+ 0, 0, 0, 0, 0, 0, 0, 0, -8, -8, -8, -8, -8, -8, -8, -8, /* 1f90-1f9f */ -+ 0, 0, 0, 0, 0, 0, 0, 0, -8, -8, -8, -8, -8, -8, -8, -8, /* 1fa0-1faf */ -+ 0, 0, 0, 0, 0, 0, 0, 0, -8, -8, -74, -74, -9, 0, 0, 0, /* 1fb0-1fbf */ -+ 0, 0, 0, 0, 0, 0, 0, 0, -86, -86, -86, -86, -9, 0, 0, 0, /* 1fc0-1fcf */ -+ 0, 0, 0, 0, 0, 0, 0, 0, -8, -8, -100, -100, 0, 0, 0, 0, /* 1fd0-1fdf */ -+ 0, 0, 0, 0, 0, 0, 0, 0, -8, -8, -112, -112, -7, 0, 0, 0, /* 1fe0-1fef */ -+ 0, 0, 0, 0, 0, 0, 0, 0, -+}; -+ -+/* Lower case range - Wide latin */ -+static signed char UniCaseRangeLff20[27] = { -+ 0, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, /* ff20-ff2f */ -+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, -+}; -+ -+/* -+ * Lower Case Range -+ */ -+const static struct UniCaseRange CifsUniLowerRange[] = { -+ 0x0380, 0x03ab, UniCaseRangeL0380, -+ 0x0400, 0x042f, UniCaseRangeL0400, -+ 0x0490, 0x04cb, UniCaseRangeL0490, -+ 0x1e00, 0x1ff7, UniCaseRangeL1e00, -+ 0xff20, 0xff3a, UniCaseRangeLff20, -+ 0, 0, 0 -+}; -+#endif ---- /dev/null -+++ b/fs/cifs/connect.c -@@ -0,0 +1,2924 @@ -+/* -+ * fs/cifs/connect.c -+ * -+ * Copyright (C) International Business Machines Corp., 2002,2004 -+ * Author(s): Steve French (sfrench@us.ibm.com) -+ * -+ * This library is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU Lesser General Public License as published -+ * by the Free Software Foundation; either version 2.1 of the License, or -+ * (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -+ * the GNU Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public License -+ * along with this library; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ */ -+#include <linux/fs.h> -+#include <linux/net.h> -+#include <linux/string.h> -+#include <linux/list.h> -+#include <linux/wait.h> -+#include <linux/version.h> -+#include <linux/ipv6.h> -+#include <linux/pagemap.h> -+#include <linux/ctype.h> -+#include <linux/utsname.h> -+#include <asm/uaccess.h> -+#include <asm/processor.h> -+#include "cifspdu.h" -+#include "cifsglob.h" -+#include "cifsproto.h" -+#include "cifs_unicode.h" -+#include "cifs_debug.h" -+#include "cifs_fs_sb.h" -+#include "ntlmssp.h" -+#include "nterr.h" -+#include "rfc1002pdu.h" -+ -+#define CIFS_PORT 445 -+#define RFC1001_PORT 139 -+ -+extern void SMBencrypt(unsigned char *passwd, unsigned char *c8, -+ unsigned char *p24); -+extern void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, -+ unsigned char *p24); -+extern int cifs_inet_pton(int, const char *, void *dst); -+ -+struct smb_vol { -+ char *username; -+ char *password; -+ char *domainname; -+ char *UNC; -+ char *UNCip; -+ char *iocharset; /* local code page for mapping to and from Unicode */ -+ char source_rfc1001_name[16]; /* netbios name of client */ -+ uid_t linux_uid; -+ gid_t linux_gid; -+ mode_t file_mode; -+ mode_t dir_mode; -+ int rw:1; -+ int retry:1; -+ int intr:1; -+ unsigned int rsize; -+ unsigned int wsize; -+ unsigned int sockopt; -+ unsigned short int port; -+}; -+ -+static int ipv4_connect(struct sockaddr_in *psin_server, -+ struct socket **csocket, -+ char * netb_name); -+static int ipv6_connect(struct sockaddr_in6 *psin_server, -+ struct socket **csocket); -+ -+ -+ /* -+ * cifs tcp session reconnection -+ * -+ * mark tcp session as reconnecting so temporarily locked -+ * mark all smb sessions as reconnecting for tcp session -+ * reconnect tcp session -+ * wake up waiters on reconnection? - (not needed currently) -+ */ -+ -+int -+cifs_reconnect(struct TCP_Server_Info *server) -+{ -+ int rc = 0; -+ struct list_head *tmp; -+ struct cifsSesInfo *ses; -+ struct cifsTconInfo *tcon; -+ struct mid_q_entry * mid_entry; -+ -+ spin_lock(&GlobalMid_Lock); -+ if(server->tcpStatus == CifsExiting) { -+ /* the demux thread will exit normally -+ next time through the loop */ -+ spin_unlock(&GlobalMid_Lock); -+ return rc; -+ } else -+ server->tcpStatus = CifsNeedReconnect; -+ spin_unlock(&GlobalMid_Lock); -+ server->maxBuf = 0; -+ -+ cFYI(1, ("Reconnecting tcp session ")); -+ -+ /* before reconnecting the tcp session, mark the smb session (uid) -+ and the tid bad so they are not used until reconnected */ -+ read_lock(&GlobalSMBSeslock); -+ list_for_each(tmp, &GlobalSMBSessionList) { -+ ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); -+ if (ses->server) { -+ if (ses->server == server) { -+ ses->status = CifsNeedReconnect; -+ ses->ipc_tid = 0; -+ } -+ } -+ /* else tcp and smb sessions need reconnection */ -+ } -+ list_for_each(tmp, &GlobalTreeConnectionList) { -+ tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); -+ if((tcon) && (tcon->ses) && (tcon->ses->server == server)) { -+ tcon->tidStatus = CifsNeedReconnect; -+ } -+ } -+ read_unlock(&GlobalSMBSeslock); -+ /* do not want to be sending data on a socket we are freeing */ -+ down(&server->tcpSem); -+ if(server->ssocket) { -+ cFYI(1,("State: 0x%x Flags: 0x%lx", server->ssocket->state, -+ server->ssocket->flags)); -+ server->ssocket->ops->shutdown(server->ssocket,SEND_SHUTDOWN); -+ cFYI(1,("Post shutdown state: 0x%x Flags: 0x%lx", server->ssocket->state, -+ server->ssocket->flags)); -+ sock_release(server->ssocket); -+ server->ssocket = NULL; -+ } -+ -+ spin_lock(&GlobalMid_Lock); -+ list_for_each(tmp, &server->pending_mid_q) { -+ mid_entry = list_entry(tmp, struct -+ mid_q_entry, -+ qhead); -+ if(mid_entry) { -+ if(mid_entry->midState == MID_REQUEST_SUBMITTED) { -+ /* Mark other intransit requests as needing retry so -+ we do not immediately mark the session bad again -+ (ie after we reconnect below) as they timeout too */ -+ mid_entry->midState = MID_RETRY_NEEDED; -+ } -+ } -+ } -+ spin_unlock(&GlobalMid_Lock); -+ up(&server->tcpSem); -+ -+ while ((server->tcpStatus != CifsExiting) && (server->tcpStatus != CifsGood)) -+ { -+ if(server->protocolType == IPV6) { -+ rc = ipv6_connect(&server->addr.sockAddr6,&server->ssocket); -+ } else { -+ rc = ipv4_connect(&server->addr.sockAddr, -+ &server->ssocket, -+ server->workstation_RFC1001_name); -+ } -+ if(rc) { -+ set_current_state(TASK_INTERRUPTIBLE); -+ schedule_timeout(3 * HZ); -+ } else { -+ atomic_inc(&tcpSesReconnectCount); -+ spin_lock(&GlobalMid_Lock); -+ if(server->tcpStatus != CifsExiting) -+ server->tcpStatus = CifsGood; -+ spin_unlock(&GlobalMid_Lock); -+ /* atomic_set(&server->inFlight,0);*/ -+ wake_up(&server->response_q); -+ } -+ } -+ return rc; -+} -+ -+static int -+cifs_demultiplex_thread(struct TCP_Server_Info *server) -+{ -+ int length; -+ unsigned int pdu_length, total_read; -+ struct smb_hdr *smb_buffer = NULL; -+ struct msghdr smb_msg; -+ mm_segment_t temp_fs; -+ struct iovec iov; -+ struct socket *csocket = server->ssocket; -+ struct list_head *tmp; -+ struct cifsSesInfo *ses; -+ struct task_struct *task_to_wake = NULL; -+ struct mid_q_entry *mid_entry; -+ char *temp; -+ -+ daemonize(); -+ sprintf(current->comm,"cifsd"); -+ /* allow_signal(SIGKILL);*/ -+ current->flags |= PF_MEMALLOC; -+ server->tsk = current; /* save process info to wake at shutdown */ -+ cFYI(1, ("Demultiplex PID: %d", current->pid)); -+ -+ temp_fs = get_fs(); /* we must turn off socket api parm checking */ -+ set_fs(get_ds()); -+ -+ while (server->tcpStatus != CifsExiting) { -+ if (smb_buffer == NULL) -+ smb_buffer = cifs_buf_get(); -+ else -+ memset(smb_buffer, 0, sizeof (struct smb_hdr)); -+ -+ if (smb_buffer == NULL) { -+ cERROR(1,("Can not get memory for SMB response")); -+ set_current_state(TASK_INTERRUPTIBLE); -+ schedule_timeout(HZ * 3); /* give system time to free memory */ -+ continue; -+ } -+ iov.iov_base = smb_buffer; -+ iov.iov_len = sizeof (struct smb_hdr) - 1; -+ /* 1 byte less above since wct is not always returned in error cases */ -+ smb_msg.msg_iov = &iov; -+ smb_msg.msg_iovlen = 1; -+ smb_msg.msg_control = NULL; -+ smb_msg.msg_controllen = 0; -+ -+ length = -+ sock_recvmsg(csocket, &smb_msg, -+ sizeof (struct smb_hdr) - -+ 1 /* RFC1001 header and SMB header */ , -+ MSG_PEEK /* flags see socket.h */ ); -+ -+ if(server->tcpStatus == CifsExiting) { -+ break; -+ } else if (server->tcpStatus == CifsNeedReconnect) { -+ cFYI(1,("Reconnecting after server stopped responding")); -+ cifs_reconnect(server); -+ cFYI(1,("call to reconnect done")); -+ csocket = server->ssocket; -+ continue; -+ } else if ((length == -ERESTARTSYS) || (length == -EAGAIN)) { -+ set_current_state(TASK_INTERRUPTIBLE); -+ schedule_timeout(1); /* minimum sleep to prevent looping -+ allowing socket to clear and app threads to set -+ tcpStatus CifsNeedReconnect if server hung */ -+ continue; -+ } else if (length <= 0) { -+ if(server->tcpStatus == CifsNew) { -+ cFYI(1,("tcp session abended prematurely (after SMBnegprot)")); -+ /* some servers kill tcp session rather than returning -+ smb negprot error in which case reconnecting here is -+ not going to help - return error to mount */ -+ break; -+ } -+ if(length == -EINTR) { -+ cFYI(1,("cifsd thread killed")); -+ break; -+ } -+ cFYI(1,("Reconnecting after unexpected peek error %d",length)); -+ cifs_reconnect(server); -+ csocket = server->ssocket; -+ wake_up(&server->response_q); -+ continue; -+ } -+ -+ pdu_length = 4 + ntohl(smb_buffer->smb_buf_length); -+ /* Ony read pdu_length after below checks for too short (due -+ to e.g. int overflow) and too long ie beyond end of buf */ -+ cFYI(1, ("Peek length rcvd: 0x%x beginning 0x%x)", length, pdu_length)); -+ -+ temp = (char *) smb_buffer; -+ if (length > 3) { -+ if (temp[0] == (char) RFC1002_SESSION_KEEP_ALIVE) { -+ iov.iov_base = smb_buffer; -+ iov.iov_len = 4; -+ length = sock_recvmsg(csocket, &smb_msg, 4, 0); -+ cFYI(0,("Received 4 byte keep alive packet")); -+ } else if (temp[0] == (char) RFC1002_POSITIVE_SESSION_RESPONSE) { -+ iov.iov_base = smb_buffer; -+ iov.iov_len = 4; -+ length = sock_recvmsg(csocket, &smb_msg, 4, 0); -+ cFYI(1,("Good RFC 1002 session rsp")); -+ } else if ((temp[0] == (char)RFC1002_NEGATIVE_SESSION_RESPONSE) -+ && (length == 5)) { -+ /* we get this from Windows 98 instead of error on SMB negprot response */ -+ cFYI(1,("Negative RFC 1002 Session Response Error 0x%x)",temp[4])); -+ if(server->tcpStatus == CifsNew) { -+ /* if nack on negprot (rather than -+ ret of smb negprot error) reconnecting -+ not going to help, ret error to mount */ -+ break; -+ } else { -+ /* give server a second to -+ clean up before reconnect attempt */ -+ set_current_state(TASK_INTERRUPTIBLE); -+ schedule_timeout(HZ); -+ /* always try 445 first on reconnect -+ since we get NACK on some if we ever -+ connected to port 139 (the NACK is -+ since we do not begin with RFC1001 -+ session initialize frame) */ -+ server->addr.sockAddr.sin_port = CIFS_PORT; -+ cifs_reconnect(server); -+ csocket = server->ssocket; -+ wake_up(&server->response_q); -+ continue; -+ } -+ } else if (temp[0] != (char) 0) { -+ cERROR(1,("Unknown RFC 1002 frame")); -+ cifs_dump_mem(" Received Data: ", temp, length); -+ cifs_reconnect(server); -+ csocket = server->ssocket; -+ continue; -+ } else { -+ if ((length != sizeof (struct smb_hdr) - 1) -+ || (pdu_length > -+ CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE) -+ || (pdu_length < -+ sizeof (struct smb_hdr) - 1) -+ || -+ (checkSMBhdr -+ (smb_buffer, smb_buffer->Mid))) { -+ cERROR(1, -+ ("Invalid size or format for SMB found with length %d and pdu_lenght %d", -+ length, pdu_length)); -+ cifs_dump_mem("Received Data is: ",temp,sizeof(struct smb_hdr)); -+ /* could we fix this network corruption by finding next -+ smb header (instead of killing the session) and -+ restart reading from next valid SMB found? */ -+ cifs_reconnect(server); -+ csocket = server->ssocket; -+ continue; -+ } else { /* length ok */ -+ -+ length = 0; -+ iov.iov_base = smb_buffer; -+ iov.iov_len = pdu_length; -+ for (total_read = 0; -+ total_read < pdu_length; -+ total_read += length) { -+ length = sock_recvmsg(csocket, &smb_msg, -+ pdu_length - total_read, 0); -+ if (length == 0) { -+ cERROR(1, -+ ("Zero length receive when expecting %d ", -+ pdu_length - total_read)); -+ cifs_reconnect(server); -+ csocket = server->ssocket; -+ continue; -+ } -+ } -+ } -+ -+ dump_smb(smb_buffer, length); -+ if (checkSMB -+ (smb_buffer, smb_buffer->Mid, total_read)) { -+ cERROR(1, ("Bad SMB Received ")); -+ continue; -+ } -+ -+ task_to_wake = NULL; -+ spin_lock(&GlobalMid_Lock); -+ list_for_each(tmp, &server->pending_mid_q) { -+ mid_entry = list_entry(tmp, struct -+ mid_q_entry, -+ qhead); -+ -+ if ((mid_entry->mid == smb_buffer->Mid) && (mid_entry->midState == MID_REQUEST_SUBMITTED)) { -+ cFYI(1, -+ (" Mid 0x%x matched - waking up ",mid_entry->mid)); -+ task_to_wake = mid_entry->tsk; -+ mid_entry->resp_buf = -+ smb_buffer; -+ mid_entry->midState = -+ MID_RESPONSE_RECEIVED; -+ } -+ } -+ spin_unlock(&GlobalMid_Lock); -+ if (task_to_wake) { -+ smb_buffer = NULL; /* will be freed by users thread after he is done */ -+ wake_up_process(task_to_wake); -+ } else if (is_valid_oplock_break(smb_buffer) == FALSE) { -+ cERROR(1, ("No task to wake, unknown frame rcvd!")); -+ cifs_dump_mem("Received Data is: ",temp,sizeof(struct smb_hdr)); -+ } -+ } -+ } else { -+ cFYI(0, -+ ("Frame less than four bytes received %d bytes long.", -+ length)); -+ if (length > 0) { -+ length = sock_recvmsg(csocket, &smb_msg, length, 0); /* throw away junk frame */ -+ cFYI(1, -+ (" with junk 0x%x in it ", -+ *(__u32 *) smb_buffer)); -+ } -+ } -+ } -+ spin_lock(&GlobalMid_Lock); -+ server->tcpStatus = CifsExiting; -+ server->tsk = NULL; -+ atomic_set(&server->inFlight, 0); -+ spin_unlock(&GlobalMid_Lock); -+ /* Although there should not be any requests blocked on -+ this queue it can not hurt to be paranoid and try to wake up requests -+ that may haven been blocked when more than 50 at time were on the wire -+ to the same server - they now will see the session is in exit state -+ and get out of SendReceive. */ -+ wake_up_all(&server->request_q); -+ /* give those requests time to exit */ -+ set_current_state(TASK_INTERRUPTIBLE); -+ schedule_timeout(HZ/8); -+ -+ if(server->ssocket) { -+ sock_release(csocket); -+ server->ssocket = NULL; -+ } -+ set_fs(temp_fs); -+ if (smb_buffer) /* buffer usually freed in free_mid - need to free it on error or exit */ -+ cifs_buf_release(smb_buffer); -+ -+ read_lock(&GlobalSMBSeslock); -+ if (list_empty(&server->pending_mid_q)) { -+ /* loop through server session structures attached to this and mark them dead */ -+ list_for_each(tmp, &GlobalSMBSessionList) { -+ ses = -+ list_entry(tmp, struct cifsSesInfo, -+ cifsSessionList); -+ if (ses->server == server) { -+ ses->status = CifsExiting; -+ ses->server = NULL; -+ } -+ } -+ read_unlock(&GlobalSMBSeslock); -+ } else { -+ spin_lock(&GlobalMid_Lock); -+ list_for_each(tmp, &server->pending_mid_q) { -+ mid_entry = list_entry(tmp, struct mid_q_entry, qhead); -+ if (mid_entry->midState == MID_REQUEST_SUBMITTED) { -+ cFYI(1, -+ (" Clearing Mid 0x%x - waking up ",mid_entry->mid)); -+ task_to_wake = mid_entry->tsk; -+ if(task_to_wake) { -+ wake_up_process(task_to_wake); -+ } -+ } -+ } -+ spin_unlock(&GlobalMid_Lock); -+ read_unlock(&GlobalSMBSeslock); -+ set_current_state(TASK_INTERRUPTIBLE); -+ /* 1/8th of sec is more than enough time for them to exit */ -+ schedule_timeout(HZ/8); -+ } -+ -+ if (list_empty(&server->pending_mid_q)) { -+ /* mpx threads have not exited yet give them -+ at least the smb send timeout time for long ops */ -+ cFYI(1, ("Wait for exit from demultiplex thread")); -+ set_current_state(TASK_INTERRUPTIBLE); -+ schedule_timeout(46 * HZ); -+ /* if threads still have not exited they are probably never -+ coming home not much else we can do but free the memory */ -+ } -+ kfree(server); -+ -+ set_current_state(TASK_INTERRUPTIBLE); -+ schedule_timeout(HZ/4); -+ return 0; -+} -+ -+static void * -+cifs_kcalloc(size_t size, int type) -+{ -+ void *addr; -+ addr = kmalloc(size, type); -+ if (addr) -+ memset(addr, 0, size); -+ return addr; -+} -+ -+static int -+cifs_parse_mount_options(char *options, const char *devname, struct smb_vol *vol) -+{ -+ char *value; -+ char *data; -+ unsigned int temp_len, i, j; -+ char separator[2]; -+ -+ separator[0] = ','; -+ separator[1] = 0; -+ -+ memset(vol->source_rfc1001_name,0x20,15); -+ for(i=0;i < strnlen(system_utsname.nodename,15);i++) { -+ /* does not have to be a perfect mapping since the field is -+ informational, only used for servers that do not support -+ port 445 and it can be overridden at mount time */ -+ vol->source_rfc1001_name[i] = toupper(system_utsname.nodename[i]); -+ } -+ vol->source_rfc1001_name[15] = 0; -+ -+ vol->linux_uid = current->uid; /* current->euid instead? */ -+ vol->linux_gid = current->gid; -+ vol->dir_mode = S_IRWXUGO; -+ /* 2767 perms indicate mandatory locking support */ -+ vol->file_mode = S_IALLUGO & ~(S_ISUID | S_IXGRP); -+ -+ /* vol->retry default is 0 (i.e. "soft" limited retry not hard retry) */ -+ vol->rw = TRUE; -+ -+ if (!options) -+ return 1; -+ -+ if(strncmp(options,"sep=",4) == 0) { -+ if(options[4] != 0) { -+ separator[0] = options[4]; -+ options += 5; -+ } else { -+ cFYI(1,("Null separator not allowed")); -+ } -+ } -+ -+ while ((data = strsep(&options, separator)) != NULL) { -+ if (!*data) -+ continue; -+ if ((value = strchr(data, '=')) != NULL) -+ *value++ = '\0'; -+ if (strnicmp(data, "user", 4) == 0) { -+ if (!value || !*value) { -+ printk(KERN_WARNING -+ "CIFS: invalid or missing username\n"); -+ return 1; /* needs_arg; */ -+ } -+ if (strnlen(value, 200) < 200) { -+ vol->username = value; -+ } else { -+ printk(KERN_WARNING "CIFS: username too long\n"); -+ return 1; -+ } -+ } else if (strnicmp(data, "pass", 4) == 0) { -+ if (!value || !*value) { -+ vol->password = NULL; -+ continue; -+ } -+ temp_len = strlen(value); -+ /* removed password length check, NTLM passwords -+ can be arbitrarily long */ -+ -+ /* if comma in password, the string will be -+ prematurely null terminated. Commas in password are -+ specified across the cifs mount interface by a double -+ comma ie ,, and a comma used as in other cases ie ',' -+ as a parameter delimiter/separator is single and due -+ to the strsep above is temporarily zeroed. */ -+ -+ /* NB: password legally can have multiple commas and -+ the only illegal character in a password is null */ -+ -+ if ((value[temp_len] == 0) && (value[temp_len+1] == separator[0])) { -+ /* reinsert comma */ -+ value[temp_len] = separator[0]; -+ temp_len+=2; /* move after the second comma */ -+ while(value[temp_len] != 0) { -+ if((value[temp_len] == separator[0]) && (value[temp_len+1] != separator[0])) { -+ /* single comma indicating start of next parm */ -+ break; -+ } -+ temp_len++; -+ } -+ if(value[temp_len] == 0) { -+ options = NULL; -+ } else { -+ value[temp_len] = 0; -+ /* move options to point to start of next parm */ -+ options = value + temp_len + 1; -+ } -+ /* go from value to (value + temp_len) condensing double commas to singles */ -+ vol->password = cifs_kcalloc(temp_len, GFP_KERNEL); -+ for(i=0,j=0;i<temp_len;i++,j++) { -+ vol->password[j] = value[i]; -+ if(value[i] == separator[0] && value[i+1] == separator[0]) { -+ /* skip second comma */ -+ i++; -+ } -+ } -+ /* value[temp_len] is zeroed above so -+ vol->password[temp_len] guaranteed to be null */ -+ } else { -+ vol->password = cifs_kcalloc(temp_len + 1, GFP_KERNEL); -+ strcpy(vol->password, value); -+ } -+ } else if (strnicmp(data, "ip", 2) == 0) { -+ if (!value || !*value) { -+ vol->UNCip = NULL; -+ } else if (strnlen(value, 35) < 35) { -+ vol->UNCip = value; -+ } else { -+ printk(KERN_WARNING "CIFS: ip address too long\n"); -+ return 1; -+ } -+ } else if ((strnicmp(data, "unc", 3) == 0) -+ || (strnicmp(data, "target", 6) == 0) -+ || (strnicmp(data, "path", 4) == 0)) { -+ if (!value || !*value) { -+ printk(KERN_WARNING -+ "CIFS: invalid path to network resource\n"); -+ return 1; /* needs_arg; */ -+ } -+ if ((temp_len = strnlen(value, 300)) < 300) { -+ vol->UNC = kmalloc(temp_len+1,GFP_KERNEL); -+ if(vol->UNC == NULL) -+ return 1; -+ strcpy(vol->UNC,value); -+ if (strncmp(vol->UNC, "//", 2) == 0) { -+ vol->UNC[0] = '\\'; -+ vol->UNC[1] = '\\'; -+ } else if (strncmp(vol->UNC, "\\\\", 2) != 0) { -+ printk(KERN_WARNING -+ "CIFS: UNC Path does not begin with // or \\\\ \n"); -+ return 1; -+ } -+ } else { -+ printk(KERN_WARNING "CIFS: UNC name too long\n"); -+ return 1; -+ } -+ } else if ((strnicmp(data, "domain", 3) == 0) -+ || (strnicmp(data, "workgroup", 5) == 0)) { -+ if (!value || !*value) { -+ printk(KERN_WARNING "CIFS: invalid domain name\n"); -+ return 1; /* needs_arg; */ -+ } -+ /* BB are there cases in which a comma can be valid in -+ a domain name and need special handling? */ -+ if (strnlen(value, 65) < 65) { -+ vol->domainname = value; -+ cFYI(1, ("Domain name set")); -+ } else { -+ printk(KERN_WARNING "CIFS: domain name too long\n"); -+ return 1; -+ } -+ } else if (strnicmp(data, "iocharset", 9) == 0) { -+ if (!value || !*value) { -+ printk(KERN_WARNING "CIFS: invalid iocharset specified\n"); -+ return 1; /* needs_arg; */ -+ } -+ if (strnlen(value, 65) < 65) { -+ if(strnicmp(value,"default",7)) -+ vol->iocharset = value; -+ /* if iocharset not set load_nls_default used by caller */ -+ cFYI(1, ("iocharset set to %s",value)); -+ } else { -+ printk(KERN_WARNING "CIFS: iocharset name too long.\n"); -+ return 1; -+ } -+ } else if (strnicmp(data, "uid", 3) == 0) { -+ if (value && *value) { -+ vol->linux_uid = -+ simple_strtoul(value, &value, 0); -+ } -+ } else if (strnicmp(data, "gid", 3) == 0) { -+ if (value && *value) { -+ vol->linux_gid = -+ simple_strtoul(value, &value, 0); -+ } -+ } else if (strnicmp(data, "file_mode", 4) == 0) { -+ if (value && *value) { -+ vol->file_mode = -+ simple_strtoul(value, &value, 0); -+ } -+ } else if (strnicmp(data, "dir_mode", 3) == 0) { -+ if (value && *value) { -+ vol->dir_mode = -+ simple_strtoul(value, &value, 0); -+ } -+ } else if (strnicmp(data, "port", 4) == 0) { -+ if (value && *value) { -+ vol->port = -+ simple_strtoul(value, &value, 0); -+ } -+ } else if (strnicmp(data, "rsize", 5) == 0) { -+ if (value && *value) { -+ vol->rsize = -+ simple_strtoul(value, &value, 0); -+ } -+ } else if (strnicmp(data, "wsize", 5) == 0) { -+ if (value && *value) { -+ vol->wsize = -+ simple_strtoul(value, &value, 0); -+ } -+ } else if (strnicmp(data, "sockopt", 5) == 0) { -+ if (value && *value) { -+ vol->sockopt = -+ simple_strtoul(value, &value, 0); -+ } -+ } else if (strnicmp(data, "netbiosname", 4) == 0) { -+ if (!value || !*value || (*value == ' ')) { -+ cFYI(1,("invalid (empty) netbiosname specified")); -+ } else { -+ memset(vol->source_rfc1001_name,0x20,15); -+ for(i=0;i<15;i++) { -+ /* BB are there cases in which a comma can be -+ valid in this workstation netbios name (and need -+ special handling)? */ -+ -+ /* We do not uppercase netbiosname for user */ -+ if (value[i]==0) -+ break; -+ else -+ vol->source_rfc1001_name[i] = value[i]; -+ } -+ /* The string has 16th byte zero still from -+ set at top of the function */ -+ if((i==15) && (value[i] != 0)) -+ printk(KERN_WARNING "CIFS: netbiosname longer than 15 and was truncated.\n"); -+ } -+ } else if (strnicmp(data, "credentials", 4) == 0) { -+ /* ignore */ -+ } else if (strnicmp(data, "version", 3) == 0) { -+ /* ignore */ -+ } else if (strnicmp(data, "rw", 2) == 0) { -+ vol->rw = TRUE; -+ } else if ((strnicmp(data, "suid", 4) == 0) || -+ (strnicmp(data, "nosuid", 6) == 0) || -+ (strnicmp(data, "exec", 4) == 0) || -+ (strnicmp(data, "noexec", 6) == 0) || -+ (strnicmp(data, "nodev", 5) == 0) || -+ (strnicmp(data, "noauto", 6) == 0) || -+ (strnicmp(data, "dev", 3) == 0)) { -+ /* The mount tool or mount.cifs helper (if present) -+ uses these opts to set flags, and the flags are read -+ by the kernel vfs layer before we get here (ie -+ before read super) so there is no point trying to -+ parse these options again and set anything and it -+ is ok to just ignore them */ -+ continue; -+ } else if (strnicmp(data, "ro", 2) == 0) { -+ vol->rw = FALSE; -+ } else if (strnicmp(data, "hard", 4) == 0) { -+ vol->retry = 1; -+ } else if (strnicmp(data, "soft", 4) == 0) { -+ vol->retry = 0; -+ } else if (strnicmp(data, "nohard", 6) == 0) { -+ vol->retry = 0; -+ } else if (strnicmp(data, "nosoft", 6) == 0) { -+ vol->retry = 1; -+ } else if (strnicmp(data, "nointr", 6) == 0) { -+ vol->intr = 0; -+ } else if (strnicmp(data, "intr", 4) == 0) { -+ vol->intr = 1; -+ } else if (strnicmp(data, "noac", 4) == 0) { -+ printk(KERN_WARNING "CIFS: Mount option noac not supported. Instead set /proc/fs/cifs/LookupCacheEnabled to 0\n"); -+ } else -+ printk(KERN_WARNING "CIFS: Unknown mount option %s\n",data); -+ } -+ if (vol->UNC == NULL) { -+ if(devname == NULL) { -+ printk(KERN_WARNING "CIFS: Missing UNC name for mount target\n"); -+ return 1; -+ } -+ if ((temp_len = strnlen(devname, 300)) < 300) { -+ vol->UNC = kmalloc(temp_len+1,GFP_KERNEL); -+ if(vol->UNC == NULL) -+ return 1; -+ strcpy(vol->UNC,devname); -+ if (strncmp(vol->UNC, "//", 2) == 0) { -+ vol->UNC[0] = '\\'; -+ vol->UNC[1] = '\\'; -+ } else if (strncmp(vol->UNC, "\\\\", 2) != 0) { -+ printk(KERN_WARNING "CIFS: UNC Path does not begin with // or \\\\ \n"); -+ return 1; -+ } -+ } else { -+ printk(KERN_WARNING "CIFS: UNC name too long\n"); -+ return 1; -+ } -+ } -+ if(vol->UNCip == 0) -+ vol->UNCip = &vol->UNC[2]; -+ -+ return 0; -+} -+ -+static struct cifsSesInfo * -+cifs_find_tcp_session(__u32 new_target_ip_addr, -+ char *userName, struct TCP_Server_Info **psrvTcp) -+{ -+ struct list_head *tmp; -+ struct cifsSesInfo *ses; -+ -+ *psrvTcp = NULL; -+ read_lock(&GlobalSMBSeslock); -+ list_for_each(tmp, &GlobalSMBSessionList) { -+ ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); -+ if (ses->server) { -+ if (ses->server->addr.sockAddr.sin_addr.s_addr == -+ new_target_ip_addr) { -+ /* BB lock server and tcp session and increment use count here?? */ -+ *psrvTcp = ses->server; /* found a match on the TCP session */ -+ /* BB check if reconnection needed */ -+ if (strncmp -+ (ses->userName, userName, -+ MAX_USERNAME_SIZE) == 0){ -+ read_unlock(&GlobalSMBSeslock); -+ return ses; /* found exact match on both tcp and SMB sessions */ -+ } -+ } -+ } -+ /* else tcp and smb sessions need reconnection */ -+ } -+ read_unlock(&GlobalSMBSeslock); -+ return NULL; -+} -+ -+static struct cifsTconInfo * -+find_unc(__u32 new_target_ip_addr, char *uncName, char *userName) -+{ -+ struct list_head *tmp; -+ struct cifsTconInfo *tcon; -+ -+ read_lock(&GlobalSMBSeslock); -+ list_for_each(tmp, &GlobalTreeConnectionList) { -+ cFYI(1, ("Next tcon - ")); -+ tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); -+ if (tcon->ses) { -+ if (tcon->ses->server) { -+ cFYI(1, -+ (" old ip addr: %x == new ip %x ?", -+ tcon->ses->server->addr.sockAddr.sin_addr. -+ s_addr, new_target_ip_addr)); -+ if (tcon->ses->server->addr.sockAddr.sin_addr. -+ s_addr == new_target_ip_addr) { -+ /* BB lock tcon and server and tcp session and increment use count here? */ -+ /* found a match on the TCP session */ -+ /* BB check if reconnection needed */ -+ cFYI(1,("Matched ip, old UNC: %s == new: %s ?", -+ tcon->treeName, uncName)); -+ if (strncmp -+ (tcon->treeName, uncName, -+ MAX_TREE_SIZE) == 0) { -+ cFYI(1, -+ ("Matched UNC, old user: %s == new: %s ?", -+ tcon->treeName, uncName)); -+ if (strncmp -+ (tcon->ses->userName, -+ userName, -+ MAX_USERNAME_SIZE) == 0) { -+ read_unlock(&GlobalSMBSeslock); -+ return tcon;/* also matched user (smb session)*/ -+ } -+ } -+ } -+ } -+ } -+ } -+ read_unlock(&GlobalSMBSeslock); -+ return NULL; -+} -+ -+int -+connect_to_dfs_path(int xid, struct cifsSesInfo *pSesInfo, -+ const char *old_path, const struct nls_table *nls_codepage) -+{ -+ unsigned char *referrals = NULL; -+ unsigned int num_referrals; -+ int rc = 0; -+ -+ rc = get_dfs_path(xid, pSesInfo,old_path, nls_codepage, -+ &num_referrals, &referrals); -+ -+ /* BB Add in code to: if valid refrl, if not ip address contact -+ the helper that resolves tcp names, mount to it, try to -+ tcon to it unmount it if fail */ -+ -+ if(referrals) -+ kfree(referrals); -+ -+ return rc; -+} -+ -+int -+get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, -+ const char *old_path, const struct nls_table *nls_codepage, -+ unsigned int *pnum_referrals, unsigned char ** preferrals) -+{ -+ char *temp_unc; -+ int rc = 0; -+ -+ *pnum_referrals = 0; -+ -+ if (pSesInfo->ipc_tid == 0) { -+ temp_unc = kmalloc(2 /* for slashes */ + -+ strnlen(pSesInfo->serverName,SERVER_NAME_LEN_WITH_NULL * 2) -+ + 1 + 4 /* slash IPC$ */ + 2, -+ GFP_KERNEL); -+ if (temp_unc == NULL) -+ return -ENOMEM; -+ temp_unc[0] = '\\'; -+ temp_unc[1] = '\\'; -+ strcpy(temp_unc + 2, pSesInfo->serverName); -+ strcpy(temp_unc + 2 + strlen(pSesInfo->serverName), "\\IPC$"); -+ rc = CIFSTCon(xid, pSesInfo, temp_unc, NULL, nls_codepage); -+ cFYI(1, -+ ("CIFS Tcon rc = %d ipc_tid = %d", rc,pSesInfo->ipc_tid)); -+ kfree(temp_unc); -+ } -+ if (rc == 0) -+ rc = CIFSGetDFSRefer(xid, pSesInfo, old_path, preferrals, -+ pnum_referrals, nls_codepage); -+ -+ return rc; -+} -+ -+/* See RFC1001 section 14 on representation of Netbios names */ -+static void rfc1002mangle(char * target,char * source, unsigned int length) -+{ -+ unsigned int i,j; -+ -+ for(i=0,j=0;i<(length);i++) { -+ /* mask a nibble at a time and encode */ -+ target[j] = 'A' + (0x0F & (source[i] >> 4)); -+ target[j+1] = 'A' + (0x0F & source[i]); -+ j+=2; -+ } -+ -+} -+ -+ -+static int -+ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, -+ char * netbios_name) -+{ -+ int rc = 0; -+ int connected = 0; -+ unsigned short int orig_port = 0; -+ -+ if(*csocket == NULL) { -+ rc = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, csocket); -+ if (rc < 0) { -+ cERROR(1, ("Error %d creating socket",rc)); -+ *csocket = NULL; -+ return rc; -+ } else { -+ /* BB other socket options to set KEEPALIVE, NODELAY? */ -+ cFYI(1,("Socket created")); -+ (*csocket)->sk->allocation = GFP_NOFS; -+ } -+ } -+ -+ psin_server->sin_family = AF_INET; -+ if(psin_server->sin_port) { /* user overrode default port */ -+ rc = (*csocket)->ops->connect(*csocket, -+ (struct sockaddr *) psin_server, -+ sizeof (struct sockaddr_in),0); -+ if (rc >= 0) -+ connected = 1; -+ } -+ -+ if(!connected) { -+ /* save original port so we can retry user specified port -+ later if fall back ports fail this time */ -+ orig_port = psin_server->sin_port; -+ -+ /* do not retry on the same port we just failed on */ -+ if(psin_server->sin_port != htons(CIFS_PORT)) { -+ psin_server->sin_port = htons(CIFS_PORT); -+ -+ rc = (*csocket)->ops->connect(*csocket, -+ (struct sockaddr *) psin_server, -+ sizeof (struct sockaddr_in),0); -+ if (rc >= 0) -+ connected = 1; -+ } -+ } -+ if (!connected) { -+ psin_server->sin_port = htons(RFC1001_PORT); -+ rc = (*csocket)->ops->connect(*csocket, (struct sockaddr *) -+ psin_server, sizeof (struct sockaddr_in),0); -+ if (rc >= 0) -+ connected = 1; -+ } -+ -+ /* give up here - unless we want to retry on different -+ protocol families some day */ -+ if (!connected) { -+ if(orig_port) -+ psin_server->sin_port = orig_port; -+ cFYI(1,("Error %d connecting to server via ipv4",rc)); -+ sock_release(*csocket); -+ *csocket = NULL; -+ return rc; -+ } -+ /* Eventually check for other socket options to change from -+ the default. sock_setsockopt not used because it expects -+ user space buffer */ -+ (*csocket)->sk->rcvtimeo = 7 * HZ; -+ -+ /* send RFC1001 sessinit */ -+ -+ if(psin_server->sin_port == htons(139)) { -+ /* some servers require RFC1001 sessinit before sending -+ negprot - BB check reconnection in case where second -+ sessinit is sent but no second negprot */ -+ struct rfc1002_session_packet * ses_init_buf; -+ struct smb_hdr * smb_buf; -+ ses_init_buf = cifs_kcalloc(sizeof(struct rfc1002_session_packet), GFP_KERNEL); -+ if(ses_init_buf) { -+ ses_init_buf->trailer.session_req.called_len = 32; -+ rfc1002mangle(ses_init_buf->trailer.session_req.called_name, -+ DEFAULT_CIFS_CALLED_NAME,16); -+ ses_init_buf->trailer.session_req.calling_len = 32; -+ /* calling name ends in null (byte 16) from old smb -+ convention. */ -+ if(netbios_name && (netbios_name[0] !=0)) { -+ rfc1002mangle(ses_init_buf->trailer.session_req.calling_name, -+ netbios_name,16); -+ } else { -+ rfc1002mangle(ses_init_buf->trailer.session_req.calling_name, -+ "LINUX_CIFS_CLNT",16); -+ } -+ ses_init_buf->trailer.session_req.scope1 = 0; -+ ses_init_buf->trailer.session_req.scope2 = 0; -+ smb_buf = (struct smb_hdr *)ses_init_buf; -+ /* sizeof RFC1002_SESSION_REQUEST with no scope */ -+ smb_buf->smb_buf_length = 0x81000044; -+ rc = smb_send(*csocket, smb_buf, 0x44, -+ (struct sockaddr *)psin_server); -+ kfree(ses_init_buf); -+ } -+ /* else the negprot may still work without this -+ even though malloc failed */ -+ -+ } -+ -+ return rc; -+} -+ -+static int -+ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket) -+{ -+ int rc = 0; -+ int connected = 0; -+ -+ if(*csocket == NULL) { -+ rc = sock_create(PF_INET6, SOCK_STREAM, IPPROTO_TCP, csocket); -+ if (rc < 0) { -+ cERROR(1, ("Error %d creating ipv6 socket",rc)); -+ *csocket = NULL; -+ return rc; -+ } else { -+ /* BB other socket options to set KEEPALIVE, NODELAY? */ -+ cFYI(1,("ipv6 Socket created")); -+ (*csocket)->sk->allocation = GFP_NOFS; -+ } -+ } -+ -+ psin_server->sin6_family = AF_INET6; -+ -+ if(psin_server->sin6_port) { /* user overrode default port */ -+ rc = (*csocket)->ops->connect(*csocket, -+ (struct sockaddr *) psin_server, -+ sizeof (struct sockaddr_in6),0); -+ if (rc >= 0) -+ connected = 1; -+ } -+ -+ if(!connected) { -+ /* do not retry on the same port we just failed on */ -+ if(psin_server->sin6_port != htons(CIFS_PORT)) { -+ psin_server->sin6_port = htons(CIFS_PORT); -+ -+ rc = (*csocket)->ops->connect(*csocket, -+ (struct sockaddr *) psin_server, -+ sizeof (struct sockaddr_in6),0); -+ if (rc >= 0) -+ connected = 1; -+ } -+ } -+ if (!connected) { -+ psin_server->sin6_port = htons(RFC1001_PORT); -+ rc = (*csocket)->ops->connect(*csocket, (struct sockaddr *) -+ psin_server, sizeof (struct sockaddr_in6),0); -+ if (rc >= 0) -+ connected = 1; -+ } -+ -+ /* give up here - unless we want to retry on different -+ protocol families some day */ -+ if (!connected) { -+ cFYI(1,("Error %d connecting to server via ipv6",rc)); -+ sock_release(*csocket); -+ *csocket = NULL; -+ return rc; -+ } -+ /* Eventually check for other socket options to change from -+ the default. sock_setsockopt not used because it expects -+ user space buffer */ -+ (*csocket)->sk->rcvtimeo = 7 * HZ; -+ -+ return rc; -+} -+ -+int -+cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, -+ char *mount_data, const char *devname) -+{ -+ int rc = 0; -+ int xid; -+ struct socket *csocket = NULL; -+ struct sockaddr_in sin_server; -+ struct sockaddr_in6 sin_server6; -+ struct smb_vol volume_info; -+ struct cifsSesInfo *pSesInfo = NULL; -+ struct cifsSesInfo *existingCifsSes = NULL; -+ struct cifsTconInfo *tcon = NULL; -+ struct TCP_Server_Info *srvTcp = NULL; -+ -+ xid = GetXid(); -+ -+ cFYI(1, ("Entering cifs_mount. Xid: %d with: %s", xid, mount_data)); /* BB removeme BB fixme */ -+ -+ memset(&volume_info,0,sizeof(struct smb_vol)); -+ if (cifs_parse_mount_options(mount_data, devname, &volume_info)) { -+ if(volume_info.UNC) -+ kfree(volume_info.UNC); -+ if(volume_info.password) -+ kfree(volume_info.password); -+ FreeXid(xid); -+ return -EINVAL; -+ } -+ -+ if (volume_info.username) { -+ cFYI(1, ("Username: %s ", volume_info.username)); -+ -+ } else { -+ cifserror("No username specified "); -+ /* In userspace mount helper we can get user name from alternate -+ locations such as env variables and files on disk */ -+ if(volume_info.UNC) -+ kfree(volume_info.UNC); -+ if(volume_info.password) -+ kfree(volume_info.password); -+ FreeXid(xid); -+ return -EINVAL; -+ } -+ -+ if (volume_info.UNCip && volume_info.UNC) { -+ rc = cifs_inet_pton(AF_INET, volume_info.UNCip,&sin_server.sin_addr.s_addr); -+ -+ if(rc == 0) { -+ /* not ipv4 address, try ipv6 */ -+ rc = cifs_inet_pton(AF_INET6,volume_info.UNCip,&sin_server6.sin6_addr.in6_u); -+ } -+ -+ if(rc != 1) { -+ /* we failed translating address */ -+ if(volume_info.UNC) -+ kfree(volume_info.UNC); -+ if(volume_info.password) -+ kfree(volume_info.password); -+ FreeXid(xid); -+ return -EINVAL; -+ } -+ -+ cFYI(1, ("UNC: %s ip: %s", volume_info.UNC, volume_info.UNCip)); -+ /* success */ -+ rc = 0; -+ } else if (volume_info.UNCip){ -+ /* BB using ip addr as server name connect to the DFS root below */ -+ cERROR(1,("Connecting to DFS root not implemented yet")); -+ if(volume_info.UNC) -+ kfree(volume_info.UNC); -+ if(volume_info.password) -+ kfree(volume_info.password); -+ FreeXid(xid); -+ return -EINVAL; -+ } else /* which servers DFS root would we conect to */ { -+ cERROR(1, -+ ("CIFS mount error: No UNC path (e.g. -o unc=//192.168.1.100/public) specified ")); -+ if(volume_info.UNC) -+ kfree(volume_info.UNC); -+ if(volume_info.password) -+ kfree(volume_info.password); -+ FreeXid(xid); -+ return -EINVAL; -+ } -+ -+ /* this is needed for ASCII cp to Unicode converts */ -+ if(volume_info.iocharset == NULL) { -+ cifs_sb->local_nls = load_nls_default(); -+ /* load_nls_default can not return null */ -+ } else { -+ cifs_sb->local_nls = load_nls(volume_info.iocharset); -+ if(cifs_sb->local_nls == NULL) { -+ cERROR(1,("CIFS mount error: iocharset %s not found",volume_info.iocharset)); -+ if(volume_info.UNC) -+ kfree(volume_info.UNC); -+ if(volume_info.password) -+ kfree(volume_info.password); -+ FreeXid(xid); -+ return -ELIBACC; -+ } -+ } -+ -+ existingCifsSes = -+ cifs_find_tcp_session(sin_server.sin_addr.s_addr, -+ volume_info.username, &srvTcp); -+ if (srvTcp) { -+ cFYI(1, ("Existing tcp session with server found ")); -+ } else { /* create socket */ -+ if(volume_info.port) -+ sin_server.sin_port = htons(volume_info.port); -+ else -+ sin_server.sin_port = 0; -+ rc = ipv4_connect(&sin_server,&csocket,volume_info.source_rfc1001_name); -+ if (rc < 0) { -+ cERROR(1, -+ ("Error connecting to IPv4 socket. Aborting operation")); -+ if(csocket != NULL) -+ sock_release(csocket); -+ if(volume_info.UNC) -+ kfree(volume_info.UNC); -+ if(volume_info.password) -+ kfree(volume_info.password); -+ FreeXid(xid); -+ return rc; -+ } -+ -+ srvTcp = kmalloc(sizeof (struct TCP_Server_Info), GFP_KERNEL); -+ if (srvTcp == NULL) { -+ rc = -ENOMEM; -+ sock_release(csocket); -+ if(volume_info.UNC) -+ kfree(volume_info.UNC); -+ if(volume_info.password) -+ kfree(volume_info.password); -+ FreeXid(xid); -+ return rc; -+ } else { -+ memset(srvTcp, 0, sizeof (struct TCP_Server_Info)); -+ memcpy(&srvTcp->addr.sockAddr, &sin_server, sizeof (struct sockaddr_in)); -+ atomic_set(&srvTcp->inFlight,0); -+ /* BB Add code for ipv6 case too */ -+ srvTcp->ssocket = csocket; -+ srvTcp->protocolType = IPV4; -+ init_waitqueue_head(&srvTcp->response_q); -+ init_waitqueue_head(&srvTcp->request_q); -+ INIT_LIST_HEAD(&srvTcp->pending_mid_q); -+ /* at this point we are the only ones with the pointer -+ to the struct since the kernel thread not created yet -+ so no need to spinlock this init of tcpStatus */ -+ srvTcp->tcpStatus = CifsNew; -+ init_MUTEX(&srvTcp->tcpSem); -+ kernel_thread((void *)(void *)cifs_demultiplex_thread, srvTcp, -+ CLONE_FS | CLONE_FILES | CLONE_VM); -+ memcpy(srvTcp->workstation_RFC1001_name, volume_info.source_rfc1001_name,16); -+ } -+ } -+ -+ if (existingCifsSes) { -+ pSesInfo = existingCifsSes; -+ cFYI(1, ("Existing smb sess found ")); -+ if(volume_info.password) -+ kfree(volume_info.password); -+ /* volume_info.UNC freed at end of function */ -+ } else if (!rc) { -+ cFYI(1, ("Existing smb sess not found ")); -+ pSesInfo = sesInfoAlloc(); -+ if (pSesInfo == NULL) -+ rc = -ENOMEM; -+ else { -+ pSesInfo->server = srvTcp; -+ sprintf(pSesInfo->serverName, "%u.%u.%u.%u", -+ NIPQUAD(sin_server.sin_addr.s_addr)); -+ } -+ -+ if (!rc){ -+ /* volume_info.password freed at unmount */ -+ if (volume_info.password) -+ pSesInfo->password = volume_info.password; -+ if (volume_info.username) -+ strncpy(pSesInfo->userName, -+ volume_info.username,MAX_USERNAME_SIZE); -+ if (volume_info.domainname) -+ strncpy(pSesInfo->domainName, -+ volume_info.domainname,MAX_USERNAME_SIZE); -+ pSesInfo->linux_uid = volume_info.linux_uid; -+ down(&pSesInfo->sesSem); -+ rc = cifs_setup_session(xid,pSesInfo, cifs_sb->local_nls); -+ up(&pSesInfo->sesSem); -+ if(!rc) -+ atomic_inc(&srvTcp->socketUseCount); -+ } else -+ if(volume_info.password) -+ kfree(volume_info.password); -+ } -+ -+ /* search for existing tcon to this server share */ -+ if (!rc) { -+ if((volume_info.rsize) && (volume_info.rsize + MAX_CIFS_HDR_SIZE < srvTcp->maxBuf)) -+ cifs_sb->rsize = volume_info.rsize; -+ else -+ cifs_sb->rsize = srvTcp->maxBuf - MAX_CIFS_HDR_SIZE; /* default */ -+ if((volume_info.wsize) && (volume_info.wsize + MAX_CIFS_HDR_SIZE < srvTcp->maxBuf)) -+ cifs_sb->wsize = volume_info.wsize; -+ else -+ cifs_sb->wsize = srvTcp->maxBuf - MAX_CIFS_HDR_SIZE; /* default */ -+ if(cifs_sb->rsize < PAGE_CACHE_SIZE) { -+ cifs_sb->rsize = PAGE_CACHE_SIZE; -+ cERROR(1,("Attempt to set readsize for mount to less than one page (4096)")); -+ } -+ cifs_sb->mnt_uid = volume_info.linux_uid; -+ cifs_sb->mnt_gid = volume_info.linux_gid; -+ cifs_sb->mnt_file_mode = volume_info.file_mode; -+ cifs_sb->mnt_dir_mode = volume_info.dir_mode; -+ cFYI(1,("file mode: 0x%x dir mode: 0x%x",cifs_sb->mnt_file_mode,cifs_sb->mnt_dir_mode)); -+ tcon = -+ find_unc(sin_server.sin_addr.s_addr, volume_info.UNC, -+ volume_info.username); -+ if (tcon) { -+ cFYI(1, ("Found match on UNC path ")); -+ /* we can have only one retry value for a connection -+ to a share so for resources mounted more than once -+ to the same server share the last value passed in -+ for the retry flag is used */ -+ tcon->retry = volume_info.retry; -+ } else { -+ tcon = tconInfoAlloc(); -+ if (tcon == NULL) -+ rc = -ENOMEM; -+ else { -+ /* check for null share name ie connect to dfs root */ -+ -+ /* BB check if this works for exactly length three strings */ -+ if ((strchr(volume_info.UNC + 3, '\\') == NULL) -+ && (strchr(volume_info.UNC + 3, '/') == -+ NULL)) { -+ rc = connect_to_dfs_path(xid, -+ pSesInfo, -+ "", -+ cifs_sb-> -+ local_nls); -+ if(volume_info.UNC) -+ kfree(volume_info.UNC); -+ FreeXid(xid); -+ return -ENODEV; -+ } else { -+ rc = CIFSTCon(xid, pSesInfo, -+ volume_info.UNC, -+ tcon, cifs_sb->local_nls); -+ cFYI(1, ("CIFS Tcon rc = %d", rc)); -+ } -+ if (!rc) { -+ atomic_inc(&pSesInfo->inUse); -+ tcon->retry = volume_info.retry; -+ } -+ } -+ } -+ } -+ if(pSesInfo) { -+ if (pSesInfo->capabilities & CAP_LARGE_FILES) { -+ sb->s_maxbytes = (u64) 1 << 63; -+ } else -+ sb->s_maxbytes = (u64) 1 << 31; /* 2 GB */ -+ } -+ -+/* on error free sesinfo and tcon struct if needed */ -+ if (rc) { -+ /* if session setup failed, use count is zero but -+ we still need to free cifsd thread */ -+ if(atomic_read(&srvTcp->socketUseCount) == 0) { -+ spin_lock(&GlobalMid_Lock); -+ srvTcp->tcpStatus = CifsExiting; -+ spin_unlock(&GlobalMid_Lock); -+ if(srvTcp->tsk) -+ send_sig(SIGKILL,srvTcp->tsk,1); -+ } -+ /* If find_unc succeeded then rc == 0 so we can not end */ -+ if (tcon) /* up accidently freeing someone elses tcon struct */ -+ tconInfoFree(tcon); -+ if (existingCifsSes == 0) { -+ if (pSesInfo) { -+ if ((pSesInfo->server) && -+ (pSesInfo->status == CifsGood)) { -+ int temp_rc; -+ temp_rc = CIFSSMBLogoff(xid, pSesInfo); -+ /* if the socketUseCount is now zero */ -+ if((temp_rc == -ESHUTDOWN) && -+ (pSesInfo->server->tsk)) -+ send_sig(SIGKILL,pSesInfo->server->tsk,1); -+ } else -+ cFYI(1, ("No session or bad tcon")); -+ sesInfoFree(pSesInfo); -+ /* pSesInfo = NULL; */ -+ } -+ } -+ } else { -+ atomic_inc(&tcon->useCount); -+ cifs_sb->tcon = tcon; -+ tcon->ses = pSesInfo; -+ -+ /* do not care if following two calls succeed - informational only */ -+ CIFSSMBQFSDeviceInfo(xid, tcon, cifs_sb->local_nls); -+ CIFSSMBQFSAttributeInfo(xid, tcon, cifs_sb->local_nls); -+ if (tcon->ses->capabilities & CAP_UNIX) -+ CIFSSMBQFSUnixInfo(xid, tcon, cifs_sb->local_nls); -+ } -+ -+ /* volume_info.password is freed above when existing session found -+ (in which case it is not needed anymore) but when new sesion is created -+ the password ptr is put in the new session structure (in which case the -+ password will be freed at unmount time) */ -+ if(volume_info.UNC) -+ kfree(volume_info.UNC); -+ FreeXid(xid); -+ return rc; -+} -+ -+static int -+CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, -+ char session_key[CIFS_SESSION_KEY_SIZE], -+ const struct nls_table *nls_codepage) -+{ -+ struct smb_hdr *smb_buffer; -+ struct smb_hdr *smb_buffer_response; -+ SESSION_SETUP_ANDX *pSMB; -+ SESSION_SETUP_ANDX *pSMBr; -+ char *bcc_ptr; -+ char *user = ses->userName; -+ char *domain = ses->domainName; -+ int rc = 0; -+ int remaining_words = 0; -+ int bytes_returned = 0; -+ int len; -+ -+ cFYI(1, ("In sesssetup ")); -+ -+ smb_buffer = cifs_buf_get(); -+ if (smb_buffer == 0) { -+ return -ENOMEM; -+ } -+ smb_buffer_response = smb_buffer; -+ pSMBr = pSMB = (SESSION_SETUP_ANDX *) smb_buffer; -+ -+ /* send SMBsessionSetup here */ -+ header_assemble(smb_buffer, SMB_COM_SESSION_SETUP_ANDX, -+ NULL /* no tCon exists yet */ , 13 /* wct */ ); -+ -+ pSMB->req_no_secext.AndXCommand = 0xFF; -+ pSMB->req_no_secext.MaxBufferSize = cpu_to_le16(ses->server->maxBuf); -+ pSMB->req_no_secext.MaxMpxCount = cpu_to_le16(ses->server->maxReq); -+ -+ if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) -+ smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; -+ -+ pSMB->req_no_secext.Capabilities = -+ CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS; -+ if (ses->capabilities & CAP_UNICODE) { -+ smb_buffer->Flags2 |= SMBFLG2_UNICODE; -+ pSMB->req_no_secext.Capabilities |= CAP_UNICODE; -+ } -+ if (ses->capabilities & CAP_STATUS32) { -+ smb_buffer->Flags2 |= SMBFLG2_ERR_STATUS; -+ pSMB->req_no_secext.Capabilities |= CAP_STATUS32; -+ } -+ if (ses->capabilities & CAP_DFS) { -+ smb_buffer->Flags2 |= SMBFLG2_DFS; -+ pSMB->req_no_secext.Capabilities |= CAP_DFS; -+ } -+ pSMB->req_no_secext.Capabilities = -+ cpu_to_le32(pSMB->req_no_secext.Capabilities); -+ /* pSMB->req_no_secext.CaseInsensitivePasswordLength = -+ CIFS_SESSION_KEY_SIZE; */ -+ pSMB->req_no_secext.CaseInsensitivePasswordLength = 0; -+ pSMB->req_no_secext.CaseSensitivePasswordLength = -+ cpu_to_le16(CIFS_SESSION_KEY_SIZE); -+ bcc_ptr = pByteArea(smb_buffer); -+ /* memcpy(bcc_ptr, (char *) lm_session_key, CIFS_SESSION_KEY_SIZE); -+ bcc_ptr += CIFS_SESSION_KEY_SIZE; */ -+ memcpy(bcc_ptr, (char *) session_key, CIFS_SESSION_KEY_SIZE); -+ bcc_ptr += CIFS_SESSION_KEY_SIZE; -+ -+ if (ses->capabilities & CAP_UNICODE) { -+ if ((long) bcc_ptr % 2) { /* must be word aligned for Unicode */ -+ *bcc_ptr = 0; -+ bcc_ptr++; -+ } -+ if(user == NULL) -+ bytes_returned = 0; /* skill null user */ -+ else -+ bytes_returned = -+ cifs_strtoUCS((wchar_t *) bcc_ptr, user, 100, -+ nls_codepage); -+ bcc_ptr += 2 * bytes_returned; /* convert num 16 bit words to bytes */ -+ bcc_ptr += 2; /* trailing null */ -+ if (domain == NULL) -+ bytes_returned = -+ cifs_strtoUCS((wchar_t *) bcc_ptr, -+ "CIFS_LINUX_DOM", 32, nls_codepage); -+ else -+ bytes_returned = -+ cifs_strtoUCS((wchar_t *) bcc_ptr, domain, 64, -+ nls_codepage); -+ bcc_ptr += 2 * bytes_returned; -+ bcc_ptr += 2; -+ bytes_returned = -+ cifs_strtoUCS((wchar_t *) bcc_ptr, "Linux version ", -+ 32, nls_codepage); -+ bcc_ptr += 2 * bytes_returned; -+ bytes_returned = -+ cifs_strtoUCS((wchar_t *) bcc_ptr, UTS_RELEASE, 32, -+ nls_codepage); -+ bcc_ptr += 2 * bytes_returned; -+ bcc_ptr += 2; -+ bytes_returned = -+ cifs_strtoUCS((wchar_t *) bcc_ptr, CIFS_NETWORK_OPSYS, -+ 64, nls_codepage); -+ bcc_ptr += 2 * bytes_returned; -+ bcc_ptr += 2; -+ } else { -+ if(user != NULL) { -+ strncpy(bcc_ptr, user, 200); -+ bcc_ptr += strnlen(user, 200); -+ } -+ *bcc_ptr = 0; -+ bcc_ptr++; -+ if (domain == NULL) { -+ strcpy(bcc_ptr, "CIFS_LINUX_DOM"); -+ bcc_ptr += strlen("CIFS_LINUX_DOM") + 1; -+ } else { -+ strncpy(bcc_ptr, domain, 64); -+ bcc_ptr += strnlen(domain, 64); -+ *bcc_ptr = 0; -+ bcc_ptr++; -+ } -+ strcpy(bcc_ptr, "Linux version "); -+ bcc_ptr += strlen("Linux version "); -+ strcpy(bcc_ptr, UTS_RELEASE); -+ bcc_ptr += strlen(UTS_RELEASE) + 1; -+ strcpy(bcc_ptr, CIFS_NETWORK_OPSYS); -+ bcc_ptr += strlen(CIFS_NETWORK_OPSYS) + 1; -+ } -+ BCC(smb_buffer) = (long) bcc_ptr - (long) pByteArea(smb_buffer); -+ smb_buffer->smb_buf_length += BCC(smb_buffer); -+ BCC(smb_buffer) = cpu_to_le16(BCC(smb_buffer)); -+ -+ rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response, -+ &bytes_returned, 1); -+ if (rc) { -+/* rc = map_smb_to_linux_error(smb_buffer_response); now done in SendReceive */ -+ } else if ((smb_buffer_response->WordCount == 3) -+ || (smb_buffer_response->WordCount == 4)) { -+ pSMBr->resp.Action = le16_to_cpu(pSMBr->resp.Action); -+ if (pSMBr->resp.Action & GUEST_LOGIN) -+ cFYI(1, (" Guest login")); /* do we want to mark SesInfo struct ? */ -+ if (ses) { -+ ses->Suid = smb_buffer_response->Uid; /* UID left in wire format (le) */ -+ cFYI(1, ("UID = %d ", ses->Suid)); -+ /* response can have either 3 or 4 word count - Samba sends 3 */ -+ bcc_ptr = pByteArea(smb_buffer_response); -+ if ((pSMBr->resp.hdr.WordCount == 3) -+ || ((pSMBr->resp.hdr.WordCount == 4) -+ && (pSMBr->resp.SecurityBlobLength < -+ pSMBr->resp.ByteCount))) { -+ if (pSMBr->resp.hdr.WordCount == 4) -+ bcc_ptr += -+ pSMBr->resp.SecurityBlobLength; -+ -+ if (smb_buffer->Flags2 & SMBFLG2_UNICODE) { -+ if ((long) (bcc_ptr) % 2) { -+ remaining_words = -+ (BCC(smb_buffer_response) -+ - 1) / 2; -+ bcc_ptr++; /* Unicode strings must be word aligned */ -+ } else { -+ remaining_words = -+ BCC -+ (smb_buffer_response) / 2; -+ } -+ len = -+ UniStrnlen((wchar_t *) bcc_ptr, -+ remaining_words - 1); -+/* We look for obvious messed up bcc or strings in response so we do not go off -+ the end since (at least) WIN2K and Windows XP have a major bug in not null -+ terminating last Unicode string in response */ -+ ses->serverOS = cifs_kcalloc(2 * (len + 1), GFP_KERNEL); -+ cifs_strfromUCS_le(ses->serverOS, -+ (wchar_t *)bcc_ptr, len,nls_codepage); -+ bcc_ptr += 2 * (len + 1); -+ remaining_words -= len + 1; -+ ses->serverOS[2 * len] = 0; -+ ses->serverOS[1 + (2 * len)] = 0; -+ if (remaining_words > 0) { -+ len = UniStrnlen((wchar_t *)bcc_ptr, -+ remaining_words -+ - 1); -+ ses->serverNOS =cifs_kcalloc(2 * (len + 1),GFP_KERNEL); -+ cifs_strfromUCS_le(ses->serverNOS, -+ (wchar_t *)bcc_ptr,len,nls_codepage); -+ bcc_ptr += 2 * (len + 1); -+ ses->serverNOS[2 * len] = 0; -+ ses->serverNOS[1 + (2 * len)] = 0; -+ remaining_words -= len + 1; -+ if (remaining_words > 0) { -+ len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); -+ /* last string is not always null terminated (for e.g. for Windows XP & 2000) */ -+ ses->serverDomain = -+ cifs_kcalloc(2*(len+1),GFP_KERNEL); -+ cifs_strfromUCS_le(ses->serverDomain, -+ (wchar_t *)bcc_ptr,len,nls_codepage); -+ bcc_ptr += 2 * (len + 1); -+ ses->serverDomain[2*len] = 0; -+ ses->serverDomain[1+(2*len)] = 0; -+ } /* else no more room so create dummy domain string */ -+ else -+ ses->serverDomain = -+ cifs_kcalloc(2, -+ GFP_KERNEL); -+ } else { /* no room so create dummy domain and NOS string */ -+ ses->serverDomain = -+ cifs_kcalloc(2, GFP_KERNEL); -+ ses->serverNOS = -+ cifs_kcalloc(2, GFP_KERNEL); -+ } -+ } else { /* ASCII */ -+ len = strnlen(bcc_ptr, 1024); -+ if (((long) bcc_ptr + len) - (long) -+ pByteArea(smb_buffer_response) -+ <= BCC(smb_buffer_response)) { -+ ses->serverOS = cifs_kcalloc(len + 1,GFP_KERNEL); -+ strncpy(ses->serverOS,bcc_ptr, len); -+ -+ bcc_ptr += len; -+ bcc_ptr[0] = 0; /* null terminate the string */ -+ bcc_ptr++; -+ -+ len = strnlen(bcc_ptr, 1024); -+ ses->serverNOS = cifs_kcalloc(len + 1,GFP_KERNEL); -+ strncpy(ses->serverNOS, bcc_ptr, len); -+ bcc_ptr += len; -+ bcc_ptr[0] = 0; -+ bcc_ptr++; -+ -+ len = strnlen(bcc_ptr, 1024); -+ ses->serverDomain = cifs_kcalloc(len + 1,GFP_KERNEL); -+ strncpy(ses->serverDomain, bcc_ptr, len); -+ bcc_ptr += len; -+ bcc_ptr[0] = 0; -+ bcc_ptr++; -+ } else -+ cFYI(1, -+ ("Variable field of length %d extends beyond end of smb ", -+ len)); -+ } -+ } else { -+ cERROR(1, -+ (" Security Blob Length extends beyond end of SMB")); -+ } -+ } else { -+ cERROR(1, ("No session structure passed in.")); -+ } -+ } else { -+ cERROR(1, -+ (" Invalid Word count %d: ", -+ smb_buffer_response->WordCount)); -+ rc = -EIO; -+ } -+ -+ if (smb_buffer) -+ cifs_buf_release(smb_buffer); -+ -+ return rc; -+} -+ -+static int -+CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses, -+ char *SecurityBlob,int SecurityBlobLength, -+ const struct nls_table *nls_codepage) -+{ -+ struct smb_hdr *smb_buffer; -+ struct smb_hdr *smb_buffer_response; -+ SESSION_SETUP_ANDX *pSMB; -+ SESSION_SETUP_ANDX *pSMBr; -+ char *bcc_ptr; -+ char *user = ses->userName; -+ char *domain = ses->domainName; -+ int rc = 0; -+ int remaining_words = 0; -+ int bytes_returned = 0; -+ int len; -+ -+ cFYI(1, ("In spnego sesssetup ")); -+ -+ smb_buffer = cifs_buf_get(); -+ if (smb_buffer == 0) { -+ return -ENOMEM; -+ } -+ smb_buffer_response = smb_buffer; -+ pSMBr = pSMB = (SESSION_SETUP_ANDX *) smb_buffer; -+ -+ /* send SMBsessionSetup here */ -+ header_assemble(smb_buffer, SMB_COM_SESSION_SETUP_ANDX, -+ NULL /* no tCon exists yet */ , 12 /* wct */ ); -+ pSMB->req.hdr.Flags2 |= SMBFLG2_EXT_SEC; -+ pSMB->req.AndXCommand = 0xFF; -+ pSMB->req.MaxBufferSize = cpu_to_le16(ses->server->maxBuf); -+ pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq); -+ -+ if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) -+ smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; -+ -+ pSMB->req.Capabilities = -+ CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | -+ CAP_EXTENDED_SECURITY; -+ if (ses->capabilities & CAP_UNICODE) { -+ smb_buffer->Flags2 |= SMBFLG2_UNICODE; -+ pSMB->req.Capabilities |= CAP_UNICODE; -+ } -+ if (ses->capabilities & CAP_STATUS32) { -+ smb_buffer->Flags2 |= SMBFLG2_ERR_STATUS; -+ pSMB->req.Capabilities |= CAP_STATUS32; -+ } -+ if (ses->capabilities & CAP_DFS) { -+ smb_buffer->Flags2 |= SMBFLG2_DFS; -+ pSMB->req.Capabilities |= CAP_DFS; -+ } -+ pSMB->req.Capabilities = cpu_to_le32(pSMB->req.Capabilities); -+ -+ pSMB->req.SecurityBlobLength = cpu_to_le16(SecurityBlobLength); -+ bcc_ptr = pByteArea(smb_buffer); -+ memcpy(bcc_ptr, SecurityBlob, SecurityBlobLength); -+ bcc_ptr += SecurityBlobLength; -+ -+ if (ses->capabilities & CAP_UNICODE) { -+ if ((long) bcc_ptr % 2) { /* must be word aligned for Unicode strings */ -+ *bcc_ptr = 0; -+ bcc_ptr++; -+ } -+ bytes_returned = -+ cifs_strtoUCS((wchar_t *) bcc_ptr, user, 100, nls_codepage); -+ bcc_ptr += 2 * bytes_returned; /* convert num of 16 bit words to bytes */ -+ bcc_ptr += 2; /* trailing null */ -+ if (domain == NULL) -+ bytes_returned = -+ cifs_strtoUCS((wchar_t *) bcc_ptr, -+ "CIFS_LINUX_DOM", 32, nls_codepage); -+ else -+ bytes_returned = -+ cifs_strtoUCS((wchar_t *) bcc_ptr, domain, 64, -+ nls_codepage); -+ bcc_ptr += 2 * bytes_returned; -+ bcc_ptr += 2; -+ bytes_returned = -+ cifs_strtoUCS((wchar_t *) bcc_ptr, "Linux version ", -+ 32, nls_codepage); -+ bcc_ptr += 2 * bytes_returned; -+ bytes_returned = -+ cifs_strtoUCS((wchar_t *) bcc_ptr, UTS_RELEASE, 32, -+ nls_codepage); -+ bcc_ptr += 2 * bytes_returned; -+ bcc_ptr += 2; -+ bytes_returned = -+ cifs_strtoUCS((wchar_t *) bcc_ptr, CIFS_NETWORK_OPSYS, -+ 64, nls_codepage); -+ bcc_ptr += 2 * bytes_returned; -+ bcc_ptr += 2; -+ } else { -+ strncpy(bcc_ptr, user, 200); -+ bcc_ptr += strnlen(user, 200); -+ *bcc_ptr = 0; -+ bcc_ptr++; -+ if (domain == NULL) { -+ strcpy(bcc_ptr, "CIFS_LINUX_DOM"); -+ bcc_ptr += strlen("CIFS_LINUX_DOM") + 1; -+ } else { -+ strncpy(bcc_ptr, domain, 64); -+ bcc_ptr += strnlen(domain, 64); -+ *bcc_ptr = 0; -+ bcc_ptr++; -+ } -+ strcpy(bcc_ptr, "Linux version "); -+ bcc_ptr += strlen("Linux version "); -+ strcpy(bcc_ptr, UTS_RELEASE); -+ bcc_ptr += strlen(UTS_RELEASE) + 1; -+ strcpy(bcc_ptr, CIFS_NETWORK_OPSYS); -+ bcc_ptr += strlen(CIFS_NETWORK_OPSYS) + 1; -+ } -+ BCC(smb_buffer) = (long) bcc_ptr - (long) pByteArea(smb_buffer); -+ smb_buffer->smb_buf_length += BCC(smb_buffer); -+ BCC(smb_buffer) = cpu_to_le16(BCC(smb_buffer)); -+ -+ rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response, -+ &bytes_returned, 1); -+ if (rc) { -+/* rc = map_smb_to_linux_error(smb_buffer_response); *//* done in SendReceive now */ -+ } else if ((smb_buffer_response->WordCount == 3) -+ || (smb_buffer_response->WordCount == 4)) { -+ pSMBr->resp.Action = le16_to_cpu(pSMBr->resp.Action); -+ pSMBr->resp.SecurityBlobLength = -+ le16_to_cpu(pSMBr->resp.SecurityBlobLength); -+ if (pSMBr->resp.Action & GUEST_LOGIN) -+ cFYI(1, (" Guest login")); /* BB do we want to set anything in SesInfo struct ? */ -+ if (ses) { -+ ses->Suid = smb_buffer_response->Uid; /* UID left in wire format (le) */ -+ cFYI(1, ("UID = %d ", ses->Suid)); -+ bcc_ptr = pByteArea(smb_buffer_response); /* response can have either 3 or 4 word count - Samba sends 3 */ -+ -+ /* BB Fix below to make endian neutral !! */ -+ -+ if ((pSMBr->resp.hdr.WordCount == 3) -+ || ((pSMBr->resp.hdr.WordCount == 4) -+ && (pSMBr->resp.SecurityBlobLength < -+ pSMBr->resp.ByteCount))) { -+ if (pSMBr->resp.hdr.WordCount == 4) { -+ bcc_ptr += -+ pSMBr->resp.SecurityBlobLength; -+ cFYI(1, -+ ("Security Blob Length %d ", -+ pSMBr->resp.SecurityBlobLength)); -+ } -+ -+ if (smb_buffer->Flags2 & SMBFLG2_UNICODE) { -+ if ((long) (bcc_ptr) % 2) { -+ remaining_words = -+ (BCC(smb_buffer_response) -+ - 1) / 2; -+ bcc_ptr++; /* Unicode strings must be word aligned */ -+ } else { -+ remaining_words = -+ BCC -+ (smb_buffer_response) / 2; -+ } -+ len = -+ UniStrnlen((wchar_t *) bcc_ptr, -+ remaining_words - 1); -+/* We look for obvious messed up bcc or strings in response so we do not go off -+ the end since (at least) WIN2K and Windows XP have a major bug in not null -+ terminating last Unicode string in response */ -+ ses->serverOS = -+ cifs_kcalloc(2 * (len + 1), GFP_KERNEL); -+ cifs_strfromUCS_le(ses->serverOS, -+ (wchar_t *) -+ bcc_ptr, len, -+ nls_codepage); -+ bcc_ptr += 2 * (len + 1); -+ remaining_words -= len + 1; -+ ses->serverOS[2 * len] = 0; -+ ses->serverOS[1 + (2 * len)] = 0; -+ if (remaining_words > 0) { -+ len = UniStrnlen((wchar_t *)bcc_ptr, -+ remaining_words -+ - 1); -+ ses->serverNOS = -+ cifs_kcalloc(2 * (len + 1), -+ GFP_KERNEL); -+ cifs_strfromUCS_le(ses->serverNOS, -+ (wchar_t *)bcc_ptr, -+ len, -+ nls_codepage); -+ bcc_ptr += 2 * (len + 1); -+ ses->serverNOS[2 * len] = 0; -+ ses->serverNOS[1 + (2 * len)] = 0; -+ remaining_words -= len + 1; -+ if (remaining_words > 0) { -+ len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); -+ /* last string is not always null terminated (for e.g. for Windows XP & 2000) */ -+ ses->serverDomain = cifs_kcalloc(2*(len+1),GFP_KERNEL); -+ cifs_strfromUCS_le(ses->serverDomain, -+ (wchar_t *)bcc_ptr, -+ len, -+ nls_codepage); -+ bcc_ptr += 2*(len+1); -+ ses->serverDomain[2*len] = 0; -+ ses->serverDomain[1+(2*len)] = 0; -+ } /* else no more room so create dummy domain string */ -+ else -+ ses->serverDomain = -+ cifs_kcalloc(2,GFP_KERNEL); -+ } else { /* no room so create dummy domain and NOS string */ -+ ses->serverDomain = cifs_kcalloc(2, GFP_KERNEL); -+ ses->serverNOS = cifs_kcalloc(2, GFP_KERNEL); -+ } -+ } else { /* ASCII */ -+ -+ len = strnlen(bcc_ptr, 1024); -+ if (((long) bcc_ptr + len) - (long) -+ pByteArea(smb_buffer_response) -+ <= BCC(smb_buffer_response)) { -+ ses->serverOS = cifs_kcalloc(len + 1, GFP_KERNEL); -+ strncpy(ses->serverOS, bcc_ptr, len); -+ -+ bcc_ptr += len; -+ bcc_ptr[0] = 0; /* null terminate the string */ -+ bcc_ptr++; -+ -+ len = strnlen(bcc_ptr, 1024); -+ ses->serverNOS = cifs_kcalloc(len + 1,GFP_KERNEL); -+ strncpy(ses->serverNOS, bcc_ptr, len); -+ bcc_ptr += len; -+ bcc_ptr[0] = 0; -+ bcc_ptr++; -+ -+ len = strnlen(bcc_ptr, 1024); -+ ses->serverDomain = cifs_kcalloc(len + 1, GFP_KERNEL); -+ strncpy(ses->serverDomain, bcc_ptr, len); -+ bcc_ptr += len; -+ bcc_ptr[0] = 0; -+ bcc_ptr++; -+ } else -+ cFYI(1, -+ ("Variable field of length %d extends beyond end of smb ", -+ len)); -+ } -+ } else { -+ cERROR(1, -+ (" Security Blob Length extends beyond end of SMB")); -+ } -+ } else { -+ cERROR(1, ("No session structure passed in.")); -+ } -+ } else { -+ cERROR(1, -+ (" Invalid Word count %d: ", -+ smb_buffer_response->WordCount)); -+ rc = -EIO; -+ } -+ -+ if (smb_buffer) -+ cifs_buf_release(smb_buffer); -+ -+ return rc; -+} -+ -+static int -+CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, -+ struct cifsSesInfo *ses, int * pNTLMv2_flag, -+ const struct nls_table *nls_codepage) -+{ -+ struct smb_hdr *smb_buffer; -+ struct smb_hdr *smb_buffer_response; -+ SESSION_SETUP_ANDX *pSMB; -+ SESSION_SETUP_ANDX *pSMBr; -+ char *bcc_ptr; -+ char *domain = ses->domainName; -+ int rc = 0; -+ int remaining_words = 0; -+ int bytes_returned = 0; -+ int len; -+ int SecurityBlobLength = sizeof (NEGOTIATE_MESSAGE); -+ PNEGOTIATE_MESSAGE SecurityBlob; -+ PCHALLENGE_MESSAGE SecurityBlob2; -+ -+ cFYI(1, ("In NTLMSSP sesssetup (negotiate) ")); -+ *pNTLMv2_flag = FALSE; -+ smb_buffer = cifs_buf_get(); -+ if (smb_buffer == 0) { -+ return -ENOMEM; -+ } -+ smb_buffer_response = smb_buffer; -+ pSMB = (SESSION_SETUP_ANDX *) smb_buffer; -+ pSMBr = (SESSION_SETUP_ANDX *) smb_buffer_response; -+ -+ /* send SMBsessionSetup here */ -+ header_assemble(smb_buffer, SMB_COM_SESSION_SETUP_ANDX, -+ NULL /* no tCon exists yet */ , 12 /* wct */ ); -+ pSMB->req.hdr.Flags2 |= SMBFLG2_EXT_SEC; -+ pSMB->req.hdr.Flags |= (SMBFLG_CASELESS | SMBFLG_CANONICAL_PATH_FORMAT); -+ -+ pSMB->req.AndXCommand = 0xFF; -+ pSMB->req.MaxBufferSize = cpu_to_le16(ses->server->maxBuf); -+ pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq); -+ -+ if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) -+ smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; -+ -+ pSMB->req.Capabilities = -+ CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | -+ CAP_EXTENDED_SECURITY; -+ if (ses->capabilities & CAP_UNICODE) { -+ smb_buffer->Flags2 |= SMBFLG2_UNICODE; -+ pSMB->req.Capabilities |= CAP_UNICODE; -+ } -+ if (ses->capabilities & CAP_STATUS32) { -+ smb_buffer->Flags2 |= SMBFLG2_ERR_STATUS; -+ pSMB->req.Capabilities |= CAP_STATUS32; -+ } -+ if (ses->capabilities & CAP_DFS) { -+ smb_buffer->Flags2 |= SMBFLG2_DFS; -+ pSMB->req.Capabilities |= CAP_DFS; -+ } -+ pSMB->req.Capabilities = cpu_to_le32(pSMB->req.Capabilities); -+ -+ bcc_ptr = (char *) &pSMB->req.SecurityBlob; -+ SecurityBlob = (PNEGOTIATE_MESSAGE) bcc_ptr; -+ strncpy(SecurityBlob->Signature, NTLMSSP_SIGNATURE, 8); -+ SecurityBlob->MessageType = NtLmNegotiate; -+ SecurityBlob->NegotiateFlags = -+ NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_NEGOTIATE_OEM | -+ NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_NTLM | 0x80000000 | -+ /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN | */ NTLMSSP_NEGOTIATE_128; -+ if(sign_CIFS_PDUs) -+ SecurityBlob->NegotiateFlags |= NTLMSSP_NEGOTIATE_SIGN; -+ if(ntlmv2_support) -+ SecurityBlob->NegotiateFlags |= NTLMSSP_NEGOTIATE_NTLMV2; -+ /* setup pointers to domain name and workstation name */ -+ bcc_ptr += SecurityBlobLength; -+ -+ SecurityBlob->WorkstationName.Buffer = 0; -+ SecurityBlob->WorkstationName.Length = 0; -+ SecurityBlob->WorkstationName.MaximumLength = 0; -+ -+ if (domain == NULL) { -+ SecurityBlob->DomainName.Buffer = 0; -+ SecurityBlob->DomainName.Length = 0; -+ SecurityBlob->DomainName.MaximumLength = 0; -+ } else { -+ SecurityBlob->NegotiateFlags |= -+ NTLMSSP_NEGOTIATE_DOMAIN_SUPPLIED; -+ strncpy(bcc_ptr, domain, 63); -+ SecurityBlob->DomainName.Length = strnlen(domain, 64); -+ SecurityBlob->DomainName.MaximumLength = -+ cpu_to_le16(SecurityBlob->DomainName.Length); -+ SecurityBlob->DomainName.Buffer = -+ cpu_to_le32((long) &SecurityBlob-> -+ DomainString - -+ (long) &SecurityBlob->Signature); -+ bcc_ptr += SecurityBlob->DomainName.Length; -+ SecurityBlobLength += SecurityBlob->DomainName.Length; -+ SecurityBlob->DomainName.Length = -+ cpu_to_le16(SecurityBlob->DomainName.Length); -+ } -+ if (ses->capabilities & CAP_UNICODE) { -+ if ((long) bcc_ptr % 2) { -+ *bcc_ptr = 0; -+ bcc_ptr++; -+ } -+ -+ bytes_returned = -+ cifs_strtoUCS((wchar_t *) bcc_ptr, "Linux version ", -+ 32, nls_codepage); -+ bcc_ptr += 2 * bytes_returned; -+ bytes_returned = -+ cifs_strtoUCS((wchar_t *) bcc_ptr, UTS_RELEASE, 32, -+ nls_codepage); -+ bcc_ptr += 2 * bytes_returned; -+ bcc_ptr += 2; /* null terminate Linux version */ -+ bytes_returned = -+ cifs_strtoUCS((wchar_t *) bcc_ptr, CIFS_NETWORK_OPSYS, -+ 64, nls_codepage); -+ bcc_ptr += 2 * bytes_returned; -+ *(bcc_ptr + 1) = 0; -+ *(bcc_ptr + 2) = 0; -+ bcc_ptr += 2; /* null terminate network opsys string */ -+ *(bcc_ptr + 1) = 0; -+ *(bcc_ptr + 2) = 0; -+ bcc_ptr += 2; /* null domain */ -+ } else { /* ASCII */ -+ strcpy(bcc_ptr, "Linux version "); -+ bcc_ptr += strlen("Linux version "); -+ strcpy(bcc_ptr, UTS_RELEASE); -+ bcc_ptr += strlen(UTS_RELEASE) + 1; -+ strcpy(bcc_ptr, CIFS_NETWORK_OPSYS); -+ bcc_ptr += strlen(CIFS_NETWORK_OPSYS) + 1; -+ bcc_ptr++; /* empty domain field */ -+ *bcc_ptr = 0; -+ } -+ SecurityBlob->NegotiateFlags = -+ cpu_to_le32(SecurityBlob->NegotiateFlags); -+ pSMB->req.SecurityBlobLength = cpu_to_le16(SecurityBlobLength); -+ BCC(smb_buffer) = (long) bcc_ptr - (long) pByteArea(smb_buffer); -+ smb_buffer->smb_buf_length += BCC(smb_buffer); -+ BCC(smb_buffer) = cpu_to_le16(BCC(smb_buffer)); -+ -+ rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response, -+ &bytes_returned, 1); -+ -+ if (smb_buffer_response->Status.CifsError == -+ (NT_STATUS_MORE_PROCESSING_REQUIRED)) -+ rc = 0; -+ -+ if (rc) { -+/* rc = map_smb_to_linux_error(smb_buffer_response); *//* done in SendReceive now */ -+ } else if ((smb_buffer_response->WordCount == 3) -+ || (smb_buffer_response->WordCount == 4)) { -+ pSMBr->resp.Action = le16_to_cpu(pSMBr->resp.Action); -+ pSMBr->resp.SecurityBlobLength = -+ le16_to_cpu(pSMBr->resp.SecurityBlobLength); -+ if (pSMBr->resp.Action & GUEST_LOGIN) -+ cFYI(1, (" Guest login")); -+ /* Do we want to set anything in SesInfo struct when guest login? */ -+ -+ bcc_ptr = pByteArea(smb_buffer_response); -+ /* response can have either 3 or 4 word count - Samba sends 3 */ -+ -+ SecurityBlob2 = (PCHALLENGE_MESSAGE) bcc_ptr; -+ if (SecurityBlob2->MessageType != NtLmChallenge) { -+ cFYI(1, -+ ("Unexpected NTLMSSP message type received %d", -+ SecurityBlob2->MessageType)); -+ } else if (ses) { -+ ses->Suid = smb_buffer_response->Uid; /* UID left in le format */ -+ cFYI(1, ("UID = %d ", ses->Suid)); -+ if ((pSMBr->resp.hdr.WordCount == 3) -+ || ((pSMBr->resp.hdr.WordCount == 4) -+ && (pSMBr->resp.SecurityBlobLength < -+ pSMBr->resp.ByteCount))) { -+ if (pSMBr->resp.hdr.WordCount == 4) { -+ bcc_ptr += -+ pSMBr->resp.SecurityBlobLength; -+ cFYI(1, -+ ("Security Blob Length %d ", -+ pSMBr->resp.SecurityBlobLength)); -+ } -+ -+ cFYI(1, ("NTLMSSP Challenge rcvd ")); -+ -+ memcpy(ses->server->cryptKey, -+ SecurityBlob2->Challenge, -+ CIFS_CRYPTO_KEY_SIZE); -+ if(SecurityBlob2->NegotiateFlags & NTLMSSP_NEGOTIATE_NTLMV2) -+ *pNTLMv2_flag = TRUE; -+ -+ if((SecurityBlob2->NegotiateFlags & -+ NTLMSSP_NEGOTIATE_ALWAYS_SIGN) -+ || (sign_CIFS_PDUs > 1)) -+ ses->server->secMode |= -+ SECMODE_SIGN_REQUIRED; -+ if ((SecurityBlob2->NegotiateFlags & -+ NTLMSSP_NEGOTIATE_SIGN) && (sign_CIFS_PDUs)) -+ ses->server->secMode |= -+ SECMODE_SIGN_ENABLED; -+ -+ if (smb_buffer->Flags2 & SMBFLG2_UNICODE) { -+ if ((long) (bcc_ptr) % 2) { -+ remaining_words = -+ (BCC(smb_buffer_response) -+ - 1) / 2; -+ bcc_ptr++; /* Unicode strings must be word aligned */ -+ } else { -+ remaining_words = -+ BCC -+ (smb_buffer_response) / 2; -+ } -+ len = -+ UniStrnlen((wchar_t *) bcc_ptr, -+ remaining_words - 1); -+/* We look for obvious messed up bcc or strings in response so we do not go off -+ the end since (at least) WIN2K and Windows XP have a major bug in not null -+ terminating last Unicode string in response */ -+ ses->serverOS = -+ cifs_kcalloc(2 * (len + 1), GFP_KERNEL); -+ cifs_strfromUCS_le(ses->serverOS, -+ (wchar_t *) -+ bcc_ptr, len, -+ nls_codepage); -+ bcc_ptr += 2 * (len + 1); -+ remaining_words -= len + 1; -+ ses->serverOS[2 * len] = 0; -+ ses->serverOS[1 + (2 * len)] = 0; -+ if (remaining_words > 0) { -+ len = UniStrnlen((wchar_t *) -+ bcc_ptr, -+ remaining_words -+ - 1); -+ ses->serverNOS = -+ cifs_kcalloc(2 * (len + 1), -+ GFP_KERNEL); -+ cifs_strfromUCS_le(ses-> -+ serverNOS, -+ (wchar_t *) -+ bcc_ptr, -+ len, -+ nls_codepage); -+ bcc_ptr += 2 * (len + 1); -+ ses->serverNOS[2 * len] = 0; -+ ses->serverNOS[1 + -+ (2 * len)] = 0; -+ remaining_words -= len + 1; -+ if (remaining_words > 0) { -+ len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); -+ /* last string is not always null terminated (for e.g. for Windows XP & 2000) */ -+ ses->serverDomain = -+ cifs_kcalloc(2 * -+ (len + -+ 1), -+ GFP_KERNEL); -+ cifs_strfromUCS_le -+ (ses-> -+ serverDomain, -+ (wchar_t *) -+ bcc_ptr, len, -+ nls_codepage); -+ bcc_ptr += -+ 2 * (len + 1); -+ ses-> -+ serverDomain[2 -+ * len] -+ = 0; -+ ses-> -+ serverDomain[1 -+ + -+ (2 -+ * -+ len)] -+ = 0; -+ } /* else no more room so create dummy domain string */ -+ else -+ ses->serverDomain = -+ cifs_kcalloc(2, -+ GFP_KERNEL); -+ } else { /* no room so create dummy domain and NOS string */ -+ ses->serverDomain = -+ cifs_kcalloc(2, GFP_KERNEL); -+ ses->serverNOS = -+ cifs_kcalloc(2, GFP_KERNEL); -+ } -+ } else { /* ASCII */ -+ len = strnlen(bcc_ptr, 1024); -+ if (((long) bcc_ptr + len) - (long) -+ pByteArea(smb_buffer_response) -+ <= BCC(smb_buffer_response)) { -+ ses->serverOS = -+ cifs_kcalloc(len + 1, -+ GFP_KERNEL); -+ strncpy(ses->serverOS, -+ bcc_ptr, len); -+ -+ bcc_ptr += len; -+ bcc_ptr[0] = 0; /* null terminate string */ -+ bcc_ptr++; -+ -+ len = strnlen(bcc_ptr, 1024); -+ ses->serverNOS = -+ cifs_kcalloc(len + 1, -+ GFP_KERNEL); -+ strncpy(ses->serverNOS, bcc_ptr, len); -+ bcc_ptr += len; -+ bcc_ptr[0] = 0; -+ bcc_ptr++; -+ -+ len = strnlen(bcc_ptr, 1024); -+ ses->serverDomain = -+ cifs_kcalloc(len + 1, -+ GFP_KERNEL); -+ strncpy(ses->serverDomain, bcc_ptr, len); -+ bcc_ptr += len; -+ bcc_ptr[0] = 0; -+ bcc_ptr++; -+ } else -+ cFYI(1, -+ ("Variable field of length %d extends beyond end of smb ", -+ len)); -+ } -+ } else { -+ cERROR(1, -+ (" Security Blob Length extends beyond end of SMB")); -+ } -+ } else { -+ cERROR(1, ("No session structure passed in.")); -+ } -+ } else { -+ cERROR(1, -+ (" Invalid Word count %d: ", -+ smb_buffer_response->WordCount)); -+ rc = -EIO; -+ } -+ -+ if (smb_buffer) -+ cifs_buf_release(smb_buffer); -+ -+ return rc; -+} -+ -+static int -+CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, -+ char *ntlm_session_key, int ntlmv2_flag, -+ const struct nls_table *nls_codepage) -+{ -+ struct smb_hdr *smb_buffer; -+ struct smb_hdr *smb_buffer_response; -+ SESSION_SETUP_ANDX *pSMB; -+ SESSION_SETUP_ANDX *pSMBr; -+ char *bcc_ptr; -+ char *user = ses->userName; -+ char *domain = ses->domainName; -+ int rc = 0; -+ int remaining_words = 0; -+ int bytes_returned = 0; -+ int len; -+ int SecurityBlobLength = sizeof (AUTHENTICATE_MESSAGE); -+ PAUTHENTICATE_MESSAGE SecurityBlob; -+ -+ cFYI(1, ("In NTLMSSPSessSetup (Authenticate)")); -+ -+ smb_buffer = cifs_buf_get(); -+ if (smb_buffer == 0) { -+ return -ENOMEM; -+ } -+ smb_buffer_response = smb_buffer; -+ pSMB = (SESSION_SETUP_ANDX *) smb_buffer; -+ pSMBr = (SESSION_SETUP_ANDX *) smb_buffer_response; -+ -+ /* send SMBsessionSetup here */ -+ header_assemble(smb_buffer, SMB_COM_SESSION_SETUP_ANDX, -+ NULL /* no tCon exists yet */ , 12 /* wct */ ); -+ pSMB->req.hdr.Flags |= (SMBFLG_CASELESS | SMBFLG_CANONICAL_PATH_FORMAT); -+ pSMB->req.hdr.Flags2 |= SMBFLG2_EXT_SEC; -+ pSMB->req.AndXCommand = 0xFF; -+ pSMB->req.MaxBufferSize = cpu_to_le16(ses->server->maxBuf); -+ pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq); -+ -+ pSMB->req.hdr.Uid = ses->Suid; -+ -+ if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) -+ smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; -+ -+ pSMB->req.Capabilities = -+ CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | -+ CAP_EXTENDED_SECURITY; -+ if (ses->capabilities & CAP_UNICODE) { -+ smb_buffer->Flags2 |= SMBFLG2_UNICODE; -+ pSMB->req.Capabilities |= CAP_UNICODE; -+ } -+ if (ses->capabilities & CAP_STATUS32) { -+ smb_buffer->Flags2 |= SMBFLG2_ERR_STATUS; -+ pSMB->req.Capabilities |= CAP_STATUS32; -+ } -+ if (ses->capabilities & CAP_DFS) { -+ smb_buffer->Flags2 |= SMBFLG2_DFS; -+ pSMB->req.Capabilities |= CAP_DFS; -+ } -+ pSMB->req.Capabilities = cpu_to_le32(pSMB->req.Capabilities); -+ -+ bcc_ptr = (char *) &pSMB->req.SecurityBlob; -+ SecurityBlob = (PAUTHENTICATE_MESSAGE) bcc_ptr; -+ strncpy(SecurityBlob->Signature, NTLMSSP_SIGNATURE, 8); -+ SecurityBlob->MessageType = NtLmAuthenticate; -+ bcc_ptr += SecurityBlobLength; -+ SecurityBlob->NegotiateFlags = -+ NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_REQUEST_TARGET | -+ NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_TARGET_INFO | -+ 0x80000000 | NTLMSSP_NEGOTIATE_128; -+ if(sign_CIFS_PDUs) -+ SecurityBlob->NegotiateFlags |= /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN |*/ NTLMSSP_NEGOTIATE_SIGN; -+ if(ntlmv2_flag) -+ SecurityBlob->NegotiateFlags |= NTLMSSP_NEGOTIATE_NTLMV2; -+ -+/* setup pointers to domain name and workstation name */ -+ -+ SecurityBlob->WorkstationName.Buffer = 0; -+ SecurityBlob->WorkstationName.Length = 0; -+ SecurityBlob->WorkstationName.MaximumLength = 0; -+ SecurityBlob->SessionKey.Length = 0; -+ SecurityBlob->SessionKey.MaximumLength = 0; -+ SecurityBlob->SessionKey.Buffer = 0; -+ -+ SecurityBlob->LmChallengeResponse.Length = 0; -+ SecurityBlob->LmChallengeResponse.MaximumLength = 0; -+ SecurityBlob->LmChallengeResponse.Buffer = 0; -+ -+ SecurityBlob->NtChallengeResponse.Length = -+ cpu_to_le16(CIFS_SESSION_KEY_SIZE); -+ SecurityBlob->NtChallengeResponse.MaximumLength = -+ cpu_to_le16(CIFS_SESSION_KEY_SIZE); -+ memcpy(bcc_ptr, ntlm_session_key, CIFS_SESSION_KEY_SIZE); -+ SecurityBlob->NtChallengeResponse.Buffer = -+ cpu_to_le32(SecurityBlobLength); -+ SecurityBlobLength += CIFS_SESSION_KEY_SIZE; -+ bcc_ptr += CIFS_SESSION_KEY_SIZE; -+ -+ if (ses->capabilities & CAP_UNICODE) { -+ if (domain == NULL) { -+ SecurityBlob->DomainName.Buffer = 0; -+ SecurityBlob->DomainName.Length = 0; -+ SecurityBlob->DomainName.MaximumLength = 0; -+ } else { -+ SecurityBlob->DomainName.Length = -+ cifs_strtoUCS((wchar_t *) bcc_ptr, domain, 64, -+ nls_codepage); -+ SecurityBlob->DomainName.Length *= 2; -+ SecurityBlob->DomainName.MaximumLength = -+ cpu_to_le16(SecurityBlob->DomainName.Length); -+ SecurityBlob->DomainName.Buffer = -+ cpu_to_le32(SecurityBlobLength); -+ bcc_ptr += SecurityBlob->DomainName.Length; -+ SecurityBlobLength += SecurityBlob->DomainName.Length; -+ SecurityBlob->DomainName.Length = -+ cpu_to_le16(SecurityBlob->DomainName.Length); -+ } -+ if (user == NULL) { -+ SecurityBlob->UserName.Buffer = 0; -+ SecurityBlob->UserName.Length = 0; -+ SecurityBlob->UserName.MaximumLength = 0; -+ } else { -+ SecurityBlob->UserName.Length = -+ cifs_strtoUCS((wchar_t *) bcc_ptr, user, 64, -+ nls_codepage); -+ SecurityBlob->UserName.Length *= 2; -+ SecurityBlob->UserName.MaximumLength = -+ cpu_to_le16(SecurityBlob->UserName.Length); -+ SecurityBlob->UserName.Buffer = -+ cpu_to_le32(SecurityBlobLength); -+ bcc_ptr += SecurityBlob->UserName.Length; -+ SecurityBlobLength += SecurityBlob->UserName.Length; -+ SecurityBlob->UserName.Length = -+ cpu_to_le16(SecurityBlob->UserName.Length); -+ } -+ -+ /* SecurityBlob->WorkstationName.Length = cifs_strtoUCS((wchar_t *) bcc_ptr, "AMACHINE",64, nls_codepage); -+ SecurityBlob->WorkstationName.Length *= 2; -+ SecurityBlob->WorkstationName.MaximumLength = cpu_to_le16(SecurityBlob->WorkstationName.Length); -+ SecurityBlob->WorkstationName.Buffer = cpu_to_le32(SecurityBlobLength); -+ bcc_ptr += SecurityBlob->WorkstationName.Length; -+ SecurityBlobLength += SecurityBlob->WorkstationName.Length; -+ SecurityBlob->WorkstationName.Length = cpu_to_le16(SecurityBlob->WorkstationName.Length); */ -+ -+ if ((long) bcc_ptr % 2) { -+ *bcc_ptr = 0; -+ bcc_ptr++; -+ } -+ bytes_returned = -+ cifs_strtoUCS((wchar_t *) bcc_ptr, "Linux version ", -+ 32, nls_codepage); -+ bcc_ptr += 2 * bytes_returned; -+ bytes_returned = -+ cifs_strtoUCS((wchar_t *) bcc_ptr, UTS_RELEASE, 32, -+ nls_codepage); -+ bcc_ptr += 2 * bytes_returned; -+ bcc_ptr += 2; /* null term version string */ -+ bytes_returned = -+ cifs_strtoUCS((wchar_t *) bcc_ptr, CIFS_NETWORK_OPSYS, -+ 64, nls_codepage); -+ bcc_ptr += 2 * bytes_returned; -+ *(bcc_ptr + 1) = 0; -+ *(bcc_ptr + 2) = 0; -+ bcc_ptr += 2; /* null terminate network opsys string */ -+ *(bcc_ptr + 1) = 0; -+ *(bcc_ptr + 2) = 0; -+ bcc_ptr += 2; /* null domain */ -+ } else { /* ASCII */ -+ if (domain == NULL) { -+ SecurityBlob->DomainName.Buffer = 0; -+ SecurityBlob->DomainName.Length = 0; -+ SecurityBlob->DomainName.MaximumLength = 0; -+ } else { -+ SecurityBlob->NegotiateFlags |= -+ NTLMSSP_NEGOTIATE_DOMAIN_SUPPLIED; -+ strncpy(bcc_ptr, domain, 63); -+ SecurityBlob->DomainName.Length = strnlen(domain, 64); -+ SecurityBlob->DomainName.MaximumLength = -+ cpu_to_le16(SecurityBlob->DomainName.Length); -+ SecurityBlob->DomainName.Buffer = -+ cpu_to_le32(SecurityBlobLength); -+ bcc_ptr += SecurityBlob->DomainName.Length; -+ SecurityBlobLength += SecurityBlob->DomainName.Length; -+ SecurityBlob->DomainName.Length = -+ cpu_to_le16(SecurityBlob->DomainName.Length); -+ } -+ if (user == NULL) { -+ SecurityBlob->UserName.Buffer = 0; -+ SecurityBlob->UserName.Length = 0; -+ SecurityBlob->UserName.MaximumLength = 0; -+ } else { -+ strncpy(bcc_ptr, user, 63); -+ SecurityBlob->UserName.Length = strnlen(user, 64); -+ SecurityBlob->UserName.MaximumLength = -+ cpu_to_le16(SecurityBlob->UserName.Length); -+ SecurityBlob->UserName.Buffer = -+ cpu_to_le32(SecurityBlobLength); -+ bcc_ptr += SecurityBlob->UserName.Length; -+ SecurityBlobLength += SecurityBlob->UserName.Length; -+ SecurityBlob->UserName.Length = -+ cpu_to_le16(SecurityBlob->UserName.Length); -+ } -+ /* BB fill in our workstation name if known BB */ -+ -+ strcpy(bcc_ptr, "Linux version "); -+ bcc_ptr += strlen("Linux version "); -+ strcpy(bcc_ptr, UTS_RELEASE); -+ bcc_ptr += strlen(UTS_RELEASE) + 1; -+ strcpy(bcc_ptr, CIFS_NETWORK_OPSYS); -+ bcc_ptr += strlen(CIFS_NETWORK_OPSYS) + 1; -+ bcc_ptr++; /* null domain */ -+ *bcc_ptr = 0; -+ } -+ SecurityBlob->NegotiateFlags = -+ cpu_to_le32(SecurityBlob->NegotiateFlags); -+ pSMB->req.SecurityBlobLength = cpu_to_le16(SecurityBlobLength); -+ BCC(smb_buffer) = (long) bcc_ptr - (long) pByteArea(smb_buffer); -+ smb_buffer->smb_buf_length += BCC(smb_buffer); -+ BCC(smb_buffer) = cpu_to_le16(BCC(smb_buffer)); -+ -+ rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response, -+ &bytes_returned, 1); -+ if (rc) { -+/* rc = map_smb_to_linux_error(smb_buffer_response); *//* done in SendReceive now */ -+ } else if ((smb_buffer_response->WordCount == 3) -+ || (smb_buffer_response->WordCount == 4)) { -+ pSMBr->resp.Action = le16_to_cpu(pSMBr->resp.Action); -+ pSMBr->resp.SecurityBlobLength = -+ le16_to_cpu(pSMBr->resp.SecurityBlobLength); -+ if (pSMBr->resp.Action & GUEST_LOGIN) -+ cFYI(1, (" Guest login")); /* BB do we want to set anything in SesInfo struct ? */ -+/* if(SecurityBlob2->MessageType != NtLm??){ -+ cFYI("Unexpected message type on auth response is %d ")); -+ } */ -+ if (ses) { -+ cFYI(1, -+ ("Does UID on challenge %d match auth response UID %d ", -+ ses->Suid, smb_buffer_response->Uid)); -+ ses->Suid = smb_buffer_response->Uid; /* UID left in wire format */ -+ bcc_ptr = pByteArea(smb_buffer_response); -+ /* response can have either 3 or 4 word count - Samba sends 3 */ -+ if ((pSMBr->resp.hdr.WordCount == 3) -+ || ((pSMBr->resp.hdr.WordCount == 4) -+ && (pSMBr->resp.SecurityBlobLength < -+ pSMBr->resp.ByteCount))) { -+ if (pSMBr->resp.hdr.WordCount == 4) { -+ bcc_ptr += -+ pSMBr->resp.SecurityBlobLength; -+ cFYI(1, -+ ("Security Blob Length %d ", -+ pSMBr->resp.SecurityBlobLength)); -+ } -+ -+ cFYI(1, -+ ("NTLMSSP response to Authenticate ")); -+ -+ if (smb_buffer->Flags2 & SMBFLG2_UNICODE) { -+ if ((long) (bcc_ptr) % 2) { -+ remaining_words = -+ (BCC(smb_buffer_response) -+ - 1) / 2; -+ bcc_ptr++; /* Unicode strings must be word aligned */ -+ } else { -+ remaining_words = BCC(smb_buffer_response) / 2; -+ } -+ len = -+ UniStrnlen((wchar_t *) bcc_ptr,remaining_words - 1); -+/* We look for obvious messed up bcc or strings in response so we do not go off -+ the end since (at least) WIN2K and Windows XP have a major bug in not null -+ terminating last Unicode string in response */ -+ ses->serverOS = -+ cifs_kcalloc(2 * (len + 1), GFP_KERNEL); -+ cifs_strfromUCS_le(ses->serverOS, -+ (wchar_t *) -+ bcc_ptr, len, -+ nls_codepage); -+ bcc_ptr += 2 * (len + 1); -+ remaining_words -= len + 1; -+ ses->serverOS[2 * len] = 0; -+ ses->serverOS[1 + (2 * len)] = 0; -+ if (remaining_words > 0) { -+ len = UniStrnlen((wchar_t *) -+ bcc_ptr, -+ remaining_words -+ - 1); -+ ses->serverNOS = -+ cifs_kcalloc(2 * (len + 1), -+ GFP_KERNEL); -+ cifs_strfromUCS_le(ses-> -+ serverNOS, -+ (wchar_t *) -+ bcc_ptr, -+ len, -+ nls_codepage); -+ bcc_ptr += 2 * (len + 1); -+ ses->serverNOS[2 * len] = 0; -+ ses->serverNOS[1+(2*len)] = 0; -+ remaining_words -= len + 1; -+ if (remaining_words > 0) { -+ len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); -+ /* last string not always null terminated (e.g. for Windows XP & 2000) */ -+ ses->serverDomain = -+ cifs_kcalloc(2 * -+ (len + -+ 1), -+ GFP_KERNEL); -+ cifs_strfromUCS_le -+ (ses-> -+ serverDomain, -+ (wchar_t *) -+ bcc_ptr, len, -+ nls_codepage); -+ bcc_ptr += -+ 2 * (len + 1); -+ ses-> -+ serverDomain[2 -+ * len] -+ = 0; -+ ses-> -+ serverDomain[1 -+ + -+ (2 -+ * -+ len)] -+ = 0; -+ } /* else no more room so create dummy domain string */ -+ else -+ ses->serverDomain = cifs_kcalloc(2,GFP_KERNEL); -+ } else { /* no room so create dummy domain and NOS string */ -+ ses->serverDomain = cifs_kcalloc(2, GFP_KERNEL); -+ ses->serverNOS = cifs_kcalloc(2, GFP_KERNEL); -+ } -+ } else { /* ASCII */ -+ len = strnlen(bcc_ptr, 1024); -+ if (((long) bcc_ptr + len) - -+ (long) pByteArea(smb_buffer_response) -+ <= BCC(smb_buffer_response)) { -+ ses->serverOS = cifs_kcalloc(len + 1,GFP_KERNEL); -+ strncpy(ses->serverOS,bcc_ptr, len); -+ -+ bcc_ptr += len; -+ bcc_ptr[0] = 0; /* null terminate the string */ -+ bcc_ptr++; -+ -+ len = strnlen(bcc_ptr, 1024); -+ ses->serverNOS = cifs_kcalloc(len+1,GFP_KERNEL); -+ strncpy(ses->serverNOS, bcc_ptr, len); -+ bcc_ptr += len; -+ bcc_ptr[0] = 0; -+ bcc_ptr++; -+ -+ len = strnlen(bcc_ptr, 1024); -+ ses->serverDomain = cifs_kcalloc(len+1,GFP_KERNEL); -+ strncpy(ses->serverDomain, bcc_ptr, len); -+ bcc_ptr += len; -+ bcc_ptr[0] = 0; -+ bcc_ptr++; -+ } else -+ cFYI(1, -+ ("Variable field of length %d extends beyond end of smb ", -+ len)); -+ } -+ } else { -+ cERROR(1, -+ (" Security Blob Length extends beyond end of SMB")); -+ } -+ } else { -+ cERROR(1, ("No session structure passed in.")); -+ } -+ } else { -+ cERROR(1, -+ (" Invalid Word count %d: ", -+ smb_buffer_response->WordCount)); -+ rc = -EIO; -+ } -+ -+ if (smb_buffer) -+ cifs_buf_release(smb_buffer); -+ -+ return rc; -+} -+ -+int -+CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, -+ const char *tree, struct cifsTconInfo *tcon, -+ const struct nls_table *nls_codepage) -+{ -+ struct smb_hdr *smb_buffer; -+ struct smb_hdr *smb_buffer_response; -+ TCONX_REQ *pSMB; -+ TCONX_RSP *pSMBr; -+ char *bcc_ptr; -+ int rc = 0; -+ int length; -+ -+ if (ses == NULL) -+ return -EIO; -+ -+ smb_buffer = cifs_buf_get(); -+ if (smb_buffer == 0) { -+ return -ENOMEM; -+ } -+ smb_buffer_response = smb_buffer; -+ -+ header_assemble(smb_buffer, SMB_COM_TREE_CONNECT_ANDX, -+ NULL /*no tid */ , 4 /*wct */ ); -+ smb_buffer->Uid = ses->Suid; -+ pSMB = (TCONX_REQ *) smb_buffer; -+ pSMBr = (TCONX_RSP *) smb_buffer_response; -+ -+ pSMB->AndXCommand = 0xFF; -+ pSMB->Flags = cpu_to_le16(TCON_EXTENDED_SECINFO); -+ pSMB->PasswordLength = cpu_to_le16(1); /* minimum */ -+ bcc_ptr = &(pSMB->Password[0]); -+ bcc_ptr++; /* skip password */ -+ -+ if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) -+ smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; -+ -+ if (ses->capabilities & CAP_STATUS32) { -+ smb_buffer->Flags2 |= SMBFLG2_ERR_STATUS; -+ } -+ if (ses->capabilities & CAP_DFS) { -+ smb_buffer->Flags2 |= SMBFLG2_DFS; -+ } -+ if (ses->capabilities & CAP_UNICODE) { -+ smb_buffer->Flags2 |= SMBFLG2_UNICODE; -+ length = -+ cifs_strtoUCS((wchar_t *) bcc_ptr, tree, 100, nls_codepage); -+ bcc_ptr += 2 * length; /* convert num of 16 bit words to bytes */ -+ bcc_ptr += 2; /* skip trailing null */ -+ } else { /* ASCII */ -+ -+ strcpy(bcc_ptr, tree); -+ bcc_ptr += strlen(tree) + 1; -+ } -+ strcpy(bcc_ptr, "?????"); -+ bcc_ptr += strlen("?????"); -+ bcc_ptr += 1; -+ BCC(smb_buffer) = (long) bcc_ptr - (long) pByteArea(smb_buffer); -+ smb_buffer->smb_buf_length += BCC(smb_buffer); -+ BCC(smb_buffer) = cpu_to_le16(BCC(smb_buffer)); -+ -+ rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response, &length, 0); -+ -+ /* if (rc) rc = map_smb_to_linux_error(smb_buffer_response); */ -+ /* above now done in SendReceive */ -+ if ((rc == 0) && (tcon != NULL)) { -+ tcon->tidStatus = CifsGood; -+ tcon->tid = smb_buffer_response->Tid; -+ bcc_ptr = pByteArea(smb_buffer_response); -+ length = strnlen(bcc_ptr, BCC(smb_buffer_response) - 2); -+ /* skip service field (NB: this field is always ASCII) */ -+ bcc_ptr += length + 1; -+ strncpy(tcon->treeName, tree, MAX_TREE_SIZE); -+ if (smb_buffer->Flags2 & SMBFLG2_UNICODE) { -+ length = UniStrnlen((wchar_t *) bcc_ptr, 512); -+ if (((long) bcc_ptr + (2 * length)) - -+ (long) pByteArea(smb_buffer_response) <= -+ BCC(smb_buffer_response)) { -+ if(tcon->nativeFileSystem) -+ kfree(tcon->nativeFileSystem); -+ tcon->nativeFileSystem = -+ cifs_kcalloc(length + 2, GFP_KERNEL); -+ cifs_strfromUCS_le(tcon->nativeFileSystem, -+ (wchar_t *) bcc_ptr, -+ length, nls_codepage); -+ bcc_ptr += 2 * length; -+ bcc_ptr[0] = 0; /* null terminate the string */ -+ bcc_ptr[1] = 0; -+ bcc_ptr += 2; -+ } -+ /* else do not bother copying these informational fields */ -+ } else { -+ length = strnlen(bcc_ptr, 1024); -+ if (((long) bcc_ptr + length) - -+ (long) pByteArea(smb_buffer_response) <= -+ BCC(smb_buffer_response)) { -+ if(tcon->nativeFileSystem) -+ kfree(tcon->nativeFileSystem); -+ tcon->nativeFileSystem = -+ cifs_kcalloc(length + 1, GFP_KERNEL); -+ strncpy(tcon->nativeFileSystem, bcc_ptr, -+ length); -+ } -+ /* else do not bother copying these informational fields */ -+ } -+ tcon->Flags = le16_to_cpu(pSMBr->OptionalSupport); -+ cFYI(1, ("Tcon flags: 0x%x ", tcon->Flags)); -+ } else if ((rc == 0) && tcon == NULL) { -+ /* all we need to save for IPC$ connection */ -+ ses->ipc_tid = smb_buffer_response->Tid; -+ } -+ -+ if (smb_buffer) -+ cifs_buf_release(smb_buffer); -+ return rc; -+} -+ -+int -+cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb) -+{ -+ int rc = 0; -+ int xid; -+ struct cifsSesInfo *ses = NULL; -+ struct task_struct *cifsd_task; -+ -+ xid = GetXid(); -+ -+ if (cifs_sb->tcon) { -+ ses = cifs_sb->tcon->ses; /* save ptr to ses before delete tcon!*/ -+ rc = CIFSSMBTDis(xid, cifs_sb->tcon); -+ if (rc == -EBUSY) { -+ FreeXid(xid); -+ return 0; -+ } -+ tconInfoFree(cifs_sb->tcon); -+ if ((ses) && (ses->server)) { -+ /* save off task so we do not refer to ses later */ -+ cifsd_task = ses->server->tsk; -+ cFYI(1, ("About to do SMBLogoff ")); -+ rc = CIFSSMBLogoff(xid, ses); -+ if (rc == -EBUSY) { -+ FreeXid(xid); -+ return 0; -+ } else if (rc == -ESHUTDOWN) { -+ cFYI(1,("Waking up socket by sending it signal")); -+ send_sig(SIGKILL,cifsd_task,1); -+ rc = 0; -+ } /* else - we have an smb session -+ left on this socket do not kill cifsd */ -+ } else -+ cFYI(1, ("No session or bad tcon")); -+ } -+ -+ cifs_sb->tcon = NULL; -+ if (ses) { -+ set_current_state(TASK_INTERRUPTIBLE); -+ schedule_timeout(HZ / 2); -+ } -+ if (ses) -+ sesInfoFree(ses); -+ -+ FreeXid(xid); -+ return rc; /* BB check if we should always return zero here */ -+} -+ -+int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, -+ struct nls_table * nls_info) -+{ -+ int rc = 0; -+ char ntlm_session_key[CIFS_SESSION_KEY_SIZE]; -+ int ntlmv2_flag = FALSE; -+ -+ /* what if server changes its buffer size after dropping the session? */ -+ if(pSesInfo->server->maxBuf == 0) /* no need to send on reconnect */ { -+ rc = CIFSSMBNegotiate(xid, pSesInfo); -+ if(rc == -EAGAIN) /* retry only once on 1st time connection */ { -+ rc = CIFSSMBNegotiate(xid, pSesInfo); -+ if(rc == -EAGAIN) -+ rc = -EHOSTDOWN; -+ } -+ if(rc == 0) { -+ spin_lock(&GlobalMid_Lock); -+ if(pSesInfo->server->tcpStatus != CifsExiting) -+ pSesInfo->server->tcpStatus = CifsGood; -+ else -+ rc = -EHOSTDOWN; -+ spin_unlock(&GlobalMid_Lock); -+ -+ } -+ } -+ if (!rc) { -+ pSesInfo->capabilities = pSesInfo->server->capabilities; -+ if(linuxExtEnabled == 0) -+ pSesInfo->capabilities &= (~CAP_UNIX); -+ pSesInfo->sequence_number = 0; -+ cFYI(1,("Security Mode: 0x%x Capabilities: 0x%x Time Zone: %d", -+ pSesInfo->server->secMode, -+ pSesInfo->server->capabilities, -+ pSesInfo->server->timeZone)); -+ if (extended_security -+ && (pSesInfo->capabilities & CAP_EXTENDED_SECURITY) -+ && (pSesInfo->server->secType == NTLMSSP)) { -+ cFYI(1, ("New style sesssetup ")); -+ rc = CIFSSpnegoSessSetup(xid, pSesInfo, -+ NULL /* security blob */, -+ 0 /* blob length */, -+ nls_info); -+ } else if (extended_security -+ && (pSesInfo->capabilities & CAP_EXTENDED_SECURITY) -+ && (pSesInfo->server->secType == RawNTLMSSP)) { -+ cFYI(1, ("NTLMSSP sesssetup ")); -+ rc = CIFSNTLMSSPNegotiateSessSetup(xid, -+ pSesInfo, -+ &ntlmv2_flag, -+ nls_info); -+ if (!rc) { -+ if(ntlmv2_flag) { -+ char * v2_response; -+ cFYI(1,("Can use more secure NTLM version 2 password hash")); -+ CalcNTLMv2_partial_mac_key(pSesInfo, -+ nls_info); -+ v2_response = kmalloc(16 + 64 /* blob */, GFP_KERNEL); -+ if(v2_response) { -+ CalcNTLMv2_response(pSesInfo,v2_response); -+/* cifs_calculate_ntlmv2_mac_key(pSesInfo->mac_signing_key, response, ntlm_session_key, */ -+ kfree(v2_response); -+ /* BB Put dummy sig in SessSetup PDU? */ -+ } else -+ rc = -ENOMEM; -+ -+ } else { -+ SMBNTencrypt(pSesInfo->password, -+ pSesInfo->server->cryptKey, -+ ntlm_session_key); -+ -+ cifs_calculate_mac_key(pSesInfo->mac_signing_key, -+ ntlm_session_key, -+ pSesInfo->password); -+ } -+ /* for better security the weaker lanman hash not sent -+ in AuthSessSetup so we no longer calculate it */ -+ -+ rc = CIFSNTLMSSPAuthSessSetup(xid, -+ pSesInfo, -+ ntlm_session_key, -+ ntlmv2_flag, -+ nls_info); -+ } -+ } else { /* old style NTLM 0.12 session setup */ -+ SMBNTencrypt(pSesInfo->password, -+ pSesInfo->server->cryptKey, -+ ntlm_session_key); -+ -+ cifs_calculate_mac_key(pSesInfo->mac_signing_key, -+ ntlm_session_key, pSesInfo->password); -+ rc = CIFSSessSetup(xid, pSesInfo, -+ ntlm_session_key, nls_info); -+ } -+ if (rc) { -+ cERROR(1,("Send error in SessSetup = %d",rc)); -+ } else { -+ cFYI(1,("CIFS Session Established successfully")); -+ pSesInfo->status = CifsGood; -+ } -+ } -+ return rc; -+} -+ ---- /dev/null -+++ b/fs/cifs/dir.c -@@ -0,0 +1,425 @@ -+/* -+ * fs/cifs/dir.c -+ * -+ * vfs operations that deal with dentries -+ * -+ * Copyright (C) International Business Machines Corp., 2002,2003 -+ * Author(s): Steve French (sfrench@us.ibm.com) -+ * -+ * This library is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU Lesser General Public License as published -+ * by the Free Software Foundation; either version 2.1 of the License, or -+ * (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -+ * the GNU Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public License -+ * along with this library; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ */ -+#include <linux/fs.h> -+#include <linux/stat.h> -+#include <linux/slab.h> -+#include "cifsfs.h" -+#include "cifspdu.h" -+#include "cifsglob.h" -+#include "cifsproto.h" -+#include "cifs_debug.h" -+#include "cifs_fs_sb.h" -+ -+void -+renew_parental_timestamps(struct dentry *direntry) -+{ -+ /* BB check if there is a way to get the kernel to do this or if we really need this */ -+ do { -+ direntry->d_time = jiffies; -+ direntry = direntry->d_parent; -+ } while (!IS_ROOT(direntry)); -+} -+ -+/* Note: caller must free return buffer */ -+char * -+build_path_from_dentry(struct dentry *direntry) -+{ -+ struct dentry *temp; -+ int namelen = 0; -+ char *full_path; -+ -+ if(direntry == NULL) -+ return NULL; /* not much we can do if dentry is freed and -+ we need to reopen the file after it was closed implicitly -+ when the server crashed */ -+ -+cifs_bp_rename_retry: -+ for (temp = direntry; !IS_ROOT(temp);) { -+ namelen += (1 + temp->d_name.len); -+ temp = temp->d_parent; -+ if(temp == NULL) { -+ cERROR(1,("corrupt dentry")); -+ return NULL; -+ } -+ } -+ -+ full_path = kmalloc(namelen+1, GFP_KERNEL); -+ if(full_path == NULL) -+ return full_path; -+ full_path[namelen] = 0; /* trailing null */ -+ -+ for (temp = direntry; !IS_ROOT(temp);) { -+ namelen -= 1 + temp->d_name.len; -+ if (namelen < 0) { -+ break; -+ } else { -+ full_path[namelen] = '\\'; -+ strncpy(full_path + namelen + 1, temp->d_name.name, -+ temp->d_name.len); -+ cFYI(0, (" name: %s ", full_path + namelen)); -+ } -+ temp = temp->d_parent; -+ if(temp == NULL) { -+ cERROR(1,("corrupt dentry")); -+ kfree(full_path); -+ return NULL; -+ } -+ } -+ if (namelen != 0) { -+ cERROR(1, -+ ("We did not end path lookup where we expected namelen is %d", -+ namelen)); -+ /* presumably this is only possible if we were racing with a rename -+ of one of the parent directories (we can not lock the dentries -+ above us to prevent this, but retrying should be harmless) */ -+ kfree(full_path); -+ namelen = 0; -+ goto cifs_bp_rename_retry; -+ } -+ -+ return full_path; -+} -+ -+/* Note: caller must free return buffer */ -+char * -+build_wildcard_path_from_dentry(struct dentry *direntry) -+{ -+ struct dentry *temp; -+ int namelen = 0; -+ char *full_path; -+ -+ if(direntry == NULL) -+ return NULL; /* not much we can do if dentry is freed and -+ we need to reopen the file after it was closed implicitly -+ when the server crashed */ -+ -+cifs_bwp_rename_retry: -+ for (temp = direntry; !IS_ROOT(temp);) { -+ namelen += (1 + temp->d_name.len); -+ temp = temp->d_parent; -+ if(temp == NULL) { -+ cERROR(1,("corrupt dentry")); -+ return NULL; -+ } -+ } -+ -+ full_path = kmalloc(namelen+3, GFP_KERNEL); -+ if(full_path == NULL) -+ return full_path; -+ -+ full_path[namelen] = '\\'; -+ full_path[namelen+1] = '*'; -+ full_path[namelen+2] = 0; /* trailing null */ -+ -+ for (temp = direntry; !IS_ROOT(temp);) { -+ namelen -= 1 + temp->d_name.len; -+ if (namelen < 0) { -+ break; -+ } else { -+ full_path[namelen] = '\\'; -+ strncpy(full_path + namelen + 1, temp->d_name.name, -+ temp->d_name.len); -+ cFYI(0, (" name: %s ", full_path + namelen)); -+ } -+ temp = temp->d_parent; -+ if(temp == NULL) { -+ cERROR(1,("corrupt dentry")); -+ kfree(full_path); -+ return NULL; -+ } -+ } -+ if (namelen != 0) { -+ cERROR(1, -+ ("We did not end path lookup where we expected namelen is %d", -+ namelen)); -+ /* presumably this is only possible if we were racing with a rename -+ of one of the parent directories (we can not lock the dentries -+ above us to prevent this, but retrying should be harmless) */ -+ kfree(full_path); -+ namelen = 0; -+ goto cifs_bwp_rename_retry; -+ } -+ -+ return full_path; -+} -+ -+/* Inode operations in similar order to how they appear in the Linux file fs.h */ -+ -+int -+cifs_create(struct inode *inode, struct dentry *direntry, int mode) -+{ -+ int rc = -ENOENT; -+ int xid; -+ int oplock = 0; /* no sense requested oplock if we are just going to -+ immediately close the file */ -+ __u16 fileHandle; -+ struct cifs_sb_info *cifs_sb; -+ struct cifsTconInfo *pTcon; -+ char *full_path = NULL; -+ FILE_ALL_INFO * buf = NULL; -+ struct inode *newinode = NULL; -+ -+ xid = GetXid(); -+ -+ cifs_sb = CIFS_SB(inode->i_sb); -+ pTcon = cifs_sb->tcon; -+ -+ down(&direntry->d_sb->s_vfs_rename_sem); -+ full_path = build_path_from_dentry(direntry); -+ up(&direntry->d_sb->s_vfs_rename_sem); -+ if(full_path == NULL) { -+ FreeXid(xid); -+ return -ENOMEM; -+ } -+ -+ /* BB add processing to set equivalent of mode - e.g. via CreateX with ACLs */ -+ -+ buf = kmalloc(sizeof(FILE_ALL_INFO),GFP_KERNEL); -+ rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OVERWRITE_IF, -+ GENERIC_WRITE, CREATE_NOT_DIR, -+ &fileHandle, &oplock, buf, cifs_sb->local_nls); -+ if (rc) { -+ cFYI(1, ("cifs_create returned 0x%x ", rc)); -+ } else { -+ /* BB for case of overwriting existing file can we use the inode that was -+ passed in rather than creating new one?? */ -+ if (pTcon->ses->capabilities & CAP_UNIX) -+ rc = cifs_get_inode_info_unix(&newinode, full_path, -+ inode->i_sb,xid); -+ else -+ rc = cifs_get_inode_info(&newinode, full_path, -+ buf, inode->i_sb,xid); -+ -+ if (rc != 0) { -+ cFYI(1,("Create worked but get_inode_info failed with rc = %d", -+ rc)); -+ } else { -+ direntry->d_op = &cifs_dentry_ops; -+ d_instantiate(direntry, newinode); -+ } -+ CIFSSMBClose(xid, pTcon, fileHandle); -+ -+ if(newinode) { -+ newinode->i_mode = mode; -+ if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) -+ CIFSSMBUnixSetPerms(xid, pTcon, full_path, inode->i_mode, -+ (__u64)-1, -+ (__u64)-1, -+ 0 /* dev */, -+ cifs_sb->local_nls); -+ else { /* BB implement via Windows security descriptors */ -+ /* eg CIFSSMBWinSetPerms(xid,pTcon,full_path,mode,-1,-1,local_nls);*/ -+ /* in the meantime could set r/o dos attribute when perms are eg: -+ mode & 0222 == 0 */ -+ } -+ } -+ } -+ -+ if (buf) -+ kfree(buf); -+ if (full_path) -+ kfree(full_path); -+ FreeXid(xid); -+ -+ return rc; -+} -+ -+int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, int device_number) -+{ -+ int rc = -EPERM; -+ int xid; -+ struct cifs_sb_info *cifs_sb; -+ struct cifsTconInfo *pTcon; -+ char *full_path = NULL; -+ struct inode * newinode = NULL; -+ -+ xid = GetXid(); -+ -+ cifs_sb = CIFS_SB(inode->i_sb); -+ pTcon = cifs_sb->tcon; -+ -+ down(&direntry->d_sb->s_vfs_rename_sem); -+ full_path = build_path_from_dentry(direntry); -+ up(&direntry->d_sb->s_vfs_rename_sem); -+ if(full_path == NULL) -+ rc = -ENOMEM; -+ -+ if (full_path && (pTcon->ses->capabilities & CAP_UNIX)) { -+ rc = CIFSSMBUnixSetPerms(xid, pTcon, -+ full_path, mode, current->euid, current->egid, -+ device_number, cifs_sb->local_nls); -+ if(!rc) { -+ rc = cifs_get_inode_info_unix(&newinode, full_path, -+ inode->i_sb,xid); -+ direntry->d_op = &cifs_dentry_ops; -+ if(rc == 0) -+ d_instantiate(direntry, newinode); -+ } -+ } -+ -+ if (full_path) -+ kfree(full_path); -+ FreeXid(xid); -+ -+ return rc; -+} -+ -+ -+struct dentry * -+cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry) -+{ -+ int xid; -+ int rc = 0; /* to get around spurious gcc warning, set to zero here */ -+ struct cifs_sb_info *cifs_sb; -+ struct cifsTconInfo *pTcon; -+ struct inode *newInode = NULL; -+ char *full_path = NULL; -+ -+ xid = GetXid(); -+ -+ cFYI(1, -+ (" parent inode = 0x%p name is: %s and dentry = 0x%p", -+ parent_dir_inode, direntry->d_name.name, direntry)); -+ -+ /* BB Add check of incoming data - e.g. frame not longer than maximum SMB - let server check the namelen BB */ -+ -+ /* check whether path exists */ -+ -+ cifs_sb = CIFS_SB(parent_dir_inode->i_sb); -+ pTcon = cifs_sb->tcon; -+ -+ /* can not grab the rename sem here since it would -+ deadlock in the cases (beginning of sys_rename itself) -+ in which we already have the sb rename sem */ -+ full_path = build_path_from_dentry(direntry); -+ if(full_path == NULL) { -+ FreeXid(xid); -+ return ERR_PTR(-ENOMEM); -+ } -+ -+ if (direntry->d_inode != NULL) { -+ cFYI(1, (" non-NULL inode in lookup")); -+ } else { -+ cFYI(1, (" NULL inode in lookup")); -+ } -+ cFYI(1, -+ (" Full path: %s inode = 0x%p", full_path, direntry->d_inode)); -+ -+ if (pTcon->ses->capabilities & CAP_UNIX) -+ rc = cifs_get_inode_info_unix(&newInode, full_path, -+ parent_dir_inode->i_sb,xid); -+ else -+ rc = cifs_get_inode_info(&newInode, full_path, NULL, -+ parent_dir_inode->i_sb,xid); -+ -+ if ((rc == 0) && (newInode != NULL)) { -+ direntry->d_op = &cifs_dentry_ops; -+ d_add(direntry, newInode); -+ -+ /* since paths are not looked up by component - the parent directories are presumed to be good here */ -+ renew_parental_timestamps(direntry); -+ -+ } else if (rc == -ENOENT) { -+ rc = 0; -+ d_add(direntry, NULL); -+ } else { -+ cERROR(1,("Error 0x%x or on cifs_get_inode_info in lookup",rc)); -+ /* BB special case check for Access Denied - watch security -+ exposure of returning dir info implicitly via different rc -+ if file exists or not but no access BB */ -+ } -+ -+ if (full_path) -+ kfree(full_path); -+ FreeXid(xid); -+ return ERR_PTR(rc); -+} -+ -+int -+cifs_dir_open(struct inode *inode, struct file *file) -+{ /* NB: currently unused since searches are opened in readdir */ -+ int rc = 0; -+ int xid; -+ struct cifs_sb_info *cifs_sb; -+ struct cifsTconInfo *pTcon; -+ char *full_path = NULL; -+ -+ xid = GetXid(); -+ -+ cifs_sb = CIFS_SB(inode->i_sb); -+ pTcon = cifs_sb->tcon; -+ -+ if(file->f_dentry) { -+ down(&file->f_dentry->d_sb->s_vfs_rename_sem); -+ full_path = build_wildcard_path_from_dentry(file->f_dentry); -+ up(&file->f_dentry->d_sb->s_vfs_rename_sem); -+ } else { -+ FreeXid(xid); -+ return -EIO; -+ } -+ -+ cFYI(1, ("inode = 0x%p and full path is %s", inode, full_path)); -+ -+ if (full_path) -+ kfree(full_path); -+ FreeXid(xid); -+ return rc; -+} -+ -+static int -+cifs_d_revalidate(struct dentry *direntry, int flags) -+{ -+ int isValid = 1; -+ -+/* lock_kernel(); *//* surely we do not want to lock the kernel for a whole network round trip which could take seconds */ -+ -+ if (direntry->d_inode) { -+ if (cifs_revalidate(direntry)) { -+ /* unlock_kernel(); */ -+ return 0; -+ } -+ } else { -+ cFYI(1, -+ ("In cifs_d_revalidate with no inode but name = %s and dentry 0x%p", -+ direntry->d_name.name, direntry)); -+ } -+ -+/* unlock_kernel(); */ -+ -+ return isValid; -+} -+ -+/* static int cifs_d_delete(struct dentry *direntry) -+{ -+ int rc = 0; -+ -+ cFYI(1, ("In cifs d_delete, name = %s", direntry->d_name.name)); -+ -+ return rc; -+} */ -+ -+struct dentry_operations cifs_dentry_ops = { -+ .d_revalidate = cifs_d_revalidate, -+/* d_delete: cifs_d_delete, *//* not needed except for debugging */ -+ /* no need for d_hash, d_compare, d_release, d_iput ... yet. BB confirm this BB */ -+}; ---- /dev/null -+++ b/fs/cifs/file.c -@@ -0,0 +1,2185 @@ -+/* -+ * fs/cifs/file.c -+ * -+ * vfs operations that deal with files -+ * -+ * Copyright (C) International Business Machines Corp., 2002,2003 -+ * Author(s): Steve French (sfrench@us.ibm.com) -+ * -+ * This library is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU Lesser General Public License as published -+ * by the Free Software Foundation; either version 2.1 of the License, or -+ * (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -+ * the GNU Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public License -+ * along with this library; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ */ -+#include <linux/fs.h> -+#include <linux/stat.h> -+#include <linux/fcntl.h> -+#include <linux/version.h> -+#include <linux/pagemap.h> -+#include <linux/smp_lock.h> -+#include <linux/list.h> -+#include <asm/div64.h> -+#include <linux/mm.h> -+#include <linux/types.h> -+#include "cifsfs.h" -+#include "cifspdu.h" -+#include "cifsglob.h" -+#include "cifsproto.h" -+#include "cifs_unicode.h" -+#include "cifs_debug.h" -+#include "cifs_fs_sb.h" -+ -+int -+cifs_open(struct inode *inode, struct file *file) -+{ -+ int rc = -EACCES; -+ int xid, oplock; -+ struct cifs_sb_info *cifs_sb; -+ struct cifsTconInfo *pTcon; -+ struct cifsFileInfo *pCifsFile; -+ struct cifsInodeInfo *pCifsInode; -+ char *full_path = NULL; -+ int desiredAccess = 0x20197; -+ int disposition; -+ __u16 netfid; -+ FILE_ALL_INFO * buf = NULL; -+ time_t temp; -+ -+ xid = GetXid(); -+ -+ cifs_sb = CIFS_SB(inode->i_sb); -+ pTcon = cifs_sb->tcon; -+ -+ down(&inode->i_sb->s_vfs_rename_sem); -+ full_path = build_path_from_dentry(file->f_dentry); -+ up(&inode->i_sb->s_vfs_rename_sem); -+ if(full_path == NULL) { -+ FreeXid(xid); -+ return -ENOMEM; -+ } -+ -+ cFYI(1, (" inode = 0x%p file flags are 0x%x for %s", inode, file->f_flags,full_path)); -+ if ((file->f_flags & O_ACCMODE) == O_RDONLY) -+ desiredAccess = GENERIC_READ; -+ else if ((file->f_flags & O_ACCMODE) == O_WRONLY) -+ desiredAccess = GENERIC_WRITE; -+ else if ((file->f_flags & O_ACCMODE) == O_RDWR) { -+ /* GENERIC_ALL is too much permission to request */ -+ /* can cause unnecessary access denied on create */ -+ /* desiredAccess = GENERIC_ALL; */ -+ desiredAccess = GENERIC_READ | GENERIC_WRITE; -+ } -+ -+/********************************************************************* -+ * open flag mapping table: -+ * -+ * POSIX Flag CIFS Disposition -+ * ---------- ---------------- -+ * O_CREAT FILE_OPEN_IF -+ * O_CREAT | O_EXCL FILE_CREATE -+ * O_CREAT | O_TRUNC FILE_OVERWRITE_IF -+ * O_TRUNC FILE_OVERWRITE -+ * none of the above FILE_OPEN -+ * -+ * Note that there is not a direct match between disposition -+ * FILE_SUPERSEDE (ie create whether or not file exists although -+ * O_CREAT | O_TRUNC is similar but truncates the existing -+ * file rather than creating a new file as FILE_SUPERSEDE does -+ * (which uses the attributes / metadata passed in on open call) -+ *? -+ *? O_SYNC is a reasonable match to CIFS writethrough flag -+ *? and the read write flags match reasonably. O_LARGEFILE -+ *? is irrelevant because largefile support is always used -+ *? by this client. Flags O_APPEND, O_DIRECT, O_DIRECTORY, -+ * O_FASYNC, O_NOFOLLOW, O_NONBLOCK need further investigation -+ *********************************************************************/ -+ -+ /* For 2.4 case, file was already checked for existence -+ before create by vfs lookup and created in create -+ entry point, we are now just opening the newly -+ created file with the right desiredAccess flags */ -+ -+ if((file->f_flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) -+ disposition = FILE_OPEN_IF; -+ else if((file->f_flags & (O_CREAT | O_TRUNC)) == (O_CREAT | O_TRUNC)) -+ disposition = FILE_OVERWRITE_IF; -+ else if((file->f_flags & O_CREAT) == O_CREAT) -+ disposition = FILE_OPEN_IF; -+ else -+ disposition = FILE_OPEN; -+ -+ if (oplockEnabled) -+ oplock = REQ_OPLOCK; -+ else -+ oplock = FALSE; -+ -+ /* BB pass O_SYNC flag through on file attributes .. BB */ -+ -+ /* Also refresh inode by passing in file_info buf returned by SMBOpen -+ and calling get_inode_info with returned buf (at least -+ helps non-Unix server case */ -+ -+ /* BB we can not do this if this is the second open of a file -+ and the first handle has writebehind data, we might be -+ able to simply do a filemap_fdatawrite/filemap_fdatawait first */ -+ buf = kmalloc(sizeof(FILE_ALL_INFO),GFP_KERNEL); -+ if(buf==0) { -+ if (full_path) -+ kfree(full_path); -+ FreeXid(xid); -+ return -ENOMEM; -+ } -+ rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, desiredAccess, -+ CREATE_NOT_DIR, &netfid, &oplock, buf, cifs_sb->local_nls); -+ if (rc) { -+ cFYI(1, ("cifs_open returned 0x%x ", rc)); -+ cFYI(1, ("oplock: %d ", oplock)); -+ } else { -+ file->private_data = -+ kmalloc(sizeof (struct cifsFileInfo), GFP_KERNEL); -+ if (file->private_data) { -+ memset(file->private_data, 0, sizeof(struct cifsFileInfo)); -+ pCifsFile = (struct cifsFileInfo *) file->private_data; -+ pCifsFile->netfid = netfid; -+ pCifsFile->pid = current->pid; -+ init_MUTEX(&pCifsFile->fh_sem); -+ pCifsFile->pfile = file; /* needed for writepage */ -+ pCifsFile->pInode = inode; -+ pCifsFile->invalidHandle = FALSE; -+ pCifsFile->closePend = FALSE; -+ write_lock(&GlobalSMBSeslock); -+ spin_lock(&files_lock); -+ list_add(&pCifsFile->tlist,&pTcon->openFileList); -+ pCifsInode = CIFS_I(file->f_dentry->d_inode); -+ if(pCifsInode) { -+ /* want handles we can use to read with first */ -+ /* in the list so we do not have to walk the */ -+ /* list to search for one in prepare_write */ -+ if ((file->f_flags & O_ACCMODE) == O_WRONLY) { -+ list_add_tail(&pCifsFile->flist,&pCifsInode->openFileList); -+ } else { -+ list_add(&pCifsFile->flist,&pCifsInode->openFileList); -+ } -+ spin_unlock(&files_lock); -+ write_unlock(&GlobalSMBSeslock); -+ if(pCifsInode->clientCanCacheRead) { -+ /* we have the inode open somewhere else -+ no need to discard cache data */ -+ } else { -+ if(buf) { -+ /* BB need same check in cifs_create too? */ -+ -+ /* if not oplocked, invalidate inode pages if mtime -+ or file size changed */ -+ temp = cifs_NTtimeToUnix(le64_to_cpu(buf->LastWriteTime)); -+ if((file->f_dentry->d_inode->i_mtime == temp) && -+ (file->f_dentry->d_inode->i_size == (loff_t)le64_to_cpu(buf->EndOfFile))) { -+ cFYI(1,("inode unchanged on server")); -+ } else { -+ if(file->f_dentry->d_inode->i_mapping) { -+ /* BB no need to lock inode until after invalidate*/ -+ /* since namei code should already have it locked?*/ -+ filemap_fdatasync(file->f_dentry->d_inode->i_mapping); -+ } -+ cFYI(1,("invalidating remote inode since open detected it changed")); -+ invalidate_inode_pages(file->f_dentry->d_inode); -+ } -+ } -+ } -+ if (pTcon->ses->capabilities & CAP_UNIX) -+ rc = cifs_get_inode_info_unix(&file->f_dentry->d_inode, -+ full_path, inode->i_sb,xid); -+ else -+ rc = cifs_get_inode_info(&file->f_dentry->d_inode, -+ full_path, buf, inode->i_sb,xid); -+ -+ if((oplock & 0xF) == OPLOCK_EXCLUSIVE) { -+ pCifsInode->clientCanCacheAll = TRUE; -+ pCifsInode->clientCanCacheRead = TRUE; -+ cFYI(1,("Exclusive Oplock granted on inode %p",file->f_dentry->d_inode)); -+ } else if((oplock & 0xF) == OPLOCK_READ) -+ pCifsInode->clientCanCacheRead = TRUE; -+ } else { -+ spin_unlock(&files_lock); -+ write_unlock(&GlobalSMBSeslock); -+ } -+ if(oplock & CIFS_CREATE_ACTION) { -+ /* time to set mode which we can not set earlier due -+ to problems creating new read-only files */ -+ if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) -+ CIFSSMBUnixSetPerms(xid, pTcon, full_path, inode->i_mode, -+ (__u64)-1, -+ (__u64)-1, -+ 0 /* dev */, -+ cifs_sb->local_nls); -+ else {/* BB implement via Windows security descriptors */ -+ /* eg CIFSSMBWinSetPerms(xid,pTcon,full_path,mode,-1,-1,local_nls);*/ -+ /* in the meantime could set r/o dos attribute when perms are eg: -+ mode & 0222 == 0 */ -+ } -+ } -+ } -+ } -+ -+ if (buf) -+ kfree(buf); -+ if (full_path) -+ kfree(full_path); -+ FreeXid(xid); -+ return rc; -+} -+ -+/* Try to reaquire byte range locks that were released when session */ -+/* to server was lost */ -+static int cifs_relock_file(struct cifsFileInfo * cifsFile) -+{ -+ int rc = 0; -+ -+/* BB list all locks open on this file and relock */ -+ -+ return rc; -+} -+ -+static int cifs_reopen_file(struct inode *inode, struct file *file, int can_flush) -+{ -+ int rc = -EACCES; -+ int xid, oplock; -+ struct cifs_sb_info *cifs_sb; -+ struct cifsTconInfo *pTcon; -+ struct cifsFileInfo *pCifsFile; -+ struct cifsInodeInfo *pCifsInode; -+ char *full_path = NULL; -+ int desiredAccess = 0x20197; -+ int disposition = FILE_OPEN; -+ __u16 netfid; -+ -+ if(inode == NULL) -+ return -EBADF; -+ if (file->private_data) { -+ pCifsFile = (struct cifsFileInfo *) file->private_data; -+ } else -+ return -EBADF; -+ -+ xid = GetXid(); -+ down(&pCifsFile->fh_sem); -+ if(pCifsFile->invalidHandle == FALSE) { -+ up(&pCifsFile->fh_sem); -+ FreeXid(xid); -+ return 0; -+ } -+ -+ if(file->f_dentry == NULL) { -+ up(&pCifsFile->fh_sem); -+ cFYI(1,("failed file reopen, no valid name if dentry freed")); -+ FreeXid(xid); -+ return -EBADF; -+ } -+ cifs_sb = CIFS_SB(inode->i_sb); -+ pTcon = cifs_sb->tcon; -+/* can not grab rename sem here because various ops, including -+those that already have the rename sem can end up causing writepage -+to get called and if the server was down that means we end up here, -+and we can never tell if the caller already has the rename_sem */ -+ full_path = build_path_from_dentry(file->f_dentry); -+ if(full_path == NULL) { -+ up(&pCifsFile->fh_sem); -+ FreeXid(xid); -+ return -ENOMEM; -+ } -+ -+ cFYI(1, (" inode = 0x%p file flags are 0x%x for %s", inode, file->f_flags,full_path)); -+ if ((file->f_flags & O_ACCMODE) == O_RDONLY) -+ desiredAccess = GENERIC_READ; -+ else if ((file->f_flags & O_ACCMODE) == O_WRONLY) -+ desiredAccess = GENERIC_WRITE; -+ else if ((file->f_flags & O_ACCMODE) == O_RDWR) { -+ /* GENERIC_ALL is too much permission to request */ -+ /* can cause unnecessary access denied on create */ -+ /* desiredAccess = GENERIC_ALL; */ -+ desiredAccess = GENERIC_READ | GENERIC_WRITE; -+ } -+ -+ if (oplockEnabled) -+ oplock = REQ_OPLOCK; -+ else -+ oplock = FALSE; -+ -+ -+ /* Can not refresh inode by passing in file_info buf to be returned -+ by SMBOpen and then calling get_inode_info with returned buf -+ since file might have write behind data that needs to be flushed -+ and server version of file size can be stale. If we -+ knew for sure that inode was not dirty locally we could do this */ -+ -+/* buf = kmalloc(sizeof(FILE_ALL_INFO),GFP_KERNEL); -+ if(buf==0) { -+ up(&pCifsFile->fh_sem); -+ if (full_path) -+ kfree(full_path); -+ FreeXid(xid); -+ return -ENOMEM; -+ }*/ -+ rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, desiredAccess, -+ CREATE_NOT_DIR, &netfid, &oplock, NULL, cifs_sb->local_nls); -+ if (rc) { -+ up(&pCifsFile->fh_sem); -+ cFYI(1, ("cifs_open returned 0x%x ", rc)); -+ cFYI(1, ("oplock: %d ", oplock)); -+ } else { -+ pCifsFile->netfid = netfid; -+ pCifsFile->invalidHandle = FALSE; -+ up(&pCifsFile->fh_sem); -+ pCifsInode = CIFS_I(inode); -+ if(pCifsInode) { -+ if(can_flush) { -+ filemap_fdatasync(inode->i_mapping); -+ filemap_fdatawait(inode->i_mapping); -+ /* temporarily disable caching while we -+ go to server to get inode info */ -+ pCifsInode->clientCanCacheAll = FALSE; -+ pCifsInode->clientCanCacheRead = FALSE; -+ if (pTcon->ses->capabilities & CAP_UNIX) -+ rc = cifs_get_inode_info_unix(&inode, -+ full_path, inode->i_sb,xid); -+ else -+ rc = cifs_get_inode_info(&inode, -+ full_path, NULL, inode->i_sb,xid); -+ } /* else we are writing out data to server already -+ and could deadlock if we tried to flush data, and -+ since we do not know if we have data that would -+ invalidate the current end of file on the server -+ we can not go to the server to get the new -+ inod info */ -+ if((oplock & 0xF) == OPLOCK_EXCLUSIVE) { -+ pCifsInode->clientCanCacheAll = TRUE; -+ pCifsInode->clientCanCacheRead = TRUE; -+ cFYI(1,("Exclusive Oplock granted on inode %p",file->f_dentry->d_inode)); -+ } else if((oplock & 0xF) == OPLOCK_READ) { -+ pCifsInode->clientCanCacheRead = TRUE; -+ pCifsInode->clientCanCacheAll = FALSE; -+ } else { -+ pCifsInode->clientCanCacheRead = FALSE; -+ pCifsInode->clientCanCacheAll = FALSE; -+ } -+ cifs_relock_file(pCifsFile); -+ } -+ } -+ -+ if (full_path) -+ kfree(full_path); -+ FreeXid(xid); -+ return rc; -+} -+ -+int -+cifs_close(struct inode *inode, struct file *file) -+{ -+ int rc = 0; -+ int xid; -+ struct cifs_sb_info *cifs_sb; -+ struct cifsTconInfo *pTcon; -+ struct cifsFileInfo *pSMBFile = -+ (struct cifsFileInfo *) file->private_data; -+ -+ xid = GetXid(); -+ -+ cifs_sb = CIFS_SB(inode->i_sb); -+ pTcon = cifs_sb->tcon; -+ if (pSMBFile) { -+ pSMBFile->closePend = TRUE; -+ spin_lock(&files_lock); -+ if(pTcon) { -+ /* no sense reconnecting to close a file that is -+ already closed */ -+ if (pTcon->tidStatus != CifsNeedReconnect) { -+ spin_unlock(&files_lock); -+ rc = CIFSSMBClose(xid,pTcon,pSMBFile->netfid); -+ spin_lock(&files_lock); -+ } -+ } -+ list_del(&pSMBFile->flist); -+ list_del(&pSMBFile->tlist); -+ spin_unlock(&files_lock); -+ if(pSMBFile->search_resume_name) -+ kfree(pSMBFile->search_resume_name); -+ kfree(file->private_data); -+ file->private_data = NULL; -+ } else -+ rc = -EBADF; -+ -+ if(list_empty(&(CIFS_I(inode)->openFileList))) { -+ cFYI(1,("closing last open instance for inode %p",inode)); -+ /* if the file is not open we do not know if we can cache -+ info on this inode, much less write behind and read ahead */ -+ CIFS_I(inode)->clientCanCacheRead = FALSE; -+ CIFS_I(inode)->clientCanCacheAll = FALSE; -+ } -+ if((rc ==0) && CIFS_I(inode)->write_behind_rc) -+ rc = CIFS_I(inode)->write_behind_rc; -+ FreeXid(xid); -+ return rc; -+} -+ -+int -+cifs_closedir(struct inode *inode, struct file *file) -+{ -+ int rc = 0; -+ int xid; -+ struct cifsFileInfo *pSMBFileStruct = -+ (struct cifsFileInfo *) file->private_data; -+ -+ cFYI(1, ("Closedir inode = 0x%p with ", inode)); -+ -+ xid = GetXid(); -+ -+ if (pSMBFileStruct) { -+ cFYI(1, ("Freeing private data in close dir")); -+ kfree(file->private_data); -+ file->private_data = NULL; -+ } -+ FreeXid(xid); -+ return rc; -+} -+ -+int -+cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) -+{ -+ int rc, xid; -+ __u32 lockType = LOCKING_ANDX_LARGE_FILES; -+ __u32 numLock = 0; -+ __u32 numUnlock = 0; -+ __u64 length; -+ int wait_flag = FALSE; -+ struct cifs_sb_info *cifs_sb; -+ struct cifsTconInfo *pTcon; -+ length = 1 + pfLock->fl_end - pfLock->fl_start; -+ -+ rc = -EACCES; -+ -+ xid = GetXid(); -+ -+ cFYI(1, -+ ("Lock parm: 0x%x flockflags: 0x%x flocktype: 0x%x start: %lld end: %lld", -+ cmd, pfLock->fl_flags, pfLock->fl_type, pfLock->fl_start, -+ pfLock->fl_end)); -+ -+ if (pfLock->fl_flags & FL_POSIX) -+ cFYI(1, ("Posix ")); -+ if (pfLock->fl_flags & FL_FLOCK) -+ cFYI(1, ("Flock ")); -+/* if (pfLock->fl_flags & FL_SLEEP) { -+ cFYI(1, ("Blocking lock ")); -+ wait_flag = TRUE; -+ } */ -+ if (pfLock->fl_flags & FL_ACCESS) -+ cFYI(1, ("Process suspended by mandatory locking - not implemented yet ")); -+ if (pfLock->fl_flags & FL_LEASE) -+ cFYI(1, ("Lease on file - not implemented yet")); -+ if (pfLock->fl_flags & (~(FL_POSIX | FL_FLOCK | FL_ACCESS | FL_LEASE))) -+ cFYI(1, ("Unknown lock flags 0x%x",pfLock->fl_flags)); -+ -+ if (pfLock->fl_type == F_WRLCK) { -+ cFYI(1, ("F_WRLCK ")); -+ numLock = 1; -+ } else if (pfLock->fl_type == F_UNLCK) { -+ cFYI(1, ("F_UNLCK ")); -+ numUnlock = 1; -+ } else if (pfLock->fl_type == F_RDLCK) { -+ cFYI(1, ("F_RDLCK ")); -+ lockType |= LOCKING_ANDX_SHARED_LOCK; -+ numLock = 1; -+ } else if (pfLock->fl_type == F_EXLCK) { -+ cFYI(1, ("F_EXLCK ")); -+ numLock = 1; -+ } else if (pfLock->fl_type == F_SHLCK) { -+ cFYI(1, ("F_SHLCK ")); -+ lockType |= LOCKING_ANDX_SHARED_LOCK; -+ numLock = 1; -+ } else -+ cFYI(1, ("Unknown type of lock ")); -+ -+ cifs_sb = CIFS_SB(file->f_dentry->d_sb); -+ pTcon = cifs_sb->tcon; -+ -+ if (file->private_data == NULL) { -+ FreeXid(xid); -+ return -EBADF; -+ } -+ -+ if (IS_GETLK(cmd)) { -+ rc = CIFSSMBLock(xid, pTcon, -+ ((struct cifsFileInfo *) file-> -+ private_data)->netfid, -+ length, -+ pfLock->fl_start, 0, 1, lockType, -+ 0 /* wait flag */ ); -+ if (rc == 0) { -+ rc = CIFSSMBLock(xid, pTcon, -+ ((struct cifsFileInfo *) file-> -+ private_data)->netfid, -+ length, -+ pfLock->fl_start, 1 /* numUnlock */ , -+ 0 /* numLock */ , lockType, -+ 0 /* wait flag */ ); -+ pfLock->fl_type = F_UNLCK; -+ if (rc != 0) -+ cERROR(1, -+ ("Error unlocking previously locked range %d during test of lock ", -+ rc)); -+ rc = 0; -+ -+ } else { -+ /* if rc == ERR_SHARING_VIOLATION ? */ -+ rc = 0; /* do not change lock type to unlock since range in use */ -+ } -+ -+ FreeXid(xid); -+ return rc; -+ } -+ -+ rc = CIFSSMBLock(xid, pTcon, -+ ((struct cifsFileInfo *) file->private_data)-> -+ netfid, length, -+ pfLock->fl_start, numUnlock, numLock, lockType, -+ wait_flag); -+ FreeXid(xid); -+ return rc; -+} -+ -+ssize_t -+cifs_write(struct file * file, const char *write_data, -+ size_t write_size, loff_t * poffset) -+{ -+ int rc = 0; -+ unsigned int bytes_written = 0; -+ unsigned int total_written; -+ struct cifs_sb_info *cifs_sb; -+ struct cifsTconInfo *pTcon; -+ int xid, long_op; -+ struct cifsFileInfo * open_file; -+ -+ if(file->f_dentry == NULL) -+ return -EBADF; -+ -+ cifs_sb = CIFS_SB(file->f_dentry->d_sb); -+ if(cifs_sb == NULL) { -+ return -EBADF; -+ } -+ pTcon = cifs_sb->tcon; -+ -+ /*cFYI(1, -+ (" write %d bytes to offset %lld of %s", write_size, -+ *poffset, file->f_dentry->d_name.name)); */ -+ -+ if (file->private_data == NULL) { -+ return -EBADF; -+ } else { -+ open_file = (struct cifsFileInfo *) file->private_data; -+ } -+ -+ xid = GetXid(); -+ if(file->f_dentry->d_inode == NULL) { -+ FreeXid(xid); -+ return -EBADF; -+ } -+ -+ if (*poffset > file->f_dentry->d_inode->i_size) -+ long_op = 2; /* writes past end of file can take a long time */ -+ else -+ long_op = 1; -+ -+ for (total_written = 0; write_size > total_written; -+ total_written += bytes_written) { -+ rc = -EAGAIN; -+ while(rc == -EAGAIN) { -+ if(file->private_data == NULL) { -+ /* file has been closed on us */ -+ FreeXid(xid); -+ /* if we have gotten here we have written some data -+ and blocked, and the file has been freed on us -+ while we blocked so return what we managed to write */ -+ return total_written; -+ } -+ if(open_file->closePend) { -+ FreeXid(xid); -+ if(total_written) -+ return total_written; -+ else -+ return -EBADF; -+ } -+ if (open_file->invalidHandle) { -+ if((file->f_dentry == NULL) || -+ (file->f_dentry->d_inode == NULL)) { -+ FreeXid(xid); -+ return total_written; -+ } -+ /* we could deadlock if we called -+ filemap_fdatawait from here so tell -+ reopen_file not to flush data to server now */ -+ rc = cifs_reopen_file(file->f_dentry->d_inode, -+ file,FALSE); -+ if(rc != 0) -+ break; -+ } -+ -+ rc = CIFSSMBWrite(xid, pTcon, -+ open_file->netfid, -+ write_size - total_written, *poffset, -+ &bytes_written, -+ write_data + total_written, long_op); -+ } -+ if (rc || (bytes_written == 0)) { -+ if (total_written) -+ break; -+ else { -+ FreeXid(xid); -+ return rc; -+ } -+ } else -+ *poffset += bytes_written; -+ long_op = FALSE; /* subsequent writes fast - 15 seconds is plenty */ -+ } -+ -+#ifdef CONFIG_CIFS_STATS -+ if(total_written > 0) { -+ atomic_inc(&pTcon->num_writes); -+ spin_lock(&pTcon->stat_lock); -+ pTcon->bytes_written += total_written; -+ spin_unlock(&pTcon->stat_lock); -+ } -+#endif -+ -+ /* since the write may have blocked check these pointers again */ -+ if(file->f_dentry) { -+ if(file->f_dentry->d_inode) { -+ file->f_dentry->d_inode->i_ctime = file->f_dentry->d_inode->i_mtime = -+ CURRENT_TIME; -+ if (total_written > 0) { -+ if (*poffset > file->f_dentry->d_inode->i_size) -+ file->f_dentry->d_inode->i_size = *poffset; -+ } -+ mark_inode_dirty_sync(file->f_dentry->d_inode); -+ } -+ } -+ FreeXid(xid); -+ return total_written; -+} -+ -+static int -+cifs_partialpagewrite(struct page *page,unsigned from, unsigned to) -+{ -+ struct address_space *mapping = page->mapping; -+ loff_t offset = (loff_t)page->index << PAGE_CACHE_SHIFT; -+ char * write_data; -+ int rc = -EFAULT; -+ int bytes_written = 0; -+ struct cifs_sb_info *cifs_sb; -+ struct cifsTconInfo *pTcon; -+ struct inode *inode; -+ struct cifsInodeInfo *cifsInode; -+ struct cifsFileInfo *open_file = NULL; -+ struct list_head *tmp; -+ struct list_head *tmp1; -+ -+ if (!mapping) { -+ return -EFAULT; -+ } else if(!mapping->host) { -+ return -EFAULT; -+ } -+ -+ inode = page->mapping->host; -+ cifs_sb = CIFS_SB(inode->i_sb); -+ pTcon = cifs_sb->tcon; -+ -+ offset += (loff_t)from; -+ write_data = kmap(page); -+ write_data += from; -+ -+ if((to > PAGE_CACHE_SIZE) || (from > to)) { -+ kunmap(page); -+ return -EIO; -+ } -+ -+ /* racing with truncate? */ -+ if(offset > mapping->host->i_size) { -+ kunmap(page); -+ return 0; /* don't care */ -+ } -+ -+ /* check to make sure that we are not extending the file */ -+ if(mapping->host->i_size - offset < (loff_t)to) -+ to = (unsigned)(mapping->host->i_size - offset); -+ -+ -+ cifsInode = CIFS_I(mapping->host); -+ read_lock(&GlobalSMBSeslock); -+ /* BB we should start at the end */ -+ list_for_each_safe(tmp, tmp1, &cifsInode->openFileList) { -+ open_file = list_entry(tmp,struct cifsFileInfo, flist); -+ if(open_file->closePend) -+ continue; -+ /* We check if file is open for writing first */ -+ if((open_file->pfile) && -+ ((open_file->pfile->f_flags & O_RDWR) || -+ (open_file->pfile->f_flags & O_WRONLY))) { -+ read_unlock(&GlobalSMBSeslock); -+ bytes_written = cifs_write(open_file->pfile, write_data, -+ to-from, &offset); -+ read_lock(&GlobalSMBSeslock); -+ /* Does mm or vfs already set times? */ -+ inode->i_atime = inode->i_mtime = CURRENT_TIME; -+ if ((bytes_written > 0) && (offset)) { -+ rc = 0; -+ } else if(bytes_written < 0) { -+ if(rc == -EBADF) { -+ /* have seen a case in which -+ kernel seemed to have closed/freed a file -+ even with writes active so we might as well -+ see if there are other file structs to try -+ for the same inode before giving up */ -+ continue; -+ } else -+ rc = bytes_written; -+ } -+ break; /* now that we found a valid file handle -+ and tried to write to it we are done, no -+ sense continuing to loop looking for another */ -+ } -+ if(tmp->next == NULL) { -+ cFYI(1,("File instance %p removed",tmp)); -+ break; -+ } -+ } -+ read_unlock(&GlobalSMBSeslock); -+ if(open_file == NULL) { -+ cFYI(1,("No writeable filehandles for inode")); -+ rc = -EIO; -+ } -+ -+ kunmap(page); -+ return rc; -+} -+ -+#if 0 -+static int -+cifs_writepages(struct address_space *mapping, struct writeback_control *wbc) -+{ -+ int rc = -EFAULT; -+ int xid; -+ -+ xid = GetXid(); -+/* call 16K write then Setpageuptodate */ -+ FreeXid(xid); -+ return rc; -+} -+#endif -+ -+static int -+cifs_writepage(struct page* page) -+{ -+ int rc = -EFAULT; -+ int xid; -+ -+ xid = GetXid(); -+/* BB add check for wbc flags */ -+ page_cache_get(page); -+ if (!Page_Uptodate(page)) { -+ cFYI(1,("ppw - page not up to date")); -+ } -+ -+ rc = cifs_partialpagewrite(page,0,PAGE_CACHE_SIZE); -+ SetPageUptodate(page); /* BB add check for error and Clearuptodate? */ -+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20)) -+ unlock_page(page); -+#else -+ UnlockPage(page); -+#endif -+ page_cache_release(page); -+ FreeXid(xid); -+ return rc; -+} -+ -+static int -+cifs_commit_write(struct file *file, struct page *page, unsigned offset, -+ unsigned to) -+{ -+ int xid; -+ int rc = 0; -+ struct inode *inode = page->mapping->host; -+ loff_t position = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to; -+ char * page_data; -+ -+ xid = GetXid(); -+ cFYI(1,("commit write for page %p up to position %lld for %d",page,position,to)); -+ if (position > inode->i_size){ -+ inode->i_size = position; -+ /*if (file->private_data == NULL) { -+ rc = -EBADF; -+ } else { -+ open_file = (struct cifsFileInfo *)file->private_data; -+ cifs_sb = CIFS_SB(inode->i_sb); -+ rc = -EAGAIN; -+ while(rc == -EAGAIN) { -+ if((open_file->invalidHandle) && -+ (!open_file->closePend)) { -+ rc = cifs_reopen_file(file->f_dentry->d_inode,file); -+ if(rc != 0) -+ break; -+ } -+ if(!open_file->closePend) { -+ rc = CIFSSMBSetFileSize(xid, cifs_sb->tcon, -+ position, open_file->netfid, -+ open_file->pid,FALSE); -+ } else { -+ rc = -EBADF; -+ break; -+ } -+ } -+ cFYI(1,(" SetEOF (commit write) rc = %d",rc)); -+ }*/ -+ } -+ if (!Page_Uptodate(page)) { -+ position = ((loff_t)page->index << PAGE_CACHE_SHIFT) + offset; -+ /* can not rely on (or let) writepage write this data */ -+ if(to < offset) { -+ cFYI(1,("Illegal offsets, can not copy from %d to %d", -+ offset,to)); -+ FreeXid(xid); -+ return rc; -+ } -+ /* this is probably better than directly calling -+ partialpage_write since in this function -+ the file handle is known which we might as well -+ leverage */ -+ /* BB check if anything else missing out of ppw */ -+ /* such as updating last write time */ -+ page_data = kmap(page); -+ rc = cifs_write(file, page_data+offset,to-offset, -+ &position); -+ if(rc > 0) -+ rc = 0; -+ /* else if rc < 0 should we set writebehind rc? */ -+ kunmap(page); -+ } else { -+ set_page_dirty(page); -+ } -+ -+ FreeXid(xid); -+ return rc; -+} -+ -+int -+cifs_fsync(struct file *file, struct dentry *dentry, int datasync) -+{ -+ int xid; -+ int rc = 0; -+ struct inode * inode = file->f_dentry->d_inode; -+ -+ xid = GetXid(); -+ -+ cFYI(1, ("Sync file - name: %s datasync: 0x%x ", -+ dentry->d_name.name, datasync)); -+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,17)) -+ rc = filemap_fdatasync(inode->i_mapping); -+#else -+ filemap_fdatasync(inode->i_mapping); -+#endif -+ if(rc == 0) -+ CIFS_I(inode)->write_behind_rc = 0; -+ FreeXid(xid); -+ return rc; -+} -+ -+static int -+cifs_sync_page(struct page *page) -+{ -+ struct address_space *mapping; -+ struct inode *inode; -+ unsigned long index = page->index; -+ unsigned int rpages = 0; -+ int rc = 0; -+ -+ cFYI(1,("sync page %p",page)); -+ mapping = page->mapping; -+ if (!mapping) -+ return 0; -+ inode = mapping->host; -+ if (!inode) -+ return 0; -+ -+/* fill in rpages then -+ result = cifs_pagein_inode(inode, index, rpages); *//* BB finish */ -+ -+ cFYI(1, ("rpages is %d for sync page of Index %ld ", rpages, index)); -+ -+ if (rc < 0) -+ return rc; -+ return 0; -+} -+ -+/* -+ * As file closes, flush all cached write data for this inode checking -+ * for write behind errors. -+ * -+ */ -+int cifs_flush(struct file *file) -+{ -+ struct inode * inode = file->f_dentry->d_inode; -+ int rc = 0; -+ -+ /* Rather than do the steps manually: */ -+ /* lock the inode for writing */ -+ /* loop through pages looking for write behind data (dirty pages) */ -+ /* coalesce into contiguous 16K (or smaller) chunks to write to server */ -+ /* send to server (prefer in parallel) */ -+ /* deal with writebehind errors */ -+ /* unlock inode for writing */ -+ /* filemapfdatawrite appears easier for the time being */ -+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,17)) -+ rc = filemap_fdatasync(inode->i_mapping); -+#else -+ filemap_fdatasync(inode->i_mapping); -+#endif -+ if(rc == 0) /* reset wb rc if we were able to write out dirty pages */ -+ CIFS_I(inode)->write_behind_rc = 0; -+ -+ cFYI(1,("Flush inode %p file %p rc %d",inode,file,rc)); -+ -+ return rc; -+} -+ -+ -+ssize_t -+cifs_read(struct file * file, char *read_data, size_t read_size, -+ loff_t * poffset) -+{ -+ int rc = -EACCES; -+ unsigned int bytes_read = 0; -+ unsigned int total_read; -+ unsigned int current_read_size; -+ struct cifs_sb_info *cifs_sb; -+ struct cifsTconInfo *pTcon; -+ int xid; -+ char * current_offset; -+ struct cifsFileInfo * open_file; -+ -+ xid = GetXid(); -+ cifs_sb = CIFS_SB(file->f_dentry->d_sb); -+ pTcon = cifs_sb->tcon; -+ -+ if (file->private_data == NULL) { -+ FreeXid(xid); -+ return -EBADF; -+ } -+ open_file = (struct cifsFileInfo *)file->private_data; -+ -+ if((file->f_flags & O_ACCMODE) == O_WRONLY) { -+ cFYI(1,("attempting read on write only file instance")); -+ } -+ -+ for (total_read = 0,current_offset=read_data; read_size > total_read; -+ total_read += bytes_read,current_offset+=bytes_read) { -+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,15)) -+ current_read_size = min_t(const int,read_size - total_read,cifs_sb->rsize); -+#else -+ current_read_size = min(read_size - total_read,cifs_sb->rsize); -+#endif -+ rc = -EAGAIN; -+ while(rc == -EAGAIN) { -+ if ((open_file->invalidHandle) && (!open_file->closePend)) { -+ rc = cifs_reopen_file(file->f_dentry->d_inode, -+ file,TRUE); -+ if(rc != 0) -+ break; -+ } -+ -+ rc = CIFSSMBRead(xid, pTcon, -+ open_file->netfid, -+ current_read_size, *poffset, -+ &bytes_read, ¤t_offset); -+ } -+ if (rc || (bytes_read == 0)) { -+ if (total_read) { -+ break; -+ } else { -+ FreeXid(xid); -+ return rc; -+ } -+ } else { -+#ifdef CONFIG_CIFS_STATS -+ atomic_inc(&pTcon->num_reads); -+ spin_lock(&pTcon->stat_lock); -+ pTcon->bytes_read += total_read; -+ spin_unlock(&pTcon->stat_lock); -+#endif -+ *poffset += bytes_read; -+ } -+ } -+ FreeXid(xid); -+ return total_read; -+} -+ -+int cifs_file_mmap(struct file * file, struct vm_area_struct * vma) -+{ -+ struct dentry * dentry = file->f_dentry; -+ int rc, xid; -+ -+ xid = GetXid(); -+ rc = cifs_revalidate(dentry); -+ if (rc) { -+ cFYI(1,("Validation prior to mmap failed, error=%d", rc)); -+ FreeXid(xid); -+ return rc; -+ } -+ rc = generic_file_mmap(file, vma); -+ FreeXid(xid); -+ return rc; -+} -+ -+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) -+static void cifs_copy_cache_pages(struct address_space *mapping, -+ struct list_head *pages, int bytes_read, -+ char *data,struct pagevec * plru_pvec) -+{ -+ struct page *page; -+ char * target; -+ -+ while (bytes_read > 0) { -+ if(list_empty(pages)) -+ break; -+ -+ page = list_entry(pages->prev, struct page, lru); -+ list_del(&page->lru); -+ -+ if (add_to_page_cache(page, mapping, page->index, GFP_KERNEL)) { -+ page_cache_release(page); -+ cFYI(1,("Add page cache failed")); -+ continue; -+ } -+ -+ target = kmap_atomic(page,KM_USER0); -+ -+ if(PAGE_CACHE_SIZE > bytes_read) { -+ memcpy(target,data,bytes_read); -+ /* zero the tail end of this partial page */ -+ memset(target+bytes_read,0,PAGE_CACHE_SIZE-bytes_read); -+ bytes_read = 0; -+ } else { -+ memcpy(target,data,PAGE_CACHE_SIZE); -+ bytes_read -= PAGE_CACHE_SIZE; -+ } -+ kunmap_atomic(target,KM_USER0); -+ -+ flush_dcache_page(page); -+ SetPageUptodate(page); -+ unlock_page(page); -+ if (!pagevec_add(plru_pvec, page)) -+ __pagevec_lru_add(plru_pvec); -+ data += PAGE_CACHE_SIZE; -+ } -+ return; -+} -+ -+ -+static int -+cifs_readpages(struct file *file, struct address_space *mapping, -+ struct list_head *page_list, unsigned num_pages) -+{ -+ int rc = -EACCES; -+ int xid; -+ loff_t offset; -+ struct page * page; -+ struct cifs_sb_info *cifs_sb; -+ struct cifsTconInfo *pTcon; -+ int bytes_read = 0; -+ unsigned int read_size,i; -+ char * smb_read_data = NULL; -+ struct smb_com_read_rsp * pSMBr; -+ struct pagevec lru_pvec; -+ struct cifsFileInfo * open_file; -+ -+ xid = GetXid(); -+ if (file->private_data == NULL) { -+ FreeXid(xid); -+ return -EBADF; -+ } -+ open_file = (struct cifsFileInfo *)file->private_data; -+ cifs_sb = CIFS_SB(file->f_dentry->d_sb); -+ pTcon = cifs_sb->tcon; -+ -+ pagevec_init(&lru_pvec, 0); -+ -+ for(i = 0;i<num_pages;) { -+ unsigned contig_pages; -+ struct page * tmp_page; -+ unsigned long expected_index; -+ -+ if(list_empty(page_list)) { -+ break; -+ } -+ page = list_entry(page_list->prev, struct page, lru); -+ offset = (loff_t)page->index << PAGE_CACHE_SHIFT; -+ -+ /* count adjacent pages that we will read into */ -+ contig_pages = 0; -+ expected_index = list_entry(page_list->prev,struct page,lru)->index; -+ list_for_each_entry_reverse(tmp_page,page_list,lru) { -+ if(tmp_page->index == expected_index) { -+ contig_pages++; -+ expected_index++; -+ } else { -+ break; -+ } -+ } -+ if(contig_pages + i > num_pages) { -+ contig_pages = num_pages - i; -+ } -+ -+ /* for reads over a certain size could initiate async read ahead */ -+ -+ read_size = contig_pages * PAGE_CACHE_SIZE; -+ /* Read size needs to be in multiples of one page */ -+ read_size = min_t(const unsigned int,read_size,cifs_sb->rsize & PAGE_CACHE_MASK); -+ -+ rc = -EAGAIN; -+ while(rc == -EAGAIN) { -+ if ((open_file->invalidHandle) && (!open_file->closePend)) { -+ rc = cifs_reopen_file(file->f_dentry->d_inode, -+ file, TRUE); -+ if(rc != 0) -+ break; -+ } -+ -+ rc = CIFSSMBRead(xid, pTcon, -+ open_file->netfid, -+ read_size, offset, -+ &bytes_read, &smb_read_data); -+ /* BB need to check return code here */ -+ if(rc== -EAGAIN) { -+ if(smb_read_data) { -+ cifs_buf_release(smb_read_data); -+ smb_read_data = NULL; -+ } -+ } -+ } -+ if ((rc < 0) || (smb_read_data == NULL)) { -+ cFYI(1,("Read error in readpages: %d",rc)); -+ /* clean up remaing pages off list */ -+ while (!list_empty(page_list) && (i < num_pages)) { -+ page = list_entry(page_list->prev, struct page, lru); -+ list_del(&page->lru); -+ page_cache_release(page); -+ } -+ break; -+ } else if (bytes_read > 0) { -+ pSMBr = (struct smb_com_read_rsp *)smb_read_data; -+ cifs_copy_cache_pages(mapping, page_list, bytes_read, -+ smb_read_data + 4 /* RFC1001 hdr */ + -+ le16_to_cpu(pSMBr->DataOffset), &lru_pvec); -+ -+ i += bytes_read >> PAGE_CACHE_SHIFT; -+#ifdef CONFIG_CIFS_STATS -+ atomic_inc(&pTcon->num_reads); -+ spin_lock(&pTcon->stat_lock); -+ pTcon->bytes_read += bytes_read; -+ spin_unlock(&pTcon->stat_lock); -+#endif -+ if((int)(bytes_read & PAGE_CACHE_MASK) != bytes_read) { -+ cFYI(1,("Partial page %d of %d read to cache",i++,num_pages)); -+ -+ i++; /* account for partial page */ -+ -+ /* server copy of file can have smaller size than client */ -+ /* BB do we need to verify this common case ? this case is ok - -+ if we are at server EOF we will hit it on next read */ -+ -+ /* while(!list_empty(page_list) && (i < num_pages)) { -+ page = list_entry(page_list->prev,struct page, list); -+ list_del(&page->list); -+ page_cache_release(page); -+ } -+ break; */ -+ } -+ } else { -+ cFYI(1,("No bytes read (%d) at offset %lld . Cleaning remaining pages from readahead list",bytes_read,offset)); -+ /* BB turn off caching and do new lookup on file size at server? */ -+ while (!list_empty(page_list) && (i < num_pages)) { -+ page = list_entry(page_list->prev, struct page, lru); -+ list_del(&page->lru); -+ page_cache_release(page); /* BB removeme - replace with zero of page? */ -+ } -+ break; -+ } -+ if(smb_read_data) { -+ cifs_buf_release(smb_read_data); -+ smb_read_data = NULL; -+ } -+ bytes_read = 0; -+ } -+ -+ pagevec_lru_add(&lru_pvec); -+ -+/* need to free smb_read_data buf before exit */ -+ if(smb_read_data) { -+ cifs_buf_release(smb_read_data); -+ smb_read_data = NULL; -+ } -+ -+ FreeXid(xid); -+ return rc; -+} -+#endif -+ -+static int cifs_readpage_worker(struct file *file, struct page *page, loff_t * poffset) -+{ -+ char * read_data; -+ int rc; -+ -+ page_cache_get(page); -+ read_data = kmap(page); -+ /* for reads over a certain size could initiate async read ahead */ -+ -+ rc = cifs_read(file, read_data, PAGE_CACHE_SIZE, poffset); -+ -+ if (rc < 0) -+ goto io_error; -+ else { -+ cFYI(1,("Bytes read %d ",rc)); -+ } -+ -+ file->f_dentry->d_inode->i_atime = CURRENT_TIME; -+ -+ if(PAGE_CACHE_SIZE > rc) { -+ memset(read_data+rc, 0, PAGE_CACHE_SIZE - rc); -+ } -+ flush_dcache_page(page); -+ SetPageUptodate(page); -+ rc = 0; -+ -+io_error: -+ kunmap(page); -+ page_cache_release(page); -+ return rc; -+} -+ -+static int -+cifs_readpage(struct file *file, struct page *page) -+{ -+ loff_t offset = (loff_t)page->index << PAGE_CACHE_SHIFT; -+ int rc = -EACCES; -+ int xid; -+ -+ xid = GetXid(); -+ -+ if (file->private_data == NULL) { -+ FreeXid(xid); -+ return -EBADF; -+ } -+ -+ cFYI(1,("readpage %p at offset %d 0x%x\n",page,(int)offset,(int)offset)); -+ -+ rc = cifs_readpage_worker(file,page,&offset); -+ -+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20)) -+ unlock_page(page); -+#else -+ UnlockPage(page); -+#endif -+ -+ FreeXid(xid); -+ return rc; -+} -+ -+/* We do not want to update the file size from server for inodes -+ open for write - to avoid races with writepage extending -+ the file - in the future we could consider allowing -+ refreshing the inode only on increases in the file size -+ but this is tricky to do without racing with writebehind -+ page caching in the current Linux kernel design */ -+ -+int is_size_safe_to_change(struct cifsInodeInfo * cifsInode) -+{ -+ struct list_head *tmp; -+ struct list_head *tmp1; -+ struct cifsFileInfo *open_file = NULL; -+ int rc = TRUE; -+ -+ if(cifsInode == NULL) -+ return rc; -+ -+ read_lock(&GlobalSMBSeslock); -+ list_for_each_safe(tmp, tmp1, &cifsInode->openFileList) { -+ open_file = list_entry(tmp,struct cifsFileInfo, flist); -+ if(open_file == NULL) -+ break; -+ if(open_file->closePend) -+ continue; -+ /* We check if file is open for writing, -+ BB we could supplement this with a check to see if file size -+ changes have been flushed to server - ie inode metadata dirty */ -+ if((open_file->pfile) && -+ ((open_file->pfile->f_flags & O_RDWR) || -+ (open_file->pfile->f_flags & O_WRONLY))) { -+ rc = FALSE; -+ break; -+ } -+ if(tmp->next == NULL) { -+ cFYI(1,("File instance %p removed",tmp)); -+ break; -+ } -+ } -+ read_unlock(&GlobalSMBSeslock); -+ return rc; -+} -+ -+ -+void -+fill_in_inode(struct inode *tmp_inode, -+ FILE_DIRECTORY_INFO * pfindData, int *pobject_type) -+{ -+ struct cifsInodeInfo *cifsInfo = CIFS_I(tmp_inode); -+ struct cifs_sb_info *cifs_sb = CIFS_SB(tmp_inode->i_sb); -+ -+ pfindData->ExtFileAttributes = -+ le32_to_cpu(pfindData->ExtFileAttributes); -+ pfindData->AllocationSize = le64_to_cpu(pfindData->AllocationSize); -+ pfindData->EndOfFile = le64_to_cpu(pfindData->EndOfFile); -+ cifsInfo->cifsAttrs = pfindData->ExtFileAttributes; -+ cifsInfo->time = jiffies; -+ -+ /* Linux can not store file creation time unfortunately so ignore it */ -+ tmp_inode->i_atime = -+ cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastAccessTime)); -+ tmp_inode->i_mtime = -+ cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastWriteTime)); -+ tmp_inode->i_ctime = -+ cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime)); -+ /* treat dos attribute of read-only as read-only mode bit e.g. 555? */ -+ /* 2767 perms - indicate mandatory locking */ -+ /* BB fill in uid and gid here? with help from winbind? -+ or retrieve from NTFS stream extended attribute */ -+ if(atomic_read(&cifsInfo->inUse) == 0) { -+ tmp_inode->i_uid = cifs_sb->mnt_uid; -+ tmp_inode->i_gid = cifs_sb->mnt_gid; -+ /* set default mode. will override for dirs below */ -+ tmp_inode->i_mode = cifs_sb->mnt_file_mode; -+ } -+ -+ cFYI(0, -+ ("CIFS FFIRST: Attributes came in as 0x%x", -+ pfindData->ExtFileAttributes)); -+ if (pfindData->ExtFileAttributes & ATTR_REPARSE) { -+ *pobject_type = DT_LNK; -+ /* BB can this and S_IFREG or S_IFDIR be set as in Windows? */ -+ tmp_inode->i_mode |= S_IFLNK; -+ } else if (pfindData->ExtFileAttributes & ATTR_DIRECTORY) { -+ *pobject_type = DT_DIR; -+ /* override default perms since we do not lock dirs */ -+ if(atomic_read(&cifsInfo->inUse) == 0) { -+ tmp_inode->i_mode = cifs_sb->mnt_dir_mode; -+ } -+ tmp_inode->i_mode |= S_IFDIR; -+ } else { -+ *pobject_type = DT_REG; -+ tmp_inode->i_mode |= S_IFREG; -+ if(pfindData->ExtFileAttributes & ATTR_READONLY) -+ tmp_inode->i_mode &= ~(S_IWUGO); -+ -+ }/* could add code here - to validate if device or weird share type? */ -+ -+ /* can not fill in nlink here as in qpathinfo version and Unx search */ -+ if(atomic_read(&cifsInfo->inUse) == 0) { -+ atomic_set(&cifsInfo->inUse,1); -+ } -+ if(is_size_safe_to_change(cifsInfo)) { -+ /* can not safely change the file size here if the -+ client is writing to it due to potential races */ -+ tmp_inode->i_size = pfindData->EndOfFile; -+ -+ /* 512 bytes (2**9) is the fake blocksize that must be used */ -+ /* for this calculation, even though the reported blocksize is larger */ -+ tmp_inode->i_blocks = (512 - 1 + pfindData->AllocationSize) >> 9; -+ } -+ -+ if (pfindData->AllocationSize < pfindData->EndOfFile) -+ cFYI(1, ("Possible sparse file: allocation size less than end of file ")); -+ cFYI(1, -+ ("File Size %ld and blocks %ld and blocksize %ld", -+ (unsigned long) tmp_inode->i_size, tmp_inode->i_blocks, -+ tmp_inode->i_blksize)); -+ if (S_ISREG(tmp_inode->i_mode)) { -+ cFYI(1, (" File inode ")); -+ tmp_inode->i_op = &cifs_file_inode_ops; -+ tmp_inode->i_fop = &cifs_file_ops; -+ tmp_inode->i_data.a_ops = &cifs_addr_ops; -+ } else if (S_ISDIR(tmp_inode->i_mode)) { -+ cFYI(1, (" Directory inode")); -+ tmp_inode->i_op = &cifs_dir_inode_ops; -+ tmp_inode->i_fop = &cifs_dir_ops; -+ } else if (S_ISLNK(tmp_inode->i_mode)) { -+ cFYI(1, (" Symbolic Link inode ")); -+ tmp_inode->i_op = &cifs_symlink_inode_ops; -+ } else { -+ cFYI(1, (" Init special inode ")); -+ init_special_inode(tmp_inode, tmp_inode->i_mode, -+ kdev_t_to_nr(tmp_inode->i_rdev)); -+ } -+} -+ -+void -+unix_fill_in_inode(struct inode *tmp_inode, -+ FILE_UNIX_INFO * pfindData, int *pobject_type) -+{ -+ struct cifsInodeInfo *cifsInfo = CIFS_I(tmp_inode); -+ cifsInfo->time = jiffies; -+ atomic_inc(&cifsInfo->inUse); -+ -+ tmp_inode->i_atime = -+ cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastAccessTime)); -+ tmp_inode->i_mtime = -+ cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastModificationTime)); -+ tmp_inode->i_ctime = -+ cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastStatusChange)); -+ -+ tmp_inode->i_mode = le64_to_cpu(pfindData->Permissions); -+ pfindData->Type = le32_to_cpu(pfindData->Type); -+ if (pfindData->Type == UNIX_FILE) { -+ *pobject_type = DT_REG; -+ tmp_inode->i_mode |= S_IFREG; -+ } else if (pfindData->Type == UNIX_SYMLINK) { -+ *pobject_type = DT_LNK; -+ tmp_inode->i_mode |= S_IFLNK; -+ } else if (pfindData->Type == UNIX_DIR) { -+ *pobject_type = DT_DIR; -+ tmp_inode->i_mode |= S_IFDIR; -+ } else if (pfindData->Type == UNIX_CHARDEV) { -+ *pobject_type = DT_CHR; -+ tmp_inode->i_mode |= S_IFCHR; -+ tmp_inode->i_rdev = MKDEV(le64_to_cpu(pfindData->DevMajor), -+ le64_to_cpu(pfindData->DevMinor) & MINORMASK); -+ } else if (pfindData->Type == UNIX_BLOCKDEV) { -+ *pobject_type = DT_BLK; -+ tmp_inode->i_mode |= S_IFBLK; -+ tmp_inode->i_rdev = MKDEV(le64_to_cpu(pfindData->DevMajor), -+ le64_to_cpu(pfindData->DevMinor) & MINORMASK); -+ } else if (pfindData->Type == UNIX_FIFO) { -+ *pobject_type = DT_FIFO; -+ tmp_inode->i_mode |= S_IFIFO; -+ } else if (pfindData->Type == UNIX_SOCKET) { -+ *pobject_type = DT_SOCK; -+ tmp_inode->i_mode |= S_IFSOCK; -+ } -+ -+ tmp_inode->i_uid = le64_to_cpu(pfindData->Uid); -+ tmp_inode->i_gid = le64_to_cpu(pfindData->Gid); -+ tmp_inode->i_nlink = le64_to_cpu(pfindData->Nlinks); -+ -+ pfindData->NumOfBytes = le64_to_cpu(pfindData->NumOfBytes); -+ if(is_size_safe_to_change(cifsInfo)) { -+ /* can not safely change the file size here if the -+ client is writing to it due to potential races */ -+ pfindData->EndOfFile = le64_to_cpu(pfindData->EndOfFile); -+ tmp_inode->i_size = pfindData->EndOfFile; -+ -+ /* 512 bytes (2**9) is the fake blocksize that must be used */ -+ /* for this calculation, not the real blocksize */ -+ tmp_inode->i_blocks = (512 - 1 + pfindData->NumOfBytes) >> 9; -+ } -+ -+ if (S_ISREG(tmp_inode->i_mode)) { -+ cFYI(1, ("File inode")); -+ tmp_inode->i_op = &cifs_file_inode_ops; -+ tmp_inode->i_fop = &cifs_file_ops; -+ tmp_inode->i_data.a_ops = &cifs_addr_ops; -+ } else if (S_ISDIR(tmp_inode->i_mode)) { -+ cFYI(1, ("Directory inode")); -+ tmp_inode->i_op = &cifs_dir_inode_ops; -+ tmp_inode->i_fop = &cifs_dir_ops; -+ } else if (S_ISLNK(tmp_inode->i_mode)) { -+ cFYI(1, ("Symbolic Link inode")); -+ tmp_inode->i_op = &cifs_symlink_inode_ops; -+/* tmp_inode->i_fop = *//* do not need to set to anything */ -+ } else { -+ cFYI(1, ("Special inode")); -+ init_special_inode(tmp_inode, tmp_inode->i_mode, -+ kdev_t_to_nr(tmp_inode->i_rdev)); -+ } -+} -+ -+static void -+construct_dentry(struct qstr *qstring, struct file *file, -+ struct inode **ptmp_inode, struct dentry **pnew_dentry) -+{ -+ struct dentry *tmp_dentry; -+ struct cifs_sb_info *cifs_sb; -+ struct cifsTconInfo *pTcon; -+ struct cifsInodeInfo *pCifsI; -+ -+ cFYI(1, ("For %s ", qstring->name)); -+ cifs_sb = CIFS_SB(file->f_dentry->d_sb); -+ pTcon = cifs_sb->tcon; -+ -+ qstring->hash = full_name_hash(qstring->name, qstring->len); -+ tmp_dentry = d_lookup(file->f_dentry, qstring); -+ if (tmp_dentry) { -+ cFYI(0, (" existing dentry with inode 0x%p", tmp_dentry->d_inode)); -+ *ptmp_inode = tmp_dentry->d_inode; -+ /* BB overwrite the old name? i.e. tmp_dentry->d_name and tmp_dentry->d_name.len ?? */ -+ if(*ptmp_inode == NULL) { -+ *ptmp_inode = new_inode(file->f_dentry->d_sb); -+ if(*ptmp_inode == NULL) -+ return; -+ d_instantiate(tmp_dentry, *ptmp_inode); -+ insert_inode_hash(*ptmp_inode); -+ pCifsI = CIFS_I(*ptmp_inode); -+ INIT_LIST_HEAD(&pCifsI->openFileList); -+ /* can not enable caching for this inode -+ until a file instance is open and we -+ can check the oplock flag on the open -+ response */ -+ (*ptmp_inode)->i_blksize = CIFS_MAX_MSGSIZE; -+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,15)) -+ (*ptmp_inode)->i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */ -+#endif -+ pCifsI->clientCanCacheRead = FALSE; -+ pCifsI->clientCanCacheAll = FALSE; -+ pCifsI->time = 0; -+ /* do not need to set cifs Attrs since -+ they are about to be overwritten -+ in fill_in_inode */ -+ atomic_set(&pCifsI->inUse, 0); -+ } -+ } else { -+ tmp_dentry = d_alloc(file->f_dentry, qstring); -+ if(tmp_dentry == NULL) { -+ cERROR(1,("Failed allocating dentry")); -+ return; -+ } -+ -+ if(ptmp_inode) { -+ *ptmp_inode = new_inode(file->f_dentry->d_sb); -+ if(*ptmp_inode == NULL) -+ return; -+ pCifsI = CIFS_I(*ptmp_inode); -+ insert_inode_hash(*ptmp_inode); -+ INIT_LIST_HEAD(&pCifsI->openFileList); -+ /* can not enable caching for this inode -+ until a file instance is open and we -+ can check the oplock flag on the open -+ response */ -+ (*ptmp_inode)->i_blksize = CIFS_MAX_MSGSIZE; -+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,15)) -+ (*ptmp_inode)->i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */ -+#endif -+ pCifsI->clientCanCacheRead = FALSE; -+ pCifsI->clientCanCacheAll = FALSE; -+ pCifsI->time = 0; -+ /* do not need to set cifs Attrs since -+ they are about to be overwritten -+ in fill_in_inode */ -+ atomic_set(&pCifsI->inUse, 0); -+ } -+ tmp_dentry->d_op = &cifs_dentry_ops; -+ d_instantiate(tmp_dentry, *ptmp_inode); -+ d_rehash(tmp_dentry); -+ } -+ -+ tmp_dentry->d_time = jiffies; -+ *pnew_dentry = tmp_dentry; -+} -+ -+static void reset_resume_key(struct file * dir_file, -+ unsigned char * filename, -+ unsigned int len,int Unicode,struct nls_table * nls_tab) { -+ struct cifsFileInfo *cifsFile; -+ -+ cifsFile = (struct cifsFileInfo *)dir_file->private_data; -+ if(cifsFile == NULL) -+ return; -+ if(cifsFile->search_resume_name) { -+ kfree(cifsFile->search_resume_name); -+ } -+ -+ if(Unicode) -+ len *= 2; -+ cifsFile->resume_name_length = len; -+ -+ cifsFile->search_resume_name = -+ kmalloc(cifsFile->resume_name_length, GFP_KERNEL); -+ -+ if(cifsFile->search_resume_name == NULL) { -+ cERROR(1,("failed new resume key allocate, length %d", -+ cifsFile->resume_name_length)); -+ return; -+ } -+ if(Unicode) -+ cifs_strtoUCS((wchar_t *) cifsFile->search_resume_name, -+ filename, len, nls_tab); -+ else -+ memcpy(cifsFile->search_resume_name, filename, -+ cifsFile->resume_name_length); -+ cFYI(1,("Reset resume key to: %s with len %d",filename,len)); -+ return; -+} -+ -+ -+ -+static int -+cifs_filldir(struct qstr *pqstring, FILE_DIRECTORY_INFO * pfindData, -+ struct file *file, filldir_t filldir, void *direntry) -+{ -+ struct inode *tmp_inode; -+ struct dentry *tmp_dentry; -+ int object_type,rc; -+ -+ pqstring->name = pfindData->FileName; -+ pqstring->len = pfindData->FileNameLength; -+ -+ construct_dentry(pqstring, file, &tmp_inode, &tmp_dentry); -+ if((tmp_inode == NULL) || (tmp_dentry == NULL)) { -+ return -ENOMEM; -+ } -+ fill_in_inode(tmp_inode, pfindData, &object_type); -+ rc = filldir(direntry, pfindData->FileName, pqstring->len, file->f_pos, -+ tmp_inode->i_ino, object_type); -+ if(rc) { -+ /* due to readdir error we need to recalculate resume -+ key so next readdir will restart on right entry */ -+ cFYI(1,("Error %d on filldir of %s",rc ,pfindData->FileName)); -+ } -+ dput(tmp_dentry); -+ return rc; -+} -+ -+static int -+cifs_filldir_unix(struct qstr *pqstring, -+ FILE_UNIX_INFO * pUnixFindData, struct file *file, -+ filldir_t filldir, void *direntry) -+{ -+ struct inode *tmp_inode; -+ struct dentry *tmp_dentry; -+ int object_type, rc; -+ -+ pqstring->name = pUnixFindData->FileName; -+ pqstring->len = strnlen(pUnixFindData->FileName, MAX_PATHCONF); -+ -+ construct_dentry(pqstring, file, &tmp_inode, &tmp_dentry); -+ if((tmp_inode == NULL) || (tmp_dentry == NULL)) { -+ return -ENOMEM; -+ } -+ -+ unix_fill_in_inode(tmp_inode, pUnixFindData, &object_type); -+ rc = filldir(direntry, pUnixFindData->FileName, pqstring->len, -+ file->f_pos, tmp_inode->i_ino, object_type); -+ if(rc) { -+ /* due to readdir error we need to recalculate resume -+ key so next readdir will restart on right entry */ -+ cFYI(1,("Error %d on filldir of %s",rc ,pUnixFindData->FileName)); -+ } -+ dput(tmp_dentry); -+ return rc; -+} -+ -+int -+cifs_readdir(struct file *file, void *direntry, filldir_t filldir) -+{ -+ int rc = 0; -+ int xid; -+ int Unicode = FALSE; -+ int UnixSearch = FALSE; -+ unsigned int bufsize, i; -+ __u16 searchHandle; -+ struct cifs_sb_info *cifs_sb; -+ struct cifsTconInfo *pTcon; -+ struct cifsFileInfo *cifsFile = NULL; -+ char *full_path = NULL; -+ char *data; -+ struct qstr qstring; -+ T2_FFIRST_RSP_PARMS findParms; -+ T2_FNEXT_RSP_PARMS findNextParms; -+ FILE_DIRECTORY_INFO *pfindData; -+ FILE_DIRECTORY_INFO *lastFindData; -+ FILE_UNIX_INFO *pfindDataUnix; -+ -+ xid = GetXid(); -+ -+ cifs_sb = CIFS_SB(file->f_dentry->d_sb); -+ pTcon = cifs_sb->tcon; -+ bufsize = pTcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE; -+ if(bufsize > CIFS_MAX_MSGSIZE) { -+ FreeXid(xid); -+ return -EIO; -+ } -+ data = kmalloc(bufsize, GFP_KERNEL); -+ pfindData = (FILE_DIRECTORY_INFO *) data; -+ -+ if(file->f_dentry == NULL) { -+ FreeXid(xid); -+ return -EIO; -+ } -+ down(&file->f_dentry->d_sb->s_vfs_rename_sem); -+ full_path = build_wildcard_path_from_dentry(file->f_dentry); -+ up(&file->f_dentry->d_sb->s_vfs_rename_sem); -+ -+ -+ cFYI(1, ("Full path: %s start at: %lld ", full_path, file->f_pos)); -+ -+ switch ((int) file->f_pos) { -+ case 0: -+ if (filldir(direntry, ".", 1, file->f_pos, -+ file->f_dentry->d_inode->i_ino, DT_DIR) < 0) { -+ cERROR(1, ("Filldir for current dir failed ")); -+ break; -+ } -+ file->f_pos++; -+ /* fallthrough */ -+ case 1: -+ if (filldir(direntry, "..", 2, file->f_pos, -+ file->f_dentry->d_parent->d_inode->i_ino, DT_DIR) < 0) { -+ cERROR(1, ("Filldir for parent dir failed ")); -+ break; -+ } -+ file->f_pos++; -+ /* fallthrough */ -+ case 2: -+ if (file->private_data != NULL) { -+ cifsFile = -+ (struct cifsFileInfo *) file->private_data; -+ if (cifsFile->endOfSearch) { -+ if(cifsFile->emptyDir) { -+ cFYI(1, ("End of search, empty dir")); -+ rc = 0; -+ break; -+ } -+ } else { -+ cifsFile->invalidHandle = TRUE; -+ CIFSFindClose(xid, pTcon, cifsFile->netfid); -+ } -+ if(cifsFile->search_resume_name) { -+ kfree(cifsFile->search_resume_name); -+ cifsFile->search_resume_name = NULL; -+ } -+ } -+ rc = CIFSFindFirst(xid, pTcon, full_path, pfindData, -+ &findParms, cifs_sb->local_nls, -+ &Unicode, &UnixSearch); -+ cFYI(1, ("Count: %d End: %d ", findParms.SearchCount, -+ findParms.EndofSearch)); -+ -+ if (rc == 0) { -+ searchHandle = findParms.SearchHandle; -+ if(file->private_data == NULL) -+ file->private_data = -+ kmalloc(sizeof(struct cifsFileInfo),GFP_KERNEL); -+ if (file->private_data) { -+ memset(file->private_data, 0, -+ sizeof (struct cifsFileInfo)); -+ cifsFile = -+ (struct cifsFileInfo *) file->private_data; -+ cifsFile->netfid = searchHandle; -+ cifsFile->invalidHandle = FALSE; -+ init_MUTEX(&cifsFile->fh_sem); -+ } else { -+ rc = -ENOMEM; -+ break; -+ } -+ -+ renew_parental_timestamps(file->f_dentry); -+ lastFindData = -+ (FILE_DIRECTORY_INFO *) ((char *) pfindData + -+ findParms.LastNameOffset); -+ if((char *)lastFindData > (char *)pfindData + bufsize) { -+ cFYI(1,("last search entry past end of packet")); -+ rc = -EIO; -+ break; -+ } -+ /* Offset of resume key same for levels 257 and 514 */ -+ cifsFile->resume_key = lastFindData->FileIndex; -+ if(UnixSearch == FALSE) { -+ cifsFile->resume_name_length = -+ le32_to_cpu(lastFindData->FileNameLength); -+ if(cifsFile->resume_name_length > bufsize - 64) { -+ cFYI(1,("Illegal resume file name length %d", -+ cifsFile->resume_name_length)); -+ rc = -ENOMEM; -+ break; -+ } -+ cifsFile->search_resume_name = -+ kmalloc(cifsFile->resume_name_length, GFP_KERNEL); -+ cFYI(1,("Last file: %s with name %d bytes long", -+ lastFindData->FileName, -+ cifsFile->resume_name_length)); -+ memcpy(cifsFile->search_resume_name, -+ lastFindData->FileName, -+ cifsFile->resume_name_length); -+ } else { -+ pfindDataUnix = (FILE_UNIX_INFO *)lastFindData; -+ if (Unicode == TRUE) { -+ for(i=0;(pfindDataUnix->FileName[i] -+ | pfindDataUnix->FileName[i+1]); -+ i+=2) { -+ if(i > bufsize-64) -+ break; -+ } -+ cifsFile->resume_name_length = i + 2; -+ } else { -+ cifsFile->resume_name_length = -+ strnlen(pfindDataUnix->FileName, -+ bufsize-63); -+ } -+ if(cifsFile->resume_name_length > bufsize - 64) { -+ cFYI(1,("Illegal resume file name length %d", -+ cifsFile->resume_name_length)); -+ rc = -ENOMEM; -+ break; -+ } -+ cifsFile->search_resume_name = -+ kmalloc(cifsFile->resume_name_length, GFP_KERNEL); -+ cFYI(1,("Last file: %s with name %d bytes long", -+ pfindDataUnix->FileName, -+ cifsFile->resume_name_length)); -+ memcpy(cifsFile->search_resume_name, -+ pfindDataUnix->FileName, -+ cifsFile->resume_name_length); -+ } -+ for (i = 2; i < (unsigned int)findParms.SearchCount + 2; i++) { -+ if (UnixSearch == FALSE) { -+ pfindData->FileNameLength = -+ le32_to_cpu(pfindData->FileNameLength); -+ if (Unicode == TRUE) -+ pfindData->FileNameLength = -+ cifs_strfromUCS_le -+ (pfindData->FileName, -+ (wchar_t *) -+ pfindData->FileName, -+ (pfindData-> -+ FileNameLength) / 2, -+ cifs_sb->local_nls); -+ qstring.len = pfindData->FileNameLength; -+ if (((qstring.len != 1) -+ || (pfindData->FileName[0] != '.')) -+ && ((qstring.len != 2) -+ || (pfindData-> -+ FileName[0] != '.') -+ || (pfindData-> -+ FileName[1] != '.'))) { -+ if(cifs_filldir(&qstring, -+ pfindData, -+ file, filldir, -+ direntry)) { -+ /* do not end search if -+ kernel not ready to take -+ remaining entries yet */ -+ reset_resume_key(file, pfindData->FileName,qstring.len, -+ Unicode, cifs_sb->local_nls); -+ findParms.EndofSearch = 0; -+ break; -+ } -+ file->f_pos++; -+ } -+ } else { /* UnixSearch */ -+ pfindDataUnix = -+ (FILE_UNIX_INFO *) pfindData; -+ if (Unicode == TRUE) -+ qstring.len = -+ cifs_strfromUCS_le -+ (pfindDataUnix->FileName, -+ (wchar_t *) -+ pfindDataUnix->FileName, -+ MAX_PATHCONF, -+ cifs_sb->local_nls); -+ else -+ qstring.len = -+ strnlen(pfindDataUnix-> -+ FileName, -+ MAX_PATHCONF); -+ if (((qstring.len != 1) -+ || (pfindDataUnix-> -+ FileName[0] != '.')) -+ && ((qstring.len != 2) -+ || (pfindDataUnix-> -+ FileName[0] != '.') -+ || (pfindDataUnix-> -+ FileName[1] != '.'))) { -+ if(cifs_filldir_unix(&qstring, -+ pfindDataUnix, -+ file, -+ filldir, -+ direntry)) { -+ /* do not end search if -+ kernel not ready to take -+ remaining entries yet */ -+ findParms.EndofSearch = 0; -+ reset_resume_key(file, pfindDataUnix->FileName, -+ qstring.len,Unicode,cifs_sb->local_nls); -+ break; -+ } -+ file->f_pos++; -+ } -+ } -+ /* works also for Unix ff struct since first field of both */ -+ pfindData = -+ (FILE_DIRECTORY_INFO *) ((char *) pfindData -+ + le32_to_cpu(pfindData->NextEntryOffset)); -+ /* BB also should check to make sure that pointer is not beyond the end of the SMB */ -+ /* if(pfindData > lastFindData) rc = -EIO; break; */ -+ } /* end for loop */ -+ if ((findParms.EndofSearch != 0) && cifsFile) { -+ cifsFile->endOfSearch = TRUE; -+ if(findParms.SearchCount == 2) -+ cifsFile->emptyDir = TRUE; -+ } -+ } else { -+ if (cifsFile) -+ cifsFile->endOfSearch = TRUE; -+ /* unless parent directory gone do not return error */ -+ rc = 0; -+ } -+ break; -+ default: -+ if (file->private_data == NULL) { -+ rc = -EBADF; -+ cFYI(1, -+ ("Readdir on closed srch, pos = %lld", -+ file->f_pos)); -+ } else { -+ cifsFile = (struct cifsFileInfo *) file->private_data; -+ if (cifsFile->endOfSearch) { -+ rc = 0; -+ cFYI(1, ("End of search ")); -+ break; -+ } -+ searchHandle = cifsFile->netfid; -+ rc = CIFSFindNext(xid, pTcon, pfindData, -+ &findNextParms, searchHandle, -+ cifsFile->search_resume_name, -+ cifsFile->resume_name_length, -+ cifsFile->resume_key, -+ &Unicode, &UnixSearch); -+ cFYI(1,("Count: %d End: %d ", -+ findNextParms.SearchCount, -+ findNextParms.EndofSearch)); -+ if ((rc == 0) && (findNextParms.SearchCount != 0)) { -+ /* BB save off resume key, key name and name length */ -+ lastFindData = -+ (FILE_DIRECTORY_INFO *) ((char *) pfindData -+ + findNextParms.LastNameOffset); -+ if((char *)lastFindData > (char *)pfindData + bufsize) { -+ cFYI(1,("last search entry past end of packet")); -+ rc = -EIO; -+ break; -+ } -+ /* Offset of resume key same for levels 257 and 514 */ -+ cifsFile->resume_key = lastFindData->FileIndex; -+ -+ if(UnixSearch == FALSE) { -+ cifsFile->resume_name_length = -+ le32_to_cpu(lastFindData->FileNameLength); -+ if(cifsFile->resume_name_length > bufsize - 64) { -+ cFYI(1,("Illegal resume file name length %d", -+ cifsFile->resume_name_length)); -+ rc = -ENOMEM; -+ break; -+ } -+ /* Free the memory allocated by previous findfirst -+ or findnext call - we can not reuse the memory since -+ the resume name may not be same string length */ -+ if(cifsFile->search_resume_name) -+ kfree(cifsFile->search_resume_name); -+ cifsFile->search_resume_name = -+ kmalloc(cifsFile->resume_name_length, GFP_KERNEL); -+ cFYI(1,("Last file: %s with name %d bytes long", -+ lastFindData->FileName, -+ cifsFile->resume_name_length)); -+ memcpy(cifsFile->search_resume_name, -+ lastFindData->FileName, -+ cifsFile->resume_name_length); -+ } else { -+ pfindDataUnix = (FILE_UNIX_INFO *)lastFindData; -+ if (Unicode == TRUE) { -+ for(i=0;(pfindDataUnix->FileName[i] -+ | pfindDataUnix->FileName[i+1]); -+ i+=2) { -+ if(i > bufsize-64) -+ break; -+ } -+ cifsFile->resume_name_length = i + 2; -+ } else { -+ cifsFile->resume_name_length = -+ strnlen(pfindDataUnix-> -+ FileName, -+ MAX_PATHCONF); -+ } -+ if(cifsFile->resume_name_length > bufsize - 64) { -+ cFYI(1,("Illegal resume file name length %d", -+ cifsFile->resume_name_length)); -+ rc = -ENOMEM; -+ break; -+ } -+ /* Free the memory allocated by previous findfirst -+ or findnext call - we can not reuse the memory since -+ the resume name may not be same string length */ -+ if(cifsFile->search_resume_name) -+ kfree(cifsFile->search_resume_name); -+ cifsFile->search_resume_name = -+ kmalloc(cifsFile->resume_name_length, GFP_KERNEL); -+ cFYI(1,("fnext last file: %s with name %d bytes long", -+ pfindDataUnix->FileName, -+ cifsFile->resume_name_length)); -+ memcpy(cifsFile->search_resume_name, -+ pfindDataUnix->FileName, -+ cifsFile->resume_name_length); -+ } -+ -+ for (i = 0; i < findNextParms.SearchCount; i++) { -+ pfindData->FileNameLength = -+ le32_to_cpu(pfindData-> -+ FileNameLength); -+ if (UnixSearch == FALSE) { -+ if (Unicode == TRUE) -+ pfindData->FileNameLength = -+ cifs_strfromUCS_le -+ (pfindData->FileName, -+ (wchar_t *) -+ pfindData->FileName, -+ (pfindData->FileNameLength)/ 2, -+ cifs_sb->local_nls); -+ qstring.len = -+ pfindData->FileNameLength; -+ if (((qstring.len != 1) -+ || (pfindData->FileName[0] != '.')) -+ && ((qstring.len != 2) -+ || (pfindData->FileName[0] != '.') -+ || (pfindData->FileName[1] != -+ '.'))) { -+ if(cifs_filldir -+ (&qstring, -+ pfindData, -+ file, filldir, -+ direntry)) { -+ /* do not end search if -+ kernel not ready to take -+ remaining entries yet */ -+ findNextParms.EndofSearch = 0; -+ reset_resume_key(file, pfindData->FileName,qstring.len, -+ Unicode,cifs_sb->local_nls); -+ break; -+ } -+ file->f_pos++; -+ } -+ } else { /* UnixSearch */ -+ pfindDataUnix = -+ (FILE_UNIX_INFO *) -+ pfindData; -+ if (Unicode == TRUE) -+ qstring.len = -+ cifs_strfromUCS_le -+ (pfindDataUnix->FileName, -+ (wchar_t *) -+ pfindDataUnix->FileName, -+ MAX_PATHCONF, -+ cifs_sb->local_nls); -+ else -+ qstring.len = -+ strnlen -+ (pfindDataUnix-> -+ FileName, -+ MAX_PATHCONF); -+ if (((qstring.len != 1) -+ || (pfindDataUnix-> -+ FileName[0] != '.')) -+ && ((qstring.len != 2) -+ || (pfindDataUnix-> -+ FileName[0] != '.') -+ || (pfindDataUnix-> -+ FileName[1] != -+ '.'))) { -+ if(cifs_filldir_unix -+ (&qstring, -+ pfindDataUnix, -+ file, filldir, -+ direntry)) { -+ /* do not end search if -+ kernel not ready to take -+ remaining entries yet */ -+ findNextParms.EndofSearch = 0; -+ reset_resume_key(file, pfindDataUnix->FileName,qstring.len, -+ Unicode,cifs_sb->local_nls); -+ break; -+ } -+ file->f_pos++; -+ } -+ } -+ pfindData = (FILE_DIRECTORY_INFO *) ((char *) pfindData + le32_to_cpu(pfindData->NextEntryOffset)); /* works also for Unix find struct since this is the first field of both */ -+ /* BB also should check to make sure that pointer is not beyond the end of the SMB */ -+ } /* end for loop */ -+ if (findNextParms.EndofSearch != 0) { -+ cifsFile->endOfSearch = TRUE; -+ } -+ } else { -+ cifsFile->endOfSearch = TRUE; -+ rc = 0; /* unless parent directory disappeared - do not return error here (eg Access Denied or no more files) */ -+ } -+ } -+ } /* end switch */ -+ if (data) -+ kfree(data); -+ if (full_path) -+ kfree(full_path); -+ FreeXid(xid); -+ -+ return rc; -+} -+int cifs_prepare_write(struct file *file, struct page *page, -+ unsigned from, unsigned to) -+{ -+ int rc = 0; -+ loff_t offset = (loff_t)page->index << PAGE_CACHE_SHIFT; -+ cFYI(1,("prepare write for page %p from %d to %d",page,from,to)); -+ if (!Page_Uptodate(page)) { -+ /* if (to - from != PAGE_CACHE_SIZE) { -+ void *kaddr = kmap_atomic(page, KM_USER0); -+ memset(kaddr, 0, from); -+ memset(kaddr + to, 0, PAGE_CACHE_SIZE - to); -+ flush_dcache_page(page); -+ kunmap_atomic(kaddr, KM_USER0); -+ } */ -+ /* If we are writing a full page it will be up to date, -+ no need to read from the server */ -+ if((to==PAGE_CACHE_SIZE) && (from == 0)) -+ SetPageUptodate(page); -+ -+ /* might as well read a page, it is fast enough */ -+ if((file->f_flags & O_ACCMODE) != O_WRONLY) { -+ rc = cifs_readpage_worker(file,page,&offset); -+ } else { -+ /* should we try using another -+ file handle if there is one - how would we lock it -+ to prevent close of that handle racing with this read? */ -+ /* In any case this will be written out by commit_write */ -+ } -+ } -+ -+ /* BB should we pass any errors back? e.g. if we do not have read access to the file */ -+ return 0; -+} -+ -+ -+struct address_space_operations cifs_addr_ops = { -+ .readpage = cifs_readpage, -+/* .readpages = cifs_readpages, */ -+ .writepage = cifs_writepage, -+ .prepare_write = cifs_prepare_write, -+ .commit_write = cifs_commit_write, -+ .sync_page = cifs_sync_page, -+ /*.direct_IO = */ -+}; ---- /dev/null -+++ b/fs/cifs/inode.c -@@ -0,0 +1,1079 @@ -+/* -+ * fs/cifs/inode.c -+ * -+ * Copyright (C) International Business Machines Corp., 2002,2003 -+ * Author(s): Steve French (sfrench@us.ibm.com) -+ * -+ * This library is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU Lesser General Public License as published -+ * by the Free Software Foundation; either version 2.1 of the License, or -+ * (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -+ * the GNU Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public License -+ * along with this library; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ */ -+#include <linux/fs.h> -+#include <linux/stat.h> -+#include <linux/pagemap.h> -+#include <linux/version.h> -+#include <asm/div64.h> -+#include "cifsfs.h" -+#include "cifspdu.h" -+#include "cifsglob.h" -+#include "cifsproto.h" -+#include "cifs_debug.h" -+#include "cifs_fs_sb.h" -+ -+extern int is_size_safe_to_change(struct cifsInodeInfo *); -+ -+struct inode * get_cifs_inode(struct super_block * sb) -+{ -+ struct inode * newinode; -+ newinode = new_inode(sb); -+ cFYI(1,("got new inode %p",newinode)); -+ if(newinode) { -+ struct cifsInodeInfo * cifsInfo = CIFS_I(newinode); -+ cifsInfo->clientCanCacheRead = FALSE; -+ cifsInfo->clientCanCacheAll = FALSE; -+ INIT_LIST_HEAD(&cifsInfo->openFileList); -+ cifsInfo->cifsAttrs = 0x20; /* default */ -+ newinode->i_blksize = CIFS_MAX_MSGSIZE; -+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,15)) -+ newinode->i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */ -+#endif -+ atomic_set(&cifsInfo->inUse, 0); -+ cifsInfo->time = 0; -+ insert_inode_hash(newinode); -+ } -+ return newinode; -+ -+} -+ -+int -+cifs_get_inode_info_unix(struct inode **pinode, -+ const unsigned char *search_path, -+ struct super_block *sb,int xid) -+{ -+ int rc = 0; -+ FILE_UNIX_BASIC_INFO findData; -+ struct cifsTconInfo *pTcon; -+ struct inode *inode; -+ struct cifs_sb_info *cifs_sb = CIFS_SB(sb); -+ char *tmp_path; -+ -+ pTcon = cifs_sb->tcon; -+ cFYI(1, (" Getting info on %s ", search_path)); -+ /* we could have done a find first instead but this returns more info */ -+ rc = CIFSSMBUnixQPathInfo(xid, pTcon, search_path, &findData, -+ cifs_sb->local_nls); -+ /* dump_mem("\nUnixQPathInfo return data", &findData, sizeof(findData)); */ -+ if (rc) { -+ if (rc == -EREMOTE) { -+ tmp_path = -+ kmalloc(strnlen -+ (pTcon->treeName, -+ MAX_TREE_SIZE + 1) + -+ strnlen(search_path, MAX_PATHCONF) + 1, -+ GFP_KERNEL); -+ if (tmp_path == NULL) { -+ return -ENOMEM; -+ } -+ /* have to skip first of the double backslash of UNC name */ -+ strncpy(tmp_path, pTcon->treeName, MAX_TREE_SIZE); -+ strncat(tmp_path, search_path, MAX_PATHCONF); -+ rc = connect_to_dfs_path(xid, pTcon->ses, -+ /* treename + */ tmp_path, -+ cifs_sb->local_nls); -+ kfree(tmp_path); -+ -+ /* BB fix up inode etc. */ -+ } else if (rc) { -+ return rc; -+ } -+ -+ } else { -+ struct cifsInodeInfo *cifsInfo; -+ -+ /* get new inode */ -+ if (*pinode == NULL) { -+ *pinode = get_cifs_inode(sb); -+ } -+ if(*pinode == NULL) { -+ return -ENOMEM; -+ } -+ -+ inode = *pinode; -+ cifsInfo = CIFS_I(inode); -+ -+ cFYI(1, (" Old time %ld ", cifsInfo->time)); -+ cifsInfo->time = jiffies; -+ cFYI(1, (" New time %ld ", cifsInfo->time)); -+ atomic_set(&cifsInfo->inUse,1); /* ok to set on every refresh of inode */ -+ -+ inode->i_atime = -+ cifs_NTtimeToUnix(le64_to_cpu(findData.LastAccessTime)); -+ inode->i_mtime = -+ cifs_NTtimeToUnix(le64_to_cpu -+ (findData.LastModificationTime)); -+ inode->i_ctime = -+ cifs_NTtimeToUnix(le64_to_cpu(findData.LastStatusChange)); -+ inode->i_mode = le64_to_cpu(findData.Permissions); -+ findData.Type = le32_to_cpu(findData.Type); -+ if (findData.Type == UNIX_FILE) { -+ inode->i_mode |= S_IFREG; -+ } else if (findData.Type == UNIX_SYMLINK) { -+ inode->i_mode |= S_IFLNK; -+ } else if (findData.Type == UNIX_DIR) { -+ inode->i_mode |= S_IFDIR; -+ } else if (findData.Type == UNIX_CHARDEV) { -+ inode->i_mode |= S_IFCHR; -+ inode->i_rdev = MKDEV(le64_to_cpu(findData.DevMajor), -+ le64_to_cpu(findData.DevMinor) & MINORMASK); -+ } else if (findData.Type == UNIX_BLOCKDEV) { -+ inode->i_mode |= S_IFBLK; -+ inode->i_rdev = MKDEV(le64_to_cpu(findData.DevMajor), -+ le64_to_cpu(findData.DevMinor) & MINORMASK); -+ } else if (findData.Type == UNIX_FIFO) { -+ inode->i_mode |= S_IFIFO; -+ } else if (findData.Type == UNIX_SOCKET) { -+ inode->i_mode |= S_IFSOCK; -+ } -+ inode->i_uid = le64_to_cpu(findData.Uid); -+ inode->i_gid = le64_to_cpu(findData.Gid); -+ inode->i_nlink = le64_to_cpu(findData.Nlinks); -+ findData.NumOfBytes = le64_to_cpu(findData.NumOfBytes); -+ findData.EndOfFile = le64_to_cpu(findData.EndOfFile); -+ -+ if(is_size_safe_to_change(cifsInfo)) { -+ /* can not safely change the file size here if the -+ client is writing to it due to potential races */ -+ inode->i_size = findData.EndOfFile; -+/* blksize needs to be multiple of two. So safer to default to blksize -+ and blkbits set in superblock so 2**blkbits and blksize will match */ -+/* inode->i_blksize = -+ (pTcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) & 0xFFFFFE00;*/ -+ -+ /* This seems incredibly stupid but it turns out that -+ i_blocks is not related to (i_size / i_blksize), instead a -+ size of 512 is required to be used for calculating num blocks */ -+ -+ -+/* inode->i_blocks = -+ (inode->i_blksize - 1 + findData.NumOfBytes) >> inode->i_blkbits;*/ -+ -+ /* 512 bytes (2**9) is the fake blocksize that must be used */ -+ /* for this calculation */ -+ inode->i_blocks = (512 - 1 + findData.NumOfBytes) >> 9; -+ } -+ -+ if (findData.NumOfBytes < findData.EndOfFile) -+ cFYI(1, ("Server inconsistency Error: it says allocation size less than end of file ")); -+ cFYI(1, -+ ("Size %ld and blocks %ld ", -+ (unsigned long) inode->i_size, inode->i_blocks)); -+ if (S_ISREG(inode->i_mode)) { -+ cFYI(1, (" File inode ")); -+ inode->i_op = &cifs_file_inode_ops; -+ inode->i_fop = &cifs_file_ops; -+ inode->i_data.a_ops = &cifs_addr_ops; -+ } else if (S_ISDIR(inode->i_mode)) { -+ cFYI(1, (" Directory inode")); -+ inode->i_op = &cifs_dir_inode_ops; -+ inode->i_fop = &cifs_dir_ops; -+ } else if (S_ISLNK(inode->i_mode)) { -+ cFYI(1, (" Symbolic Link inode ")); -+ inode->i_op = &cifs_symlink_inode_ops; -+/* tmp_inode->i_fop = *//* do not need to set to anything */ -+ } else { -+ cFYI(1, (" Init special inode ")); -+ init_special_inode(inode, inode->i_mode, -+ kdev_t_to_nr(inode->i_rdev)); -+ } -+ } -+ return rc; -+} -+ -+int -+cifs_get_inode_info(struct inode **pinode, const unsigned char *search_path, -+ FILE_ALL_INFO * pfindData, struct super_block *sb, int xid) -+{ -+ int rc = 0; -+ struct cifsTconInfo *pTcon; -+ struct inode *inode; -+ struct cifs_sb_info *cifs_sb = CIFS_SB(sb); -+ char *tmp_path; -+ char *buf = NULL; -+ -+ pTcon = cifs_sb->tcon; -+ cFYI(1,("Getting info on %s ", search_path)); -+ -+ if((pfindData == NULL) && (*pinode != NULL)) { -+ if(CIFS_I(*pinode)->clientCanCacheRead) { -+ cFYI(1,("No need to revalidate inode sizes on cached file ")); -+ return rc; -+ } -+ } -+ -+ /* if file info not passed in then get it from server */ -+ if(pfindData == NULL) { -+ buf = kmalloc(sizeof(FILE_ALL_INFO),GFP_KERNEL); -+ pfindData = (FILE_ALL_INFO *)buf; -+ /* could do find first instead but this returns more info */ -+ rc = CIFSSMBQPathInfo(xid, pTcon, search_path, pfindData, -+ cifs_sb->local_nls); -+ } -+ /* dump_mem("\nQPathInfo return data",&findData, sizeof(findData)); */ -+ if (rc) { -+ if (rc == -EREMOTE) { -+ tmp_path = -+ kmalloc(strnlen -+ (pTcon->treeName, -+ MAX_TREE_SIZE + 1) + -+ strnlen(search_path, MAX_PATHCONF) + 1, -+ GFP_KERNEL); -+ if (tmp_path == NULL) { -+ if(buf) -+ kfree(buf); -+ return -ENOMEM; -+ } -+ -+ strncpy(tmp_path, pTcon->treeName, MAX_TREE_SIZE); -+ strncat(tmp_path, search_path, MAX_PATHCONF); -+ rc = connect_to_dfs_path(xid, pTcon->ses, -+ /* treename + */ tmp_path, -+ cifs_sb->local_nls); -+ kfree(tmp_path); -+ /* BB fix up inode etc. */ -+ } else if (rc) { -+ if(buf) -+ kfree(buf); -+ return rc; -+ } -+ } else { -+ struct cifsInodeInfo *cifsInfo; -+ -+ /* get new inode */ -+ if (*pinode == NULL) { -+ *pinode = get_cifs_inode(sb); -+ } -+ if(*pinode == NULL) -+ return -ENOMEM; -+ inode = *pinode; -+ cifsInfo = CIFS_I(inode); -+ pfindData->Attributes = le32_to_cpu(pfindData->Attributes); -+ cifsInfo->cifsAttrs = pfindData->Attributes; -+ cFYI(1, (" Old time %ld ", cifsInfo->time)); -+ cifsInfo->time = jiffies; -+ cFYI(1, (" New time %ld ", cifsInfo->time)); -+ -+/* blksize needs to be multiple of two. So safer to default to blksize -+ and blkbits set in superblock so 2**blkbits and blksize will match */ -+/* inode->i_blksize = -+ (pTcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) & 0xFFFFFE00;*/ -+ -+ /* Linux can not store file creation time unfortunately so we ignore it */ -+ inode->i_atime = -+ cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastAccessTime)); -+ inode->i_mtime = -+ cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastWriteTime)); -+ inode->i_ctime = -+ cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime)); -+ cFYI(0, -+ (" Attributes came in as 0x%x ", pfindData->Attributes)); -+ -+ /* set default mode. will override for dirs below */ -+ if(atomic_read(&cifsInfo->inUse) == 0) -+ /* new inode, can safely set these fields */ -+ inode->i_mode = cifs_sb->mnt_file_mode; -+ -+ if (pfindData->Attributes & ATTR_REPARSE) { -+ /* Can IFLNK be set as it basically is on windows with IFREG or IFDIR? */ -+ inode->i_mode |= S_IFLNK; -+ } else if (pfindData->Attributes & ATTR_DIRECTORY) { -+ /* override default perms since we do not do byte range locking on dirs */ -+ inode->i_mode = cifs_sb->mnt_dir_mode; -+ inode->i_mode |= S_IFDIR; -+ } else { -+ inode->i_mode |= S_IFREG; -+ /* treat the dos attribute of read-only as read-only mode e.g. 555 */ -+ if(cifsInfo->cifsAttrs & ATTR_READONLY) -+ inode->i_mode &= ~(S_IWUGO); -+ /* BB add code here - validate if device or weird share or device type? */ -+ } -+ if(is_size_safe_to_change(cifsInfo)) { -+ /* can not safely change the file size here if the -+ client is writing to it due to potential races */ -+ inode->i_size = le64_to_cpu(pfindData->EndOfFile); -+ -+ /* 512 bytes (2**9) is the fake blocksize that must be used */ -+ /* for this calculation */ -+ inode->i_blocks = (512 - 1 + pfindData->AllocationSize) -+ >> 9; -+ } -+ pfindData->AllocationSize = le64_to_cpu(pfindData->AllocationSize); -+ -+ cFYI(1, -+ (" Size %ld and blocks %ld ", -+ (unsigned long) inode->i_size, inode->i_blocks)); -+ inode->i_nlink = le32_to_cpu(pfindData->NumberOfLinks); -+ -+ /* BB fill in uid and gid here? with help from winbind? -+ or retrieve from NTFS stream extended attribute */ -+ if(atomic_read(&cifsInfo->inUse) == 0) { -+ inode->i_uid = cifs_sb->mnt_uid; -+ inode->i_gid = cifs_sb->mnt_gid; -+ /* set so we do not keep refreshing these fields with -+ bad data after user has changed them in memory */ -+ atomic_set(&cifsInfo->inUse,1); -+ } -+ -+ if (S_ISREG(inode->i_mode)) { -+ cFYI(1, (" File inode ")); -+ inode->i_op = &cifs_file_inode_ops; -+ inode->i_fop = &cifs_file_ops; -+ inode->i_data.a_ops = &cifs_addr_ops; -+ } else if (S_ISDIR(inode->i_mode)) { -+ cFYI(1, (" Directory inode ")); -+ inode->i_op = &cifs_dir_inode_ops; -+ inode->i_fop = &cifs_dir_ops; -+ } else if (S_ISLNK(inode->i_mode)) { -+ cFYI(1, (" Symbolic Link inode ")); -+ inode->i_op = &cifs_symlink_inode_ops; -+ } else { -+ init_special_inode(inode, inode->i_mode, -+ kdev_t_to_nr(inode->i_rdev)); -+ } -+ } -+ if(buf) -+ kfree(buf); -+ return rc; -+} -+ -+void -+cifs_read_inode(struct inode *inode) -+{ /* gets root inode */ -+ int xid; -+ struct cifs_sb_info *cifs_sb; -+ struct cifsInodeInfo *cifs_inode; -+ -+ cifs_sb = CIFS_SB(inode->i_sb); -+ xid = GetXid(); -+ -+ cifs_inode = CIFS_I(inode); -+ cifs_inode->cifsAttrs = ATTR_DIRECTORY; -+ atomic_set(&cifs_inode->inUse, 0); -+ cifs_inode->time = 0; -+ inode->i_blksize = CIFS_MAX_MSGSIZE; -+ inode->i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */ -+ -+ INIT_LIST_HEAD(&cifs_inode->openFileList); -+ -+ if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) -+ cifs_get_inode_info_unix(&inode, "", inode->i_sb,xid); -+ else -+ cifs_get_inode_info(&inode, "", NULL, inode->i_sb,xid); -+ /* can not call macro FreeXid here since in a void func */ -+ _FreeXid(xid); -+} -+ -+int -+cifs_unlink(struct inode *inode, struct dentry *direntry) -+{ -+ int rc = 0; -+ int xid; -+ struct cifs_sb_info *cifs_sb; -+ struct cifsTconInfo *pTcon; -+ char *full_path = NULL; -+ struct cifsInodeInfo *cifsInode; -+ FILE_BASIC_INFO * pinfo_buf; -+ -+ cFYI(1, (" cifs_unlink, inode = 0x%p with ", inode)); -+ -+ xid = GetXid(); -+ -+ cifs_sb = CIFS_SB(inode->i_sb); -+ pTcon = cifs_sb->tcon; -+ -+/* Unlink can be called from rename so we can not grab -+ the sem here since we deadlock otherwise */ -+/* down(&direntry->d_sb->s_vfs_rename_sem);*/ -+ full_path = build_path_from_dentry(direntry); -+/* up(&direntry->d_sb->s_vfs_rename_sem);*/ -+ if(full_path == NULL) { -+ FreeXid(xid); -+ return -ENOMEM; -+ } -+ rc = CIFSSMBDelFile(xid, pTcon, full_path, cifs_sb->local_nls); -+ -+ if (!rc) { -+ direntry->d_inode->i_nlink--; -+ } else if (rc == -ENOENT) { -+ d_drop(direntry); -+ } else if (rc == -ETXTBSY) { -+ int oplock = FALSE; -+ __u16 netfid; -+ -+ rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, DELETE, -+ CREATE_NOT_DIR | CREATE_DELETE_ON_CLOSE, -+ &netfid, &oplock, NULL, cifs_sb->local_nls); -+ if(rc==0) { -+ CIFSSMBRenameOpenFile(xid,pTcon,netfid, -+ NULL, cifs_sb->local_nls); -+ CIFSSMBClose(xid, pTcon, netfid); -+ direntry->d_inode->i_nlink--; -+ } -+ } else if (rc == -EACCES) { -+ /* try only if r/o attribute set in local lookup data? */ -+ pinfo_buf = (FILE_BASIC_INFO *)kmalloc(sizeof(FILE_BASIC_INFO),GFP_KERNEL); -+ if(pinfo_buf) { -+ memset(pinfo_buf,0,sizeof(FILE_BASIC_INFO)); -+ /* ATTRS set to normal clears r/o bit */ -+ pinfo_buf->Attributes = cpu_to_le32(ATTR_NORMAL); -+ rc = CIFSSMBSetTimes(xid, pTcon, full_path, pinfo_buf, -+ cifs_sb->local_nls); -+ kfree(pinfo_buf); -+ } -+ if(rc==0) { -+ rc = CIFSSMBDelFile(xid, pTcon, full_path, cifs_sb->local_nls); -+ if (!rc) { -+ direntry->d_inode->i_nlink--; -+ } else if (rc == -ETXTBSY) { -+ int oplock = FALSE; -+ __u16 netfid; -+ -+ rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, DELETE, -+ CREATE_NOT_DIR | CREATE_DELETE_ON_CLOSE, -+ &netfid, &oplock, NULL, cifs_sb->local_nls); -+ if(rc==0) { -+ CIFSSMBRenameOpenFile(xid,pTcon,netfid,NULL,cifs_sb->local_nls); -+ CIFSSMBClose(xid, pTcon, netfid); -+ direntry->d_inode->i_nlink--; -+ } -+ /* BB if rc = -ETXTBUSY goto the rename logic BB */ -+ } -+ } -+ } -+ cifsInode = CIFS_I(direntry->d_inode); -+ cifsInode->time = 0; /* will force revalidate to get info when needed */ -+ direntry->d_inode->i_ctime = inode->i_ctime = inode->i_mtime = -+ CURRENT_TIME; -+ cifsInode = CIFS_I(inode); -+ cifsInode->time = 0; /* force revalidate of dir as well */ -+ -+ if (full_path) -+ kfree(full_path); -+ FreeXid(xid); -+ return rc; -+} -+ -+int -+cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) -+{ -+ int rc = 0; -+ int xid; -+ struct cifs_sb_info *cifs_sb; -+ struct cifsTconInfo *pTcon; -+ char *full_path = NULL; -+ struct inode *newinode = NULL; -+ -+ cFYI(1, ("In cifs_mkdir, mode = 0x%x inode = 0x%p ", mode, inode)); -+ -+ xid = GetXid(); -+ -+ cifs_sb = CIFS_SB(inode->i_sb); -+ pTcon = cifs_sb->tcon; -+ -+ down(&inode->i_sb->s_vfs_rename_sem); -+ full_path = build_path_from_dentry(direntry); -+ up(&inode->i_sb->s_vfs_rename_sem); -+ if(full_path == NULL) { -+ FreeXid(xid); -+ return -ENOMEM; -+ } -+ /* BB add setting the equivalent of mode via CreateX w/ACLs */ -+ rc = CIFSSMBMkDir(xid, pTcon, full_path, cifs_sb->local_nls); -+ if (rc) { -+ cFYI(1, ("cifs_mkdir returned 0x%x ", rc)); -+ d_drop(direntry); -+ } else { -+ inode->i_nlink++; -+ if (pTcon->ses->capabilities & CAP_UNIX) -+ rc = cifs_get_inode_info_unix(&newinode, full_path, -+ inode->i_sb,xid); -+ else -+ rc = cifs_get_inode_info(&newinode, full_path,NULL, -+ inode->i_sb,xid); -+ -+ direntry->d_op = &cifs_dentry_ops; -+ d_instantiate(direntry, newinode); -+ if(direntry->d_inode) -+ direntry->d_inode->i_nlink = 2; -+ if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) -+ CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, -+ (__u64)-1, -+ (__u64)-1, -+ 0 /* dev_t */, -+ cifs_sb->local_nls); -+ else { /* BB to be implemented via Windows secrty descriptors*/ -+ /* eg CIFSSMBWinSetPerms(xid,pTcon,full_path,mode,-1,-1,local_nls);*/ -+ } -+ } -+ if (full_path) -+ kfree(full_path); -+ FreeXid(xid); -+ -+ return rc; -+} -+ -+int -+cifs_rmdir(struct inode *inode, struct dentry *direntry) -+{ -+ int rc = 0; -+ int xid; -+ struct cifs_sb_info *cifs_sb; -+ struct cifsTconInfo *pTcon; -+ char *full_path = NULL; -+ struct cifsInodeInfo *cifsInode; -+ -+ cFYI(1, (" cifs_rmdir, inode = 0x%p with ", inode)); -+ -+ xid = GetXid(); -+ -+ cifs_sb = CIFS_SB(inode->i_sb); -+ pTcon = cifs_sb->tcon; -+ -+ down(&inode->i_sb->s_vfs_rename_sem); -+ full_path = build_path_from_dentry(direntry); -+ up(&inode->i_sb->s_vfs_rename_sem); -+ if(full_path == NULL) { -+ FreeXid(xid); -+ return -ENOMEM; -+ } -+ -+ rc = CIFSSMBRmDir(xid, pTcon, full_path, cifs_sb->local_nls); -+ -+ if (!rc) { -+ inode->i_nlink--; -+ direntry->d_inode->i_size = 0; -+ direntry->d_inode->i_nlink = 0; -+ } -+ -+ cifsInode = CIFS_I(direntry->d_inode); -+ cifsInode->time = 0; /* force revalidate to go get info when needed */ -+ direntry->d_inode->i_ctime = inode->i_ctime = inode->i_mtime = -+ CURRENT_TIME; -+ -+ if (full_path) -+ kfree(full_path); -+ FreeXid(xid); -+ return rc; -+} -+ -+int -+cifs_rename(struct inode *source_inode, struct dentry *source_direntry, -+ struct inode *target_inode, struct dentry *target_direntry) -+{ -+ char *fromName; -+ char *toName; -+ struct cifs_sb_info *cifs_sb_source; -+ struct cifs_sb_info *cifs_sb_target; -+ struct cifsTconInfo *pTcon; -+ int xid; -+ int rc = 0; -+ -+ xid = GetXid(); -+ -+ cifs_sb_target = CIFS_SB(target_inode->i_sb); -+ cifs_sb_source = CIFS_SB(source_inode->i_sb); -+ pTcon = cifs_sb_source->tcon; -+ -+ if (pTcon != cifs_sb_target->tcon) { -+ FreeXid(xid); -+ return -EXDEV; /* BB actually could be allowed if same server, but -+ different share. Might eventually add support for this */ -+ } -+ -+ /* we already have the rename sem so we do not need -+ to grab it again here to protect the path integrity */ -+ fromName = build_path_from_dentry(source_direntry); -+ toName = build_path_from_dentry(target_direntry); -+ if((fromName == NULL) || (toName == NULL)) { -+ rc = -ENOMEM; -+ goto cifs_rename_exit; -+ } -+ -+ rc = CIFSSMBRename(xid, pTcon, fromName, toName, -+ cifs_sb_source->local_nls); -+ if(rc == -EEXIST) { -+ /* check if they are the same file -+ because rename of hardlinked files is a noop */ -+ FILE_UNIX_BASIC_INFO * info_buf_source; -+ FILE_UNIX_BASIC_INFO * info_buf_target; -+ -+ info_buf_source = -+ kmalloc(2 * sizeof(FILE_UNIX_BASIC_INFO),GFP_KERNEL); -+ if(info_buf_source != NULL) { -+ info_buf_target = info_buf_source+1; -+ rc = CIFSSMBUnixQPathInfo(xid, pTcon, fromName, -+ info_buf_source, cifs_sb_source->local_nls); -+ if(rc == 0) { -+ rc = CIFSSMBUnixQPathInfo(xid,pTcon,toName, -+ info_buf_target, -+ cifs_sb_target->local_nls); -+ } -+ if((rc == 0) && -+ (info_buf_source->UniqueId == -+ info_buf_target->UniqueId)) { -+ /* do not rename since the files are hardlinked -+ which is a noop */ -+ } else { -+ /* we either can not tell the files are hardlinked -+ (as with Windows servers) or files are not hardlinked -+ so delete the target manually before renaming to -+ follow POSIX rather than Windows semantics */ -+ cifs_unlink(target_inode, target_direntry); -+ rc = CIFSSMBRename(xid, pTcon, fromName, toName, -+ cifs_sb_source->local_nls); -+ } -+ kfree(info_buf_source); -+ } /* if we can not get memory just leave rc as EEXIST */ -+ } -+ -+ if((rc == -EIO)||(rc == -EEXIST)) { -+ int oplock = FALSE; -+ __u16 netfid; -+ -+ rc = CIFSSMBOpen(xid, pTcon, fromName, FILE_OPEN, GENERIC_READ, -+ CREATE_NOT_DIR, -+ &netfid, &oplock, NULL, cifs_sb_source->local_nls); -+ if(rc==0) { -+ CIFSSMBRenameOpenFile(xid,pTcon,netfid, -+ toName, cifs_sb_source->local_nls); -+ CIFSSMBClose(xid, pTcon, netfid); -+ } -+ } -+ -+cifs_rename_exit: -+ if (fromName) -+ kfree(fromName); -+ if (toName) -+ kfree(toName); -+ -+ FreeXid(xid); -+ return rc; -+} -+ -+int -+cifs_revalidate(struct dentry *direntry) -+{ -+ int xid; -+ int rc = 0; -+ char *full_path; -+ struct cifs_sb_info *cifs_sb; -+ struct cifsInodeInfo *cifsInode; -+ loff_t local_size; -+ time_t local_mtime; -+ int invalidate_inode = FALSE; -+ -+ if(direntry->d_inode == NULL) -+ return -ENOENT; -+ -+ cifsInode = CIFS_I(direntry->d_inode); -+ -+ if(cifsInode == NULL) -+ return -ENOENT; -+ -+ /* no sense revalidating inode info on file that no one can write */ -+ if(CIFS_I(direntry->d_inode)->clientCanCacheRead) -+ return rc; -+ -+ xid = GetXid(); -+ -+ cifs_sb = CIFS_SB(direntry->d_sb); -+ -+ /* can not safely grab the rename sem here if -+ rename calls revalidate since that would deadlock */ -+ full_path = build_path_from_dentry(direntry); -+ if(full_path == NULL) { -+ FreeXid(xid); -+ return -ENOMEM; -+ } -+ cFYI(1, -+ ("Revalidate: %s inode 0x%p count %d dentry: 0x%p d_time %ld jiffies %ld", -+ full_path, direntry->d_inode, -+ direntry->d_inode->i_count.counter, direntry, -+ direntry->d_time, jiffies)); -+ -+ if (cifsInode->time == 0){ -+ /* was set to zero previously to force revalidate */ -+ } else if (time_before(jiffies, cifsInode->time + HZ) && lookupCacheEnabled) { -+ if((S_ISREG(direntry->d_inode->i_mode) == 0) || -+ (direntry->d_inode->i_nlink == 1)) { -+ if (full_path) -+ kfree(full_path); -+ FreeXid(xid); -+ return rc; -+ } else { -+ cFYI(1,("Have to revalidate file due to hardlinks")); -+ } -+ } -+ -+ /* save mtime and size */ -+ local_mtime = direntry->d_inode->i_mtime; -+ local_size = direntry->d_inode->i_size; -+ -+ if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) { -+ rc = cifs_get_inode_info_unix(&direntry->d_inode, full_path, -+ direntry->d_sb,xid); -+ if(rc) { -+ cFYI(1,("error on getting revalidate info %d",rc)); -+/* if(rc != -ENOENT) -+ rc = 0; */ /* BB should we cache info on certain errors? */ -+ } -+ } else { -+ rc = cifs_get_inode_info(&direntry->d_inode, full_path, NULL, -+ direntry->d_sb,xid); -+ if(rc) { -+ cFYI(1,("error on getting revalidate info %d",rc)); -+/* if(rc != -ENOENT) -+ rc = 0; */ /* BB should we cache info on certain errors? */ -+ } -+ } -+ /* should we remap certain errors, access denied?, to zero */ -+ -+ /* if not oplocked, we invalidate inode pages if mtime -+ or file size had changed on server */ -+ -+ if((local_mtime == direntry->d_inode->i_mtime) && -+ (local_size == direntry->d_inode->i_size)) { -+ cFYI(1,("cifs_revalidate - inode unchanged")); -+ } else { -+ /* file may have changed on server */ -+ if(cifsInode->clientCanCacheRead) { -+ /* no need to invalidate inode pages since we were -+ the only ones who could have modified the file and -+ the server copy is staler than ours */ -+ } else { -+ invalidate_inode = TRUE; -+ } -+ } -+ -+ /* can not grab this sem since kernel filesys locking -+ documentation indicates i_sem may be taken by the kernel -+ on lookup and rename which could deadlock if we grab -+ the i_sem here as well */ -+/* down(&direntry->d_inode->i_sem);*/ -+ /* need to write out dirty pages here */ -+ if(direntry->d_inode->i_mapping) { -+ /* do we need to lock inode until after invalidate completes below? */ -+ filemap_fdatasync(direntry->d_inode->i_mapping); -+ } -+ if(invalidate_inode) { -+ filemap_fdatawait(direntry->d_inode->i_mapping); -+ /* may eventually have to do this for open files too */ -+ if(list_empty(&(cifsInode->openFileList))) { -+ /* Has changed on server - flush read ahead pages */ -+ cFYI(1,("Invalidating read ahead data on closed file")); -+ invalidate_inode_pages(direntry->d_inode); -+ } -+ } -+/* up(&direntry->d_inode->i_sem);*/ -+ -+ if (full_path) -+ kfree(full_path); -+ FreeXid(xid); -+ -+ return rc; -+} -+ -+/* int cifs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) -+{ -+ int err = cifs_revalidate(dentry); -+ if (!err) -+ generic_fillattr(dentry->d_inode, stat); -+ return err; -+} */ -+ -+void -+cifs_truncate_file(struct inode *inode) -+{ /* BB remove - may not need this function after all BB */ -+ int xid; -+ int rc = -EIO; -+ int found = FALSE; -+ struct cifsFileInfo *open_file = NULL; -+ struct cifs_sb_info *cifs_sb; -+ struct cifsTconInfo *pTcon; -+ struct cifsInodeInfo *cifsInode; -+ struct dentry *dirent; -+ struct list_head * tmp; -+ char *full_path = NULL; -+ -+ xid = GetXid(); -+ -+ cifs_sb = CIFS_SB(inode->i_sb); -+ pTcon = cifs_sb->tcon; -+ -+ /* To avoid spurious oplock breaks from server, in the case -+ of inodes that we already have open, avoid doing path -+ based setting of file size if we can do it by handle. -+ This keeps our caching token (oplock) and avoids -+ timeouts when the local oplock break takes longer to flush -+ writebehind data than the SMB timeout for the SetPathInfo -+ request would allow */ -+ read_lock(&GlobalSMBSeslock); -+ cifsInode = CIFS_I(inode); -+ list_for_each(tmp, &cifsInode->openFileList) { -+ open_file = list_entry(tmp,struct cifsFileInfo, flist); -+ /* We check if file is open for writing first */ -+ if((open_file->pfile) && (!open_file->invalidHandle) && -+ ((open_file->pfile->f_flags & O_RDWR) || -+ (open_file->pfile->f_flags & O_WRONLY))) { -+ read_unlock(&GlobalSMBSeslock); -+ found = TRUE; -+ rc = CIFSSMBSetFileSize(xid, pTcon, inode->i_size, -+ open_file->netfid,open_file->pid,FALSE); -+ if(rc == 0) { -+ FreeXid(xid); -+ return; -+ } -+ /* Do not need reopen and retry on EAGAIN since we will -+ retry by pathname below */ -+ if(rc == -EAGAIN) -+ rc = -EHOSTDOWN; -+ -+ break; /* now that we found one valid file handle no -+ sense continuing to loop trying others */ -+ } -+ } -+ if(found == FALSE) -+ read_unlock(&GlobalSMBSeslock); -+ -+ if (list_empty(&inode->i_dentry)) { -+ cERROR(1, -+ ("Can not get pathname from empty dentry in inode 0x%p ", -+ inode)); -+ FreeXid(xid); -+ return; -+ } -+ -+ dirent = list_entry(inode->i_dentry.next, struct dentry, d_alias); -+ if (dirent) { -+ full_path = build_path_from_dentry(dirent); -+ rc = CIFSSMBSetEOF(xid, pTcon, full_path, inode->i_size,FALSE, -+ cifs_sb->local_nls); -+ cFYI(1,(" SetEOF (truncate) rc = %d",rc)); -+ if (!rc) -+ CIFSSMBSetEOF(xid,pTcon,full_path,inode->i_size,TRUE,cifs_sb->local_nls); -+ /* allocation size setting seems optional so ignore return code */ -+ } -+ if (full_path) -+ kfree(full_path); -+ FreeXid(xid); -+ return; -+} -+ -+static int cifs_truncate_page(struct address_space *mapping, loff_t from) -+{ -+ unsigned long index = from >> PAGE_CACHE_SHIFT; -+ unsigned offset = from & (PAGE_CACHE_SIZE-1); -+ struct page *page; -+ char *kaddr; -+ int rc = 0; -+ -+ page = grab_cache_page(mapping, index); -+ if (!page) -+ return -ENOMEM; -+ -+ kaddr = kmap_atomic(page, KM_USER0); -+ memset(kaddr + offset, 0, PAGE_CACHE_SIZE - offset); -+ flush_dcache_page(page); -+ kunmap_atomic(kaddr, KM_USER0); -+ unlock_page(page); -+ page_cache_release(page); -+ return rc; -+} -+ -+int -+cifs_setattr(struct dentry *direntry, struct iattr *attrs) -+{ -+ int xid; -+ struct cifs_sb_info *cifs_sb; -+ struct cifsTconInfo *pTcon; -+ char *full_path = NULL; -+ int rc = -EACCES; -+ int found = FALSE; -+ struct cifsFileInfo *open_file = NULL; -+ FILE_BASIC_INFO time_buf; -+ int set_time = FALSE; -+ __u64 mode = 0xFFFFFFFFFFFFFFFFULL; -+ __u64 uid = 0xFFFFFFFFFFFFFFFFULL; -+ __u64 gid = 0xFFFFFFFFFFFFFFFFULL; -+ struct cifsInodeInfo *cifsInode; -+ struct list_head * tmp; -+ -+ xid = GetXid(); -+ -+ cFYI(1, -+ (" In cifs_setattr, name = %s attrs->iavalid 0x%x ", -+ direntry->d_name.name, attrs->ia_valid)); -+ cifs_sb = CIFS_SB(direntry->d_inode->i_sb); -+ pTcon = cifs_sb->tcon; -+ -+ down(&direntry->d_sb->s_vfs_rename_sem); -+ full_path = build_path_from_dentry(direntry); -+ up(&direntry->d_sb->s_vfs_rename_sem); -+ if(full_path == NULL) { -+ FreeXid(xid); -+ return -ENOMEM; -+ } -+ cifsInode = CIFS_I(direntry->d_inode); -+ -+ /* BB check if we need to refresh inode from server now ? BB */ -+ -+ /* need to flush data before changing file size on server */ -+ filemap_fdatasync(direntry->d_inode->i_mapping); -+ -+ if (attrs->ia_valid & ATTR_SIZE) { -+ read_lock(&GlobalSMBSeslock); -+ /* To avoid spurious oplock breaks from server, in the case -+ of inodes that we already have open, avoid doing path -+ based setting of file size if we can do it by handle. -+ This keeps our caching token (oplock) and avoids -+ timeouts when the local oplock break takes longer to flush -+ writebehind data than the SMB timeout for the SetPathInfo -+ request would allow */ -+ list_for_each(tmp, &cifsInode->openFileList) { -+ open_file = list_entry(tmp,struct cifsFileInfo, flist); -+ /* We check if file is open for writing first */ -+ if((open_file->pfile) && -+ ((open_file->pfile->f_flags & O_RDWR) || -+ (open_file->pfile->f_flags & O_WRONLY))) { -+ if(open_file->invalidHandle == FALSE) { -+ /* we found a valid, writeable network file -+ handle to use to try to set the file size */ -+ __u16 nfid = open_file->netfid; -+ __u32 npid = open_file->pid; -+ read_unlock(&GlobalSMBSeslock); -+ found = TRUE; -+ rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size, -+ nfid,npid,FALSE); -+ cFYI(1,("SetFileSize by handle (setattrs) rc = %d",rc)); -+ /* Do not need reopen and retry on EAGAIN since we will -+ retry by pathname below */ -+ -+ break; /* now that we found one valid file handle no -+ sense continuing to loop trying others */ -+ } -+ } -+ } -+ if(found == FALSE) { -+ read_unlock(&GlobalSMBSeslock); -+ } -+ -+ -+ if(rc != 0) { -+ /* Set file size by pathname rather than by handle either -+ because no valid, writeable file handle for it was found or -+ because there was an error setting it by handle */ -+ rc = CIFSSMBSetEOF(xid, pTcon, full_path, attrs->ia_size,FALSE, -+ cifs_sb->local_nls); -+ cFYI(1,(" SetEOF by path (setattrs) rc = %d",rc)); -+ } -+ -+ /* Server is ok setting allocation size implicitly - no need to call: */ -+ /*CIFSSMBSetEOF(xid, pTcon, full_path, attrs->ia_size, TRUE, cifs_sb->local_nls);*/ -+ -+ if (rc == 0) { -+ rc = vmtruncate(direntry->d_inode, attrs->ia_size); -+ cifs_truncate_page(direntry->d_inode->i_mapping, direntry->d_inode->i_size); -+ } -+ } -+ if (attrs->ia_valid & ATTR_UID) { -+ cFYI(1, (" CIFS - UID changed to %d", attrs->ia_uid)); -+ uid = attrs->ia_uid; -+ /* entry->uid = cpu_to_le16(attr->ia_uid); */ -+ } -+ if (attrs->ia_valid & ATTR_GID) { -+ cFYI(1, (" CIFS - GID changed to %d", attrs->ia_gid)); -+ gid = attrs->ia_gid; -+ /* entry->gid = cpu_to_le16(attr->ia_gid); */ -+ } -+ -+ time_buf.Attributes = 0; -+ if (attrs->ia_valid & ATTR_MODE) { -+ cFYI(1, (" CIFS - Mode changed to 0x%x", attrs->ia_mode)); -+ mode = attrs->ia_mode; -+ /* entry->mode = cpu_to_le16(attr->ia_mode); */ -+ } -+ -+ if ((cifs_sb->tcon->ses->capabilities & CAP_UNIX) -+ && (attrs->ia_valid & (ATTR_MODE | ATTR_GID | ATTR_UID))) -+ rc = CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, uid, gid, -+ 0 /* dev_t */, cifs_sb->local_nls); -+ else if (attrs->ia_valid & ATTR_MODE) { -+ if((mode & S_IWUGO) == 0) /* not writeable */ { -+ if((cifsInode->cifsAttrs & ATTR_READONLY) == 0) -+ time_buf.Attributes = -+ cpu_to_le32(cifsInode->cifsAttrs | ATTR_READONLY); -+ } else if((mode & S_IWUGO) == S_IWUGO) { -+ if(cifsInode->cifsAttrs & ATTR_READONLY) -+ time_buf.Attributes = -+ cpu_to_le32(cifsInode->cifsAttrs & (~ATTR_READONLY)); -+ } -+ /* BB to be implemented - via Windows security descriptors or streams */ -+ /* CIFSSMBWinSetPerms(xid,pTcon,full_path,mode,uid,gid,cifs_sb->local_nls);*/ -+ } -+ -+ if (attrs->ia_valid & ATTR_ATIME) { -+ set_time = TRUE; -+ time_buf.LastAccessTime = -+ cpu_to_le64(cifs_UnixTimeToNT(attrs->ia_atime)); -+ } else -+ time_buf.LastAccessTime = 0; -+ -+ if (attrs->ia_valid & ATTR_MTIME) { -+ set_time = TRUE; -+ time_buf.LastWriteTime = -+ cpu_to_le64(cifs_UnixTimeToNT(attrs->ia_mtime)); -+ } else -+ time_buf.LastWriteTime = 0; -+ -+ if (attrs->ia_valid & ATTR_CTIME) { -+ set_time = TRUE; -+ time_buf.ChangeTime = -+ cpu_to_le64(cifs_UnixTimeToNT(attrs->ia_ctime)); -+ } else -+ time_buf.ChangeTime = 0; -+ -+ if (set_time | time_buf.Attributes) { -+ /* BB what if setting one attribute fails -+ (such as size) but time setting works */ -+ time_buf.CreationTime = 0; /* do not change */ -+ /* In the future we should experiment - try setting timestamps -+ via Handle (SetFileInfo) instead of by path */ -+ rc = CIFSSMBSetTimes(xid, pTcon, full_path, &time_buf, -+ cifs_sb->local_nls); -+ } -+ -+ /* do not need local check to inode_check_ok since the server does that */ -+ if (!rc) -+ rc = inode_setattr(direntry->d_inode, attrs); -+ if (full_path) -+ kfree(full_path); -+ FreeXid(xid); -+ return rc; -+} -+ -+void -+cifs_delete_inode(struct inode *inode) -+{ -+ cFYI(1, ("In cifs_delete_inode, inode = 0x%p ", inode)); -+ /* may have to add back in if and when safe distributed caching of -+ directories added e.g. via FindNotify */ -+} ---- /dev/null -+++ b/fs/cifs/link.c -@@ -0,0 +1,328 @@ -+/* -+ * fs/cifs/link.c -+ * -+ * Copyright (C) International Business Machines Corp., 2002,2003 -+ * Author(s): Steve French (sfrench@us.ibm.com) -+ * -+ * This library is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU Lesser General Public License as published -+ * by the Free Software Foundation; either version 2.1 of the License, or -+ * (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -+ * the GNU Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public License -+ * along with this library; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ */ -+#include <linux/fs.h> -+#include <linux/stat.h> -+#include "cifsfs.h" -+#include "cifspdu.h" -+#include "cifsglob.h" -+#include "cifsproto.h" -+#include "cifs_debug.h" -+#include "cifs_fs_sb.h" -+ -+int -+cifs_hardlink(struct dentry *old_file, struct inode *inode, -+ struct dentry *direntry) -+{ -+ int rc = -EACCES; -+ int xid; -+ char *fromName = NULL; -+ char *toName = NULL; -+ struct cifs_sb_info *cifs_sb_target; -+ struct cifsTconInfo *pTcon; -+ struct cifsInodeInfo *cifsInode; -+ -+ xid = GetXid(); -+ -+ cifs_sb_target = CIFS_SB(inode->i_sb); -+ pTcon = cifs_sb_target->tcon; -+ -+/* No need to check for cross device links since server will do that -+ BB note DFS case in future though (when we may have to check) */ -+ -+ down(&inode->i_sb->s_vfs_rename_sem); -+ fromName = build_path_from_dentry(old_file); -+ toName = build_path_from_dentry(direntry); -+ up(&inode->i_sb->s_vfs_rename_sem); -+ if((fromName == NULL) || (toName == NULL)) { -+ rc = -ENOMEM; -+ goto cifs_hl_exit; -+ } -+ -+ if (cifs_sb_target->tcon->ses->capabilities & CAP_UNIX) -+ rc = CIFSUnixCreateHardLink(xid, pTcon, fromName, toName, -+ cifs_sb_target->local_nls); -+ else { -+ rc = CIFSCreateHardLink(xid, pTcon, fromName, toName, -+ cifs_sb_target->local_nls); -+ if(rc == -EIO) -+ rc = -EOPNOTSUPP; -+ } -+ -+/* if (!rc) */ -+ { -+ /* renew_parental_timestamps(old_file); -+ inode->i_nlink++; -+ mark_inode_dirty(inode); -+ d_instantiate(direntry, inode); */ -+ /* BB add call to either mark inode dirty or refresh its data and timestamp to current time */ -+ } -+ d_drop(direntry); /* force new lookup from server */ -+ cifsInode = CIFS_I(old_file->d_inode); -+ cifsInode->time = 0; /* will force revalidate to go get info when needed */ -+ -+cifs_hl_exit: -+ if (fromName) -+ kfree(fromName); -+ if (toName) -+ kfree(toName); -+ FreeXid(xid); -+ return rc; -+} -+ -+int -+cifs_follow_link(struct dentry *direntry, struct nameidata *nd) -+{ -+ struct inode *inode = direntry->d_inode; -+ int rc = -EACCES; -+ int xid; -+ char *full_path = NULL; -+ char * target_path; -+ struct cifs_sb_info *cifs_sb; -+ struct cifsTconInfo *pTcon; -+ -+ xid = GetXid(); -+ -+ down(&direntry->d_sb->s_vfs_rename_sem); -+ full_path = build_path_from_dentry(direntry); -+ up(&direntry->d_sb->s_vfs_rename_sem); -+ -+ if(full_path == NULL) { -+ FreeXid(xid); -+ return -ENOMEM; -+ } -+ cFYI(1, ("Full path: %s inode = 0x%p", full_path, inode)); -+ cifs_sb = CIFS_SB(inode->i_sb); -+ pTcon = cifs_sb->tcon; -+ target_path = kmalloc(PATH_MAX, GFP_KERNEL); -+ if(target_path == NULL) { -+ if (full_path) -+ kfree(full_path); -+ FreeXid(xid); -+ return -ENOMEM; -+ } -+ /* can not call the following line due to EFAULT in vfs_readlink which is presumably expecting a user space buffer */ -+ /* length = cifs_readlink(direntry,target_path, sizeof(target_path) - 1); */ -+ -+/* BB add read reparse point symlink code and Unix extensions symlink code here BB */ -+ if (pTcon->ses->capabilities & CAP_UNIX) -+ rc = CIFSSMBUnixQuerySymLink(xid, pTcon, full_path, -+ target_path, -+ PATH_MAX-1, -+ cifs_sb->local_nls); -+ else { -+ /* rc = CIFSSMBQueryReparseLinkInfo */ -+ /* BB Add code to Query ReparsePoint info */ -+ } -+ /* BB Anything else to do to handle recursive links? */ -+ /* BB Should we be using page symlink ops here? */ -+ -+ if (rc == 0) { -+ -+/* BB Add special case check for Samba DFS symlinks */ -+ -+ target_path[PATH_MAX-1] = 0; -+ rc = vfs_follow_link(nd, target_path); -+ } -+ /* else EACCESS */ -+ -+ if (target_path) -+ kfree(target_path); -+ if (full_path) -+ kfree(full_path); -+ FreeXid(xid); -+ return rc; -+} -+ -+int -+cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname) -+{ -+ int rc = -EOPNOTSUPP; -+ int xid; -+ struct cifs_sb_info *cifs_sb; -+ struct cifsTconInfo *pTcon; -+ char *full_path = NULL; -+ struct inode *newinode = NULL; -+ -+ xid = GetXid(); -+ -+ cifs_sb = CIFS_SB(inode->i_sb); -+ pTcon = cifs_sb->tcon; -+ -+ down(&inode->i_sb->s_vfs_rename_sem); -+ full_path = build_path_from_dentry(direntry); -+ up(&inode->i_sb->s_vfs_rename_sem); -+ -+ if(full_path == NULL) { -+ FreeXid(xid); -+ return -ENOMEM; -+ } -+ -+ cFYI(1, ("Full path: %s ", full_path)); -+ cFYI(1, ("symname is %s", symname)); -+ -+ /* BB what if DFS and this volume is on different share? BB */ -+ if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) -+ rc = CIFSUnixCreateSymLink(xid, pTcon, full_path, symname, -+ cifs_sb->local_nls); -+ /* else -+ rc = CIFSCreateReparseSymLink(xid, pTcon, fromName, toName,cifs_sb_target->local_nls); */ -+ -+ if (rc == 0) { -+ if (pTcon->ses->capabilities & CAP_UNIX) -+ rc = cifs_get_inode_info_unix(&newinode, full_path, -+ inode->i_sb,xid); -+ else -+ rc = cifs_get_inode_info(&newinode, full_path, NULL, -+ inode->i_sb,xid); -+ -+ if (rc != 0) { -+ cFYI(1, -+ ("Create symlink worked but get_inode_info failed with rc = %d ", -+ rc)); -+ } else { -+ direntry->d_op = &cifs_dentry_ops; -+ d_instantiate(direntry, newinode); -+ } -+ } -+ -+ if (full_path) -+ kfree(full_path); -+ FreeXid(xid); -+ return rc; -+} -+ -+int -+cifs_readlink(struct dentry *direntry, char *pBuffer, int buflen) -+{ -+ struct inode *inode = direntry->d_inode; -+ int rc = -EACCES; -+ int xid; -+ int oplock = FALSE; -+ struct cifs_sb_info *cifs_sb; -+ struct cifsTconInfo *pTcon; -+ char *full_path = NULL; -+ char *tmp_path = NULL; -+ char * tmpbuffer; -+ unsigned char * referrals = NULL; -+ int num_referrals = 0; -+ int len; -+ __u16 fid; -+ -+ xid = GetXid(); -+ cifs_sb = CIFS_SB(inode->i_sb); -+ pTcon = cifs_sb->tcon; -+ -+/* BB would it be safe against deadlock to grab this sem -+ even though rename itself grabs the sem and calls lookup? */ -+/* down(&inode->i_sb->s_vfs_rename_sem);*/ -+ full_path = build_path_from_dentry(direntry); -+/* up(&inode->i_sb->s_vfs_rename_sem);*/ -+ -+ if(full_path == NULL) { -+ FreeXid(xid); -+ return -ENOMEM; -+ } -+ -+ cFYI(1, -+ ("Full path: %s inode = 0x%p pBuffer = 0x%p buflen = %d", -+ full_path, inode, pBuffer, buflen)); -+ if(buflen > PATH_MAX) -+ len = PATH_MAX; -+ else -+ len = buflen; -+ tmpbuffer = kmalloc(len,GFP_KERNEL); -+ if(tmpbuffer == NULL) { -+ if (full_path) -+ kfree(full_path); -+ FreeXid(xid); -+ return -ENOMEM; -+ } -+ -+/* BB add read reparse point symlink code and Unix extensions symlink code here BB */ -+ if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) -+ rc = CIFSSMBUnixQuerySymLink(xid, pTcon, full_path, -+ tmpbuffer, -+ len - 1, -+ cifs_sb->local_nls); -+ else { -+ rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, GENERIC_READ, -+ OPEN_REPARSE_POINT,&fid, &oplock, NULL, cifs_sb->local_nls); -+ if(!rc) { -+ rc = CIFSSMBQueryReparseLinkInfo(xid, pTcon, full_path, -+ tmpbuffer, -+ len - 1, -+ fid, -+ cifs_sb->local_nls); -+ if(CIFSSMBClose(xid, pTcon, fid)) { -+ cFYI(1,("Error closing junction point (open for ioctl)")); -+ } -+ if(rc == -EIO) { -+ /* Query if DFS Junction */ -+ tmp_path = -+ kmalloc(MAX_TREE_SIZE + MAX_PATHCONF + 1, -+ GFP_KERNEL); -+ if (tmp_path) { -+ strncpy(tmp_path, pTcon->treeName, MAX_TREE_SIZE); -+ strncat(tmp_path, full_path, MAX_PATHCONF); -+ rc = get_dfs_path(xid, pTcon->ses, tmp_path, -+ cifs_sb->local_nls, &num_referrals, &referrals); -+ cFYI(1,("Get DFS for %s rc = %d ",tmp_path, rc)); -+ if((num_referrals == 0) && (rc == 0)) -+ rc = -EACCES; -+ else { -+ cFYI(1,("num referral: %d",num_referrals)); -+ if(referrals) { -+ cFYI(1,("referral string: %s ",referrals)); -+ strncpy(tmpbuffer, referrals, len-1); -+ } -+ } -+ if(referrals) -+ kfree(referrals); -+ kfree(tmp_path); -+ if(referrals) { -+ kfree(referrals); -+ } -+ } -+ /* BB add code like else decode referrals then memcpy to -+ tmpbuffer and free referrals string array BB */ -+ } -+ } -+ } -+ /* BB Anything else to do to handle recursive links? */ -+ /* BB Should we be using page ops here? */ -+ -+ /* BB null terminate returned string in pBuffer? BB */ -+ if (rc == 0) { -+ rc = vfs_readlink(direntry, pBuffer, len, tmpbuffer); -+ cFYI(1, -+ ("vfs_readlink called from cifs_readlink returned %d", -+ rc)); -+ } -+ -+ if (tmpbuffer) { -+ kfree(tmpbuffer); -+ } -+ if (full_path) { -+ kfree(full_path); -+ } -+ FreeXid(xid); -+ return rc; -+} ---- /dev/null -+++ b/fs/cifs/Makefile -@@ -0,0 +1,10 @@ -+# -+# Makefile for Linux CIFS VFS client -+# -+O_TARGET := cifs.o -+ -+obj-y := cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o inode.o link.o misc.o netmisc.o smbdes.o smbencrypt.o transport.o asn1.o md4.o md5.o cifs_unicode.o nterr.o cifsencrypt.o -+ -+obj-m := $(O_TARGET) -+ -+include $(TOPDIR)/Rules.make ---- /dev/null -+++ b/fs/cifs/md4.c -@@ -0,0 +1,203 @@ -+/* -+ Unix SMB/Netbios implementation. -+ Version 1.9. -+ a implementation of MD4 designed for use in the SMB authentication protocol -+ Copyright (C) Andrew Tridgell 1997-1998. -+ Modified by Steve French (sfrench@us.ibm.com) 2002-2003 -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 2 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software -+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -+*/ -+#include <linux/module.h> -+#include <linux/fs.h> -+/* NOTE: This code makes no attempt to be fast! */ -+ -+static __u32 -+F(__u32 X, __u32 Y, __u32 Z) -+{ -+ return (X & Y) | ((~X) & Z); -+} -+ -+static __u32 -+G(__u32 X, __u32 Y, __u32 Z) -+{ -+ return (X & Y) | (X & Z) | (Y & Z); -+} -+ -+static __u32 -+H(__u32 X, __u32 Y, __u32 Z) -+{ -+ return X ^ Y ^ Z; -+} -+ -+static __u32 -+lshift(__u32 x, int s) -+{ -+ x &= 0xFFFFFFFF; -+ return ((x << s) & 0xFFFFFFFF) | (x >> (32 - s)); -+} -+ -+#define ROUND1(a,b,c,d,k,s) (*a) = lshift((*a) + F(*b,*c,*d) + X[k], s) -+#define ROUND2(a,b,c,d,k,s) (*a) = lshift((*a) + G(*b,*c,*d) + X[k] + (__u32)0x5A827999,s) -+#define ROUND3(a,b,c,d,k,s) (*a) = lshift((*a) + H(*b,*c,*d) + X[k] + (__u32)0x6ED9EBA1,s) -+ -+/* this applies md4 to 64 byte chunks */ -+static void -+mdfour64(__u32 * M, __u32 * A, __u32 *B, __u32 * C, __u32 *D) -+{ -+ int j; -+ __u32 AA, BB, CC, DD; -+ __u32 X[16]; -+ -+ -+ for (j = 0; j < 16; j++) -+ X[j] = M[j]; -+ -+ AA = *A; -+ BB = *B; -+ CC = *C; -+ DD = *D; -+ -+ ROUND1(A, B, C, D, 0, 3); -+ ROUND1(D, A, B, C, 1, 7); -+ ROUND1(C, D, A, B, 2, 11); -+ ROUND1(B, C, D, A, 3, 19); -+ ROUND1(A, B, C, D, 4, 3); -+ ROUND1(D, A, B, C, 5, 7); -+ ROUND1(C, D, A, B, 6, 11); -+ ROUND1(B, C, D, A, 7, 19); -+ ROUND1(A, B, C, D, 8, 3); -+ ROUND1(D, A, B, C, 9, 7); -+ ROUND1(C, D, A, B, 10, 11); -+ ROUND1(B, C, D, A, 11, 19); -+ ROUND1(A, B, C, D, 12, 3); -+ ROUND1(D, A, B, C, 13, 7); -+ ROUND1(C, D, A, B, 14, 11); -+ ROUND1(B, C, D, A, 15, 19); -+ -+ ROUND2(A, B, C, D, 0, 3); -+ ROUND2(D, A, B, C, 4, 5); -+ ROUND2(C, D, A, B, 8, 9); -+ ROUND2(B, C, D, A, 12, 13); -+ ROUND2(A, B, C, D, 1, 3); -+ ROUND2(D, A, B, C, 5, 5); -+ ROUND2(C, D, A, B, 9, 9); -+ ROUND2(B, C, D, A, 13, 13); -+ ROUND2(A, B, C, D, 2, 3); -+ ROUND2(D, A, B, C, 6, 5); -+ ROUND2(C, D, A, B, 10, 9); -+ ROUND2(B, C, D, A, 14, 13); -+ ROUND2(A, B, C, D, 3, 3); -+ ROUND2(D, A, B, C, 7, 5); -+ ROUND2(C, D, A, B, 11, 9); -+ ROUND2(B, C, D, A, 15, 13); -+ -+ ROUND3(A, B, C, D, 0, 3); -+ ROUND3(D, A, B, C, 8, 9); -+ ROUND3(C, D, A, B, 4, 11); -+ ROUND3(B, C, D, A, 12, 15); -+ ROUND3(A, B, C, D, 2, 3); -+ ROUND3(D, A, B, C, 10, 9); -+ ROUND3(C, D, A, B, 6, 11); -+ ROUND3(B, C, D, A, 14, 15); -+ ROUND3(A, B, C, D, 1, 3); -+ ROUND3(D, A, B, C, 9, 9); -+ ROUND3(C, D, A, B, 5, 11); -+ ROUND3(B, C, D, A, 13, 15); -+ ROUND3(A, B, C, D, 3, 3); -+ ROUND3(D, A, B, C, 11, 9); -+ ROUND3(C, D, A, B, 7, 11); -+ ROUND3(B, C, D, A, 15, 15); -+ -+ *A += AA; -+ *B += BB; -+ *C += CC; -+ *D += DD; -+ -+ *A &= 0xFFFFFFFF; -+ *B &= 0xFFFFFFFF; -+ *C &= 0xFFFFFFFF; -+ *D &= 0xFFFFFFFF; -+ -+ for (j = 0; j < 16; j++) -+ X[j] = 0; -+} -+ -+static void -+copy64(__u32 * M, unsigned char *in) -+{ -+ int i; -+ -+ for (i = 0; i < 16; i++) -+ M[i] = (in[i * 4 + 3] << 24) | (in[i * 4 + 2] << 16) | -+ (in[i * 4 + 1] << 8) | (in[i * 4 + 0] << 0); -+} -+ -+static void -+copy4(unsigned char *out, __u32 x) -+{ -+ out[0] = x & 0xFF; -+ out[1] = (x >> 8) & 0xFF; -+ out[2] = (x >> 16) & 0xFF; -+ out[3] = (x >> 24) & 0xFF; -+} -+ -+/* produce a md4 message digest from data of length n bytes */ -+void -+mdfour(unsigned char *out, unsigned char *in, int n) -+{ -+ unsigned char buf[128]; -+ __u32 M[16]; -+ __u32 b = n * 8; -+ int i; -+ __u32 A = 0x67452301; -+ __u32 B = 0xefcdab89; -+ __u32 C = 0x98badcfe; -+ __u32 D = 0x10325476; -+ -+ while (n > 64) { -+ copy64(M, in); -+ mdfour64(M,&A,&B, &C, &D); -+ in += 64; -+ n -= 64; -+ } -+ -+ for (i = 0; i < 128; i++) -+ buf[i] = 0; -+ memcpy(buf, in, n); -+ buf[n] = 0x80; -+ -+ if (n <= 55) { -+ copy4(buf + 56, b); -+ copy64(M, buf); -+ mdfour64(M, &A, &B, &C, &D); -+ } else { -+ copy4(buf + 120, b); -+ copy64(M, buf); -+ mdfour64(M, &A, &B, &C, &D); -+ copy64(M, buf + 64); -+ mdfour64(M, &A, &B, &C, &D); -+ } -+ -+ for (i = 0; i < 128; i++) -+ buf[i] = 0; -+ copy64(M, buf); -+ -+ copy4(out, A); -+ copy4(out + 4, B); -+ copy4(out + 8, C); -+ copy4(out + 12, D); -+ -+ A = B = C = D = 0; -+} ---- /dev/null -+++ b/fs/cifs/md5.c -@@ -0,0 +1,363 @@ -+/* -+ * This code implements the MD5 message-digest algorithm. -+ * The algorithm is due to Ron Rivest. This code was -+ * written by Colin Plumb in 1993, no copyright is claimed. -+ * This code is in the public domain; do with it what you wish. -+ * -+ * Equivalent code is available from RSA Data Security, Inc. -+ * This code has been tested against that, and is equivalent, -+ * except that you don't need to include two pages of legalese -+ * with every copy. -+ * -+ * To compute the message digest of a chunk of bytes, declare an -+ * MD5Context structure, pass it to MD5Init, call MD5Update as -+ * needed on buffers full of bytes, and then call MD5Final, which -+ * will fill a supplied 16-byte array with the digest. -+ */ -+ -+/* This code slightly modified to fit into Samba by -+ abartlet@samba.org Jun 2001 -+ and to fit the cifs vfs by -+ Steve French sfrench@us.ibm.com */ -+ -+#include <linux/string.h> -+#include "md5.h" -+ -+static void MD5Transform(__u32 buf[4], __u32 const in[16]); -+ -+/* -+ * Note: this code is harmless on little-endian machines. -+ */ -+static void -+byteReverse(unsigned char *buf, unsigned longs) -+{ -+ __u32 t; -+ do { -+ t = (__u32) ((unsigned) buf[3] << 8 | buf[2]) << 16 | -+ ((unsigned) buf[1] << 8 | buf[0]); -+ *(__u32 *) buf = t; -+ buf += 4; -+ } while (--longs); -+} -+ -+/* -+ * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious -+ * initialization constants. -+ */ -+void -+MD5Init(struct MD5Context *ctx) -+{ -+ ctx->buf[0] = 0x67452301; -+ ctx->buf[1] = 0xefcdab89; -+ ctx->buf[2] = 0x98badcfe; -+ ctx->buf[3] = 0x10325476; -+ -+ ctx->bits[0] = 0; -+ ctx->bits[1] = 0; -+} -+ -+/* -+ * Update context to reflect the concatenation of another buffer full -+ * of bytes. -+ */ -+void -+MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len) -+{ -+ register __u32 t; -+ -+ /* Update bitcount */ -+ -+ t = ctx->bits[0]; -+ if ((ctx->bits[0] = t + ((__u32) len << 3)) < t) -+ ctx->bits[1]++; /* Carry from low to high */ -+ ctx->bits[1] += len >> 29; -+ -+ t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ -+ -+ /* Handle any leading odd-sized chunks */ -+ -+ if (t) { -+ unsigned char *p = (unsigned char *) ctx->in + t; -+ -+ t = 64 - t; -+ if (len < t) { -+ memmove(p, buf, len); -+ return; -+ } -+ memmove(p, buf, t); -+ byteReverse(ctx->in, 16); -+ MD5Transform(ctx->buf, (__u32 *) ctx->in); -+ buf += t; -+ len -= t; -+ } -+ /* Process data in 64-byte chunks */ -+ -+ while (len >= 64) { -+ memmove(ctx->in, buf, 64); -+ byteReverse(ctx->in, 16); -+ MD5Transform(ctx->buf, (__u32 *) ctx->in); -+ buf += 64; -+ len -= 64; -+ } -+ -+ /* Handle any remaining bytes of data. */ -+ -+ memmove(ctx->in, buf, len); -+} -+ -+/* -+ * Final wrapup - pad to 64-byte boundary with the bit pattern -+ * 1 0* (64-bit count of bits processed, MSB-first) -+ */ -+void -+MD5Final(unsigned char digest[16], struct MD5Context *ctx) -+{ -+ unsigned int count; -+ unsigned char *p; -+ -+ /* Compute number of bytes mod 64 */ -+ count = (ctx->bits[0] >> 3) & 0x3F; -+ -+ /* Set the first char of padding to 0x80. This is safe since there is -+ always at least one byte free */ -+ p = ctx->in + count; -+ *p++ = 0x80; -+ -+ /* Bytes of padding needed to make 64 bytes */ -+ count = 64 - 1 - count; -+ -+ /* Pad out to 56 mod 64 */ -+ if (count < 8) { -+ /* Two lots of padding: Pad the first block to 64 bytes */ -+ memset(p, 0, count); -+ byteReverse(ctx->in, 16); -+ MD5Transform(ctx->buf, (__u32 *) ctx->in); -+ -+ /* Now fill the next block with 56 bytes */ -+ memset(ctx->in, 0, 56); -+ } else { -+ /* Pad block to 56 bytes */ -+ memset(p, 0, count - 8); -+ } -+ byteReverse(ctx->in, 14); -+ -+ /* Append length in bits and transform */ -+ ((__u32 *) ctx->in)[14] = ctx->bits[0]; -+ ((__u32 *) ctx->in)[15] = ctx->bits[1]; -+ -+ MD5Transform(ctx->buf, (__u32 *) ctx->in); -+ byteReverse((unsigned char *) ctx->buf, 4); -+ memmove(digest, ctx->buf, 16); -+ memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ -+} -+ -+/* The four core functions - F1 is optimized somewhat */ -+ -+/* #define F1(x, y, z) (x & y | ~x & z) */ -+#define F1(x, y, z) (z ^ (x & (y ^ z))) -+#define F2(x, y, z) F1(z, x, y) -+#define F3(x, y, z) (x ^ y ^ z) -+#define F4(x, y, z) (y ^ (x | ~z)) -+ -+/* This is the central step in the MD5 algorithm. */ -+#define MD5STEP(f, w, x, y, z, data, s) \ -+ ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x ) -+ -+/* -+ * The core of the MD5 algorithm, this alters an existing MD5 hash to -+ * reflect the addition of 16 longwords of new data. MD5Update blocks -+ * the data and converts bytes into longwords for this routine. -+ */ -+static void -+MD5Transform(__u32 buf[4], __u32 const in[16]) -+{ -+ register __u32 a, b, c, d; -+ -+ a = buf[0]; -+ b = buf[1]; -+ c = buf[2]; -+ d = buf[3]; -+ -+ MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); -+ MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); -+ MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); -+ MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); -+ MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); -+ MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); -+ MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); -+ MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); -+ MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); -+ MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); -+ MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); -+ MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); -+ MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); -+ MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); -+ MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); -+ MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); -+ -+ MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); -+ MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); -+ MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); -+ MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); -+ MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); -+ MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); -+ MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); -+ MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); -+ MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); -+ MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); -+ MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); -+ MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); -+ MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); -+ MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); -+ MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); -+ MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); -+ -+ MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); -+ MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); -+ MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); -+ MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); -+ MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); -+ MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); -+ MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); -+ MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); -+ MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); -+ MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); -+ MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); -+ MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); -+ MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); -+ MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); -+ MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); -+ MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); -+ -+ MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); -+ MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); -+ MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); -+ MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); -+ MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); -+ MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); -+ MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); -+ MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); -+ MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); -+ MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); -+ MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); -+ MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); -+ MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); -+ MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); -+ MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); -+ MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); -+ -+ buf[0] += a; -+ buf[1] += b; -+ buf[2] += c; -+ buf[3] += d; -+} -+ -+/*********************************************************************** -+ the rfc 2104 version of hmac_md5 initialisation. -+***********************************************************************/ -+void -+hmac_md5_init_rfc2104(unsigned char *key, int key_len, -+ struct HMACMD5Context *ctx) -+{ -+ int i; -+ -+ /* if key is longer than 64 bytes reset it to key=MD5(key) */ -+ if (key_len > 64) { -+ unsigned char tk[16]; -+ struct MD5Context tctx; -+ -+ MD5Init(&tctx); -+ MD5Update(&tctx, key, key_len); -+ MD5Final(tk, &tctx); -+ -+ key = tk; -+ key_len = 16; -+ } -+ -+ /* start out by storing key in pads */ -+ memset(ctx->k_ipad, 0, sizeof (ctx->k_ipad)); -+ memset(ctx->k_opad, 0, sizeof (ctx->k_opad)); -+ memcpy(ctx->k_ipad, key, key_len); -+ memcpy(ctx->k_opad, key, key_len); -+ -+ /* XOR key with ipad and opad values */ -+ for (i = 0; i < 64; i++) { -+ ctx->k_ipad[i] ^= 0x36; -+ ctx->k_opad[i] ^= 0x5c; -+ } -+ -+ MD5Init(&ctx->ctx); -+ MD5Update(&ctx->ctx, ctx->k_ipad, 64); -+} -+ -+/*********************************************************************** -+ the microsoft version of hmac_md5 initialisation. -+***********************************************************************/ -+void -+hmac_md5_init_limK_to_64(const unsigned char *key, int key_len, -+ struct HMACMD5Context *ctx) -+{ -+ int i; -+ -+ /* if key is longer than 64 bytes truncate it */ -+ if (key_len > 64) { -+ key_len = 64; -+ } -+ -+ /* start out by storing key in pads */ -+ memset(ctx->k_ipad, 0, sizeof (ctx->k_ipad)); -+ memset(ctx->k_opad, 0, sizeof (ctx->k_opad)); -+ memcpy(ctx->k_ipad, key, key_len); -+ memcpy(ctx->k_opad, key, key_len); -+ -+ /* XOR key with ipad and opad values */ -+ for (i = 0; i < 64; i++) { -+ ctx->k_ipad[i] ^= 0x36; -+ ctx->k_opad[i] ^= 0x5c; -+ } -+ -+ MD5Init(&ctx->ctx); -+ MD5Update(&ctx->ctx, ctx->k_ipad, 64); -+} -+ -+/*********************************************************************** -+ update hmac_md5 "inner" buffer -+***********************************************************************/ -+void -+hmac_md5_update(const unsigned char *text, int text_len, -+ struct HMACMD5Context *ctx) -+{ -+ MD5Update(&ctx->ctx, text, text_len); /* then text of datagram */ -+} -+ -+/*********************************************************************** -+ finish off hmac_md5 "inner" buffer and generate outer one. -+***********************************************************************/ -+void -+hmac_md5_final(unsigned char *digest, struct HMACMD5Context *ctx) -+{ -+ struct MD5Context ctx_o; -+ -+ MD5Final(digest, &ctx->ctx); -+ -+ MD5Init(&ctx_o); -+ MD5Update(&ctx_o, ctx->k_opad, 64); -+ MD5Update(&ctx_o, digest, 16); -+ MD5Final(digest, &ctx_o); -+} -+ -+/*********************************************************** -+ single function to calculate an HMAC MD5 digest from data. -+ use the microsoft hmacmd5 init method because the key is 16 bytes. -+************************************************************/ -+void -+hmac_md5(unsigned char key[16], unsigned char *data, int data_len, -+ unsigned char *digest) -+{ -+ struct HMACMD5Context ctx; -+ hmac_md5_init_limK_to_64(key, 16, &ctx); -+ if (data_len != 0) { -+ hmac_md5_update(data, data_len, &ctx); -+ } -+ hmac_md5_final(digest, &ctx); -+} ---- /dev/null -+++ b/fs/cifs/md5.h -@@ -0,0 +1,38 @@ -+#ifndef MD5_H -+#define MD5_H -+#ifndef HEADER_MD5_H -+/* Try to avoid clashes with OpenSSL */ -+#define HEADER_MD5_H -+#endif -+ -+struct MD5Context { -+ __u32 buf[4]; -+ __u32 bits[2]; -+ unsigned char in[64]; -+}; -+#endif /* !MD5_H */ -+ -+#ifndef _HMAC_MD5_H -+struct HMACMD5Context { -+ struct MD5Context ctx; -+ unsigned char k_ipad[65]; -+ unsigned char k_opad[65]; -+}; -+#endif /* _HMAC_MD5_H */ -+ -+void MD5Init(struct MD5Context *context); -+void MD5Update(struct MD5Context *context, unsigned char const *buf, -+ unsigned len); -+void MD5Final(unsigned char digest[16], struct MD5Context *context); -+ -+/* The following definitions come from lib/hmacmd5.c */ -+ -+void hmac_md5_init_rfc2104(unsigned char *key, int key_len, -+ struct HMACMD5Context *ctx); -+void hmac_md5_init_limK_to_64(const unsigned char *key, int key_len, -+ struct HMACMD5Context *ctx); -+void hmac_md5_update(const unsigned char *text, int text_len, -+ struct HMACMD5Context *ctx); -+void hmac_md5_final(unsigned char *digest, struct HMACMD5Context *ctx); -+void hmac_md5(unsigned char key[16], unsigned char *data, int data_len, -+ unsigned char *digest); ---- /dev/null -+++ b/fs/cifs/misc.c -@@ -0,0 +1,463 @@ -+/* -+ * fs/cifs/misc.c -+ * -+ * Copyright (C) International Business Machines Corp., 2002,2003 -+ * Author(s): Steve French (sfrench@us.ibm.com) -+ * -+ * This library is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU Lesser General Public License as published -+ * by the Free Software Foundation; either version 2.1 of the License, or -+ * (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -+ * the GNU Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public License -+ * along with this library; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ */ -+ -+#include <linux/slab.h> -+#include <linux/ctype.h> -+#include "cifspdu.h" -+#include "cifsglob.h" -+#include "cifsproto.h" -+#include "cifs_debug.h" -+#include "smberr.h" -+#include "nterr.h" -+ -+extern kmem_cache_t *cifs_req_cachep; -+extern struct task_struct * oplockThread; -+ -+__u16 GlobalMid; /* multiplex id - rotating counter */ -+ -+/* The xid serves as a useful identifier for each incoming vfs request, -+ in a similar way to the mid which is useful to track each sent smb, -+ and CurrentXid can also provide a running counter (although it -+ will eventually wrap past zero) of the total vfs operations handled -+ since the cifs fs was mounted */ -+ -+unsigned int -+_GetXid(void) -+{ -+ unsigned int xid; -+ -+ spin_lock(&GlobalMid_Lock); -+ GlobalTotalActiveXid++; -+ if (GlobalTotalActiveXid > GlobalMaxActiveXid) -+ GlobalMaxActiveXid = GlobalTotalActiveXid; /* keep high water mark for number of simultaneous vfs ops in our filesystem */ -+ xid = GlobalCurrentXid++; -+ spin_unlock(&GlobalMid_Lock); -+ return xid; -+} -+ -+void -+_FreeXid(unsigned int xid) -+{ -+ spin_lock(&GlobalMid_Lock); -+ /* if(GlobalTotalActiveXid == 0) -+ BUG(); */ -+ GlobalTotalActiveXid--; -+ spin_unlock(&GlobalMid_Lock); -+} -+ -+struct cifsSesInfo * -+sesInfoAlloc(void) -+{ -+ struct cifsSesInfo *ret_buf; -+ -+ ret_buf = -+ (struct cifsSesInfo *) kmalloc(sizeof (struct cifsSesInfo), -+ GFP_KERNEL); -+ if (ret_buf) { -+ memset(ret_buf, 0, sizeof (struct cifsSesInfo)); -+ write_lock(&GlobalSMBSeslock); -+ atomic_inc(&sesInfoAllocCount); -+ ret_buf->status = CifsNew; -+ list_add(&ret_buf->cifsSessionList, &GlobalSMBSessionList); -+ init_MUTEX(&ret_buf->sesSem); -+ write_unlock(&GlobalSMBSeslock); -+ } -+ return ret_buf; -+} -+ -+void -+sesInfoFree(struct cifsSesInfo *buf_to_free) -+{ -+ if (buf_to_free == NULL) { -+ cFYI(1, ("Null buffer passed to sesInfoFree")); -+ return; -+ } -+ -+ write_lock(&GlobalSMBSeslock); -+ atomic_dec(&sesInfoAllocCount); -+ list_del(&buf_to_free->cifsSessionList); -+ write_unlock(&GlobalSMBSeslock); -+ if (buf_to_free->serverOS) -+ kfree(buf_to_free->serverOS); -+ if (buf_to_free->serverDomain) -+ kfree(buf_to_free->serverDomain); -+ if (buf_to_free->serverNOS) -+ kfree(buf_to_free->serverNOS); -+ if (buf_to_free->password) -+ kfree(buf_to_free->password); -+ kfree(buf_to_free); -+} -+ -+struct cifsTconInfo * -+tconInfoAlloc(void) -+{ -+ struct cifsTconInfo *ret_buf; -+ ret_buf = -+ (struct cifsTconInfo *) kmalloc(sizeof (struct cifsTconInfo), -+ GFP_KERNEL); -+ if (ret_buf) { -+ memset(ret_buf, 0, sizeof (struct cifsTconInfo)); -+ write_lock(&GlobalSMBSeslock); -+ atomic_inc(&tconInfoAllocCount); -+ list_add(&ret_buf->cifsConnectionList, -+ &GlobalTreeConnectionList); -+ ret_buf->tidStatus = CifsNew; -+ INIT_LIST_HEAD(&ret_buf->openFileList); -+ init_MUTEX(&ret_buf->tconSem); -+#ifdef CONFIG_CIFS_STATS -+ ret_buf->stat_lock = SPIN_LOCK_UNLOCKED; -+#endif -+ write_unlock(&GlobalSMBSeslock); -+ } -+ return ret_buf; -+} -+ -+void -+tconInfoFree(struct cifsTconInfo *buf_to_free) -+{ -+ if (buf_to_free == NULL) { -+ cFYI(1, ("Null buffer passed to tconInfoFree")); -+ return; -+ } -+ write_lock(&GlobalSMBSeslock); -+ atomic_dec(&tconInfoAllocCount); -+ list_del(&buf_to_free->cifsConnectionList); -+ write_unlock(&GlobalSMBSeslock); -+ if (buf_to_free->nativeFileSystem) -+ kfree(buf_to_free->nativeFileSystem); -+ kfree(buf_to_free); -+} -+ -+struct smb_hdr * -+cifs_buf_get(void) -+{ -+ struct smb_hdr *ret_buf = NULL; -+ -+/* We could use negotiated size instead of max_msgsize - -+ but it may be more efficient to always alloc same size -+ albeit slightly larger than necessary and maxbuffersize -+ defaults to this and can not be bigger */ -+ ret_buf = -+ (struct smb_hdr *) kmem_cache_alloc(cifs_req_cachep, SLAB_KERNEL); -+ -+ /* clear the first few header bytes */ -+ if (ret_buf) { -+ memset(ret_buf, 0, sizeof (struct smb_hdr)); -+ atomic_inc(&bufAllocCount); -+ } -+ -+ return ret_buf; -+} -+ -+void -+cifs_buf_release(void *buf_to_free) -+{ -+ -+ if (buf_to_free == NULL) { -+ cFYI(1, ("Null buffer passed to cifs_buf_release")); -+ return; -+ } -+ kmem_cache_free(cifs_req_cachep, buf_to_free); -+ -+ atomic_dec(&bufAllocCount); -+ return; -+} -+ -+void -+header_assemble(struct smb_hdr *buffer, char smb_command /* command */ , -+ const struct cifsTconInfo *treeCon, int word_count -+ /* length of fixed section (word count) in two byte units */ -+ ) -+{ -+ int i; -+ __u32 tmp; -+ struct list_head* temp_item; -+ struct cifsSesInfo * ses; -+ char *temp = (char *) buffer; -+ -+ for (i = 0; i < MAX_CIFS_HDR_SIZE; i++) { -+ temp[i] = 0; /* BB is this needed ?? */ -+ } -+ -+ buffer->smb_buf_length = -+ (2 * word_count) + sizeof (struct smb_hdr) - -+ 4 /* RFC 1001 length field does not count */ + -+ 2 /* for bcc field itself */ ; -+ /* Note that this is the only network field that has to be converted to big endian and it is done just before we send it */ -+ -+ buffer->Protocol[0] = 0xFF; -+ buffer->Protocol[1] = 'S'; -+ buffer->Protocol[2] = 'M'; -+ buffer->Protocol[3] = 'B'; -+ buffer->Command = smb_command; -+ buffer->Flags = 0x00; /* case sensitive */ -+ buffer->Flags2 = SMBFLG2_KNOWS_LONG_NAMES; -+ tmp = cpu_to_le32(current->pid); -+ buffer->Pid = tmp & 0xFFFF; -+ tmp >>= 16; -+ buffer->PidHigh = tmp & 0xFFFF; -+ spin_lock(&GlobalMid_Lock); -+ GlobalMid++; -+ buffer->Mid = GlobalMid; -+ spin_unlock(&GlobalMid_Lock); -+ if (treeCon) { -+ buffer->Tid = treeCon->tid; -+ if (treeCon->ses) { -+ if (treeCon->ses->capabilities & CAP_UNICODE) -+ buffer->Flags2 |= SMBFLG2_UNICODE; -+ if (treeCon->ses->capabilities & CAP_STATUS32) { -+ buffer->Flags2 |= SMBFLG2_ERR_STATUS; -+ } -+ -+ buffer->Uid = treeCon->ses->Suid; /* always in LE format */ -+ if(multiuser_mount != 0) { -+ /* For the multiuser case, there are few obvious technically */ -+ /* possible mechanisms to match the local linux user (uid) */ -+ /* to a valid remote smb user (smb_uid): */ -+ /* 1) Query Winbind (or other local pam/nss daemon */ -+ /* for userid/password/logon_domain or credential */ -+ /* 2) Query Winbind for uid to sid to username mapping */ -+ /* and see if we have a matching password for existing*/ -+ /* session for that user perhas getting password by */ -+ /* adding a new pam_cifs module that stores passwords */ -+ /* so that the cifs vfs can get at that for all logged*/ -+ /* on users */ -+ /* 3) (Which is the mechanism we have chosen) */ -+ /* Search through sessions to the same server for a */ -+ /* a match on the uid that was passed in on mount */ -+ /* with the current processes uid (or euid?) and use */ -+ /* that smb uid. If no existing smb session for */ -+ /* that uid found, use the default smb session ie */ -+ /* the smb session for the volume mounted which is */ -+ /* the same as would be used if the multiuser mount */ -+ /* flag were disabled. */ -+ -+ /* BB Add support for establishing new tCon and SMB Session */ -+ /* with userid/password pairs found on the smb session */ -+ /* for other target tcp/ip addresses BB */ -+ if(current->uid != treeCon->ses->linux_uid) { -+ cFYI(1,("Multiuser mode and UID did not match tcon uid ")); -+ read_lock(&GlobalSMBSeslock); -+ list_for_each(temp_item, &GlobalSMBSessionList) { -+ ses = list_entry(temp_item, struct cifsSesInfo, cifsSessionList); -+ if(ses->linux_uid == current->uid) { -+ if(ses->server == treeCon->ses->server) { -+ cFYI(1,("found matching uid substitute right smb_uid")); -+ buffer->Uid = ses->Suid; -+ break; -+ } else { -+ /* BB eventually call cifs_setup_session here */ -+ cFYI(1,("local UID found but smb sess with this server does not exist")); -+ } -+ } -+ } -+ read_unlock(&GlobalSMBSeslock); -+ } -+ } -+ } -+ if (treeCon->Flags & SMB_SHARE_IS_IN_DFS) -+ buffer->Flags2 |= SMBFLG2_DFS; -+ if(treeCon->ses->server) -+ if(treeCon->ses->server->secMode & -+ (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) -+ buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; -+ } -+ -+/* endian conversion of flags is now done just before sending */ -+ buffer->WordCount = (char) word_count; -+ return; -+} -+ -+int -+checkSMBhdr(struct smb_hdr *smb, __u16 mid) -+{ -+ /* Make sure that this really is an SMB, that it is a response, -+ and that the message ids match */ -+ if ((*(unsigned int *) smb->Protocol == cpu_to_le32(0x424d53ff)) && -+ (mid == smb->Mid)) { -+ if(smb->Flags & SMBFLG_RESPONSE) -+ return 0; -+ else { -+ /* only one valid case where server sends us request */ -+ if(smb->Command == SMB_COM_LOCKING_ANDX) -+ return 0; -+ else -+ cERROR(1, ("Rcvd Request not response ")); -+ } -+ } else { /* bad signature or mid */ -+ if (*(unsigned int *) smb->Protocol != cpu_to_le32(0x424d53ff)) -+ cERROR(1, -+ ("Bad protocol string signature header %x ", -+ *(unsigned int *) smb->Protocol)); -+ if (mid != smb->Mid) -+ cERROR(1, ("Mids do not match")); -+ } -+ cERROR(1, ("bad smb detected. The Mid=%d", smb->Mid)); -+ return 1; -+} -+ -+int -+checkSMB(struct smb_hdr *smb, __u16 mid, int length) -+{ -+ cFYI(0, -+ ("Entering checkSMB with Length: %x, smb_buf_length: %x ", -+ length, ntohl(smb->smb_buf_length))); -+ if (((unsigned int)length < 2 + sizeof (struct smb_hdr)) -+ || (ntohl(smb->smb_buf_length) > -+ CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE - 4)) { -+ if ((unsigned int)length < 2 + sizeof (struct smb_hdr)) { -+ cERROR(1, ("Length less than 2 + sizeof smb_hdr ")); -+ if (((unsigned int)length >= sizeof (struct smb_hdr) - 1) -+ && (smb->Status.CifsError != 0)) -+ return 0; /* some error cases do not return wct and bcc */ -+ -+ } -+ if (ntohl(smb->smb_buf_length) > -+ CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE - 4) -+ cERROR(1, -+ ("smb_buf_length greater than CIFS_MAX_MSGSIZE ... ")); -+ cERROR(1, -+ ("bad smb detected. Illegal length. The mid=%d", -+ smb->Mid)); -+ return 1; -+ } -+ -+ if (checkSMBhdr(smb, mid)) -+ return 1; -+ -+ if ((4 + ntohl(smb->smb_buf_length) != smbCalcSize(smb)) -+ || (4 + ntohl(smb->smb_buf_length) != (unsigned int)length)) { -+ return 0; -+ } else { -+ cERROR(1, ("smbCalcSize %x ", smbCalcSize(smb))); -+ cERROR(1, -+ ("bad smb size detected. The Mid=%d", smb->Mid)); -+ return 1; -+ } -+} -+int -+is_valid_oplock_break(struct smb_hdr *buf) -+{ -+ struct smb_com_lock_req * pSMB = (struct smb_com_lock_req *)buf; -+ struct list_head *tmp; -+ struct list_head *tmp1; -+ struct cifsTconInfo *tcon; -+ struct cifsFileInfo *netfile; -+ -+ /* could add check for smb response flag 0x80 */ -+ cFYI(1,("Checking for oplock break")); -+ if(pSMB->hdr.Command != SMB_COM_LOCKING_ANDX) -+ return FALSE; -+ if(pSMB->hdr.Flags & SMBFLG_RESPONSE) { -+ /* no sense logging error on invalid handle on oplock -+ break - harmless race between close request and oplock -+ break response is expected from time to time writing out -+ large dirty files cached on the client */ -+ if ((NT_STATUS_INVALID_HANDLE) == -+ le32_to_cpu(pSMB->hdr.Status.CifsError)) { -+ cFYI(1,("invalid handle on oplock break")); -+ return TRUE; -+ } else if (ERRbadfid == -+ le16_to_cpu(pSMB->hdr.Status.DosError.Error)) { -+ return TRUE; -+ } else { -+ return FALSE; /* on valid oplock brk we get "request" */ -+ } -+ } -+ if(pSMB->hdr.WordCount != 8) -+ return FALSE; -+ -+ cFYI(1,(" oplock type 0x%d level 0x%d",pSMB->LockType,pSMB->OplockLevel)); -+ if(!(pSMB->LockType & LOCKING_ANDX_OPLOCK_RELEASE)) -+ return FALSE; -+ -+ /* look up tcon based on tid & uid */ -+ read_lock(&GlobalSMBSeslock); -+ list_for_each(tmp, &GlobalTreeConnectionList) { -+ tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); -+ if (tcon->tid == buf->Tid) { -+#ifdef CONFIG_CIFS_STATS -+ atomic_inc(&tcon->num_oplock_brks); -+#endif -+ list_for_each(tmp1,&tcon->openFileList){ -+ netfile = list_entry(tmp1,struct cifsFileInfo,tlist); -+ if(pSMB->Fid == netfile->netfid) { -+ struct cifsInodeInfo *pCifsInode; -+ read_unlock(&GlobalSMBSeslock); -+ cFYI(1,("Matching file id, processing oplock break")); -+ pCifsInode = -+ CIFS_I(netfile->pInode); -+ pCifsInode->clientCanCacheAll = FALSE; -+ if(pSMB->OplockLevel == 0) -+ pCifsInode->clientCanCacheRead = FALSE; -+ pCifsInode->oplockPending = TRUE; -+ AllocOplockQEntry(netfile->pInode, netfile->netfid, tcon); -+ cFYI(1,("about to wake up oplock thd")); -+ wake_up_process(oplockThread); -+ return TRUE; -+ } -+ } -+ read_unlock(&GlobalSMBSeslock); -+ cFYI(1,("No matching file for oplock break on connection")); -+ return TRUE; -+ } -+ } -+ read_unlock(&GlobalSMBSeslock); -+ cFYI(1,("Can not process oplock break for non-existent connection")); -+ return TRUE; -+} -+ -+void -+dump_smb(struct smb_hdr *smb_buf, int smb_buf_length) -+{ -+ int i, j; -+ char debug_line[17]; -+ unsigned char *buffer; -+ -+ if (traceSMB == 0) -+ return; -+ -+ buffer = (unsigned char *) smb_buf; -+ for (i = 0, j = 0; i < smb_buf_length; i++, j++) { -+ if (i % 8 == 0) { /* we have reached the beginning of line */ -+ printk(KERN_DEBUG "| "); -+ j = 0; -+ } -+ printk("%0#4x ", buffer[i]); -+ debug_line[2 * j] = ' '; -+ if (isprint(buffer[i])) -+ debug_line[1 + (2 * j)] = buffer[i]; -+ else -+ debug_line[1 + (2 * j)] = '_'; -+ -+ if (i % 8 == 7) { /* we have reached end of line, time to print ascii */ -+ debug_line[16] = 0; -+ printk(" | %s\n", debug_line); -+ } -+ } -+ for (; j < 8; j++) { -+ printk(" "); -+ debug_line[2 * j] = ' '; -+ debug_line[1 + (2 * j)] = ' '; -+ } -+ printk( " | %s\n", debug_line); -+ return; -+} ---- /dev/null -+++ b/fs/cifs/netmisc.c -@@ -0,0 +1,905 @@ -+/* -+ * fs/cifs/netmisc.c -+ * -+ * Copyright (c) International Business Machines Corp., 2002 -+ * Author(s): Steve French (sfrench@us.ibm.com) -+ * -+ * Error mapping routines from Samba libsmb/errormap.c -+ * Copyright (C) Andrew Tridgell 2001 -+ * -+ * -+ * 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 -+ */ -+ -+#include <linux/net.h> -+#include <linux/string.h> -+#include <linux/in.h> -+#include <linux/ctype.h> -+#include <linux/fs.h> -+#include <asm/div64.h> -+#include <asm/byteorder.h> -+#include "cifsfs.h" -+#include "cifspdu.h" -+#include "cifsglob.h" -+#include "cifsproto.h" -+#include "smberr.h" -+#include "cifs_debug.h" -+#include "nterr.h" -+ -+struct smb_to_posix_error { -+ __u16 smb_err; -+ int posix_code; -+}; -+ -+const struct smb_to_posix_error mapping_table_ERRDOS[] = { -+ {ERRbadfunc, -EINVAL}, -+ {ERRbadfile, -ENOENT}, -+ {ERRbadpath, -ENOTDIR}, -+ {ERRnofids, -EMFILE}, -+ {ERRnoaccess, -EACCES}, -+ {ERRbadfid, -EBADF}, -+ {ERRbadmcb, -EIO}, -+ {ERRnomem, -ENOMEM}, -+ {ERRbadmem, -EFAULT}, -+ {ERRbadenv, -EFAULT}, -+ {ERRbadformat, -EINVAL}, -+ {ERRbadaccess, -EACCES}, -+ {ERRbaddata, -EIO}, -+ {ERRbaddrive, -ENXIO}, -+ {ERRremcd, -EACCES}, -+ {ERRdiffdevice, -EXDEV}, -+ {ERRnofiles, -ENOENT}, -+ {ERRbadshare, -ETXTBSY}, -+ {ERRlock, -EACCES}, -+ {ERRunsup, -EINVAL}, -+ {ERRnosuchshare,-ENXIO}, -+ {ERRfilexists, -EEXIST}, -+ {ERRinvparm, -EINVAL}, -+ {ERRdiskfull, -ENOSPC}, -+ {ERRinvname, -ENOENT}, -+ {ERRdirnotempty, -ENOTEMPTY}, -+ {ERRnotlocked, -ENOLCK}, -+ {ERRalreadyexists, -EEXIST}, -+ {ERRmoredata, -EOVERFLOW}, -+ {ErrQuota, -EDQUOT}, -+ {ErrNotALink, -ENOLINK}, -+ {ERRnetlogonNotStarted,-ENOPROTOOPT}, -+ {0, 0} -+}; -+ -+const struct smb_to_posix_error mapping_table_ERRSRV[] = { -+ {ERRerror, -EIO}, -+ {ERRbadpw, -EPERM}, -+ {ERRbadtype, -EREMOTE}, -+ {ERRaccess, -EACCES}, -+ {ERRinvtid, -ENXIO}, -+ {ERRinvnetname, -ENODEV}, -+ {ERRinvdevice, -ENXIO}, -+ {ERRqfull, -ENOSPC}, -+ {ERRqtoobig, -ENOSPC}, -+ {ERRqeof, -EIO}, -+ {ERRinvpfid, -EBADF}, -+ {ERRsmbcmd, -EBADRQC}, -+ {ERRsrverror, -EIO}, -+ {ERRbadBID, -EIO}, -+ {ERRfilespecs, -EINVAL}, -+ {ERRbadLink, -EIO}, -+ {ERRbadpermits, -EINVAL}, -+ {ERRbadPID, -ESRCH}, -+ {ERRsetattrmode, -EINVAL}, -+ {ERRpaused, -EHOSTDOWN}, -+ {ERRmsgoff, -EHOSTDOWN}, -+ {ERRnoroom, -ENOSPC}, -+ {ERRrmuns, -EUSERS}, -+ {ERRtimeout, -ETIME}, -+ {ERRnoresource, -ENOBUFS}, -+ {ERRtoomanyuids, -EUSERS}, -+ {ERRbaduid, -EACCES}, -+ {ERRusempx, -EIO}, -+ {ERRusestd, -EIO}, -+ {ERR_NOTIFY_ENUM_DIR, -ENOBUFS}, -+ {ERRaccountexpired, -EACCES}, -+ {ERRbadclient, -EACCES}, -+ {ERRbadLogonTime, -EACCES}, -+ {ERRpasswordExpired, -EACCES}, -+ {ERRnosupport, -EINVAL}, -+ {0, 0} -+}; -+ -+const struct smb_to_posix_error mapping_table_ERRHRD[] = { -+ {0, 0} -+}; -+ -+/* Convert string containing dotted ip address to binary form */ -+/* returns 0 if invalid address */ -+ -+/* BB add address family, change rc to status flag and return union or for ipv6 */ -+/* will need parent to call something like inet_pton to convert ipv6 address BB */ -+int -+cifs_inet_pton(int address_family, char *cp,void *dst) -+{ -+ struct in_addr address; -+ int value; -+ int digit; -+ int i; -+ char temp; -+ char bytes[4]; -+ char *end = bytes; -+ static const int addr_class_max[4] = -+ { 0xffffffff, 0xffffff, 0xffff, 0xff }; -+ -+ if(address_family != AF_INET) -+ return -EAFNOSUPPORT; -+ -+ for (i = 0; i < 4; i++) { -+ bytes[i] = 0; -+ } -+ -+ temp = *cp; -+ -+ while (TRUE) { -+ if (!isdigit(temp)) -+ return 0; -+ -+ value = 0; -+ digit = 0; -+ for (;;) { -+ if (isascii(temp) && isdigit(temp)) { -+ value = (value * 10) + temp - '0'; -+ temp = *++cp; -+ digit = 1; -+ } else -+ break; -+ } -+ -+ if (temp == '.') { -+ if ((end > bytes + 2) || (value > 255)) -+ return 0; -+ *end++ = value; -+ temp = *++cp; -+ } else if (temp == ':') { -+ cFYI(1,("IPv6 addresses not supported for CIFS mounts yet")); -+ return -1; -+ } else -+ break; -+ } -+ -+ /* check for last characters */ -+ if (temp != '\0' && (!isascii(temp) || !isspace(temp))) -+ if (temp != '\\') { -+ if (temp != '/') -+ return 0; -+ else -+ (*cp = '\\'); /* switch the slash the expected way */ -+ } -+ if (value > addr_class_max[end - bytes]) -+ return 0; -+ -+ address.s_addr = *((int *) bytes) | htonl(value); -+ *((int *)dst) = address.s_addr; -+ return 1; /* success */ -+} -+ -+/***************************************************************************** -+convert a NT status code to a dos class/code -+ *****************************************************************************/ -+/* NT status -> dos error map */ -+static const struct { -+ __u8 dos_class; -+ __u16 dos_code; -+ __u32 ntstatus; -+} ntstatus_to_dos_map[] = { -+ { -+ ERRDOS, ERRgeneral, NT_STATUS_UNSUCCESSFUL}, { -+ ERRDOS, ERRbadfunc, NT_STATUS_NOT_IMPLEMENTED}, { -+ ERRDOS, 87, NT_STATUS_INVALID_INFO_CLASS}, { -+ ERRDOS, 24, NT_STATUS_INFO_LENGTH_MISMATCH}, { -+ ERRHRD, ERRgeneral, NT_STATUS_ACCESS_VIOLATION}, { -+ ERRHRD, ERRgeneral, NT_STATUS_IN_PAGE_ERROR}, { -+ ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_QUOTA}, { -+ ERRDOS, ERRbadfid, NT_STATUS_INVALID_HANDLE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_BAD_INITIAL_STACK}, { -+ ERRDOS, 193, NT_STATUS_BAD_INITIAL_PC}, { -+ ERRDOS, 87, NT_STATUS_INVALID_CID}, { -+ ERRHRD, ERRgeneral, NT_STATUS_TIMER_NOT_CANCELED}, { -+ ERRDOS, 87, NT_STATUS_INVALID_PARAMETER}, { -+ ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_DEVICE}, { -+ ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_FILE}, { -+ ERRDOS, ERRbadfunc, NT_STATUS_INVALID_DEVICE_REQUEST}, { -+ ERRDOS, 38, NT_STATUS_END_OF_FILE}, { -+ ERRDOS, 34, NT_STATUS_WRONG_VOLUME}, { -+ ERRDOS, 21, NT_STATUS_NO_MEDIA_IN_DEVICE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_UNRECOGNIZED_MEDIA}, { -+ ERRDOS, 27, NT_STATUS_NONEXISTENT_SECTOR}, -+/* { This NT error code was 'sqashed' -+ from NT_STATUS_MORE_PROCESSING_REQUIRED to NT_STATUS_OK -+ during the session setup } */ -+ { -+ ERRDOS, ERRnomem, NT_STATUS_NO_MEMORY}, { -+ ERRDOS, 487, NT_STATUS_CONFLICTING_ADDRESSES}, { -+ ERRDOS, 487, NT_STATUS_NOT_MAPPED_VIEW}, { -+ ERRDOS, 87, NT_STATUS_UNABLE_TO_FREE_VM}, { -+ ERRDOS, 87, NT_STATUS_UNABLE_TO_DELETE_SECTION}, { -+ ERRDOS, 2142, NT_STATUS_INVALID_SYSTEM_SERVICE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_INSTRUCTION}, { -+ ERRDOS, ERRnoaccess, NT_STATUS_INVALID_LOCK_SEQUENCE}, { -+ ERRDOS, ERRnoaccess, NT_STATUS_INVALID_VIEW_SIZE}, { -+ ERRDOS, 193, NT_STATUS_INVALID_FILE_FOR_SECTION}, { -+ ERRDOS, ERRnoaccess, NT_STATUS_ALREADY_COMMITTED}, -+/* { This NT error code was 'sqashed' -+ from NT_STATUS_ACCESS_DENIED to NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE -+ during the session setup } */ -+ { -+ ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED}, { -+ ERRDOS, 111, NT_STATUS_BUFFER_TOO_SMALL}, { -+ ERRDOS, ERRbadfid, NT_STATUS_OBJECT_TYPE_MISMATCH}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NONCONTINUABLE_EXCEPTION}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_DISPOSITION}, { -+ ERRHRD, ERRgeneral, NT_STATUS_UNWIND}, { -+ ERRHRD, ERRgeneral, NT_STATUS_BAD_STACK}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_UNWIND_TARGET}, { -+ ERRDOS, 158, NT_STATUS_NOT_LOCKED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_PARITY_ERROR}, { -+ ERRDOS, 487, NT_STATUS_UNABLE_TO_DECOMMIT_VM}, { -+ ERRDOS, 487, NT_STATUS_NOT_COMMITTED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_PORT_ATTRIBUTES}, { -+ ERRHRD, ERRgeneral, NT_STATUS_PORT_MESSAGE_TOO_LONG}, { -+ ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_MIX}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_QUOTA_LOWER}, { -+ ERRHRD, ERRgeneral, NT_STATUS_DISK_CORRUPT_ERROR}, { -+ ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_INVALID}, { /* mapping changed since shell does lookup on * and expects file not found */ -+ ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_NOT_FOUND}, { -+ ERRDOS, ERRalreadyexists, NT_STATUS_OBJECT_NAME_COLLISION}, { -+ ERRHRD, ERRgeneral, NT_STATUS_HANDLE_NOT_WAITABLE}, { -+ ERRDOS, ERRbadfid, NT_STATUS_PORT_DISCONNECTED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_DEVICE_ALREADY_ATTACHED}, { -+ ERRDOS, 161, NT_STATUS_OBJECT_PATH_INVALID}, { -+ ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND}, { -+ ERRDOS, 161, NT_STATUS_OBJECT_PATH_SYNTAX_BAD}, { -+ ERRHRD, ERRgeneral, NT_STATUS_DATA_OVERRUN}, { -+ ERRHRD, ERRgeneral, NT_STATUS_DATA_LATE_ERROR}, { -+ ERRDOS, 23, NT_STATUS_DATA_ERROR}, { -+ ERRDOS, 23, NT_STATUS_CRC_ERROR}, { -+ ERRDOS, ERRnomem, NT_STATUS_SECTION_TOO_BIG}, { -+ ERRDOS, ERRnoaccess, NT_STATUS_PORT_CONNECTION_REFUSED}, { -+ ERRDOS, ERRbadfid, NT_STATUS_INVALID_PORT_HANDLE}, { -+ ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION}, { -+ ERRHRD, ERRgeneral, NT_STATUS_QUOTA_EXCEEDED}, { -+ ERRDOS, 87, NT_STATUS_INVALID_PAGE_PROTECTION}, { -+ ERRDOS, 288, NT_STATUS_MUTANT_NOT_OWNED}, { -+ ERRDOS, 298, NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED}, { -+ ERRDOS, 87, NT_STATUS_PORT_ALREADY_SET}, { -+ ERRDOS, 87, NT_STATUS_SECTION_NOT_IMAGE}, { -+ ERRDOS, 156, NT_STATUS_SUSPEND_COUNT_EXCEEDED}, { -+ ERRDOS, ERRnoaccess, NT_STATUS_THREAD_IS_TERMINATING}, { -+ ERRDOS, 87, NT_STATUS_BAD_WORKING_SET_LIMIT}, { -+ ERRDOS, 87, NT_STATUS_INCOMPATIBLE_FILE_MAP}, { -+ ERRDOS, 87, NT_STATUS_SECTION_PROTECTION}, { -+ ERRDOS, 282, NT_STATUS_EAS_NOT_SUPPORTED}, { -+ ERRDOS, 255, NT_STATUS_EA_TOO_LARGE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NONEXISTENT_EA_ENTRY}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NO_EAS_ON_FILE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_EA_CORRUPT_ERROR}, { -+ ERRDOS, ERRlock, NT_STATUS_FILE_LOCK_CONFLICT}, { -+ ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED}, { -+ ERRDOS, ERRbadfile, NT_STATUS_DELETE_PENDING}, { -+ ERRDOS, ERRunsup, NT_STATUS_CTL_FILE_NOT_SUPPORTED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_UNKNOWN_REVISION}, { -+ ERRHRD, ERRgeneral, NT_STATUS_REVISION_MISMATCH}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_OWNER}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_PRIMARY_GROUP}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NO_IMPERSONATION_TOKEN}, { -+ ERRHRD, ERRgeneral, NT_STATUS_CANT_DISABLE_MANDATORY}, { -+ ERRDOS, 2215, NT_STATUS_NO_LOGON_SERVERS}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_LOGON_SESSION}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_PRIVILEGE}, { -+ ERRDOS, ERRnoaccess, NT_STATUS_PRIVILEGE_NOT_HELD}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_ACCOUNT_NAME}, { -+ ERRHRD, ERRgeneral, NT_STATUS_USER_EXISTS}, -+/* { This NT error code was 'sqashed' -+ from NT_STATUS_NO_SUCH_USER to NT_STATUS_LOGON_FAILURE -+ during the session setup } */ -+ { -+ ERRDOS, ERRnoaccess, NT_STATUS_NO_SUCH_USER}, { -+ ERRHRD, ERRgeneral, NT_STATUS_GROUP_EXISTS}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_GROUP}, { -+ ERRHRD, ERRgeneral, NT_STATUS_MEMBER_IN_GROUP}, { -+ ERRHRD, ERRgeneral, NT_STATUS_MEMBER_NOT_IN_GROUP}, { -+ ERRHRD, ERRgeneral, NT_STATUS_LAST_ADMIN}, -+/* { This NT error code was 'sqashed' -+ from NT_STATUS_WRONG_PASSWORD to NT_STATUS_LOGON_FAILURE -+ during the session setup } */ -+ { -+ ERRSRV, ERRbadpw, NT_STATUS_WRONG_PASSWORD}, { -+ ERRHRD, ERRgeneral, NT_STATUS_ILL_FORMED_PASSWORD}, { -+ ERRHRD, ERRgeneral, NT_STATUS_PASSWORD_RESTRICTION}, { -+ ERRDOS, ERRnoaccess, NT_STATUS_LOGON_FAILURE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_ACCOUNT_RESTRICTION}, { -+ ERRSRV, 2241, NT_STATUS_INVALID_LOGON_HOURS}, { -+ ERRSRV, 2240, NT_STATUS_INVALID_WORKSTATION}, { -+ ERRSRV, 2242, NT_STATUS_PASSWORD_EXPIRED}, { -+ ERRSRV, 2239, NT_STATUS_ACCOUNT_DISABLED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NONE_MAPPED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_LUIDS_REQUESTED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_LUIDS_EXHAUSTED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_SUB_AUTHORITY}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_ACL}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_SID}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_SECURITY_DESCR}, { -+ ERRDOS, 127, NT_STATUS_PROCEDURE_NOT_FOUND}, { -+ ERRDOS, 193, NT_STATUS_INVALID_IMAGE_FORMAT}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NO_TOKEN}, { -+ ERRHRD, ERRgeneral, NT_STATUS_BAD_INHERITANCE_ACL}, { -+ ERRDOS, 158, NT_STATUS_RANGE_NOT_LOCKED}, { -+ ERRDOS, 112, NT_STATUS_DISK_FULL}, { -+ ERRHRD, ERRgeneral, NT_STATUS_SERVER_DISABLED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_SERVER_NOT_DISABLED}, { -+ ERRDOS, 68, NT_STATUS_TOO_MANY_GUIDS_REQUESTED}, { -+ ERRDOS, 259, NT_STATUS_GUIDS_EXHAUSTED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_ID_AUTHORITY}, { -+ ERRDOS, 259, NT_STATUS_AGENTS_EXHAUSTED}, { -+ ERRDOS, 154, NT_STATUS_INVALID_VOLUME_LABEL}, { -+ ERRDOS, 14, NT_STATUS_SECTION_NOT_EXTENDED}, { -+ ERRDOS, 487, NT_STATUS_NOT_MAPPED_DATA}, { -+ ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_DATA_NOT_FOUND}, { -+ ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_TYPE_NOT_FOUND}, { -+ ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_NAME_NOT_FOUND}, { -+ ERRHRD, ERRgeneral, NT_STATUS_ARRAY_BOUNDS_EXCEEDED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_FLOAT_DENORMAL_OPERAND}, { -+ ERRHRD, ERRgeneral, NT_STATUS_FLOAT_DIVIDE_BY_ZERO}, { -+ ERRHRD, ERRgeneral, NT_STATUS_FLOAT_INEXACT_RESULT}, { -+ ERRHRD, ERRgeneral, NT_STATUS_FLOAT_INVALID_OPERATION}, { -+ ERRHRD, ERRgeneral, NT_STATUS_FLOAT_OVERFLOW}, { -+ ERRHRD, ERRgeneral, NT_STATUS_FLOAT_STACK_CHECK}, { -+ ERRHRD, ERRgeneral, NT_STATUS_FLOAT_UNDERFLOW}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INTEGER_DIVIDE_BY_ZERO}, { -+ ERRDOS, 534, NT_STATUS_INTEGER_OVERFLOW}, { -+ ERRHRD, ERRgeneral, NT_STATUS_PRIVILEGED_INSTRUCTION}, { -+ ERRDOS, ERRnomem, NT_STATUS_TOO_MANY_PAGING_FILES}, { -+ ERRHRD, ERRgeneral, NT_STATUS_FILE_INVALID}, { -+ ERRHRD, ERRgeneral, NT_STATUS_ALLOTTED_SPACE_EXCEEDED}, -+/* { This NT error code was 'sqashed' -+ from NT_STATUS_INSUFFICIENT_RESOURCES to NT_STATUS_INSUFF_SERVER_RESOURCES -+ during the session setup } */ -+ { -+ ERRDOS, ERRnomem, NT_STATUS_INSUFFICIENT_RESOURCES}, { -+ ERRDOS, ERRbadpath, NT_STATUS_DFS_EXIT_PATH_FOUND}, { -+ ERRDOS, 23, NT_STATUS_DEVICE_DATA_ERROR}, { -+ ERRHRD, ERRgeneral, NT_STATUS_DEVICE_NOT_CONNECTED}, { -+ ERRDOS, 21, NT_STATUS_DEVICE_POWER_FAILURE}, { -+ ERRDOS, 487, NT_STATUS_FREE_VM_NOT_AT_BASE}, { -+ ERRDOS, 487, NT_STATUS_MEMORY_NOT_ALLOCATED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_WORKING_SET_QUOTA}, { -+ ERRDOS, 19, NT_STATUS_MEDIA_WRITE_PROTECTED}, { -+ ERRDOS, 21, NT_STATUS_DEVICE_NOT_READY}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_GROUP_ATTRIBUTES}, { -+ ERRHRD, ERRgeneral, NT_STATUS_BAD_IMPERSONATION_LEVEL}, { -+ ERRHRD, ERRgeneral, NT_STATUS_CANT_OPEN_ANONYMOUS}, { -+ ERRHRD, ERRgeneral, NT_STATUS_BAD_VALIDATION_CLASS}, { -+ ERRHRD, ERRgeneral, NT_STATUS_BAD_TOKEN_TYPE}, { -+ ERRDOS, 87, NT_STATUS_BAD_MASTER_BOOT_RECORD}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INSTRUCTION_MISALIGNMENT}, { -+ ERRDOS, ERRpipebusy, NT_STATUS_INSTANCE_NOT_AVAILABLE}, { -+ ERRDOS, ERRpipebusy, NT_STATUS_PIPE_NOT_AVAILABLE}, { -+ ERRDOS, ERRbadpipe, NT_STATUS_INVALID_PIPE_STATE}, { -+ ERRDOS, ERRpipebusy, NT_STATUS_PIPE_BUSY}, { -+ ERRDOS, ERRbadfunc, NT_STATUS_ILLEGAL_FUNCTION}, { -+ ERRDOS, ERRnotconnected, NT_STATUS_PIPE_DISCONNECTED}, { -+ ERRDOS, ERRpipeclosing, NT_STATUS_PIPE_CLOSING}, { -+ ERRHRD, ERRgeneral, NT_STATUS_PIPE_CONNECTED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_PIPE_LISTENING}, { -+ ERRDOS, ERRbadpipe, NT_STATUS_INVALID_READ_MODE}, { -+ ERRDOS, 121, NT_STATUS_IO_TIMEOUT}, { -+ ERRDOS, 38, NT_STATUS_FILE_FORCED_CLOSED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_PROFILING_NOT_STARTED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_PROFILING_NOT_STOPPED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_COULD_NOT_INTERPRET}, { -+ ERRDOS, ERRnoaccess, NT_STATUS_FILE_IS_A_DIRECTORY}, { -+ ERRDOS, ERRunsup, NT_STATUS_NOT_SUPPORTED}, { -+ ERRDOS, 51, NT_STATUS_REMOTE_NOT_LISTENING}, { -+ ERRDOS, 52, NT_STATUS_DUPLICATE_NAME}, { -+ ERRDOS, 53, NT_STATUS_BAD_NETWORK_PATH}, { -+ ERRDOS, 54, NT_STATUS_NETWORK_BUSY}, { -+ ERRDOS, 55, NT_STATUS_DEVICE_DOES_NOT_EXIST}, { -+ ERRDOS, 56, NT_STATUS_TOO_MANY_COMMANDS}, { -+ ERRDOS, 57, NT_STATUS_ADAPTER_HARDWARE_ERROR}, { -+ ERRDOS, 58, NT_STATUS_INVALID_NETWORK_RESPONSE}, { -+ ERRDOS, 59, NT_STATUS_UNEXPECTED_NETWORK_ERROR}, { -+ ERRDOS, 60, NT_STATUS_BAD_REMOTE_ADAPTER}, { -+ ERRDOS, 61, NT_STATUS_PRINT_QUEUE_FULL}, { -+ ERRDOS, 62, NT_STATUS_NO_SPOOL_SPACE}, { -+ ERRDOS, 63, NT_STATUS_PRINT_CANCELLED}, { -+ ERRDOS, 64, NT_STATUS_NETWORK_NAME_DELETED}, { -+ ERRDOS, 65, NT_STATUS_NETWORK_ACCESS_DENIED}, { -+ ERRDOS, 66, NT_STATUS_BAD_DEVICE_TYPE}, { -+ ERRDOS, ERRnosuchshare, NT_STATUS_BAD_NETWORK_NAME}, { -+ ERRDOS, 68, NT_STATUS_TOO_MANY_NAMES}, { -+ ERRDOS, 69, NT_STATUS_TOO_MANY_SESSIONS}, { -+ ERRDOS, 70, NT_STATUS_SHARING_PAUSED}, { -+ ERRDOS, 71, NT_STATUS_REQUEST_NOT_ACCEPTED}, { -+ ERRDOS, 72, NT_STATUS_REDIRECTOR_PAUSED}, { -+ ERRDOS, 88, NT_STATUS_NET_WRITE_FAULT}, { -+ ERRHRD, ERRgeneral, NT_STATUS_PROFILING_AT_LIMIT}, { -+ ERRDOS, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE}, { -+ ERRDOS, ERRnoaccess, NT_STATUS_FILE_RENAMED}, { -+ ERRDOS, 240, NT_STATUS_VIRTUAL_CIRCUIT_CLOSED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NO_SECURITY_ON_OBJECT}, { -+ ERRHRD, ERRgeneral, NT_STATUS_CANT_WAIT}, { -+ ERRDOS, ERRpipeclosing, NT_STATUS_PIPE_EMPTY}, { -+ ERRHRD, ERRgeneral, NT_STATUS_CANT_ACCESS_DOMAIN_INFO}, { -+ ERRHRD, ERRgeneral, NT_STATUS_CANT_TERMINATE_SELF}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_SERVER_STATE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_DOMAIN_STATE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_DOMAIN_ROLE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_DOMAIN}, { -+ ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_EXISTS}, { -+ ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_LIMIT_EXCEEDED}, { -+ ERRDOS, 300, NT_STATUS_OPLOCK_NOT_GRANTED}, { -+ ERRDOS, 301, NT_STATUS_INVALID_OPLOCK_PROTOCOL}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_DB_CORRUPTION}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_ERROR}, { -+ ERRHRD, ERRgeneral, NT_STATUS_GENERIC_NOT_MAPPED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_BAD_DESCRIPTOR_FORMAT}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_USER_BUFFER}, { -+ ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_IO_ERROR}, { -+ ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_CREATE_ERR}, { -+ ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_MAP_ERROR}, { -+ ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_EXTEND_ERR}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NOT_LOGON_PROCESS}, { -+ ERRHRD, ERRgeneral, NT_STATUS_LOGON_SESSION_EXISTS}, { -+ ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_1}, { -+ ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_2}, { -+ ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_3}, { -+ ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_4}, { -+ ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_5}, { -+ ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_6}, { -+ ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_7}, { -+ ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_8}, { -+ ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_9}, { -+ ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_10}, { -+ ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_11}, { -+ ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_12}, { -+ ERRDOS, ERRbadpath, NT_STATUS_REDIRECTOR_NOT_STARTED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_REDIRECTOR_STARTED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_STACK_OVERFLOW}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_PACKAGE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_BAD_FUNCTION_TABLE}, { -+ ERRDOS, 203, 0xc0000100}, { -+ ERRDOS, 145, NT_STATUS_DIRECTORY_NOT_EMPTY}, { -+ ERRHRD, ERRgeneral, NT_STATUS_FILE_CORRUPT_ERROR}, { -+ ERRDOS, 267, NT_STATUS_NOT_A_DIRECTORY}, { -+ ERRHRD, ERRgeneral, NT_STATUS_BAD_LOGON_SESSION_STATE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_LOGON_SESSION_COLLISION}, { -+ ERRDOS, 206, NT_STATUS_NAME_TOO_LONG}, { -+ ERRDOS, 2401, NT_STATUS_FILES_OPEN}, { -+ ERRDOS, 2404, NT_STATUS_CONNECTION_IN_USE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_MESSAGE_NOT_FOUND}, { -+ ERRDOS, ERRnoaccess, NT_STATUS_PROCESS_IS_TERMINATING}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_LOGON_TYPE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NO_GUID_TRANSLATION}, { -+ ERRHRD, ERRgeneral, NT_STATUS_CANNOT_IMPERSONATE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_IMAGE_ALREADY_LOADED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_ABIOS_NOT_PRESENT}, { -+ ERRHRD, ERRgeneral, NT_STATUS_ABIOS_LID_NOT_EXIST}, { -+ ERRHRD, ERRgeneral, NT_STATUS_ABIOS_LID_ALREADY_OWNED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_ABIOS_NOT_LID_OWNER}, { -+ ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_COMMAND}, { -+ ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_LID}, { -+ ERRHRD, ERRgeneral, NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_SELECTOR}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NO_LDT}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_SIZE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_OFFSET}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_DESCRIPTOR}, { -+ ERRDOS, 193, NT_STATUS_INVALID_IMAGE_NE_FORMAT}, { -+ ERRHRD, ERRgeneral, NT_STATUS_RXACT_INVALID_STATE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_RXACT_COMMIT_FAILURE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_MAPPED_FILE_SIZE_ZERO}, { -+ ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES}, { -+ ERRHRD, ERRgeneral, NT_STATUS_CANCELLED}, { -+ ERRDOS, ERRnoaccess, NT_STATUS_CANNOT_DELETE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_COMPUTER_NAME}, { -+ ERRDOS, ERRnoaccess, NT_STATUS_FILE_DELETED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_ACCOUNT}, { -+ ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_GROUP}, { -+ ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_USER}, { -+ ERRHRD, ERRgeneral, NT_STATUS_MEMBERS_PRIMARY_GROUP}, { -+ ERRDOS, ERRbadfid, NT_STATUS_FILE_CLOSED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_THREADS}, { -+ ERRHRD, ERRgeneral, NT_STATUS_THREAD_NOT_IN_PROCESS}, { -+ ERRHRD, ERRgeneral, NT_STATUS_TOKEN_ALREADY_IN_USE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_QUOTA_EXCEEDED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_COMMITMENT_LIMIT}, { -+ ERRDOS, 193, NT_STATUS_INVALID_IMAGE_LE_FORMAT}, { -+ ERRDOS, 193, NT_STATUS_INVALID_IMAGE_NOT_MZ}, { -+ ERRDOS, 193, NT_STATUS_INVALID_IMAGE_PROTECT}, { -+ ERRDOS, 193, NT_STATUS_INVALID_IMAGE_WIN_16}, { -+ ERRHRD, ERRgeneral, NT_STATUS_LOGON_SERVER_CONFLICT}, { -+ ERRHRD, ERRgeneral, NT_STATUS_TIME_DIFFERENCE_AT_DC}, { -+ ERRHRD, ERRgeneral, NT_STATUS_SYNCHRONIZATION_REQUIRED}, { -+ ERRDOS, 126, NT_STATUS_DLL_NOT_FOUND}, { -+ ERRHRD, ERRgeneral, NT_STATUS_OPEN_FAILED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_IO_PRIVILEGE_FAILED}, { -+ ERRDOS, 182, NT_STATUS_ORDINAL_NOT_FOUND}, { -+ ERRDOS, 127, NT_STATUS_ENTRYPOINT_NOT_FOUND}, { -+ ERRHRD, ERRgeneral, NT_STATUS_CONTROL_C_EXIT}, { -+ ERRDOS, 64, NT_STATUS_LOCAL_DISCONNECT}, { -+ ERRDOS, 64, NT_STATUS_REMOTE_DISCONNECT}, { -+ ERRDOS, 51, NT_STATUS_REMOTE_RESOURCES}, { -+ ERRDOS, 59, NT_STATUS_LINK_FAILED}, { -+ ERRDOS, 59, NT_STATUS_LINK_TIMEOUT}, { -+ ERRDOS, 59, NT_STATUS_INVALID_CONNECTION}, { -+ ERRDOS, 59, NT_STATUS_INVALID_ADDRESS}, { -+ ERRHRD, ERRgeneral, NT_STATUS_DLL_INIT_FAILED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_MISSING_SYSTEMFILE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_UNHANDLED_EXCEPTION}, { -+ ERRHRD, ERRgeneral, NT_STATUS_APP_INIT_FAILURE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_CREATE_FAILED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NO_PAGEFILE}, { -+ ERRDOS, 124, NT_STATUS_INVALID_LEVEL}, { -+ ERRDOS, 86, NT_STATUS_WRONG_PASSWORD_CORE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_FLOAT_CONTEXT}, { -+ ERRDOS, 109, NT_STATUS_PIPE_BROKEN}, { -+ ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_CORRUPT}, { -+ ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_IO_FAILED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NO_EVENT_PAIR}, { -+ ERRHRD, ERRgeneral, NT_STATUS_UNRECOGNIZED_VOLUME}, { -+ ERRHRD, ERRgeneral, NT_STATUS_SERIAL_NO_DEVICE_INITED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_ALIAS}, { -+ ERRHRD, ERRgeneral, NT_STATUS_MEMBER_NOT_IN_ALIAS}, { -+ ERRHRD, ERRgeneral, NT_STATUS_MEMBER_IN_ALIAS}, { -+ ERRHRD, ERRgeneral, NT_STATUS_ALIAS_EXISTS}, { -+ ERRHRD, ERRgeneral, NT_STATUS_LOGON_NOT_GRANTED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_SECRETS}, { -+ ERRHRD, ERRgeneral, NT_STATUS_SECRET_TOO_LONG}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_DB_ERROR}, { -+ ERRHRD, ERRgeneral, NT_STATUS_FULLSCREEN_MODE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_CONTEXT_IDS}, { -+ ERRDOS, ERRnoaccess, NT_STATUS_LOGON_TYPE_NOT_GRANTED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NOT_REGISTRY_FILE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR}, { -+ ERRHRD, ERRgeneral, NT_STATUS_FT_MISSING_MEMBER}, { -+ ERRHRD, ERRgeneral, NT_STATUS_ILL_FORMED_SERVICE_ENTRY}, { -+ ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_CHARACTER}, { -+ ERRHRD, ERRgeneral, NT_STATUS_UNMAPPABLE_CHARACTER}, { -+ ERRHRD, ERRgeneral, NT_STATUS_UNDEFINED_CHARACTER}, { -+ ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_VOLUME}, { -+ ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND}, { -+ ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_WRONG_CYLINDER}, { -+ ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_UNKNOWN_ERROR}, { -+ ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_BAD_REGISTERS}, { -+ ERRHRD, ERRgeneral, NT_STATUS_DISK_RECALIBRATE_FAILED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_DISK_OPERATION_FAILED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_DISK_RESET_FAILED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_SHARED_IRQ_BUSY}, { -+ ERRHRD, ERRgeneral, NT_STATUS_FT_ORPHANING}, { -+ ERRHRD, ERRgeneral, 0xc000016e}, { -+ ERRHRD, ERRgeneral, 0xc000016f}, { -+ ERRHRD, ERRgeneral, 0xc0000170}, { -+ ERRHRD, ERRgeneral, 0xc0000171}, { -+ ERRHRD, ERRgeneral, NT_STATUS_PARTITION_FAILURE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_BLOCK_LENGTH}, { -+ ERRHRD, ERRgeneral, NT_STATUS_DEVICE_NOT_PARTITIONED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_UNABLE_TO_LOCK_MEDIA}, { -+ ERRHRD, ERRgeneral, NT_STATUS_UNABLE_TO_UNLOAD_MEDIA}, { -+ ERRHRD, ERRgeneral, NT_STATUS_EOM_OVERFLOW}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NO_MEDIA}, { -+ ERRHRD, ERRgeneral, 0xc0000179}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_MEMBER}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_MEMBER}, { -+ ERRHRD, ERRgeneral, NT_STATUS_KEY_DELETED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NO_LOG_SPACE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_SIDS}, { -+ ERRHRD, ERRgeneral, NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_KEY_HAS_CHILDREN}, { -+ ERRHRD, ERRgeneral, NT_STATUS_CHILD_MUST_BE_VOLATILE}, { -+ ERRDOS, 87, NT_STATUS_DEVICE_CONFIGURATION_ERROR}, { -+ ERRHRD, ERRgeneral, NT_STATUS_DRIVER_INTERNAL_ERROR}, { -+ ERRDOS, 22, NT_STATUS_INVALID_DEVICE_STATE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_IO_DEVICE_ERROR}, { -+ ERRHRD, ERRgeneral, NT_STATUS_DEVICE_PROTOCOL_ERROR}, { -+ ERRHRD, ERRgeneral, NT_STATUS_BACKUP_CONTROLLER}, { -+ ERRHRD, ERRgeneral, NT_STATUS_LOG_FILE_FULL}, { -+ ERRDOS, 19, NT_STATUS_TOO_LATE}, { -+ ERRDOS, ERRnoaccess, NT_STATUS_NO_TRUST_LSA_SECRET}, -+/* { This NT error code was 'sqashed' -+ from NT_STATUS_NO_TRUST_SAM_ACCOUNT to NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE -+ during the session setup } */ -+ { -+ ERRDOS, ERRnoaccess, NT_STATUS_NO_TRUST_SAM_ACCOUNT}, { -+ ERRDOS, ERRnoaccess, NT_STATUS_TRUSTED_DOMAIN_FAILURE}, { -+ ERRDOS, ERRnoaccess, NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_FILE_CORRUPT}, { -+ ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_CANT_START}, { -+ ERRDOS, ERRnoaccess, NT_STATUS_TRUST_FAILURE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_MUTANT_LIMIT_EXCEEDED}, { -+ ERRDOS, ERRnetlogonNotStarted, NT_STATUS_NETLOGON_NOT_STARTED}, { -+ ERRSRV, 2239, NT_STATUS_ACCOUNT_EXPIRED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_POSSIBLE_DEADLOCK}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NETWORK_CREDENTIAL_CONFLICT}, { -+ ERRHRD, ERRgeneral, NT_STATUS_REMOTE_SESSION_LIMIT}, { -+ ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_FILE_CHANGED}, { -+ ERRDOS, ERRnoaccess, NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT}, { -+ ERRDOS, ERRnoaccess, NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT}, { -+ ERRDOS, ERRnoaccess, NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT}, -+/* { This NT error code was 'sqashed' -+ from NT_STATUS_DOMAIN_TRUST_INCONSISTENT to NT_STATUS_LOGON_FAILURE -+ during the session setup } */ -+ { -+ ERRDOS, ERRnoaccess, NT_STATUS_DOMAIN_TRUST_INCONSISTENT}, { -+ ERRHRD, ERRgeneral, NT_STATUS_FS_DRIVER_REQUIRED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NO_USER_SESSION_KEY}, { -+ ERRDOS, 59, NT_STATUS_USER_SESSION_DELETED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_LANG_NOT_FOUND}, { -+ ERRDOS, ERRnomem, NT_STATUS_INSUFF_SERVER_RESOURCES}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_BUFFER_SIZE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_ADDRESS_COMPONENT}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_ADDRESS_WILDCARD}, { -+ ERRDOS, 68, NT_STATUS_TOO_MANY_ADDRESSES}, { -+ ERRDOS, 52, NT_STATUS_ADDRESS_ALREADY_EXISTS}, { -+ ERRDOS, 64, NT_STATUS_ADDRESS_CLOSED}, { -+ ERRDOS, 64, NT_STATUS_CONNECTION_DISCONNECTED}, { -+ ERRDOS, 64, NT_STATUS_CONNECTION_RESET}, { -+ ERRDOS, 68, NT_STATUS_TOO_MANY_NODES}, { -+ ERRDOS, 59, NT_STATUS_TRANSACTION_ABORTED}, { -+ ERRDOS, 59, NT_STATUS_TRANSACTION_TIMED_OUT}, { -+ ERRDOS, 59, NT_STATUS_TRANSACTION_NO_RELEASE}, { -+ ERRDOS, 59, NT_STATUS_TRANSACTION_NO_MATCH}, { -+ ERRDOS, 59, NT_STATUS_TRANSACTION_RESPONDED}, { -+ ERRDOS, 59, NT_STATUS_TRANSACTION_INVALID_ID}, { -+ ERRDOS, 59, NT_STATUS_TRANSACTION_INVALID_TYPE}, { -+ ERRDOS, ERRunsup, NT_STATUS_NOT_SERVER_SESSION}, { -+ ERRDOS, ERRunsup, NT_STATUS_NOT_CLIENT_SESSION}, { -+ ERRHRD, ERRgeneral, NT_STATUS_CANNOT_LOAD_REGISTRY_FILE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_DEBUG_ATTACH_FAILED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_SYSTEM_PROCESS_TERMINATED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_DATA_NOT_ACCEPTED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NO_BROWSER_SERVERS_FOUND}, { -+ ERRHRD, ERRgeneral, NT_STATUS_VDM_HARD_ERROR}, { -+ ERRHRD, ERRgeneral, NT_STATUS_DRIVER_CANCEL_TIMEOUT}, { -+ ERRHRD, ERRgeneral, NT_STATUS_REPLY_MESSAGE_MISMATCH}, { -+ ERRHRD, ERRgeneral, NT_STATUS_MAPPED_ALIGNMENT}, { -+ ERRDOS, 193, NT_STATUS_IMAGE_CHECKSUM_MISMATCH}, { -+ ERRHRD, ERRgeneral, NT_STATUS_LOST_WRITEBEHIND_DATA}, { -+ ERRHRD, ERRgeneral, NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID}, { -+ ERRSRV, 2242, NT_STATUS_PASSWORD_MUST_CHANGE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NOT_FOUND}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NOT_TINY_STREAM}, { -+ ERRHRD, ERRgeneral, NT_STATUS_RECOVERY_FAILURE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_STACK_OVERFLOW_READ}, { -+ ERRHRD, ERRgeneral, NT_STATUS_FAIL_CHECK}, { -+ ERRHRD, ERRgeneral, NT_STATUS_DUPLICATE_OBJECTID}, { -+ ERRHRD, ERRgeneral, NT_STATUS_OBJECTID_EXISTS}, { -+ ERRHRD, ERRgeneral, NT_STATUS_CONVERT_TO_LARGE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_RETRY}, { -+ ERRHRD, ERRgeneral, NT_STATUS_FOUND_OUT_OF_SCOPE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_ALLOCATE_BUCKET}, { -+ ERRHRD, ERRgeneral, NT_STATUS_PROPSET_NOT_FOUND}, { -+ ERRHRD, ERRgeneral, NT_STATUS_MARSHALL_OVERFLOW}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_VARIANT}, { -+ ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND}, { -+ ERRDOS, ERRnoaccess, NT_STATUS_ACCOUNT_LOCKED_OUT}, { -+ ERRDOS, ERRbadfid, NT_STATUS_HANDLE_NOT_CLOSABLE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_REFUSED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_GRACEFUL_DISCONNECT}, { -+ ERRHRD, ERRgeneral, NT_STATUS_ADDRESS_ALREADY_ASSOCIATED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_ADDRESS_NOT_ASSOCIATED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_INVALID}, { -+ ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_ACTIVE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NETWORK_UNREACHABLE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_HOST_UNREACHABLE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_PROTOCOL_UNREACHABLE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_PORT_UNREACHABLE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_REQUEST_ABORTED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_ABORTED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_BAD_COMPRESSION_BUFFER}, { -+ ERRHRD, ERRgeneral, NT_STATUS_USER_MAPPED_FILE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_AUDIT_FAILED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_TIMER_RESOLUTION_NOT_SET}, { -+ ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_COUNT_LIMIT}, { -+ ERRHRD, ERRgeneral, NT_STATUS_LOGIN_TIME_RESTRICTION}, { -+ ERRHRD, ERRgeneral, NT_STATUS_LOGIN_WKSTA_RESTRICTION}, { -+ ERRDOS, 193, NT_STATUS_IMAGE_MP_UP_MISMATCH}, { -+ ERRHRD, ERRgeneral, 0xc000024a}, { -+ ERRHRD, ERRgeneral, 0xc000024b}, { -+ ERRHRD, ERRgeneral, 0xc000024c}, { -+ ERRHRD, ERRgeneral, 0xc000024d}, { -+ ERRHRD, ERRgeneral, 0xc000024e}, { -+ ERRHRD, ERRgeneral, 0xc000024f}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INSUFFICIENT_LOGON_INFO}, { -+ ERRHRD, ERRgeneral, NT_STATUS_BAD_DLL_ENTRYPOINT}, { -+ ERRHRD, ERRgeneral, NT_STATUS_BAD_SERVICE_ENTRYPOINT}, { -+ ERRHRD, ERRgeneral, NT_STATUS_LPC_REPLY_LOST}, { -+ ERRHRD, ERRgeneral, NT_STATUS_IP_ADDRESS_CONFLICT1}, { -+ ERRHRD, ERRgeneral, NT_STATUS_IP_ADDRESS_CONFLICT2}, { -+ ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_QUOTA_LIMIT}, { -+ ERRSRV, 3, NT_STATUS_PATH_NOT_COVERED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_NO_CALLBACK_ACTIVE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_LICENSE_QUOTA_EXCEEDED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_PWD_TOO_SHORT}, { -+ ERRHRD, ERRgeneral, NT_STATUS_PWD_TOO_RECENT}, { -+ ERRHRD, ERRgeneral, NT_STATUS_PWD_HISTORY_CONFLICT}, { -+ ERRHRD, ERRgeneral, 0xc000025d}, { -+ ERRHRD, ERRgeneral, NT_STATUS_PLUGPLAY_NO_DEVICE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_UNSUPPORTED_COMPRESSION}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_HW_PROFILE}, { -+ ERRHRD, ERRgeneral, NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH}, { -+ ERRDOS, 182, NT_STATUS_DRIVER_ORDINAL_NOT_FOUND}, { -+ ERRDOS, 127, NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND}, { -+ ERRDOS, 288, NT_STATUS_RESOURCE_NOT_OWNED}, { -+ ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_LINKS}, { -+ ERRHRD, ERRgeneral, NT_STATUS_QUOTA_LIST_INCONSISTENT}, { -+ ERRHRD, ERRgeneral, NT_STATUS_FILE_IS_OFFLINE}, { -+ ERRDOS, 21, 0xc000026e}, { -+ ERRDOS, 161, 0xc0000281}, { -+ ERRDOS, ERRnoaccess, 0xc000028a}, { -+ ERRDOS, ERRnoaccess, 0xc000028b}, { -+ ERRHRD, ERRgeneral, 0xc000028c}, { -+ ERRDOS, ERRnoaccess, 0xc000028d}, { -+ ERRDOS, ERRnoaccess, 0xc000028e}, { -+ ERRDOS, ERRnoaccess, 0xc000028f}, { -+ ERRDOS, ERRnoaccess, 0xc0000290}, { -+ERRDOS, ERRbadfunc, 0xc000029c},}; -+ -+/***************************************************************************** -+ Print an error message from the status code -+ *****************************************************************************/ -+static void -+cifs_print_status(__u32 status_code) -+{ -+ int idx = 0; -+ -+ while (nt_errs[idx].nt_errstr != NULL) { -+ if (((nt_errs[idx].nt_errcode) & 0xFFFFFF) == -+ (status_code & 0xFFFFFF)) { -+ printk(KERN_NOTICE "Status code returned 0x%08x %s\n", -+ status_code,nt_errs[idx].nt_errstr); -+ } -+ idx++; -+ } -+ return; -+} -+ -+ -+static void -+ntstatus_to_dos(__u32 ntstatus, __u8 * eclass, __u16 * ecode) -+{ -+ int i; -+ if (ntstatus == 0) { -+ *eclass = 0; -+ *ecode = 0; -+ return; -+ } -+ for (i = 0; ntstatus_to_dos_map[i].ntstatus; i++) { -+ if (ntstatus == ntstatus_to_dos_map[i].ntstatus) { -+ *eclass = ntstatus_to_dos_map[i].dos_class; -+ *ecode = ntstatus_to_dos_map[i].dos_code; -+ return; -+ } -+ } -+ *eclass = ERRHRD; -+ *ecode = ERRgeneral; -+} -+ -+int -+map_smb_to_linux_error(struct smb_hdr *smb) -+{ -+ unsigned int i; -+ int rc = -EIO; /* if transport error smb error may not be set */ -+ __u8 smberrclass; -+ __u16 smberrcode; -+ -+ /* BB if NT Status codes - map NT BB */ -+ -+ /* old style smb error codes */ -+ if (smb->Status.CifsError == 0) -+ return 0; -+ -+ if (smb->Flags2 & SMBFLG2_ERR_STATUS) { -+ /* translate the newer STATUS codes to old style errors and then to POSIX errors */ -+ smb->Status.CifsError = le32_to_cpu(smb->Status.CifsError); -+ if(cifsFYI) -+ cifs_print_status(smb->Status.CifsError); -+ ntstatus_to_dos(smb->Status.CifsError, &smberrclass, -+ &smberrcode); -+ } else { -+ smberrclass = smb->Status.DosError.ErrorClass; -+ smb->Status.DosError.Error = -+ le16_to_cpu(smb->Status.DosError.Error); -+ smberrcode = smb->Status.DosError.Error; -+ } -+ -+ /* old style errors */ -+ -+ /* DOS class smb error codes - map DOS */ -+ if (smberrclass == ERRDOS) { /* one byte field no need to byte reverse */ -+ for (i = 0; -+ i < -+ sizeof (mapping_table_ERRDOS) / -+ sizeof (struct smb_to_posix_error); i++) { -+ if (mapping_table_ERRDOS[i].smb_err == 0) -+ break; -+ else if (mapping_table_ERRDOS[i].smb_err == smberrcode) { -+ rc = mapping_table_ERRDOS[i].posix_code; -+ break; -+ } -+ /* else try the next error mapping one to see if it will match */ -+ } -+ } else if (smberrclass == ERRSRV) { /* server class of error codes */ -+ for (i = 0; -+ i < -+ sizeof (mapping_table_ERRSRV) / -+ sizeof (struct smb_to_posix_error); i++) { -+ if (mapping_table_ERRSRV[i].smb_err == 0) -+ break; -+ else if (mapping_table_ERRSRV[i].smb_err == smberrcode) { -+ rc = mapping_table_ERRSRV[i].posix_code; -+ break; -+ } -+ /* else try the next error mapping one to see if it will match */ -+ } -+ } -+ /* else ERRHRD class errors or junk - return EIO */ -+ -+ cFYI(1, (" !!Mapping smb error code %d to POSIX err %d !!", smberrcode,rc)); -+ -+ /* generic corrective action e.g. reconnect SMB session on ERRbaduid could be added */ -+ -+ return rc; -+} -+ -+/* -+ * calculate the size of the SMB message based on the fixed header -+ * portion, the number of word parameters and the data portion of the message -+ */ -+unsigned int -+smbCalcSize(struct smb_hdr *ptr) -+{ -+ return (sizeof (struct smb_hdr) + (2 * ptr->WordCount) + -+ BCC(ptr)); -+} -+ -+/* The following are taken from fs/ntfs/util.c */ -+ -+#define NTFS_TIME_OFFSET ((u64)(369*365 + 89) * 24 * 3600 * 10000000) -+ -+ /* -+ * Convert the NT UTC (based 1601-01-01, in hundred nanosecond units) -+ * into Unix UTC (based 1970-01-01, in seconds). -+ */ -+time_t -+cifs_NTtimeToUnix(__u64 ntutc) -+{ -+ /* BB what about the timezone? BB */ -+ -+ /* Subtract the NTFS time offset, then convert to 1s intervals. */ -+ u64 t; -+ -+ t = ntutc - NTFS_TIME_OFFSET; -+ do_div(t, 10000000); -+ return (time_t)t; -+} -+ -+/* Convert the Unix UTC into NT UTC. */ -+__u64 -+cifs_UnixTimeToNT(time_t t) -+{ -+ __u64 dce_time; -+ /* Convert to 100ns intervals and then add the NTFS time offset. */ -+ dce_time = (__u64) t * 10000000; -+ dce_time += NTFS_TIME_OFFSET; -+ return dce_time; -+} ---- /dev/null -+++ b/fs/cifs/nterr.c -@@ -0,0 +1,687 @@ -+/* -+ * Unix SMB/Netbios implementation. -+ * Version 1.9. -+ * RPC Pipe client / server routines -+ * Copyright (C) Luke Kenneth Casson Leighton 1997-2001. -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -+ */ -+ -+/* NT error codes - see nterr.h */ -+#include <linux/types.h> -+#include <linux/fs.h> -+#include "nterr.h" -+ -+const struct nt_err_code_struct nt_errs[] = { -+ {"NT_STATUS_OK", NT_STATUS_OK}, -+ {"NT_STATUS_UNSUCCESSFUL", NT_STATUS_UNSUCCESSFUL}, -+ {"NT_STATUS_NOT_IMPLEMENTED", NT_STATUS_NOT_IMPLEMENTED}, -+ {"NT_STATUS_INVALID_INFO_CLASS", NT_STATUS_INVALID_INFO_CLASS}, -+ {"NT_STATUS_INFO_LENGTH_MISMATCH", NT_STATUS_INFO_LENGTH_MISMATCH}, -+ {"NT_STATUS_ACCESS_VIOLATION", NT_STATUS_ACCESS_VIOLATION}, -+ {"STATUS_BUFFER_OVERFLOW", STATUS_BUFFER_OVERFLOW}, -+ {"NT_STATUS_IN_PAGE_ERROR", NT_STATUS_IN_PAGE_ERROR}, -+ {"NT_STATUS_PAGEFILE_QUOTA", NT_STATUS_PAGEFILE_QUOTA}, -+ {"NT_STATUS_INVALID_HANDLE", NT_STATUS_INVALID_HANDLE}, -+ {"NT_STATUS_BAD_INITIAL_STACK", NT_STATUS_BAD_INITIAL_STACK}, -+ {"NT_STATUS_BAD_INITIAL_PC", NT_STATUS_BAD_INITIAL_PC}, -+ {"NT_STATUS_INVALID_CID", NT_STATUS_INVALID_CID}, -+ {"NT_STATUS_TIMER_NOT_CANCELED", NT_STATUS_TIMER_NOT_CANCELED}, -+ {"NT_STATUS_INVALID_PARAMETER", NT_STATUS_INVALID_PARAMETER}, -+ {"NT_STATUS_NO_SUCH_DEVICE", NT_STATUS_NO_SUCH_DEVICE}, -+ {"NT_STATUS_NO_SUCH_FILE", NT_STATUS_NO_SUCH_FILE}, -+ {"NT_STATUS_INVALID_DEVICE_REQUEST", -+ NT_STATUS_INVALID_DEVICE_REQUEST}, -+ {"NT_STATUS_END_OF_FILE", NT_STATUS_END_OF_FILE}, -+ {"NT_STATUS_WRONG_VOLUME", NT_STATUS_WRONG_VOLUME}, -+ {"NT_STATUS_NO_MEDIA_IN_DEVICE", NT_STATUS_NO_MEDIA_IN_DEVICE}, -+ {"NT_STATUS_UNRECOGNIZED_MEDIA", NT_STATUS_UNRECOGNIZED_MEDIA}, -+ {"NT_STATUS_NONEXISTENT_SECTOR", NT_STATUS_NONEXISTENT_SECTOR}, -+ {"NT_STATUS_MORE_PROCESSING_REQUIRED", -+ NT_STATUS_MORE_PROCESSING_REQUIRED}, -+ {"NT_STATUS_NO_MEMORY", NT_STATUS_NO_MEMORY}, -+ {"NT_STATUS_CONFLICTING_ADDRESSES", -+ NT_STATUS_CONFLICTING_ADDRESSES}, -+ {"NT_STATUS_NOT_MAPPED_VIEW", NT_STATUS_NOT_MAPPED_VIEW}, -+ {"NT_STATUS_UNABLE_TO_FREE_VM", NT_STATUS_UNABLE_TO_FREE_VM}, -+ {"NT_STATUS_UNABLE_TO_DELETE_SECTION", -+ NT_STATUS_UNABLE_TO_DELETE_SECTION}, -+ {"NT_STATUS_INVALID_SYSTEM_SERVICE", -+ NT_STATUS_INVALID_SYSTEM_SERVICE}, -+ {"NT_STATUS_ILLEGAL_INSTRUCTION", NT_STATUS_ILLEGAL_INSTRUCTION}, -+ {"NT_STATUS_INVALID_LOCK_SEQUENCE", -+ NT_STATUS_INVALID_LOCK_SEQUENCE}, -+ {"NT_STATUS_INVALID_VIEW_SIZE", NT_STATUS_INVALID_VIEW_SIZE}, -+ {"NT_STATUS_INVALID_FILE_FOR_SECTION", -+ NT_STATUS_INVALID_FILE_FOR_SECTION}, -+ {"NT_STATUS_ALREADY_COMMITTED", NT_STATUS_ALREADY_COMMITTED}, -+ {"NT_STATUS_ACCESS_DENIED", NT_STATUS_ACCESS_DENIED}, -+ {"NT_STATUS_BUFFER_TOO_SMALL", NT_STATUS_BUFFER_TOO_SMALL}, -+ {"NT_STATUS_OBJECT_TYPE_MISMATCH", NT_STATUS_OBJECT_TYPE_MISMATCH}, -+ {"NT_STATUS_NONCONTINUABLE_EXCEPTION", -+ NT_STATUS_NONCONTINUABLE_EXCEPTION}, -+ {"NT_STATUS_INVALID_DISPOSITION", NT_STATUS_INVALID_DISPOSITION}, -+ {"NT_STATUS_UNWIND", NT_STATUS_UNWIND}, -+ {"NT_STATUS_BAD_STACK", NT_STATUS_BAD_STACK}, -+ {"NT_STATUS_INVALID_UNWIND_TARGET", -+ NT_STATUS_INVALID_UNWIND_TARGET}, -+ {"NT_STATUS_NOT_LOCKED", NT_STATUS_NOT_LOCKED}, -+ {"NT_STATUS_PARITY_ERROR", NT_STATUS_PARITY_ERROR}, -+ {"NT_STATUS_UNABLE_TO_DECOMMIT_VM", -+ NT_STATUS_UNABLE_TO_DECOMMIT_VM}, -+ {"NT_STATUS_NOT_COMMITTED", NT_STATUS_NOT_COMMITTED}, -+ {"NT_STATUS_INVALID_PORT_ATTRIBUTES", -+ NT_STATUS_INVALID_PORT_ATTRIBUTES}, -+ {"NT_STATUS_PORT_MESSAGE_TOO_LONG", -+ NT_STATUS_PORT_MESSAGE_TOO_LONG}, -+ {"NT_STATUS_INVALID_PARAMETER_MIX", -+ NT_STATUS_INVALID_PARAMETER_MIX}, -+ {"NT_STATUS_INVALID_QUOTA_LOWER", NT_STATUS_INVALID_QUOTA_LOWER}, -+ {"NT_STATUS_DISK_CORRUPT_ERROR", NT_STATUS_DISK_CORRUPT_ERROR}, -+ {"NT_STATUS_OBJECT_NAME_INVALID", NT_STATUS_OBJECT_NAME_INVALID}, -+ {"NT_STATUS_OBJECT_NAME_NOT_FOUND", -+ NT_STATUS_OBJECT_NAME_NOT_FOUND}, -+ {"NT_STATUS_OBJECT_NAME_COLLISION", -+ NT_STATUS_OBJECT_NAME_COLLISION}, -+ {"NT_STATUS_HANDLE_NOT_WAITABLE", NT_STATUS_HANDLE_NOT_WAITABLE}, -+ {"NT_STATUS_PORT_DISCONNECTED", NT_STATUS_PORT_DISCONNECTED}, -+ {"NT_STATUS_DEVICE_ALREADY_ATTACHED", -+ NT_STATUS_DEVICE_ALREADY_ATTACHED}, -+ {"NT_STATUS_OBJECT_PATH_INVALID", NT_STATUS_OBJECT_PATH_INVALID}, -+ {"NT_STATUS_OBJECT_PATH_NOT_FOUND", -+ NT_STATUS_OBJECT_PATH_NOT_FOUND}, -+ {"NT_STATUS_OBJECT_PATH_SYNTAX_BAD", -+ NT_STATUS_OBJECT_PATH_SYNTAX_BAD}, -+ {"NT_STATUS_DATA_OVERRUN", NT_STATUS_DATA_OVERRUN}, -+ {"NT_STATUS_DATA_LATE_ERROR", NT_STATUS_DATA_LATE_ERROR}, -+ {"NT_STATUS_DATA_ERROR", NT_STATUS_DATA_ERROR}, -+ {"NT_STATUS_CRC_ERROR", NT_STATUS_CRC_ERROR}, -+ {"NT_STATUS_SECTION_TOO_BIG", NT_STATUS_SECTION_TOO_BIG}, -+ {"NT_STATUS_PORT_CONNECTION_REFUSED", -+ NT_STATUS_PORT_CONNECTION_REFUSED}, -+ {"NT_STATUS_INVALID_PORT_HANDLE", NT_STATUS_INVALID_PORT_HANDLE}, -+ {"NT_STATUS_SHARING_VIOLATION", NT_STATUS_SHARING_VIOLATION}, -+ {"NT_STATUS_QUOTA_EXCEEDED", NT_STATUS_QUOTA_EXCEEDED}, -+ {"NT_STATUS_INVALID_PAGE_PROTECTION", -+ NT_STATUS_INVALID_PAGE_PROTECTION}, -+ {"NT_STATUS_MUTANT_NOT_OWNED", NT_STATUS_MUTANT_NOT_OWNED}, -+ {"NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED", -+ NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED}, -+ {"NT_STATUS_PORT_ALREADY_SET", NT_STATUS_PORT_ALREADY_SET}, -+ {"NT_STATUS_SECTION_NOT_IMAGE", NT_STATUS_SECTION_NOT_IMAGE}, -+ {"NT_STATUS_SUSPEND_COUNT_EXCEEDED", -+ NT_STATUS_SUSPEND_COUNT_EXCEEDED}, -+ {"NT_STATUS_THREAD_IS_TERMINATING", -+ NT_STATUS_THREAD_IS_TERMINATING}, -+ {"NT_STATUS_BAD_WORKING_SET_LIMIT", -+ NT_STATUS_BAD_WORKING_SET_LIMIT}, -+ {"NT_STATUS_INCOMPATIBLE_FILE_MAP", -+ NT_STATUS_INCOMPATIBLE_FILE_MAP}, -+ {"NT_STATUS_SECTION_PROTECTION", NT_STATUS_SECTION_PROTECTION}, -+ {"NT_STATUS_EAS_NOT_SUPPORTED", NT_STATUS_EAS_NOT_SUPPORTED}, -+ {"NT_STATUS_EA_TOO_LARGE", NT_STATUS_EA_TOO_LARGE}, -+ {"NT_STATUS_NONEXISTENT_EA_ENTRY", NT_STATUS_NONEXISTENT_EA_ENTRY}, -+ {"NT_STATUS_NO_EAS_ON_FILE", NT_STATUS_NO_EAS_ON_FILE}, -+ {"NT_STATUS_EA_CORRUPT_ERROR", NT_STATUS_EA_CORRUPT_ERROR}, -+ {"NT_STATUS_FILE_LOCK_CONFLICT", NT_STATUS_FILE_LOCK_CONFLICT}, -+ {"NT_STATUS_LOCK_NOT_GRANTED", NT_STATUS_LOCK_NOT_GRANTED}, -+ {"NT_STATUS_DELETE_PENDING", NT_STATUS_DELETE_PENDING}, -+ {"NT_STATUS_CTL_FILE_NOT_SUPPORTED", -+ NT_STATUS_CTL_FILE_NOT_SUPPORTED}, -+ {"NT_STATUS_UNKNOWN_REVISION", NT_STATUS_UNKNOWN_REVISION}, -+ {"NT_STATUS_REVISION_MISMATCH", NT_STATUS_REVISION_MISMATCH}, -+ {"NT_STATUS_INVALID_OWNER", NT_STATUS_INVALID_OWNER}, -+ {"NT_STATUS_INVALID_PRIMARY_GROUP", -+ NT_STATUS_INVALID_PRIMARY_GROUP}, -+ {"NT_STATUS_NO_IMPERSONATION_TOKEN", -+ NT_STATUS_NO_IMPERSONATION_TOKEN}, -+ {"NT_STATUS_CANT_DISABLE_MANDATORY", -+ NT_STATUS_CANT_DISABLE_MANDATORY}, -+ {"NT_STATUS_NO_LOGON_SERVERS", NT_STATUS_NO_LOGON_SERVERS}, -+ {"NT_STATUS_NO_SUCH_LOGON_SESSION", -+ NT_STATUS_NO_SUCH_LOGON_SESSION}, -+ {"NT_STATUS_NO_SUCH_PRIVILEGE", NT_STATUS_NO_SUCH_PRIVILEGE}, -+ {"NT_STATUS_PRIVILEGE_NOT_HELD", NT_STATUS_PRIVILEGE_NOT_HELD}, -+ {"NT_STATUS_INVALID_ACCOUNT_NAME", NT_STATUS_INVALID_ACCOUNT_NAME}, -+ {"NT_STATUS_USER_EXISTS", NT_STATUS_USER_EXISTS}, -+ {"NT_STATUS_NO_SUCH_USER", NT_STATUS_NO_SUCH_USER}, -+ {"NT_STATUS_GROUP_EXISTS", NT_STATUS_GROUP_EXISTS}, -+ {"NT_STATUS_NO_SUCH_GROUP", NT_STATUS_NO_SUCH_GROUP}, -+ {"NT_STATUS_MEMBER_IN_GROUP", NT_STATUS_MEMBER_IN_GROUP}, -+ {"NT_STATUS_MEMBER_NOT_IN_GROUP", NT_STATUS_MEMBER_NOT_IN_GROUP}, -+ {"NT_STATUS_LAST_ADMIN", NT_STATUS_LAST_ADMIN}, -+ {"NT_STATUS_WRONG_PASSWORD", NT_STATUS_WRONG_PASSWORD}, -+ {"NT_STATUS_ILL_FORMED_PASSWORD", NT_STATUS_ILL_FORMED_PASSWORD}, -+ {"NT_STATUS_PASSWORD_RESTRICTION", NT_STATUS_PASSWORD_RESTRICTION}, -+ {"NT_STATUS_LOGON_FAILURE", NT_STATUS_LOGON_FAILURE}, -+ {"NT_STATUS_ACCOUNT_RESTRICTION", NT_STATUS_ACCOUNT_RESTRICTION}, -+ {"NT_STATUS_INVALID_LOGON_HOURS", NT_STATUS_INVALID_LOGON_HOURS}, -+ {"NT_STATUS_INVALID_WORKSTATION", NT_STATUS_INVALID_WORKSTATION}, -+ {"NT_STATUS_PASSWORD_EXPIRED", NT_STATUS_PASSWORD_EXPIRED}, -+ {"NT_STATUS_ACCOUNT_DISABLED", NT_STATUS_ACCOUNT_DISABLED}, -+ {"NT_STATUS_NONE_MAPPED", NT_STATUS_NONE_MAPPED}, -+ {"NT_STATUS_TOO_MANY_LUIDS_REQUESTED", -+ NT_STATUS_TOO_MANY_LUIDS_REQUESTED}, -+ {"NT_STATUS_LUIDS_EXHAUSTED", NT_STATUS_LUIDS_EXHAUSTED}, -+ {"NT_STATUS_INVALID_SUB_AUTHORITY", -+ NT_STATUS_INVALID_SUB_AUTHORITY}, -+ {"NT_STATUS_INVALID_ACL", NT_STATUS_INVALID_ACL}, -+ {"NT_STATUS_INVALID_SID", NT_STATUS_INVALID_SID}, -+ {"NT_STATUS_INVALID_SECURITY_DESCR", -+ NT_STATUS_INVALID_SECURITY_DESCR}, -+ {"NT_STATUS_PROCEDURE_NOT_FOUND", NT_STATUS_PROCEDURE_NOT_FOUND}, -+ {"NT_STATUS_INVALID_IMAGE_FORMAT", NT_STATUS_INVALID_IMAGE_FORMAT}, -+ {"NT_STATUS_NO_TOKEN", NT_STATUS_NO_TOKEN}, -+ {"NT_STATUS_BAD_INHERITANCE_ACL", NT_STATUS_BAD_INHERITANCE_ACL}, -+ {"NT_STATUS_RANGE_NOT_LOCKED", NT_STATUS_RANGE_NOT_LOCKED}, -+ {"NT_STATUS_DISK_FULL", NT_STATUS_DISK_FULL}, -+ {"NT_STATUS_SERVER_DISABLED", NT_STATUS_SERVER_DISABLED}, -+ {"NT_STATUS_SERVER_NOT_DISABLED", NT_STATUS_SERVER_NOT_DISABLED}, -+ {"NT_STATUS_TOO_MANY_GUIDS_REQUESTED", -+ NT_STATUS_TOO_MANY_GUIDS_REQUESTED}, -+ {"NT_STATUS_GUIDS_EXHAUSTED", NT_STATUS_GUIDS_EXHAUSTED}, -+ {"NT_STATUS_INVALID_ID_AUTHORITY", NT_STATUS_INVALID_ID_AUTHORITY}, -+ {"NT_STATUS_AGENTS_EXHAUSTED", NT_STATUS_AGENTS_EXHAUSTED}, -+ {"NT_STATUS_INVALID_VOLUME_LABEL", NT_STATUS_INVALID_VOLUME_LABEL}, -+ {"NT_STATUS_SECTION_NOT_EXTENDED", NT_STATUS_SECTION_NOT_EXTENDED}, -+ {"NT_STATUS_NOT_MAPPED_DATA", NT_STATUS_NOT_MAPPED_DATA}, -+ {"NT_STATUS_RESOURCE_DATA_NOT_FOUND", -+ NT_STATUS_RESOURCE_DATA_NOT_FOUND}, -+ {"NT_STATUS_RESOURCE_TYPE_NOT_FOUND", -+ NT_STATUS_RESOURCE_TYPE_NOT_FOUND}, -+ {"NT_STATUS_RESOURCE_NAME_NOT_FOUND", -+ NT_STATUS_RESOURCE_NAME_NOT_FOUND}, -+ {"NT_STATUS_ARRAY_BOUNDS_EXCEEDED", -+ NT_STATUS_ARRAY_BOUNDS_EXCEEDED}, -+ {"NT_STATUS_FLOAT_DENORMAL_OPERAND", -+ NT_STATUS_FLOAT_DENORMAL_OPERAND}, -+ {"NT_STATUS_FLOAT_DIVIDE_BY_ZERO", NT_STATUS_FLOAT_DIVIDE_BY_ZERO}, -+ {"NT_STATUS_FLOAT_INEXACT_RESULT", NT_STATUS_FLOAT_INEXACT_RESULT}, -+ {"NT_STATUS_FLOAT_INVALID_OPERATION", -+ NT_STATUS_FLOAT_INVALID_OPERATION}, -+ {"NT_STATUS_FLOAT_OVERFLOW", NT_STATUS_FLOAT_OVERFLOW}, -+ {"NT_STATUS_FLOAT_STACK_CHECK", NT_STATUS_FLOAT_STACK_CHECK}, -+ {"NT_STATUS_FLOAT_UNDERFLOW", NT_STATUS_FLOAT_UNDERFLOW}, -+ {"NT_STATUS_INTEGER_DIVIDE_BY_ZERO", -+ NT_STATUS_INTEGER_DIVIDE_BY_ZERO}, -+ {"NT_STATUS_INTEGER_OVERFLOW", NT_STATUS_INTEGER_OVERFLOW}, -+ {"NT_STATUS_PRIVILEGED_INSTRUCTION", -+ NT_STATUS_PRIVILEGED_INSTRUCTION}, -+ {"NT_STATUS_TOO_MANY_PAGING_FILES", -+ NT_STATUS_TOO_MANY_PAGING_FILES}, -+ {"NT_STATUS_FILE_INVALID", NT_STATUS_FILE_INVALID}, -+ {"NT_STATUS_ALLOTTED_SPACE_EXCEEDED", -+ NT_STATUS_ALLOTTED_SPACE_EXCEEDED}, -+ {"NT_STATUS_INSUFFICIENT_RESOURCES", -+ NT_STATUS_INSUFFICIENT_RESOURCES}, -+ {"NT_STATUS_DFS_EXIT_PATH_FOUND", NT_STATUS_DFS_EXIT_PATH_FOUND}, -+ {"NT_STATUS_DEVICE_DATA_ERROR", NT_STATUS_DEVICE_DATA_ERROR}, -+ {"NT_STATUS_DEVICE_NOT_CONNECTED", NT_STATUS_DEVICE_NOT_CONNECTED}, -+ {"NT_STATUS_DEVICE_POWER_FAILURE", NT_STATUS_DEVICE_POWER_FAILURE}, -+ {"NT_STATUS_FREE_VM_NOT_AT_BASE", NT_STATUS_FREE_VM_NOT_AT_BASE}, -+ {"NT_STATUS_MEMORY_NOT_ALLOCATED", NT_STATUS_MEMORY_NOT_ALLOCATED}, -+ {"NT_STATUS_WORKING_SET_QUOTA", NT_STATUS_WORKING_SET_QUOTA}, -+ {"NT_STATUS_MEDIA_WRITE_PROTECTED", -+ NT_STATUS_MEDIA_WRITE_PROTECTED}, -+ {"NT_STATUS_DEVICE_NOT_READY", NT_STATUS_DEVICE_NOT_READY}, -+ {"NT_STATUS_INVALID_GROUP_ATTRIBUTES", -+ NT_STATUS_INVALID_GROUP_ATTRIBUTES}, -+ {"NT_STATUS_BAD_IMPERSONATION_LEVEL", -+ NT_STATUS_BAD_IMPERSONATION_LEVEL}, -+ {"NT_STATUS_CANT_OPEN_ANONYMOUS", NT_STATUS_CANT_OPEN_ANONYMOUS}, -+ {"NT_STATUS_BAD_VALIDATION_CLASS", NT_STATUS_BAD_VALIDATION_CLASS}, -+ {"NT_STATUS_BAD_TOKEN_TYPE", NT_STATUS_BAD_TOKEN_TYPE}, -+ {"NT_STATUS_BAD_MASTER_BOOT_RECORD", -+ NT_STATUS_BAD_MASTER_BOOT_RECORD}, -+ {"NT_STATUS_INSTRUCTION_MISALIGNMENT", -+ NT_STATUS_INSTRUCTION_MISALIGNMENT}, -+ {"NT_STATUS_INSTANCE_NOT_AVAILABLE", -+ NT_STATUS_INSTANCE_NOT_AVAILABLE}, -+ {"NT_STATUS_PIPE_NOT_AVAILABLE", NT_STATUS_PIPE_NOT_AVAILABLE}, -+ {"NT_STATUS_INVALID_PIPE_STATE", NT_STATUS_INVALID_PIPE_STATE}, -+ {"NT_STATUS_PIPE_BUSY", NT_STATUS_PIPE_BUSY}, -+ {"NT_STATUS_ILLEGAL_FUNCTION", NT_STATUS_ILLEGAL_FUNCTION}, -+ {"NT_STATUS_PIPE_DISCONNECTED", NT_STATUS_PIPE_DISCONNECTED}, -+ {"NT_STATUS_PIPE_CLOSING", NT_STATUS_PIPE_CLOSING}, -+ {"NT_STATUS_PIPE_CONNECTED", NT_STATUS_PIPE_CONNECTED}, -+ {"NT_STATUS_PIPE_LISTENING", NT_STATUS_PIPE_LISTENING}, -+ {"NT_STATUS_INVALID_READ_MODE", NT_STATUS_INVALID_READ_MODE}, -+ {"NT_STATUS_IO_TIMEOUT", NT_STATUS_IO_TIMEOUT}, -+ {"NT_STATUS_FILE_FORCED_CLOSED", NT_STATUS_FILE_FORCED_CLOSED}, -+ {"NT_STATUS_PROFILING_NOT_STARTED", -+ NT_STATUS_PROFILING_NOT_STARTED}, -+ {"NT_STATUS_PROFILING_NOT_STOPPED", -+ NT_STATUS_PROFILING_NOT_STOPPED}, -+ {"NT_STATUS_COULD_NOT_INTERPRET", NT_STATUS_COULD_NOT_INTERPRET}, -+ {"NT_STATUS_FILE_IS_A_DIRECTORY", NT_STATUS_FILE_IS_A_DIRECTORY}, -+ {"NT_STATUS_NOT_SUPPORTED", NT_STATUS_NOT_SUPPORTED}, -+ {"NT_STATUS_REMOTE_NOT_LISTENING", NT_STATUS_REMOTE_NOT_LISTENING}, -+ {"NT_STATUS_DUPLICATE_NAME", NT_STATUS_DUPLICATE_NAME}, -+ {"NT_STATUS_BAD_NETWORK_PATH", NT_STATUS_BAD_NETWORK_PATH}, -+ {"NT_STATUS_NETWORK_BUSY", NT_STATUS_NETWORK_BUSY}, -+ {"NT_STATUS_DEVICE_DOES_NOT_EXIST", -+ NT_STATUS_DEVICE_DOES_NOT_EXIST}, -+ {"NT_STATUS_TOO_MANY_COMMANDS", NT_STATUS_TOO_MANY_COMMANDS}, -+ {"NT_STATUS_ADAPTER_HARDWARE_ERROR", -+ NT_STATUS_ADAPTER_HARDWARE_ERROR}, -+ {"NT_STATUS_INVALID_NETWORK_RESPONSE", -+ NT_STATUS_INVALID_NETWORK_RESPONSE}, -+ {"NT_STATUS_UNEXPECTED_NETWORK_ERROR", -+ NT_STATUS_UNEXPECTED_NETWORK_ERROR}, -+ {"NT_STATUS_BAD_REMOTE_ADAPTER", NT_STATUS_BAD_REMOTE_ADAPTER}, -+ {"NT_STATUS_PRINT_QUEUE_FULL", NT_STATUS_PRINT_QUEUE_FULL}, -+ {"NT_STATUS_NO_SPOOL_SPACE", NT_STATUS_NO_SPOOL_SPACE}, -+ {"NT_STATUS_PRINT_CANCELLED", NT_STATUS_PRINT_CANCELLED}, -+ {"NT_STATUS_NETWORK_NAME_DELETED", NT_STATUS_NETWORK_NAME_DELETED}, -+ {"NT_STATUS_NETWORK_ACCESS_DENIED", -+ NT_STATUS_NETWORK_ACCESS_DENIED}, -+ {"NT_STATUS_BAD_DEVICE_TYPE", NT_STATUS_BAD_DEVICE_TYPE}, -+ {"NT_STATUS_BAD_NETWORK_NAME", NT_STATUS_BAD_NETWORK_NAME}, -+ {"NT_STATUS_TOO_MANY_NAMES", NT_STATUS_TOO_MANY_NAMES}, -+ {"NT_STATUS_TOO_MANY_SESSIONS", NT_STATUS_TOO_MANY_SESSIONS}, -+ {"NT_STATUS_SHARING_PAUSED", NT_STATUS_SHARING_PAUSED}, -+ {"NT_STATUS_REQUEST_NOT_ACCEPTED", NT_STATUS_REQUEST_NOT_ACCEPTED}, -+ {"NT_STATUS_REDIRECTOR_PAUSED", NT_STATUS_REDIRECTOR_PAUSED}, -+ {"NT_STATUS_NET_WRITE_FAULT", NT_STATUS_NET_WRITE_FAULT}, -+ {"NT_STATUS_PROFILING_AT_LIMIT", NT_STATUS_PROFILING_AT_LIMIT}, -+ {"NT_STATUS_NOT_SAME_DEVICE", NT_STATUS_NOT_SAME_DEVICE}, -+ {"NT_STATUS_FILE_RENAMED", NT_STATUS_FILE_RENAMED}, -+ {"NT_STATUS_VIRTUAL_CIRCUIT_CLOSED", -+ NT_STATUS_VIRTUAL_CIRCUIT_CLOSED}, -+ {"NT_STATUS_NO_SECURITY_ON_OBJECT", -+ NT_STATUS_NO_SECURITY_ON_OBJECT}, -+ {"NT_STATUS_CANT_WAIT", NT_STATUS_CANT_WAIT}, -+ {"NT_STATUS_PIPE_EMPTY", NT_STATUS_PIPE_EMPTY}, -+ {"NT_STATUS_CANT_ACCESS_DOMAIN_INFO", -+ NT_STATUS_CANT_ACCESS_DOMAIN_INFO}, -+ {"NT_STATUS_CANT_TERMINATE_SELF", NT_STATUS_CANT_TERMINATE_SELF}, -+ {"NT_STATUS_INVALID_SERVER_STATE", NT_STATUS_INVALID_SERVER_STATE}, -+ {"NT_STATUS_INVALID_DOMAIN_STATE", NT_STATUS_INVALID_DOMAIN_STATE}, -+ {"NT_STATUS_INVALID_DOMAIN_ROLE", NT_STATUS_INVALID_DOMAIN_ROLE}, -+ {"NT_STATUS_NO_SUCH_DOMAIN", NT_STATUS_NO_SUCH_DOMAIN}, -+ {"NT_STATUS_DOMAIN_EXISTS", NT_STATUS_DOMAIN_EXISTS}, -+ {"NT_STATUS_DOMAIN_LIMIT_EXCEEDED", -+ NT_STATUS_DOMAIN_LIMIT_EXCEEDED}, -+ {"NT_STATUS_OPLOCK_NOT_GRANTED", NT_STATUS_OPLOCK_NOT_GRANTED}, -+ {"NT_STATUS_INVALID_OPLOCK_PROTOCOL", -+ NT_STATUS_INVALID_OPLOCK_PROTOCOL}, -+ {"NT_STATUS_INTERNAL_DB_CORRUPTION", -+ NT_STATUS_INTERNAL_DB_CORRUPTION}, -+ {"NT_STATUS_INTERNAL_ERROR", NT_STATUS_INTERNAL_ERROR}, -+ {"NT_STATUS_GENERIC_NOT_MAPPED", NT_STATUS_GENERIC_NOT_MAPPED}, -+ {"NT_STATUS_BAD_DESCRIPTOR_FORMAT", -+ NT_STATUS_BAD_DESCRIPTOR_FORMAT}, -+ {"NT_STATUS_INVALID_USER_BUFFER", NT_STATUS_INVALID_USER_BUFFER}, -+ {"NT_STATUS_UNEXPECTED_IO_ERROR", NT_STATUS_UNEXPECTED_IO_ERROR}, -+ {"NT_STATUS_UNEXPECTED_MM_CREATE_ERR", -+ NT_STATUS_UNEXPECTED_MM_CREATE_ERR}, -+ {"NT_STATUS_UNEXPECTED_MM_MAP_ERROR", -+ NT_STATUS_UNEXPECTED_MM_MAP_ERROR}, -+ {"NT_STATUS_UNEXPECTED_MM_EXTEND_ERR", -+ NT_STATUS_UNEXPECTED_MM_EXTEND_ERR}, -+ {"NT_STATUS_NOT_LOGON_PROCESS", NT_STATUS_NOT_LOGON_PROCESS}, -+ {"NT_STATUS_LOGON_SESSION_EXISTS", NT_STATUS_LOGON_SESSION_EXISTS}, -+ {"NT_STATUS_INVALID_PARAMETER_1", NT_STATUS_INVALID_PARAMETER_1}, -+ {"NT_STATUS_INVALID_PARAMETER_2", NT_STATUS_INVALID_PARAMETER_2}, -+ {"NT_STATUS_INVALID_PARAMETER_3", NT_STATUS_INVALID_PARAMETER_3}, -+ {"NT_STATUS_INVALID_PARAMETER_4", NT_STATUS_INVALID_PARAMETER_4}, -+ {"NT_STATUS_INVALID_PARAMETER_5", NT_STATUS_INVALID_PARAMETER_5}, -+ {"NT_STATUS_INVALID_PARAMETER_6", NT_STATUS_INVALID_PARAMETER_6}, -+ {"NT_STATUS_INVALID_PARAMETER_7", NT_STATUS_INVALID_PARAMETER_7}, -+ {"NT_STATUS_INVALID_PARAMETER_8", NT_STATUS_INVALID_PARAMETER_8}, -+ {"NT_STATUS_INVALID_PARAMETER_9", NT_STATUS_INVALID_PARAMETER_9}, -+ {"NT_STATUS_INVALID_PARAMETER_10", NT_STATUS_INVALID_PARAMETER_10}, -+ {"NT_STATUS_INVALID_PARAMETER_11", NT_STATUS_INVALID_PARAMETER_11}, -+ {"NT_STATUS_INVALID_PARAMETER_12", NT_STATUS_INVALID_PARAMETER_12}, -+ {"NT_STATUS_REDIRECTOR_NOT_STARTED", -+ NT_STATUS_REDIRECTOR_NOT_STARTED}, -+ {"NT_STATUS_REDIRECTOR_STARTED", NT_STATUS_REDIRECTOR_STARTED}, -+ {"NT_STATUS_STACK_OVERFLOW", NT_STATUS_STACK_OVERFLOW}, -+ {"NT_STATUS_NO_SUCH_PACKAGE", NT_STATUS_NO_SUCH_PACKAGE}, -+ {"NT_STATUS_BAD_FUNCTION_TABLE", NT_STATUS_BAD_FUNCTION_TABLE}, -+ {"NT_STATUS_DIRECTORY_NOT_EMPTY", NT_STATUS_DIRECTORY_NOT_EMPTY}, -+ {"NT_STATUS_FILE_CORRUPT_ERROR", NT_STATUS_FILE_CORRUPT_ERROR}, -+ {"NT_STATUS_NOT_A_DIRECTORY", NT_STATUS_NOT_A_DIRECTORY}, -+ {"NT_STATUS_BAD_LOGON_SESSION_STATE", -+ NT_STATUS_BAD_LOGON_SESSION_STATE}, -+ {"NT_STATUS_LOGON_SESSION_COLLISION", -+ NT_STATUS_LOGON_SESSION_COLLISION}, -+ {"NT_STATUS_NAME_TOO_LONG", NT_STATUS_NAME_TOO_LONG}, -+ {"NT_STATUS_FILES_OPEN", NT_STATUS_FILES_OPEN}, -+ {"NT_STATUS_CONNECTION_IN_USE", NT_STATUS_CONNECTION_IN_USE}, -+ {"NT_STATUS_MESSAGE_NOT_FOUND", NT_STATUS_MESSAGE_NOT_FOUND}, -+ {"NT_STATUS_PROCESS_IS_TERMINATING", -+ NT_STATUS_PROCESS_IS_TERMINATING}, -+ {"NT_STATUS_INVALID_LOGON_TYPE", NT_STATUS_INVALID_LOGON_TYPE}, -+ {"NT_STATUS_NO_GUID_TRANSLATION", NT_STATUS_NO_GUID_TRANSLATION}, -+ {"NT_STATUS_CANNOT_IMPERSONATE", NT_STATUS_CANNOT_IMPERSONATE}, -+ {"NT_STATUS_IMAGE_ALREADY_LOADED", NT_STATUS_IMAGE_ALREADY_LOADED}, -+ {"NT_STATUS_ABIOS_NOT_PRESENT", NT_STATUS_ABIOS_NOT_PRESENT}, -+ {"NT_STATUS_ABIOS_LID_NOT_EXIST", NT_STATUS_ABIOS_LID_NOT_EXIST}, -+ {"NT_STATUS_ABIOS_LID_ALREADY_OWNED", -+ NT_STATUS_ABIOS_LID_ALREADY_OWNED}, -+ {"NT_STATUS_ABIOS_NOT_LID_OWNER", NT_STATUS_ABIOS_NOT_LID_OWNER}, -+ {"NT_STATUS_ABIOS_INVALID_COMMAND", -+ NT_STATUS_ABIOS_INVALID_COMMAND}, -+ {"NT_STATUS_ABIOS_INVALID_LID", NT_STATUS_ABIOS_INVALID_LID}, -+ {"NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE", -+ NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE}, -+ {"NT_STATUS_ABIOS_INVALID_SELECTOR", -+ NT_STATUS_ABIOS_INVALID_SELECTOR}, -+ {"NT_STATUS_NO_LDT", NT_STATUS_NO_LDT}, -+ {"NT_STATUS_INVALID_LDT_SIZE", NT_STATUS_INVALID_LDT_SIZE}, -+ {"NT_STATUS_INVALID_LDT_OFFSET", NT_STATUS_INVALID_LDT_OFFSET}, -+ {"NT_STATUS_INVALID_LDT_DESCRIPTOR", -+ NT_STATUS_INVALID_LDT_DESCRIPTOR}, -+ {"NT_STATUS_INVALID_IMAGE_NE_FORMAT", -+ NT_STATUS_INVALID_IMAGE_NE_FORMAT}, -+ {"NT_STATUS_RXACT_INVALID_STATE", NT_STATUS_RXACT_INVALID_STATE}, -+ {"NT_STATUS_RXACT_COMMIT_FAILURE", NT_STATUS_RXACT_COMMIT_FAILURE}, -+ {"NT_STATUS_MAPPED_FILE_SIZE_ZERO", -+ NT_STATUS_MAPPED_FILE_SIZE_ZERO}, -+ {"NT_STATUS_TOO_MANY_OPENED_FILES", -+ NT_STATUS_TOO_MANY_OPENED_FILES}, -+ {"NT_STATUS_CANCELLED", NT_STATUS_CANCELLED}, -+ {"NT_STATUS_CANNOT_DELETE", NT_STATUS_CANNOT_DELETE}, -+ {"NT_STATUS_INVALID_COMPUTER_NAME", -+ NT_STATUS_INVALID_COMPUTER_NAME}, -+ {"NT_STATUS_FILE_DELETED", NT_STATUS_FILE_DELETED}, -+ {"NT_STATUS_SPECIAL_ACCOUNT", NT_STATUS_SPECIAL_ACCOUNT}, -+ {"NT_STATUS_SPECIAL_GROUP", NT_STATUS_SPECIAL_GROUP}, -+ {"NT_STATUS_SPECIAL_USER", NT_STATUS_SPECIAL_USER}, -+ {"NT_STATUS_MEMBERS_PRIMARY_GROUP", -+ NT_STATUS_MEMBERS_PRIMARY_GROUP}, -+ {"NT_STATUS_FILE_CLOSED", NT_STATUS_FILE_CLOSED}, -+ {"NT_STATUS_TOO_MANY_THREADS", NT_STATUS_TOO_MANY_THREADS}, -+ {"NT_STATUS_THREAD_NOT_IN_PROCESS", -+ NT_STATUS_THREAD_NOT_IN_PROCESS}, -+ {"NT_STATUS_TOKEN_ALREADY_IN_USE", NT_STATUS_TOKEN_ALREADY_IN_USE}, -+ {"NT_STATUS_PAGEFILE_QUOTA_EXCEEDED", -+ NT_STATUS_PAGEFILE_QUOTA_EXCEEDED}, -+ {"NT_STATUS_COMMITMENT_LIMIT", NT_STATUS_COMMITMENT_LIMIT}, -+ {"NT_STATUS_INVALID_IMAGE_LE_FORMAT", -+ NT_STATUS_INVALID_IMAGE_LE_FORMAT}, -+ {"NT_STATUS_INVALID_IMAGE_NOT_MZ", NT_STATUS_INVALID_IMAGE_NOT_MZ}, -+ {"NT_STATUS_INVALID_IMAGE_PROTECT", -+ NT_STATUS_INVALID_IMAGE_PROTECT}, -+ {"NT_STATUS_INVALID_IMAGE_WIN_16", NT_STATUS_INVALID_IMAGE_WIN_16}, -+ {"NT_STATUS_LOGON_SERVER_CONFLICT", -+ NT_STATUS_LOGON_SERVER_CONFLICT}, -+ {"NT_STATUS_TIME_DIFFERENCE_AT_DC", -+ NT_STATUS_TIME_DIFFERENCE_AT_DC}, -+ {"NT_STATUS_SYNCHRONIZATION_REQUIRED", -+ NT_STATUS_SYNCHRONIZATION_REQUIRED}, -+ {"NT_STATUS_DLL_NOT_FOUND", NT_STATUS_DLL_NOT_FOUND}, -+ {"NT_STATUS_OPEN_FAILED", NT_STATUS_OPEN_FAILED}, -+ {"NT_STATUS_IO_PRIVILEGE_FAILED", NT_STATUS_IO_PRIVILEGE_FAILED}, -+ {"NT_STATUS_ORDINAL_NOT_FOUND", NT_STATUS_ORDINAL_NOT_FOUND}, -+ {"NT_STATUS_ENTRYPOINT_NOT_FOUND", NT_STATUS_ENTRYPOINT_NOT_FOUND}, -+ {"NT_STATUS_CONTROL_C_EXIT", NT_STATUS_CONTROL_C_EXIT}, -+ {"NT_STATUS_LOCAL_DISCONNECT", NT_STATUS_LOCAL_DISCONNECT}, -+ {"NT_STATUS_REMOTE_DISCONNECT", NT_STATUS_REMOTE_DISCONNECT}, -+ {"NT_STATUS_REMOTE_RESOURCES", NT_STATUS_REMOTE_RESOURCES}, -+ {"NT_STATUS_LINK_FAILED", NT_STATUS_LINK_FAILED}, -+ {"NT_STATUS_LINK_TIMEOUT", NT_STATUS_LINK_TIMEOUT}, -+ {"NT_STATUS_INVALID_CONNECTION", NT_STATUS_INVALID_CONNECTION}, -+ {"NT_STATUS_INVALID_ADDRESS", NT_STATUS_INVALID_ADDRESS}, -+ {"NT_STATUS_DLL_INIT_FAILED", NT_STATUS_DLL_INIT_FAILED}, -+ {"NT_STATUS_MISSING_SYSTEMFILE", NT_STATUS_MISSING_SYSTEMFILE}, -+ {"NT_STATUS_UNHANDLED_EXCEPTION", NT_STATUS_UNHANDLED_EXCEPTION}, -+ {"NT_STATUS_APP_INIT_FAILURE", NT_STATUS_APP_INIT_FAILURE}, -+ {"NT_STATUS_PAGEFILE_CREATE_FAILED", -+ NT_STATUS_PAGEFILE_CREATE_FAILED}, -+ {"NT_STATUS_NO_PAGEFILE", NT_STATUS_NO_PAGEFILE}, -+ {"NT_STATUS_INVALID_LEVEL", NT_STATUS_INVALID_LEVEL}, -+ {"NT_STATUS_WRONG_PASSWORD_CORE", NT_STATUS_WRONG_PASSWORD_CORE}, -+ {"NT_STATUS_ILLEGAL_FLOAT_CONTEXT", -+ NT_STATUS_ILLEGAL_FLOAT_CONTEXT}, -+ {"NT_STATUS_PIPE_BROKEN", NT_STATUS_PIPE_BROKEN}, -+ {"NT_STATUS_REGISTRY_CORRUPT", NT_STATUS_REGISTRY_CORRUPT}, -+ {"NT_STATUS_REGISTRY_IO_FAILED", NT_STATUS_REGISTRY_IO_FAILED}, -+ {"NT_STATUS_NO_EVENT_PAIR", NT_STATUS_NO_EVENT_PAIR}, -+ {"NT_STATUS_UNRECOGNIZED_VOLUME", NT_STATUS_UNRECOGNIZED_VOLUME}, -+ {"NT_STATUS_SERIAL_NO_DEVICE_INITED", -+ NT_STATUS_SERIAL_NO_DEVICE_INITED}, -+ {"NT_STATUS_NO_SUCH_ALIAS", NT_STATUS_NO_SUCH_ALIAS}, -+ {"NT_STATUS_MEMBER_NOT_IN_ALIAS", NT_STATUS_MEMBER_NOT_IN_ALIAS}, -+ {"NT_STATUS_MEMBER_IN_ALIAS", NT_STATUS_MEMBER_IN_ALIAS}, -+ {"NT_STATUS_ALIAS_EXISTS", NT_STATUS_ALIAS_EXISTS}, -+ {"NT_STATUS_LOGON_NOT_GRANTED", NT_STATUS_LOGON_NOT_GRANTED}, -+ {"NT_STATUS_TOO_MANY_SECRETS", NT_STATUS_TOO_MANY_SECRETS}, -+ {"NT_STATUS_SECRET_TOO_LONG", NT_STATUS_SECRET_TOO_LONG}, -+ {"NT_STATUS_INTERNAL_DB_ERROR", NT_STATUS_INTERNAL_DB_ERROR}, -+ {"NT_STATUS_FULLSCREEN_MODE", NT_STATUS_FULLSCREEN_MODE}, -+ {"NT_STATUS_TOO_MANY_CONTEXT_IDS", NT_STATUS_TOO_MANY_CONTEXT_IDS}, -+ {"NT_STATUS_LOGON_TYPE_NOT_GRANTED", -+ NT_STATUS_LOGON_TYPE_NOT_GRANTED}, -+ {"NT_STATUS_NOT_REGISTRY_FILE", NT_STATUS_NOT_REGISTRY_FILE}, -+ {"NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED", -+ NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED}, -+ {"NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR", -+ NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR}, -+ {"NT_STATUS_FT_MISSING_MEMBER", NT_STATUS_FT_MISSING_MEMBER}, -+ {"NT_STATUS_ILL_FORMED_SERVICE_ENTRY", -+ NT_STATUS_ILL_FORMED_SERVICE_ENTRY}, -+ {"NT_STATUS_ILLEGAL_CHARACTER", NT_STATUS_ILLEGAL_CHARACTER}, -+ {"NT_STATUS_UNMAPPABLE_CHARACTER", NT_STATUS_UNMAPPABLE_CHARACTER}, -+ {"NT_STATUS_UNDEFINED_CHARACTER", NT_STATUS_UNDEFINED_CHARACTER}, -+ {"NT_STATUS_FLOPPY_VOLUME", NT_STATUS_FLOPPY_VOLUME}, -+ {"NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND", -+ NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND}, -+ {"NT_STATUS_FLOPPY_WRONG_CYLINDER", -+ NT_STATUS_FLOPPY_WRONG_CYLINDER}, -+ {"NT_STATUS_FLOPPY_UNKNOWN_ERROR", NT_STATUS_FLOPPY_UNKNOWN_ERROR}, -+ {"NT_STATUS_FLOPPY_BAD_REGISTERS", NT_STATUS_FLOPPY_BAD_REGISTERS}, -+ {"NT_STATUS_DISK_RECALIBRATE_FAILED", -+ NT_STATUS_DISK_RECALIBRATE_FAILED}, -+ {"NT_STATUS_DISK_OPERATION_FAILED", -+ NT_STATUS_DISK_OPERATION_FAILED}, -+ {"NT_STATUS_DISK_RESET_FAILED", NT_STATUS_DISK_RESET_FAILED}, -+ {"NT_STATUS_SHARED_IRQ_BUSY", NT_STATUS_SHARED_IRQ_BUSY}, -+ {"NT_STATUS_FT_ORPHANING", NT_STATUS_FT_ORPHANING}, -+ {"NT_STATUS_PARTITION_FAILURE", NT_STATUS_PARTITION_FAILURE}, -+ {"NT_STATUS_INVALID_BLOCK_LENGTH", NT_STATUS_INVALID_BLOCK_LENGTH}, -+ {"NT_STATUS_DEVICE_NOT_PARTITIONED", -+ NT_STATUS_DEVICE_NOT_PARTITIONED}, -+ {"NT_STATUS_UNABLE_TO_LOCK_MEDIA", NT_STATUS_UNABLE_TO_LOCK_MEDIA}, -+ {"NT_STATUS_UNABLE_TO_UNLOAD_MEDIA", -+ NT_STATUS_UNABLE_TO_UNLOAD_MEDIA}, -+ {"NT_STATUS_EOM_OVERFLOW", NT_STATUS_EOM_OVERFLOW}, -+ {"NT_STATUS_NO_MEDIA", NT_STATUS_NO_MEDIA}, -+ {"NT_STATUS_NO_SUCH_MEMBER", NT_STATUS_NO_SUCH_MEMBER}, -+ {"NT_STATUS_INVALID_MEMBER", NT_STATUS_INVALID_MEMBER}, -+ {"NT_STATUS_KEY_DELETED", NT_STATUS_KEY_DELETED}, -+ {"NT_STATUS_NO_LOG_SPACE", NT_STATUS_NO_LOG_SPACE}, -+ {"NT_STATUS_TOO_MANY_SIDS", NT_STATUS_TOO_MANY_SIDS}, -+ {"NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED", -+ NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED}, -+ {"NT_STATUS_KEY_HAS_CHILDREN", NT_STATUS_KEY_HAS_CHILDREN}, -+ {"NT_STATUS_CHILD_MUST_BE_VOLATILE", -+ NT_STATUS_CHILD_MUST_BE_VOLATILE}, -+ {"NT_STATUS_DEVICE_CONFIGURATION_ERROR", -+ NT_STATUS_DEVICE_CONFIGURATION_ERROR}, -+ {"NT_STATUS_DRIVER_INTERNAL_ERROR", -+ NT_STATUS_DRIVER_INTERNAL_ERROR}, -+ {"NT_STATUS_INVALID_DEVICE_STATE", NT_STATUS_INVALID_DEVICE_STATE}, -+ {"NT_STATUS_IO_DEVICE_ERROR", NT_STATUS_IO_DEVICE_ERROR}, -+ {"NT_STATUS_DEVICE_PROTOCOL_ERROR", -+ NT_STATUS_DEVICE_PROTOCOL_ERROR}, -+ {"NT_STATUS_BACKUP_CONTROLLER", NT_STATUS_BACKUP_CONTROLLER}, -+ {"NT_STATUS_LOG_FILE_FULL", NT_STATUS_LOG_FILE_FULL}, -+ {"NT_STATUS_TOO_LATE", NT_STATUS_TOO_LATE}, -+ {"NT_STATUS_NO_TRUST_LSA_SECRET", NT_STATUS_NO_TRUST_LSA_SECRET}, -+ {"NT_STATUS_NO_TRUST_SAM_ACCOUNT", NT_STATUS_NO_TRUST_SAM_ACCOUNT}, -+ {"NT_STATUS_TRUSTED_DOMAIN_FAILURE", -+ NT_STATUS_TRUSTED_DOMAIN_FAILURE}, -+ {"NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE", -+ NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE}, -+ {"NT_STATUS_EVENTLOG_FILE_CORRUPT", -+ NT_STATUS_EVENTLOG_FILE_CORRUPT}, -+ {"NT_STATUS_EVENTLOG_CANT_START", NT_STATUS_EVENTLOG_CANT_START}, -+ {"NT_STATUS_TRUST_FAILURE", NT_STATUS_TRUST_FAILURE}, -+ {"NT_STATUS_MUTANT_LIMIT_EXCEEDED", -+ NT_STATUS_MUTANT_LIMIT_EXCEEDED}, -+ {"NT_STATUS_NETLOGON_NOT_STARTED", NT_STATUS_NETLOGON_NOT_STARTED}, -+ {"NT_STATUS_ACCOUNT_EXPIRED", NT_STATUS_ACCOUNT_EXPIRED}, -+ {"NT_STATUS_POSSIBLE_DEADLOCK", NT_STATUS_POSSIBLE_DEADLOCK}, -+ {"NT_STATUS_NETWORK_CREDENTIAL_CONFLICT", -+ NT_STATUS_NETWORK_CREDENTIAL_CONFLICT}, -+ {"NT_STATUS_REMOTE_SESSION_LIMIT", NT_STATUS_REMOTE_SESSION_LIMIT}, -+ {"NT_STATUS_EVENTLOG_FILE_CHANGED", -+ NT_STATUS_EVENTLOG_FILE_CHANGED}, -+ {"NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT", -+ NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT}, -+ {"NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT", -+ NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT}, -+ {"NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT", -+ NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT}, -+ {"NT_STATUS_DOMAIN_TRUST_INCONSISTENT", -+ NT_STATUS_DOMAIN_TRUST_INCONSISTENT}, -+ {"NT_STATUS_FS_DRIVER_REQUIRED", NT_STATUS_FS_DRIVER_REQUIRED}, -+ {"NT_STATUS_NO_USER_SESSION_KEY", NT_STATUS_NO_USER_SESSION_KEY}, -+ {"NT_STATUS_USER_SESSION_DELETED", NT_STATUS_USER_SESSION_DELETED}, -+ {"NT_STATUS_RESOURCE_LANG_NOT_FOUND", -+ NT_STATUS_RESOURCE_LANG_NOT_FOUND}, -+ {"NT_STATUS_INSUFF_SERVER_RESOURCES", -+ NT_STATUS_INSUFF_SERVER_RESOURCES}, -+ {"NT_STATUS_INVALID_BUFFER_SIZE", NT_STATUS_INVALID_BUFFER_SIZE}, -+ {"NT_STATUS_INVALID_ADDRESS_COMPONENT", -+ NT_STATUS_INVALID_ADDRESS_COMPONENT}, -+ {"NT_STATUS_INVALID_ADDRESS_WILDCARD", -+ NT_STATUS_INVALID_ADDRESS_WILDCARD}, -+ {"NT_STATUS_TOO_MANY_ADDRESSES", NT_STATUS_TOO_MANY_ADDRESSES}, -+ {"NT_STATUS_ADDRESS_ALREADY_EXISTS", -+ NT_STATUS_ADDRESS_ALREADY_EXISTS}, -+ {"NT_STATUS_ADDRESS_CLOSED", NT_STATUS_ADDRESS_CLOSED}, -+ {"NT_STATUS_CONNECTION_DISCONNECTED", -+ NT_STATUS_CONNECTION_DISCONNECTED}, -+ {"NT_STATUS_CONNECTION_RESET", NT_STATUS_CONNECTION_RESET}, -+ {"NT_STATUS_TOO_MANY_NODES", NT_STATUS_TOO_MANY_NODES}, -+ {"NT_STATUS_TRANSACTION_ABORTED", NT_STATUS_TRANSACTION_ABORTED}, -+ {"NT_STATUS_TRANSACTION_TIMED_OUT", -+ NT_STATUS_TRANSACTION_TIMED_OUT}, -+ {"NT_STATUS_TRANSACTION_NO_RELEASE", -+ NT_STATUS_TRANSACTION_NO_RELEASE}, -+ {"NT_STATUS_TRANSACTION_NO_MATCH", NT_STATUS_TRANSACTION_NO_MATCH}, -+ {"NT_STATUS_TRANSACTION_RESPONDED", -+ NT_STATUS_TRANSACTION_RESPONDED}, -+ {"NT_STATUS_TRANSACTION_INVALID_ID", -+ NT_STATUS_TRANSACTION_INVALID_ID}, -+ {"NT_STATUS_TRANSACTION_INVALID_TYPE", -+ NT_STATUS_TRANSACTION_INVALID_TYPE}, -+ {"NT_STATUS_NOT_SERVER_SESSION", NT_STATUS_NOT_SERVER_SESSION}, -+ {"NT_STATUS_NOT_CLIENT_SESSION", NT_STATUS_NOT_CLIENT_SESSION}, -+ {"NT_STATUS_CANNOT_LOAD_REGISTRY_FILE", -+ NT_STATUS_CANNOT_LOAD_REGISTRY_FILE}, -+ {"NT_STATUS_DEBUG_ATTACH_FAILED", NT_STATUS_DEBUG_ATTACH_FAILED}, -+ {"NT_STATUS_SYSTEM_PROCESS_TERMINATED", -+ NT_STATUS_SYSTEM_PROCESS_TERMINATED}, -+ {"NT_STATUS_DATA_NOT_ACCEPTED", NT_STATUS_DATA_NOT_ACCEPTED}, -+ {"NT_STATUS_NO_BROWSER_SERVERS_FOUND", -+ NT_STATUS_NO_BROWSER_SERVERS_FOUND}, -+ {"NT_STATUS_VDM_HARD_ERROR", NT_STATUS_VDM_HARD_ERROR}, -+ {"NT_STATUS_DRIVER_CANCEL_TIMEOUT", -+ NT_STATUS_DRIVER_CANCEL_TIMEOUT}, -+ {"NT_STATUS_REPLY_MESSAGE_MISMATCH", -+ NT_STATUS_REPLY_MESSAGE_MISMATCH}, -+ {"NT_STATUS_MAPPED_ALIGNMENT", NT_STATUS_MAPPED_ALIGNMENT}, -+ {"NT_STATUS_IMAGE_CHECKSUM_MISMATCH", -+ NT_STATUS_IMAGE_CHECKSUM_MISMATCH}, -+ {"NT_STATUS_LOST_WRITEBEHIND_DATA", -+ NT_STATUS_LOST_WRITEBEHIND_DATA}, -+ {"NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID", -+ NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID}, -+ {"NT_STATUS_PASSWORD_MUST_CHANGE", NT_STATUS_PASSWORD_MUST_CHANGE}, -+ {"NT_STATUS_NOT_FOUND", NT_STATUS_NOT_FOUND}, -+ {"NT_STATUS_NOT_TINY_STREAM", NT_STATUS_NOT_TINY_STREAM}, -+ {"NT_STATUS_RECOVERY_FAILURE", NT_STATUS_RECOVERY_FAILURE}, -+ {"NT_STATUS_STACK_OVERFLOW_READ", NT_STATUS_STACK_OVERFLOW_READ}, -+ {"NT_STATUS_FAIL_CHECK", NT_STATUS_FAIL_CHECK}, -+ {"NT_STATUS_DUPLICATE_OBJECTID", NT_STATUS_DUPLICATE_OBJECTID}, -+ {"NT_STATUS_OBJECTID_EXISTS", NT_STATUS_OBJECTID_EXISTS}, -+ {"NT_STATUS_CONVERT_TO_LARGE", NT_STATUS_CONVERT_TO_LARGE}, -+ {"NT_STATUS_RETRY", NT_STATUS_RETRY}, -+ {"NT_STATUS_FOUND_OUT_OF_SCOPE", NT_STATUS_FOUND_OUT_OF_SCOPE}, -+ {"NT_STATUS_ALLOCATE_BUCKET", NT_STATUS_ALLOCATE_BUCKET}, -+ {"NT_STATUS_PROPSET_NOT_FOUND", NT_STATUS_PROPSET_NOT_FOUND}, -+ {"NT_STATUS_MARSHALL_OVERFLOW", NT_STATUS_MARSHALL_OVERFLOW}, -+ {"NT_STATUS_INVALID_VARIANT", NT_STATUS_INVALID_VARIANT}, -+ {"NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND", -+ NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND}, -+ {"NT_STATUS_ACCOUNT_LOCKED_OUT", NT_STATUS_ACCOUNT_LOCKED_OUT}, -+ {"NT_STATUS_HANDLE_NOT_CLOSABLE", NT_STATUS_HANDLE_NOT_CLOSABLE}, -+ {"NT_STATUS_CONNECTION_REFUSED", NT_STATUS_CONNECTION_REFUSED}, -+ {"NT_STATUS_GRACEFUL_DISCONNECT", NT_STATUS_GRACEFUL_DISCONNECT}, -+ {"NT_STATUS_ADDRESS_ALREADY_ASSOCIATED", -+ NT_STATUS_ADDRESS_ALREADY_ASSOCIATED}, -+ {"NT_STATUS_ADDRESS_NOT_ASSOCIATED", -+ NT_STATUS_ADDRESS_NOT_ASSOCIATED}, -+ {"NT_STATUS_CONNECTION_INVALID", NT_STATUS_CONNECTION_INVALID}, -+ {"NT_STATUS_CONNECTION_ACTIVE", NT_STATUS_CONNECTION_ACTIVE}, -+ {"NT_STATUS_NETWORK_UNREACHABLE", NT_STATUS_NETWORK_UNREACHABLE}, -+ {"NT_STATUS_HOST_UNREACHABLE", NT_STATUS_HOST_UNREACHABLE}, -+ {"NT_STATUS_PROTOCOL_UNREACHABLE", NT_STATUS_PROTOCOL_UNREACHABLE}, -+ {"NT_STATUS_PORT_UNREACHABLE", NT_STATUS_PORT_UNREACHABLE}, -+ {"NT_STATUS_REQUEST_ABORTED", NT_STATUS_REQUEST_ABORTED}, -+ {"NT_STATUS_CONNECTION_ABORTED", NT_STATUS_CONNECTION_ABORTED}, -+ {"NT_STATUS_BAD_COMPRESSION_BUFFER", -+ NT_STATUS_BAD_COMPRESSION_BUFFER}, -+ {"NT_STATUS_USER_MAPPED_FILE", NT_STATUS_USER_MAPPED_FILE}, -+ {"NT_STATUS_AUDIT_FAILED", NT_STATUS_AUDIT_FAILED}, -+ {"NT_STATUS_TIMER_RESOLUTION_NOT_SET", -+ NT_STATUS_TIMER_RESOLUTION_NOT_SET}, -+ {"NT_STATUS_CONNECTION_COUNT_LIMIT", -+ NT_STATUS_CONNECTION_COUNT_LIMIT}, -+ {"NT_STATUS_LOGIN_TIME_RESTRICTION", -+ NT_STATUS_LOGIN_TIME_RESTRICTION}, -+ {"NT_STATUS_LOGIN_WKSTA_RESTRICTION", -+ NT_STATUS_LOGIN_WKSTA_RESTRICTION}, -+ {"NT_STATUS_IMAGE_MP_UP_MISMATCH", NT_STATUS_IMAGE_MP_UP_MISMATCH}, -+ {"NT_STATUS_INSUFFICIENT_LOGON_INFO", -+ NT_STATUS_INSUFFICIENT_LOGON_INFO}, -+ {"NT_STATUS_BAD_DLL_ENTRYPOINT", NT_STATUS_BAD_DLL_ENTRYPOINT}, -+ {"NT_STATUS_BAD_SERVICE_ENTRYPOINT", -+ NT_STATUS_BAD_SERVICE_ENTRYPOINT}, -+ {"NT_STATUS_LPC_REPLY_LOST", NT_STATUS_LPC_REPLY_LOST}, -+ {"NT_STATUS_IP_ADDRESS_CONFLICT1", NT_STATUS_IP_ADDRESS_CONFLICT1}, -+ {"NT_STATUS_IP_ADDRESS_CONFLICT2", NT_STATUS_IP_ADDRESS_CONFLICT2}, -+ {"NT_STATUS_REGISTRY_QUOTA_LIMIT", NT_STATUS_REGISTRY_QUOTA_LIMIT}, -+ {"NT_STATUS_PATH_NOT_COVERED", NT_STATUS_PATH_NOT_COVERED}, -+ {"NT_STATUS_NO_CALLBACK_ACTIVE", NT_STATUS_NO_CALLBACK_ACTIVE}, -+ {"NT_STATUS_LICENSE_QUOTA_EXCEEDED", -+ NT_STATUS_LICENSE_QUOTA_EXCEEDED}, -+ {"NT_STATUS_PWD_TOO_SHORT", NT_STATUS_PWD_TOO_SHORT}, -+ {"NT_STATUS_PWD_TOO_RECENT", NT_STATUS_PWD_TOO_RECENT}, -+ {"NT_STATUS_PWD_HISTORY_CONFLICT", NT_STATUS_PWD_HISTORY_CONFLICT}, -+ {"NT_STATUS_PLUGPLAY_NO_DEVICE", NT_STATUS_PLUGPLAY_NO_DEVICE}, -+ {"NT_STATUS_UNSUPPORTED_COMPRESSION", -+ NT_STATUS_UNSUPPORTED_COMPRESSION}, -+ {"NT_STATUS_INVALID_HW_PROFILE", NT_STATUS_INVALID_HW_PROFILE}, -+ {"NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH", -+ NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH}, -+ {"NT_STATUS_DRIVER_ORDINAL_NOT_FOUND", -+ NT_STATUS_DRIVER_ORDINAL_NOT_FOUND}, -+ {"NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND", -+ NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND}, -+ {"NT_STATUS_RESOURCE_NOT_OWNED", NT_STATUS_RESOURCE_NOT_OWNED}, -+ {"NT_STATUS_TOO_MANY_LINKS", NT_STATUS_TOO_MANY_LINKS}, -+ {"NT_STATUS_QUOTA_LIST_INCONSISTENT", -+ NT_STATUS_QUOTA_LIST_INCONSISTENT}, -+ {"NT_STATUS_FILE_IS_OFFLINE", NT_STATUS_FILE_IS_OFFLINE}, -+ {"NT_STATUS_NO_MORE_ENTRIES", NT_STATUS_NO_MORE_ENTRIES}, -+ {"STATUS_MORE_ENTRIES", STATUS_MORE_ENTRIES}, -+ {"STATUS_SOME_UNMAPPED", STATUS_SOME_UNMAPPED}, -+ {NULL, 0} -+}; ---- /dev/null -+++ b/fs/cifs/nterr.h -@@ -0,0 +1,556 @@ -+/* -+ Unix SMB/Netbios implementation. -+ Version 1.9. -+ NT error code constants -+ Copyright (C) Andrew Tridgell 1992-2000 -+ Copyright (C) John H Terpstra 1996-2000 -+ Copyright (C) Luke Kenneth Casson Leighton 1996-2000 -+ Copyright (C) Paul Ashton 1998-2000 -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 2 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software -+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -+*/ -+ -+ -+ -+#ifndef _NTERR_H -+#define _NTERR_H -+ -+struct nt_err_code_struct { -+ char *nt_errstr; -+ __u32 nt_errcode; -+}; -+ -+extern const struct nt_err_code_struct nt_errs[]; -+ -+/* Win32 Status codes. */ -+ -+#define STATUS_BUFFER_OVERFLOW 0x80000005 -+#define STATUS_MORE_ENTRIES 0x0105 -+#define ERROR_INVALID_PARAMETER 0x0057 -+#define ERROR_INSUFFICIENT_BUFFER 0x007a -+#define STATUS_1804 0x070c -+#define STATUS_NOTIFY_ENUM_DIR 0x010c -+ -+/* Win32 Error codes extracted using a loop in smbclient then printing a -+ netmon sniff to a file. */ -+ -+#define NT_STATUS_OK 0x0000 -+#define STATUS_SOME_UNMAPPED 0x0107 -+#define STATUS_BUFFER_OVERFLOW 0x80000005 -+#define NT_STATUS_NO_MORE_ENTRIES 0x8000001a -+#define NT_STATUS_UNSUCCESSFUL 0xC0000000 | 0x0001 -+#define NT_STATUS_NOT_IMPLEMENTED 0xC0000000 | 0x0002 -+#define NT_STATUS_INVALID_INFO_CLASS 0xC0000000 | 0x0003 -+#define NT_STATUS_INFO_LENGTH_MISMATCH 0xC0000000 | 0x0004 -+#define NT_STATUS_ACCESS_VIOLATION 0xC0000000 | 0x0005 -+#define NT_STATUS_IN_PAGE_ERROR 0xC0000000 | 0x0006 -+#define NT_STATUS_PAGEFILE_QUOTA 0xC0000000 | 0x0007 -+#define NT_STATUS_INVALID_HANDLE 0xC0000000 | 0x0008 -+#define NT_STATUS_BAD_INITIAL_STACK 0xC0000000 | 0x0009 -+#define NT_STATUS_BAD_INITIAL_PC 0xC0000000 | 0x000a -+#define NT_STATUS_INVALID_CID 0xC0000000 | 0x000b -+#define NT_STATUS_TIMER_NOT_CANCELED 0xC0000000 | 0x000c -+#define NT_STATUS_INVALID_PARAMETER 0xC0000000 | 0x000d -+#define NT_STATUS_NO_SUCH_DEVICE 0xC0000000 | 0x000e -+#define NT_STATUS_NO_SUCH_FILE 0xC0000000 | 0x000f -+#define NT_STATUS_INVALID_DEVICE_REQUEST 0xC0000000 | 0x0010 -+#define NT_STATUS_END_OF_FILE 0xC0000000 | 0x0011 -+#define NT_STATUS_WRONG_VOLUME 0xC0000000 | 0x0012 -+#define NT_STATUS_NO_MEDIA_IN_DEVICE 0xC0000000 | 0x0013 -+#define NT_STATUS_UNRECOGNIZED_MEDIA 0xC0000000 | 0x0014 -+#define NT_STATUS_NONEXISTENT_SECTOR 0xC0000000 | 0x0015 -+#define NT_STATUS_MORE_PROCESSING_REQUIRED 0xC0000000 | 0x0016 -+#define NT_STATUS_NO_MEMORY 0xC0000000 | 0x0017 -+#define NT_STATUS_CONFLICTING_ADDRESSES 0xC0000000 | 0x0018 -+#define NT_STATUS_NOT_MAPPED_VIEW 0xC0000000 | 0x0019 -+#define NT_STATUS_UNABLE_TO_FREE_VM 0x80000000 | 0x001a -+#define NT_STATUS_UNABLE_TO_DELETE_SECTION 0xC0000000 | 0x001b -+#define NT_STATUS_INVALID_SYSTEM_SERVICE 0xC0000000 | 0x001c -+#define NT_STATUS_ILLEGAL_INSTRUCTION 0xC0000000 | 0x001d -+#define NT_STATUS_INVALID_LOCK_SEQUENCE 0xC0000000 | 0x001e -+#define NT_STATUS_INVALID_VIEW_SIZE 0xC0000000 | 0x001f -+#define NT_STATUS_INVALID_FILE_FOR_SECTION 0xC0000000 | 0x0020 -+#define NT_STATUS_ALREADY_COMMITTED 0xC0000000 | 0x0021 -+#define NT_STATUS_ACCESS_DENIED 0xC0000000 | 0x0022 -+#define NT_STATUS_BUFFER_TOO_SMALL 0xC0000000 | 0x0023 -+#define NT_STATUS_OBJECT_TYPE_MISMATCH 0xC0000000 | 0x0024 -+#define NT_STATUS_NONCONTINUABLE_EXCEPTION 0xC0000000 | 0x0025 -+#define NT_STATUS_INVALID_DISPOSITION 0xC0000000 | 0x0026 -+#define NT_STATUS_UNWIND 0xC0000000 | 0x0027 -+#define NT_STATUS_BAD_STACK 0xC0000000 | 0x0028 -+#define NT_STATUS_INVALID_UNWIND_TARGET 0xC0000000 | 0x0029 -+#define NT_STATUS_NOT_LOCKED 0xC0000000 | 0x002a -+#define NT_STATUS_PARITY_ERROR 0xC0000000 | 0x002b -+#define NT_STATUS_UNABLE_TO_DECOMMIT_VM 0xC0000000 | 0x002c -+#define NT_STATUS_NOT_COMMITTED 0xC0000000 | 0x002d -+#define NT_STATUS_INVALID_PORT_ATTRIBUTES 0xC0000000 | 0x002e -+#define NT_STATUS_PORT_MESSAGE_TOO_LONG 0xC0000000 | 0x002f -+#define NT_STATUS_INVALID_PARAMETER_MIX 0xC0000000 | 0x0030 -+#define NT_STATUS_INVALID_QUOTA_LOWER 0xC0000000 | 0x0031 -+#define NT_STATUS_DISK_CORRUPT_ERROR 0xC0000000 | 0x0032 -+#define NT_STATUS_OBJECT_NAME_INVALID 0xC0000000 | 0x0033 -+#define NT_STATUS_OBJECT_NAME_NOT_FOUND 0xC0000000 | 0x0034 -+#define NT_STATUS_OBJECT_NAME_COLLISION 0xC0000000 | 0x0035 -+#define NT_STATUS_HANDLE_NOT_WAITABLE 0xC0000000 | 0x0036 -+#define NT_STATUS_PORT_DISCONNECTED 0xC0000000 | 0x0037 -+#define NT_STATUS_DEVICE_ALREADY_ATTACHED 0xC0000000 | 0x0038 -+#define NT_STATUS_OBJECT_PATH_INVALID 0xC0000000 | 0x0039 -+#define NT_STATUS_OBJECT_PATH_NOT_FOUND 0xC0000000 | 0x003a -+#define NT_STATUS_OBJECT_PATH_SYNTAX_BAD 0xC0000000 | 0x003b -+#define NT_STATUS_DATA_OVERRUN 0xC0000000 | 0x003c -+#define NT_STATUS_DATA_LATE_ERROR 0xC0000000 | 0x003d -+#define NT_STATUS_DATA_ERROR 0xC0000000 | 0x003e -+#define NT_STATUS_CRC_ERROR 0xC0000000 | 0x003f -+#define NT_STATUS_SECTION_TOO_BIG 0xC0000000 | 0x0040 -+#define NT_STATUS_PORT_CONNECTION_REFUSED 0xC0000000 | 0x0041 -+#define NT_STATUS_INVALID_PORT_HANDLE 0xC0000000 | 0x0042 -+#define NT_STATUS_SHARING_VIOLATION 0xC0000000 | 0x0043 -+#define NT_STATUS_QUOTA_EXCEEDED 0xC0000000 | 0x0044 -+#define NT_STATUS_INVALID_PAGE_PROTECTION 0xC0000000 | 0x0045 -+#define NT_STATUS_MUTANT_NOT_OWNED 0xC0000000 | 0x0046 -+#define NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED 0xC0000000 | 0x0047 -+#define NT_STATUS_PORT_ALREADY_SET 0xC0000000 | 0x0048 -+#define NT_STATUS_SECTION_NOT_IMAGE 0xC0000000 | 0x0049 -+#define NT_STATUS_SUSPEND_COUNT_EXCEEDED 0xC0000000 | 0x004a -+#define NT_STATUS_THREAD_IS_TERMINATING 0xC0000000 | 0x004b -+#define NT_STATUS_BAD_WORKING_SET_LIMIT 0xC0000000 | 0x004c -+#define NT_STATUS_INCOMPATIBLE_FILE_MAP 0xC0000000 | 0x004d -+#define NT_STATUS_SECTION_PROTECTION 0xC0000000 | 0x004e -+#define NT_STATUS_EAS_NOT_SUPPORTED 0xC0000000 | 0x004f -+#define NT_STATUS_EA_TOO_LARGE 0xC0000000 | 0x0050 -+#define NT_STATUS_NONEXISTENT_EA_ENTRY 0xC0000000 | 0x0051 -+#define NT_STATUS_NO_EAS_ON_FILE 0xC0000000 | 0x0052 -+#define NT_STATUS_EA_CORRUPT_ERROR 0xC0000000 | 0x0053 -+#define NT_STATUS_FILE_LOCK_CONFLICT 0xC0000000 | 0x0054 -+#define NT_STATUS_LOCK_NOT_GRANTED 0xC0000000 | 0x0055 -+#define NT_STATUS_DELETE_PENDING 0xC0000000 | 0x0056 -+#define NT_STATUS_CTL_FILE_NOT_SUPPORTED 0xC0000000 | 0x0057 -+#define NT_STATUS_UNKNOWN_REVISION 0xC0000000 | 0x0058 -+#define NT_STATUS_REVISION_MISMATCH 0xC0000000 | 0x0059 -+#define NT_STATUS_INVALID_OWNER 0xC0000000 | 0x005a -+#define NT_STATUS_INVALID_PRIMARY_GROUP 0xC0000000 | 0x005b -+#define NT_STATUS_NO_IMPERSONATION_TOKEN 0xC0000000 | 0x005c -+#define NT_STATUS_CANT_DISABLE_MANDATORY 0xC0000000 | 0x005d -+#define NT_STATUS_NO_LOGON_SERVERS 0xC0000000 | 0x005e -+#define NT_STATUS_NO_SUCH_LOGON_SESSION 0xC0000000 | 0x005f -+#define NT_STATUS_NO_SUCH_PRIVILEGE 0xC0000000 | 0x0060 -+#define NT_STATUS_PRIVILEGE_NOT_HELD 0xC0000000 | 0x0061 -+#define NT_STATUS_INVALID_ACCOUNT_NAME 0xC0000000 | 0x0062 -+#define NT_STATUS_USER_EXISTS 0xC0000000 | 0x0063 -+#define NT_STATUS_NO_SUCH_USER 0xC0000000 | 0x0064 -+#define NT_STATUS_GROUP_EXISTS 0xC0000000 | 0x0065 -+#define NT_STATUS_NO_SUCH_GROUP 0xC0000000 | 0x0066 -+#define NT_STATUS_MEMBER_IN_GROUP 0xC0000000 | 0x0067 -+#define NT_STATUS_MEMBER_NOT_IN_GROUP 0xC0000000 | 0x0068 -+#define NT_STATUS_LAST_ADMIN 0xC0000000 | 0x0069 -+#define NT_STATUS_WRONG_PASSWORD 0xC0000000 | 0x006a -+#define NT_STATUS_ILL_FORMED_PASSWORD 0xC0000000 | 0x006b -+#define NT_STATUS_PASSWORD_RESTRICTION 0xC0000000 | 0x006c -+#define NT_STATUS_LOGON_FAILURE 0xC0000000 | 0x006d -+#define NT_STATUS_ACCOUNT_RESTRICTION 0xC0000000 | 0x006e -+#define NT_STATUS_INVALID_LOGON_HOURS 0xC0000000 | 0x006f -+#define NT_STATUS_INVALID_WORKSTATION 0xC0000000 | 0x0070 -+#define NT_STATUS_PASSWORD_EXPIRED 0xC0000000 | 0x0071 -+#define NT_STATUS_ACCOUNT_DISABLED 0xC0000000 | 0x0072 -+#define NT_STATUS_NONE_MAPPED 0xC0000000 | 0x0073 -+#define NT_STATUS_TOO_MANY_LUIDS_REQUESTED 0xC0000000 | 0x0074 -+#define NT_STATUS_LUIDS_EXHAUSTED 0xC0000000 | 0x0075 -+#define NT_STATUS_INVALID_SUB_AUTHORITY 0xC0000000 | 0x0076 -+#define NT_STATUS_INVALID_ACL 0xC0000000 | 0x0077 -+#define NT_STATUS_INVALID_SID 0xC0000000 | 0x0078 -+#define NT_STATUS_INVALID_SECURITY_DESCR 0xC0000000 | 0x0079 -+#define NT_STATUS_PROCEDURE_NOT_FOUND 0xC0000000 | 0x007a -+#define NT_STATUS_INVALID_IMAGE_FORMAT 0xC0000000 | 0x007b -+#define NT_STATUS_NO_TOKEN 0xC0000000 | 0x007c -+#define NT_STATUS_BAD_INHERITANCE_ACL 0xC0000000 | 0x007d -+#define NT_STATUS_RANGE_NOT_LOCKED 0xC0000000 | 0x007e -+#define NT_STATUS_DISK_FULL 0xC0000000 | 0x007f -+#define NT_STATUS_SERVER_DISABLED 0xC0000000 | 0x0080 -+#define NT_STATUS_SERVER_NOT_DISABLED 0xC0000000 | 0x0081 -+#define NT_STATUS_TOO_MANY_GUIDS_REQUESTED 0xC0000000 | 0x0082 -+#define NT_STATUS_GUIDS_EXHAUSTED 0xC0000000 | 0x0083 -+#define NT_STATUS_INVALID_ID_AUTHORITY 0xC0000000 | 0x0084 -+#define NT_STATUS_AGENTS_EXHAUSTED 0xC0000000 | 0x0085 -+#define NT_STATUS_INVALID_VOLUME_LABEL 0xC0000000 | 0x0086 -+#define NT_STATUS_SECTION_NOT_EXTENDED 0xC0000000 | 0x0087 -+#define NT_STATUS_NOT_MAPPED_DATA 0xC0000000 | 0x0088 -+#define NT_STATUS_RESOURCE_DATA_NOT_FOUND 0xC0000000 | 0x0089 -+#define NT_STATUS_RESOURCE_TYPE_NOT_FOUND 0xC0000000 | 0x008a -+#define NT_STATUS_RESOURCE_NAME_NOT_FOUND 0xC0000000 | 0x008b -+#define NT_STATUS_ARRAY_BOUNDS_EXCEEDED 0xC0000000 | 0x008c -+#define NT_STATUS_FLOAT_DENORMAL_OPERAND 0xC0000000 | 0x008d -+#define NT_STATUS_FLOAT_DIVIDE_BY_ZERO 0xC0000000 | 0x008e -+#define NT_STATUS_FLOAT_INEXACT_RESULT 0xC0000000 | 0x008f -+#define NT_STATUS_FLOAT_INVALID_OPERATION 0xC0000000 | 0x0090 -+#define NT_STATUS_FLOAT_OVERFLOW 0xC0000000 | 0x0091 -+#define NT_STATUS_FLOAT_STACK_CHECK 0xC0000000 | 0x0092 -+#define NT_STATUS_FLOAT_UNDERFLOW 0xC0000000 | 0x0093 -+#define NT_STATUS_INTEGER_DIVIDE_BY_ZERO 0xC0000000 | 0x0094 -+#define NT_STATUS_INTEGER_OVERFLOW 0xC0000000 | 0x0095 -+#define NT_STATUS_PRIVILEGED_INSTRUCTION 0xC0000000 | 0x0096 -+#define NT_STATUS_TOO_MANY_PAGING_FILES 0xC0000000 | 0x0097 -+#define NT_STATUS_FILE_INVALID 0xC0000000 | 0x0098 -+#define NT_STATUS_ALLOTTED_SPACE_EXCEEDED 0xC0000000 | 0x0099 -+#define NT_STATUS_INSUFFICIENT_RESOURCES 0xC0000000 | 0x009a -+#define NT_STATUS_DFS_EXIT_PATH_FOUND 0xC0000000 | 0x009b -+#define NT_STATUS_DEVICE_DATA_ERROR 0xC0000000 | 0x009c -+#define NT_STATUS_DEVICE_NOT_CONNECTED 0xC0000000 | 0x009d -+#define NT_STATUS_DEVICE_POWER_FAILURE 0xC0000000 | 0x009e -+#define NT_STATUS_FREE_VM_NOT_AT_BASE 0xC0000000 | 0x009f -+#define NT_STATUS_MEMORY_NOT_ALLOCATED 0xC0000000 | 0x00a0 -+#define NT_STATUS_WORKING_SET_QUOTA 0xC0000000 | 0x00a1 -+#define NT_STATUS_MEDIA_WRITE_PROTECTED 0xC0000000 | 0x00a2 -+#define NT_STATUS_DEVICE_NOT_READY 0xC0000000 | 0x00a3 -+#define NT_STATUS_INVALID_GROUP_ATTRIBUTES 0xC0000000 | 0x00a4 -+#define NT_STATUS_BAD_IMPERSONATION_LEVEL 0xC0000000 | 0x00a5 -+#define NT_STATUS_CANT_OPEN_ANONYMOUS 0xC0000000 | 0x00a6 -+#define NT_STATUS_BAD_VALIDATION_CLASS 0xC0000000 | 0x00a7 -+#define NT_STATUS_BAD_TOKEN_TYPE 0xC0000000 | 0x00a8 -+#define NT_STATUS_BAD_MASTER_BOOT_RECORD 0xC0000000 | 0x00a9 -+#define NT_STATUS_INSTRUCTION_MISALIGNMENT 0xC0000000 | 0x00aa -+#define NT_STATUS_INSTANCE_NOT_AVAILABLE 0xC0000000 | 0x00ab -+#define NT_STATUS_PIPE_NOT_AVAILABLE 0xC0000000 | 0x00ac -+#define NT_STATUS_INVALID_PIPE_STATE 0xC0000000 | 0x00ad -+#define NT_STATUS_PIPE_BUSY 0xC0000000 | 0x00ae -+#define NT_STATUS_ILLEGAL_FUNCTION 0xC0000000 | 0x00af -+#define NT_STATUS_PIPE_DISCONNECTED 0xC0000000 | 0x00b0 -+#define NT_STATUS_PIPE_CLOSING 0xC0000000 | 0x00b1 -+#define NT_STATUS_PIPE_CONNECTED 0xC0000000 | 0x00b2 -+#define NT_STATUS_PIPE_LISTENING 0xC0000000 | 0x00b3 -+#define NT_STATUS_INVALID_READ_MODE 0xC0000000 | 0x00b4 -+#define NT_STATUS_IO_TIMEOUT 0xC0000000 | 0x00b5 -+#define NT_STATUS_FILE_FORCED_CLOSED 0xC0000000 | 0x00b6 -+#define NT_STATUS_PROFILING_NOT_STARTED 0xC0000000 | 0x00b7 -+#define NT_STATUS_PROFILING_NOT_STOPPED 0xC0000000 | 0x00b8 -+#define NT_STATUS_COULD_NOT_INTERPRET 0xC0000000 | 0x00b9 -+#define NT_STATUS_FILE_IS_A_DIRECTORY 0xC0000000 | 0x00ba -+#define NT_STATUS_NOT_SUPPORTED 0xC0000000 | 0x00bb -+#define NT_STATUS_REMOTE_NOT_LISTENING 0xC0000000 | 0x00bc -+#define NT_STATUS_DUPLICATE_NAME 0xC0000000 | 0x00bd -+#define NT_STATUS_BAD_NETWORK_PATH 0xC0000000 | 0x00be -+#define NT_STATUS_NETWORK_BUSY 0xC0000000 | 0x00bf -+#define NT_STATUS_DEVICE_DOES_NOT_EXIST 0xC0000000 | 0x00c0 -+#define NT_STATUS_TOO_MANY_COMMANDS 0xC0000000 | 0x00c1 -+#define NT_STATUS_ADAPTER_HARDWARE_ERROR 0xC0000000 | 0x00c2 -+#define NT_STATUS_INVALID_NETWORK_RESPONSE 0xC0000000 | 0x00c3 -+#define NT_STATUS_UNEXPECTED_NETWORK_ERROR 0xC0000000 | 0x00c4 -+#define NT_STATUS_BAD_REMOTE_ADAPTER 0xC0000000 | 0x00c5 -+#define NT_STATUS_PRINT_QUEUE_FULL 0xC0000000 | 0x00c6 -+#define NT_STATUS_NO_SPOOL_SPACE 0xC0000000 | 0x00c7 -+#define NT_STATUS_PRINT_CANCELLED 0xC0000000 | 0x00c8 -+#define NT_STATUS_NETWORK_NAME_DELETED 0xC0000000 | 0x00c9 -+#define NT_STATUS_NETWORK_ACCESS_DENIED 0xC0000000 | 0x00ca -+#define NT_STATUS_BAD_DEVICE_TYPE 0xC0000000 | 0x00cb -+#define NT_STATUS_BAD_NETWORK_NAME 0xC0000000 | 0x00cc -+#define NT_STATUS_TOO_MANY_NAMES 0xC0000000 | 0x00cd -+#define NT_STATUS_TOO_MANY_SESSIONS 0xC0000000 | 0x00ce -+#define NT_STATUS_SHARING_PAUSED 0xC0000000 | 0x00cf -+#define NT_STATUS_REQUEST_NOT_ACCEPTED 0xC0000000 | 0x00d0 -+#define NT_STATUS_REDIRECTOR_PAUSED 0xC0000000 | 0x00d1 -+#define NT_STATUS_NET_WRITE_FAULT 0xC0000000 | 0x00d2 -+#define NT_STATUS_PROFILING_AT_LIMIT 0xC0000000 | 0x00d3 -+#define NT_STATUS_NOT_SAME_DEVICE 0xC0000000 | 0x00d4 -+#define NT_STATUS_FILE_RENAMED 0xC0000000 | 0x00d5 -+#define NT_STATUS_VIRTUAL_CIRCUIT_CLOSED 0xC0000000 | 0x00d6 -+#define NT_STATUS_NO_SECURITY_ON_OBJECT 0xC0000000 | 0x00d7 -+#define NT_STATUS_CANT_WAIT 0xC0000000 | 0x00d8 -+#define NT_STATUS_PIPE_EMPTY 0xC0000000 | 0x00d9 -+#define NT_STATUS_CANT_ACCESS_DOMAIN_INFO 0xC0000000 | 0x00da -+#define NT_STATUS_CANT_TERMINATE_SELF 0xC0000000 | 0x00db -+#define NT_STATUS_INVALID_SERVER_STATE 0xC0000000 | 0x00dc -+#define NT_STATUS_INVALID_DOMAIN_STATE 0xC0000000 | 0x00dd -+#define NT_STATUS_INVALID_DOMAIN_ROLE 0xC0000000 | 0x00de -+#define NT_STATUS_NO_SUCH_DOMAIN 0xC0000000 | 0x00df -+#define NT_STATUS_DOMAIN_EXISTS 0xC0000000 | 0x00e0 -+#define NT_STATUS_DOMAIN_LIMIT_EXCEEDED 0xC0000000 | 0x00e1 -+#define NT_STATUS_OPLOCK_NOT_GRANTED 0xC0000000 | 0x00e2 -+#define NT_STATUS_INVALID_OPLOCK_PROTOCOL 0xC0000000 | 0x00e3 -+#define NT_STATUS_INTERNAL_DB_CORRUPTION 0xC0000000 | 0x00e4 -+#define NT_STATUS_INTERNAL_ERROR 0xC0000000 | 0x00e5 -+#define NT_STATUS_GENERIC_NOT_MAPPED 0xC0000000 | 0x00e6 -+#define NT_STATUS_BAD_DESCRIPTOR_FORMAT 0xC0000000 | 0x00e7 -+#define NT_STATUS_INVALID_USER_BUFFER 0xC0000000 | 0x00e8 -+#define NT_STATUS_UNEXPECTED_IO_ERROR 0xC0000000 | 0x00e9 -+#define NT_STATUS_UNEXPECTED_MM_CREATE_ERR 0xC0000000 | 0x00ea -+#define NT_STATUS_UNEXPECTED_MM_MAP_ERROR 0xC0000000 | 0x00eb -+#define NT_STATUS_UNEXPECTED_MM_EXTEND_ERR 0xC0000000 | 0x00ec -+#define NT_STATUS_NOT_LOGON_PROCESS 0xC0000000 | 0x00ed -+#define NT_STATUS_LOGON_SESSION_EXISTS 0xC0000000 | 0x00ee -+#define NT_STATUS_INVALID_PARAMETER_1 0xC0000000 | 0x00ef -+#define NT_STATUS_INVALID_PARAMETER_2 0xC0000000 | 0x00f0 -+#define NT_STATUS_INVALID_PARAMETER_3 0xC0000000 | 0x00f1 -+#define NT_STATUS_INVALID_PARAMETER_4 0xC0000000 | 0x00f2 -+#define NT_STATUS_INVALID_PARAMETER_5 0xC0000000 | 0x00f3 -+#define NT_STATUS_INVALID_PARAMETER_6 0xC0000000 | 0x00f4 -+#define NT_STATUS_INVALID_PARAMETER_7 0xC0000000 | 0x00f5 -+#define NT_STATUS_INVALID_PARAMETER_8 0xC0000000 | 0x00f6 -+#define NT_STATUS_INVALID_PARAMETER_9 0xC0000000 | 0x00f7 -+#define NT_STATUS_INVALID_PARAMETER_10 0xC0000000 | 0x00f8 -+#define NT_STATUS_INVALID_PARAMETER_11 0xC0000000 | 0x00f9 -+#define NT_STATUS_INVALID_PARAMETER_12 0xC0000000 | 0x00fa -+#define NT_STATUS_REDIRECTOR_NOT_STARTED 0xC0000000 | 0x00fb -+#define NT_STATUS_REDIRECTOR_STARTED 0xC0000000 | 0x00fc -+#define NT_STATUS_STACK_OVERFLOW 0xC0000000 | 0x00fd -+#define NT_STATUS_NO_SUCH_PACKAGE 0xC0000000 | 0x00fe -+#define NT_STATUS_BAD_FUNCTION_TABLE 0xC0000000 | 0x00ff -+#define NT_STATUS_DIRECTORY_NOT_EMPTY 0xC0000000 | 0x0101 -+#define NT_STATUS_FILE_CORRUPT_ERROR 0xC0000000 | 0x0102 -+#define NT_STATUS_NOT_A_DIRECTORY 0xC0000000 | 0x0103 -+#define NT_STATUS_BAD_LOGON_SESSION_STATE 0xC0000000 | 0x0104 -+#define NT_STATUS_LOGON_SESSION_COLLISION 0xC0000000 | 0x0105 -+#define NT_STATUS_NAME_TOO_LONG 0xC0000000 | 0x0106 -+#define NT_STATUS_FILES_OPEN 0xC0000000 | 0x0107 -+#define NT_STATUS_CONNECTION_IN_USE 0xC0000000 | 0x0108 -+#define NT_STATUS_MESSAGE_NOT_FOUND 0xC0000000 | 0x0109 -+#define NT_STATUS_PROCESS_IS_TERMINATING 0xC0000000 | 0x010a -+#define NT_STATUS_INVALID_LOGON_TYPE 0xC0000000 | 0x010b -+#define NT_STATUS_NO_GUID_TRANSLATION 0xC0000000 | 0x010c -+#define NT_STATUS_CANNOT_IMPERSONATE 0xC0000000 | 0x010d -+#define NT_STATUS_IMAGE_ALREADY_LOADED 0xC0000000 | 0x010e -+#define NT_STATUS_ABIOS_NOT_PRESENT 0xC0000000 | 0x010f -+#define NT_STATUS_ABIOS_LID_NOT_EXIST 0xC0000000 | 0x0110 -+#define NT_STATUS_ABIOS_LID_ALREADY_OWNED 0xC0000000 | 0x0111 -+#define NT_STATUS_ABIOS_NOT_LID_OWNER 0xC0000000 | 0x0112 -+#define NT_STATUS_ABIOS_INVALID_COMMAND 0xC0000000 | 0x0113 -+#define NT_STATUS_ABIOS_INVALID_LID 0xC0000000 | 0x0114 -+#define NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE 0xC0000000 | 0x0115 -+#define NT_STATUS_ABIOS_INVALID_SELECTOR 0xC0000000 | 0x0116 -+#define NT_STATUS_NO_LDT 0xC0000000 | 0x0117 -+#define NT_STATUS_INVALID_LDT_SIZE 0xC0000000 | 0x0118 -+#define NT_STATUS_INVALID_LDT_OFFSET 0xC0000000 | 0x0119 -+#define NT_STATUS_INVALID_LDT_DESCRIPTOR 0xC0000000 | 0x011a -+#define NT_STATUS_INVALID_IMAGE_NE_FORMAT 0xC0000000 | 0x011b -+#define NT_STATUS_RXACT_INVALID_STATE 0xC0000000 | 0x011c -+#define NT_STATUS_RXACT_COMMIT_FAILURE 0xC0000000 | 0x011d -+#define NT_STATUS_MAPPED_FILE_SIZE_ZERO 0xC0000000 | 0x011e -+#define NT_STATUS_TOO_MANY_OPENED_FILES 0xC0000000 | 0x011f -+#define NT_STATUS_CANCELLED 0xC0000000 | 0x0120 -+#define NT_STATUS_CANNOT_DELETE 0xC0000000 | 0x0121 -+#define NT_STATUS_INVALID_COMPUTER_NAME 0xC0000000 | 0x0122 -+#define NT_STATUS_FILE_DELETED 0xC0000000 | 0x0123 -+#define NT_STATUS_SPECIAL_ACCOUNT 0xC0000000 | 0x0124 -+#define NT_STATUS_SPECIAL_GROUP 0xC0000000 | 0x0125 -+#define NT_STATUS_SPECIAL_USER 0xC0000000 | 0x0126 -+#define NT_STATUS_MEMBERS_PRIMARY_GROUP 0xC0000000 | 0x0127 -+#define NT_STATUS_FILE_CLOSED 0xC0000000 | 0x0128 -+#define NT_STATUS_TOO_MANY_THREADS 0xC0000000 | 0x0129 -+#define NT_STATUS_THREAD_NOT_IN_PROCESS 0xC0000000 | 0x012a -+#define NT_STATUS_TOKEN_ALREADY_IN_USE 0xC0000000 | 0x012b -+#define NT_STATUS_PAGEFILE_QUOTA_EXCEEDED 0xC0000000 | 0x012c -+#define NT_STATUS_COMMITMENT_LIMIT 0xC0000000 | 0x012d -+#define NT_STATUS_INVALID_IMAGE_LE_FORMAT 0xC0000000 | 0x012e -+#define NT_STATUS_INVALID_IMAGE_NOT_MZ 0xC0000000 | 0x012f -+#define NT_STATUS_INVALID_IMAGE_PROTECT 0xC0000000 | 0x0130 -+#define NT_STATUS_INVALID_IMAGE_WIN_16 0xC0000000 | 0x0131 -+#define NT_STATUS_LOGON_SERVER_CONFLICT 0xC0000000 | 0x0132 -+#define NT_STATUS_TIME_DIFFERENCE_AT_DC 0xC0000000 | 0x0133 -+#define NT_STATUS_SYNCHRONIZATION_REQUIRED 0xC0000000 | 0x0134 -+#define NT_STATUS_DLL_NOT_FOUND 0xC0000000 | 0x0135 -+#define NT_STATUS_OPEN_FAILED 0xC0000000 | 0x0136 -+#define NT_STATUS_IO_PRIVILEGE_FAILED 0xC0000000 | 0x0137 -+#define NT_STATUS_ORDINAL_NOT_FOUND 0xC0000000 | 0x0138 -+#define NT_STATUS_ENTRYPOINT_NOT_FOUND 0xC0000000 | 0x0139 -+#define NT_STATUS_CONTROL_C_EXIT 0xC0000000 | 0x013a -+#define NT_STATUS_LOCAL_DISCONNECT 0xC0000000 | 0x013b -+#define NT_STATUS_REMOTE_DISCONNECT 0xC0000000 | 0x013c -+#define NT_STATUS_REMOTE_RESOURCES 0xC0000000 | 0x013d -+#define NT_STATUS_LINK_FAILED 0xC0000000 | 0x013e -+#define NT_STATUS_LINK_TIMEOUT 0xC0000000 | 0x013f -+#define NT_STATUS_INVALID_CONNECTION 0xC0000000 | 0x0140 -+#define NT_STATUS_INVALID_ADDRESS 0xC0000000 | 0x0141 -+#define NT_STATUS_DLL_INIT_FAILED 0xC0000000 | 0x0142 -+#define NT_STATUS_MISSING_SYSTEMFILE 0xC0000000 | 0x0143 -+#define NT_STATUS_UNHANDLED_EXCEPTION 0xC0000000 | 0x0144 -+#define NT_STATUS_APP_INIT_FAILURE 0xC0000000 | 0x0145 -+#define NT_STATUS_PAGEFILE_CREATE_FAILED 0xC0000000 | 0x0146 -+#define NT_STATUS_NO_PAGEFILE 0xC0000000 | 0x0147 -+#define NT_STATUS_INVALID_LEVEL 0xC0000000 | 0x0148 -+#define NT_STATUS_WRONG_PASSWORD_CORE 0xC0000000 | 0x0149 -+#define NT_STATUS_ILLEGAL_FLOAT_CONTEXT 0xC0000000 | 0x014a -+#define NT_STATUS_PIPE_BROKEN 0xC0000000 | 0x014b -+#define NT_STATUS_REGISTRY_CORRUPT 0xC0000000 | 0x014c -+#define NT_STATUS_REGISTRY_IO_FAILED 0xC0000000 | 0x014d -+#define NT_STATUS_NO_EVENT_PAIR 0xC0000000 | 0x014e -+#define NT_STATUS_UNRECOGNIZED_VOLUME 0xC0000000 | 0x014f -+#define NT_STATUS_SERIAL_NO_DEVICE_INITED 0xC0000000 | 0x0150 -+#define NT_STATUS_NO_SUCH_ALIAS 0xC0000000 | 0x0151 -+#define NT_STATUS_MEMBER_NOT_IN_ALIAS 0xC0000000 | 0x0152 -+#define NT_STATUS_MEMBER_IN_ALIAS 0xC0000000 | 0x0153 -+#define NT_STATUS_ALIAS_EXISTS 0xC0000000 | 0x0154 -+#define NT_STATUS_LOGON_NOT_GRANTED 0xC0000000 | 0x0155 -+#define NT_STATUS_TOO_MANY_SECRETS 0xC0000000 | 0x0156 -+#define NT_STATUS_SECRET_TOO_LONG 0xC0000000 | 0x0157 -+#define NT_STATUS_INTERNAL_DB_ERROR 0xC0000000 | 0x0158 -+#define NT_STATUS_FULLSCREEN_MODE 0xC0000000 | 0x0159 -+#define NT_STATUS_TOO_MANY_CONTEXT_IDS 0xC0000000 | 0x015a -+#define NT_STATUS_LOGON_TYPE_NOT_GRANTED 0xC0000000 | 0x015b -+#define NT_STATUS_NOT_REGISTRY_FILE 0xC0000000 | 0x015c -+#define NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED 0xC0000000 | 0x015d -+#define NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR 0xC0000000 | 0x015e -+#define NT_STATUS_FT_MISSING_MEMBER 0xC0000000 | 0x015f -+#define NT_STATUS_ILL_FORMED_SERVICE_ENTRY 0xC0000000 | 0x0160 -+#define NT_STATUS_ILLEGAL_CHARACTER 0xC0000000 | 0x0161 -+#define NT_STATUS_UNMAPPABLE_CHARACTER 0xC0000000 | 0x0162 -+#define NT_STATUS_UNDEFINED_CHARACTER 0xC0000000 | 0x0163 -+#define NT_STATUS_FLOPPY_VOLUME 0xC0000000 | 0x0164 -+#define NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND 0xC0000000 | 0x0165 -+#define NT_STATUS_FLOPPY_WRONG_CYLINDER 0xC0000000 | 0x0166 -+#define NT_STATUS_FLOPPY_UNKNOWN_ERROR 0xC0000000 | 0x0167 -+#define NT_STATUS_FLOPPY_BAD_REGISTERS 0xC0000000 | 0x0168 -+#define NT_STATUS_DISK_RECALIBRATE_FAILED 0xC0000000 | 0x0169 -+#define NT_STATUS_DISK_OPERATION_FAILED 0xC0000000 | 0x016a -+#define NT_STATUS_DISK_RESET_FAILED 0xC0000000 | 0x016b -+#define NT_STATUS_SHARED_IRQ_BUSY 0xC0000000 | 0x016c -+#define NT_STATUS_FT_ORPHANING 0xC0000000 | 0x016d -+#define NT_STATUS_PARTITION_FAILURE 0xC0000000 | 0x0172 -+#define NT_STATUS_INVALID_BLOCK_LENGTH 0xC0000000 | 0x0173 -+#define NT_STATUS_DEVICE_NOT_PARTITIONED 0xC0000000 | 0x0174 -+#define NT_STATUS_UNABLE_TO_LOCK_MEDIA 0xC0000000 | 0x0175 -+#define NT_STATUS_UNABLE_TO_UNLOAD_MEDIA 0xC0000000 | 0x0176 -+#define NT_STATUS_EOM_OVERFLOW 0xC0000000 | 0x0177 -+#define NT_STATUS_NO_MEDIA 0xC0000000 | 0x0178 -+#define NT_STATUS_NO_SUCH_MEMBER 0xC0000000 | 0x017a -+#define NT_STATUS_INVALID_MEMBER 0xC0000000 | 0x017b -+#define NT_STATUS_KEY_DELETED 0xC0000000 | 0x017c -+#define NT_STATUS_NO_LOG_SPACE 0xC0000000 | 0x017d -+#define NT_STATUS_TOO_MANY_SIDS 0xC0000000 | 0x017e -+#define NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED 0xC0000000 | 0x017f -+#define NT_STATUS_KEY_HAS_CHILDREN 0xC0000000 | 0x0180 -+#define NT_STATUS_CHILD_MUST_BE_VOLATILE 0xC0000000 | 0x0181 -+#define NT_STATUS_DEVICE_CONFIGURATION_ERROR 0xC0000000 | 0x0182 -+#define NT_STATUS_DRIVER_INTERNAL_ERROR 0xC0000000 | 0x0183 -+#define NT_STATUS_INVALID_DEVICE_STATE 0xC0000000 | 0x0184 -+#define NT_STATUS_IO_DEVICE_ERROR 0xC0000000 | 0x0185 -+#define NT_STATUS_DEVICE_PROTOCOL_ERROR 0xC0000000 | 0x0186 -+#define NT_STATUS_BACKUP_CONTROLLER 0xC0000000 | 0x0187 -+#define NT_STATUS_LOG_FILE_FULL 0xC0000000 | 0x0188 -+#define NT_STATUS_TOO_LATE 0xC0000000 | 0x0189 -+#define NT_STATUS_NO_TRUST_LSA_SECRET 0xC0000000 | 0x018a -+#define NT_STATUS_NO_TRUST_SAM_ACCOUNT 0xC0000000 | 0x018b -+#define NT_STATUS_TRUSTED_DOMAIN_FAILURE 0xC0000000 | 0x018c -+#define NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE 0xC0000000 | 0x018d -+#define NT_STATUS_EVENTLOG_FILE_CORRUPT 0xC0000000 | 0x018e -+#define NT_STATUS_EVENTLOG_CANT_START 0xC0000000 | 0x018f -+#define NT_STATUS_TRUST_FAILURE 0xC0000000 | 0x0190 -+#define NT_STATUS_MUTANT_LIMIT_EXCEEDED 0xC0000000 | 0x0191 -+#define NT_STATUS_NETLOGON_NOT_STARTED 0xC0000000 | 0x0192 -+#define NT_STATUS_ACCOUNT_EXPIRED 0xC0000000 | 0x0193 -+#define NT_STATUS_POSSIBLE_DEADLOCK 0xC0000000 | 0x0194 -+#define NT_STATUS_NETWORK_CREDENTIAL_CONFLICT 0xC0000000 | 0x0195 -+#define NT_STATUS_REMOTE_SESSION_LIMIT 0xC0000000 | 0x0196 -+#define NT_STATUS_EVENTLOG_FILE_CHANGED 0xC0000000 | 0x0197 -+#define NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT 0xC0000000 | 0x0198 -+#define NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT 0xC0000000 | 0x0199 -+#define NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT 0xC0000000 | 0x019a -+#define NT_STATUS_DOMAIN_TRUST_INCONSISTENT 0xC0000000 | 0x019b -+#define NT_STATUS_FS_DRIVER_REQUIRED 0xC0000000 | 0x019c -+#define NT_STATUS_NO_USER_SESSION_KEY 0xC0000000 | 0x0202 -+#define NT_STATUS_USER_SESSION_DELETED 0xC0000000 | 0x0203 -+#define NT_STATUS_RESOURCE_LANG_NOT_FOUND 0xC0000000 | 0x0204 -+#define NT_STATUS_INSUFF_SERVER_RESOURCES 0xC0000000 | 0x0205 -+#define NT_STATUS_INVALID_BUFFER_SIZE 0xC0000000 | 0x0206 -+#define NT_STATUS_INVALID_ADDRESS_COMPONENT 0xC0000000 | 0x0207 -+#define NT_STATUS_INVALID_ADDRESS_WILDCARD 0xC0000000 | 0x0208 -+#define NT_STATUS_TOO_MANY_ADDRESSES 0xC0000000 | 0x0209 -+#define NT_STATUS_ADDRESS_ALREADY_EXISTS 0xC0000000 | 0x020a -+#define NT_STATUS_ADDRESS_CLOSED 0xC0000000 | 0x020b -+#define NT_STATUS_CONNECTION_DISCONNECTED 0xC0000000 | 0x020c -+#define NT_STATUS_CONNECTION_RESET 0xC0000000 | 0x020d -+#define NT_STATUS_TOO_MANY_NODES 0xC0000000 | 0x020e -+#define NT_STATUS_TRANSACTION_ABORTED 0xC0000000 | 0x020f -+#define NT_STATUS_TRANSACTION_TIMED_OUT 0xC0000000 | 0x0210 -+#define NT_STATUS_TRANSACTION_NO_RELEASE 0xC0000000 | 0x0211 -+#define NT_STATUS_TRANSACTION_NO_MATCH 0xC0000000 | 0x0212 -+#define NT_STATUS_TRANSACTION_RESPONDED 0xC0000000 | 0x0213 -+#define NT_STATUS_TRANSACTION_INVALID_ID 0xC0000000 | 0x0214 -+#define NT_STATUS_TRANSACTION_INVALID_TYPE 0xC0000000 | 0x0215 -+#define NT_STATUS_NOT_SERVER_SESSION 0xC0000000 | 0x0216 -+#define NT_STATUS_NOT_CLIENT_SESSION 0xC0000000 | 0x0217 -+#define NT_STATUS_CANNOT_LOAD_REGISTRY_FILE 0xC0000000 | 0x0218 -+#define NT_STATUS_DEBUG_ATTACH_FAILED 0xC0000000 | 0x0219 -+#define NT_STATUS_SYSTEM_PROCESS_TERMINATED 0xC0000000 | 0x021a -+#define NT_STATUS_DATA_NOT_ACCEPTED 0xC0000000 | 0x021b -+#define NT_STATUS_NO_BROWSER_SERVERS_FOUND 0xC0000000 | 0x021c -+#define NT_STATUS_VDM_HARD_ERROR 0xC0000000 | 0x021d -+#define NT_STATUS_DRIVER_CANCEL_TIMEOUT 0xC0000000 | 0x021e -+#define NT_STATUS_REPLY_MESSAGE_MISMATCH 0xC0000000 | 0x021f -+#define NT_STATUS_MAPPED_ALIGNMENT 0xC0000000 | 0x0220 -+#define NT_STATUS_IMAGE_CHECKSUM_MISMATCH 0xC0000000 | 0x0221 -+#define NT_STATUS_LOST_WRITEBEHIND_DATA 0xC0000000 | 0x0222 -+#define NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID 0xC0000000 | 0x0223 -+#define NT_STATUS_PASSWORD_MUST_CHANGE 0xC0000000 | 0x0224 -+#define NT_STATUS_NOT_FOUND 0xC0000000 | 0x0225 -+#define NT_STATUS_NOT_TINY_STREAM 0xC0000000 | 0x0226 -+#define NT_STATUS_RECOVERY_FAILURE 0xC0000000 | 0x0227 -+#define NT_STATUS_STACK_OVERFLOW_READ 0xC0000000 | 0x0228 -+#define NT_STATUS_FAIL_CHECK 0xC0000000 | 0x0229 -+#define NT_STATUS_DUPLICATE_OBJECTID 0xC0000000 | 0x022a -+#define NT_STATUS_OBJECTID_EXISTS 0xC0000000 | 0x022b -+#define NT_STATUS_CONVERT_TO_LARGE 0xC0000000 | 0x022c -+#define NT_STATUS_RETRY 0xC0000000 | 0x022d -+#define NT_STATUS_FOUND_OUT_OF_SCOPE 0xC0000000 | 0x022e -+#define NT_STATUS_ALLOCATE_BUCKET 0xC0000000 | 0x022f -+#define NT_STATUS_PROPSET_NOT_FOUND 0xC0000000 | 0x0230 -+#define NT_STATUS_MARSHALL_OVERFLOW 0xC0000000 | 0x0231 -+#define NT_STATUS_INVALID_VARIANT 0xC0000000 | 0x0232 -+#define NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND 0xC0000000 | 0x0233 -+#define NT_STATUS_ACCOUNT_LOCKED_OUT 0xC0000000 | 0x0234 -+#define NT_STATUS_HANDLE_NOT_CLOSABLE 0xC0000000 | 0x0235 -+#define NT_STATUS_CONNECTION_REFUSED 0xC0000000 | 0x0236 -+#define NT_STATUS_GRACEFUL_DISCONNECT 0xC0000000 | 0x0237 -+#define NT_STATUS_ADDRESS_ALREADY_ASSOCIATED 0xC0000000 | 0x0238 -+#define NT_STATUS_ADDRESS_NOT_ASSOCIATED 0xC0000000 | 0x0239 -+#define NT_STATUS_CONNECTION_INVALID 0xC0000000 | 0x023a -+#define NT_STATUS_CONNECTION_ACTIVE 0xC0000000 | 0x023b -+#define NT_STATUS_NETWORK_UNREACHABLE 0xC0000000 | 0x023c -+#define NT_STATUS_HOST_UNREACHABLE 0xC0000000 | 0x023d -+#define NT_STATUS_PROTOCOL_UNREACHABLE 0xC0000000 | 0x023e -+#define NT_STATUS_PORT_UNREACHABLE 0xC0000000 | 0x023f -+#define NT_STATUS_REQUEST_ABORTED 0xC0000000 | 0x0240 -+#define NT_STATUS_CONNECTION_ABORTED 0xC0000000 | 0x0241 -+#define NT_STATUS_BAD_COMPRESSION_BUFFER 0xC0000000 | 0x0242 -+#define NT_STATUS_USER_MAPPED_FILE 0xC0000000 | 0x0243 -+#define NT_STATUS_AUDIT_FAILED 0xC0000000 | 0x0244 -+#define NT_STATUS_TIMER_RESOLUTION_NOT_SET 0xC0000000 | 0x0245 -+#define NT_STATUS_CONNECTION_COUNT_LIMIT 0xC0000000 | 0x0246 -+#define NT_STATUS_LOGIN_TIME_RESTRICTION 0xC0000000 | 0x0247 -+#define NT_STATUS_LOGIN_WKSTA_RESTRICTION 0xC0000000 | 0x0248 -+#define NT_STATUS_IMAGE_MP_UP_MISMATCH 0xC0000000 | 0x0249 -+#define NT_STATUS_INSUFFICIENT_LOGON_INFO 0xC0000000 | 0x0250 -+#define NT_STATUS_BAD_DLL_ENTRYPOINT 0xC0000000 | 0x0251 -+#define NT_STATUS_BAD_SERVICE_ENTRYPOINT 0xC0000000 | 0x0252 -+#define NT_STATUS_LPC_REPLY_LOST 0xC0000000 | 0x0253 -+#define NT_STATUS_IP_ADDRESS_CONFLICT1 0xC0000000 | 0x0254 -+#define NT_STATUS_IP_ADDRESS_CONFLICT2 0xC0000000 | 0x0255 -+#define NT_STATUS_REGISTRY_QUOTA_LIMIT 0xC0000000 | 0x0256 -+#define NT_STATUS_PATH_NOT_COVERED 0xC0000000 | 0x0257 -+#define NT_STATUS_NO_CALLBACK_ACTIVE 0xC0000000 | 0x0258 -+#define NT_STATUS_LICENSE_QUOTA_EXCEEDED 0xC0000000 | 0x0259 -+#define NT_STATUS_PWD_TOO_SHORT 0xC0000000 | 0x025a -+#define NT_STATUS_PWD_TOO_RECENT 0xC0000000 | 0x025b -+#define NT_STATUS_PWD_HISTORY_CONFLICT 0xC0000000 | 0x025c -+#define NT_STATUS_PLUGPLAY_NO_DEVICE 0xC0000000 | 0x025e -+#define NT_STATUS_UNSUPPORTED_COMPRESSION 0xC0000000 | 0x025f -+#define NT_STATUS_INVALID_HW_PROFILE 0xC0000000 | 0x0260 -+#define NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH 0xC0000000 | 0x0261 -+#define NT_STATUS_DRIVER_ORDINAL_NOT_FOUND 0xC0000000 | 0x0262 -+#define NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND 0xC0000000 | 0x0263 -+#define NT_STATUS_RESOURCE_NOT_OWNED 0xC0000000 | 0x0264 -+#define NT_STATUS_TOO_MANY_LINKS 0xC0000000 | 0x0265 -+#define NT_STATUS_QUOTA_LIST_INCONSISTENT 0xC0000000 | 0x0266 -+#define NT_STATUS_FILE_IS_OFFLINE 0xC0000000 | 0x0267 -+#define NT_STATUS_NO_SUCH_JOB 0xC0000000 | 0xEDE /* scheduler */ -+ -+#endif /* _NTERR_H */ ---- /dev/null -+++ b/fs/cifs/ntlmssp.h -@@ -0,0 +1,101 @@ -+/* -+ * fs/cifs/ntlmssp.h -+ * -+ * Copyright (c) International Business Machines Corp., 2002 -+ * Author(s): Steve French (sfrench@us.ibm.com) -+ * -+ * This library is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU Lesser General Public License as published -+ * by the Free Software Foundation; either version 2.1 of the License, or -+ * (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -+ * the GNU Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public License -+ * along with this library; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ */ -+ -+#pragma pack(1) -+ -+#define NTLMSSP_SIGNATURE "NTLMSSP" -+/* Message Types */ -+#define NtLmNegotiate 1 -+#define NtLmChallenge 2 -+#define NtLmAuthenticate 3 -+#define UnknownMessage 8 -+ -+/* Negotiate Flags */ -+#define NTLMSSP_NEGOTIATE_UNICODE 0x01 // Text strings are in unicode -+#define NTLMSSP_NEGOTIATE_OEM 0x02 // Text strings are in OEM -+#define NTLMSSP_REQUEST_TARGET 0x04 // Server return its auth realm -+#define NTLMSSP_NEGOTIATE_SIGN 0x0010 // Request signature capability -+#define NTLMSSP_NEGOTIATE_SEAL 0x0020 // Request confidentiality -+#define NTLMSSP_NEGOTIATE_DGRAM 0x0040 -+#define NTLMSSP_NEGOTIATE_LM_KEY 0x0080 // Use LM session key for sign/seal -+#define NTLMSSP_NEGOTIATE_NTLM 0x0200 // NTLM authentication -+#define NTLMSSP_NEGOTIATE_DOMAIN_SUPPLIED 0x1000 -+#define NTLMSSP_NEGOTIATE_WORKSTATION_SUPPLIED 0x2000 -+#define NTLMSSP_NEGOTIATE_LOCAL_CALL 0x4000 // client/server on same machine -+#define NTLMSSP_NEGOTIATE_ALWAYS_SIGN 0x8000 // Sign for all security levels -+#define NTLMSSP_TARGET_TYPE_DOMAIN 0x10000 -+#define NTLMSSP_TARGET_TYPE_SERVER 0x20000 -+#define NTLMSSP_TARGET_TYPE_SHARE 0x40000 -+#define NTLMSSP_NEGOTIATE_NTLMV2 0x80000 -+#define NTLMSSP_REQUEST_INIT_RESP 0x100000 -+#define NTLMSSP_REQUEST_ACCEPT_RESP 0x200000 -+#define NTLMSSP_REQUEST_NOT_NT_KEY 0x400000 -+#define NTLMSSP_NEGOTIATE_TARGET_INFO 0x800000 -+#define NTLMSSP_NEGOTIATE_128 0x20000000 -+#define NTLMSSP_NEGOTIATE_KEY_XCH 0x40000000 -+#define NTLMSSP_NEGOTIATE_56 0x80000000 -+ -+/* Although typedefs are not commonly used for structure definitions */ -+/* in the Linux kernel, in this particular case they are useful */ -+/* to more closely match the standards document for NTLMSSP from */ -+/* OpenGroup and to make the code more closely match the standard in */ -+/* appearance */ -+ -+typedef struct _SECURITY_BUFFER { -+ __u16 Length; -+ __u16 MaximumLength; -+ __u32 Buffer; /* offset to buffer */ -+} SECURITY_BUFFER; -+ -+typedef struct _NEGOTIATE_MESSAGE { -+ __u8 Signature[sizeof (NTLMSSP_SIGNATURE)]; -+ __u32 MessageType; /* 1 */ -+ __u32 NegotiateFlags; -+ SECURITY_BUFFER DomainName; /* RFC 1001 style and ASCII */ -+ SECURITY_BUFFER WorkstationName; /* RFC 1001 and ASCII */ -+ char DomainString[0]; -+ /* followed by WorkstationString */ -+} NEGOTIATE_MESSAGE, *PNEGOTIATE_MESSAGE; -+ -+typedef struct _CHALLENGE_MESSAGE { -+ __u8 Signature[sizeof (NTLMSSP_SIGNATURE)]; -+ __u32 MessageType; /* 2 */ -+ SECURITY_BUFFER TargetName; -+ __u32 NegotiateFlags; -+ __u8 Challenge[CIFS_CRYPTO_KEY_SIZE]; -+ __u8 Reserved[8]; -+ SECURITY_BUFFER TargetInfoArray; -+} CHALLENGE_MESSAGE, *PCHALLENGE_MESSAGE; -+ -+typedef struct _AUTHENTICATE_MESSAGE { -+ __u8 Signature[sizeof (NTLMSSP_SIGNATURE)]; -+ __u32 MessageType; /* 3 */ -+ SECURITY_BUFFER LmChallengeResponse; -+ SECURITY_BUFFER NtChallengeResponse; -+ SECURITY_BUFFER DomainName; -+ SECURITY_BUFFER UserName; -+ SECURITY_BUFFER WorkstationName; -+ SECURITY_BUFFER SessionKey; -+ __u32 NegotiateFlags; -+ char UserString[0]; -+} AUTHENTICATE_MESSAGE, *PAUTHENTICATE_MESSAGE; -+ -+#pragma pack() /* resume default structure packing */ ---- /dev/null -+++ b/fs/cifs/README -@@ -0,0 +1,356 @@ -+The CIFS VFS support for Linux supports many advanced network filesystem -+features such as heirarchical dfs like namespace, hardlinks, locking and more. -+It was designed to comply with the SNIA CIFS Technical Reference (which -+supersedes the 1992 X/Open SMB Standard) as well as to perform best practice -+practical interoperability with Windows 2000, Windows XP, Samba and equivalent -+servers. -+ -+For questions or bug reports please contact: -+ sfrench@samba.org (sfrench@us.ibm.com) -+ -+Build instructions: -+================== -+For Linux 2.4: -+1) Get the kernel source (e.g.from http://www.kernel.org) -+and download the cifs vfs source (see the project page -+at http://us1.samba.org/samba/Linux_CIFS_client.html) -+and change directory into the top of the kernel directory -+then patch the kernel (e.g. "patch -p1 < cifs_24.patch") -+to add the cifs vfs to your kernel configure options if -+it has not already been added (e.g. current SuSE and UL -+users do not need to apply the cifs_24.patch since the cifs vfs is -+already in the kernel configure menu) and then -+mkdir linux/fs/cifs and then copy the current cifs vfs files from -+the cifs download to your kernel build directory e.g. -+ -+ cp <cifs_download_dir>/fs/cifs/* to <kernel_download_dir>/fs/cifs -+ -+2) make menuconfig (or make xconfig) -+3) select cifs from within the network filesystem choices -+4) save and exit -+5) make dep -+6) make modules (or "make" if CIFS VFS not to be built as a module) -+ -+For Linux 2.5: -+1) Download the kernel (e.g. from http://www.kernel.org or from bitkeeper -+at bk://linux.bkbits.net/linux-2.5) and change directory into the top -+of the kernel directory tree (e.g. /usr/src/linux-2.5.73) -+2) make menuconfig (or make xconfig) -+3) select cifs from within the network filesystem choices -+4) save and exit -+5) make -+ -+ -+Installation instructions: -+========================= -+If you have built the CIFS vfs as module (successfully) simply -+type "make modules_install" (or if you prefer, manually copy the file to -+the modules directory e.g. /lib/modules/2.4.10-4GB/kernel/fs/cifs/cifs.o). -+ -+If you have built the CIFS vfs into the kernel itself, follow the instructions -+for your distribution on how to install a new kernel (usually you -+would simply type "make install"). -+ -+If you do not have the utility mount.cifs (in the Samba 3.0 source tree and on -+the CIFS VFS web site) copy it to the same directory in which mount.smbfs and -+similar files reside (usually /sbin). Although the helper software is not -+required, mount.cifs is recommended. Eventually the Samba 3.0 utility program -+"net" may also be helpful since it may someday provide easier mount syntax for -+users who are used to Windows e.g. net use <mount point> <UNC name or cifs URL> -+Note that running the Winbind pam/nss module (logon service) on all of your -+Linux clients is useful in mapping Uids and Gids consistently across the -+domain to the proper network user. The mount.cifs mount helper can be -+trivially built from Samba 3.0 or later source e.g. by executing: -+ -+ gcc samba/source/client/mount.cifs.c -o mount.cifs -+ -+Note that when the mount.cifs utility is run suid (allowing user mounts), -+in order to reduce risks, the "nosuid" mount flag is passed in on mount to -+disallow execution of an suid program mounted on the remote target. -+When mount is executed as root, nosuid is not passed in by default, -+and execution of suid programs on the remote target would be enabled -+by default. This can be changed, as with nfs and other filesystems, -+by simply specifying "nosuid" among the mount options. For user mounts -+though to be able to pass the suid flag to mount requires rebuilding -+mount.cifs with the following flag: -+ -+ gcc samba/source/client/mount.cifs.c -DCIFS_ALLOW_USR_SUID -o mount.cifs -+ -+There is a corresponding manual page for cifs mounting in the Samba 3.0 and -+later source tree in docs/manpages/mount.cifs.8 -+ -+Samba Considerations -+==================== -+To get the maximum benefit from the CIFS VFS, we recommend using a server that -+supports the SNIA CIFS Unix Extensions standard (e.g. Samba 2.2.5 or later or -+Samba 3.0) but the CIFS vfs works fine with a wide variety of CIFS servers. -+Note that uid, gid and file permissions will display default values if you do -+not have a server that supports the Unix extensions for CIFS (such as Samba -+2.2.5 or later). To enable the Unix CIFS Extensions in the Samba server, add -+the line: -+ -+ unix extensions = yes -+ -+to your smb.conf file on the server. Note that the following smb.conf settings -+are also useful (on the Samba server) when the majority of clients are Unix or -+Linux: -+ -+ case sensitive = yes -+ delete readonly = yes -+ ea support = yes -+ -+Note that ea support is required for supporting Linux xattrs. -+Some administrators also change the "map archive" and the "create mask" -+parameters from their default values. Creating special devices (mknod) -+remotely may require specifying a mkdev function to Samba if you are not using -+Samba 3.0.5 or later. For more information on these see the manual pages -+("man smb.conf") on the Samba server system. Note that the cifs vfs, -+unlike the smbfs vfs, does not read the smb.conf on the client system -+(the few optional settings are passed in on mount via -o parameters instead). -+Note that Samba 2.2.7 or later includes a fix that allows the CIFS VFS to delete -+open files (required for strict POSIX compliance). Windows Servers already -+supported this feature. Samba server does not allow symlinks that refer to files -+outside of the share, so in Samba versions prior to 3.0.5, most symlinks to -+files with absolute paths (ie beginning with slash) such as: -+ ln -s /mnt/foo bar -+would be forbidden. Samba 3.0.5 server or later includes the ability to create -+such symlinks safely by converting unsafe symlinks (ie symlinks to server -+files that are outside of the share) to a samba specific format on the server -+that is ignored by local server applications and non-cifs clients and that will -+not be traversed by the Samba server). This is opaque to the Linux client -+application using the cifs vfs. Absolute symlinks will work to Samba 3.0.5 or -+later, but only for remote clients using the CIFS Unix extensions, and will -+be invisbile to Windows clients and typically will not affect local -+applications running on the same server as Samba. -+ -+Use instructions: -+================ -+Once the CIFS VFS support is built into the kernel or installed as a module -+(cifs.o), you can use mount syntax like the following to access Samba or Windows -+servers: -+ -+ mount -t cifs //9.53.216.11/e$ /mnt -o user=myname,pass=mypassword -+ -+Before -o the option -v may be specified to make the mount.cifs -+mount helper display the mount steps more verbosely. -+After -o the following commonly used cifs vfs specific options -+are supported: -+ -+ user=<username> -+ pass=<password> -+ domain=<domain name> -+ -+Other cifs mount options are described below. Use of TCP names (in addition to -+ip addresses) is available if the mount helper (mount.cifs) is installed. If -+you do not trust the server to which are mounted, or if you do not have -+cifs signing enabled (and the physical network is insecure), consider use -+of the standard mount options "noexec" and "nosuid" to reduce the risk of -+running an altered binary on your local system (downloaded from a hostile server -+or altered by a hostile router). -+ -+When using the mount helper mount.cifs, passwords may be specified via alternate -+mechanisms, instead of specifying it after -o using the normal "pass=" syntax -+on the command line: -+1) By including it in a credential file. Specify credentials=filename as one -+of the mount options. Credential files contain two lines -+ username=someuser -+ password=your_password -+2) By specifying the password in the PASSWD environment variable (similarly -+the user name can be taken from the USER environment variable). -+3) By specifying the password in a file by name via PASSWD_FILE -+4) By specifying the password in a file by file descriptor via PASSWD_FD -+ -+If no password is provided, mount.cifs will prompt for password entry -+ -+Restrictions -+============ -+Servers must support the NTLM SMB dialect (which is the most recent, supported -+by Samba and Windows NT version 4, 2000 and XP and many other SMB/CIFS servers) -+Servers must support either "pure-TCP" (port 445 TCP/IP CIFS connections) or RFC -+1001/1002 support for "Netbios-Over-TCP/IP." Neither of these is likely to be a -+problem as most servers support this. IPv6 support is planned for the future. -+ -+CIFS VFS Mount Options -+====================== -+A partial list of the supported mount options follows: -+ user The user name to use when trying to establish -+ the CIFS session. -+ password The user password. If the mount helper is -+ installed, the user will be prompted for password -+ if it is not supplied. -+ ip The ip address of the target server -+ unc The target server Universal Network Name (export) to -+ mount. -+ domain Set the SMB/CIFS workgroup name prepended to the -+ username during CIFS session establishment -+ uid If CIFS Unix extensions are not supported by the server -+ this overrides the default uid for inodes. For mounts to -+ servers which do support the CIFS Unix extensions, such -+ as a properly configured Samba server, the server provides -+ the uid, gid and mode. For servers which do not support -+ the Unix extensions, the default uid (and gid) returned on -+ lookup of existing files is the uid (gid) of the person -+ who executed the mount (root, except when mount.cifs -+ is configured setuid for user mounts) unless the "uid=" -+ (gid) mount option is specified. For the uid (gid) of newly -+ created files and directories, ie files created since -+ the last mount of the server share, the expected uid -+ (gid) is cached as as long as the inode remains in -+ memory on the client. Also note that permission -+ checks (authorization checks) on accesses to a file occur -+ at the server, but there are cases in which an administrator -+ may want to restrict at the client as well. For those -+ servers which do not report a uid/gid owner -+ (such as Windows), permissions can also be checked at the -+ client, and a crude form of client side permission checking -+ can be enabled by specifying file_mode and dir_mode on -+ the client -+ gid If CIFS Unix extensions are not supported by the server -+ this overrides the default gid for inodes. -+ file_mode If CIFS Unix extensions are not supported by the server -+ this overrides the default mode for file inodes. -+ dir_mode If CIFS Unix extensions are not supported by the server -+ this overrides the default mode for directory inodes. -+ port attempt to contact the server on this tcp port, before -+ trying the usual ports (port 445, then 139). -+ iocharset Codepage used to convert local path names to and from -+ Unicode. Unicode is used by default for network path -+ names if the server supports it. If iocharset is -+ not specified then the nls_default specified -+ during the local client kernel build will be used. -+ If server does not support Unicode, this parameter is -+ unused. -+ rsize default read size -+ wsize default write size -+ rw mount the network share read-write (note that the -+ server may still consider the share read-only) -+ ro mount network share read-only -+ version used to distinguish different versions of the -+ mount helper utility (not typically needed) -+ sep if first mount option (after the -o), overrides -+ the comma as the separator between the mount -+ parms. e.g. -+ -o user=myname,password=mypassword,domain=mydom -+ could be passed instead with period as the separator by -+ -o sep=.user=myname.password=mypassword.domain=mydom -+ this might be useful when comma is contained within username -+ or password or domain. This option is less important -+ when the cifs mount helper cifs.mount (version 1.1 or later) -+ is used. -+ nosuid Do not allow remote executables with the suid bit -+ program to be executed. This is only meaningful for mounts -+ to servers such as Samba which support the CIFS Unix Extensions. -+ If you do not trust the servers in your network (your mount -+ targets) it is recommended that you specify this option for -+ greater security. -+ suid Allow remote files on this mountpoint with suid enabled to -+ be executed (default for mounts when executed as root, -+ nosuid is default for user mounts). -+ credentials Although ignored by the cifs kernel component, it is used by -+ the mount helper, mount.cifs. When mount.cifs is installed it -+ opens and reads the credential file specified in order -+ to obtain the userid and password arguments which are passed to -+ the cifs vfs. -+ guest Although ignored by the kernel component, the mount.cifs -+ mount helper will not prompt the user for a password -+ if guest is specified on the mount options. If no -+ password is specified a null password will be used. -+ -+The mount.cifs mount helper also accepts a few mount options before -o -+including: -+ -+ -S take password from stdin (equivalent to setting the environment -+ variable "PASSWD_FD=0" -+ -V print mount.cifs version -+ -? display simple usage information -+ -+With recent 2.6 kernel versions of modutils, the version of the cifs kernel -+module can be displayed via modinfo. -+ -+Misc /proc/fs/cifs Flags and Debug Info -+======================================= -+Informational pseudo-files: -+DebugData Displays information about active CIFS sessions -+ and shares. -+Stats Lists summary resource usage information as well as per -+ share statistics, if CONFIG_CIFS_STATS in enabled -+ in the kernel configuration. -+ -+Configuration pseudo-files: -+MultiuserMount If set to one, more than one CIFS session to -+ the same server ip address can be established -+ if more than one uid accesses the same mount -+ point and if the uids user/password mapping -+ information is available. (default is 0) -+PacketSigningEnabled If set to one, cifs packet signing is enabled -+ and will be used if the server requires -+ it. If set to two, cifs packet signing is -+ required even if the server considers packet -+ signing optional. (default 1) -+cifsFYI If set to one, additional debug information is -+ logged to the system error log. (default 0) -+ExtendedSecurity If set to one, SPNEGO session establishment -+ is allowed which enables more advanced -+ secure CIFS session establishment (default 0) -+NTLMV2Enabled If set to one, more secure password hashes -+ are used when the server supports them and -+ when kerberos is not negotiated (default 0) -+traceSMB If set to one, debug information is logged to the -+ system error log with the start of smb requests -+ and responses (default 0) -+LookupCacheEnable If set to one, inode information is kept cached -+ for one second improving performance of lookups -+ (default 1) -+OplockEnabled If set to one, safe distributed caching enabled. -+ (default 1) -+LinuxExtensionsEnabled If set to one then the client will attempt to -+ use the CIFS "UNIX" extensions which are optional -+ protocol enhancements that allow CIFS servers -+ to return accurate UID/GID information as well -+ as support symbolic links. If you use servers -+ such as Samba that support the CIFS Unix -+ extensions but do not want to use symbolic link -+ support and want to map the uid and gid fields -+ to values supplied at mount (rather than the -+ actual values, then set this to zero. (default 1) -+ -+These experimental features and tracing can be enabled by changing flags in -+/proc/fs/cifs (after the cifs module has been installed or built into the -+kernel, e.g. insmod cifs). To enable a feature set it to 1 e.g. to enable -+tracing to the kernel message log type: -+ -+ echo 1 > /proc/fs/cifs/cifsFYI -+ -+and for more extensive tracing including the start of smb requests and responses -+ -+ echo 1 > /proc/fs/cifs/traceSMB -+ -+Three other experimental features are under development and to test -+require enabling an ifdef (e.g. by adding "#define CIFS_FCNTL" in cifsglob.h) -+ -+ CONFIG_CIFS_QUOTA -+ -+ CONFIG_CIFS_XATTR -+ -+ CONFIG_CIFS_FCNTL (fcntl needed for support of directory change -+ notification and perhaps later for file leases) -+ -+Per share (per client mount) statistics are available in /proc/fs/cifs/DebugData -+if the kernel was configured with cifs statistics enabled. The statistics -+represent the number of successful (ie non-zero return code from the server) -+SMB responses to some of the more common commands (open, delete, mkdir etc.). -+Also recorded is the total bytes read and bytes written to the server for -+that share. Note that due to client caching effects this can be less than the -+number of bytes read and written by the application running on the client. -+The statistics for the number of total SMBs and oplock breaks are different in -+that they represent all for that share, not just those for which the server -+returned success. -+ -+Also note that "cat /proc/fs/cifs/DebugData" will display information about -+the active sessions and the shares that are mounted. Note: NTLMv2 enablement -+will not work since they its implementation is not quite complete yet. -+Do not alter these configuration values unless you are doing specific testing. -+Enabling extended security works to Windows 2000 Workstations and XP but not to -+Windows 2000 server or Samba since it does not usually send "raw NTLMSSP" -+(instead it sends NTLMSSP encapsulated in SPNEGO/GSSAPI, which support is not -+complete in the CIFS VFS yet). ---- /dev/null -+++ b/fs/cifs/rfc1002pdu.h -@@ -0,0 +1,79 @@ -+/* -+ * fs/cifs/rfc1002pdu.h -+ * -+ * Protocol Data Unit definitions for RFC 1001/1002 support -+ * -+ * Copyright (c) International Business Machines Corp., 2004 -+ * Author(s): Steve French (sfrench@us.ibm.com) -+ * -+ * This library is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU Lesser General Public License as published -+ * by the Free Software Foundation; either version 2.1 of the License, or -+ * (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -+ * the GNU Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public License -+ * along with this library; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ */ -+ -+#pragma pack(1) -+ -+/* NB: unlike smb/cifs packets, the RFC1002 structures are big endian */ -+ -+ /* RFC 1002 session packet types */ -+#define RFC1002_SESSION_MESASAGE 0x00 -+#define RFC1002_SESSION_REQUEST 0x81 -+#define RFC1002_POSITIVE_SESSION_RESPONSE 0x82 -+#define RFC1002_NEGATIVE_SESSION_RESPONSE 0x83 -+#define RFC1002_RETARGET_SESSION_RESPONSE 0x83 -+#define RFC1002_SESSION_KEEP_ALIVE 0x85 -+ -+ /* RFC 1002 flags (only one defined */ -+#define RFC1002_LENGTH_EXTEND 0x80 /* high order bit of length (ie +64K) */ -+ -+struct rfc1002_session_packet { -+ __u8 type; -+ __u8 flags; -+ __u16 length; -+ union { -+ struct { -+ __u8 called_len; -+ __u8 called_name[32]; -+ __u8 scope1; /* null */ -+ __u8 calling_len; -+ __u8 calling_name[32]; -+ __u8 scope2; /* null */ -+ } session_req; -+ struct { -+ __u32 retarget_ip_addr; -+ __u16 port; -+ } retarget_resp; -+ __u8 neg_ses_resp_error_code; -+ /* POSITIVE_SESSION_RESPONSE packet does not include trailer. -+ SESSION_KEEP_ALIVE packet also does not include a trailer. -+ Trailer for the SESSION_MESSAGE packet is SMB/CIFS header */ -+ } trailer; -+}; -+ -+/* Negative Session Response error codes */ -+#define RFC1002_NOT_LISTENING_CALLED 0x80 /* not listening on called name */ -+#define RFC1002_NOT_LISTENING_CALLING 0x81 /* not listening on calling name */ -+#define RFC1002_NOT_PRESENT 0x82 /* called name not present */ -+#define RFC1002_INSUFFICIENT_RESOURCE 0x83 -+#define RFC1002_UNSPECIFIED_ERROR 0x8F -+ -+/* RFC 1002 Datagram service packets are not defined here as they -+are not needed for the network filesystem client unless we plan on -+implementing broadcast resolution of the server ip address (from -+server netbios name). Currently server names are resolved only via DNS -+(tcp name) or ip address or an /etc/hosts equivalent mapping to ip address.*/ -+ -+#define DEFAULT_CIFS_CALLED_NAME "*SMBSERVER " -+ -+#pragma pack() /* resume default structure packing */ -+ ---- /dev/null -+++ b/fs/cifs/smbdes.c -@@ -0,0 +1,408 @@ -+/* -+ Unix SMB/Netbios implementation. -+ Version 1.9. -+ -+ a partial implementation of DES designed for use in the -+ SMB authentication protocol -+ -+ Copyright (C) Andrew Tridgell 1998 -+ Modified by Steve French (sfrench@us.ibm.com) 2002,2004 -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 2 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software -+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -+*/ -+ -+/* NOTES: -+ -+ This code makes no attempt to be fast! In fact, it is a very -+ slow implementation -+ -+ This code is NOT a complete DES implementation. It implements only -+ the minimum necessary for SMB authentication, as used by all SMB -+ products (including every copy of Microsoft Windows95 ever sold) -+ -+ In particular, it can only do a unchained forward DES pass. This -+ means it is not possible to use this code for encryption/decryption -+ of data, instead it is only useful as a "hash" algorithm. -+ -+ There is no entry point into this code that allows normal DES operation. -+ -+ I believe this means that this code does not come under ITAR -+ regulations but this is NOT a legal opinion. If you are concerned -+ about the applicability of ITAR regulations to this code then you -+ should confirm it for yourself (and maybe let me know if you come -+ up with a different answer to the one above) -+*/ -+#include <linux/slab.h> -+#define uchar unsigned char -+ -+static uchar perm1[56] = { 57, 49, 41, 33, 25, 17, 9, -+ 1, 58, 50, 42, 34, 26, 18, -+ 10, 2, 59, 51, 43, 35, 27, -+ 19, 11, 3, 60, 52, 44, 36, -+ 63, 55, 47, 39, 31, 23, 15, -+ 7, 62, 54, 46, 38, 30, 22, -+ 14, 6, 61, 53, 45, 37, 29, -+ 21, 13, 5, 28, 20, 12, 4 -+}; -+ -+static uchar perm2[48] = { 14, 17, 11, 24, 1, 5, -+ 3, 28, 15, 6, 21, 10, -+ 23, 19, 12, 4, 26, 8, -+ 16, 7, 27, 20, 13, 2, -+ 41, 52, 31, 37, 47, 55, -+ 30, 40, 51, 45, 33, 48, -+ 44, 49, 39, 56, 34, 53, -+ 46, 42, 50, 36, 29, 32 -+}; -+ -+static uchar perm3[64] = { 58, 50, 42, 34, 26, 18, 10, 2, -+ 60, 52, 44, 36, 28, 20, 12, 4, -+ 62, 54, 46, 38, 30, 22, 14, 6, -+ 64, 56, 48, 40, 32, 24, 16, 8, -+ 57, 49, 41, 33, 25, 17, 9, 1, -+ 59, 51, 43, 35, 27, 19, 11, 3, -+ 61, 53, 45, 37, 29, 21, 13, 5, -+ 63, 55, 47, 39, 31, 23, 15, 7 -+}; -+ -+static uchar perm4[48] = { 32, 1, 2, 3, 4, 5, -+ 4, 5, 6, 7, 8, 9, -+ 8, 9, 10, 11, 12, 13, -+ 12, 13, 14, 15, 16, 17, -+ 16, 17, 18, 19, 20, 21, -+ 20, 21, 22, 23, 24, 25, -+ 24, 25, 26, 27, 28, 29, -+ 28, 29, 30, 31, 32, 1 -+}; -+ -+static uchar perm5[32] = { 16, 7, 20, 21, -+ 29, 12, 28, 17, -+ 1, 15, 23, 26, -+ 5, 18, 31, 10, -+ 2, 8, 24, 14, -+ 32, 27, 3, 9, -+ 19, 13, 30, 6, -+ 22, 11, 4, 25 -+}; -+ -+static uchar perm6[64] = { 40, 8, 48, 16, 56, 24, 64, 32, -+ 39, 7, 47, 15, 55, 23, 63, 31, -+ 38, 6, 46, 14, 54, 22, 62, 30, -+ 37, 5, 45, 13, 53, 21, 61, 29, -+ 36, 4, 44, 12, 52, 20, 60, 28, -+ 35, 3, 43, 11, 51, 19, 59, 27, -+ 34, 2, 42, 10, 50, 18, 58, 26, -+ 33, 1, 41, 9, 49, 17, 57, 25 -+}; -+ -+static uchar sc[16] = { 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1 }; -+ -+static uchar sbox[8][4][16] = { -+ {{14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7}, -+ {0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8}, -+ {4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0}, -+ {15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13}}, -+ -+ {{15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10}, -+ {3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5}, -+ {0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15}, -+ {13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9}}, -+ -+ {{10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8}, -+ {13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1}, -+ {13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7}, -+ {1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12}}, -+ -+ {{7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15}, -+ {13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9}, -+ {10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4}, -+ {3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14}}, -+ -+ {{2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9}, -+ {14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6}, -+ {4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14}, -+ {11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3}}, -+ -+ {{12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11}, -+ {10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8}, -+ {9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6}, -+ {4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13}}, -+ -+ {{4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1}, -+ {13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6}, -+ {1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2}, -+ {6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12}}, -+ -+ {{13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7}, -+ {1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2}, -+ {7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8}, -+ {2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11}} -+}; -+ -+static void -+permute(char *out, char *in, uchar * p, int n) -+{ -+ int i; -+ for (i = 0; i < n; i++) -+ out[i] = in[p[i] - 1]; -+} -+ -+static void -+lshift(char *d, int count, int n) -+{ -+ char out[64]; -+ int i; -+ for (i = 0; i < n; i++) -+ out[i] = d[(i + count) % n]; -+ for (i = 0; i < n; i++) -+ d[i] = out[i]; -+} -+ -+static void -+concat(char *out, char *in1, char *in2, int l1, int l2) -+{ -+ while (l1--) -+ *out++ = *in1++; -+ while (l2--) -+ *out++ = *in2++; -+} -+ -+static void -+xor(char *out, char *in1, char *in2, int n) -+{ -+ int i; -+ for (i = 0; i < n; i++) -+ out[i] = in1[i] ^ in2[i]; -+} -+ -+static void -+dohash(char *out, char *in, char *key, int forw) -+{ -+ int i, j, k; -+ char *pk1; -+ char c[28]; -+ char d[28]; -+ char *cd; -+ char ki[16][48]; -+ char *pd1; -+ char l[32], r[32]; -+ char *rl; -+ -+ /* Have to reduce stack usage */ -+ pk1 = kmalloc(56+56+64+64,GFP_KERNEL); -+ if(pk1 == NULL) -+ return; -+ -+ cd = pk1 + 56; -+ pd1= cd + 56; -+ rl = pd1 + 64; -+ -+ permute(pk1, key, perm1, 56); -+ -+ for (i = 0; i < 28; i++) -+ c[i] = pk1[i]; -+ for (i = 0; i < 28; i++) -+ d[i] = pk1[i + 28]; -+ -+ for (i = 0; i < 16; i++) { -+ lshift(c, sc[i], 28); -+ lshift(d, sc[i], 28); -+ -+ concat(cd, c, d, 28, 28); -+ permute(ki[i], cd, perm2, 48); -+ } -+ -+ permute(pd1, in, perm3, 64); -+ -+ for (j = 0; j < 32; j++) { -+ l[j] = pd1[j]; -+ r[j] = pd1[j + 32]; -+ } -+ -+ for (i = 0; i < 16; i++) { -+ char *er; /* er[48] */ -+ char *erk; /* erk[48] */ -+ char b[8][6]; -+ char *cb; /* cb[32] */ -+ char *pcb; /* pcb[32] */ -+ char *r2; /* r2[32] */ -+ -+ er = kmalloc(48+48+32+32+32, GFP_KERNEL); -+ if(er == NULL) { -+ kfree(pk1); -+ return; -+ } -+ erk = er+48; -+ cb = erk+48; -+ pcb = cb+32; -+ r2 = pcb+32; -+ -+ permute(er, r, perm4, 48); -+ -+ xor(erk, er, ki[forw ? i : 15 - i], 48); -+ -+ for (j = 0; j < 8; j++) -+ for (k = 0; k < 6; k++) -+ b[j][k] = erk[j * 6 + k]; -+ -+ for (j = 0; j < 8; j++) { -+ int m, n; -+ m = (b[j][0] << 1) | b[j][5]; -+ -+ n = (b[j][1] << 3) | (b[j][2] << 2) | (b[j][3] << -+ 1) | b[j][4]; -+ -+ for (k = 0; k < 4; k++) -+ b[j][k] = -+ (sbox[j][m][n] & (1 << (3 - k))) ? 1 : 0; -+ } -+ -+ for (j = 0; j < 8; j++) -+ for (k = 0; k < 4; k++) -+ cb[j * 4 + k] = b[j][k]; -+ permute(pcb, cb, perm5, 32); -+ -+ xor(r2, l, pcb, 32); -+ -+ for (j = 0; j < 32; j++) -+ l[j] = r[j]; -+ -+ for (j = 0; j < 32; j++) -+ r[j] = r2[j]; -+ -+ kfree(er); -+ } -+ -+ concat(rl, r, l, 32, 32); -+ -+ permute(out, rl, perm6, 64); -+ kfree(pk1); -+} -+ -+static void -+str_to_key(unsigned char *str, unsigned char *key) -+{ -+ int i; -+ -+ key[0] = str[0] >> 1; -+ key[1] = ((str[0] & 0x01) << 6) | (str[1] >> 2); -+ key[2] = ((str[1] & 0x03) << 5) | (str[2] >> 3); -+ key[3] = ((str[2] & 0x07) << 4) | (str[3] >> 4); -+ key[4] = ((str[3] & 0x0F) << 3) | (str[4] >> 5); -+ key[5] = ((str[4] & 0x1F) << 2) | (str[5] >> 6); -+ key[6] = ((str[5] & 0x3F) << 1) | (str[6] >> 7); -+ key[7] = str[6] & 0x7F; -+ for (i = 0; i < 8; i++) { -+ key[i] = (key[i] << 1); -+ } -+} -+ -+static void -+smbhash(unsigned char *out, unsigned char *in, unsigned char *key, int forw) -+{ -+ int i; -+ char *outb; /* outb[64] */ -+ char *inb; /* inb[64] */ -+ char *keyb; /* keyb[64] */ -+ unsigned char key2[8]; -+ -+ outb = kmalloc(64 * 3,GFP_KERNEL); -+ if(outb == NULL) -+ return; -+ -+ inb = outb + 64; -+ keyb = inb + 64; -+ -+ str_to_key(key, key2); -+ -+ for (i = 0; i < 64; i++) { -+ inb[i] = (in[i / 8] & (1 << (7 - (i % 8)))) ? 1 : 0; -+ keyb[i] = (key2[i / 8] & (1 << (7 - (i % 8)))) ? 1 : 0; -+ outb[i] = 0; -+ } -+ -+ dohash(outb, inb, keyb, forw); -+ -+ for (i = 0; i < 8; i++) { -+ out[i] = 0; -+ } -+ -+ for (i = 0; i < 64; i++) { -+ if (outb[i]) -+ out[i / 8] |= (1 << (7 - (i % 8))); -+ } -+ kfree(outb); -+} -+ -+void -+E_P16(unsigned char *p14, unsigned char *p16) -+{ -+ unsigned char sp8[8] = -+ { 0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25 }; -+ smbhash(p16, sp8, p14, 1); -+ smbhash(p16 + 8, sp8, p14 + 7, 1); -+} -+ -+void -+E_P24(unsigned char *p21, unsigned char *c8, unsigned char *p24) -+{ -+ smbhash(p24, c8, p21, 1); -+ smbhash(p24 + 8, c8, p21 + 7, 1); -+ smbhash(p24 + 16, c8, p21 + 14, 1); -+} -+ -+void -+D_P16(unsigned char *p14, unsigned char *in, unsigned char *out) -+{ -+ smbhash(out, in, p14, 0); -+ smbhash(out + 8, in + 8, p14 + 7, 0); -+} -+ -+void -+E_old_pw_hash(unsigned char *p14, unsigned char *in, unsigned char *out) -+{ -+ smbhash(out, in, p14, 1); -+ smbhash(out + 8, in + 8, p14 + 7, 1); -+} -+ -+void -+cred_hash1(unsigned char *out, unsigned char *in, unsigned char *key) -+{ -+ unsigned char buf[8]; -+ -+ smbhash(buf, in, key, 1); -+ smbhash(out, buf, key + 9, 1); -+} -+ -+void -+cred_hash2(unsigned char *out, unsigned char *in, unsigned char *key) -+{ -+ unsigned char buf[8]; -+ static unsigned char key2[8]; -+ -+ smbhash(buf, in, key, 1); -+ key2[0] = key[7]; -+ smbhash(out, buf, key2, 1); -+} -+ -+void -+cred_hash3(unsigned char *out, unsigned char *in, unsigned char *key, int forw) -+{ -+ static unsigned char key2[8]; -+ -+ smbhash(out, in, key, forw); -+ key2[0] = key[7]; -+ smbhash(out + 8, in + 8, key2, forw); -+} ---- /dev/null -+++ b/fs/cifs/smbencrypt.c -@@ -0,0 +1,295 @@ -+/* -+ Unix SMB/Netbios implementation. -+ Version 1.9. -+ SMB parameters and setup -+ Copyright (C) Andrew Tridgell 1992-2000 -+ Copyright (C) Luke Kenneth Casson Leighton 1996-2000 -+ Modified by Jeremy Allison 1995. -+ Copyright (C) Andrew Bartlett <abartlet@samba.org> 2002-2003 -+ Modified by Steve French (sfrench@us.ibm.com) 2002-2003 -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 2 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software -+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -+*/ -+ -+#include <linux/module.h> -+#include <linux/fs.h> -+#include <linux/string.h> -+#include <linux/kernel.h> -+#include <linux/random.h> -+#include "cifs_unicode.h" -+#include "cifspdu.h" -+#include "md5.h" -+#include "cifs_debug.h" -+ -+#ifndef FALSE -+#define FALSE 0 -+#endif -+#ifndef TRUE -+#define TRUE 1 -+#endif -+ -+/* following came from the other byteorder.h to avoid include conflicts */ -+#define CVAL(buf,pos) (((unsigned char *)(buf))[pos]) -+#define SSVALX(buf,pos,val) (CVAL(buf,pos)=(val)&0xFF,CVAL(buf,pos+1)=(val)>>8) -+#define SSVAL(buf,pos,val) SSVALX((buf),(pos),((__u16)(val))) -+ -+/*The following definitions come from lib/md4.c */ -+ -+void mdfour(unsigned char *out, unsigned char *in, int n); -+ -+/*The following definitions come from libsmb/smbdes.c */ -+ -+void E_P16(unsigned char *p14, unsigned char *p16); -+void E_P24(unsigned char *p21, unsigned char *c8, unsigned char *p24); -+void D_P16(unsigned char *p14, unsigned char *in, unsigned char *out); -+void E_old_pw_hash(unsigned char *p14, unsigned char *in, unsigned char *out); -+void cred_hash1(unsigned char *out, unsigned char *in, unsigned char *key); -+void cred_hash2(unsigned char *out, unsigned char *in, unsigned char *key); -+void cred_hash3(unsigned char *out, unsigned char *in, unsigned char *key, -+ int forw); -+ -+/*The following definitions come from libsmb/smbencrypt.c */ -+ -+void SMBencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24); -+void E_md4hash(const unsigned char *passwd, unsigned char *p16); -+void nt_lm_owf_gen(char *pwd, unsigned char nt_p16[16], unsigned char p16[16]); -+void SMBOWFencrypt(unsigned char passwd[16], unsigned char *c8, -+ unsigned char p24[24]); -+void NTLMSSPOWFencrypt(unsigned char passwd[8], -+ unsigned char *ntlmchalresp, unsigned char p24[24]); -+void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24); -+int decode_pw_buffer(char in_buffer[516], char *new_pwrd, -+ int new_pwrd_size, __u32 * new_pw_len); -+ -+/* -+ This implements the X/Open SMB password encryption -+ It takes a password, a 8 byte "crypt key" and puts 24 bytes of -+ encrypted password into p24 */ -+/* Note that password must be uppercased and null terminated */ -+void -+SMBencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24) -+{ -+ unsigned char p14[15], p21[21]; -+ -+ memset(p21, '\0', 21); -+ memset(p14, '\0', 14); -+ strncpy((char *) p14, (char *) passwd, 14); -+ -+/* strupper((char *)p14); *//* BB at least uppercase the easy range */ -+ E_P16(p14, p21); -+ -+ SMBOWFencrypt(p21, c8, p24); -+ -+ memset(p14,0,15); -+ memset(p21,0,21); -+} -+ -+/* Routines for Windows NT MD4 Hash functions. */ -+static int -+_my_wcslen(__u16 * str) -+{ -+ int len = 0; -+ while (*str++ != 0) -+ len++; -+ return len; -+} -+ -+/* -+ * Convert a string into an NT UNICODE string. -+ * Note that regardless of processor type -+ * this must be in intel (little-endian) -+ * format. -+ */ -+ -+static int -+_my_mbstowcs(__u16 * dst, const unsigned char *src, int len) -+{ /* not a very good conversion routine - change/fix */ -+ int i; -+ __u16 val; -+ -+ for (i = 0; i < len; i++) { -+ val = *src; -+ SSVAL(dst, 0, val); -+ dst++; -+ src++; -+ if (val == 0) -+ break; -+ } -+ return i; -+} -+ -+/* -+ * Creates the MD4 Hash of the users password in NT UNICODE. -+ */ -+ -+void -+E_md4hash(const unsigned char *passwd, unsigned char *p16) -+{ -+ int len; -+ __u16 wpwd[129]; -+ -+ /* Password cannot be longer than 128 characters */ -+ if(passwd) { -+ len = strlen((char *) passwd); -+ if (len > 128) { -+ len = 128; -+ } -+ /* Password must be converted to NT unicode */ -+ _my_mbstowcs(wpwd, passwd, len); -+ } else -+ len = 0; -+ -+ wpwd[len] = 0; /* Ensure string is null terminated */ -+ /* Calculate length in bytes */ -+ len = _my_wcslen(wpwd) * sizeof (__u16); -+ -+ mdfour(p16, (unsigned char *) wpwd, len); -+ memset(wpwd,0,129 * 2); -+} -+ -+/* Does both the NT and LM owfs of a user's password */ -+void -+nt_lm_owf_gen(char *pwd, unsigned char nt_p16[16], unsigned char p16[16]) -+{ -+ char passwd[514]; -+ -+ memset(passwd, '\0', 514); -+ if (strlen(pwd) < 513) -+ strcpy(passwd, pwd); -+ else -+ memcpy(passwd, pwd, 512); -+ /* Calculate the MD4 hash (NT compatible) of the password */ -+ memset(nt_p16, '\0', 16); -+ E_md4hash(passwd, nt_p16); -+ -+ /* Mangle the passwords into Lanman format */ -+ passwd[14] = '\0'; -+/* strupper(passwd); */ -+ -+ /* Calculate the SMB (lanman) hash functions of the password */ -+ -+ memset(p16, '\0', 16); -+ E_P16((unsigned char *) passwd, (unsigned char *) p16); -+ -+ /* clear out local copy of user's password (just being paranoid). */ -+ memset(passwd, '\0', sizeof (passwd)); -+} -+ -+/* Does the NTLMv2 owfs of a user's password */ -+void -+ntv2_owf_gen(const unsigned char owf[16], const char *user_n, -+ const char *domain_n, unsigned char kr_buf[16], -+ const struct nls_table *nls_codepage) -+{ -+ wchar_t * user_u; -+ wchar_t * dom_u; -+ int user_l, domain_l; -+ struct HMACMD5Context ctx; -+ -+ /* might as well do one alloc to hold both (user_u and dom_u) */ -+ user_u = kmalloc(2048 * sizeof(wchar_t),GFP_KERNEL); -+ if(user_u == NULL) -+ return; -+ dom_u = user_u + 1024; -+ -+ /* push_ucs2(NULL, user_u, user_n, (user_l+1)*2, STR_UNICODE|STR_NOALIGN|STR_TERMINATE|STR_UPPER); -+ push_ucs2(NULL, dom_u, domain_n, (domain_l+1)*2, STR_UNICODE|STR_NOALIGN|STR_TERMINATE|STR_UPPER); */ -+ -+ /* BB user and domain may need to be uppercased */ -+ user_l = cifs_strtoUCS(user_u, user_n, 511, nls_codepage); -+ domain_l = cifs_strtoUCS(dom_u, domain_n, 511, nls_codepage); -+ -+ user_l++; /* trailing null */ -+ domain_l++; -+ -+ hmac_md5_init_limK_to_64(owf, 16, &ctx); -+ hmac_md5_update((const unsigned char *) user_u, user_l * 2, &ctx); -+ hmac_md5_update((const unsigned char *) dom_u, domain_l * 2, &ctx); -+ hmac_md5_final(kr_buf, &ctx); -+ -+ kfree(user_u); -+} -+ -+/* Does the des encryption from the NT or LM MD4 hash. */ -+void -+SMBOWFencrypt(unsigned char passwd[16], unsigned char *c8, -+ unsigned char p24[24]) -+{ -+ unsigned char p21[21]; -+ -+ memset(p21, '\0', 21); -+ -+ memcpy(p21, passwd, 16); -+ E_P24(p21, c8, p24); -+} -+ -+/* Does the des encryption from the FIRST 8 BYTES of the NT or LM MD4 hash. */ -+void -+NTLMSSPOWFencrypt(unsigned char passwd[8], -+ unsigned char *ntlmchalresp, unsigned char p24[24]) -+{ -+ unsigned char p21[21]; -+ -+ memset(p21, '\0', 21); -+ memcpy(p21, passwd, 8); -+ memset(p21 + 8, 0xbd, 8); -+ -+ E_P24(p21, ntlmchalresp, p24); -+} -+ -+/* Does the NT MD4 hash then des encryption. */ -+ -+void -+SMBNTencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24) -+{ -+ unsigned char p21[21]; -+ -+ memset(p21, '\0', 21); -+ -+ E_md4hash(passwd, p21); -+ SMBOWFencrypt(p21, c8, p24); -+} -+ -+/* Does the md5 encryption from the NT hash for NTLMv2. */ -+void -+SMBOWFencrypt_ntv2(const unsigned char kr[16], -+ const struct data_blob * srv_chal, -+ const struct data_blob * cli_chal, unsigned char resp_buf[16]) -+{ -+ struct HMACMD5Context ctx; -+ -+ hmac_md5_init_limK_to_64(kr, 16, &ctx); -+ hmac_md5_update(srv_chal->data, srv_chal->length, &ctx); -+ hmac_md5_update(cli_chal->data, cli_chal->length, &ctx); -+ hmac_md5_final(resp_buf, &ctx); -+} -+ -+void -+SMBsesskeygen_ntv2(const unsigned char kr[16], -+ const unsigned char *nt_resp, __u8 sess_key[16]) -+{ -+ struct HMACMD5Context ctx; -+ -+ hmac_md5_init_limK_to_64(kr, 16, &ctx); -+ hmac_md5_update(nt_resp, 16, &ctx); -+ hmac_md5_final((unsigned char *) sess_key, &ctx); -+} -+ -+void -+SMBsesskeygen_ntv1(const unsigned char kr[16], -+ const unsigned char *nt_resp, __u8 sess_key[16]) -+{ -+ mdfour((unsigned char *) sess_key, (unsigned char *) kr, 16); -+} ---- /dev/null -+++ b/fs/cifs/smberr.c -@@ -0,0 +1,240 @@ -+/* -+ Unix SMB/Netbios implementation. -+ Version 1.9. -+ Copyright (C) Andrew Tridgell 1998 -+ Copyright (C) Steve French (sfrench@us.ibm.com) 2002 -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 2 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software -+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -+*/ -+include "smberr.h" -+#define NO_SYSLOG -+/* error code stuff - put together by Merik Karman -+ merik@blackadder.dsh.oz.au */ -+ typedef const struct { -+ char *name; -+ int code; -+ char *message; -+ int posix_code; -+} err_code_struct; -+ -+/* Dos Error Messages */ -+err_code_struct dos_msgs[] = { -+ {"ERRbadfunc", ERRbadfunc, "Invalid function.", -EINVAL}, -+ {"ERRbadfile", ERRbadfile, "File not found.", -ENOENT}, -+ {"ERRbadpath", ERRbadpath, "Directory invalid.", -ENOENT}, -+ {"ERRnofids", ERRnofids, "No file descriptors available", -EMFILE}, -+ {"ERRnoaccess", ERRnoaccess, "Access denied.", -EACCES}, -+ {"ERRbadfid", ERRbadfid, "Invalid file handle.", -EBADF}, -+ {"ERRbadmcb", 7, "Memory control blocks destroyed.", -EIO}, -+ {"ERRnomem", ERRnomem, -+ "Insufficient server memory to perform the requested function.", -+ -ENOMEM}, -+ {"ERRbadmem", ERRbadmem, "Invalid memory block address.", -EFAULT}, -+ {"ERRbadenv", ERRbadenv, "Invalid environment.", -EFAULT}, -+ {"ERRbadformat", 11, "Invalid format.", -EINVAL}, -+ {"ERRbadaccess", ERRbadaccess, "Invalid open mode." - EACCES}, -+ {"ERRbaddata", ERRbaddata, "Invalid data.", -EIO}, -+ {"ERR", ERRres, "reserved.", -EIO}, -+ {"ERRbaddrive", ERRbaddrive, "Invalid drive specified.", -ENXIO}, -+ {"ERRremcd", ERRremcd, -+ "A Delete Directory request attempted to remove the server's current directory.", -+ -EIO}, -+ {"ERRdiffdevice", ERRdiffdevice, "Not same device.", -EXDEV}, -+ {"ERRnofiles", ERRnofiles, "A File Search command can find no more files matching the specified criteria.", -ENOENT}, /* Note: must map to zero manually in some places such as readdir */ -+ {"ERRbadshare", ERRbadshare, -+ "The sharing mode specified for an Open conflicts with existing FIDs on the file.", -+ -EXTBSY}, -+ {"ERRlock", ERRlock, -+ "A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process.", -+ -EACCES}, -+ {"ERRunsup", ERRunsup, "The operation is unsupported", -EINVAL}, -+ {"ERRnosuchshare", ERRnosuchshare, -+ "You specified an invalid share name", -ENXIO}, -+ {"ERRfilexists", ERRfilexists, -+ "The file named in a Create Directory, Make New File or Link request already exists.", -+ -EEXIST}, -+ {"ERRinvalidname", ERRinvalidname, "Invalid name", -ENOENT}, -+ {"ERRdiskfull", ERRdiskfull, "Disk full", -ENOSPC} -+ -+ {"ERRmoredata", ERRmoredata, -+ "There is more data to be returned.",}, -+ {"ERRinvgroup", 2455, "Invalid workgroup (try the -W option)"}, -+ {NULL, -1, NULL, -EIO} -+}; -+ -+/* Server Error Messages */ -+err_code_struct server_msgs[] = { -+ {"ERRerror", 1, "Non-specific error code."}, -+ {"ERRbadpw", 2, -+ "Bad password - name/password pair in a Tree Connect or Session Setup are invalid."}, -+ {"ERRbadtype", 3, "reserved."}, -+ {"ERRaccess", 4, -+ "The requester does not have the necessary access rights within the specified context for the requested function. The context is defined by the TID or the UID."}, -+ {"ERRinvnid", 5, -+ "The tree ID (TID) specified in a command was invalid."}, -+ {"ERRinvnetname", 6, "Invalid network name in tree connect."}, -+ {"ERRinvdevice", 7, -+ "Invalid device - printer request made to non-printer connection or non-printer request made to printer connection."}, -+ {"ERRqfull", 49, -+ "Print queue full (files) -- returned by open print file."}, -+ {"ERRqtoobig", 50, "Print queue full -- no space."}, -+ {"ERRqeof", 51, "EOF on print queue dump."}, -+ {"ERRinvpfid", 52, "Invalid print file FID."}, -+ {"ERRsmbcmd", 64, -+ "The server did not recognize the command received."}, -+ {"ERRsrverror", 65, -+ "The server encountered an internal error, e.g., system file unavailable."}, -+ {"ERRfilespecs", 67, -+ "The file handle (FID) and pathname parameters contained an invalid combination of values."}, -+ {"ERRreserved", 68, "reserved."}, -+ {"ERRbadpermits", 69, -+ "The access permissions specified for a file or directory are not a valid combination. The server cannot set the requested attribute."}, -+ {"ERRreserved", 70, "reserved."}, -+ {"ERRsetattrmode", 71, -+ "The attribute mode in the Set File Attribute request is invalid."}, -+ {"ERRpaused", 81, "Server is paused."}, -+ {"ERRmsgoff", 82, "Not receiving messages."}, -+ {"ERRnoroom", 83, "No room to buffer message."}, -+ {"ERRrmuns", 87, "Too many remote user names."}, -+ {"ERRtimeout", 88, "Operation timed out."}, -+ {"ERRnoresource", 89, -+ "No resources currently available for request."}, -+ {"ERRtoomanyuids", 90, "Too many UIDs active on this session."}, -+ {"ERRbaduid", 91, -+ "The UID is not known as a valid ID on this session."}, -+ {"ERRusempx", 250, "Temp unable to support Raw, use MPX mode."}, -+ {"ERRusestd", 251, -+ "Temp unable to support Raw, use standard read/write."}, -+ {"ERRcontmpx", 252, "Continue in MPX mode."}, -+ {"ERRreserved", 253, "reserved."}, -+ {"ERRreserved", 254, "reserved."}, -+ {"ERRnosupport", 0xFFFF, "Function not supported."}, -+ {NULL, -1, NULL} -+}; -+ -+/* Hard Error Messages */ -+err_code_struct hard_msgs[] = { -+ {"ERRnowrite", 19, -+ "Attempt to write on write-protected diskette."}, -+ {"ERRbadunit", 20, "Unknown unit."}, -+ {"ERRnotready", 21, "Drive not ready."}, -+ {"ERRbadcmd", 22, "Unknown command."}, -+ {"ERRdata", 23, "Data error (CRC)."}, -+ {"ERRbadreq", 24, "Bad request structure length."}, -+ {"ERRseek", 25, "Seek error."}, -+ {"ERRbadmedia", 26, "Unknown media type."}, -+ {"ERRbadsector", 27, "Sector not found."}, -+ {"ERRnopaper", 28, "Printer out of paper."}, -+ {"ERRwrite", 29, "Write fault."}, -+ {"ERRread", 30, "Read fault."}, -+ {"ERRgeneral", 31, "General failure."}, -+ {"ERRbadshare", 32, "An open conflicts with an existing open."}, -+ {"ERRlock", 33, -+ "A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process."}, -+ {"ERRwrongdisk", 34, "The wrong disk was found in a drive."}, -+ {"ERRFCBUnavail", 35, "No FCBs are available to process request."}, -+ {"ERRsharebufexc", 36, "A sharing buffer has been exceeded."}, -+ {NULL, -1, NULL} -+}; -+ -+ -+const struct { -+ int code; -+ char *class; -+ err_code_struct *err_msgs; -+} err_classes[] = { -+ { -+ 0, "SUCCESS", NULL}, { -+ 0x01, "ERRDOS", dos_msgs}, { -+ 0x02, "ERRSRV", server_msgs}, { -+ 0x03, "ERRHRD", hard_msgs}, { -+ 0x04, "ERRXOS", NULL}, { -+ 0xE1, "ERRRMX1", NULL}, { -+ 0xE2, "ERRRMX2", NULL}, { -+ 0xE3, "ERRRMX3", NULL}, { -+ 0xFF, "ERRCMD", NULL}, { -+-1, NULL, NULL}}; -+ -+ -+/**************************************************************************** -+return a SMB error string from a SMB buffer -+****************************************************************************/ -+char *smb_dos_errstr(char *inbuf) -+{ -+ static pstring ret; -+ int class = CVAL(inbuf, smb_rcls); -+ int num = SVAL(inbuf, smb_err); -+ int i, j; -+ -+ for (i = 0; err_classes[i].class; i++) -+ if (err_classes[i].code == class) { -+ if (err_classes[i].err_msgs) { -+ err_code_struct *err = -+ err_classes[i].err_msgs; -+ for (j = 0; err[j].name; j++) -+ if (num == err[j].code) { -+ if (DEBUGLEVEL > 0) -+ slprintf(ret, -+ sizeof -+ (ret) - 1, -+ "%s - %s (%s)", -+ err_classes -+ [i].class, -+ err[j]. -+ name, -+ err[j]. -+ message); -+ else -+ slprintf(ret, -+ sizeof -+ (ret) - 1, -+ "%s - %s", -+ err_classes -+ [i].class, -+ err[j]. -+ name); -+ return ret; -+ } -+ } -+ -+ slprintf(ret, sizeof(ret) - 1, "%s - %d", -+ err_classes[i].class, num); -+ return ret; -+ } -+ -+ slprintf(ret, sizeof(ret) - 1, "Error: Unknown error (%d,%d)", -+ class, num); -+ return (ret); -+} -+ -+ -+/***************************************************************************** -+ returns an WERROR error message. -+ *****************************************************************************/ -+char *werror_str(WERROR status) -+{ -+ static fstring msg; -+ slprintf(msg, sizeof(msg), "WIN32 code 0x%08x", W_ERROR_V(status)); -+ return msg; -+} -+ -+ -+/***************************************************************************** -+map a unix errno to a win32 error -+ *****************************************************************************/ -+WERROR map_werror_from_unix(int error) -+{ -+ NTSTATUS status = map_nt_error_from_unix(error); -+ return ntstatus_to_werror(status); -+} ---- /dev/null -+++ b/fs/cifs/smberr.h -@@ -0,0 +1,113 @@ -+/* -+ * fs/cifs/smberr.h -+ * -+ * Copyright (c) International Business Machines Corp., 2002 -+ * Author(s): Steve French (sfrench@us.ibm.com) -+ * -+ * See Error Codes section of the SNIA CIFS Specification -+ * for more information -+ * -+ * This library is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU Lesser General Public License as published -+ * by the Free Software Foundation; either version 2.1 of the License, or -+ * (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -+ * the GNU Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public License -+ * along with this library; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ */ -+ -+#define SUCCESS 0 /* The request was successful. */ -+#define ERRDOS 0x01 /* Error is from the core DOS operating system set */ -+#define ERRSRV 0x02 /* Error is generated by the file server daemon */ -+#define ERRHRD 0x03 /* Error is a hardware error. */ -+#define ERRCMD 0xFF /* Command was not in the "SMB" format. */ -+ -+/* The following error codes may be generated with the SUCCESS error class.*/ -+ -+#define SUCCESS 0 /* The request was successful. */ -+ -+/* The following error codes may be generated with the ERRDOS error class.*/ -+ -+#define ERRbadfunc 1 /* Invalid function. The server did not recognize or could not perform a system call generated by the server, e.g., set the DIRECTORY attribute on a data file, invalid seek mode. */ -+#define ERRbadfile 2 /*File not found. The last component of a file's pathname could not be found. */ -+#define ERRbadpath 3 /* Directory invalid. A directory component in a pathname could not be found. */ -+#define ERRnofids 4 /* Too many open files. The server has no file handles available. */ -+#define ERRnoaccess 5 /* Access denied, the client's context does not permit the requested function. This includes the following conditions: invalid rename command, write to Fid open for read only, read on Fid open for write only, attempt to delete a non-empty directory */ -+#define ERRbadfid 6 /* Invalid file handle. The file handle specified was not recognized by the server. */ -+#define ERRbadmcb 7 /* Memory control blocks destroyed. */ -+#define ERRnomem 8 /* Insufficient server memory to perform the requested function. */ -+#define ERRbadmem 9 /* Invalid memory block address. */ -+#define ERRbadenv 10 /* Invalid environment. */ -+#define ERRbadformat 11 /* Invalid format. */ -+#define ERRbadaccess 12 /* Invalid open mode. */ -+#define ERRbaddata 13 /* Invalid data (generated only by IOCTL calls within the server). */ -+#define ERRbaddrive 15 /* Invalid drive specified. */ -+#define ERRremcd 16 /* A Delete Directory request attempted to remove the server's current directory. */ -+#define ERRdiffdevice 17 /* Not same device (e.g., a cross volume rename was attempted */ -+#define ERRnofiles 18 /* A File Search command can find no more files matching the specified criteria. */ -+#define ERRgeneral 31 -+#define ERRbadshare 32 /* The sharing mode specified for an Open conflicts with existing FIDs on the file. */ -+#define ERRlock 33 /* A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process. */ -+#define ERRunsup 50 -+#define ERRnosuchshare 67 -+#define ERRfilexists 80 /* The file named in the request already exists. */ -+#define ERRinvparm 87 -+#define ERRdiskfull 112 -+#define ERRinvname 123 -+#define ERRdirnotempty 145 -+#define ERRnotlocked 158 -+#define ERRalreadyexists 183 -+#define ERRbadpipe 230 -+#define ERRpipebusy 231 -+#define ERRpipeclosing 232 -+#define ERRnotconnected 233 -+#define ERRmoredata 234 -+#define ErrQuota 0x200 /* The operation would cause a quota limit to be exceeded. */ -+#define ErrNotALink 0x201 /* A link operation was performed on a pathname that -+ was not a link. */ -+ -+/* Following error codes may be generated with the ERRSRV error -+class.*/ -+ -+#define ERRerror 1 /* Non-specific error code. It is returned under the following conditions: resource other than disk space exhausted (e.g. TIDs), first SMB command was not negotiate, multiple negotiates attempted, and internal server error. */ -+#define ERRbadpw 2 /* Bad password - name/password pair in a TreeConnect or Session Setup are invalid. */ -+#define ERRbadtype 3 /* used for indicating DFS referral needed */ -+#define ERRaccess 4 /* The client does not have the necessary access rights within the specified context for requested function. */ -+#define ERRinvtid 5 /* The Tid specified in a command was invalid. */ -+#define ERRinvnetname 6 /* Invalid network name in tree connect. */ -+#define ERRinvdevice 7 /* Invalid device - printer request made to non-printer connection or non-printer request made to printer connection. */ -+#define ERRqfull 49 /* Print queue full (files) -- returned by open print file. */ -+#define ERRqtoobig 50 /* Print queue full -- no space. */ -+#define ERRqeof 51 /* EOF on print queue dump */ -+#define ERRinvpfid 52 /* Invalid print file FID. */ -+#define ERRsmbcmd 64 /* The server did not recognize the command received. */ -+#define ERRsrverror 65 /* The server encountered an internal error, e.g., system file unavailable. */ -+#define ERRbadBID 66 /* (obsolete) */ -+#define ERRfilespecs 67 /* The Fid and pathname parameters contained an invalid combination of values. */ -+#define ERRbadLink 68 /* (obsolete) */ -+#define ERRbadpermits 69 /* The access permissions specified for a file or directory are not a valid combination. */ -+#define ERRbadPID 70 -+#define ERRsetattrmode 71 /* attribute (mode) is invalid */ -+#define ERRpaused 81 /* Server is paused */ -+#define ERRmsgoff 82 /* reserved - messaging off */ -+#define ERRnoroom 83 /* reserved - no room for message */ -+#define ERRrmuns 87 /* reserved - too many remote names */ -+#define ERRtimeout 88 /* operation timed out */ -+#define ERRnoresource 89 /* No resources available for request */ -+#define ERRtoomanyuids 90 /* Too many UIDs active on this session */ -+#define ERRbaduid 91 /* The UID is not known as a valid user */ -+#define ERRusempx 250 /* temporarily unable to use raw */ -+#define ERRusestd 251 /* temporarily unable to use either raw or mpx */ -+#define ERR_NOTIFY_ENUM_DIR 1024 -+#define ERRaccountexpired 2239 -+#define ERRbadclient 2240 -+#define ERRbadLogonTime 2241 -+#define ERRpasswordExpired 2242 -+#define ERRnetlogonNotStarted 2455 -+#define ERRnosupport 0xFFFF ---- /dev/null -+++ b/fs/cifs/TODO -@@ -0,0 +1,106 @@ -+version 1.16 May 27, 2004 -+ -+A Partial List of Missing Features -+================================== -+ -+Contributions are welcome. There are plenty of opportunities -+for visible, important contributions to this module. Here -+is a partial list of the known problems and missing features: -+ -+a) Support for SecurityDescriptors for chmod/chgrp/chown so -+these can be supported for Windows servers -+ -+b) Better pam/winbind integration -+ -+c) multi-user mounts - multiplexed sessionsetups over single vc -+(ie tcp session) - prettying up needed -+ -+d) Kerberos/SPNEGO session setup support - (started) -+ -+e) NTLMv2 authentication (mostly implemented) -+ -+f) MD5-HMAC signing SMB PDUs when SPNEGO style SessionSetup -+used (Kerberos or NTLMSSP). Signing alreadyimplemented for NTLM -+and raw NTLMSSP already. This is important when enabling -+extended security and mounting to Windows 2003 Servers -+ -+f) Directory entry caching relies on a 1 second timer, rather than -+using FindNotify or equivalent. - (started) -+ -+g) A few byte range testcases fail due to POSIX vs. Windows/CIFS -+style byte range lock differences -+ -+h) quota support -+ -+i) support for the Linux 2.5 kernel new feature get_xattr and set_xattr -+which will allow us to expose dos attributes as well as real -+ACLs. This support has been started in the current code, but is -+ifdeffed out. -+ -+k) finish writepages support (multi-page write behind for improved -+performance) and syncpage -+ -+l) hook lower into the sockets api (as NFS/SunRPC does) to avoid the -+extra copy in/out of the socket buffers in some cases. -+ -+m) finish support for IPv6. This is mostly complete but -+needs a simple inet_pton like function to convert ipv6 -+addresses in string representation. -+ -+o) Better optimize open (and pathbased setfilesize) to reduce the -+oplock breaks coming from windows srv. Piggyback identical file -+opens on top of each other by incrementing reference count rather -+than resending (helps reduce server resource utilization and avoid -+spurious oplock breaks). -+ -+p) Improve performance of readpages by sending more than one read -+at a time when 8 pages or more are requested. Evaluate whether -+reads larger than 16K would be helpful. -+ -+q) For support of Windows9x/98 we need to retry failed mounts -+to *SMBSERVER (default server name) with the uppercase hostname -+in the RFC1001 session_init request. -+ -+r) Add Extended Attributed support (for storing UID/GID info -+to Windows servers) -+ -+s) Finish fcntl D_NOTIFY support so kde and gnome file list windows -+will autorefresh -+ -+t) Add GUI tool to configure /proc/fs/cifs settings and for display of -+the CIFS statistics -+ -+KNOWN BUGS (updated May 27, 2004) -+==================================== -+1) existing symbolic links (Windows reparse points) are recognized but -+can not be created remotely. They are implemented for Samba and those that -+support the CIFS Unix extensions but Samba has a bug currently handling -+symlink text beginning with slash -+2) follow_link and readdir code does not follow dfs junctions -+but recognizes them -+3) create of new files to FAT partitions on Windows servers can -+succeed but still return access denied (appears to be Windows -+server not cifs client problem) and has not been reproduced recently. -+NTFS partitions do not have this problem. -+4) debug connectathon lock test case 10 which fails against -+Samba (may be unmappable due to POSIX to Windows lock model -+differences but worth investigating). Also debug Samba to -+see why lock test case 7 takes longer to complete to Samba -+than to Windows. -+ -+Misc testing to do -+================== -+1) check out max path names and max path name components against various server -+types. Try nested symlinks. Return max path name in stat -f information -+ -+2) Modify file portion of ltp so it can run against a mounted network -+share and run it against cifs vfs. -+ -+3) Additional performance testing and optimization using iozone and similar - -+there are some easy changes that can be done to parallelize sequential writes, -+and when signing is disabled to request larger read sizes (larger than -+negotiated size) and send larger write sizes to modern servers. -+ -+4) More exhaustively test the recently added NT4 support against various -+NT4 service pack levels. -+ ---- /dev/null -+++ b/fs/cifs/transport.c -@@ -0,0 +1,434 @@ -+/* -+ * fs/cifs/transport.c -+ * -+ * Copyright (C) International Business Machines Corp., 2002,2004 -+ * Author(s): Steve French (sfrench@us.ibm.com) -+ * -+ * This library is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU Lesser General Public License as published -+ * by the Free Software Foundation; either version 2.1 of the License, or -+ * (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -+ * the GNU Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public License -+ * along with this library; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ */ -+ -+#include <linux/fs.h> -+#include <linux/list.h> -+#include <linux/wait.h> -+#include <linux/net.h> -+#include <linux/version.h> -+#include <asm/uaccess.h> -+#include <asm/processor.h> -+#include "cifspdu.h" -+#include "cifsglob.h" -+#include "cifsproto.h" -+#include "cifs_debug.h" -+ -+extern kmem_cache_t *cifs_mid_cachep; -+extern kmem_cache_t *cifs_oplock_cachep; -+ -+struct mid_q_entry * -+AllocMidQEntry(struct smb_hdr *smb_buffer, struct cifsSesInfo *ses) -+{ -+ struct mid_q_entry *temp; -+ -+ if (ses == NULL) { -+ cERROR(1, ("Null session passed in to AllocMidQEntry ")); -+ return NULL; -+ } -+ if (ses->server == NULL) { -+ cERROR(1, ("Null TCP session in AllocMidQEntry")); -+ return NULL; -+ } -+ -+ temp = (struct mid_q_entry *) kmem_cache_alloc(cifs_mid_cachep, -+ SLAB_KERNEL); -+ if (temp == NULL) -+ return temp; -+ else { -+ memset(temp, 0, sizeof (struct mid_q_entry)); -+ temp->mid = smb_buffer->Mid; /* always LE */ -+ temp->pid = current->pid; -+ temp->command = smb_buffer->Command; -+ cFYI(1, ("For smb_command %d", temp->command)); -+ do_gettimeofday(&temp->when_sent); -+ temp->ses = ses; -+ temp->tsk = current; -+ } -+ -+ spin_lock(&GlobalMid_Lock); -+ list_add_tail(&temp->qhead, &ses->server->pending_mid_q); -+ atomic_inc(&midCount); -+ temp->midState = MID_REQUEST_ALLOCATED; -+ spin_unlock(&GlobalMid_Lock); -+ return temp; -+} -+ -+void -+DeleteMidQEntry(struct mid_q_entry *midEntry) -+{ -+ spin_lock(&GlobalMid_Lock); -+ midEntry->midState = MID_FREE; -+ list_del(&midEntry->qhead); -+ atomic_dec(&midCount); -+ spin_unlock(&GlobalMid_Lock); -+ cifs_buf_release(midEntry->resp_buf); -+ kmem_cache_free(cifs_mid_cachep, midEntry); -+} -+ -+struct oplock_q_entry * -+AllocOplockQEntry(struct inode * pinode, __u16 fid, struct cifsTconInfo * tcon) -+{ -+ struct oplock_q_entry *temp; -+ if ((pinode== NULL) || (tcon == NULL)) { -+ cERROR(1, ("Null parms passed to AllocOplockQEntry")); -+ return NULL; -+ } -+ temp = (struct oplock_q_entry *) kmem_cache_alloc(cifs_oplock_cachep, -+ SLAB_KERNEL); -+ if (temp == NULL) -+ return temp; -+ else { -+ temp->pinode = pinode; -+ temp->tcon = tcon; -+ temp->netfid = fid; -+ spin_lock(&GlobalMid_Lock); -+ list_add_tail(&temp->qhead, &GlobalOplock_Q); -+ spin_unlock(&GlobalMid_Lock); -+ } -+ return temp; -+ -+} -+ -+void DeleteOplockQEntry(struct oplock_q_entry * oplockEntry) -+{ -+ spin_lock(&GlobalMid_Lock); -+ /* should we check if list empty first? */ -+ list_del(&oplockEntry->qhead); -+ spin_unlock(&GlobalMid_Lock); -+ kmem_cache_free(cifs_oplock_cachep, oplockEntry); -+} -+ -+int -+smb_send(struct socket *ssocket, struct smb_hdr *smb_buffer, -+ unsigned int smb_buf_length, struct sockaddr *sin) -+{ -+ int rc = 0; -+ int i = 0; -+ struct msghdr smb_msg; -+ struct iovec iov; -+ mm_segment_t temp_fs; -+ -+ if(ssocket == NULL) -+ return -ENOTSOCK; /* BB eventually add reconnect code here */ -+ iov.iov_base = smb_buffer; -+ iov.iov_len = smb_buf_length + 4; -+ -+ smb_msg.msg_name = sin; -+ smb_msg.msg_namelen = sizeof (struct sockaddr); -+ smb_msg.msg_iov = &iov; -+ smb_msg.msg_iovlen = 1; -+ smb_msg.msg_control = NULL; -+ smb_msg.msg_controllen = 0; -+ smb_msg.msg_flags = MSG_DONTWAIT + MSG_NOSIGNAL; /* BB add more flags?*/ -+ -+ /* smb header is converted in header_assemble. bcc and rest of SMB word -+ area, and byte area if necessary, is converted to littleendian in -+ cifssmb.c and RFC1001 len is converted to bigendian in smb_send -+ Flags2 is converted in SendReceive */ -+ -+ smb_buffer->smb_buf_length = cpu_to_be32(smb_buffer->smb_buf_length); -+ cFYI(1, ("Sending smb of length %d ", smb_buf_length)); -+ dump_smb(smb_buffer, smb_buf_length + 4); -+ -+ temp_fs = get_fs(); /* we must turn off socket api parm checking */ -+ set_fs(get_ds()); -+ while(iov.iov_len > 0) { -+ rc = sock_sendmsg(ssocket, &smb_msg, smb_buf_length + 4); -+ if ((rc == -ENOSPC) || (rc == -EAGAIN)) { -+ i++; -+ if(i > 60) { -+ cERROR(1, -+ ("sends on sock %p stuck for 30 seconds", -+ ssocket)); -+ rc = -EAGAIN; -+ break; -+ } -+ set_current_state(TASK_INTERRUPTIBLE); -+ schedule_timeout(HZ/2); -+ continue; -+ } -+ if (rc < 0) -+ break; -+ iov.iov_base += rc; -+ iov.iov_len -= rc; -+ } -+ set_fs(temp_fs); -+ -+ if (rc < 0) { -+ cERROR(1,("Error %d sending data on socket to server.", rc)); -+ } else { -+ rc = 0; -+ } -+ -+ return rc; -+} -+ -+int -+SendReceive(const unsigned int xid, struct cifsSesInfo *ses, -+ struct smb_hdr *in_buf, struct smb_hdr *out_buf, -+ int *pbytes_returned, const int long_op) -+{ -+ int rc = 0; -+ unsigned int receive_len; -+ long timeout; -+ struct mid_q_entry *midQ; -+ -+ if (ses == NULL) { -+ cERROR(1,("Null smb session")); -+ return -EIO; -+ } -+ if(ses->server == NULL) { -+ cERROR(1,("Null tcp session")); -+ return -EIO; -+ } -+ -+ /* Ensure that we do not send more than 50 overlapping requests -+ to the same server. We may make this configurable later or -+ use ses->maxReq */ -+ if(long_op == -1) { -+ /* oplock breaks must not be held up */ -+ atomic_inc(&ses->server->inFlight); -+ } else { -+ spin_lock(&GlobalMid_Lock); -+ while(1) { -+ if(atomic_read(&ses->server->inFlight) >= CIFS_MAX_REQ){ -+ spin_unlock(&GlobalMid_Lock); -+ wait_event(ses->server->request_q, -+ atomic_read(&ses->server->inFlight) -+ < CIFS_MAX_REQ); -+ spin_lock(&GlobalMid_Lock); -+ } else { -+ if(ses->server->tcpStatus == CifsExiting) { -+ spin_unlock(&GlobalMid_Lock); -+ return -ENOENT; -+ } -+ -+ /* can not count locking commands against total since -+ they are allowed to block on server */ -+ -+ if(long_op < 3) { -+ /* update # of requests on the wire to server */ -+ atomic_inc(&ses->server->inFlight); -+ } -+ spin_unlock(&GlobalMid_Lock); -+ break; -+ } -+ } -+ } -+ /* make sure that we sign in the same order that we send on this socket -+ and avoid races inside tcp sendmsg code that could cause corruption -+ of smb data */ -+ -+ down(&ses->server->tcpSem); -+ -+ if (ses->server->tcpStatus == CifsExiting) { -+ rc = -ENOENT; -+ goto out_unlock; -+ } else if (ses->server->tcpStatus == CifsNeedReconnect) { -+ cFYI(1,("tcp session dead - return to caller to retry")); -+ rc = -EAGAIN; -+ goto out_unlock; -+ } else if (ses->status != CifsGood) { -+ /* check if SMB session is bad because we are setting it up */ -+ if((in_buf->Command != SMB_COM_SESSION_SETUP_ANDX) && -+ (in_buf->Command != SMB_COM_NEGOTIATE)) { -+ rc = -EAGAIN; -+ goto out_unlock; -+ } /* else ok - we are setting up session */ -+ } -+ midQ = AllocMidQEntry(in_buf, ses); -+ if (midQ == NULL) { -+ up(&ses->server->tcpSem); -+ /* If not lock req, update # of requests on wire to server */ -+ if(long_op < 3) { -+ atomic_dec(&ses->server->inFlight); -+ wake_up(&ses->server->request_q); -+ } -+ return -ENOMEM; -+ } -+ -+ if (in_buf->smb_buf_length > CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE - 4) { -+ up(&ses->server->tcpSem); -+ cERROR(1, -+ ("Illegal length, greater than maximum frame, %d ", -+ in_buf->smb_buf_length)); -+ DeleteMidQEntry(midQ); -+ /* If not lock req, update # of requests on wire to server */ -+ if(long_op < 3) { -+ atomic_dec(&ses->server->inFlight); -+ wake_up(&ses->server->request_q); -+ } -+ return -EIO; -+ } -+ -+ if (in_buf->smb_buf_length > 12) -+ in_buf->Flags2 = cpu_to_le16(in_buf->Flags2); -+ -+ rc = cifs_sign_smb(in_buf, ses, &midQ->sequence_number); -+ -+ midQ->midState = MID_REQUEST_SUBMITTED; -+ rc = smb_send(ses->server->ssocket, in_buf, in_buf->smb_buf_length, -+ (struct sockaddr *) &(ses->server->addr.sockAddr)); -+ if(rc < 0) { -+ DeleteMidQEntry(midQ); -+ up(&ses->server->tcpSem); -+ /* If not lock req, update # of requests on wire to server */ -+ if(long_op < 3) { -+ atomic_dec(&ses->server->inFlight); -+ wake_up(&ses->server->request_q); -+ } -+ return rc; -+ } else -+ up(&ses->server->tcpSem); -+ if (long_op == -1) -+ goto cifs_no_response_exit; -+ else if (long_op == 2) /* writes past end of file can take looooong time */ -+ timeout = 300 * HZ; -+ else if (long_op == 1) -+ timeout = 45 * HZ; /* should be greater than -+ servers oplock break timeout (about 43 seconds) */ -+ else if (long_op > 2) { -+ timeout = MAX_SCHEDULE_TIMEOUT; -+ } else -+ timeout = 15 * HZ; -+ /* wait for 15 seconds or until woken up due to response arriving or -+ due to last connection to this server being unmounted */ -+ if (signal_pending(current)) { -+ /* if signal pending do not hold up user for full smb timeout -+ but we still give response a change to complete */ -+ if(midQ->midState & MID_REQUEST_SUBMITTED) { -+ set_current_state(TASK_UNINTERRUPTIBLE); -+ timeout = sleep_on_timeout(&ses->server->response_q,2 * HZ); -+ } -+ } else { /* using normal timeout */ -+ /* timeout = wait_event_interruptible_timeout(ses->server->response_q, -+ (midQ->midState & MID_RESPONSE_RECEIVED) || -+ ((ses->server->tcpStatus != CifsGood) && -+ (ses->server->tcpStatus != CifsNew)), -+ timeout); */ -+ /* Can not allow user interrupts- wreaks havoc with performance */ -+ if(midQ->midState & MID_REQUEST_SUBMITTED) { -+ set_current_state(TASK_UNINTERRUPTIBLE); -+ timeout = sleep_on_timeout(&ses->server->response_q,timeout); -+ } -+ } -+ -+ spin_lock(&GlobalMid_Lock); -+ if (midQ->resp_buf) { -+ spin_unlock(&GlobalMid_Lock); -+ receive_len = be32_to_cpu(midQ->resp_buf->smb_buf_length); -+ } else { -+ cERROR(1,("No response buffer")); -+ if(midQ->midState == MID_REQUEST_SUBMITTED) { -+ if(ses->server->tcpStatus == CifsExiting) -+ rc = -EHOSTDOWN; -+ else { -+ ses->server->tcpStatus = CifsNeedReconnect; -+ midQ->midState = MID_RETRY_NEEDED; -+ } -+ } -+ -+ if (rc != -EHOSTDOWN) { -+ if(midQ->midState == MID_RETRY_NEEDED) { -+ rc = -EAGAIN; -+ cFYI(1,("marking request for retry")); -+ } else { -+ rc = -EIO; -+ } -+ } -+ spin_unlock(&GlobalMid_Lock); -+ DeleteMidQEntry(midQ); -+ /* If not lock req, update # of requests on wire to server */ -+ if(long_op < 3) { -+ atomic_dec(&ses->server->inFlight); -+ wake_up(&ses->server->request_q); -+ } -+ return rc; -+ } -+ -+ if (receive_len > CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE) { -+ cERROR(1, -+ ("Frame too large received. Length: %d Xid: %d", -+ receive_len, xid)); -+ rc = -EIO; -+ } else { /* rcvd frame is ok */ -+ -+ if (midQ->resp_buf && out_buf -+ && (midQ->midState == MID_RESPONSE_RECEIVED)) { -+ memcpy(out_buf, midQ->resp_buf, -+ receive_len + -+ 4 /* include 4 byte RFC1001 header */ ); -+ -+ dump_smb(out_buf, 92); -+ /* convert the length into a more usable form */ -+ out_buf->smb_buf_length = -+ be32_to_cpu(out_buf->smb_buf_length); -+ if((out_buf->smb_buf_length > 24) && -+ (ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))) { -+ rc = cifs_verify_signature(out_buf, ses->mac_signing_key,midQ->sequence_number); /* BB fix BB */ -+ if(rc) -+ cFYI(1,("Unexpected signature received from server")); -+ } -+ -+ if (out_buf->smb_buf_length > 12) -+ out_buf->Flags2 = le16_to_cpu(out_buf->Flags2); -+ if (out_buf->smb_buf_length > 28) -+ out_buf->Pid = le16_to_cpu(out_buf->Pid); -+ if (out_buf->smb_buf_length > 28) -+ out_buf->PidHigh = -+ le16_to_cpu(out_buf->PidHigh); -+ -+ *pbytes_returned = out_buf->smb_buf_length; -+ -+ /* BB special case reconnect tid and reconnect uid here? */ -+ rc = map_smb_to_linux_error(out_buf); -+ -+ /* convert ByteCount if necessary */ -+ if (receive_len >= -+ sizeof (struct smb_hdr) - -+ 4 /* do not count RFC1001 header */ + -+ (2 * out_buf->WordCount) + 2 /* bcc */ ) -+ BCC(out_buf) = le16_to_cpu(BCC(out_buf)); -+ } else { -+ rc = -EIO; -+ cFYI(1,("Bad MID state? ")); -+ } -+ } -+cifs_no_response_exit: -+ DeleteMidQEntry(midQ); -+ -+ if(long_op < 3) { -+ atomic_dec(&ses->server->inFlight); -+ wake_up(&ses->server->request_q); -+ } -+ -+ return rc; -+ -+out_unlock: -+ up(&ses->server->tcpSem); -+ /* If not lock req, update # of requests on wire to server */ -+ if(long_op < 3) { -+ atomic_dec(&ses->server->inFlight); -+ wake_up(&ses->server->request_q); -+ } -+ -+ return rc; -+} ---- a/fs/Config.in -+++ b/fs/Config.in -@@ -153,6 +153,10 @@ if [ "$CONFIG_NET" = "y" ]; then - define_bool CONFIG_LOCKD_V4 y - fi - -+ dep_tristate 'CIFS support (advanced network filesystem for Samba, Window and other CIFS compliant servers)' CONFIG_CIFS $CONFIG_INET -+ dep_mbool ' CIFS statistics' CONFIG_CIFS_STATS $CONFIG_CIFS -+ dep_mbool ' CIFS POSIX Protocol Extensions' CONFIG_CIFS_POSIX $CONFIG_CIFS -+ - dep_tristate 'SMB file system support (to mount Windows shares etc.)' CONFIG_SMB_FS $CONFIG_INET - if [ "$CONFIG_SMB_FS" != "n" ]; then - bool ' Use a default NLS' CONFIG_SMB_NLS_DEFAULT ---- a/fs/Makefile -+++ b/fs/Makefile -@@ -37,6 +37,7 @@ subdir-$(CONFIG_MSDOS_FS) += msdos - subdir-$(CONFIG_VFAT_FS) += vfat - subdir-$(CONFIG_BFS_FS) += bfs - subdir-$(CONFIG_ISO9660_FS) += isofs -+subdir-$(CONFIG_CIFS) += cifs - subdir-$(CONFIG_DEVFS_FS) += devfs - subdir-$(CONFIG_HFSPLUS_FS) += hfsplus # Before hfs to find wrapped HFS+ - subdir-$(CONFIG_HFS_FS) += hfs ---- a/fs/nls/Config.in -+++ b/fs/nls/Config.in -@@ -11,6 +11,7 @@ fi - - # msdos and Joliet want NLS - if [ "$CONFIG_JOLIET" = "y" -o "$CONFIG_FAT_FS" != "n" \ -+ -o "$CONFIG_CIFS" != "n" \ - -o "$CONFIG_NTFS_FS" != "n" -o "$CONFIG_NCPFS_NLS" = "y" \ - -o "$CONFIG_SMB_NLS" = "y" -o "$CONFIG_JFS_FS" != "n" \ - -o "$CONFIG_BEFS_FS" != "n" -o "$CONFIG_HFSPLUS_FS" != "n" ]; then diff --git a/target/linux/generic-2.4/patches/108-optional_aout_support.patch b/target/linux/generic-2.4/patches/108-optional_aout_support.patch deleted file mode 100644 index 2162b88..0000000 --- a/target/linux/generic-2.4/patches/108-optional_aout_support.patch +++ /dev/null @@ -1,649 +0,0 @@ ---- a/Documentation/Configure.help -+++ b/Documentation/Configure.help -@@ -4701,6 +4701,12 @@ CONFIG_BINFMT_ELF - ld.so (check the file <file:Documentation/Changes> for location and - latest version). - -+ELF binaries with a.out format interpreters or a.out libraries -+CONFIG_BINFMT_ELF_AOUT -+ The kernel may support ELF executables which use an a.out format -+ interpreter (dynamic linker) and/or a.out shared libraries, in -+ addition to the usual ELF-ELF setups. You shouldn't need this. -+ - Kernel support for a.out binaries - CONFIG_BINFMT_AOUT - A.out (Assembler.OUTput) is a set of formats for libraries and -@@ -4714,13 +4720,11 @@ CONFIG_BINFMT_AOUT - warrant removing support. However its removal is a good idea if you - wish to ensure that absolutely none of your programs will use this - older executable format. If you don't know what to answer at this -- point then answer Y. If someone told you "You need a kernel with -+ point then answer N. If someone told you "You need a kernel with - QMAGIC support" then you'll have to say Y here. You may answer M to - compile a.out support as a module and later load the module when you - want to use a program or library in a.out format. The module will be -- called binfmt_aout.o. Saying M or N here is dangerous though, -- because some crucial programs on your system might still be in A.OUT -- format. -+ called binfmt_aout.o. - - OSF/1 v4 readv/writev compatibility - CONFIG_OSF4_COMPAT ---- a/arch/alpha/config.in -+++ b/arch/alpha/config.in -@@ -315,6 +315,9 @@ if [ "$CONFIG_BINFMT_AOUT" != "n" ]; the - fi - - bool 'Kernel support for ELF binaries' CONFIG_BINFMT_ELF -+if [ "$CONFIG_BINFMT_ELF" != "n" ]; then -+ bool ' ELF binaries with a.out format interpreters or a.out libraries' CONFIG_BINFMT_ELF_AOUT -+fi - tristate 'Kernel support for MISC binaries' CONFIG_BINFMT_MISC - tristate 'Kernel support for Linux/Intel ELF binaries' CONFIG_BINFMT_EM86 - source drivers/parport/Config.in ---- a/arch/alpha/defconfig -+++ b/arch/alpha/defconfig -@@ -72,6 +72,7 @@ CONFIG_KCORE_ELF=y - # CONFIG_KCORE_AOUT is not set - # CONFIG_BINFMT_AOUT is not set - CONFIG_BINFMT_ELF=y -+# CONFIG_BINFMT_ELF_AOUT is not set - # CONFIG_BINFMT_MISC is not set - # CONFIG_BINFMT_EM86 is not set - ---- a/arch/arm/config.in -+++ b/arch/arm/config.in -@@ -499,6 +499,9 @@ choice 'Kernel core (/proc/kcore) format - A.OUT CONFIG_KCORE_AOUT" ELF - tristate 'Kernel support for a.out binaries' CONFIG_BINFMT_AOUT - bool 'Kernel support for ELF binaries' CONFIG_BINFMT_ELF -+if [ "$CONFIG_BINFMT_ELF" != "n" ]; then -+ bool ' ELF binaries with a.out format interpreters or a.out libraries' CONFIG_BINFMT_ELF_AOUT -+fi - tristate 'Kernel support for MISC binaries' CONFIG_BINFMT_MISC - dep_bool 'Power Management support (experimental)' CONFIG_PM $CONFIG_EXPERIMENTAL - dep_tristate 'RISC OS personality' CONFIG_ARTHUR $CONFIG_CPU_32 ---- a/arch/arm/defconfig -+++ b/arch/arm/defconfig -@@ -83,8 +83,9 @@ CONFIG_SYSCTL=y - CONFIG_NWFPE=y - CONFIG_KCORE_ELF=y - # CONFIG_KCORE_AOUT is not set --CONFIG_BINFMT_AOUT=y -+# CONFIG_BINFMT_AOUT is not set - CONFIG_BINFMT_ELF=y -+# CONFIG_BINFMT_ELF_AOUT is not set - # CONFIG_BINFMT_MISC is not set - # CONFIG_PM is not set - # CONFIG_ARTHUR is not set ---- a/arch/cris/config.in -+++ b/arch/cris/config.in -@@ -31,6 +31,9 @@ bool 'BSD Process Accounting' CONFIG_BSD - bool 'Sysctl support' CONFIG_SYSCTL - - bool 'Kernel support for ELF binaries' CONFIG_BINFMT_ELF -+if [ "$CONFIG_BINFMT_ELF" != "n" ]; then -+ bool ' ELF binaries with a.out format interpreters or a.out libraries' CONFIG_BINFMT_ELF_AOUT -+fi - - string 'Kernel command line' CONFIG_ETRAX_CMDLINE "root=/dev/mtdblock3" - ---- a/arch/cris/defconfig -+++ b/arch/cris/defconfig -@@ -18,6 +18,7 @@ CONFIG_SYSVIPC=y - # CONFIG_BSD_PROCESS_ACCT is not set - # CONFIG_SYSCTL is not set - CONFIG_BINFMT_ELF=y -+# CONFIG_BINFMT_ELF_AOUT is not set - # CONFIG_ETRAX_KGDB is not set - # CONFIG_ETRAX_WATCHDOG is not set - ---- a/arch/i386/config.in -+++ b/arch/i386/config.in -@@ -345,6 +345,9 @@ if [ "$CONFIG_PROC_FS" = "y" ]; then - fi - tristate 'Kernel support for a.out binaries' CONFIG_BINFMT_AOUT - bool 'Kernel support for ELF binaries' CONFIG_BINFMT_ELF -+if [ "$CONFIG_BINFMT_ELF" != "n" ]; then -+ bool ' ELF binaries with a.out format interpreters or a.out libraries' CONFIG_BINFMT_ELF_AOUT -+fi - tristate 'Kernel support for MISC binaries' CONFIG_BINFMT_MISC - bool 'Select task to kill on out of memory condition' CONFIG_OOM_KILLER - ---- a/arch/i386/defconfig -+++ b/arch/i386/defconfig -@@ -115,9 +115,10 @@ CONFIG_SYSVIPC=y - CONFIG_SYSCTL=y - CONFIG_KCORE_ELF=y - # CONFIG_KCORE_AOUT is not set --CONFIG_BINFMT_AOUT=y -+# CONFIG_BINFMT_AOUT is not set - CONFIG_BINFMT_ELF=y --CONFIG_BINFMT_MISC=y -+# CONFIG_BINFMT_ELF_AOUT is not set -+# CONFIG_BINFMT_MISC is not set - # CONFIG_OOM_KILLER is not set - CONFIG_PM=y - # CONFIG_APM is not set ---- a/arch/ia64/config.in -+++ b/arch/ia64/config.in -@@ -124,6 +124,9 @@ bool 'System V IPC' CONFIG_SYSVIPC - bool 'BSD Process Accounting' CONFIG_BSD_PROCESS_ACCT - bool 'Sysctl support' CONFIG_SYSCTL - bool 'Kernel support for ELF binaries' CONFIG_BINFMT_ELF -+if [ "$CONFIG_BINFMT_ELF" != "n" ]; then -+ bool ' ELF binaries with a.out format interpreters or a.out libraries' CONFIG_BINFMT_ELF_AOUT -+fi - tristate 'Kernel support for MISC binaries' CONFIG_BINFMT_MISC - - if [ "$CONFIG_IA64_HP_SIM" = "n" ]; then ---- a/arch/ia64/defconfig -+++ b/arch/ia64/defconfig -@@ -60,6 +60,7 @@ CONFIG_SYSVIPC=y - # CONFIG_BSD_PROCESS_ACCT is not set - CONFIG_SYSCTL=y - CONFIG_BINFMT_ELF=y -+# CONFIG_BINFMT_ELF_AOUT is not set - # CONFIG_BINFMT_MISC is not set - CONFIG_ACPI=y - CONFIG_ACPI_EFI=y ---- a/arch/m68k/config.in -+++ b/arch/m68k/config.in -@@ -100,6 +100,9 @@ if [ "$CONFIG_PROC_FS" = "y" ]; then - fi - tristate 'Kernel support for a.out binaries' CONFIG_BINFMT_AOUT - bool 'Kernel support for ELF binaries' CONFIG_BINFMT_ELF -+if [ "$CONFIG_BINFMT_ELF" != "n" ]; then -+ bool ' ELF binaries with a.out format interpreters or a.out libraries' CONFIG_BINFMT_ELF_AOUT -+fi - tristate 'Kernel support for MISC binaries' CONFIG_BINFMT_MISC - - if [ "$CONFIG_AMIGA" = "y" ]; then ---- a/arch/m68k/defconfig -+++ b/arch/m68k/defconfig -@@ -44,8 +44,9 @@ CONFIG_SYSVIPC=y - CONFIG_SYSCTL=y - CONFIG_KCORE_ELF=y - # CONFIG_KCORE_AOUT is not set --CONFIG_BINFMT_AOUT=y -+# CONFIG_BINFMT_AOUT is not set - CONFIG_BINFMT_ELF=y -+# CONFIG_BINFMT_ELF_AOUT is not set - # CONFIG_BINFMT_MISC is not set - CONFIG_ZORRO=y - # CONFIG_AMIGA_PCMCIA is not set ---- a/arch/mips/config-shared.in -+++ b/arch/mips/config-shared.in -@@ -873,6 +873,9 @@ define_bool CONFIG_KCORE_ELF y - define_bool CONFIG_KCORE_AOUT n - define_bool CONFIG_BINFMT_AOUT n - bool 'Kernel support for ELF binaries' CONFIG_BINFMT_ELF -+if [ "$CONFIG_BINFMT_ELF" != "n" ]; then -+ bool ' ELF binaries with a.out format interpreters or a.out libraries' CONFIG_BINFMT_ELF_AOUT -+fi - dep_bool 'Kernel support for Linux/MIPS 32-bit binary compatibility' CONFIG_MIPS32_COMPAT $CONFIG_MIPS64 - dep_bool 'Kernel support for o32 binaries' CONFIG_MIPS32_O32 $CONFIG_MIPS32_COMPAT - dep_bool 'Kernel support for n32 binaries' CONFIG_MIPS32_N32 $CONFIG_MIPS32_COMPAT ---- a/arch/mips/defconfig -+++ b/arch/mips/defconfig -@@ -143,6 +143,7 @@ CONFIG_KCORE_ELF=y - # CONFIG_KCORE_AOUT is not set - # CONFIG_BINFMT_AOUT is not set - CONFIG_BINFMT_ELF=y -+# CONFIG_BINFMT_ELF_AOUT is not set - # CONFIG_MIPS32_COMPAT is not set - # CONFIG_MIPS32_O32 is not set - # CONFIG_MIPS32_N32 is not set ---- a/arch/mips/kernel/irixelf.c -+++ b/arch/mips/kernel/irixelf.c -@@ -8,6 +8,7 @@ - * Copyright 1993, 1994: Eric Youngdale (ericy@cais.com). - */ - -+#include <linux/config.h> - #include <linux/module.h> - - #include <linux/fs.h> -@@ -48,7 +49,12 @@ static int irix_core_dump(long signr, st - extern int dump_fpu (elf_fpregset_t *); - - static struct linux_binfmt irix_format = { -- NULL, THIS_MODULE, load_irix_binary, load_irix_library, -+ NULL, THIS_MODULE, load_irix_binary, -+#ifdef CONFIG_BINFMT_ELF_AOUT -+ load_irix_library, -+#else -+ NULL, -+#endif - irix_core_dump, PAGE_SIZE - }; - -@@ -794,6 +800,7 @@ out_free_ph: - goto out; - } - -+#ifdef CONFIG_BINFMT_ELF_AOUT - /* This is really simpleminded and specialized - we are loading an - * a.out library that is given an ELF header. - */ -@@ -873,6 +880,7 @@ static int load_irix_library(struct file - kfree(elf_phdata); - return 0; - } -+#endif - - /* Called through irix_syssgi() to map an elf image given an FD, - * a phdr ptr USER_PHDRP in userspace, and a count CNT telling how many ---- a/arch/mips64/defconfig -+++ b/arch/mips64/defconfig -@@ -147,6 +147,7 @@ CONFIG_KCORE_ELF=y - # CONFIG_KCORE_AOUT is not set - # CONFIG_BINFMT_AOUT is not set - CONFIG_BINFMT_ELF=y -+# CONFIG_BINFMT_ELF_AOUT is not set - CONFIG_MIPS32_COMPAT=y - CONFIG_MIPS32_O32=y - # CONFIG_MIPS32_N32 is not set ---- a/arch/parisc/config.in -+++ b/arch/parisc/config.in -@@ -89,6 +89,9 @@ bool 'BSD Process Accounting' CONFIG_BSD - bool 'Sysctl support' CONFIG_SYSCTL - define_bool CONFIG_KCORE_ELF y - bool 'Kernel support for ELF binaries' CONFIG_BINFMT_ELF -+if [ "$CONFIG_BINFMT_ELF" != "n" ]; then -+ bool ' ELF binaries with a.out format interpreters or a.out libraries' CONFIG_BINFMT_ELF_AOUT -+fi - tristate 'Kernel support for SOM binaries' CONFIG_BINFMT_SOM - tristate 'Kernel support for MISC binaries' CONFIG_BINFMT_MISC - ---- a/arch/parisc/defconfig -+++ b/arch/parisc/defconfig -@@ -56,6 +56,7 @@ CONFIG_SYSVIPC=y - CONFIG_SYSCTL=y - CONFIG_KCORE_ELF=y - CONFIG_BINFMT_ELF=y -+# CONFIG_BINFMT_ELF_AOUT is not set - CONFIG_BINFMT_SOM=y - # CONFIG_BINFMT_MISC is not set - # CONFIG_PM is not set ---- a/arch/ppc/config.in -+++ b/arch/ppc/config.in -@@ -384,6 +384,7 @@ if [ "$CONFIG_PROC_FS" = "y" ]; then - fi - define_bool CONFIG_BINFMT_ELF y - define_bool CONFIG_KERNEL_ELF y -+bool 'ELF binaries with a.out format interpreters or a.out libraries' CONFIG_BINFMT_ELF_AOUT - tristate 'Kernel support for MISC binaries' CONFIG_BINFMT_MISC - bool 'Select task to kill on out of memory condition' CONFIG_OOM_KILLER - ---- a/arch/ppc/defconfig -+++ b/arch/ppc/defconfig -@@ -59,7 +59,8 @@ CONFIG_SYSVIPC=y - CONFIG_KCORE_ELF=y - CONFIG_BINFMT_ELF=y - CONFIG_KERNEL_ELF=y --CONFIG_BINFMT_MISC=m -+# CONFIG_BINFMT_ELF_AOUT is not set -+# CONFIG_BINFMT_MISC is not set - # CONFIG_OOM_KILLER is not set - CONFIG_PCI_NAMES=y - CONFIG_HOTPLUG=y ---- a/arch/ppc64/config.in -+++ b/arch/ppc64/config.in -@@ -82,6 +82,9 @@ if [ "$CONFIG_PROC_FS" = "y" ]; then - fi - - bool 'Kernel support for 64 bit ELF binaries' CONFIG_BINFMT_ELF -+if [ "$CONFIG_BINFMT_ELF" != "n" ]; then -+ bool ' ELF binaries with a.out format interpreters or a.out libraries' CONFIG_BINFMT_ELF_AOUT -+fi - - tristate 'Kernel support for 32 bit ELF binaries' CONFIG_BINFMT_ELF32 - ---- a/arch/ppc64/defconfig -+++ b/arch/ppc64/defconfig -@@ -56,6 +56,7 @@ CONFIG_SYSVIPC=y - # CONFIG_BSD_PROCESS_ACCT is not set - CONFIG_KCORE_ELF=y - CONFIG_BINFMT_ELF=y -+# CONFIG_BINFMT_ELF_AOUT is not set - CONFIG_BINFMT_ELF32=y - # CONFIG_BINFMT_MISC is not set - CONFIG_PCI_NAMES=y ---- a/arch/s390/config.in -+++ b/arch/s390/config.in -@@ -58,6 +58,9 @@ bool 'BSD Process Accounting' CONFIG_BSD - bool 'Sysctl support' CONFIG_SYSCTL - define_bool CONFIG_KCORE_ELF y - bool 'Kernel support for ELF binaries' CONFIG_BINFMT_ELF -+if [ "$CONFIG_BINFMT_ELF" != "n" ]; then -+ bool ' ELF binaries with a.out format interpreters or a.out libraries' CONFIG_BINFMT_ELF_AOUT -+fi - tristate 'Kernel support for MISC binaries' CONFIG_BINFMT_MISC - bool 'Show crashed user process info' CONFIG_PROCESS_DEBUG - bool 'Pseudo page fault support' CONFIG_PFAULT ---- a/arch/s390/defconfig -+++ b/arch/s390/defconfig -@@ -46,6 +46,7 @@ CONFIG_SYSVIPC=y - CONFIG_SYSCTL=y - CONFIG_KCORE_ELF=y - CONFIG_BINFMT_ELF=y -+# CONFIG_BINFMT_ELF_AOUT is not set - # CONFIG_BINFMT_MISC is not set - # CONFIG_PROCESS_DEBUG is not set - CONFIG_PFAULT=y ---- a/arch/s390x/config.in -+++ b/arch/s390x/config.in -@@ -61,6 +61,9 @@ bool 'BSD Process Accounting' CONFIG_BSD - bool 'Sysctl support' CONFIG_SYSCTL - define_bool CONFIG_KCORE_ELF y - bool 'Kernel support for ELF binaries' CONFIG_BINFMT_ELF -+if [ "$CONFIG_BINFMT_ELF" != "n" ]; then -+ bool ' ELF binaries with a.out format interpreters or a.out libraries' CONFIG_BINFMT_ELF_AOUT -+fi - tristate 'Kernel support for MISC binaries' CONFIG_BINFMT_MISC - bool 'Show crashed user process info' CONFIG_PROCESS_DEBUG - bool 'Pseudo page fault support' CONFIG_PFAULT ---- a/arch/s390x/defconfig -+++ b/arch/s390x/defconfig -@@ -47,6 +47,7 @@ CONFIG_SYSVIPC=y - CONFIG_SYSCTL=y - CONFIG_KCORE_ELF=y - CONFIG_BINFMT_ELF=y -+# CONFIG_BINFMT_ELF_AOUT is not set - # CONFIG_BINFMT_MISC is not set - # CONFIG_PROCESS_DEBUG is not set - CONFIG_PFAULT=y ---- a/arch/sh/config.in -+++ b/arch/sh/config.in -@@ -283,6 +283,9 @@ if [ "$CONFIG_PROC_FS" = "y" ]; then - A.OUT CONFIG_KCORE_AOUT" ELF - fi - bool 'Kernel support for ELF binaries' CONFIG_BINFMT_ELF -+if [ "$CONFIG_BINFMT_ELF" != "n" ]; then -+ bool ' ELF binaries with a.out format interpreters or a.out libraries' CONFIG_BINFMT_ELF_AOUT -+fi - tristate 'Kernel support for MISC binaries' CONFIG_BINFMT_MISC - - bool 'Select task to kill on out of memory condition' CONFIG_OOM_KILLER ---- a/arch/sh/defconfig -+++ b/arch/sh/defconfig -@@ -48,6 +48,7 @@ CONFIG_CF_ENABLER=y - CONFIG_KCORE_ELF=y - # CONFIG_KCORE_AOUT is not set - CONFIG_BINFMT_ELF=y -+# CONFIG_BINFMT_ELF_AOUT is not set - # CONFIG_BINFMT_MISC is not set - - # ---- a/arch/sparc/config.in -+++ b/arch/sparc/config.in -@@ -74,6 +74,9 @@ if [ "$CONFIG_PROC_FS" = "y" ]; then - fi - tristate 'Kernel support for a.out binaries' CONFIG_BINFMT_AOUT - bool 'Kernel support for ELF binaries' CONFIG_BINFMT_ELF -+if [ "$CONFIG_BINFMT_ELF" != "n" ]; then -+ bool ' ELF binaries with a.out format interpreters or a.out libraries' CONFIG_BINFMT_ELF_AOUT -+fi - tristate 'Kernel support for MISC binaries' CONFIG_BINFMT_MISC - bool 'SunOS binary emulation' CONFIG_SUNOS_EMUL - bool 'Select task to kill on out of memory condition' CONFIG_OOM_KILLER ---- a/arch/sparc/defconfig -+++ b/arch/sparc/defconfig -@@ -49,9 +49,10 @@ CONFIG_SYSVIPC=y - # CONFIG_BSD_PROCESS_ACCT is not set - CONFIG_SYSCTL=y - CONFIG_KCORE_ELF=y --CONFIG_BINFMT_AOUT=y -+# CONFIG_BINFMT_AOUT is not set - CONFIG_BINFMT_ELF=y --CONFIG_BINFMT_MISC=m -+# CONFIG_BINFMT_ELF_AOUT is not set -+# CONFIG_BINFMT_MISC is not set - CONFIG_SUNOS_EMUL=y - # CONFIG_OOM_KILLER is not set - ---- a/arch/sparc64/config.in -+++ b/arch/sparc64/config.in -@@ -79,6 +79,9 @@ if [ "$CONFIG_SPARC32_COMPAT" != "n" ]; - bool ' Kernel support for 32-bit (ie. SunOS) a.out binaries' CONFIG_BINFMT_AOUT32 - fi - bool 'Kernel support for 64-bit ELF binaries' CONFIG_BINFMT_ELF -+if [ "$CONFIG_BINFMT_ELF" != "n" ]; then -+ bool ' ELF binaries with a.out format interpreters or a.out libraries' CONFIG_BINFMT_ELF_AOUT -+fi - tristate 'Kernel support for MISC binaries' CONFIG_BINFMT_MISC - bool 'SunOS binary emulation' CONFIG_SUNOS_EMUL - if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then ---- a/arch/sparc64/defconfig -+++ b/arch/sparc64/defconfig -@@ -70,7 +70,8 @@ CONFIG_SPARC32_COMPAT=y - CONFIG_BINFMT_ELF32=y - # CONFIG_BINFMT_AOUT32 is not set - CONFIG_BINFMT_ELF=y --CONFIG_BINFMT_MISC=m -+# CONFIG_BINFMT_ELF_AOUT is not set -+# CONFIG_BINFMT_MISC is not set - # CONFIG_SUNOS_EMUL is not set - CONFIG_SOLARIS_EMUL=m - # CONFIG_OOM_KILLER is not set ---- a/arch/x86_64/config.in -+++ b/arch/x86_64/config.in -@@ -118,6 +118,9 @@ if [ "$CONFIG_PROC_FS" = "y" ]; then - fi - #tristate 'Kernel support for a.out binaries' CONFIG_BINFMT_AOUT - bool 'Kernel support for ELF binaries' CONFIG_BINFMT_ELF -+if [ "$CONFIG_BINFMT_ELF" != "n" ]; then -+ bool ' ELF binaries with a.out format interpreters or a.out libraries' CONFIG_BINFMT_ELF_AOUT -+fi - tristate 'Kernel support for MISC binaries' CONFIG_BINFMT_MISC - - bool 'Power Management support' CONFIG_PM ---- a/arch/x86_64/defconfig -+++ b/arch/x86_64/defconfig -@@ -67,6 +67,7 @@ CONFIG_SYSVIPC=y - CONFIG_SYSCTL=y - CONFIG_KCORE_ELF=y - CONFIG_BINFMT_ELF=y -+# CONFIG_BINFMT_ELF_AOUT is not set - # CONFIG_BINFMT_MISC is not set - CONFIG_PM=y - CONFIG_IA32_EMULATION=y ---- a/fs/binfmt_elf.c -+++ b/fs/binfmt_elf.c -@@ -9,6 +9,7 @@ - * Copyright 1993, 1994: Eric Youngdale (ericy@cais.com). - */ - -+#include <linux/config.h> - #include <linux/module.h> - - #include <linux/fs.h> -@@ -43,7 +44,9 @@ - #include <linux/elf.h> - - static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs); -+#ifdef CONFIG_BINFMT_ELF_AOUT - static int load_elf_library(struct file*); -+#endif - static unsigned long elf_map (struct file *, unsigned long, struct elf_phdr *, int, int); - extern int dump_fpu (struct pt_regs *, elf_fpregset_t *); - extern void dump_thread(struct pt_regs *, struct user *); -@@ -74,7 +77,13 @@ static int elf_core_dump(long signr, str - #define ELF_PAGEALIGN(_v) (((_v) + ELF_MIN_ALIGN - 1) & ~(ELF_MIN_ALIGN - 1)) - - static struct linux_binfmt elf_format = { -- NULL, THIS_MODULE, load_elf_binary, load_elf_library, elf_core_dump, ELF_EXEC_PAGESIZE -+ NULL, THIS_MODULE, load_elf_binary, -+#ifdef CONFIG_BINFMT_ELF_AOUT -+ load_elf_library, -+#else -+ NULL, -+#endif -+ elf_core_dump, ELF_EXEC_PAGESIZE - }; - - #define BAD_ADDR(x) ((unsigned long)(x) >= TASK_SIZE) -@@ -404,6 +413,7 @@ out: - return error; - } - -+#ifdef CONFIG_BINFMT_ELF_AOUT - static unsigned long load_aout_interp(struct exec * interp_ex, - struct file * interpreter) - { -@@ -451,6 +461,7 @@ static unsigned long load_aout_interp(st - out: - return elf_entry; - } -+#endif - - /* - * These are the functions used to load ELF style executables and shared -@@ -458,7 +469,9 @@ out: - */ - - #define INTERPRETER_NONE 0 -+#ifdef CONFIG_BINFMT_ELF_AOUT - #define INTERPRETER_AOUT 1 -+#endif - #define INTERPRETER_ELF 2 - - -@@ -482,7 +495,9 @@ static int load_elf_binary(struct linux_ - struct elfhdr elf_ex; - struct elfhdr interp_elf_ex; - struct exec interp_ex; -+#ifdef CONFIG_BINFMT_ELF_AOUT - char passed_fileno[6]; -+#endif - struct files_struct *files; - - /* Get the exec-header */ -@@ -612,6 +627,7 @@ static int load_elf_binary(struct linux_ - - /* Some simple consistency checks for the interpreter */ - if (elf_interpreter) { -+#ifdef CONFIG_BINFMT_ELF_AOUT - interpreter_type = INTERPRETER_ELF | INTERPRETER_AOUT; - - /* Now figure out which format our binary is */ -@@ -619,6 +635,9 @@ static int load_elf_binary(struct linux_ - (N_MAGIC(interp_ex) != ZMAGIC) && - (N_MAGIC(interp_ex) != QMAGIC)) - interpreter_type = INTERPRETER_ELF; -+#else -+ interpreter_type = INTERPRETER_ELF; -+#endif - - if (memcmp(interp_elf_ex.e_ident, ELFMAG, SELFMAG) != 0) - interpreter_type &= ~INTERPRETER_ELF; -@@ -627,6 +646,7 @@ static int load_elf_binary(struct linux_ - if (!interpreter_type) - goto out_free_dentry; - -+#ifdef CONFIG_BINFMT_ELF_AOUT - /* Make sure only one type was selected */ - if ((interpreter_type & INTERPRETER_ELF) && - interpreter_type != INTERPRETER_ELF) { -@@ -634,6 +654,7 @@ static int load_elf_binary(struct linux_ - // printk(KERN_WARNING "ELF: Ambiguous type, using ELF\n"); - interpreter_type = INTERPRETER_ELF; - } -+#endif - /* Verify the interpreter has a valid arch */ - if ((interpreter_type == INTERPRETER_ELF) && - !elf_check_arch(&interp_elf_ex)) -@@ -651,6 +672,7 @@ static int load_elf_binary(struct linux_ - /* OK, we are done with that, now set up the arg stuff, - and then start this sucker up */ - -+#ifdef CONFIG_BINFMT_ELF_AOUT - if (!bprm->sh_bang) { - char * passed_p; - -@@ -669,6 +691,7 @@ static int load_elf_binary(struct linux_ - /* Executables without an interpreter also need a personality */ - SET_PERSONALITY(elf_ex, ibcs2_interpreter); - } -+#endif - - /* Flush all traces of the currently running executable */ - retval = flush_old_exec(bprm); -@@ -817,10 +840,12 @@ static int load_elf_binary(struct linux_ - padzero(elf_bss); - - if (elf_interpreter) { -+#ifdef CONFIG_BINFMT_ELF_AOUT - if (interpreter_type == INTERPRETER_AOUT) - elf_entry = load_aout_interp(&interp_ex, - interpreter); - else -+#endif - elf_entry = load_elf_interp(&interp_elf_ex, - interpreter, - &interp_load_addr); -@@ -849,7 +874,9 @@ static int load_elf_binary(struct linux_ - - kfree(elf_phdata); - -+#ifdef CONFIG_BINFMT_ELF_AOUT - if (interpreter_type != INTERPRETER_AOUT) -+#endif - sys_close(elf_exec_fileno); - - set_binfmt(&elf_format); -@@ -863,10 +890,14 @@ static int load_elf_binary(struct linux_ - &elf_ex, - load_addr, load_bias, - interp_load_addr, -+#ifdef CONFIG_BINFMT_ELF_AOUT - (interpreter_type == INTERPRETER_AOUT ? 0 : 1)); - /* N.B. passed_fileno might not be initialized? */ - if (interpreter_type == INTERPRETER_AOUT) - current->mm->arg_start += strlen(passed_fileno) + 1; -+#else -+ 1); -+#endif - current->mm->start_brk = current->mm->brk = elf_brk; - current->mm->end_code = end_code; - current->mm->start_code = start_code; -@@ -937,9 +968,9 @@ out_free_ph: - goto out; - } - -+#ifdef CONFIG_BINFMT_ELF_AOUT - /* This is really simpleminded and specialized - we are loading an - a.out library that is given an ELF header. */ -- - static int load_elf_library(struct file *file) - { - struct elf_phdr *elf_phdata; -@@ -1016,6 +1047,7 @@ out_free_ph: - out: - return error; - } -+#endif - - /* - * Note that some platforms still use traditional core dumps and not ---- a/fs/exec.c -+++ b/fs/exec.c -@@ -109,6 +109,7 @@ static inline void put_binfmt(struct lin - */ - asmlinkage long sys_uselib(const char * library) - { -+#if defined(CONFIG_BINFMT_AOUT) || defined(CONFIG_BINFMT_ELF_AOUT) - struct file * file; - struct nameidata nd; - int error; -@@ -155,6 +156,9 @@ out: - exit: - path_release(&nd); - goto out; -+#else -+ return -ENOSYS; -+#endif - } - - /* diff --git a/target/linux/generic-2.4/patches/109-ipsec_nat_traversal.patch b/target/linux/generic-2.4/patches/109-ipsec_nat_traversal.patch deleted file mode 100644 index 51981b8..0000000 --- a/target/linux/generic-2.4/patches/109-ipsec_nat_traversal.patch +++ /dev/null @@ -1,141 +0,0 @@ -packaging/utils/nattpatch 2.4 ---- a/include/net/sock.h -+++ b/include/net/sock.h -@@ -488,7 +488,13 @@ struct tcp_opt { - } bictcp; - }; - -- -+#if 1 -+#define UDP_OPT_IN_SOCK 1 -+struct udp_opt { -+ __u32 esp_in_udp; -+}; -+#endif -+ - /* - * This structure really needs to be cleaned up. - * Most of it is for TCP, and not used by any of -@@ -655,6 +661,9 @@ struct sock { - #if defined(CONFIG_SPX) || defined (CONFIG_SPX_MODULE) - struct spx_opt af_spx; - #endif /* CONFIG_SPX */ -+#if 1 -+ struct udp_opt af_udp; -+#endif - - } tp_pinfo; - ---- a/net/Config.in -+++ b/net/Config.in -@@ -104,4 +104,6 @@ comment 'Network testing' - dep_tristate 'Packet Generator (USE WITH CAUTION)' CONFIG_NET_PKTGEN $CONFIG_PROC_FS - endmenu - -+bool 'IPSEC NAT-Traversal' CONFIG_IPSEC_NAT_TRAVERSAL -+ - endmenu ---- a/net/ipv4/udp.c -+++ b/net/ipv4/udp.c -@@ -860,6 +860,9 @@ static void udp_close(struct sock *sk, l - - static int udp_queue_rcv_skb(struct sock * sk, struct sk_buff *skb) - { -+#ifdef CONFIG_IPSEC_NAT_TRAVERSAL -+ struct udp_opt *tp = &(sk->tp_pinfo.af_udp); -+#endif - /* - * Charge it to the socket, dropping if the queue is full. - */ -@@ -877,6 +880,40 @@ static int udp_queue_rcv_skb(struct sock - } - #endif - -+#ifdef CONFIG_IPSEC_NAT_TRAVERSAL -+ if (tp->esp_in_udp) { -+ /* -+ * Set skb->sk and xmit packet to ipsec_rcv. -+ * -+ * If ret != 0, ipsec_rcv refused the packet (not ESPinUDP), -+ * restore skb->sk and fall back to sock_queue_rcv_skb -+ */ -+ struct inet_protocol *esp = NULL; -+ -+#if defined(CONFIG_KLIPS) && !defined(CONFIG_KLIPS_MODULE) -+ /* optomize only when we know it is statically linked */ -+ extern struct inet_protocol esp_protocol; -+ esp = &esp_protocol; -+#else -+ for (esp = (struct inet_protocol *)inet_protos[IPPROTO_ESP & (MAX_INET_PROTOS - 1)]; -+ (esp) && (esp->protocol != IPPROTO_ESP); -+ esp = esp->next); -+#endif -+ -+ if (esp && esp->handler) { -+ struct sock *sav_sk = skb->sk; -+ skb->sk = sk; -+ if (esp->handler(skb) == 0) { -+ skb->sk = sav_sk; -+ /*not sure we might count ESPinUDP as UDP...*/ -+ UDP_INC_STATS_BH(UdpInDatagrams); -+ return 0; -+ } -+ skb->sk = sav_sk; -+ } -+ } -+#endif -+ - if (sock_queue_rcv_skb(sk,skb)<0) { - UDP_INC_STATS_BH(UdpInErrors); - IP_INC_STATS_BH(IpInDiscards); -@@ -1100,13 +1137,49 @@ out: - return len; - } - -+static int udp_setsockopt(struct sock *sk, int level, int optname, -+ char *optval, int optlen) -+{ -+ struct udp_opt *tp = &(sk->tp_pinfo.af_udp); -+ int val; -+ int err = 0; -+ -+ if (level != SOL_UDP) -+ return ip_setsockopt(sk, level, optname, optval, optlen); -+ -+ if(optlen<sizeof(int)) -+ return -EINVAL; -+ -+ if (get_user(val, (int *)optval)) -+ return -EFAULT; -+ -+ lock_sock(sk); -+ -+ switch(optname) { -+#ifdef CONFIG_IPSEC_NAT_TRAVERSAL -+#ifndef UDP_ESPINUDP -+#define UDP_ESPINUDP 100 -+#endif -+ case UDP_ESPINUDP: -+ tp->esp_in_udp = val; -+ break; -+#endif -+ default: -+ err = -ENOPROTOOPT; -+ break; -+ } -+ -+ release_sock(sk); -+ return err; -+} -+ - struct proto udp_prot = { - name: "UDP", - close: udp_close, - connect: udp_connect, - disconnect: udp_disconnect, - ioctl: udp_ioctl, -- setsockopt: ip_setsockopt, -+ setsockopt: udp_setsockopt, - getsockopt: ip_getsockopt, - sendmsg: udp_sendmsg, - recvmsg: udp_recvmsg, diff --git a/target/linux/generic-2.4/patches/110-netdev_random_core.patch b/target/linux/generic-2.4/patches/110-netdev_random_core.patch deleted file mode 100644 index 06f3e4e..0000000 --- a/target/linux/generic-2.4/patches/110-netdev_random_core.patch +++ /dev/null @@ -1,289 +0,0 @@ ---- a/Documentation/Configure.help -+++ b/Documentation/Configure.help -@@ -10687,6 +10687,20 @@ CONFIG_TUN - - If you don't know what to use this for, you don't need it. - -+Allow Net Devices to contribute to /dev/random -+CONFIG_NET_RANDOM -+ If you say Y here, network device interrupts will contribute to the -+ kernel entropy pool. Normally, block devices and some other devices -+ feed the pool. Some systems, such as those that are headless or diskless, -+ need additional entropy sources. Some people, however, feel that network -+ devices should not contribute to /dev/random because an external attacker -+ could observe incoming packets in an attempt to learn the entropy pool's -+ state. If you say N, no network device will contribute entropy. -+ -+ If you believe there is a chance of your network packets being observed -+ and you doubt the security of the entropy pool's one-way hash, do not -+ enable this. If unsure, say N. -+ - Ethertap network tap (OBSOLETE) - CONFIG_ETHERTAP - If you say Y here (and have said Y to "Kernel/User network link ---- a/drivers/net/Config.in -+++ b/drivers/net/Config.in -@@ -8,6 +8,7 @@ tristate 'Dummy net driver support' CONF - tristate 'Bonding driver support' CONFIG_BONDING - tristate 'EQL (serial line load balancing) support' CONFIG_EQUALIZER - tristate 'Universal TUN/TAP device driver support' CONFIG_TUN -+bool 'Allow Net Devices to contribute to /dev/random' CONFIG_NET_RANDOM - if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then - tristate 'Ethertap network tap (OBSOLETE)' CONFIG_ETHERTAP - fi ---- a/include/asm-alpha/signal.h -+++ b/include/asm-alpha/signal.h -@@ -121,8 +121,15 @@ typedef unsigned long sigset_t; - #define SA_PROBE SA_ONESHOT - #define SA_SAMPLE_RANDOM SA_RESTART - #define SA_SHIRQ 0x40000000 -+ -+#ifdef CONFIG_NET_RANDOM -+#define SA_NET_RANDOM SA_SAMPLE_RANDOM -+#else -+#define SA_NET_RANDOM 0 - #endif - -+#endif /* __KERNEL__ */ -+ - #define SIG_BLOCK 1 /* for blocking signals */ - #define SIG_UNBLOCK 2 /* for unblocking signals */ - #define SIG_SETMASK 3 /* for setting the signal mask */ ---- a/include/asm-arm/signal.h -+++ b/include/asm-arm/signal.h -@@ -125,8 +125,15 @@ typedef unsigned long sigset_t; - #define SA_PROBE 0x80000000 - #define SA_SAMPLE_RANDOM 0x10000000 - #define SA_SHIRQ 0x04000000 -+ -+#ifdef CONFIG_NET_RANDOM -+#define SA_NET_RANDOM SA_SAMPLE_RANDOM -+#else -+#define SA_NET_RANDOM 0 - #endif - -+#endif /* __KERNEL__ */ -+ - #define SIG_BLOCK 0 /* for blocking signals */ - #define SIG_UNBLOCK 1 /* for unblocking signals */ - #define SIG_SETMASK 2 /* for setting the signal mask */ ---- a/include/asm-cris/signal.h -+++ b/include/asm-cris/signal.h -@@ -120,8 +120,15 @@ typedef unsigned long sigset_t; - #define SA_PROBE SA_ONESHOT - #define SA_SAMPLE_RANDOM SA_RESTART - #define SA_SHIRQ 0x04000000 -+ -+#ifdef CONFIG_NET_RANDOM -+#define SA_NET_RANDOM SA_SAMPLE_RANDOM -+#else -+#define SA_NET_RANDOM 0 - #endif - -+#endif /* __KERNEL__ */ -+ - #define SIG_BLOCK 0 /* for blocking signals */ - #define SIG_UNBLOCK 1 /* for unblocking signals */ - #define SIG_SETMASK 2 /* for setting the signal mask */ ---- a/include/asm-i386/signal.h -+++ b/include/asm-i386/signal.h -@@ -119,8 +119,15 @@ typedef unsigned long sigset_t; - #define SA_PROBE SA_ONESHOT - #define SA_SAMPLE_RANDOM SA_RESTART - #define SA_SHIRQ 0x04000000 -+ -+#ifdef CONFIG_NET_RANDOM -+#define SA_NET_RANDOM SA_SAMPLE_RANDOM -+#else -+#define SA_NET_RANDOM 0 - #endif - -+#endif /* __KERNEL__ */ -+ - #define SIG_BLOCK 0 /* for blocking signals */ - #define SIG_UNBLOCK 1 /* for unblocking signals */ - #define SIG_SETMASK 2 /* for setting the signal mask */ ---- a/include/asm-ia64/signal.h -+++ b/include/asm-ia64/signal.h -@@ -117,6 +117,12 @@ - #define SA_SHIRQ 0x04000000 - #define SA_PERCPU_IRQ 0x02000000 - -+#ifdef CONFIG_NET_RANDOM -+#define SA_NET_RANDOM SA_SAMPLE_RANDOM -+#else -+#define SA_NET_RANDOM 0 -+#endif -+ - #endif /* __KERNEL__ */ - - #define SIG_BLOCK 0 /* for blocking signals */ ---- a/include/asm-m68k/signal.h -+++ b/include/asm-m68k/signal.h -@@ -116,8 +116,15 @@ typedef unsigned long sigset_t; - #define SA_PROBE SA_ONESHOT - #define SA_SAMPLE_RANDOM SA_RESTART - #define SA_SHIRQ 0x04000000 -+ -+#ifdef CONFIG_NET_RANDOM -+#define SA_NET_RANDOM SA_SAMPLE_RANDOM -+#else -+#define SA_NET_RANDOM 0 - #endif - -+#endif /* __KERNEL__ */ -+ - #define SIG_BLOCK 0 /* for blocking signals */ - #define SIG_UNBLOCK 1 /* for unblocking signals */ - #define SIG_SETMASK 2 /* for setting the signal mask */ ---- a/include/asm-mips/signal.h -+++ b/include/asm-mips/signal.h -@@ -111,6 +111,12 @@ typedef unsigned long old_sigset_t; /* - #define SA_SAMPLE_RANDOM SA_RESTART - #define SA_SHIRQ 0x02000000 - -+#ifdef CONFIG_NET_RANDOM -+#define SA_NET_RANDOM SA_SAMPLE_RANDOM -+#else -+#define SA_NET_RANDOM 0 -+#endif -+ - #endif /* __KERNEL__ */ - - #define SIG_BLOCK 1 /* for blocking signals */ ---- a/include/asm-mips64/signal.h -+++ b/include/asm-mips64/signal.h -@@ -119,6 +119,12 @@ typedef unsigned int old_sigset_t32; - #define SA_SAMPLE_RANDOM SA_RESTART - #define SA_SHIRQ 0x02000000 - -+#ifdef CONFIG_NET_RANDOM -+#define SA_NET_RANDOM SA_SAMPLE_RANDOM -+#else -+#define SA_NET_RANDOM 0 -+#endif -+ - #endif /* __KERNEL__ */ - - #define SIG_BLOCK 1 /* for blocking signals */ ---- a/include/asm-parisc/signal.h -+++ b/include/asm-parisc/signal.h -@@ -100,6 +100,12 @@ - #define SA_SAMPLE_RANDOM SA_RESTART - #define SA_SHIRQ 0x04000000 - -+#ifdef CONFIG_NET_RANDOM -+#define SA_NET_RANDOM SA_SAMPLE_RANDOM -+#else -+#define SA_NET_RANDOM 0 -+#endif -+ - #endif /* __KERNEL__ */ - - #define SIG_BLOCK 0 /* for blocking signals */ ---- a/include/asm-ppc/signal.h -+++ b/include/asm-ppc/signal.h -@@ -111,6 +111,13 @@ typedef struct { - #define SA_PROBE SA_ONESHOT - #define SA_SAMPLE_RANDOM SA_RESTART - #define SA_SHIRQ 0x04000000 -+ -+#ifdef CONFIG_NET_RANDOM -+#define SA_NET_RANDOM SA_SAMPLE_RANDOM -+#else -+#define SA_NET_RANDOM 0 -+#endif -+ - #endif /* __KERNEL__ */ - - #define SIG_BLOCK 0 /* for blocking signals */ ---- a/include/asm-s390/signal.h -+++ b/include/asm-s390/signal.h -@@ -129,8 +129,15 @@ typedef unsigned long sigset_t; - #define SA_SHIRQ 0x04000000 - #define SA_DOPATHGROUP 0x00100000 - #define SA_FORCE 0x00200000 -+ -+#ifdef CONFIG_NET_RANDOM -+#define SA_NET_RANDOM SA_SAMPLE_RANDOM -+#else -+#define SA_NET_RANDOM 0 - #endif - -+#endif /* __KERNEL__ */ -+ - #define SIG_BLOCK 0 /* for blocking signals */ - #define SIG_UNBLOCK 1 /* for unblocking signals */ - #define SIG_SETMASK 2 /* for setting the signal mask */ ---- a/include/asm-s390x/signal.h -+++ b/include/asm-s390x/signal.h -@@ -129,8 +129,15 @@ typedef unsigned long sigset_t; - #define SA_SHIRQ 0x04000000 - #define SA_DOPATHGROUP 0x00100000 - #define SA_FORCE 0x00200000 -+ -+#ifdef CONFIG_NET_RANDOM -+#define SA_NET_RANDOM SA_SAMPLE_RANDOM -+#else -+#define SA_NET_RANDOM 0 - #endif - -+#endif /* __KERNEL__ */ -+ - #define SIG_BLOCK 0 /* for blocking signals */ - #define SIG_UNBLOCK 1 /* for unblocking signals */ - #define SIG_SETMASK 2 /* for setting the signal mask */ ---- a/include/asm-sh/signal.h -+++ b/include/asm-sh/signal.h -@@ -107,8 +107,15 @@ typedef struct { - #define SA_PROBE SA_ONESHOT - #define SA_SAMPLE_RANDOM SA_RESTART - #define SA_SHIRQ 0x04000000 -+ -+#ifdef CONFIG_NET_RANDOM -+#define SA_NET_RANDOM SA_SAMPLE_RANDOM -+#else -+#define SA_NET_RANDOM 0 - #endif - -+#endif /* __KERNEL__ */ -+ - #define SIG_BLOCK 0 /* for blocking signals */ - #define SIG_UNBLOCK 1 /* for unblocking signals */ - #define SIG_SETMASK 2 /* for setting the signal mask */ ---- a/include/asm-sparc/signal.h -+++ b/include/asm-sparc/signal.h -@@ -176,8 +176,15 @@ struct sigstack { - #define SA_PROBE SA_ONESHOT - #define SA_SAMPLE_RANDOM SA_RESTART - #define SA_STATIC_ALLOC 0x80 -+ -+#ifdef CONFIG_NET_RANDOM -+#define SA_NET_RANDOM SA_SAMPLE_RANDOM -+#else -+#define SA_NET_RANDOM 0 - #endif - -+#endif /* __KERNEL__ */ -+ - /* Type of a signal handler. */ - #ifdef __KERNEL__ - typedef void (*__sighandler_t)(int, int, struct sigcontext *, char *); ---- a/include/asm-sparc64/signal.h -+++ b/include/asm-sparc64/signal.h -@@ -192,8 +192,15 @@ struct sigstack { - #define SA_PROBE SA_ONESHOT - #define SA_SAMPLE_RANDOM SA_RESTART - #define SA_STATIC_ALLOC 0x80 -+ -+#ifdef CONFIG_NET_RANDOM -+#define SA_NET_RANDOM SA_SAMPLE_RANDOM -+#else -+#define SA_NET_RANDOM 0 - #endif - -+#endif /* __KERNEL__ */ -+ - /* Type of a signal handler. */ - #ifdef __KERNEL__ - typedef void (*__sighandler_t)(int, struct sigcontext *); diff --git a/target/linux/generic-2.4/patches/112-bridging_performance.patch b/target/linux/generic-2.4/patches/112-bridging_performance.patch deleted file mode 100644 index 9e15d6c..0000000 --- a/target/linux/generic-2.4/patches/112-bridging_performance.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/net/core/dev.c -+++ b/net/core/dev.c -@@ -1289,6 +1289,19 @@ int netif_rx(struct sk_buff *skb) - local_irq_save(flags); - - netdev_rx_stat[this_cpu].total++; -+ -+#ifdef CONFIG_BRIDGE -+ /* Optimisation for framebursting (allow interleaving of pkts by -+ * immediately processing the rx pkt instead of Qing the pkt and deferring -+ * the processing). Only optimise for bridging and guard against non -+ * TASKLET based netif_rx calls. -+ */ -+ if (!in_irq() && (skb->dev->br_port != NULL) && br_handle_frame_hook != NULL) { -+ local_irq_restore(flags); -+ return netif_receive_skb(skb); -+ } -+#endif -+ - if (queue->input_pkt_queue.qlen <= netdev_max_backlog) { - if (queue->input_pkt_queue.qlen) { - if (queue->throttle) diff --git a/target/linux/generic-2.4/patches/113-even_more_gcc4_stuff.patch b/target/linux/generic-2.4/patches/113-even_more_gcc4_stuff.patch deleted file mode 100644 index 62a6e21..0000000 --- a/target/linux/generic-2.4/patches/113-even_more_gcc4_stuff.patch +++ /dev/null @@ -1,359 +0,0 @@ ---- a/arch/mips/kernel/mips_ksyms.c -+++ b/arch/mips/kernel/mips_ksyms.c -@@ -30,6 +30,10 @@ - #include <asm/floppy.h> - #endif - -+asmlinkage long long __ashldi3 (long long, int); -+asmlinkage long long __ashrdi3 (long long, int); -+asmlinkage long long __lshrdi3 (long long, int); -+asmlinkage long long __muldi3 (long long, long long); - extern void *__bzero(void *__s, size_t __count); - extern long __strncpy_from_user_nocheck_asm(char *__to, - const char *__from, long __len); -@@ -78,6 +82,13 @@ EXPORT_SYMBOL_NOVERS(__strnlen_user_noch - EXPORT_SYMBOL_NOVERS(__strnlen_user_asm); - - -+/* Compiler stuff */ -+EXPORT_SYMBOL_NOVERS(__ashldi3); -+EXPORT_SYMBOL_NOVERS(__ashrdi3); -+EXPORT_SYMBOL_NOVERS(__lshrdi3); -+EXPORT_SYMBOL_NOVERS(__muldi3); -+ -+ - /* Networking helper routines. */ - EXPORT_SYMBOL(csum_partial_copy); - ---- a/arch/mips/lib/Makefile -+++ b/arch/mips/lib/Makefile -@@ -9,7 +9,8 @@ L_TARGET = lib.a - obj-y += csum_partial.o csum_partial_copy.o \ - promlib.o rtc-std.o rtc-no.o memcpy.o \ - memset.o watch.o strlen_user.o \ -- strncpy_user.o strnlen_user.o -+ strncpy_user.o strnlen_user.o \ -+ ashldi3.o ashrdi3.o lshrdi3.o muldi3.o - - export-objs := rtc-std.o rtc-no.o - ---- /dev/null -+++ b/arch/mips/lib/ashldi3.c -@@ -0,0 +1,62 @@ -+/* ashrdi3.c extracted from gcc-2.95.2/libgcc2.c which is: */ -+/* Copyright (C) 1989, 92-98, 1999 Free Software Foundation, Inc. -+ -+This file is part of GNU CC. -+ -+GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -+the Free Software Foundation, 59 Temple Place - Suite 330, -+Boston, MA 02111-1307, USA. */ -+ -+#define BITS_PER_UNIT 8 -+ -+typedef int SItype __attribute__ ((mode (SI))); -+typedef unsigned int USItype __attribute__ ((mode (SI))); -+typedef int DItype __attribute__ ((mode (DI))); -+typedef int word_type __attribute__ ((mode (__word__))); -+ -+struct DIstruct {SItype high, low;}; -+ -+typedef union -+{ -+ struct DIstruct s; -+ DItype ll; -+} DIunion; -+ -+DItype -+__ashldi3 (DItype u, word_type b) -+{ -+ DIunion w; -+ word_type bm; -+ DIunion uu; -+ -+ if (b == 0) -+ return u; -+ -+ uu.ll = u; -+ -+ bm = (sizeof (SItype) * BITS_PER_UNIT) - b; -+ if (bm <= 0) -+ { -+ w.s.low = 0; -+ w.s.high = (USItype)uu.s.low << -bm; -+ } -+ else -+ { -+ USItype carries = (USItype)uu.s.low >> bm; -+ w.s.low = (USItype)uu.s.low << b; -+ w.s.high = ((USItype)uu.s.high << b) | carries; -+ } -+ -+ return w.ll; -+} ---- /dev/null -+++ b/arch/mips/lib/ashrdi3.c -@@ -0,0 +1,63 @@ -+/* ashrdi3.c extracted from gcc-2.7.2/libgcc2.c which is: */ -+/* Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. -+ -+This file is part of GNU CC. -+ -+GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -+the Free Software Foundation, 59 Temple Place - Suite 330, -+Boston, MA 02111-1307, USA. */ -+ -+#define BITS_PER_UNIT 8 -+ -+typedef int SItype __attribute__ ((mode (SI))); -+typedef unsigned int USItype __attribute__ ((mode (SI))); -+typedef int DItype __attribute__ ((mode (DI))); -+typedef int word_type __attribute__ ((mode (__word__))); -+ -+struct DIstruct {SItype high, low;}; -+ -+typedef union -+{ -+ struct DIstruct s; -+ DItype ll; -+} DIunion; -+ -+DItype -+__ashrdi3 (DItype u, word_type b) -+{ -+ DIunion w; -+ word_type bm; -+ DIunion uu; -+ -+ if (b == 0) -+ return u; -+ -+ uu.ll = u; -+ -+ bm = (sizeof (SItype) * BITS_PER_UNIT) - b; -+ if (bm <= 0) -+ { -+ /* w.s.high = 1..1 or 0..0 */ -+ w.s.high = uu.s.high >> (sizeof (SItype) * BITS_PER_UNIT - 1); -+ w.s.low = uu.s.high >> -bm; -+ } -+ else -+ { -+ USItype carries = (USItype)uu.s.high << bm; -+ w.s.high = uu.s.high >> b; -+ w.s.low = ((USItype)uu.s.low >> b) | carries; -+ } -+ -+ return w.ll; -+} ---- /dev/null -+++ b/arch/mips/lib/lshrdi3.c -@@ -0,0 +1,62 @@ -+/* lshrdi3.c extracted from gcc-2.7.2/libgcc2.c which is: */ -+/* Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. -+ -+This file is part of GNU CC. -+ -+GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -+the Free Software Foundation, 59 Temple Place - Suite 330, -+Boston, MA 02111-1307, USA. */ -+ -+#define BITS_PER_UNIT 8 -+ -+typedef int SItype __attribute__ ((mode (SI))); -+typedef unsigned int USItype __attribute__ ((mode (SI))); -+typedef int DItype __attribute__ ((mode (DI))); -+typedef int word_type __attribute__ ((mode (__word__))); -+ -+struct DIstruct {SItype high, low;}; -+ -+typedef union -+{ -+ struct DIstruct s; -+ DItype ll; -+} DIunion; -+ -+DItype -+__lshrdi3 (DItype u, word_type b) -+{ -+ DIunion w; -+ word_type bm; -+ DIunion uu; -+ -+ if (b == 0) -+ return u; -+ -+ uu.ll = u; -+ -+ bm = (sizeof (SItype) * BITS_PER_UNIT) - b; -+ if (bm <= 0) -+ { -+ w.s.high = 0; -+ w.s.low = (USItype)uu.s.high >> -bm; -+ } -+ else -+ { -+ USItype carries = (USItype)uu.s.high << bm; -+ w.s.high = (USItype)uu.s.high >> b; -+ w.s.low = ((USItype)uu.s.low >> b) | carries; -+ } -+ -+ return w.ll; -+} ---- /dev/null -+++ b/arch/mips/lib/muldi3.c -@@ -0,0 +1,63 @@ -+/* muldi3.c extracted from gcc-2.7.2.3/libgcc2.c and -+ gcc-2.7.2.3/longlong.h which is: */ -+/* Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. -+ -+This file is part of GNU CC. -+ -+GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -+the Free Software Foundation, 59 Temple Place - Suite 330, -+Boston, MA 02111-1307, USA. */ -+ -+#define BITS_PER_UNIT 8 -+ -+#define umul_ppmm(w1, w0, u, v) \ -+ __asm__ ("multu %2,%3" \ -+ : "=l" ((USItype)(w0)), \ -+ "=h" ((USItype)(w1)) \ -+ : "d" ((USItype)(u)), \ -+ "d" ((USItype)(v))) -+ -+#define __umulsidi3(u, v) \ -+ ({DIunion __w; \ -+ umul_ppmm (__w.s.high, __w.s.low, u, v); \ -+ __w.ll; }) -+ -+typedef int SItype __attribute__ ((mode (SI))); -+typedef unsigned int USItype __attribute__ ((mode (SI))); -+typedef int DItype __attribute__ ((mode (DI))); -+typedef int word_type __attribute__ ((mode (__word__))); -+ -+struct DIstruct {SItype high, low;}; -+ -+typedef union -+{ -+ struct DIstruct s; -+ DItype ll; -+} DIunion; -+ -+DItype -+__muldi3 (DItype u, DItype v) -+{ -+ DIunion w; -+ DIunion uu, vv; -+ -+ uu.ll = u, -+ vv.ll = v; -+ -+ w.ll = __umulsidi3 (uu.s.low, vv.s.low); -+ w.s.high += ((USItype) uu.s.low * (USItype) vv.s.high -+ + (USItype) uu.s.high * (USItype) vv.s.low); -+ -+ return w.ll; -+} ---- a/fs/cifs/cifsfs.c -+++ b/fs/cifs/cifsfs.c -@@ -50,8 +50,6 @@ - static struct quotactl_ops cifs_quotactl_ops; - #endif - --extern struct file_system_type cifs_fs_type; -- - int cifsFYI = 0; - int cifsERROR = 1; - int traceSMB = 0; ---- a/include/asm-mips/uaccess.h -+++ b/include/asm-mips/uaccess.h -@@ -149,7 +149,7 @@ static inline int verify_area(int type, - * Returns zero on success, or -EFAULT on error. - */ - #define put_user(x,ptr) \ -- __put_user_check((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr))) -+ __put_user_check((x),(ptr),sizeof(*(ptr))) - - /* - * get_user: - Get a simple variable from user space. -@@ -169,7 +169,7 @@ static inline int verify_area(int type, - * On error, the variable @x is set to zero. - */ - #define get_user(x,ptr) \ -- __get_user_check((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr))) -+ __get_user_check((x),(ptr),sizeof(*(ptr))) - - /* - * __put_user: - Write a simple value into user space, with less checking. -@@ -191,7 +191,7 @@ static inline int verify_area(int type, - * Returns zero on success, or -EFAULT on error. - */ - #define __put_user(x,ptr) \ -- __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr))) -+ __put_user_nocheck((x),(ptr),sizeof(*(ptr))) - - /* - * __get_user: - Get a simple variable from user space, with less checking. -@@ -214,7 +214,7 @@ static inline int verify_area(int type, - * On error, the variable @x is set to zero. - */ - #define __get_user(x,ptr) \ -- __get_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr))) -+ __get_user_nocheck((x),(ptr),sizeof(*(ptr))) - - struct __large_struct { unsigned long buf[100]; }; - #define __m(x) (*(struct __large_struct *)(x)) -@@ -232,7 +232,7 @@ struct __large_struct { unsigned long bu - #define __get_user_nocheck(x,ptr,size) \ - ({ \ - long __gu_err = 0; \ -- __typeof(*(ptr)) __gu_val = 0; \ -+ __typeof(*(ptr)) __gu_val = (__typeof(*(ptr))) 0; \ - long __gu_addr; \ - __gu_addr = (long) (ptr); \ - switch (size) { \ diff --git a/target/linux/generic-2.4/patches/114-sched_use_tsc.patch b/target/linux/generic-2.4/patches/114-sched_use_tsc.patch deleted file mode 100644 index 211b30b..0000000 --- a/target/linux/generic-2.4/patches/114-sched_use_tsc.patch +++ /dev/null @@ -1,81 +0,0 @@ ---- a/arch/mips/kernel/time.c -+++ b/arch/mips/kernel/time.c -@@ -151,6 +151,27 @@ void (*mips_timer_ack)(void); - unsigned int (*mips_hpt_read)(void); - void (*mips_hpt_init)(unsigned int); - -+extern __u32 get_htscl(void) -+{ -+ return timerhi; -+} -+ -+static __u64 tscll_last = 0; -+ -+extern __u64 get_tscll(void) -+{ -+ __u64 h = (__u64) timerhi; -+ __u32 c = read_c0_count(); -+ -+ h <<= 32; -+ h += c; -+ -+ while (h < tscll_last) -+ h += (((__u64) 1) << 32); -+ -+ tscll_last = h; -+ return h; -+} - - /* - * timeofday services, for syscalls. -@@ -761,3 +782,5 @@ EXPORT_SYMBOL(rtc_lock); - EXPORT_SYMBOL(to_tm); - EXPORT_SYMBOL(rtc_set_time); - EXPORT_SYMBOL(rtc_get_time); -+EXPORT_SYMBOL(get_htscl); -+EXPORT_SYMBOL(get_tscll); ---- a/include/asm-mips/timex.h -+++ b/include/asm-mips/timex.h -@@ -31,6 +31,19 @@ static inline cycles_t get_cycles (void) - return read_c0_count(); - } - -+extern __u32 get_htscl(void); -+extern __u64 get_tscll(void); -+ -+#define rdtsc(low, high) \ -+ high = get_htscl(); \ -+ low = read_c0_count(); -+ -+#define rdtscl(low) \ -+ low = read_c0_count(); -+ -+#define rdtscll(val) \ -+ val = get_tscll(); -+ - #define vxtime_lock() do {} while (0) - #define vxtime_unlock() do {} while (0) - ---- a/include/net/pkt_sched.h -+++ b/include/net/pkt_sched.h -@@ -5,7 +5,11 @@ - #define PSCHED_JIFFIES 2 - #define PSCHED_CPU 3 - -+#ifdef __mips__ -+#define PSCHED_CLOCK_SOURCE PSCHED_CPU -+#else - #define PSCHED_CLOCK_SOURCE PSCHED_JIFFIES -+#endif - - #include <linux/config.h> - #include <linux/types.h> -@@ -261,7 +265,7 @@ extern int psched_clock_scale; - #define PSCHED_US2JIFFIE(delay) (((delay)+psched_clock_per_hz-1)/psched_clock_per_hz) - #define PSCHED_JIFFIE2US(delay) ((delay)*psched_clock_per_hz) - --#ifdef CONFIG_X86_TSC -+#if defined(CONFIG_X86_TSC) || defined(__mips__) - - #define PSCHED_GET_TIME(stamp) \ - ({ u64 __cur; \ diff --git a/target/linux/generic-2.4/patches/115-branch_emul_fix.patch b/target/linux/generic-2.4/patches/115-branch_emul_fix.patch deleted file mode 100644 index 5a7b652..0000000 --- a/target/linux/generic-2.4/patches/115-branch_emul_fix.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/arch/mips/kernel/branch.c -+++ b/arch/mips/kernel/branch.c -@@ -170,7 +170,7 @@ int __compute_return_epc(struct pt_regs - bit = (insn.i_format.rt >> 2); - bit += (bit != 0); - bit += 23; -- switch (insn.i_format.rt) { -+ switch (insn.i_format.rt & 3) { - case 0: /* bc1f */ - case 2: /* bc1fl */ - if (~fcr31 & (1 << bit)) diff --git a/target/linux/generic-2.4/patches/116-bridge_ioctls.patch b/target/linux/generic-2.4/patches/116-bridge_ioctls.patch deleted file mode 100644 index e005a35..0000000 --- a/target/linux/generic-2.4/patches/116-bridge_ioctls.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/include/linux/sockios.h -+++ b/include/linux/sockios.h -@@ -68,6 +68,11 @@ - - #define SIOCGIFBR 0x8940 /* Bridging support */ - #define SIOCSIFBR 0x8941 /* Set bridging options */ -+#define SIOCBRADDBR 0x89a0 /* create new bridge device */ -+#define SIOCBRDELBR 0x89a1 /* remove bridge device */ -+#define SIOCBRADDIF 0x89a2 /* add interface to bridge */ -+#define SIOCBRDELIF 0x89a3 /* remove interface from bridge */ -+ - - #define SIOCGIFTXQLEN 0x8942 /* Get the tx queue length */ - #define SIOCSIFTXQLEN 0x8943 /* Set the tx queue length */ diff --git a/target/linux/generic-2.4/patches/200-i4l.patch b/target/linux/generic-2.4/patches/200-i4l.patch deleted file mode 100644 index 8f7caa8..0000000 --- a/target/linux/generic-2.4/patches/200-i4l.patch +++ /dev/null @@ -1,20007 +0,0 @@ ---- a/Documentation/isdn/CREDITS -+++ b/Documentation/isdn/CREDITS -@@ -37,7 +37,7 @@ Michael Knigge (knick@cove.han.de) - Andreas Kool (akool@Kool.f.EUnet.de) - For contribution of the isdnlog/isdnrep-tool - --Pedro Roque Marques (pedro_m@yahoo.com) -+Pedro Roque Marques (roque@di.fc.ul.pt) - For lot of new ideas and the pcbit driver. - - Eberhard Moenkeberg (emoenke@gwdg.de) ---- a/Documentation/isdn/HiSax.cert -+++ b/Documentation/isdn/HiSax.cert -@@ -68,6 +68,8 @@ drivers/isdn/hisax/cert.c - drivers/isdn/hisax/elsa.c - drivers/isdn/hisax/diva.c - drivers/isdn/hisax/hfc_pci.c -+drivers/isdn/hisax/hfc_usbr.c -+drivers/isdn/hisax/hfc_usb.c - - Please send any changes, bugfixes and patches to me rather than implementing - them directly into the HiSax sources. ---- a/Documentation/isdn/INTERFACE -+++ b/Documentation/isdn/INTERFACE -@@ -1,4 +1,4 @@ --$Id: INTERFACE,v 1.1.4.1 2001/11/20 14:19:33 kai Exp $ -+$Id: INTERFACE,v 1.17 2002/01/31 13:26:35 keil Exp $ - - Description of the Interface between Linklevel and Hardwarelevel - of isdn4linux: -@@ -399,7 +399,7 @@ Description of the Interface between Lin - protocol-Id is one of the constants ISDN_PROTO_L3... - parm.fax = Pointer to T30_s fax struct. (fax usage only) - -- ISDN_CMD_GETL2: (currently unused) -+ ISDN_CMD_GETL3: (currently unused) - - With this command, the HL-driver is told to return the current - setting of the Layer-3-protocol. -@@ -781,3 +781,22 @@ Description of the Interface between Lin - arg = channel-number, locally to the driver. (starting with 0) - parm = unused. - -+ ISDN_STAT_ALERT: -+ -+ With this call, the HL-driver signals the receive of an ALERTING message to the LL. -+ -+ Parameter: -+ driver = driver-Id -+ command = ISDN_STAT_ALERT -+ arg = channel-number, locally to the driver. (starting with 0) -+ -+ ISDN_STAT_PROCEED: -+ -+ With this call, the HL-driver signals the receive of an CALL PROCEEDING message -+ to the LL. -+ -+ Parameter: -+ driver = driver-Id -+ command = ISDN_STAT_PROCEED -+ arg = channel-number, locally to the driver. (starting with 0) -+ ---- a/Documentation/isdn/INTERFACE.fax -+++ b/Documentation/isdn/INTERFACE.fax -@@ -1,4 +1,4 @@ --$Id: INTERFACE.fax,v 1.1.4.1 2001/11/20 14:19:33 kai Exp $ -+$Id: INTERFACE.fax,v 1.2 2000/08/06 09:22:50 armin Exp $ - - - Description of the fax-subinterface between linklevel and hardwarelevel of ---- a/Documentation/isdn/README -+++ b/Documentation/isdn/README -@@ -278,6 +278,12 @@ README for the ISDN-subsystem - 1 = Add CPN to FCON message on - Bit 2: 0 = Add CDN to RING/FCON message off - 1 = Add CDN to RING/FCON message on -+ Bit 3: 0 = Do not signal RINGING -+ 1 = Signal RINGING if ALERT was received -+ Bit 4: 0 = Do not signal PROCEEDING -+ 1 = Signal PROCEEDING if CALL PROCEEDING -+ was received -+ - - Last but not least a (at the moment fairly primitive) device to request - the line-status (/dev/isdninfo) is made available. ---- a/Documentation/isdn/README.HiSax -+++ b/Documentation/isdn/README.HiSax -@@ -41,10 +41,9 @@ ELSA Quickstep 3000 (same settings as QS - ELSA Quickstep 3000PCI - ELSA PCMCIA - ITK ix1-micro Rev.2 --Eicon Diva 2.0 ISA and PCI (S0 and U interface, no PRO version) --Eicon Diva 2.01 ISA and PCI --Eicon Diva 2.02 PCI --Eicon Diva Piccola -+Eicon.Diehl Diva 2.0 ISA and PCI (S0 and U interface, no PRO version) -+Eicon.Diehl Diva 2.01 ISA and PCI -+Eicon.Diehl Diva Piccola - ASUSCOM NETWORK INC. ISDNLink 128K PC adapter (order code I-IN100-ST-D) - Dynalink IS64PH (OEM version of ASUSCOM NETWORK INC. ISDNLink 128K adapter) - PCBIT-DP (OEM version of ASUSCOM NETWORK INC. ISDNLink) -@@ -53,7 +52,6 @@ Sedlbauer Speed Card (Speed Win, Teledat - Sedlbauer Speed Star/Speed Star2 (PCMCIA) - Sedlbauer ISDN-Controller PC/104 - USR Sportster internal TA (compatible Stollmann tina-pp V3) --USR internal TA PCI - ith Kommunikationstechnik GmbH MIC 16 ISA card - Traverse Technologie NETjet PCI S0 card and NETspider U card - Ovislink ISDN sc100-p card (NETjet driver) -@@ -68,14 +66,14 @@ Gazel ISDN cards - HFC-PCI based cards - Winbond W6692 based cards - HFC-S+, HFC-SP/PCMCIA cards --formula-n enternow --Gerdes Power ISDN -+HFC-USB ISDN TAs - - Note: PCF, PCF-Pro: up to now, only the ISDN part is supported - PCC-8: not tested yet - Eicon.Diehl Diva U interface not tested - - If you know other passive cards with the Siemens chipset, please let me know. -+To use the PNP cards you need the isapnptools. - You can combine any card, if there is no conflict between the resources - (io, mem, irq). - -@@ -91,15 +89,8 @@ There is also some config needed before - modules. It is included in the normal "make [menu]config" target at the - kernel. Don't forget it, especially to select the right D-channel protocol. - --Please note: In older versions of the HiSax driver, all PnP cards --needed to be configured with isapnp and worked only with the HiSax --driver used as a module. -- --In the current version, HiSax will automatically use the in-kernel --ISAPnP support, provided you selected it during kernel configuration --(CONFIG_ISAPNP), if you don't give the io=, irq= command line parameters. -- --The affected card types are: 4,7,12,14,19,27-30 -+Please note: All PnP cards need to be configured with isapnp and will work -+only with the HiSax driver used as a module. - - a) when built as a module - ------------------------- -@@ -200,8 +191,6 @@ Card types: - 37 HFC 2BDS0 S+, SP irq,io - 38 NETspider U PCI card none - 39 HFC 2BDS0 SP/PCMCIA irq,io (set with cardmgr) -- 40 hotplug interface -- 41 Formula-n enter:now PCI none - - At the moment IRQ sharing is only possible with PCI cards. Please make sure - that your IRQ is free and enabled for ISA use. -@@ -227,13 +216,6 @@ Examples for module loading - (IO 1 (BASE 0x0180)) - modprobe hisax type=4 protocol=2 irq=10 io0=0x580 io1=0x180 - -- In the current version of HiSax, you can instead simply use -- -- modprobe hisax type=4 protocol=2 -- -- if you configured your kernel for ISAPnP. Don't run isapnp in -- this case! -- - 6. Teles 16.3, Euro ISDN, I/O base 280 hex, IRQ 12 and - Teles 16.0, 1TR6, IRQ 5, Memory d0000 hex - modprobe hisax type=3,1 protocol=2,1 io=0x280 mem=0,0xd0000 -@@ -314,9 +296,7 @@ type - 36 W6692 based PCI cards none - 37 HFC 2BDS0 S+,SP/PCMCIA ONLY WORKS AS A MODULE ! - 38 NETspider U PCI card none -- 39 HFC 2BDS0 SP/PCMCIA ONLY WORKS AS A MODULE ! -- 40 hotplug interface ONLY WORKS AS A MODULE ! -- 41 Formula-n enter:now PCI none -+ - - Running the driver - ------------------ ---- a/Documentation/isdn/README.act2000 -+++ b/Documentation/isdn/README.act2000 -@@ -1,4 +1,4 @@ --$Id: README.act2000,v 1.1.4.1 2001/11/20 14:19:33 kai Exp $ -+$Id: README.act2000,v 1.3 2000/08/06 09:22:51 armin Exp $ - - This document describes the ACT2000 driver for the - IBM Active 2000 ISDN card. ---- a/Documentation/isdn/README.audio -+++ b/Documentation/isdn/README.audio -@@ -1,4 +1,4 @@ --$Id: README.audio,v 1.1.4.1 2001/11/20 14:19:33 kai Exp $ -+$Id: README.audio,v 1.8 1999/07/11 17:17:29 armin Exp $ - - ISDN subsystem for Linux. - Description of audio mode. ---- a/Documentation/isdn/README.eicon -+++ b/Documentation/isdn/README.eicon -@@ -1,4 +1,4 @@ --$Id: README.eicon,v 1.1.4.1 2001/11/20 14:19:33 kai Exp $ -+$Id: README.eicon,v 1.10 2000/08/13 12:19:15 armin Exp $ - - (c) 1999,2000 Armin Schindler (mac@melware.de) - (c) 1999,2000 Cytronics & Melware (info@melware.de) ---- a/Documentation/isdn/README.hysdn -+++ b/Documentation/isdn/README.hysdn -@@ -1,4 +1,4 @@ --$Id: README.hysdn,v 1.1.4.1 2001/11/20 14:19:33 kai Exp $ -+$Id: README.hysdn,v 1.3.6.1 2001/02/10 14:41:19 kai Exp $ - The hysdn driver has been written by - by Werner Cornelius (werner@isdn4linux.de or werner@titro.de) - for Hypercope GmbH Aachen Germany. Hypercope agreed to publish this driver ---- a/Documentation/isdn/README.icn -+++ b/Documentation/isdn/README.icn -@@ -1,4 +1,4 @@ --$Id: README.icn,v 1.1.4.1 2001/11/20 14:19:33 kai Exp $ -+$Id: README.icn,v 1.7 2000/08/06 09:22:51 armin Exp $ - - You can get the ICN-ISDN-card from: - ---- a/Documentation/isdn/README.pcbit -+++ b/Documentation/isdn/README.pcbit -@@ -37,4 +37,4 @@ mailing list (isdn4linux@listserv.isdn4l - regards, - Pedro. - --<pedro_m@yahoo.com> -+<roque@di.fc.ul.pt> ---- /dev/null -+++ b/Documentation/isdn/abcext_kernel.help -@@ -0,0 +1,166 @@ -+ -+ISDN-ABC-DW Extension -+CONFIG_ISDN_WITH_ABC -+ These are many brand new Options and Features for the -+ ISDN SUBSYSTEM. Including Logical Device bindings, -+ Compression and other good stuff for Optimizing your -+ ISDN System. -+ -+ To Use this Extensions you MUST HAVE THE NEWEST -+ ISDN4K-UTILS. You must have Version 3.1-Beta6 or -+ higher. Elsewhere you can not configure this Extensions. -+ -+ WARNING ! THIS STUF IS NOT PRODUCTION RELEASE THE -+ FUNCTION ARE UNDER DEVELOPMENT. This ist BETA-CODE. -+ You can use it at you Own Risk. -+ -+ For more Information on these Extensions take a look at -+ "linux/Documentation/isdn/dw-abc-extension-howto.txt or -+ Online at the Web "http://www.mediatronix.de/i4l/index.html" -+ -+ Please Report Bugs to "mario@mediatronix.de" or -+ "delefw@isdn4linux.de" -+ -+D-Channel-Callback with Channel in use check -+CONFIG_ISDN_WITH_ABC_CALLB -+ When a Interface is declared as an Callback Interface, -+ the Interface is checking that the other Side is not -+ Calling on the same time before the Interface is Dialing. -+ -+ See "linux/Documentation/isdn/dw-abc-extension-howto.txt" -+ for more Information -+ -+ In most case answer with "Yes" when you have Callback devices, -+ otherwise leave it "No" -+ -+Outgoing-EAZ-Support -+CONFIG_ISDN_WITH_ABC_OUTGOING_EAZ -+ Enables the Feature to Define an other EAZ or MSN for -+ Outgoing calls on an Interface. -+ -+ See "linux/Documentation/isdn/dw-abc-extension-howto.txt" -+ for more Information -+ -+Least Cost Router Support -+CONFIG_ISDN_WITH_ABC_LCR_SUPPORT -+ This is the final Kernel Code for configuring an Least -+ Cost Router Softwarebased. The other Job is to do the -+ action in ISDNLOG. You need the ISDNLOG to use this -+ function. Currently the ISDNLOG have not the Support for -+ this Option. -+ So in most situations let the Option off. -+ -+TCP keepalive detect and response -+CONFIG_ISDN_WITH_ABC_IPV4_TCP_KEEPALIVE -+ This Option works only with the TCP/IP V4. It enables -+ the Function that ISDN Devices are Answering TCP_KEEPALIVE Pakets -+ localy. So that TCP KEEPALIVE Pakets not longer takes the Line -+ open. -+ -+Drop frames Sourceadresse is not Interfaceadress -+CONFIG_ISDN_WITH_ABC_IPV4_DYNADDR -+ This Option works only with the TCP/IP V4. It will allow only -+ the Transmitt of Pakets where the Sourceadresse is the Interface -+ adress. It is usefull when you have Lines with Dynamic IP. -+ -+ See "linux/Documentation/isdn/dw-abc-extension-howto.txt" -+ for more Information -+ -+Receive do not reset the Hanguptimer -+CONFIG_ISDN_WITH_ABC_RCV_NO_HUPTIMER -+ When you activate this option than the reiceive of pakets do -+ not reset the Hanguptimer. It is very usefull because if the -+ Paket vor your Network your Network generate an Response and -+ the Transmit is reseting the HUPTIMER. But when the Paket is -+ Rejected at your firewall your network generate no Response -+ and no Sendtraffic is generated. So in this case there is no -+ need to Reset the Huptimer because you have only received Data. -+ With that option only Transmitted Data/Pakets will reset the -+ HUPTIMER. -+ -+Support of (device-channel) and Binding Groups -+CONFIG_ISDN_WITH_ABC_ICALL_BIND -+ This Option enables the Feature to Bind logical ISDN Interfaces -+ to an prefered ISDN Card or ISDN Card plus Channel. So you have -+ the Chance to keep Channels exclusively for one (or more) -+ Connection. Very usefull when you have more channels and Use -+ Calling Line Identification, because you can organize that your -+ call is going out over the Line with the right EAZ for the CLI. -+ -+Skip channel if used external (Dial Only) -+CONFIG_ISDN_WITH_ABC_CH_EXTINUSE -+ When you have more than One ISDN Card in your System and you -+ will Dialout with an Interface you can become the Situation -+ that an External Device such a Telephone or Fax is Using the -+ B-Channels. Normaly ISDN4Linux does not detect this Situation -+ and dial everytime of the "External Busy" line out. With this -+ Option Enabled the I4L will detect that he can not dialout on -+ This Card and dial over the next Card out. -+ -+ See "linux/Documentation/isdn/dw-abc-extension-howto.txt" -+ for more Information -+ -+Interface autodisable if Config error -+CONFIG_ISDN_WITH_ABC_CONN_ERROR -+ This Option will detect an Device which generate Telephone -+ Cost but does not Function correctly because there are -+ Configerrors on one of the Site. In this Situation the -+ Interface will be marked as Unsuably for some time to do -+ not call every time this Site. -+ -+ See "linux/Documentation/isdn/dw-abc-extension-howto.txt" -+ for more Information -+ -+UDP-Info-Support -+CONFIG_ISDN_WITH_ABC_UDP_CHECK -+ This is the Mainoption to Enable or Disable the UDP -+ Info Support. An Option to Controll ISDN-Interfaces -+ Remotely. For this very Complex thing take a look at -+ -+ "linux/Documentation/isdn/dw-abc-extension-howto.txt" -+ for more Information. -+ -+UDP Hangup Support -+CONFIG_ISDN_WITH_ABC_UDP_CHECK_HANGUP -+ -+ Sorry no more Information! -+ -+ See "linux/Documentation/isdn/dw-abc-extension-howto.txt" -+ for more Information -+ -+UDP Dial Support -+CONFIG_ISDN_WITH_ABC_UDP_CHECK_DIAL -+ -+ Sorry no more Information! -+ -+ See "linux/Documentation/isdn/dw-abc-extension-howto.txt" -+ for more Information -+ -+Limit on the line frames to two -+CONFIG_ISDN_WITH_ABC_FRAME_LIMIT -+ -+ This Option enables support for sending only 2 Pakets on -+ the Fly to the ISDN Driver. It is very usefull when you -+ will use the new RAW-IP Compression. Because of sending -+ Only 2 Pakets on the Fly makes the risk of overflowing -+ the ISDN Driver very smaller. -+ -+ See "linux/Documentation/isdn/dw-abc-extension-howto.txt" -+ for more Information -+ -+Compression with RAWIP and X75I -+CONFIG_ISDN_WITH_ABC_RAWIPCOMPRESS -+ -+ With this Option you have the ability to make Datacompression -+ on RAW-IP Lines. It is function on HDLC and X75I Connection, -+ but the Prefered L2-Protocol for Compression is X75I because -+ the HDLC Protocol have no Errorcorrection. -+ -+ To Use this Option YOU MUST HAVE ENABLED THE OPTION: -+ Support synchronous PPP -+ and must load after loading the main isdndrivers the -+ Modul "isdn_bsdcomp". -+ -+ See "linux/Documentation/isdn/dw-abc-extension-howto.txt" -+ for more Information -+ ---- a/drivers/isdn/Config.in -+++ b/drivers/isdn/Config.in -@@ -4,11 +4,9 @@ - - # only included if CONFIG_ISDN != n - --define_bool CONFIG_ISDN_BOOL y - if [ "$CONFIG_INET" != "n" ]; then - bool ' Support synchronous PPP' CONFIG_ISDN_PPP - if [ "$CONFIG_ISDN_PPP" != "n" ]; then -- dep_bool ' PPP filtering for ISDN' CONFIG_IPPP_FILTER $CONFIG_FILTER - bool ' Use VJ-compression with synchronous PPP' CONFIG_ISDN_PPP_VJ - bool ' Support generic MP (RFC 1717)' CONFIG_ISDN_MPP - dep_tristate ' Support BSD compression' CONFIG_ISDN_PPP_BSDCOMP $CONFIG_ISDN -@@ -23,6 +21,30 @@ if [ "$CONFIG_X25" != "n" ]; then - fi - - mainmenu_option next_comment -+comment 'ISDN abc-dw-extension' -+bool 'Enable isdn-abc-dw-extension' CONFIG_ISDN_WITH_ABC -+if [ "$CONFIG_ISDN_WITH_ABC" != "n" ]; then -+ bool ' Use D-Channel-Callback with Channel in use check' CONFIG_ISDN_WITH_ABC_CALLB -+ bool ' Enable Outgoing-EAZ-Support' CONFIG_ISDN_WITH_ABC_OUTGOING_EAZ -+ bool ' Enable LCR-Support (need isdnlog)' CONFIG_ISDN_WITH_ABC_LCR_SUPPORT -+ bool ' RX dont reset hanguptimeout' CONFIG_ISDN_WITH_ABC_RCV_NO_HUPTIMER -+ if [ "$CONFIG_EXPERIMENTAL" != "n" ]; then -+ bool ' Enable UDP-Info-Support' CONFIG_ISDN_WITH_ABC_UDP_CHECK -+ if [ "$CONFIG_ISDN_WITH_ABC_UDP_CHECK" != "n" ]; then -+ bool ' Enable Hangup-Support with UDP-INFO' CONFIG_ISDN_WITH_ABC_UDP_CHECK_HANGUP -+ bool ' Enable Dial-Support with UDP-INFO' CONFIG_ISDN_WITH_ABC_UDP_CHECK_DIAL -+ fi -+ fi -+ -+ bool ' Skip channel if used external (dial only)' CONFIG_ISDN_WITH_ABC_CH_EXTINUSE -+ bool ' Support interface-auto-disable if config-error' CONFIG_ISDN_WITH_ABC_CONN_ERROR -+ if [ "$CONFIG_ISDN_PPP" != "n" ]; then -+ bool ' Enable Compression with rawip and x75i' CONFIG_ISDN_WITH_ABC_RAWIPCOMPRESS -+ fi -+fi -+endmenu -+ -+mainmenu_option next_comment - comment 'ISDN feature submodules' - dep_tristate 'isdnloop support' CONFIG_ISDN_DRV_LOOP $CONFIG_ISDN - dep_tristate 'Support isdn diversion services' CONFIG_ISDN_DIVERSION $CONFIG_ISDN -@@ -34,7 +56,6 @@ mainmenu_option next_comment - comment 'Passive ISDN cards' - dep_tristate 'HiSax SiemensChipSet driver support' CONFIG_ISDN_DRV_HISAX $CONFIG_ISDN - if [ "$CONFIG_ISDN_DRV_HISAX" != "n" ]; then -- define_bool CONFIG_ISDN_HISAX y - comment ' D-channel protocol features' - bool ' HiSax Support for EURO/DSS1' CONFIG_HISAX_EURO - if [ "$CONFIG_HISAX_EURO" != "n" ]; then -@@ -45,31 +66,28 @@ if [ "$CONFIG_ISDN_DRV_HISAX" != "n" ]; - fi - bool ' HiSax Support for german 1TR6' CONFIG_HISAX_1TR6 - bool ' HiSax Support for US NI1' CONFIG_HISAX_NI1 -- int ' Maximum number of cards supported by HiSax' CONFIG_HISAX_MAX_CARDS 8 - comment ' HiSax supported cards' -- if [ "$CONFIG_ISA" != "n" ]; then -- bool ' Teles 16.0/8.0' CONFIG_HISAX_16_0 -- bool ' Teles 16.3 or PNP or PCMCIA' CONFIG_HISAX_16_3 -- bool ' AVM A1 (Fritz)' CONFIG_HISAX_AVM_A1 -- bool ' ITK ix1-micro Revision 2' CONFIG_HISAX_IX1MICROR2 -- bool ' ASUSCOM ISA cards' CONFIG_HISAX_ASUSCOM -- bool ' TELEINT cards' CONFIG_HISAX_TELEINT -- bool ' HFC-S based cards' CONFIG_HISAX_HFCS -- bool ' USR Sportster internal TA' CONFIG_HISAX_SPORTSTER -- bool ' MIC card' CONFIG_HISAX_MIC -- bool ' Siemens I-Surf card' CONFIG_HISAX_ISURF -- bool ' HST Saphir card' CONFIG_HISAX_HSTSAPHIR -- fi -+ bool ' Teles 16.0/8.0' CONFIG_HISAX_16_0 -+ bool ' Teles 16.3 or PNP or PCMCIA' CONFIG_HISAX_16_3 - bool ' Teles PCI' CONFIG_HISAX_TELESPCI - bool ' Teles S0Box' CONFIG_HISAX_S0BOX -+ bool ' AVM A1 (Fritz)' CONFIG_HISAX_AVM_A1 - bool ' AVM PnP/PCI (Fritz!PnP/PCI)' CONFIG_HISAX_FRITZPCI - bool ' AVM A1 PCMCIA (Fritz)' CONFIG_HISAX_AVM_A1_PCMCIA - bool ' Elsa cards' CONFIG_HISAX_ELSA -+ bool ' ITK ix1-micro Revision 2' CONFIG_HISAX_IX1MICROR2 - bool ' Eicon.Diehl Diva cards' CONFIG_HISAX_DIEHLDIVA -+ bool ' ASUSCOM ISA cards' CONFIG_HISAX_ASUSCOM -+ bool ' TELEINT cards' CONFIG_HISAX_TELEINT -+ bool ' HFC-S based cards' CONFIG_HISAX_HFCS - bool ' Sedlbauer cards' CONFIG_HISAX_SEDLBAUER -+ bool ' USR Sportster internal TA' CONFIG_HISAX_SPORTSTER -+ bool ' MIC card' CONFIG_HISAX_MIC - bool ' NETjet card' CONFIG_HISAX_NETJET - bool ' NETspider U card' CONFIG_HISAX_NETJET_U - bool ' Niccy PnP/PCI card' CONFIG_HISAX_NICCY -+ bool ' Siemens I-Surf card' CONFIG_HISAX_ISURF -+ bool ' HST Saphir card' CONFIG_HISAX_HSTSAPHIR - bool ' Telekom A4T card' CONFIG_HISAX_BKM_A4T - bool ' Scitel Quadro card' CONFIG_HISAX_SCT_QUADRO - bool ' Gazel cards' CONFIG_HISAX_GAZEL -@@ -78,20 +96,27 @@ if [ "$CONFIG_ISDN_DRV_HISAX" != "n" ]; - bool ' HFC-S+, HFC-SP, HFC-PCMCIA cards' CONFIG_HISAX_HFC_SX - if [ "$CONFIG_EXPERIMENTAL" != "n" ]; then - # bool ' TESTEMULATOR (EXPERIMENTAL)' CONFIG_HISAX_TESTEMU -- bool ' Formula-n enter:now PCI card' CONFIG_HISAX_ENTERNOW_PCI - if [ "$ARCH" = "sparc" -o "$ARCH" = "sparc64" ]; then - bool ' Am7930' CONFIG_HISAX_AMD7930 - fi - fi - bool ' HiSax debugging' CONFIG_HISAX_DEBUG - -- dep_tristate 'Sedlbauer PCMCIA cards' CONFIG_HISAX_SEDLBAUER_CS $CONFIG_ISDN_DRV_HISAX $CONFIG_PCMCIA -- dep_tristate 'ELSA PCMCIA MicroLink cards' CONFIG_HISAX_ELSA_CS $CONFIG_ISDN_DRV_HISAX $CONFIG_PCMCIA -- dep_tristate 'AVM A1 PCMCIA cards' CONFIG_HISAX_AVM_A1_CS $CONFIG_ISDN_DRV_HISAX $CONFIG_PCMCIA $CONFIG_HISAX_AVM_A1_PCMCIA -- dep_tristate 'ST5481 USB ISDN modem (EXPERIMENTAL)' CONFIG_HISAX_ST5481 $CONFIG_ISDN_DRV_HISAX $CONFIG_EXPERIMENTAL -- dep_tristate 'AVM Fritz!Card PCI/PCIv2/PnP support (EXPERIMENTAL)' CONFIG_HISAX_FRITZ_PCIPNP $CONFIG_ISDN_DRV_HISAX $CONFIG_EXPERIMENTAL -- dep_tristate 'Auerswald devices ISDN support' CONFIG_USB_AUERISDN $CONFIG_ISDN_DRV_HISAX -+ dep_tristate 'Sedlbauer PCMCIA cards' CONFIG_HISAX_SEDLBAUER_CS $CONFIG_PCMCIA -+ dep_tristate 'ELSA PCMCIA MicroLink cards' CONFIG_HISAX_ELSA_CS $CONFIG_PCMCIA -+ dep_tristate 'Colognechip HFC-USB support' CONFIG_HISAX_HFC_USB_CS $CONFIG_HISAX $CONFIG_USB -+ dep_tristate 'ST5481 USB ISDN modem (EXPERIMENTAL)' CONFIG_HISAX_ST5481 $CONFIG_HISAX $CONFIG_USB $CONFIG_EXPERIMENTAL -+ dep_tristate 'Fritz!PCIv2 support (EXPERIMENTAL)' CONFIG_HISAX_FRITZ_PCIPNP $CONFIG_HISAX $CONFIG_EXPERIMENTAL - -+ if [ "$CONFIG_HISAX_SEDLBAUER_CS" != "n" ]; then -+ define_bool CONFIG_HISAX_SEDLBAUER y -+ fi -+ if [ "$CONFIG_HISAX_ELSA_CS" != "n" ]; then -+ define_bool CONFIG_HISAX_ELSA y -+ fi -+ if [ "$CONFIG_HISAX_HFC_USB_CS" != "n" ]; then -+ define_bool CONFIG_HISAX_HFC_USB y -+ fi - fi - endmenu - ---- a/drivers/isdn/Makefile -+++ b/drivers/isdn/Makefile -@@ -2,7 +2,7 @@ - - # The target object and module list name. - --O_TARGET := vmlinux-obj.o -+O_TARGET := isdn.a - - # Objects that export symbols. - -@@ -32,9 +32,9 @@ obj-$(CONFIG_ISDN_PPP_BSDCOMP) += isdn_ - - # Object files in subdirectories - --mod-subdirs := avmb1 eicon hisax -+mod-subdirs := avmb1 eicon - subdir-$(CONFIG_ISDN_DIVERSION) += divert --subdir-$(CONFIG_ISDN_HISAX) += hisax -+subdir-$(CONFIG_ISDN_DRV_HISAX) += hisax - subdir-$(CONFIG_ISDN_DRV_ICN) += icn - subdir-$(CONFIG_ISDN_DRV_PCBIT) += pcbit - subdir-$(CONFIG_ISDN_DRV_SC) += sc ---- a/drivers/isdn/act2000/act2000.h -+++ b/drivers/isdn/act2000/act2000.h -@@ -1,4 +1,4 @@ --/* $Id: act2000.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id$ - * - * ISDN lowlevel-module for the IBM ISDN-S0 Active 2000. - * -@@ -178,19 +178,19 @@ typedef struct act2000_card { - char regname[35]; /* Name used for request_region */ - } act2000_card; - --static inline void act2000_schedule_tx(act2000_card *card) -+extern __inline__ void act2000_schedule_tx(act2000_card *card) - { - queue_task(&card->snd_tq, &tq_immediate); - mark_bh(IMMEDIATE_BH); - } - --static inline void act2000_schedule_rx(act2000_card *card) -+extern __inline__ void act2000_schedule_rx(act2000_card *card) - { - queue_task(&card->rcv_tq, &tq_immediate); - mark_bh(IMMEDIATE_BH); - } - --static inline void act2000_schedule_poll(act2000_card *card) -+extern __inline__ void act2000_schedule_poll(act2000_card *card) - { - queue_task(&card->poll_tq, &tq_immediate); - mark_bh(IMMEDIATE_BH); ---- a/drivers/isdn/act2000/act2000_isa.c -+++ b/drivers/isdn/act2000/act2000_isa.c -@@ -1,4 +1,4 @@ --/* $Id: act2000_isa.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id$ - * - * ISDN lowlevel-module for the IBM ISDN-S0 Active 2000 (ISA-Version). - * -@@ -178,8 +178,7 @@ act2000_isa_config_port(act2000_card * c - card->flags &= ~ACT2000_FLAGS_PVALID; - } - if (!check_region(portbase, ISA_REGION)) { -- if (request_region(portbase, ACT2000_PORTLEN, card->regname) == NULL) -- return -EIO; -+ request_region(portbase, ACT2000_PORTLEN, card->regname); - card->port = portbase; - card->flags |= ACT2000_FLAGS_PVALID; - return 0; -@@ -341,6 +340,9 @@ act2000_isa_send(act2000_card * card) - while (skb->len) { - if (act2000_isa_writeb(card, *(skb->data))) { - /* Fifo is full, but more data to send */ -+#if 0 -+ printk(KERN_DEBUG "act2000_isa_send: %d bytes\n", l); -+#endif - test_and_clear_bit(ACT2000_LOCK_TX, (void *) &card->ilock); - /* Schedule myself */ - act2000_schedule_tx(card); -@@ -363,6 +365,9 @@ act2000_isa_send(act2000_card * card) - } else - dev_kfree_skb(skb); - card->sbuf = NULL; -+#if 0 -+ printk(KERN_DEBUG "act2000_isa_send: %d bytes\n", l); -+#endif - } - } - ---- a/drivers/isdn/act2000/act2000_isa.h -+++ b/drivers/isdn/act2000/act2000_isa.h -@@ -1,4 +1,4 @@ --/* $Id: act2000_isa.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id$ - * - * ISDN lowlevel-module for the IBM ISDN-S0 Active 2000 (ISA-Version). - * ---- a/drivers/isdn/act2000/capi.c -+++ b/drivers/isdn/act2000/capi.c -@@ -1,4 +1,4 @@ --/* $Id: capi.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id$ - * - * ISDN lowlevel-module for the IBM ISDN-S0 Active 2000. - * CAPI encoder/decoder -@@ -76,6 +76,10 @@ static actcapi_msgdsc valid_msg[] = { - {{ 0x84, 0x03}, "DISCONNECT_B3_RESP"}, - {{ 0x86, 0x03}, "DATA_B3_RESP"}, - {{ 0xff, 0x03}, "MANUFACTURER_RESP"}, -+#if 0 -+/* CAPI 2.0 */ -+ {{ 0x05, 0x80}, "LISTEN_REQ (CAPI 2.0)"}, -+#endif - #endif - {{ 0x00, 0x00}, NULL}, - }; ---- a/drivers/isdn/act2000/capi.h -+++ b/drivers/isdn/act2000/capi.h -@@ -1,4 +1,4 @@ --/* $Id: capi.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id$ - * - * ISDN lowlevel-module for the IBM ISDN-S0 Active 2000. - * -@@ -294,6 +294,19 @@ typedef struct actcapi_msg { - __u16 plci; - __u16 info; - } select_b3_protocol_conf; -+#if 0 -+ struct listen_req { -+ __u32 controller; -+ __u32 infomask; -+ __u32 cipmask; -+ __u32 cipmask2; -+ __u16 dummy; /* 2 Length-bytes of 2 Structs MUST always be 0!!! */ -+ } listen_req; -+ struct listen_conf { -+ __u32 controller; -+ __u16 info; -+ } listen_conf; -+#else - struct listen_req { - __u8 controller; - __u32 infomask __attribute__ ((packed)); -@@ -304,6 +317,7 @@ typedef struct actcapi_msg { - __u8 controller; - __u16 info __attribute__ ((packed)); - } listen_conf; -+#endif - struct data_b3_req { - __u16 fakencci; - __u16 datalen; -@@ -330,7 +344,7 @@ typedef struct actcapi_msg { - } msg; - } actcapi_msg; - --static inline unsigned short -+extern __inline__ unsigned short - actcapi_nextsmsg(act2000_card *card) - { - unsigned long flags; ---- a/drivers/isdn/act2000/module.c -+++ b/drivers/isdn/act2000/module.c -@@ -1,4 +1,4 @@ --/* $Id: module.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id$ - * - * ISDN lowlevel-module for the IBM ISDN-S0 Active 2000. - * -@@ -630,6 +630,10 @@ act2000_alloccard(int bus, int port, int - card->interface.features = - ISDN_FEATURE_L2_X75I | - ISDN_FEATURE_L2_HDLC | -+#if 0 -+/* Not yet! New Firmware is on the way ... */ -+ ISDN_FEATURE_L2_TRANS | -+#endif - ISDN_FEATURE_L3_TRANS | - ISDN_FEATURE_P_UNKNOWN; - card->interface.hl_hdrlen = 20; -@@ -843,6 +847,39 @@ static void __exit act2000_exit(void) - } - printk(KERN_INFO "%s unloaded\n", DRIVERNAME); - } -+#if 0 -+#ifndef MODULE -+void -+act2000_setup(char *str, int *ints) -+{ -+ int i, j, argc, port, irq, bus; -+ -+ argc = ints[0]; -+ i = 1; -+ if (argc) -+ while (argc) { -+ port = irq = -1; -+ bus = 0; -+ if (argc) { -+ bus = ints[i]; -+ i++; -+ argc--; -+ } -+ if (argc) { -+ port = ints[i]; -+ i++; -+ argc--; -+ } -+ if (argc) { -+ irq = ints[i]; -+ i++; -+ argc--; -+ } -+ act2000_addcard(bus, port, irq, act_id); -+ } -+} -+#endif -+#endif - - module_init(act2000_init); - module_exit(act2000_exit); ---- a/drivers/isdn/avmb1/avm_cs.c -+++ b/drivers/isdn/avmb1/avm_cs.c -@@ -1,4 +1,4 @@ --/* $Id: avm_cs.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: avm_cs.c,v 1.6 2001/09/24 13:22:44 kai Exp $ - * - * A PCMCIA client driver for AVM B1/M1/M2 - * ---- a/drivers/isdn/avmb1/avmcard.h -+++ b/drivers/isdn/avmb1/avmcard.h -@@ -1,4 +1,4 @@ --/* $Id: avmcard.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: avmcard.h,v 1.12 2001/09/24 13:22:44 kai Exp $ - * - * Copyright 1999 by Carsten Paeth <calle@calle.de> - * ---- a/drivers/isdn/avmb1/b1.c -+++ b/drivers/isdn/avmb1/b1.c -@@ -1,4 +1,4 @@ --/* $Id: b1.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: b1.c,v 1.26 2001/09/24 13:22:44 kai Exp $ - * - * Common module for AVM B1 cards. - * -@@ -20,6 +20,7 @@ - #include <linux/kernelcapi.h> - #include <asm/io.h> - #include <linux/init.h> -+#include <linux/isdn_compat.h> - #include <asm/uaccess.h> - #include <linux/netdevice.h> - #include "capilli.h" -@@ -27,7 +28,7 @@ - #include "capicmd.h" - #include "capiutil.h" - --static char *revision = "$Revision: 1.1.4.1 $"; -+static char *revision = "$Revision: 1.26 $"; - - /* ------------------------------------------------------------- */ - ---- a/drivers/isdn/avmb1/b1dma.c -+++ b/drivers/isdn/avmb1/b1dma.c -@@ -1,4 +1,4 @@ --/* $Id: b1dma.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: b1dma.c,v 1.18 2001/09/24 13:22:44 kai Exp $ - * - * Common module for AVM B1 cards that support dma with AMCC - * -@@ -21,6 +21,7 @@ - #include <linux/kernelcapi.h> - #include <asm/io.h> - #include <linux/init.h> -+#include <linux/isdn_compat.h> - #include <asm/uaccess.h> - #include <linux/netdevice.h> - #include "capilli.h" -@@ -28,7 +29,11 @@ - #include "capicmd.h" - #include "capiutil.h" - --static char *revision = "$Revision: 1.1.4.1 $"; -+#if BITS_PER_LONG != 32 -+#error FIXME: driver requires 32-bit platform -+#endif -+ -+static char *revision = "$Revision: 1.18 $"; - - /* ------------------------------------------------------------- */ - -@@ -851,7 +856,7 @@ int b1dmactl_read_proc(char *page, char - __u8 flag; - int len = 0; - char *s; -- u_long txaddr, txlen, rxaddr, rxlen, csr; -+ __u32 txaddr, txlen, rxaddr, rxlen, csr; - - len += sprintf(page+len, "%-16s %s\n", "name", card->name); - len += sprintf(page+len, "%-16s 0x%x\n", "io", card->port); -@@ -907,12 +912,12 @@ int b1dmactl_read_proc(char *page, char - save_flags(flags); - cli(); - -- txaddr = (u_long)phys_to_virt(b1dmainmeml(card->mbase+0x2c)); -- txaddr -= (u_long)card->dma->sendbuf; -+ txaddr = (__u32)phys_to_virt(b1dmainmeml(card->mbase+0x2c)); -+ txaddr -= (__u32)card->dma->sendbuf; - txlen = b1dmainmeml(card->mbase+0x30); - -- rxaddr = (u_long)phys_to_virt(b1dmainmeml(card->mbase+0x24)); -- rxaddr -= (u_long)card->dma->recvbuf; -+ rxaddr = (__u32)phys_to_virt(b1dmainmeml(card->mbase+0x24)); -+ rxaddr -= (__u32)card->dma->recvbuf; - rxlen = b1dmainmeml(card->mbase+0x28); - - csr = b1dmainmeml(card->mbase+AMCC_INTCSR); ---- a/drivers/isdn/avmb1/b1isa.c -+++ b/drivers/isdn/avmb1/b1isa.c -@@ -1,4 +1,4 @@ --/* $Id: b1isa.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: b1isa.c,v 1.14 2001/09/24 13:22:44 kai Exp $ - * - * Module for AVM B1 ISA-card. - * -@@ -19,12 +19,13 @@ - #include <linux/capi.h> - #include <linux/init.h> - #include <asm/io.h> -+#include <linux/isdn_compat.h> - #include "capicmd.h" - #include "capiutil.h" - #include "capilli.h" - #include "avmcard.h" - --static char *revision = "$Revision: 1.1.4.1 $"; -+static char *revision = "$Revision: 1.14 $"; - - /* ------------------------------------------------------------- */ - ---- a/drivers/isdn/avmb1/b1pci.c -+++ b/drivers/isdn/avmb1/b1pci.c -@@ -1,4 +1,4 @@ --/* $Id: b1pci.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: b1pci.c,v 1.40 2001/09/24 13:22:44 kai Exp $ - * - * Module for AVM B1 PCI-card. - * -@@ -21,21 +21,24 @@ - #include <linux/capi.h> - #include <asm/io.h> - #include <linux/init.h> -+#include <linux/isdn_compat.h> - #include "capicmd.h" - #include "capiutil.h" - #include "capilli.h" - #include "avmcard.h" - --static char *revision = "$Revision: 1.1.4.1 $"; -+static char *revision = "$Revision: 1.40 $"; - - /* ------------------------------------------------------------- */ - -+#ifndef COMPAT_HAS_2_2_PCI - static struct pci_device_id b1pci_pci_tbl[] __initdata = { - { PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_B1, PCI_ANY_ID, PCI_ANY_ID }, - { } /* Terminating entry */ - }; - - MODULE_DEVICE_TABLE(pci, b1pci_pci_tbl); -+#endif - MODULE_DESCRIPTION("CAPI4Linux: Driver for AVM B1 PCI card"); - MODULE_AUTHOR("Carsten Paeth"); - MODULE_LICENSE("GPL"); -@@ -416,14 +419,14 @@ static int add_card(struct pci_dev *dev) - } - param.irq = dev->irq; - -- if (pci_resource_start(dev, 2)) { /* B1 PCI V4 */ -+ if (pci_resource_start_io(dev, 2)) { /* B1 PCI V4 */ - #ifdef CONFIG_ISDN_DRV_AVMB1_B1PCIV4 - driver = &b1pciv4_driver; - - pci_set_master(dev); - #endif -- param.membase = pci_resource_start(dev, 0); -- param.port = pci_resource_start(dev, 2); -+ param.membase = pci_resource_start_mem(dev, 0); -+ param.port = pci_resource_start_io(dev, 2); - - printk(KERN_INFO - "%s: PCI BIOS reports AVM-B1 V4 at i/o %#x, irq %d, mem %#x\n", -@@ -440,7 +443,7 @@ static int add_card(struct pci_dev *dev) - } - } else { - param.membase = 0; -- param.port = pci_resource_start(dev, 1); -+ param.port = pci_resource_start_io(dev, 1); - - printk(KERN_INFO - "%s: PCI BIOS reports AVM-B1 at i/o %#x, irq %d\n", ---- a/drivers/isdn/avmb1/b1pcmcia.c -+++ b/drivers/isdn/avmb1/b1pcmcia.c -@@ -1,4 +1,4 @@ --/* $Id: b1pcmcia.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: b1pcmcia.c,v 1.17 2001/09/24 13:22:44 kai Exp $ - * - * Module for AVM B1/M1/M2 PCMCIA-card. - * -@@ -25,7 +25,7 @@ - #include "capilli.h" - #include "avmcard.h" - --static char *revision = "$Revision: 1.1.4.1 $"; -+static char *revision = "$Revision: 1.17 $"; - - /* ------------------------------------------------------------- */ - ---- a/drivers/isdn/avmb1/c4.c -+++ b/drivers/isdn/avmb1/c4.c -@@ -1,4 +1,4 @@ --/* $Id: c4.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: c4.c,v 1.38 2001/09/24 13:22:44 kai Exp $ - * - * Module for AVM C4 & C2 card. - * -@@ -18,6 +18,7 @@ - #include <linux/interrupt.h> - #include <linux/ioport.h> - #include <linux/pci.h> -+#include <linux/isdn_compat.h> - #include <linux/capi.h> - #include <linux/kernelcapi.h> - #include <linux/init.h> -@@ -30,7 +31,7 @@ - #include "capilli.h" - #include "avmcard.h" - --static char *revision = "$Revision: 1.1.4.1 $"; -+static char *revision = "$Revision: 1.38 $"; - - #undef CONFIG_C4_DEBUG - #undef CONFIG_C4_POLLDEBUG -@@ -39,6 +40,7 @@ static char *revision = "$Revision: 1.1. - - static int suppress_pollack; - -+#ifndef COMPAT_HAS_2_2_PCI - static struct pci_device_id c4_pci_tbl[] __initdata = { - { PCI_VENDOR_ID_DEC,PCI_DEVICE_ID_DEC_21285, PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_C4 }, - { PCI_VENDOR_ID_DEC,PCI_DEVICE_ID_DEC_21285, PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_C2 }, -@@ -46,6 +48,7 @@ static struct pci_device_id c4_pci_tbl[] - }; - - MODULE_DEVICE_TABLE(pci, c4_pci_tbl); -+#endif - MODULE_DESCRIPTION("CAPI4Linux: Driver for AVM C2/C4 cards"); - MODULE_AUTHOR("Carsten Paeth"); - MODULE_LICENSE("GPL"); -@@ -1332,9 +1335,9 @@ static int __init search_cards(struct ca - } - pci_set_master(dev); - -- param.port = pci_resource_start(dev, 1); -+ param.port = pci_resource_start_io(dev, 1); - param.irq = dev->irq; -- param.membase = pci_resource_start(dev, 0); -+ param.membase = pci_resource_start_mem(dev, 0); - - printk(KERN_INFO - "%s: PCI BIOS reports AVM-C%d at i/o %#x, irq %d, mem %#x\n", ---- a/drivers/isdn/avmb1/capi.c -+++ b/drivers/isdn/avmb1/capi.c -@@ -1,4 +1,4 @@ --/* $Id: capi.c,v 1.1.4.2 2001/12/09 18:45:13 kai Exp $ -+/* $Id: capi.c,v 1.59 2001/11/07 22:35:48 kai Exp $ - * - * CAPI 2.0 Interface for Linux - * -@@ -23,6 +23,7 @@ - #include <linux/smp_lock.h> - #include <linux/timer.h> - #include <linux/wait.h> -+#include <linux/isdn_compat.h> - #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE - #include <linux/tty.h> - #ifdef CONFIG_PPP -@@ -30,6 +31,9 @@ - #include <linux/ppp_defs.h> - #include <linux/if_ppp.h> - #undef CAPI_PPP_ON_RAW_DEVICE -+#ifdef CAPI_PPP_ON_RAW_DEVICE -+#include <linux/ppp_channel.h> -+#endif /* CAPI_PPP_ON_RAW_DEVICE */ - #endif /* CONFIG_PPP */ - #endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ - #include <linux/skbuff.h> -@@ -38,14 +42,16 @@ - #include <linux/capi.h> - #include <linux/kernelcapi.h> - #include <linux/init.h> -+#ifdef HAVE_DEVFS_FS - #include <linux/devfs_fs_kernel.h> -+#endif /* HAVE_DEVFS_FS */ - #include "capiutil.h" - #include "capicmd.h" - #if defined(CONFIG_ISDN_CAPI_CAPIFS) || defined(CONFIG_ISDN_CAPI_CAPIFS_MODULE) - #include "capifs.h" - #endif - --static char *revision = "$Revision: 1.1.4.2 $"; -+static char *revision = "$Revision: 1.59 $"; - - MODULE_DESCRIPTION("CAPI4Linux: Userspace /dev/capi20 interface"); - MODULE_AUTHOR("Carsten Paeth"); -@@ -87,10 +93,10 @@ struct capiminor { - struct capincci *nccip; - unsigned int minor; - -- u16 applid; -- u32 ncci; -- u16 datahandle; -- u16 msgid; -+ __u16 applid; -+ __u32 ncci; -+ __u16 datahandle; -+ __u16 msgid; - - struct file *file; - struct tty_struct *tty; -@@ -112,16 +118,22 @@ struct capiminor { - /* transmit path */ - struct datahandle_queue { - struct datahandle_queue *next; -- u16 datahandle; -+ __u16 datahandle; - } *ackqueue; - int nack; - -+#ifdef CAPI_PPP_ON_RAW_DEVICE -+ /* interface to generic ppp layer */ -+ struct ppp_channel chan; -+ int chan_connected; -+ int chan_index; -+#endif - }; - #endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ - - struct capincci { - struct capincci *next; -- u32 ncci; -+ __u32 ncci; - struct capidev *cdev; - #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE - struct capiminor *minorp; -@@ -131,8 +143,8 @@ struct capincci { - struct capidev { - struct capidev *next; - struct file *file; -- u16 applid; -- u16 errcode; -+ __u16 applid; -+ __u16 errcode; - unsigned int minor; - unsigned userflags; - -@@ -156,22 +168,28 @@ static struct capidev *capidev_openlist - static struct capiminor *minors = 0; - #endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ - -+#ifdef COMPAT_HAS_kmem_cache - static kmem_cache_t *capidev_cachep = 0; - static kmem_cache_t *capincci_cachep = 0; - #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE - static kmem_cache_t *capiminor_cachep = 0; - static kmem_cache_t *capidh_cachep = 0; - #endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ -+#endif - - #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE - /* -------- datahandles --------------------------------------------- */ - --static int capincci_add_ack(struct capiminor *mp, u16 datahandle) -+int capincci_add_ack(struct capiminor *mp, __u16 datahandle) - { - struct datahandle_queue *n, **pp; - - n = (struct datahandle_queue *) -+#ifdef COMPAT_HAS_kmem_cache - kmem_cache_alloc(capidh_cachep, GFP_ATOMIC); -+#else -+ kmalloc(sizeof(struct datahandle_queue), GFP_ATOMIC); -+#endif - if (!n) { - printk(KERN_ERR "capi: alloc datahandle failed\n"); - return -1; -@@ -184,7 +202,7 @@ static int capincci_add_ack(struct capim - return 0; - } - --static int capiminor_del_ack(struct capiminor *mp, u16 datahandle) -+int capiminor_del_ack(struct capiminor *mp, __u16 datahandle) - { - struct datahandle_queue **pp, *p; - -@@ -192,7 +210,11 @@ static int capiminor_del_ack(struct capi - if ((*pp)->datahandle == datahandle) { - p = *pp; - *pp = (*pp)->next; -+#ifdef COMPAT_HAS_kmem_cache - kmem_cache_free(capidh_cachep, p); -+#else -+ kfree(p); -+#endif - mp->nack--; - return 0; - } -@@ -200,7 +222,7 @@ static int capiminor_del_ack(struct capi - return -1; - } - --static void capiminor_del_all_ack(struct capiminor *mp) -+void capiminor_del_all_ack(struct capiminor *mp) - { - struct datahandle_queue **pp, *p; - -@@ -208,7 +230,11 @@ static void capiminor_del_all_ack(struct - while (*pp) { - p = *pp; - *pp = (*pp)->next; -+#ifdef COMPAT_HAS_kmem_cache - kmem_cache_free(capidh_cachep, p); -+#else -+ kfree(p); -+#endif - mp->nack--; - } - } -@@ -216,13 +242,17 @@ static void capiminor_del_all_ack(struct - - /* -------- struct capiminor ---------------------------------------- */ - --static struct capiminor *capiminor_alloc(u16 applid, u32 ncci) -+struct capiminor *capiminor_alloc(__u16 applid, __u32 ncci) - { - struct capiminor *mp, **pp; - unsigned int minor = 0; - - MOD_INC_USE_COUNT; -+#ifdef COMPAT_HAS_kmem_cache - mp = (struct capiminor *)kmem_cache_alloc(capiminor_cachep, GFP_ATOMIC); -+#else -+ mp = (struct capiminor *)kmalloc(sizeof(struct capiminor), GFP_ATOMIC); -+#endif - if (!mp) { - MOD_DEC_USE_COUNT; - printk(KERN_ERR "capi: can't alloc capiminor\n"); -@@ -257,7 +287,7 @@ static struct capiminor *capiminor_alloc - return mp; - } - --static void capiminor_free(struct capiminor *mp) -+void capiminor_free(struct capiminor *mp) - { - struct capiminor **pp; - -@@ -271,7 +301,11 @@ static void capiminor_free(struct capimi - skb_queue_purge(&mp->inqueue); - skb_queue_purge(&mp->outqueue); - capiminor_del_all_ack(mp); -+#ifdef COMPAT_HAS_kmem_cache - kmem_cache_free(capiminor_cachep, mp); -+#else -+ kfree(mp); -+#endif - MOD_DEC_USE_COUNT; - #ifdef _DEBUG_REFCOUNT - printk(KERN_DEBUG "capiminor_free %d\n", GET_USE_COUNT(THIS_MODULE)); -@@ -283,7 +317,7 @@ static void capiminor_free(struct capimi - } - } - --static struct capiminor *capiminor_find(unsigned int minor) -+struct capiminor *capiminor_find(unsigned int minor) - { - struct capiminor *p; - for (p = minors; p && p->minor != minor; p = p->next) -@@ -294,7 +328,7 @@ static struct capiminor *capiminor_find( - - /* -------- struct capincci ----------------------------------------- */ - --static struct capincci *capincci_alloc(struct capidev *cdev, u32 ncci) -+static struct capincci *capincci_alloc(struct capidev *cdev, __u32 ncci) - { - struct capincci *np, **pp; - #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE -@@ -302,7 +336,11 @@ static struct capincci *capincci_alloc(s - kdev_t kdev; - #endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ - -+#ifdef COMPAT_HAS_kmem_cache - np = (struct capincci *)kmem_cache_alloc(capincci_cachep, GFP_ATOMIC); -+#else -+ np = (struct capincci *)kmalloc(sizeof(struct capincci), GFP_ATOMIC); -+#endif - if (!np) - return 0; - memset(np, 0, sizeof(struct capincci)); -@@ -331,7 +369,7 @@ static struct capincci *capincci_alloc(s - return np; - } - --static void capincci_free(struct capidev *cdev, u32 ncci) -+static void capincci_free(struct capidev *cdev, __u32 ncci) - { - struct capincci *np, **pp; - #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE -@@ -367,7 +405,11 @@ static void capincci_free(struct capidev - } - } - #endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ -+#ifdef COMPAT_HAS_kmem_cache - kmem_cache_free(capincci_cachep, np); -+#else -+ kfree(np); -+#endif - if (*pp == 0) return; - } else { - pp = &(*pp)->next; -@@ -375,7 +417,7 @@ static void capincci_free(struct capidev - } - } - --static struct capincci *capincci_find(struct capidev *cdev, u32 ncci) -+struct capincci *capincci_find(struct capidev *cdev, __u32 ncci) - { - struct capincci *p; - -@@ -393,7 +435,11 @@ static struct capidev *capidev_alloc(str - struct capidev *cdev; - struct capidev **pp; - -+#ifdef COMPAT_HAS_kmem_cache - cdev = (struct capidev *)kmem_cache_alloc(capidev_cachep, GFP_KERNEL); -+#else -+ cdev = (struct capidev *)kmalloc(sizeof(struct capidev), GFP_KERNEL); -+#endif - if (!cdev) - return 0; - memset(cdev, 0, sizeof(struct capidev)); -@@ -423,10 +469,14 @@ static void capidev_free(struct capidev - if (*pp) - *pp = cdev->next; - -+#ifdef COMPAT_HAS_kmem_cache - kmem_cache_free(capidev_cachep, cdev); -+#else -+ kfree(cdev); -+#endif - } - --static struct capidev *capidev_find(u16 applid) -+static struct capidev *capidev_find(__u16 applid) - { - struct capidev *p; - for (p=capidev_openlist; p; p = p->next) { -@@ -439,13 +489,13 @@ static struct capidev *capidev_find(u16 - #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE - /* -------- handle data queue --------------------------------------- */ - --static struct sk_buff * -+struct sk_buff * - gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb) - { - struct sk_buff *nskb; - nskb = alloc_skb(CAPI_DATA_B3_RESP_LEN, GFP_ATOMIC); - if (nskb) { -- u16 datahandle = CAPIMSG_U16(skb->data,CAPIMSG_BASELEN+4+4+2); -+ __u16 datahandle = CAPIMSG_U16(skb->data,CAPIMSG_BASELEN+4+4+2); - unsigned char *s = skb_put(nskb, CAPI_DATA_B3_RESP_LEN); - capimsg_setu16(s, 0, CAPI_DATA_B3_RESP_LEN); - capimsg_setu16(s, 2, mp->applid); -@@ -458,11 +508,11 @@ gen_data_b3_resp_for(struct capiminor *m - return nskb; - } - --static int handle_recv_skb(struct capiminor *mp, struct sk_buff *skb) -+int handle_recv_skb(struct capiminor *mp, struct sk_buff *skb) - { - struct sk_buff *nskb; - unsigned int datalen; -- u16 errcode, datahandle; -+ __u16 errcode, datahandle; - - datalen = skb->len - CAPIMSG_LEN(skb->data); - if (mp->tty) { -@@ -504,6 +554,28 @@ static int handle_recv_skb(struct capimi - kfree_skb(skb); - return 0; - -+#ifdef CAPI_PPP_ON_RAW_DEVICE -+ } else if (mp->chan_connected) { -+ if ((nskb = gen_data_b3_resp_for(mp, skb)) == 0) { -+ printk(KERN_ERR "capi: gen_data_b3_resp failed\n"); -+ return -1; -+ } -+ datahandle = CAPIMSG_U16(skb->data,CAPIMSG_BASELEN+4); -+ errcode = (*capifuncs->capi_put_message)(mp->applid, nskb); -+ if (errcode != CAPI_NOERROR) { -+ printk(KERN_ERR "capi: send DATA_B3_RESP failed=%x\n", -+ errcode); -+ kfree_skb(nskb); -+ return -1; -+ } -+ (void)skb_pull(skb, CAPIMSG_LEN(skb->data)); -+#ifdef _DEBUG_DATAFLOW -+ printk(KERN_DEBUG "capi: DATA_B3_RESP %u len=%d => ppp\n", -+ datahandle, skb->len); -+#endif -+ ppp_input(&mp->chan, skb); -+ return 0; -+#endif - } else if (mp->file) { - if (skb_queue_len(&mp->recvqueue) > CAPINC_MAX_RECVQUEUE) { - #if defined(_DEBUG_DATAFLOW) || defined(_DEBUG_TTYFUNCS) -@@ -538,7 +610,7 @@ static int handle_recv_skb(struct capimi - return -1; - } - --static void handle_minor_recv(struct capiminor *mp) -+void handle_minor_recv(struct capiminor *mp) - { - struct sk_buff *skb; - while ((skb = skb_dequeue(&mp->inqueue)) != 0) { -@@ -552,13 +624,13 @@ static void handle_minor_recv(struct cap - } - } - --static int handle_minor_send(struct capiminor *mp) -+int handle_minor_send(struct capiminor *mp) - { - struct sk_buff *skb; -- u16 len; -+ __u16 len; - int count = 0; -- u16 errcode; -- u16 datahandle; -+ __u16 errcode; -+ __u16 datahandle; - - if (mp->tty && mp->ttyoutstop) { - #if defined(_DEBUG_DATAFLOW) || defined(_DEBUG_TTYFUNCS) -@@ -569,7 +641,7 @@ static int handle_minor_send(struct capi - - while ((skb = skb_dequeue(&mp->outqueue)) != 0) { - datahandle = mp->datahandle; -- len = (u16)skb->len; -+ len = (__u16)skb->len; - skb_push(skb, CAPI_DATA_B3_REQ_LEN); - memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN); - capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN); -@@ -578,7 +650,7 @@ static int handle_minor_send(struct capi - capimsg_setu8 (skb->data, 5, CAPI_REQ); - capimsg_setu16(skb->data, 6, mp->msgid++); - capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */ -- capimsg_setu32(skb->data, 12, (u32) skb->data); /* Data32 */ -+ capimsg_setu32(skb->data, 12, (__u32) skb->data); /* Data32 */ - capimsg_setu16(skb->data, 16, len); /* Data length */ - capimsg_setu16(skb->data, 18, datahandle); - capimsg_setu16(skb->data, 20, 0); /* Flags */ -@@ -620,16 +692,16 @@ static int handle_minor_send(struct capi - #endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ - /* -------- function called by lower level -------------------------- */ - --static void capi_signal(u16 applid, void *param) -+static void capi_signal(__u16 applid, void *param) - { - struct capidev *cdev = (struct capidev *)param; - #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE - struct capiminor *mp; -- u16 datahandle; -+ __u16 datahandle; - #endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ - struct capincci *np; - struct sk_buff *skb = 0; -- u32 ncci; -+ __u32 ncci; - - (void) (*capifuncs->capi_get_message) (applid, &skb); - if (!skb) { -@@ -683,6 +755,12 @@ static void capi_signal(u16 applid, void - #endif - kfree_skb(skb); - (void)capiminor_del_ack(mp, datahandle); -+#ifdef CAPI_PPP_ON_RAW_DEVICE -+ if (mp->chan_connected) { -+ ppp_output_wakeup(&mp->chan); -+ return; -+ } -+#endif - if (mp->tty) { - if (mp->tty->ldisc.write_wakeup) - mp->tty->ldisc.write_wakeup(mp->tty); -@@ -758,7 +836,7 @@ capi_write(struct file *file, const char - struct capidev *cdev = (struct capidev *)file->private_data; - struct sk_buff *skb; - int retval; -- u16 mlen; -+ __u16 mlen; - - if (ppos != &file->f_pos) - return -ESPIPE; -@@ -998,7 +1076,7 @@ capi_ioctl(struct inode *inode, struct f - sizeof(ncci)); - if (retval) - return -EFAULT; -- nccip = capincci_find(cdev, (u32) ncci); -+ nccip = capincci_find(cdev, (__u32) ncci); - if (!nccip) - return 0; - #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE -@@ -1023,7 +1101,7 @@ capi_ioctl(struct inode *inode, struct f - sizeof(ncci)); - if (retval) - return -EFAULT; -- nccip = capincci_find(cdev, (u32) ncci); -+ nccip = capincci_find(cdev, (__u32) ncci); - if (!nccip || (mp = nccip->minorp) == 0) - return -ESRCH; - return mp->minor; -@@ -1070,7 +1148,9 @@ capi_release(struct inode *inode, struct - - static struct file_operations capi_fops = - { -+#ifdef COMPAT_HAS_FILEOP_OWNER - owner: THIS_MODULE, -+#endif - llseek: no_llseek, - read: capi_read, - write: capi_write, -@@ -1233,6 +1313,45 @@ capinc_raw_ioctl(struct inode *inode, st - return -EINVAL; - - switch (cmd) { -+#ifdef CAPI_PPP_ON_RAW_DEVICE -+ case PPPIOCATTACH: -+ { -+ int retval, val; -+ if (get_user(val, (int *) arg)) -+ break; -+ if (mp->chan_connected) -+ return -EALREADY; -+ mp->chan.private = mp; -+#if 1 -+ return -EINVAL; -+#else -+ mp->chan.ops = &ppp_ops; -+#endif -+ -+ retval = ppp_register_channel(&mp->chan, val); -+ if (retval) -+ return retval; -+ mp->chan_connected = 1; -+ mp->chan_index = val; -+ } -+ return 0; -+ case PPPIOCDETACH: -+ { -+ if (!mp->chan_connected) -+ return -ENXIO; -+ ppp_unregister_channel(&mp->chan); -+ mp->chan_connected = 0; -+ } -+ return 0; -+ case PPPIOCGUNIT: -+ { -+ if (!mp->chan_connected) -+ return -ENXIO; -+ if (put_user(mp->chan_index, (int *) arg)) -+ return -EFAULT; -+ } -+ return 0; -+#endif - } - return -EINVAL; - } -@@ -1260,7 +1379,9 @@ capinc_raw_release(struct inode *inode, - - static struct file_operations capinc_raw_fops = - { -+#ifdef COMPAT_HAS_FILEOP_OWNER - owner: THIS_MODULE, -+#endif - llseek: no_llseek, - read: capinc_raw_read, - write: capinc_raw_write, -@@ -1272,7 +1393,7 @@ static struct file_operations capinc_raw - - /* -------- tty_operations for capincci ----------------------------- */ - --static int capinc_tty_open(struct tty_struct * tty, struct file * file) -+int capinc_tty_open(struct tty_struct * tty, struct file * file) - { - struct capiminor *mp; - -@@ -1300,7 +1421,7 @@ static int capinc_tty_open(struct tty_st - return 0; - } - --static void capinc_tty_close(struct tty_struct * tty, struct file * file) -+void capinc_tty_close(struct tty_struct * tty, struct file * file) - { - struct capiminor *mp; - -@@ -1325,8 +1446,8 @@ static void capinc_tty_close(struct tty_ - #endif - } - --static int capinc_tty_write(struct tty_struct * tty, int from_user, -- const unsigned char *buf, int count) -+int capinc_tty_write(struct tty_struct * tty, int from_user, -+ const unsigned char *buf, int count) - { - struct capiminor *mp = (struct capiminor *)tty->driver_data; - struct sk_buff *skb; -@@ -1377,7 +1498,7 @@ static int capinc_tty_write(struct tty_s - return count; - } - --static void capinc_tty_put_char(struct tty_struct *tty, unsigned char ch) -+void capinc_tty_put_char(struct tty_struct *tty, unsigned char ch) - { - struct capiminor *mp = (struct capiminor *)tty->driver_data; - struct sk_buff *skb; -@@ -1414,7 +1535,7 @@ static void capinc_tty_put_char(struct t - } - } - --static void capinc_tty_flush_chars(struct tty_struct *tty) -+void capinc_tty_flush_chars(struct tty_struct *tty) - { - struct capiminor *mp = (struct capiminor *)tty->driver_data; - struct sk_buff *skb; -@@ -1440,7 +1561,7 @@ static void capinc_tty_flush_chars(struc - (void)handle_minor_recv(mp); - } - --static int capinc_tty_write_room(struct tty_struct *tty) -+int capinc_tty_write_room(struct tty_struct *tty) - { - struct capiminor *mp = (struct capiminor *)tty->driver_data; - int room; -@@ -1458,7 +1579,7 @@ static int capinc_tty_write_room(struct - return room; - } - --static int capinc_tty_chars_in_buffer(struct tty_struct *tty) -+int capinc_tty_chars_in_buffer(struct tty_struct *tty) - { - struct capiminor *mp = (struct capiminor *)tty->driver_data; - if (!mp || !mp->nccip) { -@@ -1476,7 +1597,7 @@ static int capinc_tty_chars_in_buffer(st - return mp->outbytes; - } - --static int capinc_tty_ioctl(struct tty_struct *tty, struct file * file, -+int capinc_tty_ioctl(struct tty_struct *tty, struct file * file, - unsigned int cmd, unsigned long arg) - { - int error = 0; -@@ -1488,14 +1609,14 @@ static int capinc_tty_ioctl(struct tty_s - return error; - } - --static void capinc_tty_set_termios(struct tty_struct *tty, struct termios * old) -+void capinc_tty_set_termios(struct tty_struct *tty, struct termios * old) - { - #ifdef _DEBUG_TTYFUNCS - printk(KERN_DEBUG "capinc_tty_set_termios\n"); - #endif - } - --static void capinc_tty_throttle(struct tty_struct * tty) -+void capinc_tty_throttle(struct tty_struct * tty) - { - struct capiminor *mp = (struct capiminor *)tty->driver_data; - #ifdef _DEBUG_TTYFUNCS -@@ -1505,7 +1626,7 @@ static void capinc_tty_throttle(struct t - mp->ttyinstop = 1; - } - --static void capinc_tty_unthrottle(struct tty_struct * tty) -+void capinc_tty_unthrottle(struct tty_struct * tty) - { - struct capiminor *mp = (struct capiminor *)tty->driver_data; - #ifdef _DEBUG_TTYFUNCS -@@ -1517,7 +1638,7 @@ static void capinc_tty_unthrottle(struct - } - } - --static void capinc_tty_stop(struct tty_struct *tty) -+void capinc_tty_stop(struct tty_struct *tty) - { - struct capiminor *mp = (struct capiminor *)tty->driver_data; - #ifdef _DEBUG_TTYFUNCS -@@ -1528,7 +1649,7 @@ static void capinc_tty_stop(struct tty_s - } - } - --static void capinc_tty_start(struct tty_struct *tty) -+void capinc_tty_start(struct tty_struct *tty) - { - struct capiminor *mp = (struct capiminor *)tty->driver_data; - #ifdef _DEBUG_TTYFUNCS -@@ -1540,43 +1661,49 @@ static void capinc_tty_start(struct tty_ - } - } - --static void capinc_tty_hangup(struct tty_struct *tty) -+void capinc_tty_hangup(struct tty_struct *tty) - { - #ifdef _DEBUG_TTYFUNCS - printk(KERN_DEBUG "capinc_tty_hangup\n"); - #endif - } - --static void capinc_tty_break_ctl(struct tty_struct *tty, int state) -+void capinc_tty_break_ctl(struct tty_struct *tty, int state) - { - #ifdef _DEBUG_TTYFUNCS - printk(KERN_DEBUG "capinc_tty_break_ctl(%d)\n", state); - #endif - } - --static void capinc_tty_flush_buffer(struct tty_struct *tty) -+void capinc_tty_flush_buffer(struct tty_struct *tty) - { - #ifdef _DEBUG_TTYFUNCS - printk(KERN_DEBUG "capinc_tty_flush_buffer\n"); - #endif - } - --static void capinc_tty_set_ldisc(struct tty_struct *tty) -+void capinc_tty_set_ldisc(struct tty_struct *tty) - { - #ifdef _DEBUG_TTYFUNCS - printk(KERN_DEBUG "capinc_tty_set_ldisc\n"); - #endif - } - --static void capinc_tty_send_xchar(struct tty_struct *tty, char ch) -+void capinc_tty_send_xchar(struct tty_struct *tty, char ch) - { - #ifdef _DEBUG_TTYFUNCS - printk(KERN_DEBUG "capinc_tty_send_xchar(%d)\n", ch); - #endif - } - --static int capinc_tty_read_proc(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+int capinc_tty_read_proc(char *page, char **start, off_t off, -+ int count, int *eof, void *data) -+{ -+ return 0; -+} -+ -+int capinc_write_proc(struct file *file, const char *buffer, -+ unsigned long count, void *data) - { - return 0; - } -@@ -1588,7 +1715,7 @@ static struct tty_struct *capinc_tty_tab - static struct termios *capinc_tty_termios[CAPINC_NR_PORTS]; - static struct termios *capinc_tty_termios_locked[CAPINC_NR_PORTS]; - --static int capinc_tty_init(void) -+int capinc_tty_init(void) - { - struct tty_driver *drv = &capinc_tty_driver; - -@@ -1646,7 +1773,7 @@ static int capinc_tty_init(void) - return 0; - } - --static void capinc_tty_exit(void) -+void capinc_tty_exit(void) - { - struct tty_driver *drv = &capinc_tty_driver; - int retval; -@@ -1771,8 +1898,9 @@ static void __exit proc_exit(void) - - /* -------- init function and module interface ---------------------- */ - -+#ifdef COMPAT_HAS_kmem_cache - --static void alloc_exit(void) -+static void __exit alloc_exit(void) - { - if (capidev_cachep) { - (void)kmem_cache_destroy(capidev_cachep); -@@ -1837,8 +1965,9 @@ static int __init alloc_init(void) - #endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ - return 0; - } -+#endif - --static void lower_callback(unsigned int cmd, u32 contr, void *data) -+static void lower_callback(unsigned int cmd, __u32 contr, void *data) - { - struct capi_ncciinfo *np; - struct capidev *cdev; -@@ -1900,15 +2029,19 @@ static int __init capi_init(void) - MOD_DEC_USE_COUNT; - return -EIO; - } -+#ifdef HAVE_DEVFS_FS - devfs_register_series (NULL, "capi/r%u", CAPINC_NR_PORTS, - DEVFS_FL_DEFAULT, - capi_rawmajor, 0, - S_IFCHR | S_IRUSR | S_IWUSR, - &capinc_raw_fops, NULL); -+#endif - #endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ -+#ifdef HAVE_DEVFS_FS - devfs_register (NULL, "isdn/capi20", DEVFS_FL_DEFAULT, - capi_major, 0, S_IFCHR | S_IRUSR | S_IWUSR, - &capi_fops, NULL); -+#endif - printk(KERN_NOTICE "capi20: started up with major %d\n", capi_major); - - if ((capifuncs = attach_capi_interface(&cuser)) == 0) { -@@ -1918,9 +2051,11 @@ static int __init capi_init(void) - #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE - devfs_unregister_chrdev(capi_rawmajor, "capi/r%d"); - #endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ -+#ifdef HAVE_DEVFS_FS - devfs_unregister(devfs_find_handle(NULL, "capi20", - capi_major, 0, - DEVFS_SPECIAL_CHR, 0)); -+#endif - return -EIO; - } - -@@ -1934,8 +2069,10 @@ static int __init capi_init(void) - } - #endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ - -+#ifdef COMPAT_HAS_kmem_cache - if (alloc_init() < 0) { - #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE -+#ifdef HAVE_DEVFS_FS - unsigned int j; - devfs_unregister_chrdev(capi_rawmajor, "capi/r%d"); - for (j = 0; j < CAPINC_NR_PORTS; j++) { -@@ -1943,16 +2080,20 @@ static int __init capi_init(void) - sprintf(devname, "capi/r%u", j); - devfs_unregister(devfs_find_handle(NULL, devname, capi_rawmajor, j, DEVFS_SPECIAL_CHR, 0)); - } -+#endif - capinc_tty_exit(); - #endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ - (void) detach_capi_interface(&cuser); - devfs_unregister_chrdev(capi_major, "capi20"); -+#ifdef HAVE_DEVFS_FS - devfs_unregister(devfs_find_handle(NULL, "capi20", - capi_major, 0, - DEVFS_SPECIAL_CHR, 0)); -+#endif - MOD_DEC_USE_COUNT; - return -ENOMEM; - } -+#endif /* COMPAT_HAS_kmem_cache */ - - (void)proc_init(); - -@@ -1975,23 +2116,31 @@ static int __init capi_init(void) - static void __exit capi_exit(void) - { - #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE -+#ifdef HAVE_DEVFS_FS - unsigned int j; - #endif -+#endif -+#ifdef COMPAT_HAS_kmem_cache - alloc_exit(); -+#endif - (void)proc_exit(); - - devfs_unregister_chrdev(capi_major, "capi20"); -+#ifdef HAVE_DEVFS_FS - devfs_unregister(devfs_find_handle(NULL, "isdn/capi20", capi_major, 0, DEVFS_SPECIAL_CHR, 0)); -+#endif - - #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE - capinc_tty_exit(); - devfs_unregister_chrdev(capi_rawmajor, "capi/r%d"); -+#ifdef HAVE_DEVFS_FS - for (j = 0; j < CAPINC_NR_PORTS; j++) { - char devname[32]; - sprintf(devname, "capi/r%u", j); - devfs_unregister(devfs_find_handle(NULL, devname, capi_rawmajor, j, DEVFS_SPECIAL_CHR, 0)); - } - #endif -+#endif - (void) detach_capi_interface(&cuser); - printk(KERN_NOTICE "capi: Rev %s: unloaded\n", rev); - } ---- a/drivers/isdn/avmb1/capicmd.h -+++ b/drivers/isdn/avmb1/capicmd.h -@@ -1,4 +1,4 @@ --/* $Id: capicmd.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: capicmd.h,v 1.4 2001/09/24 13:22:44 kai Exp $ - * - * CAPI 2.0 Interface for Linux - * ---- a/drivers/isdn/avmb1/capidev.h -+++ b/drivers/isdn/avmb1/capidev.h -@@ -1,4 +1,4 @@ --/* $Id: capidev.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: capidev.h,v 1.8 2001/09/24 13:22:44 kai Exp $ - * - * CAPI 2.0 Interface for Linux - * ---- a/drivers/isdn/avmb1/capidrv.c -+++ b/drivers/isdn/avmb1/capidrv.c -@@ -1,4 +1,4 @@ --/* $Id: capidrv.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: capidrv.c,v 1.45 2001/09/24 13:22:44 kai Exp $ - * - * ISDN4Linux Driver, using capi20 interface (kernelcapi) - * -@@ -35,7 +35,7 @@ - #include "capicmd.h" - #include "capidrv.h" - --static char *revision = "$Revision: 1.1.4.1 $"; -+static char *revision = "$Revision: 1.45 $"; - static int debugmode = 0; - - MODULE_DESCRIPTION("CAPI4Linux: Interface to ISDN4Linux"); -@@ -105,7 +105,6 @@ struct capidrv_contr { - int oldstate; - /* */ - __u16 datahandle; -- spinlock_t lock; - struct ncci_datahandle_queue { - struct ncci_datahandle_queue *next; - __u16 datahandle; -@@ -423,7 +422,6 @@ static inline capidrv_ncci *new_ncci(cap - nccip->plcip = plcip; - nccip->chan = plcip->chan; - nccip->datahandle = 0; -- nccip->lock = SPIN_LOCK_UNLOCKED; - - nccip->next = plcip->ncci_list; - plcip->ncci_list = nccip; -@@ -480,7 +478,6 @@ static int capidrv_add_ack(struct capidr - __u16 datahandle, int len) - { - struct ncci_datahandle_queue *n, **pp; -- unsigned long flags; - - n = (struct ncci_datahandle_queue *) - kmalloc(sizeof(struct ncci_datahandle_queue), GFP_ATOMIC); -@@ -491,31 +488,25 @@ static int capidrv_add_ack(struct capidr - n->next = 0; - n->datahandle = datahandle; - n->len = len; -- spin_lock_irqsave(&nccip->lock, flags); - for (pp = &nccip->ackqueue; *pp; pp = &(*pp)->next) ; - *pp = n; -- spin_unlock_irqrestore(&nccip->lock, flags); - return 0; - } - - static int capidrv_del_ack(struct capidrv_ncci *nccip, __u16 datahandle) - { - struct ncci_datahandle_queue **pp, *p; -- unsigned long flags; - int len; - -- spin_lock_irqsave(&nccip->lock, flags); - for (pp = &nccip->ackqueue; *pp; pp = &(*pp)->next) { - if ((*pp)->datahandle == datahandle) { - p = *pp; - len = p->len; - *pp = (*pp)->next; -- spin_unlock_irqrestore(&nccip->lock, flags); - kfree(p); - return len; - } - } -- spin_unlock_irqrestore(&nccip->lock, flags); - return -1; - } - -@@ -523,25 +514,13 @@ static int capidrv_del_ack(struct capidr - - static void send_message(capidrv_contr * card, _cmsg * cmsg) - { -- struct sk_buff *skb; -- size_t len; -- u16 err; -- -+ struct sk_buff *skb; -+ size_t len; - capi_cmsg2message(cmsg, cmsg->buf); - len = CAPIMSG_LEN(cmsg->buf); - skb = alloc_skb(len, GFP_ATOMIC); -- if(!skb) { -- printk(KERN_ERR "no skb len(%d) memory\n", len); -- return; -- } - memcpy(skb_put(skb, len), cmsg->buf, len); -- err = (*capifuncs->capi_put_message) (global.appid, skb); -- if (err) { -- printk(KERN_WARNING "%s: capi_put_message error: %04x\n", -- __FUNCTION__, err); -- kfree_skb(skb); -- return; -- } -+ (*capifuncs->capi_put_message) (global.appid, skb); - global.nsentctlpkt++; - } - -@@ -1932,8 +1911,10 @@ static int if_sendbuf(int id, int channe - (void)capidrv_del_ack(nccip, datahandle); - return 0; - } -+#if 1 - printk(KERN_DEBUG "capidrv-%d: only %d bytes headroom, need %d\n", - card->contrnr, skb_headroom(skb), msglen); -+#endif - memcpy(skb_push(nskb, msglen), sendcmsg.buf, msglen); - errcode = (*capifuncs->capi_put_message) (global.appid, nskb); - if (errcode == CAPI_NOERROR) { -@@ -2035,6 +2016,52 @@ static void enable_dchannel_trace(capidr - send_message(card, &cmdcmsg); - } - -+#if 0 -+static void disable_dchannel_trace(capidrv_contr *card) -+{ -+ __u8 manufacturer[CAPI_MANUFACTURER_LEN]; -+ capi_version version; -+ __u16 contr = card->contrnr; -+ __u16 errcode; -+ __u16 avmversion[3]; -+ -+ errcode = (*capifuncs->capi_get_manufacturer)(contr, manufacturer); -+ if (errcode != CAPI_NOERROR) { -+ printk(KERN_ERR "%s: can't get manufacturer (0x%x)\n", -+ card->name, errcode); -+ return; -+ } -+ if (strstr(manufacturer, "AVM") == 0) { -+ printk(KERN_ERR "%s: not from AVM, no d-channel trace possible (%s)\n", -+ card->name, manufacturer); -+ return; -+ } -+ errcode = (*capifuncs->capi_get_version)(contr, &version); -+ if (errcode != CAPI_NOERROR) { -+ printk(KERN_ERR "%s: can't get version (0x%x)\n", -+ card->name, errcode); -+ return; -+ } -+ avmversion[0] = (version.majormanuversion >> 4) & 0x0f; -+ avmversion[1] = (version.majormanuversion << 4) & 0xf0; -+ avmversion[1] |= (version.minormanuversion >> 4) & 0x0f; -+ avmversion[2] |= version.minormanuversion & 0x0f; -+ -+ if (avmversion[0] > 3 || (avmversion[0] == 3 && avmversion[1] > 5)) { -+ printk(KERN_INFO "%s: D2 trace disabled\n", card->name); -+ } else { -+ printk(KERN_INFO "%s: D3 trace disabled\n", card->name); -+ } -+ capi_fill_MANUFACTURER_REQ(&cmdcmsg, global.appid, -+ card->msgid++, -+ contr, -+ 0x214D5641, /* ManuID */ -+ 0, /* Class */ -+ 1, /* Function */ -+ (_cstruct)"\004\000\000\000\000"); -+ send_message(card, &cmdcmsg); -+} -+#endif - - static void send_listen(capidrv_contr *card) - { -@@ -2200,10 +2227,10 @@ static int capidrv_delcontr(__u16 contr) - free_ncci(card, card->bchans[card->nbchan-1].nccip); - if (card->bchans[card->nbchan-1].plcip) - free_plci(card, card->bchans[card->nbchan-1].plcip); -+ if (card->plci_list) -+ printk(KERN_ERR "capidrv: bug in free_plci()\n"); - card->nbchan--; - } -- if (card->plci_list) -- printk(KERN_ERR "capidrv: bug in free_plci()\n"); - kfree(card->bchans); - card->bchans = 0; - ---- a/drivers/isdn/avmb1/capidrv.h -+++ b/drivers/isdn/avmb1/capidrv.h -@@ -1,4 +1,4 @@ --/* $Id: capidrv.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: capidrv.h,v 1.4 2001/09/24 13:22:44 kai Exp $ - * - * ISDN4Linux Driver, using capi20 interface (kernelcapi) - * ---- a/drivers/isdn/avmb1/capifs.c -+++ b/drivers/isdn/avmb1/capifs.c -@@ -1,4 +1,4 @@ --/* $Id: capifs.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: capifs.c,v 1.22 2001/09/24 13:22:44 kai Exp $ - * - * Copyright 2000 by Carsten Paeth <calle@calle.de> - * -@@ -25,6 +25,7 @@ - #include <linux/major.h> - #include <linux/slab.h> - #include <linux/ctype.h> -+#include <linux/isdn_compat.h> - #include <asm/bitops.h> - #include <asm/uaccess.h> - -@@ -32,7 +33,7 @@ MODULE_DESCRIPTION("CAPI4Linux: /dev/cap - MODULE_AUTHOR("Carsten Paeth"); - MODULE_LICENSE("GPL"); - --static char *revision = "$Revision: 1.1.4.1 $"; -+static char *revision = "$Revision: 1.22 $"; - - struct capifs_ncci { - struct inode *inode; -@@ -69,14 +70,21 @@ static inline struct capifs_sb_info *SBI - static int capifs_root_readdir(struct file *,void *,filldir_t); - static struct dentry *capifs_root_lookup(struct inode *,struct dentry *); - static int capifs_revalidate(struct dentry *, int); -+#ifdef COMPAT_VFS_2_4 - static struct inode *capifs_new_inode(struct super_block *sb); -+#endif - - static struct file_operations capifs_root_operations = { -+#ifdef COMPAT_VFS_2_4 - read: generic_read_dir, -+#endif - readdir: capifs_root_readdir, - }; - - struct inode_operations capifs_root_inode_operations = { -+#ifndef COMPAT_VFS_2_4 -+ default_file_ops: &capifs_root_operations, /* file operations */ -+#endif - lookup: capifs_root_lookup, - }; - -@@ -101,12 +109,20 @@ static int capifs_root_readdir(struct fi - switch(nr) - { - case 0: -+#ifdef COMPAT_VFS_2_4 - if (filldir(dirent, ".", 1, nr, inode->i_ino, DT_DIR) < 0) -+#else -+ if (filldir(dirent, ".", 1, nr, inode->i_ino) < 0) -+#endif - return 0; - filp->f_pos = ++nr; - /* fall through */ - case 1: -+#ifdef COMPAT_VFS_2_4 - if (filldir(dirent, "..", 2, nr, inode->i_ino, DT_DIR) < 0) -+#else -+ if (filldir(dirent, "..", 2, nr, inode->i_ino) < 0) -+#endif - return 0; - filp->f_pos = ++nr; - /* fall through */ -@@ -118,7 +134,11 @@ static int capifs_root_readdir(struct fi - char *p = numbuf; - if (np->type) *p++ = np->type; - sprintf(p, "%u", np->num); -+#ifdef COMPAT_VFS_2_4 - if ( filldir(dirent, numbuf, strlen(numbuf), nr, nr, DT_UNKNOWN) < 0 ) -+#else -+ if ( filldir(dirent, numbuf, strlen(numbuf), nr, nr) < 0 ) -+#endif - return 0; - } - filp->f_pos = ++nr; -@@ -180,7 +200,7 @@ static struct dentry *capifs_root_lookup - - dentry->d_inode = np->inode; - if ( dentry->d_inode ) -- atomic_inc(&dentry->d_inode->i_count); -+ i_count_inc(dentry->d_inode->i_count); - - d_add(dentry, dentry->d_inode); - -@@ -199,9 +219,9 @@ static void capifs_put_super(struct supe - - for ( i = 0 ; i < sbi->max_ncci ; i++ ) { - if ( (inode = sbi->nccis[i].inode) ) { -- if (atomic_read(&inode->i_count) != 1 ) -+ if (i_count_read(inode->i_count) != 1 ) - printk("capifs_put_super: badness: entry %d count %d\n", -- i, (unsigned)atomic_read(&inode->i_count)); -+ i, (unsigned)i_count_read(inode->i_count)); - inode->i_nlink--; - iput(inode); - } -@@ -213,11 +233,24 @@ static void capifs_put_super(struct supe - - kfree(sbi->nccis); - kfree(sbi); -+#ifndef COMPAT_VFS_2_4 -+ MOD_DEC_USE_COUNT; -+#endif - } - -+#ifdef COMPAT_VFS_2_4 - static int capifs_statfs(struct super_block *sb, struct statfs *buf); -+#else -+static int capifs_statfs(struct super_block *sb, struct statfs *buf, int bufsiz); -+static void capifs_write_inode(struct inode *inode) { }; -+static void capifs_read_inode(struct inode *inode); -+#endif - - static struct super_operations capifs_sops = { -+#ifndef COMPAT_VFS_2_4 -+ read_inode: capifs_read_inode, -+ write_inode: capifs_write_inode, -+#endif - put_super: capifs_put_super, - statfs: capifs_statfs, - }; -@@ -288,6 +321,10 @@ struct super_block *capifs_read_super(st - struct dentry * root; - struct capifs_sb_info *sbi; - -+#ifndef COMPAT_VFS_2_4 -+ MOD_INC_USE_COUNT; -+ lock_super(s); -+#endif - /* Super block already completed? */ - if (s->s_root) - goto out; -@@ -322,6 +359,7 @@ struct super_block *capifs_read_super(st - /* - * Get the root inode and dentry, but defer checking for errors. - */ -+#ifdef COMPAT_VFS_2_4 - root_inode = capifs_new_inode(s); - if (root_inode) { - root_inode->i_ino = 1; -@@ -331,6 +369,10 @@ struct super_block *capifs_read_super(st - root_inode->i_nlink = 2; - } - root = d_alloc_root(root_inode); -+#else -+ root_inode = iget(s, 1); /* inode 1 == root directory */ -+ root = d_alloc_root(root_inode, NULL); -+#endif - - /* - * Check whether somebody else completed the super block. -@@ -370,11 +412,34 @@ struct super_block *capifs_read_super(st - mounts = s; - - out: /* Success ... somebody else completed the super block for us. */ -+#ifndef COMPAT_VFS_2_4 -+ unlock_super(s); -+#endif - return s; - fail: -+#ifndef COMPAT_VFS_2_4 -+ unlock_super(s); -+ MOD_DEC_USE_COUNT; -+#endif - return NULL; - } - -+#ifndef COMPAT_VFS_2_4 -+static int capifs_statfs(struct super_block *sb, struct statfs *buf, int bufsiz) -+{ -+ struct statfs tmp; -+ -+ tmp.f_type = CAPIFS_SUPER_MAGIC; -+ tmp.f_bsize = 1024; -+ tmp.f_blocks = 0; -+ tmp.f_bfree = 0; -+ tmp.f_bavail = 0; -+ tmp.f_files = 0; -+ tmp.f_ffree = 0; -+ tmp.f_namelen = NAME_MAX; -+ return copy_to_user(buf, &tmp, bufsiz) ? -EFAULT : 0; -+} -+#else - static int capifs_statfs(struct super_block *sb, struct statfs *buf) - { - buf->f_type = CAPIFS_SUPER_MAGIC; -@@ -387,7 +452,9 @@ static int capifs_statfs(struct super_bl - buf->f_namelen = NAME_MAX; - return 0; - } -+#endif - -+#ifdef COMPAT_VFS_2_4 - static struct inode *capifs_new_inode(struct super_block *sb) - { - struct inode *inode = new_inode(sb); -@@ -399,8 +466,51 @@ static struct inode *capifs_new_inode(st - } - return inode; - } -+#else -+static void capifs_read_inode(struct inode *inode) -+{ -+ ino_t ino = inode->i_ino; -+ struct capifs_sb_info *sbi = SBI(inode->i_sb); -+ -+ inode->i_mode = 0; -+ inode->i_nlink = 0; -+ inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; -+ inode->i_blocks = 0; -+ inode->i_blksize = 1024; -+ inode->i_uid = inode->i_gid = 0; -+ -+ if ( ino == 1 ) { -+ inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR; -+ inode->i_op = &capifs_root_inode_operations; -+ inode->i_nlink = 2; -+ return; -+ } - -+ ino -= 2; -+ if ( ino >= sbi->max_ncci ) -+ return; /* Bogus */ -+ -+#ifdef COMPAT_VFS_2_4 -+ init_special_inode(inode, S_IFCHR, 0); -+#else -+ inode->i_mode = S_IFCHR; -+ inode->i_op = &chrdev_inode_operations; -+#endif -+ -+ return; -+} -+#endif -+ -+#ifndef COMPAT_VFS_2_4 -+static struct file_system_type capifs_fs_type = { -+ "capifs", -+ 0, -+ capifs_read_super, -+ NULL -+}; -+#else - static DECLARE_FSTYPE(capifs_fs_type, "capifs", capifs_read_super, 0); -+#endif - - void capifs_new_ncci(char type, unsigned int num, kdev_t device) - { -@@ -421,16 +531,26 @@ void capifs_new_ncci(char type, unsigned - break; - } - } -+#ifdef COMPAT_VFS_2_4 - if ( ino >= sbi->max_ncci ) - continue; - - if ((np->inode = capifs_new_inode(sb)) != NULL) { -+#else -+ if ((np->inode = iget(sb, ino+2)) != NULL) { -+#endif - struct inode *inode = np->inode; - inode->i_uid = sbi->setuid ? sbi->uid : current->fsuid; - inode->i_gid = sbi->setgid ? sbi->gid : current->fsgid; -+#ifdef COMPAT_VFS_2_4 - inode->i_nlink = 1; - inode->i_ino = ino + 2; - init_special_inode(inode, sbi->mode|S_IFCHR, np->kdev); -+#else -+ inode->i_mode = sbi->mode | S_IFCHR; -+ inode->i_rdev = np->kdev; -+ inode->i_nlink++; -+#endif - } - } - } ---- a/drivers/isdn/avmb1/capifs.h -+++ b/drivers/isdn/avmb1/capifs.h -@@ -1,4 +1,4 @@ --/* $Id: capifs.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: capifs.h,v 1.4 2001/09/24 13:22:44 kai Exp $ - * - * Copyright 2000 by Carsten Paeth <calle@calle.de> - * ---- a/drivers/isdn/avmb1/capilli.h -+++ b/drivers/isdn/avmb1/capilli.h -@@ -1,4 +1,4 @@ --/* $Id: capilli.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: capilli.h,v 1.5 2001/09/24 13:22:44 kai Exp $ - * - * Kernel CAPI 2.0 Driver Interface for Linux - * ---- a/drivers/isdn/avmb1/capiutil.c -+++ b/drivers/isdn/avmb1/capiutil.c -@@ -1,4 +1,4 @@ --/* $Id: capiutil.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: capiutil.c,v 1.16 2001/09/24 13:22:44 kai Exp $ - * - * CAPI 2.0 convert capi message to capi message struct - * -@@ -19,6 +19,7 @@ - #include <linux/init.h> - #include <asm/segment.h> - #include <linux/config.h> -+#include <linux/isdn_compat.h> - #include "capiutil.h" - - MODULE_DESCRIPTION("CAPI4Linux: CAPI message conversion support"); ---- a/drivers/isdn/avmb1/capiutil.h -+++ b/drivers/isdn/avmb1/capiutil.h -@@ -1,4 +1,4 @@ --/* $Id: capiutil.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: capiutil.h,v 1.7 2001/09/24 13:22:44 kai Exp $ - * - * CAPI 2.0 defines & types - * ---- a/drivers/isdn/avmb1/kcapi.c -+++ b/drivers/isdn/avmb1/kcapi.c -@@ -1,4 +1,4 @@ --/* $Id: kcapi.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: kcapi.c,v 1.28 2001/09/24 13:22:44 kai Exp $ - * - * Kernel CAPI 2.0 Module - * -@@ -21,6 +21,7 @@ - #include <linux/proc_fs.h> - #include <linux/skbuff.h> - #include <linux/tqueue.h> -+#include <linux/isdn_compat.h> - #include <linux/capi.h> - #include <linux/kernelcapi.h> - #include <linux/locks.h> -@@ -33,7 +34,7 @@ - #include <linux/b1lli.h> - #endif - --static char *revision = "$Revision: 1.1.4.1 $"; -+static char *revision = "$Revision: 1.28 $"; - - /* ------------------------------------------------------------- */ - -@@ -64,7 +65,6 @@ struct capi_ncci { - __u32 ncci; - __u32 winsize; - int nmsg; -- spinlock_t lock; - struct msgidqueue *msgidqueue; - struct msgidqueue *msgidlast; - struct msgidqueue *msgidfree; -@@ -104,14 +104,14 @@ static char capi_manufakturer[64] = "AVM - #define APPL(a) (&applications[(a)-1]) - #define VALID_APPLID(a) ((a) && (a) <= CAPI_MAXAPPL && APPL(a)->applid == a) - #define APPL_IS_FREE(a) (APPL(a)->applid == 0) --#define APPL_MARK_FREE(a) do{ APPL(a)->applid=0; MOD_DEC_USE_COUNT; }while(0) --#define APPL_MARK_USED(a) do{ APPL(a)->applid=(a); MOD_INC_USE_COUNT; }while(0) -+#define APPL_MARK_FREE(a) do{ APPL(a)->applid=0; MOD_DEC_USE_COUNT; }while(0); -+#define APPL_MARK_USED(a) do{ APPL(a)->applid=(a); MOD_INC_USE_COUNT; }while(0); - - #define NCCI2CTRL(ncci) (((ncci) >> 24) & 0x7f) - - #define VALID_CARD(c) ((c) > 0 && (c) <= CAPI_MAXCONTR) - #define CARD(c) (&cards[(c)-1]) --#define CARDNR(cp) ((((cp)-cards)+1) & 0xff) -+#define CARDNR(cp) (((cp)-cards)+1) - - static struct capi_appl applications[CAPI_MAXAPPL]; - static struct capi_ctr cards[CAPI_MAXCONTR]; -@@ -535,9 +535,13 @@ static int notify_push(unsigned int cmd, - * of devices. Devices can only removed in - * user process, not in bh. - */ -+#ifdef COMPAT_HAS_SCHEDULE_TASK - MOD_INC_USE_COUNT; - if (schedule_task(&tq_state_notify) == 0) - MOD_DEC_USE_COUNT; -+#else -+ queue_task(&tq_state_notify, &tq_scheduler); -+#endif - return 0; - } - -@@ -546,13 +550,7 @@ static int notify_push(unsigned int cmd, - static void notify_up(__u32 contr) - { - struct capi_interface_user *p; -- __u16 appl; - -- for (appl = 1; appl <= CAPI_MAXAPPL; appl++) { -- if (!VALID_APPLID(appl)) continue; -- if (APPL(appl)->releasing) continue; -- CARD(contr)->driver->register_appl(CARD(contr), appl, &APPL(appl)->rparam); -- } - printk(KERN_NOTICE "kcapi: notify up contr %d\n", contr); - spin_lock(&capi_users_lock); - for (p = capi_users; p; p = p->next) { -@@ -639,7 +637,9 @@ static void notify_handler(void *dummy) - kfree(np); - MOD_DEC_USE_COUNT; - } -+#ifdef COMPAT_HAS_SCHEDULE_TASK - MOD_DEC_USE_COUNT; -+#endif - } - - /* -------- NCCI Handling ------------------------------------- */ -@@ -647,7 +647,6 @@ static void notify_handler(void *dummy) - static inline void mq_init(struct capi_ncci * np) - { - int i; -- np->lock = SPIN_LOCK_UNLOCKED; - np->msgidqueue = 0; - np->msgidlast = 0; - np->nmsg = 0; -@@ -662,11 +661,8 @@ static inline void mq_init(struct capi_n - static inline int mq_enqueue(struct capi_ncci * np, __u16 msgid) - { - struct msgidqueue *mq; -- spin_lock_bh(&np->lock); -- if ((mq = np->msgidfree) == 0) { -- spin_unlock_bh(&np->lock); -+ if ((mq = np->msgidfree) == 0) - return 0; -- } - np->msgidfree = mq->next; - mq->msgid = msgid; - mq->next = 0; -@@ -676,14 +672,12 @@ static inline int mq_enqueue(struct capi - if (!np->msgidqueue) - np->msgidqueue = mq; - np->nmsg++; -- spin_unlock_bh(&np->lock); - return 1; - } - - static inline int mq_dequeue(struct capi_ncci * np, __u16 msgid) - { - struct msgidqueue **pp; -- spin_lock_bh(&np->lock); - for (pp = &np->msgidqueue; *pp; pp = &(*pp)->next) { - if ((*pp)->msgid == msgid) { - struct msgidqueue *mq = *pp; -@@ -693,11 +687,9 @@ static inline int mq_dequeue(struct capi - mq->next = np->msgidfree; - np->msgidfree = mq; - np->nmsg--; -- spin_unlock_bh(&np->lock); - return 1; - } - } -- spin_unlock_bh(&np->lock); - return 0; - } - -@@ -720,16 +712,12 @@ static void controllercb_appl_released(s - nextpp = &(*pp)->next; - } - } -- if (APPL(appl)->releasing) { /* only release if the application was marked for release */ -- printk(KERN_DEBUG "kcapi: appl %d releasing(%d)\n", appl, APPL(appl)->releasing); -- APPL(appl)->releasing--; -- if (APPL(appl)->releasing <= 0) { -- APPL(appl)->signal = 0; -- APPL_MARK_FREE(appl); -- printk(KERN_INFO "kcapi: appl %d down\n", appl); -- } -- } else -- printk(KERN_WARNING "kcapi: appl %d card%d released without request\n", appl, card->cnr); -+ APPL(appl)->releasing--; -+ if (APPL(appl)->releasing <= 0) { -+ APPL(appl)->signal = 0; -+ APPL_MARK_FREE(appl); -+ printk(KERN_INFO "kcapi: appl %d down\n", appl); -+ } - } - /* - * ncci management -@@ -882,7 +870,16 @@ error: - - static void controllercb_ready(struct capi_ctr * card) - { -+ __u16 appl; -+ - card->cardstate = CARD_RUNNING; -+ -+ for (appl = 1; appl <= CAPI_MAXAPPL; appl++) { -+ if (!VALID_APPLID(appl)) continue; -+ if (APPL(appl)->releasing) continue; -+ card->driver->register_appl(card, appl, &APPL(appl)->rparam); -+ } -+ - printk(KERN_NOTICE "kcapi: card %d \"%s\" ready.\n", - CARDNR(card), card->name); - ---- a/drivers/isdn/avmb1/t1isa.c -+++ b/drivers/isdn/avmb1/t1isa.c -@@ -1,4 +1,4 @@ --/* $Id: t1isa.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: t1isa.c,v 1.22 2001/09/24 13:22:44 kai Exp $ - * - * Module for AVM T1 HEMA-card. - * -@@ -19,13 +19,14 @@ - #include <linux/capi.h> - #include <linux/kernelcapi.h> - #include <linux/init.h> -+#include <linux/isdn_compat.h> - #include <asm/io.h> - #include "capicmd.h" - #include "capiutil.h" - #include "capilli.h" - #include "avmcard.h" - --static char *revision = "$Revision: 1.1.4.1 $"; -+static char *revision = "$Revision: 1.22 $"; - - /* ------------------------------------------------------------- */ - ---- a/drivers/isdn/avmb1/t1pci.c -+++ b/drivers/isdn/avmb1/t1pci.c -@@ -1,4 +1,4 @@ --/* $Id: t1pci.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: t1pci.c,v 1.25 2001/09/24 13:22:44 kai Exp $ - * - * Module for AVM T1 PCI-card. - * -@@ -18,6 +18,7 @@ - #include <linux/interrupt.h> - #include <linux/ioport.h> - #include <linux/pci.h> -+#include <linux/isdn_compat.h> - #include <linux/capi.h> - #include <linux/init.h> - #include <asm/io.h> -@@ -26,19 +27,21 @@ - #include "capilli.h" - #include "avmcard.h" - --static char *revision = "$Revision: 1.1.4.1 $"; -+static char *revision = "$Revision: 1.25 $"; - - #undef CONFIG_T1PCI_DEBUG - #undef CONFIG_T1PCI_POLLDEBUG - - /* ------------------------------------------------------------- */ - -+#ifndef COMPAT_HAS_2_2_PCI - static struct pci_device_id t1pci_pci_tbl[] __initdata = { - { PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_T1, PCI_ANY_ID, PCI_ANY_ID }, - { } /* Terminating entry */ - }; - - MODULE_DEVICE_TABLE(pci, t1pci_pci_tbl); -+#endif - MODULE_DESCRIPTION("CAPI4Linux: Driver for AVM T1 PCI card"); - MODULE_AUTHOR("Carsten Paeth"); - MODULE_LICENSE("GPL"); -@@ -264,9 +267,9 @@ static int __init t1pci_init(void) - } - pci_set_master(dev); - -- param.port = pci_resource_start(dev, 1); -+ param.port = pci_resource_start_io(dev, 1); - param.irq = dev->irq; -- param.membase = pci_resource_start(dev, 0); -+ param.membase = pci_resource_start_mem(dev, 0); - - printk(KERN_INFO - "%s: PCI BIOS reports AVM-T1-PCI at i/o %#x, irq %d, mem %#x\n", ---- a/drivers/isdn/divert/divert_procfs.c -+++ b/drivers/isdn/divert/divert_procfs.c -@@ -1,4 +1,4 @@ --/* $Id: divert_procfs.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id$ - * - * Filesystem handling for the diversion supplementary services. - * -@@ -14,13 +14,16 @@ - #include <linux/module.h> - #include <linux/version.h> - #include <linux/poll.h> -+#ifndef COMPAT_USE_MODCOUNT_LOCK - #include <linux/smp_lock.h> -+#endif - #ifdef CONFIG_PROC_FS - #include <linux/proc_fs.h> - #else - #include <linux/fs.h> - #endif - #include <linux/isdnif.h> -+#include <linux/isdn_compat.h> - #include "isdn_divert.h" - - /*********************************/ -@@ -80,7 +83,6 @@ static ssize_t - isdn_divert_read(struct file *file, char *buf, size_t count, loff_t * off) - { - struct divert_info *inf; -- loff_t pos = *off; - int len; - - if (!*((struct divert_info **) file->private_data)) { -@@ -92,11 +94,11 @@ isdn_divert_read(struct file *file, char - return (0); - - inf->usage_cnt--; /* new usage count */ -- file->private_data = &inf->next; /* next structure */ -+ (struct divert_info **) file->private_data = &inf->next; /* next structure */ - if ((len = strlen(inf->info_start)) <= count) { - if (copy_to_user(buf, inf->info_start, len)) - return -EFAULT; -- *off = pos + len; -+ file->f_pos += len; - return (len); - } - return (0); -@@ -136,17 +138,23 @@ isdn_divert_open(struct inode *ino, stru - { - unsigned long flags; - -+#ifdef COMPAT_USE_MODCOUNT_LOCK -+ MOD_INC_USE_COUNT; -+#else - lock_kernel(); -+#endif - save_flags(flags); - cli(); - if_used++; - if (divert_info_head) -- filep->private_data = &(divert_info_tail->next); -+ (struct divert_info **) filep->private_data = &(divert_info_tail->next); - else -- filep->private_data = &divert_info_head; -+ (struct divert_info **) filep->private_data = &divert_info_head; - restore_flags(flags); - /* start_divert(); */ -+#ifndef COMPAT_USE_MODCOUNT_LOCK - unlock_kernel(); -+#endif - return (0); - } /* isdn_divert_open */ - -@@ -159,7 +167,9 @@ isdn_divert_close(struct inode *ino, str - struct divert_info *inf; - unsigned long flags; - -+#ifndef COMPAT_USE_MODCOUNT_LOCK - lock_kernel(); -+#endif - save_flags(flags); - cli(); - if_used--; -@@ -175,7 +185,11 @@ isdn_divert_close(struct inode *ino, str - divert_info_head = divert_info_head->next; - kfree(inf); - } -+#ifdef COMPAT_USE_MODCOUNT_LOCK -+ MOD_DEC_USE_COUNT; -+#else - unlock_kernel(); -+#endif - return (0); - } /* isdn_divert_close */ - -@@ -276,6 +290,9 @@ static struct file_operations isdn_fops - open: isdn_divert_open, - release: isdn_divert_close, - }; -+#ifdef COMPAT_NO_SOFTNET -+struct inode_operations divert_file_inode_operations; -+#endif - - /****************************/ - /* isdn subdir in /proc/net */ -@@ -302,8 +319,16 @@ divert_dev_init(void) - remove_proc_entry("isdn", proc_net); - return (-1); - } -+#ifdef COMPAT_NO_SOFTNET -+ memset(&divert_file_inode_operations, 0, sizeof(struct inode_operations)); -+ divert_file_inode_operations.default_file_ops = &isdn_fops; -+ isdn_divert_entry->ops = &divert_file_inode_operations; -+#else - isdn_divert_entry->proc_fops = &isdn_fops; -+#ifdef COMPAT_HAS_FILEOP_OWNER - isdn_divert_entry->owner = THIS_MODULE; -+#endif -+#endif /* COMPAT_NO_SOFTNET */ - #endif /* CONFIG_PROC_FS */ - - return (0); ---- a/drivers/isdn/divert/isdn_divert.c -+++ b/drivers/isdn/divert/isdn_divert.c -@@ -1,4 +1,4 @@ --/* $Id: isdn_divert.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id$ - * - * DSS1 main diversion supplementary handling for i4l. - * -@@ -84,6 +84,9 @@ static void deflect_timer_expire(ulong a - restore_flags(flags); - break; - -+ case NETWORK_DIAL: -+ divert_if.dial_net_name(cs->deflect_dest); -+ - case DEFLECT_AUTODEL: - default: - save_flags(flags); -@@ -452,6 +455,7 @@ int isdn_divert_icall(isdn_ctrl *ic) - case DEFLECT_PROCEED: - case DEFLECT_REPORT: - case DEFLECT_REJECT: -+ case NETWORK_DIAL: - if (dv->rule.action == DEFLECT_PROCEED) - if ((!if_used) || ((!extern_wait_max) && (!dv->rule.waittime))) - return(0); /* no external deflection needed */ -@@ -495,6 +499,11 @@ int isdn_divert_icall(isdn_ctrl *ic) - else - { cs->deflect_dest[0] = '\0'; - retval = 4; /* only proceed */ -+ if (cs->akt_state == NETWORK_DIAL) { -+ strcpy(cs->deflect_dest,dv->rule.to_nr); -+ cs->timer.expires = jiffies + 10; -+ retval = 0; -+ } - } - sprintf(cs->info,"%d 0x%lx %s %s %s %s 0x%x 0x%x %d %d %s\n", - cs->akt_state, -@@ -739,6 +748,18 @@ int prot_stat_callback(isdn_ctrl *ic) - } - - -+#if 0 -+ sprintf(st, "0x%lx 0x%lx",ic->arg, ic->parm.dss1_io.ll_id); -+ p = st + strlen(st); -+ p1 = ic->parm.dss1_io.data; -+ i = ic->parm.dss1_io.datalen; -+ while ((i > 0) && (p - st < 530)) -+ { p += sprintf(p," %02x",(*p1++) & 0xFF); -+ i--; -+ } -+ sprintf(p, "\n"); -+ put_info_buffer(st); -+#endif - break; - - default: ---- a/drivers/isdn/divert/isdn_divert.h -+++ b/drivers/isdn/divert/isdn_divert.h -@@ -1,4 +1,4 @@ --/* $Id: isdn_divert.h,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id$ - * - * Header for the diversion supplementary ioctl interface. - * -@@ -36,9 +36,10 @@ - #define DEFLECT_PROCEED 2 /* deflect when externally triggered */ - #define DEFLECT_ALERT 3 /* alert and deflect after delay */ - #define DEFLECT_REJECT 4 /* reject immediately */ --#define DIVERT_ACTIVATE 5 /* diversion activate */ --#define DIVERT_DEACTIVATE 6 /* diversion deactivate */ --#define DIVERT_REPORT 7 /* interrogation result */ -+#define NETWORK_DIAL 5 /* dial a network interface */ -+#define DIVERT_ACTIVATE 16 /* diversion activate */ -+#define DIVERT_DEACTIVATE 17 /* diversion deactivate */ -+#define DIVERT_REPORT 18 /* interrogation result */ - #define DEFLECT_AUTODEL 255 /* only for internal use */ - - #define DEFLECT_ALL_IDS 0xFFFFFFFF /* all drivers selected */ -@@ -60,6 +61,7 @@ typedef struct - 2 = report call, send proceed, wait max waittime secs - 3 = report call, alert and deflect after waittime - 4 = report call, reject immediately -+ 5 = dial net interface specified in to_nr - actions 1-2 only take place if interface is opened - */ - u_char waittime; /* maximum wait time for proceeding */ ---- a/drivers/isdn/eicon/Divas_mod.c -+++ b/drivers/isdn/eicon/Divas_mod.c -@@ -20,6 +20,7 @@ - #include "adapter.h" - #include "uxio.h" - -+#include <linux/isdn_compat.h> - - MODULE_DESCRIPTION("ISDN4Linux: Driver for Eicon Diva Server cards"); - MODULE_AUTHOR("Armin Schindler"); ---- a/drivers/isdn/eicon/common.c -+++ b/drivers/isdn/eicon/common.c -@@ -808,9 +808,7 @@ void DivasDoDpc(void *pData) - - while(i--) - { -- if (card->state == DIA_RUNNING) -- DivaDoCardDpc(card); -- card++; -+ DivaDoCardDpc(card++); - } - } - ---- a/drivers/isdn/eicon/eicon.h -+++ b/drivers/isdn/eicon/eicon.h -@@ -1,4 +1,4 @@ --/* $Id: eicon.h,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: eicon.h,v 1.26 2001/09/24 13:22:47 kai Exp $ - * - * ISDN low-level module for Eicon active ISDN-Cards. - * -@@ -347,19 +347,19 @@ typedef struct eicon_card { - extern char *eicon_ctype_name[]; - - --static inline void eicon_schedule_tx(eicon_card *card) -+extern __inline__ void eicon_schedule_tx(eicon_card *card) - { - queue_task(&card->snd_tq, &tq_immediate); - mark_bh(IMMEDIATE_BH); - } - --static inline void eicon_schedule_rx(eicon_card *card) -+extern __inline__ void eicon_schedule_rx(eicon_card *card) - { - queue_task(&card->rcv_tq, &tq_immediate); - mark_bh(IMMEDIATE_BH); - } - --static inline void eicon_schedule_ack(eicon_card *card) -+extern __inline__ void eicon_schedule_ack(eicon_card *card) - { - queue_task(&card->ack_tq, &tq_immediate); - mark_bh(IMMEDIATE_BH); ---- a/drivers/isdn/eicon/eicon_dsp.h -+++ b/drivers/isdn/eicon/eicon_dsp.h -@@ -1,4 +1,4 @@ --/* $Id: eicon_dsp.h,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: eicon_dsp.h,v 1.8 2001/09/24 13:22:47 kai Exp $ - * - * ISDN lowlevel-module for Eicon active cards. - * DSP definitions ---- a/drivers/isdn/eicon/eicon_idi.c -+++ b/drivers/isdn/eicon/eicon_idi.c -@@ -1,4 +1,4 @@ --/* $Id: eicon_idi.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: eicon_idi.c,v 1.45 2001/11/07 22:35:48 kai Exp $ - * - * ISDN lowlevel-module for Eicon active cards. - * IDI interface -@@ -25,7 +25,7 @@ - - #undef EICON_FULL_SERVICE_OKTETT - --char *eicon_idi_revision = "$Revision: 1.1.4.1 $"; -+char *eicon_idi_revision = "$Revision: 1.45 $"; - - eicon_manifbuf *manbuf; - -@@ -1583,6 +1583,37 @@ idi_faxdata_rcv(eicon_card *ccard, eicon - return; - } - -+#if 0 -+ eicon_sff_dochead *doc = (eicon_sff_dochead *)skb->data; -+ eicon_sff_pagehead *page = (eicon_sff_pagehead *)skb->data + sizeof(eicon_sff_dochead); -+ -+ printk(KERN_DEBUG"SFF: doc %d / page %d (skb : %d)\n", -+ sizeof(eicon_sff_dochead), -+ sizeof(eicon_sff_pagehead), skb->len); -+ -+ if (skb->len >= sizeof(eicon_sff_dochead)) { -+ printk(KERN_DEBUG"SFF: id = 0x%x\n", doc->id); -+ printk(KERN_DEBUG"SFF: version = 0x%x\n", doc->version); -+ printk(KERN_DEBUG"SFF: reserved1 = 0x%x\n", doc->reserved1); -+ printk(KERN_DEBUG"SFF: userinfo = 0x%x\n", doc->userinfo); -+ printk(KERN_DEBUG"SFF: pagecount = 0x%x\n", doc->pagecount); -+ printk(KERN_DEBUG"SFF: off1pagehead = 0x%x\n", doc->off1pagehead); -+ printk(KERN_DEBUG"SFF: offnpagehead = 0x%x\n", doc->offnpagehead); -+ printk(KERN_DEBUG"SFF: offdocend = 0x%x\n", doc->offdocend); -+ } -+ if (skb->len >= (sizeof(eicon_sff_dochead) + sizeof(eicon_sff_pagehead))) { -+ printk(KERN_DEBUG"SFFp: id = 0x%x\n", page->pageheadid); -+ printk(KERN_DEBUG"SFFp: len = 0x%x\n", page->pageheadlen); -+ printk(KERN_DEBUG"SFFp: resvert = 0x%x\n", page->resvert); -+ printk(KERN_DEBUG"SFFp: reshoriz = 0x%x\n", page->reshoriz); -+ printk(KERN_DEBUG"SFFp: coding = 0x%x\n", page->coding); -+ printk(KERN_DEBUG"SFFp: reserved2 = 0x%x\n", page->reserved2); -+ printk(KERN_DEBUG"SFFp: linelength = 0x%x\n", page->linelength); -+ printk(KERN_DEBUG"SFFp: pagelength = 0x%x\n", page->pagelength); -+ printk(KERN_DEBUG"SFFp: offprevpage = 0x%x\n", page->offprevpage); -+ printk(KERN_DEBUG"SFFp: offnextpage = 0x%x\n", page->offnextpage); -+ } -+#endif - - - if (chan->fax->direction == ISDN_TTY_FAX_CONN_IN) { -@@ -2054,8 +2085,7 @@ idi_faxdata_send(eicon_card *ccard, eico - OutBuf.Len++; - } else { - *OutBuf.Next++ = 0; -- *(__u16 *) OutBuf.Next = (__u16) LineBuf.Len; -- OutBuf.Next += sizeof(__u16); -+ *((__u16 *) OutBuf.Next)++ = (__u16) LineBuf.Len; - OutBuf.Len += 3; - } - memcpy(OutBuf.Next, LineBuf.Data, LineBuf.Len); -@@ -2385,6 +2415,12 @@ idi_handle_ind(eicon_card *ccard, struct - } else { - if (chan->e.B2Id) - idi_do_req(ccard, chan, REMOVE, 1); -+#if 0 -+ if (chan->e.D3Id) { -+ idi_do_req(ccard, chan, REMOVE, 0); -+ idi_do_req(ccard, chan, ASSIGN, 0); -+ } -+#endif - chan->statectrl &= ~WAITING_FOR_HANGUP; - chan->statectrl &= ~IN_HOLD; - if (chan->statectrl & HAVE_CONN_REQ) { ---- a/drivers/isdn/eicon/eicon_idi.h -+++ b/drivers/isdn/eicon/eicon_idi.h -@@ -1,4 +1,4 @@ --/* $Id: eicon_idi.h,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: eicon_idi.h,v 1.12 2001/09/24 13:22:47 kai Exp $ - * - * ISDN lowlevel-module for the Eicon active cards. - * IDI-Interface ---- a/drivers/isdn/eicon/eicon_io.c -+++ b/drivers/isdn/eicon/eicon_io.c -@@ -1,4 +1,4 @@ --/* $Id: eicon_io.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: eicon_io.c,v 1.15 2001/09/24 13:22:47 kai Exp $ - * - * ISDN low-level module for Eicon active ISDN-Cards. - * Code for communicating with hardware. ---- a/drivers/isdn/eicon/eicon_isa.c -+++ b/drivers/isdn/eicon/eicon_isa.c -@@ -1,4 +1,4 @@ --/* $Id: eicon_isa.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: eicon_isa.c,v 1.18 2001/11/07 22:35:48 kai Exp $ - * - * ISDN low-level module for Eicon active ISDN-Cards. - * Hardware-specific code for old ISA cards. -@@ -20,7 +20,7 @@ - #define release_shmem release_region - #define request_shmem request_region - --char *eicon_isa_revision = "$Revision: 1.1.4.1 $"; -+char *eicon_isa_revision = "$Revision: 1.18 $"; - - #undef EICON_MCA_DEBUG - -@@ -38,8 +38,12 @@ static int eicon_isa_valid_irq[] = { - static void - eicon_isa_release_shmem(eicon_isa_card *card) { - if (card->mvalid) { -+#ifdef COMPAT_HAS_ISA_IOREMAP - iounmap(card->shmem); - release_mem_region(card->physmem, card->ramsize); -+#else -+ release_shmem((unsigned long)card->shmem, card->ramsize); -+#endif - } - card->mvalid = 0; - } -@@ -94,12 +98,20 @@ eicon_isa_find_card(int Mem, int Irq, ch - Mem, Id); - return -1; - } -+#ifdef COMPAT_HAS_ISA_IOREMAP - if (check_mem_region(Mem, RAMSIZE)) { -+#else -+ if (check_shmem(Mem, RAMSIZE)) { -+#endif - printk(KERN_WARNING "eicon_isa_boot: memory at 0x%x already in use.\n", Mem); - return -1; - } - -+#ifdef COMPAT_HAS_ISA_IOREMAP - amem = (unsigned long) ioremap(Mem, RAMSIZE); -+#else -+ amem = (unsigned long) Mem; -+#endif - writew(0x55aa, amem + 0x402); - if (readw(amem + 0x402) != 0x55aa) primary = 0; - writew(0, amem + 0x402); -@@ -109,12 +121,16 @@ eicon_isa_find_card(int Mem, int Irq, ch - if (primary) { - printk(KERN_INFO "Eicon: assuming pri card at 0x%x\n", Mem); - writeb(0, amem + 0x3ffe); -+#ifdef COMPAT_HAS_ISA_IOREMAP - iounmap((unsigned char *)amem); -+#endif - return EICON_CTYPE_ISAPRI; - } else { - printk(KERN_INFO "Eicon: assuming bri card at 0x%x\n", Mem); - writeb(0, amem + 0x400); -+#ifdef COMPAT_HAS_ISA_IOREMAP - iounmap((unsigned char *)amem); -+#endif - return EICON_CTYPE_ISABRI; - } - return -1; -@@ -151,6 +167,7 @@ eicon_isa_bootload(eicon_isa_card *card, - else - card->ramsize = RAMSIZE; - -+#ifdef COMPAT_HAS_ISA_IOREMAP - if (check_mem_region(card->physmem, card->ramsize)) { - printk(KERN_WARNING "eicon_isa_boot: memory at 0x%lx already in use.\n", - card->physmem); -@@ -159,6 +176,16 @@ eicon_isa_bootload(eicon_isa_card *card, - } - request_mem_region(card->physmem, card->ramsize, "Eicon ISA ISDN"); - card->shmem = (eicon_isa_shmem *) ioremap(card->physmem, card->ramsize); -+#else -+ /* Register shmem */ -+ if (check_shmem((unsigned long)card->shmem, card->ramsize)) { -+ printk(KERN_WARNING "eicon_isa_boot: memory at 0x%lx already in use.\n", -+ (unsigned long)card->shmem); -+ kfree(code); -+ return -EBUSY; -+ } -+ request_shmem((unsigned long)card->shmem, card->ramsize, "Eicon ISA ISDN"); -+#endif - #ifdef EICON_MCA_DEBUG - printk(KERN_INFO "eicon_isa_boot: card->ramsize = %d.\n", card->ramsize); - #endif ---- a/drivers/isdn/eicon/eicon_isa.h -+++ b/drivers/isdn/eicon/eicon_isa.h -@@ -1,4 +1,4 @@ --/* $Id: eicon_isa.h,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: eicon_isa.h,v 1.11 2001/09/24 13:22:47 kai Exp $ - * - * ISDN low-level module for Eicon active ISDN-Cards. - * ---- a/drivers/isdn/eicon/eicon_mod.c -+++ b/drivers/isdn/eicon/eicon_mod.c -@@ -1,4 +1,4 @@ --/* $Id: eicon_mod.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: eicon_mod.c,v 1.44 2001/11/20 09:48:25 armin Exp $ - * - * ISDN lowlevel-module for Eicon active cards. - * -@@ -44,7 +44,7 @@ - static eicon_card *cards = (eicon_card *) NULL; /* glob. var , contains - start of card-list */ - --static char *eicon_revision = "$Revision: 1.1.4.1 $"; -+static char *eicon_revision = "$Revision: 1.44 $"; - - extern char *eicon_pci_revision; - extern char *eicon_isa_revision; -@@ -639,6 +639,18 @@ if_command(isdn_ctrl * c) - static int - if_writecmd(const u_char * buf, int len, int user, int id, int channel) - { -+#if 0 -+ /* Not yet used */ -+ eicon_card *card = eicon_findcard(id); -+ -+ if (card) { -+ if (!card->flags & EICON_FLAGS_RUNNING) -+ return (len); -+ return (len); -+ } -+ printk(KERN_ERR -+ "eicon: if_writecmd called with invalid driverId!\n"); -+#endif - return (len); - } - -@@ -665,11 +677,8 @@ if_readstatus(u_char * buf, int len, int - else - cnt = skb->len; - -- if (user) { -- spin_unlock_irqrestore(&eicon_lock, flags); -+ if (user) - copy_to_user(p, skb->data, cnt); -- spin_lock_irqsave(&eicon_lock, flags); -- } - else - memcpy(p, skb->data, cnt); - -@@ -1459,6 +1468,7 @@ eicon_exit(void) - - #ifndef MODULE - -+#ifdef COMPAT_HAS_NEW_SETUP - static int __init - eicon_setup(char *line) - { -@@ -1467,6 +1477,12 @@ eicon_setup(char *line) - char *str; - - str = get_options(line, 4, ints); -+#else -+void -+eicon_setup(char *str, int *ints) -+{ -+ int i, argc; -+#endif - - argc = ints[0]; - i = 1; -@@ -1494,9 +1510,13 @@ eicon_setup(char *line) - #else - printk(KERN_INFO "Eicon ISDN active driver setup\n"); - #endif -+#ifdef COMPAT_HAS_NEW_SETUP - return(1); - } - __setup("eicon=", eicon_setup); -+#else -+} -+#endif - - #endif /* MODULE */ - ---- a/drivers/isdn/eicon/eicon_pci.c -+++ b/drivers/isdn/eicon/eicon_pci.c -@@ -1,4 +1,4 @@ --/* $Id: eicon_pci.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: eicon_pci.c,v 1.18 2001/09/24 13:22:47 kai Exp $ - * - * ISDN low-level module for Eicon active ISDN-Cards. - * Hardware-specific code for PCI cards. -@@ -24,7 +24,7 @@ - #include "adapter.h" - #include "uxio.h" - --char *eicon_pci_revision = "$Revision: 1.1.4.1 $"; -+char *eicon_pci_revision = "$Revision: 1.18 $"; - - #if CONFIG_PCI /* intire stuff is only for PCI */ - #ifdef CONFIG_ISDN_DRV_EICON_PCI ---- a/drivers/isdn/eicon/eicon_pci.h -+++ b/drivers/isdn/eicon/eicon_pci.h -@@ -1,4 +1,4 @@ --/* $Id: eicon_pci.h,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: eicon_pci.h,v 1.7 2001/09/24 13:22:47 kai Exp $ - * - * ISDN low-level module for Eicon active ISDN-Cards (PCI part). - * ---- a/drivers/isdn/eicon/fourbri.c -+++ b/drivers/isdn/eicon/fourbri.c -@@ -337,8 +337,7 @@ static int diva_server_4bri_load(card_t - static int diva_server_4bri_start(card_t *card, byte *channels) - { - byte *ctl; -- byte *shared; -- int i; -+ byte *shared, i; - int adapter_num; - - DPRINTF(("divas: start Diva Server 4BRI")); ---- a/drivers/isdn/eicon/kprintf.c -+++ b/drivers/isdn/eicon/kprintf.c -@@ -18,6 +18,468 @@ - #include "divalog.h" - #include "uxio.h" - -+/* -+ * Implementation of printf and sprintf for kernel -+ */ -+ -+#define MAX_BUFF (80) /* limit size of temporary buffers */ -+ -+#define WRITE_CHAR(BUFFER, SIZE, C) \ -+ if (--(SIZE) < 0) { (BUFFER)--; *(BUFFER) = '\0'; return; } *(BUFFER)++ = (C) -+ -+ -+/* -+ * convert a number to decimal ASCII -+ */ -+ -+static -+void do_decimal( char *temp, -+ int temp_len, -+ unsigned int value, -+ char *s) -+ -+{ -+ int i; -+ -+ temp[0] = '\0'; -+ -+ for (i = 1; i < temp_len; i++) -+ { -+ temp[i] = (char) ((value % 10) + (int) '0'); -+ value /= 10; -+ } -+ -+ for (i = (temp_len - 1); temp[i] == '0'; i--) -+ { -+ ; -+ } -+ -+ if (i == 0) -+ { -+ i++; -+ } -+ -+ while (i >= 0) -+ { -+ *s++ = temp[i--]; -+ } -+ -+ return; -+} -+ -+/* -+ * convert a number to octal ASCII -+ */ -+ -+static -+void do_octal( char *temp, -+ unsigned int value, -+ char *s) -+ -+{ -+ int i; -+ -+ temp[0] = '\0'; -+ -+ for (i = 1; i <= 11; i++) -+ { -+ temp[i] = (char) ((value & 07) + (int) '0'); -+ value >>= 3; -+ } -+ temp[11] &= '3'; -+ -+ for (i = 11; temp[i] == '0'; i--) -+ { -+ ; -+ } -+ -+ if (i == 0) -+ { -+ i++; -+ } -+ -+ while (i >= 0) -+ { -+ *s++ = temp[i--]; -+ } -+ -+ return; -+} -+ -+/* -+ * convert a number to hex ASCII -+ */ -+ -+static -+void do_hex( char *temp, -+ unsigned int value, -+ char *s) -+ -+{ -+ int i; -+ static -+ char *dec_to_hex = "0123456789abcdef"; -+ -+ temp[0] = '\0'; -+ -+ for (i = 1; i <= 8; i++) -+ { -+ temp[i] = dec_to_hex[value & 0x0f]; -+ value >>= 4; -+ } -+ -+ for (i = 8; temp[i] == '0'; i--) -+ { -+ ; -+ } -+ -+ if (i == 0) -+ { -+ i++; -+ } -+ -+ while (i >= 0) -+ { -+ *s++ = temp[i--]; -+ } -+ -+ return; -+} -+ -+/* -+ * convert a buffer to ASCII HEX -+ */ -+ -+static -+void do_buffer( char *buffer, -+ int length, -+ char *s) -+ -+{ -+ static -+ char hex_char [] = "0123456789abcdef"; -+ char *b = buffer; -+ int hex_byte; -+ int nybble; -+ -+ length = (length >= ((MAX_BUFF / 3) + 1)) ? (MAX_BUFF / 3) : length; -+ -+ while (length) -+ { -+ hex_byte = (int) *b++; -+ nybble = (hex_byte >> 4) & 0xf; -+ *s++ = hex_char[nybble]; -+ nybble = hex_byte & 0xf; -+ *s++ = hex_char[nybble]; -+ *s++ = ' '; -+ length--; -+ } -+ *s = '\0'; -+ -+ return; -+} -+ -+/* -+ * Body of sprintf function: behaves just like standard sprintf, except we -+ * have an extra argument (buffer size) which we use to ensure we don't -+ * overflow -+ */ -+ -+void Divas_vsprintf( char *buffer, -+ int size, -+ char *fmt, -+ va_list argptr) -+ -+{ -+ char c; /* single character buffer */ -+ int i; /* handy scratch counter */ -+ int f; /* format character (after %) */ -+ char *str; /* pointer into string */ -+ char temp[20]; /* temp buffer used in printing numbers */ -+ char string[MAX_BUFF]; /* output from number conversion */ -+ int length; /* length of string "str" */ -+ char fill; /* fill character ' ' or '0' */ -+ boolean_t leftjust; /* TRUE if left justified, else right justified */ -+ int fmax, fmin; /* field specifiers % MIN . MAX s */ -+ int leading; /* number of leading/trailing fill characters */ -+ char sign; /* set to '-' for negative decimals */ -+ int number; /* numeric argument */ -+ -+ char *buff_ptr; /* pointer to user's buffer of hex data */ -+ int buff_len; /* length of hex data */ -+ -+ /* make sure we have somthing to write into */ -+ -+ if ((!buffer) || (size <= 0)) -+ { -+ return; -+ } -+ -+ while (TRUE) -+ { -+ /* echo characters until end or '%' encountered */ -+ -+ while ((c = *fmt++) != '%') -+ { -+ if (!c) -+ { -+ *buffer = '\0'; -+ return; -+ } -+ WRITE_CHAR(buffer, size, c); -+ } -+ -+ /* echo %% as % */ -+ -+ if (*fmt == '%') -+ { -+ WRITE_CHAR(buffer, size, *fmt); -+ continue; -+ } -+ -+ /* %- turns on left-justify */ -+ -+ if ((leftjust = (boolean_t) ((*fmt == '-') ? TRUE : FALSE))) -+ { -+ fmt++; -+ } -+ -+ /* %0 turns on zero filling */ -+ -+ if (*fmt == '0') -+ { -+ fill = '0'; -+ } -+ else -+ { -+ fill = ' '; -+ } -+ -+ /* minium field width specifier for %d, u, x, c, s */ -+ -+ fmin = 0; -+ -+ if (*fmt == '*') -+ { -+ fmin = va_arg(argptr, int); -+ fmt++; -+ } -+ else -+ { -+ while ('0' <= *fmt && *fmt <= '9') -+ { -+ fmin = (fmin * 10) + (*fmt++ - '0'); -+ } -+ } -+ -+ /* maximum string width specifier for %s */ -+ -+ fmax = 0; -+ -+ if (*fmt == '.') -+ { -+ if (*(++fmt) == '*') -+ { -+ fmax = va_arg(argptr, int); -+ fmt++; -+ } -+ else -+ { -+ while ('0' <= *fmt && *fmt <= '9') -+ { -+ fmax = (fmax * 10) + (*fmt++ - '0'); -+ } -+ } -+ } -+ -+ /* skip over 'l' option (ints are assumed same size as longs) */ -+ -+ if (*fmt == 'l') -+ { -+ fmt++; -+ } -+ -+ /* get the format chacater */ -+ -+ if (!(f = *fmt++)) -+ { -+ WRITE_CHAR(buffer, size, '%'); -+ *buffer = '\0'; -+ return; -+ } -+ -+ sign = '\0'; /* sign == '-' for negative decimal */ -+ -+ str = string; -+ -+ switch (f) -+ { -+ case 'c' : -+ string[0] = (char) va_arg(argptr, int); -+ string[1] = '\0'; -+ fmax = 0; -+ fill = ' '; -+ break; -+ -+ case 's' : -+ str = va_arg(argptr, char *); -+ fill = ' '; -+ break; -+ -+ case 'D' : -+ case 'd' : -+ number = va_arg(argptr, int); -+ if (number < 0) -+ { -+ sign = '-'; -+ number = -number; -+ } -+ do_decimal(temp, DIM(temp), (unsigned int) number, str); -+ fmax = 0; -+ break; -+ -+ case 'U' : -+ case 'u' : -+ number = va_arg(argptr, int); -+ do_decimal(temp, DIM(temp), (unsigned int) number, str); -+ fmax = 0; -+ break; -+ -+ case 'O' : -+ case 'o' : -+ number = va_arg(argptr, int); -+ do_octal(temp, (unsigned int) number, str); -+ fmax = 0; -+ break; -+ -+ case 'X' : -+ case 'x' : -+ number = va_arg(argptr, int); -+ do_hex(temp, (unsigned int) number, str); -+ fmax = 0; -+ break; -+ -+ case 'H' : -+ case 'h' : -+ buff_ptr = va_arg(argptr, char *); -+ buff_len = va_arg(argptr, int); -+ do_buffer(buff_ptr, buff_len, str); -+ fmax = 0; -+ break; -+ -+ default : -+ WRITE_CHAR(buffer, size, ((char) f)); -+ break; -+ } -+ -+ /* get the length of the string */ -+ -+ length = 0; -+ while (str[length]) -+ { -+ length++; -+ } -+ -+ /* make sure we have fmax and fmin values that are O.K. */ -+ -+ if (fmin > DIM(string) || fmin < 0) -+ { -+ fmin = 0; -+ } -+ -+ if (fmax > DIM(string) || fmax < 0) -+ { -+ fmax = 0; -+ } -+ -+ /* figure out how many leading characters thare are */ -+ -+ leading = 0; -+ -+ if (fmax || fmin) -+ { -+ if (fmax) -+ { -+ if (length > fmax) -+ { -+ length = fmax; -+ } -+ } -+ -+ if (fmin) -+ { -+ leading = fmin - length; -+ } -+ -+ if (sign == '-') -+ { -+ leading--; -+ } -+ } -+ -+ /* output sign now, if fill is numeric */ -+ -+ if (sign == '-' && fill == '0') -+ { -+ WRITE_CHAR(buffer, size, '-'); -+ } -+ -+ /* if right justified, output fill characters */ -+ -+ if (!leftjust) -+ { -+ for (i = 0; i < leading; i++) -+ { -+ WRITE_CHAR(buffer, size, fill); -+ } -+ } -+ -+ /* output sign now, if fill is spaces */ -+ -+ if (sign == '-' && fill == ' ') -+ { -+ WRITE_CHAR(buffer, size, '-'); -+ } -+ -+ /* now the actual value */ -+ -+ for (i = 0; i < length; i++) -+ { -+ WRITE_CHAR(buffer, size, str[i]); -+ } -+ -+ /* if left justified, fill out with the fill character */ -+ -+ if (leftjust) -+ { -+ for (i = 0; i < leading; i++) -+ { -+ WRITE_CHAR(buffer, size, fill); -+ } -+ } -+ } -+} -+ -+/* -+ * sprintf for kernel -+ * -+ * call our vsprintf assuming user has a big buffer.... -+ */ -+ -+void DivasSprintf(char *buffer, char *fmt, ...) -+ -+{ -+ va_list argptr; /* pointer to additional args */ -+ -+ va_start(argptr, fmt); -+ -+ Divas_vsprintf(buffer, 1024, fmt, argptr); -+ -+ va_end(argptr); -+ -+ return; -+} -+ - void DivasPrintf(char *fmt, ...) - - { -@@ -40,7 +502,7 @@ void DivasPrintf(char *fmt, ...) - - /* call vsprintf to format the user's information */ - -- vsnprintf(log.buffer, DIM(log.buffer), fmt, argptr); -+ Divas_vsprintf(log.buffer, DIM(log.buffer), fmt, argptr); - - va_end(argptr); - ---- a/drivers/isdn/eicon/lincfg.c -+++ b/drivers/isdn/eicon/lincfg.c -@@ -26,6 +26,9 @@ - #include "uxio.h" - - #include <linux/pci.h> -+#ifndef COMPAT_HAS_2_2_PCI -+#include <linux/pci_ids.h> -+#endif - #include <linux/kernel.h> - #include <linux/ioport.h> - ---- a/drivers/isdn/eicon/linchr.c -+++ b/drivers/isdn/eicon/linchr.c -@@ -154,17 +154,17 @@ ssize_t do_read(struct file *pFile, char - klog_t *pHeadItem; - - if (BufferSize < sizeof(klog_t)) -+ { -+ printk(KERN_WARNING "Divas: Divalog buffer specifed a size that is too small (%d - %d required)\n", -+ BufferSize, sizeof(klog_t)); - return -EIO; -+ } - - pHeadItem = (klog_t *) DivasLogFifoRead(); - - if (pHeadItem) - { -- if(copy_to_user(pClientLogBuffer, pHeadItem, sizeof(klog_t))) -- { -- kfree(pHeadItem); -- return -EFAULT; -- } -+ memcpy(pClientLogBuffer, pHeadItem, sizeof(klog_t)); - kfree(pHeadItem); - return sizeof(klog_t); - } ---- a/drivers/isdn/eicon/linio.c -+++ b/drivers/isdn/eicon/linio.c -@@ -15,6 +15,7 @@ - #include <linux/slab.h> - #include <linux/pci.h> - #include <linux/delay.h> -+#include <linux/isdn_compat.h> - #undef N_DATA - - #include "uxio.h" ---- a/drivers/isdn/hisax/Makefile -+++ b/drivers/isdn/hisax/Makefile -@@ -4,20 +4,17 @@ - - O_TARGET := vmlinux-obj.o - --# Define maximum number of cards -- --EXTRA_CFLAGS += -DHISAX_MAX_CARDS=$(CONFIG_HISAX_MAX_CARDS) -- - # Objects that export symbols. - --export-objs := config.o hisax_isac.o isdnhdlc.o -+export-objs := config.o fsm.o hisax_isac.o - - # Multipart objects. - - list-multi := hisax.o hisax_st5481.o - hisax-objs := config.o isdnl1.o tei.o isdnl2.o isdnl3.o \ - lmgr.o q931.o callc.o fsm.o cert.o --hisax_st5481-objs := st5481_init.o st5481_usb.o st5481_d.o st5481_b.o -+hisax_st5481-objs := st5481_init.o st5481_usb.o st5481_d.o st5481_b.o \ -+ st5481_hdlc.o - - # Optional parts of multipart objects. - hisax-objs-$(CONFIG_HISAX_EURO) += l3dss1.o -@@ -33,7 +30,7 @@ hisax-objs-$(CONFIG_HISAX_AVM_A1_PCMCIA) - hisax-objs-$(CONFIG_HISAX_FRITZPCI) += avm_pci.o isac.o arcofi.o - hisax-objs-$(CONFIG_HISAX_ELSA) += elsa.o isac.o arcofi.o hscx.o - hisax-objs-$(CONFIG_HISAX_IX1MICROR2) += ix1_micro.o isac.o arcofi.o hscx.o --hisax-objs-$(CONFIG_HISAX_DIEHLDIVA) += diva.o isac.o arcofi.o hscx.o ipacx.o -+hisax-objs-$(CONFIG_HISAX_DIEHLDIVA) += diva.o isac.o arcofi.o hscx.o - hisax-objs-$(CONFIG_HISAX_ASUSCOM) += asuscom.o isac.o arcofi.o hscx.o - hisax-objs-$(CONFIG_HISAX_TELEINT) += teleint.o isac.o arcofi.o hfc_2bs0.o - hisax-objs-$(CONFIG_HISAX_SEDLBAUER) += sedlbauer.o isac.o arcofi.o hscx.o isar.o -@@ -44,6 +41,7 @@ hisax-objs-$(CONFIG_HISAX_NETJET_U) += n - hisax-objs-$(CONFIG_HISAX_HFCS) += hfcscard.o hfc_2bds0.o - hisax-objs-$(CONFIG_HISAX_HFC_PCI) += hfc_pci.o - hisax-objs-$(CONFIG_HISAX_HFC_SX) += hfc_sx.o -+hisax-objs-$(CONFIG_HISAX_HFC_USB) += hfc_usbr.o - hisax-objs-$(CONFIG_HISAX_NICCY) += niccy.o isac.o arcofi.o hscx.o - hisax-objs-$(CONFIG_HISAX_ISURF) += isurf.o isac.o arcofi.o isar.o - hisax-objs-$(CONFIG_HISAX_HSTSAPHIR) += saphir.o isac.o arcofi.o hscx.o -@@ -51,7 +49,6 @@ hisax-objs-$(CONFIG_HISAX_BKM_A4T) += bk - hisax-objs-$(CONFIG_HISAX_SCT_QUADRO) += bkm_a8.o isac.o arcofi.o hscx.o - hisax-objs-$(CONFIG_HISAX_GAZEL) += gazel.o isac.o arcofi.o hscx.o - hisax-objs-$(CONFIG_HISAX_W6692) += w6692.o --hisax-objs-$(CONFIG_HISAX_ENTERNOW_PCI) += enternow_pci.o amd7930_fn.o - #hisax-objs-$(CONFIG_HISAX_TESTEMU) += testemu.o - - hisax-objs += $(sort $(hisax-objs-y)) -@@ -61,10 +58,9 @@ hisax-objs += $(sort $(hisax-objs-y)) - obj-$(CONFIG_ISDN_DRV_HISAX) += hisax.o - obj-$(CONFIG_HISAX_SEDLBAUER_CS) += sedlbauer_cs.o - obj-$(CONFIG_HISAX_ELSA_CS) += elsa_cs.o --obj-$(CONFIG_HISAX_AVM_A1_CS) += avma1_cs.o --obj-$(CONFIG_HISAX_ST5481) += hisax_st5481.o isdnhdlc.o --obj-$(CONFIG_HISAX_FRITZ_PCIPNP) += hisax_isac.o hisax_fcpcipnp.o --obj-$(CONFIG_USB_AUERISDN) += isdnhdlc.o -+obj-$(CONFIG_HISAX_HFC_USB_CS) += hfc_usb.o -+obj-$(CONFIG_HISAX_ST5481) += hisax_st5481.o -+obj-$(CONFIG_HISAX_FRITZ_PCIPNP) += hisax_fcpcipnp.o hisax_isac.o - - CERT := $(shell md5sum -c md5sums.asc >> /dev/null;echo $$?) - CFLAGS_cert.o := -DCERTIFICATION=$(CERT) ---- /dev/null -+++ b/drivers/isdn/hisax/amd7930.c -@@ -0,0 +1,755 @@ -+/* $Id: amd7930.c,v 1.8 2001/09/24 13:22:55 kai Exp $ -+ * -+ * HiSax ISDN driver - chip specific routines for AMD 7930 -+ * -+ * Author Brent Baccala -+ * Copyright by Brent Baccala <baccala@FreeSoft.org> -+ * -+ * This software may be used and distributed according to the terms -+ * of the GNU General Public License, incorporated herein by reference. -+ * -+ * - Existing ISDN HiSax driver provides all the smarts -+ * - it compiles, runs, talks to an isolated phone switch, connects -+ * to a Cisco, pings go through -+ * - AMD 7930 support only (no DBRI yet) -+ * - no US NI-1 support (may not work on US phone system - untested) -+ * - periodic packet loss, apparently due to lost interrupts -+ * - ISDN sometimes freezes, requiring reboot before it will work again -+ * -+ * The code is unreliable enough to be consider alpha -+ * -+ * This file is (c) under GNU General Public License -+ * -+ * Advanced Micro Devices' Am79C30A is an ISDN/audio chip used in the -+ * SparcStation 1+. The chip provides microphone and speaker interfaces -+ * which provide mono-channel audio at 8K samples per second via either -+ * 8-bit A-law or 8-bit mu-law encoding. Also, the chip features an -+ * ISDN BRI Line Interface Unit (LIU), I.430 S/T physical interface, -+ * which performs basic D channel LAPD processing and provides raw -+ * B channel data. The digital audio channel, the two ISDN B channels, -+ * and two 64 Kbps channels to the microprocessor are all interconnected -+ * via a multiplexer. -+ * -+ * This driver interfaces to the Linux HiSax ISDN driver, which performs -+ * all high-level Q.921 and Q.931 ISDN functions. The file is not -+ * itself a hardware driver; rather it uses functions exported by -+ * the AMD7930 driver in the sparcaudio subsystem (drivers/sbus/audio), -+ * allowing the chip to be simultaneously used for both audio and ISDN data. -+ * The hardware driver does _no_ buffering, but provides several callbacks -+ * which are called during interrupt service and should therefore run quickly. -+ * -+ * D channel transmission is performed by passing the hardware driver the -+ * address and size of an skb's data area, then waiting for a callback -+ * to signal successful transmission of the packet. A task is then -+ * queued to notify the HiSax driver that another packet may be transmitted. -+ * -+ * D channel reception is quite simple, mainly because of: -+ * 1) the slow speed of the D channel - 16 kbps, and -+ * 2) the presence of an 8- or 32-byte (depending on chip version) FIFO -+ * to buffer the D channel data on the chip -+ * Worst case scenario of back-to-back packets with the 8 byte buffer -+ * at 16 kbps yields an service time of 4 ms - long enough to preclude -+ * the need for fancy buffering. We queue a background task that copies -+ * data out of the receive buffer into an skb, and the hardware driver -+ * simply does nothing until we're done with the receive buffer and -+ * reset it for a new packet. -+ * -+ * B channel processing is more complex, because of: -+ * 1) the faster speed - 64 kbps, -+ * 2) the lack of any on-chip buffering (it interrupts for every byte), and -+ * 3) the lack of any chip support for HDLC encapsulation -+ * -+ * The HiSax driver can put each B channel into one of three modes - -+ * L1_MODE_NULL (channel disabled), L1_MODE_TRANS (transparent data relay), -+ * and L1_MODE_HDLC (HDLC encapsulation by low-level driver). -+ * L1_MODE_HDLC is the most common, used for almost all "pure" digital -+ * data sessions. L1_MODE_TRANS is used for ISDN audio. -+ * -+ * HDLC B channel transmission is performed via a large buffer into -+ * which the skb is copied while performing HDLC bit-stuffing. A CRC -+ * is computed and attached to the end of the buffer, which is then -+ * passed to the low-level routines for raw transmission. Once -+ * transmission is complete, the hardware driver is set to enter HDLC -+ * idle by successive transmission of mark (all 1) bytes, waiting for -+ * the ISDN driver to prepare another packet for transmission and -+ * deliver it. -+ * -+ * HDLC B channel reception is performed via an X-byte ring buffer -+ * divided into N sections of X/N bytes each. Defaults: X=256 bytes, N=4. -+ * As the hardware driver notifies us that each section is full, we -+ * hand it the next section and schedule a background task to peruse -+ * the received section, bit-by-bit, with an HDLC decoder. As -+ * packets are detected, they are copied into a large buffer while -+ * decoding HDLC bit-stuffing. The ending CRC is verified, and if -+ * it is correct, we alloc a new skb of the correct length (which we -+ * now know), copy the packet into it, and hand it to the upper layers. -+ * Optimization: for large packets, we hand the buffer (which also -+ * happens to be an skb) directly to the upper layer after an skb_trim, -+ * and alloc a new large buffer for future packets, thus avoiding a copy. -+ * Then we return to HDLC processing; state is saved between calls. -+ * -+ */ -+ -+#define __NO_VERSION__ -+#include "hisax.h" -+#include "../../sbus/audio/amd7930.h" -+#include "isac.h" -+#include "isdnl1.h" -+#include "rawhdlc.h" -+#include <linux/interrupt.h> -+ -+static const char *amd7930_revision = "$Revision: 1.8 $"; -+ -+#define RCV_BUFSIZE 1024 /* Size of raw receive buffer in bytes */ -+#define RCV_BUFBLKS 4 /* Number of blocks to divide buffer into -+ * (must divide RCV_BUFSIZE) */ -+ -+static void Bchan_fill_fifo(struct BCState *, struct sk_buff *); -+ -+static void -+Bchan_xmt_bh(struct BCState *bcs) -+{ -+ struct sk_buff *skb; -+ -+ if (bcs->hw.amd7930.tx_skb != NULL) { -+ dev_kfree_skb(bcs->hw.amd7930.tx_skb); -+ bcs->hw.amd7930.tx_skb = NULL; -+ } -+ -+ if ((skb = skb_dequeue(&bcs->squeue))) { -+ Bchan_fill_fifo(bcs, skb); -+ } else { -+ clear_bit(BC_FLG_BUSY, &bcs->Flag); -+ bcs->event |= 1 << B_XMTBUFREADY; -+ queue_task(&bcs->tqueue, &tq_immediate); -+ mark_bh(IMMEDIATE_BH); -+ } -+} -+ -+static void -+Bchan_xmit_callback(struct BCState *bcs) -+{ -+ queue_task(&bcs->hw.amd7930.tq_xmt, &tq_immediate); -+ mark_bh(IMMEDIATE_BH); -+} -+ -+/* B channel transmission: two modes (three, if you count L1_MODE_NULL) -+ * -+ * L1_MODE_HDLC - We need to do HDLC encapsulation before transmiting -+ * the packet (i.e. make_raw_hdlc_data). Since this can be a -+ * time-consuming operation, our completion callback just schedules -+ * a bottom half to do encapsulation for the next packet. In between, -+ * the link will just idle -+ * -+ * L1_MODE_TRANS - Data goes through, well, transparent. No HDLC encap, -+ * and we can't just let the link idle, so the "bottom half" actually -+ * gets called during the top half (it's our callback routine in this case), -+ * but it's a lot faster now since we don't call make_raw_hdlc_data -+ */ -+ -+static void -+Bchan_fill_fifo(struct BCState *bcs, struct sk_buff *skb) -+{ -+ struct IsdnCardState *cs = bcs->cs; -+ int len; -+ -+ if ((cs->debug & L1_DEB_HSCX) || (cs->debug & L1_DEB_HSCX_FIFO)) { -+ char tmp[1024]; -+ char *t = tmp; -+ -+ t += sprintf(t, "amd7930_fill_fifo %c cnt %d", -+ bcs->channel ? 'B' : 'A', skb->len); -+ if (cs->debug & L1_DEB_HSCX_FIFO) -+ QuickHex(t, skb->data, skb->len); -+ debugl1(cs, tmp); -+ } -+ -+ if (bcs->mode == L1_MODE_HDLC) { -+ len = make_raw_hdlc_data(skb->data, skb->len, -+ bcs->hw.amd7930.tx_buff, RAW_BUFMAX); -+ if (len > 0) -+ amd7930_bxmit(0, bcs->channel, -+ bcs->hw.amd7930.tx_buff, len, -+ (void *) &Bchan_xmit_callback, -+ (void *) bcs); -+ dev_kfree_skb(skb); -+ } else if (bcs->mode == L1_MODE_TRANS) { -+ amd7930_bxmit(0, bcs->channel, -+ bcs->hw.amd7930.tx_buff, skb->len, -+ (void *) &Bchan_xmt_bh, -+ (void *) bcs); -+ bcs->hw.amd7930.tx_skb = skb; -+ } else { -+ dev_kfree_skb(skb); -+ } -+} -+ -+static void -+Bchan_mode(struct BCState *bcs, int mode, int bc) -+{ -+ struct IsdnCardState *cs = bcs->cs; -+ -+ if (cs->debug & L1_DEB_HSCX) { -+ char tmp[40]; -+ sprintf(tmp, "AMD 7930 mode %d bchan %d/%d", -+ mode, bc, bcs->channel); -+ debugl1(cs, tmp); -+ } -+ bcs->mode = mode; -+} -+ -+/* Bchan_l2l1 is the entry point for upper layer routines that want to -+ * transmit on the B channel. PH_DATA_REQ is a normal packet that -+ * we either start transmitting (if idle) or queue (if busy). -+ * PH_PULL_REQ can be called to request a callback message (PH_PULL_CNF) -+ * once the link is idle. After a "pull" callback, the upper layer -+ * routines can use PH_PULL_IND to send data. -+ */ -+ -+static void -+Bchan_l2l1(struct PStack *st, int pr, void *arg) -+{ -+ struct sk_buff *skb = arg; -+ -+ switch (pr) { -+ case (PH_DATA_REQ): -+ if (test_bit(BC_FLG_BUSY, &st->l1.bcs->Flag)) { -+ skb_queue_tail(&st->l1.bcs->squeue, skb); -+ } else { -+ test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag); -+ Bchan_fill_fifo(st->l1.bcs, skb); -+ } -+ break; -+ case (PH_PULL_IND): -+ if (test_bit(BC_FLG_BUSY, &st->l1.bcs->Flag)) { -+ printk(KERN_WARNING "amd7930: this shouldn't happen\n"); -+ break; -+ } -+ test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag); -+ Bchan_fill_fifo(st->l1.bcs, skb); -+ break; -+ case (PH_PULL_REQ): -+ if (!test_bit(BC_FLG_BUSY, &st->l1.bcs->Flag)) { -+ clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); -+ st->l1.l1l2(st, PH_PULL_CNF, NULL); -+ } else -+ set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); -+ break; -+ } -+} -+ -+/* Receiver callback and bottom half - decodes HDLC at leisure (if -+ * L1_MODE_HDLC) and passes newly received skb on via bcs->rqueue. If -+ * a large packet is received, stick rv_skb (the buffer that the -+ * packet has been decoded into) on the receive queue and alloc a new -+ * (large) skb to act as buffer for future receives. If a small -+ * packet is received, leave rv_skb alone, alloc a new skb of the -+ * correct size, and copy the packet into it -+ */ -+ -+static void -+Bchan_recv_callback(struct BCState *bcs) -+{ -+ struct amd7930_hw *hw = &bcs->hw.amd7930; -+ -+ hw->rv_buff_in += RCV_BUFSIZE/RCV_BUFBLKS; -+ hw->rv_buff_in %= RCV_BUFSIZE; -+ -+ if (hw->rv_buff_in != hw->rv_buff_out) { -+ amd7930_brecv(0, bcs->channel, -+ hw->rv_buff + hw->rv_buff_in, -+ RCV_BUFSIZE/RCV_BUFBLKS, -+ (void *) &Bchan_recv_callback, (void *) bcs); -+ } -+ -+ queue_task(&hw->tq_rcv, &tq_immediate); -+ mark_bh(IMMEDIATE_BH); -+} -+ -+static void -+Bchan_rcv_bh(struct BCState *bcs) -+{ -+ struct IsdnCardState *cs = bcs->cs; -+ struct amd7930_hw *hw = &bcs->hw.amd7930; -+ struct sk_buff *skb; -+ int len; -+ -+ if (cs->debug & L1_DEB_HSCX) { -+ char tmp[1024]; -+ -+ sprintf(tmp, "amd7930_Bchan_rcv (%d/%d)", -+ hw->rv_buff_in, hw->rv_buff_out); -+ debugl1(cs, tmp); -+ QuickHex(tmp, hw->rv_buff + hw->rv_buff_out, -+ RCV_BUFSIZE/RCV_BUFBLKS); -+ debugl1(cs, tmp); -+ } -+ -+ do { -+ if (bcs->mode == L1_MODE_HDLC) { -+ while ((len = read_raw_hdlc_data(hw->hdlc_state, -+ hw->rv_buff + hw->rv_buff_out, RCV_BUFSIZE/RCV_BUFBLKS, -+ hw->rv_skb->tail, HSCX_BUFMAX))) { -+ if (len > 0 && (cs->debug & L1_DEB_HSCX_FIFO)) { -+ char tmp[1024]; -+ char *t = tmp; -+ -+ t += sprintf(t, "amd7930_Bchan_rcv %c cnt %d", bcs->channel ? 'B' : 'A', len); -+ QuickHex(t, hw->rv_skb->tail, len); -+ debugl1(cs, tmp); -+ } -+ -+ if (len > HSCX_BUFMAX/2) { -+ /* Large packet received */ -+ -+ if (!(skb = dev_alloc_skb(HSCX_BUFMAX))) { -+ printk(KERN_WARNING "amd7930: receive out of memory"); -+ } else { -+ skb_put(hw->rv_skb, len); -+ skb_queue_tail(&bcs->rqueue, hw->rv_skb); -+ hw->rv_skb = skb; -+ bcs->event |= 1 << B_RCVBUFREADY; -+ queue_task(&bcs->tqueue, &tq_immediate); -+ } -+ } else if (len > 0) { -+ /* Small packet received */ -+ -+ if (!(skb = dev_alloc_skb(len))) { -+ printk(KERN_WARNING "amd7930: receive out of memory\n"); -+ } else { -+ memcpy(skb_put(skb, len), hw->rv_skb->tail, len); -+ skb_queue_tail(&bcs->rqueue, skb); -+ bcs->event |= 1 << B_RCVBUFREADY; -+ queue_task(&bcs->tqueue, &tq_immediate); -+ mark_bh(IMMEDIATE_BH); -+ } -+ } else { -+ /* Reception Error */ -+ /* printk("amd7930: B channel receive error\n"); */ -+ } -+ } -+ } else if (bcs->mode == L1_MODE_TRANS) { -+ if (!(skb = dev_alloc_skb(RCV_BUFSIZE/RCV_BUFBLKS))) { -+ printk(KERN_WARNING "amd7930: receive out of memory\n"); -+ } else { -+ memcpy(skb_put(skb, RCV_BUFSIZE/RCV_BUFBLKS), -+ hw->rv_buff + hw->rv_buff_out, -+ RCV_BUFSIZE/RCV_BUFBLKS); -+ skb_queue_tail(&bcs->rqueue, skb); -+ bcs->event |= 1 << B_RCVBUFREADY; -+ queue_task(&bcs->tqueue, &tq_immediate); -+ mark_bh(IMMEDIATE_BH); -+ } -+ } -+ -+ if (hw->rv_buff_in == hw->rv_buff_out) { -+ /* Buffer was filled up - need to restart receiver */ -+ amd7930_brecv(0, bcs->channel, -+ hw->rv_buff + hw->rv_buff_in, -+ RCV_BUFSIZE/RCV_BUFBLKS, -+ (void *) &Bchan_recv_callback, -+ (void *) bcs); -+ } -+ -+ hw->rv_buff_out += RCV_BUFSIZE/RCV_BUFBLKS; -+ hw->rv_buff_out %= RCV_BUFSIZE; -+ -+ } while (hw->rv_buff_in != hw->rv_buff_out); -+} -+ -+static void -+Bchan_close(struct BCState *bcs) -+{ -+ struct sk_buff *skb; -+ -+ Bchan_mode(bcs, 0, 0); -+ amd7930_bclose(0, bcs->channel); -+ -+ if (test_bit(BC_FLG_INIT, &bcs->Flag)) { -+ skb_queue_purge(&bcs->rqueue); -+ skb_queue_purge(&bcs->squeue); -+ } -+ test_and_clear_bit(BC_FLG_INIT, &bcs->Flag); -+} -+ -+static int -+Bchan_open(struct BCState *bcs) -+{ -+ struct amd7930_hw *hw = &bcs->hw.amd7930; -+ -+ if (!test_and_set_bit(BC_FLG_INIT, &bcs->Flag)) { -+ skb_queue_head_init(&bcs->rqueue); -+ skb_queue_head_init(&bcs->squeue); -+ } -+ test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); -+ -+ amd7930_bopen(0, bcs->channel, 0xff); -+ hw->rv_buff_in = 0; -+ hw->rv_buff_out = 0; -+ hw->tx_skb = NULL; -+ init_hdlc_state(hw->hdlc_state, 0); -+ amd7930_brecv(0, bcs->channel, -+ hw->rv_buff + hw->rv_buff_in, RCV_BUFSIZE/RCV_BUFBLKS, -+ (void *) &Bchan_recv_callback, (void *) bcs); -+ -+ bcs->event = 0; -+ bcs->tx_cnt = 0; -+ return (0); -+} -+ -+static void -+Bchan_init(struct BCState *bcs) -+{ -+ if (!(bcs->hw.amd7930.tx_buff = kmalloc(RAW_BUFMAX, GFP_ATOMIC))) { -+ printk(KERN_WARNING -+ "HiSax: No memory for amd7930.tx_buff\n"); -+ return; -+ } -+ if (!(bcs->hw.amd7930.rv_buff = kmalloc(RCV_BUFSIZE, GFP_ATOMIC))) { -+ printk(KERN_WARNING -+ "HiSax: No memory for amd7930.rv_buff\n"); -+ return; -+ } -+ if (!(bcs->hw.amd7930.rv_skb = dev_alloc_skb(HSCX_BUFMAX))) { -+ printk(KERN_WARNING -+ "HiSax: No memory for amd7930.rv_skb\n"); -+ return; -+ } -+ if (!(bcs->hw.amd7930.hdlc_state = kmalloc(sizeof(struct hdlc_state), -+ GFP_ATOMIC))) { -+ printk(KERN_WARNING -+ "HiSax: No memory for amd7930.hdlc_state\n"); -+ return; -+ } -+ -+ bcs->hw.amd7930.tq_rcv.sync = 0; -+ bcs->hw.amd7930.tq_rcv.routine = (void (*)(void *)) &Bchan_rcv_bh; -+ bcs->hw.amd7930.tq_rcv.data = (void *) bcs; -+ -+ bcs->hw.amd7930.tq_xmt.sync = 0; -+ bcs->hw.amd7930.tq_xmt.routine = (void (*)(void *)) &Bchan_xmt_bh; -+ bcs->hw.amd7930.tq_xmt.data = (void *) bcs; -+} -+ -+static void -+Bchan_manl1(struct PStack *st, int pr, -+ void *arg) -+{ -+ switch (pr) { -+ case (PH_ACTIVATE_REQ): -+ test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag); -+ Bchan_mode(st->l1.bcs, st->l1.mode, st->l1.bc); -+ st->l1.l1man(st, PH_ACTIVATE_CNF, NULL); -+ break; -+ case (PH_DEACTIVATE_REQ): -+ if (!test_bit(BC_FLG_BUSY, &st->l1.bcs->Flag)) -+ Bchan_mode(st->l1.bcs, 0, 0); -+ test_and_clear_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag); -+ break; -+ } -+} -+ -+int -+setstack_amd7930(struct PStack *st, struct BCState *bcs) -+{ -+ if (Bchan_open(bcs)) -+ return (-1); -+ st->l1.bcs = bcs; -+ st->l2.l2l1 = Bchan_l2l1; -+ st->ma.manl1 = Bchan_manl1; -+ setstack_manager(st); -+ bcs->st = st; -+ return (0); -+} -+ -+ -+static void -+amd7930_drecv_callback(void *arg, int error, unsigned int count) -+{ -+ struct IsdnCardState *cs = (struct IsdnCardState *) arg; -+ static struct tq_struct task; -+ struct sk_buff *skb; -+ -+ /* NOTE: This function is called directly from an interrupt handler */ -+ -+ if (1) { -+ if (!(skb = alloc_skb(count, GFP_ATOMIC))) -+ printk(KERN_WARNING "HiSax: D receive out of memory\n"); -+ else { -+ memcpy(skb_put(skb, count), cs->rcvbuf, count); -+ skb_queue_tail(&cs->rq, skb); -+ } -+ -+ task.routine = (void *) DChannel_proc_rcv; -+ task.data = (void *) cs; -+ queue_task(&task, &tq_immediate); -+ mark_bh(IMMEDIATE_BH); -+ } -+ -+ if (cs->debug & L1_DEB_ISAC_FIFO) { -+ char tmp[128]; -+ char *t = tmp; -+ -+ t += sprintf(t, "amd7930 Drecv cnt %d", count); -+ if (error) t += sprintf(t, " ERR %x", error); -+ QuickHex(t, cs->rcvbuf, count); -+ debugl1(cs, tmp); -+ } -+ -+ amd7930_drecv(0, cs->rcvbuf, MAX_DFRAME_LEN, -+ &amd7930_drecv_callback, cs); -+} -+ -+static void -+amd7930_dxmit_callback(void *arg, int error) -+{ -+ struct IsdnCardState *cs = (struct IsdnCardState *) arg; -+ static struct tq_struct task; -+ -+ /* NOTE: This function is called directly from an interrupt handler */ -+ -+ /* may wish to do retransmission here, if error indicates collision */ -+ -+ if (cs->debug & L1_DEB_ISAC_FIFO) { -+ char tmp[128]; -+ char *t = tmp; -+ -+ t += sprintf(t, "amd7930 Dxmit cnt %d", cs->tx_skb->len); -+ if (error) t += sprintf(t, " ERR %x", error); -+ QuickHex(t, cs->tx_skb->data, cs->tx_skb->len); -+ debugl1(cs, tmp); -+ } -+ -+ cs->tx_skb = NULL; -+ -+ task.routine = (void *) DChannel_proc_xmt; -+ task.data = (void *) cs; -+ queue_task(&task, &tq_immediate); -+ mark_bh(IMMEDIATE_BH); -+} -+ -+static void -+amd7930_Dchan_l2l1(struct PStack *st, int pr, void *arg) -+{ -+ struct IsdnCardState *cs = (struct IsdnCardState *) st->l1.hardware; -+ struct sk_buff *skb = arg; -+ char str[64]; -+ -+ switch (pr) { -+ case (PH_DATA_REQ): -+ if (cs->tx_skb) { -+ skb_queue_tail(&cs->sq, skb); -+#ifdef L2FRAME_DEBUG /* psa */ -+ if (cs->debug & L1_DEB_LAPD) -+ Logl2Frame(cs, skb, "PH_DATA Queued", 0); -+#endif -+ } else { -+ if ((cs->dlogflag) && (!(skb->data[2] & 1))) { -+ /* I-FRAME */ -+ LogFrame(cs, skb->data, skb->len); -+ sprintf(str, "Q.931 frame user->network tei %d", st->l2.tei); -+ dlogframe(cs, skb->data+4, skb->len-4, -+ str); -+ } -+ cs->tx_skb = skb; -+ cs->tx_cnt = 0; -+#ifdef L2FRAME_DEBUG /* psa */ -+ if (cs->debug & L1_DEB_LAPD) -+ Logl2Frame(cs, skb, "PH_DATA", 0); -+#endif -+ amd7930_dxmit(0, skb->data, skb->len, -+ &amd7930_dxmit_callback, cs); -+ } -+ break; -+ case (PH_PULL_IND): -+ if (cs->tx_skb) { -+ if (cs->debug & L1_DEB_WARN) -+ debugl1(cs, " l2l1 tx_skb exist this shouldn't happen"); -+ skb_queue_tail(&cs->sq, skb); -+ break; -+ } -+ if ((cs->dlogflag) && (!(skb->data[2] & 1))) { /* I-FRAME */ -+ LogFrame(cs, skb->data, skb->len); -+ sprintf(str, "Q.931 frame user->network tei %d", st->l2.tei); -+ dlogframe(cs, skb->data + 4, skb->len - 4, -+ str); -+ } -+ cs->tx_skb = skb; -+ cs->tx_cnt = 0; -+#ifdef L2FRAME_DEBUG /* psa */ -+ if (cs->debug & L1_DEB_LAPD) -+ Logl2Frame(cs, skb, "PH_DATA_PULLED", 0); -+#endif -+ amd7930_dxmit(0, cs->tx_skb->data, cs->tx_skb->len, -+ &amd7930_dxmit_callback, cs); -+ break; -+ case (PH_PULL_REQ): -+#ifdef L2FRAME_DEBUG /* psa */ -+ if (cs->debug & L1_DEB_LAPD) -+ debugl1(cs, "-> PH_REQUEST_PULL"); -+#endif -+ if (!cs->tx_skb) { -+ test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); -+ st->l1.l1l2(st, PH_PULL_CNF, NULL); -+ } else -+ test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); -+ break; -+ } -+} -+ -+int -+setDstack_amd7930(struct PStack *st, struct IsdnCardState *cs) -+{ -+ st->l2.l2l1 = amd7930_Dchan_l2l1; -+ if (! cs->rcvbuf) { -+ printk("setDstack_amd7930: No cs->rcvbuf!\n"); -+ } else { -+ amd7930_drecv(0, cs->rcvbuf, MAX_DFRAME_LEN, -+ &amd7930_drecv_callback, cs); -+ } -+ return (0); -+} -+ -+static void -+manl1_msg(struct IsdnCardState *cs, int msg, void *arg) { -+ struct PStack *st; -+ -+ st = cs->stlist; -+ while (st) { -+ st->ma.manl1(st, msg, arg); -+ st = st->next; -+ } -+} -+ -+static void -+amd7930_new_ph(struct IsdnCardState *cs) -+{ -+ switch (amd7930_get_liu_state(0)) { -+ case 3: -+ manl1_msg(cs, PH_POWERUP_CNF, NULL); -+ break; -+ -+ case 7: -+ manl1_msg(cs, PH_I4_P8_IND, NULL); -+ break; -+ -+ case 8: -+ manl1_msg(cs, PH_RSYNC_IND, NULL); -+ break; -+ } -+} -+ -+/* amd7930 LIU state change callback */ -+ -+static void -+amd7930_liu_callback(struct IsdnCardState *cs) -+{ -+ static struct tq_struct task; -+ -+ if (!cs) -+ return; -+ -+ if (cs->debug & L1_DEB_ISAC) { -+ char tmp[32]; -+ sprintf(tmp, "amd7930_liu state %d", amd7930_get_liu_state(0)); -+ debugl1(cs, tmp); -+ } -+ -+ task.sync = 0; -+ task.routine = (void *) &amd7930_new_ph; -+ task.data = (void *) cs; -+ queue_task(&task, &tq_immediate); -+ mark_bh(IMMEDIATE_BH); -+} -+ -+void -+amd7930_l1cmd(struct IsdnCardState *cs, int msg, void *arg) -+{ -+ u_char val; -+ char tmp[32]; -+ -+ if (cs->debug & L1_DEB_ISAC) { -+ char tmp[32]; -+ sprintf(tmp, "amd7930_l1cmd msg %x", msg); -+ debugl1(cs, tmp); -+ } -+ -+ switch(msg) { -+ case PH_RESET_REQ: -+ if (amd7930_get_liu_state(0) <= 3) -+ amd7930_liu_activate(0,0); -+ else -+ amd7930_liu_deactivate(0); -+ break; -+ case PH_ENABLE_REQ: -+ break; -+ case PH_INFO3_REQ: -+ amd7930_liu_activate(0,0); -+ break; -+ case PH_TESTLOOP_REQ: -+ break; -+ default: -+ if (cs->debug & L1_DEB_WARN) { -+ sprintf(tmp, "amd7930_l1cmd unknown %4x", msg); -+ debugl1(cs, tmp); -+ } -+ break; -+ } -+} -+ -+static void init_amd7930(struct IsdnCardState *cs) -+{ -+ Bchan_init(&cs->bcs[0]); -+ Bchan_init(&cs->bcs[1]); -+ cs->bcs[0].BC_SetStack = setstack_amd7930; -+ cs->bcs[1].BC_SetStack = setstack_amd7930; -+ cs->bcs[0].BC_Close = Bchan_close; -+ cs->bcs[1].BC_Close = Bchan_close; -+ Bchan_mode(cs->bcs, 0, 0); -+ Bchan_mode(cs->bcs + 1, 0, 0); -+} -+ -+void -+release_amd7930(struct IsdnCardState *cs) -+{ -+} -+ -+static int -+amd7930_card_msg(struct IsdnCardState *cs, int mt, void *arg) -+{ -+ switch (mt) { -+ case CARD_RESET: -+ return(0); -+ case CARD_RELEASE: -+ release_amd7930(cs); -+ return(0); -+ case CARD_INIT: -+ cs->l1cmd = amd7930_l1cmd; -+ amd7930_liu_init(0, &amd7930_liu_callback, (void *)cs); -+ init_amd7930(cs); -+ return(0); -+ case CARD_TEST: -+ return(0); -+ } -+ return(0); -+} -+ -+int __init -+setup_amd7930(struct IsdnCard *card) -+{ -+ struct IsdnCardState *cs = card->cs; -+ char tmp[64]; -+ -+ strcpy(tmp, amd7930_revision); -+ printk(KERN_INFO "HiSax: AMD7930 driver Rev. %s\n", HiSax_getrev(tmp)); -+ if (cs->typ != ISDN_CTYPE_AMD7930) -+ return (0); -+ -+ cs->irq = amd7930_get_irqnum(0); -+ if (cs->irq == 0) -+ return (0); -+ -+ cs->cardmsg = &amd7930_card_msg; -+ -+ return (1); -+} ---- a/drivers/isdn/hisax/arcofi.c -+++ b/drivers/isdn/hisax/arcofi.c -@@ -1,4 +1,4 @@ --/* $Id: arcofi.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: arcofi.c,v 1.14 2001/09/24 13:22:55 kai Exp $ - * - * Ansteuerung ARCOFI 2165 - * ---- a/drivers/isdn/hisax/arcofi.h -+++ b/drivers/isdn/hisax/arcofi.h -@@ -1,4 +1,4 @@ --/* $Id: arcofi.h,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id$ - * - * Ansteuerung ARCOFI 2165 - * ---- a/drivers/isdn/hisax/asuscom.c -+++ b/drivers/isdn/hisax/asuscom.c -@@ -1,4 +1,4 @@ --/* $Id: asuscom.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: asuscom.c,v 1.14 2001/09/24 13:22:55 kai Exp $ - * - * low level stuff for ASUSCOM NETWORK INC. ISDNLink cards - * -@@ -14,7 +14,6 @@ - - #define __NO_VERSION__ - #include <linux/init.h> --#include <linux/isapnp.h> - #include "hisax.h" - #include "isac.h" - #include "ipac.h" -@@ -23,7 +22,7 @@ - - extern const char *CardType[]; - --const char *Asuscom_revision = "$Revision: 1.1.4.1 $"; -+const char *Asuscom_revision = "$Revision: 1.14 $"; - - #define byteout(addr,val) outb(val,addr) - #define bytein(addr) inb(addr) -@@ -310,27 +309,6 @@ Asus_card_msg(struct IsdnCardState *cs, - return(0); - } - --#ifdef __ISAPNP__ --static struct isapnp_device_id asus_ids[] __initdata = { -- { ISAPNP_VENDOR('A', 'S', 'U'), ISAPNP_FUNCTION(0x1688), -- ISAPNP_VENDOR('A', 'S', 'U'), ISAPNP_FUNCTION(0x1688), -- (unsigned long) "Asus1688 PnP" }, -- { ISAPNP_VENDOR('A', 'S', 'U'), ISAPNP_FUNCTION(0x1690), -- ISAPNP_VENDOR('A', 'S', 'U'), ISAPNP_FUNCTION(0x1690), -- (unsigned long) "Asus1690 PnP" }, -- { ISAPNP_VENDOR('S', 'I', 'E'), ISAPNP_FUNCTION(0x0020), -- ISAPNP_VENDOR('S', 'I', 'E'), ISAPNP_FUNCTION(0x0020), -- (unsigned long) "Isurf2 PnP" }, -- { ISAPNP_VENDOR('E', 'L', 'F'), ISAPNP_FUNCTION(0x0000), -- ISAPNP_VENDOR('E', 'L', 'F'), ISAPNP_FUNCTION(0x0000), -- (unsigned long) "Iscas TE320" }, -- { 0, } --}; -- --static struct isapnp_device_id *adev = &asus_ids[0]; --static struct pci_bus *pnp_c __devinitdata = NULL; --#endif -- - int __init - setup_asuscom(struct IsdnCard *card) - { -@@ -343,45 +321,7 @@ setup_asuscom(struct IsdnCard *card) - printk(KERN_INFO "HiSax: Asuscom ISDNLink driver Rev. %s\n", HiSax_getrev(tmp)); - if (cs->typ != ISDN_CTYPE_ASUSCOM) - return (0); --#ifdef __ISAPNP__ -- if (!card->para[1] && isapnp_present()) { -- struct pci_bus *pb; -- struct pci_dev *pd; -- -- while(adev->card_vendor) { -- if ((pb = isapnp_find_card(adev->card_vendor, -- adev->card_device, pnp_c))) { -- pnp_c = pb; -- pd = NULL; -- if ((pd = isapnp_find_dev(pnp_c, -- adev->vendor, adev->function, pd))) { -- printk(KERN_INFO "HiSax: %s detected\n", -- (char *)adev->driver_data); -- pd->prepare(pd); -- pd->deactivate(pd); -- pd->activate(pd); -- card->para[1] = pd->resource[0].start; -- card->para[0] = pd->irq_resource[0].start; -- if (!card->para[0] || !card->para[1]) { -- printk(KERN_ERR "AsusPnP:some resources are missing %ld/%lx\n", -- card->para[0], card->para[1]); -- pd->deactivate(pd); -- return(0); -- } -- break; -- } else { -- printk(KERN_ERR "AsusPnP: PnP error card found, no device\n"); -- } -- } -- adev++; -- pnp_c=NULL; -- } -- if (!adev->card_vendor) { -- printk(KERN_INFO "AsusPnP: no ISAPnP card found\n"); -- return(0); -- } -- } --#endif -+ - bytecnt = 8; - cs->hw.asus.cfg_reg = card->para[1]; - cs->irq = card->para[0]; ---- a/drivers/isdn/hisax/avm_a1.c -+++ b/drivers/isdn/hisax/avm_a1.c -@@ -1,4 +1,4 @@ --/* $Id: avm_a1.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: avm_a1.c,v 2.15 2001/09/24 13:22:55 kai Exp $ - * - * low level stuff for AVM A1 (Fritz) isdn cards - * -@@ -18,7 +18,7 @@ - #include "isdnl1.h" - - extern const char *CardType[]; --static const char *avm_revision = "$Revision: 1.1.4.1 $"; -+static const char *avm_revision = "$Revision: 2.15 $"; - - #define AVM_A1_STAT_ISAC 0x01 - #define AVM_A1_STAT_HSCX 0x02 ---- a/drivers/isdn/hisax/avm_a1p.c -+++ b/drivers/isdn/hisax/avm_a1p.c -@@ -1,4 +1,4 @@ --/* $Id: avm_a1p.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: avm_a1p.c,v 2.9 2001/09/24 13:22:55 kai Exp $ - * - * low level stuff for the following AVM cards: - * A1 PCMCIA -@@ -57,7 +57,7 @@ - #define byteout(addr,val) outb(val,addr) - #define bytein(addr) inb(addr) - --static const char *avm_revision = "$Revision: 1.1.4.1 $"; -+static const char *avm_revision = "$Revision: 2.9 $"; - - static inline u_char - ReadISAC(struct IsdnCardState *cs, u_char offset) ---- a/drivers/isdn/hisax/avm_pci.c -+++ b/drivers/isdn/hisax/avm_pci.c -@@ -1,4 +1,4 @@ --/* $Id: avm_pci.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: avm_pci.c,v 1.29 2001/09/24 13:22:55 kai Exp $ - * - * low level stuff for AVM Fritz!PCI and ISA PnP isdn cards - * -@@ -19,11 +19,11 @@ - #include "isac.h" - #include "isdnl1.h" - #include <linux/pci.h> --#include <linux/isapnp.h> -+#include <linux/isdn_compat.h> - #include <linux/interrupt.h> - - extern const char *CardType[]; --static const char *avm_pci_rev = "$Revision: 1.1.4.1 $"; -+static const char *avm_pci_rev = "$Revision: 1.29 $"; - - #define AVM_FRITZ_PCI 1 - #define AVM_FRITZ_PNP 2 -@@ -291,8 +291,7 @@ hdlc_empty_fifo(struct BCState *bcs, int - debugl1(cs, "hdlc_empty_fifo: incoming packet too large"); - return; - } -- p = bcs->hw.hdlc.rcvbuf + bcs->hw.hdlc.rcvidx; -- ptr = (u_int *)p; -+ ptr = (u_int *) p = bcs->hw.hdlc.rcvbuf + bcs->hw.hdlc.rcvidx; - bcs->hw.hdlc.rcvidx += count; - if (cs->subtyp == AVM_FRITZ_PCI) { - outl(idx, cs->hw.avm.cfg_reg + 4); -@@ -353,8 +352,7 @@ hdlc_fill_fifo(struct BCState *bcs) - } - if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO)) - debugl1(cs, "hdlc_fill_fifo %d/%ld", count, bcs->tx_skb->len); -- p = bcs->tx_skb->data; -- ptr = (u_int *)p; -+ ptr = (u_int *) p = bcs->tx_skb->data; - skb_pull(bcs->tx_skb, count); - bcs->tx_cnt -= count; - bcs->hw.hdlc.count += count; -@@ -766,10 +764,6 @@ AVM_card_msg(struct IsdnCardState *cs, i - } - - static struct pci_dev *dev_avm __initdata = NULL; --#ifdef __ISAPNP__ --static struct pci_bus *bus_avm __initdata = NULL; --static struct pci_dev *pnp_avm __initdata = NULL; --#endif - - int __init - setup_avm_pcipnp(struct IsdnCard *card) -@@ -783,47 +777,10 @@ setup_avm_pcipnp(struct IsdnCard *card) - if (cs->typ != ISDN_CTYPE_FRITZPCI) - return (0); - if (card->para[1]) { -- /* old manual method */ - cs->hw.avm.cfg_reg = card->para[1]; - cs->irq = card->para[0]; - cs->subtyp = AVM_FRITZ_PNP; - } else { --#ifdef __ISAPNP__ -- if (isapnp_present()) { -- struct pci_bus *ba; -- if ((ba = isapnp_find_card( -- ISAPNP_VENDOR('A', 'V', 'M'), -- ISAPNP_FUNCTION(0x0900), bus_avm))) { -- bus_avm = ba; -- pnp_avm = NULL; -- if ((pnp_avm = isapnp_find_dev(bus_avm, -- ISAPNP_VENDOR('A', 'V', 'M'), -- ISAPNP_FUNCTION(0x0900), pnp_avm))) { -- pnp_avm->prepare(pnp_avm); -- pnp_avm->deactivate(pnp_avm); -- pnp_avm->activate(pnp_avm); -- cs->hw.avm.cfg_reg = -- pnp_avm->resource[0].start; -- cs->irq = -- pnp_avm->irq_resource[0].start; -- if (!cs->irq) { -- printk(KERN_ERR "FritzPnP:No IRQ\n"); -- pnp_avm->deactivate(pnp_avm); -- return(0); -- } -- if (!cs->hw.avm.cfg_reg) { -- printk(KERN_ERR "FritzPnP:No IO address\n"); -- pnp_avm->deactivate(pnp_avm); -- return(0); -- } -- cs->subtyp = AVM_FRITZ_PNP; -- goto ready; -- } -- } -- } else { -- printk(KERN_INFO "FritzPnP: no ISA PnP present\n"); -- } --#endif - #if CONFIG_PCI - if (!pci_present()) { - printk(KERN_ERR "FritzPCI: no PCI bus present\n"); -@@ -838,7 +795,7 @@ setup_avm_pcipnp(struct IsdnCard *card) - } - if (pci_enable_device(dev_avm)) - return(0); -- cs->hw.avm.cfg_reg = pci_resource_start(dev_avm, 1); -+ cs->hw.avm.cfg_reg = pci_resource_start_io(dev_avm, 1); - if (!cs->hw.avm.cfg_reg) { - printk(KERN_ERR "FritzPCI: No IO-Adr for PCI card found\n"); - return(0); -@@ -854,7 +811,6 @@ setup_avm_pcipnp(struct IsdnCard *card) - return (0); - #endif /* CONFIG_PCI */ - } --ready: - cs->hw.avm.isac = cs->hw.avm.cfg_reg + 0x10; - if (check_region((cs->hw.avm.cfg_reg), 32)) { - printk(KERN_WARNING ---- a/drivers/isdn/hisax/bkm_a4t.c -+++ b/drivers/isdn/hisax/bkm_a4t.c -@@ -1,4 +1,4 @@ --/* $Id: bkm_a4t.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: bkm_a4t.c,v 1.22 2001/09/24 13:22:55 kai Exp $ - * - * low level stuff for T-Berkom A4T - * -@@ -20,11 +20,12 @@ - #include "jade.h" - #include "isdnl1.h" - #include <linux/pci.h> -+#include <linux/isdn_compat.h> - #include "bkm_ax.h" - - extern const char *CardType[]; - --const char *bkm_a4t_revision = "$Revision: 1.1.4.1 $"; -+const char *bkm_a4t_revision = "$Revision: 1.22 $"; - - - static inline u_char -@@ -293,13 +294,13 @@ setup_bkm_a4t(struct IsdnCard *card) - u16 sub_sys; - u16 sub_vendor; - -- sub_vendor = dev_a4t->subsystem_vendor; -- sub_sys = dev_a4t->subsystem_device; -+ pci_get_sub_vendor(dev_a4t,sub_vendor); -+ pci_get_sub_system(dev_a4t,sub_sys); - if ((sub_sys == PCI_DEVICE_ID_BERKOM_A4T) && (sub_vendor == PCI_VENDOR_ID_BERKOM)) { - if (pci_enable_device(dev_a4t)) - return(0); - found = 1; -- pci_memaddr = pci_resource_start(dev_a4t, 0); -+ pci_memaddr = pci_resource_start_mem(dev_a4t, 0); - cs->irq = dev_a4t->irq; - break; - } ---- a/drivers/isdn/hisax/bkm_a8.c -+++ b/drivers/isdn/hisax/bkm_a8.c -@@ -1,4 +1,4 @@ --/* $Id: bkm_a8.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: bkm_a8.c,v 1.22 2001/09/24 13:22:55 kai Exp $ - * - * low level stuff for Scitel Quadro (4*S0, passive) - * -@@ -20,6 +20,7 @@ - #include "hscx.h" - #include "isdnl1.h" - #include <linux/pci.h> -+#include <linux/isdn_compat.h> - #include "bkm_ax.h" - - #if CONFIG_PCI -@@ -28,7 +29,7 @@ - - extern const char *CardType[]; - --const char sct_quadro_revision[] = "$Revision: 1.1.4.1 $"; -+const char sct_quadro_revision[] = "$Revision: 1.22 $"; - - static const char *sct_quadro_subtypes[] = - { -@@ -329,13 +330,13 @@ setup_sct_quadro(struct IsdnCard *card) - while ((dev_a8 = pci_find_device(PCI_VENDOR_ID_PLX, - PCI_DEVICE_ID_PLX_9050, dev_a8))) { - -- sub_vendor_id = dev_a8->subsystem_vendor; -- sub_sys_id = dev_a8->subsystem_device; -+ pci_get_sub_vendor(dev_a8,sub_vendor_id); -+ pci_get_sub_system(dev_a8,sub_sys_id); - if ((sub_sys_id == PCI_DEVICE_ID_BERKOM_SCITEL_QUADRO) && - (sub_vendor_id == PCI_VENDOR_ID_BERKOM)) { - if (pci_enable_device(dev_a8)) - return(0); -- pci_ioaddr1 = pci_resource_start(dev_a8, 1); -+ pci_ioaddr1 = pci_resource_start_io(dev_a8, 1); - pci_irq = dev_a8->irq; - pci_bus = dev_a8->bus->number; - pci_device_fn = dev_a8->devfn; -@@ -365,7 +366,7 @@ setup_sct_quadro(struct IsdnCard *card) - pci_ioaddr1 &= PCI_BASE_ADDRESS_IO_MASK; - pcibios_write_config_dword(pci_bus, pci_device_fn, - PCI_BASE_ADDRESS_1, pci_ioaddr1); -- dev_a8->resource[ 1].start = pci_ioaddr1; -+ get_pcibase(dev_a8, 1) = pci_ioaddr1; - } - #endif /* End HACK */ - } ---- a/drivers/isdn/hisax/bkm_ax.h -+++ b/drivers/isdn/hisax/bkm_ax.h -@@ -1,4 +1,4 @@ --/* $Id: bkm_ax.h,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id$ - * - * low level decls for T-Berkom cards A4T and Scitel Quadro (4*S0, passive) - * ---- a/drivers/isdn/hisax/callc.c -+++ b/drivers/isdn/hisax/callc.c -@@ -1,4 +1,4 @@ --/* $Id: callc.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: callc.c,v 2.59 2002/02/09 21:19:11 keil Exp $ - * - * Author Karsten Keil - * Copyright by Karsten Keil <keil@isdn4linux.de> -@@ -26,7 +26,7 @@ - #define MOD_USE_COUNT ( GET_USE_COUNT (&__this_module)) - #endif /* MODULE */ - --const char *lli_revision = "$Revision: 1.1.4.1 $"; -+const char *lli_revision = "$Revision: 2.59 $"; - - extern struct IsdnCard cards[]; - extern int nrcards; -@@ -145,9 +145,11 @@ enum { - EV_PROCEED, /* 20 */ - EV_ALERT, /* 21 */ - EV_REDIR, /* 22 */ -+ EV_ALERTING, /* 23 */ -+ EV_PROCEEDING, /* 24 */ - }; - --#define EVENT_COUNT (EV_REDIR + 1) -+#define EVENT_COUNT (EV_PROCEEDING + 1) - - static char *strEvent[] = - { -@@ -174,6 +176,8 @@ static char *strEvent[] = - "EV_PROCEED", - "EV_ALERT", - "EV_REDIR", -+ "EV_ALERTING", -+ "EV_PROCEEDING", - }; - - -@@ -286,6 +290,22 @@ lli_prep_dialout(struct FsmInst *fi, int - } - - static void -+lli_alerting(struct FsmInst *fi, int event, void *arg) -+{ -+ struct Channel *chanp = fi->userdata; -+ -+ HL_LL(chanp, ISDN_STAT_ALERT); -+} -+ -+static void -+lli_proceeding(struct FsmInst *fi, int event, void *arg) -+{ -+ struct Channel *chanp = fi->userdata; -+ -+ HL_LL(chanp, ISDN_STAT_PROCEED); -+} -+ -+static void - lli_resume(struct FsmInst *fi, int event, void *arg) - { - struct Channel *chanp = fi->userdata; -@@ -784,6 +804,8 @@ static struct FsmNode fnlist[] __initdat - {ST_OUT_DIAL, EV_DISCONNECT_IND, lli_release_req}, - {ST_OUT_DIAL, EV_RELEASE, lli_dhup_close}, - {ST_OUT_DIAL, EV_NOSETUP_RSP, lli_no_setup_rsp}, -+ {ST_OUT_DIAL, EV_PROCEEDING, lli_proceeding}, -+ {ST_OUT_DIAL, EV_ALERTING, lli_alerting}, - {ST_OUT_DIAL, EV_SETUP_ERR, lli_error}, - {ST_IN_WAIT_LL, EV_LEASED_REL, lli_failure_l}, - {ST_IN_WAIT_LL, EV_ACCEPTD, lli_setup_rsp}, -@@ -925,7 +947,7 @@ static void stat_redir_result(struct Isd - ic.driver = cs->myid; - ic.command = ISDN_STAT_REDIR; - ic.arg = chan; -- ic.parm.num[0] = result; -+ (ulong)(ic.parm.num[0]) = result; - cs->iif.statcallb(&ic); - } /* stat_redir_result */ - -@@ -997,8 +1019,13 @@ dchan_l3l4(struct PStack *st, int pr, vo - FsmEvent(&chanp->fi, EV_RELEASE, NULL); - break; - case (CC_PROCEED_SEND | INDICATION): -+ break; - case (CC_PROCEEDING | INDICATION): -+ FsmEvent(&chanp->fi, EV_PROCEEDING, NULL); -+ break; - case (CC_ALERTING | INDICATION): -+ FsmEvent(&chanp->fi, EV_ALERTING, NULL); -+ break; - case (CC_PROGRESS | INDICATION): - case (CC_NOTIFY | INDICATION): - break; ---- a/drivers/isdn/hisax/cert.c -+++ b/drivers/isdn/hisax/cert.c -@@ -1,4 +1,4 @@ --/* $Id: cert.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: cert.c,v 2.6 2001/09/24 13:22:56 kai Exp $ - * - * Author Karsten Keil - * Copyright by Karsten Keil <keil@isdn4linux.de> ---- a/drivers/isdn/hisax/config.c -+++ b/drivers/isdn/hisax/config.c -@@ -1,4 +1,4 @@ --/* $Id: config.c,v 1.1.4.5 2001/12/09 19:19:26 kai Exp $ -+/* $Id: config.c,v 2.84 2002/08/13 09:55:29 keil Exp $ - * - * Author Karsten Keil - * Copyright by Karsten Keil <keil@isdn4linux.de> -@@ -24,6 +24,11 @@ - #include <linux/kernel_stat.h> - #include <linux/tqueue.h> - #include <linux/interrupt.h> -+ -+#ifdef CONFIG_HISAX_HFC_USB -+#include "hisax_loadable.h" -+#endif -+ - #define HISAX_STATUS_BUFSIZE 4096 - #define INCLUDE_INLINE_FUNCS - -@@ -75,8 +80,7 @@ - * 37 HFC 2BDS0 S+/SP p0=irq p1=iobase - * 38 Travers Technologies NETspider-U PCI card - * 39 HFC 2BDS0-SP PCMCIA p0=irq p1=iobase -- * 40 hotplug interface -- * 41 Formula-n enter:now ISDN PCI a/b none -+ * 40 HFC-S USB none - * - * protocol can be either ISDN_PTYPE_EURO or ISDN_PTYPE_1TR6 or ISDN_PTYPE_NI1 - * -@@ -95,11 +99,17 @@ const char *CardType[] = { - "Siemens I-Surf", "Acer P10", "HST Saphir", "Telekom A4T", - "Scitel Quadro", "Gazel", "HFC 2BDS0 PCI", "Winbond 6692", - "HFC 2BDS0 SX", "NETspider-U", "HFC-2BDS0-SP PCMCIA", -- "Hotplug", "Formula-n enter:now PCI a/b", -+ "HFC-S USB", - }; - - void HiSax_closecard(int cardnr); - -+#ifdef CONFIG_HISAX_HFC_USB -+#define DEFAULT_CARD ISDN_CTYPE_HFC_USB -+#define DEFAULT_CFG {0,0,0,0} -+EXPORT_SYMBOL(hisax_register_hfcusb); -+#endif -+ - #ifdef CONFIG_HISAX_ELSA - #define DEFAULT_CARD ISDN_CTYPE_ELSA - #define DEFAULT_CFG {0,0,0,0} -@@ -339,19 +349,27 @@ EXPORT_SYMBOL(HiSax_closecard); - NULL, \ - } - --struct IsdnCard cards[HISAX_MAX_CARDS] = { -+#define EMPTY_CARD {0, DEFAULT_PROTO, {0, 0, 0, 0}, NULL} -+ -+struct IsdnCard cards[] = { - FIRST_CARD, -+ EMPTY_CARD, -+ EMPTY_CARD, -+ EMPTY_CARD, -+ EMPTY_CARD, -+ EMPTY_CARD, -+ EMPTY_CARD, -+ EMPTY_CARD, - }; - --#define HISAX_IDSIZE (HISAX_MAX_CARDS*8) --static char HiSaxID[HISAX_IDSIZE] __devinitdata = { 0, }; -+static char HiSaxID[64] __devinitdata = { 0, }; - - char *HiSax_id __devinitdata = HiSaxID; - #ifdef MODULE - /* Variables for insmod */ --static int type[HISAX_MAX_CARDS] __devinitdata = { 0, }; --static int protocol[HISAX_MAX_CARDS] __devinitdata = { 0, }; --static int io[HISAX_MAX_CARDS] __devinitdata = { 0, }; -+static int type[8] __devinitdata = { 0, }; -+static int protocol[8] __devinitdata = { 0, }; -+static int io[8] __devinitdata = { 0, }; - #undef IO0_IO1 - #ifdef CONFIG_HISAX_16_3 - #define IO0_IO1 -@@ -361,27 +379,23 @@ static int io[HISAX_MAX_CARDS] __devinit - #define IO0_IO1 - #endif - #ifdef IO0_IO1 --static int io0[HISAX_MAX_CARDS] __devinitdata = { 0, }; --static int io1[HISAX_MAX_CARDS] __devinitdata = { 0, }; -+static int io0[8] __devinitdata = { 0, }; -+static int io1[8] __devinitdata = { 0, }; - #endif --static int irq[HISAX_MAX_CARDS] __devinitdata = { 0, }; --static int mem[HISAX_MAX_CARDS] __devinitdata = { 0, }; -+static int irq[8] __devinitdata = { 0, }; -+static int mem[8] __devinitdata = { 0, }; - static char *id __devinitdata = HiSaxID; - --#define PARM_PARA "1-" __MODULE_STRING(HISAX_MAX_CARDS) "i" -- --MODULE_DESCRIPTION("ISDN4Linux: Driver for passive ISDN cards"); - MODULE_AUTHOR("Karsten Keil"); --MODULE_LICENSE("GPL"); --MODULE_PARM(type, PARM_PARA); --MODULE_PARM(protocol, PARM_PARA); --MODULE_PARM(io, PARM_PARA); --MODULE_PARM(irq, PARM_PARA); --MODULE_PARM(mem, PARM_PARA); -+MODULE_PARM(type, "1-8i"); -+MODULE_PARM(protocol, "1-8i"); -+MODULE_PARM(io, "1-8i"); -+MODULE_PARM(irq, "1-8i"); -+MODULE_PARM(mem, "1-8i"); - MODULE_PARM(id, "s"); - #ifdef IO0_IO1 --MODULE_PARM(io0, PARM_PARA); --MODULE_PARM(io1, PARM_PARA); -+MODULE_PARM(io0, "1-8i"); -+MODULE_PARM(io1, "1-8i"); - #endif - #endif /* MODULE */ - -@@ -432,6 +446,7 @@ void __init HiSaxVersion(void) - } - - #ifndef MODULE -+#ifdef COMPAT_HAS_NEW_SETUP - #define MAX_ARG (HISAX_MAX_CARDS*5) - static int __init HiSax_setup(char *line) - { -@@ -440,12 +455,16 @@ static int __init HiSax_setup(char *line - char *str; - - str = get_options(line, MAX_ARG, ints); -+#else -+void __init HiSax_setup(char *str, int *ints) -+{ -+ int i, j, argc; -+#endif - argc = ints[0]; - printk(KERN_DEBUG "HiSax_setup: argc(%d) str(%s)\n", argc, str); - i = 0; - j = 1; - while (argc && (i < HISAX_MAX_CARDS)) { -- cards[i].protocol = DEFAULT_PROTO; - if (argc) { - cards[i].typ = ints[j]; - j++; -@@ -473,19 +492,21 @@ static int __init HiSax_setup(char *line - } - i++; - } -- if (str && *str) { -- if (strlen(str) < HISAX_IDSIZE) -- strcpy(HiSaxID, str); -- else -- printk(KERN_WARNING "HiSax: ID too long!"); -- } else -+ if (str && *str) { -+ strcpy(HiSaxID, str); -+ HiSax_id = HiSaxID; -+ } else { - strcpy(HiSaxID, "HiSax"); -- -- HiSax_id = HiSaxID; -+ HiSax_id = HiSaxID; -+ } -+#ifdef COMPAT_HAS_NEW_SETUP - return 1; - } - - __setup("hisax=", HiSax_setup); -+#else -+} -+#endif /* COMPAT_HAS_NEW_SETUP */ - #endif /* MODULES */ - - #if CARD_TELES0 -@@ -560,6 +581,10 @@ extern int setup_hfcs(struct IsdnCard *c - extern int setup_hfcpci(struct IsdnCard *card); - #endif - -+#if CONFIG_HISAX_HFC_USB -+extern int setup_hfc_usb(struct IsdnCard *card); -+#endif -+ - #if CARD_HFC_SX - extern int setup_hfcsx(struct IsdnCard *card); - #endif -@@ -604,10 +629,6 @@ extern int setup_w6692(struct IsdnCard * - extern int setup_netjet_u(struct IsdnCard *card); - #endif - --#if CARD_FN_ENTERNOW_PCI --extern int setup_enternow_pci(struct IsdnCard *card); --#endif -- - /* - * Find card with given driverId - */ -@@ -899,7 +920,8 @@ static int __devinit init_card(struct Is - return 3; - } - --static int __devinit checkcard(int cardnr, char *id, int *busy_flag) -+static int __devinit checkcard(int cardnr, char *id, int *busy_flag, -+ void *load_drv) - { - long flags; - int ret = 0; -@@ -1093,6 +1115,12 @@ static int __devinit checkcard(int cardn - ret = setup_hfcsx(card); - break; - #endif -+#if CONFIG_HISAX_HFC_USB -+ case ISDN_CTYPE_HFC_USB: -+ cs->hw.hfcusb.drv = load_drv; -+ ret = setup_hfc_usb(card); -+ break; -+#endif - #if CARD_NICCY - case ISDN_CTYPE_NICCY: - ret = setup_niccy(card); -@@ -1143,11 +1171,6 @@ static int __devinit checkcard(int cardn - ret = setup_netjet_u(card); - break; - #endif --#if CARD_FN_ENTERNOW_PCI -- case ISDN_CTYPE_ENTERNOW: -- ret = setup_enternow_pci(card); -- break; --#endif - case ISDN_CTYPE_DYNAMIC: - ret = 2; - break; -@@ -1186,6 +1209,9 @@ static int __devinit checkcard(int cardn - case ISDN_CTYPE_DYNAMIC: - ret = 0; - break; -+ case ISDN_CTYPE_HFC_USB: -+ ret = cs->cardmsg(cs, CARD_INIT, NULL); -+ break; - default: - ret = init_card(cs); - break; -@@ -1257,16 +1283,13 @@ int __devinit HiSax_inithardware(int *bu - else - sprintf(ids, "%s%d", id, i); - } -- if (checkcard(i, ids, busy_flag)) { -+ if (checkcard(i, ids, busy_flag, NULL)) { - foundcards++; - i++; - } else { -- /* make sure we don't oops the module */ -- if (cards[i].typ > 0 && cards[i].typ <= ISDN_CTYPE_COUNT) { -- printk(KERN_WARNING -- "HiSax: Card %s not installed !\n", -- CardType[cards[i].typ]); -- } -+ printk(KERN_WARNING -+ "HiSax: Card %s not installed !\n", -+ CardType[cards[i].typ]); - HiSax_shiftcards(i); - nrcards--; - } -@@ -1342,6 +1365,49 @@ void HiSax_reportcard(int cardnr, int se - #endif - } - -+#ifdef CONFIG_HISAX_HFC_USB -+int -+hisax_register_hfcusb(struct hisax_drvreg *l1drv) -+{ -+ int i; -+ char ids[30]; -+ -+ if (l1drv->version != HISAX_LOAD_VERSION) -+ return 1; -+ -+ switch (l1drv->cmd) { -+ case HISAX_LOAD_CHKVER: -+ break; /* success */ -+ -+ case HISAX_LOAD_REGISTER: -+ for (i = 0; i < HISAX_MAX_CARDS; i++) { -+ if (!cards[i].typ) -+ break; -+ } -+ if (i >= HISAX_MAX_CARDS) -+ return 1; /* no space */ -+ cards[i].typ = ISDN_CTYPE_HFC_USB; /* setup type */ -+ cards[i].protocol = DEFAULT_PROTO; -+ sprintf(ids, "%s%d", l1drv->drvname, i); -+ if (checkcard(i, ids, NULL, (void *) l1drv)) { -+ nrcards++; -+ return 0; -+ } -+ if (cards[i].cs) -+ kfree((void *) cards[i].cs); -+ cards[i].cs = NULL; -+ cards[i].typ = 0; /* no card present */ -+ return 1; -+ break; -+ -+ default: -+ return 1; /* unknown command */ -+ } -+ -+ return 0; -+} /* hisax_register_hfcusb */ -+#endif -+ - static int __init HiSax_init(void) - { - int i, retval; -@@ -1408,8 +1474,6 @@ static int __init HiSax_init(void) - if (protocol[i]) { - cards[j].protocol = protocol[i]; - nzproto++; -- } else { -- cards[j].protocol = DEFAULT_PROTO; - } - switch (type[i]) { - case ISDN_CTYPE_16_0: -@@ -1487,22 +1551,15 @@ static int __init HiSax_init(void) - } else { - /* QUADRO is a 4 BRI card */ - cards[j++].para[0] = 1; -- /* we need to check if further cards can be added */ -- if (j < HISAX_MAX_CARDS) { -- cards[j].typ = ISDN_CTYPE_SCT_QUADRO; -- cards[j].protocol = protocol[i]; -- cards[j++].para[0] = 2; -- } -- if (j < HISAX_MAX_CARDS) { -- cards[j].typ = ISDN_CTYPE_SCT_QUADRO; -- cards[j].protocol = protocol[i]; -- cards[j++].para[0] = 3; -- } -- if (j < HISAX_MAX_CARDS) { -- cards[j].typ = ISDN_CTYPE_SCT_QUADRO; -- cards[j].protocol = protocol[i]; -- cards[j].para[0] = 4; -- } -+ cards[j].typ = ISDN_CTYPE_SCT_QUADRO; -+ cards[j].protocol = protocol[i]; -+ cards[j++].para[0] = 2; -+ cards[j].typ = ISDN_CTYPE_SCT_QUADRO; -+ cards[j].protocol = protocol[i]; -+ cards[j++].para[0] = 3; -+ cards[j].typ = ISDN_CTYPE_SCT_QUADRO; -+ cards[j].protocol = protocol[i]; -+ cards[j].para[0] = 4; - } - break; - } -@@ -1526,10 +1583,15 @@ static int __init HiSax_init(void) - nrcards, (nrcards > 1) ? "s" : ""); - - /* Install only, if at least one card found */ -- if (!HiSax_inithardware(NULL)) -- return -ENODEV; -+ if (!HiSax_inithardware(NULL)) { -+ retval = -EIO; -+ goto out_isdnl1; -+ } -+ - return 0; - -+ out_isdnl1: -+ Isdnl1Free(); - out_tei: - TeiFree(); - out_isdnl2: -@@ -1576,8 +1638,6 @@ int elsa_init_pcmcia(void *pcm_iob, int - cards[i].typ = type[i]; - if (protocol[i]) { - cards[i].protocol = protocol[i]; -- } else { -- cards[i].protocol = DEFAULT_PROTO; - } - } - cards[0].para[0] = pcm_irq; -@@ -1595,8 +1655,7 @@ int elsa_init_pcmcia(void *pcm_iob, int - printk(KERN_DEBUG "HiSax: Total %d card%s defined\n", - nrcards, (nrcards > 1) ? "s" : ""); - -- if (!HiSax_inithardware(busy_flag)) -- return -ENODEV; -+ HiSax_inithardware(busy_flag); - printk(KERN_NOTICE "HiSax: module installed\n"); - #endif - return 0; -@@ -1619,8 +1678,6 @@ int hfc_init_pcmcia(void *pcm_iob, int p - cards[i].typ = type[i]; - if (protocol[i]) { - cards[i].protocol = protocol[i]; -- } else { -- cards[i].protocol = DEFAULT_PROTO; - } - } - cards[0].para[0] = pcm_irq; -@@ -1638,8 +1695,7 @@ int hfc_init_pcmcia(void *pcm_iob, int p - printk(KERN_DEBUG "HiSax: Total %d card%s defined\n", - nrcards, (nrcards > 1) ? "s" : ""); - -- if (!HiSax_inithardware(busy_flag)) -- return -ENODEV; -+ HiSax_inithardware(busy_flag); - printk(KERN_NOTICE "HiSax: module installed\n"); - #endif - return 0; -@@ -1662,8 +1718,6 @@ int sedl_init_pcmcia(void *pcm_iob, int - cards[i].typ = type[i]; - if (protocol[i]) { - cards[i].protocol = protocol[i]; -- } else { -- cards[i].protocol = DEFAULT_PROTO; - } - } - cards[0].para[0] = pcm_irq; -@@ -1681,8 +1735,7 @@ int sedl_init_pcmcia(void *pcm_iob, int - printk(KERN_DEBUG "HiSax: Total %d card%s defined\n", - nrcards, (nrcards > 1) ? "s" : ""); - -- if (!HiSax_inithardware(busy_flag)) -- return -ENODEV; -+ HiSax_inithardware(busy_flag); - printk(KERN_NOTICE "HiSax: module installed\n"); - #endif - return 0; -@@ -1705,8 +1758,6 @@ int avm_a1_init_pcmcia(void *pcm_iob, in - cards[i].typ = type[i]; - if (protocol[i]) { - cards[i].protocol = protocol[i]; -- } else { -- cards[i].protocol = DEFAULT_PROTO; - } - } - cards[0].para[0] = pcm_irq; -@@ -1724,8 +1775,7 @@ int avm_a1_init_pcmcia(void *pcm_iob, in - printk(KERN_DEBUG "HiSax: Total %d card%s defined\n", - nrcards, (nrcards > 1) ? "s" : ""); - -- if (!HiSax_inithardware(busy_flag)) -- return -ENODEV; -+ HiSax_inithardware(busy_flag); - printk(KERN_NOTICE "HiSax: module installed\n"); - #endif - return 0; -@@ -1743,7 +1793,7 @@ int __devinit hisax_init_pcmcia(void *pc - sprintf(ids, "HiSax%d", nrcards); - else - sprintf(ids, "HiSax"); -- if (!checkcard(nrcards, ids, busy_flag)) { -+ if (!checkcard(nrcards, ids, busy_flag, NULL)) { - return -1; - } - ret = nrcards; -@@ -1785,7 +1835,7 @@ int hisax_register(struct hisax_d_if *hi - cards[i].protocol = protocol; - sprintf(id, "%s%d", name, i); - nrcards++; -- retval = checkcard(i, id, 0); -+ retval = checkcard(i, id, 0, NULL); - if (retval == 0) { // yuck - cards[i].typ = 0; - nrcards--; -@@ -2117,9 +2167,6 @@ static struct pci_device_id hisax_pci_tb - {PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_DIVA20, PCI_ANY_ID, PCI_ANY_ID}, - {PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_DIVA20_U, PCI_ANY_ID, PCI_ANY_ID}, - {PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_DIVA201, PCI_ANY_ID, PCI_ANY_ID}, --//######################################################################################### -- {PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_DIVA202, PCI_ANY_ID, PCI_ANY_ID}, --//######################################################################################### - #endif - #ifdef CONFIG_HISAX_ELSA - {PCI_VENDOR_ID_ELSA, PCI_DEVICE_ID_ELSA_MICROLINK, PCI_ANY_ID, PCI_ANY_ID}, -@@ -2178,11 +2225,3 @@ MODULE_DEVICE_TABLE(pci, hisax_pci_tbl); - - module_init(HiSax_init); - module_exit(HiSax_exit); -- --EXPORT_SYMBOL(FsmNew); --EXPORT_SYMBOL(FsmFree); --EXPORT_SYMBOL(FsmEvent); --EXPORT_SYMBOL(FsmChangeState); --EXPORT_SYMBOL(FsmInitTimer); --EXPORT_SYMBOL(FsmDelTimer); --EXPORT_SYMBOL(FsmRestartTimer); ---- a/drivers/isdn/hisax/diva.c -+++ b/drivers/isdn/hisax/diva.c -@@ -1,4 +1,4 @@ --/* $Id: diva.c,v 1.1.4.2 2002/08/30 11:21:00 keil Exp $ -+/* $Id: diva.c,v 1.33 2001/09/24 13:22:56 kai Exp $ - * - * low level stuff for Eicon.Diehl Diva Family ISDN cards - * -@@ -22,14 +22,13 @@ - #include "isac.h" - #include "hscx.h" - #include "ipac.h" --#include "ipacx.h" - #include "isdnl1.h" - #include <linux/pci.h> --#include <linux/isapnp.h> -+#include <linux/isdn_compat.h> - - extern const char *CardType[]; - --const char *Diva_revision = "$Revision: 1.1.4.2 $"; -+const char *Diva_revision = "$Revision: 1.33 $"; - - #define byteout(addr,val) outb(val,addr) - #define bytein(addr) inb(addr) -@@ -51,7 +50,6 @@ const char *Diva_revision = "$Revision: - #define DIVA_PCI 2 - #define DIVA_IPAC_ISA 3 - #define DIVA_IPAC_PCI 4 --#define DIVA_IPACX_PCI 5 - - /* CTRL (Read) */ - #define DIVA_IRQ_STAT 0x01 -@@ -71,12 +69,10 @@ const char *Diva_revision = "$Revision: - #define PITA_MISC_REG 0x1c - #ifdef __BIG_ENDIAN - #define PITA_PARA_SOFTRESET 0x00000001 --#define PITA_SER_SOFTRESET 0x00000002 - #define PITA_PARA_MPX_MODE 0x00000004 - #define PITA_INT0_ENABLE 0x00000200 - #else - #define PITA_PARA_SOFTRESET 0x01000000 --#define PITA_SER_SOFTRESET 0x02000000 - #define PITA_PARA_MPX_MODE 0x04000000 - #define PITA_INT0_ENABLE 0x00020000 - #endif -@@ -244,47 +240,6 @@ MemWriteHSCX(struct IsdnCardState *cs, i - memwritereg(cs->hw.diva.cfg_reg, offset + (hscx ? 0x40 : 0), value); - } - --/* IO-Functions for IPACX type cards */ --static u_char --MemReadISAC_IPACX(struct IsdnCardState *cs, u_char offset) --{ -- return (memreadreg(cs->hw.diva.cfg_reg, offset)); --} -- --static void --MemWriteISAC_IPACX(struct IsdnCardState *cs, u_char offset, u_char value) --{ -- memwritereg(cs->hw.diva.cfg_reg, offset, value); --} -- --static void --MemReadISACfifo_IPACX(struct IsdnCardState *cs, u_char * data, int size) --{ -- while(size--) -- *data++ = memreadreg(cs->hw.diva.cfg_reg, 0); --} -- --static void --MemWriteISACfifo_IPACX(struct IsdnCardState *cs, u_char * data, int size) --{ -- while(size--) -- memwritereg(cs->hw.diva.cfg_reg, 0, *data++); --} -- --static u_char --MemReadHSCX_IPACX(struct IsdnCardState *cs, int hscx, u_char offset) --{ -- return(memreadreg(cs->hw.diva.cfg_reg, offset + -- (hscx ? IPACX_OFF_B2 : IPACX_OFF_B1))); --} -- --static void --MemWriteHSCX_IPACX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value) --{ -- memwritereg(cs->hw.diva.cfg_reg, offset + -- (hscx ? IPACX_OFF_B2 : IPACX_OFF_B1), value); --} -- - /* - * fast interrupt HSCX stuff goes here - */ -@@ -595,7 +550,7 @@ Memhscx_int_main(struct IsdnCardState *c - u_char exval; - struct BCState *bcs; - -- if (val & 0x01) { // EXB -+ if (val & 0x01) { - bcs = cs->bcs + 1; - exval = MemReadHSCX(cs, 1, HSCX_EXIR); - if (exval & 0x40) { -@@ -622,7 +577,7 @@ Memhscx_int_main(struct IsdnCardState *c - debugl1(cs, "HSCX B interrupt %x", val); - Memhscx_interrupt(cs, val, 1); - } -- if (val & 0x02) { // EXA -+ if (val & 0x02) { - bcs = cs->bcs; - exval = MemReadHSCX(cs, 0, HSCX_EXIR); - if (exval & 0x40) { -@@ -644,7 +599,7 @@ Memhscx_int_main(struct IsdnCardState *c - } else if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "HSCX A EXIR %x", exval); - } -- if (val & 0x04) { // ICA -+ if (val & 0x04) { - exval = MemReadHSCX(cs, 0, HSCX_ISTA); - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "HSCX A interrupt %x", exval); -@@ -705,31 +660,12 @@ Start_IPACPCI: - memwritereg(cs->hw.diva.cfg_reg, IPAC_MASK, 0xC0); - } - --static void --diva_irq_ipacx_pci(int intno, void *dev_id, struct pt_regs *regs) --{ -- struct IsdnCardState *cs = dev_id; -- u_char val; -- u_char *cfg; -- -- if (!cs) { -- printk(KERN_WARNING "Diva: Spurious interrupt!\n"); -- return; -- } -- cfg = (u_char *) cs->hw.diva.pci_cfg; -- val = *cfg; -- if (!(val &PITA_INT0_STATUS)) return; // other shared IRQ -- interrupt_ipacx(cs); // handler for chip -- *cfg = PITA_INT0_STATUS; // Reset PLX interrupt --} -- - void - release_io_diva(struct IsdnCardState *cs) - { - int bytecnt; - -- if ((cs->subtyp == DIVA_IPAC_PCI) || -- (cs->subtyp == DIVA_IPACX_PCI) ) { -+ if (cs->subtyp == DIVA_IPAC_PCI) { - u_int *cfg = (unsigned int *)cs->hw.diva.pci_cfg; - - *cfg = 0; /* disable INT0/1 */ -@@ -776,16 +712,6 @@ reset_diva(struct IsdnCardState *cs) - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout((10*HZ)/1000); - memwritereg(cs->hw.diva.cfg_reg, IPAC_MASK, 0xc0); -- } else if (cs->subtyp == DIVA_IPACX_PCI) { -- unsigned int *ireg = (unsigned int *)(cs->hw.diva.pci_cfg + -- PITA_MISC_REG); -- *ireg = PITA_PARA_SOFTRESET | PITA_PARA_MPX_MODE; -- set_current_state(TASK_UNINTERRUPTIBLE); -- schedule_timeout((10*HZ)/1000); -- *ireg = PITA_PARA_MPX_MODE | PITA_SER_SOFTRESET; -- set_current_state(TASK_UNINTERRUPTIBLE); -- schedule_timeout((10*HZ)/1000); -- MemWriteISAC_IPACX(cs, IPACX_MASK, 0xff); // Interrupts off - } else { /* DIVA 2.0 */ - cs->hw.diva.ctrl_reg = 0; /* Reset On */ - byteout(cs->hw.diva.ctrl, cs->hw.diva.ctrl_reg); -@@ -814,9 +740,7 @@ diva_led_handler(struct IsdnCardState *c - { - int blink = 0; - -- if ((cs->subtyp == DIVA_IPAC_ISA) || -- (cs->subtyp == DIVA_IPAC_PCI) || -- (cs->subtyp == DIVA_IPACX_PCI) ) -+ if ((cs->subtyp == DIVA_IPAC_ISA) || (cs->subtyp == DIVA_IPAC_PCI)) - return; - del_timer(&cs->hw.diva.tl); - if (cs->hw.diva.status & DIVA_ASSIGN) -@@ -859,12 +783,6 @@ Diva_card_msg(struct IsdnCardState *cs, - release_io_diva(cs); - return(0); - case CARD_INIT: -- if (cs->subtyp == DIVA_IPACX_PCI) { -- ireg = (unsigned int *)cs->hw.diva.pci_cfg; -- *ireg = PITA_INT0_ENABLE; -- init_ipacx(cs, 3); // init chip and enable interrupts -- return (0); -- } - if (cs->subtyp == DIVA_IPAC_PCI) { - ireg = (unsigned int *)cs->hw.diva.pci_cfg; - *ireg = PITA_INT0_ENABLE; -@@ -901,9 +819,7 @@ Diva_card_msg(struct IsdnCardState *cs, - } - break; - } -- if ((cs->subtyp != DIVA_IPAC_ISA) && -- (cs->subtyp != DIVA_IPAC_PCI) && -- (cs->subtyp != DIVA_IPACX_PCI) ) -+ if ((cs->subtyp != DIVA_IPAC_ISA) && (cs->subtyp != DIVA_IPAC_PCI)) - diva_led_handler(cs); - return(0); - } -@@ -911,40 +827,11 @@ Diva_card_msg(struct IsdnCardState *cs, - static struct pci_dev *dev_diva __initdata = NULL; - static struct pci_dev *dev_diva_u __initdata = NULL; - static struct pci_dev *dev_diva201 __initdata = NULL; --static struct pci_dev *dev_diva202 __initdata = NULL; -- --#ifdef __ISAPNP__ --static struct isapnp_device_id diva_ids[] __initdata = { -- { ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x51), -- ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x51), -- (unsigned long) "Diva picola" }, -- { ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x51), -- ISAPNP_VENDOR('E', 'I', 'C'), ISAPNP_FUNCTION(0x51), -- (unsigned long) "Diva picola" }, -- { ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x71), -- ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x71), -- (unsigned long) "Diva 2.0" }, -- { ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x71), -- ISAPNP_VENDOR('E', 'I', 'C'), ISAPNP_FUNCTION(0x71), -- (unsigned long) "Diva 2.0" }, -- { ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0xA1), -- ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0xA1), -- (unsigned long) "Diva 2.01" }, -- { ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0xA1), -- ISAPNP_VENDOR('E', 'I', 'C'), ISAPNP_FUNCTION(0xA1), -- (unsigned long) "Diva 2.01" }, -- { 0, } --}; -- --static struct isapnp_device_id *pdev = &diva_ids[0]; --static struct pci_bus *pnp_c __devinitdata = NULL; --#endif -- - - int __init - setup_diva(struct IsdnCard *card) - { -- int bytecnt = 8; -+ int bytecnt; - u_char val; - struct IsdnCardState *cs = card->cs; - char tmp[64]; -@@ -977,75 +864,8 @@ setup_diva(struct IsdnCard *card) - cs->hw.diva.hscx_adr = card->para[1] + DIVA_HSCX_ADR; - } - cs->irq = card->para[0]; -+ bytecnt = 8; - } else { --#ifdef __ISAPNP__ -- if (isapnp_present()) { -- struct pci_bus *pb; -- struct pci_dev *pd; -- -- while(pdev->card_vendor) { -- if ((pb = isapnp_find_card(pdev->card_vendor, -- pdev->card_device, pnp_c))) { -- pnp_c = pb; -- pd = NULL; -- if ((pd = isapnp_find_dev(pnp_c, -- pdev->vendor, pdev->function, pd))) { -- printk(KERN_INFO "HiSax: %s detected\n", -- (char *)pdev->driver_data); -- pd->prepare(pd); -- pd->deactivate(pd); -- pd->activate(pd); -- card->para[1] = -- pd->resource[0].start; -- card->para[0] = -- pd->irq_resource[0].start; -- if (!card->para[0] || !card->para[1]) { -- printk(KERN_ERR "Diva PnP:some resources are missing %ld/%lx\n", -- card->para[0], card->para[1]); -- pd->deactivate(pd); -- return(0); -- } -- cs->hw.diva.cfg_reg = card->para[1]; -- cs->irq = card->para[0]; -- if (pdev->function == ISAPNP_FUNCTION(0xA1)) { -- cs->subtyp = DIVA_IPAC_ISA; -- cs->hw.diva.ctrl = 0; -- cs->hw.diva.isac = -- card->para[1] + DIVA_IPAC_DATA; -- cs->hw.diva.hscx = -- card->para[1] + DIVA_IPAC_DATA; -- cs->hw.diva.isac_adr = -- card->para[1] + DIVA_IPAC_ADR; -- cs->hw.diva.hscx_adr = -- card->para[1] + DIVA_IPAC_ADR; -- test_and_set_bit(HW_IPAC, &cs->HW_Flags); -- } else { -- cs->subtyp = DIVA_ISA; -- cs->hw.diva.ctrl = -- card->para[1] + DIVA_ISA_CTRL; -- cs->hw.diva.isac = -- card->para[1] + DIVA_ISA_ISAC_DATA; -- cs->hw.diva.hscx = -- card->para[1] + DIVA_HSCX_DATA; -- cs->hw.diva.isac_adr = -- card->para[1] + DIVA_ISA_ISAC_ADR; -- cs->hw.diva.hscx_adr = -- card->para[1] + DIVA_HSCX_ADR; -- } -- goto ready; -- } else { -- printk(KERN_ERR "Diva PnP: PnP error card found, no device\n"); -- return(0); -- } -- } -- pdev++; -- pnp_c=NULL; -- } -- if (!pdev->card_vendor) { -- printk(KERN_INFO "Diva PnP: no ISAPnP card found\n"); -- } -- } --#endif - #if CONFIG_PCI - if (!pci_present()) { - printk(KERN_ERR "Diva: no PCI bus present\n"); -@@ -1059,14 +879,14 @@ setup_diva(struct IsdnCard *card) - return(0); - cs->subtyp = DIVA_PCI; - cs->irq = dev_diva->irq; -- cs->hw.diva.cfg_reg = pci_resource_start(dev_diva, 2); -+ cs->hw.diva.cfg_reg = pci_resource_start_io(dev_diva, 2); - } else if ((dev_diva_u = pci_find_device(PCI_VENDOR_ID_EICON, - PCI_DEVICE_ID_EICON_DIVA20_U, dev_diva_u))) { - if (pci_enable_device(dev_diva_u)) - return(0); - cs->subtyp = DIVA_PCI; - cs->irq = dev_diva_u->irq; -- cs->hw.diva.cfg_reg = pci_resource_start(dev_diva_u, 2); -+ cs->hw.diva.cfg_reg = pci_resource_start_io(dev_diva_u, 2); - } else if ((dev_diva201 = pci_find_device(PCI_VENDOR_ID_EICON, - PCI_DEVICE_ID_EICON_DIVA201, dev_diva201))) { - if (pci_enable_device(dev_diva201)) -@@ -1074,19 +894,9 @@ setup_diva(struct IsdnCard *card) - cs->subtyp = DIVA_IPAC_PCI; - cs->irq = dev_diva201->irq; - cs->hw.diva.pci_cfg = -- (ulong) ioremap(pci_resource_start(dev_diva201, 0), 4096); -+ (ulong) ioremap(pci_resource_start_mem(dev_diva201, 0), 4096); - cs->hw.diva.cfg_reg = -- (ulong) ioremap(pci_resource_start(dev_diva201, 1), 4096); -- } else if ((dev_diva202 = pci_find_device(PCI_VENDOR_ID_EICON, -- PCI_DEVICE_ID_EICON_DIVA202, dev_diva202))) { -- if (pci_enable_device(dev_diva202)) -- return(0); -- cs->subtyp = DIVA_IPACX_PCI; -- cs->irq = dev_diva202->irq; -- cs->hw.diva.pci_cfg = -- (ulong) ioremap(pci_resource_start(dev_diva202, 0), 4096); -- cs->hw.diva.cfg_reg = -- (ulong) ioremap(pci_resource_start(dev_diva202, 1), 4096); -+ (ulong) ioremap(pci_resource_start_mem(dev_diva201, 1), 4096); - } else { - printk(KERN_WARNING "Diva: No PCI card found\n"); - return(0); -@@ -1107,8 +917,7 @@ setup_diva(struct IsdnCard *card) - printk(KERN_WARNING "Diva: unable to config DIVA PCI\n"); - return (0); - #endif /* CONFIG_PCI */ -- if ((cs->subtyp == DIVA_IPAC_PCI) || -- (cs->subtyp == DIVA_IPACX_PCI) ) { -+ if (cs->subtyp == DIVA_IPAC_PCI) { - cs->hw.diva.ctrl = 0; - cs->hw.diva.isac = 0; - cs->hw.diva.hscx = 0; -@@ -1125,23 +934,18 @@ setup_diva(struct IsdnCard *card) - bytecnt = 32; - } - } --ready: -+ - printk(KERN_INFO - "Diva: %s card configured at %#lx IRQ %d\n", - (cs->subtyp == DIVA_PCI) ? "PCI" : - (cs->subtyp == DIVA_ISA) ? "ISA" : -- (cs->subtyp == DIVA_IPAC_ISA) ? "IPAC ISA" : -- (cs->subtyp == DIVA_IPAC_PCI) ? "IPAC PCI" : "IPACX PCI", -+ (cs->subtyp == DIVA_IPAC_ISA) ? "IPAC ISA" : "IPAC PCI", - cs->hw.diva.cfg_reg, cs->irq); -- if ((cs->subtyp == DIVA_IPAC_PCI) || -- (cs->subtyp == DIVA_IPACX_PCI) || -- (cs->subtyp == DIVA_PCI) ) -- printk(KERN_INFO "Diva: %s space at %#lx\n", -- (cs->subtyp == DIVA_PCI) ? "PCI" : -- (cs->subtyp == DIVA_IPAC_PCI) ? "IPAC PCI" : "IPACX PCI", -+ if ((cs->subtyp == DIVA_IPAC_PCI) || (cs->subtyp == DIVA_PCI)) -+ printk(KERN_INFO "Diva: %s PCI space at %#lx\n", -+ (cs->subtyp == DIVA_PCI) ? "PCI" : "IPAC PCI", - cs->hw.diva.pci_cfg); -- if ((cs->subtyp != DIVA_IPAC_PCI) && -- (cs->subtyp != DIVA_IPACX_PCI) ) { -+ if (cs->subtyp != DIVA_IPAC_PCI) { - if (check_region(cs->hw.diva.cfg_reg, bytecnt)) { - printk(KERN_WARNING - "HiSax: %s config port %lx-%lx already in use\n", -@@ -1177,17 +981,6 @@ ready: - cs->irq_func = &diva_irq_ipac_pci; - val = memreadreg(cs->hw.diva.cfg_reg, IPAC_ID); - printk(KERN_INFO "Diva: IPAC version %x\n", val); -- } else if (cs->subtyp == DIVA_IPACX_PCI) { -- cs->readisac = &MemReadISAC_IPACX; -- cs->writeisac = &MemWriteISAC_IPACX; -- cs->readisacfifo = &MemReadISACfifo_IPACX; -- cs->writeisacfifo = &MemWriteISACfifo_IPACX; -- cs->BC_Read_Reg = &MemReadHSCX_IPACX; -- cs->BC_Write_Reg = &MemWriteHSCX_IPACX; -- cs->BC_Send_Data = 0; // function located in ipacx module -- cs->irq_func = &diva_irq_ipacx_pci; -- printk(KERN_INFO "Diva: IPACX Design Id: %x\n", -- MemReadISAC_IPACX(cs, IPACX_ID) &0x3F); - } else { /* DIVA 2.0 */ - cs->hw.diva.tl.function = (void *) diva_led_handler; - cs->hw.diva.tl.data = (long) cs; ---- a/drivers/isdn/hisax/elsa.c -+++ b/drivers/isdn/hisax/elsa.c -@@ -1,4 +1,4 @@ --/* $Id: elsa.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: elsa.c,v 2.32 2001/09/24 13:22:56 kai Exp $ - * - * low level stuff for Elsa isdn cards - * -@@ -28,13 +28,13 @@ - #include "hscx.h" - #include "isdnl1.h" - #include <linux/pci.h> --#include <linux/isapnp.h> -+#include <linux/isdn_compat.h> - #include <linux/serial.h> - #include <linux/serial_reg.h> - - extern const char *CardType[]; - --const char *Elsa_revision = "$Revision: 1.1.4.1 $"; -+const char *Elsa_revision = "$Revision: 2.32 $"; - const char *Elsa_Types[] = - {"None", "PC", "PCC-8", "PCC-16", "PCF", "PCF-Pro", - "PCMCIA", "QS 1000", "QS 3000", "Microlink PCI", "QS 3000 PCI", -@@ -864,21 +864,6 @@ probe_elsa(struct IsdnCardState *cs) - static struct pci_dev *dev_qs1000 __devinitdata = NULL; - static struct pci_dev *dev_qs3000 __devinitdata = NULL; - --#ifdef __ISAPNP__ --static struct isapnp_device_id elsa_ids[] __initdata = { -- { ISAPNP_VENDOR('E', 'L', 'S'), ISAPNP_FUNCTION(0x0133), -- ISAPNP_VENDOR('E', 'L', 'S'), ISAPNP_FUNCTION(0x0133), -- (unsigned long) "Elsa QS1000" }, -- { ISAPNP_VENDOR('E', 'L', 'S'), ISAPNP_FUNCTION(0x0134), -- ISAPNP_VENDOR('E', 'L', 'S'), ISAPNP_FUNCTION(0x0134), -- (unsigned long) "Elsa QS3000" }, -- { 0, } --}; -- --static struct isapnp_device_id *pdev = &elsa_ids[0]; --static struct pci_bus *pnp_c __devinitdata = NULL; --#endif -- - int __devinit - setup_elsa(struct IsdnCard *card) - { -@@ -893,7 +878,6 @@ setup_elsa(struct IsdnCard *card) - cs->hw.elsa.ctrl_reg = 0; - cs->hw.elsa.status = 0; - cs->hw.elsa.MFlag = 0; -- cs->subtyp = 0; - if (cs->typ == ISDN_CTYPE_ELSA) { - cs->hw.elsa.base = card->para[0]; - printk(KERN_INFO "Elsa: Microlink IO probing\n"); -@@ -955,60 +939,9 @@ setup_elsa(struct IsdnCard *card) - return (0); - } - } else if (cs->typ == ISDN_CTYPE_ELSA_PNP) { --#ifdef __ISAPNP__ -- if (!card->para[1] && isapnp_present()) { -- struct pci_bus *pb; -- struct pci_dev *pd; -- -- while(pdev->card_vendor) { -- if ((pb = isapnp_find_card(pdev->card_vendor, -- pdev->card_device, pnp_c))) { -- pnp_c = pb; -- pd = NULL; -- if ((pd = isapnp_find_dev(pnp_c, -- pdev->vendor, pdev->function, pd))) { -- printk(KERN_INFO "HiSax: %s detected\n", -- (char *)pdev->driver_data); -- pd->prepare(pd); -- pd->deactivate(pd); -- pd->activate(pd); -- card->para[1] = -- pd->resource[0].start; -- card->para[0] = -- pd->irq_resource[0].start; -- if (!card->para[0] || !card->para[1]) { -- printk(KERN_ERR "Elsa PnP:some resources are missing %ld/%lx\n", -- card->para[0], card->para[1]); -- pd->deactivate(pd); -- return(0); -- } -- if (pdev->function == ISAPNP_FUNCTION(0x133)) -- cs->subtyp = ELSA_QS1000; -- else -- cs->subtyp = ELSA_QS3000; -- break; -- } else { -- printk(KERN_ERR "Elsa PnP: PnP error card found, no device\n"); -- return(0); -- } -- } -- pdev++; -- pnp_c=NULL; -- } -- if (!pdev->card_vendor) { -- printk(KERN_INFO "Elsa PnP: no ISAPnP card found\n"); -- return(0); -- } -- } --#endif -- if (card->para[1] && card->para[0]) { -- cs->hw.elsa.base = card->para[1]; -- cs->irq = card->para[0]; -- if (!cs->subtyp) -- cs->subtyp = ELSA_QS1000; -- } else { -- printk(KERN_ERR "Elsa PnP: no parameter\n"); -- } -+ cs->hw.elsa.base = card->para[1]; -+ cs->irq = card->para[0]; -+ cs->subtyp = ELSA_QS1000; - cs->hw.elsa.cfg = cs->hw.elsa.base + ELSA_CONFIG; - cs->hw.elsa.ale = cs->hw.elsa.base + ELSA_ALE; - cs->hw.elsa.isac = cs->hw.elsa.base + ELSA_ISAC; -@@ -1058,16 +991,16 @@ setup_elsa(struct IsdnCard *card) - return(0); - cs->subtyp = ELSA_QS1000PCI; - cs->irq = dev_qs1000->irq; -- cs->hw.elsa.cfg = pci_resource_start(dev_qs1000, 1); -- cs->hw.elsa.base = pci_resource_start(dev_qs1000, 3); -+ cs->hw.elsa.cfg = pci_resource_start_io(dev_qs1000, 1); -+ cs->hw.elsa.base = pci_resource_start_io(dev_qs1000, 3); - } else if ((dev_qs3000 = pci_find_device(PCI_VENDOR_ID_ELSA, - PCI_DEVICE_ID_ELSA_QS3000, dev_qs3000))) { - if (pci_enable_device(dev_qs3000)) - return(0); - cs->subtyp = ELSA_QS3000PCI; - cs->irq = dev_qs3000->irq; -- cs->hw.elsa.cfg = pci_resource_start(dev_qs3000, 1); -- cs->hw.elsa.base = pci_resource_start(dev_qs3000, 3); -+ cs->hw.elsa.cfg = pci_resource_start_io(dev_qs3000, 1); -+ cs->hw.elsa.base = pci_resource_start_io(dev_qs3000, 3); - } else { - printk(KERN_WARNING "Elsa: No PCI card found\n"); - return(0); -@@ -1123,7 +1056,6 @@ setup_elsa(struct IsdnCard *card) - break; - case ELSA_PCFPRO: - case ELSA_PCF: -- case ELSA_QS3000: - case ELSA_QS3000PCI: - bytecnt = 16; - break; ---- a/drivers/isdn/hisax/elsa_cs.c -+++ b/drivers/isdn/hisax/elsa_cs.c -@@ -72,7 +72,7 @@ static int pc_debug = PCMCIA_DEBUG; - MODULE_PARM(pc_debug, "i"); - #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args); - static char *version = --"elsa_cs.c $Revision: 1.1.4.1 $ $Date: 2001/11/20 14:19:35 $ (K.Lichtenwalder)"; -+"elsa_cs.c $Revision: 1.2 $ $Date: 2001/09/24 13:22:56 $ (K.Lichtenwalder)"; - #else - #define DEBUG(n, args...) - #endif ---- a/drivers/isdn/hisax/elsa_ser.c -+++ b/drivers/isdn/hisax/elsa_ser.c -@@ -1,4 +1,4 @@ --/* $Id: elsa_ser.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: elsa_ser.c,v 2.14 2001/09/24 13:22:56 kai Exp $ - * - * stuff for the serial modem on ELSA cards - * -@@ -396,6 +396,74 @@ static inline void transmit_chars(struct - } - } - -+#if 0 -+static inline void check_modem_status(struct IsdnCardState *cs) -+{ -+ int status; -+ struct async_struct *info = cs->hw.elsa.info; -+ struct async_icount *icount; -+ -+ status = serial_inp(info, UART_MSR); -+ -+ if (status & UART_MSR_ANY_DELTA) { -+ icount = &info->state->icount; -+ /* update input line counters */ -+ if (status & UART_MSR_TERI) -+ icount->rng++; -+ if (status & UART_MSR_DDSR) -+ icount->dsr++; -+ if (status & UART_MSR_DDCD) { -+ icount->dcd++; -+ } -+ if (status & UART_MSR_DCTS) -+ icount->cts++; -+// wake_up(&info->delta_msr_wait); -+ } -+ -+ if ((info->flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) { -+#if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR)) -+ printk("ttys%d CD now %s...", info->line, -+ (status & UART_MSR_DCD) ? "on" : "off"); -+#endif -+ if (status & UART_MSR_DCD) -+// wake_up(&info->open_wait); -+; -+ else if (!((info->flags & ASYNC_CALLOUT_ACTIVE) && -+ (info->flags & ASYNC_CALLOUT_NOHUP))) { -+#ifdef SERIAL_DEBUG_OPEN -+ printk("doing serial hangup..."); -+#endif -+ if (info->tty) -+ tty_hangup(info->tty); -+ } -+ } -+#if 0 -+ if (info->flags & ASYNC_CTS_FLOW) { -+ if (info->tty->hw_stopped) { -+ if (status & UART_MSR_CTS) { -+#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW)) -+ printk("CTS tx start..."); -+#endif -+ info->tty->hw_stopped = 0; -+ info->IER |= UART_IER_THRI; -+ serial_outp(info, UART_IER, info->IER); -+// rs_sched_event(info, RS_EVENT_WRITE_WAKEUP); -+ return; -+ } -+ } else { -+ if (!(status & UART_MSR_CTS)) { -+#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW)) -+ printk("CTS tx stop..."); -+#endif -+ info->tty->hw_stopped = 1; -+ info->IER &= ~UART_IER_THRI; -+ serial_outp(info, UART_IER, info->IER); -+ } -+ } -+ } -+#endif 0 -+} -+#endif - - static void rs_interrupt_elsa(int irq, struct IsdnCardState *cs) - { ---- a/drivers/isdn/hisax/fsm.c -+++ b/drivers/isdn/hisax/fsm.c -@@ -1,4 +1,4 @@ --/* $Id: fsm.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id$ - * - * Finite state machine - * -@@ -21,6 +21,14 @@ - - #define FSM_TIMER_DEBUG 0 - -+EXPORT_SYMBOL(FsmNew); -+EXPORT_SYMBOL(FsmFree); -+EXPORT_SYMBOL(FsmEvent); -+EXPORT_SYMBOL(FsmChangeState); -+EXPORT_SYMBOL(FsmInitTimer); -+EXPORT_SYMBOL(FsmDelTimer); -+EXPORT_SYMBOL(FsmRestartTimer); -+ - int __init - FsmNew(struct Fsm *fsm, struct FsmNode *fnlist, int fncount) - { ---- a/drivers/isdn/hisax/fsm.h -+++ b/drivers/isdn/hisax/fsm.h -@@ -1,4 +1,4 @@ --/* $Id: fsm.h,v 1.1.2.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id$ - * - * Finite state machine - * ---- a/drivers/isdn/hisax/gazel.c -+++ b/drivers/isdn/hisax/gazel.c -@@ -1,4 +1,4 @@ --/* $Id: gazel.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: gazel.c,v 2.19 2001/09/24 13:22:56 kai Exp $ - * - * low level stuff for Gazel isdn cards - * -@@ -20,9 +20,10 @@ - #include "isdnl1.h" - #include "ipac.h" - #include <linux/pci.h> -+#include <linux/isdn_compat.h> - - extern const char *CardType[]; --const char *gazel_revision = "$Revision: 1.1.4.1 $"; -+const char *gazel_revision = "$Revision: 2.19 $"; - - #define R647 1 - #define R685 2 -@@ -563,8 +564,8 @@ setup_gazelpci(struct IsdnCardState *cs) - if (pci_enable_device(dev_tel)) - return 1; - pci_irq = dev_tel->irq; -- pci_ioaddr0 = pci_resource_start(dev_tel, 1); -- pci_ioaddr1 = pci_resource_start(dev_tel, 2); -+ pci_ioaddr0 = pci_resource_start_io(dev_tel, 1); -+ pci_ioaddr1 = pci_resource_start_io(dev_tel, 2); - found = 1; - } - if (found) ---- a/drivers/isdn/hisax/hfc_2bds0.c -+++ b/drivers/isdn/hisax/hfc_2bds0.c -@@ -1,4 +1,4 @@ --/* $Id: hfc_2bds0.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: hfc_2bds0.c,v 1.18 2001/09/24 13:22:56 kai Exp $ - * - * specific routines for CCD's HFC 2BDS0 - * -@@ -616,6 +616,17 @@ hfcd_bh(struct IsdnCardState *cs) - */ - if (!cs) - return; -+#if 0 -+ if (test_and_clear_bit(D_CLEARBUSY, &cs->event)) { -+ if (cs->debug) -+ debugl1(cs, "D-Channel Busy cleared"); -+ stptr = cs->stlist; -+ while (stptr != NULL) { -+ stptr->l1.l1l2(stptr, PH_PAUSE | CONFIRM, NULL); -+ stptr = stptr->next; -+ } -+ } -+#endif - if (test_and_clear_bit(D_L1STATECHANGE, &cs->event)) { - switch (cs->dc.hfcd.ph_state) { - case (0): -@@ -1090,6 +1101,32 @@ HFCD_l1hw(struct PStack *st, int pr, voi - cs->hw.hfcD.mst_m |= HFCD_MASTER; - cs->writeisac(cs, HFCD_MST_MODE, cs->hw.hfcD.mst_m); - break; -+#if 0 -+ case (HW_TESTLOOP | REQUEST): -+ u_char val = 0; -+ if (1 & (int) arg) -+ val |= 0x0c; -+ if (2 & (int) arg) -+ val |= 0x3; -+ if (test_bit(HW_IOM1, &cs->HW_Flags)) { -+ /* IOM 1 Mode */ -+ if (!val) { -+ cs->writeisac(cs, ISAC_SPCR, 0xa); -+ cs->writeisac(cs, ISAC_ADF1, 0x2); -+ } else { -+ cs->writeisac(cs, ISAC_SPCR, val); -+ cs->writeisac(cs, ISAC_ADF1, 0xa); -+ } -+ } else { -+ /* IOM 2 Mode */ -+ cs->writeisac(cs, ISAC_SPCR, val); -+ if (val) -+ cs->writeisac(cs, ISAC_ADF1, 0x8); -+ else -+ cs->writeisac(cs, ISAC_ADF1, 0x0); -+ } -+ break; -+#endif - default: - if (cs->debug & L1_DEB_WARN) - debugl1(cs, "hfcd_l1hw unknown pr %4x", pr); -@@ -1106,6 +1143,20 @@ setstack_hfcd(struct PStack *st, struct - static void - hfc_dbusy_timer(struct IsdnCardState *cs) - { -+#if 0 -+ struct PStack *stptr; -+ if (test_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) { -+ if (cs->debug) -+ debugl1(cs, "D-Channel Busy"); -+ test_and_set_bit(FLG_L1_DBUSY, &cs->HW_Flags); -+ stptr = cs->stlist; -+ -+ while (stptr != NULL) { -+ stptr->l1.l1l2(stptr, PH_PAUSE | INDICATION, NULL); -+ stptr = stptr->next; -+ } -+ } -+#endif - } - - unsigned int __init ---- a/drivers/isdn/hisax/hfc_2bds0.h -+++ b/drivers/isdn/hisax/hfc_2bds0.h -@@ -1,4 +1,4 @@ --/* $Id: hfc_2bds0.h,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: hfc_2bds0.h,v 1.6 2001/09/24 13:22:56 kai Exp $ - * - * specific defines for CCD's HFC 2BDS0 - * ---- a/drivers/isdn/hisax/hfc_2bs0.c -+++ b/drivers/isdn/hisax/hfc_2bs0.c -@@ -1,4 +1,4 @@ --/* $Id: hfc_2bs0.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: hfc_2bs0.c,v 1.20 2001/09/24 13:22:56 kai Exp $ - * - * specific routines for CCD's HFC 2BS0 - * ---- a/drivers/isdn/hisax/hfc_2bs0.h -+++ b/drivers/isdn/hisax/hfc_2bs0.h -@@ -1,4 +1,4 @@ --/* $Id: hfc_2bs0.h,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: hfc_2bs0.h,v 1.5 2001/09/24 13:22:56 kai Exp $ - * - * specific defines for CCD's HFC 2BS0 - * ---- a/drivers/isdn/hisax/hfc_pci.c -+++ b/drivers/isdn/hisax/hfc_pci.c -@@ -1,4 +1,4 @@ --/* $Id: hfc_pci.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: hfc_pci.c,v 1.48 2001/09/24 13:22:56 kai Exp $ - * - * low level driver for CCD´s hfc-pci based cards - * -@@ -22,11 +22,12 @@ - #include "hfc_pci.h" - #include "isdnl1.h" - #include <linux/pci.h> -+#include <linux/isdn_compat.h> - #include <linux/interrupt.h> - - extern const char *CardType[]; - --static const char *hfcpci_revision = "$Revision: 1.1.4.1 $"; -+static const char *hfcpci_revision = "$Revision: 1.48 $"; - - /* table entry in the PCI devices list */ - typedef struct { -@@ -76,8 +77,6 @@ release_io_hfcpci(struct IsdnCardState * - { - unsigned long flags; - -- printk(KERN_INFO "HiSax: release hfcpci at %p\n", -- cs->hw.hfcpci.pci_io); - save_flags(flags); - cli(); - cs->hw.hfcpci.int_m2 = 0; /* interrupt output off ! */ -@@ -88,11 +87,13 @@ release_io_hfcpci(struct IsdnCardState * - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout((30 * HZ) / 1000); /* Timeout 30ms */ - Write_hfc(cs, HFCPCI_CIRM, 0); /* Reset Off */ -+#if CONFIG_PCI - pcibios_write_config_word(cs->hw.hfcpci.pci_bus, cs->hw.hfcpci.pci_device_fn, PCI_COMMAND, 0); /* disable memory mapped ports + busmaster */ -+#endif /* CONFIG_PCI */ - del_timer(&cs->hw.hfcpci.timer); - kfree(cs->hw.hfcpci.share_start); - cs->hw.hfcpci.share_start = NULL; -- iounmap((void *)cs->hw.hfcpci.pci_io); -+ vfree(cs->hw.hfcpci.pci_io); - } - - /********************************************************************************/ -@@ -687,10 +688,6 @@ hfcpci_fill_fifo(struct BCState *bcs) - debugl1(cs, "hfcpci_fill_fifo_trans %d frame length %d discarded", - bcs->channel, bcs->tx_skb->len); - -- if (bcs->st->lli.l1writewakeup && -- (PACKET_NOACK != bcs->tx_skb->pkt_type)) -- bcs->st->lli.l1writewakeup(bcs->st, bcs->tx_skb->len); -- - dev_kfree_skb_any(bcs->tx_skb); - cli(); - bcs->tx_skb = skb_dequeue(&bcs->squeue); /* fetch next data */ -@@ -1146,6 +1143,20 @@ hfcpci_interrupt(int intno, void *dev_id - static void - hfcpci_dbusy_timer(struct IsdnCardState *cs) - { -+#if 0 -+ struct PStack *stptr; -+ if (test_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) { -+ if (cs->debug) -+ debugl1(cs, "D-Channel Busy"); -+ test_and_set_bit(FLG_L1_DBUSY, &cs->HW_Flags); -+ stptr = cs->stlist; -+ -+ while (stptr != NULL) { -+ stptr->l1.l1l2(stptr, PH_PAUSE | INDICATION, NULL); -+ stptr = stptr->next; -+ } -+ } -+#endif - } - - /*************************************/ -@@ -1550,6 +1561,17 @@ hfcpci_bh(struct IsdnCardState *cs) - */ - if (!cs) - return; -+#if 0 -+ if (test_and_clear_bit(D_CLEARBUSY, &cs->event)) { -+ if (cs->debug) -+ debugl1(cs, "D-Channel Busy cleared"); -+ stptr = cs->stlist; -+ while (stptr != NULL) { -+ stptr->l1.l1l2(stptr, PH_PAUSE | CONFIRM, NULL); -+ stptr = stptr->next; -+ } -+ } -+#endif - if (test_and_clear_bit(D_L1STATECHANGE, &cs->event)) { - if (!cs->hw.hfcpci.nt_mode) - switch (cs->dc.hfcpci.ph_state) { -@@ -1712,7 +1734,7 @@ setup_hfcpci(struct IsdnCard *card) - if (pci_enable_device(tmp_hfcpci)) - continue; - pci_set_master(tmp_hfcpci); -- if ((card->para[0]) && (card->para[0] != (tmp_hfcpci->resource[ 0].start & PCI_BASE_ADDRESS_IO_MASK))) -+ if ((card->para[0]) && (card->para[0] != (get_pcibase(tmp_hfcpci, 0) & PCI_BASE_ADDRESS_IO_MASK))) - continue; - else - break; -@@ -1729,7 +1751,7 @@ setup_hfcpci(struct IsdnCard *card) - printk(KERN_WARNING "HFC-PCI: No IRQ for PCI card found\n"); - return (0); - } -- cs->hw.hfcpci.pci_io = (char *) dev_hfcpci->resource[ 1].start; -+ cs->hw.hfcpci.pci_io = (char *) get_pcibase(dev_hfcpci, 1); - printk(KERN_INFO "HiSax: HFC-PCI card manufacturer: %s card name: %s\n", id_list[i].vendor_name, id_list[i].card_name); - } else { - printk(KERN_WARNING "HFC-PCI: No PCI card found\n"); -@@ -1746,7 +1768,7 @@ setup_hfcpci(struct IsdnCard *card) - printk(KERN_WARNING "HFC-PCI: Error allocating memory for FIFO!\n"); - return 0; - } -- cs->hw.hfcpci.fifos = (void *) -+ (ulong) cs->hw.hfcpci.fifos = - (((ulong) cs->hw.hfcpci.share_start) & ~0x7FFF) + 0x8000; - pcibios_write_config_dword(cs->hw.hfcpci.pci_bus, - cs->hw.hfcpci.pci_device_fn, 0x80, ---- a/drivers/isdn/hisax/hfc_pci.h -+++ b/drivers/isdn/hisax/hfc_pci.h -@@ -1,4 +1,4 @@ --/* $Id: hfc_pci.h,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: hfc_pci.h,v 1.10 2001/09/24 13:22:56 kai Exp $ - * - * specific defines for CCD's HFC 2BDS0 PCI chips - * ---- a/drivers/isdn/hisax/hfc_sx.c -+++ b/drivers/isdn/hisax/hfc_sx.c -@@ -1,4 +1,4 @@ --/* $Id: hfc_sx.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: hfc_sx.c,v 1.12 2001/09/24 13:22:56 kai Exp $ - * - * level driver for CCD´s hfc-s+/sp based cards - * -@@ -17,11 +17,10 @@ - #include "hfc_sx.h" - #include "isdnl1.h" - #include <linux/interrupt.h> --#include <linux/isapnp.h> - - extern const char *CardType[]; - --static const char *hfcsx_revision = "$Revision: 1.1.4.1 $"; -+static const char *hfcsx_revision = "$Revision: 1.12 $"; - - /***************************************/ - /* IRQ-table for CCDs demo board */ -@@ -940,6 +939,20 @@ hfcsx_interrupt(int intno, void *dev_id, - static void - hfcsx_dbusy_timer(struct IsdnCardState *cs) - { -+#if 0 -+ struct PStack *stptr; -+ if (test_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) { -+ if (cs->debug) -+ debugl1(cs, "D-Channel Busy"); -+ test_and_set_bit(FLG_L1_DBUSY, &cs->HW_Flags); -+ stptr = cs->stlist; -+ -+ while (stptr != NULL) { -+ stptr->l1.l1l2(stptr, PH_PAUSE | INDICATION, NULL); -+ stptr = stptr->next; -+ } -+ } -+#endif - } - - /*************************************/ -@@ -1333,6 +1346,17 @@ hfcsx_bh(struct IsdnCardState *cs) - */ - if (!cs) - return; -+#if 0 -+ if (test_and_clear_bit(D_CLEARBUSY, &cs->event)) { -+ if (cs->debug) -+ debugl1(cs, "D-Channel Busy cleared"); -+ stptr = cs->stlist; -+ while (stptr != NULL) { -+ stptr->l1.l1l2(stptr, PH_PAUSE | CONFIRM, NULL); -+ stptr = stptr->next; -+ } -+ } -+#endif - if (test_and_clear_bit(D_L1STATECHANGE, &cs->event)) { - if (!cs->hw.hfcsx.nt_mode) - switch (cs->dc.hfcsx.ph_state) { -@@ -1461,17 +1485,7 @@ hfcsx_card_msg(struct IsdnCardState *cs, - return (0); - } - --#ifdef __ISAPNP__ --static struct isapnp_device_id hfc_ids[] __initdata = { -- { ISAPNP_VENDOR('T', 'A', 'G'), ISAPNP_FUNCTION(0x2620), -- ISAPNP_VENDOR('T', 'A', 'G'), ISAPNP_FUNCTION(0x2620), -- (unsigned long) "Teles 16.3c2" }, -- { 0, } --}; - --static struct isapnp_device_id *hdev = &hfc_ids[0]; --static struct pci_bus *pnp_c __devinitdata = NULL; --#endif - - int __devinit - setup_hfcsx(struct IsdnCard *card) -@@ -1482,45 +1496,6 @@ setup_hfcsx(struct IsdnCard *card) - - strcpy(tmp, hfcsx_revision); - printk(KERN_INFO "HiSax: HFC-SX driver Rev. %s\n", HiSax_getrev(tmp)); --#ifdef __ISAPNP__ -- if (!card->para[1] && isapnp_present()) { -- struct pci_bus *pb; -- struct pci_dev *pd; -- -- while(hdev->card_vendor) { -- if ((pb = isapnp_find_card(hdev->card_vendor, -- hdev->card_device, pnp_c))) { -- pnp_c = pb; -- pd = NULL; -- if ((pd = isapnp_find_dev(pnp_c, -- hdev->vendor, hdev->function, pd))) { -- printk(KERN_INFO "HiSax: %s detected\n", -- (char *)hdev->driver_data); -- pd->prepare(pd); -- pd->deactivate(pd); -- pd->activate(pd); -- card->para[1] = pd->resource[0].start; -- card->para[0] = pd->irq_resource[0].start; -- if (!card->para[0] || !card->para[1]) { -- printk(KERN_ERR "HFC PnP:some resources are missing %ld/%lx\n", -- card->para[0], card->para[1]); -- pd->deactivate(pd); -- return(0); -- } -- break; -- } else { -- printk(KERN_ERR "HFC PnP: PnP error card found, no device\n"); -- } -- } -- hdev++; -- pnp_c=NULL; -- } -- if (!hdev->card_vendor) { -- printk(KERN_INFO "HFC PnP: no ISAPnP card found\n"); -- return(0); -- } -- } --#endif - cs->hw.hfcsx.base = card->para[1] & 0xfffe; - cs->irq = card->para[0]; - cs->hw.hfcsx.int_s1 = 0; -@@ -1603,3 +1578,7 @@ setup_hfcsx(struct IsdnCard *card) - cs->auxcmd = &hfcsx_auxcmd; - return (1); - } -+ -+ -+ -+ ---- a/drivers/isdn/hisax/hfc_sx.h -+++ b/drivers/isdn/hisax/hfc_sx.h -@@ -1,4 +1,4 @@ --/* $Id: hfc_sx.h,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id$ - * - * specific defines for CCD's HFC 2BDS0 S+,SP chips - * ---- /dev/null -+++ b/drivers/isdn/hisax/hfc_usb.c -@@ -0,0 +1,1189 @@ -+/* $Id: hfc_usb.c,v 2.3 2001/07/06 21:30:11 werner Exp $ -+ * -+ * -+ * -+ * Author (C) 2001 Werner Cornelius (werner@isdn-development.de) -+ * modular driver for Colognechip HFC-USB chip -+ * as plugin for HiSax isdn driver -+ * type approval valid for HFC-S USB based TAs -+ * -+ * Copyright 2001 by Werner Cornelius (werner@isdn-development.de) -+ * -+ * 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, or (at your option) -+ * any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -+ * -+ */ -+ -+#include <linux/types.h> -+#include <linux/stddef.h> -+#include <linux/timer.h> -+#include <linux/config.h> -+#include <linux/isdn_compat.h> -+#include <linux/init.h> -+#include "hisax.h" -+#include <linux/module.h> -+#include <linux/kernel_stat.h> -+#include <linux/tqueue.h> -+#include <linux/usb.h> -+#include <linux/kernel.h> -+#include <linux/smp_lock.h> -+#include <linux/sched.h> -+#include "hisax_loadable.h" -+ -+#define INCLUDE_INLINE_FUNCS -+ -+/***********/ -+/* defines */ -+/***********/ -+#define HFC_CTRL_TIMEOUT 5 /* 5ms timeout writing/reading regs */ -+#define HFC_TIMER_T3 7000 /* timeout for l1 activation timer */ -+ -+#define HFCUSB_L1_STATECHANGE 0 /* L1 state changed */ -+#define HFCUSB_L1_DRX 1 /* D-frame received */ -+#define HFCUSB_L1_ERX 2 /* E-frame received */ -+#define HFCUSB_L1_DTX 4 /* D-frames completed */ -+ -+#define MAX_BCH_SIZE 2048 /* allowed B-channel packet size */ -+ -+#define HFCUSB_RX_THRESHOLD 64 /* threshold for fifo report bit rx */ -+#define HFCUSB_TX_THRESHOLD 64 /* threshold for fifo report bit tx */ -+ -+#define HFCUSB_CHIP_ID 0x16 /* Chip ID register index */ -+#define HFCUSB_CIRM 0x00 /* cirm register index */ -+#define HFCUSB_USB_SIZE 0x07 /* int length register */ -+#define HFCUSB_USB_SIZE_I 0x06 /* iso length register */ -+#define HFCUSB_F_CROSS 0x0b /* bit order register */ -+#define HFCUSB_CLKDEL 0x37 /* bit delay register */ -+#define HFCUSB_CON_HDLC 0xfa /* channel connect register */ -+#define HFCUSB_HDLC_PAR 0xfb -+#define HFCUSB_SCTRL 0x31 /* S-bus control register (tx) */ -+#define HFCUSB_SCTRL_E 0x32 /* same for E and special funcs */ -+#define HFCUSB_SCTRL_R 0x33 /* S-bus control register (rx) */ -+#define HFCUSB_F_THRES 0x0c /* threshold register */ -+#define HFCUSB_FIFO 0x0f /* fifo select register */ -+#define HFCUSB_F_USAGE 0x1a /* fifo usage register */ -+#define HFCUSB_MST_MODE0 0x14 -+#define HFCUSB_MST_MODE1 0x15 -+#define HFCUSB_P_DATA 0x1f -+#define HFCUSB_INC_RES_F 0x0e -+#define HFCUSB_STATES 0x30 -+ -+#define HFCUSB_CHIPID 0x40 /* ID value of HFC-USB */ -+ -+/******************/ -+/* fifo registers */ -+/******************/ -+#define HFCUSB_NUM_FIFOS 8 /* maximum number of fifos */ -+#define HFCUSB_B1_TX 0 /* index for B1 transmit bulk/int */ -+#define HFCUSB_B1_RX 1 /* index for B1 receive bulk/int */ -+#define HFCUSB_B2_TX 2 -+#define HFCUSB_B2_RX 3 -+#define HFCUSB_D_TX 4 -+#define HFCUSB_D_RX 5 -+#define HFCUSB_PCM_TX 6 -+#define HFCUSB_PCM_RX 7 -+ -+/************/ -+/* LED mask */ -+/************/ -+#define LED_DRIVER 0x1 -+#define LED_L1 0x2 -+#define LED_BCH 0x4 -+ -+/**********/ -+/* macros */ -+/**********/ -+#define Write_hfc(a,b,c) usb_control_msg((a)->dev,(a)->ctrl_out_pipe,0,0x40,(c),(b),0,0,HFC_CTRL_TIMEOUT) -+#define Read_hfc(a,b,c) usb_control_msg((a)->dev,(a)->ctrl_in_pipe,1,0xC0,0,(b),(c),1,HFC_CTRL_TIMEOUT) -+ -+#ifdef COMPAT_HAS_USB_IDTAB -+/****************************************/ -+/* data defining the devices to be used */ -+/****************************************/ -+static __devinitdata const struct usb_device_id hfc_usb_idtab[3] = { -+ {USB_DEVICE(0x959, 0x2bd0)}, /* Colognechip ROM */ -+ {USB_DEVICE(0x7b0, 0x0006)}, /* USB TA 128 */ -+ {} /* end with an all-zeroes entry */ -+}; -+#endif -+ -+/*************************************************/ -+/* entry and size of output/input control buffer */ -+/*************************************************/ -+#define HFC_CTRL_BUFSIZE 32 -+typedef struct { -+ __u8 hfc_reg; /* register number */ -+ __u8 reg_val; /* value to be written (or read) */ -+} ctrl_buft; -+ -+/***************************************************************/ -+/* structure defining input+output fifos (interrupt/bulk mode) */ -+/***************************************************************/ -+struct hfcusb_data; /* forward definition */ -+typedef struct { -+ int fifonum; /* fifo index attached to this structure */ -+ __u8 fifo_mask; /* mask for this fifo */ -+ int active; /* fifo is currently active */ -+ struct hfcusb_data *hfc; /* pointer to main structure */ -+ int pipe; /* address of endpoint */ -+ __u8 usb_maxlen; /* maximum length for usb transfer */ -+ int max_size; /* maximum size of receive/send packet */ -+ int transmode; /* transparent mode selected */ -+ int framenum; /* number of frame when last tx completed */ -+ int rx_offset; /* offset inside rx buffer */ -+ int next_complete; /* complete marker */ -+ __u8 *act_ptr; /* pointer to next data */ -+ __u8 intervall; /* interrupt interval */ -+ struct sk_buff *buff; /* actual used buffer */ -+ urb_t urb; /* transfer structure for usb routines */ -+ __u8 buffer[128]; /* buffer incoming/outgoing data */ -+} usb_fifo; -+ -+/*********************************************/ -+/* structure holding all data for one device */ -+/*********************************************/ -+typedef struct hfcusb_data { -+ struct hisax_drvreg regd; /* register data and callbacks */ -+ struct usb_device *dev; /* our device */ -+ int if_used; /* used interface number */ -+ int alt_used; /* used alternate config */ -+ int ctrl_paksize; /* control pipe packet size */ -+ int ctrl_in_pipe, ctrl_out_pipe; /* handles for control pipe */ -+ -+ /* control pipe background handling */ -+ ctrl_buft ctrl_buff[HFC_CTRL_BUFSIZE]; /* buffer holding queued data */ -+ volatile int ctrl_in_idx, ctrl_out_idx, ctrl_cnt; /* input/output pointer + count */ -+ urb_t ctrl_urb; /* transfer structure for control channel */ -+ devrequest ctrl_write; /* buffer for control write request */ -+ devrequest ctrl_read; /* same for read request */ -+ -+ volatile __u8 dfifo_fill; /* value read from tx d-fifo */ -+ volatile __u8 active_fifos; /* fifos currently active as bit mask */ -+ volatile __u8 threshold_mask; /* threshold actually reported */ -+ volatile __u8 service_request; /* fifo needs service from task */ -+ volatile __u8 ctrl_fifo; /* last selected fifo */ -+ volatile __u8 bch_enables; /* or mask for sctrl_r and sctrl register values */ -+ volatile __u8 led_req; /* request status of adapters leds */ -+ volatile __u8 led_act; /* active status of adapters leds */ -+ usb_fifo fifos[HFCUSB_NUM_FIFOS]; /* structure holding all fifo data */ -+ -+ /* layer 1 activation/deactivation handling */ -+ volatile __u8 l1_state; /* actual l1 state */ -+ volatile ulong l1_event; /* event mask */ -+ struct tq_struct l1_tq; /* l1 bh structure */ -+ struct timer_list t3_timer; /* timer for activation/deactivation */ -+ struct timer_list t4_timer; /* timer for activation/deactivation */ -+} hfcusb_data; -+ -+#if 0 -+static void -+usb_dump_urb(purb_t purb) -+{ -+ printk("urb :%p\n", purb); -+ printk("next :%p\n", purb->next); -+ printk("dev :%p\n", purb->dev); -+ printk("pipe :%08X\n", purb->pipe); -+ printk("status :%d\n", purb->status); -+ printk("transfer_flags :%08X\n", purb->transfer_flags); -+ printk("transfer_buffer :%p\n", purb->transfer_buffer); -+ printk("transfer_buffer_length:%d\n", -+ purb->transfer_buffer_length); -+ printk("actual_length :%d\n", purb->actual_length); -+ printk("setup_packet :%p\n", purb->setup_packet); -+ printk("start_frame :%d\n", purb->start_frame); -+ printk("number_of_packets :%d\n", purb->number_of_packets); -+ printk("interval :%d\n", purb->interval); -+ printk("error_count :%d\n", purb->error_count); -+ printk("context :%p\n", purb->context); -+ printk("complete :%p\n", purb->complete); -+} -+#endif -+ -+/*************************************************************************/ -+/* bottom half handler for L1 activation/deactiavtaion + D-chan + E-chan */ -+/*************************************************************************/ -+static void -+usb_l1d_bh(hfcusb_data * hfc) -+{ -+ -+ while (hfc->l1_event) { -+ if (test_and_clear_bit -+ (HFCUSB_L1_STATECHANGE, &hfc->l1_event)) { -+ if (hfc->l1_state == 7) -+ hfc->led_req |= LED_L1; -+ else -+ hfc->led_req &= ~LED_L1; -+ if ((hfc->l1_state == 7) || -+ (hfc->l1_state == 3)) -+ hfc->regd.dch_l1l2(hfc->regd.arg_hisax, -+ (hfc->l1_state == -+ 7) ? (PH_ACTIVATE | -+ INDICATION) -+ : (PH_DEACTIVATE | INDICATION), -+ NULL); -+ } -+ if (test_and_clear_bit(HFCUSB_L1_DRX, &hfc->l1_event)) { -+ hfc->regd.dch_l1l2(hfc->regd.arg_hisax, -+ PH_DATA | INDICATION, -+ (void *) 0); -+ } -+ if (test_and_clear_bit(HFCUSB_L1_ERX, &hfc->l1_event)) { -+ hfc->regd.dch_l1l2(hfc->regd.arg_hisax, -+ PH_DATA | INDICATION, -+ (void *) 1); -+ } -+ if (test_and_clear_bit(HFCUSB_L1_DTX, &hfc->l1_event)) { -+ hfc->regd.dch_l1l2(hfc->regd.arg_hisax, -+ PH_DATA | CONFIRM, NULL); -+ } -+ } /* while */ -+} /* usb_l1d_bh */ -+ -+/******************************************************/ -+/* start next background transfer for control channel */ -+/******************************************************/ -+static void -+ctrl_start_transfer(hfcusb_data * hfc) -+{ -+ -+ if (hfc->ctrl_cnt) { -+ switch (hfc->ctrl_buff[hfc->ctrl_out_idx].hfc_reg) { -+ case HFCUSB_F_USAGE: -+ hfc->ctrl_urb.pipe = hfc->ctrl_in_pipe; -+ hfc->ctrl_urb.setup_packet = -+ (u_char *) & hfc->ctrl_read; -+ hfc->ctrl_urb.transfer_buffer_length = 1; -+ hfc->ctrl_read.index = -+ hfc->ctrl_buff[hfc->ctrl_out_idx]. -+ hfc_reg; -+ hfc->ctrl_urb.transfer_buffer = -+ (char *) &hfc->dfifo_fill; -+ break; -+ -+ default: /* write register */ -+ hfc->ctrl_urb.pipe = hfc->ctrl_out_pipe; -+ hfc->ctrl_urb.setup_packet = -+ (u_char *) & hfc->ctrl_write; -+ hfc->ctrl_urb.transfer_buffer = NULL; -+ hfc->ctrl_urb.transfer_buffer_length = 0; -+ hfc->ctrl_write.index = -+ hfc->ctrl_buff[hfc->ctrl_out_idx]. -+ hfc_reg; -+ hfc->ctrl_write.value = -+ hfc->ctrl_buff[hfc->ctrl_out_idx]. -+ reg_val; -+ break; -+ } -+ usb_submit_urb(&hfc->ctrl_urb); /* start transfer */ -+ } -+} /* ctrl_start_transfer */ -+ -+/************************************/ -+/* queue a control transfer request */ -+/* return 0 on success. */ -+/************************************/ -+static int -+queue_control_request(hfcusb_data * hfc, __u8 reg, __u8 val) -+{ -+ ctrl_buft *buf; -+ -+ if (hfc->ctrl_cnt >= HFC_CTRL_BUFSIZE) -+ return (1); /* no space left */ -+ buf = hfc->ctrl_buff + hfc->ctrl_in_idx; /* pointer to new index */ -+ buf->hfc_reg = reg; -+ buf->reg_val = val; -+ if (++hfc->ctrl_in_idx >= HFC_CTRL_BUFSIZE) -+ hfc->ctrl_in_idx = 0; /* pointer wrap */ -+ if (++hfc->ctrl_cnt == 1) -+ ctrl_start_transfer(hfc); -+ return (0); -+} /* queue_control_request */ -+ -+/**************************************/ -+/* called when timer t3 or t4 expires */ -+/**************************************/ -+static void -+l1_timer_expire(hfcusb_data * hfc) -+{ -+ if (timer_pending(&hfc->t4_timer)) -+ del_timer(&hfc->t4_timer); -+ queue_control_request(hfc, HFCUSB_STATES, 0x40); -+ test_and_set_bit(HFCUSB_L1_STATECHANGE, -+ &hfc->l1_event); -+ queue_task(&hfc->l1_tq, &tq_immediate); -+ mark_bh(IMMEDIATE_BH); -+} /* l1_timer_expire */ -+ -+/**************************************************/ -+/* (re)fills a tx-fifo urb. Queuing is done later */ -+/**************************************************/ -+static void -+fill_tx_urb(usb_fifo * fifo) -+{ -+ struct sk_buff *skb; -+ long flags; -+ int i, ii = 0; -+ -+ fifo->urb.dev = fifo->hfc->dev; -+ if ((fifo->buff) -+ && (fifo->urb.transfer_buffer_length < fifo->usb_maxlen)) { -+ switch (fifo->fifonum) { -+ case HFCUSB_B1_TX: -+ case HFCUSB_B2_TX: -+ skb = fifo->buff; -+ fifo->buff = NULL; -+ fifo->hfc->regd.bch_l1l2(fifo->hfc->regd. -+ arg_hisax, -+ (fifo->fifonum == -+ HFCUSB_B1_TX) ? 0 -+ : 1, -+ (PH_DATA | -+ CONFIRM), -+ (void *) skb); -+ fifo->hfc->service_request |= -+ fifo->fifo_mask; -+ return; -+ case HFCUSB_D_TX: -+ dev_kfree_skb_any(fifo->buff); -+ fifo->buff = NULL; -+ save_flags(flags); -+ cli(); -+ fifo->hfc->dfifo_fill = 0xff; /* currently invalid data */ -+ queue_control_request(fifo->hfc, -+ HFCUSB_FIFO, -+ HFCUSB_D_TX); -+ queue_control_request(fifo->hfc, -+ HFCUSB_F_USAGE, 0); -+ restore_flags(flags); -+ return; -+ default: -+ return; /* error, invalid fifo */ -+ } -+ } -+ -+ /* check if new buffer needed */ -+ if (!fifo->buff) { -+ switch (fifo->fifonum) { -+ case HFCUSB_B1_TX: -+ if (fifo->hfc->regd.bsk[0]) -+ fifo->buff = *fifo->hfc->regd.bsk[0]; /* B1-channel tx buffer */ -+ break; -+ case HFCUSB_B2_TX: -+ if (fifo->hfc->regd.bsk[1]) -+ fifo->buff = *fifo->hfc->regd.bsk[1]; /* B2-channel tx buffer */ -+ break; -+ case HFCUSB_D_TX: -+ if (fifo->hfc->regd.dsq) -+ fifo->buff = skb_dequeue(fifo->hfc->regd.dsq); /* D-channel tx queue */ -+ break; -+ default: -+ return; /* error, invalid fifo */ -+ } -+ if (!fifo->buff) { -+ fifo->active = 0; /* we are inactive now */ -+ fifo->hfc->active_fifos &= ~fifo->fifo_mask; -+ if (fifo->fifonum == HFCUSB_D_TX) { -+ test_and_set_bit(HFCUSB_L1_DTX, -+ &fifo->hfc->l1_event); -+ queue_task(&fifo->hfc->l1_tq, -+ &tq_immediate); -+ mark_bh(IMMEDIATE_BH); -+ } -+ return; -+ } -+ fifo->act_ptr = fifo->buff->data; /* start of data */ -+ fifo->active = 1; -+ ii = 1; -+ fifo->hfc->active_fifos |= fifo->fifo_mask; -+ fifo->hfc->service_request &= ~fifo->fifo_mask; -+ } -+ /* fillup the send buffer */ -+ i = fifo->buff->len - (fifo->act_ptr - fifo->buff->data); /* remaining length */ -+ fifo->buffer[0] = !fifo->transmode; /* not eof */ -+ if (i > (fifo->usb_maxlen - ii)) { -+ i = fifo->usb_maxlen - ii; -+ } -+ if (i) -+ memcpy(fifo->buffer + ii, fifo->act_ptr, i); -+ fifo->urb.transfer_buffer_length = i + ii; -+ fifo->rx_offset = ii; -+} /* fill_tx_urb */ -+ -+/************************************************/ -+/* transmit completion routine for all tx fifos */ -+/************************************************/ -+static void -+tx_complete(purb_t urb) -+{ -+ usb_fifo *fifo = (usb_fifo *) urb->context; /* pointer to our fifo */ -+ -+ fifo->hfc->service_request &= ~fifo->fifo_mask; /* no further handling */ -+ fifo->framenum = usb_get_current_frame_number(fifo->hfc->dev); -+ -+ /* check for deactivation or error */ -+ if ((!fifo->active) || (urb->status)) { -+ fifo->hfc->active_fifos &= ~fifo->fifo_mask; /* we are inactive */ -+ fifo->active = 0; -+ if ((fifo->buff) && (fifo->fifonum == HFCUSB_D_TX)) { -+ dev_kfree_skb_any(fifo->buff); -+ } -+ fifo->buff = NULL; -+ return; -+ } -+ fifo->act_ptr += (urb->transfer_buffer_length - fifo->rx_offset); /* adjust pointer */ -+ fill_tx_urb(fifo); /* refill the urb */ -+ fifo->hfc->threshold_mask |= fifo->fifo_mask; /* assume threshold reached */ -+ if (fifo->buff) -+ fifo->hfc->service_request |= fifo->fifo_mask; /* need to restart */ -+} /* tx_complete */ -+ -+/***********************************************/ -+/* receive completion routine for all rx fifos */ -+/***********************************************/ -+static void -+rx_complete(purb_t urb) -+{ -+ usb_fifo *fifo = (usb_fifo *) urb->context; /* pointer to our fifo */ -+ hfcusb_data *hfc = fifo->hfc; -+ usb_fifo *txfifo; -+ __u8 last_state; -+ int i, ii, currcnt, hdlci; -+ struct sk_buff *skb; -+ -+ urb->dev = hfc->dev; /* security init */ -+ if ((!fifo->active) || (urb->status)) { -+ hfc->service_request &= ~fifo->fifo_mask; /* no further handling */ -+ hfc->active_fifos &= ~fifo->fifo_mask; /* we are inactive */ -+ fifo->urb.interval = 0; /* cancel automatic rescheduling */ -+ if (fifo->buff) { -+ dev_kfree_skb_any(fifo->buff); -+ fifo->buff = NULL; -+ } -+ return; -+ } -+ -+ /* first check for any status changes */ -+ if ((urb->actual_length < fifo->rx_offset) -+ || (urb->actual_length > fifo->usb_maxlen)) -+ return; /* error condition */ -+ -+ if (fifo->rx_offset) { -+ hfc->threshold_mask = fifo->buffer[1]; /* update threshold status */ -+ fifo->next_complete = fifo->buffer[0] & 1; -+ if ((fifo->fifonum == HFCUSB_D_RX) && -+ (hfc->led_req != hfc->led_act)) -+ queue_control_request(hfc, HFCUSB_P_DATA, hfc->led_req); -+ -+ /* check if rescheduling needed */ -+ if ((i = -+ hfc->service_request & hfc->active_fifos & ~hfc-> -+ threshold_mask)) { -+ currcnt = -+ usb_get_current_frame_number(hfc->dev); -+ txfifo = hfc->fifos + HFCUSB_B1_TX; -+ ii = 3; -+ while (ii--) { -+ if ((i & txfifo->fifo_mask) -+ && (currcnt != txfifo->framenum)) { -+ hfc->service_request &= -+ ~txfifo->fifo_mask; -+ if (!txfifo->buff) -+ fill_tx_urb(txfifo); -+ if (txfifo->buff) -+ usb_submit_urb(&txfifo-> -+ urb); -+ } -+ txfifo += 2; -+ } -+ } -+ -+ /* handle l1 events */ -+ if ((fifo->buffer[0] >> 4) != hfc->l1_state) { -+ last_state = hfc->l1_state; -+ hfc->l1_state = fifo->buffer[0] >> 4; /* update status */ -+ if (timer_pending(&hfc->t4_timer)) -+ del_timer(&hfc->t4_timer); -+ if (((hfc->l1_state == 3) && -+ ((last_state == 7) || -+ (last_state == 8))) || -+ ((timer_pending(&hfc->t3_timer) && -+ (hfc->l1_state == 8)))) { -+ hfc->t4_timer.expires = jiffies + 2; -+ add_timer(&hfc->t4_timer); -+ } else { -+ if (timer_pending(&hfc->t3_timer) -+ && (hfc->l1_state == 7)) -+ del_timer(&hfc->t3_timer); /* no longer needed */ -+ test_and_set_bit(HFCUSB_L1_STATECHANGE, -+ &hfc->l1_event); -+ queue_task(&hfc->l1_tq, &tq_immediate); -+ mark_bh(IMMEDIATE_BH); -+ } -+ } -+ } -+ -+ /* check the length for data and move if present */ -+ if (fifo->next_complete || (urb->actual_length > fifo->rx_offset)) { -+ i = fifo->buff->len + urb->actual_length - fifo->rx_offset; /* new total length */ -+ hdlci = (fifo->transmode) ? 0 : 3; -+ if (i <= (fifo->max_size + hdlci)) { -+ memcpy(fifo->act_ptr, -+ fifo->buffer + fifo->rx_offset, -+ urb->actual_length - fifo->rx_offset); -+ fifo->act_ptr += -+ (urb->actual_length - fifo->rx_offset); -+ fifo->buff->len += -+ (urb->actual_length - fifo->rx_offset); -+ } else -+ fifo->buff->len = fifo->max_size + 4; /* mark frame as to long */ -+ if (fifo->next_complete && (urb->actual_length < fifo->usb_maxlen)) { -+ /* the frame is complete */ -+ fifo->next_complete = 0; -+ if (((!*(fifo->act_ptr - 1)) || fifo->transmode) && -+ (fifo->buff->len >= (hdlci + 1)) -+ && (fifo->buff->len <= -+ (fifo->max_size + hdlci)) && -+ ((skb = dev_alloc_skb(fifo->max_size + hdlci)) != NULL)) { -+ fifo->buff->len -= hdlci; /* adjust size */ -+ switch (fifo->fifonum) { -+ case HFCUSB_D_RX: -+ skb_queue_tail(hfc->regd. -+ drq, -+ fifo->buff); -+ test_and_set_bit -+ (HFCUSB_L1_DRX, -+ &hfc->l1_event); -+ queue_task(&hfc->l1_tq, -+ &tq_immediate); -+ mark_bh(IMMEDIATE_BH); -+ break; -+ -+ case HFCUSB_B1_RX: -+ if (hfc->regd.brq[0]) { -+ skb_queue_tail -+ (hfc->regd. -+ brq[0], -+ fifo->buff); -+ hfc->regd. -+ bch_l1l2(hfc-> -+ regd. -+ arg_hisax, -+ 0, -+ PH_DATA -+ | -+ INDICATION, -+ (void *) -+ fifo-> -+ buff); -+ } else -+ dev_kfree_skb_any -+ (fifo->buff); -+ break; -+ -+ case HFCUSB_B2_RX: -+ if (hfc->regd.brq[1]) { -+ skb_queue_tail -+ (hfc->regd. -+ brq[1], -+ fifo->buff); -+ hfc->regd. -+ bch_l1l2(hfc-> -+ regd. -+ arg_hisax, -+ 1, -+ PH_DATA -+ | -+ INDICATION, -+ (void -+ *) -+ fifo-> -+ buff); -+ } else -+ dev_kfree_skb_any -+ (fifo->buff); -+ break; -+ -+ case HFCUSB_PCM_RX: -+ skb_queue_tail(&hfc->regd. -+ erq, -+ fifo->buff); -+ test_and_set_bit -+ (HFCUSB_L1_ERX, -+ &hfc->l1_event); -+ queue_task(&hfc->l1_tq, -+ &tq_immediate); -+ mark_bh(IMMEDIATE_BH); -+ break; -+ -+ default: -+ dev_kfree_skb_any(fifo-> -+ buff); -+ break; -+ } -+ fifo->buff = skb; -+ } -+ fifo->buff->len = 0; /* reset counter */ -+ fifo->act_ptr = fifo->buff->data; /* and pointer */ -+ } -+ } -+ fifo->rx_offset = (urb->actual_length < fifo->usb_maxlen) ? 2 : 0; -+} /* rx_complete */ -+ -+/***************************************************/ -+/* start the interrupt transfer for the given fifo */ -+/***************************************************/ -+static void -+start_rx_fifo(usb_fifo * fifo) -+{ -+ if (fifo->buff) -+ return; /* still active */ -+ if (! -+ (fifo->buff = -+ dev_alloc_skb(fifo->max_size + (fifo->transmode ? 0 : 3)))) -+ return; -+ fifo->act_ptr = fifo->buff->data; -+ FILL_INT_URB(&fifo->urb, fifo->hfc->dev, fifo->pipe, fifo->buffer, -+ fifo->usb_maxlen, rx_complete, fifo, fifo->intervall); -+ fifo->next_complete = 0; -+ fifo->rx_offset = 2; -+ fifo->active = 1; /* must be marked active */ -+ fifo->hfc->active_fifos |= fifo->fifo_mask; -+ if (usb_submit_urb(&fifo->urb)) { -+ fifo->active = 0; -+ fifo->hfc->active_fifos &= ~fifo->fifo_mask; -+ dev_kfree_skb_any(fifo->buff); -+ fifo->buff = NULL; -+ } -+} /* start_rx_fifo */ -+ -+/***************************************************************/ -+/* control completion routine handling background control cmds */ -+/***************************************************************/ -+static void -+ctrl_complete(purb_t urb) -+{ -+ hfcusb_data *hfc = (hfcusb_data *) urb->context; -+ -+ urb->dev = hfc->dev; -+ if (hfc->ctrl_cnt) { -+ switch (hfc->ctrl_buff[hfc->ctrl_out_idx].hfc_reg) { -+ case HFCUSB_FIFO: -+ hfc->ctrl_fifo = -+ hfc->ctrl_buff[hfc->ctrl_out_idx]. -+ reg_val; -+ break; -+ case HFCUSB_F_USAGE: -+ if (!hfc->dfifo_fill) { -+ fill_tx_urb(hfc->fifos + -+ HFCUSB_D_TX); -+ if (hfc->fifos[HFCUSB_D_TX].buff) -+ usb_submit_urb(&hfc-> -+ fifos -+ [HFCUSB_D_TX]. -+ urb); -+ } else { -+ queue_control_request(hfc, -+ HFCUSB_FIFO, -+ HFCUSB_D_TX); -+ queue_control_request(hfc, -+ HFCUSB_F_USAGE, -+ 0); -+ } -+ break; -+ case HFCUSB_SCTRL_R: -+ switch (hfc->ctrl_fifo) { -+ case HFCUSB_B1_RX: -+ if (hfc->bch_enables & 1) -+ start_rx_fifo(hfc-> -+ fifos -+ + -+ HFCUSB_B1_RX); -+ break; -+ case HFCUSB_B2_RX: -+ if (hfc->bch_enables & 2) -+ start_rx_fifo(hfc-> -+ fifos -+ + -+ HFCUSB_B2_RX); -+ break; -+ } -+ if (hfc->bch_enables & 3) -+ hfc->led_req |= LED_BCH; -+ else -+ hfc->led_req &= ~LED_BCH; -+ break; -+ case HFCUSB_P_DATA: -+ hfc->led_act = -+ hfc->ctrl_buff[hfc->ctrl_out_idx]. -+ reg_val; -+ break; -+ } -+ hfc->ctrl_cnt--; /* decrement actual count */ -+ if (++hfc->ctrl_out_idx >= HFC_CTRL_BUFSIZE) -+ hfc->ctrl_out_idx = 0; /* pointer wrap */ -+ ctrl_start_transfer(hfc); /* start next transfer */ -+ } -+} /* ctrl_complete */ -+ -+/*****************************************/ -+/* Layer 1 + D channel access from HiSax */ -+/*****************************************/ -+static void -+hfcusb_l1_access(void *drvarg, int pr, void *arg) -+{ -+ hfcusb_data *hfc = (hfcusb_data *) drvarg; -+ -+ switch (pr) { -+ case (PH_DATA | REQUEST): -+ case (PH_PULL | INDICATION): -+ skb_queue_tail(hfc->regd.dsq, -+ (struct sk_buff *) arg); -+ if (!hfc->fifos[HFCUSB_D_TX].active -+ && !hfc->dfifo_fill) { -+ fill_tx_urb(hfc->fifos + HFCUSB_D_TX); -+ hfc->active_fifos |= -+ hfc->fifos[HFCUSB_D_TX].fifo_mask; -+ usb_submit_urb(&hfc->fifos[HFCUSB_D_TX]. -+ urb); -+ } -+ break; -+ case (PH_ACTIVATE | REQUEST): -+ switch (hfc->l1_state) { -+ case 6: -+ case 8: -+ hfc->regd.dch_l1l2(hfc->regd.arg_hisax, -+ (PH_DEACTIVATE | -+ INDICATION), NULL); -+ -+ break; -+ case 7: -+ hfc->regd.dch_l1l2(hfc->regd.arg_hisax, -+ (PH_ACTIVATE | -+ INDICATION), NULL); -+ -+ break; -+ default: -+ queue_control_request(hfc, HFCUSB_STATES, 0x60); /* start activation */ -+ hfc->t3_timer.expires = -+ jiffies + (HFC_TIMER_T3 * HZ) / 1000; -+ if (!timer_pending(&hfc->t3_timer)) -+ add_timer(&hfc->t3_timer); -+ break; -+ } -+ break; -+ -+ case (PH_DEACTIVATE | REQUEST): -+ queue_control_request(hfc, HFCUSB_STATES, 0x40); /* start deactivation */ -+ break; -+ default: -+ printk(KERN_INFO "unknown hfcusb l1_access 0x%x\n", -+ pr); -+ break; -+ } -+} /* hfcusb_l1_access */ -+ -+/*******************************/ -+/* B channel access from HiSax */ -+/*******************************/ -+static void -+hfcusb_bch_access(void *drvarg, int chan, int pr, void *arg) -+{ -+ hfcusb_data *hfc = (hfcusb_data *) drvarg; -+ usb_fifo *fifo = hfc->fifos + (chan ? HFCUSB_B2_TX : HFCUSB_B1_TX); -+ long flags; -+ -+ switch (pr) { -+ case (PH_DATA | REQUEST): -+ case (PH_PULL | INDICATION): -+ save_flags(flags); -+ cli(); -+ if (!fifo->active) { -+ fill_tx_urb(fifo); -+ hfc->active_fifos |= fifo->fifo_mask; -+ usb_submit_urb(&fifo->urb); -+ } -+ restore_flags(flags); -+ break; -+ case (PH_ACTIVATE | REQUEST): -+ if (!((int) arg)) { -+ hfc->bch_enables &= ~(1 << chan); -+ if (fifo->active) { -+ fifo->active = 0; -+ usb_unlink_urb(&fifo->urb); -+ } -+ save_flags(flags); -+ cli(); -+ queue_control_request(hfc, HFCUSB_FIFO, -+ fifo->fifonum); -+ queue_control_request(hfc, -+ HFCUSB_INC_RES_F, 2); -+ queue_control_request(hfc, HFCUSB_CON_HDLC, -+ 9); -+ queue_control_request(hfc, HFCUSB_SCTRL, -+ 0x40 + -+ hfc->bch_enables); -+ queue_control_request(hfc, HFCUSB_SCTRL_R, -+ hfc->bch_enables); -+ restore_flags(flags); -+ fifo++; -+ if (fifo->active) { -+ fifo->active = 0; -+ usb_unlink_urb(&fifo->urb); -+ } -+ return; /* fifo deactivated */ -+ } -+ fifo->transmode = ((int) arg == L1_MODE_TRANS); -+ fifo->max_size = -+ ((fifo->transmode) ? fifo-> -+ usb_maxlen : MAX_BCH_SIZE); -+ (fifo + 1)->transmode = fifo->transmode; -+ (fifo + 1)->max_size = fifo->max_size; -+ hfc->bch_enables |= (1 << chan); -+ save_flags(flags); -+ cli(); -+ queue_control_request(hfc, HFCUSB_FIFO, -+ fifo->fifonum); -+ queue_control_request(hfc, HFCUSB_CON_HDLC, -+ ((!fifo-> -+ transmode) ? 9 : 11)); -+ queue_control_request(hfc, HFCUSB_INC_RES_F, 2); -+ queue_control_request(hfc, HFCUSB_SCTRL, -+ 0x40 + hfc->bch_enables); -+ if ((int) arg == L1_MODE_HDLC) -+ queue_control_request(hfc, HFCUSB_CON_HDLC, -+ 8); -+ queue_control_request(hfc, HFCUSB_FIFO, -+ fifo->fifonum + 1); -+ queue_control_request(hfc, HFCUSB_CON_HDLC, -+ ((!fifo-> -+ transmode) ? 8 : 10)); -+ queue_control_request(hfc, HFCUSB_INC_RES_F, 2); -+ queue_control_request(hfc, HFCUSB_SCTRL_R, -+ hfc->bch_enables); -+ restore_flags(flags); -+ -+ break; -+ -+ default: -+ printk(KERN_INFO -+ "unknown hfcusb bch_access chan %d 0x%x\n", -+ chan, pr); -+ break; -+ } -+} /* hfcusb_bch_access */ -+ -+/***************************************************************************/ -+/* usb_init is called once when a new matching device is detected to setup */ -+/* main parmeters. It registers the driver at the main hisax module. */ -+/* on success 0 is returned. */ -+/***************************************************************************/ -+static int -+usb_init(hfcusb_data * hfc) -+{ -+ usb_fifo *fifo; -+ int i; -+ u_char b; -+ -+ /* check the chip id */ -+ if ((Read_hfc(hfc, HFCUSB_CHIP_ID, &b) != 1) || -+ (b != HFCUSB_CHIPID)) { -+ printk(KERN_INFO "HFC-USB: Invalid chip id 0x%02x\n", b); -+ return (1); -+ } -+ -+ /* first set the needed config, interface and alternate */ -+ usb_set_configuration(hfc->dev, 1); -+ usb_set_interface(hfc->dev, hfc->if_used, hfc->alt_used); -+ -+ /* init the led state request */ -+ hfc->led_req = LED_DRIVER; -+ -+ /* now we initialise the chip */ -+ Write_hfc(hfc, HFCUSB_CIRM, 0x10); /* aux = output, reset off */ -+ Write_hfc(hfc, HFCUSB_P_DATA, 0); /* leds = off */ -+ Write_hfc(hfc, HFCUSB_USB_SIZE, -+ (hfc->fifos[HFCUSB_B1_TX].usb_maxlen >> 3) | -+ ((hfc->fifos[HFCUSB_B1_RX].usb_maxlen >> 3) << 4)); -+ -+ /* enable PCM/GCI master mode */ -+ Write_hfc(hfc, HFCUSB_MST_MODE1, 0); /* set default values */ -+ Write_hfc(hfc, HFCUSB_MST_MODE0, 1); /* enable master mode */ -+ -+ /* init the fifos */ -+ Write_hfc(hfc, HFCUSB_F_THRES, (HFCUSB_TX_THRESHOLD >> 3) | -+ ((HFCUSB_RX_THRESHOLD >> 3) << 4)); -+ -+ for (i = 0, fifo = hfc->fifos + i; i < HFCUSB_NUM_FIFOS; -+ i++, fifo++) { -+ Write_hfc(hfc, HFCUSB_FIFO, i); /* select the desired fifo */ -+ -+ fifo->transmode = 0; /* hdlc mode selected */ -+ fifo->buff = NULL; /* init buffer pointer */ -+ fifo->max_size = -+ (i <= HFCUSB_B2_RX) ? MAX_BCH_SIZE : MAX_DFRAME_LEN; -+ Write_hfc(hfc, HFCUSB_HDLC_PAR, ((i <= HFCUSB_B2_RX) ? 0 : 2)); /* data length */ -+ Write_hfc(hfc, HFCUSB_CON_HDLC, ((i & 1) ? 0x08 : 0x09)); /* rx hdlc, tx fill 1 */ -+ Write_hfc(hfc, HFCUSB_INC_RES_F, 2); /* reset the fifo */ -+ } -+ -+ Write_hfc(hfc, HFCUSB_CLKDEL, 0x0f); /* clock delay value */ -+ Write_hfc(hfc, HFCUSB_STATES, 3 | 0x10); /* set deactivated mode */ -+ Write_hfc(hfc, HFCUSB_STATES, 3); /* enable state machine */ -+ -+ Write_hfc(hfc, HFCUSB_SCTRL_R, 0); /* disable both B receivers */ -+ Write_hfc(hfc, HFCUSB_SCTRL, 0x40); /* disable B transmitters + cap mode */ -+ -+ /* init the l1 timer */ -+ init_timer(&hfc->t3_timer); -+ hfc->t3_timer.data = (long) hfc; -+ hfc->t3_timer.function = (void *) l1_timer_expire; -+ hfc->t4_timer.data = (long) hfc; -+ hfc->t4_timer.function = (void *) l1_timer_expire; -+ hfc->l1_tq.routine = (void *) (void *) usb_l1d_bh; -+ hfc->l1_tq.sync = 0; -+ hfc->l1_tq.data = hfc; -+ -+ /* init the background control machinery */ -+ hfc->ctrl_read.requesttype = 0xc0; -+ hfc->ctrl_read.request = 1; -+ hfc->ctrl_read.length = 1; -+ hfc->ctrl_write.requesttype = 0x40; -+ hfc->ctrl_write.request = 0; -+ hfc->ctrl_write.length = 0; -+ FILL_CONTROL_URB(&hfc->ctrl_urb, hfc->dev, hfc->ctrl_out_pipe, -+ (u_char *) & hfc->ctrl_write, NULL, 0, -+ ctrl_complete, hfc); -+ -+ /* init the TX-urbs */ -+ fifo = hfc->fifos + HFCUSB_D_TX; -+ FILL_BULK_URB(&fifo->urb, hfc->dev, fifo->pipe, -+ (u_char *) fifo->buffer, 0, tx_complete, fifo); -+ fifo = hfc->fifos + HFCUSB_B1_TX; -+ FILL_BULK_URB(&fifo->urb, hfc->dev, fifo->pipe, -+ (u_char *) fifo->buffer, 0, tx_complete, fifo); -+ fifo = hfc->fifos + HFCUSB_B2_TX; -+ FILL_BULK_URB(&fifo->urb, hfc->dev, fifo->pipe, -+ (u_char *) fifo->buffer, 0, tx_complete, fifo); -+ -+ /* init the E-buffer */ -+ skb_queue_head_init(&hfc->regd.erq); -+ -+ /* now register ourself at hisax */ -+ hfc->regd.version = HISAX_LOAD_VERSION; /* set our version */ -+ hfc->regd.cmd = HISAX_LOAD_REGISTER; /* register command */ -+ hfc->regd.argl1 = (void *) hfc; /* argument for our local routine */ -+ hfc->regd.dch_l2l1 = hfcusb_l1_access; -+ hfc->regd.bch_l2l1 = hfcusb_bch_access; -+ hfc->regd.drvname = "hfc_usb"; -+ if (hisax_register_hfcusb(&hfc->regd)) { -+ printk(KERN_INFO "HFC-USB failed to register at hisax\n"); -+ Write_hfc(hfc, HFCUSB_CIRM, 0x08); /* aux = input, reset on */ -+ return (1); -+ } -+ -+ /* startup the D- and E-channel fifos */ -+ start_rx_fifo(hfc->fifos + HFCUSB_D_RX); /* D-fifo */ -+ if (hfc->fifos[HFCUSB_PCM_RX].pipe) -+ start_rx_fifo(hfc->fifos + HFCUSB_PCM_RX); /* E-fifo */ -+ -+ return (0); -+} /* usb_init */ -+ -+/*************************************************/ -+/* function called to probe a new plugged device */ -+/*************************************************/ -+static void * -+hfc_usb_probe(struct usb_device *dev, unsigned int interface -+#ifdef COMPAT_HAS_USB_IDTAB -+ , const struct usb_device_id *id_table) -+#else -+ ) -+#endif -+{ -+ hfcusb_data *context; -+ struct usb_interface *ifp = dev->actconfig->interface + interface; -+ struct usb_interface_descriptor *ifdp = -+ ifp->altsetting + ifp->act_altsetting; -+ struct usb_endpoint_descriptor *epd; -+ int i, idx, ep_msk; -+ -+#ifdef COMPAT_HAS_USB_IDTAB -+ if (id_table && (dev->descriptor.idVendor == id_table->idVendor) && -+ (dev->descriptor.idProduct == id_table->idProduct) && -+#else -+ if ((((dev->descriptor.idVendor == 0x959) && -+ (dev->descriptor.idProduct == 0x2bd0)) || -+ ((dev->descriptor.idVendor == 0x7b0) && -+ (dev->descriptor.idProduct == 0x0006))) && -+#endif -+ (ifdp->bNumEndpoints >= 6) && (ifdp->bNumEndpoints <= 16)) { -+ if (!(context = kmalloc(sizeof(hfcusb_data), GFP_KERNEL))) { -+ return (NULL); /* got no mem */ -+ }; -+ memset(context, 0, sizeof(hfcusb_data)); /* clear the structure */ -+ i = ifdp->bNumEndpoints; /* get number of endpoints */ -+ ep_msk = 0; /* none found */ -+ epd = ifdp->endpoint; /* first endpoint descriptor */ -+ while (i-- && ((ep_msk & 0xcf) != 0xcf)) { -+ -+ idx = (((epd->bEndpointAddress & 0x7f) - 1) << 1); /* get endpoint base */ -+ if (idx < 7) { -+ switch (epd->bmAttributes) { -+ case USB_ENDPOINT_XFER_INT: -+ if (! -+ (epd-> -+ bEndpointAddress & -+ 0x80)) -+ break; /* only interrupt in allowed */ -+ idx++; /* input index is odd */ -+ context->fifos[idx].pipe = -+ usb_rcvintpipe(dev, -+ epd-> -+ bEndpointAddress); -+ break; -+ -+ case USB_ENDPOINT_XFER_BULK: -+ if (epd-> -+ bEndpointAddress & -+ 0x80) -+ break; /* only bulk out allowed */ -+ context->fifos[idx].pipe = -+ usb_sndbulkpipe(dev, -+ epd-> -+ bEndpointAddress); -+ break; -+ default: -+ context->fifos[idx].pipe = 0; /* reset data */ -+ } /* switch attribute */ -+ -+ if (context->fifos[idx].pipe) { -+ context->fifos[idx].fifonum = idx; -+ context->fifos[idx].fifo_mask = -+ 1 << idx; -+ context->fifos[idx].hfc = context; -+ context->fifos[idx].usb_maxlen = -+ epd->wMaxPacketSize; -+ context->fifos[idx].intervall = -+ epd->bInterval; -+ ep_msk |= (1 << idx); -+ } else -+ ep_msk &= ~(1 << idx); -+ } /* idx < 7 */ -+ epd++; -+ } -+ -+ if ((ep_msk & 0x3f) != 0x3f) { -+ kfree(context); -+ return (NULL); -+ } -+ MOD_INC_USE_COUNT; /* lock our module */ -+ context->dev = dev; /* save device */ -+ context->if_used = interface; /* save used interface */ -+ context->alt_used = ifp->act_altsetting; /* and alternate config */ -+ context->ctrl_paksize = dev->descriptor.bMaxPacketSize0; /* control size */ -+ -+ /* create the control pipes needed for register access */ -+ context->ctrl_in_pipe = usb_rcvctrlpipe(context->dev, 0); -+ context->ctrl_out_pipe = usb_sndctrlpipe(context->dev, 0); -+ -+ /* init the chip and register the driver */ -+ if (usb_init(context)) { -+ kfree(context); -+ MOD_DEC_USE_COUNT; -+ return (NULL); -+ } -+ -+ printk(KERN_INFO -+ "HFC-USB: New device if=%d alt=%d registered\n", -+ context->if_used, context->alt_used); -+ return (context); -+ } -+ -+ return (NULL); /* no matching entry */ -+} /* hfc_usb_probe */ -+ -+/****************************************************/ -+/* function called when an active device is removed */ -+/****************************************************/ -+static void -+hfc_usb_disconnect(struct usb_device *usbdev, void *drv_context) -+{ -+ hfcusb_data *context = drv_context; -+ int i; -+ struct sk_buff *skb; -+ -+ /* tell all fifos to terminate */ -+ for (i = 0; i < HFCUSB_NUM_FIFOS; i++) -+ if (context->fifos[i].active) { -+ context->fifos[i].active = 0; -+ usb_unlink_urb(&context->fifos[i].urb); -+ } -+ while (context->active_fifos) { -+ set_current_state(TASK_INTERRUPTIBLE); -+ /* Timeout 10ms */ -+ schedule_timeout((10 * HZ) / 1000); -+ } -+ if (timer_pending(&context->t3_timer)) -+ del_timer(&context->t3_timer); -+ context->regd.release_driver(context->regd.arg_hisax); -+ while ((skb = skb_dequeue(&context->regd.erq)) != NULL) -+ dev_kfree_skb_any(skb); -+ -+ kfree(context); /* free our structure again */ -+ MOD_DEC_USE_COUNT; /* and decrement the usage counter */ -+} /* hfc_usb_disconnect */ -+ -+/************************************/ -+/* our driver information structure */ -+/************************************/ -+static struct usb_driver hfc_drv = { -+ name:"hfc_usb", -+#ifdef COMPAT_HAS_USB_IDTAB -+ id_table:hfc_usb_idtab, -+#endif -+ probe:hfc_usb_probe, -+ disconnect:hfc_usb_disconnect, -+}; -+ -+static void __exit -+hfc_usb_exit(void) -+{ -+ -+ usb_deregister(&hfc_drv); /* release our driver */ -+ printk(KERN_INFO "HFC-USB module removed\n"); -+} -+ -+static int __init -+hfc_usb_init(void) -+{ -+ struct hisax_drvreg drv; -+ -+ drv.version = HISAX_LOAD_VERSION; /* set our version */ -+ drv.cmd = HISAX_LOAD_CHKVER; /* check command only */ -+ if (hisax_register_hfcusb(&drv)) { -+ printk(KERN_INFO "HFC-USB <-> hisax version conflict\n"); -+ return (-1); /* unable to register */ -+ } -+ if (usb_register(&hfc_drv)) { -+ printk(KERN_INFO -+ "Unable to register HFC-USB module at usb stack\n"); -+ return (-1); /* unable to register */ -+ } -+ -+ printk(KERN_INFO "HFC-USB module loaded\n"); -+ return (0); -+} -+ -+module_init(hfc_usb_init); -+module_exit(hfc_usb_exit); ---- /dev/null -+++ b/drivers/isdn/hisax/hfc_usbr.c -@@ -0,0 +1,471 @@ -+/* $Id: hfc_usbr.c,v 2.5 2001/07/06 21:30:11 werner Exp $ -+ -+ * hfc_usb.c low level driver for CCD´s hfc-usb single chip controllers -+ * type approval valid for HFC-S USB based TAs -+ * -+ * Author Werner Cornelius (werner@isdn-development.de) -+ * -+ * Copyright 2001 by Werner Cornelius (werner@isdn4linux.de) -+ * -+ * 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, or (at your option) -+ * any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -+ * -+ */ -+ -+#define __NO_VERSION__ -+#include <linux/init.h> -+#include "hisax.h" -+#include "isdnl1.h" -+#include "hisax_loadable.h" -+ -+extern const char *CardType[]; -+ -+static const char *hfcusb_revision = "$Revision: 2.5 $"; -+ -+/*********************************/ -+/* schedule a new b_channel task */ -+/*********************************/ -+static void -+hfcusb_sched_event(struct BCState *bcs, int event) -+{ -+ bcs->event |= 1 << event; -+ queue_task(&bcs->tqueue, &tq_immediate); -+ mark_bh(IMMEDIATE_BH); -+} -+ -+/************************************************/ -+/* select a b-channel entry matching and active */ -+/************************************************/ -+static -+struct BCState * -+Sel_BCS(struct IsdnCardState *cs, int channel) -+{ -+ if (cs->bcs[0].mode && (cs->bcs[0].channel == channel)) -+ return (&cs->bcs[0]); -+ else if (cs->bcs[1].mode && (cs->bcs[1].channel == channel)) -+ return (&cs->bcs[1]); -+ else -+ return (NULL); -+} -+ -+/**********************************************/ -+/* transfer function (D-channel from l2 to l1 */ -+/**********************************************/ -+static void -+hfcusb_d_l2l1(struct PStack *st, int pr, void *arg) -+{ -+ struct IsdnCardState *cs = st->l1.hardware; -+ struct hisax_drvreg *drv = cs->hw.hfcusb.drv; -+ -+ if (drv) { -+ switch (pr) { -+ case (PH_DATA | REQUEST): -+ case (PH_PULL | INDICATION): -+ cs->hw.hfcusb.dch_tx_busy = 1; -+ break; -+ case (PH_PULL | REQUEST): -+ if (!cs->hw.hfcusb.dch_tx_busy) { -+ test_and_clear_bit(FLG_L1_PULL_REQ, -+ &st->l1.Flags); -+ st->l1.l1l2(st, PH_PULL | CONFIRM, -+ NULL); -+ } else -+ test_and_set_bit(FLG_L1_PULL_REQ, -+ &st->l1.Flags); -+ return; -+ } -+ drv->dch_l2l1(drv, pr, arg); -+ } else -+ debugl1(cs, "hfcusb l2l1 called without existing driver"); -+} /* hfcusb_d_l2l1 */ -+ -+/*****************************/ -+/* E-channel receive routine */ -+/*****************************/ -+static void -+EChannel_proc_rcv(struct IsdnCardState *cs) -+{ -+ u_char *ptr; -+ struct sk_buff *skb; -+ struct hisax_drvreg *usbdrv = -+ (struct hisax_drvreg *) cs->hw.hfcusb.drv; -+ -+ -+ while ((skb = skb_dequeue(&usbdrv->erq)) != NULL) { -+ if (cs->debug & DEB_DLOG_HEX) { -+ ptr = cs->dlog; -+ if ((skb->len) < MAX_DLOG_SPACE / 3 - 10) { -+ *ptr++ = 'E'; -+ *ptr++ = 'C'; -+ *ptr++ = 'H'; -+ *ptr++ = 'O'; -+ *ptr++ = ':'; -+ ptr += QuickHex(ptr, skb->data, skb->len); -+ ptr--; -+ *ptr++ = '\n'; -+ *ptr = 0; -+ HiSax_putstatus(cs, NULL, cs->dlog); -+ } else -+ HiSax_putstatus(cs, "LogEcho: ", -+ "warning Frame too big (%d)", -+ skb->len); -+ } -+ dev_kfree_skb_any(skb); -+ } -+} -+ -+/******************************************/ -+/* transfer function called from L1 to L2 */ -+/******************************************/ -+static void -+hfcusb_d_l1l2(void *cs1, int pr, void *arg) -+{ -+ struct IsdnCardState *cs = (struct IsdnCardState *) cs1; -+ -+ switch (pr) { -+ case (PH_DATA | INDICATION): -+ if (!((int) arg)) -+ DChannel_proc_rcv(cs); -+ else -+ EChannel_proc_rcv(cs); -+ break; -+ -+ case (PH_DATA | CONFIRM): -+ cs->hw.hfcusb.dch_tx_busy = 0; -+ DChannel_proc_xmt(cs); -+ break; -+ -+ case (PH_ACTIVATE | INDICATION): -+ case (PH_ACTIVATE | CONFIRM): -+ cs->stlist->l1.l1l2(cs->stlist, pr, arg); -+ if (cs->debug & L1_DEB_ISAC) -+ debugl1(cs, "layer 1 activated"); -+ break; -+ -+ case (PH_DEACTIVATE | INDICATION): -+ case (PH_DEACTIVATE | CONFIRM): -+ cs->stlist->l1.l1l2(cs->stlist, pr, arg); -+ if (cs->debug & L1_DEB_ISAC) -+ debugl1(cs, "layer 1 deactivated"); -+ break; -+ -+ default: -+ debugl1(cs, "unknown l1 msg 0x%x ", pr); -+ } -+} /* hfcusb_d_l1l2 */ -+ -+ -+/******************************************/ -+/* transfer function called from L1 to L2 */ -+/******************************************/ -+static void -+hfcusb_b_l1l2(void *cs1, int chan, int pr, void *arg) -+{ -+ struct IsdnCardState *cs = (struct IsdnCardState *) cs1; -+ struct BCState *bcs = Sel_BCS(cs, chan); -+ -+ switch (pr) { -+ case (PH_DATA | INDICATION): -+ if (!bcs) -+ return; -+ hfcusb_sched_event(bcs, B_RCVBUFREADY); -+ break; -+ -+ case (PH_DATA | CONFIRM): -+ if (!bcs) -+ return; -+ bcs->tx_cnt -= bcs->tx_skb->len; -+ if (bcs->st->lli.l1writewakeup && -+ (PACKET_NOACK != bcs->tx_skb->pkt_type)) -+ bcs->st->lli.l1writewakeup(bcs->st, -+ bcs->tx_skb-> -+ len); -+ dev_kfree_skb_any(bcs->tx_skb); -+ bcs->tx_skb = skb_dequeue(&bcs->squeue); -+ break; -+ -+ case (PH_ACTIVATE | INDICATION): -+ case (PH_ACTIVATE | CONFIRM): -+ cs->stlist->l1.l1l2(cs->stlist, pr, arg); -+ if (cs->debug & L1_DEB_ISAC) -+ debugl1(cs, "layer 1 activated"); -+ break; -+ -+ case (PH_DEACTIVATE | INDICATION): -+ case (PH_DEACTIVATE | CONFIRM): -+ cs->stlist->l1.l1l2(cs->stlist, pr, arg); -+ if (cs->debug & L1_DEB_ISAC) -+ debugl1(cs, "layer 1 deactivated"); -+ break; -+ -+ default: -+ debugl1(cs, "unknown l1 b msg 0x%x ", pr); -+ } -+} /* hfcusb_b_l1l2 */ -+ -+ -+/***********************************************/ -+/* called during init setting l1 stack pointer */ -+/***********************************************/ -+void -+setstack_hfcusb(struct PStack *st, struct IsdnCardState *cs) -+{ -+ st->l2.l2l1 = hfcusb_d_l2l1; -+} -+ -+/**************************************/ -+/* send B-channel data if not blocked */ -+/**************************************/ -+static void -+hfcusb_send_data(struct BCState *bcs) -+{ -+ struct IsdnCardState *cs = bcs->cs; -+ struct hisax_drvreg *drv = -+ (struct hisax_drvreg *) cs->hw.hfcusb.drv; -+ -+ if (!drv) -+ return; -+ drv->bch_l2l1(drv->argl1, bcs->channel, PH_DATA | REQUEST, -+ bcs->tx_skb); -+} -+ -+/***************************************************************/ -+/* activate/deactivate hardware for selected channels and mode */ -+/***************************************************************/ -+void -+mode_hfcusb(struct BCState *bcs, int mode, int bc) -+{ -+ struct IsdnCardState *cs = bcs->cs; -+ struct hisax_drvreg *drv = cs->hw.hfcusb.drv; -+ -+ if (!drv) -+ return; -+ if (cs->debug & L1_DEB_HSCX) -+ debugl1(cs, "HFCUSB bchannel mode %d bchan %d/%d", -+ mode, bc, bcs->channel); -+ bcs->mode = mode; -+ bcs->channel = bc; -+ if (mode) { -+ drv->bsk[bc] = &bcs->tx_skb; -+ drv->brq[bc] = &bcs->rqueue; -+ } -+ drv->bch_l2l1(drv->argl1, bc, PH_ACTIVATE | REQUEST, -+ (void *) mode); -+ if (!mode) { -+ drv->bsk[bc] = NULL; -+ drv->brq[bc] = NULL; -+ } -+} -+ -+/******************************/ -+/* Layer2 -> Layer 1 Transfer */ -+/******************************/ -+static void -+hfcusb_b_l2l1(struct PStack *st, int pr, void *arg) -+{ -+ struct sk_buff *skb = arg; -+ struct hisax_drvreg *drv = st->l1.bcs->cs->hw.hfcusb.drv; -+ long flags; -+ -+ switch (pr) { -+ case (PH_DATA | REQUEST): -+ save_flags(flags); -+ cli(); -+ if (st->l1.bcs->tx_skb) { -+ skb_queue_tail(&st->l1.bcs->squeue, skb); -+ restore_flags(flags); -+ } else { -+ st->l1.bcs->tx_skb = skb; -+ st->l1.bcs->cs->BC_Send_Data(st->l1.bcs); -+ restore_flags(flags); -+ } -+ break; -+ case (PH_PULL | INDICATION): -+ if (st->l1.bcs->tx_skb) { -+ printk(KERN_WARNING -+ "hfc_l2l1: this shouldn't happen\n"); -+ break; -+ } -+ save_flags(flags); -+ cli(); -+ st->l1.bcs->tx_skb = skb; -+ st->l1.bcs->cs->BC_Send_Data(st->l1.bcs); -+ restore_flags(flags); -+ break; -+ case (PH_PULL | REQUEST): -+ if (!st->l1.bcs->tx_skb) { -+ test_and_clear_bit(FLG_L1_PULL_REQ, -+ &st->l1.Flags); -+ st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); -+ } else -+ test_and_set_bit(FLG_L1_PULL_REQ, -+ &st->l1.Flags); -+ break; -+ case (PH_ACTIVATE | REQUEST): -+ if (drv) { -+ test_and_set_bit(BC_FLG_ACTIV, -+ &st->l1.bcs->Flag); -+ mode_hfcusb(st->l1.bcs, st->l1.mode, -+ st->l1.bc); -+ l1_msg_b(st, pr, arg); -+ } -+ break; -+ case (PH_DEACTIVATE | REQUEST): -+ l1_msg_b(st, pr, arg); -+ break; -+ case (PH_DEACTIVATE | CONFIRM): -+ test_and_clear_bit(BC_FLG_ACTIV, -+ &st->l1.bcs->Flag); -+ test_and_clear_bit(BC_FLG_BUSY, &st->l1.bcs->Flag); -+ mode_hfcusb(st->l1.bcs, 0, st->l1.bc); -+ st->l1.l1l2(st, PH_DEACTIVATE | CONFIRM, NULL); -+ break; -+ } -+} -+ -+/******************************************/ -+/* deactivate B-channel access and queues */ -+/******************************************/ -+static void -+close_hfcusb(struct BCState *bcs) -+{ -+ mode_hfcusb(bcs, 0, bcs->channel); -+ if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) { -+ skb_queue_purge(&bcs->rqueue); -+ skb_queue_purge(&bcs->squeue); -+ if (bcs->tx_skb) { -+ dev_kfree_skb_any(bcs->tx_skb); -+ bcs->tx_skb = NULL; -+ test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); -+ } -+ } -+} -+ -+/*************************************/ -+/* init B-channel queues and control */ -+/*************************************/ -+static int -+open_hfcusbstate(struct IsdnCardState *cs, struct BCState *bcs) -+{ -+ if (!test_and_set_bit(BC_FLG_INIT, &bcs->Flag)) { -+ skb_queue_head_init(&bcs->rqueue); -+ skb_queue_head_init(&bcs->squeue); -+ } -+ bcs->tx_skb = NULL; -+ test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); -+ bcs->event = 0; -+ bcs->tx_cnt = 0; -+ return (0); -+} -+ -+/*********************************/ -+/* inits the stack for B-channel */ -+/*********************************/ -+static int -+setstack_2b(struct PStack *st, struct BCState *bcs) -+{ -+ bcs->channel = st->l1.bc; -+ if (open_hfcusbstate(st->l1.hardware, bcs)) -+ return (-1); -+ st->l1.bcs = bcs; -+ st->l2.l2l1 = hfcusb_b_l2l1; -+ setstack_manager(st); -+ bcs->st = st; -+ setstack_l1_B(st); -+ return (0); -+} -+ -+/********************************/ -+/* called for card init message */ -+/********************************/ -+void __devinit -+inithfcusb(struct IsdnCardState *cs) -+{ -+ cs->setstack_d = setstack_hfcusb; -+ cs->BC_Send_Data = &hfcusb_send_data; -+ cs->bcs[0].BC_SetStack = setstack_2b; -+ cs->bcs[1].BC_SetStack = setstack_2b; -+ cs->bcs[0].BC_Close = close_hfcusb; -+ cs->bcs[1].BC_Close = close_hfcusb; -+ mode_hfcusb(cs->bcs, 0, 0); -+ mode_hfcusb(cs->bcs + 1, 0, 1); -+} -+ -+ -+ -+/*******************************************/ -+/* handle card messages from control layer */ -+/*******************************************/ -+static int -+hfcusb_card_msg(struct IsdnCardState *cs, int mt, void *arg) -+{ -+ if (cs->debug & L1_DEB_ISAC) -+ debugl1(cs, "HFCUSB: card_msg %x", mt); -+ switch (mt) { -+ case CARD_INIT: -+ inithfcusb(cs); -+ return (0); -+ case CARD_RELEASE: -+ case CARD_RESET: -+ case CARD_TEST: -+ return (0); -+ } -+ return (0); -+} -+ -+ -+extern void -+ HiSax_closecard(int cardnr); -+/*****************************/ -+/* release a driver instance */ -+/* called when hardware is */ -+/* no longer present. */ -+/*****************************/ -+static void -+release_hfcdrv(void *arg) -+{ -+ struct IsdnCardState *cs = (struct IsdnCardState *) arg; -+ -+ cs->hw.hfcusb.drv = NULL; /* disable any further use of driver */ -+ HiSax_closecard(cs->cardnr); -+} /* release_hfcdrv */ -+ -+/*********************************************/ -+/* called once when a new device is detected */ -+/* initialises local data */ -+/*********************************************/ -+int -+setup_hfc_usb(struct IsdnCard *card) -+{ -+ struct IsdnCardState *cs = card->cs; -+ char tmp[64]; -+ struct hisax_drvreg *usbdrv = -+ (struct hisax_drvreg *) cs->hw.hfcusb.drv; -+ -+ if (!usbdrv) -+ return (0); /* no driver data present */ -+ -+ strcpy(tmp, hfcusb_revision); -+ printk(KERN_INFO "HiSax: HFC-USB driver Rev. %s\n", -+ HiSax_getrev(tmp)); -+ -+ usbdrv->release_driver = &release_hfcdrv; /* release routine */ -+ usbdrv->arg_hisax = (void *) cs; /* parameter for calling */ -+ usbdrv->dch_l1l2 = &hfcusb_d_l1l2; /* access from L1 to HiSax */ -+ usbdrv->bch_l1l2 = &hfcusb_b_l1l2; -+ usbdrv->drq = &cs->rq; -+ usbdrv->dsq = &cs->sq; -+ cs->cardmsg = &hfcusb_card_msg; -+ return (1); /* success */ -+} ---- a/drivers/isdn/hisax/hfcscard.c -+++ b/drivers/isdn/hisax/hfcscard.c -@@ -1,4 +1,4 @@ --/* $Id: hfcscard.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ -+/* $Id: hfcscard.c,v 1.10 2001/09/24 13:22:56 kai Exp $ - * - * low level stuff for hfcs based cards (Teles3c, ACER P10) - * -@@ -12,14 +12,13 @@ - - #define __NO_VERSION__ - #include <linux/init.h> --#include <linux/isapnp.h> - #include "hisax.h" - #include "hfc_2bds0.h" - #include "isdnl1.h" - - extern const char *CardType[]; - --static const char *hfcs_revision = "$Revision: 1.1.4.1 $"; -+static const char *hfcs_revision = "$Revision: 1.10 $"; - - static void - hfcs_interrupt(int intno, void *dev_id, struct pt_regs *regs) -@@ -140,36 +139,6 @@ hfcs_card_msg(struct IsdnCardState *cs, - return(0); - } - --#ifdef __ISAPNP__ --static struct isapnp_device_id hfc_ids[] __initdata = { -- { ISAPNP_VENDOR('A', 'N', 'X'), ISAPNP_FUNCTION(0x1114), -- ISAPNP_VENDOR('A', 'N', 'X'), ISAPNP_FUNCTION(0x1114), -- (unsigned long) "Acer P10" }, -- { ISAPNP_VENDOR('B', 'I', 'L'), ISAPNP_FUNCTION(0x0002), -- ISAPNP_VENDOR('B', 'I', 'L'), ISAPNP_FUNCTION(0x0002), -- (unsigned long) "Billion 2" }, -- { ISAPNP_VENDOR('B', 'I', 'L'), ISAPNP_FUNCTION(0x0001), -- ISAPNP_VENDOR('B', 'I', 'L'), ISAPNP_FUNCTION(0x0001), -- (unsigned long) "Billion 1" }, -- { ISAPNP_VENDOR('T', 'A', 'G'), ISAPNP_FUNCTION(0x7410), -- ISAPNP_VENDOR('T', 'A', 'G'), ISAPNP_FUNCTION(0x7410), -- (unsigned long) "IStar PnP" }, -- { ISAPNP_VENDOR('T', 'A', 'G'), ISAPNP_FUNCTION(0x2610), -- ISAPNP_VENDOR('T', 'A', 'G'), ISAPNP_FUNCTION(0x2610), -- (unsigned long) "Teles 16.3c" }, -- { ISAPNP_VENDOR('S', 'F', 'M'), ISAPNP_FUNCTION(0x0001), -- ISAPNP_VENDOR('S', 'F', 'M'), ISAPNP_FUNCTION(0x0001), -- (unsigned long) "Tornado Tipa C" }, -- { ISAPNP_VENDOR('K', 'Y', 'E'), ISAPNP_FUNCTION(0x0001), -- ISAPNP_VENDOR('K', 'Y', 'E'), ISAPNP_FUNCTION(0x0001), -- (unsigned long) "Genius Speed Surfer" }, -- { 0, } --}; -- --static struct isapnp_device_id *hdev = &hfc_ids[0]; --static struct pci_bus *pnp_c __devinitdata = NULL; --#endif -- - int __init - setup_hfcs(struct IsdnCard *card) - { -@@ -178,46 +147,6 @@ setup_hfcs(struct IsdnCard *card) - - strcpy(tmp, hfcs_revision); - printk(KERN_INFO "HiSax: HFC-S driver Rev. %s\n", HiSax_getrev(tmp)); -- --#ifdef __ISAPNP__ -- if (!card->para[1] && isapnp_present()) { -- struct pci_bus *pb; -- struct pci_dev *pd; -- -- while(hdev->card_vendor) { -- if ((pb = isapnp_find_card(hdev->card_vendor, -- hdev->card_device, pnp_c))) { -- pnp_c = pb; -- pd = NULL; -- if ((pd = isapnp_find_dev(pnp_c, -- hdev->vendor, hdev->function, pd))) { -- printk(KERN_INFO "HiSax: %s detected\n", -- (char *)hdev->driver_data); -- pd->prepare(pd); -- pd->deactivate(pd); -- pd->activate(pd); -- card->para[1] = pd->resource[0].start; -- card->para[0] = pd->irq_resource[0].start; -- if (!card->para[0] || !card->para[1]) { -- printk(KERN_ERR "HFC PnP:some resources are missing %ld/%lx\n", -- card->para[0], card->para[1]); -- pd->deactivate(pd); -- return(0); -- } -- break; -- } else { -- printk(KERN_ERR "HFC PnP: PnP error card found, no device\n"); -- } -- } -- hdev++; -- pnp_c=NULL; -- } -- if (!hdev->card_vendor) { -- printk(KERN_INFO "HFC PnP: no ISAPnP card found\n"); -- return(0); -- } -- } --#endif - cs->hw.hfcD.addr = card->para[1] & 0xfffe; - cs->irq = card->para[0]; - cs->hw.hfcD.cip = 0; ---- a/drivers/isdn/hisax/hisax.h -+++ b/drivers/isdn/hisax/hisax.h -@@ -1,4 +1,4 @@ --/* $Id: hisax.h,v 1.1.4.2 2001/12/09 19:15:28 kai Exp $ -+/* $Id: hisax.h,v 2.64 2001/09/24 13:22:56 kai Exp $ - * - * Basic declarations, defines and prototypes - * -@@ -24,7 +24,9 @@ - #include <linux/isdnif.h> - #include <linux/tty.h> - #include <linux/serial_reg.h> -+#ifndef COMPAT_NO_SOFTNET - #include <linux/netdevice.h> -+#endif - - #define ERROR_STATISTIC - -@@ -68,9 +70,6 @@ - #define DL_DATA 0x0220 - #define DL_FLUSH 0x0224 - #define DL_UNIT_DATA 0x0230 -- --#define MDL_BC_RELEASE 0x0278 // Formula-n enter:now --#define MDL_BC_ASSIGN 0x027C // Formula-n enter:now - #define MDL_ASSIGN 0x0280 - #define MDL_REMOVE 0x0284 - #define MDL_ERROR 0x0288 -@@ -472,8 +471,6 @@ struct amd7930_hw { - #define BC_FLG_FTI_RUN 13 - #define BC_FLG_LL_OK 14 - #define BC_FLG_LL_CONN 15 --#define BC_FLG_FTI_FTS 16 --#define BC_FLG_FRH_WAIT 17 - - #define L1_MODE_NULL 0 - #define L1_MODE_TRANS 1 -@@ -695,6 +692,13 @@ struct hfcPCI_hw { - struct timer_list timer; - }; - -+#ifdef CONFIG_HISAX_HFC_USB -+struct hfcUSB_hw { -+ void *drv; /* pointer to driver structure */ -+ int dch_tx_busy; -+}; -+#endif -+ - struct hfcSX_hw { - unsigned long base; - unsigned char cirm; -@@ -838,17 +842,6 @@ struct w6692_chip { - int ph_state; - }; - --struct amd7930_chip { -- u_char lmr1; -- u_char ph_state; -- u_char old_state; -- u_char flg_t3; -- unsigned int tx_xmtlen; -- struct timer_list timer3; -- void (*ph_command) (struct IsdnCardState *, u_char, char *); -- void (*setIrqMask) (struct IsdnCardState *, u_char); --}; -- - struct icc_chip { - int ph_state; - u_char *mon_tx; -@@ -902,6 +895,9 @@ struct IsdnCardState { - struct njet_hw njet; - struct hfcD_hw hfcD; - struct hfcPCI_hw hfcpci; -+#ifdef CONFIG_HISAX_HFC_USB -+ struct hfcUSB_hw hfcusb; -+#endif - struct hfcSX_hw hfcsx; - struct ix1_hw niccy; - struct isurf_hw isurf; -@@ -945,7 +941,6 @@ struct IsdnCardState { - struct hfcpci_chip hfcpci; - struct hfcsx_chip hfcsx; - struct w6692_chip w6692; -- struct amd7930_chip amd7930; - struct icc_chip icc; - } dc; - u_char *rcvbuf; -@@ -967,6 +962,8 @@ struct IsdnCardState { - #define MON0_TX 4 - #define MON1_TX 8 - -+#define HISAX_MAX_CARDS 8 -+ - #define ISDN_CTYPE_16_0 1 - #define ISDN_CTYPE_8_0 2 - #define ISDN_CTYPE_16_3 3 -@@ -1006,8 +1003,8 @@ struct IsdnCardState { - #define ISDN_CTYPE_HFC_SX 37 - #define ISDN_CTYPE_NETJET_U 38 - #define ISDN_CTYPE_HFC_SP_PCMCIA 39 --#define ISDN_CTYPE_DYNAMIC 40 --#define ISDN_CTYPE_ENTERNOW 41 -+#define ISDN_CTYPE_HFC_USB 40 -+#define ISDN_CTYPE_DYNAMIC 41 - #define ISDN_CTYPE_COUNT 41 - - -@@ -1267,10 +1264,6 @@ struct IsdnCardState { - #define CARD_NETJET_U 0 - #endif - --#ifdef CONFIG_HISAX_ENTERNOW_PCI --#define CARD_FN_ENTERNOW_PCI 1 --#endif -- - #define TEI_PER_CARD 1 - - /* L1 Debug */ ---- a/drivers/isdn/hisax/hisax_debug.h -+++ b/drivers/isdn/hisax/hisax_debug.h -@@ -28,7 +28,7 @@ - - #define DBG(level, format, arg...) do { \ - if (level & __debug_variable) \ --printk(KERN_DEBUG "%s: " format "\n" , __FUNCTION__ , ## arg); \ -+printk(KERN_DEBUG __FUNCTION__ ": " format "\n" , ## arg); \ - } while (0) - - #define DBG_PACKET(level,data,count) \ ---- a/drivers/isdn/hisax/hisax_fcpcipnp.c -+++ b/drivers/isdn/hisax/hisax_fcpcipnp.c -@@ -20,22 +20,19 @@ - * - * o POWER PC - * o clean up debugging -- * o tx_skb at PH_DEACTIVATE time - */ - - #include <linux/version.h> - #include <linux/module.h> - #include <linux/init.h> - #include <linux/pci.h> --#include <linux/isapnp.h> -+#include "hisax_isapnp.h" - #include <linux/kmod.h> - #include <linux/slab.h> - #include <linux/skbuff.h> - #include <linux/netdevice.h> -- --#include <asm/io.h> -- - #include "hisax_fcpcipnp.h" -+#include "hisax_isac.h" - - // debugging cruft - #define __debug_variable debug -@@ -46,10 +43,14 @@ static int debug = 0; - MODULE_PARM(debug, "i"); - #endif - --MODULE_AUTHOR("Kai Germaschewski <kai.germaschewski@gmx.de>/Karsten Keil <kkeil@suse.de>"); -+MODULE_AUTHOR("Kai Germaschewski <kai.germaschewski@gmx.de>"); - MODULE_DESCRIPTION("AVM Fritz!PCI/PnP ISDN driver"); - --static struct pci_device_id fcpci_ids[] __devinitdata = { -+#ifndef PCI_DEVICE_ID_AVM_A1_V2 -+#define PCI_DEVICE_ID_AVM_A1_V2 0x0e00 -+#endif -+ -+static struct pci_device_id fcpci_ids[] __initdata = { - { PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_A1 , PCI_ANY_ID, PCI_ANY_ID, - 0, 0, (unsigned long) "Fritz!Card PCI" }, - { PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_A1_V2, PCI_ANY_ID, PCI_ANY_ID, -@@ -58,7 +59,7 @@ static struct pci_device_id fcpci_ids[] - }; - MODULE_DEVICE_TABLE(pci, fcpci_ids); - --static struct isapnp_device_id fcpnp_ids[] __devinitdata = { -+static struct isapnp_device_id fcpnp_ids[] __initdata = { - { ISAPNP_VENDOR('A', 'V', 'M'), ISAPNP_FUNCTION(0x0900), - ISAPNP_VENDOR('A', 'V', 'M'), ISAPNP_FUNCTION(0x0900), - (unsigned long) "Fritz!Card PnP" }, -@@ -68,7 +69,8 @@ MODULE_DEVICE_TABLE(isapnp, fcpnp_ids); - - static int protocol = 2; /* EURO-ISDN Default */ - MODULE_PARM(protocol, "i"); --MODULE_LICENSE("GPL"); -+ -+static LIST_HEAD(adapter_list); - - // ---------------------------------------------------------------------- - -@@ -147,7 +149,7 @@ static unsigned char fcpci_read_isac(str - outb(idx, adapter->io + AVM_INDEX); - val = inb(adapter->io + AVM_DATA + (offset & 0xf)); - spin_unlock_irqrestore(&adapter->hw_lock, flags); -- DBG(0x1000, " port %#x, value %#x", -+ DBG(0x1000, __FUNCTION__ " port %#x, value %#x", - offset, val); - return val; - } -@@ -160,7 +162,7 @@ static void fcpci_write_isac(struct isac - AVM_IDX_ISAC_REG_HIGH : AVM_IDX_ISAC_REG_LOW; - unsigned long flags; - -- DBG(0x1000, " port %#x, value %#x", -+ DBG(0x1000, __FUNCTION__ " port %#x, value %#x", - offset, value); - spin_lock_irqsave(&adapter->hw_lock, flags); - outb(idx, adapter->io + AVM_INDEX); -@@ -240,7 +242,7 @@ static unsigned char fcpci2_read_isac(st - outl(offset, adapter->io + AVM_ISACSX_INDEX); - val = inl(adapter->io + AVM_ISACSX_DATA); - spin_unlock_irqrestore(&adapter->hw_lock, flags); -- DBG(0x1000, " port %#x, value %#x", -+ DBG(0x1000, __FUNCTION__ " port %#x, value %#x", - offset, val); - - return val; -@@ -252,7 +254,7 @@ static void fcpci2_write_isac(struct isa - struct fritz_adapter *adapter = isac->priv; - unsigned long flags; - -- DBG(0x1000, " port %#x, value %#x", -+ DBG(0x1000, __FUNCTION__ " port %#x, value %#x", - offset, value); - spin_lock_irqsave(&adapter->hw_lock, flags); - outl(offset, adapter->io + AVM_ISACSX_INDEX); -@@ -375,6 +377,9 @@ static void hdlc_fill_fifo(struct fritz_ - - DBG(0x40, "hdlc_fill_fifo"); - -+ if (!skb) -+ BUG(); -+ - if (skb->len == 0) - BUG(); - -@@ -515,7 +520,6 @@ static inline void hdlc_xdu_irq(struct f - } - skb_push(bcs->tx_skb, bcs->tx_cnt); - bcs->tx_cnt = 0; -- hdlc_fill_fifo(bcs); - } - - static inline void hdlc_xpr_irq(struct fritz_bcs *bcs) -@@ -536,7 +540,7 @@ static inline void hdlc_xpr_irq(struct f - dev_kfree_skb_irq(skb); - } - --static void hdlc_irq_one(struct fritz_bcs *bcs, u32 stat) -+static void hdlc_irq(struct fritz_bcs *bcs, u32 stat) - { - DBG(0x10, "ch%d stat %#x", bcs->channel, stat); - if (stat & HDLC_INT_RPR) { -@@ -553,7 +557,7 @@ static void hdlc_irq_one(struct fritz_bc - } - } - --static inline void hdlc_irq(struct fritz_adapter *adapter) -+static inline void hdlc_interrupt(struct fritz_adapter *adapter) - { - int nr; - u32 stat; -@@ -562,7 +566,7 @@ static inline void hdlc_irq(struct fritz - stat = adapter->read_hdlc_status(adapter, nr); - DBG(0x10, "HDLC %c stat %#x", 'A' + nr, stat); - if (stat & HDLC_INT_MASK) -- hdlc_irq_one(&adapter->bcs[nr], stat); -+ hdlc_irq(&adapter->bcs[nr], stat); - } - } - -@@ -584,14 +588,14 @@ static void modehdlc(struct fritz_bcs *b - adapter->write_ctrl(bcs, 5); - break; - case L1_MODE_TRANS: -+ bcs->ctrl.sr.mode = HDLC_MODE_TRANS; -+ adapter->write_ctrl(bcs, 5); -+ bcs->ctrl.sr.cmd = HDLC_CMD_XRS; -+ adapter->write_ctrl(bcs, 1); -+ bcs->ctrl.sr.cmd = 0; -+ break; - case L1_MODE_HDLC: -- bcs->rcvidx = 0; -- bcs->tx_cnt = 0; -- bcs->tx_skb = NULL; -- if (mode == L1_MODE_TRANS) -- bcs->ctrl.sr.mode = HDLC_MODE_TRANS; -- else -- bcs->ctrl.sr.mode = HDLC_MODE_ITF_FLG; -+ bcs->ctrl.sr.mode = HDLC_MODE_ITF_FLG; - adapter->write_ctrl(bcs, 5); - bcs->ctrl.sr.cmd = HDLC_CMD_XRS; - adapter->write_ctrl(bcs, 1); -@@ -645,10 +649,10 @@ static void fcpci2_irq(int intno, void * - return; - DBG(2, "STATUS0 %#x", val); - if (val & AVM_STATUS0_IRQ_ISAC) -- isacsx_irq(&adapter->isac); -+ isacsx_interrupt(&adapter->isac); - - if (val & AVM_STATUS0_IRQ_HDLC) -- hdlc_irq(adapter); -+ hdlc_interrupt(adapter); - } - - static void fcpci_irq(int intno, void *dev, struct pt_regs *regs) -@@ -662,10 +666,10 @@ static void fcpci_irq(int intno, void *d - return; - DBG(2, "sval %#x", sval); - if (!(sval & AVM_STATUS0_IRQ_ISAC)) -- isac_irq(&adapter->isac); -+ isac_interrupt(&adapter->isac); - - if (!(sval & AVM_STATUS0_IRQ_HDLC)) -- hdlc_irq(adapter); -+ hdlc_interrupt(adapter); - } - - // ---------------------------------------------------------------------- -@@ -681,11 +685,6 @@ static inline void fcpci_init(struct fri - { - outb(AVM_STATUS0_DIS_TIMER | AVM_STATUS0_RES_TIMER | - AVM_STATUS0_ENA_IRQ, adapter->io + AVM_STATUS0); -- -- outb(AVM_STATUS1_ENA_IOM | adapter->irq, -- adapter->io + AVM_STATUS1); -- set_current_state(TASK_UNINTERRUPTIBLE); -- schedule_timeout(50*HZ / 1000); /* Timeout 50ms */ - } - - // ---------------------------------------------------------------------- -@@ -693,6 +692,7 @@ static inline void fcpci_init(struct fri - static int __devinit fcpcipnp_setup(struct fritz_adapter *adapter) - { - u32 val = 0; -+ struct pci_dev *pdev = adapter->pci_dev; - int retval; - - DBG(1,""); -@@ -700,21 +700,21 @@ static int __devinit fcpcipnp_setup(stru - isac_init(&adapter->isac); // FIXME is this okay now - - retval = -EBUSY; -- if (!request_region(adapter->io, 32, "fcpcipnp")) -+ if (!request_region(adapter->io, 32, "hisax_fcpcipnp")) - goto err; - - switch (adapter->type) { - case AVM_FRITZ_PCIV2: -- retval = request_irq(adapter->irq, fcpci2_irq, SA_SHIRQ, -- "fcpcipnp", adapter); -+ retval = request_irq(pdev->irq, fcpci2_irq, SA_SHIRQ, -+ "hisax_fcpcipnp", adapter); - break; - case AVM_FRITZ_PCI: -- retval = request_irq(adapter->irq, fcpci_irq, SA_SHIRQ, -- "fcpcipnp", adapter); -+ retval = request_irq(pdev->irq, fcpci_irq, SA_SHIRQ, -+ "hisax_fcpcipnp", adapter); - break; - case AVM_FRITZ_PNP: -- retval = request_irq(adapter->irq, fcpci_irq, 0, -- "fcpcipnp", adapter); -+ retval = request_irq(pdev->irq, fcpci_irq, 0, -+ "hisax_fcpcipnp", adapter); - break; - } - if (retval) -@@ -808,11 +808,23 @@ static int __devinit fcpcipnp_setup(stru - - static void __devexit fcpcipnp_release(struct fritz_adapter *adapter) - { -+ struct pci_dev *pdev = adapter->pci_dev; -+ - DBG(1,""); - - outb(0, adapter->io + AVM_STATUS0); -- free_irq(adapter->irq, adapter); -+ free_irq(pdev->irq, adapter); - release_region(adapter->io, 32); -+ -+ switch (adapter->type) { -+ case AVM_FRITZ_PCI: -+ case AVM_FRITZ_PCIV2: -+ pci_disable_device(pdev); -+ break; -+ case AVM_FRITZ_PNP: -+ pdev->deactivate(pdev); -+ break; -+ } - } - - // ---------------------------------------------------------------------- -@@ -830,6 +842,8 @@ new_adapter(struct pci_dev *pdev) - - memset(adapter, 0, sizeof(struct fritz_adapter)); - -+ adapter->pci_dev = pdev; -+ - SET_MODULE_OWNER(&adapter->isac.hisax_d_if); - adapter->isac.hisax_d_if.ifc.priv = &adapter->isac; - adapter->isac.hisax_d_if.ifc.l2l1 = isac_d_l2l1; -@@ -840,6 +854,7 @@ new_adapter(struct pci_dev *pdev) - adapter->bcs[i].b_if.ifc.priv = &adapter->bcs[i]; - adapter->bcs[i].b_if.ifc.l2l1 = fritz_b_l2l1; - } -+ list_add(&adapter->list, &adapter_list); - - pci_set_drvdata(pdev, adapter); - -@@ -854,6 +869,7 @@ new_adapter(struct pci_dev *pdev) - static void delete_adapter(struct fritz_adapter *adapter) - { - hisax_unregister(&adapter->isac.hisax_d_if); -+ list_del(&adapter->list); - kfree(adapter); - } - -@@ -863,12 +879,15 @@ static int __devinit fcpci_probe(struct - struct fritz_adapter *adapter; - int retval; - -+ printk(KERN_INFO "hisax_fcpcipnp: found adapter %s at %s\n", -+ (char *) ent->driver_data, pdev->slot_name); -+ - retval = -ENOMEM; - adapter = new_adapter(pdev); - if (!adapter) - goto err; - -- if (pdev->device == PCI_DEVICE_ID_AVM_A1_V2) -+ if (pdev->device == 0x0e00) - adapter->type = AVM_FRITZ_PCIV2; - else - adapter->type = AVM_FRITZ_PCI; -@@ -876,12 +895,7 @@ static int __devinit fcpci_probe(struct - retval = pci_enable_device(pdev); - if (retval) - goto err_free; -- - adapter->io = pci_resource_start(pdev, 1); -- adapter->irq = pdev->irq; -- -- printk(KERN_INFO "hisax_fcpcipnp: found adapter %s at %s\n", -- (char *) ent->driver_data, pdev->slot_name); - - retval = fcpcipnp_setup(adapter); - if (retval) -@@ -901,6 +915,9 @@ static int __devinit fcpnp_probe(struct - struct fritz_adapter *adapter; - int retval; - -+ printk(KERN_INFO "hisax_fcpcipnp: found adapter %s\n", -+ (char *) ent->driver_data); -+ - retval = -ENOMEM; - adapter = new_adapter(pdev); - if (!adapter) -@@ -912,11 +929,8 @@ static int __devinit fcpnp_probe(struct - pdev->deactivate(pdev); // why? - pdev->activate(pdev); - adapter->io = pdev->resource[0].start; -- adapter->irq = pdev->irq_resource[0].start; -- -- printk(KERN_INFO "hisax_fcpcipnp: found adapter %s at IO %#x irq %d\n", -- (char *) ent->driver_data, adapter->io, adapter->irq); -- -+ pdev->irq = pdev->irq_resource[0].start; -+ - retval = fcpcipnp_setup(adapter); - if (retval) - goto err_free; -@@ -929,43 +943,35 @@ static int __devinit fcpnp_probe(struct - return retval; - } - --static void __devexit fcpci_remove(struct pci_dev *pdev) --{ -- struct fritz_adapter *adapter = pci_get_drvdata(pdev); -- -- fcpcipnp_release(adapter); -- pci_disable_device(pdev); -- delete_adapter(adapter); --} -- --static void __devexit fcpnp_remove(struct pci_dev *pdev) -+static void __devexit fcpcipnp_remove(struct pci_dev *pdev) - { - struct fritz_adapter *adapter = pci_get_drvdata(pdev); - - fcpcipnp_release(adapter); -- pdev->deactivate(pdev); - delete_adapter(adapter); - } - - static struct pci_driver fcpci_driver = { -- name: "fcpci", -- probe: fcpci_probe, -- remove: __devexit_p(fcpci_remove), -+ name: "fcpci", -+ probe: fcpci_probe, -+ remove: fcpcipnp_remove, - id_table: fcpci_ids, - }; - - static struct isapnp_driver fcpnp_driver = { -- name: "fcpnp", -- probe: fcpnp_probe, -- remove: __devexit_p(fcpnp_remove), -+ name: "fcpnp", -+ probe: fcpnp_probe, -+ remove: fcpcipnp_remove, - id_table: fcpnp_ids, - }; - --static int __init hisax_fcpcipnp_init(void) -+static LIST_HEAD(isapnp_drivers); -+ -+static int __init hisax_fcpci_init(void) - { - int retval, pci_nr_found; - -- printk(KERN_INFO "hisax_fcpcipnp: Fritz!Card PCI/PCIv2/PnP ISDN driver v0.0.1\n"); -+ printk(KERN_INFO "hisax_fcpcipnp: Fritz!PCI/PnP ISDN driver v0.0.1\n"); - - retval = pci_register_driver(&fcpci_driver); - if (retval < 0) -@@ -976,15 +982,14 @@ static int __init hisax_fcpcipnp_init(vo - if (retval < 0) - goto out_unregister_pci; - --#if !defined(CONFIG_HOTPLUG) || defined(MODULE) -+#if !defined(CONFIG_HOTPLUG) && defined(MODULE) - if (pci_nr_found + retval == 0) { - retval = -ENODEV; - goto out_unregister_isapnp; -- } - #endif - return 0; - --#if !defined(CONFIG_HOTPLUG) || defined(MODULE) -+#if !defined(CONFIG_HOTPLUG) && defined(MODULE) - out_unregister_isapnp: - isapnp_unregister_driver(&fcpnp_driver); - #endif -@@ -994,11 +999,15 @@ static int __init hisax_fcpcipnp_init(vo - return retval; - } - --static void __exit hisax_fcpcipnp_exit(void) -+static void __exit hisax_fcpci_exit(void) - { - isapnp_unregister_driver(&fcpnp_driver); - pci_unregister_driver(&fcpci_driver); - } - --module_init(hisax_fcpcipnp_init); --module_exit(hisax_fcpcipnp_exit); -+module_init(hisax_fcpci_init); -+module_exit(hisax_fcpci_exit); -+ -+#ifdef __ISAPNP__ -+#include "hisax_isapnp.c" -+#endif ---- a/drivers/isdn/hisax/hisax_fcpcipnp.h -+++ b/drivers/isdn/hisax/hisax_fcpcipnp.h -@@ -43,10 +43,12 @@ struct fritz_bcs { - }; - - struct fritz_adapter { -+ struct list_head list; -+ struct pci_dev *pci_dev; -+ - int type; - spinlock_t hw_lock; - unsigned int io; -- unsigned int irq; - struct isac isac; - - struct fritz_bcs bcs[2]; ---- a/drivers/isdn/hisax/hisax_isac.c -+++ b/drivers/isdn/hisax/hisax_isac.c -@@ -34,7 +34,7 @@ - static int debug = 1; - MODULE_PARM(debug, "i"); - --static char *ISACVer[] = { -+static char *ISACVer[] __devinitdata = { - "2086/2186 V1.1", - "2085 B1", - "2085 B2", -@@ -42,10 +42,6 @@ static char *ISACVer[] = { - }; - #endif - --MODULE_AUTHOR("Kai Germaschewski <kai.germaschewski@gmx.de>/Karsten Keil <kkeil@suse.de>"); --MODULE_DESCRIPTION("ISAC/ISAC-SX driver"); --MODULE_LICENSE("GPL"); -- - #define DBG_WARN 0x0001 - #define DBG_IRQ 0x0002 - #define DBG_L1M 0x0004 -@@ -438,7 +434,7 @@ static void l1m_debug(struct FsmInst *fi - va_end(args); - } - --static void isac_version(struct isac *cs) -+static void __devinit isac_version(struct isac *cs) - { - int val; - -@@ -602,7 +598,7 @@ static inline void isac_exi_interrupt(st - } - } - --void isac_irq(struct isac *isac) -+void isac_interrupt(struct isac *isac) - { - unsigned char val; - -@@ -635,8 +631,6 @@ void isac_irq(struct isac *isac) - if (val & ISAC_ISTA_SIN) { - DBG(DBG_WARN, "SIN"); - } -- isac->write_isac(isac, ISAC_MASK, 0xff); -- isac->write_isac(isac, ISAC_MASK, 0x00); - } - - // ====================================================================== -@@ -742,7 +736,7 @@ static inline void isacsx_icd_interrupt( - } - } - --void isacsx_irq(struct isac *isac) -+void isacsx_interrupt(struct isac *isac) - { - unsigned char val; - -@@ -755,7 +749,7 @@ void isacsx_irq(struct isac *isac) - isacsx_cic_interrupt(isac); - } - --void isac_init(struct isac *isac) -+void __devinit isac_init(struct isac *isac) - { - isac->tx_skb = NULL; - isac->l1m.fsm = &l1fsm; -@@ -770,7 +764,7 @@ void isac_init(struct isac *isac) - FsmInitTimer(&isac->l1m, &isac->timer); - } - --void isac_setup(struct isac *isac) -+void __devinit isac_setup(struct isac *isac) - { - int val, eval; - -@@ -781,7 +775,7 @@ void isac_setup(struct isac *isac) - - isac->write_isac(isac, ISAC_MASK, 0xff); - isac->mocr = 0xaa; -- if (test_bit(ISAC_IOM1, &isac->flags)) { -+ if (test_bit(HW_IOM1, &isac->flags)) { - /* IOM 1 Mode */ - isac->write_isac(isac, ISAC_ADF2, 0x0); - isac->write_isac(isac, ISAC_SPCR, 0xa); -@@ -817,7 +811,7 @@ void isac_setup(struct isac *isac) - FsmEvent(&isac->l1m, (val >> 2) & 0xf, NULL); - - isac->write_isac(isac, ISAC_MASK, 0x0); -- // RESET Receiver and Transmitter -+ /* RESET Receiver and Transmitter */ - isac->write_isac(isac, ISAC_CMDR, ISAC_CMDR_XRES | ISAC_CMDR_RRES); - } - -@@ -888,10 +882,10 @@ EXPORT_SYMBOL(isac_init); - EXPORT_SYMBOL(isac_d_l2l1); - - EXPORT_SYMBOL(isacsx_setup); --EXPORT_SYMBOL(isacsx_irq); -+EXPORT_SYMBOL(isacsx_interrupt); - - EXPORT_SYMBOL(isac_setup); --EXPORT_SYMBOL(isac_irq); -+EXPORT_SYMBOL(isac_interrupt); - - module_init(hisax_isac_init); - module_exit(hisax_isac_exit); ---- a/drivers/isdn/hisax/hisax_isac.h -+++ b/drivers/isdn/hisax/hisax_isac.h -@@ -8,7 +8,7 @@ - #define TIMER3_VALUE 7000 - #define MAX_DFRAME_LEN_L1 300 - --#define ISAC_IOM1 0 -+#define HW_IOM1 0 - - struct isac { - void *priv; -@@ -37,9 +37,9 @@ void isac_init(struct isac *isac); - void isac_d_l2l1(struct hisax_if *hisax_d_if, int pr, void *arg); - - void isac_setup(struct isac *isac); --void isac_irq(struct isac *isac); -+void isac_interrupt(struct isac *isac); - - void isacsx_setup(struct isac *isac); --void isacsx_irq(struct isac *isac); -+void isacsx_interrupt(struct isac *isac); - - #endif ---- /dev/null -+++ b/drivers/isdn/hisax/hisax_isapnp.c -@@ -0,0 +1,105 @@ -+// FIXME copied -+static const struct isapnp_device_id * -+isapnp_match_device(const struct isapnp_device_id *ids, struct pci_dev *dev) -+{ -+ DBG(1,""); -+ -+ while (ids->card_vendor || ids->card_device) { -+ if ((ids->card_vendor == ISAPNP_ANY_ID || ids->card_vendor == dev->bus->vendor) && -+ (ids->card_device == ISAPNP_ANY_ID || ids->card_device == dev->bus->device) && -+ (ids->vendor == ISAPNP_ANY_ID || ids->vendor == dev->vendor) && -+ (ids->function == ISAPNP_ANY_ID || ids->function == dev->device)) -+ return ids; -+ ids++; -+ } -+ return NULL; -+} -+ -+/** -+ * pci_dev_driver - get the pci_driver of a device -+ * @dev: the device to query -+ * -+ * Returns the appropriate pci_driver structure or %NULL if there is no -+ * registered driver for the device. -+ */ -+struct pci_driver *isapnp_dev_driver(const struct pci_dev *dev) -+{ -+ return dev->driver; -+} -+ -+static int isapnp_announce_device(struct isapnp_driver *drv, struct pci_dev *dev) -+{ -+ const struct isapnp_device_id *id; -+ int ret = 0; -+ -+ DBG(1,""); -+ -+ if (drv->id_table) { -+ id = isapnp_match_device(drv->id_table, dev); -+ if (!id) { -+ ret = 0; -+ goto out; -+ } -+ } else -+ id = NULL; -+ -+// dev_probe_lock(); -+ if (drv->probe(dev, id) >= 0) { -+ dev->driver = (struct pci_driver *) drv; -+ ret = 1; -+ } -+// dev_probe_unlock(); -+out: -+ return ret; -+} -+ -+/** -+ * FIXME pci_register_driver - register a new pci driver -+ * @drv: the driver structure to register -+ * -+ * Adds the driver structure to the list of registered drivers -+ * Returns the number of pci devices which were claimed by the driver -+ * during registration. The driver remains registered even if the -+ * return value is zero. -+ */ -+int isapnp_register_driver(struct isapnp_driver *drv) -+{ -+ struct pci_dev *dev; -+ int count = 0; -+ -+ DBG(1,""); -+ -+ list_add_tail(&drv->node, &isapnp_drivers); -+ isapnp_for_each_dev(dev) { -+ if (!isapnp_dev_driver(dev)) -+ count += isapnp_announce_device(drv, dev); -+ } -+ return count; -+} -+ -+/** -+ * pci_unregister_driver - unregister a pci driver -+ * @drv: the driver structure to unregister -+ * -+ * Deletes the driver structure from the list of registered PCI drivers, -+ * gives it a chance to clean up by calling its remove() function for -+ * each device it was responsible for, and marks those devices as -+ * driverless. -+ */ -+ -+void isapnp_unregister_driver(struct isapnp_driver *drv) -+{ -+ struct pci_dev *dev; -+ -+ DBG(1,""); -+ -+ list_del(&drv->node); -+ isapnp_for_each_dev(dev) { -+ if (dev->driver == (struct pci_driver *) drv) { -+ if (drv->remove) -+ drv->remove(dev); -+ dev->driver = NULL; -+ } -+ } -+} -+ ---- /dev/null -+++ b/drivers/isdn/hisax/hisax_isapnp.h -@@ -0,0 +1,33 @@ -+#ifndef __HISAX_ISAPNP_H__ -+#define __HISAX_ISAPNP_H__ -+ -+#include <linux/isapnp.h> -+ -+#ifdef COMPAT_NEED_ISAPNP_DRIVER -+struct isapnp_driver { -+ struct list_head node; -+ char *name; -+ const struct isapnp_device_id *id_table; /* NULL if wants all devices */ -+ int (*probe) (struct pci_dev *dev, const struct isapnp_device_id *id); /* New device inserted */ -+ void (*remove) (struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */ -+}; -+#endif -+#ifdef __ISAPNP__ -+ -+int isapnp_register_driver(struct isapnp_driver *drv); -+void isapnp_unregister_driver(struct isapnp_driver *drv); -+ -+#else -+ -+static inline int isapnp_register_driver(struct isapnp_driver *drv) -+{ -+ return 0; -+} -+ -+static inline void isapnp_unregister_driver(struct isapnp_driver *drv) -+{ -+} -+ -+#endif -+ -+#endif ---- /dev/null -+++ b/drivers/isdn/hisax/hisax_loadable.h -@@ -0,0 +1,74 @@ -+/* $Id: hisax_loadable.h,v 2.1 2001/06/08 22:19:16 werner Exp $ -+ * -+ * -+ * Author (C) 2001 Werner Cornelius (werner@isdn-development.de) -+ * modular driver for Colognechip HFC-USB chip -+ * as plugin for HiSax isdn driver -+ * -+ * Copyright 2001 by Werner Cornelius (werner@isdn4linux.de) -+ * -+ * 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, or (at your option) -+ * any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -+ * -+ */ -+ -+#include <linux/types.h> -+#include <linux/skbuff.h> -+ -+/***************************************/ -+/* additional defines for l1 constants */ -+/***************************************/ -+#define B1_DATA 0x1f0 -+#define B1_SETMODE 0x1f4 -+#define B2_DATA 0x1f8 -+#define B2_SETMODE 0x1fc -+ -+ -+/********************************************************/ -+/* structure used for register and release of L1 driver */ -+/********************************************************/ -+struct hisax_drvreg { -+ int version; /* actual version for check */ -+ int cmd; /* command code */ -+ -+ /* function pointers set by hisax during register call */ -+ void (*release_driver) (void *arg_hisax); /* set by hisax, release function for driver */ -+ void (*dch_l1l2) (void *arg_hisax, int pr, void *arg); /* set by hisax, notify dch+l1 events */ -+ void (*bch_l1l2) (void *arg_hisax, int chan, int pr, void *arg); /* set by hisax, notify bch events */ -+ void *arg_hisax; /* argument when calling hisax main */ -+ struct sk_buff_head *drq; /* pointer to D-receive queue */ -+ struct sk_buff_head *dsq; /* pointer to D-send queue */ -+ struct sk_buff_head erq; /* E-receive queue */ -+ struct sk_buff_head *brq[2]; /* pointer to B-receive queues */ -+ struct sk_buff **bsk[2]; /* pointer to B-transmit buffer */ -+ -+ /* function pointers set by l1 driver before calling the register function */ -+ void (*dch_l2l1) (void *argl1, int pr, void *arg); /* function dch+l1 from hisax -> l1 */ -+ void (*bch_l2l1) (void *argl1, int chan, int pr, void *arg); /* function bch from hisax -> l1 */ -+ void *argl1; /* pointer to l1 data structure when calling l1 */ -+ -+ char *drvname; /* driver name for hisax usage */ -+}; -+ -+/**************************/ -+/* constants and commands */ -+/**************************/ -+#define HISAX_LOAD_VERSION 4 /* change when interface changes */ -+#define HISAX_LOAD_CHKVER 0 /* check version command (returns 0 on success) */ -+#define HISAX_LOAD_REGISTER 1 /* register the L1 driver and return 0 on success */ -+ -+/***************************************/ -+/* definition of the register function */ -+/***************************************/ -+extern int hisax_register_hfcusb(struct hisax_drvreg *l1drv); ---- a/drivers/isdn/hisax/hscx.c -+++ b/drivers/isdn/hisax/hscx.c -@@ -1,4 +1,4 @@ --/* $Id: hscx.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: hscx.c,v 1.24 2001/09/24 13:22:56 kai Exp $ - * - * HSCX specific routines - * ---- a/drivers/isdn/hisax/hscx.h -+++ b/drivers/isdn/hisax/hscx.h -@@ -1,4 +1,4 @@ --/* $Id: hscx.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: hscx.h,v 1.8 2001/09/24 13:22:56 kai Exp $ - * - * HSCX specific defines - * ---- a/drivers/isdn/hisax/hscx_irq.c -+++ b/drivers/isdn/hisax/hscx_irq.c -@@ -1,4 +1,4 @@ --/* $Id: hscx_irq.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: hscx_irq.c,v 1.18 2001/09/24 13:22:56 kai Exp $ - * - * low level b-channel stuff for Siemens HSCX - * ---- a/drivers/isdn/hisax/icc.c -+++ b/drivers/isdn/hisax/icc.c -@@ -1,4 +1,4 @@ --/* $Id: icc.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: icc.c,v 1.8 2001/09/24 13:22:56 kai Exp $ - * - * ICC specific routines - * ---- a/drivers/isdn/hisax/icc.h -+++ b/drivers/isdn/hisax/icc.h -@@ -1,4 +1,4 @@ --/* $Id: icc.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: icc.h,v 1.4 2001/09/24 13:22:56 kai Exp $ - * - * ICC specific routines - * ---- a/drivers/isdn/hisax/ipac.h -+++ b/drivers/isdn/hisax/ipac.h -@@ -1,4 +1,4 @@ --/* $Id: ipac.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: ipac.h,v 1.7 2001/09/24 13:22:56 kai Exp $ - * - * IPAC specific defines - * ---- a/drivers/isdn/hisax/isac.c -+++ b/drivers/isdn/hisax/isac.c -@@ -1,4 +1,4 @@ --/* $Id: isac.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: isac.c,v 1.31 2001/09/24 13:22:56 kai Exp $ - * - * ISAC specific routines - * ---- a/drivers/isdn/hisax/isac.h -+++ b/drivers/isdn/hisax/isac.h -@@ -1,4 +1,4 @@ --/* $Id: isac.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: isac.h,v 1.9 2001/09/24 13:22:56 kai Exp $ - * - * ISAC specific defines - * ---- a/drivers/isdn/hisax/isar.c -+++ b/drivers/isdn/hisax/isar.c -@@ -1,4 +1,4 @@ --/* $Id: isar.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: isar.c,v 1.22 2001/09/23 12:00:05 keil Exp $ - * - * isar.c ISAR (Siemens PSB 7110) specific routines - * -@@ -21,12 +21,10 @@ - #define DLE 0x10 - #define ETX 0x03 - --#define FAXMODCNT 13 --const u_char faxmodulation[] = {3,24,48,72,73,74,96,97,98,121,122,145,146}; --static u_int modmask = 0x1fff; --static int frm_extra_delay = 2; --static int para_TOA = 6; --const u_char *FC1_CMD[] = {"FAE", "FTS", "FRS", "FTM", "FRM", "FTH", "FRH", "CTRL" }; -+ -+const u_char faxmodulation_s[] = "3,24,48,72,73,74,96,97,98,121,122,145,146"; -+const u_char faxmodulation[] = {3,24,48,72,73,74,96,97,98,121,122,145,146}; -+#define FAXMODCNT 13 - - void isar_setup(struct IsdnCardState *cs); - static void isar_pump_cmd(struct BCState *bcs, u_char cmd, u_char para); -@@ -127,7 +125,7 @@ get_irq_infos(struct IsdnCardState *cs, - ireg->clsb = cs->BC_Read_Reg(cs, 1, ISAR_CTRL_L); - #if DUMP_MBOXFRAME - if (cs->debug & L1_DEB_HSCX) -- debugl1(cs, "irq_stat(%02x,%02x,%d)", ireg->iis, ireg->cmsb, -+ debugl1(cs, "rcv_mbox(%02x,%02x,%d)", ireg->iis, ireg->cmsb, - ireg->clsb); - #endif - } -@@ -414,7 +412,6 @@ isar_load_firmware(struct IsdnCardState - } - cs->debug = debug; - isar_setup(cs); -- - ret = 0; - reterrflg: - restore_flags(flags); -@@ -428,21 +425,6 @@ reterror: - return(ret); - } - --static inline void --ll_deliver_faxstat(struct BCState *bcs, u_char status) --{ -- isdn_ctrl ic; -- struct Channel *chanp = (struct Channel *) bcs->st->lli.userdata; -- -- if (bcs->cs->debug & L1_DEB_HSCX) -- debugl1(bcs->cs, "HL->LL FAXIND %x", status); -- ic.driver = bcs->cs->myid; -- ic.command = ISDN_STAT_FAXIND; -- ic.arg = chanp->chan; -- ic.parm.aux.cmd = status; -- bcs->cs->iif.statcallb(&ic); --} -- - extern void BChannel_bh(struct BCState *); - #define B_LL_NOCARRIER 8 - #define B_LL_CONNECT 9 -@@ -599,6 +581,7 @@ isar_rcv_frame(struct IsdnCardState *cs, - if (ireg->cmsb & SART_NMD) { /* ABORT */ - if (cs->debug & L1_DEB_WARN) - debugl1(cs, "isar_rcv_frame: no more data"); -+ cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); - bcs->hw.isar.rcvidx = 0; - send_DLE_ETX(bcs); - sendmsg(cs, SET_DPS(bcs->hw.isar.dpath) | -@@ -609,6 +592,7 @@ isar_rcv_frame(struct IsdnCardState *cs, - } - } else { - printk(KERN_WARNING "HiSax: skb out of memory\n"); -+ cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); - } - break; - } -@@ -633,9 +617,8 @@ isar_rcv_frame(struct IsdnCardState *cs, - bcs->hw.isar.rcvidx = 0; - cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); - } else { -- if (ireg->cmsb & HDLC_FSD) { -+ if (ireg->cmsb & HDLC_FSD) - bcs->hw.isar.rcvidx = 0; -- } - ptr = bcs->hw.isar.rcvbuf + bcs->hw.isar.rcvidx; - bcs->hw.isar.rcvidx += ireg->clsb; - rcv_mbox(cs, ireg, ptr); -@@ -646,8 +629,6 @@ isar_rcv_frame(struct IsdnCardState *cs, - if (cs->debug & L1_DEB_WARN) - debugl1(cs, "isar frame to short %d", - bcs->hw.isar.rcvidx); -- printk(KERN_WARNING "ISAR: frame to short %d\n", -- bcs->hw.isar.rcvidx); - } else if (!(skb = dev_alloc_skb(bcs->hw.isar.rcvidx))) { - printk(KERN_WARNING "ISAR: receive out of memory\n"); - } else { -@@ -658,7 +639,6 @@ isar_rcv_frame(struct IsdnCardState *cs, - isar_sched_event(bcs, B_RCVBUFREADY); - send_DLE_ETX(bcs); - isar_sched_event(bcs, B_LL_OK); -- test_and_clear_bit(BC_FLG_FRH_WAIT, &bcs->Flag); - } - bcs->hw.isar.rcvidx = 0; - } -@@ -666,14 +646,13 @@ isar_rcv_frame(struct IsdnCardState *cs, - if (ireg->cmsb & SART_NMD) { /* ABORT */ - if (cs->debug & L1_DEB_WARN) - debugl1(cs, "isar_rcv_frame: no more data"); -+ cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); - bcs->hw.isar.rcvidx = 0; -+ send_DLE_ETX(bcs); - sendmsg(cs, SET_DPS(bcs->hw.isar.dpath) | - ISAR_HIS_PUMPCTRL, PCTRL_CMD_ESC, 0, NULL); - bcs->hw.isar.state = STFAX_ESCAPE; -- if (test_and_clear_bit(BC_FLG_FRH_WAIT, &bcs->Flag)) { -- send_DLE_ETX(bcs); -- isar_sched_event(bcs, B_LL_NOCARRIER); -- } -+ isar_sched_event(bcs, B_LL_NOCARRIER); - } - break; - default: -@@ -977,6 +956,21 @@ isar_pump_statev_modem(struct BCState *b - } - } - -+static inline void -+ll_deliver_faxstat(struct BCState *bcs, u_char status) -+{ -+ isdn_ctrl ic; -+ struct Channel *chanp = (struct Channel *) bcs->st->lli.userdata; -+ -+ if (bcs->cs->debug & L1_DEB_HSCX) -+ debugl1(bcs->cs, "HL->LL FAXIND %x", status); -+ ic.driver = bcs->cs->myid; -+ ic.command = ISDN_STAT_FAXIND; -+ ic.arg = chanp->chan; -+ ic.parm.aux.cmd = status; -+ bcs->cs->iif.statcallb(&ic); -+} -+ - static void - isar_pump_statev_fax(struct BCState *bcs, u_char devt) { - struct IsdnCardState *cs = bcs->cs; -@@ -1081,22 +1075,19 @@ isar_pump_statev_fax(struct BCState *bcs - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev RSP_DISC"); - if (bcs->hw.isar.state == STFAX_ESCAPE) { -- p1 = 5; - switch(bcs->hw.isar.newcmd) { - case 0: - bcs->hw.isar.state = STFAX_READY; - break; -- case PCTRL_CMD_FTM: -- p1 = 2; - case PCTRL_CMD_FTH: -+ case PCTRL_CMD_FTM: -+ p1 = 10; - sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, - PCTRL_CMD_SILON, 1, &p1); - bcs->hw.isar.state = STFAX_SILDET; - break; -- case PCTRL_CMD_FRM: -- if (frm_extra_delay) -- mdelay(frm_extra_delay); - case PCTRL_CMD_FRH: -+ case PCTRL_CMD_FRM: - p1 = bcs->hw.isar.mod = bcs->hw.isar.newmod; - bcs->hw.isar.newmod = 0; - bcs->hw.isar.cmd = bcs->hw.isar.newcmd; -@@ -1215,9 +1206,6 @@ isar_int_main(struct IsdnCardState *cs) - isar_pump_statev_modem(bcs, ireg->cmsb); - } else if (bcs->mode == L1_MODE_FAX) { - isar_pump_statev_fax(bcs, ireg->cmsb); -- } else if (ireg->cmsb == PSEV_10MS_TIMER) { -- if (cs->debug & L1_DEB_HSCX) -- debugl1(cs, "pump stev TIMER"); - } else { - if (cs->debug & L1_DEB_WARN) - debugl1(cs, "isar IIS_PSTEV pmode %d stat %x", -@@ -1278,9 +1266,6 @@ ftimer_handler(struct BCState *bcs) { - if (test_and_clear_bit(BC_FLG_LL_CONN, &bcs->Flag)) { - isar_sched_event(bcs, B_LL_CONNECT); - } -- if (test_and_clear_bit(BC_FLG_FTI_FTS, &bcs->Flag)) { -- isar_sched_event(bcs, B_LL_OK); -- } - } - - static void -@@ -1303,7 +1288,7 @@ setup_pump(struct BCState *bcs) { - } else { - param[5] = PV32P6_ATN; - } -- param[0] = para_TOA; /* 6 db */ -+ param[0] = 6; /* 6 db */ - param[1] = PV32P2_V23R | PV32P2_V22A | PV32P2_V22B | - PV32P2_V22C | PV32P2_V21 | PV32P2_BEL; - param[2] = PV32P3_AMOD | PV32P3_V32B | PV32P3_V23B; -@@ -1319,7 +1304,7 @@ setup_pump(struct BCState *bcs) { - } else { - param[1] = PFAXP2_ATN; - } -- param[0] = para_TOA; /* 6 db */ -+ param[0] = 6; /* 6 db */ - sendmsg(cs, dps | ISAR_HIS_PUMPCFG, ctrl, 2, param); - bcs->hw.isar.state = STFAX_NULL; - bcs->hw.isar.newcmd = 0; -@@ -1348,6 +1333,7 @@ setup_sart(struct BCState *bcs) { - "\0\0"); - break; - case L1_MODE_HDLC: -+ case L1_MODE_FAX: - param[0] = 0; - sendmsg(cs, dps | ISAR_HIS_SARTCFG, SMODE_HDLC, 1, - param); -@@ -1359,9 +1345,6 @@ setup_sart(struct BCState *bcs) { - sendmsg(cs, dps | ISAR_HIS_SARTCFG, ctrl, 2, - param); - break; -- case L1_MODE_FAX: -- /* SART must not configured with FAX */ -- break; - } - udelay(1000); - sendmsg(cs, dps | ISAR_HIS_BSTREQ, 0, 0, NULL); -@@ -1465,7 +1448,6 @@ isar_pump_cmd(struct BCState *bcs, u_cha - - switch(cmd) { - case ISDN_FAX_CLASS1_FTM: -- test_and_clear_bit(BC_FLG_FRH_WAIT, &bcs->Flag); - if (bcs->hw.isar.state == STFAX_READY) { - p1 = para; - ctrl = PCTRL_CMD_FTM; -@@ -1489,7 +1471,6 @@ isar_pump_cmd(struct BCState *bcs, u_cha - } - break; - case ISDN_FAX_CLASS1_FTH: -- test_and_clear_bit(BC_FLG_FRH_WAIT, &bcs->Flag); - if (bcs->hw.isar.state == STFAX_READY) { - p1 = para; - ctrl = PCTRL_CMD_FTH; -@@ -1513,7 +1494,6 @@ isar_pump_cmd(struct BCState *bcs, u_cha - } - break; - case ISDN_FAX_CLASS1_FRM: -- test_and_clear_bit(BC_FLG_FRH_WAIT, &bcs->Flag); - if (bcs->hw.isar.state == STFAX_READY) { - p1 = para; - ctrl = PCTRL_CMD_FRM; -@@ -1537,7 +1517,6 @@ isar_pump_cmd(struct BCState *bcs, u_cha - } - break; - case ISDN_FAX_CLASS1_FRH: -- test_and_set_bit(BC_FLG_FRH_WAIT, &bcs->Flag); - if (bcs->hw.isar.state == STFAX_READY) { - p1 = para; - ctrl = PCTRL_CMD_FRH; -@@ -1560,11 +1539,6 @@ isar_pump_cmd(struct BCState *bcs, u_cha - bcs->hw.isar.state = STFAX_ESCAPE; - } - break; -- case ISDN_FAXPUMP_HALT: -- bcs->hw.isar.state = STFAX_NULL; -- nom = 0; -- ctrl = PCTRL_CMD_HALT; -- break; - } - if (ctrl) - sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, ctrl, nom, &p1); -@@ -1658,15 +1632,6 @@ isar_l2l1(struct PStack *st, int pr, voi - l1_msg_b(st, pr, arg); - break; - case (PH_DEACTIVATE | CONFIRM): -- switch(st->l1.mode) { -- case L1_MODE_TRANS: -- case L1_MODE_HDLC: -- case L1_MODE_V32: -- break; -- case L1_MODE_FAX: -- isar_pump_cmd(st->l1.bcs, ISDN_FAXPUMP_HALT, 0); -- break; -- } - test_and_clear_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag); - test_and_clear_bit(BC_FLG_BUSY, &st->l1.bcs->Flag); - if (st->l1.bcs->cs->debug & L1_DEB_HSCX) -@@ -1758,51 +1723,6 @@ isar_auxcmd(struct IsdnCardState *cs, is - test_and_set_bit(BC_FLG_DLEETX, - &bcs->Flag); - break; -- case ISDN_FAX_CLASS1_FTS: -- if (ic->parm.aux.subcmd == AT_QUERY) { -- ic->command = ISDN_STAT_FAXIND; -- ic->parm.aux.cmd = ISDN_FAX_CLASS1_OK; -- cs->iif.statcallb(ic); -- return(0); -- } else if (ic->parm.aux.subcmd == AT_EQ_QUERY) { -- strcpy(ic->parm.aux.para, "0-255"); -- ic->command = ISDN_STAT_FAXIND; -- ic->parm.aux.cmd = ISDN_FAX_CLASS1_QUERY; -- cs->iif.statcallb(ic); -- return(0); -- } else if (ic->parm.aux.subcmd == AT_EQ_VALUE) { -- if (cs->debug & L1_DEB_HSCX) -- debugl1(cs, "isar_auxcmd %s=%d", -- FC1_CMD[ic->parm.aux.cmd], ic->parm.aux.para[0]); -- if (bcs->hw.isar.state == STFAX_READY) { -- if (! ic->parm.aux.para[0]) { -- ic->command = ISDN_STAT_FAXIND; -- ic->parm.aux.cmd = ISDN_FAX_CLASS1_OK; -- cs->iif.statcallb(ic); -- return(0); -- } -- if (! test_and_set_bit(BC_FLG_FTI_RUN, &bcs->Flag)) { -- /* n*10 ms */ -- bcs->hw.isar.ftimer.expires = -- jiffies + ((ic->parm.aux.para[0] * 10 * HZ)/1000); -- test_and_set_bit(BC_FLG_FTI_FTS, &bcs->Flag); -- add_timer(&bcs->hw.isar.ftimer); -- return(0); -- } else { -- if (cs->debug) -- debugl1(cs, "isar FTS=%d and FTI busy", -- ic->parm.aux.para[0]); -- } -- } else { -- if (cs->debug) -- debugl1(cs, "isar FTS=%d and isar.state not ready(%x)", -- ic->parm.aux.para[0],bcs->hw.isar.state); -- } -- ic->command = ISDN_STAT_FAXIND; -- ic->parm.aux.cmd = ISDN_FAX_CLASS1_ERROR; -- cs->iif.statcallb(ic); -- } -- break; - case ISDN_FAX_CLASS1_FRM: - case ISDN_FAX_CLASS1_FRH: - case ISDN_FAX_CLASS1_FTM: -@@ -1815,24 +1735,16 @@ isar_auxcmd(struct IsdnCardState *cs, is - cs->iif.statcallb(ic); - return(0); - } else if (ic->parm.aux.subcmd == AT_EQ_QUERY) { -- char *p = ic->parm.aux.para; -- for(i=0;i<FAXMODCNT;i++) -- if ((1<<i) & modmask) -- p += sprintf(p, "%d,", faxmodulation[i]); -- p--; -- *p=0; -+ strcpy(ic->parm.aux.para, faxmodulation_s); - ic->command = ISDN_STAT_FAXIND; - ic->parm.aux.cmd = ISDN_FAX_CLASS1_QUERY; - cs->iif.statcallb(ic); - return(0); - } else if (ic->parm.aux.subcmd == AT_EQ_VALUE) { -- if (cs->debug & L1_DEB_HSCX) -- debugl1(cs, "isar_auxcmd %s=%d", -- FC1_CMD[ic->parm.aux.cmd], ic->parm.aux.para[0]); - for(i=0;i<FAXMODCNT;i++) - if (faxmodulation[i]==ic->parm.aux.para[0]) - break; -- if ((i < FAXMODCNT) && ((1<<i) & modmask) && -+ if ((FAXMODCNT > i) && - test_bit(BC_FLG_INIT, &bcs->Flag)) { - isar_pump_cmd(bcs, - ic->parm.aux.cmd, -@@ -1850,7 +1762,7 @@ isar_auxcmd(struct IsdnCardState *cs, is - break; - case (ISDN_CMD_IOCTL): - switch (ic->arg) { -- case 9: /* load firmware */ -+ case (9): /* load firmware */ - features = ISDN_FEATURE_L2_MODEM | - ISDN_FEATURE_L2_FAX | - ISDN_FEATURE_L3_FCLASS1; -@@ -1860,26 +1772,6 @@ isar_auxcmd(struct IsdnCardState *cs, is - else - ll_run(cs, features); - break; -- case 20: -- features = *(unsigned int *) ic->parm.num; -- printk(KERN_DEBUG "HiSax: max modulation old(%04x) new(%04x)\n", -- modmask, features); -- modmask = features; -- break; -- case 21: -- features = *(unsigned int *) ic->parm.num; -- printk(KERN_DEBUG "HiSax: FRM extra delay old(%d) new(%d) ms\n", -- frm_extra_delay, features); -- if (features >= 0) -- frm_extra_delay = features; -- break; -- case 22: -- features = *(unsigned int *) ic->parm.num; -- printk(KERN_DEBUG "HiSax: TOA old(%d) new(%d) db\n", -- para_TOA, features); -- if (features >= 0 && features < 32) -- para_TOA = features; -- break; - default: - printk(KERN_DEBUG "HiSax: invalid ioctl %d\n", - (int) ic->arg); ---- a/drivers/isdn/hisax/isar.h -+++ b/drivers/isdn/hisax/isar.h -@@ -1,4 +1,4 @@ --/* $Id: isar.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: isar.h,v 1.11 2001/09/24 13:22:56 kai Exp $ - * - * ISAR (Siemens PSB 7110) specific defines - * -@@ -28,8 +28,6 @@ - #define ISAR_HIS_FIRM 0x1e - #define ISAR_HIS_STDSP 0x08 - #define ISAR_HIS_DIAG 0x05 --#define ISAR_HIS_WAITSTATE 0x27 --#define ISAR_HIS_TIMERIRQ 0x25 - #define ISAR_HIS_P0CFG 0x3c - #define ISAR_HIS_P12CFG 0x24 - #define ISAR_HIS_SARTCFG 0x25 -@@ -45,10 +43,6 @@ - #define ISAR_HIS_DPS2 0x80 - #define SET_DPS(x) ((x<<6) & 0xc0) - --#define ISAR_CMD_TIMERIRQ_OFF 0x20 --#define ISAR_CMD_TIMERIRQ_ON 0x21 -- -- - #define ISAR_IIS_MSCMSD 0x3f - #define ISAR_IIS_VNR 0x15 - #define ISAR_IIS_DKEY 0x03 -@@ -213,8 +207,6 @@ - #define STFAX_ESCAPE 5 - #define STFAX_SILDET 6 - --#define ISDN_FAXPUMP_HALT 100 -- - extern int ISARVersion(struct IsdnCardState *cs, char *s); - extern void isar_int_main(struct IsdnCardState *cs); - extern void initisar(struct IsdnCardState *cs); ---- a/drivers/isdn/hisax/isdnl1.c -+++ b/drivers/isdn/hisax/isdnl1.c -@@ -1,4 +1,4 @@ --/* $Id: isdnl1.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: isdnl1.c,v 2.46 2001/09/24 13:22:56 kai Exp $ - * - * common low level stuff for Siemens Chipsetbased isdn cards - * -@@ -18,7 +18,7 @@ - * - */ - --const char *l1_revision = "$Revision: 1.1.4.1 $"; -+const char *l1_revision = "$Revision: 2.46 $"; - - #define __NO_VERSION__ - #include <linux/init.h> ---- a/drivers/isdn/hisax/isdnl1.h -+++ b/drivers/isdn/hisax/isdnl1.h -@@ -1,4 +1,4 @@ --/* $Id: isdnl1.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: isdnl1.h,v 2.12 2001/09/24 13:22:56 kai Exp $ - * - * Layer 1 defines - * ---- a/drivers/isdn/hisax/isdnl2.c -+++ b/drivers/isdn/hisax/isdnl2.c -@@ -1,4 +1,4 @@ --/* $Id: isdnl2.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: isdnl2.c,v 2.30 2001/09/24 13:22:56 kai Exp $ - * - * Author Karsten Keil - * based on the teles driver from Jan den Ouden -@@ -20,7 +20,7 @@ - #include "hisax.h" - #include "isdnl2.h" - --const char *l2_revision = "$Revision: 1.1.4.1 $"; -+const char *l2_revision = "$Revision: 2.30 $"; - - static void l2m_debug(struct FsmInst *fi, char *fmt, ...); - -@@ -1418,8 +1418,8 @@ l2_st5_tei_remove(struct FsmInst *fi, in - freewin(st); - st->l2.tei = -1; - stop_t200(st, 17); -- st5_dl_release_l2l3(st); - FsmChangeState(fi, ST_L2_1); -+ st5_dl_release_l2l3(st); - } - - static void ---- a/drivers/isdn/hisax/isdnl2.h -+++ b/drivers/isdn/hisax/isdnl2.h -@@ -1,4 +1,4 @@ --/* $Id: isdnl2.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id$ - * - * Layer 2 defines - * ---- a/drivers/isdn/hisax/isdnl3.c -+++ b/drivers/isdn/hisax/isdnl3.c -@@ -1,4 +1,4 @@ --/* $Id: isdnl3.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: isdnl3.c,v 2.22 2001/09/24 13:22:56 kai Exp $ - * - * Author Karsten Keil - * based on the teles driver from Jan den Ouden -@@ -21,7 +21,7 @@ - #include "isdnl3.h" - #include <linux/config.h> - --const char *l3_revision = "$Revision: 1.1.4.1 $"; -+const char *l3_revision = "$Revision: 2.22 $"; - - static struct Fsm l3fsm; - ---- a/drivers/isdn/hisax/isdnl3.h -+++ b/drivers/isdn/hisax/isdnl3.h -@@ -1,4 +1,4 @@ --/* $Id: isdnl3.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id$ - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. ---- a/drivers/isdn/hisax/isurf.c -+++ b/drivers/isdn/hisax/isurf.c -@@ -1,4 +1,4 @@ --/* $Id: isurf.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: isurf.c,v 1.12 2001/09/24 13:22:56 kai Exp $ - * - * low level stuff for Siemens I-Surf/I-Talk cards - * -@@ -16,11 +16,10 @@ - #include "isac.h" - #include "isar.h" - #include "isdnl1.h" --#include <linux/isapnp.h> - - extern const char *CardType[]; - --static const char *ISurf_revision = "$Revision: 1.1.4.1 $"; -+static const char *ISurf_revision = "$Revision: 1.12 $"; - - #define byteout(addr,val) outb(val,addr) - #define bytein(addr) inb(addr) -@@ -128,8 +127,10 @@ void - release_io_isurf(struct IsdnCardState *cs) - { - release_region(cs->hw.isurf.reset, 1); -+#ifdef COMPAT_HAS_ISA_IOREMAP - iounmap((unsigned char *)cs->hw.isurf.isar); - release_mem_region(cs->hw.isurf.phymem, ISURF_IOMEM_SIZE); -+#endif - } - - static void -@@ -194,10 +195,6 @@ isurf_auxcmd(struct IsdnCardState *cs, i - return(isar_auxcmd(cs, ic)); - } - --#ifdef __ISAPNP__ --static struct pci_bus *pnp_surf __devinitdata = NULL; --#endif -- - int __init - setup_isurf(struct IsdnCard *card) - { -@@ -215,58 +212,9 @@ setup_isurf(struct IsdnCard *card) - cs->hw.isurf.phymem = card->para[2]; - cs->irq = card->para[0]; - } else { --#ifdef __ISAPNP__ -- struct pci_bus *pb; -- struct pci_dev *pd; -- -- if (isapnp_present()) { -- cs->subtyp = 0; -- if ((pb = isapnp_find_card( -- ISAPNP_VENDOR('S', 'I', 'E'), -- ISAPNP_FUNCTION(0x0010), pnp_surf))) { -- pnp_surf = pb; -- pd = NULL; -- if (!(pd = isapnp_find_dev(pnp_surf, -- ISAPNP_VENDOR('S', 'I', 'E'), -- ISAPNP_FUNCTION(0x0010), pd))) { -- printk(KERN_ERR "ISurfPnP: PnP error card found, no device\n"); -- return (0); -- } -- pd->prepare(pd); -- pd->deactivate(pd); -- pd->activate(pd); -- /* The ISA-PnP logic apparently -- * expects upper limit address to be -- * set. Since the isa-pnp module -- * doesn't do this, so we have to make -- * up for it. -- */ -- isapnp_cfg_begin(pd->bus->number, pd->devfn); -- isapnp_write_word(ISAPNP_CFG_MEM+3, -- pd->resource[8].end >> 8); -- isapnp_cfg_end(); -- cs->hw.isurf.reset = pd->resource[0].start; -- cs->hw.isurf.phymem = pd->resource[8].start; -- cs->irq = pd->irq_resource[0].start; -- if (!cs->irq || !cs->hw.isurf.reset || !cs->hw.isurf.phymem) { -- printk(KERN_ERR "ISurfPnP:some resources are missing %d/%x/%lx\n", -- cs->irq, cs->hw.isurf.reset, cs->hw.isurf.phymem); -- pd->deactivate(pd); -- return(0); -- } -- } else { -- printk(KERN_INFO "ISurfPnP: no ISAPnP card found\n"); -- return(0); -- } -- } else { -- printk(KERN_INFO "ISurfPnP: no ISAPnP bus found\n"); -- return(0); -- } --#else - printk(KERN_WARNING "HiSax: %s port/mem not set\n", - CardType[card->typ]); - return (0); --#endif - } - if (check_region(cs->hw.isurf.reset, 1)) { - printk(KERN_WARNING -@@ -277,6 +225,7 @@ setup_isurf(struct IsdnCard *card) - } else { - request_region(cs->hw.isurf.reset, 1, "isurf isdn"); - } -+#ifdef COMPAT_HAS_ISA_IOREMAP - if (check_mem_region(cs->hw.isurf.phymem, ISURF_IOMEM_SIZE)) { - printk(KERN_WARNING - "HiSax: %s memory region %lx-%lx already in use\n", -@@ -292,6 +241,10 @@ setup_isurf(struct IsdnCard *card) - cs->hw.isurf.isar = - (unsigned long) ioremap(cs->hw.isurf.phymem, ISURF_IOMEM_SIZE); - cs->hw.isurf.isac = cs->hw.isurf.isar + ISURF_ISAC_OFFSET; -+#else -+ cs->hw.isurf.isar = cs->hw.isurf.phymem + ISURF_ISAR_OFFSET; -+ cs->hw.isurf.isac = cs->hw.isurf.phymem + ISURF_ISAC_OFFSET; -+#endif - printk(KERN_INFO - "ISurf: defined at 0x%x 0x%lx IRQ %d\n", - cs->hw.isurf.reset, ---- a/drivers/isdn/hisax/ix1_micro.c -+++ b/drivers/isdn/hisax/ix1_micro.c -@@ -1,4 +1,4 @@ --/* $Id: ix1_micro.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: ix1_micro.c,v 2.12 2001/09/24 13:22:56 kai Exp $ - * - * low level stuff for ITK ix1-micro Rev.2 isdn cards - * derived from the original file teles3.c from Karsten Keil -@@ -19,14 +19,13 @@ - - #define __NO_VERSION__ - #include <linux/init.h> --#include <linux/isapnp.h> - #include "hisax.h" - #include "isac.h" - #include "hscx.h" - #include "isdnl1.h" - - extern const char *CardType[]; --const char *ix1_revision = "$Revision: 1.1.4.1 $"; -+const char *ix1_revision = "$Revision: 2.12 $"; - - #define byteout(addr,val) outb(val,addr) - #define bytein(addr) inb(addr) -@@ -219,21 +218,6 @@ ix1_card_msg(struct IsdnCardState *cs, i - return(0); - } - --#ifdef __ISAPNP__ --static struct isapnp_device_id itk_ids[] __initdata = { -- { ISAPNP_VENDOR('I', 'T', 'K'), ISAPNP_FUNCTION(0x25), -- ISAPNP_VENDOR('I', 'T', 'K'), ISAPNP_FUNCTION(0x25), -- (unsigned long) "ITK micro 2" }, -- { ISAPNP_VENDOR('I', 'T', 'K'), ISAPNP_FUNCTION(0x29), -- ISAPNP_VENDOR('I', 'T', 'K'), ISAPNP_FUNCTION(0x29), -- (unsigned long) "ITK micro 2." }, -- { 0, } --}; -- --static struct isapnp_device_id *idev = &itk_ids[0]; --static struct pci_bus *pnp_c __devinitdata = NULL; --#endif -- - - int __init - setup_ix1micro(struct IsdnCard *card) -@@ -246,45 +230,6 @@ setup_ix1micro(struct IsdnCard *card) - if (cs->typ != ISDN_CTYPE_IX1MICROR2) - return (0); - --#ifdef __ISAPNP__ -- if (!card->para[1] && isapnp_present()) { -- struct pci_bus *pb; -- struct pci_dev *pd; -- -- while(idev->card_vendor) { -- if ((pb = isapnp_find_card(idev->card_vendor, -- idev->card_device, pnp_c))) { -- pnp_c = pb; -- pd = NULL; -- if ((pd = isapnp_find_dev(pnp_c, -- idev->vendor, idev->function, pd))) { -- printk(KERN_INFO "HiSax: %s detected\n", -- (char *)idev->driver_data); -- pd->prepare(pd); -- pd->deactivate(pd); -- pd->activate(pd); -- card->para[1] = pd->resource[0].start; -- card->para[0] = pd->irq_resource[0].start; -- if (!card->para[0] || !card->para[1]) { -- printk(KERN_ERR "ITK PnP:some resources are missing %ld/%lx\n", -- card->para[0], card->para[1]); -- pd->deactivate(pd); -- return(0); -- } -- break; -- } else { -- printk(KERN_ERR "ITK PnP: PnP error card found, no device\n"); -- } -- } -- idev++; -- pnp_c=NULL; -- } -- if (!idev->card_vendor) { -- printk(KERN_INFO "ITK PnP: no ISAPnP card found\n"); -- return(0); -- } -- } --#endif - /* IO-Ports */ - cs->hw.ix1.isac_ale = card->para[1] + ISAC_COMMAND_OFFSET; - cs->hw.ix1.hscx_ale = card->para[1] + HSCX_COMMAND_OFFSET; ---- a/drivers/isdn/hisax/jade.c -+++ b/drivers/isdn/hisax/jade.c -@@ -1,4 +1,4 @@ --/* $Id: jade.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: jade.c,v 1.9 2001/09/24 13:22:56 kai Exp $ - * - * JADE stuff (derived from original hscx.c) - * ---- a/drivers/isdn/hisax/jade.h -+++ b/drivers/isdn/hisax/jade.h -@@ -1,4 +1,4 @@ --/* $Id: jade.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: jade.h,v 1.5 2001/09/24 13:22:56 kai Exp $ - * - * JADE specific defines - * ---- a/drivers/isdn/hisax/jade_irq.c -+++ b/drivers/isdn/hisax/jade_irq.c -@@ -1,4 +1,4 @@ --/* $Id: jade_irq.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: jade_irq.c,v 1.7 2001/09/24 13:22:56 kai Exp $ - * - * Low level JADE IRQ stuff (derived from original hscx_irq.c) - * ---- a/drivers/isdn/hisax/l3_1tr6.c -+++ b/drivers/isdn/hisax/l3_1tr6.c -@@ -1,4 +1,4 @@ --/* $Id: l3_1tr6.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: l3_1tr6.c,v 2.15 2001/09/24 13:22:56 kai Exp $ - * - * German 1TR6 D-channel protocol - * -@@ -20,7 +20,7 @@ - #include <linux/ctype.h> - - extern char *HiSax_getrev(const char *revision); --const char *l3_1tr6_revision = "$Revision: 1.1.4.1 $"; -+const char *l3_1tr6_revision = "$Revision: 2.15 $"; - - #define MsgHead(ptr, cref, mty, dis) \ - *ptr++ = dis; \ ---- a/drivers/isdn/hisax/l3_1tr6.h -+++ b/drivers/isdn/hisax/l3_1tr6.h -@@ -1,4 +1,4 @@ --/* $Id: l3_1tr6.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id$ - * - * German 1TR6 D-channel protocol defines - * ---- a/drivers/isdn/hisax/l3dss1.c -+++ b/drivers/isdn/hisax/l3dss1.c -@@ -1,4 +1,4 @@ --/* $Id: l3dss1.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: l3dss1.c,v 2.32 2001/09/24 13:22:56 kai Exp $ - * - * EURO/DSS1 D-channel protocol - * -@@ -27,7 +27,7 @@ - #include <linux/config.h> - - extern char *HiSax_getrev(const char *revision); --const char *dss1_revision = "$Revision: 1.1.4.1 $"; -+const char *dss1_revision = "$Revision: 2.32 $"; - - #define EXT_BEARER_CAPS 1 - ---- a/drivers/isdn/hisax/l3dss1.h -+++ b/drivers/isdn/hisax/l3dss1.h -@@ -1,4 +1,4 @@ --/* $Id: l3dss1.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id$ - * - * DSS1 (Euro) D-channel protocol defines - * ---- a/drivers/isdn/hisax/l3ni1.c -+++ b/drivers/isdn/hisax/l3ni1.c -@@ -1,4 +1,4 @@ --/* $Id: l3ni1.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: l3ni1.c,v 2.8 2001/09/24 13:22:56 kai Exp $ - * - * NI1 D-channel protocol - * -@@ -25,7 +25,7 @@ - #include <linux/ctype.h> - - extern char *HiSax_getrev(const char *revision); --const char *ni1_revision = "$Revision: 1.1.4.1 $"; -+const char *ni1_revision = "$Revision: 2.8 $"; - - #define EXT_BEARER_CAPS 1 - ---- a/drivers/isdn/hisax/l3ni1.h -+++ b/drivers/isdn/hisax/l3ni1.h -@@ -1,4 +1,4 @@ --/* $Id: l3ni1.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id$ - * - * NI1 D-channel protocol - * ---- a/drivers/isdn/hisax/lmgr.c -+++ b/drivers/isdn/hisax/lmgr.c -@@ -1,4 +1,4 @@ --/* $Id: lmgr.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id$ - * - * Layermanagement module - * ---- a/drivers/isdn/hisax/md5sums.asc -+++ b/drivers/isdn/hisax/md5sums.asc -@@ -1,33 +1,22 @@ -------BEGIN PGP SIGNED MESSAGE----- --Hash: SHA1 -- - # This are valid md5sums for certificated HiSax driver. - # The certification is valid only if the md5sums of all files match. - # The certification is valid only for ELSA Microlink PCI, --# Eicon Technology Diva 2.01 PCI, Sedlbauer SpeedFax+, --# HFC-S PCI A based cards and HFC-S USB based ISDN --# terminal adapters in the moment. -+# Eicon Technology Diva 2.01 PCI, Sedlbauer SpeedFax+, -+# HFC-S PCI A based cards and HFC-S USB based isdn tas -+# in the moment. - # Read ../../../Documentation/isdn/HiSax.cert for more informations. - # --cd4a9917e1147039d5dfc66440d42054 isac.c --211840e78b56c9d4753be9c85da21a50 isdnl1.c --5ce9b1fff42a02f9c2eb4fb81c701b1f isdnl2.c --6948de0c43513dd23c6706feb5fc2209 isdnl3.c --3730780b69368218d756024165efea79 tei.c --16e72710eb58da01415b877490f5d2ac callc.c --6abc55c77e0f3149ae9334f3257a1a1a cert.c --27bdb2800d4590e00da20eff241edc47 l3dss1.c --df8bb877b854c4302d396b554e4e84ef l3_1tr6.c --9d8b4bed15370063d1b16e47080f50e1 elsa.c --210f4a3f1eebca70229d786b15cf3e90 diva.c --4ddf21079dd77e892380f789bae250a7 sedlbauer.c --8200d818771e3cbdef2a3c3e818d25ac hfc_pci.c -+6f9433a8b696076562562d090e3c420f isac.c -+13c3eed869f5139f44c563e3a8fea1f5 isdnl1.c -+addcff863b0ff1e366c0f2ae9fa6e81e isdnl2.c -+7076deb94a363945c21ea27aca4a720a isdnl3.c -+51c603829b6cc4f8421f744ad657ceff tei.c -+669050ab5079f02887ed0239d86e5474 callc.c -+ecacd146b8f8881ef9349935dab3df4a cert.c -+fadeb3b85bb23bc1ac48470c0848d6fa l3dss1.c -+cf7dec9fac6283716904d26b99188476 l3_1tr6.c -+2f75c8765e1be13d114d5f4433cf364b elsa.c -+b4cf8a4dceed9ea6dcba65a85b4eecc7 diva.c -+dee3f8f40c6fe78a4b57729804b7e6cd sedlbauer.c -+0d79fe6dfc5bfaa4826970c41a6d273d hfc_pci.c - # end of md5sums -------BEGIN PGP SIGNATURE----- --Version: GnuPG v1.0.6 (GNU/Linux) --Comment: For info see http://www.gnupg.org -- --iD8DBQE9rE91DiY0VZsg4ukRAkKfAJ4xWUfqjc0hW+V+JPue5yr7mrt+RwCdGdSf --GIKgAEdRLzERmpt/bCCwAbY= --=FaHw -------END PGP SIGNATURE----- ---- a/drivers/isdn/hisax/mic.c -+++ b/drivers/isdn/hisax/mic.c -@@ -1,4 +1,4 @@ --/* $Id: mic.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: mic.c,v 1.12 2001/09/24 13:22:56 kai Exp $ - * - * low level stuff for mic cards - * -@@ -19,7 +19,7 @@ - - extern const char *CardType[]; - --const char *mic_revision = "$Revision: 1.1.4.1 $"; -+const char *mic_revision = "$Revision: 1.12 $"; - - #define byteout(addr,val) outb(val,addr) - #define bytein(addr) inb(addr) ---- a/drivers/isdn/hisax/netjet.c -+++ b/drivers/isdn/hisax/netjet.c -@@ -1,4 +1,4 @@ --/* $Id: netjet.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: netjet.c,v 1.29 2001/09/24 13:22:56 kai Exp $ - * - * low level stuff for Traverse Technologie NETJet ISDN cards - * -@@ -8,9 +8,7 @@ - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * -- * Thanks to Traverse Technologies Australia for documents and information -- * -- * 16-Apr-2002 - led code added - Guy Ellis (guy@traverse.com.au) -+ * Thanks to Traverse Technologie Australia for documents and information - * - */ - -@@ -26,7 +24,7 @@ - #include <asm/io.h> - #include "netjet.h" - --const char *NETjet_revision = "$Revision: 1.1.4.1 $"; -+const char *NETjet_revision = "$Revision: 1.29 $"; - - /* Interface functions */ - -@@ -135,7 +133,6 @@ void - mode_tiger(struct BCState *bcs, int mode, int bc) - { - struct IsdnCardState *cs = bcs->cs; -- u_char led; - - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "Tiger mode %d bchan %d/%d", -@@ -157,15 +154,6 @@ mode_tiger(struct BCState *bcs, int mode - cs->hw.njet.dmactrl); - byteout(cs->hw.njet.base + NETJET_IRQMASK0, 0); - } -- if (cs->typ == ISDN_CTYPE_NETJET_S) -- { -- // led off -- led = bc & 0x01; -- led = 0x01 << (6 + led); // convert to mask -- led = ~led; -- cs->hw.njet.auxd &= led; -- byteout(cs->hw.njet.auxa, cs->hw.njet.auxd); -- } - break; - case (L1_MODE_TRANS): - break; -@@ -191,14 +179,6 @@ mode_tiger(struct BCState *bcs, int mode - bcs->hw.tiger.sendp = bcs->hw.tiger.send; - bcs->hw.tiger.free = NETJET_DMA_TXSIZE; - test_and_set_bit(BC_FLG_EMPTY, &bcs->Flag); -- if (cs->typ == ISDN_CTYPE_NETJET_S) -- { -- // led on -- led = bc & 0x01; -- led = 0x01 << (6 + led); // convert to mask -- cs->hw.njet.auxd |= led; -- byteout(cs->hw.njet.auxa, cs->hw.njet.auxd); -- } - break; - } - if (cs->debug & L1_DEB_HSCX) -@@ -874,13 +854,9 @@ tiger_l2l1(struct PStack *st, int pr, vo - case (PH_ACTIVATE | REQUEST): - test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag); - mode_tiger(st->l1.bcs, st->l1.mode, st->l1.bc); -- /* 2001/10/04 Christoph Ersfeld, Formula-n Europe AG */ -- st->l1.bcs->cs->cardmsg(st->l1.bcs->cs, MDL_BC_ASSIGN, (void *)(&st->l1.bc)); - l1_msg_b(st, pr, arg); - break; - case (PH_DEACTIVATE | REQUEST): -- /* 2001/10/04 Christoph Ersfeld, Formula-n Europe AG */ -- st->l1.bcs->cs->cardmsg(st->l1.bcs->cs, MDL_BC_RELEASE, (void *)(&st->l1.bc)); - l1_msg_b(st, pr, arg); - break; - case (PH_DEACTIVATE | CONFIRM): ---- a/drivers/isdn/hisax/netjet.h -+++ b/drivers/isdn/hisax/netjet.h -@@ -1,4 +1,4 @@ --/* $Id: netjet.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: netjet.h,v 2.8 2001/09/24 13:22:56 kai Exp $ - * - * NETjet common header file - * ---- a/drivers/isdn/hisax/niccy.c -+++ b/drivers/isdn/hisax/niccy.c -@@ -1,4 +1,4 @@ --/* $Id: niccy.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: niccy.c,v 1.21 2001/10/20 22:05:00 kai Exp $ - * - * low level stuff for Dr. Neuhaus NICCY PnP and NICCY PCI and - * compatible (SAGEM cybermodem) -@@ -22,10 +22,10 @@ - #include "hscx.h" - #include "isdnl1.h" - #include <linux/pci.h> --#include <linux/isapnp.h> -+#include <linux/isdn_compat.h> - - extern const char *CardType[]; --const char *niccy_revision = "$Revision: 1.1.4.1 $"; -+const char *niccy_revision = "$Revision: 1.21 $"; - - #define byteout(addr,val) outb(val,addr) - #define bytein(addr) inb(addr) -@@ -239,9 +239,6 @@ niccy_card_msg(struct IsdnCardState *cs, - } - - static struct pci_dev *niccy_dev __initdata = NULL; --#ifdef __ISAPNP__ --static struct pci_bus *pnp_c __devinitdata = NULL; --#endif - - int __init - setup_niccy(struct IsdnCard *card) -@@ -253,39 +250,7 @@ setup_niccy(struct IsdnCard *card) - printk(KERN_INFO "HiSax: Niccy driver Rev. %s\n", HiSax_getrev(tmp)); - if (cs->typ != ISDN_CTYPE_NICCY) - return (0); --#ifdef __ISAPNP__ -- if (!card->para[1] && isapnp_present()) { -- struct pci_bus *pb; -- struct pci_dev *pd; -- -- if ((pb = isapnp_find_card( -- ISAPNP_VENDOR('S', 'D', 'A'), -- ISAPNP_FUNCTION(0x0150), pnp_c))) { -- pnp_c = pb; -- pd = NULL; -- if (!(pd = isapnp_find_dev(pnp_c, -- ISAPNP_VENDOR('S', 'D', 'A'), -- ISAPNP_FUNCTION(0x0150), pd))) { -- printk(KERN_ERR "NiccyPnP: PnP error card found, no device\n"); -- return (0); -- } -- pd->prepare(pd); -- pd->deactivate(pd); -- pd->activate(pd); -- card->para[1] = pd->resource[0].start; -- card->para[2] = pd->resource[1].start; -- card->para[0] = pd->irq_resource[0].start; -- if (!card->para[0] || !card->para[1] || !card->para[2]) { -- printk(KERN_ERR "NiccyPnP:some resources are missing %ld/%lx/%lx\n", -- card->para[0], card->para[1], card->para[2]); -- pd->deactivate(pd); -- return(0); -- } -- } else { -- printk(KERN_INFO "NiccyPnP: no ISAPnP card found\n"); -- } -- } --#endif -+ - if (card->para[1]) { - cs->hw.niccy.isac = card->para[1] + ISAC_PNP; - cs->hw.niccy.hscx = card->para[1] + HSCX_PNP; -@@ -331,12 +296,12 @@ setup_niccy(struct IsdnCard *card) - return(0); - } - cs->irq = niccy_dev->irq; -- cs->hw.niccy.cfg_reg = pci_resource_start(niccy_dev, 0); -+ cs->hw.niccy.cfg_reg = pci_resource_start_io(niccy_dev, 0); - if (!cs->hw.niccy.cfg_reg) { - printk(KERN_WARNING "Niccy: No IO-Adr for PCI cfg found\n"); - return(0); - } -- pci_ioaddr = pci_resource_start(niccy_dev, 1); -+ pci_ioaddr = pci_resource_start_io(niccy_dev, 1); - if (!pci_ioaddr) { - printk(KERN_WARNING "Niccy: No IO-Adr for PCI card found\n"); - return(0); ---- a/drivers/isdn/hisax/nj_s.c -+++ b/drivers/isdn/hisax/nj_s.c -@@ -1,4 +1,4 @@ --/* $Id: nj_s.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: nj_s.c,v 2.13 2001/09/24 13:22:56 kai Exp $ - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. -@@ -12,11 +12,12 @@ - #include "isac.h" - #include "isdnl1.h" - #include <linux/pci.h> -+#include <linux/isdn_compat.h> - #include <linux/interrupt.h> - #include <linux/ppp_defs.h> - #include "netjet.h" - --const char *NETjet_S_revision = "$Revision: 1.1.4.1 $"; -+const char *NETjet_S_revision = "$Revision: 2.13 $"; - - static u_char dummyrr(struct IsdnCardState *cs, int chan, u_char off) - { -@@ -130,7 +131,6 @@ NETjet_S_card_msg(struct IsdnCardState * - release_io_netjet(cs); - return(0); - case CARD_INIT: -- reset_netjet_s(cs); - inittiger(cs); - clear_pending_isac_ints(cs); - initisac(cs); -@@ -180,19 +180,11 @@ setup_netjet_s(struct IsdnCard *card) - printk(KERN_WARNING "NETjet-S: No IRQ for PCI card found\n"); - return(0); - } -- cs->hw.njet.base = pci_resource_start(dev_netjet, 0); -+ cs->hw.njet.base = pci_resource_start_io(dev_netjet, 0); - if (!cs->hw.njet.base) { - printk(KERN_WARNING "NETjet-S: No IO-Adr for PCI card found\n"); - return(0); - } -- /* 2001/10/04 Christoph Ersfeld, Formula-n Europe AG www.formula-n.com */ -- if ((dev_netjet->subsystem_vendor == 0x55) && -- (dev_netjet->subsystem_device == 0x02)) { -- printk(KERN_WARNING "Netjet: You tried to load this driver with an incompatible TigerJet-card\n"); -- printk(KERN_WARNING "Use type=41 for Formula-n enter:now ISDN PCI and compatible\n"); -- return(0); -- } -- /* end new code */ - } else { - printk(KERN_WARNING "NETjet-S: No PCI card found\n"); - return(0); -@@ -263,6 +255,7 @@ setup_netjet_s(struct IsdnCard *card) - } else { - request_region(cs->hw.njet.base, bytecnt, "netjet-s isdn"); - } -+ reset_netjet_s(cs); - cs->readisac = &NETjet_ReadIC; - cs->writeisac = &NETjet_WriteIC; - cs->readisacfifo = &NETjet_ReadICfifo; ---- a/drivers/isdn/hisax/nj_u.c -+++ b/drivers/isdn/hisax/nj_u.c -@@ -1,4 +1,4 @@ --/* $Id: nj_u.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: nj_u.c,v 2.14 2001/09/24 13:22:56 kai Exp $ - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. -@@ -12,11 +12,12 @@ - #include "icc.h" - #include "isdnl1.h" - #include <linux/pci.h> -+#include <linux/isdn_compat.h> - #include <linux/interrupt.h> - #include <linux/ppp_defs.h> - #include "netjet.h" - --const char *NETjet_U_revision = "$Revision: 1.1.4.1 $"; -+const char *NETjet_U_revision = "$Revision: 2.14 $"; - - static u_char dummyrr(struct IsdnCardState *cs, int chan, u_char off) - { -@@ -181,7 +182,7 @@ setup_netjet_u(struct IsdnCard *card) - printk(KERN_WARNING "NETspider-U: No IRQ for PCI card found\n"); - return(0); - } -- cs->hw.njet.base = pci_resource_start(dev_netjet, 0); -+ cs->hw.njet.base = pci_resource_start_io(dev_netjet, 0); - if (!cs->hw.njet.base) { - printk(KERN_WARNING "NETspider-U: No IO-Adr for PCI card found\n"); - return(0); ---- a/drivers/isdn/hisax/q931.c -+++ b/drivers/isdn/hisax/q931.c -@@ -1,4 +1,4 @@ --/* $Id: q931.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: q931.c,v 1.12 2001/09/24 13:22:56 kai Exp $ - * - * code to decode ITU Q.931 call control messages - * -@@ -197,6 +197,31 @@ struct MessageType mt_n1[] = - - #define MT_N1_LEN (sizeof(mt_n1) / sizeof(struct MessageType)) - -+#if 0 -+static struct MessageType fac_1tr6[] = -+{ -+ {FAC_Sperre, "Sperre"}, -+ {FAC_Forward1, "Forward 1"}, -+ {FAC_Forward2, "Forward 2"}, -+ {FAC_Konferenz, "Konferenz"}, -+ {FAC_GrabBchan, "Grab Bchannel"}, -+ {FAC_Reactivate, "Reactivate"}, -+ {FAC_Konferenz3, "Dreier Konferenz"}, -+ {FAC_Dienstwechsel1, "Einseitiger Dienstwechsel"}, -+ {FAC_Dienstwechsel2, "Zweiseitiger Dienstwechsel"}, -+ {FAC_NummernIdent, "Rufnummer-Identifizierung"}, -+ {FAC_GBG, "GBG"}, -+ {FAC_DisplayUebergeben, "Display Uebergeben"}, -+ {FAC_DisplayUmgeleitet, "Display Umgeleitet"}, -+ {FAC_Unterdruecke, "Unterdruecke Rufnummer"}, -+ {FAC_Deactivate, "Deactivate"}, -+ {FAC_Activate, "Activate"}, -+ {FAC_SPV, "SPV"}, -+ {FAC_Rueckwechsel, "Rueckwechsel"}, -+ {FAC_Umleitung, "Umleitung"} -+}; -+#define FAC_1TR6_LEN (sizeof(fac_1tr6) / sizeof(struct MessageType)) -+#endif - - static int - prbits(char *dest, u_char b, int start, int len) ---- /dev/null -+++ b/drivers/isdn/hisax/rawhdlc.c -@@ -0,0 +1,543 @@ -+/* $Id: rawhdlc.c,v 1.7 2001/09/24 13:22:57 kai Exp $ -+ * -+ * support routines for cards that don't support HDLC -+ * -+ * Author Brent Baccala -+ * Copyright by Karsten Keil <keil@isdn4linux.de> -+ * by Brent Baccala <baccala@FreeSoft.org> -+ * -+ * This software may be used and distributed according to the terms -+ * of the GNU General Public License, incorporated herein by reference. -+ * -+ * -+ * Some passive ISDN cards, such as the Traverse NETJet and the AMD 7930, -+ * don't perform HDLC encapsulation over the B channel. Drivers for -+ * such cards use support routines in this file to perform B channel HDLC. -+ * -+ * Bit-synchronous HDLC encapsulation is a means of encapsulating packets -+ * over a continuously transmitting serial communications link. -+ * It looks like this: -+ * -+ * 11111111101111110...........0111111011111111111 -+ * iiiiiiiiiffffffffdddddddddddffffffffiiiiiiiiiii -+ * -+ * i = idle f = flag d = data -+ * -+ * When idle, the channel sends a continuous string of ones (mark -+ * idle; illustrated), or a continuous string of flag characters (flag -+ * idle). The beginning of a data frame is marked by a flag character -+ * (01111110), then comes the actual data, followed by another flag -+ * character, after which another frame may be sent immediately (a -+ * single flag may serve as both the end of one frame and the start of -+ * the next), or the link may return to idle. Obviously, the flag -+ * character can not appear anywhere in the data (or a false -+ * end-of-frame would occur), so the transmitter performs -+ * "bit-stuffing" - inserting a zero bit after every five one bits, -+ * irregardless of the original bit after the five ones. Byte -+ * ordering is irrelevent at this point - the data is treated as a -+ * string of bits, not bytes. Since no more than 5 ones may now occur -+ * in a row, the flag sequence, with its 6 ones, is unique. -+ * -+ * Upon reception, a zero bit that occur after 5 one bits is simply -+ * discarded. A series of 6 one bits is end-of-frame, and a series of -+ * 7 one bits is an abort. Once bit-stuffing has been corrected for, -+ * an integer number of bytes should now be present. The last two -+ * of these bytes form the Frame Check Sequence, a CRC that is verified -+ * and then discarded. Note that bit-stuffing is performed on the FCS -+ * just as if it were regular data. -+ * -+ * -+ * -+ * int make_raw_hdlc_data(u_char *src, u_int slen, -+ * u_char *dst, u_int dsize) -+ * -+ * Used for transmission. Copies slen bytes from src to dst, performing -+ * HDLC encapsulation (flag bytes, bit-stuffing, CRC) in the process. -+ * dsize is size of destination buffer, and should be at least -+ * ((6*slen)/5)+5 bytes to ensure adequate space will be available. -+ * Function returns length (in bytes) of valid destination buffer, or -+ * 0 upon destination overflow. -+ * -+ * void init_hdlc_state(struct hdlc_state *stateptr, int mode) -+ * -+ * Initializes hdlc_state structure before first call to read_raw_hdlc_data -+ * -+ * mode = 0: Sane mode -+ * mode = 1/2: -+ * Insane mode; NETJet use a shared unsigned int memory block ( -+ * with busmaster DMA), the bit pattern of every word is -+ * <8 B1> <8 B2> <8 Mon> <2 D> <4 C/I> <MX> <MR> -+ * according to Siemens IOM-2 interface, so we have to handle -+ * the src buffer as unsigned int and have to shift/mask the -+ * B-channel bytes. -+ * mode 1 -> B1 mode 2 -> B2 data is used -+ * -+ * int read_raw_hdlc_data(struct hdlc_state *saved_state, -+ * u_char *src, u_int slen, -+ * u_char *dst, u_int dsize) -+ * -+ * Used for reception. Scans source buffer bit-by-bit looking for -+ * valid HDLC frames, which are copied to destination buffer. HDLC -+ * state information is stored in a structure, which allows this -+ * function to process frames spread across several blocks of raw -+ * HDLC data. Part of the state information is bit offsets into -+ * the source and destination buffers. -+ * -+ * A return value >0 indicates the length of a valid frame, now -+ * stored in the destination buffer. In this case, the source -+ * buffer might not be completely processed, so this function should -+ * be called again with the same source buffer, possibly with a -+ * different destination buffer. -+ * -+ * A return value of zero indicates that the source buffer was -+ * completely processed without finding a valid end-of-packet; -+ * however, we might be in the middle of packet reception, so -+ * the function should be called again with the next block of -+ * raw HDLC data and the same destination buffer. It is NOT -+ * permitted to change the destination buffer in this case, -+ * since data may already have begun to be stored there. -+ * -+ * A return value of -1 indicates some kind of error - destination -+ * buffer overflow, CRC check failed, frame not a multiple of 8 -+ * bits. Destination buffer probably contains invalid data, which -+ * should be discarded. Call function again with same source buffer -+ * and a new (or same) destination buffer. -+ * -+ * Suggested calling sequence: -+ * -+ * init_hdlc_state(...); -+ * for (EACH_RAW_DATA_BLOCK) { -+ * while (len = read_raw_hdlc_data(...)) { -+ * if (len == -1) DISCARD_FRAME; -+ * else PROCESS_FRAME; -+ * } -+ * } -+ * -+ * -+ * Test the code in this file as follows: -+ * gcc -DDEBUGME -o rawhdlctest rawhdlc.c -+ * ./rawhdlctest < rawdata -+ * -+ * The file "rawdata" can be easily generated from a HISAX B-channel -+ * hex dump (CF CF CF 02 ...) using the following perl script: -+ * -+ * while(<>) { -+ * @hexlist = split ' '; -+ * while ($hexstr = shift(@hexlist)) { -+ * printf "%c", hex($hexstr); -+ * } -+ * } -+ * -+ */ -+ -+#ifdef DEBUGME -+#include <stdio.h> -+#endif -+ -+#include <linux/types.h> -+#include <linux/ppp_defs.h> -+#include "rawhdlc.h" -+ -+/* There's actually an identical copy of this table in the PPP code -+ * (ppp_crc16_table), but I don't want this code dependent on PPP -+ */ -+ -+// static -+__u16 fcstab[256] = -+{ -+ 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, -+ 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, -+ 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, -+ 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, -+ 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, -+ 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, -+ 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, -+ 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, -+ 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb, -+ 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, -+ 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, -+ 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, -+ 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, -+ 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, -+ 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, -+ 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, -+ 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, -+ 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff, -+ 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, -+ 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, -+ 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, -+ 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, -+ 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, -+ 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, -+ 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, -+ 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, -+ 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, -+ 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, -+ 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, -+ 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, -+ 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, -+ 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78 -+}; -+ -+#define HDLC_ZERO_SEARCH 0 -+#define HDLC_FLAG_SEARCH 1 -+#define HDLC_FLAG_FOUND 2 -+#define HDLC_FRAME_FOUND 3 -+#define HDLC_NULL 4 -+#define HDLC_PART 5 -+#define HDLC_FULL 6 -+ -+#define HDLC_FLAG_VALUE 0x7e -+ -+ -+#define MAKE_RAW_BYTE for (j=0; j<8; j++) { \ -+ bitcnt++;\ -+ out_val >>= 1;\ -+ if (val & 1) {\ -+ s_one++;\ -+ out_val |= 0x80;\ -+ } else {\ -+ s_one = 0;\ -+ out_val &= 0x7f;\ -+ }\ -+ if (bitcnt==8) {\ -+ if (d_cnt == dsize) return 0;\ -+ dst[d_cnt++] = out_val;\ -+ bitcnt = 0;\ -+ }\ -+ if (s_one == 5) {\ -+ out_val >>= 1;\ -+ out_val &= 0x7f;\ -+ bitcnt++;\ -+ s_one = 0;\ -+ }\ -+ if (bitcnt==8) {\ -+ if (d_cnt == dsize) return 0;\ -+ dst[d_cnt++] = out_val;\ -+ bitcnt = 0;\ -+ }\ -+ val >>= 1;\ -+ } -+ -+/* Optimization suggestion: If needed, this function could be -+ * dramatically sped up using a state machine. Each state would -+ * correspond to having seen N one bits, and being offset M bits into -+ * the current output byte. N ranges from 0 to 4, M from 0 to 7, so -+ * we need 5*8 = 35 states. Each state would have a table with 256 -+ * entries, one for each input character. Each entry would contain -+ * three output characters, an output state, an a byte increment -+ * that's either 1 or 2. All this could fit in four bytes; so we need -+ * 4 bytes * 256 characters = 1 KB for each state (35 KB total). Zero -+ * the output buffer before you start. For each character in your -+ * input, you look it up in the current state's table and get three -+ * bytes to be or'ed into the output at the current byte offset, and -+ * an byte increment to move your pointer forward. A simple Perl -+ * script could generate the tables. Given HDLC semantics, probably -+ * would be better to set output to all 1s, then use ands instead of ors. -+ * A smaller state machine could operate on nibbles instead of bytes. -+ * A state machine for 32-bit architectures could use word offsets -+ * instead of byte offsets, requiring 5*32 = 160 states; probably -+ * best to work on nibbles in such a case. -+ */ -+ -+ -+int make_raw_hdlc_data(u_char *src, u_int slen, u_char *dst, u_int dsize) -+{ -+ register u_int i,d_cnt=0; -+ register u_char j; -+ register u_char val; -+ register u_char s_one = 0; -+ register u_char out_val = 0; -+ register u_char bitcnt = 0; -+ u_int fcs; -+ -+ -+ dst[d_cnt++] = HDLC_FLAG_VALUE; -+ fcs = PPP_INITFCS; -+ for (i=0; i<slen; i++) { -+ val = src[i]; -+ fcs = PPP_FCS (fcs, val); -+ MAKE_RAW_BYTE; -+ } -+ fcs ^= 0xffff; -+ val = fcs & 0xff; -+ MAKE_RAW_BYTE; -+ val = (fcs>>8) & 0xff; -+ MAKE_RAW_BYTE; -+ val = HDLC_FLAG_VALUE; -+ for (j=0; j<8; j++) { -+ bitcnt++; -+ out_val >>= 1; -+ if (val & 1) -+ out_val |= 0x80; -+ else -+ out_val &= 0x7f; -+ if (bitcnt==8) { -+ if (d_cnt == dsize) return 0; -+ dst[d_cnt++] = out_val; -+ bitcnt = 0; -+ } -+ val >>= 1; -+ } -+ if (bitcnt) { -+ while (8>bitcnt++) { -+ out_val >>= 1; -+ out_val |= 0x80; -+ } -+ if (d_cnt == dsize) return 0; -+ dst[d_cnt++] = out_val; -+ } -+ -+ return d_cnt; -+} -+ -+void init_hdlc_state(struct hdlc_state *stateptr, int mode) -+{ -+ stateptr->state = HDLC_ZERO_SEARCH; -+ stateptr->r_one = 0; -+ stateptr->r_val = 0; -+ stateptr->o_bitcnt = 0; -+ stateptr->i_bitcnt = 0; -+ stateptr->insane_mode = mode; -+} -+ -+/* Optimization suggestion: A similar state machine could surely -+ * be developed for this function as well. -+ */ -+ -+int read_raw_hdlc_data(struct hdlc_state *saved_state, -+ u_char *src, u_int slen, u_char *dst, u_int dsize) -+{ -+ int retval=0; -+ register u_char val; -+ register u_char state = saved_state->state; -+ register u_char r_one = saved_state->r_one; -+ register u_char r_val = saved_state->r_val; -+ register u_int o_bitcnt = saved_state->o_bitcnt; -+ register u_int i_bitcnt = saved_state->i_bitcnt; -+ register u_int fcs = saved_state->fcs; -+ register u_int *isrc = (u_int *) src; -+ -+ /* Use i_bitcnt (bit offset into source buffer) to reload "val" -+ * in case we're starting up again partway through a source buffer -+ */ -+ -+ if ((i_bitcnt >> 3) < slen) { -+ if (saved_state->insane_mode==1) { -+ val = isrc[(i_bitcnt >> 3)] & 0xff; -+ } else if (saved_state->insane_mode==2) { -+ val = (isrc[i_bitcnt >> 3] >>8) & 0xff; -+ } else { -+ val = src[i_bitcnt >> 3]; -+ } -+ val >>= i_bitcnt & 7; -+ } -+ -+ /* One bit per loop. Keep going until we've got something to -+ * report (retval != 0), or we exhaust the source buffer -+ */ -+ -+ while ((retval == 0) && ((i_bitcnt >> 3) < slen)) { -+ if ((i_bitcnt & 7) == 0) { -+ if (saved_state->insane_mode==1) { -+ val = isrc[(i_bitcnt >> 3)] & 0xff; -+ } else if (saved_state->insane_mode==2) { -+ val = (isrc[i_bitcnt >> 3] >>8) & 0xff; -+ } else { -+ val = src[i_bitcnt >> 3]; -+ } -+#ifdef DEBUGME -+ printf("Input byte %d: 0x%2x\n", i_bitcnt>>3, val); -+#endif -+ if (val == 0xff) { -+ state = HDLC_ZERO_SEARCH; -+ o_bitcnt = 0; -+ r_one = 0; -+ i_bitcnt += 8; -+ continue; -+ } -+ } -+ -+#ifdef DEBUGME -+ /* printf("Data bit=%d (%d/%d)\n", val&1, i_bitcnt>>3, i_bitcnt&7);*/ -+#endif -+ -+ if (state == HDLC_ZERO_SEARCH) { -+ if (val & 1) { -+ r_one++; -+ } else { -+ r_one=0; -+ state= HDLC_FLAG_SEARCH; -+ } -+ } else if (state == HDLC_FLAG_SEARCH) { -+ if (val & 1) { -+ r_one++; -+ if (r_one>6) { -+ state=HDLC_ZERO_SEARCH; -+ } -+ } else { -+ if (r_one==6) { -+ o_bitcnt=0; -+ r_val=0; -+ state=HDLC_FLAG_FOUND; -+ } -+ r_one=0; -+ } -+ } else if (state == HDLC_FLAG_FOUND) { -+ if (val & 1) { -+ r_one++; -+ if (r_one>6) { -+ state=HDLC_ZERO_SEARCH; -+ } else { -+ r_val >>= 1; -+ r_val |= 0x80; -+ o_bitcnt++; -+ } -+ } else { -+ if (r_one==6) { -+ o_bitcnt=0; -+ r_val=0; -+ r_one=0; -+ i_bitcnt++; -+ val >>= 1; -+ continue; -+ } else if (r_one!=5) { -+ r_val >>= 1; -+ r_val &= 0x7f; -+ o_bitcnt++; -+ } -+ r_one=0; -+ } -+ if ((state != HDLC_ZERO_SEARCH) && -+ !(o_bitcnt & 7)) { -+#ifdef DEBUGME -+ printf("HDLC_FRAME_FOUND at i_bitcnt:%d\n",i_bitcnt); -+#endif -+ state=HDLC_FRAME_FOUND; -+ fcs = PPP_INITFCS; -+ dst[0] = r_val; -+ fcs = PPP_FCS (fcs, r_val); -+ } -+ } else if (state == HDLC_FRAME_FOUND) { -+ if (val & 1) { -+ r_one++; -+ if (r_one>6) { -+ state=HDLC_ZERO_SEARCH; -+ o_bitcnt=0; -+ } else { -+ r_val >>= 1; -+ r_val |= 0x80; -+ o_bitcnt++; -+ } -+ } else { -+ if (r_one==6) { -+ r_val=0; -+ r_one=0; -+ o_bitcnt++; -+ if (o_bitcnt & 7) { -+ /* Alignment error */ -+#ifdef DEBUGME -+ printf("Alignment error\n"); -+#endif -+ state=HDLC_FLAG_SEARCH; -+ retval = -1; -+ } else if (fcs==PPP_GOODFCS) { -+ /* Valid frame */ -+ state=HDLC_FLAG_FOUND; -+ retval = (o_bitcnt>>3)-3; -+ } else { -+ /* CRC error */ -+#ifdef DEBUGME -+ printf("CRC error; fcs was 0x%x, should have been 0x%x\n", fcs, PPP_GOODFCS); -+#endif -+ state=HDLC_FLAG_FOUND; -+ retval = -1; -+ } -+ } else if (r_one==5) { -+ r_one=0; -+ i_bitcnt++; -+ val >>= 1; -+ continue; -+ } else { -+ r_val >>= 1; -+ r_val &= 0x7f; -+ o_bitcnt++; -+ } -+ r_one=0; -+ } -+ if ((state == HDLC_FRAME_FOUND) && -+ !(o_bitcnt & 7)) { -+ if ((o_bitcnt>>3)>=dsize) { -+ /* Buffer overflow error */ -+#ifdef DEBUGME -+ printf("Buffer overflow error\n"); -+#endif -+ r_val=0; -+ state=HDLC_FLAG_SEARCH; -+ retval = -1; -+ } else { -+ dst[(o_bitcnt>>3)-1] = r_val; -+ fcs = PPP_FCS (fcs, r_val); -+#ifdef DEBUGME -+ printf("Output byte %d: 0x%02x; FCS 0x%04x\n", (o_bitcnt>>3)-1, r_val, fcs); -+#endif -+ } -+ } -+ } -+ i_bitcnt ++; -+ val >>= 1; -+ } -+ -+ /* We exhausted the source buffer before anything else happened -+ * (retval==0). Reset i_bitcnt in expectation of a new source -+ * buffer. Other, we either had an error or a valid frame, so -+ * reset o_bitcnt in expectation of a new destination buffer. -+ */ -+ -+ if (retval == 0) { -+ i_bitcnt = 0; -+ } else { -+ o_bitcnt = 0; -+ } -+ -+ saved_state->state = state; -+ saved_state->r_one = r_one; -+ saved_state->r_val = r_val; -+ saved_state->fcs = fcs; -+ saved_state->o_bitcnt = o_bitcnt; -+ saved_state->i_bitcnt = i_bitcnt; -+ -+ return (retval); -+} -+ -+ -+ -+#ifdef DEBUGME -+ -+char buffer[1024]; -+char obuffer[1024]; -+ -+main() -+{ -+ int buflen=0; -+ int len; -+ struct hdlc_state hdlc_state; -+ -+ while((buffer[buflen] = getc(stdin)) != EOF && buflen<1024) buflen++; -+ -+ printf("buflen = %d\n", buflen); -+ -+ init_hdlc_state(&hdlc_state, 0); -+ -+ while (len = read_raw_hdlc_data(&hdlc_state,buffer,buflen,obuffer,1024)) { -+ if (len == -1) printf("Error @ byte %d/bit %d\n", -+ hdlc_state.i_bitcnt>>3, hdlc_state.i_bitcnt & 7); -+ else { -+ printf("Frame received: len %d\n", len); -+ } -+ } -+ -+ printf("Done\n"); -+} -+ -+#endif ---- /dev/null -+++ b/drivers/isdn/hisax/rawhdlc.h -@@ -0,0 +1,28 @@ -+/* $Id: rawhdlc.h,v 1.5 2001/09/24 13:22:57 kai Exp $ -+ * -+ * Author Brent Baccala -+ * Copyright by Brent Baccala <baccala@FreeSoft.org> -+ * -+ * This software may be used and distributed according to the terms -+ * of the GNU General Public License, incorporated herein by reference. -+ * -+ */ -+ -+#ifndef RAWHDLC_H -+struct hdlc_state { -+ char insane_mode; -+ u_char state; -+ u_char r_one; -+ u_char r_val; -+ u_int o_bitcnt; -+ u_int i_bitcnt; -+ u_int fcs; -+}; -+ -+ -+int make_raw_hdlc_data(u_char *src, u_int slen, u_char *dst, u_int dsize); -+void init_hdlc_state(struct hdlc_state *stateptr, int mode); -+int read_raw_hdlc_data(struct hdlc_state *saved_state, -+ u_char *src, u_int slen, u_char *dst, u_int dsize); -+#define RAWHDLC_H -+#endif ---- a/drivers/isdn/hisax/s0box.c -+++ b/drivers/isdn/hisax/s0box.c -@@ -1,4 +1,4 @@ --/* $Id: s0box.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: s0box.c,v 2.6 2001/09/24 13:22:57 kai Exp $ - * - * low level stuff for Creatix S0BOX - * -@@ -18,7 +18,7 @@ - #include "isdnl1.h" - - extern const char *CardType[]; --const char *s0box_revision = "$Revision: 1.1.4.1 $"; -+const char *s0box_revision = "$Revision: 2.6 $"; - - static inline void - writereg(unsigned int padr, signed int addr, u_char off, u_char val) { ---- a/drivers/isdn/hisax/saphir.c -+++ b/drivers/isdn/hisax/saphir.c -@@ -1,4 +1,4 @@ --/* $Id: saphir.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: saphir.c,v 1.10 2001/09/24 13:22:57 kai Exp $ - * - * low level stuff for HST Saphir 1 - * -@@ -20,7 +20,7 @@ - #include "isdnl1.h" - - extern const char *CardType[]; --static char *saphir_rev = "$Revision: 1.1.4.1 $"; -+static char *saphir_rev = "$Revision: 1.10 $"; - - #define byteout(addr,val) outb(val,addr) - #define bytein(addr) inb(addr) ---- a/drivers/isdn/hisax/sedlbauer.c -+++ b/drivers/isdn/hisax/sedlbauer.c -@@ -1,4 +1,4 @@ --/* $Id: sedlbauer.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: sedlbauer.c,v 1.34 2002/02/09 21:00:57 keil Exp $ - * - * low level stuff for Sedlbauer cards - * includes support for the Sedlbauer speed star (speed star II), -@@ -48,18 +48,19 @@ - #include "isar.h" - #include "isdnl1.h" - #include <linux/pci.h> --#include <linux/isapnp.h> -+#include <linux/isdn_compat.h> - - extern const char *CardType[]; - --const char *Sedlbauer_revision = "$Revision: 1.1.4.1 $"; -+const char *Sedlbauer_revision = "$Revision: 1.34 $"; - - const char *Sedlbauer_Types[] = - {"None", "speed card/win", "speed star", "speed fax+", - "speed win II / ISDN PC/104", "speed star II", "speed pci", -- "speed fax+ pyramid", "speed fax+ pci"}; -+ "speed fax+ pyramid", "speed fax+ pci", "HST Saphir III"}; - - #define PCI_SUBVENDOR_SPEEDFAX_PYRAMID 0x51 -+#define PCI_SUBVENDOR_HST_SAPHIR3 0x52 - #define PCI_SUBVENDOR_SEDLBAUER_PCI 0x53 - #define PCI_SUBVENDOR_SPEEDFAX_PCI 0x54 - #define PCI_SUB_ID_SEDLBAUER 0x01 -@@ -72,6 +73,7 @@ const char *Sedlbauer_Types[] = - #define SEDL_SPEED_PCI 6 - #define SEDL_SPEEDFAX_PYRAMID 7 - #define SEDL_SPEEDFAX_PCI 8 -+#define HST_SAPHIR3 9 - - #define SEDL_CHIP_TEST 0 - #define SEDL_CHIP_ISAC_HSCX 1 -@@ -531,21 +533,6 @@ Sedl_card_msg(struct IsdnCardState *cs, - - static struct pci_dev *dev_sedl __devinitdata = NULL; - --#ifdef __ISAPNP__ --static struct isapnp_device_id sedl_ids[] __initdata = { -- { ISAPNP_VENDOR('S', 'A', 'G'), ISAPNP_FUNCTION(0x01), -- ISAPNP_VENDOR('S', 'A', 'G'), ISAPNP_FUNCTION(0x01), -- (unsigned long) "Speed win" }, -- { ISAPNP_VENDOR('S', 'A', 'G'), ISAPNP_FUNCTION(0x02), -- ISAPNP_VENDOR('S', 'A', 'G'), ISAPNP_FUNCTION(0x02), -- (unsigned long) "Speed Fax+" }, -- { 0, } --}; -- --static struct isapnp_device_id *pdev = &sedl_ids[0]; --static struct pci_bus *pnp_c __devinitdata = NULL; --#endif -- - int __devinit - setup_sedlbauer(struct IsdnCard *card) - { -@@ -581,57 +568,6 @@ setup_sedlbauer(struct IsdnCard *card) - bytecnt = 16; - } - } else { --#ifdef __ISAPNP__ -- if (isapnp_present()) { -- struct pci_bus *pb; -- struct pci_dev *pd; -- -- while(pdev->card_vendor) { -- if ((pb = isapnp_find_card(pdev->card_vendor, -- pdev->card_device, pnp_c))) { -- pnp_c = pb; -- pd = NULL; -- if ((pd = isapnp_find_dev(pnp_c, -- pdev->vendor, pdev->function, pd))) { -- printk(KERN_INFO "HiSax: %s detected\n", -- (char *)pdev->driver_data); -- pd->prepare(pd); -- pd->deactivate(pd); -- pd->activate(pd); -- card->para[1] = -- pd->resource[0].start; -- card->para[0] = -- pd->irq_resource[0].start; -- if (!card->para[0] || !card->para[1]) { -- printk(KERN_ERR "Sedlbauer PnP:some resources are missing %ld/%lx\n", -- card->para[0], card->para[1]); -- pd->deactivate(pd); -- return(0); -- } -- cs->hw.sedl.cfg_reg = card->para[1]; -- cs->irq = card->para[0]; -- if (pdev->function == ISAPNP_FUNCTION(0x2)) { -- cs->subtyp = SEDL_SPEED_FAX; -- cs->hw.sedl.chip = SEDL_CHIP_ISAC_ISAR; -- bytecnt = 16; -- } else { -- cs->subtyp = SEDL_SPEED_CARD_WIN; -- cs->hw.sedl.chip = SEDL_CHIP_TEST; -- } -- goto ready; -- } else { -- printk(KERN_ERR "Sedlbauer PnP: PnP error card found, no device\n"); -- return(0); -- } -- } -- pdev++; -- pnp_c=NULL; -- } -- if (!pdev->card_vendor) { -- printk(KERN_INFO "Sedlbauer PnP: no ISAPnP card found\n"); -- } -- } --#endif - /* Probe for Sedlbauer speed pci */ - #if CONFIG_PCI - if (!pci_present()) { -@@ -647,15 +583,15 @@ setup_sedlbauer(struct IsdnCard *card) - printk(KERN_WARNING "Sedlbauer: No IRQ for PCI card found\n"); - return(0); - } -- cs->hw.sedl.cfg_reg = pci_resource_start(dev_sedl, 0); -+ cs->hw.sedl.cfg_reg = pci_resource_start_io(dev_sedl, 0); - } else { - printk(KERN_WARNING "Sedlbauer: No PCI card found\n"); - return(0); - } - cs->irq_flags |= SA_SHIRQ; - cs->hw.sedl.bus = SEDL_BUS_PCI; -- sub_vendor_id = dev_sedl->subsystem_vendor; -- sub_id = dev_sedl->subsystem_device; -+ pci_get_sub_vendor(dev_sedl,sub_vendor_id); -+ pci_get_sub_system(dev_sedl,sub_id); - printk(KERN_INFO "Sedlbauer: PCI subvendor:%x subid %x\n", - sub_vendor_id, sub_id); - printk(KERN_INFO "Sedlbauer: PCI base adr %#x\n", -@@ -670,6 +606,9 @@ setup_sedlbauer(struct IsdnCard *card) - } else if (sub_vendor_id == PCI_SUBVENDOR_SPEEDFAX_PCI) { - cs->hw.sedl.chip = SEDL_CHIP_ISAC_ISAR; - cs->subtyp = SEDL_SPEEDFAX_PCI; -+ } else if (sub_vendor_id == PCI_SUBVENDOR_HST_SAPHIR3) { -+ cs->hw.sedl.chip = SEDL_CHIP_IPAC; -+ cs->subtyp = HST_SAPHIR3; - } else if (sub_vendor_id == PCI_SUBVENDOR_SEDLBAUER_PCI) { - cs->hw.sedl.chip = SEDL_CHIP_IPAC; - cs->subtyp = SEDL_SPEED_PCI; -@@ -683,8 +622,8 @@ setup_sedlbauer(struct IsdnCard *card) - cs->hw.sedl.reset_off = SEDL_ISAR_PCI_ISAR_RESET_OFF; - byteout(cs->hw.sedl.cfg_reg, 0xff); - byteout(cs->hw.sedl.cfg_reg, 0x00); -- byteout(cs->hw.sedl.cfg_reg+ 2, 0xdd); -- byteout(cs->hw.sedl.cfg_reg+ 5, 0x02); -+ byteout(cs->hw.sedl.cfg_reg +2, 0xdd); -+ byteout(cs->hw.sedl.cfg_reg +5, 0x02); - byteout(cs->hw.sedl.cfg_reg +3, cs->hw.sedl.reset_on); - save_flags(flags); - sti(); -@@ -697,7 +636,7 @@ setup_sedlbauer(struct IsdnCard *card) - return (0); - #endif /* CONFIG_PCI */ - } --ready: -+ - /* In case of the sedlbauer pcmcia card, this region is in use, - * reserved for us by the card manager. So we do not check it - * here, it would fail. ---- a/drivers/isdn/hisax/sportster.c -+++ b/drivers/isdn/hisax/sportster.c -@@ -1,4 +1,4 @@ --/* $Id: sportster.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: sportster.c,v 1.16 2001/09/24 13:22:57 kai Exp $ - * - * low level stuff for USR Sportster internal TA - * -@@ -20,7 +20,7 @@ - #include "isdnl1.h" - - extern const char *CardType[]; --const char *sportster_revision = "$Revision: 1.1.4.1 $"; -+const char *sportster_revision = "$Revision: 1.16 $"; - - #define byteout(addr,val) outb(val,addr) - #define bytein(addr) inb(addr) ---- /dev/null -+++ b/drivers/isdn/hisax/st5481-debug.h -@@ -0,0 +1,103 @@ -+#define ST5481_DEBUG 0x0 -+ -+#if ST5481_DEBUG -+ -+ -+/* -+ DEBUG flags. Set compile option ST5481_DEBUG with the following bits set to trace -+ the given subsections: -+ -+ 0x01: USB -+ 0x02: D -+ 0x04: B -+ 0x08: PH -+ 0x10: PACKET_DUMP D out -+ 0x20: ISO_DUMP D out -+ 0x40: PACKET_DUMP D in -+ 0x80: ISO_DUMP in -+ 0x100: PACKET_DUMP B out -+ 0x200: ISO_DUMP B out -+ 0x400: PACKET_DUMP B in -+*/ -+ -+#define DBG(level, format, arg...) \ -+if (level & ST5481_DEBUG) \ -+printk(KERN_DEBUG __FUNCTION__ ": " format "\n" , ## arg) \ -+ -+static inline void -+dump_packet(const char *name,const u_char *data,int pkt_len) -+{ -+#define DUMP_HDR_SIZE 200 -+#define DUMP_TLR_SIZE 8 -+ if (pkt_len) { -+ int i,len1,len2; -+ -+ printk(KERN_DEBUG "%s: length=%d,data=",name,pkt_len); -+ -+ if (pkt_len > DUMP_HDR_SIZE+ DUMP_TLR_SIZE) { -+ len1 = DUMP_HDR_SIZE; -+ len2 = DUMP_TLR_SIZE; -+ } else { -+ len1 = pkt_len > DUMP_HDR_SIZE ? DUMP_HDR_SIZE : pkt_len; -+ len2 = 0; -+ } -+ for (i = 0; i < len1; ++i) { -+ printk ("%.2x", data[i]); -+ } -+ if (len2) { -+ printk (".."); -+ for (i = pkt_len-DUMP_TLR_SIZE; i < pkt_len; ++i) { -+ printk ("%.2x", data[i]); -+ } -+ } -+ printk ("\n"); -+ } -+#undef DUMP_HDR_SIZE -+#undef DUMP_TLR_SIZE -+} -+ -+static inline void -+dump_iso_packet(const char *name,urb_t *urb) -+{ -+ int i,j; -+ int len,ofs; -+ u_char *data; -+ -+ printk(KERN_DEBUG "%s: packets=%d,errors=%d\n", -+ name,urb->number_of_packets,urb->error_count); -+ for (i = 0; i < urb->number_of_packets; ++i) { -+ if (urb->pipe & USB_DIR_IN) { -+ len = urb->iso_frame_desc[i].actual_length; -+ } else { -+ len = urb->iso_frame_desc[i].length; -+ } -+ ofs = urb->iso_frame_desc[i].offset; -+ printk(KERN_DEBUG "len=%.2d,ofs=%.3d ",len,ofs); -+ if (len) { -+ data = urb->transfer_buffer+ofs; -+ for (j=0; j < len; j++) { -+ printk ("%.2x", data[j]); -+ } -+ } -+ printk("\n"); -+ } -+} -+ -+#define DUMP_PACKET(level,data,count) \ -+ if (level & ST5481_DEBUG) dump_packet(__FUNCTION__,data,count) -+#define DUMP_SKB(level,skb) \ -+ if ((level & ST5481_DEBUG) && skb) dump_packet(__FUNCTION__,skb->data,skb->len) -+#define DUMP_ISO_PACKET(level,urb) \ -+ if (level & ST5481_DEBUG) dump_iso_packet(__FUNCTION__,urb) -+ -+#else -+ -+#define DBG(level,format, arg...) do {} while (0) -+#define DUMP_PACKET(level,data,count) do {} while (0) -+#define DUMP_SKB(level,skb) do {} while (0) -+#define DUMP_ISO_PACKET(level,urb) do {} while (0) -+ -+#endif -+ -+ -+ ---- a/drivers/isdn/hisax/st5481.h -+++ b/drivers/isdn/hisax/st5481.h -@@ -219,15 +219,15 @@ enum { - #define L1_EVENT_COUNT (EV_TIMER3 + 1) - - #define ERR(format, arg...) \ --printk(KERN_ERR "%s:%s: " format "\n" , __FILE__, __FUNCTION__ , ## arg) -+printk(KERN_ERR __FILE__ ": " __FUNCTION__ ": " format "\n" , ## arg) - - #define WARN(format, arg...) \ --printk(KERN_WARNING "%s:%s: " format "\n" , __FILE__, __FUNCTION__ , ## arg) -+printk(KERN_WARNING __FILE__ ": " __FUNCTION__ ": " format "\n" , ## arg) - - #define INFO(format, arg...) \ --printk(KERN_INFO "%s:%s: " format "\n" , __FILE__, __FUNCTION__ , ## arg) -+printk(KERN_INFO __FILE__ ": " __FUNCTION__ ": " format "\n" , ## arg) - --#include "isdnhdlc.h" -+#include "st5481_hdlc.h" - #include "fsm.h" - #include "hisax_if.h" - #include <linux/skbuff.h> -@@ -236,7 +236,7 @@ printk(KERN_INFO "%s:%s: " format "\n" , - * FIFO handling - */ - --/* Generic FIFO structure */ -+/* Generic FIFO structure */ - struct fifo { - u_char r,w,count,size; - spinlock_t lock; -@@ -270,7 +270,7 @@ static inline int fifo_add(struct fifo * - index = -1; - } else { - // Return index where to get the next data to add to the FIFO -- index = fifo->w++ & (fifo->size-1); -+ index = fifo->w++ & (fifo->size-1); - fifo->count++; - } - spin_unlock_irqrestore(&fifo->lock, flags); -@@ -289,13 +289,13 @@ static inline int fifo_remove(struct fif - return -1; - } - -- spin_lock_irqsave(&fifo->lock, flags); -+ spin_lock_irqsave(&fifo->lock, flags); - if (!fifo->count) { - // FIFO empty - index = -1; - } else { - // Return index where to get the next data from the FIFO -- index = fifo->r++ & (fifo->size-1); -+ index = fifo->r++ & (fifo->size-1); - fifo->count--; - } - spin_unlock_irqrestore(&fifo->lock, flags); -@@ -309,7 +309,7 @@ static inline int fifo_remove(struct fif - typedef void (*ctrl_complete_t)(void *); - - typedef struct ctrl_msg { -- struct usb_ctrlrequest dr; -+ devrequest dr; - ctrl_complete_t complete; - void *context; - } ctrl_msg; -@@ -336,7 +336,7 @@ struct st5481_intr { - }; - - struct st5481_d_out { -- struct isdnhdlc_vars hdlc_state; -+ struct hdlc_vars hdlc_state; - struct urb *urb[2]; /* double buffering */ - unsigned long busy; - struct sk_buff *tx_skb; -@@ -344,7 +344,7 @@ struct st5481_d_out { - }; - - struct st5481_b_out { -- struct isdnhdlc_vars hdlc_state; -+ struct hdlc_vars hdlc_state; - struct urb *urb[2]; /* double buffering */ - u_char flow_event; - u_long busy; -@@ -352,7 +352,7 @@ struct st5481_b_out { - }; - - struct st5481_in { -- struct isdnhdlc_vars hdlc_state; -+ struct hdlc_vars hdlc_state; - struct urb *urb[2]; /* double buffering */ - int mode; - int bufsize; -@@ -478,7 +478,7 @@ extern int st5481_debug; - if (level & __debug_variable) dump_iso_packet(__FUNCTION__,urb) - - static void __attribute__((unused)) --dump_iso_packet(const char *name,struct urb *urb) -+dump_iso_packet(const char *name,urb_t *urb) - { - int i,j; - int len,ofs; ---- a/drivers/isdn/hisax/st5481_b.c -+++ b/drivers/isdn/hisax/st5481_b.c -@@ -67,28 +67,24 @@ static void usb_b_out(struct st5481_bcs - bytes_sent = buf_size - len; - if (skb->len < bytes_sent) - bytes_sent = skb->len; -- { /* swap tx bytes to get hearable audio data */ -- register unsigned char *src = skb->data; -- register unsigned char *dest = urb->transfer_buffer+len; -- register unsigned int count; -- for (count = 0; count < bytes_sent; count++) -- *dest++ = isdnhdlc_bit_rev_tab[*src++]; -- } -+ -+ memcpy(urb->transfer_buffer+len, skb->data, bytes_sent); -+ - len += bytes_sent; - } else { -- len += isdnhdlc_encode(&b_out->hdlc_state, -- skb->data, skb->len, &bytes_sent, -- urb->transfer_buffer+len, buf_size-len); -+ len += hdlc_encode(&b_out->hdlc_state, -+ skb->data, skb->len, &bytes_sent, -+ urb->transfer_buffer+len, buf_size-len); - } - - skb_pull(skb, bytes_sent); -- -+ - if (!skb->len) { - // Frame sent - b_out->tx_skb = NULL; - B_L1L2(bcs, PH_DATA | CONFIRM, (void *) skb->truesize); - dev_kfree_skb_any(skb); -- -+ - /* if (!(bcs->tx_skb = skb_dequeue(&bcs->sq))) { */ - /* st5481B_sched_event(bcs, B_XMTBUFREADY); */ - /* } */ -@@ -99,9 +95,9 @@ static void usb_b_out(struct st5481_bcs - len = buf_size; - } else { - // Send flags -- len += isdnhdlc_encode(&b_out->hdlc_state, -- NULL, 0, &bytes_sent, -- urb->transfer_buffer+len, buf_size-len); -+ len += hdlc_encode(&b_out->hdlc_state, -+ NULL, 0, &bytes_sent, -+ urb->transfer_buffer+len, buf_size-len); - } - } - } -@@ -213,7 +209,7 @@ static void st5481B_mode(struct st5481_b - if (bcs->mode != L1_MODE_NULL) { - // Open the B channel - if (bcs->mode != L1_MODE_TRANS) { -- isdnhdlc_out_init(&b_out->hdlc_state, 0, bcs->mode == L1_MODE_HDLC_56K); -+ hdlc_out_init(&b_out->hdlc_state, 0, bcs->mode == L1_MODE_HDLC_56K); - } - st5481_usb_pipe_reset(adapter, (bcs->channel+1)*2, NULL, NULL); - -@@ -279,7 +275,7 @@ static int __devinit st5481_setup_b_out( - usb_b_out_complete, bcs); - } - --static void st5481_release_b_out(struct st5481_bcs *bcs) -+static void __devexit st5481_release_b_out(struct st5481_bcs *bcs) - { - struct st5481_b_out *b_out = &bcs->b_out; - -@@ -320,7 +316,7 @@ int __devinit st5481_setup_b(struct st54 - /* - * Release buffers and URBs for the B channels - */ --void st5481_release_b(struct st5481_bcs *bcs) -+void __devexit st5481_release_b(struct st5481_bcs *bcs) - { - DBG(4,""); - ---- a/drivers/isdn/hisax/st5481_d.c -+++ b/drivers/isdn/hisax/st5481_d.c -@@ -162,8 +162,8 @@ static struct FsmNode L1FnList[] __initd - {ST_L1_F8, EV_TIMER3, l1_timer3}, - {ST_L1_F8, EV_IND_DP, l1_go_f3}, - {ST_L1_F8, EV_IND_AP, l1_go_f6}, -- {ST_L1_F8, EV_IND_AI8, l1_go_f7}, -- {ST_L1_F8, EV_IND_AI10, l1_go_f7}, -+ {ST_L1_F8, EV_IND_AI8, l1_go_f8}, -+ {ST_L1_F8, EV_IND_AI10, l1_go_f8}, - {ST_L1_F8, EV_IND_RSY, l1_ignore}, - }; - -@@ -297,7 +297,7 @@ static void usb_d_out(struct st5481_adap - unsigned int num_packets, packet_offset; - int len, buf_size, bytes_sent; - struct sk_buff *skb; -- struct iso_packet_descriptor *desc; -+ iso_packet_descriptor_t *desc; - - if (d_out->fsm.state != ST_DOUT_NORMAL) - return; -@@ -313,15 +313,15 @@ static void usb_d_out(struct st5481_adap - buf_size = NUM_ISO_PACKETS_D * SIZE_ISO_PACKETS_D_OUT; - - if (skb) { -- len = isdnhdlc_encode(&d_out->hdlc_state, -- skb->data, skb->len, &bytes_sent, -- urb->transfer_buffer, buf_size); -+ len = hdlc_encode(&d_out->hdlc_state, -+ skb->data, skb->len, &bytes_sent, -+ urb->transfer_buffer, buf_size); - skb_pull(skb,bytes_sent); - } else { - // Send flags or idle -- len = isdnhdlc_encode(&d_out->hdlc_state, -- NULL, 0, &bytes_sent, -- urb->transfer_buffer, buf_size); -+ len = hdlc_encode(&d_out->hdlc_state, -+ NULL, 0, &bytes_sent, -+ urb->transfer_buffer, buf_size); - } - - if (len < buf_size) { -@@ -413,7 +413,7 @@ static void dout_start_xmit(struct FsmIn - - DBG(2,"len=%d",skb->len); - -- isdnhdlc_out_init(&d_out->hdlc_state, 1, 0); -+ hdlc_out_init(&d_out->hdlc_state, 1, 0); - - if (test_and_set_bit(buf_nr, &d_out->busy)) { - WARN("ep %d urb %d busy %#lx", EP_D_OUT, buf_nr, d_out->busy); -@@ -422,9 +422,9 @@ static void dout_start_xmit(struct FsmIn - urb = d_out->urb[buf_nr]; - - DBG_SKB(0x10, skb); -- len = isdnhdlc_encode(&d_out->hdlc_state, -- skb->data, skb->len, &bytes_sent, -- urb->transfer_buffer, 16); -+ len = hdlc_encode(&d_out->hdlc_state, -+ skb->data, skb->len, &bytes_sent, -+ urb->transfer_buffer, 16); - skb_pull(skb, bytes_sent); - - if(len < 16) -@@ -673,7 +673,7 @@ static int __devinit st5481_setup_d_out( - usb_d_out_complete, adapter); - } - --static void st5481_release_d_out(struct st5481_adapter *adapter) -+static void __devexit st5481_release_d_out(struct st5481_adapter *adapter) - { - struct st5481_d_out *d_out = &adapter->d_out; - -@@ -723,7 +723,7 @@ int __devinit st5481_setup_d(struct st54 - return retval; - } - --void st5481_release_d(struct st5481_adapter *adapter) -+void __devexit st5481_release_d(struct st5481_adapter *adapter) - { - DBG(2,""); - ---- a/drivers/isdn/hisax/st5481_init.c -+++ b/drivers/isdn/hisax/st5481_init.c -@@ -14,6 +14,7 @@ - * TODO: - * - * b layer1 delay? -+ * hdlc as module - * hotplug / unregister issues - * mod_inc/dec_use_count - * unify parts of d/b channel usb handling -@@ -177,7 +178,7 @@ MODULE_DEVICE_TABLE (usb, st5481_ids); - static struct usb_driver st5481_usb_driver = { - name: "st5481_usb", - probe: probe_st5481, -- disconnect: __devexit_p(disconnect_st5481), -+ disconnect: disconnect_st5481, - id_table: st5481_ids, - }; - ---- a/drivers/isdn/hisax/st5481_usb.c -+++ b/drivers/isdn/hisax/st5481_usb.c -@@ -41,9 +41,9 @@ static void usb_next_ctrl_msg(struct urb - (unsigned char *)&ctrl->msg_fifo.data[r_index]; - - DBG(1,"request=0x%02x,value=0x%04x,index=%x", -- ((struct ctrl_msg *)urb->setup_packet)->dr.bRequest, -- ((struct ctrl_msg *)urb->setup_packet)->dr.wValue, -- ((struct ctrl_msg *)urb->setup_packet)->dr.wIndex); -+ ((struct ctrl_msg *)urb->setup_packet)->dr.request, -+ ((struct ctrl_msg *)urb->setup_packet)->dr.value, -+ ((struct ctrl_msg *)urb->setup_packet)->dr.index); - - // Prepare the URB - urb->dev = adapter->usb_dev; -@@ -69,11 +69,11 @@ void usb_ctrl_msg(struct st5481_adapter - } - ctrl_msg = &ctrl->msg_fifo.data[w_index]; - -- ctrl_msg->dr.bRequestType = requesttype; -- ctrl_msg->dr.bRequest = request; -- ctrl_msg->dr.wValue = cpu_to_le16p(&value); -- ctrl_msg->dr.wIndex = cpu_to_le16p(&index); -- ctrl_msg->dr.wLength = 0; -+ ctrl_msg->dr.requesttype = requesttype; -+ ctrl_msg->dr.request = request; -+ ctrl_msg->dr.value = cpu_to_le16p(&value); -+ ctrl_msg->dr.index = cpu_to_le16p(&index); -+ ctrl_msg->dr.length = 0; - ctrl_msg->complete = complete; - ctrl_msg->context = context; - -@@ -140,17 +140,17 @@ static void usb_ctrl_complete(struct urb - - ctrl_msg = (struct ctrl_msg *)urb->setup_packet; - -- if (ctrl_msg->dr.bRequest == USB_REQ_CLEAR_FEATURE) { -+ if (ctrl_msg->dr.request == USB_REQ_CLEAR_FEATURE) { - /* Special case handling for pipe reset */ -- le16_to_cpus(&ctrl_msg->dr.wIndex); -+ le16_to_cpus(&ctrl_msg->dr.index); - usb_endpoint_running(adapter->usb_dev, -- ctrl_msg->dr.wIndex & ~USB_DIR_IN, -- (ctrl_msg->dr.wIndex & USB_DIR_IN) == 0); -+ ctrl_msg->dr.index & ~USB_DIR_IN, -+ (ctrl_msg->dr.index & USB_DIR_IN) == 0); - - /* toggle is reset on clear */ - usb_settoggle(adapter->usb_dev, -- ctrl_msg->dr.wIndex & ~USB_DIR_IN, -- (ctrl_msg->dr.wIndex & USB_DIR_IN) == 0, -+ ctrl_msg->dr.index & ~USB_DIR_IN, -+ (ctrl_msg->dr.index & USB_DIR_IN) == 0, - 0); - - -@@ -235,7 +235,7 @@ int __devinit st5481_setup_usb(struct st - struct usb_interface_descriptor *altsetting; - struct usb_endpoint_descriptor *endpoint; - int status; -- struct urb *urb; -+ urb_t *urb; - u_char *buf; - - DBG(1,""); -@@ -307,7 +307,7 @@ int __devinit st5481_setup_usb(struct st - * Release buffers and URBs for the interrupt and control - * endpoint. - */ --void st5481_release_usb(struct st5481_adapter *adapter) -+void __devexit st5481_release_usb(struct st5481_adapter *adapter) - { - struct st5481_intr *intr = &adapter->intr; - struct st5481_ctrl *ctrl = &adapter->ctrl; -@@ -443,7 +443,7 @@ st5481_setup_isocpipes(struct urb* urb[2 - return retval; - } - --void st5481_release_isocpipes(struct urb* urb[2]) -+void __devexit st5481_release_isocpipes(struct urb* urb[2]) - { - int j; - -@@ -484,18 +484,16 @@ static void usb_in_complete(struct urb * - ptr = urb->transfer_buffer; - while (len > 0) { - if (in->mode == L1_MODE_TRANS) { -- /* swap rx bytes to get hearable audio */ -- register unsigned char *dest = in->rcvbuf; -+ memcpy(in->rcvbuf, ptr, len); - status = len; -- for (; len; len--) -- *dest++ = isdnhdlc_bit_rev_tab[*ptr++]; -+ len = 0; - } else { -- status = isdnhdlc_decode(&in->hdlc_state, ptr, len, &count, -- in->rcvbuf, in->bufsize); -+ status = hdlc_decode(&in->hdlc_state, ptr, len, &count, -+ in->rcvbuf, in->bufsize); - ptr += count; - len -= count; - } -- -+ - if (status > 0) { - // Good frame received - DBG(4,"count=%d",status); -@@ -549,7 +547,7 @@ int __devinit st5481_setup_in(struct st5 - return retval; - } - --void st5481_release_in(struct st5481_in *in) -+void __devexit st5481_release_in(struct st5481_in *in) - { - DBG(2,""); - -@@ -562,8 +560,7 @@ void st5481_release_in(struct st5481_in - */ - int st5481_isoc_flatten(struct urb *urb) - { -- struct iso_packet_descriptor *pipd; -- struct iso_packet_descriptor *pend; -+ piso_packet_descriptor_t pipd,pend; - unsigned char *src,*dst; - unsigned int len; - -@@ -624,10 +621,15 @@ void st5481_in_mode(struct st5481_in *in - - if (in->mode != L1_MODE_NULL) { - if (in->mode != L1_MODE_TRANS) -- isdnhdlc_rcv_init(&in->hdlc_state, -- in->mode == L1_MODE_HDLC_56K); -+ hdlc_rcv_init(&in->hdlc_state, -+ in->mode == L1_MODE_HDLC_56K); - - st5481_usb_pipe_reset(in->adapter, in->ep, NULL, NULL); -+#if 0 -+ st5481_usb_device_ctrl_msg(in->adapter, in->counter, -+ in->packet_size, -+ st5481_start_rcv, in); -+#endif - st5481_usb_device_ctrl_msg(in->adapter, in->counter, - in->packet_size, - NULL, NULL); ---- a/drivers/isdn/hisax/tei.c -+++ b/drivers/isdn/hisax/tei.c -@@ -1,4 +1,4 @@ --/* $Id: tei.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: tei.c,v 2.20 2001/09/24 13:22:57 kai Exp $ - * - * Author Karsten Keil - * based on the teles driver from Jan den Ouden -@@ -21,7 +21,7 @@ - #include <linux/init.h> - #include <linux/random.h> - --const char *tei_revision = "$Revision: 1.1.4.1 $"; -+const char *tei_revision = "$Revision: 2.20 $"; - - #define ID_REQUEST 1 - #define ID_ASSIGNED 2 ---- a/drivers/isdn/hisax/teleint.c -+++ b/drivers/isdn/hisax/teleint.c -@@ -1,4 +1,4 @@ --/* $Id: teleint.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: teleint.c,v 1.16 2001/09/24 13:22:57 kai Exp $ - * - * low level stuff for TeleInt isdn cards - * -@@ -19,7 +19,7 @@ - - extern const char *CardType[]; - --const char *TeleInt_revision = "$Revision: 1.1.4.1 $"; -+const char *TeleInt_revision = "$Revision: 1.16 $"; - - #define byteout(addr,val) outb(val,addr) - #define bytein(addr) inb(addr) ---- a/drivers/isdn/hisax/teles0.c -+++ b/drivers/isdn/hisax/teles0.c -@@ -1,4 +1,4 @@ --/* $Id: teles0.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: teles0.c,v 2.15 2001/09/24 13:22:57 kai Exp $ - * - * low level stuff for Teles Memory IO isdn cards - * -@@ -24,7 +24,7 @@ - - extern const char *CardType[]; - --const char *teles0_revision = "$Revision: 1.1.4.1 $"; -+const char *teles0_revision = "$Revision: 2.15 $"; - - #define TELES_IOMEM_SIZE 0x400 - #define byteout(addr,val) outb(val,addr) -@@ -189,8 +189,10 @@ release_io_teles0(struct IsdnCardState * - { - if (cs->hw.teles0.cfg_reg) - release_region(cs->hw.teles0.cfg_reg, 8); -+#ifdef COMPAT_HAS_ISA_IOREMAP - iounmap((unsigned char *)cs->hw.teles0.membase); - release_mem_region(cs->hw.teles0.phymem, TELES_IOMEM_SIZE); -+#endif - } - - static int -@@ -327,6 +329,7 @@ setup_teles0(struct IsdnCard *card) - /* 16.0 and 8.0 designed for IOM1 */ - test_and_set_bit(HW_IOM1, &cs->HW_Flags); - cs->hw.teles0.phymem = card->para[1]; -+#ifdef COMPAT_HAS_ISA_IOREMAP - if (check_mem_region(cs->hw.teles0.phymem, TELES_IOMEM_SIZE)) { - printk(KERN_WARNING - "HiSax: %s memory region %lx-%lx already in use\n", -@@ -342,6 +345,9 @@ setup_teles0(struct IsdnCard *card) - } - cs->hw.teles0.membase = - (unsigned long) ioremap(cs->hw.teles0.phymem, TELES_IOMEM_SIZE); -+#else -+ cs->hw.teles0.membase = cs->hw.teles0.phymem; -+#endif - printk(KERN_INFO - "HiSax: %s config irq:%d mem:0x%lX cfg:0x%X\n", - CardType[cs->typ], cs->irq, ---- a/drivers/isdn/hisax/teles3.c -+++ b/drivers/isdn/hisax/teles3.c -@@ -1,4 +1,4 @@ --/* $Id: teles3.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: teles3.c,v 2.19 2001/09/24 13:22:57 kai Exp $ - * - * low level stuff for Teles 16.3 & PNP isdn cards - * -@@ -15,14 +15,13 @@ - */ - #define __NO_VERSION__ - #include <linux/init.h> --#include <linux/isapnp.h> - #include "hisax.h" - #include "isac.h" - #include "hscx.h" - #include "isdnl1.h" - - extern const char *CardType[]; --const char *teles3_revision = "$Revision: 1.1.4.1 $"; -+const char *teles3_revision = "$Revision: 2.19 $"; - - #define byteout(addr,val) outb(val,addr) - #define bytein(addr) inb(addr) -@@ -255,24 +254,6 @@ Teles_card_msg(struct IsdnCardState *cs, - return(0); - } - --#ifdef __ISAPNP__ --static struct isapnp_device_id teles_ids[] __initdata = { -- { ISAPNP_VENDOR('T', 'A', 'G'), ISAPNP_FUNCTION(0x2110), -- ISAPNP_VENDOR('T', 'A', 'G'), ISAPNP_FUNCTION(0x2110), -- (unsigned long) "Teles 16.3 PnP" }, -- { ISAPNP_VENDOR('C', 'T', 'X'), ISAPNP_FUNCTION(0x0), -- ISAPNP_VENDOR('C', 'T', 'X'), ISAPNP_FUNCTION(0x0), -- (unsigned long) "Creatix 16.3 PnP" }, -- { ISAPNP_VENDOR('C', 'P', 'Q'), ISAPNP_FUNCTION(0x1002), -- ISAPNP_VENDOR('C', 'P', 'Q'), ISAPNP_FUNCTION(0x1002), -- (unsigned long) "Compaq ISDN S0" }, -- { 0, } --}; -- --static struct isapnp_device_id *tdev = &teles_ids[0]; --static struct pci_bus *pnp_c __devinitdata = NULL; --#endif -- - int __devinit - setup_teles3(struct IsdnCard *card) - { -@@ -286,47 +267,6 @@ setup_teles3(struct IsdnCard *card) - && (cs->typ != ISDN_CTYPE_TELESPCMCIA) && (cs->typ != ISDN_CTYPE_COMPAQ_ISA)) - return (0); - --#ifdef __ISAPNP__ -- if (!card->para[1] && isapnp_present()) { -- struct pci_bus *pb; -- struct pci_dev *pd; -- -- while(tdev->card_vendor) { -- if ((pb = isapnp_find_card(tdev->card_vendor, -- tdev->card_device, pnp_c))) { -- pnp_c = pb; -- pd = NULL; -- if ((pd = isapnp_find_dev(pnp_c, -- tdev->vendor, tdev->function, pd))) { -- printk(KERN_INFO "HiSax: %s detected\n", -- (char *)tdev->driver_data); -- pd->prepare(pd); -- pd->deactivate(pd); -- pd->activate(pd); -- card->para[3] = pd->resource[2].start; -- card->para[2] = pd->resource[1].start; -- card->para[1] = pd->resource[0].start; -- card->para[0] = pd->irq_resource[0].start; -- if (!card->para[0] || !card->para[1] || !card->para[2]) { -- printk(KERN_ERR "Teles PnP:some resources are missing %ld/%lx/%lx\n", -- card->para[0], card->para[1], card->para[2]); -- pd->deactivate(pd); -- return(0); -- } -- break; -- } else { -- printk(KERN_ERR "Teles PnP: PnP error card found, no device\n"); -- } -- } -- tdev++; -- pnp_c=NULL; -- } -- if (!tdev->card_vendor) { -- printk(KERN_INFO "Teles PnP: no ISAPnP card found\n"); -- return(0); -- } -- } --#endif - if (cs->typ == ISDN_CTYPE_16_3) { - cs->hw.teles3.cfg_reg = card->para[1]; - switch (cs->hw.teles3.cfg_reg) { ---- a/drivers/isdn/hisax/telespci.c -+++ b/drivers/isdn/hisax/telespci.c -@@ -1,4 +1,4 @@ --/* $Id: telespci.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: telespci.c,v 2.23 2001/09/24 13:22:57 kai Exp $ - * - * low level stuff for Teles PCI isdn cards - * -@@ -20,9 +20,10 @@ - #include "hscx.h" - #include "isdnl1.h" - #include <linux/pci.h> -+#include <linux/isdn_compat.h> - - extern const char *CardType[]; --const char *telespci_revision = "$Revision: 1.1.4.1 $"; -+const char *telespci_revision = "$Revision: 2.23 $"; - - #define ZORAN_PO_RQ_PEN 0x02000000 - #define ZORAN_PO_WR 0x00800000 -@@ -307,10 +308,10 @@ setup_telespci(struct IsdnCard *card) - printk(KERN_WARNING "Teles: No IRQ for PCI card found\n"); - return(0); - } -- cs->hw.teles0.membase = (u_long) ioremap(pci_resource_start(dev_tel, 0), -+ cs->hw.teles0.membase = (u_long) ioremap(pci_resource_start_mem(dev_tel, 0), - PAGE_SIZE); - printk(KERN_INFO "Found: Zoran, base-address: 0x%lx, irq: 0x%x\n", -- pci_resource_start(dev_tel, 0), dev_tel->irq); -+ pci_resource_start_mem(dev_tel, 0), dev_tel->irq); - } else { - printk(KERN_WARNING "TelesPCI: No PCI card found\n"); - return(0); ---- a/drivers/isdn/hisax/w6692.c -+++ b/drivers/isdn/hisax/w6692.c -@@ -1,4 +1,4 @@ --/* $Id: w6692.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: w6692.c,v 1.18 2001/09/24 13:22:57 kai Exp $ - * - * Winbond W6692 specific routines - * -@@ -18,6 +18,7 @@ - #include "isdnl1.h" - #include <linux/interrupt.h> - #include <linux/pci.h> -+#include <linux/isdn_compat.h> - - /* table entry in the PCI devices list */ - typedef struct { -@@ -29,20 +30,14 @@ typedef struct { - - static const PCI_ENTRY id_list[] = - { -- {PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_6692, "Winbond", "W6692"}, - {PCI_VENDOR_ID_DYNALINK, PCI_DEVICE_ID_DYNALINK_IS64PH, "Dynalink/AsusCom", "IS64PH"}, -- {0, 0, "U.S.Robotics", "ISDN PCI Card TA"} -+ {PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_6692, "Winbond", "W6692"}, -+ {0, 0, NULL, NULL} - }; - --#define W6692_SV_USR 0x16ec --#define W6692_SD_USR 0x3409 --#define W6692_WINBOND 0 --#define W6692_DYNALINK 1 --#define W6692_USR 2 -- - extern const char *CardType[]; - --const char *w6692_revision = "$Revision: 1.1.4.1 $"; -+const char *w6692_revision = "$Revision: 1.18 $"; - - #define DBUSY_TIMER_VALUE 80 - -@@ -675,6 +670,16 @@ setstack_W6692(struct PStack *st, struct - static void - DC_Close_W6692(struct IsdnCardState *cs) - { -+#if 0 -+ if (cs->dc.w6692.mon_rx) { -+ kfree(cs->dc.w6692.mon_rx); -+ cs->dc.w6692.mon_rx = NULL; -+ } -+ if (cs->dc.w6692.mon_tx) { -+ kfree(cs->dc.w6692.mon_tx); -+ cs->dc.w6692.mon_tx = NULL; -+ } -+#endif - } - - static void -@@ -865,38 +870,31 @@ setstack_w6692(struct PStack *st, struct - return (0); - } - --void resetW6692(struct IsdnCardState *cs) --{ -- cs->writeW6692(cs, W_D_CTL, W_D_CTL_SRST); -- schedule_timeout((10*HZ)/1000); -- cs->writeW6692(cs, W_D_CTL, 0x00); -- schedule_timeout((10*HZ)/1000); -- cs->writeW6692(cs, W_IMASK, 0xff); -- cs->writeW6692(cs, W_D_SAM, 0xff); -- cs->writeW6692(cs, W_D_TAM, 0xff); -- cs->writeW6692(cs, W_D_EXIM, 0x00); -- cs->writeW6692(cs, W_D_MODE, W_D_MODE_RACT); -- cs->writeW6692(cs, W_IMASK, 0x18); -- if (cs->subtyp == W6692_USR) { -- /* seems that USR implemented some power control features -- * Pin 79 is connected to the oscilator circuit so we -- * have to handle it here -- */ -- cs->writeW6692(cs, W_PCTL, 0x80); -- cs->writeW6692(cs, W_XDATA, 0x00); -- } --} -- - void __init initW6692(struct IsdnCardState *cs, int part) - { - if (part & 1) { - cs->tqueue.routine = (void *) (void *) W6692_bh; - cs->setstack_d = setstack_W6692; - cs->DC_Close = DC_Close_W6692; -+#if 0 -+ cs->dc.w6692.mon_tx = NULL; -+ cs->dc.w6692.mon_rx = NULL; -+#endif - cs->dbusytimer.function = (void *) dbusy_timer_handler; - cs->dbusytimer.data = (long) cs; - init_timer(&cs->dbusytimer); -- resetW6692(cs); -+ -+ cs->writeW6692(cs, W_D_CTL, W_D_CTL_SRST); -+ cs->writeW6692(cs, W_D_CTL, 0x00); -+ cs->writeW6692(cs, W_IMASK, 0xff); -+#if 0 -+ cs->dc.w6692.mocr = 0xaa; -+#endif -+ cs->writeW6692(cs, W_D_SAM, 0xff); -+ cs->writeW6692(cs, W_D_TAM, 0xff); -+ cs->writeW6692(cs, W_D_EXIM, 0x00); -+ cs->writeW6692(cs, W_D_MODE, W_D_MODE_RACT); -+ cs->writeW6692(cs, W_IMASK, 0x18); - ph_command(cs, W_L1CMD_RST); - cs->dc.w6692.ph_state = W_L1CMD_RST; - W6692_new_ph(cs); -@@ -963,14 +961,9 @@ w6692_card_msg(struct IsdnCardState *cs, - { - switch (mt) { - case CARD_RESET: -- resetW6692(cs); - return (0); - case CARD_RELEASE: -- cs->writeW6692(cs, W_IMASK, 0xff); - release_region(cs->hw.w6692.iobase, 256); -- if (cs->subtyp == W6692_USR) { -- cs->writeW6692(cs, W_XDATA, 0x04); -- } - return (0); - case CARD_INIT: - initW6692(cs, 3); -@@ -1013,7 +1006,6 @@ setup_w6692(struct IsdnCard *card) - if (dev_w6692) { - if (pci_enable_device(dev_w6692)) - continue; -- cs->subtyp = id_idx; - break; - } - id_idx++; -@@ -1023,14 +1015,7 @@ setup_w6692(struct IsdnCard *card) - pci_irq = dev_w6692->irq; - /* I think address 0 is allways the configuration area */ - /* and address 1 is the real IO space KKe 03.09.99 */ -- pci_ioaddr = pci_resource_start(dev_w6692, 1); -- /* USR ISDN PCI card TA need some special handling */ -- if (cs->subtyp == W6692_WINBOND) { -- if ((W6692_SV_USR == dev_w6692->subsystem_vendor) && -- (W6692_SD_USR == dev_w6692->subsystem_device)) { -- cs->subtyp = W6692_USR; -- } -- } -+ pci_ioaddr = pci_resource_start_io(dev_w6692, 1); - } - if (!found) { - printk(KERN_WARNING "W6692: No PCI card found\n"); -@@ -1047,18 +1032,18 @@ setup_w6692(struct IsdnCard *card) - } - cs->hw.w6692.iobase = pci_ioaddr; - printk(KERN_INFO "Found: %s %s, I/O base: 0x%x, irq: %d\n", -- id_list[cs->subtyp].vendor_name, id_list[cs->subtyp].card_name, -- pci_ioaddr, pci_irq); -+ id_list[id_idx].vendor_name, id_list[id_idx].card_name, -+ pci_ioaddr, dev_w6692->irq); - if (check_region((cs->hw.w6692.iobase), 256)) { - printk(KERN_WARNING - "HiSax: %s I/O ports %x-%x already in use\n", -- id_list[cs->subtyp].card_name, -+ id_list[id_idx].card_name, - cs->hw.w6692.iobase, - cs->hw.w6692.iobase + 255); - return (0); - } else { - request_region(cs->hw.w6692.iobase, 256, -- id_list[cs->subtyp].card_name); -+ id_list[id_idx].card_name); - } - #else - printk(KERN_WARNING "HiSax: W6692 and NO_PCI_BIOS\n"); -@@ -1068,7 +1053,7 @@ setup_w6692(struct IsdnCard *card) - - printk(KERN_INFO - "HiSax: %s config irq:%d I/O:%x\n", -- id_list[cs->subtyp].card_name, cs->irq, -+ id_list[id_idx].card_name, cs->irq, - cs->hw.w6692.iobase); - - cs->readW6692 = &ReadW6692; ---- a/drivers/isdn/hisax/w6692.h -+++ b/drivers/isdn/hisax/w6692.h -@@ -1,4 +1,4 @@ --/* $Id: w6692.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ -+/* $Id: w6692.h,v 1.4 2001/09/24 13:22:57 kai Exp $ - * - * Winbond W6692 specific defines - * ---- a/drivers/isdn/hysdn/boardergo.c -+++ b/drivers/isdn/hysdn/boardergo.c -@@ -1,27 +1,41 @@ --/* $Id: boardergo.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ -- * -+/* $Id: boardergo.c,v 1.9 2001/07/19 20:39:51 kai Exp $ -+ - * Linux driver for HYSDN cards, specific routines for ergo type boards. - * -- * Author Werner Cornelius (werner@titro.de) for Hypercope GmbH -- * Copyright 1999 by Werner Cornelius (werner@titro.de) -- * -- * This software may be used and distributed according to the terms -- * of the GNU General Public License, incorporated herein by reference. -- * - * As all Linux supported cards Champ2, Ergo and Metro2/4 use the same - * DPRAM interface and layout with only minor differences all related - * stuff is done here, not in separate modules. - * -+ * written by Werner Cornelius (werner@titro.de) for Hypercope GmbH -+ * -+ * Copyright 1999 by Werner Cornelius (werner@titro.de) -+ * -+ * 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, or (at your option) -+ * any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -+ * - */ - -+#define __NO_VERSION__ - #include <linux/config.h> --#include <linux/sched.h> -+#include <linux/module.h> -+#include <linux/version.h> -+#include <asm/io.h> - #include <linux/signal.h> - #include <linux/kernel.h> - #include <linux/ioport.h> - #include <linux/interrupt.h> - #include <linux/vmalloc.h> --#include <asm/io.h> - - #include "hysdn_defs.h" - #include "boardergo.h" -@@ -45,11 +59,10 @@ ergo_interrupt(int intno, void *dev_id, - if (!card->irq_enabled) - return; /* other device interrupting or irq switched off */ - -- save_flags(flags); -- cli(); /* no further irqs allowed */ -+ HYSDN_SPIN_LOCK(&card->irq_lock, flags); - - if (!(bytein(card->iobase + PCI9050_INTR_REG) & PCI9050_INTR_REG_STAT1)) { -- restore_flags(flags); /* restore old state */ -+ HYSDN_SPIN_UNLOCK(&card->irq_lock, flags); - return; /* no interrupt requested by E1 */ - } - /* clear any pending ints on the board */ -@@ -63,7 +76,7 @@ ergo_interrupt(int intno, void *dev_id, - queue_task(&card->irq_queue, &tq_immediate); - mark_bh(IMMEDIATE_BH); - } -- restore_flags(flags); -+ HYSDN_SPIN_UNLOCK(&card->irq_lock, flags); - } /* ergo_interrupt */ - - /******************************************************************************/ -@@ -83,17 +96,15 @@ ergo_irq_bh(hysdn_card * card) - return; /* invalid call */ - - dpr = card->dpram; /* point to DPRAM */ -+ HYSDN_SPIN_LOCK(&card->irq_lock, flags); - -- save_flags(flags); -- cli(); - if (card->hw_lock) { -- restore_flags(flags); /* hardware currently unavailable */ -+ HYSDN_SPIN_UNLOCK(&card->irq_lock, flags); - return; - } - card->hw_lock = 1; /* we now lock the hardware */ - - do { -- sti(); /* reenable other ints */ - again = 0; /* assume loop not to be repeated */ - - if (!dpr->ToHyFlag) { -@@ -113,15 +124,13 @@ ergo_irq_bh(hysdn_card * card) - again = 1; /* restart loop */ - } - } /* a message has arrived for us */ -- cli(); /* no further ints */ - if (again) { - dpr->ToHyInt = 1; - dpr->ToPcInt = 1; /* interrupt to E1 for all cards */ - } else - card->hw_lock = 0; /* free hardware again */ - } while (again); /* until nothing more to do */ -- -- restore_flags(flags); -+ HYSDN_SPIN_UNLOCK(&card->irq_lock, flags); - } /* ergo_irq_bh */ - - -@@ -138,8 +147,7 @@ ergo_stopcard(hysdn_card * card) - #ifdef CONFIG_HYSDN_CAPI - hycapi_capi_stop(card); - #endif /* CONFIG_HYSDN_CAPI */ -- save_flags(flags); -- cli(); -+ HYSDN_SPIN_LOCK(&card->irq_lock, flags); - val = bytein(card->iobase + PCI9050_INTR_REG); /* get actual value */ - val &= ~(PCI9050_INTR_REG_ENPCI | PCI9050_INTR_REG_EN1); /* mask irq */ - byteout(card->iobase + PCI9050_INTR_REG, val); -@@ -147,8 +155,7 @@ ergo_stopcard(hysdn_card * card) - byteout(card->iobase + PCI9050_USER_IO, PCI9050_E1_RESET); /* reset E1 processor */ - card->state = CARD_STATE_UNUSED; - card->err_log_state = ERRLOG_STATE_OFF; /* currently no log active */ -- -- restore_flags(flags); -+ HYSDN_SPIN_UNLOCK(&card->irq_lock, flags); - } /* ergo_stopcard */ - - /**************************************************************************/ -@@ -163,20 +170,17 @@ ergo_set_errlog_state(hysdn_card * card, - card->err_log_state = ERRLOG_STATE_OFF; /* must be off */ - return; - } -- save_flags(flags); -- cli(); -- -+ HYSDN_SPIN_LOCK(&card->irq_lock, flags); - if (((card->err_log_state == ERRLOG_STATE_OFF) && !on) || - ((card->err_log_state == ERRLOG_STATE_ON) && on)) { -- restore_flags(flags); -+ HYSDN_SPIN_UNLOCK(&card->irq_lock, flags); - return; /* nothing to do */ - } - if (on) - card->err_log_state = ERRLOG_STATE_START; /* request start */ - else - card->err_log_state = ERRLOG_STATE_STOP; /* request stop */ -- -- restore_flags(flags); -+ HYSDN_SPIN_UNLOCK(&card->irq_lock, flags); - queue_task(&card->irq_queue, &tq_immediate); - mark_bh(IMMEDIATE_BH); - } /* ergo_set_errlog_state */ -@@ -245,9 +249,6 @@ ergo_writebootimg(struct HYSDN_CARD *car - while (!dpram->ToHyNoDpramErrLog); /* reread volatile register to flush PCI */ - - byteout(card->iobase + PCI9050_USER_IO, PCI9050_E1_RUN); /* start E1 processor */ -- /* the interrupts are still masked */ -- -- sti(); - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout((20 * HZ) / 1000); /* Timeout 20ms */ - -@@ -282,7 +283,6 @@ ergo_writebootseq(struct HYSDN_CARD *car - dst = sp->Data; /* point to data in spool structure */ - buflen = sp->Len; /* maximum len of spooled data */ - wr_mirror = sp->WrPtr; /* only once read */ -- sti(); - - /* try until all bytes written or error */ - i = 0x1000; /* timeout value */ -@@ -358,9 +358,7 @@ ergo_waitpofready(struct HYSDN_CARD *car - - if (card->debug_flags & LOG_POF_RECORD) - hysdn_addlog(card, "ERGO: pof boot success"); -- save_flags(flags); -- cli(); -- -+ HYSDN_SPIN_LOCK(&card->irq_lock, flags); - card->state = CARD_STATE_RUN; /* now card is running */ - /* enable the cards interrupt */ - byteout(card->iobase + PCI9050_INTR_REG, -@@ -371,8 +369,7 @@ ergo_waitpofready(struct HYSDN_CARD *car - dpr->ToPcFlag = 0; /* reset data indicator */ - dpr->ToHyInt = 1; - dpr->ToPcInt = 1; /* interrupt to E1 for all cards */ -- -- restore_flags(flags); -+ HYSDN_SPIN_UNLOCK(&card->irq_lock, flags); - if ((hynet_enable & (1 << card->myid)) - && (i = hysdn_net_create(card))) - { -@@ -387,7 +384,6 @@ ergo_waitpofready(struct HYSDN_CARD *car - #endif /* CONFIG_HYSDN_CAPI */ - return (0); /* success */ - } /* data has arrived */ -- sti(); - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout((50 * HZ) / 1000); /* Timeout 50ms */ - } /* wait until timeout */ ---- a/drivers/isdn/hysdn/boardergo.h -+++ b/drivers/isdn/hysdn/boardergo.h -@@ -1,4 +1,4 @@ --/* $Id: boardergo.h,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id$ - * - * Linux driver for HYSDN cards, definitions for ergo type boards (buffers..). - * -@@ -10,6 +10,7 @@ - * - */ - -+#include <linux/isdn_compat.h> - - /************************************************/ - /* defines for the dual port memory of the card */ ---- a/drivers/isdn/hysdn/hycapi.c -+++ b/drivers/isdn/hysdn/hycapi.c -@@ -1,4 +1,4 @@ --/* $Id: hycapi.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id$ - * - * Linux driver for HYSDN cards, CAPI2.0-Interface. - * -@@ -29,7 +29,7 @@ - #include "hysdn_defs.h" - #include <linux/kernelcapi.h> - --static char hycapi_revision[]="$Revision: 1.1.4.1 $"; -+static char hycapi_revision[]="$Revision$"; - - unsigned int hycapi_enable = 0xffffffff; - MODULE_PARM(hycapi_enable, "i"); ---- a/drivers/isdn/hysdn/hysdn_boot.c -+++ b/drivers/isdn/hysdn/hysdn_boot.c -@@ -1,4 +1,4 @@ --/* $Id: hysdn_boot.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id$ - * - * Linux driver for HYSDN cards - * specific routines for booting and pof handling -@@ -143,7 +143,7 @@ pof_handle_data(hysdn_card * card, int d - (boot->pof_recid == TAG_CABSDATA) ? "CABSDATA" : "ABSDATA", - datlen, boot->pof_recoffset); - -- if ((boot->last_error = card->writebootseq(card, boot->buf.BootBuf, datlen)) < 0) -+ if ((boot->last_error = card->writebootseq(card, boot->buf.BootBuf, datlen) < 0)) - return (boot->last_error); /* error writing data */ - - if (boot->pof_recoffset + datlen >= boot->pof_reclen) ---- a/drivers/isdn/hysdn/hysdn_defs.h -+++ b/drivers/isdn/hysdn/hysdn_defs.h -@@ -1,4 +1,4 @@ --/* $Id: hysdn_defs.h,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id: hysdn_defs.h,v 1.10 2001/09/24 13:23:03 kai Exp $ - * - * Linux driver for HYSDN cards - * global definitions and exported vars and functions. -@@ -19,6 +19,11 @@ - #include <linux/interrupt.h> - #include <linux/tqueue.h> - #include <linux/skbuff.h> -+#include <linux/isdn_compat.h> -+#include <linux/spinlock.h> -+ -+#define HYSDN_SPIN_LOCK(a,b) spin_lock(a) -+#define HYSDN_SPIN_UNLOCK(a,b) spin_unlock(a) - - /****************************/ - /* storage type definitions */ -@@ -176,6 +181,7 @@ typedef struct HYSDN_CARD { - struct tq_struct irq_queue; /* interrupt task queue */ - uchar volatile irq_enabled; /* interrupt enabled if != 0 */ - uchar volatile hw_lock; /* hardware is currently locked -> no access */ -+ spinlock_t irq_lock; - - /* boot process */ - void *boot; /* pointer to boot private data */ ---- a/drivers/isdn/hysdn/hysdn_init.c -+++ b/drivers/isdn/hysdn/hysdn_init.c -@@ -1,4 +1,4 @@ --/* $Id: hysdn_init.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id$ - * - * Linux driver for HYSDN cards, init functions. - * -@@ -21,6 +21,7 @@ - - #include "hysdn_defs.h" - -+#ifndef COMPAT_HAS_2_2_PCI - static struct pci_device_id hysdn_pci_tbl[] __initdata = { - {PCI_VENDOR_ID_HYPERCOPE, PCI_DEVICE_ID_HYPERCOPE_PLX, PCI_ANY_ID, PCI_SUBDEVICE_ID_HYPERCOPE_METRO}, - {PCI_VENDOR_ID_HYPERCOPE, PCI_DEVICE_ID_HYPERCOPE_PLX, PCI_ANY_ID, PCI_SUBDEVICE_ID_HYPERCOPE_CHAMP2}, -@@ -29,11 +30,12 @@ static struct pci_device_id hysdn_pci_tb - { } /* Terminating entry */ - }; - MODULE_DEVICE_TABLE(pci, hysdn_pci_tbl); -+#endif - MODULE_DESCRIPTION("ISDN4Linux: Driver for HYSDN cards"); - MODULE_AUTHOR("Werner Cornelius"); - MODULE_LICENSE("GPL"); - --static char *hysdn_init_revision = "$Revision: 1.1.4.1 $"; -+static char *hysdn_init_revision = "$Revision$"; - int cardmax; /* number of found cards */ - hysdn_card *card_root = NULL; /* pointer to first card */ - -@@ -91,11 +93,11 @@ search_cards(void) - card->myid = cardmax; /* set own id */ - card->bus = akt_pcidev->bus->number; - card->devfn = akt_pcidev->devfn; /* slot + function */ -- card->subsysid = akt_pcidev->subsystem_device; -+ pci_get_sub_system(akt_pcidev,card->subsysid); - card->irq = akt_pcidev->irq; -- card->iobase = pci_resource_start(akt_pcidev, PCI_REG_PLX_IO_BASE); -- card->plxbase = pci_resource_start(akt_pcidev, PCI_REG_PLX_MEM_BASE); -- card->membase = pci_resource_start(akt_pcidev, PCI_REG_MEMORY_BASE); -+ card->iobase = pci_resource_start_io(akt_pcidev, PCI_REG_PLX_IO_BASE); -+ card->plxbase = pci_resource_start_mem(akt_pcidev, PCI_REG_PLX_MEM_BASE); -+ card->membase = pci_resource_start_mem(akt_pcidev, PCI_REG_MEMORY_BASE); - card->brdtype = BD_NONE; /* unknown */ - card->debug_flags = DEF_DEB_FLAGS; /* set default debug */ - card->faxchans = 0; /* default no fax channels */ ---- a/drivers/isdn/hysdn/hysdn_net.c -+++ b/drivers/isdn/hysdn/hysdn_net.c -@@ -1,4 +1,4 @@ --/* $Id: hysdn_net.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id$ - * - * Linux driver for HYSDN cards, net (ethernet type) handling routines. - * -@@ -29,7 +29,7 @@ unsigned int hynet_enable = 0xffffffff; - MODULE_PARM(hynet_enable, "i"); - - /* store the actual version for log reporting */ --char *hysdn_net_revision = "$Revision: 1.1.4.1 $"; -+char *hysdn_net_revision = "$Revision$"; - - #define MAX_SKB_BUFFERS 20 /* number of buffers for keeping TX-data */ - -@@ -45,6 +45,10 @@ struct net_local { - /* additional vars may be added here */ - char dev_name[9]; /* our own device name */ - -+#ifdef COMPAT_NO_SOFTNET -+ struct sk_buff *tx_skb; /* buffer for tx operation */ -+ -+#else - /* Tx control lock. This protects the transmit buffer ring - * state along with the "tx full" state of the driver. This - * means all netif_queue flow control actions are protected -@@ -56,6 +60,7 @@ struct net_local { - int sk_count; /* number of buffers currently in ring */ - - int is_open; /* flag controlling module locking */ -+#endif - }; /* net_local */ - - -@@ -83,11 +88,19 @@ net_open(struct net_device *dev) - hysdn_card *card = dev->priv; - int i; - -+#ifdef COMPAT_NO_SOFTNET -+ dev->tbusy = 0; /* non busy state */ -+ dev->interrupt = 0; -+ if (!dev->start) -+ MOD_INC_USE_COUNT; /* increment only if device is down */ -+ dev->start = 1; /* and started */ -+#else - if (!((struct net_local *) dev)->is_open) - MOD_INC_USE_COUNT; /* increment only if interface is actually down */ - ((struct net_local *) dev)->is_open = 1; /* device actually open */ - - netif_start_queue(dev); /* start tx-queueing */ -+#endif - - /* Fill in the MAC-level header (if not already set) */ - if (!card->mac_addr[0]) { -@@ -104,6 +117,7 @@ net_open(struct net_device *dev) - return (0); - } /* net_open */ - -+#ifndef COMPAT_NO_SOFTNET - /*******************************************/ - /* flush the currently occupied tx-buffers */ - /* must only be called when device closed */ -@@ -119,6 +133,7 @@ flush_tx_buffers(struct net_local *nl) - nl->sk_count--; - } - } /* flush_tx_buffers */ -+#endif - - - /*********************************************************************/ -@@ -129,6 +144,15 @@ static int - net_close(struct net_device *dev) - { - -+#ifdef COMPAT_NO_SOFTNET -+ dev->tbusy = 1; /* we are busy */ -+ -+ if (dev->start) -+ MOD_DEC_USE_COUNT; /* dec only if device has been active */ -+ -+ dev->start = 0; /* and not started */ -+ -+#else - netif_stop_queue(dev); /* disable queueing */ - - if (((struct net_local *) dev)->is_open) -@@ -136,9 +160,52 @@ net_close(struct net_device *dev) - ((struct net_local *) dev)->is_open = 0; - flush_tx_buffers((struct net_local *) dev); - -+#endif - return (0); /* success */ - } /* net_close */ - -+#ifdef COMPAT_NO_SOFTNET -+/************************************/ -+/* send a packet on this interface. */ -+/* only for kernel versions < 2.3.33 */ -+/************************************/ -+static int -+net_send_packet(struct sk_buff *skb, struct net_device *dev) -+{ -+ struct net_local *lp = (struct net_local *) dev; -+ -+ if (dev->tbusy) { -+ /* -+ * If we get here, some higher level has decided we are broken. -+ * There should really be a "kick me" function call instead. -+ * As ISDN may have higher timeouts than real ethernet 10s timeout -+ */ -+ int tickssofar = jiffies - dev->trans_start; -+ if (tickssofar < (10000 * HZ) / 1000) -+ return 1; -+ printk(KERN_WARNING "%s: transmit timed out. \n", dev->name); -+ dev->tbusy = 0; -+ dev->trans_start = jiffies; -+ } -+ /* -+ * Block a timer-based transmit from overlapping. This could better be -+ * done with atomic_swap(1, dev->tbusy), but set_bit() works as well. -+ */ -+ if (test_and_set_bit(0, (void *) &dev->tbusy) != 0) -+ printk(KERN_WARNING "%s: Transmitter access conflict.\n", dev->name); -+ -+ else { -+ lp->stats.tx_bytes += skb->len; -+ dev->trans_start = jiffies; -+ lp->tx_skb = skb; /* remember skb pointer */ -+ queue_task(&((hysdn_card *) dev->priv)->irq_queue, &tq_immediate); -+ mark_bh(IMMEDIATE_BH); -+ } -+ -+ return (0); /* success */ -+} /* net_send_packet */ -+ -+#else - /************************************/ - /* send a packet on this interface. */ - /* new style for kernel >= 2.3.33 */ -@@ -176,6 +243,7 @@ net_send_packet(struct sk_buff *skb, str - return (0); /* success */ - } /* net_send_packet */ - -+#endif - - - /***********************************************************************/ -@@ -190,6 +258,15 @@ hysdn_tx_netack(hysdn_card * card) - if (!lp) - return; /* non existing device */ - -+#ifdef COMPAT_NO_SOFTNET -+ if (lp->tx_skb) -+ dev_kfree_skb(lp->tx_skb); /* free tx pointer */ -+ lp->tx_skb = NULL; /* reset pointer */ -+ -+ lp->stats.tx_packets++; -+ lp->netdev.tbusy = 0; -+ mark_bh(NET_BH); /* Inform upper layers. */ -+#else - - if (!lp->sk_count) - return; /* error condition */ -@@ -203,6 +280,7 @@ hysdn_tx_netack(hysdn_card * card) - - if (lp->sk_count-- == MAX_SKB_BUFFERS) /* dec usage count */ - netif_start_queue((struct net_device *) lp); -+#endif - } /* hysdn_tx_netack */ - - /*****************************************************/ -@@ -250,10 +328,15 @@ hysdn_tx_netget(hysdn_card * card) - if (!lp) - return (NULL); /* non existing device */ - -+#ifdef COMPAT_NO_SOFTNET -+ return (lp->tx_skb); /* return packet pointer */ -+ -+#else - if (!lp->sk_count) - return (NULL); /* nothing available */ - - return (lp->skbs[lp->out_idx]); /* next packet to send */ -+#endif - } /* hysdn_tx_netget */ - - -@@ -296,15 +379,21 @@ hysdn_net_create(hysdn_card * card) - } - memset(dev, 0, sizeof(struct net_local)); /* clean the structure */ - -+#ifndef COMPAT_NO_SOFTNET - spin_lock_init(&((struct net_local *) dev)->lock); -+#endif - - /* initialise necessary or informing fields */ - dev->base_addr = card->iobase; /* IO address */ - dev->irq = card->irq; /* irq */ - dev->init = net_init; /* the init function of the device */ -+#ifdef COMPAT_NO_SOFTNET -+ dev->name = ((struct net_local *) dev)->dev_name; /* device name */ -+#else - if(dev->name) { - strcpy(dev->name, ((struct net_local *) dev)->dev_name); - } -+#endif - if ((i = register_netdev(dev))) { - printk(KERN_WARNING "HYSDN: unable to create network device\n"); - kfree(dev); -@@ -333,7 +422,9 @@ hysdn_net_release(hysdn_card * card) - card->netif = NULL; /* clear out pointer */ - dev->stop(dev); /* close the device */ - -+#ifndef COMPAT_NO_SOFTNET - flush_tx_buffers((struct net_local *) dev); /* empty buffers */ -+#endif - - unregister_netdev(dev); /* release the device */ - kfree(dev); /* release the memory allocated */ ---- a/drivers/isdn/hysdn/hysdn_pof.h -+++ b/drivers/isdn/hysdn/hysdn_pof.h -@@ -1,4 +1,4 @@ --/* $Id: hysdn_pof.h,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id$ - * - * Linux driver for HYSDN cards, definitions used for handling pof-files. - * ---- a/drivers/isdn/hysdn/hysdn_procconf.c -+++ b/drivers/isdn/hysdn/hysdn_procconf.c -@@ -1,4 +1,4 @@ --/* $Id: hysdn_procconf.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id$ - * - * Linux driver for HYSDN cards, /proc/net filesystem dir and conf functions. - * -@@ -17,11 +17,13 @@ - #include <linux/poll.h> - #include <linux/proc_fs.h> - #include <linux/pci.h> -+#ifndef COMPAT_USE_MODCOUNT_LOCK - #include <linux/smp_lock.h> -+#endif - - #include "hysdn_defs.h" - --static char *hysdn_procconf_revision = "$Revision: 1.1.4.1 $"; -+static char *hysdn_procconf_revision = "$Revision$"; - - #define INFO_OUT_LEN 80 /* length of info line including lf */ - -@@ -212,32 +214,29 @@ hysdn_conf_write(struct file *file, cons - static ssize_t - hysdn_conf_read(struct file *file, char *buf, size_t count, loff_t * off) - { -- loff_t pos = *off; - char *cp; - int i; - - if (off != &file->f_pos) /* fs error check */ - return -ESPIPE; - -- if (!(file->f_mode & FMODE_READ)) -- return -EPERM; -- -- if (!(cp = file->private_data)) -- return (-EFAULT); /* should never happen */ -- -- i = strlen(cp); /* get total string length */ -- -- if (pos != (unsigned)pos || pos >= i) -- return 0; -- -- /* still bytes to transfer */ -- cp += pos; /* point to desired data offset */ -- i -= pos; /* remaining length */ -- if (i > count) -- i = count; /* limit length to transfer */ -- if (copy_to_user(buf, cp, i)) -- return (-EFAULT); /* copy error */ -- *off = pos + i; /* adjust offset */ -+ if (file->f_mode & FMODE_READ) { -+ if (!(cp = file->private_data)) -+ return (-EFAULT); /* should never happen */ -+ i = strlen(cp); /* get total string length */ -+ if (*off < i) { -+ /* still bytes to transfer */ -+ cp += *off; /* point to desired data offset */ -+ i -= *off; /* remaining length */ -+ if (i > count) -+ i = count; /* limit length to transfer */ -+ if (copy_to_user(buf, cp, i)) -+ return (-EFAULT); /* copy error */ -+ *off += i; /* adjust offset */ -+ } else -+ return (0); -+ } else -+ return (-EPERM); /* no permission to read */ - - return (i); - } /* hysdn_conf_read */ -@@ -254,7 +253,11 @@ hysdn_conf_open(struct inode *ino, struc - char *cp, *tmp; - - /* now search the addressed card */ -+#ifdef COMPAT_USE_MODCOUNT_LOCK -+ MOD_INC_USE_COUNT; -+#else - lock_kernel(); -+#endif - card = card_root; - while (card) { - pd = card->procconf; -@@ -263,7 +266,11 @@ hysdn_conf_open(struct inode *ino, struc - card = card->next; /* search next entry */ - } - if (!card) { -+#ifdef COMPAT_USE_MODCOUNT_LOCK -+ MOD_DEC_USE_COUNT; -+#else - unlock_kernel(); -+#endif - return (-ENODEV); /* device is unknown/invalid */ - } - if (card->debug_flags & (LOG_PROC_OPEN | LOG_PROC_ALL)) -@@ -274,7 +281,11 @@ hysdn_conf_open(struct inode *ino, struc - /* write only access -> write boot file or conf line */ - - if (!(cnf = kmalloc(sizeof(struct conf_writedata), GFP_KERNEL))) { -+#ifdef COMPAT_USE_MODCOUNT_LOCK -+ MOD_DEC_USE_COUNT; -+#else - unlock_kernel(); -+#endif - return (-EFAULT); - } - cnf->card = card; -@@ -286,7 +297,11 @@ hysdn_conf_open(struct inode *ino, struc - /* read access -> output card info data */ - - if (!(tmp = (char *) kmalloc(INFO_OUT_LEN * 2 + 2, GFP_KERNEL))) { -+#ifdef COMPAT_USE_MODCOUNT_LOCK -+ MOD_DEC_USE_COUNT; -+#else - unlock_kernel(); -+#endif - return (-EFAULT); /* out of memory */ - } - filep->private_data = tmp; /* start of string */ -@@ -320,10 +335,16 @@ hysdn_conf_open(struct inode *ino, struc - *cp++ = '\n'; - *cp = 0; /* end of string */ - } else { /* simultaneous read/write access forbidden ! */ -+#ifdef COMPAT_USE_MODCOUNT_LOCK -+ MOD_DEC_USE_COUNT; -+#else - unlock_kernel(); -+#endif - return (-EPERM); /* no permission this time */ - } -+#ifndef COMPAT_USE_MODCOUNT_LOCK - unlock_kernel(); -+#endif - return (0); - } /* hysdn_conf_open */ - -@@ -338,7 +359,9 @@ hysdn_conf_close(struct inode *ino, stru - int retval = 0; - struct proc_dir_entry *pd; - -+#ifndef COMPAT_USE_MODCOUNT_LOCK - lock_kernel(); -+#endif - /* search the addressed card */ - card = card_root; - while (card) { -@@ -348,7 +371,9 @@ hysdn_conf_close(struct inode *ino, stru - card = card->next; /* search next entry */ - } - if (!card) { -+#ifndef COMPAT_USE_MODCOUNT_LOCK - unlock_kernel(); -+#endif - return (-ENODEV); /* device is unknown/invalid */ - } - if (card->debug_flags & (LOG_PROC_OPEN | LOG_PROC_ALL)) -@@ -371,7 +396,11 @@ hysdn_conf_close(struct inode *ino, stru - if (filep->private_data) - kfree(filep->private_data); /* release memory */ - } -+#ifdef COMPAT_USE_MODCOUNT_LOCK -+ MOD_DEC_USE_COUNT; -+#else - unlock_kernel(); -+#endif - return (retval); - } /* hysdn_conf_close */ - -@@ -387,6 +416,9 @@ static struct file_operations conf_fops - release: hysdn_conf_close, - }; - -+#ifdef COMPAT_NO_SOFTNET -+static struct inode_operations conf_inode_operations; -+#endif - /*****************************/ - /* hysdn subdir in /proc/net */ - /*****************************/ -@@ -415,8 +447,17 @@ hysdn_procconf_init(void) - if ((card->procconf = (void *) create_proc_entry(conf_name, - S_IFREG | S_IRUGO | S_IWUSR, - hysdn_proc_entry)) != NULL) { -+#ifdef COMPAT_NO_SOFTNET -+ memset(&conf_inode_operations, 0, sizeof(struct inode_operations)); -+ conf_inode_operations.default_file_ops = &conf_fops; -+ -+ ((struct proc_dir_entry *) card->procconf)->ops = &conf_inode_operations; -+#else - ((struct proc_dir_entry *) card->procconf)->proc_fops = &conf_fops; -+#ifdef COMPAT_HAS_FILEOP_OWNER - ((struct proc_dir_entry *) card->procconf)->owner = THIS_MODULE; -+#endif -+#endif - hysdn_proclog_init(card); /* init the log file entry */ - } - card = card->next; /* next entry */ ---- a/drivers/isdn/hysdn/hysdn_proclog.c -+++ b/drivers/isdn/hysdn/hysdn_proclog.c -@@ -1,4 +1,4 @@ --/* $Id: hysdn_proclog.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id$ - * - * Linux driver for HYSDN cards, /proc/net filesystem log functions. - * -@@ -16,7 +16,9 @@ - #include <linux/poll.h> - #include <linux/proc_fs.h> - #include <linux/pci.h> -+#ifndef COMPAT_USE_MODCOUNT_LOCK - #include <linux/smp_lock.h> -+#endif - - #include "hysdn_defs.h" - -@@ -115,8 +117,7 @@ put_log_buffer(hysdn_card * card, char * - strcpy(ib->log_start, cp); /* set output string */ - ib->next = NULL; - ib->proc_ctrl = pd; /* point to own control structure */ -- save_flags(flags); -- cli(); -+ HYSDN_SPIN_LOCK(&card->irq_lock, flags); - ib->usage_cnt = pd->if_used; - if (!pd->log_head) - pd->log_head = ib; /* new head */ -@@ -124,7 +125,7 @@ put_log_buffer(hysdn_card * card, char * - pd->log_tail->next = ib; /* follows existing messages */ - pd->log_tail = ib; /* new tail */ - i = pd->del_lock++; /* get lock state */ -- restore_flags(flags); -+ HYSDN_SPIN_UNLOCK(&card->irq_lock, flags); - - /* delete old entrys */ - if (!i) -@@ -210,7 +211,6 @@ hysdn_log_read(struct file *file, char * - word ino; - struct procdata *pd = NULL; - hysdn_card *card; -- loff_t pos = *off; - - if (!*((struct log_data **) file->private_data)) { - if (file->f_flags & O_NONBLOCK) -@@ -235,11 +235,11 @@ hysdn_log_read(struct file *file, char * - return (0); - - inf->usage_cnt--; /* new usage count */ -- file->private_data = &inf->next; /* next structure */ -+ (struct log_data **) file->private_data = &inf->next; /* next structure */ - if ((len = strlen(inf->log_start)) <= count) { - if (copy_to_user(buf, inf->log_start, len)) - return -EFAULT; -- *off = pos + len; -+ file->f_pos += len; - return (len); - } - return (0); -@@ -255,7 +255,11 @@ hysdn_log_open(struct inode *ino, struct - struct procdata *pd = NULL; - ulong flags; - -+#ifdef COMPAT_USE_MODCOUNT_LOCK -+ MOD_INC_USE_COUNT; -+#else - lock_kernel(); -+#endif - card = card_root; - while (card) { - pd = card->proclog; -@@ -264,7 +268,11 @@ hysdn_log_open(struct inode *ino, struct - card = card->next; /* search next entry */ - } - if (!card) { -+#ifdef COMPAT_USE_MODCOUNT_LOCK -+ MOD_DEC_USE_COUNT; -+#else - unlock_kernel(); -+#endif - return (-ENODEV); /* device is unknown/invalid */ - } - filep->private_data = card; /* remember our own card */ -@@ -274,19 +282,24 @@ hysdn_log_open(struct inode *ino, struct - } else if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) { - - /* read access -> log/debug read */ -- save_flags(flags); -- cli(); -+ HYSDN_SPIN_LOCK(&card->irq_lock, flags); - pd->if_used++; - if (pd->log_head) -- filep->private_data = &(pd->log_tail->next); -+ (struct log_data **) filep->private_data = &(pd->log_tail->next); - else -- filep->private_data = &(pd->log_head); -- restore_flags(flags); -+ (struct log_data **) filep->private_data = &(pd->log_head); -+ HYSDN_SPIN_UNLOCK(&card->irq_lock, flags); - } else { /* simultaneous read/write access forbidden ! */ -+#ifdef COMPAT_USE_MODCOUNT_LOCK -+ MOD_DEC_USE_COUNT; -+#else - unlock_kernel(); -+#endif - return (-EPERM); /* no permission this time */ - } -+#ifndef COMPAT_USE_MODCOUNT_LOCK - unlock_kernel(); -+#endif - return (0); - } /* hysdn_log_open */ - -@@ -306,7 +319,9 @@ hysdn_log_close(struct inode *ino, struc - int flags, retval = 0; - - -+#ifndef COMPAT_USE_MODCOUNT_LOCK - lock_kernel(); -+#endif - if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) { - /* write only access -> write debug level written */ - retval = 0; /* success */ -@@ -314,8 +329,7 @@ hysdn_log_close(struct inode *ino, struc - /* read access -> log/debug read, mark one further file as closed */ - - pd = NULL; -- save_flags(flags); -- cli(); -+ HYSDN_SPIN_LOCK(&card->irq_lock, flags); - inf = *((struct log_data **) filep->private_data); /* get first log entry */ - if (inf) - pd = (struct procdata *) inf->proc_ctrl; /* still entries there */ -@@ -338,7 +352,7 @@ hysdn_log_close(struct inode *ino, struc - inf->usage_cnt--; /* decrement usage count for buffers */ - inf = inf->next; - } -- restore_flags(flags); -+ HYSDN_SPIN_UNLOCK(&card->irq_lock, flags); - - if (pd) - if (pd->if_used <= 0) /* delete buffers if last file closed */ -@@ -348,7 +362,11 @@ hysdn_log_close(struct inode *ino, struc - kfree(inf); - } - } /* read access */ -+#ifdef COMPAT_USE_MODCOUNT_LOCK -+ MOD_DEC_USE_COUNT; -+#else - unlock_kernel(); -+#endif - - return (retval); - } /* hysdn_log_close */ -@@ -400,6 +418,9 @@ static struct file_operations log_fops = - release: hysdn_log_close, - }; - -+#ifdef COMPAT_NO_SOFTNET -+struct inode_operations log_inode_operations; -+#endif - - /***********************************************************************************/ - /* hysdn_proclog_init is called when the module is loaded after creating the cards */ -@@ -414,10 +435,20 @@ hysdn_proclog_init(hysdn_card * card) - - if ((pd = (struct procdata *) kmalloc(sizeof(struct procdata), GFP_KERNEL)) != NULL) { - memset(pd, 0, sizeof(struct procdata)); -+#ifdef COMPAT_NO_SOFTNET -+ memset(&log_inode_operations, 0, sizeof(struct inode_operations)); -+ log_inode_operations.default_file_ops = &log_fops; -+#endif - sprintf(pd->log_name, "%s%d", PROC_LOG_BASENAME, card->myid); - if ((pd->log = create_proc_entry(pd->log_name, S_IFREG | S_IRUGO | S_IWUSR, hysdn_proc_entry)) != NULL) { -+#ifdef COMPAT_NO_SOFTNET -+ pd->log->ops = &log_inode_operations; /* set new operations table */ -+#else - pd->log->proc_fops = &log_fops; -+#ifdef COMPAT_HAS_FILEOP_OWNER - pd->log->owner = THIS_MODULE; -+#endif -+#endif - } - - init_waitqueue_head(&(pd->rd_queue)); ---- a/drivers/isdn/hysdn/hysdn_sched.c -+++ b/drivers/isdn/hysdn/hysdn_sched.c -@@ -1,4 +1,4 @@ --/* $Id: hysdn_sched.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id: hysdn_sched.c,v 1.9 2001/09/24 13:23:03 kai Exp $ - * - * Linux driver for HYSDN cards - * scheduler routines for handling exchange card <-> pc. -@@ -12,11 +12,9 @@ - */ - - #include <linux/config.h> --#include <linux/sched.h> - #include <linux/signal.h> - #include <linux/kernel.h> - #include <linux/ioport.h> --#include <linux/interrupt.h> - #include <asm/io.h> - - #include "hysdn_defs.h" -@@ -151,22 +149,19 @@ hysdn_tx_cfgline(hysdn_card * card, ucha - - if (card->debug_flags & LOG_SCHED_ASYN) - hysdn_addlog(card, "async tx-cfg chan=%d len=%d", chan, strlen(line) + 1); -- -- save_flags(flags); -- cli(); -+ HYSDN_SPIN_LOCK(&card->irq_lock, flags); - while (card->async_busy) { -- sti(); -- -+ HYSDN_SPIN_UNLOCK(&card->irq_lock, flags); - if (card->debug_flags & LOG_SCHED_ASYN) - hysdn_addlog(card, "async tx-cfg delayed"); - - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout((20 * HZ) / 1000); /* Timeout 20ms */ - if (!--cnt) { -- restore_flags(flags); -+ HYSDN_SPIN_UNLOCK(&card->irq_lock, flags); - return (-ERR_ASYNC_TIME); /* timed out */ - } -- cli(); -+ HYSDN_SPIN_LOCK(&card->irq_lock, flags); - } /* wait for buffer to become free */ - - strcpy(card->async_data, line); -@@ -177,31 +172,26 @@ hysdn_tx_cfgline(hysdn_card * card, ucha - /* now queue the task */ - queue_task(&card->irq_queue, &tq_immediate); - mark_bh(IMMEDIATE_BH); -- sti(); -- -+ HYSDN_SPIN_UNLOCK(&card->irq_lock, flags); - if (card->debug_flags & LOG_SCHED_ASYN) - hysdn_addlog(card, "async tx-cfg data queued"); - - cnt++; /* short delay */ -- cli(); -- -+ HYSDN_SPIN_LOCK(&card->irq_lock, flags); - while (card->async_busy) { -- sti(); -- -+ HYSDN_SPIN_UNLOCK(&card->irq_lock, flags); - if (card->debug_flags & LOG_SCHED_ASYN) - hysdn_addlog(card, "async tx-cfg waiting for tx-ready"); - - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout((20 * HZ) / 1000); /* Timeout 20ms */ - if (!--cnt) { -- restore_flags(flags); -+ HYSDN_SPIN_UNLOCK(&card->irq_lock, flags); - return (-ERR_ASYNC_TIME); /* timed out */ - } -- cli(); -+ HYSDN_SPIN_LOCK(&card->irq_lock, flags); - } /* wait for buffer to become free again */ -- -- restore_flags(flags); -- -+ HYSDN_SPIN_UNLOCK(&card->irq_lock, flags); - if (card->debug_flags & LOG_SCHED_ASYN) - hysdn_addlog(card, "async tx-cfg data send"); - ---- a/drivers/isdn/icn/icn.c -+++ b/drivers/isdn/icn/icn.c -@@ -1,4 +1,4 @@ --/* $Id: icn.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id$ - * - * ISDN low-level module for the ICN active ISDN-Card. - * -@@ -41,7 +41,7 @@ MODULE_PARM_DESC(icn_id2, "ID-String of - #undef MAP_DEBUG - - static char --*revision = "$Revision: 1.1.4.1 $"; -+*revision = "$Revision$"; - - static int icn_addcard(int, char *, char *); - -@@ -1634,6 +1634,7 @@ icn_addcard(int port, char *id1, char *i - } - - #ifndef MODULE -+#ifdef COMPAT_HAS_NEW_SETUP - static int __init - icn_setup(char *line) - { -@@ -1643,6 +1644,14 @@ icn_setup(char *line) - static char sid2[20]; - - str = get_options(line, 2, ints); -+#else -+void -+icn_setup(char *str, int *ints) -+{ -+ char *p; -+ static char sid[20]; -+ static char sid2[20]; -+#endif - if (ints[0]) - portbase = ints[1]; - if (ints[0] > 1) -@@ -1656,9 +1665,13 @@ icn_setup(char *line) - icn_id2 = sid2; - } - } -+#ifdef COMPAT_HAS_NEW_SETUP - return(1); - } - __setup("icn=", icn_setup); -+#else -+} -+#endif - #endif /* MODULE */ - - static int __init icn_init(void) ---- a/drivers/isdn/icn/icn.h -+++ b/drivers/isdn/icn/icn.h -@@ -1,4 +1,4 @@ --/* $Id: icn.h,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id$ - * - * ISDN lowlevel-module for the ICN active ISDN-Card. - * ---- a/drivers/isdn/isdn_audio.c -+++ b/drivers/isdn/isdn_audio.c -@@ -1,9 +1,9 @@ --/* $Id: isdn_audio.c,v 1.1.4.1 2001/11/20 14:19:33 kai Exp $ -+/* $Id: isdn_audio.c,v 1.24 2002/08/13 09:57:26 keil Exp $ - * - * Linux ISDN subsystem, audio conversion and compression (linklevel). - * - * Copyright 1994-1999 by Fritz Elfert (fritz@isdn4linux.de) -- * DTMF code (c) 1996 by Christian Mock (cm@kukuruz.ping.at) -+ * DTMF code (c) 1996 by Christian Mock (cm@tahina.priv.at) - * Silence detection (c) 1998 by Armin Schindler (mac@gismo.telekom.de) - * - * This software may be used and distributed according to the terms -@@ -15,7 +15,7 @@ - #include "isdn_audio.h" - #include "isdn_common.h" - --char *isdn_audio_revision = "$Revision: 1.1.4.1 $"; -+char *isdn_audio_revision = "$Revision: 1.24 $"; - - /* - * Misc. lookup-tables. -@@ -169,19 +169,39 @@ static char isdn_audio_ulaw_to_alaw[] = - 0x8a, 0x8a, 0x6a, 0x6a, 0xea, 0xea, 0x2a, 0x2a - }; - --#define NCOEFF 8 /* number of frequencies to be analyzed */ --#define DTMF_TRESH 4000 /* above this is dtmf */ -+#define NCOEFF 16 /* number of frequencies to be analyzed */ -+#define DTMF_TRESH 25000 /* above this is dtmf */ - #define SILENCE_TRESH 200 /* below this is silence */ -+#define H2_TRESH 20000 /* 2nd harmonic */ - #define AMP_BITS 9 /* bits per sample, reduced to avoid overflow */ - #define LOGRP 0 - #define HIGRP 1 - -+typedef struct { -+ int grp; /* low/high group */ -+ int k; /* k */ -+ int k2; /* k fuer 2. harmonic */ -+} dtmf_t; -+ - /* For DTMF recognition: - * 2 * cos(2 * PI * k / N) precalculated for all k - */ - static int cos2pik[NCOEFF] = - { -- 55813, 53604, 51193, 48591, 38114, 33057, 25889, 18332 -+ 55812, 29528, 53603, 24032, 51193, 14443, 48590, 6517, -+ 38113, -21204, 33057, -32186, 25889, -45081, 18332, -55279 -+}; -+ -+static dtmf_t dtmf_tones[8] = -+{ -+ {LOGRP, 0, 1}, /* 697 Hz */ -+ {LOGRP, 2, 3}, /* 770 Hz */ -+ {LOGRP, 4, 5}, /* 852 Hz */ -+ {LOGRP, 6, 7}, /* 941 Hz */ -+ {HIGRP, 8, 9}, /* 1209 Hz */ -+ {HIGRP, 10, 11}, /* 1336 Hz */ -+ {HIGRP, 12, 13}, /* 1477 Hz */ -+ {HIGRP, 14, 15} /* 1633 Hz */ - }; - - static char dtmf_matrix[4][4] = -@@ -208,7 +228,7 @@ isdn_audio_tlookup(const u_char *table, - : "memory", "ax"); - #else - while (n--) -- *buff = table[*(unsigned char *)buff], buff++; -+ *buff++ = table[*(unsigned char *)buff]; - #endif - } - -@@ -479,18 +499,6 @@ isdn_audio_goertzel(int *sample, modem_i - sk2 = sk1; - sk1 = sk; - } -- /* Avoid overflows */ -- sk >>= 1; -- sk2 >>= 1; -- /* compute |X(k)|**2 */ -- /* report overflows. This should not happen. */ -- /* Comment this out if desired */ -- if (sk < -32768 || sk > 32767) -- printk(KERN_DEBUG -- "isdn_audio: dtmf goertzel overflow, sk=%d\n", sk); -- if (sk2 < -32768 || sk2 > 32767) -- printk(KERN_DEBUG -- "isdn_audio: dtmf goertzel overflow, sk2=%d\n", sk2); - result[k] = - ((sk * sk) >> AMP_BITS) - - ((((cos2pik[k] * sk) >> 15) * sk2) >> AMP_BITS) + -@@ -514,58 +522,28 @@ isdn_audio_eval_dtmf(modem_info * info) - int grp[2]; - char what; - char *p; -- int thresh; - - while ((skb = skb_dequeue(&info->dtmf_queue))) { - result = (int *) skb->data; - s = info->dtmf_state; -- grp[LOGRP] = grp[HIGRP] = -1; -+ grp[LOGRP] = grp[HIGRP] = -2; - silence = 0; -- thresh = 0; -- for (i = 0; i < NCOEFF; i++) { -- if (result[i] > DTMF_TRESH) { -- if (result[i] > thresh) -- thresh = result[i]; -- } -- else if (result[i] < SILENCE_TRESH) -+ for (i = 0; i < 8; i++) { -+ if ((result[dtmf_tones[i].k] > DTMF_TRESH) && -+ (result[dtmf_tones[i].k2] < H2_TRESH)) -+ grp[dtmf_tones[i].grp] = (grp[dtmf_tones[i].grp] == -2) ? i : -1; -+ else if ((result[dtmf_tones[i].k] < SILENCE_TRESH) && -+ (result[dtmf_tones[i].k2] < SILENCE_TRESH)) - silence++; - } -- if (silence == NCOEFF) -+ if (silence == 8) - what = ' '; - else { -- if (thresh > 0) { -- thresh = thresh >> 4; /* touchtones must match within 12 dB */ -- for (i = 0; i < NCOEFF; i++) { -- if (result[i] < thresh) -- continue; /* ignore */ -- /* good level found. This is allowed only one time per group */ -- if (i < NCOEFF / 2) { -- /* lowgroup*/ -- if (grp[LOGRP] >= 0) { -- // Bad. Another tone found. */ -- grp[LOGRP] = -1; -- break; -- } -- else -- grp[LOGRP] = i; -- } -- else { /* higroup */ -- if (grp[HIGRP] >= 0) { // Bad. Another tone found. */ -- grp[HIGRP] = -1; -- break; -- } -- else -- grp[HIGRP] = i - NCOEFF/2; -- } -- } -- if ((grp[LOGRP] >= 0) && (grp[HIGRP] >= 0)) { -- what = dtmf_matrix[grp[LOGRP]][grp[HIGRP]]; -- if (s->last != ' ' && s->last != '.') -- s->last = what; /* min. 1 non-DTMF between DTMF */ -- } else -- what = '.'; -- } -- else -+ if ((grp[LOGRP] >= 0) && (grp[HIGRP] >= 0)) { -+ what = dtmf_matrix[grp[LOGRP]][grp[HIGRP] - 4]; -+ if (s->last != ' ' && s->last != '.') -+ s->last = what; /* min. 1 non-DTMF between DTMF */ -+ } else - what = '.'; - } - if ((what != s->last) && (what != ' ') && (what != '.')) { ---- a/drivers/isdn/isdn_audio.h -+++ b/drivers/isdn/isdn_audio.h -@@ -1,4 +1,4 @@ --/* $Id: isdn_audio.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: isdn_audio.h,v 1.10 2001/09/24 13:22:42 kai Exp $ - * - * Linux ISDN subsystem, audio conversion and compression (linklevel). - * -@@ -20,7 +20,6 @@ typedef struct adpcm_state { - - typedef struct dtmf_state { - char last; -- char llast; - int idx; - int buf[DTMF_NPOINTS]; - } dtmf_state; ---- a/drivers/isdn/isdn_bsdcomp.c -+++ b/drivers/isdn/isdn_bsdcomp.c -@@ -105,6 +105,14 @@ MODULE_LICENSE("Dual BSD/GPL"); - - #define DEBUG 1 - -+#ifdef CONFIG_ISDN_WITH_ABC -+#define BSD_C_MALLOC(x) kmalloc((x),GFP_ATOMIC) -+#define BSD_C_FREE(x) kfree(x) -+#else -+#define BSD_C_MALLOC(x) vmalloc(x) -+#define BSD_C_FREE(x) vfree(x) -+#endif -+ - /* - * A dictionary for doing BSD compress. - */ -@@ -285,7 +293,7 @@ static void bsd_free (void *state) - * Release the dictionary - */ - if (db->dict) { -- vfree (db->dict); -+ BSD_C_FREE (db->dict); - db->dict = NULL; - } - -@@ -293,7 +301,7 @@ static void bsd_free (void *state) - * Release the string buffer - */ - if (db->lens) { -- vfree (db->lens); -+ BSD_C_FREE (db->lens); - db->lens = NULL; - } - -@@ -350,14 +358,19 @@ static void *bsd_alloc (struct isdn_ppp_ - * Allocate space for the dictionary. This may be more than one page in - * length. - */ -- db->dict = (struct bsd_dict *) vmalloc (hsize * sizeof (struct bsd_dict)); -+ db->dict = (struct bsd_dict *) BSD_C_MALLOC (hsize * sizeof (struct bsd_dict)); -+ -+ MOD_INC_USE_COUNT; -+ /* -+ ** MOD_INC_USE_COUNT must be before bsd_free -+ ** bsd_free make MOD_DEC_USE_COUNT if db != NULL -+ */ -+ - if (!db->dict) { - bsd_free (db); - return NULL; - } - -- MOD_INC_USE_COUNT; -- - /* - * If this is the compression buffer then there is no length data. - * For decompression, the length information is needed as well. -@@ -365,7 +378,7 @@ static void *bsd_alloc (struct isdn_ppp_ - if (!decomp) - db->lens = NULL; - else { -- db->lens = (unsigned short *) vmalloc ((maxmaxcode + 1) * -+ db->lens = (unsigned short *) BSD_C_MALLOC ((maxmaxcode + 1) * - sizeof (db->lens[0])); - if (!db->lens) { - bsd_free (db); /* calls MOD_DEC_USE_COUNT; */ -@@ -478,7 +491,11 @@ static int bsd_compress (void *state, st - int hval,disp,ilen,mxcode; - unsigned char *rptr = skb_in->data; - int isize = skb_in->len; -+#ifdef CONFIG_ISDN_WITH_ABC -+ long secure = 0; -+#endif - -+#ifndef CONFIG_ISDN_WITH_ABC - #define OUTPUT(ent) \ - { \ - bitno -= n_bits; \ -@@ -490,17 +507,45 @@ static int bsd_compress (void *state, st - bitno += 8; \ - } while (bitno <= 24); \ - } -+#else -+#define OUTPUT(ent) \ -+ { \ -+ secure = 0; \ -+ bitno -= n_bits; \ -+ accm |= ((ent) << bitno); \ -+ do { \ -+ if(skb_out && skb_tailroom(skb_out) > 0) \ -+ *(skb_put(skb_out,1)) = (unsigned char) (accm>>24); \ -+ accm <<= 8; \ -+ bitno += 8; \ -+ } while (bitno <= 24 && ++secure < 10000); \ -+ if(secure >= 10000) { \ -+ printk(KERN_DEBUG "BSD in OUTPUT secure counter reached\n"); \ -+ return 0; \ -+ } \ -+ } -+#endif - - /* - * If the protocol is not in the range we're interested in, - * just return without compressing the packet. If it is, - * the protocol becomes the first byte to compress. - */ -+#ifdef CONFIG_ISDN_WITH_ABC -+ ent = proto; -+ -+ if (proto < 0x21 || proto > 0xf9 || !(proto & 0x1) ) { -+ -+ printk(KERN_DEBUG "bsd_compress called with %x\n",proto); -+ return 0; -+ } -+#else - printk(KERN_DEBUG "bsd_compress called with %x\n",proto); - - ent = proto; - if (proto < 0x21 || proto > 0xf9 || !(proto & 0x1) ) - return 0; -+#endif - - db = (struct bsd_db *) state; - hshift = db->hshift; -@@ -538,6 +583,9 @@ static int bsd_compress (void *state, st - - /* continue probing until a match or invalid entry */ - disp = (hval == 0) ? 1 : hval; -+#ifdef CONFIG_ISDN_WITH_ABC -+ secure = 0; -+#endif - - do { - hval += disp; -@@ -546,7 +594,15 @@ static int bsd_compress (void *state, st - dictp = dict_ptr (db, hval); - if (dictp->codem1 >= max_ent) - goto nomatch; -+#ifndef CONFIG_ISDN_WITH_ABC - } while (dictp->fcode != fcode); -+#else -+ } while (dictp->fcode != fcode && ++secure < 100000); -+ if(secure >= 100000) { -+ printk(KERN_DEBUG "BSD: compress while dictp->fcode != fcode secure-counter reached\n"); -+ return 0; -+ } -+#endif - - ent = dictp->codem1 + 1; /* finally found (prefix,suffix) */ - continue; -@@ -669,6 +725,9 @@ static int bsd_decompress (void *state, - int ilen; - int codelen; - int extra; -+#ifdef CONFIG_ISDN_WITH_ABC -+ unsigned long secure = 0; -+#endif - - db = (struct bsd_db *) state; - max_ent = db->max_ent; -@@ -677,7 +736,9 @@ static int bsd_decompress (void *state, - n_bits = db->n_bits; - tgtbitno = 32 - n_bits; /* bitno when we have a code */ - -+#ifndef CONFIG_ISDN_WITH_ABC - printk(KERN_DEBUG "bsd_decompress called\n"); -+#endif - - if(!skb_in || !skb_out) { - printk(KERN_ERR "bsd_decompress called with NULL parameter\n"); -@@ -795,7 +856,11 @@ static int bsd_decompress (void *state, - - p = skb_put(skb_out,codelen); - p += codelen; -+#ifdef CONFIG_ISDN_WITH_ABC -+ for(secure = 0; finchar > LAST && secure < 50000;secure++) { -+#else - while (finchar > LAST) { -+#endif - struct bsd_dict *dictp2 = dict_ptr (db, finchar); - - dictp = dict_ptr (db, dictp2->cptr); -@@ -822,6 +887,12 @@ static int bsd_decompress (void *state, - } - } - *--p = finchar; -+#ifdef CONFIG_ISDN_WITH_ABC -+ if(secure >= 50000) { -+ printk(KERN_DEBUG "BSD: decompress secure-counter reached\n"); -+ return DECOMP_FATALERROR; -+ } -+#endif - - #ifdef DEBUG - if (--codelen != 0) -@@ -851,12 +922,23 @@ static int bsd_decompress (void *state, - /* look for a free hash table entry */ - if (dictp->codem1 < max_ent) { - disp = (hval == 0) ? 1 : hval; -+#ifdef CONFIG_ISDN_WITH_ABC -+ secure = 0; -+#endif - do { - hval += disp; - if (hval >= db->hsize) - hval -= db->hsize; - dictp = dict_ptr (db, hval); -+#ifndef CONFIG_ISDN_WITH_ABC - } while (dictp->codem1 < max_ent); -+#else -+ } while (dictp->codem1 < max_ent && ++secure < 50000); -+ if(secure >= 50000) { -+ printk(KERN_DEBUG "BSD: decomp while (dictp->codem1 < max_ent) secure-counter reached\n"); -+ return DECOMP_FATALERROR; -+ } -+#endif - } - - /* -@@ -895,11 +977,21 @@ static int bsd_decompress (void *state, - db->comp_bytes += skb_in->len - BSD_OVHD; - db->uncomp_bytes += skb_out->len; - -+#ifdef CONFIG_ISDN_WITH_ABC -+ /* -+ ** bsd_check will call bsd_clear -+ ** and so on the internal tables will be cleared. -+ ** -+ ** I think that's not what we will at this point ????? -+ ** For me at works without bsd_check. -+ */ -+#else - if (bsd_check(db)) { - if (db->debug) - printk(KERN_DEBUG "bsd_decomp%d: peer should have cleared dictionary on %d\n", - db->unit, db->seqno - 1); - } -+#endif - return skb_out->len; - } - ---- a/drivers/isdn/isdn_common.c -+++ b/drivers/isdn/isdn_common.c -@@ -1,4 +1,4 @@ --/* $Id: isdn_common.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: isdn_common.c,v 1.137 2002/02/09 21:19:11 keil Exp $ - * - * Linux ISDN subsystem, common used functions (linklevel). - * -@@ -19,6 +19,7 @@ - #include <linux/vmalloc.h> - #include <linux/isdn.h> - #include <linux/smp_lock.h> -+#include <linux/list.h> - #include "isdn_common.h" - #include "isdn_tty.h" - #include "isdn_net.h" -@@ -33,7 +34,9 @@ - #include <linux/isdn_divertif.h> - #endif /* CONFIG_ISDN_DIVERSION */ - #include "isdn_v110.h" -+#ifdef HAVE_DEVFS_FS - #include <linux/devfs_fs_kernel.h> -+#endif /* HAVE_DEVFS_FS */ - - /* Debugflags */ - #undef ISDN_DEBUG_STATCALLB -@@ -44,7 +47,7 @@ MODULE_LICENSE("GPL"); - - isdn_dev *dev; - --static char *isdn_revision = "$Revision: 1.1.4.1 $"; -+static char *isdn_revision = "$Revision: 1.137 $"; - - extern char *isdn_net_revision; - extern char *isdn_tty_revision; -@@ -67,19 +70,19 @@ static isdn_divert_if *divert_if; /* = N - - static int isdn_writebuf_stub(int, int, const u_char *, int, int); - static void set_global_features(void); -+#ifdef HAVE_DEVFS_FS - static void isdn_register_devfs(int); - static void isdn_unregister_devfs(int); -+#endif /* HAVE_DEVFS_FS */ - static int isdn_wildmat(char *s, char *p); - - void - isdn_lock_drivers(void) - { - int i; -- isdn_ctrl cmd; - -- for (i = 0; i < ISDN_MAX_DRIVERS; i++) { -- if (!dev->drv[i]) -- continue; -+ for (i = 0; i < dev->drivers; i++) { -+ isdn_ctrl cmd; - - cmd.driver = i; - cmd.arg = 0; -@@ -101,10 +104,7 @@ isdn_unlock_drivers(void) - { - int i; - -- for (i = 0; i < ISDN_MAX_DRIVERS; i++) { -- if (!dev->drv[i]) -- continue; -- -+ for (i = 0; i < dev->drivers; i++) - if (dev->drv[i]->locks > 0) { - isdn_ctrl cmd; - -@@ -114,7 +114,6 @@ isdn_unlock_drivers(void) - isdn_command(&cmd); - dev->drv[i]->locks--; - } -- } - } - - void -@@ -473,6 +472,7 @@ isdn_status_callback(isdn_ctrl * c) - dev->drv[di]->flags &= ~DRV_FLAG_RUNNING; - break; - case ISDN_STAT_ICALL: -+ case ISDN_STAT_ICALLW: - if (i < 0) - return -1; - #ifdef ISDN_DEBUG_STATCALLB -@@ -718,7 +718,9 @@ isdn_status_callback(isdn_ctrl * c) - dev->drvmap[i] = -1; - dev->chanmap[i] = -1; - dev->usage[i] &= ~ISDN_USAGE_DISABLED; -+#ifdef HAVE_DEVFS_FS - isdn_unregister_devfs(i); -+#endif /* HAVE_DEVFS_FS */ - } - dev->drivers--; - dev->channels -= dev->drv[di]->channels; -@@ -755,6 +757,10 @@ isdn_status_callback(isdn_ctrl * c) - if (divert_if) - return(divert_if->stat_callback(c)); - #endif /* CONFIG_ISDN_DIVERSION */ -+ case ISDN_STAT_ALERT: -+ case ISDN_STAT_PROCEED: -+ isdn_tty_stat_callback(i, c); -+ break; - default: - return -1; - } -@@ -900,72 +906,239 @@ isdn_minor2chan(int minor) - return (dev->chanmap[minor]); - } - --static char * --isdn_statstr(void) -+// ---------------------------------------------------------------------- -+// /dev/isdninfo -+// -+// This device has somewhat insane semantics, but we need to support -+// them for the sake of compatibility. -+// -+// After opening, the first read will succeed and return the current state -+// Then, unless O_NONBLOCK is set, it will block until a state change happens -+// and then return the new state. -+// Also, if the buffer size for the read is too small, we'll just return -+// EOF -+ -+struct isdnstatus_dev { -+ struct list_head list; -+ int update; -+}; -+ -+static DECLARE_WAIT_QUEUE_HEAD(isdnstatus_waitq); -+static LIST_HEAD(isdnstatus_devs); -+static spinlock_t isdnstatus_devs_lock = SPIN_LOCK_UNLOCKED; -+ -+void -+isdn_info_update(void) -+{ -+ struct list_head *p; -+ struct isdnstatus_dev *idev; -+ -+ spin_lock(&isdnstatus_devs_lock); -+ list_for_each(p, &isdnstatus_devs) { -+ idev = list_entry(p, struct isdnstatus_dev, list); -+ idev->update = 1; -+ } -+ spin_unlock(&isdnstatus_devs_lock); -+ wake_up_interruptible(&isdnstatus_waitq); -+} -+ -+static int -+isdnstatus_open(struct inode *ino, struct file *filep) -+{ -+ struct isdnstatus_dev *p; -+ -+ p = kmalloc(sizeof(struct isdnstatus_dev), GFP_USER); -+ if (!p) -+ return -ENOMEM; -+ -+ /* At opening time we allow a single update */ -+ p->update = 1; -+ spin_lock(&isdnstatus_devs_lock); -+ list_add(&p->list, &isdnstatus_devs); -+ spin_unlock(&isdnstatus_devs_lock); -+ filep->private_data = p; -+ -+ return 0; -+} -+ -+static void -+isdnstatus_close(struct inode *ino, struct file *filep) -+{ -+ struct isdnstatus_dev *p = filep->private_data; -+ -+ spin_lock(&isdnstatus_devs_lock); -+ list_del(&p->list); -+ spin_unlock(&isdnstatus_devs_lock); -+ kfree(p); -+} -+ -+// FIXME we don't lock against the state changing whilst being -+// printed -+ -+void -+isdn_statstr(char *buf) - { -- static char istatbuf[2048]; - char *p; - int i; - -- sprintf(istatbuf, "idmap:\t"); -- p = istatbuf + strlen(istatbuf); -+ p = buf; -+ p += sprintf(p, "idmap:\t"); - for (i = 0; i < ISDN_MAX_CHANNELS; i++) { -- sprintf(p, "%s ", (dev->drvmap[i] < 0) ? "-" : dev->drvid[dev->drvmap[i]]); -- p = istatbuf + strlen(istatbuf); -+ p += sprintf(p, "%s ", (dev->drvmap[i] < 0) ? "-" : dev->drvid[dev->drvmap[i]]); - } -- sprintf(p, "\nchmap:\t"); -- p = istatbuf + strlen(istatbuf); -+ p += sprintf(p, "\nchmap:\t"); - for (i = 0; i < ISDN_MAX_CHANNELS; i++) { -- sprintf(p, "%d ", dev->chanmap[i]); -- p = istatbuf + strlen(istatbuf); -+ p += sprintf(p, "%d ", dev->chanmap[i]); - } -- sprintf(p, "\ndrmap:\t"); -- p = istatbuf + strlen(istatbuf); -+ p += sprintf(p, "\ndrmap:\t"); - for (i = 0; i < ISDN_MAX_CHANNELS; i++) { -- sprintf(p, "%d ", dev->drvmap[i]); -- p = istatbuf + strlen(istatbuf); -+ p += sprintf(p, "%d ", dev->drvmap[i]); - } -- sprintf(p, "\nusage:\t"); -- p = istatbuf + strlen(istatbuf); -+ p += sprintf(p, "\nusage:\t"); - for (i = 0; i < ISDN_MAX_CHANNELS; i++) { -- sprintf(p, "%d ", dev->usage[i]); -- p = istatbuf + strlen(istatbuf); -+ p += sprintf(p, "%d ", dev->usage[i]); - } -- sprintf(p, "\nflags:\t"); -- p = istatbuf + strlen(istatbuf); -+ p += sprintf(p, "\nflags:\t"); - for (i = 0; i < ISDN_MAX_DRIVERS; i++) { - if (dev->drv[i]) { -- sprintf(p, "%ld ", dev->drv[i]->online); -- p = istatbuf + strlen(istatbuf); -+ p += sprintf(p, "%ld ", dev->drv[i]->online); - } else { -- sprintf(p, "? "); -- p = istatbuf + strlen(istatbuf); -+ p += sprintf(p, "? "); - } - } -- sprintf(p, "\nphone:\t"); -- p = istatbuf + strlen(istatbuf); -+ p += sprintf(p, "\nphone:\t"); - for (i = 0; i < ISDN_MAX_CHANNELS; i++) { -- sprintf(p, "%s ", dev->num[i]); -- p = istatbuf + strlen(istatbuf); -+ p += sprintf(p, "%s ", dev->num[i]); - } -- sprintf(p, "\n"); -- return istatbuf; -+ p += sprintf(p, "\n"); - } - --/* Module interface-code */ -+static ssize_t -+isdnstatus_read(struct file *file, char *buf, size_t count, loff_t * off) -+{ -+ static DECLARE_MUTEX(istatbuf_mutex); -+ static char istatbuf[2048]; - --void --isdn_info_update(void) -+ DECLARE_WAITQUEUE(wait, current); -+ struct isdnstatus_dev *idev; -+ int retval = 0; -+ unsigned int len; -+ -+ idev = file->private_data; -+ -+ if (off != &file->f_pos) -+ return -ESPIPE; -+ -+ add_wait_queue(&isdnstatus_waitq, &wait); -+ for (;;) { -+ set_current_state(TASK_INTERRUPTIBLE); -+ -+ if (idev->update) -+ break; -+ -+ retval = -EAGAIN; -+ if (file->f_flags & O_NONBLOCK) -+ break; -+ -+ retval = -ERESTARTSYS; -+ if (signal_pending(current)) -+ break; -+ -+ schedule(); -+ } -+ __set_current_state(TASK_RUNNING); -+ remove_wait_queue(&isdnstatus_waitq, &wait); -+ -+ if (!idev->update) -+ goto out; -+ -+ idev->update = 0; -+ down(&istatbuf_mutex); -+ isdn_statstr(istatbuf); -+ len = strlen(istatbuf); -+ if (len > count) { -+ retval = 0; -+ goto out_unlock; -+ } -+ if (copy_to_user(buf, istatbuf, len)) { -+ retval = -EFAULT; -+ goto out_unlock; -+ } -+ *off += len; -+ retval = len; -+ -+ out_unlock: -+ up(&istatbuf_mutex); -+ out: -+ return retval; -+} -+ -+static ssize_t -+isdnstatus_write(struct file *file, const char *buf, size_t count, loff_t * off) - { -- infostruct *p = dev->infochain; -+ return -EINVAL; -+} -+ -+static unsigned int -+isdnstatus_poll(struct file *file, poll_table * wait) -+{ -+ struct isdnstatus_dev *idev; -+ unsigned int mask = 0; -+ -+ idev = file->private_data; - -- while (p) { -- *(p->private) = 1; -- p = (infostruct *) p->next; -+ poll_wait(file, &isdnstatus_waitq, wait); -+ if (idev->update) { -+ mask |= POLLIN | POLLRDNORM; - } -- wake_up_interruptible(&(dev->info_waitq)); -+ return mask; - } - -+static int -+isdnstatus_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) -+{ -+ int retval; -+ isdn_net_ioctl_phone phone; -+ -+ switch (cmd) { -+ case IIOCGETDVR: -+ return (TTY_DV + -+ (NET_DV << 8) + -+ (INF_DV << 16)); -+ case IIOCGETCPS: -+ if (arg) { -+ ulong *p = (ulong *) arg; -+ int i; -+ if ((retval = verify_area(VERIFY_WRITE, (void *) arg, -+ sizeof(ulong) * ISDN_MAX_CHANNELS * 2))) -+ return retval; -+ for (i = 0; i < ISDN_MAX_CHANNELS; i++) { -+ put_user(dev->ibytes[i], p++); -+ put_user(dev->obytes[i], p++); -+ } -+ return 0; -+ } else -+ return -EINVAL; -+ break; -+#ifdef CONFIG_NETDEVICES -+ case IIOCNETGPN: -+ /* Get peer phone number of a connected -+ * isdn network interface */ -+ if (arg) { -+ if (copy_from_user((char *) &phone, (char *) arg, sizeof(phone))) -+ return -EFAULT; -+ return isdn_net_getpeer(&phone, (isdn_net_ioctl_phone *) arg); -+ } else -+ return -EINVAL; -+#endif -+ default: -+ return -EINVAL; -+ } -+} -+ -+// ---------------------------------------------------------------------- -+ -+ - static ssize_t - isdn_read(struct file *file, char *buf, size_t count, loff_t * off) - { -@@ -976,37 +1149,16 @@ isdn_read(struct file *file, char *buf, - int chidx; - int retval; - char *p; -- loff_t pos = *off; - - if (off != &file->f_pos) - return -ESPIPE; - -- if (pos != (unsigned) pos) -- return -EINVAL; -- -+#ifndef COMPAT_HAVE_READ_LOCK_KERNEL - lock_kernel(); -- if (minor == ISDN_MINOR_STATUS) { -- if (!file->private_data) { -- if (file->f_flags & O_NONBLOCK) { -- retval = -EAGAIN; -- goto out; -- } -- interruptible_sleep_on(&(dev->info_waitq)); -- } -- p = isdn_statstr(); -- file->private_data = 0; -- if ((len = strlen(p)) <= count) { -- if (copy_to_user(buf, p, len)) { -- retval = -EFAULT; -- goto out; -- } -- *off = pos + len; -- retval = len; -- goto out; -- } -- retval = 0; -- goto out; -- } -+#endif -+ if (minor == ISDN_MINOR_STATUS) -+ return isdnstatus_read(file, buf, count, off); -+ - if (!dev->drivers) { - retval = -ENODEV; - goto out; -@@ -1031,7 +1183,7 @@ isdn_read(struct file *file, char *buf, - cli(); - len = isdn_readbchan(drvidx, chidx, p, 0, count, - &dev->drv[drvidx]->rcv_waitq[chidx]); -- *off = pos + len; -+ *off += len; - restore_flags(flags); - if (copy_to_user(buf,p,len)) - len = -EFAULT; -@@ -1052,6 +1204,9 @@ isdn_read(struct file *file, char *buf, - } - interruptible_sleep_on(&(dev->drv[drvidx]->st_waitq)); - } -+#ifdef CONFIG_ISDN_WITH_ABC_LCR_SUPPORT -+ if(drvidx || (len = isdn_dw_abc_lcr_readstat(buf,count)) < 1) { -+#endif - if (dev->drv[drvidx]->interface->readstat) { - if (count > dev->drv[drvidx]->stavail) - count = dev->drv[drvidx]->stavail; -@@ -1065,6 +1220,9 @@ isdn_read(struct file *file, char *buf, - } else { - len = 0; - } -+#ifdef CONFIG_ISDN_WITH_ABC_LCR_SUPPORT -+ } -+#endif - save_flags(flags); - cli(); - if (len) -@@ -1072,7 +1230,7 @@ isdn_read(struct file *file, char *buf, - else - dev->drv[drvidx]->stavail = 0; - restore_flags(flags); -- *off = pos + len; -+ *off += len; - retval = len; - goto out; - } -@@ -1084,7 +1242,9 @@ isdn_read(struct file *file, char *buf, - #endif - retval = -ENODEV; - out: -+#ifndef COMPAT_HAVE_READ_LOCK_KERNEL - unlock_kernel(); -+#endif - return retval; - } - -@@ -1096,15 +1256,18 @@ isdn_write(struct file *file, const char - int chidx; - int retval; - -+ if (minor == ISDN_MINOR_STATUS) -+ return isdnstatus_write(file, buf, count, off); -+ - if (off != &file->f_pos) - return -ESPIPE; - -- if (minor == ISDN_MINOR_STATUS) -- return -EPERM; - if (!dev->drivers) - return -ENODEV; - -+#ifndef COMPAT_HAVE_WRITE_LOCK_KERNEL - lock_kernel(); -+#endif - if (minor <= ISDN_MINOR_BMAX) { - printk(KERN_WARNING "isdn_write minor %d obsolete!\n", minor); - drvidx = isdn_minor2drv(minor); -@@ -1149,7 +1312,9 @@ isdn_write(struct file *file, const char - #endif - retval = -ENODEV; - out: -+#ifndef COMPAT_HAVE_WRITE_LOCK_KERNEL - unlock_kernel(); -+#endif - return retval; - } - -@@ -1160,15 +1325,12 @@ isdn_poll(struct file *file, poll_table - unsigned int minor = MINOR(file->f_dentry->d_inode->i_rdev); - int drvidx = isdn_minor2drv(minor - ISDN_MINOR_CTRL); - -+#ifndef COMPAT_HAVE_POLL_LOCK_KERNEL - lock_kernel(); -- if (minor == ISDN_MINOR_STATUS) { -- poll_wait(file, &(dev->info_waitq), wait); -- /* mask = POLLOUT | POLLWRNORM; */ -- if (file->private_data) { -- mask |= POLLIN | POLLRDNORM; -- } -- goto out; -- } -+#endif -+ if (minor == ISDN_MINOR_STATUS) -+ return isdnstatus_poll(file, wait); -+ - if (minor >= ISDN_MINOR_CTRL && minor <= ISDN_MINOR_CTRLMAX) { - if (drvidx < 0) { - /* driver deregistered while file open */ -@@ -1190,7 +1352,9 @@ isdn_poll(struct file *file, poll_table - #endif - mask = POLLERR; - out: -+#ifndef COMPAT_HAVE_POLL_LOCK_KERNEL - unlock_kernel(); -+#endif - return mask; - } - -@@ -1220,42 +1384,9 @@ isdn_ioctl(struct inode *inode, struct f - #define phone iocpar.phone - #define cfg iocpar.cfg - -- if (minor == ISDN_MINOR_STATUS) { -- switch (cmd) { -- case IIOCGETDVR: -- return (TTY_DV + -- (NET_DV << 8) + -- (INF_DV << 16)); -- case IIOCGETCPS: -- if (arg) { -- ulong *p = (ulong *) arg; -- int i; -- if ((ret = verify_area(VERIFY_WRITE, (void *) arg, -- sizeof(ulong) * ISDN_MAX_CHANNELS * 2))) -- return ret; -- for (i = 0; i < ISDN_MAX_CHANNELS; i++) { -- put_user(dev->ibytes[i], p++); -- put_user(dev->obytes[i], p++); -- } -- return 0; -- } else -- return -EINVAL; -- break; --#ifdef CONFIG_NETDEVICES -- case IIOCNETGPN: -- /* Get peer phone number of a connected -- * isdn network interface */ -- if (arg) { -- if (copy_from_user((char *) &phone, (char *) arg, sizeof(phone))) -- return -EFAULT; -- return isdn_net_getpeer(&phone, (isdn_net_ioctl_phone *) arg); -- } else -- return -EINVAL; --#endif -- default: -- return -EINVAL; -- } -- } -+ if (minor == ISDN_MINOR_STATUS) -+ return isdnstatus_ioctl(inode, file, cmd, arg); -+ - if (!dev->drivers) - return -ENODEV; - if (minor <= ISDN_MINOR_BMAX) { -@@ -1277,11 +1408,34 @@ isdn_ioctl(struct inode *inode, struct f - */ - switch (cmd) { - case IIOCNETDWRSET: -+#ifdef CONFIG_ISDN_WITH_ABC -+ if (arg) { -+ -+ if (copy_from_user(name, (char *) arg, sizeof(name))) { -+ -+ return(-EFAULT); -+ -+ } else { -+ -+ isdn_net_dev *p = isdn_net_findif(name); -+ -+ if(p == NULL) -+ return(-EINVAL); -+ -+ return(isdn_dw_abc_reset_interface(p->local,1)); -+ } -+ } -+#else - printk(KERN_INFO "INFO: ISDN_DW_ABC_EXTENSION not enabled\n"); -+#endif - return(-EINVAL); - case IIOCNETLCR: -+#ifdef CONFIG_ISDN_WITH_ABC_LCR_SUPPORT -+ return(isdn_dw_abc_lcr_ioctl(arg)); -+#else - printk(KERN_INFO "INFO: ISDN_ABC_LCR_SUPPORT not enabled\n"); - return -ENODEV; -+#endif - #ifdef CONFIG_NETDEVICES - case IIOCNETAIF: - /* Add a network-interface */ -@@ -1657,22 +1811,12 @@ isdn_open(struct inode *ino, struct file - int chidx; - int retval = -ENODEV; - -+#ifdef COMPAT_USE_MODCOUNT_LOCK -+ MOD_INC_USE_COUNT; -+#endif - - if (minor == ISDN_MINOR_STATUS) { -- infostruct *p; -- -- if ((p = kmalloc(sizeof(infostruct), GFP_KERNEL))) { -- p->next = (char *) dev->infochain; -- p->private = (char *) &(filep->private_data); -- dev->infochain = p; -- /* At opening we allow a single update */ -- filep->private_data = (char *) 1; -- retval = 0; -- goto out; -- } else { -- retval = -ENOMEM; -- goto out; -- } -+ return isdnstatus_open(ino, filep); - } - if (!dev->channels) - goto out; -@@ -1695,6 +1839,9 @@ isdn_open(struct inode *ino, struct file - if (drvidx < 0) - goto out; - isdn_lock_drivers(); -+#ifdef CONFIG_ISDN_WITH_ABC_LCR_SUPPORT -+ if(!drvidx) isdn_dw_abc_lcr_open(); -+#endif - retval = 0; - goto out; - } -@@ -1707,6 +1854,10 @@ isdn_open(struct inode *ino, struct file - } - #endif - out: -+#ifdef COMPAT_USE_MODCOUNT_LOCK -+ if (retval) -+ MOD_DEC_USE_COUNT; -+#endif - return retval; - } - -@@ -1715,25 +1866,11 @@ isdn_close(struct inode *ino, struct fil - { - uint minor = MINOR(ino->i_rdev); - -+#ifndef COMPAT_USE_MODCOUNT_LOCK - lock_kernel(); -+#endif - if (minor == ISDN_MINOR_STATUS) { -- infostruct *p = dev->infochain; -- infostruct *q = NULL; -- -- while (p) { -- if (p->private == (char *) &(filep->private_data)) { -- if (q) -- q->next = p->next; -- else -- dev->infochain = (infostruct *) (p->next); -- kfree(p); -- goto out; -- } -- q = p; -- p = (infostruct *) (p->next); -- } -- printk(KERN_WARNING "isdn: No private data while closing isdnctrl\n"); -- goto out; -+ isdnstatus_close(ino, filep); - } - isdn_unlock_drivers(); - if (minor <= ISDN_MINOR_BMAX) -@@ -1741,6 +1878,12 @@ isdn_close(struct inode *ino, struct fil - if (minor <= ISDN_MINOR_CTRLMAX) { - if (dev->profd == current) - dev->profd = NULL; -+#ifdef CONFIG_ISDN_WITH_ABC_LCR_SUPPORT -+ { -+ int drvidx = isdn_minor2drv(minor - ISDN_MINOR_CTRL); -+ if(!drvidx) isdn_dw_abc_lcr_close(); -+ } -+#endif - goto out; - } - #ifdef CONFIG_ISDN_PPP -@@ -1749,13 +1892,19 @@ isdn_close(struct inode *ino, struct fil - #endif - - out: -+#ifdef COMPAT_USE_MODCOUNT_LOCK -+ MOD_DEC_USE_COUNT; -+#else - unlock_kernel(); -+#endif - return 0; - } - - static struct file_operations isdn_fops = - { -+#ifdef COMPAT_HAS_FILEOP_OWNER - owner: THIS_MODULE, -+#endif - llseek: no_llseek, - read: isdn_read, - write: isdn_write, -@@ -1808,6 +1957,15 @@ isdn_get_free_channel(int usage, int l2_ - if (USG_NONE(dev->usage[i]) && - (dev->drvmap[i] != -1)) { - int d = dev->drvmap[i]; -+#ifdef CONFIG_ISDN_WITH_ABC_CH_EXTINUSE -+ if(jiffies < dev->dwabc_chan_external_inuse[i]) { -+ -+ if((dev->dwabc_chan_external_inuse[i] - jiffies) > (HZ * 120)) -+ dev->dwabc_chan_external_inuse[i] = 0; -+ else -+ continue; -+ } -+#endif - if ((dev->usage[i] & ISDN_USAGE_EXCLUSIVE) && - ((pre_dev != d) || (pre_chan != dev->chanmap[i]))) - continue; -@@ -1826,7 +1984,11 @@ isdn_get_free_channel(int usage, int l2_ - restore_flags(flags); - return i; - } else { -+#ifdef CONFIG_ISDN_WITH_ABC -+ if ((pre_dev == d) && ((pre_chan == dev->chanmap[i]) || pre_chan > 1000)) { -+#else - if ((pre_dev == d) && (pre_chan == dev->chanmap[i])) { -+#endif - dev->usage[i] &= ISDN_USAGE_EXCLUSIVE; - dev->usage[i] |= usage; - isdn_info_update(); -@@ -2013,7 +2175,7 @@ isdn_add_channels(driver *d, int drvidx, - - if ((adding) && (d->rcverr)) - kfree(d->rcverr); -- if (!(d->rcverr = kmalloc(sizeof(int) * m, GFP_KERNEL))) { -+ if (!(d->rcverr = (int *) kmalloc(sizeof(int) * m, GFP_KERNEL))) { - printk(KERN_WARNING "register_isdn: Could not alloc rcverr\n"); - return -1; - } -@@ -2021,7 +2183,7 @@ isdn_add_channels(driver *d, int drvidx, - - if ((adding) && (d->rcvcount)) - kfree(d->rcvcount); -- if (!(d->rcvcount = kmalloc(sizeof(int) * m, GFP_KERNEL))) { -+ if (!(d->rcvcount = (int *) kmalloc(sizeof(int) * m, GFP_KERNEL))) { - printk(KERN_WARNING "register_isdn: Could not alloc rcvcount\n"); - if (!adding) kfree(d->rcverr); - return -1; -@@ -2033,7 +2195,8 @@ isdn_add_channels(driver *d, int drvidx, - skb_queue_purge(&d->rpqueue[j]); - kfree(d->rpqueue); - } -- if (!(d->rpqueue = kmalloc(sizeof(struct sk_buff_head) * m, GFP_KERNEL))) { -+ if (!(d->rpqueue = -+ (struct sk_buff_head *) kmalloc(sizeof(struct sk_buff_head) * m, GFP_KERNEL))) { - printk(KERN_WARNING "register_isdn: Could not alloc rpqueue\n"); - if (!adding) { - kfree(d->rcvcount); -@@ -2047,7 +2210,8 @@ isdn_add_channels(driver *d, int drvidx, - - if ((adding) && (d->rcv_waitq)) - kfree(d->rcv_waitq); -- d->rcv_waitq = kmalloc(sizeof(wait_queue_head_t) * 2 * m, GFP_KERNEL); -+ d->rcv_waitq = (wait_queue_head_t *) -+ kmalloc(sizeof(wait_queue_head_t) * 2 * m, GFP_KERNEL); - if (!d->rcv_waitq) { - printk(KERN_WARNING "register_isdn: Could not alloc rcv_waitq\n"); - if (!adding) { -@@ -2071,7 +2235,9 @@ isdn_add_channels(driver *d, int drvidx, - if (dev->chanmap[k] < 0) { - dev->chanmap[k] = j; - dev->drvmap[k] = drvidx; -+#ifdef HAVE_DEVFS_FS - isdn_register_devfs(k); -+#endif /* HAVE_DEVFS_FS */ - break; - } - restore_flags(flags); -@@ -2135,6 +2301,7 @@ int DIVERT_REG_NAME(isdn_divert_if *i_di - i_div->ll_cmd = isdn_command; /* set command function */ - i_div->drv_to_name = map_drvname; - i_div->name_to_drv = map_namedrv; -+ i_div->dial_net_name = isdn_net_force_dial; - MOD_INC_USE_COUNT; - divert_if = i_div; /* remember interface */ - return(DIVERT_NO_ERR); -@@ -2172,7 +2339,7 @@ register_isdn(isdn_if * i) - printk(KERN_WARNING "register_isdn: No write routine given.\n"); - return 0; - } -- if (!(d = kmalloc(sizeof(driver), GFP_KERNEL))) { -+ if (!(d = (driver *) kmalloc(sizeof(driver), GFP_KERNEL))) { - printk(KERN_WARNING "register_isdn: Could not alloc driver-struct\n"); - return 0; - } -@@ -2232,6 +2399,7 @@ isdn_getrev(const char *revision) - return rev; - } - -+#ifdef HAVE_DEVFS_FS - #ifdef CONFIG_DEVFS_FS - - static devfs_handle_t devfs_handle; -@@ -2321,6 +2489,7 @@ static void isdn_cleanup_devfs(void) - } - - #endif /* CONFIG_DEVFS_FS */ -+#endif /* HAVE_DEVFS_FS */ - - /* - * Allocate and initialize all data, register modem-devices -@@ -2338,7 +2507,6 @@ static int __init isdn_init(void) - init_timer(&dev->timer); - dev->timer.function = isdn_timer_funct; - init_MUTEX(&dev->sem); -- init_waitqueue_head(&dev->info_waitq); - for (i = 0; i < ISDN_MAX_CHANNELS; i++) { - dev->drvmap[i] = -1; - dev->chanmap[i] = -1; -@@ -2352,7 +2520,9 @@ static int __init isdn_init(void) - vfree(dev); - return -EIO; - } -+#ifdef HAVE_DEVFS_FS - isdn_init_devfs(); -+#endif /* HAVE_DEVFS_FS */ - if ((i = isdn_tty_modem_init()) < 0) { - printk(KERN_WARNING "isdn: Could not register tty devices\n"); - if (i == -3) -@@ -2360,7 +2530,9 @@ static int __init isdn_init(void) - if (i <= -2) - tty_unregister_driver(&dev->mdm.tty_modem); - vfree(dev); -+#ifdef HAVE_DEVFS_FS - isdn_cleanup_devfs(); -+#endif /* HAVE_DEVFS_FS */ - devfs_unregister_chrdev(ISDN_MAJOR, "isdn"); - return -EIO; - } -@@ -2371,7 +2543,9 @@ static int __init isdn_init(void) - tty_unregister_driver(&dev->mdm.cua_modem); - for (i = 0; i < ISDN_MAX_CHANNELS; i++) - kfree(dev->mdm.info[i].xmit_buf - 4); -+#ifdef HAVE_DEVFS_FS - isdn_cleanup_devfs(); -+#endif /* HAVE_DEVFS_FS */ - devfs_unregister_chrdev(ISDN_MAJOR, "isdn"); - vfree(dev); - return -EIO; -@@ -2397,6 +2571,9 @@ static int __init isdn_init(void) - printk("\n"); - #endif - isdn_info_update(); -+#ifdef CONFIG_ISDN_WITH_ABC -+ isdn_dw_abc_init_func(); -+#endif - return 0; - } - -@@ -2405,7 +2582,7 @@ static int __init isdn_init(void) - */ - static void __exit isdn_exit(void) - { -- unsigned long flags; -+ int flags; - int i; - - #ifdef CONFIG_ISDN_PPP -@@ -2439,13 +2616,18 @@ static void __exit isdn_exit(void) - printk(KERN_WARNING "isdn: controldevice busy, remove cancelled\n"); - restore_flags(flags); - } else { -+#ifdef HAVE_DEVFS_FS - isdn_cleanup_devfs(); -+#endif /* HAVE_DEVFS_FS */ - del_timer(&dev->timer); - restore_flags(flags); - /* call vfree with interrupts enabled, else it will hang */ - vfree(dev); - printk(KERN_NOTICE "ISDN-subsystem unloaded\n"); - } -+#ifdef CONFIG_ISDN_WITH_ABC -+ isdn_dw_abc_release_func(); -+#endif - } - - module_init(isdn_init); ---- a/drivers/isdn/isdn_common.h -+++ b/drivers/isdn/isdn_common.h -@@ -1,4 +1,4 @@ --/* $Id: isdn_common.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: isdn_common.h,v 1.22 2001/09/24 13:22:42 kai Exp $ - * - * header for Linux ISDN subsystem - * common used functions and debugging-switches (linklevel). -@@ -24,6 +24,9 @@ - #undef ISDN_DEBUG_NET_DIAL - #undef ISDN_DEBUG_NET_ICALL - -+#ifdef CONFIG_ISDN_WITH_ABC -+int isdn_net_force_dial_lp(isdn_net_local *); -+#endif - /* Prototypes */ - extern void isdn_MOD_INC_USE_COUNT(void); - extern void isdn_MOD_DEC_USE_COUNT(void); ---- a/drivers/isdn/isdn_concap.c -+++ b/drivers/isdn/isdn_concap.c -@@ -1,4 +1,4 @@ --/* $Id: isdn_concap.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: isdn_concap.c,v 1.9 2001/09/24 13:22:42 kai Exp $ - * - * Linux ISDN subsystem, protocol encapsulation - * ---- a/drivers/isdn/isdn_concap.h -+++ b/drivers/isdn/isdn_concap.h -@@ -1,4 +1,4 @@ --/* $Id: isdn_concap.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: isdn_concap.h,v 1.4 2001/09/24 13:22:42 kai Exp $ - * - * Linux ISDN subsystem, protocol encapsulation - * ---- /dev/null -+++ b/drivers/isdn/isdn_dwabc.c -@@ -0,0 +1,1053 @@ -+ -+/* $Id: isdn_dwabc.c,v 1.27 2001/12/01 23:18:21 detabc Exp $ -+ -+ * Linux ISDN subsystem, abc-extension releated funktions. -+ * -+ * Copyright by abc GmbH -+ * written by Detlef Wengorz <detlefw@isdn4linux.de> -+ * -+ * 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, or (at your option) -+ * any later version. -+ * -+ */ -+ -+#include <linux/config.h> -+#define __NO_VERSION__ -+ -+#ifdef CONFIG_ISDN_WITH_ABC -+ -+static char *dwabcrevison = "$Revision: 1.27 $"; -+ -+#include <asm/semaphore.h> -+#define CONFIG_ISDN_WITH_ABC_NEED_DWSJIFFIES 1 -+#include <linux/list.h> -+#include <linux/isdn.h> -+#include "isdn_common.h" -+#include "isdn_net.h" -+ -+#include <linux/skbuff.h> -+ -+#include <net/udp.h> -+#include <net/checksum.h> -+#include <linux/isdn_dwabc.h> -+ -+ -+#if CONFIG_ISDN_WITH_ABC_RAWIPCOMPRESS && CONFIG_ISDN_PPP -+#include <linux/isdn_ppp.h> -+extern struct isdn_ppp_compressor *isdn_ippp_comp_head; -+#define ipc_head isdn_ippp_comp_head -+#ifndef CI_BSD_COMPRESS -+#define CI_BSD_COMPRESS 21 -+#endif -+#endif -+ -+#define NBYTEORDER_30BYTES 0x1e00 -+#define DWABC_TMRES (HZ / 10) -+ -+#define VERBLEVEL (dev->net_verbose > 2) -+ -+static struct timer_list dw_abc_timer; -+ -+ -+#ifdef CONFIG_ISDN_WITH_ABC_LCR_SUPPORT -+static ISDN_DWSPINLOCK lcr_spin = ISDN_DWSPIN_UNLOCKED; -+#define LCR_LOCK() isdn_dwspin_trylock(&lcr_spin) -+#define LCR_ULOCK() isdn_dwspin_unlock(&lcr_spin) -+ -+typedef struct ISDN_DW_ABC_LCR { -+ -+ struct list_head dll; -+ char lcr_printbuf[64 + ISDN_MSNLEN + ISDN_MSNLEN]; -+ char *lcr_poin; -+ char *lcr_epoin; -+ -+} ISDN_DW_ABC_LCR; -+ -+static LIST_HEAD(lcr_dll); -+static atomic_t lcr_open_count = ATOMIC_INIT(0); -+static volatile ulong lcr_call_counter = 0; -+ -+ -+static int myjiftime(char *p,u_long nj) -+{ -+ sprintf(p,"%02ld:%02ld.%02ld", -+ ((nj / 100) / 60) % 100, (nj / 100) % 60,nj % 100); -+ -+ return(8); -+} -+ -+ -+static void dw_lcr_clear_all(void) -+{ -+ struct list_head *lh; -+ -+ if(!LCR_LOCK()) { -+ -+ while((lh = lcr_dll.next) != &lcr_dll) { -+ -+ ISDN_DW_ABC_LCR *p = list_entry(lh,ISDN_DW_ABC_LCR,dll); -+ list_del(&p->dll); -+ kfree(p); -+ } -+ -+ LCR_ULOCK(); -+ } -+} -+ -+void isdn_dw_abc_lcr_open(void) -+{ atomic_inc(&lcr_open_count); } -+ -+void isdn_dw_abc_lcr_close(void) -+{ -+ if(atomic_dec_and_test(&lcr_open_count)) -+ dw_lcr_clear_all(); -+} -+ -+int isdn_dw_abc_lcr_lock(void) -+{ return(LCR_LOCK()); } -+ -+void isdn_dw_abc_lcr_ulock(void) -+{ LCR_ULOCK(); } -+ -+ -+size_t isdn_dw_abc_lcr_readstat(char *buf,size_t count) -+{ -+ size_t retw = 0; -+ -+ while(buf != NULL && count > 0) { -+ -+ struct list_head *lh = NULL; -+ ISDN_DW_ABC_LCR *p = NULL; -+ char *dp = NULL; -+ size_t n; -+ -+ if((n = LCR_LOCK())) { -+ -+ if(!retw) -+ retw = n; -+ -+ break; -+ } -+ -+ -+ while((lh = lcr_dll.next) != &lcr_dll) { -+ -+ p = list_entry(lh,ISDN_DW_ABC_LCR,dll); -+ -+ if(p->lcr_poin >= p->lcr_epoin) { -+ -+ list_del(&p->dll); -+ kfree(p); -+ p = NULL; -+ -+ } else break; -+ } -+ -+ if(p == NULL) { -+ -+ LCR_ULOCK(); -+ break; -+ } -+ -+ n = p->lcr_epoin - p->lcr_poin; -+ -+ if(n > count) -+ n = count; -+ -+ dp = p->lcr_poin; -+ p->lcr_poin += n; -+ retw += n; -+ LCR_ULOCK(); -+ copy_to_user(buf,dp,n); -+ buf += n; -+ } -+ -+ return(retw); -+} -+ -+ -+static void isdn_dw_abc_lcr_clear_helper(isdn_net_local *lp) -+{ -+ if(lp != NULL) { -+ -+ void *a,*b; -+ -+ a = lp->dw_abc_lcr_cmd; -+ b = lp->dw_abc_lcr_io; -+ lp->dw_abc_lcr_io = NULL; -+ lp->dw_abc_lcr_cmd = NULL; -+ lp->dw_abc_lcr_callid = -+ lp->dw_abc_lcr_start_request = -+ lp->dw_abc_lcr_end_request = 0; -+ -+ if(a) kfree(a); -+ if(b) kfree(b); -+ } -+} -+ -+void isdn_dw_abc_lcr_clear(isdn_net_local *lp) -+{ -+ if(!LCR_LOCK()) { -+ isdn_dw_abc_lcr_clear_helper(lp); -+ LCR_ULOCK(); -+ } -+} -+ -+ -+u_long isdn_dw_abc_lcr_call_number( isdn_net_local *lp,isdn_ctrl *call_cmd) -+{ -+ u_long mid = 0; -+ -+ if(LCR_LOCK()) -+ return(0); -+ -+ isdn_dw_abc_lcr_clear_helper(lp); -+ -+ if( atomic_read(&lcr_open_count) > 0 && -+ lp != NULL && -+ call_cmd != NULL) { -+ -+ ISDN_DW_ABC_LCR *lc = NULL; -+ int ab = 0; -+ -+ if((lp->dw_abc_lcr_cmd = -+ ( isdn_ctrl *)kmalloc(sizeof(isdn_ctrl),GFP_ATOMIC)) == NULL) { -+ -+no_mem_out:; -+ isdn_dw_abc_lcr_clear_helper(lp); -+ LCR_ULOCK(); -+ printk(KERN_DEBUG "%s %d : LCR no memory\n",__FILE__,__LINE__); -+ return(0); -+ } -+ -+ memcpy(lp->dw_abc_lcr_cmd,call_cmd,sizeof(*call_cmd)); -+ while(!(lp->dw_abc_lcr_callid = mid = lcr_call_counter++)); -+ -+ lp->dw_abc_lcr_end_request = lp->dw_abc_lcr_start_request = jiffies; -+ lp->dw_abc_lcr_end_request += HZ * 3; -+ -+ if((lc = (ISDN_DW_ABC_LCR *)kmalloc(sizeof(*lc),GFP_KERNEL)) == NULL) -+ goto no_mem_out; -+ -+ lc->lcr_poin = lc->lcr_epoin = lc->lcr_printbuf; -+ lc->lcr_epoin += myjiftime(lc->lcr_epoin,jiffies); -+ -+ sprintf(lc->lcr_epoin," DW_ABC_LCR\t%lu\t%.*s\t%.*s\n", -+ mid, -+ (int)ISDN_MSNLEN, -+ call_cmd->parm.setup.eazmsn, -+ (int)ISDN_MSNLEN, -+ call_cmd->parm.setup.phone); -+ -+ lc->lcr_epoin += strlen(lc->lcr_epoin); -+ ab = lc->lcr_epoin - lc->lcr_poin; -+ -+ list_add_tail(&lc->dll,&lcr_dll); -+ LCR_ULOCK(); -+ -+ if(ab > 0) { -+ -+ if(dev->drv[0] != NULL ) { -+ -+ dev->drv[0]->stavail += ab; -+ wake_up_interruptible(&dev->drv[0]->st_waitq); -+ } -+ } -+ -+ } else LCR_ULOCK(); -+ -+ return(mid); -+} -+ -+ -+int isdn_dw_abc_lcr_ioctl(u_long arg) -+{ -+ struct ISDN_DWABC_LCR_IOCTL i; -+ int need = sizeof(struct ISDN_DWABC_LCR_IOCTL); -+ isdn_net_dev *p; -+ -+ memset(&i,0,sizeof(struct ISDN_DWABC_LCR_IOCTL)); -+ copy_from_user(&i,(char *)arg,sizeof(int)); -+ -+ if(i.lcr_ioctl_sizeof < need) -+ need = i.lcr_ioctl_sizeof; -+ -+ if(need > 0) -+ copy_from_user(&i,(char *)arg,need); -+ -+ if(LCR_LOCK()) -+ return(-EAGAIN); -+ -+ p = dev->netdev; -+ -+ for(;p ; p = p->next) { -+ -+ isdn_net_local *lp = p->local; -+ -+ if( lp->dw_abc_lcr_callid != i.lcr_ioctl_callid) -+ continue; -+ -+ if(lp->dw_abc_lcr_cmd == NULL) -+ continue; -+ -+ if(lp->dw_abc_lcr_io == NULL) -+ lp->dw_abc_lcr_io = (struct ISDN_DWABC_LCR_IOCTL *) -+ kmalloc(sizeof(struct ISDN_DWABC_LCR_IOCTL),GFP_ATOMIC); -+ -+ if(lp->dw_abc_lcr_io == NULL) { -+ -+ printk(KERN_DEBUG "%s %d : no memory\n",__FILE__,__LINE__); -+ continue; -+ } -+ -+ memcpy(lp->dw_abc_lcr_io,&i,sizeof(struct ISDN_DWABC_LCR_IOCTL)); -+ -+ if(i.lcr_ioctl_flags & DWABC_LCR_FLG_NEWNUMBER) { -+ -+ char *xx = i.lcr_ioctl_nr; -+ char *exx = xx + sizeof(i.lcr_ioctl_nr); -+ char *d = lp->dw_abc_lcr_cmd->parm.setup.phone; -+ char *ed = d + sizeof(lp->dw_abc_lcr_cmd->parm.setup.phone) - 1; -+ -+ while(d < ed && xx < exx && *xx) *(d++) = *(xx++); -+ while(d < ed) *(d++) = 0; -+ *d = 0; -+ } -+ } -+ -+ LCR_ULOCK(); -+ return(0); -+} -+ -+#endif -+ -+ -+#ifdef CONFIG_ISDN_WITH_ABC_UDP_CHECK -+int dw_abc_udp_test(struct sk_buff *skb,struct net_device *ndev) -+{ -+ if(ndev != NULL && skb != NULL && skb->protocol == htons(ETH_P_IP)) { -+ -+ struct iphdr *iph = (struct iphdr *)skb->data; -+ isdn_net_local *lp = (isdn_net_local *) ndev->priv; -+ int rklen = skb->len; -+ -+ if (skb->nh.raw > skb->data && skb->nh.raw < skb->tail) { -+ -+ rklen -= (char *)skb->nh.raw - (char *)skb->data; -+ iph = (struct iphdr *)skb->nh.raw; -+ } -+ -+ if(rklen >= 20 && iph->version == 4 && -+ !(lp->dw_abc_flags & ISDN_DW_ABC_FLAG_NO_UDP_CHECK)) { -+ -+ if( iph->tot_len == NBYTEORDER_30BYTES && -+ iph->protocol == IPPROTO_UDP) { -+ -+ struct udphdr *udp = -+ (struct udphdr *)((char *)iph + (iph->ihl << 2)); -+ -+ ushort usrc = ntohs(udp->source); -+ -+ if( udp->dest == htons(25001) && -+ usrc >= 20000 && usrc < 25000) { -+ -+ char *p = (char *)(udp + 1); -+ -+ if(p[0] == p[1]) { -+ -+ char mc = 0; -+ -+ switch(*p) { -+ case 0x30: -+ -+ mc = *p; -+ -+ if((lp->flags & ISDN_NET_CONNECTED) && (!lp->dialstate)) -+ mc++; -+ -+ break; -+ -+ case 0x32: -+ -+ mc = *p; -+#ifdef CONFIG_ISDN_WITH_ABC_UDP_CHECK_DIAL -+ if((lp->flags & ISDN_NET_CONNECTED) && (!lp->dialstate)) { -+ -+ mc++; -+ break; -+ } -+ -+ if(!isdn_net_force_dial_lp(lp)) mc++; -+#endif -+ break; -+ -+ case 0x11: -+ mc = *p + 1; -+ isdn_dw_abc_reset_interface(lp,1); -+ break; -+ -+ case 0x28: mc = *p + 1; break; -+ case 0x2a: -+ case 0x2c: -+ -+ mc = *p; -+#ifdef CONFIG_ISDN_WITH_ABC_UDP_CHECK_HANGUP -+ if(!(lp->dw_abc_flags & ISDN_DW_ABC_FLAG_NO_UDP_HANGUP)) { -+ -+ if(lp->isdn_device >= 0) { -+ -+ isdn_net_hangup(ndev); -+ mc = *p + 1; -+ } -+ } -+#endif -+ break; -+ } -+ -+ if(mc) { -+ -+ struct sk_buff *nskb; -+ int need = 2+sizeof(struct iphdr)+sizeof(struct udphdr); -+ int hneed = need + ndev->hard_header_len; -+ -+ if((nskb = (struct sk_buff *)dev_alloc_skb(hneed)) != NULL) { -+ -+ ushort n = sizeof(struct udphdr) + 2; -+ struct iphdr *niph; -+ struct udphdr *nup; -+ skb_reserve(nskb,ndev->hard_header_len); -+ -+ if((niph = (struct iphdr *)skb_put(nskb,need))==NULL){ -+ -+ printk(KERN_DEBUG "%s: skb_put failt (%d bytes)\n", lp->name,hneed); -+ dev_kfree_skb(nskb); -+ return(0); -+ } -+ -+ nup = (struct udphdr *)(niph + 1); -+ ((char *)(nup + 1))[0] = mc; -+ ((char *)(nup + 1))[1] = mc; -+ nup->source=udp->dest; -+ nup->dest=udp->source; -+ nup->len=htons(n); -+ nup->check=0; /* dont need checksum */ -+ memset((void *)niph,0,sizeof(*niph)); -+ niph->version=4; -+ niph->ihl=5; -+ niph->tot_len=NBYTEORDER_30BYTES; -+ niph->ttl = 32; -+ niph->protocol = IPPROTO_UDP; -+ niph->saddr=iph->daddr; -+ niph->daddr=iph->saddr; -+ niph->id=iph->id; -+ niph->check=ip_fast_csum((unsigned char *)niph,niph->ihl); -+ nskb->dev = ndev; -+ nskb->pkt_type = PACKET_HOST; -+ nskb->protocol = htons(ETH_P_IP); -+ nskb->mac.raw = nskb->data; -+ netif_rx(nskb); -+ } -+ -+ return(1); -+ } -+ } -+ } -+ } -+ } -+ } -+ -+ return(0); -+} -+#endif -+ -+ -+void isdn_dw_clear_if(ulong pm,isdn_net_local *lp) -+{ -+ if(lp != NULL) { -+#ifdef CONFIG_ISDN_WITH_ABC_LCR_SUPPORT -+ isdn_dw_abc_lcr_clear(lp); -+#endif -+ } -+} -+ -+ -+ -+static void dw_abc_timer_func(u_long dont_need_yet) -+{ -+ register u_long t; -+ -+ if(!((t = ++isdn_dwabc_jiffies.msec_100) & 1)) -+ if(isdn_dwabc_jiffies.msec_200++ & 1) -+ isdn_dwabc_jiffies.msec_400++; -+ -+ if(!(t % 5)) -+ if(isdn_dwabc_jiffies.msec_500++ & 1) -+ isdn_dwabc_jiffies.msec_1000++; -+ -+ dw_abc_timer.expires = jiffies + DWABC_TMRES; -+ add_timer(&dw_abc_timer); -+} -+ -+ -+void isdn_dw_abc_init_func(void) -+{ -+ -+ init_timer(&dw_abc_timer); -+ dw_abc_timer.function = dw_abc_timer_func; -+ -+ -+ printk( KERN_INFO -+ "abc-extension %s Kernel 0x%06X\n" -+ "written by\nDetlef Wengorz <detlefw@isdn4linux.de>\n" -+ "Installed options:\n" -+#ifdef CONFIG_ISDN_WITH_ABC_CALLB -+ "CONFIG_ISDN_WITH_ABC_CALLB\n" -+#endif -+#ifdef CONFIG_ISDN_WITH_ABC_UDP_CHECK -+ "CONFIG_ISDN_WITH_ABC_UDP_CHECK\n" -+#endif -+#ifdef CONFIG_ISDN_WITH_ABC_UDP_CHECK_HANGUP -+ "CONFIG_ISDN_WITH_ABC_UDP_CHECK_HANGUP\n" -+#endif -+#ifdef CONFIG_ISDN_WITH_ABC_UDP_CHECK_DIAL -+ "CONFIG_ISDN_WITH_ABC_UDP_CHECK_DIAL\n" -+#endif -+#ifdef CONFIG_ISDN_WITH_ABC_OUTGOING_EAZ -+ "CONFIG_ISDN_WITH_ABC_OUTGOING_EAZ\n" -+#endif -+#ifdef CONFIG_ISDN_WITH_ABC_LCR_SUPPORT -+ "CONFIG_ISDN_WITH_ABC_LCR_SUPPORT\n" -+#endif -+#ifdef CONFIG_ISDN_WITH_ABC_RCV_NO_HUPTIMER -+ "CONFIG_ISDN_WITH_ABC_RCV_NO_HUPTIMER\n" -+#endif -+#ifdef CONFIG_ISDN_WITH_ABC_CH_EXTINUSE -+ "CONFIG_ISDN_WITH_ABC_CH_EXTINUSE\n" -+#endif -+#ifdef CONFIG_ISDN_WITH_ABC_CONN_ERROR -+ "CONFIG_ISDN_WITH_ABC_CONN_ERROR\n" -+#endif -+#ifdef CONFIG_ISDN_WITH_ABC_RAWIPCOMPRESS -+ "CONFIG_ISDN_WITH_ABC_RAWIPCOMPRESS\n" -+#endif -+ "loaded\n", -+ dwabcrevison,LINUX_VERSION_CODE); -+ dwsjiffies = 0; -+ dw_abc_timer.expires = jiffies + DWABC_TMRES; -+ add_timer(&dw_abc_timer); -+} -+ -+void isdn_dw_abc_release_func(void) -+{ -+ del_timer(&dw_abc_timer); -+#ifdef CONFIG_ISDN_WITH_ABC_LCR_SUPPORT -+ dw_lcr_clear_all(); -+#endif -+ printk( KERN_INFO -+ "abc-extension %s Kernel 0x%06X\n" -+ "written by\n" -+ "Detlef Wengorz <detlefw@isdn4linux.de>\n" -+ "unloaded\n", -+ dwabcrevison,LINUX_VERSION_CODE); -+} -+ -+ -+void isdn_dwabc_test_phone(isdn_net_local *lp) -+{ -+ if(lp != NULL) { -+ -+ isdn_net_phone *h = lp->phone[0]; -+ ulong oflags = lp->dw_abc_flags; -+ int secure = 0; -+ -+ lp->dw_abc_flags = 0; -+#ifdef CONFIG_ISDN_WITH_ABC_OUTGOING_EAZ -+ *lp->dw_out_msn = 0; -+#endif -+ -+ for(;h != NULL && secure < 1000;secure++,h = h->next) { -+ -+ char *p = h->num; -+ char *ep = p + ISDN_MSNLEN; -+ -+ for(;p < ep && *p && (*p <= ' ' || *p == '"' || *p == '\'');p++); -+ -+ if(p >= ep) -+ continue; -+ -+#ifdef CONFIG_ISDN_WITH_ABC_OUTGOING_EAZ -+ if(*p == '>') { -+ -+ if(++p < ep && *p != '<' && *p != '>') { -+ -+ char *d = lp->dw_out_msn; -+ -+ for(;*p && (p < ep) && (*p == ' ' || *p == '\t');p++); -+ for(ep--;*p && (p < ep);) *(d++) = *(p++); -+ *d = 0; -+ continue; -+ } -+ } -+#endif -+ -+ if(*p == '~') { -+ -+ /* abc switch's */ -+ -+ for(p++;p < ep && *p;p++) switch(*p) { -+ case 'u': lp->dw_abc_flags |= ISDN_DW_ABC_FLAG_NO_UDP_CHECK; break; -+ case 'h': lp->dw_abc_flags |= ISDN_DW_ABC_FLAG_NO_UDP_HANGUP; break; -+ case 'd': lp->dw_abc_flags |= ISDN_DW_ABC_FLAG_NO_UDP_DIAL; break; -+ case 'c': lp->dw_abc_flags |= ISDN_DW_ABC_FLAG_NO_CH_EXTINUSE; break; -+ case 'e': lp->dw_abc_flags |= ISDN_DW_ABC_FLAG_NO_CONN_ERROR; break; -+ case 'l': lp->dw_abc_flags |= ISDN_DW_ABC_FLAG_NO_LCR; break; -+ -+ case 'x': -+ case 'X': lp->dw_abc_flags |= ISDN_DW_ABC_FLAG_RCV_NO_HUPTIMER; break; -+ -+ case 'B': lp->dw_abc_flags |= ISDN_DW_ABC_FLAG_BSD_COMPRESS; break; -+ case 'L': lp->dw_abc_flags |= ISDN_DW_ABC_FLAG_LEASED_LINE; break; -+ -+ case '"': -+ case ' ': -+ case '\t': -+ case '\'': break; -+ -+ default: -+ printk(KERN_DEBUG"isdn_net: %s abc-switch <~%c> unknown\n",lp->name,*p); -+ break; -+ } -+ } -+ } -+ -+ if(lp->dw_abc_flags & ISDN_DW_ABC_FLAG_LEASED_LINE) { -+ -+ lp->dw_abc_flags |= -+ ISDN_DW_ABC_FLAG_NO_UDP_CHECK | -+ ISDN_DW_ABC_FLAG_NO_UDP_HANGUP | -+ ISDN_DW_ABC_FLAG_NO_UDP_DIAL | -+ ISDN_DW_ABC_FLAG_NO_CH_EXTINUSE | -+ ISDN_DW_ABC_FLAG_NO_CONN_ERROR | -+ ISDN_DW_ABC_FLAG_NO_LCR; -+ } -+ -+ if(dev->net_verbose && (lp->dw_abc_flags != oflags || dev->net_verbose > 4)) -+ printk(KERN_DEBUG "isdn_net %s abc-flags 0x%lx\n",lp->name,lp->dw_abc_flags); -+ -+ } -+} -+ -+ -+int isdn_dw_abc_reset_interface(isdn_net_local *lp,int with_message) -+{ -+ int r = -EINVAL; -+ -+ if(lp != NULL) { -+ -+ r = 0; -+ -+ lp->dw_abc_bchan_last_connect = 0; -+ lp->dw_abc_dialstart = 0; -+ lp->dw_abc_inuse_secure = 0; -+#ifdef CONFIG_ISDN_WITH_ABC_CONN_ERROR -+ lp->dw_abc_bchan_errcnt = 0; -+#endif -+ -+ if(with_message && dev->net_verbose > 0) -+ printk(KERN_INFO -+ "%s: NOTE: reset (clear) abc-interface-secure-counter\n", -+ lp->name); -+ } -+ -+ return(r); -+} -+ -+ -+#if CONFIG_ISDN_WITH_ABC_RAWIPCOMPRESS && CONFIG_ISDN_PPP -+ -+#define DWBSD_PKT_FIRST_LEN 16 -+#define DWBSD_PKT_SWITCH 165 -+#define DWBSD_PKT_BSD 189 -+ -+#define DWBSD_VERSION 0x2 -+ -+void dwabc_bsd_first_gen(isdn_net_local *lp) -+{ -+ if(lp != NULL && lp->p_encap == ISDN_NET_ENCAP_RAWIP && -+ (lp->dw_abc_flags & ISDN_DW_ABC_FLAG_BSD_COMPRESS)) { -+ -+ struct sk_buff *skb = NULL; -+ char *p = NULL; -+ char *ep = NULL; -+ -+ if((skb =(struct sk_buff *)dev_alloc_skb(128)) == NULL) { -+ -+ printk(KERN_INFO "%s: dwabc: alloc-skb failed for 128 bytes\n",lp->name); -+ return; -+ } -+ -+ skb_reserve(skb,64); -+ p = skb_put(skb,DWBSD_PKT_FIRST_LEN); -+ ep = p + DWBSD_PKT_FIRST_LEN; -+ -+ *(p++) = DWBSD_PKT_SWITCH; -+ *(p++) = DWBSD_VERSION; -+ for(;p < ep;p++) *(p++) = 0; -+ -+ isdn_net_write_super(lp, skb); -+ -+ if(dev->net_verbose > 2) -+ printk(KERN_INFO "%s: dwabc: sending comm-header version 0x%x\n",lp->name,DWBSD_VERSION); -+ } -+} -+ -+ -+void dwabc_bsd_free(isdn_net_local *lp) -+{ -+ if(lp != NULL) { -+ -+ if(lp->dw_abc_bsd_stat_rx || lp->dw_abc_bsd_stat_tx) { -+ -+ struct isdn_ppp_compressor *c = NULL; -+ -+ if(!(c = (struct isdn_ppp_compressor *)lp->dw_abc_bsd_compressor)) { -+ -+ printk(KERN_WARNING -+ "%s: PANIC: freeing bsd compressmemory without compressor\n", -+ lp->name); -+ -+ } else { -+ -+ if(lp->dw_abc_bsd_stat_rx) (*c->free)(lp->dw_abc_bsd_stat_rx); -+ if(lp->dw_abc_bsd_stat_tx) (*c->free)(lp->dw_abc_bsd_stat_tx); -+ -+ if(dev->net_verbose > 2) -+ printk(KERN_INFO -+ "%s: free bsd compress-memory\n", -+ lp->name); -+ } -+ } -+ -+ lp->dw_abc_bsd_compressor = NULL; -+ lp->dw_abc_bsd_stat_rx = NULL; -+ lp->dw_abc_bsd_stat_tx = NULL; -+ lp->dw_abc_if_flags &= ~ISDN_DW_ABC_IFFLAG_BSDAKTIV; -+ -+ if(dev->net_verbose > 0) { -+ -+ if(lp->dw_abc_bsd_rcv != lp->dw_abc_bsd_bsd_rcv) { -+ -+ printk(KERN_INFO "%s: Receive %lu<-%lu kb\n",lp->name, -+ lp->dw_abc_bsd_rcv >> 10 , lp->dw_abc_bsd_bsd_rcv >> 10); -+ } -+ -+ -+ if(lp->dw_abc_bsd_snd != lp->dw_abc_bsd_bsd_snd) { -+ -+ printk(KERN_INFO "%s: Send %lu->%lu kb\n",lp->name, -+ lp->dw_abc_bsd_snd >> 10 , lp->dw_abc_bsd_bsd_snd >> 10); -+ } -+ } -+ -+ lp->dw_abc_bsd_rcv = -+ lp->dw_abc_bsd_bsd_rcv = -+ lp->dw_abc_bsd_snd = -+ lp->dw_abc_bsd_bsd_snd = 0; -+ } -+} -+ -+ -+int dwabc_bsd_init(isdn_net_local *lp) -+{ -+ int r = 1; -+ -+ if(lp != NULL) { -+ -+ dwabc_bsd_free(lp); -+ -+ if(lp->p_encap == ISDN_NET_ENCAP_RAWIP) { -+ -+ void *rx = NULL; -+ void *tx = NULL; -+ struct isdn_ppp_comp_data *cp = NULL; -+ struct isdn_ppp_compressor *c = NULL; -+ -+ if(lp->dw_abc_flags & ISDN_DW_ABC_FLAG_BSD_COMPRESS) do { -+ -+ for(c = ipc_head ; -+ c != NULL && c->num != CI_BSD_COMPRESS; c = c->next); -+ -+ if(c == NULL) { -+ -+ printk(KERN_INFO -+ "%s: Module isdn_bsdcompress not loaded\n", -+ lp->name); -+ -+ break; -+ } -+ -+ cp = (struct isdn_ppp_comp_data *) -+ kmalloc(sizeof(struct isdn_ppp_comp_data),GFP_ATOMIC); -+ -+ if(cp == NULL) { -+ -+ printk(KERN_INFO -+ "%s: allocation of isdn_ppp_comp_data failed\n", -+ lp->name); -+ -+ break; -+ } -+ -+ memset(cp,0,sizeof(*cp)); -+ cp->num = CI_BSD_COMPRESS; -+ cp->optlen = 1; -+ -+ /* -+ ** set BSD_VERSION 1 and 12 bits compressmode -+ */ -+ *cp->options = (1 << 5) | 12; -+ -+ if((rx = (*c->alloc)(cp)) == NULL) { -+ -+ printk(KERN_INFO -+ "%s: allocation of bsd rx-memory failed\n", -+ lp->name); -+ -+ break; -+ } -+ -+ if(!(*c->init)(rx,cp,0,1)) { -+ -+ printk(KERN_INFO -+ "%s: init of bsd rx-stream failed\n",lp->name); -+ -+ break; -+ } -+ -+ cp->flags = IPPP_COMP_FLAG_XMIT; -+ -+ if((tx = (*c->alloc)(cp)) == NULL) { -+ -+ printk(KERN_INFO -+ "%s: allocation of bsd tx-memory failed\n", -+ lp->name); -+ -+ break; -+ } -+ -+ if(!(*c->init)(tx,cp,0,1)) { -+ -+ printk(KERN_INFO -+ "%s: init of bsd tx-stream failed\n", -+ lp->name); -+ -+ break; -+ } -+ -+ lp->dw_abc_bsd_compressor = (void *)c; -+ lp->dw_abc_bsd_stat_rx = rx; -+ lp->dw_abc_bsd_stat_tx = tx; -+ rx = tx = NULL; -+ r = 0; -+ -+ if(dev->net_verbose > 2) -+ printk(KERN_INFO -+ "%s: bsd compress-memory and init ok\n", -+ lp->name); -+ -+ } while(0); -+ -+ if(cp != NULL) -+ kfree(cp); -+ -+ if(c != NULL) { -+ -+ if(tx != NULL) (*c->free)(tx); -+ if(rx != NULL) (*c->free)(rx); -+ } -+ -+ } else if(lp->dw_abc_flags & ISDN_DW_ABC_FLAG_BSD_COMPRESS) { -+ -+ printk(KERN_INFO -+ "%s: bsd-compress only with encapsulation rawip allowed\n", -+ lp->name); -+ } -+ } -+ -+ return(r); -+} -+ -+struct sk_buff *dwabc_bsd_compress( isdn_net_local *lp, -+ struct sk_buff *skb, -+ struct net_device *ndev) -+{ -+ if(lp != NULL && lp->p_encap == ISDN_NET_ENCAP_RAWIP && -+ (lp->dw_abc_flags & ISDN_DW_ABC_FLAG_BSD_COMPRESS) && -+ (lp->dw_abc_if_flags & ISDN_DW_ABC_IFFLAG_BSDAKTIV)) { -+ -+ if(lp->dw_abc_bsd_stat_tx != NULL && lp->dw_abc_bsd_compressor) { -+ -+ struct isdn_ppp_compressor *cp = -+ (struct isdn_ppp_compressor *)lp->dw_abc_bsd_compressor; -+ -+ struct sk_buff *nskb = (struct sk_buff *) -+ dev_alloc_skb(skb->len * 2 + ndev->hard_header_len); -+ -+ int l = 0; -+ -+ if(nskb == NULL) { -+ -+ (void)(*cp->reset)(lp->dw_abc_bsd_stat_tx,0,0,NULL,0,NULL); -+ printk(KERN_INFO "%s: dwabc-compress no memory\n",lp->name); -+ -+ } else { -+ -+ skb_reserve(nskb,ndev->hard_header_len); -+ *(unsigned char *)skb_put(nskb,1) = DWBSD_PKT_BSD; -+ l = (*cp->compress)(lp->dw_abc_bsd_stat_tx,skb,nskb,0x21); -+ -+ if(l < 1 || l > skb->len) { -+ -+ (void)(*cp->reset)(lp->dw_abc_bsd_stat_tx,0,0,NULL,0,NULL); -+ dev_kfree_skb(nskb); -+ -+ } else { -+ -+ u_short sqnr; -+ -+ dev_kfree_skb(skb); -+ skb = nskb; -+ sqnr = ((*(u_char *)skb->data) << 8) + -+ ((u_char)skb->data[1]); -+ -+ if(sqnr > 65500) -+ (void)(*cp->reset) -+ (lp->dw_abc_bsd_stat_tx,0,0,NULL,0,NULL); -+ } -+ } -+ } -+ } -+ -+ return(skb); -+} -+ -+struct sk_buff *dwabc_bsd_rx_pkt( isdn_net_local *lp, -+ struct sk_buff *skb, -+ struct net_device *ndev) -+{ -+ struct sk_buff *r = skb; -+ -+ if(lp != NULL && lp->p_encap == ISDN_NET_ENCAP_RAWIP && -+ (lp->dw_abc_flags & ISDN_DW_ABC_FLAG_BSD_COMPRESS)) { -+ -+ unsigned char *p = (unsigned char *)skb->data; -+ struct isdn_ppp_compressor *cp = -+ (struct isdn_ppp_compressor *)lp->dw_abc_bsd_compressor; -+ -+ if(*p == DWBSD_PKT_SWITCH) { -+ -+ if(skb->len == DWBSD_PKT_FIRST_LEN) { -+ -+ if((lp->dw_abc_remote_version = p[1]) < 0x2) { -+ -+ printk(KERN_INFO -+ "%s: I can't really talk with remote version 0x%x\n" -+ "Please upgrade remote or disable rawip-compression\n", -+ lp->name, -+ p[1]); -+ } -+ -+ lp->dw_abc_if_flags |= ISDN_DW_ABC_IFFLAG_BSDAKTIV; -+ dev_kfree_skb(skb); -+ -+ if(cp && lp->dw_abc_bsd_stat_tx) -+ (void)(*cp->reset)(lp->dw_abc_bsd_stat_tx,0,0,NULL,0,NULL); -+ -+ if(dev->net_verbose > 2) -+ printk(KERN_INFO -+ "%s: receive comm-header rem-version 0x%02x\n", -+ lp->name, -+ lp->dw_abc_remote_version); -+ -+ return(NULL); -+ } -+ -+ } else if(*p == DWBSD_PKT_BSD && lp->dw_abc_bsd_stat_rx != NULL && cp) { -+ -+ struct sk_buff *nskb = NULL; -+ -+ if(test_and_set_bit(ISDN_DW_ABC_BITLOCK_RECEIVE, -+ &lp->dw_abc_bitlocks)) { -+ -+ printk(KERN_INFO "%s: bsd-decomp called recursivly\n",lp->name); -+ dev_kfree_skb(skb); -+ dwabc_bsd_first_gen(lp); -+ return(NULL); -+ } -+ -+ nskb = (struct sk_buff *) -+ dev_alloc_skb(2048 + ndev->hard_header_len); -+ -+ if(nskb != NULL) { -+ -+ int l = 0; -+ u_short sqnr; -+ -+ skb_reserve(nskb,ndev->hard_header_len); -+ skb_pull(skb, 1); -+ sqnr = ((*(u_char *)skb->data) << 8) | ((u_char)skb->data[1]); -+ -+ if(!sqnr && cp && lp->dw_abc_bsd_stat_rx) -+ (void)(*cp->reset)(lp->dw_abc_bsd_stat_rx,0,0,NULL,0,NULL); -+ -+ if((l = (*cp->decompress) -+ (lp->dw_abc_bsd_stat_rx,skb,nskb,NULL)) < 1 || l>8000) { -+ -+ printk(KERN_INFO "%s: abc-decomp failed\n",lp->name); -+ dev_kfree_skb(nskb); -+ dev_kfree_skb(skb); -+ nskb = NULL; -+ dwabc_bsd_first_gen(lp); -+ -+ } else { -+ -+ if (nskb->data[0] & 0x1) -+ skb_pull(nskb, 1); /* protocol ID is only 8 bit */ -+ else -+ skb_pull(nskb, 2); -+ -+ nskb->dev = skb->dev; -+ nskb->pkt_type = skb->pkt_type; -+ nskb->mac.raw = nskb->data; -+ dev_kfree_skb(skb); -+ } -+ -+ } else { -+ -+ printk(KERN_INFO "%s: PANIC abc-decomp no memory\n",lp->name); -+ dev_kfree_skb(skb); -+ dwabc_bsd_first_gen(lp); -+ } -+ -+ clear_bit(ISDN_DW_ABC_BITLOCK_RECEIVE,&lp->dw_abc_bitlocks); -+ r = nskb; -+ } -+ } -+ -+ return(r); -+} -+ -+#else -+int dwabc_bsd_init(isdn_net_local *lp) { return(1); } -+void dwabc_bsd_free(isdn_net_local *lp) { return; } -+void dwabc_bsd_first_gen(isdn_net_local *lp) { return ; } -+ -+struct sk_buff *dwabc_bsd_compress(isdn_net_local *lp,struct sk_buff *skb,struct net_device *ndev) -+{ return(skb); } -+ -+struct sk_buff *dwabc_bsd_rx_pkt(isdn_net_local *lp,struct sk_buff *skb,struct net_device *ndev) -+{ return(skb); } -+#endif -+#endif ---- a/drivers/isdn/isdn_net.c -+++ b/drivers/isdn/isdn_net.c -@@ -1,4 +1,4 @@ --/* $Id: isdn_net.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: isdn_net.c,v 1.153 2002/08/17 18:35:23 detabc Exp $ - * - * Linux ISDN subsystem, network interfaces and related functions (linklevel). - * -@@ -9,14 +9,6 @@ - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * -- * Data Over Voice (DOV) support added - Guy Ellis 23-Mar-02 -- * guy@traverse.com.au -- * Outgoing calls - looks for a 'V' in first char of dialed number -- * Incoming calls - checks first character of eaz as follows: -- * Numeric - accept DATA only - original functionality -- * 'V' - accept VOICE (DOV) only -- * 'B' - accept BOTH DATA and DOV types -- * - * Jan 2001: fix CISCO HDLC Bjoern A. Zeeb <i4l@zabbadoz.net> - * for info on the protocol, see - * http://i4l.zabbadoz.net/i4l/cisco-hdlc.txt -@@ -38,6 +30,10 @@ - #include "isdn_concap.h" - #endif - -+#ifdef CONFIG_ISDN_WITH_ABC -+#include <linux/isdn_dwabc.h> -+#define isdn_net_log_skb(skb,lp) isdn_net_log_skb_dwabc(skb,lp,NULL) -+#endif - - /* - * Outline of new tbusy handling: -@@ -79,7 +75,11 @@ static __inline__ int isdn_net_device_st - dev = lp->master; - else - dev = &n->dev; -+#ifdef COMPAT_NO_SOFTNET -+ return dev->start; -+#else - return netif_running(dev); -+#endif - } - - /* -@@ -143,6 +143,10 @@ static __inline__ void isdn_net_inc_fram - atomic_inc(&lp->frame_cnt); - if (isdn_net_device_busy(lp)) - isdn_net_device_stop_queue(lp); -+#if 0 -+ printk(KERN_DEBUG "%s: inc_frame_cnt now %d\n", lp->name, -+ atomic_read(&lp->frame_cnt)); -+#endif - } - - static __inline__ void isdn_net_dec_frame_cnt(isdn_net_local *lp) -@@ -157,11 +161,19 @@ static __inline__ void isdn_net_dec_fram - isdn_net_device_wake_queue(lp); - } - } -+#if 0 -+ printk(KERN_DEBUG "%s: dec_frame_cnt now %d\n", lp->name, -+ atomic_read(&lp->frame_cnt)); -+#endif - } - - static __inline__ void isdn_net_zero_frame_cnt(isdn_net_local *lp) - { - atomic_set(&lp->frame_cnt, 0); -+#if 0 -+ printk(KERN_DEBUG "%s: zero_frame_cnt now %d\n", lp->name, -+ atomic_read(&lp->frame_cnt)); -+#endif - } - - /* For 2.2.x we leave the transmitter busy timeout at 2 secs, just -@@ -173,23 +185,101 @@ static __inline__ void isdn_net_zero_fra - * which might rely on the tx timeout. If so, we'll find out this way... - */ - -+#ifdef COMPAT_NO_SOFTNET -+#define ISDN_NET_TX_TIMEOUT (2*HZ) -+#else - #define ISDN_NET_TX_TIMEOUT (20*HZ) -+#endif - - /* Prototypes */ - -+#ifndef CONFIG_ISDN_WITH_ABC - int isdn_net_force_dial_lp(isdn_net_local *); -+#endif - static int isdn_net_start_xmit(struct sk_buff *, struct net_device *); - - static void isdn_net_ciscohdlck_connected(isdn_net_local *lp); - static void isdn_net_ciscohdlck_disconnected(isdn_net_local *lp); - --char *isdn_net_revision = "$Revision: 1.1.4.1 $"; -+char *isdn_net_revision = "$Revision: 1.153 $"; - - /* - * Code for raw-networking over ISDN - */ -+#ifdef CONFIG_ISDN_WITH_ABC -+#ifdef CONFIG_ISDN_WITH_ABC_CONN_ERROR -+static int isdn_dwabc_encap_with_conerr(isdn_net_local *lp) -+{ -+ if(lp->dw_abc_flags & ISDN_DW_ABC_FLAG_NO_CONN_ERROR) -+ return(0); -+ -+ return( -+ lp->p_encap == ISDN_NET_ENCAP_SYNCPPP || -+ lp->p_encap == ISDN_NET_ENCAP_RAWIP || -+ lp->p_encap == ISDN_NET_ENCAP_CISCOHDLCK || -+ lp->p_encap == ISDN_NET_ENCAP_UIHDLC ); -+} -+ -+static int isdn_dwabc_conerr_ippktok(struct sk_buff *skb) -+{ -+ struct iphdr *iph = (struct iphdr *)skb->data; -+ return(iph->version == 6 || (skb->len >= 20 && iph->version == 4)); -+} -+ -+#endif -+ -+static int isdn_dwabc_is_interface_disabled(isdn_net_local *lp) -+{ -+ if(lp == NULL) -+ return(0); -+ -+ lp->dw_abc_inuse_secure = 0; -+ lp->dw_abc_dialstart = 0; -+ -+ /* -+ ** check for jiffies overflow -+ */ -+ if(lp->dw_abc_bchan_last_connect > jiffies) { -+ -+#ifdef CONFIG_ISDN_WITH_ABC_CONN_ERROR -+ lp->dw_abc_bchan_errcnt = 0; -+#endif -+ lp->dw_abc_bchan_last_connect = 0; -+ } -+ -+#ifdef CONFIG_ISDN_WITH_ABC_CONN_ERROR -+ if(!(lp->dw_abc_flags & ISDN_DW_ABC_FLAG_NO_CONN_ERROR) && isdn_dwabc_encap_with_conerr(lp)) { -+ -+ if(lp->dw_abc_bchan_errcnt > 3 && !(lp->dw_abc_bchan_errcnt & 3)) { - -+ ulong nj = jiffies; -+ ulong delay = lp->dw_abc_bchan_errcnt * -+ lp->dw_abc_bchan_errcnt * -+ lp->dw_abc_bchan_errcnt; -+ -+ if(delay > 86400) delay = 86400; -+ delay = (lp->dw_abc_bchan_last_connect + delay * HZ); -+ -+ if(delay > nj) { -+ -+ printk(KERN_INFO -+ "%s: interface auto-disabled (bchannel connect-error %lu seconds left)\n", -+ lp->name,(delay - nj) / HZ); -+ -+ return(1); -+ } -+ } -+ } -+#endif -+ return(0); -+} -+#endif -+ -+#ifdef CONFIG_ISDN_WITH_ABC -+void -+#else - static void -+#endif - isdn_net_unreachable(struct net_device *dev, struct sk_buff *skb, char *reason) - { - if(skb) { -@@ -297,6 +387,12 @@ isdn_net_unbind_channel(isdn_net_local * - - save_flags(flags); - cli(); -+#ifdef CONFIG_ISDN_WITH_ABC -+ isdn_dw_clear_if(0l,lp); -+ lp->dw_abc_if_flags &= ~ISDN_DW_ABC_IFFLAG_NODCHAN; -+ lp->dw_abc_inuse_secure = 0; -+ dwabc_bsd_free(lp); -+#endif - skb_queue_purge(&lp->super_tx_queue); - - if (!lp->master) { /* reset only master device */ -@@ -351,6 +447,26 @@ isdn_net_autohup() - if ((l->flags & ISDN_NET_CONNECTED) && (!l->dialstate)) { - anymore = 1; - l->huptimer++; -+#ifdef CONFIG_ISDN_WITH_ABC -+#ifdef CONFIG_ISDN_WITH_ABC_CONN_ERROR -+ if( isdn_dwabc_encap_with_conerr(l) && l->dw_abc_bchan_errcnt > 0) { -+ -+ int n = 180; -+ -+ if(l->dw_abc_bchan_errcnt > 3) n = 120; -+ if(l->dw_abc_bchan_errcnt > 6) n = 90; -+ if(l->dw_abc_bchan_errcnt > 9) n = 60; -+ -+ if(l->huptimer > n) { -+ -+ printk(KERN_INFO "%s: bchan conf-error auto-secure-hangup\n",l->name); -+ isdn_net_hangup(&p->dev); -+ p = (isdn_net_dev *) p->next; -+ continue; -+ } -+ } -+#endif -+#endif - /* - * if there is some dialmode where timeout-hangup - * should _not_ be done, check for that here -@@ -465,8 +581,32 @@ isdn_net_stat_callback(int idx, isdn_ctr - printk(KERN_INFO "%s: Chargesum is %d\n", lp->name, - lp->charge); - isdn_net_unbind_channel(lp); -+#ifdef CONFIG_ISDN_WITH_ABC_CONN_ERROR -+ if(lp->dw_abc_bchan_errcnt) { -+ -+ printk(KERN_INFO -+ "%s: Note: bchannel-error-counter is %hd\n", -+ lp->name, -+ lp->dw_abc_bchan_errcnt); -+ } -+#endif - return 1; - } -+#ifdef CONFIG_ISDN_WITH_ABC_CH_EXTINUSE -+ if(!(lp->dw_abc_flags & ISDN_DW_ABC_FLAG_NO_CH_EXTINUSE)) { -+ if((lp->dialstate == 4 || lp->dialstate == 12) && -+ lp->dw_abc_dialstart && (idx < ISDN_MAX_CHANNELS)) { -+ -+ if((jiffies - lp->dw_abc_dialstart) < (HZ >>2)) { -+ -+ lp->dw_abc_if_flags |= ISDN_DW_ABC_IFFLAG_NODCHAN; -+ lp->dialstate = 1; -+ dev->dwabc_chan_external_inuse[idx] = jiffies + HZ * 30; -+ printk(KERN_INFO "%s: Channel %d look like external in use\n",lp->name,idx); -+ } -+ } -+ } -+#endif - break; - #ifdef CONFIG_ISDN_X25 - case ISDN_STAT_BHUP: -@@ -507,6 +647,19 @@ isdn_net_stat_callback(int idx, isdn_ctr - } - } - printk(KERN_INFO "isdn_net: %s connected\n", lp->name); -+#ifdef CONFIG_ISDN_WITH_ABC -+ if(!dwabc_bsd_init(lp)) dwabc_bsd_first_gen(lp); -+ lp->dw_abc_bchan_last_connect = jiffies; -+#ifdef CONFIG_ISDN_WITH_ABC_CONN_ERROR -+ if(!(lp->dw_abc_flags & ISDN_DW_ABC_FLAG_NO_CONN_ERROR)) { -+ -+ lp->dw_abc_bchan_errcnt += isdn_dwabc_encap_with_conerr(lp); -+ -+ if(lp->dw_abc_bchan_errcnt > 32000) -+ lp->dw_abc_bchan_errcnt = 32000; -+ } -+#endif -+#endif - /* If first Chargeinfo comes before B-Channel connect, - * we correct the timestamp here. - */ -@@ -578,7 +731,6 @@ isdn_net_dial(void) - int i; - unsigned long flags; - isdn_ctrl cmd; -- u_char *phone_number; - - while (p) { - isdn_net_local *lp = p->local; -@@ -597,6 +749,47 @@ isdn_net_dial(void) - */ - save_flags(flags); - cli(); -+#ifdef CONFIG_ISDN_WITH_ABC_CH_EXTINUSE -+ if(!(lp->dw_abc_flags & ISDN_DW_ABC_FLAG_NO_CH_EXTINUSE) && -+ (lp->dw_abc_if_flags & ISDN_DW_ABC_IFFLAG_NODCHAN)) { -+ -+ int chi = 0; -+ short lsecure = 0; -+ -+ lsecure = lp->dw_abc_inuse_secure; -+ isdn_net_unbind_channel(lp); -+ lp->dw_abc_inuse_secure = lsecure + 1; -+ -+ /* Grab a free ISDN-Channel */ -+ if ((lsecure >= ISDN_MAX_CHANNELS ) || (chi = -+ isdn_get_free_channel( -+ ISDN_USAGE_NET, -+ lp->l2_proto, -+ lp->l3_proto, -+ lp->pre_device, -+ lp->pre_channel, -+#ifdef CONFIG_ISDN_WITH_ABC_OUTGOING_EAZ -+ (*lp->dw_out_msn) ? lp->dw_out_msn : lp->msn) -+#else -+ lp->msn) -+#endif -+ ) < 0) { -+ -+ restore_flags(flags); -+ isdn_net_unreachable(&p->dev, NULL, -+ "DWABC: redial-external-inuse NO FREE CHANNEL\n"); -+ isdn_net_hangup(&p->dev); -+ break; -+ } -+ -+ isdn_net_bind_channel(lp, chi); -+ lp->dialstate = 1; -+ lp->dialstarted = 0; -+ lp->dialwait_timer = 0; -+ } -+ -+ lp->dw_abc_if_flags &= ~ISDN_DW_ABC_IFFLAG_NODCHAN; -+#endif - lp->dial = lp->phone[1]; - restore_flags(flags); - if (!lp->dial) { -@@ -621,18 +814,69 @@ isdn_net_dial(void) - cmd.arg = lp->isdn_channel; - cmd.command = ISDN_CMD_CLREAZ; - isdn_command(&cmd); -+#ifdef CONFIG_ISDN_WITH_ABC_OUTGOING_EAZ -+ sprintf(cmd.parm.num, "%s", -+ isdn_map_eaz2msn((*lp->dw_out_msn) ? lp->dw_out_msn : lp->msn, cmd.driver)); -+#else - sprintf(cmd.parm.num, "%s", isdn_map_eaz2msn(lp->msn, cmd.driver)); -+#endif - cmd.command = ISDN_CMD_SETEAZ; - isdn_command(&cmd); - lp->dialretry = 0; - anymore = 1; - lp->dialstate++; -+#ifdef CONFIG_ISDN_WITH_ABC -+ lp->onhtime = lp->dw_abc_old_onhtime; -+#ifdef CONFIG_ISDN_WITH_ABC_LCR_SUPPORT -+ isdn_dw_abc_lcr_clear(lp); -+#endif -+#endif - /* Fall through */ - case 3: - /* Setup interface, dial current phone-number, switch to next number. - * If list of phone-numbers is exhausted, increment - * retry-counter. - */ -+#ifdef CONFIG_ISDN_WITH_ABC_LCR_SUPPORT -+ if(!isdn_dw_abc_lcr_lock()) { -+ -+ if( lp->dw_abc_lcr_cmd != NULL && -+ lp->dw_abc_lcr_start_request != -+ lp->dw_abc_lcr_end_request) { -+ -+ if( lp->dw_abc_lcr_io == NULL && -+ lp->dw_abc_lcr_start_request <= jiffies && -+ lp->dw_abc_lcr_end_request > jiffies) { -+ -+ isdn_dw_abc_lcr_ulock(); -+ anymore = 1; -+ break; -+ } -+ -+ if(lp->dw_abc_lcr_io != NULL) { -+ -+ if(lp->dw_abc_lcr_io->lcr_ioctl_flags & -+ DWABC_LCR_FLG_DISABLE) { -+ -+ isdn_dw_abc_lcr_ulock(); -+ isdn_net_hangup(&p->dev); -+ break; -+ } -+ -+ if(lp->dw_abc_lcr_io->lcr_ioctl_flags & -+ DWABC_LCR_FLG_NEWHUPTIME) { -+ lp->onhtime = lp->dw_abc_lcr_io->lcr_ioctl_onhtime; -+ } -+ } -+ -+ memcpy(&cmd,lp->dw_abc_lcr_cmd,sizeof(cmd)); -+ isdn_dw_abc_lcr_ulock(); -+ goto dw_abc_lcr_next_click; -+ } -+ -+ isdn_dw_abc_lcr_ulock(); -+ } -+#endif - if(dev->global_flags & ISDN_GLOBAL_STOPPED || (ISDN_NET_DIALMODE(*lp) == ISDN_NET_DM_OFF)) { - char *s; - if (dev->global_flags & ISDN_GLOBAL_STOPPED) -@@ -677,20 +921,7 @@ isdn_net_dial(void) - break; - } - -- cmd.driver = lp->isdn_device; -- cmd.command = ISDN_CMD_DIAL; -- cmd.parm.setup.si2 = 0; -- -- /* check for DOV */ -- phone_number = lp->dial->num; -- if ((*phone_number == 'v') || -- (*phone_number == 'V')) { /* DOV call */ -- cmd.parm.setup.si1 = 1; -- } else { /* DATA call */ -- cmd.parm.setup.si1 = 7; -- } -- -- strcpy(cmd.parm.setup.phone, phone_number); -+ sprintf(cmd.parm.setup.phone, "%s", lp->dial->num); - /* - * Switch to next number or back to start if at end of list. - */ -@@ -710,17 +941,70 @@ isdn_net_dial(void) - } - } - restore_flags(flags); -+ cmd.driver = lp->isdn_device; -+ cmd.command = ISDN_CMD_DIAL; -+ cmd.parm.setup.si1 = 7; -+ cmd.parm.setup.si2 = 0; -+#ifdef CONFIG_ISDN_WITH_ABC_OUTGOING_EAZ -+ sprintf(cmd.parm.setup.eazmsn, "%s", -+ isdn_map_eaz2msn((*lp->dw_out_msn) ? lp->dw_out_msn : lp->msn, cmd.driver)); -+#else - sprintf(cmd.parm.setup.eazmsn, "%s", - isdn_map_eaz2msn(lp->msn, cmd.driver)); -+#endif -+#ifdef CONFIG_ISDN_WITH_ABC_LCR_SUPPORT -+ /* -+ ** if callback-out we dont need -+ ** low-cost-routing LCR -+ */ -+ if(!(lp->flags & ISDN_NET_CBOUT) && -+ !(lp->dw_abc_flags & ISDN_DW_ABC_FLAG_NO_LCR)) { -+ -+ isdn_dw_abc_lcr_call_number(lp,&cmd); -+ -+ if(lp->dw_abc_lcr_start_request != lp->dw_abc_lcr_end_request) { -+ -+ if(dev->net_verbose > 2) { -+ -+ printk(KERN_INFO -+ "%s: Waiting for LCR-response from isdnlog %s -> %s...\n", -+ lp->name, -+ cmd.parm.setup.eazmsn, -+ cmd.parm.setup.phone); -+ } -+ -+ anymore = 1; -+ break; -+ } -+ } -+ -+dw_abc_lcr_next_click:; -+ isdn_dw_abc_lcr_clear(lp); -+#endif - i = isdn_dc2minor(lp->isdn_device, lp->isdn_channel); - if (i >= 0) { - strcpy(dev->num[i], cmd.parm.setup.phone); - dev->usage[i] |= ISDN_USAGE_OUTGOING; - isdn_info_update(); - } -- printk(KERN_INFO "%s: dialing %d %s... %s\n", lp->name, -- lp->dialretry, cmd.parm.setup.phone, -- (cmd.parm.setup.si1 == 1) ? "DOV" : ""); -+#ifdef CONFIG_ISDN_WITH_ABC -+ printk(KERN_INFO "%s: dialing %d %s -> %s...\n", lp->name, -+ lp->dialretry, -+ cmd.parm.setup.eazmsn, -+ cmd.parm.setup.phone); -+#ifdef CONFIG_ISDN_WITH_ABC_CONN_ERROR -+ if(lp->dw_abc_bchan_errcnt) { -+ -+ printk(KERN_INFO -+ "%s: Note: bchannel-error-counter is %hd\n", -+ lp->name, -+ lp->dw_abc_bchan_errcnt); -+ } -+#endif -+#else -+ printk(KERN_INFO "%s: dialing %d %s...\n", lp->name, -+ lp->dialretry, cmd.parm.setup.phone); -+#endif - lp->dtimer = 0; - #ifdef ISDN_DEBUG_NET_DIAL - printk(KERN_DEBUG "dial: d=%d c=%d\n", lp->isdn_device, -@@ -741,6 +1025,10 @@ isdn_net_dial(void) - lp->dialstate = - (lp->cbdelay && - (lp->flags & ISDN_NET_CBOUT)) ? 12 : 4; -+#ifdef CONFIG_ISDN_WITH_ABC -+ lp->dw_abc_if_flags &= ~ISDN_DW_ABC_IFFLAG_NODCHAN; -+ lp->dw_abc_dialstart = jiffies; -+#endif - break; - case 4: - /* Wait for D-Channel-connect. -@@ -890,6 +1178,15 @@ isdn_net_hangup(struct net_device *d) - isdn_command(&cmd); - printk(KERN_INFO "%s: Chargesum is %d\n", lp->name, lp->charge); - isdn_all_eaz(lp->isdn_device, lp->isdn_channel); -+#ifdef CONFIG_ISDN_WITH_ABC_CONN_ERROR -+ if(lp->dw_abc_bchan_errcnt) { -+ -+ printk(KERN_INFO -+ "%s: Note: bchannel-error-counter is %hd\n", -+ lp->name, -+ lp->dw_abc_bchan_errcnt); -+ } -+#endif - } - isdn_net_unbind_channel(lp); - } -@@ -899,8 +1196,13 @@ typedef struct { - unsigned short dest; - } ip_ports; - -+#ifdef CONFIG_ISDN_WITH_ABC -+void -+isdn_net_log_skb_dwabc(struct sk_buff * skb, isdn_net_local * lp,char *reason) -+#else - static void - isdn_net_log_skb(struct sk_buff * skb, isdn_net_local * lp) -+#endif - { - u_char *p = skb->nh.raw; /* hopefully, this was set correctly */ - unsigned short proto = ntohs(skb->protocol); -@@ -972,7 +1274,13 @@ isdn_net_log_skb(struct sk_buff * skb, i - break; - } - printk(KERN_INFO -+#ifdef CONFIG_ISDN_WITH_ABC -+ "%s %s: %d.%d.%d.%d -> %d.%d.%d.%d%s\n", -+ (reason == NULL) ? "OPEN" : reason, -+ (lp != NULL) ? lp->name : "", -+#else - "OPEN: %d.%d.%d.%d -> %d.%d.%d.%d%s\n", -+#endif - - p[12], p[13], p[14], p[15], - p[16], p[17], p[18], p[19], -@@ -980,7 +1288,13 @@ isdn_net_log_skb(struct sk_buff * skb, i - break; - case ETH_P_ARP: - printk(KERN_INFO -+#ifdef CONFIG_ISDN_WITH_ABC -+ "%s %s: ARP %d.%d.%d.%d -> *.*.*.* ?%d.%d.%d.%d\n", -+ (reason == NULL) ? "OPEN" : reason, -+ (lp != NULL) ? lp->name : "", -+#else - "OPEN: ARP %d.%d.%d.%d -> *.*.*.* ?%d.%d.%d.%d\n", -+#endif - p[14], p[15], p[16], p[17], - p[24], p[25], p[26], p[27]); - break; -@@ -1004,11 +1318,22 @@ void isdn_net_write_super(isdn_net_local - } - - spin_lock_bh(&lp->xmit_lock); -+ - if (!isdn_net_lp_busy(lp)) { -+#ifdef CONFIG_ISDN_WITH_ABC -+ if(!skb_queue_empty(&lp->super_tx_queue)) { -+ /* -+ ** don't reverse the frame flow -+ ** compression need frames in order and maybe other's too -+ */ -+ skb_queue_tail(&lp->super_tx_queue, skb); -+ skb = skb_dequeue(&lp->super_tx_queue); -+ } -+#endif - isdn_net_writebuf_skb(lp, skb); -- } else { -- skb_queue_tail(&lp->super_tx_queue, skb); -- } -+ -+ } else skb_queue_tail(&lp->super_tx_queue, skb); -+ - spin_unlock_bh(&lp->xmit_lock); - } - -@@ -1056,7 +1381,6 @@ void isdn_net_writebuf_skb(isdn_net_loca - printk(KERN_WARNING "%s: HL driver queue full\n", lp->name); - goto error; - } -- - lp->transcount += len; - isdn_net_inc_frame_cnt(lp); - return; -@@ -1064,9 +1388,19 @@ void isdn_net_writebuf_skb(isdn_net_loca - error: - dev_kfree_skb(skb); - lp->stats.tx_errors++; -- - } - -+#if 0 -+int isdn_net_send_skb(struct net_device *ndev, isdn_net_local * lp,struct sk_buff *skb) -+{ -+ if (isdn_net_lp_busy(lp)) { -+ printk(KERN_WARNING "isdn_net_send_skb: HL channel busy\n"); -+ return 1; -+ } -+ isdn_net_writebuf_skb(lp, skb); -+ return 0; -+} -+#endif - - /* - * Helper function for isdn_net_start_xmit. -@@ -1109,7 +1443,54 @@ isdn_net_xmit(struct net_device *ndev, s - - /* Reset hangup-timeout */ - lp->huptimer = 0; // FIXME? -+#ifdef CONFIG_ISDN_WITH_ABC -+ -+ if(test_and_set_bit(ISDN_DW_ABC_BITLOCK_SEND,&lp->dw_abc_bitlocks)) { -+ -+ if(dev->net_verbose > 2) -+ printk(KERN_INFO "%s: isdn_net_xmit called recursivly\n",lp->name); -+ -+ spin_unlock_bh(&lp->xmit_lock); -+ return(1); -+ } -+ -+ if(skb != NULL) { -+ -+ int l = skb->len; -+ int nl = l; -+ -+ if( lp->p_encap == ISDN_NET_ENCAP_RAWIP && -+ (lp->dw_abc_if_flags & ISDN_DW_ABC_IFFLAG_BSDAKTIV)) { -+ -+ if((skb = dwabc_bsd_compress(lp,skb,ndev)) != NULL) { -+ -+ int r = 0; -+ nl = skb->len; -+ skb_queue_tail(&lp->super_tx_queue,skb); -+ -+ if(l != nl && (r = isdn_dc2minor(lp->isdn_device,lp->isdn_channel)) >= 0) { -+ -+ dev->obytes[r] += l - nl; -+ lp->stats.tx_bytes += l - nl; -+ } -+ } -+ -+ } else skb_queue_tail(&lp->super_tx_queue,skb); -+ -+ if(lp->p_encap == ISDN_NET_ENCAP_RAWIP) { -+ -+ lp->dw_abc_bsd_snd += l; -+ lp->dw_abc_bsd_bsd_snd += nl; -+ } -+ } -+ clear_bit(ISDN_DW_ABC_BITLOCK_SEND,&lp->dw_abc_bitlocks); -+ -+ while(!isdn_net_lp_busy(lp) && (skb = skb_dequeue(&lp->super_tx_queue))) -+ isdn_net_writebuf_skb(lp, skb); -+ -+#else - isdn_net_writebuf_skb(lp, skb); -+#endif - spin_unlock_bh(&lp->xmit_lock); - - /* the following stuff is here for backwards compatibility. -@@ -1143,6 +1524,69 @@ isdn_net_xmit(struct net_device *ndev, s - - return retv; - -+#if 0 -+ if (lp->cps > lp->triggercps) { -+ /* Device overloaded */ -+ -+ /* -+ * Packet-delivery via round-robin over master -+ * and all connected slaves. -+ */ -+ if (lp->master) { -+ /* Slaves always deliver themselves */ -+ spin_lock_bh(&lp->xmit_lock); -+ if (!isdn_net_lp_busy(lp)) { -+ isdn_net_writebuf_skb(lp, skb); -+ ret = 0; -+ } else { -+ isdn_net_device_stop_queue(lp); -+ ret = 1; -+ } -+ ret = isdn_net_send_skb(ndev, lp, skb); -+ spin_unlock_bh(&lp->xmit_lock); -+ } else { -+ isdn_net_local *slp = (isdn_net_local *) (lp->srobin->priv); -+ /* Master delivers via srobin and maintains srobin */ -+ if (lp->srobin == ndev) { -+ spin_lock_bh(&lp->xmit_lock); -+ ret = isdn_net_send_skb(ndev, lp, skb); -+ spin_unlock_bh(&lp->xmit_lock); -+ } else { -+ ret = isdn_net_start_xmit(skb, lp->srobin); -+ } -+ lp->srobin = (slp->slave) ? slp->slave : ndev; -+ slp = (isdn_net_local *) (lp->srobin->priv); -+ if (!((slp->flags & ISDN_NET_CONNECTED) && (slp->dialstate == 0))) -+ lp->srobin = ndev; -+ } -+ /* Slave-startup using delay-variable */ -+ if (lp->slave) { -+ if (!lp->sqfull) { -+ /* First time overload: set timestamp only */ -+ lp->sqfull = 1; -+ lp->sqfull_stamp = jiffies; -+ } else { -+ /* subsequent overload: if slavedelay exceeded, start dialing */ -+ if ((jiffies - lp->sqfull_stamp) > lp->slavedelay) -+ isdn_net_force_dial_lp((isdn_net_local *) lp->slave->priv); -+ } -+ } -+ } else { -+ /* Not overloaded, deliver locally */ -+ spin_lock_bh(&lp->xmit_lock); -+ if (!isdn_net_lp_busy(lp)) { -+ isdn_net_writebuf_skb(lp, skb); -+ ret = 0; -+ } else { -+ isdn_net_device_stop_queue(lp); -+ ret = 1; -+ } -+ spin_unlock_bh(&lp->xmit_lock); -+ if (lp->sqfull && ((jiffies - lp->sqfull_stamp) > (lp->slavedelay + (10 * HZ)))) -+ lp->sqfull = 0; -+ } -+ return ret; -+#endif - } - - static void -@@ -1161,6 +1605,7 @@ isdn_net_adjust_hdr(struct sk_buff *skb, - } - - -+#ifndef COMPAT_NO_SOFTNET - void isdn_net_tx_timeout(struct net_device * ndev) - { - isdn_net_local *lp = (isdn_net_local *) ndev->priv; -@@ -1188,19 +1633,206 @@ void isdn_net_tx_timeout(struct net_devi - ndev->trans_start = jiffies; - netif_wake_queue(ndev); - } -+#endif - - /* - * Try sending a packet. - * If this interface isn't connected to a ISDN-Channel, find a free channel, - * and start dialing. - */ -+#ifdef CONFIG_ISDN_WITH_ABC -+static int dwabc_isdn_net_start_xmit(struct sk_buff *,struct net_device *); -+ -+static int isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev) -+{ -+ if(skb == NULL || ndev == NULL) -+ return(dwabc_isdn_net_start_xmit(skb,ndev)); -+#ifdef CONFIG_ISDN_WITH_ABC_UDP_CHECK -+ if(!(((isdn_net_local *)ndev->priv)->dw_abc_flags & -+ ISDN_DW_ABC_FLAG_NO_UDP_CHECK)) { -+ -+ if(dw_abc_udp_test(skb,ndev)) { -+ dev_kfree_skb(skb); -+ return(0); -+ } -+ } -+#endif -+ return(dwabc_isdn_net_start_xmit(skb,ndev)); -+} -+ -+ -+#ifdef CONFIG_ISDN_WITH_ABC -+int isdn_auto_dial_helper( isdn_net_local *lp, -+ struct sk_buff *skb, -+ int dm_manual_allowed) -+/********************************************************************** -+ return's: -+ -1 dial not allowed or impossible -+ 0 interface is connected -+ 1 dial is started -+***********************************************************************/ -+{ -+ int retw = -1; -+ int chi; -+ ulong flags; -+ char *errmsg = NULL; -+ -+#ifdef ISDN_DEBUG_NET_DUMP -+ { -+ char *buf = skb->data; -+ isdn_dumppkt("S:", buf, skb->len, 40); -+ } -+#endif -+ if (lp->flags & ISDN_NET_CONNECTED) -+ return(0); -+ -+ save_flags(flags); -+ cli(); -+ -+ do { -+ -+ /* Log packet, which triggered dialing */ -+ if (dev->net_verbose) -+ isdn_net_log_skb(skb, lp); -+ /* only do autodial if allowed by config */ -+ if (!(ISDN_NET_DIALMODE(*lp) == ISDN_NET_DM_AUTO)) { -+ errmsg = "dial rejected: interface not in dialmode `auto'"; -+ -+ if(dm_manual_allowed && -+ !(ISDN_NET_DIALMODE(*lp) == ISDN_NET_DM_MANUAL)) { -+ -+ errmsg = -+ "dial rejected: interface not in dialmode `auto or manual'"; -+ } -+ break; -+ } -+ -+ if (!lp->phone[1]) { -+ -+ errmsg = "No phone number"; -+ break; -+ } -+ -+ if(lp->dialwait_timer <= 0) { -+ -+ if( lp->dialstarted > 0 && -+ lp->dialtimeout > 0 && -+ jiffies < (lp->dialstarted + lp->dialtimeout + lp->dialwait)) { -+ -+ lp->dialwait_timer = -+ lp->dialstarted + lp->dialtimeout + lp->dialwait; -+ } -+ } -+ -+ if(lp->dialwait_timer > 0) { -+ -+ if(jiffies < lp->dialwait_timer) { -+ -+ errmsg = "dial rejected: retry-time not reached"; -+ break; -+ -+ } else lp->dialwait_timer = 0; -+ } -+#ifdef CONFIG_ISDN_WITH_ABC -+ if(isdn_dwabc_is_interface_disabled(lp)) -+ break; -+#endif -+ /* Grab a free ISDN-Channel */ -+ if (((chi = -+ isdn_get_free_channel( -+ ISDN_USAGE_NET, -+ lp->l2_proto, -+ lp->l3_proto, -+ lp->pre_device, -+ lp->pre_channel, -+#ifdef CONFIG_ISDN_WITH_ABC_OUTGOING_EAZ -+ (*lp->dw_out_msn) ? lp->dw_out_msn : -+#endif -+ lp->msn) -+ ) < 0) && -+ ((chi = -+ isdn_get_free_channel( -+ ISDN_USAGE_NET, -+ lp->l2_proto, -+ lp->l3_proto, -+ lp->pre_device, -+ lp->pre_channel^1, -+#ifdef CONFIG_ISDN_WITH_ABC_OUTGOING_EAZ -+ (*lp->dw_out_msn) ? lp->dw_out_msn : -+#endif -+ lp->msn) -+ ) < 0)) { -+ -+ errmsg = "No channel"; -+ break; -+ } -+ -+ lp->dialstate = 1; -+ /* Connect interface with channel */ -+ isdn_net_bind_channel(lp, chi); -+#ifdef CONFIG_ISDN_PPP -+ if (lp->p_encap == ISDN_NET_ENCAP_SYNCPPP) { -+ /* no 'first_skb' handling for syncPPP */ -+ if (isdn_ppp_bind(lp) < 0) { -+ isdn_net_unbind_channel(lp); -+ break; -+ } -+ -+ isdn_net_dial(); /* Initiate dialing */ -+ netif_stop_queue(&lp->netdev->dev); -+ retw = 1; -+ break; -+ /* let upper layer requeue skb packet */ -+ } -+#endif -+ /* Initiate dialing */ -+ isdn_net_dial(); -+ isdn_net_device_stop_queue(lp); -+ retw = 1; -+ -+ } while(0); -+ -+ if(retw < 0 && errmsg != NULL) -+ isdn_net_unreachable(&lp->netdev->dev, skb, errmsg); -+ -+ restore_flags(flags); -+ return(retw); -+} -+#endif -+ -+ -+ -+static int -+dwabc_isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev) -+#else - static int - isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev) -+#endif - { - isdn_net_local *lp = (isdn_net_local *) ndev->priv; - #ifdef CONFIG_ISDN_X25 - struct concap_proto * cprot = lp -> netdev -> cprot; - #endif -+#ifdef COMPAT_NO_SOFTNET -+ /* some comment as with the softnet TX timeout -+ when this happens, it's a bug in the HL card driver -+ and should be fixed there, so we can supposedly get rid of -+ this here at all. -+ I added a debugging message to find out if it ever occurs --KG -+ */ -+ -+ if (ndev->tbusy) { -+ if (jiffies - ndev->trans_start < ISDN_NET_TX_TIMEOUT) -+ return 1; -+ if (!lp->dialstate){ -+ lp->stats.tx_errors++; -+ printk(KERN_WARNING "isdn_tx_timeout dev %s dialstate %d\n", -+ ndev->name, lp->dialstate); -+ } -+ ndev->trans_start = jiffies; -+ netif_wake_queue(ndev); -+ } -+#endif - #ifdef CONFIG_ISDN_X25 - /* At this point hard_start_xmit() passes control to the encapsulation - protocol (if present). -@@ -1220,6 +1852,40 @@ isdn_net_start_xmit(struct sk_buff *skb, - } else - #endif - /* auto-dialing xmit function */ -+#ifdef CONFIG_ISDN_WITH_ABC -+ { -+ int r; -+ -+ isdn_net_adjust_hdr(skb, ndev); -+ -+ if(!(r = isdn_auto_dial_helper(lp,skb,0))) { -+ -+ /* -+ ** Device is connected to an ISDN channel -+ */ -+ ndev->trans_start = jiffies; -+ -+ if (!lp->dialstate) { -+ -+ /* -+ ** ISDN connection is established, try sending -+ */ -+ r = isdn_net_xmit(ndev, skb); -+ -+ } else r = 1; -+ -+ if(r) -+ netif_stop_queue(ndev); -+ -+ } else if(r < 0) { -+ -+ dev_kfree_skb(skb); -+ r = 0; -+ } -+ -+ return(r); -+ } -+#else - { - #ifdef ISDN_DEBUG_NET_DUMP - u_char *buf; -@@ -1256,6 +1922,14 @@ isdn_net_start_xmit(struct sk_buff *skb, - } else - lp->dialwait_timer = 0; - } -+#ifdef CONFIG_ISDN_WITH_ABC -+ if(isdn_dwabc_is_interface_disabled(lp)) { -+ -+ dev_kfree_skb(skb); -+ restore_flags(flags); -+ return(0); -+ } -+#endif - /* Grab a free ISDN-Channel */ - if (((chi = - isdn_get_free_channel( -@@ -1264,6 +1938,9 @@ isdn_net_start_xmit(struct sk_buff *skb, - lp->l3_proto, - lp->pre_device, - lp->pre_channel, -+#ifdef CONFIG_ISDN_WITH_ABC_OUTGOING_EAZ -+ (*lp->dw_out_msn) ? lp->dw_out_msn : -+#endif - lp->msn) - ) < 0) && - ((chi = -@@ -1273,6 +1950,9 @@ isdn_net_start_xmit(struct sk_buff *skb, - lp->l3_proto, - lp->pre_device, - lp->pre_channel^1, -+#ifdef CONFIG_ISDN_WITH_ABC_OUTGOING_EAZ -+ (*lp->dw_out_msn) ? lp->dw_out_msn : -+#endif - lp->msn) - ) < 0)) { - restore_flags(flags); -@@ -1296,16 +1976,6 @@ isdn_net_start_xmit(struct sk_buff *skb, - restore_flags(flags); - return 0; /* STN (skb to nirvana) ;) */ - } --#ifdef CONFIG_IPPP_FILTER -- if (isdn_ppp_autodial_filter(skb, lp)) { -- isdn_ppp_free(lp); -- isdn_net_unbind_channel(lp); -- restore_flags(flags); -- isdn_net_unreachable(ndev, skb, "dial rejected: packet filtered"); -- dev_kfree_skb(skb); -- return 0; -- } --#endif - restore_flags(flags); - isdn_net_dial(); /* Initiate dialing */ - netif_stop_queue(ndev); -@@ -1337,6 +2007,7 @@ isdn_net_start_xmit(struct sk_buff *skb, - } - } - return 1; -+#endif - } - - /* -@@ -1356,6 +2027,9 @@ isdn_net_close(struct net_device *dev) - if( cprot && cprot -> pops ) cprot -> pops -> close( cprot ); - #endif - netif_stop_queue(dev); -+#ifdef COMPAT_NO_SOFTNET -+ dev->start = 0; -+#endif - if ((p = (((isdn_net_local *) dev->priv)->slave))) { - /* If this interface has slaves, stop them also */ - while (p) { -@@ -1776,6 +2450,10 @@ isdn_net_ciscohdlck_receive(isdn_net_loc - } - - switch (type) { -+ case CISCO_TYPE_INET: -+ skb->protocol = htons(ETH_P_IP); -+ netif_rx(skb); -+ break; - case CISCO_TYPE_SLARP: - isdn_net_ciscohdlck_slarp_in(lp, skb); - goto out_free; -@@ -1785,11 +2463,11 @@ isdn_net_ciscohdlck_receive(isdn_net_loc - "\"no cdp enable\" on cisco.\n", lp->name); - goto out_free; - default: -- /* no special cisco protocol */ -- skb->protocol = htons(type); -- netif_rx(skb); -- return; -+ printk(KERN_WARNING "%s: Unknown Cisco type 0x%04x\n", -+ lp->name, type); -+ goto out_free; - } -+ return; - - out_free: - kfree_skb(skb); -@@ -1803,9 +2481,19 @@ isdn_net_receive(struct net_device *ndev - { - isdn_net_local *lp = (isdn_net_local *) ndev->priv; - isdn_net_local *olp = lp; /* original 'lp' */ -+#ifdef CONFIG_ISDN_PPP -+ int proto = PPP_PROTOCOL(skb->data); -+#endif - #ifdef CONFIG_ISDN_X25 - struct concap_proto *cprot = lp -> netdev -> cprot; - #endif -+#ifdef CONFIG_ISDN_WITH_ABC -+ struct net_device *ondev = ndev; -+#ifdef CONFIG_ISDN_WITH_ABC_RCV_NO_HUPTIMER -+ ulong lp_huptimer = 0; -+ ulong olp_huptimer = 0; -+#endif -+#endif - lp->transcount += skb->len; - - lp->stats.rx_packets++; -@@ -1819,6 +2507,10 @@ isdn_net_receive(struct net_device *ndev - lp->stats.rx_packets++; - lp->stats.rx_bytes += skb->len; - } -+#ifdef CONFIG_ISDN_WITH_ABC_RCV_NO_HUPTIMER -+ lp_huptimer = lp->huptimer; -+ olp_huptimer = olp->huptimer; -+#endif - skb->dev = ndev; - skb->pkt_type = PACKET_HOST; - skb->mac.raw = skb->data; -@@ -1840,9 +2532,40 @@ isdn_net_receive(struct net_device *ndev - /* Fall through */ - case ISDN_NET_ENCAP_RAWIP: - /* RAW-IP without MAC-Header */ -+#ifdef CONFIG_ISDN_WITH_ABC -+ if(olp->p_encap == ISDN_NET_ENCAP_RAWIP) { -+ -+ ushort l = skb->len; -+ short r = 0; -+ -+ olp->dw_abc_bsd_bsd_rcv += l; -+ -+ if((skb = dwabc_bsd_rx_pkt(olp,skb,ondev)) == NULL) { -+ -+ olp->dw_abc_bsd_rcv += l; -+ return; -+ } -+ -+ olp->dw_abc_bsd_rcv += skb->len; -+ -+ if( l != skb->len && -+ (r=isdn_dc2minor(olp->isdn_device,olp->isdn_channel))>=0) { -+ -+ dev->ibytes[r] += skb->len - l; -+ olp->stats.rx_bytes += skb->len - l; -+ -+ if(olp != lp) -+ lp->stats.rx_bytes += skb->len - l; -+ } -+ } -+#endif - olp->huptimer = 0; - lp->huptimer = 0; - skb->protocol = htons(ETH_P_IP); -+#ifdef CONFIG_ISDN_WITH_ABC_CONN_ERROR -+ if(isdn_dwabc_conerr_ippktok(skb)) -+ lp->dw_abc_bchan_errcnt = 0; -+#endif - break; - case ISDN_NET_ENCAP_CISCOHDLCK: - isdn_net_ciscohdlck_receive(lp, skb); -@@ -1862,8 +2585,22 @@ isdn_net_receive(struct net_device *ndev - break; - #ifdef CONFIG_ISDN_PPP - case ISDN_NET_ENCAP_SYNCPPP: -- /* huptimer is done in isdn_ppp_push_higher */ -+ /* -+ * If encapsulation is syncppp, don't reset -+ * huptimer on LCP packets. -+ */ -+ if (proto != PPP_LCP) { -+ olp->huptimer = 0; -+ lp->huptimer = 0; -+ } - isdn_ppp_receive(lp->netdev, olp, skb); -+#ifdef CONFIG_ISDN_WITH_ABC_RCV_NO_HUPTIMER -+ if(olp->dw_abc_flags & ISDN_DW_ABC_FLAG_RCV_NO_HUPTIMER) { -+ -+ lp->huptimer = lp_huptimer + 1; -+ olp->huptimer = olp_huptimer+ 1; -+ } -+#endif - return; - #endif - -@@ -1873,6 +2610,15 @@ isdn_net_receive(struct net_device *ndev - if(cprot) if(cprot -> pops) - if( cprot -> pops -> data_ind){ - cprot -> pops -> data_ind(cprot,skb); -+#ifdef CONFIG_ISDN_WITH_ABC_CONN_ERROR -+ lp->dw_abc_bchan_errcnt = 0; -+#ifdef CONFIG_ISDN_WITH_ABC_RCV_NO_HUPTIMER -+ if(olp->dw_abc_flags & ISDN_DW_ABC_FLAG_RCV_NO_HUPTIMER) { -+ lp->huptimer = lp_huptimer; -+ olp->huptimer = olp_huptimer; -+ } -+#endif -+#endif - return; - }; - #endif /* CONFIG_ISDN_X25 */ -@@ -1882,6 +2628,15 @@ isdn_net_receive(struct net_device *ndev - return; - } - -+#ifdef CONFIG_ISDN_WITH_ABC -+#ifdef CONFIG_ISDN_WITH_ABC_RCV_NO_HUPTIMER -+ if(olp->dw_abc_flags & ISDN_DW_ABC_FLAG_RCV_NO_HUPTIMER) { -+ -+ lp->huptimer = lp_huptimer; -+ olp->huptimer = olp_huptimer; -+ } -+#endif -+#endif - netif_rx(skb); - return; - } -@@ -2160,7 +2915,10 @@ isdn_net_find_icall(int di, int ch, int - isdn_net_phone *n; - ulong flags; - char nr[ISDN_MSNLEN]; -- char *my_eaz; -+#ifdef CONFIG_ISDN_WITH_ABC -+ if(dev->net_verbose > 2) -+ printk(KERN_DEBUG "n_fi: di=%d ch=%d idx=%d usg=0x%04X\n", di, ch, idx,dev->usage[idx]); -+#endif - - /* Search name in netdev-chain */ - save_flags(flags); -@@ -2182,17 +2940,15 @@ isdn_net_find_icall(int di, int ch, int - eaz = setup->eazmsn; - if (dev->net_verbose > 1) - printk(KERN_INFO "isdn_net: call from %s,%d,%d -> %s\n", nr, si1, si2, eaz); -- /* Accept DATA and VOICE calls at this stage -- local eaz is checked later for allowed call types */ -- if ((si1 != 7) && (si1 != 1)) { -- restore_flags(flags); -- if (dev->net_verbose > 1) -- printk(KERN_INFO "isdn_net: Service-Indicator not 1 or 7, ignored\n"); -- return 0; -- } -- --n = (isdn_net_phone *) 0; --p = dev->netdev; -+ /* Accept only calls with Si1 = 7 (Data-Transmission) */ -+ if (si1 != 7) { -+ restore_flags(flags); -+ if (dev->net_verbose > 1) -+ printk(KERN_INFO "isdn_net: Service-Indicator not 7, ignored\n"); -+ return 0; -+ } -+ n = (isdn_net_phone *) 0; -+ p = dev->netdev; - ematch = wret = swapped = 0; - #ifdef ISDN_DEBUG_NET_ICALL - printk(KERN_DEBUG "n_fi: di=%d ch=%d idx=%d usg=%d\n", di, ch, idx, -@@ -2212,25 +2968,8 @@ p = dev->netdev; - break; - } - swapped = 0; -- /* check acceptable call types for DOV */ -- my_eaz = isdn_map_eaz2msn(lp->msn, di); -- if (si1 == 1) { /* it's a DOV call, check if we allow it */ -- if (*my_eaz == 'v' || *my_eaz == 'V' || -- *my_eaz == 'b' || *my_eaz == 'B') -- my_eaz++; /* skip to allow a match */ -- else -- my_eaz = 0; /* force non match */ -- } else { /* it's a DATA call, check if we allow it */ -- if (*my_eaz == 'b' || *my_eaz == 'B') -- my_eaz++; /* skip to allow a match */ -- } -- if (my_eaz) -- matchret = isdn_msncmp(eaz, my_eaz); -- else -- matchret = 1; -- if (!matchret) -- ematch = 1; -- -+ if (!(matchret = isdn_msncmp(eaz, isdn_map_eaz2msn(lp->msn, di)))) -+ ematch = 1; - /* Remember if more numbers eventually can match */ - if (matchret > wret) - wret = matchret; -@@ -2238,17 +2977,122 @@ p = dev->netdev; - printk(KERN_DEBUG "n_fi: if='%s', l.msn=%s, l.flags=%d, l.dstate=%d\n", - lp->name, lp->msn, lp->flags, lp->dialstate); - #endif -+#ifdef CONFIG_ISDN_WITH_ABC_CALLB -+ if ((!matchret) && /* EAZ is matching */ -+ (((!(lp->flags & ISDN_NET_CONNECTED)) && /* but not connected */ -+ (USG_NONE(dev->usage[idx]))) || /* and ch. unused or */ -+ (lp->dialstate == 4) || (lp->dialstate == 12) || /* if dialing */ -+ ((lp->flags & ISDN_NET_CBOUT) != 0 && /* init a callback */ -+ lp->outgoing != 0 ))) -+ -+ /* -+ ** we dont stop call's anymore (both sides call's syncron) -+ ** it will be problem in any case. -+ ** both sides will make the same. -+ ** i try later to make a switch (check the phon-numbers) -+ ** to detect with side must be stop the call. -+ */ -+#else - if ((!matchret) && /* EAZ is matching */ - (((!(lp->flags & ISDN_NET_CONNECTED)) && /* but not connected */ - (USG_NONE(dev->usage[idx]))) || /* and ch. unused or */ - ((((lp->dialstate == 4) || (lp->dialstate == 12)) && /* if dialing */ - (!(lp->flags & ISDN_NET_CALLBACK))) /* but no callback */ - ))) -+#endif - { - #ifdef ISDN_DEBUG_NET_ICALL - printk(KERN_DEBUG "n_fi: match1, pdev=%d pch=%d\n", - lp->pre_device, lp->pre_channel); - #endif -+#ifdef CONFIG_ISDN_WITH_ABC -+#ifdef CONFIG_ISDN_WITH_ABC_CALLB -+ { -+ int use_this_call = 0; -+ -+ if(!(lp->flags & ISDN_NET_CBOUT) && ((lp->dialstate == 4) || (lp->dialstate == 12))) { -+ -+ /* -+ ** searching for a diff. in the calling-number and the EAZ -+ ** the remote will make the same -+ */ -+ -+ char *pnr = nr; -+ char *pea = eaz; -+ -+ for(;*pnr;pnr++); -+ for(;*pea;pea++); -+ for(pnr--,pea--;pnr >= nr && pea >= eaz && *pea != *pnr;pnr--,pea--); -+ -+ if(pnr < nr || pea < eaz || *pea > *pnr) { -+ -+ p = (isdn_net_dev *) p->next; -+ continue; -+ } -+ -+ use_this_call = 1; -+ } -+ -+ if( use_this_call || -+ ((lp->flags & ISDN_NET_CBOUT) && (lp->flags & ISDN_NET_CONNECTED))) { -+ -+ /* -+ ** the incoming call was to quick. -+ ** the callback-delay-time ist not reached. -+ ** in that case we can stop the call -+ */ -+ -+ if(lp->isdn_device > -1 && lp->isdn_channel > -1) { -+ -+ int minor = isdn_dc2minor(lp->isdn_device,lp->isdn_channel); -+ -+ if(lp->isdn_device != di || lp->isdn_channel != ch) { -+ -+ isdn_ctrl cmd; -+ -+ memset((void *)&cmd,0,sizeof(cmd)); -+ cmd.driver = lp->isdn_device; -+ cmd.command = ISDN_CMD_HANGUP; -+ cmd.arg = lp->isdn_channel; -+ (void) dev->drv[cmd.driver]->interface->command(&cmd); -+ isdn_all_eaz(lp->isdn_device, lp->isdn_channel); -+ -+ if(dev->net_verbose > 1) { -+ -+ printk(KERN_INFO -+ "%s: found outgoing call hangup old call on di %d ch %d\n", -+ lp->name,lp->isdn_device,lp->isdn_channel); -+ } -+ -+ } else if (dev->net_verbose > 1) { -+ -+ printk(KERN_INFO "%s: found outgoing call on same di %d ch %d\n", -+ lp->name,lp->isdn_device,lp->isdn_channel); -+ } -+ -+ if(minor >= 0) { -+ -+ dev->rx_netdev[minor] = NULL; -+ dev->st_netdev[minor] = NULL; -+ } -+ -+ isdn_free_channel(lp->isdn_device, -+ lp->isdn_channel, ISDN_USAGE_NET); -+ -+ } else if (dev->net_verbose > 1) { -+ -+ printk(KERN_INFO "%s: found outgoing call reset callstate \n",lp->name); -+ } -+ -+ lp->flags &= ~ISDN_NET_CONNECTED; -+ lp->isdn_device = -1; -+ lp->isdn_channel = -1; -+ lp->dtimer = 0; -+ lp->dialstate = 0; -+ } -+ } -+#endif -+#endif - if (dev->usage[idx] & ISDN_USAGE_EXCLUSIVE) { - if ((lp->pre_channel != ch) || - (lp->pre_device != di)) { -@@ -2377,6 +3221,12 @@ p = dev->netdev; - continue; - } - } -+#ifdef CONFIG_ISDN_WITH_ABC_CONN_ERROR -+ if(isdn_dwabc_is_interface_disabled(lp)) { -+ restore_flags(flags); -+ return 3; -+ } -+#endif - if (lp->flags & ISDN_NET_CALLBACK) { - int chi; - /* -@@ -2429,6 +3279,47 @@ p = dev->netdev; - restore_flags(flags); - return 0; - } else { -+#ifdef CONFIG_ISDN_WITH_ABC_CALLB -+ { -+ /* -+ ** this is a sanity-check. -+ ** check for double use (device and channel) -+ ** will be very near to a kernel-crash in that case -+ */ -+ isdn_net_dev *sp = dev->netdev; -+ int s_shl; -+ isdn_net_local *ml; -+ -+ for(s_shl=0; s_shl < 2048 && sp != NULL; sp = (isdn_net_dev *)sp->next, s_shl++) { -+ -+ if(sp == p || (ml = sp->local) == NULL) -+ continue; -+ -+ if(ml->isdn_device != di || ml->isdn_channel != ch) -+ continue; -+ -+ if(ml->dialstate != 4 && ml->dialstate != 12) { -+ -+ /* -+ ** wrong situation -+ */ -+ break; -+ } -+ -+ isdn_net_unbind_channel(ml); -+ } -+ -+ if(sp != NULL) { -+ -+ printk(KERN_DEBUG -+"%s: call from %s -> %s (drv %d chan %d duplicated with %s) \n", -+ lp->name, nr, eaz,di,ch, -+ sp->local->name ); -+ -+ restore_flags(flags); -+ return 3; -+ }} -+#endif - printk(KERN_DEBUG "%s: call from %s -> %s accepted\n", lp->name, nr, - eaz); - /* if this interface is dialing, it does it probably on a different -@@ -2518,7 +3409,11 @@ isdn_net_force_dial_lp(isdn_net_local * - lp->l3_proto, - lp->pre_device, - lp->pre_channel, -+#ifdef CONFIG_ISDN_WITH_ABC_OUTGOING_EAZ -+ (*lp->dw_out_msn) ? lp->dw_out_msn : lp->msn) -+#else - lp->msn) -+#endif - ) < 0) { - printk(KERN_WARNING "isdn_net_force_dial: No channel for %s\n", lp->name); - restore_flags(flags); -@@ -2601,7 +3496,11 @@ isdn_net_new(char *name, struct net_devi - strcpy(netdev->local->name, " "); - else - strcpy(netdev->local->name, name); -+#ifdef COMPAT_NO_SOFTNET -+ netdev->dev.name = netdev->local->name; -+#else - strcpy(netdev->dev.name, netdev->local->name); -+#endif - netdev->dev.priv = netdev->local; - netdev->dev.init = isdn_net_init; - netdev->local->p_encap = ISDN_NET_ENCAP_RAWIP; -@@ -2619,11 +3518,13 @@ isdn_net_new(char *name, struct net_devi - ((isdn_net_local *) q->priv)->slave = &(netdev->dev); - } else { - /* Device shall be a master */ -+#ifndef COMPAT_NO_SOFTNET - /* - * Watchdog timer (currently) for master only. - */ - netdev->dev.tx_timeout = isdn_net_tx_timeout; - netdev->dev.watchdog_timeo = ISDN_NET_TX_TIMEOUT; -+#endif - if (register_netdev(&netdev->dev) != 0) { - printk(KERN_WARNING "isdn_net: Could not register net-device\n"); - kfree(netdev->local); -@@ -2660,6 +3561,9 @@ isdn_net_new(char *name, struct net_devi - netdev->local->hupflags = ISDN_INHUP; /* Do hangup even on incoming calls */ - netdev->local->onhtime = 10; /* Default hangup-time for saving costs - of those who forget configuring this */ -+#ifdef CONFIG_ISDN_WITH_ABC -+ netdev->local->dw_abc_old_onhtime = netdev->local->onhtime; -+#endif - netdev->local->dialmax = 1; - netdev->local->flags = ISDN_NET_CBHUP | ISDN_NET_DM_MANUAL; /* Hangup before Callback, manual dial */ - netdev->local->cbdelay = 25; /* Wait 5 secs before Callback */ -@@ -2833,7 +3737,6 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg - - /* If binding is exclusive, try to grab the channel */ - save_flags(flags); -- cli(); - if ((i = isdn_get_free_channel(ISDN_USAGE_NET, - lp->l2_proto, lp->l3_proto, drvidx, - chidx, lp->msn)) < 0) { -@@ -2862,6 +3765,9 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg - lp->pre_device = drvidx; - lp->pre_channel = chidx; - lp->onhtime = cfg->onhtime; -+#ifdef CONFIG_ISDN_WITH_ABC -+ lp->dw_abc_old_onhtime = lp->onhtime; -+#endif - lp->charge = cfg->charge; - lp->l2_proto = cfg->l2_proto; - lp->l3_proto = cfg->l3_proto; -@@ -2935,6 +3841,9 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg - } - } - lp->p_encap = cfg->p_encap; -+#ifdef CONFIG_ISDN_WITH_ABC -+ isdn_dw_abc_reset_interface(lp,0); -+#endif - return 0; - } - return -ENODEV; -@@ -3011,6 +3920,9 @@ isdn_net_addphone(isdn_net_ioctl_phone * - n->num[sizeof(n->num) - 1] = 0; - n->next = p->local->phone[phone->outgoing & 1]; - p->local->phone[phone->outgoing & 1] = n; -+#ifdef CONFIG_ISDN_WITH_ABC -+ isdn_dwabc_test_phone(p->local); -+#endif - return 0; - } - return -ENODEV; -@@ -3104,6 +4016,9 @@ isdn_net_delphone(isdn_net_ioctl_phone * - else - p->local->phone[inout] = n->next; - kfree(n); -+#ifdef CONFIG_ISDN_WITH_ABC -+ isdn_dwabc_test_phone(p->local); -+#endif - restore_flags(flags); - return 0; - } -@@ -3139,6 +4054,9 @@ isdn_net_rmallphone(isdn_net_dev * p) - p->local->phone[i] = NULL; - } - p->local->dial = NULL; -+#ifdef CONFIG_ISDN_WITH_ABC -+ isdn_dwabc_test_phone(p->local); -+#endif - restore_flags(flags); - return 0; - } -@@ -3222,6 +4140,10 @@ isdn_net_realrm(isdn_net_dev * p, isdn_n - /* If no more net-devices remain, disable auto-hangup timer */ - if (dev->netdev == NULL) - isdn_timer_ctrl(ISDN_TIMER_NETHANGUP, 0); -+#ifdef CONFIG_ISDN_WITH_ABC -+ isdn_dw_clear_if(~0l,p->local); -+ dwabc_bsd_free(p->local); -+#endif - restore_flags(flags); - kfree(p->local); - kfree(p); ---- a/drivers/isdn/isdn_net.h -+++ b/drivers/isdn/isdn_net.h -@@ -1,4 +1,4 @@ --/* $Id: isdn_net.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: isdn_net.h,v 1.23 2001/11/07 22:35:48 kai Exp $ - * - * header for Linux ISDN subsystem, network related functions (linklevel). - * -@@ -26,6 +26,7 @@ - #define CISCO_ADDR_BROADCAST 0x8f - #define CISCO_CTRL 0x00 - #define CISCO_TYPE_CDP 0x2000 -+#define CISCO_TYPE_INET 0x0800 - #define CISCO_TYPE_SLARP 0x8035 - #define CISCO_SLARP_REQUEST 0 - #define CISCO_SLARP_REPLY 1 -@@ -106,8 +107,6 @@ static __inline__ void isdn_net_add_to_b - spin_lock_irqsave(&nd->queue_lock, flags); - - lp = nd->queue; --// printk(KERN_DEBUG __FUNCTION__": lp:%s(%p) nlp:%s(%p) last(%p)\n", --// lp->name, lp, nlp->name, nlp, lp->last); - nlp->last = lp->last; - lp->last->next = nlp; - lp->last = nlp; -@@ -127,20 +126,12 @@ static __inline__ void isdn_net_rm_from_ - if (lp->master) - master_lp = (isdn_net_local *) lp->master->priv; - --// printk(KERN_DEBUG __FUNCTION__": lp:%s(%p) mlp:%s(%p) last(%p) next(%p) mndq(%p)\n", --// lp->name, lp, master_lp->name, master_lp, lp->last, lp->next, master_lp->netdev->queue); - spin_lock_irqsave(&master_lp->netdev->queue_lock, flags); - lp->last->next = lp->next; - lp->next->last = lp->last; -- if (master_lp->netdev->queue == lp) { -+ if (master_lp->netdev->queue == lp) - master_lp->netdev->queue = lp->next; -- if (lp->next == lp) { /* last in queue */ -- master_lp->netdev->queue = master_lp->netdev->local; -- } -- } - lp->next = lp->last = lp; /* (re)set own pointers */ --// printk(KERN_DEBUG __FUNCTION__": mndq(%p)\n", --// master_lp->netdev->queue); - spin_unlock_irqrestore(&master_lp->netdev->queue_lock, flags); - } - ---- a/drivers/isdn/isdn_ppp.c -+++ b/drivers/isdn/isdn_ppp.c -@@ -1,4 +1,4 @@ --/* $Id: isdn_ppp.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: isdn_ppp.c,v 1.94 2001/11/07 22:35:48 kai Exp $ - * - * Linux ISDN subsystem, functions for synchronous PPP (linklevel). - * -@@ -13,9 +13,6 @@ - #include <linux/isdn.h> - #include <linux/poll.h> - #include <linux/ppp-comp.h> --#ifdef CONFIG_IPPP_FILTER --#include <linux/filter.h> --#endif - - #include "isdn_common.h" - #include "isdn_ppp.h" -@@ -72,11 +69,19 @@ static void isdn_ppp_mp_cleanup( isdn_ne - static int isdn_ppp_bundle(struct ippp_struct *, int unit); - #endif /* CONFIG_ISDN_MPP */ - --char *isdn_ppp_revision = "$Revision: 1.1.4.1 $"; -+char *isdn_ppp_revision = "$Revision: 1.94 $"; - - static struct ippp_struct *ippp_table[ISDN_MAX_CHANNELS]; - -+#ifndef CONFIG_ISDN_WITH_ABC - static struct isdn_ppp_compressor *ipc_head = NULL; -+#else -+ /* -+ ** make compressor's common usable -+ */ -+struct isdn_ppp_compressor *isdn_ippp_comp_head = NULL; -+#define ipc_head isdn_ippp_comp_head -+#endif - - /* - * frame log (debug) -@@ -110,11 +115,8 @@ isdn_ppp_free(isdn_net_local * lp) - unsigned long flags; - struct ippp_struct *is; - -- if (lp->ppp_slot < 0 || lp->ppp_slot > ISDN_MAX_CHANNELS) { -- printk(KERN_ERR "%s: ppp_slot(%d) out of range\n", -- __FUNCTION__, lp->ppp_slot); -+ if (lp->ppp_slot < 0 || lp->ppp_slot > ISDN_MAX_CHANNELS) - return 0; -- } - - save_flags(flags); - cli(); -@@ -130,12 +132,7 @@ isdn_ppp_free(isdn_net_local * lp) - lp->netdev->pb->ref_ct--; - spin_unlock(&lp->netdev->pb->lock); - #endif /* CONFIG_ISDN_MPP */ -- if (lp->ppp_slot < 0 || lp->ppp_slot > ISDN_MAX_CHANNELS) { -- printk(KERN_ERR "%s: ppp_slot(%d) now invalid\n", -- __FUNCTION__, lp->ppp_slot); -- restore_flags(flags); -- return 0; -- } -+ - is = ippp_table[lp->ppp_slot]; - if ((is->state & IPPP_CONNECT)) - isdn_ppp_closewait(lp->ppp_slot); /* force wakeup on ippp device */ -@@ -231,13 +228,12 @@ isdn_ppp_bind(isdn_net_local * lp) - void - isdn_ppp_wakeup_daemon(isdn_net_local * lp) - { -- if (lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS) { -- printk(KERN_ERR "%s: ppp_slot(%d) out of range\n", -- __FUNCTION__, lp->ppp_slot); -+ if (lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS) - return; -- } -+ - ippp_table[lp->ppp_slot]->state = IPPP_OPEN | IPPP_CONNECT | IPPP_NOBLOCK; -- wake_up_interruptible(&ippp_table[lp->ppp_slot]->wq); -+ -+ wake_up_interruptible(&ippp_table[lp->ppp_slot]->wq); - } - - /* -@@ -250,14 +246,13 @@ isdn_ppp_closewait(int slot) - { - struct ippp_struct *is; - -- if (slot < 0 || slot >= ISDN_MAX_CHANNELS) { -- printk(KERN_ERR "%s: slot(%d) out of range\n", -- __FUNCTION__, slot); -+ if (slot < 0 || slot >= ISDN_MAX_CHANNELS) - return 0; -- } - is = ippp_table[slot]; -+ - if (is->state) - wake_up_interruptible(&is->wq); -+ - is->state = IPPP_CLOSEWAIT; - return 1; - } -@@ -295,9 +290,11 @@ isdn_ppp_open(int min, struct file *file - return -EBUSY; - } - is = file->private_data = ippp_table[slot]; -- -- printk(KERN_DEBUG "ippp, open, slot: %d, minor: %d, state: %04x\n", -- slot, min, is->state); -+ -+#if 0 -+ if (is->debug & 0x1) -+#endif -+ printk(KERN_DEBUG "ippp, open, slot: %d, minor: %d, state: %04x\n", slot, min, is->state); - - /* compression stuff */ - is->link_compressor = is->compressor = NULL; -@@ -327,10 +324,7 @@ isdn_ppp_open(int min, struct file *file - */ - is->slcomp = slhc_init(16, 16); /* not necessary for 2. link in bundle */ - #endif --#ifdef CONFIG_IPPP_FILTER -- is->pass_filter.filter = NULL; -- is->active_filter.filter = NULL; --#endif -+ - is->state = IPPP_OPEN; - - return 0; -@@ -349,20 +343,12 @@ isdn_ppp_release(int min, struct file *f - return; - is = file->private_data; - -- if (!is) { -- printk(KERN_ERR "%s: no file->private_data\n", __FUNCTION__); -- return; -- } - if (is->debug & 0x1) - printk(KERN_DEBUG "ippp: release, minor: %d %lx\n", min, (long) is->lp); - - if (is->lp) { /* a lp address says: this link is still up */ - isdn_net_dev *p = is->lp->netdev; - -- if (!p) { -- printk(KERN_ERR "%s: no lp->netdev\n", __FUNCTION__); -- return; -- } - is->state &= ~IPPP_CONNECT; /* -> effect: no call of wakeup */ - /* - * isdn_net_hangup() calls isdn_ppp_free() -@@ -385,18 +371,8 @@ isdn_ppp_release(int min, struct file *f - slhc_free(is->slcomp); - is->slcomp = NULL; - #endif --#ifdef CONFIG_IPPP_FILTER -- if (is->pass_filter.filter) { -- kfree(is->pass_filter.filter); -- is->pass_filter.filter = NULL; -- } -- if (is->active_filter.filter) { -- kfree(is->active_filter.filter); -- is->active_filter.filter = NULL; -- } --#endif - --/* TODO: if this was the previous master: link the stuff to the new master */ -+/* TODO: if this was the previous master: link the the stuff to the new master */ - if(is->comp_stat) - is->compressor->free(is->comp_stat); - if(is->link_comp_stat) -@@ -509,13 +485,15 @@ isdn_ppp_ioctl(int min, struct file *fil - if (val & SC_ENABLE_IP && !(is->pppcfg & SC_ENABLE_IP) && (is->state & IPPP_CONNECT)) { - if (lp) { - /* OK .. we are ready to send buffers */ -- is->pppcfg = val; /* isdn_ppp_xmit test for SC_ENABLE_IP !!! */ - netif_wake_queue(&lp->netdev->dev); -- break; - } - } - is->pppcfg = val; - break; -+#if 0 -+ case PPPIOCGSTAT: /* read PPP statistic information */ -+ break; -+#endif - case PPPIOCGIDLE: /* get idle time information */ - if (lp) { - struct ppp_idle pidle; -@@ -604,39 +582,6 @@ isdn_ppp_ioctl(int min, struct file *fil - } - return set_arg((void *)arg,&pci,sizeof(struct pppcallinfo)); - } --#ifdef CONFIG_IPPP_FILTER -- case PPPIOCSPASS: -- case PPPIOCSACTIVE: -- { -- struct sock_fprog uprog, *filtp; -- struct sock_filter *code = NULL; -- int len, err; -- -- if (copy_from_user(&uprog, (void *) arg, sizeof(uprog))) -- return -EFAULT; -- if (uprog.len > 0 && uprog.len < 65536) { -- len = uprog.len * sizeof(struct sock_filter); -- code = kmalloc(len, GFP_KERNEL); -- if (code == NULL) -- return -ENOMEM; -- if (copy_from_user(code, uprog.filter, len)) { -- kfree(code); -- return -EFAULT; -- } -- err = sk_chk_filter(code, uprog.len); -- if (err) { -- kfree(code); -- return err; -- } -- } -- filtp = (cmd == PPPIOCSPASS) ? &is->pass_filter : &is->active_filter; -- if (filtp->filter) -- kfree(filtp->filter); -- filtp->filter = code; -- filtp->len = uprog.len; -- break; -- } --#endif /* CONFIG_IPPP_FILTER */ - default: - break; - } -@@ -699,7 +644,7 @@ isdn_ppp_fill_rq(unsigned char *buf, int - struct ippp_struct *is; - - if (slot < 0 || slot >= ISDN_MAX_CHANNELS) { -- printk(KERN_WARNING "ippp: illegal slot(%d).\n", slot); -+ printk(KERN_WARNING "ippp: illegal slot.\n"); - return 0; - } - is = ippp_table[slot]; -@@ -976,8 +921,7 @@ void isdn_ppp_receive(isdn_net_dev * net - - slot = lp->ppp_slot; - if (slot < 0 || slot > ISDN_MAX_CHANNELS) { -- printk(KERN_ERR "isdn_ppp_receive: lp->ppp_slot(%d)\n", -- lp->ppp_slot); -+ printk(KERN_ERR "isdn_ppp_receive: lp->ppp_slot %d\n", lp->ppp_slot); - kfree_skb(skb); - return; - } -@@ -1026,23 +970,19 @@ isdn_ppp_push_higher(isdn_net_dev * net_ - { - struct net_device *dev = &net_dev->dev; - struct ippp_struct *is, *mis; -- isdn_net_local *mlp = NULL; - int slot; - - slot = lp->ppp_slot; - if (slot < 0 || slot > ISDN_MAX_CHANNELS) { -- printk(KERN_ERR "isdn_ppp_push_higher: lp->ppp_slot(%d)\n", -- lp->ppp_slot); -+ printk(KERN_ERR "isdn_ppp_push_higher: lp->ppp_slot %d\n", lp->ppp_slot); - goto drop_packet; - } - is = ippp_table[slot]; - - if (lp->master) { // FIXME? -- mlp = (isdn_net_local *) lp->master->priv; -- slot = mlp->ppp_slot; -+ slot = ((isdn_net_local *) (lp->master->priv))->ppp_slot; - if (slot < 0 || slot > ISDN_MAX_CHANNELS) { -- printk(KERN_ERR "isdn_ppp_push_higher: master->ppp_slot(%d)\n", -- lp->ppp_slot); -+ printk(KERN_ERR "isdn_ppp_push_higher: master->ppp_slot %d\n", lp->ppp_slot); - goto drop_packet; - } - } -@@ -1076,11 +1016,6 @@ isdn_ppp_push_higher(isdn_net_dev * net_ - case PPP_VJC_UNCOMP: - if (is->debug & 0x20) - printk(KERN_DEBUG "isdn_ppp: VJC_UNCOMP\n"); -- if (net_dev->local->ppp_slot < 0) { -- printk(KERN_ERR "%s: net_dev->local->ppp_slot(%d) out of range\n", -- __FUNCTION__, net_dev->local->ppp_slot); -- goto drop_packet; -- } - if (slhc_remember(ippp_table[net_dev->local->ppp_slot]->slcomp, skb->data, skb->len) <= 0) { - printk(KERN_WARNING "isdn_ppp: received illegal VJC_UNCOMP frame!\n"); - goto drop_packet; -@@ -1102,11 +1037,6 @@ isdn_ppp_push_higher(isdn_net_dev * net_ - } - skb_put(skb, skb_old->len + 128); - memcpy(skb->data, skb_old->data, skb_old->len); -- if (net_dev->local->ppp_slot < 0) { -- printk(KERN_ERR "%s: net_dev->local->ppp_slot(%d) out of range\n", -- __FUNCTION__, net_dev->local->ppp_slot); -- goto drop_packet; -- } - pkt_len = slhc_uncompress(ippp_table[net_dev->local->ppp_slot]->slcomp, - skb->data, skb_old->len); - kfree_skb(skb_old); -@@ -1133,36 +1063,12 @@ isdn_ppp_push_higher(isdn_net_dev * net_ - return; - } - --#ifdef CONFIG_IPPP_FILTER -- /* check if the packet passes the pass and active filters -- * the filter instructions are constructed assuming -- * a four-byte PPP header on each packet (which is still present) */ -- skb_push(skb, 4); -- skb->data[0] = 0; /* indicate inbound */ -- -- if (is->pass_filter.filter -- && sk_run_filter(skb, is->pass_filter.filter, -- is->pass_filter.len) == 0) { -- if (is->debug & 0x2) -- printk(KERN_DEBUG "IPPP: inbound frame filtered.\n"); -- kfree_skb(skb); -- return; -- } -- if (!(is->active_filter.filter -- && sk_run_filter(skb, is->active_filter.filter, -- is->active_filter.len) == 0)) { -- if (is->debug & 0x2) -- printk(KERN_DEBUG "IPPP: link-active filter: reseting huptimer.\n"); -- lp->huptimer = 0; -- if (mlp) -- mlp->huptimer = 0; -- } -- skb_pull(skb, 4); --#else /* CONFIG_IPPP_FILTER */ -- lp->huptimer = 0; -- if (mlp) -- mlp->huptimer = 0; --#endif /* CONFIG_IPPP_FILTER */ -+ /* Reset hangup-timer */ -+ lp->huptimer = 0; -+#ifdef CONFIG_ISDN_WITH_ABC_CONN_ERROR -+ lp->dw_abc_bchan_errcnt = 0; -+#endif -+ - skb->dev = dev; - skb->mac.raw = skb->data; - netif_rx(skb); -@@ -1199,6 +1105,7 @@ static unsigned char *isdn_ppp_skb_push( - return skb_push(skb,len); - } - -+ - /* - * send ppp frame .. we expect a PIDCOMPressable proto -- - * (here: currently always PPP_IP,PPP_VJC_COMP,PPP_VJC_UNCOMP) -@@ -1214,25 +1121,23 @@ isdn_ppp_xmit(struct sk_buff *skb, struc - isdn_net_dev *nd; - unsigned int proto = PPP_IP; /* 0x21 */ - struct ippp_struct *ipt,*ipts; -- int slot, retval = 0; -+ int slot; - - mlp = (isdn_net_local *) (netdev->priv); - nd = mlp->netdev; /* get master lp */ - - slot = mlp->ppp_slot; - if (slot < 0 || slot > ISDN_MAX_CHANNELS) { -- printk(KERN_ERR "isdn_ppp_xmit: lp->ppp_slot(%d)\n", -- mlp->ppp_slot); -+ printk(KERN_ERR "isdn_ppp_xmit: lp->ppp_slot %d\n", mlp->ppp_slot); - kfree_skb(skb); -- goto out; -+ return 0; - } - ipts = ippp_table[slot]; - - if (!(ipts->pppcfg & SC_ENABLE_IP)) { /* PPP connected ? */ - if (ipts->debug & 0x1) - printk(KERN_INFO "%s: IP frame delayed.\n", netdev->name); -- retval = 1; -- goto out; -+ return 1; - } - - switch (ntohs(skb->protocol)) { -@@ -1246,25 +1151,24 @@ isdn_ppp_xmit(struct sk_buff *skb, struc - printk(KERN_ERR "isdn_ppp: skipped unsupported protocol: %#x.\n", - skb->protocol); - dev_kfree_skb(skb); -- goto out; -+ return 0; - } - - lp = isdn_net_get_locked_lp(nd); - if (!lp) { - printk(KERN_WARNING "%s: all channels busy - requeuing!\n", netdev->name); -- retval = 1; -- goto out; -+ return 1; - } - /* we have our lp locked from now on */ - - slot = lp->ppp_slot; - if (slot < 0 || slot > ISDN_MAX_CHANNELS) { -- printk(KERN_ERR "isdn_ppp_xmit: lp->ppp_slot(%d)\n", -- lp->ppp_slot); -+ printk(KERN_ERR "isdn_ppp_xmit: lp->ppp_slot %d\n", lp->ppp_slot); - kfree_skb(skb); -- goto unlock; -+ return 0; - } - ipt = ippp_table[slot]; -+ lp->huptimer = 0; - - /* - * after this line .. requeueing in the device queue is no longer allowed!!! -@@ -1275,34 +1179,6 @@ isdn_ppp_xmit(struct sk_buff *skb, struc - */ - skb_pull(skb,IPPP_MAX_HEADER); - --#ifdef CONFIG_IPPP_FILTER -- /* check if we should pass this packet -- * the filter instructions are constructed assuming -- * a four-byte PPP header on each packet */ -- skb_push(skb, 4); -- skb->data[0] = 1; /* indicate outbound */ -- *(u_int16_t *)(skb->data + 2) = htons(proto); -- -- if (ipt->pass_filter.filter -- && sk_run_filter(skb, ipt->pass_filter.filter, -- ipt->pass_filter.len) == 0) { -- if (ipt->debug & 0x4) -- printk(KERN_DEBUG "IPPP: outbound frame filtered.\n"); -- kfree_skb(skb); -- goto unlock; -- } -- if (!(ipt->active_filter.filter -- && sk_run_filter(skb, ipt->active_filter.filter, -- ipt->active_filter.len) == 0)) { -- if (ipt->debug & 0x4) -- printk(KERN_DEBUG "IPPP: link-active filter: reseting huptimer.\n"); -- lp->huptimer = 0; -- } -- skb_pull(skb, 4); --#else /* CONFIG_IPPP_FILTER */ -- lp->huptimer = 0; --#endif /* CONFIG_IPPP_FILTER */ -- - if (ipt->debug & 0x4) - printk(KERN_DEBUG "xmit skb, len %d\n", (int) skb->len); - if (ipts->debug & 0x40) -@@ -1440,54 +1316,9 @@ isdn_ppp_xmit(struct sk_buff *skb, struc - - unlock: - spin_unlock_bh(&lp->xmit_lock); -- out: -- return retval; -+ return 0; - } - --#ifdef CONFIG_IPPP_FILTER --/* -- * check if this packet may trigger auto-dial. -- */ -- --int isdn_ppp_autodial_filter(struct sk_buff *skb, isdn_net_local *lp) --{ -- struct ippp_struct *is = ippp_table[lp->ppp_slot]; -- u_int16_t proto; -- int drop = 0; -- -- switch (ntohs(skb->protocol)) { -- case ETH_P_IP: -- proto = PPP_IP; -- break; -- case ETH_P_IPX: -- proto = PPP_IPX; -- break; -- default: -- printk(KERN_ERR "isdn_ppp_autodial_filter: unsupported protocol 0x%x.\n", -- skb->protocol); -- return 1; -- } -- -- /* the filter instructions are constructed assuming -- * a four-byte PPP header on each packet. we have to -- * temporarily remove part of the fake header stuck on -- * earlier. -- */ -- skb_pull(skb, IPPP_MAX_HEADER - 4); -- skb->data[0] = 1; /* indicate outbound */ -- *(u_int16_t *)(skb->data + 2) = htons(proto); -- -- drop |= is->pass_filter.filter -- && sk_run_filter(skb, is->pass_filter.filter, -- is->pass_filter.len) == 0; -- drop |= is->active_filter.filter -- && sk_run_filter(skb, is->active_filter.filter, -- is->active_filter.len) == 0; -- -- skb_push(skb, IPPP_MAX_HEADER - 4); -- return drop; --} --#endif - #ifdef CONFIG_ISDN_MPP - - /* this is _not_ rfc1990 header, but something we convert both short and long -@@ -1537,15 +1368,8 @@ static ippp_bundle * isdn_ppp_mp_bundle_ - - static int isdn_ppp_mp_init( isdn_net_local * lp, ippp_bundle * add_to ) - { -- struct ippp_struct * is; -- -- if (lp->ppp_slot < 0) { -- printk(KERN_ERR "%s: lp->ppp_slot(%d) out of range\n", -- __FUNCTION__, lp->ppp_slot); -- return(-EINVAL); -- } -- -- is = ippp_table[lp->ppp_slot]; -+ struct ippp_struct * is = ippp_table[lp->ppp_slot]; -+ - if (add_to) { - if( lp->netdev->pb ) - lp->netdev->pb->ref_ct--; -@@ -1591,8 +1415,7 @@ static void isdn_ppp_mp_receive(isdn_net - stats = &mp->stats; - slot = lp->ppp_slot; - if (slot < 0 || slot > ISDN_MAX_CHANNELS) { -- printk(KERN_ERR "%s: lp->ppp_slot(%d)\n", -- __FUNCTION__, lp->ppp_slot); -+ printk(KERN_ERR "isdn_ppp_mp_receive: lp->ppp_slot %d\n", lp->ppp_slot); - stats->frame_drops++; - dev_kfree_skb(skb); - spin_unlock_irqrestore(&mp->lock, flags); -@@ -1628,8 +1451,7 @@ static void isdn_ppp_mp_receive(isdn_net - for (lpq = net_dev->queue;;) { - slot = lpq->ppp_slot; - if (slot < 0 || slot > ISDN_MAX_CHANNELS) { -- printk(KERN_ERR "%s: lpq->ppp_slot(%d)\n", -- __FUNCTION__, lpq->ppp_slot); -+ printk(KERN_ERR "isdn_ppp_mp_receive: lpq->ppp_slot %d\n", lpq->ppp_slot); - } else { - u32 lls = ippp_table[slot]->last_link_seqno; - if (MP_LT(lls, minseq)) -@@ -1861,14 +1683,9 @@ void isdn_ppp_mp_reassembly( isdn_net_de - struct sk_buff * skb; - unsigned int tot_len; - -- if (lp->ppp_slot < 0 || lp->ppp_slot > ISDN_MAX_CHANNELS) { -- printk(KERN_ERR "%s: lp->ppp_slot(%d) out of range\n", -- __FUNCTION__, lp->ppp_slot); -- return; -- } - if( MP_FLAGS(from) == (MP_BEGIN_FRAG | MP_END_FRAG) ) { - if( ippp_table[lp->ppp_slot]->debug & 0x40 ) -- printk(KERN_DEBUG "isdn_mppp: reassembly: frame %d, " -+ printk(KERN_DEBUG"isdn_mppp: reassembly: frame %d, " - "len %d\n", MP_SEQ(from), from->len ); - skb = from; - skb_pull(skb, MP_HEADER_LEN); -@@ -1987,10 +1804,8 @@ isdn_ppp_dev_ioctl_stats(int slot, struc - memset(&t, 0, sizeof(struct ppp_stats)); - if (dev->flags & IFF_UP) { - t.p.ppp_ipackets = lp->stats.rx_packets; -- t.p.ppp_ibytes = lp->stats.rx_bytes; - t.p.ppp_ierrors = lp->stats.rx_errors; - t.p.ppp_opackets = lp->stats.tx_packets; -- t.p.ppp_obytes = lp->stats.tx_bytes; - t.p.ppp_oerrors = lp->stats.tx_errors; - #ifdef CONFIG_ISDN_PPP_VJ - if (slot >= 0 && ippp_table[slot]->slcomp) { -@@ -2018,6 +1833,9 @@ isdn_ppp_dev_ioctl(struct net_device *de - int len; - isdn_net_local *lp = (isdn_net_local *) dev->priv; - -+#if 0 -+ printk(KERN_DEBUG "ippp, dev_ioctl: cmd %#08x , %d \n", cmd, lp->ppp_slot); -+#endif - - if (lp->p_encap != ISDN_NET_ENCAP_SYNCPPP) - return -EINVAL; -@@ -2432,7 +2250,7 @@ static void isdn_ppp_ccp_reset_trans(str - return; - } - rs->state = CCPResetSentReq; -- /* We always expect an Ack if the decompressor doesn't -+ /* We always expect an Ack if the decompressor doesnt - know better */ - rs->expra = 1; - rs->dlen = 0; -@@ -2583,7 +2401,13 @@ static struct sk_buff *isdn_ppp_compress - } - - if(type) { /* type=1 => Link compression */ -+#if 0 -+ compressor = is->link_compressor; -+ stat = is->link_comp_stat; -+ new_proto = PPP_LINK_COMP; -+#else - return skb_in; -+#endif - } - else { - if(!master) { -@@ -2631,31 +2455,18 @@ static struct sk_buff *isdn_ppp_compress - static void isdn_ppp_receive_ccp(isdn_net_dev *net_dev, isdn_net_local *lp, - struct sk_buff *skb,int proto) - { -- struct ippp_struct *is; -+ struct ippp_struct *is = ippp_table[lp->ppp_slot]; - struct ippp_struct *mis; - int len; - struct isdn_ppp_resetparams rsparm; - unsigned char rsdata[IPPP_RESET_MAXDATABYTES]; - -- printk(KERN_DEBUG "Received CCP frame from peer slot(%d)\n", -- lp->ppp_slot); -- if (lp->ppp_slot < 0 || lp->ppp_slot > ISDN_MAX_CHANNELS) { -- printk(KERN_ERR "%s: lp->ppp_slot(%d) out of range\n", -- __FUNCTION__, lp->ppp_slot); -- return; -- } -- is = ippp_table[lp->ppp_slot]; -+ printk(KERN_DEBUG "Received CCP frame from peer\n"); - isdn_ppp_frame_log("ccp-rcv", skb->data, skb->len, 32, is->unit,lp->ppp_slot); - -- if(lp->master) { -- int slot = ((isdn_net_local *) (lp->master->priv))->ppp_slot; -- if (slot < 0 || slot > ISDN_MAX_CHANNELS) { -- printk(KERN_ERR "%s: slot(%d) out of range\n", -- __FUNCTION__, slot); -- return; -- } -- mis = ippp_table[slot]; -- } else -+ if(lp->master) -+ mis = ippp_table[((isdn_net_local *) (lp->master->priv))->ppp_slot]; -+ else - mis = is; - - switch(skb->data[0]) { -@@ -2807,18 +2618,13 @@ static void isdn_ppp_receive_ccp(isdn_ne - - static void isdn_ppp_send_ccp(isdn_net_dev *net_dev, isdn_net_local *lp, struct sk_buff *skb) - { -- struct ippp_struct *mis,*is; -- int proto, slot = lp->ppp_slot; -+ struct ippp_struct *mis,*is = ippp_table[lp->ppp_slot]; -+ int proto; - unsigned char *data; - - if(!skb || skb->len < 3) - return; -- if (slot < 0 || slot > ISDN_MAX_CHANNELS) { -- printk(KERN_ERR "%s: lp->ppp_slot(%d) out of range\n", -- __FUNCTION__, slot); -- return; -- } -- is = ippp_table[slot]; -+ - /* Daemon may send with or without address and control field comp */ - data = skb->data; - if(!(is->pppcfg & SC_COMP_AC) && data[0] == 0xff && data[1] == 0x03) { -@@ -2834,17 +2640,12 @@ static void isdn_ppp_send_ccp(isdn_net_d - printk(KERN_DEBUG "Received CCP frame from daemon:\n"); - isdn_ppp_frame_log("ccp-xmit", skb->data, skb->len, 32, is->unit,lp->ppp_slot); - -- if (lp->master) { -- slot = ((isdn_net_local *) (lp->master->priv))->ppp_slot; -- if (slot < 0 || slot > ISDN_MAX_CHANNELS) { -- printk(KERN_ERR "%s: slot(%d) out of range\n", -- __FUNCTION__, slot); -- return; -- } -- mis = ippp_table[slot]; -- } else -- mis = is; -- if (mis != is) -+ if(lp->master) -+ mis = ippp_table[((isdn_net_local *) (lp->master->priv))->ppp_slot]; -+ else -+ mis = is; -+ -+ if(mis != is) - printk(KERN_DEBUG "isdn_ppp: Ouch! Master CCP sends on slave slot!\n"); - - switch(data[2]) { ---- a/drivers/isdn/isdn_ppp.h -+++ b/drivers/isdn/isdn_ppp.h -@@ -1,4 +1,4 @@ --/* $Id: isdn_ppp.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: isdn_ppp.h,v 1.18 2001/09/24 13:22:42 kai Exp $ - * - * header for Linux ISDN subsystem, functions for synchronous PPP (linklevel). - * -@@ -19,7 +19,6 @@ extern int isdn_ppp_init(void); - extern void isdn_ppp_cleanup(void); - extern int isdn_ppp_free(isdn_net_local *); - extern int isdn_ppp_bind(isdn_net_local *); --extern int isdn_ppp_autodial_filter(struct sk_buff *, isdn_net_local *); - extern int isdn_ppp_xmit(struct sk_buff *, struct net_device *); - extern void isdn_ppp_receive(isdn_net_dev *, isdn_net_local *, struct sk_buff *); - extern int isdn_ppp_dev_ioctl(struct net_device *, struct ifreq *, int); ---- a/drivers/isdn/isdn_tty.c -+++ b/drivers/isdn/isdn_tty.c -@@ -1,4 +1,4 @@ --/* $Id: isdn_tty.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: isdn_tty.c,v 1.104 2002/02/09 21:19:11 keil Exp $ - * - * Linux ISDN subsystem, tty functions and AT-command emulator (linklevel). - * -@@ -53,7 +53,7 @@ static int bit2si[8] = - static int si2bit[8] = - {4, 1, 4, 4, 4, 4, 4, 4}; - --char *isdn_tty_revision = "$Revision: 1.1.4.1 $"; -+char *isdn_tty_revision = "$Revision: 1.104 $"; - - - /* isdn_tty_try_read() is called from within isdn_tty_rcv_skb() -@@ -321,7 +321,10 @@ isdn_tty_tint(modem_info * info) - info->send_outstanding++; - info->msr &= ~UART_MSR_CTS; - info->lsr &= ~UART_LSR_TEMT; -- tty_wakeup(tty); -+ if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && -+ tty->ldisc.write_wakeup) -+ (tty->ldisc.write_wakeup) (tty); -+ wake_up_interruptible(&tty->write_wait); - return; - } - if (slen < 0) { -@@ -1211,7 +1214,10 @@ isdn_tty_write(struct tty_struct *tty, i - /* If DLE decoding results in zero-transmit, but - * c originally was non-zero, do a wakeup. - */ -- tty_wakeup(tty); -+ if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && -+ tty->ldisc.write_wakeup) -+ (tty->ldisc.write_wakeup) (tty); -+ wake_up_interruptible(&tty->write_wait); - info->msr |= UART_MSR_CTS; - info->lsr |= UART_LSR_TEMT; - } -@@ -1232,6 +1238,7 @@ isdn_tty_write(struct tty_struct *tty, i - } - } - } else -+#ifdef ISDN_TTY_FCLASS1 - if (TTY_IS_FCLASS1(info)) { - int cc = isdn_tty_handleDLEdown(info, m, c); - -@@ -1252,6 +1259,7 @@ isdn_tty_write(struct tty_struct *tty, i - info->xmit_count += cc; - } else - #endif -+#endif - info->xmit_count += c; - } else { - info->msr |= UART_MSR_CTS; -@@ -1329,7 +1337,10 @@ isdn_tty_flush_buffer(struct tty_struct - isdn_tty_cleanup_xmit(info); - info->xmit_count = 0; - restore_flags(flags); -- tty_wakeup(tty); -+ wake_up_interruptible(&tty->write_wait); -+ if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && -+ tty->ldisc.write_wakeup) -+ (tty->ldisc.write_wakeup) (tty); - } - - static void -@@ -1858,7 +1869,8 @@ isdn_tty_close(struct tty_struct *tty, s - isdn_tty_shutdown(info); - if (tty->driver.flush_buffer) - tty->driver.flush_buffer(tty); -- tty_ldisc_flush(tty); -+ if (tty->ldisc.flush_buffer) -+ tty->ldisc.flush_buffer(tty); - info->tty = 0; - info->ncarrier = 0; - tty->closing = 0; -@@ -2306,6 +2318,22 @@ isdn_tty_stat_callback(int i, isdn_ctrl - isdn_tty_at_cout("\r\n", info); - } - return 1; -+ case ISDN_STAT_ALERT: -+#ifdef ISDN_TTY_STAT_DEBUG -+ printk(KERN_DEBUG "tty_STAT_ALERT ttyI%d\n", info->line); -+#endif -+ /* Signal RINGING to tty-device if requested */ -+ if (info->emu.mdmreg[REG_ALERT] & BIT_ALERT) -+ isdn_tty_modem_result(RESULT_RINGING, info); -+ return 1; -+ case ISDN_STAT_PROCEED: -+#ifdef ISDN_TTY_STAT_DEBUG -+ printk(KERN_DEBUG "tty_STAT_PROCEED ttyI%d\n", info->line); -+#endif -+ /* Signal PROCEEDING to tty-device if requested */ -+ if (info->emu.mdmreg[REG_PROCEED] & BIT_PROCEED) -+ isdn_tty_modem_result(RESULT_PROCEEDING, info); -+ return 1; - case ISDN_STAT_DCONN: - #ifdef ISDN_TTY_STAT_DEBUG - printk(KERN_DEBUG "tty_STAT_DCONN ttyI%d\n", info->line); -@@ -2618,7 +2646,7 @@ isdn_tty_modem_result(int code, modem_in - static char *msg[] = - {"OK", "CONNECT", "RING", "NO CARRIER", "ERROR", - "CONNECT 64000", "NO DIALTONE", "BUSY", "NO ANSWER", -- "RINGING", "NO MSN/EAZ", "VCON", "RUNG"}; -+ "RINGING", "NO MSN/EAZ", "VCON", "RUNG", "PROCEEDING"}; - ulong flags; - char s[ISDN_MSNLEN+10]; - -@@ -2781,7 +2809,8 @@ isdn_tty_modem_result(int code, modem_in - restore_flags(flags); - return; - } -- tty_ldisc_flush(info->tty); -+ if (info->tty->ldisc.flush_buffer) -+ info->tty->ldisc.flush_buffer(info->tty); - if ((info->flags & ISDN_ASYNC_CHECK_CD) && - (!((info->flags & ISDN_ASYNC_CALLOUT_ACTIVE) && - (info->flags & ISDN_ASYNC_CALLOUT_NOHUP)))) { -@@ -3296,9 +3325,11 @@ isdn_tty_cmd_PLUSF(char **p, modem_info - #ifdef CONFIG_ISDN_TTY_FAX - if (TTY_IS_FCLASS2(info)) - sprintf(rs, "\r\n2"); -+#ifdef ISDN_TTY_FCLASS1 - else if (TTY_IS_FCLASS1(info)) - sprintf(rs, "\r\n1"); - #endif -+#endif - isdn_tty_at_cout(rs, info); - break; - case '=': -@@ -3313,6 +3344,7 @@ isdn_tty_cmd_PLUSF(char **p, modem_info - m->mdmreg[REG_PSIZE] * 16; - break; - #ifdef CONFIG_ISDN_TTY_FAX -+#ifdef ISDN_TTY_FCLASS1 - case '1': - p[0]++; - if (!(dev->global_features & -@@ -3324,6 +3356,7 @@ isdn_tty_cmd_PLUSF(char **p, modem_info - info->xmit_size = - m->mdmreg[REG_PSIZE] * 16; - break; -+#endif - case '2': - p[0]++; - if (!(dev->global_features & -@@ -3348,9 +3381,11 @@ isdn_tty_cmd_PLUSF(char **p, modem_info - p[0]++; - strcpy(rs, "\r\n0,"); - #ifdef CONFIG_ISDN_TTY_FAX -+#ifdef ISDN_TTY_FCLASS1 - if (dev->global_features & - ISDN_FEATURE_L3_FCLASS1) - strcat(rs, "1,"); -+#endif - if (dev->global_features & - ISDN_FEATURE_L3_FCLASS2) - strcat(rs, "2,"); ---- a/drivers/isdn/isdn_tty.h -+++ b/drivers/isdn/isdn_tty.h -@@ -1,4 +1,4 @@ --/* $Id: isdn_tty.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: isdn_tty.h,v 1.25 2002/02/09 21:19:11 keil Exp $ - * - * header for Linux ISDN subsystem, tty related functions (linklevel). - * -@@ -78,6 +78,10 @@ - #define BIT_CPNFCON 2 - #define REG_CDN 23 - #define BIT_CDN 4 -+#define REG_ALERT 23 -+#define BIT_ALERT 8 -+#define REG_PROCEED 23 -+#define BIT_PROCEED 16 - - /* defines for result codes */ - #define RESULT_OK 0 -@@ -93,10 +97,13 @@ - #define RESULT_NO_MSN_EAZ 10 - #define RESULT_VCON 11 - #define RESULT_RUNG 12 -+#define RESULT_PROCEEDING 13 - -+#ifdef ISDN_TTY_FCLASS1 - #define TTY_IS_FCLASS1(info) \ - ((info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_FAX) && \ - (info->emu.mdmreg[REG_L3PROT] == ISDN_PROTO_L3_FCLASS1)) -+#endif - #define TTY_IS_FCLASS2(info) \ - ((info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_FAX) && \ - (info->emu.mdmreg[REG_L3PROT] == ISDN_PROTO_L3_FCLASS2)) ---- a/drivers/isdn/isdn_ttyfax.c -+++ b/drivers/isdn/isdn_ttyfax.c -@@ -1,4 +1,4 @@ --/* $Id: isdn_ttyfax.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: isdn_ttyfax.c,v 1.9 2001/09/24 13:22:43 kai Exp $ - * - * Linux ISDN subsystem, tty_fax AT-command emulator (linklevel). - * -@@ -20,7 +20,7 @@ - #include "isdn_ttyfax.h" - - --static char *isdn_tty_fax_revision = "$Revision: 1.1.4.1 $"; -+static char *isdn_tty_fax_revision = "$Revision: 1.9 $"; - - #define PARSE_ERROR1 { isdn_tty_fax_modem_result(1, info); return 1; } - -@@ -148,6 +148,7 @@ isdn_tty_fax_modem_result(int code, mode - } - } - -+#ifdef ISDN_TTY_FCLASS1 - int - isdn_tty_fax_command1(modem_info * info, isdn_ctrl * c) - { -@@ -186,6 +187,7 @@ isdn_tty_fax_command1(modem_info * info, - } - return (0); - } -+#endif - - int - isdn_tty_fax_command(modem_info * info, isdn_ctrl * c) -@@ -193,8 +195,10 @@ isdn_tty_fax_command(modem_info * info, - T30_s *f = info->fax; - char rs[10]; - -+#ifdef ISDN_TTY_FCLASS1 - if (TTY_IS_FCLASS1(info)) - return (isdn_tty_fax_command1(info, c)); -+#endif - - #ifdef ISDN_TTY_FAX_CMD_DEBUG - printk(KERN_DEBUG "isdn_tty: Fax cmd %d on ttyI%d\n", -@@ -312,6 +316,7 @@ isdn_tty_fax_bitorder(modem_info * info, - } - } - -+#ifdef ISDN_TTY_FCLASS1 - /* - * Parse AT+F.. FAX class 1 commands - */ -@@ -403,6 +408,7 @@ isdn_tty_cmd_FCLASS1(char **p, modem_inf - } - return 1; - } -+#endif - - /* - * Parse AT+F.. FAX class 2 commands -@@ -970,6 +976,70 @@ isdn_tty_cmd_FCLASS2(char **p, modem_inf - } - return 0; - } -+#if 0 -+ /* LO=n - Flow control opts */ -+ if (!strncmp(p[0], "LO", 2)) { /* TODO */ -+ p[0] += 2; -+ switch (*p[0]) { -+ case '?': -+ p[0]++; -+ sprintf(rs, "\r\n%d", f->lo); -+ isdn_tty_at_cout(rs, info); -+ break; -+ case '=': -+ p[0]++; -+ if (*p[0] == '?') { -+ p[0]++; -+ sprintf(rs, "\r\n0,1,2"); -+ isdn_tty_at_cout(rs, info); -+ } else { -+ par = isdn_getnum(p); -+ if ((par < 0) || (par > 2)) -+ PARSE_ERROR1; -+ f->lo = par; -+#ifdef ISDN_TTY_FAX_STAT_DEBUG -+ printk(KERN_DEBUG "isdn_tty: Fax FLO=%d\n", par); -+#endif -+ } -+ break; -+ default: -+ PARSE_ERROR1; -+ } -+ return 0; -+ } -+#endif -+#if 0 -+ /* LPL=n - Doc for polling cmd */ -+ if (!strncmp(p[0], "LPL", 3)) { /* TODO */ -+ p[0] += 3; -+ switch (*p[0]) { -+ case '?': -+ p[0]++; -+ sprintf(rs, "\r\n%d", f->lpl); -+ isdn_tty_at_cout(rs, info); -+ break; -+ case '=': -+ p[0]++; -+ if (*p[0] == '?') { -+ p[0]++; -+ sprintf(rs, "\r\n0,1"); -+ isdn_tty_at_cout(rs, info); -+ } else { -+ par = isdn_getnum(p); -+ if ((par < 0) || (par > 1)) -+ PARSE_ERROR1; -+ f->lpl = par; -+#ifdef ISDN_TTY_FAX_STAT_DEBUG -+ printk(KERN_DEBUG "isdn_tty: Fax FLPL=%d\n", par); -+#endif -+ } -+ break; -+ default: -+ PARSE_ERROR1; -+ } -+ return 0; -+ } -+#endif - - /* MDL? - DCE Model */ - if (!strncmp(p[0], "MDL?", 4)) { -@@ -1049,6 +1119,38 @@ isdn_tty_cmd_FCLASS2(char **p, modem_inf - } - return 0; - } -+#if 0 -+ /* PTS=n - Page transfer status */ -+ if (!strncmp(p[0], "PTS", 3)) { /* TODO */ -+ p[0] += 3; -+ switch (*p[0]) { -+ case '?': -+ p[0]++; -+ sprintf(rs, "\r\n%d", f->pts); -+ isdn_tty_at_cout(rs, info); -+ break; -+ case '=': -+ p[0]++; -+ if (*p[0] == '?') { -+ p[0]++; -+ sprintf(rs, "\r\n0-5"); -+ isdn_tty_at_cout(rs, info); -+ } else { -+ par = isdn_getnum(p); -+ if ((par < 0) || (par > 5)) -+ PARSE_ERROR1; -+ f->pts = par; -+#ifdef ISDN_TTY_FAX_STAT_DEBUG -+ printk(KERN_DEBUG "isdn_tty: Fax FPTS=%d\n", par); -+#endif -+ } -+ break; -+ default: -+ PARSE_ERROR1; -+ } -+ return 0; -+ } -+#endif - - /* REL=n - Phase C received EOL alignment */ - if (!strncmp(p[0], "REL", 3)) { -@@ -1091,6 +1193,38 @@ isdn_tty_cmd_FCLASS2(char **p, modem_inf - isdn_tty_at_cout(rs, info); - return 0; - } -+#if 0 -+ /* SPL=n - Enable polling */ -+ if (!strncmp(p[0], "SPL", 3)) { /* TODO */ -+ p[0] += 3; -+ switch (*p[0]) { -+ case '?': -+ p[0]++; -+ sprintf(rs, "\r\n%d", f->spl); -+ isdn_tty_at_cout(rs, info); -+ break; -+ case '=': -+ p[0]++; -+ if (*p[0] == '?') { -+ p[0]++; -+ sprintf(rs, "\r\n0,1"); -+ isdn_tty_at_cout(rs, info); -+ } else { -+ par = isdn_getnum(p); -+ if ((par < 0) || (par > 1)) -+ PARSE_ERROR1; -+ f->spl = par; -+#ifdef ISDN_TTY_FAX_STAT_DEBUG -+ printk(KERN_DEBUG "isdn_tty: Fax FSPL=%d\n", par); -+#endif -+ } -+ break; -+ default: -+ PARSE_ERROR1; -+ } -+ return 0; -+ } -+#endif - - /* Phase C Transmit Data Block Size */ - if (!strncmp(p[0], "TBC=", 4)) { /* dummy, not used */ -@@ -1116,7 +1250,9 @@ isdn_tty_cmd_PLUSF_FAX(char **p, modem_i - { - if (TTY_IS_FCLASS2(info)) - return (isdn_tty_cmd_FCLASS2(p, info)); -+#ifdef ISDN_TTY_FCLASS1 - else if (TTY_IS_FCLASS1(info)) - return (isdn_tty_cmd_FCLASS1(p, info)); -+#endif - PARSE_ERROR1; - } ---- a/drivers/isdn/isdn_ttyfax.h -+++ b/drivers/isdn/isdn_ttyfax.h -@@ -1,4 +1,4 @@ --/* $Id: isdn_ttyfax.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: isdn_ttyfax.h,v 1.3 2001/09/24 13:22:43 kai Exp $ - * - * header for Linux ISDN subsystem, tty_fax related functions (linklevel). - * ---- a/drivers/isdn/isdn_v110.c -+++ b/drivers/isdn/isdn_v110.c -@@ -1,4 +1,4 @@ --/* $Id: isdn_v110.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: isdn_v110.c,v 1.8 2001/09/24 13:22:43 kai Exp $ - * - * Linux ISDN subsystem, V.110 related functions (linklevel). - * -@@ -19,7 +19,7 @@ - - #undef ISDN_V110_DEBUG - --char *isdn_v110_revision = "$Revision: 1.1.4.1 $"; -+char *isdn_v110_revision = "$Revision: 1.8 $"; - - #define V110_38400 255 - #define V110_19200 15 -@@ -138,6 +138,14 @@ isdn_v110_close(isdn_v110_stream * v) - return; - #ifdef ISDN_V110_DEBUG - printk(KERN_DEBUG "v110 close\n"); -+#if 0 -+ printk(KERN_DEBUG "isdn_v110_close: nbytes=%d\n", v->nbytes); -+ printk(KERN_DEBUG "isdn_v110_close: nbits=%d\n", v->nbits); -+ printk(KERN_DEBUG "isdn_v110_close: key=%d\n", v->key); -+ printk(KERN_DEBUG "isdn_v110_close: SyncInit=%d\n", v->SyncInit); -+ printk(KERN_DEBUG "isdn_v110:close: decodelen=%d\n", v->decodelen); -+ printk(KERN_DEBUG "isdn_v110_close: framelen=%d\n", v->framelen); -+#endif - #endif - kfree(v->encodebuf); - kfree(v); ---- a/drivers/isdn/isdn_v110.h -+++ b/drivers/isdn/isdn_v110.h -@@ -1,4 +1,4 @@ --/* $Id: isdn_v110.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: isdn_v110.h,v 1.5 2001/09/24 13:22:43 kai Exp $ - * - * Linux ISDN subsystem, V.110 related functions (linklevel). - * ---- a/drivers/isdn/isdn_x25iface.c -+++ b/drivers/isdn/isdn_x25iface.c -@@ -1,4 +1,4 @@ --/* $Id: isdn_x25iface.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: isdn_x25iface.c,v 1.10 2001/09/24 13:22:43 kai Exp $ - * - * Linux ISDN subsystem, X.25 related functions - * ---- a/drivers/isdn/isdn_x25iface.h -+++ b/drivers/isdn/isdn_x25iface.h -@@ -1,4 +1,4 @@ --/* $Id: isdn_x25iface.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ -+/* $Id: isdn_x25iface.h,v 1.4 2001/09/24 13:22:43 kai Exp $ - * - * header for Linux ISDN subsystem, x.25 related functions - * ---- a/drivers/isdn/isdnloop/isdnloop.c -+++ b/drivers/isdn/isdnloop/isdnloop.c -@@ -1,4 +1,4 @@ --/* $Id: isdnloop.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id: isdnloop.c,v 1.17 2001/08/30 10:45:42 kai Exp $ - * - * ISDN low-level module implementing a dummy loop driver. - * -@@ -14,7 +14,7 @@ - #include <linux/init.h> - #include "isdnloop.h" - --static char *revision = "$Revision: 1.1.4.1 $"; -+static char *revision = "$Revision$"; - static char *isdnloop_id; - - MODULE_DESCRIPTION("ISDN4Linux: Pseudo Driver that simulates an ISDN card"); -@@ -22,8 +22,8 @@ MODULE_AUTHOR("Fritz Elfert"); - MODULE_LICENSE("GPL"); - MODULE_PARM(isdnloop_id, "s"); - MODULE_PARM_DESC(isdnloop_id, "ID-String of first card"); -- --static int isdnloop_addcard(char *); -+ -+ static int isdnloop_addcard(char *); - - /* - * Free queue completely. -@@ -1542,11 +1542,7 @@ isdnloop_init(void) - } else - strcpy(rev, " ??? "); - printk(KERN_NOTICE "isdnloop-ISDN-driver Rev%s\n", rev); -- -- if (isdnloop_id) -- return (isdnloop_addcard(isdnloop_id)); -- -- return 0; -+ return (isdnloop_addcard(isdnloop_id)); - } - - static void __exit ---- a/drivers/isdn/isdnloop/isdnloop.h -+++ b/drivers/isdn/isdnloop/isdnloop.h -@@ -1,4 +1,4 @@ --/* $Id: isdnloop.h,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id$ - * - * Loopback lowlevel module for testing of linklevel. - * ---- a/drivers/isdn/pcbit/callbacks.c -+++ b/drivers/isdn/pcbit/callbacks.c -@@ -3,7 +3,7 @@ - * - * Copyright (C) 1996 Universidade de Lisboa - * -- * Written by Pedro Roque Marques (pedro_m@yahoo.com) -+ * Written by Pedro Roque Marques (roque@di.fc.ul.pt) - * - * This software may be used and distributed according to the terms of - * the GNU General Public License, incorporated herein by reference. ---- a/drivers/isdn/pcbit/callbacks.h -+++ b/drivers/isdn/pcbit/callbacks.h -@@ -3,7 +3,7 @@ - * - * Copyright (C) 1996 Universidade de Lisboa - * -- * Written by Pedro Roque Marques (pedro_m@yahoo.com) -+ * Written by Pedro Roque Marques (roque@di.fc.ul.pt) - * - * This software may be used and distributed according to the terms of - * the GNU General Public License, incorporated herein by reference. ---- a/drivers/isdn/pcbit/capi.c -+++ b/drivers/isdn/pcbit/capi.c -@@ -4,7 +4,7 @@ - * - * Copyright (C) 1996 Universidade de Lisboa - * -- * Written by Pedro Roque Marques (pedro_m@yahoo.com) -+ * Written by Pedro Roque Marques (roque@di.fc.ul.pt) - * - * This software may be used and distributed according to the terms of - * the GNU General Public License, incorporated herein by reference. ---- a/drivers/isdn/pcbit/capi.h -+++ b/drivers/isdn/pcbit/capi.h -@@ -3,7 +3,7 @@ - * - * Copyright (C) 1996 Universidade de Lisboa - * -- * Written by Pedro Roque Marques (pedro_m@yahoo.com) -+ * Written by Pedro Roque Marques (roque@di.fc.ul.pt) - * - * This software may be used and distributed according to the terms of - * the GNU General Public License, incorporated herein by reference. -@@ -63,7 +63,8 @@ extern int capi_disc_resp(struct pcbit_c - extern int capi_decode_debug_188(u_char *hdr, ushort hdrlen); - #endif - --static inline struct pcbit_chan * -+extern __inline__ -+struct pcbit_chan * - capi_channel(struct pcbit_dev *dev, struct sk_buff *skb) - { - ushort callref; ---- a/drivers/isdn/pcbit/drv.c -+++ b/drivers/isdn/pcbit/drv.c -@@ -3,7 +3,7 @@ - * - * Copyright (C) 1996 Universidade de Lisboa - * -- * Written by Pedro Roque Marques (pedro_m@yahoo.com) -+ * Written by Pedro Roque Marques (roque@di.fc.ul.pt) - * - * This software may be used and distributed according to the terms of - * the GNU General Public License, incorporated herein by reference. -@@ -35,7 +35,9 @@ - #include <linux/isdnif.h> - #include <asm/string.h> - #include <asm/io.h> -+#ifdef COMPAT_HAS_ISA_IOREMAP - #include <linux/ioport.h> -+#endif - - #include "pcbit.h" - #include "edss1.h" -@@ -89,6 +91,7 @@ int pcbit_init_dev(int board, int mem_ba - - if (mem_base >= 0xA0000 && mem_base <= 0xFFFFF ) { - dev->ph_mem = mem_base; -+#ifdef COMPAT_HAS_ISA_IOREMAP - if (check_mem_region(dev->ph_mem, 4096)) { - printk(KERN_WARNING - "PCBIT: memory region %lx-%lx already in use\n", -@@ -100,6 +103,9 @@ int pcbit_init_dev(int board, int mem_ba - request_mem_region(dev->ph_mem, 4096, "PCBIT mem"); - } - dev->sh_mem = (unsigned char*)ioremap(dev->ph_mem, 4096); -+#else -+ dev->sh_mem = (unsigned char*) mem_base; -+#endif - } - else - { -@@ -112,8 +118,10 @@ int pcbit_init_dev(int board, int mem_ba - dev->b1 = kmalloc(sizeof(struct pcbit_chan), GFP_KERNEL); - if (!dev->b1) { - printk("pcbit_init: couldn't malloc pcbit_chan struct\n"); -+#ifdef COMPAT_HAS_ISA_IOREMAP - iounmap((unsigned char*)dev->sh_mem); - release_mem_region(dev->ph_mem, 4096); -+#endif - kfree(dev); - return -ENOMEM; - } -@@ -122,8 +130,10 @@ int pcbit_init_dev(int board, int mem_ba - if (!dev->b2) { - printk("pcbit_init: couldn't malloc pcbit_chan struct\n"); - kfree(dev->b1); -+#ifdef COMPAT_HAS_ISA_IOREMAP - iounmap((unsigned char*)dev->sh_mem); - release_mem_region(dev->ph_mem, 4096); -+#endif - kfree(dev); - return -ENOMEM; - } -@@ -144,8 +154,10 @@ int pcbit_init_dev(int board, int mem_ba - { - kfree(dev->b1); - kfree(dev->b2); -+#ifdef COMPAT_HAS_ISA_IOREMAP - iounmap((unsigned char*)dev->sh_mem); - release_mem_region(dev->ph_mem, 4096); -+#endif - kfree(dev); - dev_pcbit[board] = NULL; - return -EIO; -@@ -166,8 +178,10 @@ int pcbit_init_dev(int board, int mem_ba - free_irq(irq, dev); - kfree(dev->b1); - kfree(dev->b2); -+#ifdef COMPAT_HAS_ISA_IOREMAP - iounmap((unsigned char*)dev->sh_mem); - release_mem_region(dev->ph_mem, 4096); -+#endif - kfree(dev); - dev_pcbit[board] = NULL; - return -EIO; -@@ -197,8 +211,10 @@ int pcbit_init_dev(int board, int mem_ba - free_irq(irq, dev); - kfree(dev->b1); - kfree(dev->b2); -+#ifdef COMPAT_HAS_ISA_IOREMAP - iounmap((unsigned char*)dev->sh_mem); - release_mem_region(dev->ph_mem, 4096); -+#endif - kfree(dev); - dev_pcbit[board] = NULL; - return -EIO; -@@ -235,8 +251,10 @@ void pcbit_terminate(int board) - del_timer(&dev->b2->fsm_timer); - kfree(dev->b1); - kfree(dev->b2); -+#ifdef COMPAT_HAS_ISA_IOREMAP - iounmap((unsigned char*)dev->sh_mem); - release_mem_region(dev->ph_mem, 4096); -+#endif - kfree(dev); - } - } -@@ -430,7 +448,7 @@ int pcbit_writecmd(const u_char* buf, in - switch(dev->l2_state) { - case L2_LWMODE: - /* check (size <= rdp_size); write buf into board */ -- if (len < 0 || len > BANK4 + 1) -+ if (len > BANK4 + 1) - { - printk("pcbit_writecmd: invalid length %d\n", len); - return -EINVAL; -@@ -609,6 +627,20 @@ void pcbit_l3_receive(struct pcbit_dev * - dev->b1->s_refnum, - dev->b2->s_refnum); - #endif -+#if 0 -+ if (dev->b1->s_refnum == refnum) -+ chan = dev->b1; -+ else { -+ -+ if (dev->b2->s_refnum == refnum) -+ chan = dev->b2; -+ else { -+ chan = NULL; -+ printk(KERN_WARNING "Connection Confirm - refnum doesn't match chan\n"); -+ break; -+ } -+ } -+#else - /* We just try to find a channel in the right state */ - - if (dev->b1->fsm_state == ST_CALL_INIT) -@@ -622,6 +654,7 @@ void pcbit_l3_receive(struct pcbit_dev * - break; - } - } -+#endif - if (capi_decode_conn_conf(chan, skb, &complete)) { - printk(KERN_DEBUG "conn_conf indicates error\n"); - pcbit_fsm_event(dev, chan, EV_ERROR, NULL); ---- a/drivers/isdn/pcbit/edss1.c -+++ b/drivers/isdn/pcbit/edss1.c -@@ -4,7 +4,7 @@ - * - * Copyright (C) 1996 Universidade de Lisboa - * -- * Written by Pedro Roque Marques (pedro_m@yahoo.com) -+ * Written by Pedro Roque Marques (roque@di.fc.ul.pt) - * - * This software may be used and distributed according to the terms of - * the GNU General Public License, incorporated herein by reference. ---- a/drivers/isdn/pcbit/edss1.h -+++ b/drivers/isdn/pcbit/edss1.h -@@ -3,7 +3,7 @@ - * - * Copyright (C) 1996 Universidade de Lisboa - * -- * Written by Pedro Roque Marques (pedro_m@yahoo.com) -+ * Written by Pedro Roque Marques (roque@di.fc.ul.pt) - * - * This software may be used and distributed according to the terms of - * the GNU General Public License, incorporated herein by reference. ---- a/drivers/isdn/pcbit/layer2.c -+++ b/drivers/isdn/pcbit/layer2.c -@@ -3,7 +3,7 @@ - * - * Copyright (C) 1996 Universidade de Lisboa - * -- * Written by Pedro Roque Marques (pedro_m@yahoo.com) -+ * Written by Pedro Roque Marques (roque@di.fc.ul.pt) - * - * This software may be used and distributed according to the terms of - * the GNU General Public License, incorporated herein by reference. -@@ -369,11 +369,16 @@ pcbit_receive(struct pcbit_dev *dev) - - if (dev->read_frame) { - printk(KERN_DEBUG "pcbit_receive: Type 0 frame and read_frame != NULL\n"); -+#if 0 -+ pcbit_l2_error(dev); -+ return; -+#else - /* discard previous queued frame */ - if (dev->read_frame->skb) - kfree_skb(dev->read_frame->skb); - kfree(dev->read_frame); - dev->read_frame = NULL; -+#endif - } - frame = kmalloc(sizeof(struct frame_buf), GFP_ATOMIC); - -@@ -449,10 +454,14 @@ pcbit_receive(struct pcbit_dev *dev) - - if (!(frame = dev->read_frame)) { - printk("Type 1 frame and no frame queued\n"); -+#if 1 - /* usually after an error: toss frame */ - dev->readptr += tt; - if (dev->readptr > dev->sh_mem + BANK2 + BANKLEN) - dev->readptr -= BANKLEN; -+#else -+ pcbit_l2_error(dev); -+#endif - return; - - } ---- a/drivers/isdn/pcbit/layer2.h -+++ b/drivers/isdn/pcbit/layer2.h -@@ -3,7 +3,7 @@ - * - * Copyright (C) 1996 Universidade de Lisboa - * -- * Written by Pedro Roque Marques (pedro_m@yahoo.com) -+ * Written by Pedro Roque Marques (roque@di.fc.ul.pt) - * - * This software may be used and distributed according to the terms of - * the GNU General Public License, incorporated herein by reference. ---- a/drivers/isdn/pcbit/module.c -+++ b/drivers/isdn/pcbit/module.c -@@ -3,7 +3,7 @@ - * - * Copyright (C) 1996 Universidade de Lisboa - * -- * Written by Pedro Roque Marques (pedro_m@yahoo.com) -+ * Written by Pedro Roque Marques (roque@di.fc.ul.pt) - * - * This software may be used and distributed according to the terms of - * the GNU General Public License, incorporated herein by reference. -@@ -92,6 +92,7 @@ static void __exit pcbit_exit(void) - } - - #ifndef MODULE -+#ifdef COMPAT_HAS_NEW_SETUP - #define MAX_PARA (MAX_PCBIT_CARDS * 2) - static int __init pcbit_setup(char *line) - { -@@ -100,6 +101,11 @@ static int __init pcbit_setup(char *line - int ints[MAX_PARA+1]; - - str = get_options(line, MAX_PARA, ints); -+#else -+void pcbit_setup(char *str, int *ints) -+{ -+ int i, j, argc; -+#endif - argc = ints[0]; - i = 0; - j = 1; -@@ -118,9 +124,13 @@ static int __init pcbit_setup(char *line - - i++; - } -+#ifdef COMPAT_HAS_NEW_SETUP - return(1); - } - __setup("pcbit=", pcbit_setup); -+#else -+} -+#endif - #endif - - module_init(pcbit_init); ---- a/drivers/isdn/pcbit/pcbit.h -+++ b/drivers/isdn/pcbit/pcbit.h -@@ -3,7 +3,7 @@ - * - * Copyright (C) 1996 Universidade de Lisboa - * -- * Written by Pedro Roque Marques (pedro_m@yahoo.com) -+ * Written by Pedro Roque Marques (roque@di.fc.ul.pt) - * - * This software may be used and distributed according to the terms of - * the GNU General Public License, incorporated herein by reference. ---- a/drivers/isdn/sc/card.h -+++ b/drivers/isdn/sc/card.h -@@ -1,4 +1,4 @@ --/* $Id: card.h,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id$ - * - * Driver parameters for SpellCaster ISA ISDN adapters - * ---- a/drivers/isdn/sc/command.c -+++ b/drivers/isdn/sc/command.c -@@ -1,4 +1,4 @@ --/* $Id: command.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id$ - * - * Copyright (C) 1996 SpellCaster Telecommunications Inc. - * -@@ -95,7 +95,7 @@ int get_card_from_id(int driver) - if(adapter[i]->driverId == driver) - return i; - } -- return -ENODEV; -+ return -NODEV; - } - - /* ---- a/drivers/isdn/sc/debug.c -+++ b/drivers/isdn/sc/debug.c -@@ -1,4 +1,4 @@ --/* $Id: debug.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id$ - * - * Copyright (C) 1996 SpellCaster Telecommunications Inc. - * ---- a/drivers/isdn/sc/debug.h -+++ b/drivers/isdn/sc/debug.h -@@ -1,4 +1,4 @@ --/* $Id: debug.h,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id$ - * - * Copyright (C) 1996 SpellCaster Telecommunications Inc. - * ---- a/drivers/isdn/sc/event.c -+++ b/drivers/isdn/sc/event.c -@@ -1,4 +1,4 @@ --/* $Id: event.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id$ - * - * Copyright (C) 1996 SpellCaster Telecommunications Inc. - * ---- a/drivers/isdn/sc/init.c -+++ b/drivers/isdn/sc/init.c -@@ -514,6 +514,15 @@ int identify_board(unsigned long rambase - schedule_timeout(HZ); - sig = readl(rambase + SIG_OFFSET); - pr_debug("Looking for a signature, got 0x%x\n", sig); -+#if 0 -+/* -+ * For Gary: -+ * If it's a timing problem, it should be gone with the above schedule() -+ * Another possible reason may be the missing volatile in the original -+ * code. readl() does this for us. -+ */ -+ printk(""); /* Hack! Doesn't work without this !!!??? */ -+#endif - if(sig == SIGNATURE) - return PRI_BOARD; - -@@ -525,6 +534,9 @@ int identify_board(unsigned long rambase - schedule_timeout(HZ); - sig = readl(rambase + SIG_OFFSET); - pr_debug("Looking for a signature, got 0x%x\n", sig); -+#if 0 -+ printk(""); /* Hack! Doesn't work without this !!!??? */ -+#endif - if(sig == SIGNATURE) - return BRI_BOARD; - ---- a/drivers/isdn/sc/interrupt.c -+++ b/drivers/isdn/sc/interrupt.c -@@ -1,4 +1,4 @@ --/* $Id: interrupt.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id$ - * - * Copyright (C) 1996 SpellCaster Telecommunications Inc. - * ---- a/drivers/isdn/sc/ioctl.c -+++ b/drivers/isdn/sc/ioctl.c -@@ -23,6 +23,9 @@ extern int send_and_receive(int, unsigne - - extern board *adapter[]; - -+#if 0 -+static char *ChannelStates[] = { "Idle", "Ready", "Connecting", "Connected", "Disconnecting" }; -+#endif - - int GetStatus(int card, boardInfo *); - ---- a/drivers/isdn/sc/message.c -+++ b/drivers/isdn/sc/message.c -@@ -1,4 +1,4 @@ --/* $Id: message.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id$ - * - * functions for sending and receiving control messages - * ---- a/drivers/isdn/sc/message.h -+++ b/drivers/isdn/sc/message.h -@@ -1,4 +1,4 @@ --/* $Id: message.h,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id$ - * - * Copyright (C) 1996 SpellCaster Telecommunications Inc. - * ---- a/drivers/isdn/sc/packet.c -+++ b/drivers/isdn/sc/packet.c -@@ -1,4 +1,4 @@ --/* $Id: packet.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id$ - * - * Copyright (C) 1996 SpellCaster Telecommunications Inc. - * ---- a/drivers/isdn/sc/shmem.c -+++ b/drivers/isdn/sc/shmem.c -@@ -1,4 +1,4 @@ --/* $Id: shmem.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id$ - * - * Copyright (C) 1996 SpellCaster Telecommunications Inc. - * ---- a/drivers/isdn/sc/timer.c -+++ b/drivers/isdn/sc/timer.c -@@ -1,4 +1,4 @@ --/* $Id: timer.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id$ - * - * Copyright (C) 1996 SpellCaster Telecommunications Inc. - * ---- a/drivers/isdn/tpam/tpam.h -+++ b/drivers/isdn/tpam/tpam.h -@@ -1,4 +1,4 @@ --/* $Id: tpam.h,v 1.1.2.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id: tpam.h,v 1.3 2001/09/24 13:23:12 kai Exp $ - * - * Turbo PAM ISDN driver for Linux. (Kernel Driver) - * ---- a/drivers/isdn/tpam/tpam_commands.c -+++ b/drivers/isdn/tpam/tpam_commands.c -@@ -1,4 +1,4 @@ --/* $Id: tpam_commands.c,v 1.1.2.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id: tpam_commands.c,v 1.3 2001/09/24 13:23:12 kai Exp $ - * - * Turbo PAM ISDN driver for Linux. (Kernel Driver - ISDN commands) - * ---- a/drivers/isdn/tpam/tpam_crcpc.c -+++ b/drivers/isdn/tpam/tpam_crcpc.c -@@ -1,4 +1,4 @@ --/* $Id: tpam_crcpc.c,v 1.1.2.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id$ - * - * Turbo PAM ISDN driver for Linux. (Kernel Driver - CRC encoding) - * ---- a/drivers/isdn/tpam/tpam_hdlc.c -+++ b/drivers/isdn/tpam/tpam_hdlc.c -@@ -1,4 +1,4 @@ --/* $Id: tpam_hdlc.c,v 1.1.2.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id: tpam_hdlc.c,v 1.3 2001/09/24 13:23:12 kai Exp $ - * - * Turbo PAM ISDN driver for Linux. (Kernel Driver - HDLC encoding) - * ---- a/drivers/isdn/tpam/tpam_main.c -+++ b/drivers/isdn/tpam/tpam_main.c -@@ -1,4 +1,4 @@ --/* $Id: tpam_main.c,v 1.1.2.2 2001/12/09 18:45:14 kai Exp $ -+/* $Id$ - * - * Turbo PAM ISDN driver for Linux. (Kernel Driver - main routines) - * -@@ -254,7 +254,7 @@ static struct pci_driver tpam_driver = { - name: "tpam", - id_table: tpam_pci_tbl, - probe: tpam_probe, -- remove: __devexit_p(tpam_remove), -+ remove: tpam_remove, - }; - - static int __init tpam_init(void) { ---- a/drivers/isdn/tpam/tpam_memory.c -+++ b/drivers/isdn/tpam/tpam_memory.c -@@ -1,4 +1,4 @@ --/* $Id: tpam_memory.c,v 1.1.2.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id$ - * - * Turbo PAM ISDN driver for Linux. (Kernel Driver - Board Memory Access) - * ---- a/drivers/isdn/tpam/tpam_nco.c -+++ b/drivers/isdn/tpam/tpam_nco.c -@@ -1,4 +1,4 @@ --/* $Id: tpam_nco.c,v 1.1.2.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id$ - * - * Turbo PAM ISDN driver for Linux. - * (Kernel Driver - Low Level NCO Manipulation) ---- a/drivers/isdn/tpam/tpam_queues.c -+++ b/drivers/isdn/tpam/tpam_queues.c -@@ -1,4 +1,4 @@ --/* $Id: tpam_queues.c,v 1.1.2.1 2001/11/20 14:19:37 kai Exp $ -+/* $Id$ - * - * Turbo PAM ISDN driver for Linux. (Kernel Driver) - * -@@ -146,7 +146,6 @@ void tpam_irq(int irq, void *dev_id, str - do { - hpic = readl(card->bar0 + TPAM_HPIC_REGISTER); - if (waiting_too_long++ > 0xfffffff) { -- kfree_skb(skb); - spin_unlock(&card->lock); - printk(KERN_ERR "TurboPAM(tpam_irq): " - "waiting too long...\n"); ---- a/include/linux/b1lli.h -+++ b/include/linux/b1lli.h -@@ -1,4 +1,4 @@ --/* $Id: b1lli.h,v 1.8.8.3 2001/09/23 22:25:05 kai Exp $ -+/* $Id$ - * - * ISDN lowlevel-module for AVM B1-card. - * ---- a/include/linux/b1pcmcia.h -+++ b/include/linux/b1pcmcia.h -@@ -1,4 +1,4 @@ --/* $Id: b1pcmcia.h,v 1.1.8.2 2001/09/23 22:25:05 kai Exp $ -+/* $Id$ - * - * Exported functions of module b1pcmcia to be called by - * avm_cs card services module. ---- a/include/linux/capi.h -+++ b/include/linux/capi.h -@@ -1,4 +1,4 @@ --/* $Id: capi.h,v 1.1.4.1 2001/11/20 14:19:38 kai Exp $ -+/* $Id$ - * - * CAPI 2.0 Interface for Linux - * ---- a/include/linux/concap.h -+++ b/include/linux/concap.h -@@ -1,4 +1,4 @@ --/* $Id: concap.h,v 1.2.8.1 2001/09/23 22:25:05 kai Exp $ -+/* $Id: concap.h,v 1.3 2001/09/24 13:23:13 kai Exp $ - * - * Copyright 1997 by Henner Eisen <eis@baty.hanse.de> - * -@@ -11,6 +11,7 @@ - #ifdef __KERNEL__ - #include <linux/skbuff.h> - #include <linux/netdevice.h> -+#include <linux/isdn_compat.h> - - /* Stuff to support encapsulation protocols genericly. The encapsulation - protocol is processed at the uppermost layer of the network interface. ---- a/include/linux/hysdn_if.h -+++ b/include/linux/hysdn_if.h -@@ -1,4 +1,4 @@ --/* $Id: hysdn_if.h,v 1.1.8.3 2001/09/23 22:25:05 kai Exp $ -+/* $Id$ - * - * Linux driver for HYSDN cards - * ioctl definitions shared by hynetmgr and driver. ---- a/include/linux/isdn/tpam.h -+++ b/include/linux/isdn/tpam.h -@@ -1,4 +1,4 @@ --/* $Id: tpam.h,v 1.1.2.1 2001/11/20 14:19:38 kai Exp $ -+/* $Id$ - * - * Turbo PAM ISDN driver for Linux. (Kernel Driver) - * ---- a/include/linux/isdn.h -+++ b/include/linux/isdn.h -@@ -1,4 +1,4 @@ --/* $Id: isdn.h,v 1.1.4.1 2001/11/20 14:19:38 kai Exp $ -+/* $Id: isdn.h,v 1.125 2001/12/01 23:18:21 detabc Exp $ - * - * Main header for the Linux ISDN subsystem (linklevel). - * -@@ -14,6 +14,7 @@ - #ifndef __ISDN_H__ - #define __ISDN_H__ - -+#include <linux/isdn_compat.h> - #include <linux/ioctl.h> - - #ifdef CONFIG_COBALT_MICRO_SERVER -@@ -93,9 +94,15 @@ - #define ISDN_LMSNLEN 255 /* Length of tty's Listen-MSN string */ - #define ISDN_CMSGLEN 50 /* Length of CONNECT-Message to add for Modem */ - -+#ifdef BIG_PHONE_NUMBERS - #define ISDN_MSNLEN 32 - #define NET_DV 0x06 /* Data version for isdn_net_ioctl_cfg */ - #define TTY_DV 0x06 /* Data version for iprofd etc. */ -+#else -+#define ISDN_MSNLEN 20 -+#define NET_DV 0x05 /* Data version for isdn_net_ioctl_cfg */ -+#define TTY_DV 0x05 /* Data version for iprofd etc. */ -+#endif - - #define INF_DV 0x01 /* Data version for /dev/isdninfo */ - -@@ -187,6 +194,61 @@ typedef struct { - #define ISDN_MINOR_PPPMAX (128 + (ISDN_MAX_CHANNELS-1)) - #define ISDN_MINOR_STATUS 255 - -+#ifndef CONFIG_ISDN_WITH_ABC -+#undef CONFIG_ISDN_WITH_ABC_CALLB -+#undef CONFIG_ISDN_WITH_ABC_UDP_CHECK -+#undef CONFIG_ISDN_WITH_ABC_UDP_CHECK_HANGUP -+#undef CONFIG_ISDN_WITH_ABC_UDP_CHECK_DIAL -+#undef CONFIG_ISDN_WITH_ABC_OUTGOING_EAZ -+#undef CONFIG_ISDN_WITH_ABC_LCR_SUPPORT -+#undef CONFIG_ISDN_WITH_ABC_RCV_NO_HUPTIMER -+#undef CONFIG_ISDN_WITH_ABC_CH_EXTINUSE -+#undef CONFIG_ISDN_WITH_ABC_CONN_ERROR -+#undef CONFIG_ISDN_WITH_ABC_RAWIPCOMPRESS -+#else /* CONFIG_ISDN_WITH_ABC */ -+#include <linux/isdn_dwabc.h> -+ -+ -+typedef struct DWABCJIFFIES { -+ -+ u_long msec_1000; -+ u_long msec_500; -+ u_long msec_400; -+ u_long msec_200; -+ u_long msec_100; -+ -+} DWABCJIFFIES; -+ -+ -+#ifdef CONFIG_ISDN_WITH_ABC_NEED_DWSJIFFIES -+DWABCJIFFIES isdn_dwabc_jiffies; -+#else -+extern DWABCJIFFIES isdn_dwabc_jiffies; -+#endif -+#define dwsjiffies (isdn_dwabc_jiffies.msec_1000) -+ -+#define ISDN_DW_ABC_FLAG_UNUSED00001 0x00000001L -+#define ISDN_DW_ABC_FLAG_NO_UDP_CHECK 0x00000002L -+#define ISDN_DW_ABC_FLAG_NO_UDP_HANGUP 0x00000004L -+#define ISDN_DW_ABC_FLAG_NO_UDP_DIAL 0x00000008L -+#define ISDN_DW_ABC_FLAG_UNUSED00010 0x00000010L -+#define ISDN_DW_ABC_FLAG_RCV_NO_HUPTIMER 0x00000020L -+#define ISDN_DW_ABC_FLAG_NO_CH_EXTINUSE 0x00000040L -+#define ISDN_DW_ABC_FLAG_NO_CONN_ERROR 0x00000080L -+#define ISDN_DW_ABC_FLAG_BSD_COMPRESS 0x00000100L -+#define ISDN_DW_ABC_FLAG_NO_LCR 0x00000200L -+#define ISDN_DW_ABC_FLAG_LEASED_LINE 0x00001000L -+ -+#define ISDN_DW_ABC_IFFLAG_NODCHAN 0x00000001L -+#define ISDN_DW_ABC_IFFLAG_BSDAKTIV 0x00000002L -+ -+#define ISDN_DW_ABC_BITLOCK_SEND 0 -+#define ISDN_DW_ABC_BITLOCK_RECEIVE 1 -+ -+#endif /* CONFIG_ISDN_WITH_ABC */ -+ -+ -+ - #ifdef CONFIG_ISDN_PPP - - #ifdef CONFIG_ISDN_PPP_VJ -@@ -204,9 +266,11 @@ typedef struct { - # include <linux/concap.h> - #endif - -+#ifdef HAVE_DEVFS_FS - #ifdef CONFIG_DEVFS_FS - # include <linux/devfs_fs_kernel.h> - #endif -+#endif /* HAVE_DEVFS_FS */ - - #include <linux/isdnif.h> - -@@ -272,6 +336,12 @@ typedef struct { - #define ISDN_NET_CALLBACK 0x04 /* activate callback */ - #define ISDN_NET_CBHUP 0x08 /* hangup before callback */ - #define ISDN_NET_CBOUT 0x10 /* remote machine does callback */ -+#if 0 -+/* Unused??? */ -+#define ISDN_NET_CLONE 0x08 /* clone a tmp interface when called */ -+#define ISDN_NET_TMP 0x10 /* tmp interface until getting an IP */ -+#define ISDN_NET_DYNAMIC 0x20 /* this link is dynamically allocated */ -+#endif - - #define ISDN_NET_MAGIC 0x49344C02 /* for paranoia-checking */ - -@@ -386,6 +456,38 @@ typedef struct isdn_net_local_s { - char cisco_debserint; /* debugging flag of cisco hdlc with slarp */ - struct timer_list cisco_timer; - struct tq_struct tqueue; -+#ifdef CONFIG_ISDN_WITH_ABC -+ ulong dw_abc_flags; -+ ulong dw_abc_if_flags; -+ int dw_abc_inuse_secure; -+ ulong dw_abc_dialstart; -+ int dw_abc_old_onhtime; -+ int dw_abc_remote_version; -+ int dw_abc_bitlocks; -+#ifdef CONFIG_ISDN_WITH_ABC_OUTGOING_EAZ -+ char dw_out_msn[ISDN_MSNLEN]; /* eaz for outgoing call if *out_msn != 0 */ -+#endif -+#ifdef CONFIG_ISDN_WITH_ABC_LCR_SUPPORT -+ ulong dw_abc_lcr_callid; -+ ulong dw_abc_lcr_start_request; -+ ulong dw_abc_lcr_end_request; -+ isdn_ctrl *dw_abc_lcr_cmd; -+ struct ISDN_DWABC_LCR_IOCTL *dw_abc_lcr_io; -+#endif -+ ulong dw_abc_bchan_last_connect; -+#ifdef CONFIG_ISDN_WITH_ABC_CONN_ERROR -+ short dw_abc_bchan_errcnt; -+#endif -+#ifdef CONFIG_ISDN_WITH_ABC_RAWIPCOMPRESS -+ void *dw_abc_bsd_compressor; -+ void *dw_abc_bsd_stat_rx; -+ void *dw_abc_bsd_stat_tx; -+#endif -+ ulong dw_abc_bsd_snd; -+ ulong dw_abc_bsd_bsd_snd; -+ ulong dw_abc_bsd_rcv; -+ ulong dw_abc_bsd_bsd_rcv; -+#endif - } isdn_net_local; - - /* the interface itself */ -@@ -608,12 +710,13 @@ typedef struct isdn_devt { - int tflags; /* Timer-Flags: */ - /* see ISDN_TIMER_..defines */ - int global_flags; -- infostruct *infochain; /* List of open info-devs. */ -- wait_queue_head_t info_waitq; /* Wait-Queue for isdninfo */ - struct timer_list timer; /* Misc.-function Timer */ - int chanmap[ISDN_MAX_CHANNELS];/* Map minor->device-channel */ - int drvmap[ISDN_MAX_CHANNELS]; /* Map minor->driver-index */ - int usage[ISDN_MAX_CHANNELS]; /* Used by tty/ip/voice */ -+#ifdef CONFIG_ISDN_WITH_ABC_CH_EXTINUSE -+ ulong dwabc_chan_external_inuse[ISDN_MAX_CHANNELS]; -+#endif - char num[ISDN_MAX_CHANNELS][ISDN_MSNLEN]; - /* Remote number of active ch.*/ - int m_idx[ISDN_MAX_CHANNELS]; /* Index for mdm.... */ -@@ -631,6 +734,7 @@ typedef struct isdn_devt { - isdn_v110_stream *v110[ISDN_MAX_CHANNELS]; /* V.110 private data */ - struct semaphore sem; /* serialize list access*/ - unsigned long global_features; -+#ifdef HAVE_DEVFS_FS - #ifdef CONFIG_DEVFS_FS - devfs_handle_t devfs_handle_isdninfo; - devfs_handle_t devfs_handle_isdnctrl; -@@ -640,10 +744,41 @@ typedef struct isdn_devt { - devfs_handle_t devfs_handle_ipppX[ISDN_MAX_CHANNELS]; - #endif - #endif /* CONFIG_DEVFS_FS */ -+#endif /* HAVE_DEVFS_FS */ - } isdn_dev; - - extern isdn_dev *dev; - -+#ifdef CONFIG_ISDN_WITH_ABC -+extern int isdn_auto_dial_helper(isdn_net_local *,struct sk_buff *,int); -+extern void dwisdn_nfw_send(isdn_net_local *lp,int drop_only); -+extern void isdn_net_unreachable(struct net_device *,struct sk_buff *,char *); -+extern void isdn_net_log_skb_dwabc(struct sk_buff *,isdn_net_local *,char *); -+extern void isdn_net_hangup(struct net_device *d); -+extern void isdn_dw_clear_if(ulong pm,isdn_net_local *); -+extern void isdn_dwabc_test_phone(isdn_net_local *); -+extern void isdn_dw_abc_init_func(void); -+extern void isdn_dw_abc_release_func(void); -+extern int isdn_dw_abc_reset_interface(isdn_net_local *,int); -+extern int dwabc_bsd_init(isdn_net_local *lp); -+extern void dwabc_bsd_free(isdn_net_local *lp); -+extern struct sk_buff *dwabc_bsd_compress(isdn_net_local *,struct sk_buff *,struct net_device *); -+extern void dwabc_bsd_first_gen(isdn_net_local *); -+extern struct sk_buff *dwabc_bsd_rx_pkt(isdn_net_local *,struct sk_buff *,struct net_device *); -+#ifdef CONFIG_ISDN_WITH_ABC_LCR_SUPPORT -+extern size_t isdn_dw_abc_lcr_readstat(char *,size_t); -+extern ulong isdn_dw_abc_lcr_call_number(isdn_net_local *,isdn_ctrl *); -+extern void isdn_dw_abc_lcr_open(void); -+extern void isdn_dw_abc_lcr_close(void); -+extern int isdn_dw_abc_lcr_ioctl(ulong); -+extern void isdn_dw_abc_lcr_clear(isdn_net_local *); -+extern int isdn_dw_abc_lcr_lock(void); -+extern void isdn_dw_abc_lcr_ulock(void); -+#endif -+#ifdef CONFIG_ISDN_WITH_ABC_UDP_CHECK -+extern int dw_abc_udp_test(struct sk_buff *skb,struct net_device *ndev); -+#endif -+#endif - - #endif /* __KERNEL__ */ - ---- /dev/null -+++ b/include/linux/isdn_compat.h -@@ -0,0 +1,261 @@ -+/* $Id: isdn_compat.h,v 1.53 2001/09/24 13:23:13 kai Exp $ -+ * -+ * Linux ISDN subsystem -+ * Compatibility for various Linux kernel versions -+ * -+ * This software may be used and distributed according to the terms -+ * of the GNU General Public License, incorporated herein by reference. -+ * -+ */ -+ -+#ifndef _LINUX_ISDN_COMPAT_H -+#define _LINUX_ISDN_COMPAT_H -+ -+#ifdef __KERNEL__ -+ -+#ifndef ISDN_COMPAT_NOT_GENERIC -+/* when using std2kern -u, this part is left out and instead provided -+ by the .ctrl files */ -+ -+#include <linux/version.h> -+ -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18) -+ -+#define set_current_state(sta) (current->state = sta) -+#define module_init(x) int init_module(void) { return x(); } -+#define module_exit(x) void cleanup_module(void) { x(); } -+#define BUG() do { printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); *(int *)0 = 0; } while (0) -+#define init_MUTEX(x) *(x)=MUTEX -+#define init_MUTEX_LOCKED(x) *(x)=MUTEX_LOCKED -+#define __devinit -+#define __devinitdata -+ -+#else /* 2.2.18 and later */ -+ -+#define COMPAT_HAS_NEW_SETUP -+#define COMPAT_HAS_NEW_WAITQ -+ -+#endif -+ -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) -+ -+#define dev_kfree_skb_irq(a) dev_kfree_skb(a) -+#define dev_kfree_skb_any(a) dev_kfree_skb(a) -+#define COMPAT_HAS_2_2_PCI -+#define get_pcibase(ps, nr) ps->base_address[nr] -+#define pci_resource_start_io(pdev, nr) ((pdev)->base_address[nr] & PCI_BASE_ADDRESS_IO_MASK) -+#define pci_resource_start_mem(pdev, nr) ((pdev)->base_address[nr] & PCI_BASE_ADDRESS_MEM_MASK) -+#define pci_get_sub_vendor(pdev, id) pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, &id) -+#define pci_get_sub_system(pdev, id) pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &id) -+ -+#define __exit -+#define __devinit -+#define __devinitdata -+ -+#define net_device device -+#define COMPAT_NO_SOFTNET -+#define netif_running(d) test_bit(LINK_STATE_START, &d->state) -+#define COMPAT_NEED_MPPP_DEFS -+#define spin_lock_bh(lock) -+#define spin_unlock_bh(lock) -+#define COMPAT_NEED_SPIN_LOCK_BH -+#define i_count_read(ic) ic -+#define i_count_inc(ic) ic++ -+#define COMPAT_USE_MODCOUNT_LOCK -+#define devfs_register_chrdev(m,n,f) register_chrdev(m,n,f) -+#define devfs_unregister_chrdev(m,n) unregister_chrdev(m,n) -+#define COMPAT_NEED_PCI_IDS -+#define in_irq() (local_irq_count[smp_processor_id()] != 0) -+ -+#else /* 2.4.0 and later */ -+ -+#define pci_resource_start_io(pdev, nr) pci_resource_start(pdev, nr) -+#define pci_resource_start_mem(pdev, nr) pci_resource_start(pdev, nr) -+#define get_pcibase(ps, nr) ps->resource[nr].start -+#define pci_get_sub_system(pdev, id) id = pdev->subsystem_device -+#define pci_get_sub_vendor(pdev, id) id = pdev->subsystem_vendor -+ -+#define BIG_PHONE_NUMBERS -+#define COMPAT_HAS_ISA_IOREMAP -+#define i_count_read(ic) atomic_read(&ic) -+#define i_count_inc(ic) atomic_inc(&ic) -+#define COMPAT_HAS_FILEOP_OWNER -+#define COMPAT_HAVE_NEW_FILLDIR -+#define COMPAT_has_fileops_in_inode -+#define COMPAT_HAS_init_special_inode -+#define COMPAT_d_alloc_root_one_parameter -+#define HAVE_DEVFS_FS -+#define COMPAT_HAS_SCHEDULE_TASK -+#define COMPAT_HAS_USB_IDTAB -+ -+#endif -+ -+#endif /* ISDN_COMPAT_GENERIC */ -+ -+#ifdef COMPAT_HAS_2_2_PCI -+#include <linux/pci.h> -+#ifdef __powerpc__ -+static inline int pci_enable_device(struct pci_dev *dev) -+{ -+ u16 cmd; -+ pci_read_config_word(dev, PCI_COMMAND, &cmd); -+ cmd |= PCI_COMMAND_MEMORY | PCI_COMMAND_IO | PCI_COMMAND_SERR; -+ cmd &= ~PCI_COMMAND_FAST_BACK; -+ pci_write_config_word(dev, PCI_COMMAND, cmd); -+ return(0); -+} -+#else -+static inline int pci_enable_device(struct pci_dev *dev) -+{ -+ return 0; -+} -+#endif /* __powerpc__ */ -+ -+#define PCI_ANY_ID (~0) -+ -+/* as this is included multiple times, we make it inline */ -+ -+static inline struct pci_dev * pci_find_subsys(unsigned int vendor, unsigned int device, -+ unsigned int ss_vendor, unsigned int ss_device, -+ struct pci_dev *from) -+{ -+ unsigned short subsystem_vendor, subsystem_device; -+ -+ while ((from = pci_find_device(vendor, device, from))) { -+ pci_read_config_word(from, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor); -+ pci_read_config_word(from, PCI_SUBSYSTEM_ID, &subsystem_device); -+ if ((ss_vendor == PCI_ANY_ID || subsystem_vendor == ss_vendor) && -+ (ss_device == PCI_ANY_ID || subsystem_device == ss_device)) -+ return from; -+ } -+ return NULL; -+} -+#endif -+ -+#ifdef COMPAT_NO_SOFTNET -+#include <linux/netdevice.h> -+ -+/* -+ * Tell upper layers that the network device is ready to xmit more frames. -+ */ -+static void __inline__ netif_wake_queue(struct net_device * dev) -+{ -+ dev->tbusy = 0; -+ mark_bh(NET_BH); -+} -+ -+/* -+ * called during net_device open() -+ */ -+static void __inline__ netif_start_queue(struct net_device * dev) -+{ -+ dev->tbusy = 0; -+ /* actually, we never use the interrupt flag at all */ -+ dev->interrupt = 0; -+ dev->start = 1; -+} -+ -+/* -+ * Ask upper layers to temporarily cease passing us more xmit frames. -+ */ -+static void __inline__ netif_stop_queue(struct net_device * dev) -+{ -+ dev->tbusy = 1; -+} -+ -+#endif /* COMPAT_NO_SOFTNET */ -+ -+#ifndef COMPAT_HAS_NEW_WAITQ -+typedef struct wait_queue wait_queue_t; -+typedef struct wait_queue *wait_queue_head_t; -+ -+#define DECLARE_WAITQUEUE(wait, current) struct wait_queue wait = { current, NULL } -+#define DECLARE_WAIT_QUEUE_HEAD(wait) wait_queue_head_t wait -+#define init_waitqueue_head(x) *(x)=NULL -+#define init_waitqueue_entry(q,p) ((q)->task)=(p) -+#endif /* COMPAT_HAS_NEW_WAITQ */ -+ -+#ifdef COMPAT_NEED_PCI_IDS -+ -+#define PCI_ANY_ID (~0) -+ -+#define PCI_VENDOR_ID_DYNALINK 0x0675 -+#define PCI_DEVICE_ID_DYNALINK_IS64PH 0x1702 -+ -+#define PCI_DEVICE_ID_WINBOND2_6692 0x6692 -+ -+#define PCI_DEVICE_ID_PLX_R685 0x1030 -+#define PCI_DEVICE_ID_PLX_DJINN_ITOO 0x1151 -+#define PCI_DEVICE_ID_PLX_R753 0x1152 -+ -+#define PCI_VENDOR_ID_ELSA 0x1048 -+#define PCI_DEVICE_ID_ELSA_MICROLINK 0x1000 -+#define PCI_DEVICE_ID_ELSA_QS3000 0x3000 -+ -+#define PCI_VENDOR_ID_EICON 0x1133 -+#define PCI_DEVICE_ID_EICON_DIVA20PRO 0xe001 -+#define PCI_DEVICE_ID_EICON_DIVA20 0xe002 -+#define PCI_DEVICE_ID_EICON_DIVA20PRO_U 0xe003 -+#define PCI_DEVICE_ID_EICON_DIVA20_U 0xe004 -+#define PCI_DEVICE_ID_EICON_DIVA201 0xe005 -+#define PCI_DEVICE_ID_EICON_MAESTRA 0xe010 -+#define PCI_DEVICE_ID_EICON_MAESTRAQ 0xe012 -+#define PCI_DEVICE_ID_EICON_MAESTRAQ_U 0xe013 -+#define PCI_DEVICE_ID_EICON_MAESTRAP 0xe014 -+ -+#define PCI_VENDOR_ID_CCD 0x1397 -+#define PCI_DEVICE_ID_CCD_2BD0 0x2BD0 -+#define PCI_DEVICE_ID_CCD_B000 0xB000 -+#define PCI_DEVICE_ID_CCD_B006 0xB006 -+#define PCI_DEVICE_ID_CCD_B007 0xB007 -+#define PCI_DEVICE_ID_CCD_B008 0xB008 -+#define PCI_DEVICE_ID_CCD_B009 0xB009 -+#define PCI_DEVICE_ID_CCD_B00A 0xB00A -+#define PCI_DEVICE_ID_CCD_B00B 0xB00B -+#define PCI_DEVICE_ID_CCD_B00C 0xB00C -+#define PCI_DEVICE_ID_CCD_B100 0xB100 -+ -+#define PCI_VENDOR_ID_ASUSTEK 0x1043 -+#define PCI_DEVICE_ID_ASUSTEK_0675 0x0675 -+ -+#define PCI_VENDOR_ID_BERKOM 0x0871 -+#define PCI_DEVICE_ID_BERKOM_A1T 0xFFA1 -+#define PCI_DEVICE_ID_BERKOM_T_CONCEPT 0xFFA2 -+#define PCI_DEVICE_ID_BERKOM_A4T 0xFFA4 -+#define PCI_DEVICE_ID_BERKOM_SCITEL_QUADRO 0xFFA8 -+ -+#define PCI_DEVICE_ID_SATSAGEM_NICCY 0x1016 -+ -+#define PCI_DEVICE_ID_TIGERJET_100 0x0002 -+ -+#define PCI_VENDOR_ID_ANIGMA 0x1051 -+#define PCI_DEVICE_ID_ANIGMA_MC145575 0x0100 -+ -+#define PCI_VENDOR_ID_ZOLTRIX 0x15b0 -+#define PCI_DEVICE_ID_ZOLTRIX_2BD0 0x2BD0 -+ -+#define PCI_DEVICE_ID_DIGI_DF_M_IOM2_E 0x0070 -+#define PCI_DEVICE_ID_DIGI_DF_M_E 0x0071 -+#define PCI_DEVICE_ID_DIGI_DF_M_IOM2_A 0x0072 -+#define PCI_DEVICE_ID_DIGI_DF_M_A 0x0073 -+ -+#define PCI_DEVICE_ID_AVM_B1 0x0700 -+#define PCI_DEVICE_ID_AVM_C4 0x0800 -+#define PCI_DEVICE_ID_AVM_C2 0x1100 -+#define PCI_DEVICE_ID_AVM_T1 0x1200 -+ -+#define PCI_VENDOR_ID_HYPERCOPE 0x1365 -+#define PCI_DEVICE_ID_HYPERCOPE_PLX 0x9050 -+#define PCI_SUBDEVICE_ID_HYPERCOPE_OLD_ERGO 0x0104 -+#define PCI_SUBDEVICE_ID_HYPERCOPE_ERGO 0x0106 -+#define PCI_SUBDEVICE_ID_HYPERCOPE_METRO 0x0107 -+#define PCI_SUBDEVICE_ID_HYPERCOPE_CHAMP2 0x0108 -+#define PCI_SUBDEVICE_ID_HYPERCOPE_PLEXUS 0x0109 -+ -+#define PCI_VENDOR_ID_ABOCOM 0x13D1 -+#define PCI_DEVICE_ID_ABOCOM_2BD1 0x2BD1 -+ -+#endif /* COMPAT_NEED_PCI_IDS */ -+ -+#endif /* __KERNEL__ */ -+#endif /* _LINUX_ISDN_COMPAT_H */ ---- a/include/linux/isdn_divertif.h -+++ b/include/linux/isdn_divertif.h -@@ -1,4 +1,4 @@ --/* $Id: isdn_divertif.h,v 1.1.4.1 2001/11/20 14:19:38 kai Exp $ -+/* $Id$ - * - * Header for the diversion supplementary interface for i4l. - * -@@ -14,7 +14,7 @@ - /***********************************************************/ - /* magic value is also used to control version information */ - /***********************************************************/ --#define DIVERT_IF_MAGIC 0x25873401 -+#define DIVERT_IF_MAGIC 0x25873402 - #define DIVERT_CMD_REG 0x00 /* register command */ - #define DIVERT_CMD_REL 0x01 /* release command */ - #define DIVERT_NO_ERR 0x00 /* return value no error */ -@@ -34,6 +34,7 @@ typedef struct - int (*ll_cmd)(isdn_ctrl *); /* supplied by hl on return */ - char * (*drv_to_name)(int); /* map a driver id to name, supplied by hl */ - int (*name_to_drv)(char *); /* map a driver id to name, supplied by hl */ -+ int (*dial_net_name)(char *); /* force dial of a ll net interface */ - } isdn_divert_if; - - /*********************/ ---- /dev/null -+++ b/include/linux/isdn_dwabc.h -@@ -0,0 +1,84 @@ -+/* $Id: isdn_dwabc.h,v 1.9 2001/09/26 20:32:08 detabc Exp $ -+ * -+ * Header for the Linux ISDN abc-extension. -+ * -+ * Copyright by abc GmbH -+ * written by Detlef Wengorz <detlefw@isdn4linux.de> -+ * -+ * This software may be used and distributed according to the terms -+ * of the GNU General Public License, incorporated herein by reference. -+ * -+ */ -+ -+#ifndef ISDN_DWABC_H -+#define ISDN_DWABC_H -+ -+#ifdef __KERNEL__ -+#include <linux/types.h> -+#include <linux/kernel.h> -+#include <linux/sched.h> -+#include <linux/smp.h> -+#include <linux/spinlock.h> -+#include <linux/errno.h> -+ -+ -+typedef struct ISDN_DWSPINLOCK { -+ -+ spinlock_t spin; -+ short owner; -+ short my_flags; -+ ulong irq_flags; -+ -+} ISDN_DWSPINLOCK; -+ -+#define ISDN_DWSPIN_UNLOCKED \ -+ (ISDN_DWSPINLOCK) { \ -+ spin: SPIN_LOCK_UNLOCKED, \ -+ owner: -1, \ -+ my_flags: 0, \ -+ irq_flags: 0, \ -+ } -+ -+#define ISDN_DWSPIN_INIT(x) \ -+ do { *(x) = ISDN_DWSPIN_UNLOCKED; } while(0); -+ -+static __inline__ int isdn_dwspin_trylock(ISDN_DWSPINLOCK *spin) -+{ -+ if(!spin_trylock(&spin->spin)) { -+ -+ if(spin->owner == smp_processor_id()) -+ return(-EAGAIN); -+ -+ spin_lock(&spin->spin); -+ } -+ -+ spin->owner = smp_processor_id(); -+ return(0); -+} -+ -+static __inline__ void isdn_dwspin_unlock(ISDN_DWSPINLOCK *spin) -+{ -+ spin->owner = -1; -+ spin_unlock(&spin->spin); -+} -+ -+ -+#else -+#include <sys/types.h> -+#endif -+ -+#define DWABC_LCR_FLG_NEWNUMBER 0x00000001L -+#define DWABC_LCR_FLG_DISABLE 0x00000002L -+#define DWABC_LCR_FLG_NEWHUPTIME 0x00000004L -+ -+ -+struct ISDN_DWABC_LCR_IOCTL { -+ -+ int lcr_ioctl_sizeof; /* mustbe sizeof(ISDN_DWABC_LCR_IOCTL) */ -+ u_short lcr_ioctl_onhtime; /* new hanguptime */ -+ u_long lcr_ioctl_callid; /* callid from lcr-subsystem */ -+ u_long lcr_ioctl_flags; /* see above */ -+ char lcr_ioctl_nr[32]; /* new destination phonenumber */ -+}; -+ -+#endif ---- a/include/linux/isdn_lzscomp.h -+++ b/include/linux/isdn_lzscomp.h -@@ -1,4 +1,4 @@ --/* $Id: isdn_lzscomp.h,v 1.1.4.1 2001/11/20 14:19:38 kai Exp $ -+/* $Id$ - * - * Header for isdn_lzscomp.c - * Concentrated here to not mess up half a dozen kernel headers with code ---- a/include/linux/isdn_ppp.h -+++ b/include/linux/isdn_ppp.h -@@ -8,6 +8,7 @@ - #ifndef _LINUX_ISDN_PPP_H - #define _LINUX_ISDN_PPP_H - -+#include <linux/isdn_compat.h> - - #define CALLTYPE_INCOMING 0x1 - #define CALLTYPE_OUTGOING 0x2 -@@ -33,6 +34,11 @@ struct pppcallinfo - #define PPPIOCSCOMPRESSOR _IOW('t',135,int) - #define PPPIOCGIFNAME _IOR('t',136, char [IFNAMSIZ] ) - -+#ifdef COMPAT_NEED_MPPP_DEFS -+#define PPP_MP 0x003d -+#define PPP_COMPFRAG 0x00fb -+#define PPP_CCPFRAG 0x80fb -+#endif - - #define SC_MP_PROT 0x00000200 - #define SC_REJ_MP_PROT 0x00000400 -@@ -65,9 +71,6 @@ struct isdn_ppp_comp_data { - - #include <linux/config.h> - --#ifdef CONFIG_IPPP_FILTER --#include <linux/filter.h> --#endif - - #define DECOMP_ERR_NOMEM (-10) - -@@ -226,10 +229,6 @@ struct ippp_struct { - unsigned char *cbuf; - struct slcompress *slcomp; - #endif --#ifdef CONFIG_IPPP_FILTER -- struct sock_fprog pass_filter; /* filter for packets to pass */ -- struct sock_fprog active_filter; /* filter for pkts to reset idle */ --#endif - unsigned long debug; - struct isdn_ppp_compressor *compressor,*decompressor; - struct isdn_ppp_compressor *link_compressor,*link_decompressor; ---- a/include/linux/isdnif.h -+++ b/include/linux/isdnif.h -@@ -1,4 +1,4 @@ --/* $Id: isdnif.h,v 1.1.4.1 2001/11/20 14:19:38 kai Exp $ -+/* $Id: isdnif.h,v 1.43 2002/02/09 21:19:11 keil Exp $ - * - * Linux ISDN subsystem - * Definition of the interface between the subsystem and its low-level drivers. -@@ -14,6 +14,7 @@ - #ifndef __ISDNIF_H__ - #define __ISDNIF_H__ - -+#include <linux/isdn_compat.h> - - /* - * Values for general protocol-selection -@@ -213,6 +214,8 @@ typedef struct - #define ISDN_STAT_FAXIND 276 /* FAX indications from HL-driver */ - #define ISDN_STAT_AUDIO 277 /* DTMF, DSP indications */ - #define ISDN_STAT_DISCH 278 /* Disable/Enable channel usage */ -+#define ISDN_STAT_ALERT 279 /* Signal alerting */ -+#define ISDN_STAT_PROCEED 280 /* Signal proceeding */ - - /* - * Audio commands ---- a/include/linux/kernelcapi.h -+++ b/include/linux/kernelcapi.h -@@ -1,12 +1,10 @@ --/* $Id: kernelcapi.h,v 1.1.4.2 2002/01/28 18:25:10 kai Exp $ -+/* -+ * $Id: kernelcapi.h,v 1.9 2000/11/28 09:34:02 kai Exp $ - * - * Kernel CAPI 2.0 Interface for Linux - * - * (c) Copyright 1997 by Carsten Paeth (calle@calle.in-berlin.de) - * -- * This software may be used and distributed according to the terms -- * of the GNU General Public License, incorporated herein by reference. -- * - */ - - #ifndef __KERNELCAPI_H__ diff --git a/target/linux/generic-2.4/patches/201-hfc_usb_backport.patch b/target/linux/generic-2.4/patches/201-hfc_usb_backport.patch deleted file mode 100644 index c2d62f6..0000000 --- a/target/linux/generic-2.4/patches/201-hfc_usb_backport.patch +++ /dev/null @@ -1,2661 +0,0 @@ ---- a/drivers/Makefile -+++ b/drivers/Makefile -@@ -38,7 +38,7 @@ subdir-$(CONFIG_FUSION) += message/fusi - subdir-$(CONFIG_MD) += md - subdir-$(CONFIG_IEEE1394) += ieee1394 - subdir-$(CONFIG_PNP) += pnp --subdir-$(CONFIG_ISDN_BOOL) += isdn -+subdir-$(CONFIG_ISDN) += isdn - subdir-$(CONFIG_ATM) += atm - subdir-$(CONFIG_FC4) += fc4 - ---- a/drivers/isdn/hisax/hfc_usb.c -+++ b/drivers/isdn/hisax/hfc_usb.c -@@ -1,13 +1,11 @@ --/* $Id: hfc_usb.c,v 2.3 2001/07/06 21:30:11 werner Exp $ -+/* -+ * hfc_usb.c - * -+ * modular HiSax ISDN driver for Colognechip HFC-USB chip - * -- * -- * Author (C) 2001 Werner Cornelius (werner@isdn-development.de) -- * modular driver for Colognechip HFC-USB chip -- * as plugin for HiSax isdn driver -- * type approval valid for HFC-S USB based TAs -- * -- * Copyright 2001 by Werner Cornelius (werner@isdn-development.de) -+ * Authors : Peter Sprenger (sprenger@moving-byters.de) -+ * Martin Bachem (info@colognechip.com) -+ * based on the first hfc_usb driver of Werner Cornelius (werner@isdn-development.de) - * - * 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 -@@ -23,70 +21,90 @@ - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * -- */ -+ * 2005_Mar_16 grsch -+ * ported 2.6.8 hfc_usb.c to 2.4.20 format -+ * Gregor Schaffrath <gschaff@ran-dom.org> -+*/ -+ - - #include <linux/types.h> - #include <linux/stddef.h> - #include <linux/timer.h> - #include <linux/config.h> --#include <linux/isdn_compat.h> - #include <linux/init.h> - #include "hisax.h" - #include <linux/module.h> - #include <linux/kernel_stat.h> --#include <linux/tqueue.h> - #include <linux/usb.h> - #include <linux/kernel.h> - #include <linux/smp_lock.h> - #include <linux/sched.h> -+#include "hisax_if.h" - #include "hisax_loadable.h" - -+static const char *hfcusb_revision = "4.0"; -+ -+/* -+ to enable much mire debug messages in this driver, define -+ VERBOSE_USB_DEBUG and VERBOSE_ISDN_DEBUG -+ below -+*/ -+ -+#define VERBOSE_USB_DEBUG -+#define VERBOSE_ISDN_DEBUG -+ - #define INCLUDE_INLINE_FUNCS - -+#define TRUE 1 -+#define FALSE 0 -+ -+ - /***********/ - /* defines */ - /***********/ --#define HFC_CTRL_TIMEOUT 5 /* 5ms timeout writing/reading regs */ --#define HFC_TIMER_T3 7000 /* timeout for l1 activation timer */ -- --#define HFCUSB_L1_STATECHANGE 0 /* L1 state changed */ --#define HFCUSB_L1_DRX 1 /* D-frame received */ --#define HFCUSB_L1_ERX 2 /* E-frame received */ --#define HFCUSB_L1_DTX 4 /* D-frames completed */ -- --#define MAX_BCH_SIZE 2048 /* allowed B-channel packet size */ -- --#define HFCUSB_RX_THRESHOLD 64 /* threshold for fifo report bit rx */ --#define HFCUSB_TX_THRESHOLD 64 /* threshold for fifo report bit tx */ -- --#define HFCUSB_CHIP_ID 0x16 /* Chip ID register index */ --#define HFCUSB_CIRM 0x00 /* cirm register index */ --#define HFCUSB_USB_SIZE 0x07 /* int length register */ --#define HFCUSB_USB_SIZE_I 0x06 /* iso length register */ --#define HFCUSB_F_CROSS 0x0b /* bit order register */ --#define HFCUSB_CLKDEL 0x37 /* bit delay register */ --#define HFCUSB_CON_HDLC 0xfa /* channel connect register */ -+#define HFC_CTRL_TIMEOUT 20 //(HZ * USB_CTRL_GET_TIMEOUT) -+/* 5ms timeout writing/reading regs */ -+#define HFC_TIMER_T3 8000 /* timeout for l1 activation timer */ -+#define HFC_TIMER_T4 500 /* time for state change interval */ -+ -+#define HFCUSB_L1_STATECHANGE 0 /* L1 state changed */ -+#define HFCUSB_L1_DRX 1 /* D-frame received */ -+#define HFCUSB_L1_ERX 2 /* E-frame received */ -+#define HFCUSB_L1_DTX 4 /* D-frames completed */ -+ -+#define MAX_BCH_SIZE 2048 /* allowed B-channel packet size */ -+ -+#define HFCUSB_RX_THRESHOLD 64 /* threshold for fifo report bit rx */ -+#define HFCUSB_TX_THRESHOLD 64 /* threshold for fifo report bit tx */ -+ -+#define HFCUSB_CHIP_ID 0x16 /* Chip ID register index */ -+#define HFCUSB_CIRM 0x00 /* cirm register index */ -+#define HFCUSB_USB_SIZE 0x07 /* int length register */ -+#define HFCUSB_USB_SIZE_I 0x06 /* iso length register */ -+#define HFCUSB_F_CROSS 0x0b /* bit order register */ -+#define HFCUSB_CLKDEL 0x37 /* bit delay register */ -+#define HFCUSB_CON_HDLC 0xfa /* channel connect register */ - #define HFCUSB_HDLC_PAR 0xfb --#define HFCUSB_SCTRL 0x31 /* S-bus control register (tx) */ --#define HFCUSB_SCTRL_E 0x32 /* same for E and special funcs */ --#define HFCUSB_SCTRL_R 0x33 /* S-bus control register (rx) */ --#define HFCUSB_F_THRES 0x0c /* threshold register */ --#define HFCUSB_FIFO 0x0f /* fifo select register */ --#define HFCUSB_F_USAGE 0x1a /* fifo usage register */ -+#define HFCUSB_SCTRL 0x31 /* S-bus control register (tx) */ -+#define HFCUSB_SCTRL_E 0x32 /* same for E and special funcs */ -+#define HFCUSB_SCTRL_R 0x33 /* S-bus control register (rx) */ -+#define HFCUSB_F_THRES 0x0c /* threshold register */ -+#define HFCUSB_FIFO 0x0f /* fifo select register */ -+#define HFCUSB_F_USAGE 0x1a /* fifo usage register */ - #define HFCUSB_MST_MODE0 0x14 - #define HFCUSB_MST_MODE1 0x15 - #define HFCUSB_P_DATA 0x1f - #define HFCUSB_INC_RES_F 0x0e - #define HFCUSB_STATES 0x30 - --#define HFCUSB_CHIPID 0x40 /* ID value of HFC-USB */ -+#define HFCUSB_CHIPID 0x40 /* ID value of HFC-USB */ - - /******************/ - /* fifo registers */ - /******************/ --#define HFCUSB_NUM_FIFOS 8 /* maximum number of fifos */ --#define HFCUSB_B1_TX 0 /* index for B1 transmit bulk/int */ --#define HFCUSB_B1_RX 1 /* index for B1 receive bulk/int */ -+#define HFCUSB_NUM_FIFOS 8 /* maximum number of fifos */ -+#define HFCUSB_B1_TX 0 /* index for B1 transmit bulk/int */ -+#define HFCUSB_B1_RX 1 /* index for B1 receive bulk/int */ - #define HFCUSB_B2_TX 2 - #define HFCUSB_B2_RX 3 - #define HFCUSB_D_TX 4 -@@ -94,198 +112,162 @@ - #define HFCUSB_PCM_TX 6 - #define HFCUSB_PCM_RX 7 - --/************/ --/* LED mask */ --/************/ --#define LED_DRIVER 0x1 --#define LED_L1 0x2 --#define LED_BCH 0x4 -+/* -+* used to switch snd_transfer_mode for different TA modes e.g. the Billion USB TA just -+* supports ISO out, while the Cologne Chip EVAL TA just supports BULK out -+*/ -+#define USB_INT 0 -+#define USB_BULK 1 -+#define USB_ISOC 2 -+ -+#define ISOC_PACKETS_D 8 -+#define ISOC_PACKETS_B 8 -+#define ISO_BUFFER_SIZE 128 -+ -+// ISO send definitions -+#define SINK_MAX 68 -+#define SINK_MIN 48 -+#define SINK_DMIN 12 -+#define SINK_DMAX 18 -+#define BITLINE_INF (-64*8) -+ -+ -+ - - /**********/ - /* macros */ - /**********/ --#define Write_hfc(a,b,c) usb_control_msg((a)->dev,(a)->ctrl_out_pipe,0,0x40,(c),(b),0,0,HFC_CTRL_TIMEOUT) --#define Read_hfc(a,b,c) usb_control_msg((a)->dev,(a)->ctrl_in_pipe,1,0xC0,0,(b),(c),1,HFC_CTRL_TIMEOUT) -- --#ifdef COMPAT_HAS_USB_IDTAB --/****************************************/ --/* data defining the devices to be used */ --/****************************************/ --static __devinitdata const struct usb_device_id hfc_usb_idtab[3] = { -- {USB_DEVICE(0x959, 0x2bd0)}, /* Colognechip ROM */ -- {USB_DEVICE(0x7b0, 0x0006)}, /* USB TA 128 */ -- {} /* end with an all-zeroes entry */ --}; --#endif -+#define write_usb(a,b,c) usb_control_msg((a)->dev,(a)->ctrl_out_pipe,0,0x40,(c),(b),NULL,0,HFC_CTRL_TIMEOUT) -+#define read_usb(a,b,c) usb_control_msg((a)->dev,(a)->ctrl_in_pipe,1,0xC0,0,(b),(c),1,HFC_CTRL_TIMEOUT) - - /*************************************************/ - /* entry and size of output/input control buffer */ - /*************************************************/ - #define HFC_CTRL_BUFSIZE 32 --typedef struct { -+typedef struct -+{ - __u8 hfc_reg; /* register number */ - __u8 reg_val; /* value to be written (or read) */ -+ int action; /* data for action handler */ -+ - } ctrl_buft; - -+typedef struct -+{ -+ int vendor; // vendor id -+ int prod_id; // product id -+ char *vend_name; // vendor string -+ __u8 led_scheme; // led display scheme -+ __u8 led_invert; // invert led aux port settings -+ __u8 led_bits[8]; // array of 8 possible LED bitmask settings -+ -+} vendor_data; -+ - /***************************************************************/ - /* structure defining input+output fifos (interrupt/bulk mode) */ - /***************************************************************/ --struct hfcusb_data; /* forward definition */ --typedef struct { -- int fifonum; /* fifo index attached to this structure */ -- __u8 fifo_mask; /* mask for this fifo */ -- int active; /* fifo is currently active */ -+ -+struct usb_fifo; /* forward definition */ -+typedef struct iso_urb_struct -+{ -+ struct urb *purb; -+ __u8 buffer[ISO_BUFFER_SIZE]; /* buffer incoming/outgoing data */ -+ struct usb_fifo *owner_fifo; // pointer to owner fifo -+} iso_urb_struct; -+ -+ -+struct hfcusb_data; /* forward definition */ -+typedef struct usb_fifo -+{ -+ int fifonum; /* fifo index attached to this structure */ -+ int active; /* fifo is currently active */ - struct hfcusb_data *hfc; /* pointer to main structure */ -- int pipe; /* address of endpoint */ -- __u8 usb_maxlen; /* maximum length for usb transfer */ -- int max_size; /* maximum size of receive/send packet */ -- int transmode; /* transparent mode selected */ -- int framenum; /* number of frame when last tx completed */ -- int rx_offset; /* offset inside rx buffer */ -- int next_complete; /* complete marker */ -- __u8 *act_ptr; /* pointer to next data */ -- __u8 intervall; /* interrupt interval */ -- struct sk_buff *buff; /* actual used buffer */ -- urb_t urb; /* transfer structure for usb routines */ -- __u8 buffer[128]; /* buffer incoming/outgoing data */ -+ int pipe; /* address of endpoint */ -+ __u8 usb_packet_maxlen; /* maximum length for usb transfer */ -+ unsigned int max_size; /* maximum size of receive/send packet */ -+ __u8 intervall; /* interrupt interval */ -+ struct sk_buff *skbuff; /* actual used buffer */ -+ struct urb *urb; /* transfer structure for usb routines */ -+ __u8 buffer[128]; /* buffer incoming/outgoing data */ -+ int bit_line; /* how much bits are in the fifo? */ -+ -+ volatile __u8 usb_transfer_mode;/* switched between ISO and INT */ -+ iso_urb_struct iso[2]; /* need two urbs to have one always for pending */ -+ struct hisax_if *hif; /* hisax interface */ -+ int delete_flg; /* only delete skbuff once */ -+ int last_urblen; /* remember length of last packet */ -+ - } usb_fifo; - -+ - /*********************************************/ - /* structure holding all data for one device */ - /*********************************************/ --typedef struct hfcusb_data { -- struct hisax_drvreg regd; /* register data and callbacks */ -- struct usb_device *dev; /* our device */ -- int if_used; /* used interface number */ -- int alt_used; /* used alternate config */ -- int ctrl_paksize; /* control pipe packet size */ -+typedef struct hfcusb_data -+{ -+ // HiSax Interface for loadable Layer1 drivers -+ struct hisax_d_if d_if; /* see hisax_if.h */ -+ struct hisax_b_if b_if[2]; /* see hisax_if.h */ -+ int protocol; -+ -+ struct usb_device *dev; /* our device */ -+ int if_used; /* used interface number */ -+ int alt_used; /* used alternate config */ -+ int ctrl_paksize; /* control pipe packet size */ - int ctrl_in_pipe, ctrl_out_pipe; /* handles for control pipe */ -+ int cfg_used; /* configuration index used */ -+ int vend_idx; // vendor found -+ -+ int b_mode[2]; // B-channel mode -+ -+ int l1_activated; // layer 1 activated -+ -+ int packet_size,iso_packet_size; - - /* control pipe background handling */ - ctrl_buft ctrl_buff[HFC_CTRL_BUFSIZE]; /* buffer holding queued data */ -- volatile int ctrl_in_idx, ctrl_out_idx, ctrl_cnt; /* input/output pointer + count */ -- urb_t ctrl_urb; /* transfer structure for control channel */ -- devrequest ctrl_write; /* buffer for control write request */ -- devrequest ctrl_read; /* same for read request */ -- -- volatile __u8 dfifo_fill; /* value read from tx d-fifo */ -- volatile __u8 active_fifos; /* fifos currently active as bit mask */ -- volatile __u8 threshold_mask; /* threshold actually reported */ -- volatile __u8 service_request; /* fifo needs service from task */ -- volatile __u8 ctrl_fifo; /* last selected fifo */ -- volatile __u8 bch_enables; /* or mask for sctrl_r and sctrl register values */ -- volatile __u8 led_req; /* request status of adapters leds */ -- volatile __u8 led_act; /* active status of adapters leds */ -+ volatile int ctrl_in_idx, ctrl_out_idx, -+ ctrl_cnt; /* input/output pointer + count */ -+ struct urb *ctrl_urb; /* transfer structure for control channel */ -+ -+ struct usb_ctrlrequest ctrl_write; /* buffer for control write request */ -+ struct usb_ctrlrequest ctrl_read; /* same for read request */ -+ -+ __u8 led_state,led_new_data,led_b_active; -+ -+ volatile __u8 threshold_mask; /* threshold actually reported */ -+ volatile __u8 bch_enables; /* or mask for sctrl_r and sctrl register values */ -+ - usb_fifo fifos[HFCUSB_NUM_FIFOS]; /* structure holding all fifo data */ - -- /* layer 1 activation/deactivation handling */ -- volatile __u8 l1_state; /* actual l1 state */ -- volatile ulong l1_event; /* event mask */ -- struct tq_struct l1_tq; /* l1 bh structure */ -- struct timer_list t3_timer; /* timer for activation/deactivation */ -- struct timer_list t4_timer; /* timer for activation/deactivation */ -+ volatile __u8 l1_state; /* actual l1 state */ -+ struct timer_list t3_timer; /* timer 3 for activation/deactivation */ -+ struct timer_list t4_timer; /* timer 4 for activation/deactivation */ -+ struct timer_list led_timer; /* timer flashing leds */ -+ - } hfcusb_data; - --#if 0 --static void --usb_dump_urb(purb_t purb) --{ -- printk("urb :%p\n", purb); -- printk("next :%p\n", purb->next); -- printk("dev :%p\n", purb->dev); -- printk("pipe :%08X\n", purb->pipe); -- printk("status :%d\n", purb->status); -- printk("transfer_flags :%08X\n", purb->transfer_flags); -- printk("transfer_buffer :%p\n", purb->transfer_buffer); -- printk("transfer_buffer_length:%d\n", -- purb->transfer_buffer_length); -- printk("actual_length :%d\n", purb->actual_length); -- printk("setup_packet :%p\n", purb->setup_packet); -- printk("start_frame :%d\n", purb->start_frame); -- printk("number_of_packets :%d\n", purb->number_of_packets); -- printk("interval :%d\n", purb->interval); -- printk("error_count :%d\n", purb->error_count); -- printk("context :%p\n", purb->context); -- printk("complete :%p\n", purb->complete); --} --#endif - --/*************************************************************************/ --/* bottom half handler for L1 activation/deactiavtaion + D-chan + E-chan */ --/*************************************************************************/ --static void --usb_l1d_bh(hfcusb_data * hfc) --{ -+static void collect_rx_frame(usb_fifo *fifo,__u8 *data,int len,int finish); -+ - -- while (hfc->l1_event) { -- if (test_and_clear_bit -- (HFCUSB_L1_STATECHANGE, &hfc->l1_event)) { -- if (hfc->l1_state == 7) -- hfc->led_req |= LED_L1; -- else -- hfc->led_req &= ~LED_L1; -- if ((hfc->l1_state == 7) || -- (hfc->l1_state == 3)) -- hfc->regd.dch_l1l2(hfc->regd.arg_hisax, -- (hfc->l1_state == -- 7) ? (PH_ACTIVATE | -- INDICATION) -- : (PH_DEACTIVATE | INDICATION), -- NULL); -- } -- if (test_and_clear_bit(HFCUSB_L1_DRX, &hfc->l1_event)) { -- hfc->regd.dch_l1l2(hfc->regd.arg_hisax, -- PH_DATA | INDICATION, -- (void *) 0); -- } -- if (test_and_clear_bit(HFCUSB_L1_ERX, &hfc->l1_event)) { -- hfc->regd.dch_l1l2(hfc->regd.arg_hisax, -- PH_DATA | INDICATION, -- (void *) 1); -- } -- if (test_and_clear_bit(HFCUSB_L1_DTX, &hfc->l1_event)) { -- hfc->regd.dch_l1l2(hfc->regd.arg_hisax, -- PH_DATA | CONFIRM, NULL); -- } -- } /* while */ --} /* usb_l1d_bh */ - - /******************************************************/ - /* start next background transfer for control channel */ - /******************************************************/ --static void --ctrl_start_transfer(hfcusb_data * hfc) -+static void ctrl_start_transfer(hfcusb_data * hfc) - { -- -- if (hfc->ctrl_cnt) { -- switch (hfc->ctrl_buff[hfc->ctrl_out_idx].hfc_reg) { -- case HFCUSB_F_USAGE: -- hfc->ctrl_urb.pipe = hfc->ctrl_in_pipe; -- hfc->ctrl_urb.setup_packet = -- (u_char *) & hfc->ctrl_read; -- hfc->ctrl_urb.transfer_buffer_length = 1; -- hfc->ctrl_read.index = -- hfc->ctrl_buff[hfc->ctrl_out_idx]. -- hfc_reg; -- hfc->ctrl_urb.transfer_buffer = -- (char *) &hfc->dfifo_fill; -- break; -- -- default: /* write register */ -- hfc->ctrl_urb.pipe = hfc->ctrl_out_pipe; -- hfc->ctrl_urb.setup_packet = -- (u_char *) & hfc->ctrl_write; -- hfc->ctrl_urb.transfer_buffer = NULL; -- hfc->ctrl_urb.transfer_buffer_length = 0; -- hfc->ctrl_write.index = -- hfc->ctrl_buff[hfc->ctrl_out_idx]. -- hfc_reg; -- hfc->ctrl_write.value = -- hfc->ctrl_buff[hfc->ctrl_out_idx]. -- reg_val; -- break; -- } -- usb_submit_urb(&hfc->ctrl_urb); /* start transfer */ -+ int err; -+ if(hfc->ctrl_cnt) -+ { -+ hfc->ctrl_urb->pipe = hfc->ctrl_out_pipe; -+ hfc->ctrl_urb->setup_packet = (u_char *) & hfc->ctrl_write; -+ hfc->ctrl_urb->transfer_buffer = NULL; -+ hfc->ctrl_urb->transfer_buffer_length = 0; -+ hfc->ctrl_write.wIndex = hfc->ctrl_buff[hfc->ctrl_out_idx].hfc_reg; -+ hfc->ctrl_write.wValue = hfc->ctrl_buff[hfc->ctrl_out_idx].reg_val; -+ err = usb_submit_urb(hfc->ctrl_urb); /* start transfer */ -+ printk(KERN_DEBUG "ctrl_start_transfer: submit %d\n", err); - } - } /* ctrl_start_transfer */ - -@@ -293,897 +275,1418 @@ ctrl_start_transfer(hfcusb_data * hfc) - /* queue a control transfer request */ - /* return 0 on success. */ - /************************************/ --static int --queue_control_request(hfcusb_data * hfc, __u8 reg, __u8 val) -+static int queue_control_request(hfcusb_data * hfc, __u8 reg, __u8 val,int action) - { - ctrl_buft *buf; - -- if (hfc->ctrl_cnt >= HFC_CTRL_BUFSIZE) -- return (1); /* no space left */ -- buf = hfc->ctrl_buff + hfc->ctrl_in_idx; /* pointer to new index */ -+#ifdef VERBOSE_USB_DEBUG -+ printk ("HFC_USB: queue_control_request reg: %x, val: %x\n", reg, val); -+#endif -+ -+ if(hfc->ctrl_cnt >= HFC_CTRL_BUFSIZE) return(1); /* no space left */ -+ buf = &hfc->ctrl_buff[hfc->ctrl_in_idx]; /* pointer to new index */ - buf->hfc_reg = reg; - buf->reg_val = val; -+ buf->action=action; - if (++hfc->ctrl_in_idx >= HFC_CTRL_BUFSIZE) - hfc->ctrl_in_idx = 0; /* pointer wrap */ - if (++hfc->ctrl_cnt == 1) - ctrl_start_transfer(hfc); -- return (0); --} /* queue_control_request */ -+ return(0); -+} /* queue_control_request */ - --/**************************************/ --/* called when timer t3 or t4 expires */ --/**************************************/ --static void --l1_timer_expire(hfcusb_data * hfc) --{ -- if (timer_pending(&hfc->t4_timer)) -- del_timer(&hfc->t4_timer); -- queue_control_request(hfc, HFCUSB_STATES, 0x40); -- test_and_set_bit(HFCUSB_L1_STATECHANGE, -- &hfc->l1_event); -- queue_task(&hfc->l1_tq, &tq_immediate); -- mark_bh(IMMEDIATE_BH); --} /* l1_timer_expire */ -- --/**************************************************/ --/* (re)fills a tx-fifo urb. Queuing is done later */ --/**************************************************/ --static void --fill_tx_urb(usb_fifo * fifo) --{ -- struct sk_buff *skb; -- long flags; -- int i, ii = 0; -- -- fifo->urb.dev = fifo->hfc->dev; -- if ((fifo->buff) -- && (fifo->urb.transfer_buffer_length < fifo->usb_maxlen)) { -- switch (fifo->fifonum) { -- case HFCUSB_B1_TX: -- case HFCUSB_B2_TX: -- skb = fifo->buff; -- fifo->buff = NULL; -- fifo->hfc->regd.bch_l1l2(fifo->hfc->regd. -- arg_hisax, -- (fifo->fifonum == -- HFCUSB_B1_TX) ? 0 -- : 1, -- (PH_DATA | -- CONFIRM), -- (void *) skb); -- fifo->hfc->service_request |= -- fifo->fifo_mask; -- return; -- case HFCUSB_D_TX: -- dev_kfree_skb_any(fifo->buff); -- fifo->buff = NULL; -- save_flags(flags); -- cli(); -- fifo->hfc->dfifo_fill = 0xff; /* currently invalid data */ -- queue_control_request(fifo->hfc, -- HFCUSB_FIFO, -- HFCUSB_D_TX); -- queue_control_request(fifo->hfc, -- HFCUSB_F_USAGE, 0); -- restore_flags(flags); -- return; -- default: -- return; /* error, invalid fifo */ -- } -+ -+static int control_action_handler(hfcusb_data *hfc,int reg,int val,int action) -+{ -+ if(!action) return(1); // no action defined -+ -+ return(0); -+} -+ -+ -+/***************************************************************/ -+/* control completion routine handling background control cmds */ -+/***************************************************************/ -+static void ctrl_complete(struct urb *urb) -+{ -+ hfcusb_data *hfc = (hfcusb_data *) urb->context; -+ ctrl_buft *buf; -+ -+ printk(KERN_DEBUG "ctrl_complete cnt %d\n", hfc->ctrl_cnt); -+ urb->dev = hfc->dev; -+ if(hfc->ctrl_cnt) -+ { -+ buf=&hfc->ctrl_buff[hfc->ctrl_out_idx]; -+ control_action_handler(hfc,buf->hfc_reg,buf->reg_val,buf->action); -+ -+ hfc->ctrl_cnt--; /* decrement actual count */ -+ if(++hfc->ctrl_out_idx >= HFC_CTRL_BUFSIZE) hfc->ctrl_out_idx = 0; /* pointer wrap */ -+ -+ ctrl_start_transfer(hfc); /* start next transfer */ -+ } -+} /* ctrl_complete */ -+ -+ -+ -+#define LED_OFF 0 // no LED support -+#define LED_SCHEME1 1 // LED standard scheme -+#define LED_SCHEME2 2 // not used yet... -+ -+#define LED_POWER_ON 1 -+#define LED_POWER_OFF 2 -+#define LED_S0_ON 3 -+#define LED_S0_OFF 4 -+#define LED_B1_ON 5 -+#define LED_B1_OFF 6 -+#define LED_B1_DATA 7 -+#define LED_B2_ON 8 -+#define LED_B2_OFF 9 -+#define LED_B2_DATA 10 -+ -+#define LED_NORMAL 0 // LEDs are normal -+#define LED_INVERTED 1 // LEDs are inverted -+ -+// time for LED flashing -+#define LED_TIME 250 -+ -+vendor_data vdata[]= -+{ -+ {0x959, 0x2bd0, "ISDN USB TA (Cologne Chip HFC-S USB based)", LED_OFF,LED_NORMAL,{4,0,2,1}}, /* CologneChip Eval TA */ -+ {0x7b0, 0x0007, "Billion tiny USB ISDN TA 128", LED_SCHEME1, LED_INVERTED, {8,0x40,0x20,0x10}}, /* Billion TA */ -+ {0x742, 0x2008, "Stollmann USB TA", LED_SCHEME1, LED_NORMAL, {4,0,2,1}}, /* Stollmann TA */ -+ {0x8e3, 0x0301, "Olitec USB RNIS", LED_SCHEME1, LED_NORMAL, {2,0,1,4}}, /* Olitec TA */ -+ {0x675, 0x1688, "DrayTec USB ISDN TA", LED_SCHEME1, LED_NORMAL, {4,0,2,1}}, /* Draytec TA */ -+ {0x7fa, 0x0846, "Bewan Modem RNIS USB", LED_SCHEME1, LED_INVERTED, {8,0x40,0x20,0x10}}, /* Bewan TA */ -+ {0} // EOL element -+}; -+ -+/***************************************************/ -+/* write led data to auxport & invert if necessary */ -+/***************************************************/ -+static void write_led(hfcusb_data * hfc,__u8 led_state) -+{ -+ if(led_state!=hfc->led_state) -+ { -+ hfc->led_state=led_state; -+ queue_control_request(hfc, HFCUSB_P_DATA,(vdata[hfc->vend_idx].led_invert) ? ~led_state : led_state,1); -+ } -+} -+ -+/******************************************/ -+/* invert B-channel LEDs if data is sent */ -+/******************************************/ -+static void led_timer(hfcusb_data * hfc) -+{ -+ static int cnt=0; -+ __u8 led_state=hfc->led_state; -+ -+ if(cnt) -+ { -+ if(hfc->led_b_active&1) led_state|=vdata[hfc->vend_idx].led_bits[2]; -+ if(hfc->led_b_active&2) led_state|=vdata[hfc->vend_idx].led_bits[3]; -+ } -+ else -+ { -+ if(!(hfc->led_b_active&1) || hfc->led_new_data&1) led_state&=~vdata[hfc->vend_idx].led_bits[2]; -+ if(!(hfc->led_b_active&2) || hfc->led_new_data&2) led_state&=~vdata[hfc->vend_idx].led_bits[3]; - } - -- /* check if new buffer needed */ -- if (!fifo->buff) { -- switch (fifo->fifonum) { -- case HFCUSB_B1_TX: -- if (fifo->hfc->regd.bsk[0]) -- fifo->buff = *fifo->hfc->regd.bsk[0]; /* B1-channel tx buffer */ -+ write_led(hfc,led_state); -+ hfc->led_new_data=0; -+ -+ cnt=!cnt; -+ // restart 4 hz timer -+ hfc->led_timer.expires = jiffies + (LED_TIME * HZ) / 1000; -+ if(!timer_pending(&hfc->led_timer)) add_timer(&hfc->led_timer); -+} -+ -+/**************************/ -+/* handle LED requests */ -+/**************************/ -+static void handle_led(hfcusb_data * hfc,int event) -+{ -+ __u8 led_state=hfc->led_state; -+ -+ // if no scheme -> no LED action -+ if(vdata[hfc->vend_idx].led_scheme==LED_OFF) return; -+ -+ switch(event) -+ { -+ case LED_POWER_ON: -+ led_state|=vdata[hfc->vend_idx].led_bits[0]; -+ break; -+ case LED_POWER_OFF: // no Power off handling -+ break; -+ case LED_S0_ON: -+ led_state|=vdata[hfc->vend_idx].led_bits[1]; -+ break; -+ case LED_S0_OFF: -+ led_state&=~vdata[hfc->vend_idx].led_bits[1]; - break; -- case HFCUSB_B2_TX: -- if (fifo->hfc->regd.bsk[1]) -- fifo->buff = *fifo->hfc->regd.bsk[1]; /* B2-channel tx buffer */ -+ case LED_B1_ON: -+ hfc->led_b_active|=1; - break; -- case HFCUSB_D_TX: -- if (fifo->hfc->regd.dsq) -- fifo->buff = skb_dequeue(fifo->hfc->regd.dsq); /* D-channel tx queue */ -+ case LED_B1_OFF: -+ hfc->led_b_active&=~1; - break; -- default: -- return; /* error, invalid fifo */ -+ case LED_B1_DATA: -+ hfc->led_new_data|=1; -+ break; -+ case LED_B2_ON: -+ hfc->led_b_active|=2; -+ break; -+ case LED_B2_OFF: -+ hfc->led_b_active&=~2; -+ break; -+ case LED_B2_DATA: -+ hfc->led_new_data|=2; -+ break; -+ } -+ -+ write_led(hfc,led_state); -+} -+ -+/********************************/ -+/* called when timer t3 expires */ -+/********************************/ -+static void l1_timer_expire_t3(hfcusb_data * hfc) -+{ -+ //printk (KERN_INFO "HFC-USB: l1_timer_expire_t3\n"); -+ -+ hfc->d_if.ifc.l1l2(&hfc->d_if.ifc,PH_DEACTIVATE | INDICATION,NULL); -+#ifdef VERBOSE_USB_DEBUG -+ printk(KERN_INFO "PH_DEACTIVATE | INDICATION sent\n"); -+#endif -+ hfc->l1_activated=FALSE; -+ handle_led(hfc,LED_S0_OFF); -+} -+ -+/********************************/ -+/* called when timer t4 expires */ -+/********************************/ -+static void l1_timer_expire_t4(hfcusb_data * hfc) -+{ -+ //printk (KERN_INFO "HFC-USB: l1_timer_expire_t4\n"); -+ -+ hfc->d_if.ifc.l1l2(&hfc->d_if.ifc,PH_DEACTIVATE | INDICATION,NULL); -+#ifdef VERBOSE_USB_DEBUG -+ printk(KERN_INFO "PH_DEACTIVATE | INDICATION sent\n"); -+#endif -+ hfc->l1_activated=FALSE; -+ handle_led(hfc,LED_S0_OFF); -+} -+ -+/*****************************/ -+/* handle S0 state changes */ -+/*****************************/ -+static void state_handler(hfcusb_data * hfc,__u8 state) -+{ -+ __u8 old_state; -+ -+ old_state=hfc->l1_state; -+ -+ // range check -+ if(state==old_state || state<1 || state>8) return; -+ -+#ifdef VERBOSE_ISDN_DEBUG -+ printk(KERN_INFO "HFC-USB: new S0 state:%d old_state:%d\n",state,old_state); -+#endif -+ -+ if(state<4 || state==7 || state==8) -+ { -+ if(timer_pending(&hfc->t3_timer)) del_timer(&hfc->t3_timer); -+ //printk(KERN_INFO "HFC-USB: T3 deactivated\n"); -+ } -+ -+ if(state>=7) -+ { -+ if(timer_pending(&hfc->t4_timer)) del_timer(&hfc->t4_timer); -+ //printk(KERN_INFO "HFC-USB: T4 deactivated\n"); -+ } -+ -+ if(state==7 && !hfc->l1_activated) -+ { -+ hfc->d_if.ifc.l1l2(&hfc->d_if.ifc,PH_ACTIVATE | INDICATION,NULL); -+ //printk(KERN_INFO "HFC-USB: PH_ACTIVATE | INDICATION sent\n"); -+ hfc->l1_activated=TRUE; -+ handle_led(hfc,LED_S0_ON); -+ } -+ else -+ if(state<=3 /* && activated*/) -+ { -+ if(old_state==7 || old_state==8) -+ { -+ //printk(KERN_INFO "HFC-USB: T4 activated\n"); -+ hfc->t4_timer.expires = jiffies + (HFC_TIMER_T4 * HZ) / 1000; -+ if(!timer_pending(&hfc->t4_timer)) add_timer(&hfc->t4_timer); - } -- if (!fifo->buff) { -- fifo->active = 0; /* we are inactive now */ -- fifo->hfc->active_fifos &= ~fifo->fifo_mask; -- if (fifo->fifonum == HFCUSB_D_TX) { -- test_and_set_bit(HFCUSB_L1_DTX, -- &fifo->hfc->l1_event); -- queue_task(&fifo->hfc->l1_tq, -- &tq_immediate); -- mark_bh(IMMEDIATE_BH); -- } -- return; -+ else -+ { -+ hfc->d_if.ifc.l1l2(&hfc->d_if.ifc,PH_DEACTIVATE | INDICATION,NULL); -+ //printk(KERN_INFO "HFC-USB: PH_DEACTIVATE | INDICATION sent\n"); -+ hfc->l1_activated=FALSE; -+ handle_led(hfc,LED_S0_OFF); - } -- fifo->act_ptr = fifo->buff->data; /* start of data */ -- fifo->active = 1; -- ii = 1; -- fifo->hfc->active_fifos |= fifo->fifo_mask; -- fifo->hfc->service_request &= ~fifo->fifo_mask; -- } -- /* fillup the send buffer */ -- i = fifo->buff->len - (fifo->act_ptr - fifo->buff->data); /* remaining length */ -- fifo->buffer[0] = !fifo->transmode; /* not eof */ -- if (i > (fifo->usb_maxlen - ii)) { -- i = fifo->usb_maxlen - ii; -- } -- if (i) -- memcpy(fifo->buffer + ii, fifo->act_ptr, i); -- fifo->urb.transfer_buffer_length = i + ii; -- fifo->rx_offset = ii; --} /* fill_tx_urb */ -- --/************************************************/ --/* transmit completion routine for all tx fifos */ --/************************************************/ --static void --tx_complete(purb_t urb) -+ } -+ -+ hfc->l1_state=state; -+} -+ -+ -+/* prepare iso urb */ -+static void fill_isoc_urb(struct urb *urb, struct usb_device *dev, unsigned int pipe, void *buf, -+ int num_packets, int packet_size, int interval, usb_complete_t complete, void *context) - { -- usb_fifo *fifo = (usb_fifo *) urb->context; /* pointer to our fifo */ -+ int k; - -- fifo->hfc->service_request &= ~fifo->fifo_mask; /* no further handling */ -- fifo->framenum = usb_get_current_frame_number(fifo->hfc->dev); -+ spin_lock_init(&urb->lock); // do we really need spin_lock_init ? -+ urb->dev = dev; -+ urb->pipe = pipe; -+ urb->complete = complete; -+ urb->number_of_packets = num_packets; -+ urb->transfer_buffer_length = packet_size * num_packets; -+ urb->context = context; -+ urb->transfer_buffer = buf; -+ urb->transfer_flags = 0; -+ urb->transfer_flags = USB_ISO_ASAP; -+ urb->actual_length = 0; -+ urb->interval = interval; -+ for (k = 0; k < num_packets; k++) { -+ urb->iso_frame_desc[k].offset = packet_size * k; -+ urb->iso_frame_desc[k].length = packet_size; -+ urb->iso_frame_desc[k].actual_length = 0; -+ } -+} - -- /* check for deactivation or error */ -- if ((!fifo->active) || (urb->status)) { -- fifo->hfc->active_fifos &= ~fifo->fifo_mask; /* we are inactive */ -- fifo->active = 0; -- if ((fifo->buff) && (fifo->fifonum == HFCUSB_D_TX)) { -- dev_kfree_skb_any(fifo->buff); -+/* allocs urbs and start isoc transfer with two pending urbs to avoid gaps in the transfer chain */ -+static int start_isoc_chain(usb_fifo * fifo, int num_packets_per_urb,usb_complete_t complete,int packet_size) -+{ -+ int i, k, errcode; -+ -+#ifdef VERBOSE_USB_DEBUG -+ printk(KERN_INFO "HFC-USB: starting ISO-chain for Fifo %i\n", fifo->fifonum); -+#endif -+ -+ -+ // allocate Memory for Iso out Urbs -+ for (i = 0; i < 2; i++) { -+ if (!(fifo->iso[i].purb)) { -+ fifo->iso[i].purb = usb_alloc_urb(num_packets_per_urb); -+ fifo->iso[i].owner_fifo = (struct usb_fifo *) fifo; -+ -+ // Init the first iso -+ if (ISO_BUFFER_SIZE >= (fifo->usb_packet_maxlen * num_packets_per_urb)) -+ { -+ -+ fill_isoc_urb(fifo->iso[i].purb, fifo->hfc->dev, fifo->pipe, fifo->iso[i].buffer, -+ num_packets_per_urb, fifo->usb_packet_maxlen, fifo->intervall, -+ complete, &fifo->iso[i]); -+ -+ memset(fifo->iso[i].buffer, 0, sizeof(fifo->iso[i].buffer)); -+ -+ // defining packet delimeters in fifo->buffer -+ for(k = 0; k < num_packets_per_urb; k++) -+ { -+ fifo->iso[i].purb->iso_frame_desc[k].offset = k*packet_size; -+ fifo->iso[i].purb->iso_frame_desc[k].length = packet_size; -+ } -+ } - } -- fifo->buff = NULL; -- return; -+ -+ fifo->bit_line = BITLINE_INF; -+ -+ errcode = usb_submit_urb(fifo->iso[i].purb); -+ fifo->active = (errcode >= 0) ? 1 : 0; -+ if(errcode < 0) -+ { -+ printk(KERN_INFO "HFC-USB: error submitting ISO URB: %i.%i \n", errcode, i); -+ }; -+ - } -- fifo->act_ptr += (urb->transfer_buffer_length - fifo->rx_offset); /* adjust pointer */ -- fill_tx_urb(fifo); /* refill the urb */ -- fifo->hfc->threshold_mask |= fifo->fifo_mask; /* assume threshold reached */ -- if (fifo->buff) -- fifo->hfc->service_request |= fifo->fifo_mask; /* need to restart */ --} /* tx_complete */ - --/***********************************************/ --/* receive completion routine for all rx fifos */ --/***********************************************/ --static void --rx_complete(purb_t urb) -+ // errcode = (usb_submit_urb(fifo->iso[0].purb, GFP_KERNEL)); -+ return(fifo->active); -+} -+ -+/* stops running iso chain and frees their pending urbs */ -+static void stop_isoc_chain(usb_fifo * fifo) - { -- usb_fifo *fifo = (usb_fifo *) urb->context; /* pointer to our fifo */ -- hfcusb_data *hfc = fifo->hfc; -- usb_fifo *txfifo; -- __u8 last_state; -- int i, ii, currcnt, hdlci; -- struct sk_buff *skb; -- -- urb->dev = hfc->dev; /* security init */ -- if ((!fifo->active) || (urb->status)) { -- hfc->service_request &= ~fifo->fifo_mask; /* no further handling */ -- hfc->active_fifos &= ~fifo->fifo_mask; /* we are inactive */ -- fifo->urb.interval = 0; /* cancel automatic rescheduling */ -- if (fifo->buff) { -- dev_kfree_skb_any(fifo->buff); -- fifo->buff = NULL; -+ int i; -+ -+ for(i = 0; i < 2; i++) -+ { -+ if(fifo->iso[i].purb) -+ { -+#ifdef VERBOSE_USB_DEBUG -+ printk(KERN_INFO "HFC-USB: Stopping iso chain for fifo %i.%i\n", fifo->fifonum, i); -+#endif -+ usb_unlink_urb(fifo->iso[i].purb); -+ usb_free_urb(fifo->iso[i].purb); -+ fifo->iso[i].purb = NULL; - } -- return; - } -+ if (fifo->urb) { -+ usb_unlink_urb(fifo->urb); -+ usb_free_urb(fifo->urb); -+ fifo->urb = NULL; -+ } -+ fifo->active = 0; -+} - -- /* first check for any status changes */ -- if ((urb->actual_length < fifo->rx_offset) -- || (urb->actual_length > fifo->usb_maxlen)) -- return; /* error condition */ -- -- if (fifo->rx_offset) { -- hfc->threshold_mask = fifo->buffer[1]; /* update threshold status */ -- fifo->next_complete = fifo->buffer[0] & 1; -- if ((fifo->fifonum == HFCUSB_D_RX) && -- (hfc->led_req != hfc->led_act)) -- queue_control_request(hfc, HFCUSB_P_DATA, hfc->led_req); -- -- /* check if rescheduling needed */ -- if ((i = -- hfc->service_request & hfc->active_fifos & ~hfc-> -- threshold_mask)) { -- currcnt = -- usb_get_current_frame_number(hfc->dev); -- txfifo = hfc->fifos + HFCUSB_B1_TX; -- ii = 3; -- while (ii--) { -- if ((i & txfifo->fifo_mask) -- && (currcnt != txfifo->framenum)) { -- hfc->service_request &= -- ~txfifo->fifo_mask; -- if (!txfifo->buff) -- fill_tx_urb(txfifo); -- if (txfifo->buff) -- usb_submit_urb(&txfifo-> -- urb); -+// defines how much ISO packets are handled in one URB -+static int iso_packets[8]={ISOC_PACKETS_B,ISOC_PACKETS_B,ISOC_PACKETS_B,ISOC_PACKETS_B, -+ ISOC_PACKETS_D,ISOC_PACKETS_D,ISOC_PACKETS_D,ISOC_PACKETS_D}; -+ -+/*****************************************************/ -+/* transmit completion routine for all ISO tx fifos */ -+/*****************************************************/ -+static void tx_iso_complete(struct urb *urb) -+{ -+ iso_urb_struct *context_iso_urb = (iso_urb_struct *) urb->context; -+ usb_fifo *fifo = context_iso_urb->owner_fifo; -+ hfcusb_data *hfc = fifo->hfc; -+ int k, tx_offset, num_isoc_packets, sink, len, current_len,errcode,frame_complete,transp_mode,fifon; -+ __u8 threshbit; -+ __u8 threshtable[8] = { 1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; -+ -+ fifon=fifo->fifonum; -+ tx_offset=0; -+ // very weird error code when using ohci drivers, for now : ignore this error ... (MB) -+ if(urb->status == -EOVERFLOW) -+ { -+ urb->status = 0; -+#ifdef VERBOSE_USB_DEBUG -+ printk(KERN_INFO "HFC-USB: ignoring USB DATAOVERRUN for fifo %i \n",fifon); -+#endif -+ } -+ -+ if(fifo->active && !urb->status) -+ { -+ transp_mode=0; -+ if(fifon<4 && hfc->b_mode[fifon/2]==L1_MODE_TRANS) transp_mode=TRUE; -+ -+ threshbit = threshtable[fifon] & hfc->threshold_mask; // is threshold set for our channel? -+ num_isoc_packets=iso_packets[fifon]; -+ -+ if(fifon >= HFCUSB_D_TX) -+ { -+ sink = (threshbit) ? SINK_DMIN : SINK_DMAX; // how much bit go to the sink for D-channel? -+ } -+ else -+ { -+ sink = (threshbit) ? SINK_MIN : SINK_MAX; // how much bit go to the sink for B-channel? -+ } -+ -+ // prepare ISO Urb -+ fill_isoc_urb(urb, fifo->hfc->dev, fifo->pipe,context_iso_urb->buffer, num_isoc_packets, -+ fifo->usb_packet_maxlen, fifo->intervall, tx_iso_complete, urb->context); -+ memset(context_iso_urb->buffer, 0, sizeof(context_iso_urb->buffer)); -+ -+ frame_complete=FALSE; -+ -+ // Generate Iso Packets -+ for(k = 0; k < num_isoc_packets; ++k) -+ { -+ if(fifo->skbuff) -+ { -+ len = fifo->skbuff->len; // remaining length -+ -+ fifo->bit_line -= sink; // we lower data margin every msec -+ current_len = (0 - fifo->bit_line) / 8; -+ if(current_len > 14) current_len = 14; // maximum 15 byte for every ISO packet makes our life easier -+ current_len = (len <= current_len) ? len : current_len; -+ fifo->bit_line += current_len * 8; // how much bit do we put on the line? -+ -+ context_iso_urb->buffer[tx_offset] = 0; -+ if(current_len == len) -+ { -+ if(!transp_mode) -+ { -+ context_iso_urb->buffer[tx_offset] = 1; // here frame completion -+ fifo->bit_line += 32; // add 2 byte flags and 16bit CRC at end of ISDN frame -+ } -+ frame_complete = TRUE; -+ } -+ -+ // copy bytes from buffer into ISO_URB -+ memcpy(context_iso_urb->buffer+tx_offset+1,fifo->skbuff->data,current_len); -+ skb_pull(fifo->skbuff,current_len); -+ -+ // define packet delimeters within the URB buffer -+ urb->iso_frame_desc[k].offset = tx_offset; -+ urb->iso_frame_desc[k].length = current_len + 1; -+ -+ tx_offset += (current_len + 1); -+ // printk(KERN_INFO "HFC-USB: fifonum:%d,%d bytes to send, %d bytes ISO packet,bitline:%d,sink:%d,threshbit:%d,threshmask:%x\n",fifon,len,current_len,fifo->bit_line,sink,threshbit,hfc->threshold_mask); -+ if(!transp_mode) -+ { -+ if(fifon==HFCUSB_B1_TX) handle_led(hfc,LED_B1_DATA); -+ if(fifon==HFCUSB_B2_TX) handle_led(hfc,LED_B2_DATA); -+ } -+ } -+ else -+ { -+ // we have no more data - generate 1 byte ISO packets -+ urb->iso_frame_desc[k].offset = tx_offset++; -+ -+ urb->iso_frame_desc[k].length = 1; -+ fifo->bit_line -= sink; // we lower data margin every msec -+ -+ if(fifo->bit_line < BITLINE_INF) -+ { -+ fifo->bit_line = BITLINE_INF; -+ //printk (KERN_INFO "HFC-USB: BITLINE_INF underrun\n"); - } -- txfifo += 2; - } -- } - -- /* handle l1 events */ -- if ((fifo->buffer[0] >> 4) != hfc->l1_state) { -- last_state = hfc->l1_state; -- hfc->l1_state = fifo->buffer[0] >> 4; /* update status */ -- if (timer_pending(&hfc->t4_timer)) -- del_timer(&hfc->t4_timer); -- if (((hfc->l1_state == 3) && -- ((last_state == 7) || -- (last_state == 8))) || -- ((timer_pending(&hfc->t3_timer) && -- (hfc->l1_state == 8)))) { -- hfc->t4_timer.expires = jiffies + 2; -- add_timer(&hfc->t4_timer); -- } else { -- if (timer_pending(&hfc->t3_timer) -- && (hfc->l1_state == 7)) -- del_timer(&hfc->t3_timer); /* no longer needed */ -- test_and_set_bit(HFCUSB_L1_STATECHANGE, -- &hfc->l1_event); -- queue_task(&hfc->l1_tq, &tq_immediate); -- mark_bh(IMMEDIATE_BH); -+ if(frame_complete) -+ { -+ // delete the buffer only once, here or in hfc_usb_l2l1() in a PH_DATA|REQUEST -+ fifo->delete_flg=TRUE; -+ -+ fifo->hif->l1l2(fifo->hif,PH_DATA|CONFIRM,(void*)fifo->skbuff->truesize); -+ -+ if(fifo->skbuff && fifo->delete_flg) -+ { -+ dev_kfree_skb_any(fifo->skbuff); -+ //printk(KERN_INFO "HFC-USB: skbuff=NULL on fifo:%d\n",fifo->fifonum); -+ fifo->skbuff = NULL; -+ fifo->delete_flg=FALSE; -+ } -+ -+ frame_complete=FALSE; - } -+ } -+ -+ errcode = usb_submit_urb(urb); -+ if(errcode < 0) -+ { -+ printk(KERN_INFO "HFC-USB: error submitting ISO URB: %i \n", errcode); -+ } -+ } -+ else -+ { -+ if(urb->status) -+ { -+ printk(KERN_INFO "HFC-USB: tx_iso_complete : urb->status %i, fifonum %i\n", urb->status,fifon); - } - } - -- /* check the length for data and move if present */ -- if (fifo->next_complete || (urb->actual_length > fifo->rx_offset)) { -- i = fifo->buff->len + urb->actual_length - fifo->rx_offset; /* new total length */ -- hdlci = (fifo->transmode) ? 0 : 3; -- if (i <= (fifo->max_size + hdlci)) { -- memcpy(fifo->act_ptr, -- fifo->buffer + fifo->rx_offset, -- urb->actual_length - fifo->rx_offset); -- fifo->act_ptr += -- (urb->actual_length - fifo->rx_offset); -- fifo->buff->len += -- (urb->actual_length - fifo->rx_offset); -- } else -- fifo->buff->len = fifo->max_size + 4; /* mark frame as to long */ -- if (fifo->next_complete && (urb->actual_length < fifo->usb_maxlen)) { -- /* the frame is complete */ -- fifo->next_complete = 0; -- if (((!*(fifo->act_ptr - 1)) || fifo->transmode) && -- (fifo->buff->len >= (hdlci + 1)) -- && (fifo->buff->len <= -- (fifo->max_size + hdlci)) && -- ((skb = dev_alloc_skb(fifo->max_size + hdlci)) != NULL)) { -- fifo->buff->len -= hdlci; /* adjust size */ -- switch (fifo->fifonum) { -- case HFCUSB_D_RX: -- skb_queue_tail(hfc->regd. -- drq, -- fifo->buff); -- test_and_set_bit -- (HFCUSB_L1_DRX, -- &hfc->l1_event); -- queue_task(&hfc->l1_tq, -- &tq_immediate); -- mark_bh(IMMEDIATE_BH); -- break; -+} /* tx_iso_complete */ - -- case HFCUSB_B1_RX: -- if (hfc->regd.brq[0]) { -- skb_queue_tail -- (hfc->regd. -- brq[0], -- fifo->buff); -- hfc->regd. -- bch_l1l2(hfc-> -- regd. -- arg_hisax, -- 0, -- PH_DATA -- | -- INDICATION, -- (void *) -- fifo-> -- buff); -- } else -- dev_kfree_skb_any -- (fifo->buff); -- break; -- -- case HFCUSB_B2_RX: -- if (hfc->regd.brq[1]) { -- skb_queue_tail -- (hfc->regd. -- brq[1], -- fifo->buff); -- hfc->regd. -- bch_l1l2(hfc-> -- regd. -- arg_hisax, -- 1, -- PH_DATA -- | -- INDICATION, -- (void -- *) -- fifo-> -- buff); -- } else -- dev_kfree_skb_any -- (fifo->buff); -- break; -+/*****************************************************/ -+/* receive completion routine for all ISO tx fifos */ -+/*****************************************************/ -+static void rx_iso_complete(struct urb *urb) -+{ -+ iso_urb_struct *context_iso_urb = (iso_urb_struct *) urb->context; -+ usb_fifo *fifo = context_iso_urb->owner_fifo; -+ hfcusb_data *hfc = fifo->hfc; -+ int k, len, errcode, offset, num_isoc_packets,fifon; -+ __u8 *buf; - -- case HFCUSB_PCM_RX: -- skb_queue_tail(&hfc->regd. -- erq, -- fifo->buff); -- test_and_set_bit -- (HFCUSB_L1_ERX, -- &hfc->l1_event); -- queue_task(&hfc->l1_tq, -- &tq_immediate); -- mark_bh(IMMEDIATE_BH); -- break; -+ fifon=fifo->fifonum; -+ // very weird error code when using ohci drivers, for now : ignore this error ... (MB) -+ if(urb->status == -EOVERFLOW) -+ { -+ urb->status = 0; -+#ifdef VERBOSE_USB_DEBUG -+ printk(KERN_INFO "HFC-USB: ignoring USB DATAOVERRUN for fifo %i \n",fifon); -+#endif -+ } - -- default: -- dev_kfree_skb_any(fifo-> -- buff); -- break; -+ if(fifo->active && !urb->status) -+ { -+ num_isoc_packets=iso_packets[fifon]; -+ -+ // Generate D-Channel Iso Packets -+ for(k = 0; k < num_isoc_packets; ++k) -+ { -+ len=urb->iso_frame_desc[k].actual_length; -+ offset=urb->iso_frame_desc[k].offset; -+ buf=context_iso_urb->buffer+offset; -+ -+ if(fifo->last_urblen!=fifo->usb_packet_maxlen) -+ { -+ // the threshold mask is in the 2nd status byte -+ hfc->threshold_mask=buf[1]; -+ // the S0 state is in the upper half of the 1st status byte -+ state_handler(hfc,buf[0] >> 4); -+ // if we have more than the 2 status bytes -> collect data -+ if(len>2) collect_rx_frame(fifo,buf+2,len-2,buf[0]&1); - } -- fifo->buff = skb; -- } -- fifo->buff->len = 0; /* reset counter */ -- fifo->act_ptr = fifo->buff->data; /* and pointer */ -+ else collect_rx_frame(fifo,buf,len,0); -+ -+ fifo->last_urblen=len; -+ -+ } -+ -+ // prepare ISO Urb -+ fill_isoc_urb(urb, fifo->hfc->dev, fifo->pipe,context_iso_urb->buffer, num_isoc_packets, -+ fifo->usb_packet_maxlen, fifo->intervall, rx_iso_complete, urb->context); -+ -+ errcode = usb_submit_urb(urb); -+ if(errcode < 0) -+ { -+ printk(KERN_INFO "HFC-USB: error submitting ISO URB: %i \n", errcode); -+ } -+ } -+ else -+ { -+ if(urb->status) -+ { -+ printk(KERN_INFO "HFC-USB: rx_iso_complete : urb->status %i, fifonum %i\n", urb->status,fifon); -+ } -+ } -+} /* rx_iso_complete */ -+ -+ -+/*****************************************************/ -+/* collect data from interrupt or isochron in */ -+/*****************************************************/ -+static void collect_rx_frame(usb_fifo *fifo,__u8 *data,int len,int finish) -+{ -+ hfcusb_data *hfc = fifo->hfc; -+ int transp_mode,fifon; -+ -+ fifon=fifo->fifonum; -+ transp_mode=0; -+ if(fifon<4 && hfc->b_mode[fifon/2]==L1_MODE_TRANS) transp_mode=TRUE; -+ -+ //printk(KERN_INFO "HFC-USB: got %d bytes finish:%d max_size:%d fifo:%d\n",len,finish,fifo->max_size,fifon); -+ if(!fifo->skbuff) -+ { -+ // allocate sk buffer -+ fifo->skbuff=dev_alloc_skb(fifo->max_size + 3); -+ if(!fifo->skbuff) -+ { -+ printk(KERN_INFO "HFC-USB: cannot allocate buffer (dev_alloc_skb) fifo:%d\n",fifon); -+ return; -+ } -+ -+ } -+ -+ if(len && fifo->skbuff->len+len<fifo->max_size) -+ { -+ memcpy(skb_put(fifo->skbuff,len),data,len); -+ } -+ else printk(KERN_INFO "HCF-USB: got frame exceeded fifo->max_size:%d\n",fifo->max_size); -+ -+ // give transparent data up, when 128 byte are available -+ if(transp_mode && fifo->skbuff->len>=128) -+ { -+ fifo->hif->l1l2(fifo->hif,PH_DATA | INDICATION,fifo->skbuff); -+ fifo->skbuff = NULL; // buffer was freed from upper layer -+ return; -+ } -+ -+ // we have a complete hdlc packet -+ if(finish) -+ { -+ if(!fifo->skbuff->data[fifo->skbuff->len-1]) -+ { -+ skb_trim(fifo->skbuff,fifo->skbuff->len-3); // remove CRC & status -+ -+ //printk(KERN_INFO "HFC-USB: got frame %d bytes on fifo:%d\n",fifo->skbuff->len,fifon); -+ -+ if(fifon==HFCUSB_PCM_RX) fifo->hif->l1l2(fifo->hif,PH_DATA_E | INDICATION,fifo->skbuff); -+ else fifo->hif->l1l2(fifo->hif,PH_DATA | INDICATION,fifo->skbuff); -+ -+ fifo->skbuff = NULL; // buffer was freed from upper layer -+ } -+ else -+ { -+ printk(KERN_INFO "HFC-USB: got frame %d bytes but CRC ERROR!!!\n",fifo->skbuff->len); -+ -+ skb_trim(fifo->skbuff,0); // clear whole buffer -+ } -+ } -+ -+ // LED flashing only in HDLC mode -+ if(!transp_mode) -+ { -+ if(fifon==HFCUSB_B1_RX) handle_led(hfc,LED_B1_DATA); -+ if(fifon==HFCUSB_B2_RX) handle_led(hfc,LED_B2_DATA); -+ } -+} -+ -+/***********************************************/ -+/* receive completion routine for all rx fifos */ -+/***********************************************/ -+static void rx_complete(struct urb *urb) -+{ -+ int len; -+ __u8 *buf; -+ usb_fifo *fifo = (usb_fifo *) urb->context; /* pointer to our fifo */ -+ hfcusb_data *hfc = fifo->hfc; -+ -+ urb->dev = hfc->dev; /* security init */ -+ -+ if((!fifo->active) || (urb->status)) { -+#ifdef VERBOSE_USB_DEBUG -+ printk(KERN_INFO "HFC-USB: RX-Fifo %i is going down (%i)\n", fifo->fifonum, urb->status); -+#endif -+ fifo->urb->interval = 0; /* cancel automatic rescheduling */ -+ if(fifo->skbuff) { -+ dev_kfree_skb_any(fifo->skbuff); -+ fifo->skbuff = NULL; - } -+ return; - } -- fifo->rx_offset = (urb->actual_length < fifo->usb_maxlen) ? 2 : 0; --} /* rx_complete */ -+ -+ len=urb->actual_length; -+ buf=fifo->buffer; -+ -+ if(fifo->last_urblen!=fifo->usb_packet_maxlen) { -+ // the threshold mask is in the 2nd status byte -+ hfc->threshold_mask=buf[1]; -+ // the S0 state is in the upper half of the 1st status byte -+ state_handler(hfc,buf[0] >> 4); -+ // if we have more than the 2 status bytes -> collect data -+ if(len>2) collect_rx_frame(fifo,buf+2,urb->actual_length-2,buf[0]&1); -+ } else -+ collect_rx_frame(fifo,buf,urb->actual_length,0); -+ -+ fifo->last_urblen=urb->actual_length; -+ -+ -+} /* rx_complete */ -+ -+ - - /***************************************************/ - /* start the interrupt transfer for the given fifo */ - /***************************************************/ --static void --start_rx_fifo(usb_fifo * fifo) -+static void start_int_fifo(usb_fifo * fifo) - { -- if (fifo->buff) -- return; /* still active */ -- if (! -- (fifo->buff = -- dev_alloc_skb(fifo->max_size + (fifo->transmode ? 0 : 3)))) -- return; -- fifo->act_ptr = fifo->buff->data; -- FILL_INT_URB(&fifo->urb, fifo->hfc->dev, fifo->pipe, fifo->buffer, -- fifo->usb_maxlen, rx_complete, fifo, fifo->intervall); -- fifo->next_complete = 0; -- fifo->rx_offset = 2; -- fifo->active = 1; /* must be marked active */ -- fifo->hfc->active_fifos |= fifo->fifo_mask; -- if (usb_submit_urb(&fifo->urb)) { -+ int errcode; -+ -+#ifdef VERBOSE_USB_DEBUG -+ printk(KERN_INFO "HFC-USB: starting intr IN fifo:%d\n", fifo->fifonum); -+#endif -+ if (!fifo->urb) { -+ fifo->urb = usb_alloc_urb(0); -+ if (!fifo->urb) -+ return; -+ } -+ usb_fill_int_urb(fifo->urb, fifo->hfc->dev, fifo->pipe, fifo->buffer, -+ fifo->usb_packet_maxlen, rx_complete, fifo, fifo->intervall); -+ fifo->active = 1; /* must be marked active */ -+ errcode = usb_submit_urb(fifo->urb); -+ -+ if(errcode) -+ { -+ printk(KERN_INFO "HFC-USB: submit URB error(start_int_info): status:%i\n", errcode); - fifo->active = 0; -- fifo->hfc->active_fifos &= ~fifo->fifo_mask; -- dev_kfree_skb_any(fifo->buff); -- fifo->buff = NULL; -+ fifo->skbuff = NULL; - } --} /* start_rx_fifo */ -+} /* start_int_fifo */ - --/***************************************************************/ --/* control completion routine handling background control cmds */ --/***************************************************************/ --static void --ctrl_complete(purb_t urb) -+/*****************************/ -+/* set the B-channel mode */ -+/*****************************/ -+static void set_hfcmode(hfcusb_data *hfc,int channel,int mode) - { -- hfcusb_data *hfc = (hfcusb_data *) urb->context; -+ __u8 val,idx_table[2]={0,2}; - -- urb->dev = hfc->dev; -- if (hfc->ctrl_cnt) { -- switch (hfc->ctrl_buff[hfc->ctrl_out_idx].hfc_reg) { -- case HFCUSB_FIFO: -- hfc->ctrl_fifo = -- hfc->ctrl_buff[hfc->ctrl_out_idx]. -- reg_val; -- break; -- case HFCUSB_F_USAGE: -- if (!hfc->dfifo_fill) { -- fill_tx_urb(hfc->fifos + -- HFCUSB_D_TX); -- if (hfc->fifos[HFCUSB_D_TX].buff) -- usb_submit_urb(&hfc-> -- fifos -- [HFCUSB_D_TX]. -- urb); -- } else { -- queue_control_request(hfc, -- HFCUSB_FIFO, -- HFCUSB_D_TX); -- queue_control_request(hfc, -- HFCUSB_F_USAGE, -- 0); -- } -- break; -- case HFCUSB_SCTRL_R: -- switch (hfc->ctrl_fifo) { -- case HFCUSB_B1_RX: -- if (hfc->bch_enables & 1) -- start_rx_fifo(hfc-> -- fifos -- + -- HFCUSB_B1_RX); -- break; -- case HFCUSB_B2_RX: -- if (hfc->bch_enables & 2) -- start_rx_fifo(hfc-> -- fifos -- + -- HFCUSB_B2_RX); -- break; -- } -- if (hfc->bch_enables & 3) -- hfc->led_req |= LED_BCH; -- else -- hfc->led_req &= ~LED_BCH; -- break; -- case HFCUSB_P_DATA: -- hfc->led_act = -- hfc->ctrl_buff[hfc->ctrl_out_idx]. -- reg_val; -- break; -- } -- hfc->ctrl_cnt--; /* decrement actual count */ -- if (++hfc->ctrl_out_idx >= HFC_CTRL_BUFSIZE) -- hfc->ctrl_out_idx = 0; /* pointer wrap */ -- ctrl_start_transfer(hfc); /* start next transfer */ -+#ifdef VERBOSE_ISDN_DEBUG -+ printk (KERN_INFO "HFC-USB: setting channel %d to mode %d\n",channel,mode); -+#endif -+ -+ hfc->b_mode[channel]=mode; -+ -+ // setup CON_HDLC -+ val=0; -+ if(mode!=L1_MODE_NULL) val=8; // enable fifo? -+ if(mode==L1_MODE_TRANS) val|=2; // set transparent bit -+ -+ queue_control_request(hfc,HFCUSB_FIFO,idx_table[channel],1); // set FIFO to transmit register -+ queue_control_request(hfc,HFCUSB_CON_HDLC,val,1); -+ queue_control_request(hfc,HFCUSB_INC_RES_F,2,1); // reset fifo -+ -+ queue_control_request(hfc,HFCUSB_FIFO,idx_table[channel]+1,1); // set FIFO to receive register -+ queue_control_request(hfc,HFCUSB_CON_HDLC,val,1); -+ queue_control_request(hfc,HFCUSB_INC_RES_F,2,1); // reset fifo -+ -+ val=0x40; -+ if(hfc->b_mode[0]) val|=1; -+ if(hfc->b_mode[1]) val|=2; -+ queue_control_request(hfc,HFCUSB_SCTRL,val,1); -+ -+ val=0; -+ if(hfc->b_mode[0]) val|=1; -+ if(hfc->b_mode[1]) val|=2; -+ queue_control_request(hfc,HFCUSB_SCTRL_R,val,1); -+ -+ if(mode==L1_MODE_NULL) -+ { -+ if(channel) handle_led(hfc,LED_B2_OFF); -+ else handle_led(hfc,LED_B1_OFF); - } --} /* ctrl_complete */ -+ else -+ { -+ if(channel) handle_led(hfc,LED_B2_ON); -+ else handle_led(hfc,LED_B1_ON); -+ } -+} - --/*****************************************/ --/* Layer 1 + D channel access from HiSax */ --/*****************************************/ --static void --hfcusb_l1_access(void *drvarg, int pr, void *arg) --{ -- hfcusb_data *hfc = (hfcusb_data *) drvarg; -- -- switch (pr) { -- case (PH_DATA | REQUEST): -- case (PH_PULL | INDICATION): -- skb_queue_tail(hfc->regd.dsq, -- (struct sk_buff *) arg); -- if (!hfc->fifos[HFCUSB_D_TX].active -- && !hfc->dfifo_fill) { -- fill_tx_urb(hfc->fifos + HFCUSB_D_TX); -- hfc->active_fifos |= -- hfc->fifos[HFCUSB_D_TX].fifo_mask; -- usb_submit_urb(&hfc->fifos[HFCUSB_D_TX]. -- urb); -- } -- break; -- case (PH_ACTIVATE | REQUEST): -- switch (hfc->l1_state) { -- case 6: -- case 8: -- hfc->regd.dch_l1l2(hfc->regd.arg_hisax, -- (PH_DEACTIVATE | -- INDICATION), NULL); -+/* -+ -------------------------------------------------------------------------------------- -+ from here : hisax_if callback routines : -+ - void hfc_usb_d_l2l1(struct hisax_if *hisax_d_if, int pr, void *arg) { - -- break; -- case 7: -- hfc->regd.dch_l1l2(hfc->regd.arg_hisax, -- (PH_ACTIVATE | -- INDICATION), NULL); -+ l1 to l2 routines : -+ - static void hfc_usb_l1l2(hfcusb_data * hfc) - -- break; -- default: -- queue_control_request(hfc, HFCUSB_STATES, 0x60); /* start activation */ -- hfc->t3_timer.expires = -- jiffies + (HFC_TIMER_T3 * HZ) / 1000; -- if (!timer_pending(&hfc->t3_timer)) -- add_timer(&hfc->t3_timer); -- break; -- } -- break; -+*/ - -- case (PH_DEACTIVATE | REQUEST): -- queue_control_request(hfc, HFCUSB_STATES, 0x40); /* start deactivation */ -- break; -- default: -- printk(KERN_INFO "unknown hfcusb l1_access 0x%x\n", -- pr); -- break; -- } --} /* hfcusb_l1_access */ -- --/*******************************/ --/* B channel access from HiSax */ --/*******************************/ --static void --hfcusb_bch_access(void *drvarg, int chan, int pr, void *arg) --{ -- hfcusb_data *hfc = (hfcusb_data *) drvarg; -- usb_fifo *fifo = hfc->fifos + (chan ? HFCUSB_B2_TX : HFCUSB_B1_TX); -- long flags; -- -- switch (pr) { -- case (PH_DATA | REQUEST): -- case (PH_PULL | INDICATION): -- save_flags(flags); -- cli(); -- if (!fifo->active) { -- fill_tx_urb(fifo); -- hfc->active_fifos |= fifo->fifo_mask; -- usb_submit_urb(&fifo->urb); -- } -- restore_flags(flags); -- break; -- case (PH_ACTIVATE | REQUEST): -- if (!((int) arg)) { -- hfc->bch_enables &= ~(1 << chan); -- if (fifo->active) { -- fifo->active = 0; -- usb_unlink_urb(&fifo->urb); -+void hfc_usb_l2l1(struct hisax_if *my_hisax_if, int pr, void *arg) -+{ -+ usb_fifo *fifo = my_hisax_if->priv; -+ hfcusb_data *hfc = fifo->hfc; -+ -+ switch (pr) { -+ case PH_ACTIVATE | REQUEST: -+ if(fifo->fifonum==HFCUSB_D_TX) -+ { -+#ifdef VERBOSE_ISDN_DEBUG -+ printk (KERN_INFO "HFC_USB: hfc_usb_d_l2l1 D-chan: PH_ACTIVATE | REQUEST\n"); -+#endif -+ queue_control_request(hfc, HFCUSB_STATES,0x60,1); /* make activation */ -+ hfc->t3_timer.expires = jiffies + (HFC_TIMER_T3 * HZ) / 1000; -+ if(!timer_pending(&hfc->t3_timer)) add_timer(&hfc->t3_timer); - } -- save_flags(flags); -- cli(); -- queue_control_request(hfc, HFCUSB_FIFO, -- fifo->fifonum); -- queue_control_request(hfc, -- HFCUSB_INC_RES_F, 2); -- queue_control_request(hfc, HFCUSB_CON_HDLC, -- 9); -- queue_control_request(hfc, HFCUSB_SCTRL, -- 0x40 + -- hfc->bch_enables); -- queue_control_request(hfc, HFCUSB_SCTRL_R, -- hfc->bch_enables); -- restore_flags(flags); -- fifo++; -- if (fifo->active) { -- fifo->active = 0; -- usb_unlink_urb(&fifo->urb); -+ else -+ { -+#ifdef VERBOSE_ISDN_DEBUG -+ printk (KERN_INFO "HFC_USB: hfc_usb_d_l2l1 Bx-chan: PH_ACTIVATE | REQUEST\n"); -+#endif -+ set_hfcmode(hfc,(fifo->fifonum==HFCUSB_B1_TX) ? 0 : 1 ,(int)arg); -+ fifo->hif->l1l2(fifo->hif,PH_ACTIVATE | INDICATION, NULL); - } -- return; /* fifo deactivated */ -- } -- fifo->transmode = ((int) arg == L1_MODE_TRANS); -- fifo->max_size = -- ((fifo->transmode) ? fifo-> -- usb_maxlen : MAX_BCH_SIZE); -- (fifo + 1)->transmode = fifo->transmode; -- (fifo + 1)->max_size = fifo->max_size; -- hfc->bch_enables |= (1 << chan); -- save_flags(flags); -- cli(); -- queue_control_request(hfc, HFCUSB_FIFO, -- fifo->fifonum); -- queue_control_request(hfc, HFCUSB_CON_HDLC, -- ((!fifo-> -- transmode) ? 9 : 11)); -- queue_control_request(hfc, HFCUSB_INC_RES_F, 2); -- queue_control_request(hfc, HFCUSB_SCTRL, -- 0x40 + hfc->bch_enables); -- if ((int) arg == L1_MODE_HDLC) -- queue_control_request(hfc, HFCUSB_CON_HDLC, -- 8); -- queue_control_request(hfc, HFCUSB_FIFO, -- fifo->fifonum + 1); -- queue_control_request(hfc, HFCUSB_CON_HDLC, -- ((!fifo-> -- transmode) ? 8 : 10)); -- queue_control_request(hfc, HFCUSB_INC_RES_F, 2); -- queue_control_request(hfc, HFCUSB_SCTRL_R, -- hfc->bch_enables); -- restore_flags(flags); -- -- break; -- -- default: -- printk(KERN_INFO -- "unknown hfcusb bch_access chan %d 0x%x\n", -- chan, pr); -- break; -- } --} /* hfcusb_bch_access */ -+ break; -+ case PH_DEACTIVATE | REQUEST: -+ if(fifo->fifonum==HFCUSB_D_TX) -+ { -+#ifdef VERBOSE_ISDN_DEBUG -+ printk (KERN_INFO "HFC_USB: hfc_usb_d_l2l1 D-chan: PH_DEACTIVATE | REQUEST\n"); -+#endif -+ printk (KERN_INFO "HFC-USB: ISDN TE device should not deativate...\n"); -+ } -+ else -+ { -+#ifdef VERBOSE_ISDN_DEBUG -+ printk (KERN_INFO "HFC_USB: hfc_usb_d_l2l1 Bx-chan: PH_DEACTIVATE | REQUEST\n"); -+#endif -+ set_hfcmode(hfc,(fifo->fifonum==HFCUSB_B1_TX) ? 0 : 1 ,(int)L1_MODE_NULL); -+ fifo->hif->l1l2(fifo->hif,PH_DEACTIVATE | INDICATION, NULL); -+ } -+ break; -+ case PH_DATA | REQUEST: -+ if(fifo->skbuff && fifo->delete_flg) -+ { -+ dev_kfree_skb_any(fifo->skbuff); -+ //printk(KERN_INFO "skbuff=NULL on fifo:%d\n",fifo->fifonum); -+ fifo->skbuff = NULL; -+ fifo->delete_flg=FALSE; -+ } -+ -+ fifo->skbuff=arg; // we have a new buffer -+ -+ //if(fifo->fifonum==HFCUSB_D_TX) printk (KERN_INFO "HFC_USB: hfc_usb_d_l2l1 D-chan: PH_DATA | REQUEST\n"); -+ //else printk (KERN_INFO "HFC_USB: hfc_usb_d_l2l1 Bx-chan: PH_DATA | REQUEST\n"); -+ break; -+ default: -+ printk (KERN_INFO "HFC_USB: hfc_usb_d_l2l1: unkown state : %#x\n", pr); -+ break; -+ } -+} -+ -+// valid configurations -+#define CNF_4INT3ISO 1 // 4 INT IN, 3 ISO OUT -+#define CNF_3INT3ISO 2 // 3 INT IN, 3 ISO OUT -+#define CNF_4ISO3ISO 3 // 4 ISO IN, 3 ISO OUT -+#define CNF_3ISO3ISO 4 // 3 ISO IN, 3 ISO OUT -+ -+ -+/* -+ -------------------------------------------------------------------------------------- -+ From here on USB initialization and deactivation related routines are implemented : -+ -+ - hfc_usb_init : -+ is the main Entry Point for the USB Subsystem when the device get plugged -+ in. This function calls usb_register with usb_driver as parameter. -+ Here, further entry points for probing (hfc_usb_probe) and disconnecting -+ the device (hfc_usb_disconnect) are published, as the id_table -+ -+ - hfc_usb_probe -+ this function is called by the usb subsystem, and steps through the alternate -+ settings of the currently plugged in device to detect all Endpoints needed to -+ run an ISDN TA. -+ Needed EndPoints are -+ 3 (+1) IntIn EndPoints (D-in, E-in, B1-in, B2-in, (E-in)) or -+ 3 (+1) Isochron In Endpoints (D-out, B1-out, B2-out) and 3 IsoOut Endpoints -+ The currently used transfer mode of on the Out-Endpoints will be stored in -+ hfc->usb_transfer_mode and is either USB_INT or USB_ISO -+ When a valid alternate setting could be found, the usb_init (see blow) -+ function is called -+ -+ - usb_init -+ Here, the HFC_USB Chip itself gets initialized and the USB framework to send/receive -+ Data to/from the several EndPoints are initialized: -+ The E- and D-Channel Int-In chain gets started -+ The IsoChain for the Iso-Out traffic get started -+ -+ - hfc_usb_disconnect -+ this function is called by the usb subsystem and has to free all resources -+ and stop all usb traffic to allow a proper hotplugging disconnect. -+ -+*/ - - /***************************************************************************/ - /* usb_init is called once when a new matching device is detected to setup */ --/* main parmeters. It registers the driver at the main hisax module. */ -+/* main parameters. It registers the driver at the main hisax module. */ - /* on success 0 is returned. */ - /***************************************************************************/ --static int --usb_init(hfcusb_data * hfc) -+static int usb_init(hfcusb_data * hfc) - { - usb_fifo *fifo; -- int i; -+ int i, err; - u_char b; -- -+ struct hisax_b_if *p_b_if[2]; -+ - /* check the chip id */ -- if ((Read_hfc(hfc, HFCUSB_CHIP_ID, &b) != 1) || -- (b != HFCUSB_CHIPID)) { -+ printk(KERN_INFO "HFCUSB_CHIP_ID begin\n"); -+ if (read_usb(hfc, HFCUSB_CHIP_ID, &b) != 1) { -+ printk(KERN_INFO "HFC-USB: cannot read chip id\n"); -+ return(1); -+ } -+ printk(KERN_INFO "HFCUSB_CHIP_ID %x\n", b); -+ if (b != HFCUSB_CHIPID) { - printk(KERN_INFO "HFC-USB: Invalid chip id 0x%02x\n", b); -- return (1); -+ return(1); - } - - /* first set the needed config, interface and alternate */ -- usb_set_configuration(hfc->dev, 1); -- usb_set_interface(hfc->dev, hfc->if_used, hfc->alt_used); -+ printk(KERN_INFO "usb_init 1\n"); -+// usb_set_configuration(hfc->dev, 1); -+ printk(KERN_INFO "usb_init 2\n"); -+ err = usb_set_interface(hfc->dev, hfc->if_used, hfc->alt_used); -+ printk(KERN_INFO "usb_init usb_set_interface return %d\n", err); -+ /* now we initialize the chip */ -+ write_usb(hfc, HFCUSB_CIRM, 8); // do reset -+ write_usb(hfc, HFCUSB_CIRM, 0x10); // aux = output, reset off - -- /* init the led state request */ -- hfc->led_req = LED_DRIVER; -+ // set USB_SIZE to match the the wMaxPacketSize for INT or BULK transfers -+ write_usb(hfc, HFCUSB_USB_SIZE,(hfc->packet_size/8) | ((hfc->packet_size/8) << 4)); - -- /* now we initialise the chip */ -- Write_hfc(hfc, HFCUSB_CIRM, 0x10); /* aux = output, reset off */ -- Write_hfc(hfc, HFCUSB_P_DATA, 0); /* leds = off */ -- Write_hfc(hfc, HFCUSB_USB_SIZE, -- (hfc->fifos[HFCUSB_B1_TX].usb_maxlen >> 3) | -- ((hfc->fifos[HFCUSB_B1_RX].usb_maxlen >> 3) << 4)); -+ // set USB_SIZE_I to match the the wMaxPacketSize for ISO transfers -+ write_usb(hfc, HFCUSB_USB_SIZE_I, hfc->iso_packet_size); - - /* enable PCM/GCI master mode */ -- Write_hfc(hfc, HFCUSB_MST_MODE1, 0); /* set default values */ -- Write_hfc(hfc, HFCUSB_MST_MODE0, 1); /* enable master mode */ -+ write_usb(hfc, HFCUSB_MST_MODE1, 0); /* set default values */ -+ write_usb(hfc, HFCUSB_MST_MODE0, 1); /* enable master mode */ - - /* init the fifos */ -- Write_hfc(hfc, HFCUSB_F_THRES, (HFCUSB_TX_THRESHOLD >> 3) | -- ((HFCUSB_RX_THRESHOLD >> 3) << 4)); -+ write_usb(hfc, HFCUSB_F_THRES, (HFCUSB_TX_THRESHOLD/8) |((HFCUSB_RX_THRESHOLD/8) << 4)); - -- for (i = 0, fifo = hfc->fifos + i; i < HFCUSB_NUM_FIFOS; -- i++, fifo++) { -- Write_hfc(hfc, HFCUSB_FIFO, i); /* select the desired fifo */ -- -- fifo->transmode = 0; /* hdlc mode selected */ -- fifo->buff = NULL; /* init buffer pointer */ -- fifo->max_size = -- (i <= HFCUSB_B2_RX) ? MAX_BCH_SIZE : MAX_DFRAME_LEN; -- Write_hfc(hfc, HFCUSB_HDLC_PAR, ((i <= HFCUSB_B2_RX) ? 0 : 2)); /* data length */ -- Write_hfc(hfc, HFCUSB_CON_HDLC, ((i & 1) ? 0x08 : 0x09)); /* rx hdlc, tx fill 1 */ -- Write_hfc(hfc, HFCUSB_INC_RES_F, 2); /* reset the fifo */ -- } -- -- Write_hfc(hfc, HFCUSB_CLKDEL, 0x0f); /* clock delay value */ -- Write_hfc(hfc, HFCUSB_STATES, 3 | 0x10); /* set deactivated mode */ -- Write_hfc(hfc, HFCUSB_STATES, 3); /* enable state machine */ -+ fifo = hfc->fifos; -+ for(i = 0; i < HFCUSB_NUM_FIFOS; i++) -+ { -+ write_usb(hfc, HFCUSB_FIFO, i); /* select the desired fifo */ -+ fifo[i].skbuff = NULL; /* init buffer pointer */ -+ fifo[i].max_size = (i <= HFCUSB_B2_RX) ? MAX_BCH_SIZE : MAX_DFRAME_LEN; -+ fifo[i].last_urblen=0; -+ write_usb(hfc, HFCUSB_HDLC_PAR, ((i <= HFCUSB_B2_RX) ? 0 : 2)); // set 2 bit for D- & E-channel -+ write_usb(hfc, HFCUSB_CON_HDLC, ((i==HFCUSB_D_TX) ? 0x09 : 0x08)); // rx hdlc, enable IFF for D-channel -+ write_usb(hfc, HFCUSB_INC_RES_F, 2); /* reset the fifo */ -+ } - -- Write_hfc(hfc, HFCUSB_SCTRL_R, 0); /* disable both B receivers */ -- Write_hfc(hfc, HFCUSB_SCTRL, 0x40); /* disable B transmitters + cap mode */ -+ write_usb(hfc, HFCUSB_CLKDEL, 0x0f); /* clock delay value */ -+ write_usb(hfc, HFCUSB_STATES, 3 | 0x10); /* set deactivated mode */ -+ write_usb(hfc, HFCUSB_STATES, 3); /* enable state machine */ -+ -+ write_usb(hfc, HFCUSB_SCTRL_R, 0); /* disable both B receivers */ -+ write_usb(hfc, HFCUSB_SCTRL, 0x40); /* disable B transmitters + capacitive mode */ -+ -+ // set both B-channel to not connected -+ hfc->b_mode[0]=L1_MODE_NULL; -+ hfc->b_mode[1]=L1_MODE_NULL; -+ -+ hfc->l1_activated=FALSE; -+ hfc->led_state=0; -+ hfc->led_new_data=0; - -- /* init the l1 timer */ -+ /* init the t3 timer */ - init_timer(&hfc->t3_timer); - hfc->t3_timer.data = (long) hfc; -- hfc->t3_timer.function = (void *) l1_timer_expire; -+ hfc->t3_timer.function = (void *) l1_timer_expire_t3; -+ /* init the t4 timer */ -+ init_timer(&hfc->t4_timer); - hfc->t4_timer.data = (long) hfc; -- hfc->t4_timer.function = (void *) l1_timer_expire; -- hfc->l1_tq.routine = (void *) (void *) usb_l1d_bh; -- hfc->l1_tq.sync = 0; -- hfc->l1_tq.data = hfc; -- -- /* init the background control machinery */ -- hfc->ctrl_read.requesttype = 0xc0; -- hfc->ctrl_read.request = 1; -- hfc->ctrl_read.length = 1; -- hfc->ctrl_write.requesttype = 0x40; -- hfc->ctrl_write.request = 0; -- hfc->ctrl_write.length = 0; -- FILL_CONTROL_URB(&hfc->ctrl_urb, hfc->dev, hfc->ctrl_out_pipe, -- (u_char *) & hfc->ctrl_write, NULL, 0, -- ctrl_complete, hfc); -- -- /* init the TX-urbs */ -- fifo = hfc->fifos + HFCUSB_D_TX; -- FILL_BULK_URB(&fifo->urb, hfc->dev, fifo->pipe, -- (u_char *) fifo->buffer, 0, tx_complete, fifo); -- fifo = hfc->fifos + HFCUSB_B1_TX; -- FILL_BULK_URB(&fifo->urb, hfc->dev, fifo->pipe, -- (u_char *) fifo->buffer, 0, tx_complete, fifo); -- fifo = hfc->fifos + HFCUSB_B2_TX; -- FILL_BULK_URB(&fifo->urb, hfc->dev, fifo->pipe, -- (u_char *) fifo->buffer, 0, tx_complete, fifo); -- -- /* init the E-buffer */ -- skb_queue_head_init(&hfc->regd.erq); -- -- /* now register ourself at hisax */ -- hfc->regd.version = HISAX_LOAD_VERSION; /* set our version */ -- hfc->regd.cmd = HISAX_LOAD_REGISTER; /* register command */ -- hfc->regd.argl1 = (void *) hfc; /* argument for our local routine */ -- hfc->regd.dch_l2l1 = hfcusb_l1_access; -- hfc->regd.bch_l2l1 = hfcusb_bch_access; -- hfc->regd.drvname = "hfc_usb"; -- if (hisax_register_hfcusb(&hfc->regd)) { -- printk(KERN_INFO "HFC-USB failed to register at hisax\n"); -- Write_hfc(hfc, HFCUSB_CIRM, 0x08); /* aux = input, reset on */ -- return (1); -- } -- -- /* startup the D- and E-channel fifos */ -- start_rx_fifo(hfc->fifos + HFCUSB_D_RX); /* D-fifo */ -- if (hfc->fifos[HFCUSB_PCM_RX].pipe) -- start_rx_fifo(hfc->fifos + HFCUSB_PCM_RX); /* E-fifo */ -+ hfc->t4_timer.function = (void *) l1_timer_expire_t4; -+ /* init the led timer */ -+ init_timer(&hfc->led_timer); -+ hfc->led_timer.data = (long) hfc; -+ hfc->led_timer.function = (void *) led_timer; -+ // trigger 4 hz led timer -+ hfc->led_timer.expires = jiffies + (LED_TIME * HZ) / 1000; -+ if(!timer_pending(&hfc->led_timer)) add_timer(&hfc->led_timer); -+ -+ // init the background machinery for control requests -+ hfc->ctrl_read.bRequestType = 0xc0; -+ hfc->ctrl_read.bRequest = 1; -+ hfc->ctrl_read.wLength = 1; -+ hfc->ctrl_write.bRequestType = 0x40; -+ hfc->ctrl_write.bRequest = 0; -+ hfc->ctrl_write.wLength = 0; -+ usb_fill_control_urb(hfc->ctrl_urb, hfc->dev, hfc->ctrl_out_pipe,(u_char *) & hfc->ctrl_write, NULL, 0, ctrl_complete, hfc); -+ -+ /* Init All Fifos */ -+ for(i = 0; i < HFCUSB_NUM_FIFOS; i++) -+ { -+ hfc->fifos[i].iso[0].purb = NULL; -+ hfc->fifos[i].iso[1].purb = NULL; -+ hfc->fifos[i].active = 0; -+ } -+ -+ // register like Germaschewski : -+ hfc->d_if.owner = THIS_MODULE; -+ hfc->d_if.ifc.priv = &hfc->fifos[HFCUSB_D_TX]; -+ hfc->d_if.ifc.l2l1 = hfc_usb_l2l1; -+ -+ for (i=0; i<2; i++) -+ { -+ hfc->b_if[i].ifc.priv = &hfc->fifos[HFCUSB_B1_TX+i*2]; -+ hfc->b_if[i].ifc.l2l1 = hfc_usb_l2l1; -+ p_b_if[i] = &hfc->b_if[i]; -+ } -+ -+ hfc->protocol = 2; /* default EURO ISDN, should be a module_param */ -+ hisax_register(&hfc->d_if, p_b_if, "hfc_usb", hfc->protocol); -+ -+ for (i=0; i<4; i++) -+ hfc->fifos[i].hif=&p_b_if[i/2]->ifc; -+ for (i=4; i<8; i++) -+ hfc->fifos[i].hif=&hfc->d_if.ifc; -+ -+ // 3 (+1) INT IN + 3 ISO OUT -+ if(hfc->cfg_used == CNF_3INT3ISO || hfc->cfg_used == CNF_4INT3ISO) -+ { -+ start_int_fifo(hfc->fifos + HFCUSB_D_RX); // Int IN D-fifo -+ if(hfc->fifos[HFCUSB_PCM_RX].pipe) start_int_fifo(hfc->fifos + HFCUSB_PCM_RX); // E-fifo -+ start_int_fifo(hfc->fifos + HFCUSB_B1_RX); // Int IN B1-fifo -+ start_int_fifo(hfc->fifos + HFCUSB_B2_RX); // Int IN B2-fifo -+ } -+ -+ // 3 (+1) ISO IN + 3 ISO OUT -+ if(hfc->cfg_used==CNF_3ISO3ISO || hfc->cfg_used==CNF_4ISO3ISO) -+ { -+ start_isoc_chain(hfc->fifos + HFCUSB_D_RX, ISOC_PACKETS_D, rx_iso_complete,16); -+ if(hfc->fifos[HFCUSB_PCM_RX].pipe) start_isoc_chain(hfc->fifos + HFCUSB_PCM_RX, ISOC_PACKETS_D, rx_iso_complete,16); -+ start_isoc_chain(hfc->fifos + HFCUSB_B1_RX, ISOC_PACKETS_B, rx_iso_complete,16); -+ start_isoc_chain(hfc->fifos + HFCUSB_B2_RX, ISOC_PACKETS_B, rx_iso_complete,16); -+ } -+ -+ start_isoc_chain(hfc->fifos + HFCUSB_D_TX, ISOC_PACKETS_D, tx_iso_complete,1); -+ start_isoc_chain(hfc->fifos + HFCUSB_B1_TX, ISOC_PACKETS_B, tx_iso_complete,1); -+ start_isoc_chain(hfc->fifos + HFCUSB_B2_TX, ISOC_PACKETS_B, tx_iso_complete,1); -+ -+ handle_led(hfc,LED_POWER_ON); -+ -+ return(0); -+} /* usb_init */ -+ -+ -+/****************************************/ -+/* data defining the devices to be used */ -+/****************************************/ -+// static __devinitdata const struct usb_device_id hfc_usb_idtab[3] = { -+static struct usb_device_id hfc_usb_idtab[] = { -+ {USB_DEVICE(0x7b0, 0x0007)}, /* Billion USB TA 2 */ -+ {USB_DEVICE(0x742, 0x2008)}, /* Stollmann USB TA */ -+ {USB_DEVICE(0x959, 0x2bd0)}, /* Colognechip USB eval TA */ -+ {USB_DEVICE(0x8e3, 0x0301)}, /* OliTec ISDN USB */ -+ {USB_DEVICE(0x675, 0x1688)}, /* DrayTec ISDN USB */ -+ {USB_DEVICE(0x7fa, 0x0846)}, /* Bewan ISDN USB TA */ -+ {} /* end with an all-zeroes entry */ -+}; -+ -+MODULE_AUTHOR("Peter Sprenger (sprenger@moving-byters.de)/Martin Bachem (info@colognechip.com)"); -+MODULE_DESCRIPTION("HFC I4L USB driver"); -+MODULE_DEVICE_TABLE(usb, hfc_usb_idtab); -+MODULE_LICENSE("GPL"); -+ -+#define EP_NUL 1 // Endpoint at this position not allowed -+#define EP_NOP 2 // all type of endpoints allowed at this position -+#define EP_ISO 3 // Isochron endpoint mandatory at this position -+#define EP_BLK 4 // Bulk endpoint mandatory at this position -+#define EP_INT 5 // Interrupt endpoint mandatory at this position -+ -+// this array represents all endpoints possible in the HCF-USB -+// the last 2 entries are the configuration number and the minimum interval for Interrupt endpoints -+int validconf[][18]= -+{ -+ // INT in, ISO out config -+ {EP_NUL,EP_INT,EP_NUL,EP_INT,EP_NUL,EP_INT,EP_NOP,EP_INT,EP_ISO,EP_NUL,EP_ISO,EP_NUL,EP_ISO,EP_NUL,EP_NUL,EP_NUL,CNF_4INT3ISO,2}, -+ {EP_NUL,EP_INT,EP_NUL,EP_INT,EP_NUL,EP_INT,EP_NUL,EP_NUL,EP_ISO,EP_NUL,EP_ISO,EP_NUL,EP_ISO,EP_NUL,EP_NUL,EP_NUL,CNF_3INT3ISO,2}, -+ // ISO in, ISO out config -+ {EP_NUL,EP_NUL,EP_NUL,EP_NUL,EP_NUL,EP_NUL,EP_NUL,EP_NUL,EP_ISO,EP_ISO,EP_ISO,EP_ISO,EP_ISO,EP_ISO,EP_NOP,EP_ISO,CNF_4ISO3ISO,2}, -+ {EP_NUL,EP_NUL,EP_NUL,EP_NUL,EP_NUL,EP_NUL,EP_NUL,EP_NUL,EP_ISO,EP_ISO,EP_ISO,EP_ISO,EP_ISO,EP_ISO,EP_NUL,EP_NUL,CNF_3ISO3ISO,2}, -+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} // EOL element -+}; -+ -+// string description of chosen config -+char *conf_str[]= -+{ -+ "4 Interrupt IN + 3 Isochron OUT", -+ "3 Interrupt IN + 3 Isochron OUT", -+ "4 Isochron IN + 3 Isochron OUT", -+ "3 Isochron IN + 3 Isochron OUT" -+}; - -- return (0); --} /* usb_init */ - - /*************************************************/ - /* function called to probe a new plugged device */ - /*************************************************/ --static void * --hfc_usb_probe(struct usb_device *dev, unsigned int interface --#ifdef COMPAT_HAS_USB_IDTAB -- , const struct usb_device_id *id_table) --#else -- ) --#endif -+//static int hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) -+static void* hfc_usb_probe(struct usb_device *dev, unsigned int ifnum, const struct usb_device_id *id) - { -+ //struct usb_device *dev= interface_to_usbdev(intf); -+ struct usb_interface* intf = dev->actconfig->interface + ifnum; - hfcusb_data *context; -- struct usb_interface *ifp = dev->actconfig->interface + interface; -- struct usb_interface_descriptor *ifdp = -- ifp->altsetting + ifp->act_altsetting; -- struct usb_endpoint_descriptor *epd; -- int i, idx, ep_msk; -- --#ifdef COMPAT_HAS_USB_IDTAB -- if (id_table && (dev->descriptor.idVendor == id_table->idVendor) && -- (dev->descriptor.idProduct == id_table->idProduct) && --#else -- if ((((dev->descriptor.idVendor == 0x959) && -- (dev->descriptor.idProduct == 0x2bd0)) || -- ((dev->descriptor.idVendor == 0x7b0) && -- (dev->descriptor.idProduct == 0x0006))) && --#endif -- (ifdp->bNumEndpoints >= 6) && (ifdp->bNumEndpoints <= 16)) { -- if (!(context = kmalloc(sizeof(hfcusb_data), GFP_KERNEL))) { -- return (NULL); /* got no mem */ -- }; -- memset(context, 0, sizeof(hfcusb_data)); /* clear the structure */ -- i = ifdp->bNumEndpoints; /* get number of endpoints */ -- ep_msk = 0; /* none found */ -- epd = ifdp->endpoint; /* first endpoint descriptor */ -- while (i-- && ((ep_msk & 0xcf) != 0xcf)) { -- -- idx = (((epd->bEndpointAddress & 0x7f) - 1) << 1); /* get endpoint base */ -- if (idx < 7) { -- switch (epd->bmAttributes) { -- case USB_ENDPOINT_XFER_INT: -- if (! -- (epd-> -- bEndpointAddress & -- 0x80)) -- break; /* only interrupt in allowed */ -- idx++; /* input index is odd */ -- context->fifos[idx].pipe = -- usb_rcvintpipe(dev, -- epd-> -- bEndpointAddress); -- break; -- -- case USB_ENDPOINT_XFER_BULK: -- if (epd-> -- bEndpointAddress & -- 0x80) -- break; /* only bulk out allowed */ -- context->fifos[idx].pipe = -- usb_sndbulkpipe(dev, -- epd-> -- bEndpointAddress); -- break; -- default: -- context->fifos[idx].pipe = 0; /* reset data */ -- } /* switch attribute */ -- -- if (context->fifos[idx].pipe) { -- context->fifos[idx].fifonum = idx; -- context->fifos[idx].fifo_mask = -- 1 << idx; -- context->fifos[idx].hfc = context; -- context->fifos[idx].usb_maxlen = -- epd->wMaxPacketSize; -- context->fifos[idx].intervall = -- epd->bInterval; -- ep_msk |= (1 << idx); -- } else -- ep_msk &= ~(1 << idx); -- } /* idx < 7 */ -- epd++; -- } -+ //struct usb_host_interface *iface = intf->cur_altsetting; -+ //struct usb_host_interface *iface_used = NULL; -+ //struct usb_host_endpoint *ep; -+ struct usb_endpoint_descriptor* ep; -+ //int ifnum = iface->desc.bInterfaceNumber; -+ struct usb_interface_descriptor* intfdesc = intf->altsetting + intf->act_altsetting; -+ struct usb_interface_descriptor* intfdesc_used = NULL; -+ int i, idx, alt_idx, probe_alt_setting, vend_idx, cfg_used, *vcf, attr, cfg_found, cidx, ep_addr; -+ int cmptbl[16],small_match,iso_packet_size,packet_size,alt_used=0; -+ -+// usb_show_device(dev); -+// usb_show_device_descriptor(&dev->descriptor); -+// usb_show_interface_descriptor(&iface->desc); -+ vend_idx=0xffff; -+ for(i=0;vdata[i].vendor;i++) -+ { -+ if(dev->descriptor.idVendor==vdata[i].vendor && dev->descriptor.idProduct==vdata[i].prod_id) vend_idx=i; -+ } -+ - -- if ((ep_msk & 0x3f) != 0x3f) { -- kfree(context); -- return (NULL); -- } -- MOD_INC_USE_COUNT; /* lock our module */ -- context->dev = dev; /* save device */ -- context->if_used = interface; /* save used interface */ -- context->alt_used = ifp->act_altsetting; /* and alternate config */ -- context->ctrl_paksize = dev->descriptor.bMaxPacketSize0; /* control size */ -- -- /* create the control pipes needed for register access */ -- context->ctrl_in_pipe = usb_rcvctrlpipe(context->dev, 0); -- context->ctrl_out_pipe = usb_sndctrlpipe(context->dev, 0); -- -- /* init the chip and register the driver */ -- if (usb_init(context)) { -- kfree(context); -- MOD_DEC_USE_COUNT; -- return (NULL); -- } -+#ifdef VERBOSE_USB_DEBUG -+ printk(KERN_INFO "HFC-USB: probing interface(%d) actalt(%d)\n", -+ ifnum, intfdesc->bAlternateSetting); -+ /* printk(KERN_INFO "HFC-USB: probing interface(%d) actalt(%d) minor(%d)\n", -+ ifnum, intfdesc->bAlternateSetting, intf->driver->minor); */ -+#endif - -- printk(KERN_INFO -- "HFC-USB: New device if=%d alt=%d registered\n", -- context->if_used, context->alt_used); -- return (context); -- } -+ if (vend_idx != 0xffff) { -+#ifdef VERBOSE_USB_DEBUG -+ printk(KERN_INFO "HFC-USB: found vendor idx:%d name:%s\n",vend_idx,vdata[vend_idx].vend_name); -+#endif -+ /* if vendor and product ID is OK, start probing a matching alternate setting ... */ -+ alt_idx = 0; -+ small_match=0xffff; -+ // default settings -+ iso_packet_size=16; -+ packet_size=64; -+ -+ while (alt_idx < intf->num_altsetting) { -+ //iface = intf->altsetting + alt_idx; -+ intfdesc = intf->altsetting + alt_idx; -+ probe_alt_setting = intfdesc->bAlternateSetting; -+ cfg_used=0; - -- return (NULL); /* no matching entry */ --} /* hfc_usb_probe */ -+#ifdef VERBOSE_USB_DEBUG -+ printk(KERN_INFO "HFC-USB: test alt_setting %d\n", probe_alt_setting); -+#endif -+ // check for config EOL element -+ while (validconf[cfg_used][0]) { -+ cfg_found=TRUE; -+ vcf=validconf[cfg_used]; -+ ep = intfdesc->endpoint; /* first endpoint descriptor */ -+ -+#ifdef VERBOSE_USB_DEBUG -+ printk(KERN_INFO "HFC-USB: (if=%d alt=%d cfg_used=%d)\n", -+ ifnum, probe_alt_setting, cfg_used); -+#endif -+ // copy table -+ memcpy(cmptbl,vcf,16*sizeof(int)); -+ -+ // check for all endpoints in this alternate setting -+ for (i=0; i < intfdesc->bNumEndpoints; i++) { -+ ep_addr = ep->bEndpointAddress; -+ idx = ((ep_addr & 0x7f)-1)*2; /* get endpoint base */ -+ if (ep_addr & 0x80) -+ idx++; -+ attr = ep->bmAttributes; -+ -+ if (cmptbl[idx] == EP_NUL) { -+ printk(KERN_INFO "HFC-USB: cfg_found=FALSE in idx:%d attr:%d cmptbl[%d]:%d\n", -+ idx, attr, idx, cmptbl[idx]); -+ cfg_found = FALSE; -+ } -+ -+ if (attr == USB_ENDPOINT_XFER_INT && cmptbl[idx] == EP_INT) -+ cmptbl[idx] = EP_NUL; -+ if (attr == USB_ENDPOINT_XFER_BULK && cmptbl[idx] == EP_BLK) -+ cmptbl[idx] = EP_NUL; -+ if (attr == USB_ENDPOINT_XFER_ISOC && cmptbl[idx] == EP_ISO) -+ cmptbl[idx] = EP_NUL; -+ -+ // check if all INT endpoints match minimum interval -+ if (attr == USB_ENDPOINT_XFER_INT && ep->bInterval < vcf[17]) { -+#ifdef VERBOSE_USB_DEBUG -+ if (cfg_found) -+ printk(KERN_INFO "HFC-USB: Interrupt Endpoint interval < %d found - skipping config\n", -+ vcf[17]); -+#endif -+ cfg_found = FALSE; -+ } -+ -+ ep++; -+ } -+ -+ for (i = 0; i < 16; i++) { -+ // printk(KERN_INFO "HFC-USB: cmptbl[%d]:%d\n", i, cmptbl[i]); -+ -+ // all entries must be EP_NOP or EP_NUL for a valid config -+ if (cmptbl[i] != EP_NOP && cmptbl[i] != EP_NUL) -+ cfg_found = FALSE; -+ } -+ -+ // we check for smallest match, to provide configuration priority -+ // configurations with smaller index have higher priority -+ if (cfg_found) { -+ if (cfg_used < small_match) { -+ small_match = cfg_used; -+ alt_used = probe_alt_setting; -+ //iface_used = iface; -+ intfdesc_used = intfdesc; -+ } -+#ifdef VERBOSE_USB_DEBUG -+ printk(KERN_INFO "HFC-USB: small_match=%x %x\n", small_match, alt_used); -+#endif -+ } -+ -+ cfg_used++; -+ } -+ -+ alt_idx++; -+ } /* (alt_idx < intf->num_altsetting) */ -+#ifdef VERBOSE_USB_DEBUG -+ printk(KERN_INFO "HFC-USB: final small_match=%x alt_used=%x\n",small_match, alt_used); -+#endif -+ // yiipiee, we found a valid config -+ if (small_match != 0xffff) { -+ //iface = iface_used; -+ intfdesc = intfdesc_used; -+ -+ if (!(context = kmalloc(sizeof(hfcusb_data), GFP_KERNEL))) -+ return(NULL); /* got no mem */ -+ memset(context, 0, sizeof(hfcusb_data)); /* clear the structure */ -+ -+ ep = intfdesc->endpoint; /* first endpoint descriptor */ -+ vcf = validconf[small_match]; -+ -+ for (i = 0; i < intfdesc->bNumEndpoints; i++) { -+ ep_addr = ep->bEndpointAddress; -+ idx = ((ep_addr & 0x7f)-1)*2; /* get endpoint base */ -+ if (ep_addr & 0x80) -+ idx++; -+ cidx = idx & 7; -+ attr = ep->bmAttributes; -+ -+ // only initialize used endpoints -+ if (vcf[idx] != EP_NOP && vcf[idx] != EP_NUL) { -+ switch (attr) { -+ case USB_ENDPOINT_XFER_INT: -+ context->fifos[cidx].pipe = usb_rcvintpipe(dev, ep->bEndpointAddress); -+ context->fifos[cidx].usb_transfer_mode = USB_INT; -+ packet_size = ep->wMaxPacketSize; // remember max packet size -+#ifdef VERBOSE_USB_DEBUG -+ printk (KERN_INFO "HFC-USB: Interrupt-In Endpoint found %d ms(idx:%d cidx:%d)!\n", -+ ep->bInterval, idx, cidx); -+#endif -+ break; -+ case USB_ENDPOINT_XFER_BULK: -+ if (ep_addr & 0x80) -+ context->fifos[cidx].pipe = usb_rcvbulkpipe(dev, ep->bEndpointAddress); -+ else -+ context->fifos[cidx].pipe = usb_sndbulkpipe(dev, ep->bEndpointAddress); -+ context->fifos[cidx].usb_transfer_mode = USB_BULK; -+ packet_size = ep->wMaxPacketSize; // remember max packet size -+#ifdef VERBOSE_USB_DEBUG -+ printk (KERN_INFO "HFC-USB: Bulk Endpoint found (idx:%d cidx:%d)!\n", -+ idx, cidx); -+#endif -+ break; -+ case USB_ENDPOINT_XFER_ISOC: -+ if (ep_addr & 0x80) -+ context->fifos[cidx].pipe = usb_rcvisocpipe(dev, ep->bEndpointAddress); -+ else -+ context->fifos[cidx].pipe = usb_sndisocpipe(dev, ep->bEndpointAddress); -+ context->fifos[cidx].usb_transfer_mode = USB_ISOC; -+ iso_packet_size = ep->wMaxPacketSize; // remember max packet size -+#ifdef VERBOSE_USB_DEBUG -+ printk (KERN_INFO "HFC-USB: ISO Endpoint found (idx:%d cidx:%d)!\n", -+ idx, cidx); -+#endif -+ break; -+ default: -+ context->fifos[cidx].pipe = 0; /* reset data */ -+ } /* switch attribute */ -+ -+ if (context->fifos[cidx].pipe) { -+ context->fifos[cidx].fifonum = cidx; -+ context->fifos[cidx].hfc = context; -+ context->fifos[cidx].usb_packet_maxlen = ep->wMaxPacketSize; -+ context->fifos[cidx].intervall = ep->bInterval; -+ context->fifos[cidx].skbuff = NULL; -+#ifdef VERBOSE_USB_DEBUG -+ printk (KERN_INFO "HFC-USB: fifo%d pktlen %d interval %d\n", -+ context->fifos[cidx].fifonum, -+ context->fifos[cidx].usb_packet_maxlen, -+ context->fifos[cidx].intervall); -+#endif -+ } -+ } -+ -+ ep++; -+ } -+ -+ // now share our luck -+ context->dev = dev; /* save device */ -+ context->if_used = ifnum; /* save used interface */ -+ context->alt_used = alt_used; /* and alternate config */ -+ context->ctrl_paksize = dev->descriptor.bMaxPacketSize0; /* control size */ -+ context->cfg_used=vcf[16]; // store used config -+ context->vend_idx=vend_idx; // store found vendor -+ context->packet_size=packet_size; -+ context->iso_packet_size=iso_packet_size; -+ -+ /* create the control pipes needed for register access */ -+ context->ctrl_in_pipe = usb_rcvctrlpipe(context->dev, 0); -+ context->ctrl_out_pipe = usb_sndctrlpipe(context->dev, 0); -+ context->ctrl_urb = usb_alloc_urb(0); -+ -+ printk(KERN_INFO "HFC-USB: detected \"%s\" configuration: %s (if=%d alt=%d)\n", -+ vdata[vend_idx].vend_name, conf_str[small_match], context->if_used, context->alt_used); -+ -+ /* init the chip and register the driver */ -+ if (usb_init(context)) -+ { -+ if (context->ctrl_urb) { -+ usb_unlink_urb(context->ctrl_urb); -+ usb_free_urb(context->ctrl_urb); -+ context->ctrl_urb = NULL; -+ } -+ kfree(context); -+ return(NULL); -+ } -+ //usb_set_intfdata(intf, context); -+ //intf->private_data = context; -+ return(context); -+ } -+ } -+ return(NULL); -+} - - /****************************************************/ - /* function called when an active device is removed */ - /****************************************************/ --static void --hfc_usb_disconnect(struct usb_device *usbdev, void *drv_context) -+//static void hfc_usb_disconnect(struct usb_interface *intf) -+static void hfc_usb_disconnect(struct usb_device *usbdev, void* drv_context) - { -- hfcusb_data *context = drv_context; -+ //hfcusb_data *context = intf->private_data; -+ hfcusb_data* context = drv_context; - int i; -- struct sk_buff *skb; - -- /* tell all fifos to terminate */ -- for (i = 0; i < HFCUSB_NUM_FIFOS; i++) -- if (context->fifos[i].active) { -- context->fifos[i].active = 0; -- usb_unlink_urb(&context->fifos[i].urb); -- } -- while (context->active_fifos) { -- set_current_state(TASK_INTERRUPTIBLE); -- /* Timeout 10ms */ -- schedule_timeout((10 * HZ) / 1000); -- } -+ printk(KERN_INFO "HFC-USB: device disconnect\n"); -+ -+ //intf->private_data = NULL; -+ if (!context) -+ return; - if (timer_pending(&context->t3_timer)) - del_timer(&context->t3_timer); -- context->regd.release_driver(context->regd.arg_hisax); -- while ((skb = skb_dequeue(&context->regd.erq)) != NULL) -- dev_kfree_skb_any(skb); -+ if (timer_pending(&context->t4_timer)) -+ del_timer(&context->t4_timer); -+ if (timer_pending(&context->led_timer)) -+ del_timer(&context->led_timer); -+ -+ hisax_unregister(&context->d_if); - -+ /* tell all fifos to terminate */ -+ for(i = 0; i < HFCUSB_NUM_FIFOS; i++) { -+ if(context->fifos[i].usb_transfer_mode == USB_ISOC) { -+ if(context->fifos[i].active > 0) { -+ stop_isoc_chain(&context->fifos[i]); -+#ifdef VERBOSE_USB_DEBUG -+ printk (KERN_INFO "HFC-USB: hfc_usb_disconnect: stopping ISOC chain Fifo no %i\n", i); -+#endif -+ } -+ } else { -+ if(context->fifos[i].active > 0) { -+ context->fifos[i].active = 0; -+#ifdef VERBOSE_USB_DEBUG -+ printk (KERN_INFO "HFC-USB: hfc_usb_disconnect: unlinking URB for Fifo no %i\n", i); -+#endif -+ } -+ if (context->fifos[i].urb) { -+ usb_unlink_urb(context->fifos[i].urb); -+ usb_free_urb(context->fifos[i].urb); -+ context->fifos[i].urb = NULL; -+ } -+ } -+ context->fifos[i].active = 0; -+ } -+ if (context->ctrl_urb) { -+ usb_unlink_urb(context->ctrl_urb); -+ usb_free_urb(context->ctrl_urb); -+ context->ctrl_urb = NULL; -+ } - kfree(context); /* free our structure again */ -- MOD_DEC_USE_COUNT; /* and decrement the usage counter */ - } /* hfc_usb_disconnect */ - -+ - /************************************/ - /* our driver information structure */ - /************************************/ - static struct usb_driver hfc_drv = { - name:"hfc_usb", --#ifdef COMPAT_HAS_USB_IDTAB - id_table:hfc_usb_idtab, --#endif - probe:hfc_usb_probe, - disconnect:hfc_usb_disconnect, - }; - --static void __exit --hfc_usb_exit(void) --{ - -+static void __exit hfc_usb_exit(void) -+{ -+#ifdef VERBOSE_USB_DEBUG -+ printk ("HFC-USB: calling \"hfc_usb_exit\" ...\n"); -+#endif - usb_deregister(&hfc_drv); /* release our driver */ - printk(KERN_INFO "HFC-USB module removed\n"); - } - --static int __init --hfc_usb_init(void) -+static int __init hfc_usb_init(void) - { -- struct hisax_drvreg drv; -+ printk ("HFC-USB: driver module revision %s loaded\n", hfcusb_revision); - -- drv.version = HISAX_LOAD_VERSION; /* set our version */ -- drv.cmd = HISAX_LOAD_CHKVER; /* check command only */ -- if (hisax_register_hfcusb(&drv)) { -- printk(KERN_INFO "HFC-USB <-> hisax version conflict\n"); -- return (-1); /* unable to register */ -- } -- if (usb_register(&hfc_drv)) { -- printk(KERN_INFO -- "Unable to register HFC-USB module at usb stack\n"); -- return (-1); /* unable to register */ -+ if(usb_register(&hfc_drv)) -+ { -+ printk(KERN_INFO "HFC-USB: Unable to register HFC-USB module at usb stack\n"); -+ return(-1); /* unable to register */ - } -- -- printk(KERN_INFO "HFC-USB module loaded\n"); -- return (0); -+ return(0); - } - -+ -+ -+ -+ - module_init(hfc_usb_init); - module_exit(hfc_usb_exit); -+ diff --git a/target/linux/generic-2.4/patches/203-hfsplus_fix.patch b/target/linux/generic-2.4/patches/203-hfsplus_fix.patch deleted file mode 100644 index 4710c86..0000000 --- a/target/linux/generic-2.4/patches/203-hfsplus_fix.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/fs/hfsplus/super.c -+++ b/fs/hfsplus/super.c -@@ -240,8 +240,7 @@ int hfsplus_remount(struct super_block * - if (!(*flags & MS_RDONLY)) { - struct hfsplus_vh *vhdr = HFSPLUS_SB(sb).s_vhdr; - -- if ((vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_INCNSTNT)) || -- !(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) { -+ if (!(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) { - printk("HFS+-fs warning: Filesystem was not cleanly unmounted, " - "running fsck.hfsplus is recommended. leaving read-only.\n"); - sb->s_flags |= MS_RDONLY; -@@ -343,8 +342,7 @@ static int hfsplus_fill_super(struct sup - /* Set up operations so we can load metadata */ - sb->s_op = &hfsplus_sops; - -- if ((vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_INCNSTNT)) || -- !(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) { -+ if (!(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) { - if (!silent) - printk("HFS+-fs warning: Filesystem was not cleanly unmounted, " - "running fsck.hfsplus is recommended. mounting read-only.\n"); diff --git a/target/linux/generic-2.4/patches/206-gcc_3.4_fixes.patch b/target/linux/generic-2.4/patches/206-gcc_3.4_fixes.patch deleted file mode 100644 index bdf6501..0000000 --- a/target/linux/generic-2.4/patches/206-gcc_3.4_fixes.patch +++ /dev/null @@ -1,217 +0,0 @@ ---- a/arch/mips/kernel/signal.c -+++ b/arch/mips/kernel/signal.c -@@ -6,8 +6,10 @@ - * Copyright (C) 1991, 1992 Linus Torvalds - * Copyright (C) 1994 - 1999 Ralf Baechle - * Copyright (C) 1999 Silicon Graphics, Inc. -+ * Copyright (C) 2004 Maciej W. Rozycki - */ - #include <linux/config.h> -+#include <linux/compiler.h> - #include <linux/sched.h> - #include <linux/mm.h> - #include <linux/smp.h> -@@ -76,7 +78,9 @@ int copy_siginfo_to_user(siginfo_t *to, - * Atomically swap in the new signal mask, and wait for a signal. - */ - save_static_function(sys_sigsuspend); --static_unused int _sys_sigsuspend(struct pt_regs regs) -+static int _sys_sigsuspend(struct pt_regs regs) -+ __asm__("_sys_sigsuspend") __attribute_used__; -+static int _sys_sigsuspend(struct pt_regs regs) - { - sigset_t *uset, saveset, newset; - -@@ -102,7 +106,9 @@ static_unused int _sys_sigsuspend(struct - } - - save_static_function(sys_rt_sigsuspend); --static_unused int _sys_rt_sigsuspend(struct pt_regs regs) -+static int _sys_rt_sigsuspend(struct pt_regs regs) -+ __asm__("_sys_rt_sigsuspend") __attribute_used__; -+static int _sys_rt_sigsuspend(struct pt_regs regs) - { - sigset_t *unewset, saveset, newset; - size_t sigsetsize; ---- a/arch/mips/kernel/syscall.c -+++ b/arch/mips/kernel/syscall.c -@@ -5,6 +5,7 @@ - * - * Copyright (C) 1995 - 2000 by Ralf Baechle - * Copyright (C) 2000 Silicon Graphics, Inc. -+ * Copyright (C) 2004 Maciej W. Rozycki - * - * TODO: Implement the compatibility syscalls. - * Don't waste that much memory for empty entries in the syscall -@@ -158,7 +159,9 @@ sys_mmap2(unsigned long addr, unsigned l - } - - save_static_function(sys_fork); --static_unused int _sys_fork(struct pt_regs regs) -+static int _sys_fork(struct pt_regs regs) -+ __asm__("_sys_fork") __attribute_used__; -+static int _sys_fork(struct pt_regs regs) - { - int res; - -@@ -168,7 +171,9 @@ static_unused int _sys_fork(struct pt_re - - - save_static_function(sys_clone); --static_unused int _sys_clone(struct pt_regs regs) -+static int _sys_clone(struct pt_regs regs) -+ __asm__("_sys_clone") __attribute_used__; -+static int _sys_clone(struct pt_regs regs) - { - unsigned long clone_flags; - unsigned long newsp; ---- a/arch/mips/ld.script.in -+++ b/arch/mips/ld.script.in -@@ -9,6 +9,7 @@ SECTIONS - { - _ftext = . ; - *(.text) -+ *(.fixup) - *(.rodata) - *(.rodata.*) - *(.rodata1) ---- a/arch/mips64/kernel/signal.c -+++ b/arch/mips64/kernel/signal.c -@@ -6,8 +6,10 @@ - * Copyright (C) 1991, 1992 Linus Torvalds - * Copyright (C) 1994 - 2000 Ralf Baechle - * Copyright (C) 1999, 2000 Silicon Graphics, Inc. -+ * Copyright (C) 2004 Maciej W. Rozycki - */ - #include <linux/config.h> -+#include <linux/compiler.h> - #include <linux/sched.h> - #include <linux/mm.h> - #include <linux/smp.h> -@@ -75,7 +77,9 @@ int copy_siginfo_to_user(siginfo_t *to, - * Atomically swap in the new signal mask, and wait for a signal. - */ - save_static_function(sys_rt_sigsuspend); --static_unused int _sys_rt_sigsuspend(abi64_no_regargs, struct pt_regs regs) -+static int _sys_rt_sigsuspend(abi64_no_regargs, struct pt_regs regs) -+ __asm__("_sys_rt_sigsuspend") __attribute_used__; -+static int _sys_rt_sigsuspend(abi64_no_regargs, struct pt_regs regs) - { - sigset_t *unewset, saveset, newset; - size_t sigsetsize; ---- a/arch/mips64/kernel/signal32.c -+++ b/arch/mips64/kernel/signal32.c -@@ -6,7 +6,9 @@ - * Copyright (C) 1991, 1992 Linus Torvalds - * Copyright (C) 1994 - 2000 Ralf Baechle - * Copyright (C) 1999, 2000 Silicon Graphics, Inc. -+ * Copyright (C) 2004 Maciej W. Rozycki - */ -+#include <linux/compiler.h> - #include <linux/sched.h> - #include <linux/mm.h> - #include <linux/smp.h> -@@ -192,7 +194,9 @@ static inline int get_sigset(sigset_t *k - * Atomically swap in the new signal mask, and wait for a signal. - */ - save_static_function(sys32_sigsuspend); --static_unused int _sys32_sigsuspend(abi64_no_regargs, struct pt_regs regs) -+static int _sys32_sigsuspend(abi64_no_regargs, struct pt_regs regs) -+ __asm__("_sys32_sigsuspend") __attribute_used__; -+static int _sys32_sigsuspend(abi64_no_regargs, struct pt_regs regs) - { - sigset32_t *uset; - sigset_t newset, saveset; -@@ -219,7 +223,9 @@ static_unused int _sys32_sigsuspend(abi6 - } - - save_static_function(sys32_rt_sigsuspend); --static_unused int _sys32_rt_sigsuspend(abi64_no_regargs, struct pt_regs regs) -+static int _sys32_rt_sigsuspend(abi64_no_regargs, struct pt_regs regs) -+ __asm__("_sys32_rt_sigsuspend") __attribute_used__; -+static int _sys32_rt_sigsuspend(abi64_no_regargs, struct pt_regs regs) - { - sigset32_t *uset; - sigset_t newset, saveset; ---- a/arch/mips64/kernel/syscall.c -+++ b/arch/mips64/kernel/syscall.c -@@ -6,7 +6,9 @@ - * Copyright (C) 1995 - 2000, 2001 by Ralf Baechle - * Copyright (C) 1999, 2000 Silicon Graphics, Inc. - * Copyright (C) 2001 MIPS Technologies, Inc. -+ * Copyright (C) 2004 Maciej W. Rozycki - */ -+#include <linux/compiler.h> - #include <linux/errno.h> - #include <linux/linkage.h> - #include <linux/mm.h> -@@ -151,7 +153,9 @@ out: - } - - save_static_function(sys_fork); --static_unused int _sys_fork(abi64_no_regargs, struct pt_regs regs) -+static int _sys_fork(abi64_no_regargs, struct pt_regs regs) -+ __asm__("_sys_fork") __attribute_used__; -+static int _sys_fork(abi64_no_regargs, struct pt_regs regs) - { - int res; - -@@ -160,7 +164,9 @@ static_unused int _sys_fork(abi64_no_reg - } - - save_static_function(sys_clone); --static_unused int _sys_clone(abi64_no_regargs, struct pt_regs regs) -+static int _sys_clone(abi64_no_regargs, struct pt_regs regs) -+ __asm__("_sys_clone") __attribute_used__; -+static int _sys_clone(abi64_no_regargs, struct pt_regs regs) - { - unsigned long clone_flags; - unsigned long newsp; ---- a/include/asm-mips/ptrace.h -+++ b/include/asm-mips/ptrace.h -@@ -4,6 +4,7 @@ - * for more details. - * - * Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000 by Ralf Baechle -+ * Copyright (C) 2004 Maciej W. Rozycki - * - * Machine dependent structs and defines to help the user use - * the ptrace system call. -@@ -64,12 +65,10 @@ __asm__ ( - "sw\t$22,"__str(PT_R22)"($29)\n\t" \ - "sw\t$23,"__str(PT_R23)"($29)\n\t" \ - "sw\t$30,"__str(PT_R30)"($29)\n\t" \ -+ "j\t_" #symbol "\n\t" \ - ".end\t" #symbol "\n\t" \ - ".size\t" #symbol",. - " #symbol) - --/* Used in declaration of save_static functions. */ --#define static_unused static __attribute__((unused)) -- - #endif /* !__ASSEMBLY__ */ - - /* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */ ---- a/include/asm-mips64/ptrace.h -+++ b/include/asm-mips64/ptrace.h -@@ -5,6 +5,7 @@ - * - * Copyright (C) 1994, 95, 96, 97, 98, 99, 2000 by Ralf Baechle - * Copyright (C) 1999, 2000 Silicon Graphics, Inc. -+ * Copyright (C) 2004 Maciej W. Rozycki - */ - #ifndef _ASM_PTRACE_H - #define _ASM_PTRACE_H -@@ -61,12 +62,10 @@ __asm__ ( - "sd\t$22,"__str(PT_R22)"($29)\n\t" \ - "sd\t$23,"__str(PT_R23)"($29)\n\t" \ - "sd\t$30,"__str(PT_R30)"($29)\n\t" \ -+ "j\t_" #symbol "\n\t" \ - ".end\t" #symbol "\n\t" \ - ".size\t" #symbol",. - " #symbol) - --/* Used in declaration of save_static functions. */ --#define static_unused static __attribute__((unused)) -- - #define abi64_no_regargs \ - unsigned long __dummy0, \ - unsigned long __dummy1, \ diff --git a/target/linux/generic-2.4/patches/208-usb2_fix.patch b/target/linux/generic-2.4/patches/208-usb2_fix.patch deleted file mode 100644 index 5c90e63..0000000 --- a/target/linux/generic-2.4/patches/208-usb2_fix.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/drivers/usb/host/ehci-q.c -+++ b/drivers/usb/host/ehci-q.c -@@ -782,6 +782,11 @@ static void qh_link_async (struct ehci_h - if (!(cmd & CMD_ASE)) { - /* in case a clear of CMD_ASE didn't take yet */ - (void) handshake (&ehci->regs->status, STS_ASS, 0, 150); -+ -+ /* force async head to be valid */ -+ writel ((u32)ehci->async->qh_dma, -+ &ehci->regs->async_next); -+ - cmd |= CMD_ASE | CMD_RUN; - writel (cmd, &ehci->regs->command); - ehci->hcd.state = USB_STATE_RUNNING; diff --git a/target/linux/generic-2.4/patches/209-build_fixes.patch b/target/linux/generic-2.4/patches/209-build_fixes.patch deleted file mode 100644 index 720f0f3..0000000 --- a/target/linux/generic-2.4/patches/209-build_fixes.patch +++ /dev/null @@ -1,47 +0,0 @@ ---- a/Makefile -+++ b/Makefile -@@ -365,7 +365,7 @@ include/linux/compile.h: $(CONFIGURATION - @rm -f .ver1 - - include/linux/version.h: ./Makefile -- @expr length "$(KERNELRELEASE)" \<= $(uts_len) > /dev/null || \ -+ @-expr length "$(KERNELRELEASE)" \<= $(uts_len) > /dev/null || \ - (echo KERNELRELEASE \"$(KERNELRELEASE)\" exceeds $(uts_len) characters >&2; false) - @echo \#define UTS_RELEASE \"$(KERNELRELEASE)\" > .ver - @echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)` >> .ver -@@ -507,7 +507,7 @@ dep-files: scripts/mkdep archdep include - ifdef CONFIG_MODVERSIONS - $(MAKE) update-modverfile - endif -- scripts/mkdep -- `find $(FINDHPATH) \( -name SCCS -o -name .svn \) -prune -o -follow -name \*.h ! -name modversions.h -print` > .hdepend -+ find $(FINDHPATH) \( -name SCCS -o -name .svn \) -prune -o -follow -name \*.h ! -name modversions.h -print | xargs scripts/mkdep -- > .hdepend - scripts/mkdep -- init/*.c > .depend - - ifdef CONFIG_MODVERSIONS ---- a/Rules.make -+++ b/Rules.make -@@ -126,7 +126,7 @@ endif - # This make dependencies quickly - # - fastdep: dummy -- $(TOPDIR)/scripts/mkdep $(CFLAGS) $(EXTRA_CFLAGS_nostdinc) -- $(wildcard *.[chS]) > .depend -+ find . -name '*.[chS]' | xargs $(TOPDIR)/scripts/mkdep $(CFLAGS) $(EXTRA_CFLAGS_nostdinc) -- > .depend - ifdef ALL_SUB_DIRS - $(MAKE) $(patsubst %,_sfdep_%,$(ALL_SUB_DIRS)) _FASTDEP_ALL_SUB_DIRS="$(ALL_SUB_DIRS)" - endif -@@ -176,7 +176,14 @@ modules: $(ALL_MOBJS) dummy \ - _modinst__: dummy - ifneq "$(strip $(ALL_MOBJS))" "" - mkdir -p $(MODLIB)/kernel/$(MOD_DESTDIR) -- cp $(sort $(ALL_MOBJS)) $(MODLIB)/kernel/$(MOD_DESTDIR) -+ #@cp $(sort $(ALL_MOBJS)) $(MODLIB)/kernel/$(MOD_DESTDIR) -+ for f in $(ALL_MOBJS) ; do \ -+ $(OBJCOPY) -R __ksymtab -R .comment -R .note -x \ -+ `$(NM) $$f | cut -f3- -d' ' | sed -n \ -+ -e 's/__module_parm_\(.*\)/-K \1/p' \ -+ -e 's/__ks..tab_\(.*\)/-K \1/p'` \ -+ $$f $(MODLIB)/kernel/$(MOD_DESTDIR)$(MOD_TARGET)`basename $$f`; \ -+ done - endif - - .PHONY: modules_install diff --git a/target/linux/generic-2.4/patches/210-fix-irq-serial.patch b/target/linux/generic-2.4/patches/210-fix-irq-serial.patch deleted file mode 100644 index 3b8a01f..0000000 --- a/target/linux/generic-2.4/patches/210-fix-irq-serial.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/drivers/char/serial.c -+++ b/drivers/char/serial.c -@@ -5458,18 +5458,6 @@ static int __init rs_init(void) - sizeof(struct rs_multiport_struct)); - #endif - } --#ifdef CONFIG_SERIAL_CONSOLE -- /* -- * The interrupt of the serial console port -- * can't be shared. -- */ -- if (sercons.flags & CON_CONSDEV) { -- for(i = 0; i < NR_PORTS; i++) -- if (i != sercons.index && -- rs_table[i].irq == rs_table[sercons.index].irq) -- rs_table[i].irq = 0; -- } --#endif - show_serial_version(); - - /* Initialize the tty_driver structure */ diff --git a/target/linux/generic-2.4/patches/212-htb_time_fix.patch b/target/linux/generic-2.4/patches/212-htb_time_fix.patch deleted file mode 100644 index 8c1d11e..0000000 --- a/target/linux/generic-2.4/patches/212-htb_time_fix.patch +++ /dev/null @@ -1,75 +0,0 @@ ---- a/net/sched/sch_htb.c -+++ b/net/sched/sch_htb.c -@@ -369,7 +369,7 @@ static void htb_debug_dump (struct htb_s - struct list_head *l; - list_for_each (l,q->hash+i) { - struct htb_class *cl = list_entry(l,struct htb_class,hlist); -- long diff = PSCHED_TDIFF_SAFE(q->now, cl->t_c, (u32)cl->mbuffer, 0); -+ long long diff = PSCHED_TDIFF_SAFE(q->now, cl->t_c, (u32)cl->mbuffer, 0); - printk(KERN_DEBUG "htb*c%x m=%d t=%ld c=%ld pq=%lu df=%ld ql=%d " - "pa=%x f:", - cl->classid,cl->cmode,cl->tokens,cl->ctokens, -@@ -617,7 +617,7 @@ static void htb_deactivate_prios(struct - * mode transitions per time unit. The speed gain is about 1/6. - */ - static __inline__ enum htb_cmode --htb_class_mode(struct htb_class *cl,long *diff) -+htb_class_mode(struct htb_class *cl,long long *diff) - { - long toks; - -@@ -650,7 +650,7 @@ htb_class_mode(struct htb_class *cl,long - * to mode other than HTB_CAN_SEND (see htb_add_to_wait_tree). - */ - static void --htb_change_class_mode(struct htb_sched *q, struct htb_class *cl, long *diff) -+htb_change_class_mode(struct htb_sched *q, struct htb_class *cl, long long *diff) - { - enum htb_cmode new_mode = htb_class_mode(cl,diff); - -@@ -815,7 +815,8 @@ static void htb_rate_timer(unsigned long - static void htb_charge_class(struct htb_sched *q,struct htb_class *cl, - int level,int bytes) - { -- long toks,diff; -+ long long diff; -+ long toks; - enum htb_cmode old_mode; - HTB_DBG(5,1,"htb_chrg_cl cl=%X lev=%d len=%d\n",cl->classid,level,bytes); - -@@ -831,7 +832,7 @@ static void htb_charge_class(struct htb_ - #ifdef HTB_DEBUG - if (diff > cl->mbuffer || diff < 0 || PSCHED_TLESS(q->now, cl->t_c)) { - if (net_ratelimit()) -- printk(KERN_ERR "HTB: bad diff in charge, cl=%X diff=%lX now=%Lu then=%Lu j=%lu\n", -+ printk(KERN_ERR "HTB: bad diff in charge, cl=%X diff=%Ld now=%Lu then=%Lu j=%lu\n", - cl->classid, diff, - (unsigned long long) q->now, - (unsigned long long) cl->t_c, -@@ -848,7 +849,7 @@ static void htb_charge_class(struct htb_ - } - HTB_ACCNT (ctokens,cbuffer,ceil); - cl->t_c = q->now; -- HTB_DBG(5,2,"htb_chrg_clp cl=%X diff=%ld tok=%ld ctok=%ld\n",cl->classid,diff,cl->tokens,cl->ctokens); -+ HTB_DBG(5,2,"htb_chrg_clp cl=%X diff=%Ld tok=%ld ctok=%ld\n",cl->classid,diff,cl->tokens,cl->ctokens); - - old_mode = cl->cmode; diff = 0; - htb_change_class_mode(q,cl,&diff); -@@ -887,7 +888,7 @@ static long htb_do_events(struct htb_sch - level,q->wait_pq[level].rb_node,q->row_mask[level]); - for (i = 0; i < 500; i++) { - struct htb_class *cl; -- long diff; -+ long long diff; - rb_node_t *p = q->wait_pq[level].rb_node; - if (!p) return 0; - while (p->rb_left) p = p->rb_left; -@@ -902,7 +903,7 @@ static long htb_do_events(struct htb_sch - #ifdef HTB_DEBUG - if (diff > cl->mbuffer || diff < 0 || PSCHED_TLESS(q->now, cl->t_c)) { - if (net_ratelimit()) -- printk(KERN_ERR "HTB: bad diff in events, cl=%X diff=%lX now=%Lu then=%Lu j=%lu\n", -+ printk(KERN_ERR "HTB: bad diff in events, cl=%X diff=%Ld now=%Lu then=%Lu j=%lu\n", - cl->classid, diff, - (unsigned long long) q->now, - (unsigned long long) cl->t_c, diff --git a/target/linux/generic-2.4/patches/213-htb_disable_hysteresis.patch b/target/linux/generic-2.4/patches/213-htb_disable_hysteresis.patch deleted file mode 100644 index eac74cd..0000000 --- a/target/linux/generic-2.4/patches/213-htb_disable_hysteresis.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/sched/sch_htb.c -+++ b/net/sched/sch_htb.c -@@ -74,7 +74,7 @@ - #define HTB_EWMAC 2 /* rate average over HTB_EWMAC*HTB_HSIZE sec */ - #define HTB_DEBUG 1 /* compile debugging support (activated by tc tool) */ - #define HTB_RATECM 1 /* whether to use rate computer */ --#define HTB_HYSTERESIS 1/* whether to use mode hysteresis for speedup */ -+#define HTB_HYSTERESIS 0/* whether to use mode hysteresis for speedup */ - #define HTB_QLOCK(S) spin_lock_bh(&(S)->dev->queue_lock) - #define HTB_QUNLOCK(S) spin_unlock_bh(&(S)->dev->queue_lock) - #define HTB_VER 0x30011 /* major must be matched with number suplied by TC as version */ diff --git a/target/linux/generic-2.4/patches/222-sound.patch b/target/linux/generic-2.4/patches/222-sound.patch deleted file mode 100644 index 7f3a1a3..0000000 --- a/target/linux/generic-2.4/patches/222-sound.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/drivers/sound/sound_core.c -+++ b/drivers/sound/sound_core.c -@@ -174,9 +174,9 @@ static int sound_insert_unit(struct soun - } - - if (r == low) -- sprintf (name_buf, "%s", name); -+ snprintf (name_buf, sizeof(name_buf), "%s", name); - else -- sprintf (name_buf, "%s%d", name, (r - low) / SOUND_STEP); -+ snprintf (name_buf, sizeof(name_buf), "%s%d", name, (r - low) / SOUND_STEP); - s->de = devfs_register (devfs_handle, name_buf, - DEVFS_FL_NONE, SOUND_MAJOR, s->unit_minor, - S_IFCHR | mode, fops, NULL); -@@ -507,9 +507,9 @@ int soundcore_open(struct inode *inode, - * ALSA toplevel modules for soundcards, thus we need - * load them at first. [Jaroslav Kysela <perex@jcu.cz>] - */ -- sprintf(mod, "sound-slot-%i", unit>>4); -+ snprintf(mod, sizeof(mod), "sound-slot-%i", unit>>4); - request_module(mod); -- sprintf(mod, "sound-service-%i-%i", unit>>4, chain); -+ snprintf(mod, sizeof(mod), "sound-service-%i-%i", unit>>4, chain); - request_module(mod); - spin_lock(&sound_loader_lock); - s = __look_for_unit(chain, unit); diff --git a/target/linux/generic-2.4/patches/224-atm_hotplug.patch b/target/linux/generic-2.4/patches/224-atm_hotplug.patch deleted file mode 100644 index b1238ed..0000000 --- a/target/linux/generic-2.4/patches/224-atm_hotplug.patch +++ /dev/null @@ -1,96 +0,0 @@ ---- a/include/linux/atmdev.h -+++ b/include/linux/atmdev.h -@@ -400,6 +400,7 @@ extern rwlock_t vcc_sklist_lock; - struct atm_dev *atm_dev_register(const char *type,const struct atmdev_ops *ops, - int number,atm_dev_flags_t *flags); /* number == -1: pick first available */ - struct atm_dev *atm_dev_lookup(int number); -+void atm_dev_set_link_status(struct atm_dev *dev, int status); - void atm_dev_deregister(struct atm_dev *dev); - void shutdown_atm_dev(struct atm_dev *dev); - void vcc_insert_socket(struct sock *sk); ---- a/net/atm/resources.c -+++ b/net/atm/resources.c -@@ -10,6 +10,7 @@ - #include <linux/sonet.h> - #include <linux/kernel.h> /* for barrier */ - #include <linux/module.h> -+#include <linux/kmod.h> - #include <linux/bitops.h> - #include <net/sock.h> /* for struct sock */ - #include <asm/segment.h> /* for get_fs_long and put_fs_long */ -@@ -70,6 +71,44 @@ struct atm_dev *atm_dev_lookup(int numbe - return dev; - } - -+#ifdef CONFIG_HOTPLUG -+static void atm_run_sbin_hotplug(struct atm_dev *dev, char *action) -+{ -+ char *argv[3], *envp[5], ifname[12 + IFNAMSIZ], atmname[255], action_str[32]; -+ int i; -+ -+ sprintf(ifname, "INTERFACE=atm%d", dev->number); -+ sprintf(atmname, "ATMDRIVER=%s", dev->type); -+ sprintf(action_str, "ACTION=%s", action); -+ -+ i = 0; -+ argv[i++] = hotplug_path; -+ argv[i++] = "net"; -+ argv[i] = 0; -+ -+ i = 0; -+ /* minimal command environment */ -+ envp [i++] = "HOME=/"; -+ envp [i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; -+ envp [i++] = ifname; -+ envp [i++] = atmname; -+ envp [i++] = action_str; -+ envp [i] = 0; -+ -+ return call_usermodehelper(argv [0], argv, envp); -+} -+#endif -+ -+void atm_dev_set_link_status(struct atm_dev *dev, int status) -+{ -+#ifdef CONFIG_HOTPLUG -+ if (status) -+ atm_run_sbin_hotplug(dev, "up"); -+ else -+ atm_run_sbin_hotplug(dev, "down"); -+#endif -+} -+ - struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops, - int number, atm_dev_flags_t *flags) - { -@@ -123,7 +162,10 @@ struct atm_dev *atm_dev_register(const c - } - } - #endif -- -+#ifdef CONFIG_HOTPLUG -+ atm_run_sbin_hotplug(dev, "register"); -+#endif -+ - return dev; - } - -@@ -131,6 +173,10 @@ struct atm_dev *atm_dev_register(const c - void atm_dev_deregister(struct atm_dev *dev) - { - unsigned long warning_time; -+ -+#ifdef CONFIG_HOTPLUG -+ atm_run_sbin_hotplug(dev, "unregister"); -+#endif - - #ifdef CONFIG_PROC_FS - if (dev->ops->proc_read) -@@ -399,6 +445,7 @@ done: - } - - -+EXPORT_SYMBOL(atm_dev_set_link_status); - EXPORT_SYMBOL(atm_dev_register); - EXPORT_SYMBOL(atm_dev_deregister); - EXPORT_SYMBOL(atm_dev_lookup); diff --git a/target/linux/generic-2.4/patches/225-string_lib_useful_exports.patch b/target/linux/generic-2.4/patches/225-string_lib_useful_exports.patch deleted file mode 100644 index 51ec27f..0000000 --- a/target/linux/generic-2.4/patches/225-string_lib_useful_exports.patch +++ /dev/null @@ -1,169 +0,0 @@ ---- a/lib/string.c -+++ b/lib/string.c -@@ -50,6 +50,7 @@ int strnicmp(const char *s1, const char - } - return (int)c1 - (int)c2; - } -+EXPORT_SYMBOL(strnicmp); - #endif - - char * ___strtok; -@@ -68,6 +69,7 @@ char * strcpy(char * dest,const char *sr - /* nothing */; - return tmp; - } -+EXPORT_SYMBOL(strcpy); - #endif - - #ifndef __HAVE_ARCH_STRNCPY -@@ -90,6 +92,7 @@ char * strncpy(char * dest,const char *s - - return tmp; - } -+EXPORT_SYMBOL(strncpy); - #endif - - #ifndef __HAVE_ARCH_STRCAT -@@ -109,6 +112,7 @@ char * strcat(char * dest, const char * - - return tmp; - } -+EXPORT_SYMBOL(strcat); - #endif - - #ifndef __HAVE_ARCH_STRNCAT -@@ -138,6 +142,7 @@ char * strncat(char *dest, const char *s - - return tmp; - } -+EXPORT_SYMBOL(strncat); - #endif - - #ifndef __HAVE_ARCH_STRCMP -@@ -157,6 +162,7 @@ int strcmp(const char * cs,const char * - - return __res; - } -+EXPORT_SYMBOL(strcmp); - #endif - - #ifndef __HAVE_ARCH_STRNCMP -@@ -178,6 +184,7 @@ int strncmp(const char * cs,const char * - - return __res; - } -+EXPORT_SYMBOL(strncmp); - #endif - - #ifndef __HAVE_ARCH_STRCHR -@@ -193,6 +200,7 @@ char * strchr(const char * s, int c) - return NULL; - return (char *) s; - } -+EXPORT_SYMBOL(strchr); - #endif - - #ifndef __HAVE_ARCH_STRRCHR -@@ -210,6 +218,7 @@ char * strrchr(const char * s, int c) - } while (--p >= s); - return NULL; - } -+EXPORT_SYMBOL(strrchr); - #endif - - #ifndef __HAVE_ARCH_STRLEN -@@ -225,6 +234,7 @@ size_t strlen(const char * s) - /* nothing */; - return sc - s; - } -+EXPORT_SYMBOL(strlen); - #endif - - #ifndef __HAVE_ARCH_STRNLEN -@@ -241,6 +251,7 @@ size_t strnlen(const char * s, size_t co - /* nothing */; - return sc - s; - } -+EXPORT_SYMBOL(strnlen); - #endif - - #ifndef __HAVE_ARCH_STRSPN -@@ -268,6 +279,7 @@ size_t strspn(const char *s, const char - - return count; - } -+EXPORT_SYMBOL(strspn); - #endif - - #ifndef __HAVE_ARCH_STRPBRK -@@ -288,6 +300,7 @@ char * strpbrk(const char * cs,const cha - } - return NULL; - } -+EXPORT_SYMBOL(strpbrk); - #endif - - #ifndef __HAVE_ARCH_STRTOK -@@ -345,6 +358,7 @@ char * strsep(char **s, const char *ct) - - return sbegin; - } -+EXPORT_SYMBOL(strsep); - #endif - - #ifndef __HAVE_ARCH_MEMSET -@@ -365,6 +379,7 @@ void * memset(void * s,int c,size_t coun - - return s; - } -+EXPORT_SYMBOL(memset); - #endif - - #ifndef __HAVE_ARCH_BCOPY -@@ -409,6 +424,7 @@ void * memcpy(void * dest,const void *sr - - return dest; - } -+EXPORT_SYMBOL(memcpy); - #endif - - #ifndef __HAVE_ARCH_MEMMOVE -@@ -439,6 +455,7 @@ void * memmove(void * dest,const void *s - - return dest; - } -+EXPORT_SYMBOL(memmove); - #endif - - #ifndef __HAVE_ARCH_MEMCMP -@@ -459,6 +476,7 @@ int memcmp(const void * cs,const void * - break; - return res; - } -+EXPORT_SYMBOL(memcmp); - #endif - - #ifndef __HAVE_ARCH_MEMSCAN -@@ -483,6 +501,7 @@ void * memscan(void * addr, int c, size_ - } - return (void *) p; - } -+EXPORT_SYMBOL(memscan); - #endif - - #ifndef __HAVE_ARCH_STRSTR -@@ -507,6 +526,7 @@ char * strstr(const char * s1,const char - } - return NULL; - } -+EXPORT_SYMBOL(strstr); - #endif - - #ifndef __HAVE_ARCH_MEMCHR -@@ -529,5 +549,5 @@ void *memchr(const void *s, int c, size_ - } - return NULL; - } -- -+EXPORT_SYMBOL(memchr); - #endif diff --git a/target/linux/generic-2.4/patches/226-atm_br2684.patch b/target/linux/generic-2.4/patches/226-atm_br2684.patch deleted file mode 100644 index 0ae1cce..0000000 --- a/target/linux/generic-2.4/patches/226-atm_br2684.patch +++ /dev/null @@ -1,576 +0,0 @@ ---- a/net/atm/br2684.c -+++ b/net/atm/br2684.c -@@ -55,36 +55,55 @@ static void skb_debug(const struct sk_bu - #define skb_debug(skb) do {} while (0) - #endif - -+#define BR2684_LLC_LEN 3 -+#define BR2684_SNAP_LEN 3 -+#define BR2684_ETHERTYPE_LEN 2 -+#define BR2684_PID_LEN 2 -+#define BR2684_PAD_LEN 2 -+ -+static unsigned char llc_common[] = { 0xaa, 0xaa, 0x03 }; -+static unsigned char snap_bridged[] = { 0x00, 0x80, 0xc2 }; -+static unsigned char snap_routed[] = { 0x00, 0x00, 0x00 }; -+static unsigned char pid_ipv4[] = { 0x00, 0x07 }; -+static unsigned char ethertype_ipv4[] = { 0x08, 0x00 }; -+static unsigned char ethertype_ipv6[] = { 0x86, 0xdd }; -+static unsigned char pad_bridged[] = { 0x00, 0x00 }; -+ - static unsigned char llc_oui_pid_pad[] = - { 0xAA, 0xAA, 0x03, 0x00, 0x80, 0xC2, 0x00, 0x07, 0x00, 0x00 }; -+static unsigned char llc_oui_ipv6[] = -+ { 0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00, 0x86, 0xdd }; -+static unsigned char llc_oui_ipv4[] = -+ { 0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00 }; - #define PADLEN (2) - - enum br2684_encaps { -- e_vc = BR2684_ENCAPS_VC, -+ e_vc = BR2684_ENCAPS_VC, - e_llc = BR2684_ENCAPS_LLC, - }; - - struct br2684_vcc { -- struct atm_vcc *atmvcc; -+ struct atm_vcc *atmvcc; - struct br2684_dev *brdev; - /* keep old push,pop functions for chaining */ -- void (*old_push)(struct atm_vcc *vcc,struct sk_buff *skb); -+ void (*old_push) (struct atm_vcc * vcc, struct sk_buff * skb); - /* void (*old_pop)(struct atm_vcc *vcc,struct sk_buff *skb); */ - enum br2684_encaps encaps; -+ enum br2684_payload payload; - struct list_head brvccs; - #ifdef CONFIG_ATM_BR2684_IPFILTER - struct br2684_filter filter; --#endif /* CONFIG_ATM_BR2684_IPFILTER */ -+#endif /* CONFIG_ATM_BR2684_IPFILTER */ - #ifndef FASTER_VERSION - unsigned copies_needed, copies_failed; --#endif /* FASTER_VERSION */ -+#endif /* FASTER_VERSION */ - }; - - struct br2684_dev { - struct net_device net_dev; - struct list_head br2684_devs; - int number; -- struct list_head brvccs; /* one device <=> one vcc (before xmas) */ -+ struct list_head brvccs; /* one device <=> one vcc (before xmas) */ - struct net_device_stats stats; - int mac_was_set; - }; -@@ -173,24 +192,84 @@ static int br2684_xmit_vcc(struct sk_buf - } - skb = skb2; - } -- skb_push(skb, minheadroom); -- if (brvcc->encaps == e_llc) -- memcpy(skb->data, llc_oui_pid_pad, 10); -- else -- memset(skb->data, 0, 2); --#endif /* FASTER_VERSION */ -+ -+ /* This skb_push is a problem: routed packets need less headroom than -+ * bridged packets. -+ */ -+ -+/* skb_push(skb, minheadroom); */ -+ if (brvcc->encaps == e_llc) { -+ int offset = 0; -+ int actual_headroom; -+ -+ actual_headroom = -+ BR2684_LLC_LEN + -+ BR2684_SNAP_LEN + -+ ((brvcc->payload == p_bridged) ? -+ (BR2684_PID_LEN + BR2684_PAD_LEN) : -+ BR2684_ETHERTYPE_LEN); -+ -+ skb_push(skb, actual_headroom); -+ memcpy(skb->data, llc_common, BR2684_LLC_LEN); -+ offset += BR2684_LLC_LEN; -+ -+ if (brvcc->payload == p_bridged) { -+ memcpy(skb->data + offset, snap_bridged, -+ BR2684_SNAP_LEN); -+ offset += BR2684_SNAP_LEN; -+ /* pid_ipv4 is poorly named. should probably be -+ * pid_ethernet -+ */ -+ memcpy(skb->data + offset, pid_ipv4, -+ BR2684_PID_LEN); -+ offset += BR2684_PID_LEN; -+ memcpy(skb->data + offset, pad_bridged, -+ BR2684_PAD_LEN); -+ offset += BR2684_PAD_LEN; -+ } else if (brvcc->payload == p_routed) { -+ unsigned short prot = -+ __constant_ntohs(skb->protocol); -+ memcpy(skb->data + offset, snap_routed, -+ BR2684_SNAP_LEN); -+ offset += BR2684_SNAP_LEN; -+ -+ switch (prot) { -+ case ETH_P_IP: -+ memcpy(skb->data + offset, -+ ethertype_ipv4, -+ BR2684_ETHERTYPE_LEN); -+ break; -+ case ETH_P_IPV6: -+ memcpy(skb->data + offset, -+ ethertype_ipv6, -+ BR2684_ETHERTYPE_LEN); -+ break; -+ default: -+ dev_kfree_skb(skb); -+ return 0; -+ } -+ offset += BR2684_ETHERTYPE_LEN; -+ -+ } -+ } else { -+ skb_push(skb, 2); -+ if (brvcc->payload == p_bridged) -+ memset(skb->data, 0, 2); -+ } -+#endif /* FASTER_VERSION */ - skb_debug(skb); - - ATM_SKB(skb)->vcc = atmvcc = brvcc->atmvcc; -- DPRINTK("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, atmvcc, atmvcc->dev); -+ DPRINTK("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, atmvcc, -+ atmvcc->dev); - if (!atm_may_send(atmvcc, skb->truesize)) { - /* we free this here for now, because we cannot know in a higher -- layer whether the skb point it supplied wasn't freed yet. -- now, it always is. -- */ -+ layer whether the skb point it supplied wasn't freed yet. -+ now, it always is. -+ */ - dev_kfree_skb(skb); - return 0; -- } -+ } - atomic_add(skb->truesize, &atmvcc->sk->wmem_alloc); - ATM_SKB(skb)->atm_options = atmvcc->atm_options; - brdev->stats.tx_packets++; -@@ -428,18 +507,39 @@ static void br2684_push(struct atm_vcc * - atm_return(atmvcc, skb->truesize); - DPRINTK("skb from brdev %p\n", brdev); - if (brvcc->encaps == e_llc) { -+ /* accept packets that have "ipv[46]" in the snap header */ -+ /* 8 - 2 == sizeof(llc_oui_ipv6) - BR2684_ETHERTYPE_LEN */ -+ if (memcmp(skb->data, llc_oui_ipv6, 8 - 2) == 0) { -+ plen = sizeof(llc_oui_ipv6); -+ -+ if (memcmp(skb->data + 6, ethertype_ipv6, 2) == 0) -+ skb->protocol = -+ __constant_htons(ETH_P_IPV6); -+ else if (memcmp(skb->data + 6, ethertype_ipv4, 2) -+ == 0) -+ skb->protocol = __constant_htons(ETH_P_IP); -+ else { -+ brdev->stats.rx_errors++; -+ dev_kfree_skb(skb); -+ return; -+ } -+ skb_pull(skb, plen); -+ skb->nh.raw = skb->data; -+ skb->pkt_type = PACKET_HOST; -+ } -+ - /* let us waste some time for checking the encapsulation. - Note, that only 7 char is checked so frames with a valid FCS - are also accepted (but FCS is not checked of course) */ -- if (memcmp(skb->data, llc_oui_pid_pad, 7)) { -+ else if (memcmp(skb->data, llc_oui_pid_pad, 7) == 0) { -+ skb_pull(skb, plen - ETH_HLEN); -+ skb->protocol = -+ eth_type_trans(skb, &brdev->net_dev); -+ } else { - brdev->stats.rx_errors++; - dev_kfree_skb(skb); - return; - } -- -- /* Strip FCS if present */ -- if (skb->len > 7 && skb->data[7] == 0x01) -- __skb_trim(skb, skb->len - 4); - } else { - plen = PADLEN + ETH_HLEN; /* pad, dstmac,srcmac, ethtype */ - /* first 2 chars should be 0 */ -@@ -448,13 +548,14 @@ static void br2684_push(struct atm_vcc * - dev_kfree_skb(skb); - return; - } -+ skb_pull(skb, plen - ETH_HLEN); -+ skb->protocol = eth_type_trans(skb, &brdev->net_dev); - } - if (skb->len < plen) { - brdev->stats.rx_errors++; - dev_kfree_skb(skb); /* dev_ not needed? */ - return; - } -- - #ifdef FASTER_VERSION - /* FIXME: tcpdump shows that pointer to mac header is 2 bytes earlier, - than should be. What else should I set? */ -@@ -465,30 +566,29 @@ static void br2684_push(struct atm_vcc * - skb->protocol = ((u16 *) skb->data)[-1]; - #else /* some protocols might require this: */ - skb->protocol = br_type_trans(skb, &brdev->net_dev); --#endif /* CONFIG_BR2684_FAST_TRANS */ -+#endif /* CONFIG_BR2684_FAST_TRANS */ - #else -- skb_pull(skb, plen - ETH_HLEN); -- skb->protocol = eth_type_trans(skb, &brdev->net_dev); --#endif /* FASTER_VERSION */ -+ /* skb_pull(skb, plen - ETH_HLEN); */ -+ /* skb->protocol = eth_type_trans(skb, &brdev->net_dev); */ -+#endif /* FASTER_VERSION */ - #ifdef CONFIG_ATM_BR2684_IPFILTER - if (packet_fails_filter(skb->protocol, brvcc, skb)) { - brdev->stats.rx_dropped++; - dev_kfree_skb(skb); - return; - } --#endif /* CONFIG_ATM_BR2684_IPFILTER */ -+#endif /* CONFIG_ATM_BR2684_IPFILTER */ - skb->dev = &brdev->net_dev; -- ATM_SKB(skb)->vcc = atmvcc; /* needed ? */ -+ /* ATM_SKB(skb)->vcc = atmvcc; *//* needed ? */ - DPRINTK("received packet's protocol: %x\n", ntohs(skb->protocol)); - skb_debug(skb); -- if (!(brdev->net_dev.flags & IFF_UP)) { /* sigh, interface is down */ -+ if (!(brdev->net_dev.flags & IFF_UP)) { /* sigh, interface is down */ - brdev->stats.rx_dropped++; - dev_kfree_skb(skb); - return; - } - brdev->stats.rx_packets++; - brdev->stats.rx_bytes += skb->len; -- memset(ATM_SKB(skb), 0, sizeof(struct atm_skb_data)); - netif_rx(skb); - } - -@@ -529,10 +629,10 @@ Note: we do not have explicit unassign, - err = -EEXIST; - goto error; - } -- if (be.fcs_in != BR2684_FCSIN_NO || be.fcs_out != BR2684_FCSOUT_NO || -- be.fcs_auto || be.has_vpiid || be.send_padding || (be.encaps != -- BR2684_ENCAPS_VC && be.encaps != BR2684_ENCAPS_LLC) || -- be.min_size != 0) { -+ if (be.fcs_in != BR2684_FCSIN_NO || be.fcs_out != BR2684_FCSOUT_NO -+ || be.fcs_auto || be.has_vpiid || be.send_padding -+ || (be.encaps != BR2684_ENCAPS_VC -+ && be.encaps != BR2684_ENCAPS_LLC) || be.min_size != 0) { - err = -EINVAL; - goto error; - } -@@ -553,18 +653,21 @@ Note: we do not have explicit unassign, - brvcc->atmvcc = atmvcc; - atmvcc->user_back = brvcc; - brvcc->encaps = (enum br2684_encaps) be.encaps; -+ brvcc->payload = (enum br2684_payload) be.payload; - brvcc->old_push = atmvcc->push; - barrier(); - atmvcc->push = br2684_push; - skb_queue_head_init(©); - skb_migrate(&atmvcc->sk->receive_queue, ©); - while ((skb = skb_dequeue(©))) { -+#ifdef notdef - BRPRIV(skb->dev)->stats.rx_bytes -= skb->len; - BRPRIV(skb->dev)->stats.rx_packets--; -+#endif - br2684_push(atmvcc, skb); - } - return 0; -- error: -+ error: - write_unlock_irq(&devs_lock); - kfree(brvcc); - MOD_DEC_USE_COUNT; -@@ -608,12 +711,25 @@ static int br2684_create(unsigned long a - - if (ni.ifname[0] != '\0') { - memcpy(brdev->net_dev.name, ni.ifname, -- sizeof(brdev->net_dev.name)); -- brdev->net_dev.name[sizeof(brdev->net_dev.name) - 1] = '\0'; -+ sizeof(brdev->net_dev.name)); -+ brdev->net_dev.name[sizeof(brdev->net_dev.name) - 1] = -+ '\0'; - } else - sprintf(brdev->net_dev.name, "nas%d", brdev->number); - DPRINTK("registered netdev %s\n", brdev->net_dev.name); -- ether_setup(&brdev->net_dev); -+ if (ni.payload == p_routed) { -+ brdev->net_dev.hard_header_len = 0; -+ brdev->net_dev.addr_len = 0; -+ brdev->net_dev.mtu = 1500; -+ -+ /* Type PPP seems most suitable */ -+ brdev->net_dev.type = ARPHRD_PPP; -+ brdev->net_dev.flags = -+ IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST; -+ brdev->net_dev.tx_queue_len = 100; -+ } else { -+ ether_setup(&brdev->net_dev); -+ } - brdev->mac_was_set = 0; - #ifdef FASTER_VERSION - my_eth_header = brdev->net_dev.hard_header; -@@ -677,12 +793,11 @@ static int br2684_ioctl(struct atm_vcc * - err = br2684_setfilt(atmvcc, arg); - MOD_DEC_USE_COUNT; - return err; --#endif /* CONFIG_ATM_BR2684_IPFILTER */ -+#endif /* CONFIG_ATM_BR2684_IPFILTER */ - } - return -ENOIOCTLCMD; - } - --#ifdef CONFIG_PROC_FS - /* Never put more than 256 bytes in at once */ - static int br2684_proc_engine(loff_t pos, char *buf) - { -@@ -692,52 +807,62 @@ static int br2684_proc_engine(loff_t pos - list_for_each(lhd, &br2684_devs) { - brdev = list_entry_brdev(lhd); - if (pos-- == 0) -- return sprintf(buf, "dev %.16s: num=%d, mac=%02X:%02X:" -- "%02X:%02X:%02X:%02X (%s)\n", brdev->net_dev.name, -- brdev->number, -- brdev->net_dev.dev_addr[0], -- brdev->net_dev.dev_addr[1], -- brdev->net_dev.dev_addr[2], -- brdev->net_dev.dev_addr[3], -- brdev->net_dev.dev_addr[4], -- brdev->net_dev.dev_addr[5], -- brdev->mac_was_set ? "set" : "auto"); -+ return sprintf(buf, -+ "dev %.16s: num=%d, mac=%02X:%02X:" -+ "%02X:%02X:%02X:%02X (%s)\n", -+ brdev->net_dev.name, brdev->number, -+ brdev->net_dev.dev_addr[0], -+ brdev->net_dev.dev_addr[1], -+ brdev->net_dev.dev_addr[2], -+ brdev->net_dev.dev_addr[3], -+ brdev->net_dev.dev_addr[4], -+ brdev->net_dev.dev_addr[5], -+ brdev-> -+ mac_was_set ? "set" : "auto"); - list_for_each(lhc, &brdev->brvccs) { - brvcc = list_entry_brvcc(lhc); - if (pos-- == 0) -- return sprintf(buf, " vcc %d.%d.%d: encaps=%s" -+ return sprintf(buf, -+ " vcc %d.%d.%d: encaps=%s" -+ ", payload=%s" - #ifndef FASTER_VERSION -- ", failed copies %u/%u" --#endif /* FASTER_VERSION */ -- "\n", brvcc->atmvcc->dev->number, -- brvcc->atmvcc->vpi, brvcc->atmvcc->vci, -- (brvcc->encaps == e_llc) ? "LLC" : "VC" -+ ", failed copies %u/%u" -+#endif /* FASTER_VERSION */ -+ "\n", -+ brvcc->atmvcc->dev->number, -+ brvcc->atmvcc->vpi, -+ brvcc->atmvcc->vci, -+ (brvcc->encaps == -+ e_llc) ? "LLC" : "VC", -+ (brvcc->payload == -+ p_bridged) ? "bridged" : -+ "routed" - #ifndef FASTER_VERSION -- , brvcc->copies_failed -- , brvcc->copies_needed --#endif /* FASTER_VERSION */ -+ , brvcc->copies_failed, -+ brvcc->copies_needed -+#endif /* FASTER_VERSION */ - ); - #ifdef CONFIG_ATM_BR2684_IPFILTER - #define b1(var, byte) ((u8 *) &brvcc->filter.var)[byte] - #define bs(var) b1(var, 0), b1(var, 1), b1(var, 2), b1(var, 3) - if (brvcc->filter.netmask != 0 && pos-- == 0) -- return sprintf(buf, " filter=%d.%d.%d.%d/" -- "%d.%d.%d.%d\n", bs(prefix), bs(netmask)); -+ return sprintf(buf, -+ " filter=%d.%d.%d.%d/" -+ "%d.%d.%d.%d\n", bs(prefix), -+ bs(netmask)); - #undef bs - #undef b1 --#endif /* CONFIG_ATM_BR2684_IPFILTER */ -+#endif /* CONFIG_ATM_BR2684_IPFILTER */ - } - } - return 0; - } - - static ssize_t br2684_proc_read(struct file *file, char *buf, size_t count, -- loff_t *pos) -+ loff_t * pos) - { - unsigned long page; - int len = 0, x, left; -- loff_t n = *pos; -- - page = get_free_page(GFP_KERNEL); - if (!page) - return -ENOMEM; -@@ -746,7 +871,7 @@ static ssize_t br2684_proc_read(struct f - left = count; - read_lock(&devs_lock); - for (;;) { -- x = br2684_proc_engine(n, &((char *) page)[len]); -+ x = br2684_proc_engine(*pos, &((char *) page)[len]); - if (x == 0) - break; - if (x > left) -@@ -761,12 +886,11 @@ static ssize_t br2684_proc_read(struct f - } - len += x; - left -= x; -- n++; -+ (*pos)++; - if (left < 256) - break; - } - read_unlock(&devs_lock); -- *pos = n; - if (len > 0 && copy_to_user(buf, (char *) page, len)) - len = -EFAULT; - free_page(page); -@@ -774,23 +898,20 @@ static ssize_t br2684_proc_read(struct f - } - - static struct file_operations br2684_proc_operations = { -- read: br2684_proc_read, -+ read:br2684_proc_read, - }; - - extern struct proc_dir_entry *atm_proc_root; /* from proc.c */ --#endif /* CONFIG_PROC_FS */ - - /* the following avoids some spurious warnings from the compiler */ - #define UNUSED __attribute__((unused)) - - static int __init UNUSED br2684_init(void) - { --#ifdef CONFIG_PROC_FS - struct proc_dir_entry *p; - if ((p = create_proc_entry("br2684", 0, atm_proc_root)) == NULL) - return -ENOMEM; - p->proc_fops = &br2684_proc_operations; --#endif /* CONFIG_PROC_FS */ - br2684_ioctl_set(br2684_ioctl); - return 0; - } -@@ -799,9 +920,7 @@ static void __exit UNUSED br2684_exit(vo - { - struct br2684_dev *brdev; - br2684_ioctl_set(NULL); --#ifdef CONFIG_PROC_FS - remove_proc_entry("br2684", atm_proc_root); --#endif /* CONFIG_PROC_FS */ - while (!list_empty(&br2684_devs)) { - brdev = list_entry_brdev(br2684_devs.next); - unregister_netdev(&brdev->net_dev); ---- a/net/atm/common.c -+++ b/net/atm/common.c -@@ -158,6 +158,7 @@ void br2684_ioctl_set(int (*hook)(struct - } - #ifdef CONFIG_ATM_BR2684_MODULE - EXPORT_SYMBOL(br2684_ioctl_set); -+EXPORT_SYMBOL(br2684_ioctl_hook); - #endif - #endif - ---- a/include/linux/atmbr2684.h -+++ b/include/linux/atmbr2684.h -@@ -3,6 +3,7 @@ - - #include <linux/atm.h> - #include <linux/if.h> /* For IFNAMSIZ */ -+#include <linux/if_ether.h> /* ETH_P_* */ - - /* - * Type of media we're bridging (ethernet, token ring, etc) Currently only -@@ -36,15 +37,24 @@ - #define BR2684_ENCAPS_AUTODETECT (2) /* Unsuported */ - - /* -+ * Is this VC bridged or routed? -+ */ -+ -+#define BR2684_PAYLOAD_ROUTED (0) -+#define BR2684_PAYLOAD_BRIDGED (1) -+ -+ -+/* - * This is for the ATM_NEWBACKENDIF call - these are like socket families: - * the first element of the structure is the backend number and the rest - * is per-backend specific - */ - struct atm_newif_br2684 { -- atm_backend_t backend_num; /* ATM_BACKEND_BR2684 */ -- int media; /* BR2684_MEDIA_* */ -- char ifname[IFNAMSIZ]; -- int mtu; -+ atm_backend_t backend_num; /* ATM_BACKEND_BR2684 */ -+ int media; /* BR2684_MEDIA_* */ -+ char ifname[IFNAMSIZ]; -+ int mtu; -+ int payload; /* bridged or routed */ - }; - - /* -@@ -68,16 +78,17 @@ struct br2684_if_spec { - * is per-backend specific - */ - struct atm_backend_br2684 { -- atm_backend_t backend_num; /* ATM_BACKEND_BR2684 */ -+ atm_backend_t backend_num; /* ATM_BACKEND_BR2684 */ - struct br2684_if_spec ifspec; -- int fcs_in; /* BR2684_FCSIN_* */ -- int fcs_out; /* BR2684_FCSOUT_* */ -- int fcs_auto; /* 1: fcs_{in,out} disabled if no FCS rx'ed */ -- int encaps; /* BR2684_ENCAPS_* */ -- int has_vpiid; /* 1: use vpn_id - Unsupported */ -- __u8 vpn_id[7]; -- int send_padding; /* unsupported */ -- int min_size; /* we will pad smaller packets than this */ -+ int fcs_in; /* BR2684_FCSIN_* */ -+ int fcs_out; /* BR2684_FCSOUT_* */ -+ int fcs_auto; /* 1: fcs_{in,out} disabled if no FCS rx'ed */ -+ int encaps; /* BR2684_ENCAPS_* */ -+ int payload; /* BR2684_PAYLOAD_* */ -+ int has_vpiid; /* 1: use vpn_id - Unsupported */ -+ __u8 vpn_id[7]; -+ int send_padding; /* unsupported */ -+ int min_size; /* we will pad smaller packets than this */ - }; - - /* -@@ -95,7 +106,12 @@ struct br2684_filter_set { - struct br2684_filter filter; - }; - -+enum br2684_payload { -+ p_routed = BR2684_PAYLOAD_ROUTED, -+ p_bridged = BR2684_PAYLOAD_BRIDGED, -+}; -+ - #define BR2684_SETFILT _IOW( 'a', ATMIOC_BACKEND + 0, \ - struct br2684_filter_set) - --#endif /* _LINUX_ATMBR2684_H */ -+#endif /* _LINUX_ATMBR2684_H */ diff --git a/target/linux/generic-2.4/patches/227-jffs2_eofdetect.patch b/target/linux/generic-2.4/patches/227-jffs2_eofdetect.patch deleted file mode 100644 index 196693d..0000000 --- a/target/linux/generic-2.4/patches/227-jffs2_eofdetect.patch +++ /dev/null @@ -1,95 +0,0 @@ ---- a/fs/jffs2/build.c -+++ b/fs/jffs2/build.c -@@ -31,6 +31,10 @@ - * provisions above, a recipient may use your version of this file - * under either the RHEPL or the GPL. - * -+ * Modification for automatically cleaning the filesystem after -+ * a specially marked block -+ * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org> -+ * - * $Id: build.c,v 1.16.2.3 2003/04/30 09:43:32 dwmw2 Exp $ - * - */ -@@ -38,6 +42,7 @@ - #include <linux/kernel.h> - #include <linux/jffs2.h> - #include <linux/slab.h> -+#include <linux/mtd/mtd.h> - #include "nodelist.h" - - int jffs2_build_inode_pass1(struct jffs2_sb_info *, struct jffs2_inode_cache *); -@@ -89,6 +94,18 @@ int jffs2_build_filesystem(struct jffs2_ - if (ret) - return ret; - -+ if (c->flags & (1 << 7)) { -+ printk("%s(): unlocking the mtd device... ", __func__); -+ if (c->mtd->unlock) -+ c->mtd->unlock(c->mtd, 0, c->mtd->size); -+ printk("done.\n"); -+ -+ printk("%s(): erasing all blocks after the end marker... ", __func__); -+ jffs2_erase_pending_blocks(c); -+ jffs2_mark_erased_blocks(c); -+ printk("done.\n"); -+ } -+ - D1(printk(KERN_DEBUG "Scanned flash completely\n")); - /* Now build the data map for each inode, marking obsoleted nodes - as such, and also increase nlink of any children. */ ---- a/fs/jffs2/scan.c -+++ b/fs/jffs2/scan.c -@@ -31,6 +31,10 @@ - * provisions above, a recipient may use your version of this file - * under either the RHEPL or the GPL. - * -+ * Modification for automatically cleaning the filesystem after -+ * a specially marked block -+ * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org> -+ * - * $Id: scan.c,v 1.51.2.4 2003/11/02 13:51:18 dwmw2 Exp $ - * - */ -@@ -88,7 +92,12 @@ int jffs2_scan_medium(struct jffs2_sb_in - for (i=0; i<c->nr_blocks; i++) { - struct jffs2_eraseblock *jeb = &c->blocks[i]; - -- ret = jffs2_scan_eraseblock(c, jeb); -+ -+ if (c->flags & (1 << 7)) -+ ret = 1; -+ else -+ ret = jffs2_scan_eraseblock(c, jeb); -+ - if (ret < 0) - return ret; - -@@ -181,6 +190,7 @@ static int jffs2_scan_eraseblock (struct - - while(ofs < jeb->offset + c->sector_size) { - ssize_t retlen; -+ unsigned char *buf = (unsigned char *) &node; - ACCT_PARANOIA_CHECK(jeb); - - if (ofs & 3) { -@@ -202,8 +212,18 @@ static int jffs2_scan_eraseblock (struct - break; - } - -- err = c->mtd->read(c->mtd, ofs, sizeof(node), &retlen, (char *)&node); -+ err = c->mtd->read(c->mtd, ofs, sizeof(node), &retlen, buf); -+ if ((buf[0] == 0xde) && -+ (buf[1] == 0xad) && -+ (buf[2] == 0xc0) && -+ (buf[3] == 0xde)) { -+ -+ /* end of filesystem. erase everything after this point */ -+ c->flags |= (1 << 7); -+ printk("jffs2_scan_eraseblock(): End of filesystem marker found at 0x%x\n", jeb->offset); - -+ return 1; -+ } - if (err) { - D1(printk(KERN_WARNING "mtd->read(0x%x bytes from 0x%x) returned %d\n", sizeof(node), ofs, err)); - return err; diff --git a/target/linux/generic-2.4/patches/228-more_usb_fixes.patch b/target/linux/generic-2.4/patches/228-more_usb_fixes.patch deleted file mode 100644 index 16b554a..0000000 --- a/target/linux/generic-2.4/patches/228-more_usb_fixes.patch +++ /dev/null @@ -1,843 +0,0 @@ ---- a/drivers/scsi/hosts.c -+++ b/drivers/scsi/hosts.c -@@ -107,8 +107,21 @@ scsi_unregister(struct Scsi_Host * sh){ - if (shn) shn->host_registered = 0; - /* else {} : This should not happen, we should panic here... */ - -+ /* If we are removing the last host registered, it is safe to reuse -+ * its host number (this avoids "holes" at boot time) (DB) -+ * It is also safe to reuse those of numbers directly below which have -+ * been released earlier (to avoid some holes in numbering). -+ */ -+ if(sh->host_no == max_scsi_hosts - 1) { -+ while(--max_scsi_hosts >= next_scsi_host) { -+ shpnt = scsi_hostlist; -+ while(shpnt && shpnt->host_no != max_scsi_hosts - 1) -+ shpnt = shpnt->next; -+ if(shpnt) -+ break; -+ } -+ } - next_scsi_host--; -- - kfree((char *) sh); - } - ---- a/drivers/usb/hcd.c -+++ b/drivers/usb/hcd.c -@@ -1105,7 +1105,8 @@ static int hcd_submit_urb (struct urb *u - break; - case PIPE_BULK: - allowed |= USB_DISABLE_SPD | USB_QUEUE_BULK -- | USB_ZERO_PACKET | URB_NO_INTERRUPT; -+ | USB_ZERO_PACKET | URB_NO_INTERRUPT -+ | URB_NO_TRANSFER_DMA_MAP; - break; - case PIPE_INTERRUPT: - allowed |= USB_DISABLE_SPD; -@@ -1212,7 +1213,8 @@ static int hcd_submit_urb (struct urb *u - urb->setup_packet, - sizeof (struct usb_ctrlrequest), - PCI_DMA_TODEVICE); -- if (urb->transfer_buffer_length != 0) -+ if (urb->transfer_buffer_length != 0 -+ && !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)) - urb->transfer_dma = pci_map_single ( - hcd->pdev, - urb->transfer_buffer, ---- a/drivers/usb/host/ehci-hcd.c -+++ b/drivers/usb/host/ehci-hcd.c -@@ -399,6 +399,27 @@ static int ehci_start (struct usb_hcd *h - ehci_mem_cleanup (ehci); - return retval; - } -+ -+{ -+ int misc_reg; -+ u32 vendor_id; -+ -+ pci_read_config_dword (ehci->hcd.pdev, PCI_VENDOR_ID, &vendor_id); -+ if (vendor_id == 0x31041106) { -+ /* VIA 6212 */ -+ printk(KERN_INFO "EHCI: Enabling VIA 6212 workarounds\n", misc_reg); -+ pci_read_config_byte(ehci->hcd.pdev, 0x49, &misc_reg); -+ misc_reg &= ~0x20; -+ pci_write_config_byte(ehci->hcd.pdev, 0x49, misc_reg); -+ pci_read_config_byte(ehci->hcd.pdev, 0x49, &misc_reg); -+ -+ pci_read_config_byte(ehci->hcd.pdev, 0x4b, &misc_reg); -+ misc_reg |= 0x20; -+ pci_write_config_byte(ehci->hcd.pdev, 0x4b, misc_reg); -+ pci_read_config_byte(ehci->hcd.pdev, 0x4b, &misc_reg); -+ } -+} -+ - writel (INTR_MASK, &ehci->regs->intr_enable); - writel (ehci->periodic_dma, &ehci->regs->frame_list); - ---- a/drivers/usb/host/ehci-q.c -+++ b/drivers/usb/host/ehci-q.c -@@ -791,6 +791,8 @@ static void qh_link_async (struct ehci_h - writel (cmd, &ehci->regs->command); - ehci->hcd.state = USB_STATE_RUNNING; - /* posted write need not be known to HC yet ... */ -+ -+ timer_action (ehci, TIMER_IO_WATCHDOG); - } - } - ---- a/drivers/usb/host/usb-uhci.c -+++ b/drivers/usb/host/usb-uhci.c -@@ -3034,6 +3034,21 @@ uhci_pci_probe (struct pci_dev *dev, con - - pci_set_master(dev); - -+ { -+ u8 misc_reg; -+ u32 vendor_id; -+ -+ pci_read_config_dword (dev, PCI_VENDOR_ID, &vendor_id); -+ if (vendor_id == 0x30381106) { -+ /* VIA 6212 */ -+ printk(KERN_INFO "UHCI: Enabling VIA 6212 workarounds\n"); -+ pci_read_config_byte(dev, 0x41, &misc_reg); -+ misc_reg &= ~0x10; -+ pci_write_config_byte(dev, 0x41, misc_reg); -+ pci_read_config_byte(dev, 0x41, &misc_reg); -+ } -+ } -+ - /* Search for the IO base address.. */ - for (i = 0; i < 6; i++) { - ---- a/drivers/usb/storage/transport.c -+++ b/drivers/usb/storage/transport.c -@@ -54,6 +54,22 @@ - #include <linux/sched.h> - #include <linux/errno.h> - #include <linux/slab.h> -+#include <linux/pci.h> -+#include "../hcd.h" -+ -+/* These definitions mirror those in pci.h, so they can be used -+ * interchangeably with their PCI_ counterparts */ -+enum dma_data_direction { -+ DMA_BIDIRECTIONAL = 0, -+ DMA_TO_DEVICE = 1, -+ DMA_FROM_DEVICE = 2, -+ DMA_NONE = 3, -+}; -+ -+#define dma_map_sg(d,s,n,dir) pci_map_sg(d,s,n,dir) -+#define dma_unmap_sg(d,s,n,dir) pci_unmap_sg(d,s,n,dir) -+ -+ - - /*********************************************************************** - * Helper routines -@@ -554,6 +570,543 @@ int usb_stor_transfer_partial(struct us_ - return US_BULK_TRANSFER_SHORT; - } - -+/*-------------------------------------------------------------------*/ -+/** -+ * usb_buffer_unmap_sg - free DMA mapping(s) for a scatterlist -+ * @dev: device to which the scatterlist will be mapped -+ * @pipe: endpoint defining the mapping direction -+ * @sg: the scatterlist to unmap -+ * @n_hw_ents: the positive return value from usb_buffer_map_sg -+ * -+ * Reverses the effect of usb_buffer_map_sg(). -+ */ -+static void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe, -+ struct scatterlist *sg, int n_hw_ents) -+{ -+ struct usb_bus *bus; -+ struct usb_hcd *hcd; -+ struct pci_dev *pdev; -+ -+ if (!dev -+ || !(bus = dev->bus) -+ || !(hcd = bus->hcpriv) -+ || !(pdev = hcd->pdev) -+ || !pdev->dma_mask) -+ return; -+ -+ dma_unmap_sg (pdev, sg, n_hw_ents, -+ usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); -+} -+ -+/** -+ * usb_buffer_map_sg - create scatterlist DMA mapping(s) for an endpoint -+ * @dev: device to which the scatterlist will be mapped -+ * @pipe: endpoint defining the mapping direction -+ * @sg: the scatterlist to map -+ * @nents: the number of entries in the scatterlist -+ * -+ * Return value is either < 0 (indicating no buffers could be mapped), or -+ * the number of DMA mapping array entries in the scatterlist. -+ * -+ * The caller is responsible for placing the resulting DMA addresses from -+ * the scatterlist into URB transfer buffer pointers, and for setting the -+ * URB_NO_TRANSFER_DMA_MAP transfer flag in each of those URBs. -+ * -+ * Top I/O rates come from queuing URBs, instead of waiting for each one -+ * to complete before starting the next I/O. This is particularly easy -+ * to do with scatterlists. Just allocate and submit one URB for each DMA -+ * mapping entry returned, stopping on the first error or when all succeed. -+ * Better yet, use the usb_sg_*() calls, which do that (and more) for you. -+ * -+ * This call would normally be used when translating scatterlist requests, -+ * rather than usb_buffer_map(), since on some hardware (with IOMMUs) it -+ * may be able to coalesce mappings for improved I/O efficiency. -+ * -+ * Reverse the effect of this call with usb_buffer_unmap_sg(). -+ */ -+static int usb_buffer_map_sg (struct usb_device *dev, unsigned pipe, -+ struct scatterlist *sg, int nents) -+{ -+ struct usb_bus *bus; -+ struct usb_hcd *hcd; -+ struct pci_dev *pdev; -+ -+ if (!dev -+ || usb_pipecontrol (pipe) -+ || !(bus = dev->bus) -+ || !(hcd = bus->hcpriv) -+ || !(pdev = hcd->pdev) -+ || !pdev->dma_mask) -+ return -1; -+ -+ // FIXME generic api broken like pci, can't report errors -+ return dma_map_sg (pdev, sg, nents, -+ usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); -+} -+ -+static void sg_clean (struct usb_sg_request *io) -+{ -+ struct usb_hcd *hcd = io->dev->bus->hcpriv; -+ struct pci_dev *pdev = hcd->pdev; -+ -+ if (io->urbs) { -+ while (io->entries--) -+ usb_free_urb (io->urbs [io->entries]); -+ kfree (io->urbs); -+ io->urbs = 0; -+ } -+ if (pdev->dma_mask != 0) -+ usb_buffer_unmap_sg (io->dev, io->pipe, io->sg, io->nents); -+ io->dev = 0; -+} -+ -+static void sg_complete (struct urb *urb) -+{ -+ struct usb_sg_request *io = (struct usb_sg_request *) urb->context; -+ -+ spin_lock (&io->lock); -+ -+ /* In 2.5 we require hcds' endpoint queues not to progress after fault -+ * reports, until the completion callback (this!) returns. That lets -+ * device driver code (like this routine) unlink queued urbs first, -+ * if it needs to, since the HC won't work on them at all. So it's -+ * not possible for page N+1 to overwrite page N, and so on. -+ * -+ * That's only for "hard" faults; "soft" faults (unlinks) sometimes -+ * complete before the HCD can get requests away from hardware, -+ * though never during cleanup after a hard fault. -+ */ -+ if (io->status -+ && (io->status != -ECONNRESET -+ || urb->status != -ECONNRESET) -+ && urb->actual_length) { -+ US_DEBUGP("Error: %s ep%d%s scatterlist error %d/%d\n", -+ io->dev->devpath, -+ usb_pipeendpoint (urb->pipe), -+ usb_pipein (urb->pipe) ? "in" : "out", -+ urb->status, io->status); -+ // BUG (); -+ } -+ -+ if (urb->status && urb->status != -ECONNRESET) { -+ int i, found, status; -+ -+ io->status = urb->status; -+ -+ /* the previous urbs, and this one, completed already. -+ * unlink pending urbs so they won't rx/tx bad data. -+ */ -+ for (i = 0, found = 0; i < io->entries; i++) { -+ if (!io->urbs [i]) -+ continue; -+ if (found) { -+ status = usb_unlink_urb (io->urbs [i]); -+ if (status != -EINPROGRESS && status != -EBUSY) -+ US_DEBUGP("Error: %s, unlink --> %d\n", __FUNCTION__, status); -+ } else if (urb == io->urbs [i]) -+ found = 1; -+ } -+ } -+ urb->dev = 0; -+ -+ /* on the last completion, signal usb_sg_wait() */ -+ io->bytes += urb->actual_length; -+ io->count--; -+ if (!io->count) -+ complete (&io->complete); -+ -+ spin_unlock (&io->lock); -+} -+ -+/** -+ * usb_sg_init - initializes scatterlist-based bulk/interrupt I/O request -+ * @io: request block being initialized. until usb_sg_wait() returns, -+ * treat this as a pointer to an opaque block of memory, -+ * @dev: the usb device that will send or receive the data -+ * @pipe: endpoint "pipe" used to transfer the data -+ * @period: polling rate for interrupt endpoints, in frames or -+ * (for high speed endpoints) microframes; ignored for bulk -+ * @sg: scatterlist entries -+ * @nents: how many entries in the scatterlist -+ * @length: how many bytes to send from the scatterlist, or zero to -+ * send every byte identified in the list. -+ * @mem_flags: SLAB_* flags affecting memory allocations in this call -+ * -+ * Returns zero for success, else a negative errno value. This initializes a -+ * scatter/gather request, allocating resources such as I/O mappings and urb -+ * memory (except maybe memory used by USB controller drivers). -+ * -+ * The request must be issued using usb_sg_wait(), which waits for the I/O to -+ * complete (or to be canceled) and then cleans up all resources allocated by -+ * usb_sg_init(). -+ * -+ * The request may be canceled with usb_sg_cancel(), either before or after -+ * usb_sg_wait() is called. -+ */ -+int usb_sg_init ( -+ struct usb_sg_request *io, -+ struct usb_device *dev, -+ unsigned pipe, -+ unsigned period, -+ struct scatterlist *sg, -+ int nents, -+ size_t length, -+ int mem_flags -+) -+{ -+ int i; -+ int urb_flags; -+ int dma; -+ struct usb_hcd *hcd; -+ -+ hcd = dev->bus->hcpriv; -+ -+ if (!io || !dev || !sg -+ || usb_pipecontrol (pipe) -+ || usb_pipeisoc (pipe) -+ || nents <= 0) -+ return -EINVAL; -+ -+ spin_lock_init (&io->lock); -+ io->dev = dev; -+ io->pipe = pipe; -+ io->sg = sg; -+ io->nents = nents; -+ -+ /* not all host controllers use DMA (like the mainstream pci ones); -+ * they can use PIO (sl811) or be software over another transport. -+ */ -+ dma = (hcd->pdev->dma_mask != 0); -+ if (dma) -+ io->entries = usb_buffer_map_sg (dev, pipe, sg, nents); -+ else -+ io->entries = nents; -+ -+ /* initialize all the urbs we'll use */ -+ if (io->entries <= 0) -+ return io->entries; -+ -+ io->count = 0; -+ io->urbs = kmalloc (io->entries * sizeof *io->urbs, mem_flags); -+ if (!io->urbs) -+ goto nomem; -+ -+ urb_flags = USB_ASYNC_UNLINK | URB_NO_INTERRUPT | URB_NO_TRANSFER_DMA_MAP; -+ if (usb_pipein (pipe)) -+ urb_flags |= URB_SHORT_NOT_OK; -+ -+ for (i = 0; i < io->entries; i++, io->count = i) { -+ unsigned len; -+ -+ io->urbs [i] = usb_alloc_urb (0); -+ if (!io->urbs [i]) { -+ io->entries = i; -+ goto nomem; -+ } -+ -+ io->urbs [i]->dev = 0; -+ io->urbs [i]->pipe = pipe; -+ io->urbs [i]->interval = period; -+ io->urbs [i]->transfer_flags = urb_flags; -+ -+ io->urbs [i]->complete = sg_complete; -+ io->urbs [i]->context = io; -+ io->urbs [i]->status = -EINPROGRESS; -+ io->urbs [i]->actual_length = 0; -+ -+ if (dma) { -+ /* hc may use _only_ transfer_dma */ -+ io->urbs [i]->transfer_dma = sg_dma_address (sg + i); -+ len = sg_dma_len (sg + i); -+ } else { -+ /* hc may use _only_ transfer_buffer */ -+ io->urbs [i]->transfer_buffer = -+ page_address (sg [i].page) + sg [i].offset; -+ len = sg [i].length; -+ } -+ -+ if (length) { -+ len = min_t (unsigned, len, length); -+ length -= len; -+ if (length == 0) -+ io->entries = i + 1; -+ } -+ io->urbs [i]->transfer_buffer_length = len; -+ } -+ io->urbs [--i]->transfer_flags &= ~URB_NO_INTERRUPT; -+ -+ /* transaction state */ -+ io->status = 0; -+ io->bytes = 0; -+ init_completion (&io->complete); -+ return 0; -+ -+nomem: -+ sg_clean (io); -+ return -ENOMEM; -+} -+ -+/** -+ * usb_sg_cancel - stop scatter/gather i/o issued by usb_sg_wait() -+ * @io: request block, initialized with usb_sg_init() -+ * -+ * This stops a request after it has been started by usb_sg_wait(). -+ * It can also prevents one initialized by usb_sg_init() from starting, -+ * so that call just frees resources allocated to the request. -+ */ -+void usb_sg_cancel (struct usb_sg_request *io) -+{ -+ unsigned long flags; -+ -+ spin_lock_irqsave (&io->lock, flags); -+ -+ /* shut everything down, if it didn't already */ -+ if (!io->status) { -+ int i; -+ -+ io->status = -ECONNRESET; -+ for (i = 0; i < io->entries; i++) { -+ int retval; -+ -+ if (!io->urbs [i]->dev) -+ continue; -+ retval = usb_unlink_urb (io->urbs [i]); -+ if (retval != -EINPROGRESS && retval != -EBUSY) -+ US_DEBUGP("WARNING: %s, unlink --> %d\n", __FUNCTION__, retval); -+ } -+ } -+ spin_unlock_irqrestore (&io->lock, flags); -+} -+ -+/** -+ * usb_sg_wait - synchronously execute scatter/gather request -+ * @io: request block handle, as initialized with usb_sg_init(). -+ * some fields become accessible when this call returns. -+ * Context: !in_interrupt () -+ * -+ * This function blocks until the specified I/O operation completes. It -+ * leverages the grouping of the related I/O requests to get good transfer -+ * rates, by queueing the requests. At higher speeds, such queuing can -+ * significantly improve USB throughput. -+ * -+ * There are three kinds of completion for this function. -+ * (1) success, where io->status is zero. The number of io->bytes -+ * transferred is as requested. -+ * (2) error, where io->status is a negative errno value. The number -+ * of io->bytes transferred before the error is usually less -+ * than requested, and can be nonzero. -+ * (3) cancelation, a type of error with status -ECONNRESET that -+ * is initiated by usb_sg_cancel(). -+ * -+ * When this function returns, all memory allocated through usb_sg_init() or -+ * this call will have been freed. The request block parameter may still be -+ * passed to usb_sg_cancel(), or it may be freed. It could also be -+ * reinitialized and then reused. -+ * -+ * Data Transfer Rates: -+ * -+ * Bulk transfers are valid for full or high speed endpoints. -+ * The best full speed data rate is 19 packets of 64 bytes each -+ * per frame, or 1216 bytes per millisecond. -+ * The best high speed data rate is 13 packets of 512 bytes each -+ * per microframe, or 52 KBytes per millisecond. -+ * -+ * The reason to use interrupt transfers through this API would most likely -+ * be to reserve high speed bandwidth, where up to 24 KBytes per millisecond -+ * could be transferred. That capability is less useful for low or full -+ * speed interrupt endpoints, which allow at most one packet per millisecond, -+ * of at most 8 or 64 bytes (respectively). -+ */ -+void usb_sg_wait (struct usb_sg_request *io) -+{ -+ int i, entries = io->entries; -+ -+ /* queue the urbs. */ -+ spin_lock_irq (&io->lock); -+ for (i = 0; i < entries && !io->status; i++) { -+ int retval; -+ -+ io->urbs [i]->dev = io->dev; -+ retval = usb_submit_urb (io->urbs [i]); -+ -+ /* after we submit, let completions or cancelations fire; -+ * we handshake using io->status. -+ */ -+ spin_unlock_irq (&io->lock); -+ switch (retval) { -+ /* maybe we retrying will recover */ -+ case -ENXIO: // hc didn't queue this one -+ case -EAGAIN: -+ case -ENOMEM: -+ io->urbs [i]->dev = 0; -+ retval = 0; -+ i--; -+ yield (); -+ break; -+ -+ /* no error? continue immediately. -+ * -+ * NOTE: to work better with UHCI (4K I/O buffer may -+ * need 3K of TDs) it may be good to limit how many -+ * URBs are queued at once; N milliseconds? -+ */ -+ case 0: -+ cpu_relax (); -+ break; -+ -+ /* fail any uncompleted urbs */ -+ default: -+ spin_lock_irq (&io->lock); -+ io->count -= entries - i; -+ if (io->status == -EINPROGRESS) -+ io->status = retval; -+ if (io->count == 0) -+ complete (&io->complete); -+ spin_unlock_irq (&io->lock); -+ -+ io->urbs [i]->dev = 0; -+ io->urbs [i]->status = retval; -+ -+ US_DEBUGP("%s, submit --> %d\n", __FUNCTION__, retval); -+ usb_sg_cancel (io); -+ } -+ spin_lock_irq (&io->lock); -+ if (retval && io->status == -ECONNRESET) -+ io->status = retval; -+ } -+ spin_unlock_irq (&io->lock); -+ -+ /* OK, yes, this could be packaged as non-blocking. -+ * So could the submit loop above ... but it's easier to -+ * solve neither problem than to solve both! -+ */ -+ wait_for_completion (&io->complete); -+ -+ sg_clean (io); -+} -+ -+/* -+ * Interpret the results of a URB transfer -+ * -+ * This function prints appropriate debugging messages, clears halts on -+ * non-control endpoints, and translates the status to the corresponding -+ * USB_STOR_XFER_xxx return code. -+ */ -+static int interpret_urb_result(struct us_data *us, unsigned int pipe, -+ unsigned int length, int result, unsigned int partial) -+{ -+ US_DEBUGP("Status code %d; transferred %u/%u\n", -+ result, partial, length); -+ switch (result) { -+ -+ /* no error code; did we send all the data? */ -+ case 0: -+ if (partial != length) { -+ US_DEBUGP("-- short transfer\n"); -+ return USB_STOR_XFER_SHORT; -+ } -+ -+ US_DEBUGP("-- transfer complete\n"); -+ return USB_STOR_XFER_GOOD; -+ -+ /* stalled */ -+ case -EPIPE: -+ /* for control endpoints, (used by CB[I]) a stall indicates -+ * a failed command */ -+ if (usb_pipecontrol(pipe)) { -+ US_DEBUGP("-- stall on control pipe\n"); -+ return USB_STOR_XFER_STALLED; -+ } -+ -+ /* for other sorts of endpoint, clear the stall */ -+ US_DEBUGP("clearing endpoint halt for pipe 0x%x\n", pipe); -+ if (usb_stor_clear_halt(us, pipe) < 0) -+ return USB_STOR_XFER_ERROR; -+ return USB_STOR_XFER_STALLED; -+ -+ /* timeout or excessively long NAK */ -+ case -ETIMEDOUT: -+ US_DEBUGP("-- timeout or NAK\n"); -+ return USB_STOR_XFER_ERROR; -+ -+ /* babble - the device tried to send more than we wanted to read */ -+ case -EOVERFLOW: -+ US_DEBUGP("-- babble\n"); -+ return USB_STOR_XFER_LONG; -+ -+ /* the transfer was cancelled by abort, disconnect, or timeout */ -+ case -ECONNRESET: -+ US_DEBUGP("-- transfer cancelled\n"); -+ return USB_STOR_XFER_ERROR; -+ -+ /* short scatter-gather read transfer */ -+ case -EREMOTEIO: -+ US_DEBUGP("-- short read transfer\n"); -+ return USB_STOR_XFER_SHORT; -+ -+ /* abort or disconnect in progress */ -+ case -EIO: -+ US_DEBUGP("-- abort or disconnect in progress\n"); -+ return USB_STOR_XFER_ERROR; -+ -+ /* the catch-all error case */ -+ default: -+ US_DEBUGP("-- unknown error\n"); -+ return USB_STOR_XFER_ERROR; -+ } -+} -+ -+/* -+ * Transfer a scatter-gather list via bulk transfer -+ * -+ * This function does basically the same thing as usb_stor_bulk_msg() -+ * above, but it uses the usbcore scatter-gather library. -+ */ -+int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe, -+ struct scatterlist *sg, int num_sg, unsigned int length, -+ unsigned int *act_len) -+{ -+ int result; -+ -+ /* don't submit s-g requests during abort/disconnect processing */ -+ if (us->flags & ABORTING_OR_DISCONNECTING) -+ return USB_STOR_XFER_ERROR; -+ -+ /* initialize the scatter-gather request block */ -+ US_DEBUGP("%s: xfer %u bytes, %d entries\n", __FUNCTION__, -+ length, num_sg); -+ result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0, -+ sg, num_sg, length, SLAB_NOIO); -+ if (result) { -+ US_DEBUGP("usb_sg_init returned %d\n", result); -+ return USB_STOR_XFER_ERROR; -+ } -+ -+ /* since the block has been initialized successfully, it's now -+ * okay to cancel it */ -+ set_bit(US_FLIDX_SG_ACTIVE, &us->flags); -+ -+ /* did an abort/disconnect occur during the submission? */ -+ if (us->flags & ABORTING_OR_DISCONNECTING) { -+ -+ /* cancel the request, if it hasn't been cancelled already */ -+ if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->flags)) { -+ US_DEBUGP("-- cancelling sg request\n"); -+ usb_sg_cancel(&us->current_sg); -+ } -+ } -+ -+ /* wait for the completion of the transfer */ -+ usb_sg_wait(&us->current_sg); -+ clear_bit(US_FLIDX_SG_ACTIVE, &us->flags); -+ -+ result = us->current_sg.status; -+ if (act_len) -+ *act_len = us->current_sg.bytes; -+ return interpret_urb_result(us, pipe, length, result, -+ us->current_sg.bytes); -+} -+ - /* - * Transfer an entire SCSI command's worth of data payload over the bulk - * pipe. -@@ -569,6 +1122,8 @@ void usb_stor_transfer(Scsi_Cmnd *srb, s - struct scatterlist *sg; - unsigned int total_transferred = 0; - unsigned int transfer_amount; -+ unsigned int partial; -+ unsigned int pipe; - - /* calculate how much we want to transfer */ - transfer_amount = usb_stor_transfer_length(srb); -@@ -585,23 +1140,34 @@ void usb_stor_transfer(Scsi_Cmnd *srb, s - * make the appropriate requests for each, until done - */ - sg = (struct scatterlist *) srb->request_buffer; -- for (i = 0; i < srb->use_sg; i++) { -- -- /* transfer the lesser of the next buffer or the -- * remaining data */ -- if (transfer_amount - total_transferred >= -- sg[i].length) { -- result = usb_stor_transfer_partial(us, -- sg[i].address, sg[i].length); -- total_transferred += sg[i].length; -- } else -- result = usb_stor_transfer_partial(us, -- sg[i].address, -- transfer_amount - total_transferred); -- -- /* if we get an error, end the loop here */ -- if (result) -- break; -+ if (us->pusb_dev->speed == USB_SPEED_HIGH) { -+ /* calculate the appropriate pipe information */ -+ if (us->srb->sc_data_direction == SCSI_DATA_READ) -+ pipe = usb_rcvbulkpipe(us->pusb_dev, us->ep_in); -+ else -+ pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out); -+ /* use the usb core scatter-gather primitives */ -+ result = usb_stor_bulk_transfer_sglist(us, pipe, -+ sg, srb->use_sg, transfer_amount, &partial); -+ } else { -+ for (i = 0; i < srb->use_sg; i++) { -+ -+ /* transfer the lesser of the next buffer or the -+ * remaining data */ -+ if (transfer_amount - total_transferred >= -+ sg[i].length) { -+ result = usb_stor_transfer_partial(us, -+ sg[i].address, sg[i].length); -+ total_transferred += sg[i].length; -+ } else -+ result = usb_stor_transfer_partial(us, -+ sg[i].address, -+ transfer_amount - total_transferred); -+ -+ /* if we get an error, end the loop here */ -+ if (result) -+ break; -+ } - } - } - else ---- a/drivers/usb/storage/transport.h -+++ b/drivers/usb/storage/transport.h -@@ -127,6 +127,16 @@ struct bulk_cs_wrap { - #define US_BULK_TRANSFER_ABORTED 3 /* transfer canceled */ - - /* -+ * usb_stor_bulk_transfer_xxx() return codes, in order of severity -+ */ -+ -+#define USB_STOR_XFER_GOOD 0 /* good transfer */ -+#define USB_STOR_XFER_SHORT 1 /* transferred less than expected */ -+#define USB_STOR_XFER_STALLED 2 /* endpoint stalled */ -+#define USB_STOR_XFER_LONG 3 /* device tried to send too much */ -+#define USB_STOR_XFER_ERROR 4 /* transfer died in the middle */ -+ -+/* - * Transport return codes - */ - ---- a/drivers/usb/storage/usb.h -+++ b/drivers/usb/storage/usb.h -@@ -111,6 +111,60 @@ typedef int (*trans_reset)(struct us_dat - typedef void (*proto_cmnd)(Scsi_Cmnd*, struct us_data*); - typedef void (*extra_data_destructor)(void *); /* extra data destructor */ - -+/* Dynamic flag definitions: used in set_bit() etc. */ -+#define US_FLIDX_URB_ACTIVE 18 /* 0x00040000 current_urb is in use */ -+#define US_FLIDX_SG_ACTIVE 19 /* 0x00080000 current_sg is in use */ -+#define US_FLIDX_ABORTING 20 /* 0x00100000 abort is in progress */ -+#define US_FLIDX_DISCONNECTING 21 /* 0x00200000 disconnect in progress */ -+#define ABORTING_OR_DISCONNECTING ((1UL << US_FLIDX_ABORTING) | \ -+ (1UL << US_FLIDX_DISCONNECTING)) -+#define US_FLIDX_RESETTING 22 /* 0x00400000 device reset in progress */ -+ -+/* processing state machine states */ -+#define US_STATE_IDLE 1 -+#define US_STATE_RUNNING 2 -+#define US_STATE_RESETTING 3 -+#define US_STATE_ABORTING 4 -+ -+/** -+ * struct usb_sg_request - support for scatter/gather I/O -+ * @status: zero indicates success, else negative errno -+ * @bytes: counts bytes transferred. -+ * -+ * These requests are initialized using usb_sg_init(), and then are used -+ * as request handles passed to usb_sg_wait() or usb_sg_cancel(). Most -+ * members of the request object aren't for driver access. -+ * -+ * The status and bytecount values are valid only after usb_sg_wait() -+ * returns. If the status is zero, then the bytecount matches the total -+ * from the request. -+ * -+ * After an error completion, drivers may need to clear a halt condition -+ * on the endpoint. -+ */ -+struct usb_sg_request { -+ int status; -+ size_t bytes; -+ -+ /* -+ * members below are private to usbcore, -+ * and are not provided for driver access! -+ */ -+ spinlock_t lock; -+ -+ struct usb_device *dev; -+ int pipe; -+ struct scatterlist *sg; -+ int nents; -+ -+ int entries; -+ struct urb **urbs; -+ -+ int count; -+ struct completion complete; -+}; -+ -+ - /* we allocate one of these for every device that we remember */ - struct us_data { - struct us_data *next; /* next device */ -@@ -171,6 +225,7 @@ struct us_data { - struct urb *current_urb; /* non-int USB requests */ - struct completion current_done; /* the done flag */ - unsigned int tag; /* tag for bulk CBW/CSW */ -+ struct usb_sg_request current_sg; /* scatter-gather req. */ - - /* the semaphore for sleeping the control thread */ - struct semaphore sema; /* to sleep thread on */ ---- a/include/linux/usb.h -+++ b/include/linux/usb.h -@@ -483,6 +483,8 @@ struct usb_driver { - #define URB_NO_INTERRUPT 0x0080 /* HINT: no non-error interrupt needed */ - /* ... less overhead for QUEUE_BULK */ - #define USB_TIMEOUT_KILLED 0x1000 // only set by HCD! -+#define URB_NO_TRANSFER_DMA_MAP 0x0400 /* urb->transfer_dma valid on submit */ -+#define URB_NO_SETUP_DMA_MAP 0x0800 /* urb->setup_dma valid on submit */ - - struct iso_packet_descriptor - { diff --git a/target/linux/generic-2.4/patches/229-usb_storage_16_byte_cdb.patch b/target/linux/generic-2.4/patches/229-usb_storage_16_byte_cdb.patch deleted file mode 100644 index f14abbb..0000000 --- a/target/linux/generic-2.4/patches/229-usb_storage_16_byte_cdb.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/drivers/usb/storage/scsiglue.c -+++ b/drivers/usb/storage/scsiglue.c -@@ -95,6 +95,11 @@ static int detect(struct SHT *sht) - if (us->host) { - us->host->hostdata[0] = (unsigned long)us; - us->host_no = us->host->host_no; -+ -+ /* allow 16-byte CDBs as we need it for devices > 2TB -+ and ATA command pass-through */ -+ us->host->max_cmd_len = 16; -+ - return 1; - } - diff --git a/target/linux/generic-2.4/patches/230-tun_get_user_backport.patch b/target/linux/generic-2.4/patches/230-tun_get_user_backport.patch deleted file mode 100644 index 2fcfd23..0000000 --- a/target/linux/generic-2.4/patches/230-tun_get_user_backport.patch +++ /dev/null @@ -1,102 +0,0 @@ ---- a/include/linux/skbuff.h -+++ b/include/linux/skbuff.h -@@ -912,6 +912,49 @@ static inline void skb_reserve(struct sk - skb->tail+=len; - } - -+/* -+ * CPUs often take a performance hit when accessing unaligned memory -+ * locations. The actual performance hit varies, it can be small if the -+ * hardware handles it or large if we have to take an exception and fix it -+ * in software. -+ * -+ * Since an ethernet header is 14 bytes network drivers often end up with -+ * the IP header at an unaligned offset. The IP header can be aligned by -+ * shifting the start of the packet by 2 bytes. Drivers should do this -+ * with: -+ * -+ * skb_reserve(NET_IP_ALIGN); -+ * -+ * The downside to this alignment of the IP header is that the DMA is now -+ * unaligned. On some architectures the cost of an unaligned DMA is high -+ * and this cost outweighs the gains made by aligning the IP header. -+ * -+ * Since this trade off varies between architectures, we allow NET_IP_ALIGN -+ * to be overridden. -+ */ -+#ifndef NET_IP_ALIGN -+#define NET_IP_ALIGN 2 -+#endif -+ -+/* -+ * The networking layer reserves some headroom in skb data (via -+ * dev_alloc_skb). This is used to avoid having to reallocate skb data when -+ * the header has to grow. In the default case, if the header has to grow -+ * 16 bytes or less we avoid the reallocation. -+ * -+ * Unfortunately this headroom changes the DMA alignment of the resulting -+ * network packet. As for NET_IP_ALIGN, this unaligned DMA is expensive -+ * on some architectures. An architecture can override this value, -+ * perhaps setting it to a cacheline in size (since that will maintain -+ * cacheline alignment of the DMA). It must be a power of 2. -+ * -+ * Various parts of the networking layer expect at least 16 bytes of -+ * headroom, you should not reduce this. -+ */ -+#ifndef NET_SKB_PAD -+#define NET_SKB_PAD 16 -+#endif -+ - extern int ___pskb_trim(struct sk_buff *skb, unsigned int len, int realloc); - - static inline void __skb_trim(struct sk_buff *skb, unsigned int len) ---- a/drivers/net/tun.c -+++ b/drivers/net/tun.c -@@ -185,22 +185,31 @@ static __inline__ ssize_t tun_get_user(s - { - struct tun_pi pi = { 0, __constant_htons(ETH_P_IP) }; - struct sk_buff *skb; -- size_t len = count; -+ size_t len = count, align = 0; - - if (!(tun->flags & TUN_NO_PI)) { - if ((len -= sizeof(pi)) > count) - return -EINVAL; - -- memcpy_fromiovec((void *)&pi, iv, sizeof(pi)); -+ if(memcpy_fromiovec((void *)&pi, iv, sizeof(pi))) -+ return -EFAULT; - } -- -- if (!(skb = alloc_skb(len + 2, GFP_KERNEL))) { -+ -+ if ((tun->flags & TUN_TYPE_MASK) == TUN_TAP_DEV) -+ align = NET_IP_ALIGN; -+ -+ if (!(skb = alloc_skb(len + align, GFP_KERNEL))) { - tun->stats.rx_dropped++; - return -ENOMEM; - } - -- skb_reserve(skb, 2); -- memcpy_fromiovec(skb_put(skb, len), iv, len); -+ if (align) -+ skb_reserve(skb, align); -+ if (memcpy_fromiovec(skb_put(skb, len), iv, len)) { -+ tun->stats.rx_dropped++; -+ kfree_skb(skb); -+ return -EFAULT; -+ } - - skb->dev = &tun->dev; - switch (tun->flags & TUN_TYPE_MASK) { -@@ -271,7 +280,8 @@ static __inline__ ssize_t tun_put_user(s - pi.flags |= TUN_PKT_STRIP; - } - -- memcpy_toiovec(iv, (void *) &pi, sizeof(pi)); -+ if(memcpy_toiovec(iv, (void *) &pi, sizeof(pi))) -+ return -EFAULT; - total += sizeof(pi); - } - diff --git a/target/linux/generic-2.4/patches/231-mini_fo.patch b/target/linux/generic-2.4/patches/231-mini_fo.patch deleted file mode 100644 index 8605cd3..0000000 --- a/target/linux/generic-2.4/patches/231-mini_fo.patch +++ /dev/null @@ -1,7753 +0,0 @@ ---- a/fs/Config.in -+++ b/fs/Config.in -@@ -77,6 +77,7 @@ dep_mbool ' JFS debugging' CONFIG_JFS_D - dep_mbool ' JFS statistics' CONFIG_JFS_STATISTICS $CONFIG_JFS_FS - - tristate 'Minix fs support' CONFIG_MINIX_FS -+tristate 'mini_fo filesystem overlay' CONFIG_MINI_FO - - tristate 'FreeVxFS file system support (VERITAS VxFS(TM) compatible)' CONFIG_VXFS_FS - tristate 'NTFS file system support (read only)' CONFIG_NTFS_FS ---- a/fs/Makefile -+++ b/fs/Makefile -@@ -31,6 +31,7 @@ subdir-$(CONFIG_RAMFS) += ramfs - subdir-$(CONFIG_CODA_FS) += coda - subdir-$(CONFIG_INTERMEZZO_FS) += intermezzo - subdir-$(CONFIG_MINIX_FS) += minix -+subdir-$(CONFIG_MINI_FO) += mini_fo - subdir-$(CONFIG_FAT_FS) += fat - subdir-$(CONFIG_UMSDOS_FS) += umsdos - subdir-$(CONFIG_MSDOS_FS) += msdos ---- /dev/null -+++ b/fs/mini_fo/aux.c -@@ -0,0 +1,580 @@ -+/* -+ * Copyright (c) 1997-2003 Erez Zadok -+ * Copyright (c) 2001-2003 Stony Brook University -+ * -+ * For specific licensing information, see the COPYING file distributed with -+ * this package, or get one from ftp://ftp.filesystems.org/pub/fist/COPYING. -+ * -+ * This Copyright notice must be kept intact and distributed with all -+ * fistgen sources INCLUDING sources generated by fistgen. -+ */ -+/* -+ * Copyright (C) 2004, 2005 Markus Klotzbuecher <mk@creamnet.de> -+ * -+ * 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. -+ */ -+/* -+ * $Id$ -+ */ -+ -+#ifdef HAVE_CONFIG_H -+# include <config.h> -+#endif -+ -+#include "fist.h" -+#include "mini_fo.h" -+ -+/* check if file exists in storage */ -+int exists_in_storage(dentry_t *dentry) -+{ -+ check_mini_fo_dentry(dentry); -+ if(dtost(dentry) == MODIFIED || dtost(dentry) == CREATED || dtost(dentry) == DEL_REWRITTEN) -+ return 1; -+ return 0; -+} -+ -+/* check if dentry is in an existing state */ -+int is_mini_fo_existant(dentry_t *dentry) -+{ -+ check_mini_fo_dentry(dentry); -+ -+ if(dtost(dentry) == DELETED || dtost(dentry) == NON_EXISTANT) -+ return 0; -+ else -+ return 1; -+} -+ -+/* -+ * This function will create a negative storage dentry for -+ * dentry, what is required for many create like options. -+ * It will create the storage structure if necessary. -+ */ -+int get_neg_sto_dentry(dentry_t *dentry) -+{ -+ int err = 0; -+ unsigned int len; -+ const unsigned char *name; -+ -+ if(!dentry || -+ !dtopd(dentry) || -+ !(dtost(dentry) == UNMODIFIED || -+ dtost(dentry) == NON_EXISTANT || -+ dtost(dentry) == DELETED)) { -+ printk(KERN_CRIT "mini_fo: get_neg_sto_dentry: invalid dentry passed.\n"); -+ err = -1; -+ goto out; -+ } -+ /* Have we got a neg. dentry already? */ -+ if(dtohd2(dentry)) { -+ err = 0; -+ goto out; -+ } -+ if(dtost(dentry->d_parent) == UNMODIFIED) { -+ /* build sto struct */ -+ err = build_sto_structure(dentry->d_parent->d_parent, dentry->d_parent); -+ if(err || -+ dtost(dentry->d_parent) != MODIFIED) { -+ printk(KERN_CRIT "mini_fo: get_neg_sto_dentry: ERROR building sto structure.\n"); -+ err = -1; -+ goto out; -+ } -+ } -+ -+ len = dentry->d_name.len; -+ name = dentry->d_name.name; -+ -+ dtohd2(dentry) = -+ lookup_one_len(name, dtohd2(dentry->d_parent), len); -+ -+ out: -+ return err; -+} -+ -+int check_mini_fo_dentry(dentry_t *dentry) -+{ -+ ASSERT(dentry != NULL); -+ ASSERT(dtopd(dentry) != NULL); -+ ASSERT((dtohd(dentry) != NULL) || (dtohd2(dentry) != NULL)); -+ -+/* if(dtost(dentry) == MODIFIED) { */ -+/* ASSERT(dentry->d_inode != NULL); */ -+/* ASSERT(dtohd(dentry) != NULL); */ -+/* ASSERT(dtohd(dentry)->d_inode != NULL); */ -+/* ASSERT(dtohd2(dentry) != NULL); */ -+/* ASSERT(dtohd2(dentry)->d_inode != NULL); */ -+/* } */ -+/* else if(dtost(dentry) == UNMODIFIED) { */ -+/* ASSERT(dentry->d_inode != NULL); */ -+/* ASSERT( */ -+/* } */ -+ return 0; -+} -+ -+int check_mini_fo_file(file_t *file) -+{ -+ ASSERT(file != NULL); -+ ASSERT(ftopd(file) != NULL); -+ ASSERT(file->f_dentry != NULL); -+ -+ /* violent checking, check depending of state and type -+ * if(S_ISDIR(file->f_dentry->d_inode->i_mode)) {} -+ */ -+ ASSERT((ftohf(file) != NULL) || (ftohf2(file) != NULL)); -+ return 0; -+} -+ -+int check_mini_fo_inode(inode_t *inode) -+{ -+ ASSERT(inode != NULL); -+ ASSERT(itopd(inode) != NULL); -+ ASSERT((itohi(inode) != NULL) || (itohi2(inode) != NULL)); -+ return 0; -+} -+ -+/* -+ * will walk a base path as provided by get_mini_fo_bpath and return -+ * the (hopefully ;-) ) positive dentry of the renamed base dir. -+ * -+ * This does some work of path_init. -+ */ -+dentry_t *bpath_walk(super_block_t *sb, char *bpath) -+{ -+ int err; -+ struct nameidata nd; -+ -+ /* be paranoid */ -+ if(!bpath || bpath[0] != '/') { -+ printk(KERN_CRIT "mini_fo: bpath_walk: Invalid string.\n"); -+ return NULL; -+ } -+ if(!sb || !stopd(sb)) { -+ printk(KERN_CRIT "mini_fo: bpath_walk: Invalid sb.\n"); -+ return NULL; -+ } -+ -+ /* setup nd as path_init does */ -+ nd.last_type = LAST_ROOT; /* if there are only slashes... */ -+ nd.flags = LOOKUP_FOLLOW; -+ /* fix this: how do I reach this lock? -+ * read_lock(¤t->fs->lock); */ -+ nd.mnt = mntget(stopd(sb)->hidden_mnt); -+ nd.dentry = dget(stopd(sb)->base_dir_dentry); -+ /* read_unlock(¤t->fs->lock); */ -+ -+ err = path_walk(bpath+1, &nd); -+ -+ /* validate */ -+ if (err || !nd.dentry || !nd.dentry->d_inode) { -+ printk(KERN_CRIT "mini_fo: bpath_walk: path_walk failed.\n"); -+ return NULL; -+ } -+ return nd.dentry; -+} -+ -+ -+/* returns the full path of the basefile incl. its name */ -+int get_mini_fo_bpath(dentry_t *dentry, char **bpath, int *bpath_len) -+{ -+ char *buf_walker; -+ int len = 0; -+ dentry_t *sky_walker; -+ -+ if(!dentry || !dtohd(dentry)) { -+ printk(KERN_CRIT "mini_fo: get_mini_fo_bpath: invalid dentry passed.\n"); -+ return -1; -+ } -+ sky_walker = dtohd(dentry); -+ -+ do { -+ len += sky_walker->d_name.len + 1 ; /* 1 for '/' */ -+ sky_walker = sky_walker->d_parent; -+ } while(sky_walker != stopd(dentry->d_inode->i_sb)->base_dir_dentry); -+ -+ /* 1 to oil the loop */ -+ *bpath = (char*) kmalloc(len + 1, GFP_KERNEL); -+ if(!*bpath) { -+ printk(KERN_CRIT "mini_fo: get_mini_fo_bpath: out of mem.\n"); -+ return -1; -+ } -+ buf_walker = *bpath+len; /* put it on last char */ -+ *buf_walker = '\n'; -+ sky_walker = dtohd(dentry); -+ -+ do { -+ buf_walker -= sky_walker->d_name.len; -+ strncpy(buf_walker, -+ sky_walker->d_name.name, -+ sky_walker->d_name.len); -+ *(--buf_walker) = '/'; -+ sky_walker = sky_walker->d_parent; -+ } while(sky_walker != stopd(dentry->d_inode->i_sb)->base_dir_dentry); -+ -+ /* bpath_len doesn't count newline! */ -+ *bpath_len = len; -+ return 0; -+} -+ -+int mini_fo_cp_cont(dentry_t *tgt_dentry, struct vfsmount *tgt_mnt, -+ dentry_t *src_dentry, struct vfsmount *src_mnt) -+{ -+ void *buf; -+ mm_segment_t old_fs; -+ file_t *tgt_file; -+ file_t *src_file; -+ int bytes, len, tmp, err; -+ err = 0; -+ -+ if(!(tgt_dentry->d_inode && src_dentry->d_inode)) { -+ printk(KERN_CRIT "mini_fo_cp_cont: ERROR, neg. dentry passed.\n"); -+ err = -EINVAL; -+ goto out; -+ } -+ -+ dget(tgt_dentry); -+ dget(src_dentry); -+ mntget(tgt_mnt); -+ mntget(src_mnt); -+ -+ /* open file write only */ -+ tgt_file = dentry_open(tgt_dentry, tgt_mnt, 0x1); -+ if(!tgt_file || IS_ERR(tgt_file)) { -+ printk(KERN_CRIT "mini_fo_cp_cont: ERROR opening target file.\n"); -+ err = PTR_ERR(tgt_file); -+ goto out_err; -+ } -+ -+ /* open file read only */ -+ src_file = dentry_open(src_dentry, src_mnt, 0x0); -+ if(!src_file || IS_ERR(src_file)) { -+ printk(KERN_CRIT "mini_fo_cp_cont: ERROR opening source file.\n"); -+ err = PTR_ERR(src_file); -+ -+ /* close target file */ -+ fput(tgt_file); -+ goto out_err; -+ } -+ -+ /* check if the filesystem(s) support read respective write */ -+ if(!src_file->f_op->read || !tgt_file->f_op->write) { -+ printk(KERN_CRIT "mini_fo_cp_cont: ERROR, no fs read or write support.\n"); -+ err = -EPERM; -+ goto out_close; -+ } -+ -+ /* allocate a page for transfering the data */ -+ buf = (void *) __get_free_page(GFP_KERNEL); -+ if(!buf) { -+ printk(KERN_CRIT "mini_fo_cp_cont: ERROR, out of kernel mem.\n"); -+ goto out_err; -+ } -+ -+ tgt_file->f_pos = 0; -+ src_file->f_pos = 0; -+ -+ old_fs = get_fs(); -+ set_fs(KERNEL_DS); -+ -+ /* Doing this I assume that a read operation will return a full -+ * buffer while there is still data to read, and a less than -+ * full buffer when all data has been read. -+ */ -+ bytes = len = PAGE_SIZE; -+ while(bytes == len) { -+ bytes = src_file->f_op->read(src_file, buf, len, -+ &src_file->f_pos); -+ tmp = tgt_file->f_op->write(tgt_file, buf, bytes, -+ &tgt_file->f_pos); -+ if(tmp != bytes) { -+ printk(KERN_CRIT "mini_fo_cp_cont: ERROR writing.\n"); -+ goto out_close_unset; -+ } -+ } -+ -+ free_page((unsigned long) buf); -+ set_fs(old_fs); -+ fput(tgt_file); -+ fput(src_file); -+ goto out; -+ -+ out_close_unset: -+ free_page((unsigned long) buf); -+ set_fs(old_fs); -+ -+ out_close: -+ fput(tgt_file); -+ fput(src_file); -+ -+ out_err: -+ dput(tgt_dentry); -+ dput(src_dentry); -+ -+ /* mk: not sure if this need to be done */ -+ mntput(tgt_mnt); -+ mntput(src_mnt); -+ -+ out: -+ return err; -+} -+ -+/* mk: -+ * ndl (no-duplicate list) stuff -+ * This is used in mini_fo_readdir, to save the storage directory contents -+ * and later when reading base, match them against the list in order -+ * to avoid duplicates. -+ */ -+ -+/* add a file specified by name and len to the ndl -+ * Return values: 0 on success, <0 on failure. -+ */ -+int ndl_add_entry(struct readdir_data *rd, const char *name, int len) -+{ -+ struct ndl_entry *tmp_entry; -+ -+ tmp_entry = (struct ndl_entry *) -+ kmalloc(sizeof(struct ndl_entry), GFP_KERNEL); -+ if(!tmp_entry) { -+ printk(KERN_CRIT "mini_fo: ndl_add_entry: out of mem.\n"); -+ return -ENOMEM; -+ } -+ tmp_entry->name = (char*) kmalloc(len, GFP_KERNEL); -+ if(!tmp_entry->name) { -+ printk(KERN_CRIT "mini_fo: ndl_add_entry: out of mem.\n"); -+ return -ENOMEM; -+ } -+ strncpy(tmp_entry->name, name, len); -+ tmp_entry->len = len; -+ -+ list_add(&tmp_entry->list, &rd->ndl_list); -+ rd->ndl_size++; -+ return 0; -+} -+ -+/* delete all list entries and free memory */ -+void ndl_put_list(struct readdir_data *rd) -+{ -+ struct list_head *tmp; -+ struct ndl_entry *tmp_entry; -+ -+ if(rd->ndl_size <= 0) -+ return; -+ while(!list_empty(&rd->ndl_list)) { -+ tmp = rd->ndl_list.next; -+ list_del(tmp); -+ tmp_entry = list_entry(tmp, struct ndl_entry, list); -+ kfree(tmp_entry->name); -+ kfree(tmp_entry); -+ } -+ rd->ndl_size = 0; -+} -+ -+/* Check if a file specified by name and len is in the ndl -+ * Return value: 0 if not in list, 1 if file is found in ndl. -+ */ -+int ndl_check_entry(struct readdir_data *rd, const char *name, int len) -+{ -+ struct list_head *tmp; -+ struct ndl_entry *tmp_entry; -+ -+ if(rd->ndl_size <= 0) -+ return 0; -+ -+ list_for_each(tmp, &rd->ndl_list) { -+ tmp_entry = list_entry(tmp, struct ndl_entry, list); -+ if(tmp_entry->len != len) -+ continue; -+ if(!strncmp(tmp_entry->name, name, len)) -+ return 1; -+ } -+ return 0; -+} -+ -+/* mk: -+ * Recursive function to create corresponding directorys in the storage fs. -+ * The function will build the storage directorys up to dentry. -+ */ -+int build_sto_structure(dentry_t *dir, dentry_t *dentry) -+{ -+ int err; -+ dentry_t *hidden_sto_dentry; -+ dentry_t *hidden_sto_dir_dentry; -+ -+ if(dentry->d_parent != dir) { -+ printk(KERN_CRIT "mini_fo: build_sto_structure: invalid parameter or meta data corruption [1].\n"); -+ return 1; -+ } -+ -+ if(dtost(dir) != MODIFIED) { -+ err = build_sto_structure(dir->d_parent, dentry->d_parent); -+ if(err) -+ return err; -+ } -+ -+ /* ok, coming back again. */ -+ check_mini_fo_dentry(dentry); -+ hidden_sto_dentry = dtohd2(dentry); -+ -+ if(!hidden_sto_dentry) { -+ /* -+ * This is the case after creating the first -+ * hidden_sto_dentry. -+ * After one negative storage_dentry, all pointers to -+ * hidden_storage dentries are set to NULL. We need to -+ * create the negative dentry before we create the storage -+ * file. -+ */ -+ unsigned int len; -+ const unsigned char *name; -+ len = dtohd(dentry)->d_name.len; -+ name = dtohd(dentry)->d_name.name; -+ hidden_sto_dentry = lookup_one_len(name, dtohd2(dir), len); -+ dtohd2(dentry) = hidden_sto_dentry; -+ } -+ -+ /* was: hidden_sto_dir_dentry = lock_parent(hidden_sto_dentry); */ -+ hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent); -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex); -+#else -+ down(&hidden_sto_dir_dentry->d_inode->i_sem); -+#endif -+ /* lets be safe */ -+ if(dtohd2(dir) != hidden_sto_dir_dentry) { -+ printk(KERN_CRIT "mini_fo: build_sto_structure: invalid parameter or meta data corruption [2].\n"); -+ return 1; -+ } -+ -+ /* check for errors in lock_parent */ -+ err = PTR_ERR(hidden_sto_dir_dentry); -+ if(IS_ERR(hidden_sto_dir_dentry)) { -+ printk(KERN_CRIT "mini_fo: build_sto_structure: lock_parent failed.\n"); -+ return err; -+ } -+ -+ err = vfs_mkdir(hidden_sto_dir_dentry->d_inode, -+ hidden_sto_dentry, -+ dir->d_inode->i_mode); -+ -+ if(err) { -+ printk(KERN_CRIT "mini_fo: build_sto_structure: failed to create storage dir [1].\n"); -+ /* was: unlock_dir(dir); */ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_unlock(&dir->d_inode->i_mutex); -+#else -+ up(&dir->d_inode->i_sem); -+#endif -+ dput(dir); -+ return err; -+ } -+ -+ /* everything ok! */ -+ if(!dtohd2(dentry)->d_inode) { -+ printk(KERN_CRIT "mini_fo: build_sto_structure: failed to create storage dir [2].\n"); -+ /* was: unlock_dir(dir); */ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_unlock(&dir->d_inode->i_mutex); -+#else -+ up(&dir->d_inode->i_sem); -+#endif -+ dput(dir); -+ return 1; -+ } -+ -+ /* interpose the new inode and set new state */ -+ itohi2(dentry->d_inode) = igrab(dtohd2(dentry)->d_inode); -+ dtopd(dentry)->state = MODIFIED; -+ -+ /* initalize the wol list */ -+ itopd(dentry->d_inode)->deleted_list_size = -1; -+ itopd(dentry->d_inode)->renamed_list_size = -1; -+ meta_build_lists(dentry); -+ -+ fist_copy_attr_all(dentry->d_inode, itohi2(dentry->d_inode)); -+ fist_copy_attr_timesizes(dir->d_inode, -+ hidden_sto_dir_dentry->d_inode); -+ dir->d_inode->i_nlink++; -+ /* was: unlock_dir(hidden_sto_dir_dentry); */ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex); -+#else -+ up(&hidden_sto_dir_dentry->d_inode->i_sem); -+#endif -+ dput(hidden_sto_dir_dentry); -+ return 0; -+} -+ -+ -+#if 0 /* unused */ -+ -+/* -+ * Read "len" bytes from "filename" into "buf". -+ * "buf" is in kernel space. -+ */ -+int -+mini_fo_read_file(const char *filename, void *buf, int len) -+{ -+ file_t *filp; -+ mm_segment_t oldfs; -+ int bytes; -+ /* Chroot? Maybe NULL isn't right here */ -+ filp = filp_open(filename, O_RDONLY, 0); -+ if (!filp || IS_ERR(filp)) { -+ printk("mini_fo_read_file err %d\n", (int) PTR_ERR(filp)); -+ return -1; /* or do something else */ -+ } -+ -+ if (!filp->f_op->read) -+ return -2; /* file(system) doesn't allow reads */ -+ -+ /* now read len bytes from offset 0 */ -+ filp->f_pos = 0; /* start offset */ -+ oldfs = get_fs(); -+ set_fs(KERNEL_DS); -+ bytes = filp->f_op->read(filp, buf, len, &filp->f_pos); -+ set_fs(oldfs); -+ -+ /* close the file */ -+ fput(filp); -+ -+ return bytes; -+} -+ -+ -+ -+/* -+ * Write "len" bytes from "buf" to "filename" -+ * "buf" is in kernel space. -+ */ -+int -+mini_fo_write_file(const char *filename, void *buf, int len) -+{ -+ file_t *filp; -+ mm_segment_t oldfs; -+ int bytes; -+ /* Chroot? Maybe NULL isn't right here */ -+ filp = filp_open(filename, O_RDWR|O_CREAT, 0640); -+ if (!filp || IS_ERR(filp)) { -+ printk("mini_fo_write_file err %d\n", (int) PTR_ERR(filp)); -+ return -1; /* or do something else */ -+ } -+ -+ if (!filp->f_op->write) -+ return -2; /* file(system) doesn't allow writes */ -+ -+ /* now write len bytes from offset 0 */ -+ filp->f_pos = 0; /* start offset */ -+ oldfs = get_fs(); -+ set_fs(KERNEL_DS); -+ bytes = filp->f_op->write(filp, buf, len, &filp->f_pos); -+ set_fs(oldfs); -+ -+ /* close the file */ -+ fput(filp); -+ -+ return bytes; -+} -+ -+#endif /* unused */ -+ ---- /dev/null -+++ b/fs/mini_fo/ChangeLog -@@ -0,0 +1,281 @@ -+2006-01-24 Markus Klotzbuecher <mk@mary.denx.de> -+ -+ * Add tons of ugly ifdefs to Ed L. Cashin's mutex patch to -+ retain backwards compatibility. -+ -+2006-01-24 Ed L. Cashin <ecashin@coraid.com> -+ -+ * Support for the new mutex infrastructure -+ (7892f2f48d165a34b0b8130c8a195dfd807b8cb6) -+ -+2005-10-15 Markus Klotzbuecher <mk@localhost.localdomain> -+ -+ * Bugfix for a serious memory leak in mini_fo_follow_link. -+ -+2005-09-21 Markus Klotzbuecher <mk@mary> -+ -+ * new release 0.6.1 -+ -+ * fix of a compiler warning due to changes in 2.6.13 -+ -+2005-09-21 Klaus Wenninger <klaus.wenninger@siemens.com> -+ -+ * file.c: readdir: fix for a bug that caused directory entries -+ to show up twice when using storage filesystems such as -+ minixfs or pramfs. -+ -+2005-06-30 Eric Lammerts <eric@lammerts.org> -+ -+ * fix for an oops when overwriting a binary thats beeing -+ executed. -+ -+2005-06-09 <mk@mary> -+ -+ * Renamed overlay to mini_fo-overlay. -+ -+ * Added mini_fo-merge script to allow merging of storage and base -+ after making modifications. -+ -+2005-05-22 root <mk@mary> -+ -+ * Added overlay script that allows to easily mount mini_fo ontop -+ of a given base directory -+ -+2005-05-10 <mk@mary> -+ -+ * inode.c: xattr functions return -EOPNOSUPP instead of -+ -ENOSUPP, what confuses "ls -l" -+ -+ * Changed license from LGPL to GPL. -+ -+2005-05-08 root <mk@mary> -+ -+ * Makefile: clean it up and added make install and make -+ uninstall. -+ -+2005-05-06 <mk@mary> -+ -+ * merged devel branch back to main. [v0-6-0-pre3] -+ -+ * removed unused files print.c and fist_ioctl. [devel-0-0-18] -+ -+ * ioctl: removed fist_ioctl stuff, that is not needed for -+ now. -+ -+2005-05-03 <mk@mary> -+ -+ * file.c: simplified mini_fo_open and mini_fo_setattr using -+ new state changing functions. [devel-0-0-17] -+ -+ * inode.c: Fixed getattr state bug (see below) in 2.4 function -+ mini_fo_inode revalidate. -+ -+ * inode.c: found an other bug in mini_fo_getattr. States are not -+ reliable in this function, as a file can be opened, unlinked and -+ the getattr function called. This results in a deleted dentry -+ with an inode. Fix is to ignore states and simply use the inode -+ available. -+ -+2005-04-29 <mk@mary> -+ -+ * file.c: Bugfix and cleanup in fasync and fsync. [devel-0-0-16] -+ -+ * file.c: do not use mini_fo_lock so the generic version is -+ used (I guess). -+ -+ * inode.c: getattr, never call getattr on lower files, as this -+ will cause the inum to change. -+ -+ * inode.c: rename_reg_file renamed to rename_nondir, as it -+ doesn't matter as long it't not a dir. Removed all -+ rename_dev_file etc. -+ -+ * tagged as devel-0-0-15 -+ -+ * inode.c: added support for chosing support for extended -+ attrs at compile time by XATTR define in mini_fo.h . -+ -+ * inode.c: fixed mini_fo_getattr to use mini_fo inode and not -+ lower again, what avoids inode number changes that confused -+ rm again. This is the proper solution. -+ -+2005-04-24 <mk@mary> -+ -+ * all files: updated Copyright notive to 2005. [devel-0-0-14] -+ -+ * inode.c: fixed mini_fo_getattr to not change the inode -+ number, even if lower files change. -+ -+ * super.c: fixed a bug that caused deleted base file to show -+ up suddenly after some time, or after creating a special -+ file. The problem was that after some time or after special -+ file creating sync_sb_inodes is called by the vfs, that -+ called our mini_fo_put_inode. There was (wrongly) called -+ __meta_put_lists, that nuked the lists, although the inode -+ was going to continue its life. Moving __meta_put_lists to -+ mini_fo_clear_inode, where an inode is really destroyed, -+ solved the problem. -+ -+ -+2005-04-23 <mk@mary> -+ -+ * state.c, aux.c: more cleaning up and -+ simplifications. [devel-0-0-13] -+ -+ * inode.c: implemented mini_fo_getattr, that was required for -+ 2.6 because inode_revalidate has been remove there, and the -+ old "du" bug returned. -+ -+ -+2005-04-20 <mk@mary> -+ -+ * aux.c: get_neg_sto_dentry(): allow to be called for dentries -+ in state UNMODIFIED, NON_EXISTANT _and_ DELETED. -+ -+2005-04-19 <mk@mary> -+ -+ * Fixed a bug under 2.6 that caused files deleted via mini_fo -+ not to be deleted properly and therefore the fs filled up -+ untill no memory was left. [devel-0-0-12] -+ -+ * Added basic hard link support. This means that creating -+ hardlinks will work, but existing ones will be treated as -+ individual files. [devel-0-0-11] -+ -+2005-04-17 <mk@mary> -+ -+ * Bugfixes -+ -+2005-04-13 root <mk@mary> -+ -+ * Added file state.c for the state transition -+ functions. Doesn't work very well yet, though... -+ -+2005-04-12 <mk@mary> -+ -+ * Porting to 2.6 started, which is easier than expected, also -+ due to Olivier previous work. -+ -+2005-04-08 <mk@mary> -+ -+ * Fixed the bug that caused du to return invalid sizes of -+ directory trees. The problem was that -+ mini_fo_inode_revalidate didn't always copy the attributes -+ from the base inode properly. -+ -+2005-04-01 Markus Klotzbuecher <mk@chasey> -+ -+ * Merged devel branch back to main trunk and updated the -+ RELEASE notes. This will be 0-6-0-pre1. -+ -+2005-03-31 Markus Klotzbuecher <mk@chasey> -+ -+ * Fixed some bugs in rename_reg_file, that only showed up in -+ the kernel compile test. Kernel compiles cleanly ontop of -+ mini_fo, now also make mrproper etc. work. Seems pretty stable. -+ -+2005-03-28 Markus Klotzbuecher <mk@chasey> -+ -+ * Many, many directory renaming bugfixes and a lot of other -+ cleanup. Dir renaming seems to work relatively stable. -+ -+2005-03-22 Markus Klotzbuecher <mk@chasey> -+ -+ * Finished implementing lightweight directory renaming. Some -+ basic testing indicates it works fine. -+ Next is to implement testcases for the testsuite and confirm -+ everything is really working ok. -+ -+2005-03-18 Markus Klotzbuecher <mk@chasey> -+ -+ * Finished implementing meta.c stuff required for directory -+ renaming. -+ -+2005-03-17 Markus Klotzbuecher <mk@chasey> -+ -+ * Fixed all compile warnings + an extremly old bug that -+ somehow crept in while reworking the wol stuff to the META -+ system. Turning on -Werror again... :-) -+ -+ * Fixed some bugs in the new rename_reg_file function. -+ -+ * Rewrote mini_fo rename and split it into several -+ subfunctions, that handle the different types -+ seperately. Rewrote the regular file function aswell, as it -+ was implemented somewhat inefficient. -+ -+2005-03-16 Markus Klotzbuecher <mk@chasey> -+ -+ * Implemented new META subsystem, removed old WOL stuff in favor -+ if it. -+ -+ * After some basic testing everything seems ok... -+ -+2005-03-11 Markus Klotzbuecher <mk@chasey> -+ -+ * Renaming a non regular file caused trouble because I always -+ tried to copy the contents. Now I only do this for regular -+ files. mini_fo_rename still isn't implemented properly, renaming -+ of device files, symlinks etc. results in a empty regular file -+ instead of the proper type. -+ -+ * Directory renaming suddenly works! What a surprise! I guess -+ this is because renaming is implemented as making a copy and -+ removing the original. Still this might not work -+ everywhere... -+ -+2005-03-09 Markus Klotzbuecher <mk@chasey> -+ -+ * Bugfix, when a mini_fo directory that exists in storage -+ (state: MODIFIED, CREATED and DEL_REWRITTEN) is deleted, a -+ possibly existing WOL file contained in it needs to be -+ deleted too. -+ -+ * Starting cleanup: defined state names in order to get rid of -+ the state numbers. -+ -+2005-03-08 Markus Klotzbuecher <mk@chasey> -+ -+ * Makefile fix, fist_ioctl was built against wrong sources if ARCH=um -+ -+ * Fixed a bug in dentry.c, mini_fo_d_hash. In state 4 = -+ DEL_REWRITTEN the hash was calculated from the base dentry, -+ which was wrong and and caused assertions in -+ __mini_fo_hidden_dentry to fail. -+ -+2005-02-21 <mk@mary> -+ -+ * Implemented directory deleting (inode.c) -+ -+ * main.c: made mini_fo_parse_options a little more robust. -+ -+2004-12-22 <mk@mary> -+ -+ * Makefile cleanup and uml stuff, removed unneccessary files -+ -+ * Created a new and hopefully more informative README -+ -+ * CHANGELOG: created a new CHANGELOG and added old entries reversely -+ -+ -+2004-10-24 Gleb Natapov <gleb@nbase.co.il> -+ -+ * Fix: owner and group where not correctly copied from base to -+ storage. -+ -+ -+2004-10-05 Gleb Natapov <gleb@nbase.co.il> -+ -+ * Implementation of fsync, fasync and lock mini_fo functions. -+ -+ -+2004-09-29 Bob Lee <bob@pantasys.com> -+ -+ * Fix of a serious pointer bug -+ -+ -+2004-09-28 Gleb Natapov <gleb@nbase.co.il> -+ -+ * Implementation of mini_fo_mknod and mini_fo_rename, support -+ for device files. -+ ---- /dev/null -+++ b/fs/mini_fo/dentry.c -@@ -0,0 +1,244 @@ -+/* -+ * Copyright (c) 1997-2003 Erez Zadok -+ * Copyright (c) 2001-2003 Stony Brook University -+ * -+ * For specific licensing information, see the COPYING file distributed with -+ * this package, or get one from ftp://ftp.filesystems.org/pub/fist/COPYING. -+ * -+ * This Copyright notice must be kept intact and distributed with all -+ * fistgen sources INCLUDING sources generated by fistgen. -+ */ -+/* -+ * Copyright (C) 2004, 2005 Markus Klotzbuecher <mk@creamnet.de> -+ * -+ * 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. -+ */ -+ -+/* -+ * $Id$ -+ */ -+ -+#ifdef HAVE_CONFIG_H -+# include <config.h> -+#endif -+ -+#include "fist.h" -+#include "mini_fo.h" -+ -+/* -+ * THIS IS A BOOLEAN FUNCTION: returns 1 if valid, 0 otherwise. -+ */ -+STATIC int -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+mini_fo_d_revalidate(dentry_t *dentry, struct nameidata *nd) -+#else -+mini_fo_d_revalidate(dentry_t *dentry, int flags) -+#endif -+{ -+ int err1 = 1; /* valid = 1, invalid = 0 */ -+ int err2 = 1; -+ dentry_t *hidden_dentry; -+ dentry_t *hidden_sto_dentry; -+ -+ -+ check_mini_fo_dentry(dentry); -+ -+ hidden_dentry = dtohd(dentry); -+ hidden_sto_dentry = dtohd2(dentry); -+ -+ if(hidden_dentry && -+ hidden_dentry->d_op && -+ hidden_dentry->d_op->d_revalidate) { -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+ err1 = hidden_dentry->d_op->d_revalidate(hidden_dentry, nd); -+#else -+ err1 = hidden_dentry->d_op->d_revalidate(hidden_dentry, flags); -+#endif -+ } -+ if(hidden_sto_dentry && -+ hidden_sto_dentry->d_op && -+ hidden_sto_dentry->d_op->d_revalidate) { -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+ err2 = hidden_sto_dentry->d_op->d_revalidate(hidden_sto_dentry, -+ nd); -+#else -+ err2 = hidden_sto_dentry->d_op->d_revalidate(hidden_sto_dentry, -+ flags); -+#endif -+ } -+ -+ /* mk: if one of the lower level dentries are valid, -+ * the mini_fo dentry is too. -+ */ -+ return (err1 || err2); -+} -+ -+ -+STATIC int -+mini_fo_d_hash(dentry_t *dentry, qstr_t *name) -+{ -+ int err = 0; -+ dentry_t *hidden_dentry; -+ dentry_t *hidden_sto_dentry; -+ -+ /* hidden_dentry = mini_fo_hidden_dentry(dentry); -+ * hidden_sto_dentry = mini_fo_hidden_sto_dentry(dentry); */ -+ -+ /* state 1, 3, 4, 5: build the hash for the storage dentry */ -+ if((dtopd(dentry)->state == MODIFIED) || -+ (dtopd(dentry)->state == CREATED) || -+ (dtopd(dentry)->state == DEL_REWRITTEN) || -+ (dtopd(dentry)->state == DELETED)) { -+ hidden_sto_dentry = dtohd2(dentry); -+ if(hidden_sto_dentry && -+ hidden_sto_dentry->d_op && -+ hidden_sto_dentry->d_op->d_hash) { -+ err = hidden_sto_dentry->d_op->d_hash(hidden_sto_dentry, name); -+ } -+ goto out; -+ } -+ /* state 2: build the hash for the base dentry */ -+ if(dtopd(dentry)->state == UNMODIFIED) { -+ hidden_dentry = dtohd(dentry); -+ if(hidden_dentry && -+ hidden_dentry->d_op && -+ hidden_dentry->d_op->d_hash) { -+ err = hidden_dentry->d_op->d_hash(hidden_dentry, name); -+ } -+ goto out; -+ } -+ /* state 6: build hash for the dentry that exists */ -+ if(dtopd(dentry)->state == NON_EXISTANT) { -+ hidden_sto_dentry = dtohd2(dentry); -+ if(hidden_sto_dentry && -+ hidden_sto_dentry->d_op && -+ hidden_sto_dentry->d_op->d_hash) { -+ err = hidden_sto_dentry->d_op->d_hash(hidden_sto_dentry, name); -+ goto out; -+ } -+ hidden_dentry = dtohd(dentry); -+ if(hidden_dentry && -+ hidden_dentry->d_op && -+ hidden_dentry->d_op->d_hash) { -+ err = hidden_dentry->d_op->d_hash(hidden_dentry, name); -+ goto out; -+ } -+ } -+ -+ printk(KERN_CRIT "mini_fo: d_hash: invalid state detected.\n"); -+ -+ out: -+ return err; -+} -+ -+ -+STATIC int -+mini_fo_d_compare(dentry_t *dentry, qstr_t *a, qstr_t *b) -+{ -+ int err; -+ dentry_t *hidden_dentry=NULL; -+ -+ /* hidden_dentry = mini_fo_hidden_dentry(dentry); */ -+ if(dtohd2(dentry)) -+ hidden_dentry = dtohd2(dentry); -+ else if(dtohd(dentry)) -+ hidden_dentry = dtohd(dentry); -+ -+ if (hidden_dentry && hidden_dentry->d_op && hidden_dentry->d_op->d_compare) { -+ err = hidden_dentry->d_op->d_compare(hidden_dentry, a, b); -+ } else { -+ err = ((a->len != b->len) || memcmp(a->name, b->name, b->len)); -+ } -+ -+ return err; -+} -+ -+ -+int -+mini_fo_d_delete(dentry_t *dentry) -+{ -+ dentry_t *hidden_dentry; -+ dentry_t *hidden_sto_dentry; -+ int err = 0; -+ -+ /* this could be a negative dentry, so check first */ -+ if (!dtopd(dentry)) { -+ printk(KERN_CRIT "mini_fo_d_delete: negative dentry passed.\n"); -+ goto out; -+ } -+ hidden_dentry = dtohd(dentry); -+ hidden_sto_dentry = dtohd2(dentry); -+ -+ if(hidden_dentry) { -+ if(hidden_dentry->d_op && -+ hidden_dentry->d_op->d_delete) { -+ err = hidden_dentry->d_op->d_delete(hidden_dentry); -+ } -+ } -+ if(hidden_sto_dentry) { -+ if(hidden_sto_dentry->d_op && -+ hidden_sto_dentry->d_op->d_delete) { -+ err = hidden_sto_dentry->d_op->d_delete(hidden_sto_dentry); -+ } -+ } -+ -+ out: -+ return err; -+} -+ -+ -+void -+mini_fo_d_release(dentry_t *dentry) -+{ -+ dentry_t *hidden_dentry; -+ dentry_t *hidden_sto_dentry; -+ -+ -+ /* this could be a negative dentry, so check first */ -+ if (!dtopd(dentry)) { -+ printk(KERN_CRIT "mini_fo_d_release: no private data.\n"); -+ goto out; -+ } -+ hidden_dentry = dtohd(dentry); -+ hidden_sto_dentry = dtohd2(dentry); -+ -+ if(hidden_dentry) { -+ /* decrement hidden dentry's counter and free its inode */ -+ dput(hidden_dentry); -+ } -+ if(hidden_sto_dentry) { -+ /* decrement hidden dentry's counter and free its inode */ -+ dput(hidden_sto_dentry); -+ } -+ -+ /* free private data (mini_fo_dentry_info) here */ -+ kfree(dtopd(dentry)); -+ __dtopd(dentry) = NULL; /* just to be safe */ -+ out: -+ return; -+} -+ -+ -+/* -+ * we don't really need mini_fo_d_iput, because dentry_iput will call iput() if -+ * mini_fo_d_iput is not defined. We left this implemented for ease of -+ * tracing/debugging. -+ */ -+void -+mini_fo_d_iput(dentry_t *dentry, inode_t *inode) -+{ -+ iput(inode); -+} -+ -+ -+struct dentry_operations mini_fo_dops = { -+ d_revalidate: mini_fo_d_revalidate, -+ d_hash: mini_fo_d_hash, -+ d_compare: mini_fo_d_compare, -+ d_release: mini_fo_d_release, -+ d_delete: mini_fo_d_delete, -+ d_iput: mini_fo_d_iput, -+}; ---- /dev/null -+++ b/fs/mini_fo/file.c -@@ -0,0 +1,717 @@ -+/* -+ * Copyright (c) 1997-2003 Erez Zadok -+ * Copyright (c) 2001-2003 Stony Brook University -+ * -+ * For specific licensing information, see the COPYING file distributed with -+ * this package, or get one from ftp://ftp.filesystems.org/pub/fist/COPYING. -+ * -+ * This Copyright notice must be kept intact and distributed with all -+ * fistgen sources INCLUDING sources generated by fistgen. -+ */ -+/* -+ * Copyright (C) 2004, 2005 Markus Klotzbuecher <mk@creamnet.de> -+ * -+ * 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. -+ */ -+ -+/* -+ * $Id$ -+ */ -+ -+#ifdef HAVE_CONFIG_H -+# include <config.h> -+#endif -+ -+#include "fist.h" -+#include "mini_fo.h" -+#define ROUND_UP(x) (((x)+sizeof(long)-1) & ~(sizeof(long)-1)) -+ -+/******************* -+ * File Operations * -+ *******************/ -+ -+STATIC loff_t -+mini_fo_llseek(file_t *file, loff_t offset, int origin) -+{ -+ loff_t err; -+ file_t *hidden_file = NULL; -+ -+ if(S_ISDIR(file->f_dentry->d_inode->i_mode)) { -+ /* Check if trying to llseek from a directory */ -+ err = -EISDIR; -+ goto out; -+ } -+ if (ftopd(file) != NULL) { -+ if(ftohf2(file)) { -+ hidden_file = ftohf2(file); -+ } else { -+ hidden_file = ftohf(file); -+ } -+ } -+ -+ /* always set hidden position to this one */ -+ hidden_file->f_pos = file->f_pos; -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+ memcpy(&(hidden_file->f_ra), -+ &(file->f_ra), -+ sizeof(struct file_ra_state)); -+#else -+ if (file->f_reada) { /* update readahead information if needed */ -+ hidden_file->f_reada = file->f_reada; -+ hidden_file->f_ramax = file->f_ramax; -+ hidden_file->f_raend = file->f_raend; -+ hidden_file->f_ralen = file->f_ralen; -+ hidden_file->f_rawin = file->f_rawin; -+ } -+#endif -+ if (hidden_file->f_op && hidden_file->f_op->llseek) -+ err = hidden_file->f_op->llseek(hidden_file, offset, origin); -+ else -+ err = generic_file_llseek(hidden_file, offset, origin); -+ -+ if (err < 0) -+ goto out; -+ -+ if (err != file->f_pos) { -+ file->f_pos = err; -+ // ION maybe this? -+ // file->f_pos = hidden_file->f_pos; -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) -+ file->f_reada = 0; -+#endif -+ file->f_version++; -+ } -+ -+ out: -+ return err; -+} -+ -+ -+/* mk: fanout capable */ -+STATIC ssize_t -+mini_fo_read(file_t *file, char *buf, size_t count, loff_t *ppos) -+{ -+ int err = -EINVAL; -+ file_t *hidden_file = NULL; -+ loff_t pos = *ppos; -+ -+ if(S_ISDIR(file->f_dentry->d_inode->i_mode)) { -+ /* Check if trying to read from a directory */ -+ /* printk(KERN_CRIT "mini_fo_read: ERROR: trying to read data from a directory.\n"); */ -+ err = -EISDIR; -+ goto out; -+ } -+ -+ if (ftopd(file) != NULL) { -+ if(ftohf2(file)) { -+ hidden_file = ftohf2(file); -+ } else { -+ hidden_file = ftohf(file); -+ } -+ } -+ -+ if (!hidden_file->f_op || !hidden_file->f_op->read) -+ goto out; -+ -+ err = hidden_file->f_op->read(hidden_file, buf, count, &pos); -+ *ppos = pos; -+ -+ if (err >= 0) { -+ /* atime should also be updated for reads of size zero or more */ -+ fist_copy_attr_atime(file->f_dentry->d_inode, -+ hidden_file->f_dentry->d_inode); -+ } -+ -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) -+ /* -+ * MAJOR HACK -+ * because pread() does not have any way to tell us that it is -+ * our caller, then we don't know for sure if we have to update -+ * the file positions. This hack relies on read() having passed us -+ * the "real" pointer of its struct file's f_pos field. -+ */ -+ if (ppos == &file->f_pos) -+ hidden_file->f_pos = *ppos = pos; -+ if (hidden_file->f_reada) { /* update readahead information if needed */ -+ file->f_reada = hidden_file->f_reada; -+ file->f_ramax = hidden_file->f_ramax; -+ file->f_raend = hidden_file->f_raend; -+ file->f_ralen = hidden_file->f_ralen; -+ file->f_rawin = hidden_file->f_rawin; -+ } -+#else -+ memcpy(&(file->f_ra),&(hidden_file->f_ra),sizeof(struct file_ra_state)); -+#endif -+ -+ out: -+ return err; -+} -+ -+ -+/* this mini_fo_write() does not modify data pages! */ -+STATIC ssize_t -+mini_fo_write(file_t *file, const char *buf, size_t count, loff_t *ppos) -+{ -+ int err = -EINVAL; -+ file_t *hidden_file = NULL; -+ inode_t *inode; -+ inode_t *hidden_inode; -+ loff_t pos = *ppos; -+ -+ /* mk: fan out: */ -+ if (ftopd(file) != NULL) { -+ if(ftohf2(file)) { -+ hidden_file = ftohf2(file); -+ } else { -+ /* This is bad! We have no storage file to write to. This -+ * should never happen because if a file is opened for -+ * writing, a copy should have been made earlier. -+ */ -+ printk(KERN_CRIT "mini_fo: write : ERROR, no storage file to write.\n"); -+ err = -EINVAL; -+ goto out; -+ } -+ } -+ -+ inode = file->f_dentry->d_inode; -+ hidden_inode = itohi2(inode); -+ if(!hidden_inode) { -+ printk(KERN_CRIT "mini_fo: write: no sto inode found, not good.\n"); -+ goto out; -+ } -+ -+ if (!hidden_file->f_op || !hidden_file->f_op->write) -+ goto out; -+ -+ /* adjust for append -- seek to the end of the file */ -+ if (file->f_flags & O_APPEND) -+ pos = inode->i_size; -+ -+ err = hidden_file->f_op->write(hidden_file, buf, count, &pos); -+ -+ /* -+ * copy ctime and mtime from lower layer attributes -+ * atime is unchanged for both layers -+ */ -+ if (err >= 0) -+ fist_copy_attr_times(inode, hidden_inode); -+ -+ *ppos = pos; -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) -+ /* -+ * XXX: MAJOR HACK -+ * -+ * because pwrite() does not have any way to tell us that it is -+ * our caller, then we don't know for sure if we have to update -+ * the file positions. This hack relies on write() having passed us -+ * the "real" pointer of its struct file's f_pos field. -+ */ -+ if (ppos == &file->f_pos) -+ hidden_file->f_pos = *ppos = pos; -+#endif -+ /* update this inode's size */ -+ if (pos > inode->i_size) -+ inode->i_size = pos; -+ -+ out: -+ return err; -+} -+ -+/* Global variable to hold a file_t pointer. -+ * This serves to allow mini_fo_filldir function to know which file is -+ * beeing read, which is required for two reasons: -+ * -+ * - be able to call wol functions in order to avoid listing deleted -+ * base files. -+ * - if we're reading a directory which is in state 1, we need to -+ * maintain a list (in mini_fo_filldir) of which files allready -+ * have been copied to userspace,to detect files existing in base -+ * and storage and not list them twice. -+ */ -+filldir_t mini_fo_filldir_orig; -+file_t *mini_fo_filldir_file; -+ -+/* mainly copied from fs/readdir.c */ -+STATIC int -+mini_fo_filldir(void * __buf, const char * name, int namlen, loff_t offset, -+ ino_t ino, unsigned int d_type) -+{ -+ struct linux_dirent *dirent, d; -+ struct getdents_callback * buf = (struct getdents_callback *) __buf; -+ int reclen; -+ file_t* file = mini_fo_filldir_file; -+ -+ /* In theses states we filter meta files in storage (WOL) */ -+ if(file && (dtopd(file->f_dentry)->state == MODIFIED || -+ dtopd(file->f_dentry)->state == CREATED || -+ dtopd(file->f_dentry)->state == DEL_REWRITTEN)) { -+ -+ int tmp = strlen(META_FILENAME); -+ if(tmp == namlen) { -+ if(!strncmp(name, META_FILENAME, namlen)) -+ return 0; -+ } -+ } -+ -+ /* check if we are merging the contents of storage and base */ -+ if(file && dtopd(file->f_dentry)->state == MODIFIED) { -+ /* check if we are still reading storage contents, if -+ * yes, we just save the name of the file for duplicate -+ * checking later. */ -+ -+ if(!ftopd(file)->rd.sto_done) { -+ /* put file into ndl list */ -+ if(ndl_add_entry(&ftopd(file)->rd, name, namlen)) -+ printk(KERN_CRIT "mini_fo_filldir: Error adding to ndl.\n"); -+ } else { -+ /* check if file has been deleted */ -+ if(meta_check_d_entry(file->f_dentry, name, namlen)) -+ return 0; -+ -+ /* do duplicate checking */ -+ if(ndl_check_entry(&ftopd(file)->rd, name, namlen)) -+ return 0; -+ } -+ } -+ -+ return mini_fo_filldir_orig(buf, name, namlen, offset, ino, d_type); -+} -+ -+ -+STATIC int -+mini_fo_readdir(file_t *file, void *dirent, filldir_t filldir) -+{ -+ int err = 0;/* mk: ??? -ENOTDIR; */ -+ file_t *hidden_file = NULL; -+ file_t *hidden_sto_file = NULL; -+ inode_t *inode; -+ struct getdents_callback *buf; -+ int oldcount; -+ -+#if defined(FIST_FILTER_NAME) || defined(FIST_FILTER_SCA) -+ struct mini_fo_getdents_callback buf; -+#endif /* FIST_FILTER_NAME || FIST_FILTER_SCA */ -+ -+ buf = (struct getdents_callback *) dirent; -+ oldcount = buf->count; -+ inode = file->f_dentry->d_inode; -+ mini_fo_filldir_file = file; -+ mini_fo_filldir_orig = filldir; -+ -+ ftopd(file)->rd.sto_done = 0; -+ do { -+ if (ftopd(file) != NULL) { -+ if(ftohf2(file)) { -+ hidden_sto_file = ftohf2(file); -+ err = vfs_readdir(hidden_sto_file, mini_fo_filldir, dirent); -+ file->f_pos = hidden_sto_file->f_pos; -+ if (err > 0) -+ fist_copy_attr_atime(inode, hidden_sto_file->f_dentry->d_inode); -+ /* not finshed yet, we'll be called again */ -+ if (buf->count != oldcount) -+ break; -+ } -+ -+ ftopd(file)->rd.sto_done = 1; -+ -+ if(ftohf(file)) { -+ hidden_file = ftohf(file); -+ err = vfs_readdir(hidden_file, mini_fo_filldir, dirent); -+ file->f_pos = hidden_file->f_pos; -+ if (err > 0) -+ fist_copy_attr_atime(inode, hidden_file->f_dentry->d_inode); -+ } -+ -+ } -+ } while (0); -+ -+ /* mk: -+ * we need to check if all the directory data has been copied to userspace, -+ * or if we will be called again by userspace to complete the operation. -+ */ -+ if(buf->count == oldcount) { -+ ndl_put_list(&ftopd(file)->rd); -+ } -+ -+ /* unset this, safe */ -+ mini_fo_filldir_file = NULL; -+ return err; -+} -+ -+ -+STATIC unsigned int -+mini_fo_poll(file_t *file, poll_table *wait) -+{ -+ unsigned int mask = DEFAULT_POLLMASK; -+ file_t *hidden_file = NULL; -+ -+ if (ftopd(file) != NULL) { -+ if(ftohf2(file)) { -+ hidden_file = ftohf2(file); -+ } else { -+ hidden_file = ftohf(file); -+ } -+ } -+ -+ if (!hidden_file->f_op || !hidden_file->f_op->poll) -+ goto out; -+ -+ mask = hidden_file->f_op->poll(hidden_file, wait); -+ -+ out: -+ return mask; -+} -+ -+/* FIST-LITE special version of mmap */ -+STATIC int -+mini_fo_mmap(file_t *file, vm_area_t *vma) -+{ -+ int err = 0; -+ file_t *hidden_file = NULL; -+ -+ /* fanout capability */ -+ if (ftopd(file) != NULL) { -+ if(ftohf2(file)) { -+ hidden_file = ftohf2(file); -+ } else { -+ hidden_file = ftohf(file); -+ } -+ } -+ -+ ASSERT(hidden_file != NULL); -+ ASSERT(hidden_file->f_op != NULL); -+ ASSERT(hidden_file->f_op->mmap != NULL); -+ -+ vma->vm_file = hidden_file; -+ err = hidden_file->f_op->mmap(hidden_file, vma); -+ get_file(hidden_file); /* make sure it doesn't get freed on us */ -+ fput(file); /* no need to keep extra ref on ours */ -+ -+ return err; -+} -+ -+ -+ -+STATIC int -+mini_fo_open(inode_t *inode, file_t *file) -+{ -+ int err = 0; -+ int hidden_flags; -+ file_t *hidden_file = NULL; -+ dentry_t *hidden_dentry = NULL; -+ -+ /* fanout stuff */ -+ file_t *hidden_sto_file = NULL; -+ dentry_t *hidden_sto_dentry = NULL; -+ -+ __ftopd(file) = -+ kmalloc(sizeof(struct mini_fo_file_info), GFP_KERNEL); -+ if (!ftopd(file)) { -+ err = -ENOMEM; -+ goto out; -+ } -+ -+ /* init the readdir_helper structure */ -+ INIT_LIST_HEAD(&ftopd(file)->rd.ndl_list); -+ ftopd(file)->rd.ndl_size = 0; -+ -+ /* In certain paths this could stay uninitalized and cause trouble */ -+ ftohf(file) = NULL; -+ ftohf2(file) = NULL; -+ hidden_flags = file->f_flags; -+ -+ /* create storage files? */ -+ if(dtost(file->f_dentry) == UNMODIFIED) { -+ if(!IS_WRITE_FLAG(file->f_flags)) { -+ hidden_dentry = dtohd(file->f_dentry); -+ dget(hidden_dentry); -+ /* dentry_open will decrement mnt refcnt if err. -+ * otherwise fput() will do an mntput() for us upon file close. */ -+ mntget(stopd(inode->i_sb)->hidden_mnt); -+ hidden_file = dentry_open(hidden_dentry, -+ stopd(inode->i_sb)->hidden_mnt, -+ hidden_flags); -+ if (IS_ERR(hidden_file)) { -+ err = PTR_ERR(hidden_file); -+ dput(hidden_dentry); -+ goto out; -+ } -+ ftohf(file) = hidden_file; /* link two files */ -+ goto out; -+ } -+ else { -+ if(S_ISDIR(file->f_dentry->d_inode->i_mode)) { -+ err = dir_unmod_to_mod(file->f_dentry); -+ } else -+ err = nondir_unmod_to_mod(file->f_dentry, 1); -+ -+ if (err) { -+ printk("mini_fo_open: ERROR creating storage file.\n"); -+ goto out; -+ } -+ } -+ } -+ hidden_sto_dentry = dtohd2(file->f_dentry); -+ dget(hidden_sto_dentry); -+ -+ if(dtopd(file->f_dentry)->state == MODIFIED) { -+ /* Directorys are special, interpose on both lower level files */ -+ if(S_ISDIR(itohi(inode)->i_mode)) { -+ /* check for invalid file types of lower level files */ -+ if(!(S_ISDIR(itohi(inode)->i_mode) && S_ISDIR(itohi2(inode)->i_mode))) { -+ printk(KERN_CRIT "mini_fo_open: meta data corruption detected.\n"); -+ dput(hidden_sto_dentry); -+ err = -EINVAL; -+ goto out; -+ } -+ -+ /* lower level directorys are ok, open the base file */ -+ hidden_dentry = dtohd(file->f_dentry); -+ dget(hidden_dentry); -+ -+ mntget(stopd(inode->i_sb)->hidden_mnt); -+ hidden_file = dentry_open(hidden_dentry, -+ stopd(inode->i_sb)->hidden_mnt, -+ hidden_flags); -+ if (IS_ERR(hidden_file)) { -+ err = PTR_ERR(hidden_file); -+ dput(hidden_dentry); -+ dput(hidden_sto_dentry); -+ goto out; -+ } -+ ftohf(file) = hidden_file; /* link the two files */ -+ } -+ } -+ -+ if(!exists_in_storage(file->f_dentry)) { -+ printk(KERN_CRIT "mini_fo_open: invalid file state detected.\n"); -+ err = -EINVAL; -+ dput(hidden_sto_dentry); -+ -+ /* If the base file has been opened, we need to close it here */ -+ if(ftohf(file)) { -+ if (hidden_file->f_op && hidden_file->f_op->flush) -+ hidden_file->f_op->flush(hidden_file); -+ dput(hidden_dentry); -+ } -+ goto out; -+ } -+ -+ /* ok, now we can safely open the storage file */ -+ mntget(stopd(inode->i_sb)->hidden_mnt2); -+ hidden_sto_file = dentry_open(hidden_sto_dentry, -+ stopd(inode->i_sb)->hidden_mnt2, -+ hidden_flags); -+ -+ /* dentry_open dputs the dentry if it fails */ -+ if (IS_ERR(hidden_sto_file)) { -+ err = PTR_ERR(hidden_sto_file); -+ /* close base file if open */ -+ if(ftohf(file)) { -+ if (hidden_file->f_op && hidden_file->f_op->flush) -+ hidden_file->f_op->flush(hidden_file); -+ dput(hidden_dentry); -+ } -+ goto out; -+ } -+ ftohf2(file) = hidden_sto_file; /* link storage file */ -+ -+ out: -+ if (err < 0 && ftopd(file)) { -+ kfree(ftopd(file)); -+ } -+ return err; -+} -+ -+STATIC int -+mini_fo_flush(file_t *file) -+{ -+ int err1 = 0; /* assume ok (see open.c:close_fp) */ -+ int err2 = 0; -+ file_t *hidden_file = NULL; -+ -+ check_mini_fo_file(file); -+ -+ /* mk: we don't do any state checking here, as its not worth the time. -+ * Just flush the lower level files if they exist. -+ */ -+ if(ftopd(file) != NULL) { -+ if(ftohf(file) != NULL) { -+ hidden_file = ftohf(file); -+ if (hidden_file->f_op && hidden_file->f_op->flush) -+ err1 = hidden_file->f_op->flush(hidden_file); -+ } -+ if(ftohf2(file) != NULL) { -+ hidden_file = ftohf2(file); -+ if (hidden_file->f_op && hidden_file->f_op->flush) -+ err2 = hidden_file->f_op->flush(hidden_file); -+ } -+ } -+ return (err1 | err2); -+} -+ -+ -+STATIC int -+mini_fo_release(inode_t *inode, file_t *file) -+{ -+ int err = 0; -+ file_t *hidden_file = NULL; -+ -+ if (ftopd(file) != NULL) { -+ if(ftohf(file)) { -+ hidden_file = ftohf(file); -+ fput(hidden_file); -+ } -+ if(ftohf2(file)) { -+ hidden_file = ftohf2(file); -+ fput(hidden_file); -+ } -+ kfree(ftopd(file)); -+ } -+ return err; -+} -+ -+STATIC int -+mini_fo_fsync(file_t *file, dentry_t *dentry, int datasync) -+{ -+ int err1 = 0; -+ int err2 = 0; -+ file_t *hidden_file = NULL; -+ dentry_t *hidden_dentry; -+ -+ check_mini_fo_file(file); -+ -+ if ((hidden_file = ftohf(file)) != NULL) { -+ hidden_dentry = dtohd(dentry); -+ if (hidden_file->f_op && hidden_file->f_op->fsync) { -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_lock(&hidden_dentry->d_inode->i_mutex); -+#else -+ down(&hidden_dentry->d_inode->i_sem); -+#endif -+ err1 = hidden_file->f_op->fsync(hidden_file, hidden_dentry, datasync); -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_unlock(&hidden_dentry->d_inode->i_mutex); -+#else -+ up(&hidden_dentry->d_inode->i_sem); -+#endif -+ } -+ } -+ -+ if ((hidden_file = ftohf2(file)) != NULL) { -+ hidden_dentry = dtohd2(dentry); -+ if (hidden_file->f_op && hidden_file->f_op->fsync) { -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_lock(&hidden_dentry->d_inode->i_mutex); -+#else -+ down(&hidden_dentry->d_inode->i_sem); -+#endif -+ err2 = hidden_file->f_op->fsync(hidden_file, hidden_dentry, datasync); -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_unlock(&hidden_dentry->d_inode->i_mutex); -+#else -+ up(&hidden_dentry->d_inode->i_sem); -+#endif -+ } -+ } -+ else -+ goto err; -+ -+err: -+ return (err1 || err2); -+} -+ -+ -+STATIC int -+mini_fo_fasync(int fd, file_t *file, int flag) -+{ -+ int err1 = 0; -+ int err2 = 0; -+ -+ file_t *hidden_file = NULL; -+ -+ check_mini_fo_file(file); -+ -+ if((hidden_file = ftohf(file)) != NULL) { -+ err1 = hidden_file->f_op->fasync(fd, hidden_file, flag); -+ } -+ if((hidden_file = ftohf2(file)) != NULL) { -+ err2 = hidden_file->f_op->fasync(fd, hidden_file, flag); -+ } -+ -+ return (err1 || err2); -+} -+ -+ -+STATIC int -+mini_fo_lock(file_t *file, int cmd, struct file_lock *fl) -+{ -+ int err = -EINVAL; -+ file_t *hidden_file = NULL; -+ -+ if(!check_mini_fo_file(file)) -+ goto out; -+ -+ /* which file shall we lock? */ -+ if(ftohf2(file)) -+ hidden_file = ftohf2(file); -+ else -+ hidden_file = ftohf(file); -+ -+ if (hidden_file->f_op->lock) { -+ fl->fl_file = hidden_file; -+ err = hidden_file->f_op->lock(hidden_file, F_GETLK, fl); -+ fl->fl_file = file; -+ } else { -+ if(posix_test_lock(hidden_file, fl)) -+ err = 0; -+ } -+ out: -+ return err; -+} -+ -+ -+struct file_operations mini_fo_dir_fops = -+ { -+ read: generic_read_dir, -+ write: mini_fo_write, -+ readdir: mini_fo_readdir, -+ poll: mini_fo_poll, -+ /* ioctl: mini_fo_ioctl, */ -+ mmap: mini_fo_mmap, -+ open: mini_fo_open, -+ flush: mini_fo_flush, -+ release: mini_fo_release, -+ fsync: mini_fo_fsync, -+ fasync: mini_fo_fasync, -+ /* not needed lock: mini_fo_lock, */ -+ /* not needed: readv */ -+ /* not needed: writev */ -+ /* not implemented: sendpage */ -+ /* not implemented: get_unmapped_area */ -+ }; -+ -+struct file_operations mini_fo_main_fops = -+ { -+ llseek: mini_fo_llseek, -+ read: mini_fo_read, -+ write: mini_fo_write, -+ readdir: mini_fo_readdir, -+ poll: mini_fo_poll, -+ /* ioctl: mini_fo_ioctl, */ -+ mmap: mini_fo_mmap, -+ open: mini_fo_open, -+ flush: mini_fo_flush, -+ release: mini_fo_release, -+ fsync: mini_fo_fsync, -+ fasync: mini_fo_fasync, -+ /* not needed: lock: mini_fo_lock, */ -+ /* not needed: readv */ -+ /* not needed: writev */ -+ /* not implemented: sendpage */ -+ /* not implemented: get_unmapped_area */ -+ }; ---- /dev/null -+++ b/fs/mini_fo/fist.h -@@ -0,0 +1,248 @@ -+/* -+ * Copyright (c) 1997-2003 Erez Zadok -+ * Copyright (c) 2001-2003 Stony Brook University -+ * -+ * For specific licensing information, see the COPYING file distributed with -+ * this package, or get one from ftp://ftp.filesystems.org/pub/fist/COPYING. -+ * -+ * This Copyright notice must be kept intact and distributed with all -+ * fistgen sources INCLUDING sources generated by fistgen. -+ */ -+/* -+ * Copyright (C) 2004, 2005 Markus Klotzbuecher <mk@creamnet.de> -+ * -+ * 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. -+ */ -+ -+ -+/* -+ * $Id$ -+ */ -+ -+#ifndef __FIST_H_ -+#define __FIST_H_ -+ -+/* -+ * KERNEL ONLY CODE: -+ */ -+#ifdef __KERNEL__ -+#include <linux/config.h> -+#include <linux/version.h> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) -+#ifdef CONFIG_MODVERSIONS -+# define MODVERSIONS -+# include <linux/modversions.h> -+#endif /* CONFIG_MODVERSIONS */ -+#endif /* KERNEL_VERSION < 2.6.0 */ -+#include <linux/sched.h> -+#include <linux/kernel.h> -+#include <linux/mm.h> -+#include <linux/string.h> -+#include <linux/stat.h> -+#include <linux/errno.h> -+#include <linux/wait.h> -+#include <linux/limits.h> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) -+#include <linux/locks.h> -+#else -+#include <linux/buffer_head.h> -+#include <linux/pagemap.h> -+#include <linux/namei.h> -+#include <linux/module.h> -+#include <linux/mount.h> -+#include <linux/page-flags.h> -+#include <linux/writeback.h> -+#include <linux/statfs.h> -+#endif -+#include <linux/smp.h> -+#include <linux/smp_lock.h> -+#include <linux/file.h> -+#include <linux/slab.h> -+#include <linux/vmalloc.h> -+#include <linux/poll.h> -+#include <linux/list.h> -+#include <linux/init.h> -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20) -+#include <linux/xattr.h> -+#endif -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+#include <linux/security.h> -+#endif -+ -+#include <linux/swap.h> -+ -+#include <asm/system.h> -+#include <asm/segment.h> -+#include <asm/mman.h> -+#include <linux/seq_file.h> -+ -+/* -+ * MACROS: -+ */ -+ -+/* those mapped to ATTR_* were copied from linux/fs.h */ -+#define FA_MODE ATTR_MODE -+#define FA_UID ATTR_UID -+#define FA_GID ATTR_GID -+#define FA_SIZE ATTR_SIZE -+#define FA_ATIME ATTR_ATIME -+#define FA_MTIME ATTR_MTIME -+#define FA_CTIME ATTR_CTIME -+#define FA_ATIME_SET ATTR_ATIME_SET -+#define FA_MTIME_SET ATTR_MTIME_SET -+#define FA_FORCE ATTR_FORCE -+#define FA_ATTR_FLAGS ATTR_ATTR_FLAG -+ -+/* must be greater than all other ATTR_* flags! */ -+#define FA_NLINK 2048 -+#define FA_BLKSIZE 4096 -+#define FA_BLOCKS 8192 -+#define FA_TIMES (FA_ATIME|FA_MTIME|FA_CTIME) -+#define FA_ALL 0 -+ -+/* macros to manage changes between kernels */ -+#define INODE_DATA(i) (&(i)->i_data) -+ -+#define MIN(x,y) ((x < y) ? (x) : (y)) -+#define MAX(x,y) ((x > y) ? (x) : (y)) -+#define MAXPATHLEN PATH_MAX -+ -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,5) -+# define lookup_one_len(a,b,c) lookup_one(a,b) -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,4,5) */ -+ -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,8) -+# define generic_file_llseek default_llseek -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,4,8) */ -+ -+#ifndef SEEK_SET -+# define SEEK_SET 0 -+#endif /* not SEEK_SET */ -+ -+#ifndef SEEK_CUR -+# define SEEK_CUR 1 -+#endif /* not SEEK_CUR */ -+ -+#ifndef SEEK_END -+# define SEEK_END 2 -+#endif /* not SEEK_END */ -+ -+#ifndef DEFAULT_POLLMASK -+# define DEFAULT_POLLMASK (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM) -+#endif /* not DEFAULT_POLLMASK */ -+ -+/* XXX: fix this so fistgen generates kfree() code directly */ -+#define kfree_s(a,b) kfree(a) -+ -+/* -+ * TYPEDEFS: -+ */ -+typedef struct dentry dentry_t; -+typedef struct file file_t; -+typedef struct inode inode_t; -+typedef inode_t vnode_t; -+typedef struct page page_t; -+typedef struct qstr qstr_t; -+typedef struct super_block super_block_t; -+typedef super_block_t vfs_t; -+typedef struct vm_area_struct vm_area_t; -+ -+ -+/* -+ * EXTERNALS: -+ */ -+ -+#define FPPF(str,page) printk("PPF %s 0x%x/%d: Lck:%d Err:%d Ref:%d Upd:%d Other::%d:%d:%d:%d:\n", \ -+ str, \ -+ (int) page, \ -+ (int) page->index, \ -+ (PageLocked(page) ? 1 : 0), \ -+ (PageError(page) ? 1 : 0), \ -+ (PageReferenced(page) ? 1 : 0), \ -+ (Page_Uptodate(page) ? 1 : 0), \ -+ (PageDecrAfter(page) ? 1 : 0), \ -+ (PageSlab(page) ? 1 : 0), \ -+ (PageSwapCache(page) ? 1 : 0), \ -+ (PageReserved(page) ? 1 : 0) \ -+ ) -+#define EZKDBG printk("EZK %s:%d:%s\n",__FILE__,__LINE__,__FUNCTION__) -+#if 0 -+# define EZKDBG1 printk("EZK %s:%d\n",__FILE__,__LINE__) -+#else -+# define EZKDBG1 -+#endif -+ -+extern int fist_get_debug_value(void); -+extern int fist_set_debug_value(int val); -+#if 0 /* mini_fo doesn't need these */ -+extern void fist_dprint_internal(int level, char *str,...); -+extern void fist_print_dentry(char *str, const dentry_t *dentry); -+extern void fist_print_inode(char *str, const inode_t *inode); -+extern void fist_print_file(char *str, const file_t *file); -+extern void fist_print_buffer_flags(char *str, struct buffer_head *buffer); -+extern void fist_print_page_flags(char *str, page_t *page); -+extern void fist_print_page_bytes(char *str, page_t *page); -+extern void fist_print_pte_flags(char *str, const page_t *page); -+extern void fist_checkinode(inode_t *inode, char *msg); -+extern void fist_print_sb(char *str, const super_block_t *sb); -+ -+/* §$% by mk: special debug functions */ -+extern void fist_mk_print_dentry(char *str, const dentry_t *dentry); -+extern void fist_mk_print_inode(char *str, const inode_t *inode); -+ -+extern char *add_indent(void); -+extern char *del_indent(void); -+#endif/* mini_fo doesn't need these */ -+ -+ -+#define STATIC -+#define ASSERT(EX) \ -+do { \ -+ if (!(EX)) { \ -+ printk(KERN_CRIT "ASSERTION FAILED: %s at %s:%d (%s)\n", #EX, \ -+ __FILE__, __LINE__, __FUNCTION__); \ -+ (*((char *)0))=0; \ -+ } \ -+} while (0) -+/* same ASSERT, but tell me who was the caller of the function */ -+#define ASSERT2(EX) \ -+do { \ -+ if (!(EX)) { \ -+ printk(KERN_CRIT "ASSERTION FAILED (caller): %s at %s:%d (%s)\n", #EX, \ -+ file, line, func); \ -+ (*((char *)0))=0; \ -+ } \ -+} while (0) -+ -+#if 0 /* mini_fo doesn't need these */ -+#define dprintk(format, args...) printk(KERN_DEBUG format, ##args) -+#define fist_dprint(level, str, args...) fist_dprint_internal(level, KERN_DEBUG str, ## args) -+#define print_entry_location() fist_dprint(4, "%sIN: %s %s:%d\n", add_indent(), __FUNCTION__, __FILE__, __LINE__) -+#define print_exit_location() fist_dprint(4, "%s OUT: %s %s:%d\n", del_indent(), __FUNCTION__, __FILE__, __LINE__) -+#define print_exit_status(status) fist_dprint(4, "%s OUT: %s %s:%d, STATUS: %d\n", del_indent(), __FUNCTION__, __FILE__, __LINE__, status) -+#define print_exit_pointer(status) \ -+do { \ -+ if (IS_ERR(status)) \ -+ fist_dprint(4, "%s OUT: %s %s:%d, RESULT: %ld\n", del_indent(), __FUNCTION__, __FILE__, __LINE__, PTR_ERR(status)); \ -+ else \ -+ fist_dprint(4, "%s OUT: %s %s:%d, RESULT: 0x%x\n", del_indent(), __FUNCTION__, __FILE__, __LINE__, PTR_ERR(status)); \ -+} while (0) -+#endif/* mini_fo doesn't need these */ -+ -+#endif /* __KERNEL__ */ -+ -+ -+/* -+ * DEFINITIONS FOR USER AND KERNEL CODE: -+ * (Note: ioctl numbers 1--9 are reserved for fistgen, the rest -+ * are auto-generated automatically based on the user's .fist file.) -+ */ -+# define FIST_IOCTL_GET_DEBUG_VALUE _IOR(0x15, 1, int) -+# define FIST_IOCTL_SET_DEBUG_VALUE _IOW(0x15, 2, int) -+ -+#endif /* not __FIST_H_ */ ---- /dev/null -+++ b/fs/mini_fo/inode.c -@@ -0,0 +1,1573 @@ -+/* -+ * Copyright (c) 1997-2003 Erez Zadok -+ * Copyright (c) 2001-2003 Stony Brook University -+ * -+ * For specific licensing information, see the COPYING file distributed with -+ * this package, or get one from ftp://ftp.filesystems.org/pub/fist/COPYING. -+ * -+ * This Copyright notice must be kept intact and distributed with all -+ * fistgen sources INCLUDING sources generated by fistgen. -+ */ -+/* -+ * Copyright (C) 2004, 2005 Markus Klotzbuecher <mk@creamnet.de> -+ * -+ * 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. -+ */ -+ -+/* -+ * $Id$ -+ */ -+ -+#ifdef HAVE_CONFIG_H -+# include <config.h> -+#endif -+ -+#include "fist.h" -+#include "mini_fo.h" -+ -+STATIC int -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+mini_fo_create(inode_t *dir, dentry_t *dentry, int mode, struct nameidata *nd) -+#else -+mini_fo_create(inode_t *dir, dentry_t *dentry, int mode) -+#endif -+{ -+ int err = 0; -+ -+ check_mini_fo_dentry(dentry); -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+ err = create_sto_reg_file(dentry, mode, nd); -+#else -+ err = create_sto_reg_file(dentry, mode); -+#endif -+ check_mini_fo_dentry(dentry); -+ return err; -+} -+ -+ -+STATIC dentry_t * -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+mini_fo_lookup(inode_t *dir, dentry_t *dentry, struct nameidata* nd) -+#else -+mini_fo_lookup(inode_t *dir, dentry_t *dentry) -+#endif -+{ -+ int err = 0; -+ dentry_t *hidden_dir_dentry; -+ dentry_t *hidden_dentry = NULL; -+ -+ dentry_t *hidden_sto_dir_dentry; -+ dentry_t *hidden_sto_dentry = NULL; -+ -+ /* whiteout flag */ -+ int del_flag = 0; -+ char *bpath = NULL; -+ -+ const char *name; -+ unsigned int namelen; -+ -+ /* Don't allow lookups of META-files */ -+ namelen = strlen(META_FILENAME); -+ if(namelen == dentry->d_name.len) { -+ if(!strncmp(dentry->d_name.name, META_FILENAME, namelen)) { -+ err = -ENOENT; -+ goto out; -+ } -+ } -+ -+ hidden_dir_dentry = dtohd(dentry->d_parent); -+ hidden_sto_dir_dentry = dtohd2(dentry->d_parent); -+ -+ name = dentry->d_name.name; -+ namelen = dentry->d_name.len; -+ -+ /* must initialize dentry operations */ -+ dentry->d_op = &mini_fo_dops; -+ -+ /* setup the del_flag */ -+ del_flag = __meta_check_d_entry(dir, name, namelen); -+ bpath = __meta_check_r_entry(dir, name, namelen); -+ -+ /* perform the lookups of base and storage files: -+ * -+ * This caused some serious trouble, as a lookup_one_len passing -+ * a negative dentry oopses. Solution is to only do the lookup -+ * if the dentry is positive, else we set it to NULL -+ * More trouble, who said a *_dir_dentry can't be NULL? -+ */ -+ if(bpath) { -+ /* Cross-Interposing (C), yeah! */ -+ hidden_dentry = bpath_walk(dir->i_sb, bpath); -+ if(!hidden_dentry || !hidden_dentry->d_inode) { -+ printk(KERN_CRIT "mini_fo_lookup: bpath_walk failed.\n"); -+ err= -EINVAL; -+ goto out; -+ } -+ -+ /* this can be set up safely without fear of spaghetti -+ * interposing as it is only used for copying times */ -+ hidden_dir_dentry = hidden_dentry->d_parent; -+ kfree(bpath); -+ } -+ else if(hidden_dir_dentry && hidden_dir_dentry->d_inode) -+ hidden_dentry = -+ lookup_one_len(name, hidden_dir_dentry, namelen); -+ else -+ hidden_dentry = NULL; -+ -+ if(hidden_sto_dir_dentry && hidden_sto_dir_dentry->d_inode) -+ hidden_sto_dentry = -+ lookup_one_len(name, hidden_sto_dir_dentry, namelen); -+ else -+ hidden_sto_dentry = NULL; -+ -+ /* catch error in lookup */ -+ if (IS_ERR(hidden_dentry) || IS_ERR(hidden_sto_dentry)) { -+ /* mk: we need to call dput on the dentry, whose -+ * lookup_one_len operation failed, in order to avoid -+ * unmount trouble. -+ */ -+ if(IS_ERR(hidden_dentry)) { -+ printk(KERN_CRIT "mini_fo_lookup: ERR from base dentry, lookup failed.\n"); -+ err = PTR_ERR(hidden_dentry); -+ } else { -+ dput(hidden_dentry); -+ } -+ if(IS_ERR(hidden_sto_dentry)) { -+ printk(KERN_CRIT "mini_fo_lookup: ERR from storage dentry, lookup failed.\n"); -+ err = PTR_ERR(hidden_sto_dentry); -+ } else { -+ dput(hidden_sto_dentry); -+ } -+ goto out; -+ } -+ -+ /* allocate dentry private data */ -+ __dtopd(dentry) = (struct mini_fo_dentry_info *) -+ kmalloc(sizeof(struct mini_fo_dentry_info), GFP_KERNEL); -+ -+ if (!dtopd(dentry)) { -+ err = -ENOMEM; -+ goto out_dput; -+ } -+ -+ /* check for different states of the mini_fo file to be looked up. */ -+ -+ /* state 1, file has been modified */ -+ if(hidden_dentry && hidden_sto_dentry && -+ hidden_dentry->d_inode && hidden_sto_dentry->d_inode && !del_flag) { -+ -+ /* update parent directory's atime */ -+ fist_copy_attr_atime(dir, hidden_sto_dir_dentry->d_inode); -+ -+ dtopd(dentry)->state = MODIFIED; -+ dtohd(dentry) = hidden_dentry; -+ dtohd2(dentry) = hidden_sto_dentry; -+ -+ err = mini_fo_tri_interpose(hidden_dentry, -+ hidden_sto_dentry, -+ dentry, dir->i_sb, 1); -+ if (err) { -+ printk(KERN_CRIT "mini_fo_lookup: error interposing (state1).\n"); -+ goto out_free; -+ } -+ goto out; -+ } -+ /* state 2, file is unmodified */ -+ if(hidden_dentry && hidden_dentry->d_inode && !del_flag) { -+ -+ fist_copy_attr_atime(dir, hidden_dir_dentry->d_inode); -+ -+ dtopd(dentry)->state = UNMODIFIED; -+ dtohd(dentry) = hidden_dentry; -+ dtohd2(dentry) = hidden_sto_dentry; /* could be negative */ -+ -+ err = mini_fo_tri_interpose(hidden_dentry, -+ hidden_sto_dentry, -+ dentry, dir->i_sb, 1); -+ if (err) { -+ printk(KERN_CRIT "mini_fo_lookup: error interposing (state2).\n"); -+ goto out_free; -+ } -+ goto out; -+ } -+ /* state 3, file has been newly created */ -+ if(hidden_sto_dentry && hidden_sto_dentry->d_inode && !del_flag) { -+ -+ fist_copy_attr_atime(dir, hidden_sto_dir_dentry->d_inode); -+ dtopd(dentry)->state = CREATED; -+ dtohd(dentry) = hidden_dentry; /* could be negative */ -+ dtohd2(dentry) = hidden_sto_dentry; -+ -+ err = mini_fo_tri_interpose(hidden_dentry, -+ hidden_sto_dentry, -+ dentry, dir->i_sb, 1); -+ if (err) { -+ printk(KERN_CRIT "mini_fo_lookup: error interposing (state3).\n"); -+ goto out_free; -+ } -+ goto out; -+ } -+ -+ /* state 4, file has deleted and created again. */ -+ if(hidden_dentry && hidden_sto_dentry && -+ hidden_dentry->d_inode && -+ hidden_sto_dentry->d_inode && del_flag) { -+ -+ fist_copy_attr_atime(dir, hidden_sto_dir_dentry->d_inode); -+ dtopd(dentry)->state = DEL_REWRITTEN; -+ dtohd(dentry) = NULL; -+ dtohd2(dentry) = hidden_sto_dentry; -+ -+ err = mini_fo_tri_interpose(NULL, -+ hidden_sto_dentry, -+ dentry, dir->i_sb, 1); -+ if (err) { -+ printk(KERN_CRIT "mini_fo_lookup: error interposing (state4).\n"); -+ goto out_free; -+ } -+ /* We will never need this dentry again, as the file has been -+ * deleted from base */ -+ dput(hidden_dentry); -+ goto out; -+ } -+ /* state 5, file has been deleted in base */ -+ if(hidden_dentry && hidden_sto_dentry && -+ hidden_dentry->d_inode && -+ !hidden_sto_dentry->d_inode && del_flag) { -+ -+ /* check which parents atime we need for updating */ -+ if(hidden_sto_dir_dentry->d_inode) -+ fist_copy_attr_atime(dir, -+ hidden_sto_dir_dentry->d_inode); -+ else -+ fist_copy_attr_atime(dir, -+ hidden_dir_dentry->d_inode); -+ -+ dtopd(dentry)->state = DELETED; -+ dtohd(dentry) = NULL; -+ dtohd2(dentry) = hidden_sto_dentry; -+ -+ /* add negative dentry to dcache to speed up lookups */ -+ d_add(dentry, NULL); -+ dput(hidden_dentry); -+ goto out; -+ } -+ /* state 6, file does not exist */ -+ if(((hidden_dentry && !hidden_dentry->d_inode) || -+ (hidden_sto_dentry && !hidden_sto_dentry->d_inode)) && !del_flag) -+ { -+ /* check which parents atime we need for updating */ -+ if(hidden_sto_dir_dentry && hidden_sto_dir_dentry->d_inode) -+ fist_copy_attr_atime(dir, hidden_sto_dir_dentry->d_inode); -+ else -+ fist_copy_attr_atime(dir, hidden_dir_dentry->d_inode); -+ -+ dtopd(dentry)->state = NON_EXISTANT; -+ dtohd(dentry) = hidden_dentry; -+ dtohd2(dentry) = hidden_sto_dentry; -+ d_add(dentry, NULL); -+ goto out; -+ } -+ -+ /* if we get to here, were in an invalid state. bad. */ -+ printk(KERN_CRIT "mini_fo_lookup: ERROR, meta data corruption detected.\n"); -+ -+ /* end state checking */ -+ out_free: -+ d_drop(dentry); /* so that our bad dentry will get destroyed */ -+ kfree(dtopd(dentry)); -+ __dtopd(dentry) = NULL; /* be safe */ -+ -+ out_dput: -+ if(hidden_dentry) -+ dput(hidden_dentry); -+ if(hidden_sto_dentry) -+ dput(hidden_sto_dentry); /* drops usage count and marks for release */ -+ -+ out: -+ /* initalize wol if file exists and is directory */ -+ if(dentry->d_inode) { -+ if(S_ISDIR(dentry->d_inode->i_mode)) { -+ itopd(dentry->d_inode)->deleted_list_size = -1; -+ itopd(dentry->d_inode)->renamed_list_size = -1; -+ meta_build_lists(dentry); -+ } -+ } -+ return ERR_PTR(err); -+} -+ -+ -+STATIC int -+mini_fo_link(dentry_t *old_dentry, inode_t *dir, dentry_t *new_dentry) -+{ -+ int err; -+ dentry_t *hidden_old_dentry; -+ dentry_t *hidden_new_dentry; -+ dentry_t *hidden_dir_dentry; -+ -+ -+ check_mini_fo_dentry(old_dentry); -+ check_mini_fo_dentry(new_dentry); -+ check_mini_fo_inode(dir); -+ -+ /* no links to directorys and existing targets target allowed */ -+ if(S_ISDIR(old_dentry->d_inode->i_mode) || -+ is_mini_fo_existant(new_dentry)) { -+ err = -EPERM; -+ goto out; -+ } -+ -+ /* bring it directly from unmod to del_rew */ -+ if(dtost(old_dentry) == UNMODIFIED) { -+ err = nondir_unmod_to_mod(old_dentry, 1); -+ if(err) { -+ err = -EINVAL; -+ goto out; -+ } -+ err = meta_add_d_entry(old_dentry->d_parent, -+ old_dentry->d_name.name, -+ old_dentry->d_name.len); -+ if(err) { -+ err = -EINVAL; -+ goto out; -+ } -+ dput(dtohd(old_dentry)); -+ dtohd(old_dentry) = NULL; -+ dtost(old_dentry) = DEL_REWRITTEN; -+ } -+ -+ err = get_neg_sto_dentry(new_dentry); -+ if(err) { -+ err = -EINVAL; -+ goto out; -+ } -+ -+ hidden_old_dentry = dtohd2(old_dentry); -+ hidden_new_dentry = dtohd2(new_dentry); -+ -+ dget(hidden_old_dentry); -+ dget(hidden_new_dentry); -+ -+ /* was: hidden_dir_dentry = lock_parent(hidden_new_dentry); */ -+ hidden_dir_dentry = dget(hidden_new_dentry->d_parent); -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_lock(&hidden_dir_dentry->d_inode->i_mutex); -+#else -+ down(&hidden_dir_dentry->d_inode->i_sem); -+#endif -+ -+ err = vfs_link(hidden_old_dentry, -+ hidden_dir_dentry->d_inode, -+ hidden_new_dentry); -+ if (err || !hidden_new_dentry->d_inode) -+ goto out_lock; -+ -+ dtost(new_dentry) = CREATED; -+ err = mini_fo_tri_interpose(NULL, hidden_new_dentry, new_dentry, dir->i_sb, 0); -+ if (err) -+ goto out_lock; -+ -+ fist_copy_attr_timesizes(dir, hidden_new_dentry->d_inode); -+ /* propagate number of hard-links */ -+ old_dentry->d_inode->i_nlink = itohi2(old_dentry->d_inode)->i_nlink; -+ -+ out_lock: -+ /* was: unlock_dir(hidden_dir_dentry); */ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_unlock(&hidden_dir_dentry->d_inode->i_mutex); -+#else -+ up(&hidden_dir_dentry->d_inode->i_sem); -+#endif -+ dput(hidden_dir_dentry); -+ -+ dput(hidden_new_dentry); -+ dput(hidden_old_dentry); -+ if (!new_dentry->d_inode) -+ d_drop(new_dentry); -+ -+ out: -+ return err; -+} -+ -+ -+STATIC int -+mini_fo_unlink(inode_t *dir, dentry_t *dentry) -+{ -+ int err = 0; -+ -+ dget(dentry); -+ if(dtopd(dentry)->state == MODIFIED) { -+ err = nondir_mod_to_del(dentry); -+ goto out; -+ } -+ else if(dtopd(dentry)->state == UNMODIFIED) { -+ err = nondir_unmod_to_del(dentry); -+ goto out; -+ } -+ else if(dtopd(dentry)->state == CREATED) { -+ err = nondir_creat_to_del(dentry); -+ goto out; -+ } -+ else if(dtopd(dentry)->state == DEL_REWRITTEN) { -+ err = nondir_del_rew_to_del(dentry); -+ goto out; -+ } -+ -+ printk(KERN_CRIT "mini_fo_unlink: ERROR, invalid state detected.\n"); -+ -+ out: -+ fist_copy_attr_times(dir, itohi2(dentry->d_parent->d_inode)); -+ -+ if(!err) { -+ /* is this causing my pain? d_delete(dentry); */ -+ d_drop(dentry); -+ } -+ -+ dput(dentry); -+ return err; -+} -+ -+ -+STATIC int -+mini_fo_symlink(inode_t *dir, dentry_t *dentry, const char *symname) -+{ -+ int err=0; -+ dentry_t *hidden_sto_dentry; -+ dentry_t *hidden_sto_dir_dentry; -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+ umode_t mode; -+#endif -+ -+ /* Fail if the symlink file exists */ -+ if(!(dtost(dentry) == DELETED || -+ dtost(dentry) == NON_EXISTANT)) { -+ err = -EEXIST; -+ goto out; -+ } -+ -+ err = get_neg_sto_dentry(dentry); -+ if(err) { -+ err = -EINVAL; -+ goto out; -+ } -+ hidden_sto_dentry = dtohd2(dentry); -+ -+ dget(hidden_sto_dentry); -+ /* was: hidden_sto_dir_dentry = lock_parent(hidden_sto_dentry); */ -+ hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent); -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex); -+#else -+ down(&hidden_sto_dir_dentry->d_inode->i_sem); -+#endif -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+ mode = S_IALLUGO; -+ err = vfs_symlink(hidden_sto_dir_dentry->d_inode, -+ hidden_sto_dentry, symname, mode); -+#else -+ err = vfs_symlink(hidden_sto_dir_dentry->d_inode, -+ hidden_sto_dentry, -+ symname); -+#endif -+ if (err || !hidden_sto_dentry->d_inode) -+ goto out_lock; -+ -+ if(dtost(dentry) == DELETED) { -+ dtost(dentry) = DEL_REWRITTEN; -+ err = mini_fo_tri_interpose(NULL, hidden_sto_dentry, dentry, dir->i_sb, 0); -+ if(err) -+ goto out_lock; -+ } else if(dtost(dentry) == NON_EXISTANT) { -+ dtost(dentry) = CREATED; -+ err = mini_fo_tri_interpose(dtohd(dentry), hidden_sto_dentry, dentry, dir->i_sb, 0); -+ if(err) -+ goto out_lock; -+ } -+ fist_copy_attr_timesizes(dir, hidden_sto_dir_dentry->d_inode); -+ -+ out_lock: -+ /* was: unlock_dir(hidden_sto_dir_dentry); */ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex); -+#else -+ up(&hidden_sto_dir_dentry->d_inode->i_sem); -+#endif -+ dput(hidden_sto_dir_dentry); -+ -+ dput(hidden_sto_dentry); -+ if (!dentry->d_inode) -+ d_drop(dentry); -+ out: -+ return err; -+} -+ -+STATIC int -+mini_fo_mkdir(inode_t *dir, dentry_t *dentry, int mode) -+{ -+ int err; -+ -+ err = create_sto_dir(dentry, mode); -+ -+ check_mini_fo_dentry(dentry); -+ -+ return err; -+} -+ -+ -+STATIC int -+mini_fo_rmdir(inode_t *dir, dentry_t *dentry) -+{ -+ int err = 0; -+ -+ dentry_t *hidden_sto_dentry; -+ dentry_t *hidden_sto_dir_dentry; -+ dentry_t *meta_dentry; -+ inode_t *hidden_sto_dir = NULL; -+ -+ check_mini_fo_dentry(dentry); -+ check_mini_fo_inode(dir); -+ -+ dget(dentry); -+ if(dtopd(dentry)->state == MODIFIED) { -+ /* XXX: disabled, because it does not bother to check files on -+ * the original filesystem - just a hack, but better than simply -+ * removing it without testing */ -+ err = -EINVAL; -+ goto out; -+ -+ hidden_sto_dir = itohi2(dir); -+ hidden_sto_dentry = dtohd2(dentry); -+ -+ /* was:hidden_sto_dir_dentry = lock_parent(hidden_sto_dentry); */ -+ hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent); -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex); -+#else -+ down(&hidden_sto_dir_dentry->d_inode->i_sem); -+#endif -+ -+ /* avoid destroying the hidden inode if the file is in use */ -+ dget(hidden_sto_dentry); -+ -+ /* Delete an old WOL file contained in the storage dir */ -+ meta_dentry = lookup_one_len(META_FILENAME, -+ hidden_sto_dentry, -+ strlen(META_FILENAME)); -+ if(meta_dentry->d_inode) { -+ err = vfs_unlink(hidden_sto_dentry->d_inode, meta_dentry); -+ dput(meta_dentry); -+ if(!err) -+ d_delete(meta_dentry); -+ } -+ -+ err = vfs_rmdir(hidden_sto_dir, hidden_sto_dentry); -+ dput(hidden_sto_dentry); -+ if(!err) -+ d_delete(hidden_sto_dentry); -+ -+ /* propagate number of hard-links */ -+ dentry->d_inode->i_nlink = itohi2(dentry->d_inode)->i_nlink; -+ -+ dput(dtohd(dentry)); -+ -+ dtohd(dentry) = NULL; -+ dtopd(dentry)->state = DELETED; -+ -+ /* carefull with R files */ -+ if( __meta_is_r_entry(dir, -+ dentry->d_name.name, -+ dentry->d_name.len) == 1) { -+ err = meta_remove_r_entry(dentry->d_parent, -+ dentry->d_name.name, -+ dentry->d_name.len); -+ if(err) { -+ printk(KERN_CRIT "mini_fo: rmdir: meta_remove_r_entry failed.\n"); -+ goto out; -+ } -+ } -+ else { -+ /* ok, add deleted file to META */ -+ meta_add_d_entry(dentry->d_parent, -+ dentry->d_name.name, -+ dentry->d_name.len); -+ } -+ /* was: unlock_dir(hidden_sto_dir_dentry); */ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex); -+#else -+ up(&hidden_sto_dir_dentry->d_inode->i_sem); -+#endif -+ dput(hidden_sto_dir_dentry); -+ goto out; -+ } -+ else if(dtopd(dentry)->state == UNMODIFIED) { -+ /* XXX: simply adding it to the delete list here is fscking dangerous! -+ * as a temporary hack, i will disable rmdir on unmodified directories -+ * for now. -+ */ -+ err = -EINVAL; -+ goto out; -+ -+ err = get_neg_sto_dentry(dentry); -+ if(err) { -+ err = -EINVAL; -+ goto out; -+ } -+ -+ /* dput base dentry, this will relase the inode and free the -+ * dentry, as we will never need it again. */ -+ dput(dtohd(dentry)); -+ dtohd(dentry) = NULL; -+ dtopd(dentry)->state = DELETED; -+ -+ /* add deleted file to META-file */ -+ meta_add_d_entry(dentry->d_parent, -+ dentry->d_name.name, -+ dentry->d_name.len); -+ goto out; -+ } -+ else if(dtopd(dentry)->state == CREATED) { -+ hidden_sto_dir = itohi2(dir); -+ hidden_sto_dentry = dtohd2(dentry); -+ -+ /* was: hidden_sto_dir_dentry = lock_parent(hidden_sto_dentry);*/ -+ hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent); -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex); -+#else -+ down(&hidden_sto_dir_dentry->d_inode->i_sem); -+#endif -+ -+ /* avoid destroying the hidden inode if the file is in use */ -+ dget(hidden_sto_dentry); -+ -+ /* Delete an old WOL file contained in the storage dir */ -+ meta_dentry = lookup_one_len(META_FILENAME, -+ hidden_sto_dentry, -+ strlen(META_FILENAME)); -+ if(meta_dentry->d_inode) { -+ /* is this necessary? dget(meta_dentry); */ -+ err = vfs_unlink(hidden_sto_dentry->d_inode, -+ meta_dentry); -+ dput(meta_dentry); -+ if(!err) -+ d_delete(meta_dentry); -+ } -+ -+ err = vfs_rmdir(hidden_sto_dir, hidden_sto_dentry); -+ dput(hidden_sto_dentry); -+ if(!err) -+ d_delete(hidden_sto_dentry); -+ -+ /* propagate number of hard-links */ -+ dentry->d_inode->i_nlink = itohi2(dentry->d_inode)->i_nlink; -+ dtopd(dentry)->state = NON_EXISTANT; -+ -+ /* was: unlock_dir(hidden_sto_dir_dentry); */ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex); -+#else -+ up(&hidden_sto_dir_dentry->d_inode->i_sem); -+#endif -+ dput(hidden_sto_dir_dentry); -+ -+ goto out; -+ } -+ else if(dtopd(dentry)->state == DEL_REWRITTEN) { -+ hidden_sto_dir = itohi2(dir); -+ hidden_sto_dentry = dtohd2(dentry); -+ -+ /* was: hidden_sto_dir_dentry = lock_parent(hidden_sto_dentry);*/ -+ hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent); -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex); -+#else -+ down(&hidden_sto_dir_dentry->d_inode->i_sem); -+#endif -+ -+ /* avoid destroying the hidden inode if the file is in use */ -+ dget(hidden_sto_dentry); -+ -+ /* Delete an old WOL file contained in the storage dir */ -+ meta_dentry = lookup_one_len(META_FILENAME, -+ hidden_sto_dentry, -+ strlen(META_FILENAME)); -+ if(meta_dentry->d_inode) { -+ /* is this necessary? dget(meta_dentry); */ -+ err = vfs_unlink(hidden_sto_dentry->d_inode, -+ meta_dentry); -+ dput(meta_dentry); -+ if(!err) -+ d_delete(meta_dentry); -+ } -+ -+ err = vfs_rmdir(hidden_sto_dir, hidden_sto_dentry); -+ dput(hidden_sto_dentry); -+ if(!err) -+ d_delete(hidden_sto_dentry); -+ -+ /* propagate number of hard-links */ -+ dentry->d_inode->i_nlink = itohi2(dentry->d_inode)->i_nlink; -+ dtopd(dentry)->state = DELETED; -+ /* was: unlock_dir(hidden_sto_dir_dentry); */ -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex); -+#else -+ up(&hidden_sto_dir_dentry->d_inode->i_sem); -+#endif -+ dput(hidden_sto_dir_dentry); -+ goto out; -+ } -+ -+ printk(KERN_CRIT "mini_fo_rmdir: ERROR, invalid state detected.\n"); -+ -+ out: -+ if(!err) { -+ d_drop(dentry); -+ } -+ -+ fist_copy_attr_times(dir, itohi2(dentry->d_parent->d_inode)); -+ dput(dentry); -+ -+ return err; -+} -+ -+ -+STATIC int -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+mini_fo_mknod(inode_t *dir, dentry_t *dentry, int mode, dev_t dev) -+#else -+mini_fo_mknod(inode_t *dir, dentry_t *dentry, int mode, int dev) -+#endif -+{ -+ int err = 0; -+ -+ check_mini_fo_dentry(dentry); -+ -+ err = create_sto_nod(dentry, mode, dev); -+ if(err) { -+ printk(KERN_CRIT "mini_fo_mknod: creating sto nod failed.\n"); -+ err = -EINVAL; -+ } -+ -+ check_mini_fo_dentry(dentry); -+ return err; -+} -+ -+ -+STATIC int -+mini_fo_rename(inode_t *old_dir, dentry_t *old_dentry, -+ inode_t *new_dir, dentry_t *new_dentry) -+{ -+ /* dispatch */ -+ if(S_ISDIR(old_dentry->d_inode->i_mode)) -+ return rename_directory(old_dir, old_dentry, new_dir, new_dentry); -+ return rename_nondir(old_dir, old_dentry, new_dir, new_dentry); -+ -+} -+ -+int rename_directory(inode_t *old_dir, dentry_t *old_dentry, -+ inode_t *new_dir, dentry_t *new_dentry) -+{ -+ int err, bpath_len; -+ char *bpath; -+ -+ dentry_t *hidden_old_dentry; -+ dentry_t *hidden_new_dentry; -+ dentry_t *hidden_old_dir_dentry; -+ dentry_t *hidden_new_dir_dentry; -+ -+ err = 0; -+ bpath = NULL; -+ bpath_len = 0; -+ -+ /* this is a test, chuck out if it works */ -+ if(!(dtopd(new_dentry)->state == DELETED || -+ dtopd(new_dentry)->state == NON_EXISTANT)) { -+ printk(KERN_CRIT "mini_fo: rename_directory: \ -+ uh, ah, new_dentry not negative.\n"); -+ /* return -1; */ -+ } -+ -+ /* state = UNMODIFIED */ -+ if(dtopd(old_dentry)->state == UNMODIFIED) { -+ err = dir_unmod_to_mod(old_dentry); -+ if (err) -+ goto out; -+ } -+ -+ /* state = MODIFIED */ -+ if(dtopd(old_dentry)->state == MODIFIED) { -+ bpath = meta_check_r_entry(old_dentry->d_parent, -+ old_dentry->d_name.name, -+ old_dentry->d_name.len); -+ if(bpath) { -+ err = meta_remove_r_entry(old_dentry->d_parent, -+ old_dentry->d_name.name, -+ old_dentry->d_name.len); -+ if(err) { -+ printk(KERN_CRIT "mini_fo: rename_directory:\ -+ meta_remove_r_entry \ -+ failed.\n"); -+ goto out; -+ } -+ err = meta_add_r_entry(new_dentry->d_parent, -+ bpath, -+ strlen(bpath), -+ new_dentry->d_name.name, -+ new_dentry->d_name.len); -+ kfree(bpath); -+ } -+ else {/* wol it */ -+ err = meta_add_d_entry(old_dentry->d_parent, -+ old_dentry->d_name.name, -+ old_dentry->d_name.len); -+ if (err) -+ goto out; -+ /* put it on rename list */ -+ err = get_mini_fo_bpath(old_dentry, -+ &bpath, -+ &bpath_len); -+ if (err) -+ goto out; -+ err = meta_add_r_entry(new_dentry->d_parent, -+ bpath, bpath_len, -+ new_dentry->d_name.name, -+ new_dentry->d_name.len); -+ if (err) -+ goto out; -+ } -+ /* no state change, MODIFIED stays MODIFIED */ -+ } -+ /* state = CREATED */ -+ if(dtopd(old_dentry)->state == CREATED || -+ dtopd(old_dentry)->state == DEL_REWRITTEN) { -+ if(dtohd(old_dentry)) -+ dput(dtohd(old_dentry)); -+ -+ if(dtopd(new_dentry)->state == DELETED) { -+ dtopd(old_dentry)->state = DEL_REWRITTEN; -+ dtohd(old_dentry) = NULL; -+ } -+ else if(dtopd(new_dentry)->state == NON_EXISTANT) { -+ dtopd(old_dentry)->state = CREATED; -+ /* steal new dentry's neg. base dentry */ -+ dtohd(old_dentry) = dtohd(new_dentry); -+ dtohd(new_dentry) = NULL; -+ } -+ } -+ if(dtopd(new_dentry)->state == UNMODIFIED || -+ dtopd(new_dentry)->state == NON_EXISTANT) { -+ err = get_neg_sto_dentry(new_dentry); -+ if(err) -+ goto out; -+ } -+ -+ /* now move sto file */ -+ hidden_old_dentry = dtohd2(old_dentry); -+ hidden_new_dentry = dtohd2(new_dentry); -+ -+ dget(hidden_old_dentry); -+ dget(hidden_new_dentry); -+ -+ hidden_old_dir_dentry = dget(hidden_old_dentry->d_parent); -+ hidden_new_dir_dentry = dget(hidden_new_dentry->d_parent); -+ double_lock(hidden_old_dir_dentry, hidden_new_dir_dentry); -+ -+ err = vfs_rename(hidden_old_dir_dentry->d_inode, hidden_old_dentry, -+ hidden_new_dir_dentry->d_inode, hidden_new_dentry); -+ if(err) -+ goto out_lock; -+ -+ fist_copy_attr_all(new_dir, hidden_new_dir_dentry->d_inode); -+ if (new_dir != old_dir) -+ fist_copy_attr_all(old_dir, -+ hidden_old_dir_dentry->d_inode); -+ -+ out_lock: -+ /* double_unlock will dput the new/old parent dentries -+ * whose refcnts were incremented via get_parent above. */ -+ double_unlock(hidden_old_dir_dentry, hidden_new_dir_dentry); -+ dput(hidden_new_dentry); -+ dput(hidden_old_dentry); -+ -+ out: -+ return err; -+} -+ -+int rename_nondir(inode_t *old_dir, dentry_t *old_dentry, -+ inode_t *new_dir, dentry_t *new_dentry) -+{ -+ int err=0; -+ -+ check_mini_fo_dentry(old_dentry); -+ check_mini_fo_dentry(new_dentry); -+ check_mini_fo_inode(old_dir); -+ check_mini_fo_inode(new_dir); -+ -+ /* state: UNMODIFIED */ -+ if(dtost(old_dentry) == UNMODIFIED) { -+ err = nondir_unmod_to_mod(old_dentry, 1); -+ if(err) { -+ err = -EINVAL; -+ goto out; -+ } -+ } -+ -+ /* the easy states */ -+ if(exists_in_storage(old_dentry)) { -+ -+ dentry_t *hidden_old_dentry; -+ dentry_t *hidden_new_dentry; -+ dentry_t *hidden_old_dir_dentry; -+ dentry_t *hidden_new_dir_dentry; -+ -+ /* if old file is MODIFIED, add it to the deleted_list */ -+ if(dtopd(old_dentry)->state == MODIFIED) { -+ meta_add_d_entry(old_dentry->d_parent, -+ old_dentry->d_name.name, -+ old_dentry->d_name.len); -+ -+ dput(dtohd(old_dentry)); -+ } -+ /* if old file is CREATED, we only release the base dentry */ -+ if(dtopd(old_dentry)->state == CREATED) { -+ if(dtohd(old_dentry)) -+ dput(dtohd(old_dentry)); -+ } -+ -+ /* now setup the new states (depends on new_dentry state) */ -+ /* new dentry state = MODIFIED */ -+ if(dtopd(new_dentry)->state == MODIFIED) { -+ meta_add_d_entry(new_dentry->d_parent, -+ new_dentry->d_name.name, -+ new_dentry->d_name.len); -+ -+ /* new dentry will be d_put'ed later by the vfs -+ * so don't do it here -+ * dput(dtohd(new_dentry)); -+ */ -+ dtohd(old_dentry) = NULL; -+ dtopd(old_dentry)->state = DEL_REWRITTEN; -+ } -+ /* new dentry state = UNMODIFIED */ -+ else if(dtopd(new_dentry)->state == UNMODIFIED) { -+ if(get_neg_sto_dentry(new_dentry)) -+ return -EINVAL; -+ -+ meta_add_d_entry(new_dentry->d_parent, -+ new_dentry->d_name.name, -+ new_dentry->d_name.len); -+ -+ /* is this right??? */ -+ /*dput(dtohd(new_dentry));*/ -+ dtohd(old_dentry) = NULL; -+ dtopd(old_dentry)->state = DEL_REWRITTEN; -+ } -+ /* new dentry state = CREATED */ -+ else if(dtopd(new_dentry)->state == CREATED) { -+ /* we keep the neg. base dentry (if exists) */ -+ dtohd(old_dentry) = dtohd(new_dentry); -+ /* ...and set it to Null, or we'll get -+ * dcache.c:345 if it gets dput twice... */ -+ dtohd(new_dentry) = NULL; -+ dtopd(old_dentry)->state = CREATED; -+ } -+ /* new dentry state = NON_EXISTANT */ -+ else if(dtopd(new_dentry)->state == NON_EXISTANT) { -+ if(get_neg_sto_dentry(new_dentry)) -+ return -EINVAL; -+ -+ /* we keep the neg. base dentry (if exists) */ -+ dtohd(old_dentry) = dtohd(new_dentry); -+ /* ...and set it to Null, or we'll get -+ * Dr. dcache.c:345 if it gets dput twice... */ -+ dtohd(new_dentry) = NULL; -+ dtopd(old_dentry)->state = CREATED; -+ } -+ /* new dentry state = DEL_REWRITTEN or DELETED */ -+ else if(dtopd(new_dentry)->state == DEL_REWRITTEN || -+ dtopd(new_dentry)->state == DELETED) { -+ dtohd(old_dentry) = NULL; -+ dtopd(old_dentry)->state = DEL_REWRITTEN; -+ } -+ else { /* not possible, uhh, ahh */ -+ printk(KERN_CRIT -+ "mini_fo: rename_reg_file: invalid state detected [1].\n"); -+ return -1; -+ } -+ -+ /* now we definitely have a sto file */ -+ hidden_old_dentry = dtohd2(old_dentry); -+ hidden_new_dentry = dtohd2(new_dentry); -+ -+ dget(hidden_old_dentry); -+ dget(hidden_new_dentry); -+ -+ hidden_old_dir_dentry = dget(hidden_old_dentry->d_parent); -+ hidden_new_dir_dentry = dget(hidden_new_dentry->d_parent); -+ double_lock(hidden_old_dir_dentry, hidden_new_dir_dentry); -+ -+ err = vfs_rename(hidden_old_dir_dentry->d_inode, -+ hidden_old_dentry, -+ hidden_new_dir_dentry->d_inode, -+ hidden_new_dentry); -+ if(err) -+ goto out_lock; -+ -+ fist_copy_attr_all(new_dir, hidden_new_dir_dentry->d_inode); -+ if (new_dir != old_dir) -+ fist_copy_attr_all(old_dir, hidden_old_dir_dentry->d_inode); -+ -+ out_lock: -+ /* double_unlock will dput the new/old parent dentries -+ * whose refcnts were incremented via get_parent above. -+ */ -+ double_unlock(hidden_old_dir_dentry, hidden_new_dir_dentry); -+ dput(hidden_new_dentry); -+ dput(hidden_old_dentry); -+ out: -+ return err; -+ } -+ else { /* invalid state */ -+ printk(KERN_CRIT "mini_fo: rename_reg_file: ERROR: invalid state detected [2].\n"); -+ return -1; -+ } -+} -+ -+ -+STATIC int -+mini_fo_readlink(dentry_t *dentry, char *buf, int bufsiz) -+{ -+ int err=0; -+ dentry_t *hidden_dentry = NULL; -+ -+ if(dtohd2(dentry) && dtohd2(dentry)->d_inode) { -+ hidden_dentry = dtohd2(dentry); -+ } else if(dtohd(dentry) && dtohd(dentry)->d_inode) { -+ hidden_dentry = dtohd(dentry); -+ } else { -+ goto out; -+ } -+ -+ if (!hidden_dentry->d_inode->i_op || -+ !hidden_dentry->d_inode->i_op->readlink) { -+ err = -EINVAL; goto out; -+ } -+ -+ err = hidden_dentry->d_inode->i_op->readlink(hidden_dentry, -+ buf, -+ bufsiz); -+ if (err > 0) -+ fist_copy_attr_atime(dentry->d_inode, hidden_dentry->d_inode); -+ -+ out: -+ return err; -+} -+ -+ -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13) -+static int mini_fo_follow_link(dentry_t *dentry, struct nameidata *nd) -+#else -+static void* mini_fo_follow_link(dentry_t *dentry, struct nameidata *nd) -+#endif -+{ -+ char *buf; -+ int len = PAGE_SIZE, err; -+ mm_segment_t old_fs; -+ -+ /* in 2.6 this is freed by mini_fo_put_link called by __do_follow_link */ -+ buf = kmalloc(len, GFP_KERNEL); -+ if (!buf) { -+ err = -ENOMEM; -+ goto out; -+ } -+ -+ /* read the symlink, and then we will follow it */ -+ old_fs = get_fs(); -+ set_fs(KERNEL_DS); -+ err = dentry->d_inode->i_op->readlink(dentry, buf, len); -+ set_fs(old_fs); -+ if (err < 0) { -+ kfree(buf); -+ buf = NULL; -+ goto out; -+ } -+ buf[err] = 0; -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+ nd_set_link(nd, buf); -+ err = 0; -+#else -+ err = vfs_follow_link(nd, buf); -+#endif -+ -+ out: -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) -+ kfree(buf); -+#endif -+ -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13) -+ return err; -+#else -+ return ERR_PTR(err); -+#endif -+} -+ -+STATIC -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13) -+void mini_fo_put_link(struct dentry *dentry, struct nameidata *nd) -+#else -+void mini_fo_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie) -+#endif -+{ -+ char *link; -+ link = nd_get_link(nd); -+ kfree(link); -+} -+#endif -+ -+STATIC int -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+mini_fo_permission(inode_t *inode, int mask, struct nameidata *nd) -+#else -+mini_fo_permission(inode_t *inode, int mask) -+#endif -+{ -+ inode_t *hidden_inode; -+ int mode; -+ int err; -+ -+ if(itohi2(inode)) { -+ hidden_inode = itohi2(inode); -+ } else { -+ hidden_inode = itohi(inode); -+ } -+ mode = inode->i_mode; -+ -+ /* not really needed, as permission handles everything: -+ * err = vfs_permission(inode, mask); -+ * if (err) -+ * goto out; -+ */ -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+ err = permission(hidden_inode, mask, nd); -+#else -+ err = permission(hidden_inode, mask); -+#endif -+ -+ /* out: */ -+ return err; -+} -+ -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) -+STATIC int -+mini_fo_inode_revalidate(dentry_t *dentry) -+{ -+ int err = 0; -+ dentry_t *hidden_dentry; -+ inode_t *hidden_inode; -+ -+ ASSERT(dentry->d_inode); -+ ASSERT(itopd(dentry->d_inode)); -+ -+ if(itohi2(dentry->d_inode)) { -+ hidden_dentry = dtohd2(dentry); -+ hidden_inode = hidden_dentry->d_inode; -+ } else if(itohi(dentry->d_inode)) { -+ hidden_dentry = dtohd(dentry); -+ hidden_inode = hidden_dentry->d_inode; -+ } else { -+ printk(KERN_CRIT "mini_fo_inode_revalidate: ERROR, invalid state detected.\n"); -+ err = -ENOENT; -+ goto out; -+ } -+ if (hidden_inode && hidden_inode->i_op && hidden_inode->i_op->revalidate){ -+ err = hidden_inode->i_op->revalidate(hidden_dentry); -+ if (err) -+ goto out; -+ } -+ fist_copy_attr_all(dentry->d_inode, hidden_inode); -+ out: -+ return err; -+} -+#endif -+ -+STATIC int -+mini_fo_setattr(dentry_t *dentry, struct iattr *ia) -+{ -+ int err = 0; -+ -+ check_mini_fo_dentry(dentry); -+ -+ if(!is_mini_fo_existant(dentry)) { -+ printk(KERN_CRIT "mini_fo_setattr: ERROR, invalid state detected [1].\n"); -+ goto out; -+ } -+ -+ if(dtost(dentry) == UNMODIFIED) { -+ if(!IS_COPY_FLAG(ia->ia_valid)) -+ goto out; /* we ignore these changes to base */ -+ -+ if(S_ISDIR(dentry->d_inode->i_mode)) { -+ err = dir_unmod_to_mod(dentry); -+ } else { -+ /* we copy contents if file is not beeing truncated */ -+ if(S_ISREG(dentry->d_inode->i_mode) && -+ !(ia->ia_size == 0 && (ia->ia_valid & ATTR_SIZE))) { -+ err = nondir_unmod_to_mod(dentry, 1); -+ } else -+ err = nondir_unmod_to_mod(dentry, 0); -+ } -+ if(err) { -+ err = -EINVAL; -+ printk(KERN_CRIT "mini_fo_setattr: ERROR changing states.\n"); -+ goto out; -+ } -+ } -+ if(!exists_in_storage(dentry)) { -+ printk(KERN_CRIT "mini_fo_setattr: ERROR, invalid state detected [2].\n"); -+ err = -EINVAL; -+ goto out; -+ } -+ ASSERT(dentry->d_inode); -+ ASSERT(dtohd2(dentry)); -+ ASSERT(itopd(dentry->d_inode)); -+ ASSERT(itohi2(dentry->d_inode)); -+ -+ err = notify_change(dtohd2(dentry), ia); -+ fist_copy_attr_all(dentry->d_inode, itohi2(dentry->d_inode)); -+ out: -+ return err; -+} -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+STATIC int -+mini_fo_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) -+{ -+ int err = 0; -+ dentry_t *hidden_dentry; -+ -+ ASSERT(dentry->d_inode); -+ ASSERT(itopd(dentry->d_inode)); -+ -+ if(itohi2(dentry->d_inode)) { -+ hidden_dentry = dtohd2(dentry); -+ } else if(itohi(dentry->d_inode)) { -+ hidden_dentry = dtohd(dentry); -+ } else { -+ printk(KERN_CRIT "mini_fo_getattr: ERROR, invalid state detected.\n"); -+ err = -ENOENT; -+ goto out; -+ } -+ fist_copy_attr_all(dentry->d_inode, hidden_dentry->d_inode); -+ -+ ASSERT(hidden_dentry); -+ ASSERT(hidden_dentry->d_inode); -+ ASSERT(hidden_dentry->d_inode->i_op); -+ -+ generic_fillattr(dentry->d_inode, stat); -+ if (!stat->blksize) { -+ struct super_block *s = hidden_dentry->d_inode->i_sb; -+ unsigned blocks; -+ blocks = (stat->size+s->s_blocksize-1) >> s->s_blocksize_bits; -+ stat->blocks = (s->s_blocksize / 512) * blocks; -+ stat->blksize = s->s_blocksize; -+ } -+ out: -+ return err; -+} -+#endif -+ -+#if defined(XATTR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20)) -+#if 0 /* no xattr_alloc() and xattr_free() */ -+/* This is lifted from fs/xattr.c */ -+static void * -+xattr_alloc(size_t size, size_t limit) -+{ -+ void *ptr; -+ -+ if (size > limit) -+ return ERR_PTR(-E2BIG); -+ -+ if (!size) /* size request, no buffer is needed */ -+ return NULL; -+ else if (size <= PAGE_SIZE) -+ ptr = kmalloc((unsigned long) size, GFP_KERNEL); -+ else -+ ptr = vmalloc((unsigned long) size); -+ if (!ptr) -+ return ERR_PTR(-ENOMEM); -+ return ptr; -+} -+ -+static void -+xattr_free(void *ptr, size_t size) -+{ -+ if (!size) /* size request, no buffer was needed */ -+ return; -+ else if (size <= PAGE_SIZE) -+ kfree(ptr); -+ else -+ vfree(ptr); -+} -+#endif /* no xattr_alloc() and xattr_free() */ -+ -+/* BKL held by caller. -+ * dentry->d_inode->i_sem down -+ */ -+STATIC int -+mini_fo_getxattr(struct dentry *dentry, const char *name, void *value, size_t size) { -+ struct dentry *hidden_dentry = NULL; -+ int err = -EOPNOTSUPP; -+ /* Define these anyway so we don't need as much ifdef'ed code. */ -+ char *encoded_name = NULL; -+ char *encoded_value = NULL; -+ -+ check_mini_fo_dentry(dentry); -+ -+ if(exists_in_storage(dentry)) -+ hidden_dentry = dtohd2(dentry); -+ else -+ hidden_dentry = dtohd(dentry); -+ -+ ASSERT(hidden_dentry); -+ ASSERT(hidden_dentry->d_inode); -+ ASSERT(hidden_dentry->d_inode->i_op); -+ -+ if (hidden_dentry->d_inode->i_op->getxattr) { -+ encoded_name = (char *)name; -+ encoded_value = (char *)value; -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_lock(&hidden_dentry->d_inode->i_mutex); -+#else -+ down(&hidden_dentry->d_inode->i_sem); -+#endif -+ /* lock_kernel() already done by caller. */ -+ err = hidden_dentry->d_inode->i_op->getxattr(hidden_dentry, encoded_name, encoded_value, size); -+ /* unlock_kernel() will be done by caller. */ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_lock(&hidden_dentry->d_inode->i_mutex); -+#else -+ up(&hidden_dentry->d_inode->i_sem); -+#endif -+ } -+ return err; -+} -+ -+/* BKL held by caller. -+ * dentry->d_inode->i_sem down -+ */ -+STATIC int -+#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,21) \ -+ && LINUX_VERSION_CODE <= KERNEL_VERSION(2,4,23)) \ -+ || LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) -+mini_fo_setxattr(struct dentry *dentry, const char *name, -+ const void *value, size_t size, int flags) -+#else -+mini_fo_setxattr(struct dentry *dentry, const char *name, -+ void *value, size_t size, int flags) -+#endif -+ -+{ -+ struct dentry *hidden_dentry = NULL; -+ int err = -EOPNOTSUPP; -+ -+ /* Define these anyway, so we don't have as much ifdef'ed code. */ -+ char *encoded_value = NULL; -+ char *encoded_name = NULL; -+ -+ check_mini_fo_dentry(dentry); -+ -+ if(exists_in_storage(dentry)) -+ hidden_dentry = dtohd2(dentry); -+ else -+ hidden_dentry = dtohd(dentry); -+ -+ ASSERT(hidden_dentry); -+ ASSERT(hidden_dentry->d_inode); -+ ASSERT(hidden_dentry->d_inode->i_op); -+ -+ if (hidden_dentry->d_inode->i_op->setxattr) { -+ encoded_name = (char *)name; -+ encoded_value = (char *)value; -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_lock(&hidden_dentry->d_inode->i_mutex); -+#else -+ down(&hidden_dentry->d_inode->i_sem); -+#endif -+ /* lock_kernel() already done by caller. */ -+ err = hidden_dentry->d_inode->i_op->setxattr(hidden_dentry, encoded_name, encoded_value, size, flags); -+ /* unlock_kernel() will be done by caller. */ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_unlock(&hidden_dentry->d_inode->i_mutex); -+#else -+ up(&hidden_dentry->d_inode->i_sem); -+#endif -+ } -+ return err; -+} -+ -+/* BKL held by caller. -+ * dentry->d_inode->i_sem down -+ */ -+STATIC int -+mini_fo_removexattr(struct dentry *dentry, const char *name) { -+ struct dentry *hidden_dentry = NULL; -+ int err = -EOPNOTSUPP; -+ char *encoded_name; -+ -+ check_mini_fo_dentry(dentry); -+ -+ if(exists_in_storage(dentry)) -+ hidden_dentry = dtohd2(dentry); -+ else -+ hidden_dentry = dtohd(dentry); -+ -+ ASSERT(hidden_dentry); -+ ASSERT(hidden_dentry->d_inode); -+ ASSERT(hidden_dentry->d_inode->i_op); -+ -+ if (hidden_dentry->d_inode->i_op->removexattr) { -+ encoded_name = (char *)name; -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_lock(&hidden_dentry->d_inode->i_mutex); -+#else -+ down(&hidden_dentry->d_inode->i_sem); -+#endif -+ /* lock_kernel() already done by caller. */ -+ err = hidden_dentry->d_inode->i_op->removexattr(hidden_dentry, encoded_name); -+ /* unlock_kernel() will be done by caller. */ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_unlock(&hidden_dentry->d_inode->i_mutex); -+#else -+ up(&hidden_dentry->d_inode->i_sem); -+#endif -+ } -+ return err; -+} -+ -+/* BKL held by caller. -+ * dentry->d_inode->i_sem down -+ */ -+STATIC int -+mini_fo_listxattr(struct dentry *dentry, char *list, size_t size) { -+ struct dentry *hidden_dentry = NULL; -+ int err = -EOPNOTSUPP; -+ char *encoded_list = NULL; -+ -+ check_mini_fo_dentry(dentry); -+ -+ if(exists_in_storage(dentry)) -+ hidden_dentry = dtohd2(dentry); -+ else -+ hidden_dentry = dtohd(dentry); -+ -+ ASSERT(hidden_dentry); -+ ASSERT(hidden_dentry->d_inode); -+ ASSERT(hidden_dentry->d_inode->i_op); -+ -+ if (hidden_dentry->d_inode->i_op->listxattr) { -+ encoded_list = list; -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_lock(&hidden_dentry->d_inode->i_mutex); -+#else -+ down(&hidden_dentry->d_inode->i_sem); -+#endif -+ /* lock_kernel() already done by caller. */ -+ err = hidden_dentry->d_inode->i_op->listxattr(hidden_dentry, encoded_list, size); -+ /* unlock_kernel() will be done by caller. */ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_unlock(&hidden_dentry->d_inode->i_mutex); -+#else -+ up(&hidden_dentry->d_inode->i_sem); -+#endif -+ } -+ return err; -+} -+# endif /* defined(XATTR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20)) */ -+ -+struct inode_operations mini_fo_symlink_iops = -+ { -+ readlink: mini_fo_readlink, -+ follow_link: mini_fo_follow_link, -+ /* mk: permission: mini_fo_permission, */ -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) -+ revalidate: mini_fo_inode_revalidate, -+#endif -+ setattr: mini_fo_setattr, -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+ getattr: mini_fo_getattr, -+ put_link: mini_fo_put_link, -+#endif -+ -+#if defined(XATTR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20)) -+ setxattr: mini_fo_setxattr, -+ getxattr: mini_fo_getxattr, -+ listxattr: mini_fo_listxattr, -+ removexattr: mini_fo_removexattr -+# endif /* defined(XATTR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20)) */ -+ }; -+ -+struct inode_operations mini_fo_dir_iops = -+ { -+ create: mini_fo_create, -+ lookup: mini_fo_lookup, -+ link: mini_fo_link, -+ unlink: mini_fo_unlink, -+ symlink: mini_fo_symlink, -+ mkdir: mini_fo_mkdir, -+ rmdir: mini_fo_rmdir, -+ mknod: mini_fo_mknod, -+ rename: mini_fo_rename, -+ /* no readlink/follow_link for non-symlinks */ -+ // off because we have setattr -+ // truncate: mini_fo_truncate, -+ /* mk:permission: mini_fo_permission, */ -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) -+ revalidate: mini_fo_inode_revalidate, -+#endif -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+ getattr: mini_fo_getattr, -+#endif -+ setattr: mini_fo_setattr, -+#if defined(XATTR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20)) -+ setxattr: mini_fo_setxattr, -+ getxattr: mini_fo_getxattr, -+ listxattr: mini_fo_listxattr, -+ removexattr: mini_fo_removexattr -+# endif /* XATTR && LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20) */ -+ }; -+ -+struct inode_operations mini_fo_main_iops = -+ { -+ /* permission: mini_fo_permission, */ -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) -+ revalidate: mini_fo_inode_revalidate, -+#endif -+ setattr: mini_fo_setattr, -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+ getattr: mini_fo_getattr, -+#endif -+#if defined(XATTR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20)) -+ setxattr: mini_fo_setxattr, -+ getxattr: mini_fo_getxattr, -+ listxattr: mini_fo_listxattr, -+ removexattr: mini_fo_removexattr -+# endif /* XATTR && LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20) */ -+ }; ---- /dev/null -+++ b/fs/mini_fo/main.c -@@ -0,0 +1,414 @@ -+/* -+ * Copyright (c) 1997-2003 Erez Zadok -+ * Copyright (c) 2001-2003 Stony Brook University -+ * -+ * For specific licensing information, see the COPYING file distributed with -+ * this package, or get one from ftp://ftp.filesystems.org/pub/fist/COPYING. -+ * -+ * This Copyright notice must be kept intact and distributed with all -+ * fistgen sources INCLUDING sources generated by fistgen. -+ */ -+/* -+ * Copyright (C) 2004, 2005 Markus Klotzbuecher <mk@creamnet.de> -+ * -+ * 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. -+ */ -+ -+/* -+ * $Id$ -+ */ -+ -+#ifdef HAVE_CONFIG_H -+# include <config.h> -+#endif -+ -+#include "fist.h" -+#include "mini_fo.h" -+#include <linux/module.h> -+ -+/* This definition must only appear after we include <linux/module.h> */ -+#ifndef MODULE_LICENSE -+# define MODULE_LICENSE(bison) -+#endif /* not MODULE_LICENSE */ -+ -+/* -+ * This is the mini_fo tri interpose function, which extends the -+ * functionality of the regular interpose by interposing a higher -+ * level inode on top of two lower level ones: the base filesystem -+ * inode and the storage filesystem inode. -+ * -+ * sb we pass is mini_fo's super_block -+ */ -+int -+mini_fo_tri_interpose(dentry_t *hidden_dentry, -+ dentry_t *hidden_sto_dentry, -+ dentry_t *dentry, super_block_t *sb, int flag) -+{ -+ inode_t *hidden_inode = NULL; -+ inode_t *hidden_sto_inode = NULL; /* store corresponding storage inode */ -+ int err = 0; -+ inode_t *inode; -+ -+ /* Pointer to hidden_sto_inode if exists, else to hidden_inode. -+ * This is used to copy the attributes of the correct inode. */ -+ inode_t *master_inode; -+ -+ if(hidden_dentry) -+ hidden_inode = hidden_dentry->d_inode; -+ if(hidden_sto_dentry) -+ hidden_sto_inode = hidden_sto_dentry->d_inode; -+ -+ ASSERT(dentry->d_inode == NULL); -+ -+ /* mk: One of the inodes associated with the dentrys is likely to -+ * be NULL, so carefull: -+ */ -+ ASSERT((hidden_inode != NULL) || (hidden_sto_inode != NULL)); -+ -+ if(hidden_sto_inode) -+ master_inode = hidden_sto_inode; -+ else -+ master_inode = hidden_inode; -+ -+ /* -+ * We allocate our new inode below, by calling iget. -+ * iget will call our read_inode which will initialize some -+ * of the new inode's fields -+ */ -+ -+ /* -+ * original: inode = iget(sb, hidden_inode->i_ino); -+ */ -+ inode = iget(sb, iunique(sb, 25)); -+ if (!inode) { -+ err = -EACCES; /* should be impossible??? */ -+ goto out; -+ } -+ -+ /* -+ * interpose the inode if not already interposed -+ * this is possible if the inode is being reused -+ * XXX: what happens if we get_empty_inode() but there's another already? -+ * for now, ASSERT() that this can't happen; fix later. -+ */ -+ if (itohi(inode) != NULL) { -+ printk(KERN_CRIT "mini_fo_tri_interpose: itohi(inode) != NULL.\n"); -+ } -+ if (itohi2(inode) != NULL) { -+ printk(KERN_CRIT "mini_fo_tri_interpose: itohi2(inode) != NULL.\n"); -+ } -+ -+ /* mk: Carefull, igrab can't handle NULL inodes (ok, why should it?), so -+ * we need to check here: -+ */ -+ if(hidden_inode) -+ itohi(inode) = igrab(hidden_inode); -+ else -+ itohi(inode) = NULL; -+ -+ if(hidden_sto_inode) -+ itohi2(inode) = igrab(hidden_sto_inode); -+ else -+ itohi2(inode) = NULL; -+ -+ -+ /* Use different set of inode ops for symlinks & directories*/ -+ if (S_ISLNK(master_inode->i_mode)) -+ inode->i_op = &mini_fo_symlink_iops; -+ else if (S_ISDIR(master_inode->i_mode)) -+ inode->i_op = &mini_fo_dir_iops; -+ -+ /* Use different set of file ops for directories */ -+ if (S_ISDIR(master_inode->i_mode)) -+ inode->i_fop = &mini_fo_dir_fops; -+ -+ /* properly initialize special inodes */ -+ if (S_ISBLK(master_inode->i_mode) || S_ISCHR(master_inode->i_mode) || -+ S_ISFIFO(master_inode->i_mode) || S_ISSOCK(master_inode->i_mode)) { -+ init_special_inode(inode, master_inode->i_mode, master_inode->i_rdev); -+ } -+ -+ /* Fix our inode's address operations to that of the lower inode */ -+ if (inode->i_mapping->a_ops != master_inode->i_mapping->a_ops) { -+ inode->i_mapping->a_ops = master_inode->i_mapping->a_ops; -+ } -+ -+ /* only (our) lookup wants to do a d_add */ -+ if (flag) -+ d_add(dentry, inode); -+ else -+ d_instantiate(dentry, inode); -+ -+ ASSERT(dtopd(dentry) != NULL); -+ -+ /* all well, copy inode attributes */ -+ fist_copy_attr_all(inode, master_inode); -+ -+ out: -+ return err; -+} -+ -+/* parse mount options "base=" and "sto=" */ -+dentry_t * -+mini_fo_parse_options(super_block_t *sb, char *options) -+{ -+ dentry_t *hidden_root = ERR_PTR(-EINVAL); -+ dentry_t *hidden_root2 = ERR_PTR(-EINVAL); -+ struct nameidata nd, nd2; -+ char *name, *tmp, *end; -+ int err = 0; -+ -+ /* We don't want to go off the end of our arguments later on. */ -+ for (end = options; *end; end++); -+ -+ while (options < end) { -+ tmp = options; -+ while (*tmp && *tmp != ',') -+ tmp++; -+ *tmp = '\0'; -+ if (!strncmp("base=", options, 5)) { -+ name = options + 5; -+ printk(KERN_INFO "mini_fo: using base directory: %s\n", name); -+ -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) -+ if (path_init(name, LOOKUP_FOLLOW, &nd)) -+ err = path_walk(name, &nd); -+#else -+ err = path_lookup(name, LOOKUP_FOLLOW, &nd); -+#endif -+ if (err) { -+ printk(KERN_CRIT "mini_fo: error accessing hidden directory '%s'\n", name); -+ hidden_root = ERR_PTR(err); -+ goto out; -+ } -+ hidden_root = nd.dentry; -+ stopd(sb)->base_dir_dentry = nd.dentry; -+ stopd(sb)->hidden_mnt = nd.mnt; -+ -+ } else if(!strncmp("sto=", options, 4)) { -+ /* parse the storage dir */ -+ name = options + 4; -+ printk(KERN_INFO "mini_fo: using storage directory: %s\n", name); -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) -+ if(path_init(name, LOOKUP_FOLLOW, &nd2)) -+ err = path_walk(name, &nd2); -+#else -+ err = path_lookup(name, LOOKUP_FOLLOW, &nd2); -+#endif -+ if(err) { -+ printk(KERN_CRIT "mini_fo: error accessing hidden storage directory '%s'\n", name); -+ -+ hidden_root2 = ERR_PTR(err); -+ goto out; -+ } -+ hidden_root2 = nd2.dentry; -+ stopd(sb)->storage_dir_dentry = nd2.dentry; -+ stopd(sb)->hidden_mnt2 = nd2.mnt; -+ stohs2(sb) = hidden_root2->d_sb; -+ -+ /* validate storage dir, this is done in -+ * mini_fo_read_super for the base directory. -+ */ -+ if (IS_ERR(hidden_root2)) { -+ printk(KERN_WARNING "mini_fo_parse_options: storage dentry lookup failed (err = %ld)\n", PTR_ERR(hidden_root2)); -+ goto out; -+ } -+ if (!hidden_root2->d_inode) { -+ printk(KERN_WARNING "mini_fo_parse_options: no storage dir to interpose on.\n"); -+ goto out; -+ } -+ stohs2(sb) = hidden_root2->d_sb; -+ } else { -+ printk(KERN_WARNING "mini_fo: unrecognized option '%s'\n", options); -+ hidden_root = ERR_PTR(-EINVAL); -+ goto out; -+ } -+ options = tmp + 1; -+ } -+ -+ out: -+ if(IS_ERR(hidden_root2)) -+ return hidden_root2; -+ return hidden_root; -+} -+ -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+static int -+#else -+super_block_t * -+#endif -+mini_fo_read_super(super_block_t *sb, void *raw_data, int silent) -+{ -+ dentry_t *hidden_root; -+ int err = 0; -+ -+ if (!raw_data) { -+ printk(KERN_WARNING "mini_fo_read_super: missing argument\n"); -+ err = -EINVAL; -+ goto out; -+ } -+ /* -+ * Allocate superblock private data -+ */ -+ __stopd(sb) = kmalloc(sizeof(struct mini_fo_sb_info), GFP_KERNEL); -+ if (!stopd(sb)) { -+ printk(KERN_WARNING "%s: out of memory\n", __FUNCTION__); -+ err = -ENOMEM; -+ goto out; -+ } -+ stohs(sb) = NULL; -+ -+ hidden_root = mini_fo_parse_options(sb, raw_data); -+ if (IS_ERR(hidden_root)) { -+ printk(KERN_WARNING "mini_fo_read_super: lookup_dentry failed (err = %ld)\n", PTR_ERR(hidden_root)); -+ err = PTR_ERR(hidden_root); -+ goto out_free; -+ } -+ if (!hidden_root->d_inode) { -+ printk(KERN_WARNING "mini_fo_read_super: no directory to interpose on\n"); -+ goto out_free; -+ } -+ stohs(sb) = hidden_root->d_sb; -+ -+ /* -+ * Linux 2.4.2-ac3 and beyond has code in -+ * mm/filemap.c:generic_file_write() that requires sb->s_maxbytes -+ * to be populated. If not set, all write()s under that sb will -+ * return 0. -+ * -+ * Linux 2.4.4+ automatically sets s_maxbytes to MAX_NON_LFS; -+ * the filesystem should override it only if it supports LFS. -+ */ -+ /* non-SCA code is good to go with LFS */ -+ sb->s_maxbytes = hidden_root->d_sb->s_maxbytes; -+ -+ sb->s_op = &mini_fo_sops; -+ /* -+ * we can't use d_alloc_root if we want to use -+ * our own interpose function unchanged, -+ * so we simply replicate *most* of the code in d_alloc_root here -+ */ -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) -+ sb->s_root = d_alloc(NULL, &(const struct qstr) { "/", 1, 0 }); -+#else -+ sb->s_root = d_alloc(NULL, &(const struct qstr){hash: 0, name: "/", len : 1}); -+#endif -+ if (IS_ERR(sb->s_root)) { -+ printk(KERN_WARNING "mini_fo_read_super: d_alloc failed\n"); -+ err = -ENOMEM; -+ goto out_dput; -+ } -+ -+ sb->s_root->d_op = &mini_fo_dops; -+ sb->s_root->d_sb = sb; -+ sb->s_root->d_parent = sb->s_root; -+ -+ /* link the upper and lower dentries */ -+ __dtopd(sb->s_root) = (struct mini_fo_dentry_info *) -+ kmalloc(sizeof(struct mini_fo_dentry_info), GFP_KERNEL); -+ if (!dtopd(sb->s_root)) { -+ err = -ENOMEM; -+ goto out_dput2; -+ } -+ dtopd(sb->s_root)->state = MODIFIED; -+ dtohd(sb->s_root) = hidden_root; -+ -+ /* fanout relevant, interpose on storage root dentry too */ -+ dtohd2(sb->s_root) = stopd(sb)->storage_dir_dentry; -+ -+ /* ...and call tri-interpose to interpose root dir inodes -+ * if (mini_fo_interpose(hidden_root, sb->s_root, sb, 0)) -+ */ -+ if(mini_fo_tri_interpose(hidden_root, dtohd2(sb->s_root), sb->s_root, sb, 0)) -+ goto out_dput2; -+ -+ /* initalize the wol list */ -+ itopd(sb->s_root->d_inode)->deleted_list_size = -1; -+ itopd(sb->s_root->d_inode)->renamed_list_size = -1; -+ meta_build_lists(sb->s_root); -+ -+ goto out; -+ -+ out_dput2: -+ dput(sb->s_root); -+ out_dput: -+ dput(hidden_root); -+ dput(dtohd2(sb->s_root)); /* release the hidden_sto_dentry too */ -+ out_free: -+ kfree(stopd(sb)); -+ __stopd(sb) = NULL; -+ out: -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+ return err; -+#else -+ if (err) { -+ return ERR_PTR(err); -+ } else { -+ return sb; -+ } -+#endif -+} -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+static struct super_block *mini_fo_get_sb(struct file_system_type *fs_type, -+ int flags, const char *dev_name, -+ void *raw_data) -+{ -+ return get_sb_nodev(fs_type, flags, raw_data, mini_fo_read_super); -+} -+ -+void mini_fo_kill_block_super(struct super_block *sb) -+{ -+ generic_shutdown_super(sb); -+ /* -+ * XXX: BUG: Halcrow: Things get unstable sometime after this point: -+ * lib/rwsem-spinlock.c:127: spin_is_locked on uninitialized -+ * fs/fs-writeback.c:402: spin_lock(fs/super.c:a0381828) already -+ * locked by fs/fs-writeback.c/402 -+ * -+ * Apparently, someone's not releasing a lock on sb_lock... -+ */ -+} -+ -+static struct file_system_type mini_fo_fs_type = { -+ .owner = THIS_MODULE, -+ .name = "mini_fo", -+ .get_sb = mini_fo_get_sb, -+ .kill_sb = mini_fo_kill_block_super, -+ .fs_flags = 0, -+}; -+ -+ -+#else -+static DECLARE_FSTYPE(mini_fo_fs_type, "mini_fo", mini_fo_read_super, 0); -+#endif -+ -+static int __init init_mini_fo_fs(void) -+{ -+ printk("Registering mini_fo version $Id$\n"); -+ return register_filesystem(&mini_fo_fs_type); -+} -+static void __exit exit_mini_fo_fs(void) -+{ -+ printk("Unregistering mini_fo version $Id$\n"); -+ unregister_filesystem(&mini_fo_fs_type); -+} -+ -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) -+EXPORT_NO_SYMBOLS; -+#endif -+ -+MODULE_AUTHOR("Erez Zadok <ezk@cs.sunysb.edu>"); -+MODULE_DESCRIPTION("FiST-generated mini_fo filesystem"); -+MODULE_LICENSE("GPL"); -+ -+/* MODULE_PARM(fist_debug_var, "i"); */ -+/* MODULE_PARM_DESC(fist_debug_var, "Debug level"); */ -+ -+module_init(init_mini_fo_fs) -+module_exit(exit_mini_fo_fs) ---- /dev/null -+++ b/fs/mini_fo/Makefile -@@ -0,0 +1,22 @@ -+# -+# Makefile for mini_fo 2.4 and 2.6 Linux kernels -+# -+# Copyright (C) 2004, 2005 Markus Klotzbuecher <mk@creamnet.de> -+# -+# 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. -+# -+ -+obj-$(CONFIG_MINI_FO) := mini_fo.o -+mini_fo-objs := meta.o dentry.o file.o inode.o main.o super.o state.o aux.o -+ -+O_TARGET := $(obj-$(CONFIG_MINI_FO)) -+obj-y := $(mini_fo-objs) -+ -+-include $(TOPDIR)/Rules.make -+ -+# dependencies -+${mini_fo-objs}: mini_fo.h fist.h -+ ---- /dev/null -+++ b/fs/mini_fo/meta.c -@@ -0,0 +1,1000 @@ -+/* -+ * Copyright (C) 2004, 2005 Markus Klotzbuecher <mk@creamnet.de> -+ * -+ * 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. -+ */ -+ -+#ifdef HAVE_CONFIG_H -+# include <config.h> -+#endif /* HAVE_CONFIG_H */ -+#include "fist.h" -+#include "mini_fo.h" -+ -+int meta_build_lists(dentry_t *dentry) -+{ -+ struct mini_fo_inode_info *inode_info; -+ -+ dentry_t *meta_dentry = 0; -+ file_t *meta_file = 0; -+ mm_segment_t old_fs; -+ void *buf; -+ -+ int bytes, len; -+ struct vfsmount *meta_mnt; -+ char *entry; -+ -+ inode_info = itopd(dentry->d_inode); -+ if(!(inode_info->deleted_list_size == -1 && -+ inode_info->renamed_list_size == -1)) { -+ printk(KERN_CRIT "mini_fo: meta_build_lists: \ -+ Error, list(s) not virgin.\n"); -+ return -1; -+ } -+ -+ /* init our meta lists */ -+ INIT_LIST_HEAD(&inode_info->deleted_list); -+ inode_info->deleted_list_size = 0; -+ -+ INIT_LIST_HEAD(&inode_info->renamed_list); -+ inode_info->renamed_list_size = 0; -+ -+ /* might there be a META-file? */ -+ if(dtohd2(dentry) && dtohd2(dentry)->d_inode) { -+ meta_dentry = lookup_one_len(META_FILENAME, -+ dtohd2(dentry), -+ strlen(META_FILENAME)); -+ if(!meta_dentry->d_inode) { -+ dput(meta_dentry); -+ goto out_ok; -+ } -+ /* $%& err, is this correct? */ -+ meta_mnt = stopd(dentry->d_inode->i_sb)->hidden_mnt2; -+ mntget(meta_mnt); -+ -+ -+ /* open META-file for reading */ -+ meta_file = dentry_open(meta_dentry, meta_mnt, 0x0); -+ if(!meta_file || IS_ERR(meta_file)) { -+ printk(KERN_CRIT "mini_fo: meta_build_lists: \ -+ ERROR opening META file.\n"); -+ goto out_err; -+ } -+ -+ /* check if fs supports reading */ -+ if(!meta_file->f_op->read) { -+ printk(KERN_CRIT "mini_fo: meta_build_lists: \ -+ ERROR, fs does not support reading.\n"); -+ goto out_err_close; -+ } -+ -+ /* allocate a page for transfering the data */ -+ buf = (void *) __get_free_page(GFP_KERNEL); -+ if(!buf) { -+ printk(KERN_CRIT "mini_fo: meta_build_lists: \ -+ ERROR, out of mem.\n"); -+ goto out_err_close; -+ } -+ meta_file->f_pos = 0; -+ old_fs = get_fs(); -+ set_fs(KERNEL_DS); -+ do { -+ char *c; -+ bytes = meta_file->f_op->read(meta_file, buf, PAGE_SIZE, &meta_file->f_pos); -+ if(bytes == PAGE_SIZE) { -+ /* trim a cut off filename and adjust f_pos to get it next time */ -+ for(c = (char*) buf+PAGE_SIZE; -+ *c != '\n'; -+ c--, bytes--, meta_file->f_pos--); -+ } -+ entry = (char *) buf; -+ while(entry < (char *) buf+bytes) { -+ -+ char *old_path; -+ char *dir_name; -+ int old_len, new_len; -+ -+ /* len without '\n'*/ -+ len = (int) (strchr(entry, '\n') - entry); -+ switch (*entry) { -+ case 'D': -+ /* format: "D filename" */ -+ meta_list_add_d_entry(dentry, -+ entry+2, -+ len-2); -+ break; -+ case 'R': -+ /* format: "R path/xy/dir newDir" */ -+ old_path = entry+2; -+ dir_name = strchr(old_path, ' ') + 1; -+ old_len = dir_name - old_path - 1; -+ new_len = ((int) entry) + len - ((int ) dir_name); -+ meta_list_add_r_entry(dentry, -+ old_path, -+ old_len, -+ dir_name, -+ new_len); -+ break; -+ default: -+ /* unknown entry type detected */ -+ break; -+ } -+ entry += len+1; -+ } -+ -+ } while(meta_file->f_pos < meta_dentry->d_inode->i_size); -+ -+ free_page((unsigned long) buf); -+ set_fs(old_fs); -+ fput(meta_file); -+ } -+ goto out_ok; -+ -+ out_err_close: -+ fput(meta_file); -+ out_err: -+ mntput(meta_mnt); -+ dput(meta_dentry); -+ return -1; -+ out_ok: -+ return 1; /* check this!!! inode_info->wol_size; */ -+} -+ -+/* cleanups up all lists and free's the mem by dentry */ -+int meta_put_lists(dentry_t *dentry) -+{ -+ if(!dentry || !dentry->d_inode) { -+ printk("mini_fo: meta_put_lists: invalid dentry passed.\n"); -+ return -1; -+ } -+ return __meta_put_lists(dentry->d_inode); -+} -+ -+/* cleanups up all lists and free's the mem by inode */ -+int __meta_put_lists(inode_t *inode) -+{ -+ int err = 0; -+ if(!inode || !itopd(inode)) { -+ printk("mini_fo: __meta_put_lists: invalid inode passed.\n"); -+ return -1; -+ } -+ err = __meta_put_d_list(inode); -+ err |= __meta_put_r_list(inode); -+ return err; -+} -+ -+int meta_sync_lists(dentry_t *dentry) -+{ -+ int err = 0; -+ if(!dentry || !dentry->d_inode) { -+ printk("mini_fo: meta_sync_lists: \ -+ invalid dentry passed.\n"); -+ return -1; -+ } -+ err = meta_sync_d_list(dentry, 0); -+ err |= meta_sync_r_list(dentry, 1); -+ return err; -+} -+ -+ -+/* remove all D entries from the renamed list and free the mem */ -+int __meta_put_d_list(inode_t *inode) -+{ -+ struct list_head *tmp; -+ struct deleted_entry *del_entry; -+ struct mini_fo_inode_info *inode_info; -+ -+ if(!inode || !itopd(inode)) { -+ printk(KERN_CRIT "mini_fo: __meta_put_d_list: \ -+ invalid inode passed.\n"); -+ return -1; -+ } -+ inode_info = itopd(inode); -+ -+ /* nuke the DELETED-list */ -+ if(inode_info->deleted_list_size <= 0) -+ return 0; -+ -+ while(!list_empty(&inode_info->deleted_list)) { -+ tmp = inode_info->deleted_list.next; -+ list_del(tmp); -+ del_entry = list_entry(tmp, struct deleted_entry, list); -+ kfree(del_entry->name); -+ kfree(del_entry); -+ } -+ inode_info->deleted_list_size = 0; -+ -+ return 0; -+} -+ -+/* remove all R entries from the renamed list and free the mem */ -+int __meta_put_r_list(inode_t *inode) -+{ -+ struct list_head *tmp; -+ struct renamed_entry *ren_entry; -+ struct mini_fo_inode_info *inode_info; -+ -+ if(!inode || !itopd(inode)) { -+ printk(KERN_CRIT "mini_fo: meta_put_r_list: invalid inode.\n"); -+ return -1; -+ } -+ inode_info = itopd(inode); -+ -+ /* nuke the RENAMED-list */ -+ if(inode_info->renamed_list_size <= 0) -+ return 0; -+ -+ while(!list_empty(&inode_info->renamed_list)) { -+ tmp = inode_info->renamed_list.next; -+ list_del(tmp); -+ ren_entry = list_entry(tmp, struct renamed_entry, list); -+ kfree(ren_entry->new_name); -+ kfree(ren_entry->old_name); -+ kfree(ren_entry); -+ } -+ inode_info->renamed_list_size = 0; -+ -+ return 0; -+} -+ -+int meta_add_d_entry(dentry_t *dentry, const char *name, int len) -+{ -+ int err = 0; -+ err = meta_list_add_d_entry(dentry, name, len); -+ err |= meta_write_d_entry(dentry,name,len); -+ return err; -+} -+ -+/* add a D entry to the deleted list */ -+int meta_list_add_d_entry(dentry_t *dentry, const char *name, int len) -+{ -+ struct deleted_entry *del_entry; -+ struct mini_fo_inode_info *inode_info; -+ -+ if(!dentry || !dentry->d_inode) { -+ printk(KERN_CRIT "mini_fo: meta_list_add_d_entry: \ -+ invalid dentry passed.\n"); -+ return -1; -+ } -+ inode_info = itopd(dentry->d_inode); -+ -+ if(inode_info->deleted_list_size < 0) -+ return -1; -+ -+ del_entry = (struct deleted_entry *) -+ kmalloc(sizeof(struct deleted_entry), GFP_KERNEL); -+ del_entry->name = (char*) kmalloc(len, GFP_KERNEL); -+ if(!del_entry || !del_entry->name) { -+ printk(KERN_CRIT "mini_fo: meta_list_add_d_entry: \ -+ out of mem.\n"); -+ kfree(del_entry->name); -+ kfree(del_entry); -+ return -ENOMEM; -+ } -+ -+ strncpy(del_entry->name, name, len); -+ del_entry->len = len; -+ -+ list_add(&del_entry->list, &inode_info->deleted_list); -+ inode_info->deleted_list_size++; -+ return 0; -+} -+ -+int meta_add_r_entry(dentry_t *dentry, -+ const char *old_name, int old_len, -+ const char *new_name, int new_len) -+{ -+ int err = 0; -+ err = meta_list_add_r_entry(dentry, -+ old_name, old_len, -+ new_name, new_len); -+ err |= meta_write_r_entry(dentry, -+ old_name, old_len, -+ new_name, new_len); -+ return err; -+} -+ -+/* add a R entry to the renamed list */ -+int meta_list_add_r_entry(dentry_t *dentry, -+ const char *old_name, int old_len, -+ const char *new_name, int new_len) -+{ -+ struct renamed_entry *ren_entry; -+ struct mini_fo_inode_info *inode_info; -+ -+ if(!dentry || !dentry->d_inode) { -+ printk(KERN_CRIT "mini_fo: meta_list_add_r_entry: \ -+ invalid dentry passed.\n"); -+ return -1; -+ } -+ inode_info = itopd(dentry->d_inode); -+ -+ if(inode_info->renamed_list_size < 0) -+ return -1; -+ -+ ren_entry = (struct renamed_entry *) -+ kmalloc(sizeof(struct renamed_entry), GFP_KERNEL); -+ ren_entry->old_name = (char*) kmalloc(old_len, GFP_KERNEL); -+ ren_entry->new_name = (char*) kmalloc(new_len, GFP_KERNEL); -+ -+ if(!ren_entry || !ren_entry->old_name || !ren_entry->new_name) { -+ printk(KERN_CRIT "mini_fo: meta_list_add_r_entry: \ -+ out of mem.\n"); -+ kfree(ren_entry->new_name); -+ kfree(ren_entry->old_name); -+ kfree(ren_entry); -+ return -ENOMEM; -+ } -+ -+ strncpy(ren_entry->old_name, old_name, old_len); -+ ren_entry->old_len = old_len; -+ strncpy(ren_entry->new_name, new_name, new_len); -+ ren_entry->new_len = new_len; -+ -+ list_add(&ren_entry->list, &inode_info->renamed_list); -+ inode_info->renamed_list_size++; -+ return 0; -+} -+ -+ -+int meta_remove_r_entry(dentry_t *dentry, const char *name, int len) -+{ -+ int err = 0; -+ if(!dentry || !dentry->d_inode) { -+ printk(KERN_CRIT -+ "mini_fo: meta_remove_r_entry: \ -+ invalid dentry passed.\n"); -+ return -1; -+ } -+ -+ err = meta_list_remove_r_entry(dentry, name, len); -+ err |= meta_sync_lists(dentry); -+ return err; -+} -+ -+int meta_list_remove_r_entry(dentry_t *dentry, const char *name, int len) -+{ -+ if(!dentry || !dentry->d_inode) { -+ printk(KERN_CRIT -+ "mini_fo: meta_list_remove_r_entry: \ -+ invalid dentry passed.\n"); -+ return -1; -+ } -+ return __meta_list_remove_r_entry(dentry->d_inode, name, len); -+} -+ -+int __meta_list_remove_r_entry(inode_t *inode, const char *name, int len) -+{ -+ struct list_head *tmp; -+ struct renamed_entry *ren_entry; -+ struct mini_fo_inode_info *inode_info; -+ -+ if(!inode || !itopd(inode)) -+ printk(KERN_CRIT -+ "mini_fo: __meta_list_remove_r_entry: \ -+ invalid inode passed.\n"); -+ inode_info = itopd(inode); -+ -+ if(inode_info->renamed_list_size < 0) -+ return -1; -+ if(inode_info->renamed_list_size == 0) -+ return 1; -+ -+ list_for_each(tmp, &inode_info->renamed_list) { -+ ren_entry = list_entry(tmp, struct renamed_entry, list); -+ if(ren_entry->new_len != len) -+ continue; -+ -+ if(!strncmp(ren_entry->new_name, name, len)) { -+ list_del(tmp); -+ kfree(ren_entry->new_name); -+ kfree(ren_entry->old_name); -+ kfree(ren_entry); -+ inode_info->renamed_list_size--; -+ return 0; -+ } -+ } -+ return 1; -+} -+ -+ -+/* append a single D entry to the meta file */ -+int meta_write_d_entry(dentry_t *dentry, const char *name, int len) -+{ -+ dentry_t *meta_dentry = 0; -+ file_t *meta_file = 0; -+ mm_segment_t old_fs; -+ -+ int bytes, err; -+ struct vfsmount *meta_mnt = 0; -+ char *buf; -+ -+ err = 0; -+ -+ if(itopd(dentry->d_inode)->deleted_list_size < 0) { -+ err = -1; -+ goto out; -+ } -+ -+ if(dtopd(dentry)->state == UNMODIFIED) { -+ err = build_sto_structure(dentry->d_parent, dentry); -+ if(err) { -+ printk(KERN_CRIT "mini_fo: meta_write_d_entry: \ -+ build_sto_structure failed.\n"); -+ goto out; -+ } -+ } -+ meta_dentry = lookup_one_len(META_FILENAME, -+ dtohd2(dentry), strlen (META_FILENAME)); -+ -+ /* We need to create a META-file */ -+ if(!meta_dentry->d_inode) { -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+ vfs_create(dtohd2(dentry)->d_inode, -+ meta_dentry, -+ S_IRUSR | S_IWUSR, -+ NULL); -+#else -+ vfs_create(dtohd2(dentry)->d_inode, -+ meta_dentry, -+ S_IRUSR | S_IWUSR); -+#endif -+ } -+ /* open META-file for writing */ -+ meta_file = dentry_open(meta_dentry, meta_mnt, 0x1); -+ if(!meta_file || IS_ERR(meta_file)) { -+ printk(KERN_CRIT "mini_fo: meta_write_d_entry: \ -+ ERROR opening meta file.\n"); -+ mntput(meta_mnt); /* $%& is this necessary? */ -+ dput(meta_dentry); -+ err = -1; -+ goto out; -+ } -+ -+ /* check if fs supports writing */ -+ if(!meta_file->f_op->write) { -+ printk(KERN_CRIT "mini_fo: meta_write_d_entry: \ -+ ERROR, fs does not support writing.\n"); -+ goto out_err_close; -+ } -+ -+ meta_file->f_pos = meta_dentry->d_inode->i_size; /* append */ -+ old_fs = get_fs(); -+ set_fs(KERNEL_DS); -+ -+ /* size: len for name, 1 for \n and 2 for "D " */ -+ buf = (char *) kmalloc(len+3, GFP_KERNEL); -+ if (!buf) { -+ printk(KERN_CRIT "mini_fo: meta_write_d_entry: \ -+ out of mem.\n"); -+ return -ENOMEM; -+ } -+ -+ buf[0] = 'D'; -+ buf[1] = ' '; -+ strncpy(buf+2, name, len); -+ buf[len+2] = '\n'; -+ bytes = meta_file->f_op->write(meta_file, buf, len+3, -+ &meta_file->f_pos); -+ if(bytes != len+3) { -+ printk(KERN_CRIT "mini_fo: meta_write_d_entry: \ -+ ERROR writing.\n"); -+ err = -1; -+ } -+ kfree(buf); -+ set_fs(old_fs); -+ -+ out_err_close: -+ fput(meta_file); -+ out: -+ return err; -+} -+ -+/* append a single R entry to the meta file */ -+int meta_write_r_entry(dentry_t *dentry, -+ const char *old_name, int old_len, -+ const char *new_name, int new_len) -+{ -+ dentry_t *meta_dentry = 0; -+ file_t *meta_file = 0; -+ mm_segment_t old_fs; -+ -+ int bytes, err, buf_len; -+ struct vfsmount *meta_mnt = 0; -+ char *buf; -+ -+ -+ err = 0; -+ -+ if(itopd(dentry->d_inode)->renamed_list_size < 0) { -+ err = -1; -+ goto out; -+ } -+ -+ /* build the storage structure? */ -+ if(dtopd(dentry)->state == UNMODIFIED) { -+ err = build_sto_structure(dentry->d_parent, dentry); -+ if(err) { -+ printk(KERN_CRIT "mini_fo: meta_write_r_entry: \ -+ build_sto_structure failed.\n"); -+ goto out; -+ } -+ } -+ meta_dentry = lookup_one_len(META_FILENAME, -+ dtohd2(dentry), -+ strlen (META_FILENAME)); -+ if(!meta_dentry->d_inode) { -+ /* We need to create a META-file */ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+ vfs_create(dtohd2(dentry)->d_inode, -+ meta_dentry, S_IRUSR | S_IWUSR, NULL); -+#else -+ vfs_create(dtohd2(dentry)->d_inode, -+ meta_dentry, S_IRUSR | S_IWUSR); -+#endif -+ } -+ /* open META-file for writing */ -+ meta_file = dentry_open(meta_dentry, meta_mnt, 0x1); -+ if(!meta_file || IS_ERR(meta_file)) { -+ printk(KERN_CRIT "mini_fo: meta_write_r_entry: \ -+ ERROR opening meta file.\n"); -+ mntput(meta_mnt); -+ dput(meta_dentry); -+ err = -1; -+ goto out; -+ } -+ -+ /* check if fs supports writing */ -+ if(!meta_file->f_op->write) { -+ printk(KERN_CRIT "mini_fo: meta_write_r_entry: \ -+ ERROR, fs does not support writing.\n"); -+ goto out_err_close; -+ } -+ -+ meta_file->f_pos = meta_dentry->d_inode->i_size; /* append */ -+ old_fs = get_fs(); -+ set_fs(KERNEL_DS); -+ -+ /* size: 2 for "R ", old_len+new_len for names, 1 blank+1 \n */ -+ buf_len = old_len + new_len + 4; -+ buf = (char *) kmalloc(buf_len, GFP_KERNEL); -+ if (!buf) { -+ printk(KERN_CRIT "mini_fo: meta_write_r_entry: out of mem.\n"); -+ return -ENOMEM; -+ } -+ -+ buf[0] = 'R'; -+ buf[1] = ' '; -+ strncpy(buf + 2, old_name, old_len); -+ buf[old_len + 2] = ' '; -+ strncpy(buf + old_len + 3, new_name, new_len); -+ buf[buf_len -1] = '\n'; -+ bytes = meta_file->f_op->write(meta_file, buf, buf_len, &meta_file->f_pos); -+ if(bytes != buf_len) { -+ printk(KERN_CRIT "mini_fo: meta_write_r_entry: ERROR writing.\n"); -+ err = -1; -+ } -+ -+ kfree(buf); -+ set_fs(old_fs); -+ -+ out_err_close: -+ fput(meta_file); -+ out: -+ return err; -+} -+ -+/* sync D list to disk, append data if app_flag is 1 */ -+/* check the meta_mnt, which seems not to be used (properly) */ -+ -+int meta_sync_d_list(dentry_t *dentry, int app_flag) -+{ -+ dentry_t *meta_dentry; -+ file_t *meta_file; -+ mm_segment_t old_fs; -+ -+ int bytes, err; -+ struct vfsmount *meta_mnt; -+ char *buf; -+ -+ struct list_head *tmp; -+ struct deleted_entry *del_entry; -+ struct mini_fo_inode_info *inode_info; -+ -+ err = 0; -+ meta_file=0; -+ meta_mnt=0; -+ -+ if(!dentry || !dentry->d_inode) { -+ printk(KERN_CRIT "mini_fo: meta_sync_d_list: \ -+ invalid inode passed.\n"); -+ err = -1; -+ goto out; -+ } -+ inode_info = itopd(dentry->d_inode); -+ -+ if(inode_info->deleted_list_size < 0) { -+ err = -1; -+ goto out; -+ } -+ -+ /* ok, there is something to sync */ -+ -+ /* build the storage structure? */ -+ if(!dtohd2(dentry) && !itohi2(dentry->d_inode)) { -+ err = build_sto_structure(dentry->d_parent, dentry); -+ if(err) { -+ printk(KERN_CRIT "mini_fo: meta_sync_d_list: \ -+ build_sto_structure failed.\n"); -+ goto out; -+ } -+ } -+ meta_dentry = lookup_one_len(META_FILENAME, -+ dtohd2(dentry), -+ strlen(META_FILENAME)); -+ if(!meta_dentry->d_inode) { -+ /* We need to create a META-file */ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+ vfs_create(dtohd2(dentry)->d_inode, -+ meta_dentry, S_IRUSR | S_IWUSR, NULL); -+#else -+ vfs_create(dtohd2(dentry)->d_inode, -+ meta_dentry, S_IRUSR | S_IWUSR); -+#endif -+ app_flag = 0; -+ } -+ /* need we truncate the meta file? */ -+ if(!app_flag) { -+ struct iattr newattrs; -+ newattrs.ia_size = 0; -+ newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME; -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_lock(&meta_dentry->d_inode->i_mutex); -+#else -+ down(&meta_dentry->d_inode->i_sem); -+#endif -+ err = notify_change(meta_dentry, &newattrs); -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_unlock(&meta_dentry->d_inode->i_mutex); -+#else -+ up(&meta_dentry->d_inode->i_sem); -+#endif -+ -+ if(err || meta_dentry->d_inode->i_size != 0) { -+ printk(KERN_CRIT "mini_fo: meta_sync_d_list: \ -+ ERROR truncating meta file.\n"); -+ goto out_err_close; -+ } -+ } -+ -+ /* open META-file for writing */ -+ meta_file = dentry_open(meta_dentry, meta_mnt, 0x1); -+ if(!meta_file || IS_ERR(meta_file)) { -+ printk(KERN_CRIT "mini_fo: meta_sync_d_list: \ -+ ERROR opening meta file.\n"); -+ /* we don't mntget so we dont't mntput (for now) -+ * mntput(meta_mnt); -+ */ -+ dput(meta_dentry); -+ err = -1; -+ goto out; -+ } -+ -+ /* check if fs supports writing */ -+ if(!meta_file->f_op->write) { -+ printk(KERN_CRIT "mini_fo: meta_sync_d_list: \ -+ ERROR, fs does not support writing.\n"); -+ goto out_err_close; -+ } -+ -+ meta_file->f_pos = meta_dentry->d_inode->i_size; /* append */ -+ old_fs = get_fs(); -+ set_fs(KERNEL_DS); -+ -+ /* here we go... */ -+ list_for_each(tmp, &inode_info->deleted_list) { -+ del_entry = list_entry(tmp, struct deleted_entry, list); -+ -+ /* size: len for name, 1 for \n and 2 for "D " */ -+ buf = (char *) kmalloc(del_entry->len+3, GFP_KERNEL); -+ if (!buf) { -+ printk(KERN_CRIT "mini_fo: meta_sync_d_list: \ -+ out of mem.\n"); -+ return -ENOMEM; -+ } -+ -+ buf[0] = 'D'; -+ buf[1] = ' '; -+ strncpy(buf+2, del_entry->name, del_entry->len); -+ buf[del_entry->len+2] = '\n'; -+ bytes = meta_file->f_op->write(meta_file, buf, -+ del_entry->len+3, -+ &meta_file->f_pos); -+ if(bytes != del_entry->len+3) { -+ printk(KERN_CRIT "mini_fo: meta_sync_d_list: \ -+ ERROR writing.\n"); -+ err |= -1; -+ } -+ kfree(buf); -+ } -+ set_fs(old_fs); -+ -+ out_err_close: -+ fput(meta_file); -+ out: -+ return err; -+ -+} -+ -+int meta_sync_r_list(dentry_t *dentry, int app_flag) -+{ -+ dentry_t *meta_dentry; -+ file_t *meta_file; -+ mm_segment_t old_fs; -+ -+ int bytes, err, buf_len; -+ struct vfsmount *meta_mnt; -+ char *buf; -+ -+ struct list_head *tmp; -+ struct renamed_entry *ren_entry; -+ struct mini_fo_inode_info *inode_info; -+ -+ err = 0; -+ meta_file=0; -+ meta_mnt=0; -+ -+ if(!dentry || !dentry->d_inode) { -+ printk(KERN_CRIT "mini_fo: meta_sync_r_list: \ -+ invalid dentry passed.\n"); -+ err = -1; -+ goto out; -+ } -+ inode_info = itopd(dentry->d_inode); -+ -+ if(inode_info->deleted_list_size < 0) { -+ err = -1; -+ goto out; -+ } -+ -+ /* ok, there is something to sync */ -+ -+ /* build the storage structure? */ -+ if(!dtohd2(dentry) && !itohi2(dentry->d_inode)) { -+ err = build_sto_structure(dentry->d_parent, dentry); -+ if(err) { -+ printk(KERN_CRIT "mini_fo: meta_sync_r_list: \ -+ build_sto_structure failed.\n"); -+ goto out; -+ } -+ } -+ meta_dentry = lookup_one_len(META_FILENAME, -+ dtohd2(dentry), -+ strlen(META_FILENAME)); -+ if(!meta_dentry->d_inode) { -+ /* We need to create a META-file */ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+ vfs_create(dtohd2(dentry)->d_inode, -+ meta_dentry, S_IRUSR | S_IWUSR, NULL); -+#else -+ vfs_create(dtohd2(dentry)->d_inode, -+ meta_dentry, S_IRUSR | S_IWUSR); -+#endif -+ app_flag = 0; -+ } -+ /* need we truncate the meta file? */ -+ if(!app_flag) { -+ struct iattr newattrs; -+ newattrs.ia_size = 0; -+ newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME; -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_lock(&meta_dentry->d_inode->i_mutex); -+#else -+ down(&meta_dentry->d_inode->i_sem); -+#endif -+ err = notify_change(meta_dentry, &newattrs); -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_unlock(&meta_dentry->d_inode->i_mutex); -+#else -+ up(&meta_dentry->d_inode->i_sem); -+#endif -+ if(err || meta_dentry->d_inode->i_size != 0) { -+ printk(KERN_CRIT "mini_fo: meta_sync_r_list: \ -+ ERROR truncating meta file.\n"); -+ goto out_err_close; -+ } -+ } -+ -+ /* open META-file for writing */ -+ meta_file = dentry_open(meta_dentry, meta_mnt, 0x1); -+ if(!meta_file || IS_ERR(meta_file)) { -+ printk(KERN_CRIT "mini_fo: meta_sync_r_list: \ -+ ERROR opening meta file.\n"); -+ /* we don't mntget so we dont't mntput (for now) -+ * mntput(meta_mnt); -+ */ -+ dput(meta_dentry); -+ err = -1; -+ goto out; -+ } -+ -+ /* check if fs supports writing */ -+ if(!meta_file->f_op->write) { -+ printk(KERN_CRIT "mini_fo: meta_sync_r_list: \ -+ ERROR, fs does not support writing.\n"); -+ goto out_err_close; -+ } -+ -+ meta_file->f_pos = meta_dentry->d_inode->i_size; /* append */ -+ old_fs = get_fs(); -+ set_fs(KERNEL_DS); -+ -+ /* here we go... */ -+ list_for_each(tmp, &inode_info->renamed_list) { -+ ren_entry = list_entry(tmp, struct renamed_entry, list); -+ /* size: -+ * 2 for "R ", old_len+new_len for names, 1 blank+1 \n */ -+ buf_len = ren_entry->old_len + ren_entry->new_len + 4; -+ buf = (char *) kmalloc(buf_len, GFP_KERNEL); -+ if (!buf) { -+ printk(KERN_CRIT "mini_fo: meta_sync_r_list: \ -+ out of mem.\n"); -+ return -ENOMEM; -+ } -+ buf[0] = 'R'; -+ buf[1] = ' '; -+ strncpy(buf + 2, ren_entry->old_name, ren_entry->old_len); -+ buf[ren_entry->old_len + 2] = ' '; -+ strncpy(buf + ren_entry->old_len + 3, -+ ren_entry->new_name, ren_entry->new_len); -+ buf[buf_len - 1] = '\n'; -+ bytes = meta_file->f_op->write(meta_file, buf, -+ buf_len, &meta_file->f_pos); -+ if(bytes != buf_len) { -+ printk(KERN_CRIT "mini_fo: meta_sync_r_list: \ -+ ERROR writing.\n"); -+ err |= -1; -+ } -+ kfree(buf); -+ } -+ set_fs(old_fs); -+ -+ out_err_close: -+ fput(meta_file); -+ out: -+ return err; -+} -+ -+int meta_check_d_entry(dentry_t *dentry, const char *name, int len) -+{ -+ if(!dentry || !dentry->d_inode) -+ printk(KERN_CRIT "mini_fo: meta_check_d_dentry: \ -+ invalid dentry passed.\n"); -+ return __meta_check_d_entry(dentry->d_inode, name, len); -+} -+ -+int __meta_check_d_entry(inode_t *inode, const char *name, int len) -+{ -+ struct list_head *tmp; -+ struct deleted_entry *del_entry; -+ struct mini_fo_inode_info *inode_info; -+ -+ if(!inode || !itopd(inode)) -+ printk(KERN_CRIT "mini_fo: __meta_check_d_dentry: \ -+ invalid inode passed.\n"); -+ -+ inode_info = itopd(inode); -+ -+ if(inode_info->deleted_list_size <= 0) -+ return 0; -+ -+ list_for_each(tmp, &inode_info->deleted_list) { -+ del_entry = list_entry(tmp, struct deleted_entry, list); -+ if(del_entry->len != len) -+ continue; -+ -+ if(!strncmp(del_entry->name, name, len)) -+ return 1; -+ } -+ return 0; -+} -+ -+/* -+ * check if file has been renamed and return path to orig. base dir. -+ * Implements no error return values so far, what of course sucks. -+ * String is null terminated.' -+ */ -+char* meta_check_r_entry(dentry_t *dentry, const char *name, int len) -+{ -+ if(!dentry || !dentry->d_inode) { -+ printk(KERN_CRIT "mini_fo: meta_check_r_dentry: \ -+ invalid dentry passed.\n"); -+ return NULL; -+ } -+ return __meta_check_r_entry(dentry->d_inode, name, len); -+} -+ -+char* __meta_check_r_entry(inode_t *inode, const char *name, int len) -+{ -+ struct list_head *tmp; -+ struct renamed_entry *ren_entry; -+ struct mini_fo_inode_info *inode_info; -+ char *old_path; -+ -+ if(!inode || !itopd(inode)) { -+ printk(KERN_CRIT "mini_fo: meta_check_r_dentry: \ -+ invalid inode passed.\n"); -+ return NULL; -+ } -+ inode_info = itopd(inode); -+ -+ if(inode_info->renamed_list_size <= 0) -+ return NULL; -+ -+ list_for_each(tmp, &inode_info->renamed_list) { -+ ren_entry = list_entry(tmp, struct renamed_entry, list); -+ if(ren_entry->new_len != len) -+ continue; -+ -+ if(!strncmp(ren_entry->new_name, name, len)) { -+ old_path = (char *) -+ kmalloc(ren_entry->old_len+1, GFP_KERNEL); -+ strncpy(old_path, -+ ren_entry->old_name, -+ ren_entry->old_len); -+ old_path[ren_entry->old_len]='\0'; -+ return old_path; -+ } -+ } -+ return NULL; -+} -+ -+/* -+ * This version only checks if entry exists and return: -+ * 1 if exists, -+ * 0 if not, -+ * -1 if error. -+ */ -+int meta_is_r_entry(dentry_t *dentry, const char *name, int len) -+{ -+ if(!dentry || !dentry->d_inode) { -+ printk(KERN_CRIT "mini_fo: meta_check_r_dentry [2]: \ -+ invalid dentry passed.\n"); -+ return -1; -+ } -+ return __meta_is_r_entry(dentry->d_inode, name, len); -+} -+ -+int __meta_is_r_entry(inode_t *inode, const char *name, int len) -+{ -+ struct list_head *tmp; -+ struct renamed_entry *ren_entry; -+ struct mini_fo_inode_info *inode_info; -+ -+ if(!inode || !itopd(inode)) { -+ printk(KERN_CRIT "mini_fo: meta_check_r_dentry [2]: \ -+ invalid inode passed.\n"); -+ return -1; -+ } -+ inode_info = itopd(inode); -+ -+ if(inode_info->renamed_list_size <= 0) -+ return -1; -+ -+ list_for_each(tmp, &inode_info->renamed_list) { -+ ren_entry = list_entry(tmp, struct renamed_entry, list); -+ if(ren_entry->new_len != len) -+ continue; -+ -+ if(!strncmp(ren_entry->new_name, name, len)) -+ return 1; -+ } -+ return 0; -+} -+ ---- /dev/null -+++ b/fs/mini_fo/mini_fo.h -@@ -0,0 +1,503 @@ -+/* -+ * Copyright (c) 1997-2003 Erez Zadok -+ * Copyright (c) 2001-2003 Stony Brook University -+ * -+ * For specific licensing information, see the COPYING file distributed with -+ * this package, or get one from ftp://ftp.filesystems.org/pub/fist/COPYING. -+ * -+ * This Copyright notice must be kept intact and distributed with all -+ * fistgen sources INCLUDING sources generated by fistgen. -+ */ -+/* -+ * Copyright (C) 2004, 2005 Markus Klotzbuecher <mk@creamnet.de> -+ * -+ * 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. -+ */ -+ -+/* -+ * $Id$ -+ */ -+ -+#ifndef __MINI_FO_H_ -+#define __MINI_FO_H_ -+ -+#ifdef __KERNEL__ -+ -+/* META stuff */ -+#define META_FILENAME "META_dAfFgHE39ktF3HD2sr" -+ -+/* use xattrs? */ -+#define XATTR -+ -+/* File attributes that when changed, result in a file beeing copied to storage */ -+#define COPY_FLAGS ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_SIZE -+ -+/* -+ * mini_fo filestates -+ */ -+#define MODIFIED 1 -+#define UNMODIFIED 2 -+#define CREATED 3 -+#define DEL_REWRITTEN 4 -+#define DELETED 5 -+#define NON_EXISTANT 6 -+ -+/* fist file systems superblock magic */ -+# define MINI_FO_SUPER_MAGIC 0xf15f -+ -+/* -+ * STRUCTURES: -+ */ -+ -+/* mini_fo inode data in memory */ -+struct mini_fo_inode_info { -+ inode_t *wii_inode; -+ inode_t *wii_inode2; /* pointer to storage inode */ -+ -+ /* META-data lists */ -+ /* deleted list, ex wol */ -+ struct list_head deleted_list; -+ int deleted_list_size; -+ -+ /* renamed list */ -+ struct list_head renamed_list; -+ int renamed_list_size; -+ -+ /* add other lists here ... */ -+}; -+ -+/* mini_fo dentry data in memory */ -+struct mini_fo_dentry_info { -+ dentry_t *wdi_dentry; -+ dentry_t *wdi_dentry2; /* pointer to storage dentry */ -+ unsigned int state; /* state of the mini_fo dentry */ -+}; -+ -+ -+/* mini_fo super-block data in memory */ -+struct mini_fo_sb_info { -+ super_block_t *wsi_sb, *wsi_sb2; /* mk: might point to the same sb */ -+ struct vfsmount *hidden_mnt, *hidden_mnt2; -+ dentry_t *base_dir_dentry; -+ dentry_t *storage_dir_dentry; -+ ; -+}; -+ -+/* readdir_data, readdir helper struct */ -+struct readdir_data { -+ struct list_head ndl_list; /* linked list head ptr */ -+ int ndl_size; /* list size */ -+ int sto_done; /* flag to show that the storage dir entries have -+ * all been read an now follow base entries */ -+}; -+ -+/* file private data. */ -+struct mini_fo_file_info { -+ struct file *wfi_file; -+ struct file *wfi_file2; /* pointer to storage file */ -+ struct readdir_data rd; -+}; -+ -+/* struct ndl_entry */ -+struct ndl_entry { -+ struct list_head list; -+ char *name; -+ int len; -+}; -+ -+/******************************** -+ * META-data structures -+ ********************************/ -+ -+/* deleted entry */ -+struct deleted_entry { -+ struct list_head list; -+ char *name; -+ int len; -+}; -+ -+/* renamed entry */ -+struct renamed_entry { -+ struct list_head list; -+ char *old_name; /* old directory with full path */ -+ int old_len; /* length of above string */ -+ char *new_name; /* new directory name */ -+ int new_len; /* length of above string */ -+}; -+ -+/* attr_change entry */ -+struct attr_change_entry { -+ struct list_head list; -+ char *name; -+ int len; -+}; -+ -+/* link entry */ -+struct link_entry { -+ struct list_head list; -+ int links_moved; -+ int inum_base; -+ int inum_sto; -+ char *weird_name; -+ int weird_name_len; -+}; -+ -+ -+/* Some other stuff required for mini_fo_filldir64, copied from -+ * fs/readdir.c -+ */ -+ -+#define ROUND_UP64(x) (((x)+sizeof(u64)-1) & ~(sizeof(u64)-1)) -+#define NAME_OFFSET(de) ((int) ((de)->d_name - (char *) (de))) -+ -+ -+struct linux_dirent64 { -+ u64 d_ino; -+ s64 d_off; -+ unsigned short d_reclen; -+ unsigned char d_type; -+ char d_name[0]; -+}; -+ -+ -+struct getdents_callback64 { -+ struct linux_dirent64 * current_dir; -+ struct linux_dirent64 * previous; -+ int count; -+ int error; -+}; -+ -+struct linux_dirent { -+ unsigned long d_ino; -+ unsigned long d_off; -+ unsigned short d_reclen; -+ char d_name[1]; -+}; -+ -+struct getdents_callback { -+ struct linux_dirent * current_dir; -+ struct linux_dirent * previous; -+ int count; -+ int error; -+}; -+ -+ -+/* -+ * MACROS: -+ */ -+ -+/* file TO private_data */ -+# define ftopd(file) ((struct mini_fo_file_info *)((file)->private_data)) -+# define __ftopd(file) ((file)->private_data) -+/* file TO hidden_file */ -+# define ftohf(file) ((ftopd(file))->wfi_file) -+# define ftohf2(file) ((ftopd(file))->wfi_file2) -+ -+/* inode TO private_data */ -+# define itopd(ino) ((struct mini_fo_inode_info *)(ino)->u.generic_ip) -+# define __itopd(ino) ((ino)->u.generic_ip) -+/* inode TO hidden_inode */ -+# define itohi(ino) (itopd(ino)->wii_inode) -+# define itohi2(ino) (itopd(ino)->wii_inode2) -+ -+/* superblock TO private_data */ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+# define stopd(super) ((struct mini_fo_sb_info *)(super)->s_fs_info) -+# define __stopd(super) ((super)->s_fs_info) -+#else -+# define stopd(super) ((struct mini_fo_sb_info *)(super)->u.generic_sbp) -+# define __stopd(super) ((super)->u.generic_sbp) -+#endif -+ -+/* unused? # define vfs2priv stopd */ -+/* superblock TO hidden_superblock */ -+ -+# define stohs(super) (stopd(super)->wsi_sb) -+# define stohs2(super) (stopd(super)->wsi_sb2) -+ -+/* dentry TO private_data */ -+# define dtopd(dentry) ((struct mini_fo_dentry_info *)(dentry)->d_fsdata) -+# define __dtopd(dentry) ((dentry)->d_fsdata) -+/* dentry TO hidden_dentry */ -+# define dtohd(dent) (dtopd(dent)->wdi_dentry) -+# define dtohd2(dent) (dtopd(dent)->wdi_dentry2) -+ -+/* dentry to state */ -+# define dtost(dent) (dtopd(dent)->state) -+# define sbt(sb) ((sb)->s_type->name) -+ -+#define IS_WRITE_FLAG(flag) (flag & (O_RDWR | O_WRONLY | O_APPEND)) -+#define IS_COPY_FLAG(flag) (flag & (COPY_FLAGS)) -+ -+/* macros to simplify non-SCA code */ -+# define MALLOC_PAGE_POINTERS(hidden_pages, num_hidden_pages) -+# define MALLOC_PAGEDATA_POINTERS(hidden_pages_data, num_hidden_pages) -+# define FREE_PAGE_POINTERS(hidden_pages, num) -+# define FREE_PAGEDATA_POINTERS(hidden_pages_data, num) -+# define FOR_EACH_PAGE -+# define CURRENT_HIDDEN_PAGE hidden_page -+# define CURRENT_HIDDEN_PAGEDATA hidden_page_data -+# define CURRENT_HIDDEN_PAGEINDEX page->index -+ -+/* -+ * EXTERNALS: -+ */ -+extern struct file_operations mini_fo_main_fops; -+extern struct file_operations mini_fo_dir_fops; -+extern struct inode_operations mini_fo_main_iops; -+extern struct inode_operations mini_fo_dir_iops; -+extern struct inode_operations mini_fo_symlink_iops; -+extern struct super_operations mini_fo_sops; -+extern struct dentry_operations mini_fo_dops; -+extern struct vm_operations_struct mini_fo_shared_vmops; -+extern struct vm_operations_struct mini_fo_private_vmops; -+extern struct address_space_operations mini_fo_aops; -+ -+#if 0 /* unused by mini_fo */ -+extern int mini_fo_interpose(dentry_t *hidden_dentry, dentry_t *this_dentry, super_block_t *sb, int flag); -+#if defined(FIST_FILTER_DATA) || defined(FIST_FILTER_SCA) -+extern page_t *mini_fo_get1page(file_t *file, int index); -+extern int mini_fo_fill_zeros(file_t *file, page_t *page, unsigned from); -+# endif /* FIST_FILTER_DATA || FIST_FILTER_SCA */ -+ -+ -+# define mini_fo_hidden_dentry(d) __mini_fo_hidden_dentry(__FILE__,__FUNCTION__,__LINE__,(d)) -+# define mini_fo_hidden_sto_dentry(d) __mini_fo_hidden_sto_dentry(__FILE__,__FUNCTION__,__LINE__,(d)) -+ -+extern dentry_t *__mini_fo_hidden_dentry(char *file, char *func, int line, dentry_t *this_dentry); -+extern dentry_t *__mini_fo_hidden_sto_dentry(char *file, char *func, int line, dentry_t *this_dentry); -+ -+extern int mini_fo_read_file(const char *filename, void *buf, int len); -+extern int mini_fo_write_file(const char *filename, void *buf, int len); -+extern dentry_t *fist_lookup(dentry_t *dir, const char *name, vnode_t **out, uid_t uid, gid_t gid); -+#endif /* unused by mini_fo */ -+ -+/* state transition functions */ -+extern int nondir_unmod_to_mod(dentry_t *dentry, int cp_flag); -+extern int nondir_del_rew_to_del(dentry_t *dentry); -+extern int nondir_creat_to_del(dentry_t *dentry); -+extern int nondir_mod_to_del(dentry_t *dentry); -+extern int nondir_unmod_to_del(dentry_t *dentry); -+ -+extern int dir_unmod_to_mod(dentry_t *dentry); -+ -+/* rename specials */ -+extern int rename_directory(inode_t *old_dir, dentry_t *old_dentry, inode_t *new_dir, dentry_t *new_dentry); -+extern int rename_nondir(inode_t *old_dir, dentry_t *old_dentry, inode_t *new_dir, dentry_t *new_dentry); -+ -+/* misc stuff */ -+extern int mini_fo_tri_interpose(dentry_t *hidden_dentry, -+ dentry_t *hidden_sto_dentry, -+ dentry_t *dentry, -+ super_block_t *sb, int flag); -+ -+extern int mini_fo_cp_cont(dentry_t *tgt_dentry, struct vfsmount *tgt_mnt, -+ dentry_t *src_dentry, struct vfsmount *src_mnt); -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+extern int mini_fo_create(inode_t *dir, dentry_t *dentry, int mode, struct nameidata *nd); -+ -+extern int create_sto_nod(dentry_t *dentry, int mode, dev_t dev); -+extern int create_sto_reg_file(dentry_t *dentry, int mode, struct nameidata *nd); -+#else -+extern int mini_fo_create(inode_t *dir, dentry_t *dentry, int mode); -+ -+extern int create_sto_nod(dentry_t *dentry, int mode, int dev); -+extern int create_sto_reg_file(dentry_t *dentry, int mode); -+#endif -+ -+extern int create_sto_dir(dentry_t *dentry, int mode); -+ -+extern int exists_in_storage(dentry_t *dentry); -+extern int is_mini_fo_existant(dentry_t *dentry); -+extern int get_neg_sto_dentry(dentry_t *dentry); -+extern int build_sto_structure(dentry_t *dir, dentry_t *dentry); -+extern int get_mini_fo_bpath(dentry_t *dentry, char **bpath, int *bpath_len); -+extern dentry_t *bpath_walk(super_block_t *sb, char *bpath); -+extern int bpath_put(dentry_t *dentry); -+ -+/* check_mini_fo types functions */ -+extern int check_mini_fo_dentry(dentry_t *dentry); -+extern int check_mini_fo_file(file_t *file); -+extern int check_mini_fo_inode(inode_t *inode); -+ -+/* General meta functions, can be called from outside of meta.c */ -+extern int meta_build_lists(dentry_t *dentry); -+extern int meta_put_lists(dentry_t *dentry); -+extern int __meta_put_lists(inode_t *inode); -+ -+extern int meta_add_d_entry(dentry_t *dentry, const char *name, int len); -+extern int meta_add_r_entry(dentry_t *dentry, -+ const char *old_name, int old_len, -+ const char *new_name, int new_len); -+ -+extern int meta_remove_r_entry(dentry_t *dentry, const char *name, int len); -+ -+extern int meta_check_d_entry(dentry_t *dentry, const char *name, int len); -+extern int __meta_check_d_entry(inode_t *inode, const char *name, int len); -+ -+extern char* meta_check_r_entry(dentry_t *dentry, const char *name, int len); -+extern char* __meta_check_r_entry(inode_t *inode, const char *name, int len); -+extern int meta_is_r_entry(dentry_t *dentry, const char *name, int len); -+extern int __meta_is_r_entry(inode_t *inode, const char *name, int len); -+ -+/* Specific meta functions, should be called only inside meta.c */ -+extern int __meta_put_d_list(inode_t *inode); -+extern int __meta_put_r_list(inode_t *inode); -+ -+extern int meta_list_add_d_entry(dentry_t *dentry, -+ const char *name, int len); -+extern int meta_list_add_r_entry(dentry_t *dentry, -+ const char *old_name, int old_len, -+ const char *new_name, int new_len); -+ -+extern int meta_list_remove_r_entry(dentry_t *dentry, -+ const char *name, int len); -+ -+extern int __meta_list_remove_r_entry(inode_t *inode, -+ const char *name, int len); -+ -+extern int meta_write_d_entry(dentry_t *dentry, const char *name, int len); -+extern int meta_write_r_entry(dentry_t *dentry, -+ const char *old_name, int old_len, -+ const char *new_name, int new_len); -+ -+extern int meta_sync_lists(dentry_t *dentry); -+extern int meta_sync_d_list(dentry_t *dentry, int app_flag); -+extern int meta_sync_r_list(dentry_t *dentry, int app_flag); -+ -+/* ndl stuff */ -+extern int ndl_add_entry(struct readdir_data *rd, const char *name, int len); -+extern void ndl_put_list(struct readdir_data *rd); -+extern int ndl_check_entry(struct readdir_data *rd, -+ const char *name, int len); -+ -+ -+# define copy_inode_size(dst, src) \ -+ dst->i_size = src->i_size; \ -+ dst->i_blocks = src->i_blocks; -+ -+static inline void -+fist_copy_attr_atime(inode_t *dest, const inode_t *src) -+{ -+ ASSERT(dest != NULL); -+ ASSERT(src != NULL); -+ dest->i_atime = src->i_atime; -+} -+static inline void -+fist_copy_attr_times(inode_t *dest, const inode_t *src) -+{ -+ ASSERT(dest != NULL); -+ ASSERT(src != NULL); -+ dest->i_atime = src->i_atime; -+ dest->i_mtime = src->i_mtime; -+ dest->i_ctime = src->i_ctime; -+} -+static inline void -+fist_copy_attr_timesizes(inode_t *dest, const inode_t *src) -+{ -+ ASSERT(dest != NULL); -+ ASSERT(src != NULL); -+ dest->i_atime = src->i_atime; -+ dest->i_mtime = src->i_mtime; -+ dest->i_ctime = src->i_ctime; -+ copy_inode_size(dest, src); -+} -+static inline void -+fist_copy_attr_all(inode_t *dest, const inode_t *src) -+{ -+ ASSERT(dest != NULL); -+ ASSERT(src != NULL); -+ dest->i_mode = src->i_mode; -+ dest->i_nlink = src->i_nlink; -+ dest->i_uid = src->i_uid; -+ dest->i_gid = src->i_gid; -+ dest->i_rdev = src->i_rdev; -+ dest->i_atime = src->i_atime; -+ dest->i_mtime = src->i_mtime; -+ dest->i_ctime = src->i_ctime; -+ dest->i_blksize = src->i_blksize; -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,12) -+ dest->i_blkbits = src->i_blkbits; -+# endif /* linux 2.4.12 and newer */ -+ copy_inode_size(dest, src); -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) -+ dest->i_attr_flags = src->i_attr_flags; -+#else -+ dest->i_flags = src->i_flags; -+#endif -+} -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+/* copied from linux/fs.h */ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+static inline void double_lock(struct dentry *d1, struct dentry *d2) -+{ -+ struct mutex *m1 = &d1->d_inode->i_mutex; -+ struct mutex *m2 = &d2->d_inode->i_mutex; -+ if (m1 != m2) { -+ if ((unsigned long) m1 < (unsigned long) m2) { -+ struct mutex *tmp = m2; -+ m2 = m1; m1 = tmp; -+ } -+ mutex_lock(m1); -+ } -+ mutex_lock(m2); -+} -+ -+static inline void double_unlock(struct dentry *d1, struct dentry *d2) -+{ -+ struct mutex *m1 = &d1->d_inode->i_mutex; -+ struct mutex *m2 = &d2->d_inode->i_mutex; -+ mutex_unlock(m1); -+ if (m1 != m2) -+ mutex_unlock(m2); -+ dput(d1); -+ dput(d2); -+} -+ -+#else -+static inline void double_down(struct semaphore *s1, struct semaphore *s2) -+{ -+ if (s1 != s2) { -+ if ((unsigned long) s1 < (unsigned long) s2) { -+ struct semaphore *tmp = s2; -+ s2 = s1; s1 = tmp; -+ } -+ down(s1); -+ } -+ down(s2); -+} -+ -+static inline void double_up(struct semaphore *s1, struct semaphore *s2) -+{ -+ up(s1); -+ if (s1 != s2) -+ up(s2); -+} -+ -+static inline void double_lock(struct dentry *d1, struct dentry *d2) -+{ -+ double_down(&d1->d_inode->i_sem, &d2->d_inode->i_sem); -+} -+ -+static inline void double_unlock(struct dentry *d1, struct dentry *d2) -+{ -+ double_up(&d1->d_inode->i_sem,&d2->d_inode->i_sem); -+ dput(d1); -+ dput(d2); -+} -+#endif /* if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) */ -+#endif /* if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) */ -+#endif /* __KERNEL__ */ -+ -+/* -+ * Definitions for user and kernel code -+ */ -+ -+/* ioctls */ -+ -+#endif /* not __MINI_FO_H_ */ ---- /dev/null -+++ b/fs/mini_fo/mini_fo-merge -@@ -0,0 +1,180 @@ -+#!/bin/bash -+# -+# Copyright (C) 2005 Markus Klotzbuecher <mk@creamnet.de> -+# 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. -+# -+ -+BASE= -+STO= -+HELP= -+DRYRUN= -+VERBOSE= -+TMP="/tmp/" -+META_NAME="META_dAfFgHE39ktF3HD2sr" -+SKIP_DEL_LIST="skip-delete-list.mini_fo-merge" -+ -+COMMAND= -+exec_command() -+{ -+ if [ x$DRYRUN == "xset" ]; then -+ echo " would run: $COMMAND" -+ elif ! [ x$DRYRUN == "xset" ]; then -+ if [ x$VERBOSE == "xset" ]; then -+ echo " running: $COMMAND" -+ fi -+ eval $COMMAND -+ fi -+} -+ -+usage() -+{ -+cat <<EOF -+ -+USAGE: $0 -b <base dir> -s <storage dir> -+Version 0.1 -+ -+This script merges the contents of a mini_fo storage file system back -+to the base file system. -+ -+!!! Warning: This will modify the base filesystem and can destroy data -+ if used wrongly. -+ -+Options: -+ -b <base dir> -+ the directory of the base file system. -+ -+ -s <storage dir> -+ the directory of the storage file system. -+ -+ -d dry run, will not change anything and print the commands that -+ would be executed. -+ -+ -t tmp dir for storing temporary file. default: $TMP -+ -+ -v show what operations are performed. -+ -+ -h displays this message. -+ -+EOF -+} -+ -+# parse parameters -+while getopts hdvt:b:s: OPTS -+ do -+ case $OPTS in -+ h) HELP="set";; -+ d) DRYRUN="set";; -+ v) VERBOSE="set";; -+ b) BASE="$OPTARG";; -+ s) STO="$OPTARG";; -+ t) TMP="$OPTARG";; -+ ?) usage -+ exit 1;; -+ esac -+done -+ -+if [ "x$HELP" == "xset" ]; then -+ usage -+ exit -1 -+fi -+ -+if ! [ -d "$BASE" ] || ! [ -d "$STO" ]; then -+ echo -e "$0:\n Error, -s and/or -b argument missing. type $0 -h for help." -+ exit -1; -+fi -+ -+# get full paths -+pushd $STO; STO=`pwd`; popd -+pushd $BASE; BASE=`pwd`; popd -+TMP=${TMP%/} -+ -+ -+cat<<EOF -+############################################################################### -+# mini_fo-merge -+# -+# base dir: $BASE -+# storage dir: $STO -+# meta filename: $META_NAME -+# dry run: $DRYRUN -+# verbose: $VERBOSE -+# tmp files: $TMP -+############################################################################### -+ -+EOF -+ -+rm $TMP/$SKIP_DEL_LIST -+ -+# first process all renamed dirs -+echo "Merging renamed directories..." -+pushd $STO &> /dev/null -+find . -name $META_NAME -type f -print0 | xargs -0 -e grep -e '^R ' | tr -s ':R' ' ' | while read ENTRY; do -+ echo "entry: $ENTRY" -+ META_FILE=`echo $ENTRY | cut -d ' ' -f 1` -+ OLD_B_DIR=`echo $ENTRY | cut -d ' ' -f 2 | sed -e 's/\///'` -+ NEW_NAME=`echo $ENTRY | cut -d ' ' -f 3` -+ NEW_B_DIR=`echo $META_FILE | sed -e "s/$META_NAME/$NEW_NAME/" | sed -e 's/^\.\///'` -+ echo "META_FILE: $META_FILE" -+ echo "OLD_B_DIR: $OLD_B_DIR" -+ echo "NEW_NAME: $NEW_NAME" -+ echo "NEW_B_DIR: $NEW_B_DIR" -+ -+ pushd $BASE &> /dev/null -+ # remove an existing dir in storage -+ COMMAND="rm -rf $NEW_B_DIR"; exec_command -+ COMMAND="cp -R $OLD_B_DIR $NEW_B_DIR"; exec_command -+ echo "" -+ popd &> /dev/null -+ -+ # remember this dir to exclude it from deleting later -+ echo $NEW_B_DIR >> $TMP/$SKIP_DEL_LIST -+done -+ -+# delete all whiteouted files from base -+echo -e "\nDeleting whiteout'ed files from base file system..." -+find . -name $META_NAME -type f -print0 | xargs -0 -e grep -e '^D ' | sed -e 's/:D//' | while read ENTRY; do -+ META_FILE=`echo $ENTRY | cut -d ' ' -f 1` -+ DEL_NAME=`echo $ENTRY | cut -d ' ' -f 2` -+ DEL_FILE=`echo $META_FILE | sed -e "s/$META_NAME/$DEL_NAME/" | sed -e 's/^\.\///'` -+ grep -x $DEL_FILE $TMP/$SKIP_DEL_LIST &> /dev/null -+ if [ $? -ne 0 ]; then -+ pushd $BASE &> /dev/null -+ COMMAND="rm -rf $DEL_FILE"; exec_command -+ popd &> /dev/null -+ else -+ echo " excluding: $DEL_FILE as in skip-del-list." -+ fi -+done -+ -+# create all dirs and update permissions -+echo -e "\nSetting up directory structures in base file system..." -+find . -type d | sed -e 's/^\.\///' | while read DIR; do -+ PERMS=`stat -c %a $DIR` -+ DIR_UID=`stat -c %u $DIR` -+ DIR_GID=`stat -c %g $DIR` -+ pushd $BASE &> /dev/null -+ if ! [ -d $DIR ]; then -+ COMMAND="mkdir -p $DIR"; exec_command -+ fi -+ COMMAND="chmod $PERMS $DIR"; exec_command -+ COMMAND="chown $DIR_UID:$DIR_GID $DIR"; exec_command -+ popd &> /dev/null -+done -+ -+# merge all non-directory files -+echo -e "\nMerging all non-directory files...." -+for i in b c p f l s; do -+ find . -type $i | sed -e 's/^\.\///' | grep -v "$META_NAME" | while read FILE; do -+ pushd $BASE #&> /dev/null -+ COMMAND="cp -df $STO/$FILE $BASE/$FILE"; exec_command -+ popd &> /dev/null -+ done -+done -+popd &> /dev/null -+ -+#rm $TMP/$SKIP_DEL_LIST -+ -+echo "Done!" ---- /dev/null -+++ b/fs/mini_fo/mini_fo-overlay -@@ -0,0 +1,130 @@ -+#!/bin/bash -+# -+# Copyright (C) 2005 Markus Klotzbuecher <mk@creamnet.de> -+# 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. -+# -+ -+HELP= -+SUFF= -+MNTP= -+MNT_DIR="/mnt" -+STO= -+STO_DIR="/tmp" -+BASE= -+ -+usage() -+{ -+cat <<EOF -+ -+Usage: $0 [-s suffix] [-d sto_dir_dir] [-m mount point] base_dir -+Version 0.1 -+ -+This script overlays the given base directory using the mini_fo file -+system. If only the base directory base_dir is given, $0 -+will use a storage directory called "sto-<base_dir_name>" in $STO_DIR, -+and mount point "mini_fo-<base_dir_dir>" in $MNT_DIR. -+ -+Options: -+ -s <suffix> -+ add given suffix to storage directory and the mount -+ point. This is usefull for overlaying one base directory -+ several times and avoiding conflicts with storage directory -+ names and mount points. -+ -+ -d <sto_dir_dir> -+ change the directory in which the storage directory will be -+ created (default is currently "$STO_DIR". -+ -+ -m <mount point> -+ use an alternative directory to create the mini_fo -+ mountpoint (default is currently "$MNT_DIR". -+ -+ -h displays this message. -+ -+EOF -+exit 1; -+} -+ -+while getopts hm:s:d: OPTS -+ do -+ case $OPTS in -+ s) SUFF="$OPTARG";; -+ d) STO_DIR="$OPTARG";; -+ m) MNT_DIR="$OPTARG";; -+ h) HELP="set";; -+ ?) usage -+ exit 1;; -+ esac -+done -+shift $(($OPTIND - 1)) -+ -+BASE="$1" -+ -+if [ "x$HELP" == "xset" ]; then -+ usage -+ exit -1 -+fi -+ -+# fix suffix -+if [ "x$SUFF" != "x" ]; then -+ SUFF="-$SUFF" -+fi -+ -+# kill trailing slashes -+MNT_DIR=${MNT_DIR%/} -+STO_DIR=${STO_DIR%/} -+BASE=${BASE%/} -+ -+ -+if ! [ -d "$BASE" ]; then -+ echo "invalid base dir $BASE, run $0 -h for help." -+ exit -1 -+fi -+ -+# check opts -+if ! [ -d "$MNT_DIR" ]; then -+ echo "invalid mount dir $MNT_DIR, run $0 -h for help." -+ exit -1 -+fi -+ -+if ! [ -d "$STO_DIR" ]; then -+ echo "invalid sto_dir_dir $STO_DIR, run $0 -h for help." -+ exit -1 -+fi -+ -+MNTP="$MNT_DIR/mini_fo-`basename $BASE`$SUFF" -+STO="$STO_DIR/sto-`basename $BASE`$SUFF" -+ -+# create the mount point if it doesn't exist -+mkdir -p $MNTP -+if [ $? -ne 0 ]; then -+ echo "Error, failed to create mount point $MNTP" -+fi -+ -+mkdir -p $STO -+if [ $? -ne 0 ]; then -+ echo "Error, failed to create storage dir $STO" -+fi -+ -+# check if fs is already mounted -+mount | grep mini_fo | grep $MNTP &> /dev/null -+if [ $? -eq 0 ]; then -+ echo "Error, existing mini_fo mount at $MNTP." -+ exit -1 -+fi -+ -+mount | grep mini_fo | grep $STO &> /dev/null -+if [ $? -eq 0 ]; then -+ echo "Error, $STO seems to be used already." -+ exit -1 -+fi -+ -+# mount -+mount -t mini_fo -o base=$BASE,sto=$STO $BASE $MNTP -+ -+if [ $? -ne 0 ]; then -+ echo "Error, mounting failed, maybe no permisson to mount?" -+fi ---- /dev/null -+++ b/fs/mini_fo/mmap.c -@@ -0,0 +1,637 @@ -+/* -+ * Copyright (c) 1997-2003 Erez Zadok -+ * Copyright (c) 2001-2003 Stony Brook University -+ * -+ * For specific licensing information, see the COPYING file distributed with -+ * this package, or get one from ftp://ftp.filesystems.org/pub/fist/COPYING. -+ * -+ * This Copyright notice must be kept intact and distributed with all -+ * fistgen sources INCLUDING sources generated by fistgen. -+ */ -+/* -+ * Copyright (C) 2004, 2005 Markus Klotzbuecher <mk@creamnet.de> -+ * -+ * 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. -+ */ -+ -+/* -+ * $Id$ -+ */ -+ -+#ifdef HAVE_CONFIG_H -+# include <config.h> -+#endif /* HAVE_CONFIG_H */ -+ -+#include "fist.h" -+#include "mini_fo.h" -+ -+ -+#ifdef FIST_COUNT_WRITES -+/* for counting writes in the middle vs. regular writes */ -+unsigned long count_writes = 0, count_writes_middle = 0; -+#endif /* FIST_COUNT_WRITES */ -+ -+/* forward declaration of commit write and prepare write */ -+STATIC int mini_fo_commit_write(file_t *file, page_t *page, unsigned from, unsigned to); -+STATIC int mini_fo_prepare_write(file_t *file, page_t *page, unsigned from, unsigned to); -+ -+ -+/* -+ * Function for handling creation of holes when lseek-ing past the -+ * end of the file and then writing some data. -+ */ -+int -+mini_fo_fill_zeros(file_t* file, page_t *page, unsigned from) -+{ -+ int err = 0; -+ dentry_t *dentry = file->f_dentry; -+ inode_t *inode = dentry->d_inode; -+ page_t *tmp_page; -+ int index; -+ -+ print_entry_location(); -+ -+ for (index = inode->i_size >> PAGE_CACHE_SHIFT; index < page->index; index++) { -+ tmp_page = mini_fo_get1page(file, index); -+ if (IS_ERR(tmp_page)) { -+ err = PTR_ERR(tmp_page); -+ goto out; -+ } -+ -+ /* -+ * zero out rest of the contents of the page between the appropriate -+ * offsets. -+ */ -+ memset((char*)page_address(tmp_page) + (inode->i_size & ~PAGE_CACHE_MASK), 0, PAGE_CACHE_SIZE - (inode->i_size & ~PAGE_CACHE_MASK)); -+ -+ if (! (err = mini_fo_prepare_write(file, tmp_page, 0, PAGE_CACHE_SIZE))) -+ err = mini_fo_commit_write(file, tmp_page, 0, PAGE_CACHE_SIZE); -+ -+ page_cache_release(tmp_page); -+ if (err < 0) -+ goto out; -+ if (current->need_resched) -+ schedule(); -+ } -+ -+ /* zero out appropriate parts of last page */ -+ -+ /* -+ * if the encoding type is block, then adjust the 'from' (where the -+ * zeroing will start) offset appropriately -+ */ -+ from = from & (~(FIST_ENCODING_BLOCKSIZE - 1)); -+ -+ if ((from - (inode->i_size & ~PAGE_CACHE_MASK)) > 0) { -+ -+ memset((char*)page_address(page) + (inode->i_size & ~PAGE_CACHE_MASK), 0, from - (inode->i_size & ~PAGE_CACHE_MASK)); -+ if (! (err = mini_fo_prepare_write(file, page, 0, PAGE_CACHE_SIZE))) -+ err = mini_fo_commit_write(file, page, 0, PAGE_CACHE_SIZE); -+ -+ if (err < 0) -+ goto out; -+ if (current->need_resched) -+ schedule(); -+ } -+ -+ out: -+ print_exit_status(err); -+ return err; -+} -+ -+ -+ -+STATIC int -+mini_fo_writepage(page_t *page) -+{ -+ int err = -EIO; -+ inode_t *inode; -+ inode_t *hidden_inode; -+ page_t *hidden_page; -+ char *kaddr, *hidden_kaddr; -+ -+ print_entry_location(); -+ -+ inode = page->mapping->host; -+ hidden_inode = itohi(inode); -+ -+ /* -+ * writepage is called when shared mmap'ed files need to write -+ * their pages, while prepare/commit_write are called from the -+ * non-paged write() interface. (However, in 2.3 the two interfaces -+ * share the same cache, while in 2.2 they didn't.) -+ * -+ * So we pretty much have to duplicate much of what commit_write does. -+ */ -+ -+ /* find lower page (returns a locked page) */ -+ hidden_page = grab_cache_page(hidden_inode->i_mapping, page->index); -+ if (!hidden_page) -+ goto out; -+ -+ /* get page address, and encode it */ -+ kaddr = (char *) kmap(page); -+ hidden_kaddr = (char*) kmap(hidden_page); -+ mini_fo_encode_block(kaddr, hidden_kaddr, PAGE_CACHE_SIZE, inode, inode->i_sb, page->index); -+ /* if encode_block could fail, then return error */ -+ kunmap(page); -+ kunmap(hidden_page); -+ -+ /* call lower writepage (expects locked page) */ -+ err = hidden_inode->i_mapping->a_ops->writepage(hidden_page); -+ -+ /* -+ * update mtime and ctime of lower level file system -+ * mini_fo' mtime and ctime are updated by generic_file_write -+ */ -+ hidden_inode->i_mtime = hidden_inode->i_ctime = CURRENT_TIME; -+ -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,1) -+ UnlockPage(hidden_page); /* b/c grab_cache_page locked it */ -+# endif /* kernel older than 2.4.1 */ -+ page_cache_release(hidden_page); /* b/c grab_cache_page increased refcnt */ -+ -+ if (err) -+ ClearPageUptodate(page); -+ else -+ SetPageUptodate(page); -+ out: -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,1) -+ UnlockPage(page); -+# endif /* kernel 2.4.1 and newer */ -+ print_exit_status(err); -+ return err; -+} -+ -+ -+/* -+ * get one page from cache or lower f/s, return error otherwise. -+ * returns unlocked, up-to-date page (if ok), with increased refcnt. -+ */ -+page_t * -+mini_fo_get1page(file_t *file, int index) -+{ -+ page_t *page; -+ dentry_t *dentry; -+ inode_t *inode; -+ struct address_space *mapping; -+ int err; -+ -+ print_entry_location(); -+ -+ dentry = file->f_dentry; /* CPW: Moved below print_entry_location */ -+ inode = dentry->d_inode; -+ mapping = inode->i_mapping; -+ -+ fist_dprint(8, "%s: read page index %d pid %d\n", __FUNCTION__, index, current->pid); -+ if (index < 0) { -+ printk("%s BUG: index=%d\n", __FUNCTION__, index); -+ page = ERR_PTR(-EIO); -+ goto out; -+ } -+ page = read_cache_page(mapping, -+ index, -+ (filler_t *) mapping->a_ops->readpage, -+ (void *) file); -+ if (IS_ERR(page)) -+ goto out; -+ wait_on_page(page); -+ if (!Page_Uptodate(page)) { -+ lock_page(page); -+ err = mapping->a_ops->readpage(file, page); -+ if (err) { -+ page = ERR_PTR(err); -+ goto out; -+ } -+ wait_on_page(page); -+ if (!Page_Uptodate(page)) { -+ page = ERR_PTR(-EIO); -+ goto out; -+ } -+ } -+ -+ out: -+ print_exit_pointer(page); -+ return page; -+} -+ -+ -+/* -+ * get one page from cache or lower f/s, return error otherwise. -+ * similar to get1page, but doesn't guarantee that it will return -+ * an unlocked page. -+ */ -+page_t * -+mini_fo_get1page_cached(file_t *file, int index) -+{ -+ page_t *page; -+ dentry_t *dentry; -+ inode_t *inode; -+ struct address_space *mapping; -+ int err; -+ -+ print_entry_location(); -+ -+ dentry = file->f_dentry; /* CPW: Moved below print_entry_location */ -+ inode = dentry->d_inode; -+ mapping = inode->i_mapping; -+ -+ fist_dprint(8, "%s: read page index %d pid %d\n", __FUNCTION__, index, current->pid); -+ if (index < 0) { -+ printk("%s BUG: index=%d\n", __FUNCTION__, index); -+ page = ERR_PTR(-EIO); -+ goto out; -+ } -+ page = read_cache_page(mapping, -+ index, -+ (filler_t *) mapping->a_ops->readpage, -+ (void *) file); -+ if (IS_ERR(page)) -+ goto out; -+ -+ out: -+ print_exit_pointer(page); -+ return page; -+} -+ -+ -+/* -+ * readpage is called from generic_page_read and the fault handler. -+ * If your file system uses generic_page_read for the read op, it -+ * must implement readpage. -+ * -+ * Readpage expects a locked page, and must unlock it. -+ */ -+STATIC int -+mini_fo_do_readpage(file_t *file, page_t *page) -+{ -+ int err = -EIO; -+ dentry_t *dentry; -+ file_t *hidden_file = NULL; -+ dentry_t *hidden_dentry; -+ inode_t *inode; -+ inode_t *hidden_inode; -+ char *page_data; -+ page_t *hidden_page; -+ char *hidden_page_data; -+ int real_size; -+ -+ print_entry_location(); -+ -+ dentry = file->f_dentry; /* CPW: Moved below print_entry_location */ -+ if (ftopd(file) != NULL) -+ hidden_file = ftohf(file); -+ hidden_dentry = dtohd(dentry); -+ inode = dentry->d_inode; -+ hidden_inode = itohi(inode); -+ -+ fist_dprint(7, "%s: requesting page %d from file %s\n", __FUNCTION__, page->index, dentry->d_name.name); -+ -+ MALLOC_PAGE_POINTERS(hidden_pages, num_hidden_pages); -+ MALLOC_PAGEDATA_POINTERS(hidden_pages_data, num_hidden_pages); -+ FOR_EACH_PAGE -+ CURRENT_HIDDEN_PAGE = NULL; -+ -+ /* find lower page (returns a locked page) */ -+ FOR_EACH_PAGE { -+ fist_dprint(8, "%s: Current page index = %d\n", __FUNCTION__, CURRENT_HIDDEN_PAGEINDEX); -+ CURRENT_HIDDEN_PAGE = read_cache_page(hidden_inode->i_mapping, -+ CURRENT_HIDDEN_PAGEINDEX, -+ (filler_t *) hidden_inode->i_mapping->a_ops->readpage, -+ (void *) hidden_file); -+ if (IS_ERR(CURRENT_HIDDEN_PAGE)) { -+ err = PTR_ERR(CURRENT_HIDDEN_PAGE); -+ CURRENT_HIDDEN_PAGE = NULL; -+ goto out_release; -+ } -+ } -+ -+ /* -+ * wait for the page data to show up -+ * (signaled by readpage as unlocking the page) -+ */ -+ FOR_EACH_PAGE { -+ wait_on_page(CURRENT_HIDDEN_PAGE); -+ if (!Page_Uptodate(CURRENT_HIDDEN_PAGE)) { -+ /* -+ * call readpage() again if we returned from wait_on_page with a -+ * page that's not up-to-date; that can happen when a partial -+ * page has a few buffers which are ok, but not the whole -+ * page. -+ */ -+ lock_page(CURRENT_HIDDEN_PAGE); -+ err = hidden_inode->i_mapping->a_ops->readpage(hidden_file, -+ CURRENT_HIDDEN_PAGE); -+ if (err) { -+ CURRENT_HIDDEN_PAGE = NULL; -+ goto out_release; -+ } -+ wait_on_page(CURRENT_HIDDEN_PAGE); -+ if (!Page_Uptodate(CURRENT_HIDDEN_PAGE)) { -+ err = -EIO; -+ goto out_release; -+ } -+ } -+ } -+ -+ /* map pages, get their addresses */ -+ page_data = (char *) kmap(page); -+ FOR_EACH_PAGE -+ CURRENT_HIDDEN_PAGEDATA = (char *) kmap(CURRENT_HIDDEN_PAGE); -+ -+ /* if decode_block could fail, then return error */ -+ err = 0; -+ real_size = hidden_inode->i_size - (page->index << PAGE_CACHE_SHIFT); -+ if (real_size <= 0) -+ memset(page_data, 0, PAGE_CACHE_SIZE); -+ else if (real_size < PAGE_CACHE_SIZE) { -+ mini_fo_decode_block(hidden_page_data, page_data, real_size, inode, inode->i_sb, page->index); -+ memset(page_data + real_size, 0, PAGE_CACHE_SIZE - real_size); -+ } else -+ mini_fo_decode_block(hidden_page_data, page_data, PAGE_CACHE_SIZE, inode, inode->i_sb, page->index); -+ -+ FOR_EACH_PAGE -+ kunmap(CURRENT_HIDDEN_PAGE); -+ kunmap(page); -+ -+ out_release: -+ FOR_EACH_PAGE -+ if (CURRENT_HIDDEN_PAGE) -+ page_cache_release(CURRENT_HIDDEN_PAGE); /* undo read_cache_page */ -+ -+ FREE_PAGE_POINTERS(hidden_pages, num_hidden_pages); -+ FREE_PAGEDATA_POINTERS(hidden_pages_data, num_hidden_pages); -+ -+ out: -+ if (err == 0) -+ SetPageUptodate(page); -+ else -+ ClearPageUptodate(page); -+ -+ print_exit_status(err); -+ return err; -+} -+ -+ -+STATIC int -+mini_fo_readpage(file_t *file, page_t *page) -+{ -+ int err; -+ print_entry_location(); -+ -+ err = mini_fo_do_readpage(file, page); -+ -+ /* -+ * we have to unlock our page, b/c we _might_ have gotten a locked page. -+ * but we no longer have to wakeup on our page here, b/c UnlockPage does -+ * it -+ */ -+ UnlockPage(page); -+ -+ print_exit_status(err); -+ return err; -+} -+ -+ -+STATIC int -+mini_fo_prepare_write(file_t *file, page_t *page, unsigned from, unsigned to) -+{ -+ int err = 0; -+ -+ print_entry_location(); -+ -+ /* -+ * we call kmap(page) only here, and do the kunmap -+ * and the actual downcalls, including unlockpage and uncache -+ * in commit_write. -+ */ -+ kmap(page); -+ -+ /* fast path for whole page writes */ -+ if (from == 0 && to == PAGE_CACHE_SIZE) -+ goto out; -+ /* read the page to "revalidate" our data */ -+ /* call the helper function which doesn't unlock the page */ -+ if (!Page_Uptodate(page)) -+ err = mini_fo_do_readpage(file, page); -+ -+ out: -+ print_exit_status(err); -+ return err; -+} -+ -+ -+ -+STATIC int -+mini_fo_commit_write(file_t *file, page_t *page, unsigned from, unsigned to) -+{ -+ int err = -ENOMEM; -+ inode_t *inode; -+ inode_t *hidden_inode; -+ page_t *hidden_page; -+ file_t *hidden_file = NULL; -+ loff_t pos; -+ unsigned bytes = to - from; -+ unsigned hidden_from, hidden_to, hidden_bytes; -+ -+ print_entry_location(); -+ -+ inode = page->mapping->host; /* CPW: Moved below print_entry_location */ -+ hidden_inode = itohi(inode); -+ -+ ASSERT(file != NULL); -+ /* -+ * here we have a kmapped page, with data from the user copied -+ * into it. we need to encode_block it, and then call the lower -+ * commit_write. We also need to simulate same behavior of -+ * generic_file_write, and call prepare_write on the lower f/s first. -+ */ -+#ifdef FIST_COUNT_WRITES -+ count_writes++; -+# endif /* FIST_COUNT_WRITES */ -+ -+ /* this is append and/or extend -- we can't have holes so fill them in */ -+ if (page->index > (hidden_inode->i_size >> PAGE_CACHE_SHIFT)) { -+ page_t *tmp_page; -+ int index; -+ for (index = hidden_inode->i_size >> PAGE_CACHE_SHIFT; index < page->index; index++) { -+ tmp_page = mini_fo_get1page(file, index); -+ if (IS_ERR(tmp_page)) { -+ err = PTR_ERR(tmp_page); -+ goto out; -+ } -+ /* zero out the contents of the page at the appropriate offsets */ -+ memset((char*)page_address(tmp_page) + (inode->i_size & ~PAGE_CACHE_MASK), 0, PAGE_CACHE_SIZE - (inode->i_size & ~PAGE_CACHE_MASK)); -+ if (!(err = mini_fo_prepare_write(file, tmp_page, 0, PAGE_CACHE_SIZE))) -+ err = mini_fo_commit_write(file, tmp_page, 0, PAGE_CACHE_SIZE); -+ page_cache_release(tmp_page); -+ if (err < 0) -+ goto out; -+ if (current->need_resched) -+ schedule(); -+ } -+ } -+ -+ if (ftopd(file) != NULL) -+ hidden_file = ftohf(file); -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_lock(&hidden_inode->i_mutex); -+#else -+ down(&hidden_inode->i_sem); -+#endif -+ /* find lower page (returns a locked page) */ -+ hidden_page = grab_cache_page(hidden_inode->i_mapping, page->index); -+ if (!hidden_page) -+ goto out; -+ -+#if FIST_ENCODING_BLOCKSIZE > 1 -+# error encoding_blocksize greater than 1 is not yet supported -+# endif /* FIST_ENCODING_BLOCKSIZE > 1 */ -+ -+ hidden_from = from & (~(FIST_ENCODING_BLOCKSIZE - 1)); -+ hidden_to = ((to + FIST_ENCODING_BLOCKSIZE - 1) & (~(FIST_ENCODING_BLOCKSIZE - 1))); -+ if ((page->index << PAGE_CACHE_SHIFT) + to > hidden_inode->i_size) { -+ -+ /* -+ * if this call to commit_write had introduced holes and the code -+ * for handling holes was invoked, then the beginning of this page -+ * must be zeroed out -+ * zero out bytes from 'size_of_file%pagesize' to 'from'. -+ */ -+ if ((hidden_from - (inode->i_size & ~PAGE_CACHE_MASK)) > 0) -+ memset((char*)page_address(page) + (inode->i_size & ~PAGE_CACHE_MASK), 0, hidden_from - (inode->i_size & ~PAGE_CACHE_MASK)); -+ -+ } -+ hidden_bytes = hidden_to - hidden_from; -+ -+ /* call lower prepare_write */ -+ err = -EINVAL; -+ if (hidden_inode->i_mapping && -+ hidden_inode->i_mapping->a_ops && -+ hidden_inode->i_mapping->a_ops->prepare_write) -+ err = hidden_inode->i_mapping->a_ops->prepare_write(hidden_file, -+ hidden_page, -+ hidden_from, -+ hidden_to); -+ if (err) -+ /* don't leave locked pages behind, esp. on an ENOSPC */ -+ goto out_unlock; -+ -+ fist_dprint(8, "%s: encoding %d bytes\n", __FUNCTION__, hidden_bytes); -+ mini_fo_encode_block((char *) page_address(page) + hidden_from, (char*) page_address(hidden_page) + hidden_from, hidden_bytes, inode, inode->i_sb, page->index); -+ /* if encode_block could fail, then goto unlock and return error */ -+ -+ /* call lower commit_write */ -+ err = hidden_inode->i_mapping->a_ops->commit_write(hidden_file, -+ hidden_page, -+ hidden_from, -+ hidden_to); -+ -+ if (err < 0) -+ goto out_unlock; -+ -+ err = bytes; /* convert error to no. of bytes */ -+ -+ inode->i_blocks = hidden_inode->i_blocks; -+ /* we may have to update i_size */ -+ pos = (page->index << PAGE_CACHE_SHIFT) + to; -+ if (pos > inode->i_size) -+ inode->i_size = pos; -+ -+ /* -+ * update mtime and ctime of lower level file system -+ * mini_fo' mtime and ctime are updated by generic_file_write -+ */ -+ hidden_inode->i_mtime = hidden_inode->i_ctime = CURRENT_TIME; -+ -+ mark_inode_dirty_sync(inode); -+ -+ out_unlock: -+ UnlockPage(hidden_page); -+ page_cache_release(hidden_page); -+ kunmap(page); /* kmap was done in prepare_write */ -+ out: -+ /* we must set our page as up-to-date */ -+ if (err < 0) -+ ClearPageUptodate(page); -+ else -+ SetPageUptodate(page); -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_unlock(&hidden_inode->i_mutex); -+#else -+ up(&hidden_inode->i_sem); -+#endif -+ print_exit_status(err); -+ return err; /* assume all is ok */ -+} -+ -+ -+STATIC int -+mini_fo_bmap(struct address_space *mapping, long block) -+{ -+ int err = 0; -+ inode_t *inode; -+ inode_t *hidden_inode; -+ -+ print_entry_location(); -+ -+ inode = (inode_t *) mapping->host; -+ hidden_inode = itohi(inode); -+ -+ if (hidden_inode->i_mapping->a_ops->bmap) -+ err = hidden_inode->i_mapping->a_ops->bmap(hidden_inode->i_mapping, block); -+ print_exit_location(); -+ return err; -+} -+ -+ -+/* -+ * This function is copied verbatim from mm/filemap.c. -+ * XXX: It should be simply moved to some header file instead -- bug Al about it! -+ */ -+static inline int sync_page(struct page *page) -+{ -+ struct address_space *mapping = page->mapping; -+ -+ if (mapping && mapping->a_ops && mapping->a_ops->sync_page) -+ return mapping->a_ops->sync_page(page); -+ return 0; -+} -+ -+ -+/* -+ * XXX: we may not need this function if not FIST_FILTER_DATA. -+ * FIXME: for FIST_FILTER_SCA, get all lower pages and sync them each. -+ */ -+STATIC int -+mini_fo_sync_page(page_t *page) -+{ -+ int err = 0; -+ inode_t *inode; -+ inode_t *hidden_inode; -+ page_t *hidden_page; -+ -+ print_entry_location(); -+ -+ inode = page->mapping->host; /* CPW: Moved below print_entry_location */ -+ hidden_inode = itohi(inode); -+ -+ /* find lower page (returns a locked page) */ -+ hidden_page = grab_cache_page(hidden_inode->i_mapping, page->index); -+ if (!hidden_page) -+ goto out; -+ -+ err = sync_page(hidden_page); -+ -+ UnlockPage(hidden_page); /* b/c grab_cache_page locked it */ -+ page_cache_release(hidden_page); /* b/c grab_cache_page increased refcnt */ -+ -+ out: -+ print_exit_status(err); -+ return err; -+} ---- /dev/null -+++ b/fs/mini_fo/README -@@ -0,0 +1,163 @@ -+README for the mini_fo overlay file system -+========================================= -+ -+ -+WHAT IS MINI_FO? -+---------------- -+ -+mini_fo is a virtual kernel file system that can make read-only -+file systems writable. This is done by redirecting modifying operations -+to a writeable location called "storage directory", and leaving the -+original data in the "base directory" untouched. When reading, the -+file system merges the modifed and original data so that only the -+newest versions will appear. This occurs transparently to the user, -+who can access the data like on any other read-write file system. -+ -+Base and storage directories may be located on the same or on -+different partitions and may be of different file system types. While -+the storage directory obviously needs to be writable, the base may or -+may not be writable, what doesn't matter as it will no be modified -+anyway. -+ -+ -+WHAT IS GOOD FOR? -+----------------- -+ -+The primary purpose of the mini_fo file system is to allow easy -+software updates to embedded systems, that often store their root -+file system in a read-only flash file system, but there are many -+more as for example sandboxing, or for allowing live-cds to -+permanently store information. -+ -+ -+BUILDING -+-------- -+This should be simple. Adjust the Makefile to point to the correct -+kernel headers you want to build the module for. Then: -+ -+ # make -+ -+should build "mini_fo.o" for a 2.4 kernel or "mini_fo.ko" for a 2.6 -+kernel. -+ -+If you are building the module for you current kernel, you can install -+the module (as root): -+ -+ # make install -+ -+or uninstall with -+ -+ # make uninstall -+ -+ -+USING THE FILE SYSTEM -+-------------------- -+ -+the general mount syntax is: -+ -+ mount -t mini_fo -o base=<base directory>,sto=<storage directory>\ -+ <base directory> <mount point> -+ -+Example: -+ -+You have mounted a cdrom to /mnt/cdrom and want to modifiy some files -+on it: -+ -+load the module (as root) -+ -+ # insmod mini_fo.o for a 2.4 kernel or -+ -+ # insmod mini_fo.ko for a 2.6 kernel -+ -+ -+create a storage dir in tmp and a mountpoint for mini_fo: -+ -+ # mkdir /tmp/sto -+ # mkdir /mnt/mini_fo -+ -+and mount the mini_fo file system: -+ -+ # mount -t mini_fo -o base=/mnt/cdrom,sto=/tmp/sto /mnt/cdrom /mnt/mini_fo -+ -+ -+Now the data stored on the cd can be accessed via the mini_fo -+mountpoint just like any read-write file system, files can be modified -+and deleted, new ones can be created and so on. When done unmount the -+file system: -+ -+ # unmount /mnt/mini_fo -+ -+Note that if the file system is mounted again using the same storage -+file system, of course it will appear in the modified state again. If -+you remount it using an new empty storage directory, it will be -+unmodified. Therefore by executing: -+ -+ # cd /tmp/sto -+ # rm -rf * -+ -+you can nuke all the changes you made to the original file system. But -+ remember NEVER do this while the mini_fo file system is mounted! -+ -+ -+Alternatively you can use the mini_fo-overlay bash script, that -+simplifies managing mini_fo mounts. See TOOLS Section. -+ -+ -+TOOLS -+----- -+ -+mini_fo-merge (experimental): -+ -+This is a bash script that will merge changes contained in the storage -+directory back to the base directory. This allows mini_fo to function -+as a cache file system by overlaying a slow (network, ...) file system -+and using a fast (ramdisk, ...) as storage. When done, changes can be -+merged back to the (slow) base with mini_fo-merge. See "mini_fo-merge -+-h" for details. -+ -+It can be usefull for merging changes back after a successfull test -+(patches, software updates...) -+ -+ -+mini_fo-overlay: -+ -+This bash script simplifies managing one or more mini_fo mounts. For -+overlaying a directory called "basedir1", you can just call: -+ -+ # mini_fo-overlay basedir1 -+ -+This will mount mini_fo with "basedir1" as base, "/tmp/sto-basedir1/" -+as storage to "/mnt/mini_fo-basedir1/". It has more options though, -+type "mini_fo-overlay -h" for details. -+ -+ -+DOCUMENTATION, REPORTING BUGS, GETTING HELP -+------------------------------------------- -+ -+Please visit the mini_fo project page at: -+ -+http://www.denx.de/twiki/bin/view/Know/MiniFOHome -+ -+ -+WARNINGS -+-------- -+ -+Never modify the base or the storage directorys while the mini_fo -+file system is mounted, or you might crash you system. Simply accessing -+and reading should not cause any trouble. -+ -+Exporting a mini_fo mount point via NFS has not been tested, and may -+or may not work. -+ -+Check the RELEASE_NOTES for details on bugs and features. -+ -+ -+ -+Copyright (C) 2004, 2005 Markus Klotzbuecher <mk@creamnet.de> -+ -+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. -+ -+ ---- /dev/null -+++ b/fs/mini_fo/RELEASE_NOTES -@@ -0,0 +1,111 @@ -+Release: mini_fo-0.6.1 (v0-6-1) -+Date: 21.09.2005 -+ -+ -+Changes: -+-------- -+v0-6-1: -+ -+- bugfixes (see ChangeLog) -+ -+- two helper scripts "mini_fo_merge" and "mini_fo_overlay" (see -+ README for details). -+ -+v0-6-0: -+ -+- Support for 2.4 and 2.6 (see Makefile) -+ -+- Partial hard link support (creating works as expected, but already -+ existing links in the base file system will be treated as if they -+ were individual files). -+ -+- Various bugfixes and cleanups. -+ -+ -+v0-6-0-pre1: -+ -+- This is mini_fo-0-6-0-pre1! This release is a complete rewrite of -+ many vital mini_fo parts such as the old whiteout list code which -+ has been replaced by the new META subsystem. -+ -+- Light weight directory renaming implemented. This means if a -+ directory is renamed via the mini_fo filesystem this will no longer -+ result in a complete copy in storage, instead only one empty -+ directory will be created. All base filed contained in the original -+ directory stay there until modified. -+ -+- Special files (creating, renaming, deleting etc.) now working. -+ -+- Many bugfixes and cleanup, mini_fo is now a lot more stable. -+ -+ -+v0-5-10: -+ -+- Final release of the 0-5-* versions. Next will be a complete rewrite -+ of many features. This release contains several bugfixes related to -+ directory renaming. -+ -+ -+v0-5-10-pre6: -+ -+- Lots of cleanup and several bugfixes related to directory deleting -+ -+- Directory renaming suddenly works, what is most likely due to the -+ fact tha that "mv" is smart: if the classic rename doesn't work it -+ will assume that source and target file are on different fs and will -+ copy the directory and try to remove the source directory. Until -+ directory removing wasn't implemented, it would fail to do this and -+ rollback. -+ So, directory renaming works for now, but it doesn't yet do what you -+ would expect from a overlay fs, so use with care. -+ -+ -+v0-5-10-pre5: -+ -+- implemented directory deleting -+- made parsing of mount options more stable -+- New format of mount options! (See README) -+- I can't reproduce the unknown panic with 2.4.25 anymore, so I'll -+ happily assume it never existed! -+ -+ -+Implemented features: -+--------------------- -+ -+- creating hard links (see BUGS on already existing hard links) -+- lightweight directory renaming -+- renaming device files, pipes, sockets, etc. -+- creating, renaming, deleting of special files -+- deleting directorys -+- general directory reading (simple "ls" ) -+- creating files in existing directorys -+- creating directorys -+- renaming files. -+- reading and writing files (involves opening) -+- appending to files (creates copy in storage) -+- deleting files -+- llseek works too, what allows editors to work -+- persistency (a deleted file stay deleted over remounts) -+- use of symbolic links -+- creating of device files -+ -+ -+Not (yet) implemented features: -+------------------------------- -+ -+- full hard link support. -+ -+ -+ -+BUGS: -+----- -+ -+Hard links in the base file system will be treated as individual -+files, not as links to one inode. -+ -+The main problem with hard links isn't allowing to create them, but -+their pure existence. If you modify a base hard link, the changes made -+will only show up on this link, the other link will remain in the -+original state. I hope to fix this someday. Please note that this does -+not effect the special hard links '.' and '..', that are handled -+seperately by the lower fs. ---- /dev/null -+++ b/fs/mini_fo/state.c -@@ -0,0 +1,620 @@ -+/* -+ * Copyright (C) 2005 Markus Klotzbuecher <mk@creamnet.de> -+ * -+ * 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. -+ */ -+ -+#ifdef HAVE_CONFIG_H -+# include <config.h> -+#endif /* HAVE_CONFIG_H */ -+ -+#include "fist.h" -+#include "mini_fo.h" -+ -+ -+/* create the storage file, setup new states */ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+int create_sto_reg_file(dentry_t *dentry, int mode, struct nameidata *nd) -+#else -+int create_sto_reg_file(dentry_t *dentry, int mode) -+#endif -+{ -+ int err = 0; -+ inode_t *dir; -+ dentry_t *hidden_sto_dentry; -+ dentry_t *hidden_sto_dir_dentry; -+ -+ if(exists_in_storage(dentry)) { -+ printk(KERN_CRIT "mini_fo: create_sto_file: wrong type or state.\n"); -+ err = -EINVAL; -+ goto out; -+ } -+ err = get_neg_sto_dentry(dentry); -+ -+ if (err) { -+ printk(KERN_CRIT "mini_fo: create_sto_file: ERROR getting neg. sto dentry.\n"); -+ goto out; -+ } -+ -+ dir = dentry->d_parent->d_inode; -+ hidden_sto_dentry = dtohd2(dentry); -+ -+ /* lock parent */ -+ hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent); -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex); -+#else -+ down(&hidden_sto_dir_dentry->d_inode->i_sem); -+#endif -+ -+ err = PTR_ERR(hidden_sto_dir_dentry); -+ if (IS_ERR(hidden_sto_dir_dentry)) -+ goto out; -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+ err = vfs_create(hidden_sto_dir_dentry->d_inode, -+ hidden_sto_dentry, -+ mode, nd); -+#else -+ err = vfs_create(hidden_sto_dir_dentry->d_inode, -+ hidden_sto_dentry, -+ mode); -+#endif -+ if(err) { -+ printk(KERN_CRIT "mini_fo: create_sto_file: ERROR creating sto file.\n"); -+ goto out_lock; -+ } -+ -+ if(!dtohd2(dentry)->d_inode) { -+ printk(KERN_CRIT "mini_fo: create_sto_file: ERROR creating sto file [2].\n"); -+ err = -EINVAL; -+ goto out_lock; -+ } -+ -+ /* interpose the new inode */ -+ if(dtost(dentry) == DELETED) { -+ dtost(dentry) = DEL_REWRITTEN; -+ err = mini_fo_tri_interpose(NULL, hidden_sto_dentry, dentry, dir->i_sb, 0); -+ if(err) -+ goto out_lock; -+ } -+ else if(dtost(dentry) == NON_EXISTANT) { -+ dtost(dentry) = CREATED; -+ err = mini_fo_tri_interpose(dtohd(dentry), hidden_sto_dentry, dentry, dir->i_sb, 0); -+ if(err) -+ goto out_lock; -+ } -+ else if(dtost(dentry) == UNMODIFIED) { -+ dtost(dentry) = MODIFIED; -+ /* interpose on new inode */ -+ if(itohi2(dentry->d_inode) != NULL) { -+ printk(KERN_CRIT "mini_fo: create_sto_file: invalid inode detected.\n"); -+ err = -EINVAL; -+ goto out_lock; -+ } -+ itohi2(dentry->d_inode) = igrab(dtohd2(dentry)->d_inode); -+ } -+ fist_copy_attr_timesizes(dentry->d_parent->d_inode, -+ hidden_sto_dir_dentry->d_inode); -+ -+ out_lock: -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex); -+#else -+ up(&hidden_sto_dir_dentry->d_inode->i_sem); -+#endif -+ dput(hidden_sto_dir_dentry); -+ out: -+ return err; -+} -+ -+/* create the sto dir, setup states */ -+int create_sto_dir(dentry_t *dentry, int mode) -+{ -+ int err = 0; -+ inode_t *dir; -+ dentry_t *hidden_sto_dentry; -+ dentry_t *hidden_sto_dir_dentry; -+ -+ /* had to take the "!S_ISDIR(mode))" check out, because it failed */ -+ if(exists_in_storage(dentry)) { -+ printk(KERN_CRIT "mini_fo: create_sto_dir: wrong type or state.\\ -+n"); -+ err = -EINVAL; -+ goto out; -+ } -+ -+ err = get_neg_sto_dentry(dentry); -+ if(err) { -+ err = -EINVAL; -+ goto out; -+ } -+ -+ dir = dentry->d_parent->d_inode; -+ hidden_sto_dentry = dtohd2(dentry); -+ -+ /* was: hidden_sto_dir_dentry = lock_parent(hidden_sto_dentry); */ -+ hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent); -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex); -+#else -+ down(&hidden_sto_dir_dentry->d_inode->i_sem); -+#endif -+ -+ err = PTR_ERR(hidden_sto_dir_dentry); -+ if (IS_ERR(hidden_sto_dir_dentry)) -+ goto out; -+ -+ err = vfs_mkdir(hidden_sto_dir_dentry->d_inode, -+ hidden_sto_dentry, -+ mode); -+ if(err) { -+ printk(KERN_CRIT "mini_fo: create_sto_dir: ERROR creating sto dir.\n"); -+ goto out_lock; -+ } -+ -+ if(!dtohd2(dentry)->d_inode) { -+ printk(KERN_CRIT "mini_fo: create_sto_dir: ERROR creating sto dir [2].\n"); -+ err = -EINVAL; -+ goto out_lock; -+ } -+ -+ /* interpose the new inode */ -+ if(dtost(dentry) == DELETED) { -+ dtost(dentry) = DEL_REWRITTEN; -+ err = mini_fo_tri_interpose(NULL, hidden_sto_dentry, dentry, dir->i_sb, 0); -+ if(err) -+ goto out_lock; -+ } -+ else if(dtopd(dentry)->state == NON_EXISTANT) { -+ dtopd(dentry)->state = CREATED; -+ err = mini_fo_tri_interpose(dtohd(dentry), hidden_sto_dentry, dentry, dir->i_sb, 0); -+ if(err) -+ goto out_lock; -+ } -+ else if(dtopd(dentry)->state == UNMODIFIED) { -+ dtopd(dentry)->state = MODIFIED; -+ /* interpose on new inode */ -+ if(itohi2(dentry->d_inode) != NULL) { -+ printk(KERN_CRIT "mini_fo: create_sto_dir: ERROR, invalid inode detected.\n"); -+ err = -EINVAL; -+ goto out_lock; -+ } -+ itohi2(dentry->d_inode) = igrab(dtohd2(dentry)->d_inode); -+ } -+ -+ fist_copy_attr_timesizes(dir, hidden_sto_dir_dentry->d_inode); -+ -+ /* initalize the wol list */ -+ itopd(dentry->d_inode)->deleted_list_size = -1; -+ itopd(dentry->d_inode)->renamed_list_size = -1; -+ meta_build_lists(dentry); -+ -+ -+ out_lock: -+ /* was: unlock_dir(hidden_sto_dir_dentry); */ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex); -+#else -+ up(&hidden_sto_dir_dentry->d_inode->i_sem); -+#endif -+ dput(hidden_sto_dir_dentry); -+ out: -+ return err; -+} -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+int create_sto_nod(dentry_t *dentry, int mode, dev_t dev) -+#else -+int create_sto_nod(dentry_t *dentry, int mode, int dev) -+#endif -+{ -+ int err = 0; -+ inode_t *dir; -+ dentry_t *hidden_sto_dentry; -+ dentry_t *hidden_sto_dir_dentry; -+ -+ if(exists_in_storage(dentry)) { -+ err = -EEXIST; -+ goto out; -+ } -+ err = get_neg_sto_dentry(dentry); -+ -+ if (err) { -+ printk(KERN_CRIT "mini_fo: create_sto_nod: ERROR getting neg. sto dentry.\n"); -+ goto out; -+ } -+ -+ dir = dentry->d_parent->d_inode; -+ hidden_sto_dentry = dtohd2(dentry); -+ -+ /* lock parent */ -+ hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent); -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex); -+#else -+ down(&hidden_sto_dir_dentry->d_inode->i_sem); -+#endif -+ -+ err = PTR_ERR(hidden_sto_dir_dentry); -+ if (IS_ERR(hidden_sto_dir_dentry)) -+ goto out; -+ -+ err = vfs_mknod(hidden_sto_dir_dentry->d_inode, hidden_sto_dentry, mode, dev); -+ if(err) -+ goto out_lock; -+ -+ if(!dtohd2(dentry)->d_inode) { -+ printk(KERN_CRIT "mini_fo: create_sto_nod: creating storage inode failed [1].\n"); -+ err = -EINVAL; /* return something indicating failure */ -+ goto out_lock; -+ } -+ -+ /* interpose the new inode */ -+ if(dtost(dentry) == DELETED) { -+ dtost(dentry) = DEL_REWRITTEN; -+ err = mini_fo_tri_interpose(NULL, hidden_sto_dentry, dentry, dir->i_sb, 0); -+ if(err) -+ goto out_lock; -+ } -+ else if(dtost(dentry) == NON_EXISTANT) { -+ dtost(dentry) = CREATED; -+ err = mini_fo_tri_interpose(dtohd(dentry), hidden_sto_dentry, dentry, dir->i_sb, 0); -+ if(err) -+ goto out_lock; -+ } -+ else if(dtost(dentry) == UNMODIFIED) { -+ dtost(dentry) = MODIFIED; -+ /* interpose on new inode */ -+ if(itohi2(dentry->d_inode) != NULL) { -+ printk(KERN_CRIT "mini_fo: create_sto_nod: error, invalid inode detected.\n"); -+ err = -EINVAL; -+ goto out_lock; -+ } -+ itohi2(dentry->d_inode) = igrab(dtohd2(dentry)->d_inode); -+ } -+ -+ fist_copy_attr_timesizes(dir, hidden_sto_dir_dentry->d_inode); -+ -+ out_lock: -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex); -+#else -+ up(&hidden_sto_dir_dentry->d_inode->i_sem); -+#endif -+ dput(hidden_sto_dir_dentry); -+ out: -+ return err; -+} -+ -+ -+/* unimplemented (and possibly not usefull): -+ -+ nondir-del_to_del_rew -+ nondir-non_exist_to_creat -+ -+ dir-unmod_to_del -+ dir-mod_to_del -+ dir-creat_to_del -+ dir-del_rew_to_del -+ dir-del_to_del_rew -+ dir-non_exist_to_creat -+*/ -+ -+ -+/* bring a file of any type from state UNMODIFIED to MODIFIED */ -+int nondir_unmod_to_mod(dentry_t *dentry, int cp_flag) -+{ -+ int err = 0; -+ struct vfsmount *tgt_mnt; -+ struct vfsmount *src_mnt; -+ dentry_t *tgt_dentry; -+ dentry_t *src_dentry; -+ dentry_t *hidden_sto_dentry; -+ dentry_t *hidden_sto_dir_dentry; -+ -+ check_mini_fo_dentry(dentry); -+ -+ if((dtost(dentry) != UNMODIFIED) || -+ S_ISDIR(dentry->d_inode->i_mode)) { -+ printk(KERN_CRIT "mini_fo: nondir_unmod_to_mod: \ -+ wrong type or state.\n"); -+ err = -1; -+ goto out; -+ } -+ err = get_neg_sto_dentry(dentry); -+ -+ if (err) { -+ printk(KERN_CRIT "mini_fo: nondir_unmod_to_mod: \ -+ ERROR getting neg. sto dentry.\n"); -+ goto out; -+ } -+ -+ /* create sto file */ -+ hidden_sto_dentry = dtohd2(dentry); -+ -+ /* lock parent */ -+ hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent); -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex); -+#else -+ down(&hidden_sto_dir_dentry->d_inode->i_sem); -+#endif -+ -+ err = PTR_ERR(hidden_sto_dir_dentry); -+ if (IS_ERR(hidden_sto_dir_dentry)) -+ goto out; -+ -+ /* handle different types of nondirs */ -+ if(S_ISCHR(dentry->d_inode->i_mode) || -+ S_ISBLK(dentry->d_inode->i_mode)) { -+ err = vfs_mknod(hidden_sto_dir_dentry->d_inode, -+ hidden_sto_dentry, -+ dtohd(dentry)->d_inode->i_mode, -+ dtohd(dentry)->d_inode->i_rdev); -+ } -+ -+ else if(S_ISREG(dentry->d_inode->i_mode)) { -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+ err = vfs_create(hidden_sto_dir_dentry->d_inode, -+ hidden_sto_dentry, -+ dtohd(dentry)->d_inode->i_mode, NULL); -+#else -+ err = vfs_create(hidden_sto_dir_dentry->d_inode, -+ hidden_sto_dentry, -+ dtohd(dentry)->d_inode->i_mode); -+#endif -+ } -+ if(err) { -+ printk(KERN_CRIT "mini_fo: nondir_unmod_to_mod: \ -+ ERROR creating sto file.\n"); -+ goto out_lock; -+ } -+ -+ /* interpose on new inode */ -+ if(itohi2(dentry->d_inode) != NULL) { -+ printk(KERN_CRIT "mini_fo: nondir_unmod_to_mod: \ -+ ERROR, invalid inode detected.\n"); -+ err = -EINVAL; -+ goto out_lock; -+ } -+ -+ itohi2(dentry->d_inode) = igrab(dtohd2(dentry)->d_inode); -+ -+ fist_copy_attr_timesizes(dentry->d_parent->d_inode, -+ hidden_sto_dir_dentry->d_inode); -+ dtost(dentry) = MODIFIED; -+ -+ /* copy contents if regular file and cp_flag = 1 */ -+ if((cp_flag == 1) && S_ISREG(dentry->d_inode->i_mode)) { -+ -+ /* unlock first */ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex); -+#else -+ up(&hidden_sto_dir_dentry->d_inode->i_sem); -+#endif -+ -+ dput(hidden_sto_dir_dentry); -+ -+ tgt_dentry = dtohd2(dentry); -+ tgt_mnt = stopd(dentry->d_inode->i_sb)->hidden_mnt2; -+ src_dentry = dtohd(dentry); -+ src_mnt = stopd(dentry->d_inode->i_sb)->hidden_mnt; -+ -+ err = mini_fo_cp_cont(tgt_dentry, tgt_mnt, -+ src_dentry, src_mnt); -+ if(err) { -+ printk(KERN_CRIT "mini_fo: nondir_unmod_to_mod: \ -+ ERROR copying contents.\n"); -+ } -+ goto out; -+ } -+ -+ out_lock: -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex); -+#else -+ up(&hidden_sto_dir_dentry->d_inode->i_sem); -+#endif -+ dput(hidden_sto_dir_dentry); -+ out: -+ return err; -+} -+ -+/* this function is currently identical to nondir_creat_to_del */ -+int nondir_del_rew_to_del(dentry_t *dentry) -+{ -+ return nondir_creat_to_del(dentry); -+} -+ -+int nondir_creat_to_del(dentry_t *dentry) -+{ -+ int err = 0; -+ -+ inode_t *hidden_sto_dir_inode; -+ dentry_t *hidden_sto_dir_dentry; -+ dentry_t *hidden_sto_dentry; -+ -+ check_mini_fo_dentry(dentry); -+ -+ /* for now this function serves for both state DEL_REWRITTEN and -+ * CREATED */ -+ if(!(dtost(dentry) == CREATED || (dtost(dentry) == DEL_REWRITTEN)) || -+ S_ISDIR(dentry->d_inode->i_mode)) { -+ printk(KERN_CRIT "mini_fo: nondir_mod_to_del/del_rew_to_del: \ -+ wrong type or state.\n"); -+ err = -1; -+ goto out; -+ } -+ -+ hidden_sto_dir_inode = itohi2(dentry->d_parent->d_inode); -+ hidden_sto_dentry = dtohd2(dentry); -+ -+ /* was: hidden_sto_dir_dentry = lock_parent(hidden_sto_dentry);*/ -+ hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent); -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex); -+#else -+ down(&hidden_sto_dir_dentry->d_inode->i_sem); -+#endif -+ -+ /* avoid destroying the hidden inode if the file is in use */ -+ dget(hidden_sto_dentry); -+ err = vfs_unlink(hidden_sto_dir_inode, hidden_sto_dentry); -+ dput(hidden_sto_dentry); -+ if(!err) -+ d_delete(hidden_sto_dentry); -+ -+ /* propagate number of hard-links */ -+ dentry->d_inode->i_nlink = itohi2(dentry->d_inode)->i_nlink; -+ -+ dtost(dentry) = NON_EXISTANT; -+ -+ /* was: unlock_dir(hidden_sto_dir_dentry); */ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex); -+#else -+ up(&hidden_sto_dir_dentry->d_inode->i_sem); -+#endif -+ dput(hidden_sto_dir_dentry); -+ -+ out: -+ return err; -+} -+ -+int nondir_mod_to_del(dentry_t *dentry) -+{ -+ int err; -+ dentry_t *hidden_sto_dentry; -+ inode_t *hidden_sto_dir_inode; -+ dentry_t *hidden_sto_dir_dentry; -+ -+ check_mini_fo_dentry(dentry); -+ -+ if(dtost(dentry) != MODIFIED || -+ S_ISDIR(dentry->d_inode->i_mode)) { -+ printk(KERN_CRIT "mini_fo: nondir_mod_to_del: \ -+ wrong type or state.\n"); -+ err = -1; -+ goto out; -+ } -+ -+ hidden_sto_dir_inode = itohi2(dentry->d_parent->d_inode); -+ hidden_sto_dentry = dtohd2(dentry); -+ -+ /* was hidden_sto_dir_dentry = lock_parent(hidden_sto_dentry); */ -+ hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent); -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex); -+#else -+ down(&hidden_sto_dir_dentry->d_inode->i_sem); -+#endif -+ -+ /* avoid destroying the hidden inode if the file is in use */ -+ dget(hidden_sto_dentry); -+ err = vfs_unlink(hidden_sto_dir_inode, hidden_sto_dentry); -+ dput(hidden_sto_dentry); -+ if(!err) -+ d_delete(hidden_sto_dentry); -+ -+ /* propagate number of hard-links */ -+ dentry->d_inode->i_nlink = itohi2(dentry->d_inode)->i_nlink; -+ -+ /* dput base dentry, this will relase the inode and free the -+ * dentry, as we will never need it again. */ -+ dput(dtohd(dentry)); -+ dtohd(dentry) = NULL; -+ dtost(dentry) = DELETED; -+ -+ /* add deleted file to META-file */ -+ meta_add_d_entry(dentry->d_parent, -+ dentry->d_name.name, -+ dentry->d_name.len); -+ -+ /* was: unlock_dir(hidden_sto_dir_dentry); */ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -+ mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex); -+#else -+ up(&hidden_sto_dir_dentry->d_inode->i_sem); -+#endif -+ dput(hidden_sto_dir_dentry); -+ -+ out: -+ return err; -+} -+ -+int nondir_unmod_to_del(dentry_t *dentry) -+{ -+ int err = 0; -+ -+ check_mini_fo_dentry(dentry); -+ -+ if(dtost(dentry) != UNMODIFIED || -+ S_ISDIR(dentry->d_inode->i_mode)) { -+ printk(KERN_CRIT "mini_fo: nondir_unmod_to_del: \ -+ wrong type or state.\n"); -+ err = -1; -+ goto out; -+ } -+ -+ /* next we have to get a negative dentry for the storage file */ -+ err = get_neg_sto_dentry(dentry); -+ -+ if(err) -+ goto out; -+ -+ /* add deleted file to META lists */ -+ err = meta_add_d_entry(dentry->d_parent, -+ dentry->d_name.name, -+ dentry->d_name.len); -+ -+ if(err) -+ goto out; -+ -+ /* dput base dentry, this will relase the inode and free the -+ * dentry, as we will never need it again. */ -+ dput(dtohd(dentry)); -+ dtohd(dentry) = NULL; -+ dtost(dentry) = DELETED; -+ -+ out: -+ return err; -+} -+ -+/* bring a dir from state UNMODIFIED to MODIFIED */ -+int dir_unmod_to_mod(dentry_t *dentry) -+{ -+ int err; -+ -+ check_mini_fo_dentry(dentry); -+ -+ if(dtost(dentry) != UNMODIFIED || -+ !S_ISDIR(dentry->d_inode->i_mode)) { -+ printk(KERN_CRIT "mini_fo: dir_unmod_to_mod: \ -+ wrong type or state.\n"); -+ err = -1; -+ goto out; -+ } -+ -+ /* this creates our dir incl. sto. structure */ -+ err = build_sto_structure(dentry->d_parent, dentry); -+ if(err) { -+ printk(KERN_CRIT "mini_fo: dir_unmod_to_mod: \ -+ build_sto_structure failed.\n"); -+ goto out; -+ } -+ out: -+ return err; -+} -+ ---- /dev/null -+++ b/fs/mini_fo/super.c -@@ -0,0 +1,259 @@ -+/* -+ * Copyright (c) 1997-2003 Erez Zadok -+ * Copyright (c) 2001-2003 Stony Brook University -+ * -+ * For specific licensing information, see the COPYING file distributed with -+ * this package, or get one from ftp://ftp.filesystems.org/pub/fist/COPYING. -+ * -+ * This Copyright notice must be kept intact and distributed with all -+ * fistgen sources INCLUDING sources generated by fistgen. -+ */ -+/* -+ * Copyright (C) 2004, 2005 Markus Klotzbuecher <mk@creamnet.de> -+ * -+ * 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. -+ */ -+ -+/* -+ * $Id$ -+ */ -+ -+#ifdef HAVE_CONFIG_H -+# include <config.h> -+#endif -+ -+#include "fist.h" -+#include "mini_fo.h" -+ -+ -+STATIC void -+mini_fo_read_inode(inode_t *inode) -+{ -+ static struct address_space_operations mini_fo_empty_aops; -+ -+ __itopd(inode) = kmalloc(sizeof(struct mini_fo_inode_info), GFP_KERNEL); -+ if (!itopd(inode)) { -+ printk("<0>%s:%s:%d: No kernel memory!\n", __FILE__, __FUNCTION__, __LINE__); -+ ASSERT(NULL); -+ } -+ itohi(inode) = NULL; -+ itohi2(inode) = NULL; -+ -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+ inode->i_version++; -+#else -+ inode->i_version = ++event; /* increment inode version */ -+#endif -+ inode->i_op = &mini_fo_main_iops; -+ inode->i_fop = &mini_fo_main_fops; -+#if 0 -+ /* -+ * XXX: To export a file system via NFS, it has to have the -+ * FS_REQUIRES_DEV flag, so turn it on. But should we inherit it from -+ * the lower file system, or can we allow our file system to be exported -+ * even if the lower one cannot be natively exported. -+ */ -+ inode->i_sb->s_type->fs_flags |= FS_REQUIRES_DEV; -+ /* -+ * OK, the above was a hack, which is now turned off because it may -+ * cause a panic/oops on some systems. The correct way to export a -+ * "nodev" filesystem is via using nfs-utils > 1.0 and the "fsid=" export -+ * parameter, which requires 2.4.20 or later. -+ */ -+#endif -+ /* I don't think ->a_ops is ever allowed to be NULL */ -+ inode->i_mapping->a_ops = &mini_fo_empty_aops; -+} -+ -+ -+#if defined(FIST_DEBUG) || defined(FIST_FILTER_SCA) -+/* -+ * No need to call write_inode() on the lower inode, as it -+ * will have been marked 'dirty' anyway. But we might need -+ * to write some of our own stuff to disk. -+ */ -+STATIC void -+mini_fo_write_inode(inode_t *inode, int sync) -+{ -+ print_entry_location(); -+ print_exit_location(); -+} -+#endif /* defined(FIST_DEBUG) || defined(FIST_FILTER_SCA) */ -+ -+ -+STATIC void -+mini_fo_put_inode(inode_t *inode) -+{ -+ /* -+ * This is really funky stuff: -+ * Basically, if i_count == 1, iput will then decrement it and this inode will be destroyed. -+ * It is currently holding a reference to the hidden inode. -+ * Therefore, it needs to release that reference by calling iput on the hidden inode. -+ * iput() _will_ do it for us (by calling our clear_inode), but _only_ if i_nlink == 0. -+ * The problem is, NFS keeps i_nlink == 1 for silly_rename'd files. -+ * So we must for our i_nlink to 0 here to trick iput() into calling our clear_inode. -+ */ -+ if (atomic_read(&inode->i_count) == 1) -+ inode->i_nlink = 0; -+} -+ -+ -+#if defined(FIST_DEBUG) || defined(FIST_FILTER_SCA) -+/* -+ * we now define delete_inode, because there are two VFS paths that may -+ * destroy an inode: one of them calls clear inode before doing everything -+ * else that's needed, and the other is fine. This way we truncate the inode -+ * size (and its pages) and then clear our own inode, which will do an iput -+ * on our and the lower inode. -+ */ -+STATIC void -+mini_fo_delete_inode(inode_t *inode) -+{ -+ print_entry_location(); -+ -+ fist_checkinode(inode, "mini_fo_delete_inode IN"); -+ inode->i_size = 0; /* every f/s seems to do that */ -+ clear_inode(inode); -+ -+ print_exit_location(); -+} -+#endif /* defined(FIST_DEBUG) || defined(FIST_FILTER_SCA) */ -+ -+ -+/* final actions when unmounting a file system */ -+STATIC void -+mini_fo_put_super(super_block_t *sb) -+{ -+ if (stopd(sb)) { -+ mntput(stopd(sb)->hidden_mnt); -+ mntput(stopd(sb)->hidden_mnt2); -+ -+ /* mk: no! dput(stopd(sb)->base_dir_dentry); -+ dput(stopd(sb)->storage_dir_dentry); */ -+ -+ kfree(stopd(sb)); -+ __stopd(sb) = NULL; -+ } -+} -+ -+ -+#ifdef NOT_NEEDED -+/* -+ * This is called in do_umount before put_super. -+ * The superblock lock is not held yet. -+ * We probably do not need to define this or call write_super -+ * on the hidden_sb, because sync_supers() will get to hidden_sb -+ * sooner or later. But it is also called from file_fsync()... -+ */ -+STATIC void -+mini_fo_write_super(super_block_t *sb) -+{ -+ return; -+} -+#endif /* NOT_NEEDED */ -+ -+ -+STATIC int -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+mini_fo_statfs(super_block_t *sb, struct kstatfs *buf) -+#else -+mini_fo_statfs(super_block_t *sb, struct statfs *buf) -+#endif -+{ -+ int err = 0; -+ super_block_t *hidden_sb; -+ -+ hidden_sb = stohs(sb); -+ err = vfs_statfs(hidden_sb, buf); -+ -+ return err; -+} -+ -+ -+/* -+ * XXX: not implemented. This is not allowed yet. -+ * Should we call this on the hidden_sb? Probably not. -+ */ -+STATIC int -+mini_fo_remount_fs(super_block_t *sb, int *flags, char *data) -+{ -+ //printk(KERN_CRIT "mini_fo_remount_fs: WARNING, this function is umimplemented.\n"); -+ return -ENOSYS; -+} -+ -+ -+/* -+ * Called by iput() when the inode reference count reached zero -+ * and the inode is not hashed anywhere. Used to clear anything -+ * that needs to be, before the inode is completely destroyed and put -+ * on the inode free list. -+ */ -+STATIC void -+mini_fo_clear_inode(inode_t *inode) -+{ -+ /* -+ * Decrement a reference to a hidden_inode, which was incremented -+ * by our read_inode when it was created initially. -+ */ -+ -+ /* release the wol_list */ -+ if(S_ISDIR(inode->i_mode)) { -+ __meta_put_lists(inode); -+ } -+ -+ /* mk: fan out fun */ -+ if(itohi(inode)) -+ iput(itohi(inode)); -+ if(itohi2(inode)) -+ iput(itohi2(inode)); -+ -+ // XXX: why this assertion fails? -+ // because it doesn't like us -+ // ASSERT((inode->i_state & I_DIRTY) == 0); -+ kfree(itopd(inode)); -+ __itopd(inode) = NULL; -+} -+ -+ -+/* -+ * Called in do_umount() if the MNT_FORCE flag was used and this -+ * function is defined. See comment in linux/fs/super.c:do_umount(). -+ * Used only in nfs, to kill any pending RPC tasks, so that subsequent -+ * code can actually succeed and won't leave tasks that need handling. -+ * -+ * PS. I wonder if this is somehow useful to undo damage that was -+ * left in the kernel after a user level file server (such as amd) -+ * dies. -+ */ -+STATIC void -+mini_fo_umount_begin(super_block_t *sb) -+{ -+ super_block_t *hidden_sb; -+ -+ hidden_sb = stohs(sb); -+ -+ if (hidden_sb->s_op->umount_begin) -+ hidden_sb->s_op->umount_begin(hidden_sb); -+ -+} -+ -+ -+struct super_operations mini_fo_sops = -+{ -+ read_inode: mini_fo_read_inode, -+#if defined(FIST_DEBUG) || defined(FIST_FILTER_SCA) -+ write_inode: mini_fo_write_inode, -+#endif /* defined(FIST_DEBUG) || defined(FIST_FILTER_SCA) */ -+ put_inode: mini_fo_put_inode, -+#if defined(FIST_DEBUG) || defined(FIST_FILTER_SCA) -+ delete_inode: mini_fo_delete_inode, -+#endif /* defined(FIST_DEBUG) || defined(FIST_FILTER_SCA) */ -+ put_super: mini_fo_put_super, -+ statfs: mini_fo_statfs, -+ remount_fs: mini_fo_remount_fs, -+ clear_inode: mini_fo_clear_inode, -+ umount_begin: mini_fo_umount_begin, -+}; diff --git a/target/linux/generic-2.4/patches/601-netfilter_ipp2p_0.8.1rc1.patch b/target/linux/generic-2.4/patches/601-netfilter_ipp2p_0.8.1rc1.patch deleted file mode 100644 index ed7601e..0000000 --- a/target/linux/generic-2.4/patches/601-netfilter_ipp2p_0.8.1rc1.patch +++ /dev/null @@ -1,925 +0,0 @@ ---- /dev/null -+++ b/include/linux/netfilter_ipv4/ipt_ipp2p.h -@@ -0,0 +1,31 @@ -+#ifndef __IPT_IPP2P_H -+#define __IPT_IPP2P_H -+#define IPP2P_VERSION "0.8.1_rc1" -+ -+struct ipt_p2p_info { -+ int cmd; -+ int debug; -+}; -+ -+#endif //__IPT_IPP2P_H -+ -+#define SHORT_HAND_IPP2P 1 /* --ipp2p switch*/ -+//#define SHORT_HAND_DATA 4 /* --ipp2p-data switch*/ -+#define SHORT_HAND_NONE 5 /* no short hand*/ -+ -+#define IPP2P_EDK (1 << 1) -+#define IPP2P_DATA_KAZAA (1 << 2) -+#define IPP2P_DATA_EDK (1 << 3) -+#define IPP2P_DATA_DC (1 << 4) -+#define IPP2P_DC (1 << 5) -+#define IPP2P_DATA_GNU (1 << 6) -+#define IPP2P_GNU (1 << 7) -+#define IPP2P_KAZAA (1 << 8) -+#define IPP2P_BIT (1 << 9) -+#define IPP2P_APPLE (1 << 10) -+#define IPP2P_SOUL (1 << 11) -+#define IPP2P_WINMX (1 << 12) -+#define IPP2P_ARES (1 << 13) -+#define IPP2P_MUTE (1 << 14) -+#define IPP2P_WASTE (1 << 15) -+#define IPP2P_XDCC (1 << 16) ---- a/net/ipv4/netfilter/Config.in -+++ b/net/ipv4/netfilter/Config.in -@@ -26,6 +26,7 @@ if [ "$CONFIG_IP_NF_IPTABLES" != "n" ]; - dep_tristate ' TOS match support' CONFIG_IP_NF_MATCH_TOS $CONFIG_IP_NF_IPTABLES - dep_tristate ' recent match support' CONFIG_IP_NF_MATCH_RECENT $CONFIG_IP_NF_IPTABLES - dep_tristate ' ECN match support' CONFIG_IP_NF_MATCH_ECN $CONFIG_IP_NF_IPTABLES -+ dep_tristate ' peer to peer traffic match support' CONFIG_IP_NF_MATCH_IPP2P $CONFIG_IP_NF_IPTABLES - - dep_tristate ' DSCP match support' CONFIG_IP_NF_MATCH_DSCP $CONFIG_IP_NF_IPTABLES - ---- a/net/ipv4/netfilter/Makefile -+++ b/net/ipv4/netfilter/Makefile -@@ -67,6 +67,7 @@ obj-$(CONFIG_IP_NF_MATCH_HELPER) += ipt_ - obj-$(CONFIG_IP_NF_MATCH_LIMIT) += ipt_limit.o - obj-$(CONFIG_IP_NF_MATCH_MARK) += ipt_mark.o - obj-$(CONFIG_IP_NF_MATCH_MAC) += ipt_mac.o -+obj-$(CONFIG_IP_NF_MATCH_IPP2P) += ipt_ipp2p.o - - obj-$(CONFIG_IP_NF_MATCH_PKTTYPE) += ipt_pkttype.o - obj-$(CONFIG_IP_NF_MATCH_MULTIPORT) += ipt_multiport.o ---- /dev/null -+++ b/net/ipv4/netfilter/ipt_ipp2p.c -@@ -0,0 +1,868 @@ -+#if defined(MODVERSIONS) -+#include <linux/modversions.h> -+#endif -+#include <linux/module.h> -+#include <linux/netfilter_ipv4/ip_tables.h> -+#include <linux/version.h> -+#include <linux/netfilter_ipv4/ipt_ipp2p.h> -+#include <net/tcp.h> -+#include <net/udp.h> -+ -+#define get_u8(X,O) (*(__u8 *)(X + O)) -+#define get_u16(X,O) (*(__u16 *)(X + O)) -+#define get_u32(X,O) (*(__u32 *)(X + O)) -+ -+MODULE_AUTHOR("Eicke Friedrich/Klaus Degner <ipp2p@ipp2p.org>"); -+MODULE_DESCRIPTION("An extension to iptables to identify P2P traffic."); -+MODULE_LICENSE("GPL"); -+ -+ -+/*Search for UDP eDonkey/eMule/Kad commands*/ -+int -+udp_search_edk (unsigned char *haystack, int packet_len) -+{ -+ unsigned char *t = haystack; -+ t += 8; -+ -+ switch (t[0]) { -+ case 0xe3: -+ { /*edonkey*/ -+ switch (t[1]) -+ { -+ /* client -> server status request */ -+ case 0x96: -+ if (packet_len == 14) return ((IPP2P_EDK * 100) + 50); -+ break; -+ /* server -> client status request */ -+ case 0x97: if (packet_len == 42) return ((IPP2P_EDK * 100) + 51); -+ break; -+ /* server description request */ -+ /* e3 2a ff f0 .. | size == 6 */ -+ case 0xa2: if ( (packet_len == 14) && ( get_u16(t,2) == __constant_htons(0xfff0) ) ) return ((IPP2P_EDK * 100) + 52); -+ break; -+ /* server description response */ -+ /* e3 a3 ff f0 .. | size > 40 && size < 200 */ -+ //case 0xa3: return ((IPP2P_EDK * 100) + 53); -+ // break; -+ case 0x9a: if (packet_len==26) return ((IPP2P_EDK * 100) + 54); -+ break; -+ -+ case 0x92: if (packet_len==18) return ((IPP2P_EDK * 100) + 55); -+ break; -+ } -+ break; -+ } -+ case 0xe4: -+ { -+ switch (t[1]) -+ { -+ /* e4 20 .. | size == 43 */ -+ case 0x20: if ((packet_len == 43) && (t[2] != 0x00) && (t[34] != 0x00)) return ((IPP2P_EDK * 100) + 60); -+ break; -+ /* e4 00 .. 00 | size == 35 ? */ -+ case 0x00: if ((packet_len == 35) && (t[26] == 0x00)) return ((IPP2P_EDK * 100) + 61); -+ break; -+ /* e4 10 .. 00 | size == 35 ? */ -+ case 0x10: if ((packet_len == 35) && (t[26] == 0x00)) return ((IPP2P_EDK * 100) + 62); -+ break; -+ /* e4 18 .. 00 | size == 35 ? */ -+ case 0x18: if ((packet_len == 35) && (t[26] == 0x00)) return ((IPP2P_EDK * 100) + 63); -+ break; -+ /* e4 52 .. | size = 44 */ -+ case 0x52: if (packet_len == 44 ) return ((IPP2P_EDK * 100) + 64); -+ break; -+ /* e4 58 .. | size == 6 */ -+ case 0x58: if (packet_len == 14 ) return ((IPP2P_EDK * 100) + 65); -+ break; -+ /* e4 59 .. | size == 2 */ -+ case 0x59: if (packet_len == 10 )return ((IPP2P_EDK * 100) + 66); -+ break; -+ /* e4 28 .. | packet_len == 52,77,102,127... */ -+ case 0x28: if (((packet_len-52) % 25) == 0) return ((IPP2P_EDK * 100) + 67); -+ break; -+ /* e4 50 xx xx | size == 4 */ -+ case 0x50: if (packet_len == 12) return ((IPP2P_EDK * 100) + 68); -+ break; -+ /* e4 40 xx xx | size == 48 */ -+ case 0x40: if (packet_len == 56) return ((IPP2P_EDK * 100) + 69); -+ break; -+ } -+ break; -+ } -+ } /* end of switch (t[0]) */ -+ return 0; -+}/*udp_search_edk*/ -+ -+ -+/*Search for UDP Gnutella commands*/ -+int -+udp_search_gnu (unsigned char *haystack, int packet_len) -+{ -+ unsigned char *t = haystack; -+ t += 8; -+ -+ if (memcmp(t, "GND", 3) == 0) return ((IPP2P_GNU * 100) + 51); -+ if (memcmp(t, "GNUTELLA ", 9) == 0) return ((IPP2P_GNU * 100) + 52); -+ return 0; -+}/*udp_search_gnu*/ -+ -+ -+/*Search for UDP KaZaA commands*/ -+int -+udp_search_kazaa (unsigned char *haystack, int packet_len) -+{ -+ unsigned char *t = haystack; -+ -+ if (t[packet_len-1] == 0x00){ -+ t += (packet_len - 6); -+ if (memcmp(t, "KaZaA", 5) == 0) return (IPP2P_KAZAA * 100 +50); -+ } -+ -+ return 0; -+}/*udp_search_kazaa*/ -+ -+/*Search for UDP DirectConnect commands*/ -+int -+udp_search_directconnect (unsigned char *haystack, int packet_len) -+{ -+ unsigned char *t = haystack; -+ if ((*(t + 8) == 0x24) && (*(t + packet_len - 1) == 0x7c)) { -+ t+=8; -+ if (memcmp(t, "SR ", 3) == 0) return ((IPP2P_DC * 100) + 60); -+ if (memcmp(t, "Ping ", 5) == 0) return ((IPP2P_DC * 100) + 61); -+ } -+ return 0; -+}/*udp_search_directconnect*/ -+ -+ -+ -+/*Search for UDP BitTorrent commands*/ -+int -+udp_search_bit (unsigned char *haystack, int packet_len) -+{ -+ switch(packet_len) -+ { -+ case 24: -+ /* ^ 00 00 04 17 27 10 19 80 */ -+ if ((ntohl(get_u32(haystack, 8)) == 0x00000417) && (ntohl(get_u32(haystack, 12)) == 0x27101980)) -+ return (IPP2P_BIT * 100 + 50); -+ break; -+ case 44: -+ if (get_u32(haystack, 16) == __constant_htonl(0x00000400) && get_u32(haystack, 36) == __constant_htonl(0x00000104)) -+ return (IPP2P_BIT * 100 + 51); -+ if (get_u32(haystack, 16) == __constant_htonl(0x00000400)) -+ return (IPP2P_BIT * 100 + 61); -+ break; -+ case 65: -+ if (get_u32(haystack, 16) == __constant_htonl(0x00000404) && get_u32(haystack, 36) == __constant_htonl(0x00000104)) -+ return (IPP2P_BIT * 100 + 52); -+ if (get_u32(haystack, 16) == __constant_htonl(0x00000404)) -+ return (IPP2P_BIT * 100 + 62); -+ break; -+ case 67: -+ if (get_u32(haystack, 16) == __constant_htonl(0x00000406) && get_u32(haystack, 36) == __constant_htonl(0x00000104)) -+ return (IPP2P_BIT * 100 + 53); -+ if (get_u32(haystack, 16) == __constant_htonl(0x00000406)) -+ return (IPP2P_BIT * 100 + 63); -+ break; -+ case 211: -+ if (get_u32(haystack, 8) == __constant_htonl(0x00000405)) -+ return (IPP2P_BIT * 100 + 54); -+ break; -+ case 29: -+ if ((get_u32(haystack, 8) == __constant_htonl(0x00000401))) -+ return (IPP2P_BIT * 100 + 55); -+ break; -+ case 52: -+ if (get_u32(haystack,8) == __constant_htonl(0x00000827) && -+ get_u32(haystack,12) == __constant_htonl(0x37502950)) -+ return (IPP2P_BIT * 100 + 80); -+ break; -+ default: -+ /* this packet does not have a constant size */ -+ if (packet_len >= 40 && get_u32(haystack, 16) == __constant_htonl(0x00000402) && get_u32(haystack, 36) == __constant_htonl(0x00000104)) -+ return (IPP2P_BIT * 100 + 56); -+ break; -+ } -+ -+ /* some extra-bitcomet rules: -+ * "d1:" [a|r] "d2:id20:" -+ */ -+ if (packet_len > 30 && get_u8(haystack, 8) == 'd' && get_u8(haystack, 9) == '1' && get_u8(haystack, 10) == ':' ) -+ { -+ if (get_u8(haystack, 11) == 'a' || get_u8(haystack, 11) == 'r') -+ { -+ if (memcmp(haystack+12,"d2:id20:",8)==0) -+ return (IPP2P_BIT * 100 + 57); -+ } -+ } -+ -+#if 0 -+ /* bitlord rules */ -+ /* packetlen must be bigger than 40 */ -+ /* first 4 bytes are zero */ -+ if (packet_len > 40 && get_u32(haystack, 8) == 0x00000000) -+ { -+ /* first rule: 00 00 00 00 01 00 00 xx xx xx xx 00 00 00 00*/ -+ if (get_u32(haystack, 12) == 0x00000000 && -+ get_u32(haystack, 16) == 0x00010000 && -+ get_u32(haystack, 24) == 0x00000000 ) -+ return (IPP2P_BIT * 100 + 71); -+ -+ /* 00 01 00 00 0d 00 00 xx xx xx xx 00 00 00 00*/ -+ if (get_u32(haystack, 12) == 0x00000001 && -+ get_u32(haystack, 16) == 0x000d0000 && -+ get_u32(haystack, 24) == 0x00000000 ) -+ return (IPP2P_BIT * 100 + 71); -+ -+ -+ } -+#endif -+ -+ return 0; -+}/*udp_search_bit*/ -+ -+ -+ -+/*Search for Ares commands*/ -+//#define IPP2P_DEBUG_ARES -+int -+search_ares (const unsigned char *payload, const u16 plen) -+//int search_ares (unsigned char *haystack, int packet_len, int head_len) -+{ -+// const unsigned char *t = haystack + head_len; -+ -+ /* all ares packets start with */ -+ if (payload[1] == 0 && (plen - payload[0]) == 3) -+ { -+ switch (payload[2]) -+ { -+ case 0x5a: -+ /* ares connect */ -+ if ( plen == 6 && payload[5] == 0x05 ) return ((IPP2P_ARES * 100) + 1); -+ break; -+ case 0x09: -+ /* ares search, min 3 chars --> 14 bytes -+ * lets define a search can be up to 30 chars --> max 34 bytes -+ */ -+ if ( plen >= 14 && plen <= 34 ) return ((IPP2P_ARES * 100) + 1); -+ break; -+#ifdef IPP2P_DEBUG_ARES -+ default: -+ printk(KERN_DEBUG "Unknown Ares command %x recognized, len: %u \n", (unsigned int) payload[2],plen); -+#endif /* IPP2P_DEBUG_ARES */ -+ } -+ } -+ -+#if 0 -+ /* found connect packet: 03 00 5a 04 03 05 */ -+ /* new version ares 1.8: 03 00 5a xx xx 05 */ -+ if ((plen) == 6){ /* possible connect command*/ -+ if ((payload[0] == 0x03) && (payload[1] == 0x00) && (payload[2] == 0x5a) && (payload[5] == 0x05)) -+ return ((IPP2P_ARES * 100) + 1); -+ } -+ if ((plen) == 60){ /* possible download command*/ -+ if ((payload[59] == 0x0a) && (payload[58] == 0x0a)){ -+ if (memcmp(t, "PUSH SHA1:", 10) == 0) /* found download command */ -+ return ((IPP2P_ARES * 100) + 2); -+ } -+ } -+#endif -+ -+ return 0; -+} /*search_ares*/ -+ -+/*Search for SoulSeek commands*/ -+int -+search_soul (const unsigned char *payload, const u16 plen) -+{ -+//#define IPP2P_DEBUG_SOUL -+ /* match: xx xx xx xx | xx = sizeof(payload) - 4 */ -+ if (get_u32(payload, 0) == (plen - 4)){ -+ const __u32 m=get_u32(payload, 4); -+ /* match 00 yy yy 00, yy can be everything */ -+ if ( get_u8(payload, 4) == 0x00 && get_u8(payload, 7) == 0x00 ) -+ { -+#ifdef IPP2P_DEBUG_SOUL -+ printk(KERN_DEBUG "0: Soulseek command 0x%x recognized\n",get_u32(payload, 4)); -+#endif /* IPP2P_DEBUG_SOUL */ -+ return ((IPP2P_SOUL * 100) + 1); -+ } -+ -+ /* next match: 01 yy 00 00 | yy can be everything */ -+ if ( get_u8(payload, 4) == 0x01 && get_u16(payload, 6) == 0x0000 ) -+ { -+#ifdef IPP2P_DEBUG_SOUL -+ printk(KERN_DEBUG "1: Soulseek command 0x%x recognized\n",get_u16(payload, 4)); -+#endif /* IPP2P_DEBUG_SOUL */ -+ return ((IPP2P_SOUL * 100) + 2); -+ } -+ -+ /* other soulseek commandos are: 1-5,7,9,13-18,22,23,26,28,35-37,40-46,50,51,60,62-69,91,92,1001 */ -+ /* try to do this in an intelligent way */ -+ /* get all small commandos */ -+ switch(m) -+ { -+ case 7: -+ case 9: -+ case 22: -+ case 23: -+ case 26: -+ case 28: -+ case 50: -+ case 51: -+ case 60: -+ case 91: -+ case 92: -+ case 1001: -+#ifdef IPP2P_DEBUG_SOUL -+ printk(KERN_DEBUG "2: Soulseek command 0x%x recognized\n",get_u16(payload, 4)); -+#endif /* IPP2P_DEBUG_SOUL */ -+ return ((IPP2P_SOUL * 100) + 3); -+ } -+ -+ if (m > 0 && m < 6 ) -+ { -+#ifdef IPP2P_DEBUG_SOUL -+ printk(KERN_DEBUG "3: Soulseek command 0x%x recognized\n",get_u16(payload, 4)); -+#endif /* IPP2P_DEBUG_SOUL */ -+ return ((IPP2P_SOUL * 100) + 4); -+ } -+ if (m > 12 && m < 19 ) -+ { -+#ifdef IPP2P_DEBUG_SOUL -+ printk(KERN_DEBUG "4: Soulseek command 0x%x recognized\n",get_u16(payload, 4)); -+#endif /* IPP2P_DEBUG_SOUL */ -+ return ((IPP2P_SOUL * 100) + 5); -+ } -+ -+ if (m > 34 && m < 38 ) -+ { -+#ifdef IPP2P_DEBUG_SOUL -+ printk(KERN_DEBUG "5: Soulseek command 0x%x recognized\n",get_u16(payload, 4)); -+#endif /* IPP2P_DEBUG_SOUL */ -+ return ((IPP2P_SOUL * 100) + 6); -+ } -+ -+ if (m > 39 && m < 47 ) -+ { -+#ifdef IPP2P_DEBUG_SOUL -+ printk(KERN_DEBUG "6: Soulseek command 0x%x recognized\n",get_u16(payload, 4)); -+#endif /* IPP2P_DEBUG_SOUL */ -+ return ((IPP2P_SOUL * 100) + 7); -+ } -+ -+ if (m > 61 && m < 70 ) -+ { -+#ifdef IPP2P_DEBUG_SOUL -+ printk(KERN_DEBUG "7: Soulseek command 0x%x recognized\n",get_u16(payload, 4)); -+#endif /* IPP2P_DEBUG_SOUL */ -+ return ((IPP2P_SOUL * 100) + 8); -+ } -+ -+#ifdef IPP2P_DEBUG_SOUL -+ printk(KERN_DEBUG "unknown SOULSEEK command: 0x%x, first 16 bit: 0x%x, first 8 bit: 0x%x ,soulseek ???\n",get_u32(payload, 4),get_u16(payload, 4) >> 16,get_u8(payload, 4) >> 24); -+#endif /* IPP2P_DEBUG_SOUL */ -+ } -+ -+ /* match 14 00 00 00 01 yy 00 00 00 STRING(YY) 01 00 00 00 00 46|50 00 00 00 00 */ -+ /* without size at the beginning !!! */ -+ if ( get_u32(payload, 0) == 0x14 && get_u8(payload, 4) == 0x01 ) -+ { -+ __u32 y=get_u32(payload, 5); -+ /* we need 19 chars + string */ -+ if ( (y + 19) <= (plen) ) -+ { -+ const unsigned char *w=payload+9+y; -+ if (get_u32(w, 0) == 0x01 && ( get_u16(w, 4) == 0x4600 || get_u16(w, 4) == 0x5000) && get_u32(w, 6) == 0x00); -+#ifdef IPP2P_DEBUG_SOUL -+ printk(KERN_DEBUG "Soulssek special client command recognized\n"); -+#endif /* IPP2P_DEBUG_SOUL */ -+ return ((IPP2P_SOUL * 100) + 9); -+ } -+ } -+ return 0; -+} -+ -+ -+/*Search for WinMX commands*/ -+int -+search_winmx (const unsigned char *payload, const u16 plen) -+{ -+//#define IPP2P_DEBUG_WINMX -+ if (((plen) == 4) && (memcmp(payload, "SEND", 4) == 0)) return ((IPP2P_WINMX * 100) + 1); -+ if (((plen) == 3) && (memcmp(payload, "GET", 3) == 0)) return ((IPP2P_WINMX * 100) + 2); -+ //if (packet_len < (head_len + 10)) return 0; -+ if (plen < 10) return 0; -+ -+ if ((memcmp(payload, "SEND", 4) == 0) || (memcmp(payload, "GET", 3) == 0)){ -+ u16 c=4; -+ const u16 end=plen-2; -+ u8 count=0; -+ while (c < end) -+ { -+ if (payload[c]== 0x20 && payload[c+1] == 0x22) -+ { -+ c++; -+ count++; -+ if (count>=2) return ((IPP2P_WINMX * 100) + 3); -+ } -+ c++; -+ } -+ } -+ -+ if ( plen == 149 && payload[0] == '8' ) -+ { -+#ifdef IPP2P_DEBUG_WINMX -+ printk(KERN_INFO "maybe WinMX\n"); -+#endif -+ if (get_u32(payload,17) == 0 && get_u32(payload,21) == 0 && get_u32(payload,25) == 0 && -+// get_u32(payload,33) == __constant_htonl(0x71182b1a) && get_u32(payload,37) == __constant_htonl(0x05050000) && -+// get_u32(payload,133) == __constant_htonl(0x31097edf) && get_u32(payload,145) == __constant_htonl(0xdcb8f792)) -+ get_u16(payload,39) == 0 && get_u16(payload,135) == __constant_htons(0x7edf) && get_u16(payload,147) == __constant_htons(0xf792)) -+ -+ { -+#ifdef IPP2P_DEBUG_WINMX -+ printk(KERN_INFO "got WinMX\n"); -+#endif -+ return ((IPP2P_WINMX * 100) + 4); -+ } -+ } -+ return 0; -+} /*search_winmx*/ -+ -+ -+/*Search for appleJuice commands*/ -+int -+search_apple (const unsigned char *payload, const u16 plen) -+{ -+ if ( (plen > 7) && (payload[6] == 0x0d) && (payload[7] == 0x0a) && (memcmp(payload, "ajprot", 6) == 0)) return (IPP2P_APPLE * 100); -+ -+ return 0; -+} -+ -+ -+/*Search for BitTorrent commands*/ -+int -+search_bittorrent (const unsigned char *payload, const u16 plen) -+{ -+ if (plen > 20) -+ { -+ /* test for match 0x13+"BitTorrent protocol" */ -+ if (payload[0] == 0x13) -+ { -+ if (memcmp(payload+1, "BitTorrent protocol", 19) == 0) return (IPP2P_BIT * 100); -+ } -+ -+ /* get tracker commandos, all starts with GET / -+ * then it can follow: scrape| announce -+ * and then ?hash_info= -+ */ -+ if (memcmp(payload,"GET /",5) == 0) -+ { -+ /* message scrape */ -+ if ( memcmp(payload+5,"scrape?info_hash=",17)==0 ) return (IPP2P_BIT * 100 + 1); -+ /* message announce */ -+ if ( memcmp(payload+5,"announce?info_hash=",19)==0 ) return (IPP2P_BIT * 100 + 2); -+ } -+ } -+ else -+ { -+ /* bitcomet encryptes the first packet, so we have to detect another -+ * one later in the flow */ -+ /* first try failed, too many missdetections */ -+ //if ( size == 5 && get_u32(t,0) == __constant_htonl(1) && t[4] < 3) return (IPP2P_BIT * 100 + 3); -+ -+ /* second try: block request packets */ -+ if ( plen == 17 && get_u32(payload,0) == __constant_htonl(0x0d) && payload[4] == 0x06 && get_u32(payload,13) == __constant_htonl(0x4000) ) return (IPP2P_BIT * 100 + 3); -+ } -+ -+ return 0; -+} -+ -+ -+ -+/*check for Kazaa get command*/ -+int -+search_kazaa (const unsigned char *payload, const u16 plen) -+ -+{ -+ if ((payload[plen-2] == 0x0d) && (payload[plen-1] == 0x0a) && memcmp(payload, "GET /.hash=", 11) == 0) -+ return (IPP2P_DATA_KAZAA * 100); -+ -+ return 0; -+} -+ -+ -+/*check for gnutella get command*/ -+int -+search_gnu (const unsigned char *payload, const u16 plen) -+{ -+ if ((payload[plen-2] == 0x0d) && (payload[plen-1] == 0x0a)) -+ { -+ if (memcmp(payload, "GET /get/", 9) == 0) return ((IPP2P_DATA_GNU * 100) + 1); -+ if (memcmp(payload, "GET /uri-res/", 13) == 0) return ((IPP2P_DATA_GNU * 100) + 2); -+ } -+ return 0; -+} -+ -+ -+/*check for gnutella get commands and other typical data*/ -+int -+search_all_gnu (const unsigned char *payload, const u16 plen) -+{ -+ -+ if ((payload[plen-2] == 0x0d) && (payload[plen-1] == 0x0a)) -+ { -+ -+ if (memcmp(payload, "GNUTELLA CONNECT/", 17) == 0) return ((IPP2P_GNU * 100) + 1); -+ if (memcmp(payload, "GNUTELLA/", 9) == 0) return ((IPP2P_GNU * 100) + 2); -+ -+ -+ if ((memcmp(payload, "GET /get/", 9) == 0) || (memcmp(payload, "GET /uri-res/", 13) == 0)) -+ { -+ u16 c=8; -+ const u16 end=plen-22; -+ while (c < end) { -+ if ( payload[c] == 0x0a && payload[c+1] == 0x0d && ((memcmp(&payload[c+2], "X-Gnutella-", 11) == 0) || (memcmp(&payload[c+2], "X-Queue:", 8) == 0))) -+ return ((IPP2P_GNU * 100) + 3); -+ c++; -+ } -+ } -+ } -+ return 0; -+} -+ -+ -+/*check for KaZaA download commands and other typical data*/ -+int -+search_all_kazaa (const unsigned char *payload, const u16 plen) -+{ -+ if ((payload[plen-2] == 0x0d) && (payload[plen-1] == 0x0a)) -+ { -+ -+ if (memcmp(payload, "GIVE ", 5) == 0) return ((IPP2P_KAZAA * 100) + 1); -+ -+ if (memcmp(payload, "GET /", 5) == 0) { -+ u16 c = 8; -+ const u16 end=plen-22; -+ while (c < end) { -+ if ( payload[c] == 0x0a && payload[c+1] == 0x0d && ((memcmp(&payload[c+2], "X-Kazaa-Username: ", 18) == 0) || (memcmp(&payload[c+2], "User-Agent: PeerEnabler/", 24) == 0))) -+ return ((IPP2P_KAZAA * 100) + 2); -+ c++; -+ } -+ } -+ } -+ return 0; -+} -+ -+/*fast check for edonkey file segment transfer command*/ -+int -+search_edk (const unsigned char *payload, const u16 plen) -+{ -+ if (payload[0] != 0xe3) -+ return 0; -+ else { -+ if (payload[5] == 0x47) -+ return (IPP2P_DATA_EDK * 100); -+ else -+ return 0; -+ } -+} -+ -+ -+ -+/*intensive but slower search for some edonkey packets including size-check*/ -+int -+search_all_edk (const unsigned char *payload, const u16 plen) -+{ -+ if (payload[0] != 0xe3) -+ return 0; -+ else { -+ //t += head_len; -+ const u16 cmd = get_u16(payload, 1); -+ if (cmd == (plen - 5)) { -+ switch (payload[5]) { -+ case 0x01: return ((IPP2P_EDK * 100) + 1); /*Client: hello or Server:hello*/ -+ case 0x4c: return ((IPP2P_EDK * 100) + 9); /*Client: Hello-Answer*/ -+ } -+ } -+ return 0; -+ } -+} -+ -+ -+/*fast check for Direct Connect send command*/ -+int -+search_dc (const unsigned char *payload, const u16 plen) -+{ -+ -+ if (payload[0] != 0x24 ) -+ return 0; -+ else { -+ if (memcmp(&payload[1], "Send|", 5) == 0) -+ return (IPP2P_DATA_DC * 100); -+ else -+ return 0; -+ } -+ -+} -+ -+ -+/*intensive but slower check for all direct connect packets*/ -+int -+search_all_dc (const unsigned char *payload, const u16 plen) -+{ -+// unsigned char *t = haystack; -+ -+ if (payload[0] == 0x24 && payload[plen-1] == 0x7c) -+ { -+ const unsigned char *t=&payload[1]; -+ /* Client-Hub-Protocol */ -+ if (memcmp(t, "Lock ", 5) == 0) return ((IPP2P_DC * 100) + 1); -+ /* Client-Client-Protocol, some are already recognized by client-hub (like lock) */ -+ if (memcmp(t, "MyNick ", 7) == 0) return ((IPP2P_DC * 100) + 38); -+ } -+ return 0; -+} -+ -+/*check for mute*/ -+int -+search_mute (const unsigned char *payload, const u16 plen) -+{ -+ if ( plen == 209 || plen == 345 || plen == 473 || plen == 609 || plen == 1121 ) -+ { -+ //printk(KERN_DEBUG "size hit: %u",size); -+ if (memcmp(payload,"PublicKey: ",11) == 0 ) -+ { -+ return ((IPP2P_MUTE * 100) + 0); -+ -+/* if (memcmp(t+size-14,"\x0aEndPublicKey\x0a",14) == 0) -+ { -+ printk(KERN_DEBUG "end pubic key hit: %u",size); -+ -+ }*/ -+ } -+ } -+ return 0; -+} -+ -+ -+/* check for xdcc */ -+int -+search_xdcc (const unsigned char *payload, const u16 plen) -+{ -+ /* search in small packets only */ -+ if (plen > 20 && plen < 200 && payload[plen-1] == 0x0a && payload[plen-2] == 0x0d && memcmp(payload,"PRIVMSG ",8) == 0) -+ { -+ -+ u16 x=10; -+ const u16 end=plen - 13; -+ -+ /* is seems to be a irc private massage, chedck for xdcc command */ -+ while (x < end) -+ { -+ if (payload[x] == ':') -+ { -+ if ( memcmp(&payload[x+1],"xdcc send #",11) == 0 ) -+ return ((IPP2P_XDCC * 100) + 0); -+ } -+ x++; -+ } -+ } -+ return 0; -+} -+ -+/* search for waste */ -+int search_waste(const unsigned char *payload, const u16 plen) -+{ -+ if ( plen >= 8 && memcmp(payload,"GET.sha1:",9) == 0) -+ return ((IPP2P_WASTE * 100) + 0); -+ -+ return 0; -+} -+ -+ -+static struct { -+ int command; -+ __u8 short_hand; /*for fucntions included in short hands*/ -+ int packet_len; -+ int (*function_name) (const unsigned char *, const u16); -+} matchlist[] = { -+ {IPP2P_EDK,SHORT_HAND_IPP2P,20, &search_all_edk}, -+// {IPP2P_DATA_KAZAA,SHORT_HAND_DATA,200, &search_kazaa}, -+// {IPP2P_DATA_EDK,SHORT_HAND_DATA,60, &search_edk}, -+// {IPP2P_DATA_DC,SHORT_HAND_DATA,26, &search_dc}, -+ {IPP2P_DC,SHORT_HAND_IPP2P,5, search_all_dc}, -+// {IPP2P_DATA_GNU,SHORT_HAND_DATA,40, &search_gnu}, -+ {IPP2P_GNU,SHORT_HAND_IPP2P,5, &search_all_gnu}, -+ {IPP2P_KAZAA,SHORT_HAND_IPP2P,5, &search_all_kazaa}, -+ {IPP2P_BIT,SHORT_HAND_IPP2P,20, &search_bittorrent}, -+ {IPP2P_APPLE,SHORT_HAND_IPP2P,5, &search_apple}, -+ {IPP2P_SOUL,SHORT_HAND_IPP2P,5, &search_soul}, -+ {IPP2P_WINMX,SHORT_HAND_IPP2P,2, &search_winmx}, -+ {IPP2P_ARES,SHORT_HAND_IPP2P,5, &search_ares}, -+ {IPP2P_MUTE,SHORT_HAND_NONE,200, &search_mute}, -+ {IPP2P_WASTE,SHORT_HAND_NONE,5, &search_waste}, -+ {IPP2P_XDCC,SHORT_HAND_NONE,5, &search_xdcc}, -+ {0,0,0,NULL} -+}; -+ -+ -+static struct { -+ int command; -+ __u8 short_hand; /*for fucntions included in short hands*/ -+ int packet_len; -+ int (*function_name) (unsigned char *, int); -+} udp_list[] = { -+ {IPP2P_KAZAA,SHORT_HAND_IPP2P,14, &udp_search_kazaa}, -+ {IPP2P_BIT,SHORT_HAND_IPP2P,23, &udp_search_bit}, -+ {IPP2P_GNU,SHORT_HAND_IPP2P,11, &udp_search_gnu}, -+ {IPP2P_EDK,SHORT_HAND_IPP2P,9, &udp_search_edk}, -+ {IPP2P_DC,SHORT_HAND_IPP2P,12, &udp_search_directconnect}, -+ {0,0,0,NULL} -+}; -+ -+ -+static int -+match(const struct sk_buff *skb, -+ const struct net_device *in, -+ const struct net_device *out, -+ const void *matchinfo, -+ int offset, -+ -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) -+ const void *hdr, -+ u_int16_t datalen, -+#endif -+ -+ int *hotdrop) -+{ -+ const struct ipt_p2p_info *info = matchinfo; -+ unsigned char *haystack; -+ struct iphdr *ip = skb->nh.iph; -+ int p2p_result = 0, i = 0; -+// int head_len; -+ int hlen = ntohs(ip->tot_len)-(ip->ihl*4); /*hlen = packet-data length*/ -+ -+ /*must not be a fragment*/ -+ if (offset) { -+ if (info->debug) printk("IPP2P.match: offset found %i \n",offset); -+ return 0; -+ } -+ -+ /*make sure that skb is linear*/ -+ if(skb_is_nonlinear(skb)){ -+ if (info->debug) printk("IPP2P.match: nonlinear skb found\n"); -+ return 0; -+ } -+ -+ -+ haystack=(char *)ip+(ip->ihl*4); /*haystack = packet data*/ -+ -+ switch (ip->protocol){ -+ case IPPROTO_TCP: /*what to do with a TCP packet*/ -+ { -+ struct tcphdr *tcph = (void *) ip + ip->ihl * 4; -+ -+ if (tcph->fin) return 0; /*if FIN bit is set bail out*/ -+ if (tcph->syn) return 0; /*if SYN bit is set bail out*/ -+ if (tcph->rst) return 0; /*if RST bit is set bail out*/ -+ -+ haystack += tcph->doff * 4; /*get TCP-Header-Size*/ -+ hlen -= tcph->doff * 4; -+ while (matchlist[i].command) { -+ if ((((info->cmd & matchlist[i].command) == matchlist[i].command) || -+ ((info->cmd & matchlist[i].short_hand) == matchlist[i].short_hand)) && -+ (hlen > matchlist[i].packet_len)) { -+ p2p_result = matchlist[i].function_name(haystack, hlen); -+ if (p2p_result) -+ { -+ if (info->debug) printk("IPP2P.debug:TCP-match: %i from: %u.%u.%u.%u:%i to: %u.%u.%u.%u:%i Length: %i\n", -+ p2p_result, NIPQUAD(ip->saddr),ntohs(tcph->source), NIPQUAD(ip->daddr),ntohs(tcph->dest),hlen); -+ return p2p_result; -+ } -+ } -+ i++; -+ } -+ return p2p_result; -+ } -+ -+ case IPPROTO_UDP: /*what to do with an UDP packet*/ -+ { -+ struct udphdr *udph = (void *) ip + ip->ihl * 4; -+ -+ while (udp_list[i].command){ -+ if ((((info->cmd & udp_list[i].command) == udp_list[i].command) || -+ ((info->cmd & udp_list[i].short_hand) == udp_list[i].short_hand)) && -+ (hlen > udp_list[i].packet_len)) { -+ p2p_result = udp_list[i].function_name(haystack, hlen); -+ if (p2p_result){ -+ if (info->debug) printk("IPP2P.debug:UDP-match: %i from: %u.%u.%u.%u:%i to: %u.%u.%u.%u:%i Length: %i\n", -+ p2p_result, NIPQUAD(ip->saddr),ntohs(udph->source), NIPQUAD(ip->daddr),ntohs(udph->dest),hlen); -+ return p2p_result; -+ } -+ } -+ i++; -+ } -+ return p2p_result; -+ } -+ -+ default: return 0; -+ } -+} -+ -+ -+ -+static int -+checkentry(const char *tablename, -+ const struct ipt_ip *ip, -+ void *matchinfo, -+ unsigned int matchsize, -+ unsigned int hook_mask) -+{ -+ /* Must specify -p tcp */ -+/* if (ip->proto != IPPROTO_TCP || (ip->invflags & IPT_INV_PROTO)) { -+ * printk("ipp2p: Only works on TCP packets, use -p tcp\n"); -+ * return 0; -+ * }*/ -+ return 1; -+} -+ -+ -+ -+ -+static struct ipt_match ipp2p_match = { -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) -+ { NULL, NULL }, -+ "ipp2p", -+ &match, -+ &checkentry, -+ NULL, -+ THIS_MODULE -+#endif -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -+ .name = "ipp2p", -+ .match = &match, -+ .checkentry = &checkentry, -+ .me = THIS_MODULE, -+#endif -+}; -+ -+ -+static int __init init(void) -+{ -+ printk(KERN_INFO "IPP2P v%s loading\n", IPP2P_VERSION); -+ return ipt_register_match(&ipp2p_match); -+} -+ -+static void __exit fini(void) -+{ -+ ipt_unregister_match(&ipp2p_match); -+ printk(KERN_INFO "IPP2P v%s unloaded\n", IPP2P_VERSION); -+} -+ -+module_init(init); -+module_exit(fini); -+ -+ diff --git a/target/linux/generic-2.4/patches/602-netfilter_layer7_2.21.patch b/target/linux/generic-2.4/patches/602-netfilter_layer7_2.21.patch deleted file mode 100644 index d84a2c6..0000000 --- a/target/linux/generic-2.4/patches/602-netfilter_layer7_2.21.patch +++ /dev/null @@ -1,2062 +0,0 @@ ---- a/Documentation/Configure.help -+++ b/Documentation/Configure.help -@@ -29252,6 +29252,18 @@ CONFIG_SOUND_WM97XX - - If unsure, say N. - -+CONFIG_IP_NF_MATCH_LAYER7 -+ Say Y if you want to be able to classify connections (and their -+ packets) based on regular expression matching of their application -+ layer data. This is one way to classify applications such as -+ peer-to-peer filesharing systems that do not always use the same -+ port. -+ -+ To compile it as a module, choose M here. If unsure, say N. -+ -+CONFIG_IP_NF_MATCH_LAYER7_DEBUG -+ Say Y to get lots of debugging output. -+ - # - # A couple of things I keep forgetting: - # capitalize: AppleTalk, Ethernet, DOS, DMA, FAT, FTP, Internet, ---- a/include/linux/netfilter_ipv4/ip_conntrack.h -+++ b/include/linux/netfilter_ipv4/ip_conntrack.h -@@ -207,6 +207,17 @@ struct ip_conntrack - } nat; - #endif /* CONFIG_IP_NF_NAT_NEEDED */ - -+#if defined(CONFIG_IP_NF_MATCH_LAYER7) || defined(CONFIG_IP_NF_MATCH_LAYER7_MODULE) -+ struct { -+ unsigned int numpackets; /* surely this is kept track of somewhere else, right? I can't find it... */ -+ char * app_proto; /* "http", "ftp", etc. NULL if unclassifed */ -+ -+ /* the application layer data so far. NULL if ->numpackets > numpackets */ -+ char * app_data; -+ -+ unsigned int app_data_len; -+ } layer7; -+#endif - }; - - /* get master conntrack via master expectation */ ---- /dev/null -+++ b/include/linux/netfilter_ipv4/ipt_layer7.h -@@ -0,0 +1,26 @@ -+/* -+ By Matthew Strait <quadong@users.sf.net>, Dec 2003. -+ http://l7-filter.sf.net -+ -+ 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. -+ http://www.gnu.org/licenses/gpl.txt -+*/ -+ -+#ifndef _IPT_LAYER7_H -+#define _IPT_LAYER7_H -+ -+#define MAX_PATTERN_LEN 8192 -+#define MAX_PROTOCOL_LEN 256 -+ -+typedef char *(*proc_ipt_search) (char *, char, char *); -+ -+struct ipt_layer7_info { -+ char protocol[MAX_PROTOCOL_LEN]; -+ char invert:1; -+ char pattern[MAX_PATTERN_LEN]; -+}; -+ -+#endif /* _IPT_LAYER7_H */ ---- a/net/ipv4/netfilter/Config.in -+++ b/net/ipv4/netfilter/Config.in -@@ -44,6 +44,9 @@ if [ "$CONFIG_IP_NF_IPTABLES" != "n" ]; - if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then - dep_tristate ' Unclean match support (EXPERIMENTAL)' CONFIG_IP_NF_MATCH_UNCLEAN $CONFIG_IP_NF_IPTABLES - dep_tristate ' Owner match support (EXPERIMENTAL)' CONFIG_IP_NF_MATCH_OWNER $CONFIG_IP_NF_IPTABLES -+ dep_tristate ' Layer 7 match support (EXPERIMENTAL)' CONFIG_IP_NF_MATCH_LAYER7 $CONFIG_IP_NF_CONNTRACK -+ dep_mbool ' Layer 7 debugging output (EXPERIMENTAL)' CONFIG_IP_NF_MATCH_LAYER7_DEBUG $CONFIG_IP_NF_MATCH_LAYER7 -+ - fi - # The targets - dep_tristate ' Packet filtering' CONFIG_IP_NF_FILTER $CONFIG_IP_NF_IPTABLES ---- a/net/ipv4/netfilter/Makefile -+++ b/net/ipv4/netfilter/Makefile -@@ -87,6 +87,7 @@ obj-$(CONFIG_IP_NF_MATCH_STATE) += ipt_s - obj-$(CONFIG_IP_NF_MATCH_CONNTRACK) += ipt_conntrack.o - obj-$(CONFIG_IP_NF_MATCH_UNCLEAN) += ipt_unclean.o - obj-$(CONFIG_IP_NF_MATCH_TCPMSS) += ipt_tcpmss.o -+obj-$(CONFIG_IP_NF_MATCH_LAYER7) += ipt_layer7.o - - # targets - obj-$(CONFIG_IP_NF_TARGET_REJECT) += ipt_REJECT.o ---- a/net/ipv4/netfilter/ip_conntrack_core.c -+++ b/net/ipv4/netfilter/ip_conntrack_core.c -@@ -346,6 +346,14 @@ destroy_conntrack(struct nf_conntrack *n - } - kfree(ct->master); - } -+ -+ #if defined(CONFIG_IP_NF_MATCH_LAYER7) || defined(CONFIG_IP_NF_MATCH_LAYER7_MODULE) -+ if(ct->layer7.app_proto) -+ kfree(ct->layer7.app_proto); -+ if(ct->layer7.app_data) -+ kfree(ct->layer7.app_data); -+ #endif -+ - WRITE_UNLOCK(&ip_conntrack_lock); - - if (master) ---- a/net/ipv4/netfilter/ip_conntrack_standalone.c -+++ b/net/ipv4/netfilter/ip_conntrack_standalone.c -@@ -107,6 +107,13 @@ print_conntrack(char *buffer, struct ip_ - len += sprintf(buffer + len, "[ASSURED] "); - len += sprintf(buffer + len, "use=%u ", - atomic_read(&conntrack->ct_general.use)); -+ -+ #if defined(CONFIG_IP_NF_MATCH_LAYER7) || defined(CONFIG_IP_NF_MATCH_LAYER7_MODULE) -+ if(conntrack->layer7.app_proto) -+ len += sprintf(buffer + len, "l7proto=%s ", -+ conntrack->layer7.app_proto); -+ #endif -+ - len += sprintf(buffer + len, "\n"); - - return len; ---- /dev/null -+++ b/net/ipv4/netfilter/ipt_layer7.c -@@ -0,0 +1,570 @@ -+/* -+ Kernel module to match application layer (OSI layer 7) -+ data in connections. -+ -+ http://l7-filter.sf.net -+ -+ By Matthew Strait and Ethan Sommer, 2003-2005. -+ -+ 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. -+ http://www.gnu.org/licenses/gpl.txt -+ -+ Based on ipt_string.c (C) 2000 Emmanuel Roger <winfield@freegates.be> -+ and cls_layer7.c (C) 2003 Matthew Strait, Ethan Sommer, Justin Levandoski -+*/ -+ -+#include <linux/module.h> -+#include <linux/skbuff.h> -+#include <linux/netfilter_ipv4/ip_conntrack.h> -+#include <linux/proc_fs.h> -+#include <linux/ctype.h> -+#include <net/ip.h> -+#include <net/tcp.h> -+#include <linux/netfilter_ipv4/lockhelp.h> -+ -+#include "regexp/regexp.c" -+ -+#include <linux/netfilter_ipv4/ipt_layer7.h> -+#include <linux/netfilter_ipv4/ip_tables.h> -+ -+MODULE_AUTHOR("Matthew Strait <quadong@users.sf.net>, Ethan Sommer <sommere@users.sf.net>"); -+MODULE_LICENSE("GPL"); -+MODULE_DESCRIPTION("iptables application layer match module"); -+ -+static int maxdatalen = 2048; // this is the default -+MODULE_PARM(maxdatalen,"i"); -+MODULE_PARM_DESC(maxdatalen,"maximum bytes of data looked at by l7-filter"); -+ -+#if defined(CONFIG_IP_NF_MATCH_LAYER7_DEBUG) -+ #define DPRINTK(format,args...) printk(format,##args) -+#else -+ #define DPRINTK(format,args...) -+#endif -+ -+#define TOTAL_PACKETS master_conntrack->layer7.numpackets -+ -+/* Number of packets whose data we look at. -+This can be modified through /proc/net/layer7_numpackets */ -+static int num_packets = 10; -+ -+static struct pattern_cache { -+ char * regex_string; -+ regexp * pattern; -+ struct pattern_cache * next; -+} * first_pattern_cache = NULL; -+ -+/* I'm new to locking. Here are my assumptions: -+ -+- No one will write to /proc/net/layer7_numpackets over and over very fast; -+ if they did, nothing awful would happen. -+ -+- This code will never be processing the same packet twice at the same time, -+ because iptables rules are traversed in order. -+ -+- It doesn't matter if two packets from different connections are in here at -+ the same time, because they don't share any data. -+ -+- It _does_ matter if two packets from the same connection are here at the same -+ time. In this case, we have to protect the conntracks and the list of -+ compiled patterns. -+*/ -+DECLARE_RWLOCK(ct_lock); -+DECLARE_LOCK(list_lock); -+ -+#if CONFIG_IP_NF_MATCH_LAYER7_DEBUG -+/* Converts an unfriendly string into a friendly one by -+replacing unprintables with periods and all whitespace with " ". */ -+static char * friendly_print(unsigned char * s) -+{ -+ char * f = kmalloc(strlen(s) + 1, GFP_ATOMIC); -+ int i; -+ -+ if(!f) { -+ if (net_ratelimit()) -+ printk(KERN_ERR "layer7: out of memory in friendly_print, bailing.\n"); -+ return NULL; -+ } -+ -+ for(i = 0; i < strlen(s); i++){ -+ if(isprint(s[i]) && s[i] < 128) f[i] = s[i]; -+ else if(isspace(s[i])) f[i] = ' '; -+ else f[i] = '.'; -+ } -+ f[i] = '\0'; -+ return f; -+} -+ -+static char dec2hex(int i) -+{ -+ switch (i) { -+ case 0 ... 9: -+ return (char)(i + '0'); -+ break; -+ case 10 ... 15: -+ return (char)(i - 10 + 'a'); -+ break; -+ default: -+ if (net_ratelimit()) -+ printk("Problem in dec2hex\n"); -+ return '\0'; -+ } -+} -+ -+static char * hex_print(unsigned char * s) -+{ -+ char * g = kmalloc(strlen(s)*3 + 1, GFP_ATOMIC); -+ int i; -+ -+ if(!g) { -+ if (net_ratelimit()) -+ printk(KERN_ERR "layer7: out of memory in hex_print, bailing.\n"); -+ return NULL; -+ } -+ -+ for(i = 0; i < strlen(s); i++) { -+ g[i*3 ] = dec2hex(s[i]/16); -+ g[i*3 + 1] = dec2hex(s[i]%16); -+ g[i*3 + 2] = ' '; -+ } -+ g[i*3] = '\0'; -+ -+ return g; -+} -+#endif // DEBUG -+ -+/* Use instead of regcomp. As we expect to be seeing the same regexps over and -+over again, it make sense to cache the results. */ -+static regexp * compile_and_cache(char * regex_string, char * protocol) -+{ -+ struct pattern_cache * node = first_pattern_cache; -+ struct pattern_cache * last_pattern_cache = first_pattern_cache; -+ struct pattern_cache * tmp; -+ unsigned int len; -+ -+ while (node != NULL) { -+ if (!strcmp(node->regex_string, regex_string)) -+ return node->pattern; -+ -+ last_pattern_cache = node;/* points at the last non-NULL node */ -+ node = node->next; -+ } -+ -+ /* If we reach the end of the list, then we have not yet cached -+ the pattern for this regex. Let's do that now. -+ Be paranoid about running out of memory to avoid list corruption. */ -+ tmp = kmalloc(sizeof(struct pattern_cache), GFP_ATOMIC); -+ -+ if(!tmp) { -+ if (net_ratelimit()) -+ printk(KERN_ERR "layer7: out of memory in compile_and_cache, bailing.\n"); -+ return NULL; -+ } -+ -+ tmp->regex_string = kmalloc(strlen(regex_string) + 1, GFP_ATOMIC); -+ tmp->pattern = kmalloc(sizeof(struct regexp), GFP_ATOMIC); -+ tmp->next = NULL; -+ -+ if(!tmp->regex_string || !tmp->pattern) { -+ if (net_ratelimit()) -+ printk(KERN_ERR "layer7: out of memory in compile_and_cache, bailing.\n"); -+ kfree(tmp->regex_string); -+ kfree(tmp->pattern); -+ kfree(tmp); -+ return NULL; -+ } -+ -+ /* Ok. The new node is all ready now. */ -+ node = tmp; -+ -+ if(first_pattern_cache == NULL) /* list is empty */ -+ first_pattern_cache = node; /* make node the beginning */ -+ else -+ last_pattern_cache->next = node; /* attach node to the end */ -+ -+ /* copy the string and compile the regex */ -+ len = strlen(regex_string); -+ DPRINTK("About to compile this: \"%s\"\n", regex_string); -+ node->pattern = regcomp(regex_string, &len); -+ if ( !node->pattern ) { -+ if (net_ratelimit()) -+ printk(KERN_ERR "layer7: Error compiling regexp \"%s\" (%s)\n", regex_string, protocol); -+ /* pattern is now cached as NULL, so we won't try again. */ -+ } -+ -+ strcpy(node->regex_string, regex_string); -+ return node->pattern; -+} -+ -+static int can_handle(const struct sk_buff *skb) -+{ -+ if(!skb->nh.iph) /* not IP */ -+ return 0; -+ if(skb->nh.iph->protocol != IPPROTO_TCP && -+ skb->nh.iph->protocol != IPPROTO_UDP && -+ skb->nh.iph->protocol != IPPROTO_ICMP) -+ return 0; -+ return 1; -+} -+ -+/* Returns offset the into the skb->data that the application data starts */ -+static int app_data_offset(const struct sk_buff *skb) -+{ -+ /* In case we are ported somewhere (ebtables?) where skb->nh.iph -+ isn't set, this can be gotten from 4*(skb->data[0] & 0x0f) as well. */ -+ int ip_hl = 4*skb->nh.iph->ihl; -+ -+ if( skb->nh.iph->protocol == IPPROTO_TCP ) { -+ /* 12 == offset into TCP header for the header length field. -+ Can't get this with skb->h.th->doff because the tcphdr -+ struct doesn't get set when routing (this is confirmed to be -+ true in Netfilter as well as QoS.) */ -+ int tcp_hl = 4*(skb->data[ip_hl + 12] >> 4); -+ -+ return ip_hl + tcp_hl; -+ } else if( skb->nh.iph->protocol == IPPROTO_UDP ) { -+ return ip_hl + 8; /* UDP header is always 8 bytes */ -+ } else if( skb->nh.iph->protocol == IPPROTO_ICMP ) { -+ return ip_hl + 8; /* ICMP header is 8 bytes */ -+ } else { -+ if (net_ratelimit()) -+ printk(KERN_ERR "layer7: tried to handle unknown protocol!\n"); -+ return ip_hl + 8; /* something reasonable */ -+ } -+} -+ -+/* handles whether there's a match when we aren't appending data anymore */ -+static int match_no_append(struct ip_conntrack * conntrack, struct ip_conntrack * master_conntrack, -+ enum ip_conntrack_info ctinfo, enum ip_conntrack_info master_ctinfo, -+ struct ipt_layer7_info * info) -+{ -+ /* If we're in here, throw the app data away */ -+ WRITE_LOCK(&ct_lock); -+ if(master_conntrack->layer7.app_data != NULL) { -+ -+ #ifdef CONFIG_IP_NF_MATCH_LAYER7_DEBUG -+ if(!master_conntrack->layer7.app_proto) { -+ char * f = friendly_print(master_conntrack->layer7.app_data); -+ char * g = hex_print(master_conntrack->layer7.app_data); -+ DPRINTK("\nl7-filter gave up after %d bytes (%d packets):\n%s\n", -+ strlen(f), -+ TOTAL_PACKETS, f); -+ kfree(f); -+ DPRINTK("In hex: %s\n", g); -+ kfree(g); -+ } -+ #endif -+ -+ kfree(master_conntrack->layer7.app_data); -+ master_conntrack->layer7.app_data = NULL; /* don't free again */ -+ } -+ WRITE_UNLOCK(&ct_lock); -+ -+ if(master_conntrack->layer7.app_proto){ -+ /* Here child connections set their .app_proto (for /proc/net/ip_conntrack) */ -+ WRITE_LOCK(&ct_lock); -+ if(!conntrack->layer7.app_proto) { -+ conntrack->layer7.app_proto = kmalloc(strlen(master_conntrack->layer7.app_proto)+1, GFP_ATOMIC); -+ if(!conntrack->layer7.app_proto){ -+ if (net_ratelimit()) -+ printk(KERN_ERR "layer7: out of memory in match_no_append, bailing.\n"); -+ WRITE_UNLOCK(&ct_lock); -+ return 1; -+ } -+ strcpy(conntrack->layer7.app_proto, master_conntrack->layer7.app_proto); -+ } -+ WRITE_UNLOCK(&ct_lock); -+ -+ return (!strcmp(master_conntrack->layer7.app_proto, info->protocol)); -+ } -+ else { -+ /* If not classified, set to "unknown" to distinguish from -+ connections that are still being tested. */ -+ WRITE_LOCK(&ct_lock); -+ master_conntrack->layer7.app_proto = kmalloc(strlen("unknown")+1, GFP_ATOMIC); -+ if(!master_conntrack->layer7.app_proto){ -+ if (net_ratelimit()) -+ printk(KERN_ERR "layer7: out of memory in match_no_append, bailing.\n"); -+ WRITE_UNLOCK(&ct_lock); -+ return 1; -+ } -+ strcpy(master_conntrack->layer7.app_proto, "unknown"); -+ WRITE_UNLOCK(&ct_lock); -+ return 0; -+ } -+} -+ -+/* add the new app data to the conntrack. Return number of bytes added. */ -+static int add_data(struct ip_conntrack * master_conntrack, -+ char * app_data, int appdatalen) -+{ -+ int length = 0, i; -+ int oldlength = master_conntrack->layer7.app_data_len; -+ -+ /* Strip nulls. Make everything lower case (our regex lib doesn't -+ do case insensitivity). Add it to the end of the current data. */ -+ for(i = 0; i < maxdatalen-oldlength-1 && i < appdatalen; i++) { -+ if(app_data[i] != '\0') { -+ master_conntrack->layer7.app_data[length+oldlength] = -+ /* the kernel version of tolower mungs 'upper ascii' */ -+ isascii(app_data[i])? tolower(app_data[i]) : app_data[i]; -+ length++; -+ } -+ } -+ -+ master_conntrack->layer7.app_data[length+oldlength] = '\0'; -+ master_conntrack->layer7.app_data_len = length + oldlength; -+ -+ return length; -+} -+ -+/* Returns true on match and false otherwise. */ -+static int match(/* const */struct sk_buff *skb, const struct net_device *in, -+ const struct net_device *out, const void *matchinfo, -+ int offset, int *hotdrop) -+{ -+ struct ipt_layer7_info * info = (struct ipt_layer7_info *)matchinfo; -+ enum ip_conntrack_info master_ctinfo, ctinfo; -+ struct ip_conntrack *master_conntrack, *conntrack; -+ unsigned char * app_data; -+ unsigned int pattern_result, appdatalen; -+ regexp * comppattern; -+ -+ if(!can_handle(skb)){ -+ DPRINTK("layer7: This is some protocol I can't handle.\n"); -+ return info->invert; -+ } -+ -+ /* Treat the parent and all its children together as one connection, -+ except for the purpose of setting conntrack->layer7.app_proto in the -+ actual connection. This makes /proc/net/ip_conntrack somewhat more -+ satisfying. */ -+ if(!(conntrack = ip_conntrack_get((struct sk_buff *)skb, &ctinfo)) || -+ !(master_conntrack = ip_conntrack_get((struct sk_buff *)skb, &master_ctinfo))) { -+ DPRINTK("layer7: packet is not from a known connection, giving up.\n"); -+ return info->invert; -+ } -+ -+ /* Try to get a master conntrack (and its master etc) for FTP, etc. */ -+ while (master_ct(master_conntrack) != NULL) -+ master_conntrack = master_ct(master_conntrack); -+ -+ if(!skb->cb[0]){ -+ WRITE_LOCK(&ct_lock); -+ master_conntrack->layer7.numpackets++;/*starts at 0 via memset*/ -+ WRITE_UNLOCK(&ct_lock); -+ } -+ -+ /* if we've classified it or seen too many packets */ -+ if(TOTAL_PACKETS > num_packets || -+ master_conntrack->layer7.app_proto) { -+ -+ pattern_result = match_no_append(conntrack, master_conntrack, ctinfo, master_ctinfo, info); -+ -+ /* skb->cb[0] == seen. Avoid doing things twice if there are two l7 -+ rules. I'm not sure that using cb for this purpose is correct, although -+ it says "put your private variables there". But it doesn't look like it -+ is being used for anything else in the skbs that make it here. How can -+ I write to cb without making the compiler angry? */ -+ skb->cb[0] = 1; /* marking it seen here is probably irrelevant, but consistant */ -+ -+ return (pattern_result ^ info->invert); -+ } -+ -+ if(skb_is_nonlinear(skb)){ -+ if(skb_linearize(skb, GFP_ATOMIC) != 0){ -+ if (net_ratelimit()) -+ printk(KERN_ERR "layer7: failed to linearize packet, bailing.\n"); -+ return info->invert; -+ } -+ } -+ -+ /* now that the skb is linearized, it's safe to set these. */ -+ app_data = skb->data + app_data_offset(skb); -+ appdatalen = skb->tail - app_data; -+ -+ LOCK_BH(&list_lock); -+ /* the return value gets checked later, when we're ready to use it */ -+ comppattern = compile_and_cache(info->pattern, info->protocol); -+ UNLOCK_BH(&list_lock); -+ -+ /* On the first packet of a connection, allocate space for app data */ -+ WRITE_LOCK(&ct_lock); -+ if(TOTAL_PACKETS == 1 && !skb->cb[0] && !master_conntrack->layer7.app_data) { -+ master_conntrack->layer7.app_data = kmalloc(maxdatalen, GFP_ATOMIC); -+ if(!master_conntrack->layer7.app_data){ -+ if (net_ratelimit()) -+ printk(KERN_ERR "layer7: out of memory in match, bailing.\n"); -+ WRITE_UNLOCK(&ct_lock); -+ return info->invert; -+ } -+ -+ master_conntrack->layer7.app_data[0] = '\0'; -+ } -+ WRITE_UNLOCK(&ct_lock); -+ -+ /* Can be here, but unallocated, if numpackets is increased near -+ the beginning of a connection */ -+ if(master_conntrack->layer7.app_data == NULL) -+ return (info->invert); /* unmatched */ -+ -+ if(!skb->cb[0]){ -+ int newbytes; -+ WRITE_LOCK(&ct_lock); -+ newbytes = add_data(master_conntrack, app_data, appdatalen); -+ WRITE_UNLOCK(&ct_lock); -+ -+ if(newbytes == 0) { /* didn't add any data */ -+ skb->cb[0] = 1; -+ /* Didn't match before, not going to match now */ -+ return info->invert; -+ } -+ } -+ -+ /* If looking for "unknown", then never match. "Unknown" means that -+ we've given up; we're still trying with these packets. */ -+ if(!strcmp(info->protocol, "unknown")) { -+ pattern_result = 0; -+ /* If the regexp failed to compile, don't bother running it */ -+ } else if(comppattern && regexec(comppattern, master_conntrack->layer7.app_data)) { -+ DPRINTK("layer7: regexec positive: %s!\n", info->protocol); -+ pattern_result = 1; -+ } else pattern_result = 0; -+ -+ if(pattern_result) { -+ WRITE_LOCK(&ct_lock); -+ master_conntrack->layer7.app_proto = kmalloc(strlen(info->protocol)+1, GFP_ATOMIC); -+ if(!master_conntrack->layer7.app_proto){ -+ if (net_ratelimit()) -+ printk(KERN_ERR "layer7: out of memory in match, bailing.\n"); -+ WRITE_UNLOCK(&ct_lock); -+ return (pattern_result ^ info->invert); -+ } -+ strcpy(master_conntrack->layer7.app_proto, info->protocol); -+ WRITE_UNLOCK(&ct_lock); -+ } -+ -+ /* mark the packet seen */ -+ skb->cb[0] = 1; -+ -+ return (pattern_result ^ info->invert); -+} -+ -+static int checkentry(const char *tablename, const struct ipt_ip *ip, -+ void *matchinfo, unsigned int matchsize, unsigned int hook_mask) -+{ -+ if (matchsize != IPT_ALIGN(sizeof(struct ipt_layer7_info))) -+ return 0; -+ return 1; -+} -+ -+static struct ipt_match layer7_match = { -+ .name = "layer7", -+ .match = &match, -+ .checkentry = &checkentry, -+ .me = THIS_MODULE -+}; -+ -+/* taken from drivers/video/modedb.c */ -+static int my_atoi(const char *s) -+{ -+ int val = 0; -+ -+ for (;; s++) { -+ switch (*s) { -+ case '0'...'9': -+ val = 10*val+(*s-'0'); -+ break; -+ default: -+ return val; -+ } -+ } -+} -+ -+/* write out num_packets to userland. */ -+static int layer7_read_proc(char* page, char ** start, off_t off, int count, -+ int* eof, void * data) -+{ -+ if(num_packets > 99 && net_ratelimit()) -+ printk(KERN_ERR "layer7: NOT REACHED. num_packets too big\n"); -+ -+ page[0] = num_packets/10 + '0'; -+ page[1] = num_packets%10 + '0'; -+ page[2] = '\n'; -+ page[3] = '\0'; -+ -+ *eof=1; -+ -+ return 3; -+} -+ -+/* Read in num_packets from userland */ -+static int layer7_write_proc(struct file* file, const char* buffer, -+ unsigned long count, void *data) -+{ -+ char * foo = kmalloc(count, GFP_ATOMIC); -+ -+ if(!foo){ -+ if (net_ratelimit()) -+ printk(KERN_ERR "layer7: out of memory, bailing. num_packets unchanged.\n"); -+ return count; -+ } -+ -+ copy_from_user(foo, buffer, count); -+ -+ num_packets = my_atoi(foo); -+ kfree (foo); -+ -+ /* This has an arbitrary limit to make the math easier. I'm lazy. -+ But anyway, 99 is a LOT! If you want more, you're doing it wrong! */ -+ if(num_packets > 99) { -+ printk(KERN_WARNING "layer7: num_packets can't be > 99.\n"); -+ num_packets = 99; -+ } else if(num_packets < 1) { -+ printk(KERN_WARNING "layer7: num_packets can't be < 1.\n"); -+ num_packets = 1; -+ } -+ -+ return count; -+} -+ -+/* register the proc file */ -+static void layer7_init_proc(void) -+{ -+ struct proc_dir_entry* entry; -+ entry = create_proc_entry("layer7_numpackets", 0644, proc_net); -+ entry->read_proc = layer7_read_proc; -+ entry->write_proc = layer7_write_proc; -+} -+ -+static void layer7_cleanup_proc(void) -+{ -+ remove_proc_entry("layer7_numpackets", proc_net); -+} -+ -+static int __init init(void) -+{ -+ layer7_init_proc(); -+ if(maxdatalen < 1) { -+ printk(KERN_WARNING "layer7: maxdatalen can't be < 1, using 1\n"); -+ maxdatalen = 1; -+ } -+ /* This is not a hard limit. It's just here to prevent people from -+ bringing their slow machines to a grinding halt. */ -+ else if(maxdatalen > 65536) { -+ printk(KERN_WARNING "layer7: maxdatalen can't be > 65536, using 65536\n"); -+ maxdatalen = 65536; -+ } -+ return ipt_register_match(&layer7_match); -+} -+ -+static void __exit fini(void) -+{ -+ layer7_cleanup_proc(); -+ ipt_unregister_match(&layer7_match); -+} -+ -+module_init(init); -+module_exit(fini); ---- /dev/null -+++ b/net/ipv4/netfilter/regexp/regexp.c -@@ -0,0 +1,1195 @@ -+/* -+ * regcomp and regexec -- regsub and regerror are elsewhere -+ * @(#)regexp.c 1.3 of 18 April 87 -+ * -+ * Copyright (c) 1986 by University of Toronto. -+ * Written by Henry Spencer. Not derived from licensed software. -+ * -+ * Permission is granted to anyone to use this software for any -+ * purpose on any computer system, and to redistribute it freely, -+ * subject to the following restrictions: -+ * -+ * 1. The author is not responsible for the consequences of use of -+ * this software, no matter how awful, even if they arise -+ * from defects in it. -+ * -+ * 2. The origin of this software must not be misrepresented, either -+ * by explicit claim or by omission. -+ * -+ * 3. Altered versions must be plainly marked as such, and must not -+ * be misrepresented as being the original software. -+ * -+ * Beware that some of this code is subtly aware of the way operator -+ * precedence is structured in regular expressions. Serious changes in -+ * regular-expression syntax might require a total rethink. -+ * -+ * This code was modified by Ethan Sommer to work within the kernel -+ * (it now uses kmalloc etc..) -+ * -+ * Modified slightly by Matthew Strait to use more modern C. -+ */ -+ -+#include "regexp.h" -+#include "regmagic.h" -+ -+/* added by ethan and matt. Lets it work in both kernel and user space. -+(So iptables can use it, for instance.) Yea, it goes both ways... */ -+#if __KERNEL__ -+ #define malloc(foo) kmalloc(foo,GFP_ATOMIC) -+#else -+ #define printk(format,args...) printf(format,##args) -+#endif -+ -+void regerror(char * s) -+{ -+ printk("<3>Regexp: %s\n", s); -+ /* NOTREACHED */ -+} -+ -+/* -+ * The "internal use only" fields in regexp.h are present to pass info from -+ * compile to execute that permits the execute phase to run lots faster on -+ * simple cases. They are: -+ * -+ * regstart char that must begin a match; '\0' if none obvious -+ * reganch is the match anchored (at beginning-of-line only)? -+ * regmust string (pointer into program) that match must include, or NULL -+ * regmlen length of regmust string -+ * -+ * Regstart and reganch permit very fast decisions on suitable starting points -+ * for a match, cutting down the work a lot. Regmust permits fast rejection -+ * of lines that cannot possibly match. The regmust tests are costly enough -+ * that regcomp() supplies a regmust only if the r.e. contains something -+ * potentially expensive (at present, the only such thing detected is * or + -+ * at the start of the r.e., which can involve a lot of backup). Regmlen is -+ * supplied because the test in regexec() needs it and regcomp() is computing -+ * it anyway. -+ */ -+ -+/* -+ * Structure for regexp "program". This is essentially a linear encoding -+ * of a nondeterministic finite-state machine (aka syntax charts or -+ * "railroad normal form" in parsing technology). Each node is an opcode -+ * plus a "next" pointer, possibly plus an operand. "Next" pointers of -+ * all nodes except BRANCH implement concatenation; a "next" pointer with -+ * a BRANCH on both ends of it is connecting two alternatives. (Here we -+ * have one of the subtle syntax dependencies: an individual BRANCH (as -+ * opposed to a collection of them) is never concatenated with anything -+ * because of operator precedence.) The operand of some types of node is -+ * a literal string; for others, it is a node leading into a sub-FSM. In -+ * particular, the operand of a BRANCH node is the first node of the branch. -+ * (NB this is *not* a tree structure: the tail of the branch connects -+ * to the thing following the set of BRANCHes.) The opcodes are: -+ */ -+ -+/* definition number opnd? meaning */ -+#define END 0 /* no End of program. */ -+#define BOL 1 /* no Match "" at beginning of line. */ -+#define EOL 2 /* no Match "" at end of line. */ -+#define ANY 3 /* no Match any one character. */ -+#define ANYOF 4 /* str Match any character in this string. */ -+#define ANYBUT 5 /* str Match any character not in this string. */ -+#define BRANCH 6 /* node Match this alternative, or the next... */ -+#define BACK 7 /* no Match "", "next" ptr points backward. */ -+#define EXACTLY 8 /* str Match this string. */ -+#define NOTHING 9 /* no Match empty string. */ -+#define STAR 10 /* node Match this (simple) thing 0 or more times. */ -+#define PLUS 11 /* node Match this (simple) thing 1 or more times. */ -+#define OPEN 20 /* no Mark this point in input as start of #n. */ -+ /* OPEN+1 is number 1, etc. */ -+#define CLOSE 30 /* no Analogous to OPEN. */ -+ -+/* -+ * Opcode notes: -+ * -+ * BRANCH The set of branches constituting a single choice are hooked -+ * together with their "next" pointers, since precedence prevents -+ * anything being concatenated to any individual branch. The -+ * "next" pointer of the last BRANCH in a choice points to the -+ * thing following the whole choice. This is also where the -+ * final "next" pointer of each individual branch points; each -+ * branch starts with the operand node of a BRANCH node. -+ * -+ * BACK Normal "next" pointers all implicitly point forward; BACK -+ * exists to make loop structures possible. -+ * -+ * STAR,PLUS '?', and complex '*' and '+', are implemented as circular -+ * BRANCH structures using BACK. Simple cases (one character -+ * per match) are implemented with STAR and PLUS for speed -+ * and to minimize recursive plunges. -+ * -+ * OPEN,CLOSE ...are numbered at compile time. -+ */ -+ -+/* -+ * A node is one char of opcode followed by two chars of "next" pointer. -+ * "Next" pointers are stored as two 8-bit pieces, high order first. The -+ * value is a positive offset from the opcode of the node containing it. -+ * An operand, if any, simply follows the node. (Note that much of the -+ * code generation knows about this implicit relationship.) -+ * -+ * Using two bytes for the "next" pointer is vast overkill for most things, -+ * but allows patterns to get big without disasters. -+ */ -+#define OP(p) (*(p)) -+#define NEXT(p) (((*((p)+1)&0377)<<8) + (*((p)+2)&0377)) -+#define OPERAND(p) ((p) + 3) -+ -+/* -+ * See regmagic.h for one further detail of program structure. -+ */ -+ -+ -+/* -+ * Utility definitions. -+ */ -+#ifndef CHARBITS -+#define UCHARAT(p) ((int)*(unsigned char *)(p)) -+#else -+#define UCHARAT(p) ((int)*(p)&CHARBITS) -+#endif -+ -+#define FAIL(m) { regerror(m); return(NULL); } -+#define ISMULT(c) ((c) == '*' || (c) == '+' || (c) == '?') -+#define META "^$.[()|?+*\\" -+ -+/* -+ * Flags to be passed up and down. -+ */ -+#define HASWIDTH 01 /* Known never to match null string. */ -+#define SIMPLE 02 /* Simple enough to be STAR/PLUS operand. */ -+#define SPSTART 04 /* Starts with * or +. */ -+#define WORST 0 /* Worst case. */ -+ -+/* -+ * Global work variables for regcomp(). -+ */ -+static char *regparse; /* Input-scan pointer. */ -+static int regnpar; /* () count. */ -+static char regdummy; -+static char *regcode; /* Code-emit pointer; ®dummy = don't. */ -+static long regsize; /* Code size. */ -+ -+/* -+ * Forward declarations for regcomp()'s friends. -+ */ -+#ifndef STATIC -+#define STATIC static -+#endif -+STATIC char *reg(int paren,int *flagp); -+STATIC char *regbranch(int *flagp); -+STATIC char *regpiece(int *flagp); -+STATIC char *regatom(int *flagp); -+STATIC char *regnode(char op); -+STATIC char *regnext(char *p); -+STATIC void regc(char b); -+STATIC void reginsert(char op, char *opnd); -+STATIC void regtail(char *p, char *val); -+STATIC void regoptail(char *p, char *val); -+ -+ -+__kernel_size_t my_strcspn(const char *s1,const char *s2) -+{ -+ char *scan1; -+ char *scan2; -+ int count; -+ -+ count = 0; -+ for (scan1 = (char *)s1; *scan1 != '\0'; scan1++) { -+ for (scan2 = (char *)s2; *scan2 != '\0';) /* ++ moved down. */ -+ if (*scan1 == *scan2++) -+ return(count); -+ count++; -+ } -+ return(count); -+} -+ -+/* -+ - regcomp - compile a regular expression into internal code -+ * -+ * We can't allocate space until we know how big the compiled form will be, -+ * but we can't compile it (and thus know how big it is) until we've got a -+ * place to put the code. So we cheat: we compile it twice, once with code -+ * generation turned off and size counting turned on, and once "for real". -+ * This also means that we don't allocate space until we are sure that the -+ * thing really will compile successfully, and we never have to move the -+ * code and thus invalidate pointers into it. (Note that it has to be in -+ * one piece because free() must be able to free it all.) -+ * -+ * Beware that the optimization-preparation code in here knows about some -+ * of the structure of the compiled regexp. -+ */ -+regexp * -+regcomp(char *exp,int *patternsize) -+{ -+ register regexp *r; -+ register char *scan; -+ register char *longest; -+ register int len; -+ int flags; -+ /* commented out by ethan -+ extern char *malloc(); -+ */ -+ -+ if (exp == NULL) -+ FAIL("NULL argument"); -+ -+ /* First pass: determine size, legality. */ -+ regparse = exp; -+ regnpar = 1; -+ regsize = 0L; -+ regcode = ®dummy; -+ regc(MAGIC); -+ if (reg(0, &flags) == NULL) -+ return(NULL); -+ -+ /* Small enough for pointer-storage convention? */ -+ if (regsize >= 32767L) /* Probably could be 65535L. */ -+ FAIL("regexp too big"); -+ -+ /* Allocate space. */ -+ *patternsize=sizeof(regexp) + (unsigned)regsize; -+ r = (regexp *)malloc(sizeof(regexp) + (unsigned)regsize); -+ if (r == NULL) -+ FAIL("out of space"); -+ -+ /* Second pass: emit code. */ -+ regparse = exp; -+ regnpar = 1; -+ regcode = r->program; -+ regc(MAGIC); -+ if (reg(0, &flags) == NULL) -+ return(NULL); -+ -+ /* Dig out information for optimizations. */ -+ r->regstart = '\0'; /* Worst-case defaults. */ -+ r->reganch = 0; -+ r->regmust = NULL; -+ r->regmlen = 0; -+ scan = r->program+1; /* First BRANCH. */ -+ if (OP(regnext(scan)) == END) { /* Only one top-level choice. */ -+ scan = OPERAND(scan); -+ -+ /* Starting-point info. */ -+ if (OP(scan) == EXACTLY) -+ r->regstart = *OPERAND(scan); -+ else if (OP(scan) == BOL) -+ r->reganch++; -+ -+ /* -+ * If there's something expensive in the r.e., find the -+ * longest literal string that must appear and make it the -+ * regmust. Resolve ties in favor of later strings, since -+ * the regstart check works with the beginning of the r.e. -+ * and avoiding duplication strengthens checking. Not a -+ * strong reason, but sufficient in the absence of others. -+ */ -+ if (flags&SPSTART) { -+ longest = NULL; -+ len = 0; -+ for (; scan != NULL; scan = regnext(scan)) -+ if (OP(scan) == EXACTLY && strlen(OPERAND(scan)) >= len) { -+ longest = OPERAND(scan); -+ len = strlen(OPERAND(scan)); -+ } -+ r->regmust = longest; -+ r->regmlen = len; -+ } -+ } -+ -+ return(r); -+} -+ -+/* -+ - reg - regular expression, i.e. main body or parenthesized thing -+ * -+ * Caller must absorb opening parenthesis. -+ * -+ * Combining parenthesis handling with the base level of regular expression -+ * is a trifle forced, but the need to tie the tails of the branches to what -+ * follows makes it hard to avoid. -+ */ -+static char * -+reg(int paren, int *flagp /* Parenthesized? */ ) -+{ -+ register char *ret; -+ register char *br; -+ register char *ender; -+ register int parno = 0; /* 0 makes gcc happy */ -+ int flags; -+ -+ *flagp = HASWIDTH; /* Tentatively. */ -+ -+ /* Make an OPEN node, if parenthesized. */ -+ if (paren) { -+ if (regnpar >= NSUBEXP) -+ FAIL("too many ()"); -+ parno = regnpar; -+ regnpar++; -+ ret = regnode(OPEN+parno); -+ } else -+ ret = NULL; -+ -+ /* Pick up the branches, linking them together. */ -+ br = regbranch(&flags); -+ if (br == NULL) -+ return(NULL); -+ if (ret != NULL) -+ regtail(ret, br); /* OPEN -> first. */ -+ else -+ ret = br; -+ if (!(flags&HASWIDTH)) -+ *flagp &= ~HASWIDTH; -+ *flagp |= flags&SPSTART; -+ while (*regparse == '|') { -+ regparse++; -+ br = regbranch(&flags); -+ if (br == NULL) -+ return(NULL); -+ regtail(ret, br); /* BRANCH -> BRANCH. */ -+ if (!(flags&HASWIDTH)) -+ *flagp &= ~HASWIDTH; -+ *flagp |= flags&SPSTART; -+ } -+ -+ /* Make a closing node, and hook it on the end. */ -+ ender = regnode((paren) ? CLOSE+parno : END); -+ regtail(ret, ender); -+ -+ /* Hook the tails of the branches to the closing node. */ -+ for (br = ret; br != NULL; br = regnext(br)) -+ regoptail(br, ender); -+ -+ /* Check for proper termination. */ -+ if (paren && *regparse++ != ')') { -+ FAIL("unmatched ()"); -+ } else if (!paren && *regparse != '\0') { -+ if (*regparse == ')') { -+ FAIL("unmatched ()"); -+ } else -+ FAIL("junk on end"); /* "Can't happen". */ -+ /* NOTREACHED */ -+ } -+ -+ return(ret); -+} -+ -+/* -+ - regbranch - one alternative of an | operator -+ * -+ * Implements the concatenation operator. -+ */ -+static char * -+regbranch(int *flagp) -+{ -+ register char *ret; -+ register char *chain; -+ register char *latest; -+ int flags; -+ -+ *flagp = WORST; /* Tentatively. */ -+ -+ ret = regnode(BRANCH); -+ chain = NULL; -+ while (*regparse != '\0' && *regparse != '|' && *regparse != ')') { -+ latest = regpiece(&flags); -+ if (latest == NULL) -+ return(NULL); -+ *flagp |= flags&HASWIDTH; -+ if (chain == NULL) /* First piece. */ -+ *flagp |= flags&SPSTART; -+ else -+ regtail(chain, latest); -+ chain = latest; -+ } -+ if (chain == NULL) /* Loop ran zero times. */ -+ (void) regnode(NOTHING); -+ -+ return(ret); -+} -+ -+/* -+ - regpiece - something followed by possible [*+?] -+ * -+ * Note that the branching code sequences used for ? and the general cases -+ * of * and + are somewhat optimized: they use the same NOTHING node as -+ * both the endmarker for their branch list and the body of the last branch. -+ * It might seem that this node could be dispensed with entirely, but the -+ * endmarker role is not redundant. -+ */ -+static char * -+regpiece(int *flagp) -+{ -+ register char *ret; -+ register char op; -+ register char *next; -+ int flags; -+ -+ ret = regatom(&flags); -+ if (ret == NULL) -+ return(NULL); -+ -+ op = *regparse; -+ if (!ISMULT(op)) { -+ *flagp = flags; -+ return(ret); -+ } -+ -+ if (!(flags&HASWIDTH) && op != '?') -+ FAIL("*+ operand could be empty"); -+ *flagp = (op != '+') ? (WORST|SPSTART) : (WORST|HASWIDTH); -+ -+ if (op == '*' && (flags&SIMPLE)) -+ reginsert(STAR, ret); -+ else if (op == '*') { -+ /* Emit x* as (x&|), where & means "self". */ -+ reginsert(BRANCH, ret); /* Either x */ -+ regoptail(ret, regnode(BACK)); /* and loop */ -+ regoptail(ret, ret); /* back */ -+ regtail(ret, regnode(BRANCH)); /* or */ -+ regtail(ret, regnode(NOTHING)); /* null. */ -+ } else if (op == '+' && (flags&SIMPLE)) -+ reginsert(PLUS, ret); -+ else if (op == '+') { -+ /* Emit x+ as x(&|), where & means "self". */ -+ next = regnode(BRANCH); /* Either */ -+ regtail(ret, next); -+ regtail(regnode(BACK), ret); /* loop back */ -+ regtail(next, regnode(BRANCH)); /* or */ -+ regtail(ret, regnode(NOTHING)); /* null. */ -+ } else if (op == '?') { -+ /* Emit x? as (x|) */ -+ reginsert(BRANCH, ret); /* Either x */ -+ regtail(ret, regnode(BRANCH)); /* or */ -+ next = regnode(NOTHING); /* null. */ -+ regtail(ret, next); -+ regoptail(ret, next); -+ } -+ regparse++; -+ if (ISMULT(*regparse)) -+ FAIL("nested *?+"); -+ -+ return(ret); -+} -+ -+/* -+ - regatom - the lowest level -+ * -+ * Optimization: gobbles an entire sequence of ordinary characters so that -+ * it can turn them into a single node, which is smaller to store and -+ * faster to run. Backslashed characters are exceptions, each becoming a -+ * separate node; the code is simpler that way and it's not worth fixing. -+ */ -+static char * -+regatom(int *flagp) -+{ -+ register char *ret; -+ int flags; -+ -+ *flagp = WORST; /* Tentatively. */ -+ -+ switch (*regparse++) { -+ case '^': -+ ret = regnode(BOL); -+ break; -+ case '$': -+ ret = regnode(EOL); -+ break; -+ case '.': -+ ret = regnode(ANY); -+ *flagp |= HASWIDTH|SIMPLE; -+ break; -+ case '[': { -+ register int class; -+ register int classend; -+ -+ if (*regparse == '^') { /* Complement of range. */ -+ ret = regnode(ANYBUT); -+ regparse++; -+ } else -+ ret = regnode(ANYOF); -+ if (*regparse == ']' || *regparse == '-') -+ regc(*regparse++); -+ while (*regparse != '\0' && *regparse != ']') { -+ if (*regparse == '-') { -+ regparse++; -+ if (*regparse == ']' || *regparse == '\0') -+ regc('-'); -+ else { -+ class = UCHARAT(regparse-2)+1; -+ classend = UCHARAT(regparse); -+ if (class > classend+1) -+ FAIL("invalid [] range"); -+ for (; class <= classend; class++) -+ regc(class); -+ regparse++; -+ } -+ } else -+ regc(*regparse++); -+ } -+ regc('\0'); -+ if (*regparse != ']') -+ FAIL("unmatched []"); -+ regparse++; -+ *flagp |= HASWIDTH|SIMPLE; -+ } -+ break; -+ case '(': -+ ret = reg(1, &flags); -+ if (ret == NULL) -+ return(NULL); -+ *flagp |= flags&(HASWIDTH|SPSTART); -+ break; -+ case '\0': -+ case '|': -+ case ')': -+ FAIL("internal urp"); /* Supposed to be caught earlier. */ -+ break; -+ case '?': -+ case '+': -+ case '*': -+ FAIL("?+* follows nothing"); -+ break; -+ case '\\': -+ if (*regparse == '\0') -+ FAIL("trailing \\"); -+ ret = regnode(EXACTLY); -+ regc(*regparse++); -+ regc('\0'); -+ *flagp |= HASWIDTH|SIMPLE; -+ break; -+ default: { -+ register int len; -+ register char ender; -+ -+ regparse--; -+ len = my_strcspn((const char *)regparse, (const char *)META); -+ if (len <= 0) -+ FAIL("internal disaster"); -+ ender = *(regparse+len); -+ if (len > 1 && ISMULT(ender)) -+ len--; /* Back off clear of ?+* operand. */ -+ *flagp |= HASWIDTH; -+ if (len == 1) -+ *flagp |= SIMPLE; -+ ret = regnode(EXACTLY); -+ while (len > 0) { -+ regc(*regparse++); -+ len--; -+ } -+ regc('\0'); -+ } -+ break; -+ } -+ -+ return(ret); -+} -+ -+/* -+ - regnode - emit a node -+ */ -+static char * /* Location. */ -+regnode(char op) -+{ -+ register char *ret; -+ register char *ptr; -+ -+ ret = regcode; -+ if (ret == ®dummy) { -+ regsize += 3; -+ return(ret); -+ } -+ -+ ptr = ret; -+ *ptr++ = op; -+ *ptr++ = '\0'; /* Null "next" pointer. */ -+ *ptr++ = '\0'; -+ regcode = ptr; -+ -+ return(ret); -+} -+ -+/* -+ - regc - emit (if appropriate) a byte of code -+ */ -+static void -+regc(char b) -+{ -+ if (regcode != ®dummy) -+ *regcode++ = b; -+ else -+ regsize++; -+} -+ -+/* -+ - reginsert - insert an operator in front of already-emitted operand -+ * -+ * Means relocating the operand. -+ */ -+static void -+reginsert(char op, char* opnd) -+{ -+ register char *src; -+ register char *dst; -+ register char *place; -+ -+ if (regcode == ®dummy) { -+ regsize += 3; -+ return; -+ } -+ -+ src = regcode; -+ regcode += 3; -+ dst = regcode; -+ while (src > opnd) -+ *--dst = *--src; -+ -+ place = opnd; /* Op node, where operand used to be. */ -+ *place++ = op; -+ *place++ = '\0'; -+ *place++ = '\0'; -+} -+ -+/* -+ - regtail - set the next-pointer at the end of a node chain -+ */ -+static void -+regtail(char *p, char *val) -+{ -+ register char *scan; -+ register char *temp; -+ register int offset; -+ -+ if (p == ®dummy) -+ return; -+ -+ /* Find last node. */ -+ scan = p; -+ for (;;) { -+ temp = regnext(scan); -+ if (temp == NULL) -+ break; -+ scan = temp; -+ } -+ -+ if (OP(scan) == BACK) -+ offset = scan - val; -+ else -+ offset = val - scan; -+ *(scan+1) = (offset>>8)&0377; -+ *(scan+2) = offset&0377; -+} -+ -+/* -+ - regoptail - regtail on operand of first argument; nop if operandless -+ */ -+static void -+regoptail(char *p, char *val) -+{ -+ /* "Operandless" and "op != BRANCH" are synonymous in practice. */ -+ if (p == NULL || p == ®dummy || OP(p) != BRANCH) -+ return; -+ regtail(OPERAND(p), val); -+} -+ -+/* -+ * regexec and friends -+ */ -+ -+/* -+ * Global work variables for regexec(). -+ */ -+static char *reginput; /* String-input pointer. */ -+static char *regbol; /* Beginning of input, for ^ check. */ -+static char **regstartp; /* Pointer to startp array. */ -+static char **regendp; /* Ditto for endp. */ -+ -+/* -+ * Forwards. -+ */ -+STATIC int regtry(regexp *prog, char *string); -+STATIC int regmatch(char *prog); -+STATIC int regrepeat(char *p); -+ -+#ifdef DEBUG -+int regnarrate = 0; -+void regdump(); -+STATIC char *regprop(char *op); -+#endif -+ -+/* -+ - regexec - match a regexp against a string -+ */ -+int -+regexec(regexp *prog, char *string) -+{ -+ register char *s; -+ -+ /* Be paranoid... */ -+ if (prog == NULL || string == NULL) { -+ printk("<3>Regexp: NULL parameter\n"); -+ return(0); -+ } -+ -+ /* Check validity of program. */ -+ if (UCHARAT(prog->program) != MAGIC) { -+ printk("<3>Regexp: corrupted program\n"); -+ return(0); -+ } -+ -+ /* If there is a "must appear" string, look for it. */ -+ if (prog->regmust != NULL) { -+ s = string; -+ while ((s = strchr(s, prog->regmust[0])) != NULL) { -+ if (strncmp(s, prog->regmust, prog->regmlen) == 0) -+ break; /* Found it. */ -+ s++; -+ } -+ if (s == NULL) /* Not present. */ -+ return(0); -+ } -+ -+ /* Mark beginning of line for ^ . */ -+ regbol = string; -+ -+ /* Simplest case: anchored match need be tried only once. */ -+ if (prog->reganch) -+ return(regtry(prog, string)); -+ -+ /* Messy cases: unanchored match. */ -+ s = string; -+ if (prog->regstart != '\0') -+ /* We know what char it must start with. */ -+ while ((s = strchr(s, prog->regstart)) != NULL) { -+ if (regtry(prog, s)) -+ return(1); -+ s++; -+ } -+ else -+ /* We don't -- general case. */ -+ do { -+ if (regtry(prog, s)) -+ return(1); -+ } while (*s++ != '\0'); -+ -+ /* Failure. */ -+ return(0); -+} -+ -+/* -+ - regtry - try match at specific point -+ */ -+static int /* 0 failure, 1 success */ -+regtry(regexp *prog, char *string) -+{ -+ register int i; -+ register char **sp; -+ register char **ep; -+ -+ reginput = string; -+ regstartp = prog->startp; -+ regendp = prog->endp; -+ -+ sp = prog->startp; -+ ep = prog->endp; -+ for (i = NSUBEXP; i > 0; i--) { -+ *sp++ = NULL; -+ *ep++ = NULL; -+ } -+ if (regmatch(prog->program + 1)) { -+ prog->startp[0] = string; -+ prog->endp[0] = reginput; -+ return(1); -+ } else -+ return(0); -+} -+ -+/* -+ - regmatch - main matching routine -+ * -+ * Conceptually the strategy is simple: check to see whether the current -+ * node matches, call self recursively to see whether the rest matches, -+ * and then act accordingly. In practice we make some effort to avoid -+ * recursion, in particular by going through "ordinary" nodes (that don't -+ * need to know whether the rest of the match failed) by a loop instead of -+ * by recursion. -+ */ -+static int /* 0 failure, 1 success */ -+regmatch(char *prog) -+{ -+ register char *scan = prog; /* Current node. */ -+ char *next; /* Next node. */ -+ -+#ifdef DEBUG -+ if (scan != NULL && regnarrate) -+ fprintf(stderr, "%s(\n", regprop(scan)); -+#endif -+ while (scan != NULL) { -+#ifdef DEBUG -+ if (regnarrate) -+ fprintf(stderr, "%s...\n", regprop(scan)); -+#endif -+ next = regnext(scan); -+ -+ switch (OP(scan)) { -+ case BOL: -+ if (reginput != regbol) -+ return(0); -+ break; -+ case EOL: -+ if (*reginput != '\0') -+ return(0); -+ break; -+ case ANY: -+ if (*reginput == '\0') -+ return(0); -+ reginput++; -+ break; -+ case EXACTLY: { -+ register int len; -+ register char *opnd; -+ -+ opnd = OPERAND(scan); -+ /* Inline the first character, for speed. */ -+ if (*opnd != *reginput) -+ return(0); -+ len = strlen(opnd); -+ if (len > 1 && strncmp(opnd, reginput, len) != 0) -+ return(0); -+ reginput += len; -+ } -+ break; -+ case ANYOF: -+ if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) == NULL) -+ return(0); -+ reginput++; -+ break; -+ case ANYBUT: -+ if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) != NULL) -+ return(0); -+ reginput++; -+ break; -+ case NOTHING: -+ case BACK: -+ break; -+ case OPEN+1: -+ case OPEN+2: -+ case OPEN+3: -+ case OPEN+4: -+ case OPEN+5: -+ case OPEN+6: -+ case OPEN+7: -+ case OPEN+8: -+ case OPEN+9: { -+ register int no; -+ register char *save; -+ -+ no = OP(scan) - OPEN; -+ save = reginput; -+ -+ if (regmatch(next)) { -+ /* -+ * Don't set startp if some later -+ * invocation of the same parentheses -+ * already has. -+ */ -+ if (regstartp[no] == NULL) -+ regstartp[no] = save; -+ return(1); -+ } else -+ return(0); -+ } -+ break; -+ case CLOSE+1: -+ case CLOSE+2: -+ case CLOSE+3: -+ case CLOSE+4: -+ case CLOSE+5: -+ case CLOSE+6: -+ case CLOSE+7: -+ case CLOSE+8: -+ case CLOSE+9: -+ { -+ register int no; -+ register char *save; -+ -+ no = OP(scan) - CLOSE; -+ save = reginput; -+ -+ if (regmatch(next)) { -+ /* -+ * Don't set endp if some later -+ * invocation of the same parentheses -+ * already has. -+ */ -+ if (regendp[no] == NULL) -+ regendp[no] = save; -+ return(1); -+ } else -+ return(0); -+ } -+ break; -+ case BRANCH: { -+ register char *save; -+ -+ if (OP(next) != BRANCH) /* No choice. */ -+ next = OPERAND(scan); /* Avoid recursion. */ -+ else { -+ do { -+ save = reginput; -+ if (regmatch(OPERAND(scan))) -+ return(1); -+ reginput = save; -+ scan = regnext(scan); -+ } while (scan != NULL && OP(scan) == BRANCH); -+ return(0); -+ /* NOTREACHED */ -+ } -+ } -+ break; -+ case STAR: -+ case PLUS: { -+ register char nextch; -+ register int no; -+ register char *save; -+ register int min; -+ -+ /* -+ * Lookahead to avoid useless match attempts -+ * when we know what character comes next. -+ */ -+ nextch = '\0'; -+ if (OP(next) == EXACTLY) -+ nextch = *OPERAND(next); -+ min = (OP(scan) == STAR) ? 0 : 1; -+ save = reginput; -+ no = regrepeat(OPERAND(scan)); -+ while (no >= min) { -+ /* If it could work, try it. */ -+ if (nextch == '\0' || *reginput == nextch) -+ if (regmatch(next)) -+ return(1); -+ /* Couldn't or didn't -- back up. */ -+ no--; -+ reginput = save + no; -+ } -+ return(0); -+ } -+ break; -+ case END: -+ return(1); /* Success! */ -+ break; -+ default: -+ printk("<3>Regexp: memory corruption\n"); -+ return(0); -+ break; -+ } -+ -+ scan = next; -+ } -+ -+ /* -+ * We get here only if there's trouble -- normally "case END" is -+ * the terminating point. -+ */ -+ printk("<3>Regexp: corrupted pointers\n"); -+ return(0); -+} -+ -+/* -+ - regrepeat - repeatedly match something simple, report how many -+ */ -+static int -+regrepeat(char *p) -+{ -+ register int count = 0; -+ register char *scan; -+ register char *opnd; -+ -+ scan = reginput; -+ opnd = OPERAND(p); -+ switch (OP(p)) { -+ case ANY: -+ count = strlen(scan); -+ scan += count; -+ break; -+ case EXACTLY: -+ while (*opnd == *scan) { -+ count++; -+ scan++; -+ } -+ break; -+ case ANYOF: -+ while (*scan != '\0' && strchr(opnd, *scan) != NULL) { -+ count++; -+ scan++; -+ } -+ break; -+ case ANYBUT: -+ while (*scan != '\0' && strchr(opnd, *scan) == NULL) { -+ count++; -+ scan++; -+ } -+ break; -+ default: /* Oh dear. Called inappropriately. */ -+ printk("<3>Regexp: internal foulup\n"); -+ count = 0; /* Best compromise. */ -+ break; -+ } -+ reginput = scan; -+ -+ return(count); -+} -+ -+/* -+ - regnext - dig the "next" pointer out of a node -+ */ -+static char* -+regnext(char *p) -+{ -+ register int offset; -+ -+ if (p == ®dummy) -+ return(NULL); -+ -+ offset = NEXT(p); -+ if (offset == 0) -+ return(NULL); -+ -+ if (OP(p) == BACK) -+ return(p-offset); -+ else -+ return(p+offset); -+} -+ -+#ifdef DEBUG -+ -+STATIC char *regprop(); -+ -+/* -+ - regdump - dump a regexp onto stdout in vaguely comprehensible form -+ */ -+void -+regdump(regexp *r) -+{ -+ register char *s; -+ register char op = EXACTLY; /* Arbitrary non-END op. */ -+ register char *next; -+ /* extern char *strchr(); */ -+ -+ -+ s = r->program + 1; -+ while (op != END) { /* While that wasn't END last time... */ -+ op = OP(s); -+ printf("%2d%s", s-r->program, regprop(s)); /* Where, what. */ -+ next = regnext(s); -+ if (next == NULL) /* Next ptr. */ -+ printf("(0)"); -+ else -+ printf("(%d)", (s-r->program)+(next-s)); -+ s += 3; -+ if (op == ANYOF || op == ANYBUT || op == EXACTLY) { -+ /* Literal string, where present. */ -+ while (*s != '\0') { -+ putchar(*s); -+ s++; -+ } -+ s++; -+ } -+ putchar('\n'); -+ } -+ -+ /* Header fields of interest. */ -+ if (r->regstart != '\0') -+ printf("start `%c' ", r->regstart); -+ if (r->reganch) -+ printf("anchored "); -+ if (r->regmust != NULL) -+ printf("must have \"%s\"", r->regmust); -+ printf("\n"); -+} -+ -+/* -+ - regprop - printable representation of opcode -+ */ -+static char * -+regprop(char *op) -+{ -+#define BUFLEN 50 -+ register char *p; -+ static char buf[BUFLEN]; -+ -+ strcpy(buf, ":"); -+ -+ switch (OP(op)) { -+ case BOL: -+ p = "BOL"; -+ break; -+ case EOL: -+ p = "EOL"; -+ break; -+ case ANY: -+ p = "ANY"; -+ break; -+ case ANYOF: -+ p = "ANYOF"; -+ break; -+ case ANYBUT: -+ p = "ANYBUT"; -+ break; -+ case BRANCH: -+ p = "BRANCH"; -+ break; -+ case EXACTLY: -+ p = "EXACTLY"; -+ break; -+ case NOTHING: -+ p = "NOTHING"; -+ break; -+ case BACK: -+ p = "BACK"; -+ break; -+ case END: -+ p = "END"; -+ break; -+ case OPEN+1: -+ case OPEN+2: -+ case OPEN+3: -+ case OPEN+4: -+ case OPEN+5: -+ case OPEN+6: -+ case OPEN+7: -+ case OPEN+8: -+ case OPEN+9: -+ snprintf(buf+strlen(buf),BUFLEN-strlen(buf), "OPEN%d", OP(op)-OPEN); -+ p = NULL; -+ break; -+ case CLOSE+1: -+ case CLOSE+2: -+ case CLOSE+3: -+ case CLOSE+4: -+ case CLOSE+5: -+ case CLOSE+6: -+ case CLOSE+7: -+ case CLOSE+8: -+ case CLOSE+9: -+ snprintf(buf+strlen(buf),BUFLEN-strlen(buf), "CLOSE%d", OP(op)-CLOSE); -+ p = NULL; -+ break; -+ case STAR: -+ p = "STAR"; -+ break; -+ case PLUS: -+ p = "PLUS"; -+ break; -+ default: -+ printk("<3>Regexp: corrupted opcode\n"); -+ break; -+ } -+ if (p != NULL) -+ strncat(buf, p, BUFLEN-strlen(buf)); -+ return(buf); -+} -+#endif -+ -+ ---- /dev/null -+++ b/net/ipv4/netfilter/regexp/regexp.h -@@ -0,0 +1,40 @@ -+/* -+ * Definitions etc. for regexp(3) routines. -+ * -+ * Caveat: this is V8 regexp(3) [actually, a reimplementation thereof], -+ * not the System V one. -+ */ -+ -+#ifndef REGEXP_H -+#define REGEXP_H -+ -+/* -+http://www.opensource.apple.com/darwinsource/10.3/expect-1/expect/expect.h , -+which contains a version of this library, says: -+ -+ * -+ * NSUBEXP must be at least 10, and no greater than 117 or the parser -+ * will not work properly. -+ * -+ -+However, it looks rather like this library is limited to 10. If you think -+otherwise, let us know. -+*/ -+ -+#define NSUBEXP 10 -+typedef struct regexp { -+ char *startp[NSUBEXP]; -+ char *endp[NSUBEXP]; -+ char regstart; /* Internal use only. */ -+ char reganch; /* Internal use only. */ -+ char *regmust; /* Internal use only. */ -+ int regmlen; /* Internal use only. */ -+ char program[1]; /* Unwarranted chumminess with compiler. */ -+} regexp; -+ -+regexp * regcomp(char *exp, int *patternsize); -+int regexec(regexp *prog, char *string); -+void regsub(regexp *prog, char *source, char *dest); -+void regerror(char *s); -+ -+#endif ---- /dev/null -+++ b/net/ipv4/netfilter/regexp/regmagic.h -@@ -0,0 +1,5 @@ -+/* -+ * The first byte of the regexp internal "program" is actually this magic -+ * number; the start node begins in the second byte. -+ */ -+#define MAGIC 0234 ---- /dev/null -+++ b/net/ipv4/netfilter/regexp/regsub.c -@@ -0,0 +1,95 @@ -+/* -+ * regsub -+ * @(#)regsub.c 1.3 of 2 April 86 -+ * -+ * Copyright (c) 1986 by University of Toronto. -+ * Written by Henry Spencer. Not derived from licensed software. -+ * -+ * Permission is granted to anyone to use this software for any -+ * purpose on any computer system, and to redistribute it freely, -+ * subject to the following restrictions: -+ * -+ * 1. The author is not responsible for the consequences of use of -+ * this software, no matter how awful, even if they arise -+ * from defects in it. -+ * -+ * 2. The origin of this software must not be misrepresented, either -+ * by explicit claim or by omission. -+ * -+ * 3. Altered versions must be plainly marked as such, and must not -+ * be misrepresented as being the original software. -+ * -+ * -+ * This code was modified by Ethan Sommer to work within the kernel -+ * (it now uses kmalloc etc..) -+ * -+ */ -+#include "regexp.h" -+#include "regmagic.h" -+#include <linux/string.h> -+ -+ -+#ifndef CHARBITS -+#define UCHARAT(p) ((int)*(unsigned char *)(p)) -+#else -+#define UCHARAT(p) ((int)*(p)&CHARBITS) -+#endif -+ -+#if 0 -+//void regerror(char * s) -+//{ -+// printk("regexp(3): %s", s); -+// /* NOTREACHED */ -+//} -+#endif -+ -+/* -+ - regsub - perform substitutions after a regexp match -+ */ -+void -+regsub(regexp * prog, char * source, char * dest) -+{ -+ register char *src; -+ register char *dst; -+ register char c; -+ register int no; -+ register int len; -+ -+ /* Not necessary and gcc doesn't like it -MLS */ -+ /*extern char *strncpy();*/ -+ -+ if (prog == NULL || source == NULL || dest == NULL) { -+ regerror("NULL parm to regsub"); -+ return; -+ } -+ if (UCHARAT(prog->program) != MAGIC) { -+ regerror("damaged regexp fed to regsub"); -+ return; -+ } -+ -+ src = source; -+ dst = dest; -+ while ((c = *src++) != '\0') { -+ if (c == '&') -+ no = 0; -+ else if (c == '\\' && '0' <= *src && *src <= '9') -+ no = *src++ - '0'; -+ else -+ no = -1; -+ -+ if (no < 0) { /* Ordinary character. */ -+ if (c == '\\' && (*src == '\\' || *src == '&')) -+ c = *src++; -+ *dst++ = c; -+ } else if (prog->startp[no] != NULL && prog->endp[no] != NULL) { -+ len = prog->endp[no] - prog->startp[no]; -+ (void) strncpy(dst, prog->startp[no], len); -+ dst += len; -+ if (len != 0 && *(dst-1) == '\0') { /* strncpy hit NUL. */ -+ regerror("damaged match string"); -+ return; -+ } -+ } -+ } -+ *dst++ = '\0'; -+} ---- /dev/null -+++ b/include/linux/netfilter/xt_layer7.h -@@ -0,0 +1,14 @@ -+#ifndef _XT_LAYER7_H -+#define _XT_LAYER7_H -+ -+#define MAX_PATTERN_LEN 8192 -+#define MAX_PROTOCOL_LEN 256 -+ -+struct xt_layer7_info { -+ char protocol[MAX_PROTOCOL_LEN]; -+ char pattern[MAX_PATTERN_LEN]; -+ u_int8_t invert; -+ u_int8_t pkt; -+}; -+ -+#endif /* _XT_LAYER7_H */ diff --git a/target/linux/generic-2.4/patches/604-netfilter_maxconn.patch b/target/linux/generic-2.4/patches/604-netfilter_maxconn.patch deleted file mode 100644 index 5414bef..0000000 --- a/target/linux/generic-2.4/patches/604-netfilter_maxconn.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/ipv4/netfilter/ip_conntrack_core.c -+++ b/net/ipv4/netfilter/ip_conntrack_core.c -@@ -1407,7 +1407,7 @@ void ip_conntrack_cleanup(void) - nf_unregister_sockopt(&so_getorigdst); - } - --static int hashsize = 0; -+static int hashsize = 5953; - MODULE_PARM(hashsize, "i"); - - int __init ip_conntrack_init(void) -@@ -1428,7 +1428,7 @@ int __init ip_conntrack_init(void) - if (ip_conntrack_htable_size < 16) - ip_conntrack_htable_size = 16; - } -- ip_conntrack_max = 8 * ip_conntrack_htable_size; -+ ip_conntrack_max = ip_conntrack_htable_size; - - printk("ip_conntrack version %s (%u buckets, %d max)" - " - %Zd bytes per conntrack\n", IP_CONNTRACK_VERSION, diff --git a/target/linux/generic-2.4/patches/605-netfilter_TTL.patch b/target/linux/generic-2.4/patches/605-netfilter_TTL.patch deleted file mode 100644 index 3abff50..0000000 --- a/target/linux/generic-2.4/patches/605-netfilter_TTL.patch +++ /dev/null @@ -1,175 +0,0 @@ ---- a/Documentation/Configure.help -+++ b/Documentation/Configure.help -@@ -3220,6 +3220,15 @@ CONFIG_IP_NF_TARGET_CLASSIFY - If you want to compile it as a module, say M here and read - Documentation/modules.txt. If unsure, say `N'. - -+TTL target support -+CONFIG_IP_NF_TARGET_TTL -+ This option adds a `TTL' target, which enables the user to set -+ the TTL value or increment / decrement the TTL value by a given -+ amount. -+ -+ If you want to compile it as a module, say M here and read -+ Documentation/modules.txt. If unsure, say `N'. -+ - ipchains (2.2-style) support - CONFIG_IP_NF_COMPAT_IPCHAINS - This option places ipchains (with masquerading and redirection ---- /dev/null -+++ b/include/linux/netfilter_ipv4/ipt_TTL.h -@@ -0,0 +1,21 @@ -+/* TTL modification module for IP tables -+ * (C) 2000 by Harald Welte <laforge@gnumonks.org> */ -+ -+#ifndef _IPT_TTL_H -+#define _IPT_TTL_H -+ -+enum { -+ IPT_TTL_SET = 0, -+ IPT_TTL_INC, -+ IPT_TTL_DEC -+}; -+ -+#define IPT_TTL_MAXMODE IPT_TTL_DEC -+ -+struct ipt_TTL_info { -+ u_int8_t mode; -+ u_int8_t ttl; -+}; -+ -+ -+#endif ---- a/net/ipv4/netfilter/Config.in -+++ b/net/ipv4/netfilter/Config.in -@@ -110,6 +110,7 @@ if [ "$CONFIG_IP_NF_IPTABLES" != "n" ]; - dep_tristate ' CLASSIFY target support (EXPERIMENTAL)' CONFIG_IP_NF_TARGET_CLASSIFY $CONFIG_IP_NF_MANGLE - fi - dep_tristate ' LOG target support' CONFIG_IP_NF_TARGET_LOG $CONFIG_IP_NF_IPTABLES -+ dep_tristate ' TTL target support' CONFIG_IP_NF_TARGET_TTL $CONFIG_IP_NF_IPTABLES - dep_tristate ' ULOG target support' CONFIG_IP_NF_TARGET_ULOG $CONFIG_IP_NF_IPTABLES - dep_tristate ' TCPMSS target support' CONFIG_IP_NF_TARGET_TCPMSS $CONFIG_IP_NF_IPTABLES - fi ---- /dev/null -+++ b/net/ipv4/netfilter/ipt_TTL.c -@@ -0,0 +1,110 @@ -+/* TTL modification target for IP tables -+ * (C) 2000 by Harald Welte <laforge@gnumonks.org> -+ * -+ * Version: $Revision: 1.1 $ -+ * -+ * This software is distributed under the terms of GNU GPL -+ */ -+ -+#include <linux/module.h> -+#include <linux/skbuff.h> -+#include <linux/ip.h> -+#include <net/checksum.h> -+ -+#include <linux/netfilter_ipv4/ip_tables.h> -+#include <linux/netfilter_ipv4/ipt_TTL.h> -+ -+MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>"); -+MODULE_DESCRIPTION("IP tables TTL modification module"); -+MODULE_LICENSE("GPL"); -+ -+static unsigned int ipt_ttl_target(struct sk_buff **pskb, unsigned int hooknum, -+ const struct net_device *in, const struct net_device *out, -+ const void *targinfo, void *userinfo) -+{ -+ struct iphdr *iph = (*pskb)->nh.iph; -+ const struct ipt_TTL_info *info = targinfo; -+ u_int16_t diffs[2]; -+ int new_ttl; -+ -+ switch (info->mode) { -+ case IPT_TTL_SET: -+ new_ttl = info->ttl; -+ break; -+ case IPT_TTL_INC: -+ new_ttl = iph->ttl + info->ttl; -+ if (new_ttl > 255) -+ new_ttl = 255; -+ break; -+ case IPT_TTL_DEC: -+ new_ttl = iph->ttl - info->ttl; -+ if (new_ttl < 0) -+ new_ttl = 0; -+ break; -+ default: -+ new_ttl = iph->ttl; -+ break; -+ } -+ -+ if (new_ttl != iph->ttl) { -+ diffs[0] = htons(((unsigned)iph->ttl) << 8) ^ 0xFFFF; -+ iph->ttl = new_ttl; -+ diffs[1] = htons(((unsigned)iph->ttl) << 8); -+ iph->check = csum_fold(csum_partial((char *)diffs, -+ sizeof(diffs), -+ iph->check^0xFFFF)); -+ (*pskb)->nfcache |= NFC_ALTERED; -+ } -+ -+ return IPT_CONTINUE; -+} -+ -+static int ipt_ttl_checkentry(const char *tablename, -+ const struct ipt_entry *e, -+ void *targinfo, -+ unsigned int targinfosize, -+ unsigned int hook_mask) -+{ -+ struct ipt_TTL_info *info = targinfo; -+ -+ if (targinfosize != IPT_ALIGN(sizeof(struct ipt_TTL_info))) { -+ printk(KERN_WARNING "TTL: targinfosize %u != %Zu\n", -+ targinfosize, -+ IPT_ALIGN(sizeof(struct ipt_TTL_info))); -+ return 0; -+ } -+ -+ if (strcmp(tablename, "mangle")) { -+ printk(KERN_WARNING "TTL: can only be called from \"mangle\" table, not \"%s\"\n", tablename); -+ return 0; -+ } -+ -+ if (info->mode > IPT_TTL_MAXMODE) { -+ printk(KERN_WARNING "TTL: invalid or unknown Mode %u\n", -+ info->mode); -+ return 0; -+ } -+ -+ if ((info->mode != IPT_TTL_SET) && (info->ttl == 0)) { -+ printk(KERN_WARNING "TTL: increment/decrement doesn't make sense with value 0\n"); -+ return 0; -+ } -+ -+ return 1; -+} -+ -+static struct ipt_target ipt_TTL = { { NULL, NULL }, "TTL", -+ ipt_ttl_target, ipt_ttl_checkentry, NULL, THIS_MODULE }; -+ -+static int __init init(void) -+{ -+ return ipt_register_target(&ipt_TTL); -+} -+ -+static void __exit fini(void) -+{ -+ ipt_unregister_target(&ipt_TTL); -+} -+ -+module_init(init); -+module_exit(fini); ---- a/net/ipv4/netfilter/Makefile -+++ b/net/ipv4/netfilter/Makefile -@@ -101,6 +101,7 @@ obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += - obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o - obj-$(CONFIG_IP_NF_NAT_SNMP_BASIC) += ip_nat_snmp_basic.o - obj-$(CONFIG_IP_NF_TARGET_LOG) += ipt_LOG.o -+obj-$(CONFIG_IP_NF_TARGET_TTL) += ipt_TTL.o - obj-$(CONFIG_IP_NF_TARGET_ULOG) += ipt_ULOG.o - obj-$(CONFIG_IP_NF_TARGET_TCPMSS) += ipt_TCPMSS.o - diff --git a/target/linux/generic-2.4/patches/606-netfilter_NETMAP.patch b/target/linux/generic-2.4/patches/606-netfilter_NETMAP.patch deleted file mode 100644 index adc0a81..0000000 --- a/target/linux/generic-2.4/patches/606-netfilter_NETMAP.patch +++ /dev/null @@ -1,155 +0,0 @@ ---- a/Documentation/Configure.help -+++ b/Documentation/Configure.help -@@ -3086,6 +3086,17 @@ CONFIG_IP_NF_TARGET_REDIRECT - If you want to compile it as a module, say M here and read - <file:Documentation/modules.txt>. If unsure, say `N'. - -+NETMAP target support -+CONFIG_IP_NF_TARGET_NETMAP -+ NETMAP is an implementation of static 1:1 NAT mapping of network -+ addresses. It maps the network address part, while keeping the -+ host address part intact. It is similar to Fast NAT, except that -+ Netfilter's connection tracking doesn't work well with Fast NAT. -+ -+ If you want to compile it as a module, say M here and read -+ Documentation/modules.txt. The module will be called -+ ipt_NETMAP.o. If unsure, say `N'. -+ - Packet mangling - CONFIG_IP_NF_MANGLE - This option adds a `mangle' table to iptables: see the man page for ---- a/net/ipv4/netfilter/Config.in -+++ b/net/ipv4/netfilter/Config.in -@@ -63,6 +63,7 @@ if [ "$CONFIG_IP_NF_IPTABLES" != "n" ]; - define_bool CONFIG_IP_NF_NAT_NEEDED y - dep_tristate ' MASQUERADE target support' CONFIG_IP_NF_TARGET_MASQUERADE $CONFIG_IP_NF_NAT - dep_tristate ' REDIRECT target support' CONFIG_IP_NF_TARGET_REDIRECT $CONFIG_IP_NF_NAT -+ dep_tristate ' NETMAP target support' CONFIG_IP_NF_TARGET_NETMAP $CONFIG_IP_NF_NAT - if [ "$CONFIG_IP_NF_AMANDA" = "m" ]; then - define_tristate CONFIG_IP_NF_NAT_AMANDA m - else ---- /dev/null -+++ b/net/ipv4/netfilter/ipt_NETMAP.c -@@ -0,0 +1,112 @@ -+/* NETMAP - static NAT mapping of IP network addresses (1:1). -+ The mapping can be applied to source (POSTROUTING), -+ destination (PREROUTING), or both (with separate rules). -+ -+ Author: Svenning Soerensen <svenning@post5.tele.dk> -+*/ -+ -+#include <linux/config.h> -+#include <linux/ip.h> -+#include <linux/module.h> -+#include <linux/netdevice.h> -+#include <linux/netfilter.h> -+#include <linux/netfilter_ipv4.h> -+#include <linux/netfilter_ipv4/ip_nat_rule.h> -+ -+#define MODULENAME "NETMAP" -+MODULE_LICENSE("GPL"); -+MODULE_AUTHOR("Svenning Soerensen <svenning@post5.tele.dk>"); -+MODULE_DESCRIPTION("iptables 1:1 NAT mapping of IP networks target"); -+ -+#if 0 -+#define DEBUGP printk -+#else -+#define DEBUGP(format, args...) -+#endif -+ -+static int -+check(const char *tablename, -+ const struct ipt_entry *e, -+ void *targinfo, -+ unsigned int targinfosize, -+ unsigned int hook_mask) -+{ -+ const struct ip_nat_multi_range *mr = targinfo; -+ -+ if (strcmp(tablename, "nat") != 0) { -+ DEBUGP(MODULENAME":check: bad table `%s'.\n", tablename); -+ return 0; -+ } -+ if (targinfosize != IPT_ALIGN(sizeof(*mr))) { -+ DEBUGP(MODULENAME":check: size %u.\n", targinfosize); -+ return 0; -+ } -+ if (hook_mask & ~((1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_POST_ROUTING))) { -+ DEBUGP(MODULENAME":check: bad hooks %x.\n", hook_mask); -+ return 0; -+ } -+ if (!(mr->range[0].flags & IP_NAT_RANGE_MAP_IPS)) { -+ DEBUGP(MODULENAME":check: bad MAP_IPS.\n"); -+ return 0; -+ } -+ if (mr->rangesize != 1) { -+ DEBUGP(MODULENAME":check: bad rangesize %u.\n", mr->rangesize); -+ return 0; -+ } -+ return 1; -+} -+ -+static unsigned int -+target(struct sk_buff **pskb, -+ unsigned int hooknum, -+ const struct net_device *in, -+ const struct net_device *out, -+ const void *targinfo, -+ void *userinfo) -+{ -+ struct ip_conntrack *ct; -+ enum ip_conntrack_info ctinfo; -+ u_int32_t new_ip, netmask; -+ const struct ip_nat_multi_range *mr = targinfo; -+ struct ip_nat_multi_range newrange; -+ -+ IP_NF_ASSERT(hooknum == NF_IP_PRE_ROUTING -+ || hooknum == NF_IP_POST_ROUTING); -+ ct = ip_conntrack_get(*pskb, &ctinfo); -+ -+ netmask = ~(mr->range[0].min_ip ^ mr->range[0].max_ip); -+ -+ if (hooknum == NF_IP_PRE_ROUTING) -+ new_ip = (*pskb)->nh.iph->daddr & ~netmask; -+ else -+ new_ip = (*pskb)->nh.iph->saddr & ~netmask; -+ new_ip |= mr->range[0].min_ip & netmask; -+ -+ newrange = ((struct ip_nat_multi_range) -+ { 1, { { mr->range[0].flags | IP_NAT_RANGE_MAP_IPS, -+ new_ip, new_ip, -+ mr->range[0].min, mr->range[0].max } } }); -+ -+ /* Hand modified range to generic setup. */ -+ return ip_nat_setup_info(ct, &newrange, hooknum); -+} -+ -+static struct ipt_target target_module = { -+ .name = MODULENAME, -+ .target = target, -+ .checkentry = check, -+ .me = THIS_MODULE -+}; -+ -+static int __init init(void) -+{ -+ return ipt_register_target(&target_module); -+} -+ -+static void __exit fini(void) -+{ -+ ipt_unregister_target(&target_module); -+} -+ -+module_init(init); -+module_exit(fini); ---- a/net/ipv4/netfilter/Makefile -+++ b/net/ipv4/netfilter/Makefile -@@ -99,6 +99,7 @@ obj-$(CONFIG_IP_NF_TARGET_DSCP) += ipt_D - obj-$(CONFIG_IP_NF_TARGET_MARK) += ipt_MARK.o - obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o - obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o -+obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o - obj-$(CONFIG_IP_NF_NAT_SNMP_BASIC) += ip_nat_snmp_basic.o - obj-$(CONFIG_IP_NF_TARGET_LOG) += ipt_LOG.o - obj-$(CONFIG_IP_NF_TARGET_TTL) += ipt_TTL.o diff --git a/target/linux/generic-2.4/patches/607-netfilter_connmark.patch b/target/linux/generic-2.4/patches/607-netfilter_connmark.patch deleted file mode 100644 index 3d3c947..0000000 --- a/target/linux/generic-2.4/patches/607-netfilter_connmark.patch +++ /dev/null @@ -1,340 +0,0 @@ ---- a/include/linux/netfilter_ipv4/ip_conntrack.h -+++ b/include/linux/netfilter_ipv4/ip_conntrack.h -@@ -218,6 +218,9 @@ struct ip_conntrack - unsigned int app_data_len; - } layer7; - #endif -+#if defined(CONFIG_IP_NF_CONNTRACK_MARK) -+ unsigned long mark; -+#endif - }; - - /* get master conntrack via master expectation */ ---- /dev/null -+++ b/include/linux/netfilter_ipv4/ipt_CONNMARK.h -@@ -0,0 +1,25 @@ -+#ifndef _IPT_CONNMARK_H_target -+#define _IPT_CONNMARK_H_target -+ -+/* Copyright (C) 2002,2004 MARA Systems AB <http://www.marasystems.com> -+ * by Henrik Nordstrom <hno@marasystems.com> -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ */ -+ -+enum { -+ IPT_CONNMARK_SET = 0, -+ IPT_CONNMARK_SAVE, -+ IPT_CONNMARK_RESTORE -+}; -+ -+struct ipt_connmark_target_info { -+ unsigned long mark; -+ unsigned long mask; -+ u_int8_t mode; -+}; -+ -+#endif /*_IPT_CONNMARK_H_target*/ ---- /dev/null -+++ b/include/linux/netfilter_ipv4/ipt_connmark.h -@@ -0,0 +1,18 @@ -+#ifndef _IPT_CONNMARK_H -+#define _IPT_CONNMARK_H -+ -+/* Copyright (C) 2002,2004 MARA Systems AB <http://www.marasystems.com> -+ * by Henrik Nordstrom <hno@marasystems.com> -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ */ -+ -+struct ipt_connmark_info { -+ unsigned long mark, mask; -+ u_int8_t invert; -+}; -+ -+#endif /*_IPT_CONNMARK_H*/ ---- a/net/ipv4/netfilter/Config.in -+++ b/net/ipv4/netfilter/Config.in -@@ -6,6 +6,7 @@ comment ' IP: Netfilter Configuration' - - tristate 'Connection tracking (required for masq/NAT)' CONFIG_IP_NF_CONNTRACK - if [ "$CONFIG_IP_NF_CONNTRACK" != "n" ]; then -+ bool ' Connection mark tracking support' CONFIG_IP_NF_CONNTRACK_MARK - dep_tristate ' FTP protocol support' CONFIG_IP_NF_FTP $CONFIG_IP_NF_CONNTRACK - dep_tristate ' Amanda protocol support' CONFIG_IP_NF_AMANDA $CONFIG_IP_NF_CONNTRACK - dep_tristate ' TFTP protocol support' CONFIG_IP_NF_TFTP $CONFIG_IP_NF_CONNTRACK -@@ -40,6 +41,9 @@ if [ "$CONFIG_IP_NF_IPTABLES" != "n" ]; - if [ "$CONFIG_IP_NF_CONNTRACK" != "n" ]; then - dep_tristate ' Connection state match support' CONFIG_IP_NF_MATCH_STATE $CONFIG_IP_NF_CONNTRACK $CONFIG_IP_NF_IPTABLES - dep_tristate ' Connection tracking match support' CONFIG_IP_NF_MATCH_CONNTRACK $CONFIG_IP_NF_CONNTRACK $CONFIG_IP_NF_IPTABLES -+ if [ "$CONFIG_IP_NF_CONNTRACK_MARK" != "n" ]; then -+ dep_tristate ' Connection mark match support' CONFIG_IP_NF_MATCH_CONNMARK $CONFIG_IP_NF_IPTABLES -+ fi - fi - if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then - dep_tristate ' Unclean match support (EXPERIMENTAL)' CONFIG_IP_NF_MATCH_UNCLEAN $CONFIG_IP_NF_IPTABLES -@@ -110,6 +114,9 @@ if [ "$CONFIG_IP_NF_IPTABLES" != "n" ]; - dep_tristate ' MARK target support' CONFIG_IP_NF_TARGET_MARK $CONFIG_IP_NF_MANGLE - dep_tristate ' CLASSIFY target support (EXPERIMENTAL)' CONFIG_IP_NF_TARGET_CLASSIFY $CONFIG_IP_NF_MANGLE - fi -+ if [ "$CONFIG_IP_NF_CONNTRACK_MARK" != "n" ]; then -+ dep_tristate ' CONNMARK target support' CONFIG_IP_NF_TARGET_CONNMARK $CONFIG_IP_NF_IPTABLES -+ fi - dep_tristate ' LOG target support' CONFIG_IP_NF_TARGET_LOG $CONFIG_IP_NF_IPTABLES - dep_tristate ' TTL target support' CONFIG_IP_NF_TARGET_TTL $CONFIG_IP_NF_IPTABLES - dep_tristate ' ULOG target support' CONFIG_IP_NF_TARGET_ULOG $CONFIG_IP_NF_IPTABLES ---- a/net/ipv4/netfilter/Makefile -+++ b/net/ipv4/netfilter/Makefile -@@ -84,6 +84,7 @@ obj-$(CONFIG_IP_NF_MATCH_LENGTH) += ipt_ - - obj-$(CONFIG_IP_NF_MATCH_TTL) += ipt_ttl.o - obj-$(CONFIG_IP_NF_MATCH_STATE) += ipt_state.o -+obj-$(CONFIG_IP_NF_MATCH_CONNMARK) += ipt_connmark.o - obj-$(CONFIG_IP_NF_MATCH_CONNTRACK) += ipt_conntrack.o - obj-$(CONFIG_IP_NF_MATCH_UNCLEAN) += ipt_unclean.o - obj-$(CONFIG_IP_NF_MATCH_TCPMSS) += ipt_tcpmss.o -@@ -102,6 +103,7 @@ obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += i - obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o - obj-$(CONFIG_IP_NF_NAT_SNMP_BASIC) += ip_nat_snmp_basic.o - obj-$(CONFIG_IP_NF_TARGET_LOG) += ipt_LOG.o -+obj-$(CONFIG_IP_NF_TARGET_CONNMARK) += ipt_CONNMARK.o - obj-$(CONFIG_IP_NF_TARGET_TTL) += ipt_TTL.o - obj-$(CONFIG_IP_NF_TARGET_ULOG) += ipt_ULOG.o - obj-$(CONFIG_IP_NF_TARGET_TCPMSS) += ipt_TCPMSS.o ---- a/net/ipv4/netfilter/ip_conntrack_core.c -+++ b/net/ipv4/netfilter/ip_conntrack_core.c -@@ -750,6 +750,9 @@ init_conntrack(const struct ip_conntrack - __set_bit(IPS_EXPECTED_BIT, &conntrack->status); - conntrack->master = expected; - expected->sibling = conntrack; -+#ifdef CONFIG_IP_NF_CONNTRACK_MARK -+ conntrack->mark = expected->expectant->mark; -+#endif - LIST_DELETE(&ip_conntrack_expect_list, expected); - expected->expectant->expecting--; - nf_conntrack_get(&master_ct(conntrack)->infos[0]); ---- a/net/ipv4/netfilter/ip_conntrack_standalone.c -+++ b/net/ipv4/netfilter/ip_conntrack_standalone.c -@@ -107,6 +107,9 @@ print_conntrack(char *buffer, struct ip_ - len += sprintf(buffer + len, "[ASSURED] "); - len += sprintf(buffer + len, "use=%u ", - atomic_read(&conntrack->ct_general.use)); -+ #if defined(CONFIG_IP_NF_CONNTRACK_MARK) -+ len += sprintf(buffer + len, "mark=%ld ", conntrack->mark); -+ #endif - - #if defined(CONFIG_IP_NF_MATCH_LAYER7) || defined(CONFIG_IP_NF_MATCH_LAYER7_MODULE) - if(conntrack->layer7.app_proto) ---- /dev/null -+++ b/net/ipv4/netfilter/ipt_CONNMARK.c -@@ -0,0 +1,118 @@ -+/* This kernel module is used to modify the connection mark values, or -+ * to optionally restore the skb nfmark from the connection mark -+ * -+ * Copyright (C) 2002,2004 MARA Systems AB <http://www.marasystems.com> -+ * by Henrik Nordstrom <hno@marasystems.com> -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; 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 -+ */ -+#include <linux/module.h> -+#include <linux/skbuff.h> -+#include <linux/ip.h> -+#include <net/checksum.h> -+ -+MODULE_AUTHOR("Henrik Nordstrom <hno@marasytems.com>"); -+MODULE_DESCRIPTION("IP tables CONNMARK matching module"); -+MODULE_LICENSE("GPL"); -+ -+#include <linux/netfilter_ipv4/ip_tables.h> -+#include <linux/netfilter_ipv4/ipt_CONNMARK.h> -+#include <linux/netfilter_ipv4/ip_conntrack.h> -+ -+static unsigned int -+target(struct sk_buff **pskb, -+ unsigned int hooknum, -+ const struct net_device *in, -+ const struct net_device *out, -+ const void *targinfo, -+ void *userinfo) -+{ -+ const struct ipt_connmark_target_info *markinfo = targinfo; -+ unsigned long diff; -+ unsigned long nfmark; -+ unsigned long newmark; -+ -+ enum ip_conntrack_info ctinfo; -+ struct ip_conntrack *ct = ip_conntrack_get((*pskb), &ctinfo); -+ if (ct) { -+ switch(markinfo->mode) { -+ case IPT_CONNMARK_SET: -+ newmark = (ct->mark & ~markinfo->mask) | markinfo->mark; -+ if (newmark != ct->mark) -+ ct->mark = newmark; -+ break; -+ case IPT_CONNMARK_SAVE: -+ newmark = (ct->mark & ~markinfo->mask) | ((*pskb)->nfmark & markinfo->mask); -+ if (ct->mark != newmark) -+ ct->mark = newmark; -+ break; -+ case IPT_CONNMARK_RESTORE: -+ nfmark = (*pskb)->nfmark; -+ diff = (ct->mark ^ nfmark & markinfo->mask); -+ if (diff != 0) { -+ (*pskb)->nfmark = nfmark ^ diff; -+ (*pskb)->nfcache |= NFC_ALTERED; -+ } -+ break; -+ } -+ } -+ -+ return IPT_CONTINUE; -+} -+ -+static int -+checkentry(const char *tablename, -+ const struct ipt_entry *e, -+ void *targinfo, -+ unsigned int targinfosize, -+ unsigned int hook_mask) -+{ -+ struct ipt_connmark_target_info *matchinfo = targinfo; -+ if (targinfosize != IPT_ALIGN(sizeof(struct ipt_connmark_target_info))) { -+ printk(KERN_WARNING "CONNMARK: targinfosize %u != %Zu\n", -+ targinfosize, -+ IPT_ALIGN(sizeof(struct ipt_connmark_target_info))); -+ return 0; -+ } -+ -+ if (matchinfo->mode == IPT_CONNMARK_RESTORE) { -+ if (strcmp(tablename, "mangle") != 0) { -+ printk(KERN_WARNING "CONNMARK: restore can only be called from \"mangle\" table, not \"%s\"\n", tablename); -+ return 0; -+ } -+ } -+ -+ return 1; -+} -+ -+static struct ipt_target ipt_connmark_reg = { -+ .name = "CONNMARK", -+ .target = &target, -+ .checkentry = &checkentry, -+ .me = THIS_MODULE -+}; -+ -+static int __init init(void) -+{ -+ return ipt_register_target(&ipt_connmark_reg); -+} -+ -+static void __exit fini(void) -+{ -+ ipt_unregister_target(&ipt_connmark_reg); -+} -+ -+module_init(init); -+module_exit(fini); ---- /dev/null -+++ b/net/ipv4/netfilter/ipt_connmark.c -@@ -0,0 +1,83 @@ -+/* This kernel module matches connection mark values set by the -+ * CONNMARK target -+ * -+ * Copyright (C) 2002,2004 MARA Systems AB <http://www.marasystems.com> -+ * by Henrik Nordstrom <hno@marasystems.com> -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; 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 -+ */ -+ -+#include <linux/module.h> -+#include <linux/skbuff.h> -+ -+MODULE_AUTHOR("Henrik Nordstrom <hno@marasytems.com>"); -+MODULE_DESCRIPTION("IP tables connmark match module"); -+MODULE_LICENSE("GPL"); -+ -+#include <linux/netfilter_ipv4/ip_tables.h> -+#include <linux/netfilter_ipv4/ipt_connmark.h> -+#include <linux/netfilter_ipv4/ip_conntrack.h> -+ -+static int -+match(const struct sk_buff *skb, -+ const struct net_device *in, -+ const struct net_device *out, -+ const void *matchinfo, -+ int offset, -+ const void *hdr, -+ u_int16_t datalen, -+ int *hotdrop) -+{ -+ const struct ipt_connmark_info *info = matchinfo; -+ enum ip_conntrack_info ctinfo; -+ struct ip_conntrack *ct = ip_conntrack_get((struct sk_buff *)skb, &ctinfo); -+ if (!ct) -+ return 0; -+ -+ return ((ct->mark & info->mask) == info->mark) ^ info->invert; -+} -+ -+static int -+checkentry(const char *tablename, -+ const struct ipt_ip *ip, -+ void *matchinfo, -+ unsigned int matchsize, -+ unsigned int hook_mask) -+{ -+ if (matchsize != IPT_ALIGN(sizeof(struct ipt_connmark_info))) -+ return 0; -+ -+ return 1; -+} -+ -+static struct ipt_match connmark_match = { -+ .name = "connmark", -+ .match = &match, -+ .checkentry = &checkentry, -+ .me = THIS_MODULE -+}; -+ -+static int __init init(void) -+{ -+ return ipt_register_match(&connmark_match); -+} -+ -+static void __exit fini(void) -+{ -+ ipt_unregister_match(&connmark_match); -+} -+ -+module_init(init); -+module_exit(fini); diff --git a/target/linux/generic-2.4/patches/609-netfilter_string.patch b/target/linux/generic-2.4/patches/609-netfilter_string.patch deleted file mode 100644 index 87934ed..0000000 --- a/target/linux/generic-2.4/patches/609-netfilter_string.patch +++ /dev/null @@ -1,973 +0,0 @@ ---- /dev/null -+++ b/include/linux/netfilter_ipv4/ipt_string.h -@@ -0,0 +1,18 @@ -+#ifndef _IPT_STRING_H -+#define _IPT_STRING_H -+ -+#define IPT_STRING_MAX_PATTERN_SIZE 128 -+#define IPT_STRING_MAX_ALGO_NAME_SIZE 16 -+ -+struct ipt_string_info -+{ -+ u_int16_t from_offset; -+ u_int16_t to_offset; -+ char algo[IPT_STRING_MAX_ALGO_NAME_SIZE]; -+ char pattern[IPT_STRING_MAX_PATTERN_SIZE]; -+ u_int8_t patlen; -+ u_int8_t invert; -+ struct ts_config __attribute__((aligned(8))) *config; -+}; -+ -+#endif /*_IPT_STRING_H*/ ---- a/net/ipv4/netfilter/Config.in -+++ b/net/ipv4/netfilter/Config.in -@@ -47,6 +47,7 @@ if [ "$CONFIG_IP_NF_IPTABLES" != "n" ]; - fi - if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then - dep_tristate ' Unclean match support (EXPERIMENTAL)' CONFIG_IP_NF_MATCH_UNCLEAN $CONFIG_IP_NF_IPTABLES -+ dep_tristate ' String match support (EXPERIMENTAL) ' CONFIG_IP_NF_MATCH_STRING $CONFIG_IP_NF_IPTABLES - dep_tristate ' Owner match support (EXPERIMENTAL)' CONFIG_IP_NF_MATCH_OWNER $CONFIG_IP_NF_IPTABLES - dep_tristate ' Layer 7 match support (EXPERIMENTAL)' CONFIG_IP_NF_MATCH_LAYER7 $CONFIG_IP_NF_CONNTRACK - dep_mbool ' Layer 7 debugging output (EXPERIMENTAL)' CONFIG_IP_NF_MATCH_LAYER7_DEBUG $CONFIG_IP_NF_MATCH_LAYER7 ---- /dev/null -+++ b/net/ipv4/netfilter/ipt_string.c -@@ -0,0 +1,99 @@ -+/* String matching match for iptables -+ * -+ * (C) 2005 Pablo Neira Ayuso <pablo@eurodev.net> -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License version 2 as -+ * published by the Free Software Foundation. -+ */ -+ -+#include <linux/init.h> -+#include <linux/module.h> -+#include <linux/kernel.h> -+#include <linux/skbuff.h> -+#include <linux/netfilter_ipv4/ip_tables.h> -+#include <linux/netfilter_ipv4/ipt_string.h> -+#include "textsearch/textsearch.h" -+#include "textsearch/textsearch.c" -+#include "textsearch/ts_bm.c" -+#include "textsearch/ts_kmp.c" -+ -+MODULE_AUTHOR("Pablo Neira Ayuso <pablo@eurodev.net>"); -+MODULE_DESCRIPTION("IP tables string match module"); -+MODULE_LICENSE("GPL"); -+ -+static int match(const struct sk_buff *skb, -+ const struct net_device *in, -+ const struct net_device *out, -+ const void *matchinfo, -+ int offset, -+ int *hotdrop) -+{ -+ struct iphdr *ip = skb->nh.iph; -+ struct ts_state state; -+ struct ipt_string_info *conf = (struct ipt_string_info *) matchinfo; -+ char *buf = (char *)ip+(ip->ihl*4); -+ int len = ntohs(ip->tot_len)-(ip->ihl*4); -+ -+ memset(&state, 0, sizeof(struct ts_state)); -+ -+ return (textsearch_find_continuous(conf->config, &state, buf, len) != UINT_MAX) && !conf->invert; -+} -+ -+#define STRING_TEXT_PRIV(m) ((struct ipt_string_info *) m) -+ -+static int checkentry(const char *tablename, -+ const struct ipt_ip *ip, -+ void *matchinfo, -+ unsigned int matchsize, -+ unsigned int hook_mask) -+{ -+ struct ipt_string_info *conf = matchinfo; -+ struct ts_config *ts_conf; -+ -+ if (matchsize != IPT_ALIGN(sizeof(struct ipt_string_info))) -+ return 0; -+ -+ /* Damn, can't handle this case properly with iptables... */ -+ if (conf->from_offset > conf->to_offset) -+ return 0; -+ -+ ts_conf = textsearch_prepare(conf->algo, conf->pattern, conf->patlen, -+ GFP_KERNEL, TS_AUTOLOAD); -+ if (IS_ERR(ts_conf)) -+ return 0; -+ -+ conf->config = ts_conf; -+ -+ return 1; -+} -+ -+static void destroy(void *matchinfo, unsigned int matchsize) -+{ -+ textsearch_destroy(STRING_TEXT_PRIV(matchinfo)->config); -+} -+ -+static struct ipt_match string_match = { -+ .name = "string", -+ .match = match, -+ .checkentry = checkentry, -+ .destroy = destroy, -+ .me = THIS_MODULE -+}; -+ -+static int __init init(void) -+{ -+ init_bm(); -+ init_kmp(); -+ return ipt_register_match(&string_match); -+} -+ -+static void __exit fini(void) -+{ -+ exit_kmp(); -+ exit_bm(); -+ ipt_unregister_match(&string_match); -+} -+ -+module_init(init); -+module_exit(fini); ---- a/net/ipv4/netfilter/Makefile -+++ b/net/ipv4/netfilter/Makefile -@@ -87,6 +87,7 @@ obj-$(CONFIG_IP_NF_MATCH_STATE) += ipt_s - obj-$(CONFIG_IP_NF_MATCH_CONNMARK) += ipt_connmark.o - obj-$(CONFIG_IP_NF_MATCH_CONNTRACK) += ipt_conntrack.o - obj-$(CONFIG_IP_NF_MATCH_UNCLEAN) += ipt_unclean.o -+obj-$(CONFIG_IP_NF_MATCH_STRING) += ipt_string.o - obj-$(CONFIG_IP_NF_MATCH_TCPMSS) += ipt_tcpmss.o - obj-$(CONFIG_IP_NF_MATCH_LAYER7) += ipt_layer7.o - ---- /dev/null -+++ b/net/ipv4/netfilter/textsearch/textsearch.c -@@ -0,0 +1,305 @@ -+/* -+ * lib/textsearch.c Generic text search interface -+ * -+ * 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. -+ * -+ * Authors: Thomas Graf <tgraf@suug.ch> -+ * Pablo Neira Ayuso <pablo@eurodev.net> -+ * -+ * ========================================================================== -+ * -+ * INTRODUCTION -+ * -+ * The textsearch infrastructure provides text searching facitilies for -+ * both linear and non-linear data. Individual search algorithms are -+ * implemented in modules and chosen by the user. -+ * -+ * ARCHITECTURE -+ * -+ * User -+ * +----------------+ -+ * | finish()|<--------------(6)-----------------+ -+ * |get_next_block()|<--------------(5)---------------+ | -+ * | | Algorithm | | -+ * | | +------------------------------+ -+ * | | | init() find() destroy() | -+ * | | +------------------------------+ -+ * | | Core API ^ ^ ^ -+ * | | +---------------+ (2) (4) (8) -+ * | (1)|----->| prepare() |---+ | | -+ * | (3)|----->| find()/next() |-----------+ | -+ * | (7)|----->| destroy() |----------------------+ -+ * +----------------+ +---------------+ -+ * -+ * (1) User configures a search by calling _prepare() specifying the -+ * search parameters such as the pattern and algorithm name. -+ * (2) Core requests the algorithm to allocate and initialize a search -+ * configuration according to the specified parameters. -+ * (3) User starts the search(es) by calling _find() or _next() to -+ * fetch subsequent occurrences. A state variable is provided -+ * to the algorihtm to store persistant variables. -+ * (4) Core eventually resets the search offset and forwards the find() -+ * request to the algorithm. -+ * (5) Algorithm calls get_next_block() provided by the user continously -+ * to fetch the data to be searched in block by block. -+ * (6) Algorithm invokes finish() after the last call to get_next_block -+ * to clean up any leftovers from get_next_block. (Optional) -+ * (7) User destroys the configuration by calling _destroy(). -+ * (8) Core notifies the algorithm to destroy algorithm specific -+ * allocations. (Optional) -+ * -+ * USAGE -+ * -+ * Before a search can be performed, a configuration must be created -+ * by calling textsearch_prepare() specyfing the searching algorithm and -+ * the pattern to look for. The returned configuration may then be used -+ * for an arbitary amount of times and even in parallel as long as a -+ * separate struct ts_state variable is provided to every instance. -+ * -+ * The actual search is performed by either calling textsearch_find_- -+ * continuous() for linear data or by providing an own get_next_block() -+ * implementation and calling textsearch_find(). Both functions return -+ * the position of the first occurrence of the patern or UINT_MAX if -+ * no match was found. Subsequent occurences can be found by calling -+ * textsearch_next() regardless of the linearity of the data. -+ * -+ * Once you're done using a configuration it must be given back via -+ * textsearch_destroy. -+ * -+ * EXAMPLE -+ * -+ * int pos; -+ * struct ts_config *conf; -+ * struct ts_state state; -+ * const char *pattern = "chicken"; -+ * const char *example = "We dance the funky chicken"; -+ * -+ * conf = textsearch_prepare("kmp", pattern, strlen(pattern), -+ * GFP_KERNEL, TS_AUTOLOAD); -+ * if (IS_ERR(conf)) { -+ * err = PTR_ERR(conf); -+ * goto errout; -+ * } -+ * -+ * pos = textsearch_find_continuous(conf, &state, example, strlen(example)); -+ * if (pos != UINT_MAX) -+ * panic("Oh my god, dancing chickens at %d\n", pos); -+ * -+ * textsearch_destroy(conf); -+ * -+ * ========================================================================== -+ */ -+ -+#include <linux/config.h> -+#include <linux/module.h> -+#include <linux/types.h> -+#include <linux/string.h> -+#include <linux/init.h> -+#include <linux/netfilter_ipv4/lockhelp.h> -+#include "textsearch.h" -+ -+static LIST_HEAD(ts_ops); -+static spinlock_t ts_mod_lock = SPIN_LOCK_UNLOCKED; -+static DECLARE_RWLOCK(ts_ops_lock); -+ -+static inline struct ts_ops *lookup_ts_algo(const char *name) -+{ -+ struct ts_ops *o; -+ -+ read_lock(&ts_ops_lock); -+ list_for_each_entry(o, &ts_ops, list) { -+ if (!strcmp(name, o->name)) { -+ MOD_INC_USE_COUNT; -+ read_unlock(&ts_ops_lock); -+ return o; -+ } -+ } -+ read_unlock(&ts_ops_lock); -+ -+ return NULL; -+} -+ -+/** -+ * textsearch_register - register a textsearch module -+ * @ops: operations lookup table -+ * -+ * This function must be called by textsearch modules to announce -+ * their presence. The specified &@ops must have %name set to a -+ * unique identifier and the callbacks find(), init(), get_pattern(), -+ * and get_pattern_len() must be implemented. -+ * -+ * Returns 0 or -EEXISTS if another module has already registered -+ * with same name. -+ */ -+int textsearch_register(struct ts_ops *ops) -+{ -+ int err = -EEXIST; -+ struct ts_ops *o; -+ -+ if (ops->name == NULL || ops->find == NULL || ops->init == NULL || -+ ops->get_pattern == NULL || ops->get_pattern_len == NULL) -+ return -EINVAL; -+ -+ spin_lock(&ts_mod_lock); -+ list_for_each_entry(o, &ts_ops, list) { -+ if (!strcmp(ops->name, o->name)) -+ goto errout; -+ } -+ -+ write_lock(&ts_ops_lock); -+ list_add_tail(&ops->list, &ts_ops); -+ write_unlock(&ts_ops_lock); -+ -+ err = 0; -+errout: -+ spin_unlock(&ts_mod_lock); -+ return err; -+} -+ -+/** -+ * textsearch_unregister - unregister a textsearch module -+ * @ops: operations lookup table -+ * -+ * This function must be called by textsearch modules to announce -+ * their disappearance for examples when the module gets unloaded. -+ * The &ops parameter must be the same as the one during the -+ * registration. -+ * -+ * Returns 0 on success or -ENOENT if no matching textsearch -+ * registration was found. -+ */ -+int textsearch_unregister(struct ts_ops *ops) -+{ -+ int err = 0; -+ struct ts_ops *o; -+ -+ spin_lock(&ts_mod_lock); -+ list_for_each_entry(o, &ts_ops, list) { -+ if (o == ops) { -+ write_lock(&ts_ops_lock); -+ list_del(&o->list); -+ write_unlock(&ts_ops_lock); -+ goto out; -+ } -+ } -+ -+ err = -ENOENT; -+out: -+ spin_unlock(&ts_mod_lock); -+ return err; -+} -+ -+struct ts_linear_state -+{ -+ unsigned int len; -+ const void *data; -+}; -+ -+static unsigned int get_linear_data(unsigned int consumed, const u8 **dst, -+ struct ts_config *conf, -+ struct ts_state *state) -+{ -+ struct ts_linear_state *st = (struct ts_linear_state *) state->cb; -+ -+ if (likely(consumed < st->len)) { -+ *dst = st->data + consumed; -+ return st->len - consumed; -+ } -+ -+ return 0; -+} -+ -+/** -+ * textsearch_find_continuous - search a pattern in continuous/linear data -+ * @conf: search configuration -+ * @state: search state -+ * @data: data to search in -+ * @len: length of data -+ * -+ * A simplified version of textsearch_find() for continuous/linear data. -+ * Call textsearch_next() to retrieve subsequent matches. -+ * -+ * Returns the position of first occurrence of the pattern or -+ * UINT_MAX if no occurrence was found. -+ */ -+unsigned int textsearch_find_continuous(struct ts_config *conf, -+ struct ts_state *state, -+ const void *data, unsigned int len) -+{ -+ struct ts_linear_state *st = (struct ts_linear_state *) state->cb; -+ -+ conf->get_next_block = get_linear_data; -+ st->data = data; -+ st->len = len; -+ -+ return textsearch_find(conf, state); -+} -+ -+/** -+ * textsearch_prepare - Prepare a search -+ * @algo: name of search algorithm -+ * @pattern: pattern data -+ * @len: length of pattern -+ * @gfp_mask: allocation mask -+ * @flags: search flags -+ * -+ * Looks up the search algorithm module and creates a new textsearch -+ * configuration for the specified pattern. Upon completion all -+ * necessary refcnts are held and the configuration must be put back -+ * using textsearch_put() after usage. -+ * -+ * Note: The format of the pattern may not be compatible between -+ * the various search algorithms. -+ * -+ * Returns a new textsearch configuration according to the specified -+ * parameters or a ERR_PTR(). -+ */ -+struct ts_config *textsearch_prepare(const char *algo, const void *pattern, -+ unsigned int len, gfp_t gfp_mask, int flags) -+{ -+ int err = -ENOENT; -+ struct ts_config *conf; -+ struct ts_ops *ops; -+ -+ ops = lookup_ts_algo(algo); -+ -+ if (ops == NULL) -+ goto errout; -+ -+ conf = ops->init(pattern, len, gfp_mask); -+ if (IS_ERR(conf)) { -+ err = PTR_ERR(conf); -+ goto errout; -+ } -+ -+ conf->ops = ops; -+ return conf; -+ -+errout: -+ if (ops) -+ MOD_DEC_USE_COUNT; -+ -+ return ERR_PTR(err); -+} -+ -+/** -+ * textsearch_destroy - destroy a search configuration -+ * @conf: search configuration -+ * -+ * Releases all references of the configuration and frees -+ * up the memory. -+ */ -+void textsearch_destroy(struct ts_config *conf) -+{ -+ if (conf->ops) { -+ if (conf->ops->destroy) -+ conf->ops->destroy(conf); -+ MOD_DEC_USE_COUNT; -+ } -+ -+ kfree(conf); -+} -+ ---- /dev/null -+++ b/net/ipv4/netfilter/textsearch/textsearch.h -@@ -0,0 +1,182 @@ -+#ifndef __LINUX_TEXTSEARCH_H -+#define __LINUX_TEXTSEARCH_H -+ -+#ifdef __KERNEL__ -+ -+#include <linux/types.h> -+#include <linux/list.h> -+#include <linux/kernel.h> -+#include <linux/module.h> -+#include <linux/slab.h> -+ -+typedef int gfp_t; -+struct ts_config; -+ -+/** -+ * TS_AUTOLOAD - Automatically load textsearch modules when needed -+ */ -+#define TS_AUTOLOAD 1 -+ -+/** -+ * struct ts_state - search state -+ * @offset: offset for next match -+ * @cb: control buffer, for persistant variables of get_next_block() -+ */ -+struct ts_state -+{ -+ unsigned int offset; -+ char cb[40]; -+}; -+ -+/** -+ * struct ts_ops - search module operations -+ * @name: name of search algorithm -+ * @init: initialization function to prepare a search -+ * @find: find the next occurrence of the pattern -+ * @destroy: destroy algorithm specific parts of a search configuration -+ * @get_pattern: return head of pattern -+ * @get_pattern_len: return length of pattern -+ * @owner: module reference to algorithm -+ */ -+struct ts_ops -+{ -+ const char *name; -+ struct ts_config * (*init)(const void *, unsigned int, gfp_t); -+ unsigned int (*find)(struct ts_config *, -+ struct ts_state *); -+ void (*destroy)(struct ts_config *); -+ void * (*get_pattern)(struct ts_config *); -+ unsigned int (*get_pattern_len)(struct ts_config *); -+ struct module *owner; -+ struct list_head list; -+}; -+ -+/** -+ * struct ts_config - search configuration -+ * @ops: operations of chosen algorithm -+ * @get_next_block: callback to fetch the next block to search in -+ * @finish: callback to finalize a search -+ */ -+struct ts_config -+{ -+ struct ts_ops *ops; -+ -+ /** -+ * get_next_block - fetch next block of data -+ * @consumed: number of bytes consumed by the caller -+ * @dst: destination buffer -+ * @conf: search configuration -+ * @state: search state -+ * -+ * Called repeatedly until 0 is returned. Must assign the -+ * head of the next block of data to &*dst and return the length -+ * of the block or 0 if at the end. consumed == 0 indicates -+ * a new search. May store/read persistant values in state->cb. -+ */ -+ unsigned int (*get_next_block)(unsigned int consumed, -+ const u8 **dst, -+ struct ts_config *conf, -+ struct ts_state *state); -+ -+ /** -+ * finish - finalize/clean a series of get_next_block() calls -+ * @conf: search configuration -+ * @state: search state -+ * -+ * Called after the last use of get_next_block(), may be used -+ * to cleanup any leftovers. -+ */ -+ void (*finish)(struct ts_config *conf, -+ struct ts_state *state); -+}; -+ -+/** -+ * textsearch_next - continue searching for a pattern -+ * @conf: search configuration -+ * @state: search state -+ * -+ * Continues a search looking for more occurrences of the pattern. -+ * textsearch_find() must be called to find the first occurrence -+ * in order to reset the state. -+ * -+ * Returns the position of the next occurrence of the pattern or -+ * UINT_MAX if not match was found. -+ */ -+static inline unsigned int textsearch_next(struct ts_config *conf, -+ struct ts_state *state) -+{ -+ unsigned int ret = conf->ops->find(conf, state); -+ -+ if (conf->finish) -+ conf->finish(conf, state); -+ -+ return ret; -+} -+ -+/** -+ * textsearch_find - start searching for a pattern -+ * @conf: search configuration -+ * @state: search state -+ * -+ * Returns the position of first occurrence of the pattern or -+ * UINT_MAX if no match was found. -+ */ -+static inline unsigned int textsearch_find(struct ts_config *conf, -+ struct ts_state *state) -+{ -+ state->offset = 0; -+ return textsearch_next(conf, state); -+} -+ -+/** -+ * textsearch_get_pattern - return head of the pattern -+ * @conf: search configuration -+ */ -+static inline void *textsearch_get_pattern(struct ts_config *conf) -+{ -+ return conf->ops->get_pattern(conf); -+} -+ -+/** -+ * textsearch_get_pattern_len - return length of the pattern -+ * @conf: search configuration -+ */ -+static inline unsigned int textsearch_get_pattern_len(struct ts_config *conf) -+{ -+ return conf->ops->get_pattern_len(conf); -+} -+ -+extern int textsearch_register(struct ts_ops *); -+extern int textsearch_unregister(struct ts_ops *); -+extern struct ts_config *textsearch_prepare(const char *, const void *, -+ unsigned int, gfp_t, int); -+extern void textsearch_destroy(struct ts_config *conf); -+extern unsigned int textsearch_find_continuous(struct ts_config *, -+ struct ts_state *, -+ const void *, unsigned int); -+ -+ -+#define TS_PRIV_ALIGNTO 8 -+#define TS_PRIV_ALIGN(len) (((len) + TS_PRIV_ALIGNTO-1) & ~(TS_PRIV_ALIGNTO-1)) -+ -+static inline struct ts_config *alloc_ts_config(size_t payload, -+ gfp_t gfp_mask) -+{ -+ struct ts_config *conf; -+ -+ conf = kmalloc(TS_PRIV_ALIGN(sizeof(*conf)) + payload, gfp_mask); -+ if (conf == NULL) -+ return ERR_PTR(-ENOMEM); -+ -+ memset(conf, 0, TS_PRIV_ALIGN(sizeof(*conf)) + payload); -+ return conf; -+} -+ -+static inline void *ts_config_priv(struct ts_config *conf) -+{ -+ return ((u8 *) conf + TS_PRIV_ALIGN(sizeof(struct ts_config))); -+} -+ -+#endif /* __KERNEL__ */ -+ -+#endif ---- /dev/null -+++ b/net/ipv4/netfilter/textsearch/ts_bm.c -@@ -0,0 +1,190 @@ -+/* -+ * lib/ts_bm.c Boyer-Moore text search implementation -+ * -+ * 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. -+ * -+ * Authors: Pablo Neira Ayuso <pablo@eurodev.net> -+ * -+ * ========================================================================== -+ * -+ * Implements Boyer-Moore string matching algorithm: -+ * -+ * [1] A Fast String Searching Algorithm, R.S. Boyer and Moore. -+ * Communications of the Association for Computing Machinery, -+ * 20(10), 1977, pp. 762-772. -+ * http://www.cs.utexas.edu/users/moore/publications/fstrpos.pdf -+ * -+ * [2] Handbook of Exact String Matching Algorithms, Thierry Lecroq, 2004 -+ * http://www-igm.univ-mlv.fr/~lecroq/string/string.pdf -+ * -+ * Note: Since Boyer-Moore (BM) performs searches for matchings from right -+ * to left, it's still possible that a matching could be spread over -+ * multiple blocks, in that case this algorithm won't find any coincidence. -+ * -+ * If you're willing to ensure that such thing won't ever happen, use the -+ * Knuth-Pratt-Morris (KMP) implementation instead. In conclusion, choose -+ * the proper string search algorithm depending on your setting. -+ * -+ * Say you're using the textsearch infrastructure for filtering, NIDS or -+ * any similar security focused purpose, then go KMP. Otherwise, if you -+ * really care about performance, say you're classifying packets to apply -+ * Quality of Service (QoS) policies, and you don't mind about possible -+ * matchings spread over multiple fragments, then go BM. -+ */ -+ -+#include <linux/config.h> -+#include <linux/kernel.h> -+#include <linux/module.h> -+#include <linux/types.h> -+#include <linux/string.h> -+#include "textsearch.h" -+ -+/* Alphabet size, use ASCII */ -+#define ASIZE 256 -+ -+#if 0 -+#define DEBUGP printk -+#else -+#define DEBUGP(args, format...) -+#endif -+ -+struct ts_bm -+{ -+ u8 * pattern; -+ unsigned int patlen; -+ unsigned int bad_shift[ASIZE]; -+ unsigned int good_shift[0]; -+}; -+ -+static unsigned int bm_find(struct ts_config *conf, struct ts_state *state) -+{ -+ struct ts_bm *bm = ts_config_priv(conf); -+ unsigned int i, text_len, consumed = state->offset; -+ const u8 *text; -+ int shift = bm->patlen, bs; -+ -+ for (;;) { -+ text_len = conf->get_next_block(consumed, &text, conf, state); -+ -+ if (unlikely(text_len == 0)) -+ break; -+ -+ while (shift < text_len) { -+ DEBUGP("Searching in position %d (%c)\n", -+ shift, text[shift]); -+ for (i = 0; i < bm->patlen; i++) -+ if (text[shift-i] != bm->pattern[bm->patlen-1-i]) -+ goto next; -+ -+ /* London calling... */ -+ DEBUGP("found!\n"); -+ return consumed += (shift-(bm->patlen-1)); -+ -+next: bs = bm->bad_shift[text[shift-i]]; -+ -+ /* Now jumping to... */ -+ shift = max_t(int, shift-i+bs, shift+bm->good_shift[i]); -+ } -+ consumed += text_len; -+ } -+ -+ return UINT_MAX; -+} -+ -+static int subpattern(u8 *pattern, int i, int j, int g) -+{ -+ int x = i+g-1, y = j+g-1, ret = 0; -+ -+ while(pattern[x--] == pattern[y--]) { -+ if (y < 0) { -+ ret = 1; -+ break; -+ } -+ if (--g == 0) { -+ ret = pattern[i-1] != pattern[j-1]; -+ break; -+ } -+ } -+ -+ return ret; -+} -+ -+static void bm_compute_prefix_tbl(struct ts_bm *bm, const u8 *pattern, -+ unsigned int len) -+{ -+ int i, j, g; -+ -+ for (i = 0; i < ASIZE; i++) -+ bm->bad_shift[i] = len; -+ for (i = 0; i < len - 1; i++) -+ bm->bad_shift[pattern[i]] = len - 1 - i; -+ -+ /* Compute the good shift array, used to match reocurrences -+ * of a subpattern */ -+ bm->good_shift[0] = 1; -+ for (i = 1; i < bm->patlen; i++) -+ bm->good_shift[i] = bm->patlen; -+ for (i = bm->patlen-1, g = 1; i > 0; g++, i--) { -+ for (j = i-1; j >= 1-g ; j--) -+ if (subpattern(bm->pattern, i, j, g)) { -+ bm->good_shift[g] = bm->patlen-j-g; -+ break; -+ } -+ } -+} -+ -+static struct ts_config *bm_init(const void *pattern, unsigned int len, -+ gfp_t gfp_mask) -+{ -+ struct ts_config *conf; -+ struct ts_bm *bm; -+ unsigned int prefix_tbl_len = len * sizeof(unsigned int); -+ size_t priv_size = sizeof(*bm) + len + prefix_tbl_len; -+ -+ conf = alloc_ts_config(priv_size, gfp_mask); -+ if (IS_ERR(conf)) -+ return conf; -+ -+ bm = ts_config_priv(conf); -+ bm->patlen = len; -+ bm->pattern = (u8 *) bm->good_shift + prefix_tbl_len; -+ bm_compute_prefix_tbl(bm, pattern, len); -+ memcpy(bm->pattern, pattern, len); -+ -+ return conf; -+} -+ -+static void *bm_get_pattern(struct ts_config *conf) -+{ -+ struct ts_bm *bm = ts_config_priv(conf); -+ return bm->pattern; -+} -+ -+static unsigned int bm_get_pattern_len(struct ts_config *conf) -+{ -+ struct ts_bm *bm = ts_config_priv(conf); -+ return bm->patlen; -+} -+ -+static struct ts_ops bm_ops = { -+ .name = "bm", -+ .find = bm_find, -+ .init = bm_init, -+ .get_pattern = bm_get_pattern, -+ .get_pattern_len = bm_get_pattern_len, -+ .owner = THIS_MODULE, -+ .list = LIST_HEAD_INIT(bm_ops.list) -+}; -+ -+static int __init init_bm(void) -+{ -+ return textsearch_register(&bm_ops); -+} -+ -+static void __exit exit_bm(void) -+{ -+ textsearch_unregister(&bm_ops); -+} ---- /dev/null -+++ b/net/ipv4/netfilter/textsearch/ts_kmp.c -@@ -0,0 +1,141 @@ -+/* -+ * lib/ts_kmp.c Knuth-Morris-Pratt text search implementation -+ * -+ * 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. -+ * -+ * Authors: Thomas Graf <tgraf@suug.ch> -+ * -+ * ========================================================================== -+ * -+ * Implements a linear-time string-matching algorithm due to Knuth, -+ * Morris, and Pratt [1]. Their algorithm avoids the explicit -+ * computation of the transition function DELTA altogether. Its -+ * matching time is O(n), for n being length(text), using just an -+ * auxiliary function PI[1..m], for m being length(pattern), -+ * precomputed from the pattern in time O(m). The array PI allows -+ * the transition function DELTA to be computed efficiently -+ * "on the fly" as needed. Roughly speaking, for any state -+ * "q" = 0,1,...,m and any character "a" in SIGMA, the value -+ * PI["q"] contains the information that is independent of "a" and -+ * is needed to compute DELTA("q", "a") [2]. Since the array PI -+ * has only m entries, whereas DELTA has O(m|SIGMA|) entries, we -+ * save a factor of |SIGMA| in the preprocessing time by computing -+ * PI rather than DELTA. -+ * -+ * [1] Cormen, Leiserson, Rivest, Stein -+ * Introdcution to Algorithms, 2nd Edition, MIT Press -+ * [2] See finite automation theory -+ */ -+ -+#include <linux/config.h> -+#include <linux/module.h> -+#include <linux/types.h> -+#include <linux/string.h> -+#include "textsearch.h" -+ -+struct ts_kmp -+{ -+ u8 * pattern; -+ unsigned int pattern_len; -+ unsigned int prefix_tbl[0]; -+}; -+ -+static unsigned int kmp_find(struct ts_config *conf, struct ts_state *state) -+{ -+ struct ts_kmp *kmp = ts_config_priv(conf); -+ unsigned int i, q = 0, text_len, consumed = state->offset; -+ const u8 *text; -+ -+ for (;;) { -+ text_len = conf->get_next_block(consumed, &text, conf, state); -+ -+ if (unlikely(text_len == 0)) -+ break; -+ -+ for (i = 0; i < text_len; i++) { -+ while (q > 0 && kmp->pattern[q] != text[i]) -+ q = kmp->prefix_tbl[q - 1]; -+ if (kmp->pattern[q] == text[i]) -+ q++; -+ if (unlikely(q == kmp->pattern_len)) { -+ state->offset = consumed + i + 1; -+ return state->offset - kmp->pattern_len; -+ } -+ } -+ -+ consumed += text_len; -+ } -+ -+ return UINT_MAX; -+} -+ -+static inline void kmp_compute_prefix_tbl(const u8 *pattern, unsigned int len, -+ unsigned int *prefix_tbl) -+{ -+ unsigned int k, q; -+ -+ for (k = 0, q = 1; q < len; q++) { -+ while (k > 0 && pattern[k] != pattern[q]) -+ k = prefix_tbl[k-1]; -+ if (pattern[k] == pattern[q]) -+ k++; -+ prefix_tbl[q] = k; -+ } -+} -+ -+static struct ts_config *kmp_init(const void *pattern, unsigned int len, -+ gfp_t gfp_mask) -+{ -+ struct ts_config *conf; -+ struct ts_kmp *kmp; -+ unsigned int prefix_tbl_len = len * sizeof(unsigned int); -+ size_t priv_size = sizeof(*kmp) + len + prefix_tbl_len; -+ -+ conf = alloc_ts_config(priv_size, gfp_mask); -+ if (IS_ERR(conf)) -+ return conf; -+ -+ kmp = ts_config_priv(conf); -+ kmp->pattern_len = len; -+ kmp_compute_prefix_tbl(pattern, len, kmp->prefix_tbl); -+ kmp->pattern = (u8 *) kmp->prefix_tbl + prefix_tbl_len; -+ memcpy(kmp->pattern, pattern, len); -+ -+ return conf; -+} -+ -+static void *kmp_get_pattern(struct ts_config *conf) -+{ -+ struct ts_kmp *kmp = ts_config_priv(conf); -+ return kmp->pattern; -+} -+ -+static unsigned int kmp_get_pattern_len(struct ts_config *conf) -+{ -+ struct ts_kmp *kmp = ts_config_priv(conf); -+ return kmp->pattern_len; -+} -+ -+static struct ts_ops kmp_ops = { -+ .name = "kmp", -+ .find = kmp_find, -+ .init = kmp_init, -+ .get_pattern = kmp_get_pattern, -+ .get_pattern_len = kmp_get_pattern_len, -+ .owner = THIS_MODULE, -+ .list = LIST_HEAD_INIT(kmp_ops.list) -+}; -+ -+static int __init init_kmp(void) -+{ -+ return textsearch_register(&kmp_ops); -+} -+ -+static void __exit exit_kmp(void) -+{ -+ textsearch_unregister(&kmp_ops); -+} -+ diff --git a/target/linux/generic-2.4/patches/610-netfilter_connbytes.patch b/target/linux/generic-2.4/patches/610-netfilter_connbytes.patch deleted file mode 100644 index a5bc17e..0000000 --- a/target/linux/generic-2.4/patches/610-netfilter_connbytes.patch +++ /dev/null @@ -1,417 +0,0 @@ ---- a/net/ipv4/netfilter/Config.in -+++ b/net/ipv4/netfilter/Config.in -@@ -11,6 +11,8 @@ if [ "$CONFIG_IP_NF_CONNTRACK" != "n" ]; - dep_tristate ' Amanda protocol support' CONFIG_IP_NF_AMANDA $CONFIG_IP_NF_CONNTRACK - dep_tristate ' TFTP protocol support' CONFIG_IP_NF_TFTP $CONFIG_IP_NF_CONNTRACK - dep_tristate ' IRC protocol support' CONFIG_IP_NF_IRC $CONFIG_IP_NF_CONNTRACK -+ dep_tristate ' Connection tracking flow accounting' CONFIG_IP_NF_CT_ACCT $CONFIG_IP_NF_CONNTRACK -+ dep_tristate ' Connection byte counter support' CONFIG_IP_NF_MATCH_CONNBYTES $CONFIG_IP_NF_CT_ACCT $CONFIG_IP_NF_CONNTRACK $CONFIG_IP_NF_IPTABLES - fi - - if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then ---- a/net/ipv4/netfilter/Makefile -+++ b/net/ipv4/netfilter/Makefile -@@ -85,6 +85,7 @@ obj-$(CONFIG_IP_NF_MATCH_LENGTH) += ipt_ - obj-$(CONFIG_IP_NF_MATCH_TTL) += ipt_ttl.o - obj-$(CONFIG_IP_NF_MATCH_STATE) += ipt_state.o - obj-$(CONFIG_IP_NF_MATCH_CONNMARK) += ipt_connmark.o -+obj-$(CONFIG_IP_NF_MATCH_CONNBYTES) += ipt_connbytes.o - obj-$(CONFIG_IP_NF_MATCH_CONNTRACK) += ipt_conntrack.o - obj-$(CONFIG_IP_NF_MATCH_UNCLEAN) += ipt_unclean.o - obj-$(CONFIG_IP_NF_MATCH_STRING) += ipt_string.o ---- a/net/ipv4/netfilter/ip_conntrack_amanda.c -+++ b/net/ipv4/netfilter/ip_conntrack_amanda.c -@@ -75,7 +75,7 @@ static int help(const struct iphdr *iph, - - /* increase the UDP timeout of the master connection as replies from - * Amanda clients to the server can be quite delayed */ -- ip_ct_refresh(ct, master_timeout * HZ); -+ ip_ct_refresh_acct(ct,ctinfo,NULL, master_timeout * HZ); - - /* Search for "CONNECT " string */ - do { ---- a/net/ipv4/netfilter/ip_conntrack_proto_tcp.c -+++ b/net/ipv4/netfilter/ip_conntrack_proto_tcp.c -@@ -211,7 +211,7 @@ static int tcp_packet(struct ip_conntrac - set_bit(IPS_ASSURED_BIT, &conntrack->status); - - WRITE_UNLOCK(&tcp_lock); -- ip_ct_refresh(conntrack, *tcp_timeouts[newconntrack]); -+ ip_ct_refresh_acct(conntrack,ctinfo,iph, *tcp_timeouts[newconntrack]); - } - - return NF_ACCEPT; ---- a/net/ipv4/netfilter/ip_conntrack_proto_udp.c -+++ b/net/ipv4/netfilter/ip_conntrack_proto_udp.c -@@ -47,16 +47,16 @@ static unsigned int udp_print_conntrack( - /* Returns verdict for packet, and may modify conntracktype */ - static int udp_packet(struct ip_conntrack *conntrack, - struct iphdr *iph, size_t len, -- enum ip_conntrack_info conntrackinfo) -+ enum ip_conntrack_info ctinfo) - { - /* If we've seen traffic both ways, this is some kind of UDP - stream. Extend timeout. */ - if (test_bit(IPS_SEEN_REPLY_BIT, &conntrack->status)) { -- ip_ct_refresh(conntrack, ip_ct_udp_timeout_stream); -+ ip_ct_refresh_acct(conntrack,ctinfo,iph,ip_ct_udp_timeout_stream); - /* Also, more likely to be important, and not a probe */ - set_bit(IPS_ASSURED_BIT, &conntrack->status); - } else -- ip_ct_refresh(conntrack, ip_ct_udp_timeout); -+ ip_ct_refresh_acct(conntrack,ctinfo,iph, ip_ct_udp_timeout); - - return NF_ACCEPT; - } ---- a/net/ipv4/netfilter/ip_conntrack_standalone.c -+++ b/net/ipv4/netfilter/ip_conntrack_standalone.c -@@ -79,6 +79,18 @@ print_expect(char *buffer, const struct - return len; - } - -+#if defined(CONFIG_IP_NF_CT_ACCT) || \ -+ defined(CONFIG_IP_NF_CT_ACCT_MODULE) -+static unsigned int -+print_counters(char *buffer, struct ip_conntrack_counter *counter) -+{ -+ return sprintf(buffer, "packets=%llu bytes=%llu ", -+ counter->packets, counter->bytes); -+} -+#else -+#define print_counters(x, y) 0 -+#endif -+ - static unsigned int - print_conntrack(char *buffer, struct ip_conntrack *conntrack) - { -@@ -98,11 +110,15 @@ print_conntrack(char *buffer, struct ip_ - len += print_tuple(buffer + len, - &conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple, - proto); -+ len += print_counters(buffer + len, -+ &conntrack->counters[IP_CT_DIR_ORIGINAL]); - if (!(test_bit(IPS_SEEN_REPLY_BIT, &conntrack->status))) - len += sprintf(buffer + len, "[UNREPLIED] "); - len += print_tuple(buffer + len, - &conntrack->tuplehash[IP_CT_DIR_REPLY].tuple, - proto); -+ len += print_counters(buffer + len, -+ &conntrack->counters[IP_CT_DIR_REPLY]); - if (test_bit(IPS_ASSURED_BIT, &conntrack->status)) - len += sprintf(buffer + len, "[ASSURED] "); - len += sprintf(buffer + len, "use=%u ", -@@ -481,7 +497,7 @@ EXPORT_SYMBOL(ip_conntrack_get); - EXPORT_SYMBOL(ip_conntrack_helper_register); - EXPORT_SYMBOL(ip_conntrack_helper_unregister); - EXPORT_SYMBOL(ip_ct_iterate_cleanup); --EXPORT_SYMBOL(ip_ct_refresh); -+EXPORT_SYMBOL(ip_ct_refresh_acct); - EXPORT_SYMBOL(ip_ct_find_proto); - EXPORT_SYMBOL(__ip_ct_find_proto); - EXPORT_SYMBOL(ip_ct_find_helper); ---- a/net/ipv4/netfilter/ip_conntrack_proto_generic.c -+++ b/net/ipv4/netfilter/ip_conntrack_proto_generic.c -@@ -41,9 +41,9 @@ static unsigned int generic_print_conntr - /* Returns verdict for packet, or -1 for invalid. */ - static int established(struct ip_conntrack *conntrack, - struct iphdr *iph, size_t len, -- enum ip_conntrack_info conntrackinfo) -+ enum ip_conntrack_info ctinfo) - { -- ip_ct_refresh(conntrack, ip_ct_generic_timeout); -+ ip_ct_refresh_acct(conntrack, ctinfo,iph,ip_ct_generic_timeout); - return NF_ACCEPT; - } - ---- a/net/ipv4/netfilter/ip_conntrack_proto_icmp.c -+++ b/net/ipv4/netfilter/ip_conntrack_proto_icmp.c -@@ -82,7 +82,7 @@ static int icmp_packet(struct ip_conntra - ct->timeout.function((unsigned long)ct); - } else { - atomic_inc(&ct->proto.icmp.count); -- ip_ct_refresh(ct, ip_ct_icmp_timeout); -+ ip_ct_refresh_acct(ct,ctinfo,iph, ip_ct_icmp_timeout); - } - - return NF_ACCEPT; ---- a/net/ipv4/netfilter/ip_conntrack_core.c -+++ b/net/ipv4/netfilter/ip_conntrack_core.c -@@ -1193,22 +1193,40 @@ void ip_conntrack_helper_unregister(stru - - MOD_DEC_USE_COUNT; - } -+static inline void ct_add_counters(struct ip_conntrack *ct, -+ enum ip_conntrack_info ctinfo, -+ const struct iphdr *iph) -+{ -+#if defined(CONFIG_IP_NF_CT_ACCT) || \ -+ defined(CONFIG_IP_NF_CT_ACCT_MODULE) -+ if (iph) { -+ ct->counters[CTINFO2DIR(ctinfo)].packets++; -+ ct->counters[CTINFO2DIR(ctinfo)].bytes += -+ ntohs(iph->tot_len); -+ } -+#endif -+} - - /* Refresh conntrack for this many jiffies. */ --void ip_ct_refresh(struct ip_conntrack *ct, unsigned long extra_jiffies) -+void ip_ct_refresh_acct(struct ip_conntrack *ct, -+ enum ip_conntrack_info ctinfo, -+ const struct iphdr *iph, -+ unsigned long extra_jiffies) - { - IP_NF_ASSERT(ct->timeout.data == (unsigned long)ct); - - WRITE_LOCK(&ip_conntrack_lock); - /* If not in hash table, timer will not be active yet */ -- if (!is_confirmed(ct)) -+ if (!is_confirmed(ct)) { - ct->timeout.expires = extra_jiffies; -- else { -+ ct_add_counters(ct, ctinfo,iph); -+ } else { - /* Need del_timer for race avoidance (may already be dying). */ - if (del_timer(&ct->timeout)) { - ct->timeout.expires = jiffies + extra_jiffies; - add_timer(&ct->timeout); - } -+ ct_add_counters(ct, ctinfo, iph); - } - WRITE_UNLOCK(&ip_conntrack_lock); - } ---- a/include/linux/netfilter_ipv4/ip_conntrack.h -+++ b/include/linux/netfilter_ipv4/ip_conntrack.h -@@ -156,6 +156,12 @@ struct ip_conntrack_expect - union ip_conntrack_expect_help help; - }; - -+struct ip_conntrack_counter -+{ -+ u_int64_t packets; -+ u_int64_t bytes; -+}; -+ - struct ip_conntrack_helper; - - struct ip_conntrack -@@ -173,6 +179,12 @@ struct ip_conntrack - /* Timer function; drops refcnt when it goes off. */ - struct timer_list timeout; - -+#if defined(CONFIG_IP_NF_CT_ACCT) || \ -+ defined(CONFIG_IP_NF_CT_ACCT_MODULE) -+ /* Accounting Information (same cache line as other written members) */ -+ struct ip_conntrack_counter counters[IP_CT_DIR_MAX]; -+#endif -+ - /* If we're expecting another related connection, this will be - in expected linked list */ - struct list_head sibling_list; -@@ -256,8 +268,10 @@ extern int invert_tuplepr(struct ip_conn - const struct ip_conntrack_tuple *orig); - - /* Refresh conntrack for this many jiffies */ --extern void ip_ct_refresh(struct ip_conntrack *ct, -- unsigned long extra_jiffies); -+extern void ip_ct_refresh_acct(struct ip_conntrack *ct, -+ enum ip_conntrack_info ctinfo, -+ const struct iphdr *iph, -+ unsigned long extra_jiffies); - - /* These are for NAT. Icky. */ - /* Call me when a conntrack is destroyed. */ ---- /dev/null -+++ b/net/ipv4/netfilter/ipt_connbytes.c -@@ -0,0 +1,163 @@ -+/* Kernel module to match connection tracking byte counter. -+ * GPL (C) 2002 Martin Devera (devik@cdi.cz). -+ * -+ * 2004-07-20 Harald Welte <laforge at netfilter.org> -+ * - reimplemented to use per-connection accounting counters -+ * - add functionality to match number of packets -+ * - add functionality to match average packet size -+ * - add support to match directions seperately -+ * -+ * 2004-10-24 Piotr Chytla <pch at fouk.org> -+ * - Connbytes with per-connection accouting backported to 2.4 -+ * -+ */ -+ -+#include <linux/module.h> -+#include <linux/skbuff.h> -+#include <linux/types.h> -+#include <linux/netfilter_ipv4/ip_conntrack.h> -+#include <linux/netfilter_ipv4/ip_tables.h> -+#include <linux/netfilter_ipv4/ipt_connbytes.h> -+ -+#include <asm/div64.h> -+ -+static u_int64_t mydiv(u_int64_t arg1,u_int32_t arg2) -+{ -+ do_div(arg1,arg2); -+ return arg1; -+} -+ -+static int -+match(const struct sk_buff *skb, -+ const struct net_device *in, -+ const struct net_device *out, -+ const void *matchinfo, -+ int offset, -+ const void *hdr, -+ u_int16_t datalen, -+ int *hotdrop) -+{ -+ static u_int64_t what; -+ const struct ipt_connbytes_info *sinfo = matchinfo; -+ enum ip_conntrack_info ctinfo; -+ struct ip_conntrack *ct; -+ -+ if (!(ct = ip_conntrack_get((struct sk_buff *)skb, &ctinfo))) -+ return 0; /* no match */ -+ switch (sinfo->what) { -+ case IPT_CONNBYTES_PKTS: -+ switch (sinfo->direction) { -+ case IPT_CONNBYTES_DIR_ORIGINAL: -+ what = ct->counters[IP_CT_DIR_ORIGINAL].packets; -+ break; -+ case IPT_CONNBYTES_DIR_REPLY: -+ what = ct->counters[IP_CT_DIR_REPLY].packets; -+ break; -+ case IPT_CONNBYTES_DIR_BOTH: -+ what = ct->counters[IP_CT_DIR_ORIGINAL].packets; -+ what += ct->counters[IP_CT_DIR_REPLY].packets; -+ break; -+ } -+ break; -+ case IPT_CONNBYTES_BYTES: -+ switch (sinfo->direction) { -+ case IPT_CONNBYTES_DIR_ORIGINAL: -+ what = ct->counters[IP_CT_DIR_ORIGINAL].bytes; -+ break; -+ case IPT_CONNBYTES_DIR_REPLY: -+ what = ct->counters[IP_CT_DIR_REPLY].bytes; -+ break; -+ case IPT_CONNBYTES_DIR_BOTH: -+ what = ct->counters[IP_CT_DIR_ORIGINAL].bytes; -+ what += ct->counters[IP_CT_DIR_REPLY].bytes; -+ break; -+ } -+ break; -+ case IPT_CONNBYTES_AVGPKT: -+ switch (sinfo->direction) { -+ case IPT_CONNBYTES_DIR_ORIGINAL: -+ { -+ u_int32_t pkts32; -+ -+ if (ct->counters[IP_CT_DIR_ORIGINAL].packets > 0xfffffffff) -+ pkts32 = 0xffffffff; -+ else -+ pkts32 = ct->counters[IP_CT_DIR_ORIGINAL].packets; -+ what = mydiv(ct->counters[IP_CT_DIR_ORIGINAL].bytes,pkts32); -+ } -+ break; -+ case IPT_CONNBYTES_DIR_REPLY: -+ { -+ u_int32_t pkts32; -+ -+ if (ct->counters[IP_CT_DIR_REPLY].packets > 0xffffffff) -+ pkts32 = 0xffffffff; -+ else -+ pkts32 = ct->counters[IP_CT_DIR_REPLY].packets; -+ what = mydiv(ct->counters[IP_CT_DIR_REPLY].bytes,pkts32); -+ } -+ break; -+ case IPT_CONNBYTES_DIR_BOTH: -+ { -+ u_int64_t bytes; -+ u_int64_t pkts; -+ u_int32_t pkts32; -+ bytes = ct->counters[IP_CT_DIR_ORIGINAL].bytes + -+ ct->counters[IP_CT_DIR_REPLY].bytes; -+ pkts = ct->counters[IP_CT_DIR_ORIGINAL].packets + -+ ct->counters[IP_CT_DIR_REPLY].packets; -+ if (pkts > 0xffffffff) -+ pkts32 = 0xffffffff; -+ else -+ pkts32 = pkts; -+ what = mydiv(bytes,pkts); -+ } -+ break; -+ } -+ break; -+ } -+ if (sinfo->count.to) -+ return (what <= sinfo->count.to && what >= sinfo->count.from); -+ else -+ return (what >= sinfo->count.from); -+} -+ -+static int check(const char *tablename, -+ const struct ipt_ip *ip, -+ void *matchinfo, -+ unsigned int matchsize, -+ unsigned int hook_mask) -+{ -+ const struct ipt_connbytes_info *sinfo = matchinfo; -+ -+ if (matchsize != IPT_ALIGN(sizeof(struct ipt_connbytes_info))) -+ return 0; -+ if (sinfo->what != IPT_CONNBYTES_PKTS && -+ sinfo->what != IPT_CONNBYTES_BYTES && -+ sinfo->what != IPT_CONNBYTES_AVGPKT) -+ return 0; -+ -+ if (sinfo->direction != IPT_CONNBYTES_DIR_ORIGINAL && -+ sinfo->direction != IPT_CONNBYTES_DIR_REPLY && -+ sinfo->direction != IPT_CONNBYTES_DIR_BOTH) -+ return 0; -+ -+ return 1; -+} -+ -+static struct ipt_match state_match -+= { { NULL, NULL }, "connbytes", &match, &check, NULL, THIS_MODULE }; -+ -+static int __init init(void) -+{ -+ return ipt_register_match(&state_match); -+} -+ -+static void __exit fini(void) -+{ -+ ipt_unregister_match(&state_match); -+} -+ -+module_init(init); -+module_exit(fini); -+MODULE_LICENSE("GPL"); ---- /dev/null -+++ b/include/linux/netfilter_ipv4/ipt_connbytes.h -@@ -0,0 +1,25 @@ -+#ifndef _IPT_CONNBYTES_H -+#define _IPT_CONNBYTES_H -+enum ipt_connbytes_what { -+ IPT_CONNBYTES_PKTS, -+ IPT_CONNBYTES_BYTES, -+ IPT_CONNBYTES_AVGPKT, -+}; -+ -+enum ipt_connbytes_direction { -+ IPT_CONNBYTES_DIR_ORIGINAL, -+ IPT_CONNBYTES_DIR_REPLY, -+ IPT_CONNBYTES_DIR_BOTH, -+}; -+ -+struct ipt_connbytes_info -+{ -+ struct { -+ u_int64_t from; /* count to be matched */ -+ u_int64_t to; /* count to be matched */ -+ } count; -+ u_int8_t what; /* ipt_connbytes_what */ -+ u_int8_t direction; /* ipt_connbytes_direction */ -+}; -+ -+#endif diff --git a/target/linux/generic-2.4/patches/611-netfilter_condition.patch b/target/linux/generic-2.4/patches/611-netfilter_condition.patch deleted file mode 100644 index 511d32a..0000000 --- a/target/linux/generic-2.4/patches/611-netfilter_condition.patch +++ /dev/null @@ -1,616 +0,0 @@ ---- a/Documentation/Configure.help -+++ b/Documentation/Configure.help -@@ -2979,6 +2979,14 @@ CONFIG_IP_NF_MATCH_TOS - If you want to compile it as a module, say M here and read - <file:Documentation/modules.txt>. If unsure, say `N'. - -+Condition variable match support -+CONFIG_IP_NF_MATCH_CONDITION -+ This option allows you to match firewall rules against condition -+ variables stored in the /proc/net/ipt_condition directory. -+ -+ If you want to compile it as a module, say M here and read -+ Documentation/modules.txt. If unsure, say `N'. -+ - conntrack match support - CONFIG_IP_NF_MATCH_CONNTRACK - This is a general conntrack match module, a superset of the state match. -@@ -3296,6 +3304,14 @@ CONFIG_IP6_NF_MATCH_MARK - If you want to compile it as a module, say M here and read - <file:Documentation/modules.txt>. If unsure, say `N'. - -+Condition variable match support -+CONFIG_IP6_NF_MATCH_CONDITION -+ This option allows you to match firewall rules against condition -+ variables stored in the /proc/net/ipt_condition directory. -+ -+ If you want to compile it as a module, say M here and read -+ Documentation/modules.txt. If unsure, say `N'. -+ - Multiple port match support - CONFIG_IP6_NF_MATCH_MULTIPORT - Multiport matching allows you to match TCP or UDP packets based on ---- /dev/null -+++ b/include/linux/netfilter_ipv4/ipt_condition.h -@@ -0,0 +1,11 @@ -+#ifndef __IPT_CONDITION_MATCH__ -+#define __IPT_CONDITION_MATCH__ -+ -+#define CONDITION_NAME_LEN 32 -+ -+struct condition_info { -+ char name[CONDITION_NAME_LEN]; -+ int invert; -+}; -+ -+#endif ---- /dev/null -+++ b/include/linux/netfilter_ipv6/ip6t_condition.h -@@ -0,0 +1,11 @@ -+#ifndef __IP6T_CONDITION_MATCH__ -+#define __IP6T_CONDITION_MATCH__ -+ -+#define CONDITION6_NAME_LEN 32 -+ -+struct condition6_info { -+ char name[CONDITION6_NAME_LEN]; -+ int invert; -+}; -+ -+#endif ---- a/net/ipv4/netfilter/Config.in -+++ b/net/ipv4/netfilter/Config.in -@@ -27,6 +27,7 @@ if [ "$CONFIG_IP_NF_IPTABLES" != "n" ]; - dep_tristate ' netfilter MARK match support' CONFIG_IP_NF_MATCH_MARK $CONFIG_IP_NF_IPTABLES - dep_tristate ' Multiple port match support' CONFIG_IP_NF_MATCH_MULTIPORT $CONFIG_IP_NF_IPTABLES - dep_tristate ' TOS match support' CONFIG_IP_NF_MATCH_TOS $CONFIG_IP_NF_IPTABLES -+ dep_tristate ' condition match support' CONFIG_IP_NF_MATCH_CONDITION $CONFIG_IP_NF_IPTABLES - dep_tristate ' recent match support' CONFIG_IP_NF_MATCH_RECENT $CONFIG_IP_NF_IPTABLES - dep_tristate ' ECN match support' CONFIG_IP_NF_MATCH_ECN $CONFIG_IP_NF_IPTABLES - dep_tristate ' peer to peer traffic match support' CONFIG_IP_NF_MATCH_IPP2P $CONFIG_IP_NF_IPTABLES ---- a/net/ipv4/netfilter/Makefile -+++ b/net/ipv4/netfilter/Makefile -@@ -73,6 +73,7 @@ obj-$(CONFIG_IP_NF_MATCH_PKTTYPE) += ipt - obj-$(CONFIG_IP_NF_MATCH_MULTIPORT) += ipt_multiport.o - obj-$(CONFIG_IP_NF_MATCH_OWNER) += ipt_owner.o - obj-$(CONFIG_IP_NF_MATCH_TOS) += ipt_tos.o -+obj-$(CONFIG_IP_NF_MATCH_CONDITION) += ipt_condition.o - - obj-$(CONFIG_IP_NF_MATCH_RECENT) += ipt_recent.o - ---- /dev/null -+++ b/net/ipv4/netfilter/ipt_condition.c -@@ -0,0 +1,256 @@ -+/*-------------------------------------------*\ -+| Netfilter Condition Module | -+| | -+| Description: This module allows firewall | -+| rules to match using condition variables | -+| stored in /proc files. | -+| | -+| Author: Stephane Ouellette 2002-10-22 | -+| <ouellettes@videotron.ca> | -+| | -+| History: | -+| 2003-02-10 Second version with improved | -+| locking and simplified code. | -+| | -+| This software is distributed under the | -+| terms of the GNU GPL. | -+\*-------------------------------------------*/ -+ -+#include<linux/module.h> -+#include<linux/proc_fs.h> -+#include<linux/spinlock.h> -+#include<linux/string.h> -+#include<asm/atomic.h> -+#include<linux/netfilter_ipv4/ip_tables.h> -+#include<linux/netfilter_ipv4/ipt_condition.h> -+ -+ -+#ifndef CONFIG_PROC_FS -+#error "Proc file system support is required for this module" -+#endif -+ -+ -+MODULE_AUTHOR("Stephane Ouellette <ouellettes@videotron.ca>"); -+MODULE_DESCRIPTION("Allows rules to match against condition variables"); -+MODULE_LICENSE("GPL"); -+ -+ -+struct condition_variable { -+ struct condition_variable *next; -+ struct proc_dir_entry *status_proc; -+ atomic_t refcount; -+ int enabled; /* TRUE == 1, FALSE == 0 */ -+}; -+ -+ -+static rwlock_t list_lock; -+static struct condition_variable *head = NULL; -+static struct proc_dir_entry *proc_net_condition = NULL; -+ -+ -+static int -+ipt_condition_read_info(char *buffer, char **start, off_t offset, -+ int length, int *eof, void *data) -+{ -+ struct condition_variable *var = -+ (struct condition_variable *) data; -+ -+ if (offset == 0) { -+ *start = buffer; -+ buffer[0] = (var->enabled) ? '1' : '0'; -+ buffer[1] = '\n'; -+ return 2; -+ } -+ -+ *eof = 1; -+ return 0; -+} -+ -+ -+static int -+ipt_condition_write_info(struct file *file, const char *buffer, -+ unsigned long length, void *data) -+{ -+ struct condition_variable *var = -+ (struct condition_variable *) data; -+ -+ if (length) { -+ /* Match only on the first character */ -+ switch (buffer[0]) { -+ case '0': -+ var->enabled = 0; -+ break; -+ case '1': -+ var->enabled = 1; -+ } -+ } -+ -+ return (int) length; -+} -+ -+ -+static int -+match(const struct sk_buff *skb, const struct net_device *in, -+ const struct net_device *out, const void *matchinfo, int offset, -+ const void *hdr, u_int16_t datalen, int *hotdrop) -+{ -+ const struct condition_info *info = -+ (const struct condition_info *) matchinfo; -+ struct condition_variable *var; -+ int condition_status = 0; -+ -+ read_lock(&list_lock); -+ -+ for (var = head; var; var = var->next) { -+ if (strcmp(info->name, var->status_proc->name) == 0) { -+ condition_status = var->enabled; -+ break; -+ } -+ } -+ -+ read_unlock(&list_lock); -+ -+ return condition_status ^ info->invert; -+} -+ -+ -+ -+static int -+checkentry(const char *tablename, const struct ipt_ip *ip, -+ void *matchinfo, unsigned int matchsize, unsigned int hook_mask) -+{ -+ struct condition_info *info = (struct condition_info *) matchinfo; -+ struct condition_variable *var, *newvar; -+ -+ if (matchsize != IPT_ALIGN(sizeof(struct condition_info))) -+ return 0; -+ -+ /* The first step is to check if the condition variable already exists. */ -+ /* Here, a read lock is sufficient because we won't change the list */ -+ read_lock(&list_lock); -+ -+ for (var = head; var; var = var->next) { -+ if (strcmp(info->name, var->status_proc->name) == 0) { -+ atomic_inc(&var->refcount); -+ read_unlock(&list_lock); -+ return 1; -+ } -+ } -+ -+ read_unlock(&list_lock); -+ -+ /* At this point, we need to allocate a new condition variable */ -+ newvar = kmalloc(sizeof(struct condition_variable), GFP_KERNEL); -+ -+ if (!newvar) -+ return -ENOMEM; -+ -+ /* Create the condition variable's proc file entry */ -+ newvar->status_proc = create_proc_entry(info->name, 0644, proc_net_condition); -+ -+ if (!newvar->status_proc) { -+ /* -+ * There are two possibilities: -+ * 1- Another condition variable with the same name has been created, which is valid. -+ * 2- There was a memory allocation error. -+ */ -+ kfree(newvar); -+ read_lock(&list_lock); -+ -+ for (var = head; var; var = var->next) { -+ if (strcmp(info->name, var->status_proc->name) == 0) { -+ atomic_inc(&var->refcount); -+ read_unlock(&list_lock); -+ return 1; -+ } -+ } -+ -+ read_unlock(&list_lock); -+ return -ENOMEM; -+ } -+ -+ atomic_set(&newvar->refcount, 1); -+ newvar->enabled = 0; -+ newvar->status_proc->owner = THIS_MODULE; -+ newvar->status_proc->data = newvar; -+ wmb(); -+ newvar->status_proc->read_proc = ipt_condition_read_info; -+ newvar->status_proc->write_proc = ipt_condition_write_info; -+ -+ write_lock(&list_lock); -+ -+ newvar->next = head; -+ head = newvar; -+ -+ write_unlock(&list_lock); -+ -+ return 1; -+} -+ -+ -+static void -+destroy(void *matchinfo, unsigned int matchsize) -+{ -+ struct condition_info *info = (struct condition_info *) matchinfo; -+ struct condition_variable *var, *prev = NULL; -+ -+ if (matchsize != IPT_ALIGN(sizeof(struct condition_info))) -+ return; -+ -+ write_lock(&list_lock); -+ -+ for (var = head; var && strcmp(info->name, var->status_proc->name); -+ prev = var, var = var->next); -+ -+ if (var && atomic_dec_and_test(&var->refcount)) { -+ if (prev) -+ prev->next = var->next; -+ else -+ head = var->next; -+ -+ write_unlock(&list_lock); -+ remove_proc_entry(var->status_proc->name, proc_net_condition); -+ kfree(var); -+ } else -+ write_unlock(&list_lock); -+} -+ -+ -+static struct ipt_match condition_match = { -+ .name = "condition", -+ .match = &match, -+ .checkentry = &checkentry, -+ .destroy = &destroy, -+ .me = THIS_MODULE -+}; -+ -+ -+static int __init -+init(void) -+{ -+ int errorcode; -+ -+ rwlock_init(&list_lock); -+ proc_net_condition = proc_mkdir("ipt_condition", proc_net); -+ -+ if (proc_net_condition) { -+ errorcode = ipt_register_match(&condition_match); -+ -+ if (errorcode) -+ remove_proc_entry("ipt_condition", proc_net); -+ } else -+ errorcode = -EACCES; -+ -+ return errorcode; -+} -+ -+ -+static void __exit -+fini(void) -+{ -+ ipt_unregister_match(&condition_match); -+ remove_proc_entry("ipt_condition", proc_net); -+} -+ -+module_init(init); -+module_exit(fini); ---- a/net/ipv6/netfilter/Config.in -+++ b/net/ipv6/netfilter/Config.in -@@ -17,6 +17,7 @@ tristate 'IP6 tables support (required f - if [ "$CONFIG_IP6_NF_IPTABLES" != "n" ]; then - # The simple matches. - dep_tristate ' limit match support' CONFIG_IP6_NF_MATCH_LIMIT $CONFIG_IP6_NF_IPTABLES -+ dep_tristate ' condition match support' CONFIG_IP6_NF_MATCH_CONDITION $CONFIG_IP6_NF_IPTABLES - dep_tristate ' MAC address match support' CONFIG_IP6_NF_MATCH_MAC $CONFIG_IP6_NF_IPTABLES - if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then - dep_tristate ' Routing header match support (EXPERIMENTAL)' CONFIG_IP6_NF_MATCH_RT $CONFIG_IP6_NF_IPTABLES ---- a/net/ipv6/netfilter/Makefile -+++ b/net/ipv6/netfilter/Makefile -@@ -14,6 +14,7 @@ export-objs := ip6_tables.o - # Link order matters here. - obj-$(CONFIG_IP6_NF_IPTABLES) += ip6_tables.o - obj-$(CONFIG_IP6_NF_MATCH_LIMIT) += ip6t_limit.o -+obj-$(CONFIG_IP6_NF_MATCH_CONDITION) += ip6t_condition.o - obj-$(CONFIG_IP6_NF_MATCH_MARK) += ip6t_mark.o - obj-$(CONFIG_IP6_NF_MATCH_LENGTH) += ip6t_length.o - obj-$(CONFIG_IP6_NF_MATCH_MAC) += ip6t_mac.o ---- /dev/null -+++ b/net/ipv6/netfilter/ip6t_condition.c -@@ -0,0 +1,254 @@ -+/*-------------------------------------------*\ -+| Netfilter Condition Module for IPv6 | -+| | -+| Description: This module allows firewall | -+| rules to match using condition variables | -+| stored in /proc files. | -+| | -+| Author: Stephane Ouellette 2003-02-10 | -+| <ouellettes@videotron.ca> | -+| | -+| This software is distributed under the | -+| terms of the GNU GPL. | -+\*-------------------------------------------*/ -+ -+#include<linux/module.h> -+#include<linux/proc_fs.h> -+#include<linux/spinlock.h> -+#include<linux/string.h> -+#include<asm/atomic.h> -+#include<linux/netfilter_ipv6/ip6_tables.h> -+#include<linux/netfilter_ipv6/ip6t_condition.h> -+ -+ -+#ifndef CONFIG_PROC_FS -+#error "Proc file system support is required for this module" -+#endif -+ -+ -+MODULE_AUTHOR("Stephane Ouellette <ouellettes@videotron.ca>"); -+MODULE_DESCRIPTION("Allows rules to match against condition variables"); -+MODULE_LICENSE("GPL"); -+ -+ -+struct condition_variable { -+ struct condition_variable *next; -+ struct proc_dir_entry *status_proc; -+ atomic_t refcount; -+ int enabled; /* TRUE == 1, FALSE == 0 */ -+}; -+ -+ -+static rwlock_t list_lock; -+static struct condition_variable *head = NULL; -+static struct proc_dir_entry *proc_net_condition = NULL; -+ -+ -+static int -+ipt_condition_read_info(char *buffer, char **start, off_t offset, -+ int length, int *eof, void *data) -+{ -+ struct condition_variable *var = -+ (struct condition_variable *) data; -+ -+ if (offset == 0) { -+ *start = buffer; -+ buffer[0] = (var->enabled) ? '1' : '0'; -+ buffer[1] = '\n'; -+ return 2; -+ } -+ -+ *eof = 1; -+ return 0; -+} -+ -+ -+static int -+ipt_condition_write_info(struct file *file, const char *buffer, -+ unsigned long length, void *data) -+{ -+ struct condition_variable *var = -+ (struct condition_variable *) data; -+ -+ if (length) { -+ /* Match only on the first character */ -+ switch (buffer[0]) { -+ case '0': -+ var->enabled = 0; -+ break; -+ case '1': -+ var->enabled = 1; -+ } -+ } -+ -+ return (int) length; -+} -+ -+ -+static int -+match(const struct sk_buff *skb, const struct net_device *in, -+ const struct net_device *out, const void *matchinfo, int offset, -+ const void *hdr, u_int16_t datalen, int *hotdrop) -+{ -+ const struct condition6_info *info = -+ (const struct condition6_info *) matchinfo; -+ struct condition_variable *var; -+ int condition_status = 0; -+ -+ read_lock(&list_lock); -+ -+ for (var = head; var; var = var->next) { -+ if (strcmp(info->name, var->status_proc->name) == 0) { -+ condition_status = var->enabled; -+ break; -+ } -+ } -+ -+ read_unlock(&list_lock); -+ -+ return condition_status ^ info->invert; -+} -+ -+ -+ -+static int -+checkentry(const char *tablename, const struct ip6t_ip6 *ip, -+ void *matchinfo, unsigned int matchsize, unsigned int hook_mask) -+{ -+ struct condition6_info *info = -+ (struct condition6_info *) matchinfo; -+ struct condition_variable *var, *newvar; -+ -+ if (matchsize != IP6T_ALIGN(sizeof(struct condition6_info))) -+ return 0; -+ -+ /* The first step is to check if the condition variable already exists. */ -+ /* Here, a read lock is sufficient because we won't change the list */ -+ read_lock(&list_lock); -+ -+ for (var = head; var; var = var->next) { -+ if (strcmp(info->name, var->status_proc->name) == 0) { -+ atomic_inc(&var->refcount); -+ read_unlock(&list_lock); -+ return 1; -+ } -+ } -+ -+ read_unlock(&list_lock); -+ -+ /* At this point, we need to allocate a new condition variable */ -+ newvar = kmalloc(sizeof(struct condition_variable), GFP_KERNEL); -+ -+ if (!newvar) -+ return -ENOMEM; -+ -+ /* Create the condition variable's proc file entry */ -+ newvar->status_proc = create_proc_entry(info->name, 0644, proc_net_condition); -+ -+ if (!newvar->status_proc) { -+ /* -+ * There are two possibilities: -+ * 1- Another condition variable with the same name has been created, which is valid. -+ * 2- There was a memory allocation error. -+ */ -+ kfree(newvar); -+ read_lock(&list_lock); -+ -+ for (var = head; var; var = var->next) { -+ if (strcmp(info->name, var->status_proc->name) == 0) { -+ atomic_inc(&var->refcount); -+ read_unlock(&list_lock); -+ return 1; -+ } -+ } -+ -+ read_unlock(&list_lock); -+ return -ENOMEM; -+ } -+ -+ atomic_set(&newvar->refcount, 1); -+ newvar->enabled = 0; -+ newvar->status_proc->owner = THIS_MODULE; -+ newvar->status_proc->data = newvar; -+ wmb(); -+ newvar->status_proc->read_proc = ipt_condition_read_info; -+ newvar->status_proc->write_proc = ipt_condition_write_info; -+ -+ write_lock(&list_lock); -+ -+ newvar->next = head; -+ head = newvar; -+ -+ write_unlock(&list_lock); -+ -+ return 1; -+} -+ -+ -+static void -+destroy(void *matchinfo, unsigned int matchsize) -+{ -+ struct condition6_info *info = -+ (struct condition6_info *) matchinfo; -+ struct condition_variable *var, *prev = NULL; -+ -+ if (matchsize != IP6T_ALIGN(sizeof(struct condition6_info))) -+ return; -+ -+ write_lock(&list_lock); -+ -+ for (var = head; var && strcmp(info->name, var->status_proc->name); -+ prev = var, var = var->next); -+ -+ if (var && atomic_dec_and_test(&var->refcount)) { -+ if (prev) -+ prev->next = var->next; -+ else -+ head = var->next; -+ -+ write_unlock(&list_lock); -+ remove_proc_entry(var->status_proc->name, proc_net_condition); -+ kfree(var); -+ } else -+ write_unlock(&list_lock); -+} -+ -+ -+static struct ip6t_match condition_match = { -+ .name = "condition", -+ .match = &match, -+ .checkentry = &checkentry, -+ .destroy = &destroy, -+ .me = THIS_MODULE -+}; -+ -+ -+static int __init -+init(void) -+{ -+ int errorcode; -+ -+ rwlock_init(&list_lock); -+ proc_net_condition = proc_mkdir("ip6t_condition", proc_net); -+ -+ if (proc_net_condition) { -+ errorcode = ipt_register_match(&condition_match); -+ -+ if (errorcode) -+ remove_proc_entry("ip6t_condition", proc_net); -+ } else -+ errorcode = -EACCES; -+ -+ return errorcode; -+} -+ -+ -+static void __exit -+fini(void) -+{ -+ ipt_unregister_match(&condition_match); -+ remove_proc_entry("ip6t_condition", proc_net); -+} -+ -+module_init(init); -+module_exit(fini); diff --git a/target/linux/generic-2.4/patches/612-netfilter_quota.patch b/target/linux/generic-2.4/patches/612-netfilter_quota.patch deleted file mode 100644 index d5bb1e2..0000000 --- a/target/linux/generic-2.4/patches/612-netfilter_quota.patch +++ /dev/null @@ -1,142 +0,0 @@ ---- a/Documentation/Configure.help -+++ b/Documentation/Configure.help -@@ -2888,6 +2888,13 @@ CONFIG_IP_NF_MATCH_LIMIT - If you want to compile it as a module, say M here and read - <file:Documentation/modules.txt>. If unsure, say `N'. - -+quota match support -+CONFIG_IP_NF_MATCH_QUOTA -+ This match implements network quotas. -+ -+ If you want to compile it as a module, say M here and read -+ Documentation/modules.txt. If unsure, say `N'. -+ - skb->pkt_type packet match support - CONFIG_IP_NF_MATCH_PKTTYPE - This patch allows you to match packet in accrodance ---- /dev/null -+++ b/include/linux/netfilter_ipv4/ipt_quota.h -@@ -0,0 +1,12 @@ -+#ifndef _IPT_QUOTA_H -+#define _IPT_QUOTA_H -+ -+/* print debug info in both kernel/netfilter module & iptable library */ -+//#define DEBUG_IPT_QUOTA -+ -+struct ipt_quota_info { -+ u_int64_t quota; -+ struct ipt_quota_info *master; -+}; -+ -+#endif /*_IPT_QUOTA_H*/ ---- a/net/ipv4/netfilter/Config.in -+++ b/net/ipv4/netfilter/Config.in -@@ -22,6 +22,7 @@ tristate 'IP tables support (required fo - if [ "$CONFIG_IP_NF_IPTABLES" != "n" ]; then - # The simple matches. - dep_tristate ' limit match support' CONFIG_IP_NF_MATCH_LIMIT $CONFIG_IP_NF_IPTABLES -+ dep_tristate ' quota match support' CONFIG_IP_NF_MATCH_QUOTA $CONFIG_IP_NF_IPTABLES - dep_tristate ' MAC address match support' CONFIG_IP_NF_MATCH_MAC $CONFIG_IP_NF_IPTABLES - dep_tristate ' Packet type match support' CONFIG_IP_NF_MATCH_PKTTYPE $CONFIG_IP_NF_IPTABLES - dep_tristate ' netfilter MARK match support' CONFIG_IP_NF_MATCH_MARK $CONFIG_IP_NF_IPTABLES ---- a/net/ipv4/netfilter/Makefile -+++ b/net/ipv4/netfilter/Makefile -@@ -65,6 +65,7 @@ obj-$(CONFIG_IP_NF_NAT) += iptable_nat.o - # matches - obj-$(CONFIG_IP_NF_MATCH_HELPER) += ipt_helper.o - obj-$(CONFIG_IP_NF_MATCH_LIMIT) += ipt_limit.o -+obj-$(CONFIG_IP_NF_MATCH_QUOTA) += ipt_quota.o - obj-$(CONFIG_IP_NF_MATCH_MARK) += ipt_mark.o - obj-$(CONFIG_IP_NF_MATCH_MAC) += ipt_mac.o - obj-$(CONFIG_IP_NF_MATCH_IPP2P) += ipt_ipp2p.o ---- /dev/null -+++ b/net/ipv4/netfilter/ipt_quota.c -@@ -0,0 +1,88 @@ -+/* -+ * netfilter module to enforce network quotas -+ * -+ * Sam Johnston <samj@samj.net> -+ * -+ * 30/01/05: Fixed on SMP --Pablo Neira <pablo@eurodev.net> -+ */ -+#include <linux/module.h> -+#include <linux/skbuff.h> -+#include <linux/spinlock.h> -+#include <linux/interrupt.h> -+ -+#include <linux/netfilter_ipv4/ip_tables.h> -+#include <linux/netfilter_ipv4/ipt_quota.h> -+ -+MODULE_LICENSE("GPL"); -+ -+static spinlock_t quota_lock = SPIN_LOCK_UNLOCKED; -+ -+static int -+match(const struct sk_buff *skb, -+ const struct net_device *in, -+ const struct net_device *out, -+ const void *matchinfo, -+ int offset, const void *hdr, u_int16_t datalen, int *hotdrop) -+{ -+ struct ipt_quota_info *q = -+ ((struct ipt_quota_info *) matchinfo)->master; -+ -+ spin_lock_bh("a_lock); -+ -+ if (q->quota >= datalen) { -+ /* we can afford this one */ -+ q->quota -= datalen; -+ spin_unlock_bh("a_lock); -+ -+#ifdef DEBUG_IPT_QUOTA -+ printk("IPT Quota OK: %llu datlen %d \n", q->quota, datalen); -+#endif -+ return 1; -+ } -+ -+ /* so we do not allow even small packets from now on */ -+ q->quota = 0; -+ -+#ifdef DEBUG_IPT_QUOTA -+ printk("IPT Quota Failed: %llu datlen %d \n", q->quota, datalen); -+#endif -+ -+ spin_unlock_bh("a_lock); -+ return 0; -+} -+ -+static int -+checkentry(const char *tablename, -+ const struct ipt_ip *ip, -+ void *matchinfo, unsigned int matchsize, unsigned int hook_mask) -+{ -+ /* TODO: spinlocks? sanity checks? */ -+ struct ipt_quota_info *q = (struct ipt_quota_info *) matchinfo; -+ -+ if (matchsize != IPT_ALIGN(sizeof (struct ipt_quota_info))) -+ return 0; -+ -+ /* For SMP, we only want to use one set of counters. */ -+ q->master = q; -+ -+ return 1; -+} -+ -+static struct ipt_match quota_match -+ = { {NULL, NULL}, "quota", &match, &checkentry, NULL, THIS_MODULE }; -+ -+static int __init -+init(void) -+{ -+ return ipt_register_match("a_match); -+} -+ -+static void __exit -+fini(void) -+{ -+ ipt_unregister_match("a_match); -+} -+ -+module_init(init); -+module_exit(fini); -+ diff --git a/target/linux/generic-2.4/patches/613-netfilter_nat_h323.patch b/target/linux/generic-2.4/patches/613-netfilter_nat_h323.patch deleted file mode 100644 index 9505160..0000000 --- a/target/linux/generic-2.4/patches/613-netfilter_nat_h323.patch +++ /dev/null @@ -1,814 +0,0 @@ ---- a/net/ipv4/netfilter/Config.in -+++ b/net/ipv4/netfilter/Config.in -@@ -13,6 +13,7 @@ if [ "$CONFIG_IP_NF_CONNTRACK" != "n" ]; - dep_tristate ' IRC protocol support' CONFIG_IP_NF_IRC $CONFIG_IP_NF_CONNTRACK - dep_tristate ' Connection tracking flow accounting' CONFIG_IP_NF_CT_ACCT $CONFIG_IP_NF_CONNTRACK - dep_tristate ' Connection byte counter support' CONFIG_IP_NF_MATCH_CONNBYTES $CONFIG_IP_NF_CT_ACCT $CONFIG_IP_NF_CONNTRACK $CONFIG_IP_NF_IPTABLES -+ dep_tristate ' H.323 (netmeeting) support' CONFIG_IP_NF_H323 $CONFIG_IP_NF_CONNTRACK - fi - - if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then -@@ -80,6 +81,13 @@ if [ "$CONFIG_IP_NF_IPTABLES" != "n" ]; - define_tristate CONFIG_IP_NF_NAT_AMANDA $CONFIG_IP_NF_NAT - fi - fi -+ if [ "$CONFIG_IP_NF_H323" = "m" ]; then -+ define_tristate CONFIG_IP_NF_NAT_H323 m -+ else -+ if [ "$CONFIG_IP_NF_H323" = "y" ]; then -+ define_tristate CONFIG_IP_NF_NAT_H323 $CONFIG_IP_NF_NAT -+ fi -+ fi - if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then - dep_tristate ' Basic SNMP-ALG support (EXPERIMENTAL)' CONFIG_IP_NF_NAT_SNMP_BASIC $CONFIG_IP_NF_NAT - fi ---- a/net/ipv4/netfilter/Makefile -+++ b/net/ipv4/netfilter/Makefile -@@ -47,12 +47,17 @@ obj-$(CONFIG_IP_NF_IRC) += ip_conntrack_ - ifdef CONFIG_IP_NF_IRC - export-objs += ip_conntrack_irc.o - endif -+obj-$(CONFIG_IP_NF_H323) += ip_conntrack_h323.o -+ifdef CONFIG_IP_NF_NAT_H323 -+ export-objs += ip_conntrack_h323.o -+endif - - # NAT helpers - obj-$(CONFIG_IP_NF_NAT_AMANDA) += ip_nat_amanda.o - obj-$(CONFIG_IP_NF_NAT_TFTP) += ip_nat_tftp.o - obj-$(CONFIG_IP_NF_NAT_FTP) += ip_nat_ftp.o - obj-$(CONFIG_IP_NF_NAT_IRC) += ip_nat_irc.o -+obj-$(CONFIG_IP_NF_NAT_H323) += ip_nat_h323.o - - # generic IP tables - obj-$(CONFIG_IP_NF_IPTABLES) += ip_tables.o ---- /dev/null -+++ b/net/ipv4/netfilter/ip_conntrack_h323.c -@@ -0,0 +1,302 @@ -+/* -+ * H.323 'brute force' extension for H.323 connection tracking. -+ * Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> -+ * -+ * Based on ip_masq_h323.c for 2.2 kernels from CoRiTel, Sofia project. -+ * (http://www.coritel.it/projects/sofia/nat/) -+ * Uses Sampsa Ranta's excellent idea on using expectfn to 'bind' -+ * the unregistered helpers to the conntrack entries. -+ */ -+ -+ -+#include <linux/module.h> -+#include <linux/netfilter.h> -+#include <linux/ip.h> -+#include <net/checksum.h> -+#include <net/tcp.h> -+ -+#include <linux/netfilter_ipv4/lockhelp.h> -+#include <linux/netfilter_ipv4/ip_conntrack.h> -+#include <linux/netfilter_ipv4/ip_conntrack_core.h> -+#include <linux/netfilter_ipv4/ip_conntrack_helper.h> -+#include <linux/netfilter_ipv4/ip_conntrack_tuple.h> -+#include <linux/netfilter_ipv4/ip_conntrack_h323.h> -+ -+MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>"); -+MODULE_DESCRIPTION("H.323 'brute force' connection tracking module"); -+MODULE_LICENSE("GPL"); -+ -+DECLARE_LOCK(ip_h323_lock); -+struct module *ip_conntrack_h323 = THIS_MODULE; -+ -+#define DEBUGP(format, args...) -+ -+static int h245_help(const struct iphdr *iph, size_t len, -+ struct ip_conntrack *ct, -+ enum ip_conntrack_info ctinfo) -+{ -+ struct tcphdr *tcph = (void *)iph + iph->ihl * 4; -+ unsigned char *data = (unsigned char *) tcph + tcph->doff * 4; -+ unsigned char *data_limit; -+ u_int32_t tcplen = len - iph->ihl * 4; -+ u_int32_t datalen = tcplen - tcph->doff * 4; -+ int dir = CTINFO2DIR(ctinfo); -+ struct ip_ct_h225_master *info = &ct->help.ct_h225_info; -+ struct ip_conntrack_expect expect, *exp = &expect; -+ struct ip_ct_h225_expect *exp_info = &exp->help.exp_h225_info; -+ u_int16_t data_port; -+ u_int32_t data_ip; -+ unsigned int i; -+ -+ DEBUGP("ct_h245_help: help entered %u.%u.%u.%u:%u->%u.%u.%u.%u:%u\n", -+ NIPQUAD(iph->saddr), ntohs(tcph->source), -+ NIPQUAD(iph->daddr), ntohs(tcph->dest)); -+ -+ /* Can't track connections formed before we registered */ -+ if (!info) -+ return NF_ACCEPT; -+ -+ /* Until there's been traffic both ways, don't look in packets. */ -+ if (ctinfo != IP_CT_ESTABLISHED -+ && ctinfo != IP_CT_ESTABLISHED + IP_CT_IS_REPLY) { -+ DEBUGP("ct_h245_help: Conntrackinfo = %u\n", ctinfo); -+ return NF_ACCEPT; -+ } -+ -+ /* Not whole TCP header or too short packet? */ -+ if (tcplen < sizeof(struct tcphdr) || tcplen < tcph->doff * 4 + 5) { -+ DEBUGP("ct_h245_help: tcplen = %u\n", (unsigned)tcplen); -+ return NF_ACCEPT; -+ } -+ -+ /* Checksum invalid? Ignore. */ -+ if (tcp_v4_check(tcph, tcplen, iph->saddr, iph->daddr, -+ csum_partial((char *)tcph, tcplen, 0))) { -+ DEBUGP("ct_h245_help: bad csum: %p %u %u.%u.%u.%u %u.%u.%u.%u\n", -+ tcph, tcplen, NIPQUAD(iph->saddr), -+ NIPQUAD(iph->daddr)); -+ return NF_ACCEPT; -+ } -+ -+ data_limit = (unsigned char *) data + datalen; -+ /* bytes: 0123 45 -+ ipadrr port */ -+ for (i = 0; data < (data_limit - 5); data++, i++) { -+ memcpy(&data_ip, data, sizeof(u_int32_t)); -+ if (data_ip == iph->saddr) { -+ memcpy(&data_port, data + 4, sizeof(u_int16_t)); -+ memset(&expect, 0, sizeof(expect)); -+ /* update the H.225 info */ -+ DEBUGP("ct_h245_help: new RTCP/RTP requested %u.%u.%u.%u:->%u.%u.%u.%u:%u\n", -+ NIPQUAD(ct->tuplehash[!dir].tuple.src.ip), -+ NIPQUAD(iph->saddr), ntohs(data_port)); -+ LOCK_BH(&ip_h323_lock); -+ info->is_h225 = H225_PORT + 1; -+ exp_info->port = data_port; -+ exp_info->dir = dir; -+ exp_info->offset = i; -+ -+ exp->seq = ntohl(tcph->seq) + i; -+ -+ exp->tuple = ((struct ip_conntrack_tuple) -+ { { ct->tuplehash[!dir].tuple.src.ip, -+ { 0 } }, -+ { data_ip, -+ { data_port }, -+ IPPROTO_UDP }}); -+ exp->mask = ((struct ip_conntrack_tuple) -+ { { 0xFFFFFFFF, { 0 } }, -+ { 0xFFFFFFFF, { 0xFFFF }, 0xFFFF }}); -+ -+ exp->expectfn = NULL; -+ -+ /* Ignore failure; should only happen with NAT */ -+ ip_conntrack_expect_related(ct, exp); -+ -+ UNLOCK_BH(&ip_h323_lock); -+ } -+ } -+ -+ return NF_ACCEPT; -+ -+} -+ -+/* H.245 helper is not registered! */ -+static struct ip_conntrack_helper h245 = -+ { { NULL, NULL }, -+ "H.245", /* name */ -+ IP_CT_HELPER_F_REUSE_EXPECT, /* flags */ -+ NULL, /* module */ -+ 8, /* max_ expected */ -+ 240, /* timeout */ -+ { { 0, { 0 } }, /* tuple */ -+ { 0, { 0 }, IPPROTO_TCP } }, -+ { { 0, { 0xFFFF } }, /* mask */ -+ { 0, { 0 }, 0xFFFF } }, -+ h245_help /* helper */ -+ }; -+ -+static int h225_expect(struct ip_conntrack *ct) -+{ -+ WRITE_LOCK(&ip_conntrack_lock); -+ ct->helper = &h245; -+ DEBUGP("h225_expect: helper for %p added\n", ct); -+ WRITE_UNLOCK(&ip_conntrack_lock); -+ -+ return NF_ACCEPT; /* unused */ -+} -+ -+static int h225_help(const struct iphdr *iph, size_t len, -+ struct ip_conntrack *ct, -+ enum ip_conntrack_info ctinfo) -+{ -+ struct tcphdr *tcph = (void *)iph + iph->ihl * 4; -+ unsigned char *data = (unsigned char *) tcph + tcph->doff * 4; -+ unsigned char *data_limit; -+ u_int32_t tcplen = len - iph->ihl * 4; -+ u_int32_t datalen = tcplen - tcph->doff * 4; -+ int dir = CTINFO2DIR(ctinfo); -+ struct ip_ct_h225_master *info = &ct->help.ct_h225_info; -+ struct ip_conntrack_expect expect, *exp = &expect; -+ struct ip_ct_h225_expect *exp_info = &exp->help.exp_h225_info; -+ u_int16_t data_port; -+ u_int32_t data_ip; -+ unsigned int i; -+ -+ DEBUGP("ct_h225_help: help entered %u.%u.%u.%u:%u->%u.%u.%u.%u:%u\n", -+ NIPQUAD(iph->saddr), ntohs(tcph->source), -+ NIPQUAD(iph->daddr), ntohs(tcph->dest)); -+ -+ /* Can't track connections formed before we registered */ -+ if (!info) -+ return NF_ACCEPT; -+ -+ /* Until there's been traffic both ways, don't look in packets. */ -+ if (ctinfo != IP_CT_ESTABLISHED -+ && ctinfo != IP_CT_ESTABLISHED + IP_CT_IS_REPLY) { -+ DEBUGP("ct_h225_help: Conntrackinfo = %u\n", ctinfo); -+ return NF_ACCEPT; -+ } -+ -+ /* Not whole TCP header or too short packet? */ -+ if (tcplen < sizeof(struct tcphdr) || tcplen < tcph->doff * 4 + 5) { -+ DEBUGP("ct_h225_help: tcplen = %u\n", (unsigned)tcplen); -+ return NF_ACCEPT; -+ } -+ -+ /* Checksum invalid? Ignore. */ -+ if (tcp_v4_check(tcph, tcplen, iph->saddr, iph->daddr, -+ csum_partial((char *)tcph, tcplen, 0))) { -+ DEBUGP("ct_h225_help: bad csum: %p %u %u.%u.%u.%u %u.%u.%u.%u\n", -+ tcph, tcplen, NIPQUAD(iph->saddr), -+ NIPQUAD(iph->daddr)); -+ return NF_ACCEPT; -+ } -+ -+ data_limit = (unsigned char *) data + datalen; -+ /* bytes: 0123 45 -+ ipadrr port */ -+ for (i = 0; data < (data_limit - 5); data++, i++) { -+ memcpy(&data_ip, data, sizeof(u_int32_t)); -+ if (data_ip == iph->saddr) { -+ memcpy(&data_port, data + 4, sizeof(u_int16_t)); -+ if (data_port == tcph->source) { -+ /* Signal address */ -+ DEBUGP("ct_h225_help: sourceCallSignalAddress from %u.%u.%u.%u\n", -+ NIPQUAD(iph->saddr)); -+ /* Update the H.225 info so that NAT can mangle the address/port -+ even when we have no expected connection! */ -+#ifdef CONFIG_IP_NF_NAT_NEEDED -+ LOCK_BH(&ip_h323_lock); -+ info->dir = dir; -+ info->seq[IP_CT_DIR_ORIGINAL] = ntohl(tcph->seq) + i; -+ info->offset[IP_CT_DIR_ORIGINAL] = i; -+ UNLOCK_BH(&ip_h323_lock); -+#endif -+ } else { -+ memset(&expect, 0, sizeof(expect)); -+ -+ /* update the H.225 info */ -+ LOCK_BH(&ip_h323_lock); -+ info->is_h225 = H225_PORT; -+ exp_info->port = data_port; -+ exp_info->dir = dir; -+ exp_info->offset = i; -+ -+ exp->seq = ntohl(tcph->seq) + i; -+ -+ exp->tuple = ((struct ip_conntrack_tuple) -+ { { ct->tuplehash[!dir].tuple.src.ip, -+ { 0 } }, -+ { data_ip, -+ { data_port }, -+ IPPROTO_TCP }}); -+ exp->mask = ((struct ip_conntrack_tuple) -+ { { 0xFFFFFFFF, { 0 } }, -+ { 0xFFFFFFFF, { 0xFFFF }, 0xFFFF }}); -+ -+ exp->expectfn = h225_expect; -+ -+ /* Ignore failure */ -+ ip_conntrack_expect_related(ct, exp); -+ -+ DEBUGP("ct_h225_help: new H.245 requested %u.%u.%u.%u->%u.%u.%u.%u:%u\n", -+ NIPQUAD(ct->tuplehash[!dir].tuple.src.ip), -+ NIPQUAD(iph->saddr), ntohs(data_port)); -+ -+ UNLOCK_BH(&ip_h323_lock); -+ } -+#ifdef CONFIG_IP_NF_NAT_NEEDED -+ } else if (data_ip == iph->daddr) { -+ memcpy(&data_port, data + 4, sizeof(u_int16_t)); -+ if (data_port == tcph->dest) { -+ /* Signal address */ -+ DEBUGP("ct_h225_help: destCallSignalAddress %u.%u.%u.%u\n", -+ NIPQUAD(iph->daddr)); -+ /* Update the H.225 info so that NAT can mangle the address/port -+ even when we have no expected connection! */ -+ LOCK_BH(&ip_h323_lock); -+ info->dir = dir; -+ info->seq[IP_CT_DIR_REPLY] = ntohl(tcph->seq) + i; -+ info->offset[IP_CT_DIR_REPLY] = i; -+ UNLOCK_BH(&ip_h323_lock); -+ } -+#endif -+ } -+ } -+ -+ return NF_ACCEPT; -+ -+} -+ -+static struct ip_conntrack_helper h225 = -+ { { NULL, NULL }, -+ "H.225", /* name */ -+ IP_CT_HELPER_F_REUSE_EXPECT, /* flags */ -+ THIS_MODULE, /* module */ -+ 2, /* max_expected */ -+ 240, /* timeout */ -+ { { 0, { __constant_htons(H225_PORT) } }, /* tuple */ -+ { 0, { 0 }, IPPROTO_TCP } }, -+ { { 0, { 0xFFFF } }, /* mask */ -+ { 0, { 0 }, 0xFFFF } }, -+ h225_help /* helper */ -+ }; -+ -+static int __init init(void) -+{ -+ return ip_conntrack_helper_register(&h225); -+} -+ -+static void __exit fini(void) -+{ -+ /* Unregister H.225 helper */ -+ ip_conntrack_helper_unregister(&h225); -+} -+ -+#ifdef CONFIG_IP_NF_NAT_NEEDED -+EXPORT_SYMBOL(ip_h323_lock); -+#endif -+ -+module_init(init); -+module_exit(fini); ---- /dev/null -+++ b/net/ipv4/netfilter/ip_nat_h323.c -@@ -0,0 +1,403 @@ -+/* -+ * H.323 'brute force' extension for NAT alteration. -+ * Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> -+ * -+ * Based on ip_masq_h323.c for 2.2 kernels from CoRiTel, Sofia project. -+ * (http://www.coritel.it/projects/sofia/nat.html) -+ * Uses Sampsa Ranta's excellent idea on using expectfn to 'bind' -+ * the unregistered helpers to the conntrack entries. -+ */ -+ -+ -+#include <linux/module.h> -+#include <linux/netfilter.h> -+#include <linux/ip.h> -+#include <net/checksum.h> -+#include <net/tcp.h> -+ -+#include <linux/netfilter_ipv4/lockhelp.h> -+#include <linux/netfilter_ipv4/ip_nat.h> -+#include <linux/netfilter_ipv4/ip_nat_helper.h> -+#include <linux/netfilter_ipv4/ip_nat_rule.h> -+#include <linux/netfilter_ipv4/ip_conntrack_tuple.h> -+#include <linux/netfilter_ipv4/ip_conntrack_helper.h> -+#include <linux/netfilter_ipv4/ip_conntrack_h323.h> -+ -+MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>"); -+MODULE_DESCRIPTION("H.323 'brute force' connection tracking module"); -+MODULE_LICENSE("GPL"); -+ -+DECLARE_LOCK_EXTERN(ip_h323_lock); -+struct module *ip_nat_h323 = THIS_MODULE; -+ -+#define DEBUGP(format, args...) -+ -+ -+static unsigned int -+h225_nat_expected(struct sk_buff **pskb, -+ unsigned int hooknum, -+ struct ip_conntrack *ct, -+ struct ip_nat_info *info); -+ -+static unsigned int h225_nat_help(struct ip_conntrack *ct, -+ struct ip_conntrack_expect *exp, -+ struct ip_nat_info *info, -+ enum ip_conntrack_info ctinfo, -+ unsigned int hooknum, -+ struct sk_buff **pskb); -+ -+static struct ip_nat_helper h245 = -+ { { NULL, NULL }, -+ "H.245", /* name */ -+ 0, /* flags */ -+ NULL, /* module */ -+ { { 0, { 0 } }, /* tuple */ -+ { 0, { 0 }, IPPROTO_TCP } }, -+ { { 0, { 0xFFFF } }, /* mask */ -+ { 0, { 0 }, 0xFFFF } }, -+ h225_nat_help, /* helper */ -+ h225_nat_expected /* expectfn */ -+ }; -+ -+static unsigned int -+h225_nat_expected(struct sk_buff **pskb, -+ unsigned int hooknum, -+ struct ip_conntrack *ct, -+ struct ip_nat_info *info) -+{ -+ struct ip_nat_multi_range mr; -+ u_int32_t newdstip, newsrcip, newip; -+ u_int16_t port; -+ struct ip_ct_h225_expect *exp_info; -+ struct ip_ct_h225_master *master_info; -+ struct ip_conntrack *master = master_ct(ct); -+ unsigned int is_h225, ret; -+ -+ IP_NF_ASSERT(info); -+ IP_NF_ASSERT(master); -+ -+ IP_NF_ASSERT(!(info->initialized & (1<<HOOK2MANIP(hooknum)))); -+ -+ DEBUGP("h225_nat_expected: We have a connection!\n"); -+ master_info = &ct->master->expectant->help.ct_h225_info; -+ exp_info = &ct->master->help.exp_h225_info; -+ -+ LOCK_BH(&ip_h323_lock); -+ -+ DEBUGP("master: "); -+ DUMP_TUPLE(&master->tuplehash[IP_CT_DIR_ORIGINAL].tuple); -+ DUMP_TUPLE(&master->tuplehash[IP_CT_DIR_REPLY].tuple); -+ DEBUGP("conntrack: "); -+ DUMP_TUPLE(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); -+ if (exp_info->dir == IP_CT_DIR_ORIGINAL) { -+ /* Make connection go to the client. */ -+ newdstip = master->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip; -+ newsrcip = master->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.ip; -+ DEBUGP("h225_nat_expected: %u.%u.%u.%u->%u.%u.%u.%u (to client)\n", -+ NIPQUAD(newsrcip), NIPQUAD(newdstip)); -+ } else { -+ /* Make the connection go to the server */ -+ newdstip = master->tuplehash[IP_CT_DIR_REPLY].tuple.src.ip; -+ newsrcip = master->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip; -+ DEBUGP("h225_nat_expected: %u.%u.%u.%u->%u.%u.%u.%u (to server)\n", -+ NIPQUAD(newsrcip), NIPQUAD(newdstip)); -+ } -+ port = exp_info->port; -+ is_h225 = master_info->is_h225 == H225_PORT; -+ UNLOCK_BH(&ip_h323_lock); -+ -+ if (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC) -+ newip = newsrcip; -+ else -+ newip = newdstip; -+ -+ DEBUGP("h225_nat_expected: IP to %u.%u.%u.%u\n", NIPQUAD(newip)); -+ -+ mr.rangesize = 1; -+ /* We don't want to manip the per-protocol, just the IPs... */ -+ mr.range[0].flags = IP_NAT_RANGE_MAP_IPS; -+ mr.range[0].min_ip = mr.range[0].max_ip = newip; -+ -+ /* ... unless we're doing a MANIP_DST, in which case, make -+ sure we map to the correct port */ -+ if (HOOK2MANIP(hooknum) == IP_NAT_MANIP_DST) { -+ mr.range[0].flags |= IP_NAT_RANGE_PROTO_SPECIFIED; -+ mr.range[0].min = mr.range[0].max -+ = ((union ip_conntrack_manip_proto) -+ { port }); -+ } -+ -+ ret = ip_nat_setup_info(ct, &mr, hooknum); -+ -+ if (is_h225) { -+ DEBUGP("h225_nat_expected: H.225, setting NAT helper for %p\n", ct); -+ /* NAT expectfn called with ip_nat_lock write-locked */ -+ info->helper = &h245; -+ } -+ return ret; -+} -+ -+static int h323_signal_address_fixup(struct ip_conntrack *ct, -+ struct sk_buff **pskb, -+ enum ip_conntrack_info ctinfo) -+{ -+ struct iphdr *iph = (*pskb)->nh.iph; -+ struct tcphdr *tcph = (void *)iph + iph->ihl*4; -+ unsigned char *data; -+ u_int32_t tcplen = (*pskb)->len - iph->ihl*4; -+ u_int32_t datalen = tcplen - tcph->doff*4; -+ struct ip_ct_h225_master *info = &ct->help.ct_h225_info; -+ u_int32_t newip; -+ u_int16_t port; -+ u_int8_t buffer[6]; -+ int i; -+ -+ MUST_BE_LOCKED(&ip_h323_lock); -+ -+ DEBUGP("h323_signal_address_fixup: %s %s\n", -+ between(info->seq[IP_CT_DIR_ORIGINAL], ntohl(tcph->seq), ntohl(tcph->seq) + datalen) -+ ? "yes" : "no", -+ between(info->seq[IP_CT_DIR_REPLY], ntohl(tcph->seq), ntohl(tcph->seq) + datalen) -+ ? "yes" : "no"); -+ if (!(between(info->seq[IP_CT_DIR_ORIGINAL], ntohl(tcph->seq), ntohl(tcph->seq) + datalen) -+ || between(info->seq[IP_CT_DIR_REPLY], ntohl(tcph->seq), ntohl(tcph->seq) + datalen))) -+ return 1; -+ -+ DEBUGP("h323_signal_address_fixup: offsets %u + 6 and %u + 6 in %u\n", -+ info->offset[IP_CT_DIR_ORIGINAL], -+ info->offset[IP_CT_DIR_REPLY], -+ tcplen); -+ DUMP_TUPLE(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); -+ DUMP_TUPLE(&ct->tuplehash[IP_CT_DIR_REPLY].tuple); -+ -+ for (i = 0; i < IP_CT_DIR_MAX; i++) { -+ DEBUGP("h323_signal_address_fixup: %s %s\n", -+ info->dir == IP_CT_DIR_ORIGINAL ? "original" : "reply", -+ i == IP_CT_DIR_ORIGINAL ? "caller" : "callee"); -+ if (!between(info->seq[i], ntohl(tcph->seq), -+ ntohl(tcph->seq) + datalen)) -+ continue; -+ if (!between(info->seq[i] + 6, ntohl(tcph->seq), -+ ntohl(tcph->seq) + datalen)) { -+ /* Partial retransmisison. It's a cracker being funky. */ -+ if (net_ratelimit()) { -+ printk("H.323_NAT: partial packet %u/6 in %u/%u\n", -+ info->seq[i], -+ ntohl(tcph->seq), -+ ntohl(tcph->seq) + datalen); -+ } -+ return 0; -+ } -+ -+ /* Change address inside packet to match way we're mapping -+ this connection. */ -+ if (i == IP_CT_DIR_ORIGINAL) { -+ newip = ct->tuplehash[!info->dir].tuple.dst.ip; -+ port = ct->tuplehash[!info->dir].tuple.dst.u.tcp.port; -+ } else { -+ newip = ct->tuplehash[!info->dir].tuple.src.ip; -+ port = ct->tuplehash[!info->dir].tuple.src.u.tcp.port; -+ } -+ -+ data = (char *) tcph + tcph->doff * 4 + info->offset[i]; -+ -+ DEBUGP("h323_signal_address_fixup: orig %s IP:port %u.%u.%u.%u:%u\n", -+ i == IP_CT_DIR_ORIGINAL ? "source" : "dest ", -+ data[0], data[1], data[2], data[3], -+ (data[4] << 8 | data[5])); -+ -+ /* Modify the packet */ -+ memcpy(buffer, &newip, 4); -+ memcpy(buffer + 4, &port, 2); -+ if (!ip_nat_mangle_tcp_packet(pskb, ct, ctinfo, info->offset[i], -+ 6, buffer, 6)) -+ return 0; -+ -+ DEBUGP("h323_signal_address_fixup: new %s IP:port %u.%u.%u.%u:%u\n", -+ i == IP_CT_DIR_ORIGINAL ? "source" : "dest ", -+ data[0], data[1], data[2], data[3], -+ (data[4] << 8 | data[5])); -+ } -+ -+ return 1; -+} -+ -+static int h323_data_fixup(struct ip_ct_h225_expect *info, -+ struct ip_conntrack *ct, -+ struct sk_buff **pskb, -+ enum ip_conntrack_info ctinfo, -+ struct ip_conntrack_expect *expect) -+{ -+ u_int32_t newip; -+ u_int16_t port; -+ u_int8_t buffer[6]; -+ struct ip_conntrack_tuple newtuple; -+ struct iphdr *iph = (*pskb)->nh.iph; -+ struct tcphdr *tcph = (void *)iph + iph->ihl*4; -+ unsigned char *data; -+ u_int32_t tcplen = (*pskb)->len - iph->ihl*4; -+ struct ip_ct_h225_master *master_info = &ct->help.ct_h225_info; -+ int is_h225; -+ -+ MUST_BE_LOCKED(&ip_h323_lock); -+ DEBUGP("h323_data_fixup: offset %u + 6 in %u\n", info->offset, tcplen); -+ DUMP_TUPLE(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); -+ DUMP_TUPLE(&ct->tuplehash[IP_CT_DIR_REPLY].tuple); -+ -+ if (!between(expect->seq + 6, ntohl(tcph->seq), -+ ntohl(tcph->seq) + tcplen - tcph->doff * 4)) { -+ /* Partial retransmisison. It's a cracker being funky. */ -+ if (net_ratelimit()) { -+ printk("H.323_NAT: partial packet %u/6 in %u/%u\n", -+ expect->seq, -+ ntohl(tcph->seq), -+ ntohl(tcph->seq) + tcplen - tcph->doff * 4); -+ } -+ return 0; -+ } -+ -+ /* Change address inside packet to match way we're mapping -+ this connection. */ -+ if (info->dir == IP_CT_DIR_REPLY) { -+ /* Must be where client thinks server is */ -+ newip = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.ip; -+ /* Expect something from client->server */ -+ newtuple.src.ip = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip; -+ newtuple.dst.ip = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.ip; -+ } else { -+ /* Must be where server thinks client is */ -+ newip = ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip; -+ /* Expect something from server->client */ -+ newtuple.src.ip = ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.ip; -+ newtuple.dst.ip = ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip; -+ } -+ -+ is_h225 = (master_info->is_h225 == H225_PORT); -+ -+ if (is_h225) { -+ newtuple.dst.protonum = IPPROTO_TCP; -+ newtuple.src.u.tcp.port = expect->tuple.src.u.tcp.port; -+ } else { -+ newtuple.dst.protonum = IPPROTO_UDP; -+ newtuple.src.u.udp.port = expect->tuple.src.u.udp.port; -+ } -+ -+ /* Try to get same port: if not, try to change it. */ -+ for (port = ntohs(info->port); port != 0; port++) { -+ if (is_h225) -+ newtuple.dst.u.tcp.port = htons(port); -+ else -+ newtuple.dst.u.udp.port = htons(port); -+ -+ if (ip_conntrack_change_expect(expect, &newtuple) == 0) -+ break; -+ } -+ if (port == 0) { -+ DEBUGP("h323_data_fixup: no free port found!\n"); -+ return 0; -+ } -+ -+ port = htons(port); -+ -+ data = (char *) tcph + tcph->doff * 4 + info->offset; -+ -+ DEBUGP("h323_data_fixup: orig IP:port %u.%u.%u.%u:%u\n", -+ data[0], data[1], data[2], data[3], -+ (data[4] << 8 | data[5])); -+ -+ /* Modify the packet */ -+ memcpy(buffer, &newip, 4); -+ memcpy(buffer + 4, &port, 2); -+ if (!ip_nat_mangle_tcp_packet(pskb, ct, ctinfo, info->offset, -+ 6, buffer, 6)) -+ return 0; -+ -+ DEBUGP("h323_data_fixup: new IP:port %u.%u.%u.%u:%u\n", -+ data[0], data[1], data[2], data[3], -+ (data[4] << 8 | data[5])); -+ -+ return 1; -+} -+ -+static unsigned int h225_nat_help(struct ip_conntrack *ct, -+ struct ip_conntrack_expect *exp, -+ struct ip_nat_info *info, -+ enum ip_conntrack_info ctinfo, -+ unsigned int hooknum, -+ struct sk_buff **pskb) -+{ -+ int dir; -+ struct ip_ct_h225_expect *exp_info; -+ -+ /* Only mangle things once: original direction in POST_ROUTING -+ and reply direction on PRE_ROUTING. */ -+ dir = CTINFO2DIR(ctinfo); -+ DEBUGP("nat_h323: dir %s at hook %s\n", -+ dir == IP_CT_DIR_ORIGINAL ? "ORIG" : "REPLY", -+ hooknum == NF_IP_POST_ROUTING ? "POSTROUTING" -+ : hooknum == NF_IP_PRE_ROUTING ? "PREROUTING" -+ : hooknum == NF_IP_LOCAL_OUT ? "OUTPUT" : "???"); -+ if (!((hooknum == NF_IP_POST_ROUTING && dir == IP_CT_DIR_ORIGINAL) -+ || (hooknum == NF_IP_PRE_ROUTING && dir == IP_CT_DIR_REPLY))) { -+ DEBUGP("nat_h323: Not touching dir %s at hook %s\n", -+ dir == IP_CT_DIR_ORIGINAL ? "ORIG" : "REPLY", -+ hooknum == NF_IP_POST_ROUTING ? "POSTROUTING" -+ : hooknum == NF_IP_PRE_ROUTING ? "PREROUTING" -+ : hooknum == NF_IP_LOCAL_OUT ? "OUTPUT" : "???"); -+ return NF_ACCEPT; -+ } -+ -+ if (!exp) { -+ LOCK_BH(&ip_h323_lock); -+ if (!h323_signal_address_fixup(ct, pskb, ctinfo)) { -+ UNLOCK_BH(&ip_h323_lock); -+ return NF_DROP; -+ } -+ UNLOCK_BH(&ip_h323_lock); -+ return NF_ACCEPT; -+ } -+ -+ exp_info = &exp->help.exp_h225_info; -+ -+ LOCK_BH(&ip_h323_lock); -+ if (!h323_data_fixup(exp_info, ct, pskb, ctinfo, exp)) { -+ UNLOCK_BH(&ip_h323_lock); -+ return NF_DROP; -+ } -+ UNLOCK_BH(&ip_h323_lock); -+ -+ return NF_ACCEPT; -+} -+ -+static struct ip_nat_helper h225 = -+ { { NULL, NULL }, -+ "H.225", /* name */ -+ IP_NAT_HELPER_F_ALWAYS, /* flags */ -+ THIS_MODULE, /* module */ -+ { { 0, { __constant_htons(H225_PORT) } }, /* tuple */ -+ { 0, { 0 }, IPPROTO_TCP } }, -+ { { 0, { 0xFFFF } }, /* mask */ -+ { 0, { 0 }, 0xFFFF } }, -+ h225_nat_help, /* helper */ -+ h225_nat_expected /* expectfn */ -+ }; -+ -+static int __init init(void) -+{ -+ int ret; -+ -+ ret = ip_nat_helper_register(&h225); -+ -+ if (ret != 0) -+ printk("ip_nat_h323: cannot initialize the module!\n"); -+ -+ return ret; -+} -+ -+static void __exit fini(void) -+{ -+ ip_nat_helper_unregister(&h225); -+} -+ -+module_init(init); -+module_exit(fini); ---- a/include/linux/netfilter_ipv4/ip_conntrack.h -+++ b/include/linux/netfilter_ipv4/ip_conntrack.h -@@ -67,6 +67,7 @@ union ip_conntrack_expect_proto { - - #include <linux/netfilter_ipv4/ip_conntrack_ftp.h> - #include <linux/netfilter_ipv4/ip_conntrack_irc.h> -+#include <linux/netfilter_ipv4/ip_conntrack_h323.h> - - /* per expectation: application helper private data */ - union ip_conntrack_expect_help { -@@ -74,6 +75,7 @@ union ip_conntrack_expect_help { - struct ip_ct_amanda_expect exp_amanda_info; - struct ip_ct_ftp_expect exp_ftp_info; - struct ip_ct_irc_expect exp_irc_info; -+ struct ip_ct_h225_expect exp_h225_info; - - #ifdef CONFIG_IP_NF_NAT_NEEDED - union { -@@ -87,6 +89,7 @@ union ip_conntrack_help { - /* insert conntrack helper private data (master) here */ - struct ip_ct_ftp_master ct_ftp_info; - struct ip_ct_irc_master ct_irc_info; -+ struct ip_ct_h225_master ct_h225_info; - }; - - #ifdef CONFIG_IP_NF_NAT_NEEDED ---- /dev/null -+++ b/include/linux/netfilter_ipv4/ip_conntrack_h323.h -@@ -0,0 +1,30 @@ -+#ifndef _IP_CONNTRACK_H323_H -+#define _IP_CONNTRACK_H323_H -+/* H.323 connection tracking. */ -+ -+#ifdef __KERNEL__ -+/* Protects H.323 related data */ -+DECLARE_LOCK_EXTERN(ip_h323_lock); -+#endif -+ -+/* Default H.225 port */ -+#define H225_PORT 1720 -+ -+/* This structure is per expected connection */ -+struct ip_ct_h225_expect { -+ u_int16_t port; /* Port of the H.225 helper/RTCP/RTP channel */ -+ enum ip_conntrack_dir dir; /* Direction of the original connection */ -+ unsigned int offset; /* offset of the address in the payload */ -+}; -+ -+/* This structure exists only once per master */ -+struct ip_ct_h225_master { -+ int is_h225; /* H.225 or H.245 connection */ -+#ifdef CONFIG_IP_NF_NAT_NEEDED -+ enum ip_conntrack_dir dir; /* Direction of the original connection */ -+ u_int32_t seq[IP_CT_DIR_MAX]; /* Exceptional packet mangling for signal addressess... */ -+ unsigned int offset[IP_CT_DIR_MAX]; /* ...and the offset of the addresses in the payload */ -+#endif -+}; -+ -+#endif /* _IP_CONNTRACK_H323_H */ diff --git a/target/linux/generic-2.4/patches/614-netfilter_nat_rtsp.patch b/target/linux/generic-2.4/patches/614-netfilter_nat_rtsp.patch deleted file mode 100644 index 94f11e6..0000000 --- a/target/linux/generic-2.4/patches/614-netfilter_nat_rtsp.patch +++ /dev/null @@ -1,1516 +0,0 @@ ---- a/net/ipv4/netfilter/Config.in -+++ b/net/ipv4/netfilter/Config.in -@@ -14,6 +14,7 @@ if [ "$CONFIG_IP_NF_CONNTRACK" != "n" ]; - dep_tristate ' Connection tracking flow accounting' CONFIG_IP_NF_CT_ACCT $CONFIG_IP_NF_CONNTRACK - dep_tristate ' Connection byte counter support' CONFIG_IP_NF_MATCH_CONNBYTES $CONFIG_IP_NF_CT_ACCT $CONFIG_IP_NF_CONNTRACK $CONFIG_IP_NF_IPTABLES - dep_tristate ' H.323 (netmeeting) support' CONFIG_IP_NF_H323 $CONFIG_IP_NF_CONNTRACK -+ dep_tristate ' RTSP protocol support' CONFIG_IP_NF_RTSP $CONFIG_IP_NF_CONNTRACK - fi - - if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then -@@ -88,6 +89,13 @@ if [ "$CONFIG_IP_NF_IPTABLES" != "n" ]; - define_tristate CONFIG_IP_NF_NAT_H323 $CONFIG_IP_NF_NAT - fi - fi -+ if [ "$CONFIG_IP_NF_RTSP" = "m" ]; then -+ define_tristate CONFIG_IP_NF_NAT_RTSP m -+ else -+ if [ "$CONFIG_IP_NF_RTSP" = "y" ]; then -+ define_tristate CONFIG_IP_NF_NAT_RTSP $CONFIG_IP_NF_NAT -+ fi -+ fi - if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then - dep_tristate ' Basic SNMP-ALG support (EXPERIMENTAL)' CONFIG_IP_NF_NAT_SNMP_BASIC $CONFIG_IP_NF_NAT - fi ---- a/net/ipv4/netfilter/Makefile -+++ b/net/ipv4/netfilter/Makefile -@@ -51,6 +51,11 @@ obj-$(CONFIG_IP_NF_H323) += ip_conntrack - ifdef CONFIG_IP_NF_NAT_H323 - export-objs += ip_conntrack_h323.o - endif -+obj-$(CONFIG_IP_NF_RTSP) += ip_conntrack_rtsp.o -+ifdef CONFIG_IP_NF_NAT_RTSP -+ export-objs += ip_conntrack_rtsp.o -+endif -+ - - # NAT helpers - obj-$(CONFIG_IP_NF_NAT_AMANDA) += ip_nat_amanda.o -@@ -58,6 +63,7 @@ obj-$(CONFIG_IP_NF_NAT_TFTP) += ip_nat_t - obj-$(CONFIG_IP_NF_NAT_FTP) += ip_nat_ftp.o - obj-$(CONFIG_IP_NF_NAT_IRC) += ip_nat_irc.o - obj-$(CONFIG_IP_NF_NAT_H323) += ip_nat_h323.o -+obj-$(CONFIG_IP_NF_NAT_RTSP) += ip_nat_rtsp.o - - # generic IP tables - obj-$(CONFIG_IP_NF_IPTABLES) += ip_tables.o ---- /dev/null -+++ b/net/ipv4/netfilter/ip_conntrack_rtsp.c -@@ -0,0 +1,507 @@ -+/* -+ * RTSP extension for IP connection tracking -+ * (C) 2003 by Tom Marshall <tmarshall@real.com> -+ * based on ip_conntrack_irc.c -+ * -+ * 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. -+ * -+ * Module load syntax: -+ * insmod ip_conntrack_rtsp.o ports=port1,port2,...port<MAX_PORTS> -+ * max_outstanding=n setup_timeout=secs -+ * -+ * If no ports are specified, the default will be port 554. -+ * -+ * With max_outstanding you can define the maximum number of not yet -+ * answered SETUP requests per RTSP session (default 8). -+ * With setup_timeout you can specify how long the system waits for -+ * an expected data channel (default 300 seconds). -+ */ -+ -+#include <linux/config.h> -+#include <linux/module.h> -+#include <linux/netfilter.h> -+#include <linux/ip.h> -+#include <net/checksum.h> -+#include <net/tcp.h> -+ -+#include <linux/netfilter_ipv4/lockhelp.h> -+#include <linux/netfilter_ipv4/ip_conntrack_helper.h> -+#include <linux/netfilter_ipv4/ip_conntrack_rtsp.h> -+ -+#include <linux/ctype.h> -+#define NF_NEED_STRNCASECMP -+#define NF_NEED_STRTOU16 -+#define NF_NEED_STRTOU32 -+#define NF_NEED_NEXTLINE -+#include <linux/netfilter_helpers.h> -+#define NF_NEED_MIME_NEXTLINE -+#include <linux/netfilter_mime.h> -+ -+#define MAX_SIMUL_SETUP 8 /* XXX: use max_outstanding */ -+ -+#define INFOP(fmt, args...) printk(KERN_INFO "%s: %s: " fmt, __FILE__, __FUNCTION__ , ## args) -+#ifdef IP_NF_RTSP_DEBUG -+#define DEBUGP(fmt, args...) printk(KERN_DEBUG "%s: %s: " fmt, __FILE__, __FUNCTION__ , ## args) -+#else -+#define DEBUGP(fmt, args...) -+#endif -+ -+#define MAX_PORTS 8 -+static int ports[MAX_PORTS]; -+static int num_ports = 0; -+static int max_outstanding = 8; -+static unsigned int setup_timeout = 300; -+ -+MODULE_AUTHOR("Tom Marshall <tmarshall@real.com>"); -+MODULE_DESCRIPTION("RTSP connection tracking module"); -+MODULE_LICENSE("GPL"); -+#ifdef MODULE_PARM -+MODULE_PARM(ports, "1-" __MODULE_STRING(MAX_PORTS) "i"); -+MODULE_PARM_DESC(ports, "port numbers of RTSP servers"); -+MODULE_PARM(max_outstanding, "i"); -+MODULE_PARM_DESC(max_outstanding, "max number of outstanding SETUP requests per RTSP session"); -+MODULE_PARM(setup_timeout, "i"); -+MODULE_PARM_DESC(setup_timeout, "timeout on for unestablished data channels"); -+#endif -+ -+DECLARE_LOCK(ip_rtsp_lock); -+struct module* ip_conntrack_rtsp = THIS_MODULE; -+ -+/* -+ * Max mappings we will allow for one RTSP connection (for RTP, the number -+ * of allocated ports is twice this value). Note that SMIL burns a lot of -+ * ports so keep this reasonably high. If this is too low, you will see a -+ * lot of "no free client map entries" messages. -+ */ -+#define MAX_PORT_MAPS 16 -+ -+/*** default port list was here in the masq code: 554, 3030, 4040 ***/ -+ -+#define SKIP_WSPACE(ptr,len,off) while(off < len && isspace(*(ptr+off))) { off++; } -+ -+/* -+ * Parse an RTSP packet. -+ * -+ * Returns zero if parsing failed. -+ * -+ * Parameters: -+ * IN ptcp tcp data pointer -+ * IN tcplen tcp data len -+ * IN/OUT ptcpoff points to current tcp offset -+ * OUT phdrsoff set to offset of rtsp headers -+ * OUT phdrslen set to length of rtsp headers -+ * OUT pcseqoff set to offset of CSeq header -+ * OUT pcseqlen set to length of CSeq header -+ */ -+static int -+rtsp_parse_message(char* ptcp, uint tcplen, uint* ptcpoff, -+ uint* phdrsoff, uint* phdrslen, -+ uint* pcseqoff, uint* pcseqlen) -+{ -+ uint entitylen = 0; -+ uint lineoff; -+ uint linelen; -+ -+ if (!nf_nextline(ptcp, tcplen, ptcpoff, &lineoff, &linelen)) -+ { -+ return 0; -+ } -+ -+ *phdrsoff = *ptcpoff; -+ while (nf_mime_nextline(ptcp, tcplen, ptcpoff, &lineoff, &linelen)) -+ { -+ if (linelen == 0) -+ { -+ if (entitylen > 0) -+ { -+ *ptcpoff += min(entitylen, tcplen - *ptcpoff); -+ } -+ break; -+ } -+ if (lineoff+linelen > tcplen) -+ { -+ INFOP("!! overrun !!\n"); -+ break; -+ } -+ -+ if (nf_strncasecmp(ptcp+lineoff, "CSeq:", 5) == 0) -+ { -+ *pcseqoff = lineoff; -+ *pcseqlen = linelen; -+ } -+ if (nf_strncasecmp(ptcp+lineoff, "Content-Length:", 15) == 0) -+ { -+ uint off = lineoff+15; -+ SKIP_WSPACE(ptcp+lineoff, linelen, off); -+ nf_strtou32(ptcp+off, &entitylen); -+ } -+ } -+ *phdrslen = (*ptcpoff) - (*phdrsoff); -+ -+ return 1; -+} -+ -+/* -+ * Find lo/hi client ports (if any) in transport header -+ * In: -+ * ptcp, tcplen = packet -+ * tranoff, tranlen = buffer to search -+ * -+ * Out: -+ * pport_lo, pport_hi = lo/hi ports (host endian) -+ * -+ * Returns nonzero if any client ports found -+ * -+ * Note: it is valid (and expected) for the client to request multiple -+ * transports, so we need to parse the entire line. -+ */ -+static int -+rtsp_parse_transport(char* ptran, uint tranlen, -+ struct ip_ct_rtsp_expect* prtspexp) -+{ -+ int rc = 0; -+ uint off = 0; -+ -+ if (tranlen < 10 || !iseol(ptran[tranlen-1]) || -+ nf_strncasecmp(ptran, "Transport:", 10) != 0) -+ { -+ INFOP("sanity check failed\n"); -+ return 0; -+ } -+ DEBUGP("tran='%.*s'\n", (int)tranlen, ptran); -+ off += 10; -+ SKIP_WSPACE(ptran, tranlen, off); -+ -+ /* Transport: tran;field;field=val,tran;field;field=val,... */ -+ while (off < tranlen) -+ { -+ const char* pparamend; -+ uint nextparamoff; -+ -+ pparamend = memchr(ptran+off, ',', tranlen-off); -+ pparamend = (pparamend == NULL) ? ptran+tranlen : pparamend+1; -+ nextparamoff = pparamend-ptran; -+ -+ while (off < nextparamoff) -+ { -+ const char* pfieldend; -+ uint nextfieldoff; -+ -+ pfieldend = memchr(ptran+off, ';', nextparamoff-off); -+ nextfieldoff = (pfieldend == NULL) ? nextparamoff : pfieldend-ptran+1; -+ -+ if (strncmp(ptran+off, "client_port=", 12) == 0) -+ { -+ u_int16_t port; -+ uint numlen; -+ -+ off += 12; -+ numlen = nf_strtou16(ptran+off, &port); -+ off += numlen; -+ if (prtspexp->loport != 0 && prtspexp->loport != port) -+ { -+ DEBUGP("multiple ports found, port %hu ignored\n", port); -+ } -+ else -+ { -+ prtspexp->loport = prtspexp->hiport = port; -+ if (ptran[off] == '-') -+ { -+ off++; -+ numlen = nf_strtou16(ptran+off, &port); -+ off += numlen; -+ prtspexp->pbtype = pb_range; -+ prtspexp->hiport = port; -+ -+ // If we have a range, assume rtp: -+ // loport must be even, hiport must be loport+1 -+ if ((prtspexp->loport & 0x0001) != 0 || -+ prtspexp->hiport != prtspexp->loport+1) -+ { -+ DEBUGP("incorrect range: %hu-%hu, correcting\n", -+ prtspexp->loport, prtspexp->hiport); -+ prtspexp->loport &= 0xfffe; -+ prtspexp->hiport = prtspexp->loport+1; -+ } -+ } -+ else if (ptran[off] == '/') -+ { -+ off++; -+ numlen = nf_strtou16(ptran+off, &port); -+ off += numlen; -+ prtspexp->pbtype = pb_discon; -+ prtspexp->hiport = port; -+ } -+ rc = 1; -+ } -+ } -+ -+ /* -+ * Note we don't look for the destination parameter here. -+ * If we are using NAT, the NAT module will handle it. If not, -+ * and the client is sending packets elsewhere, the expectation -+ * will quietly time out. -+ */ -+ -+ off = nextfieldoff; -+ } -+ -+ off = nextparamoff; -+ } -+ -+ return rc; -+} -+ -+/*** conntrack functions ***/ -+ -+/* outbound packet: client->server */ -+static int -+help_out(const struct iphdr* iph, size_t pktlen, -+ struct ip_conntrack* ct, enum ip_conntrack_info ctinfo) -+{ -+ int dir = CTINFO2DIR(ctinfo); /* = IP_CT_DIR_ORIGINAL */ -+ struct tcphdr* tcph = (void*)iph + iph->ihl * 4; -+ uint tcplen = pktlen - iph->ihl * 4; -+ char* pdata = (char*)tcph + tcph->doff * 4; -+ uint datalen = tcplen - tcph->doff * 4; -+ uint dataoff = 0; -+ -+ struct ip_conntrack_expect exp; -+ -+ while (dataoff < datalen) -+ { -+ uint cmdoff = dataoff; -+ uint hdrsoff = 0; -+ uint hdrslen = 0; -+ uint cseqoff = 0; -+ uint cseqlen = 0; -+ uint lineoff = 0; -+ uint linelen = 0; -+ uint off; -+ int rc; -+ -+ if (!rtsp_parse_message(pdata, datalen, &dataoff, -+ &hdrsoff, &hdrslen, -+ &cseqoff, &cseqlen)) -+ { -+ break; /* not a valid message */ -+ } -+ -+ if (strncmp(pdata+cmdoff, "SETUP ", 6) != 0) -+ { -+ continue; /* not a SETUP message */ -+ } -+ DEBUGP("found a setup message\n"); -+ -+ memset(&exp, 0, sizeof(exp)); -+ -+ off = 0; -+ while (nf_mime_nextline(pdata+hdrsoff, hdrslen, &off, -+ &lineoff, &linelen)) -+ { -+ if (linelen == 0) -+ { -+ break; -+ } -+ if (off > hdrsoff+hdrslen) -+ { -+ INFOP("!! overrun !!"); -+ break; -+ } -+ -+ if (nf_strncasecmp(pdata+hdrsoff+lineoff, "Transport:", 10) == 0) -+ { -+ rtsp_parse_transport(pdata+hdrsoff+lineoff, linelen, -+ &exp.help.exp_rtsp_info); -+ } -+ } -+ -+ if (exp.help.exp_rtsp_info.loport == 0) -+ { -+ DEBUGP("no udp transports found\n"); -+ continue; /* no udp transports found */ -+ } -+ -+ DEBUGP("udp transport found, ports=(%d,%hu,%hu)\n", -+ (int)exp.help.exp_rtsp_info.pbtype, -+ exp.help.exp_rtsp_info.loport, -+ exp.help.exp_rtsp_info.hiport); -+ -+ LOCK_BH(&ip_rtsp_lock); -+ exp.seq = ntohl(tcph->seq) + hdrsoff; /* mark all the headers */ -+ exp.help.exp_rtsp_info.len = hdrslen; -+ -+ exp.tuple.src.ip = ct->tuplehash[!dir].tuple.src.ip; -+ exp.mask.src.ip = 0xffffffff; -+ exp.tuple.dst.ip = ct->tuplehash[dir].tuple.src.ip; -+ exp.mask.dst.ip = 0xffffffff; -+ exp.tuple.dst.u.udp.port = exp.help.exp_rtsp_info.loport; -+ exp.mask.dst.u.udp.port = (exp.help.exp_rtsp_info.pbtype == pb_range) ? 0xfffe : 0xffff; -+ exp.tuple.dst.protonum = IPPROTO_UDP; -+ exp.mask.dst.protonum = 0xffff; -+ -+ DEBUGP("expect_related %u.%u.%u.%u:%u-%u.%u.%u.%u:%u\n", -+ NIPQUAD(exp.tuple.src.ip), -+ ntohs(exp.tuple.src.u.tcp.port), -+ NIPQUAD(exp.tuple.dst.ip), -+ ntohs(exp.tuple.dst.u.tcp.port)); -+ -+ /* pass the request off to the nat helper */ -+ rc = ip_conntrack_expect_related(ct, &exp); -+ UNLOCK_BH(&ip_rtsp_lock); -+ if (rc == 0) -+ { -+ DEBUGP("ip_conntrack_expect_related succeeded\n"); -+ } -+ else -+ { -+ INFOP("ip_conntrack_expect_related failed (%d)\n", rc); -+ } -+ } -+ -+ return NF_ACCEPT; -+} -+ -+/* inbound packet: server->client */ -+static int -+help_in(const struct iphdr* iph, size_t pktlen, -+ struct ip_conntrack* ct, enum ip_conntrack_info ctinfo) -+{ -+ return NF_ACCEPT; -+} -+ -+static int -+help(const struct iphdr* iph, size_t pktlen, -+ struct ip_conntrack* ct, enum ip_conntrack_info ctinfo) -+{ -+ /* tcplen not negative guarenteed by ip_conntrack_tcp.c */ -+ struct tcphdr* tcph = (void*)iph + iph->ihl * 4; -+ u_int32_t tcplen = pktlen - iph->ihl * 4; -+ -+ /* Until there's been traffic both ways, don't look in packets. */ -+ if (ctinfo != IP_CT_ESTABLISHED && ctinfo != IP_CT_ESTABLISHED + IP_CT_IS_REPLY) -+ { -+ DEBUGP("conntrackinfo = %u\n", ctinfo); -+ return NF_ACCEPT; -+ } -+ -+ /* Not whole TCP header? */ -+ if (tcplen < sizeof(struct tcphdr) || tcplen < tcph->doff * 4) -+ { -+ DEBUGP("tcplen = %u\n", (unsigned)tcplen); -+ return NF_ACCEPT; -+ } -+ -+ /* Checksum invalid? Ignore. */ -+ /* FIXME: Source route IP option packets --RR */ -+ if (tcp_v4_check(tcph, tcplen, iph->saddr, iph->daddr, -+ csum_partial((char*)tcph, tcplen, 0))) -+ { -+ DEBUGP("bad csum: %p %u %u.%u.%u.%u %u.%u.%u.%u\n", -+ tcph, tcplen, NIPQUAD(iph->saddr), NIPQUAD(iph->daddr)); -+ return NF_ACCEPT; -+ } -+ -+ switch (CTINFO2DIR(ctinfo)) -+ { -+ case IP_CT_DIR_ORIGINAL: -+ help_out(iph, pktlen, ct, ctinfo); -+ break; -+ case IP_CT_DIR_REPLY: -+ help_in(iph, pktlen, ct, ctinfo); -+ break; -+ } -+ -+ return NF_ACCEPT; -+} -+ -+static struct ip_conntrack_helper rtsp_helpers[MAX_PORTS]; -+static char rtsp_names[MAX_PORTS][10]; -+ -+/* This function is intentionally _NOT_ defined as __exit */ -+static void -+fini(void) -+{ -+ int i; -+ for (i = 0; i < num_ports; i++) -+ { -+ DEBUGP("unregistering port %d\n", ports[i]); -+ ip_conntrack_helper_unregister(&rtsp_helpers[i]); -+ } -+} -+ -+static int __init -+init(void) -+{ -+ int i, ret; -+ struct ip_conntrack_helper *hlpr; -+ char *tmpname; -+ -+ printk("ip_conntrack_rtsp v" IP_NF_RTSP_VERSION " loading\n"); -+ -+ if (max_outstanding < 1) -+ { -+ printk("ip_conntrack_rtsp: max_outstanding must be a positive integer\n"); -+ return -EBUSY; -+ } -+ if (setup_timeout < 0) -+ { -+ printk("ip_conntrack_rtsp: setup_timeout must be a positive integer\n"); -+ return -EBUSY; -+ } -+ -+ /* If no port given, default to standard rtsp port */ -+ if (ports[0] == 0) -+ { -+ ports[0] = RTSP_PORT; -+ } -+ -+ for (i = 0; (i < MAX_PORTS) && ports[i]; i++) -+ { -+ hlpr = &rtsp_helpers[i]; -+ memset(hlpr, 0, sizeof(struct ip_conntrack_helper)); -+ hlpr->tuple.src.u.tcp.port = htons(ports[i]); -+ hlpr->tuple.dst.protonum = IPPROTO_TCP; -+ hlpr->mask.src.u.tcp.port = 0xFFFF; -+ hlpr->mask.dst.protonum = 0xFFFF; -+ hlpr->max_expected = max_outstanding; -+ hlpr->timeout = setup_timeout; -+ hlpr->flags = IP_CT_HELPER_F_REUSE_EXPECT; -+ hlpr->me = ip_conntrack_rtsp; -+ hlpr->help = help; -+ -+ tmpname = &rtsp_names[i][0]; -+ if (ports[i] == RTSP_PORT) -+ { -+ sprintf(tmpname, "rtsp"); -+ } -+ else -+ { -+ sprintf(tmpname, "rtsp-%d", i); -+ } -+ hlpr->name = tmpname; -+ -+ DEBUGP("port #%d: %d\n", i, ports[i]); -+ -+ ret = ip_conntrack_helper_register(hlpr); -+ -+ if (ret) -+ { -+ printk("ip_conntrack_rtsp: ERROR registering port %d\n", ports[i]); -+ fini(); -+ return -EBUSY; -+ } -+ num_ports++; -+ } -+ return 0; -+} -+ -+#ifdef CONFIG_IP_NF_NAT_NEEDED -+EXPORT_SYMBOL(ip_rtsp_lock); -+#endif -+ -+module_init(init); -+module_exit(fini); ---- /dev/null -+++ b/net/ipv4/netfilter/ip_nat_rtsp.c -@@ -0,0 +1,621 @@ -+/* -+ * RTSP extension for TCP NAT alteration -+ * (C) 2003 by Tom Marshall <tmarshall@real.com> -+ * based on ip_nat_irc.c -+ * -+ * 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. -+ * -+ * Module load syntax: -+ * insmod ip_nat_rtsp.o ports=port1,port2,...port<MAX_PORTS> -+ * stunaddr=<address> -+ * destaction=[auto|strip|none] -+ * -+ * If no ports are specified, the default will be port 554 only. -+ * -+ * stunaddr specifies the address used to detect that a client is using STUN. -+ * If this address is seen in the destination parameter, it is assumed that -+ * the client has already punched a UDP hole in the firewall, so we don't -+ * mangle the client_port. If none is specified, it is autodetected. It -+ * only needs to be set if you have multiple levels of NAT. It should be -+ * set to the external address that the STUN clients detect. Note that in -+ * this case, it will not be possible for clients to use UDP with servers -+ * between the NATs. -+ * -+ * If no destaction is specified, auto is used. -+ * destaction=auto: strip destination parameter if it is not stunaddr. -+ * destaction=strip: always strip destination parameter (not recommended). -+ * destaction=none: do not touch destination parameter (not recommended). -+ */ -+ -+#include <linux/module.h> -+#include <linux/netfilter_ipv4.h> -+#include <linux/ip.h> -+#include <linux/tcp.h> -+#include <linux/kernel.h> -+#include <net/tcp.h> -+#include <linux/netfilter_ipv4/ip_nat.h> -+#include <linux/netfilter_ipv4/ip_nat_helper.h> -+#include <linux/netfilter_ipv4/ip_nat_rule.h> -+#include <linux/netfilter_ipv4/ip_conntrack_rtsp.h> -+#include <linux/netfilter_ipv4/ip_conntrack_helper.h> -+ -+#include <linux/inet.h> -+#include <linux/ctype.h> -+#define NF_NEED_STRNCASECMP -+#define NF_NEED_STRTOU16 -+#include <linux/netfilter_helpers.h> -+#define NF_NEED_MIME_NEXTLINE -+#include <linux/netfilter_mime.h> -+ -+#define INFOP(fmt, args...) printk(KERN_INFO "%s: %s: " fmt, __FILE__, __FUNCTION__ , ## args) -+#ifdef IP_NF_RTSP_DEBUG -+#define DEBUGP(fmt, args...) printk(KERN_DEBUG "%s: %s: " fmt, __FILE__, __FUNCTION__ , ## args) -+#else -+#define DEBUGP(fmt, args...) -+#endif -+ -+#define MAX_PORTS 8 -+#define DSTACT_AUTO 0 -+#define DSTACT_STRIP 1 -+#define DSTACT_NONE 2 -+ -+static int ports[MAX_PORTS]; -+static char* stunaddr = NULL; -+static char* destaction = NULL; -+ -+static int num_ports = 0; -+static u_int32_t extip = 0; -+static int dstact = 0; -+ -+MODULE_AUTHOR("Tom Marshall <tmarshall@real.com>"); -+MODULE_DESCRIPTION("RTSP network address translation module"); -+MODULE_LICENSE("GPL"); -+#ifdef MODULE_PARM -+MODULE_PARM(ports, "1-" __MODULE_STRING(MAX_PORTS) "i"); -+MODULE_PARM_DESC(ports, "port numbers of RTSP servers"); -+MODULE_PARM(stunaddr, "s"); -+MODULE_PARM_DESC(stunaddr, "Address for detecting STUN"); -+MODULE_PARM(destaction, "s"); -+MODULE_PARM_DESC(destaction, "Action for destination parameter (auto/strip/none)"); -+#endif -+ -+/* protects rtsp part of conntracks */ -+DECLARE_LOCK_EXTERN(ip_rtsp_lock); -+ -+#define SKIP_WSPACE(ptr,len,off) while(off < len && isspace(*(ptr+off))) { off++; } -+ -+/*** helper functions ***/ -+ -+static void -+get_skb_tcpdata(struct sk_buff* skb, char** pptcpdata, uint* ptcpdatalen) -+{ -+ struct iphdr* iph = (struct iphdr*)skb->nh.iph; -+ struct tcphdr* tcph = (struct tcphdr*)((char*)iph + iph->ihl*4); -+ -+ *pptcpdata = (char*)tcph + tcph->doff*4; -+ *ptcpdatalen = ((char*)skb->h.raw + skb->len) - *pptcpdata; -+} -+ -+/*** nat functions ***/ -+ -+/* -+ * Mangle the "Transport:" header: -+ * - Replace all occurences of "client_port=<spec>" -+ * - Handle destination parameter -+ * -+ * In: -+ * ct, ctinfo = conntrack context -+ * pskb = packet -+ * tranoff = Transport header offset from TCP data -+ * tranlen = Transport header length (incl. CRLF) -+ * rport_lo = replacement low port (host endian) -+ * rport_hi = replacement high port (host endian) -+ * -+ * Returns packet size difference. -+ * -+ * Assumes that a complete transport header is present, ending with CR or LF -+ */ -+static int -+rtsp_mangle_tran(struct ip_conntrack* ct, enum ip_conntrack_info ctinfo, -+ struct ip_conntrack_expect* exp, -+ struct sk_buff** pskb, uint tranoff, uint tranlen) -+{ -+ char* ptcp; -+ uint tcplen; -+ char* ptran; -+ char rbuf1[16]; /* Replacement buffer (one port) */ -+ uint rbuf1len; /* Replacement len (one port) */ -+ char rbufa[16]; /* Replacement buffer (all ports) */ -+ uint rbufalen; /* Replacement len (all ports) */ -+ u_int32_t newip; -+ u_int16_t loport, hiport; -+ uint off = 0; -+ uint diff; /* Number of bytes we removed */ -+ -+ struct ip_ct_rtsp_expect* prtspexp = &exp->help.exp_rtsp_info; -+ struct ip_conntrack_tuple t; -+ -+ char szextaddr[15+1]; -+ uint extaddrlen; -+ int is_stun; -+ -+ get_skb_tcpdata(*pskb, &ptcp, &tcplen); -+ ptran = ptcp+tranoff; -+ -+ if (tranoff+tranlen > tcplen || tcplen-tranoff < tranlen || -+ tranlen < 10 || !iseol(ptran[tranlen-1]) || -+ nf_strncasecmp(ptran, "Transport:", 10) != 0) -+ { -+ INFOP("sanity check failed\n"); -+ return 0; -+ } -+ off += 10; -+ SKIP_WSPACE(ptcp+tranoff, tranlen, off); -+ -+ newip = ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip; -+ t = exp->tuple; -+ t.dst.ip = newip; -+ -+ extaddrlen = extip ? sprintf(szextaddr, "%u.%u.%u.%u", NIPQUAD(extip)) -+ : sprintf(szextaddr, "%u.%u.%u.%u", NIPQUAD(newip)); -+ DEBUGP("stunaddr=%s (%s)\n", szextaddr, (extip?"forced":"auto")); -+ -+ rbuf1len = rbufalen = 0; -+ switch (prtspexp->pbtype) -+ { -+ case pb_single: -+ for (loport = prtspexp->loport; loport != 0; loport++) /* XXX: improper wrap? */ -+ { -+ t.dst.u.udp.port = htons(loport); -+ if (ip_conntrack_change_expect(exp, &t) == 0) -+ { -+ DEBUGP("using port %hu\n", loport); -+ break; -+ } -+ } -+ if (loport != 0) -+ { -+ rbuf1len = sprintf(rbuf1, "%hu", loport); -+ rbufalen = sprintf(rbufa, "%hu", loport); -+ } -+ break; -+ case pb_range: -+ for (loport = prtspexp->loport; loport != 0; loport += 2) /* XXX: improper wrap? */ -+ { -+ t.dst.u.udp.port = htons(loport); -+ if (ip_conntrack_change_expect(exp, &t) == 0) -+ { -+ hiport = loport + ~exp->mask.dst.u.udp.port; -+ DEBUGP("using ports %hu-%hu\n", loport, hiport); -+ break; -+ } -+ } -+ if (loport != 0) -+ { -+ rbuf1len = sprintf(rbuf1, "%hu", loport); -+ rbufalen = sprintf(rbufa, "%hu-%hu", loport, loport+1); -+ } -+ break; -+ case pb_discon: -+ for (loport = prtspexp->loport; loport != 0; loport++) /* XXX: improper wrap? */ -+ { -+ t.dst.u.udp.port = htons(loport); -+ if (ip_conntrack_change_expect(exp, &t) == 0) -+ { -+ DEBUGP("using port %hu (1 of 2)\n", loport); -+ break; -+ } -+ } -+ for (hiport = prtspexp->hiport; hiport != 0; hiport++) /* XXX: improper wrap? */ -+ { -+ t.dst.u.udp.port = htons(hiport); -+ if (ip_conntrack_change_expect(exp, &t) == 0) -+ { -+ DEBUGP("using port %hu (2 of 2)\n", hiport); -+ break; -+ } -+ } -+ if (loport != 0 && hiport != 0) -+ { -+ rbuf1len = sprintf(rbuf1, "%hu", loport); -+ if (hiport == loport+1) -+ { -+ rbufalen = sprintf(rbufa, "%hu-%hu", loport, hiport); -+ } -+ else -+ { -+ rbufalen = sprintf(rbufa, "%hu/%hu", loport, hiport); -+ } -+ } -+ break; -+ } -+ -+ if (rbuf1len == 0) -+ { -+ return 0; /* cannot get replacement port(s) */ -+ } -+ -+ /* Transport: tran;field;field=val,tran;field;field=val,... */ -+ while (off < tranlen) -+ { -+ uint saveoff; -+ const char* pparamend; -+ uint nextparamoff; -+ -+ pparamend = memchr(ptran+off, ',', tranlen-off); -+ pparamend = (pparamend == NULL) ? ptran+tranlen : pparamend+1; -+ nextparamoff = pparamend-ptcp; -+ -+ /* -+ * We pass over each param twice. On the first pass, we look for a -+ * destination= field. It is handled by the security policy. If it -+ * is present, allowed, and equal to our external address, we assume -+ * that STUN is being used and we leave the client_port= field alone. -+ */ -+ is_stun = 0; -+ saveoff = off; -+ while (off < nextparamoff) -+ { -+ const char* pfieldend; -+ uint nextfieldoff; -+ -+ pfieldend = memchr(ptran+off, ';', nextparamoff-off); -+ nextfieldoff = (pfieldend == NULL) ? nextparamoff : pfieldend-ptran+1; -+ -+ if (dstact != DSTACT_NONE && strncmp(ptran+off, "destination=", 12) == 0) -+ { -+ if (strncmp(ptran+off+12, szextaddr, extaddrlen) == 0) -+ { -+ is_stun = 1; -+ } -+ if (dstact == DSTACT_STRIP || (dstact == DSTACT_AUTO && !is_stun)) -+ { -+ diff = nextfieldoff-off; -+ if (!ip_nat_mangle_tcp_packet(pskb, ct, ctinfo, -+ off, diff, NULL, 0)) -+ { -+ /* mangle failed, all we can do is bail */ -+ return 0; -+ } -+ get_skb_tcpdata(*pskb, &ptcp, &tcplen); -+ ptran = ptcp+tranoff; -+ tranlen -= diff; -+ nextparamoff -= diff; -+ nextfieldoff -= diff; -+ } -+ } -+ -+ off = nextfieldoff; -+ } -+ if (is_stun) -+ { -+ continue; -+ } -+ off = saveoff; -+ while (off < nextparamoff) -+ { -+ const char* pfieldend; -+ uint nextfieldoff; -+ -+ pfieldend = memchr(ptran+off, ';', nextparamoff-off); -+ nextfieldoff = (pfieldend == NULL) ? nextparamoff : pfieldend-ptran+1; -+ -+ if (strncmp(ptran+off, "client_port=", 12) == 0) -+ { -+ u_int16_t port; -+ uint numlen; -+ uint origoff; -+ uint origlen; -+ char* rbuf = rbuf1; -+ uint rbuflen = rbuf1len; -+ -+ off += 12; -+ origoff = (ptran-ptcp)+off; -+ origlen = 0; -+ numlen = nf_strtou16(ptran+off, &port); -+ off += numlen; -+ origlen += numlen; -+ if (port != prtspexp->loport) -+ { -+ DEBUGP("multiple ports found, port %hu ignored\n", port); -+ } -+ else -+ { -+ if (ptran[off] == '-' || ptran[off] == '/') -+ { -+ off++; -+ origlen++; -+ numlen = nf_strtou16(ptran+off, &port); -+ off += numlen; -+ origlen += numlen; -+ rbuf = rbufa; -+ rbuflen = rbufalen; -+ } -+ -+ /* -+ * note we cannot just memcpy() if the sizes are the same. -+ * the mangle function does skb resizing, checks for a -+ * cloned skb, and updates the checksums. -+ * -+ * parameter 4 below is offset from start of tcp data. -+ */ -+ diff = origlen-rbuflen; -+ if (!ip_nat_mangle_tcp_packet(pskb, ct, ctinfo, -+ origoff, origlen, rbuf, rbuflen)) -+ { -+ /* mangle failed, all we can do is bail */ -+ return 0; -+ } -+ get_skb_tcpdata(*pskb, &ptcp, &tcplen); -+ ptran = ptcp+tranoff; -+ tranlen -= diff; -+ nextparamoff -= diff; -+ nextfieldoff -= diff; -+ } -+ } -+ -+ off = nextfieldoff; -+ } -+ -+ off = nextparamoff; -+ } -+ -+ return 1; -+} -+ -+static unsigned int -+expected(struct sk_buff **pskb, uint hooknum, struct ip_conntrack* ct, struct ip_nat_info* info) -+{ -+ struct ip_nat_multi_range mr; -+ u_int32_t newdstip, newsrcip, newip; -+ -+ struct ip_conntrack *master = master_ct(ct); -+ -+ IP_NF_ASSERT(info); -+ IP_NF_ASSERT(master); -+ -+ IP_NF_ASSERT(!(info->initialized & (1 << HOOK2MANIP(hooknum)))); -+ -+ newdstip = master->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip; -+ newsrcip = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip; -+ newip = (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC) ? newsrcip : newdstip; -+ -+ DEBUGP("newsrcip=%u.%u.%u.%u, newdstip=%u.%u.%u.%u, newip=%u.%u.%u.%u\n", -+ NIPQUAD(newsrcip), NIPQUAD(newdstip), NIPQUAD(newip)); -+ -+ mr.rangesize = 1; -+ /* We don't want to manip the per-protocol, just the IPs. */ -+ mr.range[0].flags = IP_NAT_RANGE_MAP_IPS; -+ mr.range[0].min_ip = mr.range[0].max_ip = newip; -+ -+ return ip_nat_setup_info(ct, &mr, hooknum); -+} -+ -+static uint -+help_out(struct ip_conntrack* ct, enum ip_conntrack_info ctinfo, -+ struct ip_conntrack_expect* exp, struct sk_buff** pskb) -+{ -+ char* ptcp; -+ uint tcplen; -+ uint hdrsoff; -+ uint hdrslen; -+ uint lineoff; -+ uint linelen; -+ uint off; -+ -+ struct iphdr* iph = (struct iphdr*)(*pskb)->nh.iph; -+ struct tcphdr* tcph = (struct tcphdr*)((void*)iph + iph->ihl*4); -+ -+ struct ip_ct_rtsp_expect* prtspexp = &exp->help.exp_rtsp_info; -+ -+ get_skb_tcpdata(*pskb, &ptcp, &tcplen); -+ -+ hdrsoff = exp->seq - ntohl(tcph->seq); -+ hdrslen = prtspexp->len; -+ off = hdrsoff; -+ -+ while (nf_mime_nextline(ptcp, hdrsoff+hdrslen, &off, &lineoff, &linelen)) -+ { -+ if (linelen == 0) -+ { -+ break; -+ } -+ if (off > hdrsoff+hdrslen) -+ { -+ INFOP("!! overrun !!"); -+ break; -+ } -+ DEBUGP("hdr: len=%u, %.*s", linelen, (int)linelen, ptcp+lineoff); -+ -+ if (nf_strncasecmp(ptcp+lineoff, "Transport:", 10) == 0) -+ { -+ uint oldtcplen = tcplen; -+ if (!rtsp_mangle_tran(ct, ctinfo, exp, pskb, lineoff, linelen)) -+ { -+ break; -+ } -+ get_skb_tcpdata(*pskb, &ptcp, &tcplen); -+ hdrslen -= (oldtcplen-tcplen); -+ off -= (oldtcplen-tcplen); -+ lineoff -= (oldtcplen-tcplen); -+ linelen -= (oldtcplen-tcplen); -+ DEBUGP("rep: len=%u, %.*s", linelen, (int)linelen, ptcp+lineoff); -+ } -+ } -+ -+ return NF_ACCEPT; -+} -+ -+static uint -+help_in(struct ip_conntrack* ct, enum ip_conntrack_info ctinfo, -+ struct ip_conntrack_expect* exp, struct sk_buff** pskb) -+{ -+ /* XXX: unmangle */ -+ return NF_ACCEPT; -+} -+ -+static uint -+help(struct ip_conntrack* ct, -+ struct ip_conntrack_expect* exp, -+ struct ip_nat_info* info, -+ enum ip_conntrack_info ctinfo, -+ unsigned int hooknum, -+ struct sk_buff** pskb) -+{ -+ struct iphdr* iph = (struct iphdr*)(*pskb)->nh.iph; -+ struct tcphdr* tcph = (struct tcphdr*)((char*)iph + iph->ihl * 4); -+ uint datalen; -+ int dir; -+ struct ip_ct_rtsp_expect* ct_rtsp_info; -+ int rc = NF_ACCEPT; -+ -+ if (ct == NULL || exp == NULL || info == NULL || pskb == NULL) -+ { -+ DEBUGP("!! null ptr (%p,%p,%p,%p) !!\n", ct, exp, info, pskb); -+ return NF_ACCEPT; -+ } -+ -+ ct_rtsp_info = &exp->help.exp_rtsp_info; -+ -+ /* -+ * Only mangle things once: original direction in POST_ROUTING -+ * and reply direction on PRE_ROUTING. -+ */ -+ dir = CTINFO2DIR(ctinfo); -+ if (!((hooknum == NF_IP_POST_ROUTING && dir == IP_CT_DIR_ORIGINAL) -+ || (hooknum == NF_IP_PRE_ROUTING && dir == IP_CT_DIR_REPLY))) -+ { -+ DEBUGP("Not touching dir %s at hook %s\n", -+ dir == IP_CT_DIR_ORIGINAL ? "ORIG" : "REPLY", -+ hooknum == NF_IP_POST_ROUTING ? "POSTROUTING" -+ : hooknum == NF_IP_PRE_ROUTING ? "PREROUTING" -+ : hooknum == NF_IP_LOCAL_OUT ? "OUTPUT" : "???"); -+ return NF_ACCEPT; -+ } -+ DEBUGP("got beyond not touching\n"); -+ -+ datalen = (*pskb)->len - iph->ihl * 4 - tcph->doff * 4; -+ -+ LOCK_BH(&ip_rtsp_lock); -+ /* Ensure the packet contains all of the marked data */ -+ if (!between(exp->seq + ct_rtsp_info->len, -+ ntohl(tcph->seq), ntohl(tcph->seq) + datalen)) -+ { -+ /* Partial retransmission? Probably a hacker. */ -+ if (net_ratelimit()) -+ { -+ INFOP("partial packet %u/%u in %u/%u\n", -+ exp->seq, ct_rtsp_info->len, ntohl(tcph->seq), ntohl(tcph->seq) + datalen); -+ } -+ UNLOCK_BH(&ip_rtsp_lock); -+ return NF_DROP; -+ } -+ -+ switch (dir) -+ { -+ case IP_CT_DIR_ORIGINAL: -+ rc = help_out(ct, ctinfo, exp, pskb); -+ break; -+ case IP_CT_DIR_REPLY: -+ rc = help_in(ct, ctinfo, exp, pskb); -+ break; -+ } -+ UNLOCK_BH(&ip_rtsp_lock); -+ -+ return rc; -+} -+ -+static struct ip_nat_helper ip_nat_rtsp_helpers[MAX_PORTS]; -+static char rtsp_names[MAX_PORTS][10]; -+ -+/* This function is intentionally _NOT_ defined as __exit */ -+static void -+fini(void) -+{ -+ int i; -+ -+ for (i = 0; i < num_ports; i++) -+ { -+ DEBUGP("unregistering helper for port %d\n", ports[i]); -+ ip_nat_helper_unregister(&ip_nat_rtsp_helpers[i]); -+ } -+} -+ -+static int __init -+init(void) -+{ -+ int ret = 0; -+ int i; -+ struct ip_nat_helper* hlpr; -+ char* tmpname; -+ -+ printk("ip_nat_rtsp v" IP_NF_RTSP_VERSION " loading\n"); -+ -+ if (ports[0] == 0) -+ { -+ ports[0] = RTSP_PORT; -+ } -+ -+ for (i = 0; (i < MAX_PORTS) && ports[i] != 0; i++) -+ { -+ hlpr = &ip_nat_rtsp_helpers[i]; -+ memset(hlpr, 0, sizeof(struct ip_nat_helper)); -+ -+ hlpr->tuple.dst.protonum = IPPROTO_TCP; -+ hlpr->tuple.src.u.tcp.port = htons(ports[i]); -+ hlpr->mask.src.u.tcp.port = 0xFFFF; -+ hlpr->mask.dst.protonum = 0xFFFF; -+ hlpr->help = help; -+ hlpr->flags = 0; -+ hlpr->me = THIS_MODULE; -+ hlpr->expect = expected; -+ -+ tmpname = &rtsp_names[i][0]; -+ if (ports[i] == RTSP_PORT) -+ { -+ sprintf(tmpname, "rtsp"); -+ } -+ else -+ { -+ sprintf(tmpname, "rtsp-%d", i); -+ } -+ hlpr->name = tmpname; -+ -+ DEBUGP("registering helper for port %d: name %s\n", ports[i], hlpr->name); -+ ret = ip_nat_helper_register(hlpr); -+ -+ if (ret) -+ { -+ printk("ip_nat_rtsp: error registering helper for port %d\n", ports[i]); -+ fini(); -+ return 1; -+ } -+ num_ports++; -+ } -+ if (stunaddr != NULL) -+ { -+ extip = in_aton(stunaddr); -+ } -+ if (destaction != NULL) -+ { -+ if (strcmp(destaction, "auto") == 0) -+ { -+ dstact = DSTACT_AUTO; -+ } -+ if (strcmp(destaction, "strip") == 0) -+ { -+ dstact = DSTACT_STRIP; -+ } -+ if (strcmp(destaction, "none") == 0) -+ { -+ dstact = DSTACT_NONE; -+ } -+ } -+ return ret; -+} -+ -+module_init(init); -+module_exit(fini); ---- a/arch/mips/kernel/mips_ksyms.c -+++ b/arch/mips/kernel/mips_ksyms.c -@@ -52,6 +52,7 @@ EXPORT_SYMBOL(EISA_bus); - /* - * String functions - */ -+EXPORT_SYMBOL_NOVERS(memchr); - EXPORT_SYMBOL_NOVERS(memcmp); - EXPORT_SYMBOL_NOVERS(memset); - EXPORT_SYMBOL_NOVERS(memcpy); ---- /dev/null -+++ b/include/linux/netfilter_helpers.h -@@ -0,0 +1,133 @@ -+/* -+ * Helpers for netfiler modules. This file provides implementations for basic -+ * functions such as strncasecmp(), etc. -+ * -+ * gcc will warn for defined but unused functions, so we only include the -+ * functions requested. The following macros are used: -+ * NF_NEED_STRNCASECMP nf_strncasecmp() -+ * NF_NEED_STRTOU16 nf_strtou16() -+ * NF_NEED_STRTOU32 nf_strtou32() -+ */ -+#ifndef _NETFILTER_HELPERS_H -+#define _NETFILTER_HELPERS_H -+ -+/* Only include these functions for kernel code. */ -+#ifdef __KERNEL__ -+ -+#include <linux/ctype.h> -+#define iseol(c) ( (c) == '\r' || (c) == '\n' ) -+ -+/* -+ * The standard strncasecmp() -+ */ -+#ifdef NF_NEED_STRNCASECMP -+static int -+nf_strncasecmp(const char* s1, const char* s2, u_int32_t len) -+{ -+ if (s1 == NULL || s2 == NULL) -+ { -+ if (s1 == NULL && s2 == NULL) -+ { -+ return 0; -+ } -+ return (s1 == NULL) ? -1 : 1; -+ } -+ while (len > 0 && tolower(*s1) == tolower(*s2)) -+ { -+ len--; -+ s1++; -+ s2++; -+ } -+ return ( (len == 0) ? 0 : (tolower(*s1) - tolower(*s2)) ); -+} -+#endif /* NF_NEED_STRNCASECMP */ -+ -+/* -+ * Parse a string containing a 16-bit unsigned integer. -+ * Returns the number of chars used, or zero if no number is found. -+ */ -+#ifdef NF_NEED_STRTOU16 -+static int -+nf_strtou16(const char* pbuf, u_int16_t* pval) -+{ -+ int n = 0; -+ -+ *pval = 0; -+ while (isdigit(pbuf[n])) -+ { -+ *pval = (*pval * 10) + (pbuf[n] - '0'); -+ n++; -+ } -+ -+ return n; -+} -+#endif /* NF_NEED_STRTOU16 */ -+ -+/* -+ * Parse a string containing a 32-bit unsigned integer. -+ * Returns the number of chars used, or zero if no number is found. -+ */ -+#ifdef NF_NEED_STRTOU32 -+static int -+nf_strtou32(const char* pbuf, u_int32_t* pval) -+{ -+ int n = 0; -+ -+ *pval = 0; -+ while (pbuf[n] >= '0' && pbuf[n] <= '9') -+ { -+ *pval = (*pval * 10) + (pbuf[n] - '0'); -+ n++; -+ } -+ -+ return n; -+} -+#endif /* NF_NEED_STRTOU32 */ -+ -+/* -+ * Given a buffer and length, advance to the next line and mark the current -+ * line. -+ */ -+#ifdef NF_NEED_NEXTLINE -+static int -+nf_nextline(char* p, uint len, uint* poff, uint* plineoff, uint* plinelen) -+{ -+ uint off = *poff; -+ uint physlen = 0; -+ -+ if (off >= len) -+ { -+ return 0; -+ } -+ -+ while (p[off] != '\n') -+ { -+ if (len-off <= 1) -+ { -+ return 0; -+ } -+ -+ physlen++; -+ off++; -+ } -+ -+ /* if we saw a crlf, physlen needs adjusted */ -+ if (physlen > 0 && p[off] == '\n' && p[off-1] == '\r') -+ { -+ physlen--; -+ } -+ -+ /* advance past the newline */ -+ off++; -+ -+ *plineoff = *poff; -+ *plinelen = physlen; -+ *poff = off; -+ -+ return 1; -+} -+#endif /* NF_NEED_NEXTLINE */ -+ -+#endif /* __KERNEL__ */ -+ -+#endif /* _NETFILTER_HELPERS_H */ ---- /dev/null -+++ b/include/linux/netfilter_ipv4/ip_conntrack_rtsp.h -@@ -0,0 +1,68 @@ -+/* -+ * RTSP extension for IP connection tracking. -+ * (C) 2003 by Tom Marshall <tmarshall@real.com> -+ * based on ip_conntrack_irc.h -+ * -+ * 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 _IP_CONNTRACK_RTSP_H -+#define _IP_CONNTRACK_RTSP_H -+ -+/* #define IP_NF_RTSP_DEBUG */ -+#define IP_NF_RTSP_VERSION "0.01" -+ -+/* port block types */ -+typedef enum { -+ pb_single, /* client_port=x */ -+ pb_range, /* client_port=x-y */ -+ pb_discon /* client_port=x/y (rtspbis) */ -+} portblock_t; -+ -+/* We record seq number and length of rtsp headers here, all in host order. */ -+ -+/* -+ * This structure is per expected connection. It is a member of struct -+ * ip_conntrack_expect. The TCP SEQ for the conntrack expect is stored -+ * there and we are expected to only store the length of the data which -+ * needs replaced. If a packet contains multiple RTSP messages, we create -+ * one expected connection per message. -+ * -+ * We use these variables to mark the entire header block. This may seem -+ * like overkill, but the nature of RTSP requires it. A header may appear -+ * multiple times in a message. We must treat two Transport headers the -+ * same as one Transport header with two entries. -+ */ -+struct ip_ct_rtsp_expect -+{ -+ u_int32_t len; /* length of header block */ -+ portblock_t pbtype; /* Type of port block that was requested */ -+ u_int16_t loport; /* Port that was requested, low or first */ -+ u_int16_t hiport; /* Port that was requested, high or second */ -+#if 0 -+ uint method; /* RTSP method */ -+ uint cseq; /* CSeq from request */ -+#endif -+}; -+ -+/* This structure exists only once per master */ -+struct ip_ct_rtsp_master -+{ -+ /* Empty (?) */ -+}; -+ -+ -+#ifdef __KERNEL__ -+ -+#include <linux/netfilter_ipv4/lockhelp.h> -+ -+#define RTSP_PORT 554 -+ -+/* Protects rtsp part of conntracks */ -+DECLARE_LOCK_EXTERN(ip_rtsp_lock); -+ -+#endif /* __KERNEL__ */ -+ -+#endif /* _IP_CONNTRACK_RTSP_H */ ---- /dev/null -+++ b/include/linux/netfilter_mime.h -@@ -0,0 +1,90 @@ -+/* -+ * MIME functions for netfilter modules. This file provides implementations -+ * for basic MIME parsing. MIME headers are used in many protocols, such as -+ * HTTP, RTSP, SIP, etc. -+ * -+ * gcc will warn for defined but unused functions, so we only include the -+ * functions requested. The following macros are used: -+ * NF_NEED_MIME_NEXTLINE nf_mime_nextline() -+ */ -+#ifndef _NETFILTER_MIME_H -+#define _NETFILTER_MIME_H -+ -+/* Only include these functions for kernel code. */ -+#ifdef __KERNEL__ -+ -+#include <linux/kernel.h> -+#include <linux/ctype.h> -+ -+/* -+ * Given a buffer and length, advance to the next line and mark the current -+ * line. If the current line is empty, *plinelen will be set to zero. If -+ * not, it will be set to the actual line length (including CRLF). -+ * -+ * 'line' in this context means logical line (includes LWS continuations). -+ * Returns 1 on success, 0 on failure. -+ */ -+#ifdef NF_NEED_MIME_NEXTLINE -+static int -+nf_mime_nextline(char* p, uint len, uint* poff, uint* plineoff, uint* plinelen) -+{ -+ uint off = *poff; -+ uint physlen = 0; -+ int is_first_line = 1; -+ -+ if (off >= len) -+ { -+ return 0; -+ } -+ -+ do -+ { -+ while (p[off] != '\n') -+ { -+ if (len-off <= 1) -+ { -+ return 0; -+ } -+ -+ physlen++; -+ off++; -+ } -+ -+ /* if we saw a crlf, physlen needs adjusted */ -+ if (physlen > 0 && p[off] == '\n' && p[off-1] == '\r') -+ { -+ physlen--; -+ } -+ -+ /* advance past the newline */ -+ off++; -+ -+ /* check for an empty line */ -+ if (physlen == 0) -+ { -+ break; -+ } -+ -+ /* check for colon on the first physical line */ -+ if (is_first_line) -+ { -+ is_first_line = 0; -+ if (memchr(p+(*poff), ':', physlen) == NULL) -+ { -+ return 0; -+ } -+ } -+ } -+ while (p[off] == ' ' || p[off] == '\t'); -+ -+ *plineoff = *poff; -+ *plinelen = (physlen == 0) ? 0 : (off - *poff); -+ *poff = off; -+ -+ return 1; -+} -+#endif /* NF_NEED_MIME_NEXTLINE */ -+ -+#endif /* __KERNEL__ */ -+ -+#endif /* _NETFILTER_MIME_H */ ---- a/include/linux/netfilter_ipv4/ip_conntrack.h -+++ b/include/linux/netfilter_ipv4/ip_conntrack.h -@@ -68,6 +68,7 @@ union ip_conntrack_expect_proto { - #include <linux/netfilter_ipv4/ip_conntrack_ftp.h> - #include <linux/netfilter_ipv4/ip_conntrack_irc.h> - #include <linux/netfilter_ipv4/ip_conntrack_h323.h> -+#include <linux/netfilter_ipv4/ip_conntrack_rtsp.h> - - /* per expectation: application helper private data */ - union ip_conntrack_expect_help { -@@ -76,6 +77,7 @@ union ip_conntrack_expect_help { - struct ip_ct_ftp_expect exp_ftp_info; - struct ip_ct_irc_expect exp_irc_info; - struct ip_ct_h225_expect exp_h225_info; -+ struct ip_ct_rtsp_expect exp_rtsp_info; - - #ifdef CONFIG_IP_NF_NAT_NEEDED - union { -@@ -90,6 +92,7 @@ union ip_conntrack_help { - struct ip_ct_ftp_master ct_ftp_info; - struct ip_ct_irc_master ct_irc_info; - struct ip_ct_h225_master ct_h225_info; -+ struct ip_ct_rtsp_master ct_rtsp_info; - }; - - #ifdef CONFIG_IP_NF_NAT_NEEDED diff --git a/target/linux/generic-2.4/patches/615-netfilter_nat_mms.patch b/target/linux/generic-2.4/patches/615-netfilter_nat_mms.patch deleted file mode 100644 index 511a337..0000000 --- a/target/linux/generic-2.4/patches/615-netfilter_nat_mms.patch +++ /dev/null @@ -1,733 +0,0 @@ ---- a/net/ipv4/netfilter/Config.in -+++ b/net/ipv4/netfilter/Config.in -@@ -15,6 +15,7 @@ if [ "$CONFIG_IP_NF_CONNTRACK" != "n" ]; - dep_tristate ' Connection byte counter support' CONFIG_IP_NF_MATCH_CONNBYTES $CONFIG_IP_NF_CT_ACCT $CONFIG_IP_NF_CONNTRACK $CONFIG_IP_NF_IPTABLES - dep_tristate ' H.323 (netmeeting) support' CONFIG_IP_NF_H323 $CONFIG_IP_NF_CONNTRACK - dep_tristate ' RTSP protocol support' CONFIG_IP_NF_RTSP $CONFIG_IP_NF_CONNTRACK -+ dep_tristate ' MMS protocol support' CONFIG_IP_NF_MMS $CONFIG_IP_NF_CONNTRACK - fi - - if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then -@@ -96,6 +97,13 @@ if [ "$CONFIG_IP_NF_IPTABLES" != "n" ]; - define_tristate CONFIG_IP_NF_NAT_RTSP $CONFIG_IP_NF_NAT - fi - fi -+ if [ "$CONFIG_IP_NF_MMS" = "m" ]; then -+ define_tristate CONFIG_IP_NF_NAT_MMS m -+ else -+ if [ "$CONFIG_IP_NF_MMS" = "y" ]; then -+ define_tristate CONFIG_IP_NF_NAT_MMS $CONFIG_IP_NF_NAT -+ fi -+ fi - if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then - dep_tristate ' Basic SNMP-ALG support (EXPERIMENTAL)' CONFIG_IP_NF_NAT_SNMP_BASIC $CONFIG_IP_NF_NAT - fi ---- a/net/ipv4/netfilter/Makefile -+++ b/net/ipv4/netfilter/Makefile -@@ -55,6 +55,10 @@ obj-$(CONFIG_IP_NF_RTSP) += ip_conntrack - ifdef CONFIG_IP_NF_NAT_RTSP - export-objs += ip_conntrack_rtsp.o - endif -+obj-$(CONFIG_IP_NF_MMS) += ip_conntrack_mms.o -+ifdef CONFIG_IP_NF_NAT_MMS -+ export-objs += ip_conntrack_mms.o -+endif - - - # NAT helpers -@@ -64,6 +68,7 @@ obj-$(CONFIG_IP_NF_NAT_FTP) += ip_nat_ft - obj-$(CONFIG_IP_NF_NAT_IRC) += ip_nat_irc.o - obj-$(CONFIG_IP_NF_NAT_H323) += ip_nat_h323.o - obj-$(CONFIG_IP_NF_NAT_RTSP) += ip_nat_rtsp.o -+obj-$(CONFIG_IP_NF_NAT_MMS) += ip_nat_mms.o - - # generic IP tables - obj-$(CONFIG_IP_NF_IPTABLES) += ip_tables.o ---- /dev/null -+++ b/net/ipv4/netfilter/ip_conntrack_mms.c -@@ -0,0 +1,292 @@ -+/* MMS extension for IP connection tracking -+ * (C) 2002 by Filip Sneppe <filip.sneppe@cronos.be> -+ * based on ip_conntrack_ftp.c and ip_conntrack_irc.c -+ * -+ * ip_conntrack_mms.c v0.3 2002-09-22 -+ * -+ * 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. -+ * -+ * Module load syntax: -+ * insmod ip_conntrack_mms.o ports=port1,port2,...port<MAX_PORTS> -+ * -+ * Please give the ports of all MMS servers You wish to connect to. -+ * If you don't specify ports, the default will be TCP port 1755. -+ * -+ * More info on MMS protocol, firewalls and NAT: -+ * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwmt/html/MMSFirewall.asp -+ * http://www.microsoft.com/windows/windowsmedia/serve/firewall.asp -+ * -+ * The SDP project people are reverse-engineering MMS: -+ * http://get.to/sdp -+ */ -+ -+#include <linux/config.h> -+#include <linux/module.h> -+#include <linux/netfilter.h> -+#include <linux/ip.h> -+#include <linux/ctype.h> -+#include <net/checksum.h> -+#include <net/tcp.h> -+ -+#include <linux/netfilter_ipv4/lockhelp.h> -+#include <linux/netfilter_ipv4/ip_conntrack_helper.h> -+#include <linux/netfilter_ipv4/ip_conntrack_mms.h> -+ -+DECLARE_LOCK(ip_mms_lock); -+struct module *ip_conntrack_mms = THIS_MODULE; -+ -+#define MAX_PORTS 8 -+static int ports[MAX_PORTS]; -+static int ports_c; -+#ifdef MODULE_PARM -+MODULE_PARM(ports, "1-" __MODULE_STRING(MAX_PORTS) "i"); -+#endif -+ -+#define DEBUGP(format, args...) -+ -+#ifdef CONFIG_IP_NF_NAT_NEEDED -+EXPORT_SYMBOL(ip_mms_lock); -+#endif -+ -+MODULE_AUTHOR("Filip Sneppe <filip.sneppe@cronos.be>"); -+MODULE_DESCRIPTION("Microsoft Windows Media Services (MMS) connection tracking module"); -+MODULE_LICENSE("GPL"); -+ -+/* #define isdigit(c) (c >= '0' && c <= '9') */ -+ -+/* copied from drivers/usb/serial/io_edgeport.c - not perfect but will do the trick */ -+static void unicode_to_ascii (char *string, short *unicode, int unicode_size) -+{ -+ int i; -+ for (i = 0; i < unicode_size; ++i) { -+ string[i] = (char)(unicode[i]); -+ } -+ string[unicode_size] = 0x00; -+} -+ -+__inline static int atoi(char *s) -+{ -+ int i=0; -+ while (isdigit(*s)) { -+ i = i*10 + *(s++) - '0'; -+ } -+ return i; -+} -+ -+/* convert ip address string like "192.168.0.10" to unsigned int */ -+__inline static u_int32_t asciiiptoi(char *s) -+{ -+ unsigned int i, j, k; -+ -+ for(i=k=0; k<3; ++k, ++s, i<<=8) { -+ i+=atoi(s); -+ for(j=0; (*(++s) != '.') && (j<3); ++j) -+ ; -+ } -+ i+=atoi(s); -+ return ntohl(i); -+} -+ -+int parse_mms(const char *data, -+ const unsigned int datalen, -+ u_int32_t *mms_ip, -+ u_int16_t *mms_proto, -+ u_int16_t *mms_port, -+ char **mms_string_b, -+ char **mms_string_e, -+ char **mms_padding_e) -+{ -+ int unicode_size, i; -+ char tempstring[28]; /* "\\255.255.255.255\UDP\65535" */ -+ char getlengthstring[28]; -+ -+ for(unicode_size=0; -+ (char) *(data+(MMS_SRV_UNICODE_STRING_OFFSET+unicode_size*2)) != (char)0; -+ unicode_size++) -+ if ((unicode_size == 28) || (MMS_SRV_UNICODE_STRING_OFFSET+unicode_size*2 >= datalen)) -+ return -1; /* out of bounds - incomplete packet */ -+ -+ unicode_to_ascii(tempstring, (short *)(data+MMS_SRV_UNICODE_STRING_OFFSET), unicode_size); -+ DEBUGP("ip_conntrack_mms: offset 60: %s\n", (const char *)(tempstring)); -+ -+ /* IP address ? */ -+ *mms_ip = asciiiptoi(tempstring+2); -+ -+ i=sprintf(getlengthstring, "%u.%u.%u.%u", HIPQUAD(*mms_ip)); -+ -+ /* protocol ? */ -+ if(strncmp(tempstring+3+i, "TCP", 3)==0) -+ *mms_proto = IPPROTO_TCP; -+ else if(strncmp(tempstring+3+i, "UDP", 3)==0) -+ *mms_proto = IPPROTO_UDP; -+ -+ /* port ? */ -+ *mms_port = atoi(tempstring+7+i); -+ -+ /* we store a pointer to the beginning of the "\\a.b.c.d\proto\port" -+ unicode string, one to the end of the string, and one to the end -+ of the packet, since we must keep track of the number of bytes -+ between end of the unicode string and the end of packet (padding) */ -+ *mms_string_b = (char *)(data + MMS_SRV_UNICODE_STRING_OFFSET); -+ *mms_string_e = (char *)(data + MMS_SRV_UNICODE_STRING_OFFSET + unicode_size * 2); -+ *mms_padding_e = (char *)(data + datalen); /* looks funny, doesn't it */ -+ return 0; -+} -+ -+ -+static int help(const struct iphdr *iph, size_t len, -+ struct ip_conntrack *ct, -+ enum ip_conntrack_info ctinfo) -+{ -+ /* tcplen not negative guaranteed by ip_conntrack_tcp.c */ -+ struct tcphdr *tcph = (void *)iph + iph->ihl * 4; -+ const char *data = (const char *)tcph + tcph->doff * 4; -+ unsigned int tcplen = len - iph->ihl * 4; -+ unsigned int datalen = tcplen - tcph->doff * 4; -+ int dir = CTINFO2DIR(ctinfo); -+ struct ip_conntrack_expect expect, *exp = &expect; -+ struct ip_ct_mms_expect *exp_mms_info = &exp->help.exp_mms_info; -+ -+ u_int32_t mms_ip; -+ u_int16_t mms_proto; -+ char mms_proto_string[8]; -+ u_int16_t mms_port; -+ char *mms_string_b, *mms_string_e, *mms_padding_e; -+ -+ /* Until there's been traffic both ways, don't look in packets. */ -+ if (ctinfo != IP_CT_ESTABLISHED -+ && ctinfo != IP_CT_ESTABLISHED+IP_CT_IS_REPLY) { -+ DEBUGP("ip_conntrack_mms: Conntrackinfo = %u\n", ctinfo); -+ return NF_ACCEPT; -+ } -+ -+ /* Not whole TCP header? */ -+ if (tcplen < sizeof(struct tcphdr) || tcplen < tcph->doff*4) { -+ DEBUGP("ip_conntrack_mms: tcplen = %u\n", (unsigned)tcplen); -+ return NF_ACCEPT; -+ } -+ -+ /* Checksum invalid? Ignore. */ -+ if (tcp_v4_check(tcph, tcplen, iph->saddr, iph->daddr, -+ csum_partial((char *)tcph, tcplen, 0))) { -+ DEBUGP("mms_help: bad csum: %p %u %u.%u.%u.%u %u.%u.%u.%u\n", -+ tcph, tcplen, NIPQUAD(iph->saddr), -+ NIPQUAD(iph->daddr)); -+ return NF_ACCEPT; -+ } -+ -+ /* Only look at packets with 0x00030002/196610 on bytes 36->39 of TCP payload */ -+ if( (MMS_SRV_MSG_OFFSET < datalen) && -+ ((*(u32 *)(data+MMS_SRV_MSG_OFFSET)) == MMS_SRV_MSG_ID)) { -+ DEBUGP("ip_conntrack_mms: offset 37: %u %u %u %u, datalen:%u\n", -+ (u8)*(data+36), (u8)*(data+37), -+ (u8)*(data+38), (u8)*(data+39), -+ datalen); -+ if(parse_mms(data, datalen, &mms_ip, &mms_proto, &mms_port, -+ &mms_string_b, &mms_string_e, &mms_padding_e)) -+ if(net_ratelimit()) -+ printk(KERN_WARNING -+ "ip_conntrack_mms: Unable to parse data payload\n"); -+ -+ memset(&expect, 0, sizeof(expect)); -+ -+ sprintf(mms_proto_string, "(%u)", mms_proto); -+ DEBUGP("ip_conntrack_mms: adding %s expectation %u.%u.%u.%u -> %u.%u.%u.%u:%u\n", -+ mms_proto == IPPROTO_TCP ? "TCP" -+ : mms_proto == IPPROTO_UDP ? "UDP":mms_proto_string, -+ NIPQUAD(ct->tuplehash[!dir].tuple.src.ip), -+ NIPQUAD(mms_ip), -+ mms_port); -+ -+ /* it's possible that the client will just ask the server to tunnel -+ the stream over the same TCP session (from port 1755): there's -+ shouldn't be a need to add an expectation in that case, but it -+ makes NAT packet mangling so much easier */ -+ LOCK_BH(&ip_mms_lock); -+ -+ DEBUGP("ip_conntrack_mms: tcph->seq = %u\n", tcph->seq); -+ -+ exp->seq = ntohl(tcph->seq) + (mms_string_b - data); -+ exp_mms_info->len = (mms_string_e - mms_string_b); -+ exp_mms_info->padding = (mms_padding_e - mms_string_e); -+ exp_mms_info->port = mms_port; -+ -+ DEBUGP("ip_conntrack_mms: wrote info seq=%u (ofs=%u), len=%d, padding=%u\n", -+ exp->seq, (mms_string_e - data), exp_mms_info->len, exp_mms_info->padding); -+ -+ exp->tuple = ((struct ip_conntrack_tuple) -+ { { ct->tuplehash[!dir].tuple.src.ip, { 0 } }, -+ { mms_ip, -+ { (__u16) ntohs(mms_port) }, -+ mms_proto } } -+ ); -+ exp->mask = ((struct ip_conntrack_tuple) -+ { { 0xFFFFFFFF, { 0 } }, -+ { 0xFFFFFFFF, { 0xFFFF }, 0xFFFF }}); -+ exp->expectfn = NULL; -+ ip_conntrack_expect_related(ct, &expect); -+ UNLOCK_BH(&ip_mms_lock); -+ } -+ -+ return NF_ACCEPT; -+} -+ -+static struct ip_conntrack_helper mms[MAX_PORTS]; -+static char mms_names[MAX_PORTS][10]; -+ -+/* Not __exit: called from init() */ -+static void fini(void) -+{ -+ int i; -+ for (i = 0; (i < MAX_PORTS) && ports[i]; i++) { -+ DEBUGP("ip_conntrack_mms: unregistering helper for port %d\n", -+ ports[i]); -+ ip_conntrack_helper_unregister(&mms[i]); -+ } -+} -+ -+static int __init init(void) -+{ -+ int i, ret; -+ char *tmpname; -+ -+ if (ports[0] == 0) -+ ports[0] = MMS_PORT; -+ -+ for (i = 0; (i < MAX_PORTS) && ports[i]; i++) { -+ memset(&mms[i], 0, sizeof(struct ip_conntrack_helper)); -+ mms[i].tuple.src.u.tcp.port = htons(ports[i]); -+ mms[i].tuple.dst.protonum = IPPROTO_TCP; -+ mms[i].mask.src.u.tcp.port = 0xFFFF; -+ mms[i].mask.dst.protonum = 0xFFFF; -+ mms[i].max_expected = 1; -+ mms[i].timeout = 0; -+ mms[i].flags = IP_CT_HELPER_F_REUSE_EXPECT; -+ mms[i].me = THIS_MODULE; -+ mms[i].help = help; -+ -+ tmpname = &mms_names[i][0]; -+ if (ports[i] == MMS_PORT) -+ sprintf(tmpname, "mms"); -+ else -+ sprintf(tmpname, "mms-%d", ports[i]); -+ mms[i].name = tmpname; -+ -+ DEBUGP("ip_conntrack_mms: registering helper for port %d\n", -+ ports[i]); -+ ret = ip_conntrack_helper_register(&mms[i]); -+ -+ if (ret) { -+ fini(); -+ return ret; -+ } -+ ports_c++; -+ } -+ return 0; -+} -+ -+module_init(init); -+module_exit(fini); ---- /dev/null -+++ b/net/ipv4/netfilter/ip_nat_mms.c -@@ -0,0 +1,330 @@ -+/* MMS extension for TCP NAT alteration. -+ * (C) 2002 by Filip Sneppe <filip.sneppe@cronos.be> -+ * based on ip_nat_ftp.c and ip_nat_irc.c -+ * -+ * ip_nat_mms.c v0.3 2002-09-22 -+ * -+ * 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. -+ * -+ * Module load syntax: -+ * insmod ip_nat_mms.o ports=port1,port2,...port<MAX_PORTS> -+ * -+ * Please give the ports of all MMS servers You wish to connect to. -+ * If you don't specify ports, the default will be TCP port 1755. -+ * -+ * More info on MMS protocol, firewalls and NAT: -+ * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwmt/html/MMSFirewall.asp -+ * http://www.microsoft.com/windows/windowsmedia/serve/firewall.asp -+ * -+ * The SDP project people are reverse-engineering MMS: -+ * http://get.to/sdp -+ */ -+ -+ -+#include <linux/module.h> -+#include <linux/netfilter_ipv4.h> -+#include <linux/ip.h> -+#include <linux/tcp.h> -+#include <net/tcp.h> -+#include <linux/netfilter_ipv4/ip_nat.h> -+#include <linux/netfilter_ipv4/ip_nat_helper.h> -+#include <linux/netfilter_ipv4/ip_nat_rule.h> -+#include <linux/netfilter_ipv4/ip_conntrack_mms.h> -+#include <linux/netfilter_ipv4/ip_conntrack_helper.h> -+ -+#define DEBUGP(format, args...) -+#define DUMP_BYTES(address, counter) -+ -+#define MAX_PORTS 8 -+static int ports[MAX_PORTS]; -+static int ports_c = 0; -+ -+#ifdef MODULE_PARM -+MODULE_PARM(ports, "1-" __MODULE_STRING(MAX_PORTS) "i"); -+#endif -+ -+MODULE_AUTHOR("Filip Sneppe <filip.sneppe@cronos.be>"); -+MODULE_DESCRIPTION("Microsoft Windows Media Services (MMS) NAT module"); -+MODULE_LICENSE("GPL"); -+ -+DECLARE_LOCK_EXTERN(ip_mms_lock); -+ -+ -+static int mms_data_fixup(const struct ip_ct_mms_expect *ct_mms_info, -+ struct ip_conntrack *ct, -+ struct sk_buff **pskb, -+ enum ip_conntrack_info ctinfo, -+ struct ip_conntrack_expect *expect) -+{ -+ u_int32_t newip; -+ struct ip_conntrack_tuple t; -+ struct iphdr *iph = (*pskb)->nh.iph; -+ struct tcphdr *tcph = (void *) iph + iph->ihl * 4; -+ char *data = (char *)tcph + tcph->doff * 4; -+ int i, j, k, port; -+ u_int16_t mms_proto; -+ -+ u_int32_t *mms_chunkLenLV = (u_int32_t *)(data + MMS_SRV_CHUNKLENLV_OFFSET); -+ u_int32_t *mms_chunkLenLM = (u_int32_t *)(data + MMS_SRV_CHUNKLENLM_OFFSET); -+ u_int32_t *mms_messageLength = (u_int32_t *)(data + MMS_SRV_MESSAGELENGTH_OFFSET); -+ -+ int zero_padding; -+ -+ char buffer[28]; /* "\\255.255.255.255\UDP\65635" * 2 (for unicode) */ -+ char unicode_buffer[75]; /* 27*2 (unicode) + 20 + 1 */ -+ char proto_string[6]; -+ -+ MUST_BE_LOCKED(&ip_mms_lock); -+ -+ /* what was the protocol again ? */ -+ mms_proto = expect->tuple.dst.protonum; -+ sprintf(proto_string, "%u", mms_proto); -+ -+ DEBUGP("ip_nat_mms: mms_data_fixup: info (seq %u + %u) in %u, proto %s\n", -+ expect->seq, ct_mms_info->len, ntohl(tcph->seq), -+ mms_proto == IPPROTO_UDP ? "UDP" -+ : mms_proto == IPPROTO_TCP ? "TCP":proto_string); -+ -+ newip = ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip; -+ -+ /* Alter conntrack's expectations. */ -+ t = expect->tuple; -+ t.dst.ip = newip; -+ for (port = ct_mms_info->port; port != 0; port++) { -+ t.dst.u.tcp.port = htons(port); -+ if (ip_conntrack_change_expect(expect, &t) == 0) { -+ DEBUGP("ip_nat_mms: mms_data_fixup: using port %d\n", port); -+ break; -+ } -+ } -+ -+ if(port == 0) -+ return 0; -+ -+ sprintf(buffer, "\\\\%u.%u.%u.%u\\%s\\%u", -+ NIPQUAD(newip), -+ expect->tuple.dst.protonum == IPPROTO_UDP ? "UDP" -+ : expect->tuple.dst.protonum == IPPROTO_TCP ? "TCP":proto_string, -+ port); -+ DEBUGP("ip_nat_mms: new unicode string=%s\n", buffer); -+ -+ memset(unicode_buffer, 0, sizeof(char)*75); -+ -+ for (i=0; i<strlen(buffer); ++i) -+ *(unicode_buffer+i*2)=*(buffer+i); -+ -+ DEBUGP("ip_nat_mms: mms_data_fixup: padding: %u len: %u\n", ct_mms_info->padding, ct_mms_info->len); -+ DEBUGP("ip_nat_mms: mms_data_fixup: offset: %u\n", MMS_SRV_UNICODE_STRING_OFFSET+ct_mms_info->len); -+ DUMP_BYTES(data+MMS_SRV_UNICODE_STRING_OFFSET, 60); -+ -+ /* add end of packet to it */ -+ for (j=0; j<ct_mms_info->padding; ++j) { -+ DEBUGP("ip_nat_mms: mms_data_fixup: i=%u j=%u byte=%u\n", -+ i, j, (u8)*(data+MMS_SRV_UNICODE_STRING_OFFSET+ct_mms_info->len+j)); -+ *(unicode_buffer+i*2+j) = *(data+MMS_SRV_UNICODE_STRING_OFFSET+ct_mms_info->len+j); -+ } -+ -+ /* pad with zeroes at the end ? see explanation of weird math below */ -+ zero_padding = (8-(strlen(buffer)*2 + ct_mms_info->padding + 4)%8)%8; -+ for (k=0; k<zero_padding; ++k) -+ *(unicode_buffer+i*2+j+k)= (char)0; -+ -+ DEBUGP("ip_nat_mms: mms_data_fixup: zero_padding = %u\n", zero_padding); -+ DEBUGP("ip_nat_mms: original=> chunkLenLV=%u chunkLenLM=%u messageLength=%u\n", -+ *mms_chunkLenLV, *mms_chunkLenLM, *mms_messageLength); -+ -+ /* explanation, before I forget what I did: -+ strlen(buffer)*2 + ct_mms_info->padding + 4 must be divisable by 8; -+ divide by 8 and add 3 to compute the mms_chunkLenLM field, -+ but note that things may have to be padded with zeroes to align by 8 -+ bytes, hence we add 7 and divide by 8 to get the correct length */ -+ *mms_chunkLenLM = (u_int32_t) (3+(strlen(buffer)*2+ct_mms_info->padding+11)/8); -+ *mms_chunkLenLV = *mms_chunkLenLM+2; -+ *mms_messageLength = *mms_chunkLenLV*8; -+ -+ DEBUGP("ip_nat_mms: modified=> chunkLenLV=%u chunkLenLM=%u messageLength=%u\n", -+ *mms_chunkLenLV, *mms_chunkLenLM, *mms_messageLength); -+ -+ ip_nat_mangle_tcp_packet(pskb, ct, ctinfo, -+ expect->seq - ntohl(tcph->seq), -+ ct_mms_info->len + ct_mms_info->padding, unicode_buffer, -+ strlen(buffer)*2 + ct_mms_info->padding + zero_padding); -+ DUMP_BYTES(unicode_buffer, 60); -+ -+ return 1; -+} -+ -+static unsigned int -+mms_nat_expected(struct sk_buff **pskb, -+ unsigned int hooknum, -+ struct ip_conntrack *ct, -+ struct ip_nat_info *info) -+{ -+ struct ip_nat_multi_range mr; -+ u_int32_t newdstip, newsrcip, newip; -+ -+ struct ip_conntrack *master = master_ct(ct); -+ -+ IP_NF_ASSERT(info); -+ IP_NF_ASSERT(master); -+ -+ IP_NF_ASSERT(!(info->initialized & (1 << HOOK2MANIP(hooknum)))); -+ -+ DEBUGP("ip_nat_mms: mms_nat_expected: We have a connection!\n"); -+ -+ newdstip = master->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip; -+ newsrcip = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip; -+ DEBUGP("ip_nat_mms: mms_nat_expected: hook %s: newsrc->newdst %u.%u.%u.%u->%u.%u.%u.%u\n", -+ hooknum == NF_IP_POST_ROUTING ? "POSTROUTING" -+ : hooknum == NF_IP_PRE_ROUTING ? "PREROUTING" -+ : hooknum == NF_IP_LOCAL_OUT ? "OUTPUT" : "???", -+ NIPQUAD(newsrcip), NIPQUAD(newdstip)); -+ -+ if (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC) -+ newip = newsrcip; -+ else -+ newip = newdstip; -+ -+ DEBUGP("ip_nat_mms: mms_nat_expected: IP to %u.%u.%u.%u\n", NIPQUAD(newip)); -+ -+ mr.rangesize = 1; -+ /* We don't want to manip the per-protocol, just the IPs. */ -+ mr.range[0].flags = IP_NAT_RANGE_MAP_IPS; -+ mr.range[0].min_ip = mr.range[0].max_ip = newip; -+ -+ return ip_nat_setup_info(ct, &mr, hooknum); -+} -+ -+ -+static unsigned int mms_nat_help(struct ip_conntrack *ct, -+ struct ip_conntrack_expect *exp, -+ struct ip_nat_info *info, -+ enum ip_conntrack_info ctinfo, -+ unsigned int hooknum, -+ struct sk_buff **pskb) -+{ -+ struct iphdr *iph = (*pskb)->nh.iph; -+ struct tcphdr *tcph = (void *) iph + iph->ihl * 4; -+ unsigned int datalen; -+ int dir; -+ struct ip_ct_mms_expect *ct_mms_info; -+ -+ if (!exp) -+ DEBUGP("ip_nat_mms: no exp!!"); -+ -+ ct_mms_info = &exp->help.exp_mms_info; -+ -+ /* Only mangle things once: original direction in POST_ROUTING -+ and reply direction on PRE_ROUTING. */ -+ dir = CTINFO2DIR(ctinfo); -+ if (!((hooknum == NF_IP_POST_ROUTING && dir == IP_CT_DIR_ORIGINAL) -+ ||(hooknum == NF_IP_PRE_ROUTING && dir == IP_CT_DIR_REPLY))) { -+ DEBUGP("ip_nat_mms: mms_nat_help: not touching dir %s at hook %s\n", -+ dir == IP_CT_DIR_ORIGINAL ? "ORIG" : "REPLY", -+ hooknum == NF_IP_POST_ROUTING ? "POSTROUTING" -+ : hooknum == NF_IP_PRE_ROUTING ? "PREROUTING" -+ : hooknum == NF_IP_LOCAL_OUT ? "OUTPUT" : "???"); -+ return NF_ACCEPT; -+ } -+ DEBUGP("ip_nat_mms: mms_nat_help: beyond not touching (dir %s at hook %s)\n", -+ dir == IP_CT_DIR_ORIGINAL ? "ORIG" : "REPLY", -+ hooknum == NF_IP_POST_ROUTING ? "POSTROUTING" -+ : hooknum == NF_IP_PRE_ROUTING ? "PREROUTING" -+ : hooknum == NF_IP_LOCAL_OUT ? "OUTPUT" : "???"); -+ -+ datalen = (*pskb)->len - iph->ihl * 4 - tcph->doff * 4; -+ -+ DEBUGP("ip_nat_mms: mms_nat_help: %u+%u=%u %u %u\n", exp->seq, ct_mms_info->len, -+ exp->seq + ct_mms_info->len, -+ ntohl(tcph->seq), -+ ntohl(tcph->seq) + datalen); -+ -+ LOCK_BH(&ip_mms_lock); -+ /* Check wether the whole IP/proto/port pattern is carried in the payload */ -+ if (between(exp->seq + ct_mms_info->len, -+ ntohl(tcph->seq), -+ ntohl(tcph->seq) + datalen)) { -+ if (!mms_data_fixup(ct_mms_info, ct, pskb, ctinfo, exp)) { -+ UNLOCK_BH(&ip_mms_lock); -+ return NF_DROP; -+ } -+ } else { -+ /* Half a match? This means a partial retransmisison. -+ It's a cracker being funky. */ -+ if (net_ratelimit()) { -+ printk("ip_nat_mms: partial packet %u/%u in %u/%u\n", -+ exp->seq, ct_mms_info->len, -+ ntohl(tcph->seq), -+ ntohl(tcph->seq) + datalen); -+ } -+ UNLOCK_BH(&ip_mms_lock); -+ return NF_DROP; -+ } -+ UNLOCK_BH(&ip_mms_lock); -+ -+ return NF_ACCEPT; -+} -+ -+static struct ip_nat_helper mms[MAX_PORTS]; -+static char mms_names[MAX_PORTS][10]; -+ -+/* Not __exit: called from init() */ -+static void fini(void) -+{ -+ int i; -+ -+ for (i = 0; (i < MAX_PORTS) && ports[i]; i++) { -+ DEBUGP("ip_nat_mms: unregistering helper for port %d\n", ports[i]); -+ ip_nat_helper_unregister(&mms[i]); -+ } -+} -+ -+static int __init init(void) -+{ -+ int i, ret = 0; -+ char *tmpname; -+ -+ if (ports[0] == 0) -+ ports[0] = MMS_PORT; -+ -+ for (i = 0; (i < MAX_PORTS) && ports[i]; i++) { -+ -+ memset(&mms[i], 0, sizeof(struct ip_nat_helper)); -+ -+ mms[i].tuple.dst.protonum = IPPROTO_TCP; -+ mms[i].tuple.src.u.tcp.port = htons(ports[i]); -+ mms[i].mask.dst.protonum = 0xFFFF; -+ mms[i].mask.src.u.tcp.port = 0xFFFF; -+ mms[i].help = mms_nat_help; -+ mms[i].me = THIS_MODULE; -+ mms[i].flags = 0; -+ mms[i].expect = mms_nat_expected; -+ -+ tmpname = &mms_names[i][0]; -+ if (ports[i] == MMS_PORT) -+ sprintf(tmpname, "mms"); -+ else -+ sprintf(tmpname, "mms-%d", i); -+ mms[i].name = tmpname; -+ -+ DEBUGP("ip_nat_mms: register helper for port %d\n", -+ ports[i]); -+ ret = ip_nat_helper_register(&mms[i]); -+ -+ if (ret) { -+ printk("ip_nat_mms: error registering " -+ "helper for port %d\n", ports[i]); -+ fini(); -+ return ret; -+ } -+ ports_c++; -+ } -+ -+ return ret; -+} -+ -+module_init(init); -+module_exit(fini); ---- a/include/linux/netfilter_ipv4/ip_conntrack.h -+++ b/include/linux/netfilter_ipv4/ip_conntrack.h -@@ -69,6 +69,7 @@ union ip_conntrack_expect_proto { - #include <linux/netfilter_ipv4/ip_conntrack_irc.h> - #include <linux/netfilter_ipv4/ip_conntrack_h323.h> - #include <linux/netfilter_ipv4/ip_conntrack_rtsp.h> -+#include <linux/netfilter_ipv4/ip_conntrack_mms.h> - - /* per expectation: application helper private data */ - union ip_conntrack_expect_help { -@@ -78,6 +79,7 @@ union ip_conntrack_expect_help { - struct ip_ct_irc_expect exp_irc_info; - struct ip_ct_h225_expect exp_h225_info; - struct ip_ct_rtsp_expect exp_rtsp_info; -+ struct ip_ct_mms_expect exp_mms_info; - - #ifdef CONFIG_IP_NF_NAT_NEEDED - union { -@@ -93,6 +95,7 @@ union ip_conntrack_help { - struct ip_ct_irc_master ct_irc_info; - struct ip_ct_h225_master ct_h225_info; - struct ip_ct_rtsp_master ct_rtsp_info; -+ struct ip_ct_mms_master ct_mms_info; - }; - - #ifdef CONFIG_IP_NF_NAT_NEEDED ---- /dev/null -+++ b/include/linux/netfilter_ipv4/ip_conntrack_mms.h -@@ -0,0 +1,31 @@ -+#ifndef _IP_CONNTRACK_MMS_H -+#define _IP_CONNTRACK_MMS_H -+/* MMS tracking. */ -+ -+#ifdef __KERNEL__ -+#include <linux/netfilter_ipv4/lockhelp.h> -+ -+DECLARE_LOCK_EXTERN(ip_mms_lock); -+ -+#define MMS_PORT 1755 -+#define MMS_SRV_MSG_ID 196610 -+ -+#define MMS_SRV_MSG_OFFSET 36 -+#define MMS_SRV_UNICODE_STRING_OFFSET 60 -+#define MMS_SRV_CHUNKLENLV_OFFSET 16 -+#define MMS_SRV_CHUNKLENLM_OFFSET 32 -+#define MMS_SRV_MESSAGELENGTH_OFFSET 8 -+#endif -+ -+/* This structure is per expected connection */ -+struct ip_ct_mms_expect { -+ u_int32_t len; -+ u_int32_t padding; -+ u_int16_t port; -+}; -+ -+/* This structure exists only once per master */ -+struct ip_ct_mms_master { -+}; -+ -+#endif /* _IP_CONNTRACK_MMS_H */ diff --git a/target/linux/generic-2.4/patches/616-netfilter_imq.patch b/target/linux/generic-2.4/patches/616-netfilter_imq.patch deleted file mode 100644 index a7e6479..0000000 --- a/target/linux/generic-2.4/patches/616-netfilter_imq.patch +++ /dev/null @@ -1,732 +0,0 @@ ---- a/Documentation/Configure.help -+++ b/Documentation/Configure.help -@@ -3160,6 +3160,22 @@ CONFIG_IP_NF_TARGET_TOS - If you want to compile it as a module, say M here and read - <file:Documentation/modules.txt>. If unsure, say `N'. - -+IMQ target support -+CONFIG_IP_NF_TARGET_IMQ -+ This option adds a `IMQ' target which is used to specify if and -+ to which imq device packets should get enqueued/dequeued. -+ -+ If you want to compile it as a module, say M here and read -+ <file:Documentation/modules.txt>. If unsure, say `N'. -+ -+IMQ target support -+CONFIG_IP6_NF_TARGET_IMQ -+ This option adds a `IMQ' target which is used to specify if and -+ to which imq device packets should get enqueued/dequeued. -+ -+ If you want to compile it as a module, say M here and read -+ <file:Documentation/modules.txt>. If unsure, say `N'. -+ - MARK target support - CONFIG_IP_NF_TARGET_MARK - This option adds a `MARK' target, which allows you to create rules -@@ -9862,6 +9878,20 @@ CONFIG_BONDING - say M here and read <file:Documentation/modules.txt>. The module - will be called bonding.o. - -+Intermediate queueing device support -+CONFIG_IMQ -+ The imq device(s) is used as placeholder for QoS queueing disciplines. -+ Every packet entering/leaving the ip stack can be directed through -+ the imq device where it's enqueued/dequeued to the attached qdisc. -+ This allows you to treat network devices as classes and distribute -+ bandwidth among them. Iptables is used to specify through which imq -+ device, if any, packets travel. -+ -+ If you want to compile this as a module ( = code which ca be -+ inserted in and removed from the running kernel whenever you want), -+ say M here and read <file:Documentation/modules.txt>. The module -+ will be called imq.o -+ - SLIP (serial line) support - CONFIG_SLIP - Say Y if you intend to use SLIP or CSLIP (compressed SLIP) to ---- a/drivers/net/Config.in -+++ b/drivers/net/Config.in -@@ -7,6 +7,11 @@ source drivers/net/arcnet/Config.in - tristate 'Dummy net driver support' CONFIG_DUMMY - tristate 'Bonding driver support' CONFIG_BONDING - tristate 'EQL (serial line load balancing) support' CONFIG_EQUALIZER -+if [ "$CONFIG_NETFILTER" = "y" ]; then -+ tristate 'IMQ (intermediate queueing device) support' CONFIG_IMQ -+else -+ comment 'IMQ needs CONFIG_NETFILTER enabled' -+fi - tristate 'Universal TUN/TAP device driver support' CONFIG_TUN - bool 'Allow Net Devices to contribute to /dev/random' CONFIG_NET_RANDOM - if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then ---- a/drivers/net/Makefile -+++ b/drivers/net/Makefile -@@ -176,6 +176,7 @@ endif - - obj-$(CONFIG_STRIP) += strip.o - obj-$(CONFIG_DUMMY) += dummy.o -+obj-$(CONFIG_IMQ) += imq.o - obj-$(CONFIG_DE600) += de600.o - obj-$(CONFIG_DE620) += de620.o - obj-$(CONFIG_AT1500) += lance.o ---- /dev/null -+++ b/drivers/net/imq.c -@@ -0,0 +1,321 @@ -+/* -+ * Pseudo-driver for the intermediate queue device. -+ * -+ * 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. -+ * -+ * Authors: Patrick McHardy, <kaber@trash.net> -+ * -+ * The first version was written by Martin Devera, <devik@cdi.cz> -+ * -+ * Credits: Jan Rafaj <imq2t@cedric.vabo.cz> -+ * - Update patch to 2.4.21 -+ * Sebastian Strollo <sstrollo@nortelnetworks.com> -+ * - Fix "Dead-loop on netdevice imq"-issue -+ */ -+ -+#include <linux/kernel.h> -+#include <linux/module.h> -+#include <linux/config.h> -+#include <linux/skbuff.h> -+#include <linux/netdevice.h> -+#include <linux/rtnetlink.h> -+#include <linux/if_arp.h> -+#include <linux/netfilter.h> -+#include <linux/netfilter_ipv4.h> -+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) -+#include <linux/netfilter_ipv6.h> -+#endif -+#include <linux/imq.h> -+#include <net/pkt_sched.h> -+ -+static nf_hookfn imq_nf_hook; -+ -+static struct nf_hook_ops imq_ingress_ipv4 = { -+ { NULL, NULL}, -+ imq_nf_hook, -+ PF_INET, -+ NF_IP_PRE_ROUTING, -+ NF_IP_PRI_MANGLE + 1 -+}; -+ -+static struct nf_hook_ops imq_egress_ipv4 = { -+ { NULL, NULL}, -+ imq_nf_hook, -+ PF_INET, -+ NF_IP_POST_ROUTING, -+ NF_IP_PRI_LAST -+}; -+ -+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) -+static struct nf_hook_ops imq_ingress_ipv6 = { -+ { NULL, NULL}, -+ imq_nf_hook, -+ PF_INET6, -+ NF_IP6_PRE_ROUTING, -+ NF_IP6_PRI_MANGLE + 1 -+}; -+ -+static struct nf_hook_ops imq_egress_ipv6 = { -+ { NULL, NULL}, -+ imq_nf_hook, -+ PF_INET6, -+ NF_IP6_POST_ROUTING, -+ NF_IP6_PRI_LAST -+}; -+#endif -+ -+static unsigned int numdevs = 2; -+ -+MODULE_PARM(numdevs, "i"); -+MODULE_PARM_DESC(numdevs, "number of imq devices"); -+ -+static struct net_device *imq_devs; -+ -+ -+static struct net_device_stats *imq_get_stats(struct net_device *dev) -+{ -+ return (struct net_device_stats *)dev->priv; -+} -+ -+/* called for packets kfree'd in qdiscs at places other than enqueue */ -+static void imq_skb_destructor(struct sk_buff *skb) -+{ -+ struct nf_info *info = skb->nf_info; -+ -+ if (info) { -+ if (info->indev) -+ dev_put(info->indev); -+ if (info->outdev) -+ dev_put(info->outdev); -+ kfree(info); -+ } -+} -+ -+static int imq_dev_xmit(struct sk_buff *skb, struct net_device *dev) -+{ -+ struct net_device_stats *stats = (struct net_device_stats*) dev->priv; -+ -+ stats->tx_bytes += skb->len; -+ stats->tx_packets++; -+ -+ skb->imq_flags = 0; -+ skb->destructor = NULL; -+ -+ dev->trans_start = jiffies; -+ nf_reinject(skb, skb->nf_info, NF_ACCEPT); -+ return 0; -+} -+ -+static int imq_nf_queue(struct sk_buff *skb, struct nf_info *info, -+ void *data) -+{ -+ struct net_device *dev; -+ struct net_device_stats *stats; -+ struct sk_buff *skb2 = NULL; -+ struct Qdisc *q; -+ unsigned int index = skb->imq_flags&IMQ_F_IFMASK; -+ int ret = -1; -+ -+ if (index > numdevs) -+ return -1; -+ -+ dev = imq_devs + index; -+ if (!(dev->flags & IFF_UP)) { -+ skb->imq_flags = 0; -+ nf_reinject(skb, info, NF_ACCEPT); -+ return 0; -+ } -+ dev->last_rx = jiffies; -+ -+ if (skb->destructor) { -+ skb2 = skb; -+ skb = skb_clone(skb, GFP_ATOMIC); -+ if (!skb) -+ return -1; -+ } -+ skb->nf_info = info; -+ -+ stats = (struct net_device_stats *)dev->priv; -+ stats->rx_bytes+= skb->len; -+ stats->rx_packets++; -+ -+ spin_lock_bh(&dev->queue_lock); -+ q = dev->qdisc; -+ if (q->enqueue) { -+ q->enqueue(skb_get(skb), q); -+ if (skb_shared(skb)) { -+ skb->destructor = imq_skb_destructor; -+ kfree_skb(skb); -+ ret = 0; -+ } -+ } -+ if (spin_is_locked(&dev->xmit_lock)) -+ netif_schedule(dev); -+ else -+ qdisc_run(dev); -+ spin_unlock_bh(&dev->queue_lock); -+ -+ if (skb2) -+ kfree_skb(ret ? skb : skb2); -+ -+ return ret; -+} -+ -+static unsigned int imq_nf_hook(unsigned int hook, struct sk_buff **pskb, -+ const struct net_device *indev, -+ const struct net_device *outdev, -+ int (*okfn)(struct sk_buff *)) -+{ -+ if ((*pskb)->imq_flags & IMQ_F_ENQUEUE) -+ return NF_QUEUE; -+ -+ return NF_ACCEPT; -+} -+ -+ -+static int __init imq_init_hooks(void) -+{ -+ int err; -+ -+ if ((err = nf_register_queue_handler(PF_INET, imq_nf_queue, NULL))) -+ goto err1; -+ if ((err = nf_register_hook(&imq_ingress_ipv4))) -+ goto err2; -+ if ((err = nf_register_hook(&imq_egress_ipv4))) -+ goto err3; -+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) -+ if ((err = nf_register_queue_handler(PF_INET6, imq_nf_queue, NULL))) -+ goto err4; -+ if ((err = nf_register_hook(&imq_ingress_ipv6))) -+ goto err5; -+ if ((err = nf_register_hook(&imq_egress_ipv6))) -+ goto err6; -+#endif -+ -+ return 0; -+ -+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) -+err6: -+ nf_unregister_hook(&imq_ingress_ipv6); -+err5: -+ nf_unregister_queue_handler(PF_INET6); -+err4: -+ nf_unregister_hook(&imq_egress_ipv4); -+#endif -+err3: -+ nf_unregister_hook(&imq_ingress_ipv4); -+err2: -+ nf_unregister_queue_handler(PF_INET); -+err1: -+ return err; -+} -+ -+static void __exit imq_unhook(void) -+{ -+ nf_unregister_hook(&imq_ingress_ipv4); -+ nf_unregister_hook(&imq_egress_ipv4); -+ nf_unregister_queue_handler(PF_INET); -+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) -+ nf_unregister_hook(&imq_ingress_ipv6); -+ nf_unregister_hook(&imq_egress_ipv6); -+ nf_unregister_queue_handler(PF_INET6); -+#endif -+} -+ -+static int __init imq_dev_init(struct net_device *dev) -+{ -+ dev->hard_start_xmit = imq_dev_xmit; -+ dev->type = ARPHRD_VOID; -+ dev->mtu = 1500; -+ dev->tx_queue_len = 30; -+ dev->flags = IFF_NOARP; -+ dev->priv = kmalloc(sizeof(struct net_device_stats), GFP_KERNEL); -+ if (dev->priv == NULL) -+ return -ENOMEM; -+ memset(dev->priv, 0, sizeof(struct net_device_stats)); -+ dev->get_stats = imq_get_stats; -+ -+ return 0; -+} -+ -+static void imq_dev_uninit(struct net_device *dev) -+{ -+ kfree(dev->priv); -+} -+ -+static int __init imq_init_devs(void) -+{ -+ struct net_device *dev; -+ int i; -+ -+ if (!numdevs || numdevs > IMQ_MAX_DEVS) { -+ printk(KERN_ERR "numdevs has to be betweed 1 and %u\n", -+ IMQ_MAX_DEVS); -+ return -EINVAL; -+ } -+ -+ imq_devs = kmalloc(sizeof(struct net_device) * numdevs, GFP_KERNEL); -+ if (!imq_devs) -+ return -ENOMEM; -+ memset(imq_devs, 0, sizeof(struct net_device) * numdevs); -+ -+ /* we start counting at zero */ -+ numdevs--; -+ -+ for (i = 0, dev = imq_devs; i <= numdevs; i++, dev++) { -+ SET_MODULE_OWNER(dev); -+ strcpy(dev->name, "imq%d"); -+ dev->init = imq_dev_init; -+ dev->uninit = imq_dev_uninit; -+ -+ if (register_netdev(dev) < 0) -+ goto err_register; -+ } -+ return 0; -+ -+err_register: -+ for (; i; i--) -+ unregister_netdev(--dev); -+ kfree(imq_devs); -+ return -EIO; -+} -+ -+static void imq_cleanup_devs(void) -+{ -+ int i; -+ struct net_device *dev = imq_devs; -+ -+ for (i = 0; i <= numdevs; i++) -+ unregister_netdev(dev++); -+ -+ kfree(imq_devs); -+} -+ -+static int __init imq_init_module(void) -+{ -+ int err; -+ -+ if ((err = imq_init_devs())) -+ return err; -+ if ((err = imq_init_hooks())) { -+ imq_cleanup_devs(); -+ return err; -+ } -+ -+ printk(KERN_INFO "imq driver loaded.\n"); -+ -+ return 0; -+} -+ -+static void __exit imq_cleanup_module(void) -+{ -+ imq_unhook(); -+ imq_cleanup_devs(); -+} -+ -+module_init(imq_init_module); -+module_exit(imq_cleanup_module); -+MODULE_LICENSE("GPL"); ---- /dev/null -+++ b/include/linux/imq.h -@@ -0,0 +1,9 @@ -+#ifndef _IMQ_H -+#define _IMQ_H -+ -+#define IMQ_MAX_DEVS 16 -+ -+#define IMQ_F_IFMASK 0x7f -+#define IMQ_F_ENQUEUE 0x80 -+ -+#endif /* _IMQ_H */ ---- /dev/null -+++ b/include/linux/netfilter_ipv4/ipt_IMQ.h -@@ -0,0 +1,8 @@ -+#ifndef _IPT_IMQ_H -+#define _IPT_IMQ_H -+ -+struct ipt_imq_info { -+ unsigned int todev; /* target imq device */ -+}; -+ -+#endif /* _IPT_IMQ_H */ ---- /dev/null -+++ b/include/linux/netfilter_ipv6/ip6t_IMQ.h -@@ -0,0 +1,8 @@ -+#ifndef _IP6T_IMQ_H -+#define _IP6T_IMQ_H -+ -+struct ip6t_imq_info { -+ unsigned int todev; /* target imq device */ -+}; -+ -+#endif /* _IP6T_IMQ_H */ ---- a/include/linux/skbuff.h -+++ b/include/linux/skbuff.h -@@ -93,6 +93,9 @@ struct nf_ct_info { - struct nf_conntrack *master; - }; - #endif -+#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE) -+struct nf_info; -+#endif - - struct sk_buff_head { - /* These two members must be first. */ -@@ -182,7 +185,7 @@ struct sk_buff { - unsigned int len; /* Length of actual data */ - unsigned int data_len; - unsigned int csum; /* Checksum */ -- unsigned char __unused, /* Dead field, may be reused */ -+ unsigned char imq_flags, /* intermediate queueing device */ - cloned, /* head may be cloned (check refcnt to be sure). */ - pkt_type, /* Packet class */ - ip_summed; /* Driver fed us an IP checksum */ -@@ -219,6 +222,9 @@ struct sk_buff { - #ifdef CONFIG_NET_SCHED - __u32 tc_index; /* traffic control index */ - #endif -+#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE) -+ struct nf_info *nf_info; -+#endif - }; - - #ifdef __KERNEL__ ---- a/net/core/skbuff.c -+++ b/net/core/skbuff.c -@@ -202,6 +202,10 @@ struct sk_buff *alloc_skb(unsigned int s - /* Set up other state */ - skb->len = 0; - skb->cloned = 0; -+#if defined(CONFIG_IMQ) || defined (CONFIG_IMQ_MODULE) -+ skb->imq_flags = 0; -+ skb->nf_info = NULL; -+#endif - skb->data_len = 0; - - atomic_set(&skb->users, 1); -@@ -250,6 +254,10 @@ static inline void skb_headerinit(void * - #ifdef CONFIG_NET_SCHED - skb->tc_index = 0; - #endif -+#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE) -+ skb->imq_flags = 0; -+ skb->nf_info = NULL; -+#endif - } - - static void skb_drop_fraglist(struct sk_buff *skb) -@@ -400,6 +408,10 @@ struct sk_buff *skb_clone(struct sk_buff - #ifdef CONFIG_NET_SCHED - C(tc_index); - #endif -+#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE) -+ C(imq_flags); -+ C(nf_info); -+#endif - - atomic_inc(&(skb_shinfo(skb)->dataref)); - skb->cloned = 1; -@@ -444,6 +456,10 @@ static void copy_skb_header(struct sk_bu - #ifdef CONFIG_NET_SCHED - new->tc_index = old->tc_index; - #endif -+#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE) -+ new->imq_flags=old->imq_flags; -+ new->nf_info=old->nf_info; -+#endif - } - - /** ---- a/net/ipv4/netfilter/Config.in -+++ b/net/ipv4/netfilter/Config.in -@@ -141,6 +141,7 @@ if [ "$CONFIG_IP_NF_IPTABLES" != "n" ]; - dep_tristate ' DSCP target support' CONFIG_IP_NF_TARGET_DSCP $CONFIG_IP_NF_MANGLE - - dep_tristate ' MARK target support' CONFIG_IP_NF_TARGET_MARK $CONFIG_IP_NF_MANGLE -+ dep_tristate ' IMQ target support' CONFIG_IP_NF_TARGET_IMQ $CONFIG_IP_NF_MANGLE - dep_tristate ' CLASSIFY target support (EXPERIMENTAL)' CONFIG_IP_NF_TARGET_CLASSIFY $CONFIG_IP_NF_MANGLE - fi - if [ "$CONFIG_IP_NF_CONNTRACK_MARK" != "n" ]; then ---- a/net/ipv4/netfilter/Makefile -+++ b/net/ipv4/netfilter/Makefile -@@ -118,6 +118,7 @@ obj-$(CONFIG_IP_NF_TARGET_TOS) += ipt_TO - obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o - obj-$(CONFIG_IP_NF_TARGET_DSCP) += ipt_DSCP.o - obj-$(CONFIG_IP_NF_TARGET_MARK) += ipt_MARK.o -+obj-$(CONFIG_IP_NF_TARGET_IMQ) += ipt_IMQ.o - obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o - obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o - obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o ---- /dev/null -+++ b/net/ipv4/netfilter/ipt_IMQ.c -@@ -0,0 +1,78 @@ -+/* This target marks packets to be enqueued to an imq device */ -+#include <linux/module.h> -+#include <linux/skbuff.h> -+#include <linux/netfilter_ipv4/ip_tables.h> -+#include <linux/netfilter_ipv4/ipt_IMQ.h> -+#include <linux/imq.h> -+ -+static unsigned int imq_target(struct sk_buff **pskb, -+ unsigned int hooknum, -+ const struct net_device *in, -+ const struct net_device *out, -+ const void *targinfo, -+ void *userinfo) -+{ -+ struct ipt_imq_info *mr = (struct ipt_imq_info*)targinfo; -+ -+ (*pskb)->imq_flags = mr->todev | IMQ_F_ENQUEUE; -+ (*pskb)->nfcache |= NFC_ALTERED; -+ -+ return IPT_CONTINUE; -+} -+ -+static int imq_checkentry(const char *tablename, -+ const struct ipt_entry *e, -+ void *targinfo, -+ unsigned int targinfosize, -+ unsigned int hook_mask) -+{ -+ struct ipt_imq_info *mr; -+ -+ if (targinfosize != IPT_ALIGN(sizeof(struct ipt_imq_info))) { -+ printk(KERN_WARNING "IMQ: invalid targinfosize\n"); -+ return 0; -+ } -+ mr = (struct ipt_imq_info*)targinfo; -+ -+ if (strcmp(tablename, "mangle") != 0) { -+ printk(KERN_WARNING -+ "IMQ: IMQ can only be called from \"mangle\" table, not \"%s\"\n", -+ tablename); -+ return 0; -+ } -+ -+ if (mr->todev > IMQ_MAX_DEVS) { -+ printk(KERN_WARNING -+ "IMQ: invalid device specified, highest is %u\n", -+ IMQ_MAX_DEVS); -+ return 0; -+ } -+ -+ return 1; -+} -+ -+static struct ipt_target ipt_imq_reg = { -+ { NULL, NULL}, -+ "IMQ", -+ imq_target, -+ imq_checkentry, -+ NULL, -+ THIS_MODULE -+}; -+ -+static int __init init(void) -+{ -+ if (ipt_register_target(&ipt_imq_reg)) -+ return -EINVAL; -+ -+ return 0; -+} -+ -+static void __exit fini(void) -+{ -+ ipt_unregister_target(&ipt_imq_reg); -+} -+ -+module_init(init); -+module_exit(fini); -+MODULE_LICENSE("GPL"); ---- a/net/ipv6/netfilter/Config.in -+++ b/net/ipv6/netfilter/Config.in -@@ -72,6 +72,7 @@ if [ "$CONFIG_IP6_NF_IPTABLES" != "n" ]; - if [ "$CONFIG_IP6_NF_MANGLE" != "n" ]; then - # dep_tristate ' TOS target support' CONFIG_IP6_NF_TARGET_TOS $CONFIG_IP_NF_MANGLE - dep_tristate ' MARK target support' CONFIG_IP6_NF_TARGET_MARK $CONFIG_IP6_NF_MANGLE -+ dep_tristate ' IMQ target support' CONFIG_IP6_NF_TARGET_IMQ $CONFIG_IP6_NF_MANGLE - fi - #dep_tristate ' LOG target support' CONFIG_IP6_NF_TARGET_LOG $CONFIG_IP6_NF_IPTABLES - fi ---- a/net/ipv6/netfilter/Makefile -+++ b/net/ipv6/netfilter/Makefile -@@ -29,6 +29,7 @@ obj-$(CONFIG_IP6_NF_MATCH_OWNER) += ip6t - obj-$(CONFIG_IP6_NF_FILTER) += ip6table_filter.o - obj-$(CONFIG_IP6_NF_MANGLE) += ip6table_mangle.o - obj-$(CONFIG_IP6_NF_TARGET_MARK) += ip6t_MARK.o -+obj-$(CONFIG_IP6_NF_TARGET_IMQ) += ip6t_IMQ.o - obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue.o - obj-$(CONFIG_IP6_NF_TARGET_LOG) += ip6t_LOG.o - obj-$(CONFIG_IP6_NF_MATCH_HL) += ip6t_hl.o ---- /dev/null -+++ b/net/ipv6/netfilter/ip6t_IMQ.c -@@ -0,0 +1,78 @@ -+/* This target marks packets to be enqueued to an imq device */ -+#include <linux/module.h> -+#include <linux/skbuff.h> -+#include <linux/netfilter_ipv6/ip6_tables.h> -+#include <linux/netfilter_ipv6/ip6t_IMQ.h> -+#include <linux/imq.h> -+ -+static unsigned int imq_target(struct sk_buff **pskb, -+ unsigned int hooknum, -+ const struct net_device *in, -+ const struct net_device *out, -+ const void *targinfo, -+ void *userinfo) -+{ -+ struct ip6t_imq_info *mr = (struct ip6t_imq_info*)targinfo; -+ -+ (*pskb)->imq_flags = mr->todev | IMQ_F_ENQUEUE; -+ (*pskb)->nfcache |= NFC_ALTERED; -+ -+ return IP6T_CONTINUE; -+} -+ -+static int imq_checkentry(const char *tablename, -+ const struct ip6t_entry *e, -+ void *targinfo, -+ unsigned int targinfosize, -+ unsigned int hook_mask) -+{ -+ struct ip6t_imq_info *mr; -+ -+ if (targinfosize != IP6T_ALIGN(sizeof(struct ip6t_imq_info))) { -+ printk(KERN_WARNING "IMQ: invalid targinfosize\n"); -+ return 0; -+ } -+ mr = (struct ip6t_imq_info*)targinfo; -+ -+ if (strcmp(tablename, "mangle") != 0) { -+ printk(KERN_WARNING -+ "IMQ: IMQ can only be called from \"mangle\" table, not \"%s\"\n", -+ tablename); -+ return 0; -+ } -+ -+ if (mr->todev > IMQ_MAX_DEVS) { -+ printk(KERN_WARNING -+ "IMQ: invalid device specified, highest is %u\n", -+ IMQ_MAX_DEVS); -+ return 0; -+ } -+ -+ return 1; -+} -+ -+static struct ip6t_target ip6t_imq_reg = { -+ { NULL, NULL}, -+ "IMQ", -+ imq_target, -+ imq_checkentry, -+ NULL, -+ THIS_MODULE -+}; -+ -+static int __init init(void) -+{ -+ if (ip6t_register_target(&ip6t_imq_reg)) -+ return -EINVAL; -+ -+ return 0; -+} -+ -+static void __exit fini(void) -+{ -+ ip6t_unregister_target(&ip6t_imq_reg); -+} -+ -+module_init(init); -+module_exit(fini); -+MODULE_LICENSE("GPL"); ---- a/net/sched/sch_generic.c -+++ b/net/sched/sch_generic.c -@@ -29,6 +29,9 @@ - #include <linux/skbuff.h> - #include <linux/rtnetlink.h> - #include <linux/init.h> -+#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE) -+#include <linux/imq.h> -+#endif - #include <linux/list.h> - #include <net/sock.h> - #include <net/pkt_sched.h> -@@ -90,7 +93,11 @@ int qdisc_restart(struct net_device *dev - spin_unlock(&dev->queue_lock); - - if (!netif_queue_stopped(dev)) { -- if (netdev_nit) -+ if (netdev_nit -+#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE) -+ && !(skb->imq_flags & IMQ_F_ENQUEUE) -+#endif -+ ) - dev_queue_xmit_nit(skb, dev); - - if (dev->hard_start_xmit(skb, dev) == 0) { diff --git a/target/linux/generic-2.4/patches/618-netfilter_multiport_backport.patch b/target/linux/generic-2.4/patches/618-netfilter_multiport_backport.patch deleted file mode 100644 index cc1d898..0000000 --- a/target/linux/generic-2.4/patches/618-netfilter_multiport_backport.patch +++ /dev/null @@ -1,229 +0,0 @@ ---- a/include/linux/netfilter_ipv4/ipt_multiport.h -+++ b/include/linux/netfilter_ipv4/ipt_multiport.h -@@ -11,11 +11,12 @@ enum ipt_multiport_flags - - #define IPT_MULTI_PORTS 15 - --/* Must fit inside union ipt_matchinfo: 16 bytes */ --struct ipt_multiport -+struct ipt_multiport_v1 - { - u_int8_t flags; /* Type of comparison */ - u_int8_t count; /* Number of ports */ - u_int16_t ports[IPT_MULTI_PORTS]; /* Ports */ -+ u_int8_t pflags[IPT_MULTI_PORTS]; /* Port flags */ -+ u_int8_t invert; /* Invert flag */ - }; - #endif /*_IPT_MULTIPORT_H*/ ---- a/net/ipv4/netfilter/ipt_multiport.c -+++ b/net/ipv4/netfilter/ipt_multiport.c -@@ -1,5 +1,14 @@ - /* Kernel module to match one of a list of TCP/UDP ports: ports are in - the same place so we can treat them as equal. */ -+ -+/* (C) 1999-2001 Paul `Rusty' Russell -+ * (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org> -+ * -+ * 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/types.h> - #include <linux/udp.h> -@@ -8,97 +17,136 @@ - #include <linux/netfilter_ipv4/ipt_multiport.h> - #include <linux/netfilter_ipv4/ip_tables.h> - -+MODULE_LICENSE("GPL"); -+MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>"); -+MODULE_DESCRIPTION("iptables multiple port match module"); -+ - #if 0 - #define duprintf(format, args...) printk(format , ## args) - #else - #define duprintf(format, args...) - #endif - -+/* from linux 2.6 skbuff.h */ -+static inline void *skb_header_pointer(const struct sk_buff *skb, int offset, -+ int len, void *buffer) -+{ -+ int hlen = skb_headlen(skb); -+ -+ if (hlen - offset >= len) -+ return skb->data + offset; -+ -+ if (skb_copy_bits(skb, offset, buffer, len) < 0) -+ return NULL; -+ -+ return buffer; -+} -+ -+ - /* Returns 1 if the port is matched by the test, 0 otherwise. */ - static inline int --ports_match(const u_int16_t *portlist, enum ipt_multiport_flags flags, -- u_int8_t count, u_int16_t src, u_int16_t dst) -+ports_match_v1(const struct ipt_multiport_v1 *minfo, -+ u_int16_t src, u_int16_t dst) - { - unsigned int i; -- for (i=0; i<count; i++) { -- if (flags != IPT_MULTIPORT_DESTINATION -- && portlist[i] == src) -- return 1; -- -- if (flags != IPT_MULTIPORT_SOURCE -- && portlist[i] == dst) -- return 1; -- } -+ u_int16_t s, e; - -- return 0; -+ for (i=0; i < minfo->count; i++) { -+ s = minfo->ports[i]; -+ -+ if (minfo->pflags[i]) { -+ /* range port matching */ -+ e = minfo->ports[++i]; -+ duprintf("src or dst matches with %d-%d?\n", s, e); -+ -+ if (minfo->flags == IPT_MULTIPORT_SOURCE -+ && src >= s && src <= e) -+ return 1 ^ minfo->invert; -+ if (minfo->flags == IPT_MULTIPORT_DESTINATION -+ && dst >= s && dst <= e) -+ return 1 ^ minfo->invert; -+ if (minfo->flags == IPT_MULTIPORT_EITHER -+ && ((dst >= s && dst <= e) -+ || (src >= s && src <= e))) -+ return 1 ^ minfo->invert; -+ } else { -+ /* exact port matching */ -+ duprintf("src or dst matches with %d?\n", s); -+ -+ if (minfo->flags == IPT_MULTIPORT_SOURCE -+ && src == s) -+ return 1 ^ minfo->invert; -+ if (minfo->flags == IPT_MULTIPORT_DESTINATION -+ && dst == s) -+ return 1 ^ minfo->invert; -+ if (minfo->flags == IPT_MULTIPORT_EITHER -+ && (src == s || dst == s)) -+ return 1 ^ minfo->invert; -+ } -+ } -+ -+ return minfo->invert; - } - - static int --match(const struct sk_buff *skb, -- const struct net_device *in, -- const struct net_device *out, -- const void *matchinfo, -- int offset, -- const void *hdr, -- u_int16_t datalen, -- int *hotdrop) -+match_v1(const struct sk_buff *skb, -+ const struct net_device *in, -+ const struct net_device *out, -+ const void *matchinfo, -+ int offset, -+ int *hotdrop) - { -- const struct udphdr *udp = hdr; -- const struct ipt_multiport *multiinfo = matchinfo; -+ u16 _ports[2], *pptr; -+ const struct ipt_multiport_v1 *multiinfo = matchinfo; -+ -+ if (offset) -+ return 0; - -- /* Must be big enough to read ports. */ -- if (offset == 0 && datalen < sizeof(struct udphdr)) { -+ pptr = skb_header_pointer(skb, skb->nh.iph->ihl * 4, -+ sizeof(_ports), _ports); -+ if (pptr == NULL) { - /* We've been asked to examine this packet, and we -- can't. Hence, no choice but to drop. */ -- duprintf("ipt_multiport:" -- " Dropping evil offset=0 tinygram.\n"); -- *hotdrop = 1; -- return 0; -+ * can't. Hence, no choice but to drop. -+ */ -+ duprintf("ipt_multiport:" -+ " Dropping evil offset=0 tinygram.\n"); -+ *hotdrop = 1; -+ return 0; - } - -- /* Must not be a fragment. */ -- return !offset -- && ports_match(multiinfo->ports, -- multiinfo->flags, multiinfo->count, -- ntohs(udp->source), ntohs(udp->dest)); -+ return ports_match_v1(multiinfo, ntohs(pptr[0]), ntohs(pptr[1])); - } - --/* Called when user tries to insert an entry of this type. */ - static int --checkentry(const char *tablename, -- const struct ipt_ip *ip, -- void *matchinfo, -- unsigned int matchsize, -- unsigned int hook_mask) -+checkentry_v1(const char *tablename, -+ const struct ipt_ip *ip, -+ void *matchinfo, -+ unsigned int matchsize, -+ unsigned int hook_mask) - { -- const struct ipt_multiport *multiinfo = matchinfo; -- -- if (matchsize != IPT_ALIGN(sizeof(struct ipt_multiport))) -- return 0; -- -- /* Must specify proto == TCP/UDP, no unknown flags or bad count */ -- return (ip->proto == IPPROTO_TCP || ip->proto == IPPROTO_UDP) -- && !(ip->invflags & IPT_INV_PROTO) -- && matchsize == IPT_ALIGN(sizeof(struct ipt_multiport)) -- && (multiinfo->flags == IPT_MULTIPORT_SOURCE -- || multiinfo->flags == IPT_MULTIPORT_DESTINATION -- || multiinfo->flags == IPT_MULTIPORT_EITHER) -- && multiinfo->count <= IPT_MULTI_PORTS; -+ return (matchsize == IPT_ALIGN(sizeof(struct ipt_multiport_v1))); - } - --static struct ipt_match multiport_match --= { { NULL, NULL }, "multiport", &match, &checkentry, NULL, THIS_MODULE }; -+static struct ipt_match multiport_match_v1 = { -+ .name = "multiport", -+ .match = &match_v1, -+ .checkentry = &checkentry_v1, -+ .me = THIS_MODULE, -+}; - - static int __init init(void) - { -- return ipt_register_match(&multiport_match); -+ int err; -+ -+ err = ipt_register_match(&multiport_match_v1); -+ -+ return err; - } - - static void __exit fini(void) - { -- ipt_unregister_match(&multiport_match); -+ ipt_unregister_match(&multiport_match_v1); - } - - module_init(init); - module_exit(fini); --MODULE_LICENSE("GPL"); diff --git a/target/linux/generic-2.4/patches/620-netfilter_iprange.patch b/target/linux/generic-2.4/patches/620-netfilter_iprange.patch deleted file mode 100644 index 5024197..0000000 --- a/target/linux/generic-2.4/patches/620-netfilter_iprange.patch +++ /dev/null @@ -1,167 +0,0 @@ ---- a/Documentation/Configure.help -+++ b/Documentation/Configure.help -@@ -2986,6 +2986,14 @@ CONFIG_IP_NF_MATCH_TOS - If you want to compile it as a module, say M here and read - <file:Documentation/modules.txt>. If unsure, say `N'. - -+iprange match support -+CONFIG_IP_NF_MATCH_IPRANGE -+ This option makes possible to match IP addresses against -+ IP address ranges. -+ -+ If you want to compile it as a module, say M here and read -+ <file:Documentation/modules.txt>. If unsure, say `N'. -+ - Condition variable match support - CONFIG_IP_NF_MATCH_CONDITION - This option allows you to match firewall rules against condition ---- /dev/null -+++ b/include/linux/netfilter_ipv4/ipt_iprange.h -@@ -0,0 +1,23 @@ -+#ifndef _IPT_IPRANGE_H -+#define _IPT_IPRANGE_H -+ -+#define IPRANGE_SRC 0x01 /* Match source IP address */ -+#define IPRANGE_DST 0x02 /* Match destination IP address */ -+#define IPRANGE_SRC_INV 0x10 /* Negate the condition */ -+#define IPRANGE_DST_INV 0x20 /* Negate the condition */ -+ -+struct ipt_iprange { -+ /* Inclusive: network order. */ -+ u_int32_t min_ip, max_ip; -+}; -+ -+struct ipt_iprange_info -+{ -+ struct ipt_iprange src; -+ struct ipt_iprange dst; -+ -+ /* Flags from above */ -+ u_int8_t flags; -+}; -+ -+#endif /* _IPT_IPRANGE_H */ ---- a/net/ipv4/netfilter/Config.in -+++ b/net/ipv4/netfilter/Config.in -@@ -25,6 +25,7 @@ tristate 'IP tables support (required fo - if [ "$CONFIG_IP_NF_IPTABLES" != "n" ]; then - # The simple matches. - dep_tristate ' limit match support' CONFIG_IP_NF_MATCH_LIMIT $CONFIG_IP_NF_IPTABLES -+ dep_tristate ' IP range match support' CONFIG_IP_NF_MATCH_IPRANGE $CONFIG_IP_NF_IPTABLES - dep_tristate ' quota match support' CONFIG_IP_NF_MATCH_QUOTA $CONFIG_IP_NF_IPTABLES - dep_tristate ' MAC address match support' CONFIG_IP_NF_MATCH_MAC $CONFIG_IP_NF_IPTABLES - dep_tristate ' Packet type match support' CONFIG_IP_NF_MATCH_PKTTYPE $CONFIG_IP_NF_IPTABLES ---- /dev/null -+++ b/net/ipv4/netfilter/ipt_iprange.c -@@ -0,0 +1,101 @@ -+/* -+ * iptables module to match IP address ranges -+ * (c) 2003 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> -+ * -+ * Released under the terms of GNU GPLv2. -+ * -+ */ -+#include <linux/module.h> -+#include <linux/skbuff.h> -+#include <linux/ip.h> -+#include <linux/netfilter_ipv4/ip_tables.h> -+#include <linux/netfilter_ipv4/ipt_iprange.h> -+ -+MODULE_LICENSE("GPL"); -+MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>"); -+MODULE_DESCRIPTION("iptables arbitrary IP range match module"); -+ -+#if 0 -+#define DEBUGP printk -+#else -+#define DEBUGP(format, args...) -+#endif -+ -+static int -+match(const struct sk_buff *skb, -+ const struct net_device *in, -+ const struct net_device *out, -+ const void *matchinfo, -+ int offset, -+ const void *hdr, -+ u_int16_t datalen, -+ int *hotdrop) -+{ -+ const struct ipt_iprange_info *info = matchinfo; -+ const struct iphdr *iph = skb->nh.iph; -+ -+ -+ if (info->flags & IPRANGE_SRC) { -+ if (((ntohl(iph->saddr) < ntohl(info->src.min_ip)) -+ || (ntohl(iph->saddr) > ntohl(info->src.max_ip))) -+ ^ !!(info->flags & IPRANGE_SRC_INV)) { -+ DEBUGP("src IP %u.%u.%u.%u NOT in range %s" -+ "%u.%u.%u.%u-%u.%u.%u.%u\n", -+ NIPQUAD(iph->saddr), -+ info->flags & IPRANGE_SRC_INV ? "(INV) " : "", -+ NIPQUAD(info->src.min_ip), -+ NIPQUAD(info->src.max_ip)); -+ return 0; -+ } -+ } -+ if (info->flags & IPRANGE_DST) { -+ if (((ntohl(iph->daddr) < ntohl(info->dst.min_ip)) -+ || (ntohl(iph->daddr) > ntohl(info->dst.max_ip))) -+ ^ !!(info->flags & IPRANGE_DST_INV)) { -+ DEBUGP("dst IP %u.%u.%u.%u NOT in range %s" -+ "%u.%u.%u.%u-%u.%u.%u.%u\n", -+ NIPQUAD(iph->daddr), -+ info->flags & IPRANGE_DST_INV ? "(INV) " : "", -+ NIPQUAD(info->dst.min_ip), -+ NIPQUAD(info->dst.max_ip)); -+ return 0; -+ } -+ } -+ return 1; -+} -+ -+static int check(const char *tablename, -+ const struct ipt_ip *ip, -+ void *matchinfo, -+ unsigned int matchsize, -+ unsigned int hook_mask) -+{ -+ /* verify size */ -+ if (matchsize != IPT_ALIGN(sizeof(struct ipt_iprange_info))) -+ return 0; -+ -+ return 1; -+} -+ -+static struct ipt_match iprange_match = -+{ -+ .list = { NULL, NULL }, -+ .name = "iprange", -+ .match = &match, -+ .checkentry = &check, -+ .destroy = NULL, -+ .me = THIS_MODULE -+}; -+ -+static int __init init(void) -+{ -+ return ipt_register_match(&iprange_match); -+} -+ -+static void __exit fini(void) -+{ -+ ipt_unregister_match(&iprange_match); -+} -+ -+module_init(init); -+module_exit(fini); ---- a/net/ipv4/netfilter/Makefile -+++ b/net/ipv4/netfilter/Makefile -@@ -81,6 +81,7 @@ obj-$(CONFIG_IP_NF_NAT) += iptable_nat.o - # matches - obj-$(CONFIG_IP_NF_MATCH_HELPER) += ipt_helper.o - obj-$(CONFIG_IP_NF_MATCH_LIMIT) += ipt_limit.o -+obj-$(CONFIG_IP_NF_MATCH_IPRANGE) += ipt_iprange.o - obj-$(CONFIG_IP_NF_MATCH_QUOTA) += ipt_quota.o - obj-$(CONFIG_IP_NF_MATCH_MARK) += ipt_mark.o - obj-$(CONFIG_IP_NF_MATCH_MAC) += ipt_mac.o diff --git a/target/linux/generic-2.4/patches/621-netfilter_random.patch b/target/linux/generic-2.4/patches/621-netfilter_random.patch deleted file mode 100644 index fbc648b..0000000 --- a/target/linux/generic-2.4/patches/621-netfilter_random.patch +++ /dev/null @@ -1,309 +0,0 @@ ---- a/Documentation/Configure.help -+++ b/Documentation/Configure.help -@@ -2914,6 +2914,15 @@ CONFIG_IP_NF_MATCH_MAC - If you want to compile it as a module, say M here and read - <file:Documentation/modules.txt>. If unsure, say `N'. - -+Random match support -+CONFIG_IP_NF_MATCH_RANDOM -+ This option adds a `random' match, -+ which allow you to match packets randomly -+ following a given probability. -+ -+ If you want to compile it as a module, say M here and read -+ Documentation/modules.txt. If unsure, say `N'. -+ - Netfilter MARK match support - CONFIG_IP_NF_MATCH_MARK - Netfilter mark matching allows you to match packets based on the -@@ -3229,6 +3238,7 @@ CONFIG_IP_NF_MATCH_HELPER - If you want to compile it as a module, say M here and read - Documentation/modules.txt. If unsure, say `Y'. - -+ - TCPMSS match support - CONFIG_IP_NF_MATCH_TCPMSS - This option adds a `tcpmss' match, which allows you to examine the -@@ -3318,6 +3328,14 @@ CONFIG_IP6_NF_MATCH_MAC - If you want to compile it as a module, say M here and read - <file:Documentation/modules.txt>. If unsure, say `N'. - -+CONFIG_IP6_NF_MATCH_RANDOM -+ This option adds a `random' match, -+ which allow you to match packets randomly -+ following a given probability. -+ -+ If you want to compile it as a module, say M here and read -+ Documentation/modules.txt. If unsure, say `N'. -+ - length match support - CONFIG_IP6_NF_MATCH_LENGTH - This option allows you to match the length of a packet against a ---- /dev/null -+++ b/include/linux/netfilter_ipv4/ipt_random.h -@@ -0,0 +1,11 @@ -+#ifndef _IPT_RAND_H -+#define _IPT_RAND_H -+ -+#include <linux/param.h> -+#include <linux/types.h> -+ -+struct ipt_rand_info { -+ u_int8_t average; -+}; -+ -+#endif /*_IPT_RAND_H*/ ---- /dev/null -+++ b/include/linux/netfilter_ipv6/ip6t_random.h -@@ -0,0 +1,11 @@ -+#ifndef _IP6T_RAND_H -+#define _IP6T_RAND_H -+ -+#include <linux/param.h> -+#include <linux/types.h> -+ -+struct ip6t_rand_info { -+ u_int8_t average; -+}; -+ -+#endif /*_IP6T_RAND_H*/ ---- a/net/ipv4/netfilter/Config.in -+++ b/net/ipv4/netfilter/Config.in -@@ -32,6 +32,7 @@ if [ "$CONFIG_IP_NF_IPTABLES" != "n" ]; - dep_tristate ' netfilter MARK match support' CONFIG_IP_NF_MATCH_MARK $CONFIG_IP_NF_IPTABLES - dep_tristate ' Multiple port match support' CONFIG_IP_NF_MATCH_MULTIPORT $CONFIG_IP_NF_IPTABLES - dep_tristate ' TOS match support' CONFIG_IP_NF_MATCH_TOS $CONFIG_IP_NF_IPTABLES -+ dep_tristate ' random match support' CONFIG_IP_NF_MATCH_RANDOM $CONFIG_IP_NF_IPTABLES - dep_tristate ' condition match support' CONFIG_IP_NF_MATCH_CONDITION $CONFIG_IP_NF_IPTABLES - dep_tristate ' recent match support' CONFIG_IP_NF_MATCH_RECENT $CONFIG_IP_NF_IPTABLES - dep_tristate ' ECN match support' CONFIG_IP_NF_MATCH_ECN $CONFIG_IP_NF_IPTABLES ---- /dev/null -+++ b/net/ipv4/netfilter/ipt_random.c -@@ -0,0 +1,96 @@ -+/* -+ This is a module which is used for a "random" match support. -+ This file is distributed under the terms of the GNU General Public -+ License (GPL). Copies of the GPL can be obtained from: -+ ftp://prep.ai.mit.edu/pub/gnu/GPL -+ -+ 2001-10-14 Fabrice MARIE <fabrice@netfilter.org> : initial implementation. -+*/ -+ -+#include <linux/module.h> -+#include <linux/skbuff.h> -+#include <linux/ip.h> -+#include <linux/random.h> -+#include <net/tcp.h> -+#include <linux/spinlock.h> -+#include <linux/netfilter_ipv4/ip_tables.h> -+#include <linux/netfilter_ipv4/ipt_random.h> -+ -+MODULE_LICENSE("GPL"); -+ -+static int -+ipt_rand_match(const struct sk_buff *pskb, -+ const struct net_device *in, -+ const struct net_device *out, -+ const void *matchinfo, -+ int offset, -+ const void *hdr, -+ u_int16_t datalen, -+ int *hotdrop) -+{ -+ /* Parameters from userspace */ -+ const struct ipt_rand_info *info = matchinfo; -+ u_int8_t random_number; -+ -+ /* get 1 random number from the kernel random number generation routine */ -+ get_random_bytes((void *)(&random_number), 1); -+ -+ /* Do we match ? */ -+ if (random_number <= info->average) -+ return 1; -+ else -+ return 0; -+} -+ -+static int -+ipt_rand_checkentry(const char *tablename, -+ const struct ipt_ip *e, -+ void *matchinfo, -+ unsigned int matchsize, -+ unsigned int hook_mask) -+{ -+ /* Parameters from userspace */ -+ const struct ipt_rand_info *info = matchinfo; -+ -+ if (matchsize != IPT_ALIGN(sizeof(struct ipt_rand_info))) { -+ printk("ipt_random: matchsize %u != %u\n", matchsize, -+ IPT_ALIGN(sizeof(struct ipt_rand_info))); -+ return 0; -+ } -+ -+ /* must be 1 <= average % <= 99 */ -+ /* 1 x 2.55 = 2 */ -+ /* 99 x 2.55 = 252 */ -+ if ((info->average < 2) || (info->average > 252)) { -+ printk("ipt_random: invalid average %u\n", info->average); -+ return 0; -+ } -+ -+ return 1; -+} -+ -+static struct ipt_match ipt_rand_reg = { -+ {NULL, NULL}, -+ "random", -+ ipt_rand_match, -+ ipt_rand_checkentry, -+ NULL, -+ THIS_MODULE }; -+ -+static int __init init(void) -+{ -+ if (ipt_register_match(&ipt_rand_reg)) -+ return -EINVAL; -+ -+ printk("ipt_random match loaded\n"); -+ return 0; -+} -+ -+static void __exit fini(void) -+{ -+ ipt_unregister_match(&ipt_rand_reg); -+ printk("ipt_random match unloaded\n"); -+} -+ -+module_init(init); -+module_exit(fini); ---- a/net/ipv4/netfilter/Makefile -+++ b/net/ipv4/netfilter/Makefile -@@ -93,6 +93,8 @@ obj-$(CONFIG_IP_NF_MATCH_OWNER) += ipt_o - obj-$(CONFIG_IP_NF_MATCH_TOS) += ipt_tos.o - obj-$(CONFIG_IP_NF_MATCH_CONDITION) += ipt_condition.o - -+obj-$(CONFIG_IP_NF_MATCH_RANDOM) += ipt_random.o -+ - obj-$(CONFIG_IP_NF_MATCH_RECENT) += ipt_recent.o - - obj-$(CONFIG_IP_NF_MATCH_ECN) += ipt_ecn.o ---- a/net/ipv6/netfilter/Config.in -+++ b/net/ipv6/netfilter/Config.in -@@ -19,6 +19,7 @@ if [ "$CONFIG_IP6_NF_IPTABLES" != "n" ]; - dep_tristate ' limit match support' CONFIG_IP6_NF_MATCH_LIMIT $CONFIG_IP6_NF_IPTABLES - dep_tristate ' condition match support' CONFIG_IP6_NF_MATCH_CONDITION $CONFIG_IP6_NF_IPTABLES - dep_tristate ' MAC address match support' CONFIG_IP6_NF_MATCH_MAC $CONFIG_IP6_NF_IPTABLES -+ dep_tristate ' Random match support' CONFIG_IP6_NF_MATCH_RANDOM $CONFIG_IP6_NF_IPTABLES - if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then - dep_tristate ' Routing header match support (EXPERIMENTAL)' CONFIG_IP6_NF_MATCH_RT $CONFIG_IP6_NF_IPTABLES - fi ---- /dev/null -+++ b/net/ipv6/netfilter/ip6t_random.c -@@ -0,0 +1,97 @@ -+/* -+ This is a module which is used for a "random" match support. -+ This file is distributed under the terms of the GNU General Public -+ License (GPL). Copies of the GPL can be obtained from: -+ ftp://prep.ai.mit.edu/pub/gnu/GPL -+ -+ 2001-10-14 Fabrice MARIE <fabrice@netfilter.org> : initial implementation. -+ 2003-04-30 Maciej Soltysiak <solt@dns.toxicfilms.tv> : IPv6 Port -+*/ -+ -+#include <linux/module.h> -+#include <linux/skbuff.h> -+#include <linux/ip.h> -+#include <linux/random.h> -+#include <net/tcp.h> -+#include <linux/spinlock.h> -+#include <linux/netfilter_ipv6/ip6_tables.h> -+#include <linux/netfilter_ipv6/ip6t_random.h> -+ -+MODULE_LICENSE("GPL"); -+ -+static int -+ip6t_rand_match(const struct sk_buff *pskb, -+ const struct net_device *in, -+ const struct net_device *out, -+ const void *matchinfo, -+ int offset, -+ const void *hdr, -+ u_int16_t datalen, -+ int *hotdrop) -+{ -+ /* Parameters from userspace */ -+ const struct ip6t_rand_info *info = matchinfo; -+ u_int8_t random_number; -+ -+ /* get 1 random number from the kernel random number generation routine */ -+ get_random_bytes((void *)(&random_number), 1); -+ -+ /* Do we match ? */ -+ if (random_number <= info->average) -+ return 1; -+ else -+ return 0; -+} -+ -+static int -+ip6t_rand_checkentry(const char *tablename, -+ const struct ip6t_ip6 *e, -+ void *matchinfo, -+ unsigned int matchsize, -+ unsigned int hook_mask) -+{ -+ /* Parameters from userspace */ -+ const struct ip6t_rand_info *info = matchinfo; -+ -+ if (matchsize != IP6T_ALIGN(sizeof(struct ip6t_rand_info))) { -+ printk("ip6t_random: matchsize %u != %u\n", matchsize, -+ IP6T_ALIGN(sizeof(struct ip6t_rand_info))); -+ return 0; -+ } -+ -+ /* must be 1 <= average % <= 99 */ -+ /* 1 x 2.55 = 2 */ -+ /* 99 x 2.55 = 252 */ -+ if ((info->average < 2) || (info->average > 252)) { -+ printk("ip6t_random: invalid average %u\n", info->average); -+ return 0; -+ } -+ -+ return 1; -+} -+ -+static struct ip6t_match ip6t_rand_reg = { -+ {NULL, NULL}, -+ "random", -+ ip6t_rand_match, -+ ip6t_rand_checkentry, -+ NULL, -+ THIS_MODULE }; -+ -+static int __init init(void) -+{ -+ if (ip6t_register_match(&ip6t_rand_reg)) -+ return -EINVAL; -+ -+ printk("ip6t_random match loaded\n"); -+ return 0; -+} -+ -+static void __exit fini(void) -+{ -+ ip6t_unregister_match(&ip6t_rand_reg); -+ printk("ip6t_random match unloaded\n"); -+} -+ -+module_init(init); -+module_exit(fini); ---- a/net/ipv6/netfilter/Makefile -+++ b/net/ipv6/netfilter/Makefile -@@ -32,6 +32,7 @@ obj-$(CONFIG_IP6_NF_TARGET_MARK) += ip6t - obj-$(CONFIG_IP6_NF_TARGET_IMQ) += ip6t_IMQ.o - obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue.o - obj-$(CONFIG_IP6_NF_TARGET_LOG) += ip6t_LOG.o -+obj-$(CONFIG_IP6_NF_MATCH_RANDOM) += ip6t_random.o - obj-$(CONFIG_IP6_NF_MATCH_HL) += ip6t_hl.o - - include $(TOPDIR)/Rules.make diff --git a/target/linux/generic-2.4/patches/622-tc_esfq.patch b/target/linux/generic-2.4/patches/622-tc_esfq.patch deleted file mode 100644 index 5b54cfd..0000000 --- a/target/linux/generic-2.4/patches/622-tc_esfq.patch +++ /dev/null @@ -1,738 +0,0 @@ ---- a/Documentation/Configure.help -+++ b/Documentation/Configure.help -@@ -11096,6 +11096,24 @@ CONFIG_NET_SCH_HFSC - whenever you want). If you want to compile it as a module, say M - here and read <file:Documentation/modules.txt>. - -+ESFQ queue -+CONFIG_NET_SCH_ESFQ -+ Say Y here if you want to use the Stochastic Fairness Queueing (SFQ) -+ packet scheduling algorithm for some of your network devices or as a -+ leaf discipline for the CBQ scheduling algorithm (see the top of -+ <file:net/sched/sch_esfq.c> for details and references about the SFQ -+ algorithm). -+ -+ This is an enchanced SFQ version which allows you to control the -+ hardcoded values in the SFQ scheduler: queue depth, hash table size, -+ queues limit. Also adds control to the hash function used to identify -+ packet flows. Hash by src or dst ip and original sfq hash. -+ -+ This code is also available as a module called sch_esfq.o ( = code -+ which can be inserted in and removed from the running kernel -+ whenever you want). If you want to compile it as a module, say M -+ here and read <file:Documentation/modules.txt>. -+ - CSZ packet scheduler - CONFIG_NET_SCH_CSZ - Say Y here if you want to use the Clark-Shenker-Zhang (CSZ) packet ---- a/include/linux/pkt_sched.h -+++ b/include/linux/pkt_sched.h -@@ -173,8 +173,36 @@ struct tc_sfq_qopt - * - * The only reason for this is efficiency, it is possible - * to change these parameters in compile time. -+ * -+ * If you need to play with these values use esfq instead. - */ - -+/* ESFQ section */ -+ -+enum -+{ -+ /* traditional */ -+ TCA_SFQ_HASH_CLASSIC, -+ TCA_SFQ_HASH_DST, -+ TCA_SFQ_HASH_SRC, -+ /* conntrack */ -+ TCA_SFQ_HASH_CTORIGDST, -+ TCA_SFQ_HASH_CTORIGSRC, -+ TCA_SFQ_HASH_CTREPLDST, -+ TCA_SFQ_HASH_CTREPLSRC, -+ TCA_SFQ_HASH_CTNATCHG, -+}; -+ -+struct tc_esfq_qopt -+{ -+ unsigned quantum; /* Bytes per round allocated to flow */ -+ int perturb_period; /* Period of hash perturbation */ -+ __u32 limit; /* Maximal packets in queue */ -+ unsigned divisor; /* Hash divisor */ -+ unsigned flows; /* Maximal number of flows */ -+ unsigned hash_kind; /* Hash function to use for flow identification */ -+}; -+ - /* RED section */ - - enum ---- a/net/sched/Config.in -+++ b/net/sched/Config.in -@@ -12,6 +12,7 @@ fi - tristate ' The simplest PRIO pseudoscheduler' CONFIG_NET_SCH_PRIO - tristate ' RED queue' CONFIG_NET_SCH_RED - tristate ' SFQ queue' CONFIG_NET_SCH_SFQ -+tristate ' ESFQ queue' CONFIG_NET_SCH_ESFQ - tristate ' TEQL queue' CONFIG_NET_SCH_TEQL - tristate ' TBF queue' CONFIG_NET_SCH_TBF - tristate ' GRED queue' CONFIG_NET_SCH_GRED ---- a/net/sched/Makefile -+++ b/net/sched/Makefile -@@ -19,6 +19,7 @@ obj-$(CONFIG_NET_SCH_HPFQ) += sch_hpfq.o - obj-$(CONFIG_NET_SCH_HFSC) += sch_hfsc.o - obj-$(CONFIG_NET_SCH_HTB) += sch_htb.o - obj-$(CONFIG_NET_SCH_SFQ) += sch_sfq.o -+obj-$(CONFIG_NET_SCH_ESFQ) += sch_esfq.o - obj-$(CONFIG_NET_SCH_RED) += sch_red.o - obj-$(CONFIG_NET_SCH_TBF) += sch_tbf.o - obj-$(CONFIG_NET_SCH_PRIO) += sch_prio.o ---- /dev/null -+++ b/net/sched/sch_esfq.c -@@ -0,0 +1,649 @@ -+/* -+ * net/sched/sch_esfq.c Extended Stochastic Fairness Queueing discipline. -+ * -+ * 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. -+ * -+ * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> -+ * -+ * Changes: Alexander Atanasov, <alex@ssi.bg> -+ * Added dynamic depth,limit,divisor,hash_kind options. -+ * Added dst and src hashes. -+ * -+ * Alexander Clouter, <alex@digriz.org.uk> -+ * Ported ESFQ to Linux 2.6. -+ * -+ * Corey Hickey, <bugfood-c@fatooh.org> -+ * Maintenance of the Linux 2.6 port. -+ * Added fwmark hash (thanks to Robert Kurjata). -+ * Added usage of jhash. -+ * -+ */ -+ -+#include <linux/config.h> -+#include <linux/module.h> -+#include <asm/uaccess.h> -+#include <asm/system.h> -+#include <linux/bitops.h> -+#include <linux/types.h> -+#include <linux/kernel.h> -+#include <linux/sched.h> -+#include <linux/string.h> -+#include <linux/mm.h> -+#include <linux/socket.h> -+#include <linux/sockios.h> -+#include <linux/in.h> -+#include <linux/errno.h> -+#include <linux/interrupt.h> -+#include <linux/if_ether.h> -+#include <linux/inet.h> -+#include <linux/netdevice.h> -+#include <linux/etherdevice.h> -+#include <linux/notifier.h> -+#include <linux/init.h> -+#include <net/ip.h> -+#include <net/route.h> -+#include <linux/skbuff.h> -+#include <net/sock.h> -+#include <net/pkt_sched.h> -+#include <linux/jhash.h> -+ -+#define IPPROTO_DCCP 33 -+#define qdisc_priv(q) ((void *)(q->data)) -+ -+#ifdef CONFIG_IP_NF_CONNTRACK -+/* #include <net/netfilter/nf_conntrack.h> */ -+#include <linux/netfilter_ipv4/ip_conntrack.h> -+#endif -+ -+/* Stochastic Fairness Queuing algorithm. -+ For more comments look at sch_sfq.c. -+ The difference is that you can change limit, depth, -+ hash table size and choose alternate hash types. -+ -+ classic: same as in sch_sfq.c -+ dst: destination IP address -+ src: source IP address -+ ctorigdst: original destination IP address -+ ctorigsrc: original source IP address -+ ctrepldst: reply destination IP address -+ ctreplsrc: reply source IP -+ ctnatchg: use the address which changed via nat -+ -+*/ -+ -+ -+/* This type should contain at least SFQ_DEPTH*2 values */ -+typedef unsigned int esfq_index; -+ -+struct esfq_head -+{ -+ esfq_index next; -+ esfq_index prev; -+}; -+ -+struct esfq_sched_data -+{ -+/* Parameters */ -+ int perturb_period; -+ unsigned quantum; /* Allotment per round: MUST BE >= MTU */ -+ int limit; -+ unsigned depth; -+ unsigned hash_divisor; -+ unsigned hash_kind; -+/* Variables */ -+ struct timer_list perturb_timer; -+ int perturbation; -+ esfq_index tail; /* Index of current slot in round */ -+ esfq_index max_depth; /* Maximal depth */ -+ -+ esfq_index *ht; /* Hash table */ -+ esfq_index *next; /* Active slots link */ -+ short *allot; /* Current allotment per slot */ -+ unsigned short *hash; /* Hash value indexed by slots */ -+ struct sk_buff_head *qs; /* Slot queue */ -+ struct esfq_head *dep; /* Linked list of slots, indexed by depth */ -+ unsigned dyn_min; /* For dynamic divisor adjustment; minimum value seen */ -+ unsigned dyn_max; /* maximum value seen */ -+ unsigned dyn_range; /* saved range */ -+}; -+ -+/* This contains the info we will hash. */ -+struct esfq_packet_info -+{ -+ u32 proto; /* protocol or port */ -+ u32 src; /* source from packet header */ -+ u32 dst; /* destination from packet header */ -+ u32 ctorigsrc; /* original source from conntrack */ -+ u32 ctorigdst; /* original destination from conntrack */ -+ u32 ctreplsrc; /* reply source from conntrack */ -+ u32 ctrepldst; /* reply destination from conntrack */ -+}; -+ -+static __inline__ unsigned esfq_jhash_1word(struct esfq_sched_data *q,u32 a) -+{ -+ return jhash_1word(a, q->perturbation) & (q->hash_divisor-1); -+} -+ -+static __inline__ unsigned esfq_jhash_2words(struct esfq_sched_data *q, u32 a, u32 b) -+{ -+ return jhash_2words(a, b, q->perturbation) & (q->hash_divisor-1); -+} -+ -+static __inline__ unsigned esfq_jhash_3words(struct esfq_sched_data *q, u32 a, u32 b, u32 c) -+{ -+ return jhash_3words(a, b, c, q->perturbation) & (q->hash_divisor-1); -+} -+ -+ -+static unsigned esfq_hash(struct esfq_sched_data *q, struct sk_buff *skb) -+{ -+ struct esfq_packet_info info; -+#ifdef CONFIG_IP_NF_CONNTRACK -+ enum ip_conntrack_info ctinfo; -+ struct ip_conntrack *ct = ip_conntrack_get(skb, &ctinfo); -+#endif -+ -+ switch (skb->protocol) { -+ case __constant_htons(ETH_P_IP): -+ { -+ struct iphdr *iph = skb->nh.iph; -+ info.dst = iph->daddr; -+ info.src = iph->saddr; -+ if (!(iph->frag_off&htons(IP_MF|IP_OFFSET)) && -+ (iph->protocol == IPPROTO_TCP || -+ iph->protocol == IPPROTO_UDP || -+ iph->protocol == IPPROTO_SCTP || -+ iph->protocol == IPPROTO_DCCP || -+ iph->protocol == IPPROTO_ESP)) -+ info.proto = *(((u32*)iph) + iph->ihl); -+ else -+ info.proto = iph->protocol; -+ break; -+ } -+ default: -+ info.dst = (u32)(unsigned long)skb->dst; -+ info.src = (u32)(unsigned long)skb->sk; -+ info.proto = skb->protocol; -+ } -+ -+#ifdef CONFIG_IP_NF_CONNTRACK -+ /* defaults if there is no conntrack info */ -+ info.ctorigsrc = info.src; -+ info.ctorigdst = info.dst; -+ info.ctreplsrc = info.dst; -+ info.ctrepldst = info.src; -+ /* collect conntrack info */ -+ IP_NF_ASSERT(ct); -+ if (ct) { -+ if (skb->protocol == __constant_htons(ETH_P_IP)) { -+ info.ctorigsrc = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip; -+ info.ctorigdst = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.ip; -+ info.ctreplsrc = ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.ip; -+ info.ctrepldst = ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip; -+ } -+ } -+#endif -+ -+ switch(q->hash_kind) -+ { -+ case TCA_SFQ_HASH_CLASSIC: -+ return esfq_jhash_3words(q, info.dst, info.src, info.proto); -+ case TCA_SFQ_HASH_DST: -+ return esfq_jhash_1word(q, info.dst); -+ case TCA_SFQ_HASH_SRC: -+ return esfq_jhash_1word(q, info.src); -+#ifdef CONFIG_IP_NF_CONNTRACK -+ case TCA_SFQ_HASH_CTORIGDST: -+ return esfq_jhash_1word(q, info.ctorigdst); -+ case TCA_SFQ_HASH_CTORIGSRC: -+ return esfq_jhash_1word(q, info.ctorigsrc); -+ case TCA_SFQ_HASH_CTREPLDST: -+ return esfq_jhash_1word(q, info.ctrepldst); -+ case TCA_SFQ_HASH_CTREPLSRC: -+ return esfq_jhash_1word(q, info.ctreplsrc); -+ case TCA_SFQ_HASH_CTNATCHG: -+ { -+ if (info.ctorigdst == info.ctreplsrc) -+ return esfq_jhash_1word(q, info.ctorigsrc); -+ else -+ return esfq_jhash_1word(q, info.ctreplsrc); -+ } -+#endif -+ default: -+ if (net_ratelimit()) -+ printk(KERN_WARNING "ESFQ: Unknown hash method. Falling back to classic.\n"); -+ } -+ return esfq_jhash_3words(q, info.dst, info.src, info.proto); -+} -+ -+static inline void esfq_link(struct esfq_sched_data *q, esfq_index x) -+{ -+ esfq_index p, n; -+ int d = q->qs[x].qlen + q->depth; -+ -+ p = d; -+ n = q->dep[d].next; -+ q->dep[x].next = n; -+ q->dep[x].prev = p; -+ q->dep[p].next = q->dep[n].prev = x; -+} -+ -+static inline void esfq_dec(struct esfq_sched_data *q, esfq_index x) -+{ -+ esfq_index p, n; -+ -+ n = q->dep[x].next; -+ p = q->dep[x].prev; -+ q->dep[p].next = n; -+ q->dep[n].prev = p; -+ -+ if (n == p && q->max_depth == q->qs[x].qlen + 1) -+ q->max_depth--; -+ -+ esfq_link(q, x); -+} -+ -+static inline void esfq_inc(struct esfq_sched_data *q, esfq_index x) -+{ -+ esfq_index p, n; -+ int d; -+ -+ n = q->dep[x].next; -+ p = q->dep[x].prev; -+ q->dep[p].next = n; -+ q->dep[n].prev = p; -+ d = q->qs[x].qlen; -+ if (q->max_depth < d) -+ q->max_depth = d; -+ -+ esfq_link(q, x); -+} -+ -+static unsigned int esfq_drop(struct Qdisc *sch) -+{ -+ struct esfq_sched_data *q = qdisc_priv(sch); -+ esfq_index d = q->max_depth; -+ struct sk_buff *skb; -+ unsigned int len; -+ -+ /* Queue is full! Find the longest slot and -+ drop a packet from it */ -+ -+ if (d > 1) { -+ esfq_index x = q->dep[d+q->depth].next; -+ skb = q->qs[x].prev; -+ len = skb->len; -+ __skb_unlink(skb, &q->qs[x]); -+ kfree_skb(skb); -+ esfq_dec(q, x); -+ sch->q.qlen--; -+ sch->stats.drops++; -+ sch->stats.backlog -= len; -+ return len; -+ } -+ -+ if (d == 1) { -+ /* It is difficult to believe, but ALL THE SLOTS HAVE LENGTH 1. */ -+ d = q->next[q->tail]; -+ q->next[q->tail] = q->next[d]; -+ q->allot[q->next[d]] += q->quantum; -+ skb = q->qs[d].prev; -+ len = skb->len; -+ __skb_unlink(skb, &q->qs[d]); -+ kfree_skb(skb); -+ esfq_dec(q, d); -+ sch->q.qlen--; -+ q->ht[q->hash[d]] = q->depth; -+ sch->stats.drops++; -+ sch->stats.backlog -= len; -+ return len; -+ } -+ -+ return 0; -+} -+ -+static int -+esfq_enqueue(struct sk_buff *skb, struct Qdisc* sch) -+{ -+ struct esfq_sched_data *q = qdisc_priv(sch); -+ unsigned hash = esfq_hash(q, skb); -+ unsigned depth = q->depth; -+ esfq_index x; -+ -+ x = q->ht[hash]; -+ if (x == depth) { -+ q->ht[hash] = x = q->dep[depth].next; -+ q->hash[x] = hash; -+ } -+ sch->stats.backlog += skb->len; -+ __skb_queue_tail(&q->qs[x], skb); -+ esfq_inc(q, x); -+ if (q->qs[x].qlen == 1) { /* The flow is new */ -+ if (q->tail == depth) { /* It is the first flow */ -+ q->tail = x; -+ q->next[x] = x; -+ q->allot[x] = q->quantum; -+ } else { -+ q->next[x] = q->next[q->tail]; -+ q->next[q->tail] = x; -+ q->tail = x; -+ } -+ } -+ if (++sch->q.qlen < q->limit-1) { -+ sch->stats.bytes += skb->len; -+ sch->stats.packets++; -+ return 0; -+ } -+ -+ esfq_drop(sch); -+ return NET_XMIT_CN; -+} -+ -+static int -+esfq_requeue(struct sk_buff *skb, struct Qdisc* sch) -+{ -+ struct esfq_sched_data *q = qdisc_priv(sch); -+ unsigned hash = esfq_hash(q, skb); -+ unsigned depth = q->depth; -+ esfq_index x; -+ -+ x = q->ht[hash]; -+ if (x == depth) { -+ q->ht[hash] = x = q->dep[depth].next; -+ q->hash[x] = hash; -+ } -+ sch->stats.backlog += skb->len; -+ __skb_queue_head(&q->qs[x], skb); -+ esfq_inc(q, x); -+ if (q->qs[x].qlen == 1) { /* The flow is new */ -+ if (q->tail == depth) { /* It is the first flow */ -+ q->tail = x; -+ q->next[x] = x; -+ q->allot[x] = q->quantum; -+ } else { -+ q->next[x] = q->next[q->tail]; -+ q->next[q->tail] = x; -+ q->tail = x; -+ } -+ } -+ if (++sch->q.qlen < q->limit - 1) { -+ return 0; -+ } -+ -+ sch->stats.drops++; -+ esfq_drop(sch); -+ return NET_XMIT_CN; -+} -+ -+ -+ -+ -+static struct sk_buff * -+esfq_dequeue(struct Qdisc* sch) -+{ -+ struct esfq_sched_data *q = qdisc_priv(sch); -+ struct sk_buff *skb; -+ unsigned depth = q->depth; -+ esfq_index a, old_a; -+ -+ /* No active slots */ -+ if (q->tail == depth) -+ return NULL; -+ -+ a = old_a = q->next[q->tail]; -+ -+ /* Grab packet */ -+ skb = __skb_dequeue(&q->qs[a]); -+ esfq_dec(q, a); -+ sch->q.qlen--; -+ sch->stats.backlog -= skb->len; -+ -+ /* Is the slot empty? */ -+ if (q->qs[a].qlen == 0) { -+ q->ht[q->hash[a]] = depth; -+ a = q->next[a]; -+ if (a == old_a) { -+ q->tail = depth; -+ return skb; -+ } -+ q->next[q->tail] = a; -+ q->allot[a] += q->quantum; -+ } else if ((q->allot[a] -= skb->len) <= 0) { -+ q->tail = a; -+ a = q->next[a]; -+ q->allot[a] += q->quantum; -+ } -+ -+ return skb; -+} -+ -+static void -+esfq_reset(struct Qdisc* sch) -+{ -+ struct sk_buff *skb; -+ -+ while ((skb = esfq_dequeue(sch)) != NULL) -+ kfree_skb(skb); -+} -+ -+static void esfq_perturbation(unsigned long arg) -+{ -+ struct Qdisc *sch = (struct Qdisc*)arg; -+ struct esfq_sched_data *q = qdisc_priv(sch); -+ -+ q->perturbation = net_random()&0x1F; -+ -+ if (q->perturb_period) { -+ q->perturb_timer.expires = jiffies + q->perturb_period; -+ add_timer(&q->perturb_timer); -+ } -+} -+ -+static int esfq_change(struct Qdisc *sch, struct rtattr *opt) -+{ -+ struct esfq_sched_data *q = qdisc_priv(sch); -+ struct tc_esfq_qopt *ctl = RTA_DATA(opt); -+ int old_perturb = q->perturb_period; -+ -+ if (opt->rta_len < RTA_LENGTH(sizeof(*ctl))) -+ return -EINVAL; -+ -+ sch_tree_lock(sch); -+ q->quantum = ctl->quantum ? : psched_mtu(sch->dev); -+ q->perturb_period = ctl->perturb_period*HZ; -+// q->hash_divisor = ctl->divisor; -+// q->tail = q->limit = q->depth = ctl->flows; -+ -+ if (ctl->limit) -+ q->limit = min_t(u32, ctl->limit, q->depth); -+ -+ if (ctl->hash_kind) { -+ q->hash_kind = ctl->hash_kind; -+ if (q->hash_kind != TCA_SFQ_HASH_CLASSIC) -+ q->perturb_period = 0; -+ } -+ -+ // is sch_tree_lock enough to do this ? -+ while (sch->q.qlen >= q->limit-1) -+ esfq_drop(sch); -+ -+ if (old_perturb) -+ del_timer(&q->perturb_timer); -+ if (q->perturb_period) { -+ q->perturb_timer.expires = jiffies + q->perturb_period; -+ add_timer(&q->perturb_timer); -+ } else { -+ q->perturbation = 0; -+ } -+ sch_tree_unlock(sch); -+ return 0; -+} -+ -+static int esfq_init(struct Qdisc *sch, struct rtattr *opt) -+{ -+ struct esfq_sched_data *q = qdisc_priv(sch); -+ struct tc_esfq_qopt *ctl; -+ esfq_index p = ~0U/2; -+ int i; -+ -+ if (opt && opt->rta_len < RTA_LENGTH(sizeof(*ctl))) -+ return -EINVAL; -+ -+ init_timer(&q->perturb_timer); -+ q->perturb_timer.data = (unsigned long)sch; -+ q->perturb_timer.function = esfq_perturbation; -+ q->perturbation = 0; -+ q->hash_kind = TCA_SFQ_HASH_CLASSIC; -+ q->max_depth = 0; -+ q->dyn_min = ~0U; /* maximum value for this type */ -+ q->dyn_max = 0; /* dyn_min/dyn_max will be set properly upon first packet */ -+ if (opt == NULL) { -+ q->quantum = psched_mtu(sch->dev); -+ q->perturb_period = 0; -+ q->hash_divisor = 1024; -+ q->tail = q->limit = q->depth = 128; -+ -+ } else { -+ ctl = RTA_DATA(opt); -+ q->quantum = ctl->quantum ? : psched_mtu(sch->dev); -+ q->perturb_period = ctl->perturb_period*HZ; -+ q->hash_divisor = ctl->divisor ? : 1024; -+ q->tail = q->limit = q->depth = ctl->flows ? : 128; -+ -+ if ( q->depth > p - 1 ) -+ return -EINVAL; -+ -+ if (ctl->limit) -+ q->limit = min_t(u32, ctl->limit, q->depth); -+ -+ if (ctl->hash_kind) { -+ q->hash_kind = ctl->hash_kind; -+ } -+ -+ if (q->perturb_period) { -+ q->perturb_timer.expires = jiffies + q->perturb_period; -+ add_timer(&q->perturb_timer); -+ } -+ } -+ -+ q->ht = kmalloc(q->hash_divisor*sizeof(esfq_index), GFP_KERNEL); -+ if (!q->ht) -+ goto err_case; -+ -+ q->dep = kmalloc((1+q->depth*2)*sizeof(struct esfq_head), GFP_KERNEL); -+ if (!q->dep) -+ goto err_case; -+ q->next = kmalloc(q->depth*sizeof(esfq_index), GFP_KERNEL); -+ if (!q->next) -+ goto err_case; -+ -+ q->allot = kmalloc(q->depth*sizeof(short), GFP_KERNEL); -+ if (!q->allot) -+ goto err_case; -+ q->hash = kmalloc(q->depth*sizeof(unsigned short), GFP_KERNEL); -+ if (!q->hash) -+ goto err_case; -+ q->qs = kmalloc(q->depth*sizeof(struct sk_buff_head), GFP_KERNEL); -+ if (!q->qs) -+ goto err_case; -+ -+ for (i=0; i< q->hash_divisor; i++) -+ q->ht[i] = q->depth; -+ for (i=0; i<q->depth; i++) { -+ skb_queue_head_init(&q->qs[i]); -+ q->dep[i+q->depth].next = i+q->depth; -+ q->dep[i+q->depth].prev = i+q->depth; -+ } -+ -+ for (i=0; i<q->depth; i++) -+ esfq_link(q, i); -+ return 0; -+err_case: -+ del_timer(&q->perturb_timer); -+ if (q->ht) -+ kfree(q->ht); -+ if (q->dep) -+ kfree(q->dep); -+ if (q->next) -+ kfree(q->next); -+ if (q->allot) -+ kfree(q->allot); -+ if (q->hash) -+ kfree(q->hash); -+ if (q->qs) -+ kfree(q->qs); -+ return -ENOBUFS; -+} -+ -+static void esfq_destroy(struct Qdisc *sch) -+{ -+ struct esfq_sched_data *q = qdisc_priv(sch); -+ del_timer(&q->perturb_timer); -+ if(q->ht) -+ kfree(q->ht); -+ if(q->dep) -+ kfree(q->dep); -+ if(q->next) -+ kfree(q->next); -+ if(q->allot) -+ kfree(q->allot); -+ if(q->hash) -+ kfree(q->hash); -+ if(q->qs) -+ kfree(q->qs); -+} -+ -+static int esfq_dump(struct Qdisc *sch, struct sk_buff *skb) -+{ -+ struct esfq_sched_data *q = qdisc_priv(sch); -+ unsigned char *b = skb->tail; -+ struct tc_esfq_qopt opt; -+ -+ opt.quantum = q->quantum; -+ opt.perturb_period = q->perturb_period/HZ; -+ -+ opt.limit = q->limit; -+ opt.divisor = q->hash_divisor; -+ opt.flows = q->depth; -+ opt.hash_kind = q->hash_kind; -+ -+ RTA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt); -+ -+ return skb->len; -+ -+rtattr_failure: -+ skb_trim(skb, b - skb->data); -+ return -1; -+} -+ -+static struct Qdisc_ops esfq_qdisc_ops = -+{ -+ .next = NULL, -+ .cl_ops = NULL, -+ .id = "esfq", -+ .priv_size = sizeof(struct esfq_sched_data), -+ .enqueue = esfq_enqueue, -+ .dequeue = esfq_dequeue, -+ .requeue = esfq_requeue, -+ .drop = esfq_drop, -+ .init = esfq_init, -+ .reset = esfq_reset, -+ .destroy = esfq_destroy, -+ .change = NULL, /* esfq_change - needs more work */ -+ .dump = esfq_dump, -+}; -+ -+static int __init esfq_module_init(void) -+{ -+ return register_qdisc(&esfq_qdisc_ops); -+} -+static void __exit esfq_module_exit(void) -+{ -+ unregister_qdisc(&esfq_qdisc_ops); -+} -+module_init(esfq_module_init) -+module_exit(esfq_module_exit) -+MODULE_LICENSE("GPL"); diff --git a/target/linux/generic-2.4/patches/624-netfilter_ip6t_reject.patch b/target/linux/generic-2.4/patches/624-netfilter_ip6t_reject.patch deleted file mode 100644 index 1960e9c..0000000 --- a/target/linux/generic-2.4/patches/624-netfilter_ip6t_reject.patch +++ /dev/null @@ -1,352 +0,0 @@ ---- /dev/null -+++ b/net/ipv6/netfilter/ip6t_REJECT.c -@@ -0,0 +1,301 @@ -+/* -+ * This is a module which is used for rejecting packets. -+ * Added support for customized reject packets (Jozsef Kadlecsik). -+ * Sun 12 Nov 2000 -+ * Port to IPv6 / ip6tables (Harald Welte <laforge@gnumonks.org>) -+ */ -+#include <linux/config.h> -+#include <linux/module.h> -+#include <linux/skbuff.h> -+#include <linux/icmpv6.h> -+#include <net/tcp.h> -+#include <net/ipv6.h> -+#include <net/ip6_fib.h> -+#include <net/ip6_route.h> -+#include <linux/netfilter_ipv6/ip6_tables.h> -+#include <linux/netfilter_ipv6/ip6t_REJECT.h> -+ -+#if 1 -+#define DEBUGP printk -+#else -+#define DEBUGP(format, args...) -+#endif -+ -+#if 0 -+/* Send RST reply */ -+static void send_reset(struct sk_buff *oldskb) -+{ -+ struct sk_buff *nskb; -+ struct tcphdr *otcph, *tcph; -+ struct rtable *rt; -+ unsigned int otcplen; -+ int needs_ack; -+ -+ /* IP header checks: fragment, too short. */ -+ if (oldskb->nh.iph->frag_off & htons(IP_OFFSET) -+ || oldskb->len < (oldskb->nh.iph->ihl<<2) + sizeof(struct tcphdr)) -+ return; -+ -+ otcph = (struct tcphdr *)((u_int32_t*)oldskb->nh.iph + oldskb->nh.iph->ihl); -+ otcplen = oldskb->len - oldskb->nh.iph->ihl*4; -+ -+ /* No RST for RST. */ -+ if (otcph->rst) -+ return; -+ -+ /* Check checksum. */ -+ if (tcp_v4_check(otcph, otcplen, oldskb->nh.iph->saddr, -+ oldskb->nh.iph->daddr, -+ csum_partial((char *)otcph, otcplen, 0)) != 0) -+ return; -+ -+ /* Copy skb (even if skb is about to be dropped, we can't just -+ clone it because there may be other things, such as tcpdump, -+ interested in it) */ -+ nskb = skb_copy(oldskb, GFP_ATOMIC); -+ if (!nskb) -+ return; -+ -+ /* This packet will not be the same as the other: clear nf fields */ -+ nf_conntrack_put(nskb->nfct); -+ nskb->nfct = NULL; -+ nskb->nfcache = 0; -+#ifdef CONFIG_NETFILTER_DEBUG -+ nskb->nf_debug = 0; -+#endif -+ -+ tcph = (struct tcphdr *)((u_int32_t*)nskb->nh.iph + nskb->nh.iph->ihl); -+ -+ nskb->nh.iph->daddr = xchg(&nskb->nh.iph->saddr, nskb->nh.iph->daddr); -+ tcph->source = xchg(&tcph->dest, tcph->source); -+ -+ /* Truncate to length (no data) */ -+ tcph->doff = sizeof(struct tcphdr)/4; -+ skb_trim(nskb, nskb->nh.iph->ihl*4 + sizeof(struct tcphdr)); -+ nskb->nh.iph->tot_len = htons(nskb->len); -+ -+ if (tcph->ack) { -+ needs_ack = 0; -+ tcph->seq = otcph->ack_seq; -+ tcph->ack_seq = 0; -+ } else { -+ needs_ack = 1; -+ tcph->ack_seq = htonl(ntohl(otcph->seq) + otcph->syn + otcph->fin -+ + otcplen - (otcph->doff<<2)); -+ tcph->seq = 0; -+ } -+ -+ /* Reset flags */ -+ ((u_int8_t *)tcph)[13] = 0; -+ tcph->rst = 1; -+ tcph->ack = needs_ack; -+ -+ tcph->window = 0; -+ tcph->urg_ptr = 0; -+ -+ /* Adjust TCP checksum */ -+ tcph->check = 0; -+ tcph->check = tcp_v4_check(tcph, sizeof(struct tcphdr), -+ nskb->nh.iph->saddr, -+ nskb->nh.iph->daddr, -+ csum_partial((char *)tcph, -+ sizeof(struct tcphdr), 0)); -+ -+ /* Adjust IP TTL, DF */ -+ nskb->nh.iph->ttl = MAXTTL; -+ /* Set DF, id = 0 */ -+ nskb->nh.iph->frag_off = htons(IP_DF); -+ nskb->nh.iph->id = 0; -+ -+ /* Adjust IP checksum */ -+ nskb->nh.iph->check = 0; -+ nskb->nh.iph->check = ip_fast_csum((unsigned char *)nskb->nh.iph, -+ nskb->nh.iph->ihl); -+ -+ /* Routing */ -+ if (ip_route_output(&rt, nskb->nh.iph->daddr, nskb->nh.iph->saddr, -+ RT_TOS(nskb->nh.iph->tos) | RTO_CONN, -+ 0) != 0) -+ goto free_nskb; -+ -+ dst_release(nskb->dst); -+ nskb->dst = &rt->u.dst; -+ -+ /* "Never happens" */ -+ if (nskb->len > nskb->dst->pmtu) -+ goto free_nskb; -+ -+ NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, nskb, NULL, nskb->dst->dev, -+ ip_finish_output); -+ return; -+ -+ free_nskb: -+ kfree_skb(nskb); -+} -+#endif -+ -+static unsigned int reject6_target(struct sk_buff **pskb, -+ unsigned int hooknum, -+ const struct net_device *in, -+ const struct net_device *out, -+ const void *targinfo, -+ void *userinfo) -+{ -+ const struct ip6t_reject_info *reject = targinfo; -+ struct sk_buff *skb2 = NULL; -+ struct rt6_info *rt6i; -+ struct net_device odev; -+ -+ if (!out) { -+ skb2 = skb_clone(*pskb, GFP_ATOMIC); -+ if (skb2 == NULL) { -+ return NF_DROP; -+ } -+ dst_release(skb2->dst); -+ skb2->dst = NULL; -+ -+ rt6i = rt6_lookup(&skb2->nh.ipv6h->saddr, NULL, 0, 0); -+ if (rt6i && rt6i->rt6i_dev) { -+ skb2->dev = rt6i->rt6i_dev; -+ rt6i = rt6_lookup(&skb2->nh.ipv6h->daddr, &skb2->nh.ipv6h->saddr, 0, 0); -+ } -+ memcpy(&odev, skb2->dev, sizeof(odev)); /* XXX 'out' has 'const' qualifier... */ -+ } else { -+ memcpy(&odev, out, sizeof(odev)); -+ } -+ -+ printk(KERN_DEBUG "%s: medium point\n", __FUNCTION__); -+ /* WARNING: This code causes reentry within ip6tables. -+ This means that the ip6tables jump stack is now crap. We -+ must return an absolute verdict. --RR */ -+ DEBUGP("REJECTv6: calling icmpv6_send\n"); -+ switch (reject->with) { -+ case IP6T_ICMP6_NO_ROUTE: -+ icmpv6_send(*pskb, ICMPV6_DEST_UNREACH, ICMPV6_NOROUTE, 0, &odev); -+ break; -+ case IP6T_ICMP6_ADM_PROHIBITED: -+ icmpv6_send(*pskb, ICMPV6_DEST_UNREACH, ICMPV6_ADM_PROHIBITED, 0, &odev); -+ break; -+ case IP6T_ICMP6_NOT_NEIGHBOUR: -+ icmpv6_send(*pskb, ICMPV6_DEST_UNREACH, ICMPV6_NOT_NEIGHBOUR, 0, &odev); -+ break; -+ case IP6T_ICMP6_ADDR_UNREACH: -+ icmpv6_send(*pskb, ICMPV6_DEST_UNREACH, ICMPV6_ADDR_UNREACH, 0, &odev); -+ break; -+ case IP6T_ICMP6_PORT_UNREACH: -+ icmpv6_send(*pskb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0, &odev); -+ break; -+#if 0 -+ case IPT_ICMP_ECHOREPLY: { -+ struct icmp6hdr *icmph = (struct icmphdr *) -+ ((u_int32_t *)(*pskb)->nh.iph + (*pskb)->nh.iph->ihl); -+ unsigned int datalen = (*pskb)->len - (*pskb)->nh.iph->ihl * 4; -+ -+ /* Not non-head frags, or truncated */ -+ if (((ntohs((*pskb)->nh.iph->frag_off) & IP_OFFSET) == 0) -+ && datalen >= 4) { -+ /* Usually I don't like cut & pasting code, -+ but dammit, my party is starting in 45 -+ mins! --RR */ -+ struct icmp_bxm icmp_param; -+ -+ icmp_param.icmph=*icmph; -+ icmp_param.icmph.type=ICMP_ECHOREPLY; -+ icmp_param.data_ptr=(icmph+1); -+ icmp_param.data_len=datalen; -+ icmp_reply(&icmp_param, *pskb); -+ } -+ } -+ break; -+ case IPT_TCP_RESET: -+ send_reset(*pskb); -+ break; -+#endif -+ default: -+ printk(KERN_WARNING "REJECTv6: case %u not handled yet\n", reject->with); -+ break; -+ } -+ -+ if (skb2) kfree_skb(skb2); -+ -+ return NF_DROP; -+} -+ -+static inline int find_ping_match(const struct ip6t_entry_match *m) -+{ -+ const struct ip6t_icmp *icmpinfo = (const struct ip6t_icmp *)m->data; -+ -+ if (strcmp(m->u.kernel.match->name, "icmp6") == 0 -+ && icmpinfo->type == ICMPV6_ECHO_REQUEST -+ && !(icmpinfo->invflags & IP6T_ICMP_INV)) -+ return 1; -+ -+ return 0; -+} -+ -+static int check(const char *tablename, -+ const struct ip6t_entry *e, -+ void *targinfo, -+ unsigned int targinfosize, -+ unsigned int hook_mask) -+{ -+ const struct ip6t_reject_info *rejinfo = targinfo; -+ -+ if (targinfosize != IP6T_ALIGN(sizeof(struct ip6t_reject_info))) { -+ DEBUGP("REJECTv6: targinfosize %u != 0\n", targinfosize); -+ return 0; -+ } -+ -+ /* Only allow these for packet filtering. */ -+ if (strcmp(tablename, "filter") != 0) { -+ DEBUGP("REJECTv6: bad table `%s'.\n", tablename); -+ return 0; -+ } -+ if ((hook_mask & ~((1 << NF_IP6_LOCAL_IN) -+ | (1 << NF_IP6_FORWARD) -+ | (1 << NF_IP6_LOCAL_OUT))) != 0) { -+ DEBUGP("REJECTv6: bad hook mask %X\n", hook_mask); -+ return 0; -+ } -+ -+ if (rejinfo->with == IP6T_ICMP6_ECHOREPLY) { -+ /* Must specify that it's an ICMP ping packet. */ -+ if (e->ipv6.proto != IPPROTO_ICMPV6 -+ || (e->ipv6.invflags & IP6T_INV_PROTO)) { -+ DEBUGP("REJECTv6: ECHOREPLY illegal for non-icmp\n"); -+ return 0; -+ } -+ /* Must contain ICMP match. */ -+ if (IP6T_MATCH_ITERATE(e, find_ping_match) == 0) { -+ DEBUGP("REJECTv6: ECHOREPLY illegal for non-ping\n"); -+ return 0; -+ } -+ } else if (rejinfo->with == IP6T_TCP_RESET) { -+ /* Must specify that it's a TCP packet */ -+ if (e->ipv6.proto != IPPROTO_TCP -+ || (e->ipv6.invflags & IP6T_INV_PROTO)) { -+ DEBUGP("REJECTv6: TCP_RESET illegal for non-tcp\n"); -+ return 0; -+ } -+ } -+ -+ return 1; -+} -+ -+static struct ip6t_target ip6t_reject_reg -+= { { NULL, NULL }, "REJECT", reject6_target, check, NULL, THIS_MODULE }; -+ -+static int __init init(void) -+{ -+ if (ip6t_register_target(&ip6t_reject_reg)) -+ return -EINVAL; -+ return 0; -+} -+ -+static void __exit fini(void) -+{ -+ ip6t_unregister_target(&ip6t_reject_reg); -+} -+ -+module_init(init); -+module_exit(fini); ---- a/include/linux/netfilter_ipv6/ip6t_REJECT.h -+++ b/include/linux/netfilter_ipv6/ip6t_REJECT.h -@@ -2,15 +2,17 @@ - #define _IP6T_REJECT_H - - enum ip6t_reject_with { -- IP6T_ICMP_NET_UNREACHABLE, -- IP6T_ICMP_HOST_UNREACHABLE, -- IP6T_ICMP_PROT_UNREACHABLE, -- IP6T_ICMP_PORT_UNREACHABLE, -- IP6T_ICMP_ECHOREPLY -+ IP6T_ICMP6_NO_ROUTE, -+ IP6T_ICMP6_ADM_PROHIBITED, -+ IP6T_ICMP6_NOT_NEIGHBOUR, -+ IP6T_ICMP6_ADDR_UNREACH, -+ IP6T_ICMP6_PORT_UNREACH, -+ IP6T_ICMP6_ECHOREPLY, -+ IP6T_TCP_RESET - }; - - struct ip6t_reject_info { - enum ip6t_reject_with with; /* reject type */ - }; - --#endif /*_IPT_REJECT_H*/ -+#endif /*_IP6T_REJECT_H*/ ---- a/net/ipv6/netfilter/Makefile -+++ b/net/ipv6/netfilter/Makefile -@@ -34,5 +34,7 @@ obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue. - obj-$(CONFIG_IP6_NF_TARGET_LOG) += ip6t_LOG.o - obj-$(CONFIG_IP6_NF_MATCH_RANDOM) += ip6t_random.o - obj-$(CONFIG_IP6_NF_MATCH_HL) += ip6t_hl.o -+obj-$(CONFIG_IP6_NF_TARGET_REJECT) += ip6t_REJECT.o -+ - - include $(TOPDIR)/Rules.make ---- a/net/ipv6/netfilter/Config.in -+++ b/net/ipv6/netfilter/Config.in -@@ -61,6 +61,9 @@ if [ "$CONFIG_IP6_NF_IPTABLES" != "n" ]; - if [ "$CONFIG_IP6_NF_FILTER" != "n" ]; then - dep_tristate ' LOG target support' CONFIG_IP6_NF_TARGET_LOG $CONFIG_IP6_NF_FILTER - fi -+ if [ "$CONFIG_IP6_NF_FILTER" != "n" ]; then -+ dep_tristate ' REJECT target support' CONFIG_IP6_NF_TARGET_REJECT $CONFIG_IP6_NF_FILTER -+ fi - - # if [ "$CONFIG_IP6_NF_FILTER" != "n" ]; then - # dep_tristate ' REJECT target support' CONFIG_IP6_NF_TARGET_REJECT $CONFIG_IP6_NF_FILTER diff --git a/target/linux/generic-2.4/patches/626-netfilter_conntrack_fix.patch b/target/linux/generic-2.4/patches/626-netfilter_conntrack_fix.patch deleted file mode 100644 index 363df14..0000000 --- a/target/linux/generic-2.4/patches/626-netfilter_conntrack_fix.patch +++ /dev/null @@ -1,49 +0,0 @@ ---- a/include/linux/netfilter_ipv4/ip_conntrack_tuple.h -+++ b/include/linux/netfilter_ipv4/ip_conntrack_tuple.h -@@ -62,6 +62,35 @@ struct ip_conntrack_tuple - } dst; - }; - -+/* This is exposed to userspace, so remains frozen in time. */ -+struct ip_conntrack_old_tuple -+{ -+ struct ip_conntrack_manip src; -+ -+ /* These are the parts of the tuple which are fixed. */ -+ struct { -+ u_int32_t ip; -+ union { -+ /* Add other protocols here. */ -+ u_int16_t all; -+ -+ struct { -+ u_int16_t port; -+ } tcp; -+ struct { -+ u_int16_t port; -+ } udp; -+ struct { -+ u_int8_t type, code; -+ } icmp; -+ } u; -+ -+ /* The protocol. */ -+ u_int16_t protonum; -+ } dst; -+}; -+ -+ - /* This is optimized opposed to a memset of the whole structure. Everything we - * really care about is the source/destination unions */ - #define IP_CT_TUPLE_U_BLANK(tuple) \ ---- a/include/linux/netfilter_ipv4/ipt_conntrack.h -+++ b/include/linux/netfilter_ipv4/ipt_conntrack.h -@@ -25,7 +25,7 @@ struct ipt_conntrack_info - { - unsigned int statemask, statusmask; - -- struct ip_conntrack_tuple tuple[IP_CT_DIR_MAX]; -+ struct ip_conntrack_old_tuple tuple[IP_CT_DIR_MAX]; - struct in_addr sipmsk[IP_CT_DIR_MAX], dipmsk[IP_CT_DIR_MAX]; - - unsigned long expires_min, expires_max; diff --git a/target/linux/generic-2.4/patches/628-netfilter_raw.patch b/target/linux/generic-2.4/patches/628-netfilter_raw.patch deleted file mode 100644 index de54a35..0000000 --- a/target/linux/generic-2.4/patches/628-netfilter_raw.patch +++ /dev/null @@ -1,707 +0,0 @@ ---- a/Documentation/Configure.help -+++ b/Documentation/Configure.help -@@ -3057,6 +3057,34 @@ CONFIG_IP_NF_FILTER - If you want to compile it as a module, say M here and read - <file:Documentation/modules.txt>. If unsure, say `N'. - -+raw table support (required for NOTRACK/TRACE) -+CONFIG_IP_NF_RAW -+ This option adds a `raw' table to iptables. This table is the very -+ first in the netfilter framework and hooks in at the PREROUTING -+ and OUTPUT chains. -+ -+ If you want to compile it as a module, say M here and read -+ <file:Documentation/modules.txt>. If unsure, say `N'. -+ -+NOTRACK target support -+CONFIG_IP_NF_TARGET_NOTRACK -+ The NOTRACK target allows a select rule to specify -+ which packets *not* to enter the conntrack/NAT -+ subsystem with all the consequences (no ICMP error tracking, -+ no protocol helpers for the selected packets). -+ -+ If you want to compile it as a module, say M here and read -+ <file:Documentation/modules.txt>. If unsure, say `N'. -+ -+raw table support (required for TRACE) -+CONFIG_IP6_NF_RAW -+ This option adds a `raw' table to ip6tables. This table is the very -+ first in the netfilter framework and hooks in at the PREROUTING -+ and OUTPUT chains. -+ -+ If you want to compile it as a module, say M here and read -+ <file:Documentation/modules.txt>. If unsure, say `N'. -+ - REJECT target support - CONFIG_IP_NF_TARGET_REJECT - The REJECT target allows a filtering rule to specify that an ICMP ---- a/include/linux/netfilter_ipv4/ip_conntrack.h -+++ b/include/linux/netfilter_ipv4/ip_conntrack.h -@@ -286,6 +286,9 @@ extern void ip_ct_refresh_acct(struct ip - /* Call me when a conntrack is destroyed. */ - extern void (*ip_conntrack_destroyed)(struct ip_conntrack *conntrack); - -+/* Fake conntrack entry for untracked connections */ -+extern struct ip_conntrack ip_conntrack_untracked; -+ - /* Returns new sk_buff, or NULL */ - struct sk_buff * - ip_ct_gather_frags(struct sk_buff *skb, u_int32_t user); ---- a/include/linux/netfilter_ipv4/ipt_conntrack.h -+++ b/include/linux/netfilter_ipv4/ipt_conntrack.h -@@ -10,6 +10,7 @@ - - #define IPT_CONNTRACK_STATE_SNAT (1 << (IP_CT_NUMBER + 1)) - #define IPT_CONNTRACK_STATE_DNAT (1 << (IP_CT_NUMBER + 2)) -+#define IPT_CONNTRACK_STATE_UNTRACKED (1 << (IP_CT_NUMBER + 3)) - - /* flags, invflags: */ - #define IPT_CONNTRACK_STATE 0x01 ---- a/include/linux/netfilter_ipv4/ipt_state.h -+++ b/include/linux/netfilter_ipv4/ipt_state.h -@@ -4,6 +4,8 @@ - #define IPT_STATE_BIT(ctinfo) (1 << ((ctinfo)%IP_CT_IS_REPLY+1)) - #define IPT_STATE_INVALID (1 << 0) - -+#define IPT_STATE_UNTRACKED (1 << (IP_CT_NUMBER + 1)) -+ - struct ipt_state_info - { - unsigned int statemask; ---- a/include/linux/netfilter_ipv4.h -+++ b/include/linux/netfilter_ipv4.h -@@ -51,6 +51,8 @@ - - enum nf_ip_hook_priorities { - NF_IP_PRI_FIRST = INT_MIN, -+ NF_IP_PRI_CONNTRACK_DEFRAG = -400, -+ NF_IP_PRI_RAW = -300, - NF_IP_PRI_CONNTRACK = -200, - NF_IP_PRI_MANGLE = -150, - NF_IP_PRI_NAT_DST = -100, ---- a/net/ipv4/netfilter/Config.in -+++ b/net/ipv4/netfilter/Config.in -@@ -153,6 +153,15 @@ if [ "$CONFIG_IP_NF_IPTABLES" != "n" ]; - dep_tristate ' TTL target support' CONFIG_IP_NF_TARGET_TTL $CONFIG_IP_NF_IPTABLES - dep_tristate ' ULOG target support' CONFIG_IP_NF_TARGET_ULOG $CONFIG_IP_NF_IPTABLES - dep_tristate ' TCPMSS target support' CONFIG_IP_NF_TARGET_TCPMSS $CONFIG_IP_NF_IPTABLES -+ if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then -+ tristate ' raw table support (required for NOTRACK/TRACE)' CONFIG_IP_NF_RAW $CONFIG_IP_NF_IPTABLES -+ fi -+ if [ "$CONFIG_IP_NF_RAW" != "n" ]; then -+ if [ "$CONFIG_IP_NF_CONNTRACK" != "n" ]; then -+ dep_tristate ' NOTRACK target support' CONFIG_IP_NF_TARGET_NOTRACK $CONFIG_IP_NF_RAW -+ fi -+ # Marker for TRACE target -+ fi - fi - - tristate 'ARP tables support' CONFIG_IP_NF_ARPTABLES ---- a/net/ipv4/netfilter/ip_conntrack_core.c -+++ b/net/ipv4/netfilter/ip_conntrack_core.c -@@ -64,6 +64,7 @@ int ip_conntrack_max = 0; - static atomic_t ip_conntrack_count = ATOMIC_INIT(0); - struct list_head *ip_conntrack_hash; - static kmem_cache_t *ip_conntrack_cachep; -+struct ip_conntrack ip_conntrack_untracked; - static LIST_HEAD(unconfirmed); - - extern struct ip_conntrack_protocol ip_conntrack_generic_protocol; -@@ -834,6 +835,15 @@ unsigned int ip_conntrack_in(unsigned in - int set_reply; - int ret; - -+ /* Never happen */ -+ if ((*pskb)->nh.iph->frag_off & htons(IP_OFFSET)) { -+ if (net_ratelimit()) { -+ printk(KERN_ERR "ip_conntrack_in: Frag of proto %u (hook=%u)\n", -+ (*pskb)->nh.iph->protocol, hooknum); -+ } -+ return NF_DROP; -+ } -+ - /* FIXME: Do this right please. --RR */ - (*pskb)->nfcache |= NFC_UNKNOWN; - -@@ -1489,6 +1499,18 @@ int __init ip_conntrack_init(void) - - /* For use by ipt_REJECT */ - ip_ct_attach = ip_conntrack_attach; -+ -+ /* Set up fake conntrack: -+ - to never be deleted, not in any hashes */ -+ atomic_set(&ip_conntrack_untracked.ct_general.use, 1); -+ /* - and look it like as a confirmed connection */ -+ set_bit(IPS_CONFIRMED_BIT, &ip_conntrack_untracked.status); -+ /* - and prepare the ctinfo field for REJECT/NAT. */ -+ ip_conntrack_untracked.infos[IP_CT_NEW].master = -+ ip_conntrack_untracked.infos[IP_CT_RELATED].master = -+ ip_conntrack_untracked.infos[IP_CT_RELATED + IP_CT_IS_REPLY].master = -+ &ip_conntrack_untracked.ct_general; -+ - return ret; - - err_free_hash: ---- a/net/ipv4/netfilter/ip_conntrack_standalone.c -+++ b/net/ipv4/netfilter/ip_conntrack_standalone.c -@@ -218,6 +218,29 @@ static unsigned int ip_confirm(unsigned - return ip_conntrack_confirm(*pskb); - } - -+static unsigned int ip_conntrack_defrag(unsigned int hooknum, -+ struct sk_buff **pskb, -+ const struct net_device *in, -+ const struct net_device *out, -+ int (*okfn)(struct sk_buff *)) -+{ -+ /* Previously seen (loopback)? Ignore. Do this before -+ fragment check. */ -+ if ((*pskb)->nfct) -+ return NF_ACCEPT; -+ -+ /* Gather fragments. */ -+ if ((*pskb)->nh.iph->frag_off & htons(IP_MF|IP_OFFSET)) { -+ *pskb = ip_ct_gather_frags(*pskb, -+ hooknum == NF_IP_PRE_ROUTING ? -+ IP_DEFRAG_CONNTRACK_IN : -+ IP_DEFRAG_CONNTRACK_OUT); -+ if (!*pskb) -+ return NF_STOLEN; -+ } -+ return NF_ACCEPT; -+} -+ - static unsigned int ip_refrag(unsigned int hooknum, - struct sk_buff **pskb, - const struct net_device *in, -@@ -259,9 +282,15 @@ static unsigned int ip_conntrack_local(u - - /* Connection tracking may drop packets, but never alters them, so - make it the first hook. */ -+static struct nf_hook_ops ip_conntrack_defrag_ops -+= { { NULL, NULL }, ip_conntrack_defrag, PF_INET, NF_IP_PRE_ROUTING, -+ NF_IP_PRI_CONNTRACK_DEFRAG }; - static struct nf_hook_ops ip_conntrack_in_ops - = { { NULL, NULL }, ip_conntrack_in, PF_INET, NF_IP_PRE_ROUTING, - NF_IP_PRI_CONNTRACK }; -+static struct nf_hook_ops ip_conntrack_defrag_local_out_ops -+= { { NULL, NULL }, ip_conntrack_defrag, PF_INET, NF_IP_LOCAL_OUT, -+ NF_IP_PRI_CONNTRACK_DEFRAG }; - static struct nf_hook_ops ip_conntrack_local_out_ops - = { { NULL, NULL }, ip_conntrack_local, PF_INET, NF_IP_LOCAL_OUT, - NF_IP_PRI_CONNTRACK }; -@@ -382,10 +411,20 @@ static int init_or_cleanup(int init) - if (!proc) goto cleanup_init; - proc->owner = THIS_MODULE; - -+ ret = nf_register_hook(&ip_conntrack_defrag_ops); -+ if (ret < 0) { -+ printk("ip_conntrack: can't register pre-routing defrag hook.\n"); -+ goto cleanup_proc; -+ } -+ ret = nf_register_hook(&ip_conntrack_defrag_local_out_ops); -+ if (ret < 0) { -+ printk("ip_conntrack: can't register local_out defrag hook.\n"); -+ goto cleanup_defragops; -+ } - ret = nf_register_hook(&ip_conntrack_in_ops); - if (ret < 0) { - printk("ip_conntrack: can't register pre-routing hook.\n"); -- goto cleanup_proc; -+ goto cleanup_defraglocalops; - } - ret = nf_register_hook(&ip_conntrack_local_out_ops); - if (ret < 0) { -@@ -423,6 +462,10 @@ static int init_or_cleanup(int init) - nf_unregister_hook(&ip_conntrack_local_out_ops); - cleanup_inops: - nf_unregister_hook(&ip_conntrack_in_ops); -+ cleanup_defraglocalops: -+ nf_unregister_hook(&ip_conntrack_defrag_local_out_ops); -+ cleanup_defragops: -+ nf_unregister_hook(&ip_conntrack_defrag_ops); - cleanup_proc: - proc_net_remove("ip_conntrack"); - cleanup_init: -@@ -512,5 +555,6 @@ EXPORT_SYMBOL(ip_conntrack_htable_size); - EXPORT_SYMBOL(ip_conntrack_expect_list); - EXPORT_SYMBOL(ip_conntrack_lock); - EXPORT_SYMBOL(ip_conntrack_hash); -+EXPORT_SYMBOL(ip_conntrack_untracked); - EXPORT_SYMBOL_GPL(ip_conntrack_find_get); - EXPORT_SYMBOL_GPL(ip_conntrack_put); ---- a/net/ipv4/netfilter/ip_nat_core.c -+++ b/net/ipv4/netfilter/ip_nat_core.c -@@ -1023,6 +1023,10 @@ int __init ip_nat_init(void) - /* FIXME: Man, this is a hack. <SIGH> */ - IP_NF_ASSERT(ip_conntrack_destroyed == NULL); - ip_conntrack_destroyed = &ip_nat_cleanup_conntrack; -+ -+ /* Initialize fake conntrack so that NAT will skip it */ -+ ip_conntrack_untracked.nat.info.initialized |= -+ (1 << IP_NAT_MANIP_SRC) | (1 << IP_NAT_MANIP_DST); - - return 0; - } ---- /dev/null -+++ b/net/ipv4/netfilter/iptable_raw.c -@@ -0,0 +1,149 @@ -+/* -+ * 'raw' table, which is the very first hooked in at PRE_ROUTING and LOCAL_OUT . -+ * -+ * Copyright (C) 2003 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> -+ */ -+#include <linux/module.h> -+#include <linux/netfilter_ipv4/ip_tables.h> -+ -+#define RAW_VALID_HOOKS ((1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_LOCAL_OUT)) -+ -+/* Standard entry. */ -+struct ipt_standard -+{ -+ struct ipt_entry entry; -+ struct ipt_standard_target target; -+}; -+ -+struct ipt_error_target -+{ -+ struct ipt_entry_target target; -+ char errorname[IPT_FUNCTION_MAXNAMELEN]; -+}; -+ -+struct ipt_error -+{ -+ struct ipt_entry entry; -+ struct ipt_error_target target; -+}; -+ -+static struct -+{ -+ struct ipt_replace repl; -+ struct ipt_standard entries[2]; -+ struct ipt_error term; -+} initial_table __initdata -+= { { "raw", RAW_VALID_HOOKS, 3, -+ sizeof(struct ipt_standard) * 2 + sizeof(struct ipt_error), -+ { [NF_IP_PRE_ROUTING] 0, -+ [NF_IP_LOCAL_OUT] sizeof(struct ipt_standard) }, -+ { [NF_IP_PRE_ROUTING] 0, -+ [NF_IP_LOCAL_OUT] sizeof(struct ipt_standard) }, -+ 0, NULL, { } }, -+ { -+ /* PRE_ROUTING */ -+ { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 }, -+ 0, -+ sizeof(struct ipt_entry), -+ sizeof(struct ipt_standard), -+ 0, { 0, 0 }, { } }, -+ { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } }, -+ -NF_ACCEPT - 1 } }, -+ /* LOCAL_OUT */ -+ { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 }, -+ 0, -+ sizeof(struct ipt_entry), -+ sizeof(struct ipt_standard), -+ 0, { 0, 0 }, { } }, -+ { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } }, -+ -NF_ACCEPT - 1 } } -+ }, -+ /* ERROR */ -+ { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 }, -+ 0, -+ sizeof(struct ipt_entry), -+ sizeof(struct ipt_error), -+ 0, { 0, 0 }, { } }, -+ { { { { IPT_ALIGN(sizeof(struct ipt_error_target)), IPT_ERROR_TARGET } }, -+ { } }, -+ "ERROR" -+ } -+ } -+}; -+ -+static struct ipt_table packet_raw = { -+ .name = "raw", -+ .table = &initial_table.repl, -+ .valid_hooks = RAW_VALID_HOOKS, -+ .lock = RW_LOCK_UNLOCKED, -+ .me = THIS_MODULE -+}; -+ -+/* The work comes in here from netfilter.c. */ -+static unsigned int -+ipt_hook(unsigned int hook, -+ struct sk_buff **pskb, -+ const struct net_device *in, -+ const struct net_device *out, -+ int (*okfn)(struct sk_buff *)) -+{ -+ return ipt_do_table(pskb, hook, in, out, &packet_raw, NULL); -+} -+ -+/* 'raw' is the very first table. */ -+static struct nf_hook_ops ipt_ops[] = { -+ { -+ .hook = ipt_hook, -+ .pf = PF_INET, -+ .hooknum = NF_IP_PRE_ROUTING, -+ .priority = NF_IP_PRI_RAW -+ }, -+ { -+ .hook = ipt_hook, -+ .pf = PF_INET, -+ .hooknum = NF_IP_LOCAL_OUT, -+ .priority = NF_IP_PRI_RAW -+ }, -+}; -+ -+static int __init init(void) -+{ -+ int ret; -+ -+ /* Register table */ -+ ret = ipt_register_table(&packet_raw); -+ if (ret < 0) -+ return ret; -+ -+ /* Register hooks */ -+ ret = nf_register_hook(&ipt_ops[0]); -+ if (ret < 0) -+ goto cleanup_table; -+ -+ ret = nf_register_hook(&ipt_ops[1]); -+ if (ret < 0) -+ goto cleanup_hook0; -+ -+ return ret; -+ -+ cleanup_hook0: -+ nf_unregister_hook(&ipt_ops[0]); -+ cleanup_table: -+ ipt_unregister_table(&packet_raw); -+ -+ return ret; -+} -+ -+static void __exit fini(void) -+{ -+ unsigned int i; -+ -+ for (i = 0; i < sizeof(ipt_ops)/sizeof(struct nf_hook_ops); i++) -+ nf_unregister_hook(&ipt_ops[i]); -+ -+ ipt_unregister_table(&packet_raw); -+} -+ -+module_init(init); -+module_exit(fini); -+MODULE_LICENSE("GPL"); ---- a/net/ipv4/netfilter/ipt_conntrack.c -+++ b/net/ipv4/netfilter/ipt_conntrack.c -@@ -27,11 +27,13 @@ match(const struct sk_buff *skb, - - #define FWINV(bool,invflg) ((bool) ^ !!(sinfo->invflags & invflg)) - -- if (ct) -- statebit = IPT_CONNTRACK_STATE_BIT(ctinfo); -- else -- statebit = IPT_CONNTRACK_STATE_INVALID; -- -+ if (skb->nfct == &ip_conntrack_untracked.infos[IP_CT_NEW]) -+ statebit = IPT_CONNTRACK_STATE_UNTRACKED; -+ else if (ct) -+ statebit = IPT_CONNTRACK_STATE_BIT(ctinfo); -+ else -+ statebit = IPT_CONNTRACK_STATE_INVALID; -+ - if(sinfo->flags & IPT_CONNTRACK_STATE) { - if (ct) { - if(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip != ---- /dev/null -+++ b/net/ipv4/netfilter/ipt_NOTRACK.c -@@ -0,0 +1,75 @@ -+/* This is a module which is used for setting up fake conntracks -+ * on packets so that they are not seen by the conntrack/NAT code. -+ */ -+#include <linux/module.h> -+#include <linux/skbuff.h> -+ -+#include <linux/netfilter_ipv4/ip_tables.h> -+#include <linux/netfilter_ipv4/ip_conntrack.h> -+ -+static unsigned int -+target(struct sk_buff **pskb, -+ unsigned int hooknum, -+ const struct net_device *in, -+ const struct net_device *out, -+ const void *targinfo, -+ void *userinfo) -+{ -+ /* Previously seen (loopback)? Ignore. */ -+ if ((*pskb)->nfct != NULL) -+ return IPT_CONTINUE; -+ -+ /* Attach fake conntrack entry. -+ If there is a real ct entry correspondig to this packet, -+ it'll hang aroun till timing out. We don't deal with it -+ for performance reasons. JK */ -+ (*pskb)->nfct = &ip_conntrack_untracked.infos[IP_CT_NEW]; -+ nf_conntrack_get((*pskb)->nfct); -+ -+ return IPT_CONTINUE; -+} -+ -+static int -+checkentry(const char *tablename, -+ const struct ipt_entry *e, -+ void *targinfo, -+ unsigned int targinfosize, -+ unsigned int hook_mask) -+{ -+ if (targinfosize != 0) { -+ printk(KERN_WARNING "NOTRACK: targinfosize %u != 0\n", -+ targinfosize); -+ return 0; -+ } -+ -+ if (strcmp(tablename, "raw") != 0) { -+ printk(KERN_WARNING "NOTRACK: can only be called from \"raw\" table, not \"%s\"\n", tablename); -+ return 0; -+ } -+ -+ return 1; -+} -+ -+static struct ipt_target ipt_notrack_reg = { -+ .name = "NOTRACK", -+ .target = target, -+ .checkentry = checkentry, -+ .me = THIS_MODULE -+}; -+ -+static int __init init(void) -+{ -+ if (ipt_register_target(&ipt_notrack_reg)) -+ return -EINVAL; -+ -+ return 0; -+} -+ -+static void __exit fini(void) -+{ -+ ipt_unregister_target(&ipt_notrack_reg); -+} -+ -+module_init(init); -+module_exit(fini); -+MODULE_LICENSE("GPL"); ---- a/net/ipv4/netfilter/ipt_state.c -+++ b/net/ipv4/netfilter/ipt_state.c -@@ -21,7 +21,9 @@ match(const struct sk_buff *skb, - enum ip_conntrack_info ctinfo; - unsigned int statebit; - -- if (!ip_conntrack_get((struct sk_buff *)skb, &ctinfo)) -+ if (skb->nfct == &ip_conntrack_untracked.infos[IP_CT_NEW]) -+ statebit = IPT_STATE_UNTRACKED; -+ else if (!ip_conntrack_get((struct sk_buff *)skb, &ctinfo)) - statebit = IPT_STATE_INVALID; - else - statebit = IPT_STATE_BIT(ctinfo); ---- a/net/ipv4/netfilter/Makefile -+++ b/net/ipv4/netfilter/Makefile -@@ -77,6 +77,7 @@ obj-$(CONFIG_IP_NF_IPTABLES) += ip_table - obj-$(CONFIG_IP_NF_FILTER) += iptable_filter.o - obj-$(CONFIG_IP_NF_MANGLE) += iptable_mangle.o - obj-$(CONFIG_IP_NF_NAT) += iptable_nat.o -+obj-$(CONFIG_IP_NF_RAW) += iptable_raw.o - - # matches - obj-$(CONFIG_IP_NF_MATCH_HELPER) += ipt_helper.o -@@ -131,6 +132,7 @@ obj-$(CONFIG_IP_NF_TARGET_CONNMARK) += i - obj-$(CONFIG_IP_NF_TARGET_TTL) += ipt_TTL.o - obj-$(CONFIG_IP_NF_TARGET_ULOG) += ipt_ULOG.o - obj-$(CONFIG_IP_NF_TARGET_TCPMSS) += ipt_TCPMSS.o -+obj-$(CONFIG_IP_NF_TARGET_NOTRACK) += ipt_NOTRACK.o - - # generic ARP tables - obj-$(CONFIG_IP_NF_ARPTABLES) += arp_tables.o ---- a/net/ipv6/netfilter/Config.in -+++ b/net/ipv6/netfilter/Config.in -@@ -79,6 +79,10 @@ if [ "$CONFIG_IP6_NF_IPTABLES" != "n" ]; - dep_tristate ' IMQ target support' CONFIG_IP6_NF_TARGET_IMQ $CONFIG_IP6_NF_MANGLE - fi - #dep_tristate ' LOG target support' CONFIG_IP6_NF_TARGET_LOG $CONFIG_IP6_NF_IPTABLES -+ if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then -+ tristate ' raw table support (required for TRACE)' CONFIG_IP6_NF_RAW $CONFIG_IP6_NF_IPTABLES -+ fi -+ # Marker for TRACE target - fi - - endmenu ---- /dev/null -+++ b/net/ipv6/netfilter/ip6table_raw.c -@@ -0,0 +1,154 @@ -+/* -+ * IPv6 raw table, a port of the IPv4 raw table to IPv6 -+ * -+ * Copyright (C) 2003 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> -+ */ -+#include <linux/module.h> -+#include <linux/netfilter_ipv6/ip6_tables.h> -+ -+#define RAW_VALID_HOOKS ((1 << NF_IP6_PRE_ROUTING) | (1 << NF_IP6_LOCAL_OUT)) -+ -+#if 0 -+#define DEBUGP(x, args...) printk(KERN_DEBUG x, ## args) -+#else -+#define DEBUGP(x, args...) -+#endif -+ -+/* Standard entry. */ -+struct ip6t_standard -+{ -+ struct ip6t_entry entry; -+ struct ip6t_standard_target target; -+}; -+ -+struct ip6t_error_target -+{ -+ struct ip6t_entry_target target; -+ char errorname[IP6T_FUNCTION_MAXNAMELEN]; -+}; -+ -+struct ip6t_error -+{ -+ struct ip6t_entry entry; -+ struct ip6t_error_target target; -+}; -+ -+static struct -+{ -+ struct ip6t_replace repl; -+ struct ip6t_standard entries[2]; -+ struct ip6t_error term; -+} initial_table __initdata -+= { { "raw", RAW_VALID_HOOKS, 3, -+ sizeof(struct ip6t_standard) * 2 + sizeof(struct ip6t_error), -+ { [NF_IP6_PRE_ROUTING] 0, -+ [NF_IP6_LOCAL_OUT] sizeof(struct ip6t_standard) }, -+ { [NF_IP6_PRE_ROUTING] 0, -+ [NF_IP6_LOCAL_OUT] sizeof(struct ip6t_standard) }, -+ 0, NULL, { } }, -+ { -+ /* PRE_ROUTING */ -+ { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 }, -+ 0, -+ sizeof(struct ip6t_entry), -+ sizeof(struct ip6t_standard), -+ 0, { 0, 0 }, { } }, -+ { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } }, -+ -NF_ACCEPT - 1 } }, -+ /* LOCAL_OUT */ -+ { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 }, -+ 0, -+ sizeof(struct ip6t_entry), -+ sizeof(struct ip6t_standard), -+ 0, { 0, 0 }, { } }, -+ { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } }, -+ -NF_ACCEPT - 1 } }, -+ }, -+ /* ERROR */ -+ { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 }, -+ 0, -+ sizeof(struct ip6t_entry), -+ sizeof(struct ip6t_error), -+ 0, { 0, 0 }, { } }, -+ { { { { IP6T_ALIGN(sizeof(struct ip6t_error_target)), IP6T_ERROR_TARGET } }, -+ { } }, -+ "ERROR" -+ } -+ } -+}; -+ -+static struct ip6t_table packet_raw = { -+ .name = "raw", -+ .table = &initial_table.repl, -+ .valid_hooks = RAW_VALID_HOOKS, -+ .lock = RW_LOCK_UNLOCKED, -+ .me = THIS_MODULE -+}; -+ -+/* The work comes in here from netfilter.c. */ -+static unsigned int -+ip6t_hook(unsigned int hook, -+ struct sk_buff **pskb, -+ const struct net_device *in, -+ const struct net_device *out, -+ int (*okfn)(struct sk_buff *)) -+{ -+ return ip6t_do_table(pskb, hook, in, out, &packet_raw, NULL); -+} -+ -+static struct nf_hook_ops ip6t_ops[] = { -+ { -+ .hook = ip6t_hook, -+ .pf = PF_INET6, -+ .hooknum = NF_IP6_PRE_ROUTING, -+ .priority = NF_IP6_PRI_FIRST -+ }, -+ { -+ .hook = ip6t_hook, -+ .pf = PF_INET6, -+ .hooknum = NF_IP6_LOCAL_OUT, -+ .priority = NF_IP6_PRI_FIRST -+ }, -+}; -+ -+static int __init init(void) -+{ -+ int ret; -+ -+ /* Register table */ -+ ret = ip6t_register_table(&packet_raw); -+ if (ret < 0) -+ return ret; -+ -+ /* Register hooks */ -+ ret = nf_register_hook(&ip6t_ops[0]); -+ if (ret < 0) -+ goto cleanup_table; -+ -+ ret = nf_register_hook(&ip6t_ops[1]); -+ if (ret < 0) -+ goto cleanup_hook0; -+ -+ return ret; -+ -+ cleanup_hook0: -+ nf_unregister_hook(&ip6t_ops[0]); -+ cleanup_table: -+ ip6t_unregister_table(&packet_raw); -+ -+ return ret; -+} -+ -+static void __exit fini(void) -+{ -+ unsigned int i; -+ -+ for (i = 0; i < sizeof(ip6t_ops)/sizeof(struct nf_hook_ops); i++) -+ nf_unregister_hook(&ip6t_ops[i]); -+ -+ ip6t_unregister_table(&packet_raw); -+} -+ -+module_init(init); -+module_exit(fini); -+MODULE_LICENSE("GPL"); ---- a/net/ipv6/netfilter/Makefile -+++ b/net/ipv6/netfilter/Makefile -@@ -32,6 +32,7 @@ obj-$(CONFIG_IP6_NF_TARGET_MARK) += ip6t - obj-$(CONFIG_IP6_NF_TARGET_IMQ) += ip6t_IMQ.o - obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue.o - obj-$(CONFIG_IP6_NF_TARGET_LOG) += ip6t_LOG.o -+obj-$(CONFIG_IP6_NF_RAW) += ip6table_raw.o - obj-$(CONFIG_IP6_NF_MATCH_RANDOM) += ip6t_random.o - obj-$(CONFIG_IP6_NF_MATCH_HL) += ip6t_hl.o - obj-$(CONFIG_IP6_NF_TARGET_REJECT) += ip6t_REJECT.o diff --git a/target/linux/generic-2.4/patches/629-netlink_types_h.patch b/target/linux/generic-2.4/patches/629-netlink_types_h.patch deleted file mode 100644 index 49803b7..0000000 --- a/target/linux/generic-2.4/patches/629-netlink_types_h.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/include/linux/netlink.h -+++ b/include/linux/netlink.h -@@ -1,6 +1,8 @@ - #ifndef __LINUX_NETLINK_H - #define __LINUX_NETLINK_H - -+#include <linux/types.h> -+ - #define NETLINK_ROUTE 0 /* Routing/device hook */ - #define NETLINK_SKIP 1 /* Reserved for ENskip */ - #define NETLINK_USERSOCK 2 /* Reserved for user mode socket protocols */ ---- a/include/linux/filter.h -+++ b/include/linux/filter.h -@@ -5,6 +5,8 @@ - #ifndef __LINUX_FILTER_H__ - #define __LINUX_FILTER_H__ - -+#include <linux/types.h> -+ - /* - * Current version of the filter code architecture. - */ diff --git a/target/linux/generic-2.4/patches/630-netfilter_comment.patch b/target/linux/generic-2.4/patches/630-netfilter_comment.patch deleted file mode 100644 index 1181d06..0000000 --- a/target/linux/generic-2.4/patches/630-netfilter_comment.patch +++ /dev/null @@ -1,95 +0,0 @@ ---- /dev/null -+++ b/include/linux/netfilter_ipv4/ipt_comment.h -@@ -0,0 +1,10 @@ -+#ifndef _IPT_COMMENT_H -+#define _IPT_COMMENT_H -+ -+#define IPT_MAX_COMMENT_LEN 256 -+ -+struct ipt_comment_info { -+ char comment[IPT_MAX_COMMENT_LEN]; -+}; -+ -+#endif /* _IPT_COMMENT_H */ ---- /dev/null -+++ b/net/ipv4/netfilter/ipt_comment.c -@@ -0,0 +1,59 @@ -+/* -+ * Implements a dummy match to allow attaching comments to rules -+ * -+ * 2003-05-13 Brad Fisher (brad@info-link.net) -+ */ -+ -+#include <linux/module.h> -+#include <linux/skbuff.h> -+#include <linux/netfilter_ipv4/ip_tables.h> -+#include <linux/netfilter_ipv4/ipt_comment.h> -+ -+MODULE_AUTHOR("Brad Fisher <brad@info-link.net>"); -+MODULE_DESCRIPTION("iptables comment match module"); -+MODULE_LICENSE("GPL"); -+ -+static int -+match(const struct sk_buff *skb, -+ const struct net_device *in, -+ const struct net_device *out, -+ const void *matchinfo, -+ int offset, -+ int *hotdrop) -+{ -+ /* We always match */ -+ return 1; -+} -+ -+static int -+checkentry(const char *tablename, -+ const struct ipt_ip *ip, -+ void *matchinfo, -+ unsigned int matchsize, -+ unsigned int hook_mask) -+{ -+ /* Check the size */ -+ if (matchsize != IPT_ALIGN(sizeof(struct ipt_comment_info))) -+ return 0; -+ return 1; -+} -+ -+static struct ipt_match comment_match = { -+ .name = "comment", -+ .match = match, -+ .checkentry = checkentry, -+ .me = THIS_MODULE -+}; -+ -+static int __init init(void) -+{ -+ return ipt_register_match(&comment_match); -+} -+ -+static void __exit fini(void) -+{ -+ ipt_unregister_match(&comment_match); -+} -+ -+module_init(init); -+module_exit(fini); ---- a/net/ipv4/netfilter/Makefile -+++ b/net/ipv4/netfilter/Makefile -@@ -113,6 +113,7 @@ obj-$(CONFIG_IP_NF_MATCH_UNCLEAN) += ipt - obj-$(CONFIG_IP_NF_MATCH_STRING) += ipt_string.o - obj-$(CONFIG_IP_NF_MATCH_TCPMSS) += ipt_tcpmss.o - obj-$(CONFIG_IP_NF_MATCH_LAYER7) += ipt_layer7.o -+obj-$(CONFIG_IP_NF_MATCH_COMMENT) += ipt_comment.o - - # targets - obj-$(CONFIG_IP_NF_TARGET_REJECT) += ipt_REJECT.o ---- a/net/ipv4/netfilter/Config.in -+++ b/net/ipv4/netfilter/Config.in -@@ -44,6 +44,7 @@ if [ "$CONFIG_IP_NF_IPTABLES" != "n" ]; - dep_tristate ' LENGTH match support' CONFIG_IP_NF_MATCH_LENGTH $CONFIG_IP_NF_IPTABLES - dep_tristate ' TTL match support' CONFIG_IP_NF_MATCH_TTL $CONFIG_IP_NF_IPTABLES - dep_tristate ' tcpmss match support' CONFIG_IP_NF_MATCH_TCPMSS $CONFIG_IP_NF_IPTABLES -+ dep_tristate ' comment match support' CONFIG_IP_NF_MATCH_COMMENT $CONFIG_IP_NF_IPTABLES - if [ "$CONFIG_IP_NF_CONNTRACK" != "n" ]; then - dep_tristate ' Helper match support' CONFIG_IP_NF_MATCH_HELPER $CONFIG_IP_NF_IPTABLES - fi diff --git a/target/linux/generic-2.4/patches/700-multiple_default_gateways.patch b/target/linux/generic-2.4/patches/700-multiple_default_gateways.patch deleted file mode 100644 index ec62aa2..0000000 --- a/target/linux/generic-2.4/patches/700-multiple_default_gateways.patch +++ /dev/null @@ -1,1284 +0,0 @@ ---- a/include/linux/netfilter_ipv4/ip_nat.h -+++ b/include/linux/netfilter_ipv4/ip_nat.h -@@ -121,5 +121,13 @@ extern int ip_nat_used_tuple(const struc - extern u_int16_t ip_nat_cheat_check(u_int32_t oldvalinv, - u_int32_t newval, - u_int16_t oldcheck); -+ -+/* Call input routing for SNAT-ed traffic */ -+extern unsigned int ip_nat_route_input(unsigned int hooknum, -+ struct sk_buff **pskb, -+ const struct net_device *in, -+ const struct net_device *out, -+ int (*okfn)(struct sk_buff *)); -+ - #endif /*__KERNEL__*/ - #endif ---- a/include/linux/rtnetlink.h -+++ b/include/linux/rtnetlink.h -@@ -234,6 +234,8 @@ struct rtnexthop - #define RTNH_F_DEAD 1 /* Nexthop is dead (used by multipath) */ - #define RTNH_F_PERVASIVE 2 /* Do recursive gateway lookup */ - #define RTNH_F_ONLINK 4 /* Gateway is forced on link */ -+#define RTNH_F_SUSPECT 8 /* We don't know the real state */ -+#define RTNH_F_BADSTATE (RTNH_F_DEAD | RTNH_F_SUSPECT) - - /* Macros to handle hexthops */ - ---- a/include/net/ip_fib.h -+++ b/include/net/ip_fib.h -@@ -162,7 +162,8 @@ static inline int fib_lookup(const struc - - static inline void fib_select_default(const struct rt_key *key, struct fib_result *res) - { -- if (FIB_RES_GW(*res) && FIB_RES_NH(*res).nh_scope == RT_SCOPE_LINK) -+ if ((FIB_RES_GW(*res) && FIB_RES_NH(*res).nh_scope == RT_SCOPE_LINK) || -+ FIB_RES_NH(*res).nh_scope == RT_SCOPE_HOST) - main_table->tb_select_default(main_table, key, res); - } - -@@ -174,6 +175,7 @@ extern struct fib_table * fib_tables[RT_ - extern int fib_lookup(const struct rt_key *key, struct fib_result *res); - extern struct fib_table *__fib_new_table(int id); - extern void fib_rule_put(struct fib_rule *r); -+extern int fib_result_table(struct fib_result *res); - - static inline struct fib_table *fib_get_table(int id) - { -@@ -275,5 +277,6 @@ static inline void fib_res_put(struct fi - #endif - } - -+extern rwlock_t fib_nhflags_lock; - - #endif /* _NET_FIB_H */ ---- a/include/net/route.h -+++ b/include/net/route.h -@@ -49,6 +49,8 @@ struct rt_key - { - __u32 dst; - __u32 src; -+ __u32 lsrc; -+ __u32 gw; - int iif; - int oif; - #ifdef CONFIG_IP_ROUTE_FWMARK -@@ -128,6 +130,7 @@ extern void ip_rt_advice(struct rtable - extern void rt_cache_flush(int how); - extern int ip_route_output_key(struct rtable **, const struct rt_key *key); - extern int ip_route_input(struct sk_buff*, u32 dst, u32 src, u8 tos, struct net_device *devin); -+extern int ip_route_input_lookup(struct sk_buff*, u32 dst, u32 src, u8 tos, struct net_device *devin, u32 lsrc); - extern unsigned short ip_rt_frag_needed(struct iphdr *iph, unsigned short new_mtu); - extern void ip_rt_update_pmtu(struct dst_entry *dst, unsigned mtu); - extern void ip_rt_send_redirect(struct sk_buff *skb); -@@ -148,6 +151,15 @@ static inline int ip_route_output(struct - } - - -+static inline int -+ip_route_output_lookup(struct rtable **rp, -+ u32 daddr, u32 saddr, u32 tos, int oif, u32 gw) -+{ -+ struct rt_key key = { dst:daddr, src:saddr, gw:gw, oif:oif, tos:tos }; -+ -+ return ip_route_output_key(rp, &key); -+} -+ - static inline void ip_rt_put(struct rtable * rt) - { - if (rt) ---- a/net/ipv4/fib_frontend.c -+++ b/net/ipv4/fib_frontend.c -@@ -54,6 +54,8 @@ - struct fib_table *local_table; - struct fib_table *main_table; - -+#define FIB_RES_TABLE(r) (RT_TABLE_MAIN) -+ - #else - - #define RT_TABLE_MIN 1 -@@ -71,6 +73,7 @@ struct fib_table *__fib_new_table(int id - return tb; - } - -+#define FIB_RES_TABLE(r) (fib_result_table(r)) - - #endif /* CONFIG_IP_MULTIPLE_TABLES */ - -@@ -209,6 +212,9 @@ int fib_validate_source(u32 src, u32 dst - struct in_device *in_dev; - struct rt_key key; - struct fib_result res; -+ int table; -+ unsigned char prefixlen; -+ unsigned char scope; - int no_addr, rpf; - int ret; - -@@ -216,6 +222,7 @@ int fib_validate_source(u32 src, u32 dst - key.src = dst; - key.tos = tos; - key.oif = 0; -+ key.gw = 0; - key.iif = oif; - key.scope = RT_SCOPE_UNIVERSE; - -@@ -237,31 +244,35 @@ int fib_validate_source(u32 src, u32 dst - goto e_inval_res; - *spec_dst = FIB_RES_PREFSRC(res); - fib_combine_itag(itag, &res); --#ifdef CONFIG_IP_ROUTE_MULTIPATH -- if (FIB_RES_DEV(res) == dev || res.fi->fib_nhs > 1) --#else - if (FIB_RES_DEV(res) == dev) --#endif - { - ret = FIB_RES_NH(res).nh_scope >= RT_SCOPE_HOST; - fib_res_put(&res); - return ret; - } -+ table = FIB_RES_TABLE(&res); -+ prefixlen = res.prefixlen; -+ scope = res.scope; - fib_res_put(&res); - if (no_addr) - goto last_resort; -- if (rpf) -- goto e_inval; - key.oif = dev->ifindex; - - ret = 0; - if (fib_lookup(&key, &res) == 0) { -- if (res.type == RTN_UNICAST) { -+ if (res.type == RTN_UNICAST && -+ ((table == FIB_RES_TABLE(&res) && -+ res.prefixlen >= prefixlen && res.scope >= scope) || -+ !rpf)) { - *spec_dst = FIB_RES_PREFSRC(res); - ret = FIB_RES_NH(res).nh_scope >= RT_SCOPE_HOST; -+ fib_res_put(&res); -+ return ret; - } - fib_res_put(&res); - } -+ if (rpf) -+ goto e_inval; - return ret; - - last_resort: -@@ -579,9 +590,7 @@ static int fib_inetaddr_event(struct not - switch (event) { - case NETDEV_UP: - fib_add_ifaddr(ifa); --#ifdef CONFIG_IP_ROUTE_MULTIPATH - fib_sync_up(ifa->ifa_dev->dev); --#endif - rt_cache_flush(-1); - break; - case NETDEV_DOWN: -@@ -617,9 +626,7 @@ static int fib_netdev_event(struct notif - for_ifa(in_dev) { - fib_add_ifaddr(ifa); - } endfor_ifa(in_dev); --#ifdef CONFIG_IP_ROUTE_MULTIPATH - fib_sync_up(dev); --#endif - rt_cache_flush(-1); - break; - case NETDEV_DOWN: ---- a/net/ipv4/fib_hash.c -+++ b/net/ipv4/fib_hash.c -@@ -71,6 +71,7 @@ struct fib_node - struct fib_info *fn_info; - #define FIB_INFO(f) ((f)->fn_info) - fn_key_t fn_key; -+ int fn_last_dflt; - u8 fn_tos; - u8 fn_type; - u8 fn_scope; -@@ -336,72 +337,123 @@ out: - return err; - } - --static int fn_hash_last_dflt=-1; -- --static int fib_detect_death(struct fib_info *fi, int order, -- struct fib_info **last_resort, int *last_idx) -+static int fib_detect_death(struct fib_info *fi, int order, int last_dflt, -+ struct fib_info **last_resort, int *last_idx, -+ int *last_nhsel, const struct rt_key *key) - { - struct neighbour *n; -- int state = NUD_NONE; -+ int nhsel; -+ int state; -+ struct fib_nh * nh; -+ u32 dst; -+ int flag, dead = 1; -+ -+ /* change_nexthops(fi) { */ -+ for (nhsel = 0, nh = fi->fib_nh; nhsel < fi->fib_nhs; nh++, nhsel++) { -+ if (key->oif && key->oif != nh->nh_oif) -+ continue; -+ if (key->gw && key->gw != nh->nh_gw && nh->nh_gw && -+ nh->nh_scope == RT_SCOPE_LINK) -+ continue; -+ if (nh->nh_flags & RTNH_F_DEAD) -+ continue; - -- n = neigh_lookup(&arp_tbl, &fi->fib_nh[0].nh_gw, fi->fib_dev); -- if (n) { -- state = n->nud_state; -- neigh_release(n); -+ flag = 0; -+ if (nh->nh_dev->flags & IFF_NOARP) { -+ dead = 0; -+ goto setfl; -+ } -+ -+ dst = nh->nh_gw; -+ if (!nh->nh_gw || nh->nh_scope != RT_SCOPE_LINK) -+ dst = key->dst; -+ -+ state = NUD_NONE; -+ n = neigh_lookup(&arp_tbl, &dst, nh->nh_dev); -+ if (n) { -+ state = n->nud_state; -+ neigh_release(n); -+ } -+ if (state==NUD_REACHABLE || -+ ((state&NUD_VALID) && order != last_dflt)) { -+ dead = 0; -+ goto setfl; -+ } -+ if (!(state&NUD_VALID)) -+ flag = 1; -+ if (!dead) -+ goto setfl; -+ if ((state&NUD_VALID) || -+ (*last_idx<0 && order >= last_dflt)) { -+ *last_resort = fi; -+ *last_idx = order; -+ *last_nhsel = nhsel; -+ } -+ -+ setfl: -+ -+ read_lock_bh(&fib_nhflags_lock); -+ if (flag) -+ nh->nh_flags |= RTNH_F_SUSPECT; -+ else -+ nh->nh_flags &= ~RTNH_F_SUSPECT; -+ read_unlock_bh(&fib_nhflags_lock); - } -- if (state==NUD_REACHABLE) -- return 0; -- if ((state&NUD_VALID) && order != fn_hash_last_dflt) -- return 0; -- if ((state&NUD_VALID) || -- (*last_idx<0 && order > fn_hash_last_dflt)) { -- *last_resort = fi; -- *last_idx = order; -- } -- return 1; -+ /* } endfor_nexthops(fi) */ -+ -+ return dead; - } - - static void - fn_hash_select_default(struct fib_table *tb, const struct rt_key *key, struct fib_result *res) - { -- int order, last_idx; -- struct fib_node *f; -+ int order, last_idx, last_dflt, last_nhsel; -+ struct fib_node *f, *first_node; - struct fib_info *fi = NULL; - struct fib_info *last_resort; - struct fn_hash *t = (struct fn_hash*)tb->tb_data; -- struct fn_zone *fz = t->fn_zones[0]; -+ struct fn_zone *fz = t->fn_zones[res->prefixlen]; -+ fn_key_t k; - - if (fz == NULL) - return; - -+ k = fz_key(key->dst, fz); -+ last_dflt = -2; -+ first_node = NULL; - last_idx = -1; - last_resort = NULL; -+ last_nhsel = 0; - order = -1; - - read_lock(&fib_hash_lock); -- for (f = fz->fz_hash[0]; f; f = f->fn_next) { -+ for (f = fz_chain(k, fz); f; f = f->fn_next) { - struct fib_info *next_fi = FIB_INFO(f); - -- if ((f->fn_state&FN_S_ZOMBIE) || -+ if (!fn_key_eq(k, f->fn_key) || -+ (f->fn_state&FN_S_ZOMBIE) || - f->fn_scope != res->scope || -+#ifdef CONFIG_IP_ROUTE_TOS -+ (f->fn_tos && f->fn_tos != key->tos) || -+#endif - f->fn_type != RTN_UNICAST) - continue; - - if (next_fi->fib_priority > res->fi->fib_priority) - break; -- if (!next_fi->fib_nh[0].nh_gw || next_fi->fib_nh[0].nh_scope != RT_SCOPE_LINK) -- continue; - f->fn_state |= FN_S_ACCESSED; - -- if (fi == NULL) { -- if (next_fi != res->fi) -- break; -- } else if (!fib_detect_death(fi, order, &last_resort, &last_idx)) { -+ if (!first_node) { -+ last_dflt = f->fn_last_dflt; -+ first_node = f; -+ } -+ if (fi && !fib_detect_death(fi, order, last_dflt, -+ &last_resort, &last_idx, &last_nhsel, key)) { - if (res->fi) - fib_info_put(res->fi); - res->fi = fi; - atomic_inc(&fi->fib_clntref); -- fn_hash_last_dflt = order; -+ first_node->fn_last_dflt = order; - goto out; - } - fi = next_fi; -@@ -409,16 +461,25 @@ fn_hash_select_default(struct fib_table - } - - if (order<=0 || fi==NULL) { -- fn_hash_last_dflt = -1; -+ if (fi && fi->fib_nhs > 1 && -+ fib_detect_death(fi, order, last_dflt, -+ &last_resort, &last_idx, &last_nhsel, key) && -+ last_resort == fi) { -+ read_lock_bh(&fib_nhflags_lock); -+ fi->fib_nh[last_nhsel].nh_flags &= ~RTNH_F_SUSPECT; -+ read_unlock_bh(&fib_nhflags_lock); -+ } -+ if (first_node) first_node->fn_last_dflt = -1; - goto out; - } - -- if (!fib_detect_death(fi, order, &last_resort, &last_idx)) { -+ if (!fib_detect_death(fi, order, last_dflt, &last_resort, &last_idx, -+ &last_nhsel, key)) { - if (res->fi) - fib_info_put(res->fi); - res->fi = fi; - atomic_inc(&fi->fib_clntref); -- fn_hash_last_dflt = order; -+ first_node->fn_last_dflt = order; - goto out; - } - -@@ -428,8 +489,11 @@ fn_hash_select_default(struct fib_table - res->fi = last_resort; - if (last_resort) - atomic_inc(&last_resort->fib_clntref); -+ read_lock_bh(&fib_nhflags_lock); -+ last_resort->fib_nh[last_nhsel].nh_flags &= ~RTNH_F_SUSPECT; -+ read_unlock_bh(&fib_nhflags_lock); -+ first_node->fn_last_dflt = last_idx; - } -- fn_hash_last_dflt = last_idx; - out: - read_unlock(&fib_hash_lock); - } -@@ -589,6 +653,7 @@ replace: - - memset(new_f, 0, sizeof(struct fib_node)); - -+ new_f->fn_last_dflt = -1; - new_f->fn_key = key; - #ifdef CONFIG_IP_ROUTE_TOS - new_f->fn_tos = tos; ---- a/net/ipv4/fib_rules.c -+++ b/net/ipv4/fib_rules.c -@@ -307,6 +307,11 @@ static void fib_rules_attach(struct net_ - } - } - -+int fib_result_table(struct fib_result *res) -+{ -+ return res->r->r_table; -+} -+ - int fib_lookup(const struct rt_key *key, struct fib_result *res) - { - int err; -@@ -371,8 +376,10 @@ FRprintk("FAILURE\n"); - - void fib_select_default(const struct rt_key *key, struct fib_result *res) - { -- if (res->r && res->r->r_action == RTN_UNICAST && -- FIB_RES_GW(*res) && FIB_RES_NH(*res).nh_scope == RT_SCOPE_LINK) { -+ if (res->r && -+ (res->r->r_action == RTN_UNICAST || res->r->r_action == RTN_NAT) && -+ ((FIB_RES_GW(*res) && FIB_RES_NH(*res).nh_scope == RT_SCOPE_LINK) || -+ FIB_RES_NH(*res).nh_scope == RT_SCOPE_HOST)) { - struct fib_table *tb; - if ((tb = fib_get_table(res->r->r_table)) != NULL) - tb->tb_select_default(tb, key, res); ---- a/net/ipv4/fib_semantics.c -+++ b/net/ipv4/fib_semantics.c -@@ -48,6 +48,7 @@ - static struct fib_info *fib_info_list; - static rwlock_t fib_info_lock = RW_LOCK_UNLOCKED; - int fib_info_cnt; -+rwlock_t fib_nhflags_lock = RW_LOCK_UNLOCKED; - - #define for_fib_info() { struct fib_info *fi; \ - for (fi = fib_info_list; fi; fi = fi->fib_next) -@@ -150,7 +151,7 @@ static __inline__ int nh_comp(const stru - #ifdef CONFIG_NET_CLS_ROUTE - nh->nh_tclassid != onh->nh_tclassid || - #endif -- ((nh->nh_flags^onh->nh_flags)&~RTNH_F_DEAD)) -+ ((nh->nh_flags^onh->nh_flags)&~RTNH_F_BADSTATE)) - return -1; - onh++; - } endfor_nexthops(fi); -@@ -166,7 +167,7 @@ static __inline__ struct fib_info * fib_ - nfi->fib_prefsrc == fi->fib_prefsrc && - nfi->fib_priority == fi->fib_priority && - memcmp(nfi->fib_metrics, fi->fib_metrics, sizeof(fi->fib_metrics)) == 0 && -- ((nfi->fib_flags^fi->fib_flags)&~RTNH_F_DEAD) == 0 && -+ ((nfi->fib_flags^fi->fib_flags)&~RTNH_F_BADSTATE) == 0 && - (nfi->fib_nhs == 0 || nh_comp(fi, nfi) == 0)) - return fi; - } endfor_fib_info(); -@@ -365,8 +366,11 @@ static int fib_check_nh(const struct rtm - return -EINVAL; - if ((dev = __dev_get_by_index(nh->nh_oif)) == NULL) - return -ENODEV; -- if (!(dev->flags&IFF_UP)) -- return -ENETDOWN; -+ if (!(dev->flags&IFF_UP)) { -+ if (fi->fib_protocol != RTPROT_STATIC) -+ return -ENETDOWN; -+ nh->nh_flags |= RTNH_F_DEAD; -+ } - nh->nh_dev = dev; - dev_hold(dev); - nh->nh_scope = RT_SCOPE_LINK; -@@ -380,23 +384,48 @@ static int fib_check_nh(const struct rtm - /* It is not necessary, but requires a bit of thinking */ - if (key.scope < RT_SCOPE_LINK) - key.scope = RT_SCOPE_LINK; -- if ((err = fib_lookup(&key, &res)) != 0) -- return err; -- err = -EINVAL; -- if (res.type != RTN_UNICAST && res.type != RTN_LOCAL) -- goto out; -- nh->nh_scope = res.scope; -- nh->nh_oif = FIB_RES_OIF(res); -- if ((nh->nh_dev = FIB_RES_DEV(res)) == NULL) -- goto out; -- dev_hold(nh->nh_dev); -- err = -ENETDOWN; -- if (!(nh->nh_dev->flags & IFF_UP)) -- goto out; -- err = 0; -+ -+ err = fib_lookup(&key, &res); -+ if (err) { -+ struct in_device *in_dev; -+ -+ if (err != -ENETUNREACH || -+ fi->fib_protocol != RTPROT_STATIC) -+ return err; -+ -+ in_dev = inetdev_by_index(nh->nh_oif); -+ if (in_dev == NULL || -+ in_dev->dev->flags & IFF_UP) { -+ if (in_dev) -+ in_dev_put(in_dev); -+ return err; -+ } -+ nh->nh_flags |= RTNH_F_DEAD; -+ nh->nh_scope = RT_SCOPE_LINK; -+ nh->nh_dev = in_dev->dev; -+ dev_hold(nh->nh_dev); -+ in_dev_put(in_dev); -+ } else { -+ err = -EINVAL; -+ if (res.type != RTN_UNICAST && res.type != RTN_LOCAL) -+ goto out; -+ nh->nh_scope = res.scope; -+ nh->nh_oif = FIB_RES_OIF(res); -+ if ((nh->nh_dev = FIB_RES_DEV(res)) == NULL) -+ goto out; -+ dev_hold(nh->nh_dev); -+ if (!(nh->nh_dev->flags & IFF_UP)) { -+ if (fi->fib_protocol != RTPROT_STATIC) { -+ err = -ENETDOWN; -+ goto out; -+ } -+ nh->nh_flags |= RTNH_F_DEAD; -+ } -+ err = 0; - out: -- fib_res_put(&res); -- return err; -+ fib_res_put(&res); -+ return err; -+ } - } else { - struct in_device *in_dev; - -@@ -407,8 +436,11 @@ out: - if (in_dev == NULL) - return -ENODEV; - if (!(in_dev->dev->flags&IFF_UP)) { -- in_dev_put(in_dev); -- return -ENETDOWN; -+ if (fi->fib_protocol != RTPROT_STATIC) { -+ in_dev_put(in_dev); -+ return -ENETDOWN; -+ } -+ nh->nh_flags |= RTNH_F_DEAD; - } - nh->nh_dev = in_dev->dev; - dev_hold(nh->nh_dev); -@@ -606,8 +638,12 @@ fib_semantic_match(int type, struct fib_ - for_nexthops(fi) { - if (nh->nh_flags&RTNH_F_DEAD) - continue; -- if (!key->oif || key->oif == nh->nh_oif) -- break; -+ if (key->oif && key->oif != nh->nh_oif) -+ continue; -+ if (key->gw && key->gw != nh->nh_gw && -+ nh->nh_gw && nh->nh_scope == RT_SCOPE_LINK) -+ continue; -+ break; - } - #ifdef CONFIG_IP_ROUTE_MULTIPATH - if (nhsel < fi->fib_nhs) { -@@ -873,22 +909,35 @@ int fib_sync_down(u32 local, struct net_ - if (local && fi->fib_prefsrc == local) { - fi->fib_flags |= RTNH_F_DEAD; - ret++; -- } else if (dev && fi->fib_nhs) { -+ } else if (fi->fib_nhs) { - int dead = 0; - - change_nexthops(fi) { -- if (nh->nh_flags&RTNH_F_DEAD) -- dead++; -- else if (nh->nh_dev == dev && -- nh->nh_scope != scope) { -- nh->nh_flags |= RTNH_F_DEAD; -+ if (nh->nh_flags&RTNH_F_DEAD) { -+ if (fi->fib_protocol!=RTPROT_STATIC || -+ nh->nh_dev == NULL || -+ !__in_dev_get(nh->nh_dev) || -+ nh->nh_dev->flags&IFF_UP) -+ dead++; -+ } else if ((nh->nh_dev == dev && dev && -+ nh->nh_scope != scope) || -+ (local == nh->nh_gw && local && -+ nh->nh_oif)) { -+ write_lock_bh(&fib_nhflags_lock); - #ifdef CONFIG_IP_ROUTE_MULTIPATH -- spin_lock_bh(&fib_multipath_lock); -+ spin_lock(&fib_multipath_lock); -+ nh->nh_flags |= RTNH_F_DEAD; - fi->fib_power -= nh->nh_power; - nh->nh_power = 0; -- spin_unlock_bh(&fib_multipath_lock); -+ spin_unlock(&fib_multipath_lock); -+#else -+ nh->nh_flags |= RTNH_F_DEAD; - #endif -- dead++; -+ write_unlock_bh(&fib_nhflags_lock); -+ if (fi->fib_protocol!=RTPROT_STATIC || -+ force || -+ (dev && __in_dev_get(dev) == NULL)) -+ dead++; - } - #ifdef CONFIG_IP_ROUTE_MULTIPATH - if (force > 1 && nh->nh_dev == dev) { -@@ -906,37 +955,55 @@ int fib_sync_down(u32 local, struct net_ - return ret; - } - --#ifdef CONFIG_IP_ROUTE_MULTIPATH -- - /* -- Dead device goes up. We wake up dead nexthops. -- It takes sense only on multipath routes. -+ Dead device goes up or new address is added. We wake up dead nexthops. - */ - - int fib_sync_up(struct net_device *dev) - { -- int ret = 0; -+ struct rt_key key; -+ struct fib_result res; -+ int ret, rep; - -+repeat: - if (!(dev->flags&IFF_UP)) - return 0; - -+ ret = 0; -+ rep = 0; - for_fib_info() { - int alive = 0; - - change_nexthops(fi) { -- if (!(nh->nh_flags&RTNH_F_DEAD)) { -- alive++; -+ if (!(nh->nh_flags&RTNH_F_DEAD)) - continue; -- } - if (nh->nh_dev == NULL || !(nh->nh_dev->flags&IFF_UP)) - continue; - if (nh->nh_dev != dev || __in_dev_get(dev) == NULL) - continue; -+ if (nh->nh_gw && fi->fib_protocol == RTPROT_STATIC) { -+ memset(&key, 0, sizeof(key)); -+ key.dst = nh->nh_gw; -+ key.oif = nh->nh_oif; -+ key.scope = nh->nh_scope; -+ if (fib_lookup(&key, &res) != 0) -+ continue; -+ if (res.type != RTN_UNICAST && -+ res.type != RTN_LOCAL) { -+ fib_res_put(&res); -+ continue; -+ } -+ nh->nh_scope = res.scope; -+ fib_res_put(&res); -+ rep = 1; -+ } - alive++; -+#ifdef CONFIG_IP_ROUTE_MULTIPATH - spin_lock_bh(&fib_multipath_lock); - nh->nh_power = 0; - nh->nh_flags &= ~RTNH_F_DEAD; - spin_unlock_bh(&fib_multipath_lock); -+#endif - } endfor_nexthops(fi) - - if (alive > 0) { -@@ -944,9 +1011,13 @@ int fib_sync_up(struct net_device *dev) - ret++; - } - } endfor_fib_info(); -+ if (rep) -+ goto repeat; - return ret; - } - -+#ifdef CONFIG_IP_ROUTE_MULTIPATH -+ - /* - The algorithm is suboptimal, but it provides really - fair weighted route distribution. -@@ -955,24 +1026,45 @@ int fib_sync_up(struct net_device *dev) - void fib_select_multipath(const struct rt_key *key, struct fib_result *res) - { - struct fib_info *fi = res->fi; -- int w; -+ int w, alive; - - spin_lock_bh(&fib_multipath_lock); -+ if (key->oif) { -+ int sel = -1; -+ w = -1; -+ change_nexthops(fi) { -+ if (key->oif != nh->nh_oif) -+ continue; -+ if (key->gw && key->gw != nh->nh_gw && -+ nh->nh_gw && nh->nh_scope == RT_SCOPE_LINK) -+ continue; -+ if (!(nh->nh_flags&RTNH_F_BADSTATE)) { -+ if (nh->nh_power > w) { -+ w = nh->nh_power; -+ sel = nhsel; -+ } -+ } -+ } endfor_nexthops(fi); -+ if (sel >= 0) { -+ spin_unlock_bh(&fib_multipath_lock); -+ res->nh_sel = sel; -+ return; -+ } -+ goto last_resort; -+ } -+ -+repeat: - if (fi->fib_power <= 0) { - int power = 0; - change_nexthops(fi) { -- if (!(nh->nh_flags&RTNH_F_DEAD)) { -+ if (!(nh->nh_flags&RTNH_F_BADSTATE)) { - power += nh->nh_weight; - nh->nh_power = nh->nh_weight; - } - } endfor_nexthops(fi); - fi->fib_power = power; -- if (power <= 0) { -- spin_unlock_bh(&fib_multipath_lock); -- /* Race condition: route has just become dead. */ -- res->nh_sel = 0; -- return; -- } -+ if (power <= 0) -+ goto last_resort; - } - - -@@ -982,20 +1074,40 @@ void fib_select_multipath(const struct r - - w = jiffies % fi->fib_power; - -+ alive = 0; - change_nexthops(fi) { -- if (!(nh->nh_flags&RTNH_F_DEAD) && nh->nh_power) { -+ if (!(nh->nh_flags&RTNH_F_BADSTATE) && nh->nh_power) { - if ((w -= nh->nh_power) <= 0) { - nh->nh_power--; - fi->fib_power--; -- res->nh_sel = nhsel; - spin_unlock_bh(&fib_multipath_lock); -+ res->nh_sel = nhsel; - return; - } -+ alive = 1; -+ } -+ } endfor_nexthops(fi); -+ if (alive) { -+ fi->fib_power = 0; -+ goto repeat; -+ } -+ -+last_resort: -+ -+ for_nexthops(fi) { -+ if (!(nh->nh_flags&RTNH_F_DEAD)) { -+ if (key->oif && key->oif != nh->nh_oif) -+ continue; -+ if (key->gw && key->gw != nh->nh_gw && -+ nh->nh_gw && nh->nh_scope == RT_SCOPE_LINK) -+ continue; -+ spin_unlock_bh(&fib_multipath_lock); -+ res->nh_sel = nhsel; -+ return; - } - } endfor_nexthops(fi); - - /* Race condition: route has just become dead. */ -- res->nh_sel = 0; - spin_unlock_bh(&fib_multipath_lock); - } - #endif ---- a/net/ipv4/ip_nat_dumb.c -+++ b/net/ipv4/ip_nat_dumb.c -@@ -124,6 +124,7 @@ ip_do_nat(struct sk_buff *skb) - key.dst = ciph->saddr; - key.iif = skb->dev->ifindex; - key.oif = 0; -+ key.gw = 0; - #ifdef CONFIG_IP_ROUTE_TOS - key.tos = RT_TOS(ciph->tos); - #endif ---- a/net/ipv4/netfilter/ip_fw_compat_masq.c -+++ b/net/ipv4/netfilter/ip_fw_compat_masq.c -@@ -41,6 +41,10 @@ do_masquerade(struct sk_buff **pskb, con - enum ip_conntrack_info ctinfo; - struct ip_conntrack *ct; - unsigned int ret; -+ struct rtable *rt, *skb_rt; -+ struct net_device *skb_dev; -+ __u32 saddr; -+ int new; - - /* Sorry, only ICMP, TCP and UDP. */ - if (iph->protocol != IPPROTO_ICMP -@@ -64,22 +68,28 @@ do_masquerade(struct sk_buff **pskb, con - } - - info = &ct->nat.info; -+ iph = (*pskb)->nh.iph; -+ saddr = iph->saddr; -+ new = 0; - - WRITE_LOCK(&ip_nat_lock); - /* Setup the masquerade, if not already */ - if (!info->initialized) { - u_int32_t newsrc; -- struct rtable *rt; - struct ip_nat_multi_range range; - -+ skb_rt = (struct rtable *) (*pskb)->dst; -+ skb_dev = skb_rt->u.dst.dev; - /* Pass 0 instead of saddr, since it's going to be changed - anyway. */ -- if (ip_route_output(&rt, iph->daddr, 0, 0, 0) != 0) { -+ if (ip_route_output_lookup(&rt, iph->daddr, 0, RT_TOS(iph->tos), -+ skb_dev? skb_dev->ifindex : 0, -+ skb_dev? skb_rt->rt_gateway : 0) != 0) { -+ WRITE_UNLOCK(&ip_nat_lock); - DEBUGP("ipnat_rule_masquerade: Can't reroute.\n"); - return NF_DROP; - } -- newsrc = inet_select_addr(rt->u.dst.dev, rt->rt_gateway, -- RT_SCOPE_UNIVERSE); -+ newsrc = rt->rt_src; - ip_rt_put(rt); - range = ((struct ip_nat_multi_range) - { 1, -@@ -92,11 +102,31 @@ do_masquerade(struct sk_buff **pskb, con - WRITE_UNLOCK(&ip_nat_lock); - return ret; - } -+ new = 1; - } else - DEBUGP("Masquerading already done on this conn.\n"); - WRITE_UNLOCK(&ip_nat_lock); - -- return do_bindings(ct, ctinfo, info, NF_IP_POST_ROUTING, pskb); -+ ret = do_bindings(ct, ctinfo, info, NF_IP_POST_ROUTING, pskb); -+ if (ret != NF_ACCEPT || saddr == (*pskb)->nh.iph->saddr || new) -+ return ret; -+ -+ iph = (*pskb)->nh.iph; -+ if (ip_route_output(&rt, iph->daddr, iph->saddr, RT_TOS(iph->tos), 0) != 0) -+ return NF_DROP; -+ -+ skb_rt = (struct rtable *) (*pskb)->dst; -+ skb_dev = skb_rt->u.dst.dev; -+ if (skb_dev != rt->u.dst.dev || rt->rt_gateway != skb_rt->rt_gateway) { -+ if (skb_dev != rt->u.dst.dev) { -+ /* TODO: check the new mtu and reply FRAG_NEEDED */ -+ } -+ dst_release((*pskb)->dst); -+ (*pskb)->dst = &rt->u.dst; -+ } else { -+ ip_rt_put(rt); -+ } -+ return NF_ACCEPT; - } - - void ---- a/net/ipv4/netfilter/ip_nat_core.c -+++ b/net/ipv4/netfilter/ip_nat_core.c -@@ -994,6 +994,60 @@ icmp_reply_translation(struct sk_buff *s - return NF_ACCEPT; - } - -+unsigned int -+ip_nat_route_input(unsigned int hooknum, -+ struct sk_buff **pskb, -+ const struct net_device *in, -+ const struct net_device *out, -+ int (*okfn)(struct sk_buff *)) -+{ -+ struct sk_buff *skb = *pskb; -+ struct iphdr *iph; -+ struct ip_conntrack *ct; -+ enum ip_conntrack_info ctinfo; -+ struct ip_nat_info *info; -+ enum ip_conntrack_dir dir; -+ __u32 saddr; -+ int i; -+ -+ if (!(ct = ip_conntrack_get(skb, &ctinfo))) -+ return NF_ACCEPT; -+ -+ info = &ct->nat.info; -+ if (!info->initialized) -+ return NF_ACCEPT; -+ -+ if (skb->dst) -+ return NF_ACCEPT; -+ -+ if (skb->len < sizeof(struct iphdr)) -+ return NF_ACCEPT; -+ -+ iph = skb->nh.iph; -+ saddr = iph->saddr; -+ hooknum = NF_IP_POST_ROUTING; -+ dir = CTINFO2DIR(ctinfo); -+ -+ READ_LOCK(&ip_nat_lock); -+ for (i = 0; i < info->num_manips; i++) { -+ if (info->manips[i].direction == dir -+ && info->manips[i].hooknum == hooknum -+ && info->manips[i].maniptype == IP_NAT_MANIP_SRC) { -+ saddr = info->manips[i].manip.ip; -+ } -+ } -+ READ_UNLOCK(&ip_nat_lock); -+ -+ if (saddr == iph->saddr) -+ return NF_ACCEPT; -+ -+ if (ip_route_input_lookup(skb, iph->daddr, iph->saddr, iph->tos, -+ skb->dev, saddr)) -+ return NF_DROP; -+ -+ return NF_ACCEPT; -+} -+ - int __init ip_nat_init(void) - { - size_t i; ---- a/net/ipv4/netfilter/ip_nat_standalone.c -+++ b/net/ipv4/netfilter/ip_nat_standalone.c -@@ -245,6 +245,9 @@ ip_nat_local_fn(unsigned int hooknum, - /* Before packet filtering, change destination */ - static struct nf_hook_ops ip_nat_in_ops - = { { NULL, NULL }, ip_nat_in, PF_INET, NF_IP_PRE_ROUTING, NF_IP_PRI_NAT_DST }; -+/* Before routing, route before mangling */ -+static struct nf_hook_ops ip_nat_inr_ops -+= { { NULL, NULL }, ip_nat_route_input, PF_INET, NF_IP_PRE_ROUTING, NF_IP_PRI_LAST-1 }; - /* After packet filtering, change source */ - static struct nf_hook_ops ip_nat_out_ops - = { { NULL, NULL }, ip_nat_out, PF_INET, NF_IP_POST_ROUTING, NF_IP_PRI_NAT_SRC}; -@@ -313,10 +316,15 @@ static int init_or_cleanup(int init) - printk("ip_nat_init: can't register in hook.\n"); - goto cleanup_nat; - } -+ ret = nf_register_hook(&ip_nat_inr_ops); -+ if (ret < 0) { -+ printk("ip_nat_init: can't register inr hook.\n"); -+ goto cleanup_inops; -+ } - ret = nf_register_hook(&ip_nat_out_ops); - if (ret < 0) { - printk("ip_nat_init: can't register out hook.\n"); -- goto cleanup_inops; -+ goto cleanup_inrops; - } - ret = nf_register_hook(&ip_nat_local_out_ops); - if (ret < 0) { -@@ -336,6 +344,8 @@ static int init_or_cleanup(int init) - nf_unregister_hook(&ip_nat_local_out_ops); - cleanup_outops: - nf_unregister_hook(&ip_nat_out_ops); -+ cleanup_inrops: -+ nf_unregister_hook(&ip_nat_inr_ops); - cleanup_inops: - nf_unregister_hook(&ip_nat_in_ops); - cleanup_nat: ---- a/net/ipv4/netfilter/ipt_MASQUERADE.c -+++ b/net/ipv4/netfilter/ipt_MASQUERADE.c -@@ -87,7 +87,8 @@ masquerade_target(struct sk_buff **pskb, - key.dst = (*pskb)->nh.iph->daddr; - key.src = 0; /* Unknown: that's what we're trying to establish */ - key.tos = RT_TOS((*pskb)->nh.iph->tos)|RTO_CONN; -- key.oif = 0; -+ key.oif = out->ifindex; -+ key.gw = ((struct rtable *) (*pskb)->dst)->rt_gateway; - #ifdef CONFIG_IP_ROUTE_FWMARK - key.fwmark = (*pskb)->nfmark; - #endif -@@ -98,13 +99,6 @@ masquerade_target(struct sk_buff **pskb, - " No route: Rusty's brain broke!\n"); - return NF_DROP; - } -- if (rt->u.dst.dev != out) { -- if (net_ratelimit()) -- printk("MASQUERADE:" -- " Route sent us somewhere else.\n"); -- ip_rt_put(rt); -- return NF_DROP; -- } - - newsrc = rt->rt_src; - DEBUGP("newsrc = %u.%u.%u.%u\n", NIPQUAD(newsrc)); ---- a/net/ipv4/route.c -+++ b/net/ipv4/route.c -@@ -919,6 +919,7 @@ void ip_rt_redirect(u32 old_gw, u32 dadd - - /* Gateway is different ... */ - rt->rt_gateway = new_gw; -+ if (rt->key.gw) rt->key.gw = new_gw; - - /* Redirect received -> path was valid */ - dst_confirm(&rth->u.dst); -@@ -1343,6 +1344,7 @@ static int ip_route_input_mc(struct sk_b - rth->key.fwmark = skb->nfmark; - #endif - rth->key.src = saddr; -+ rth->key.lsrc = 0; - rth->rt_src = saddr; - #ifdef CONFIG_IP_ROUTE_NAT - rth->rt_dst_map = daddr; -@@ -1356,6 +1358,7 @@ static int ip_route_input_mc(struct sk_b - rth->u.dst.dev = &loopback_dev; - dev_hold(rth->u.dst.dev); - rth->key.oif = 0; -+ rth->key.gw = 0; - rth->rt_gateway = daddr; - rth->rt_spec_dst= spec_dst; - rth->rt_type = RTN_MULTICAST; -@@ -1395,7 +1398,7 @@ e_inval: - */ - - int ip_route_input_slow(struct sk_buff *skb, u32 daddr, u32 saddr, -- u8 tos, struct net_device *dev) -+ u8 tos, struct net_device *dev, u32 lsrc) - { - struct rt_key key; - struct fib_result res; -@@ -1415,16 +1418,17 @@ int ip_route_input_slow(struct sk_buff * - goto out; - - key.dst = daddr; -- key.src = saddr; -+ key.src = lsrc? : saddr; - key.tos = tos; - #ifdef CONFIG_IP_ROUTE_FWMARK - key.fwmark = skb->nfmark; - #endif -- key.iif = dev->ifindex; -+ key.iif = lsrc? loopback_dev.ifindex : dev->ifindex; - key.oif = 0; -+ key.gw = 0; - key.scope = RT_SCOPE_UNIVERSE; - -- hash = rt_hash_code(daddr, saddr ^ (key.iif << 5), tos); -+ hash = rt_hash_code(daddr, saddr ^ (dev->ifindex << 5), tos); - - /* Check for the most weird martians, which can be not detected - by fib_lookup. -@@ -1445,6 +1449,12 @@ int ip_route_input_slow(struct sk_buff * - if (BADCLASS(daddr) || ZERONET(daddr) || LOOPBACK(daddr)) - goto martian_destination; - -+ if (lsrc) { -+ if (MULTICAST(lsrc) || BADCLASS(lsrc) || -+ ZERONET(lsrc) || LOOPBACK(lsrc)) -+ goto e_inval; -+ } -+ - /* - * Now we are ready to route packet. - */ -@@ -1454,6 +1464,10 @@ int ip_route_input_slow(struct sk_buff * - goto no_route; - } - free_res = 1; -+ if (lsrc && res.type != RTN_UNICAST && res.type != RTN_NAT) -+ goto e_inval; -+ key.iif = dev->ifindex; -+ key.src = saddr; - - rt_cache_stat[smp_processor_id()].in_slow_tot++; - -@@ -1464,7 +1478,7 @@ int ip_route_input_slow(struct sk_buff * - - if (1) { - u32 src_map = saddr; -- if (res.r) -+ if (res.r && !lsrc) - src_map = fib_rules_policy(saddr, &res, &flags); - - if (res.type == RTN_NAT) { -@@ -1503,8 +1517,9 @@ int ip_route_input_slow(struct sk_buff * - if (res.type != RTN_UNICAST) - goto martian_destination; - -+ fib_select_default(&key, &res); - #ifdef CONFIG_IP_ROUTE_MULTIPATH -- if (res.fi->fib_nhs > 1 && key.oif == 0) -+ if (res.fi->fib_nhs > 1) - fib_select_multipath(&key, &res); - #endif - out_dev = in_dev_get(FIB_RES_DEV(res)); -@@ -1524,6 +1539,7 @@ int ip_route_input_slow(struct sk_buff * - flags |= RTCF_DIRECTSRC; - - if (out_dev == in_dev && err && !(flags & (RTCF_NAT | RTCF_MASQ)) && -+ !lsrc && - (IN_DEV_SHARED_MEDIA(out_dev) || - inet_addr_onlink(out_dev, saddr, FIB_RES_GW(res)))) - flags |= RTCF_DOREDIRECT; -@@ -1550,6 +1566,7 @@ int ip_route_input_slow(struct sk_buff * - #endif - rth->key.src = saddr; - rth->rt_src = saddr; -+ rth->key.lsrc = lsrc; - rth->rt_gateway = daddr; - #ifdef CONFIG_IP_ROUTE_NAT - rth->rt_src_map = key.src; -@@ -1562,6 +1579,7 @@ int ip_route_input_slow(struct sk_buff * - rth->u.dst.dev = out_dev->dev; - dev_hold(rth->u.dst.dev); - rth->key.oif = 0; -+ rth->key.gw = 0; - rth->rt_spec_dst= spec_dst; - - rth->u.dst.input = ip_forward; -@@ -1572,7 +1590,8 @@ int ip_route_input_slow(struct sk_buff * - rth->rt_flags = flags; - - #ifdef CONFIG_NET_FASTROUTE -- if (netdev_fastroute && !(flags&(RTCF_NAT|RTCF_MASQ|RTCF_DOREDIRECT))) { -+ if (netdev_fastroute && !(flags&(RTCF_NAT|RTCF_MASQ|RTCF_DOREDIRECT)) && -+ !lsrc) { - struct net_device *odev = rth->u.dst.dev; - if (odev != dev && - dev->accept_fastpath && -@@ -1595,6 +1614,8 @@ out: return err; - brd_input: - if (skb->protocol != htons(ETH_P_IP)) - goto e_inval; -+ if (lsrc) -+ goto e_inval; - - if (ZERONET(saddr)) - spec_dst = inet_select_addr(dev, 0, RT_SCOPE_LINK); -@@ -1627,6 +1648,7 @@ local_input: - #endif - rth->key.src = saddr; - rth->rt_src = saddr; -+ rth->key.lsrc = 0; - #ifdef CONFIG_IP_ROUTE_NAT - rth->rt_dst_map = key.dst; - rth->rt_src_map = key.src; -@@ -1639,6 +1661,7 @@ local_input: - rth->u.dst.dev = &loopback_dev; - dev_hold(rth->u.dst.dev); - rth->key.oif = 0; -+ rth->key.gw = 0; - rth->rt_gateway = daddr; - rth->rt_spec_dst= spec_dst; - rth->u.dst.input= ip_local_deliver; -@@ -1704,8 +1727,9 @@ martian_source: - goto e_inval; - } - --int ip_route_input(struct sk_buff *skb, u32 daddr, u32 saddr, -- u8 tos, struct net_device *dev) -+static inline int -+ip_route_input_cached(struct sk_buff *skb, u32 daddr, u32 saddr, -+ u8 tos, struct net_device *dev, u32 lsrc) - { - struct rtable * rth; - unsigned hash; -@@ -1719,6 +1743,7 @@ int ip_route_input(struct sk_buff *skb, - if (rth->key.dst == daddr && - rth->key.src == saddr && - rth->key.iif == iif && -+ rth->key.lsrc == lsrc && - rth->key.oif == 0 && - #ifdef CONFIG_IP_ROUTE_FWMARK - rth->key.fwmark == skb->nfmark && -@@ -1766,9 +1791,21 @@ int ip_route_input(struct sk_buff *skb, - read_unlock(&inetdev_lock); - return -EINVAL; - } -- return ip_route_input_slow(skb, daddr, saddr, tos, dev); -+ return ip_route_input_slow(skb, daddr, saddr, tos, dev, lsrc); -+} -+ -+int ip_route_input(struct sk_buff *skb, u32 daddr, u32 saddr, -+ u8 tos, struct net_device *dev) -+{ -+ return ip_route_input_cached(skb, daddr, saddr, tos, dev, 0); - } - -+int ip_route_input_lookup(struct sk_buff *skb, u32 daddr, u32 saddr, -+ u8 tos, struct net_device *dev, u32 lsrc) -+{ -+ return ip_route_input_cached(skb, daddr, saddr, tos, dev, lsrc); -+} -+ - /* - * Major route resolver routine. - */ -@@ -1791,6 +1828,7 @@ int ip_route_output_slow(struct rtable * - key.tos = tos & IPTOS_RT_MASK; - key.iif = loopback_dev.ifindex; - key.oif = oldkey->oif; -+ key.gw = oldkey->gw; - #ifdef CONFIG_IP_ROUTE_FWMARK - key.fwmark = oldkey->fwmark; - #endif -@@ -1880,6 +1918,7 @@ int ip_route_output_slow(struct rtable * - dev_out = &loopback_dev; - dev_hold(dev_out); - key.oif = loopback_dev.ifindex; -+ key.gw = 0; - res.type = RTN_LOCAL; - flags |= RTCF_LOCAL; - goto make_route; -@@ -1887,7 +1926,7 @@ int ip_route_output_slow(struct rtable * - - if (fib_lookup(&key, &res)) { - res.fi = NULL; -- if (oldkey->oif) { -+ if (oldkey->oif && dev_out->flags&IFF_UP) { - /* Apparently, routing tables are wrong. Assume, - that the destination is on link. - -@@ -1930,6 +1969,7 @@ int ip_route_output_slow(struct rtable * - dev_out = &loopback_dev; - dev_hold(dev_out); - key.oif = dev_out->ifindex; -+ key.gw = 0; - if (res.fi) - fib_info_put(res.fi); - res.fi = NULL; -@@ -1937,13 +1977,12 @@ int ip_route_output_slow(struct rtable * - goto make_route; - } - -+ if (res.type == RTN_UNICAST) -+ fib_select_default(&key, &res); - #ifdef CONFIG_IP_ROUTE_MULTIPATH -- if (res.fi->fib_nhs > 1 && key.oif == 0) -+ if (res.fi->fib_nhs > 1) - fib_select_multipath(&key, &res); -- else - #endif -- if (!res.prefixlen && res.type == RTN_UNICAST && !key.oif) -- fib_select_default(&key, &res); - - if (!key.src) - key.src = FIB_RES_PREFSRC(res); -@@ -2001,7 +2040,9 @@ make_route: - rth->key.tos = tos; - rth->key.src = oldkey->src; - rth->key.iif = 0; -+ rth->key.lsrc = 0; - rth->key.oif = oldkey->oif; -+ rth->key.gw = oldkey->gw; - #ifdef CONFIG_IP_ROUTE_FWMARK - rth->key.fwmark = oldkey->fwmark; - #endif -@@ -2080,6 +2121,7 @@ int ip_route_output_key(struct rtable ** - rth->key.src == key->src && - rth->key.iif == 0 && - rth->key.oif == key->oif && -+ rth->key.gw == key->gw && - #ifdef CONFIG_IP_ROUTE_FWMARK - rth->key.fwmark == key->fwmark && - #endif ---- a/net/netsyms.c -+++ b/net/netsyms.c -@@ -260,6 +260,7 @@ EXPORT_SYMBOL(inet_register_protosw); - EXPORT_SYMBOL(inet_unregister_protosw); - EXPORT_SYMBOL(ip_route_output_key); - EXPORT_SYMBOL(ip_route_input); -+EXPORT_SYMBOL(ip_route_input_lookup); - EXPORT_SYMBOL(icmp_send); - EXPORT_SYMBOL(icmp_statistics); - EXPORT_SYMBOL(icmp_err_convert); diff --git a/target/linux/generic-2.4/patches/801-usb_serial_endpoint_size.patch b/target/linux/generic-2.4/patches/801-usb_serial_endpoint_size.patch deleted file mode 100644 index 2e436f0..0000000 --- a/target/linux/generic-2.4/patches/801-usb_serial_endpoint_size.patch +++ /dev/null @@ -1,30 +0,0 @@ ---- a/drivers/usb/serial/usbserial.c -+++ b/drivers/usb/serial/usbserial.c -@@ -331,6 +331,7 @@ static void generic_shutdown (struct us - #ifdef CONFIG_USB_SERIAL_GENERIC - static __u16 vendor = 0x05f9; - static __u16 product = 0xffff; -+static int maxSize = 0; - - static struct usb_device_id generic_device_ids[2]; /* Initially all zeroes. */ - -@@ -1557,7 +1558,11 @@ static void * usb_serial_probe(struct us - err("No free urbs available"); - goto probe_error; - } -+#ifdef CONFIG_USB_SERIAL_GENERIC -+ buffer_size = (endpoint->wMaxPacketSize > maxSize) ? endpoint->wMaxPacketSize : maxSize; -+#else - buffer_size = endpoint->wMaxPacketSize; -+#endif - port->bulk_in_endpointAddress = endpoint->bEndpointAddress; - port->bulk_in_buffer = kmalloc (buffer_size, GFP_KERNEL); - if (!port->bulk_in_buffer) { -@@ -1921,4 +1926,7 @@ MODULE_PARM_DESC(vendor, "User specified - - MODULE_PARM(product, "h"); - MODULE_PARM_DESC(product, "User specified USB idProduct"); -+ -+MODULE_PARM(maxSize,"i"); -+MODULE_PARM_DESC(maxSize,"User specified USB endpoint size"); - #endif diff --git a/target/linux/generic-2.4/patches/802-usb_serial_3g_cards.patch b/target/linux/generic-2.4/patches/802-usb_serial_3g_cards.patch deleted file mode 100644 index 808e49c..0000000 --- a/target/linux/generic-2.4/patches/802-usb_serial_3g_cards.patch +++ /dev/null @@ -1,42 +0,0 @@ ---- a/drivers/usb/serial/usbserial.c -+++ b/drivers/usb/serial/usbserial.c -@@ -333,7 +333,7 @@ static __u16 vendor = 0x05f9; - static __u16 product = 0xffff; - static int maxSize = 0; - --static struct usb_device_id generic_device_ids[2]; /* Initially all zeroes. */ -+static struct usb_device_id generic_device_ids[9]; /* Initially all zeroes. */ - - /* All of the device info needed for the Generic Serial Converter */ - static struct usb_serial_device_type generic_device = { -@@ -1836,6 +1836,30 @@ static int __init usb_serial_init(void) - generic_device_ids[0].idVendor = vendor; - generic_device_ids[0].idProduct = product; - generic_device_ids[0].match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT; -+ /* Option 3G/UMTS 'Colt' */ -+ generic_device_ids[1].idVendor = 0x0af0; -+ generic_device_ids[1].idProduct = 0x5000; -+ generic_device_ids[1].match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT; -+ /* Option 3G/UMTS 'Fusion' */ -+ generic_device_ids[2].idVendor = 0x0af0; -+ generic_device_ids[2].idProduct = 0x6000; -+ generic_device_ids[2].match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT; -+ /* Option 3G/UMTS 'Fusion2' */ -+ generic_device_ids[3].idVendor = 0x0af0; -+ generic_device_ids[3].idProduct = 0x6300; -+ generic_device_ids[3].match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT; -+ /* Audiovox Aircard */ -+ generic_device_ids[4].idVendor = 0x0f3d; -+ generic_device_ids[4].idProduct = 0x0112; -+ generic_device_ids[4].match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT; -+ /* Huawei E600 */ -+ generic_device_ids[6].idVendor = 0x12d1; -+ generic_device_ids[6].idProduct = 0x1001; -+ generic_device_ids[6].match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT; -+ /* Merlin XU870 */ -+ generic_device_ids[7].idVendor = 0x1410; -+ generic_device_ids[7].idProduct = 0x1430; -+ generic_device_ids[7].match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT; - /* register our generic driver with ourselves */ - usb_serial_register (&generic_device); - #endif diff --git a/target/linux/generic-2.4/patches/804-watchdog_include.patch b/target/linux/generic-2.4/patches/804-watchdog_include.patch deleted file mode 100644 index c85ef22..0000000 --- a/target/linux/generic-2.4/patches/804-watchdog_include.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/include/linux/watchdog.h -+++ b/include/linux/watchdog.h -@@ -10,6 +10,7 @@ - #define _LINUX_WATCHDOG_H - - #include <linux/ioctl.h> -+#include <linux/types.h> - - #define WATCHDOG_IOCTL_BASE 'W' - diff --git a/target/linux/generic-2.4/patches/900-ocf-kconfig-integration.patch b/target/linux/generic-2.4/patches/900-ocf-kconfig-integration.patch deleted file mode 100644 index e176bf5..0000000 --- a/target/linux/generic-2.4/patches/900-ocf-kconfig-integration.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/crypto/Config.in -+++ b/crypto/Config.in -@@ -117,4 +117,6 @@ if [ "$CONFIG_CRYPTO" = "y" ]; then - tristate ' Testing module' CONFIG_CRYPTO_TEST - fi - -+source crypto/ocf/Config.in -+ - endmenu ---- a/crypto/Makefile -+++ b/crypto/Makefile -@@ -36,4 +36,9 @@ obj-$(CONFIG_CRYPTO_MICHAEL_MIC) += mich - - obj-$(CONFIG_CRYPTO_TEST) += tcrypt.o - -+mod-subdirs += ocf -+subdir-$(CONFIG_OCF_OCF) += ocf -+ocf-$(CONFIG_OCF_OCF) = ocf/ocfdrv.o -+obj-$(CONFIG_OCF_OCF) += $(ocf-y) -+ - include $(TOPDIR)/Rules.make diff --git a/target/linux/generic-2.4/patches/901-ocf-20100325.patch b/target/linux/generic-2.4/patches/901-ocf-20100325.patch deleted file mode 100644 index 6d0f522..0000000 --- a/target/linux/generic-2.4/patches/901-ocf-20100325.patch +++ /dev/null @@ -1,120 +0,0 @@ ---- a/drivers/char/random.c -+++ b/drivers/char/random.c -@@ -901,6 +901,65 @@ void add_blkdev_randomness(int major) - #define subRound(a, b, c, d, e, f, k, data) \ - ( e += ROTL( 5, a ) + f( b, c, d ) + k + data, b = ROTL( 30, b ) ) - -+/* -+ * random_input_words - add bulk entropy to pool -+ * -+ * @buf: buffer to add -+ * @wordcount: number of __u32 words to add -+ * @ent_count: total amount of entropy (in bits) to credit -+ * -+ * this provides bulk input of entropy to the input pool -+ * -+ */ -+void random_input_words(__u32 *buf, size_t wordcount, int ent_count) -+{ -+ if (!random_state) -+ return; -+ add_entropy_words(random_state, buf, wordcount); -+ -+ credit_entropy_store(random_state, ent_count); -+ -+ DEBUG_ENT("credited %d bits => %d\n", -+ ent_count, random_state->entropy_count); -+ /* -+ * Wake up waiting processes if we have enough -+ * entropy. -+ */ -+ if (random_state->entropy_count >= random_read_wakeup_thresh) -+ wake_up_interruptible(&random_read_wait); -+} -+EXPORT_SYMBOL(random_input_words); -+ -+/* -+ * random_input_wait - wait until random needs entropy -+ * -+ * this function sleeps until the /dev/random subsystem actually -+ * needs more entropy, and then return the amount of entropy -+ * that it would be nice to have added to the system. -+ */ -+int random_input_wait(void) -+{ -+ int count; -+ -+ if (!random_state) -+ return -1; -+ -+ wait_event_interruptible(random_write_wait, -+ random_state->entropy_count < random_write_wakeup_thresh); -+ -+ count = random_write_wakeup_thresh - random_state->entropy_count; -+ -+ /* likely we got woken up due to a signal */ -+ if (count <= 0) count = random_read_wakeup_thresh; -+ -+ DEBUG_ENT("requesting %d bits from input_wait()er %d<%d\n", -+ count, -+ random_state->entropy_count, random_write_wakeup_thresh); -+ -+ return count; -+} -+EXPORT_SYMBOL(random_input_wait); -+ - - static void SHATransform(__u32 digest[85], __u32 const data[16]) - { ---- a/fs/Makefile -+++ b/fs/Makefile -@@ -10,6 +10,8 @@ O_TARGET := fs.o - export-objs := filesystems.o open.o dcache.o buffer.o dquot.o - mod-subdirs := nls - -+export-objs += fcntl.o -+ - obj-y := open.o read_write.o devices.o file_table.o buffer.o \ - super.o block_dev.o char_dev.o stat.o exec.o pipe.o namei.o \ - fcntl.o ioctl.o readdir.o select.o fifo.o locks.o \ ---- a/fs/fcntl.c -+++ b/fs/fcntl.c -@@ -12,6 +12,7 @@ - #include <linux/slab.h> - #include <linux/iobuf.h> - #include <linux/ptrace.h> -+#include <linux/module.h> - - #include <asm/poll.h> - #include <asm/siginfo.h> -@@ -199,6 +200,7 @@ asmlinkage long sys_dup(unsigned int fil - ret = dupfd(file, 0); - return ret; - } -+EXPORT_SYMBOL(sys_dup); - - #define SETFL_MASK (O_APPEND | O_NONBLOCK | O_NDELAY | FASYNC | O_DIRECT) - ---- a/include/linux/miscdevice.h -+++ b/include/linux/miscdevice.h -@@ -15,6 +15,7 @@ - #define ADB_MOUSE_MINOR 10 - #define MK712_MINOR 15 /* MK712 touch screen */ - #define SYNTH_MINOR 25 -+#define CRYPTODEV_MINOR 70 /* OpenBSD cryptographic framework */ - #define WATCHDOG_MINOR 130 /* Watchdog timer */ - #define TEMP_MINOR 131 /* Temperature Sensor */ - #define RTC_MINOR 135 ---- a/include/linux/random.h -+++ b/include/linux/random.h -@@ -53,6 +53,10 @@ extern void add_mouse_randomness(__u32 m - extern void add_interrupt_randomness(int irq); - extern void add_blkdev_randomness(int major); - -+extern void random_input_words(__u32 *buf, size_t wordcount, int ent_count); -+extern int random_input_wait(void); -+#define HAS_RANDOM_INPUT_WAIT 1 -+ - extern void get_random_bytes(void *buf, int nbytes); - void generate_random_uuid(unsigned char uuid_out[16]); - |