target-i386: Introduce x86_cpuid_set_model_id()
Move the logic to transform the 48-char model ID into the 12-word model value into a helper. Signed-off-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
		
							parent
							
								
									38c3dc4622
								
							
						
					
					
						commit
						dcce6675de
					
				@ -619,6 +619,24 @@ static void x86_cpuid_version_set_stepping(CPUX86State *env, int stepping)
 | 
				
			|||||||
    env->cpuid_version |= stepping & 0xf;
 | 
					    env->cpuid_version |= stepping & 0xf;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void x86_cpuid_set_model_id(CPUX86State *env, const char *model_id)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    int c, len, i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (model_id == NULL) {
 | 
				
			||||||
 | 
					        model_id = "";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    len = strlen(model_id);
 | 
				
			||||||
 | 
					    for (i = 0; i < 48; i++) {
 | 
				
			||||||
 | 
					        if (i >= len) {
 | 
				
			||||||
 | 
					            c = '\0';
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            c = (uint8_t)model_id[i];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        env->cpuid_model[i >> 2] |= c << (8 * (i & 3));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
 | 
					static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    unsigned int i;
 | 
					    unsigned int i;
 | 
				
			||||||
@ -929,20 +947,7 @@ int cpu_x86_register (CPUX86State *env, const char *cpu_model)
 | 
				
			|||||||
        env->cpuid_ext3_features &= TCG_EXT3_FEATURES;
 | 
					        env->cpuid_ext3_features &= TCG_EXT3_FEATURES;
 | 
				
			||||||
        env->cpuid_svm_features &= TCG_SVM_FEATURES;
 | 
					        env->cpuid_svm_features &= TCG_SVM_FEATURES;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    {
 | 
					    x86_cpuid_set_model_id(env, def->model_id);
 | 
				
			||||||
        const char *model_id = def->model_id;
 | 
					 | 
				
			||||||
        int c, len, i;
 | 
					 | 
				
			||||||
        if (!model_id)
 | 
					 | 
				
			||||||
            model_id = "";
 | 
					 | 
				
			||||||
        len = strlen(model_id);
 | 
					 | 
				
			||||||
        for(i = 0; i < 48; i++) {
 | 
					 | 
				
			||||||
            if (i >= len)
 | 
					 | 
				
			||||||
                c = '\0';
 | 
					 | 
				
			||||||
            else
 | 
					 | 
				
			||||||
                c = (uint8_t)model_id[i];
 | 
					 | 
				
			||||||
            env->cpuid_model[i >> 2] |= c << (8 * (i & 3));
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user