1 /* $NetBSD: ether_if.c,v 1.4 2009/01/12 11:00:49 tsutsui Exp $ */
4 * Copyright (c) 2004 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <lib/libsa/stand.h>
33 #include <lib/libkern/libkern.h>
35 #include <sys/socket.h>
37 #include <netinet/in.h>
38 #include <netinet/in_systm.h>
40 #include <lib/libsa/net.h>
41 #include <lib/libsa/netif.h>
42 #include <lib/libsa/bootp.h>
43 #include <lib/libsa/dev_net.h>
45 #include <machine/sbd.h>
46 #define _SBD_TR2A_PRIVATE
47 #include <machine/sbd_tr2a.h> /* getsecs. */
51 struct devsw netdevsw
= {
52 "net", net_strategy
, net_open
, net_close
, net_ioctl
55 int ether_match(struct netif
*, void *);
56 int ether_probe(struct netif
*, void *);
57 void ether_init(struct iodesc
*, void *);
58 int ether_get(struct iodesc
*, void *, size_t, saseconds_t
);
59 int ether_put(struct iodesc
*, void *, size_t);
60 void ether_end(struct netif
*);
62 extern bool lance_init(void);
63 extern void lance_eaddr(uint8_t *);
64 extern bool lance_get(void *, size_t);
65 extern bool lance_put(void *, size_t);
67 struct netif_stats ether_stats
[1];
69 struct netif_dif ether_ifs
[] = {
70 { 0, 1, ðer_stats
[0], 0, },
73 struct netif_driver __netif_driver
= {
86 int n_netif_drivers
= 1;
87 struct netif_driver
*netif_drivers
[1] = { &__netif_driver
};
90 ether_match(struct netif
*netif
, void *hint
)
93 return SBD_INFO
->machine
== MACHINE_TR2A
;
97 ether_probe(struct netif
*netif
, void *hint
)
104 ether_init(struct iodesc
*iodesc
, void *hint
)
108 lance_eaddr(iodesc
->myea
);
112 ether_get(struct iodesc
*iodesc
, void *pkt
, size_t len
, saseconds_t timeout
)
115 return lance_get(pkt
, len
) ? len
: -1;
119 ether_put(struct iodesc
*iodesc
, void *pkt
, size_t len
)
122 return lance_put(pkt
, len
) ? len
: -1;
126 ether_end(struct netif
*netif
)
135 while (/*CONSTCOND*/1)
143 volatile uint8_t *mkclock
;
146 mkclock
= RTC_MK48T18_ADDR
;
147 t
= bcdtobin(*(mkclock
+ 4));
148 t
+= bcdtobin(*(mkclock
+ 8)) * 60;
149 t
+= bcdtobin(*(mkclock
+ 12)) * 60 * 60;