Re: want to Restart system on panic()
Re: want to Restart system on panic()
- Subject: Re: want to Restart system on panic()
- From: Josh de Cesare <email@hidden>
- Date: Thu, 21 Oct 2004 12:46:32 -0700
Parav,
There is no direct way to do this. The basic problem is that
the kernel is unwilling to run driver threads after a panic.
Rebooting the system requires running on or more driver threads. The
indirect way is to used the system's watchdog timer. Below is some
sample source to control the watchdog.
Josh
watchdog.c:
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
cc -o watchdog watchdog.c -framework IOKit -Wall
*/
#include <stdio.h>
#include <unistd.h>
#include <IOKit/IOKitLib.h>
#include <CoreFoundation/CoreFoundation.h>
char *gToolName;
mach_port_t gMasterPort;
int main(int argc, char **argv)
{
kern_return_t result;
io_iterator_t watchDogs;
io_registry_entry_t watchDog;
CFNumberRef numberRef;
UInt32 timeOut;
gToolName = argv[0];
// Get master device port.
result = IOMasterPort(bootstrap_port, &gMasterPort);
if (result != KERN_SUCCESS) {
fprintf(stderr, "%s: Failed to get master device port.\n", gToolName);
exit(-1);
}
result =
IOServiceGetMatchingServices(gMasterPort,
IOServiceMatching("IOWatchDogTimer"),
&watchDogs);
if (result != KERN_SUCCESS) {
fprintf(stderr, "%s: Failed to get an iterator for the watchdogs.\n",
gToolName);
exit(-1);
}
watchDog = IOIteratorNext(watchDogs);
if (watchDog == 0) {
fprintf(stderr, "%s: Failed to get a watchdog.\n", gToolName);
exit(-1);
}
IOObjectRelease(watchDogs);
timeOut = 20;
numberRef = CFNumberCreate(kCFAllocatorDefault,
kCFNumberSInt32Type, &timeOut);
while (1) {
printf("Here\n");
IORegistryEntrySetCFProperties(watchDog, numberRef);
sleep(10);
}
return 0;
}
At 5:24 PM +0530 10/21/04, Parav Pandit wrote:
Hi,
I want to restart my system when panic() gets called.
But in xnu i couldn't find code for it.
I searched on assembly files *.s but no fruitful results.
In which file I should look in?
Where should I patch the kernel to restart it?
What instructions should I write to restart it ?
If we look in in to the System Preferences -> Energy Saver->Options we can
restart our machine on daily/weekly basis.
I think that code should I use but where it ?
Regards,
Parav Pandit
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden