Ejemplo n.º 1
0
void dom0_shutdown(u8 reason)
{
    switch ( reason )
    {
    case SHUTDOWN_poweroff:
    {
        printk("Domain 0 halted: halting machine.\n");
        machine_halt();
        break; /* not reached */
    }

    case SHUTDOWN_crash:
    {
        debugger_trap_immediate();
        printk("Domain 0 crashed: ");
        maybe_reboot();
        break; /* not reached */
    }

    case SHUTDOWN_reboot:
    {
        printk("Domain 0 shutdown: rebooting machine.\n");
        machine_restart(0);
        break; /* not reached */
    }

    default:
    {
        printk("Domain 0 shutdown (unknown reason %u): ", reason);
        maybe_reboot();
        break; /* not reached */
    }
    }
}  
Ejemplo n.º 2
0
Archivo: shutdown.c Proyecto: Fantu/Xen
void hwdom_shutdown(u8 reason)
{
    switch ( reason )
    {
    case SHUTDOWN_poweroff:
        printk("Hardware Dom%u halted: halting machine\n",
               hardware_domain->domain_id);
        machine_halt();
        break; /* not reached */

    case SHUTDOWN_crash:
        debugger_trap_immediate();
        printk("Hardware Dom%u crashed: ", hardware_domain->domain_id);
#ifdef CONFIG_KEXEC
        kexec_crash();
#endif
        maybe_reboot();
        break; /* not reached */

    case SHUTDOWN_reboot:
        printk("Hardware Dom%u shutdown: rebooting machine\n",
               hardware_domain->domain_id);
        machine_restart(0);
        break; /* not reached */

    case SHUTDOWN_watchdog:
        printk("Hardware Dom%u shutdown: watchdog rebooting machine\n",
               hardware_domain->domain_id);
#ifdef CONFIG_KEXEC
        kexec_crash();
#endif
        machine_restart(0);
        break; /* not reached */

    default:
        printk("Hardware Dom%u shutdown (unknown reason %u): ",
               hardware_domain->domain_id, reason);
        maybe_reboot();
        break; /* not reached */
    }
}  
Ejemplo n.º 3
0
void domain_shutdown(struct domain *d, u8 reason)
{
    struct vcpu *v;

    if ( d->domain_id == 0 )
    {
        extern void machine_restart(char *);
        extern void machine_halt(void);

        debugger_trap_immediate();

        if ( reason == SHUTDOWN_poweroff ) 
        {
            printk("Domain 0 halted: halting machine.\n");
            machine_halt();
        }
        else if ( reason == SHUTDOWN_crash )
        {
            printk("Domain 0 crashed: rebooting machine in 5 seconds.\n");
            watchdog_disable();
            //mdelay(5000);
            machine_restart(0);
        }
        else
        {
            printk("Domain 0 shutdown: rebooting machine.\n");
            machine_restart(0);
        }
    }

    /* Mark the domain as shutting down. */
    d->shutdown_code = reason;

    /* Put every vcpu to sleep, but don't wait (avoids inter-vcpu deadlock). */
    for_each_vcpu ( d, v )
    {
        atomic_inc(&v->pausecnt);
        vcpu_sleep_nosync(v);
    }
Ejemplo n.º 4
0
static void __init __start_xen(void)
{
    memcpy(0, exception_vectors, exception_vectors_end - exception_vectors);
    synchronize_caches(0, exception_vectors_end - exception_vectors);

    ticks_per_usec = timebase_freq / 1000000ULL;

    /* Parse the command-line options. */
    cmdline_parse(xen_cmdline);

    /* we need to be able to identify this CPU early on */
    init_boot_cpu();

    /* We initialise the serial devices very early so we can get debugging. */
    ns16550.io_base = 0x3f8;
    ns16550_init(0, &ns16550);
    ns16550.io_base = 0x2f8;
    ns16550_init(1, &ns16550);
    serial_init_preirq();

    init_console();
    console_start_sync(); /* Stay synchronous for early debugging. */

    rtas_init((void *)oftree);

    memory_init();

    printk("xen_cmdline:  %016lx\n", (ulong)xen_cmdline);
    printk("dom0_cmdline: %016lx\n", (ulong)dom0_cmdline);
    printk("dom0_addr:    %016lx\n", (ulong)dom0_addr);
    printk("dom0_len:     %016lx\n", (ulong)dom0_len);
    printk("initrd_start: %016lx\n", (ulong)initrd_start);
    printk("initrd_len:   %016lx\n", (ulong)initrd_len);

    printk("dom0: %016llx\n", *(unsigned long long *)dom0_addr);

#ifdef OF_DEBUG
    key_ofdump(0);
#endif
    percpu_init_areas();

    init_parea(0);
    cpu_initialize(0);

#ifdef CONFIG_GDB
    initialise_gdb();
    if (opt_earlygdb)
        debugger_trap_immediate();
#endif

    start_of_day();

    acm_init(NULL, 0);

    mpic_setup_this_cpu();

    /* Deal with secondary processors.  */
    if (opt_nosmp || ofd_boot_cpu == -1) {
        printk("nosmp: leaving secondary processors spinning forever\n");
    } else {
        printk("spinning up at most %d total processors ...\n", max_cpus);
        kick_secondary_cpus(max_cpus);
    }

    /* This cannot be called before secondary cpus are marked online.  */
    percpu_free_unused_areas();

    /* Create initial domain 0. */
    dom0 = domain_create(0, 0, DOM0_SSIDREF);
    if (dom0 == NULL)
        panic("Error creating domain 0\n");

    /* The Interrupt Controller will route everything to CPU 0 so we
     * need to make sure Dom0's vVCPU 0 is pinned to the CPU */
    dom0->vcpu[0]->cpu_affinity = cpumask_of_cpu(0);

    dom0->is_privileged = 1;

    /* scrub_heap_pages() requires IRQs enabled, and we're post IRQ setup... */
    local_irq_enable();
    /* Scrub RAM that is still free and so may go to an unprivileged domain. */
    scrub_heap_pages();

    if ((dom0_addr == 0) || (dom0_len == 0))
        panic("No domain 0 found.\n");

    if (construct_dom0(dom0, dom0_addr, dom0_len,
                       initrd_start, initrd_len,
                       dom0_cmdline) != 0) {
        panic("Could not set up DOM0 guest OS\n");
    }

    init_xenheap_pages(ALIGN_UP(dom0_addr, PAGE_SIZE),
                       ALIGN_DOWN(dom0_addr + dom0_len, PAGE_SIZE));
    if (initrd_start)
        init_xenheap_pages(ALIGN_UP(initrd_start, PAGE_SIZE),
                           ALIGN_DOWN(initrd_start + initrd_len, PAGE_SIZE));

    init_trace_bufs();

    console_endboot();

    /* Hide UART from DOM0 if we're using it */
    serial_endboot();

    console_end_sync();

    domain_unpause_by_systemcontroller(dom0);
#ifdef DEBUG_IPI
    ipi_torture_test();
#endif
    startup_cpu_idle_loop();
}