source: soft/giet_vm/giet_drivers/pic_driver.c @ 396

Last change on this file since 396 was 320, checked in by alain, 10 years ago

All drivers have been modified to use only the information
contained in the hard_config.h file

File size: 3.1 KB
Line 
1///////////////////////////////////////////////////////////////////////////////////
2// File     : pic_driver.c
3// Date     : 05/03/2014
4// Author   : alain greiner
5// Copyright (c) UPMC-LIP6
6///////////////////////////////////////////////////////////////////////////////////
7// The pic_driver.c and pic_drivers.h files are part ot the GIET-VM kernel.
8// This driver supports the SocLib vci_iopic component.
9//
10// The SEG_PIC_BASE address must be defined in hard_config.h file.
11///////////////////////////////////////////////////////////////////////////////////
12// Implementation note:
13//
14// All physical accesses to device registers are done by the two
15// _pic_get_register(), _pic_set_register() low-level functions,
16// that are handling virtual / physical addressing.
17///////////////////////////////////////////////////////////////////////////////////
18
19#include <pic_driver.h>
20#include <utils.h>
21
22#if !defined(SEG_PIC_BASE)
23# error: You must define SEG_PIC_BASE in the hard_config.h file
24#endif
25
26/////////////////////////////////////////////////////////////////////////////////
27// This low level function returns the value of register (channel / index)
28/////////////////////////////////////////////////////////////////////////////////
29unsigned int _pic_get_register( unsigned int channel,
30                                unsigned int index )
31{
32    unsigned int* vaddr = (unsigned int*)SEG_PIC_BASE + channel*IOPIC_SPAN + index;
33    return _io_extended_read( vaddr );
34}
35
36/////////////////////////////////////////////////////////////////////////////////
37// This low level function set a new value in register (channel / index) 
38/////////////////////////////////////////////////////////////////////////////////
39void _pic_set_register( unsigned int channel,
40                        unsigned int index,
41                        unsigned int value )
42{
43    unsigned int* vaddr = (unsigned int*)SEG_PIC_BASE + channel*IOPIC_SPAN + index;
44    _io_extended_write( vaddr, value );
45}
46
47/////////////////////////////////////////////////////////////////////////////////
48// This function initializes the XICU target physical address (vaddr + extend)
49// corresponding to a given HWI channel.
50/////////////////////////////////////////////////////////////////////////////////
51void _pic_init( unsigned int channel,      // source PIC HWI channel
52                unsigned int vaddr,        // dest XCU WTI address
53                unsigned int extend )      // dest XCU cluster_xy
54{
55    _pic_set_register( channel, IOPIC_ADDRESS, vaddr );
56    _pic_set_register( channel, IOPIC_EXTEND, extend );
57}
58
59/////////////////////////////////////////////////////////////////////////////////
60// This function returns the status of a given HWI channel.
61/////////////////////////////////////////////////////////////////////////////////
62unsigned int _pic_get_status( unsigned int channel )
63{
64    return _pic_get_register( channel, IOPIC_STATUS );
65}
66
67
68// Local Variables:
69// tab-width: 4
70// c-basic-offset: 4
71// c-file-offsets:((innamespace . 0)(inline-open . 0))
72// indent-tabs-mode: nil
73// End:
74// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
75
Note: See TracBrowser for help on using the repository browser.