int 
ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex )
{
	return( mon_create( mutex ) );
}
psim_create(const char *file_name,
            device *root)
{
    int cpu_nr;
    const char *env;
    psim *system;
    os_emul *os_emulation;
    int nr_cpus;

    /* given this partially populated device tree, os_emul_create() uses
       it and file_name to determine the selected emulation and hence
       further populate the tree with any other required nodes. */

    os_emulation = os_emul_create(file_name, root);
    if (os_emulation == NULL)
        error("psim: either file %s was not reconized or unreconized or unknown os-emulation type\n", file_name);

    /* fill in the missing real number of CPU's */
    nr_cpus = tree_find_integer_property(root, "/openprom/options/smp");
    if (MAX_NR_PROCESSORS < nr_cpus)
        error("target and configured number of cpus conflict\n");

    /* fill in the missing TARGET BYTE ORDER information */
    current_target_byte_order
        = (tree_find_boolean_property(root, "/options/little-endian?")
           ? LITTLE_ENDIAN
           : BIG_ENDIAN);
    if (CURRENT_TARGET_BYTE_ORDER != current_target_byte_order)
        error("target and configured byte order conflict\n");

    /* fill in the missing HOST BYTE ORDER information */
    current_host_byte_order = (current_host_byte_order = 1,
                               (*(char*)(&current_host_byte_order)
                                ? LITTLE_ENDIAN
                                : BIG_ENDIAN));
    if (CURRENT_HOST_BYTE_ORDER != current_host_byte_order)
        error("host and configured byte order conflict\n");

    /* fill in the missing OEA/VEA information */
    env = tree_find_string_property(root, "/openprom/options/env");
    current_environment = ((strcmp(env, "user") == 0
                            || strcmp(env, "uea") == 0)
                           ? USER_ENVIRONMENT
                           : (strcmp(env, "virtual") == 0
                              || strcmp(env, "vea") == 0)
                           ? VIRTUAL_ENVIRONMENT
                           : (strcmp(env, "operating") == 0
                              || strcmp(env, "oea") == 0)
                           ? OPERATING_ENVIRONMENT
                           : 0);
    if (current_environment == 0)
        error("unreconized /options env property\n");
    if (CURRENT_ENVIRONMENT != current_environment)
        error("target and configured environment conflict\n");

    /* fill in the missing ALLIGNMENT information */
    current_alignment
        = (tree_find_boolean_property(root, "/openprom/options/strict-alignment?")
           ? STRICT_ALIGNMENT
           : NONSTRICT_ALIGNMENT);
    if (CURRENT_ALIGNMENT != current_alignment)
        error("target and configured alignment conflict\n");

    /* fill in the missing FLOATING POINT information */
    current_floating_point
        = (tree_find_boolean_property(root, "/openprom/options/floating-point?")
           ? HARD_FLOATING_POINT
           : SOFT_FLOATING_POINT);
    if (CURRENT_FLOATING_POINT != current_floating_point)
        error("target and configured floating-point conflict\n");

    /* fill in the missing STDIO information */
    current_stdio
        = (tree_find_boolean_property(root, "/openprom/options/use-stdio?")
           ? DO_USE_STDIO
           : DONT_USE_STDIO);
    if (CURRENT_STDIO != current_stdio)
        error("target and configured stdio interface conflict\n");

    /* sort out the level of detail for issue modeling */
    current_model_issue
        = tree_find_integer_property(root, "/openprom/options/model-issue");
    if (CURRENT_MODEL_ISSUE != current_model_issue)
        error("target and configured model-issue conflict\n");

    /* sort out our model architecture - wrong.

       FIXME: this should be obtaining the required information from the
       device tree via the "/chosen" property "cpu" which is an instance
       (ihandle) for the only executing processor. By converting that
       ihandle into the corresponding cpu's phandle and then querying
       the "name" property, the cpu type can be determined. Ok? */

    model_set(tree_find_string_property(root, "/openprom/options/model"));

    /* create things */
    system = ZALLOC(psim);
    system->events = event_queue_create();
    system->memory = core_from_device(root);
    system->monitor = mon_create();
    system->nr_cpus = nr_cpus;
    system->os_emulation = os_emulation;
    system->devices = root;

    /* now all the processors attaching to each their per-cpu information */
    for (cpu_nr = 0; cpu_nr < MAX_NR_PROCESSORS; cpu_nr++) {
        system->processors[cpu_nr] = cpu_create(system,
                                                system->memory,
                                                mon_cpu(system->monitor,
                                                        cpu_nr),
                                                system->os_emulation,
                                                cpu_nr);
    }

    /* dump out the contents of the device tree */
    if (ppc_trace[trace_print_device_tree] || ppc_trace[trace_dump_device_tree])
        tree_print(root);
    if (ppc_trace[trace_dump_device_tree])
        error("");

    return system;
}