1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 /* Copyright (c) 2010-2012 Broadcom. All rights reserved. */ 3 4 #ifndef VCHIQ_CORE_H 5 #define VCHIQ_CORE_H 6 7 #include <linux/mutex.h> 8 #include <linux/completion.h> 9 #include <linux/kthread.h> 10 #include <linux/kref.h> 11 #include <linux/rcupdate.h> 12 #include <linux/wait.h> 13 #include <linux/raspberrypi/vchiq.h> 14 15 #include "vchiq_cfg.h" 16 17 18 /* Do this so that we can test-build the code on non-rpi systems */ 19 #if IS_ENABLED(CONFIG_RASPBERRYPI_FIRMWARE) 20 21 #else 22 23 #ifndef dsb 24 #define dsb(a) 25 #endif 26 27 #endif /* IS_ENABLED(CONFIG_RASPBERRYPI_FIRMWARE) */ 28 29 #define VCHIQ_SERVICE_HANDLE_INVALID 0 30 31 #define VCHIQ_SLOT_SIZE 4096 32 #define VCHIQ_MAX_MSG_SIZE (VCHIQ_SLOT_SIZE - sizeof(struct vchiq_header)) 33 34 /* Run time control of log level, based on KERN_XXX level. */ 35 #define VCHIQ_LOG_DEFAULT 4 36 #define VCHIQ_LOG_ERROR 3 37 #define VCHIQ_LOG_WARNING 4 38 #define VCHIQ_LOG_INFO 6 39 #define VCHIQ_LOG_TRACE 7 40 41 #define VCHIQ_LOG_PREFIX KERN_INFO "vchiq: " 42 43 #ifndef vchiq_log_error 44 #define vchiq_log_error(cat, fmt, ...) \ 45 do { if (cat >= VCHIQ_LOG_ERROR) \ 46 printk(VCHIQ_LOG_PREFIX fmt "\n", ##__VA_ARGS__); } while (0) 47 #endif 48 #ifndef vchiq_log_warning 49 #define vchiq_log_warning(cat, fmt, ...) \ 50 do { if (cat >= VCHIQ_LOG_WARNING) \ 51 printk(VCHIQ_LOG_PREFIX fmt "\n", ##__VA_ARGS__); } while (0) 52 #endif 53 #ifndef vchiq_log_info 54 #define vchiq_log_info(cat, fmt, ...) \ 55 do { if (cat >= VCHIQ_LOG_INFO) \ 56 printk(VCHIQ_LOG_PREFIX fmt "\n", ##__VA_ARGS__); } while (0) 57 #endif 58 #ifndef vchiq_log_trace 59 #define vchiq_log_trace(cat, fmt, ...) \ 60 do { if (cat >= VCHIQ_LOG_TRACE) \ 61 printk(VCHIQ_LOG_PREFIX fmt "\n", ##__VA_ARGS__); } while (0) 62 #endif 63 64 #define vchiq_loud_error(...) \ 65 vchiq_log_error(vchiq_core_log_level, "===== " __VA_ARGS__) 66 67 #ifndef vchiq_static_assert 68 #define vchiq_static_assert(cond) __attribute__((unused)) \ 69 extern int vchiq_static_assert[(cond) ? 1 : -1] 70 #endif 71 72 #define IS_POW2(x) (x && ((x & (x - 1)) == 0)) 73 74 /* Ensure that the slot size and maximum number of slots are powers of 2 */ 75 vchiq_static_assert(IS_POW2(VCHIQ_SLOT_SIZE)); 76 vchiq_static_assert(IS_POW2(VCHIQ_MAX_SLOTS)); 77 vchiq_static_assert(IS_POW2(VCHIQ_MAX_SLOTS_PER_SIDE)); 78 79 #define VCHIQ_SLOT_MASK (VCHIQ_SLOT_SIZE - 1) 80 #define VCHIQ_SLOT_QUEUE_MASK (VCHIQ_MAX_SLOTS_PER_SIDE - 1) 81 #define VCHIQ_SLOT_ZERO_SLOTS DIV_ROUND_UP(sizeof(struct vchiq_slot_zero), \ 82 VCHIQ_SLOT_SIZE) 83 84 #define VCHIQ_MSG_PADDING 0 /* - */ 85 #define VCHIQ_MSG_CONNECT 1 /* - */ 86 #define VCHIQ_MSG_OPEN 2 /* + (srcport, -), fourcc, client_id */ 87 #define VCHIQ_MSG_OPENACK 3 /* + (srcport, dstport) */ 88 #define VCHIQ_MSG_CLOSE 4 /* + (srcport, dstport) */ 89 #define VCHIQ_MSG_DATA 5 /* + (srcport, dstport) */ 90 #define VCHIQ_MSG_BULK_RX 6 /* + (srcport, dstport), data, size */ 91 #define VCHIQ_MSG_BULK_TX 7 /* + (srcport, dstport), data, size */ 92 #define VCHIQ_MSG_BULK_RX_DONE 8 /* + (srcport, dstport), actual */ 93 #define VCHIQ_MSG_BULK_TX_DONE 9 /* + (srcport, dstport), actual */ 94 #define VCHIQ_MSG_PAUSE 10 /* - */ 95 #define VCHIQ_MSG_RESUME 11 /* - */ 96 #define VCHIQ_MSG_REMOTE_USE 12 /* - */ 97 #define VCHIQ_MSG_REMOTE_RELEASE 13 /* - */ 98 #define VCHIQ_MSG_REMOTE_USE_ACTIVE 14 /* - */ 99 100 #define VCHIQ_PORT_MAX (VCHIQ_MAX_SERVICES - 1) 101 #define VCHIQ_PORT_FREE 0x1000 102 #define VCHIQ_PORT_IS_VALID(port) (port < VCHIQ_PORT_FREE) 103 #define VCHIQ_MAKE_MSG(type, srcport, dstport) \ 104 ((type<<24) | (srcport<<12) | (dstport<<0)) 105 #define VCHIQ_MSG_TYPE(msgid) ((unsigned int)msgid >> 24) 106 #define VCHIQ_MSG_SRCPORT(msgid) \ 107 (unsigned short)(((unsigned int)msgid >> 12) & 0xfff) 108 #define VCHIQ_MSG_DSTPORT(msgid) \ 109 ((unsigned short)msgid & 0xfff) 110 111 #define VCHIQ_FOURCC_AS_4CHARS(fourcc) \ 112 ((fourcc) >> 24) & 0xff, \ 113 ((fourcc) >> 16) & 0xff, \ 114 ((fourcc) >> 8) & 0xff, \ 115 (fourcc) & 0xff 116 117 /* Ensure the fields are wide enough */ 118 vchiq_static_assert(VCHIQ_MSG_SRCPORT(VCHIQ_MAKE_MSG(0, 0, VCHIQ_PORT_MAX)) 119 == 0); 120 vchiq_static_assert(VCHIQ_MSG_TYPE(VCHIQ_MAKE_MSG(0, VCHIQ_PORT_MAX, 0)) == 0); 121 vchiq_static_assert((unsigned int)VCHIQ_PORT_MAX < 122 (unsigned int)VCHIQ_PORT_FREE); 123 124 #define VCHIQ_MSGID_PADDING VCHIQ_MAKE_MSG(VCHIQ_MSG_PADDING, 0, 0) 125 #define VCHIQ_MSGID_CLAIMED 0x40000000 126 127 #define VCHIQ_FOURCC_INVALID 0x00000000 128 #define VCHIQ_FOURCC_IS_LEGAL(fourcc) (fourcc != VCHIQ_FOURCC_INVALID) 129 130 #define VCHIQ_BULK_ACTUAL_ABORTED -1 131 132 typedef uint32_t BITSET_T; 133 134 vchiq_static_assert((sizeof(BITSET_T) * 8) == 32); 135 136 #define BITSET_SIZE(b) ((b + 31) >> 5) 137 #define BITSET_WORD(b) (b >> 5) 138 #define BITSET_BIT(b) (1 << (b & 31)) 139 #define BITSET_IS_SET(bs, b) (bs[BITSET_WORD(b)] & BITSET_BIT(b)) 140 #define BITSET_SET(bs, b) (bs[BITSET_WORD(b)] |= BITSET_BIT(b)) 141 #define BITSET_CLR(bs, b) (bs[BITSET_WORD(b)] &= ~BITSET_BIT(b)) 142 143 #if VCHIQ_ENABLE_STATS 144 #define VCHIQ_STATS_INC(state, stat) (state->stats. stat++) 145 #define VCHIQ_SERVICE_STATS_INC(service, stat) (service->stats. stat++) 146 #define VCHIQ_SERVICE_STATS_ADD(service, stat, addend) \ 147 (service->stats. stat += addend) 148 #else 149 #define VCHIQ_STATS_INC(state, stat) ((void)0) 150 #define VCHIQ_SERVICE_STATS_INC(service, stat) ((void)0) 151 #define VCHIQ_SERVICE_STATS_ADD(service, stat, addend) ((void)0) 152 #endif 153 154 enum { 155 DEBUG_ENTRIES, 156 #if VCHIQ_ENABLE_DEBUG 157 DEBUG_SLOT_HANDLER_COUNT, 158 DEBUG_SLOT_HANDLER_LINE, 159 DEBUG_PARSE_LINE, 160 DEBUG_PARSE_HEADER, 161 DEBUG_PARSE_MSGID, 162 DEBUG_AWAIT_COMPLETION_LINE, 163 DEBUG_DEQUEUE_MESSAGE_LINE, 164 DEBUG_SERVICE_CALLBACK_LINE, 165 DEBUG_MSG_QUEUE_FULL_COUNT, 166 DEBUG_COMPLETION_QUEUE_FULL_COUNT, 167 #endif 168 DEBUG_MAX 169 }; 170 171 #if VCHIQ_ENABLE_DEBUG 172 173 #define DEBUG_INITIALISE(local) int *debug_ptr = (local)->debug; 174 #define DEBUG_TRACE(d) \ 175 do { debug_ptr[DEBUG_ ## d] = __LINE__; dsb(sy); } while (0) 176 #define DEBUG_VALUE(d, v) \ 177 do { debug_ptr[DEBUG_ ## d] = (v); dsb(sy); } while (0) 178 #define DEBUG_COUNT(d) \ 179 do { debug_ptr[DEBUG_ ## d]++; dsb(sy); } while (0) 180 181 #else /* VCHIQ_ENABLE_DEBUG */ 182 183 #define DEBUG_INITIALISE(local) 184 #define DEBUG_TRACE(d) 185 #define DEBUG_VALUE(d, v) 186 #define DEBUG_COUNT(d) 187 188 #endif /* VCHIQ_ENABLE_DEBUG */ 189 190 enum vchiq_connstate { 191 VCHIQ_CONNSTATE_DISCONNECTED, 192 VCHIQ_CONNSTATE_CONNECTING, 193 VCHIQ_CONNSTATE_CONNECTED, 194 VCHIQ_CONNSTATE_PAUSING, 195 VCHIQ_CONNSTATE_PAUSE_SENT, 196 VCHIQ_CONNSTATE_PAUSED, 197 VCHIQ_CONNSTATE_RESUMING, 198 VCHIQ_CONNSTATE_PAUSE_TIMEOUT, 199 VCHIQ_CONNSTATE_RESUME_TIMEOUT 200 }; 201 202 enum { 203 VCHIQ_SRVSTATE_FREE, 204 VCHIQ_SRVSTATE_HIDDEN, 205 VCHIQ_SRVSTATE_LISTENING, 206 VCHIQ_SRVSTATE_OPENING, 207 VCHIQ_SRVSTATE_OPEN, 208 VCHIQ_SRVSTATE_OPENSYNC, 209 VCHIQ_SRVSTATE_CLOSESENT, 210 VCHIQ_SRVSTATE_CLOSERECVD, 211 VCHIQ_SRVSTATE_CLOSEWAIT, 212 VCHIQ_SRVSTATE_CLOSED 213 }; 214 215 enum { 216 VCHIQ_POLL_TERMINATE, 217 VCHIQ_POLL_REMOVE, 218 VCHIQ_POLL_TXNOTIFY, 219 VCHIQ_POLL_RXNOTIFY, 220 VCHIQ_POLL_COUNT 221 }; 222 223 enum vchiq_bulk_dir { 224 VCHIQ_BULK_TRANSMIT, 225 VCHIQ_BULK_RECEIVE 226 }; 227 228 typedef void (*vchiq_userdata_term)(void *userdata); 229 230 struct vchiq_bulk { 231 short mode; 232 short dir; 233 void *userdata; 234 dma_addr_t data; 235 int size; 236 void *remote_data; 237 int remote_size; 238 int actual; 239 }; 240 241 struct vchiq_bulk_queue { 242 int local_insert; /* Where to insert the next local bulk */ 243 int remote_insert; /* Where to insert the next remote bulk (master) */ 244 int process; /* Bulk to transfer next */ 245 int remote_notify; /* Bulk to notify the remote client of next (mstr) */ 246 int remove; /* Bulk to notify the local client of, and remove, next */ 247 struct vchiq_bulk bulks[VCHIQ_NUM_SERVICE_BULKS]; 248 }; 249 250 struct remote_event { 251 int armed; 252 int fired; 253 u32 __unused; 254 }; 255 256 struct opaque_platform_state; 257 258 struct vchiq_slot { 259 char data[VCHIQ_SLOT_SIZE]; 260 }; 261 262 struct vchiq_slot_info { 263 /* Use two counters rather than one to avoid the need for a mutex. */ 264 short use_count; 265 short release_count; 266 }; 267 268 struct vchiq_service { 269 struct vchiq_service_base base; 270 unsigned int handle; 271 struct kref ref_count; 272 struct rcu_head rcu; 273 int srvstate; 274 vchiq_userdata_term userdata_term; 275 unsigned int localport; 276 unsigned int remoteport; 277 int public_fourcc; 278 int client_id; 279 char auto_close; 280 char sync; 281 char closing; 282 char trace; 283 atomic_t poll_flags; 284 short version; 285 short version_min; 286 short peer_version; 287 288 struct vchiq_state *state; 289 struct vchiq_instance *instance; 290 291 int service_use_count; 292 293 struct vchiq_bulk_queue bulk_tx; 294 struct vchiq_bulk_queue bulk_rx; 295 296 struct completion remove_event; 297 struct completion bulk_remove_event; 298 struct mutex bulk_mutex; 299 300 struct service_stats_struct { 301 int quota_stalls; 302 int slot_stalls; 303 int bulk_stalls; 304 int error_count; 305 int ctrl_tx_count; 306 int ctrl_rx_count; 307 int bulk_tx_count; 308 int bulk_rx_count; 309 int bulk_aborted_count; 310 uint64_t ctrl_tx_bytes; 311 uint64_t ctrl_rx_bytes; 312 uint64_t bulk_tx_bytes; 313 uint64_t bulk_rx_bytes; 314 } stats; 315 316 int msg_queue_read; 317 int msg_queue_write; 318 struct completion msg_queue_pop; 319 struct completion msg_queue_push; 320 struct vchiq_header *msg_queue[VCHIQ_MAX_SLOTS]; 321 }; 322 323 /* 324 * The quota information is outside struct vchiq_service so that it can 325 * be statically allocated, since for accounting reasons a service's slot 326 * usage is carried over between users of the same port number. 327 */ 328 struct vchiq_service_quota { 329 unsigned short slot_quota; 330 unsigned short slot_use_count; 331 unsigned short message_quota; 332 unsigned short message_use_count; 333 struct completion quota_event; 334 int previous_tx_index; 335 }; 336 337 struct vchiq_shared_state { 338 339 /* A non-zero value here indicates that the content is valid. */ 340 int initialised; 341 342 /* The first and last (inclusive) slots allocated to the owner. */ 343 int slot_first; 344 int slot_last; 345 346 /* The slot allocated to synchronous messages from the owner. */ 347 int slot_sync; 348 349 /* 350 * Signalling this event indicates that owner's slot handler thread 351 * should run. 352 */ 353 struct remote_event trigger; 354 355 /* 356 * Indicates the byte position within the stream where the next message 357 * will be written. The least significant bits are an index into the 358 * slot. The next bits are the index of the slot in slot_queue. 359 */ 360 int tx_pos; 361 362 /* This event should be signalled when a slot is recycled. */ 363 struct remote_event recycle; 364 365 /* The slot_queue index where the next recycled slot will be written. */ 366 int slot_queue_recycle; 367 368 /* This event should be signalled when a synchronous message is sent. */ 369 struct remote_event sync_trigger; 370 371 /* 372 * This event should be signalled when a synchronous message has been 373 * released. 374 */ 375 struct remote_event sync_release; 376 377 /* A circular buffer of slot indexes. */ 378 int slot_queue[VCHIQ_MAX_SLOTS_PER_SIDE]; 379 380 /* Debugging state */ 381 int debug[DEBUG_MAX]; 382 }; 383 384 struct vchiq_slot_zero { 385 int magic; 386 short version; 387 short version_min; 388 int slot_zero_size; 389 int slot_size; 390 int max_slots; 391 int max_slots_per_side; 392 int platform_data[2]; 393 struct vchiq_shared_state master; 394 struct vchiq_shared_state slave; 395 struct vchiq_slot_info slots[VCHIQ_MAX_SLOTS]; 396 }; 397 398 struct vchiq_state { 399 int id; 400 int initialised; 401 enum vchiq_connstate conn_state; 402 short version_common; 403 404 struct vchiq_shared_state *local; 405 struct vchiq_shared_state *remote; 406 struct vchiq_slot *slot_data; 407 408 unsigned short default_slot_quota; 409 unsigned short default_message_quota; 410 411 /* Event indicating connect message received */ 412 struct completion connect; 413 414 /* Mutex protecting services */ 415 struct mutex mutex; 416 struct vchiq_instance **instance; 417 418 /* Processes incoming messages */ 419 struct task_struct *slot_handler_thread; 420 421 /* Processes recycled slots */ 422 struct task_struct *recycle_thread; 423 424 /* Processes synchronous messages */ 425 struct task_struct *sync_thread; 426 427 /* Local implementation of the trigger remote event */ 428 wait_queue_head_t trigger_event; 429 430 /* Local implementation of the recycle remote event */ 431 wait_queue_head_t recycle_event; 432 433 /* Local implementation of the sync trigger remote event */ 434 wait_queue_head_t sync_trigger_event; 435 436 /* Local implementation of the sync release remote event */ 437 wait_queue_head_t sync_release_event; 438 439 char *tx_data; 440 char *rx_data; 441 struct vchiq_slot_info *rx_info; 442 443 struct mutex slot_mutex; 444 445 struct mutex recycle_mutex; 446 447 struct mutex sync_mutex; 448 449 struct mutex bulk_transfer_mutex; 450 451 /* 452 * Indicates the byte position within the stream from where the next 453 * message will be read. The least significant bits are an index into 454 * the slot.The next bits are the index of the slot in 455 * remote->slot_queue. 456 */ 457 int rx_pos; 458 459 /* 460 * A cached copy of local->tx_pos. Only write to local->tx_pos, and read 461 * from remote->tx_pos. 462 */ 463 int local_tx_pos; 464 465 /* The slot_queue index of the slot to become available next. */ 466 int slot_queue_available; 467 468 /* A flag to indicate if any poll has been requested */ 469 int poll_needed; 470 471 /* Ths index of the previous slot used for data messages. */ 472 int previous_data_index; 473 474 /* The number of slots occupied by data messages. */ 475 unsigned short data_use_count; 476 477 /* The maximum number of slots to be occupied by data messages. */ 478 unsigned short data_quota; 479 480 /* An array of bit sets indicating which services must be polled. */ 481 atomic_t poll_services[BITSET_SIZE(VCHIQ_MAX_SERVICES)]; 482 483 /* The number of the first unused service */ 484 int unused_service; 485 486 /* Signalled when a free slot becomes available. */ 487 struct completion slot_available_event; 488 489 struct completion slot_remove_event; 490 491 /* Signalled when a free data slot becomes available. */ 492 struct completion data_quota_event; 493 494 struct state_stats_struct { 495 int slot_stalls; 496 int data_stalls; 497 int ctrl_tx_count; 498 int ctrl_rx_count; 499 int error_count; 500 } stats; 501 502 struct vchiq_service __rcu *services[VCHIQ_MAX_SERVICES]; 503 struct vchiq_service_quota service_quotas[VCHIQ_MAX_SERVICES]; 504 struct vchiq_slot_info slot_info[VCHIQ_MAX_SLOTS]; 505 506 struct opaque_platform_state *platform_state; 507 }; 508 509 struct bulk_waiter { 510 struct vchiq_bulk *bulk; 511 struct completion event; 512 int actual; 513 }; 514 515 struct vchiq_config { 516 unsigned int max_msg_size; 517 unsigned int bulk_threshold; /* The message size above which it 518 * is better to use a bulk transfer 519 * (<= max_msg_size) 520 */ 521 unsigned int max_outstanding_bulks; 522 unsigned int max_services; 523 short version; /* The version of VCHIQ */ 524 short version_min; /* The minimum compatible version of VCHIQ */ 525 }; 526 527 528 extern spinlock_t bulk_waiter_spinlock; 529 530 extern int vchiq_core_log_level; 531 extern int vchiq_core_msg_log_level; 532 extern int vchiq_sync_log_level; 533 534 extern struct vchiq_state *vchiq_states[VCHIQ_MAX_STATES]; 535 536 extern const char * 537 get_conn_state_name(enum vchiq_connstate conn_state); 538 539 extern struct vchiq_slot_zero * 540 vchiq_init_slots(void *mem_base, int mem_size); 541 542 extern enum vchiq_status 543 vchiq_init_state(struct vchiq_state *state, struct vchiq_slot_zero *slot_zero); 544 545 extern enum vchiq_status 546 vchiq_connect_internal(struct vchiq_state *state, struct vchiq_instance *instance); 547 548 struct vchiq_service * 549 vchiq_add_service_internal(struct vchiq_state *state, 550 const struct vchiq_service_params_kernel *params, 551 int srvstate, struct vchiq_instance *instance, 552 vchiq_userdata_term userdata_term); 553 554 extern enum vchiq_status 555 vchiq_open_service_internal(struct vchiq_service *service, int client_id); 556 557 extern enum vchiq_status 558 vchiq_close_service_internal(struct vchiq_service *service, int close_recvd); 559 560 extern void 561 vchiq_terminate_service_internal(struct vchiq_service *service); 562 563 extern void 564 vchiq_free_service_internal(struct vchiq_service *service); 565 566 extern enum vchiq_status 567 vchiq_shutdown_internal(struct vchiq_state *state, struct vchiq_instance *instance); 568 569 extern void 570 remote_event_pollall(struct vchiq_state *state); 571 572 extern enum vchiq_status 573 vchiq_bulk_transfer(unsigned int handle, void *offset, void __user *uoffset, 574 int size, void *userdata, enum vchiq_bulk_mode mode, 575 enum vchiq_bulk_dir dir); 576 577 extern int 578 vchiq_dump_state(void *dump_context, struct vchiq_state *state); 579 580 extern int 581 vchiq_dump_service_state(void *dump_context, struct vchiq_service *service); 582 583 extern void 584 vchiq_loud_error_header(void); 585 586 extern void 587 vchiq_loud_error_footer(void); 588 589 extern void 590 request_poll(struct vchiq_state *state, struct vchiq_service *service, 591 int poll_type); 592 593 static inline struct vchiq_service * 594 handle_to_service(unsigned int handle) 595 { 596 int idx = handle & (VCHIQ_MAX_SERVICES - 1); 597 struct vchiq_state *state = vchiq_states[(handle / VCHIQ_MAX_SERVICES) & 598 (VCHIQ_MAX_STATES - 1)]; 599 600 if (!state) 601 return NULL; 602 return rcu_dereference(state->services[idx]); 603 } 604 605 extern struct vchiq_service * 606 find_service_by_handle(unsigned int handle); 607 608 extern struct vchiq_service * 609 find_service_by_port(struct vchiq_state *state, int localport); 610 611 extern struct vchiq_service * 612 find_service_for_instance(struct vchiq_instance *instance, 613 unsigned int handle); 614 615 extern struct vchiq_service * 616 find_closed_service_for_instance(struct vchiq_instance *instance, 617 unsigned int handle); 618 619 extern struct vchiq_service * 620 __next_service_by_instance(struct vchiq_state *state, 621 struct vchiq_instance *instance, 622 int *pidx); 623 624 extern struct vchiq_service * 625 next_service_by_instance(struct vchiq_state *state, 626 struct vchiq_instance *instance, 627 int *pidx); 628 629 extern void 630 lock_service(struct vchiq_service *service); 631 632 extern void 633 unlock_service(struct vchiq_service *service); 634 635 extern enum vchiq_status 636 vchiq_queue_message(unsigned int handle, 637 ssize_t (*copy_callback)(void *context, void *dest, 638 size_t offset, size_t maxsize), 639 void *context, 640 size_t size); 641 642 /* 643 * The following functions are called from vchiq_core, and external 644 * implementations must be provided. 645 */ 646 647 extern enum vchiq_status 648 vchiq_prepare_bulk_data(struct vchiq_bulk *bulk, void *offset, 649 void __user *uoffset, int size, int dir); 650 651 extern void 652 vchiq_complete_bulk(struct vchiq_bulk *bulk); 653 654 extern void 655 remote_event_signal(struct remote_event *event); 656 657 extern int 658 vchiq_dump(void *dump_context, const char *str, int len); 659 660 extern int 661 vchiq_dump_platform_state(void *dump_context); 662 663 extern int 664 vchiq_dump_platform_instances(void *dump_context); 665 666 extern int 667 vchiq_dump_platform_service_state(void *dump_context, 668 struct vchiq_service *service); 669 670 extern enum vchiq_status 671 vchiq_use_service_internal(struct vchiq_service *service); 672 673 extern enum vchiq_status 674 vchiq_release_service_internal(struct vchiq_service *service); 675 676 extern void 677 vchiq_on_remote_use(struct vchiq_state *state); 678 679 extern void 680 vchiq_on_remote_release(struct vchiq_state *state); 681 682 extern enum vchiq_status 683 vchiq_platform_init_state(struct vchiq_state *state); 684 685 extern enum vchiq_status 686 vchiq_check_service(struct vchiq_service *service); 687 688 extern void 689 vchiq_on_remote_use_active(struct vchiq_state *state); 690 691 extern enum vchiq_status 692 vchiq_send_remote_use(struct vchiq_state *state); 693 694 extern enum vchiq_status 695 vchiq_send_remote_use_active(struct vchiq_state *state); 696 697 extern void 698 vchiq_platform_conn_state_changed(struct vchiq_state *state, 699 enum vchiq_connstate oldstate, 700 enum vchiq_connstate newstate); 701 702 extern void 703 vchiq_set_conn_state(struct vchiq_state *state, enum vchiq_connstate newstate); 704 705 extern void 706 vchiq_log_dump_mem(const char *label, uint32_t addr, const void *voidMem, 707 size_t numBytes); 708 709 extern enum vchiq_status vchiq_remove_service(unsigned int service); 710 711 extern int vchiq_get_client_id(unsigned int service); 712 713 extern void vchiq_get_config(struct vchiq_config *config); 714 715 extern enum vchiq_status 716 vchiq_set_service_option(unsigned int service, enum vchiq_service_option option, 717 int value); 718 719 #endif 720