Merge pull request #8 from jk-ozlabs/master
bin/ipmi_debug: Use newer HostIpmi interface
diff --git a/Makefile b/Makefile
index 23b53ce..02f51f1 100644
--- a/Makefile
+++ b/Makefile
@@ -37,9 +37,6 @@
led_controller: led_controller.o gpio.o libopenbmc_intf
$(CC) -o bin/$@.exe obj/gpio.o obj/led_controller.o $(LDFLAGS) $(LIBS)
-sensor_ambient: sensor_threshold.o sensor_temperature_ambient_obj.o libopenbmc_intf
- $(CC) -o bin/$@.exe obj/sensor_threshold.o obj/sensor_temperature_ambient_obj.o $(LDFLAGS) $(LIBS)
-
button_power: button_power_obj.o gpio.o libopenbmc_intf
$(CC) -o bin/$@.exe obj/button_power_obj.o obj/gpio.o $(LDFLAGS) $(LIBS)
@@ -74,4 +71,4 @@
$(CC) -o bin/$@.exe obj/hwmon_intf.o $(LDFLAGS) $(LIBS)
-all: setup libopenbmc_intf power_control led_controller sensor_ambient button_power control_host fan host_watchdog control_bmc board_vpd pcie_slot_present flash_bios flasher control_bmc_barreleye
+all: setup libopenbmc_intf power_control led_controller button_power control_host fan host_watchdog control_bmc board_vpd pcie_slot_present flash_bios flasher control_bmc_barreleye
diff --git a/bin/Barreleye.py b/bin/Barreleye.py
index e77a438..d42dedb 100755
--- a/bin/Barreleye.py
+++ b/bin/Barreleye.py
@@ -1,13 +1,9 @@
#! /usr/bin/python
-import dbus
-import Openbmc
-
HOME_PATH = './'
-CACHE_PATH = HOME_PATH+'cache/'
-FRU_PATH = CACHE_PATH+'frus/'
+CACHE_PATH = '/var/cache/obmc/'
FLASH_DOWNLOAD_PATH = "/tmp"
-
+GPIO_BASE = 320
SYSTEM_NAME = "Barreleye"
@@ -16,6 +12,7 @@
## - a process emits a GotoSystemState signal with state name to goto
## - objects specified in EXIT_STATE_DEPEND have started
SYSTEM_STATES = [
+ 'BASE_APPS',
'BMC_INIT',
'BMC_STARTING',
'BMC_READY',
@@ -27,191 +24,144 @@
]
EXIT_STATE_DEPEND = {
+ 'BASE_APPS' : {
+ '/org/openbmc/managers/Property': 0,
+ },
'BMC_STARTING' : {
'/org/openbmc/control/chassis0': 0,
'/org/openbmc/control/power0' : 0,
'/org/openbmc/control/led/BMC_READY' : 0,
- '/org/openbmc/control/Host_0' : 0,
+ '/org/openbmc/control/host0' : 0,
+ '/org/openbmc/control/flash/bios' : 0,
}
}
## method will be called when state is entered
ENTER_STATE_CALLBACK = {
- 'HOST_POWERED_ON' : {
- 'bus_name' : 'org.openbmc.control.Host',
- 'obj_name' : '/org/openbmc/control/Host_0',
- 'interface_name' : 'org.openbmc.control.Host',
- 'method_name' : 'boot'
+ 'HOST_POWERED_ON' : {
+ 'boot' : {
+ 'bus_name' : 'org.openbmc.control.Host',
+ 'obj_name' : '/org/openbmc/control/host0',
+ 'interface_name' : 'org.openbmc.control.Host',
+ }
},
'BMC_READY' : {
- 'bus_name' : 'org.openbmc.control.led',
- 'obj_name' : '/org/openbmc/control/led/BMC_READY',
- 'interface_name' : 'org.openbmc.Led',
- 'method_name' : 'setOn'
+ 'setOn' : {
+ 'bus_name' : 'org.openbmc.control.led',
+ 'obj_name' : '/org/openbmc/control/led/BMC_READY',
+ 'interface_name' : 'org.openbmc.Led',
+ },
+ 'init' : {
+ 'bus_name' : 'org.openbmc.control.Flash',
+ 'obj_name' : '/org/openbmc/control/flash/bios',
+ 'interface_name' : 'org.openbmc.Flash',
+ },
}
}
-SYSTEM_CONFIG = {}
-
-SYSTEM_CONFIG['org.openbmc.control.Bmc'] = {
- 'system_state' : 'BMC_INIT',
- 'start_process' : True,
+APPS = {
+ 'property_manager' : {
+ 'system_state' : 'BASE_APPS',
+ 'start_process' : True,
'monitor_process' : True,
- 'process_name' : 'control_bmc_barreleye.exe',
- 'heartbeat' : 'no',
- 'instances' : [ { 'name' : 'Bmc_0' } ]
- }
-
-SYSTEM_CONFIG['org.openbmc.managers.Inventory'] = {
- 'system_state' : 'BMC_STARTING',
- 'start_process' : True,
- 'monitor_process' : True,
- 'process_name' : 'inventory_items.py',
- 'heartbeat' : 'no',
- 'instances' : [ { 'name' : SYSTEM_NAME } ]
- }
-SYSTEM_CONFIG['org.openbmc.control.PciePresent'] = {
- 'system_state' : 'HOST_POWERED_ON',
- 'start_process' : True,
+ 'process_name' : 'property_manager.py',
+ 'args' : [ SYSTEM_NAME ]
+ },
+ 'bmc_init' : {
+ 'system_state' : 'BMC_INIT',
+ 'start_process' : True,
'monitor_process' : False,
- 'process_name' : 'pcie_slot_present.exe',
- 'heartbeat' : 'no',
- 'instances' : [ { 'name' : 'Slots_0' } ]
- }
-SYSTEM_CONFIG['org.openbmc.sensor.Power8Virtual'] = {
- 'system_state' : 'BMC_STARTING',
- 'start_process' : True,
+ 'process_name' : 'control_bmc_barreleye.exe',
+ },
+ 'inventory' : {
+ 'system_state' : 'BMC_STARTING',
+ 'start_process' : True,
'monitor_process' : True,
- 'process_name' : 'sensors_virtual_p8.py',
- 'heartbeat' : 'no',
- 'instances' : [ { 'name' : 'virtual' } ]
- }
-
-SYSTEM_CONFIG['org.openbmc.managers.Sensors'] = {
- 'system_state' : 'BMC_STARTING',
- 'start_process' : True,
+ 'process_name' : 'inventory_items.py',
+ 'args' : [ SYSTEM_NAME ]
+ },
+ 'pcie_present' : {
+ 'system_state' : 'HOST_POWERED_ON',
+ 'start_process' : True,
+ 'monitor_process' : False,
+ 'process_name' : 'pcie_slot_present.exe',
+ },
+ 'virtual_sensors' : {
+ 'system_state' : 'BMC_STARTING',
+ 'start_process' : True,
'monitor_process' : True,
- 'process_name' : 'sensor_manager.py',
- 'heartbeat' : 'no',
- 'instances' : [ { 'name' : SYSTEM_NAME } ]
- }
-
-SYSTEM_CONFIG['org.openbmc.watchdog.Host'] = {
- 'system_state' : 'BMC_STARTING',
- 'start_process' : True,
+ 'process_name' : 'sensors_virtual_p8.py',
+ },
+ 'sensor_manager' : {
+ 'system_state' : 'BMC_STARTING',
+ 'start_process' : True,
'monitor_process' : True,
- 'process_name' : 'host_watchdog.exe',
- 'heartbeat' : 'no',
- 'instances' : [
- {
- 'name' : 'HostWatchdog_0',
- 'properties' : {
- 'org.openbmc.Watchdog' : {
- 'poll_interval': 30000,
- }
- }
- }
- ]
- }
-
-SYSTEM_CONFIG['org.openbmc.control.Power'] = {
- 'system_state' : 'BMC_STARTING',
- 'start_process' : True,
+ 'process_name' : 'sensor_manager.py',
+ 'args' : [ SYSTEM_NAME ]
+ },
+ 'host_watchdog' : {
+ 'system_state' : 'BMC_STARTING',
+ 'start_process' : True,
+ 'monitor_process' : True,
+ 'process_name' : 'host_watchdog.exe',
+ },
+ 'power_control' : {
+ 'system_state' : 'BMC_STARTING',
+ 'start_process' : True,
'monitor_process' : True,
'process_name' : 'power_control.exe',
- 'heartbeat' : 'no',
- 'instances' : [
- {
- 'name' : 'power0',
- 'user_label': 'Power control',
- 'properties' : {
- 'org.openbmc.Control': {
- 'poll_interval' : 3000
- },
- 'org.openbmc.control.Power': {
- 'pgood_timeout' : 10
- }
- }
- }
- ]
- }
-
-SYSTEM_CONFIG['org.openbmc.buttons.Power'] = {
- 'system_state' : 'BMC_STARTING',
- 'start_process' : True,
- 'monitor_process' : True,
- 'process_name' : 'button_power.exe',
- 'heartbeat' : 'no',
- 'instances' : [ { 'name' : 'PowerButton_0' } ]
- }
-SYSTEM_CONFIG['org.openbmc.control.led'] = {
- 'system_state' : 'BMC_STARTING',
- 'start_process' : True,
- 'monitor_process' : True,
- 'process_name' : 'led_controller.exe',
- 'heartbeat' : 'no',
- 'instances' : [ { 'name' : 'Dummy' } ]
- }
-SYSTEM_CONFIG['org.openbmc.control.Flash'] = {
- 'system_state' : 'BMC_STARTING',
- 'start_process' : True,
- 'monitor_process' : True,
- 'process_name' : 'flash_bios.exe',
- 'heartbeat' : 'no',
- 'instances' : [ { 'name' : 'dummy' } ]
- }
-
-SYSTEM_CONFIG['org.openbmc.manager.Download'] = {
- 'system_state' : 'BMC_STARTING',
- 'start_process' : True,
- 'monitor_process' : True,
- 'process_name' : 'download_manager.py',
- 'heartbeat' : 'no',
- 'instances' : [ { 'name' : SYSTEM_NAME } ]
- }
-
-SYSTEM_CONFIG['org.openbmc.control.Host'] = {
- 'system_state' : 'BMC_STARTING',
- 'start_process' : True,
- 'monitor_process' : True,
- 'process_name' : 'control_host.exe',
- 'heartbeat' : 'no',
- 'instances' : [ { 'name' : 'Host_0' } ]
- }
-SYSTEM_CONFIG['org.openbmc.control.Chassis'] = {
- 'system_state' : 'BMC_STARTING',
- 'start_process' : True,
- 'monitor_process' : True,
- 'process_name' : 'chassis_control.py',
- 'heartbeat' : 'no',
- 'instances' : [ { 'name' : 'chassis0' } ]
- }
-
-SYSTEM_CONFIG['org.openbmc.vpd'] = {
- 'system_state' : 'HOST_POWERED_ON',
- 'start_process' : False,
+ 'args' : [ '3000', '10' ]
+ },
+ 'power_button' : {
+ 'system_state' : 'BMC_STARTING',
+ 'start_process' : False,
'monitor_process' : False,
- 'process_name' : 'board_vpd.exe',
- 'heartbeat' : 'no',
- 'instances' : [ { 'name' : 'MBVPD_0' } ]
- }
-
-SYSTEM_CONFIG['org.openbmc.sensors.Fan'] = {
- 'system_state' : 'BMC_STARTING',
- 'start_process' : True,
+ 'process_name' : 'button_power.exe',
+ },
+ 'led_control' : {
+ 'system_state' : 'BMC_STARTING',
+ 'start_process' : True,
'monitor_process' : True,
- 'process_name' : 'fan.exe',
- 'heartbeat' : 'no',
- 'instances' : [ {'name' : 'Fan_0' }, {'name' : 'Fan_1'}, {'name' : 'Fan_2'} ]
+ 'process_name' : 'led_controller.exe',
+ },
+ 'flash_control' : {
+ 'system_state' : 'BMC_STARTING',
+ 'start_process' : True,
+ 'monitor_process' : True,
+ 'process_name' : 'flash_bios.exe',
+ },
+ 'download_manager' : {
+ 'system_state' : 'BMC_STARTING',
+ 'start_process' : True,
+ 'monitor_process' : True,
+ 'process_name' : 'download_manager.py',
+ 'args' : [ SYSTEM_NAME ]
+ },
+ 'host_control' : {
+ 'system_state' : 'BMC_STARTING',
+ 'start_process' : True,
+ 'monitor_process' : True,
+ 'process_name' : 'control_host.exe',
+ },
+ 'chassis_control' : {
+ 'system_state' : 'BMC_STARTING',
+ 'start_process' : True,
+ 'monitor_process' : True,
+ 'process_name' : 'chassis_control.py',
+ },
+ 'fans' : {
+ 'system_state' : 'BMC_STARTING',
+ 'start_process' : True,
+ 'monitor_process' : True,
+ 'process_name' : 'fan.exe',
+ 'args' : [ 'fan0','fan1','fan2','fan3','fan4' ]
}
-
-NON_CACHABLE_PROPERTIES = {
- 'name' : True,
- 'user_label' : True,
- 'location' : True,
- 'state' : True,
- 'cache' : True
}
+
+CACHED_INTERFACES = {
+ "org.openbmc.InventoryItem" : True,
+ "org.openbmc.control.Chassis" : True,
+ }
INVENTORY_ROOT = '/org/openbmc/inventory'
FRU_INSTANCES = {
@@ -311,8 +261,6 @@
}
-
-
ID_LOOKUP = {
'FRU' : {
0x0d : '<inventory_root>/system/chassis',
@@ -323,7 +271,7 @@
0x04 : '<inventory_root>/system/chassis/motherboard/dimm1',
0x05 : '<inventory_root>/system/chassis/motherboard/dimm2',
0x06 : '<inventory_root>/system/chassis/motherboard/dimm3',
- 0xff : '<inventory_root>/system',
+ 0x35 : '<inventory_root>/system',
},
'FRU_STR' : {
'PRODUCT_15' : '<inventory_root>/system',
@@ -367,22 +315,31 @@
}
GPIO_CONFIG = {}
-GPIO_CONFIG['FSI_CLK'] = { 'gpio_num': 484, 'direction': 'out' }
-GPIO_CONFIG['FSI_DATA'] = { 'gpio_num': 485, 'direction': 'out' }
-GPIO_CONFIG['FSI_ENABLE'] = { 'gpio_num': 504, 'direction': 'out' }
-GPIO_CONFIG['POWER_PIN'] = { 'gpio_num': 449, 'direction': 'out' }
-GPIO_CONFIG['CRONUS_SEL'] = { 'gpio_num': 486, 'direction': 'out' }
-GPIO_CONFIG['PGOOD'] = { 'gpio_num': 503, 'direction': 'in' }
-GPIO_CONFIG['IDENTIFY'] = { 'gpio_num': 474, 'direction': 'out' }
-GPIO_CONFIG['BMC_READY'] = { 'gpio_num': 474, 'direction': 'out' }
-GPIO_CONFIG['POWER_BUTTON'] = { 'gpio_num': 448, 'direction': 'falling' }
-GPIO_CONFIG['SLOT0_RISER_PRESENT'] = { 'gpio_num': 392, 'direction': 'in' }
-GPIO_CONFIG['SLOT1_RISER_PRESENT'] = { 'gpio_num': 393, 'direction': 'in' }
-GPIO_CONFIG['SLOT2_RISER_PRESENT'] = { 'gpio_num': 394, 'direction': 'in' }
-GPIO_CONFIG['SLOT0_PRESENT'] = { 'gpio_num': 395, 'direction': 'in' }
-GPIO_CONFIG['SLOT1_PRESENT'] = { 'gpio_num': 396, 'direction': 'in' }
-GPIO_CONFIG['SLOT2_PRESENT'] = { 'gpio_num': 397, 'direction': 'in' }
-GPIO_CONFIG['MEZZ0_PRESENT'] = { 'gpio_num': 400, 'direction': 'in' }
-GPIO_CONFIG['MEZZ1_PRESENT'] = { 'gpio_num': 401, 'direction': 'in' }
+GPIO_CONFIG['FSI_CLK'] = { 'gpio_pin': 'A4', 'direction': 'out' }
+GPIO_CONFIG['FSI_DATA'] = { 'gpio_pin': 'A5', 'direction': 'out' }
+GPIO_CONFIG['FSI_ENABLE'] = { 'gpio_pin': 'D0', 'direction': 'out' }
+GPIO_CONFIG['POWER_PIN'] = { 'gpio_pin': 'E1', 'direction': 'out' }
+GPIO_CONFIG['CRONUS_SEL'] = { 'gpio_pin': 'A6', 'direction': 'out' }
+GPIO_CONFIG['PGOOD'] = { 'gpio_pin': 'C7', 'direction': 'in' }
+GPIO_CONFIG['IDENTIFY'] = { 'gpio_pin': 'R5', 'direction': 'out' }
+GPIO_CONFIG['BMC_READY'] = { 'gpio_pin': 'H2', 'direction': 'out' }
+GPIO_CONFIG['POWER_BUTTON'] = { 'gpio_pin': 'E0', 'direction': 'both' }
+GPIO_CONFIG['SLOT0_RISER_PRESENT'] = { 'gpio_pin': 'N0', 'direction': 'in' }
+GPIO_CONFIG['SLOT1_RISER_PRESENT'] = { 'gpio_pin': 'N1', 'direction': 'in' }
+GPIO_CONFIG['SLOT2_RISER_PRESENT'] = { 'gpio_pin': 'N2', 'direction': 'in' }
+GPIO_CONFIG['SLOT0_PRESENT'] = { 'gpio_pin': 'N3', 'direction': 'in' }
+GPIO_CONFIG['SLOT1_PRESENT'] = { 'gpio_pin': 'N4', 'direction': 'in' }
+GPIO_CONFIG['SLOT2_PRESENT'] = { 'gpio_pin': 'N5', 'direction': 'in' }
+GPIO_CONFIG['MEZZ0_PRESENT'] = { 'gpio_pin': 'O0', 'direction': 'in' }
+GPIO_CONFIG['MEZZ1_PRESENT'] = { 'gpio_pin': 'O1', 'direction': 'in' }
+
+def convertGpio(name):
+ name = name.upper()
+ c = name[0:1]
+ offset = int(name[1:])
+ a = ord(c)-65
+ base = a*8+GPIO_BASE
+ return base+offset
+
diff --git a/bin/Palmetto.py b/bin/Palmetto.py
index f38fd73..c1b9238 100755
--- a/bin/Palmetto.py
+++ b/bin/Palmetto.py
@@ -1,12 +1,9 @@
#! /usr/bin/python
-import dbus
-import Openbmc
-
HOME_PATH = './'
-CACHE_PATH = HOME_PATH+'cache/'
+CACHE_PATH = '/var/cache/obmc/'
FLASH_DOWNLOAD_PATH = "/tmp"
-
+GPIO_BASE = 320
SYSTEM_NAME = "Palmetto"
@@ -34,172 +31,132 @@
'/org/openbmc/control/chassis0': 0,
'/org/openbmc/control/power0' : 0,
'/org/openbmc/control/led/BMC_READY' : 0,
- '/org/openbmc/control/Host_0' : 0,
+ '/org/openbmc/control/host0' : 0,
+ '/org/openbmc/control/flash/bios' : 0,
}
}
## method will be called when state is entered
ENTER_STATE_CALLBACK = {
- 'HOST_POWERED_ON' : {
- 'bus_name' : 'org.openbmc.control.Host',
- 'obj_name' : '/org/openbmc/control/Host_0',
- 'interface_name' : 'org.openbmc.control.Host',
- 'method_name' : 'boot'
+ 'HOST_POWERED_ON' : {
+ 'boot' : {
+ 'bus_name' : 'org.openbmc.control.Host',
+ 'obj_name' : '/org/openbmc/control/host0',
+ 'interface_name' : 'org.openbmc.control.Host',
+ }
},
'BMC_READY' : {
- 'bus_name' : 'org.openbmc.control.led',
- 'obj_name' : '/org/openbmc/control/led/BMC_READY',
- 'interface_name' : 'org.openbmc.Led',
- 'method_name' : 'setOn'
+ 'setOn' : {
+ 'bus_name' : 'org.openbmc.control.led',
+ 'obj_name' : '/org/openbmc/control/led/BMC_READY',
+ 'interface_name' : 'org.openbmc.Led',
+ },
+ 'init' : {
+ 'bus_name' : 'org.openbmc.control.Flash',
+ 'obj_name' : '/org/openbmc/control/flash/bios',
+ 'interface_name' : 'org.openbmc.Flash',
+ },
}
}
-SYSTEM_CONFIG = {}
-
-SYSTEM_CONFIG['org.openbmc.managers.Property'] = {
- 'system_state' : 'BASE_APPS',
- 'start_process' : True,
+APPS = {
+ 'property_manager' : {
+ 'system_state' : 'BASE_APPS',
+ 'start_process' : True,
'monitor_process' : True,
- 'process_name' : 'property_manager.py',
- 'instances' : [ { 'name' : SYSTEM_NAME } ]
- }
-
-SYSTEM_CONFIG['org.openbmc.control.Bmc'] = {
- 'system_state' : 'BMC_INIT',
- 'start_process' : True,
- 'monitor_process' : True,
- 'process_name' : 'control_bmc.exe',
- 'instances' : [ { 'name' : 'Bmc_0' } ]
- }
-
-SYSTEM_CONFIG['org.openbmc.managers.Inventory'] = {
- 'system_state' : 'BMC_STARTING',
- 'start_process' : True,
- 'monitor_process' : True,
- 'process_name' : 'inventory_items.py',
- 'instances' : [ { 'name' : SYSTEM_NAME } ]
- }
-SYSTEM_CONFIG['org.openbmc.control.PciePresent'] = {
- 'system_state' : 'HOST_POWERED_ON',
- 'start_process' : True,
+ 'process_name' : 'property_manager.py',
+ 'args' : [ SYSTEM_NAME ]
+ },
+ 'bmc_init' : {
+ 'system_state' : 'BMC_INIT',
+ 'start_process' : True,
'monitor_process' : False,
- 'process_name' : 'pcie_slot_present.exe',
- 'instances' : [ { 'name' : 'Slots_0' } ]
- }
-SYSTEM_CONFIG['org.openbmc.sensor.Power8Virtual'] = {
- 'system_state' : 'BMC_STARTING',
- 'start_process' : True,
+ 'process_name' : 'control_bmc.exe',
+ },
+ 'inventory' : {
+ 'system_state' : 'BMC_STARTING',
+ 'start_process' : True,
'monitor_process' : True,
- 'process_name' : 'sensors_virtual_p8.py',
- 'instances' : [ { 'name' : 'virtual' } ]
- }
-
-SYSTEM_CONFIG['org.openbmc.managers.Sensors'] = {
- 'system_state' : 'BMC_STARTING',
- 'start_process' : True,
+ 'process_name' : 'inventory_items.py',
+ 'args' : [ SYSTEM_NAME ]
+ },
+ 'pcie_present' : {
+ 'system_state' : 'HOST_POWERED_ON',
+ 'start_process' : True,
+ 'monitor_process' : False,
+ 'process_name' : 'pcie_slot_present.exe',
+ },
+ 'virtual_sensors' : {
+ 'system_state' : 'BMC_STARTING',
+ 'start_process' : True,
'monitor_process' : True,
- 'process_name' : 'sensor_manager.py',
- 'instances' : [ { 'name' : SYSTEM_NAME } ]
- }
-
-SYSTEM_CONFIG['org.openbmc.watchdog.Host'] = {
- 'system_state' : 'BMC_STARTING',
- 'start_process' : True,
+ 'process_name' : 'sensors_virtual_p8.py',
+ },
+ 'sensor_manager' : {
+ 'system_state' : 'BMC_STARTING',
+ 'start_process' : True,
'monitor_process' : True,
- 'process_name' : 'host_watchdog.exe',
- 'instances' : [
- {
- 'name' : 'HostWatchdog_0',
- 'properties' : {
- 'org.openbmc.Watchdog' : {
- 'poll_interval': 30000,
- }
- }
- }
- ]
- }
-
-SYSTEM_CONFIG['org.openbmc.control.Power'] = {
- 'system_state' : 'BMC_STARTING',
- 'start_process' : True,
+ 'process_name' : 'sensor_manager.py',
+ 'args' : [ SYSTEM_NAME ]
+ },
+ 'host_watchdog' : {
+ 'system_state' : 'BMC_STARTING',
+ 'start_process' : True,
+ 'monitor_process' : True,
+ 'process_name' : 'host_watchdog.exe',
+ },
+ 'power_control' : {
+ 'system_state' : 'BMC_STARTING',
+ 'start_process' : True,
'monitor_process' : True,
'process_name' : 'power_control.exe',
- 'instances' : [
- {
- 'name' : 'power0',
- 'user_label': 'Power control',
- 'properties' : {
- 'org.openbmc.Control': {
- 'poll_interval' : 3000
- },
- 'org.openbmc.control.Power': {
- 'pgood_timeout' : 10
- }
- }
- }
- ]
- }
-
-SYSTEM_CONFIG['org.openbmc.buttons.Power'] = {
- 'system_state' : 'BMC_STARTING',
- 'start_process' : True,
- 'monitor_process' : True,
- 'process_name' : 'button_power.exe',
- 'instances' : [ { 'name' : 'PowerButton_0' } ]
- }
-SYSTEM_CONFIG['org.openbmc.control.led'] = {
- 'system_state' : 'BMC_STARTING',
- 'start_process' : True,
- 'monitor_process' : True,
- 'process_name' : 'led_controller.exe',
- 'instances' : [ { 'name' : 'Dummy' } ]
- }
-SYSTEM_CONFIG['org.openbmc.control.Flash'] = {
- 'system_state' : 'BMC_STARTING',
- 'start_process' : True,
- 'monitor_process' : True,
- 'process_name' : 'flash_bios.exe',
- 'instances' : [ { 'name' : 'dummy' } ]
- }
-
-SYSTEM_CONFIG['org.openbmc.manager.Download'] = {
- 'system_state' : 'BMC_STARTING',
- 'start_process' : True,
- 'monitor_process' : True,
- 'process_name' : 'download_manager.py',
- 'instances' : [ { 'name' : SYSTEM_NAME } ]
- }
-
-SYSTEM_CONFIG['org.openbmc.control.Host'] = {
- 'system_state' : 'BMC_STARTING',
- 'start_process' : True,
- 'monitor_process' : True,
- 'process_name' : 'control_host.exe',
- 'instances' : [ { 'name' : 'Host_0' } ]
- }
-SYSTEM_CONFIG['org.openbmc.control.Chassis'] = {
- 'system_state' : 'BMC_STARTING',
- 'start_process' : True,
- 'monitor_process' : True,
- 'process_name' : 'chassis_control.py',
- 'instances' : [ { 'name' : 'chassis0' } ]
- }
-
-SYSTEM_CONFIG['org.openbmc.vpd'] = {
- 'system_state' : 'HOST_POWERED_ON',
- 'start_process' : False,
+ 'args' : [ '3000', '10' ]
+ },
+ 'power_button' : {
+ 'system_state' : 'BMC_STARTING',
+ 'start_process' : False,
'monitor_process' : False,
- 'process_name' : 'board_vpd.exe',
- 'instances' : [ { 'name' : 'MBVPD_0' } ]
- }
-
-SYSTEM_CONFIG['org.openbmc.sensors.Fan'] = {
- 'system_state' : 'BMC_STARTING',
- 'start_process' : True,
+ 'process_name' : 'button_power.exe',
+ },
+ 'led_control' : {
+ 'system_state' : 'BMC_STARTING',
+ 'start_process' : True,
'monitor_process' : True,
- 'process_name' : 'fan.exe',
- 'instances' : [ {'name' : 'Fan_0' }, {'name' : 'Fan_1'}, {'name' : 'Fan_2'} ]
+ 'process_name' : 'led_controller.exe',
+ },
+ 'flash_control' : {
+ 'system_state' : 'BMC_STARTING',
+ 'start_process' : True,
+ 'monitor_process' : True,
+ 'process_name' : 'flash_bios.exe',
+ },
+ 'download_manager' : {
+ 'system_state' : 'BMC_STARTING',
+ 'start_process' : True,
+ 'monitor_process' : True,
+ 'process_name' : 'download_manager.py',
+ 'args' : [ SYSTEM_NAME ]
+ },
+ 'host_control' : {
+ 'system_state' : 'BMC_STARTING',
+ 'start_process' : True,
+ 'monitor_process' : True,
+ 'process_name' : 'control_host.exe',
+ },
+ 'chassis_control' : {
+ 'system_state' : 'BMC_STARTING',
+ 'start_process' : True,
+ 'monitor_process' : True,
+ 'process_name' : 'chassis_control.py',
+ },
+ 'fans' : {
+ 'system_state' : 'BMC_STARTING',
+ 'start_process' : True,
+ 'monitor_process' : True,
+ 'process_name' : 'fan.exe',
+ 'args' : [ 'fan0','fan1','fan2','fan3','fan4' ]
}
+}
CACHED_INTERFACES = {
"org.openbmc.InventoryItem" : True,
@@ -208,88 +165,42 @@
INVENTORY_ROOT = '/org/openbmc/inventory'
FRU_INSTANCES = {
- '<inventory_root>/system' :
- { 'fru_type' : 'SYSTEM','is_fru' : True, },
+ '<inventory_root>/system' : { 'fru_type' : 'SYSTEM','is_fru' : True, },
+ '<inventory_root>/system/chassis' : { 'fru_type' : 'SYSTEM','is_fru' : True, },
+ '<inventory_root>/system/chassis/motherboard' : { 'fru_type' : 'MAIN_PLANAR','is_fru' : True, },
- '<inventory_root>/system/chassis' :
- { 'fru_type' : 'SYSTEM','is_fru' : True, },
+ '<inventory_root>/system/chassis/fan0' : { 'fru_type' : 'FAN','is_fru' : True, },
+ '<inventory_root>/system/chassis/fan1' : { 'fru_type' : 'FAN','is_fru' : True, },
+ '<inventory_root>/system/chassis/fan2' : { 'fru_type' : 'FAN','is_fru' : True, },
+ '<inventory_root>/system/chassis/fan3' : { 'fru_type' : 'FAN','is_fru' : True, },
+ '<inventory_root>/system/chassis/fan4' : { 'fru_type' : 'FAN','is_fru' : True, },
- '<inventory_root>/system/chassis/motherboard' :
- { 'fru_type' : 'MAIN_PLANAR','is_fru' : True, },
-
- '<inventory_root>/system/chassis/fan0' :
- { 'fru_type' : 'FAN','is_fru' : True, },
- '<inventory_root>/system/chassis/fan1' :
- { 'fru_type' : 'FAN','is_fru' : True, },
- '<inventory_root>/system/chassis/fan2' :
- { 'fru_type' : 'FAN','is_fru' : True, },
- '<inventory_root>/system/chassis/fan3' :
- { 'fru_type' : 'FAN','is_fru' : True, },
- '<inventory_root>/system/chassis/fan4' :
- { 'fru_type' : 'FAN','is_fru' : True, },
-
- '<inventory_root>/system/chassis/motherboard/bmc' :
- { 'fru_type' : 'BMC','is_fru' : False,
+ '<inventory_root>/system/chassis/motherboard/bmc' : { 'fru_type' : 'BMC','is_fru' : False,
'manufacturer' : 'ASPEED' },
- '<inventory_root>/system/chassis/motherboard/cpu0' :
- { 'fru_type' : 'CPU', 'is_fru' : True, },
+ '<inventory_root>/system/chassis/motherboard/cpu0' : { 'fru_type' : 'CPU', 'is_fru' : True, },
+ '<inventory_root>/system/chassis/motherboard/cpu0/core0' : { 'fru_type' : 'CORE', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/cpu0/core1' : { 'fru_type' : 'CORE', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/cpu0/core2' : { 'fru_type' : 'CORE', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/cpu0/core3' : { 'fru_type' : 'CORE', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/cpu0/core4' : { 'fru_type' : 'CORE', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/cpu0/core5' : { 'fru_type' : 'CORE', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/cpu0/core6' : { 'fru_type' : 'CORE', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/cpu0/core7' : { 'fru_type' : 'CORE', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/cpu0/core8' : { 'fru_type' : 'CORE', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/cpu0/core9' : { 'fru_type' : 'CORE', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/cpu0/core10' : { 'fru_type' : 'CORE', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/cpu0/core11' : { 'fru_type' : 'CORE', 'is_fru' : False, },
- '<inventory_root>/system/chassis/motherboard/cpu0/core0' :
- { 'fru_type' : 'CORE', 'is_fru' : False, },
-
- '<inventory_root>/system/chassis/motherboard/cpu0/core1' :
- { 'fru_type' : 'CORE', 'is_fru' : False, },
-
- '<inventory_root>/system/chassis/motherboard/cpu0/core2' :
- { 'fru_type' : 'CORE', 'is_fru' : False, },
-
- '<inventory_root>/system/chassis/motherboard/cpu0/core3' :
- { 'fru_type' : 'CORE', 'is_fru' : False, },
-
- '<inventory_root>/system/chassis/motherboard/cpu0/core4' :
- { 'fru_type' : 'CORE', 'is_fru' : False, },
-
- '<inventory_root>/system/chassis/motherboard/cpu0/core5' :
- { 'fru_type' : 'CORE', 'is_fru' : False, },
-
- '<inventory_root>/system/chassis/motherboard/cpu0/core6' :
- { 'fru_type' : 'CORE', 'is_fru' : False, },
-
- '<inventory_root>/system/chassis/motherboard/cpu0/core7' :
- { 'fru_type' : 'CORE', 'is_fru' : False, },
-
- '<inventory_root>/system/chassis/motherboard/cpu0/core8' :
- { 'fru_type' : 'CORE', 'is_fru' : False, },
-
- '<inventory_root>/system/chassis/motherboard/cpu0/core9' :
- { 'fru_type' : 'CORE', 'is_fru' : False, },
-
- '<inventory_root>/system/chassis/motherboard/cpu0/core10' :
- { 'fru_type' : 'CORE', 'is_fru' : False, },
-
- '<inventory_root>/system/chassis/motherboard/cpu0/core11' :
- { 'fru_type' : 'CORE', 'is_fru' : False, },
- '<inventory_root>/system/chassis/motherboard/centaur0' :
- { 'fru_type' : 'MEMORY_BUFFER', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/centaur0' : { 'fru_type' : 'MEMORY_BUFFER', 'is_fru' : False, },
- '<inventory_root>/system/chassis/motherboard/dimm0' :
- { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm0' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm1' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm2' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm3' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
- '<inventory_root>/system/chassis/motherboard/dimm1' :
- { 'fru_type' : 'DIMM', 'is_fru' : True,},
-
- '<inventory_root>/system/chassis/motherboard/dimm2' :
- { 'fru_type' : 'DIMM', 'is_fru' : True,},
-
- '<inventory_root>/system/chassis/motherboard/dimm3' :
- { 'fru_type' : 'DIMM', 'is_fru' : True,},
-
- '<inventory_root>/system/chassis/io_board/pcie_slot0' :
- { 'fru_type' : 'PCIE_CARD', 'is_fru' : True,},
-
- '<inventory_root>/system/chassis/io_board/pcie_slot1' :
- { 'fru_type' : 'PCIE_CARD', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/io_board/pcie_slot0' : { 'fru_type' : 'PCIE_CARD', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/io_board/pcie_slot1' : { 'fru_type' : 'PCIE_CARD', 'is_fru' : True,},
}
@@ -347,22 +258,31 @@
}
GPIO_CONFIG = {}
-GPIO_CONFIG['FSI_CLK'] = { 'gpio_num': 484, 'direction': 'out' }
-GPIO_CONFIG['FSI_DATA'] = { 'gpio_num': 485, 'direction': 'out' }
-GPIO_CONFIG['FSI_ENABLE'] = { 'gpio_num': 504, 'direction': 'out' }
-GPIO_CONFIG['POWER_PIN'] = { 'gpio_num': 449, 'direction': 'out' }
-GPIO_CONFIG['CRONUS_SEL'] = { 'gpio_num': 486, 'direction': 'out' }
-GPIO_CONFIG['PGOOD'] = { 'gpio_num': 503, 'direction': 'in' }
-GPIO_CONFIG['IDENTIFY'] = { 'gpio_num': 365, 'direction': 'out' }
-GPIO_CONFIG['BMC_READY'] = { 'gpio_num': 365, 'direction': 'out' }
-GPIO_CONFIG['POWER_BUTTON'] = { 'gpio_num': 448, 'direction': 'falling' }
-GPIO_CONFIG['SLOT0_RISER_PRESENT'] = { 'gpio_num': 104, 'direction': 'in' }
-GPIO_CONFIG['SLOT1_RISER_PRESENT'] = { 'gpio_num': 105, 'direction': 'in' }
-GPIO_CONFIG['SLOT2_RISER_PRESENT'] = { 'gpio_num': 106, 'direction': 'in' }
-GPIO_CONFIG['SLOT0_PRESENT'] = { 'gpio_num': 470, 'direction': 'in' }
-GPIO_CONFIG['SLOT1_PRESENT'] = { 'gpio_num': 471, 'direction': 'in' }
-GPIO_CONFIG['SLOT2_PRESENT'] = { 'gpio_num': 109, 'direction': 'in' }
-GPIO_CONFIG['MEZZ0_PRESENT'] = { 'gpio_num': 112, 'direction': 'in' }
-GPIO_CONFIG['MEZZ1_PRESENT'] = { 'gpio_num': 113, 'direction': 'in' }
+GPIO_CONFIG['FSI_CLK'] = { 'gpio_pin': 'A4', 'direction': 'out' }
+GPIO_CONFIG['FSI_DATA'] = { 'gpio_pin': 'A5', 'direction': 'out' }
+GPIO_CONFIG['FSI_ENABLE'] = { 'gpio_pin': 'D0', 'direction': 'out' }
+GPIO_CONFIG['POWER_PIN'] = { 'gpio_pin': 'E1', 'direction': 'out' }
+GPIO_CONFIG['CRONUS_SEL'] = { 'gpio_pin': 'A6', 'direction': 'out' }
+GPIO_CONFIG['PGOOD'] = { 'gpio_pin': 'C7', 'direction': 'in' }
+GPIO_CONFIG['IDENTIFY'] = { 'gpio_pin': 'R4', 'direction': 'out' }
+GPIO_CONFIG['BMC_READY'] = { 'gpio_pin': 'R4', 'direction': 'out' }
+GPIO_CONFIG['POWER_BUTTON'] = { 'gpio_pin': 'E0', 'direction': 'both' }
+GPIO_CONFIG['SLOT0_RISER_PRESENT'] = { 'gpio_pin': 'N0', 'direction': 'in' }
+GPIO_CONFIG['SLOT1_RISER_PRESENT'] = { 'gpio_pin': 'N1', 'direction': 'in' }
+GPIO_CONFIG['SLOT2_RISER_PRESENT'] = { 'gpio_pin': 'N2', 'direction': 'in' }
+GPIO_CONFIG['SLOT0_PRESENT'] = { 'gpio_pin': 'N3', 'direction': 'in' }
+GPIO_CONFIG['SLOT1_PRESENT'] = { 'gpio_pin': 'N4', 'direction': 'in' }
+GPIO_CONFIG['SLOT2_PRESENT'] = { 'gpio_pin': 'N5', 'direction': 'in' }
+GPIO_CONFIG['MEZZ0_PRESENT'] = { 'gpio_pin': 'O0', 'direction': 'in' }
+GPIO_CONFIG['MEZZ1_PRESENT'] = { 'gpio_pin': 'O1', 'direction': 'in' }
+
+def convertGpio(name):
+ name = name.upper()
+ c = name[0:1]
+ offset = int(name[1:])
+ a = ord(c)-65
+ base = a*8+GPIO_BASE
+ return base+offset
+
diff --git a/bin/chassis_control.py b/bin/chassis_control.py
index b3d622c..0cac579 100755
--- a/bin/chassis_control.py
+++ b/bin/chassis_control.py
@@ -10,7 +10,7 @@
import Openbmc
DBUS_NAME = 'org.openbmc.control.Chassis'
-OBJ_NAME = '/org/openbmc/control/'+sys.argv[1]
+OBJ_NAME = '/org/openbmc/control/chassis0'
CONTROL_INTF = 'org.openbmc.Control'
POWER_OFF = 0
@@ -37,7 +37,7 @@
},
'watchdog' : {
'bus_name' : 'org.openbmc.watchdog.Host',
- 'object_name' : '/org/openbmc/watchdog/HostWatchdog_0',
+ 'object_name' : '/org/openbmc/watchdog/host0',
'interface_name' : 'org.openbmc.Watchdog'
}
}
@@ -50,7 +50,7 @@
bus.add_signal_receiver(self.power_button_signal_handler,
dbus_interface = "org.openbmc.Button", signal_name = "ButtonPressed",
- path="/org/openbmc/buttons/PowerButton_0" )
+ path="/org/openbmc/buttons/power0" )
bus.add_signal_receiver(self.host_watchdog_signal_handler,
dbus_interface = "org.openbmc.Watchdog", signal_name = "WatchdogError")
bus.add_signal_receiver(self.SystemStateHandler,signal_name = "GotoSystemState")
diff --git a/bin/console b/bin/console
deleted file mode 100755
index d3fa8bb..0000000
--- a/bin/console
+++ /dev/null
@@ -1,4 +0,0 @@
-#! /bin/sh
-
-screen /dev/ttyS3 115200
-
diff --git a/bin/gpio2num b/bin/gpio2num
deleted file mode 100755
index a176ec5..0000000
--- a/bin/gpio2num
+++ /dev/null
@@ -1,18 +0,0 @@
-#! /usr/bin/python
-
-import sys
-
-if (len(sys.argv) <2):
- print "Usage: gpio2num [gpio1] [gpio2] ... [gpion]"
- print "\tExample: gpio2num A2 B4"
- exit(0)
-
-sys.argv.pop(0)
-for name in sys.argv:
- c = name[0:1]
- num = name[1:]
- a = ord(c)-65
- base = 480 - (int(a/4) * 32)
- offset = a%4*8 + int(num)
- gpio_num = base+offset
- print name+" = " + str(gpio_num)
diff --git a/bin/gpioutil b/bin/gpioutil
new file mode 100755
index 0000000..ab44b4d
--- /dev/null
+++ b/bin/gpioutil
@@ -0,0 +1,162 @@
+#!/usr/bin/env python
+
+import sys
+import os
+import getopt
+
+
+def printUsage():
+ print '\nUsage:'
+ print 'gpioutil SYSTEM_NAME -n GPIO_NAME [-v value]'
+ print 'gpioutil SYSTEM_NAME -i GPIO_NUM -d <DIRECTION = in,out,falling,rising,both> [-v value]'
+ print 'gpioutil SYSTEM_NAME -p PIN_NAME -d <DIRECTION = in,out,falling,rising,both> [-v value]'
+ print 'gpioutil SYSTEM_NAME -l PIN_NAME (lookup pin name only)'
+ exit(1)
+
+
+
+if (len(sys.argv) < 3):
+ printUsage()
+
+sys.argv.pop(0)
+libr = sys.argv.pop(0)
+System = __import__(libr)
+
+GPIO_SYSFS = '/sys/class/gpio/'
+
+class Gpio:
+ def __init__(self,gpio_num):
+ self.gpio_num = str(gpio_num)
+ self.direction = ''
+ self.interrupt = ''
+ self.exported = False
+
+ def getPath(self,name):
+ return GPIO_SYSFS+'gpio'+self.gpio_num+'/'+name
+
+ def export(self):
+ if (os.path.exists(GPIO_SYSFS+'export') == False):
+ raise Exception("ERROR - GPIO_SYSFS path does not exist. Does this platform support GPIOS?")
+ if (os.path.exists(GPIO_SYSFS+'gpio'+self.gpio_num) == False):
+ self.write(GPIO_SYSFS+'export',self.gpio_num)
+
+ self.exported = True
+
+ def setDirection(self,dir):
+ if (self.exported == False):
+ raise Exception("ERROR - Not exported: "+self.getPath())
+
+ self.direction = ''
+ self.interrupt = ''
+ if (dir == 'in' or dir == 'out'):
+ self.direction = dir
+ elif (dir == 'rising' or
+ dir == 'falling' or
+ dir == 'both'):
+ self.direction = 'in'
+ self.interrupt = dir
+ self.write(self.getPath('edge'),self.interrupt)
+ else:
+ raise Exception("ERROR - Invalid Direction: "+dir)
+
+
+ self.write(self.getPath('direction'),self.direction)
+
+ def setValue(self,value):
+ if (value == '0'):
+ self.write(self.getPath('value'),'0')
+ elif (value == '1'):
+ self.write(self.getPath('value'),'1')
+ else:
+ raise Exception("ERROR - Invalid value: "+value)
+
+ def getValue(self):
+ return self.read(self.getPath('value'))
+
+ def write(self,path,data):
+ f = open(path,'w')
+ f.write(data)
+ f.close()
+
+
+ def read(self,path):
+ f = open(path,'r')
+ data = f.readline()
+ f.close()
+ return data
+
+
+
+if __name__ == '__main__':
+
+ try:
+ opts, args = getopt.getopt(sys.argv,"hn:i:d:v:p:l:")
+ except getopt.GetoptError:
+ printUsage()
+
+
+
+ lookup = False
+ gpio_name = ""
+ value = ""
+ direction = ""
+ for opt, arg in opts:
+ if opt == '-h':
+ printUsage()
+
+ elif opt in ("-n"):
+ gpio_name = arg
+ lookup = True
+ elif opt in ("-i"):
+ gpio_name = arg
+ elif opt in ("-d"):
+ direction = arg
+ elif opt in ("-v"):
+ value = arg
+ elif opt in ("-p"):
+ gpio_name = System.convertGpio(arg)
+ elif opt in ("-l"):
+ gpio_name = System.convertGpio(arg)
+ print gpio_name
+ exit(0)
+
+ gpio_info = {}
+ if (lookup == True):
+ if (System.GPIO_CONFIG.has_key(gpio_name) == False):
+ print "ERROR - GPIO Name doesn't exist"
+ print "Valid names: "
+ for n in System.GPIO_CONFIG:
+ print "\t"+n
+ exit(0)
+ gpio_info = System.GPIO_CONFIG[gpio_name]
+ direction = gpio_info['direction']
+ if (gpio_info.has_key('gpio_num')):
+ gpio_name = str(gpio_info['gpio_num'])
+ else:
+ gpio_name = str(System.convertGpio(gpio_info['gpio_pin']))
+ print "GPIO ID: "+gpio_name+"; DIRECTION: "+direction
+
+
+ ## Rules
+ if (gpio_name == ""):
+ print "ERROR - Gpio not specified"
+ printUsage()
+
+ if (direction == "in" and value != ""):
+ print "ERROR - Value cannot be specified when direction = in"
+ printUsage()
+
+ gpio = Gpio(gpio_name)
+ try:
+ gpio.export()
+ if (direction != ""):
+ gpio.setDirection(direction)
+
+ if (value == ""):
+ print gpio.getValue()
+ else:
+ gpio.setValue(value)
+
+ except Exception as e:
+ print e
+
diff --git a/bin/hconsole b/bin/hconsole
new file mode 100755
index 0000000..7fec020
--- /dev/null
+++ b/bin/hconsole
@@ -0,0 +1,7 @@
+#! /bin/sh
+
+echo "Ctrl-a :quit to exit console. [Enter] to continue"
+read a
+systemctl stop serial-getty@ttyS0
+screen /dev/ttyS3 115200
+
diff --git a/bin/ipmi_example.py b/bin/ipmi_example.py
deleted file mode 100755
index f8b921e..0000000
--- a/bin/ipmi_example.py
+++ /dev/null
@@ -1,137 +0,0 @@
-#!/usr/bin/env python
-
-import sys
-import subprocess
-import gobject
-import dbus
-import dbus.service
-import dbus.mainloop.glib
-import PropertyManager
-
-import Openbmc
-
-SENSOR_INTERFACE = "org.openbmc.SensorValue"
-
-class IpmiBt(dbus.service.Object):
- def __init__(self,bus,name):
- dbus.service.Object.__init__(self,bus,name)
-
-
-def getWatchdog():
- obj = bus.get_object('org.openbmc.watchdog.Host',
- '/org/openbmc/watchdog/HostWatchdog_0')
- intf = dbus.Interface(obj, 'org.openbmc.Watchdog' )
- return intf
-
-def getChassisControl():
- obj = bus.get_object('org.openbmc.control.Chassis',
- '/org/openbmc/control/chassis0')
- intf = dbus.Interface(obj, 'org.openbmc.control.Chassis' )
- return intf
-
-def prettyPrint(data):
- for k in data.keys():
- print k
- for k2 in data[k].keys():
- print "\t"+k2+" = "+str(data[k][k2])
-
-
-
-if __name__ == '__main__':
- #dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
- bus = Openbmc.getDBus()
-
- #name = dbus.service.BusName(DBUS_NAME,bus)
- #mainloop = gobject.MainLoop()
-
- cmd = sys.argv[1]
- data = None
- ipmi_id = dbus.Byte(0)
- if (len(sys.argv) > 2):
- ipmi_id = sys.argv[2]
- if (len(sys.argv)>3):
- data = sys.argv[3]
-
- if (cmd == "poweron"):
- intf = getChassisControl()
- intf.powerOn()
- elif (cmd == "poweroff"):
- intf = getChassisControl()
- intf.powerOff()
- elif (cmd == "getid"):
- intf = getChassisControl()
- id = intf.getID()
- print id
- elif (cmd == "setsensor"):
- intf_sys = Openbmc.getManagerInterface(bus,"System")
- obj_info = intf_sys.getObjectFromByteId("SENSOR",chr(int(ipmi_id)))
- obj_path = obj_info[1]
- bus_name = obj_info[0]
- if (obj_path != "" and bus_name != ""):
- obj = bus.get_object(bus_name,obj_path)
- intf = dbus.Interface(obj,)
- intf.setValue(dbus.Byte(int(data)))
-
- elif (cmd == "getsensors"):
- intf_sens = Openbmc.getManagerInterface(bus,"Sensors")
- data = intf_sens.getSensors()
- prettyPrint(data)
- elif (cmd == "updatefru"):
- d = { 'manufacturer' : data }
- intf_sys = Openbmc.getManagerInterface(bus,"System")
- c = chr(int(ipmi_id))
- print c
- obj_info = intf_sys.getObjectFromByteId("FRU",c)
- intf_name = obj_info[2]
- obj_path = obj_info[1]
- bus_name = obj_info[0]
- if (obj_path != "" and bus_name != ""):
- obj = bus.get_object(bus_name,obj_path)
- intf = dbus.Interface(obj,intf_name)
- intf.update(d)
-
- elif (cmd == "getfrus"):
- obj = bus.get_object('org.openbmc.managers.Inventory',
- '/org/openbmc/inventory')
- intf_fru = dbus.Interface(obj,'org.openbmc.Object.Enumerate')
-
- data = intf_fru.enumerate()
- for i in data:
- print ">>>>>>>>"
- print i
- for k in data[i].keys():
- print k+" = "+str(data[i][k])
- elif (cmd == "updatefwftp"):
- obj = bus.get_object('org.openbmc.flash.Bios','/org/openbmc/flash/Bios_0')
- intf = dbus.Interface(obj,"org.openbmc.Flash")
- intf.updateViaTftp(sys.argv[2],sys.argv[3])
- elif (cmd == "updatefwfile"):
- obj = bus.get_object('org.openbmc.flash.Bios','/org/openbmc/flash/Bios_0')
- intf = dbus.Interface(obj,"org.openbmc.Flash")
- intf.update(sys.argv[2])
- elif (cmd == "fwstatus"):
- intf = Openbmc.getManagerInterface(bus,"Flash")
- status = intf.getStatus()
- for i in status:
- print i+" = "+status[i]
- elif (cmd == "pokewatchdog"):
- intf = getWatchdog()
- intf.poke()
- elif (cmd == "statewatchdog"):
- intf = getWatchdog()
- intf.start()
- elif (cmd == "stopwatchdog"):
- intf = getWatchdog()
- intf.stop()
- elif (cmd == "setwatchdog"):
- count = int(sys.argv[2])
- intf = getWatchdog()
- intf.set(count)
- else:
- print "Unsupported command"
-
-
-
-
-
-
diff --git a/bin/obmcutil b/bin/obmcutil
index 4340f37..e4e07c4 100755
--- a/bin/obmcutil
+++ b/bin/obmcutil
@@ -52,7 +52,7 @@
},
'identify_led' : {
'bus_name' : 'org.openbmc.control.led',
- 'object_name' : '/org/openbmc/led/IDENTIFY',
+ 'object_name' : '/org/openbmc/control/led/IDENTIFY',
'interface_name' : 'org.openbmc.Led'
},
'chassis' : {
diff --git a/bin/system_manager.py b/bin/system_manager.py
index 75fb74f..b33f78f 100755
--- a/bin/system_manager.py
+++ b/bin/system_manager.py
@@ -7,9 +7,10 @@
import dbus.service
import dbus.mainloop.glib
import os
-import PropertyManager
import time
import json
+import xml.etree.ElementTree as ET
+
import Openbmc
if (len(sys.argv) < 2):
@@ -27,10 +28,37 @@
INTF_ITEM = 'org.openbmc.InventoryItem'
INTF_CONTROL = 'org.openbmc.Control'
+def get_objects(bus,bus_name,path,objects):
+ tmp_path = path
+ if (path == ""):
+ tmp_path="/"
+
+ obj = bus.get_object(bus_name,tmp_path)
+ introspect_iface = dbus.Interface(obj,"org.freedesktop.DBus.Introspectable")
+ tree = ET.ElementTree(ET.fromstring(introspect_iface.Introspect()))
+ root = tree.getroot()
+ parent = True
+ ##print introspect_iface.Introspect()
+ for node in root.iter('node'):
+ for intf in node.iter('interface'):
+ objects[path] = True
+
+ if (node.attrib.has_key('name') == True):
+ node_name = node.attrib['name']
+ if (parent == False):
+ get_objects(bus,bus_name,path+"/"+node_name,objects)
+ else:
+ if (node_name != "" and node_name != path):
+ get_objects(bus,bus_name,node_name,objects)
+
+ parent = False
+
+
+
+
class SystemManager(dbus.service.Object):
def __init__(self,bus,name):
dbus.service.Object.__init__(self,bus,name)
- self.property_manager = PropertyManager.PropertyManager(bus,System.CACHE_PATH)
## Signal handlers
bus.add_signal_receiver(self.NewBusHandler,
@@ -43,11 +71,11 @@
self.bus_name_lookup = {}
self.bin_path = os.path.dirname(os.path.realpath(sys.argv[0]))
- for bus_name in System.SYSTEM_CONFIG.keys():
- sys_state = System.SYSTEM_CONFIG[bus_name]['system_state']
+ for name in System.APPS.keys():
+ sys_state = System.APPS[name]['system_state']
if (self.system_states.has_key(sys_state) == False):
self.system_states[sys_state] = []
- self.system_states[sys_state].append(bus_name)
+ self.system_states[sys_state].append(name)
## replace symbolic path in ID_LOOKUP
for category in System.ID_LOOKUP:
@@ -61,18 +89,6 @@
def SystemStateHandler(self,state_name):
- print "Checking previous state started..."
- i = 0
- started = self.check_state_started()
- while(i<10 and started == False):
- started = self.check_state_started()
- i=i+1
- time.sleep(1)
-
- if (i == STATE_START_TIMEOUT):
- print "ERROR: Timeout waiting for state to finish: "+self.current_state
- return
-
## clearing object started flags
try:
for obj_path in System.EXIT_STATE_DEPEND[self.current_state]:
@@ -82,8 +98,8 @@
print "Running System State: "+state_name
if (self.system_states.has_key(state_name)):
- for bus_name in self.system_states[state_name]:
- self.start_process(bus_name)
+ for name in self.system_states[state_name]:
+ self.start_process(name)
if (state_name == "BMC_INIT"):
## Add poll for heartbeat
@@ -144,81 +160,56 @@
byte = int(key)
return self.doObjectLookup(category,byte)
- def start_process(self,bus_name):
- if (System.SYSTEM_CONFIG[bus_name]['start_process'] == True):
- process_name = self.bin_path+"/"+System.SYSTEM_CONFIG[bus_name]['process_name']
+ def start_process(self,name):
+ if (System.APPS[name]['start_process'] == True):
+ app = System.APPS[name]
+ process_name = self.bin_path+"/"+app['process_name']
cmdline = [ ]
cmdline.append(process_name)
- System.SYSTEM_CONFIG[bus_name]['popen'] = None
- for instance in System.SYSTEM_CONFIG[bus_name]['instances']:
- cmdline.append(instance['name'])
+ app['popen'] = None
+ if (app.has_key('args')):
+ for a in app['args']:
+ cmdline.append(a)
try:
- print "Starting process: "+" ".join(cmdline)+": "+bus_name
- System.SYSTEM_CONFIG[bus_name]['popen'] = subprocess.Popen(cmdline)
+ print "Starting process: "+" ".join(cmdline)+": "+name
+ app['popen'] = subprocess.Popen(cmdline)
except Exception as e:
## TODO: error
print "ERROR: starting process: "+" ".join(cmdline)
def heartbeat_check(self):
- for bus_name in System.SYSTEM_CONFIG.keys():
- if (System.SYSTEM_CONFIG[bus_name]['start_process'] == True and
- System.SYSTEM_CONFIG[bus_name].has_key('popen') and
- System.SYSTEM_CONFIG[bus_name]['monitor_process'] == True):
+ for name in System.APPS.keys():
+ app = System.APPS[name]
+ if (app['start_process'] == True and
+ app.has_key('popen') and
+ app['monitor_process'] == True):
+
## make sure process is still alive
- p = System.SYSTEM_CONFIG[bus_name]['popen']
+ p = app['popen']
p.poll()
if (p.returncode != None):
- print "Process for "+bus_name+" appears to be dead"
- self.start_process(bus_name)
+ print "Process for "+name+" appears to be dead"
+ self.start_process(name)
return True
- def check_state_started(self):
- r = True
- if (self.current_state == ""):
- return True
- if (self.system_states.has_key(self.current_state)):
- for bus_name in self.system_states[self.current_state]:
- if (System.SYSTEM_CONFIG[bus_name].has_key('popen') == False and
- System.SYSTEM_CONFIG[bus_name]['start_process'] == True):
- r = False
- break;
- return r
-
def NewBusHandler(self, bus_name, a, b):
if (len(b) > 0 and bus_name.find(Openbmc.BUS_PREFIX) == 0):
objects = {}
try:
- Openbmc.get_objs(bus,bus_name,"",objects)
- for instance_name in objects.keys():
- obj_path = objects[instance_name]['PATH']
- #obj = bus.get_object("org.openbmc.managers.Property",
- # "/org/openbmc/managers/Property")
- #intf = dbus.Interface(obj,"org.openbmc.managers.Property")
- #intf.loadFromCache(bus_name,obj_path)
+ get_objects(bus,bus_name,"",objects)
+ for obj_path in objects.keys():
self.bus_name_lookup[obj_path] = bus_name
+ print "New object: "+obj_path+" ("+bus_name+")"
if (System.EXIT_STATE_DEPEND[self.current_state].has_key(obj_path) == True):
System.EXIT_STATE_DEPEND[self.current_state][obj_path] = 1
except Exception as e:
+ ## object probably disappeared
+ #print e
pass
- if (System.SYSTEM_CONFIG.has_key(bus_name)):
- for instance_name in objects.keys():
- obj_path = objects[instance_name]['PATH']
- for instance in System.SYSTEM_CONFIG[bus_name]['instances']:
- if (instance.has_key('properties') and instance['name'] == instance_name):
- props = instance['properties']
- print "Load Properties: "+obj_path
- self.property_manager.loadProperties(bus_name,obj_path,props)
- ## If object has an init method, call it
- for init_intf in objects[instance_name]['INIT']:
- obj = bus.get_object(bus_name,obj_path)
- intf = dbus.Interface(obj,init_intf)
- print "Calling init method: " +obj_path+" : "+init_intf
- intf.init()
-
- ## check if all objects are started to move to next state
+ ## check if all required objects are started to move to next state
try:
state = 1
for obj_path in System.EXIT_STATE_DEPEND[self.current_state]:
@@ -236,16 +227,26 @@
in_signature='s', out_signature='sis')
def gpioInit(self,name):
gpio_path = ''
- gpio_num = 0
+ gpio_num = -1
+ r = ['',gpio_num,'']
if (System.GPIO_CONFIG.has_key(name) == False):
# TODO: Error handling
print "ERROR: "+name+" not found in GPIO config table"
- return ['',0,'']
else:
- gpio_num = System.GPIO_CONFIG[name]['gpio_num']
-
- return [Openbmc.GPIO_DEV, gpio_num, System.GPIO_CONFIG[name]['direction']]
-
+
+ gpio_num = -1
+ gpio = System.GPIO_CONFIG[name]
+ if (System.GPIO_CONFIG[name].has_key('gpio_num')):
+ gpio_num = gpio['gpio_num']
+ else:
+ if (System.GPIO_CONFIG[name].has_key('gpio_pin')):
+ gpio_num = System.convertGpio(gpio['gpio_pin'])
+ else:
+ print "ERROR: SystemManager - GPIO lookup failed for "+name
+
+ if (gpio_num != -1):
+ r = [Openbmc.GPIO_DEV, gpio_num, gpio['direction']]
+ return r
if __name__ == '__main__':
diff --git a/includes/gpio.c b/includes/gpio.c
index 51c2b82..6fed039 100644
--- a/includes/gpio.c
+++ b/includes/gpio.c
@@ -183,16 +183,17 @@
int gpio_open_interrupt(GPIO* gpio, GIOFunc func, gpointer user_data)
{
int rc = GPIO_OK;
- char* buf;
+ char buf[255];
sprintf(buf, "%s/gpio%d/value", gpio->dev, gpio->num);
gpio->fd = open(buf, O_RDONLY | O_NONBLOCK );
+ gpio->irq_inited = false;
if (gpio->fd == -1)
{
rc = GPIO_OPEN_ERROR;
}
else
{
- GIOChannel* channel = g_io_channel_unix_new( gpio->fd );
+ GIOChannel* channel = g_io_channel_unix_new( gpio->fd);
guint id = g_io_add_watch( channel, G_IO_PRI, func, user_data );
}
return rc;
diff --git a/includes/gpio.h b/includes/gpio.h
index d9279e4..6983e77 100644
--- a/includes/gpio.h
+++ b/includes/gpio.h
@@ -3,6 +3,7 @@
#include <stdint.h>
#include <gio/gio.h>
+#include <stdbool.h>
typedef struct {
gchar* name;
@@ -10,6 +11,7 @@
uint16_t num;
gchar* direction;
int fd;
+ bool irq_inited;
} GPIO;
diff --git a/includes/openbmc.h b/includes/openbmc.h
index ca44fb7..d0882c3 100644
--- a/includes/openbmc.h
+++ b/includes/openbmc.h
@@ -40,7 +40,8 @@
typedef struct {
gint argc;
gchar **argv;
- GMainLoop *loop;
+ GMainLoop *loop;
+ gpointer user_data;
} cmdline;
diff --git a/objects/button_power_obj.c b/objects/button_power_obj.c
index 30078bb..93005a1 100644
--- a/objects/button_power_obj.c
+++ b/objects/button_power_obj.c
@@ -5,6 +5,7 @@
/* ---------------------------------------------------------------------------------------------------- */
static const gchar* dbus_object_path = "/org/openbmc/buttons";
+static const gchar* instance_name = "power0";
static const gchar* dbus_name = "org.openbmc.buttons.Power";
static GDBusObjectManagerServer *manager = NULL;
@@ -37,9 +38,34 @@
GIOCondition condition,
gpointer user_data )
{
- Button* button = object_get_button((Object*)user_data);
- printf("Power Button pressed\n");
- button_emit_button_pressed(button);
+
+ GError *error = 0;
+ gsize bytes_read = 0;
+ gchar buf[2];
+ buf[1] = '\0';
+ g_io_channel_seek_position( channel, 0, G_SEEK_SET, 0 );
+ GIOStatus rc = g_io_channel_read_chars( channel,
+ buf, 1,
+ &bytes_read,
+ &error );
+ printf("%s\n",buf);
+
+ if (gpio_button.irq_inited)
+ {
+ Button* button = object_get_button((Object*)user_data);
+ if (buf[0] == '0')
+ {
+ printf("Power Button pressed\n");
+ button_emit_button_pressed(button);
+ }
+ else
+ {
+ printf("Power Button released\n");
+ }
+ }
+ else { gpio_button.irq_inited = true; }
+
+ return TRUE;
}
static void
@@ -50,15 +76,10 @@
ObjectSkeleton *object;
//g_print ("Acquired a message bus connection: %s\n",name);
cmdline *cmd = user_data;
- if (cmd->argc < 2)
- {
- g_print("No objects created. Put object name(s) on command line\n");
- return;
- }
manager = g_dbus_object_manager_server_new (dbus_object_path);
int i=0;
gchar *s;
- s = g_strdup_printf ("%s/%s",dbus_object_path,cmd->argv[1]);
+ s = g_strdup_printf ("%s/%s",dbus_object_path,instance_name);
object = object_skeleton_new (s);
g_free (s);
diff --git a/objects/control_bmc_barreleye.c b/objects/control_bmc_barreleye.c
index 0e6c5cb..a3a19e8 100644
--- a/objects/control_bmc_barreleye.c
+++ b/objects/control_bmc_barreleye.c
@@ -12,6 +12,7 @@
/* ---------------------------------------------------------------------------------------------------- */
static const gchar* dbus_object_path = "/org/openbmc/control";
+static const gchar* instance_name = "bmc0";
static const gchar* dbus_name = "org.openbmc.control.Bmc";
//this probably should come from some global SOC config
@@ -23,7 +24,6 @@
#define SPI_BASE (off_t)0x1e630000
#define SCU_BASE (off_t)0x1e780000
#define UART_BASE (off_t)0x1e783000
-#define UART_BASE2 (off_t)0x1e785000
#define COM_BASE (off_t)0x1e789000
#define COM_BASE2 (off_t)0x1e789100
#define GPIO_BASE (off_t)0x1e6e2000
@@ -72,11 +72,6 @@
devmem(bmcreg+0x00,0x00000000); //Set Baud rate divisor -> 13 (Baud 115200)
devmem(bmcreg+0x04,0x00000000); //Set Baud rate divisor -> 13 (Baud 115200)
devmem(bmcreg+0x08,0x000000c1); //Disable Parity, 1 stop bit, 8 bits
-
- bmcreg = memmap(mem_fd,UART_BASE2);
- devmem(bmcreg+0x0c,0x00000000);
- devmem(bmcreg+0x2c,0x00000000);
-
bmcreg = memmap(mem_fd,COM_BASE);
devmem(bmcreg+0x9C,0x08060000); //Set UART routing
@@ -103,7 +98,6 @@
devmem(bmcreg+0x170,0x00000042);
devmem(bmcreg+0x174,0x00004000);
-
close(mem_fd);
}
@@ -112,13 +106,25 @@
GDBusMethodInvocation *invocation,
gpointer user_data)
{
+ //#ifdef __arm__
+ //reg_init();
+ //#endif
+ control_complete_init(control,invocation);
+ //control_emit_goto_system_state(control,"BMC_STARTING");
+
+ return TRUE;
+}
+gboolean go(gpointer user_data)
+{
+ cmdline *cmd = user_data;
+ Control* control = object_get_control((Object*)cmd->user_data);
#ifdef __arm__
reg_init();
#endif
- control_complete_init(control,invocation);
control_emit_goto_system_state(control,"BMC_STARTING");
- return TRUE;
+ //g_main_loop_quit(cmd->loop);
+ return FALSE;
}
static void
@@ -128,47 +134,48 @@
{
ObjectSkeleton *object;
cmdline *cmd = user_data;
- if (cmd->argc < 2)
- {
- g_print("No objects created. Put object name(s) on command line\n");
- return;
- }
manager = g_dbus_object_manager_server_new (dbus_object_path);
- int i=0;
- for (i=1;i<cmd->argc;i++)
- {
- gchar *s;
- s = g_strdup_printf ("%s/%s",dbus_object_path,cmd->argv[i]);
- object = object_skeleton_new (s);
- g_free (s);
- ControlBmc* control_bmc = control_bmc_skeleton_new ();
- object_skeleton_set_control_bmc (object, control_bmc);
- g_object_unref (control_bmc);
+ gchar *s;
+ s = g_strdup_printf ("%s/%s",dbus_object_path,instance_name);
+ object = object_skeleton_new (s);
+ g_free (s);
- Control* control = control_skeleton_new ();
- object_skeleton_set_control (object, control);
- g_object_unref (control);
+ ControlBmc* control_bmc = control_bmc_skeleton_new ();
+ object_skeleton_set_control_bmc (object, control_bmc);
+ g_object_unref (control_bmc);
- //define method callbacks here
- g_signal_connect (control,
- "handle-init",
- G_CALLBACK (on_init),
- NULL); /* user_data */
+ Control* control = control_skeleton_new ();
+ object_skeleton_set_control (object, control);
+ g_object_unref (control);
- /* Export the object (@manager takes its own reference to @object) */
- g_dbus_object_manager_server_export (manager, G_DBUS_OBJECT_SKELETON (object));
- g_object_unref (object);
- }
+ //define method callbacks here
+ g_signal_connect (control,
+ "handle-init",
+ G_CALLBACK (on_init),
+ NULL); /* user_data */
+
+ /* Export the object (@manager takes its own reference to @object) */
+ g_dbus_object_manager_server_export (manager, G_DBUS_OBJECT_SKELETON (object));
+ g_object_unref (object);
+
/* Export all objects */
g_dbus_object_manager_server_set_connection (manager, connection);
+
+ //TODO: This is a bad hack to wait for object to be on bus
+ //sleep(1);
+ cmd->user_data = object;
+ g_idle_add(go,cmd);
}
+
static void
on_name_acquired (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
+
+
}
static void
@@ -179,8 +186,6 @@
}
-
-
/*----------------------------------------------------------------*/
/* Main Event Loop */
@@ -194,6 +199,7 @@
guint id;
loop = g_main_loop_new (NULL, FALSE);
+ cmd.loop = loop;
id = g_bus_own_name (DBUS_TYPE,
dbus_name,
diff --git a/objects/control_bmc_obj.c b/objects/control_bmc_obj.c
index 2aedd04..9a7fd5f 100644
--- a/objects/control_bmc_obj.c
+++ b/objects/control_bmc_obj.c
@@ -12,6 +12,7 @@
/* ---------------------------------------------------------------------------------------------------- */
static const gchar* dbus_object_path = "/org/openbmc/control";
+static const gchar* instance_name = "bmc0";
static const gchar* dbus_name = "org.openbmc.control.Bmc";
//this probably should come from some global SOC config
@@ -103,13 +104,25 @@
GDBusMethodInvocation *invocation,
gpointer user_data)
{
+ //#ifdef __arm__
+ //reg_init();
+ //#endif
+ control_complete_init(control,invocation);
+ //control_emit_goto_system_state(control,"BMC_STARTING");
+
+ return TRUE;
+}
+gboolean go(gpointer user_data)
+{
+ cmdline *cmd = user_data;
+ Control* control = object_get_control((Object*)cmd->user_data);
#ifdef __arm__
reg_init();
#endif
- control_complete_init(control,invocation);
control_emit_goto_system_state(control,"BMC_STARTING");
-
- return TRUE;
+
+ //g_main_loop_quit(cmd->loop);
+ return FALSE;
}
static void
@@ -119,47 +132,48 @@
{
ObjectSkeleton *object;
cmdline *cmd = user_data;
- if (cmd->argc < 2)
- {
- g_print("No objects created. Put object name(s) on command line\n");
- return;
- }
manager = g_dbus_object_manager_server_new (dbus_object_path);
- int i=0;
- for (i=1;i<cmd->argc;i++)
- {
- gchar *s;
- s = g_strdup_printf ("%s/%s",dbus_object_path,cmd->argv[i]);
- object = object_skeleton_new (s);
- g_free (s);
- ControlBmc* control_bmc = control_bmc_skeleton_new ();
- object_skeleton_set_control_bmc (object, control_bmc);
- g_object_unref (control_bmc);
+ gchar *s;
+ s = g_strdup_printf ("%s/%s",dbus_object_path,instance_name);
+ object = object_skeleton_new (s);
+ g_free (s);
- Control* control = control_skeleton_new ();
- object_skeleton_set_control (object, control);
- g_object_unref (control);
+ ControlBmc* control_bmc = control_bmc_skeleton_new ();
+ object_skeleton_set_control_bmc (object, control_bmc);
+ g_object_unref (control_bmc);
- //define method callbacks here
- g_signal_connect (control,
- "handle-init",
- G_CALLBACK (on_init),
- NULL); /* user_data */
+ Control* control = control_skeleton_new ();
+ object_skeleton_set_control (object, control);
+ g_object_unref (control);
- /* Export the object (@manager takes its own reference to @object) */
- g_dbus_object_manager_server_export (manager, G_DBUS_OBJECT_SKELETON (object));
- g_object_unref (object);
- }
+ //define method callbacks here
+ g_signal_connect (control,
+ "handle-init",
+ G_CALLBACK (on_init),
+ NULL); /* user_data */
+
+ /* Export the object (@manager takes its own reference to @object) */
+ g_dbus_object_manager_server_export (manager, G_DBUS_OBJECT_SKELETON (object));
+ g_object_unref (object);
+
/* Export all objects */
g_dbus_object_manager_server_set_connection (manager, connection);
+
+ //TODO: This is a bad hack to wait for object to be on bus
+ //sleep(1);
+ cmd->user_data = object;
+ g_idle_add(go,cmd);
}
+
static void
on_name_acquired (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
+
+
}
static void
@@ -170,8 +184,6 @@
}
-
-
/*----------------------------------------------------------------*/
/* Main Event Loop */
@@ -185,6 +197,7 @@
guint id;
loop = g_main_loop_new (NULL, FALSE);
+ cmd.loop = loop;
id = g_bus_own_name (DBUS_TYPE,
dbus_name,
diff --git a/objects/control_host_obj.c b/objects/control_host_obj.c
index d051f88..63a8d64 100644
--- a/objects/control_host_obj.c
+++ b/objects/control_host_obj.c
@@ -12,6 +12,7 @@
/* ---------------------------------------------------------------------------------------------------- */
static const gchar* dbus_object_path = "/org/openbmc/control";
+static const gchar* instance_name = "host0";
static const gchar* dbus_name = "org.openbmc.control.Host";
static GDBusObjectManagerServer *manager = NULL;
@@ -105,17 +106,10 @@
ObjectSkeleton *object;
//g_print ("Acquired a message bus connection: %s\n",name);
cmdline *cmd = user_data;
- if (cmd->argc < 2)
- {
- g_print("No objects created. Put object name(s) on command line\n");
- return;
- }
manager = g_dbus_object_manager_server_new (dbus_object_path);
- int i=0;
- for (i=1;i<cmd->argc;i++)
- {
+
gchar *s;
- s = g_strdup_printf ("%s/%s",dbus_object_path,cmd->argv[i]);
+ s = g_strdup_printf ("%s/%s",dbus_object_path,instance_name);
object = object_skeleton_new (s);
g_free (s);
ControlHost* control_host = control_host_skeleton_new ();
@@ -140,7 +134,7 @@
/* Export the object (@manager takes its own reference to @object) */
g_dbus_object_manager_server_export (manager, G_DBUS_OBJECT_SKELETON (object));
g_object_unref (object);
- }
+
/* Export all objects */
g_dbus_object_manager_server_set_connection (manager, connection);
diff --git a/objects/flash_bios_obj.c b/objects/flash_bios_obj.c
index a3f3d03..4b82d67 100644
--- a/objects/flash_bios_obj.c
+++ b/objects/flash_bios_obj.c
@@ -47,6 +47,9 @@
{
printf("ERROR FlashControl: Unable to init\n");
}
+ //TODO: have to tune flash twice
+ sleep(1);
+ update(f,obj_path);
}
return TRUE;
}
@@ -288,8 +291,8 @@
c--;
}
- const char* inst[] = {"bios","bmc"};
- for (i=0;i<2;i++)
+ const char* inst[] = {"bios","bmc","bmc_ramdisk","bmc_kernel"};
+ for (i=0;i<4;i++)
{
gchar* s;
s = g_strdup_printf ("%s/%s",dbus_object_path,inst[i]);
diff --git a/objects/flasher_obj.c b/objects/flasher_obj.c
index 53d62fd..26bf441 100644
--- a/objects/flasher_obj.c
+++ b/objects/flasher_obj.c
@@ -53,6 +53,7 @@
static uint8_t FLASH_OK = 0;
static uint8_t FLASH_ERROR = 1;
+static struct blocklevel_device *bl;
static int erase_chip(void)
{
@@ -71,6 +72,7 @@
return (rc);
}
+
void flash_message(GDBusConnection* connection,char* obj_path,char* method, char* error_msg)
{
GDBusProxy *proxy;
@@ -296,13 +298,13 @@
atexit(flash_access_cleanup_pnor);
}
-uint8_t flash(FlashControl* flash_control,bool bmc_flash, char* write_file, char* obj_path)
+uint8_t flash(FlashControl* flash_control,bool bmc_flash, uint32_t address, char* write_file, char* obj_path)
{
bool has_sfc = false, has_ast = false, use_lpc = true;
bool erase = true, program = true;
- uint32_t address = 0;
+
int rc;
- printf("flasher: %s, BMC = %d\n",write_file,bmc_flash);
+ printf("flasher: %s, BMC = %d, address = 0x%x\n",write_file,bmc_flash,address);
#ifdef __arm__
/* Check platform */
check_platform(&has_sfc, &has_ast);
@@ -390,10 +392,20 @@
/* Export all objects */
g_dbus_object_manager_server_set_connection (manager, connection);
bool bmc_flash = false;
+ uint32_t address = 0;
if (strcmp(cmd->argv[1],"bmc")==0) {
bmc_flash = true;
}
- int rc = flash(flash_control,bmc_flash,cmd->argv[2],cmd->argv[3]);
+ if (strcmp(cmd->argv[1],"bmc_ramdisk")==0) {
+ bmc_flash = true;
+ address = 0x20300000;
+ }
+ if (strcmp(cmd->argv[1],"bmc_kernel")==0) {
+ bmc_flash = true;
+ address = 0x20080000;
+ }
+
+ int rc = flash(flash_control,bmc_flash,address,cmd->argv[2],cmd->argv[3]);
if (rc == FLASH_ERROR) {
flash_message(connection,cmd->argv[3],"error","Flash Error");
} else {
diff --git a/objects/host_watchdog_obj.c b/objects/host_watchdog_obj.c
index b1c8f2b..13208e2 100644
--- a/objects/host_watchdog_obj.c
+++ b/objects/host_watchdog_obj.c
@@ -5,6 +5,7 @@
/* ---------------------------------------------------------------------------------------------------- */
static const gchar* dbus_object_path = "/org/openbmc/watchdog";
+static const gchar* instance_name = "host0";
static const gchar* dbus_name = "org.openbmc.watchdog.Host";
static GDBusObjectManagerServer *manager = NULL;
@@ -87,20 +88,10 @@
const gchar *name,
gpointer user_data)
{
- // g_print ("Acquired a message bus connection: %s\n",name);
-
cmdline *cmd = user_data;
- if (cmd->argc < 2)
- {
- g_print("No objects created. Put object name(s) on command line\n");
- return;
- }
manager = g_dbus_object_manager_server_new (dbus_object_path);
- int i=0;
- for (i=1;i<cmd->argc;i++)
- {
gchar *s;
- s = g_strdup_printf ("%s/%s",dbus_object_path,cmd->argv[i]);
+ s = g_strdup_printf ("%s/%s",dbus_object_path,instance_name);
ObjectSkeleton *object = object_skeleton_new (s);
g_free (s);
@@ -135,7 +126,6 @@
/* Export the object (@manager takes its own reference to @object) */
g_dbus_object_manager_server_export (manager, G_DBUS_OBJECT_SKELETON (object));
g_object_unref (object);
- }
/* Export all objects */
g_dbus_object_manager_server_set_connection (manager, connection);
diff --git a/objects/led_controller.c b/objects/led_controller.c
index b4cd04d..29698fe 100644
--- a/objects/led_controller.c
+++ b/objects/led_controller.c
@@ -22,14 +22,14 @@
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- printf("Turn on chassis identify led\n");
GPIO* mygpio = (GPIO*)user_data;
+ g_print("Turn on LED: %s\n",mygpio->name);
led_complete_set_on(led,invocation);
int rc = GPIO_OK;
do {
rc = gpio_open(mygpio);
if (rc != GPIO_OK) { break; }
- rc = gpio_write(mygpio,1);
+ rc = gpio_write(mygpio,0);
if (rc != GPIO_OK) { break; }
} while(0);
gpio_close(mygpio);
@@ -47,14 +47,14 @@
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- g_print("Turn off chassis identify led\n");
GPIO* mygpio = (GPIO*)user_data;
+ g_print("Turn off LED: %s\n",mygpio->name);
led_complete_set_off(led,invocation);
int rc = GPIO_OK;
do {
rc = gpio_open(mygpio);
if (rc != GPIO_OK) { break; }
- rc = gpio_write(mygpio,0);
+ rc = gpio_write(mygpio,1);
if (rc != GPIO_OK) { break; }
} while(0);
gpio_close(mygpio);
@@ -73,11 +73,6 @@
ObjectSkeleton *object;
cmdline *cmd = user_data;
- if (cmd->argc < 2)
- {
- g_print("No objects created. Put object name(s) on command line\n");
- return;
- }
manager = g_dbus_object_manager_server_new (dbus_object_path);
int i = 0;
diff --git a/objects/power_control_obj.c b/objects/power_control_obj.c
index bdb7c9a..97d1021 100644
--- a/objects/power_control_obj.c
+++ b/objects/power_control_obj.c
@@ -13,6 +13,7 @@
/* ---------------------------------------------------------------------------------------------------- */
static const gchar* dbus_object_path = "/org/openbmc/control";
+static const gchar* instance_name = "power0";
static const gchar* dbus_name = "org.openbmc.control.Power";
//This object will use these GPIOs
@@ -145,8 +146,8 @@
gpointer user_data)
{
pgood_timeout_start = 0;
- guint poll_interval = control_get_poll_interval(control);
- g_timeout_add(poll_interval, poll_pgood, user_data);
+ //guint poll_interval = control_get_poll_interval(control);
+ //g_timeout_add(poll_interval, poll_pgood, user_data);
control_complete_init(control,invocation);
return TRUE;
}
@@ -168,14 +169,14 @@
{
ObjectSkeleton *object;
cmdline *cmd = user_data;
- if (cmd->argc < 2)
+ if (cmd->argc < 3)
{
- g_print("No objects created. Put object name(s) on command line\n");
+ g_print("Usage: power_control.exe [poll interval] [timeout]\n");
return;
}
manager = g_dbus_object_manager_server_new (dbus_object_path);
gchar *s;
- s = g_strdup_printf ("%s/%s",dbus_object_path,cmd->argv[1]);
+ s = g_strdup_printf ("%s/%s",dbus_object_path,instance_name);
object = object_skeleton_new (s);
g_free (s);
@@ -230,7 +231,19 @@
if (rc != GPIO_OK)
{
printf("ERROR PowerControl: GPIO setup (rc=%d)\n",rc);
- }
+ }
+ //start poll
+ pgood_timeout_start = 0;
+ int poll_interval = atoi(cmd->argv[1]);
+ int pgood_timeout = atoi(cmd->argv[2]);
+ if (poll_interval < 1000 || pgood_timeout <5) {
+ printf("ERROR PowerControl: poll_interval < 1000 or pgood_timeout < 5\n");
+ } else {
+ control_set_poll_interval(control,poll_interval);
+ control_power_set_pgood_timeout(control_power,pgood_timeout);
+ g_timeout_add(poll_interval, poll_pgood, object);
+ }
+
}
static void
diff --git a/objects/sensor_temperature_ambient_obj.c b/objects/sensor_temperature_ambient_obj.c
deleted file mode 100644
index eb8fe8c..0000000
--- a/objects/sensor_temperature_ambient_obj.c
+++ /dev/null
@@ -1,187 +0,0 @@
-#include "interfaces/openbmc_intf.h"
-#include "openbmc.h"
-#include "sensor_threshold.h"
-
-
-/* ---------------------------------------------------------------------------------------------------- */
-
-static const gchar* dbus_object_path = "/org/openbmc/sensors";
-static const gchar* dbus_name = "org.openbmc.sensors.Temperature.Ambient";
-static guint heartbeat = 0;
-
-static GDBusObjectManagerServer *manager = NULL;
-
-static gboolean
-poll_sensor(gpointer user_data)
-{
- SensorValue *sensor = object_get_sensor_value((Object*)user_data);
- SensorThreshold *threshold = object_get_sensor_threshold((Object*)user_data);
- SensorI2c *i2c = object_get_sensor_i2c((Object*)user_data);
-
- GVariant* v_value = sensor_value_get_value(sensor);
- guint poll_interval = sensor_value_get_poll_interval(sensor);
-
- //TODO: Change to actually read sensor
- double value = GET_VARIANT_D(v_value);
- //g_print("Reading I2C = %s; Address = %s; %f\n",
- // sensor_i2c_get_dev_path(i2c),sensor_i2c_get_address(i2c),value);
-
- value = value+1;
- // Do this in case of an error
- //sensor_value_emit_error(sensor);
-
- if (heartbeat > 4000)
- {
- heartbeat = 0;
- sensor_value_emit_heartbeat(sensor,dbus_name);
- }
- else
- {
- heartbeat = heartbeat+poll_interval;
- }
-
- // End actually reading sensor
-
- //if changed, set property and emit signal
- if (value != GET_VARIANT_D(v_value))
- {
- GVariant* v_new_value = NEW_VARIANT_D(value);
- sensor_value_set_value(sensor,v_new_value);
- const gchar* units = sensor_value_get_units(sensor);
- sensor_value_emit_changed(sensor,v_new_value,units);
- check_thresholds(threshold,v_new_value);
- }
- return TRUE;
-}
-
-static gboolean
-on_init (SensorValue *sen,
- GDBusMethodInvocation *invocation,
- gpointer user_data)
-{
-
- guint poll_interval = sensor_value_get_poll_interval(sen);
- g_timeout_add(poll_interval, poll_sensor, user_data);
- sensor_value_complete_init(sen,invocation);
- return TRUE;
-}
-
-
-
-static void
-on_bus_acquired (GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
-{
- // g_print ("Acquired a message bus connection: %s\n",name);
-
- cmdline *cmd = user_data;
- if (cmd->argc < 2)
- {
- g_print("No objects created. Put object name(s) on command line\n");
- return;
- }
- manager = g_dbus_object_manager_server_new (dbus_object_path);
- int i=0;
- for (i=1;i<cmd->argc;i++)
- {
- gchar *s;
- s = g_strdup_printf ("%s/Temperature/%s",dbus_object_path,cmd->argv[i]);
- ObjectSkeleton *object = object_skeleton_new (s);
- g_free (s);
-
- SensorValue *sensor = sensor_value_skeleton_new ();
- object_skeleton_set_sensor_value (object, sensor);
- g_object_unref (sensor);
-
- SensorThreshold *threshold = sensor_threshold_skeleton_new();
- object_skeleton_set_sensor_threshold (object,threshold);
- g_object_unref (threshold);
-
- SensorI2c *i2c = sensor_i2c_skeleton_new();
- object_skeleton_set_sensor_i2c (object,i2c);
- g_object_unref (i2c);
-
-
- // set properties
- GVariant* value = g_variant_new_variant(g_variant_new_double(1.0));
- sensor_value_set_value(sensor,value);
- sensor_value_set_units(sensor,"C");
- sensor_value_set_settable(sensor,FALSE);
- sensor_threshold_set_state(threshold,NOT_SET);
-
- sensor_threshold_set_upper_critical(threshold,
- g_variant_new_variant(g_variant_new_double(0.0)));
- sensor_threshold_set_upper_warning(threshold,
- g_variant_new_variant(g_variant_new_double(0.0)));
- sensor_threshold_set_lower_warning(threshold,
- g_variant_new_variant(g_variant_new_double(0.0)));
- sensor_threshold_set_lower_critical(threshold,
- g_variant_new_variant(g_variant_new_double(0.0)));
-
- //define method callbacks here
-
- g_signal_connect (sensor,
- "handle-init",
- G_CALLBACK (on_init),
- object); /* user_data */
-
- g_signal_connect (threshold,
- "handle-get-state",
- G_CALLBACK (get_threshold_state),
- NULL); /* user_data */
-
-
-
- /* Export the object (@manager takes its own reference to @object) */
- g_dbus_object_manager_server_export (manager, G_DBUS_OBJECT_SKELETON (object));
- g_object_unref (object);
- }
-
- /* Export all objects */
- g_dbus_object_manager_server_set_connection (manager, connection);
-}
-
-static void
-on_name_acquired (GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
-{
-// g_print ("Acquired the name %s\n", name);
-}
-
-static void
-on_name_lost (GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
-{
-// g_print ("Lost the name %s\n", name);
-}
-
-
-gint
-main (gint argc, gchar *argv[])
-{
- GMainLoop *loop;
- cmdline cmd;
- cmd.argc = argc;
- cmd.argv = argv;
- guint id;
- loop = g_main_loop_new (NULL, FALSE);
-
- id = g_bus_own_name (DBUS_TYPE,
- dbus_name,
- G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
- G_BUS_NAME_OWNER_FLAGS_REPLACE,
- on_bus_acquired,
- on_name_acquired,
- on_name_lost,
- &cmd,
- NULL);
-
- g_main_loop_run (loop);
-
- g_bus_unown_name (id);
- g_main_loop_unref (loop);
- return 0;
-}