init.c 1007 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * @file init.c
  3. *
  4. * @remark Copyright 2002 OProfile authors
  5. * @remark Read the file COPYING
  6. *
  7. * @author John Levon <levon@movementarian.org>
  8. */
  9. #include <linux/oprofile.h>
  10. #include <linux/init.h>
  11. #include <linux/errno.h>
  12. /*
  13. * We support CPUs that have performance counters like the Pentium Pro
  14. * with the NMI mode driver.
  15. */
  16. extern int op_nmi_init(struct oprofile_operations *ops);
  17. extern int op_nmi_timer_init(struct oprofile_operations *ops);
  18. extern void op_nmi_exit(void);
  19. extern void x86_backtrace(struct pt_regs * const regs, unsigned int depth);
  20. static int nmi_timer;
  21. int __init oprofile_arch_init(struct oprofile_operations *ops)
  22. {
  23. int ret;
  24. ret = -ENODEV;
  25. #ifdef CONFIG_X86_LOCAL_APIC
  26. ret = op_nmi_init(ops);
  27. #endif
  28. nmi_timer = (ret != 0);
  29. #ifdef CONFIG_X86_IO_APIC
  30. if (nmi_timer)
  31. ret = op_nmi_timer_init(ops);
  32. #endif
  33. ops->backtrace = x86_backtrace;
  34. return ret;
  35. }
  36. void oprofile_arch_exit(void)
  37. {
  38. #ifdef CONFIG_X86_LOCAL_APIC
  39. if (!nmi_timer)
  40. op_nmi_exit();
  41. #endif
  42. }