source: soft/giet_vm/giet_drivers/mwr_driver.c @ 518

Last change on this file since 518 was 518, checked in by alain, 9 years ago

Redefinition of the driver for the vci_mwmr_dma component.

File size: 4.8 KB
Line 
1///////////////////////////////////////////////////////////////////////////////////
2// File     : mwr_driver.c
3// Date     : 27/02/2015
4// Author   : alain greiner
5// Copyright (c) UPMC-LIP6
6///////////////////////////////////////////////////////////////////////////////////
7
8#include <giet_config.h>
9#include <hard_config.h>
10#include <mapping_info.h>
11#include <mwr_driver.h>
12#include <utils.h>
13#include <tty0.h>
14#include <io.h>
15
16#if !defined(X_SIZE)
17# error: You must define X_SIZE in the hard_config.h file
18#endif
19
20#if !defined(Y_SIZE)
21# error: You must define X_SIZE in the hard_config.h file
22#endif
23
24#if !defined(X_WIDTH)
25# error: You must define X_WIDTH in the hard_config.h file
26#endif
27
28#if !defined(Y_WIDTH)
29# error: You must define X_WIDTH in the hard_config.h file
30#endif
31
32#if !defined(SEG_MWR_BASE)
33# error: You must define SEG_MWR_BASE in the hard_config.h file
34#endif
35
36#if !defined(PERI_CLUSTER_INCREMENT)
37# error: You must define PERI_CLUSTER_INCREMENT in the hard_config.h file
38#endif
39
40extern unsigned int _coproc_done[X_SIZE*Y_SIZE];
41
42/////////////////////////////////////////////////////////////////////////////
43// This function returns the value contained in a private register
44// of the coprocessor contained in cluster "cluster_xy".
45/////////////////////////////////////////////////////////////////////////////
46unsigned int _mwr_get_coproc_register( unsigned int cluster_xy, // cluster
47                                       unsigned int index )     // register
48{
49    unsigned int vaddr =
50        SEG_MWR_BASE + 
51        (cluster_xy * PERI_CLUSTER_INCREMENT) + 
52        (index << 2);
53
54    return ioread32( (void*)vaddr );
55}
56
57/////////////////////////////////////////////////////////////////////////////
58// This function sets a new value in a private register
59// of the coprocessor contained in cluster "clustenr_xy".
60/////////////////////////////////////////////////////////////////////////////
61void _mwr_set_coproc_register( unsigned int cluster_xy,   // cluster index
62                               unsigned int index,        // register index
63                               unsigned int value )       // writte value
64{
65    unsigned int vaddr =
66        SEG_MWR_BASE + 
67        (cluster_xy * PERI_CLUSTER_INCREMENT) +
68        (index << 2);
69       
70    iowrite32( (void*)vaddr, value );
71}
72
73/////////////////////////////////////////////////////////////////////////////
74// This function returns the value contained in a channel register
75// defined by the "index" and "channel" arguments, in the MWMR_DMA component
76// contained in cluster "cluster_xy".
77/////////////////////////////////////////////////////////////////////////////
78unsigned int _mwr_get_channel_register( unsigned int cluster_xy, // cluster
79                                        unsigned int channel,    // channel
80                                        unsigned int index )     // register
81{
82    unsigned int vaddr =
83        SEG_MWR_BASE + 
84        (cluster_xy * PERI_CLUSTER_INCREMENT) + 
85        ((channel + 1) * (CHANNEL_SPAN << 2)) +
86        (index << 2);
87
88    return ioread32( (void*)vaddr );
89}
90
91/////////////////////////////////////////////////////////////////////////////
92// This function sets a new value in a channel register
93// defined by the "index" and "channel") arguments, in the MWMR_DMA component
94// contained in cluster "cluster_xy".
95/////////////////////////////////////////////////////////////////////////////
96void _mwr_set_channel_register( unsigned int cluster_xy,  // cluster index
97                                unsigned int channel,     // channel index
98                                unsigned int index,       // register index
99                                unsigned int value )      // written value
100{
101    unsigned int vaddr =
102        SEG_MWR_BASE + 
103        (cluster_xy * PERI_CLUSTER_INCREMENT) +
104        ((channel + 1) * (CHANNEL_SPAN << 2)) +
105        (index << 2);
106       
107    iowrite32( (void*)vaddr, value );
108}
109
110///////////////////////////////////////////////////////
111void _mwr_isr( unsigned int irq_type,  // should be HWI
112               unsigned int irq_id,    // index returned by XCU
113               unsigned int channel )  // MWMR_DMA channel
114{
115    unsigned int gpid       = _get_procid();
116    unsigned int cluster_xy = gpid >> P_WIDTH;
117    unsigned int x          = cluster_xy >> Y_WIDTH;
118    unsigned int y          = cluster_xy & ((1<<Y_WIDTH)-1);
119
120    // acknowledge IRQ
121    _mwr_set_channel_register( cluster_xy, channel, CHANNEL_RUNNING, 0 );
122
123    // compute coproc_id from cluster coordinates
124    unsigned int coproc_id = x * Y_SIZE + y;
125
126    // set synchronisation variable
127    _coproc_done[coproc_id] = 1;
128}
129
130
131
132// Local Variables:
133// tab-width: 4
134// c-basic-offset: 4
135// c-file-offsets:((innamespace . 0)(inline-open . 0))
136// indent-tabs-mode: nil
137// End:
138// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
139
Note: See TracBrowser for help on using the repository browser.