1 //==========================================================================
3 // moab_eth_dp83816.inl
5 // MOAB ethernet I/O definitions.
7 //==========================================================================
8 //####ECOSGPLCOPYRIGHTBEGIN####
9 // -------------------------------------------
10 // This file is part of eCos, the Embedded Configurable Operating System.
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
12 // Copyright (C) 2003 Gary Thomas
14 // eCos is free software; you can redistribute it and/or modify it under
15 // the terms of the GNU General Public License as published by the Free
16 // Software Foundation; either version 2 or (at your option) any later version.
18 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
19 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 // You should have received a copy of the GNU General Public License along
24 // with eCos; if not, write to the Free Software Foundation, Inc.,
25 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
27 // As a special exception, if other files instantiate templates or use macros
28 // or inline functions from this file, or you compile this file and link it
29 // with other works to produce a work based on this file, this file does not
30 // by itself cause the resulting work to be covered by the GNU General Public
31 // License. However the source code for this file must still be made available
32 // in accordance with section (3) of the GNU General Public License.
34 // This exception does not invalidate any other reasons why a work based on
35 // this file might be covered by the GNU General Public License.
37 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
38 // at http://sources.redhat.com/ecos/ecos-license/
39 // -------------------------------------------
40 //####ECOSGPLCOPYRIGHTEND####
41 //==========================================================================
42 //#####DESCRIPTIONBEGIN####
47 // Purpose: MOAB ethernet defintions
48 //####DESCRIPTIONEND####
49 //==========================================================================
51 #include <cyg/hal/hal_cache.h>
52 #include <cyg/io/pci.h>
56 #define DP_IN(_b_, _o_, _d_) HAL_READ_UINT32LE((cyg_addrword_t)(_b_)+(_o_), (_d_))
57 #define DP_OUT(_b_, _o_, _d_) HAL_WRITE_UINT32LE((cyg_addrword_t)(_b_)+(_o_), (_d_))
60 find_rtl8381x_match_func(cyg_uint16 v, cyg_uint16 d, cyg_uint32 c, void *p)
62 return ((v == 0x100B) && (d == 0x0020));
66 _moab_eth_init(dp83816_priv_data_t *dp)
68 cyg_pci_device_id devid;
69 cyg_pci_device dev_info;
71 devid = CYG_PCI_NULL_DEVID;
72 if (cyg_pci_find_matching( &find_rtl8381x_match_func, NULL, &devid )) {
73 cyg_pci_get_device_info(devid, &dev_info);
74 cyg_pci_translate_interrupt(&dev_info, &dp->interrupt);
75 dp->base = (cyg_uint8 *)(dev_info.base_map[0] & ~1);
76 diag_printf("DP83816 at %p, interrupt: %x\n", dp->base, dp->interrupt);
80 #undef CYGHWR_NS_DP83816_PLF_INIT
81 #define CYGHWR_NS_DP83816_PLF_INIT(dp) _moab_eth_init(dp)
83 // Align buffers on a cache boundary
84 #define RxBUFSIZE CYGNUM_DEVS_ETH_MOAB_DP83816_RxNUM*_DP83816_BUFSIZE
85 #define TxBUFSIZE CYGNUM_DEVS_ETH_MOAB_DP83816_TxNUM*_DP83816_BUFSIZE
86 static unsigned char dp83816_eth_rxbufs[RxBUFSIZE] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));
87 static unsigned char dp83816_eth_txbufs[TxBUFSIZE] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));
88 static dp83816_bd_t dp83816_eth_rxbd[CYGNUM_DEVS_ETH_MOAB_DP83816_RxNUM] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));
89 static dp83816_bd_t dp83816_eth_txbd[CYGNUM_DEVS_ETH_MOAB_DP83816_TxNUM] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));
91 extern char _moab_eth1_ESA[];
92 static dp83816_priv_data_t dp83816_eth1_priv_data = {
95 CYGNUM_DEVS_ETH_MOAB_DP83816_RxNUM, // Number of Rx buffers
96 dp83816_eth_rxbufs, // Rx buffer space
97 dp83816_eth_rxbd, // Rx buffer headers
98 CYGNUM_DEVS_ETH_MOAB_DP83816_TxNUM, // Number of Tx buffers
99 dp83816_eth_txbufs, // Tx buffer space
100 dp83816_eth_txbd, // Tx buffer headers
103 ETH_DRV_SC(dp83816_sc,
104 &dp83816_eth1_priv_data, // Driver specific data
112 dp83816_deliver, // "pseudoDSR" called from fast net thread
113 dp83816_poll, // poll function, encapsulates ISR and DSR
116 NETDEVTAB_ENTRY(dp83816_netdev,
121 #if defined(CYGPKG_REDBOOT)
122 #include <pkgconf/redboot.h>
123 #ifdef CYGSEM_REDBOOT_FLASH_CONFIG
125 #include <flash_config.h>
126 RedBoot_config_option("eth1 network hardware address [MAC]",
128 ALWAYS_ENABLED, true,
129 CONFIG_ESA, _moab_eth1_ESA
131 #endif // CYGSEM_REDBOOT_FLASH_CONFIG
136 #endif // CYGPKG_REDBOOT
139 // EOF moab_eth_dp83816.inl