15 #ifndef GEN5200_BESTCOMM_H 16 #define GEN5200_BESTCOMM_H 18 #include "bestcomm_ops.h" 24 #include <bsp/mpc5200.h> 26 #include <bsp/bestcomm/bestcomm_glue.h> 45 volatile uint32_t (*var_table)[32];
46 uint32_t fdt_and_pragmas;
49 uint32_t *context_begin;
53 #define BESTCOMM_TASK_ENTRY_TABLE ((volatile bestcomm_task_entry *) 0xf0008000) 55 #define BESTCOMM_IRQ_EVENT RTEMS_EVENT_13 62 void bestcomm_irq_create(
bestcomm_irq *
self,
int task_index);
66 static inline void bestcomm_irq_enable(
const bestcomm_irq *
self)
68 bestcomm_glue_irq_enable(self->task_index);
71 static inline void bestcomm_irq_disable(
const bestcomm_irq *
self)
73 bestcomm_glue_irq_disable(self->task_index);
76 static inline void bestcomm_irq_clear(
const bestcomm_irq *
self)
78 SDMA_CLEAR_IEVENT(&mpc5200.sdma.IntPend, self->task_index);
81 static inline int bestcomm_irq_get_task_index(
const bestcomm_irq *
self)
83 return self->task_index;
88 return self->event_task_id;
93 self->event_task_id = id;
96 static inline void bestcomm_irq_wakeup_event_task(
const bestcomm_irq *
self)
103 static inline void bestcomm_irq_wait(
const bestcomm_irq *
self)
113 assert(events == BESTCOMM_IRQ_EVENT);
117 static inline bool bestcomm_irq_peek(
const bestcomm_irq *
self)
124 return (events & BESTCOMM_IRQ_EVENT) != 0;
128 volatile uint16_t *task_control_register;
130 volatile uint32_t (*variable_table)[32];
138 size_t tdt_opcode_count;
141 void bestcomm_task_create(
bestcomm_task *
self, TaskId task_index);
143 void bestcomm_task_create_and_load(
146 const uint32_t *tdt_source_begin,
152 void bestcomm_task_load(
bestcomm_task *
self,
const uint32_t *tdt_source_begin,
size_t tdt_size);
154 static inline void bestcomm_task_set_priority(
bestcomm_task *
self,
int priority)
157 mpc5200.sdma.ipr[
self->task_index] = SDMA_IPR_PRIOR(priority);
160 static inline void bestcomm_task_irq_enable(
const bestcomm_task *
self)
162 bestcomm_irq_enable(&self->irq);
165 static inline void bestcomm_task_irq_disable(
const bestcomm_task *
self)
167 bestcomm_irq_disable(&self->irq);
170 static inline void bestcomm_task_irq_clear(
const bestcomm_task *
self)
172 bestcomm_irq_clear(&self->irq);
177 return bestcomm_irq_get_event_task_id(&self->irq);
182 bestcomm_irq_set_event_task_id(&self->irq,
id);
185 static inline void bestcomm_task_associate_with_current_task(
bestcomm_task *
self)
190 static inline void bestcomm_task_start(
const bestcomm_task *
self)
192 *
self->task_control_register = SDMA_TCR_EN | SDMA_TCR_HIGH_EN;
195 static inline void bestcomm_task_start_with_autostart(
const bestcomm_task *
self)
197 *
self->task_control_register = (uint16_t)
198 (SDMA_TCR_EN | SDMA_TCR_HIGH_EN | SDMA_TCR_AUTO_START | SDMA_TCR_AS(self->task_index));
201 static inline void bestcomm_task_stop(
const bestcomm_task *
self)
203 *
self->task_control_register = 0;
206 static inline void bestcomm_task_wakeup_event_task(
const bestcomm_task *
self)
208 bestcomm_irq_wakeup_event_task(&self->irq);
211 static inline void bestcomm_task_wait(
const bestcomm_task *
self)
213 bestcomm_irq_wait(&self->irq);
216 static inline bool bestcomm_task_peek(
const bestcomm_task *
self)
218 return bestcomm_irq_peek(&self->irq);
221 static inline bool bestcomm_task_is_running(
const bestcomm_task *
self)
223 return (*self->task_control_register & SDMA_TCR_EN) != 0;
226 static inline uint32_t bestcomm_get_task_variable(
const bestcomm_task *
self,
size_t index)
228 assert(index < VAR_COUNT);
229 return (*self->variable_table)[index];
232 static inline volatile uint32_t *bestcomm_task_get_address_of_variable(
const bestcomm_task *
self,
size_t index)
234 assert(index < VAR_COUNT);
235 return &(*
self->variable_table)[index];
238 static inline void bestcomm_task_set_variable(
const bestcomm_task *
self,
size_t index, uint32_t value)
240 assert(index < VAR_COUNT);
241 (*
self->variable_table)[index] = value;
244 static inline uint32_t bestcomm_task_get_increment_and_condition(
const bestcomm_task *
self,
size_t index)
246 assert(index < INC_COUNT);
247 return (*self->variable_table)[INC(index)];
250 static inline void bestcomm_task_set_increment_and_condition_32(
253 uint32_t inc_and_cond
256 assert(index < INC_COUNT);
257 (*
self->variable_table)[INC(index)] = inc_and_cond;
260 static inline void bestcomm_task_set_increment_and_condition(
267 bestcomm_task_set_increment_and_condition_32(
self, index, INC_INIT(cond, inc));
270 static inline void bestcomm_task_set_increment(
const bestcomm_task *
self,
size_t index, int16_t inc)
272 bestcomm_task_set_increment_and_condition_32(
self, index, INC_INIT(0, inc));
275 void bestcomm_task_clear_variables(
const bestcomm_task *
self);
277 static inline uint32_t bestcomm_task_get_opcode(
const bestcomm_task *
self,
size_t index)
279 assert(index < self->tdt_opcode_count);
280 return self->tdt_begin[index];
283 static inline void bestcomm_task_set_opcode(
bestcomm_task *
self,
size_t index, uint32_t opcode)
285 assert(index < self->tdt_opcode_count);
286 self->tdt_begin[index] = opcode;
289 static inline void bestcomm_task_set_initiator(
const bestcomm_task *
self,
int initiator)
293 *
self->task_control_register = BSP_BFLD16SET(*self->task_control_register, initiator, 3, 7);
299 return &BESTCOMM_TASK_ENTRY_TABLE[
self->task_index];
302 static inline void bestcomm_task_set_pragma(
const bestcomm_task *
self,
int bit_pos,
bool enable)
305 uint32_t mask = BSP_BIT32(bit_pos);
306 uint32_t bit = enable ? mask : 0;
307 entry->fdt_and_pragmas = (
entry->fdt_and_pragmas & ~mask) | bit;
310 static inline void bestcomm_task_enable_precise_increment(
const bestcomm_task *
self,
bool enable)
312 bestcomm_task_set_pragma(
self, SDMA_PRAGMA_BIT_PRECISE_INC, enable);
315 static inline void bestcomm_task_enable_error_reset(
const bestcomm_task *
self,
bool enable)
317 bestcomm_task_set_pragma(
self, SDMA_PRAGMA_BIT_RST_ERROR_NO, !enable);
320 static inline void bestcomm_task_enable_pack_data(
const bestcomm_task *
self,
bool enable)
322 bestcomm_task_set_pragma(
self, SDMA_PRAGMA_BIT_PACK, enable);
325 static inline void bestcomm_task_enable_integer_mode(
const bestcomm_task *
self,
bool enable)
327 bestcomm_task_set_pragma(
self, SDMA_PRAGMA_BIT_INTEGER, enable);
330 static inline void bestcomm_task_enable_speculative_read(
const bestcomm_task *
self,
bool enable)
332 bestcomm_task_set_pragma(
self, SDMA_PRAGMA_BIT_SPECREAD, enable);
335 static inline void bestcomm_task_enable_combined_write(
const bestcomm_task *
self,
bool enable)
337 bestcomm_task_set_pragma(
self, SDMA_PRAGMA_BIT_CW, enable);
340 static inline void bestcomm_task_enable_read_buffer(
const bestcomm_task *
self,
bool enable)
342 bestcomm_task_set_pragma(
self, SDMA_PRAGMA_BIT_RL, enable);
345 static inline volatile uint16_t *bestcomm_task_get_task_control_register(
const bestcomm_task *
self)
347 return self->task_control_register;
350 static inline int bestcomm_task_get_task_index(
const bestcomm_task *
self)
352 return self->task_index;
355 static inline void bestcomm_task_free_tdt(
bestcomm_task *
self)
357 bestcomm_free(self->tdt_begin);
358 self->tdt_begin =
NULL;
361 static inline void bestcomm_task_clear_pragmas(
const bestcomm_task *
self)
364 entry->fdt_and_pragmas &= ~0xffU;
rtems_status_code rtems_event_receive(rtems_event_set event_in, rtems_option option_set, rtems_interval ticks, rtems_event_set *event_out)
Receives pending events.
Definition: eventreceive.c:27
Information for the Assert Handler.
rtems_status_code
Classic API Status.
Definition: status.h:43
#define rtems_interrupt_disable(_isr_cookie)
Disable RTEMS Interrupt.
Definition: intr.h:99
uint32_t rtems_event_set
Integer type to hold an event set of up to 32 events represented as a bit field.
Definition: event.h:40
#define RTEMS_WAIT
Definition: options.h:53
#define RTEMS_EVENT_ALL
Definition: options.h:65
Definition: bestcomm.h:127
#define rtems_interrupt_enable(_isr_cookie)
Enable RTEMS Interrupt.
Definition: intr.h:110
Definition: bestcomm.h:42
ISR_Level rtems_interrupt_level
Interrupt level type.
Definition: intr.h:42
rtems_id rtems_task_self(void)
RTEMS Get Self Task Id.
Definition: taskself.c:23
#define RTEMS_NO_TIMEOUT
Constant for indefinite wait.
Definition: rtems.h:174
Objects_Id rtems_id
Used to manage and manipulate RTEMS object identifiers.
Definition: types.h:83
Definition: bestcomm.h:57
Definition: mmu-config.c:40
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77
rtems_status_code rtems_event_send(rtems_id id, rtems_event_set event_in)
Sends an Event Set to the Target Task.
Definition: eventsend.c:25