示例#1
0
static gboolean
on_boot         (ControlHost        *host,
                GDBusMethodInvocation  *invocation,
                gpointer                user_data)
{
	// TODO: Add error checking
	g_print("Do Boot\n");
	int rc = GPIO_OK;

	Control* control = object_get_control((Object*)user_data);
	control_host_complete_boot(host,invocation);
	do {	
		rc |= gpio_open(&fsi_clk);
		rc |= gpio_open(&fsi_data);
		rc |= gpio_open(&fsi_enable);
		rc |= gpio_open(&cronus_sel);
		if (rc!=GPIO_OK) { break; }
		
		rc = gpio_write(&cronus_sel,1);
		//putcfam pu 281c 30000000 -p0
		char a[] = "000011111111110101111000111001100111111111111111111111111111101111111111";
		//putcfam pu 281c B0000000 -p0
		char b[] = "000011111111110101111000111000100111111111111111111111111111101101111111";

		gpio_write(&fsi_enable,1);
		gpio_write(&fsi_clk,1);
		gpio_write(&fsi_data,1);
		gpio_clock_cycle(&fsi_clk,5000);
		gpio_write(&fsi_data,0);
		gpio_clock_cycle(&fsi_clk,256);
		gpio_write(&fsi_data,1);
		gpio_clock_cycle(&fsi_clk,50);
		uint16_t i=0;
		for(i=0;i<strlen(a);i++) {
			gpio_writec(&fsi_data,a[i]);
			gpio_clock_cycle(&fsi_clk,1);
		}
		gpio_write(&fsi_data,1); /* Data standby state */
		gpio_clock_cycle(&fsi_clk,5000);

		for(i=0;i<strlen(b);i++) {
			gpio_writec(&fsi_data,b[i]);
			gpio_clock_cycle(&fsi_clk,1);
		}
		gpio_write(&fsi_data,1); /* Data standby state */
		gpio_clock_cycle(&fsi_clk,2);

	        gpio_write(&fsi_clk,0); /* hold clk low for clock mux */
	        gpio_write(&fsi_enable,0);
	        gpio_clock_cycle(&fsi_clk,16);
	        gpio_write(&fsi_clk,0); /* Data standby state */
	
	} while(0);
	if (rc != GPIO_OK)
	{
		printf("ERROR HostControl: GPIO sequence failed (rc=%d)\n",rc);
	}	
	gpio_close(&fsi_clk);
	gpio_close(&fsi_data);
	gpio_close(&fsi_enable);
	gpio_close(&cronus_sel);

	control_emit_goto_system_state(control,"HOST_BOOTING");
	
	control_host_emit_booted(host);
	return TRUE;
}
示例#2
0
static gboolean
on_boot(ControlHost *host,
		GDBusMethodInvocation *invocation,
		gpointer user_data)
{
	int rc = GPIO_OK;
	GDBusProxy *proxy;
	GError *error = NULL;
	GVariant *result = NULL;
	GDBusConnection *connection =
		g_dbus_object_manager_server_get_connection(manager);

	if(control_host_get_debug_mode(host)==1)
	{
		g_print("Enabling debug mode; not booting host\n");
		rc |= gpio_open(&fsi_enable);
		rc |= gpio_open(&cronus_sel);
		rc |= gpio_write(&fsi_enable,1);
		rc |= gpio_write(&cronus_sel,0);
		if(rc!=GPIO_OK) {
			g_print("ERROR enabling debug mode: %d\n",rc);
		}
		return TRUE;
	}
	g_print("Booting host\n");
	Control* control = object_get_control((Object*)user_data);
	control_host_complete_boot(host,invocation);
	do {
		rc = gpio_open(&fsi_clk);
		rc |= gpio_open(&fsi_data);
		rc |= gpio_open(&fsi_enable);
		rc |= gpio_open(&cronus_sel);
		rc |= gpio_open(&Throttle);
		rc |= gpio_open(&idbtn);
		if(rc!=GPIO_OK) { break; }

		//setup dc pins
		rc = gpio_write(&cronus_sel,1);
		rc |= gpio_write(&fsi_enable,1);
		rc |= gpio_write(&fsi_clk,1);
		rc |= gpio_write(&Throttle,1);
		rc |= gpio_write(&idbtn,0);
		if(rc!=GPIO_OK) { break; }

		//data standy state
		rc = fsi_standby();

		//clear out pipes
		rc |= gpio_write(&fsi_data,0);
		rc |= gpio_clock_cycle(&fsi_clk,256);
		rc |= gpio_write(&fsi_data,1);
		rc |= gpio_clock_cycle(&fsi_clk,50);
		if(rc!=GPIO_OK) { break; }

		rc = fsi_bitbang(attnA);
		rc |= fsi_standby();

		rc |= fsi_bitbang(attnB);
		rc |= fsi_standby();

		rc |= fsi_bitbang(attnC);
		rc |= fsi_standby();
		if(rc!=GPIO_OK) { break; }

		const gchar* flash_side = control_host_get_flash_side(host);
		g_print("Using %s side of the bios flash\n",flash_side);
		if(strcmp(flash_side,"primary")==0) {
			rc |= fsi_bitbang(primary);
		} else if(strcmp(flash_side,"golden") == 0) {
			rc |= fsi_bitbang(golden);
		} else {
			g_print("ERROR: Invalid flash side: %s\n",flash_side);
			rc = 0xff;

		}
		rc |= fsi_standby();
		if(rc!=GPIO_OK) { break; }

		rc = fsi_bitbang(go);

		rc |= gpio_write(&fsi_data,1); /* Data standby state */
		rc |= gpio_clock_cycle(&fsi_clk,2);

		rc |= gpio_write(&fsi_clk,0); /* hold clk low for clock mux */
		rc |= gpio_write(&fsi_enable,0);
		rc |= gpio_clock_cycle(&fsi_clk,16);
		rc |= gpio_write(&fsi_clk,0); /* Data standby state */

	} while(0);
	if(rc != GPIO_OK)
	{
		g_print("ERROR HostControl: GPIO sequence failed (rc=%d)\n",rc);
	} else {
		control_emit_goto_system_state(control,"HOST_BOOTING");
	}
	gpio_close(&fsi_clk);
	gpio_close(&fsi_data);
	gpio_close(&fsi_enable);
	gpio_close(&cronus_sel);
	gpio_close(&Throttle);
	gpio_close(&idbtn);

	// Start watchdog with 30s timeout per the OpenPower Host IPMI Spec.
	// Once the host starts booting, it'll reset and refresh the timer.
	error = NULL;
	proxy = g_dbus_proxy_new_sync(connection,
		G_DBUS_PROXY_FLAGS_NONE,
		NULL, /* GDBusInterfaceInfo* */
		"org.openbmc.watchdog.Host", /* name */
		"/org/openbmc/watchdog/host0", /* object path */
		"org.openbmc.Watchdog", /* interface name */
		NULL, /* GCancellable */
		&error);
	g_assert_no_error(error);
	if(error)
		goto exit;

	// Set watchdog timer to 30s
	error = NULL;
	result = g_dbus_proxy_call_sync(proxy,
		"set",
		g_variant_new("(i)", 30000),
		G_DBUS_CALL_FLAGS_NONE,
		-1,
		NULL,
		&error);
	g_assert_no_error(error);
	if (error)
		goto exit;
	if (result)
		g_variant_unref(result);

	// Start watchdog timer
	error = NULL;
	result = g_dbus_proxy_call_sync(proxy,
		"start",
		NULL,
		G_DBUS_CALL_FLAGS_NONE,
		-1,
		NULL,
		&error);
	g_assert_no_error(error);
	if (error)
		goto exit;

	control_host_emit_booted(host);

exit:
	if (result)
		g_variant_unref(result);

	return TRUE;
}