/[gxemul]/trunk/src/promemul/dec_prom.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/dec_prom.c

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

revision 21 by dpavlin, Mon Oct 8 16:18:51 2007 UTC revision 22 by dpavlin, Mon Oct 8 16:19:37 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2003-2005  Anders Gavare.  All rights reserved.   *  Copyright (C) 2003-2006  Anders Gavare.  All rights reserved.
3   *   *
4   *  Redistribution and use in source and binary forms, with or without   *  Redistribution and use in source and binary forms, with or without
5   *  modification, are permitted provided that the following conditions are met:   *  modification, are permitted provided that the following conditions are met:
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: dec_prom.c,v 1.1 2005/08/29 14:46:34 debug Exp $   *  $Id: dec_prom.c,v 1.4 2006/02/16 05:57:10 debug Exp $
29   *   *
30   *  DECstation PROM emulation.   *  DECstation PROM emulation.
31   */   */
# Line 349  int decstation_prom_emul(struct cpu *cpu Line 349  int decstation_prom_emul(struct cpu *cpu
349                  i = 0; ch = -1; argreg = MIPS_GPR_A1;                  i = 0; ch = -1; argreg = MIPS_GPR_A1;
350                  while (ch != '\0') {                  while (ch != '\0') {
351                          char printfbuf[8000];                          char printfbuf[8000];
352                          int x;                          size_t x;
353    
354                          printfbuf[0] = printfbuf[sizeof(printfbuf)-1] = '\0';                          printfbuf[0] = printfbuf[sizeof(printfbuf)-1] = '\0';
355    
# Line 508  int decstation_prom_emul(struct cpu *cpu Line 508  int decstation_prom_emul(struct cpu *cpu
508                  break;                  break;
509          case 0x64:              /*  getenv()  */          case 0x64:              /*  getenv()  */
510                  /*  Find the environment variable given by a0:  */                  /*  Find the environment variable given by a0:  */
511                  for (i=0; i<sizeof(buf); i++)                  for (i=0; i<(int)sizeof(buf); i++)
512                          cpu->memory_rw(cpu, cpu->mem,                          cpu->memory_rw(cpu, cpu->mem,
513                              cpu->cd.mips.gpr[MIPS_GPR_A0] + i, &buf[i],                              cpu->cd.mips.gpr[MIPS_GPR_A0] + i, &buf[i],
514                              sizeof(char), MEM_READ, CACHE_DATA | NO_EXCEPTIONS);                              sizeof(char), MEM_READ, CACHE_DATA | NO_EXCEPTIONS);
# Line 517  int decstation_prom_emul(struct cpu *cpu Line 517  int decstation_prom_emul(struct cpu *cpu
517                  for (i=0; i<0x1000; i++) {                  for (i=0; i<0x1000; i++) {
518                          /*  Matching string at offset i?  */                          /*  Matching string at offset i?  */
519                          int nmatches = 0;                          int nmatches = 0;
520                          for (j=0; j<strlen((char *)buf); j++) {                          for (j=0; j<(int32_t)strlen((char *)buf); j++) {
521                                  cpu->memory_rw(cpu, cpu->mem, (uint64_t)                                  cpu->memory_rw(cpu, cpu->mem, (uint64_t)
522                                      (DEC_PROM_STRINGS + i + j), &ch2,                                      (DEC_PROM_STRINGS + i + j), &ch2,
523                                      sizeof(char), MEM_READ, CACHE_DATA |                                      sizeof(char), MEM_READ, CACHE_DATA |
# Line 529  int decstation_prom_emul(struct cpu *cpu Line 529  int decstation_prom_emul(struct cpu *cpu
529                              (uint64_t)(DEC_PROM_STRINGS                              (uint64_t)(DEC_PROM_STRINGS
530                              + i + strlen((char *)buf)), &ch2, sizeof(char),                              + i + strlen((char *)buf)), &ch2, sizeof(char),
531                              MEM_READ, CACHE_DATA | NO_EXCEPTIONS);                              MEM_READ, CACHE_DATA | NO_EXCEPTIONS);
532                          if (nmatches == strlen((char *)buf) && ch2 == '=') {                          if (nmatches == (int)strlen((char *)buf) && ch2=='=') {
533                                  cpu->cd.mips.gpr[MIPS_GPR_V0] =                                  cpu->cd.mips.gpr[MIPS_GPR_V0] =
534                                      DEC_PROM_STRINGS + i +                                      DEC_PROM_STRINGS + i +
535                                      strlen((char *)buf) + 1;                                      strlen((char *)buf) + 1;

Legend:
Removed from v.21  
changed lines
  Added in v.22

  ViewVC Help
Powered by ViewVC 1.1.26