Mercurial > audlegacy-plugins
annotate src/psf2/psx_hw.c @ 3193:93cf4d0a0dde
alsa-ng: Prefer "PCM" volume control over "Wave" on systems that have both, for consistency with OSS plugin and maybe other apps (closes AUD-34 and AUD-36).
author | John Lindgren <john.lindgren@tds.net> |
---|---|
date | Mon, 29 Jun 2009 23:05:56 -0400 |
parents | f2c62b0fc3ba |
children |
rev | line source |
---|---|
2737
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1 /* |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2 Audio Overload SDK - PSX and IOP hardware emulation |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
4 Copyright (c) 2007 R. Belmont and Richard Bannister. |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
5 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
6 All rights reserved. |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
7 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
8 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
9 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
10 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
11 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
12 * Neither the names of R. Belmont and Richard Bannister nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
13 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
15 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
16 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
17 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
18 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
19 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
20 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
21 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
22 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
23 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
24 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
25 */ |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
26 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
27 /* |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
28 psx_hw.c - Minimal PSX/IOP hardware glue/emulation/whatever |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
29 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
30 supported: main RAM (2 MB, mirrored to fill an 8 MB space like on real HW) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
31 DMA channel 4 (SPURAM) in both directions (including completion IRQ) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
32 VBL IRQ |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
33 Root counters 2 and 3 including completion events and IRQs |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
34 Some BIOS services including exception handling (via HLE) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
35 HLE emulation of IOP operating system, including multithreading |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
36 SPU(2), SPU(2)RAM (via PEOpS) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
37 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
38 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
39 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
40 Special notes: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
41 PSF1 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
42 - Chocobo's Dungeon 2 contains an illegal code sequence (patched) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
43 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
44 PSF2 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
45 - Shadow Hearts assumes that the wave buffer alloc will go to 0x80060000 and the sequence buffer to 0x80170000. |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
46 Our memory management doesn't work out that way, so we have to (wait for it) cheese it. |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
47 */ |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
48 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
49 #include <stdio.h> |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
50 #include "ao.h" |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
51 #include "cpuintrf.h" |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
52 #include "psx.h" |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
53 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
54 #define DEBUG_HLE_BIOS (0) // debug PS1 HLE BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
55 #define DEBUG_HLE_IOP (0) // debug PS2 IOP OS calls |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
56 #define DEBUG_UNK_RW (0) // debug unknown reads/writes |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
57 #define DEBUG_THREADING (0) // debug PS2 IOP threading |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
58 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
59 extern void mips_get_info(UINT32 state, union cpuinfo *info); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
60 extern void mips_set_info(UINT32 state, union cpuinfo *info); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
61 extern int psxcpu_verbose; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
62 extern void mips_shorten_frame(void); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
63 extern int mips_execute( int cycles ); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
64 extern uint32 psf2_load_file(char *file, uint8 *buf, uint32 buflen); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
65 extern uint32 psf2_load_elf(uint8 *start, uint32 len); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
66 void psx_hw_runcounters(void); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
67 int mips_get_icount(void); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
68 void mips_set_icount(int count); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
69 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
70 // SPU2 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
71 extern void SPU2write(unsigned long reg, unsigned short val); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
72 extern unsigned short SPU2read(unsigned long reg); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
73 extern void SPU2readDMA4Mem(uint32 usPSXMem,int iSize); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
74 extern void SPU2writeDMA4Mem(uint32 usPSXMem,int iSize); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
75 extern void SPU2readDMA7Mem(uint32 usPSXMem,int iSize); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
76 extern void SPU2writeDMA7Mem(uint32 usPSXMem,int iSize); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
77 extern void SPU2interruptDMA4(void); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
78 extern void SPU2interruptDMA7(void); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
79 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
80 #define MAX_FILE_SLOTS (32) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
81 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
82 static volatile int softcall_target = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
83 static int filestat[MAX_FILE_SLOTS]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
84 static uint8 *filedata[MAX_FILE_SLOTS]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
85 static uint32 filesize[MAX_FILE_SLOTS], filepos[MAX_FILE_SLOTS]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
86 uint32 psf2_get_loadaddr(void); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
87 void psf2_set_loadaddr(uint32 new); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
88 static void call_irq_routine(uint32 routine, uint32 parameter); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
89 static int intr_susp = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
90 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
91 static uint64 sys_time; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
92 static int timerexp = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
93 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
94 typedef struct |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
95 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
96 char name[10]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
97 uint32 dispatch; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
98 } ExternLibEntries; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
99 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
100 static int32 iNumLibs; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
101 static ExternLibEntries reglibs[32]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
102 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
103 typedef struct |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
104 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
105 uint32 type; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
106 uint32 value; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
107 uint32 param; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
108 int inUse; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
109 } EventFlag; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
110 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
111 static int32 iNumFlags; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
112 static EventFlag evflags[32]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
113 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
114 typedef struct |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
115 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
116 uint32 attr; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
117 uint32 option; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
118 int32 init; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
119 int32 current; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
120 int32 max; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
121 int32 threadsWaiting; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
122 int32 inuse; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
123 } Semaphore; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
124 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
125 #define SEMA_MAX (64) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
126 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
127 static int32 iNumSema; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
128 static Semaphore semaphores[SEMA_MAX]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
129 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
130 // thread states |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
131 enum |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
132 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
133 TS_RUNNING = 0, // now running |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
134 TS_READY, // ready to run |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
135 TS_WAITEVFLAG, // waiting on an event flag |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
136 TS_WAITSEMA, // waiting on a semaphore |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
137 TS_WAITDELAY, // waiting on a time delay |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
138 TS_SLEEPING, // sleeping |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
139 TS_CREATED, // newly created, hasn't run yet |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
140 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
141 TS_MAXSTATE |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
142 }; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
143 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
144 typedef struct |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
145 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
146 int32 iState; // state of thread |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
147 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
148 uint32 flags; // flags |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
149 uint32 routine; // start of code for the thread |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
150 uint32 stackloc; // stack location in IOP RAM |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
151 uint32 stacksize; // stack size |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
152 uint32 refCon; // user value passed in at CreateThread time |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
153 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
154 uint32 waitparm; // what we're waiting on if in one the TS_WAIT* states |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
155 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
156 uint32 save_regs[37]; // CPU registers belonging to this thread |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
157 } Thread; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
158 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
159 static int32 iNumThreads, iCurThread; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
160 static Thread threads[32]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
161 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
162 #if DEBUG_THREADING |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
163 static char *_ThreadStateNames[TS_MAXSTATE] = { "RUNNING", "READY", "WAITEVFLAG", "WAITSEMA", "WAITDELAY", "SLEEPING", "CREATED" }; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
164 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
165 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
166 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
167 static char *seek_types[3] = { "SEEK_SET", "SEEK_CUR", "SEEK_END" }; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
168 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
169 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
170 typedef struct |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
171 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
172 int32 iActive; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
173 uint32 count; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
174 uint32 target; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
175 uint32 source; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
176 uint32 prescale; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
177 uint32 handler; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
178 uint32 hparam; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
179 uint32 mode; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
180 } IOPTimer; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
181 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
182 static IOPTimer iop_timers[8]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
183 static int32 iNumTimers; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
184 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
185 typedef struct |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
186 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
187 uint32 count; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
188 uint32 mode; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
189 uint32 target; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
190 uint32 sysclock; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
191 } Counter; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
192 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
193 static Counter root_cnts[3]; // 3 of the bastards |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
194 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
195 #define CLOCK_DIV (8) // 33 MHz / this = what we run the R3000 at to keep the CPU usage not insane |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
196 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
197 // counter modes |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
198 #define RC_EN (0x0001) // halt |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
199 #define RC_RESET (0x0008) // automatically wrap |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
200 #define RC_IQ1 (0x0010) // IRQ when target reached |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
201 #define RC_IQ2 (0x0040) // IRQ when target reached (pSX treats same as IQ1?) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
202 #define RC_CLC (0x0100) // counter uses direct system clock |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
203 #define RC_DIV8 (0x0200) // (counter 2 only) system clock/8 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
204 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
205 typedef struct |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
206 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
207 uint32 desc; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
208 int32 status; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
209 int32 mode; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
210 uint32 fhandler; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
211 } EvtCtrlBlk[32]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
212 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
213 static EvtCtrlBlk *Event; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
214 static EvtCtrlBlk *CounterEvent; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
215 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
216 // Sony event states |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
217 #define EvStUNUSED 0x0000 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
218 #define EvStWAIT 0x1000 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
219 #define EvStACTIVE 0x2000 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
220 #define EvStALREADY 0x4000 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
221 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
222 // Sony event modes |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
223 #define EvMdINTR 0x1000 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
224 #define EvMdNOINTR 0x2000 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
225 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
226 // PSX main RAM |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
227 uint32 psx_ram[(2*1024*1024)/4]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
228 uint32 psx_scratch[0x400]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
229 // backup image to restart songs |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
230 uint32 initial_ram[(2*1024*1024)/4]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
231 uint32 initial_scratch[0x400]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
232 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
233 static uint32 spu_delay, dma_icr, irq_data, irq_mask, dma_timer, WAI; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
234 static uint32 dma4_madr, dma4_bcr, dma4_chcr, dma4_delay; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
235 static uint32 dma7_madr, dma7_bcr, dma7_chcr, dma7_delay; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
236 static uint32 dma4_cb, dma7_cb, dma4_fval, dma4_flag, dma7_fval, dma7_flag; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
237 static uint32 irq9_cb, irq9_fval, irq9_flag; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
238 |
2956
f2c62b0fc3ba
Start on line-level output model, not unlike upse.
William Pitcock <nenolod@atheme.org>
parents:
2955
diff
changeset
|
239 #if DEBUG_THREADING |
f2c62b0fc3ba
Start on line-level output model, not unlike upse.
William Pitcock <nenolod@atheme.org>
parents:
2955
diff
changeset
|
240 static int wakecount = 0; |
f2c62b0fc3ba
Start on line-level output model, not unlike upse.
William Pitcock <nenolod@atheme.org>
parents:
2955
diff
changeset
|
241 #endif |
f2c62b0fc3ba
Start on line-level output model, not unlike upse.
William Pitcock <nenolod@atheme.org>
parents:
2955
diff
changeset
|
242 |
2737
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
243 // take a snapshot of the CPU state for a thread |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
244 static void FreezeThread(int32 iThread, int flag) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
245 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
246 int i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
247 union cpuinfo mipsinfo; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
248 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
249 #if DEBUG_THREADING |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
250 // printf("IOP: FreezeThread(%d)\n", iThread); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
251 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
252 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
253 for (i = 0; i < 32; i++) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
254 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
255 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R0 + i, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
256 threads[iThread].save_regs[i] = mipsinfo.i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
257 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
258 mips_get_info(CPUINFO_INT_REGISTER + MIPS_HI, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
259 threads[iThread].save_regs[32] = mipsinfo.i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
260 mips_get_info(CPUINFO_INT_REGISTER + MIPS_LO, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
261 threads[iThread].save_regs[33] = mipsinfo.i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
262 mips_get_info(CPUINFO_INT_REGISTER + MIPS_DELAYV, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
263 threads[iThread].save_regs[35] = mipsinfo.i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
264 mips_get_info(CPUINFO_INT_REGISTER + MIPS_DELAYR, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
265 threads[iThread].save_regs[36] = mipsinfo.i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
266 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
267 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
268 // if a thread is freezing itself due to a IOP syscall, we must save the RA as the PC |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
269 // to come back to or else the syscall will recurse |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
270 if (flag) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
271 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
272 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R31, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
273 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
274 else |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
275 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
276 mips_get_info(CPUINFO_INT_PC, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
277 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
278 threads[iThread].save_regs[34] = mipsinfo.i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
279 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
280 #if DEBUG_THREADING |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
281 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
282 char buffer[256]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
283 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
284 printf("IOP: FreezeThread(%d) => %08x [%s]\n", iThread, threads[iThread].save_regs[34], buffer); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
285 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
286 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
287 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
288 // if thread was running, now it's ready |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
289 if (threads[iThread].iState == TS_RUNNING) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
290 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
291 threads[iThread].iState = TS_READY; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
292 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
293 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
294 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
295 // restore the CPU state from a thread's snapshot |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
296 static void ThawThread(int32 iThread) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
297 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
298 int i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
299 union cpuinfo mipsinfo; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
300 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
301 // the first time a thread is put on the CPU, |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
302 // some special setup is required |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
303 if (threads[iThread].iState == TS_CREATED) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
304 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
305 // PC = starting routine |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
306 threads[iThread].save_regs[34] = threads[iThread].routine-4; // compensate for weird delay slot effects |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
307 // SP = thread's stack area |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
308 threads[iThread].save_regs[29] = (threads[iThread].stackloc + threads[iThread].stacksize) - 16; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
309 threads[iThread].save_regs[29] |= 0x80000000; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
310 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
311 threads[iThread].save_regs[35] = threads[iThread].save_regs[36] = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
312 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
313 #if DEBUG_THREADING |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
314 // printf("IOP: Initial setup for thread %d => PC %x SP %x\n", iThread, threads[iThread].save_regs[34]+4, threads[iThread].save_regs[29]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
315 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
316 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
317 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
318 #if DEBUG_THREADING |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
319 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
320 char buffer[256]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
321 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
322 mips_get_info(CPUINFO_INT_PC, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
323 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
324 printf("IOP: ThawThread(%d) => %08x [%s] (wake %d)\n", iThread, threads[iThread].save_regs[34], buffer, wakecount); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
325 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
326 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
327 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
328 for (i = 0; i < 32; i++) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
329 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
330 mipsinfo.i = threads[iThread].save_regs[i]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
331 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R0 + i, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
332 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
333 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
334 mipsinfo.i = threads[iThread].save_regs[32]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
335 mips_set_info(CPUINFO_INT_REGISTER + MIPS_HI, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
336 mipsinfo.i = threads[iThread].save_regs[33]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
337 mips_set_info(CPUINFO_INT_REGISTER + MIPS_LO, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
338 mipsinfo.i = threads[iThread].save_regs[34]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
339 mips_set_info(CPUINFO_INT_PC, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
340 mipsinfo.i = threads[iThread].save_regs[35]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
341 mips_set_info(CPUINFO_INT_REGISTER + MIPS_DELAYV, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
342 mipsinfo.i = threads[iThread].save_regs[36]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
343 mips_set_info(CPUINFO_INT_REGISTER + MIPS_DELAYR, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
344 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
345 threads[iThread].iState = TS_RUNNING; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
346 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
347 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
348 // find a new thread to run |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
349 static void ps2_reschedule(void) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
350 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
351 int i, starti, iNextThread; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
352 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
353 iNextThread = -1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
354 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
355 // see if any thread other than the current one is ready to run |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
356 i = iCurThread+1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
357 if (i >= iNumThreads) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
358 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
359 i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
360 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
361 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
362 starti = i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
363 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
364 // starting with the next thread after this one, |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
365 // see who wants to run |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
366 while (i < iNumThreads) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
367 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
368 if (i != iCurThread) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
369 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
370 if (threads[i].iState == TS_READY) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
371 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
372 iNextThread = i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
373 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
374 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
375 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
376 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
377 i++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
378 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
379 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
380 // if we started above thread 0 and didn't pick one, |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
381 // go around and try from zero |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
382 if ((starti > 0) && (iNextThread == -1)) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
383 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
384 for (i = 0; i < iNumThreads; i++) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
385 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
386 if (i != iCurThread) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
387 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
388 if (threads[i].iState == TS_READY) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
389 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
390 iNextThread = i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
391 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
392 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
393 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
394 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
395 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
396 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
397 if (iNextThread != -1) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
398 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
399 #if DEBUG_THREADING |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
400 for (i = 0; i < iNumThreads; i++) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
401 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
402 printf("Thread %02d: %s\n", i, _ThreadStateNames[threads[i].iState]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
403 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
404 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
405 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
406 if (iCurThread != -1) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
407 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
408 FreezeThread(iCurThread, 0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
409 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
410 ThawThread(iNextThread); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
411 iCurThread = iNextThread; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
412 threads[iCurThread].iState = TS_RUNNING; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
413 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
414 else |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
415 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
416 // no thread to switch to, is the current one still running? |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
417 if (iCurThread != -1) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
418 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
419 if (threads[iCurThread].iState != TS_RUNNING) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
420 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
421 #if DEBUG_THREADING |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
422 printf("IOP: no threads to run\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
423 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
424 for (i = 0; i < iNumThreads; i++) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
425 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
426 printf("Thread %02d: %s\n", i, _ThreadStateNames[threads[i].iState]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
427 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
428 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
429 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
430 mips_shorten_frame(); // kill the CPU |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
431 iCurThread = -1; // no threads are active |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
432 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
433 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
434 else |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
435 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
436 mips_shorten_frame(); // kill the CPU |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
437 iCurThread = -1; // no threads are active |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
438 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
439 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
440 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
441 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
442 static void psx_irq_update(void) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
443 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
444 union cpuinfo mipsinfo; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
445 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
446 if ((irq_data & irq_mask) != 0) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
447 { // assert the line |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
448 WAI = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
449 mipsinfo.i = ASSERT_LINE; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
450 mips_set_info( CPUINFO_INT_INPUT_STATE + MIPS_IRQ0, &mipsinfo ); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
451 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
452 else |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
453 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
454 // clear the line |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
455 mipsinfo.i = CLEAR_LINE; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
456 mips_set_info( CPUINFO_INT_INPUT_STATE + MIPS_IRQ0, &mipsinfo ); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
457 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
458 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
459 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
460 void psx_irq_set(uint32 irq) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
461 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
462 irq_data |= irq; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
463 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
464 psx_irq_update(); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
465 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
466 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
467 static uint32 gpu_stat = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
468 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
469 uint32 psx_hw_read(offs_t offset, uint32 mem_mask) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
470 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
471 if (offset >= 0x00000000 && offset <= 0x007fffff) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
472 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
473 offset &= 0x1fffff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
474 return LE32(psx_ram[offset>>2]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
475 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
476 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
477 if (offset >= 0x80000000 && offset <= 0x807fffff) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
478 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
479 offset &= 0x1fffff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
480 return LE32(psx_ram[offset>>2]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
481 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
482 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
483 if (offset == 0xbfc00180 || offset == 0xbfc00184) // exception vector |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
484 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
485 return FUNCT_HLECALL; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
486 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
487 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
488 if (offset == 0x1f801014) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
489 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
490 return spu_delay; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
491 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
492 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
493 if (offset == 0xbf801014) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
494 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
495 return spu_delay; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
496 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
497 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
498 if (offset == 0x1f801814) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
499 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
500 gpu_stat ^= 0xffffffff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
501 return gpu_stat; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
502 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
503 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
504 if (offset >= 0xbf900000 && offset <= 0xbf9007ff) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
505 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
506 if ((mem_mask == 0xffff0000) || (mem_mask == 0xffffff00)) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
507 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
508 return SPU2read(offset) & ~mem_mask; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
509 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
510 else if (mem_mask == 0x0000ffff) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
511 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
512 return SPU2read(offset)<<16; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
513 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
514 else if (mem_mask == 0) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
515 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
516 return SPU2read(offset) | SPU2read(offset+2)<<16; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
517 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
518 else printf("SPU2: read unknown mask %08x\n", mem_mask); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
519 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
520 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
521 if (offset >= 0x1f801100 && offset <= 0x1f801128) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
522 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
523 int cnt = (offset>>4) & 0xf; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
524 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
525 switch (offset & 0xf) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
526 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
527 case 0: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
528 // printf("RC: read counter %d count = %x\n", cnt, root_cnts[cnt].count); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
529 return root_cnts[cnt].count; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
530 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
531 case 4: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
532 // printf("RC: read counter %d mode\n", cnt); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
533 return root_cnts[cnt].mode; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
534 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
535 case 8: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
536 // printf("RC: read counter %d target\n", cnt); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
537 return root_cnts[cnt].target; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
538 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
539 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
540 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
541 return 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
542 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
543 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
544 if (offset == 0x1f8010f4) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
545 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
546 return dma_icr; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
547 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
548 else if (offset == 0x1f801070) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
549 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
550 // printf("Read IRQ_data %x (mask %08x)\n", irq_data, mem_mask); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
551 return irq_data; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
552 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
553 else if (offset == 0x1f801074) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
554 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
555 return irq_mask; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
556 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
557 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
558 /* if (offset == 0xbf801508) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
559 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
560 return dma7_bcr; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
561 }*/ |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
562 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
563 if (offset == 0xbf920344) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
564 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
565 return 0x80808080; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
566 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
567 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
568 #if DEBUG_UNK_RW |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
569 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
570 union cpuinfo mipsinfo; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
571 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
572 mips_get_info(CPUINFO_INT_PC, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
573 printf("Unknown read: %08x, mask %08x (PC=%x)\n", offset&~3, mem_mask, mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
574 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
575 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
576 return 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
577 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
578 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
579 static void ps2_dma4(uint32 madr, uint32 bcr, uint32 chcr) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
580 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
581 if (chcr == 0x01000201) // cpu to SPU2 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
582 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
583 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
584 printf("DMA4: RAM %08x to SPU2\n", madr); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
585 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
586 bcr = (bcr>>16) * (bcr & 0xffff) * 4; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
587 SPU2writeDMA4Mem(madr&0x1fffff, bcr); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
588 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
589 else |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
590 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
591 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
592 printf("DMA4: SPU2 to RAM %08x\n", madr); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
593 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
594 bcr = (bcr>>16) * (bcr & 0xffff) * 4; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
595 SPU2readDMA4Mem(madr&0x1fffff, bcr); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
596 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
597 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
598 dma4_delay = 80; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
599 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
600 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
601 static void ps2_dma7(uint32 madr, uint32 bcr, uint32 chcr) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
602 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
603 if ((chcr == 0x01000201) || (chcr == 0x00100010) || (chcr == 0x000f0010) || (chcr == 0x00010010)) // cpu to SPU2 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
604 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
605 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
606 printf("DMA7: RAM %08x to SPU2\n", madr); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
607 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
608 bcr = (bcr>>16) * (bcr & 0xffff) * 4; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
609 SPU2writeDMA7Mem(madr&0x1fffff, bcr); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
610 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
611 else |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
612 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
613 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
614 printf("DMA7: SPU2 to RAM %08x\n", madr); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
615 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
616 bcr = (bcr>>16) * (bcr & 0xffff) * 4; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
617 // SPU2readDMA7Mem(madr&0x1fffff, bcr); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
618 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
619 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
620 dma7_delay = 80; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
621 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
622 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
623 void psx_hw_write(offs_t offset, uint32 data, uint32 mem_mask) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
624 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
625 union cpuinfo mipsinfo; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
626 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
627 if (offset >= 0x00000000 && offset <= 0x007fffff) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
628 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
629 offset &= 0x1fffff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
630 // if (offset < 0x10000) printf("Write %x to kernel @ %x\n", data, offset); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
631 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
632 mips_get_info(CPUINFO_INT_PC, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
633 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
634 psx_ram[offset>>2] &= LE32(mem_mask); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
635 psx_ram[offset>>2] |= LE32(data); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
636 return; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
637 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
638 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
639 if (offset >= 0x80000000 && offset <= 0x807fffff) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
640 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
641 offset &= 0x1fffff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
642 // if (offset < 0x10000) printf("Write %x to kernel @ %x\n", data, offset); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
643 mips_get_info(CPUINFO_INT_PC, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
644 psx_ram[offset>>2] &= LE32(mem_mask); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
645 psx_ram[offset>>2] |= LE32(data); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
646 return; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
647 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
648 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
649 if (offset == 0x1f801014 || offset == 0xbf801014) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
650 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
651 spu_delay &= mem_mask; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
652 spu_delay |= data; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
653 return; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
654 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
655 |
2955
eb29c6fbdeb3
Remove unnecessary PS1 emulation core.
William Pitcock <nenolod@atheme.org>
parents:
2954
diff
changeset
|
656 #if 0 |
2737
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
657 if (offset >= 0x1f801c00 && offset <= 0x1f801dff) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
658 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
659 // printf("SPU2 wrote %x to SPU1 address %x!\n", data, offset); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
660 if (mem_mask == 0xffff0000) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
661 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
662 SPUwriteRegister(offset, data); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
663 return; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
664 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
665 else if (mem_mask == 0x0000ffff) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
666 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
667 SPUwriteRegister(offset, data>>16); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
668 return; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
669 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
670 else printf("SPU: write unknown mask %08x\n", mem_mask); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
671 } |
2955
eb29c6fbdeb3
Remove unnecessary PS1 emulation core.
William Pitcock <nenolod@atheme.org>
parents:
2954
diff
changeset
|
672 #endif |
2737
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
673 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
674 if (offset >= 0xbf900000 && offset <= 0xbf9007ff) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
675 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
676 if (mem_mask == 0xffff0000) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
677 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
678 SPU2write(offset, data); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
679 return; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
680 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
681 else if (mem_mask == 0x0000ffff) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
682 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
683 SPU2write(offset, data>>16); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
684 return; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
685 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
686 else if (mem_mask == 0) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
687 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
688 SPU2write(offset, data & 0xffff); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
689 SPU2write(offset+2, data>>16); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
690 return; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
691 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
692 else printf("SPU2: write unknown mask %08x\n", mem_mask); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
693 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
694 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
695 if (offset >= 0x1f801100 && offset <= 0x1f801128) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
696 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
697 int cnt = (offset>>4) & 0xf; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
698 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
699 switch (offset & 0xf) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
700 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
701 case 0: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
702 root_cnts[cnt].count = data; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
703 // printf("RC: counter %d count = %x\n", cnt, data); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
704 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
705 case 4: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
706 root_cnts[cnt].mode = data; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
707 // printf("RC: counter %d mode = %x\n", cnt, data); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
708 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
709 case 8: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
710 root_cnts[cnt].target = data; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
711 // printf("RC: counter %d target = %x\n", cnt, data); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
712 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
713 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
714 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
715 return; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
716 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
717 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
718 // PS2 DMA4 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
719 if (offset == 0xbf8010c0) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
720 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
721 dma4_madr = data; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
722 return; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
723 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
724 else if (offset == 0xbf8010c8) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
725 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
726 dma4_chcr = data; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
727 ps2_dma4(dma4_madr, dma4_bcr, dma4_chcr); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
728 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
729 if (dma_icr & (1 << (16+4))) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
730 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
731 dma_timer = 3; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
732 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
733 return; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
734 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
735 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
736 if (offset == 0xbf8010c4 || offset == 0xbf8010c6) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
737 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
738 dma4_bcr &= mem_mask; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
739 dma4_bcr |= data; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
740 return; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
741 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
742 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
743 // PS2 DMA7 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
744 if (offset == 0xbf801500) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
745 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
746 dma7_madr = data; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
747 return; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
748 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
749 else if (offset == 0xbf801504) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
750 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
751 dma7_chcr = data; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
752 ps2_dma7(dma7_madr, dma7_bcr, dma7_chcr); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
753 return; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
754 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
755 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
756 if (offset == 0xbf801508 || offset == 0xbf80150a) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
757 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
758 dma7_bcr &= mem_mask; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
759 dma7_bcr |= data; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
760 return; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
761 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
762 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
763 #if DEBUG_UNK_RW |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
764 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
765 union cpuinfo mipsinfo; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
766 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
767 mips_get_info(CPUINFO_INT_PC, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
768 printf("Unknown write: %08x to %08x, mask %08x (PC=%x)\n", data, offset&~3, mem_mask, mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
769 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
770 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
771 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
772 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
773 // called per sample, 1/44100th of a second (768 clock cycles) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
774 void psx_hw_slice(void) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
775 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
776 psx_hw_runcounters(); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
777 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
778 if (!WAI) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
779 mips_execute(768/CLOCK_DIV); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
780 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
781 if (dma_timer) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
782 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
783 dma_timer--; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
784 if (dma_timer == 0) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
785 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
786 dma_icr |= (1 << (24+4)); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
787 psx_irq_set(0x0008); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
788 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
789 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
790 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
791 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
792 void ps2_hw_slice(void) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
793 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
794 int i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
795 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
796 timerexp = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
797 psx_hw_runcounters(); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
798 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
799 if (iCurThread != -1) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
800 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
801 mips_execute(836/CLOCK_DIV); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
802 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
803 else // no thread, don't run CPU, just update counters |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
804 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
805 if (timerexp) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
806 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
807 ps2_reschedule(); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
808 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
809 if (iCurThread != -1) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
810 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
811 mips_execute((836/CLOCK_DIV)-i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
812 i = (836/CLOCK_DIV); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
813 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
814 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
815 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
816 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
817 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
818 void ps2_hw_frame(void) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
819 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
820 ps2_reschedule(); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
821 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
822 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
823 // BIOS HLE |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
824 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
825 // heap block struct offsets |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
826 enum |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
827 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
828 BLK_STAT = 0, |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
829 BLK_SIZE = 4, |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
830 BLK_FD = 8, |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
831 BLK_BK = 12 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
832 }; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
833 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
834 static uint32 heap_addr, entry_int = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
835 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
836 extern uint32 mips_get_cause(void); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
837 extern uint32 mips_get_status(void); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
838 extern void mips_set_status(uint32 status); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
839 extern uint32 mips_get_ePC(void); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
840 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
841 static uint32 irq_regs[37]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
842 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
843 static int irq_mutex = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
844 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
845 static void call_irq_routine(uint32 routine, uint32 parameter) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
846 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
847 int j, oldICount; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
848 union cpuinfo mipsinfo; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
849 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
850 if (!irq_mutex) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
851 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
852 irq_mutex = 1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
853 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
854 else |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
855 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
856 printf("IOP: ERROR! IRQ reentry!\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
857 return; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
858 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
859 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
860 // save regs for IRQ |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
861 for (j = 0; j < 32; j++) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
862 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
863 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R0 + j, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
864 irq_regs[j] = mipsinfo.i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
865 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
866 mips_get_info(CPUINFO_INT_REGISTER + MIPS_HI, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
867 irq_regs[32] = mipsinfo.i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
868 mips_get_info(CPUINFO_INT_REGISTER + MIPS_LO, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
869 irq_regs[33] = mipsinfo.i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
870 mips_get_info(CPUINFO_INT_PC, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
871 irq_regs[34] = mipsinfo.i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
872 mips_get_info(CPUINFO_INT_REGISTER + MIPS_DELAYV, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
873 irq_regs[35] = mipsinfo.i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
874 mips_get_info(CPUINFO_INT_REGISTER + MIPS_DELAYR, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
875 irq_regs[36] = mipsinfo.i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
876 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
877 // PC = timer handler routine |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
878 mipsinfo.i = routine; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
879 mips_set_info(CPUINFO_INT_PC, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
880 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
881 // parameter in a0 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
882 mipsinfo.i = parameter; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
883 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R4, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
884 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
885 // RA = a trap address we can set |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
886 mipsinfo.i = 0x80001000; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
887 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R31, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
888 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
889 // make sure we're set |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
890 psx_ram[0x1000/4] = LE32(FUNCT_HLECALL); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
891 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
892 softcall_target = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
893 oldICount = mips_get_icount(); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
894 while (!softcall_target) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
895 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
896 mips_execute(10); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
897 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
898 mips_set_icount(oldICount); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
899 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
900 // restore IRQ regs |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
901 for (j = 0; j < 32; j++) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
902 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
903 mipsinfo.i = irq_regs[j]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
904 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R0 + j, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
905 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
906 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
907 mipsinfo.i = irq_regs[32]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
908 mips_set_info(CPUINFO_INT_REGISTER + MIPS_HI, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
909 mipsinfo.i = irq_regs[33]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
910 mips_set_info(CPUINFO_INT_REGISTER + MIPS_LO, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
911 mipsinfo.i = irq_regs[34]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
912 mips_set_info(CPUINFO_INT_PC, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
913 mipsinfo.i = irq_regs[35]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
914 mips_set_info(CPUINFO_INT_REGISTER + MIPS_DELAYV, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
915 mipsinfo.i = irq_regs[36]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
916 mips_set_info(CPUINFO_INT_REGISTER + MIPS_DELAYR, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
917 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
918 irq_mutex = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
919 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
920 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
921 void psx_bios_exception(uint32 pc) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
922 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
923 uint32 a0, status; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
924 union cpuinfo mipsinfo; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
925 int i, oldICount; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
926 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
927 // printf("bios_exception: cause %x\n", mips_get_cause() & 0x3c); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
928 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
929 // get a0 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
930 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R4, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
931 a0 = mipsinfo.i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
932 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
933 switch (mips_get_cause() & 0x3c) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
934 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
935 case 0: // IRQ |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
936 // printf("IRQ: %x, mask %x\n", irq_data, irq_mask); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
937 // save all regs |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
938 for (i = 0; i < 32; i++) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
939 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
940 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R0 + i, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
941 irq_regs[i] = mipsinfo.i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
942 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
943 mips_get_info(CPUINFO_INT_REGISTER + MIPS_HI, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
944 irq_regs[32] = mipsinfo.i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
945 mips_get_info(CPUINFO_INT_REGISTER + MIPS_LO, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
946 irq_regs[33] = mipsinfo.i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
947 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
948 // check BIOS-driven interrupts |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
949 if (irq_data & 1) // VSync |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
950 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
951 if (CounterEvent[3][1].status == LE32(EvStACTIVE)) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
952 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
953 // run the handler |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
954 mipsinfo.i = LE32(CounterEvent[3][1].fhandler); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
955 // printf("Cause = %x, ePC = %x\n", mips_get_cause(), mips_get_ePC()); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
956 // printf("VBL running handler @ %x\n", mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
957 mips_set_info(CPUINFO_INT_PC, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
958 mipsinfo.i = 0x80001000; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
959 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R31, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
960 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
961 // make sure we're set |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
962 psx_ram[0x1000/4] = LE32(FUNCT_HLECALL); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
963 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
964 softcall_target = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
965 oldICount = mips_get_icount(); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
966 while (!softcall_target) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
967 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
968 mips_execute(10); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
969 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
970 mips_set_icount(oldICount); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
971 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
972 // printf("Exiting softcall handler\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
973 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
974 irq_data &= ~1; // clear the VBL IRQ if we handled it |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
975 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
976 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
977 else if (irq_data & 0x70) // root counters |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
978 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
979 for (i = 0; i < 3; i++) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
980 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
981 if (irq_data & (1 << (i+4))) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
982 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
983 if (CounterEvent[i][1].status == LE32(EvStACTIVE)) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
984 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
985 // run the handler |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
986 mipsinfo.i = LE32(CounterEvent[i][1].fhandler); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
987 // printf("Cause = %x, ePC = %x\n", mips_get_cause(), mips_get_ePC()); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
988 // printf("Counter %d running handler @ %x\n", i, mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
989 mips_set_info(CPUINFO_INT_PC, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
990 mipsinfo.i = 0x80001000; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
991 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R31, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
992 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
993 // make sure we're set |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
994 psx_ram[0x1000/4] = LE32(FUNCT_HLECALL); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
995 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
996 softcall_target = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
997 oldICount = mips_get_icount(); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
998 while (!softcall_target) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
999 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1000 mips_execute(10); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1001 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1002 mips_set_icount(oldICount); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1003 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1004 // printf("Exiting softcall handler\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1005 irq_data &= ~(1 << (i+4)); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1006 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1007 else |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1008 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1009 // printf("CEvt %d not active\n", i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1010 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1011 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1012 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1013 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1014 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1015 if (entry_int) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1016 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1017 psx_hw_write(0x1f801070, 0xffffffff, 0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1018 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1019 a0 = entry_int; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1020 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1021 // printf("taking entry_int\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1022 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1023 // RA (and PC) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1024 mipsinfo.i = LE32(psx_ram[((a0&0x1fffff)+0)/4]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1025 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R31, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1026 mips_set_info(CPUINFO_INT_PC, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1027 // SP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1028 mipsinfo.i = LE32(psx_ram[((a0&0x1fffff)+4)/4]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1029 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R29, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1030 // FP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1031 mipsinfo.i = LE32(psx_ram[((a0&0x1fffff)+8)/4]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1032 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R30, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1033 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1034 // S0-S7 are next |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1035 for (i = 0; i < 8; i++) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1036 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1037 mipsinfo.i = LE32(psx_ram[((a0&0x1fffff)+12+(i*4))/4]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1038 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R16 + i, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1039 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1040 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1041 // GP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1042 mipsinfo.i = LE32(psx_ram[((a0&0x1fffff)+44)/4]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1043 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R28, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1044 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1045 // v0 = 1 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1046 mipsinfo.i = 1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1047 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1048 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1049 else |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1050 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1051 psx_hw_write(0x1f801070, 0, 0xffff0000); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1052 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1053 // note: the entry_int won't be bailing us out here, so do it ourselves |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1054 for (i = 0; i < 32; i++) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1055 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1056 mipsinfo.i = irq_regs[i]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1057 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R0 + i, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1058 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1059 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1060 mipsinfo.i = irq_regs[32]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1061 mips_set_info(CPUINFO_INT_REGISTER + MIPS_HI, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1062 mipsinfo.i = irq_regs[33]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1063 mips_set_info(CPUINFO_INT_REGISTER + MIPS_LO, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1064 mipsinfo.i = mips_get_ePC(); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1065 mips_set_info(CPUINFO_INT_PC, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1066 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1067 status = mips_get_status(); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1068 status = (status & 0xfffffff0) | ((status & 0x3c)>>2); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1069 mips_set_status(status); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1070 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1071 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1072 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1073 case 0x20: // syscall |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1074 // syscall always farks with the status, so get it now |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1075 status = mips_get_status(); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1076 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1077 switch (a0) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1078 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1079 case 1: // EnterCritical |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1080 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1081 printf("HLEBIOS: EnterCritical\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1082 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1083 status &= ~0x0404; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1084 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1085 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1086 case 2: // ExitCritical |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1087 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1088 printf("HLEBIOS: ExitCritical\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1089 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1090 status |= 0x0404; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1091 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1092 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1093 default: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1094 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1095 printf("HLEBIOS: Unknown syscall %x\n", a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1096 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1097 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1098 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1099 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1100 // PC = ePC + 4 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1101 mipsinfo.i = mips_get_ePC() + 4; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1102 mips_set_info(CPUINFO_INT_PC, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1103 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1104 // and update the status accordingly |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1105 status = (status & 0xfffffff0) | ((status & 0x3c)>>2); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1106 mips_set_status(status); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1107 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1108 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1109 default: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1110 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1111 printf("HLEBIOS: Unknown exception %x\n", mips_get_cause()); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1112 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1113 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1114 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1115 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1116 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1117 static uint32 calc_ev(uint32 a0) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1118 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1119 uint32 ev; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1120 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1121 ev = (a0 >> 24) & 0xf; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1122 if (ev == 0xf) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1123 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1124 ev = 0x5; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1125 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1126 ev *= 32; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1127 ev += (a0 & 0x1f); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1128 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1129 return ev; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1130 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1131 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1132 static uint32 calc_spec(uint32 a1) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1133 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1134 uint32 spec = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1135 int i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1136 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1137 if (a1 == 0x301) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1138 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1139 spec = 16; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1140 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1141 else if (a1 == 0x302) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1142 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1143 spec = 17; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1144 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1145 else |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1146 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1147 for (i = 0; i < 16; i++) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1148 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1149 if (a1 & (1<<i)) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1150 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1151 spec = i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1152 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1153 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1154 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1155 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1156 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1157 return spec; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1158 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1159 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1160 void psx_hw_init(void) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1161 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1162 timerexp = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1163 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1164 memset(filestat, 0, sizeof(filestat)); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1165 memset(filedata, 0, sizeof(filedata)); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1166 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1167 dma4_cb = dma7_cb = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1168 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1169 sys_time = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1170 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1171 // clear registered libraries table |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1172 memset(reglibs, 0, sizeof(reglibs)); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1173 iNumLibs = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1174 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1175 memset(evflags, 0, sizeof(evflags)); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1176 iNumFlags = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1177 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1178 memset(threads, 0, sizeof(threads)); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1179 iNumThreads = 1; // we always have at least one thread |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1180 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1181 memset(semaphores, 0, sizeof(semaphores)); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1182 iNumSema = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1183 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1184 // set the initial thread to "RUNNING" |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1185 threads[0].iState = TS_RUNNING; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1186 iCurThread = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1187 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1188 memset(iop_timers, 0, sizeof(iop_timers)); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1189 iNumTimers = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1190 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1191 // set PS1 BIOS HLE breakpoints |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1192 psx_ram[0xa0/4] = LE32(FUNCT_HLECALL); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1193 psx_ram[0xb0/4] = LE32(FUNCT_HLECALL); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1194 psx_ram[0xc0/4] = LE32(FUNCT_HLECALL); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1195 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1196 Event = (EvtCtrlBlk *)&psx_ram[0x1000/4]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1197 CounterEvent = (Event + (32*2)); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1198 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1199 dma_icr = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1200 spu_delay = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1201 irq_data = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1202 irq_mask = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1203 softcall_target = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1204 gpu_stat = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1205 dma4_madr = dma4_bcr = dma4_chcr = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1206 heap_addr = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1207 entry_int = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1208 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1209 WAI = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1210 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1211 root_cnts[0].mode = RC_EN; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1212 root_cnts[1].mode = RC_EN; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1213 root_cnts[2].mode = RC_EN; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1214 root_cnts[0].sysclock = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1215 root_cnts[1].sysclock = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1216 root_cnts[2].sysclock = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1217 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1218 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1219 void psx_bios_hle(uint32 pc) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1220 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1221 uint32 subcall, status; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1222 union cpuinfo mipsinfo; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1223 uint32 a0, a1, a2, a3; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1224 int i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1225 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1226 if ((pc == 0) || (pc == 0x80000000)) // IOP "null" state |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1227 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1228 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1229 printf("IOP 'null' state\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1230 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1231 // ao_song_done = 1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1232 return; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1233 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1234 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1235 if (pc == 0xbfc00180 || pc == 0xbfc00184) // exception, not BIOS call |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1236 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1237 psx_bios_exception(pc); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1238 return; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1239 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1240 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1241 if (pc == 0x80001000) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1242 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1243 // printf("hit softcall target\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1244 softcall_target = 1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1245 return; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1246 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1247 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1248 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R9, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1249 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1250 subcall = mipsinfo.i & 0xff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1251 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1252 // most calls have a0/a1 as parameters, so prefetch them |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1253 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R4, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1254 a0 = mipsinfo.i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1255 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R5, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1256 a1 = mipsinfo.i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1257 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R6, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1258 a2 = mipsinfo.i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1259 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R7, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1260 a3 = mipsinfo.i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1261 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1262 // mips_get_info(CPUINFO_INT_REGISTER + MIPS_R31, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1263 // printf("HLEBIOS: return is %08x\n", mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1264 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1265 switch (pc) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1266 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1267 case 0xa0: // a0 syscalls |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1268 switch (subcall) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1269 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1270 case 0x13: // setjmp |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1271 // RA |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1272 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R31, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1273 psx_ram[((a0&0x1fffff)+0)/4] = LE32(mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1274 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1275 printf("HLEBIOS: setjmp(%08x) => PC %08x\n", a0, mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1276 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1277 // SP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1278 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R29, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1279 psx_ram[((a0&0x1fffff)+4)/4] = LE32(mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1280 // FP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1281 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R30, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1282 psx_ram[((a0&0x1fffff)+8)/4] = LE32(mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1283 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1284 // S0-S7 are next |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1285 for (i = 0; i < 8; i++) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1286 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1287 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R16 + i, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1288 psx_ram[((a0&0x1fffff)+12+(i*4))/4] = LE32(mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1289 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1290 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1291 // GP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1292 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R28, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1293 psx_ram[((a0&0x1fffff)+44)/4] = LE32(mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1294 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1295 // v0 = 0 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1296 mipsinfo.i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1297 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1298 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1299 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1300 case 0x18: // strncmp |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1301 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1302 uint8 *dst, *src; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1303 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1304 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1305 printf("HLEBIOS: strncmp(%08x, %08x, %d)\n", a0, a1, a2); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1306 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1307 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1308 dst = (uint8 *)psx_ram; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1309 src = (uint8 *)psx_ram; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1310 dst += (a0 & 0x1fffff); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1311 src += (a1 & 0x1fffff); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1312 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1313 // v0 = result |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1314 mipsinfo.i = strncmp((char *)dst, (char *)src, a2); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1315 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1316 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1317 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1318 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1319 case 0x19: // strcpy |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1320 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1321 uint8 *dst, *src; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1322 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1323 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1324 printf("HLEBIOS: strcpy(%08x, %08x)\n", a0, a1); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1325 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1326 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1327 dst = (uint8 *)psx_ram; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1328 src = (uint8 *)psx_ram; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1329 dst += (a0 & 0x1fffff); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1330 src += (a1 & 0x1fffff); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1331 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1332 while (*src) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1333 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1334 *dst = *src; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1335 dst++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1336 src++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1337 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1338 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1339 // v0 = a0 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1340 mipsinfo.i = a0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1341 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1342 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1343 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1344 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1345 case 0x28: // bzero |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1346 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1347 uint8 *dst; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1348 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1349 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1350 printf("HLEBIOS: bzero(%08x, %08x)\n", a0, a1); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1351 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1352 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1353 dst = (uint8 *)psx_ram; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1354 dst += (a0 & 0x1fffff); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1355 memset(dst, 0, a1); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1356 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1357 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1358 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1359 case 0x2a: // memcpy |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1360 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1361 uint8 *dst, *src; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1362 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1363 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1364 printf("HLEBIOS: memcpy(%08x, %08x, %08x)\n", a0, a1, a2); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1365 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1366 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1367 dst = (uint8 *)psx_ram; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1368 src = (uint8 *)psx_ram; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1369 dst += (a0 & 0x1fffff); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1370 src += (a1 & 0x1fffff); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1371 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1372 while (a2) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1373 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1374 *dst = *src; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1375 dst++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1376 src++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1377 a2--; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1378 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1379 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1380 // v0 = a0 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1381 mipsinfo.i = a0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1382 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1383 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1384 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1385 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1386 case 0x2b: // memset |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1387 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1388 uint8 *dst; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1389 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1390 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1391 printf("HLEBIOS: memset(%08x, %08x, %08x)\n", a0, a1, a2); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1392 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1393 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1394 dst = (uint8 *)psx_ram; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1395 dst += (a0 & 0x1fffff); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1396 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1397 while (a2) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1398 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1399 *dst = a1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1400 dst++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1401 a2--; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1402 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1403 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1404 // v0 = a0 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1405 mipsinfo.i = a0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1406 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1407 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1408 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1409 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1410 case 0x2f: // rand |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1411 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1412 printf("HLEBIOS: rand\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1413 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1414 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1415 // v0 = result |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1416 mipsinfo.i = 1 + (int)(32767.0*rand()/(RAND_MAX+1.0)); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1417 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1418 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1419 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1420 case 0x30: // srand |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1421 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1422 printf("HLEBIOS: srand(%x)\n", a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1423 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1424 srand(a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1425 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1426 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1427 case 0x33: // malloc |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1428 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1429 uint32 chunk, fd; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1430 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1431 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1432 printf("HLEBIOS: malloc(%x)\n", a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1433 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1434 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1435 chunk = heap_addr; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1436 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1437 // find a free block that's big enough |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1438 while ((a0 > LE32(psx_ram[(chunk+BLK_SIZE)/4])) || |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1439 (LE32(psx_ram[(chunk+BLK_STAT)/4]) == 1)) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1440 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1441 chunk = LE32(psx_ram[(chunk+BLK_FD)]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1442 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1443 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1444 // split free block |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1445 fd = chunk + 16 + a0; // free block starts after block record and allocation size |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1446 psx_ram[(fd+BLK_STAT)/4] = psx_ram[(chunk+BLK_STAT)/4]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1447 psx_ram[(fd+BLK_SIZE)/4] = LE32(LE32(psx_ram[(chunk+BLK_SIZE)/4]) - a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1448 psx_ram[(fd+BLK_FD)/4] = psx_ram[(chunk+BLK_FD)/4]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1449 psx_ram[(fd+BLK_BK)/4] = chunk; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1450 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1451 psx_ram[(chunk+BLK_STAT)/4] = LE32(1); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1452 psx_ram[(chunk+BLK_SIZE)/4] = LE32(a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1453 psx_ram[(chunk+BLK_FD)/4] = LE32(fd); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1454 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1455 mipsinfo.i = chunk + 16; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1456 mipsinfo.i |= 0x80000000; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1457 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1458 printf("== %08x\n", mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1459 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1460 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1461 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1462 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1463 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1464 case 0x39: // InitHeap |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1465 // heap address in A0, length in A1 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1466 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1467 printf("HLEBIOS: InitHeap(%08x, %08x)\n", a0, a1); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1468 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1469 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1470 heap_addr = a0 & 0x3fffffff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1471 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1472 psx_ram[(heap_addr+BLK_STAT)/4] = LE32(0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1473 psx_ram[(heap_addr+BLK_FD)/4] = LE32(0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1474 psx_ram[(heap_addr+BLK_BK)/4] = LE32(0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1475 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1476 // if heap size out of range, clamp it |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1477 if (((a0 & 0x1fffff) + a1) >= 2*1024*1024) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1478 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1479 psx_ram[(heap_addr+BLK_SIZE)/4] = LE32(0x1ffffc - (a0 & 0x1fffff)); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1480 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1481 else |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1482 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1483 psx_ram[(heap_addr+BLK_SIZE)/4] = LE32(a1); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1484 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1485 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1486 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1487 case 0x3f: // printf |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1488 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1489 printf("HLEBIOS: printf(%08x) = %s\n", a0, &psx_ram[(a0&0x1fffff)/4]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1490 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1491 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1492 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1493 case 0x72: //__96_remove |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1494 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1495 printf("HLEBIOS: __96_remove\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1496 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1497 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1498 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1499 default: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1500 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1501 printf("Unknown BIOS A0 call = %x\n", subcall); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1502 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1503 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1504 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1505 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1506 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1507 case 0xb0: // b0 syscalls |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1508 switch (subcall) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1509 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1510 case 0x07: // DeliverEvent |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1511 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1512 int ev, spec; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1513 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1514 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1515 ev = calc_ev(a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1516 spec = calc_spec(a1); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1517 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1518 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1519 printf("HLEBIOS: DeliverEvent(ev %d, spec %d)\n", ev, spec); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1520 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1521 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1522 if (Event[ev][spec].status != LE32(EvStACTIVE)) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1523 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1524 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1525 printf("event not active\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1526 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1527 return; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1528 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1529 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1530 // if interrupt mode, do the call |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1531 if (Event[ev][spec].mode == LE32(EvMdINTR)) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1532 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1533 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1534 printf("INTR type, need to call handler %x\n", LE32(Event[ev][spec].fhandler)); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1535 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1536 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1537 else |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1538 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1539 Event[ev][spec].status = LE32(EvStALREADY); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1540 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1541 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1542 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1543 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1544 case 0x08: // OpenEvent |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1545 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1546 int ev, spec; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1547 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1548 ev = calc_ev(a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1549 spec = calc_spec(a1); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1550 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1551 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1552 printf("HLEBIOS: OpenEvent(%08x, %08x, %08x, %08x) = ev %d spec %d\n", a0, a1, a2, a3, ev, spec); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1553 if (ev >= 64 && ev <= 67) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1554 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1555 printf("HLEBIOS: event %d maps to root counter %d\n", ev, ev-64); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1556 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1557 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1558 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1559 Event[ev][spec].status = LE32(EvStWAIT); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1560 Event[ev][spec].mode = LE32(a2); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1561 Event[ev][spec].fhandler = LE32(a3); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1562 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1563 // v0 = ev | spec<<8; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1564 mipsinfo.i = ev | (spec<<8); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1565 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1566 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1567 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1568 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1569 case 0x0a: // WaitEvent |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1570 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1571 int ev, spec; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1572 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1573 ev = a0 & 0xff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1574 spec = (a0 >> 8) & 0xff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1575 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1576 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R31, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1577 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1578 printf("HLEBIOS: WaitEvent(ev %d spec %d) PC=%x\n", ev, spec, mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1579 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1580 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1581 Event[ev][spec].status = LE32(EvStACTIVE); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1582 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1583 // v0 = 1 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1584 mipsinfo.i = 1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1585 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1586 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1587 WAI = 1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1588 mips_shorten_frame(); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1589 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1590 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1591 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1592 case 0x0b: // TestEvent |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1593 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1594 int ev, spec; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1595 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1596 ev = a0 & 0xff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1597 spec = (a0 >> 8) & 0xff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1598 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1599 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1600 printf("HLEBIOS: TestEvent(ev %d spec %d)\n", ev, spec); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1601 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1602 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1603 // v0 = (is event ready?) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1604 if (Event[ev][spec].status == LE32(EvStALREADY)) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1605 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1606 Event[ev][spec].status = LE32(EvStACTIVE); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1607 mipsinfo.i = 1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1608 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1609 else |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1610 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1611 mipsinfo.i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1612 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1613 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1614 WAI = 1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1615 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1616 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1617 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1618 // it looks like this sets v1 to something non-zero too |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1619 // (code in Crash 2 & 3 actually relies on that behavior) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1620 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R3, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1621 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1622 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1623 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1624 case 0x0c: // EnableEvent |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1625 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1626 int ev, spec; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1627 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1628 ev = a0 & 0xff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1629 spec = (a0 >> 8) & 0xff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1630 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1631 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1632 printf("HLEBIOS: EnableEvent(ev %d spec %d)\n", ev, spec); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1633 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1634 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1635 Event[ev][spec].status = LE32(EvStACTIVE); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1636 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1637 // v0 = 1 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1638 mipsinfo.i = 1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1639 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1640 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1641 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1642 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1643 case 0x0d: // DisableEvent |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1644 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1645 int ev, spec; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1646 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1647 ev = a0 & 0xff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1648 spec = (a0 >> 8) & 0xff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1649 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1650 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1651 printf("HLEBIOS: DisableEvent(ev %d spec %d)\n", ev, spec); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1652 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1653 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1654 Event[ev][spec].status = LE32(EvStWAIT); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1655 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1656 // v0 = 1 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1657 mipsinfo.i = 1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1658 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1659 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1660 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1661 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1662 case 0x17: // ReturnFromException |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1663 for (i = 0; i < 32; i++) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1664 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1665 mipsinfo.i = irq_regs[i]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1666 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R0 + i, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1667 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1668 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1669 mipsinfo.i = irq_regs[32]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1670 mips_set_info(CPUINFO_INT_REGISTER + MIPS_HI, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1671 mipsinfo.i = irq_regs[33]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1672 mips_set_info(CPUINFO_INT_REGISTER + MIPS_LO, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1673 mipsinfo.i = mips_get_ePC(); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1674 // printf("ReturnFromException: IRQ state %x\n", irq_data & irq_mask); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1675 // printf("HLEBIOS: ReturnFromException, cause = %08x, PC = %08x\n", mips_get_cause(), mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1676 mips_set_info(CPUINFO_INT_PC, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1677 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1678 status = mips_get_status(); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1679 status = (status & 0xfffffff0) | ((status & 0x3c)>>2); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1680 mips_set_status(status); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1681 return; // force return to avoid PC=RA below |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1682 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1683 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1684 case 0x19: // HookEntryInt |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1685 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1686 printf("HLEBIOS: HookEntryInt(%08x)\n", a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1687 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1688 entry_int = a0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1689 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1690 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1691 case 0x3f: // puts |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1692 // printf("HLEBIOS: puts\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1693 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1694 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1695 case 0x5b: // ChangeClearPAD |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1696 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1697 printf("HLEBIOS: ChangeClearPAD\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1698 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1699 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1700 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1701 default: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1702 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1703 printf("Unknown BIOS B0 call = %x\n", subcall); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1704 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1705 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1706 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1707 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1708 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1709 case 0xc0: // c0 syscalls |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1710 switch (subcall) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1711 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1712 case 0xa: // ChangeClearRCnt |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1713 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1714 printf("HLEBIOS: ChangeClearRCnt(%08x, %08x)\n", a0, a1); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1715 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1716 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1717 // v0 = (a0*4)+0x8600 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1718 mipsinfo.i = LE32(psx_ram[((a0<<2) + 0x8600)/4]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1719 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1720 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1721 // (a0*4)+0x8600 = a1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1722 psx_ram[((a0<<2) + 0x8600)/4] = LE32(a1); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1723 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1724 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1725 default: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1726 #if DEBUG_HLE_BIOS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1727 printf("Unknown BIOS C0 call = %x\n", subcall); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1728 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1729 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1730 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1731 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1732 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1733 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1734 // PC = RA |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1735 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R31, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1736 mips_set_info(CPUINFO_INT_PC, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1737 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1738 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1739 // root counters |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1740 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1741 void psx_hw_runcounters(void) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1742 { |
2954 | 1743 int i; |
2737
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1744 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1745 // don't process any IRQ sources when interrupts are suspended |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1746 if (!intr_susp) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1747 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1748 if (dma4_delay) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1749 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1750 dma4_delay--; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1751 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1752 if (dma4_delay == 0) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1753 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1754 SPU2interruptDMA4(); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1755 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1756 if (dma4_cb) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1757 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1758 call_irq_routine(dma4_cb, dma4_flag); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1759 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1760 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1761 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1762 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1763 if (dma7_delay) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1764 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1765 dma7_delay--; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1766 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1767 if (dma7_delay == 0) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1768 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1769 SPU2interruptDMA7(); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1770 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1771 if (dma7_cb) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1772 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1773 call_irq_routine(dma7_cb, dma7_flag); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1774 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1775 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1776 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1777 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1778 for (i = 0; i < iNumThreads; i++) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1779 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1780 if (threads[i].iState == TS_WAITDELAY) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1781 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1782 if (threads[i].waitparm > CLOCK_DIV) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1783 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1784 threads[i].waitparm -= CLOCK_DIV; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1785 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1786 else // time's up |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1787 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1788 threads[i].waitparm = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1789 threads[i].iState = TS_READY; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1790 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1791 timerexp = 1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1792 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1793 ps2_reschedule(); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1794 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1795 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1796 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1797 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1798 sys_time += 836; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1799 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1800 if (iNumTimers > 0) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1801 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1802 for (i = 0; i < iNumTimers; i++) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1803 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1804 if (iop_timers[i].iActive > 0) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1805 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1806 iop_timers[i].count += 836; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1807 if (iop_timers[i].count >= iop_timers[i].target) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1808 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1809 iop_timers[i].count -= iop_timers[i].target; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1810 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1811 // printf("Timer %d: handler = %08x, param = %08x\n", i, iop_timers[i].handler, iop_timers[i].hparam); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1812 call_irq_routine(iop_timers[i].handler, iop_timers[i].hparam); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1813 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1814 timerexp = 1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1815 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1816 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1817 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1818 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1819 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1820 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1821 // PS1 root counters |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1822 for (i = 0; i < 3; i++) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1823 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1824 if ((!(root_cnts[i].mode & RC_EN)) && (root_cnts[i].mode != 0)) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1825 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1826 if (root_cnts[i].mode & RC_DIV8) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1827 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1828 root_cnts[i].count += 768/8; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1829 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1830 else |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1831 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1832 root_cnts[i].count += 768; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1833 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1834 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1835 if (root_cnts[i].count >= root_cnts[i].target) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1836 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1837 if (!(root_cnts[i].mode & RC_RESET)) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1838 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1839 root_cnts[i].mode |= RC_EN; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1840 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1841 else |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1842 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1843 root_cnts[i].count %= root_cnts[i].target; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1844 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1845 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1846 psx_irq_set(1<<(4+i)); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1847 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1848 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1849 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1850 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1851 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1852 // PEOpS callbacks |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1853 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1854 void SPUirq(void) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1855 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1856 // psx_irq_set(0x200); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1857 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1858 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1859 // PSXCPU callbacks |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1860 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1861 uint8 program_read_byte_32le(offs_t address) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1862 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1863 switch (address & 0x3) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1864 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1865 case 0: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1866 return psx_hw_read(address, 0xffffff00); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1867 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1868 case 1: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1869 return psx_hw_read(address, 0xffff00ff)>>8; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1870 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1871 case 2: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1872 return psx_hw_read(address, 0xff00ffff)>>16; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1873 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1874 case 3: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1875 return psx_hw_read(address, 0x00ffffff)>>24; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1876 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1877 } |
2954 | 1878 |
1879 return psx_hw_read(address, 0xffffff00); | |
2737
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1880 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1881 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1882 uint16 program_read_word_32le(offs_t address) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1883 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1884 if (address & 2) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1885 return psx_hw_read(address, 0x0000ffff)>>16; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1886 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1887 return psx_hw_read(address, 0xffff0000); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1888 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1889 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1890 uint32 program_read_dword_32le(offs_t address) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1891 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1892 return psx_hw_read(address, 0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1893 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1894 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1895 void program_write_byte_32le(offs_t address, uint8 data) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1896 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1897 switch (address & 0x3) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1898 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1899 case 0: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1900 psx_hw_write(address, data, 0xffffff00); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1901 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1902 case 1: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1903 psx_hw_write(address, data<<8, 0xffff00ff); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1904 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1905 case 2: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1906 psx_hw_write(address, data<<16, 0xff00ffff); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1907 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1908 case 3: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1909 psx_hw_write(address, data<<24, 0x00ffffff); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1910 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1911 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1912 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1913 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1914 void program_write_word_32le(offs_t address, uint16 data) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1915 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1916 if (address & 2) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1917 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1918 psx_hw_write(address, data<<16, 0x0000ffff); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1919 return; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1920 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1921 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1922 psx_hw_write(address, data, 0xffff0000); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1923 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1924 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1925 void program_write_dword_32le(offs_t address, uint32 data) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1926 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1927 psx_hw_write(address, data, 0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1928 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1929 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1930 // sprintf replacement |
2954 | 1931 static void iop_sprintf(char *out, char *fmt, uint32 pstart) |
2737
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1932 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1933 char temp[64], tfmt[64]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1934 char *cf, *pstr; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1935 union cpuinfo mipsinfo; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1936 int curparm, fp, isnum; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1937 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1938 curparm = pstart; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1939 cf = fmt; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1940 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1941 while (*cf != '\0') |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1942 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1943 if (*cf != '%') |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1944 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1945 if (*cf == 27) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1946 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1947 *out++ = '['; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1948 *out++ = 'E'; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1949 *out++ = 'S'; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1950 *out++ = 'C'; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1951 *out = ']'; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1952 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1953 else |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1954 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1955 *out = *cf; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1956 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1957 out++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1958 cf++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1959 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1960 else // got format |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1961 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1962 cf++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1963 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1964 tfmt[0] = '%'; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1965 fp = 1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1966 while (((*cf >= '0') && (*cf <= '9')) || (*cf == '.')) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1967 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1968 tfmt[fp] = *cf; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1969 fp++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1970 cf++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1971 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1972 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1973 tfmt[fp] = *cf; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1974 tfmt[fp+1] = '\0'; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1975 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1976 isnum = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1977 switch (*cf) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1978 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1979 case 'x': |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1980 case 'X': |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1981 case 'd': |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1982 case 'D': |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1983 case 'c': |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1984 case 'C': |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1985 case 'u': |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1986 case 'U': |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1987 isnum = 1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1988 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1989 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1990 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1991 // printf("]]] temp format: [%s] [%d]\n", tfmt, isnum); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1992 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1993 if (isnum) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1994 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1995 mips_get_info(curparm, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1996 // printf("parameter %d = %x\n", curparm-pstart, mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1997 curparm++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1998 sprintf(temp, tfmt, (int32)mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1999 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2000 else |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2001 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2002 mips_get_info(curparm, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2003 curparm++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2004 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2005 pstr = (char *)psx_ram; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2006 pstr += (mipsinfo.i & 0x1fffff); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2007 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2008 sprintf(temp, tfmt, pstr); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2009 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2010 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2011 pstr = &temp[0]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2012 while (*pstr != '\0') |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2013 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2014 *out = *pstr; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2015 out++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2016 pstr++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2017 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2018 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2019 cf++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2020 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2021 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2022 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2023 *out = '\0'; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2024 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2025 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2026 // PS2 IOP callbacks |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2027 void psx_iop_call(uint32 pc, uint32 callnum) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2028 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2029 uint32 scan; |
2954 | 2030 char *mname, *str1, name[9], out[512]; |
2737
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2031 uint32 a0, a1, a2, a3; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2032 union cpuinfo mipsinfo; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2033 int i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2034 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2035 // printf("IOP call @ %08x\n", pc); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2036 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2037 // prefetch parameters |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2038 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R4, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2039 a0 = mipsinfo.i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2040 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R5, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2041 a1 = mipsinfo.i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2042 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R6, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2043 a2 = mipsinfo.i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2044 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R7, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2045 a3 = mipsinfo.i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2046 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2047 scan = (pc&0x0fffffff)/4; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2048 while ((psx_ram[scan] != LE32(0x41e00000)) && (scan >= (0x10000/4))) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2049 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2050 scan--; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2051 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2052 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2053 if (psx_ram[scan] != LE32(0x41e00000)) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2054 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2055 printf("FATAL ERROR: couldn't find IOP link signature\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2056 return; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2057 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2058 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2059 scan += 3; // skip zero and version |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2060 memcpy(name, &psx_ram[scan], 8); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2061 name[8] = '\0'; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2062 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2063 // printf("IOP: call module [%s] service %d (PC=%08x)\n", name, callnum, pc); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2064 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2065 if (!strcmp(name, "stdio")) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2066 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2067 switch (callnum) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2068 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2069 case 4: // printf |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2070 mname = (char *)psx_ram; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2071 mname += a0 & 0x1fffff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2072 mname += (a0 & 3); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2073 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2074 iop_sprintf(out, mname, CPUINFO_INT_REGISTER + MIPS_R5); // a1 is first parm |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2075 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2076 /* if (out[strlen(out)-1] != '\n') |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2077 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2078 strcat(out, "\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2079 }*/ |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2080 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2081 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2082 printf("%s", out); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2083 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2084 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2085 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2086 default: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2087 printf("IOP: Unhandled service %d for module %s\n", callnum, name); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2088 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2089 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2090 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2091 else if (!strcmp(name, "sifman")) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2092 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2093 switch (callnum) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2094 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2095 case 5: // sceSifInit |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2096 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2097 printf("IOP: sceSifInit()\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2098 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2099 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2100 mipsinfo.i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2101 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2102 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2103 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2104 case 7: // sceSifSetDma |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2105 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2106 printf("IOP: sceSifSetDma(%08x %08x)\n", a0, a1); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2107 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2108 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2109 mipsinfo.i = 1; // nonzero = success |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2110 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2111 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2112 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2113 case 8: // sceSifDmaStat |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2114 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2115 printf("IOP: sceSifDmaStat(%08x)\n", a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2116 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2117 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2118 mipsinfo.i = -1; // dma completed |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2119 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2120 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2121 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2122 case 29: // sceSifCheckInit |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2123 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2124 printf("IOP: sceSifCheckInit()\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2125 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2126 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2127 mipsinfo.i = 1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2128 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2129 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2130 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2131 default: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2132 printf("IOP: Unhandled service %d for module %s\n", callnum, name); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2133 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2134 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2135 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2136 else if (!strcmp(name, "thbase")) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2137 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2138 uint32 newAlloc; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2139 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2140 switch (callnum) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2141 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2142 case 4: // CreateThread |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2143 #if DEBUG_THREADING |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2144 printf("IOP: CreateThread(%08x)\n", a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2145 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2146 a0 &= 0x1fffff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2147 a0 /= 4; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2148 #if DEBUG_THREADING |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2149 printf(" : flags %x routine %08x pri %x stacksize %d refCon %08x\n", |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2150 psx_ram[a0], psx_ram[a0+1], psx_ram[a0+2], psx_ram[a0+3], psx_ram[a0+4]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2151 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2152 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2153 newAlloc = psf2_get_loadaddr(); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2154 // force 16-byte alignment |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2155 if (newAlloc & 0xf) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2156 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2157 newAlloc &= ~0xf; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2158 newAlloc += 16; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2159 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2160 psf2_set_loadaddr(newAlloc + LE32(psx_ram[a0+3])); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2161 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2162 threads[iNumThreads].iState = TS_CREATED; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2163 threads[iNumThreads].stackloc = newAlloc; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2164 threads[iNumThreads].flags = LE32(psx_ram[a0]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2165 threads[iNumThreads].routine = LE32(psx_ram[a0+2]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2166 threads[iNumThreads].stacksize = LE32(psx_ram[a0+3]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2167 threads[iNumThreads].refCon = LE32(psx_ram[a0+4]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2168 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2169 mipsinfo.i = iNumThreads; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2170 iNumThreads++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2171 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2172 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2173 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2174 case 6: // StartThread |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2175 #if DEBUG_THREADING |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2176 printf("IOP: StartThread(%d %d)\n", a0, a1); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2177 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2178 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2179 FreezeThread(iCurThread, 1); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2180 ThawThread(a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2181 iCurThread = a0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2182 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2183 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2184 case 20:// GetThreadID |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2185 #if DEBUG_THREADING |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2186 printf("IOP: GetThreadId()\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2187 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2188 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2189 mipsinfo.i = iCurThread; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2190 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2191 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2192 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2193 case 24:// SleepThread |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2194 #if DEBUG_THREADING |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2195 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R31, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2196 printf("IOP: SleepThread() [curThread %d, PC=%x]\n", iCurThread, mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2197 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2198 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2199 FreezeThread(iCurThread, 1); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2200 threads[iCurThread].iState = TS_SLEEPING; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2201 iCurThread = -1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2202 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2203 ps2_reschedule(); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2204 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2205 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2206 case 25:// WakeupThread |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2207 #if DEBUG_THREADING |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2208 printf("IOP: WakeupThread(%d)\n", a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2209 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2210 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2211 // set thread to "ready to go" |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2212 threads[a0].iState = TS_READY; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2213 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2214 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2215 case 26:// iWakeupThread |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2216 #if DEBUG_THREADING |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2217 printf("IOP: iWakeupThread(%d)\n", a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2218 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2219 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2220 // set thread to "ready to go" if it's not running |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2221 if (threads[a0].iState != TS_RUNNING) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2222 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2223 threads[a0].iState = TS_READY; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2224 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2225 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2226 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2227 case 33:// DelayThread |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2228 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2229 double dTicks; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2230 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2231 #if DEBUG_THREADING |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2232 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R31, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2233 printf("IOP: DelayThread(%d) (PC=%x) [curthread = %d]\n", a0, mipsinfo.i, iCurThread); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2234 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2235 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2236 if (a0 < 100) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2237 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2238 a0 = 100; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2239 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2240 dTicks = (double)a0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2241 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2242 FreezeThread(iCurThread, 1); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2243 threads[iCurThread].iState = TS_WAITDELAY; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2244 dTicks /= (double)1000000.0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2245 dTicks *= (double)36864000.0; // 768*48000 = IOP native-mode clock rate |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2246 threads[iCurThread].waitparm = (uint32)dTicks; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2247 iCurThread = -1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2248 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2249 ps2_reschedule(); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2250 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2251 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2252 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2253 case 34://GetSystemTime |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2254 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2255 printf("IOP: GetSystemTime(%x)\n", a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2256 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2257 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2258 a0 &= 0x1fffff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2259 a0 /= 4; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2260 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2261 psx_ram[a0] = LE32(sys_time & 0xffffffff); // low |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2262 psx_ram[a0+1] = LE32(sys_time >> 32); // high |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2263 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2264 mipsinfo.i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2265 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2266 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2267 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2268 case 39:// USec2SysClock |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2269 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2270 uint64 dTicks = (uint64)a0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2271 uint32 hi, lo; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2272 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2273 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2274 printf("IOP: USec2SysClock(%d %08x)\n", a0, a1); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2275 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2276 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2277 dTicks *= (uint64)36864000; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2278 dTicks /= (uint64)1000000; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2279 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2280 hi = dTicks>>32; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2281 lo = dTicks & 0xffffffff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2282 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2283 psx_ram[((a1 & 0x1fffff)/4)] = LE32(lo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2284 psx_ram[((a1 & 0x1fffff)/4)+1] = LE32(hi); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2285 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2286 mipsinfo.i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2287 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2288 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2289 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2290 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2291 case 40://SysClock2USec |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2292 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2293 uint64 temp; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2294 uint32 seconds, usec; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2295 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2296 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2297 printf("IOP: SysClock2USec(%08x %08x %08x)\n", a0, a1, a2); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2298 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2299 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2300 a0 &= 0x1fffff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2301 a1 &= 0x1fffff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2302 a2 &= 0x1fffff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2303 a0 /= 4; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2304 a1 /= 4; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2305 a2 /= 4; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2306 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2307 temp = LE32(psx_ram[a0]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2308 temp |= (uint64)LE32(psx_ram[a0+1])<<32; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2309 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2310 temp *= (uint64)1000000; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2311 temp /= (uint64)36864000; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2312 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2313 // temp now is USec |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2314 seconds = (temp / 1000000) & 0xffffffff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2315 usec = (temp % 1000000) & 0xffffffff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2316 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2317 psx_ram[a1] = LE32(seconds); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2318 psx_ram[a2] = LE32(usec); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2319 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2320 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2321 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2322 default: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2323 printf("IOP: Unhandled service %d for module %s\n", callnum, name); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2324 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2325 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2326 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2327 else if (!strcmp(name, "thevent")) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2328 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2329 switch (callnum) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2330 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2331 case 4: // CreateEventFlag |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2332 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R31, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2333 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2334 printf("IOP: CreateEventFlag(%08x) (PC=%x)\n", a0, mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2335 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2336 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2337 a0 &= 0x1fffff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2338 a0 /= 4; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2339 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2340 evflags[iNumFlags].type = LE32(psx_ram[a0]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2341 evflags[iNumFlags].value = LE32(psx_ram[a0+1]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2342 evflags[iNumFlags].param = LE32(psx_ram[a0+2]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2343 evflags[iNumFlags].inUse = 1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2344 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2345 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2346 printf(" Flag %02d: type %d init %08x param %08x\n", iNumFlags, evflags[iNumFlags].type, evflags[iNumFlags].value, evflags[iNumFlags].param); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2347 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2348 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2349 mipsinfo.i = iNumFlags+1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2350 iNumFlags++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2351 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2352 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2353 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2354 case 6: // SetEventFlag |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2355 a0--; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2356 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2357 printf("IOP: SetEventFlag(%d %08x)\n", a0, a1); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2358 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2359 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2360 evflags[a0].value |= a1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2361 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2362 mipsinfo.i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2363 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2364 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2365 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2366 case 7: // iSetEventFlag |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2367 a0--; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2368 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2369 printf("IOP: iSetEventFlag(%08x %08x)\n", a0, a1); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2370 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2371 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2372 evflags[a0].value |= a1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2373 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2374 mipsinfo.i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2375 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2376 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2377 for (i=0; i < iNumThreads; i++) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2378 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2379 if ((threads[i].iState == TS_WAITEVFLAG) && (threads[i].waitparm == a0)) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2380 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2381 threads[i].iState = TS_READY; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2382 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2383 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2384 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2385 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2386 case 8: // ClearEventFlag |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2387 a0--; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2388 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R31, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2389 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2390 printf("IOP: ClearEventFlag(%d %08x) (PC=%x)\n", a0, a1, mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2391 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2392 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2393 evflags[a0].value &= a1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2394 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2395 mipsinfo.i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2396 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2397 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2398 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2399 case 9: // iClearEventFlag |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2400 a0--; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2401 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2402 printf("IOP: iClearEventFlag(%d %08x)\n", a0, a1); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2403 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2404 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2405 evflags[a0].value &= a1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2406 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2407 mipsinfo.i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2408 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2409 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2410 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2411 case 10:// WaitEventFlag |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2412 a0--; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2413 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2414 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R31, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2415 printf("IOP: WaitEventFlag(%d %08x %d %08x PC=%x)\n", a0, a1, a2, a3, mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2416 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2417 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2418 // if we're not set, freeze this thread |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2419 if (!(evflags[a0].value & a1)) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2420 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2421 FreezeThread(iCurThread, 1); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2422 threads[iCurThread].iState = TS_WAITEVFLAG; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2423 threads[iCurThread].waitparm = a0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2424 iCurThread = -1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2425 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2426 ps2_reschedule(); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2427 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2428 else |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2429 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2430 mipsinfo.i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2431 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2432 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2433 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2434 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2435 default: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2436 printf("IOP: Unhandled service %d for module %s\n", callnum, name); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2437 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2438 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2439 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2440 else if (!strcmp(name, "thsemap")) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2441 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2442 int foundthread; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2443 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2444 switch (callnum) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2445 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2446 case 4: // CreateSema |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2447 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2448 printf("IOP: CreateSema(%08x)\n", a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2449 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2450 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2451 mipsinfo.i = -1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2452 for (i = 0; i < SEMA_MAX; i++) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2453 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2454 if (!semaphores[i].inuse) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2455 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2456 mipsinfo.i = i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2457 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2458 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2459 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2460 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2461 if (mipsinfo.i == -1) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2462 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2463 printf("IOP: out of semaphores!\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2464 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2465 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2466 a0 &= 0x7fffffff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2467 a0 /= 4; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2468 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2469 // printf("Sema %d Parms: %08x %08x %08x %08x\n", mipsinfo.i, psx_ram[a0], psx_ram[a0+1], psx_ram[a0+2], psx_ram[a0+3]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2470 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2471 if (mipsinfo.i != -1) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2472 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2473 semaphores[mipsinfo.i].attr = LE32(psx_ram[a0]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2474 semaphores[mipsinfo.i].option = LE32(psx_ram[a0+1]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2475 semaphores[mipsinfo.i].init = LE32(psx_ram[a0+2]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2476 semaphores[mipsinfo.i].max = LE32(psx_ram[a0+3]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2477 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2478 semaphores[mipsinfo.i].current = semaphores[mipsinfo.i].init; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2479 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2480 semaphores[mipsinfo.i].inuse = 1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2481 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2482 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2483 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2484 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2485 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2486 case 6: // SignalSema |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2487 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2488 printf("IOP: SignalSema(%d) (current %d)\n", a0, semaphores[a0].current); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2489 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2490 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2491 foundthread = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2492 for (i=0; i < iNumThreads; i++) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2493 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2494 if ((threads[i].iState == TS_WAITSEMA) && (threads[i].waitparm == a0)) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2495 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2496 threads[i].iState = TS_READY; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2497 semaphores[a0].threadsWaiting--; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2498 foundthread = 1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2499 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2500 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2501 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2502 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2503 mipsinfo.i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2504 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2505 if (!foundthread) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2506 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2507 if (semaphores[a0].current < semaphores[a0].max) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2508 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2509 semaphores[a0].current++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2510 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2511 else |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2512 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2513 mipsinfo.i = -420; // semaphore overflow |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2514 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2515 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2516 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2517 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2518 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2519 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2520 case 7: // iSignalSema |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2521 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2522 printf("IOP: iSignalSema(%d)\n", a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2523 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2524 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2525 foundthread = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2526 for (i=0; i < iNumThreads; i++) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2527 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2528 if ((threads[i].iState == TS_WAITSEMA) && (threads[i].waitparm == a0)) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2529 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2530 threads[i].iState = TS_READY; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2531 semaphores[a0].threadsWaiting--; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2532 foundthread = 1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2533 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2534 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2535 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2536 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2537 mipsinfo.i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2538 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2539 if (!foundthread) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2540 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2541 if (semaphores[a0].current < semaphores[a0].max) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2542 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2543 semaphores[a0].current++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2544 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2545 else |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2546 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2547 mipsinfo.i = -420; // semaphore overflow |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2548 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2549 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2550 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2551 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2552 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2553 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2554 case 8: // WaitSema |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2555 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2556 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R31, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2557 printf("IOP: WaitSema(%d) (cnt %d) (th %d) (PC=%x)\n", a0, iCurThread, semaphores[a0].current, mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2558 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2559 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2560 if (semaphores[a0].current > 0) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2561 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2562 semaphores[a0].current--; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2563 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2564 else |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2565 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2566 FreezeThread(iCurThread, 1); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2567 threads[iCurThread].iState = TS_WAITSEMA; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2568 threads[iCurThread].waitparm = a0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2569 ps2_reschedule(); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2570 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2571 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2572 mipsinfo.i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2573 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2574 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2575 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2576 default: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2577 printf("IOP: Unhandled service %d for module %s\n", callnum, name); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2578 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2579 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2580 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2581 else if (!strcmp(name, "timrman")) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2582 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2583 switch (callnum) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2584 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2585 case 4: // AllocHardTimer |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2586 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2587 printf("IOP: AllocHardTimer(%d %d %d)\n", a0, a1, a2); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2588 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2589 // source, size, prescale |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2590 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2591 if (a1 != 32) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2592 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2593 printf("IOP: AllocHardTimer doesn't support 16-bit timers!\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2594 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2595 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2596 iop_timers[iNumTimers].source = a0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2597 iop_timers[iNumTimers].prescale = a2; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2598 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2599 mipsinfo.i = iNumTimers+1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2600 iNumTimers++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2601 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2602 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2603 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2604 case 6: // FreeHardTimer |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2605 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2606 printf("IOP: FreeHardTimer(%d)\n", a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2607 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2608 mipsinfo.i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2609 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2610 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2611 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2612 case 10:// GetTimerCounter |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2613 mipsinfo.i = iop_timers[a0-1].count; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2614 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2615 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2616 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2617 case 20: // SetTimerHandler |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2618 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2619 printf("IOP: SetTimerHandler(%d %d %08x %08x)\n", a0, a1, a2, a3); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2620 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2621 // id, compare, handler, common (last is param for handler) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2622 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2623 iop_timers[a0-1].target = a1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2624 iop_timers[a0-1].handler = a2; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2625 iop_timers[a0-1].hparam = a3; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2626 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2627 mipsinfo.i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2628 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2629 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2630 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2631 case 22: // SetupHardTimer |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2632 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2633 printf("IOP: SetupHardTimer(%d %d %d %d)\n", a0, a1, a2, a3); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2634 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2635 // id, source, mode, prescale |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2636 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2637 iop_timers[a0-1].source = a1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2638 iop_timers[a0-1].mode = a2; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2639 iop_timers[a0-1].prescale = a3; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2640 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2641 mipsinfo.i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2642 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2643 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2644 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2645 case 23: // StartHardTimer |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2646 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2647 printf("IOP: StartHardTimer(%d)\n", a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2648 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2649 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2650 iop_timers[a0-1].iActive = 1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2651 iop_timers[a0-1].count = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2652 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2653 mipsinfo.i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2654 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2655 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2656 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2657 case 24: // StopHardTimer |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2658 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2659 printf("IOP: StopHardTimer(%d)\n", a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2660 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2661 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2662 iop_timers[a0-1].iActive = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2663 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2664 mipsinfo.i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2665 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2666 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2667 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2668 default: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2669 printf("IOP: Unhandled service %d for module %s\n", callnum, name); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2670 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2671 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2672 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2673 else if (!strcmp(name, "sysclib")) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2674 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2675 switch (callnum) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2676 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2677 case 12: // memcpy |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2678 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2679 uint8 *dst, *src; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2680 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2681 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2682 printf("IOP: memcpy(%08x, %08x, %d)\n", a0, a1, a2); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2683 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2684 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2685 dst = (uint8 *)&psx_ram[(a0&0x1fffff)/4]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2686 src = (uint8 *)&psx_ram[(a1&0x1fffff)/4]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2687 // get exact byte alignment |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2688 dst += a0 % 4; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2689 src += a1 % 4; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2690 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2691 while (a2) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2692 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2693 *dst = *src; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2694 dst++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2695 src++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2696 a2--; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2697 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2698 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2699 // v0 = a0 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2700 mipsinfo.i = a0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2701 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2702 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2703 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2704 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2705 case 13: // memmove |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2706 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2707 uint8 *dst, *src; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2708 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2709 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2710 printf("IOP: memmove(%08x, %08x, %d)\n", a0, a1, a2); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2711 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2712 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2713 dst = (uint8 *)&psx_ram[(a0&0x1fffff)/4]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2714 src = (uint8 *)&psx_ram[(a1&0x1fffff)/4]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2715 // get exact byte alignment |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2716 dst += a0 % 4; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2717 src += a1 % 4; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2718 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2719 dst += a2 - 1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2720 src += a2 - 1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2721 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2722 while (a2) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2723 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2724 *dst = *src; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2725 dst--; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2726 src--; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2727 a2--; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2728 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2729 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2730 // v0 = a0 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2731 mipsinfo.i = a0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2732 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2733 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2734 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2735 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2736 case 14: // memset |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2737 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2738 uint8 *dst; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2739 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2740 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2741 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R31, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2742 printf("IOP: memset(%08x, %02x, %d) [PC=%x]\n", a0, a1, a2, mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2743 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2744 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2745 dst = (uint8 *)&psx_ram[(a0&0x1fffff)/4]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2746 dst += (a0 & 3); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2747 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2748 memset(dst, a1, a2); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2749 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2750 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2751 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2752 case 17: // bzero |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2753 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2754 uint8 *dst; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2755 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2756 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2757 printf("IOP: bzero(%08x, %08x)\n", a0, a1); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2758 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2759 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2760 dst = (uint8 *)&psx_ram[(a0&0x1fffff)/4]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2761 dst += (a0 & 3); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2762 memset(dst, 0, a1); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2763 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2764 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2765 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2766 case 19: // sprintf |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2767 mname = (char *)psx_ram; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2768 str1 = (char *)psx_ram; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2769 mname += a0 & 0x1fffff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2770 str1 += a1 & 0x1fffff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2771 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2772 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2773 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R31, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2774 printf("IOP: sprintf(%08x, %s, ...) [PC=%08x]\n", a0, str1, (uint32)mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2775 printf("%x %x %x %x\n", a0, a1, a2, a3); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2776 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2777 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2778 iop_sprintf(mname, str1, CPUINFO_INT_REGISTER + MIPS_R6); // a2 is first parameter |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2779 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2780 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2781 printf(" = [%s]\n", mname); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2782 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2783 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2784 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2785 case 23: // strcpy |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2786 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2787 uint8 *dst, *src; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2788 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2789 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2790 printf("IOP: strcpy(%08x, %08x)\n", a0, a1); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2791 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2792 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2793 dst = (uint8 *)&psx_ram[(a0&0x1fffff)/4]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2794 src = (uint8 *)&psx_ram[(a1&0x1fffff)/4]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2795 // get exact byte alignment |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2796 dst += a0 % 4; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2797 src += a1 % 4; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2798 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2799 while (*src != '\0') |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2800 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2801 *dst = *src; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2802 dst++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2803 src++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2804 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2805 *dst = '\0'; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2806 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2807 // v0 = a0 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2808 mipsinfo.i = a0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2809 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2810 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2811 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2812 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2813 case 27: // strlen |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2814 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2815 char *dst; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2816 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2817 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2818 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R31, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2819 printf("IOP: strlen(%08x) [PC=%x]\n", a0, mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2820 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2821 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2822 dst = (char *)&psx_ram[(a0&0x1fffff)/4]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2823 dst += (a0 & 3); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2824 mipsinfo.i = strlen(dst); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2825 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2826 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2827 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2828 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2829 case 30: // strncpy |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2830 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2831 char *dst, *src; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2832 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2833 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2834 printf("IOP: strncpy(%08x, %08x, %d)\n", a0, a1, a2); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2835 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2836 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2837 dst = (char *)&psx_ram[(a0&0x1fffff)/4]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2838 src = (char *)&psx_ram[(a1&0x1fffff)/4]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2839 // get exact byte alignment |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2840 dst += a0 % 4; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2841 src += a1 % 4; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2842 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2843 while ((*src != '\0') && (a2 > 0)) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2844 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2845 *dst = *src; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2846 dst++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2847 src++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2848 a2--; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2849 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2850 *dst = '\0'; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2851 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2852 // v0 = a0 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2853 mipsinfo.i = a0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2854 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2855 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2856 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2857 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2858 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2859 case 36: // strtol |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2860 mname = (char *)&psx_ram[(a0 & 0x1fffff)/4]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2861 mname += (a0 & 3); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2862 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2863 if (a1) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2864 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2865 printf("IOP: Unhandled strtol with non-NULL second parm\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2866 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2867 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2868 mipsinfo.i = strtol(mname, NULL, a2); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2869 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2870 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2871 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2872 default: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2873 printf("IOP: Unhandled service %d for module %s\n", callnum, name); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2874 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2875 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2876 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2877 else if (!strcmp(name, "intrman")) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2878 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2879 switch (callnum) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2880 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2881 case 4: // RegisterIntrHandler |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2882 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2883 printf("IOP: RegisterIntrHandler(%d %08x %08x %08x)\n", a0, a1, a2, a3); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2884 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2885 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2886 if (a0 == 9) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2887 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2888 irq9_fval = a1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2889 irq9_cb = a2; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2890 irq9_flag = a3; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2891 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2892 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2893 // DMA4? |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2894 if (a0 == 36) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2895 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2896 dma4_fval = a1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2897 dma4_cb = a2; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2898 dma4_flag = a3; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2899 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2900 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2901 // DMA7? |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2902 if (a0 == 40) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2903 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2904 dma7_fval = a1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2905 dma7_cb = a2; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2906 dma7_flag = a3; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2907 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2908 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2909 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2910 case 5: // ReleaseIntrHandler |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2911 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2912 printf("IOP: ReleaseIntrHandler(%d)\n", a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2913 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2914 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2915 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2916 case 6: // EnableIntr |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2917 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2918 printf("IOP: EnableIntr(%d)\n", a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2919 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2920 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2921 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2922 case 7: // DisableIntr |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2923 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2924 printf("IOP: DisableIntr(%d)\n", a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2925 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2926 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2927 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2928 case 8: // CpuDisableIntr |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2929 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2930 printf("IOP: CpuDisableIntr(%d)\n", a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2931 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2932 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2933 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2934 case 9: // CpuEnableIntr |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2935 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2936 printf("IOP: CpuEnableIntr(%d)\n", a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2937 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2938 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2939 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2940 case 17: // CpuSuspendIntr |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2941 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2942 printf("IOP: CpuSuspendIntr\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2943 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2944 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2945 // if already suspended, return an error code |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2946 if (intr_susp) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2947 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2948 mipsinfo.i = -102; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2949 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2950 else |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2951 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2952 mipsinfo.i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2953 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2954 intr_susp = 1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2955 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2956 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2957 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2958 case 18: // CpuResumeIntr |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2959 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2960 printf("IOP: CpuResumeIntr\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2961 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2962 intr_susp = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2963 mipsinfo.i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2964 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2965 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2966 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2967 case 23: // QueryIntrContext |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2968 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2969 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R31, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2970 printf("IOP: QueryIntrContext(PC=%x)\n", mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2971 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2972 mipsinfo.i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2973 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2974 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2975 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2976 default: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2977 printf("IOP: Unhandled service %d for module %s\n", callnum, name); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2978 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2979 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2980 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2981 else if (!strcmp(name, "loadcore")) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2982 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2983 switch (callnum) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2984 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2985 case 5: // FlushDcache |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2986 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2987 printf("IOP: FlushDcache()\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2988 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2989 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2990 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2991 case 6: // RegisterLibraryEntries |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2992 a0 &= 0x1fffff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2993 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2994 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R31, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2995 printf("IOP: RegisterLibraryEntries(%08x) (PC=%x)\n", a0, mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2996 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2997 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2998 if (psx_ram[a0/4] == LE32(0x41c00000)) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2999 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3000 a0 += 3*4; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3001 memcpy(®libs[iNumLibs].name, &psx_ram[a0/4], 8); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3002 reglibs[iNumLibs].name[8] = '\0'; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3003 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3004 printf("Lib name [%s]\n", ®libs[iNumLibs].name); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3005 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3006 a0 += 2*4; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3007 reglibs[iNumLibs].dispatch = a0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3008 iNumLibs++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3009 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3010 else |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3011 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3012 printf("ERROR: Entry table signature missing\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3013 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3014 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3015 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3016 mipsinfo.i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3017 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3018 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3019 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3020 default: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3021 printf("IOP: Unhandled service %d for module %s\n", callnum, name); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3022 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3023 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3024 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3025 else if (!strcmp(name, "sysmem")) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3026 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3027 uint32 newAlloc; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3028 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3029 switch (callnum) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3030 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3031 case 4: // AllocMemory |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3032 newAlloc = psf2_get_loadaddr(); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3033 // make sure we're 16-byte aligned |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3034 if (newAlloc & 15) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3035 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3036 newAlloc &= ~15; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3037 newAlloc += 16; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3038 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3039 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3040 if (a1 & 15) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3041 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3042 a1 &= ~15; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3043 a1 += 16; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3044 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3045 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3046 if (a1 == 1114112) // HACK for crappy code in Shadow Hearts rip that assumes the buffer address |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3047 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3048 printf("SH Hack: was %x now %x\n", newAlloc, 0x60000); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3049 newAlloc = 0x60000; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3050 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3051 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3052 psf2_set_loadaddr(newAlloc + a1); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3053 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3054 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3055 printf("IOP: AllocMemory(%d, %d, %x) = %08x\n", a0, a1, a2, newAlloc|0x80000000); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3056 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3057 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3058 mipsinfo.i = newAlloc; // | 0x80000000; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3059 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3060 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3061 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3062 case 5: // FreeMemory |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3063 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3064 printf("IOP: FreeMemory(%x)\n", a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3065 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3066 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3067 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3068 case 7: // QueryMaxFreeMemSize |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3069 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3070 printf("IOP: QueryMaxFreeMemSize\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3071 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3072 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3073 mipsinfo.i = (2*1024*1024) - psf2_get_loadaddr(); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3074 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3075 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3076 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3077 case 8: // QueryTotalFreeMemSize |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3078 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3079 printf("IOP: QueryTotalFreeMemSize\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3080 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3081 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3082 mipsinfo.i = (2*1024*1024) - psf2_get_loadaddr(); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3083 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3084 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3085 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3086 case 14: // Kprintf |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3087 mname = (char *)psx_ram; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3088 mname += a0 & 0x1fffff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3089 mname += (a0 & 3); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3090 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3091 iop_sprintf(out, mname, CPUINFO_INT_REGISTER + MIPS_R5); // a1 is first parm |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3092 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3093 if (out[strlen(out)-1] != '\n') |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3094 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3095 strcat(out, "\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3096 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3097 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3098 // filter out ESC characters |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3099 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3100 int ch; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3101 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3102 for (ch = 0; ch < strlen(out); ch++) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3103 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3104 if (out[ch] == 27) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3105 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3106 out[ch] = ']'; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3107 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3108 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3109 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3110 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3111 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3112 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R31, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3113 printf("KTTY: %s [PC=%x]\n", out, mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3114 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3115 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3116 #if 0 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3117 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3118 FILE *f; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3119 f = fopen("psxram.bin", "wb"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3120 fwrite(psx_ram, 2*1024*1024, 1, f); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3121 fclose(f); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3122 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3123 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3124 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3125 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3126 default: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3127 printf("IOP: Unhandled service %d for module %s\n", callnum, name); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3128 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3129 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3130 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3131 else if (!strcmp(name, "modload")) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3132 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3133 uint8 *tempmem; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3134 uint32 newAlloc; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3135 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3136 switch (callnum) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3137 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3138 case 7: // LoadStartModule |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3139 mname = (char *)&psx_ram[(a0 & 0x1fffff)/4]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3140 mname += 8; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3141 str1 = (char *)&psx_ram[(a2 & 0x1fffff)/4]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3142 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3143 printf("LoadStartModule: %s\n", mname); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3144 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3145 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3146 // get 2k for our parameters |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3147 newAlloc = psf2_get_loadaddr(); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3148 // force 16-byte alignment |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3149 if (newAlloc & 0xf) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3150 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3151 newAlloc &= ~0xf; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3152 newAlloc += 16; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3153 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3154 psf2_set_loadaddr(newAlloc + 2048); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3155 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3156 tempmem = (uint8 *)malloc(2*1024*1024); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3157 if (psf2_load_file(mname, tempmem, 2*1024*1024) != 0xffffffff) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3158 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3159 uint32 start; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3160 int i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3161 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3162 start = psf2_load_elf(tempmem, 2*1024*1024); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3163 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3164 if (start != 0xffffffff) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3165 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3166 uint32 args[20], numargs = 1, argofs; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3167 uint8 *argwalk = (uint8 *)psx_ram, *argbase; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3168 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3169 argwalk += (a2 & 0x1fffff); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3170 argbase = argwalk; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3171 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3172 args[0] = a0; // program name is argc[0] |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3173 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3174 argofs = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3175 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3176 if (a1 > 0) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3177 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3178 args[numargs] = a2; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3179 numargs++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3180 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3181 while (a1) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3182 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3183 if ((*argwalk == 0) && (a1 > 1)) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3184 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3185 args[numargs] = a2 + argofs + 1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3186 numargs++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3187 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3188 argwalk++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3189 argofs++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3190 a1--; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3191 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3192 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3193 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3194 for (i = 0; i < numargs; i++) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3195 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3196 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3197 // printf("Arg %d: %08x [%s]\n", i, args[i], &argbase[args[i]-a2]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3198 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3199 psx_ram[(newAlloc/4)+i] = LE32(args[i]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3200 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3201 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3202 // set argv and argc |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3203 mipsinfo.i = numargs; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3204 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R4, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3205 mipsinfo.i = 0x80000000 | newAlloc; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3206 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R5, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3207 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3208 // leave RA alone, PC = module start |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3209 // (NOTE: we get called in the delay slot!) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3210 mipsinfo.i = start - 4; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3211 mips_set_info(CPUINFO_INT_PC, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3212 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3213 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3214 free(tempmem); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3215 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3216 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3217 default: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3218 printf("IOP: Unhandled service %d for module %s\n", callnum, name); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3219 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3220 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3221 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3222 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3223 else if (!strcmp(name, "ioman")) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3224 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3225 switch (callnum) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3226 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3227 case 4: // open |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3228 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3229 int i, slot2use; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3230 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3231 slot2use = -1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3232 for (i = 0; i < MAX_FILE_SLOTS; i++) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3233 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3234 if (filestat[i] == 0) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3235 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3236 slot2use = i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3237 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3238 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3239 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3240 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3241 if (slot2use == -1) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3242 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3243 printf("IOP: out of file slots!\n"); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3244 mipsinfo.i = 0xffffffff; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3245 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3246 return; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3247 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3248 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3249 mname = (char *)psx_ram; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3250 mname += (a0 & 0x1fffff); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3251 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3252 if (!strncmp(mname, "aofile:", 7)) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3253 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3254 mname += 8; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3255 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3256 else if (!strncmp(mname, "hefile:", 7)) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3257 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3258 mname += 8; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3259 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3260 else if (!strncmp(mname, "host0:", 6)) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3261 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3262 mname += 7; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3263 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3264 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3265 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R31, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3266 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3267 printf("IOP: open(\"%s\") (PC=%08x)\n", mname, mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3268 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3269 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3270 filedata[slot2use] = malloc(6*1024*1024); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3271 filesize[slot2use] = psf2_load_file(mname, filedata[slot2use], 6*1024*1024); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3272 filepos[slot2use] = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3273 filestat[slot2use] = 1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3274 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3275 if (filesize[slot2use] == 0xffffffff) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3276 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3277 mipsinfo.i = filesize[slot2use]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3278 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3279 else |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3280 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3281 mipsinfo.i = slot2use; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3282 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3283 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3284 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3285 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3286 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3287 case 5: // close |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3288 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3289 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R31, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3290 printf("IOP: close(%d) (PC=%08x)\n", a0, mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3291 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3292 free(filedata[a0]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3293 filedata[a0] = (uint8 *)NULL; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3294 filepos[a0] = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3295 filesize[a0] = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3296 filestat[a0] = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3297 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3298 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3299 case 6: // read |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3300 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3301 printf("IOP: read(%x %x %d) [pos %d size %d]\n", a0, a1, a2, filepos[a0], filesize[a0]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3302 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3303 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3304 if (filepos[a0] >= filesize[a0]) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3305 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3306 mipsinfo.i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3307 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3308 else |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3309 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3310 uint8 *rp; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3311 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3312 if ((filepos[a0] + a2) > filesize[a0]) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3313 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3314 a2 = filesize[a0] - filepos[a0]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3315 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3316 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3317 rp = (uint8 *)psx_ram; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3318 rp += (a1 & 0x1fffff); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3319 memcpy(rp, &filedata[a0][filepos[a0]], a2); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3320 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3321 filepos[a0] += a2; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3322 mipsinfo.i = a2; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3323 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3324 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3325 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3326 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3327 case 8: // lseek |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3328 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3329 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R31, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3330 printf("IOP: lseek(%d, %d, %s) (PC=%08x)\n", a0, a1, seek_types[a2], mipsinfo.i); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3331 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3332 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3333 switch (a2) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3334 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3335 case 0: // SEEK_SET |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3336 if (a1 <= filesize[a0]) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3337 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3338 filepos[a0] = a1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3339 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3340 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3341 case 1: // SEEK_CUR |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3342 if ((a1 + filepos[a0]) < filesize[a0]) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3343 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3344 filepos[a0] += a1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3345 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3346 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3347 case 2: // SEEK_END |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3348 filepos[a0] = filesize[a0] - a1; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3349 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3350 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3351 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3352 mipsinfo.i = filepos[a0]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3353 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3354 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3355 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3356 case 20: // AddDrv |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3357 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3358 printf("IOP: AddDrv(%x)\n", a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3359 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3360 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3361 mipsinfo.i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3362 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3363 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3364 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3365 case 21: // DelDrv |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3366 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3367 printf("IOP: DelDrv(%x)\n", a0); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3368 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3369 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3370 mipsinfo.i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3371 mips_set_info(CPUINFO_INT_REGISTER + MIPS_R2, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3372 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3373 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3374 default: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3375 printf("IOP: Unhandled service %d for module %s\n", callnum, name); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3376 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3377 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3378 else |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3379 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3380 int lib; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3381 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3382 if (iNumLibs > 0) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3383 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3384 for (lib = 0; lib < iNumLibs; lib++) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3385 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3386 if (!strcmp(name, reglibs[lib].name)) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3387 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3388 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3389 uint32 PC; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3390 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3391 mips_get_info(CPUINFO_INT_REGISTER + MIPS_R31, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3392 PC = mipsinfo.i; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3393 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3394 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3395 // zap the delay slot handling |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3396 mipsinfo.i = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3397 mips_set_info(CPUINFO_INT_REGISTER + MIPS_DELAYV, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3398 mips_set_info(CPUINFO_INT_REGISTER + MIPS_DELAYR, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3399 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3400 mipsinfo.i = LE32(psx_ram[(reglibs[lib].dispatch/4) + callnum]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3401 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3402 // (NOTE: we get called in the delay slot!) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3403 #if DEBUG_HLE_IOP |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3404 printf("IOP: Calling %s (%d) service %d => %08x (parms %08x %08x %08x %08x) (PC=%x)\n", |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3405 reglibs[lib].name, |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3406 lib, |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3407 callnum, |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3408 (uint32)mipsinfo.i, |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3409 a0, a1, a2, a3, PC); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3410 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3411 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3412 #if 0 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3413 if (!strcmp(reglibs[lib].name, "ssd")) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3414 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3415 if (callnum == 37) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3416 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3417 psxcpu_verbose = 4096; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3418 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3419 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3420 #endif |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3421 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3422 mipsinfo.i -= 4; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3423 mips_set_info(CPUINFO_INT_PC, &mipsinfo); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3424 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3425 return; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3426 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3427 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3428 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3429 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3430 printf("IOP: Unhandled service %d for module %s\n", callnum, name); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3431 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3432 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3433 |