1 | /* |
---|
2 | (C) Copyright IBM Corp. 2008 |
---|
3 | |
---|
4 | All rights reserved. |
---|
5 | |
---|
6 | Redistribution and use in source and binary forms, with or without |
---|
7 | modification, are permitted provided that the following conditions are met: |
---|
8 | |
---|
9 | * Redistributions of source code must retain the above copyright notice, |
---|
10 | this list of conditions and the following disclaimer. |
---|
11 | * Redistributions in binary form must reproduce the above copyright |
---|
12 | notice, this list of conditions and the following disclaimer in the |
---|
13 | documentation and/or other materials provided with the distribution. |
---|
14 | * Neither the name of IBM nor the names of its contributors may be |
---|
15 | used to endorse or promote products derived from this software without |
---|
16 | specific prior written permission. |
---|
17 | |
---|
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
28 | POSSIBILITY OF SUCH DAMAGE. |
---|
29 | */ |
---|
30 | |
---|
31 | #ifndef _SPU_TIMER_H_ |
---|
32 | #define _SPU_TIMER_H_ |
---|
33 | |
---|
34 | #ifdef __cplusplus |
---|
35 | extern "C" { |
---|
36 | #endif |
---|
37 | |
---|
38 | #include <stdint.h> |
---|
39 | |
---|
40 | /* Clock services. */ |
---|
41 | extern void spu_clock_start (void); |
---|
42 | extern int spu_clock_stop (void); |
---|
43 | extern uint64_t spu_clock_read (void); |
---|
44 | |
---|
45 | /* Timer services. */ |
---|
46 | extern int spu_timer_alloc (int interval, void (*func) (int)); |
---|
47 | extern int spu_timer_free (int id); |
---|
48 | extern int spu_timer_start (int id); |
---|
49 | extern int spu_timer_stop (int id); |
---|
50 | extern unsigned spu_timebase (void); |
---|
51 | |
---|
52 | /* Interrupt services. */ |
---|
53 | extern void spu_slih_register (unsigned event_mask, |
---|
54 | unsigned (*slih) (unsigned)); |
---|
55 | extern unsigned spu_clock_slih (unsigned event_mask); |
---|
56 | |
---|
57 | /* Number of supported timers. */ |
---|
58 | #define SPU_TIMER_NTIMERS 4 |
---|
59 | |
---|
60 | /* Recommended minimun spu timer interval time from (cat /proc/cpuinfo) |
---|
61 | * QS20 100/14318000 = 6.98 usec |
---|
62 | * QS21/QS22 100/26666666 = 3.75 usec |
---|
63 | * PS3 100/79800000 = 1.25 usec */ |
---|
64 | #define SPU_TIMER_MIN_INTERVAL 100 |
---|
65 | |
---|
66 | /* Clock error codes. */ |
---|
67 | #define SPU_CLOCK_ERR_NOT_RUNNING -2 |
---|
68 | #define SPU_CLOCK_ERR_STILL_RUNNING -3 |
---|
69 | #define SPU_CLOCK_ERR_TIMERS_ACTIVE -4 |
---|
70 | |
---|
71 | /* Timer error codes. */ |
---|
72 | #define SPU_TIMER_ERR_INVALID_PARM -10 |
---|
73 | #define SPU_TIMER_ERR_NONE_FREE -11 |
---|
74 | #define SPU_TIMER_ERR_INVALID_ID -12 |
---|
75 | #define SPU_TIMER_ERR_ACTIVE -13 |
---|
76 | #define SPU_TIMER_ERR_NOT_ACTIVE -14 |
---|
77 | #define SPU_TIMER_ERR_NOCLOCK -15 |
---|
78 | #define SPU_TIMER_ERR_FREE -16 |
---|
79 | #define SPU_TIMER_ERR_NOT_STOPPED -17 |
---|
80 | |
---|
81 | #ifdef __cplusplus |
---|
82 | } |
---|
83 | #endif |
---|
84 | |
---|
85 | #endif |
---|