xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: <stefano.stabellini@eu.citrix.com>
To: xen-devel@lists.xensource.com
Cc: Tim.Deegan@citrix.com, Ian Campbell <ian.campbell@citrix.com>,
	JBeulich@suse.com, stefano.stabellini@eu.citrix.com
Subject: [PATCH v4 19/25] arm: early setup code
Date: Mon, 9 Jan 2012 17:59:55 +0000	[thread overview]
Message-ID: <1326132001-21251-19-git-send-email-stefano.stabellini@eu.citrix.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1201091752280.3150@kaball-desktop>

From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
---
 xen/arch/arm/setup.c |  206 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 206 insertions(+), 0 deletions(-)
 create mode 100644 xen/arch/arm/setup.c

diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
new file mode 100644
index 0000000..33c880e
--- /dev/null
+++ b/xen/arch/arm/setup.c
@@ -0,0 +1,206 @@
+/*
+ * xen/arch/arm/setup.c
+ *
+ * Early bringup code for an ARMv7-A with virt extensions.
+ *
+ * Tim Deegan <tim@xen.org>
+ * Copyright (c) 2011 Citrix Systems.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <xen/config.h>
+#include <xen/compile.h>
+#include <xen/domain_page.h>
+#include <xen/types.h>
+#include <xen/string.h>
+#include <xen/serial.h>
+#include <xen/sched.h>
+#include <xen/console.h>
+#include <xen/init.h>
+#include <xen/irq.h>
+#include <xen/mm.h>
+#include <xen/softirq.h>
+#include <xen/keyhandler.h>
+#include <xen/cpu.h>
+#include <asm/page.h>
+#include <asm/current.h>
+#include <asm/setup.h>
+#include "gic.h"
+
+/* maxcpus: maximum number of CPUs to activate. */
+static unsigned int __initdata max_cpus = NR_CPUS;
+
+/* Xen stack for bringing up the first CPU. */
+unsigned char init_stack[STACK_SIZE] __attribute__((__aligned__(STACK_SIZE)));
+
+extern char __init_begin[], __init_end[], __bss_start[];
+
+static __attribute_used__ void init_done(void)
+{
+	/* TODO: free (or page-protect) the init areas.
+	   memset(__init_begin, 0xcc, __init_end - __init_begin);
+	   free_xen_data(__init_begin, __init_end);
+	*/
+    printk("Freed %ldkB init memory.\n", (long)(__init_end-__init_begin)>>10);
+
+    startup_cpu_idle_loop();
+}
+
+static void __init init_idle_domain(void)
+{
+        scheduler_init();
+        set_current(idle_vcpu[0]);
+        this_cpu(curr_vcpu) = current;
+        /* TODO: setup_idle_pagetable(); */
+}
+
+void __init start_xen(unsigned long boot_phys_offset,
+                      unsigned long arm_type,
+                      unsigned long atag_paddr)
+
+{
+    int i;
+
+    setup_pagetables(boot_phys_offset);
+
+#ifdef EARLY_UART_ADDRESS
+    /* Map the UART */
+    /* TODO Need to get device tree or command line for UART address */
+    set_fixmap(FIXMAP_CONSOLE, EARLY_UART_ADDRESS >> PAGE_SHIFT, DEV_SHARED);
+    pl011_init(0, FIXMAP_ADDR(FIXMAP_CONSOLE));
+    console_init_preirq();
+#endif
+
+    set_current((struct vcpu *)0xfffff000); /* debug sanity */
+    idle_vcpu[0] = current;
+    set_processor_id(0); /* needed early, for smp_processor_id() */
+
+    /* TODO: smp_prepare_boot_cpu(void) */
+    cpumask_set_cpu(smp_processor_id(), &cpu_online_map);
+    cpumask_set_cpu(smp_processor_id(), &cpu_present_map);
+
+    smp_prepare_cpus(max_cpus);
+
+    init_xen_time();
+
+    /* TODO: This needs some thought, as well as device-tree mapping.
+     * For testing, assume that the whole xenheap is contiguous in RAM */
+    setup_xenheap_mappings(0x8000000, 0x40000); /* 1 GB @ 512GB */
+    /* Must pass a single mapped page for populating bootmem_region_list. */
+    init_boot_pages(pfn_to_paddr(xenheap_mfn_start),
+                    pfn_to_paddr(xenheap_mfn_start+1));
+
+    /* Add non-xenheap memory */
+    init_boot_pages(0x8040000000, 0x80c0000000); /* 2 GB @513GB */
+
+    /* TODO Make sure Xen's own pages aren't added
+     *     -- the memory above doesn't include our relocation target.  */
+    /* TODO Handle payloads too */
+
+    /* TODO Need to find actual memory, for now use 4GB at 512GB */
+    setup_frametable_mappings(0x8000000000ULL, 0x8100000000UL);
+
+    /* Add xenheap memory */
+    init_xenheap_pages(pfn_to_paddr(xenheap_mfn_start+1),
+                       pfn_to_paddr(xenheap_mfn_end));
+
+    end_boot_allocator();
+
+    /* Setup Hyp vector base */
+    WRITE_CP32((uint32_t) hyp_traps_vector, HVBAR);
+    printk("Set hyp vector base to %"PRIx32" (expected %p)\n",
+           READ_CP32(HVBAR), hyp_traps_vector);
+
+    /* Setup Stage 2 address translation */
+    /* SH0=00, ORGN0=IRGN0=01
+     * SL0=01 (Level-1)
+     * T0SZ=(1)1000 = -8 (40 bit physical addresses)
+     */
+    WRITE_CP32(0x80002558, VTCR); isb();
+
+    softirq_init();
+    tasklet_subsys_init();
+
+    init_IRQ();
+
+    gic_init();
+
+    gic_route_irqs();
+
+    init_maintenance_interrupt();
+    init_timer_interrupt();
+
+    timer_init();
+
+    init_idle_domain();
+
+    rcu_init();
+
+    local_irq_enable();
+
+    initialize_keytable();
+
+    console_init_postirq();
+
+    do_presmp_initcalls();
+
+    for_each_present_cpu ( i )
+    {
+        if ( (num_online_cpus() < max_cpus) && !cpu_online(i) )
+        {
+            int ret = cpu_up(i);
+            if ( ret != 0 )
+                printk("Failed to bring up CPU %u (error %d)\n", i, ret);
+        }
+    }
+
+    printk("Brought up %ld CPUs\n", (long)num_online_cpus());
+    /* TODO: smp_cpus_done(); */
+
+    do_initcalls();
+
+    /* Create initial domain 0. */
+    dom0 = domain_create(0, 0, 0);
+    if ( dom0 == NULL )
+            printk("domain_create failed\n");
+    if ( (dom0 == NULL) || (alloc_dom0_vcpu0() == NULL) )
+            panic("Error creating domain 0\n");
+
+    dom0->is_privileged = 1;
+    dom0->target = NULL;
+
+    if ( construct_dom0(dom0) != 0)
+            panic("Could not set up DOM0 guest OS\n");
+
+    /* Scrub RAM that is still free and so may go to an unprivileged domain.
+       XXX too slow in simulator
+       scrub_heap_pages();
+    */
+
+    console_endboot();
+
+    /* Hide UART from DOM0 if we're using it */
+    serial_endboot();
+
+    domain_unpause_by_systemcontroller(dom0);
+
+    reset_stack_and_jump(init_done);
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
-- 
1.7.2.5

  parent reply	other threads:[~2012-01-09 17:59 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-09 17:58 [PATCH v4 00/25] xen: ARMv7 with virtualization extensions Stefano Stabellini
2012-01-09 17:59 ` [PATCH v4 01/25] Move cpufreq option parsing to cpufreq.c stefano.stabellini
2012-01-09 17:59 ` [PATCH v4 02/25] Include some header files that are not automatically included on all archs stefano.stabellini
2012-01-09 17:59 ` [PATCH v4 03/25] A collection of fixes to Xen common files stefano.stabellini
2012-01-09 17:59 ` [PATCH v4 04/25] xen: implement an signed 64 bit division helper function stefano.stabellini
2012-01-10 17:15   ` Ian Jackson
2012-01-09 17:59 ` [PATCH v4 05/25] Introduce clear_user and clear_guest stefano.stabellini
2012-01-09 17:59 ` [PATCH v4 06/25] libelf-loader: introduce elf_load_image stefano.stabellini
2012-01-10 10:02   ` Jan Beulich
2012-01-10 13:49     ` Stefano Stabellini
2012-01-09 17:59 ` [PATCH v4 07/25] xen/common/Makefile: introduce HAS_CPUFREQ, HAS_PCI, HAS_PASSTHROUGH, HAS_NS16550, HAS_KEXEC stefano.stabellini
2012-01-09 17:59 ` [PATCH v4 08/25] arm: compile tmem stefano.stabellini
2012-01-09 17:59 ` [PATCH v4 09/25] arm: header files stefano.stabellini
2012-01-09 17:59 ` [PATCH v4 10/25] arm: bit manipulation, copy and division libraries stefano.stabellini
2012-01-10  8:32   ` Ian Campbell
2012-01-10 11:22     ` Stefano Stabellini
2012-01-10 11:29       ` Ian Campbell
2012-01-09 17:59 ` [PATCH v4 11/25] arm: entry.S and head.S stefano.stabellini
2012-01-09 17:59 ` [PATCH v4 12/25] arm: domain stefano.stabellini
2012-01-09 17:59 ` [PATCH v4 13/25] arm: domain_build stefano.stabellini
2012-01-09 18:29   ` David Vrabel
2012-01-10  9:01     ` Ian Campbell
2012-01-10 11:18     ` Stefano Stabellini
2012-01-09 17:59 ` [PATCH v4 14/25] arm: driver for CoreLink GIC-400 Generic Interrupt Controller stefano.stabellini
2012-01-10 10:04   ` Ian Campbell
2012-01-10 11:13     ` Stefano Stabellini
2012-01-09 17:59 ` [PATCH v4 15/25] arm: mmio handlers stefano.stabellini
2012-01-09 17:59 ` [PATCH v4 16/25] arm: irq stefano.stabellini
2012-01-09 17:59 ` [PATCH v4 17/25] arm: mm and p2m stefano.stabellini
2012-01-09 17:59 ` stefano.stabellini [this message]
2012-01-09 17:59 ` [PATCH v4 20/25] arm: shutdown, smp and smpboot stefano.stabellini
2012-01-09 17:59 ` [PATCH v4 21/25] arm: driver for the generic timer for ARMv7 stefano.stabellini
2012-01-09 17:59 ` [PATCH v4 22/25] arm: trap handlers stefano.stabellini
2012-01-09 17:59 ` [PATCH v4 23/25] arm: vgic emulation stefano.stabellini
2012-01-09 18:25   ` David Vrabel
2012-01-10  9:00     ` Ian Campbell
2012-01-10 11:17     ` Stefano Stabellini
2012-01-09 18:00 ` [PATCH v4 24/25] arm: vtimer stefano.stabellini
2012-01-09 18:00 ` [PATCH v4 25/25] arm: makefiles stefano.stabellini
2012-01-10 10:06 ` [PATCH v4 00/25] xen: ARMv7 with virtualization extensions Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1326132001-21251-19-git-send-email-stefano.stabellini@eu.citrix.com \
    --to=stefano.stabellini@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --cc=Tim.Deegan@citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).