1 |
/* |
/* |
2 |
* Copyright (C) 2003-2006 Anders Gavare. All rights reserved. |
* Copyright (C) 2003-2007 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.9 2006/06/23 11:47:05 debug Exp $ |
* $Id: dec_prom.c,v 1.13 2007/06/15 17:02:40 debug Exp $ |
29 |
* |
* |
30 |
* DECstation PROM emulation. |
* DECstation PROM emulation. |
31 |
* |
* |
45 |
#include "cpu_mips.h" |
#include "cpu_mips.h" |
46 |
#include "diskimage.h" |
#include "diskimage.h" |
47 |
#include "machine.h" |
#include "machine.h" |
48 |
|
#include "machine_pmax.h" |
49 |
#include "memory.h" |
#include "memory.h" |
50 |
#include "misc.h" |
#include "misc.h" |
51 |
|
|
106 |
/* TODO */ |
/* TODO */ |
107 |
cpu->machine->exit_without_entering_debugger = 1; |
cpu->machine->exit_without_entering_debugger = 1; |
108 |
cpu->running = 0; |
cpu->running = 0; |
|
cpu->dead = 1; |
|
109 |
break; |
break; |
110 |
case 0x10: /* restart() */ |
case 0x10: /* restart() */ |
111 |
/* TODO */ |
/* TODO */ |
112 |
cpu->machine->exit_without_entering_debugger = 1; |
cpu->machine->exit_without_entering_debugger = 1; |
113 |
cpu->running = 0; |
cpu->running = 0; |
|
cpu->dead = 1; |
|
114 |
break; |
break; |
115 |
case 0x18: /* reinit() */ |
case 0x18: /* reinit() */ |
116 |
/* TODO */ |
/* TODO */ |
127 |
fatal("\ndec_jumptable_func(): opening more than one " |
fatal("\ndec_jumptable_func(): opening more than one " |
128 |
"file isn't supported yet.\n"); |
"file isn't supported yet.\n"); |
129 |
cpu->running = 0; |
cpu->running = 0; |
|
cpu->dead = 1; |
|
130 |
} |
} |
131 |
file_opened = 1; |
file_opened = 1; |
132 |
cpu->cd.mips.gpr[MIPS_GPR_V0] = 1; |
cpu->cd.mips.gpr[MIPS_GPR_V0] = 1; |
138 |
int res; |
int res; |
139 |
unsigned char *tmp_buf; |
unsigned char *tmp_buf; |
140 |
|
|
141 |
tmp_buf = malloc(cpu->cd.mips.gpr[MIPS_GPR_A2]); |
CHECK_ALLOCATION(tmp_buf = |
142 |
if (tmp_buf == NULL) { |
malloc(cpu->cd.mips.gpr[MIPS_GPR_A2])); |
|
fprintf(stderr, "[ *** Out of memory in " |
|
|
"dec_prom.c, allocating %i bytes ]\n", |
|
|
(int)cpu->cd.mips.gpr[MIPS_GPR_A2]); |
|
|
break; |
|
|
} |
|
143 |
|
|
144 |
res = diskimage_access(cpu->machine, disk_id, |
res = diskimage_access(cpu->machine, disk_id, |
145 |
DISKIMAGE_SCSI, 0, current_file_offset, tmp_buf, |
DISKIMAGE_SCSI, 0, current_file_offset, tmp_buf, |
194 |
fatal("PROM emulation: unimplemented JUMP TABLE vector " |
fatal("PROM emulation: unimplemented JUMP TABLE vector " |
195 |
"0x%x (decimal function %i)\n", vector, vector/8); |
"0x%x (decimal function %i)\n", vector, vector/8); |
196 |
cpu->running = 0; |
cpu->running = 0; |
|
cpu->dead = 1; |
|
197 |
} |
} |
198 |
|
|
199 |
return 0; |
return 0; |
472 |
int res; |
int res; |
473 |
unsigned char *tmp_buf; |
unsigned char *tmp_buf; |
474 |
|
|
475 |
tmp_buf = malloc(cpu->cd.mips.gpr[MIPS_GPR_A2]); |
CHECK_ALLOCATION(tmp_buf = |
476 |
if (tmp_buf == NULL) { |
malloc(cpu->cd.mips.gpr[MIPS_GPR_A2])); |
|
fprintf(stderr, "[ *** Out of memory in " |
|
|
"dec_prom.c, allocating %i bytes ]\n", |
|
|
(int)cpu->cd.mips.gpr[MIPS_GPR_A2]); |
|
|
break; |
|
|
} |
|
477 |
|
|
478 |
res = diskimage_access(cpu->machine, disk_id, |
res = diskimage_access(cpu->machine, disk_id, |
479 |
DISKIMAGE_SCSI, 0, |
DISKIMAGE_SCSI, 0, |
583 |
debug("[ DEC PROM getbitmap(0x%08x) ]\n", |
debug("[ DEC PROM getbitmap(0x%08x) ]\n", |
584 |
(int)cpu->cd.mips.gpr[MIPS_GPR_A0]); |
(int)cpu->cd.mips.gpr[MIPS_GPR_A0]); |
585 |
store_buf(cpu, cpu->cd.mips.gpr[MIPS_GPR_A0], |
store_buf(cpu, cpu->cd.mips.gpr[MIPS_GPR_A0], |
586 |
(char *)cpu->machine->md.pmax.memmap, |
(char *)cpu->machine->md.pmax->memmap, |
587 |
sizeof(struct dec_memmap)); |
sizeof(struct dec_memmap)); |
588 |
cpu->cd.mips.gpr[MIPS_GPR_V0] = |
cpu->cd.mips.gpr[MIPS_GPR_V0] = |
589 |
sizeof(cpu->machine->md.pmax.memmap->bitmap); |
sizeof(cpu->machine->md.pmax->memmap->bitmap); |
590 |
break; |
break; |
591 |
case 0x88: /* disableintr() */ |
case 0x88: /* disableintr() */ |
592 |
debug("[ DEC PROM disableintr(): TODO ]\n"); |
debug("[ DEC PROM disableintr(): TODO ]\n"); |
600 |
debug("[ DEC PROM halt() ]\n"); |
debug("[ DEC PROM halt() ]\n"); |
601 |
cpu->machine->exit_without_entering_debugger = 1; |
cpu->machine->exit_without_entering_debugger = 1; |
602 |
cpu->running = 0; |
cpu->running = 0; |
|
cpu->dead = 1; |
|
603 |
break; |
break; |
604 |
case 0xa4: /* gettcinfo() */ |
case 0xa4: /* gettcinfo() */ |
605 |
/* |
/* |
639 |
debug("DEC PROM: rex('h') ==> halt\n"); |
debug("DEC PROM: rex('h') ==> halt\n"); |
640 |
cpu->machine->exit_without_entering_debugger = 1; |
cpu->machine->exit_without_entering_debugger = 1; |
641 |
cpu->running = 0; |
cpu->running = 0; |
|
cpu->dead = 1; |
|
642 |
break; |
break; |
643 |
case 'b': |
case 'b': |
644 |
debug("DEC PROM: rex('b') ==> reboot: TODO " |
debug("DEC PROM: rex('b') ==> reboot: TODO " |
645 |
"(halting CPU instead)\n"); |
"(halting CPU instead)\n"); |
646 |
cpu->machine->exit_without_entering_debugger = 1; |
cpu->machine->exit_without_entering_debugger = 1; |
647 |
cpu->running = 0; |
cpu->running = 0; |
|
cpu->dead = 1; |
|
648 |
break; |
break; |
649 |
default: |
default: |
650 |
fatal("DEC prom emulation: unknown rex() a0=0x%"PRIx64 |
fatal("DEC prom emulation: unknown rex() a0=0x%"PRIx64 |
652 |
(int64_t) cpu->cd.mips.gpr[MIPS_GPR_A0], |
(int64_t) cpu->cd.mips.gpr[MIPS_GPR_A0], |
653 |
(char) cpu->cd.mips.gpr[MIPS_GPR_A0]); |
(char) cpu->cd.mips.gpr[MIPS_GPR_A0]); |
654 |
cpu->running = 0; |
cpu->running = 0; |
|
cpu->dead = 1; |
|
655 |
} |
} |
656 |
break; |
break; |
657 |
default: |
default: |
671 |
fatal("PROM emulation: unimplemented callback vector 0x%x\n", |
fatal("PROM emulation: unimplemented callback vector 0x%x\n", |
672 |
vector); |
vector); |
673 |
cpu->running = 0; |
cpu->running = 0; |
|
cpu->dead = 1; |
|
674 |
} |
} |
675 |
|
|
676 |
return 1; |
return 1; |