sys-manager-core.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * PS3 System Manager core.
  3. *
  4. * Copyright (C) 2007 Sony Computer Entertainment Inc.
  5. * Copyright 2007 Sony Corp.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #include <linux/kernel.h>
  21. #include <asm/ps3.h>
  22. /**
  23. * Staticly linked routines that allow late binding of a loaded sys-manager
  24. * module.
  25. */
  26. static struct ps3_sys_manager_ops ps3_sys_manager_ops;
  27. /**
  28. * ps3_register_sys_manager_ops - Bind ps3_sys_manager_ops to a module.
  29. * @ops: struct ps3_sys_manager_ops.
  30. *
  31. * To be called from ps3_sys_manager_probe() and ps3_sys_manager_remove() to
  32. * register call back ops for power control. Copies data to the static
  33. * variable ps3_sys_manager_ops.
  34. */
  35. void ps3_sys_manager_register_ops(const struct ps3_sys_manager_ops *ops)
  36. {
  37. BUG_ON(!ops);
  38. BUG_ON(!ops->dev);
  39. ps3_sys_manager_ops = ops ? *ops : ps3_sys_manager_ops;
  40. }
  41. EXPORT_SYMBOL_GPL(ps3_sys_manager_register_ops);
  42. void ps3_sys_manager_power_off(void)
  43. {
  44. if (ps3_sys_manager_ops.power_off)
  45. ps3_sys_manager_ops.power_off(ps3_sys_manager_ops.dev);
  46. printk(KERN_EMERG "System Halted, OK to turn off power\n");
  47. local_irq_disable();
  48. while (1)
  49. (void)0;
  50. }
  51. void ps3_sys_manager_restart(void)
  52. {
  53. if (ps3_sys_manager_ops.restart)
  54. ps3_sys_manager_ops.restart(ps3_sys_manager_ops.dev);
  55. printk(KERN_EMERG "System Halted, OK to turn off power\n");
  56. local_irq_disable();
  57. while (1)
  58. (void)0;
  59. }