ia64/xen-unstable

changeset 1698:1e184263e3af

bitkeeper revision 1.1041.14.1 (40eb23c0avS7xcPh73oZ3JMbtKGtDQ)

Shift domain.c machdep stuff into arch/domain.c.
author djm@kirby.fc.hp.com
date Tue Jul 06 22:12:16 2004 +0000 (2004-07-06)
parents 1d4e272147c7
children 4c46c77bb628
files xen/arch/x86/domain.c xen/common/domain.c
line diff
     1.1 --- a/xen/arch/x86/domain.c	Tue Jul 06 20:28:23 2004 +0000
     1.2 +++ b/xen/arch/x86/domain.c	Tue Jul 06 22:12:16 2004 +0000
     1.3 @@ -185,6 +185,70 @@ void machine_power_off(void)
     1.4      machine_restart(0);
     1.5  }
     1.6  
     1.7 +/* this belongs in include/asm, but there doesn't seem to be a suitable place */
     1.8 +void free_perdomain_pt(struct domain *d)
     1.9 +{
    1.10 +    free_page((unsigned long)d->mm.perdomain_pt);
    1.11 +}
    1.12 +
    1.13 +void arch_do_createdomain(struct domain *d)
    1.14 +{
    1.15 +    d->shared_info = (void *)get_free_page();
    1.16 +    memset(d->shared_info, 0, PAGE_SIZE);
    1.17 +    SHARE_PFN_WITH_DOMAIN(virt_to_page(d->shared_info), d);
    1.18 +    machine_to_phys_mapping[virt_to_phys(d->shared_info) >> 
    1.19 +                           PAGE_SHIFT] = 0x80000000UL;  /* debug */
    1.20 +
    1.21 +    d->mm.perdomain_pt = (l1_pgentry_t *)get_free_page();
    1.22 +    memset(d->mm.perdomain_pt, 0, PAGE_SIZE);
    1.23 +    machine_to_phys_mapping[virt_to_phys(d->mm.perdomain_pt) >> 
    1.24 +                           PAGE_SHIFT] = 0x0fffdeadUL;  /* debug */
    1.25 +}
    1.26 +
    1.27 +void arch_final_setup_guestos(struct domain *p, full_execution_context_t *c)
    1.28 +{
    1.29 +    unsigned long phys_basetab;
    1.30 +    int i;
    1.31 +
    1.32 +    clear_bit(DF_DONEFPUINIT, &p->flags);
    1.33 +    if ( c->flags & ECF_I387_VALID )
    1.34 +        set_bit(DF_DONEFPUINIT, &p->flags);
    1.35 +    memcpy(&p->shared_info->execution_context,
    1.36 +           &c->cpu_ctxt,
    1.37 +           sizeof(p->shared_info->execution_context));
    1.38 +    memcpy(&p->thread.i387,
    1.39 +           &c->fpu_ctxt,
    1.40 +           sizeof(p->thread.i387));
    1.41 +    memcpy(p->thread.traps,
    1.42 +           &c->trap_ctxt,
    1.43 +           sizeof(p->thread.traps));
    1.44 +#ifdef ARCH_HAS_FAST_TRAP
    1.45 +    SET_DEFAULT_FAST_TRAP(&p->thread);
    1.46 +    (void)set_fast_trap(p, c->fast_trap_idx);
    1.47 +#endif
    1.48 +    p->mm.ldt_base = c->ldt_base;
    1.49 +    p->mm.ldt_ents = c->ldt_ents;
    1.50 +    SET_GDT_ENTRIES(p, DEFAULT_GDT_ENTRIES);
    1.51 +    SET_GDT_ADDRESS(p, DEFAULT_GDT_ADDRESS);
    1.52 +    if ( c->gdt_ents != 0 )
    1.53 +        (void)set_gdt(p,
    1.54 +                      c->gdt_frames,
    1.55 +                      c->gdt_ents);
    1.56 +    p->thread.guestos_ss = c->guestos_ss;
    1.57 +    p->thread.guestos_sp = c->guestos_esp;
    1.58 +    for ( i = 0; i < 8; i++ )
    1.59 +        (void)set_debugreg(p, i, c->debugreg[i]);
    1.60 +    p->event_selector    = c->event_callback_cs;
    1.61 +    p->event_address     = c->event_callback_eip;
    1.62 +    p->failsafe_selector = c->failsafe_callback_cs;
    1.63 +    p->failsafe_address  = c->failsafe_callback_eip;
    1.64 +    
    1.65 +    phys_basetab = c->pt_base;
    1.66 +    p->mm.pagetable = mk_pagetable(phys_basetab);
    1.67 +    get_page_and_type(&frame_table[phys_basetab>>PAGE_SHIFT], p, 
    1.68 +                      PGT_base_page_table);
    1.69 +}
    1.70 +
    1.71  #if defined(__i386__)
    1.72  
    1.73  void new_thread(struct domain *p,
     2.1 --- a/xen/common/domain.c	Tue Jul 06 20:28:23 2004 +0000
     2.2 +++ b/xen/common/domain.c	Tue Jul 06 22:12:16 2004 +0000
     2.3 @@ -44,6 +44,10 @@ rwlock_t tasklist_lock __cacheline_align
     2.4  struct domain *task_hash[TASK_HASH_SIZE];
     2.5  struct domain *task_list;
     2.6  
     2.7 +void arch_do_createdomain(struct domain *);
     2.8 +void arch_final_setup_guestos(struct domain *, full_execution_context_t *c);
     2.9 +void free_perdomain_pt(struct domain *);
    2.10 +
    2.11  struct domain *do_createdomain(domid_t dom_id, unsigned int cpu)
    2.12  {
    2.13      char buf[100];
    2.14 @@ -83,16 +87,7 @@ struct domain *do_createdomain(domid_t d
    2.15          INIT_LIST_HEAD(&d->page_list);
    2.16          d->max_pages = d->tot_pages = 0;
    2.17  
    2.18 -        d->shared_info = (void *)get_free_page();
    2.19 -        memset(d->shared_info, 0, PAGE_SIZE);
    2.20 -        SHARE_PFN_WITH_DOMAIN(virt_to_page(d->shared_info), d);
    2.21 -        machine_to_phys_mapping[virt_to_phys(d->shared_info) >> 
    2.22 -                               PAGE_SHIFT] = 0x80000000UL;  /* debug */
    2.23 -
    2.24 -        d->mm.perdomain_pt = (l1_pgentry_t *)get_free_page();
    2.25 -        memset(d->mm.perdomain_pt, 0, PAGE_SIZE);
    2.26 -        machine_to_phys_mapping[virt_to_phys(d->mm.perdomain_pt) >> 
    2.27 -                               PAGE_SHIFT] = 0x0fffdeadUL;  /* debug */
    2.28 +	arch_do_createdomain(d);
    2.29  
    2.30          /* Per-domain PCI-device list. */
    2.31          spin_lock_init(&d->pcidev_lock);
    2.32 @@ -446,7 +441,7 @@ void domain_destruct(struct domain *d)
    2.33  
    2.34      destroy_event_channels(d);
    2.35  
    2.36 -    free_page((unsigned long)d->mm.perdomain_pt);
    2.37 +    free_perdomain_pt(d);
    2.38      free_page((unsigned long)d->shared_info);
    2.39  
    2.40      free_domain_struct(d);
    2.41 @@ -460,8 +455,7 @@ void domain_destruct(struct domain *d)
    2.42   */
    2.43  int final_setup_guestos(struct domain *p, dom0_builddomain_t *builddomain)
    2.44  {
    2.45 -    unsigned long phys_basetab;
    2.46 -    int i, rc = 0;
    2.47 +    int rc = 0;
    2.48      full_execution_context_t *c;
    2.49  
    2.50      if ( (c = kmalloc(sizeof(*c))) == NULL )
    2.51 @@ -479,43 +473,7 @@ int final_setup_guestos(struct domain *p
    2.52          goto out;
    2.53      }
    2.54      
    2.55 -    clear_bit(DF_DONEFPUINIT, &p->flags);
    2.56 -    if ( c->flags & ECF_I387_VALID )
    2.57 -        set_bit(DF_DONEFPUINIT, &p->flags);
    2.58 -    memcpy(&p->shared_info->execution_context,
    2.59 -           &c->cpu_ctxt,
    2.60 -           sizeof(p->shared_info->execution_context));
    2.61 -    memcpy(&p->thread.i387,
    2.62 -           &c->fpu_ctxt,
    2.63 -           sizeof(p->thread.i387));
    2.64 -    memcpy(p->thread.traps,
    2.65 -           &c->trap_ctxt,
    2.66 -           sizeof(p->thread.traps));
    2.67 -#ifdef ARCH_HAS_FAST_TRAP
    2.68 -    SET_DEFAULT_FAST_TRAP(&p->thread);
    2.69 -    (void)set_fast_trap(p, c->fast_trap_idx);
    2.70 -#endif
    2.71 -    p->mm.ldt_base = c->ldt_base;
    2.72 -    p->mm.ldt_ents = c->ldt_ents;
    2.73 -    SET_GDT_ENTRIES(p, DEFAULT_GDT_ENTRIES);
    2.74 -    SET_GDT_ADDRESS(p, DEFAULT_GDT_ADDRESS);
    2.75 -    if ( c->gdt_ents != 0 )
    2.76 -        (void)set_gdt(p,
    2.77 -                      c->gdt_frames,
    2.78 -                      c->gdt_ents);
    2.79 -    p->thread.guestos_ss = c->guestos_ss;
    2.80 -    p->thread.guestos_sp = c->guestos_esp;
    2.81 -    for ( i = 0; i < 8; i++ )
    2.82 -        (void)set_debugreg(p, i, c->debugreg[i]);
    2.83 -    p->event_selector    = c->event_callback_cs;
    2.84 -    p->event_address     = c->event_callback_eip;
    2.85 -    p->failsafe_selector = c->failsafe_callback_cs;
    2.86 -    p->failsafe_address  = c->failsafe_callback_eip;
    2.87 -    
    2.88 -    phys_basetab = c->pt_base;
    2.89 -    p->mm.pagetable = mk_pagetable(phys_basetab);
    2.90 -    get_page_and_type(&frame_table[phys_basetab>>PAGE_SHIFT], p, 
    2.91 -                      PGT_base_page_table);
    2.92 +    arch_final_setup_guestos(p,c);
    2.93  
    2.94      /* Set up the shared info structure. */
    2.95      update_dom_time(p->shared_info);