Merge pull request #7 from anoo1/watchdogpoweron
Start watchdog with 30s timeout on poweron
diff --git a/Makefile b/Makefile
index b7f0053..b11c405 100644
--- a/Makefile
+++ b/Makefile
@@ -58,8 +58,8 @@
control_bmc: control_bmc_obj.o libopenbmc_intf
$(CC) -o bin/$@.exe obj/control_bmc_obj.o $(LDFLAGS) $(LIBS)
-sensor_occ: sensor_occ_obj.o libopenbmc_intf
- $(CC) -o bin/$@.exe obj/sensor_occ_obj.o $(LDFLAGS) $(LIBS)
+control_bmc_barreleye: control_bmc_barreleye.o libopenbmc_intf
+ $(CC) -o bin/$@.exe obj/control_bmc_barreleye.o $(LDFLAGS) $(LIBS)
board_vpd: board_vpd_obj.o libopenbmc_intf
$(CC) -o bin/$@.exe obj/board_vpd_obj.o $(LDFLAGS) $(LIBS)
diff --git a/bin/Barreleye.py b/bin/Barreleye.py
index 901fcfc..9f9ba03 100755
--- a/bin/Barreleye.py
+++ b/bin/Barreleye.py
@@ -4,70 +4,100 @@
import Openbmc
HOME_PATH = './'
-BIN_PATH = HOME_PATH+'bin/'
CACHE_PATH = HOME_PATH+'cache/'
FRU_PATH = CACHE_PATH+'frus/'
+FLASH_DOWNLOAD_PATH = "/tmp"
+SYSTEM_NAME = "Barreleye"
+
+
+## System states
+## state can change to next state in 2 ways:
+## - a process emits a GotoSystemState signal with state name to goto
+## - objects specified in EXIT_STATE_DEPEND have started
SYSTEM_STATES = [
- 'INIT',
- 'STANDBY',
- 'POWERING_ON',
- 'POWERED_ON',
- 'BOOTING',
+ 'BMC_INIT',
+ 'BMC_STARTING',
+ 'BMC_READY',
+ 'HOST_POWERING_ON',
+ 'HOST_POWERED_ON',
+ 'HOST_BOOTING',
'HOST_UP',
- 'SHUTTING_DOWN',
- 'POWERING_DOWN'
+ 'HOST_POWERED_DOWN',
]
+EXIT_STATE_DEPEND = {
+ '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,
+ }
+}
+
+## method will be called when state is entered
ENTER_STATE_CALLBACK = {
- 'POWERED_ON' : {
+ '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'
+ },
+ 'BMC_READY' : {
+ 'bus_name' : 'org.openbmc.control.led',
+ 'obj_name' : '/org/openbmc/control/led/BMC_READY',
+ 'interface_name' : 'org.openbmc.Led',
+ 'method_name' : 'setOn'
}
}
SYSTEM_CONFIG = {}
SYSTEM_CONFIG['org.openbmc.control.Bmc'] = {
- 'system_state' : 'INIT',
+ 'system_state' : 'BMC_INIT',
'start_process' : True,
'monitor_process' : True,
- 'process_name' : 'control_bmc.exe',
+ 'process_name' : 'control_bmc_barreleye.exe',
'heartbeat' : 'no',
'instances' : [ { 'name' : 'Bmc_0' } ]
}
SYSTEM_CONFIG['org.openbmc.managers.Inventory'] = {
- 'system_state' : 'STANDBY',
+ 'system_state' : 'BMC_STARTING',
'start_process' : True,
'monitor_process' : True,
'process_name' : 'inventory_items.py',
'heartbeat' : 'no',
- 'instances' : [ { 'name' : 'Barreleye' } ]
+ 'instances' : [ { 'name' : SYSTEM_NAME } ]
}
SYSTEM_CONFIG['org.openbmc.control.PciePresent'] = {
- 'system_state' : 'POWERING_ON',
+ 'system_state' : 'HOST_POWERED_ON',
'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,
+ 'monitor_process' : True,
+ 'process_name' : 'sensors_virtual_p8.py',
+ 'heartbeat' : 'no',
+ 'instances' : [ { 'name' : 'virtual' } ]
+ }
SYSTEM_CONFIG['org.openbmc.managers.Sensors'] = {
- 'system_state' : 'STANDBY',
+ 'system_state' : 'BMC_STARTING',
'start_process' : True,
'monitor_process' : True,
'process_name' : 'sensor_manager.py',
'heartbeat' : 'no',
- 'instances' : [ { 'name' : 'Barreleye' } ]
+ 'instances' : [ { 'name' : SYSTEM_NAME } ]
}
SYSTEM_CONFIG['org.openbmc.watchdog.Host'] = {
- 'system_state' : 'STANDBY',
+ 'system_state' : 'BMC_STARTING',
'start_process' : True,
'monitor_process' : True,
'process_name' : 'host_watchdog.exe',
@@ -77,7 +107,7 @@
'name' : 'HostWatchdog_0',
'properties' : {
'org.openbmc.Watchdog' : {
- 'poll_interval': 3000,
+ 'poll_interval': 30000,
}
}
}
@@ -85,14 +115,14 @@
}
SYSTEM_CONFIG['org.openbmc.control.Power'] = {
- 'system_state' : 'STANDBY',
+ 'system_state' : 'BMC_STARTING',
'start_process' : True,
'monitor_process' : True,
'process_name' : 'power_control.exe',
- 'heartbeat' : 'yes',
+ 'heartbeat' : 'no',
'instances' : [
{
- 'name' : 'SystemPower_0',
+ 'name' : 'power0',
'user_label': 'Power control',
'properties' : {
'org.openbmc.Control': {
@@ -106,78 +136,42 @@
]
}
-SYSTEM_CONFIG['org.openbmc.sensors.Temperature.Ambient'] = {
- 'system_state' : 'STANDBY',
- 'start_process' : True,
- 'monitor_process' : True,
- 'process_name' : 'sensor_ambient.exe',
- 'heartbeat' : 'yes',
- 'instances' : [
- {
- 'name' : 'FrontChassis',
- 'user_label': 'Ambient Temperature 1',
- 'properties' : {
- 'org.openbmc.SensorValue': {
- 'poll_interval' : 5000,
- },
- 'org.openbmc.SensorThreshold' : {
- 'lower_critical': 5,
- 'lower_warning' : 10,
- 'upper_warning' : 15,
- 'upper_critical': 20
- },
- 'org.openbmc.SensorI2c' : {
- 'dev_path' : '/dev/i2c/i2c0',
- 'address' : '0xA0'
- }
- }
- },
- ]
- }
SYSTEM_CONFIG['org.openbmc.buttons.Power'] = {
- 'system_state' : 'STANDBY',
+ '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.sensors.HostStatus'] = {
- 'system_state' : 'STANDBY',
+SYSTEM_CONFIG['org.openbmc.control.led'] = {
+ 'system_state' : 'BMC_STARTING',
'start_process' : True,
'monitor_process' : True,
- 'process_name' : 'sensor_host_status.exe',
- 'heartbeat' : "no",
- 'instances' : [ { 'name' : 'HostStatus_0' } ]
- }
-SYSTEM_CONFIG['org.openbmc.leds.ChassisIdentify'] = {
- 'system_state' : 'STANDBY',
- 'start_process' : True,
- 'monitor_process' : True,
- 'process_name' : 'chassis_identify.exe',
+ 'process_name' : 'led_controller.exe',
'heartbeat' : 'no',
- 'instances' : [ { 'name' : 'ChassisIdentify_0' } ]
+ 'instances' : [ { 'name' : 'Dummy' } ]
}
-SYSTEM_CONFIG['org.openbmc.flash.Bios'] = {
- 'system_state' : 'STANDBY',
- 'start_process' : False,
+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' : 'BIOS_0' } ]
+ 'instances' : [ { 'name' : 'dummy' } ]
}
-SYSTEM_CONFIG['org.openbmc.manager.Flash'] = {
- 'system_state' : 'STANDBY',
+SYSTEM_CONFIG['org.openbmc.manager.Download'] = {
+ 'system_state' : 'BMC_STARTING',
'start_process' : True,
'monitor_process' : True,
- 'process_name' : 'flash_manager.py',
+ 'process_name' : 'download_manager.py',
'heartbeat' : 'no',
- 'instances' : [ { 'name' : 'FlashManager_0' } ]
+ 'instances' : [ { 'name' : SYSTEM_NAME } ]
}
SYSTEM_CONFIG['org.openbmc.control.Host'] = {
- 'system_state' : 'STANDBY',
+ 'system_state' : 'BMC_STARTING',
'start_process' : True,
'monitor_process' : True,
'process_name' : 'control_host.exe',
@@ -185,44 +179,25 @@
'instances' : [ { 'name' : 'Host_0' } ]
}
SYSTEM_CONFIG['org.openbmc.control.Chassis'] = {
- 'system_state' : 'STANDBY',
+ 'system_state' : 'BMC_STARTING',
'start_process' : True,
'monitor_process' : True,
'process_name' : 'chassis_control.py',
'heartbeat' : 'no',
- 'instances' : [ { 'name' : 'Chassis' } ]
+ 'instances' : [ { 'name' : 'chassis0' } ]
}
SYSTEM_CONFIG['org.openbmc.vpd'] = {
- 'system_state' : 'POWERING_ON',
- 'start_process' : True,
+ 'system_state' : 'HOST_POWERED_ON',
+ 'start_process' : False,
'monitor_process' : False,
'process_name' : 'board_vpd.exe',
'heartbeat' : 'no',
'instances' : [ { 'name' : 'MBVPD_0' } ]
}
-SYSTEM_CONFIG['org.openbmc.sensors.Occ'] = {
- 'system_state' : 'BOOTED',
- 'start_process' : True,
- 'monitor_process' : True,
- 'process_name' : 'sensor_occ.exe',
- 'heartbeat' : 'no',
- 'instances' : [
- {
- 'name' : 'Occ_0',
- 'properties' : {
- 'org.openbmc.Occ' : {
- 'poll_interval' : 3000,
- }
- }
- },
-
- ]
- }
-
SYSTEM_CONFIG['org.openbmc.sensors.Fan'] = {
- 'system_state' : 'STANDBY',
+ 'system_state' : 'BMC_STARTING',
'start_process' : True,
'monitor_process' : True,
'process_name' : 'fan.exe',
@@ -237,163 +212,177 @@
'state' : True,
'cache' : True
}
-INVENTORY_ROOT = '/org/openbmc/inventory/items'
+INVENTORY_ROOT = '/org/openbmc/inventory'
FRU_INSTANCES = {
- '<inventory_root>/system' :
- {
- 'fru_type' : Openbmc.FRU_TYPES['SYSTEM'],
- 'is_fru' : True,
- },
- '<inventory_root>/system/io_board' :
- {
- 'fru_type' : Openbmc.FRU_TYPES['MAIN_PLANAR'],
- 'manufacturer' : 'FOXCONN',
- 'is_fru' : True,
- 'location' : 'C1',
- },
+ '<inventory_root>/system' : { 'fru_type' : 'SYSTEM','is_fru' : True, },
- '<inventory_root>/system/motherboard' :
- {
- 'fru_type' : Openbmc.FRU_TYPES['MAIN_PLANAR'],
- 'manufacturer' : 'FOXCONN',
- 'is_fru' : True,
- 'location' : 'C0',
- },
- '<inventory_root>/system/fan0' :
- {
- 'fru_type' : Openbmc.FRU_TYPES['FAN'],
- 'manufacturer' : 'DELTA',
- 'is_fru' : True,
- 'location' : 'F0',
- },
- '<inventory_root>/system/fan1' :
- {
- 'fru_type' : Openbmc.FRU_TYPES['FAN'],
- 'manufacturer' : 'DELTA',
- 'is_fru' : True,
- 'location' : 'F1',
- },
- '<inventory_root>/system/io_board/bmc' :
- {
- 'fru_type' : Openbmc.FRU_TYPES['BMC'],
- 'manufacturer' : 'ASPEED',
- 'is_fru' : False,
- },
- '<inventory_root>/system/motherboard/cpu0' :
- {
- 'fru_type' : Openbmc.FRU_TYPES['CPU'],
- 'manufacturer' : 'IBM',
- 'is_fru' : True,
- 'location' : 'P0',
- },
- '<inventory_root>/system/motherboard/cpu0/core0' :
- {
- 'fru_type' : Openbmc.FRU_TYPES['CORE'],
- 'is_fru' : False,
- },
- '<inventory_root>/system/motherboard/cpu0/core1' :
- {
- 'fru_type' : Openbmc.FRU_TYPES['CORE'],
- 'is_fru' : False,
- },
- '<inventory_root>/system/motherboard/dimm0' :
- {
- 'fru_type' : Openbmc.FRU_TYPES['DIMM'],
- 'is_fru' : True,
- },
- '<inventory_root>/system/motherboard/dimm1' :
- {
- 'fru_type' : Openbmc.FRU_TYPES['DIMM'],
- 'is_fru' : True,
- },
- '<inventory_root>/system/io_board/pcie_left_slot_riser' :
- {
- 'fru_type' : Openbmc.FRU_TYPES['RISER_CARD'],
- 'user_label' : 'Left Slot Riser',
- 'is_fru' : True,
- },
- '<inventory_root>/system/io_board/pcie_right_slot_riser' :
- {
- 'fru_type' : Openbmc.FRU_TYPES['RISER_CARD'],
- 'user_label' : 'Right Slot Riser',
- 'is_fru' : True,
- },
- '<inventory_root>/system/io_board/pcie_x16_slot_riser' :
- {
- 'fru_type' : Openbmc.FRU_TYPES['RISER_CARD'],
- 'user_label' : 'PCIE x16 Slot Riser',
- 'is_fru' : True,
- },
- '<inventory_root>/system/io_board/pcie_slot0' :
- {
- 'fru_type' : Openbmc.FRU_TYPES['PCIE_CARD'],
- 'user_label' : 'OCP Mezz card 0',
- 'is_fru' : True,
- },
- '<inventory_root>/system/io_board/pcie_slot1' :
- {
- 'fru_type' : Openbmc.FRU_TYPES['PCIE_CARD'],
- 'user_label' : 'OCP Mezz card 1',
- 'is_fru' : True,
- },
- '<inventory_root>/system/io_board/pcie_slot2' :
- {
- 'fru_type' : Openbmc.FRU_TYPES['PCIE_CARD'],
- 'user_label' : 'OCP Mezz card 2',
- 'is_fru' : True,
- },
- '<inventory_root>/system/io_board/pcie_mezz0' :
- {
- 'fru_type' : Openbmc.FRU_TYPES['PCIE_CARD'],
- 'user_label' : 'OCP Mezz card 0',
- 'is_fru' : True,
- },
- '<inventory_root>/system/io_board/pcie_mezz1' :
- {
- 'fru_type' : Openbmc.FRU_TYPES['PCIE_CARD'],
- 'user_label' : 'OCP Mezz card 1',
- '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/io_board' : { 'fru_type' : 'DAUGHTER_CARD','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, 'manufacturer' : 'ASPEED' },
+
+ '<inventory_root>/system/chassis/motherboard/cpu0' : { 'fru_type' : 'CPU', 'is_fru' : True, },
+ '<inventory_root>/system/chassis/motherboard/cpu1' : { '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/cpu1/core0' : { 'fru_type' : 'CORE', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/cpu1/core1' : { 'fru_type' : 'CORE', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/cpu1/core2' : { 'fru_type' : 'CORE', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/cpu1/core3' : { 'fru_type' : 'CORE', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/cpu1/core4' : { 'fru_type' : 'CORE', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/cpu1/core5' : { 'fru_type' : 'CORE', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/cpu1/core6' : { 'fru_type' : 'CORE', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/cpu1/core7' : { 'fru_type' : 'CORE', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/cpu1/core8' : { 'fru_type' : 'CORE', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/cpu1/core9' : { 'fru_type' : 'CORE', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/cpu1/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/centaur1' : { 'fru_type' : 'MEMORY_BUFFER', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/centaur2' : { 'fru_type' : 'MEMORY_BUFFER', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/centaur3' : { 'fru_type' : 'MEMORY_BUFFER', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/centaur4' : { 'fru_type' : 'MEMORY_BUFFER', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/centaur5' : { 'fru_type' : 'MEMORY_BUFFER', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/centaur6' : { 'fru_type' : 'MEMORY_BUFFER', 'is_fru' : False, },
+ '<inventory_root>/system/chassis/motherboard/centaur7' : { 'fru_type' : 'MEMORY_BUFFER', 'is_fru' : False, },
+
+ '<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/dimm4' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm5' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm6' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm7' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm8' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm9' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm10' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm11' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm12' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm13' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm14' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm15' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm16' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm17' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm18' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm19' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm20' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm21' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm22' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm23' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm24' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm25' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm26' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm27' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm28' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm29' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm30' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/motherboard/dimm31' : { 'fru_type' : 'DIMM', 'is_fru' : True,},
+
+ '<inventory_root>/system/chassis/io_board/pcie_slot0_riser' : { 'fru_type' : 'PCIE_RISER', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/io_board/pcie_slot1_riser' : { 'fru_type' : 'PCIE_RISER', '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_mezz0' : { 'fru_type' : 'PCIE_CARD', 'is_fru' : True,},
+ '<inventory_root>/system/chassis/io_board/pcie_mezz1' : { 'fru_type' : 'PCIE_CARD', 'is_fru' : True,},
}
+
+
ID_LOOKUP = {
'FRU' : {
- '14' : '<inventory_root>/system/motherboard/dimm0',
+ 0x0d : '<inventory_root>/system/chassis',
+ 0x34 : '<inventory_root>/system/chassis/motherboard',
+ 0x01 : '<inventory_root>/system/chassis/motherboard/cpu0',
+ 0x02 : '<inventory_root>/system/chassis/motherboard/centaur0',
+ 0x03 : '<inventory_root>/system/chassis/motherboard/dimm0',
+ 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',
+ },
+ 'FRU_STR' : {
+ 'PRODUCT_15' : '<inventory_root>/system',
+ 'CHASSIS_2' : '<inventory_root>/system/chassis',
+ 'BOARD_1' : '<inventory_root>/system/chassis/motherboard/cpu0',
+ 'BOARD_2' : '<inventory_root>/system/chassis/motherboard/centaur0',
+ 'PRODUCT_3' : '<inventory_root>/system/chassis/motherboard/dimm0',
+ 'PRODUCT_4' : '<inventory_root>/system/chassis/motherboard/dimm1',
+ 'PRODUCT_5' : '<inventory_root>/system/chassis/motherboard/dimm2',
+ 'PRODUCT_6' : '<inventory_root>/system/chassis/motherboard/dimm3',
},
'SENSOR' : {
- '21' : '<inventory_root>/system/motherboard/dimm0',
- '14' : '/org/openbmc/sensors/HostStatus_0',
+ 0x2f : '<inventory_root>/system/chassis/motherboard/cpu0',
+ 0x22 : '<inventory_root>/system/chassis/motherboard/cpu0/core0',
+ 0x23 : '<inventory_root>/system/chassis/motherboard/cpu0/core1',
+ 0x24 : '<inventory_root>/system/chassis/motherboard/cpu0/core2',
+ 0x25 : '<inventory_root>/system/chassis/motherboard/cpu0/core3',
+ 0x26 : '<inventory_root>/system/chassis/motherboard/cpu0/core4',
+ 0x27 : '<inventory_root>/system/chassis/motherboard/cpu0/core5',
+ 0x28 : '<inventory_root>/system/chassis/motherboard/cpu0/core6',
+ 0x29 : '<inventory_root>/system/chassis/motherboard/cpu0/core7',
+ 0x2a : '<inventory_root>/system/chassis/motherboard/cpu0/core8',
+ 0x2b : '<inventory_root>/system/chassis/motherboard/cpu0/core9',
+ 0x2c : '<inventory_root>/system/chassis/motherboard/cpu0/core10',
+ 0x2d : '<inventory_root>/system/chassis/motherboard/cpu0/core11',
+ 0x2e : '<inventory_root>/system/chassis/motherboard/centaur0',
+ 0x1e : '<inventory_root>/system/chassis/motherboard/dimm0',
+ 0x1f : '<inventory_root>/system/chassis/motherboard/dimm1',
+ 0x20 : '<inventory_root>/system/chassis/motherboard/dimm2',
+ 0x21 : '<inventory_root>/system/chassis/motherboard/dimm3',
+ 0x09 : '/org/openbmc/sensor/virtual/BootCount',
+ 0x05 : '/org/openbmc/sensor/virtual/BootProgress',
+ 0x04 : '/org/openbmc/sensor/virtual/HostStatus',
+ 0x08 : '/org/openbmc/sensor/virtual/OccStatus',
+ 0x32 : '/org/openbmc/sensor/virtual/OperatingSystemStatus',
},
'GPIO_PRESENT' : {
- 'SLOT0_RISER_PRESENT' : '<inventory_root>/system/io_board/pcie_left_slot_riser',
- 'SLOT1_RISER_PRESENT' : '<inventory_root>/system/io_board/pcie_right_slot_riser',
- 'SLOT2_RISER_PRESENT' : '<inventory_root>/system/io_board/pcie_x16_slot_riser',
- 'SLOT0_PRESENT' : '<inventory_root>/system/io_board/pcie_slot0',
- 'SLOT1_PRESENT' : '<inventory_root>/system/io_board/pcie_slot1',
- 'SLOT2_PRESENT' : '<inventory_root>/system/io_board/pcie_slot2',
- 'MEZZ0_PRESENT' : '<inventory_root>/system/io_board/pcie_mezz0',
- 'MEZZ1_PRESENT' : '<inventory_root>/system/io_board/pcie_mezz1',
+ 'SLOT0_PRESENT' : '<inventory_root>/system/chassis/io_board/pcie_slot0',
+ 'SLOT1_PRESENT' : '<inventory_root>/system/chassis/io_board/pcie_slot1',
}
}
GPIO_CONFIG = {}
-GPIO_CONFIG['FSI_CLK'] = { 'gpio_num': 4, 'direction': 'out' }
-GPIO_CONFIG['FSI_DATA'] = { 'gpio_num': 5, 'direction': 'out' }
-GPIO_CONFIG['FSI_ENABLE'] = { 'gpio_num': 24, 'direction': 'out' }
-GPIO_CONFIG['POWER_PIN'] = { 'gpio_num': 33, 'direction': 'out' }
-GPIO_CONFIG['CRONUS_SEL'] = { 'gpio_num': 6, 'direction': 'out' }
-GPIO_CONFIG['PGOOD'] = { 'gpio_num': 23, 'direction': 'in' }
-GPIO_CONFIG['IDENTIFY'] = { 'gpio_num': 34, 'direction': 'out' }
-GPIO_CONFIG['POWER_BUTTON'] = { 'gpio_num': 32, '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': 107, 'direction': 'in' }
-GPIO_CONFIG['SLOT1_PRESENT'] = { 'gpio_num': 108, '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_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' }
diff --git a/bin/chassis_control.py b/bin/chassis_control.py
index 683c1da..e3f6e6a 100755
--- a/bin/chassis_control.py
+++ b/bin/chassis_control.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python -u
import sys
import uuid
@@ -160,8 +160,8 @@
def host_watchdog_signal_handler(self):
print "Watchdog Error, Hard Rebooting"
- self.reboot = 1
- self.powerOff()
+ #self.reboot = 1
+ #self.powerOff()
if __name__ == '__main__':
diff --git a/bin/download_manager.py b/bin/download_manager.py
index 35859a5..74449a3 100755
--- a/bin/download_manager.py
+++ b/bin/download_manager.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python -u
import sys
import gobject
diff --git a/bin/inventory_items.py b/bin/inventory_items.py
index d27abd3..a162bad 100755
--- a/bin/inventory_items.py
+++ b/bin/inventory_items.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python -u
import os
import sys
diff --git a/bin/ipmi_example.py b/bin/ipmi_example.py
index ba13b60..f8b921e 100755
--- a/bin/ipmi_example.py
+++ b/bin/ipmi_example.py
@@ -120,8 +120,12 @@
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/sensor_manager.py b/bin/sensor_manager.py
index a91235e..9bb42d9 100755
--- a/bin/sensor_manager.py
+++ b/bin/sensor_manager.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python -u
import sys
#from gi.repository import GObject
diff --git a/bin/sensors_virtual_p8.py b/bin/sensors_virtual_p8.py
index c348e83..b3c975a 100755
--- a/bin/sensors_virtual_p8.py
+++ b/bin/sensors_virtual_p8.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python -u
import sys
#from gi.repository import GObject
diff --git a/bin/system_manager.py b/bin/system_manager.py
index 7f94578..f7bfdad 100755
--- a/bin/system_manager.py
+++ b/bin/system_manager.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python -u
import sys
import subprocess
diff --git a/objects/control_bmc_barreleye.c b/objects/control_bmc_barreleye.c
new file mode 100644
index 0000000..0e6c5cb
--- /dev/null
+++ b/objects/control_bmc_barreleye.c
@@ -0,0 +1,213 @@
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include "interfaces/openbmc_intf.h"
+#include "openbmc.h"
+#include "gpio.h"
+
+/* ---------------------------------------------------------------------------------------------------- */
+static const gchar* dbus_object_path = "/org/openbmc/control";
+static const gchar* dbus_name = "org.openbmc.control.Bmc";
+
+//this probably should come from some global SOC config
+
+#define LPC_BASE (off_t)0x1e789000
+#define LPC_HICR6 0x80
+#define LPC_HICR7 0x88
+#define LPC_HICR8 0x8c
+#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
+
+static GDBusObjectManagerServer *manager = NULL;
+
+void* memmap(int mem_fd,off_t base)
+{
+ void* bmcreg;
+ bmcreg = mmap(NULL, getpagesize(),
+ PROT_READ | PROT_WRITE, MAP_SHARED, mem_fd, base);
+
+ if (bmcreg == MAP_FAILED) {
+ printf("ERROR: Unable to map LPC register memory");
+ exit(1);
+ }
+ return bmcreg;
+}
+
+void reg_init()
+{
+ g_print("BMC init\n");
+ // BMC init done here
+
+ void *bmcreg;
+ int mem_fd = open("/dev/mem", O_RDWR | O_SYNC);
+ if (mem_fd < 0) {
+ printf("ERROR: Unable to open /dev/mem");
+ exit(1);
+ }
+
+ bmcreg = memmap(mem_fd,LPC_BASE);
+ devmem(bmcreg+LPC_HICR6,0x00000500); //Enable LPC FWH cycles, Enable LPC to AHB bridge
+ devmem(bmcreg+LPC_HICR7,0x30000E00); //32M PNOR
+ devmem(bmcreg+LPC_HICR8,0xFC0003FF);
+
+ //flash controller
+ bmcreg = memmap(mem_fd,SPI_BASE);
+ devmem(bmcreg+0x00,0x00000003);
+ devmem(bmcreg+0x04,0x00002404);
+
+ //UART
+
+
+ bmcreg = memmap(mem_fd,UART_BASE);
+ 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
+
+ bmcreg = memmap(mem_fd,SCU_BASE);
+ devmem(bmcreg+0x00,0x9f82fce7);
+ devmem(bmcreg+0x04,0x0370e677);
+ devmem(bmcreg+0x20,0xcfc8f7ff);
+ devmem(bmcreg+0x24,0xc738f20a);
+ devmem(bmcreg+0x80,0x0031ffaf);
+
+
+ //GPIO
+ bmcreg = memmap(mem_fd,GPIO_BASE);
+ devmem(bmcreg+0x84,0x00fff0c0); //Enable UART1
+ devmem(bmcreg+0x70,0x120CE406);
+ devmem(bmcreg+0x80,0xCB000000);
+ devmem(bmcreg+0x88,0x01C000FF);
+ devmem(bmcreg+0x8c,0xC1C000FF);
+ devmem(bmcreg+0x90,0x003FA009);
+ devmem(bmcreg+0x88,0x01C0007F);
+
+
+ bmcreg = memmap(mem_fd,COM_BASE);
+ devmem(bmcreg+0x170,0x00000042);
+ devmem(bmcreg+0x174,0x00004000);
+
+
+ close(mem_fd);
+}
+
+static gboolean
+on_init (Control *control,
+ 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;
+}
+
+static void
+on_bus_acquired (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ 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);
+
+ Control* control = control_skeleton_new ();
+ object_skeleton_set_control (object, control);
+ g_object_unref (control);
+
+ //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);
+}
+
+static void
+on_name_acquired (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+}
+
+static void
+on_name_lost (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+}
+
+
+
+
+/*----------------------------------------------------------------*/
+/* Main Event Loop */
+
+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;
+}
diff --git a/objects/host_watchdog_obj.c b/objects/host_watchdog_obj.c
index e4e4bab..b1c8f2b 100644
--- a/objects/host_watchdog_obj.c
+++ b/objects/host_watchdog_obj.c
@@ -8,7 +8,7 @@
static const gchar* dbus_name = "org.openbmc.watchdog.Host";
static GDBusObjectManagerServer *manager = NULL;
-
+static guint watchdogid = 0;
static gboolean
poll_watchdog(gpointer user_data)
@@ -21,6 +21,7 @@
if (count == 0)
{
//watchdog error, emit error and stop watchdog
+ watchdogid = 0;
watchdog_emit_watchdog_error(watchdog);
return FALSE;
}
@@ -49,7 +50,7 @@
watchdog_set_watchdog(wd,1);
guint poll_interval = watchdog_get_poll_interval(wd);
g_print("Starting watchdog with poll interval: %d\n", poll_interval);
- g_timeout_add(poll_interval, poll_watchdog, user_data);
+ watchdogid = g_timeout_add(poll_interval, poll_watchdog, user_data);
watchdog_complete_start(wd,invocation);
return TRUE;
}
@@ -64,7 +65,22 @@
return TRUE;
}
+static gboolean
+on_stop (Watchdog *wd,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ g_print("Stopping watchdog\n");
+ if (watchdogid)
+ {
+ g_source_remove(watchdogid);
+ watchdogid = 0;
+ }
+
+ watchdog_complete_stop(wd,invocation);
+ return TRUE;
+}
static void
on_bus_acquired (GDBusConnection *connection,
@@ -107,6 +123,11 @@
object); /* user_data */
g_signal_connect (wd,
+ "handle-stop",
+ G_CALLBACK (on_stop),
+ object); /* user_data */
+
+ g_signal_connect (wd,
"handle-set",
G_CALLBACK (set_poll_interval),
object); /* user_data */
diff --git a/objects/sensor_occ_obj.c b/objects/sensor_occ_obj.c
deleted file mode 100644
index 669579f..0000000
--- a/objects/sensor_occ_obj.c
+++ /dev/null
@@ -1,183 +0,0 @@
-#include "interfaces/openbmc_intf.h"
-#include "openbmc.h"
-
-
-/* ---------------------------------------------------------------------------------------------------- */
-
-static const gchar* dbus_object_path = "/org/openbmc/sensors";
-static const gchar* dbus_name = "org.openbmc.sensors.Occ";
-static guint heartbeat = 0;
-
-static GDBusObjectManagerServer *manager = NULL;
-static gchar *instance_name = NULL;
-
-static gboolean poll_occ(gpointer user_data)
-{
- //g_dbus_object_get_object_path(G_DBUS_OBJECT(user_data)),
- Occ* occ = object_get_occ((Object*)user_data);
-
- gchar *s;
- s = g_strdup_printf ("%s/Temperature/P8_%s_Core_%d",
- dbus_object_path,occ_get_instance_name(occ),1);
- g_print("%s\n",s);
-
- GDBusInterface* interface = g_dbus_object_manager_get_interface((GDBusObjectManager*)manager,s,
- "org.openbmc.SensorValue");
-
- if (interface != NULL)
- {
- SensorValue* sensor = (SensorValue*) interface;
- GVariant *value = NEW_VARIANT_U(10);
- sensor_value_set_value(sensor,value);
- const gchar* units = sensor_value_get_units(sensor);
- sensor_value_emit_changed(sensor,sensor_value_get_value(sensor),units);
- }
- g_free (s);
- //g_free(interface);
- return TRUE;
-}
-
-static gboolean
-on_init (Occ *occ,
- GDBusMethodInvocation *invocation,
- gpointer user_data)
-{
- guint poll_interval = occ_get_poll_interval(occ);
- g_timeout_add(poll_interval, poll_occ, user_data);
- occ_complete_init(occ,invocation);
- return TRUE;
-}
-static gboolean
-on_init_sensor (SensorValue *sensor,
- GDBusMethodInvocation *invocation,
- gpointer user_data)
-{
- //must implement init method
- sensor_value_complete_init(sensor,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/%s",dbus_object_path,cmd->argv[i]);
- ObjectSkeleton *object = object_skeleton_new (s);
- g_free (s);
-
- Occ *occ = occ_skeleton_new ();
- object_skeleton_set_occ (object, occ);
- g_object_unref (occ);
- occ_set_instance_name(occ,cmd->argv[i]);
-
- SensorI2c *i2c = sensor_i2c_skeleton_new ();
- object_skeleton_set_sensor_i2c (object, i2c);
- g_object_unref (i2c);
-
- g_signal_connect (occ,
- "handle-init",
- G_CALLBACK (on_init),
- object); /* user_data */
-
- //g_timeout_add(3000, poll_occ, object);
-
- /* 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);
-
- int c;
- for (c=0;c<12;c++)
- {
- s = g_strdup_printf ("%s/Temperature/P8_%s_Core_%d",dbus_object_path,cmd->argv[i],c);
- 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);
- GVariant* v_new_value = NEW_VARIANT_U(c);
- sensor_value_set_value(sensor,v_new_value);
- sensor_value_set_units(sensor,"C");
-
- g_signal_connect (sensor,
- "handle-init",
- G_CALLBACK (on_init_sensor),
- NULL); /* user_data */
-
- //emit changed signal so sensor manager sees initial value
- sensor_value_emit_changed(sensor,sensor_value_get_value(sensor),sensor_value_get_units(sensor));
- /* 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);
- g_print("shutting down: %s\n",name);
- cmdline *cmd = user_data;
- g_main_loop_quit(cmd->loop);
-}
-
-
-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);
- cmd.loop = loop;
-
- 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;
-}