summaryrefslogtreecommitdiffstats
path: root/private/ntos/boot/veneer/vrrstart.c
blob: 7d4ebc3f68e9fd5cd7b7a4a151423f63f65fd774 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
/*
 *
 * Copyright (c) 1994 FirePower Systems Inc.
 * Copyright (c) 1995 FirePower Systems, Inc.
 *
 * $RCSfile: vrrstart.c $
 * $Revision: 1.7 $
 * $Date: 1996/04/15 02:55:36 $
 * $Locker:  $
 *
 *
 * Module Name:
 *	 vrrstart.c
 *
 * Author:
 *	 Shin Iwamoto at FirePower Systems Inc.
 *
 * History:
 *	 16-Jun-94  Shin Iwamoto at FirePower Systems Inc.
 *		  Changed the property getting code using get_str_prop()
 *		  in VrGetSystemId().
 *	 14-Jun-94  Shin Iwamoto at FirePower Systems Inc.
 *		  Added the pointer to SystemId because type mismatch happened.
 *	 19-May-94  Shin Iwamoto at FirePower Systems Inc.
 *		  Added some comments.
 *	 13-May-94  Shin Iwamoto at FirePower Systems Inc.
 *		  Added jump-logic to the restart address in VrRestart().
 *		  Added VrRestartInitialize().
 *	 12-May-94  Shin Iwamoto at FirePower Systems Inc.
 *		  Created.
 *
 */



#include "veneer.h"


//
// Static data.
//
STATIC SYSTEM_ID SystemId;


/*
 * Name:	VrEnterInteractiveMode
 *
 * Description:
 *  This function terminates the executing program and enters
 *  interactive mode.
 *
 * Arguments:
 *  None.
 *
 * Return Value:
 *  None.
 *
 */
VOID
VrEnterInteractiveMode(
	VOID
	)
{
	(VOID)OFEnter();
}


/*
 * Name:	VrGetSystemId
 *
 * Description:
 *  This function returns a pointer to a system identification
 *  structure that contains information used to uniquely identify
 *  each system.
 *
 * Arguments:
 *  None.
 *
 * Return Value:
 *  The 16-byte system identification structure is returned.
 *
 */
PSYSTEM_ID
VrGetSystemId(
	VOID
	)
{
	phandle PHandle;
	PCHAR Property;
	PSYSTEM_ID PSystemId = &SystemId;

	if ((LONG)(PHandle = OFFinddevice("/")) == -1) {
		fatal("Veneer: cannot find the root node in Open Firmware.\n");
	}

	if ((Property = get_str_prop(PHandle, "name", NOALLOC)) == (PCHAR)NULL) {
		fatal("Veneer: cannot get the name property for the root node.\n");
	}
	bcopy(Property, SystemId.VendorId, 8);

	if ((Property = get_str_prop(PHandle, "id", NOALLOC)) == (PCHAR)NULL) {
		fatal("Veneer: cannot get the name property for the root node.\n");
	}
	bcopy(Property, SystemId.ProductId, 8);

	return PSystemId;
}


/*
 * Name:	VrPowerDown
 *
 * Description:
 *  This function is identical to the VrHalt() with the additional
 *  feature that, the power to a system is removed if the system is
 *  equipped so.
 *
 * Arguments:
 *  None.
 *
 * Return Value:
 *  None.
 *
 */
VOID
VrPowerDown(VOID)
{
	// XXX - This must use the HALT interface; see the PPC binding.
	OFExit();
}


/*
 * Name:	VrReboot
 *
 * Description:
 *  This function reboots the system with the same parameters used
 *  for the previous system load sequence. If the parameters cannot
 *  be reproduced, then the default system load sequence is performed.
 *
 * Arguments:
 *  None.
 *
 * Return Value:
 *  None.
 *
 */
VOID
VrReboot(
	VOID
	)
{
	// XXXX
	// Make sure that this funciton reboots the system with the same
	// parameters used for the previous system load sequence. If the
	// parameters cannot be reporduced, then the default system load
	// sequence is performed.
	(VOID)OFBoot((PCHAR)NULL);
}


/*
 * Name:	VrRestart
 *
 * Description:
 *  This function performs the equivalent of a power-on reset.
 *
 * Arguments:
 *  None.
 *
 * Return Value:
 *  None.
 *
 */
VOID
VrRestart(
	VOID
	)
{

	PRESTART_BLOCK PRestartBlock;

	//
	// Detect the presence of a valid Restart Block
	//
	PRestartBlock = SYSTEM_BLOCK->RestartBlock;
	while (PRestartBlock != (PRESTART_BLOCK)NULL) {
		if (PRestartBlock->Signature == RSTB_SIGNATURE &&
						(PRestartBlock->Version == ARC_VERSION) &&
						(PRestartBlock->Revision == ARC_REVISION)) {

			break;
		}
		PRestartBlock = PRestartBlock->NextRestartBlock;
	}

	//
	// Perform a normal power-on sequence if a valid RestartBlock
	// is not found.
	//
	if (PRestartBlock == (PRESTART_BLOCK)NULL) {
		(VOID)OFBoot((PCHAR)NULL);
	}
	//
	// Reboot the system.
	//

	//
	// Goto the RestartAddress, not return;
	//
	(VOID)(*(VOID (*)())(PRestartBlock->RestartAddress))();
}


/*
 * Name:	VrHalt
 *
 * Description:
 *  This function exits the program.
 *
 * Arguments:
 *  None.
 *
 * Return Value:
 *  None.
 *
 */
VOID
VrHalt(
	VOID
	)
{
	(VOID)OFExit();
}


/*
 * Name:	VrRestartInitialize
 *
 * Description:
 *   This function initializes restart routine addresses in the firmware
 *   transfer vector.
 *
 * Arguments:
 *   None.
 *
 * Return Value:
 *   None.
 *
 */
VOID
VrRestartInitialize(
	VOID
	)
{
	debug(VRDBG_ENTRY, "VrRestartInitialize			BEGIN....\n");
	//
	// Initialize Restart routine addresses in the firmware transfer vector.
	//
	(PARC_INTERACTIVE_MODE_ROUTINE)
			SYSTEM_BLOCK->FirmwareVector[InteractiveModeRoutine] =
													VrEnterInteractiveMode;
	(PARC_GET_SYSTEM_ID_ROUTINE)
			SYSTEM_BLOCK->FirmwareVector[GetSystemIdRoutine] = VrGetSystemId;
	(PARC_POWERDOWN_ROUTINE)
			SYSTEM_BLOCK->FirmwareVector[PowerDownRoutine] = VrPowerDown;
	(PARC_REBOOT_ROUTINE)
			SYSTEM_BLOCK->FirmwareVector[RebootRoutine] = VrReboot;
	(PARC_RESTART_ROUTINE)
			SYSTEM_BLOCK->FirmwareVector[RestartRoutine] = VrRestart;
	(PARC_HALT_ROUTINE)
			SYSTEM_BLOCK->FirmwareVector[HaltRoutine] = VrHalt;
	debug(VRDBG_ENTRY, "VrRestartInitialize			....END\n");
}