blob: 7efd65d2d454d8b614c27249fd9d7855549d55cd [file] [log] [blame] [view]
Mike Leach17610e52016-09-16 15:55:11 +01001Attaching External Custom Decoders {#custom_decoders}
2==================================
3
4@brief A description of the C API external decoder interface.
5
6Introduction
7------------
8
9An external custom decoder is one which decodes a CoreSight trace byte stream from a source other
10than an ARM core which cannot be decoded by the standard builtin decoders within the library.
11
12An example of this may be a trace stream from a DSP device.
13
14The external decoder API allows a suitable decoder to be attached to the library and used in the
15same way as the built-in decoders. This means that the external decoder can be created and destroyed
16using the decode tree API, and will integrate seamlessly with any ARM processor decoders that are part
17of the same tree.
18
19An external decoder will be required to provide two standard structures:-
20
21- `ocsd_extern_dcd_fact_t` : this is a decoder "factory" that allows the creation of the custom decoders.
22- `ocsd_extern_dcd_inst_t` : one of these structures exists for each instance of the custom decoder that is created.
23
24These structures consist of data and function pointers to allow integration with the library infrastructure.
25
26Registering A Decoder
27---------------------
28
29A single API function is provided to allow a decoder to be registered with the library by name.
30
31 ocsd_err_t ocsd_register_custom_decoder(const char *name, ocsd_extern_dcd_fact_t *p_dcd_fact);
32
33This registers the custom decoder with the libary using the supplied name and factory structure.
34Once registered, the standard API functions used with the built-in decoders will work with the custom decoder.
35
36The Factory Structure
37---------------------
38This structure contains the interface that is registered with the library to allow the creation of custom decoder instances.
39
40The mandatory functions that must be provided include:
41- `fnCreateCustomDecoder` : Creates a decoder. This function will fill in a `ocsd_extern_dcd_inst_t` structure for the decoder instance.
42- `fnDestroyCustomDecoder` : Destroys the decoder. Takes the `decoder_handle` attribute of the instance structure.
43- `fnGetCSIDFromConfig` : Extracts the CoreSight Trace ID from the decoder configuration structure.
44 May be called before the create function. The CSID is used as part of the creation process to
45 attach the decoder to the correct trace byte stream.
46
47`fnPacketToString` : This optional function will provide a human readable string from a protocol specific packet structure.
48
49`protocol_id` : This is filled in when the decoder type is registered with the library. Used in some API
50 calls to specify the decoder protocol type.
51
52
53
54The Decoder Instance Structure
55------------------------------
56
57This structure must be filled in by the `fnCreateCustomDecoder` function implmentation.
58
59There is a single mandatory function in this structure:
60
61 `fnTraceDataIn` : the decoder must provide this as this is called by the library to provide the
62 raw trace data to the decoder.
63
64There are a number of optional callback functions. These allow the custom decoder to call into the library
65and use the same infrastructure as the builting decoders. The callbacks are registed with the custom decoder
66as the libary performs initialisation of connections.
67
68For example, the library will connect the error logging interface to all the decoders. The instance structure
69contains the `fnRegisterErrLogCB` function pointer which will register two error logging callbacks with the custom
70decoder, `fnLogErrorCB` and `fnLogMsgCB`. These can then be called by the custom decoder, and the errors and
71messages will appear in the same place as for the built-in decoders.
72
73Where a custom decoder does not require or support the optional callbacks, then the registration function is set to
740 in the structure.
75
76
77
78
79
80