Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@
from mmap import *

def usage():
''' This is the Usage Method '''
''' This is the Usage Method '''

print '\t\t pcisysfs.py --get --offset <offset> --res <resource>'
print '\t\t pcisysfs.py --set --val <val> --offset <offset> --res <resource>'
sys.exit(1)
print('\t\t pcisysfs.py --get --offset <offset> --res <resource>')
print('\t\t pcisysfs.py --set --val <val> --offset <offset> --res <resource>')
sys.exit(1)

def pci_mem_read(mm,offset):
mm.seek(offset)
read_data_stream=mm.read(4)
print ""
print("")
reg_val=struct.unpack('I',read_data_stream)
print "reg_val read:%x"%reg_val
print("reg_val read:%x"%reg_val)
return reg_val

def pci_mem_write(mm,offset,data):
mm.seek(offset)
print "data to write:%x"%data
print("data to write:%x"%data)
mm.write(struct.pack('I',data))

def pci_set_value(resource,val,offset):
Expand All @@ -63,7 +63,7 @@ def main(argv):
try:
opts, args = getopt.getopt(argv, "hgsv:" , \
["val=","res=","offset=","help", "get", "set"])

except getopt.GetoptError:
usage()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,15 @@ def get_reboot_cause(self):
return (self.REBOOT_CAUSE_NON_HARDWARE, None)

if reboot_cause & 0x1:
return (self.REBOOT_CAUSE_POWER_LOSS, None)
return (self.REBOOT_CAUSE_POWER_LOSS, "Power on reset")
elif reboot_cause & 0x2:
return (self.REBOOT_CAUSE_NON_HARDWARE, None)
elif reboot_cause & 0x4:
return (self.REBOOT_CAUSE_HARDWARE_OTHER, "PSU Shutdown")
elif reboot_cause & 0x8:
return (self.REBOOT_CAUSE_THERMAL_OVERLOAD_CPU, None)
return (self.REBOOT_CAUSE_THERMAL_OVERLOAD_CPU, "Thermal overload")
elif reboot_cause & 0x10:
return (self.REBOOT_CAUSE_WATCHDOG, None)
return (self.REBOOT_CAUSE_WATCHDOG, "Watchdog reset")
elif reboot_cause & 0x20:
return (self.REBOOT_CAUSE_HARDWARE_OTHER, "BMC Shutdown")
elif reboot_cause & 0x40:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@
def usage():
''' This is the Usage Method '''

print '\t\t pcisysfs.py --get --offset <offset> --res <resource>'
print '\t\t pcisysfs.py --set --val <val> --offset <offset> --res <resource>'
print('\t\t pcisysfs.py --get --offset <offset> --res <resource>')
print('\t\t pcisysfs.py --set --val <val> --offset <offset> --res <resource>')
sys.exit(1)

def pci_mem_read(mm,offset):
mm.seek(offset)
read_data_stream=mm.read(4)
print ""
print("")
reg_val=struct.unpack('I',read_data_stream)
print "reg_val read:%x"%reg_val
print("reg_val read:%x"%reg_val)
return reg_val

def pci_mem_write(mm,offset,data):
mm.seek(offset)
print "data to write:%x"%data
print("data to write:%x"%data)
mm.write(struct.pack('I',data))

def pci_set_value(resource,val,offset):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ def get_num_sfps(self):
An integer represences the number of SFPs on the chassis.
"""
return self._num_sfps

def get_reboot_cause(self):
"""
Retrieves the cause of the previous reboot
Expand All @@ -279,15 +280,15 @@ def get_reboot_cause(self):
return (self.REBOOT_CAUSE_NON_HARDWARE, None)

if reboot_cause & 0x1:
return (self.REBOOT_CAUSE_POWER_LOSS, None)
return (self.REBOOT_CAUSE_POWER_LOSS, "Power on reset")
elif reboot_cause & 0x2:
return (self.REBOOT_CAUSE_NON_HARDWARE, None)
elif reboot_cause & 0x4:
return (self.REBOOT_CAUSE_HARDWARE_OTHER, "PSU Shutdown")
elif reboot_cause & 0x8:
return (self.REBOOT_CAUSE_THERMAL_OVERLOAD_CPU, None)
return (self.REBOOT_CAUSE_THERMAL_OVERLOAD_CPU, "Thermal overload")
elif reboot_cause & 0x10:
return (self.REBOOT_CAUSE_WATCHDOG, None)
return (self.REBOOT_CAUSE_WATCHDOG, "Watchdog reset")
elif reboot_cause & 0x20:
return (self.REBOOT_CAUSE_HARDWARE_OTHER, "BMC Shutdown")
elif reboot_cause & 0x40:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Chassis(ChassisBase):

oir_fd = -1
epoll = -1
REBOOT_CAUSE_PATH = "/host/reboot-cause/platform/reboot_reason"
pci_res = "/sys/bus/pci/devices/0000:04:00.0/resource0"
sysled_offset = 0x0024
SYSLED_COLOR_TO_REG = {
Expand Down Expand Up @@ -290,15 +291,15 @@ def get_reboot_cause(self):
return (self.REBOOT_CAUSE_NON_HARDWARE, None)

if reboot_cause & 0x1:
return (self.REBOOT_CAUSE_POWER_LOSS, None)
return (self.REBOOT_CAUSE_POWER_LOSS, "Power on reset")
elif reboot_cause & 0x2:
return (self.REBOOT_CAUSE_NON_HARDWARE, None)
elif reboot_cause & 0x4:
return (self.REBOOT_CAUSE_HARDWARE_OTHER, "PSU Shutdown")
elif reboot_cause & 0x8:
return (self.REBOOT_CAUSE_THERMAL_OVERLOAD_CPU, None)
return (self.REBOOT_CAUSE_THERMAL_OVERLOAD_CPU, "Thermal overload")
elif reboot_cause & 0x10:
return (self.REBOOT_CAUSE_WATCHDOG, None)
return (self.REBOOT_CAUSE_WATCHDOG, "Watchdog reset")
elif reboot_cause & 0x20:
return (self.REBOOT_CAUSE_HARDWARE_OTHER, "BMC Shutdown")
elif reboot_cause & 0x40:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@
from mmap import *

def usage():
''' This is the Usage Method '''
''' This is the Usage Method '''

print '\t\t pcisysfs.py --get --offset <offset> --res <resource>'
print '\t\t pcisysfs.py --set --val <val> --offset <offset> --res <resource>'
sys.exit(1)
print('\t\t pcisysfs.py --get --offset <offset> --res <resource>')
print('\t\t pcisysfs.py --set --val <val> --offset <offset> --res <resource>')
sys.exit(1)

def pci_mem_read(mm,offset):
mm.seek(offset)
read_data_stream=mm.read(4)
print ""
print("")
reg_val=struct.unpack('I',read_data_stream)
print "reg_val read:%x"%reg_val
print("reg_val read:%x"%reg_val)
return reg_val

def pci_mem_write(mm,offset,data):
mm.seek(offset)
print "data to write:%x"%data
print("data to write:%x"%data)
mm.write(struct.pack('I',data))

def pci_set_value(resource,val,offset):
Expand All @@ -63,7 +63,7 @@ def main(argv):
try:
opts, args = getopt.getopt(argv, "hgsv:" , \
["val=","res=","offset=","help", "get", "set"])

except getopt.GetoptError:
usage()

Expand Down