The NvDVMS_Client library provides an interface to set and get the VM state from the VM State Manager.
Functions | |
| NvDvmsStatus | nvdvms_set_vm_state (NvDvmsState state) |
| Set VM state from application. More... | |
| NvDvmsStatus | nvdvms_get_vm_state (NvDvmsState *state) |
| Get VM's current state. More... | |
| NvDvmsStatus | nvdvms_get_power_profile (NvDvmsVmOp *profile) |
| Get(/Read) VM's current power profile. More... | |
| NvDvmsStatus | nvdvms_set_power_profile (NvDvmsVmOp profile) |
| Set VM power profile as requested by application. More... | |
| NvDvmsStatus | nvdvms_check_init_api (void) |
| Checks whether an Init Mode API can be called in the current VM state. More... | |
| NvDvmsStatus | nvdvms_check_deinit_api (void) |
| Checks whether a DeInit Mode API can be called in the current VM state. More... | |
| NvDvmsStatus | nvdvms_init (void) |
| Initializes NvDVMS client library. More... | |
| NvDvmsStatus | nvdvms_deinit (void) |
| De-Initialize nvdvms client library. More... | |
QNX Implementation: Description of custom abilities
1) The Nvdvms/ClientCommSetState ability provides access to the nvdvms_set_vm_state() APIs.
2) The Nvdvms/ClientCommGetState ability provides access to the nvdvms_check_init_api(), nvdvms_get_vm_state() and nvdvms_check_deinit_api() APIs.
Common privileges required for NvDVMS_Client_API (QNX):
Linux Implementation: Linux has a security configuration tool that exposes functional classes for the nvdvms_client library:
1) The NVDVMS_PRIV_CLASS functional class provides access to privileged actions:
nvdvms_set_vm_state() - Set VM state transitionsnvdvms_set_power_profile() - Set power profile changes2) The NVDVMS_UNPRIV_CLASS functional class provides access to unprivileged operations:
nvdvms_get_vm_state() - Get current VM statenvdvms_get_power_profile() - Get current power profilenvdvms_check_init_api() - Check if Init Mode API can be callednvdvms_check_deinit_api() - Check if DeInit Mode API can be calledClients with NVDVMS_UNPRIV_CLASS access cannot perform set_vm_state() and set_power_profile() operations.
Common privileges required for NvDVMS_Client_API (Linux):
| NvDvmsStatus nvdvms_check_deinit_api | ( | void | ) |
Checks whether a DeInit Mode API can be called in the current VM state.
Usage considerations
| NvDvmsStatus nvdvms_check_init_api | ( | void | ) |
Checks whether an Init Mode API can be called in the current VM state.
Usage considerations
| NvDvmsStatus nvdvms_deinit | ( | void | ) |
De-Initialize nvdvms client library.
This API closes file descriptor and revoke Shared memory with NvDVMS resource manager.
In case multiple DeInit calls are made from the same application, only the last deinit call (with a corresponding Init call) will do the required deinit, while all previous calls just return success. Any deinit call without a corresponding init call will return failure.
Usage considerations
| NvDvmsStatus nvdvms_get_power_profile | ( | NvDvmsVmOp * | profile | ) |
Get(/Read) VM's current power profile.
QNX Implementation: This function is used to get VM power profile. Shared Memory setup with resource manager is established in library constructor.
Linux Implementation: This function is used to get VM power profile. Shared Memory setup with nvdvms_server is established during nvdvms_init()
During boot/post successful completion of boot sequence, VM shall be in default power profile i.e 'NVDVMS_VM_OP_0' mode.
| [out] | profile | A pointer to hold VM's current power profile. 'profile' is updated only when the API returns NvDvmsSuccess. Valid profiles that can be returned: NVDVMS_VM_OP_x (x ranges from 0 to 63) |
Usage considerations
| NvDvmsStatus nvdvms_get_vm_state | ( | NvDvmsState * | state | ) |
Get VM's current state.
QNX Implementation: This function is used to get VM state. Communication channel and shared memory setup with resource manager is established in library constructor.
Application shall use this API to implement polling for VM state, until VM transition to NVDVMS_INIT_DONE state is not completed.
During boot of DRIVEOS, VM state is NVDVMS_INIT.
Post successful completion of boot sequence of DRIVEOS,VM state is set to NVDVMS_INIT_DONE. Default timeout for setting NVDVMS_INIT_DONE is 3000ms, which can be modified from device tree.
Linux Implementation: This function is used to get VM state. Communication channel and shared memory setup with server is established during nvdvms_init()
NVDVMS_INIT state is set by nvdvms_server during DriveOS boot.
Post successful completion of nvdvms_server initialization sequence, VM state is set to NVDVMS_INIT_DONE.
Application shall use this API to implement polling for VM state, until VM transition to NVDVMS_INIT_DONE state is not completed.
| [out] | state | A pointer to hold VM's current state. The value in state is set only when nvdvms_get_vm_state returns NvDvmsSuccess. Valid states that can be returned: NVDVMS_INIT = 1 NVDVMS_INIT_DONE = 2 NVDVMS_OPERATIONAL_START = 3 NVDVMS_OPERATIONAL = 4 NVDVMS_SUSPEND_START = 5 NVDVMS_RESUME_START = 7 NVDVMS_DEINIT_PREPARE = 10 NVDVMS_DEINIT_START = 11 |
Usage considerations
| NvDvmsStatus nvdvms_init | ( | void | ) |
Initializes NvDVMS client library.
This API setup the shared memory with NvDVMS resource manager.
In case multiple Init calls are made from the same application, only the first call does the required initialisation, while rest of the API calls just return success, without performing any initialisation.
Usage considerations
| NvDvmsStatus nvdvms_set_power_profile | ( | NvDvmsVmOp | profile | ) |
Set VM power profile as requested by application.
QNX Implementation: During all power profile transition, the VM must be in NVDVMS_INIT_DONE state.
Application shall switch to the default power profile configuration i.e. 'NVDVMS_VM_OP_0' before requesting to transition to a different power profile configuration i.e. transition between the non-default power profiles is rejected as invalid transition.
Linux Implementation: Currently Linux NvDVMS supports only suspend, shutdown and cold boot power profiles.
To initiate suspend power profile (NVDVMS_VM_OP_62), VM needs to be in NVDVMS_INIT_DONE state.
To initiate shutdown power profile (NVDVMS_VM_OP_63), VM needs to be in NVDVMS_DEINIT_PREPARE state.
Parallel power profile transition will be rejected, if already a state transition or power profile transition request is in progress.
| [in] | profile | Input VM power profile that the application is pushing Valid profiles that can be set: NVDVMS_VM_OP_x (x ranges from 0 to 63) |
Usage considerations
| NvDvmsStatus nvdvms_set_vm_state | ( | NvDvmsState | state | ) |
Set VM state from application.
QNX Implementation: This function is used to set VM state by making devctl calls to VM state manager device.
During boot of DriveOS, VM state is NVDVMS_INIT.
Post successful completion of boot sequence of DriveOS, VM state is set to NVDVMS_INIT_DONE. Default timeout for setting NVDVMS_INIT_DONE is 3000ms, which can be modified from device tree.
Linux Implementation: This function is used to set VM state by sending messages to the VM state manager(nvdvms_server).
NVDVMS_INIT state is set by nvdvms_server during DriveOS boot.
Post successful init sequence of nvdvms_server, VM state is updated to NVDVMS_INIT_DONE.
Linux Implementation Restrictions The Linux implementation disallows transitions to the following states using nvdvms_set_vm_state():
Common Implementation Behavior: Parallel state transition will be rejected, if already a state transition or power profile transition request is in progress.
Allowed state transitions from application
QNX Implementation: 1. NVDVMS_INIT_DONE --> NVDVMS_OPERATIONAL
For NVDVMS_OPERATIONAL, If any error is encountered during
transition to NVDVMS_OPERATIONAL state, this API returns with
an error code. The error during state transition is also
reported to FSI.
Error code reported:
nvdvms_transition_failure_pid = 0x1a2. NVDVMS_INIT_DONE --> NVDVMS_SUSPEND
For NVDVMS_SUSPEND state, this is a blocking API which returns
only when the VM resumes due to wakeup events. If any generic
error is encountered with VM state machine, API returns with
error code. Once suspend/resume transition starts, any error
encountered is reported to FSI.
Error code reported are:
nvdvms_suspend_drivers_failure = 0x1
nvdvms_suspend_get_shm_failure = 0x2
nvdvms_suspend_transition_start_failure = 0x3
nvdvms_suspend_userspace_failure = 0x4
nvdvms_suspend_system_failure = 0x5
nvdvms_resume_drivers_failure = 0x6
nvdvms_resume_userspace_failure = 0x7
nvdvms_resume_done_failure = 0x8
nvdvms_resume_init_done_failure = 0x9
nvdvms_resume_sem_failure = 0xa
nvdvms_set_suspend_state_failure = 0x14
nvdvms_set_resume_start_state_failure = 0x15
nvdvms_set_resume_state_failure = 0x16
nvdvms_set_suspend_start_state_failure = 0x17
nvdvms_transition_failure_pid = 0x1a
nvdvms_resume_stop_init_done_failure = 0x1b
nvdvms_resume_error_state_failure = 0x1c
nvdvms_mutex_api_failure = 0x1d
nvdvms_resume_get_power_profile_failure = 0x21
nvdvms_resume_update_vm_state_to_sysmgr_failure = 0x223. NVDVMS_INIT_DONE --> NVDVMS_DEINIT_PREPARE 4. NVDVMS_OPERATIONAL --> NVDVMS_DEINIT_PREPARE
NVDVMS_DEINIT_PREPARE is a best effort delivery transition.
Even if failure is encountered, progress will continue to set
VM state to NVDVMS_DEINIT_PREPARE. Error will be reported back
to application. Application should log the error (non-fatal)
and proceed with NVDVMS_DEINIT transition. During this state
transition error is reported to FSI as well.
Error code reported:
nvdvms_transition_failure_pid = 0x1a5. NVDVMS_DEINIT_PREPARE --> NVDVMS_INIT_DONE
This state transition is to support Runtime SC7.
This is required in cases where we would require transition to
Suspend from Operational state. The sequence to be followed is
described below:
a. Transition from NVDVMS_OPERATIONAL to NVDVMS_DEINIT_PREPARE
b. Transition from NVDVMS_DEINIT_PREPARE to NVDVMS_INIT_DONE At this point when all processes have moved to NVDVMS_REINIT_DONE
state, DVMS will set state to NVDVMS_INIT_DONE from where we
could transition to all states allowed.
Error code reported:
nvdvms_transition_failure_pid = 0x1a
nvdvms_process_reinit_failure = 0x1e6. NVDVMS_INIT --> NVDVMS_DEINIT_PREPARE
This state transition should be used when application detects
NVDVMS_INIT_DONE is not reached. NVDVMS_DEINIT_PREPARE is a
best effort delivery transition. Even if failure is encountered,
progress will continue to set VM state to NVDVMS_DEINIT_PREPARE.
Error will be reported back to application. Application should
log the error (non-fatal) and proceed with NVDVMS_DEINIT
transition. During this state transition error is reported to
FSI as well.
Error code reported:
nvdvms_transition_failure_pid = 0x1a7. NVDVMS_DEINIT_PREPARE --> NVDVMS_DEINIT
For NVDVMS_DEINIT state, this API never returns.
NVDVMS_DEINIT state transition means control will never reach
to application. Once NVDVMS_DEINIT transition starts, any error
encountered is reported to FSI.
Error code reported are:
nvdvms_deinit_reg_process_failure = 0xb
nvdvms_deinit_user_process_failure = 0xc
nvdvms_deinit_get_pid_failure = 0xd
nvdvms_deinit_callback_failure = 0xe
nvdvms_deinit_ack_failure = 0xf
nvdvms_deinit_get_shm_failure = 0x10
nvdvms_deinit_transition_start_failure = 0x11
nvdvms_set_deinit_start_state_failure = 0x18
nvdvms_set_deinit_state_failure = 0x19
nvdvms_transition_failure_pid = 0x1aLinux Implementation: 1. NVDVMS_INIT_DONE --> NVDVMS_OPERATIONAL
nvdvms_server updates the VM state to NVDVMS_OPERATIONAL
state.2. NVDVMS_INIT_DONE --> NVDVMS_DEINIT_PREPARE
nvdvms_server updates the VM state to NVDVMS_DEINIT_PREPARE
state.3. NVDVMS_OPERATIONAL --> NVDVMS_DEINIT_PREPARE
nvdvms_server updates the VM state to NVDVMS_DEINIT_PREPARE
state.4. NVDVMS_DEINIT_PREPARE --> NVDVMS_INIT_DONE
nvdvms_server updates the VM state to NVDVMS_INIT_DONE state.
| [in] | state | Input VM state transition which application is pushing. Valid states that can be requested are: NVDVMS_OPERATIONAL = 4 NVDVMS_SUSPEND = 6 (QNX only) NVDVMS_DEINIT_PREPARE = 10 NVDVMS_DEINIT = 12 (QNX only) NVDVMS_REINIT = 15 |
Usage considerations