|
19 | 19 | #include "cpu.h"
|
20 | 20 | #include "internals.h"
|
21 | 21 | #include "fpu/softfloat-helpers.h"
|
22 |
| -#include "cpu-csr.h" |
| 22 | +#include "csr.h" |
23 | 23 | #ifndef CONFIG_USER_ONLY
|
24 | 24 | #include "system/reset.h"
|
25 | 25 | #endif
|
@@ -375,6 +375,33 @@ static int loongarch_cpu_mmu_index(CPUState *cs, bool ifetch)
|
375 | 375 | return MMU_DA_IDX;
|
376 | 376 | }
|
377 | 377 |
|
| 378 | +static void loongarch_la464_init_csr(Object *obj) |
| 379 | +{ |
| 380 | +#ifndef CONFIG_USER_ONLY |
| 381 | + static bool initialized; |
| 382 | + LoongArchCPU *cpu = LOONGARCH_CPU(obj); |
| 383 | + CPULoongArchState *env = &cpu->env; |
| 384 | + int i, num; |
| 385 | + |
| 386 | + if (!initialized) { |
| 387 | + initialized = true; |
| 388 | + num = FIELD_EX64(env->CSR_PRCFG1, CSR_PRCFG1, SAVE_NUM); |
| 389 | + for (i = num; i < 16; i++) { |
| 390 | + set_csr_flag(LOONGARCH_CSR_SAVE(i), CSRFL_UNUSED); |
| 391 | + } |
| 392 | + set_csr_flag(LOONGARCH_CSR_IMPCTL1, CSRFL_UNUSED); |
| 393 | + set_csr_flag(LOONGARCH_CSR_IMPCTL2, CSRFL_UNUSED); |
| 394 | + set_csr_flag(LOONGARCH_CSR_MERRCTL, CSRFL_UNUSED); |
| 395 | + set_csr_flag(LOONGARCH_CSR_MERRINFO1, CSRFL_UNUSED); |
| 396 | + set_csr_flag(LOONGARCH_CSR_MERRINFO2, CSRFL_UNUSED); |
| 397 | + set_csr_flag(LOONGARCH_CSR_MERRENTRY, CSRFL_UNUSED); |
| 398 | + set_csr_flag(LOONGARCH_CSR_MERRERA, CSRFL_UNUSED); |
| 399 | + set_csr_flag(LOONGARCH_CSR_MERRSAVE, CSRFL_UNUSED); |
| 400 | + set_csr_flag(LOONGARCH_CSR_CTAG, CSRFL_UNUSED); |
| 401 | + } |
| 402 | +#endif |
| 403 | +} |
| 404 | + |
378 | 405 | static void loongarch_la464_initfn(Object *obj)
|
379 | 406 | {
|
380 | 407 | LoongArchCPU *cpu = LOONGARCH_CPU(obj);
|
@@ -470,6 +497,7 @@ static void loongarch_la464_initfn(Object *obj)
|
470 | 497 | env->CSR_PRCFG3 = FIELD_DP64(env->CSR_PRCFG3, CSR_PRCFG3, STLB_WAYS, 7);
|
471 | 498 | env->CSR_PRCFG3 = FIELD_DP64(env->CSR_PRCFG3, CSR_PRCFG3, STLB_SETS, 8);
|
472 | 499 |
|
| 500 | + loongarch_la464_init_csr(obj); |
473 | 501 | loongarch_cpu_post_init(obj);
|
474 | 502 | }
|
475 | 503 |
|
|
0 commit comments