Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / arch / ews4800mips / stand / common / ether_if.c
blobcfaca1339d5964e886a77085641c71e2b0af3686
1 /* $NetBSD: ether_if.c,v 1.4 2009/01/12 11:00:49 tsutsui Exp $ */
3 /*-
4 * Copyright (c) 2004 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by UCHIYAMA Yasushi.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
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>
36 #include <net/if.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. */
49 #include "local.h"
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, &ether_stats[0], 0, },
73 struct netif_driver __netif_driver = {
74 "ether",
75 ether_match,
76 ether_probe,
77 ether_init,
78 ether_get,
79 ether_put,
80 ether_end,
81 ether_ifs,
85 int debug = 1;
86 int n_netif_drivers = 1;
87 struct netif_driver *netif_drivers[1] = { &__netif_driver };
89 int
90 ether_match(struct netif *netif, void *hint)
93 return SBD_INFO->machine == MACHINE_TR2A;
96 int
97 ether_probe(struct netif *netif, void *hint)
100 return 0;
103 void
104 ether_init(struct iodesc *iodesc, void *hint)
107 lance_init();
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;
125 void
126 ether_end(struct netif *netif)
131 void
132 _rtt(void)
135 while (/*CONSTCOND*/1)
137 /* NOTREACHED */
140 satime_t
141 getsecs(void)
143 volatile uint8_t *mkclock;
144 u_int t;
146 mkclock = RTC_MK48T18_ADDR;
147 t = bcdtobin(*(mkclock + 4));
148 t += bcdtobin(*(mkclock + 8)) * 60;
149 t += bcdtobin(*(mkclock + 12)) * 60 * 60;
151 return (satime_t)t;