Core commit. Compile and run on the OpenPandora
[mupen64plus-pandora.git] / source / mupen64plus-core / src / r4300 / reset.c
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  *   Mupen64plus - reset.c                                                 *
3  *   Mupen64Plus homepage: http://code.google.com/p/mupen64plus/           *
4  *   Copyright (C) 2011 CasualJames                                        *
5  *   Copyright (C) 2008-2009 Richard Goedeken                              *
6  *   Copyright (C) 2008 Ebenblues Nmn Okaygo Tillin9                       *
7  *   Hard reset based on code by hacktarux.                                *
8  *                                                                         *
9  *   This program is free software; you can redistribute it and/or modify  *
10  *   it under the terms of the GNU General Public License as published by  *
11  *   the Free Software Foundation; either version 2 of the License, or     *
12  *   (at your option) any later version.                                   *
13  *                                                                         *
14  *   This program is distributed in the hope that it will be useful,       *
15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
17  *   GNU General Public License for more details.                          *
18  *                                                                         *
19  *   You should have received a copy of the GNU General Public License     *
20  *   along with this program; if not, write to the                         *
21  *   Free Software Foundation, Inc.,                                       *
22  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
23  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24
25 #include "r4300/reset.h"
26 #include "r4300/r4300.h"
27 #include "r4300/interupt.h"
28 #include "memory/memory.h"
29
30 int reset_hard_job = 0;
31
32 void reset_hard(void)
33 {
34     init_memory(0);
35     r4300_reset_hard();
36     r4300_reset_soft();
37     last_addr = 0xa4000040;
38     next_interupt = 624999;
39     init_interupt();
40     if(r4300emu != CORE_PURE_INTERPRETER)
41     {
42         /* TODO
43          * The following code *should* work and avoid free_blocks() and init_blocks(),
44          * but it doesn't unless the last line is added (which causes a memory leak).
45         int i;
46         for (i=0; i<0x100000; i++)
47             invalid_code[i] = 1;
48         blocks[0xa4000000>>12]->block = NULL; */
49         free_blocks();
50         init_blocks();
51     }
52     generic_jump_to(last_addr);
53 }
54
55 void reset_soft(void)
56 {
57     add_interupt_event(HW2_INT, 0);  /* Hardware 2 Interrupt immediately */
58     add_interupt_event(NMI_INT, 50000000);  /* Non maskable Interrupt after 1/2 second */
59 }