console-server.h (e258e51fd256c275cd58a104a6bcb379ff1534f9) console-server.h (b14ca19cf380efbf7a96a348cc6fc81e75bf0591)
1/**
2 * Copyright © 2016 IBM Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0

--- 51 unchanged lines hidden (view full) ---

60#define console_handler_register(h) \
61 static const __attribute__((section("handlers"))) \
62 __attribute__((used)) struct handler * \
63 _handler_name(__COUNTER__) = h
64/* NOLINTEND(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp) */
65
66int console_data_out(struct console *console, const uint8_t *data, size_t len);
67
1/**
2 * Copyright © 2016 IBM Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0

--- 51 unchanged lines hidden (view full) ---

60#define console_handler_register(h) \
61 static const __attribute__((section("handlers"))) \
62 __attribute__((used)) struct handler * \
63 _handler_name(__COUNTER__) = h
64/* NOLINTEND(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp) */
65
66int console_data_out(struct console *console, const uint8_t *data, size_t len);
67
68/* poller API */
69struct poller;
70
71enum poller_ret {
72 POLLER_OK = 0,
73 POLLER_REMOVE,
74 POLLER_EXIT,
75};
76
68enum poller_ret {
69 POLLER_OK = 0,
70 POLLER_REMOVE,
71 POLLER_EXIT,
72};
73
74typedef char(socket_path_t)[sizeof(((struct sockaddr_un *)NULL)->sun_path)];
75
77typedef enum poller_ret (*poller_event_fn_t)(struct handler *handler,
78 int revents, void *data);
79typedef enum poller_ret (*poller_timeout_fn_t)(struct handler *handler,
80 void *data);
81
82/* Console server structure */
83struct console {
84 const char *tty_kname;
85 char *tty_sysfs_devnode;
86 char *tty_dev;
87 const char *console_id;
88 int tty_sirq;
89 uint16_t tty_lpc_addr;
90 speed_t tty_baud;
91 int tty_fd;
92
76typedef enum poller_ret (*poller_event_fn_t)(struct handler *handler,
77 int revents, void *data);
78typedef enum poller_ret (*poller_timeout_fn_t)(struct handler *handler,
79 void *data);
80
81/* Console server structure */
82struct console {
83 const char *tty_kname;
84 char *tty_sysfs_devnode;
85 char *tty_dev;
86 const char *console_id;
87 int tty_sirq;
88 uint16_t tty_lpc_addr;
89 speed_t tty_baud;
90 int tty_fd;
91
92 /* Socket name starts with null character hence we need length */
93 socket_path_t socket_name;
94 ssize_t socket_name_len;
95
93 struct ringbuffer *rb;
94
95 struct handler **handlers;
96 long n_handlers;
97
98 struct poller **pollers;
99 long n_pollers;
100

--- 5 unchanged lines hidden (view full) ---

106struct poller {
107 struct handler *handler;
108 void *data;
109 poller_event_fn_t event_fn;
110 poller_timeout_fn_t timeout_fn;
111 struct timeval timeout;
112 bool remove;
113};
96 struct ringbuffer *rb;
97
98 struct handler **handlers;
99 long n_handlers;
100
101 struct poller **pollers;
102 long n_pollers;
103

--- 5 unchanged lines hidden (view full) ---

109struct poller {
110 struct handler *handler;
111 void *data;
112 poller_event_fn_t event_fn;
113 poller_timeout_fn_t timeout_fn;
114 struct timeval timeout;
115 bool remove;
116};
117
114/* we have two extra entry in the pollfds array for the VUART tty */
115enum internal_pollfds {
116 POLLFD_HOSTTTY = 0,
117 POLLFD_DBUS = 1,
118 MAX_INTERNAL_POLLFD = 2,
119};
120
121struct poller *console_poller_register(struct console *console,

--- 70 unchanged lines hidden (view full) ---

192void config_fini(struct config *config);
193
194int config_parse_baud(speed_t *speed, const char *baud_string);
195uint32_t parse_baud_to_int(speed_t speed);
196speed_t parse_int_to_baud(uint32_t baud);
197int config_parse_logsize(const char *size_str, size_t *size);
198
199/* socket paths */
118/* we have two extra entry in the pollfds array for the VUART tty */
119enum internal_pollfds {
120 POLLFD_HOSTTTY = 0,
121 POLLFD_DBUS = 1,
122 MAX_INTERNAL_POLLFD = 2,
123};
124
125struct poller *console_poller_register(struct console *console,

--- 70 unchanged lines hidden (view full) ---

196void config_fini(struct config *config);
197
198int config_parse_baud(speed_t *speed, const char *baud_string);
199uint32_t parse_baud_to_int(speed_t speed);
200speed_t parse_int_to_baud(uint32_t baud);
201int config_parse_logsize(const char *size_str, size_t *size);
202
203/* socket paths */
200ssize_t console_socket_path(struct sockaddr_un *addr, const char *id);
201
202typedef char(socket_path_t)[sizeof(((struct sockaddr_un *)NULL)->sun_path)];
204ssize_t console_socket_path(socket_path_t path, const char *id);
203ssize_t console_socket_path_readable(const struct sockaddr_un *addr,
204 size_t addrlen, socket_path_t path);
205
206/* utils */
207int write_buf_to_fd(int fd, const uint8_t *buf, size_t len);
208
209/* console-dbus API */
210void dbus_init(struct console *console,

--- 15 unchanged lines hidden ---
205ssize_t console_socket_path_readable(const struct sockaddr_un *addr,
206 size_t addrlen, socket_path_t path);
207
208/* utils */
209int write_buf_to_fd(int fd, const uint8_t *buf, size_t len);
210
211/* console-dbus API */
212void dbus_init(struct console *console,

--- 15 unchanged lines hidden ---