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: |
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 |
*/ |
*/ |
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 |
|
|
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); |
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 | |
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; |