1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 /**************************************************************************/
13 /**************************************************************************/
14 /**                                                                       */
15 /** Thread-Metric Component                                               */
16 /**                                                                       */
17 /** Application Interface (API)                                           */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 
23 /**************************************************************************/
24 /*                                                                        */
25 /*  APPLICATION INTERFACE DEFINITION                       RELEASE        */
26 /*                                                                        */
27 /*    tm_api.h                                            PORTABLE C      */
28 /*                                                           6.1.7        */
29 /*  AUTHOR                                                                */
30 /*                                                                        */
31 /*    William E. Lamie, Microsoft Corporation                             */
32 /*                                                                        */
33 /*  DESCRIPTION                                                           */
34 /*                                                                        */
35 /*    This file defines the basic Application Interface (API)             */
36 /*    implementation source code for the Thread-Metrics performance       */
37 /*    test suite. All service prototypes and data structure definitions   */
38 /*    are defined in this file.                                           */
39 /*                                                                        */
40 /*  RELEASE HISTORY                                                       */
41 /*                                                                        */
42 /*    DATE              NAME                      DESCRIPTION             */
43 /*                                                                        */
44 /*  10-15-2021     William E. Lamie         Initial Version 6.1.7         */
45 /*                                                                        */
46 /**************************************************************************/
47 
48 #ifndef  TM_API_H
49 #define  TM_API_H
50 
51 #include "tm_porting_layer.h"
52 
53 /* Determine if a C++ compiler is being used.  If so, ensure that standard
54    C is used to process the API information.  */
55 
56 #ifdef   __cplusplus
57 
58 /* Yes, C++ compiler is present.  Use standard C.  */
59 extern   "C" {
60 
61 #endif
62 
63 /* Define API constants.  */
64 
65 #define TM_SUCCESS  0
66 #define TM_ERROR    1
67 
68 
69 /* Define the time interval in seconds. This can be changed with a -D compiler option.  */
70 
71 #ifndef TM_TEST_DURATION
72 #define TM_TEST_DURATION    30
73 #endif
74 
75 
76 /* Define RTOS Neutral APIs. RTOS vendors should fill in the guts of the following
77    API. Once this is done the Thread-Metric tests can be successfully run.  */
78 
79 void   tm_initialize(void (*test_initialization_function)(void));
80 int    tm_thread_create(int thread_id, int priority, void (*entry_function)(void));
81 int    tm_thread_resume(int thread_id);
82 int    tm_thread_suspend(int thread_id);
83 void   tm_thread_relinquish(void);
84 void   tm_thread_sleep(int seconds);
85 int    tm_queue_create(int queue_id);
86 int    tm_queue_send(int queue_id, unsigned long *message_ptr);
87 int    tm_queue_receive(int queue_id, unsigned long *message_ptr);
88 int    tm_semaphore_create(int semaphore_id);
89 int    tm_semaphore_get(int semaphore_id);
90 int    tm_semaphore_put(int semaphore_id);
91 int    tm_memory_pool_create(int pool_id);
92 int    tm_memory_pool_allocate(int pool_id, unsigned char **memory_ptr);
93 int    tm_memory_pool_deallocate(int pool_id, unsigned char *memory_ptr);
94 
95 
96 /* Determine if a C++ compiler is being used.  If so, complete the standard
97    C conditional started above.  */
98 #ifdef   __cplusplus
99         }
100 #endif
101 
102 #endif
103