net.c

来自「ADS下的bios工程」· C语言 代码 · 共 87 行

C
87
字号
#include <bios/stdio.h>#include <bios/boot.h>#include <bios/time.h>#include <bios/config.h>#include <bios/netdev.h>#include <bios/string.h>#define DEBUG_S3C4_NET#undef DEBUG_S3C4_NET#ifdef DEBUG_S3C4_NET	#define DEBUG_NET(fmt, args...) printf("%s-%s()[%d]: " fmt, __FILE__, __FUNCTION__, __LINE__, args)#else	#define DEBUG_NET(fmt, args...)#endifextern int eth_s3c4_probe(struct netdev *dev);extern int cs8900_probe (struct netdev *dev);extern int do_tftp(struct netdev *dev);struct probe_dev netprobe[]  = {       { cs8900_probe, 0},	       { NULL, 0},};struct netdev probed_net_devs;static int net_probe(void){	static struct netdev *dev;        struct probe_dev *dp;		DEBUG_NET("In the net_probe %c\n",'!');	dev = &probed_net_devs;	dp =  (struct probe_dev *)&netprobe;	while(dp->probe != NULL) {		DEBUG_NET("dp->probe is not NULL %c\n", '!');		if (dp->probe(dev) == 0) {		       return 0;                }		else if(dp->status == 0) {		          dp->status = dp->probe(dev);		          if(dp->status == 0)			       return 0;                }		dp++;	}        return -1;}static int net_start(void){	struct netdev *dev = &probed_net_devs;        if (!dev) return -1;	if (dev->open(dev) == 0) dev->up = 1;        	return 0;}static int net_load(void){	struct netdev *dev = &probed_net_devs;	return do_tftp(dev);}static int net_stop(void){	struct netdev *dev = &probed_net_devs;		if(dev->up) dev->close(dev);	return 0;}struct bootdev boot_net = {	"net",        /* net device name */	net_probe,    /* int (*init)(void); */	net_start,    /* int (*start)(void); */	net_load,     /* int (*load)(void); */	net_stop      /* int (*stop)(void); */};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?