-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: popcornmix <[email protected]> vchiq: create_pagelist copes with vmalloc memory Signed-off-by: Daniel Stone <[email protected]> vchiq: fix the shim message release Signed-off-by: Daniel Stone <[email protected]> vchiq: export additional symbols Signed-off-by: Daniel Stone <[email protected]> VCHIQ: Make service closure fully synchronous (drv) This is one half of a two-part patch, the other half of which is to the vchiq_lib user library. With these patches, calls to vchiq_close_service and vchiq_remove_service won't return until any associated callbacks have been delivered to the callback thread. VCHIQ: Add per-service tracing The new service option VCHIQ_SERVICE_OPTION_TRACE is a boolean that toggles tracing for the specified service. This commit also introduces vchi_service_set_option and the associated option VCHI_SERVICE_OPTION_TRACE. vchiq: Make the synchronous-CLOSE logic more tolerant vchiq: Move logging control into debugfs vchiq: Take care of a corner case tickled by VCSM Closing a connection that isn't fully open requires care, since one side does not know the other side's port number. Code was present to handle the case where a CLOSE is sent immediately after an OPEN, i.e. before the OPENACK has been received, but this was incorrectly being used when an OPEN from a client using port 0 was rejected. (In the observed failure, the host was attempting to use the VCSM service, which isn't present in the 'cutdown' firmware. The failure was intermittent because sometimes the keepalive service would grab port 0.) This case can be distinguished because the client's remoteport will still be VCHIQ_PORT_FREE, and the srvstate will be OPENING. Either condition is sufficient to differentiate it from the special case described above. vchiq: Avoid high load when blocked and unkillable vchiq: Include SIGSTOP and SIGCONT in list of signals not-masked by vchiq to allow gdb to work vchiq_arm: Complete support for SYNCHRONOUS mode vchiq: Remove inline from suspend/resume vchiq: Allocation does not need to be atomic vchiq: Fix wrong condition check The log level is checked from within the log call. Remove the check in the call. Signed-off-by: Pranith Kumar <[email protected]> BCM270x: Add vchiq device to platform file and Device Tree Prepare to turn the vchiq module into a driver. Signed-off-by: Noralf Trønnes <[email protected]> bcm2708: vchiq: Add Device Tree support Turn vchiq into a driver and stop hardcoding resources. Use devm_* functions in probe path to simplify cleanup. A global variable is used to hold the register address. This is done to keep this patch as small as possible. Also make available on ARCH_BCM2835. Based on work by Lubomir Rintel. Signed-off-by: Noralf Trønnes <[email protected]> vchiq: Change logging level for inbound data vchiq_arm: Two cacheing fixes 1) Make fragment size vary with cache line size Without this patch, non-cache-line-aligned transfers may corrupt (or be corrupted by) adjacent data structures. Both ARM and VC need to be updated to enable this feature. This is ensured by having the loader apply a new DT parameter - cache-line-size. The existence of this parameter guarantees that the kernel is capable, and the parameter will only be modified from the safe default if the loader is capable. 2) Flush/invalidate vmalloc'd memory, and invalidate after reads vchiq: fix NULL pointer dereference when closing driver The following code run as root will cause a null pointer dereference oops: int fd = open("/dev/vc-cma", O_RDONLY); if (fd < 0) err(1, "open failed"); (void)close(fd); [ 1704.877721] Unable to handle kernel NULL pointer dereference at virtual address 00000000 [ 1704.877725] pgd = b899c000 [ 1704.877736] [00000000] *pgd=37fab831, *pte=00000000, *ppte=00000000 [ 1704.877748] Internal error: Oops: 817 [#1] PREEMPT SMP ARM [ 1704.877765] Modules linked in: evdev i2c_bcm2708 uio_pdrv_genirq uio [ 1704.877774] CPU: 2 PID: 3656 Comm: stress-ng-fstat Not tainted 3.19.1-12-generic-bcm2709 #12-Ubuntu [ 1704.877777] Hardware name: BCM2709 [ 1704.877783] task: b8ab9b00 ti: b7e68000 task.ti: b7e68000 [ 1704.877798] PC is at __down_interruptible+0x50/0xec [ 1704.877806] LR is at down_interruptible+0x5c/0x68 [ 1704.877813] pc : [<80630ee8>] lr : [<800704b0>] psr: 60080093 sp : b7e69e50 ip : b7e69e88 fp : b7e69e84 [ 1704.877817] r10: b88123c8 r9 : 00000010 r8 : 00000001 [ 1704.877822] r7 : b8ab9b00 r6 : 7fffffff r5 : 80a1cc34 r4 : 80a1cc34 [ 1704.877826] r3 : b7e69e50 r2 : 00000000 r1 : 00000000 r0 : 80a1cc34 [ 1704.877833] Flags: nZCv IRQs off FIQs on Mode SVC_32 ISA ARM Segment user [ 1704.877838] Control: 10c5387d Table: 3899c06a DAC: 00000015 [ 1704.877843] Process do-oops (pid: 3656, stack limit = 0xb7e68238) [ 1704.877848] Stack: (0xb7e69e50 to 0xb7e6a000) [ 1704.877856] 9e40: 80a1cc3c 00000000 00000010 b88123c8 [ 1704.877865] 9e60: b7e69e84 80a1cc34 fff9fee9 ffffffff b7e68000 00000009 b7e69ea4 b7e69e88 [ 1704.877874] 9e80: 800704b0 80630ea4 fff9fee9 60080013 80a1cc28 fff9fee9 b7e69edc b7e69ea8 [ 1704.877884] 9ea0: 8040f558 80070460 fff9fee9 ffffffff 00000000 00000000 00000009 80a1cb7c [ 1704.877893] 9ec0: 00000000 80a1cb7c 00000000 00000010 b7e69ef4 b7e69ee0 803e1ba4 8040f514 [ 1704.877902] 9ee0: 00000e48 80a1cb7c b7e69f14 b7e69ef8 803e1c9c 803e1b74 b88123c0 b92acb18 [ 1704.877911] 9f00: b8812790 b8d815d8 b7e69f24 b7e69f18 803e2250 803e1bc8 b7e69f5c b7e69f28 [ 1704.877921] 9f20: 80167bac 803e222c 00000000 00000000 b7e69f54 b8ab9ffc 00000000 8098c794 [ 1704.877930] 9f40: b8ab9b00 8000efc4 b7e68000 00000000 b7e69f6c b7e69f60 80167d6c 80167b28 [ 1704.877939] 9f60: b7e69f8c b7e69f70 80047d38 80167d60 b7e68000 b7e68010 8000efc4 b7e69fb0 [ 1704.877949] 9f80: b7e69fac b7e69f90 80012820 80047c84 01155490 011549a8 00000001 00000006 [ 1704.877957] 9fa0: 00000000 b7e69fb0 8000ee5c 80012790 00000000 353d8c0f 7efc4308 00000000 [ 1704.877966] 9fc0: 01155490 011549a8 00000001 00000006 00000000 00000000 76cf3ba0 00000003 [ 1704.877975] 9fe0: 00000000 7efc42e4 0002272f 76e2ed66 60080030 00000003 00000000 00000000 [ 1704.877998] [<80630ee8>] (__down_interruptible) from [<800704b0>] (down_interruptible+0x5c/0x68) [ 1704.878015] [<800704b0>] (down_interruptible) from [<8040f558>] (vchiu_queue_push+0x50/0xd8) [ 1704.878032] [<8040f558>] (vchiu_queue_push) from [<803e1ba4>] (send_worker_msg+0x3c/0x54) [ 1704.878045] [<803e1ba4>] (send_worker_msg) from [<803e1c9c>] (vc_cma_set_reserve+0xe0/0x1c4) [ 1704.878057] [<803e1c9c>] (vc_cma_set_reserve) from [<803e2250>] (vc_cma_release+0x30/0x38) [ 1704.878069] [<803e2250>] (vc_cma_release) from [<80167bac>] (__fput+0x90/0x1e0) [ 1704.878082] [<80167bac>] (__fput) from [<80167d6c>] (____fput+0x18/0x1c) [ 1704.878094] [<80167d6c>] (____fput) from [<80047d38>] (task_work_run+0xc0/0xf8) [ 1704.878109] [<80047d38>] (task_work_run) from [<80012820>] (do_work_pending+0x9c/0xc4) [ 1704.878123] [<80012820>] (do_work_pending) from [<8000ee5c>] (work_pending+0xc/0x20) [ 1704.878133] Code: e50b1034 e3a01000 e50b2030 e580300c (e5823000) ..the fix is to ensure that we have actually initialized the queue before we attempt to push any items onto it. This occurs if we do an open() followed by a close() without any activity in between. Signed-off-by: Colin Ian King <[email protected]> vchiq_arm: Sort out the vmalloc case See: #1055 vchiq: hack: Add include depecated dma include file vchiq_arm: Tweak the logging output Signed-off-by: Phil Elwell <[email protected]> vchiq_arm: Access the dequeue_pending flag locked Reading through this code looking for another problem (now found in userland) the use of dequeue_pending outside a lock didn't seem safe. Signed-off-by: Phil Elwell <[email protected]> vchiq_arm: Service callbacks must not fail Service callbacks are not allowed to return an error. The internal callback that delivers events and messages to user tasks does not enqueue them if the service is closing, but this is not an error and should not be reported as such. Signed-off-by: Phil Elwell <[email protected]> vchiq_arm: do not use page_cache_release(page) macro (#1403) This macro is gone since 1fa64f1. Signed-off-by: Slawomir Stepien <[email protected]> vchiq: Upate to match get_user_pages prototype vchiq_arm: Add completion records under the mutex An issue was observed when flushing openmax components which generate a large number of messages returning buffers to host. We occasionally found a duplicate message from 16 messages prior, resulting in a buffer returned twice. While only one thread adds completions, without the mutex you don't get the protection of the automatic memory barrier you get with synchronisation objects. Signed-off-by: Phil Elwell <[email protected]>
- Loading branch information
1 parent
fd23e9d
commit 11380ab
Showing
37 changed files
with
12,836 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
config BCM2708_VCHIQ | ||
tristate "Videocore VCHIQ" | ||
depends on RASPBERRYPI_FIRMWARE | ||
default y | ||
help | ||
Kernel to VideoCore communication interface for the | ||
BCM2708 family of products. | ||
Defaults to Y when the Broadcom Videocore services | ||
are included in the build, N otherwise. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
obj-$(CONFIG_BCM2708_VCHIQ) += vchiq.o | ||
|
||
vchiq-objs := \ | ||
interface/vchiq_arm/vchiq_core.o \ | ||
interface/vchiq_arm/vchiq_arm.o \ | ||
interface/vchiq_arm/vchiq_kern_lib.o \ | ||
interface/vchiq_arm/vchiq_2835_arm.o \ | ||
interface/vchiq_arm/vchiq_debugfs.o \ | ||
interface/vchiq_arm/vchiq_shim.o \ | ||
interface/vchiq_arm/vchiq_util.o \ | ||
interface/vchiq_arm/vchiq_connected.o \ | ||
|
||
ccflags-y += -DVCOS_VERIFY_BKPTS=1 -Idrivers/misc/vc04_services -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 | ||
|
328 changes: 328 additions & 0 deletions
328
drivers/misc/vc04_services/interface/vchi/connections/connection.h
Large diffs are not rendered by default.
Oops, something went wrong.
204 changes: 204 additions & 0 deletions
204
drivers/misc/vc04_services/interface/vchi/message_drivers/message.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
/** | ||
* Copyright (c) 2010-2012 Broadcom. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions, and the following disclaimer, | ||
* without modification. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. The names of the above-listed copyright holders may not be used | ||
* to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* ALTERNATIVELY, this software may be distributed under the terms of the | ||
* GNU General Public License ("GPL") version 2, as published by the Free | ||
* Software Foundation. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef _VCHI_MESSAGE_H_ | ||
#define _VCHI_MESSAGE_H_ | ||
|
||
#include <linux/kernel.h> | ||
#include <linux/types.h> | ||
#include <linux/semaphore.h> | ||
|
||
#include "interface/vchi/vchi_cfg_internal.h" | ||
#include "interface/vchi/vchi_common.h" | ||
|
||
|
||
typedef enum message_event_type { | ||
MESSAGE_EVENT_NONE, | ||
MESSAGE_EVENT_NOP, | ||
MESSAGE_EVENT_MESSAGE, | ||
MESSAGE_EVENT_SLOT_COMPLETE, | ||
MESSAGE_EVENT_RX_BULK_PAUSED, | ||
MESSAGE_EVENT_RX_BULK_COMPLETE, | ||
MESSAGE_EVENT_TX_COMPLETE, | ||
MESSAGE_EVENT_MSG_DISCARDED | ||
} MESSAGE_EVENT_TYPE_T; | ||
|
||
typedef enum vchi_msg_flags | ||
{ | ||
VCHI_MSG_FLAGS_NONE = 0x0, | ||
VCHI_MSG_FLAGS_TERMINATE_DMA = 0x1 | ||
} VCHI_MSG_FLAGS_T; | ||
|
||
typedef enum message_tx_channel | ||
{ | ||
MESSAGE_TX_CHANNEL_MESSAGE = 0, | ||
MESSAGE_TX_CHANNEL_BULK = 1 // drivers may provide multiple bulk channels, from 1 upwards | ||
} MESSAGE_TX_CHANNEL_T; | ||
|
||
// Macros used for cycling through bulk channels | ||
#define MESSAGE_TX_CHANNEL_BULK_PREV(c) (MESSAGE_TX_CHANNEL_BULK+((c)-MESSAGE_TX_CHANNEL_BULK+VCHI_MAX_BULK_TX_CHANNELS_PER_CONNECTION-1)%VCHI_MAX_BULK_TX_CHANNELS_PER_CONNECTION) | ||
#define MESSAGE_TX_CHANNEL_BULK_NEXT(c) (MESSAGE_TX_CHANNEL_BULK+((c)-MESSAGE_TX_CHANNEL_BULK+1)%VCHI_MAX_BULK_TX_CHANNELS_PER_CONNECTION) | ||
|
||
typedef enum message_rx_channel | ||
{ | ||
MESSAGE_RX_CHANNEL_MESSAGE = 0, | ||
MESSAGE_RX_CHANNEL_BULK = 1 // drivers may provide multiple bulk channels, from 1 upwards | ||
} MESSAGE_RX_CHANNEL_T; | ||
|
||
// Message receive slot information | ||
typedef struct rx_msg_slot_info { | ||
|
||
struct rx_msg_slot_info *next; | ||
//struct slot_info *prev; | ||
#if !defined VCHI_COARSE_LOCKING | ||
struct semaphore sem; | ||
#endif | ||
|
||
uint8_t *addr; // base address of slot | ||
uint32_t len; // length of slot in bytes | ||
|
||
uint32_t write_ptr; // hardware causes this to advance | ||
uint32_t read_ptr; // this module does the reading | ||
int active; // is this slot in the hardware dma fifo? | ||
uint32_t msgs_parsed; // count how many messages are in this slot | ||
uint32_t msgs_released; // how many messages have been released | ||
void *state; // connection state information | ||
uint8_t ref_count[VCHI_MAX_SERVICES_PER_CONNECTION]; // reference count for slots held by services | ||
} RX_MSG_SLOTINFO_T; | ||
|
||
// The message driver no longer needs to know about the fields of RX_BULK_SLOTINFO_T - sort this out. | ||
// In particular, it mustn't use addr and len - they're the client buffer, but the message | ||
// driver will be tasked with sending the aligned core section. | ||
typedef struct rx_bulk_slotinfo_t { | ||
struct rx_bulk_slotinfo_t *next; | ||
|
||
struct semaphore *blocking; | ||
|
||
// needed by DMA | ||
void *addr; | ||
uint32_t len; | ||
|
||
// needed for the callback | ||
void *service; | ||
void *handle; | ||
VCHI_FLAGS_T flags; | ||
} RX_BULK_SLOTINFO_T; | ||
|
||
|
||
/* ---------------------------------------------------------------------- | ||
* each connection driver will have a pool of the following struct. | ||
* | ||
* the pool will be managed by vchi_qman_* | ||
* this means there will be multiple queues (single linked lists) | ||
* a given struct message_info will be on exactly one of these queues | ||
* at any one time | ||
* -------------------------------------------------------------------- */ | ||
typedef struct rx_message_info { | ||
|
||
struct message_info *next; | ||
//struct message_info *prev; | ||
|
||
uint8_t *addr; | ||
uint32_t len; | ||
RX_MSG_SLOTINFO_T *slot; // points to whichever slot contains this message | ||
uint32_t tx_timestamp; | ||
uint32_t rx_timestamp; | ||
|
||
} RX_MESSAGE_INFO_T; | ||
|
||
typedef struct { | ||
MESSAGE_EVENT_TYPE_T type; | ||
|
||
struct { | ||
// for messages | ||
void *addr; // address of message | ||
uint16_t slot_delta; // whether this message indicated slot delta | ||
uint32_t len; // length of message | ||
RX_MSG_SLOTINFO_T *slot; // slot this message is in | ||
int32_t service; // service id this message is destined for | ||
uint32_t tx_timestamp; // timestamp from the header | ||
uint32_t rx_timestamp; // timestamp when we parsed it | ||
} message; | ||
|
||
// FIXME: cleanup slot reporting... | ||
RX_MSG_SLOTINFO_T *rx_msg; | ||
RX_BULK_SLOTINFO_T *rx_bulk; | ||
void *tx_handle; | ||
MESSAGE_TX_CHANNEL_T tx_channel; | ||
|
||
} MESSAGE_EVENT_T; | ||
|
||
|
||
// callbacks | ||
typedef void VCHI_MESSAGE_DRIVER_EVENT_CALLBACK_T( void *state ); | ||
|
||
typedef struct { | ||
VCHI_MESSAGE_DRIVER_EVENT_CALLBACK_T *event_callback; | ||
} VCHI_MESSAGE_DRIVER_OPEN_T; | ||
|
||
|
||
// handle to this instance of message driver (as returned by ->open) | ||
typedef struct opaque_mhandle_t *VCHI_MDRIVER_HANDLE_T; | ||
|
||
struct opaque_vchi_message_driver_t { | ||
VCHI_MDRIVER_HANDLE_T *(*open)( VCHI_MESSAGE_DRIVER_OPEN_T *params, void *state ); | ||
int32_t (*suspending)( VCHI_MDRIVER_HANDLE_T *handle ); | ||
int32_t (*resumed)( VCHI_MDRIVER_HANDLE_T *handle ); | ||
int32_t (*power_control)( VCHI_MDRIVER_HANDLE_T *handle, MESSAGE_TX_CHANNEL_T, int32_t enable ); | ||
int32_t (*add_msg_rx_slot)( VCHI_MDRIVER_HANDLE_T *handle, RX_MSG_SLOTINFO_T *slot ); // rx message | ||
int32_t (*add_bulk_rx)( VCHI_MDRIVER_HANDLE_T *handle, void *data, uint32_t len, RX_BULK_SLOTINFO_T *slot ); // rx data (bulk) | ||
int32_t (*send)( VCHI_MDRIVER_HANDLE_T *handle, MESSAGE_TX_CHANNEL_T channel, const void *data, uint32_t len, VCHI_MSG_FLAGS_T flags, void *send_handle ); // tx (message & bulk) | ||
void (*next_event)( VCHI_MDRIVER_HANDLE_T *handle, MESSAGE_EVENT_T *event ); // get the next event from message_driver | ||
int32_t (*enable)( VCHI_MDRIVER_HANDLE_T *handle ); | ||
int32_t (*form_message)( VCHI_MDRIVER_HANDLE_T *handle, int32_t service_id, VCHI_MSG_VECTOR_T *vector, uint32_t count, void | ||
*address, uint32_t length_avail, uint32_t max_total_length, int32_t pad_to_fill, int32_t allow_partial ); | ||
|
||
int32_t (*update_message)( VCHI_MDRIVER_HANDLE_T *handle, void *dest, int16_t *slot_count ); | ||
int32_t (*buffer_aligned)( VCHI_MDRIVER_HANDLE_T *handle, int tx, int uncached, const void *address, const uint32_t length ); | ||
void * (*allocate_buffer)( VCHI_MDRIVER_HANDLE_T *handle, uint32_t *length ); | ||
void (*free_buffer)( VCHI_MDRIVER_HANDLE_T *handle, void *address ); | ||
int (*rx_slot_size)( VCHI_MDRIVER_HANDLE_T *handle, int msg_size ); | ||
int (*tx_slot_size)( VCHI_MDRIVER_HANDLE_T *handle, int msg_size ); | ||
|
||
int32_t (*tx_supports_terminate)( const VCHI_MDRIVER_HANDLE_T *handle, MESSAGE_TX_CHANNEL_T channel ); | ||
uint32_t (*tx_bulk_chunk_size)( const VCHI_MDRIVER_HANDLE_T *handle, MESSAGE_TX_CHANNEL_T channel ); | ||
int (*tx_alignment)( const VCHI_MDRIVER_HANDLE_T *handle, MESSAGE_TX_CHANNEL_T channel ); | ||
int (*rx_alignment)( const VCHI_MDRIVER_HANDLE_T *handle, MESSAGE_RX_CHANNEL_T channel ); | ||
void (*form_bulk_aux)( VCHI_MDRIVER_HANDLE_T *handle, MESSAGE_TX_CHANNEL_T channel, const void *data, uint32_t len, uint32_t chunk_size, const void **aux_data, int32_t *aux_len ); | ||
void (*debug)( VCHI_MDRIVER_HANDLE_T *handle ); | ||
}; | ||
|
||
|
||
#endif // _VCHI_MESSAGE_H_ | ||
|
||
/****************************** End of file ***********************************/ |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,224 @@ | ||
/** | ||
* Copyright (c) 2010-2012 Broadcom. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions, and the following disclaimer, | ||
* without modification. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. The names of the above-listed copyright holders may not be used | ||
* to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* ALTERNATIVELY, this software may be distributed under the terms of the | ||
* GNU General Public License ("GPL") version 2, as published by the Free | ||
* Software Foundation. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef VCHI_CFG_H_ | ||
#define VCHI_CFG_H_ | ||
|
||
/**************************************************************************************** | ||
* Defines in this first section are part of the VCHI API and may be examined by VCHI | ||
* services. | ||
***************************************************************************************/ | ||
|
||
/* Required alignment of base addresses for bulk transfer, if unaligned transfers are not enabled */ | ||
/* Really determined by the message driver, and should be available from a run-time call. */ | ||
#ifndef VCHI_BULK_ALIGN | ||
# if __VCCOREVER__ >= 0x04000000 | ||
# define VCHI_BULK_ALIGN 32 // Allows for the need to do cache cleans | ||
# else | ||
# define VCHI_BULK_ALIGN 16 | ||
# endif | ||
#endif | ||
|
||
/* Required length multiple for bulk transfers, if unaligned transfers are not enabled */ | ||
/* May be less than or greater than VCHI_BULK_ALIGN */ | ||
/* Really determined by the message driver, and should be available from a run-time call. */ | ||
#ifndef VCHI_BULK_GRANULARITY | ||
# if __VCCOREVER__ >= 0x04000000 | ||
# define VCHI_BULK_GRANULARITY 32 // Allows for the need to do cache cleans | ||
# else | ||
# define VCHI_BULK_GRANULARITY 16 | ||
# endif | ||
#endif | ||
|
||
/* The largest possible message to be queued with vchi_msg_queue. */ | ||
#ifndef VCHI_MAX_MSG_SIZE | ||
# if defined VCHI_LOCAL_HOST_PORT | ||
# define VCHI_MAX_MSG_SIZE 16384 // makes file transfers fast, but should they be using bulk? | ||
# else | ||
# define VCHI_MAX_MSG_SIZE 4096 // NOTE: THIS MUST BE LARGER THAN OR EQUAL TO THE SIZE OF THE KHRONOS MERGE BUFFER!! | ||
# endif | ||
#endif | ||
|
||
/****************************************************************************************** | ||
* Defines below are system configuration options, and should not be used by VCHI services. | ||
*****************************************************************************************/ | ||
|
||
/* How many connections can we support? A localhost implementation uses 2 connections, | ||
* 1 for host-app, 1 for VMCS, and these are hooked together by a loopback MPHI VCFW | ||
* driver. */ | ||
#ifndef VCHI_MAX_NUM_CONNECTIONS | ||
# define VCHI_MAX_NUM_CONNECTIONS 3 | ||
#endif | ||
|
||
/* How many services can we open per connection? Extending this doesn't cost processing time, just a small | ||
* amount of static memory. */ | ||
#ifndef VCHI_MAX_SERVICES_PER_CONNECTION | ||
# define VCHI_MAX_SERVICES_PER_CONNECTION 36 | ||
#endif | ||
|
||
/* Adjust if using a message driver that supports more logical TX channels */ | ||
#ifndef VCHI_MAX_BULK_TX_CHANNELS_PER_CONNECTION | ||
# define VCHI_MAX_BULK_TX_CHANNELS_PER_CONNECTION 9 // 1 MPHI + 8 CCP2 logical channels | ||
#endif | ||
|
||
/* Adjust if using a message driver that supports more logical RX channels */ | ||
#ifndef VCHI_MAX_BULK_RX_CHANNELS_PER_CONNECTION | ||
# define VCHI_MAX_BULK_RX_CHANNELS_PER_CONNECTION 1 // 1 MPHI | ||
#endif | ||
|
||
/* How many receive slots do we use. This times VCHI_MAX_MSG_SIZE gives the effective | ||
* receive queue space, less message headers. */ | ||
#ifndef VCHI_NUM_READ_SLOTS | ||
# if defined(VCHI_LOCAL_HOST_PORT) | ||
# define VCHI_NUM_READ_SLOTS 4 | ||
# else | ||
# define VCHI_NUM_READ_SLOTS 48 | ||
# endif | ||
#endif | ||
|
||
/* Do we utilise overrun facility for receive message slots? Can aid peer transmit | ||
* performance. Only define on VideoCore end, talking to host. | ||
*/ | ||
//#define VCHI_MSG_RX_OVERRUN | ||
|
||
/* How many transmit slots do we use. Generally don't need many, as the hardware driver | ||
* underneath VCHI will usually have its own buffering. */ | ||
#ifndef VCHI_NUM_WRITE_SLOTS | ||
# define VCHI_NUM_WRITE_SLOTS 4 | ||
#endif | ||
|
||
/* If a service has held or queued received messages in VCHI_XOFF_THRESHOLD or more slots, | ||
* then it's taking up too much buffer space, and the peer service will be told to stop | ||
* transmitting with an XOFF message. For this to be effective, the VCHI_NUM_READ_SLOTS | ||
* needs to be considerably bigger than VCHI_NUM_WRITE_SLOTS, or the transmit latency | ||
* is too high. */ | ||
#ifndef VCHI_XOFF_THRESHOLD | ||
# define VCHI_XOFF_THRESHOLD (VCHI_NUM_READ_SLOTS / 2) | ||
#endif | ||
|
||
/* After we've sent an XOFF, the peer will be told to resume transmission once the local | ||
* service has dequeued/released enough messages that it's now occupying | ||
* VCHI_XON_THRESHOLD slots or fewer. */ | ||
#ifndef VCHI_XON_THRESHOLD | ||
# define VCHI_XON_THRESHOLD (VCHI_NUM_READ_SLOTS / 4) | ||
#endif | ||
|
||
/* A size below which a bulk transfer omits the handshake completely and always goes | ||
* via the message channel, if bulk auxiliary is being sent on that service. (The user | ||
* can guarantee this by enabling unaligned transmits). | ||
* Not API. */ | ||
#ifndef VCHI_MIN_BULK_SIZE | ||
# define VCHI_MIN_BULK_SIZE ( VCHI_MAX_MSG_SIZE / 2 < 4096 ? VCHI_MAX_MSG_SIZE / 2 : 4096 ) | ||
#endif | ||
|
||
/* Maximum size of bulk transmission chunks, for each interface type. A trade-off between | ||
* speed and latency; the smaller the chunk size the better change of messages and other | ||
* bulk transmissions getting in when big bulk transfers are happening. Set to 0 to not | ||
* break transmissions into chunks. | ||
*/ | ||
#ifndef VCHI_MAX_BULK_CHUNK_SIZE_MPHI | ||
# define VCHI_MAX_BULK_CHUNK_SIZE_MPHI (16 * 1024) | ||
#endif | ||
|
||
/* NB Chunked CCP2 transmissions violate the letter of the CCP2 spec by using "JPEG8" mode | ||
* with multiple-line frames. Only use if the receiver can cope. */ | ||
#ifndef VCHI_MAX_BULK_CHUNK_SIZE_CCP2 | ||
# define VCHI_MAX_BULK_CHUNK_SIZE_CCP2 0 | ||
#endif | ||
|
||
/* How many TX messages can we have pending in our transmit slots. Once exhausted, | ||
* vchi_msg_queue will be blocked. */ | ||
#ifndef VCHI_TX_MSG_QUEUE_SIZE | ||
# define VCHI_TX_MSG_QUEUE_SIZE 256 | ||
#endif | ||
|
||
/* How many RX messages can we have parsed in the receive slots. Once exhausted, parsing | ||
* will be suspended until older messages are dequeued/released. */ | ||
#ifndef VCHI_RX_MSG_QUEUE_SIZE | ||
# define VCHI_RX_MSG_QUEUE_SIZE 256 | ||
#endif | ||
|
||
/* Really should be able to cope if we run out of received message descriptors, by | ||
* suspending parsing as the comment above says, but we don't. This sweeps the issue | ||
* under the carpet. */ | ||
#if VCHI_RX_MSG_QUEUE_SIZE < (VCHI_MAX_MSG_SIZE/16 + 1) * VCHI_NUM_READ_SLOTS | ||
# undef VCHI_RX_MSG_QUEUE_SIZE | ||
# define VCHI_RX_MSG_QUEUE_SIZE (VCHI_MAX_MSG_SIZE/16 + 1) * VCHI_NUM_READ_SLOTS | ||
#endif | ||
|
||
/* How many bulk transmits can we have pending. Once exhausted, vchi_bulk_queue_transmit | ||
* will be blocked. */ | ||
#ifndef VCHI_TX_BULK_QUEUE_SIZE | ||
# define VCHI_TX_BULK_QUEUE_SIZE 64 | ||
#endif | ||
|
||
/* How many bulk receives can we have pending. Once exhausted, vchi_bulk_queue_receive | ||
* will be blocked. */ | ||
#ifndef VCHI_RX_BULK_QUEUE_SIZE | ||
# define VCHI_RX_BULK_QUEUE_SIZE 64 | ||
#endif | ||
|
||
/* A limit on how many outstanding bulk requests we expect the peer to give us. If | ||
* the peer asks for more than this, VCHI will fail and assert. The number is determined | ||
* by the peer's hardware - it's the number of outstanding requests that can be queued | ||
* on all bulk channels. VC3's MPHI peripheral allows 16. */ | ||
#ifndef VCHI_MAX_PEER_BULK_REQUESTS | ||
# define VCHI_MAX_PEER_BULK_REQUESTS 32 | ||
#endif | ||
|
||
/* Define VCHI_CCP2TX_MANUAL_POWER if the host tells us when to turn the CCP2 | ||
* transmitter on and off. | ||
*/ | ||
/*#define VCHI_CCP2TX_MANUAL_POWER*/ | ||
|
||
#ifndef VCHI_CCP2TX_MANUAL_POWER | ||
|
||
/* Timeout (in milliseconds) for putting the CCP2TX interface into IDLE state. Set | ||
* negative for no IDLE. | ||
*/ | ||
# ifndef VCHI_CCP2TX_IDLE_TIMEOUT | ||
# define VCHI_CCP2TX_IDLE_TIMEOUT 5 | ||
# endif | ||
|
||
/* Timeout (in milliseconds) for putting the CCP2TX interface into OFF state. Set | ||
* negative for no OFF. | ||
*/ | ||
# ifndef VCHI_CCP2TX_OFF_TIMEOUT | ||
# define VCHI_CCP2TX_OFF_TIMEOUT 1000 | ||
# endif | ||
|
||
#endif /* VCHI_CCP2TX_MANUAL_POWER */ | ||
|
||
#endif /* VCHI_CFG_H_ */ | ||
|
||
/****************************** End of file **********************************/ |
71 changes: 71 additions & 0 deletions
71
drivers/misc/vc04_services/interface/vchi/vchi_cfg_internal.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
* Copyright (c) 2010-2012 Broadcom. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions, and the following disclaimer, | ||
* without modification. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. The names of the above-listed copyright holders may not be used | ||
* to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* ALTERNATIVELY, this software may be distributed under the terms of the | ||
* GNU General Public License ("GPL") version 2, as published by the Free | ||
* Software Foundation. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef VCHI_CFG_INTERNAL_H_ | ||
#define VCHI_CFG_INTERNAL_H_ | ||
|
||
/**************************************************************************************** | ||
* Control optimisation attempts. | ||
***************************************************************************************/ | ||
|
||
// Don't use lots of short-term locks - use great long ones, reducing the overall locks-per-second | ||
#define VCHI_COARSE_LOCKING | ||
|
||
// Avoid lock then unlock on exit from blocking queue operations (msg tx, bulk rx/tx) | ||
// (only relevant if VCHI_COARSE_LOCKING) | ||
#define VCHI_ELIDE_BLOCK_EXIT_LOCK | ||
|
||
// Avoid lock on non-blocking peek | ||
// (only relevant if VCHI_COARSE_LOCKING) | ||
#define VCHI_AVOID_PEEK_LOCK | ||
|
||
// Use one slot-handler thread per connection, rather than 1 thread dealing with all connections in rotation. | ||
#define VCHI_MULTIPLE_HANDLER_THREADS | ||
|
||
// Put free descriptors onto the head of the free queue, rather than the tail, so that we don't thrash | ||
// our way through the pool of descriptors. | ||
#define VCHI_PUSH_FREE_DESCRIPTORS_ONTO_HEAD | ||
|
||
// Don't issue a MSG_AVAILABLE callback for every single message. Possibly only safe if VCHI_COARSE_LOCKING. | ||
#define VCHI_FEWER_MSG_AVAILABLE_CALLBACKS | ||
|
||
// Don't use message descriptors for TX messages that don't need them | ||
#define VCHI_MINIMISE_TX_MSG_DESCRIPTORS | ||
|
||
// Nano-locks for multiqueue | ||
//#define VCHI_MQUEUE_NANOLOCKS | ||
|
||
// Lock-free(er) dequeuing | ||
//#define VCHI_RX_NANOLOCKS | ||
|
||
#endif /*VCHI_CFG_INTERNAL_H_*/ |
175 changes: 175 additions & 0 deletions
175
drivers/misc/vc04_services/interface/vchi/vchi_common.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
/** | ||
* Copyright (c) 2010-2012 Broadcom. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions, and the following disclaimer, | ||
* without modification. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. The names of the above-listed copyright holders may not be used | ||
* to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* ALTERNATIVELY, this software may be distributed under the terms of the | ||
* GNU General Public License ("GPL") version 2, as published by the Free | ||
* Software Foundation. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef VCHI_COMMON_H_ | ||
#define VCHI_COMMON_H_ | ||
|
||
|
||
//flags used when sending messages (must be bitmapped) | ||
typedef enum | ||
{ | ||
VCHI_FLAGS_NONE = 0x0, | ||
VCHI_FLAGS_BLOCK_UNTIL_OP_COMPLETE = 0x1, // waits for message to be received, or sent (NB. not the same as being seen on other side) | ||
VCHI_FLAGS_CALLBACK_WHEN_OP_COMPLETE = 0x2, // run a callback when message sent | ||
VCHI_FLAGS_BLOCK_UNTIL_QUEUED = 0x4, // return once the transfer is in a queue ready to go | ||
VCHI_FLAGS_ALLOW_PARTIAL = 0x8, | ||
VCHI_FLAGS_BLOCK_UNTIL_DATA_READ = 0x10, | ||
VCHI_FLAGS_CALLBACK_WHEN_DATA_READ = 0x20, | ||
|
||
VCHI_FLAGS_ALIGN_SLOT = 0x000080, // internal use only | ||
VCHI_FLAGS_BULK_AUX_QUEUED = 0x010000, // internal use only | ||
VCHI_FLAGS_BULK_AUX_COMPLETE = 0x020000, // internal use only | ||
VCHI_FLAGS_BULK_DATA_QUEUED = 0x040000, // internal use only | ||
VCHI_FLAGS_BULK_DATA_COMPLETE = 0x080000, // internal use only | ||
VCHI_FLAGS_INTERNAL = 0xFF0000 | ||
} VCHI_FLAGS_T; | ||
|
||
// constants for vchi_crc_control() | ||
typedef enum { | ||
VCHI_CRC_NOTHING = -1, | ||
VCHI_CRC_PER_SERVICE = 0, | ||
VCHI_CRC_EVERYTHING = 1, | ||
} VCHI_CRC_CONTROL_T; | ||
|
||
//callback reasons when an event occurs on a service | ||
typedef enum | ||
{ | ||
VCHI_CALLBACK_REASON_MIN, | ||
|
||
//This indicates that there is data available | ||
//handle is the msg id that was transmitted with the data | ||
// When a message is received and there was no FULL message available previously, send callback | ||
// Tasks get kicked by the callback, reset their event and try and read from the fifo until it fails | ||
VCHI_CALLBACK_MSG_AVAILABLE, | ||
VCHI_CALLBACK_MSG_SENT, | ||
VCHI_CALLBACK_MSG_SPACE_AVAILABLE, // XXX not yet implemented | ||
|
||
// This indicates that a transfer from the other side has completed | ||
VCHI_CALLBACK_BULK_RECEIVED, | ||
//This indicates that data queued up to be sent has now gone | ||
//handle is the msg id that was used when sending the data | ||
VCHI_CALLBACK_BULK_SENT, | ||
VCHI_CALLBACK_BULK_RX_SPACE_AVAILABLE, // XXX not yet implemented | ||
VCHI_CALLBACK_BULK_TX_SPACE_AVAILABLE, // XXX not yet implemented | ||
|
||
VCHI_CALLBACK_SERVICE_CLOSED, | ||
|
||
// this side has sent XOFF to peer due to lack of data consumption by service | ||
// (suggests the service may need to take some recovery action if it has | ||
// been deliberately holding off consuming data) | ||
VCHI_CALLBACK_SENT_XOFF, | ||
VCHI_CALLBACK_SENT_XON, | ||
|
||
// indicates that a bulk transfer has finished reading the source buffer | ||
VCHI_CALLBACK_BULK_DATA_READ, | ||
|
||
// power notification events (currently host side only) | ||
VCHI_CALLBACK_PEER_OFF, | ||
VCHI_CALLBACK_PEER_SUSPENDED, | ||
VCHI_CALLBACK_PEER_ON, | ||
VCHI_CALLBACK_PEER_RESUMED, | ||
VCHI_CALLBACK_FORCED_POWER_OFF, | ||
|
||
#ifdef USE_VCHIQ_ARM | ||
// some extra notifications provided by vchiq_arm | ||
VCHI_CALLBACK_SERVICE_OPENED, | ||
VCHI_CALLBACK_BULK_RECEIVE_ABORTED, | ||
VCHI_CALLBACK_BULK_TRANSMIT_ABORTED, | ||
#endif | ||
|
||
VCHI_CALLBACK_REASON_MAX | ||
} VCHI_CALLBACK_REASON_T; | ||
|
||
// service control options | ||
typedef enum | ||
{ | ||
VCHI_SERVICE_OPTION_MIN, | ||
|
||
VCHI_SERVICE_OPTION_TRACE, | ||
VCHI_SERVICE_OPTION_SYNCHRONOUS, | ||
|
||
VCHI_SERVICE_OPTION_MAX | ||
} VCHI_SERVICE_OPTION_T; | ||
|
||
|
||
//Callback used by all services / bulk transfers | ||
typedef void (*VCHI_CALLBACK_T)( void *callback_param, //my service local param | ||
VCHI_CALLBACK_REASON_T reason, | ||
void *handle ); //for transmitting msg's only | ||
|
||
|
||
|
||
/* | ||
* Define vector struct for scatter-gather (vector) operations | ||
* Vectors can be nested - if a vector element has negative length, then | ||
* the data pointer is treated as pointing to another vector array, with | ||
* '-vec_len' elements. Thus to append a header onto an existing vector, | ||
* you can do this: | ||
* | ||
* void foo(const VCHI_MSG_VECTOR_T *v, int n) | ||
* { | ||
* VCHI_MSG_VECTOR_T nv[2]; | ||
* nv[0].vec_base = my_header; | ||
* nv[0].vec_len = sizeof my_header; | ||
* nv[1].vec_base = v; | ||
* nv[1].vec_len = -n; | ||
* ... | ||
* | ||
*/ | ||
typedef struct vchi_msg_vector { | ||
const void *vec_base; | ||
int32_t vec_len; | ||
} VCHI_MSG_VECTOR_T; | ||
|
||
// Opaque type for a connection API | ||
typedef struct opaque_vchi_connection_api_t VCHI_CONNECTION_API_T; | ||
|
||
// Opaque type for a message driver | ||
typedef struct opaque_vchi_message_driver_t VCHI_MESSAGE_DRIVER_T; | ||
|
||
|
||
// Iterator structure for reading ahead through received message queue. Allocated by client, | ||
// initialised by vchi_msg_look_ahead. Fields are for internal VCHI use only. | ||
// Iterates over messages in queue at the instant of the call to vchi_msg_lookahead - | ||
// will not proceed to messages received since. Behaviour is undefined if an iterator | ||
// is used again after messages for that service are removed/dequeued by any | ||
// means other than vchi_msg_iter_... calls on the iterator itself. | ||
typedef struct { | ||
struct opaque_vchi_service_t *service; | ||
void *last; | ||
void *next; | ||
void *remove; | ||
} VCHI_MSG_ITER_T; | ||
|
||
|
||
#endif // VCHI_COMMON_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Copyright (c) 2010-2012 Broadcom. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions, and the following disclaimer, | ||
* without modification. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. The names of the above-listed copyright holders may not be used | ||
* to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* ALTERNATIVELY, this software may be distributed under the terms of the | ||
* GNU General Public License ("GPL") version 2, as published by the Free | ||
* Software Foundation. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef VCHI_MH_H_ | ||
#define VCHI_MH_H_ | ||
|
||
#include <linux/types.h> | ||
|
||
typedef int32_t VCHI_MEM_HANDLE_T; | ||
#define VCHI_MEM_HANDLE_INVALID 0 | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Copyright (c) 2010-2012 Broadcom. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions, and the following disclaimer, | ||
* without modification. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. The names of the above-listed copyright holders may not be used | ||
* to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* ALTERNATIVELY, this software may be distributed under the terms of the | ||
* GNU General Public License ("GPL") version 2, as published by the Free | ||
* Software Foundation. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef VCHIQ_VCHIQ_H | ||
#define VCHIQ_VCHIQ_H | ||
|
||
#include "vchiq_if.h" | ||
#include "vchiq_util.h" | ||
|
||
#endif |
42 changes: 42 additions & 0 deletions
42
drivers/misc/vc04_services/interface/vchiq_arm/vchiq_2835.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Copyright (c) 2010-2012 Broadcom. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions, and the following disclaimer, | ||
* without modification. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. The names of the above-listed copyright holders may not be used | ||
* to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* ALTERNATIVELY, this software may be distributed under the terms of the | ||
* GNU General Public License ("GPL") version 2, as published by the Free | ||
* Software Foundation. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef VCHIQ_2835_H | ||
#define VCHIQ_2835_H | ||
|
||
#include "vchiq_pagelist.h" | ||
|
||
#define VCHIQ_PLATFORM_FRAGMENTS_OFFSET_IDX 0 | ||
#define VCHIQ_PLATFORM_FRAGMENTS_COUNT_IDX 1 | ||
|
||
#endif /* VCHIQ_2835_H */ |
586 changes: 586 additions & 0 deletions
586
drivers/misc/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
Large diffs are not rendered by default.
Oops, something went wrong.
2,921 changes: 2,921 additions & 0 deletions
2,921
drivers/misc/vc04_services/interface/vchiq_arm/vchiq_arm.c
Large diffs are not rendered by default.
Oops, something went wrong.
220 changes: 220 additions & 0 deletions
220
drivers/misc/vc04_services/interface/vchiq_arm/vchiq_arm.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,220 @@ | ||
/** | ||
* Copyright (c) 2014 Raspberry Pi (Trading) Ltd. All rights reserved. | ||
* Copyright (c) 2010-2012 Broadcom. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions, and the following disclaimer, | ||
* without modification. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. The names of the above-listed copyright holders may not be used | ||
* to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* ALTERNATIVELY, this software may be distributed under the terms of the | ||
* GNU General Public License ("GPL") version 2, as published by the Free | ||
* Software Foundation. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef VCHIQ_ARM_H | ||
#define VCHIQ_ARM_H | ||
|
||
#include <linux/mutex.h> | ||
#include <linux/platform_device.h> | ||
#include <linux/semaphore.h> | ||
#include <linux/atomic.h> | ||
#include "vchiq_core.h" | ||
#include "vchiq_debugfs.h" | ||
|
||
|
||
enum vc_suspend_status { | ||
VC_SUSPEND_FORCE_CANCELED = -3, /* Force suspend canceled, too busy */ | ||
VC_SUSPEND_REJECTED = -2, /* Videocore rejected suspend request */ | ||
VC_SUSPEND_FAILED = -1, /* Videocore suspend failed */ | ||
VC_SUSPEND_IDLE = 0, /* VC active, no suspend actions */ | ||
VC_SUSPEND_REQUESTED, /* User has requested suspend */ | ||
VC_SUSPEND_IN_PROGRESS, /* Slot handler has recvd suspend request */ | ||
VC_SUSPEND_SUSPENDED /* Videocore suspend succeeded */ | ||
}; | ||
|
||
enum vc_resume_status { | ||
VC_RESUME_FAILED = -1, /* Videocore resume failed */ | ||
VC_RESUME_IDLE = 0, /* VC suspended, no resume actions */ | ||
VC_RESUME_REQUESTED, /* User has requested resume */ | ||
VC_RESUME_IN_PROGRESS, /* Slot handler has received resume request */ | ||
VC_RESUME_RESUMED /* Videocore resumed successfully (active) */ | ||
}; | ||
|
||
|
||
enum USE_TYPE_E { | ||
USE_TYPE_SERVICE, | ||
USE_TYPE_SERVICE_NO_RESUME, | ||
USE_TYPE_VCHIQ | ||
}; | ||
|
||
|
||
|
||
typedef struct vchiq_arm_state_struct { | ||
/* Keepalive-related data */ | ||
struct task_struct *ka_thread; | ||
struct completion ka_evt; | ||
atomic_t ka_use_count; | ||
atomic_t ka_use_ack_count; | ||
atomic_t ka_release_count; | ||
|
||
struct completion vc_suspend_complete; | ||
struct completion vc_resume_complete; | ||
|
||
rwlock_t susp_res_lock; | ||
enum vc_suspend_status vc_suspend_state; | ||
enum vc_resume_status vc_resume_state; | ||
|
||
unsigned int wake_address; | ||
|
||
struct timer_list suspend_timer; | ||
int suspend_timer_timeout; | ||
int suspend_timer_running; | ||
|
||
/* Global use count for videocore. | ||
** This is equal to the sum of the use counts for all services. When | ||
** this hits zero the videocore suspend procedure will be initiated. | ||
*/ | ||
int videocore_use_count; | ||
|
||
/* Use count to track requests from videocore peer. | ||
** This use count is not associated with a service, so needs to be | ||
** tracked separately with the state. | ||
*/ | ||
int peer_use_count; | ||
|
||
/* Flag to indicate whether resume is blocked. This happens when the | ||
** ARM is suspending | ||
*/ | ||
struct completion resume_blocker; | ||
int resume_blocked; | ||
struct completion blocked_blocker; | ||
int blocked_count; | ||
|
||
int autosuspend_override; | ||
|
||
/* Flag to indicate that the first vchiq connect has made it through. | ||
** This means that both sides should be fully ready, and we should | ||
** be able to suspend after this point. | ||
*/ | ||
int first_connect; | ||
|
||
unsigned long long suspend_start_time; | ||
unsigned long long sleep_start_time; | ||
unsigned long long resume_start_time; | ||
unsigned long long last_wake_time; | ||
|
||
} VCHIQ_ARM_STATE_T; | ||
|
||
extern int vchiq_arm_log_level; | ||
extern int vchiq_susp_log_level; | ||
|
||
int vchiq_platform_init(struct platform_device *pdev, VCHIQ_STATE_T *state); | ||
|
||
extern VCHIQ_STATE_T * | ||
vchiq_get_state(void); | ||
|
||
extern VCHIQ_STATUS_T | ||
vchiq_arm_vcsuspend(VCHIQ_STATE_T *state); | ||
|
||
extern VCHIQ_STATUS_T | ||
vchiq_arm_force_suspend(VCHIQ_STATE_T *state); | ||
|
||
extern int | ||
vchiq_arm_allow_resume(VCHIQ_STATE_T *state); | ||
|
||
extern VCHIQ_STATUS_T | ||
vchiq_arm_vcresume(VCHIQ_STATE_T *state); | ||
|
||
extern VCHIQ_STATUS_T | ||
vchiq_arm_init_state(VCHIQ_STATE_T *state, VCHIQ_ARM_STATE_T *arm_state); | ||
|
||
extern int | ||
vchiq_check_resume(VCHIQ_STATE_T *state); | ||
|
||
extern void | ||
vchiq_check_suspend(VCHIQ_STATE_T *state); | ||
VCHIQ_STATUS_T | ||
vchiq_use_service(VCHIQ_SERVICE_HANDLE_T handle); | ||
|
||
extern VCHIQ_STATUS_T | ||
vchiq_release_service(VCHIQ_SERVICE_HANDLE_T handle); | ||
|
||
extern VCHIQ_STATUS_T | ||
vchiq_check_service(VCHIQ_SERVICE_T *service); | ||
|
||
extern VCHIQ_STATUS_T | ||
vchiq_platform_suspend(VCHIQ_STATE_T *state); | ||
|
||
extern int | ||
vchiq_platform_videocore_wanted(VCHIQ_STATE_T *state); | ||
|
||
extern int | ||
vchiq_platform_use_suspend_timer(void); | ||
|
||
extern void | ||
vchiq_dump_platform_use_state(VCHIQ_STATE_T *state); | ||
|
||
extern void | ||
vchiq_dump_service_use_state(VCHIQ_STATE_T *state); | ||
|
||
extern VCHIQ_ARM_STATE_T* | ||
vchiq_platform_get_arm_state(VCHIQ_STATE_T *state); | ||
|
||
extern int | ||
vchiq_videocore_wanted(VCHIQ_STATE_T *state); | ||
|
||
extern VCHIQ_STATUS_T | ||
vchiq_use_internal(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service, | ||
enum USE_TYPE_E use_type); | ||
extern VCHIQ_STATUS_T | ||
vchiq_release_internal(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service); | ||
|
||
extern VCHIQ_DEBUGFS_NODE_T * | ||
vchiq_instance_get_debugfs_node(VCHIQ_INSTANCE_T instance); | ||
|
||
extern int | ||
vchiq_instance_get_use_count(VCHIQ_INSTANCE_T instance); | ||
|
||
extern int | ||
vchiq_instance_get_pid(VCHIQ_INSTANCE_T instance); | ||
|
||
extern int | ||
vchiq_instance_get_trace(VCHIQ_INSTANCE_T instance); | ||
|
||
extern void | ||
vchiq_instance_set_trace(VCHIQ_INSTANCE_T instance, int trace); | ||
|
||
extern void | ||
set_suspend_state(VCHIQ_ARM_STATE_T *arm_state, | ||
enum vc_suspend_status new_state); | ||
|
||
extern void | ||
set_resume_state(VCHIQ_ARM_STATE_T *arm_state, | ||
enum vc_resume_status new_state); | ||
|
||
extern void | ||
start_suspend_timer(VCHIQ_ARM_STATE_T *arm_state); | ||
|
||
|
||
#endif /* VCHIQ_ARM_H */ |
37 changes: 37 additions & 0 deletions
37
drivers/misc/vc04_services/interface/vchiq_arm/vchiq_build_info.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* Copyright (c) 2010-2012 Broadcom. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions, and the following disclaimer, | ||
* without modification. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. The names of the above-listed copyright holders may not be used | ||
* to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* ALTERNATIVELY, this software may be distributed under the terms of the | ||
* GNU General Public License ("GPL") version 2, as published by the Free | ||
* Software Foundation. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
const char *vchiq_get_build_hostname(void); | ||
const char *vchiq_get_build_version(void); | ||
const char *vchiq_get_build_time(void); | ||
const char *vchiq_get_build_date(void); |
69 changes: 69 additions & 0 deletions
69
drivers/misc/vc04_services/interface/vchiq_arm/vchiq_cfg.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* Copyright (c) 2010-2014 Broadcom. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions, and the following disclaimer, | ||
* without modification. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. The names of the above-listed copyright holders may not be used | ||
* to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* ALTERNATIVELY, this software may be distributed under the terms of the | ||
* GNU General Public License ("GPL") version 2, as published by the Free | ||
* Software Foundation. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef VCHIQ_CFG_H | ||
#define VCHIQ_CFG_H | ||
|
||
#define VCHIQ_MAGIC VCHIQ_MAKE_FOURCC('V', 'C', 'H', 'I') | ||
/* The version of VCHIQ - change with any non-trivial change */ | ||
#define VCHIQ_VERSION 8 | ||
/* The minimum compatible version - update to match VCHIQ_VERSION with any | ||
** incompatible change */ | ||
#define VCHIQ_VERSION_MIN 3 | ||
|
||
/* The version that introduced the VCHIQ_IOC_LIB_VERSION ioctl */ | ||
#define VCHIQ_VERSION_LIB_VERSION 7 | ||
|
||
/* The version that introduced the VCHIQ_IOC_CLOSE_DELIVERED ioctl */ | ||
#define VCHIQ_VERSION_CLOSE_DELIVERED 7 | ||
|
||
/* The version that made it safe to use SYNCHRONOUS mode */ | ||
#define VCHIQ_VERSION_SYNCHRONOUS_MODE 8 | ||
|
||
#define VCHIQ_MAX_STATES 1 | ||
#define VCHIQ_MAX_SERVICES 4096 | ||
#define VCHIQ_MAX_SLOTS 128 | ||
#define VCHIQ_MAX_SLOTS_PER_SIDE 64 | ||
|
||
#define VCHIQ_NUM_CURRENT_BULKS 32 | ||
#define VCHIQ_NUM_SERVICE_BULKS 4 | ||
|
||
#ifndef VCHIQ_ENABLE_DEBUG | ||
#define VCHIQ_ENABLE_DEBUG 1 | ||
#endif | ||
|
||
#ifndef VCHIQ_ENABLE_STATS | ||
#define VCHIQ_ENABLE_STATS 1 | ||
#endif | ||
|
||
#endif /* VCHIQ_CFG_H */ |
120 changes: 120 additions & 0 deletions
120
drivers/misc/vc04_services/interface/vchiq_arm/vchiq_connected.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/** | ||
* Copyright (c) 2010-2012 Broadcom. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions, and the following disclaimer, | ||
* without modification. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. The names of the above-listed copyright holders may not be used | ||
* to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* ALTERNATIVELY, this software may be distributed under the terms of the | ||
* GNU General Public License ("GPL") version 2, as published by the Free | ||
* Software Foundation. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#include "vchiq_connected.h" | ||
#include "vchiq_core.h" | ||
#include "vchiq_killable.h" | ||
#include <linux/module.h> | ||
#include <linux/mutex.h> | ||
|
||
#define MAX_CALLBACKS 10 | ||
|
||
static int g_connected; | ||
static int g_num_deferred_callbacks; | ||
static VCHIQ_CONNECTED_CALLBACK_T g_deferred_callback[MAX_CALLBACKS]; | ||
static int g_once_init; | ||
static struct mutex g_connected_mutex; | ||
|
||
/**************************************************************************** | ||
* | ||
* Function to initialize our lock. | ||
* | ||
***************************************************************************/ | ||
|
||
static void connected_init(void) | ||
{ | ||
if (!g_once_init) { | ||
mutex_init(&g_connected_mutex); | ||
g_once_init = 1; | ||
} | ||
} | ||
|
||
/**************************************************************************** | ||
* | ||
* This function is used to defer initialization until the vchiq stack is | ||
* initialized. If the stack is already initialized, then the callback will | ||
* be made immediately, otherwise it will be deferred until | ||
* vchiq_call_connected_callbacks is called. | ||
* | ||
***************************************************************************/ | ||
|
||
void vchiq_add_connected_callback(VCHIQ_CONNECTED_CALLBACK_T callback) | ||
{ | ||
connected_init(); | ||
|
||
if (mutex_lock_interruptible(&g_connected_mutex) != 0) | ||
return; | ||
|
||
if (g_connected) | ||
/* We're already connected. Call the callback immediately. */ | ||
|
||
callback(); | ||
else { | ||
if (g_num_deferred_callbacks >= MAX_CALLBACKS) | ||
vchiq_log_error(vchiq_core_log_level, | ||
"There already %d callback registered - " | ||
"please increase MAX_CALLBACKS", | ||
g_num_deferred_callbacks); | ||
else { | ||
g_deferred_callback[g_num_deferred_callbacks] = | ||
callback; | ||
g_num_deferred_callbacks++; | ||
} | ||
} | ||
mutex_unlock(&g_connected_mutex); | ||
} | ||
|
||
/**************************************************************************** | ||
* | ||
* This function is called by the vchiq stack once it has been connected to | ||
* the videocore and clients can start to use the stack. | ||
* | ||
***************************************************************************/ | ||
|
||
void vchiq_call_connected_callbacks(void) | ||
{ | ||
int i; | ||
|
||
connected_init(); | ||
|
||
if (mutex_lock_interruptible(&g_connected_mutex) != 0) | ||
return; | ||
|
||
for (i = 0; i < g_num_deferred_callbacks; i++) | ||
g_deferred_callback[i](); | ||
|
||
g_num_deferred_callbacks = 0; | ||
g_connected = 1; | ||
mutex_unlock(&g_connected_mutex); | ||
} | ||
EXPORT_SYMBOL(vchiq_add_connected_callback); |
50 changes: 50 additions & 0 deletions
50
drivers/misc/vc04_services/interface/vchiq_arm/vchiq_connected.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* Copyright (c) 2010-2012 Broadcom. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions, and the following disclaimer, | ||
* without modification. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. The names of the above-listed copyright holders may not be used | ||
* to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* ALTERNATIVELY, this software may be distributed under the terms of the | ||
* GNU General Public License ("GPL") version 2, as published by the Free | ||
* Software Foundation. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef VCHIQ_CONNECTED_H | ||
#define VCHIQ_CONNECTED_H | ||
|
||
/* ---- Include Files ----------------------------------------------------- */ | ||
|
||
/* ---- Constants and Types ---------------------------------------------- */ | ||
|
||
typedef void (*VCHIQ_CONNECTED_CALLBACK_T)(void); | ||
|
||
/* ---- Variable Externs ------------------------------------------------- */ | ||
|
||
/* ---- Function Prototypes ---------------------------------------------- */ | ||
|
||
void vchiq_add_connected_callback(VCHIQ_CONNECTED_CALLBACK_T callback); | ||
void vchiq_call_connected_callbacks(void); | ||
|
||
#endif /* VCHIQ_CONNECTED_H */ |
3,933 changes: 3,933 additions & 0 deletions
3,933
drivers/misc/vc04_services/interface/vchiq_arm/vchiq_core.c
Large diffs are not rendered by default.
Oops, something went wrong.
712 changes: 712 additions & 0 deletions
712
drivers/misc/vc04_services/interface/vchiq_arm/vchiq_core.h
Large diffs are not rendered by default.
Oops, something went wrong.
383 changes: 383 additions & 0 deletions
383
drivers/misc/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,383 @@ | ||
/** | ||
* Copyright (c) 2014 Raspberry Pi (Trading) Ltd. All rights reserved. | ||
* Copyright (c) 2010-2012 Broadcom. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions, and the following disclaimer, | ||
* without modification. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. The names of the above-listed copyright holders may not be used | ||
* to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* ALTERNATIVELY, this software may be distributed under the terms of the | ||
* GNU General Public License ("GPL") version 2, as published by the Free | ||
* Software Foundation. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
|
||
#include <linux/debugfs.h> | ||
#include "vchiq_core.h" | ||
#include "vchiq_arm.h" | ||
#include "vchiq_debugfs.h" | ||
|
||
#ifdef CONFIG_DEBUG_FS | ||
|
||
/**************************************************************************** | ||
* | ||
* log category entries | ||
* | ||
***************************************************************************/ | ||
#define DEBUGFS_WRITE_BUF_SIZE 256 | ||
|
||
#define VCHIQ_LOG_ERROR_STR "error" | ||
#define VCHIQ_LOG_WARNING_STR "warning" | ||
#define VCHIQ_LOG_INFO_STR "info" | ||
#define VCHIQ_LOG_TRACE_STR "trace" | ||
|
||
|
||
/* Top-level debug info */ | ||
struct vchiq_debugfs_info { | ||
/* Global 'vchiq' debugfs entry used by all instances */ | ||
struct dentry *vchiq_cfg_dir; | ||
|
||
/* one entry per client process */ | ||
struct dentry *clients; | ||
|
||
/* log categories */ | ||
struct dentry *log_categories; | ||
}; | ||
|
||
static struct vchiq_debugfs_info debugfs_info; | ||
|
||
/* Log category debugfs entries */ | ||
struct vchiq_debugfs_log_entry { | ||
const char *name; | ||
int *plevel; | ||
struct dentry *dir; | ||
}; | ||
|
||
static struct vchiq_debugfs_log_entry vchiq_debugfs_log_entries[] = { | ||
{ "core", &vchiq_core_log_level }, | ||
{ "msg", &vchiq_core_msg_log_level }, | ||
{ "sync", &vchiq_sync_log_level }, | ||
{ "susp", &vchiq_susp_log_level }, | ||
{ "arm", &vchiq_arm_log_level }, | ||
}; | ||
static int n_log_entries = | ||
sizeof(vchiq_debugfs_log_entries)/sizeof(vchiq_debugfs_log_entries[0]); | ||
|
||
|
||
static struct dentry *vchiq_clients_top(void); | ||
static struct dentry *vchiq_debugfs_top(void); | ||
|
||
static int debugfs_log_show(struct seq_file *f, void *offset) | ||
{ | ||
int *levp = f->private; | ||
char *log_value = NULL; | ||
|
||
switch (*levp) { | ||
case VCHIQ_LOG_ERROR: | ||
log_value = VCHIQ_LOG_ERROR_STR; | ||
break; | ||
case VCHIQ_LOG_WARNING: | ||
log_value = VCHIQ_LOG_WARNING_STR; | ||
break; | ||
case VCHIQ_LOG_INFO: | ||
log_value = VCHIQ_LOG_INFO_STR; | ||
break; | ||
case VCHIQ_LOG_TRACE: | ||
log_value = VCHIQ_LOG_TRACE_STR; | ||
break; | ||
default: | ||
break; | ||
} | ||
|
||
seq_printf(f, "%s\n", log_value ? log_value : "(null)"); | ||
|
||
return 0; | ||
} | ||
|
||
static int debugfs_log_open(struct inode *inode, struct file *file) | ||
{ | ||
return single_open(file, debugfs_log_show, inode->i_private); | ||
} | ||
|
||
static int debugfs_log_write(struct file *file, | ||
const char __user *buffer, | ||
size_t count, loff_t *ppos) | ||
{ | ||
struct seq_file *f = (struct seq_file *)file->private_data; | ||
int *levp = f->private; | ||
char kbuf[DEBUGFS_WRITE_BUF_SIZE + 1]; | ||
|
||
memset(kbuf, 0, DEBUGFS_WRITE_BUF_SIZE + 1); | ||
if (count >= DEBUGFS_WRITE_BUF_SIZE) | ||
count = DEBUGFS_WRITE_BUF_SIZE; | ||
|
||
if (copy_from_user(kbuf, buffer, count) != 0) | ||
return -EFAULT; | ||
kbuf[count - 1] = 0; | ||
|
||
if (strncmp("error", kbuf, strlen("error")) == 0) | ||
*levp = VCHIQ_LOG_ERROR; | ||
else if (strncmp("warning", kbuf, strlen("warning")) == 0) | ||
*levp = VCHIQ_LOG_WARNING; | ||
else if (strncmp("info", kbuf, strlen("info")) == 0) | ||
*levp = VCHIQ_LOG_INFO; | ||
else if (strncmp("trace", kbuf, strlen("trace")) == 0) | ||
*levp = VCHIQ_LOG_TRACE; | ||
else | ||
*levp = VCHIQ_LOG_DEFAULT; | ||
|
||
*ppos += count; | ||
|
||
return count; | ||
} | ||
|
||
static const struct file_operations debugfs_log_fops = { | ||
.owner = THIS_MODULE, | ||
.open = debugfs_log_open, | ||
.write = debugfs_log_write, | ||
.read = seq_read, | ||
.llseek = seq_lseek, | ||
.release = single_release, | ||
}; | ||
|
||
/* create an entry under <debugfs>/vchiq/log for each log category */ | ||
static int vchiq_debugfs_create_log_entries(struct dentry *top) | ||
{ | ||
struct dentry *dir; | ||
size_t i; | ||
int ret = 0; | ||
dir = debugfs_create_dir("log", vchiq_debugfs_top()); | ||
if (!dir) | ||
return -ENOMEM; | ||
debugfs_info.log_categories = dir; | ||
|
||
for (i = 0; i < n_log_entries; i++) { | ||
void *levp = (void *)vchiq_debugfs_log_entries[i].plevel; | ||
dir = debugfs_create_file(vchiq_debugfs_log_entries[i].name, | ||
0644, | ||
debugfs_info.log_categories, | ||
levp, | ||
&debugfs_log_fops); | ||
if (!dir) { | ||
ret = -ENOMEM; | ||
break; | ||
} | ||
|
||
vchiq_debugfs_log_entries[i].dir = dir; | ||
} | ||
return ret; | ||
} | ||
|
||
static int debugfs_usecount_show(struct seq_file *f, void *offset) | ||
{ | ||
VCHIQ_INSTANCE_T instance = f->private; | ||
int use_count; | ||
|
||
use_count = vchiq_instance_get_use_count(instance); | ||
seq_printf(f, "%d\n", use_count); | ||
|
||
return 0; | ||
} | ||
|
||
static int debugfs_usecount_open(struct inode *inode, struct file *file) | ||
{ | ||
return single_open(file, debugfs_usecount_show, inode->i_private); | ||
} | ||
|
||
static const struct file_operations debugfs_usecount_fops = { | ||
.owner = THIS_MODULE, | ||
.open = debugfs_usecount_open, | ||
.read = seq_read, | ||
.llseek = seq_lseek, | ||
.release = single_release, | ||
}; | ||
|
||
static int debugfs_trace_show(struct seq_file *f, void *offset) | ||
{ | ||
VCHIQ_INSTANCE_T instance = f->private; | ||
int trace; | ||
|
||
trace = vchiq_instance_get_trace(instance); | ||
seq_printf(f, "%s\n", trace ? "Y" : "N"); | ||
|
||
return 0; | ||
} | ||
|
||
static int debugfs_trace_open(struct inode *inode, struct file *file) | ||
{ | ||
return single_open(file, debugfs_trace_show, inode->i_private); | ||
} | ||
|
||
static int debugfs_trace_write(struct file *file, | ||
const char __user *buffer, | ||
size_t count, loff_t *ppos) | ||
{ | ||
struct seq_file *f = (struct seq_file *)file->private_data; | ||
VCHIQ_INSTANCE_T instance = f->private; | ||
char firstchar; | ||
|
||
if (copy_from_user(&firstchar, buffer, 1) != 0) | ||
return -EFAULT; | ||
|
||
switch (firstchar) { | ||
case 'Y': | ||
case 'y': | ||
case '1': | ||
vchiq_instance_set_trace(instance, 1); | ||
break; | ||
case 'N': | ||
case 'n': | ||
case '0': | ||
vchiq_instance_set_trace(instance, 0); | ||
break; | ||
default: | ||
break; | ||
} | ||
|
||
*ppos += count; | ||
|
||
return count; | ||
} | ||
|
||
static const struct file_operations debugfs_trace_fops = { | ||
.owner = THIS_MODULE, | ||
.open = debugfs_trace_open, | ||
.write = debugfs_trace_write, | ||
.read = seq_read, | ||
.llseek = seq_lseek, | ||
.release = single_release, | ||
}; | ||
|
||
/* add an instance (process) to the debugfs entries */ | ||
int vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance) | ||
{ | ||
char pidstr[16]; | ||
struct dentry *top, *use_count, *trace; | ||
struct dentry *clients = vchiq_clients_top(); | ||
|
||
snprintf(pidstr, sizeof(pidstr), "%d", | ||
vchiq_instance_get_pid(instance)); | ||
|
||
top = debugfs_create_dir(pidstr, clients); | ||
if (!top) | ||
goto fail_top; | ||
|
||
use_count = debugfs_create_file("use_count", | ||
0444, top, | ||
instance, | ||
&debugfs_usecount_fops); | ||
if (!use_count) | ||
goto fail_use_count; | ||
|
||
trace = debugfs_create_file("trace", | ||
0644, top, | ||
instance, | ||
&debugfs_trace_fops); | ||
if (!trace) | ||
goto fail_trace; | ||
|
||
vchiq_instance_get_debugfs_node(instance)->dentry = top; | ||
|
||
return 0; | ||
|
||
fail_trace: | ||
debugfs_remove(use_count); | ||
fail_use_count: | ||
debugfs_remove(top); | ||
fail_top: | ||
return -ENOMEM; | ||
} | ||
|
||
void vchiq_debugfs_remove_instance(VCHIQ_INSTANCE_T instance) | ||
{ | ||
VCHIQ_DEBUGFS_NODE_T *node = vchiq_instance_get_debugfs_node(instance); | ||
debugfs_remove_recursive(node->dentry); | ||
} | ||
|
||
|
||
int vchiq_debugfs_init(void) | ||
{ | ||
BUG_ON(debugfs_info.vchiq_cfg_dir != NULL); | ||
|
||
debugfs_info.vchiq_cfg_dir = debugfs_create_dir("vchiq", NULL); | ||
if (debugfs_info.vchiq_cfg_dir == NULL) | ||
goto fail; | ||
|
||
debugfs_info.clients = debugfs_create_dir("clients", | ||
vchiq_debugfs_top()); | ||
if (!debugfs_info.clients) | ||
goto fail; | ||
|
||
if (vchiq_debugfs_create_log_entries(vchiq_debugfs_top()) != 0) | ||
goto fail; | ||
|
||
return 0; | ||
|
||
fail: | ||
vchiq_debugfs_deinit(); | ||
vchiq_log_error(vchiq_arm_log_level, | ||
"%s: failed to create debugfs directory", | ||
__func__); | ||
|
||
return -ENOMEM; | ||
} | ||
|
||
/* remove all the debugfs entries */ | ||
void vchiq_debugfs_deinit(void) | ||
{ | ||
debugfs_remove_recursive(vchiq_debugfs_top()); | ||
} | ||
|
||
static struct dentry *vchiq_clients_top(void) | ||
{ | ||
return debugfs_info.clients; | ||
} | ||
|
||
static struct dentry *vchiq_debugfs_top(void) | ||
{ | ||
BUG_ON(debugfs_info.vchiq_cfg_dir == NULL); | ||
return debugfs_info.vchiq_cfg_dir; | ||
} | ||
|
||
#else /* CONFIG_DEBUG_FS */ | ||
|
||
int vchiq_debugfs_init(void) | ||
{ | ||
return 0; | ||
} | ||
|
||
void vchiq_debugfs_deinit(void) | ||
{ | ||
} | ||
|
||
int vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance) | ||
{ | ||
return 0; | ||
} | ||
|
||
void vchiq_debugfs_remove_instance(VCHIQ_INSTANCE_T instance) | ||
{ | ||
} | ||
|
||
#endif /* CONFIG_DEBUG_FS */ |
52 changes: 52 additions & 0 deletions
52
drivers/misc/vc04_services/interface/vchiq_arm/vchiq_debugfs.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* Copyright (c) 2014 Raspberry Pi (Trading) Ltd. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions, and the following disclaimer, | ||
* without modification. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. The names of the above-listed copyright holders may not be used | ||
* to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* ALTERNATIVELY, this software may be distributed under the terms of the | ||
* GNU General Public License ("GPL") version 2, as published by the Free | ||
* Software Foundation. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef VCHIQ_DEBUGFS_H | ||
#define VCHIQ_DEBUGFS_H | ||
|
||
#include "vchiq_core.h" | ||
|
||
typedef struct vchiq_debugfs_node_struct | ||
{ | ||
struct dentry *dentry; | ||
} VCHIQ_DEBUGFS_NODE_T; | ||
|
||
int vchiq_debugfs_init(void); | ||
|
||
void vchiq_debugfs_deinit(void); | ||
|
||
int vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance); | ||
|
||
void vchiq_debugfs_remove_instance(VCHIQ_INSTANCE_T instance); | ||
|
||
#endif /* VCHIQ_DEBUGFS_H */ |
87 changes: 87 additions & 0 deletions
87
drivers/misc/vc04_services/interface/vchiq_arm/vchiq_genversion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#!/usr/bin/perl -w | ||
|
||
use strict; | ||
|
||
# | ||
# Generate a version from available information | ||
# | ||
|
||
my $prefix = shift @ARGV; | ||
my $root = shift @ARGV; | ||
|
||
|
||
if ( not defined $root ) { | ||
die "usage: $0 prefix root-dir\n"; | ||
} | ||
|
||
if ( ! -d $root ) { | ||
die "root directory $root not found\n"; | ||
} | ||
|
||
my $version = "unknown"; | ||
my $tainted = ""; | ||
|
||
if ( -d "$root/.git" ) { | ||
# attempt to work out git version. only do so | ||
# on a linux build host, as cygwin builds are | ||
# already slow enough | ||
|
||
if ( -f "/usr/bin/git" || -f "/usr/local/bin/git" ) { | ||
if (not open(F, "git --git-dir $root/.git rev-parse --verify HEAD|")) { | ||
$version = "no git version"; | ||
} | ||
else { | ||
$version = <F>; | ||
$version =~ s/[ \r\n]*$//; # chomp may not be enough (cygwin). | ||
$version =~ s/^[ \r\n]*//; # chomp may not be enough (cygwin). | ||
} | ||
|
||
if (open(G, "git --git-dir $root/.git status --porcelain|")) { | ||
$tainted = <G>; | ||
$tainted =~ s/[ \r\n]*$//; # chomp may not be enough (cygwin). | ||
$tainted =~ s/^[ \r\n]*//; # chomp may not be enough (cygwin). | ||
if (length $tainted) { | ||
$version = join ' ', $version, "(tainted)"; | ||
} | ||
else { | ||
$version = join ' ', $version, "(clean)"; | ||
} | ||
} | ||
} | ||
} | ||
|
||
my $hostname = `hostname`; | ||
$hostname =~ s/[ \r\n]*$//; # chomp may not be enough (cygwin). | ||
$hostname =~ s/^[ \r\n]*//; # chomp may not be enough (cygwin). | ||
|
||
|
||
print STDERR "Version $version\n"; | ||
print <<EOF; | ||
#include "${prefix}_build_info.h" | ||
#include <linux/broadcom/vc_debug_sym.h> | ||
VC_DEBUG_DECLARE_STRING_VAR( ${prefix}_build_hostname, "$hostname" ); | ||
VC_DEBUG_DECLARE_STRING_VAR( ${prefix}_build_version, "$version" ); | ||
VC_DEBUG_DECLARE_STRING_VAR( ${prefix}_build_time, __TIME__ ); | ||
VC_DEBUG_DECLARE_STRING_VAR( ${prefix}_build_date, __DATE__ ); | ||
const char *vchiq_get_build_hostname( void ) | ||
{ | ||
return vchiq_build_hostname; | ||
} | ||
const char *vchiq_get_build_version( void ) | ||
{ | ||
return vchiq_build_version; | ||
} | ||
const char *vchiq_get_build_date( void ) | ||
{ | ||
return vchiq_build_date; | ||
} | ||
const char *vchiq_get_build_time( void ) | ||
{ | ||
return vchiq_build_time; | ||
} | ||
EOF |
189 changes: 189 additions & 0 deletions
189
drivers/misc/vc04_services/interface/vchiq_arm/vchiq_if.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
/** | ||
* Copyright (c) 2010-2012 Broadcom. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions, and the following disclaimer, | ||
* without modification. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. The names of the above-listed copyright holders may not be used | ||
* to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* ALTERNATIVELY, this software may be distributed under the terms of the | ||
* GNU General Public License ("GPL") version 2, as published by the Free | ||
* Software Foundation. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef VCHIQ_IF_H | ||
#define VCHIQ_IF_H | ||
|
||
#include "interface/vchi/vchi_mh.h" | ||
|
||
#define VCHIQ_SERVICE_HANDLE_INVALID 0 | ||
|
||
#define VCHIQ_SLOT_SIZE 4096 | ||
#define VCHIQ_MAX_MSG_SIZE (VCHIQ_SLOT_SIZE - sizeof(VCHIQ_HEADER_T)) | ||
#define VCHIQ_CHANNEL_SIZE VCHIQ_MAX_MSG_SIZE /* For backwards compatibility */ | ||
|
||
#define VCHIQ_MAKE_FOURCC(x0, x1, x2, x3) \ | ||
(((x0) << 24) | ((x1) << 16) | ((x2) << 8) | (x3)) | ||
#define VCHIQ_GET_SERVICE_USERDATA(service) vchiq_get_service_userdata(service) | ||
#define VCHIQ_GET_SERVICE_FOURCC(service) vchiq_get_service_fourcc(service) | ||
|
||
typedef enum { | ||
VCHIQ_SERVICE_OPENED, /* service, -, - */ | ||
VCHIQ_SERVICE_CLOSED, /* service, -, - */ | ||
VCHIQ_MESSAGE_AVAILABLE, /* service, header, - */ | ||
VCHIQ_BULK_TRANSMIT_DONE, /* service, -, bulk_userdata */ | ||
VCHIQ_BULK_RECEIVE_DONE, /* service, -, bulk_userdata */ | ||
VCHIQ_BULK_TRANSMIT_ABORTED, /* service, -, bulk_userdata */ | ||
VCHIQ_BULK_RECEIVE_ABORTED /* service, -, bulk_userdata */ | ||
} VCHIQ_REASON_T; | ||
|
||
typedef enum { | ||
VCHIQ_ERROR = -1, | ||
VCHIQ_SUCCESS = 0, | ||
VCHIQ_RETRY = 1 | ||
} VCHIQ_STATUS_T; | ||
|
||
typedef enum { | ||
VCHIQ_BULK_MODE_CALLBACK, | ||
VCHIQ_BULK_MODE_BLOCKING, | ||
VCHIQ_BULK_MODE_NOCALLBACK, | ||
VCHIQ_BULK_MODE_WAITING /* Reserved for internal use */ | ||
} VCHIQ_BULK_MODE_T; | ||
|
||
typedef enum { | ||
VCHIQ_SERVICE_OPTION_AUTOCLOSE, | ||
VCHIQ_SERVICE_OPTION_SLOT_QUOTA, | ||
VCHIQ_SERVICE_OPTION_MESSAGE_QUOTA, | ||
VCHIQ_SERVICE_OPTION_SYNCHRONOUS, | ||
VCHIQ_SERVICE_OPTION_TRACE | ||
} VCHIQ_SERVICE_OPTION_T; | ||
|
||
typedef struct vchiq_header_struct { | ||
/* The message identifier - opaque to applications. */ | ||
int msgid; | ||
|
||
/* Size of message data. */ | ||
unsigned int size; | ||
|
||
char data[0]; /* message */ | ||
} VCHIQ_HEADER_T; | ||
|
||
typedef struct { | ||
const void *data; | ||
unsigned int size; | ||
} VCHIQ_ELEMENT_T; | ||
|
||
typedef unsigned int VCHIQ_SERVICE_HANDLE_T; | ||
|
||
typedef VCHIQ_STATUS_T (*VCHIQ_CALLBACK_T)(VCHIQ_REASON_T, VCHIQ_HEADER_T *, | ||
VCHIQ_SERVICE_HANDLE_T, void *); | ||
|
||
typedef struct vchiq_service_base_struct { | ||
int fourcc; | ||
VCHIQ_CALLBACK_T callback; | ||
void *userdata; | ||
} VCHIQ_SERVICE_BASE_T; | ||
|
||
typedef struct vchiq_service_params_struct { | ||
int fourcc; | ||
VCHIQ_CALLBACK_T callback; | ||
void *userdata; | ||
short version; /* Increment for non-trivial changes */ | ||
short version_min; /* Update for incompatible changes */ | ||
} VCHIQ_SERVICE_PARAMS_T; | ||
|
||
typedef struct vchiq_config_struct { | ||
unsigned int max_msg_size; | ||
unsigned int bulk_threshold; /* The message size above which it | ||
is better to use a bulk transfer | ||
(<= max_msg_size) */ | ||
unsigned int max_outstanding_bulks; | ||
unsigned int max_services; | ||
short version; /* The version of VCHIQ */ | ||
short version_min; /* The minimum compatible version of VCHIQ */ | ||
} VCHIQ_CONFIG_T; | ||
|
||
typedef struct vchiq_instance_struct *VCHIQ_INSTANCE_T; | ||
typedef void (*VCHIQ_REMOTE_USE_CALLBACK_T)(void *cb_arg); | ||
|
||
extern VCHIQ_STATUS_T vchiq_initialise(VCHIQ_INSTANCE_T *pinstance); | ||
extern VCHIQ_STATUS_T vchiq_shutdown(VCHIQ_INSTANCE_T instance); | ||
extern VCHIQ_STATUS_T vchiq_connect(VCHIQ_INSTANCE_T instance); | ||
extern VCHIQ_STATUS_T vchiq_add_service(VCHIQ_INSTANCE_T instance, | ||
const VCHIQ_SERVICE_PARAMS_T *params, | ||
VCHIQ_SERVICE_HANDLE_T *pservice); | ||
extern VCHIQ_STATUS_T vchiq_open_service(VCHIQ_INSTANCE_T instance, | ||
const VCHIQ_SERVICE_PARAMS_T *params, | ||
VCHIQ_SERVICE_HANDLE_T *pservice); | ||
extern VCHIQ_STATUS_T vchiq_close_service(VCHIQ_SERVICE_HANDLE_T service); | ||
extern VCHIQ_STATUS_T vchiq_remove_service(VCHIQ_SERVICE_HANDLE_T service); | ||
extern VCHIQ_STATUS_T vchiq_use_service(VCHIQ_SERVICE_HANDLE_T service); | ||
extern VCHIQ_STATUS_T vchiq_use_service_no_resume( | ||
VCHIQ_SERVICE_HANDLE_T service); | ||
extern VCHIQ_STATUS_T vchiq_release_service(VCHIQ_SERVICE_HANDLE_T service); | ||
|
||
extern VCHIQ_STATUS_T vchiq_queue_message(VCHIQ_SERVICE_HANDLE_T service, | ||
const VCHIQ_ELEMENT_T *elements, unsigned int count); | ||
extern void vchiq_release_message(VCHIQ_SERVICE_HANDLE_T service, | ||
VCHIQ_HEADER_T *header); | ||
extern VCHIQ_STATUS_T vchiq_queue_bulk_transmit(VCHIQ_SERVICE_HANDLE_T service, | ||
const void *data, unsigned int size, void *userdata); | ||
extern VCHIQ_STATUS_T vchiq_queue_bulk_receive(VCHIQ_SERVICE_HANDLE_T service, | ||
void *data, unsigned int size, void *userdata); | ||
extern VCHIQ_STATUS_T vchiq_queue_bulk_transmit_handle( | ||
VCHIQ_SERVICE_HANDLE_T service, VCHI_MEM_HANDLE_T handle, | ||
const void *offset, unsigned int size, void *userdata); | ||
extern VCHIQ_STATUS_T vchiq_queue_bulk_receive_handle( | ||
VCHIQ_SERVICE_HANDLE_T service, VCHI_MEM_HANDLE_T handle, | ||
void *offset, unsigned int size, void *userdata); | ||
extern VCHIQ_STATUS_T vchiq_bulk_transmit(VCHIQ_SERVICE_HANDLE_T service, | ||
const void *data, unsigned int size, void *userdata, | ||
VCHIQ_BULK_MODE_T mode); | ||
extern VCHIQ_STATUS_T vchiq_bulk_receive(VCHIQ_SERVICE_HANDLE_T service, | ||
void *data, unsigned int size, void *userdata, | ||
VCHIQ_BULK_MODE_T mode); | ||
extern VCHIQ_STATUS_T vchiq_bulk_transmit_handle(VCHIQ_SERVICE_HANDLE_T service, | ||
VCHI_MEM_HANDLE_T handle, const void *offset, unsigned int size, | ||
void *userdata, VCHIQ_BULK_MODE_T mode); | ||
extern VCHIQ_STATUS_T vchiq_bulk_receive_handle(VCHIQ_SERVICE_HANDLE_T service, | ||
VCHI_MEM_HANDLE_T handle, void *offset, unsigned int size, | ||
void *userdata, VCHIQ_BULK_MODE_T mode); | ||
extern int vchiq_get_client_id(VCHIQ_SERVICE_HANDLE_T service); | ||
extern void *vchiq_get_service_userdata(VCHIQ_SERVICE_HANDLE_T service); | ||
extern int vchiq_get_service_fourcc(VCHIQ_SERVICE_HANDLE_T service); | ||
extern VCHIQ_STATUS_T vchiq_get_config(VCHIQ_INSTANCE_T instance, | ||
int config_size, VCHIQ_CONFIG_T *pconfig); | ||
extern VCHIQ_STATUS_T vchiq_set_service_option(VCHIQ_SERVICE_HANDLE_T service, | ||
VCHIQ_SERVICE_OPTION_T option, int value); | ||
|
||
extern VCHIQ_STATUS_T vchiq_remote_use(VCHIQ_INSTANCE_T instance, | ||
VCHIQ_REMOTE_USE_CALLBACK_T callback, void *cb_arg); | ||
extern VCHIQ_STATUS_T vchiq_remote_release(VCHIQ_INSTANCE_T instance); | ||
|
||
extern VCHIQ_STATUS_T vchiq_dump_phys_mem(VCHIQ_SERVICE_HANDLE_T service, | ||
void *ptr, size_t num_bytes); | ||
|
||
extern VCHIQ_STATUS_T vchiq_get_peer_version(VCHIQ_SERVICE_HANDLE_T handle, | ||
short *peer_version); | ||
|
||
#endif /* VCHIQ_IF_H */ |
131 changes: 131 additions & 0 deletions
131
drivers/misc/vc04_services/interface/vchiq_arm/vchiq_ioctl.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
/** | ||
* Copyright (c) 2010-2012 Broadcom. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions, and the following disclaimer, | ||
* without modification. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. The names of the above-listed copyright holders may not be used | ||
* to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* ALTERNATIVELY, this software may be distributed under the terms of the | ||
* GNU General Public License ("GPL") version 2, as published by the Free | ||
* Software Foundation. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef VCHIQ_IOCTLS_H | ||
#define VCHIQ_IOCTLS_H | ||
|
||
#include <linux/ioctl.h> | ||
#include "vchiq_if.h" | ||
|
||
#define VCHIQ_IOC_MAGIC 0xc4 | ||
#define VCHIQ_INVALID_HANDLE (~0) | ||
|
||
typedef struct { | ||
VCHIQ_SERVICE_PARAMS_T params; | ||
int is_open; | ||
int is_vchi; | ||
unsigned int handle; /* OUT */ | ||
} VCHIQ_CREATE_SERVICE_T; | ||
|
||
typedef struct { | ||
unsigned int handle; | ||
unsigned int count; | ||
const VCHIQ_ELEMENT_T *elements; | ||
} VCHIQ_QUEUE_MESSAGE_T; | ||
|
||
typedef struct { | ||
unsigned int handle; | ||
void *data; | ||
unsigned int size; | ||
void *userdata; | ||
VCHIQ_BULK_MODE_T mode; | ||
} VCHIQ_QUEUE_BULK_TRANSFER_T; | ||
|
||
typedef struct { | ||
VCHIQ_REASON_T reason; | ||
VCHIQ_HEADER_T *header; | ||
void *service_userdata; | ||
void *bulk_userdata; | ||
} VCHIQ_COMPLETION_DATA_T; | ||
|
||
typedef struct { | ||
unsigned int count; | ||
VCHIQ_COMPLETION_DATA_T *buf; | ||
unsigned int msgbufsize; | ||
unsigned int msgbufcount; /* IN/OUT */ | ||
void **msgbufs; | ||
} VCHIQ_AWAIT_COMPLETION_T; | ||
|
||
typedef struct { | ||
unsigned int handle; | ||
int blocking; | ||
unsigned int bufsize; | ||
void *buf; | ||
} VCHIQ_DEQUEUE_MESSAGE_T; | ||
|
||
typedef struct { | ||
unsigned int config_size; | ||
VCHIQ_CONFIG_T *pconfig; | ||
} VCHIQ_GET_CONFIG_T; | ||
|
||
typedef struct { | ||
unsigned int handle; | ||
VCHIQ_SERVICE_OPTION_T option; | ||
int value; | ||
} VCHIQ_SET_SERVICE_OPTION_T; | ||
|
||
typedef struct { | ||
void *virt_addr; | ||
size_t num_bytes; | ||
} VCHIQ_DUMP_MEM_T; | ||
|
||
#define VCHIQ_IOC_CONNECT _IO(VCHIQ_IOC_MAGIC, 0) | ||
#define VCHIQ_IOC_SHUTDOWN _IO(VCHIQ_IOC_MAGIC, 1) | ||
#define VCHIQ_IOC_CREATE_SERVICE \ | ||
_IOWR(VCHIQ_IOC_MAGIC, 2, VCHIQ_CREATE_SERVICE_T) | ||
#define VCHIQ_IOC_REMOVE_SERVICE _IO(VCHIQ_IOC_MAGIC, 3) | ||
#define VCHIQ_IOC_QUEUE_MESSAGE \ | ||
_IOW(VCHIQ_IOC_MAGIC, 4, VCHIQ_QUEUE_MESSAGE_T) | ||
#define VCHIQ_IOC_QUEUE_BULK_TRANSMIT \ | ||
_IOWR(VCHIQ_IOC_MAGIC, 5, VCHIQ_QUEUE_BULK_TRANSFER_T) | ||
#define VCHIQ_IOC_QUEUE_BULK_RECEIVE \ | ||
_IOWR(VCHIQ_IOC_MAGIC, 6, VCHIQ_QUEUE_BULK_TRANSFER_T) | ||
#define VCHIQ_IOC_AWAIT_COMPLETION \ | ||
_IOWR(VCHIQ_IOC_MAGIC, 7, VCHIQ_AWAIT_COMPLETION_T) | ||
#define VCHIQ_IOC_DEQUEUE_MESSAGE \ | ||
_IOWR(VCHIQ_IOC_MAGIC, 8, VCHIQ_DEQUEUE_MESSAGE_T) | ||
#define VCHIQ_IOC_GET_CLIENT_ID _IO(VCHIQ_IOC_MAGIC, 9) | ||
#define VCHIQ_IOC_GET_CONFIG \ | ||
_IOWR(VCHIQ_IOC_MAGIC, 10, VCHIQ_GET_CONFIG_T) | ||
#define VCHIQ_IOC_CLOSE_SERVICE _IO(VCHIQ_IOC_MAGIC, 11) | ||
#define VCHIQ_IOC_USE_SERVICE _IO(VCHIQ_IOC_MAGIC, 12) | ||
#define VCHIQ_IOC_RELEASE_SERVICE _IO(VCHIQ_IOC_MAGIC, 13) | ||
#define VCHIQ_IOC_SET_SERVICE_OPTION \ | ||
_IOW(VCHIQ_IOC_MAGIC, 14, VCHIQ_SET_SERVICE_OPTION_T) | ||
#define VCHIQ_IOC_DUMP_PHYS_MEM \ | ||
_IOW(VCHIQ_IOC_MAGIC, 15, VCHIQ_DUMP_MEM_T) | ||
#define VCHIQ_IOC_LIB_VERSION _IO(VCHIQ_IOC_MAGIC, 16) | ||
#define VCHIQ_IOC_CLOSE_DELIVERED _IO(VCHIQ_IOC_MAGIC, 17) | ||
#define VCHIQ_IOC_MAX 17 | ||
|
||
#endif |
458 changes: 458 additions & 0 deletions
458
drivers/misc/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c
Large diffs are not rendered by default.
Oops, something went wrong.
69 changes: 69 additions & 0 deletions
69
drivers/misc/vc04_services/interface/vchiq_arm/vchiq_killable.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* Copyright (c) 2010-2012 Broadcom. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions, and the following disclaimer, | ||
* without modification. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. The names of the above-listed copyright holders may not be used | ||
* to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* ALTERNATIVELY, this software may be distributed under the terms of the | ||
* GNU General Public License ("GPL") version 2, as published by the Free | ||
* Software Foundation. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef VCHIQ_KILLABLE_H | ||
#define VCHIQ_KILLABLE_H | ||
|
||
#include <linux/mutex.h> | ||
#include <linux/semaphore.h> | ||
|
||
#define SHUTDOWN_SIGS (sigmask(SIGKILL) | sigmask(SIGINT) | sigmask(SIGQUIT) | sigmask(SIGTRAP) | sigmask(SIGSTOP) | sigmask(SIGCONT)) | ||
|
||
static inline int __must_check down_interruptible_killable(struct semaphore *sem) | ||
{ | ||
/* Allow interception of killable signals only. We don't want to be interrupted by harmless signals like SIGALRM */ | ||
int ret; | ||
sigset_t blocked, oldset; | ||
siginitsetinv(&blocked, SHUTDOWN_SIGS); | ||
sigprocmask(SIG_SETMASK, &blocked, &oldset); | ||
ret = down_interruptible(sem); | ||
sigprocmask(SIG_SETMASK, &oldset, NULL); | ||
return ret; | ||
} | ||
#define down_interruptible down_interruptible_killable | ||
|
||
|
||
static inline int __must_check mutex_lock_interruptible_killable(struct mutex *lock) | ||
{ | ||
/* Allow interception of killable signals only. We don't want to be interrupted by harmless signals like SIGALRM */ | ||
int ret; | ||
sigset_t blocked, oldset; | ||
siginitsetinv(&blocked, SHUTDOWN_SIGS); | ||
sigprocmask(SIG_SETMASK, &blocked, &oldset); | ||
ret = mutex_lock_interruptible(lock); | ||
sigprocmask(SIG_SETMASK, &oldset, NULL); | ||
return ret; | ||
} | ||
#define mutex_lock_interruptible mutex_lock_interruptible_killable | ||
|
||
#endif |
71 changes: 71 additions & 0 deletions
71
drivers/misc/vc04_services/interface/vchiq_arm/vchiq_memdrv.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
* Copyright (c) 2010-2012 Broadcom. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions, and the following disclaimer, | ||
* without modification. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. The names of the above-listed copyright holders may not be used | ||
* to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* ALTERNATIVELY, this software may be distributed under the terms of the | ||
* GNU General Public License ("GPL") version 2, as published by the Free | ||
* Software Foundation. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef VCHIQ_MEMDRV_H | ||
#define VCHIQ_MEMDRV_H | ||
|
||
/* ---- Include Files ----------------------------------------------------- */ | ||
|
||
#include <linux/kernel.h> | ||
#include "vchiq_if.h" | ||
|
||
/* ---- Constants and Types ---------------------------------------------- */ | ||
|
||
typedef struct { | ||
void *armSharedMemVirt; | ||
dma_addr_t armSharedMemPhys; | ||
size_t armSharedMemSize; | ||
|
||
void *vcSharedMemVirt; | ||
dma_addr_t vcSharedMemPhys; | ||
size_t vcSharedMemSize; | ||
} VCHIQ_SHARED_MEM_INFO_T; | ||
|
||
/* ---- Variable Externs ------------------------------------------------- */ | ||
|
||
/* ---- Function Prototypes ---------------------------------------------- */ | ||
|
||
void vchiq_get_shared_mem_info(VCHIQ_SHARED_MEM_INFO_T *info); | ||
|
||
VCHIQ_STATUS_T vchiq_memdrv_initialise(void); | ||
|
||
VCHIQ_STATUS_T vchiq_userdrv_create_instance( | ||
const VCHIQ_PLATFORM_DATA_T * platform_data); | ||
|
||
VCHIQ_STATUS_T vchiq_userdrv_suspend( | ||
const VCHIQ_PLATFORM_DATA_T * platform_data); | ||
|
||
VCHIQ_STATUS_T vchiq_userdrv_resume( | ||
const VCHIQ_PLATFORM_DATA_T * platform_data); | ||
|
||
#endif |
58 changes: 58 additions & 0 deletions
58
drivers/misc/vc04_services/interface/vchiq_arm/vchiq_pagelist.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* Copyright (c) 2010-2012 Broadcom. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions, and the following disclaimer, | ||
* without modification. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. The names of the above-listed copyright holders may not be used | ||
* to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* ALTERNATIVELY, this software may be distributed under the terms of the | ||
* GNU General Public License ("GPL") version 2, as published by the Free | ||
* Software Foundation. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef VCHIQ_PAGELIST_H | ||
#define VCHIQ_PAGELIST_H | ||
|
||
#ifndef PAGE_SIZE | ||
#define PAGE_SIZE 4096 | ||
#endif | ||
#define CACHE_LINE_SIZE 32 | ||
#define PAGELIST_WRITE 0 | ||
#define PAGELIST_READ 1 | ||
#define PAGELIST_READ_WITH_FRAGMENTS 2 | ||
|
||
typedef struct pagelist_struct { | ||
unsigned long length; | ||
unsigned short type; | ||
unsigned short offset; | ||
unsigned long addrs[1]; /* N.B. 12 LSBs hold the number of following | ||
pages at consecutive addresses. */ | ||
} PAGELIST_T; | ||
|
||
typedef struct fragments_struct { | ||
char headbuf[CACHE_LINE_SIZE]; | ||
char tailbuf[CACHE_LINE_SIZE]; | ||
} FRAGMENTS_T; | ||
|
||
#endif /* VCHIQ_PAGELIST_H */ |
860 changes: 860 additions & 0 deletions
860
drivers/misc/vc04_services/interface/vchiq_arm/vchiq_shim.c
Large diffs are not rendered by default.
Oops, something went wrong.
156 changes: 156 additions & 0 deletions
156
drivers/misc/vc04_services/interface/vchiq_arm/vchiq_util.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
/** | ||
* Copyright (c) 2010-2012 Broadcom. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions, and the following disclaimer, | ||
* without modification. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. The names of the above-listed copyright holders may not be used | ||
* to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* ALTERNATIVELY, this software may be distributed under the terms of the | ||
* GNU General Public License ("GPL") version 2, as published by the Free | ||
* Software Foundation. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#include "vchiq_util.h" | ||
#include "vchiq_killable.h" | ||
|
||
static inline int is_pow2(int i) | ||
{ | ||
return i && !(i & (i - 1)); | ||
} | ||
|
||
int vchiu_queue_init(VCHIU_QUEUE_T *queue, int size) | ||
{ | ||
WARN_ON(!is_pow2(size)); | ||
|
||
queue->size = size; | ||
queue->read = 0; | ||
queue->write = 0; | ||
queue->initialized = 1; | ||
|
||
sema_init(&queue->pop, 0); | ||
sema_init(&queue->push, 0); | ||
|
||
queue->storage = kzalloc(size * sizeof(VCHIQ_HEADER_T *), GFP_KERNEL); | ||
if (queue->storage == NULL) { | ||
vchiu_queue_delete(queue); | ||
return 0; | ||
} | ||
return 1; | ||
} | ||
|
||
void vchiu_queue_delete(VCHIU_QUEUE_T *queue) | ||
{ | ||
if (queue->storage != NULL) | ||
kfree(queue->storage); | ||
} | ||
|
||
int vchiu_queue_is_empty(VCHIU_QUEUE_T *queue) | ||
{ | ||
return queue->read == queue->write; | ||
} | ||
|
||
int vchiu_queue_is_full(VCHIU_QUEUE_T *queue) | ||
{ | ||
return queue->write == queue->read + queue->size; | ||
} | ||
|
||
void vchiu_queue_push(VCHIU_QUEUE_T *queue, VCHIQ_HEADER_T *header) | ||
{ | ||
if (!queue->initialized) | ||
return; | ||
|
||
while (queue->write == queue->read + queue->size) { | ||
if (down_interruptible(&queue->pop) != 0) { | ||
flush_signals(current); | ||
} | ||
} | ||
|
||
/* | ||
* Write to queue->storage must be visible after read from | ||
* queue->read | ||
*/ | ||
smp_mb(); | ||
|
||
queue->storage[queue->write & (queue->size - 1)] = header; | ||
|
||
/* | ||
* Write to queue->storage must be visible before write to | ||
* queue->write | ||
*/ | ||
smp_wmb(); | ||
|
||
queue->write++; | ||
|
||
up(&queue->push); | ||
} | ||
|
||
VCHIQ_HEADER_T *vchiu_queue_peek(VCHIU_QUEUE_T *queue) | ||
{ | ||
while (queue->write == queue->read) { | ||
if (down_interruptible(&queue->push) != 0) { | ||
flush_signals(current); | ||
} | ||
} | ||
|
||
up(&queue->push); // We haven't removed anything from the queue. | ||
|
||
/* | ||
* Read from queue->storage must be visible after read from | ||
* queue->write | ||
*/ | ||
smp_rmb(); | ||
|
||
return queue->storage[queue->read & (queue->size - 1)]; | ||
} | ||
|
||
VCHIQ_HEADER_T *vchiu_queue_pop(VCHIU_QUEUE_T *queue) | ||
{ | ||
VCHIQ_HEADER_T *header; | ||
|
||
while (queue->write == queue->read) { | ||
if (down_interruptible(&queue->push) != 0) { | ||
flush_signals(current); | ||
} | ||
} | ||
|
||
/* | ||
* Read from queue->storage must be visible after read from | ||
* queue->write | ||
*/ | ||
smp_rmb(); | ||
|
||
header = queue->storage[queue->read & (queue->size - 1)]; | ||
|
||
/* | ||
* Read from queue->storage must be visible before write to | ||
* queue->read | ||
*/ | ||
smp_mb(); | ||
|
||
queue->read++; | ||
|
||
up(&queue->pop); | ||
|
||
return header; | ||
} |
82 changes: 82 additions & 0 deletions
82
drivers/misc/vc04_services/interface/vchiq_arm/vchiq_util.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/** | ||
* Copyright (c) 2010-2012 Broadcom. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions, and the following disclaimer, | ||
* without modification. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. The names of the above-listed copyright holders may not be used | ||
* to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* ALTERNATIVELY, this software may be distributed under the terms of the | ||
* GNU General Public License ("GPL") version 2, as published by the Free | ||
* Software Foundation. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef VCHIQ_UTIL_H | ||
#define VCHIQ_UTIL_H | ||
|
||
#include <linux/types.h> | ||
#include <linux/semaphore.h> | ||
#include <linux/mutex.h> | ||
#include <linux/bitops.h> | ||
#include <linux/kthread.h> | ||
#include <linux/wait.h> | ||
#include <linux/vmalloc.h> | ||
#include <linux/jiffies.h> | ||
#include <linux/delay.h> | ||
#include <linux/string.h> | ||
#include <linux/types.h> | ||
#include <linux/interrupt.h> | ||
#include <linux/random.h> | ||
#include <linux/sched.h> | ||
#include <linux/ctype.h> | ||
#include <linux/uaccess.h> | ||
#include <linux/time.h> /* for time_t */ | ||
#include <linux/slab.h> | ||
#include <linux/vmalloc.h> | ||
|
||
#include "vchiq_if.h" | ||
|
||
typedef struct { | ||
int size; | ||
int read; | ||
int write; | ||
int initialized; | ||
|
||
struct semaphore pop; | ||
struct semaphore push; | ||
|
||
VCHIQ_HEADER_T **storage; | ||
} VCHIU_QUEUE_T; | ||
|
||
extern int vchiu_queue_init(VCHIU_QUEUE_T *queue, int size); | ||
extern void vchiu_queue_delete(VCHIU_QUEUE_T *queue); | ||
|
||
extern int vchiu_queue_is_empty(VCHIU_QUEUE_T *queue); | ||
extern int vchiu_queue_is_full(VCHIU_QUEUE_T *queue); | ||
|
||
extern void vchiu_queue_push(VCHIU_QUEUE_T *queue, VCHIQ_HEADER_T *header); | ||
|
||
extern VCHIQ_HEADER_T *vchiu_queue_peek(VCHIU_QUEUE_T *queue); | ||
extern VCHIQ_HEADER_T *vchiu_queue_pop(VCHIU_QUEUE_T *queue); | ||
|
||
#endif |
59 changes: 59 additions & 0 deletions
59
drivers/misc/vc04_services/interface/vchiq_arm/vchiq_version.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* Copyright (c) 2010-2012 Broadcom. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions, and the following disclaimer, | ||
* without modification. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. The names of the above-listed copyright holders may not be used | ||
* to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* ALTERNATIVELY, this software may be distributed under the terms of the | ||
* GNU General Public License ("GPL") version 2, as published by the Free | ||
* Software Foundation. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
#include "vchiq_build_info.h" | ||
#include <linux/broadcom/vc_debug_sym.h> | ||
|
||
VC_DEBUG_DECLARE_STRING_VAR( vchiq_build_hostname, "dc4-arm-01" ); | ||
VC_DEBUG_DECLARE_STRING_VAR( vchiq_build_version, "9245b4c35b99b3870e1f7dc598c5692b3c66a6f0 (tainted)" ); | ||
VC_DEBUG_DECLARE_STRING_VAR( vchiq_build_time, __TIME__ ); | ||
VC_DEBUG_DECLARE_STRING_VAR( vchiq_build_date, __DATE__ ); | ||
|
||
const char *vchiq_get_build_hostname( void ) | ||
{ | ||
return vchiq_build_hostname; | ||
} | ||
|
||
const char *vchiq_get_build_version( void ) | ||
{ | ||
return vchiq_build_version; | ||
} | ||
|
||
const char *vchiq_get_build_date( void ) | ||
{ | ||
return vchiq_build_date; | ||
} | ||
|
||
const char *vchiq_get_build_time( void ) | ||
{ | ||
return vchiq_build_time; | ||
} |