diff options
Diffstat (limited to 'meta-facebook/meta-yosemite')
55 files changed, 4408 insertions, 536 deletions
diff --git a/meta-facebook/meta-yosemite/conf/bblayers.conf.sample b/meta-facebook/meta-yosemite/conf/bblayers.conf.sample index 8827e9d..6c7c0c9 100644 --- a/meta-facebook/meta-yosemite/conf/bblayers.conf.sample +++ b/meta-facebook/meta-yosemite/conf/bblayers.conf.sample @@ -11,6 +11,7 @@ BBLAYERS ?= " \ ##OEROOT##/meta-yocto-bsp \ ##OEROOT##/meta-openembedded/meta-oe \ ##OEROOT##/meta-openembedded/meta-networking \ + ##OEROOT##/meta-openembedded/meta-python \ ##OEROOT##/meta-openbmc \ ##OEROOT##/meta-openbmc/meta-aspeed \ ##OEROOT##/meta-openbmc/meta-facebook/meta-yosemite \ diff --git a/meta-facebook/meta-yosemite/conf/local.conf.sample b/meta-facebook/meta-yosemite/conf/local.conf.sample index 9204236..6da6659 100644 --- a/meta-facebook/meta-yosemite/conf/local.conf.sample +++ b/meta-facebook/meta-yosemite/conf/local.conf.sample @@ -138,3 +138,8 @@ EXTRA_USERS_PARAMS = " \ usermod -s /bin/bash root; \ usermod -p '\$1\$UGMqyqdG\$FZiylVFmRRfl9Z0Ue8G7e/' root; \ " + +OLDEST_KERNEL = "2.6.28" + +INHERIT += "blacklist" +PNBLACKLIST[glibc] = "glibc 2.21 does not work with our kernel 2.6.28" diff --git a/meta-facebook/meta-yosemite/conf/machine/yosemite.conf b/meta-facebook/meta-yosemite/conf/machine/yosemite.conf index cd48ed6..99d6caa 100644 --- a/meta-facebook/meta-yosemite/conf/machine/yosemite.conf +++ b/meta-facebook/meta-yosemite/conf/machine/yosemite.conf @@ -5,3 +5,5 @@ UBOOT_MACHINE_yosemite = "fbyosemite_config" require conf/machine/include/ast1250.inc + +TCLIBC = 'eglibc' diff --git a/meta-facebook/meta-yosemite/recipes-core/busybox/busybox/syslog.conf b/meta-facebook/meta-yosemite/recipes-core/busybox/busybox/syslog.conf new file mode 100644 index 0000000..f033341 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-core/busybox/busybox/syslog.conf @@ -0,0 +1,5 @@ +# /etc/syslog.conf Configuration file for busybox's syslogd utility +# Send emergency messages to the console +*.crit /mnt/data/logfile +# Store everything else +*.* /var/log/messages diff --git a/meta-facebook/meta-yosemite/recipes-core/busybox/busybox_%.bbappend b/meta-facebook/meta-yosemite/recipes-core/busybox/busybox_%.bbappend index b8641ee..0047f92 100644 --- a/meta-facebook/meta-yosemite/recipes-core/busybox/busybox_%.bbappend +++ b/meta-facebook/meta-yosemite/recipes-core/busybox/busybox_%.bbappend @@ -2,4 +2,5 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" SRC_URI += " \ file://busybox.cfg \ - "
\ No newline at end of file + file://syslog.conf \ + " diff --git a/meta-facebook/meta-yosemite/recipes-core/images/yosemite-image.inc b/meta-facebook/meta-yosemite/recipes-core/images/yosemite-image.inc index 5356c20..e316aa0 100644 --- a/meta-facebook/meta-yosemite/recipes-core/images/yosemite-image.inc +++ b/meta-facebook/meta-yosemite/recipes-core/images/yosemite-image.inc @@ -39,7 +39,9 @@ NTP_PKGS = " \ # Include modules in rootfs IMAGE_INSTALL += " \ kernel-modules \ + u-boot \ u-boot-fw-utils \ + healthd \ fbutils \ fan-ctrl \ watchdog-ctrl \ @@ -66,6 +68,13 @@ IMAGE_INSTALL += " \ power-util \ consoled \ cfg-util \ + fw-util \ + fpc-util \ + me-util \ + log-util \ + cherryPy \ + lldp-util \ + spatula \ " IMAGE_FEATURES += " \ diff --git a/meta-facebook/meta-yosemite/recipes-kernel/linux/files/defconfig b/meta-facebook/meta-yosemite/recipes-kernel/linux/files/defconfig new file mode 100644 index 0000000..d32f18e --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-kernel/linux/files/defconfig @@ -0,0 +1,1480 @@ +# +# Automatically generated make config: don't edit +# Linux kernel version: 2.6.28.9 +# Tue Feb 3 16:41:40 2015 +# +CONFIG_ARM=y +CONFIG_SYS_SUPPORTS_APM_EMULATION=y +CONFIG_GENERIC_GPIO=y +CONFIG_GENERIC_TIME=y +CONFIG_GENERIC_CLOCKEVENTS=y +CONFIG_MMU=y +# CONFIG_NO_IOPORT is not set +CONFIG_GENERIC_HARDIRQS=y +CONFIG_STACKTRACE_SUPPORT=y +CONFIG_HAVE_LATENCYTOP_SUPPORT=y +CONFIG_LOCKDEP_SUPPORT=y +CONFIG_TRACE_IRQFLAGS_SUPPORT=y +CONFIG_HARDIRQS_SW_RESEND=y +CONFIG_GENERIC_IRQ_PROBE=y +CONFIG_RWSEM_GENERIC_SPINLOCK=y +# CONFIG_ARCH_HAS_ILOG2_U32 is not set +# CONFIG_ARCH_HAS_ILOG2_U64 is not set +CONFIG_GENERIC_HWEIGHT=y +CONFIG_GENERIC_CALIBRATE_DELAY=y +CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y +CONFIG_VECTORS_BASE=0xffff0000 +CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" + +# +# General setup +# +CONFIG_EXPERIMENTAL=y +CONFIG_BROKEN_ON_SMP=y +CONFIG_INIT_ENV_ARG_LIMIT=32 +CONFIG_LOCALVERSION="" +# CONFIG_LOCALVERSION_AUTO is not set +CONFIG_KERNEL_GZIP=y +# CONFIG_KERNEL_BZIP2 is not set +# CONFIG_KERNEL_LZMA is not set +CONFIG_SWAP=y +CONFIG_SYSVIPC=y +CONFIG_SYSVIPC_SYSCTL=y +CONFIG_POSIX_MQUEUE=y +# CONFIG_BSD_PROCESS_ACCT is not set +# CONFIG_TASKSTATS is not set +# CONFIG_AUDIT is not set +CONFIG_IKCONFIG=m +CONFIG_IKCONFIG_PROC=y +CONFIG_LOG_BUF_SHIFT=16 +# CONFIG_CGROUPS is not set +# CONFIG_GROUP_SCHED is not set +CONFIG_SYSFS_DEPRECATED=y +CONFIG_SYSFS_DEPRECATED_V2=y +# CONFIG_RELAY is not set +CONFIG_NAMESPACES=y +# CONFIG_UTS_NS is not set +# CONFIG_IPC_NS is not set +# CONFIG_USER_NS is not set +# CONFIG_PID_NS is not set +CONFIG_BLK_DEV_INITRD=y +CONFIG_INITRAMFS_SOURCE="" +CONFIG_CC_OPTIMIZE_FOR_SIZE=y +CONFIG_SYSCTL=y +CONFIG_ANON_INODES=y +# CONFIG_EMBEDDED is not set +CONFIG_UID16=y +CONFIG_SYSCTL_SYSCALL=y +CONFIG_KALLSYMS=y +CONFIG_KALLSYMS_EXTRA_PASS=y +CONFIG_HOTPLUG=y +CONFIG_PRINTK=y +CONFIG_BUG=y +CONFIG_ELF_CORE=y +CONFIG_BASE_FULL=y +CONFIG_FUTEX=y +CONFIG_EPOLL=y +CONFIG_SIGNALFD=y +CONFIG_TIMERFD=y +CONFIG_EVENTFD=y +CONFIG_SHMEM=y +CONFIG_AIO=y +CONFIG_VM_EVENT_COUNTERS=y +CONFIG_SLUB_DEBUG=y +CONFIG_COMPAT_BRK=y +# CONFIG_SLAB is not set +CONFIG_SLUB=y +# CONFIG_SLOB is not set +# CONFIG_PROFILING is not set +# CONFIG_MARKERS is not set +CONFIG_HAVE_OPROFILE=y +# CONFIG_KPROBES is not set +CONFIG_HAVE_KPROBES=y +CONFIG_HAVE_KRETPROBES=y +CONFIG_HAVE_GENERIC_DMA_COHERENT=y +CONFIG_SLABINFO=y +CONFIG_RT_MUTEXES=y +# CONFIG_TINY_SHMEM is not set +CONFIG_BASE_SMALL=0 +CONFIG_MODULES=y +# CONFIG_MODULE_FORCE_LOAD is not set +CONFIG_MODULE_UNLOAD=y +# CONFIG_MODULE_FORCE_UNLOAD is not set +# CONFIG_MODVERSIONS is not set +# CONFIG_MODULE_SRCVERSION_ALL is not set +CONFIG_KMOD=y +CONFIG_BLOCK=y +# CONFIG_LBD is not set +# CONFIG_BLK_DEV_IO_TRACE is not set +# CONFIG_LSF is not set +# CONFIG_BLK_DEV_BSG is not set +# CONFIG_BLK_DEV_INTEGRITY is not set + +# +# IO Schedulers +# +CONFIG_IOSCHED_NOOP=y +CONFIG_IOSCHED_AS=y +CONFIG_IOSCHED_DEADLINE=y +CONFIG_IOSCHED_CFQ=y +# CONFIG_DEFAULT_AS is not set +# CONFIG_DEFAULT_DEADLINE is not set +CONFIG_DEFAULT_CFQ=y +# CONFIG_DEFAULT_NOOP is not set +CONFIG_DEFAULT_IOSCHED="cfq" +CONFIG_CLASSIC_RCU=y +CONFIG_FREEZER=y + +# +# System Type +# +CONFIG_ARCH_ASPEED=y +# CONFIG_ARCH_AAEC2000 is not set +# CONFIG_ARCH_INTEGRATOR is not set +# CONFIG_ARCH_REALVIEW is not set +# CONFIG_ARCH_VERSATILE is not set +# CONFIG_ARCH_AT91 is not set +# CONFIG_ARCH_CLPS7500 is not set +# CONFIG_ARCH_CLPS711X is not set +# CONFIG_ARCH_EBSA110 is not set +# CONFIG_ARCH_EP93XX is not set +# CONFIG_ARCH_FOOTBRIDGE is not set +# CONFIG_ARCH_NETX is not set +# CONFIG_ARCH_H720X is not set +# CONFIG_ARCH_IMX is not set +# CONFIG_ARCH_IOP13XX is not set +# CONFIG_ARCH_IOP32X is not set +# CONFIG_ARCH_IOP33X is not set +# CONFIG_ARCH_IXP23XX is not set +# CONFIG_ARCH_IXP2000 is not set +# CONFIG_ARCH_IXP4XX is not set +# CONFIG_ARCH_L7200 is not set +# CONFIG_ARCH_KIRKWOOD is not set +# CONFIG_ARCH_KS8695 is not set +# CONFIG_ARCH_NS9XXX is not set +# CONFIG_ARCH_LOKI is not set +# CONFIG_ARCH_MV78XX0 is not set +# CONFIG_ARCH_MXC is not set +# CONFIG_ARCH_ORION5X is not set +# CONFIG_ARCH_PNX4008 is not set +# CONFIG_ARCH_PXA is not set +# CONFIG_ARCH_RPC is not set +# CONFIG_ARCH_SA1100 is not set +# CONFIG_ARCH_S3C2410 is not set +# CONFIG_ARCH_SHARK is not set +# CONFIG_ARCH_LH7A40X is not set +# CONFIG_ARCH_DAVINCI is not set +# CONFIG_ARCH_OMAP is not set +# CONFIG_ARCH_MSM is not set +CONFIG_IRMP=y +# CONFIG_PCEXT is not set +# CONFIG_REMOTEFX is not set +# CONFIG_ARCH_AST1100 is not set +# CONFIG_ARCH_AST2100 is not set +# CONFIG_ARCH_AST2200 is not set +# CONFIG_ARCH_AST2300 is not set +CONFIG_ARCH_AST2400=y +CONFIG_YOSEMITE=y +# CONFIG_ARCH_AST2500 is not set + +# +# FLASH Chip Select +# +# CONFIG_AST_CS0_NOR is not set +# CONFIG_AST_CS0_NAND is not set +CONFIG_AST_CS0_SPI=y +# CONFIG_AST_CS0_NONE is not set +# CONFIG_AST_CS1_NOR is not set +# CONFIG_AST_CS1_NAND is not set +# CONFIG_AST_CS1_SPI is not set +CONFIG_AST_CS1_NONE=y +# CONFIG_AST_CS2_NOR is not set +# CONFIG_AST_CS2_NAND is not set +# CONFIG_AST_CS2_SPI is not set +CONFIG_AST_CS2_NONE=y +# CONFIG_AST_CS3_NOR is not set +# CONFIG_AST_CS3_NAND is not set +# CONFIG_AST_CS3_SPI is not set +CONFIG_AST_CS3_NONE=y +# CONFIG_AST_CS4_NOR is not set +# CONFIG_AST_CS4_NAND is not set +# CONFIG_AST_CS4_SPI is not set +CONFIG_AST_CS4_NONE=y +# CONFIG_ARCH_AST1070 is not set +# CONFIG_AST_SCU_LOCK is not set + +# +# Boot options +# + +# +# Power management +# +CONFIG_PLAT_ASPEED=y + +# +# Processor Type +# +CONFIG_CPU_32=y +CONFIG_CPU_ARM926T=y +CONFIG_CPU_32v5=y +CONFIG_CPU_ABRT_EV5TJ=y +CONFIG_CPU_PABRT_NOIFAR=y +CONFIG_CPU_CACHE_VIVT=y +CONFIG_CPU_COPY_V4WB=y +CONFIG_CPU_TLB_V4WBI=y +CONFIG_CPU_CP15=y +CONFIG_CPU_CP15_MMU=y + +# +# Processor Features +# +CONFIG_ARM_THUMB=y +# CONFIG_CPU_ICACHE_DISABLE is not set +# CONFIG_CPU_DCACHE_DISABLE is not set +# CONFIG_CPU_DCACHE_WRITETHROUGH is not set +# CONFIG_CPU_CACHE_ROUND_ROBIN is not set +# CONFIG_OUTER_CACHE is not set + +# +# Bus support +# +CONFIG_ARM_AMBA=y +# CONFIG_PCI_SYSCALL is not set +# CONFIG_ARCH_SUPPORTS_MSI is not set +# CONFIG_PCCARD is not set + +# +# Kernel Features +# +CONFIG_TICK_ONESHOT=y +CONFIG_NO_HZ=y +CONFIG_HIGH_RES_TIMERS=y +CONFIG_GENERIC_CLOCKEVENTS_BUILD=y +CONFIG_VMSPLIT_3G=y +# CONFIG_VMSPLIT_2G is not set +# CONFIG_VMSPLIT_1G is not set +CONFIG_PAGE_OFFSET=0xC0000000 +# CONFIG_PREEMPT is not set +CONFIG_HZ=100 +CONFIG_AEABI=y +CONFIG_OABI_COMPAT=y +CONFIG_ARCH_FLATMEM_HAS_HOLES=y +# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set +# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set +CONFIG_SELECT_MEMORY_MODEL=y +CONFIG_FLATMEM_MANUAL=y +# CONFIG_DISCONTIGMEM_MANUAL is not set +# CONFIG_SPARSEMEM_MANUAL is not set +CONFIG_FLATMEM=y +CONFIG_FLAT_NODE_MEM_MAP=y +CONFIG_PAGEFLAGS_EXTENDED=y +CONFIG_SPLIT_PTLOCK_CPUS=4096 +# CONFIG_RESOURCES_64BIT is not set +# CONFIG_PHYS_ADDR_T_64BIT is not set +CONFIG_ZONE_DMA_FLAG=0 +CONFIG_VIRT_TO_BUS=y +CONFIG_UNEVICTABLE_LRU=y +CONFIG_ALIGNMENT_TRAP=y + +# +# Boot options +# +CONFIG_ZBOOT_ROM_TEXT=0 +CONFIG_ZBOOT_ROM_BSS=0 +CONFIG_CMDLINE="" +# CONFIG_XIP_KERNEL is not set +# CONFIG_KEXEC is not set + +# +# CPU Power Management +# +# CONFIG_CPU_IDLE is not set + +# +# Floating point emulation +# + +# +# At least one emulation must be selected +# +CONFIG_FPE_NWFPE=y +CONFIG_FPE_NWFPE_XP=y +# CONFIG_FPE_FASTFPE is not set +CONFIG_VFP=y + +# +# Userspace binary formats +# +CONFIG_BINFMT_ELF=y +# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set +CONFIG_HAVE_AOUT=y +CONFIG_BINFMT_AOUT=y +# CONFIG_BINFMT_MISC is not set + +# +# Power management options +# +CONFIG_PM=y +# CONFIG_PM_DEBUG is not set +CONFIG_PM_SLEEP=y +CONFIG_SUSPEND=y +CONFIG_SUSPEND_FREEZER=y +# CONFIG_APM_EMULATION is not set +CONFIG_ARCH_SUSPEND_POSSIBLE=y +CONFIG_NET=y + +# +# Networking options +# +CONFIG_PACKET=y +# CONFIG_PACKET_MMAP is not set +CONFIG_UNIX=y +CONFIG_XFRM=y +# CONFIG_XFRM_USER is not set +# CONFIG_XFRM_SUB_POLICY is not set +# CONFIG_XFRM_MIGRATE is not set +# CONFIG_XFRM_STATISTICS is not set +# CONFIG_NET_KEY is not set +CONFIG_INET=y +CONFIG_IP_MULTICAST=y +# CONFIG_IP_ADVANCED_ROUTER is not set +CONFIG_IP_FIB_HASH=y +CONFIG_IP_PNP=y +CONFIG_IP_PNP_DHCP=y +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_SYN_COOKIES is not set +# CONFIG_INET_AH is not set +# CONFIG_INET_ESP is not set +# CONFIG_INET_IPCOMP is not set +# CONFIG_INET_XFRM_TUNNEL is not set +CONFIG_INET_TUNNEL=m +CONFIG_INET_XFRM_MODE_TRANSPORT=y +CONFIG_INET_XFRM_MODE_TUNNEL=y +CONFIG_INET_XFRM_MODE_BEET=y +# CONFIG_INET_LRO is not set +CONFIG_INET_DIAG=y +CONFIG_INET_TCP_DIAG=y +# CONFIG_TCP_CONG_ADVANCED is not set +CONFIG_TCP_CONG_CUBIC=y +CONFIG_DEFAULT_TCP_CONG="cubic" +# CONFIG_TCP_MD5SIG is not set +CONFIG_IPV6=m +# CONFIG_IPV6_PRIVACY is not set +# CONFIG_IPV6_ROUTER_PREF is not set +# CONFIG_IPV6_OPTIMISTIC_DAD is not set +# CONFIG_INET6_AH is not set +# CONFIG_INET6_ESP is not set +# CONFIG_INET6_IPCOMP is not set +# CONFIG_IPV6_MIP6 is not set +# CONFIG_INET6_XFRM_TUNNEL is not set +# CONFIG_INET6_TUNNEL is not set +CONFIG_INET6_XFRM_MODE_TRANSPORT=m +CONFIG_INET6_XFRM_MODE_TUNNEL=m +CONFIG_INET6_XFRM_MODE_BEET=m +# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set +CONFIG_IPV6_SIT=m +CONFIG_IPV6_NDISC_NODETYPE=y +# CONFIG_IPV6_TUNNEL is not set +# CONFIG_IPV6_MULTIPLE_TABLES is not set +# CONFIG_IPV6_MROUTE is not set +# CONFIG_NETWORK_SECMARK is not set +# CONFIG_NETFILTER is not set +# CONFIG_IP_DCCP is not set +# CONFIG_IP_SCTP is not set +# CONFIG_TIPC is not set +# CONFIG_ATM is not set +# CONFIG_BRIDGE is not set +# CONFIG_NET_DSA is not set +CONFIG_VLAN_8021Q=m +# CONFIG_VLAN_8021Q_GVRP is not set +# CONFIG_DECNET is not set +# CONFIG_LLC2 is not set +# CONFIG_IPX is not set +# CONFIG_ATALK is not set +# CONFIG_X25 is not set +# CONFIG_LAPB is not set +# CONFIG_ECONET is not set +CONFIG_WAN_ROUTER=y +# CONFIG_NET_SCHED is not set + +# +# Network testing +# +# CONFIG_NET_PKTGEN is not set +# CONFIG_HAMRADIO is not set +# CONFIG_CAN is not set +# CONFIG_IRDA is not set +# CONFIG_BT is not set +# CONFIG_AF_RXRPC is not set +# CONFIG_PHONET is not set +# CONFIG_WIRELESS is not set +# CONFIG_RFKILL is not set +# CONFIG_NET_9P is not set + +# +# Device Drivers +# + +# +# Generic Driver Options +# +CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" +CONFIG_STANDALONE=y +CONFIG_PREVENT_FIRMWARE_BUILD=y +CONFIG_FW_LOADER=y +CONFIG_FIRMWARE_IN_KERNEL=y +CONFIG_EXTRA_FIRMWARE="" +# CONFIG_SYS_HYPERVISOR is not set +CONFIG_CONNECTOR=y +CONFIG_PROC_EVENTS=y +CONFIG_MTD=y +# CONFIG_MTD_DEBUG is not set +CONFIG_MTD_CONCAT=y +CONFIG_MTD_PARTITIONS=y +# CONFIG_MTD_REDBOOT_PARTS is not set +CONFIG_MTD_CMDLINE_PARTS=y +# CONFIG_MTD_AFS_PARTS is not set +# CONFIG_MTD_AR7_PARTS is not set + +# +# User Modules And Translation Layers +# +CONFIG_MTD_CHAR=y +CONFIG_MTD_BLKDEVS=y +CONFIG_MTD_BLOCK=y +# CONFIG_FTL is not set +# CONFIG_NFTL is not set +# CONFIG_INFTL is not set +# CONFIG_RFD_FTL is not set +# CONFIG_SSFDC is not set +# CONFIG_MTD_OOPS is not set + +# +# RAM/ROM/Flash chip drivers +# +# CONFIG_MTD_CFI is not set +# CONFIG_MTD_JEDECPROBE is not set +CONFIG_MTD_MAP_BANK_WIDTH_1=y +CONFIG_MTD_MAP_BANK_WIDTH_2=y +CONFIG_MTD_MAP_BANK_WIDTH_4=y +# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set +# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set +# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set +CONFIG_MTD_CFI_I1=y +CONFIG_MTD_CFI_I2=y +# CONFIG_MTD_CFI_I4 is not set +# CONFIG_MTD_CFI_I8 is not set +# CONFIG_MTD_RAM is not set +# CONFIG_MTD_ROM is not set +# CONFIG_MTD_ABSENT is not set + +# +# Mapping drivers for chip access +# +# CONFIG_MTD_COMPLEX_MAPPINGS is not set +# CONFIG_MTD_PLATRAM is not set + +# +# Self-contained MTD device drivers +# +CONFIG_MTD_DATAFLASH=m +CONFIG_MTD_DATAFLASH_WRITE_VERIFY=y +# CONFIG_MTD_DATAFLASH_OTP is not set +CONFIG_MTD_M25P80=y +CONFIG_M25PXX_USE_FAST_READ=y +# CONFIG_MTD_SLRAM is not set +# CONFIG_MTD_PHRAM is not set +# CONFIG_MTD_MTDRAM is not set +# CONFIG_MTD_BLOCK2MTD is not set + +# +# Disk-On-Chip Device Drivers +# +# CONFIG_MTD_DOC2000 is not set +# CONFIG_MTD_DOC2001 is not set +# CONFIG_MTD_DOC2001PLUS is not set +# CONFIG_MTD_NAND is not set +# CONFIG_MTD_ONENAND is not set + +# +# UBI - Unsorted block images +# +# CONFIG_MTD_UBI is not set +# CONFIG_PARPORT is not set +CONFIG_BLK_DEV=y +# CONFIG_BLK_DEV_COW_COMMON is not set +CONFIG_BLK_DEV_LOOP=y +# CONFIG_BLK_DEV_CRYPTOLOOP is not set +CONFIG_BLK_DEV_NBD=y +# CONFIG_BLK_DEV_UB is not set +CONFIG_BLK_DEV_RAM=y +CONFIG_BLK_DEV_RAM_COUNT=16 +CONFIG_BLK_DEV_RAM_SIZE=16384 +# CONFIG_BLK_DEV_XIP is not set +# CONFIG_RD_BZIP2 is not set +CONFIG_RD_LZMA=y +CONFIG_RD_GZIP=y +# CONFIG_CDROM_PKTCDVD is not set +# CONFIG_ATA_OVER_ETH is not set +CONFIG_MISC_DEVICES=y +# CONFIG_EEPROM_93CX6 is not set +# CONFIG_ICS932S401 is not set +# CONFIG_ENCLOSURE_SERVICES is not set +# CONFIG_C2PORT is not set +CONFIG_HAVE_IDE=y +# CONFIG_IDE is not set + +# +# SCSI device support +# +# CONFIG_RAID_ATTRS is not set +CONFIG_SCSI=y +CONFIG_SCSI_DMA=y +CONFIG_SCSI_TGT=y +# CONFIG_SCSI_NETLINK is not set +CONFIG_SCSI_PROC_FS=y + +# +# SCSI support type (disk, tape, CD-ROM) +# +CONFIG_BLK_DEV_SD=y +# CONFIG_CHR_DEV_ST is not set +# CONFIG_CHR_DEV_OSST is not set +# CONFIG_BLK_DEV_SR is not set +CONFIG_CHR_DEV_SG=y +# CONFIG_CHR_DEV_SCH is not set + +# +# Some SCSI devices (e.g. CD jukebox) support multiple LUNs +# +# CONFIG_SCSI_MULTI_LUN is not set +# CONFIG_SCSI_CONSTANTS is not set +# CONFIG_SCSI_LOGGING is not set +CONFIG_SCSI_SCAN_ASYNC=y +CONFIG_SCSI_WAIT_SCAN=m + +# +# SCSI Transports +# +# CONFIG_SCSI_SPI_ATTRS is not set +# CONFIG_SCSI_FC_ATTRS is not set +CONFIG_SCSI_ISCSI_ATTRS=m +# CONFIG_SCSI_SAS_LIBSAS is not set +# CONFIG_SCSI_SRP_ATTRS is not set +# CONFIG_SCSI_LOWLEVEL is not set +# CONFIG_SCSI_DH is not set +# CONFIG_ATA is not set +# CONFIG_MD is not set +CONFIG_NETDEVICES=y +# CONFIG_DUMMY is not set +CONFIG_BONDING=m +# CONFIG_MACVLAN is not set +# CONFIG_EQUALIZER is not set +CONFIG_TUN=m +# CONFIG_VETH is not set +# CONFIG_NET_ETHERNET is not set +CONFIG_NETDEV_1000=y +CONFIG_ASPEEDMAC=y +# CONFIG_NETDEV_10000 is not set + +# +# Wireless LAN +# +# CONFIG_WLAN_PRE80211 is not set +# CONFIG_WLAN_80211 is not set +# CONFIG_IWLWIFI_LEDS is not set + +# +# USB Network Adapters +# +# CONFIG_USB_CATC is not set +# CONFIG_USB_KAWETH is not set +# CONFIG_USB_PEGASUS is not set +# CONFIG_USB_RTL8150 is not set +# CONFIG_USB_USBNET is not set +# CONFIG_WAN is not set +# CONFIG_PPP is not set +# CONFIG_SLIP is not set +# CONFIG_NETCONSOLE is not set +# CONFIG_NETPOLL is not set +# CONFIG_NET_POLL_CONTROLLER is not set +# CONFIG_ISDN is not set + +# +# Input device support +# +CONFIG_INPUT=y +# CONFIG_INPUT_FF_MEMLESS is not set +# CONFIG_INPUT_POLLDEV is not set + +# +# Userland interfaces +# +CONFIG_INPUT_MOUSEDEV=y +CONFIG_INPUT_MOUSEDEV_PSAUX=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_EVBUG is not set + +# +# Input Device Drivers +# +CONFIG_INPUT_KEYBOARD=y +CONFIG_KEYBOARD_ATKBD=y +# CONFIG_KEYBOARD_SUNKBD is not set +# CONFIG_KEYBOARD_LKKBD is not set +# CONFIG_KEYBOARD_XTKBD is not set +# CONFIG_KEYBOARD_NEWTON is not set +# CONFIG_KEYBOARD_STOWAWAY is not set +# CONFIG_KEYBOARD_GPIO is not set +CONFIG_INPUT_MOUSE=y +CONFIG_MOUSE_PS2=y +CONFIG_MOUSE_PS2_ALPS=y +CONFIG_MOUSE_PS2_LOGIPS2PP=y +CONFIG_MOUSE_PS2_SYNAPTICS=y +CONFIG_MOUSE_PS2_LIFEBOOK=y +CONFIG_MOUSE_PS2_TRACKPOINT=y +# CONFIG_MOUSE_PS2_ELANTECH is not set +# CONFIG_MOUSE_PS2_TOUCHKIT is not set +CONFIG_MOUSE_SERIAL=y +# CONFIG_MOUSE_APPLETOUCH is not set +# CONFIG_MOUSE_BCM5974 is not set +# CONFIG_MOUSE_VSXXXAA is not set +# CONFIG_MOUSE_GPIO is not set +# CONFIG_INPUT_JOYSTICK is not set +# CONFIG_INPUT_TABLET is not set +# CONFIG_INPUT_TOUCHSCREEN is not set +# CONFIG_INPUT_MISC is not set + +# +# Hardware I/O ports +# +CONFIG_SERIO=y +CONFIG_SERIO_SERPORT=y +# CONFIG_SERIO_AMBAKMI is not set +CONFIG_SERIO_LIBPS2=y +# CONFIG_SERIO_RAW is not set +# CONFIG_GAMEPORT is not set + +# +# Character devices +# +CONFIG_VT=y +CONFIG_CONSOLE_TRANSLATIONS=y +CONFIG_VT_CONSOLE=y +CONFIG_HW_CONSOLE=y +# CONFIG_VT_HW_CONSOLE_BINDING is not set +CONFIG_DEVKMEM=y +CONFIG_SERIAL_NONSTANDARD=y +# CONFIG_N_HDLC is not set +# CONFIG_RISCOM8 is not set +# CONFIG_SPECIALIX is not set +# CONFIG_RIO is not set +# CONFIG_STALDRV is not set + +# +# Serial drivers +# +CONFIG_SERIAL_8250=y +CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_SERIAL_8250_NR_UARTS=5 +CONFIG_SERIAL_8250_RUNTIME_UARTS=5 +# CONFIG_SERIAL_AST_DMA_UART is not set +# CONFIG_SERIAL_8250_EXTENDED is not set + +# +# Non-8250 serial port support +# +# CONFIG_SERIAL_AMBA_PL010 is not set +# CONFIG_SERIAL_AMBA_PL011 is not set +# CONFIG_SERIAL_AST is not set +CONFIG_SERIAL_CORE=y +CONFIG_SERIAL_CORE_CONSOLE=y +CONFIG_UNIX98_PTYS=y +CONFIG_LEGACY_PTYS=y +CONFIG_LEGACY_PTY_COUNT=256 +# CONFIG_IPMI_HANDLER is not set +CONFIG_AST_MISC=y +# CONFIG_AST_VIDEO is not set +# CONFIG_ADC_CAT9883 is not set +# CONFIG_AST_SPI_BIOS is not set +CONFIG_AST_PECI=y +# CONFIG_AST_KCS is not set +# CONFIG_AST_GPIO is not set +# CONFIG_HW_RANDOM is not set +CONFIG_NVRAM=y +# CONFIG_R3964 is not set +# CONFIG_RAW_DRIVER is not set +# CONFIG_TCG_TPM is not set +CONFIG_I2C=y +CONFIG_I2C_BOARDINFO=y +CONFIG_I2C_CHARDEV=y +CONFIG_I2C_HELPER_AUTO=y + +# +# I2C Hardware Bus support +# + +# +# I2C system bus drivers (mostly embedded / system-on-chip) +# +# CONFIG_I2C_GPIO is not set +# CONFIG_I2C_OCORES is not set +CONFIG_I2C_AST=y +CONFIG_AST_I2C_SLAVE_MODE=y +# CONFIG_AST_I2C_SLAVE_EEPROM is not set +CONFIG_AST_I2C_SLAVE_RDWR=y +# CONFIG_I2C_SIMTEC is not set + +# +# External I2C/SMBus adapter drivers +# +# CONFIG_I2C_PARPORT_LIGHT is not set +# CONFIG_I2C_TAOS_EVM is not set +# CONFIG_I2C_TINY_USB is not set + +# +# Other I2C/SMBus bus drivers +# +# CONFIG_I2C_PCA_PLATFORM is not set +# CONFIG_I2C_STUB is not set + +# +# Miscellaneous I2C Chip support +# +# CONFIG_DS1682 is not set +CONFIG_AT24=m +# CONFIG_SENSORS_EEPROM is not set +CONFIG_SENSORS_PCF8574=m +# CONFIG_PCF8575 is not set +# CONFIG_SENSORS_PCA9539 is not set +# CONFIG_SENSORS_PCF8591 is not set +# CONFIG_TPS65010 is not set +# CONFIG_SENSORS_MAX6875 is not set +# CONFIG_SENSORS_TSL2550 is not set +# CONFIG_I2C_DEBUG_CORE is not set +# CONFIG_I2C_DEBUG_ALGO is not set +# CONFIG_I2C_DEBUG_BUS is not set +# CONFIG_I2C_DEBUG_CHIP is not set +CONFIG_SPI=y +CONFIG_SPI_MASTER=y + +# +# SPI Master Controller Drivers +# +CONFIG_SPI_AST=y +CONFIG_SPI_FMC=y +CONFIG_SPI_BITBANG=y + +# +# SPI Protocol Masters +# +CONFIG_SPI_AT25=m +# CONFIG_SPI_SPIDEV is not set +# CONFIG_SPI_TLE62X0 is not set +CONFIG_ARCH_REQUIRE_GPIOLIB=y +CONFIG_GPIOLIB=y +CONFIG_GPIO_SYSFS=y + +# +# Memory mapped GPIO expanders: +# + +# +# I2C GPIO expanders: +# +# CONFIG_GPIO_MAX732X is not set +# CONFIG_GPIO_PCA953X is not set +# CONFIG_GPIO_PCF857X is not set + +# +# PCI GPIO expanders: +# + +# +# SPI GPIO expanders: +# +# CONFIG_GPIO_MAX7301 is not set +# CONFIG_GPIO_MCP23S08 is not set +# CONFIG_W1 is not set +# CONFIG_POWER_SUPPLY is not set +CONFIG_HWMON=y +# CONFIG_HWMON_VID is not set +# CONFIG_SENSORS_AD7414 is not set +# CONFIG_SENSORS_AD7418 is not set +# CONFIG_SENSORS_ADCXX is not set +# CONFIG_SENSORS_ADM1021 is not set +# CONFIG_SENSORS_ADM1025 is not set +# CONFIG_SENSORS_ADM1026 is not set +# CONFIG_SENSORS_ADM1029 is not set +# CONFIG_SENSORS_ADM1031 is not set +# CONFIG_SENSORS_ADM9240 is not set +# CONFIG_SENSORS_ADT7462 is not set +# CONFIG_SENSORS_ADT7470 is not set +# CONFIG_SENSORS_ADT7473 is not set +# CONFIG_SENSORS_ATXP1 is not set +# CONFIG_SENSORS_DS1621 is not set +# CONFIG_SENSORS_F71805F is not set +# CONFIG_SENSORS_F71882FG is not set +# CONFIG_SENSORS_F75375S is not set +# CONFIG_SENSORS_GL518SM is not set +# CONFIG_SENSORS_GL520SM is not set +# CONFIG_SENSORS_IT87 is not set +# CONFIG_SENSORS_LM63 is not set +# CONFIG_SENSORS_LM70 is not set +CONFIG_SENSORS_LM75=m +# CONFIG_SENSORS_LM77 is not set +# CONFIG_SENSORS_LM78 is not set +# CONFIG_SENSORS_LM80 is not set +# CONFIG_SENSORS_LM83 is not set +# CONFIG_SENSORS_LM85 is not set +# CONFIG_SENSORS_LM87 is not set +# CONFIG_SENSORS_LM90 is not set +# CONFIG_SENSORS_LM92 is not set +# CONFIG_SENSORS_LM93 is not set +CONFIG_SENSORS_MAX127=m +# CONFIG_SENSORS_MAX1111 is not set +# CONFIG_SENSORS_MAX1619 is not set +# CONFIG_SENSORS_MAX6650 is not set +# CONFIG_SENSORS_PC87360 is not set +# CONFIG_SENSORS_PC87427 is not set +# CONFIG_SENSORS_DME1737 is not set +# CONFIG_SENSORS_SMSC47M1 is not set +# CONFIG_SENSORS_SMSC47M192 is not set +# CONFIG_SENSORS_SMSC47B397 is not set +CONFIG_SENSORS_ADS7828=m +# CONFIG_SENSORS_THMC50 is not set +# CONFIG_SENSORS_VT1211 is not set +# CONFIG_SENSORS_W83781D is not set +# CONFIG_SENSORS_W83791D is not set +# CONFIG_SENSORS_W83792D is not set +# CONFIG_SENSORS_W83793 is not set +# CONFIG_SENSORS_W83L785TS is not set +# CONFIG_SENSORS_W83L786NG is not set +# CONFIG_SENSORS_W83627HF is not set +# CONFIG_SENSORS_W83627EHF is not set +CONFIG_SENSORS_AST_ADC=y +CONFIG_SENSORS_AST_PWM_FAN=y +# CONFIG_SENSORS_FB_PANTHER_PLUS is not set +CONFIG_PMBUS=m +CONFIG_SENSORS_PMBUS=m +CONFIG_SENSORS_ADM1275=m +# CONFIG_SENSORS_LM25066 is not set +# CONFIG_SENSORS_LTC2978 is not set +# CONFIG_SENSORS_MAX16064 is not set +# CONFIG_SENSORS_MAX34440 is not set +# CONFIG_SENSORS_MAX8688 is not set +CONFIG_SENSORS_PFE1100=m +CONFIG_SENSORS_PFE3000=m +# CONFIG_SENSORS_UCD9000 is not set +# CONFIG_SENSORS_UCD9200 is not set +# CONFIG_SENSORS_ZL6100 is not set +# CONFIG_HWMON_DEBUG_CHIP is not set +CONFIG_THERMAL=y +CONFIG_THERMAL_HWMON=y +CONFIG_WATCHDOG=y +# CONFIG_WATCHDOG_NOWAYOUT is not set + +# +# Watchdog Device Drivers +# +# CONFIG_SOFT_WATCHDOG is not set +CONFIG_AST_WATCHDOG=y + +# +# USB-based Watchdog Cards +# +# CONFIG_USBPCWATCHDOG is not set +CONFIG_SSB_POSSIBLE=y + +# +# Sonics Silicon Backplane +# +# CONFIG_SSB is not set + +# +# Multifunction device drivers +# +# CONFIG_MFD_CORE is not set +# CONFIG_MFD_SM501 is not set +# CONFIG_MFD_ASIC3 is not set +# CONFIG_HTC_EGPIO is not set +# CONFIG_HTC_PASIC3 is not set +# CONFIG_MFD_TMIO is not set +# CONFIG_MFD_TC6393XB is not set +# CONFIG_PMIC_DA903X is not set +# CONFIG_MFD_WM8400 is not set +# CONFIG_MFD_WM8350_I2C is not set + +# +# Multimedia devices +# + +# +# Multimedia core support +# +# CONFIG_VIDEO_DEV is not set +# CONFIG_DVB_CORE is not set +# CONFIG_VIDEO_MEDIA is not set + +# +# Multimedia drivers +# +# CONFIG_DAB is not set + +# +# Graphics support +# +# CONFIG_VGASTATE is not set +# CONFIG_VIDEO_OUTPUT_CONTROL is not set +# CONFIG_FB is not set +# CONFIG_BACKLIGHT_LCD_SUPPORT is not set + +# +# Display device support +# +# CONFIG_DISPLAY_SUPPORT is not set + +# +# Console display driver support +# +# CONFIG_VGA_CONSOLE is not set +CONFIG_DUMMY_CONSOLE=y +# CONFIG_SOUND is not set +# CONFIG_HID_SUPPORT is not set +CONFIG_USB_SUPPORT=y +CONFIG_USB_ARCH_HAS_HCD=y +# CONFIG_USB_ARCH_HAS_OHCI is not set +CONFIG_USB_ARCH_HAS_EHCI=y +CONFIG_USB=m +# CONFIG_USB_DEBUG is not set +# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set + +# +# Miscellaneous USB options +# +CONFIG_USB_DEVICEFS=y +CONFIG_USB_DEVICE_CLASS=y +# CONFIG_USB_DYNAMIC_MINORS is not set +# CONFIG_USB_SUSPEND is not set +# CONFIG_USB_OTG is not set +# CONFIG_USB_MON is not set +# CONFIG_USB_WUSB is not set +# CONFIG_USB_WUSB_CBAF is not set + +# +# USB Host Controller Drivers +# +# CONFIG_USB_C67X00_HCD is not set +# CONFIG_USB_EHCI_HCD is not set +# CONFIG_USB_ISP116X_HCD is not set +# CONFIG_USB_SL811_HCD is not set +# CONFIG_USB_R8A66597_HCD is not set +# CONFIG_USB_HWA_HCD is not set + +# +# AST USB Drivers +# +CONFIG_AST_USB_UHCI_HCD=y +# CONFIG_AST_USB_UHCI_MULTIPORT_1 is not set +# CONFIG_AST_USB_UHCI_MULTIPORT_2 is not set +CONFIG_AST_USB_UHCI_MULTIPORT_4=y +# CONFIG_USB_EHCI_SPLIT_ISO is not set + +# +# USB Device Class drivers +# +# CONFIG_USB_ACM is not set +# CONFIG_USB_PRINTER is not set +# CONFIG_USB_WDM is not set +# CONFIG_USB_TMC is not set + +# +# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may also be needed; +# + +# +# see USB_STORAGE Help for more information +# +CONFIG_USB_STORAGE=m +# 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_USBAT 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_STORAGE_ALAUDA is not set +# CONFIG_USB_STORAGE_ONETOUCH is not set +# CONFIG_USB_STORAGE_KARMA is not set +# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set +# CONFIG_USB_LIBUSUAL is not set + +# +# USB Imaging devices +# +# CONFIG_USB_MDC800 is not set +# CONFIG_USB_MICROTEK is not set + +# +# USB port drivers +# +# CONFIG_USB_SERIAL is not set + +# +# USB Miscellaneous drivers +# +# CONFIG_USB_EMI62 is not set +# CONFIG_USB_EMI26 is not set +# CONFIG_USB_ADUTUX is not set +# CONFIG_USB_SEVSEG is not set +# CONFIG_USB_RIO500 is not set +# CONFIG_USB_LEGOTOWER is not set +# CONFIG_USB_LCD is not set +# CONFIG_USB_BERRY_CHARGE is not set +# CONFIG_USB_LED is not set +# CONFIG_USB_CYPRESS_CY7C63 is not set +# CONFIG_USB_CYTHERM is not set +# CONFIG_USB_PHIDGET is not set +# CONFIG_USB_IDMOUSE is not set +# CONFIG_USB_FTDI_ELAN is not set +# CONFIG_USB_APPLEDISPLAY is not set +# CONFIG_USB_LD is not set +# CONFIG_USB_TRANCEVIBRATOR is not set +# CONFIG_USB_IOWARRIOR is not set +# CONFIG_USB_TEST is not set +# CONFIG_USB_ISIGHTFW is not set +# CONFIG_USB_VST is not set +CONFIG_USB_GADGET=y +# CONFIG_USB_GADGET_DEBUG_FILES is not set +CONFIG_USB_GADGET_VBUS_DRAW=2 +CONFIG_USB_GADGET_SELECTED=y +# CONFIG_USB_GADGET_AT91 is not set +# CONFIG_USB_GADGET_ATMEL_USBA is not set +# CONFIG_USB_GADGET_FSL_USB2 is not set +# CONFIG_USB_GADGET_LH7A40X is not set +# CONFIG_USB_GADGET_OMAP is not set +# CONFIG_USB_GADGET_PXA25X is not set +# CONFIG_USB_GADGET_PXA27X is not set +# CONFIG_USB_GADGET_S3C2410 is not set +# CONFIG_USB_GADGET_M66592 is not set +# CONFIG_USB_GADGET_AMD5536UDC is not set +# CONFIG_USB_GADGET_FSL_QE is not set +# CONFIG_USB_GADGET_NET2280 is not set +# CONFIG_USB_GADGET_GOKU is not set +CONFIG_USB_GADGET_ASPEED_AST=y +CONFIG_USB_ASPEED_AST=y +# CONFIG_USB_GADGET_DUMMY_HCD is not set +CONFIG_USB_GADGET_DUALSPEED=y +CONFIG_USB_ZERO=m +CONFIG_USB_ETH=m +CONFIG_USB_ETH_RNDIS=y +CONFIG_USB_GADGETFS=m +CONFIG_USB_FILE_STORAGE=m +# CONFIG_USB_FILE_STORAGE_TEST is not set +CONFIG_USB_G_SERIAL=m +# CONFIG_USB_MIDI_GADGET is not set +# CONFIG_USB_G_PRINTER is not set +CONFIG_USB_CDC_COMPOSITE=m +# CONFIG_MMC is not set +# CONFIG_MEMSTICK is not set +# CONFIG_ACCESSIBILITY is not set +# CONFIG_NEW_LEDS is not set +CONFIG_RTC_LIB=y +CONFIG_RTC_CLASS=y +# CONFIG_RTC_HCTOSYS is not set +# CONFIG_RTC_DEBUG is not set + +# +# RTC interfaces +# +CONFIG_RTC_INTF_SYSFS=y +CONFIG_RTC_INTF_PROC=y +CONFIG_RTC_INTF_DEV=y +# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set +# CONFIG_RTC_DRV_TEST is not set + +# +# I2C RTC drivers +# +# CONFIG_RTC_DRV_DS1307 is not set +# CONFIG_RTC_DRV_DS1374 is not set +# CONFIG_RTC_DRV_DS1672 is not set +# CONFIG_RTC_DRV_MAX6900 is not set +# CONFIG_RTC_DRV_RS5C372 is not set +# CONFIG_RTC_DRV_ISL1208 is not set +# CONFIG_RTC_DRV_X1205 is not set +# CONFIG_RTC_DRV_PCF8563 is not set +# CONFIG_RTC_DRV_PCF8583 is not set +# CONFIG_RTC_DRV_M41T80 is not set +# CONFIG_RTC_DRV_S35390A is not set +# CONFIG_RTC_DRV_FM3130 is not set +# CONFIG_RTC_DRV_RX8581 is not set + +# +# SPI RTC drivers +# +# CONFIG_RTC_DRV_M41T94 is not set +# CONFIG_RTC_DRV_DS1305 is not set +# CONFIG_RTC_DRV_DS1390 is not set +# CONFIG_RTC_DRV_MAX6902 is not set +# CONFIG_RTC_DRV_R9701 is not set +# CONFIG_RTC_DRV_RS5C348 is not set +# CONFIG_RTC_DRV_DS3234 is not set + +# +# Platform RTC drivers +# +# CONFIG_RTC_DRV_CMOS is not set +# CONFIG_RTC_DRV_DS1286 is not set +# CONFIG_RTC_DRV_DS1511 is not set +# CONFIG_RTC_DRV_DS1553 is not set +# CONFIG_RTC_DRV_DS1742 is not set +# CONFIG_RTC_DRV_STK17TA8 is not set +# CONFIG_RTC_DRV_M48T86 is not set +# CONFIG_RTC_DRV_M48T35 is not set +# CONFIG_RTC_DRV_M48T59 is not set +# CONFIG_RTC_DRV_BQ4802 is not set +# CONFIG_RTC_DRV_V3020 is not set + +# +# on-CPU RTC drivers +# +# CONFIG_RTC_DRV_PL030 is not set +# CONFIG_RTC_DRV_PL031 is not set +CONFIG_RTC_DRV_ASPEED=y +# CONFIG_DMADEVICES is not set +# CONFIG_REGULATOR is not set +# CONFIG_UIO is not set + +# +# File systems +# +CONFIG_EXT2_FS=y +CONFIG_EXT2_FS_XATTR=y +CONFIG_EXT2_FS_POSIX_ACL=y +CONFIG_EXT2_FS_SECURITY=y +# CONFIG_EXT2_FS_XIP is not set +# CONFIG_EXT3_FS is not set +# CONFIG_EXT4_FS is not set +CONFIG_FS_MBCACHE=y +# CONFIG_REISERFS_FS is not set +# CONFIG_JFS_FS is not set +CONFIG_FS_POSIX_ACL=y +CONFIG_FILE_LOCKING=y +# CONFIG_XFS_FS is not set +# CONFIG_OCFS2_FS is not set +CONFIG_DNOTIFY=y +CONFIG_INOTIFY=y +CONFIG_INOTIFY_USER=y +# CONFIG_QUOTA is not set +# CONFIG_AUTOFS_FS is not set +# CONFIG_AUTOFS4_FS is not set +# CONFIG_FUSE_FS is not set +CONFIG_GENERIC_ACL=y + +# +# CD-ROM/DVD Filesystems +# +# CONFIG_ISO9660_FS is not set +# CONFIG_UDF_FS is not set + +# +# DOS/FAT/NT Filesystems +# +CONFIG_FAT_FS=y +CONFIG_MSDOS_FS=y +CONFIG_VFAT_FS=y +CONFIG_FAT_DEFAULT_CODEPAGE=437 +CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1" +CONFIG_NTFS_FS=y +# CONFIG_NTFS_DEBUG is not set +CONFIG_NTFS_RW=y + +# +# Pseudo filesystems +# +CONFIG_PROC_FS=y +CONFIG_PROC_SYSCTL=y +CONFIG_PROC_PAGE_MONITOR=y +CONFIG_SYSFS=y +CONFIG_TMPFS=y +CONFIG_TMPFS_POSIX_ACL=y +# CONFIG_HUGETLB_PAGE is not set +CONFIG_CONFIGFS_FS=m + +# +# Miscellaneous filesystems +# +# CONFIG_ADFS_FS 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_BFS_FS is not set +# CONFIG_EFS_FS is not set +CONFIG_YAFFS_FS=y +CONFIG_YAFFS_YAFFS1=y +# CONFIG_YAFFS_9BYTE_TAGS is not set +# CONFIG_YAFFS_DOES_ECC is not set +CONFIG_YAFFS_YAFFS2=y +CONFIG_YAFFS_AUTO_YAFFS2=y +# CONFIG_YAFFS_DISABLE_TAGS_ECC is not set +# CONFIG_YAFFS_DISABLE_LAZY_LOAD is not set +# CONFIG_YAFFS_DISABLE_WIDE_TNODES is not set +# CONFIG_YAFFS_ALWAYS_CHECK_CHUNK_ERASED is not set +CONFIG_YAFFS_SHORT_NAMES_IN_RAM=y +# CONFIG_YAFFS_EMPTY_LOST_AND_FOUND is not set +CONFIG_JFFS2_FS=y +CONFIG_JFFS2_FS_DEBUG=0 +CONFIG_JFFS2_FS_WRITEBUFFER=y +# CONFIG_JFFS2_FS_WBUF_VERIFY is not set +# CONFIG_JFFS2_SUMMARY is not set +# CONFIG_JFFS2_FS_XATTR is not set +# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set +CONFIG_JFFS2_ZLIB=y +# CONFIG_JFFS2_LZO is not set +CONFIG_JFFS2_RTIME=y +# CONFIG_JFFS2_RUBIN is not set +# CONFIG_CRAMFS is not set +# CONFIG_VXFS_FS is not set +# CONFIG_MINIX_FS is not set +# CONFIG_OMFS_FS is not set +# CONFIG_HPFS_FS is not set +# CONFIG_QNX4FS_FS is not set +# CONFIG_ROMFS_FS is not set +# CONFIG_SYSV_FS is not set +# CONFIG_UFS_FS is not set +CONFIG_NETWORK_FILESYSTEMS=y +CONFIG_NFS_FS=y +# CONFIG_NFS_V3 is not set +# CONFIG_NFS_V4 is not set +CONFIG_ROOT_NFS=y +# CONFIG_NFSD is not set +CONFIG_LOCKD=y +CONFIG_NFS_COMMON=y +CONFIG_SUNRPC=y +# CONFIG_SUNRPC_REGISTER_V4 is not set +# CONFIG_RPCSEC_GSS_KRB5 is not set +# CONFIG_RPCSEC_GSS_SPKM3 is not set +# CONFIG_SMB_FS is not set +# CONFIG_CIFS is not set +# CONFIG_NCP_FS is not set +# CONFIG_CODA_FS is not set +# CONFIG_AFS_FS is not set + +# +# Partition Types +# +# CONFIG_PARTITION_ADVANCED is not set +CONFIG_MSDOS_PARTITION=y +CONFIG_NLS=y +CONFIG_NLS_DEFAULT="utf8" +CONFIG_NLS_CODEPAGE_437=y +# 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=y +CONFIG_NLS_CODEPAGE_950=y +CONFIG_NLS_CODEPAGE_932=y +# 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_ASCII=y +CONFIG_NLS_ISO8859_1=y +# 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=y +# CONFIG_DLM is not set + +# +# Kernel hacking +# +# CONFIG_PRINTK_TIME is not set +# CONFIG_ENABLE_WARN_DEPRECATED is not set +CONFIG_ENABLE_MUST_CHECK=y +CONFIG_FRAME_WARN=1024 +CONFIG_MAGIC_SYSRQ=y +# CONFIG_UNUSED_SYMBOLS is not set +# CONFIG_DEBUG_FS is not set +# CONFIG_HEADERS_CHECK is not set +# CONFIG_DEBUG_KERNEL is not set +# CONFIG_SLUB_DEBUG_ON is not set +# CONFIG_SLUB_STATS is not set +CONFIG_DEBUG_BUGVERBOSE=y +CONFIG_DEBUG_MEMORY_INIT=y +CONFIG_FRAME_POINTER=y +# CONFIG_RCU_CPU_STALL_DETECTOR is not set +# CONFIG_LATENCYTOP is not set +# CONFIG_SYSCTL_SYSCALL_CHECK is not set +CONFIG_HAVE_FUNCTION_TRACER=y + +# +# Tracers +# +# CONFIG_DYNAMIC_PRINTK_DEBUG is not set +# CONFIG_SAMPLES is not set +CONFIG_HAVE_ARCH_KGDB=y +# CONFIG_DEBUG_USER is not set + +# +# Security options +# +# CONFIG_KEYS is not set +# CONFIG_SECURITY is not set +# CONFIG_SECURITYFS is not set +# CONFIG_SECURITY_FILE_CAPABILITIES is not set +CONFIG_CRYPTO=y + +# +# Crypto core or helper +# +# CONFIG_CRYPTO_FIPS is not set +CONFIG_CRYPTO_ALGAPI=y +CONFIG_CRYPTO_ALGAPI2=y +CONFIG_CRYPTO_AEAD=m +CONFIG_CRYPTO_AEAD2=y +CONFIG_CRYPTO_BLKCIPHER=y +CONFIG_CRYPTO_BLKCIPHER2=y +CONFIG_CRYPTO_HASH=y +CONFIG_CRYPTO_HASH2=y +CONFIG_CRYPTO_RNG2=y +CONFIG_CRYPTO_MANAGER=y +CONFIG_CRYPTO_MANAGER2=y +# CONFIG_CRYPTO_GF128MUL is not set +CONFIG_CRYPTO_NULL=y +# CONFIG_CRYPTO_CRYPTD is not set +CONFIG_CRYPTO_AUTHENC=m +# CONFIG_CRYPTO_TEST is not set + +# +# Authenticated Encryption with Associated Data +# +# CONFIG_CRYPTO_CCM is not set +# CONFIG_CRYPTO_GCM is not set +# CONFIG_CRYPTO_SEQIV is not set + +# +# Block modes +# +CONFIG_CRYPTO_CBC=y +# CONFIG_CRYPTO_CTR is not set +# CONFIG_CRYPTO_CTS is not set +# CONFIG_CRYPTO_ECB is not set +# CONFIG_CRYPTO_LRW is not set +# CONFIG_CRYPTO_PCBC is not set +# CONFIG_CRYPTO_XTS is not set + +# +# Hash modes +# +CONFIG_CRYPTO_HMAC=y +# CONFIG_CRYPTO_XCBC is not set + +# +# Digest +# +# CONFIG_CRYPTO_CRC32C is not set +# CONFIG_CRYPTO_MD4 is not set +CONFIG_CRYPTO_MD5=y +# CONFIG_CRYPTO_MICHAEL_MIC is not set +# CONFIG_CRYPTO_RMD128 is not set +# CONFIG_CRYPTO_RMD160 is not set +# CONFIG_CRYPTO_RMD256 is not set +# CONFIG_CRYPTO_RMD320 is not set +CONFIG_CRYPTO_SHA1=y +# CONFIG_CRYPTO_SHA256 is not set +# CONFIG_CRYPTO_SHA512 is not set +# CONFIG_CRYPTO_TGR192 is not set +# CONFIG_CRYPTO_WP512 is not set + +# +# Ciphers +# +# CONFIG_CRYPTO_AES is not set +# CONFIG_CRYPTO_ANUBIS is not set +# CONFIG_CRYPTO_ARC4 is not set +# CONFIG_CRYPTO_BLOWFISH is not set +# CONFIG_CRYPTO_CAMELLIA is not set +# CONFIG_CRYPTO_CAST5 is not set +# CONFIG_CRYPTO_CAST6 is not set +CONFIG_CRYPTO_DES=y +# CONFIG_CRYPTO_FCRYPT is not set +# CONFIG_CRYPTO_KHAZAD is not set +# CONFIG_CRYPTO_SALSA20 is not set +# CONFIG_CRYPTO_SEED is not set +# CONFIG_CRYPTO_SERPENT is not set +# CONFIG_CRYPTO_TEA is not set +# CONFIG_CRYPTO_TWOFISH is not set + +# +# Compression +# +CONFIG_CRYPTO_DEFLATE=m +# CONFIG_CRYPTO_LZO is not set + +# +# Random Number Generation +# +# CONFIG_CRYPTO_ANSI_CPRNG is not set +# CONFIG_CRYPTO_HW is not set + +# +# Library routines +# +CONFIG_BITREVERSE=y +# CONFIG_CRC_CCITT is not set +# CONFIG_CRC16 is not set +# CONFIG_CRC_T10DIF is not set +CONFIG_CRC_ITU_T=m +CONFIG_CRC32=y +# CONFIG_CRC7 is not set +# CONFIG_LIBCRC32C is not set +CONFIG_ZLIB_INFLATE=y +CONFIG_ZLIB_DEFLATE=y +CONFIG_PLIST=y +CONFIG_HAS_IOMEM=y +CONFIG_HAS_IOPORT=y +CONFIG_HAS_DMA=y + + +# GUC USB Drivers +# +CONFIG_GUC_USB_UHCI_HCD=m +# CONFIG_GUC_USB_UHCI_MULTIPORT_1 is not set +# CONFIG_GUC_USB_UHCI_MULTIPORT_2 is not set +CONFIG_GUC_USB_UHCI_MULTIPORT_4=y +# CONFIG_USB_GADGET_MUSB_HDRC is not set diff --git a/meta-facebook/meta-yosemite/recipes-kernel/linux/linux-aspeed_2.6%.bbappend b/meta-facebook/meta-yosemite/recipes-kernel/linux/linux-aspeed_2.6%.bbappend index a317986..846b197 100644 --- a/meta-facebook/meta-yosemite/recipes-kernel/linux/linux-aspeed_2.6%.bbappend +++ b/meta-facebook/meta-yosemite/recipes-kernel/linux/linux-aspeed_2.6%.bbappend @@ -2,4 +2,7 @@ LINUX_VERSION_EXTENSION = "-yosemite" COMPATIBLE_MACHINE = "yosemite" -KERNEL_CONFIG_COMMAND = "oe_runmake yosemite_defconfig && oe_runmake oldconfig" +FILESEXTRAPATHS_prepend := "${THISDIR}/files:" + +SRC_URI += "file://defconfig \ + " diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/bic-cached/bic-cached_0.1.bb b/meta-facebook/meta-yosemite/recipes-yosemite/bic-cached/bic-cached_0.1.bb index ef7a15c..010e8cf 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/bic-cached/bic-cached_0.1.bb +++ b/meta-facebook/meta-yosemite/recipes-yosemite/bic-cached/bic-cached_0.1.bb @@ -31,7 +31,7 @@ do_install() { install -d ${D}${sysconfdir}/init.d install -d ${D}${sysconfdir}/rcS.d install -m 755 setup-bic-cached.sh ${D}${sysconfdir}/init.d/setup-bic-cached.sh - update-rc.d -r ${D} setup-bic-cached.sh start 66 S . + update-rc.d -r ${D} setup-bic-cached.sh start 66 5 . } FBPACKAGEDIR = "${prefix}/local/fbpackages" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/bic-cached/files/bic-cached.c b/meta-facebook/meta-yosemite/recipes-yosemite/bic-cached/files/bic-cached.c index 3a2dd28..78e443d 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/bic-cached/files/bic-cached.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/bic-cached/files/bic-cached.c @@ -49,7 +49,7 @@ fruid_cache_init(uint8_t slot_id) { ret = bic_read_fruid(slot_id, 0, fruid_temp_path); if (ret) { - syslog(LOG_ALERT, "fruid_cache_init: bic_read_fruid returns %d\n", ret); + syslog(LOG_WARNING, "fruid_cache_init: bic_read_fruid returns %d\n", ret); } rename(fruid_temp_path, fruid_path); @@ -83,14 +83,14 @@ sdr_cache_init(uint8_t slot_id) { unlink(path); fd = open(path, O_WRONLY | O_CREAT | O_EXCL, 0666); if (fd < 0) { - syslog(LOG_ALERT, "sdr_cache_init: open fails for path: %s\n", path); + syslog(LOG_WARNING, "sdr_cache_init: open fails for path: %s\n", path); return; } while (1) { ret = bic_get_sdr(slot_id, &req, res, &rlen); if (ret) { - syslog(LOG_ALERT, "sdr_cache_init:bic_get_sdr returns %d\n", ret); + syslog(LOG_WARNING, "sdr_cache_init:bic_get_sdr returns %d\n", ret); continue; } diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fan-ctrl/fan-ctrl/set_fan_speed.sh b/meta-facebook/meta-yosemite/recipes-yosemite/fan-ctrl/fan-ctrl/set_fan_speed.sh index 49ef55b..7876619 100755 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fan-ctrl/fan-ctrl/set_fan_speed.sh +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fan-ctrl/fan-ctrl/set_fan_speed.sh @@ -37,14 +37,14 @@ fi # refer to the comments in init_pwn.sh regarding # the fan unit and PWM mapping if [ "$#" -eq 1 ]; then - PWMS="0:0 1:0" + PWMS="0:0 1:1" else case "$2" in "0") PWMS="0:0" ;; "1") - PWMS="1:0" + PWMS="1:1" ;; *) usage diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fan-ctrl/fan-ctrl_0.1.bbappend b/meta-facebook/meta-yosemite/recipes-yosemite/fan-ctrl/fan-ctrl_0.1.bbappend index d5659ae..eb91d6c 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fan-ctrl/fan-ctrl_0.1.bbappend +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fan-ctrl/fan-ctrl_0.1.bbappend @@ -51,7 +51,7 @@ do_install() { install -d ${D}${sysconfdir}/init.d install -d ${D}${sysconfdir}/rcS.d install -m 755 setup-fan.sh ${D}${sysconfdir}/init.d/setup-fan.sh - update-rc.d -r ${D} setup-fan.sh start 91 S . + update-rc.d -r ${D} setup-fan.sh start 91 5 . } FBPACKAGEDIR = "${prefix}/local/fbpackages" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/bic/bic.c b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/bic/bic.c index 55cd56b..4139b44 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/bic/bic.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/bic/bic.c @@ -22,10 +22,15 @@ #include <stdio.h> #include <stdint.h> #include <fcntl.h> +#include <syslog.h> #include "bic.h" #define FRUID_READ_COUNT_MAX 0x30 +#define FRUID_WRITE_COUNT_MAX 0x30 +#define CPLD_WRITE_COUNT_MAX 0x50 #define SDR_READ_COUNT_MAX 0x1A +#define SIZE_SYS_GUID 16 +#define SIZE_IANA_ID 3 enum { IPMB_BUS_SLOT1 = 3, @@ -87,7 +92,9 @@ bic_ipmb_wrapper(uint8_t slot_id, uint8_t netfn, uint8_t cmd, ret = get_ipmb_bus_id(slot_id); if (ret < 0) { - printf("bic_ipmb_wrapper: Wrong Slot ID %d\n", slot_id); +#ifdef DEBUG + syslog(LOG_ERR, "bic_ipmb_wrapper: Wrong Slot ID %d\n", slot_id); +#endif return ret; } @@ -114,8 +121,11 @@ bic_ipmb_wrapper(uint8_t slot_id, uint8_t netfn, uint8_t cmd, // Invoke IPMB library handler lib_ipmb_handle(bus_id, tbuf, tlen, &rbuf, &rlen); + if (rlen == 0) { - printf("bic_ipmb_wrapper: Zero bytes received\n"); +#ifdef DEBUG + syslog(LOG_DEBUG, "bic_ipmb_wrapper: Zero bytes received\n"); +#endif return -1; } @@ -123,7 +133,9 @@ bic_ipmb_wrapper(uint8_t slot_id, uint8_t netfn, uint8_t cmd, res = (ipmb_res_t*) rbuf; if (res->cc) { - printf("bic_ipmb_wrapper: Completion Code: 0x%X\n", res->cc); +#ifdef DEBUG + syslog(LOG_ERR, "bic_ipmb_wrapper: Completion Code: 0x%X\n", res->cc); +#endif return -1; } @@ -148,17 +160,23 @@ bic_get_dev_id(uint8_t slot_id, ipmi_dev_id_t *dev_id) { // Get GPIO value and configuration int bic_get_gpio(uint8_t slot_id, bic_gpio_t *gpio) { + uint8_t tbuf[3] = {0x15, 0xA0, 0x00}; // IANA ID + uint8_t rbuf[7] = {0x00}; uint8_t rlen = 0; int ret; - ret = bic_ipmb_wrapper(slot_id, NETFN_OEM_1S_REQ, CMD_OEM_1S_GET_GPIO, NULL, 0, (uint8_t*) gpio, &rlen); + ret = bic_ipmb_wrapper(slot_id, NETFN_OEM_1S_REQ, CMD_OEM_1S_GET_GPIO, tbuf, 0x03, rbuf, &rlen); + + // Ignore first 3 bytes of IANA ID + memcpy((uint8_t*) gpio, &rbuf[3], 4); return ret; } int bic_get_gpio_config(uint8_t slot_id, uint8_t gpio, bic_gpio_config_t *gpio_config) { - uint8_t tbuf[4] = {0}; + uint8_t tbuf[7] = {0x15, 0xA0, 0x00}; // IANA ID + uint8_t rbuf[4] = {0x00}; uint8_t rlen = 0; uint8_t tlen = 0; uint32_t pin; @@ -166,75 +184,245 @@ bic_get_gpio_config(uint8_t slot_id, uint8_t gpio, bic_gpio_config_t *gpio_confi pin = 1 << gpio; - tbuf[0] = pin & 0xFF; - tbuf[1] = (pin >> 8) & 0xFF; - tbuf[2] = (pin >> 16) & 0xFF; - tbuf[3] = (pin >> 24) & 0xFF; + tbuf[3] = pin & 0xFF; + tbuf[4] = (pin >> 8) & 0xFF; + tbuf[5] = (pin >> 16) & 0xFF; + tbuf[6] = (pin >> 24) & 0xFF; - tlen = 4; + tlen = 7; - ret = bic_ipmb_wrapper(slot_id, NETFN_OEM_1S_REQ, CMD_OEM_1S_GET_GPIO_CONFIG, tbuf, tlen, (uint8_t *) gpio_config, &rlen); + ret = bic_ipmb_wrapper(slot_id, NETFN_OEM_1S_REQ, CMD_OEM_1S_GET_GPIO_CONFIG, tbuf, tlen, rbuf, &rlen); + + // Ignore IANA ID + *(uint8_t *) gpio_config = rbuf[3]; return ret; } int bic_set_gpio_config(uint8_t slot_id, uint8_t gpio, bic_gpio_config_t *gpio_config) { - uint8_t tbuf[5] = {0}; + uint8_t tbuf[8] = {0x15, 0xA0, 0x00}; // IANA ID + uint8_t rbuf[4] = {0x00}; uint8_t rlen = 0; uint8_t tlen = 0; uint32_t pin; - uint8_t res; int ret; pin = 1 << gpio; - tbuf[0] = pin & 0xFF; - tbuf[1] = (pin >> 8) & 0xFF; - tbuf[2] = (pin >> 16) & 0xFF; - tbuf[3] = (pin >> 24) & 0xFF; - tbuf[4] = (*(uint8_t *) gpio_config) & 0x1F; + tbuf[3] = pin & 0xFF; + tbuf[4] = (pin >> 8) & 0xFF; + tbuf[5] = (pin >> 16) & 0xFF; + tbuf[6] = (pin >> 24) & 0xFF; + tbuf[7] = (*(uint8_t *) gpio_config) & 0x1F; - tlen = 5; + tlen = 8; ret = bic_ipmb_wrapper(slot_id, NETFN_OEM_1S_REQ, CMD_OEM_1S_SET_GPIO_CONFIG, - tbuf, tlen, &res, &rlen); + tbuf, tlen, rbuf, &rlen); return ret; } // Get BIC Configuration int bic_get_config(uint8_t slot_id, bic_config_t *cfg) { + uint8_t tbuf[3] = {0x15, 0xA0, 0x00}; // IANA ID + uint8_t rbuf[4] = {0x00}; uint8_t rlen = 0; int ret; ret = bic_ipmb_wrapper(slot_id, NETFN_OEM_1S_REQ, CMD_OEM_1S_GET_CONFIG, - NULL, 0x00, (uint8_t *) cfg, &rlen); + tbuf, 0x03, rbuf, &rlen); + // Ignore IANA ID + *(uint8_t *) cfg = rbuf[3]; + return ret; } // Set BIC Configuration int bic_set_config(uint8_t slot_id, bic_config_t *cfg) { + uint8_t tbuf[4] = {0x15, 0xA0, 0x00}; // IANA ID uint8_t rlen = 0; uint8_t rbuf[4] = {0}; int ret; + tbuf[3] = *(uint8_t *) cfg; + ret = bic_ipmb_wrapper(slot_id, NETFN_OEM_1S_REQ, CMD_OEM_1S_SET_CONFIG, - (uint8_t *) cfg, 1, rbuf, &rlen); + tbuf, 0x04, rbuf, &rlen); return ret; } // Read POST Buffer int bic_get_post_buf(uint8_t slot_id, uint8_t *buf, uint8_t *len) { + uint8_t tbuf[3] = {0x15, 0xA0, 0x00}; // IANA ID + uint8_t rbuf[255] = {0x00}; + uint8_t rlen = 0; + int ret; + + ret = bic_ipmb_wrapper(slot_id, NETFN_OEM_1S_REQ, CMD_OEM_1S_GET_POST_BUF, tbuf, 0x03, rbuf, &rlen); + + //Ignore IANA ID + memcpy(buf, &rbuf[3], rlen-3); + + *len = rlen - 3; + + return ret; +} + +// Read Firwmare Versions of various components +int +bic_get_fw_ver(uint8_t slot_id, uint8_t comp, uint8_t *ver) { + uint8_t tbuf[4] = {0x15, 0xA0, 0x00}; // IANA ID + uint8_t rbuf[16] = {0x00}; + uint8_t rlen = 0; int ret; - ret = bic_ipmb_wrapper(slot_id, NETFN_OEM_1S_REQ, CMD_OEM_1S_GET_POST_BUF, NULL, 0, buf, len); + // Fill the component for which firmware is requested + tbuf[3] = comp; + + ret = bic_ipmb_wrapper(slot_id, NETFN_OEM_1S_REQ, CMD_OEM_1S_GET_FW_VER, tbuf, 0x04, rbuf, &rlen); + // fw version has to be between 2 and 5 bytes based on component + if (ret || (rlen < 2+SIZE_IANA_ID) || (rlen > 5+SIZE_IANA_ID)) { +#ifdef DEBUG + syslog(LOG_ERR, "bic_get_fw_ver: ret: %d, rlen: %d\n", ret, rlen); +#endif + return -1; + } + + //Ignore IANA ID + memcpy(ver, &rbuf[3], rlen-3); return ret; } +// Update firmware for various components +static int +_update_fw(uint8_t slot_id, uint8_t target, uint32_t offset, uint16_t len, uint8_t *buf) { + uint8_t tbuf[256] = {0x15, 0xA0, 0x00}; // IANA ID + uint8_t rbuf[16] = {0x00}; + uint8_t tlen = 0; + uint8_t rlen = 0; + int ret; + int retries = 3; + + // Fill the component for which firmware is requested + tbuf[3] = target; + + tbuf[4] = (offset) & 0xFF; + tbuf[5] = (offset >> 8) & 0xFF; + tbuf[6] = (offset >> 16) & 0xFF; + tbuf[7] = (offset >> 24) & 0xFF; + + tbuf[8] = len & 0xFF; + tbuf[9] = (len >> 8) & 0xFF; + + memcpy(&tbuf[10], buf, len); + + printf("_update_fw: target: %d, offset: %d, len: %d\n", target, offset, len); + + tlen = len + 10; + +bic_send: + ret = bic_ipmb_wrapper(slot_id, NETFN_OEM_1S_REQ, CMD_OEM_1S_UPDATE_FW, tbuf, tlen, rbuf, &rlen); + if ((ret) && (retries--)) { + sleep(1); + printf("_update_fw: retrying..\n"); + goto bic_send; + } + + return ret; +} + +int +bic_update_fw(uint8_t slot_id, uint8_t comp, char *path) { + int ret; + uint32_t offset; + uint16_t count; + uint8_t buf[256] = {0}; + uint8_t len = 0; + uint8_t target; + int fd; + + // Open the file exclusively for read + fd = open(path, O_RDONLY, 0666); + if (fd < 0) { +#ifdef DEBUG + syslog(LOG_ERR, "bic_update_fw: open fails for path: %s\n", path); +#endif + goto error_exit; + } + + // Write chunks of CPLD binary data in a loop + offset = 0; + while (1) { + // Read from file + count = read(fd, buf, CPLD_WRITE_COUNT_MAX); + if (count <= 0) { + break; + } + + if (count == CPLD_WRITE_COUNT_MAX) { + target = comp; + } else { + target = comp | 0x80; + } + + // Write to the CPLD + ret = _update_fw(slot_id, target, offset, count, buf); + if (ret) { + break; + } + + // Update counter + offset += count; + } + +error_exit: + if (fd > 0 ) { + close(fd); + } + + return ret; +} + +int +bic_me_xmit(uint8_t slot_id, uint8_t *txbuf, uint8_t txlen, uint8_t *rxbuf, uint8_t *rxlen) { + uint8_t tbuf[256] = {0x15, 0xA0, 0x00}; // IANA ID + uint8_t rbuf[256] = {0x00}; + uint8_t rlen = 0; + uint8_t tlen = 0; + int ret; + + // Fill the interface number as ME + tbuf[3] = BIC_INTF_ME; + + // Fill the data to be sent + memcpy(&tbuf[4], txbuf, txlen); + + // Send data length includes IANA ID and interface number + tlen = txlen + 4; + + ret = bic_ipmb_wrapper(slot_id, NETFN_OEM_1S_REQ, CMD_OEM_1S_MSG_OUT, tbuf, tlen, rbuf, &rlen); + if (ret ) { + return -1; + } + + // Make sure the received interface number is same + if (rbuf[3] != tbuf[3]) { + return -1; + } + + // Copy the received data to caller skipping header + memcpy(rxbuf, &rbuf[7], rlen-7); + + *rxlen = rlen-7; + + return 0; +} + // Read 1S server's FRUID int bic_get_fruid_info(uint8_t slot_id, uint8_t fru_id, ipmi_fruid_info_t *info) { @@ -279,19 +467,23 @@ bic_read_fruid(uint8_t slot_id, uint8_t fru_id, const char *path) { // Open the file exclusively for write fd = open(path, O_WRONLY | O_CREAT | O_EXCL, 0666); if (fd < 0) { - printf("bic_read_fruid: open fails for path: %s\n", path); +#ifdef DEBUG + syslog(LOG_ERR, "bic_read_fruid: open fails for path: %s\n", path); +#endif goto error_exit; } // Read the FRUID information ret = bic_get_fruid_info(slot_id, fru_id, &info); if (ret) { - printf("bic_read_fruid: bic_read_fruid_info returns %d\n", ret); +#ifdef DEBUG + syslog(LOG_ERR, "bic_read_fruid: bic_read_fruid_info returns %d\n", ret); +#endif goto error_exit; } // Indicates the size of the FRUID - nread = (info.size_msb << 8) + (info.size_lsb); + nread = (info.size_msb << 6) + (info.size_lsb); // Read chunks of FRUID binary data in a loop offset = 0; @@ -304,7 +496,9 @@ bic_read_fruid(uint8_t slot_id, uint8_t fru_id, const char *path) { ret = _read_fruid(slot_id, fru_id, offset, count, rbuf, &rlen); if (ret) { - printf("bic_read_fruid: ipmb_wrapper fails\n"); +#ifdef DEBUG + syslog(LOG_ERR, "bic_read_fruid: ipmb_wrapper fails\n"); +#endif goto error_exit; } @@ -324,6 +518,79 @@ error_exit: return ret; } +static int +_write_fruid(uint8_t slot_id, uint8_t fru_id, uint32_t offset, uint8_t count, uint8_t *buf) { + int ret; + uint8_t tbuf[64] = {0}; + uint8_t rbuf[4] = {0}; + uint8_t tlen = 0; + uint8_t rlen = 0; + + tbuf[0] = fru_id; + tbuf[1] = offset & 0xFF; + tbuf[2] = (offset >> 8) & 0xFF; + + memcpy(&tbuf[3], buf, count); + tlen = count + 3; + + ret = bic_ipmb_wrapper(slot_id, NETFN_STORAGE_REQ, CMD_STORAGE_WRITE_FRUID_DATA, tbuf, tlen, rbuf, &rlen); + + if (ret) { + return ret; + } + + if (rbuf[0] != count) { + return -1; + } + + return ret; +} + +int +bic_write_fruid(uint8_t slot_id, uint8_t fru_id, const char *path) { + int ret; + uint32_t offset; + uint8_t count; + uint8_t buf[64] = {0}; + uint8_t len = 0; + int fd; + + // Open the file exclusively for read + fd = open(path, O_RDONLY, 0666); + if (fd < 0) { +#ifdef DEBUG + syslog(LOG_ERR, "bic_write_fruid: open fails for path: %s\n", path); +#endif + goto error_exit; + } + + // Write chunks of FRUID binary data in a loop + offset = 0; + while (1) { + // Read from file + count = read(fd, buf, FRUID_WRITE_COUNT_MAX); + if (count <= 0) { + break; + } + + // Write to the FRUID + ret = _write_fruid(slot_id, fru_id, offset, count, buf); + if (ret) { + break; + } + + // Update counter + offset += count; + } + +error_exit: + if (fd > 0 ) { + close(fd); + } + + return ret; +} + // Read System Event Log (SEL) int bic_get_sel_info(uint8_t slot_id, ipmi_sel_sdr_info_t *info) { @@ -398,7 +665,9 @@ bic_get_sdr(uint8_t slot_id, ipmi_sel_sdr_req_t *req, ipmi_sel_sdr_res_t *res, u // Get SDR reservation ID for the given record ret = _get_sdr_rsv(slot_id, &req->rsv_id); if (ret) { - printf("bic_read_sdr: _get_sdr_rsv returns %d\n", ret); +#ifdef DEBUG + syslog(LOG_ERR, "bic_read_sdr: _get_sdr_rsv returns %d\n", ret); +#endif return ret; } @@ -411,7 +680,9 @@ bic_get_sdr(uint8_t slot_id, ipmi_sel_sdr_req_t *req, ipmi_sel_sdr_res_t *res, u ret = _get_sdr(slot_id, req, tbuf, &tlen); if (ret) { - printf("bic_read_sdr: _get_sdr returns %d\n", ret); +#ifdef DEBUG + syslog(LOG_ERR, "bic_read_sdr: _get_sdr returns %d\n", ret); +#endif return ret; } @@ -439,7 +710,9 @@ bic_get_sdr(uint8_t slot_id, ipmi_sel_sdr_req_t *req, ipmi_sel_sdr_res_t *res, u ret = _get_sdr(slot_id, req, tbuf, &tlen); if (ret) { - printf("bic_read_sdr: _get_sdr returns %d\n", ret); +#ifdef DEBUG + syslog(LOG_ERR, "bic_read_sdr: _get_sdr returns %d\n", ret); +#endif return ret; } @@ -464,3 +737,19 @@ bic_read_sensor(uint8_t slot_id, uint8_t sensor_num, ipmi_sensor_reading_t *sens return ret; } + +int +bic_get_sys_guid(uint8_t slot_id, uint8_t *guid) { + int ret; + int rlen = 0; + + ret = bic_ipmb_wrapper(slot_id, NETFN_APP_REQ, CMD_APP_GET_SYSTEM_GUID, NULL, 0, guid, &rlen); + if (rlen != SIZE_SYS_GUID) { +#ifdef DEBUG + syslog(LOG_ERR, "bic_get_sys_guid: returned rlen of %d\n"); +#endif + return -1; + } + + return ret; +} diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/bic/bic.h b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/bic/bic.h index 47b0baa..7110574 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/bic/bic.h +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/bic/bic.h @@ -66,6 +66,23 @@ enum { RESERVED_31, }; +enum { + FW_CPLD = 1, + FW_BIC, + FW_ME, + FW_PVCCIN_VR, + FW_DDRAB_VR, + FW_P1V05_VR, + FW_PVCCGBE_VR, + FW_PVCCSCSUS_VR, +}; + +enum { + UPDATE_BIOS = 0, + UPDATE_CPLD, + UPDATE_BIC_BOOT +}; + // Bridge IC Spec typedef struct _bic_gpio_t { uint32_t pwrgood_cpu:1; @@ -138,6 +155,7 @@ int bic_get_post_buf(uint8_t slot_id, uint8_t *buf, uint8_t *len); int bic_get_fruid_info(uint8_t slot_id, uint8_t fru_id, ipmi_fruid_info_t *info); int bic_read_fruid(uint8_t slot_id, uint8_t fru_id, const char *path); +int bic_write_fruid(uint8_t slot_id, uint8_t fru_id, const char *path); int bic_get_sel_info(uint8_t slot_id, ipmi_sel_sdr_info_t *info); int bic_get_sel_rsv(uint8_t slot_id, uint16_t *rsv); @@ -149,6 +167,13 @@ int bic_get_sdr(uint8_t slot_id, ipmi_sel_sdr_req_t *req, ipmi_sel_sdr_res_t *re int bic_read_sensor(uint8_t slot_id, uint8_t sensor_num, ipmi_sensor_reading_t *sensor); +int bic_get_sys_guid(uint8_t slot_id, uint8_t *guid); + +int bic_get_fw_ver(uint8_t slot_id, uint8_t comp, uint8_t *ver); + +int bic_update_fw(uint8_t slot_id, uint8_t comp, char *path); +int bic_me_xmit(uint8_t slot_id, uint8_t *txbuf, uint8_t txlen, uint8_t *rxbuf, uint8_t *rxlen); + #ifdef __cplusplus } // extern "C" #endif diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/pal/Makefile b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/pal/Makefile index bab4007..c207a7d 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/pal/Makefile +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/pal/Makefile @@ -2,7 +2,7 @@ lib: libpal.so libpal.so: pal.c - $(CC) $(CFLAGS) -fPIC -c -o pal.o pal.c + $(CC) $(CFLAGS) -fPIC -c -pthread -o pal.o pal.c $(CC) -lbic -lyosemite_common -lyosemite_fruid -lyosemite_sensor -shared -o libpal.so pal.o -lc .PHONY: clean diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/pal/pal.c b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/pal/pal.c index 93a5fbf..ec0be12 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/pal/pal.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/pal/pal.c @@ -27,6 +27,7 @@ #include <syslog.h> #include <sys/mman.h> #include <string.h> +#include <pthread.h> #include "pal.h" #define BIT(value, index) ((value >> index) & 1) @@ -45,8 +46,11 @@ #define GPIO_RST_BTN 144 #define GPIO_PWR_BTN 24 +#define GPIO_HB_LED 135 + #define GPIO_USB_SW0 36 #define GPIO_USB_SW1 37 +#define GPIO_USB_MUX_EN_N 147 #define GPIO_UART_SEL0 32 #define GPIO_UART_SEL1 33 @@ -68,20 +72,27 @@ #define AST_SCU_BASE 0x1e6e2000 #define PIN_CTRL1_OFFSET 0x80 #define PIN_CTRL2_OFFSET 0x84 +#define AST_WDT_BASE 0x1e785000 +#define WDT_OFFSET 0x10 #define UART1_TXD (1 << 22) #define UART2_TXD (1 << 30) #define UART3_TXD (1 << 22) #define UART4_TXD (1 << 30) -#define BIT(v, i) ((v >> i) & 1) #define DELAY_GRACEFUL_SHUTDOWN 1 -#define DELAY_POWER_OFF 5 - -static uint8_t gpio_rst_btn[5] = { 0, 57, 56, 59, 58 }; -static uint8_t gpio_led[5] = { 0, 97, 96, 99, 98 }; -static uint8_t gpio_prsnt[5] = { 0, 61, 60, 63, 62 }; -static uint8_t gpio_power[5] = { 0, 27, 25, 31, 29 }; +#define DELAY_POWER_OFF 6 +#define DELAY_POWER_CYCLE 10 +#define DELAY_12V_CYCLE 5 + +#define CRASHDUMP_BIN "/usr/local/bin/dump.sh" +#define CRASHDUMP_FILE "/mnt/data/crashdump_" +const static uint8_t gpio_rst_btn[] = { 0, 57, 56, 59, 58 }; +const static uint8_t gpio_led[] = { 0, 97, 96, 99, 98 }; +const static uint8_t gpio_id_led[] = { 0, 41, 40, 43, 42 }; +const static uint8_t gpio_prsnt[] = { 0, 61, 60, 63, 62 }; +const static uint8_t gpio_power[] = { 0, 27, 25, 31, 29 }; +const static uint8_t gpio_12v[] = { 0, 117, 116, 119, 118 }; const char pal_fru_list[] = "all, slot1, slot2, slot3, slot4, spb, nic"; const char pal_server_list[] = "slot1, slot2, slot3, slot4"; @@ -90,6 +101,16 @@ char * key_list[] = { "pwr_server2_last_state", "pwr_server3_last_state", "pwr_server4_last_state", +"sysfw_ver_slot1", +"sysfw_ver_slot2", +"sysfw_ver_slot3", +"sysfw_ver_slot4", +"identify_sled", +"identify_slot1", +"identify_slot2", +"identify_slot3", +"identify_slot4", +"timestamp_sled", "slot1_por_cfg", "slot2_por_cfg", "slot3_por_cfg", @@ -98,6 +119,29 @@ char * key_list[] = { LAST_KEY /* This is the last key of the list */ }; +char * def_val_list[] = { + "on", /* pwr_server1_last_state */ + "on", /* pwr_server2_last_state */ + "on", /* pwr_server3_last_state */ + "on", /* pwr_server4_last_state */ + "0", /* sysfw_ver_slot1 */ + "0", /* sysfw_ver_slot2 */ + "0", /* sysfw_ver_slot3 */ + "0", /* sysfw_ver_slot4 */ + "off", /* identify_sled */ + "off", /* identify_slot1 */ + "off", /* identify_slot2 */ + "off", /* identify_slot3 */ + "off", /* identify_slot4 */ + "0", /* timestamp_sled */ + "on", /* slot1_por_cfg */ + "on", /* slot2_por_cfg */ + "on", /* slot3_por_cfg */ + "on", /* slot4_por_cfg */ + /* Add more def values for the correspoding keys*/ + LAST_KEY /* Same as last entry of the key_list */ +}; + // Helper Functions static int read_device(const char *device, int *value) { @@ -107,15 +151,18 @@ read_device(const char *device, int *value) { fp = fopen(device, "r"); if (!fp) { int err = errno; - +#ifdef DEBUG syslog(LOG_INFO, "failed to open device %s", device); +#endif return err; } rc = fscanf(fp, "%d", value); fclose(fp); if (rc != 1) { +#ifdef DEBUG syslog(LOG_INFO, "failed to read device %s", device); +#endif return ENOENT; } else { return 0; @@ -130,8 +177,9 @@ write_device(const char *device, const char *value) { fp = fopen(device, "w"); if (!fp) { int err = errno; - +#ifdef DEBUG syslog(LOG_INFO, "failed to open device for write %s", device); +#endif return err; } @@ -139,7 +187,9 @@ write_device(const char *device, const char *value) { fclose(fp); if (rc < 0) { +#ifdef DEBUG syslog(LOG_INFO, "failed to write device %s", device); +#endif return ENOENT; } else { return 0; @@ -204,6 +254,42 @@ server_power_off(uint8_t slot_id, bool gs_flag) { return 0; } +// Control 12V to the server in a given slot +static int +server_12v_on(uint8_t slot_id) { + char vpath[64] = {0}; + + if (slot_id < 1 || slot_id > 4) { + return -1; + } + + sprintf(vpath, GPIO_VAL, gpio_12v[slot_id]); + + if (write_device(vpath, "1")) { + return -1; + } + + return 0; +} + +// Turn off 12V for the server in given slot +static int +server_12v_off(uint8_t slot_id) { + char vpath[64] = {0}; + + if (slot_id < 1 || slot_id > 4) { + return -1; + } + + sprintf(vpath, GPIO_VAL, gpio_12v[slot_id]); + + if (write_device(vpath, "0")) { + return -1; + } + + return 0; +} + // Debug Card's UART and BMC/SoL port share UART port and need to enable only // one TXD i.e. either BMC's TXD or Debug Port's TXD. static int @@ -216,7 +302,9 @@ control_sol_txd(uint8_t slot) { scu_fd = open("/dev/mem", O_RDWR | O_SYNC ); if (scu_fd < 0) { - syslog(LOG_ALERT, "control_sol_txd: open fails\n"); +#ifdef DEBUG + syslog(LOG_WARNING, "control_sol_txd: open fails\n"); +#endif return -1; } @@ -295,7 +383,9 @@ pal_post_display(uint8_t status) { int ret; char *val; - syslog(LOG_ALERT, "pal_post_display: status is %d\n", status); +#ifdef DEBUG + syslog(LOG_WARNING, "pal_post_display: status is %d\n", status); +#endif sprintf(path, GPIO_VAL, GPIO_POSTCODE_0); @@ -396,7 +486,9 @@ pal_post_display(uint8_t status) { post_exit: if (ret) { - syslog(LOG_ALERT, "write_device failed for %s\n", path); +#ifdef DEBUG + syslog(LOG_WARNING, "write_device failed for %s\n", path); +#endif return -1; } else { return 0; @@ -453,11 +545,10 @@ pal_is_debug_card_prsnt(uint8_t *status) { return -1; } - // TODO: Logic is reversed until DVT board with h/w fix if (val == 0x0) { - *status = 0; - } else { *status = 1; + } else { + *status = 0; } return 0; @@ -466,11 +557,19 @@ pal_is_debug_card_prsnt(uint8_t *status) { int pal_get_server_power(uint8_t slot_id, uint8_t *status) { int ret; + char value[MAX_VALUE_LEN]; bic_gpio_t gpio; ret = bic_get_gpio(slot_id, &gpio); if (ret) { - return ret; + // Check for if the BIC is irresponsive due to 12V_OFF or 12V_CYCLE + pal_get_last_pwr_state(slot_id, value); + if (!(strcmp(value, "off"))) { + *status = SERVER_POWER_OFF; + return 0; + } else { + return ret; + } } if (gpio.pwrgood_cpu) { @@ -512,10 +611,18 @@ pal_set_server_power(uint8_t slot_id, uint8_t cmd) { break; case SERVER_POWER_CYCLE: - if (status == SERVER_POWER_ON) - return (server_power_off(slot_id, gs_flag) || server_power_on(slot_id)); - else if (status == SERVER_POWER_OFF) + if (status == SERVER_POWER_ON) { + if (server_power_off(slot_id, gs_flag)) + return -1; + + sleep(DELAY_POWER_CYCLE); + + return server_power_on(slot_id); + + } else if (status == SERVER_POWER_OFF) { + return (server_power_on(slot_id)); + } break; case SERVER_GRACEFUL_SHUTDOWN: @@ -525,6 +632,23 @@ pal_set_server_power(uint8_t slot_id, uint8_t cmd) { gs_flag = true; return server_power_off(slot_id, gs_flag); break; + + case SERVER_12V_ON: + return server_12v_on(slot_id); + break; + + case SERVER_12V_OFF: + return server_12v_off(slot_id); + break; + + case SERVER_12V_CYCLE: + if (server_12v_off(slot_id)) { + return -1; + } + + sleep(DELAY_12V_CYCLE); + + return (server_12v_on(slot_id)); default: return -1; } @@ -582,20 +706,20 @@ pal_get_hand_sw(uint8_t *pos) { loc = ((id8 << 3) | (id4 << 2) | (id2 << 1) | (id1)); switch(loc) { + case 0: + case 5: + *pos = HAND_SW_SERVER1; + break; case 1: case 6: - *pos = HAND_SW_SERVER1; + *pos = HAND_SW_SERVER2; break; case 2: case 7: - *pos = HAND_SW_SERVER2; + *pos = HAND_SW_SERVER3; break; case 3: case 8: - *pos = HAND_SW_SERVER3; - break; - case 4: - case 9: *pos = HAND_SW_SERVER4; break; default: @@ -657,9 +781,9 @@ pal_set_rst_btn(uint8_t slot, uint8_t status) { } if (status) { - val = "0"; - } else { val = "1"; + } else { + val = "0"; } sprintf(path, GPIO_VAL, gpio_rst_btn[slot]); @@ -694,6 +818,81 @@ pal_set_led(uint8_t slot, uint8_t status) { return 0; } +// Update Heartbeet LED +int +pal_set_hb_led(uint8_t status) { + char path[64] = {0}; + char *val; + + if (status) { + val = "1"; + } else { + val = "0"; + } + + sprintf(path, GPIO_VAL, GPIO_HB_LED); + if (write_device(path, val)) { + return -1; + } + + return 0; +} + +// Update the Identification LED for the given slot with the status +int +pal_set_id_led(uint8_t slot, uint8_t status) { + char path[64] = {0}; + char *val; + + if (slot < 1 || slot > 4) { + return -1; + } + + if (status) { + val = "1"; + } else { + val = "0"; + } + + sprintf(path, GPIO_VAL, gpio_id_led[slot]); + if (write_device(path, val)) { + return -1; + } + + return 0; +} + +static int +set_usb_mux(uint8_t state) { + int val; + char *new_state; + char path[64] = {0}; + + sprintf(path, GPIO_VAL, GPIO_USB_MUX_EN_N); + + if (read_device(path, &val)) { + return -1; + } + + // This GPIO Pin is active low + if (!val == state) + return 0; + + if (state) + new_state = "0"; + else + new_state = "1"; + + if (write_device(path, new_state) < 0) { +#ifdef DEBUG + syslog(LOG_WARNING, "write_device failed for %s\n", path); +#endif + return -1; + } + + return 0; +} + // Update the USB Mux to the server at given slot int pal_switch_usb_mux(uint8_t slot) { @@ -702,36 +901,49 @@ pal_switch_usb_mux(uint8_t slot) { // Based on the USB mux table in Schematics switch(slot) { - case 1: + case HAND_SW_SERVER1: gpio_sw0 = "1"; gpio_sw1 = "0"; break; - case 2: + case HAND_SW_SERVER2: gpio_sw0 = "0"; gpio_sw1 = "0"; break; - case 3: + case HAND_SW_SERVER3: gpio_sw0 = "1"; gpio_sw1 = "1"; break; - case 4: + case HAND_SW_SERVER4: gpio_sw0 = "0"; gpio_sw1 = "1"; break; + case HAND_SW_BMC: + // Disable the USB MUX + if (set_usb_mux(USB_MUX_OFF) < 0) + return -1; + else + return 0; default: - // Default is for BMC itself return 0; } + // Enable the USB MUX + if (set_usb_mux(USB_MUX_ON) < 0) + return -1; + sprintf(path, GPIO_VAL, GPIO_USB_SW0); if (write_device(path, gpio_sw0) < 0) { - syslog(LOG_ALERT, "write_device failed for %s\n", path); +#ifdef DEBUG + syslog(LOG_WARNING, "write_device failed for %s\n", path); +#endif return -1; } sprintf(path, GPIO_VAL, GPIO_USB_SW1); if (write_device(path, gpio_sw1) < 0) { - syslog(LOG_ALERT, "write_device failed for %s\n", path); +#ifdef DEBUG + syslog(LOG_WARNING, "write_device failed for %s\n", path); +#endif return -1; } @@ -750,25 +962,25 @@ pal_switch_uart_mux(uint8_t slot) { // Refer the UART select table in schematic switch(slot) { - case 1: + case HAND_SW_SERVER1: gpio_uart_sel2 = "0"; gpio_uart_sel1 = "0"; gpio_uart_sel0 = "1"; gpio_uart_rx = "0"; break; - case 2: + case HAND_SW_SERVER2: gpio_uart_sel2 = "0"; gpio_uart_sel1 = "0"; gpio_uart_sel0 = "0"; gpio_uart_rx = "0"; break; - case 3: + case HAND_SW_SERVER3: gpio_uart_sel2 = "0"; gpio_uart_sel1 = "1"; gpio_uart_sel0 = "1"; gpio_uart_rx = "0"; break; - case 4: + case HAND_SW_SERVER4: gpio_uart_sel2 = "0"; gpio_uart_sel1 = "1"; gpio_uart_sel0 = "0"; @@ -816,7 +1028,9 @@ pal_switch_uart_mux(uint8_t slot) { uart_exit: if (ret) { - syslog(LOG_ALERT, "pal_switch_uart_mux: write_device failed: %s\n", path); +#ifdef DEBUG + syslog(LOG_WARNING, "pal_switch_uart_mux: write_device failed: %s\n", path); +#endif return ret; } else { return 0; @@ -833,7 +1047,9 @@ pal_post_enable(uint8_t slot) { ret = bic_get_config(slot, &config); if (ret) { - syslog(LOG_ALERT, "post_enable: bic_get_config failed\n"); +#ifdef DEBUG + syslog(LOG_WARNING, "post_enable: bic_get_config failed for fru: %d\n", slot); +#endif return ret; } @@ -841,7 +1057,9 @@ pal_post_enable(uint8_t slot) { ret = bic_set_config(slot, &config); if (ret) { - syslog(LOG_ALERT, "post_enable: bic_set_config failed\n"); +#ifdef DEBUG + syslog(LOG_WARNING, "post_enable: bic_set_config failed\n"); +#endif return ret; } @@ -937,14 +1155,18 @@ read_kv(char *key, char *value) { fp = fopen(key, "r"); if (!fp) { int err = errno; - syslog(LOG_ALERT, "read_kv: failed to open %s", key); +#ifdef DEBUG + syslog(LOG_WARNING, "read_kv: failed to open %s", key); +#endif return err; } rc = (int) fread(value, 1, MAX_VALUE_LEN, fp); fclose(fp); if (rc <= 0) { +#ifdef DEBUG syslog(LOG_INFO, "read_kv: failed to read %s", key); +#endif return ENOENT; } else { return 0; @@ -960,7 +1182,9 @@ write_kv(char *key, char *value) { fp = fopen(key, "w"); if (!fp) { int err = errno; - syslog(LOG_ALERT, "write_kv: failed to open %s", key); +#ifdef DEBUG + syslog(LOG_WARNING, "write_kv: failed to open %s", key); +#endif return err; } @@ -968,7 +1192,9 @@ write_kv(char *key, char *value) { fclose(fp); if (rc < 0) { - syslog(LOG_ALERT, "write_kv: failed to write to %s", key); +#ifdef DEBUG + syslog(LOG_WARNING, "write_kv: failed to write to %s", key); +#endif return ENOENT; } else { return 0; @@ -982,6 +1208,17 @@ pal_get_fru_id(char *str, uint8_t *fru) { } int +pal_get_fru_name(uint8_t fru, char *name) { + + return yosemite_common_fru_name(fru, name); +} + +int +pal_get_fru_sdr_path(uint8_t fru, char *path) { + return yosemite_sensor_sdr_path(fru, path); +} + +int pal_get_fru_sensor_list(uint8_t fru, uint8_t **sensor_list, int *cnt) { switch(fru) { @@ -997,22 +1234,39 @@ pal_get_fru_sensor_list(uint8_t fru, uint8_t **sensor_list, int *cnt) { *cnt = spb_sensor_cnt; break; case FRU_NIC: - *sensor_list = NULL; // (uint8_t *) nic_sensor_list; - *cnt = 0; //nic_sensor_cnt; + *sensor_list = (uint8_t *) nic_sensor_list; + *cnt = nic_sensor_cnt; break; default: - syslog(LOG_ALERT, "pal_get_fru_sensor_list: Wrong fru id %u", fru); +#ifdef DEBUG + syslog(LOG_WARNING, "pal_get_fru_sensor_list: Wrong fru id %u", fru); +#endif return -1; } return 0; } int +pal_fruid_write(uint8_t fru, char *path) { + return bic_write_fruid(fru, 0, path); +} + +int +pal_sensor_sdr_init(uint8_t fru, sensor_info_t *sinfo) { + return yosemite_sensor_sdr_init(fru, sinfo); +} + +int pal_sensor_read(uint8_t fru, uint8_t sensor_num, void *value) { return yosemite_sensor_read(fru, sensor_num, value); } int +pal_get_sensor_threshold(uint8_t fru, uint8_t sensor_num, uint8_t thresh, void *value) { + return yosemite_sensor_threshold(fru, sensor_num, thresh, value); +} + +int pal_get_sensor_name(uint8_t fru, uint8_t sensor_num, char *name) { return yosemite_sensor_name(fru, sensor_num, name); } @@ -1028,6 +1282,11 @@ pal_get_fruid_path(uint8_t fru, char *path) { } int +pal_get_fruid_eeprom_path(uint8_t fru, char *path) { + return yosemite_get_fruid_eeprom_path(fru, path); +} + +int pal_get_fruid_name(uint8_t fru, char *name) { return yosemite_get_fruid_name(fru, name); } @@ -1073,7 +1332,9 @@ pal_get_key_value(char *key, char *value) { if (!strcmp(key, key_list[i])) { // Key is valid if ((ret = get_key_value(key, value)) < 0 ) { - syslog(LOG_ALERT, "pal_get_key_value: get_key_value failed. %d", ret); +#ifdef DEBUG + syslog(LOG_WARNING, "pal_get_key_value: get_key_value failed. %d", ret); +#endif return ret; } return ret; @@ -1085,6 +1346,31 @@ pal_get_key_value(char *key, char *value) { } int +pal_set_def_key_value() { + + int ret; + int i; + char kpath[64] = {0}; + + i = 0; + while(strcmp(key_list[i], LAST_KEY)) { + + sprintf(kpath, KV_STORE, key_list[i]); + + if (access(kpath, F_OK) == -1) { + if ((ret = set_key_value(key_list[i], def_val_list[i])) < 0) { +#ifdef DEBUG + syslog(LOG_WARNING, "pal_set_def_key_value: set_key_value failed. %d", ret); +#endif + } + } + i++; + } + + return 0; +} + +int pal_set_key_value(char *key, char *value) { int ret; @@ -1096,8 +1382,9 @@ pal_set_key_value(char *key, char *value) { if (!strcmp(key, key_list[i])) { // Key is valid if ((ret = set_key_value(key, value)) < 0) { - syslog(LOG_ALERT, "pal_set_key_value: set_key_value failed. %d", ret); - printf("pal_set_key_value: ret = %d\n", ret); +#ifdef DEBUG + syslog(LOG_WARNING, "pal_set_key_value: set_key_value failed. %d", ret); +#endif return ret; } return ret; @@ -1125,7 +1412,9 @@ pal_get_fru_devtty(uint8_t fru, char *devtty) { sprintf(devtty, "/dev/ttyS3"); break; default: - syslog(LOG_ALERT, "pal_get_fru_devtty: Wrong fru id %u", fru); +#ifdef DEBUG + syslog(LOG_WARNING, "pal_get_fru_devtty: Wrong fru id %u", fru); +#endif return -1; } return 0; @@ -1149,3 +1438,516 @@ pal_dump_key_value(void) { memset(value, 0, MAX_VALUE_LEN); } } + +int +pal_set_last_pwr_state(uint8_t fru, char *state) { + + int ret; + char key[MAX_KEY_LEN] = {0}; + + sprintf(key, "pwr_server%d_last_state", (int) fru); + + ret = pal_set_key_value(key, state); + if (ret < 0) { +#ifdef DEBUG + syslog(LOG_WARNING, "pal_set_last_pwr_state: pal_set_key_value failed for " + "fru %u", fru); +#endif + } + return ret; +} + +int +pal_get_last_pwr_state(uint8_t fru, char *state) { + int ret; + char key[MAX_KEY_LEN] = {0}; + + switch(fru) { + case FRU_SLOT1: + case FRU_SLOT2: + case FRU_SLOT3: + case FRU_SLOT4: + + sprintf(key, "pwr_server%d_last_state", (int) fru); + + ret = pal_get_key_value(key, state); + if (ret < 0) { +#ifdef DEBUG + syslog(LOG_WARNING, "pal_get_last_pwr_state: pal_get_key_value failed for " + "fru %u", fru); +#endif + } + return ret; + case FRU_SPB: + case FRU_NIC: + sprintf(state, "on"); + return 0; + } +} + +int +pal_get_sys_guid(uint8_t slot, char *guid) { + int ret; + + return bic_get_sys_guid(slot, guid); +} + +int +pal_set_sysfw_ver(uint8_t slot, uint8_t *ver) { + int i; + char key[MAX_KEY_LEN] = {0}; + char str[MAX_VALUE_LEN] = {0}; + char tstr[10] = {0}; + + sprintf(key, "sysfw_ver_slot%d", (int) slot); + + for (i = 0; i < SIZE_SYSFW_VER; i++) { + sprintf(tstr, "%02x", ver[i]); + strcat(str, tstr); + } + + return pal_set_key_value(key, str); +} + +int +pal_get_sysfw_ver(uint8_t slot, uint8_t *ver) { + int i; + int j = 0; + int ret; + int msb, lsb; + char key[MAX_KEY_LEN] = {0}; + char str[MAX_VALUE_LEN] = {0}; + char tstr[4] = {0}; + + sprintf(key, "sysfw_ver_slot%d", (int) slot); + + ret = pal_get_key_value(key, str); + if (ret) { + return ret; + } + + for (i = 0; i < 2*SIZE_SYSFW_VER; i += 2) { + sprintf(tstr, "%c\n", str[i]); + msb = strtol(tstr, NULL, 16); + + sprintf(tstr, "%c\n", str[i+1]); + lsb = strtol(tstr, NULL, 16); + ver[j++] = (msb << 4) | lsb; + } + + return 0; +} + +int +pal_is_bmc_por(void) { + uint32_t scu_fd; + uint32_t wdt; + void *scu_reg; + void *scu_wdt; + + scu_fd = open("/dev/mem", O_RDWR | O_SYNC ); + if (scu_fd < 0) { + return 0; + } + + scu_reg = mmap(NULL, PAGE_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, scu_fd, + AST_WDT_BASE); + scu_wdt = (char*)scu_reg + WDT_OFFSET; + + wdt = *(volatile uint32_t*) scu_wdt; + + munmap(scu_reg, PAGE_SIZE); + close(scu_fd); + + if (wdt & 0xff00) { + return 0; + } else { + return 1; + } +} + +int +pal_get_fru_discrete_list(uint8_t fru, uint8_t **sensor_list, int *cnt) { + + switch(fru) { + case FRU_SLOT1: + case FRU_SLOT2: + case FRU_SLOT3: + case FRU_SLOT4: + *sensor_list = (uint8_t *) bic_discrete_list; + *cnt = bic_discrete_cnt; + break; + case FRU_SPB: + case FRU_NIC: + return -1; + default: +#ifdef DEBUG + syslog(LOG_WARNING, "pal_get_fru_discrete_list: Wrong fru id %u", fru); +#endif + return -1; + } + return 0; +} + +static void +_print_sensor_discrete_log(uint8_t fru, uint8_t snr_num, char *snr_name, + uint8_t val, char *event) { + if (val) { + syslog(LOG_CRIT, "ASSERT: %s discrete - raised - FRU: %d, num: 0x%X," + " snr: %-16s val: %d", event, fru, snr_num, snr_name, val); + } else { + syslog(LOG_CRIT, "DEASSERT: %s discrete - settled - FRU: %d, num: 0x%X," + " snr: %-16s val: %d", event, fru, snr_num, snr_name, val); + } +} + +int +pal_sensor_discrete_check(uint8_t fru, uint8_t snr_num, char *snr_name, + uint8_t o_val, uint8_t n_val) { + + char name[32]; + bool valid = false; + uint8_t diff = o_val ^ n_val; + + if (GETBIT(diff, 0)) { + switch(snr_num) { + case BIC_SENSOR_SYSTEM_STATUS: + sprintf(name, "SOC_Thermal_Trip"); + valid = true; + break; + case BIC_SENSOR_VR_HOT: + sprintf(name, "SOC_VR_Hot"); + valid = true; + break; + case BIC_SENSOR_CPU_DIMM_HOT: + sprintf(name, "SOC_Hot"); + valid = true; + break; + } + if (valid) { + _print_sensor_discrete_log( fru, snr_num, snr_name, GETBIT(n_val, 0), name); + valid = false; + } + } + + if (GETBIT(diff, 1)) { + switch(snr_num) { + case BIC_SENSOR_SYSTEM_STATUS: + sprintf(name, "SOC_FIVR_Fault"); + valid = true; + break; + case BIC_SENSOR_VR_HOT: + sprintf(name, "SOC_DIMM_VR_Hot"); + valid = true; + break; + case BIC_SENSOR_CPU_DIMM_HOT: + sprintf(name, "SOC_MEMHOT"); + valid = true; + break; + } + if (valid) { + _print_sensor_discrete_log( fru, snr_num, snr_name, GETBIT(n_val, 1), name); + valid = false; + } + } + + if (GETBIT(diff, 2)) { + switch(snr_num) { + case BIC_SENSOR_SYSTEM_STATUS: + sprintf(name, "SOC_Throttle"); + valid = true; + break; + } + if (valid) { + _print_sensor_discrete_log( fru, snr_num, snr_name, GETBIT(n_val, 2), name); + valid = false; + } + } +} + +static int +pal_store_crashdump(uint8_t fru) { + + return yosemite_common_crashdump(fru); +} + +int +pal_sel_handler(uint8_t fru, uint8_t snr_num) { + + switch(snr_num) { + case CATERR: + pal_store_crashdump(fru); + break; + } + + return 0; +} + +int +pal_get_event_sensor_name(uint8_t fru, uint8_t snr_num, char *name) { + + switch(snr_num) { + case SYSTEM_EVENT: + sprintf(name, "SYSTEM_EVENT"); + break; + case THERM_THRESH_EVT: + sprintf(name, "THERM_THRESH_EVT"); + break; + case BUTTON: + sprintf(name, "BUTTON"); + break; + case POWER_STATE: + sprintf(name, "POWER_STATE"); + break; + case CRITICAL_IRQ: + sprintf(name, "CRITICAL_IRQ"); + break; + case POST_ERROR: + sprintf(name, "POST_ERROR"); + break; + case MACHINE_CHK_ERR: + sprintf(name, "MACHINE_CHK_ERR"); + break; + case PCIE_ERR: + sprintf(name, "PCIE_ERR"); + break; + case IIO_ERR: + sprintf(name, "IIO_ERR"); + break; + case MEMORY_ECC_ERR: + sprintf(name, "MEMORY_ECC_ERR"); + break; + case PROCHOT_EXT: + sprintf(name, "PROCHOT_EXT"); + break; + case PWR_ERR: + sprintf(name, "PWR_ERR"); + break; + case CATERR: + sprintf(name, "CATERR"); + break; + default: + sprintf(name, "unknown"); + break; + } + + return 0; +} + +int +pal_parse_sel(uint8_t fru, uint8_t snr_num, uint8_t *event_data, + char *error_log) { + + char *ed = event_data; + char temp_log[128] = {0}; + uint8_t temp; + + switch(snr_num) { + case SYSTEM_EVENT: + sprintf(error_log, "SYSTEM_EVENT"); + if (ed[0] == 0xE5) { + strcat(error_log, ": Cause of Time change"); + + if (ed[2] == 0x00) + strcat(error_log, ": NTP"); + else if (ed[2] == 0x01) + strcat(error_log, ": Host RTL"); + else if (ed[2] == 0x02) + strcat(error_log, ": Set SEL time cmd "); + else if (ed[2] == 0x03) + strcat(error_log, ": Set SEL time UTC offset cmd"); + else + strcat(error_log, ": Unknown"); + + if (ed[1] == 0x00) + strcat(error_log, ": First Time"); + else if(ed[1] == 0x80) + strcat(error_log, ": Second Time"); + + } + break; + + case THERM_THRESH_EVT: + sprintf(error_log, "THERM_THRESH_EVT"); + if (ed[0] == 0x1) + strcat(error_log, ": Limit Exceeded"); + else + strcat(error_log, ": Unknown"); + break; + + case BUTTON: + sprintf(error_log, "BUTTON"); + if (ed[0] == 0x0) + strcat(error_log, ": Power button pressed"); + else if (ed[0] == 0x2) + strcat(error_log, ": Reset button pressed"); + else + strcat(error_log, ": Unknown"); + break; + + case POWER_STATE: + sprintf(error_log, "POWER_STATE"); + if (ed[0] == 0x0) + strcat(error_log, ": Transition to Running"); + else if (ed[0] == 0x2) + strcat(error_log, ": Transition to Power Off"); + else + strcat(error_log, ": Unknown"); + break; + + case CRITICAL_IRQ: + sprintf(error_log, "CRITICAL_IRQ"); + if (ed[0] == 0x0) + strcat(error_log, ": Diagnostic Interrupt"); + else + strcat(error_log, ": Unknown"); + break; + + case POST_ERROR: + sprintf(error_log, "POST_ERROR"); + if ((ed[0] & 0x0F) == 0x0) + strcat(error_log, ": System Firmware Error"); + else + strcat(error_log, ": Unknown"); + if (((ed[0] >> 6) & 0x03) == 0x3) { + // TODO: Need to implement IPMI spec based Post Code + strcat(error_log, ": IPMI Post Code"); + } else if (((ed[0] >> 6) & 0x03) == 0x2) { + sprintf(temp_log, "OEM Post Code: 0x%X 0x%X", ed[2], ed[1]); + strcat(error_log, temp_log); + } + break; + + case MACHINE_CHK_ERR: + sprintf(error_log, "MACHINE_CHK_ERR"); + if ((ed[0] & 0x0F) == 0x0B) { + strcat(error_log, ": Uncorrectable"); + } else if ((ed[0] & 0x0F) == 0x0C) { + strcat(error_log, ": Correctable"); + } else { + strcat(error_log, ": Unknown"); + } + + sprintf(temp_log, "Machine Check bank Number - %d ", ed[1]); + strcat(error_log, temp_log); + sprintf(temp_log, "CPU - %d, Core - %d ", ed[2] >> 5, ed[2] & 0x1F); + strcat(error_log, temp_log); + + break; + + case PCIE_ERR: + sprintf(error_log, "PCIE_ERR"); + if ((ed[0] & 0xF) == 0x4) + strcat(error_log, ": PCI PERR"); + else if ((ed[0] & 0xF) == 0x5) + strcat(error_log, ": PCI SERR"); + else if ((ed[0] & 0xF) == 0x7) + strcat(error_log, ": Correctable"); + else if ((ed[0] & 0xF) == 0x8) + strcat(error_log, ": Uncorrectable"); + else if ((ed[0] & 0xF) == 0xA) + strcat(error_log, ": Bus Fatal"); + else + strcat(error_log, ": Unknown"); + break; + + case IIO_ERR: + sprintf(error_log, "IIO_ERR"); + if ((ed[0] & 0xF) == 0) { + + sprintf(temp_log, ": CPU - %d, Error ID - 0x%X", (ed[2] & 0xE0) >> 5, + ed[1]); + strcat(error_log, temp_log); + + temp = ed[2] & 0x7; + if (temp == 0x0) + strcat(error_log, ": IRP0"); + else if (temp == 0x1) + strcat(error_log, ": IRP1"); + else if (temp == 0x2) + strcat(error_log, ": IIO-Core"); + else if (temp == 0x3) + strcat(error_log, ": VT-d"); + else if (temp == 0x4) + strcat(error_log, ": Intel Quick Data"); + else if (temp == 0x5) + strcat(error_log, ": Misc"); + else + strcat(error_log, ": Reserved"); + } + break; + + case MEMORY_ECC_ERR: + sprintf(error_log, "MEMORY_ECC_ERR"); + if ((ed[0] & 0x0F) == 0x0) + strcat(error_log, ": Correctable"); + else if ((ed[0] & 0x0F) == 0x1) + strcat(error_log, ": Uncorrectable"); + else if ((ed[0] & 0x0F) == 0x5) + strcat(error_log, ": Correctable ECC error Logging Limit Reached"); + else + strcat(error_log, ": Unknown"); + + if (((ed[1] & 0xC) >> 2) == 0x0) { + /* All Info Valid */ + sprintf(temp_log, ": CPU# - %d, CHN# - %d, DIMM# - %d ", + (ed[2] & 0xE0) >> 5, (ed[2] & 0x18) >> 3, ed[2] & 0x7); + } else if (((ed[1] & 0xC) >> 2) == 0x1) { + /* DIMM info not valid */ + sprintf(temp_log, ": CPU# - %d, CHN# - %d", + (ed[2] & 0xE0) >> 5, (ed[2] & 0x18) >> 3); + } else if (((ed[1] & 0xC) >> 2) == 0x2) { + /* CHN info not valid */ + sprintf(temp_log, ": CPU# - %d, DIMM# - %d ", + (ed[2] & 0xE0) >> 5, ed[2] & 0x7); + } else if (((ed[1] & 0xC) >> 2) == 0x3) { + /* CPU info not valid */ + sprintf(temp_log, ": CHN# - %d, DIMM# - %d ", + (ed[2] & 0x18) >> 3, ed[2] & 0x7); + } + strcat(error_log, temp_log); + + break; + + case PROCHOT_EXT: + sprintf(error_log, "PROCHOT_EXT"); + if ((ed[0] & 0xF) == 0xA) + strcat(error_log, ": Processor Thermal Throttling Offset"); + else + strcat(error_log, ": Unknown"); + break; + + if ((ed[1] & 0x3) == 0x1) + strcat(error_log, ": External (VR)"); + else if ((ed[1] & 0x3) == 0x0) + strcat(error_log, ": Native"); + break; + + sprintf(temp_log, ": SOC ID - %d", (ed[2] & 0xE0) >> 5); + strcat(error_log, temp_log); + + case PWR_ERR: + sprintf(error_log, "PWR_ERR"); + if (ed[0] == 0x2) + strcat(error_log, ": PCH_PWROK failure"); + else + strcat(error_log, ": Unknown"); + break; + + case CATERR: + sprintf(error_log, "CATERR"); + if (ed[0] == 0x0) + strcat(error_log, ": IERR"); + else if (ed[0] == 0xB) + strcat(error_log, ": MCERR"); + else + strcat(error_log, ": Unknown"); + break; + + default: + sprintf(error_log, "unknown"); + break; + } + + return 0; +} diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/pal/pal.h b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/pal/pal.h index 1d9f3b9..b3f542a 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/pal/pal.h +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/pal/pal.h @@ -30,13 +30,17 @@ extern "C" { #include <facebook/yosemite_fruid.h> #include <facebook/yosemite_sensor.h> -#define MAX_NUM_FRUS 6 #define MAX_KEY_LEN 64 #define MAX_VALUE_LEN 64 #define KV_STORE "/mnt/data/kv_store/%s" #define KV_STORE_PATH "/mnt/data/kv_store" +#define SETBIT(x, y) (x | (1 << y)) +#define GETBIT(x, y) ((x & (1 << y)) > y) +#define CLEARBIT(x, y) (x & (~(1 << y))) +#define GETMASK(y) (1 << y) + extern char * key_list[]; extern const char pal_fru_list[]; extern const char pal_server_list[]; @@ -47,10 +51,18 @@ enum { }; enum { + USB_MUX_OFF, + USB_MUX_ON, +}; + +enum { SERVER_POWER_OFF, SERVER_POWER_ON, SERVER_POWER_CYCLE, SERVER_GRACEFUL_SHUTDOWN, + SERVER_12V_OFF, + SERVER_12V_ON, + SERVER_12V_CYCLE, }; enum { @@ -61,6 +73,22 @@ enum { HAND_SW_BMC }; +enum { + SYSTEM_EVENT = 0xE9, + THERM_THRESH_EVT = 0x7D, + BUTTON = 0xAA, + POWER_STATE = 0xAB, + CRITICAL_IRQ = 0xEA, + POST_ERROR = 0x2B, + MACHINE_CHK_ERR = 0x40, + PCIE_ERR = 0x41, + IIO_ERR = 0x43, + MEMORY_ECC_ERR = 0X63, + PROCHOT_EXT = 0X51, + PWR_ERR = 0X56, + CATERR= 0xEB, +}; + int pal_get_platform_name(char *name); int pal_get_num_slots(uint8_t *num); int pal_is_server_prsnt(uint8_t slot_id, uint8_t *status); @@ -79,17 +107,40 @@ int pal_get_pwr_btn(uint8_t *status); int pal_get_rst_btn(uint8_t *status); int pal_set_rst_btn(uint8_t slot, uint8_t status); int pal_set_led(uint8_t slot, uint8_t status); +int pal_set_hb_led(uint8_t status); +int pal_set_id_led(uint8_t slot, uint8_t status); int pal_get_fru_id(char *fru_str, uint8_t *fru); +int pal_get_fru_name(uint8_t fru, char *name); int pal_get_fruid_path(uint8_t fru, char *path); +int pal_get_fruid_eeprom_path(uint8_t fru, char *path); int pal_get_fruid_name(uint8_t fru, char *name); +int pal_get_fru_sdr_path(uint8_t fru, char *path); int pal_get_sensor_units(uint8_t fru, uint8_t sensor_num, char *units); int pal_get_fru_sensor_list(uint8_t fru, uint8_t **sensor_list, int *cnt); +int pal_get_fru_discrete_list(uint8_t fru, uint8_t **sensor_list, int *cnt); +int pal_sensor_sdr_init(uint8_t fru, sensor_info_t *sinfo); int pal_sensor_read(uint8_t fru, uint8_t sensor_num, void *value); int pal_get_sensor_name(uint8_t fru, uint8_t sensor_num, char *name); +int pal_get_sensor_threshold(uint8_t fru, uint8_t sensor_num, uint8_t thresh, + void *value); int pal_get_key_value(char *key, char *value); int pal_set_key_value(char *key, char *value); +int pal_set_def_key_value(); void pal_dump_key_value(void); int pal_get_fru_devtty(uint8_t fru, char *devtty); +int pal_get_last_pwr_state(uint8_t fru, char *state); +int pal_set_last_pwr_state(uint8_t fru, char *state); +int pal_get_sys_guid(uint8_t slot, char *guid); +int pal_set_sysfw_ver(uint8_t slot, uint8_t *ver); +int pal_get_sysfw_ver(uint8_t slot, uint8_t *ver); +int pal_fruid_write(uint8_t slot, char *path); +int pal_is_bmc_por(void); +int pal_sensor_discrete_check(uint8_t fru, uint8_t snr_num, char *snr_name, + uint8_t o_val, uint8_t n_val); +int pal_get_event_sensor_name(uint8_t fru, uint8_t snr_num, char *name); +int pal_parse_sel(uint8_t fru, uint8_t snr_num, uint8_t *event_data, + char *error_log); +int pal_sel_handler(uint8_t fru, uint8_t snr_num); #ifdef __cplusplus } // extern "C" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_common/Makefile b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_common/Makefile index 76bf61f..40ea2a8 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_common/Makefile +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_common/Makefile @@ -2,8 +2,8 @@ lib: libyosemite_common.so libyosemite_common.so: yosemite_common.c - $(CC) $(CFLAGS) -fPIC -c -o yosemite_common.o yosemite_common.c - $(CC) -shared -o libyosemite_common.so yosemite_common.o -lc + $(CC) $(CFLAGS) -fPIC -pthread -c -o yosemite_common.o yosemite_common.c + $(CC) -lpthread -shared -o libyosemite_common.so yosemite_common.o -lc .PHONY: clean diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_common/yosemite_common.c b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_common/yosemite_common.c index e41690f..c638809 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_common/yosemite_common.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_common/yosemite_common.c @@ -27,8 +27,51 @@ #include <fcntl.h> #include <errno.h> #include <syslog.h> +#include <pthread.h> +#include <string.h> #include "yosemite_common.h" +#define CRASHDUMP_BIN "/usr/local/bin/dump.sh" +#define CRASHDUMP_FILE "/mnt/data/crashdump_" + +int +yosemite_common_fru_name(uint8_t fru, char *str) { + + switch(fru) { + case FRU_SLOT1: + sprintf(str, "slot1"); + break; + + case FRU_SLOT2: + sprintf(str, "slot2"); + break; + + case FRU_SLOT3: + sprintf(str, "slot3"); + break; + + case FRU_SLOT4: + sprintf(str, "slot4"); + break; + + case FRU_SPB: + sprintf(str, "spb"); + break; + + case FRU_NIC: + sprintf(str, "nic"); + break; + + default: +#ifdef DEBUG + syslog(LOG_WARNING, "yosemite_common_fru_id: Wrong fru id"); +#endif + return -1; + } + + return 0; +} + int yosemite_common_fru_id(char *str, uint8_t *fru) { @@ -47,9 +90,61 @@ yosemite_common_fru_id(char *str, uint8_t *fru) { } else if (!strcmp(str, "nic")) { *fru = FRU_NIC; } else { - syslog(LOG_ALERT, "yosemite_common_fru_id: Wrong fru id"); +#ifdef DEBUG + syslog(LOG_WARNING, "yosemite_common_fru_id: Wrong fru id"); +#endif return -1; } return 0; } + +void * +generate_dump(void *arg) { + + uint8_t fru = *(uint8_t *) arg; + char cmd[128]; + char fruname[16]; + + yosemite_common_fru_name(fru, fruname); + + // HEADER LINE for the dump + memset(cmd, 0, 128); + sprintf(cmd, "%s time > %s%s", CRASHDUMP_BIN, CRASHDUMP_FILE, fruname); + system(cmd); + + // COREID dump + memset(cmd, 0, 128); + sprintf(cmd, "%s %s 48 coreid >> %s%s", CRASHDUMP_BIN, fruname, + CRASHDUMP_FILE, fruname); + system(cmd); + + // MSR dump + memset(cmd, 0, 128); + sprintf(cmd, "%s %s 48 msr >> %s%s", CRASHDUMP_BIN, fruname, + CRASHDUMP_FILE, fruname); + system(cmd); + + syslog(LOG_CRIT, "Crashdump for FRU: %d is generated.", fru); +} + +int +yosemite_common_crashdump(uint8_t fru) { + + if (access(CRASHDUMP_BIN, F_OK) == -1) { + syslog(LOG_CRIT, "Crashdump for FRU: %d failed : " + "crashdump binary is not preset", fru); + return 0; + } + + pthread_t t_dump; + + if (pthread_create(&t_dump, NULL, generate_dump, (void*) &fru) < 0) { + syslog(LOG_WARNING, "pal_store_crashdump: pthread_create for" + " FRU %d failed\n", fru); + } + + syslog(LOG_INFO, "Crashdump for FRU: %d is being generated.", fru); + + return 0; +} diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_common/yosemite_common.h b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_common/yosemite_common.h index 85d8638..f2128ef 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_common/yosemite_common.h +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_common/yosemite_common.h @@ -25,6 +25,7 @@ extern "C" { #endif +#define MAX_NUM_FRUS 6 enum { FRU_ALL = 0, FRU_SLOT1 = 1, @@ -35,7 +36,9 @@ enum { FRU_NIC = 6, }; +int yosemite_common_fru_name(uint8_t fru, char *str); int yosemite_common_fru_id(char *str, uint8_t *fru); +int yosemite_common_crashdump(uint8_t fru); #ifdef __cplusplus } // extern "C" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_fruid/yosemite_fruid.c b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_fruid/yosemite_fruid.c index 226f2f8..d431d34 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_fruid/yosemite_fruid.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_fruid/yosemite_fruid.c @@ -48,13 +48,42 @@ yosemite_get_fruid_path(uint8_t fru, char *path) { sprintf(fname, "nic"); break; default: - syslog(LOG_ALERT, "yosemite_get_fruid_path: wrong fruid"); +#ifdef DEBUG + syslog(LOG_WARNING, "yosemite_get_fruid_path: wrong fruid"); +#endif return -1; } sprintf(path, YOSEMITE_FRU_PATH, fname); return 0; } + +int +yosemite_get_fruid_eeprom_path(uint8_t fru, char *path) { + char fname[16] = {0}; + + switch(fru) { + case FRU_SLOT1: + case FRU_SLOT2: + case FRU_SLOT3: + case FRU_SLOT4: + return -1; + case FRU_SPB: + sprintf(path, "/sys/class/i2c-adapter/i2c-8/8-0051/eeprom"); + break; + case FRU_NIC: + sprintf(path, "/sys/class/i2c-adapter/i2c-12/12-0051/eeprom"); + break; + default: +#ifdef DEBUG + syslog(LOG_WARNING, "yosemite_get_fruid_eeprom_path: wrong fruid"); +#endif + return -1; + } + + return 0; +} + /* Populate char name[] with the path to the fru's name */ int yosemite_get_fruid_name(uint8_t fru, char *name) { @@ -79,7 +108,9 @@ yosemite_get_fruid_name(uint8_t fru, char *name) { sprintf(name, "CX4 NIC"); break; default: - syslog(LOG_ALERT, "yosemite_get_fruid_name: wrong fruid"); +#ifdef DEBUG + syslog(LOG_WARNING, "yosemite_get_fruid_name: wrong fruid"); +#endif return -1; } return 0; diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_fruid/yosemite_fruid.h b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_fruid/yosemite_fruid.h index 5c01267..78cdbe4 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_fruid/yosemite_fruid.h +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_fruid/yosemite_fruid.h @@ -28,6 +28,7 @@ extern "C" { #endif int yosemite_get_fruid_path(uint8_t fru, char *path); +int yosemite_get_fruid_eeprom_path(uint8_t fru, char *path); int yosemite_get_fruid_name(uint8_t fru, char *name); #ifdef __cplusplus diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_gpio/yosemite_gpio.c b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_gpio/yosemite_gpio.c index ac2c820..4f22500 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_gpio/yosemite_gpio.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_gpio/yosemite_gpio.c @@ -102,12 +102,16 @@ yosemite_get_gpio_name(uint8_t fru, uint8_t gpio, char *name) { //TODO: Add support for BMC GPIO pins if (fru < 1 || fru > 4) { - syslog(LOG_ALERT, "yosemite_get_gpio_name: Wrong fru %u", fru); +#ifdef DEBUG + syslog(LOG_WARNING, "yosemite_get_gpio_name: Wrong fru %u", fru); +#endif return -1; } if (gpio < 0 || gpio > MAX_GPIO_PINS) { - syslog(LOG_ALERT, "yosemite_get_gpio_name: Wrong gpio pin %u", gpio); +#ifdef DEBUG + syslog(LOG_WARNING, "yosemite_get_gpio_name: Wrong gpio pin %u", gpio); +#endif return -1; } diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_sensor/Makefile b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_sensor/Makefile index 63b334c..dd013a9 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_sensor/Makefile +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_sensor/Makefile @@ -3,7 +3,7 @@ lib: libyosemite_sensor.so libyosemite_sensor.so: yosemite_sensor.c $(CC) $(CFLAGS) -fPIC -c -o yosemite_sensor.o yosemite_sensor.c - $(CC) -lm -lbic -lsdr -lipmi -lipmb -lyosemite_common -shared -o libyosemite_sensor.so yosemite_sensor.o -lc + $(CC) -lm -lbic -lipmi -lipmb -lyosemite_common -shared -o libyosemite_sensor.so yosemite_sensor.o -lc .PHONY: clean diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_sensor/yosemite_sensor.c b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_sensor/yosemite_sensor.c index 0f25e54..9d075ce 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_sensor/yosemite_sensor.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_sensor/yosemite_sensor.c @@ -24,6 +24,7 @@ #include <stdint.h> #include <stdbool.h> #include <math.h> +#include <string.h> #include <fcntl.h> #include <errno.h> #include <syslog.h> @@ -51,6 +52,10 @@ #define UNIT_DIV 1000 +#define MEZZ_SENSOR_I2CBUS "11" +#define MEZZ_SENSOR_I2C_BUS_ADDR "0x1f" +#define MEZZ_SENSOR_TEMP_REGISTER "0x01" + #define BIC_SENSOR_READ_NA 0x20 #define MAX_SENSOR_NUM 0xFF @@ -77,6 +82,7 @@ const uint8_t bic_sensor_list[] = { BIC_SENSOR_VCCIN_VR_CURR, BIC_SENSOR_VCCIN_VR_VOL, BIC_SENSOR_INA230_POWER, + BIC_SENSOR_INA230_VOL, BIC_SENSOR_SOC_PACKAGE_PWR, BIC_SENSOR_SOC_TJMAX, BIC_SENSOR_VDDR_VR_POUT, @@ -88,6 +94,7 @@ const uint8_t bic_sensor_list[] = { BIC_SENSOR_VCC_SCSUS_VR_POUT, BIC_SENSOR_VCC_GBE_VR_POUT, BIC_SENSOR_VCC_GBE_VR_VOL, + BIC_SENSOR_1V05_PCH_VR_POUT, BIC_SENSOR_1V05_PCH_VR_VOL, BIC_SENSOR_SOC_DIMMA0_TEMP, BIC_SENSOR_SOC_DIMMA1_TEMP, @@ -101,22 +108,13 @@ const uint8_t bic_sensor_list[] = { BIC_SENSOR_PV_BAT, BIC_SENSOR_PVDDR, BIC_SENSOR_PVCC_GBE, +}; + +const uint8_t bic_discrete_list[] = { /* Discrete sensors */ - //BIC_SENSOR_SYSTEM_STATUS, - //BIC_SENSOR_SYS_BOOT_STAT, - //BIC_SENSOR_CPU_DIMM_HOT, - //BIC_SENSOR_PROC_FAIL, - //BIC_SENSOR_VR_HOT, - /* Event-only sensors */ - //BIC_SENSOR_POST_ERR, - //BIC_SENSOR_SPS_FW_HLTH, - //BIC_SENSOR_POWER_THRESH_EVENT, - //BIC_SENSOR_MACHINE_CHK_ERR, - //BIC_SENSOR_PCIE_ERR, - //BIC_SENSOR_OTHER_IIO_ERR, - //BIC_SENSOR_PROC_HOT_EXT, - //BIC_SENSOR_POWER_ERR, - //BIC_SENSOR_CAT_ERR, + BIC_SENSOR_SYSTEM_STATUS, + BIC_SENSOR_VR_HOT, + BIC_SENSOR_CPU_DIMM_HOT, }; // List of SPB sensors to be monitored @@ -130,10 +128,10 @@ const uint8_t spb_sensor_list[] = { SP_SENSOR_P5V, SP_SENSOR_P12V, SP_SENSOR_P3V3_STBY, - SP_SENSOR_P12V_SLOT0, SP_SENSOR_P12V_SLOT1, SP_SENSOR_P12V_SLOT2, SP_SENSOR_P12V_SLOT3, + SP_SENSOR_P12V_SLOT4, SP_SENSOR_P3V3, SP_SENSOR_HSC_IN_VOLT, SP_SENSOR_HSC_OUT_CURR, @@ -141,10 +139,63 @@ const uint8_t spb_sensor_list[] = { SP_SENSOR_HSC_IN_POWER, }; +// List of NIC sensors to be monitored +const uint8_t nic_sensor_list[] = { + MEZZ_SENSOR_TEMP, +}; + +float spb_sensor_threshold[MAX_SENSOR_NUM][MAX_SENSOR_THRESHOLD + 1] = {0}; +float nic_sensor_threshold[MAX_SENSOR_NUM][MAX_SENSOR_THRESHOLD + 1] = {0}; + +static void +sensor_thresh_array_init() { + static bool init_done = false; + + if (init_done) + return; + + spb_sensor_threshold[SP_SENSOR_INLET_TEMP][UCR_THRESH] = 40; + spb_sensor_threshold[SP_SENSOR_OUTLET_TEMP][UCR_THRESH] = 70; + spb_sensor_threshold[SP_SENSOR_FAN0_TACH][UCR_THRESH] = 10000; + spb_sensor_threshold[SP_SENSOR_FAN0_TACH][LCR_THRESH] = 500; + spb_sensor_threshold[SP_SENSOR_FAN1_TACH][UCR_THRESH] = 10000; + spb_sensor_threshold[SP_SENSOR_FAN1_TACH][LCR_THRESH] = 500; + //spb_sensor_threshold[SP_SENSOR_AIR_FLOW][UCR_THRESH] = {75.0, 0, 0, 0, 0, 0, 0, 0}; + spb_sensor_threshold[SP_SENSOR_P5V][UCR_THRESH] = 5.493; + spb_sensor_threshold[SP_SENSOR_P5V][LCR_THRESH] = 4.501; + spb_sensor_threshold[SP_SENSOR_P12V][UCR_THRESH] = 13.216; + spb_sensor_threshold[SP_SENSOR_P12V][LCR_THRESH] = 11.269; + spb_sensor_threshold[SP_SENSOR_P3V3_STBY][UCR_THRESH] = 3.625; + spb_sensor_threshold[SP_SENSOR_P3V3_STBY][LCR_THRESH] = 2.973; + spb_sensor_threshold[SP_SENSOR_P12V_SLOT1][UCR_THRESH] = 13.216; + spb_sensor_threshold[SP_SENSOR_P12V_SLOT1][LCR_THRESH] = 11.269; + spb_sensor_threshold[SP_SENSOR_P12V_SLOT2][UCR_THRESH] = 13.216; + spb_sensor_threshold[SP_SENSOR_P12V_SLOT2][LCR_THRESH] = 11.269; + spb_sensor_threshold[SP_SENSOR_P12V_SLOT3][UCR_THRESH] = 13.216; + spb_sensor_threshold[SP_SENSOR_P12V_SLOT3][LCR_THRESH] = 11.269; + spb_sensor_threshold[SP_SENSOR_P12V_SLOT4][UCR_THRESH] = 13.216; + spb_sensor_threshold[SP_SENSOR_P12V_SLOT4][LCR_THRESH] = 11.269; + spb_sensor_threshold[SP_SENSOR_P3V3][UCR_THRESH] = 3.625; + spb_sensor_threshold[SP_SENSOR_P3V3][LCR_THRESH] = 2.973; + spb_sensor_threshold[SP_SENSOR_HSC_IN_VOLT][UCR_THRESH] = 13.2; + spb_sensor_threshold[SP_SENSOR_HSC_IN_VOLT][LCR_THRESH] = 10.8; + spb_sensor_threshold[SP_SENSOR_HSC_OUT_CURR][UCR_THRESH] = 47.705; + spb_sensor_threshold[SP_SENSOR_HSC_TEMP][UCR_THRESH] = 120; + spb_sensor_threshold[SP_SENSOR_HSC_IN_POWER][UCR_THRESH] = 525; + + nic_sensor_threshold[MEZZ_SENSOR_TEMP][UCR_THRESH] = 80; + + init_done = true; +} + size_t bic_sensor_cnt = sizeof(bic_sensor_list)/sizeof(uint8_t); +size_t bic_discrete_cnt = sizeof(bic_discrete_list)/sizeof(uint8_t); + size_t spb_sensor_cnt = sizeof(spb_sensor_list)/sizeof(uint8_t); +size_t nic_sensor_cnt = sizeof(nic_sensor_list)/sizeof(uint8_t); + enum { FAN0 = 0, FAN1, @@ -161,12 +212,7 @@ enum { ADC_PIN7, }; -static sensor_info_t g_sinfo1[MAX_SENSOR_NUM] = {0}; -static sensor_info_t g_sinfo2[MAX_SENSOR_NUM] = {0}; -static sensor_info_t g_sinfo3[MAX_SENSOR_NUM] = {0}; -static sensor_info_t g_sinfo4[MAX_SENSOR_NUM] = {0}; -static sensor_info_t g_sinfo_spb[MAX_SENSOR_NUM] = {0}; -static sensor_info_t g_sinfo_nic[MAX_SENSOR_NUM] = {0}; +static sensor_info_t g_sinfo[MAX_NUM_FRUS][MAX_SENSOR_NUM] = {0}; static int read_device(const char *device, int *value) { @@ -177,7 +223,9 @@ read_device(const char *device, int *value) { if (!fp) { int err = errno; +#ifdef DEBUG syslog(LOG_INFO, "failed to open device %s", device); +#endif return err; } @@ -185,7 +233,9 @@ read_device(const char *device, int *value) { fclose(fp); if (rc != 1) { +#ifdef DEBUG syslog(LOG_INFO, "failed to read device %s", device); +#endif return ENOENT; } else { return 0; @@ -201,8 +251,9 @@ read_device_float(const char *device, float *value) { fp = fopen(device, "r"); if (!fp) { int err = errno; - +#ifdef DEBUG syslog(LOG_INFO, "failed to open device %s", device); +#endif return err; } @@ -210,7 +261,9 @@ read_device_float(const char *device, float *value) { fclose(fp); if (rc != 1) { +#ifdef DEBUG syslog(LOG_INFO, "failed to read device %s", device); +#endif return ENOENT; } @@ -271,46 +324,52 @@ read_hsc_value(const char *device, float *value) { } static int -bic_read_sensor_wrapper(uint8_t slot_id, uint8_t sensor_num, void *value) { +read_nic_temp(uint8_t snr_num, float *value) { + char command[64]; + char tmp[8]; + + if (snr_num == MEZZ_SENSOR_TEMP) { + sprintf(command, "i2cget -y %s %s %s b", MEZZ_SENSOR_I2CBUS, + MEZZ_SENSOR_I2C_BUS_ADDR, MEZZ_SENSOR_TEMP_REGISTER); + + FILE *fp = popen(command, "r"); + fscanf(fp, "%s", tmp); + pclose(fp); + + *value = (float) strtol(tmp, NULL, 16); + } + + return 0; +} + +static int +bic_read_sensor_wrapper(uint8_t fru, uint8_t sensor_num, bool discrete, + void *value) { + int ret; + sdr_full_t *sdr; ipmi_sensor_reading_t sensor; - ret = bic_read_sensor(slot_id, sensor_num, &sensor); + ret = bic_read_sensor(fru, sensor_num, &sensor); if (ret) { return ret; } if (sensor.flags & BIC_SENSOR_READ_NA) { +#ifdef DEBUG syslog(LOG_ERR, "bic_read_sensor_wrapper: Reading Not Available"); syslog(LOG_ERR, "bic_read_sensor_wrapper: sensor_num: 0x%X, flag: 0x%X", sensor_num, sensor.flags); +#endif return -1; } - if (sensor.status) { - //printf("bic_read_sensor_wrapper: Status Asserted: 0x%X\n", sensor.status); + if (discrete) { + *(float *) value = (float) sensor.status; + return 0; } - // Check SDR to convert raw value to actual - sdr_full_t *sdr; - - switch (slot_id) { - case 1: - sdr = &g_sinfo1[sensor_num].sdr; - break; - case 2: - sdr = &g_sinfo2[sensor_num].sdr; - break; - case 3: - sdr = &g_sinfo3[sensor_num].sdr; - break; - case 4: - sdr = &g_sinfo4[sensor_num].sdr; - break; - default: - syslog(LOG_ALERT, "bic_read_sensor_wrapper: Wrong Slot ID\n"); - return -1; - } + sdr = &g_sinfo[fru-1][sensor_num].sdr; // If the SDR is not type1, no need for conversion if (sdr->type !=1) { @@ -350,106 +409,148 @@ bic_read_sensor_wrapper(uint8_t slot_id, uint8_t sensor_num, void *value) { * (float *) value = ((m * x) + (b * pow(10, b_exp))) * (pow(10, r_exp)); + if ((sensor_num == BIC_SENSOR_SOC_THERM_MARGIN) && (* (float *) value > 0)) { + * (float *) value -= (float) THERMAL_CONSTANT; + } + return 0; } -/* Returns the all the SDRs for the particular fru# */ -static sensor_info_t * -get_struct_sensor_info(uint8_t fru) { - sensor_info_t *sinfo; - switch(fru) { +int +yosemite_sensor_sdr_path(uint8_t fru, char *path) { + +char fru_name[16] = {0}; + +switch(fru) { case FRU_SLOT1: - sinfo = g_sinfo1; + sprintf(fru_name, "%s", "slot1"); break; case FRU_SLOT2: - sinfo = g_sinfo2; + sprintf(fru_name, "%s", "slot2"); break; case FRU_SLOT3: - sinfo = g_sinfo3; + sprintf(fru_name, "%s", "slot3"); break; case FRU_SLOT4: - sinfo = g_sinfo4; + sprintf(fru_name, "%s", "slot4"); break; case FRU_SPB: - sinfo = g_sinfo_spb; + sprintf(fru_name, "%s", "spb"); break; case FRU_NIC: - sinfo = g_sinfo_nic; + sprintf(fru_name, "%s", "nic"); break; default: - syslog(LOG_ALERT, "yosemite_sdr_init: Wrong Slot ID\n"); - return NULL; - } - return sinfo; +#ifdef DEBUG + syslog(LOG_WARNING, "yosemite_sensor_sdr_path: Wrong Slot ID\n"); +#endif + return -1; } +sprintf(path, YOSEMITE_SDR_PATH, fru_name); + +if (access(path, F_OK) == -1) { + return -1; +} + +return 0; +} + +/* Populates all sensor_info_t struct using the path to SDR dump */ int -get_fru_sdr_path(uint8_t fru, char *path) { +sdr_init(char *path, sensor_info_t *sinfo) { +int fd; +uint8_t buf[MAX_SDR_LEN] = {0}; +uint8_t bytes_rd = 0; +uint8_t snr_num = 0; +sdr_full_t *sdr; + +while (access(path, F_OK) == -1) { + sleep(5); +} + +fd = open(path, O_RDONLY); +if (fd < 0) { + syslog(LOG_ERR, "sdr_init: open failed for %s\n", path); + return -1; +} + +while ((bytes_rd = read(fd, buf, sizeof(sdr_full_t))) > 0) { + if (bytes_rd != sizeof(sdr_full_t)) { + syslog(LOG_ERR, "sdr_init: read returns %d bytes\n", bytes_rd); + return -1; + } + + sdr = (sdr_full_t *) buf; + snr_num = sdr->sensor_num; + sinfo[snr_num].valid = true; + memcpy(&sinfo[snr_num].sdr, sdr, sizeof(sdr_full_t)); +} + +return 0; +} - char fru_name[16] = {0}; +int +yosemite_sensor_sdr_init(uint8_t fru, sensor_info_t *sinfo) { + int fd; + uint8_t buf[MAX_SDR_LEN] = {0}; + uint8_t bytes_rd = 0; + uint8_t sn = 0; + char path[64] = {0}; switch(fru) { case FRU_SLOT1: - sprintf(fru_name, "%s", "slot1"); - break; case FRU_SLOT2: - sprintf(fru_name, "%s", "slot2"); - break; case FRU_SLOT3: - sprintf(fru_name, "%s", "slot3"); - break; case FRU_SLOT4: - sprintf(fru_name, "%s", "slot4"); + if (yosemite_sensor_sdr_path(fru, path) < 0) { +#ifdef DEBUG + syslog(LOG_WARNING, "yosemite_sensor_sdr_init: get_fru_sdr_path failed\n"); +#endif + return ERR_NOT_READY; + } + + if (sdr_init(path, sinfo) < 0) { +#ifdef DEBUG + syslog(LOG_ERR, "yosemite_sensor_sdr_init: sdr_init failed for FRU %d", fru); +#endif + } break; + case FRU_SPB: - sprintf(fru_name, "%s", "spb"); - break; case FRU_NIC: - sprintf(fru_name, "%s", "nic"); - break; - default: - syslog(LOG_ALERT, "yosemite_sdr_init: Wrong Slot ID\n"); return -1; + break; } - sprintf(path, YOSEMITE_SDR_PATH, fru_name); - return 0; } static int yosemite_sdr_init(uint8_t fru) { - int fd; - uint8_t buf[MAX_SDR_LEN] = {0}; - uint8_t bytes_rd = 0; - uint8_t sn = 0; - char path[64] = {0}; - sensor_info_t *sinfo; - if (get_fru_sdr_path(fru, path) < 0) { - syslog(LOG_ALERT, "yosemite_sdr_init: get_fru_sdr_path failed\n"); - return -1; - } - sinfo = get_struct_sensor_info(fru); - if (sinfo == NULL) { - syslog(LOG_ALERT, "yosemite_sdr_init: get_struct_sensor_info failed\n"); - return -1; - } + static bool init_done[MAX_NUM_FRUS] = {false}; + + if (!init_done[fru - 1]) { + + sensor_info_t *sinfo = g_sinfo[fru-1]; + + if (yosemite_sensor_sdr_init(fru, sinfo) < 0) + return ERR_NOT_READY; - if (sdr_init(path, sinfo) < 0) { - syslog(LOG_ERR, "yosemite_sdr_init: sdr_init failed for FRU %d", fru); + init_done[fru - 1] = true; } return 0; } static bool -is_server_prsnt(uint8_t slot_id) { +is_server_prsnt(uint8_t fru) { uint8_t gpio; int val; char path[64] = {0}; - switch(slot_id) { + switch(fru) { case 1: gpio = 61; break; @@ -482,44 +583,21 @@ is_server_prsnt(uint8_t slot_id) { /* Get the units for the sensor */ int yosemite_sensor_units(uint8_t fru, uint8_t sensor_num, char *units) { - static bool init_done = false; uint8_t op, modifier; sensor_info_t *sinfo; - if (!init_done) { - - if (is_server_prsnt(1) && (yosemite_sdr_init(FRU_SLOT1) != 0)) { + if (is_server_prsnt(fru) && (yosemite_sdr_init(fru) != 0)) { return -1; } - if (is_server_prsnt(2) && (yosemite_sdr_init(FRU_SLOT2) != 0)) { - return -1; - } - if (is_server_prsnt(3) && (yosemite_sdr_init(FRU_SLOT3) != 0)) { - return -1; - } - if (is_server_prsnt(4) && (yosemite_sdr_init(FRU_SLOT4) != 0)) { - return -1; - } - init_done = true; - } switch(fru) { case FRU_SLOT1: case FRU_SLOT2: case FRU_SLOT3: case FRU_SLOT4: - sinfo = get_struct_sensor_info(fru); - if (sinfo == NULL) { - syslog(LOG_ALERT, "yosemite_sensor_units: get_struct_sensor_info failed\n"); - return -1; - } + sprintf(units, ""); + break; - if (sdr_get_sensor_units(&sinfo[sensor_num].sdr, &op, &modifier, units)) { - syslog(LOG_ALERT, "yosemite_sensor_units: FRU %d: num 0x%2X: reading units" - " from SDR failed.", fru, sensor_num); - return -1; - } - break; case FRU_SPB: switch(sensor_num) { case SP_SENSOR_INLET_TEMP: @@ -549,16 +627,10 @@ yosemite_sensor_units(uint8_t fru, uint8_t sensor_num, char *units) { case SP_SENSOR_P3V3_STBY: sprintf(units, "Volts"); break; - case SP_SENSOR_P12V_SLOT0: - sprintf(units, "Volts"); - break; case SP_SENSOR_P12V_SLOT1: - sprintf(units, "Volts"); - break; case SP_SENSOR_P12V_SLOT2: - sprintf(units, "Volts"); - break; case SP_SENSOR_P12V_SLOT3: + case SP_SENSOR_P12V_SLOT4: sprintf(units, "Volts"); break; case SP_SENSOR_P3V3: @@ -579,114 +651,132 @@ yosemite_sensor_units(uint8_t fru, uint8_t sensor_num, char *units) { } break; case FRU_NIC: - sprintf(units, ""); - break; + switch(sensor_num) { + case MEZZ_SENSOR_TEMP: + sprintf(units, "C"); + break; + } + break; } return 0; } -/* Get the name for the sensor */ int -yosemite_sensor_name(uint8_t fru, uint8_t sensor_num, char *name) { - static bool init_done = false; - uint8_t op, modifier; - sensor_info_t *sinfo; +yosemite_sensor_threshold(uint8_t fru, uint8_t sensor_num, uint8_t thresh, float *value) { - if (!init_done) { + sensor_thresh_array_init(); - if (is_server_prsnt(1) && (yosemite_sdr_init(FRU_SLOT1) != 0)) { - return -1; - } - if (is_server_prsnt(2) && (yosemite_sdr_init(FRU_SLOT2) != 0)) { - return -1; - } - if (is_server_prsnt(3) && (yosemite_sdr_init(FRU_SLOT3) != 0)) { - return -1; - } - if (is_server_prsnt(4) && (yosemite_sdr_init(FRU_SLOT4) != 0)) { - return -1; - } - init_done = true; + switch(fru) { + case FRU_SLOT1: + case FRU_SLOT2: + case FRU_SLOT3: + case FRU_SLOT4: + break; + case FRU_SPB: + *value = spb_sensor_threshold[sensor_num][thresh]; + break; + case FRU_NIC: + *value = nic_sensor_threshold[sensor_num][thresh]; + break; } + return 0; +} + +/* Get the name for the sensor */ +int +yosemite_sensor_name(uint8_t fru, uint8_t sensor_num, char *name) { switch(fru) { case FRU_SLOT1: case FRU_SLOT2: case FRU_SLOT3: case FRU_SLOT4: - sinfo = get_struct_sensor_info(fru); - if (sinfo == NULL) { - syslog(LOG_ALERT, "yosemite_sensor_name: get_struct_sensor_info failed\n"); - return -1; - } - - if (sdr_get_sensor_name(&sinfo[sensor_num].sdr, name)) { - syslog(LOG_ALERT, "yosemite_sensor_name: FRU %d: num 0x%2X: reading units" - " from SDR failed.", fru, sensor_num); - return -1; + switch(sensor_num) { + case BIC_SENSOR_SYSTEM_STATUS: + sprintf(name, "SYSTEM_STATUS"); + break; + case BIC_SENSOR_SYS_BOOT_STAT: + sprintf(name, "SYS_BOOT_STAT"); + break; + case BIC_SENSOR_CPU_DIMM_HOT: + sprintf(name, "CPU_DIMM_HOT"); + break; + case BIC_SENSOR_PROC_FAIL: + sprintf(name, "PROC_FAIL"); + break; + case BIC_SENSOR_VR_HOT: + sprintf(name, "VR_HOT"); + break; + default: + sprintf(name, ""); + break; } - break; + case FRU_SPB: switch(sensor_num) { case SP_SENSOR_INLET_TEMP: - sprintf(name, "SP_SENSOR_INLET_TEMP"); + sprintf(name, "SP_INLET_TEMP"); break; case SP_SENSOR_OUTLET_TEMP: - sprintf(name, "SP_SENSOR_OUTLET_TEMP"); + sprintf(name, "SP_OUTLET_TEMP"); break; case SP_SENSOR_MEZZ_TEMP: - sprintf(name, "SP_SENSOR_MEZZ_TEMP"); + sprintf(name, "SP_MEZZ_TEMP"); break; case SP_SENSOR_FAN0_TACH: - sprintf(name, "SP_SENSOR_FAN0_TACH"); + sprintf(name, "SP_FAN0_TACH"); break; case SP_SENSOR_FAN1_TACH: - sprintf(name, "SP_SENSOR_FAN1_TACH"); + sprintf(name, "SP_FAN1_TACH"); break; case SP_SENSOR_AIR_FLOW: - sprintf(name, "SP_SENSOR_AIR_FLOW"); + sprintf(name, "SP_AIR_FLOW"); break; case SP_SENSOR_P5V: - sprintf(name, "SP_SENSOR_P5V"); + sprintf(name, "SP_P5V"); break; case SP_SENSOR_P12V: - sprintf(name, "SP_SENSOR_P12V"); + sprintf(name, "SP_P12V"); break; case SP_SENSOR_P3V3_STBY: - sprintf(name, "SP_SENSOR_P3V3_STBY"); - break; - case SP_SENSOR_P12V_SLOT0: - sprintf(name, "SP_SENSOR_P12V_SLOT0"); + sprintf(name, "SP_P3V3_STBY"); break; case SP_SENSOR_P12V_SLOT1: - sprintf(name, "SP_SENSOR_P12V_SLOT1"); + sprintf(name, "SP_P12V_SLOT1"); break; case SP_SENSOR_P12V_SLOT2: - sprintf(name, "SP_SENSOR_P12V_SLOT2"); + sprintf(name, "SP_P12V_SLOT2"); break; case SP_SENSOR_P12V_SLOT3: - sprintf(name, "SP_SENSOR_P12V_SLOT3"); + sprintf(name, "SP_P12V_SLOT3"); + break; + case SP_SENSOR_P12V_SLOT4: + sprintf(name, "SP_P12V_SLOT4"); break; case SP_SENSOR_P3V3: - sprintf(name, "SP_SENSOR_P3V3"); + sprintf(name, "SP_P3V3"); break; case SP_SENSOR_HSC_IN_VOLT: - sprintf(name, "SP_SENSOR_HSC_IN_VOLT"); + sprintf(name, "SP_HSC_IN_VOLT"); break; case SP_SENSOR_HSC_OUT_CURR: - sprintf(name, "SP_SENSOR_HSC_OUT_CURR"); + sprintf(name, "SP_HSC_OUT_CURR"); break; case SP_SENSOR_HSC_TEMP: - sprintf(name, "SP_SENSOR_HSC_TEMP"); + sprintf(name, "SP_HSC_TEMP"); break; case SP_SENSOR_HSC_IN_POWER: - sprintf(name, "SP_SENSOR_HSC_IN_POWER"); + sprintf(name, "SP_HSC_IN_POWER"); break; } break; case FRU_NIC: - sprintf(name, ""); + switch(sensor_num) { + case MEZZ_SENSOR_TEMP: + sprintf(name, "MEZZ_SENSOR_TEMP"); + break; + } break; } return 0; @@ -694,85 +784,100 @@ yosemite_sensor_name(uint8_t fru, uint8_t sensor_num, char *name) { int -yosemite_sensor_read(uint8_t slot_id, uint8_t sensor_num, void *value) { - static bool init_done = false; +yosemite_sensor_read(uint8_t fru, uint8_t sensor_num, void *value) { + float volt; float curr; + int ret; + bool discrete; + int i; - if (!init_done) { + switch (fru) { + case FRU_SLOT1: + case FRU_SLOT2: + case FRU_SLOT3: + case FRU_SLOT4: - if (is_server_prsnt(1) && (yosemite_sdr_init(FRU_SLOT1) != 0)) { - return -1; - } + if (!(is_server_prsnt(fru))) { + return -1; + } - if (is_server_prsnt(2) && (yosemite_sdr_init(FRU_SLOT2) != 0)) { - return -1; - } + ret = yosemite_sdr_init(fru); + if (ret < 0) { + return ret; + } - if (is_server_prsnt(3) && (yosemite_sdr_init(FRU_SLOT3) != 0)) { - return -1; - } + discrete = false; - if (is_server_prsnt(4) && (yosemite_sdr_init(FRU_SLOT4) != 0)) { - return -1; - } + i = 0; + while (i < bic_discrete_cnt) { + if (sensor_num == bic_discrete_list[i++]) { + discrete = true; + break; + } + } - init_done = true; - } + return bic_read_sensor_wrapper(fru, sensor_num, discrete, value); - switch(sensor_num) { - // Inlet, Outlet Temp - - case SP_SENSOR_INLET_TEMP: - return read_temp(SP_INLET_TEMP_DEVICE, (float*) value); - case SP_SENSOR_OUTLET_TEMP: - return read_temp(SP_OUTLET_TEMP_DEVICE, (float*) value); - - // Fan Tach Values - case SP_SENSOR_FAN0_TACH: - return read_fan_value(FAN0, FAN_TACH_RPM, (float*) value); - case SP_SENSOR_FAN1_TACH: - return read_fan_value(FAN1, FAN_TACH_RPM, (float*) value); - - // Various Voltages - case SP_SENSOR_P5V: - return read_adc_value(ADC_PIN0, ADC_VALUE, (float*) value); - case SP_SENSOR_P12V: - return read_adc_value(ADC_PIN1, ADC_VALUE, (float*) value); - case SP_SENSOR_P3V3_STBY: - return read_adc_value(ADC_PIN2, ADC_VALUE, (float*) value); - case SP_SENSOR_P12V_SLOT0: - return read_adc_value(ADC_PIN3, ADC_VALUE, (float*) value); - case SP_SENSOR_P12V_SLOT1: - return read_adc_value(ADC_PIN4, ADC_VALUE, (float*) value); - case SP_SENSOR_P12V_SLOT2: - return read_adc_value(ADC_PIN5, ADC_VALUE, (float*) value); - case SP_SENSOR_P12V_SLOT3: - return read_adc_value(ADC_PIN6, ADC_VALUE, (float*) value); - case SP_SENSOR_P3V3: - return read_adc_value(ADC_PIN7, ADC_VALUE, (float*) value); - - // Hot Swap Controller - case SP_SENSOR_HSC_IN_VOLT: - return read_hsc_value(HSC_IN_VOLT, (float*) value); - case SP_SENSOR_HSC_OUT_CURR: - return read_hsc_value(HSC_OUT_CURR, (float*) value); - case SP_SENSOR_HSC_TEMP: - return read_hsc_value(HSC_TEMP, (float*) value); - case SP_SENSOR_HSC_IN_POWER: - if (read_hsc_value(HSC_IN_VOLT, &volt)) { - return -1; - } + case FRU_SPB: + switch(sensor_num) { - if (read_hsc_value(HSC_OUT_CURR, &curr)) { - return -1; - } + // Inlet, Outlet Temp + case SP_SENSOR_INLET_TEMP: + return read_temp(SP_INLET_TEMP_DEVICE, (float*) value); + case SP_SENSOR_OUTLET_TEMP: + return read_temp(SP_OUTLET_TEMP_DEVICE, (float*) value); - * (float*) value = volt * curr; - return 0; - default: - // For all others we assume the sensors are on Monolake - return bic_read_sensor_wrapper(slot_id, sensor_num, value); + // Fan Tach Values + case SP_SENSOR_FAN0_TACH: + return read_fan_value(FAN0, FAN_TACH_RPM, (float*) value); + case SP_SENSOR_FAN1_TACH: + return read_fan_value(FAN1, FAN_TACH_RPM, (float*) value); + + // Various Voltages + case SP_SENSOR_P5V: + return read_adc_value(ADC_PIN0, ADC_VALUE, (float*) value); + case SP_SENSOR_P12V: + return read_adc_value(ADC_PIN1, ADC_VALUE, (float*) value); + case SP_SENSOR_P3V3_STBY: + return read_adc_value(ADC_PIN2, ADC_VALUE, (float*) value); + case SP_SENSOR_P12V_SLOT1: + return read_adc_value(ADC_PIN4, ADC_VALUE, (float*) value); + case SP_SENSOR_P12V_SLOT2: + return read_adc_value(ADC_PIN3, ADC_VALUE, (float*) value); + case SP_SENSOR_P12V_SLOT3: + return read_adc_value(ADC_PIN6, ADC_VALUE, (float*) value); + case SP_SENSOR_P12V_SLOT4: + return read_adc_value(ADC_PIN5, ADC_VALUE, (float*) value); + case SP_SENSOR_P3V3: + return read_adc_value(ADC_PIN7, ADC_VALUE, (float*) value); + + // Hot Swap Controller + case SP_SENSOR_HSC_IN_VOLT: + return read_hsc_value(HSC_IN_VOLT, (float*) value); + case SP_SENSOR_HSC_OUT_CURR: + return read_hsc_value(HSC_OUT_CURR, (float*) value); + case SP_SENSOR_HSC_TEMP: + return read_hsc_value(HSC_TEMP, (float*) value); + case SP_SENSOR_HSC_IN_POWER: + if (read_hsc_value(HSC_IN_VOLT, &volt)) { + return -1; + } + if (read_hsc_value(HSC_OUT_CURR, &curr)) { + return -1; + } + * (float*) value = volt * curr; + return 0; + } + break; + + case FRU_NIC: + switch(sensor_num) { + // Mezz Temp + case MEZZ_SENSOR_TEMP: + return read_nic_temp(MEZZ_SENSOR_TEMP, (float*) value); + } + break; } } diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_sensor/yosemite_sensor.h b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_sensor/yosemite_sensor.h index 0a33173..8775f15 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_sensor/yosemite_sensor.h +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_sensor/yosemite_sensor.h @@ -24,7 +24,6 @@ #include <stdbool.h> #include <openbmc/ipmi.h> #include <openbmc/ipmb.h> -#include <openbmc/sdr.h> #include <facebook/bic.h> #include <facebook/yosemite_common.h> @@ -32,6 +31,30 @@ extern "C" { #endif +#define MAX_SDR_LEN 64 +#define MAX_SENSOR_NUM 0xFF +#define MAX_SENSOR_THRESHOLD 8 +#define MAX_RETRIES_SDR_INIT 30 +#define THERMAL_CONSTANT 255 +#define ERR_NOT_READY -2 + +typedef struct _sensor_info_t { + bool valid; + sdr_full_t sdr; +} sensor_info_t; + +/* Enum for type of Upper and Lower threshold values */ +enum { + UCR_THRESH = 0x01, + UNC_THRESH, + UNR_THRESH, + LCR_THRESH, + LNC_THRESH, + LNR_THRESH, + POS_HYST, + NEG_HYST, +}; + // Sensors under Bridge IC enum { BIC_SENSOR_MB_OUTLET_TEMP = 0x01, @@ -51,6 +74,7 @@ enum { BIC_SENSOR_VCCIN_VR_CURR = 0x23, BIC_SENSOR_VCCIN_VR_VOL = 0x24, BIC_SENSOR_INA230_POWER = 0x29, + BIC_SENSOR_INA230_VOL = 0x2A, BIC_SENSOR_POST_ERR = 0x2B, //Event-only BIC_SENSOR_SOC_PACKAGE_PWR = 0x2C, BIC_SENSOR_SOC_TJMAX = 0x30, @@ -63,9 +87,9 @@ enum { BIC_SENSOR_VCC_SCSUS_VR_POUT = 0x38, BIC_SENSOR_VCC_GBE_VR_POUT = 0x39, BIC_SENSOR_POWER_THRESH_EVENT = 0x3B, //Event-only - //BIC_SENSOR_1V05_PCH_VR_POUT = 0x40, BIC_SENSOR_MACHINE_CHK_ERR = 0x40, //Event-only BIC_SENSOR_PCIE_ERR = 0x41, //Event-only + BIC_SENSOR_1V05_PCH_VR_POUT = 0x42, BIC_SENSOR_OTHER_IIO_ERR = 0x43, //Event-only BIC_SENSOR_PROC_HOT_EXT = 0x51, //Event-only BIC_SENSOR_VCC_GBE_VR_VOL = 0x54, @@ -102,10 +126,10 @@ enum { SP_SENSOR_P5V = 0xE0, SP_SENSOR_P12V = 0xE1, SP_SENSOR_P3V3_STBY = 0xE2, - SP_SENSOR_P12V_SLOT0 = 0xE3, - SP_SENSOR_P12V_SLOT1 = 0xE4, - SP_SENSOR_P12V_SLOT2 = 0xE5, - SP_SENSOR_P12V_SLOT3 = 0xE6, + SP_SENSOR_P12V_SLOT1 = 0xE3, + SP_SENSOR_P12V_SLOT2 = 0xE4, + SP_SENSOR_P12V_SLOT3 = 0xE5, + SP_SENSOR_P12V_SLOT4 = 0xE6, SP_SENSOR_P3V3 = 0xE7, SP_SENSOR_HSC_IN_VOLT = 0xC0, SP_SENSOR_HSC_OUT_CURR = 0xC1, @@ -113,18 +137,36 @@ enum { SP_SENSOR_HSC_IN_POWER = 0xC3, }; +enum{ + MEZZ_SENSOR_TEMP = 0x01, +}; extern const uint8_t bic_sensor_list[]; +extern const uint8_t bic_discrete_list[]; + extern const uint8_t spb_sensor_list[]; +extern const uint8_t nic_sensor_list[]; + +//extern float spb_sensor_threshold[MAX_SENSOR_NUM][MAX_SENSOR_THRESHOLD + 1]; + +//extern float nic_sensor_threshold[MAX_SENSOR_NUM][MAX_SENSOR_THRESHOLD + 1]; + extern size_t bic_sensor_cnt; +extern size_t bic_discrete_cnt; + extern size_t spb_sensor_cnt; -int yosemite_sensor_read(uint8_t slot_id, uint8_t sensor_num, void *value); +extern size_t nic_sensor_cnt; + +int yosemite_sensor_read(uint8_t fru, uint8_t sensor_num, void *value); int yosemite_sensor_name(uint8_t fru, uint8_t sensor_num, char *name); int yosemite_sensor_units(uint8_t fru, uint8_t sensor_num, char *units); -int get_fru_sdr_path(uint8_t fru, char *path); +int yosemite_sensor_sdr_path(uint8_t fru, char *path); +int yosemite_sensor_threshold(uint8_t fru, uint8_t sensor_num, uint8_t thresh, float *value); +int yosemite_sensor_sdr_init(uint8_t fru, sensor_info_t *sinfo); + #ifdef __cplusplus } // extern "C" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/libyosemite-sensor_0.1.bb b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/libyosemite-sensor_0.1.bb index fbb4a15..4bbeef1 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/libyosemite-sensor_0.1.bb +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/libyosemite-sensor_0.1.bb @@ -9,7 +9,7 @@ LIC_FILES_CHKSUM = "file://yosemite_sensor.c;beginline=8;endline=20;md5=da359787 SRC_URI = "file://yosemite_sensor \ " -DEPENDS =+ " libipmi libipmb libbic libsdr libyosemite-common " +DEPENDS =+ " libipmi libipmb libbic libyosemite-common " S = "${WORKDIR}/yosemite_sensor" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fbutils_0.1.bb b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fbutils_0.1.bb index 9a9f5fe..e00f558 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fbutils_0.1.bb +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fbutils_0.1.bb @@ -83,7 +83,7 @@ do_install() { install -m 0755 ${WORKDIR}/rc.early ${D}${sysconfdir}/init.d/rc.early update-rc.d -r ${D} rc.early start 04 S . install -m 755 setup-gpio.sh ${D}${sysconfdir}/init.d/setup-gpio.sh - update-rc.d -r ${D} setup-gpio.sh start 59 S . + update-rc.d -r ${D} setup-gpio.sh start 59 5 . # create VLAN intf automatically #install -d ${D}/${sysconfdir}/network/if-up.d #install -m 755 create_vlan_intf ${D}${sysconfdir}/network/if-up.d/create_vlan_intf @@ -92,7 +92,7 @@ do_install() { #install -m 755 eth0_mac_fixup.sh ${D}${sysconfdir}/init.d/eth0_mac_fixup.sh #update-rc.d -r ${D} eth0_mac_fixup.sh start 70 S . install -m 755 power-on.sh ${D}${sysconfdir}/init.d/power-on.sh - update-rc.d -r ${D} power-on.sh start 85 S . + update-rc.d -r ${D} power-on.sh start 85 5 . #install -m 755 fcswitcher.sh ${D}${sysconfdir}/init.d/fcswitcher.sh #update-rc.d -r ${D} fcswitcher.sh start 90 S . install -m 0755 ${WORKDIR}/rc.local ${D}${sysconfdir}/init.d/rc.local diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/bic-util/bic-util.c b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/bic-util/bic-util.c index 4a8966d..3ebc3f1 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/bic-util/bic-util.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/bic-util/bic-util.c @@ -55,6 +55,19 @@ util_get_device_id(uint8_t slot_id) { printf("Aux. FW Rev: 0x%X:0x%X:0x%X:0x%X\n", id.aux_fw_rev[0], id.aux_fw_rev[1],id.aux_fw_rev[2],id.aux_fw_rev[3]); } +static void +util_get_fw_ver(uint8_t slot_id) { + int i, j, ret; + uint8_t buf[16] = {0}; + for (i = 1; i <= 8; i++) { + ret = bic_get_fw_ver(slot_id, i, buf); + printf("version of comp: %d is", i); + for (j = 0; j < 10; j++) + printf("%02X:", buf[j]); + printf("\n"); + } +} + // Tests for reading GPIO values and configuration static void util_get_gpio(uint8_t slot_id) { @@ -363,6 +376,9 @@ main(int argc, char **argv) { slot_id = atoi(argv[1]); + util_get_fw_ver(slot_id); + +#if 0 util_get_device_id(slot_id); util_get_gpio(slot_id); @@ -381,4 +397,5 @@ main(int argc, char **argv) { util_get_sdr_info(slot_id); util_get_sdr(slot_id); util_read_sensor(slot_id); +#endif } diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fpc-util/Makefile b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fpc-util/Makefile new file mode 100644 index 0000000..cb90045 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fpc-util/Makefile @@ -0,0 +1,10 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +all: fpc-util + +fpc-util: fpc-util.c + $(CC) -pthread -lipmi -lipmb -lbic -lpal -std=c99 -o $@ $^ $(LDFLAGS) + +.PHONY: clean + +clean: + rm -rf *.o fpc-util diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fpc-util/fpc-util.c b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fpc-util/fpc-util.c new file mode 100644 index 0000000..93c1166 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fpc-util/fpc-util.c @@ -0,0 +1,85 @@ +/* + * fpc-util + * + * Copyright 2015-present Facebook. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <errno.h> +#include <syslog.h> +#include <stdint.h> +#include <pthread.h> +#include <facebook/bic.h> +#include <openbmc/pal.h> +#include <openbmc/ipmi.h> + +static void +print_usage_help(void) { + printf("Usage: fpc-util <slot1|slot2|slot3|slot4> --usb\n"); + printf(" fpc-util <slot1|slot2|slot3|slot4|all> --identify <on/off>\n"); +} + +int +main(int argc, char **argv) { + + uint8_t slot_id; + char tstr[64] = {0}; + + if (argc < 3) { + goto err_exit; + } + + if (!strcmp(argv[1], "slot1")) { + slot_id = 1; + } else if (!strcmp(argv[1] , "slot2")) { + slot_id = 2; + } else if (!strcmp(argv[1] , "slot3")) { + slot_id = 3; + } else if (!strcmp(argv[1] , "slot4")) { + slot_id = 4; + } else if (!strcmp(argv[1] , "all")) { + slot_id = 0; + } else { + goto err_exit; + } + + if (!strcmp(argv[2], "--usb")) { + printf("fpc-util: switching USB channel to slot%d\n", slot_id); + return pal_switch_usb_mux(slot_id); + } else if (!strcmp(argv[2], "--identify")) { + if (argc != 4) { + goto err_exit; + } + printf("fpc-util: identication for %s is %s\n", argv[1], argv[3]); + if (slot_id == 0) { + sprintf(tstr, "identify_sled"); + } else { + sprintf(tstr, "identify_slot%d", slot_id); + } + + return pal_set_key_value(tstr, argv[3]); + } else { + goto err_exit; + } + + return 0; +err_exit: + print_usage_help(); + return -1; +} diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fw-util/Makefile b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fw-util/Makefile new file mode 100644 index 0000000..b56fca9 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fw-util/Makefile @@ -0,0 +1,10 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +all: fw-util + +fw-util: fw-util.c + $(CC) -pthread -lipmi -lipmb -lbic -lpal -std=c99 -o $@ $^ $(LDFLAGS) + +.PHONY: clean + +clean: + rm -rf *.o fw-util diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fw-util/fw-util.c b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fw-util/fw-util.c new file mode 100644 index 0000000..2b472b3 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fw-util/fw-util.c @@ -0,0 +1,161 @@ +/* + * fw-util + * + * Copyright 2015-present Facebook. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <errno.h> +#include <syslog.h> +#include <stdint.h> +#include <pthread.h> +#include <facebook/bic.h> +#include <openbmc/pal.h> +#include <openbmc/ipmi.h> + +static void +print_usage_help(void) { + printf("Usage: fw_util <slot1|slot2|slot3|slot4> <--version>\n"); + printf(" fw_util <slot1|slot2|slot3|slot4> <--update> <--cpld> <path>\n"); +} + +// TODO: Need to confirm the interpretation of firmware version for print +// Right now using decimal to print the versions +static void +print_fw_ver(uint8_t slot_id) { + int i; + uint8_t ver[32] = {0}; + + // Print CPLD Version + if (bic_get_fw_ver(slot_id, FW_CPLD, ver)) { + return; + } + + printf("CPLD Version: 0x%02x%02x%02x%02x\n", ver[0], ver[1], ver[2], ver[3]); + + // Print Bridge-IC Version + if (bic_get_fw_ver(slot_id, FW_BIC, ver)) { + return; + } + + printf("Bridge-IC Version: v%x.%x\n", ver[0], ver[1]); + + // Print ME Version + if (bic_get_fw_ver(slot_id, FW_ME, ver)){ + return; + } + + printf("ME Version: %x.%x.%x.%x%x\n", ver[0], ver[1], ver[2], ver[3], ver[4]); + + // Print PVCCIN VR Version + if (bic_get_fw_ver(slot_id, FW_PVCCIN_VR, ver)){ + return; + } + + printf("PVCCIN VR Version: 0x%02x%02x, 0x%02x%02x\n", ver[0], ver[1], ver[2], ver[3]); + + // Print DDRAB VR Version + if (bic_get_fw_ver(slot_id, FW_DDRAB_VR, ver)){ + return; + } + + printf("DDRAB VR Version: 0x%02x%02x, 0x%02x%02x\n", ver[0], ver[1], ver[2], ver[3]); + + // Print P1V05 VR Version + if (bic_get_fw_ver(slot_id, FW_P1V05_VR, ver)){ + return; + } + + printf("P1V05 VR Version: 0x%02x%02x, 0x%02x%02x\n", ver[0], ver[1], ver[2], ver[3]); + + // Print PVCCGBE VR Version + if (bic_get_fw_ver(slot_id, FW_PVCCGBE_VR, ver)){ + return; + } + + printf("PVCCGBE VR Version: 0x%02x%02x, 0x%02x%02x\n", ver[0], ver[1], ver[2], ver[3]); + + // Print PVCCSCSUS VR Version + if (bic_get_fw_ver(slot_id, FW_PVCCSCSUS_VR, ver)){ + return; + } + + printf("PVCCSCSUS VR Version: 0x%02x%02x, 0x%02x%02x\n", ver[0], ver[1], ver[2], ver[3]); + + // Print BIOS version + if (pal_get_sysfw_ver(slot_id, ver)) { + return; + } + + // BIOS version response contains the length at offset 2 followed by ascii string + printf("BIOS Version: "); + for (i = 3; i < 3+ver[2]; i++) { + printf("%c", ver[i]); + } + printf("\n"); +} + +int +main(int argc, char **argv) { + + uint8_t slot_id; + + // Check for border conditions + if ((argc != 3) && (argc != 5)) { + goto err_exit; + } + + // Derive slot_id from first parameter + if (!strcmp(argv[1], "slot1")) { + slot_id = 1; + } else if (!strcmp(argv[1] , "slot2")) { + slot_id =2; + } else if (!strcmp(argv[1] , "slot3")) { + slot_id =3; + } else if (!strcmp(argv[1] , "slot4")) { + slot_id =4; + } else { + goto err_exit; + } + + // check operation to perform + if (!strcmp(argv[2], "--version")) { + // handle printing versions of f/w components + print_fw_ver(slot_id); + } else if (!strcmp(argv[2], "--update")) { + // handle firmware update + if (argc != 5) { + goto err_exit; + } + + if (!strcmp(argv[3], "--cpld")) { + return bic_update_fw(slot_id, UPDATE_CPLD, argv[4]); + } else { + goto err_exit; + } + } else { + goto err_exit; + } + + return 0; + +err_exit: + print_usage_help(); + return -1; +} diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/setup-gpio.sh b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/setup-gpio.sh index 91797c5..10aad30 100755 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/setup-gpio.sh +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/setup-gpio.sh @@ -106,6 +106,20 @@ devmem_clear_bit $(scu_addr 80) 8 gpio_export B0 +# Enable P3V3: GPIOS1(145) +# To use GPIOS1 (145), SCU8C[1], SCU94[0], and SCU94[1] must be 0 +devmem_clear_bit $(scu_addr 8C) 1 +devmem_clear_bit $(scu_addr 94) 0 +devmem_clear_bit $(scu_addr 94) 1 + +gpio_set S1 1 + +# PWRGD_P3V3: GPIOS2(146) +# To use GPIOS2 (146), SCU8C[2], SCU94[0], and SCU94[1] must be 0 +devmem_clear_bit $(scu_addr 8C) 2 +devmem_clear_bit $(scu_addr 94) 0 +devmem_clear_bit $(scu_addr 94) 1 + # Setup GPIOs to Mux Enable: GPIOS3(147), Channel Select: GPIOE4(36), GPIOE5(37) # To use GPIOS3 (147), SCU8C[3], SCU94[0], and SCU94[1] must be 0 @@ -123,11 +137,11 @@ devmem_clear_bit $(scu_addr 80) 21 devmem_clear_bit $(scu_addr 8C) 14 devmem_clear_bit $(scu_addr 70) 22 -gpio_export S3 -gpio_export E4 -gpio_export E5 +gpio_set S3 0 +gpio_set E4 1 +gpio_set E5 0 -# BMC_HEARTBEAT_N, heartbeat LED, GPIO Q7 +# BMC_HEARTBEAT_N, heartbeat LED, GPIO Q7(135) devmem_clear_bit $(scu_addr 90) 28 gpio_export Q7 @@ -204,6 +218,34 @@ devmem_clear_bit $(scu_addr 84) 27 gpio_set M3 1 + +# Identify LED for Slot#2: +# To use GPIOF0 (40), SCU80[24] must be 0 +devmem_clear_bit $(scu_addr 80) 24 + +gpio_set F0 1 + +# Identify LED for Slot#1: +# To use GPIOF1 (41), SCU80[25], SCUA4[12], must be 0 +devmem_clear_bit $(scu_addr 80) 25 +devmem_clear_bit $(scu_addr A4) 12 + +gpio_set F1 1 + +# Identify LED for Slot#4: +# To use GPIOF2 (42), SCU80[26], SCUA4[13], must be 0 +devmem_clear_bit $(scu_addr 80) 26 +devmem_clear_bit $(scu_addr A4) 13 + +gpio_set F2 1 + +# Identify LED for Slot#3: +# To use GPIOF3 (43), SCU80[27], SCUA4[14], must be 0 +devmem_clear_bit $(scu_addr 80) 27 +devmem_clear_bit $(scu_addr A4) 14 + +gpio_set F3 1 + # Front Panel Hand Switch GPIO setup # HAND_SW_ID1: GPIOR2(138) # To use GPIOR2, SCU88[26] must be 0 @@ -305,3 +347,55 @@ gpio_set H3 1 # RST_SLOT4_SYS_RESET_N: GPIOH2 (58) # To use GPIOH2, SCU90[6], SCU90[7] must be 0 gpio_set H2 1 + +# 12V_STBY Enable for Slots + +# P12V_STBY_SLOT1_EN: GPIOO5 (117) +# To use GPIOO5, SCU88[13] must be 0 +devmem_clear_bit $(scu_addr 88) 13 + +gpio_set O5 1 + +# P12V_STBY_SLOT2_EN: GPIOO4 (116) +# To use GPIOO4, SCU88[12] must be 0 +devmem_clear_bit $(scu_addr 88) 12 + +gpio_set O4 1 + +# P12V_STBY_SLOT3_EN: GPIOO7 (119) +# To use GPIOO7, SCU88[15] must be 0 +devmem_clear_bit $(scu_addr 88) 15 + +gpio_set O7 1 + +# P12V_STBY_SLOT4_EN: GPIOO6 (118) +# To use GPIOO6, SCU88[13] must be 0 +devmem_clear_bit $(scu_addr 88) 14 + +gpio_set O6 1 + +# PWRGD_P12V_STBY_SLOT1: GPIOP1 (121) +# To use GPIOP1, SCU88[17] must be 0 +devmem_clear_bit $(scu_addr 88) 17 +gpio_export P1 + +# PWRGD_P12V_STBY_SLOT2: GPIOP0 (120) +# To use GPIOP0, SCU88[16] must be 0 +devmem_clear_bit $(scu_addr 88) 16 +gpio_export P0 + +# PWRGD_P12V_STBY_SLOT3: GPIOP3 (123) +# To use GPIOP3, SCU88[19] must be 0 +devmem_clear_bit $(scu_addr 88) 19 +gpio_export P3 + +# PWRGD_P12V_STBY_SLOT4: GPIOP2 (122) +# To use GPIOP2, SCU88[18] must be 0 +devmem_clear_bit $(scu_addr 88) 18 +gpio_export P2 + +# TODO: Enable this pin after the HW issue is fixed +# Enable the the EXTRST functionality of GPIOB7 +#devmem_set_bit $(scu_addr 80) 15 +#devmem_clear_bit $(scu_addr 90) 31 +#devmem_set_bit $(scu_addr 3c) 3 diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/yosemite-sensors/yosemite-sensors.c b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/yosemite-sensors/yosemite-sensors.c index aa921db..8eb772b 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/yosemite-sensors/yosemite-sensors.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/yosemite-sensors/yosemite-sensors.c @@ -79,12 +79,6 @@ main(int argc, char **argv) { printf("SP_SENSOR_P3V3_STBY: %.2f Volts\n", fvalue); } - if (yosemite_sensor_read(slot_id, SP_SENSOR_P12V_SLOT0, &fvalue)) { - printf("yosemite_sensor_read failed: SP_SENSOR_P12V_SLOT0\n"); - } else { - printf("SP_SENSOR_P12V_SLOT0: %.2f Volts\n", fvalue); - } - if (yosemite_sensor_read(slot_id, SP_SENSOR_P12V_SLOT1, &fvalue)) { printf("yosemite_sensor_read failed: SP_SENSOR_P12V_SLOT1\n"); } else { @@ -103,6 +97,12 @@ main(int argc, char **argv) { printf("SP_SENSOR_P12V_SLOT3: %.2f Volts\n", fvalue); } + if (yosemite_sensor_read(slot_id, SP_SENSOR_P12V_SLOT4, &fvalue)) { + printf("yosemite_sensor_read failed: SP_SENSOR_P12V_SLOT4\n"); + } else { + printf("SP_SENSOR_P12V_SLOT4: %.2f Volts\n", fvalue); + } + if (yosemite_sensor_read(slot_id, SP_SENSOR_P3V3, &fvalue)) { printf("yosemite_sensor_read failed: SP_SENSOR_P3V3\n"); } else { diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fpc-util_0.1.bb b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fpc-util_0.1.bb new file mode 100644 index 0000000..04665f1 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fpc-util_0.1.bb @@ -0,0 +1,21 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +SUMMARY = "Front Panel Control Utility" +DESCRIPTION = "Util to override the front panel control remotely" +SECTION = "base" +PR = "r1" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://fpc-util.c;beginline=4;endline=16;md5=b395943ba8a0717a83e62ca123a8d238" + +SRC_URI = "file://fpc-util \ + " + +S = "${WORKDIR}/fpc-util" + +do_install() { + install -d ${D}${bindir} + install -m 0755 fpc-util ${D}${bindir}/fpc-util +} + +DEPENDS += "libpal" + +FILES_${PN} = "${bindir}" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fw-util_0.1.bb b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fw-util_0.1.bb new file mode 100644 index 0000000..80c3064 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fw-util_0.1.bb @@ -0,0 +1,21 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +SUMMARY = "Firmware Utility" +DESCRIPTION = "Util for printing or updating firmware images" +SECTION = "base" +PR = "r1" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://fw-util.c;beginline=4;endline=16;md5=b395943ba8a0717a83e62ca123a8d238" + +SRC_URI = "file://fw-util \ + " + +S = "${WORKDIR}/fw-util" + +do_install() { + install -d ${D}${bindir} + install -m 0755 fw-util ${D}${bindir}/fw-util +} + +DEPENDS += " libbic libpal" + +FILES_${PN} = "${bindir}" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/front-paneld/files/Makefile b/meta-facebook/meta-yosemite/recipes-yosemite/front-paneld/files/Makefile index c542230..604fabf 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/front-paneld/files/Makefile +++ b/meta-facebook/meta-yosemite/recipes-yosemite/front-paneld/files/Makefile @@ -2,7 +2,7 @@ all: front-paneld front-paneld: front-paneld.c - $(CC) -pthread -lpal -lbic -std=c99 -o $@ $^ $(LDFLAGS) + $(CC) -pthread -lpal -lbic -o $@ $^ $(LDFLAGS) .PHONY: clean diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/front-paneld/files/front-paneld.c b/meta-facebook/meta-yosemite/recipes-yosemite/front-paneld/files/front-paneld.c index 03849cd..5f1c1ff 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/front-paneld/files/front-paneld.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/front-paneld/files/front-paneld.c @@ -29,12 +29,15 @@ #include <sys/socket.h> #include <sys/un.h> #include <time.h> +#include <sys/time.h> #include <openbmc/ipmi.h> #include <openbmc/ipmb.h> #include <openbmc/pal.h> -#define BTN_MAX_SAMPLES 200 +#define BTN_MAX_SAMPLES 200 +#define BTN_POWER_OFF 40 #define MAX_NUM_SLOTS 4 +#define HB_TIMESTAMP_COUNT (60 * 60) // Helper function for msleep void @@ -55,7 +58,8 @@ debug_card_handler() { int curr = -1; int prev = -1; uint8_t prsnt; - uint8_t pos; + uint8_t pos ; + uint8_t prev_pos = -1; uint8_t lpc; int i, ret; @@ -67,24 +71,37 @@ debug_card_handler() { } curr = prsnt; - if (curr == prev) { - // No state change, continue - goto debug_card_out; + + // Check if Debug Card was either inserted or removed + if (curr != prev) { + + if (!curr) { + // Debug Card was removed + syslog(LOG_WARNING, "Debug Card Extraction\n"); + // Switch UART mux to BMC + ret = pal_switch_uart_mux(HAND_SW_BMC); + if (ret) { + goto debug_card_out; + } + } else { + // Debug Card was inserted + syslog(LOG_WARNING, "Debug Card Insertion\n"); + + } } + // If Debug Card is present if (curr) { - syslog(LOG_ALERT, "Debug Card Insertion\n"); - // Get current position of hand switch ret = pal_get_hand_sw(&pos); if (ret) { goto debug_card_out; } - // Switch USB mux based on hand switch - ret = pal_switch_usb_mux(pos); - if (ret) { - goto debug_card_out; + if (pos == prev_pos && pos != HAND_SW_BMC & !prev) { + goto display_post; } + + // Switch UART mux based on hand switch ret = pal_switch_uart_mux(pos); if (ret) { @@ -109,6 +126,7 @@ debug_card_handler() { goto debug_card_out; } +display_post: // Get last post code and display it ret = pal_post_get_last(pos, &lpc); if (ret) { @@ -119,24 +137,23 @@ debug_card_handler() { if (ret) { goto debug_card_out; } - } else { - syslog(LOG_ALERT, "Debug Card Extraction\n"); - // Switch UART mux to BMC - ret = pal_switch_uart_mux(HAND_SW_BMC); - if (ret) { - goto debug_card_out; - } + } + debug_card_done: prev = curr; + prev_pos = pos; debug_card_out: - sleep(1); + if (prsnt) + msleep(500); + else + sleep(1); } } // Thread to monitor the hand switch static void * -hand_sw_handler() { +usb_handler() { int curr = -1; int prev = -1; int ret; @@ -162,48 +179,6 @@ hand_sw_handler() { goto hand_sw_out; } - // If Debug Card is present, update UART MUX - ret = pal_is_debug_card_prsnt(&prsnt); - if (ret) { - goto hand_sw_out; - } - - if (prsnt) { - // Switch UART mux based on position - ret = pal_switch_uart_mux(pos); - if (ret) { - goto hand_sw_out; - } - - if (pos == HAND_SW_BMC) { - // For BMC, there is no need for POST enable/disable code - goto hand_sw_done; - } - - ret = pal_is_server_prsnt(pos, &prsnt); - if (ret || !prsnt) { - // Server at chosen position is not present - goto hand_sw_done; - } - - // Enable post for the chosen server - ret = pal_post_enable(pos); - if (ret) { - goto hand_sw_out; - } - - // Get last post code and display it - ret = pal_post_get_last(pos, &lpc); - if (ret) { - goto hand_sw_out; - } - - ret = pal_post_handle(pos, lpc); - if (ret) { - goto hand_sw_out; - } - } -hand_sw_done: prev = curr; hand_sw_out: sleep(1); @@ -235,7 +210,7 @@ rst_btn_handler() { } // Pass the reset button to the selected slot - syslog(LOG_ALERT, "reset button pressed\n"); + syslog(LOG_WARNING, "Reset button pressed\n"); ret = pal_set_rst_btn(pos, 0); if (ret) { goto rst_btn_out; @@ -248,14 +223,15 @@ rst_btn_handler() { msleep(100); continue; } - syslog(LOG_ALERT, "Reset button released\n"); + syslog(LOG_WARNING, "Reset button released\n"); + syslog(LOG_CRIT, "Reset Button pressed for FRU: %d\n", pos); ret = pal_set_rst_btn(pos, 1); goto rst_btn_out; } // handle error case if (i == BTN_MAX_SAMPLES) { - syslog(LOG_ALERT, "Reset button seems to stuck for long time\n"); + syslog(LOG_WARNING, "Reset button seems to stuck for long time\n"); goto rst_btn_out; } rst_btn_out: @@ -267,7 +243,7 @@ rst_btn_out: static void * pwr_btn_handler() { int ret; - uint8_t pos, btn; + uint8_t pos, btn, cmd; int i; uint8_t power; @@ -285,7 +261,7 @@ pwr_btn_handler() { goto pwr_btn_out; } - syslog(LOG_ALERT, "power button pressed\n"); + syslog(LOG_WARNING, "power button pressed\n"); // Wait for the button to be released for (i = 0; i < BTN_MAX_SAMPLES; i++) { @@ -294,13 +270,13 @@ pwr_btn_handler() { msleep(100); continue; } - syslog(LOG_ALERT, "power button released\n"); + syslog(LOG_WARNING, "power button released\n"); break; } // handle error case if (i == BTN_MAX_SAMPLES) { - syslog(LOG_ALERT, "Power button seems to stuck for long time\n"); + syslog(LOG_WARNING, "Power button seems to stuck for long time\n"); goto pwr_btn_out; } @@ -310,13 +286,96 @@ pwr_btn_handler() { goto pwr_btn_out; } + // Set power command should reverse of current power state + cmd = !power; + + // To determine long button press + if (i >= BTN_POWER_OFF) { + syslog(LOG_CRIT, "Power Button Long Press for FRU: %d\n", pos); + } else { + + // If current power state is ON and it is not a long press, + // the power off should be Graceful Shutdown + if (power == SERVER_POWER_ON) + cmd = SERVER_GRACEFUL_SHUTDOWN; + + syslog(LOG_CRIT, "Power Button Press for FRU: %d\n", pos); + } + // Reverse the power state of the given server - ret = pal_set_server_power(pos, !power); + ret = pal_set_server_power(pos, cmd); pwr_btn_out: msleep(100); } } +// Thread to handle Heart Beat LED and monitor SLED Cycles +static void * +hb_handler() { + int count = 0; + struct timespec ts; + struct timespec mts; + char tstr[64] = {0}; + char buf[128] = {0}; + uint8_t por = 0; + uint8_t time_init = 0; + long time_sled_on; + long time_sled_off; + + // Read the last timestamp from KV storage + pal_get_key_value("timestamp_sled", tstr); + time_sled_off = (long) strtoul(tstr, NULL, 10); + + // If this reset is due to Power-On-Reset, we detected SLED power OFF event + if (pal_is_bmc_por()) { + ctime_r(&time_sled_off, buf); + syslog(LOG_CRIT, "SLED Powered OFF at %s", buf); + } + + + while (1) { + // Toggle HB LED + pal_set_hb_led(1); + msleep(500); + pal_set_hb_led(0); + msleep(500); + + // Make sure the time is initialized properly + // Since there is no battery backup, the time could be reset to build time + if (time_init == 0) { + // Read current time + clock_gettime(CLOCK_REALTIME, &ts); + + if (ts.tv_sec < time_sled_off) { + continue; + } + + // If current time is more than the stored time, the date is correct + time_init = 1; + + // Need to log SLED ON event, if this is Power-On-Reset + if (pal_is_bmc_por()) { + // Get uptime + clock_gettime(CLOCK_MONOTONIC, &mts); + // To find out when SLED was on, subtract the uptime from current time + time_sled_on = ts.tv_sec - mts.tv_sec; + + ctime_r(&time_sled_on, buf); + // Log an event if this is Power-On-Reset + syslog(LOG_CRIT, "SLED Powered ON at %s", buf); + } + } + + // Store timestamp every one hour to keep track of SLED power + if (count++ == HB_TIMESTAMP_COUNT) { + clock_gettime(CLOCK_REALTIME, &ts); + sprintf(tstr, "%d", ts.tv_sec); + pal_set_key_value("timestamp_sled", tstr); + count = 0; + } + } +} + // Thread to handle LED state of the server at given slot static void * led_handler(void *num) { @@ -324,13 +383,21 @@ led_handler(void *num) { uint8_t prsnt; uint8_t power; uint8_t pos; - uint8_t ident; uint8_t led_blink; + uint8_t ident = 0; int led_on_time, led_off_time; + char identify[16] = {0}; + char tstr[64] = {0}; + int id_led_on_time = 200; + int id_led_off_time = 200; + int power_led_on_time = 500; + int power_led_off_time = 500; uint8_t slot = (*(int*) num) + 1; +#ifdef DEBUG syslog(LOG_INFO, "led_handler for slot %d\n", slot); +#endif ret = pal_is_server_prsnt(slot, &prsnt); if (ret || !prsnt) { @@ -340,6 +407,45 @@ led_handler(void *num) { } while (1) { + + // Check if this slot needs to be identified + ident = 0; + + // Check if sled needs to be identified + memset(identify, 0x0, 16); + ret = pal_get_key_value("identify_sled", identify); + if (ret == 0 && !strcmp(identify, "on")) { + ident = 0x1; + } + + // Check if slot needs to be identified + if (!ident) { + sprintf(tstr, "identify_slot%d", slot); + memset(identify, 0x0, 16); + ret = pal_get_key_value(tstr, identify); + if (ret == 0 && !strcmp(identify, "on")) { + ident = 0x1; + } + } + + if (ident) { + // Turn OFF Power LED + pal_set_led(slot, 0); + + // Start blinking the ID LED + pal_set_id_led(slot, 0); + + msleep(id_led_on_time); + + pal_set_id_led(slot, 1); + + msleep(id_led_off_time); + continue; + } else { + // Turn OFF ID LED + pal_set_id_led(slot, 1); + } + // Get power status for this slot ret = pal_get_server_power(slot, &power); if (ret) { @@ -354,27 +460,22 @@ led_handler(void *num) { continue; } - if (pos == slot) { - // This server is selcted one, set ident flag - ident = 1; - } else { - ident = 0; + if (pos == HAND_SW_BMC) { + // Start blinking the ID LED + pal_set_led(slot, 0); + + msleep(power_led_off_time); + + pal_set_led(slot, 1); + + msleep(power_led_on_time); + continue; } - // Update LED based on current state - if (ident) { - // If this is selected server the blink flag is one + if (pos == slot) { + // This server is selcted one, set led_blink flag led_blink = 1; - // update the blink rate based on power state - if (power) { - led_on_time = 900; - led_off_time = 100; - } else { - led_on_time = 100; - led_off_time = 900; - } } else { - // This server is not selected one led_blink = 0; } @@ -384,7 +485,16 @@ led_handler(void *num) { goto led_handler_out; } - // Since this is selected slot, start blinking the LED + // Set blink rate + if (power) { + led_on_time = 900; + led_off_time = 100; + } else { + led_on_time = 100; + led_off_time = 900; + } + + // Start blinking the LED ret = pal_set_led(slot, 1); if (ret) { goto led_handler_out; @@ -412,30 +522,47 @@ main (int argc, char * const argv[]) { pthread_t tid_debug_card; pthread_t tid_rst_btn; pthread_t tid_pwr_btn; + pthread_t tid_hb; pthread_t tid_leds[MAX_NUM_SLOTS]; int i; int *ip; + int rc; + int pid_file; + + pid_file = open("/var/run/front-paneld.pid", O_CREAT | O_RDWR, 0666); + rc = flock(pid_file, LOCK_EX | LOCK_NB); + if(rc) { + if(EWOULDBLOCK == errno) { + printf("Another front-paneld instance is running...\n"); + exit(-1); + } + } else { + daemon(0, 1); + openlog("front-paneld", LOG_CONS, LOG_DAEMON); + } - daemon(1, 0); - openlog("front-paneld", LOG_CONS, LOG_DAEMON); - if (pthread_create(&tid_debug_card, NULL, debug_card_handler, NULL) < 0) { - syslog(LOG_ALERT, "pthread_create for debug card error\n"); + if (pthread_create(&tid_debug_card, NULL, debug_card_handler, NULL) < 0) { + syslog(LOG_WARNING, "pthread_create for debug card error\n"); exit(1); } - - if (pthread_create(&tid_hand_sw, NULL, hand_sw_handler, NULL) < 0) { - syslog(LOG_ALERT, "pthread_create for hand switch error\n"); + if (pthread_create(&tid_hand_sw, NULL, usb_handler, NULL) < 0) { + syslog(LOG_WARNING, "pthread_create for hand switch error\n"); exit(1); } if (pthread_create(&tid_rst_btn, NULL, rst_btn_handler, NULL) < 0) { - syslog(LOG_ALERT, "pthread_create for reset button error\n"); + syslog(LOG_WARNING, "pthread_create for reset button error\n"); exit(1); } if (pthread_create(&tid_pwr_btn, NULL, pwr_btn_handler, NULL) < 0) { - syslog(LOG_ALERT, "pthread_create for power button error\n"); + syslog(LOG_WARNING, "pthread_create for power button error\n"); + exit(1); + } + + if (pthread_create(&tid_hb, NULL, hb_handler, NULL) < 0) { + syslog(LOG_WARNING, "pthread_create for heart beat error\n"); exit(1); } @@ -443,15 +570,15 @@ main (int argc, char * const argv[]) { ip = malloc(sizeof(int)); *ip = i; if (pthread_create(&tid_leds[i], NULL, led_handler, (void*)ip) < 0) { - syslog(LOG_ALERT, "pthread_create for hand switch error\n"); + syslog(LOG_WARNING, "pthread_create for hand switch error\n"); exit(1); } } - pthread_join(tid_debug_card, NULL); pthread_join(tid_hand_sw, NULL); pthread_join(tid_rst_btn, NULL); pthread_join(tid_pwr_btn, NULL); + pthread_join(tid_hb, NULL); for (i = 0; i < MAX_NUM_SLOTS; i++) { pthread_join(tid_leds[i], NULL); } diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/front-paneld/front-paneld_0.1.bb b/meta-facebook/meta-yosemite/recipes-yosemite/front-paneld/front-paneld_0.1.bb index 26db659..8eb4457 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/front-paneld/front-paneld_0.1.bb +++ b/meta-facebook/meta-yosemite/recipes-yosemite/front-paneld/front-paneld_0.1.bb @@ -31,7 +31,7 @@ do_install() { install -d ${D}${sysconfdir}/init.d install -d ${D}${sysconfdir}/rcS.d install -m 755 setup-front-paneld.sh ${D}${sysconfdir}/init.d/setup-front-paneld.sh - update-rc.d -r ${D} setup-front-paneld.sh start 67 S . + update-rc.d -r ${D} setup-front-paneld.sh start 67 5 . } FBPACKAGEDIR = "${prefix}/local/fbpackages" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/gpiod/files/gpiod.c b/meta-facebook/meta-yosemite/recipes-yosemite/gpiod/files/gpiod.c index 9282e00..f4bf9f9 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/gpiod/files/gpiod.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/gpiod/files/gpiod.c @@ -41,7 +41,7 @@ #define GETMASK(y) (1 << y) #define MAX_NUM_SLOTS 4 -#define GPIOD_READ_DELAY 1 +#define DELAY_GPIOD_READ 500000 // Polls each slot gpio values every 4*x usec #define SOCK_PATH_GPIO "/tmp/gpio_socket" /* To hold the gpio info and status */ @@ -77,7 +77,7 @@ get_struct_gpio_pin(uint8_t fru) { gpios = gpio_slot4; break; default: - syslog(LOG_ALERT, "get_struct_gpio_pin: Wrong SLOT ID %d\n", fru); + syslog(LOG_WARNING, "get_struct_gpio_pin: Wrong SLOT ID %d\n", fru); return NULL; } @@ -116,7 +116,7 @@ enable_gpio_intr_config(uint8_t fru, uint8_t gpio) { } if (verify_cfg.ie != cfg.ie) { - syslog(LOG_ALERT, "Slot_id: %u,Interrupt enabling FAILED for GPIO pin# %d", + syslog(LOG_WARNING, "Slot_id: %u,Interrupt enabling FAILED for GPIO pin# %d", fru, gpio); return -1; } @@ -133,22 +133,24 @@ enable_gpio_intr(uint8_t fru) { gpios = get_struct_gpio_pin(fru); if (gpios == NULL) { - syslog(LOG_ALERT, "enable_gpio_intr: get_struct_gpio_pin failed."); + syslog(LOG_WARNING, "enable_gpio_intr: get_struct_gpio_pin failed."); return; } for (i = 0; i < gpio_pin_cnt; i++) { + + gpios[i].flag = 0; + ret = enable_gpio_intr_config(fru, gpio_pin_list[i]); if (ret < 0) { - gpios[i].flag = 0; - syslog(LOG_ALERT, "enable_gpio_intr: Slot: %d, Pin %d interrupt enabling" + syslog(LOG_WARNING, "enable_gpio_intr: Slot: %d, Pin %d interrupt enabling" " failed", fru, gpio_pin_list[i]); - syslog(LOG_ALERT, "enable_gpio_intr: Disable check for Slot %d, Pin %d", + syslog(LOG_WARNING, "enable_gpio_intr: Disable check for Slot %d, Pin %d", fru, gpio_pin_list[i]); } else { gpios[i].flag = 1; #ifdef DEBUG - syslog(LOG_ALERT, "enable_gpio_intr: Enabled check for Slot: %d, Pin %d", + syslog(LOG_WARNING, "enable_gpio_intr: Enabled check for Slot: %d, Pin %d", fru, gpio_pin_list[i]); #endif /* DEBUG */ } @@ -164,12 +166,14 @@ populate_gpio_pins(uint8_t fru) { gpios = get_struct_gpio_pin(fru); if (gpios == NULL) { - syslog(LOG_ALERT, "populate_gpio_pins: get_struct_gpio_pin failed."); + syslog(LOG_WARNING, "populate_gpio_pins: get_struct_gpio_pin failed."); return; } for(i = 0; i < gpio_pin_cnt; i++) { - gpios[gpio_pin_list[i]].flag = 1; + // Only monitor the PWRGOOD_CPU pin + if (i == PWRGOOD_CPU) + gpios[gpio_pin_list[i]].flag = 1; } @@ -200,6 +204,7 @@ gpio_monitor_poll(uint8_t fru_flag) { uint8_t fru; uint32_t revised_pins, n_pin_val, o_pin_val[MAX_NUM_SLOTS + 1] = {0}; gpio_pin_t *gpios; + char pwr_state[MAX_VALUE_LEN]; uint32_t status; bic_gpio_t gpio = {0}; @@ -211,14 +216,16 @@ gpio_monitor_poll(uint8_t fru_flag) { ret = bic_get_gpio(fru, &gpio); if (ret) { - syslog(LOG_ALERT, "populate_gpio_pins: bic_get_gpio failed for " +#ifdef DEBUG + syslog(LOG_WARNING, "gpio_monitor_poll: bic_get_gpio failed for " " fru %u", fru); +#endif continue; } gpios = get_struct_gpio_pin(fru); if (gpios == NULL) { - syslog(LOG_ALERT, "gpio_monitor_poll: get_struct_gpio_pin failed for" + syslog(LOG_WARNING, "gpio_monitor_poll: get_struct_gpio_pin failed for" " fru %u", fru); continue; } @@ -227,7 +234,7 @@ gpio_monitor_poll(uint8_t fru_flag) { o_pin_val[fru] = 0; - for (i = 0; i <= MAX_GPIO_PINS; i++) { + for (i = 0; i < MAX_GPIO_PINS; i++) { if (gpios[i].flag == 0) continue; @@ -238,8 +245,8 @@ gpio_monitor_poll(uint8_t fru_flag) { o_pin_val[fru] = SETBIT(o_pin_val[fru], i); if (gpios[i].status == gpios[i].ass_val) { - syslog(LOG_CRIT, "ASSERT: fru: %u, gpio pin: %-20s, num: %d", - fru, gpios[i].name, i); + syslog(LOG_CRIT, "ASSERT: fru: %u, num: %d, gpio pin: %-20s", + fru, i, gpios[i].name); } } } @@ -248,48 +255,68 @@ gpio_monitor_poll(uint8_t fru_flag) { while(1) { for (fru = 1; fru <= MAX_NUM_SLOTS; fru++) { if (!(GETBIT(fru_flag, fru))) { - sleep(GPIOD_READ_DELAY); + usleep(DELAY_GPIOD_READ); continue; } gpios = get_struct_gpio_pin(fru); if (gpios == NULL) { - syslog(LOG_ALERT, "gpio_monitor_poll: get_struct_gpio_pin failed for" + syslog(LOG_WARNING, "gpio_monitor_poll: get_struct_gpio_pin failed for" " fru %u", fru); continue; } + memset(pwr_state, 0, MAX_VALUE_LEN); + pal_get_last_pwr_state(fru, pwr_state); + + /* Get the GPIO pins */ if ((ret = bic_get_gpio(fru, (bic_gpio_t *) &n_pin_val)) < 0) { - syslog(LOG_ALERT, "gpio_monitor_poll: bic_get_gpio failed for " - " fru %u", fru); + /* log the error message only when the CPU is on but not reachable. */ + if (!(strcmp(pwr_state, "on"))) { +#ifdef DEBUG + syslog(LOG_WARNING, "gpio_monitor_poll: bic_get_gpio failed for " + " fru %u", fru); +#endif + } continue; } if (o_pin_val[fru] == n_pin_val) { o_pin_val[fru] = n_pin_val; - sleep(GPIOD_READ_DELAY); + usleep(DELAY_GPIOD_READ); continue; } revised_pins = (n_pin_val ^ o_pin_val[fru]); for (i = 0; i < MAX_GPIO_PINS; i++) { - if (GETBIT(revised_pins, i) & gpios[i].flag) { + if (GETBIT(revised_pins, i) && (gpios[i].flag == 1)) { gpios[i].status = GETBIT(n_pin_val, i); // Check if the new GPIO val is ASSERT if (gpios[i].status == gpios[i].ass_val) { - syslog(LOG_CRIT, "ASSERT: fru: %u, gpio pin: %-20s, num: %d", - fru, gpios[i].name, i); + /* + * GPIO - PWRGOOD_CPU assert indicates that the CPU is turned off or in a bad shape. + * Raise an error and change the LPS from on to off or vice versa for deassert. + */ + if (!(strcmp(pwr_state, "on"))) + pal_set_last_pwr_state(fru, "off"); + + syslog(LOG_CRIT, "ASSERT: fru: %u, num: %d, gpio pin: %-20s", + fru, i, gpios[i].name); } else { - syslog(LOG_CRIT, "DEASSERT: fru: %u, gpio pin: %-20s, num: %d", - fru, gpios[i].name, i); + + if (!(strcmp(pwr_state, "off"))) + pal_set_last_pwr_state(fru, "on"); + + syslog(LOG_CRIT, "DEASSERT: fru: %u, num: %d, gpio pin: %-20s", + fru, i, gpios[i].name); } } } o_pin_val[fru] = n_pin_val; - sleep(GPIOD_READ_DELAY); + usleep(DELAY_GPIOD_READ); } /* For Loop for each fru */ } /* while loop */ @@ -297,7 +324,7 @@ gpio_monitor_poll(uint8_t fru_flag) { static void print_usage() { - printf("Usage: gpiod [ %s ]\n", "slot1, slot2, slot3, slot4"); + printf("Usage: gpiod [ %s ]\n", pal_server_list); } /* Spawns a pthread for each fru to monitor all the sensors on it */ diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/gpiod/files/setup-gpiod.sh b/meta-facebook/meta-yosemite/recipes-yosemite/gpiod/files/setup-gpiod.sh index 9e532f2..01df2cd 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/gpiod/files/setup-gpiod.sh +++ b/meta-facebook/meta-yosemite/recipes-yosemite/gpiod/files/setup-gpiod.sh @@ -27,7 +27,28 @@ # Short-Description: Setup sensor monitoring ### END INIT INFO -# TODO: check for the if slot/server is present before starting the daemon +. /usr/local/fbpackages/utils/ast-functions + echo -n "Setup gpio monitoring for yosemite... " -/usr/local/bin/gpiod slot1 slot2 slot3 slot4 + +# Check for the slots present and run sensord for those slots only. +SLOTS= + if [ $(is_server_prsnt 1) == "1" ]; then + SLOTS="$SLOTS slot1" + fi + + if [ $(is_server_prsnt 2) == "1" ]; then + SLOTS="$SLOTS slot2" + fi + + if [ $(is_server_prsnt 3) == "1" ]; then + SLOTS="$SLOTS slot3" + fi + + if [ $(is_server_prsnt 4) == "1" ]; then + SLOTS="$SLOTS slot4" + fi + +/usr/local/bin/gpiod $SLOTS + echo "done." diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/gpiod/gpiod_0.1.bb b/meta-facebook/meta-yosemite/recipes-yosemite/gpiod/gpiod_0.1.bb index 2193a92..a815f36 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/gpiod/gpiod_0.1.bb +++ b/meta-facebook/meta-yosemite/recipes-yosemite/gpiod/gpiod_0.1.bb @@ -50,7 +50,7 @@ do_install() { install -d ${D}${sysconfdir}/init.d install -d ${D}${sysconfdir}/rcS.d install -m 755 setup-gpiod.sh ${D}${sysconfdir}/init.d/setup-gpiod.sh - update-rc.d -r ${D} setup-gpiod.sh start 91 S . + update-rc.d -r ${D} setup-gpiod.sh start 91 5 . } FBPACKAGEDIR = "${prefix}/local/fbpackages" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/ipmbd/ipmbd_0.1.bbappend b/meta-facebook/meta-yosemite/recipes-yosemite/ipmbd/ipmbd_0.1.bbappend index bf2af1e..f2cc6a7 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/ipmbd/ipmbd_0.1.bbappend +++ b/meta-facebook/meta-yosemite/recipes-yosemite/ipmbd/ipmbd_0.1.bbappend @@ -3,6 +3,7 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/files:" SRC_URI += " file://setup-ipmbd.sh \ " +DEPENDS_append = " fbutils " CFLAGS_prepend = " -DCONFIG_YOSEMITE" @@ -16,7 +17,7 @@ do_install() { install -d ${D}${sysconfdir}/init.d install -d ${D}${sysconfdir}/rcS.d install -m 755 setup-ipmbd.sh ${D}${sysconfdir}/init.d/setup-ipmbd.sh - update-rc.d -r ${D} setup-ipmbd.sh start 65 S . + update-rc.d -r ${D} setup-ipmbd.sh start 65 5 . } FBPACKAGEDIR = "${prefix}/local/fbpackages" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/bic.c b/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/bic.c index 5af03ce..938e076 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/bic.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/bic.c @@ -42,7 +42,7 @@ lib_gpio_intr_handle(unsigned char *request, unsigned char req_len, // TODO: Need to update to reuse the socket instead of creating new if ((sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { - syslog(LOG_ALERT, "lib_gpio_intr_handle: socket() failed\n"); + syslog(LOG_WARNING, "lib_gpio_intr_handle: socket() failed\n"); return; } @@ -51,12 +51,12 @@ lib_gpio_intr_handle(unsigned char *request, unsigned char req_len, len = strlen(remote.sun_path) + sizeof(remote.sun_family); if (connect(sockfd, (struct sockaddr *)&remote, len) == -1) { - syslog(LOG_ALERT, "lib_gpio_intr_handle: connect() failed\n"); + syslog(LOG_WARNING, "lib_gpio_intr_handle: connect() failed\n"); return; } if (send(sockfd, request, req_len, 0) == -1) { - syslog(LOG_ALERT, "lib_gpio_intr_handle: send() failed\n"); + syslog(LOG_WARNING, "lib_gpio_intr_handle: send() failed\n"); return; } @@ -64,9 +64,9 @@ lib_gpio_intr_handle(unsigned char *request, unsigned char req_len, *res_len = t; } else { if (t < 0) { - syslog(LOG_ALERT, "lib_gpio_intr_handle: recv() failed\n"); + syslog(LOG_WARNING, "lib_gpio_intr_handle: recv() failed\n"); } else { - printf("Server closed connection"); + syslog(LOG_WARNING, "Server closed connection"); } return; diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/fruid.c b/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/fruid.c index 04772d7..d3fb856 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/fruid.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/fruid.c @@ -34,12 +34,15 @@ #include "fruid.h" #define EEPROM_SPB "/sys/class/i2c-adapter/i2c-8/8-0051/eeprom" +#define EEPROM_NIC "/sys/class/i2c-adapter/i2c-12/12-0051/eeprom" #define BIN_SPB "/tmp/fruid_spb.bin" +#define BIN_NIC "/tmp/fruid_nic.bin" #define NAME_SPB "Side Plane Board" +#define NAME_NIC "Mezz Card" -#define BUF_SIZE 1024 +#define FRUID_SIZE 256 /* * copy_eeprom_to_bin - copy the eeprom to binary file im /tmp directory @@ -54,7 +57,7 @@ int copy_eeprom_to_bin(const char * eeprom_file, const char * bin_file) { int eeprom; int bin; - uint64_t tmp[BUF_SIZE]; + uint64_t tmp[FRUID_SIZE]; ssize_t bytes_rd, bytes_wr; errno = 0; @@ -75,13 +78,18 @@ int copy_eeprom_to_bin(const char * eeprom_file, const char * bin_file) { return errno; } - while ((bytes_rd = read(eeprom, tmp, BUF_SIZE)) > 0) { - bytes_wr = write(bin, tmp, bytes_rd); - if (bytes_wr != bytes_rd) { - syslog(LOG_ERR, "copy_eeprom_to_bin: write to %s file failed: %s", - bin_file, strerror(errno)); - return errno; - } + bytes_rd = read(eeprom, tmp, FRUID_SIZE); + if (bytes_rd != FRUID_SIZE) { + syslog(LOG_ERR, "copy_eeprom_to_bin: write to %s file failed: %s", + eeprom_file, strerror(errno)); + return errno; + } + + bytes_wr = write(bin, tmp, bytes_rd); + if (bytes_wr != bytes_rd) { + syslog(LOG_ERR, "copy_eeprom_to_bin: write to %s file failed: %s", + bin_file, strerror(errno)); + return errno; } close(bin); @@ -97,6 +105,7 @@ int plat_fruid_init(void) { int ret; ret = copy_eeprom_to_bin(EEPROM_SPB, BIN_SPB); + ret = copy_eeprom_to_bin(EEPROM_NIC, BIN_NIC); return ret; } diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/lan.c b/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/lan.c new file mode 100644 index 0000000..3b36046 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/lan.c @@ -0,0 +1,127 @@ +/* + * lan.c + * + * Copyright 2015-present Facebook. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#define _GNU_SOURCE /* To get defns of NI_MAXSERV and NI_MAXHOST */ +#include <arpa/inet.h> +#include <sys/socket.h> +#include <netdb.h> +#include <ifaddrs.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <net/if.h> +#include <linux/if_link.h> +#include <sys/ioctl.h> +#include <stdbool.h> +#include <openbmc/ipmi.h> + +#define ETH_INTF_NAME "eth0" + +#define IPV6_LINK_LOCAL_BYTE1 0xFE +#define IPV6_LINK_LOCAL_BYTE2 0x80 + +#define BYTE_MASK 0xFF +#define BYTE1_OFFSET 8 +#define BYTE2_OFFSET 16 +#define BYTE3_OFFSET 24 + +void plat_lan_init(lan_config_t *lan) +{ + struct ifaddrs *ifaddr, *ifa; + struct sockaddr_in *addr; + struct sockaddr_in6 *addr6; + int family, s, n, i; + unsigned long ip; + unsigned char *ip6; + int sd; + struct ifreq ifr; + uint8_t mac_addr[6]; + uint8_t eui_64_addr[8] = {0x0}; + bool slaac_flag = false; + char test[64]; + + if (getifaddrs(&ifaddr) == -1) { + return; + } + + for (ifa = ifaddr, n = 0; ifa != NULL; ifa = ifa->ifa_next, n++) { + if (ifa->ifa_addr == NULL) { + continue; + } + + if (strcmp(ifa->ifa_name, ETH_INTF_NAME)) { + continue; + } + + family = ifa->ifa_addr->sa_family; + + if (family == AF_INET) { + addr = (struct sockaddr_in*) ifa->ifa_addr; + ip = addr->sin_addr.s_addr; + + // copy the ip address from long to byte array with MSB first + lan->ip_addr[3] = (ip >> BYTE3_OFFSET) & BYTE_MASK; + lan->ip_addr[2] = (ip >> BYTE2_OFFSET) & BYTE_MASK; + lan->ip_addr[1] = (ip >> BYTE1_OFFSET) & BYTE_MASK; + lan->ip_addr[0] = ip & BYTE_MASK; + } else if (family == AF_INET6) { + addr6 = (struct sockaddr_in6*) ifa->ifa_addr; + ip6 = addr6->sin6_addr.s6_addr; + + // If the address is Link Local, Ignore it + if ((ip6[0] == IPV6_LINK_LOCAL_BYTE1) && (ip6[1] == IPV6_LINK_LOCAL_BYTE2)) { + continue; + } + + // Get the MAC address + sd = socket(PF_INET, SOCK_DGRAM, 0); + strcpy(ifr.ifr_name, ifa->ifa_name); + if(ioctl(sd, SIOCGIFHWADDR, &ifr) != -1) { + uint8_t* mac_addr = (uint8_t*)ifr.ifr_hwaddr.sa_data; + + /* + * SLAAC address has lower 8B as follows: + * 3B == First 24b MAC address + * 2B == FFFE + * 3B == Last 24b MAC address + */ + memcpy((void *)&eui_64_addr[0], (void *)&mac_addr[0], 3); + eui_64_addr[3] = 0xFF; + eui_64_addr[4] = 0xFE; + memcpy((void *)&eui_64_addr[5], (void *)&mac_addr[3], 3); + eui_64_addr[0] += 2; + + // Check if the address is SLAAC address. If yes, skip it. + if (!memcmp((void *)&ip6[8], (void *)eui_64_addr, 8)) { + slaac_flag = true; + } + } + + if (slaac_flag) + continue; + + // copy the ip address from array with MSB first + memcpy(lan->ip6_addr, ip6, SIZE_IP6_ADDR); + } + } + + freeifaddrs(ifaddr); +} diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/sensor.c b/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/sensor.c index 16cf98e..57ab5ec 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/sensor.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/sensor.c @@ -81,7 +81,7 @@ populate_mgmt_sensors(void) { // Add this sensor to the global table if (g_sensor_mgmt.num >= SENSOR_MGMT_MAX) { - syslog(LOG_ALERT, "populate_mgmt_sensors: num exceeded\n"); + syslog(LOG_WARNING, "populate_mgmt_sensors: num exceeded\n"); return; } @@ -126,7 +126,7 @@ populate_disc_sensors(void) { // Add this sensor to the global table if (g_sensor_disc.num >= SENSOR_DISC_MAX) { - syslog(LOG_ALERT, "populate_disc_sensors: num exceeded\n"); + syslog(LOG_WARNING, "populate_disc_sensors: num exceeded\n"); return; } @@ -166,7 +166,7 @@ populate_disc_sensors(void) { // Add this sensor to the global table if (g_sensor_disc.num >= SENSOR_DISC_MAX) { - syslog(LOG_ALERT, "populate_disc_sensors: num exceeded\n"); + syslog(LOG_WARNING, "populate_disc_sensors: num exceeded\n"); return; } @@ -207,7 +207,7 @@ populate_disc_sensors(void) { // Add this sensor to the global table if (g_sensor_disc.num >= SENSOR_DISC_MAX) { - syslog(LOG_ALERT, "populate_disc_sensors: num exceeded\n"); + syslog(LOG_WARNING, "populate_disc_sensors: num exceeded\n"); return; } @@ -245,7 +245,7 @@ populate_disc_sensors(void) { // Add this sensor to the global table if (g_sensor_disc.num >= SENSOR_DISC_MAX) { - syslog(LOG_ALERT, "populate_disc_sensors: num exceeded\n"); + syslog(LOG_WARNING, "populate_disc_sensors: num exceeded\n"); return; } @@ -282,7 +282,7 @@ populate_disc_sensors(void) { // Add this sensor to the global table if (g_sensor_disc.num >= SENSOR_DISC_MAX) { - syslog(LOG_ALERT, "populate_disc_sensors: num exceeded\n"); + syslog(LOG_WARNING, "populate_disc_sensors: num exceeded\n"); return; } @@ -323,7 +323,7 @@ populate_disc_sensors(void) { // Add this sensor to the global table if (g_sensor_disc.num >= SENSOR_DISC_MAX) { - syslog(LOG_ALERT, "populate_disc_sensors: num exceeded\n"); + syslog(LOG_WARNING, "populate_disc_sensors: num exceeded\n"); return; } diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/ipmid_0.2.bbappend b/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/ipmid_0.2.bbappend index 4a92e78..57215c5 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/ipmid_0.2.bbappend +++ b/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/ipmid_0.2.bbappend @@ -21,10 +21,13 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/files:" SRC_URI += "file://setup-ipmid.sh \ file://sensor.c \ file://fruid.c \ + file://lan.c \ " S = "${WORKDIR}" +CFLAGS_prepend = " -DCONFIG_YOSEMITE " + do_install() { dst="${D}/usr/local/fbpackages/${pkgdir}" bin="${D}/usr/local/bin" @@ -35,7 +38,7 @@ do_install() { install -d ${D}${sysconfdir}/init.d install -d ${D}${sysconfdir}/rcS.d install -m 755 setup-ipmid.sh ${D}${sysconfdir}/init.d/setup-ipmid.sh - update-rc.d -r ${D} setup-ipmid.sh start 64 S . + update-rc.d -r ${D} setup-ipmid.sh start 64 5 . } FBPACKAGEDIR = "${prefix}/local/fbpackages" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/me-util/files/Makefile b/meta-facebook/meta-yosemite/recipes-yosemite/me-util/files/Makefile new file mode 100644 index 0000000..941ef10 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/me-util/files/Makefile @@ -0,0 +1,10 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +all: me-util + +me-util: me-util.o + $(CC) $(CFLAGS) -pthread -lipmi -lipmb -lbic -lpal -std=c99 -o $@ $^ $(LDFLAGS) + +.PHONY: clean + +clean: + rm -rf *.o me-util diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/me-util/files/me-util.c b/meta-facebook/meta-yosemite/recipes-yosemite/me-util/files/me-util.c new file mode 100644 index 0000000..3a181b2 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/me-util/files/me-util.c @@ -0,0 +1,119 @@ +/* + * me-util + * + * Copyright 2015-present Facebook. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <errno.h> +#include <syslog.h> +#include <stdint.h> +#include <pthread.h> +#include <string.h> +#include <fcntl.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <errno.h> +#include <facebook/bic.h> +#include <openbmc/ipmi.h> + +#define LOGFILE "/tmp/me-util.log" + +static void +print_usage_help(void) { + printf("Usage: me-util <slot1|slot2|slot3|slot4> <[0..n]data_bytes_to_send>\n"); +} + +int +main(int argc, char **argv) { + uint8_t slot_id; + uint8_t tbuf[256] = {0x00}; + uint8_t rbuf[256] = {0x00}; + uint8_t tlen = 0; + uint8_t rlen = 0; + int i; + int ret; + int logfd; + int len; + char log[128]; + char temp[8]; + + if (argc < 3) { + goto err_exit; + } + + if (!strcmp(argv[1], "slot1")) { + slot_id = 1; + } else if (!strcmp(argv[1] , "slot2")) { + slot_id = 2; + } else if (!strcmp(argv[1] , "slot3")) { + slot_id = 3; + } else if (!strcmp(argv[1] , "slot4")) { + slot_id = 4; + } else { + goto err_exit; + } + + for (i = 2; i < argc; i++) { + tbuf[tlen++] = (uint8_t)strtoul(argv[i], NULL, 0); + } + +#if 1 + ret = bic_me_xmit(slot_id, tbuf, tlen, rbuf, &rlen); + if (ret) { + return ret; + } +#endif + + // memcpy(rbuf, tbuf, tlen); + //rlen = tlen; + + + memset(log, 0, 128); + for (i = 0; i < rlen; i++) { + printf("%02X ", rbuf[i]); + memset(temp, 0, 8); + sprintf(temp, "%02X ", rbuf[i]); + strcat(log, temp); + } + printf("\n"); + sprintf(temp, "\n"); + strcat(log, temp); + + errno = 0; + + logfd = open(LOGFILE, O_CREAT | O_WRONLY); + if (logfd < 0) { + syslog(LOG_WARNING, "Opening a tmp file failed. errno: %d", errno); + return -1; + } + + len = write(logfd, log, strlen(log)); + if (len != strlen(log)) { + syslog(LOG_WARNING, "Error writing the log to the file"); + return -1; + } + + close(logfd); + + return 0; +err_exit: + print_usage_help(); + return -1; +} diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/me-util/me-util_0.1.bb b/meta-facebook/meta-yosemite/recipes-yosemite/me-util/me-util_0.1.bb new file mode 100644 index 0000000..02219f2 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/me-util/me-util_0.1.bb @@ -0,0 +1,38 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +SUMMARY = "Management Engine Utility" +DESCRIPTION = "Util for communicating to Intel ME" +SECTION = "base" +PR = "r1" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://me-util.c;beginline=4;endline=16;md5=b395943ba8a0717a83e62ca123a8d238" + +SRC_URI = "file://me-util.c \ + file://Makefile \ + " + +S = "${WORKDIR}" + +binfiles = "me-util \ + " + +pkgdir = "me-util" + +DEPENDS = " libbic libpal " + +do_install() { + dst="${D}/usr/local/fbpackages/${pkgdir}" + bin="${D}/usr/local/bin" + install -d $dst + install -d $bin + for f in ${binfiles}; do + install -m 755 $f ${dst}/$f + ln -snf ../fbpackages/${pkgdir}/$f ${bin}/$f + done +} + +FBPACKAGEDIR = "${prefix}/local/fbpackages" + +FILES_${PN} = "${FBPACKAGEDIR}/me-util ${prefix}/local/bin" + +INHIBIT_PACKAGE_DEBUG_SPLIT = "1" +INHIBIT_PACKAGE_STRIP = "1" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/rest-api/rest-api_0.2.bbappend b/meta-facebook/meta-yosemite/recipes-yosemite/rest-api/rest-api_0.2.bbappend index ce33bba..701a8d1 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/rest-api/rest-api_0.2.bbappend +++ b/meta-facebook/meta-yosemite/recipes-yosemite/rest-api/rest-api_0.2.bbappend @@ -54,7 +54,7 @@ do_install() { install -d ${D}${sysconfdir}/init.d install -d ${D}${sysconfdir}/rcS.d install -m 755 setup-rest-api.sh ${D}${sysconfdir}/init.d/setup-rest-api.sh - update-rc.d -r ${D} setup-rest-api.sh start 95 2 3 4 5 . + update-rc.d -r ${D} setup-rest-api.sh start 95 5 . } FBPACKAGEDIR = "${prefix}/local/fbpackages" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/sensor-mon/files/setup-sensord.sh b/meta-facebook/meta-yosemite/recipes-yosemite/sensor-mon/files/setup-sensord.sh index 3f4b38e..f387d20 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/sensor-mon/files/setup-sensord.sh +++ b/meta-facebook/meta-yosemite/recipes-yosemite/sensor-mon/files/setup-sensord.sh @@ -29,7 +29,27 @@ . /usr/local/fbpackages/utils/ast-functions -# TODO: check for the if slot/server is present before starting the daemon echo -n "Setup sensor monitoring for yosemite... " -/usr/local/bin/sensord slot1 slot2 slot3 slot4 + +# Check for the slots present and run sensord for those slots only. +SLOTS= + if [ $(is_server_prsnt 1) == "1" ]; then + SLOTS="$SLOTS slot1" + fi + + if [ $(is_server_prsnt 2) == "1" ]; then + SLOTS="$SLOTS slot2" + fi + + if [ $(is_server_prsnt 3) == "1" ]; then + SLOTS="$SLOTS slot3" + fi + + if [ $(is_server_prsnt 4) == "1" ]; then + SLOTS="$SLOTS slot4" + fi + +SLOTS="$SLOTS spb nic" +/usr/local/bin/sensord $SLOTS + echo "done." diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/sensor-mon/sensor-mon_0.1.bbappend b/meta-facebook/meta-yosemite/recipes-yosemite/sensor-mon/sensor-mon_0.1.bbappend index 687a599..b920973 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/sensor-mon/sensor-mon_0.1.bbappend +++ b/meta-facebook/meta-yosemite/recipes-yosemite/sensor-mon/sensor-mon_0.1.bbappend @@ -22,11 +22,8 @@ SRC_URI += "file://setup-sensord.sh \ S = "${WORKDIR}" -CFLAGS_prepend = " -DCONFIG_YOSEMITE " -LDFLAGS_append = " -lyosemite_sensor " - -DEPENDS_append = "libyosemite-sensor update-rc.d-native" +DEPENDS_append = "update-rc.d-native" pkgdir = "sensor-mon" @@ -45,7 +42,7 @@ do_install() { install -d ${D}${sysconfdir}/init.d install -d ${D}${sysconfdir}/rcS.d install -m 755 setup-sensord.sh ${D}${sysconfdir}/init.d/setup-sensord.sh - update-rc.d -r ${D} setup-sensord.sh start 91 S . + update-rc.d -r ${D} setup-sensord.sh start 91 5 . } FBPACKAGEDIR = "${prefix}/local/fbpackages" |