ths | 33d68b5 | 2007-03-18 00:30:29 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * MIPS emulation for qemu: CPU initialisation routines. |
| 3 | * |
| 4 | * Copyright (c) 2004-2005 Jocelyn Mayer |
| 5 | * Copyright (c) 2007 Herve Poussineau |
| 6 | * |
| 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | * License as published by the Free Software Foundation; either |
| 10 | * version 2 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public |
| 18 | * License along with this library; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 | */ |
| 21 | |
| 22 | struct mips_def_t { |
| 23 | const unsigned char *name; |
| 24 | int32_t CP0_PRid; |
| 25 | int32_t CP0_Config0; |
| 26 | int32_t CP0_Config1; |
| 27 | }; |
| 28 | |
| 29 | /*****************************************************************************/ |
| 30 | /* MIPS CPU definitions */ |
| 31 | static mips_def_t mips_defs[] = |
| 32 | { |
| 33 | #ifndef MIPS_HAS_MIPS64 |
| 34 | { |
| 35 | .name = "4Kc", |
| 36 | .CP0_PRid = 0x00018000, |
| 37 | .CP0_Config0 = MIPS_CONFIG0, |
| 38 | .CP0_Config1 = MIPS_CONFIG1, |
| 39 | }, |
| 40 | { |
| 41 | .name = "4KEc", |
| 42 | .CP0_PRid = 0x00018400, |
| 43 | .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR), |
| 44 | .CP0_Config1 = MIPS_CONFIG1, |
| 45 | }, |
| 46 | { |
| 47 | .name = "24Kf", |
| 48 | .CP0_PRid = 0x00019300, |
| 49 | .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR), |
| 50 | .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP), |
| 51 | }, |
| 52 | #else |
| 53 | { |
| 54 | .name = "R4000", |
| 55 | .CP0_PRid = 0x00000400, |
| 56 | .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AT), |
| 57 | .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP), |
| 58 | }, |
| 59 | #endif |
| 60 | }; |
| 61 | |
| 62 | int mips_find_by_name (const unsigned char *name, mips_def_t **def) |
| 63 | { |
| 64 | int i, ret; |
| 65 | |
| 66 | ret = -1; |
| 67 | *def = NULL; |
| 68 | for (i = 0; i < sizeof(mips_defs) / sizeof(mips_defs[0]); i++) { |
| 69 | if (strcasecmp(name, mips_defs[i].name) == 0) { |
| 70 | *def = &mips_defs[i]; |
| 71 | ret = 0; |
| 72 | break; |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | return ret; |
| 77 | } |
| 78 | |
| 79 | void mips_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) |
| 80 | { |
| 81 | int i; |
| 82 | |
| 83 | for (i = 0; i < sizeof(mips_defs) / sizeof(mips_defs[0]); i++) { |
| 84 | (*cpu_fprintf)(f, "MIPS '%s'\n", |
| 85 | mips_defs[i].name); |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | int cpu_mips_register (CPUMIPSState *env, mips_def_t *def) |
| 90 | { |
| 91 | if (!def) |
| 92 | cpu_abort(env, "Unable to find MIPS CPU definition\n"); |
| 93 | env->CP0_PRid = def->CP0_PRid; |
| 94 | env->CP0_Config0 = def->CP0_Config0; |
| 95 | env->CP0_Config1 = def->CP0_Config1; |
| 96 | return 0; |
| 97 | } |