Revision 09aaa160
b/Makefile.target | ||
---|---|---|
179 | 179 |
obj-y += rtl8139.o |
180 | 180 |
obj-y += e1000.o |
181 | 181 |
|
182 |
# Generic watchdog support and some watchdog devices
|
|
183 |
obj-y += wdt_ib700.o wdt_i6300esb.o
|
|
182 |
# PCI watchdog devices
|
|
183 |
obj-y += wdt_i6300esb.o |
|
184 | 184 |
|
185 | 185 |
# Hardware support |
186 | 186 |
obj-i386-y = ide.o pckbd.o vga.o $(sound-obj-y) dma.o isa-bus.o |
187 | 187 |
obj-i386-y += fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o |
188 | 188 |
obj-i386-y += cirrus_vga.o apic.o ioapic.o parallel.o acpi.o piix_pci.o |
189 | 189 |
obj-i386-y += usb-uhci.o vmmouse.o vmport.o vmware_vga.o hpet.o |
190 |
obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o |
|
190 |
obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o wdt_ib700.o
|
|
191 | 191 |
|
192 | 192 |
# shared objects |
193 | 193 |
obj-ppc-y = ppc.o ide.o vga.o $(sound-obj-y) dma.o isa-bus.o openpic.o |
b/hw/pc.c | ||
---|---|---|
1343 | 1343 |
} |
1344 | 1344 |
} |
1345 | 1345 |
|
1346 |
watchdog_pc_init(pci_bus); |
|
1347 |
|
|
1348 | 1346 |
for(i = 0; i < nb_nics; i++) { |
1349 | 1347 |
NICInfo *nd = &nd_table[i]; |
1350 | 1348 |
|
b/hw/watchdog.c | ||
---|---|---|
20 | 20 |
*/ |
21 | 21 |
|
22 | 22 |
#include "qemu-common.h" |
23 |
#include "qemu-option.h" |
|
24 |
#include "qemu-config.h" |
|
23 | 25 |
#include "sys-queue.h" |
24 | 26 |
#include "sysemu.h" |
25 | 27 |
#include "hw/watchdog.h" |
... | ... | |
32 | 34 |
#define WDT_DEBUG 5 /* Prints a message and continues running. */ |
33 | 35 |
#define WDT_NONE 6 /* Do nothing. */ |
34 | 36 |
|
35 |
static WatchdogTimerModel *watchdog; |
|
36 | 37 |
static int watchdog_action = WDT_RESET; |
37 | 38 |
static LIST_HEAD(watchdog_list, WatchdogTimerModel) watchdog_list; |
38 | 39 |
|
... | ... | |
49 | 50 |
int select_watchdog(const char *p) |
50 | 51 |
{ |
51 | 52 |
WatchdogTimerModel *model; |
52 |
|
|
53 |
if (watchdog) { |
|
54 |
fprintf(stderr, |
|
55 |
"qemu: only one watchdog option may be given\n"); |
|
56 |
return 1; |
|
57 |
} |
|
53 |
QemuOpts *opts; |
|
58 | 54 |
|
59 | 55 |
/* -watchdog ? lists available devices and exits cleanly. */ |
60 | 56 |
if (strcmp(p, "?") == 0) { |
... | ... | |
67 | 63 |
|
68 | 64 |
LIST_FOREACH(model, &watchdog_list, entry) { |
69 | 65 |
if (strcasecmp(model->wdt_name, p) == 0) { |
70 |
watchdog = model; |
|
66 |
/* add the device */ |
|
67 |
opts = qemu_opts_create(&qemu_device_opts, NULL, 0); |
|
68 |
qemu_opt_set(opts, "driver", p); |
|
71 | 69 |
return 0; |
72 | 70 |
} |
73 | 71 |
} |
... | ... | |
130 | 128 |
break; |
131 | 129 |
} |
132 | 130 |
} |
133 |
|
|
134 |
void watchdog_pc_init(PCIBus *pci_bus) |
|
135 |
{ |
|
136 |
if (watchdog) |
|
137 |
watchdog->wdt_pc_init(pci_bus); |
|
138 |
} |
|
139 |
|
|
140 |
void register_watchdogs(void) |
|
141 |
{ |
|
142 |
wdt_ib700_init(); |
|
143 |
wdt_i6300esb_init(); |
|
144 |
} |
b/hw/watchdog.h | ||
---|---|---|
22 | 22 |
#ifndef QEMU_WATCHDOG_H |
23 | 23 |
#define QEMU_WATCHDOG_H |
24 | 24 |
|
25 |
extern void wdt_i6300esb_init(void); |
|
26 |
extern void wdt_ib700_init(void); |
|
27 |
|
|
28 |
|
|
29 | 25 |
struct WatchdogTimerModel { |
30 | 26 |
LIST_ENTRY(WatchdogTimerModel) entry; |
31 | 27 |
|
... | ... | |
33 | 29 |
const char *wdt_name; |
34 | 30 |
/* Longer description (eg. manufacturer and full model number). */ |
35 | 31 |
const char *wdt_description; |
36 |
|
|
37 |
/* This callback should create/register the device. It is called |
|
38 |
* indirectly from hw/pc.c when the virtual PC is being set up. |
|
39 |
*/ |
|
40 |
void (*wdt_pc_init)(PCIBus *pci_bus); |
|
41 | 32 |
}; |
42 | 33 |
typedef struct WatchdogTimerModel WatchdogTimerModel; |
43 | 34 |
|
... | ... | |
46 | 37 |
extern int select_watchdog_action(const char *action); |
47 | 38 |
extern void watchdog_add_model(WatchdogTimerModel *model); |
48 | 39 |
extern void watchdog_perform_action(void); |
49 |
extern void watchdog_pc_init(PCIBus *pci_bus); |
|
50 |
extern void register_watchdogs(void); |
|
51 | 40 |
|
52 | 41 |
#endif /* QEMU_WATCHDOG_H */ |
b/hw/wdt_i6300esb.c | ||
---|---|---|
413 | 413 |
return 0; |
414 | 414 |
} |
415 | 415 |
|
416 |
/* Create and initialize a virtual Intel 6300ESB during PC creation. */ |
|
417 |
static void i6300esb_pc_init(PCIBus *pci_bus) |
|
416 |
static void i6300esb_init(PCIDevice *dev) |
|
418 | 417 |
{ |
419 |
I6300State *d; |
|
418 |
I6300State *d = container_of(dev, I6300State, dev);
|
|
420 | 419 |
uint8_t *pci_conf; |
421 | 420 |
|
422 |
if (!pci_bus) { |
|
423 |
fprintf(stderr, "wdt_i6300esb: no PCI bus in this machine\n"); |
|
424 |
return; |
|
425 |
} |
|
426 |
|
|
427 |
d = (I6300State *) |
|
428 |
pci_register_device (pci_bus, "i6300esb_wdt", sizeof (I6300State), |
|
429 |
-1, |
|
430 |
i6300esb_config_read, i6300esb_config_write); |
|
431 |
|
|
432 | 421 |
d->reboot_enabled = 1; |
433 | 422 |
d->clock_scale = CLOCK_SCALE_1KHZ; |
434 | 423 |
d->int_type = INT_TYPE_IRQ; |
... | ... | |
458 | 447 |
static WatchdogTimerModel model = { |
459 | 448 |
.wdt_name = "i6300esb", |
460 | 449 |
.wdt_description = "Intel 6300ESB", |
461 |
.wdt_pc_init = i6300esb_pc_init, |
|
462 | 450 |
}; |
463 | 451 |
|
464 |
void wdt_i6300esb_init(void) |
|
452 |
static PCIDeviceInfo i6300esb_info = { |
|
453 |
.qdev.name = "i6300esb", |
|
454 |
.qdev.size = sizeof(I6300State), |
|
455 |
.config_read = i6300esb_config_read, |
|
456 |
.config_write = i6300esb_config_write, |
|
457 |
.init = i6300esb_init, |
|
458 |
}; |
|
459 |
|
|
460 |
static void i6300esb_register_devices(void) |
|
465 | 461 |
{ |
466 | 462 |
watchdog_add_model(&model); |
463 |
pci_qdev_register(&i6300esb_info); |
|
467 | 464 |
} |
465 |
|
|
466 |
device_init(i6300esb_register_devices); |
b/hw/wdt_ib700.c | ||
---|---|---|
88 | 88 |
return 0; |
89 | 89 |
} |
90 | 90 |
|
91 |
/* Create and initialize a virtual IB700 during PC creation. */ |
|
92 |
static void ib700_pc_init(PCIBus *unused) |
|
91 |
static void wdt_ib700_init(ISADevice *dev) |
|
93 | 92 |
{ |
93 |
timer = qemu_new_timer(vm_clock, ib700_timer_expired, NULL); |
|
94 | 94 |
register_savevm("ib700_wdt", -1, 0, ib700_save, ib700_load, NULL); |
95 |
|
|
96 | 95 |
register_ioport_write(0x441, 2, 1, ib700_write_disable_reg, NULL); |
97 | 96 |
register_ioport_write(0x443, 2, 1, ib700_write_enable_reg, NULL); |
98 | 97 |
} |
... | ... | |
100 | 99 |
static WatchdogTimerModel model = { |
101 | 100 |
.wdt_name = "ib700", |
102 | 101 |
.wdt_description = "iBASE 700", |
103 |
.wdt_pc_init = ib700_pc_init, |
|
104 | 102 |
}; |
105 | 103 |
|
106 |
void wdt_ib700_init(void) |
|
104 |
static ISADeviceInfo wdt_ib700_info = { |
|
105 |
.qdev.name = "ib700", |
|
106 |
.qdev.size = sizeof(ISADevice), |
|
107 |
.init = wdt_ib700_init, |
|
108 |
}; |
|
109 |
|
|
110 |
static void wdt_ib700_register_devices(void) |
|
107 | 111 |
{ |
108 | 112 |
watchdog_add_model(&model); |
109 |
timer = qemu_new_timer(vm_clock, ib700_timer_expired, NULL);
|
|
113 |
isa_qdev_register(&wdt_ib700_info);
|
|
110 | 114 |
} |
115 |
|
|
116 |
device_init(wdt_ib700_register_devices); |
b/vl.c | ||
---|---|---|
233 | 233 |
#ifndef _WIN32 |
234 | 234 |
int daemonize = 0; |
235 | 235 |
#endif |
236 |
const char *watchdog; |
|
236 | 237 |
const char *option_rom[MAX_OPTION_ROMS]; |
237 | 238 |
int nb_option_roms; |
238 | 239 |
int semihosting_enabled = 0; |
... | ... | |
4948 | 4949 |
tb_size = 0; |
4949 | 4950 |
autostart= 1; |
4950 | 4951 |
|
4951 |
register_watchdogs(); |
|
4952 |
|
|
4953 | 4952 |
optind = 1; |
4954 | 4953 |
for(;;) { |
4955 | 4954 |
if (optind >= argc) |
... | ... | |
5361 | 5360 |
serial_device_index++; |
5362 | 5361 |
break; |
5363 | 5362 |
case QEMU_OPTION_watchdog: |
5364 |
i = select_watchdog(optarg); |
|
5365 |
if (i > 0) |
|
5366 |
exit (i == 1 ? 1 : 0); |
|
5363 |
if (watchdog) { |
|
5364 |
fprintf(stderr, |
|
5365 |
"qemu: only one watchdog option may be given\n"); |
|
5366 |
return 1; |
|
5367 |
} |
|
5368 |
watchdog = optarg; |
|
5367 | 5369 |
break; |
5368 | 5370 |
case QEMU_OPTION_watchdog_action: |
5369 | 5371 |
if (select_watchdog_action(optarg) == -1) { |
... | ... | |
5927 | 5929 |
|
5928 | 5930 |
module_call_init(MODULE_INIT_DEVICE); |
5929 | 5931 |
|
5932 |
if (watchdog) { |
|
5933 |
i = select_watchdog(watchdog); |
|
5934 |
if (i > 0) |
|
5935 |
exit (i == 1 ? 1 : 0); |
|
5936 |
} |
|
5937 |
|
|
5930 | 5938 |
if (machine->compat_props) { |
5931 | 5939 |
qdev_prop_register_compat(machine->compat_props); |
5932 | 5940 |
} |
Also available in: Unified diff