2.6.1 CoprocBusProtocol protocol

This protocol connects a coprocessor implementation with a CPU component, for instance ARMCortexM33CT.

A coprocessor must derive from the coprocessor callback interface, Coprocessor. It can implement the CDP, MCR, MRC, STC, LDC, MCRR, and MRRC instructions.

A coprocessor must be registered with a specific coprocessor number, by calling the addCoprocessor() method. You can only register an external coprocessor that is not already present in the CPU. If no coprocessor has been registered with the coprocessor number encoded in an instruction, the CPU raises a NOCP fault.

To register coprocessor instruction implementations with the CPU, you must initialize the function pointers. For example, the following code passes the function pointers to the Coprocessor constructor. This code was taken from the $PVLIB_HOME/examples/LISA/FVP_Coproc_Demo example.

Registering a coprocessor

…
    class TestValCoprocessor : public Coprocessor
    {
    public:
        protocol_CoprocBusProtocol * coproc_bus;
        uint32_t coproc_number;
        uint32_t cp_reg[2][NUM_CP_REG] = {{0}}; // [0][NUM_CP_REG] --> Secure, [1][NUM_CP_REG] --> Non-Secure
        TestValCoprocessor()
        : Coprocessor(this, test_CDP, nullptr, test_MCR, nullptr, test_MRC, nullptr, test_LDC, nullptr, test_STC, nullptr, test_MCRR, nullptr, test_MRRC, nullptr)
        , coproc_bus(nullptr)
        , coproc_number(0)
        {
        }
…
    };
        
    PARAMETER { description("coprocessors number"), type(uint32_t), default(0x2), min(0x0), max(16) } coprocessor_number; // CP num
    TestValCoprocessor test_cp;
}

behaviour init
{
…
    if (coproc_bus.addCoprocessor.implemented())
    {
        coproc_bus.addCoprocessor(&test_cp, coprocessor_number);
    }
}

Coprocessor behaviors

A coprocessor can call the following master behaviors:

addCoprocessor(Coprocessor*, int num) : void
Registers the coprocessor with the CPU. num identifies which coprocessor to register it as.
removeCoprocessor(Coprocessor*, int num) : void
Unregisters the coprocessor from the CPU.
accessIsPriv(void) : bool
Checks whether the CPU state is privileged (true) or unprivileged (false).
accessIsNonSecure(void) : bool
Checks the security state of the CPU, either true for non-secure, or false for secure.

Coprocessor callback functions

A coprocessor can implement callback functions with the following signatures.

Each function returns a CoprocState value to indicate the new transaction state of the coprocessor, as listed in CoprocState values.

  • Perform a coprocessor data processing operation.

    CoprocState CDP(void* context, uint32_t inst)

    Parameters:

    context
    context that was registered with the coprocessor interface.
    inst
    the coprocessor instruction being executed.
  • Perform a move to coprocessor register operation.

    CoprocState MCR(void* context, uint32_t inst, uint32_t data)

    Parameters:

    context
    context that was registered with the coprocessor interface.
    inst
    the coprocessor instruction being executed.
    data
    register contents.
  • Perform a move from coprocessor register operation.

    CoprocState MRC(void* context, uint32_t inst, uint32_t* data)

    Parameters:

    context
    context that was registered with the coprocessor interface.
    inst
    the coprocessor instruction being executed.
    data
    pointer to word to fill with coprocessor register contents.
  • Perform a load coprocessor register from memory operation.

    CoprocState LDC(void* context, uint32_t inst, uint32_t data, CoprocState state)

    Parameters:

    context
    context that was registered with the coprocessor interface.
    inst
    the coprocessor instruction being executed.
    data
    contents of current memory location to load into register.
    state
    current state in a sequence of transactions.
  • Perform a store coprocessor register to memory operation.

    CoprocState STC(void* context, uint32_t inst, uint32_t data, CoprocState state)

    Parameters:

    context
    context that was registered with the coprocessor interface.
    inst
    the coprocessor instruction being executed.
    data
    pointer to word to fill with coprocessor register contents to be transferred to memory.
    state
    current state in a sequence of transactions.
  • Perform a move to two coprocessor registers operation.

    CoprocState MCRR(void* context, uint32_t inst, uint32_t data1, uint32_t data2)

    Parameters:

    context
    context that was registered with the coprocessor interface.
    inst
    the coprocessor instruction being executed.
    data1
    first data word to load to a coprocessor register.
    data2
    second data word to load to a coprocessor register.
  • Perform a move from two coprocessor registers operation.

    CoprocState MRRC(void* context, uint32_t inst, uint32_t* data1, uint32_t* data2)

    Parameters:

    context
    context that was registered with the coprocessor interface.
    inst
    the coprocessor instruction being executed.
    data1
    pointer to first word to fill with coprocessor register contents.
    data2
    pointer to second word to fill with coprocessor register contents.

CoprocState values

A CoprocState enum value is returned by coprocessor callback functions to indicate the new transaction state of the coprocessor. It is also used as a parameter for LDC and STC callback functions.

Table 2-5 CoprocState values

Value State label Description
0x0 CoprocOk Complete/Ok.
0x1 CoprocUndef Undefined operation.
0x2 CoprocAbort Data abort.
0x4 CoprocFirst A parameter value for LDC and STC callback functions to indicate that this is the first data transfer in a sequence.
0x5 CoprocNext A parameter value for LDC and STC callback functions to indicate that this is a subsequent data transfer in a sequence.
0x12 CoprocNop Treat as a NOP.
Non-ConfidentialPDF file icon PDF version100964_1180_00_en
Copyright © 2014–2019 Arm Limited or its affiliates. All rights reserved.