source: trunk/hal/tsar_mips32/core/hal_drivers.c @ 452

Last change on this file since 452 was 407, checked in by alain, 6 years ago

First implementation of fork/exec.

File size: 4.9 KB
Line 
1/*
2 * hal_drivers.c - Driver initializers for TSAR
3 *
4 * Copyright (c) 2017 Maxime Villard
5 *
6 * This file is part of ALMOS-MKH.
7 *
8 * ALMOS-MKH is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2.0 of the License.
11 *
12 * ALMOS-MKH is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include <hal_types.h>
23#include <chdev.h>
24#include <hal_drivers.h>
25#include <printk.h>
26
27#include <soclib_tty.h>
28#include <soclib_pic.h>
29#include <soclib_iob.h>
30#include <soclib_bdv.h>
31#include <soclib_hba.h>
32#include <soclib_mmc.h>
33#include <soclib_nic.h>
34#include <soclib_dma.h>
35
36#include <dev_txt.h>
37#include <dev_pic.h>
38#include <dev_ioc.h>
39#include <dev_mmc.h>
40#include <dev_nic.h>
41#include <dev_dma.h>
42
43///////////////////////////////////////////////////////////////////////////////
44//    TXT
45///////////////////////////////////////////////////////////////////////////////
46
47//////////////////////////////////////////
48void hal_drivers_txt_init( chdev_t  * txt,
49                           uint32_t   impl )
50{
51        assert( (impl == IMPL_TXT_TTY), __FUNCTION__ , "bad implementation" );
52
53        soclib_tty_init( txt );
54}
55
56///////////////////////////////////////////////////////////////////////////////
57//    PIC
58///////////////////////////////////////////////////////////////////////////////
59
60//////////////////////////////////////////
61void hal_drivers_pic_init( chdev_t  * pic,
62                           uint32_t   impl )
63{
64    assert( (impl == IMPL_PIC_SCL), __FUNCTION__, "bad implementation" );
65
66        soclib_pic_init( pic );
67
68        /* update the PIC chdev extension */
69        pic->ext.pic.enable_timer = &soclib_pic_enable_timer;
70        pic->ext.pic.enable_ipi   = &soclib_pic_enable_ipi;
71        pic->ext.pic.enable_irq   = &soclib_pic_enable_irq;
72        pic->ext.pic.disable_irq  = &soclib_pic_disable_irq;
73        pic->ext.pic.bind_irq     = &soclib_pic_bind_irq;
74        pic->ext.pic.send_ipi     = &soclib_pic_send_ipi;
75        pic->ext.pic.ack_ipi      = &soclib_pic_ack_ipi;
76        pic->ext.pic.extend_init  = &soclib_pic_extend_init;
77}
78
79///////////////////////////////////////////////////////////////////////////////
80//    IOB
81///////////////////////////////////////////////////////////////////////////////
82
83//////////////////////////////////////////
84void hal_drivers_iob_init( chdev_t  * iob,
85                           uint32_t   impl )
86{
87        assert( (impl == IMPL_IOB_TSR), __FUNCTION__ , "bad implementation" );
88
89        soclib_iob_init( iob );
90
91        /* update the IOB chdev extension */
92        iob->ext.iob.set_active = &soclib_iob_set_active;
93        iob->ext.iob.set_ptpr   = &soclib_iob_set_ptpr;
94        iob->ext.iob.inval_page = &soclib_iob_inval_page;
95        iob->ext.iob.get_bvar   = &soclib_iob_get_bvar;
96        iob->ext.iob.get_srcid  = &soclib_iob_get_srcid;
97        iob->ext.iob.get_error  = &soclib_iob_get_error;
98}
99
100///////////////////////////////////////////////////////////////////////////////
101//    IOC
102///////////////////////////////////////////////////////////////////////////////
103
104//////////////////////////////////////////
105void hal_drivers_ioc_init( chdev_t  * ioc,
106                           uint32_t   impl )
107{
108        if (impl == IMPL_IOC_BDV) 
109    {
110                soclib_bdv_init( ioc );
111        } 
112    else if (impl == IMPL_IOC_HBA)
113    {
114                soclib_hba_init( ioc );
115        }
116    else 
117    {
118                assert( false , __FUNCTION__ , "undefined IOC device implementation" );
119        }
120}
121
122///////////////////////////////////////////////////////////////////////////////
123//    MMC
124///////////////////////////////////////////////////////////////////////////////
125
126//////////////////////////////////////////
127void hal_drivers_mmc_init( chdev_t  * mmc,
128                           uint32_t   impl )
129{
130        assert( (impl == IMPL_MMC_TSR), __FUNCTION__ , "bad implementation" );
131 
132    soclib_mmc_init( mmc );
133}
134
135///////////////////////////////////////////////////////////////////////////////
136//    NIC
137///////////////////////////////////////////////////////////////////////////////
138
139//////////////////////////////////////////
140void hal_drivers_nic_init( chdev_t  * nic,
141                           uint32_t   impl )
142{
143        assert( (impl == IMPL_NIC_CBF), __FUNCTION__ , "bad implementation" );
144 
145    soclib_nic_init( nic );
146}
147
148///////////////////////////////////////////////////////////////////////////////
149//    DMA
150///////////////////////////////////////////////////////////////////////////////
151
152//////////////////////////////////////////
153void hal_drivers_dma_init( chdev_t  * dma,
154                           uint32_t   impl )
155{
156        assert( (impl == IMPL_DMA_SCL), __FUNCTION__ , "bad implementation" );
157 
158    soclib_dma_init( dma );
159}
160
Note: See TracBrowser for help on using the repository browser.