User manual

72
3.3 Initialization steps
When the structure of the communication contexts is available, it is time to present more
information about the component initialization process. The initialization steps are as
follows:
1. As soon as the CHARON core has finished processing the load command, it creates
the necessary internal structures representing the device and allocates resources for
both the chapi_in and the chapi_out communication context descriptors.
2. The communication context descriptors are all initialized with all zeros.
3. The CHARON core then creates all required private data structures and binds the
communication context to them properly initializing the context field of the chapi_in
communication context descriptor.
4. If the corresponding routines are supported, the CHARON core initializes the
get_license_no, encrypt_data_block, decrypt_data_block, add_config_option, debug_trace and
the log_message(_ex) fields of the chapi_in communication context descriptor, so that the
component initialization routine can use them.
5. As soon as the CHARON core assigns a value to the dll parameter, it loads the .DLL
module, if necessary, and calls the component initialization routine.
6. As soon as the component initialization routine returns, the value returned is checked
against zero. If the value is zero, then the CHARON core considers the initialization as
failed, releases all the so far allocated resources (if any), and reports an error.
Otherwise the CHARON core updates the context field of the chapi_out communication
context descriptor with this value and proceeds with the initialization.
3.4 Run-time execution contexts
The CHAPI is based on a multi-threaded software execution model. This means that
procedures defined by the CHAPI run in different threads. The CHAPI selects the CPU
emulator thread as a special execution context, so that all the procedures invoked in that
thread are invoked in the execution context synchronized to the CPU emulator thread.
The CHAPI restricts the use of certain procedures to the execution context in the following
way:
All the procedures identified by entry points stored in the put_sst, put_irq, clear_irq, and
move_io_space fields of a chapi_in communication context descriptor shall be invoked in
the execution context synchronized to the CPU emulator thread.