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)
126 assert(events == BESTCOMM_IRQ_EVENT);
130static inline bool bestcomm_irq_peek(
const bestcomm_irq *self)
137 return (events & BESTCOMM_IRQ_EVENT) != 0;
141 volatile uint16_t *task_control_register;
143 volatile uint32_t (*variable_table)[32];
151 size_t tdt_opcode_count;
154void bestcomm_task_create(
bestcomm_task *self, TaskId task_index);
156void bestcomm_task_create_and_load(
159 const uint32_t *tdt_source_begin,
165void bestcomm_task_load(
bestcomm_task *self,
const uint32_t *tdt_source_begin,
size_t tdt_size);
167static inline void bestcomm_task_set_priority(
bestcomm_task *self,
int priority)
170 mpc5200.sdma.ipr[self->task_index] = SDMA_IPR_PRIOR(priority);
173static inline void bestcomm_task_irq_enable(
const bestcomm_task *self)
175 bestcomm_irq_enable(&self->irq);
178static inline void bestcomm_task_irq_disable(
const bestcomm_task *self)
180 bestcomm_irq_disable(&self->irq);
183static inline void bestcomm_task_irq_clear(
const bestcomm_task *self)
185 bestcomm_irq_clear(&self->irq);
190 return bestcomm_irq_get_event_task_id(&self->irq);
195 bestcomm_irq_set_event_task_id(&self->irq,
id);
198static inline void bestcomm_task_associate_with_current_task(
bestcomm_task *self)
203static inline void bestcomm_task_start(
const bestcomm_task *self)
205 *self->task_control_register = SDMA_TCR_EN | SDMA_TCR_HIGH_EN;
208static inline void bestcomm_task_start_with_autostart(
const bestcomm_task *self)
210 *self->task_control_register = (uint16_t)
211 (SDMA_TCR_EN | SDMA_TCR_HIGH_EN | SDMA_TCR_AUTO_START | SDMA_TCR_AS(self->task_index));
214static inline void bestcomm_task_stop(
const bestcomm_task *self)
216 *self->task_control_register = 0;
219static inline void bestcomm_task_wakeup_event_task(
const bestcomm_task *self)
221 bestcomm_irq_wakeup_event_task(&self->irq);
224static inline void bestcomm_task_wait(
const bestcomm_task *self)
226 bestcomm_irq_wait(&self->irq);
229static inline bool bestcomm_task_peek(
const bestcomm_task *self)
231 return bestcomm_irq_peek(&self->irq);
234static inline bool bestcomm_task_is_running(
const bestcomm_task *self)
236 return (*self->task_control_register & SDMA_TCR_EN) != 0;
239static inline uint32_t bestcomm_get_task_variable(
const bestcomm_task *self,
size_t index)
241 assert(index < VAR_COUNT);
242 return (*self->variable_table)[index];
245static inline volatile uint32_t *bestcomm_task_get_address_of_variable(
const bestcomm_task *self,
size_t index)
247 assert(index < VAR_COUNT);
248 return &(*self->variable_table)[index];
251static inline void bestcomm_task_set_variable(
const bestcomm_task *self,
size_t index, uint32_t value)
253 assert(index < VAR_COUNT);
254 (*self->variable_table)[index] = value;
257static inline uint32_t bestcomm_task_get_increment_and_condition(
const bestcomm_task *self,
size_t index)
259 assert(index < INC_COUNT);
260 return (*self->variable_table)[INC(index)];
263static inline void bestcomm_task_set_increment_and_condition_32(
266 uint32_t inc_and_cond
269 assert(index < INC_COUNT);
270 (*self->variable_table)[INC(index)] = inc_and_cond;
273static inline void bestcomm_task_set_increment_and_condition(
280 bestcomm_task_set_increment_and_condition_32(self, index, INC_INIT(cond, inc));
283static inline void bestcomm_task_set_increment(
const bestcomm_task *self,
size_t index, int16_t inc)
285 bestcomm_task_set_increment_and_condition_32(self, index, INC_INIT(0, inc));
288void bestcomm_task_clear_variables(
const bestcomm_task *self);
290static inline uint32_t bestcomm_task_get_opcode(
const bestcomm_task *self,
size_t index)
292 assert(index < self->tdt_opcode_count);
293 return self->tdt_begin[index];
296static inline void bestcomm_task_set_opcode(
bestcomm_task *self,
size_t index, uint32_t opcode)
298 assert(index < self->tdt_opcode_count);
299 self->tdt_begin[index] = opcode;
302static inline void bestcomm_task_set_initiator(
const bestcomm_task *self,
int initiator)
306 *self->task_control_register = BSP_BFLD16SET(*self->task_control_register, initiator, 3, 7);
312 return &BESTCOMM_TASK_ENTRY_TABLE[self->task_index];
315static inline void bestcomm_task_set_pragma(
const bestcomm_task *self,
int bit_pos,
bool enable)
318 uint32_t mask = BSP_BIT32(bit_pos);
319 uint32_t bit = enable ? mask : 0;
320 entry->fdt_and_pragmas = (
entry->fdt_and_pragmas & ~mask) | bit;
323static inline void bestcomm_task_enable_precise_increment(
const bestcomm_task *self,
bool enable)
325 bestcomm_task_set_pragma(self, SDMA_PRAGMA_BIT_PRECISE_INC, enable);
328static inline void bestcomm_task_enable_error_reset(
const bestcomm_task *self,
bool enable)
330 bestcomm_task_set_pragma(self, SDMA_PRAGMA_BIT_RST_ERROR_NO, !enable);
333static inline void bestcomm_task_enable_pack_data(
const bestcomm_task *self,
bool enable)
335 bestcomm_task_set_pragma(self, SDMA_PRAGMA_BIT_PACK, enable);
338static inline void bestcomm_task_enable_integer_mode(
const bestcomm_task *self,
bool enable)
340 bestcomm_task_set_pragma(self, SDMA_PRAGMA_BIT_INTEGER, enable);
343static inline void bestcomm_task_enable_speculative_read(
const bestcomm_task *self,
bool enable)
345 bestcomm_task_set_pragma(self, SDMA_PRAGMA_BIT_SPECREAD, enable);
348static inline void bestcomm_task_enable_combined_write(
const bestcomm_task *self,
bool enable)
350 bestcomm_task_set_pragma(self, SDMA_PRAGMA_BIT_CW, enable);
353static inline void bestcomm_task_enable_read_buffer(
const bestcomm_task *self,
bool enable)
355 bestcomm_task_set_pragma(self, SDMA_PRAGMA_BIT_RL, enable);
358static inline volatile uint16_t *bestcomm_task_get_task_control_register(
const bestcomm_task *self)
360 return self->task_control_register;
363static inline int bestcomm_task_get_task_index(
const bestcomm_task *self)
365 return self->task_index;
368static inline void bestcomm_task_free_tdt(
bestcomm_task *self)
370 bestcomm_free(self->tdt_begin);
371 self->tdt_begin = NULL;
374static inline void bestcomm_task_clear_pragmas(
const bestcomm_task *self)
377 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:140
Definition: mmu-config.c:53