Lines Matching refs:context
53 static int poll_loop(struct mbox_context *context) in poll_loop() argument
59 context->fds[i].events = POLLIN; in poll_loop()
63 rc = poll(context->fds, POLL_FDS, -1); in poll_loop()
71 if (context->fds[SIG_FD].revents & POLLIN) { /* Signal */ in poll_loop()
74 rc = read(context->fds[SIG_FD].fd, (void *) &info, in poll_loop()
86 context->terminate = true; in poll_loop()
90 reset_all_windows(context, SET_BMC_EVENT); in poll_loop()
91 rc = reset_lpc(context); in poll_loop()
105 if (context->fds[DBUS_FD].revents & POLLIN) { /* DBUS */ in poll_loop()
106 while ((rc = sd_bus_process(context->bus, NULL)) > 0) { in poll_loop()
114 if (context->terminate) { in poll_loop()
117 if (context->fds[MBOX_FD].revents & POLLIN) { /* MBOX */ in poll_loop()
119 rc = dispatch_mbox(context); in poll_loop()
128 reset_all_windows(context, SET_BMC_EVENT); in poll_loop()
129 rc = reset_lpc(context); in poll_loop()
139 static int init_signals(struct mbox_context *context, sigset_t *set) in init_signals() argument
161 context->fds[SIG_FD].fd = rc; in init_signals()
171 struct mbox_context *context) in parse_cmdline() argument
190 context->current = NULL; /* No current window */ in parse_cmdline()
198 context->flash_size = strtol(optarg, &endptr, 10); in parse_cmdline()
207 context->flash_size <<= 10; in parse_cmdline()
209 context->flash_size <<= 10; in parse_cmdline()
218 context->windows.num = strtol(argv[optind], &endptr, in parse_cmdline()
226 context->windows.default_size = strtol(argv[optind], in parse_cmdline()
228 context->windows.default_size <<= 20; /* Given in MB */ in parse_cmdline()
234 if (!is_power_of_2(context->windows.default_size)) { in parse_cmdline()
259 if (!context->flash_size) { in parse_cmdline()
264 MSG_INFO("Flash size: 0x%.8x\n", context->flash_size); in parse_cmdline()
276 struct mbox_context *context; in main() local
281 context = calloc(1, sizeof(*context)); in main()
282 if (!context) { in main()
287 if (!parse_cmdline(argc, argv, context)) { in main()
289 free(context); in main()
294 context->fds[i].fd = -1; in main()
299 rc = init_signals(context, &set); in main()
304 rc = init_mbox_dev(context); in main()
309 rc = init_lpc_dev(context); in main()
315 rc = init_windows(context); in main()
320 rc = init_flash_dev(context); in main()
325 rc = init_mboxd_dbus(context); in main()
331 init_vpnor(context); in main()
335 rc = reset_lpc(context); in main()
340 rc = set_bmc_events(context, BMC_EVENT_DAEMON_READY, SET_BMC_EVENT); in main()
346 rc = poll_loop(context); in main()
352 clr_bmc_events(context, BMC_EVENT_DAEMON_READY, SET_BMC_EVENT); in main()
354 free_mboxd_dbus(context); in main()
355 free_flash_dev(context); in main()
356 free_lpc_dev(context); in main()
357 free_mbox_dev(context); in main()
358 free_windows(context); in main()
360 destroy_vpnor(context); in main()
362 free(context); in main()