20/239 TEE Internal Core API Specification – Public Release v1.1
Copyright
2011-2014 GlobalPlatform, Inc. All Rights Reserved.
The technology provided or described herein is subject to updates, revisions, and extensions by GlobalPlatform. Use of this information is
governed by the GlobalPlatform license agreement and any use inconsistent with that agreement is strictly prohibited.
2.1.2 Instances, Sessions, Tasks, and Commands
When a Client creates a session with a Trusted Application, it connects to an Instance of that Trusted
Application. A Trusted Application instance has physical memory space which is separated from the physical
memory space of all other Trusted Application instances. The Trusted Application instance memory space
holds the Trusted Application instance heap and writable global and static data.
All code executed in a Trusted Application is said to be executed by Tasks. A Task keeps a record of its
execution history (typically realized with a stack) and current execution state. This record is collectively called
a Task context. A Task MUST be created each time the Trusted OS calls an entry point of the Trusted
Application. Once the entry point has returned, an Implementation may recycle a Task to call another entry
point but this MUST appear like a completely new Task was created to call the new entry point.
A Session is used to logically connect multiple commands invoked in a Trusted Application. Each session
has its own state, which typically contains the session context and the context(s) of the Task(s) executing the
session.
A Command is issued within the context of a session and contains a Command Identifier, which is a 32-bit
integer, and four Operation Parameters, which can contain integer values or references to client-owned
shared memory blocks.
It is up to the Trusted Application to define the combinations of commands and their parameters that are
valid to execute. This is outside the scope of this specification.
2.1.3 Sequential Execution of Entry Points
All entry point calls within a given Trusted Application instance are called in sequence, i.e. no more than one
entry point is executed at any point in time. The Trusted Core Framework implementation MUST guarantee
that a commenced entry point call is completed before any new entry point call is allowed to begin execution.
If there is more than one entry point call to complete at any point in time, all but one call MUST be queued by
the Framework. The order in which the Framework queues and picks enqueued calls for execution is
implementation-defined.
It is not possible to execute multiple concurrent commands within a session. The TEE guarantees that a
pending command has completed before a new command is executed.
Since all entry points of a given Trusted Application instance are called in sequence, there is no need to use
any dedicated synchronization mechanisms to maintain consistency of any Trusted Application instance
memory. The sequential execution of entry points inherently guarantees this consistency.
2.1.4 Cancellations
Clients can request the cancellation of open-session and invoke-command operations at any time.
If an operation is requested to be cancelled and has not reached the Trusted Application yet but has been
queued, then the operation is simply retired from the queue.
If the operation has already been transmitted to the Trusted Application, then the task running the operation
is put in the cancelled state. This has an effect on a few “cancellable” functions, such as
TEE_Wait, but this
effect may also be masked by the Trusted Application if it does not want to be affected by client
cancellations. See section 4.10 for more details on how a Trusted Application can handle cancellation
requests and mask their effect.