Beispiel #1
0
/* ----------------------------------------------------------------------- */
void mmu_load_env()
{
  void *ptr = valloc_(8 * _Mb_);
  // alloc_init((size_t)malloc(2 * _Mb_), 2 * _Mb_);
  kSYS.mspace_ = KALLOC(kMemSpace_t);
  kSYS.scheduler_ = KALLOC(kScheduler_t);
  memset (ptr, 0, 8 * _Mb_);
  area_init(kSYS.mspace_, (size_t)ptr, 8 * _Mb_);
}
Beispiel #2
0
/*
 *	Only one processor set, the default processor set, in this case.
 */
kern_return_t
host_processor_sets(
    host_t				host,
    processor_set_name_array_t	*pset_list,
    mach_msg_type_number_t		*count)
{
    vm_offset_t addr;
    boolean_t rt = FALSE; /* ### This boolean is FALSE, because there
			       * currently exists no mechanism to determine
			       * whether or not the reply port is an RT port
			       */

    if (host == HOST_NULL)
        return KERN_INVALID_ARGUMENT;

    /*
     *	Allocate memory.  Can be pageable because it won't be
     *	touched while holding a lock.
     */

    addr = KALLOC((vm_size_t) sizeof(mach_port_t), rt);
    if (addr == 0)
        return KERN_RESOURCE_SHORTAGE;

    /* take ref for convert_pset_name_to_port */
    pset_reference(&default_pset);
    /* do the conversion that Mig should handle */
    *((ipc_port_t *) addr) = convert_pset_name_to_port(&default_pset);

    *pset_list = (mach_port_t *) addr;
    *count = 1;

    return KERN_SUCCESS;
}
Beispiel #3
0
kern_return_t
host_processors(
    host_t			host,
    processor_array_t	*processor_list,
    mach_msg_type_number_t	*countp)
{
    register int		i;
    register processor_t	*tp;
    vm_offset_t		addr;
    unsigned int		count;
    boolean_t rt = FALSE; /* ### This boolean is FALSE, because there
			       * currently exists no mechanism to determine
			       * whether or not the reply port is an RT port
			       */

    if (host == HOST_NULL)
        return(KERN_INVALID_ARGUMENT);

    /*
     *	Determine how many processors we have.
     *	(This number shouldn't change.)
     */

    count = 0;
    for (i = 0; i < NCPUS; i++)
        if (machine_slot[i].is_cpu)
            count++;

    if (count == 0)
        panic("host_processors");

    addr = KALLOC((vm_size_t) (count * sizeof(mach_port_t)), rt);
    if (addr == 0)
        return KERN_RESOURCE_SHORTAGE;

    tp = (processor_t *) addr;
    for (i = 0; i < NCPUS; i++)
        if (machine_slot[i].is_cpu)
            *tp++ = cpu_to_processor(i);

    *countp = count;
    *processor_list = (mach_port_t *) addr;

    /* do the conversion that Mig should handle */

    tp = (processor_t *) addr;
    for (i = 0; i < count; i++)
        ((mach_port_t *) tp)[i] =
            (mach_port_t)convert_processor_to_port(tp[i]);

    return KERN_SUCCESS;
}
Beispiel #4
0
kern_return_t
host_processor_sets(
    host_t				host,
    processor_set_name_array_t	*pset_list,
    mach_msg_type_number_t		*count)
{
    unsigned int actual;	/* this many psets */
    processor_set_t pset;
    processor_set_t *psets;
    int i;
    boolean_t rt = FALSE; /* ### This boolean is FALSE, because there
			       * currently exists no mechanism to determine
			       * whether or not the reply port is an RT port
			       */

    vm_size_t size;
    vm_size_t size_needed;
    vm_offset_t addr;

    if (host == HOST_NULL)
        return KERN_INVALID_ARGUMENT;

    size = 0;
    addr = 0;

    for (;;) {
        mutex_lock(&all_psets_lock);
        actual = all_psets_count;

        /* do we have the memory we need? */

        size_needed = actual * sizeof(mach_port_t);
        if (size_needed <= size)
            break;

        /* unlock and allocate more memory */
        mutex_unlock(&all_psets_lock);

        if (size != 0)
            KFREE(addr, size, rt);

        assert(size_needed > 0);
        size = size_needed;

        addr = KALLOC(size, rt);
        if (addr == 0)
            return KERN_RESOURCE_SHORTAGE;
    }

    /* OK, have memory and the all_psets_lock */

    psets = (processor_set_t *) addr;

    for (i = 0, pset = (processor_set_t) queue_first(&all_psets);
            i < actual;
            i++, pset = (processor_set_t) queue_next(&pset->all_psets)) {
        /* take ref for convert_pset_name_to_port */
        pset_reference(pset);
        psets[i] = pset;
    }
    assert(queue_end(&all_psets, (queue_entry_t) pset));

    /* can unlock now that we've got the pset refs */
    mutex_unlock(&all_psets_lock);

    /*
     *	Always have default port.
     */

    assert(actual > 0);

    /* if we allocated too much, must copy */

    if (size_needed < size) {
        vm_offset_t newaddr;

        newaddr = KALLOC(size_needed, rt);
        if (newaddr == 0) {
            for (i = 0; i < actual; i++)
                pset_deallocate(psets[i]);
            KFREE(addr, size, rt);
            return KERN_RESOURCE_SHORTAGE;
        }

        bcopy((char *) addr, (char *) newaddr, size_needed);
        KFREE(addr, size, rt);
        psets = (processor_set_t *) newaddr;
    }

    *pset_list = (mach_port_t *) psets;
    *count = actual;

    /* do the conversion that Mig should handle */

    for (i = 0; i < actual; i++)
        ((ipc_port_t *) psets)[i] = convert_pset_name_to_port(psets[i]);

    return KERN_SUCCESS;
}