1 /*	Implementation of VMIPS halt device.
2 	Copyright 2002 Paul Twohey.
3 
4 This file is part of VMIPS.
5 
6 VMIPS is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2 of the License, or (at your
9 option) any later version.
10 
11 VMIPS is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 for more details.
15 
16 You should have received a copy of the GNU General Public License along
17 with VMIPS; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
19 
20 #include "haltdev.h"
21 #include "vmips.h"
22 
23 #include <cassert>
24 
HaltDevice(vmips * machine)25 HaltDevice::HaltDevice( vmips *machine )
26 	: machine( machine )
27 {
28 	assert( machine );
29 
30 	// XXX hack until we get ranges working properly
31 	extent = 4;
32 }
33 
~HaltDevice()34 HaltDevice::~HaltDevice()
35 {
36 }
37 
fetch_word(uint32 offset,int mode,DeviceExc * client)38 uint32 HaltDevice::fetch_word(uint32 offset, int mode, DeviceExc *client)
39 {
40 	switch( offset / 4 ) {
41 	case 0:		// halt control
42 		return 0;
43 	default:
44 		assert( ! "reached" );
45 		return 0;
46 	}
47 }
48 
store_word(uint32 offset,uint32 data,DeviceExc * client)49 void HaltDevice::store_word( uint32 offset, uint32 data, DeviceExc *client )
50 {
51 	switch( offset / 4 ) {
52 	case 0:
53 		if( data )
54 			machine->halt();
55 		break;
56 	default:
57 		assert( ! "reached" );
58 	}
59 }
60 
descriptor_str()61 const char *HaltDevice::descriptor_str()
62 {
63 	return "Halt device";
64 }
65