source: soft/giet_vm/giet_drivers/xcu_driver.h @ 540

Last change on this file since 540 was 529, checked in by alain, 10 years ago

1) Removing the IOC driver (integrated in the FAT library).
2) Simplifying the BDV, HBA, SDC, RDK drivers: they support
only two modes (synchronous => polling / descheduling => IRQ),
and only one access function (for both read/write).

File size: 7.4 KB
Line 
1///////////////////////////////////////////////////////////////////////////////////
2// File     : xcu_driver.h
3// Date     : 01/11/2013
4// Author   : alain greiner
5// Copyright (c) UPMC-LIP6
6///////////////////////////////////////////////////////////////////////////////////
7// The xcu_driver.c and xcu_driver.h files are part ot the GIET-VM nano-kernel.
8// This driver supports the SoCLib vci_xicu, that is a vectorised interrupt
9// controler supporting three types of interrupts:
10//
11// - HWI : HardWare Interrupts (from hardware peripherals)
12// - PTI : Programmable Timer Interrupts (contained in the XCU component)
13// - WTI : Write Trigered Interrupts (from software, or from a PIC controller)
14//
15// It can exist several interrupt controller unit in the architecture
16// (one per cluster), and each one can contain several channels:
17// The number of XICU channels is equal to NB_PROCS_MAX, because there is
18// one private XICU channel per processor in a cluster.
19//
20// The virtual base address of the segment associated to the component is:
21//
22//      vbase = SEG_XCU_BASE + cluster_xy * PERI_CLUSTER_INCREMENT
23//
24// The SEG_XCU_BSE  and PERI_CLUSTER_INCREMENT values must be defined
25// in the hard_config.h file.
26////////////////////////////////////////////////////////////////////////////////
27
28#ifndef _GIET_XCU_DRIVER_H_
29#define _GIET_XCU_DRIVER_H_
30
31///////////////////////////////////////////////////////////////////////////////////
32// XICU registers offsets
33///////////////////////////////////////////////////////////////////////////////////
34
35enum Xcu_registers
36{
37    XCU_WTI_REG = 0,
38    XCU_PTI_PER = 1,
39    XCU_PTI_VAL = 2,
40    XCU_PTI_ACK = 3,
41
42    XCU_MSK_PTI = 4,
43    XCU_MSK_PTI_ENABLE = 5,
44    XCU_MSK_PTI_DISABLE = 6,
45    XCU_PTI_ACTIVE = 6,
46
47    XCU_MSK_HWI = 8,
48    XCU_MSK_HWI_ENABLE = 9,
49    XCU_MSK_HWI_DISABLE = 10,
50    XCU_HWI_ACTIVE = 10,
51
52    XCU_MSK_WTI = 12,
53    XCU_MSK_WTI_ENABLE = 13,
54    XCU_MSK_WTI_DISABLE = 14,
55    XCU_WTI_ACTIVE = 14,
56
57    XCU_PRIO = 15,
58};
59
60#define XCU_REG(func, index) (((func)<<5)|(index))
61 
62////////////////////////////////////////////////////////////////////////////////
63//                           access functions
64////////////////////////////////////////////////////////////////////////////////
65
66////////////////////////////////////////////////////////////////////////////////
67// This function set the mask register for the IRQ type defined by "irq_type",
68// and for the channel identified by the "cluster_xy" and "channel" arguments.
69// All '1' bits are set / all '0' bits are not modified.
70////////////////////////////////////////////////////////////////////////////////
71extern void _xcu_set_mask( unsigned int cluster_xy,
72                           unsigned int channel, 
73                           unsigned int mask, 
74                           unsigned int irq_type );
75
76////////////////////////////////////////////////////////////////////////////////
77// This function returns the index and the type of the highest priority
78// - active PTI (Timer Interrupt), then
79// - active HWI (Hardware Interrupt), then
80// - active WTI (Software Interrupt)
81////////////////////////////////////////////////////////////////////////////////
82extern void _xcu_get_index( unsigned int   cluster_xy, 
83                            unsigned int   channel,   
84                            unsigned int * index,
85                            unsigned int * irq_type );
86
87////////////////////////////////////////////////////////////////////////////////
88// This function writes the "wdata" value in the mailbox defined
89// by the "cluster_xy" and "wti_index" arguments.
90////////////////////////////////////////////////////////////////////////////////
91extern void _xcu_send_wti( unsigned int cluster_xy,
92                           unsigned int wti_index,
93                           unsigned int wdata );
94
95///////////////////////////////////////////////////////////////////////////////
96// This function writes the "wdata" by physical xcu address value in the mailbox
97// defined by the "cluster_xy" and "wti_index" arguments.
98////////////////////////////////////////////////////////////////////////////////
99void _xcu_send_wti_paddr( unsigned int cluster_xy,
100                          unsigned int wti_index,
101                          unsigned int wdata );
102////////////////////////////////////////////////////////////////////////////////
103// This function returns the value contained in a WTI mailbox defined by
104// the cluster_xy and "wti_index" arguments. This value is written in
105// the "value" argument, and the corresponding WTI is acknowledged.
106////////////////////////////////////////////////////////////////////////////////
107extern void _xcu_get_wti_value( unsigned int   cluster_xy,
108                                unsigned int   wti_index,
109                                unsigned int * value );
110
111////////////////////////////////////////////////////////////////////////////////
112// This function returns the address of a WTI mailbox defined by
113// the "wti_index" argument, in the unsigned int "address" argument.
114// It is used by the GIET to configurate the IOPIC component.
115// There is no access to a specific XCU component in a specific cluster.
116////////////////////////////////////////////////////////////////////////////////
117extern void _xcu_get_wti_address( unsigned int   wti_index,
118                                  unsigned int * address );
119
120////////////////////////////////////////////////////////////////////////////////
121// This function activates a timer contained in XCU by writing in the
122// proper register the period value.
123////////////////////////////////////////////////////////////////////////////////
124extern void _xcu_timer_start( unsigned int cluster_xy, 
125                              unsigned int pti_index,
126                              unsigned int period ); 
127
128//////////////////////////////////////////////////////////////////////////////
129// This function desactivates a timer in XCU component
130// by writing in the proper register.
131//////////////////////////////////////////////////////////////////////////////
132extern void _xcu_timer_stop( unsigned int cluster_xy, 
133                             unsigned int pti_index ); 
134
135//////////////////////////////////////////////////////////////////////////////
136// This function acknowlegge a timer interrupt in XCU
137// component by reading in the proper XCU register.
138// It can be used by both the isr_switch() for a "system" timer,
139// or by the _isr_timer() for an "user" timer.
140//////////////////////////////////////////////////////////////////////////////
141extern void _xcu_timer_reset_irq( unsigned int cluster_xy, 
142                                  unsigned int pti_index );
143
144//////////////////////////////////////////////////////////////////////////////
145// This function resets a timer counter. To do so, we re-write the period
146// in the proper register, what causes the count to restart.
147// The period value is read from the same (TIMER_PERIOD) register,
148// this is why in appearance we do nothing useful (read a value
149// from a register and write this value in the same register).
150// This function is called during a context switch (user or preemptive)
151/////////////////////////////////////////////////////////////////////////////
152extern void _xcu_timer_reset_cpt( unsigned int cluster_xy, 
153                                  unsigned int pti_index ); 
154
155#endif
156
157// Local Variables:
158// tab-width: 4
159// c-basic-offset: 4
160// c-file-offsets:((innamespace . 0)(inline-open . 0))
161// indent-tabs-mode: nil
162// End:
163// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
164
Note: See TracBrowser for help on using the repository browser.