ia64/xen-unstable

annotate xen/arch/x86/tboot.c @ 18806:ed8524f4a044

x86: Re-initialise HPET on resume from S3

Signed-off-by: Guanqun Lu <guanqun.lu@intel.com>
Signed-off-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Nov 18 15:55:14 2008 +0000 (2008-11-18)
parents e265878e8f65
children ef156b933aad
rev   line source
keir@16274 1 #include <xen/config.h>
keir@16274 2 #include <xen/init.h>
keir@16274 3 #include <xen/types.h>
keir@16274 4 #include <xen/lib.h>
keir@16274 5 #include <xen/sched.h>
keir@16274 6 #include <asm/fixmap.h>
keir@16274 7 #include <asm/page.h>
keir@16274 8 #include <asm/processor.h>
keir@16274 9 #include <asm/tboot.h>
keir@16274 10
keir@16274 11 /* tboot=<physical address of shared page> */
keir@16274 12 static char opt_tboot[20] = "";
keir@16274 13 string_param("tboot", opt_tboot);
keir@16274 14
keir@16274 15 /* Global pointer to shared data; NULL means no measured launch. */
keir@16274 16 tboot_shared_t *g_tboot_shared;
keir@16274 17
keir@16274 18 static const uuid_t tboot_shared_uuid = TBOOT_SHARED_UUID;
keir@16274 19
keir@16274 20 void __init tboot_probe(void)
keir@16274 21 {
keir@16274 22 tboot_shared_t *tboot_shared;
keir@16274 23 unsigned long p_tboot_shared;
keir@16274 24
keir@16274 25 /* Look for valid page-aligned address for shared page. */
keir@16274 26 p_tboot_shared = simple_strtoul(opt_tboot, NULL, 0);
keir@16274 27 if ( (p_tboot_shared == 0) || ((p_tboot_shared & ~PAGE_MASK) != 0) )
keir@16274 28 return;
keir@16274 29
keir@16274 30 /* Map and check for tboot UUID. */
keir@16274 31 set_fixmap(FIX_TBOOT_SHARED_BASE, p_tboot_shared);
keir@16274 32 tboot_shared = (tboot_shared_t *)fix_to_virt(FIX_TBOOT_SHARED_BASE);
keir@16274 33 if ( memcmp(&tboot_shared_uuid, (uuid_t *)tboot_shared, sizeof(uuid_t)) )
keir@16274 34 return;
keir@16274 35
keir@16274 36 g_tboot_shared = tboot_shared;
keir@16274 37 printk("TBOOT: found shared page at phys addr %lx:\n", p_tboot_shared);
keir@16274 38 printk(" version: %d\n", tboot_shared->version);
keir@16274 39 printk(" log_addr: 0x%08x\n", tboot_shared->log_addr);
keir@16274 40 printk(" shutdown_entry32: 0x%08x\n", tboot_shared->shutdown_entry32);
keir@16274 41 printk(" shutdown_entry64: 0x%08x\n", tboot_shared->shutdown_entry64);
keir@16274 42 printk(" shutdown_type: %d\n", tboot_shared->shutdown_type);
keir@16274 43 printk(" s3_tb_wakeup_entry: 0x%08x\n", tboot_shared->s3_tb_wakeup_entry);
keir@16274 44 printk(" s3_k_wakeup_entry: 0x%08x\n", tboot_shared->s3_k_wakeup_entry);
keir@16274 45 printk(" &acpi_sinfo: 0x%p\n", &tboot_shared->acpi_sinfo);
keir@16512 46 if ( tboot_shared->version >= 0x02 )
keir@16512 47 {
keir@16512 48 printk(" tboot_base: 0x%08x\n", tboot_shared->tboot_base);
keir@16512 49 printk(" tboot_size: 0x%x\n", tboot_shared->tboot_size);
keir@16512 50 }
keir@16274 51 }
keir@16274 52
keir@16274 53 void tboot_shutdown(uint32_t shutdown_type)
keir@16274 54 {
keir@16512 55 uint32_t map_base, map_size;
keir@16512 56 int err;
keir@16512 57
keir@16274 58 g_tboot_shared->shutdown_type = shutdown_type;
keir@16274 59
keir@16274 60 local_irq_disable();
keir@16274 61
keir@16512 62 /* Create identity map for tboot shutdown code. */
keir@16512 63 if ( g_tboot_shared->version >= 0x02 )
keir@16512 64 {
keir@16512 65 map_base = PFN_DOWN(g_tboot_shared->tboot_base);
keir@16512 66 map_size = PFN_UP(g_tboot_shared->tboot_size);
keir@16512 67 }
keir@16512 68 else
keir@16512 69 {
keir@16512 70 map_base = 0;
keir@16512 71 map_size = PFN_UP(0xa0000);
keir@16512 72 }
keir@16512 73
keir@16512 74 err = map_pages_to_xen(map_base << PAGE_SHIFT, map_base, map_size,
keir@16512 75 __PAGE_HYPERVISOR);
keir@16512 76 if ( err != 0 )
keir@16512 77 {
keir@16512 78 printk("error (0x%x) mapping tboot pages (mfns) @ 0x%x, 0x%x\n", err,
keir@16512 79 map_base, map_size);
keir@16512 80 return;
keir@16512 81 }
keir@16512 82
keir@16274 83 write_ptbase(idle_vcpu[0]);
keir@16274 84
keir@16274 85 #ifdef __x86_64__
keir@16274 86 asm volatile ( "call *%%rdi" :: "D" (g_tboot_shared->shutdown_entry64) );
keir@16274 87 #else
keir@16274 88 asm volatile ( "call *%0" :: "r" (g_tboot_shared->shutdown_entry32) );
keir@16274 89 #endif
keir@16274 90
keir@16274 91 BUG(); /* should not reach here */
keir@16274 92 }
keir@16274 93
keir@16274 94 int tboot_in_measured_env(void)
keir@16274 95 {
keir@16274 96 return (g_tboot_shared != NULL);
keir@16274 97 }
keir@16512 98
keir@17738 99 int tboot_in_range(paddr_t start, paddr_t end)
keir@17729 100 {
keir@17729 101 if ( g_tboot_shared == NULL || g_tboot_shared->version < 0x02 )
keir@17729 102 return 0;
keir@17729 103
keir@17738 104 start = max_t(paddr_t, start, g_tboot_shared->tboot_base);
keir@17738 105 end = min_t(paddr_t, end,
keir@17729 106 g_tboot_shared->tboot_base + g_tboot_shared->tboot_size);
keir@17729 107
keir@17729 108 return start < end;
keir@17729 109 }
keir@17729 110
keir@16512 111 /*
keir@16512 112 * Local variables:
keir@16512 113 * mode: C
keir@16512 114 * c-set-style: "BSD"
keir@16512 115 * c-basic-offset: 4
keir@16512 116 * tab-width: 4
keir@16512 117 * indent-tabs-mode: nil
keir@16512 118 * End:
keir@16512 119 */