summaryrefslogtreecommitdiff
path: root/kernel/power/tuxonice_ui.h
blob: 4934e3a91074d958ce3bfcb3618e98946ea8c389 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
 * kernel/power/tuxonice_ui.h
 *
 * Copyright (C) 2004-2015 Nigel Cunningham (nigel at nigelcunningham com au)
 */

enum {
        DONT_CLEAR_BAR,
        CLEAR_BAR
};

enum {
        /* Userspace -> Kernel */
        USERUI_MSG_ABORT = 0x11,
        USERUI_MSG_SET_STATE = 0x12,
        USERUI_MSG_GET_STATE = 0x13,
        USERUI_MSG_GET_DEBUG_STATE = 0x14,
        USERUI_MSG_SET_DEBUG_STATE = 0x15,
        USERUI_MSG_SPACE = 0x18,
        USERUI_MSG_GET_POWERDOWN_METHOD = 0x1A,
        USERUI_MSG_SET_POWERDOWN_METHOD = 0x1B,
        USERUI_MSG_GET_LOGLEVEL = 0x1C,
        USERUI_MSG_SET_LOGLEVEL = 0x1D,
        USERUI_MSG_PRINTK = 0x1E,

        /* Kernel -> Userspace */
        USERUI_MSG_MESSAGE = 0x21,
        USERUI_MSG_PROGRESS = 0x22,
        USERUI_MSG_POST_ATOMIC_RESTORE = 0x25,

        USERUI_MSG_MAX,
};

struct userui_msg_params {
        u32 a, b, c, d;
        char text[255];
};

struct ui_ops {
        char (*wait_for_key) (int timeout);
        u32 (*update_status) (u32 value, u32 maximum, const char *fmt, ...);
        void (*prepare_status) (int clearbar, const char *fmt, ...);
        void (*cond_pause) (int pause, char *message);
        void (*abort)(int result_code, const char *fmt, ...);
        void (*prepare)(void);
        void (*cleanup)(void);
        void (*message)(u32 section, u32 level, u32 normally_logged,
                        const char *fmt, ...);
};

extern struct ui_ops *toi_current_ui;

#define toi_update_status(val, max, fmt, args...) \
 (toi_current_ui ? (toi_current_ui->update_status) (val, max, fmt, ##args) : \
        max)

#define toi_prepare_console(void) \
        do { if (toi_current_ui) \
                (toi_current_ui->prepare)(); \
        } while (0)

#define toi_cleanup_console(void) \
        do { if (toi_current_ui) \
                (toi_current_ui->cleanup)(); \
        } while (0)

#define abort_hibernate(result, fmt, args...) \
        do { if (toi_current_ui) \
                (toi_current_ui->abort)(result, fmt, ##args); \
             else { \
                set_abort_result(result); \
             } \
        } while (0)

#define toi_cond_pause(pause, message) \
        do { if (toi_current_ui) \
                (toi_current_ui->cond_pause)(pause, message); \
        } while (0)

#define toi_prepare_status(clear, fmt, args...) \
        do { if (toi_current_ui) \
                (toi_current_ui->prepare_status)(clear, fmt, ##args); \
             else \
                printk(KERN_INFO fmt "%s", ##args, "\n"); \
        } while (0)

#define toi_message(sn, lev, log, fmt, a...) \
do { \
        if (toi_current_ui && (!sn || test_debug_state(sn))) \
                toi_current_ui->message(sn, lev, log, fmt, ##a); \
} while (0)

__exit void toi_ui_cleanup(void);
extern int toi_ui_init(void);
extern void toi_ui_exit(void);
extern int toi_register_ui_ops(struct ui_ops *this_ui);
extern void toi_remove_ui_ops(struct ui_ops *this_ui);