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

Last change on this file since 315 was 313, checked in by alain, 11 years ago

The main modif is in TTY driver: The hard lock implemented in the
vci_multi_tty component is not used anymore, because this (non cacheable)
lock was not scalable... It has been replaced by a software (cacheable) lock
that has a better scalability in case of hardware cache coherence.
(see the _tty_get_lock() and _tty_release_lock() functions)

File size: 3.0 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 giet_vsegs.ld 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/////////////////////////////////////////////////////////////////////////////////
23// This low level function returns the value of register (channel / index)
24/////////////////////////////////////////////////////////////////////////////////
25unsigned int _pic_get_register( unsigned int channel,
26                                unsigned int index )
27{
28    unsigned int* vaddr = (unsigned int*)&seg_pic_base + channel*IOPIC_SPAN + index;
29    return _io_extended_read( vaddr );
30}
31
32/////////////////////////////////////////////////////////////////////////////////
33// This low level function set a new value in register (channel / index) 
34/////////////////////////////////////////////////////////////////////////////////
35void _pic_set_register( unsigned int channel,
36                        unsigned int index,
37                        unsigned int value )
38{
39    unsigned int* vaddr = (unsigned int*)&seg_pic_base + channel*IOPIC_SPAN + index;
40    _io_extended_write( vaddr, value );
41}
42
43/////////////////////////////////////////////////////////////////////////////////
44// This function initializes the XICU target physical address (vaddr + extend)
45// corresponding to a given HWI channel.
46/////////////////////////////////////////////////////////////////////////////////
47void _pic_init( unsigned int channel,      // source PIC HWI channel
48                unsigned int vaddr,        // dest XCU WTI address
49                unsigned int extend )      // dest XCU cluster_xy
50{
51    _pic_set_register( channel, IOPIC_ADDRESS, vaddr );
52    _pic_set_register( channel, IOPIC_EXTEND, extend );
53}
54
55/////////////////////////////////////////////////////////////////////////////////
56// This function returns the status of a given HWI channel.
57/////////////////////////////////////////////////////////////////////////////////
58unsigned int _pic_get_status( unsigned int channel )
59{
60    return _pic_get_register( channel, IOPIC_STATUS );
61}
62
63
64// Local Variables:
65// tab-width: 4
66// c-basic-offset: 4
67// c-file-offsets:((innamespace . 0)(inline-open . 0))
68// indent-tabs-mode: nil
69// End:
70// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
71
Note: See TracBrowser for help on using the repository browser.