1 /***************************************************************************
2  * Copyright (c) 2024 Microsoft Corporation
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the MIT License which is available at
6  * https://opensource.org/licenses/MIT.
7  *
8  * SPDX-License-Identifier: MIT
9  **************************************************************************/
10 
11 
12 /**************************************************************************/
13 /**************************************************************************/
14 /**                                                                       */
15 /** ThreadX Component                                                     */
16 /**                                                                       */
17 /**   Timer                                                               */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 #define TX_SOURCE_CODE
23 
24 
25 /* Include necessary system files.  */
26 
27 #include "tx_api.h"
28 #include "tx_timer.h"
29 
30 
31 /**************************************************************************/
32 /*                                                                        */
33 /*  FUNCTION                                               RELEASE        */
34 /*                                                                        */
35 /*    _txe_timer_info_get                                 PORTABLE C      */
36 /*                                                           6.1          */
37 /*  AUTHOR                                                                */
38 /*                                                                        */
39 /*    William E. Lamie, Microsoft Corporation                             */
40 /*                                                                        */
41 /*  DESCRIPTION                                                           */
42 /*                                                                        */
43 /*    This function checks for errors in the timer information get        */
44 /*    service.                                                            */
45 /*                                                                        */
46 /*  INPUT                                                                 */
47 /*                                                                        */
48 /*    timer_ptr                         Pointer to timer control block    */
49 /*    name                              Destination for the timer name    */
50 /*    active                            Destination for active flag       */
51 /*    remaining_ticks                   Destination for remaining ticks   */
52 /*                                        before expiration               */
53 /*    reschedule_ticks                  Destination for reschedule ticks  */
54 /*    next_timer                        Destination for next timer on the */
55 /*                                        created list                    */
56 /*                                                                        */
57 /*  OUTPUT                                                                */
58 /*                                                                        */
59 /*    TX_TIMER_ERROR                    Invalid timer pointer             */
60 /*    status                            Completion status                 */
61 /*                                                                        */
62 /*  CALLS                                                                 */
63 /*                                                                        */
64 /*    _tx_timer_info_get                Actual info get call              */
65 /*                                                                        */
66 /*  CALLED BY                                                             */
67 /*                                                                        */
68 /*    Application Code                                                    */
69 /*                                                                        */
70 /*  RELEASE HISTORY                                                       */
71 /*                                                                        */
72 /*    DATE              NAME                      DESCRIPTION             */
73 /*                                                                        */
74 /*  05-19-2020     William E. Lamie         Initial Version 6.0           */
75 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
76 /*                                            resulting in version 6.1    */
77 /*                                                                        */
78 /**************************************************************************/
_txe_timer_info_get(TX_TIMER * timer_ptr,CHAR ** name,UINT * active,ULONG * remaining_ticks,ULONG * reschedule_ticks,TX_TIMER ** next_timer)79 UINT  _txe_timer_info_get(TX_TIMER *timer_ptr, CHAR **name, UINT *active, ULONG *remaining_ticks,
80                 ULONG *reschedule_ticks, TX_TIMER **next_timer)
81 {
82 
83 UINT    status;
84 
85 
86     /* Check for an invalid timer pointer.  */
87     if (timer_ptr == TX_NULL)
88     {
89 
90         /* Timer pointer is invalid, return appropriate error code.  */
91         status =  TX_TIMER_ERROR;
92     }
93 
94     /* Now check for invalid timer ID.  */
95     else if (timer_ptr -> tx_timer_id != TX_TIMER_ID)
96     {
97 
98         /* Timer pointer is invalid, return appropriate error code.  */
99         status =  TX_TIMER_ERROR;
100     }
101     else
102     {
103 
104         /* Otherwise, call the actual timer information get service.  */
105         status =  _tx_timer_info_get(timer_ptr, name, active, remaining_ticks, reschedule_ticks, next_timer);
106     }
107 
108     /* Return completion status.  */
109     return(status);
110 }
111 
112