source: soft/giet_vm/giet_drivers/icu_driver.c @ 318

Last change on this file since 318 was 295, checked in by alain, 11 years ago

Introducing a major release, to suppoort the tsar_generic_leti platform
and the various (external or internal) peripherals configurations.
The map.xml format has been modified, in order to support the new
vci_iopic componentand a new policy for peripherals initialisation.
The IRQs are nom described in the XICU and IOPIC components
(and not anymore in the processors).
To enforce this major change, the map.xml file signature changed:
The signature value must be: 0xDACE2014

This new release has been tested on the tsar_generic_leti platform
for the following mappings:

  • 4c_4p_sort_leti
  • 4c_4p_sort_leti_ext
  • 4c_4p_transpose_leti
  • 4c_4p_transpose_leti_ext
  • 4c_1p_four_leti_ext
File size: 4.2 KB
Line 
1///////////////////////////////////////////////////////////////////////////////////
2// File     : icu_driver.c
3// Date     : 23/05/2013
4// Author   : alain greiner
5// Copyright (c) UPMC-LIP6
6///////////////////////////////////////////////////////////////////////////////////
7// The icu_driver.c and icu_driver.h files are part ot the GIET-VM nano-kernel.
8// This driver supports the SoCLib vci_icu component, That is a vectorised
9// interrupt controler.
10//
11// It can exist several interrupt controller unit in the architecture
12// (one per cluster), and each one can contain several channels.
13// The number of ICU channels is equal to NB_PROCS_MAX, because there is
14// one private ICU channel per processor in a cluster.
15////////////////////////////////////////////////////////////////////////////////
16// The virtual base address of the segment associated to the component is:
17//
18//      seg_icu_base + cluster_xy * vseg_cluster_increment
19//
20// The seg_icu_base and vseg_cluster_increment values must be defined
21// in giet_vsegs.ld file.
22////////////////////////////////////////////////////////////////////////////////
23
24#include <giet_config.h>
25#include <icu_driver.h>
26#include <tty_driver.h>
27#include <utils.h>
28
29#if !defined(X_SIZE)
30# error: You must define X_SIZE in the hard_config.h file
31#endif
32
33#if !defined(Y_SIZE)
34# error: You must define X_SIZE in the hard_config.h file
35#endif
36
37#if !defined(X_WIDTH)
38# error: You must define X_WIDTH in the hard_config.h file
39#endif
40
41#if !defined(Y_WIDTH)
42# error: You must define X_WIDTH in the hard_config.h file
43#endif
44
45#if !defined(NB_PROCS_MAX)
46# error: You must define NB_PROCS_MAX in the hard_config.h file
47#endif
48
49#if !defined( USE_XICU )
50# error: You must define USE_XICU in the hard_config.h file
51#endif
52
53////////////////////////////////////////////////////////////////////////////////
54//     _icu_set_mask()
55// This function set the mask register for the ICU channel identified
56// by the cluster index and the processor index.
57// All '1' bits are set / all '0' bits are not modified.
58// Returns 0 if success, > 0 if error.
59////////////////////////////////////////////////////////////////////////////////
60unsigned int _icu_set_mask( unsigned int cluster_xy,
61                            unsigned int proc_id,
62                            unsigned int value )
63{
64    // parameters checking
65    unsigned int x = cluster_xy >> Y_WIDTH;
66    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
67    if (x >= X_SIZE)             return 1; 
68    if (y >= Y_SIZE)             return 1; 
69    if (proc_id >= NB_PROCS_MAX) return 1; 
70
71#if USE_XICU
72    _printf("[GIET ERROR] _icu_set_mask() should not be used if USE_XICU is set\n");
73    return 1;
74#else
75    unsigned int * icu_address = (unsigned int *) ((unsigned int)&seg_icu_base + 
76                                 (cluster_xy * (unsigned int)&vseg_cluster_increment));
77    icu_address[proc_id * ICU_SPAN + ICU_MASK_SET] = value; 
78    return 0;
79#endif
80}
81
82////////////////////////////////////////////////////////////////////////////////
83//     _icu_get_index()
84// This function returns the index of the highest priority (smaller index) IRQ.
85// The ICU channel is identified by the cluster index and the processor index.
86// Returns 0 if success, > 0 if error.
87////////////////////////////////////////////////////////////////////////////////
88unsigned int _icu_get_index( unsigned int cluster_xy, 
89                             unsigned int proc_id, 
90                             unsigned int * buffer) 
91{
92    // parameters checking
93    unsigned int x = cluster_xy >> Y_WIDTH;
94    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
95    if (x >= X_SIZE)             return 1; 
96    if (y >= Y_SIZE)             return 1; 
97    if (proc_id >= NB_PROCS_MAX) return 1;
98
99#if USE_XICU
100    _printf("[GIET ERROR] _icu_set_mask() should not be used if USE_XICU is set\n");
101    return 1;
102#else
103    unsigned int* icu_address = (unsigned int *) ((unsigned int)&seg_icu_base + 
104                                 (cluster_xy * (unsigned int)&vseg_cluster_increment));
105    *buffer = icu_address[proc_id * ICU_SPAN + ICU_IT_VECTOR]; 
106    return 0;
107#endif
108}
109
110
111// Local Variables:
112// tab-width: 4
113// c-basic-offset: 4
114// c-file-offsets:((innamespace . 0)(inline-open . 0))
115// indent-tabs-mode: nil
116// End:
117// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
118
Note: See TracBrowser for help on using the repository browser.