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

Last change on this file since 398 was 333, checked in by alain, 10 years ago

Cosmetic

File size: 4.0 KB
Line 
1///////////////////////////////////////////////////////////////////////////////////
2// File     : mwr_driver.c
3// Date     : 23/05/2013
4// Author   : alain greiner
5// Copyright (c) UPMC-LIP6
6///////////////////////////////////////////////////////////////////////////////////
7// The mwmr_driver.c and mwmr_driver.h files are part ot the GIET-VM nano-kernel.
8// This driver supports the SoClib vci_mwmr_controller component.
9//
10// This peripheral can be replicated (at most one component per cluster).
11//
12// The (virtual) base address of the associated segment is:
13//       SEG_MWR_BASE + cluster_xy * PERI_CLUSTER_INCREMENT
14//
15// SEG_MWR_BASE and PERI_CLUSTER_INCREMENT must be defined in hard_config.h
16////////////////////////////////////////////////////////////////////////////////
17
18#include <giet_config.h>
19#include <hard_config.h>
20#include <mwr_driver.h>
21#include <utils.h>
22
23#if !defined(X_SIZE)
24# error: You must define X_SIZE in the hard_config.h file
25#endif
26
27#if !defined(Y_SIZE)
28# error: You must define X_SIZE in the hard_config.h file
29#endif
30
31#if !defined(X_WIDTH)
32# error: You must define X_WIDTH in the hard_config.h file
33#endif
34
35#if !defined(Y_WIDTH)
36# error: You must define X_WIDTH in the hard_config.h file
37#endif
38
39#if !defined(SEG_MWR_BASE)
40# error: You must define SEG_MWR_BASE in the hard_config.h file
41#endif
42
43#if !defined(PERI_CLUSTER_INCREMENT)
44# error: You must define PERI_CLUSTER_INCREMENT in the hard_config.h file
45#endif
46
47//////////////////////////////////////////////////////////////////////////////////
48//    _mwr_hw_init()
49// This function initializes one MWMR controller channel (i.e. one coprocessor
50// port) in a given cluster.
51// - cluster_xy    : cluster index
52// _ port_id       : port index
53// - way           : direction (to_coproc/from_coproc)
54// - channel_pbase : physical base address of the MWMR channel
55// TODO : The MWMR controler should be modified to support 40 bits addresses...
56//        Introduce a MWMR_CONFIG_PADDR_EXT register in the MWMR coprocessor
57//////////////////////////////////////////////////////////////////////////////////
58// Returns 0 if success, returns > 0 if error.
59//////////////////////////////////////////////////////////////////////////////////
60unsigned int _mwr_hw_init( unsigned int           cluster_xy, 
61                           unsigned int           port_id, 
62                           unsigned int           from_coproc,
63                           paddr_t                channel_pbase ) 
64{
65    _printf(" [GIET_ERROR] _mwr_hw_init() function not supported yet\n");
66    _exit();
67
68/*
69    // parameters checking
70    unsigned int x = cluster_xy >> Y_WIDTH;
71    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
72    if (x >= X_SIZE)                    return 1;
73    if (y >= Y_SIZE)                    return 1;
74
75    // compute base address
76    unsigned int* mwr_address = (unsigned int*) ( SEG_MWR_BASE +
77                                 (cluster_xy * PERI_CLUSTER_INCREMENT) );
78
79    unsigned int lsb = (unsigned int)channel_pbase;
80    unsigned int msb = (unsigned int)(channel_pbase>>32);
81
82    // get depth and width from channel itself
83    unsigned int depth = _physical_read( channel_pbase + 16 );
84    unsigned int width = _physical_read( channel_pbase + 20 );
85
86    // initializes and launches mwmr controler
87    mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_FIFO_WAY]  = from_coproc;
88    mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_FIFO_NO]   = port_id;
89    mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_WIDTH]     = width;
90    mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_DEPTH]     = depth;
91    mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_STATUS]    = lsb;
92    mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_DATA]      = lsb + 24;
93    mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_EXT]       = msb;
94    mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_RUNNING]   = 1;
95*/
96    return 0;
97}
98
99
100// Local Variables:
101// tab-width: 4
102// c-basic-offset: 4
103// c-file-offsets:((innamespace . 0)(inline-open . 0))
104// indent-tabs-mode: nil
105// End:
106// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
107
Note: See TracBrowser for help on using the repository browser.