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