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

Last change on this file since 260 was 258, checked in by alain, 11 years ago

This is a major release, including a deep restructuration of code.
The main evolutions are

  • use of the Tsar preloader to load the GIET boot-loader from disk
  • introduction of a FAT32 file system library,
  • use of this fat32 library by the boot-loader to load the map.bin data structure, and the various .elf files
  • reorganisation of drivers (one file per peripheral).
  • introduction of drivers for new peripherals: vci_chbuf_dma and vci_multi_ahci.
  • introduction of a new physical memory allocator in the boot code.

This release has been tested on the tsar_generic_iob architecture,
for the two following mappings: 4c_1p_iob_four.xml and 4c_1p_iob_sort.xml

File size: 3.8 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_id * 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 <utils.h>
27
28#if !defined(NB_CLUSTERS)
29# error: You must define NB_CLUSTERS in the hard_config.h file
30#endif
31
32#if (NB_CLUSTERS > 256)
33# error: NB_CLUSTERS cannot be larger than 256!
34#endif
35
36#if !defined(NB_PROCS_MAX)
37# error: You must define NB_PROCS_MAX in the hard_config.h file
38#endif
39
40#if (NB_PROCS_MAX > 8)
41# error: NB_PROCS_MAX cannot be larger than 8!
42#endif
43
44#if !defined( USE_XICU )
45# error: You must define USE_XICU in the hard_config.h file
46#endif
47
48////////////////////////////////////////////////////////////////////////////////
49//     _icu_set_mask()
50// This function set the mask register for the ICU channel identified
51// by the cluster index and the processor index.
52// All '1' bits are set / all '0' bits are not modified.
53// Returns 0 if success, > 0 if error.
54////////////////////////////////////////////////////////////////////////////////
55unsigned int _icu_set_mask( unsigned int cluster_id,
56                            unsigned int proc_id,
57                            unsigned int value )
58{
59    // parameters checking
60    if (cluster_id >= NB_CLUSTERS) return 1; 
61    if (proc_id >= NB_PROCS_MAX)   return 1; 
62
63#if USE_XICU
64    _puts("[GIET ERROR] _icu_set_mask should not be used if USE_XICU is set\n");
65    return 1;
66#else
67    unsigned int * icu_address = (unsigned int *) ((unsigned int)&seg_icu_base + 
68                                 (cluster_id * (unsigned int)&vseg_cluster_increment));
69    icu_address[proc_id * ICU_SPAN + ICU_MASK_SET] = value; 
70    return 0;
71#endif
72}
73
74////////////////////////////////////////////////////////////////////////////////
75//     _icu_get_index()
76// This function returns the index of the highest priority (smaller index) IRQ.
77// The ICU channel is identified by the cluster index and the processor index.
78// Returns 0 if success, > 0 if error.
79////////////////////////////////////////////////////////////////////////////////
80unsigned int _icu_get_index( unsigned int cluster_id, 
81                             unsigned int proc_id, 
82                             unsigned int * buffer) 
83{
84    // parameters checking
85    if (cluster_id >= NB_CLUSTERS)  return 1;
86    if (proc_id >= NB_PROCS_MAX)    return 1;
87
88#if USE_XICU
89    _puts("[GIET ERROR] _icu_get_index should not be used if USE_XICU is set\n");
90    return 1;
91#else
92    unsigned int* icu_address = (unsigned int *) ((unsigned int)&seg_icu_base + 
93                                 (cluster_id * (unsigned int)&vseg_cluster_increment));
94    *buffer = icu_address[proc_id * ICU_SPAN + ICU_IT_VECTOR]; 
95    return 0;
96#endif
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.