tuxonice_ui.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * kernel/power/tuxonice_ui.h
  3. *
  4. * Copyright (C) 2004-2014 Nigel Cunningham (nigel at tuxonice net)
  5. */
  6. enum {
  7. DONT_CLEAR_BAR,
  8. CLEAR_BAR
  9. };
  10. enum {
  11. /* Userspace -> Kernel */
  12. USERUI_MSG_ABORT = 0x11,
  13. USERUI_MSG_SET_STATE = 0x12,
  14. USERUI_MSG_GET_STATE = 0x13,
  15. USERUI_MSG_GET_DEBUG_STATE = 0x14,
  16. USERUI_MSG_SET_DEBUG_STATE = 0x15,
  17. USERUI_MSG_SPACE = 0x18,
  18. USERUI_MSG_GET_POWERDOWN_METHOD = 0x1A,
  19. USERUI_MSG_SET_POWERDOWN_METHOD = 0x1B,
  20. USERUI_MSG_GET_LOGLEVEL = 0x1C,
  21. USERUI_MSG_SET_LOGLEVEL = 0x1D,
  22. USERUI_MSG_PRINTK = 0x1E,
  23. /* Kernel -> Userspace */
  24. USERUI_MSG_MESSAGE = 0x21,
  25. USERUI_MSG_PROGRESS = 0x22,
  26. USERUI_MSG_POST_ATOMIC_RESTORE = 0x25,
  27. USERUI_MSG_MAX,
  28. };
  29. struct userui_msg_params {
  30. u32 a, b, c, d;
  31. char text[255];
  32. };
  33. struct ui_ops {
  34. char (*wait_for_key)(int timeout);
  35. u32 (*update_status)(u32 value, u32 maximum, const char *fmt, ...);
  36. void (*prepare_status)(int clearbar, const char *fmt, ...);
  37. void (*cond_pause)(int pause, char *message);
  38. void (*abort)(int result_code, const char *fmt, ...);
  39. void (*prepare)(void);
  40. void (*cleanup)(void);
  41. void (*message)(u32 section, u32 level, u32 normally_logged,
  42. const char *fmt, ...);
  43. };
  44. extern struct ui_ops *toi_current_ui;
  45. #define toi_update_status(val, max, fmt, args...) \
  46. (toi_current_ui ? (toi_current_ui->update_status) (val, max, fmt, ##args) : max)
  47. #define toi_prepare_console(void) \
  48. do { \
  49. if (toi_current_ui) \
  50. (toi_current_ui->prepare)(); \
  51. } while (0)
  52. #define toi_cleanup_console(void) \
  53. do { \
  54. if (toi_current_ui) \
  55. (toi_current_ui->cleanup)(); \
  56. } while (0)
  57. #define abort_hibernate(result, fmt, args...) \
  58. do { \
  59. if (toi_current_ui) \
  60. (toi_current_ui->abort)(result, fmt, ##args); \
  61. else { \
  62. set_abort_result(result); \
  63. } \
  64. } while (0)
  65. #define toi_cond_pause(pause, message) \
  66. do { \
  67. if (toi_current_ui) \
  68. (toi_current_ui->cond_pause)(pause, message); \
  69. } while (0)
  70. #define toi_prepare_status(clear, fmt, args...) \
  71. do { \
  72. if (toi_current_ui) \
  73. (toi_current_ui->prepare_status)(clear, fmt, ##args); \
  74. else \
  75. pr_warn(fmt, ##args); \
  76. } while (0)
  77. #define toi_message(sn, lev, log, fmt, a...) \
  78. do { \
  79. if (toi_current_ui && (!sn || test_debug_state(sn))) \
  80. toi_current_ui->message(sn, lev, log, fmt, ##a); \
  81. else \
  82. pr_debug(fmt, ##a); \
  83. } while (0)
  84. __exit void toi_ui_cleanup(void);
  85. extern int toi_ui_init(void);
  86. extern void toi_ui_exit(void);
  87. extern int toi_register_ui_ops(struct ui_ops *this_ui);
  88. extern void toi_remove_ui_ops(struct ui_ops *this_ui);