Skip to content

Commit

Permalink
xen-console: add save/restore
Browse files Browse the repository at this point in the history
Add code to:

 1. Deal with the console page being canonicalized.  During save, the
    console's mfn in the start_info structure is canonicalized to a pfn.
    In order to deal with that, we always use a copy of the pfn and
    indirect off that all the time.  However, we fall back to using the
    mfn if the pfn hasn't been initialized yet.

 2. Restore the console event channel, and rebind it to the existing irq.

Signed-off-by: Jeremy Fitzhardinge <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
  • Loading branch information
jsgf authored and KAGA-KOKO committed May 27, 2008
1 parent 0f2287a commit 6b9b732
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
25 changes: 21 additions & 4 deletions drivers/char/hvc_xen.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,14 @@ static int xencons_irq;

/* ------------------------------------------------------------------ */

static unsigned long console_pfn = ~0ul;

static inline struct xencons_interface *xencons_interface(void)
{
return mfn_to_virt(xen_start_info->console.domU.mfn);
if (console_pfn == ~0ul)
return mfn_to_virt(xen_start_info->console.domU.mfn);
else
return __va(console_pfn << PAGE_SHIFT);
}

static inline void notify_daemon(void)
Expand Down Expand Up @@ -101,20 +106,32 @@ static int __init xen_init(void)
{
struct hvc_struct *hp;

if (!is_running_on_xen())
return 0;
if (!is_running_on_xen() ||
is_initial_xendomain() ||
!xen_start_info->console.domU.evtchn)
return -ENODEV;

xencons_irq = bind_evtchn_to_irq(xen_start_info->console.domU.evtchn);
if (xencons_irq < 0)
xencons_irq = 0 /* NO_IRQ */;
xencons_irq = 0; /* NO_IRQ */

hp = hvc_alloc(HVC_COOKIE, xencons_irq, &hvc_ops, 256);
if (IS_ERR(hp))
return PTR_ERR(hp);

hvc = hp;

console_pfn = mfn_to_pfn(xen_start_info->console.domU.mfn);

return 0;
}

void xen_console_resume(void)
{
if (xencons_irq)
rebind_evtchn_irq(xen_start_info->console.domU.evtchn, xencons_irq);
}

static void __exit xen_fini(void)
{
if (hvc)
Expand Down
2 changes: 2 additions & 0 deletions include/xen/hvc-console.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

extern struct console xenboot_console;

void xen_console_resume(void);

void xen_raw_console_write(const char *str);
void xen_raw_printk(const char *fmt, ...);

Expand Down

0 comments on commit 6b9b732

Please sign in to comment.