lots of changes
diff --git a/Makefile b/Makefile
index 2c49960..9ff50ed 100644
--- a/Makefile
+++ b/Makefile
@@ -1,21 +1,21 @@
-CC=gcc
+#CC=gcc
 OBJS    = objects/pflash/progress.o objects/pflash/ast-sf-ctrl.o
 OBJS	+= objects/pflash/libflash/libflash.o objects/pflash/libflash/libffs.o
 OBJS	+= objects/pflash/arm_io.o
-LIBS=/gsa/ausgsa/home/n/j/njames/openbmc
-OFLAGS =-L$(HOME)/lib -lopenbmc_intf
-HOME = /media/sf_vbox/openbmc
-#CFLAGS=$(shell pkg-config --libs --cflags gtk+-2.0 glib-2.0)
-CFLAGS = -pthread -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -lgio-2.0 -lgobject-2.0 -lglib-2.0
+LIBS = ./bin
+OFLAGS =-L$(LIBS) -lopenbmc_intf
+HOME = .
+CFLAGS=$(shell pkg-config --libs --cflags gio-unix-2.0 glib-2.0)
+#CFLAGS = -pthread -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -lgio-2.0 -lgobject-2.0 -lglib-2.0
 
 %.o: interfaces/%.c 
 	$(CC) -c -fPIC -o obj/$@ $< -I$(HOME) -I$(HOME)/includes $(CFLAGS)
 
 %.o: objects/%.c
-	$(CC) -c -o obj/$@ $< -L$(HOME)/lib -I$(HOME) -I$(HOME)/includes -I$(HOME)/objects/pflash -lfru $(CFLAGS)
+	$(CC) -c -o obj/$@ $< -L$(LIBS) -I$(HOME) -I$(HOME)/includes -I$(HOME)/objects/pflash  $(CFLAGS)
 
 %.o: includes/%.c
-	$(CC) -c -o obj/$@ $< -I$(HOME) -I$(HOME)/includes -I$(HOME)/objects/pflash $(CFLAGS)
+	$(CC) -c -o obj/$@ $< -L$(LIBS) -I$(HOME) -I$(HOME)/includes -I$(HOME)/objects/pflash $(CFLAGS)
 
 %.o: objects/pflash/%.c
 	$(CC) -c -o obj/$@ $< -I$(HOME) -I$(HOME)/objects/pflash $(CFLAGS)
@@ -23,7 +23,7 @@
 
 
 libopenbmc_intf: openbmc_intf.o
-	$(CC) -shared -o lib/$@.so obj/openbmc_intf.o $(CFLAGS)
+	$(CC) -shared -o bin/$@.so obj/openbmc_intf.o $(CFLAGS)
 
 power_control: power_control_obj.o gpio.o
 	$(CC) -o bin/$@.exe obj/gpio.o obj/power_control_obj.o $(OFLAGS) $(CFLAGS)
@@ -62,4 +62,4 @@
 	$(CC) -o bin/$@.exe obj/board_vpd_obj.o $(OFLAGS) $(CFLAGS)
 
 
-all: libopenbmc_intf power_control chassis_identify sensor_ambient button_power sensor_host_status control_host flash_bios fan host_watchdog control_bmc sensor_occ board_vpd
+all: libopenbmc_intf power_control chassis_identify sensor_ambient button_power sensor_host_status control_host fan host_watchdog control_bmc sensor_occ board_vpd
diff --git a/bin/Barreleye.py b/bin/Barreleye.py
index e32f559..d7c596b 100644
--- a/bin/Barreleye.py
+++ b/bin/Barreleye.py
@@ -4,8 +4,8 @@
 import dbus
 import Openbmc
 
-HOME_PATH = '/media/sf_vbox/openbmc/'
-BIN_PATH = HOME_PATH+'bin/'
+HOME_PATH = './'
+BIN_PATH = HOME_PATH
 CACHE_PATH = HOME_PATH+'cache/'
 FRU_PATH = CACHE_PATH+'frus/'
 
@@ -70,7 +70,7 @@
 		'instances' : [	
 			{
 				'name' : 'Barreleye',
-				'user_label': 'Fru Manager',
+				'user_label': 'Ipmi Manager',
 			}
 		]
 	}
@@ -92,8 +92,8 @@
 	}
 
 SYSTEM_CONFIG['org.openbmc.loggers.EventLogger'] = {
-		'system_state' : 'STANDBY',
-		'start_process' : True,
+		'system_state' : 'INIT',
+		'start_process' : False,
 		'monitor_process' : True,
 		'process_name' : 'eventlogger.py',
 		'heartbeat' : 'no',
@@ -141,7 +141,7 @@
 						'poll_interval' : 3000
 					},
 					'org.openbmc.control.Power': {
-						'pgood_timeout' : 10000
+						'pgood_timeout' : 10
 					}
 				}
 			}
@@ -223,7 +223,7 @@
 	}
 SYSTEM_CONFIG['org.openbmc.flash.BIOS'] = {
 		'system_state' : 'STANDBY',
-		'start_process' : True,
+		'start_process' : False,
 		'monitor_process' : True,
 		'process_name' : 'flash_bios.exe',
 		'heartbeat' : 'no',
@@ -328,29 +328,77 @@
 	'cache'      : True
 }
 
-FRUS = {}
-
-## key is IPMI FRU ID
-
-FRUS[32] = {
-		'name' : 'CPU0',
-		'user_label' : "IBM POWER8 CPU",
-		'ftype' : Openbmc.FRU_TYPES['CPU'],
-		'location' : "P0",
-		'manufacturer' : "IBM",
-		'cache' : True,
-		'state' : Openbmc.FRU_STATES['NORMAL'],
-		'sensor_id' : 10,
-	}
-
-FRUS[21] = {
-		'name' : 'IO_PLANAR',
-		'user_label' : "BARRELEYE IO PLANAR",
-		'ftype' : Openbmc.FRU_TYPES['BACKPLANE'],	
-		'cache' : False,
-		'state' : Openbmc.FRU_STATES['NORMAL'],
-		'sensor_id' : 11,
-	}
+FRU_INSTANCES = {
+	'/system' :
+	{
+		'ftype'        : Openbmc.FRU_TYPES['SYSTEM'],
+		'fru'	       : True,
+	},
+	'/system/motherboard' :
+	{
+		'ftype'        : Openbmc.FRU_TYPES['MAIN_PLANAR'],
+		'manufacturer' : 'FOXCONN',
+		'fru'	       : True,
+		'fru_id'       : 31,
+		'location' : 'C0',
+	},
+	'/system/fan0' :
+	{
+		'ftype'        : Openbmc.FRU_TYPES['FAN'],
+		'manufacturer' : 'DELTA',
+		'fru'	       : True,
+		'location' : 'F0',
+		'sensor_link' : 'fans/Fan_0',
+	},
+	'/system/fan1' :
+	{
+		'ftype'        : Openbmc.FRU_TYPES['FAN'],
+		'manufacturer' : 'DELTA',
+		'fru'	       : True,
+		'location' : 'F1',
+		'sensor_link' : 'fans/Fan_1',
+	},
+	'/system/motherboard/bmc' :
+	{
+		'ftype'        : Openbmc.FRU_TYPES['BMC'],
+		'manufacturer' : 'ASPEED',
+		'fru'	       : True,
+	},
+	'/system/motherboard/cpu0' :
+	{
+		'ftype'        : Openbmc.FRU_TYPES['CPU'],
+		'manufacturer' : 'IBM',
+		'fru'	       : True,
+		'location' : 'P0',
+		'fru_id'   : 10,
+	},
+	'/system/motherboard/cpu0/core0' :
+	{
+		'ftype'        : Openbmc.FRU_TYPES['CORE'],
+		'fru'	       : False,
+		'sensor_link' : 1,	
+	},
+	'/system/motherboard/cpu0/core1' :
+	{
+		'ftype'        : Openbmc.FRU_TYPES['CORE'],
+		'fru'	       : False,
+		'sensor_link' : 2,	
+	},
+	'/system/motherboard/dimm0' :
+	{
+		'ftype'        : Openbmc.FRU_TYPES['DIMM'],
+		'fru'	       : True,
+		'fru_id'       : 12,
+		'sensor_link'  : 20,	
+	},
+	'/system/motherboard/dimm1' :
+	{
+		'ftype'        : Openbmc.FRU_TYPES['DIMM'],
+		'fru'	       : True,
+		'fru_id'       : 13,
+		'sensor_link'  : 21,	
+	},
+}
 
 
 GPIO_CONFIG = {}
diff --git a/bin/Openbmc.py b/bin/Openbmc.py
index 9cfeffb..a777ae8 100644
--- a/bin/Openbmc.py
+++ b/bin/Openbmc.py
@@ -7,11 +7,14 @@
 
 
 FRU_TYPES = {
+	'SYSTEM' : 0,
 	'CPU' : 1,
 	'DIMM' : 2,
-	'BACKPLANE' : 3,
+	'MAIN_PLANAR' : 3,
 	'RISER_CARD' : 4,
-	'FAN' : 5
+	'FAN' : 5,
+	'BMC' : 6,
+	'CORE' : 7,
 }
 FRU_STATES = {
 	'NORMAL'            : 0,
diff --git a/bin/eventlogger.py b/bin/eventlogger.py
index 131faec..e36f928 100644
--- a/bin/eventlogger.py
+++ b/bin/eventlogger.py
@@ -25,13 +25,14 @@
 					path_keyword='path')
 
 	## Signal handler
-	def event_log_signal_handler(self,priority,msg,path = None):
+	def event_log_signal_handler(self,priority,msg,rc,path = None):
 		message = {}
 		ts = time.time()
 
 		message['priority'] = priority
 		message['object_path'] = path
 		message['message'] = msg
+		message['rc'] = rc
 
 		json_dump = json.dumps(message)
 		print "EVENT_LOG: "+json_dump
diff --git a/bin/fru_manager.py b/bin/fru_manager.py
index 1150552..220b7d3 100644
--- a/bin/fru_manager.py
+++ b/bin/fru_manager.py
@@ -17,7 +17,7 @@
 
 DBUS_NAME = 'org.openbmc.managers.Frus'
 OBJ_NAME = '/org/openbmc/managers/Frus'
-FRU_PATH = System.FRU_PATH
+FRUS = System.FRU_INSTANCES
 
 class Fru:
 	def __init__(self,fru_id,data):
@@ -89,13 +89,13 @@
 					signal_name = 'UpdateFru')
 
 		self.fru_db = {}
-		for fid in System.FRUS.keys():
-			self.updateFru(fid,System.FRUS[fid])
+		self.fru_id_lookup = {}
+		for fru in FRUS.keys():
+			#self.updateFru(fid,System.FRUS[fid])
+			if (FRUS[fru].has_key('fru_id')):
+				print fru
+				print FRUS[fru]['fru_id']
 			
-			
-	#@dbus.service.signal(DBUS_NAME)
-	#def OpenBmcRunning(self):
-	#	pass
 	def UpdateFruHandler(self,fru_id,data):
 		self.updateFru(fru_id,data)		
 
diff --git a/bin/system_manager.py b/bin/system_manager.py
index 1a4fe99..015aa8d 100644
--- a/bin/system_manager.py
+++ b/bin/system_manager.py
@@ -9,7 +9,8 @@
 import dbus.mainloop.glib
 import os
 import PropertyManager
-
+import time
+import json
 import Openbmc
 
 if (len(sys.argv) < 2):
@@ -35,6 +36,12 @@
 					signal_name = "NameOwnerChanged")
 		bus.add_signal_receiver(self.HeartbeatHandler, signal_name = "Heartbeat")
 		bus.add_signal_receiver(self.SystemStateHandler,signal_name = "GotoSystemState")
+		bus.add_signal_receiver(self.event_log_signal_handler, 
+					dbus_interface = "org.openbmc.EventLog", 
+					signal_name = "EventLog",
+					path_keyword='path')
+
+
 
 		self.current_state = ""
 		self.system_states = {}
@@ -168,6 +175,22 @@
 
 		return [Openbmc.GPIO_DEV, gpio_num, System.GPIO_CONFIG[name]['direction']]
 
+	## Signal handler
+	def event_log_signal_handler(self,priority,msg,rc,path = None):
+		message = {}
+		ts = time.time()
+
+		message['priority'] = priority
+		message['object_path'] = path
+		message['message'] = msg
+		message['rc'] = rc
+
+		json_dump = json.dumps(message)
+		print "EVENT_LOG: "+json_dump
+		#syslog.openlog('OpenBmc',logoption=syslog.LOG_PID)
+		#syslog.syslog(priority,json_dump)
+		#syslog.closelog()
+		
 
 if __name__ == '__main__':
     dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
diff --git a/includes/gpio.c b/includes/gpio.c
index 992745f..1bd10a7 100644
--- a/includes/gpio.c
+++ b/includes/gpio.c
@@ -39,7 +39,7 @@
 	return rc;
 }
 
-int gpio_read(GPIO* gpio, uint8_t* value)
+int gpio_read(GPIO* gpio, uint8_t *value)
 {
 	char buf[1];
 	int r = GPIO_OK;
@@ -51,10 +51,8 @@
 	{
 		if (read(gpio->fd,&buf,1) != 1)
 		{
-			g_print("here1\n");
 			r = GPIO_READ_ERROR;
 		} else {
-			g_print("here2\n");
 			if (buf[0]=='1') {
 				*value = 1;
 			} else {
@@ -121,21 +119,28 @@
 	//export and set direction
 	char dev[254];
 	char data[4];
-	sprintf(dev,"%s/export",gpio->dev);
+	int fd;
 	do {
-		int fd = open(dev, O_WRONLY);
-		if (fd == GPIO_ERROR) {
-			rc = GPIO_OPEN_ERROR;
-			break;
-		} 
-		sprintf(data,"%d",gpio->num);
-		rc = write(fd,data,strlen(data));
-		close(fd);
-		if (rc == GPIO_ERROR) {
-			rc = GPIO_WRITE_ERROR;
-			break;
+		struct stat st;
+		
+		sprintf(dev,"%s/gpio%d/direction",gpio->dev,gpio->num);
+    		int result = stat(dev, &st);
+    		if (result)
+		{
+			sprintf(dev,"%s/export",gpio->dev);
+			fd = open(dev, O_WRONLY);
+			if (fd == GPIO_ERROR) {
+				rc = GPIO_OPEN_ERROR;
+				break;
+			} 
+			sprintf(data,"%d",gpio->num);
+			rc = write(fd,data,strlen(data));
+			close(fd);
+			if (rc != strlen(data)) {
+				rc = GPIO_WRITE_ERROR;
+				break;
+			}
 		}
-
 		sprintf(dev,"%s/gpio%d/direction",gpio->dev,gpio->num);
 		fd = open(dev,O_WRONLY);
 		if (fd == GPIO_ERROR) {
@@ -143,7 +148,13 @@
 			break;
 		}
 		rc = write(fd,gpio->direction,strlen(gpio->direction));
+		if (rc != strlen(gpio->direction)) {
+			rc = GPIO_WRITE_ERROR;
+			break;
+		}
+
 		close(fd);
+		rc = 0;
 	} while(0);
 
 	return rc;
@@ -171,7 +182,10 @@
 		gpio->fd = open(buf, O_WRONLY);
 
 	}
-	return gpio->fd;
+	if (gpio->fd == -1) {
+		return GPIO_OPEN_ERROR;
+	}
+	return GPIO_OK;
 }
 
 void gpio_close(GPIO* gpio)
diff --git a/interfaces/openbmc_intf.c b/interfaces/openbmc_intf.c
index 5ccc4f5..6fbda1e 100644
--- a/interfaces/openbmc_intf.c
+++ b/interfaces/openbmc_intf.c
@@ -17832,10 +17832,22 @@
   FALSE
 };
 
+static const _ExtendedGDBusArgInfo _event_log_signal_info_event_log_ARG_rc =
+{
+  {
+    -1,
+    (gchar *) "rc",
+    (gchar *) "i",
+    NULL
+  },
+  FALSE
+};
+
 static const _ExtendedGDBusArgInfo * const _event_log_signal_info_event_log_ARG_pointers[] =
 {
   &_event_log_signal_info_event_log_ARG_priority,
   &_event_log_signal_info_event_log_ARG_message,
+  &_event_log_signal_info_event_log_ARG_rc,
   NULL
 };
 
@@ -17951,6 +17963,7 @@
    * @object: A #EventLog.
    * @arg_priority: Argument.
    * @arg_message: Argument.
+   * @arg_rc: Argument.
    *
    * On the client-side, this signal is emitted whenever the D-Bus signal <link linkend="gdbus-signal-org-openbmc-EventLog.EventLog">"EventLog"</link> is received.
    *
@@ -17964,7 +17977,7 @@
     NULL,
     g_cclosure_marshal_generic,
     G_TYPE_NONE,
-    2, G_TYPE_INT, G_TYPE_STRING);
+    3, G_TYPE_INT, G_TYPE_STRING, G_TYPE_INT);
 
 }
 
@@ -17973,6 +17986,7 @@
  * @object: A #EventLog.
  * @arg_priority: Argument to pass with the signal.
  * @arg_message: Argument to pass with the signal.
+ * @arg_rc: Argument to pass with the signal.
  *
  * Emits the <link linkend="gdbus-signal-org-openbmc-EventLog.EventLog">"EventLog"</link> D-Bus signal.
  */
@@ -17980,9 +17994,10 @@
 event_log_emit_event_log (
     EventLog *object,
     gint arg_priority,
-    const gchar *arg_message)
+    const gchar *arg_message,
+    gint arg_rc)
 {
-  g_signal_emit_by_name (object, "event-log", arg_priority, arg_message);
+  g_signal_emit_by_name (object, "event-log", arg_priority, arg_message, arg_rc);
 }
 
 /**
@@ -18663,7 +18678,8 @@
 _event_log_on_signal_event_log (
     EventLog *object,
     gint arg_priority,
-    const gchar *arg_message)
+    const gchar *arg_message,
+    gint arg_rc)
 {
   EventLogSkeleton *skeleton = EVENT_LOG_SKELETON (object);
 
@@ -18671,9 +18687,10 @@
   GVariant   *signal_variant;
   connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
 
-  signal_variant = g_variant_ref_sink (g_variant_new ("(is)",
+  signal_variant = g_variant_ref_sink (g_variant_new ("(isi)",
                    arg_priority,
-                   arg_message));
+                   arg_message,
+                   arg_rc));
   for (l = connections; l != NULL; l = l->next)
     {
       GDBusConnection *connection = l->data;
diff --git a/interfaces/openbmc_intf.h b/interfaces/openbmc_intf.h
index c064672..23bfccc 100644
--- a/interfaces/openbmc_intf.h
+++ b/interfaces/openbmc_intf.h
@@ -2357,7 +2357,8 @@
   void (*event_log) (
     EventLog *object,
     gint arg_priority,
-    const gchar *arg_message);
+    const gchar *arg_message,
+    gint arg_rc);
 
 };
 
@@ -2379,7 +2380,8 @@
 void event_log_emit_event_log (
     EventLog *object,
     gint arg_priority,
-    const gchar *arg_message);
+    const gchar *arg_message,
+    gint arg_rc);
 
 
 
diff --git a/objects/power_control_obj.c b/objects/power_control_obj.c
index 835ed7a..53df62d 100644
--- a/objects/power_control_obj.c
+++ b/objects/power_control_obj.c
@@ -21,9 +21,9 @@
 

 static GDBusObjectManagerServer *manager = NULL;

 

-guint tmp_pgood = 0;

-guint last_pgood = 0;

-guint pgood_timeout_count = 0;

+//guint tmp_pgood = 0;

+//guint last_pgood = 0;

+time_t pgood_timeout_start = 0;

 

 static gboolean poll_pgood(gpointer user_data)

 {

@@ -38,21 +38,22 @@
 	guint poll_int = control_get_poll_interval(control);

 	if (poll_int == 0)

 	{

-		event_log_emit_event_log(event_log, LOG_ALERT, "Poll interval cannot be 0");

+		event_log_emit_event_log(event_log, LOG_ALERT, "Poll interval cannot be 0",0);

 		return FALSE;

 	}

-	//calculate timeout count

-	guint pgood_timeout = control_power_get_pgood_timeout(control_power)/poll_int;

-

-	if (pgood_timeout_count > pgood_timeout)

+	//handle timeout

+	time_t current_time = time(NULL);

+	if (difftime(current_time,pgood_timeout_start) > control_power_get_pgood_timeout(control_power)

+		&& pgood_timeout_start != 0)

 	{

-		event_log_emit_event_log(event_log, LOG_ALERT, "Pgood poll timeout");

+		event_log_emit_event_log(event_log, LOG_ALERT, "Pgood poll timeout",0);

 		// set timeout to 0 so timeout doesn't happen again

 		control_power_set_pgood_timeout(control_power,0);

-		pgood_timeout_count = 0;

+		pgood_timeout_start = 0;

 		return TRUE;

 	}

 	//For simulation, remove

+	/*

 	if (tmp_pgood!=last_pgood) {

 		if (tmp_pgood == 1) {

 			control_emit_goto_system_state(control,"POWERED_ON");

@@ -60,10 +61,14 @@
 			control_emit_goto_system_state(control,"POWERED_OFF");

 		}

 	}

-

+	

 	last_pgood = tmp_pgood;

+	*/

 	uint8_t gpio;

-	int rc = gpio_read(&pgood,&gpio);

+	

+	int rc = gpio_open(&pgood);

+	rc = gpio_read(&pgood,&gpio);

+	gpio_close(&pgood);	

 	if (rc == GPIO_OK)

 	{

 		//if changed, set property and emit signal

@@ -82,18 +87,21 @@
  			}

 		}

 	} else {

-		event_log_emit_event_log(event_log, LOG_ALERT, "GPIO read error");

+		event_log_emit_event_log(event_log, LOG_ALERT, "GPIO read error",rc);

 		//return FALSE;

 	}

 	//pgood is not at desired state yet

+	g_print("GPIO: %d;  %d\n",gpio,control_power_get_state(control_power));

 	if (gpio != control_power_get_state(control_power) &&

-		control_power_get_pgood_timeout(control_power) != 0)

+		control_power_get_pgood_timeout(control_power) > 0)

 	{

-		pgood_timeout_count++;

+		if (pgood_timeout_start == 0 ) {

+			pgood_timeout_start = current_time;

+		}

 	}

 	else 

 	{

-		pgood_timeout_count = 0;

+		pgood_timeout_start = 0;

 	}

 	return TRUE;

 }

@@ -126,13 +134,13 @@
 	{

 		g_print("Set power state: %d\n",state);

 		//temporary until real hardware works

-		tmp_pgood = state;

+		//tmp_pgood = state;

 		int error = 0;

 		do {

 			error = gpio_open(&power_pin);

-			if (error != GPIO_OK) {	break;	}

+			if (error != GPIO_OK) { break;	}

 			error = gpio_write(&power_pin,!state);

-			if (error != GPIO_OK) {	break;	}

+			if (error != GPIO_OK) { break;	}

 			gpio_close(&power_pin);

 			control_power_set_state(pwr,state);

 			if (state == 1) {

@@ -143,7 +151,7 @@
 		} while(0);

 		if (error != GPIO_OK)

 		{

-			event_log_emit_event_log(event_log, LOG_ALERT, "GPIO setup error");

+			event_log_emit_event_log(event_log, LOG_ALERT, "GPIO set power state error",error);

 		}

 	}

 	return TRUE;

@@ -154,6 +162,7 @@
          GDBusMethodInvocation  *invocation,

          gpointer                user_data)

 {

+	pgood_timeout_start = 0;

 	guint poll_interval = control_get_poll_interval(control);

 	g_timeout_add(poll_interval, poll_pgood, user_data);

 	control_complete_init(control,invocation);

@@ -184,49 +193,45 @@
 		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]);

-		g_print("%s\n",s);

-  		object = object_skeleton_new (s);

-  		g_free (s);

+	gchar *s;

+  	s = g_strdup_printf ("%s/%s",dbus_object_path,cmd->argv[1]);

+	g_print("%s\n",s);

+  	object = object_skeleton_new (s);

+  	g_free (s);

 

-		ControlPower* control_power = control_power_skeleton_new ();

-		object_skeleton_set_control_power (object, control_power);

-		g_object_unref (control_power);

+	ControlPower* control_power = control_power_skeleton_new ();

+	object_skeleton_set_control_power (object, control_power);

+	g_object_unref (control_power);

+	

+	Control* control = control_skeleton_new ();

+	object_skeleton_set_control (object, control);

+	g_object_unref (control);

 

-		Control* control = control_skeleton_new ();

-		object_skeleton_set_control (object, control);

-		g_object_unref (control);

+	EventLog* event_log = event_log_skeleton_new ();

+	object_skeleton_set_event_log (object, event_log);

+	g_object_unref (event_log);

 

-		EventLog* event_log = event_log_skeleton_new ();

-		object_skeleton_set_event_log (object, event_log);

-		g_object_unref (event_log);

+	//define method callbacks here

+	g_signal_connect (control_power,

+       	            "handle-set-power-state",

+               	    G_CALLBACK (on_set_power_state),

+               	    object); /* user_data */

 

-		//define method callbacks here

-		g_signal_connect (control_power,

-        	            "handle-set-power-state",

-                	    G_CALLBACK (on_set_power_state),

-                	    object); /* user_data */

+	g_signal_connect (control_power,

+               	    "handle-get-power-state",

+               	    G_CALLBACK (on_get_power_state),

+               	    NULL); /* user_data */

 

-		g_signal_connect (control_power,

-                	    "handle-get-power-state",

-                	    G_CALLBACK (on_get_power_state),

-                	    NULL); /* user_data */

-

-		g_signal_connect (control,

-                	    "handle-init",

-                	    G_CALLBACK (on_init),

-                	    object); /* user_data */

+	g_signal_connect (control,

+               	    "handle-init",

+               	    G_CALLBACK (on_init),

+               	    object); /* 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 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);

 

@@ -239,12 +244,21 @@
 		rc = gpio_init(connection,&pgood);

 		if (rc != GPIO_OK) { break; }

 		rc = gpio_open(&pgood);

-		if (rc != GPIO_OK) { break; }

+

 	} while(0);

 	if (rc != GPIO_OK)

 	{

-		//event_log_emit_event_log(event_log, LOG_ALERT, "GPIO setup error");

+		event_log_emit_event_log(event_log, LOG_ALERT, "GPIO setup error",rc);

 	}

+	int rc = gpio_open(&pgood);

+	rc = gpio_read(&pgood,&gpio);

+	gpio_close(&pgood);	

+	if (rc == GPIO_OK) {

+		control_power_set_pgood(control_power,gpio);

+

+	} else {

+	}

+

 }

 

 static void

diff --git a/xml/openbmc_intf.xml b/xml/openbmc_intf.xml
index 8418b9a..f3056bf 100644
--- a/xml/openbmc_intf.xml
+++ b/xml/openbmc_intf.xml
@@ -130,6 +130,7 @@
 		<signal name="EventLog">
 			<arg name="priority" type="i"/>
 			<arg name="message" type="s"/>
+			<arg name="rc" type="i"/>
 		</signal>
 	</interface>	
 	<interface name="org.openbmc.Flash">