Lines Matching refs:context
73 static inline int mbox_xlate_errno(struct mbox_context *context, in mbox_xlate_errno() argument
80 for(entry = errno_maps[context->version]; entry->rc != -1; entry++) { in mbox_xlate_errno()
96 static int transport_mbox_flush_events(struct mbox_context *context, uint8_t events) in transport_mbox_flush_events() argument
101 rc = lseek(context->fds[MBOX_FD].fd, MBOX_BMC_EVENT, SEEK_SET); in transport_mbox_flush_events()
109 rc = write(context->fds[MBOX_FD].fd, &events, 1); in transport_mbox_flush_events()
117 rc = lseek(context->fds[MBOX_FD].fd, 0, SEEK_SET); in transport_mbox_flush_events()
127 static int transport_mbox_put_events(struct mbox_context *context, in transport_mbox_put_events() argument
130 return transport_mbox_flush_events(context, context->bmc_events & mask); in transport_mbox_put_events()
133 static int transport_mbox_update_events(struct mbox_context *context, in transport_mbox_update_events() argument
137 return transport_mbox_flush_events(context, context->bmc_events & mask); in transport_mbox_update_events()
153 static int mbox_handle_reset(struct mbox_context *context, in mbox_handle_reset() argument
157 return context->protocol->reset(context); in mbox_handle_reset()
182 static int mbox_handle_mbox_info(struct mbox_context *context, in mbox_handle_mbox_info() argument
191 rc = context->protocol->get_info(context, &io); in mbox_handle_mbox_info()
200 context->transport = &transport_mbox_ops; in mbox_handle_mbox_info()
225 static int mbox_handle_flash_info(struct mbox_context *context, in mbox_handle_flash_info() argument
232 rc = context->protocol->get_flash_info(context, &io); in mbox_handle_flash_info()
237 switch (context->version) { in mbox_handle_flash_info()
262 static inline uint16_t get_lpc_addr_shifted(struct mbox_context *context) in get_lpc_addr_shifted() argument
267 mem_offset = context->current->mem - context->mem; in get_lpc_addr_shifted()
269 lpc_addr = context->lpc_base + mem_offset; in get_lpc_addr_shifted()
273 return lpc_addr >> context->backend.block_size_shift; in get_lpc_addr_shifted()
276 static int mbox_handle_create_window(struct mbox_context *context, bool ro, in mbox_handle_create_window() argument
285 rc = context->protocol->create_window(context, &io); in mbox_handle_create_window()
291 if (context->version >= API_VERSION_2) { in mbox_handle_create_window()
318 static int mbox_handle_read_window(struct mbox_context *context, in mbox_handle_read_window() argument
321 return mbox_handle_create_window(context, true, req, resp); in mbox_handle_read_window()
343 static int mbox_handle_write_window(struct mbox_context *context, in mbox_handle_write_window() argument
346 return mbox_handle_create_window(context, false, req, resp); in mbox_handle_write_window()
365 static int mbox_handle_dirty_window(struct mbox_context *context, in mbox_handle_dirty_window() argument
371 if (context->version == API_VERSION_1) { in mbox_handle_dirty_window()
379 return context->protocol->mark_dirty(context, &io); in mbox_handle_dirty_window()
395 static int mbox_handle_erase_window(struct mbox_context *context, in mbox_handle_erase_window() argument
404 if (!context->protocol->erase) { in mbox_handle_erase_window()
409 return context->protocol->erase(context, &io); in mbox_handle_erase_window()
429 static int mbox_handle_flush_window(struct mbox_context *context, in mbox_handle_flush_window() argument
435 if (context->version == API_VERSION_1) { in mbox_handle_flush_window()
440 return context->protocol->flush(context, &io); in mbox_handle_flush_window()
454 static int mbox_handle_close_window(struct mbox_context *context, in mbox_handle_close_window() argument
460 if (context->version >= API_VERSION_2) { in mbox_handle_close_window()
464 return context->protocol->close(context, &io); in mbox_handle_close_window()
473 static int mbox_handle_ack(struct mbox_context *context, union mbox_regs *req, in mbox_handle_ack() argument
480 return context->protocol->ack(context, &io); in mbox_handle_ack()
490 static int check_req_valid(struct mbox_context *context, union mbox_regs *req) in check_req_valid() argument
500 if (seq == context->prev_seq && cmd != MBOX_C_GET_MBOX_INFO) { in check_req_valid()
502 context->prev_seq); in check_req_valid()
506 if (context->state & STATE_SUSPENDED) { in check_req_valid()
514 if (context->transport != &transport_mbox_ops) { in check_req_valid()
522 if (!(context->state & MAPS_MEM)) { in check_req_valid()
556 static int handle_mbox_req(struct mbox_context *context, union mbox_regs *req) in handle_mbox_req() argument
558 const struct transport_ops *old_transport = context->transport; in handle_mbox_req()
569 rc = check_req_valid(context, req); in handle_mbox_req()
575 rc = handler(context, req, &resp); in handle_mbox_req()
582 rc = mbox_xlate_errno(context, rc); in handle_mbox_req()
584 context->prev_seq = req->msg.seq; in handle_mbox_req()
593 len = write(context->fds[MBOX_FD].fd, &resp, sizeof(resp)); in handle_mbox_req()
599 if (context->transport != old_transport && in handle_mbox_req()
600 context->transport == &transport_mbox_ops) { in handle_mbox_req()
602 protocol_events_set(context, context->bmc_events); in handle_mbox_req()
615 static int get_message(struct mbox_context *context, union mbox_regs *msg) in get_message() argument
619 rc = read(context->fds[MBOX_FD].fd, msg, sizeof(msg->raw)); in get_message()
644 int transport_mbox_dispatch(struct mbox_context *context) in transport_mbox_dispatch() argument
649 assert(context); in transport_mbox_dispatch()
651 rc = get_message(context, &req); in transport_mbox_dispatch()
656 return handle_mbox_req(context, &req); in transport_mbox_dispatch()
659 int __transport_mbox_init(struct mbox_context *context, const char *path, in __transport_mbox_init() argument
673 context->fds[MBOX_FD].fd = fd; in __transport_mbox_init()
682 int transport_mbox_init(struct mbox_context *context, in transport_mbox_init() argument
687 rc = __transport_mbox_init(context, MBOX_HOST_PATH, ops); in transport_mbox_init()
694 void transport_mbox_free(struct mbox_context *context) in transport_mbox_free() argument
696 close(context->fds[MBOX_FD].fd); in transport_mbox_free()