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

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

Cosmetic

File size: 4.0 KB
RevLine 
[258]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).
[320]11//
[258]12// The (virtual) base address of the associated segment is:
[333]13//       SEG_MWR_BASE + cluster_xy * PERI_CLUSTER_INCREMENT
[258]14//
[333]15// SEG_MWR_BASE and PERI_CLUSTER_INCREMENT must be defined in hard_config.h
[258]16////////////////////////////////////////////////////////////////////////////////
17
18#include <giet_config.h>
[320]19#include <hard_config.h>
[258]20#include <mwr_driver.h>
21#include <utils.h>
22
[263]23#if !defined(X_SIZE)
24# error: You must define X_SIZE in the hard_config.h file
[258]25#endif
26
[263]27#if !defined(Y_SIZE)
28# error: You must define X_SIZE in the hard_config.h file
[258]29#endif
30
[263]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
[320]39#if !defined(SEG_MWR_BASE)
40# error: You must define SEG_MWR_BASE in the hard_config.h file
41#endif
42
[333]43#if !defined(PERI_CLUSTER_INCREMENT)
44# error: You must define PERI_CLUSTER_INCREMENT in the hard_config.h file
[320]45#endif
46
[258]47//////////////////////////////////////////////////////////////////////////////////
[263]48//    _mwr_hw_init()
[258]49// This function initializes one MWMR controller channel (i.e. one coprocessor
50// port) in a given cluster.
[263]51// - cluster_xy    : cluster index
[258]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//////////////////////////////////////////////////////////////////////////////////
[263]60unsigned int _mwr_hw_init( unsigned int           cluster_xy, 
61                           unsigned int           port_id, 
62                           unsigned int           from_coproc,
63                           paddr_t                channel_pbase ) 
[258]64{
[295]65    _printf(" [GIET_ERROR] _mwr_hw_init() function not supported yet\n");
[258]66    _exit();
67
68/*
69    // parameters checking
[263]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;
[258]74
[263]75    // compute base address
[320]76    unsigned int* mwr_address = (unsigned int*) ( SEG_MWR_BASE +
[333]77                                 (cluster_xy * PERI_CLUSTER_INCREMENT) );
[258]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
[263]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;
[258]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.