File indexing completed on 2025-05-11 08:23:43
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 #ifndef __TLIB_H__
0039 #define __TLIB_H__
0040
0041 #ifdef __cplusplus
0042 extern "C" {
0043 #endif
0044
0045 struct tlib_dev;
0046
0047 typedef void (*tlib_isr_t)(void *data);
0048
0049 enum {
0050 TLIB_FLAGS_BROADCAST = 0x01
0051 };
0052
0053 struct tlib_drv {
0054
0055 void (*reset)(struct tlib_dev *hand);
0056 void (*get_freq)(
0057 struct tlib_dev *hand,
0058 unsigned int *basefreq,
0059 unsigned int *tickrate);
0060 int (*set_freq)(struct tlib_dev *hand, unsigned int tickrate);
0061 void (*irq_reg)(struct tlib_dev *hand, tlib_isr_t func, void *data, int flags);
0062 void (*irq_unreg)(struct tlib_dev *hand, tlib_isr_t func,void *data);
0063 void (*start)(struct tlib_dev *hand, int once);
0064 void (*stop)(struct tlib_dev *hand);
0065 void (*restart)(struct tlib_dev *hand);
0066 void (*get_counter)(struct tlib_dev *hand, unsigned int *counter);
0067 int (*custom)(struct tlib_dev *hand, int cmd, void *arg);
0068 int (*int_pend)(struct tlib_dev *hand, int ack);
0069 void (*get_widthmask)(struct tlib_dev *hand, unsigned int *widthmask);
0070 };
0071
0072 struct tlib_dev {
0073 struct tlib_dev *next;
0074 char status;
0075 char index;
0076 tlib_isr_t isr_func;
0077 void *isr_data;
0078 struct tlib_drv *drv;
0079 };
0080
0081 #ifdef RTEMS_DRVMGR_STARTUP
0082
0083
0084
0085
0086 extern void Clock_timer_register(int timer_number);
0087 #endif
0088
0089
0090
0091
0092
0093
0094 extern int tlib_dev_reg(struct tlib_dev *newdev);
0095
0096
0097
0098
0099
0100 extern void *tlib_open(int timer_no);
0101
0102
0103 extern void tlib_close(void *hand);
0104
0105
0106 extern int tlib_ntimer(void);
0107
0108 static inline void tlib_reset(void *hand)
0109 {
0110 struct tlib_dev *dev = hand;
0111
0112 dev->drv->reset(dev);
0113 }
0114
0115
0116
0117
0118 static inline void tlib_get_freq(
0119 void *hand,
0120 unsigned int *basefreq,
0121 unsigned int *tickrate)
0122 {
0123 struct tlib_dev *dev = hand;
0124
0125 dev->drv->get_freq(dev, basefreq, tickrate);
0126 }
0127
0128
0129 static inline int tlib_set_freq(void *hand, unsigned int tickrate)
0130 {
0131 struct tlib_dev *dev = hand;
0132
0133 return dev->drv->set_freq(dev, tickrate);
0134 }
0135
0136
0137 static inline void tlib_irq_unregister(void *hand)
0138 {
0139 struct tlib_dev *dev = hand;
0140
0141 if ( dev->isr_func ) {
0142 dev->drv->irq_unreg(dev, dev->isr_func, dev->isr_data);
0143 dev->isr_func = NULL;
0144 }
0145 }
0146
0147
0148 static inline void tlib_irq_register(void *hand, tlib_isr_t func, void *data, int flags)
0149 {
0150 struct tlib_dev *dev = hand;
0151
0152
0153 tlib_irq_unregister(hand);
0154 dev->isr_func = func;
0155 dev->isr_data = data;
0156 dev->drv->irq_reg(dev, func, data, flags);
0157 }
0158
0159
0160
0161
0162
0163
0164 static inline void tlib_start(void *hand, int once)
0165 {
0166 struct tlib_dev *dev = hand;
0167
0168 dev->drv->start(dev, once);
0169 }
0170
0171
0172 static inline void tlib_stop(void *hand)
0173 {
0174 struct tlib_dev *dev = hand;
0175
0176 dev->drv->stop(dev);
0177 }
0178
0179
0180 static inline void tlib_restart(void *hand)
0181 {
0182 struct tlib_dev *dev = hand;
0183
0184 dev->drv->restart(dev);
0185 }
0186
0187
0188 static inline void tlib_get_counter(void *hand, unsigned int *counter)
0189 {
0190 struct tlib_dev *dev = hand;
0191
0192 dev->drv->get_counter(dev, counter);
0193 }
0194
0195
0196 static inline void tlib_custom(void *hand, int cmd, void *arg)
0197 {
0198 struct tlib_dev *dev = hand;
0199
0200 dev->drv->custom(dev, cmd, arg);
0201 }
0202
0203 static inline int tlib_interrupt_pending(void *hand, int ack)
0204 {
0205 struct tlib_dev *dev = hand;
0206
0207 return dev->drv->int_pend(dev, ack);
0208 }
0209
0210 static inline void tlib_get_widthmask(void *hand, unsigned int *widthmask)
0211 {
0212 struct tlib_dev *dev = hand;
0213
0214 dev->drv->get_widthmask(dev, widthmask);
0215 }
0216
0217 #ifdef __cplusplus
0218 }
0219 #endif
0220
0221 #endif