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

Last change on this file since 487 was 456, checked in by alain, 10 years ago

Defining the NIC and CMA drivers (validated by the classif application).
Updating other drivers to comply with the new tty0 common file.

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