Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 1 | /* |
| 2 | * Mailbox Daemon Implementation |
| 3 | * |
| 4 | * Copyright 2016 IBM |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 11 | * |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 17 | * |
| 18 | */ |
| 19 | |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 20 | #define _GNU_SOURCE |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 21 | #include <assert.h> |
| 22 | #include <errno.h> |
| 23 | #include <fcntl.h> |
| 24 | #include <getopt.h> |
| 25 | #include <limits.h> |
| 26 | #include <poll.h> |
| 27 | #include <stdbool.h> |
| 28 | #include <stdint.h> |
| 29 | #include <stdio.h> |
| 30 | #include <stdlib.h> |
| 31 | #include <string.h> |
| 32 | #include <syslog.h> |
Michael Neuling | 899ebac | 2017-01-14 11:20:26 -0600 | [diff] [blame] | 33 | #include <signal.h> |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 34 | #include <sys/ioctl.h> |
| 35 | #include <sys/mman.h> |
| 36 | #include <sys/stat.h> |
| 37 | #include <sys/timerfd.h> |
| 38 | #include <sys/types.h> |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 39 | #include <sys/signalfd.h> |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 40 | #include <time.h> |
| 41 | #include <unistd.h> |
Andrew Jeffery | 78210b9 | 2017-01-13 13:06:09 +1030 | [diff] [blame] | 42 | #include <inttypes.h> |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 43 | #include <systemd/sd-bus.h> |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 44 | |
| 45 | #include "mbox.h" |
| 46 | #include "common.h" |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 47 | #include "dbus.h" |
| 48 | #include "mboxd_dbus.h" |
| 49 | #include "mboxd_flash.h" |
| 50 | #include "mboxd_lpc.h" |
| 51 | #include "mboxd_msg.h" |
| 52 | #include "mboxd_windows.h" |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 53 | |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 54 | #define USAGE \ |
| 55 | "\nUsage: %s [-V | --version] [-h | --help] [-v[v] | --verbose] [-s | --syslog]\n" \ |
Suraj Jitindar Singh | c29172e | 2017-04-12 14:26:47 +1000 | [diff] [blame] | 56 | "\t\t[-n | --window-num <num>]\n" \ |
| 57 | "\t\t[-w | --window-size <size>M]\n" \ |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 58 | "\t\t-f | --flash <size>[K|M]\n\n" \ |
| 59 | "\t-v | --verbose\t\tBe [more] verbose\n" \ |
| 60 | "\t-s | --syslog\t\tLog output to syslog (pointless without -v)\n" \ |
| 61 | "\t-n | --window-num\tThe number of windows\n" \ |
Suraj Jitindar Singh | c29172e | 2017-04-12 14:26:47 +1000 | [diff] [blame] | 62 | "\t\t\t\t(default: fill the reserved memory region)\n" \ |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 63 | "\t-w | --window-size\tThe window size (power of 2) in MB\n" \ |
Suraj Jitindar Singh | c29172e | 2017-04-12 14:26:47 +1000 | [diff] [blame] | 64 | "\t\t\t\t(default: 1MB)\n" \ |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 65 | "\t-f | --flash\t\tSize of flash in [K|M] bytes\n\n" |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 66 | |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 67 | static int poll_loop(struct mbox_context *context) |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 68 | { |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 69 | int rc = 0, i; |
Cyril Bur | 4623367 | 2017-01-16 13:33:26 +1100 | [diff] [blame] | 70 | |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 71 | /* Set POLLIN on polling file descriptors */ |
| 72 | for (i = 0; i < POLL_FDS; i++) { |
| 73 | context->fds[i].events = POLLIN; |
Cyril Bur | 4623367 | 2017-01-16 13:33:26 +1100 | [diff] [blame] | 74 | } |
| 75 | |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 76 | while (1) { |
| 77 | rc = poll(context->fds, POLL_FDS, -1); |
| 78 | |
| 79 | if (rc < 0) { /* Error */ |
| 80 | MSG_ERR("Error from poll(): %s\n", strerror(errno)); |
| 81 | break; /* This should mean we clean up nicely */ |
| 82 | } |
| 83 | |
| 84 | /* Event on Polled File Descriptor - Handle It */ |
| 85 | if (context->fds[SIG_FD].revents & POLLIN) { /* Signal */ |
| 86 | struct signalfd_siginfo info = { 0 }; |
| 87 | |
| 88 | rc = read(context->fds[SIG_FD].fd, (void *) &info, |
| 89 | sizeof(info)); |
| 90 | if (rc != sizeof(info)) { |
| 91 | MSG_ERR("Error reading signal event: %s\n", |
| 92 | strerror(errno)); |
| 93 | } |
| 94 | |
Suraj Jitindar Singh | 2851959 | 2017-04-27 14:48:58 +1000 | [diff] [blame^] | 95 | MSG_DBG("Received signal: %d\n", info.ssi_signo); |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 96 | switch (info.ssi_signo) { |
| 97 | case SIGINT: |
| 98 | case SIGTERM: |
Suraj Jitindar Singh | 2851959 | 2017-04-27 14:48:58 +1000 | [diff] [blame^] | 99 | MSG_INFO("Caught Signal - Exiting...\n"); |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 100 | context->terminate = true; |
| 101 | break; |
| 102 | case SIGHUP: |
| 103 | /* Host didn't request reset -> Notify it */ |
| 104 | reset_all_windows(context, SET_BMC_EVENT); |
| 105 | rc = point_to_flash(context); |
| 106 | if (rc < 0) { |
| 107 | MSG_ERR("WARNING: Failed to point the " |
| 108 | "LPC bus back to flash on " |
| 109 | "SIGHUP\nIf the host requires " |
| 110 | "this expect problems...\n"); |
| 111 | } |
| 112 | break; |
| 113 | default: |
| 114 | MSG_ERR("Unhandled Signal: %d\n", |
| 115 | info.ssi_signo); |
| 116 | break; |
| 117 | } |
| 118 | } |
| 119 | if (context->fds[DBUS_FD].revents & POLLIN) { /* DBUS */ |
Suraj Jitindar Singh | 2851959 | 2017-04-27 14:48:58 +1000 | [diff] [blame^] | 120 | while ((rc = sd_bus_process(context->bus, NULL)) > 0) { |
| 121 | MSG_DBG("DBUS Event\n"); |
| 122 | } |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 123 | if (rc < 0) { |
| 124 | MSG_ERR("Error handling DBUS event: %s\n", |
| 125 | strerror(-rc)); |
| 126 | } |
| 127 | } |
| 128 | if (context->terminate) { |
| 129 | break; /* This should mean we clean up nicely */ |
| 130 | } |
| 131 | if (context->fds[MBOX_FD].revents & POLLIN) { /* MBOX */ |
Suraj Jitindar Singh | 2851959 | 2017-04-27 14:48:58 +1000 | [diff] [blame^] | 132 | MSG_DBG("MBOX Event\n"); |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 133 | rc = dispatch_mbox(context); |
| 134 | if (rc < 0) { |
| 135 | MSG_ERR("Error handling MBOX event\n"); |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | /* Best to reset windows and point back to flash for safety */ |
| 141 | /* Host didn't request reset -> Notify it */ |
| 142 | reset_all_windows(context, SET_BMC_EVENT); |
| 143 | rc = point_to_flash(context); |
| 144 | /* Not much we can do if this fails */ |
| 145 | if (rc < 0) { |
| 146 | MSG_ERR("WARNING: Failed to point the LPC bus back to flash\n" |
| 147 | "If the host requires this expect problems...\n"); |
| 148 | } |
| 149 | |
| 150 | return rc; |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 151 | } |
| 152 | |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 153 | static int init_signals(struct mbox_context *context, sigset_t *set) |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 154 | { |
| 155 | int rc; |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 156 | |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 157 | /* Block SIGHUPs, SIGTERMs and SIGINTs */ |
| 158 | sigemptyset(set); |
| 159 | sigaddset(set, SIGHUP); |
| 160 | sigaddset(set, SIGINT); |
| 161 | sigaddset(set, SIGTERM); |
| 162 | rc = sigprocmask(SIG_BLOCK, set, NULL); |
| 163 | if (rc < 0) { |
| 164 | MSG_ERR("Failed to set SIG_BLOCK mask %s\n", strerror(errno)); |
| 165 | return rc; |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 166 | } |
| 167 | |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 168 | /* Get Signal File Descriptor */ |
| 169 | rc = signalfd(-1, set, SFD_NONBLOCK); |
| 170 | if (rc < 0) { |
| 171 | MSG_ERR("Failed to get signalfd %s\n", strerror(errno)); |
| 172 | return rc; |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 173 | } |
| 174 | |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 175 | context->fds[SIG_FD].fd = rc; |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 176 | return 0; |
| 177 | } |
| 178 | |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 179 | static void usage(const char *name) |
| 180 | { |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 181 | printf(USAGE, name); |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 182 | } |
| 183 | |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 184 | static bool parse_cmdline(int argc, char **argv, |
| 185 | struct mbox_context *context) |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 186 | { |
Cyril Bur | e8f2de1 | 2017-01-17 16:56:02 +1100 | [diff] [blame] | 187 | char *endptr; |
Suraj Jitindar Singh | c29172e | 2017-04-12 14:26:47 +1000 | [diff] [blame] | 188 | int opt; |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 189 | |
| 190 | static const struct option long_options[] = { |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 191 | { "flash", required_argument, 0, 'f' }, |
| 192 | { "window-size", optional_argument, 0, 'w' }, |
| 193 | { "window-num", optional_argument, 0, 'n' }, |
| 194 | { "verbose", no_argument, 0, 'v' }, |
| 195 | { "syslog", no_argument, 0, 's' }, |
| 196 | { "version", no_argument, 0, 'V' }, |
| 197 | { "help", no_argument, 0, 'h' }, |
| 198 | { 0, 0, 0, 0 } |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 199 | }; |
| 200 | |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 201 | verbosity = MBOX_LOG_NONE; |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 202 | mbox_vlog = &mbox_log_console; |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 203 | |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 204 | context->current = NULL; /* No current window */ |
| 205 | |
| 206 | while ((opt = getopt_long(argc, argv, "f:w::n::vsVh", long_options, NULL)) |
| 207 | != -1) { |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 208 | switch (opt) { |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 209 | case 0: |
| 210 | break; |
| 211 | case 'f': |
| 212 | context->flash_size = strtol(optarg, &endptr, 10); |
| 213 | if (optarg == endptr) { |
| 214 | fprintf(stderr, "Unparseable flash size\n"); |
| 215 | return false; |
| 216 | } |
| 217 | switch (*endptr) { |
| 218 | case '\0': |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 219 | break; |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 220 | case 'M': |
| 221 | context->flash_size <<= 10; |
| 222 | case 'K': |
| 223 | context->flash_size <<= 10; |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 224 | break; |
| 225 | default: |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 226 | fprintf(stderr, "Unknown units '%c'\n", |
| 227 | *endptr); |
| 228 | return false; |
| 229 | } |
| 230 | break; |
| 231 | case 'n': |
| 232 | context->windows.num = strtol(argv[optind], &endptr, |
| 233 | 10); |
| 234 | if (optarg == endptr || *endptr != '\0') { |
| 235 | fprintf(stderr, "Unparseable window num\n"); |
| 236 | return false; |
| 237 | } |
| 238 | break; |
| 239 | case 'w': |
| 240 | context->windows.default_size = strtol(argv[optind], |
| 241 | &endptr, 10); |
| 242 | context->windows.default_size <<= 20; /* Given in MB */ |
| 243 | if (optarg == endptr || (*endptr != '\0' && |
| 244 | *endptr != 'M')) { |
| 245 | fprintf(stderr, "Unparseable window size\n"); |
| 246 | return false; |
| 247 | } |
Suraj Jitindar Singh | 0aff80c | 2017-04-12 14:37:24 +1000 | [diff] [blame] | 248 | if (!is_power_of_2(context->windows.default_size)) { |
| 249 | fprintf(stderr, "Window size not power of 2\n"); |
| 250 | return false; |
| 251 | } |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 252 | break; |
| 253 | case 'v': |
| 254 | verbosity++; |
| 255 | break; |
| 256 | case 's': |
| 257 | /* Avoid a double openlog() */ |
| 258 | if (mbox_vlog != &vsyslog) { |
| 259 | openlog(PREFIX, LOG_ODELAY, LOG_DAEMON); |
| 260 | mbox_vlog = &vsyslog; |
| 261 | } |
| 262 | break; |
| 263 | case 'V': |
| 264 | printf("%s v%d.%.2d\n", THIS_NAME, API_MAX_VERSION, |
| 265 | SUB_VERSION); |
| 266 | exit(0); |
| 267 | case 'h': |
| 268 | return false; /* This will print the usage message */ |
| 269 | default: |
| 270 | return false; |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 271 | } |
| 272 | } |
| 273 | |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 274 | if (!context->flash_size) { |
Cyril Bur | e8f2de1 | 2017-01-17 16:56:02 +1100 | [diff] [blame] | 275 | fprintf(stderr, "Must specify a non-zero flash size\n"); |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 276 | return false; |
Cyril Bur | e8f2de1 | 2017-01-17 16:56:02 +1100 | [diff] [blame] | 277 | } |
| 278 | |
Suraj Jitindar Singh | 2851959 | 2017-04-27 14:48:58 +1000 | [diff] [blame^] | 279 | MSG_INFO("Flash size: 0x%.8x\n", context->flash_size); |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 280 | |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 281 | if (verbosity) { |
Suraj Jitindar Singh | 2851959 | 2017-04-27 14:48:58 +1000 | [diff] [blame^] | 282 | MSG_INFO("%s logging\n", verbosity == MBOX_LOG_DEBUG ? "Debug" : |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 283 | "Verbose"); |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 284 | } |
| 285 | |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 286 | return true; |
Cyril Bur | c85e34d | 2016-11-15 11:50:41 +1100 | [diff] [blame] | 287 | } |
| 288 | |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 289 | int main(int argc, char **argv) |
| 290 | { |
| 291 | struct mbox_context *context; |
| 292 | char *name = argv[0]; |
| 293 | sigset_t set; |
| 294 | int rc, i; |
| 295 | |
| 296 | context = calloc(1, sizeof(*context)); |
| 297 | if (!context) { |
| 298 | fprintf(stderr, "Memory allocation failed\n"); |
| 299 | exit(1); |
| 300 | } |
| 301 | |
| 302 | if (!parse_cmdline(argc, argv, context)) { |
| 303 | usage(name); |
| 304 | free(context); |
| 305 | exit(0); |
| 306 | } |
| 307 | |
| 308 | for (i = 0; i < TOTAL_FDS; i++) { |
| 309 | context->fds[i].fd = -1; |
| 310 | } |
| 311 | |
Suraj Jitindar Singh | 2851959 | 2017-04-27 14:48:58 +1000 | [diff] [blame^] | 312 | MSG_INFO("Starting Daemon\n"); |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 313 | |
| 314 | rc = init_signals(context, &set); |
| 315 | if (rc) { |
| 316 | goto finish; |
| 317 | } |
| 318 | |
| 319 | rc = init_mbox_dev(context); |
| 320 | if (rc) { |
| 321 | goto finish; |
| 322 | } |
| 323 | |
| 324 | rc = init_lpc_dev(context); |
| 325 | if (rc) { |
| 326 | goto finish; |
| 327 | } |
| 328 | |
| 329 | /* We've found the reserved memory region -> we can assign to windows */ |
Suraj Jitindar Singh | c29172e | 2017-04-12 14:26:47 +1000 | [diff] [blame] | 330 | rc = init_windows(context); |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 331 | if (rc) { |
| 332 | goto finish; |
| 333 | } |
| 334 | |
| 335 | rc = init_flash_dev(context); |
| 336 | if (rc) { |
| 337 | goto finish; |
| 338 | } |
| 339 | |
| 340 | rc = init_mboxd_dbus(context); |
| 341 | if (rc) { |
| 342 | goto finish; |
| 343 | } |
| 344 | |
| 345 | /* Set the LPC bus mapping to point to the physical flash device */ |
| 346 | rc = point_to_flash(context); |
| 347 | if (rc) { |
| 348 | goto finish; |
| 349 | } |
| 350 | |
| 351 | rc = set_bmc_events(context, BMC_EVENT_DAEMON_READY, SET_BMC_EVENT); |
| 352 | if (rc) { |
| 353 | goto finish; |
| 354 | } |
| 355 | |
Suraj Jitindar Singh | 2851959 | 2017-04-27 14:48:58 +1000 | [diff] [blame^] | 356 | MSG_INFO("Entering Polling Loop\n"); |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 357 | rc = poll_loop(context); |
| 358 | |
Suraj Jitindar Singh | 2851959 | 2017-04-27 14:48:58 +1000 | [diff] [blame^] | 359 | MSG_INFO("Exiting Poll Loop: %d\n", rc); |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 360 | |
| 361 | finish: |
Suraj Jitindar Singh | 2851959 | 2017-04-27 14:48:58 +1000 | [diff] [blame^] | 362 | MSG_INFO("Daemon Exiting...\n"); |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 363 | clr_bmc_events(context, BMC_EVENT_DAEMON_READY, SET_BMC_EVENT); |
| 364 | |
| 365 | free_mboxd_dbus(context); |
| 366 | free_flash_dev(context); |
| 367 | free_lpc_dev(context); |
| 368 | free_mbox_dev(context); |
Suraj Jitindar Singh | c29172e | 2017-04-12 14:26:47 +1000 | [diff] [blame] | 369 | free_windows(context); |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 370 | free(context); |
| 371 | |
| 372 | return rc; |
| 373 | } |