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

Last change on this file since 266 was 263, checked in by alain, 11 years ago

Introducing support for TSAR fixed format cluster index (cluster_xy)
We have now 4 parameters defined in map.xml:

  • X_WIDTH, Y_WIDTH define the fixed format (typically X_WIDTH = 4 / Y_WIDTH = 4)
  • X_SIZE, Y_SIZE define the actual TSAR 2D mesh variable size (from 1 to 16)
File size: 3.9 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//
14//       seg_mwr_base + cluster_xy * vseg_cluster_increment
15//
16// The seg_mwr_base and vseg_cluster_increment values must be defined
17// in the giet_vsegs.ld file.
18////////////////////////////////////////////////////////////////////////////////
19
20#include <giet_config.h>
21#include <mwr_driver.h>
22#include <utils.h>
23
24#if !defined(X_SIZE)
25# error: You must define X_SIZE in the hard_config.h file
26#endif
27
28#if !defined(Y_SIZE)
29# error: You must define X_SIZE in the hard_config.h file
30#endif
31
32#if !defined(X_WIDTH)
33# error: You must define X_WIDTH in the hard_config.h file
34#endif
35
36#if !defined(Y_WIDTH)
37# error: You must define X_WIDTH in the hard_config.h file
38#endif
39
40//////////////////////////////////////////////////////////////////////////////////
41//    _mwr_hw_init()
42// This function initializes one MWMR controller channel (i.e. one coprocessor
43// port) in a given cluster.
44// - cluster_xy    : cluster index
45// _ port_id       : port index
46// - way           : direction (to_coproc/from_coproc)
47// - channel_pbase : physical base address of the MWMR channel
48// TODO : The MWMR controler should be modified to support 40 bits addresses...
49//        Introduce a MWMR_CONFIG_PADDR_EXT register in the MWMR coprocessor
50//////////////////////////////////////////////////////////////////////////////////
51// Returns 0 if success, returns > 0 if error.
52//////////////////////////////////////////////////////////////////////////////////
53unsigned int _mwr_hw_init( unsigned int           cluster_xy, 
54                           unsigned int           port_id, 
55                           unsigned int           from_coproc,
56                           paddr_t                channel_pbase ) 
57{
58    _puts(" [GIET_ERROR] _mwr_hw_init() function not supported yet\n");
59    _exit();
60
61/*
62    // parameters checking
63    unsigned int x = cluster_xy >> Y_WIDTH;
64    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
65    if (x >= X_SIZE)                    return 1;
66    if (y >= Y_SIZE)                    return 1;
67
68    // compute base address
69    unsigned int* mwr_address = (unsigned int*) ((unsigned int)&seg_mwr_base +
70                                 (cluster_xy * (unsigned int)&vseg_cluster_increment));
71
72    unsigned int lsb = (unsigned int)channel_pbase;
73    unsigned int msb = (unsigned int)(channel_pbase>>32);
74
75    // get depth and width from channel itself
76    unsigned int depth = _physical_read( channel_pbase + 16 );
77    unsigned int width = _physical_read( channel_pbase + 20 );
78
79    // initializes and launches mwmr controler
80    mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_FIFO_WAY]  = from_coproc;
81    mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_FIFO_NO]   = port_id;
82    mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_WIDTH]     = width;
83    mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_DEPTH]     = depth;
84    mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_STATUS]    = lsb;
85    mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_DATA]      = lsb + 24;
86    mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_EXT]       = msb;
87    mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_RUNNING]   = 1;
88*/
89    return 0;
90}
91
92
93// Local Variables:
94// tab-width: 4
95// c-basic-offset: 4
96// c-file-offsets:((innamespace . 0)(inline-open . 0))
97// indent-tabs-mode: nil
98// End:
99// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
100
Note: See TracBrowser for help on using the repository browser.