4 * Created on: Mar 3, 2009
8 #ifndef FASTCOMMUNICATION_H_
9 #define FASTCOMMUNICATION_H_
25 #include "lib/ppu/common_ppu.h"
27 #include "WindowedFifo.h"
28 #include "../common.h"
31 // Include to allocate/free using for DMA transfers
32 #include "../lib/malloc_align.h"
33 #include "../lib/free_align.h"
36 #define waittag(tag_id) mfc_write_tag_mask(1<<tag_id); mfc_read_tag_status_all();
41 typedef struct _comRequest {
42 bool valid; // If the request is valid
43 uint32_t status; // Status of the request (write_request_sen, ...)
45 uint32_t tag_id; // Tag ID
46 uint32_t queue; // The queue which is used by the request
48 bool iswfifo; // True if it is a WFIFO
49 Fifo* fifo; // Pointer to the used FIFO
50 WindowedFifo* wfifo; // Pointer to the WFIFO
52 uint32_t len; // The len of the data
53 char* data; // Point to the data which are stored
57 typedef struct _fifoCollection {
58 int type; // local, in or out
59 int queue; // Corresponding queue number
61 bool iswfifo; // True if it is a WFIFO
62 WindowedFifo* wfifo; // Pointer to the WFIFO
63 Fifo* fifo; // Pointer to the FIFO
67 * The Communication Class
69 class FastCommunication {
71 FastCommunication(int nrOfQueues, uint64_t *context_all, uint64_t *ea_base_all, int32_t * queueFromSPE, int32_t * queueOnSPE, uint64_t *);
72 virtual ~FastCommunication();
74 bool addFifo(int fifoNr, Fifo* fifo, int type, int queue);
75 bool addWFifo(int fifoNr, WindowedFifo* fifo, int type, int queue);
80 static int const local = 0;
81 static int const in = 1;
82 static int const out = 2;
84 static int const comIn = 0;
85 static int const comOut = 1;
87 static int const read_request_sent = 0;
88 static int const read_started = 1;
89 static int const read_pending = 2;
92 void sendMessage(uint32_t message, int32_t process);
93 int testMessage(int32_t process);
95 comRequest* newRequest();
96 void deleteRequest(comRequest* request);
97 comRequest* getRequest(uint8_t status, uint32_t queue);
100 comRequest _request[MAXNOREQ];
101 uint8_t _currentRequest;
104 fifoCollection * _fifos;
107 uint64_t * _context_all;
108 int32_t * queueFromSPE;
109 int32_t * queueOnSPE;
110 uint64_t * _ea_ls_base;
111 uint64_t * _fifoTails;
113 // This is used to check the completion of the SPEs (See remarks in FifoCommunication.cpp)
114 uint8_t _nrSpeComplete;
118 #endif /* FASTCOMMUNICATION_H_ */