/[gxemul]/trunk/src/promemul/yamon.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/promemul/yamon.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 41 by dpavlin, Mon Oct 8 16:21:17 2007 UTC revision 42 by dpavlin, Mon Oct 8 16:22:32 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: yamon.c,v 1.9 2006/12/30 13:31:03 debug Exp $   *  $Id: yamon.c,v 1.13 2007/06/14 16:13:30 debug Exp $
29   *   *
30   *  YAMON emulation. (Very basic, only what is needed to get NetBSD booting.)   *  YAMON emulation. (Very basic, only what is needed to get NetBSD booting.)
31   */   */
# Line 43  Line 43 
43  #include "misc.h"  #include "misc.h"
44  #include "net.h"  #include "net.h"
45    
 #ifdef ENABLE_MIPS  
   
46  #include "yamon.h"  #include "yamon.h"
47    
48    
# Line 143  int yamon_emul(struct cpu *cpu) Line 141  int yamon_emul(struct cpu *cpu)
141          uint32_t ofs = (cpu->pc & 0xff) + YAMON_FUNCTION_BASE;          uint32_t ofs = (cpu->pc & 0xff) + YAMON_FUNCTION_BASE;
142          uint8_t ch;          uint8_t ch;
143          int n;          int n;
144            uint32_t oid;
145            uint64_t paddr, psize;
146    
147          switch (ofs) {          switch (ofs) {
148    
# Line 190  int yamon_emul(struct cpu *cpu) Line 190  int yamon_emul(struct cpu *cpu)
190    
191          case YAMON_SYSCON_READ_OFS:          case YAMON_SYSCON_READ_OFS:
192                  /*                  /*
193                   *  syscon                   *  syscon_read(oid [a0], addr [a1], size [a2])
194                   */                   */
                 fatal("[ yamon_emul(): syscon: TODO ]\n");  
195    
196                  /*  TODO. For now, return some kind of "failure":  */                  oid = cpu->cd.mips.gpr[MIPS_GPR_A0];
197                  cpu->cd.mips.gpr[MIPS_GPR_V0] = 1;                  paddr = cpu->cd.mips.gpr[MIPS_GPR_A1];
198                    psize = cpu->cd.mips.gpr[MIPS_GPR_A2];
199    
200                    switch (oid) {
201                    case SYSCON_BOARD_CPU_CLOCK_FREQ_ID:
202                            if (psize == sizeof(uint32_t)) {
203                                    uint32_t freq = cpu->machine->emulated_hz;
204    
205                                    debug("[ yamon_emul(): reporting CPU "
206                                        "frequency of %u ]\n", (unsigned int)
207                                        freq);
208    
209                                    if (cpu->byte_order == EMUL_LITTLE_ENDIAN)
210                                            freq = LE32_TO_HOST(freq);
211                                    else
212                                            freq = BE32_TO_HOST(freq);
213    
214                                    cpu->memory_rw(cpu, cpu->mem, (int32_t)paddr,
215                                        (void *) &freq, sizeof(freq), MEM_WRITE,
216                                        CACHE_DATA | NO_EXCEPTIONS);
217    
218                                    cpu->cd.mips.gpr[MIPS_GPR_V0] = 0;
219                            } else {
220                                    cpu->cd.mips.gpr[MIPS_GPR_V0] = 1;
221                            }
222                            break;
223    
224                    default:
225                            fatal("[ yamon_emul(): unimplemented object id 0x%"
226                                PRIx32" ]\n", oid);
227                            cpu->cd.mips.gpr[MIPS_GPR_V0] = 1;
228                    }
229                  break;                  break;
230    
231          default:cpu_register_dump(cpu->machine, cpu, 1, 0);          default:
232                    cpu_register_dump(cpu->machine, cpu, 1, 0);
233                  printf("\n");                  printf("\n");
234                  fatal("[ yamon_emul(): unimplemented yamon function 0x%"                  fatal("[ yamon_emul(): unimplemented yamon function 0x%"
235                      PRIx32" ]\n", ofs);                      PRIx32" ]\n", ofs);
# Line 208  int yamon_emul(struct cpu *cpu) Line 239  int yamon_emul(struct cpu *cpu)
239          return 1;          return 1;
240  }  }
241    
 #endif  /*  ENABLE_MIPS  */  

Legend:
Removed from v.41  
changed lines
  Added in v.42

  ViewVC Help
Powered by ViewVC 1.1.26