1 |
786 |
skrzyp |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// moab_eth_dp83816.inl
|
4 |
|
|
//
|
5 |
|
|
// MOAB ethernet I/O definitions.
|
6 |
|
|
//
|
7 |
|
|
//==========================================================================
|
8 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
9 |
|
|
// -------------------------------------------
|
10 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
11 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
|
12 |
|
|
//
|
13 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
14 |
|
|
// the terms of the GNU General Public License as published by the Free
|
15 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
16 |
|
|
// version.
|
17 |
|
|
//
|
18 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
19 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
20 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
21 |
|
|
// for more details.
|
22 |
|
|
//
|
23 |
|
|
// You should have received a copy of the GNU General Public License
|
24 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
25 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
26 |
|
|
//
|
27 |
|
|
// As a special exception, if other files instantiate templates or use
|
28 |
|
|
// macros or inline functions from this file, or you compile this file
|
29 |
|
|
// and link it with other works to produce a work based on this file,
|
30 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
31 |
|
|
// the GNU General Public License. However the source code for this file
|
32 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
33 |
|
|
// General Public License v2.
|
34 |
|
|
//
|
35 |
|
|
// This exception does not invalidate any other reasons why a work based
|
36 |
|
|
// on this file might be covered by the GNU General Public License.
|
37 |
|
|
// -------------------------------------------
|
38 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
39 |
|
|
//==========================================================================
|
40 |
|
|
//#####DESCRIPTIONBEGIN####
|
41 |
|
|
//
|
42 |
|
|
// Author(s): gthomas
|
43 |
|
|
// Contributors:
|
44 |
|
|
// Date: 2003-09-29
|
45 |
|
|
// Purpose: MOAB ethernet defintions
|
46 |
|
|
//####DESCRIPTIONEND####
|
47 |
|
|
//==========================================================================
|
48 |
|
|
|
49 |
|
|
#include
|
50 |
|
|
#include
|
51 |
|
|
|
52 |
|
|
#undef DP_IN
|
53 |
|
|
#undef DP_OUT
|
54 |
|
|
#define DP_IN(_b_, _o_, _d_) HAL_READ_UINT32LE((cyg_addrword_t)(_b_)+(_o_), (_d_))
|
55 |
|
|
#define DP_OUT(_b_, _o_, _d_) HAL_WRITE_UINT32LE((cyg_addrword_t)(_b_)+(_o_), (_d_))
|
56 |
|
|
|
57 |
|
|
static cyg_bool
|
58 |
|
|
find_rtl8381x_match_func(cyg_uint16 v, cyg_uint16 d, cyg_uint32 c, void *p)
|
59 |
|
|
{
|
60 |
|
|
return ((v == 0x100B) && (d == 0x0020));
|
61 |
|
|
}
|
62 |
|
|
|
63 |
|
|
static void
|
64 |
|
|
_moab_eth_init(dp83816_priv_data_t *dp)
|
65 |
|
|
{
|
66 |
|
|
cyg_pci_device_id devid;
|
67 |
|
|
cyg_pci_device dev_info;
|
68 |
|
|
|
69 |
|
|
devid = CYG_PCI_NULL_DEVID;
|
70 |
|
|
if (cyg_pci_find_matching( &find_rtl8381x_match_func, NULL, &devid )) {
|
71 |
|
|
cyg_pci_get_device_info(devid, &dev_info);
|
72 |
|
|
cyg_pci_translate_interrupt(&dev_info, &dp->interrupt);
|
73 |
|
|
dp->base = (cyg_uint8 *)(dev_info.base_map[0] & ~1);
|
74 |
|
|
diag_printf("DP83816 at %p, interrupt: %x\n", dp->base, dp->interrupt);
|
75 |
|
|
}
|
76 |
|
|
}
|
77 |
|
|
|
78 |
|
|
#undef CYGHWR_NS_DP83816_PLF_INIT
|
79 |
|
|
#define CYGHWR_NS_DP83816_PLF_INIT(dp) _moab_eth_init(dp)
|
80 |
|
|
|
81 |
|
|
// Align buffers on a cache boundary
|
82 |
|
|
#define RxBUFSIZE CYGNUM_DEVS_ETH_MOAB_DP83816_RxNUM*_DP83816_BUFSIZE
|
83 |
|
|
#define TxBUFSIZE CYGNUM_DEVS_ETH_MOAB_DP83816_TxNUM*_DP83816_BUFSIZE
|
84 |
|
|
static unsigned char dp83816_eth_rxbufs[RxBUFSIZE] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));
|
85 |
|
|
static unsigned char dp83816_eth_txbufs[TxBUFSIZE] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));
|
86 |
|
|
static dp83816_bd_t dp83816_eth_rxbd[CYGNUM_DEVS_ETH_MOAB_DP83816_RxNUM] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));
|
87 |
|
|
static dp83816_bd_t dp83816_eth_txbd[CYGNUM_DEVS_ETH_MOAB_DP83816_TxNUM] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));
|
88 |
|
|
|
89 |
|
|
extern char _moab_eth1_ESA[];
|
90 |
|
|
static dp83816_priv_data_t dp83816_eth1_priv_data = {
|
91 |
|
|
"eth1_esa",
|
92 |
|
|
_moab_eth1_ESA,
|
93 |
|
|
CYGNUM_DEVS_ETH_MOAB_DP83816_RxNUM, // Number of Rx buffers
|
94 |
|
|
dp83816_eth_rxbufs, // Rx buffer space
|
95 |
|
|
dp83816_eth_rxbd, // Rx buffer headers
|
96 |
|
|
CYGNUM_DEVS_ETH_MOAB_DP83816_TxNUM, // Number of Tx buffers
|
97 |
|
|
dp83816_eth_txbufs, // Tx buffer space
|
98 |
|
|
dp83816_eth_txbd, // Tx buffer headers
|
99 |
|
|
};
|
100 |
|
|
|
101 |
|
|
ETH_DRV_SC(dp83816_sc,
|
102 |
|
|
&dp83816_eth1_priv_data, // Driver specific data
|
103 |
|
|
"eth1",
|
104 |
|
|
dp83816_start,
|
105 |
|
|
dp83816_stop,
|
106 |
|
|
dp83816_control,
|
107 |
|
|
dp83816_can_send,
|
108 |
|
|
dp83816_send,
|
109 |
|
|
dp83816_recv,
|
110 |
|
|
dp83816_deliver, // "pseudoDSR" called from fast net thread
|
111 |
|
|
dp83816_poll, // poll function, encapsulates ISR and DSR
|
112 |
|
|
dp83816_int_vector);
|
113 |
|
|
|
114 |
|
|
NETDEVTAB_ENTRY(dp83816_netdev,
|
115 |
|
|
"eth1",
|
116 |
|
|
dp83816_init,
|
117 |
|
|
&dp83816_sc);
|
118 |
|
|
|
119 |
|
|
#if defined(CYGPKG_REDBOOT)
|
120 |
|
|
#include
|
121 |
|
|
#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
|
122 |
|
|
#include
|
123 |
|
|
#include
|
124 |
|
|
RedBoot_config_option("eth1 network hardware address [MAC]",
|
125 |
|
|
eth1_esa,
|
126 |
|
|
ALWAYS_ENABLED, true,
|
127 |
|
|
CONFIG_ESA, _moab_eth1_ESA
|
128 |
|
|
);
|
129 |
|
|
#endif // CYGSEM_REDBOOT_FLASH_CONFIG
|
130 |
|
|
#else
|
131 |
|
|
#ifndef CONFIG_ESA
|
132 |
|
|
#define CONFIG_ESA 6
|
133 |
|
|
#endif
|
134 |
|
|
#endif // CYGPKG_REDBOOT
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
// EOF moab_eth_dp83816.inl
|