Example #1
0
int vuart_dispmgr(void)
{
#define N(a)	(sizeof((a)) / sizeof((a)[0]))

	static u64 subject_id[][2] =
	{
		{ 0x1070000002000001, 0x10700003FF000001 },
		{ 0x1070000002000001, 0x10700005FC000001 },
		{ 0x1070000002000001, 0x10700003FD000001 },
		{ 0x1070000002000001, 0x1070000300000001 },
	};
	u64 vuart_lpar_addr, muid, lpar_addr, ea_addr, nread, nwritten, val;
	void *msgbuf;
	struct dispmgr_header *dispmgr_header;
	struct ss_header *ss_header;
	struct ss_update_mgr_get_package_info *ss_update_mgr_get_package_info;
	int i, result;

	result = lv1_allocate_memory(VUART_DISPMGR_SIZE, VUART_DISPMGR_PAGE_SIZE,
		0, 0, &vuart_lpar_addr, &muid);
 	if (result != 0)
 		return result;

	MM_LOAD_BASE(ea_addr, VUART_DISPMGR_OFFSET);
	lpar_addr = vuart_lpar_addr;

	for (i = 0; i < VUART_DISPMGR_SIZE >> 12; i++)
	{
		result = mm_insert_htab_entry(MM_EA2VA(ea_addr), lpar_addr, 0);
 		if (result != 0)
 			return result;

		ea_addr += (1 << 12);
		lpar_addr += (1 << 12);
	}

	MM_LOAD_BASE(msgbuf, VUART_DISPMGR_OFFSET);

	for (i = 0; i < N(subject_id); i++)
	{
		memset(msgbuf, 0, VUART_DISPMGR_SIZE);

		dispmgr_header = (struct dispmgr_header *) msgbuf;
		dispmgr_header->version = 1;
		dispmgr_header->function_id = 0x6000;
		dispmgr_header->request_size = 0x28;
		dispmgr_header->response_size = 0x100;

		ss_header = (struct ss_header *) (dispmgr_header + 1);
		memset(ss_header, 0, sizeof(struct ss_header));
		ss_header->packet_id = 0x6003;
		ss_header->function_id = 0x6000;
		ss_header->laid = subject_id[i][0];
		ss_header->paid = subject_id[i][1];

		ss_update_mgr_get_package_info =
			(struct ss_update_mgr_get_package_info *) (ss_header + 1);
		memset(ss_update_mgr_get_package_info, 0,
			sizeof(struct ss_update_mgr_get_package_info));
		ss_update_mgr_get_package_info->type = 1;

		dispmgr_header->request_size += sizeof(struct ss_update_mgr_get_package_info);

		result = lv1_write_virtual_uart(DISPMGR_VUART_PORT, vuart_lpar_addr,
			sizeof(struct dispmgr_header) + sizeof(struct ss_header) +
			sizeof(struct ss_update_mgr_get_package_info), &nwritten);
		if (result < 0)
			return result;

		for (;;)
		{
			result = lv1_get_virtual_uart_param(DISPMGR_VUART_PORT, VUART_PARAM_RX_BYTES, &val);
			if (result < 0)
				return result;

			if (val != 0)
				break;
		}

		for (;;)
		{
			result = lv1_read_virtual_uart(DISPMGR_VUART_PORT, vuart_lpar_addr, VUART_DISPMGR_SIZE,
				&nread);
			if (result < 0)
				return result;

			if (nread == 0)
				break;

			result = gelic_xmit_data(gelic_bcast_mac_addr, 0xCAFE, msgbuf, nread);
			if (result < 0)
				return result;
		}
	}

	return 0;

#undef N
}
Example #2
0
int product_mode_off(void)
{
	u64 vuart_lpar_addr, muid, nread, nwritten;
	u8 *msgbuf;
	struct dispmgr_header *dispmgr_header;
	struct ss_header *ss_header;
	struct ss_update_mgr_write_eprom *ss_update_mgr_write_eprom;
	int result;

	result = lv1_allocate_memory(PRODUCT_MODE_SIZE, PRODUCT_MODE_PAGE_SIZE,
		0, 0, &vuart_lpar_addr, &muid);
 	if (result != 0)
 		return result;

	MM_LOAD_BASE(msgbuf, PRODUCT_MODE_OFFSET);

	result = mm_map_lpar_memory_region(0, (u64) msgbuf, vuart_lpar_addr,
		PRODUCT_MODE_SIZE, PRODUCT_MODE_PAGE_SIZE, 0, 0);
 	if (result != 0)
 		return result;

	memset(msgbuf, 0, PRODUCT_MODE_SIZE);

	dispmgr_header = (struct dispmgr_header *) msgbuf;
	dispmgr_header->request_id = 1;
	dispmgr_header->function_id = 0x6000;
	dispmgr_header->request_size = sizeof(struct ss_header);
	dispmgr_header->response_size = sizeof(struct ss_header) +
		sizeof(struct ss_update_mgr_write_eprom);

	ss_header = (struct ss_header *) (dispmgr_header + 1);
	memset(ss_header, 0, sizeof(struct ss_header));
	ss_header->packet_id = 0x600C;
	ss_header->function_id = 0x6000;
	ss_header->laid = subject_id[0];
	ss_header->paid = subject_id[1];

	ss_update_mgr_write_eprom =
		(struct ss_update_mgr_write_eprom *) (ss_header + 1);
	memset(ss_update_mgr_write_eprom, 0,
		sizeof(struct ss_update_mgr_write_eprom));
	ss_update_mgr_write_eprom->offset = 0x48C07;
	ss_update_mgr_write_eprom->value = 0xFF;

	dispmgr_header->request_size += sizeof(struct ss_update_mgr_write_eprom);

	result = lv1_write_virtual_uart(DISPMGR_VUART_PORT, vuart_lpar_addr,
		sizeof(struct dispmgr_header) + dispmgr_header->request_size, &nwritten);
	if (result < 0)
		return result;

	result = vuart_wait_for_rx_data(DISPMGR_VUART_PORT);
	if (result < 0)
		return result;

	result = lv1_read_virtual_uart(DISPMGR_VUART_PORT, vuart_lpar_addr, PRODUCT_MODE_SIZE,
		&nread);
	if (result < 0)
		return result;

	result = gelic_xmit_data(gelic_bcast_mac_addr, 0xBEEF, msgbuf, nread);
	if (result < 0)
		return result;

	beep(BEEP_DOUBLE);

	lv1_panic(1);

	return 0;
}
int aim_get_open_ps_id(void)
{
#define N(a)	(sizeof((a)) / sizeof((a)[0]))

	u64 vuart_lpar_addr, muid, nread, nwritten;
	u8 *msgbuf;
	struct dispmgr_header *dispmgr_header;
	struct ss_header *ss_header;
	struct ss_aim_get_open_ps_id *ss_aim_get_open_ps_id;
	int result;

	result = lv1_allocate_memory(AIM_GET_OPEN_PS_ID_SIZE, AIM_GET_OPEN_PS_ID_PAGE_SIZE,
		0, 0, &vuart_lpar_addr, &muid);
 	if (result != 0)
 		return result;

	MM_LOAD_BASE(msgbuf, AIM_GET_OPEN_PS_ID_OFFSET);

	result = mm_map_lpar_memory_region(0, MM_EA2VA((u64) msgbuf), vuart_lpar_addr,
		AIM_GET_OPEN_PS_ID_SIZE, AIM_GET_OPEN_PS_ID_PAGE_SIZE, 0, 0);
	if (result != 0)
		return result;

	memset(msgbuf, 0, AIM_GET_OPEN_PS_ID_SIZE);

	dispmgr_header = (struct dispmgr_header *) msgbuf;
	dispmgr_header->request_id = 1;
	dispmgr_header->function_id = 0x19000;
	dispmgr_header->request_size = sizeof(struct ss_header);
	dispmgr_header->response_size = sizeof(struct ss_header) +
			sizeof(struct ss_aim_get_open_ps_id);

	ss_header = (struct ss_header *) (dispmgr_header + 1);
	memset(ss_header, 0, sizeof(struct ss_header));
	ss_header->packet_id = 0x19005;
	ss_header->function_id = 0x19000;
	ss_header->laid = subject_id[0];
	ss_header->paid = subject_id[1];

	ss_aim_get_open_ps_id = (struct ss_aim_get_open_ps_id *) (ss_header + 1);
	memset(ss_aim_get_open_ps_id, 0, sizeof(struct ss_aim_get_open_ps_id));

	dispmgr_header->request_size += sizeof(struct ss_aim_get_open_ps_id);

	result = lv1_write_virtual_uart(DISPMGR_VUART_PORT, vuart_lpar_addr,
		sizeof(struct dispmgr_header) + dispmgr_header->request_size, &nwritten);
	if (result < 0)
		return result;

	result = vuart_wait_for_rx_data(DISPMGR_VUART_PORT);
	if (result < 0)
		return result;

	result = lv1_read_virtual_uart(DISPMGR_VUART_PORT, vuart_lpar_addr,
		AIM_GET_OPEN_PS_ID_SIZE, &nread);
	if (result < 0)
		return result;

	result = gelic_xmit_data(gelic_bcast_mac_addr, 0xBEEF, msgbuf, nread);
	if (result < 0)
		return result;

	beep(BEEP_DOUBLE);

	lv1_panic(1);

	return 0;

#undef N
}
Example #4
0
int vuart_sysmgr(void)
{
	u64 lpar_addr, muid, nread, nwritten, val;
	void *msgbuf;
	struct sysmgr_header *header;
	struct sysmgr_ctrl_led *ctrl_led;
	struct sysmgr_ring_buzzer *ring_buzzer;
	int result;

	result = lv1_allocate_memory(VUART_SYSMGR_SIZE, VUART_SYSMGR_PAGE_SIZE,
		0, 0, &lpar_addr, &muid);
 	if (result != 0)
 		return result;

	result = mm_insert_htab_entry(MM_EA2VA(VUART_SYSMGR_BASE), lpar_addr, 0);
 	if (result != 0)
 		return result;

	MM_LOAD_BASE(msgbuf, VUART_SYSMGR_OFFSET);

	header = (struct sysmgr_header *) msgbuf;
	memset(header, 0, sizeof(struct sysmgr_header));
	header->version = 1;
	header->size = 16;
	header->payload_size = 16;
	header->sid = SYSMGR_SID_CTRL_LED;

	ctrl_led = (struct sysmgr_ctrl_led *) (header + 1);
	memset(ctrl_led, 0, sizeof(struct sysmgr_ctrl_led));
	ctrl_led->field0 = 1;
	ctrl_led->field1 = 0;
	ctrl_led->field2 = 0xFF;
	ctrl_led->field4 = 0xFF;
	ctrl_led->field5 = 0xFF;

	result = lv1_write_virtual_uart(SYSMGR_VUART_PORT,
		lpar_addr, sizeof(struct sysmgr_header) + sizeof(struct sysmgr_ctrl_led), &nwritten);
	if (result < 0)
		return result;

	header = (struct sysmgr_header *) msgbuf;
	memset(header, 0, sizeof(struct sysmgr_header));
	header->version = 1;
	header->size = 16;
	header->payload_size = 8;
	header->sid = SYSMGR_SID_RING_BUZZER;

	ring_buzzer = (struct sysmgr_ring_buzzer *) (header + 1);
	memset(ring_buzzer, 0, sizeof(struct sysmgr_ring_buzzer));
	ring_buzzer->field1 = 0x29;
	ring_buzzer->field2 = 0x4;
	ring_buzzer->field4 = 0x6;

	result = lv1_write_virtual_uart(SYSMGR_VUART_PORT,
		lpar_addr, sizeof(struct sysmgr_header) + sizeof(struct sysmgr_ring_buzzer), &nwritten);
	if (result < 0)
		return result;

	for (;;)
	{
		result = lv1_get_virtual_uart_param(SYSMGR_VUART_PORT, VUART_PARAM_RX_BYTES, &val);
		if (result < 0)
			return result;

		if (val == 0)
			continue;

		result = lv1_read_virtual_uart(SYSMGR_VUART_PORT, lpar_addr, VUART_SYSMGR_SIZE, &nread);
		if (result < 0)
			return result;

		result = gelic_xmit_data(gelic_bcast_mac_addr, 0xCAFE, msgbuf, nread);
		if (result < 0)
			return result;
	}

	return 0;
}