Beispiel #1
0
int __init arch_board_final_init(void)
{
	int rc;
	struct vmm_devtree_node *node;
	struct vmm_chardev * cdev;
#if defined(CONFIG_RTC)
	struct vmm_rtcdev * rdev;
#endif

	/* All VMM API's are available here */
	/* We can register a Board specific resource here */

#if 0 /* FIXME: */
	/* Map control registers */
	ca15x4_sys_base = vmm_host_iomap(VEXPRESS_SYS_BASE, 0x1000);

	/* Unlock Lockable registers */
	vmm_writel(VEXPRESS_SYS_LOCKVAL, 
		   (void *)(ca15x4_sys_base + VEXPRESS_SYS_LOCK_OFFSET));
#endif

	/* Do Probing using device driver framework */
	node = vmm_devtree_getnode(VMM_DEVTREE_PATH_SEPARATOR_STRING
				   VMM_DEVTREE_HOSTINFO_NODE_NAME
				   VMM_DEVTREE_PATH_SEPARATOR_STRING "nbridge");

	if (!node) {
		return VMM_ENOTAVAIL;
	}

	rc = vmm_devdrv_probe(node, NULL);
	if (rc) {
		return rc;
	}

	/* Find uart0 character device and 
	 * set it as vmm_stdio character device */
	if ((cdev = vmm_chardev_find("uart0"))) {
		vmm_stdio_change_indevice(cdev);
		vmm_stdio_change_outdevice(cdev);
	}

	/* Syncup wall-clock time from rtc0 */
#if defined(CONFIG_RTC)
	if ((rdev = vmm_rtcdev_find("rtc0"))) {
		if ((rc = vmm_rtcdev_sync_wallclock(rdev))) {
			return rc;
		}
	}
#endif

	return VMM_OK;
}
Beispiel #2
0
int cmd_rtcdev_sync_device(struct vmm_chardev *cdev, const char * name)
{
	int rc;
	struct vmm_rtcdev * rtc = vmm_rtcdev_find(name);

	if (!rtc) {
		vmm_cprintf(cdev, "Error: cannot find rtc %s\n", name);
		return VMM_EFAIL;
	}

	rc = vmm_rtcdev_sync_device(rtc);
	if (rc) {
		vmm_cprintf(cdev, "Error: sync_device failed for rtc %s\n", 
									 name);
		return rc;
	}

	return VMM_OK;
}
Beispiel #3
0
static void system_init_work(struct vmm_work *work)
{
#define BOOTCMD_WIDTH		256
	int ret;
	char bcmd[BOOTCMD_WIDTH];
	const char *str;
	u32 c, freed;
	struct vmm_chardev *cdev;
#if defined(CONFIG_RTC)
	struct vmm_rtcdev *rdev;
#endif
	struct vmm_devtree_node *node, *node1;

	/* Initialize command manager */
	vmm_printf("Initialize Command Manager\n");
	ret = vmm_cmdmgr_init();
	if (ret) {
		vmm_panic("Error %d\n", ret);
	}

	/* Initialize device driver framework */
	vmm_printf("Initialize Device Driver Framework\n");
	ret = vmm_devdrv_init();
	if (ret) {
		vmm_panic("Error %d\n", ret);
	}

	/* Initialize device emulation framework */
	vmm_printf("Initialize Device Emulation Framework\n");
	ret = vmm_devemu_init();
	if (ret) {
		vmm_panic("Error %d\n", ret);
	}

	/* Initialize character device framework */
	vmm_printf("Initialize Character Device Framework\n");
	ret = vmm_chardev_init();
	if (ret) {
		vmm_panic("Error %d\n", ret);
	}

	/* Initialize virtual serial port framework */
	vmm_printf("Initialize Virtual Serial Port Framework\n");
	ret = vmm_vserial_init();
	if (ret) {
		vmm_panic("Error %d\n", ret);
	}

#if defined(CONFIG_SMP)
	/* Poll for all present CPUs to become online */
	/* Note: There is a timeout of 1 second */
	/* Note: The modules might use SMP IPIs or might have per-cpu context 
	 * so, we do this before vmm_modules_init() in-order to make sure that 
	 * correct number of online CPUs are visible to all modules.
	 */
	ret = 1000;
	while(ret--) {
		int all_cpu_online = 1;

		for_each_present_cpu(c) {
			if (!vmm_cpu_online(c)) {
				all_cpu_online = 0;
			}
		}

		if (all_cpu_online) {
			break;
		}

		vmm_mdelay(1);
	}
#endif

	/* Initialize hypervisor modules */
	vmm_printf("Initialize Hypervisor Modules\n");
	ret = vmm_modules_init();
	if (ret) {
		vmm_panic("Error %d\n", ret);
	}

	/* Initialize cpu final */
	vmm_printf("Initialize CPU Final\n");
	ret = arch_cpu_final_init();
	if (ret) {
		vmm_panic("Error %d\n", ret);
	}

	/* Intialize board final */
	vmm_printf("Initialize Board Final\n");
	ret = arch_board_final_init();
	if (ret) {
		vmm_panic("Error %d\n", ret);
	}

	/* Print status of present host CPUs */
	for_each_present_cpu(c) {
		if (vmm_cpu_online(c)) {
			vmm_printf("CPU%d: Online\n", c);
		} else {
			vmm_printf("CPU%d: Possible\n", c);
		}
	}
	vmm_printf("Brought Up %d CPUs\n", vmm_num_online_cpus());

	/* Free init memory */
	vmm_printf("Freeing init memory: ");
	freed = vmm_host_free_initmem();
	vmm_printf("%dK\n", freed);

	/* Process attributes in chosen node */
	node = vmm_devtree_getnode(VMM_DEVTREE_PATH_SEPARATOR_STRING
				   VMM_DEVTREE_CHOSEN_NODE_NAME);
	if (node) {
		/* Find character device based on console attribute */
		str = vmm_devtree_attrval(node, VMM_DEVTREE_CONSOLE_ATTR_NAME);
		if (!(cdev = vmm_chardev_find(str))) {
			if ((node1 = vmm_devtree_getnode(str))) {
				cdev = vmm_chardev_find(node1->name);
			}
		}
		/* Set chosen console device as stdio device */
		if (cdev) {
			vmm_printf("Change stdio device to %s\n", cdev->name);
			vmm_stdio_change_device(cdev);
		}

#if defined(CONFIG_RTC)
		/* Find rtc device based on rtcdev attribute */
		str = vmm_devtree_attrval(node, VMM_DEVTREE_RTCDEV_ATTR_NAME);
		if (!(rdev = vmm_rtcdev_find(str))) {
			if ((node1 = vmm_devtree_getnode(str))) {
				rdev = vmm_rtcdev_find(node1->name);
			}
		}
		/* Syncup wallclock time with chosen rtc device */
		if (rdev) {
			ret = vmm_rtcdev_sync_wallclock(rdev);
			vmm_printf("Syncup wallclock using %s", rdev->name);
			if (ret) {
				vmm_printf("(error %d)", ret);
			}
			vmm_printf("\n");
		}
#endif

		/* Execute boot commands */
		str = vmm_devtree_attrval(node, VMM_DEVTREE_BOOTCMD_ATTR_NAME);
		if (str) {
			c = vmm_devtree_attrlen(node, VMM_DEVTREE_BOOTCMD_ATTR_NAME);
			while (c) {
#if defined(CONFIG_VERBOSE_MODE)
				/* Print boot command */
				vmm_printf("bootcmd: %s\n", str);
#endif
				/* Execute boot command */
				strlcpy(bcmd, str, sizeof(bcmd));
				cdev = vmm_stdio_device();
				vmm_cmdmgr_execute_cmdstr(cdev, bcmd, NULL);
				/* Next boot command */
				c -= strlen(str) + 1;
				str += strlen(str) + 1;
			}
		}
	}
}
Beispiel #4
0
int cmd_rtcdev_set_time(struct vmm_chardev *cdev, const char * name,
			int targc, char **targv)
{
	int rc;
	char * s;
	struct vmm_rtc_time tm;
	struct vmm_rtcdev * rtc = vmm_rtcdev_find(name);

	if (!rtc) {
		vmm_cprintf(cdev, "Error: cannot find rtc %s\n", name);
		return VMM_EFAIL;
	}

	s = targv[0];
	rc = 0;
	tm.tm_hour = 0;
	tm.tm_min = 0;
	tm.tm_sec = 0;
	while (*s) {
		if (*s == ':') {
			rc++;
		} else if ('0' <= *s && *s <= '9') {
			switch(rc) {
			case 0:
				tm.tm_hour = tm.tm_hour * 10 + (*s - '0');
				break;
			case 1:
				tm.tm_min = tm.tm_min * 10 + (*s - '0');
				break;
			case 2:
				tm.tm_sec = tm.tm_sec * 10 + (*s - '0');
				break;
			default:
				break;
			};
		}
		s++;
	}
	rc = 0;
	tm.tm_mday = vmm_str2int(targv[1], 10);
	vmm_str2lower(targv[2]);
	if (vmm_strcmp(targv[2], "jan") == 0) {
		tm.tm_mon = 0;
	} else if (vmm_strcmp(targv[2], "feb") == 0) {
		tm.tm_mon = 1;
	} else if (vmm_strcmp(targv[2], "mar") == 0) {
		tm.tm_mon = 2;
	} else if (vmm_strcmp(targv[2], "apr") == 0) {
		tm.tm_mon = 3;
	} else if (vmm_strcmp(targv[2], "may") == 0) {
		tm.tm_mon = 4;
	} else if (vmm_strcmp(targv[2], "jun") == 0) {
		tm.tm_mon = 5;
	} else if (vmm_strcmp(targv[2], "jul") == 0) {
		tm.tm_mon = 6;
	} else if (vmm_strcmp(targv[2], "aug") == 0) {
		tm.tm_mon = 7;
	} else if (vmm_strcmp(targv[2], "sep") == 0) {
		tm.tm_mon = 8;
	} else if (vmm_strcmp(targv[2], "oct") == 0) {
		tm.tm_mon = 9;
	} else if (vmm_strcmp(targv[2], "nov") == 0) {
		tm.tm_mon = 10;
	} else if (vmm_strcmp(targv[2], "dec") == 0) {
		tm.tm_mon = 11;
	} else {
		tm.tm_mon = vmm_str2int(targv[2], 10);
	}
	tm.tm_year = vmm_str2int(targv[3], 10) - 1900;

	if (!vmm_rtc_valid_tm(&tm)) {
		vmm_cprintf(cdev, "Error: invalid date-time\n");
		return VMM_EFAIL;
	}

	rc = vmm_rtcdev_set_time(rtc, &tm);
	if (rc) {
		vmm_cprintf(cdev, "Error: set_time failed for rtc %s\n", name);
		return rc;
	}

	return VMM_OK;
}
Beispiel #5
0
int cmd_rtcdev_get_time(struct vmm_chardev *cdev, const char * name)
{
	int rc;
	struct vmm_rtc_time tm;
	struct vmm_rtcdev * rtc = vmm_rtcdev_find(name);

	if (!rtc) {
		vmm_cprintf(cdev, "Error: cannot find rtc %s\n", name);
		return VMM_EFAIL;
	}

	rc = vmm_rtcdev_get_time(rtc, &tm);
	if (rc) {
		vmm_cprintf(cdev, "Error: get_time failed for rtc %s\n", name);
		return rc;
	}

	switch (tm.tm_wday) {
	case 0:
		vmm_cprintf(cdev, "%s ", "Sun");
		break;
	case 1:
		vmm_cprintf(cdev, "%s ", "Mon");
		break;
	case 2:
		vmm_cprintf(cdev, "%s ", "Tue");
		break;
	case 3:
		vmm_cprintf(cdev, "%s ", "Wed");
		break;
	case 4:
		vmm_cprintf(cdev, "%s ", "Thu");
		break;
	case 5:
		vmm_cprintf(cdev, "%s ", "Fri");
		break;
	case 6:
		vmm_cprintf(cdev, "%s ", "Sat");
		break;
	default:
		vmm_cprintf(cdev, "Error: Invalid day of week\n");
	};

	switch (tm.tm_mon) {
	case 0:
		vmm_cprintf(cdev, "%s ", "Jan");
		break;
	case 1:
		vmm_cprintf(cdev, "%s ", "Feb");
		break;
	case 2:
		vmm_cprintf(cdev, "%s ", "Mar");
		break;
	case 3:
		vmm_cprintf(cdev, "%s ", "Apr");
		break;
	case 4:
		vmm_cprintf(cdev, "%s ", "May");
		break;
	case 5:
		vmm_cprintf(cdev, "%s ", "Jun");
		break;
	case 6:
		vmm_cprintf(cdev, "%s ", "Jul");
		break;
	case 7:
		vmm_cprintf(cdev, "%s ", "Aug");
		break;
	case 8:
		vmm_cprintf(cdev, "%s ", "Sep");
		break;
	case 9:
		vmm_cprintf(cdev, "%s ", "Oct");
		break;
	case 10:
		vmm_cprintf(cdev, "%s ", "Nov");
		break;
	case 11:
		vmm_cprintf(cdev, "%s ", "Dec");
		break;
	default:
		vmm_cprintf(cdev, "Error: Invalid month\n");
	};

	vmm_cprintf(cdev, "%2d %d:%d:%d UTC %d", tm.tm_mday, 
				tm.tm_hour, tm.tm_min, tm.tm_sec, 
				tm.tm_year + 1900);

	vmm_cprintf(cdev, "\n");

	return VMM_OK;
}