예제 #1
0
static int
gnttab_map(unsigned int start_idx, unsigned int end_idx)
{
    struct gnttab_setup_table setup;
    u_long *frames;

    unsigned int nr_gframes = end_idx + 1;
    int i, rc;

    frames = malloc(nr_gframes * sizeof(unsigned long), M_DEVBUF, M_NOWAIT);
    if (!frames)
        return (ENOMEM);

    setup.dom        = DOMID_SELF;
    setup.nr_frames  = nr_gframes;
    set_xen_guest_handle(setup.frame_list, frames);

    rc = HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1);
    if (rc == -ENOSYS) {
        free(frames, M_DEVBUF);
        return (ENOSYS);
    }
    KASSERT(!(rc || setup.status),
            ("unexpected result from grant_table_op"));

    if (shared == NULL) {
        vm_offset_t area;

        area = kmem_alloc_nofault(kernel_map,
                                  PAGE_SIZE * max_nr_grant_frames());
        KASSERT(area, ("can't allocate VM space for grant table"));
        shared = (grant_entry_t *)area;
    }

    for (i = 0; i < nr_gframes; i++)
        PT_SET_MA(((caddr_t)shared) + i*PAGE_SIZE,
                  ((vm_paddr_t)frames[i]) << PAGE_SHIFT | PG_RW | PG_V);

    free(frames, M_DEVBUF);

    return (0);
}
예제 #2
0
int
start_all_aps(void)
{
	int x,apic_id, cpu;
	struct pcpu *pc;
	
	mtx_init(&ap_boot_mtx, "ap boot", NULL, MTX_SPIN);

	/* set up temporary P==V mapping for AP boot */
	/* XXX this is a hack, we should boot the AP on its own stack/PTD */

	/* start each AP */
	for (cpu = 1; cpu < mp_ncpus; cpu++) {
		apic_id = cpu_apic_ids[cpu];


		bootAP = cpu;
		bootAPgdt = gdt + (512*cpu);

		/* Get per-cpu data */
		pc = &__pcpu[bootAP];
		pcpu_init(pc, bootAP, sizeof(struct pcpu));
		dpcpu_init((void *)kmem_alloc(kernel_map, DPCPU_SIZE), bootAP);
		pc->pc_apic_id = cpu_apic_ids[bootAP];
		pc->pc_prvspace = pc;
		pc->pc_curthread = 0;

		gdt_segs[GPRIV_SEL].ssd_base = (int) pc;
		gdt_segs[GPROC0_SEL].ssd_base = (int) &pc->pc_common_tss;
		
		PT_SET_MA(bootAPgdt, VTOM(bootAPgdt) | PG_V | PG_RW);
		bzero(bootAPgdt, PAGE_SIZE);
		for (x = 0; x < NGDT; x++)
			ssdtosd(&gdt_segs[x], &bootAPgdt[x].sd);
		PT_SET_MA(bootAPgdt, vtomach(bootAPgdt) | PG_V);
#ifdef notyet
		
                if (HYPERVISOR_vcpu_op(VCPUOP_get_physid, cpu, &cpu_id) == 0) { 
                        apicid = xen_vcpu_physid_to_x86_apicid(cpu_id.phys_id); 
                        acpiid = xen_vcpu_physid_to_x86_acpiid(cpu_id.phys_id); 
#ifdef CONFIG_ACPI 
                        if (acpiid != 0xff) 
                                x86_acpiid_to_apicid[acpiid] = apicid; 
#endif 
                } 
#endif
		
		/* attempt to start the Application Processor */
		if (!start_ap(cpu)) {
			printf("AP #%d (PHY# %d) failed!\n", cpu, apic_id);
			/* better panic as the AP may be running loose */
			printf("panic y/n? [y] ");
			if (cngetc() != 'n')
				panic("bye-bye");
		}

		CPU_SET(cpu, &all_cpus);	/* record AP in CPU map */
	}
	

	pmap_invalidate_range(kernel_pmap, 0, NKPT * NBPDR - 1);
	
	/* number of APs actually started */
	return mp_naps;
}