Skip to contentSkip to navigationSkip to topbar
On this page

Notification Functions


(warning)

Microvisor Public Beta

Microvisor is in a pre-release phase and the information contained in this document is subject to change. Some features referenced below may not be fully available until Microvisor's General Availability (GA) release.

Microvisor system calls include the following functions to manage notifications:


Return values and errors

return-values-and-errors page anchor

All of the functions described below return a 32-bit integer that is one of the values from the standard Microvisor enumeration MvStatus. All possible error values for a given system call are provided with each function's description.

Success is always signaled by a return value of zero (MV_STATUS_OKAY).


mvSetupNotifications()

mvsetupnotifications page anchor

Instantiate a notification dispatch center

Declaration

declaration page anchor
1
extern enum MvStatus mvSetupNotifications(const struct MvNotificationSetup *setup,
2
MvNotificationHandle *handle);
ParameterDescription
setupA pointer to non-secure memory in which notification setup data is stored by the application
handleA pointer to non-secure memory into which the notification center handle will be written by Microvisor
Error ValueDescription
MV_STATUS_PARAMETERFAULTparams or handle does not reference memory accessible to the application
MV_STATUS_TOOMANYNOTIFICATIONBUFFERSMicrovisor cannot create the necessary notification center because the maximum has already been reached
MV_STATUS_INVALIDBUFFERSIZEThe buffer size specified in setup is not a multiple of 16 bytes, or at least 32 bytes in size
MV_STATUS_BUFFERALREADYINUSEThe specified buffer is already being used by another notification center
MV_STATUS_INVALIDINTERRUPTThe IRQ specified in setup (see below) is not available to the application

You configure the notification center by providing a pointer to a NotificationSetup structure:

1
struct MvNotificationSetup {
2
uint32_t irq;
3
struct MvNotification *buffer;
4
uint32_t buffer_size;
5
}

These properties are:

  • irq — The number of the non-secure interrupt line that will be triggered to signal that a new notification has been posted. The call to mvSetupNotifications() will return an error if this value indicates a secure interrupt, or has already been assigned to a notification center.
  • buffer — A pointer to a previously allocated buffer. It must be 8-byte aligned.
  • buffer_size — The size of the center's buffer in bytes. It must be at least 32 bytes and a multiple of 16 bytes.
1
// Central store for Microvisor resource handles used in this code.
2
struct {
3
MvNotificationHandle notification;
4
MvNetworkHandle network;
5
MvChannelHandle channel;
6
} http_handles = { 0, 0, 0 };
7
8
// Store for HTTP notification records.
9
// Holds four records at a time -- each record is 16 bytes.
10
volatile struct MvNotification http_notification_center[4] __attribute__((aligned(8)));
11
12
// Clear the notification store
13
memset((void *)http_notification_center, 0xFF, sizeof(http_notification_center));
14
15
// Configure a notification center for network-centric notifications
16
static struct MvNotificationSetup http_notification_setup = {
17
.irq = TIM8_BRK_IRQn,
18
.buffer = (struct MvNotification *)http_notification_center,
19
.buffer_size = sizeof(http_notification_center)
20
};
21
22
// Ask Microvisor to establish the notification center
23
// and confirm that it has accepted the request
24
enum MvStatus status = mvSetupNotifications(&http_notification_setup, &http_handles.notification);
25
assert((status == MV_STATUS_OKAY) && "[ERROR] Could not set up HTTP channel NC");
26
27
// Start the notification IRQ
28
NVIC_ClearPendingIRQ(TIM8_BRK_IRQn);
29
NVIC_EnableIRQ(TIM8_BRK_IRQn);
30
printf("[DEBUG] Notification center handle: %lu\n", (uint32_t)http_handles.notification);
(information)

Info

For more details on Microvisor's notifications mechanism, please see Microvisor Notifications.


mvCloseNotifications()

mvclosenotifications page anchor

Halt the dispatch of messages from a notification center

extern enum MvStatus mvCloseNotifications(MvNotificationHandle *handle);
ParameterDescription
handleA pointer to non-secure memory in which the notification center handle is stored by the application
Error ValueDescription
MV_STATUS_PARAMETERFAULThandle does not reference memory accessible to the application
MV_STATUS_INVALIDHANDLEhandle is invalid or identifies some other type of handle

To stop receiving notifications from a specific notification center, call mvCloseNotifications() and pass in a pointer to the memory in which the center's handle is stored.

If the center is in use by other objects — for example, the same center is dispatching notifications from a network and a channel — calling mvCloseNotifications() will stop the delivery of notifications from all of its sources, and no error will be issued.

The center's non-secure interrupt will not be pended by Microvisor when the center is closed. If the interrupt has already been pended, it will not be cleared. This is the job of the application.

This example uses variables defined in the example above.

1
// If we have a valid notification center handle, then ask Microvisor
2
// to tear down the center and confirm acceptance of the request.
3
if (http_handles.notification != 0) {
4
status = mvCloseNotifications(&http_handles.notification);
5
assert((status == MV_STATUS_OKAY) && "[ERROR] Could not close HTTP channel NC");
6
}

mvOpenSystemNotification()

mvopensystemnotification page anchor

Start the dispatch of system messages to a notification center

1
extern enum MvStatus mvOpenSystemNotification(const struct MvOpenSystemNotificationParams *params,
2
MvSystemEventHandle *handle);
ParameterDescription
paramsA pointer to non-secure memory in which the notification parameters are stored by the application
handleA pointer to non-secure memory in which the handle of the system event sender is stored by the application
Error ValueDescription
MV_STATUS_UNAVAILABLESystem call has been made from an interrupt service routine
MV_STATUS_PARAMETERFAULThandle or params does not reference memory accessible to the application
MV_STATUS_INVALIDHANDLEhandle is invalid or identifies some other type of handle

To begin receiving system notifications, call mvOpenSystemNotification() and pass in a pointer to the memory in which the system notification configuration is stored, and where a system event sender's handle will be stored.

The params parameter takes a pointer to a MvOpenSystemNotificationParams structure:

1
struct MvOpenSystemNotificationParams {
2
MvNotificationHandle notification_handle;
3
uint32_t notification_tag;
4
enum MvSystemNotificationSource notification_source;
5
}

These properties are:

  • notification_handle — The handle that will be issued for the notification center messages.
  • notification_tag — An arbitrary 32-bit value you can specify and which will then be included in all notifications relating to this center.
  • notification_source — One or more MvSystemNotificationSource values OR'd to indicate the type(s) of notifications to be issued. See below.

Available MvSystemNotificationSource values include:

1
enum MvSystemNotificationSource {
2
MV_SYSTEMNOTIFICATIONSOURCE_NETWORK,
3
MV_SYSTEMNOTIFICATIONSOURCE_UPDATE
4
};

Use MV_SYSTEMNOTIFICATIONSOURCE_UPDATE to receive polite deployment notifications.


mvCloseSystemNotification()

mvclosesystemnotification page anchor

Halt the dispatch of system messages to a notification center

extern enum MvStatus mvCloseSystemNotification(MvSystemEventHandle *handle);
ParameterDescription
handleA pointer to non-secure memory in which the handle of a system event sender is stored by the application
Error ValueDescription
MV_STATUS_UNAVAILABLESystem call has been made from an interrupt service routine
MV_STATUS_INVALIDHANDLEhandle is invalid or identifies some other type of handle

To stop receiving system notifications, call mvCloseSystemNotification() and pass in the handle of the system event sender that was provided when you called mvOpenSystemNotification().

This call does not tear down the notification center to which system notifications are being sent.

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.