Ejemplo n.º 1
0
RM_STATUS NV_API_CALL os_registry_init(void)
{
    nv_parm_t *entry;
    unsigned int i;
    nv_stack_t *sp = NULL;

    NV_KMEM_CACHE_ALLOC_STACK(sp);
    if (sp == NULL)
    {
        nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate stack!\n");
        return RM_ERR_NO_FREE_MEM;
    }

    if (NVreg_RmMsg != NULL)
    {
        rm_write_registry_string(sp, NULL, "NVreg",
                "RmMsg", NVreg_RmMsg, strlen(NVreg_RmMsg));
    }

    parse_option_string(sp);

    for (i = 0; (entry = &nv_parms[i])->name != NULL; i++)
    {
        rm_write_registry_dword(sp, NULL, entry->node, entry->name, *entry->data);
    }

    NV_KMEM_CACHE_FREE_STACK(sp);

    return RM_OK;
}
Ejemplo n.º 2
0
static void parse_option_string(nv_stack_t *sp)
{
    unsigned int i, len;
    nv_parm_t *entry;
    char *option_string = NULL;
    char *ptr, *mod;
    char *token;
    char *name, *value;
    NvU32 data;

    if (NVreg_RegistryDwords != NULL)
    {
        len = strlen(NVreg_RegistryDwords) + 1;

        if (os_alloc_mem((void **)&option_string, len) != RM_OK)
            return;

        ptr = NVreg_RegistryDwords;
        mod = option_string;

        while (*ptr != '\0')
        {
            if (!isspace(*ptr)) *mod++ = *ptr;
            ptr++;
        }
        *mod = '\0';

        ptr = option_string;

        while ((token = strsep(&ptr, ";")) != NULL)
        {
            if (!(name = strsep(&token, "=")) || !strlen(name))
                continue;
            if (!(value = strsep(&token, "=")) || !strlen(value))
                continue;
            if (strsep(&token, "=") != NULL)
                continue;

            data = (NvU32)simple_strtoul(value, NULL, 0);

            for (i = 0; (entry = &nv_parms[i])->name != NULL; i++)
            {
                if (strcmp(entry->name, name) == 0)
                    break;
            }

            if (!entry->name)
                rm_write_registry_dword(sp, NULL, "NVreg", name, data);
            else
                *entry->data = data;
        }

        os_free_mem(option_string);
    }
}
Ejemplo n.º 3
0
static void parse_option_string(nv_stack_t *sp)
{
    unsigned int i;
    nv_parm_t *entry;
    char *option_string = NULL;
    char *ptr, *token;
    char *name, *value;
    NvU32 data;

    if (NVreg_RegistryDwords != NULL)
    {
        if ((option_string = remove_spaces(NVreg_RegistryDwords)) == NULL)
        {
            return;
        }

        ptr = option_string;

        while ((token = strsep(&ptr, ";")) != NULL)
        {
            if (!(name = strsep(&token, "=")) || !strlen(name))
            {
                continue;
            }

            if (!(value = strsep(&token, "=")) || !strlen(value))
            {
                continue;
            }

            if (strsep(&token, "=") != NULL)
            {
                continue;
            }

            data = (NvU32)simple_strtoul(value, NULL, 0);

            for (i = 0; (entry = &nv_parms[i])->name != NULL; i++)
            {
                if (strcmp(entry->name, name) == 0)
                    break;
            }

            if (!entry->name)
                rm_write_registry_dword(sp, NULL, "NVreg", name, data);
            else
                *entry->data = data;
        }

        os_free_mem(option_string);
    }
}
Ejemplo n.º 4
0
RM_STATUS NV_API_CALL os_registry_init(void)
{
    nv_parm_t *entry;
    unsigned int i;
    nv_stack_t *sp = NULL;

    NV_KMEM_CACHE_ALLOC_STACK(sp);
    if (sp == NULL)
    {
        nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate stack!\n");
        return RM_ERR_NO_MEMORY;
    }

    if (NVreg_RmMsg != NULL)
    {
        rm_write_registry_string(sp, NULL, "NVreg",
                "RmMsg", NVreg_RmMsg, strlen(NVreg_RmMsg));
    }

    memset(&nv_assign_gpu_pci_info, 0, sizeof(nv_assign_gpu_pci_info));

#if !defined(NV_VMWARE)
    if (parse_assign_gpus_string())
    {
        rm_write_registry_string(sp, NULL, "NVreg", NV_REG_ASSIGN_GPUS,
                                 NVreg_AssignGpus, strlen(NVreg_AssignGpus));
    }

#endif

    parse_option_string(sp);

    detect_virtualization_and_apply_defaults(sp);

    for (i = 0; (entry = &nv_parms[i])->name != NULL; i++)
    {
        rm_write_registry_dword(sp, NULL, entry->node, entry->name, *entry->data);
    }

    NV_KMEM_CACHE_FREE_STACK(sp);

    return RM_OK;
}