source: trunk/kernel/drivers/soclib/drvdb.c @ 15

Last change on this file since 15 was 4, checked in by alain, 8 years ago

Introduce the chdev_t structure in place of device_t.

File size: 3.7 KB
Line 
1/*
2 * drvdb.c - Dictionary of supported devices and associated drivers
3 *
4 * Authors Ghassan Almaless (2008,2009,2010,2011,2012)
5 *         Alain Greiner (2016)
6 *
7 * Copyright (c) UPMC Sorbonne Universites
8 *
9 * This file is part of ALMOS-MKH.
10 *
11 * ALMOS-MKH.is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; version 2.0 of the License.
14 *
15 * ALMOS-MKH.is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with ALMOS-MKH.; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25#include <types.h>
26#include <errno.h>
27#include <libk.h>
28#include <event.h>
29#include <chdev.h>
30#include <driver.h>
31#include <drvdb.h>
32#include <soclib_xicu.h>
33#include <soclib_icu.h>
34#include <soclib_tty.h>
35#include <soclib_timer.h>
36#include <soclib_dma.h>
37#include <soclib_block.h>
38#include <soclib_fb.h>
39#include <soclib_memc.h>
40#include <soclib_iopic.h>
41
42
43///////////////////////////////////////////////////////////////////////////////////////////
44// This global variable defines the array of supported devices and associated drivers.
45// It must be kept consistant with the enum in file drvdb.h.
46///////////////////////////////////////////////////////////////////////////////////////////
47
48static drvdb_entry_t drivers_db[DEV_TYPE_DRVID_NR] = 
49{
50        {DEV_TYPE_RAM     , "Random Access Memory"           , NULL},
51        {DEV_TYPE_TTY     , "Text Terminal Controler"        , &soclib_tty_driver},
52    {DEV_TYPE_FBF     , "Frame Buffer Controler"         , &soclib_fbf_driver},
53    {DEV_TYPE_IOB     , "I/O Bridge Component"           , &soclib_iob_driver},
54        {DEV_TYPE_IOC_BDV , "BDV Block Device Controler"     , &soclib_bdv_driver},
55        {DEV_TYPE_IOC_HBA , "HBA Block Device Controler"     , NULL},
56    {DEV_TYPE_IOC_SDC , "SDC Block Device Controler"     , NULL},
57    {DEV_TYPE_IOC_SPI , "SPI Block Device Controler"     , NULL},
58    {DEV_TYPE_IOC_RDK , "RDK Block device Controler"     , NULL},
59        {DEV_TYPE_MMC     , "L2 cache Configuration"         , &soclib_mmc_driver},
60        {DEV_TYPE_MWR_DMA , "DMA Coprocessor"                , NULL},
61        {DEV_TYPE_MWR_GCD , "GCD Coprocessor"                , NULL},
62        {DEV_TYPE_MWR_DCT , "DCT Coprocessor"                , NULL},
63        {DEV_TYPE_NIC     , "GMII-Compliant NIC Controller"  , NULL},
64        {DEV_TYPE_ROM     , "Read Only Memory"               , NULL},
65        {DEV_TYPE_CMA     , "Chained buffers DMA Controller" , NULL},
66        {DEV_TYPE_TIM     , "Real-Time Timer"                , &soclib_timer_driver},
67        {DEV_TYPE_XCU     , "Interrupt Controlier unit"      , &soclib_xicu_driver},
68        {DEV_TYPE_PIC     , "HWI to WTI translator"          , &soclib_iopic_driver},
69        {DEV_TYPE_NULL    , "End of Table Marker           " , NULL}
70};
71
72
73///////////////////////////////////////////////////
74drvdb_entry_t * drvdb_locate_byId( uint32_t drvid )
75{
76        if(drvid >= DEV_TYPE_RESERVED)
77                return NULL;
78
79        return &drivers_db[drvid];
80}
81
82//////////////////////////////////////////////
83drvdb_entry_t * drvdb_locate_byName( char * name )
84{
85        register uint32_t i;
86
87        for(i=0; drivers_db[i].id != DEV_TYPE_RESERVED; i++)
88                if(!strcmp(drivers_db[i].name, name))
89                        return &drivers_db[i];
90
91        return NULL;
92}
93
94driver_t* drvdb_get_driver(uint32_t drvid)
95{
96        if(drvid >= DEV_TYPE_RESERVED)
97                return NULL;
98
99        return drivers_db[drvid].driver;
100}
101
102error_t drvdb_set_driver(uint32_t drvid, driver_t *driver)
103{
104        if(drvid >= DEV_TYPE_RESERVED)
105                return ERANGE;
106
107        drivers_db[drvid].driver = driver;
108        return 0;
109}
Note: See TracBrowser for help on using the repository browser.