28#ifndef GEN5200_BESTCOMM_H
29#define GEN5200_BESTCOMM_H
31#include "bestcomm_ops.h"
37#include <bsp/mpc5200.h>
39#include <bsp/bestcomm/bestcomm_glue.h>
58 volatile uint32_t (*var_table)[32];
59 uint32_t fdt_and_pragmas;
62 uint32_t *context_begin;
66#define BESTCOMM_TASK_ENTRY_TABLE ((volatile bestcomm_task_entry *) 0xf0008000)
68#define BESTCOMM_IRQ_EVENT RTEMS_EVENT_13
75void bestcomm_irq_create(
bestcomm_irq *self,
int task_index);
79static inline void bestcomm_irq_enable(
const bestcomm_irq *self)
81 bestcomm_glue_irq_enable(self->task_index);
84static inline void bestcomm_irq_disable(
const bestcomm_irq *self)
86 bestcomm_glue_irq_disable(self->task_index);
89static inline void bestcomm_irq_clear(
const bestcomm_irq *self)
91 SDMA_CLEAR_IEVENT(&mpc5200.sdma.IntPend, self->task_index);
94static inline int bestcomm_irq_get_task_index(
const bestcomm_irq *self)
96 return self->task_index;
101 return self->event_task_id;
106 self->event_task_id = id;
109static inline void bestcomm_irq_wakeup_event_task(
const bestcomm_irq *self)
116static inline void bestcomm_irq_wait(
const bestcomm_irq *self)
128 assert(events == BESTCOMM_IRQ_EVENT);
132static inline bool bestcomm_irq_peek(
const bestcomm_irq *self)
141 return (events & BESTCOMM_IRQ_EVENT) != 0;
145 volatile uint16_t *task_control_register;
147 volatile uint32_t (*variable_table)[32];
155 size_t tdt_opcode_count;
158void bestcomm_task_create(
bestcomm_task *self, TaskId task_index);
160void bestcomm_task_create_and_load(
163 const uint32_t *tdt_source_begin,
169void bestcomm_task_load(
bestcomm_task *self,
const uint32_t *tdt_source_begin,
size_t tdt_size);
171static inline void bestcomm_task_set_priority(
bestcomm_task *self,
int priority)
174 mpc5200.sdma.ipr[self->task_index] = SDMA_IPR_PRIOR(priority);
177static inline void bestcomm_task_irq_enable(
const bestcomm_task *self)
179 bestcomm_irq_enable(&self->irq);
182static inline void bestcomm_task_irq_disable(
const bestcomm_task *self)
184 bestcomm_irq_disable(&self->irq);
187static inline void bestcomm_task_irq_clear(
const bestcomm_task *self)
189 bestcomm_irq_clear(&self->irq);
194 return bestcomm_irq_get_event_task_id(&self->irq);
199 bestcomm_irq_set_event_task_id(&self->irq,
id);
202static inline void bestcomm_task_associate_with_current_task(
bestcomm_task *self)
207static inline void bestcomm_task_start(
const bestcomm_task *self)
209 *self->task_control_register = SDMA_TCR_EN | SDMA_TCR_HIGH_EN;
212static inline void bestcomm_task_start_with_autostart(
const bestcomm_task *self)
214 *self->task_control_register = (uint16_t)
215 (SDMA_TCR_EN | SDMA_TCR_HIGH_EN | SDMA_TCR_AUTO_START | SDMA_TCR_AS(self->task_index));
218static inline void bestcomm_task_stop(
const bestcomm_task *self)
220 *self->task_control_register = 0;
223static inline void bestcomm_task_wakeup_event_task(
const bestcomm_task *self)
225 bestcomm_irq_wakeup_event_task(&self->irq);
228static inline void bestcomm_task_wait(
const bestcomm_task *self)
230 bestcomm_irq_wait(&self->irq);
233static inline bool bestcomm_task_peek(
const bestcomm_task *self)
235 return bestcomm_irq_peek(&self->irq);
238static inline bool bestcomm_task_is_running(
const bestcomm_task *self)
240 return (*self->task_control_register & SDMA_TCR_EN) != 0;
243static inline uint32_t bestcomm_get_task_variable(
const bestcomm_task *self,
size_t index)
245 assert(index < VAR_COUNT);
246 return (*self->variable_table)[index];
249static inline volatile uint32_t *bestcomm_task_get_address_of_variable(
const bestcomm_task *self,
size_t index)
251 assert(index < VAR_COUNT);
252 return &(*self->variable_table)[index];
255static inline void bestcomm_task_set_variable(
const bestcomm_task *self,
size_t index, uint32_t value)
257 assert(index < VAR_COUNT);
258 (*self->variable_table)[index] = value;
261static inline uint32_t bestcomm_task_get_increment_and_condition(
const bestcomm_task *self,
size_t index)
263 assert(index < INC_COUNT);
264 return (*self->variable_table)[INC(index)];
267static inline void bestcomm_task_set_increment_and_condition_32(
270 uint32_t inc_and_cond
273 assert(index < INC_COUNT);
274 (*self->variable_table)[INC(index)] = inc_and_cond;
277static inline void bestcomm_task_set_increment_and_condition(
284 bestcomm_task_set_increment_and_condition_32(self, index, INC_INIT(cond, inc));
287static inline void bestcomm_task_set_increment(
const bestcomm_task *self,
size_t index, int16_t inc)
289 bestcomm_task_set_increment_and_condition_32(self, index, INC_INIT(0, inc));
292void bestcomm_task_clear_variables(
const bestcomm_task *self);
294static inline uint32_t bestcomm_task_get_opcode(
const bestcomm_task *self,
size_t index)
296 assert(index < self->tdt_opcode_count);
297 return self->tdt_begin[index];
300static inline void bestcomm_task_set_opcode(
bestcomm_task *self,
size_t index, uint32_t opcode)
302 assert(index < self->tdt_opcode_count);
303 self->tdt_begin[index] = opcode;
306static inline void bestcomm_task_set_initiator(
const bestcomm_task *self,
int initiator)
310 *self->task_control_register = BSP_BFLD16SET(*self->task_control_register, initiator, 3, 7);
316 return &BESTCOMM_TASK_ENTRY_TABLE[self->task_index];
319static inline void bestcomm_task_set_pragma(
const bestcomm_task *self,
int bit_pos,
bool enable)
322 uint32_t mask = BSP_BIT32(bit_pos);
323 uint32_t bit = enable ? mask : 0;
324 entry->fdt_and_pragmas = (
entry->fdt_and_pragmas & ~mask) | bit;
327static inline void bestcomm_task_enable_precise_increment(
const bestcomm_task *self,
bool enable)
329 bestcomm_task_set_pragma(self, SDMA_PRAGMA_BIT_PRECISE_INC, enable);
332static inline void bestcomm_task_enable_error_reset(
const bestcomm_task *self,
bool enable)
334 bestcomm_task_set_pragma(self, SDMA_PRAGMA_BIT_RST_ERROR_NO, !enable);
337static inline void bestcomm_task_enable_pack_data(
const bestcomm_task *self,
bool enable)
339 bestcomm_task_set_pragma(self, SDMA_PRAGMA_BIT_PACK, enable);
342static inline void bestcomm_task_enable_integer_mode(
const bestcomm_task *self,
bool enable)
344 bestcomm_task_set_pragma(self, SDMA_PRAGMA_BIT_INTEGER, enable);
347static inline void bestcomm_task_enable_speculative_read(
const bestcomm_task *self,
bool enable)
349 bestcomm_task_set_pragma(self, SDMA_PRAGMA_BIT_SPECREAD, enable);
352static inline void bestcomm_task_enable_combined_write(
const bestcomm_task *self,
bool enable)
354 bestcomm_task_set_pragma(self, SDMA_PRAGMA_BIT_CW, enable);
357static inline void bestcomm_task_enable_read_buffer(
const bestcomm_task *self,
bool enable)
359 bestcomm_task_set_pragma(self, SDMA_PRAGMA_BIT_RL, enable);
362static inline volatile uint16_t *bestcomm_task_get_task_control_register(
const bestcomm_task *self)
364 return self->task_control_register;
367static inline int bestcomm_task_get_task_index(
const bestcomm_task *self)
369 return self->task_index;
372static inline void bestcomm_task_free_tdt(
bestcomm_task *self)
374 bestcomm_free(self->tdt_begin);
375 self->tdt_begin = NULL;
378static inline void bestcomm_task_clear_pragmas(
const bestcomm_task *self)
381 entry->fdt_and_pragmas &= ~0xffU;
This header file provides the interfaces of the Assert Handler.
rtems_status_code rtems_event_send(rtems_id id, rtems_event_set event_in)
Sends the event set to the task.
Definition: eventsend.c:46
rtems_status_code rtems_event_receive(rtems_event_set event_in, rtems_option option_set, rtems_interval ticks, rtems_event_set *event_out)
Receives or gets an event set from the calling task.
Definition: eventreceive.c:47
uint32_t rtems_event_set
This integer type represents a bit field which can hold exactly 32 individual events.
Definition: event.h:436
ISR_Level rtems_interrupt_level
This integer type represents interrupt levels.
Definition: intr.h:111
#define rtems_interrupt_enable(_isr_cookie)
Restores the previous interrupt level on the current processor.
Definition: intr.h:311
#define rtems_interrupt_disable(_isr_cookie)
Disables the maskable interrupts on the current processor.
Definition: intr.h:264
#define RTEMS_WAIT
This option constant indicates that the task wants to wait on the resource.
Definition: options.h:139
#define RTEMS_EVENT_ALL
This option constant indicates that the task wishes to wait until all events of interest are availabl...
Definition: options.h:93
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:85
@ RTEMS_SUCCESSFUL
This status code indicates successful completion of a requested operation.
Definition: status.h:90
rtems_id rtems_task_self(void)
Gets the task identifier of the calling task.
#define RTEMS_NO_TIMEOUT
This clock tick interval constant indicates that the calling task is willing to wait potentially fore...
Definition: types.h:236
Objects_Id rtems_id
This type represents RTEMS object identifiers.
Definition: types.h:94
This header file defines the RTEMS Classic API.
Definition: bestcomm.h:70
Definition: bestcomm.h:55
Definition: bestcomm.h:144
Definition: mmu-config.c:53