ZYNQ移植vxWorks6.9 添加第二路网口

ZYNQ移植vxWorks6.9 添加第二路网口

步骤:
1.添加驱动支持
2.添加地址映射
3.在系统下注册设备

1.添加驱动支持

在BSP的" hwconf.c "中添加驱动支持
添加中断优先级,“gicPriority”

#ifdef DRV_VXBEND_ZYNQMAC
    { INT_VEC_ETH0,        120 },
    { INT_VEC_ETH1,        120 },
#endif  /* DRV_VXBEND_ZYNQMAC */

添加中断触发方式“gicTrigger”

#ifdef DRV_VXBEND_ZYNQMAC
    { INT_VEC_ETH0,             VXB_INTR_TRIG_LEVEL },
    { INT_VEC_ETH1,             VXB_INTR_TRIG_LEVEL },
#endif  /* DRV_VXBEND_ZYNQMAC */

添加设备中断注册

#ifdef DRV_VXBEND_ZYNQMAC
    { INT_VEC_ETH0,        "gem",              0,       0 },
    { INT_VEC_ETH1,        "gem",              1,       0 },
#endif  /* DRV_VXBEND_ZYNQMAC */

添加设备资源,
注意PHY地址“phyAddr”,需要和硬件保持一致

#ifdef DRV_VXBEND_ZYNQMAC
LOCAL struct hcfResource zynqGemDevResources[] = {
    { "regBase",    HCF_RES_INT,    {(void *)ZYNQ7K_GEM0_BASE} },
    { "phyAddr",    HCF_RES_INT,    {(void *)1} },
	{ "isExPhy",	HCF_RES_INT,	{(void *)ZYNQ_MIO_RGMII} },
    { "clkSet",     HCF_RES_ADDR,   {(void *)sysZynq7kGemClkSet} },
#   ifdef INCLUDE_SYS_MEM_MGMT
    { "ifCached",   HCF_RES_ADDR,   {(void *)ifMemCached} },
#endif /* INCLUDE_SYS_MEM_MGMT */
    { "miiIfName",  HCF_RES_STRING, {(void *)"gem"} },
    { "miiIfUnit",  HCF_RES_INT,    {(void *)0} }
};
#define zynqGemDevNum NELEMENTS(zynqGemDevResources)

LOCAL struct hcfResource zynqGem1DevResources[] = {
    { "regBase",    HCF_RES_INT,    {(void *)ZYNQ7K_GEM1_BASE} },
    { "phyAddr",    HCF_RES_INT,    {(void *)2} },
	{ "isExPhy",	HCF_RES_INT,	{(void *)ZYNQ_MIO_RGMII} },
    { "clkSet",     HCF_RES_ADDR,   {(void *)sysZynq7kGemClkSet} },
#   ifdef INCLUDE_SYS_MEM_MGMT
    { "ifCached",   HCF_RES_ADDR,   {(void *)ifMemCached} },
#endif /* INCLUDE_SYS_MEM_MGMT */
    { "miiIfName",  HCF_RES_STRING, {(void *)"gem"} },
    { "miiIfUnit",  HCF_RES_INT,    {(void *)0} }
};
#define zynqGem1DevNum NELEMENTS(zynqGem1DevResources)
#endif /* DRV_VXBEND_ZYNQMAC */

添加设备注册

#ifdef DRV_VXBEND_ZYNQMAC
    { "gem",              0, VXB_BUSID_PLB, 0, zynqGemDevNum,      zynqGemDevResources },
    { "gem",              1, VXB_BUSID_PLB, 0, zynqGem1DevNum,      zynqGem1DevResources },
#endif /* DRV_VXBEND_ZYNQMAC */

2.添加地址映射

在BSP的“sysLib.c ”中添加第二路网口的地址映射

#ifdef DRV_VXBEND_ZYNQMAC
    {
    ZYNQ7K_GEM0_BASE,  /* Zynq-7000 Ethernet */
    ZYNQ7K_GEM0_BASE,
    PAGE_SIZE,
    MMU_ATTR_VALID_MSK | MMU_ATTR_PROT_MSK | MMU_ATTR_DEVICE_SHARED_MSK,
    MMU_ATTR_VALID     | MMU_ATTR_SUP_RWX  | MMU_ATTR_DEVICE_SHARED
    },
    {
    ZYNQ7K_GEM1_BASE,  /* Zynq-7000 Ethernet */
    ZYNQ7K_GEM1_BASE,
    PAGE_SIZE,
    MMU_ATTR_VALID_MSK | MMU_ATTR_PROT_MSK | MMU_ATTR_DEVICE_SHARED_MSK,
    MMU_ATTR_VALID     | MMU_ATTR_SUP_RWX  | MMU_ATTR_DEVICE_SHARED
    },
#endif  /* DRV_VXBEND_ZYNQMAC */

3.在系统下注册设备

在镜像工程中的“usrAppInit.c”中添加设备注册,配置IP地址,配置MAC地址。

注意:需要在镜像工程添加“ifconfig”组件

	ipAttach(1,"gem"); 							//注册设备
	ifconfig("gem1 192.168.1.30");				//配置IP地址
	ifconfig("gem1 up");						//启动网口设备
	ifconfig("gem1 lladdr 00:02:1e:2e:55:36");  //配置MAC地址
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值