summaryrefslogtreecommitdiffstats
path: root/src/occ_405/rtls/test/rtls_tables.c
blob: 24db77b98fbcff40c9b7b76d6cc6be3438d9cb2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/occ_405/rtls/test/rtls_tables.c $                         */
/*                                                                        */
/* OpenPOWER OnChipController Project                                     */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2011,2016                        */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */

#include "rtls.h"

// Default task data buffers
uint32_t task_0_data = 0x00000000;
uint32_t task_1_data = 0x00000000;
uint32_t task_2_data = 0x00000000;
uint32_t task_3_data = 0x00000000;

// Alternate task data buffers
uint32_t task_0_alt_data = 0x00000000;
uint32_t task_1_alt_data = 0x00000000;
uint32_t task_2_alt_data = 0x00000000;
uint32_t task_3_alt_data = 0x00000000;

#define TASK_ID_0 0
#define TASK_ID_1 1
#define TASK_ID_2 2
#define TASK_ID_3 3
#define TASK_ID_END 4

// Test tick sequences
// For testing, run every task on every tick, but vary the order.
uint8_t G_tick0_seq[TASK_END + 1] = { TASK_ID_0, TASK_ID_1, TASK_ID_2, TASK_ID_3, TASK_END };
uint8_t G_tick1_seq[TASK_END + 1] = { TASK_ID_1, TASK_ID_2, TASK_ID_3, TASK_ID_0, TASK_END };
uint8_t G_tick2_seq[TASK_END + 1] = { TASK_ID_2, TASK_ID_3, TASK_ID_0, TASK_ID_1, TASK_END };
uint8_t G_tick3_seq[TASK_END + 1] = { TASK_ID_3, TASK_ID_0, TASK_ID_1, TASK_ID_2, TASK_END };
uint8_t G_tick4_seq[TASK_END + 1] = { TASK_ID_3, TASK_ID_2, TASK_ID_1, TASK_ID_0, TASK_END };
uint8_t G_tick5_seq[TASK_END + 1] = { TASK_ID_2, TASK_ID_1, TASK_ID_0, TASK_ID_3, TASK_END };
uint8_t G_tick6_seq[TASK_END + 1] = { TASK_ID_1, TASK_ID_0, TASK_ID_3, TASK_ID_2, TASK_END };
uint8_t G_tick7_seq[TASK_END + 1] = { TASK_ID_0, TASK_ID_3, TASK_ID_2, TASK_ID_1, TASK_END };

/* Tick Table */
uint8_t *G_tick_table[MAX_NUM_TICKS] = {
    G_tick0_seq,
    G_tick1_seq,
    G_tick2_seq,
    G_tick3_seq,
    G_tick4_seq,
    G_tick5_seq,
    G_tick6_seq,
    G_tick7_seq
};

// Example Task Table
// Use task_id_t values to index into this table and find a specific task.
task_t G_task_table[TASK_END] = {
    // flags,       func_ptr,    data_ptr,        task_id_t
    { 0x00000000, task_0_func, (void *)&task_0_data }, // TASK_ID_0
    { 0x00000000, task_1_func, (void *)&task_1_data }, // TASK_ID_1
    { 0x00000000, task_2_func, (void *)&task_2_data }, // TASK_ID_2
    { 0x00000000, task_3_func, (void *)&task_3_data }  // TASK_ID_3
};

void task_0_func(struct task *);
void task_1_func(struct task *);
void task_2_func(struct task *);
void task_3_func(struct task *);

// Function Specification
//
// Name: task_0_func
//
// Description: Example task 0
//
// End Function Specification
void task_0_func(struct task *i_self) {
    uint8_t curr_tick = (uint8_t)((MAX_NUM_TICKS - 1) & CURRENT_TICK);

    // If our task pointer & it's data pointer are valid, set a bit
    // in the data area indicating which tick this function ran during.

    if ( i_self && i_self -> data_ptr ) {
        *((uint32_t *)(i_self -> data_ptr)) |= (0x00000001 << curr_tick);
    }
    return;
}

// Function Specification
//
// Name: task_1_func
//
// Description: Example task 1
//
// End Function Specification
void task_1_func(struct task *i_self) {
    uint8_t curr_tick = (uint8_t)((MAX_NUM_TICKS - 1) & CURRENT_TICK);

    // If our task pointer & it's data pointer are valid, set a bit
    // in the data area indicating which tick this function ran during.

    if ( i_self && i_self -> data_ptr ) {
        *((uint32_t *)(i_self -> data_ptr)) |= (0x00000001 << curr_tick);
    }
    return;
}

// Function Specification
//
// Name: task_2_func
//
// Description: Example task 2
//
// End Function Specification
void task_2_func(struct task *i_self) {
    uint8_t curr_tick = (uint8_t)((MAX_NUM_TICKS - 1) & CURRENT_TICK);

    // If our task pointer & it's data pointer are valid, set a bit
    // in the data area indicating which tick this function ran during.

    if ( i_self && i_self -> data_ptr ) {
        *((uint32_t *)(i_self -> data_ptr)) |= (0x00000001 << curr_tick);
    }
    return;
}

// Function Specification
//
// Name: task_3_func
//
// Description: Example task 3
//
// End Function Specification
void task_3_func(struct task *i_self) {
    uint8_t curr_tick = (uint8_t)((MAX_NUM_TICKS - 1) & CURRENT_TICK);

    // If our task pointer & it's data pointer are valid, set a bit
    // in the data area indicating which tick this function ran during.

    if ( i_self && i_self -> data_ptr ) {
        *((uint32_t *)(i_self -> data_ptr)) |= (0x00000001 << curr_tick);
    }
    return;
}

OpenPOWER on IntegriCloud