Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] i386: Add machine_ops interface to abstract halting and rebooting

machine_ops is an interface for the machine_* functions defined in
<linux/reboot.h>. This is intended to allow hypervisors to intercept
the reboot process, but it could be used to implement other x86
subarchtecture reboots.

Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Signed-off-by: Andi Kleen <ak@suse.de>

authored by

Jeremy Fitzhardinge and committed by
Andi Kleen
07f3331c 01a2f435

+59 -7
+1 -2
arch/i386/kernel/apm.c
··· 233 233 #include <asm/desc.h> 234 234 #include <asm/i8253.h> 235 235 #include <asm/paravirt.h> 236 + #include <asm/reboot.h> 236 237 237 238 #include "io_ports.h" 238 - 239 - extern void machine_real_restart(unsigned char *, int); 240 239 241 240 #if defined(CONFIG_APM_DISPLAY_BLANK) && defined(CONFIG_VT) 242 241 extern int (*console_blank_hook)(int);
+38 -5
arch/i386/kernel/reboot.c
··· 18 18 #include <asm/desc.h> 19 19 #include "mach_reboot.h" 20 20 #include <asm/reboot_fixups.h> 21 + #include <asm/reboot.h> 21 22 22 23 /* 23 24 * Power off function, if any ··· 281 280 EXPORT_SYMBOL(machine_real_restart); 282 281 #endif 283 282 284 - void machine_shutdown(void) 283 + static void native_machine_shutdown(void) 285 284 { 286 285 #ifdef CONFIG_SMP 287 286 int reboot_cpu_id; ··· 321 320 { 322 321 } 323 322 324 - void machine_emergency_restart(void) 323 + static void native_machine_emergency_restart(void) 325 324 { 326 325 if (!reboot_thru_bios) { 327 326 if (efi_enabled) { ··· 345 344 machine_real_restart(jump_to_bios, sizeof(jump_to_bios)); 346 345 } 347 346 348 - void machine_restart(char * __unused) 347 + static void native_machine_restart(char * __unused) 349 348 { 350 349 machine_shutdown(); 351 350 machine_emergency_restart(); 352 351 } 353 352 354 - void machine_halt(void) 353 + static void native_machine_halt(void) 355 354 { 356 355 } 357 356 358 - void machine_power_off(void) 357 + static void native_machine_power_off(void) 359 358 { 360 359 if (pm_power_off) { 361 360 machine_shutdown(); ··· 364 363 } 365 364 366 365 366 + struct machine_ops machine_ops = { 367 + .power_off = native_machine_power_off, 368 + .shutdown = native_machine_shutdown, 369 + .emergency_restart = native_machine_emergency_restart, 370 + .restart = native_machine_restart, 371 + .halt = native_machine_halt, 372 + }; 373 + 374 + void machine_power_off(void) 375 + { 376 + machine_ops.power_off(); 377 + } 378 + 379 + void machine_shutdown(void) 380 + { 381 + machine_ops.shutdown(); 382 + } 383 + 384 + void machine_emergency_restart(void) 385 + { 386 + machine_ops.emergency_restart(); 387 + } 388 + 389 + void machine_restart(char *cmd) 390 + { 391 + machine_ops.restart(cmd); 392 + } 393 + 394 + void machine_halt(void) 395 + { 396 + machine_ops.halt(); 397 + }
+20
include/asm-i386/reboot.h
··· 1 + #ifndef _ASM_REBOOT_H 2 + #define _ASM_REBOOT_H 3 + 4 + struct pt_regs; 5 + 6 + struct machine_ops 7 + { 8 + void (*restart)(char *cmd); 9 + void (*halt)(void); 10 + void (*power_off)(void); 11 + void (*shutdown)(void); 12 + void (*crash_shutdown)(struct pt_regs *); 13 + void (*emergency_restart)(void); 14 + }; 15 + 16 + extern struct machine_ops machine_ops; 17 + 18 + void machine_real_restart(unsigned char *code, int length); 19 + 20 + #endif /* _ASM_REBOOT_H */