日本免费全黄少妇一区二区三区-高清无码一区二区三区四区-欧美中文字幕日韩在线观看-国产福利诱惑在线网站-国产中文字幕一区在线-亚洲欧美精品日韩一区-久久国产精品国产精品国产-国产精久久久久久一区二区三区-欧美亚洲国产精品久久久久

1 freebsd網(wǎng)卡驅(qū)動程序詳解( 二 )


} el_softc[NEL]; /*NEL在el.h中定義,即編譯時(shí)產(chǎn)生的頭文件,意思為支持的網(wǎng)卡數(shù)*/
/*
看看arpcom結(jié)構(gòu)吧

* 該結(jié)構(gòu)是以太網(wǎng)設(shè)備驅(qū)動程序和ARP程序所共享.

struct arpcom {
/*
* ifnet 結(jié)構(gòu)必須在此結(jié)構(gòu)的第一個(gè)位置.
/
struct ifnet ac_if;
u_char ac_enaddr[6]; /* 以太網(wǎng)硬件地址/
int ac_multicnt; /* 多播地址列表數(shù) /
void *ac_netgraph; /* netgraph 節(jié)點(diǎn)信息,即我們所說的PPPoE,也就是ADSL寬帶所用到的 /
};


*/

/* 一些函數(shù)申明 */
static int el_attach(struct isa_device *);/*第二步:填充相關(guān)的數(shù)據(jù)結(jié)構(gòu)*/
static void el_init(void *); /*不用說,是初始化,在probe,attach之后被調(diào)用*/
static int el_ioctl(struct ifnet *,u_long,CADdr_t);/*控制網(wǎng)卡的函樹指針*/
static int el_probe(struct isa_device *);/*第一步:探測程序.查看是否卡存在和是否在正確的位置.*/
static void el_start(struct ifnet *);/*把數(shù)據(jù)包從硬件接口輸出去*/
static void el_reset(void *);/* 該例程重設(shè)接口. 在el_watchdog()中調(diào)用*/
static void el_watchdog(struct ifnet *);/*一般該函數(shù)用于包在一定時(shí)間內(nèi)沒發(fā)送出去,就調(diào)用他,在
本驅(qū)動程序中并不支持該函數(shù),在我的rtl8139說明中有*/
static void el_stop(void *);/*停止接口,在el_ioctl()和el_reset()中調(diào)用*/
static int el_xmit(struct el_softc *,int);/*把數(shù)據(jù)包放到芯片內(nèi),發(fā)送到以太網(wǎng)上*/
static ointhand2_t elintr;/*中斷例程*/
static __inline void elread(struct el_softc *,caddr_t,int);/* 傳遞包到更高一級協(xié)議處理,即ether_input()例程.由elintr()調(diào)用 */
static struct mbuf *elget(caddr_t,int,struct ifnet *); /* 從網(wǎng)卡上下載數(shù)據(jù)包,len是數(shù)據(jù)的長度,本地以太網(wǎng)頭部被分開*/
static __inline void el_hardreset(void *);/* 這是一個(gè)子程序,目的是重設(shè)硬件.*/

/* isa_driver結(jié)構(gòu) 為 autoconf準(zhǔn)備 */
/* isa_driver結(jié)構(gòu)說明:
該結(jié)構(gòu)來之于文件isa_device.h頭文件
結(jié)構(gòu)成員:
/*
* 通用的設(shè)備驅(qū)動程序結(jié)構(gòu).
*
* 沒一設(shè)備驅(qū)動程序定義一組例程入口,由設(shè)置程序在啟動時(shí)使用.

struct isa_driver {
int (*probe) __P((struct isa_device *idp));
/* 測試設(shè)備是否存在
int (*attach) __P((struct isa_device *idp));
/* 為設(shè)備設(shè)置驅(qū)動程序
char *name; /* 設(shè)備名稱
int sensitive_hw; /* 探測發(fā)生有沖突時(shí)為真,ISA設(shè)備的老毛病
};
*/
struct isa_driver eldriver = {
el_probe, el_attach, "el"
};


/* 探測程序.查看是否卡存在和是否在正確的位置. */
static int
el_probe(struct isa_device *idev)
{
/*
isa_device 是設(shè)備的通用結(jié)構(gòu),該結(jié)構(gòu)說明在isa_device.h頭文件中,說明如下:
struct isa_device {
int id_id; /* 設(shè)備的 id
struct isa_driver *id_driver; 指向設(shè)備的驅(qū)動程序結(jié)構(gòu)
int id_iobase; /* 基本IO地址
int id_iosize; /* 基本IO地址的長度
u_int id_irq; /* 中斷
int id_drq; /* DMA
caddr_t id_maddr; /* 在總線中的物理IO內(nèi)存地址(即便要)
int id_msize; /* IO內(nèi)存的大小
union {
inthand2_t *id_i;
ointhand2_t *id_oi;中斷例程指針
} id_iu; /* 中斷接口例程
#define id_intr id_iu.id_i
#define id_ointr id_iu.id_oi
int id_unit; /* 在該類設(shè)備中是第幾個(gè)
int id_flags; /* flags
int id_enabled; /* 設(shè)備激活了嗎
struct isa_device *id_next; /* 在 userconfig()中用于isa_devlist
struct device *id_device;
};

*/
struct el_softc *sc;
u_short base; /* 僅僅為了方便 */
u_char station_addr[ETHER_ADDR_LEN];/*以太網(wǎng)的硬件地址*/
int i;

/* 搜集一些信息 */
sc = &el_softc[idev->id_unit];/*sc是softc結(jié)構(gòu),如果你有NEL塊el卡的話就有NEL個(gè)softc
結(jié)構(gòu),當(dāng)然也有可能同時(shí)還有其他的xx_softc結(jié)構(gòu)*/
sc->el_base = idev->id_iobase;/*該塊卡的基本I/O地址*/
base = sc->el_base;/*有一點(diǎn)多余,只是為了方便下面的引用*/

推薦閱讀