Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Remove remaining uses of libsa/netif -- the "netif"...
details: https://anonhg.NetBSD.org/src/rev/3504bdc53e09
branches: trunk
changeset: 544172:3504bdc53e09
user: drochner <drochner%NetBSD.org@localhost>
date: Thu Mar 13 15:36:06 2003 +0000
description:
Remove remaining uses of libsa/netif -- the "netif" structure was only
used to lookup a "struct of_dev", everything else was ballast.
Do it straightforward now and assign the ofdev directly to io_netif.
diffstat:
sys/arch/ofppc/stand/ofwboot/net.c | 28 +++++++++--------
sys/arch/ofppc/stand/ofwboot/netif_of.c | 50 +++++++++++++-------------------
sys/arch/ofppc/stand/ofwboot/netif_of.h | 4 ++
sys/arch/shark/stand/ofwboot/net.c | 28 +++++++++--------
sys/arch/shark/stand/ofwboot/netif_of.c | 50 +++++++++++++-------------------
sys/arch/shark/stand/ofwboot/netif_of.h | 4 ++
6 files changed, 80 insertions(+), 84 deletions(-)
diffs (truncated from 478 to 300 lines):
diff -r cb0fa25a3692 -r 3504bdc53e09 sys/arch/ofppc/stand/ofwboot/net.c
--- a/sys/arch/ofppc/stand/ofwboot/net.c Thu Mar 13 14:56:56 2003 +0000
+++ b/sys/arch/ofppc/stand/ofwboot/net.c Thu Mar 13 15:36:06 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: net.c,v 1.4 1999/05/07 16:19:28 drochner Exp $ */
+/* $NetBSD: net.c,v 1.5 2003/03/13 15:36:06 drochner Exp $ */
/*
* Copyright (C) 1995 Wolfgang Solfrank.
@@ -40,7 +40,7 @@
*
* At open time, this does:
*
- * find interface - netif_open()
+ * find interface - netif_of_open()
* BOOTP - bootp()
* RPC/mountd - nfs_mount()
*
@@ -59,10 +59,12 @@
#include <lib/libsa/stand.h>
#include <lib/libsa/net.h>
-#include <lib/libsa/netif.h>
#include <lib/libkern/libkern.h>
+#include "ofdev.h"
+#include "netif_of.h"
+
char rootpath[FNAME_SIZE];
static int netdev_sock = -1;
@@ -77,13 +79,13 @@
struct of_dev *op;
{
int error = 0;
-
+
/*
* On first open, do netif open, mount, etc.
*/
if (open_count == 0) {
/* Find network interface. */
- if ((netdev_sock = netif_open(op)) < 0) {
+ if ((netdev_sock = netif_of_open(op)) < 0) {
error = errno;
goto bad;
}
@@ -93,7 +95,7 @@
open_count++;
bad:
if (netdev_sock >= 0 && open_count == 0) {
- netif_close(netdev_sock);
+ netif_of_close(netdev_sock);
netdev_sock = -1;
}
return error;
@@ -108,7 +110,7 @@
*/
if (open_count > 0)
if (--open_count == 0) {
- netif_close(netdev_sock);
+ netif_of_close(netdev_sock);
netdev_sock = -1;
}
}
@@ -120,21 +122,21 @@
#ifdef DEBUG
printf("net_mountroot\n");
#endif
-
+
/*
* Get info for NFS boot: our IP address, out hostname,
* server IP address, and our root path on the server.
* We use BOOTP (RFC951, RFC1532) exclusively as mandated
* by PowerPC Reference Platform Specification I.4.2
*/
-
+
bootp(netdev_sock);
-
+
if (myip.s_addr == 0)
return ETIMEDOUT;
-
+
printf("Using IP address: %s\n", inet_ntoa(myip));
-
+
#ifdef DEBUG
printf("myip: %s (%s)", hostname, inet_ntoa(myip));
if (gateip.s_addr)
@@ -144,7 +146,7 @@
printf("\n");
#endif
printf("root addr=%s path=%s\n", inet_ntoa(rootip), rootpath);
-
+
/*
* Get the NFS file handle (mount).
*/
diff -r cb0fa25a3692 -r 3504bdc53e09 sys/arch/ofppc/stand/ofwboot/netif_of.c
--- a/sys/arch/ofppc/stand/ofwboot/netif_of.c Thu Mar 13 14:56:56 2003 +0000
+++ b/sys/arch/ofppc/stand/ofwboot/netif_of.c Thu Mar 13 15:36:06 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netif_of.c,v 1.5 2001/07/22 14:43:15 wiz Exp $ */
+/* $NetBSD: netif_of.c,v 1.6 2003/03/13 15:36:06 drochner Exp $ */
/*
* Copyright (C) 1995 Wolfgang Solfrank.
@@ -50,14 +50,13 @@
#include <lib/libsa/stand.h>
#include <lib/libsa/net.h>
-#include <lib/libsa/netif.h>
#include "ofdev.h"
#include "openfirm.h"
-static struct netif netif_of;
+#include "netif_of.h"
-struct iodesc sockets[SOPEN_MAX];
+static struct iodesc sdesc;
struct iodesc *
socktodesc(sock)
@@ -65,23 +64,22 @@
{
if (sock != 0)
return NULL;
- return sockets;
+ return &sdesc;
}
int
-netif_open(machdep_hint)
- void *machdep_hint;
+netif_of_open(op)
+ struct of_dev *op;
{
- struct of_dev *op = machdep_hint;
struct iodesc *io;
int fd, error;
char addr[32];
-
+
#ifdef NETIF_DEBUG
printf("netif_open...");
#endif
/* find a free socket */
- io = sockets;
+ io = &sdesc;
if (io->io_netif) {
#ifdef NETIF_DEBUG
printf("device busy\n");
@@ -91,9 +89,8 @@
}
memset(io, 0, sizeof *io);
- netif_of.nif_devdata = op;
- io->io_netif = &netif_of;
-
+ io->io_netif = (void *)op;
+
/* Put our ethernet address in io->myea */
OF_getprop(OF_instance_to_package(op->handle),
"mac-address", io->myea, sizeof io->myea);
@@ -104,34 +101,29 @@
return 0;
}
-int
-netif_close(fd)
+void
+netif_of_close(fd)
int fd;
{
struct iodesc *io;
- struct netif *ni;
#ifdef NETIF_DEBUG
printf("netif_close(%x)...", fd);
#endif
+
+#ifdef NETIF_DEBUG
if (fd != 0) {
-#ifdef NETIF_DEBUG
printf("EBADF\n");
-#endif
- errno = EBADF;
- return -1;
+ return;
}
+#endif
- io = &sockets[fd];
- ni = io->io_netif;
- if (ni != NULL) {
- ni->nif_devdata = NULL;
- io->io_netif = NULL;
- }
+ io = &sdesc;
+ io->io_netif = NULL;
+
#ifdef NETIF_DEBUG
printf("OK\n");
#endif
- return 0;
}
/*
@@ -148,7 +140,7 @@
ssize_t rv;
size_t sendlen;
- op = desc->io_netif->nif_devdata;
+ op = (struct of_dev *)desc->io_netif;
#ifdef NETIF_DEBUG
{
@@ -195,7 +187,7 @@
int tick0, tmo_ms;
int len;
- op = desc->io_netif->nif_devdata;
+ op = (struct of_dev *)desc->io_netif;
#ifdef NETIF_DEBUG
printf("netif_get: pkt=0x%x, maxlen=%d, tmo=%d\n",
diff -r cb0fa25a3692 -r 3504bdc53e09 sys/arch/ofppc/stand/ofwboot/netif_of.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/ofppc/stand/ofwboot/netif_of.h Thu Mar 13 15:36:06 2003 +0000
@@ -0,0 +1,4 @@
+/* $NetBSD: netif_of.h,v 1.1 2003/03/13 15:36:06 drochner Exp $ */
+
+int netif_of_open(struct of_dev *);
+void netif_of_close(int);
diff -r cb0fa25a3692 -r 3504bdc53e09 sys/arch/shark/stand/ofwboot/net.c
--- a/sys/arch/shark/stand/ofwboot/net.c Thu Mar 13 14:56:56 2003 +0000
+++ b/sys/arch/shark/stand/ofwboot/net.c Thu Mar 13 15:36:06 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: net.c,v 1.1 2002/02/10 01:58:17 thorpej Exp $ */
+/* $NetBSD: net.c,v 1.2 2003/03/13 15:36:07 drochner Exp $ */
/*
* Copyright (C) 1995 Wolfgang Solfrank.
@@ -40,7 +40,7 @@
*
* At open time, this does:
*
- * find interface - netif_open()
+ * find interface - netif_of_open()
* BOOTP - bootp()
* RPC/mountd - nfs_mount()
*
@@ -59,10 +59,12 @@
#include <lib/libsa/stand.h>
#include <lib/libsa/net.h>
-#include <lib/libsa/netif.h>
#include <lib/libkern/libkern.h>
+#include "ofdev.h"
+#include "netif_of.h"
+
char rootpath[FNAME_SIZE];
static int netdev_sock = -1;
@@ -77,13 +79,13 @@
struct of_dev *op;
{
int error = 0;
-
+
/*
* On first open, do netif open, mount, etc.
*/
if (open_count == 0) {
/* Find network interface. */
- if ((netdev_sock = netif_open(op)) < 0) {
+ if ((netdev_sock = netif_of_open(op)) < 0) {
error = errno;
goto bad;
}
@@ -93,7 +95,7 @@
open_count++;
bad:
if (netdev_sock >= 0 && open_count == 0) {
- netif_close(netdev_sock);
+ netif_of_close(netdev_sock);
netdev_sock = -1;
}
return error;
@@ -108,7 +110,7 @@
*/
if (open_count > 0)
if (--open_count == 0) {
Home |
Main Index |
Thread Index |
Old Index