diff mbox

[5/9] unicore32-softmmu: initialize ucv2 cpu

Message ID a215b3101ede9409d31c28515c3127d14964e3db.1337944756.git.gxt@mprc.pku.edu.cn
State New
Headers show

Commit Message

Guan Xuetao May 25, 2012, 11:29 a.m. UTC
Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
---
 target-unicore32/cpu.c |   17 +++++++++++++----
 target-unicore32/cpu.h |    2 +-
 2 files changed, 14 insertions(+), 5 deletions(-)

Comments

Andreas Färber May 25, 2012, 11:42 a.m. UTC | #1
Am 25.05.2012 13:29, schrieb Guan Xuetao:
> Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
> ---
>  target-unicore32/cpu.c |   17 +++++++++++++----
>  target-unicore32/cpu.h |    2 +-
>  2 files changed, 14 insertions(+), 5 deletions(-)
> 
> diff --git a/target-unicore32/cpu.c b/target-unicore32/cpu.c
> index de63f58..62c0a22 100644
> --- a/target-unicore32/cpu.c
> +++ b/target-unicore32/cpu.c
> @@ -32,13 +32,16 @@ static void unicore_ii_cpu_initfn(Object *obj)
>      UniCore32CPU *cpu = UNICORE32_CPU(obj);
>      CPUUniCore32State *env = &cpu->env;
>  
> -    env->cp0.c0_cpuid = 0x40010863;
> +    env->cp0.c0_cpuid = UC32_CPUID_UCV2;

Please don't revert this change. I'll send you the patch to drop the
CPUID #defines instead.

Andreas

> diff --git a/target-unicore32/cpu.h b/target-unicore32/cpu.h
> index 66c42f5..8af3649 100644
> --- a/target-unicore32/cpu.h
> +++ b/target-unicore32/cpu.h
> @@ -123,7 +123,7 @@ void cpu_asr_write(CPUUniCore32State *env1, target_ulong val, target_ulong mask)
>  #define UC32_HWCAP_UCF64                8 /* 1 << 3 */
>  
>  #define UC32_CPUID(env)                 (env->cp0.c0_cpuid)
> -#define UC32_CPUID_UCV2                 0x40010863
> +#define UC32_CPUID_UCV2                 0x4d000863
>  #define UC32_CPUID_ANY                  0xffffffff
>  
>  #define cpu_init                        uc32_cpu_init
Guan Xuetao May 28, 2012, 9:43 a.m. UTC | #2
> Am 25.05.2012 13:29, schrieb Guan Xuetao:
>> Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
>> ---
>>  target-unicore32/cpu.c |   17 +++++++++++++----
>>  target-unicore32/cpu.h |    2 +-
>>  2 files changed, 14 insertions(+), 5 deletions(-)
>>
>> diff --git a/target-unicore32/cpu.c b/target-unicore32/cpu.c
>> index de63f58..62c0a22 100644
>> --- a/target-unicore32/cpu.c
>> +++ b/target-unicore32/cpu.c
>> @@ -32,13 +32,16 @@ static void unicore_ii_cpu_initfn(Object *obj)
>>      UniCore32CPU *cpu = UNICORE32_CPU(obj);
>>      CPUUniCore32State *env = &cpu->env;
>>
>> -    env->cp0.c0_cpuid = 0x40010863;
>> +    env->cp0.c0_cpuid = UC32_CPUID_UCV2;
>
> Please don't revert this change. I'll send you the patch to drop the
> CPUID #defines instead.

But, the kernel need this CPUID to check whether it is a unicore32
processor, and if check fail, the kernel will halt.

Guan Xuetao
Andreas Färber May 28, 2012, 1:14 p.m. UTC | #3
Am 28.05.2012 11:43, schrieb guanxuetao@mprc.pku.edu.cn:
>> Am 25.05.2012 13:29, schrieb Guan Xuetao:
>>> Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
>>> ---
>>>  target-unicore32/cpu.c |   17 +++++++++++++----
>>>  target-unicore32/cpu.h |    2 +-
>>>  2 files changed, 14 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/target-unicore32/cpu.c b/target-unicore32/cpu.c
>>> index de63f58..62c0a22 100644
>>> --- a/target-unicore32/cpu.c
>>> +++ b/target-unicore32/cpu.c
>>> @@ -32,13 +32,16 @@ static void unicore_ii_cpu_initfn(Object *obj)
>>>      UniCore32CPU *cpu = UNICORE32_CPU(obj);
>>>      CPUUniCore32State *env = &cpu->env;
>>>
>>> -    env->cp0.c0_cpuid = 0x40010863;
>>> +    env->cp0.c0_cpuid = UC32_CPUID_UCV2;
>>
>> Please don't revert this change. I'll send you the patch to drop the
>> CPUID #defines instead.
> 
> But, the kernel need this CPUID to check whether it is a unicore32
> processor, and if check fail, the kernel will halt.

I'm not discussing about a guest kernel but about your source change
above: The UC32_CPUID_UC32 #define should go away, i.e. please ack
(today, if we want it in 1.1) and prepend my patch, and if the value is
wrong here it should be changed *here* and not in UC32_CPUID_UCV2.

If you're introducing new uses of UC32_CPUID_UCV2 elsewhere (e.g., for
register behavior) then that is a design fault and needs to be fixed.
Compare the copro series for target-arm, which gets rid of the
CPUID-based switches there.

Andreas
Guan Xuetao May 29, 2012, 3 p.m. UTC | #4
> Am 28.05.2012 11:43, schrieb guanxuetao@mprc.pku.edu.cn:
>>> Am 25.05.2012 13:29, schrieb Guan Xuetao:
>>>> Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
>>>> ---
>>>>  target-unicore32/cpu.c |   17 +++++++++++++----
>>>>  target-unicore32/cpu.h |    2 +-
>>>>  2 files changed, 14 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/target-unicore32/cpu.c b/target-unicore32/cpu.c
>>>> index de63f58..62c0a22 100644
>>>> --- a/target-unicore32/cpu.c
>>>> +++ b/target-unicore32/cpu.c
>>>> @@ -32,13 +32,16 @@ static void unicore_ii_cpu_initfn(Object *obj)
>>>>      UniCore32CPU *cpu = UNICORE32_CPU(obj);
>>>>      CPUUniCore32State *env = &cpu->env;
>>>>
>>>> -    env->cp0.c0_cpuid = 0x40010863;
>>>> +    env->cp0.c0_cpuid = UC32_CPUID_UCV2;
>>>
>>> Please don't revert this change. I'll send you the patch to drop the
>>> CPUID #defines instead.
>>
>> But, the kernel need this CPUID to check whether it is a unicore32
>> processor, and if check fail, the kernel will halt.
>
> I'm not discussing about a guest kernel but about your source change
> above: The UC32_CPUID_UC32 #define should go away, i.e. please ack
> (today, if we want it in 1.1) and prepend my patch, and if the value is
> wrong here it should be changed *here* and not in UC32_CPUID_UCV2.
>
> If you're introducing new uses of UC32_CPUID_UCV2 elsewhere (e.g., for
> register behavior) then that is a design fault and needs to be fixed.
> Compare the copro series for target-arm, which gets rid of the
> CPUID-based switches there.
>
> Andreas
Ok, I see.
Thanks for your explanation.
I will rebase my repo on qom-cpu-unicore32-v1.2 branch.

Guan Xuetao
diff mbox

Patch

diff --git a/target-unicore32/cpu.c b/target-unicore32/cpu.c
index de63f58..62c0a22 100644
--- a/target-unicore32/cpu.c
+++ b/target-unicore32/cpu.c
@@ -32,13 +32,16 @@  static void unicore_ii_cpu_initfn(Object *obj)
     UniCore32CPU *cpu = UNICORE32_CPU(obj);
     CPUUniCore32State *env = &cpu->env;
 
-    env->cp0.c0_cpuid = 0x40010863;
+    env->cp0.c0_cpuid = UC32_CPUID_UCV2;
+    env->cp0.c0_cachetype = 0x0d152152;
+    env->cp0.c1_sys = 0x2000;
+    env->cp0.c2_base = 0x0;
+    env->cp0.c3_faultstatus = 0x0;
+    env->cp0.c4_faultaddr = 0x0;
+    env->ucf64.xregs[UC32_UCF64_FPSCR] = 0;
 
     set_feature(env, UC32_HWCAP_CMOV);
     set_feature(env, UC32_HWCAP_UCF64);
-    env->ucf64.xregs[UC32_UCF64_FPSCR] = 0;
-    env->cp0.c0_cachetype = 0x1dd20d2;
-    env->cp0.c1_sys = 0x00090078;
 }
 
 static void uc32_any_cpu_initfn(Object *obj)
@@ -47,6 +50,7 @@  static void uc32_any_cpu_initfn(Object *obj)
     CPUUniCore32State *env = &cpu->env;
 
     env->cp0.c0_cpuid = 0xffffffff;
+    env->ucf64.xregs[UC32_UCF64_FPSCR] = 0;
 
     set_feature(env, UC32_HWCAP_CMOV);
     set_feature(env, UC32_HWCAP_UCF64);
@@ -65,8 +69,13 @@  static void uc32_cpu_initfn(Object *obj)
     cpu_exec_init(env);
     env->cpu_model_str = object_get_typename(obj);
 
+#ifdef CONFIG_USER_ONLY
     env->uncached_asr = ASR_MODE_USER;
     env->regs[31] = 0;
+#else
+    env->uncached_asr = ASR_MODE_PRIV;
+    env->regs[31] = 0x03000000;
+#endif
 
     tlb_flush(env, 1);
 }
diff --git a/target-unicore32/cpu.h b/target-unicore32/cpu.h
index 66c42f5..8af3649 100644
--- a/target-unicore32/cpu.h
+++ b/target-unicore32/cpu.h
@@ -123,7 +123,7 @@  void cpu_asr_write(CPUUniCore32State *env1, target_ulong val, target_ulong mask)
 #define UC32_HWCAP_UCF64                8 /* 1 << 3 */
 
 #define UC32_CPUID(env)                 (env->cp0.c0_cpuid)
-#define UC32_CPUID_UCV2                 0x40010863
+#define UC32_CPUID_UCV2                 0x4d000863
 #define UC32_CPUID_ANY                  0xffffffff
 
 #define cpu_init                        uc32_cpu_init