int arch_board_reset(void) { #if 0 void *wdt_ptr = (void *)vmm_host_iomap(EXYNOS4_PA_WATCHDOG, 0x100); if (wdt_ptr) { u32 perir_reg; void *cmu_ptr = (void *)vmm_host_iomap(EXYNOS4_PA_CMU + EXYNOS4_CLKGATE_IP_PERIR, sizeof(perir_reg)); if (cmu_ptr) { vmm_printf("%s: CMU reg is at 0x%08x + 0x%08x\n", __func__, EXYNOS4_PA_CMU, EXYNOS4_CLKGATE_IP_PERIR); vmm_writel(0, wdt_ptr + S3C2410_WTCON); /* enable the WDT clock if it is not already enabled */ perir_reg = vmm_readl(cmu_ptr); vmm_printf("%s: CMU PERIR reg is 0x%08x\n", __func__, perir_reg); if (!(perir_reg & (1 << 14))) { perir_reg |= (1 << 14); vmm_printf ("%s: enabling WDT in PERIR: writing 0x%08x\n", __func__, perir_reg); vmm_writel(perir_reg, cmu_ptr); } vmm_writel(0x80, wdt_ptr + S3C2410_WTDAT); vmm_writel(0x80, wdt_ptr + S3C2410_WTCNT); vmm_writel(0x2025, wdt_ptr + S3C2410_WTCON); vmm_host_iounmap((virtual_addr_t) cmu_ptr, sizeof(perir_reg)); } vmm_host_iounmap((virtual_addr_t) wdt_ptr, 0x100); } #else void *pmu_ptr = (void *)vmm_host_iomap(EXYNOS4_PA_PMU + EXYNOS_SWRESET, sizeof(u32)); if (pmu_ptr) { /* Trigger a Software reset */ vmm_writel(0x1, pmu_ptr); vmm_host_iounmap((virtual_addr_t) pmu_ptr, sizeof(u32)); } #endif vmm_mdelay(500); vmm_printf("%s: failed\n", __func__); return VMM_EFAIL; }
int scsi_test_unit_ready(struct scsi_request *srb, struct scsi_transport *tr, void *priv) { int rc = VMM_EFAIL, retries = 10; unsigned char *data; unsigned long datalen; if (!srb || !tr || !tr->transport) { return VMM_EINVALID; } data = srb->data; datalen = srb->datalen; do { memset(&srb->cmd, 0, sizeof(srb->cmd)); srb->cmd[0] = SCSI_TST_U_RDY; srb->cmd[1] = srb->lun << 5; srb->data = NULL; srb->datalen = 0; srb->cmdlen = 12; rc = tr->transport(srb, tr, priv); if (rc == VMM_OK) { break; } rc = scsi_request_sense(srb, tr, priv); if (rc != VMM_OK) { return rc; } /* * Check the Key Code Qualifier, if it matches * "Not Ready - medium not present" * (the sense Key equals 0x2 and the ASC is 0x3a) * return immediately as the medium being absent won't change * unless there is a user action. */ if ((srb->sense_buf[2] == 0x02) && (srb->sense_buf[12] == 0x3a)) { rc = VMM_ENODEV; break; } vmm_mdelay(100); rc = VMM_EFAIL; } while (retries--); srb->data = data; srb->datalen = datalen; return rc; }
int arch_board_shutdown(void) { /* FIXME: For now we do a soft reset */ void *pmu_ptr = (void *)vmm_host_iomap(EXYNOS4_PA_PMU + EXYNOS_SWRESET, sizeof(u32)); if (pmu_ptr) { /* Trigger a Software reset */ vmm_writel(0x1, pmu_ptr); vmm_host_iounmap((virtual_addr_t) pmu_ptr, sizeof(u32)); } vmm_mdelay(500); vmm_printf("%s: failed\n", __func__); return VMM_EFAIL; }
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; } } } }