VxWorks5.5.1 移植RTL8139驱动和配置网络启动调试环境
- 运行平台
主机操作系统:Windows XP
开发环境: Tornado 2.2.1
目标机CPU:英特尔 ATOM D2550
- 相关知识介绍
VxWorks系统支持两种形式的网络驱动:一种是标准的BSD驱动,支持通用的BSD4.4网络API结构等和大多所BSD网络驱动类似,将网络驱动协议层与硬件驱动联系在一起;另外一种是END网络驱动,是VxWorks独有的,简称增强型网络模型(可裁剪的增强型网络堆栈,SENS-Scalable Enhanced Networks Stack)。
END型驱动程序由BSP部分和驱动程序功能实现部分组成。指定END设备与其他类型的设备驱动方式不同,网络设备驱动程序的安装是可以通过修改BSP实现的。
图1.1 VxWorks网络结构图
图1.2MUX和END接口调用关系
END设备驱动程序的装载过程:1.指定END设备;2.装载END设备;3.启动END设备;
图1.3 网络初始化流程
- 驱动程序的移植
- 获取驱动源码
RTL8139D是中国台湾瑞昱公司的100/10M自适应网卡芯片,可在官网下载到支持Tornado 2.0 X86 版本的驱动。下载地址:
下载后解压得到三个文件夹config(系统配置文件),h(头文件),src(驱动程序)。
- 配置BSP相关的系统文件
网络驱程序是协议栈的一部分,网络驱动程序是否正确必须要放到协议栈中验证,因此需要将网络程序加载到系统中。添加驱动需要修改三个BSP的系统文件:config.h、configNet.h、sysLib.c。这三个文件都位于C:\Tornado2.2\target\config\BSP包\具体修改如下:
- Config.h:
1:在Network添加INCLUDE_RTL_81X9_END,同时undef掉其他的网卡。
/* Network driver options */
#define INCLUDE_END /* Enhanced Network Driver Support */
#undef INCLUDE_DEC21X40_END /* (END) DEC 21x4x PCI interface */
#undef INCLUDE_EL_3C90X_END /* (END) 3Com Fast EtherLink XL PCI */
#undef INCLUDE_ELT_3C509_END /* (END) 3Com EtherLink III interface */
#undef INCLUDE_ENE_END /* (END) Eagle/Novell NE2000 interface */
#undef INCLUDE_FEI_END /* (END) Intel 8255[7/8/9] PCI interface */
#undef INCLUDE_GEI8254X_END /* (END) Intel 82543/82544 PCI interface */
#undef INCLUDE_LN_97X_END /* (END) AMD 79C97x PCI interface */
#undef INCLUDE_ULTRA_END /* (END) SMC Elite16 Ultra interface */
#define INCLUDE_RTL_81X9_END /* Realtek 81x9 Fast Ethernet Controller */
#undef INCLUDE_BSD /* BSD / Netif Driver Support (Deprecated) */
#undef INCLUDE_EEX /* (BSD) Intel EtherExpress interface */
#undef INCLUDE_EEX32 /* (BSD) Intel EtherExpress flash 32 */
#undef INCLUDE_ELC /* (BSD) SMC Elite16 interface */
#undef INCLUDE_ESMC /* (BSD) SMC 91c9x Ethernet interface */
2:在PCI中添加INCLUDE_RTL_81X9_END
/* Include PCI support for drivers & libraries that require it. */
#if defined (INCLUDE_LN_97X_END) || defined (INCLUDE_EL_3C90X_END) || \
defined (INCLUDE_FEI_END) || defined (INCLUDE_DEC21X40_END) || \
defined (INCLUDE_GEI8254X_END) || defined (INCLUDE_AIC_7880) || \
defined (INCLUDE_WINDML) || defined (INCLUDE_USB) || \
defined (INCLUDE_RTL_81X9_END)
# define INCLUDE_PCI
#endif
2.configNet.h
1:在定义中添加:
/* RTL81X9 EtherLink PCI driver defines */
#ifdef INCLUDE_RTL_81X9_END
/*
* load string format
* <devMemAddr>:<devIoAddr>:<pciMemBase:<vecnum>:<intLvl>:<memAdrs>:
* <memSize>:<memWidth>:<csr3b>:<offset>:<flags>
*/
#define RTL_81X9_BUFF_LOAN_0 1
#define RTL_81X9_LOAD_FUNC sysRtl81x9EndLoad
#define RTL_81X9_LOAD_STR_0 endLoadStr[0] /* First entry loc */
#define RTL_81X9_LOAD_COUNT 4
IMPORT END_OBJ * RTL_81X9_LOAD_FUNC (char *, void *);
char endLoadStr [RTL_81X9_LOAD_COUNT] [END_DESC_MAX];
#endif /* INCLUDE_RTL_81X9_END */
2:在endDevTbl []相应的位置添加:
#ifdef INCLUDE_RTL_81X9_END
{0, RTL_81X9_LOAD_FUNC, RTL_81X9_LOAD_STR_0, TRUE, NULL, FALSE},
#endif /* INCLUDE_RTL_81X9_END */
- sysLib.c
- 在/*imports*/中添加
/* include rtl81x9End driver support routines */
#ifdef INCLUDE_RTL_81X9_END
IMPORT STATUS sysRtl81x9PciInit (void);
#endif /* INCLUDE_RTL_81X9_END */
- 在#ifdef INCLUDE_XXX_END中添加
/* include rtl81x9End driver support routines */
#ifdef INCLUDE_RTL_81X9_END
#include "sysRtl81x9End.c"
#endif /* INCLUDE_RTL_81X9_END */
- 在PCI-to-PCI brige initialization 之后添加
#ifdef INCLUDE_RTL_81X9_END
sysRtl81x9PciInit ();
#endif /* INCLUDE_RTL_81X9_END */
以上修改都可以在下载下来的config里面的文件与之对比得到。
- 设置Makefile
添加如红色字体中的一句:
CPU = PENTIUM4
TOOL = gnu
TGT_DIR = $(WIND_BASE)/target
include $(TGT_DIR)/h/make/defs.bsp
ADDED_MODULES += rtl81x9.o
#include $(TGT_DIR)/h/make/make.$(CPU)$(TOOL)
#include $(TGT_DIR)/h/make/defs.$(WIND_HOST_TYPE)
- 设置开机启动项DEFAULT_BOOT_LINE
在config.h中修改
#define DEFAULT_BOOT_LINE \
"rtl(0,0) peter:vxWorks h=192.168.0.74 e=192.168.0.58 \
u=target pw=target tn=VxTarget"
- 添加文件和修改头文件
- 将sysRtl81x9End.c、rtl81x9.c、rtl81x9.h放入Tornado2.2\target\config\BSP包\
- 修改sysRtl81x9End.c和rtl81x9.h中的#include "drv/end/unsupported/rtl81x9.h"为#include "rtl81x9.h"
- 生产bootrom.bin即可使用WFTPD网络启动