MPC8572调试记录

本文详细记录了 MPC8572 处理器 BootROM 的调试过程,包括解决启动异常、内存配置、串口调试、网口配置等问题。

转载地址:http://blog.sina.com.cn/s/blog_6adcb353010113t9.html

2008-5-13

1、准备从bootrom开始调试,使用probe烧录。打开workbench3.0发现不支持MPC8572。打电话给OCD专家结果找不到人。

2、改一下思路,先不调试bootrom了,因为现在里面已经有了uBoot,会有一些地址信息从中能够查到,如果使用bootrom覆盖了,后面查地址必须看原理图了。现在准备从uBoot启动,然后加在vxWorks的image。

3、启动uBoot以后发现加载不了,找freescale的工程师Liu Yi [Yi.Liu@freescale.com]要了资料。后来发现里面不但烧了uBoot还烧了linux的bsp,在启动linux之前有一个10秒的间隙,如果不输入任何东西会自动启动linux的bsp。在10秒间隙内输入任何值,就是uBoot的状态了。

4、根据8572ADS板的target.ref文档找到了uBoot的使用方法。加载vxWorks的image。结果显示指令错,可能是config.h里面的地址不匹配。

5、串口和网口都没起来,没有调试手段,准备点灯。查看了原理图,8个GPIO都通过阻排接地了,阻排在cpu风扇的下面,想用示波器或万用表检测管脚都做不到。板子上有10几个灯,查了一些原理图,有3个是电源灯,8个是总线低8位的检测。没办法了,看来是点灯是没戏了。

6、只能寄希望于异常打印上了。

 

2008-5-14

1、把config.h看了一遍,把flash地址和DRAM的地址都修正了。还是起不来。

=> tftp 100000 vxWorks.bin

Speed: 10, half duplex

Using eTSEC1 device

TFTP from server 172.25.48.32; our IP address is 172.25.48.13

Filename 'vxWorks.bin'.

Load address: 0x100000

Loading: Got error 4

T #################################################################

         ###############################################

done

Bytes transferred = 1642720 (1910e0 hex)

=> go 0x00100000

## Starting application at 0x00100000 ...

NIP: 0012D20C XER: 00000000 LR: 0011BD78 REGS: 000ffec0 TRAP: 0700 DAR: 00000000

MSR: 00008000 EE: 1 PR: 0 FP: 0 ME: 0 IR/DR: 00

 

GPR00: 0011D8B0 000FFFB0 00000200 00000001 4C000064 00000010 002910F8 00000001

GPR08: 00000001 00000020 FFFFFFFF 00000007 0FF8DC00 A19272A0 0FFF4A00 20030000

GPR16: 00000000 00000000 00000000 00000000 00000000 000FFEB0 00000000 00000000

GPR24: 0FF90A40 00000000 00000000 00000002 00100000 0FF8DF7C 0FFF5598 000FFFB0

** Illegal Instruction **

Call backtrace:

DEADBEEF 0011D8B0 0FFC8B50

Program Check Exception

### ERROR ### Please RESET the board ###

增加了编译map的选项,查看map,0011D80地址是prjConfig.c文件中函数usrInit里面调用的第二个函数cacheLibInit。

2、可能是这句不对,注释掉后,重新跑,没有任何变化。

3、在cacheLibInit前面增加while(1)。如果是cacheLibInit出错,那么增加了while后,就应该停在前面,不会再报异常。测试结果是依然异常。

4、把while往前提一句,看一下是不是我的做法不对,根本就没跑进我的代码,结果把while加在usrInit的第一句时,系统不再报错,而是停住了。说明我的这种调试方法是可行的。

5、记得曾经遇到过不配置mmu就会出现不能调用函数的情况,估计这次也是这个原因,因为usrInit里面的第一个函数sysStart只是简单的赋值,不应该有其他可能。

6、在sysAlib.s里面增加了对flash段和内存段的映射。结果还是报异常:

=> go 0x100000

## Starting application at 0x00100000 ...

NIP: 00123CB8 XER: 00000000 LR: 0011D93C REGS: 000ffee0 TRAP: 0700 DAR: 00000000

MSR: 00008000 EE: 1 PR: 0 FP: 0 ME: 0 IR/DR: 00

 

GPR00: 0011D930 000FFFD0 002867A8 00000012 00000012 00000000 0000A9EC 00000001

GPR08: 00000000 00290000 00000020 000FFFD0 00198B24 002985A0 0FFF4A00 20030000

GPR16: 00000000 00000000 00000000 00000000 00000000 000FFED0 00000000 00000000

GPR24: 0FF90A40 00000000 00000000 00000002 00100000 0FF8DF7C 0FFF5598 000FFFD0

** Illegal Instruction **

Call backtrace:

0011D930 0FFC8B50

Program Check Exception

### ERROR ### Please RESET the board ###

不过这次有了点变化,上面红色的部分即R3和R4,值是18,这是cacheLibInit的两个输入参数。绿色的两处分别是R2和R13,在函数sysStart中,这两个寄存器分别保存了_SDA2_BASE_和_SDA_BASE_,查了一下map表,果然是这两个值。说明函数能够调用了,现在情况已经发生了变化,问题集中到了cacheLibInit上。

7、最直接的想法,注释掉这个函数,并且把cache改成disable。结果在调用下一个函数excVecInit的时候又非法指令了,函数调用还是有问题。

 

2008-5-15

1、每次在集成环境上先编译完vxWorks文件,再手工使用命令:objcopyppc -O binary --binary-without-bss vxWorks vxWorks.bin把vxWorks转换成vxWorks.bin太麻烦了。准备改一下集成环境的设置,直接编译出bin文件。不过一直没有找到地方,后来咨询了上海的同事,终于找到了地方:工程点右键选择properties->Build Properties->Build Macros->POST_BUILD_RULE,在后面增加$(EXTRACT_BIN) vxWorks vxWorks.bin可以直接编译出bin来。

2、由于调试没什么进展,准备换个思路,可能uBoot对后面的vxWorks有影响,不使用uBoot,直接把bootrom烧到flash里面去。使用升级后的workbench OCD可以连上,flash的读取也正常。查看了原理图,flash的型号是MX29LV640BT。Probe连接上以后自动选择的flash型号是S29GL01GP,明显不对,但列表里面没有MX29LV640BT,应该跟29LV640是兼容的,但我不知道板子上的是B还是T,这涉及到小扇区的分布。选了29LV640MB,能够使用,烧录没有显示异常。但是启动没有反映,单步跟踪,第一条执行是跳转到0xFFFFF000,跳过去后看到的不是二进制代码,而是一片0。感觉到这里面有不对的地方。按照MPC85XX的启动流程,第一条指令在0xFFFFFFFC。MPC85XX的运行是一定需要mmu支持的,初始状态的Mmu只映射了地址空间末尾的4K。所以第一条指令只能做一个4K内的跳转,也就是0xFFFFF000内的一个地址,在这里可以写一些简单的代码扩大mmu的映射空间,然后在从这里跳到其他地址去,vxWorks习惯于跳到0xFFF00100。但是现在明显没有按照流程来,反复烧了几次都是这个结果。

3、放弃了再烧bootrom的想法,准备把uBoot再烧回去,慢慢来吧。烧回去的时候发现最后一个block烧录过程中报错,复位、断电、多次烧录都同一个结果。查看前面的都正常,可能是flash小扇区的问题,极有可能是flash型号选错了。换成29LV640MT,烧录成功,每次换很麻烦,直接修改MPC8572的寄存器文件,使之一劳永逸,位置在\ocd\0127\RegisterFiles\PowerPC\85xx\Motorola\MPC8572E_WhiteFIN_Uboot_core0.reg,将:

TF CONF 133 00005000 65436 F8000000 'AMD   S29GL01GP (65536 x 16 )  1 Device ';

改为:

TF CONF 133 00005000 65436 FF800000 'AMD   29LV640MT (65536 x 16 )  1 Device ';

这里面我不理解为什么烧bootrom的时候没有报错,可能是我们的OCD在flash烧录校验方面的算法有问题,我看了一下uBoot和bootrom在最后一个block空间内的区别,uBoot只有最后4字节是有内容的(跳转指令),其他都是F,而bootrom是有数据,在烧录bootrom的时候大部分空间都是可写的,只有最后4个字节不同,uBoot的是0x4BFFF004,bootrom的是0x4BFFF804,有一位的差别,我查看了前面烧录的内容,bootrom烧完以后,最后4字节仍然是0x4BFFF004,所以才会出现跳转以后遇到的是0不是代码的情况。我怀疑我们的OCD在校验的时候对最后4位的校验有bug。

4、既然找到了bootrom走不下去的原因,就再继续把这条路走走看。烧录后,单步跟踪正常,程序按照预定跳转到了0xFFFFF800继续执行,设置完内存的片选以后有个循环等待,循环0x2000次,我使用run to here和设置断点都无效,只有单步跟踪有用。点了run,再也停不住了,飞了。

5、注释掉循环的地方,这里的循环无非是要等个时间,我单步的执行时间足够用了。单步跟踪发现在

useBuildOscFreq:

       cmpwi   r9, PIXIS_OSC_33_MHZ

       beq     useBuildOscFreq

之间存在循环。从表面看,应该是内存主频配置不对。

 

2008-5-16

1、内存的主频配置不对可能引发了昨天的内存初始化大循环,早上查看了资料,系统晶振是66M,所以不让代码去读0xF0000000的地址了,直接配置66M。发现仍然不行,代码运行到0xFFF00354的地方,这个地方在文件bootInit.c里面,对应的语句是退栈操作,把一个数据写入0x010000f0的地方。估计是内存不可写导致了错误。

 

2008-5-20

1、这几天一直在看MPC8572的文档,把rominit又过了一遍。E500与其他架构有些不同,E500支持36位地址,这种模式超出了软件的4G空间限制。为了让软件能够访问到所有的地址空间,E500提供了一个window的概念,所有的地址只有映射到window以后才能被访问,系统提供了12个window,每个window由一组两个寄存器配置(LAWBAR,LAWAR),一个负责起始地址,一个负责大小和属性,每个window的大小必须是2的整数次幂,最小可配置的大小为4K,所以起始地址的配置寄存器只有低24为有效。也有例外,CCSRBAR、SRAM和BootRom不需要window,这是为了启动上的方便。CCSRBAR是芯片的寄存器空间,共1M,所有片内的寄存器都集中在这里,缺省地址是0x0_FF70_0000。BootRom缺省可访问空间是4K,位置在低4G空间的末尾(0x0_FFFF_F000 到0x0_FFFF_FFFF),按照FreeScale提供的启动流程,第一条指令在低4G空间的最后4个字节(0x0_FFFF_FFFC),这里一般放一条跳转指令,跳到4K范围内的一个地址,在这段最大4K的代码里面初始化内存和mmu,执行完以后再跳转到Windriver传统的启动地址0xFFF00100。SRAM被L2SRBAR缺省映射。

自己总结了一下,如果要访问一个地址,需要片选(OR/BR)、MMU、Window同时映射才可以。

在Rominit.s里面需要访问的地址,包括CCSRBAR、Flash、SDRAM三种。

 

2008-5-21

1、在查看代码的时候发现一个问题,我们在代码中前面一部分配置的mmu表项都是TS0的,直到usrconfig以后才会有TS1的表项配置,但是TS0能够起作用是要依靠msr的一个特定位为0为前提的。如果这个位不为0,mmu如何配置都没用了。想到前面几天一直重复的一个内存无法访问的问题,感觉可能跟这里有点关系。我们缺省的代码里对msr也做了处理,不过比较简单:

       

        mfmsr   r3                     

        INT_MASK (r3, r4)              

        rlwinm  r4, r4, 0, 20, 18      

        mtmsr   r4                     

        isync

实际上是只清了中断位。

我对这个地方做了一下修改,把整个msr都初始化为0:

    mfmsr   r3                     

    li      r4, 0                  

    mtmsr   r4                     

    isync

测试一下,单步跟踪果然过了bootinit前面的压栈操作,说明内存可以访问了。

2、在前面的基础上go一下,停住,通过map表比较当前位置,还在bootinit里面,单步跟踪,发现在做一个拷贝操作。代码上是在对内存做填充0的操作。我感觉这个动作也没有多大的必要,就在rominit入口的地方修改了启动参数,把BOOT_COLD改为BOOT_NORMAL。这样就避免了内存清0操作,加快了启动速度。

3、再往下跑,发现跑飞了,并且串口仍然没有打印。通过点灯,查到原因在vxBus的初始化里面,由于此时的串口还没有打印,问题比较难查了。每次加点灯可以知道代码跑到哪一行,但是遇到循环就麻烦了,没办法用点灯来看变量和字符串,麻烦的很。个人感觉,在“复杂”的vxBus初始化之前,串口应该完成初始化,并且vxBus应该提供很方便的调试开关,而不是依靠重新编译vxBus的源码。

2008-5-24

1、今天周末,前面几天都在处理中兴的网口和编译问题,没时间搞,周末把板子带回家来调试。我准备延续21日的思路,在vxBus之前把串口跑通,我以前曾经自己做过一个print的打印,功能跟printf差不多,只要串口的初始化完成了,我的print应该能够派上用场。我看了一下MPC8572的datasheet,串口跟ns16552差别不大,在bsp目录下缺省没有这样的初始化文件,我从834x的bsp下拷贝了一份sysDuart.c,编译上除了INUM_UART不认识,其他都编译正常。在vxBus初始化之前调用了一下sysDuartHwInit,然后通过直接写寄存器的方式写了一个字符,测试一下是否好使。串口上没有任何打印,可能是波特率不对或者sysDuart里面的其他内容对串口有影响,把串口寄存器初始化部分拷贝出来,自己做成了一个串口的初始化函数使用。串口的寄存器部分有一点特殊,500、501、502三个寄存器有两个功能,当503的DLAB位为1的时候,是配置波特率分频,DLAB为0的时候是其他功能。按照MPC8572的datasheet上选择533M时9600的波特率,数据是打印出来了,但是不知道是什么。看来波特率还是不对。手头没有原理图,没法知道系统时钟,不过我记得在配置内存的时候用的时钟是500M,按照500M算出来一个波特率除数0xcb7,加进去,好使,串口有输出了。

2、下一步把串口的打印做成一个函数,然后接管printf。这个步骤简单的跟1一样。

void usrSerialInit()

{

    *(volatile unsigned char *)(CCSBAR + UDCR1) = 0x01; 

    *(volatile unsigned char *)(CCSBAR + ULCR1) = 0x80; 

    *(volatile unsigned char *)(CCSBAR + UAFR1) = 0x00;

    *(volatile unsigned char *)(CCSBAR + UDMB1) = 0x0c; 

    *(volatile unsigned char *)(CCSBAR + UDLB1) = 0xb7; 

    *(volatile unsigned char *)(CCSBAR + ULCR1) = 0x03; 

    *(volatile unsigned char *)(CCSBAR + UMCR1) = 0x02; 

    *(volatile unsigned char *)(CCSBAR + UIER1) = 0x00; 

}

void usrSerialOutput(char c)

{

    volatile int i = 0x800000;

    *(volatile unsigned char *)(CCSBAR + UTHR1) = c;

    while(i--);

}

 

void Drv_Print(const char *pStr, ...)

{

    va_list Ap;

    char OutStr[2500];

    char *pCurChar;

    unsigned long ulLen = 0;

 

    va_start(Ap, pStr);

    OutStr[0] = '\0';

    vsprintf(OutStr, pStr, Ap);

    va_end(Ap);

 

    OutStr[2040] = '\0';

    ulLen = (unsigned long)strlen(OutStr);

    pCurChar = OutStr;

    while ((ulLen != 0))

    {

        usrSerialOutput(*pCurChar);

        if (*(pCurChar + 1) == '\n')

        {

            usrSerialOutput('\r');

        }

        pCurChar++;

        ulLen--;

    }

}

做了一个打印Drv_Print("\r\n line = %d", __LINE__);编译后烧进去运行,没有任何输出。看来1并不简单,开始以为是内核没有初始化,还不支持va_start这种函数,后来一看是前面删除了usrSerialInit没有再调用。虚惊一场。

3、开始跟踪vxBus的初始化流程,前面已经使用点灯的方法跟踪了一部分:

sysHwInit->hardWareInterFaceInit->hardWareInterFaceBusInit->vxbInit->plbInit1

最后一个函数里面有循环才没办法跟了,这次直接跟踪plbInit1。打开文件vxbPlb.c里面的VXBPLB_DEBUG_MSG,用刚刚实现的Drv_Print替代printf。vxBus部分的文件都是直接参与编译的,没有以库的形式提供,这为调试提供了方便。

plbInit1(): processing device ns16550

plbInit1(): announcing device ns16550

plbDevMatch((0x010af180,ppcIntCtlr),(0x010b2fe8,0xe0004500)) called

plbDevMatch((0x010afc04,openPicTimer),(0x010b2fe8,0xe0004500)) called

plbDevMatch((0x010afb74,ns16550),(0x010b2fe8,0xe0004500)) called

plbDevMatch(): checking epic

        pHcfDev (0x010ac7cc) doesn't match 0

        check failed

plbDevMatch(): checking ppcIntCtlr

        pHcfDev (0x010ac7e4) doesn't match 1

        check failed

plbDevMatch(): checking motetsec

        pHcfDev (0x010ac7fc) doesn't match 2

        check failed

plbDevMatch(): checking motetsec

        pHcfDev (0x010ac814) doesn't match 3

        check failed

plbDevMatch(): checking motetsec

        pHcfDev (0x010ac82c) doesn't match 4

        check failed

plbDevMatch(): checking motetsec

        pHcfDev (0x010ac844) doesn't match 5

        check failed

plbDevMatch(): checking tsecMdio

        pHcfDev (0x010ac85c) doesn't match 6

        check failed

plbDevMatch(): checking ns16550

        check OK, dev=ns16550 drv=ns16550

 

发现了串口设备后就不动了。开始以为是vxBus初始化串口的波特率不对,导致串口初始化的覆盖,后面的内容输出不了。但是即使不对应该屏幕上也有乱码,现在什么都没有了,显然不对。查看plbDevMatch函数,check OK, dev=ns16550 drv=ns16550是函数最后一句打印,这以后函数就退出了。而plbDevMatch的调用者是vxbDeviceAnnounce,继续跟踪。用上面同样的方法打开vxBus.c的调试开关。在前面的基础上又增加了下面两行:

vxbDeviceAnnounce(): calling driver probe

vxbDeviceAnnounce(): found match, driver @ 0x10b0374

有了打印了,问题会查的比较快,最后找到,是ns16550初始化的过程中调用sysClkFreqGet获取主频计算波特率惹得祸。缺省的MPC8572代码中有个PIXIS模块,我在新的板子上没有看到他的片选,所以没有初始化他,但是还保留了它的地址,在这里读取主频要去PIXIS的一个寄存器里面取数据,以至于访问了非法地址出错。把这块注释调,调整了一下sysClkFreqGet,直接返回500M。系统开始启动了,不过出现了Error in boot line:的错误,后面的打印很长。

4、应该是bootline出错了,每次启动的时候bootline在0x4200的地方读出来,如果是冷启动,内存不作处理是会有一些乱数据的,打印应该是这些数据引起的。本来在bootinit.c里面有

    if (startType & BOOT_CLEAR)

    {

   

        *(BOOT_LINE_ADRS) = EOS;

    }

这段是清bootline的,在我把BOOT_CLEAR改成BOOT_NORMAL以后就没法清了,我决定把启动方式还是改回去。

5、改回去后,熟悉的界面出来了,但是在我配置完启动参数后,保存的一刹那,又出错了:

0xffffd10 (tRootTask): task 0xffffd10 has had a failure and has been stopped.

0xffffd10 (tRootTask): fatal exception stack overflow!

 

2008-5-25

1、前面出的错误很奇怪,地方不是固定的,并且也不是每次都发生。估计跟cache或内存缺省数据相关。查看了config.h的配置,发现L2cache的配置还保留着,将其去除。另外bootrom没有设置保留内存,High作为bootrom的起始地址,memtop在内存的顶端256M,感觉这样使用不好,在makefile里面增加了一个-DMAKE_BOOTROM,当制作bootrom的时候只使用前面的32M内存。修改后熟悉的界面出来了:

 

                            VxWorks System Boot

 

 

Copyright 1984-2007  Wind River Systems, Inc.

 

 

 

 

 

CPU: Freescale MPC8572E - Security Engine

Version: VxWorks 6.6

BSP version: 2.0/1

Creation date: May 25 2008, 15:00:22

 

 

 

 

Press any key to stop auto-boot...

 5

 

 

[VxWorks Boot]: p

 

boot device          : motetsec

unit number          : 0

processor number     : 0

host name            : windriver

file name            : vxWorks

inet on ethernet (e) : 192.168.0.2

host inet (h)        : 192.168.0.1

gateway inet (g)     : 192.168.0.1

user (u)             : mpc8572

ftp password (pw)    : mpc8572

flags (f)            : 0x0

target name (tn)     : MPC8572

other (o)            : 0

 

[VxWorks Boot]:

 

2、输入@,网络不好使,输入‘?’,看到的网口已经attach上了:

[VxWorks Boot]: ?

 

Commands:

                     - print this list

 @                     - boot (load and go)

                     - print boot params

                     - change boot params

                     - load boot file

 g adrs                - go to adrs

                     - print fatal exception

                     - print boot logo with version

 d adrs[,n]            - display memory

 m adrs                - modify memory

 f adrs, nbytes, value - fill memory

 t adrs, adrs, nbytes  - copy memory

 M [dev][unitNo] [MAC] - set/display ethernet address

 

Bootline Format:

  $dev(0,procnum)host:/file h=# e=# b=# g=# u=usr [pw=passwd] f=#

                          tn=targetname s=script o=other

 

Device Formats:

 

Boot Flags:

  0x02 -   load local system symbols

  0x04 -   don't autoboot

  0x08 -   quick autoboot (no countdown)

  0x80 -   use tftp to get boot image

 

Available Boot Devices:

  Enhanced Network Devices:  motetsec0 motetsec1

怕是网口的标识不好,每个网口都插网线试了一下,没效果,一个报文都没发出来。

 

2008-5-29

1、直接查看网口部分的寄存器,RBASE与RPTR是相同的,说明硬件上没有报文收到。可能是phy的地址不对。前面两天,想了好多办法,都不奏效。上午准备把phy地址都读出来,发现使用vxbEtsecHend.c里面的etsecPhyRead没读到任何有用的内容,换成mii的read,却没有调用。

2、被同事提醒了一下,说uboot能够启动这个板子,并且在打印里面可能有phy地址,烧录进去uboot,启动后果然有phy地址。对应4个phy的地址应该是4、5、3、6,缺省的0、1、2、3没有一个能对的上的。配置正确后使用etheral抓包能够抓到了。

3、抓到包以后发现IP地址和MAC地址都不对。后面就再也抓不到了。直接查看芯片的发送寄存器,看到了待发送的报文,发现IP是对的,MAC不对,估计不能与host通信的原因在于MAC地址的非法。sysNet里面配置了正确的地址,加了跟踪后发现没调到。顺藤摸瓜,发现vxbEtsecHend.c里面的etsecInstInit2也没调到,这里是初始化MAC地址的地方。准备进一步跟踪vxBus,但是有一点不太明白,pDev->pDrvCtrl的内存空间也是在这里申请的,如果这个函数没调到,后面怎么会运行正确呢?先跟踪vxBus,加了打印,发现里面的vxbDevConnectInternal调用到了,这是调用设备的devConnect函数的,我在前面对网口的跟踪是也跟踪到了。不过vxbLibInit、vxbInit、vxbDevInitInternal却没有调用,vxbDevInitInternal就是调用devInstanceInit2函数的地方,也是我们要找的初始化MAC地址的地方,感觉不对啊,vxbLibInit是必然要调用的。突然想明白,可能前面没有初始化串口,光凭打印是不行的。找块空闲内存,把打印记录进去,后面再查看。果然都调用到了,那么没有调网口的devInstanceInit2的问题可能也是因为没打印出来的缘故。用同样的方法在devInstanceInit2和sysNet里面增加内存记录,发现果然调用到了,只不过MAC地址取错了而已。继续追查错误的原因,原来是NVRAM的判断引起的,nvram取了flash的一段空间模拟,没有初始化。

STATUS sysNetMacNVRamAddrGet

    (

    char *  ifName,

    int     ifUnit,

    UINT8 * ifMacAddr,

    int     ifMacAddrLen

    )

    {

    int   offset;

    char *pEnet;

    char tmp[MAC_ADRS_LEN];

 

   

 

    if (sysMacOffsetGet(ifName, ifUnit, &pEnet, &offset) != OK)

        return(ERROR);

 

#if (NV_RAM_SIZE != NONE)

   

    sysNvRamGet (pEnet, ifMacAddrLen, NV_MAC_ADRS_OFFSET+offset);

#endif

 

    if ( memcmp(pEnet, sysInvalidAddr[0], MAC_ADRS_LEN) == 0 )

        return(ERROR);

    if ( memcmp(pEnet, sysInvalidAddr[1], MAC_ADRS_LEN) == 0 )

        return(ERROR);

 

    if((pEnet[0]!=WR_ENET0) || (pEnet[1]!=WR_ENET1) || (pEnet[2]!=WR_ENET2))

    {

    int i,j;

   

    for (i = MAC_ADRS_LEN - 1,j=0; i >= 0; i--,j++)

        tmp[j] = pEnet[i];

   

    memcpy (ifMacAddr, tmp, ifMacAddrLen);

    }

    else

    memcpy (ifMacAddr, pEnet, ifMacAddrLen);

   

 

    return (OK);

    }

把nvram部分注释掉,直接使用全局数组里面的mac地址。个人感觉这样比较直接。修改以后,可以加载了。

4、BootRom的调试工作告一段落。

 

5、从workbench3.0重新创建一下工程,vxWorks image启动也成功了。到目前为止,除了L2Cache还未配置,其他都已经调试完成。


PART I: VXBUS FUNDAMENTALS 1 Getting Started with Device Driver Development .................................... 3 1.1 About Device Drivers ..................................................................................................... 3 1.2 About this Documentation ............................................................................................ 4 1.2.1 Intended Audience ........................................................................................... 4 1.2.2 Navigating this Manual .................................................................................. 4 Experienced VxWorks Device Driver Developers ........................................ 4 Novice VxWorks Device Driver Developers ................................................. 5 1.2.3 Documentation Conventions .......................................................................... 5 1.3 Additional Documentation Resources ....................................................................... 6 2 VxBus and VxBus Device Drivers ............................................................. 7 2.1 Introduction ...................................................................................................................... 7 2.2 About VxBus ................................................................................................................... 7 2.3 VxBus Device Drivers ................................................................................................... 8 2.4 Design Goals ................................................................................................................... 11 2.4.1 Performance ....................................................................................................... 11 2.4.2 Maintenance and Readability .......................................................................... 11 2.4.3 Ease of Configuration ....................................................................................... 12 2.4.4 Performance Testing ......................................................................................... 12 2.4.5 Code Size ............................................................................................................ 12 3 Device Driver Fundamentals ..................................................................... 13 3.1 Introduction ...................................................................................................................... 13 3.2 Driver Classes ................................................................................................................. 14 VxBus Device Driver Developer's Guide, 6.9 iv 3.2.1 General Classes .................................................................................................. 14 Serial Drivers .................................................................................................... 14 Storage Drivers ................................................................................................. 14 Network Interface Drivers .............................................................................. 15 Non-Volatile RAM Drivers ............................................................................. 15 Timer Drivers .................................................................................................... 16 DMA Controller Drivers ................................................................................. 16 Bus Controller Drivers ..................................................................................... 16 USB Drivers ....................................................................................................... 17 Interrupt Controller Drivers ........................................................................... 17 Multifunction Drivers ...................................................................................... 17 Remote Processing Element Drivers ............................................................. 18 Console Drivers ................................................................................................ 18 Resource Drivers .............................................................................................. 19 3.2.2 Other Classes .................................................................................................... 19 3.3 Driver Organization ....................................................................................................... 19 3.3.1 File Location ...................................................................................................... 20 Wind River Drivers ........................................................................................... 20 Third-Party Drivers .......................................................................................... 20 3.3.2 Sample Driver Files: wrsample ....................................................................... 21 3.3.3 Required Files ................................................................................................... 21 Driver Source File ............................................................................................. 22 Component Description File ........................................................................... 24 Driver Configuration Stub Files ..................................................................... 29 README File .................................................................................................... 31 Device Driver Makefiles .................................................................................. 31 3.4 VxBus Driver Methods .................................................................................................. 33 3.4.1 Representing Driver Methods in the Documentation ................................ 33 3.4.2 Parts of a Driver Method ................................................................................. 33 3.4.3 Calling Driver Methods ................................................................................... 34 3.4.4 Advertising Driver Methods .......................................................................... 35 3.4.5 Driver Method Limitations ............................................................................. 36 3.5 Driver Run-time Life Cycle .......................................................................................... 36 3.5.1 Driver Initialization Sequence ........................................................................ 36 Making Assumptions About Initialization Order ....................................... 37 Early in the Boot Process ................................................................................. 37 sysHwInit( ), PLB, and Hardware Discovery ............................................... 37 Driver Registration ........................................................................................... 38 Driver Initialization Phase 1 ........................................................................... 38 Kernel Startup ................................................................................................... 39 Driver Initialization Phase 2 ........................................................................... 39 Driver Initialization Phase 3 ........................................................................... 39 3.5.2 Invoking a Driver Method .............................................................................. 39 3.5.3 Run-time Operation ......................................................................................... 39 Contents v Unloading a Driver .......................................................................................... 40 Removing a Device from the System ............................................................ 40 Dissociating a Device from a Driver .............................................................. 40 3.5.4 Handling a System Shutdown Notification ................................................. 41 3.5.5 Handling Late Driver Registration ................................................................ 41 3.5.6 Driver Registration Order Considerations ................................................... 42 3.5.7 Driver-to-Device Matching and Hardware Availability ............................. 42 PLB ..................................................................................................................... 43 Other Bus Types ................................................................................................ 43 3.6 Services Available to Drivers ....................................................................................... 44 3.6.1 Configuration .................................................................................................... 44 Determining Driver Configuration Information ......................................... 45 Responding to Changes in Device Parameters ............................................ 47 3.6.2 Memory Allocation .......................................................................................... 47 Allocating Memory During System Startup ................................................ 48 Allocating Memory During Normal System Operation ............................. 49 Intermixing Memory Allocation Methods within a Single Driver ........... 49 3.6.3 Non-Volatile RAM Support ............................................................................. 49 3.6.4 Hardware Access .............................................................................................. 50 Finding the Address of the Hardware Registers ......................................... 50 Reading and Writing to the Hardware Registers ........................................ 51 Special Requirements for Hardware Register Access ................................. 53 VxBus Version Considerations ........................................................................ 53 3.6.5 Interrupt Handling ........................................................................................... 54 Overview of Interrupt Handling .................................................................... 54 Interrupt Indexes .............................................................................................. 54 Dynamic Interrupt Handling .......................................................................... 55 Minimizing Work Performed Within an ISR ................................................ 56 3.6.6 Synchronization ................................................................................................ 57 Task-Level Synchronization ............................................................................ 57 Interrupt-Level Synchronization .................................................................... 58 3.6.7 Direct Memory Access (DMA) ....................................................................... 59 vxbDmaBufLib .................................................................................................. 60 DMA Considerations ........................................................................................ 60 Allocating External DMA Engines ................................................................ 63 3.6.8 Atomic Operators ............................................................................................. 65 3.7 BSP Configuration ......................................................................................................... 66 3.7.1 Requirements for PLB Devices ....................................................................... 67 3.7.2 Configuring Device Parameters in the BSP .................................................. 68 3.8 SMP Considerations ...................................................................................................... 69 3.8.1 Lack of Implicit Locking ................................................................................. 69 VxBus Device Driver Developer's Guide, 6.9 vi 3.8.2 True Task-to-Task Contention ......................................................................... 70 3.8.3 Interrupt Routing ............................................................................................. 70 3.8.4 Deferring Interrupt Processing ...................................................................... 71 3.9 Device Memory Mapping in 64-Bit Devices .............................................................. 72 3.10 Physical-to-Virtual Address Translations in 64-Bit VxWorks ................................. 73 3.10.1 64-bit Changes to the Memory Management Model ................................... 73 3.10.2 Porting Drivers That Rely on Physical-to-Virtual Address Translations .. 74 Transfer Using Descriptors .............................................................................. 74 Strategies When Order is Unpredictable ....................................................... 75 4 Development Strategies ............................................................................. 77 4.1 Introduction ...................................................................................................................... 77 4.2 Writing New VxBus Drivers ........................................................................................ 77 4.2.1 Creating the VxBus Infrastructure ................................................................. 78 Writing Driver Source Files ............................................................................. 78 Writing Header Files (Optional) .................................................................... 78 Writing the Component Description File (CDF) .......................................... 78 Writing the Configuration Stub Files ............................................................ 79 Verifying the Infrastructure ............................................................................ 80 4.2.2 Modifying the BSP (Optional) ........................................................................ 80 4.2.3 Adding Debug Code ........................................................................................ 81 4.2.4 Adding the VxBus Driver Methods ............................................................... 81 4.2.5 Removing Global Variables ............................................................................ 82 4.3 VxBus Show Routines ................................................................................................... 83 4.3.1 Available Show Routines ................................................................................ 83 vxBusShow( ) ..................................................................................................... 83 vxbDevStructShow( ) ........................................................................................ 85 vxbDevPathShow( ) .......................................................................................... 86 4.3.2 PCI Show Routines .......................................................................................... 86 pciDevShow( ) ................................................................................................... 87 vxbPciDeviceShow( ) ........................................................................................ 87 vxbPciHeaderShow( ) ....................................................................................... 88 vxbPciFindDeviceShow( ) ................................................................................ 89 vxbPciFindClassShow( ) ................................................................................... 89 vxbPciConfigTopoShow( ) ............................................................................... 90 4.3.3 Using Show Routines from Software ............................................................ 91 4.3.4 Configuring Show Routines into VxWorks .................................................. 93 4.4 Debugging ....................................................................................................................... 94 4.4.1 Configuring Show Routines ........................................................................... 94 Contents vii 4.4.2 Deferring Driver Registration ........................................................................ 95 4.4.3 Including Debug Code .................................................................................... 95 4.4.4 Confirming Register Access ............................................................................ 96 4.4.5 Increasing the Size of HWMEM_POOL ........................................................ 96 4.4.6 Confirming Device and Driver Name Matches ........................................... 96 5 Driver Release Procedure .......................................................................... 99 5.1 Introduction ..................................................................................................................... 99 5.2 Driver Source Location .................................................................................................. 100 5.3 Driver-Specific Directories ............................................................................................ 101 5.4 Driver Installation and the README File ................................................................ 102 5.5 Driver Packaging ............................................................................................................ 103 5.6 Driver Release Procedure ............................................................................................. 104 PART II: DEVICE DRIVER PORTING 6 Class-Specific Driver Development .......................................................... 107 6.1 About VxBus Driver Classes ........................................................................................ 107 6.2 Before You Begin ............................................................................................................. 107 6.3 About the Class-Specific Driver Documentation ..................................................... 108 7 Bus Controller Drivers ................................................................................ 109 7.1 Introduction ..................................................................................................................... 109 7.2 Overview .......................................................................................................................... 109 7.3 VxBus Driver Methods .................................................................................................. 111 7.3.1 {busCtlrDevCfgRead}( ) ................................................................................... 111 7.3.2 {busCtlrCfgRead}( ) ........................................................................................... 112 7.3.3 {busCtlrDevCfgWrite}( ) ................................................................................... 113 7.3.4 {busCtlrCfgWrite}( ) .......................................................................................... 113 7.3.5 {busCtlrDevCtlr}( ) ............................................................................................ 114 7.3.6 {busCtlrAccessOverride}( ) .............................................................................. 115 Override for (*busCfgRead)( ) ......................................................................... 115 Override for (*busCfgWrite)( ) ........................................................................ 116 Override for (*vxbDevControl)( ) ................................................................... 116 VxBus Device Driver Developer's Guide, 6.9 viii 7.3.7 {busCtlrCfgInfo}( ) ............................................................................................. 116 7.3.8 {busCtlrBaseAddrCvt}( ) .................................................................................. 117 7.3.9 {vxbDevRegMap}( ) ........................................................................................... 117 Specifying a Predefined Transaction Type ..................................................... 119 Providing a New Transaction Type ............................................................... 120 7.3.10 {vxbIntDynaVecProgram}( ) ............................................................................. 122 7.4 Header Files ..................................................................................................................... 122 7.5 BSP Configuration .......................................................................................................... 123 7.5.1 PCI Configuration ............................................................................................ 124 7.5.2 PCI Autoconfiguration .................................................................................... 124 7.6 Available Utility Routines ............................................................................................ 125 7.6.1 PCI Configuration ............................................................................................ 125 7.6.2 PCI Autoconfiguration ..................................................................................... 126 7.6.3 vxbBusAnnounce( ) ........................................................................................... 126 7.6.4 vxbPciBusTypeInit( ) ......................................................................................... 127 7.7 Initialization .................................................................................................................... 127 7.7.1 Initialization Example ..................................................................................... 128 vxbBusAnnounce( ) ........................................................................................... 129 vxbDeviceAnnounce( ) ..................................................................................... 130 vxbDevStructAlloc( ) ........................................................................................ 130 vxbDevStructFree( ) .......................................................................................... 130 7.8 Debugging ........................................................................................................................ 130 8 Direct Memory Access Drivers .................................................................. 131 8.1 Introduction ..................................................................................................................... 131 8.2 Overview ........................................................................................................................... 131 8.3 VxBus Driver Methods ................................................................................................... 132 8.3.1 {vxbDmaResourceGet}( ) .................................................................................. 132 8.3.2 {vxbDmaResourceRelease}( ) ........................................................................... 133 8.3.3 {vxbDmaResDedicatedGet}( ) .......................................................................... 133 8.4 Header Files ...................................................................................................................... 133 8.5 BSP Configuration .......................................................................................................... 134 8.6 Available Utility Routines ............................................................................................. 134 8.7 Initialization ..................................................................................................................... 134 Contents ix 8.8 DMA System Structures and Routines ....................................................................... 134 8.8.1 (*dmaRead)( ) ..................................................................................................... 135 8.8.2 (*dmaReadAndWait)( ) ..................................................................................... 135 8.8.3 (*dmaWrite)( ) .................................................................................................... 135 8.8.4 (*dmaWriteAndWait)( ) .................................................................................... 136 8.8.5 (*dmaCancel)( ) .................................................................................................. 136 8.8.6 (*dmaPause)( ) ................................................................................................... 136 8.8.7 (*dmaResume)( ) ................................................................................................ 136 8.8.8 (*dmaStatus)( ) ................................................................................................... 136 8.9 Debugging ....................................................................................................................... 137 9 I2C Drivers ................................................................................................... 139 9.1 Introduction ...................................................................................................................... 139 9.2 Overview ........................................................................................................................... 139 9.3 VxBus Driver Methods ................................................................................................... 140 9.4 Header Files ...................................................................................................................... 141 9.5 BSP Configuration .......................................................................................................... 141 9.6 Initialization ..................................................................................................................... 143 9.7 Implementing Driver Service Routines ...................................................................... 144 (*VXB_I2C_LOCK_BUS_FUNC)( ) ................................................................. 145 (*VXB_I2C_UNLOCK_BUS_FUNC)( ) ........................................................... 145 (*VXB_I2C_START_FUNC)( ) .......................................................................... 145 (*VXB_I2C_STOP_FUNC)( ) ............................................................................ 146 (*VXB_I2C_READ_FUNC)( ) ........................................................................... 146 (*VXB_I2C_WRITE_FUNC)( ) ......................................................................... 146 (*VXB_I2C_DEV_READ)( ) .............................................................................. 147 (*VXB_I2C_DEV_WRITE)( ) ............................................................................ 147 9.8 Device Driver ................................................................................................................... 148 9.8.1 Generic I2C Devices .......................................................................................... 149 10 Interrupt Controller Drivers ........................................................................ 151 10.1 Introduction ..................................................................................................................... 151 10.2 Overview .......................................................................................................................... 152 Interrupt Identification .................................................................................... 152 Interrupt Controller Driver Responsibilities ................................................. 152 Interrupt Controller Configurations ............................................................... 153 Dynamic Vectors ................................................................................................ 153 Interrupt Controller Drivers and Multiprocessing ....................................... 154 VxBus Device Driver Developer's Guide, 6.9 x 10.3 VxBus Driver Methods .................................................................................................. 154 10.3.1 Basic Methods .................................................................................................... 154 {vxbIntCtlrAlloc}( ) ............................................................................................ 154 {vxbIntCtlrFree}( ) ............................................................................................. 155 {vxbIntCtlrConnect}( ) ...................................................................................... 155 {vxbIntCtlrDisconnect}( ) ................................................................................. 155 {vxbIntCtlrEnable}( ) ......................................................................................... 156 {vxbIntCtlrDisable}( ) ........................................................................................ 156 10.3.2 Dynamic Vector Methods ................................................................................ 156 {vxbIntDynaVecConnect}( ) ............................................................................. 156 10.3.3 Multiprocessor Methods ................................................................................. 157 {vxbIntCtlrIntReroute}( ) .................................................................................. 157 {vxbIntCtlrCpuReroute}( ) .............................................................................. 157 {vxIpiControlGet}( ) .......................................................................................... 157 10.4 Header Files ...................................................................................................................... 158 vxbIntrCtlr.h ....................................................................................................... 158 vxbIntCtlrLib.h .................................................................................................. 158 10.5 BSP Configuration .......................................................................................................... 158 10.5.1 Interrupt Input Table ........................................................................................ 159 10.5.2 Dynamic Vector Table ....................................................................................... 160 10.5.3 CPU Routing Table ............................................................................................ 162 10.5.4 Interrupt Priority ............................................................................................... 163 10.5.5 Crossbar Routing Table .................................................................................... 163 10.6 Available Utility Routines ............................................................................................. 164 10.6.1 intCtlrHwConfGet( ) ......................................................................................... 165 10.6.2 intCtlrISRAdd( ) ................................................................................................ 165 10.6.3 intCtlrISRDisable( ) ........................................................................................... 165 10.6.4 intCtlrISREnable( ) ............................................................................................ 166 10.6.5 intCtlrISRRemove( ) .......................................................................................... 166 10.6.6 intCtlrPinFind( ) ................................................................................................ 166 10.6.7 intCtlrTableArgGet( ) ........................................................................................ 166 10.6.8 intCtlrTableFlagsGet( ) ..................................................................................... 166 10.6.9 intCtlrTableIsrGet( ) .......................................................................................... 166 10.6.10 intCtlrHwConfShow( ) ..................................................................................... 166 10.6.11 intCtlrTableCreate( ) ......................................................................................... 167 10.6.12 intCtlrTableFlagsSet( ) ...................................................................................... 167 10.6.13 intCtlrTableUserSet( ) ....................................................................................... 167 10.6.14 VXB_INTCTLR_ISR_CALL( ) ......................................................................... 167 10.6.15 VXB_INTCTLR_PINENTRY_ENABLED( ) ................................................... 167 Contents xi 10.6.16 VXB_INTCTLR_PINENTRY_ALLOCATED( ) ............................................. 167 10.6.17 Dispatch Routines ............................................................................................. 168 vxbIntDynaCtlrInputInit( ) .............................................................................. 168 vxbIntDynaVecProgram( ) ............................................................................... 168 vxbIntDynaVecErase( ) ..................................................................................... 169 10.7 Initialization ..................................................................................................................... 169 10.8 Interrupt Controller Topologies and Hierarchies ..................................................... 169 10.9 Interrupt Priority ............................................................................................................. 170 10.10 ISR Dispatch .................................................................................................................... 171 10.11 Managing Dynamic Interrupt Vectors ........................................................................ 173 Configuring Dynamic Vectors Using the Service Driver Routines ............ 174 Configuring Dynamic Vectors in the BSP ..................................................... 174 Programming Dynamic Vectors ...................................................................... 175 Determining Dynamic Vector Values ............................................................ 175 10.12 Internal Representation of Interrupt Inputs .............................................................. 176 10.13 Multiprocessor Issues with VxWorks SMP ................................................................ 177 10.13.1 Routing Interrupt Inputs to Individual CPUs .............................................. 177 10.13.2 Interprocessor Interrupts ................................................................................. 178 10.13.3 Limitations in Multiprocessor Systems .......................................................... 182 10.14 Debugging ........................................................................................................................ 182 11 Multifunction Drivers .................................................................................. 185 11.1 Introduction ...................................................................................................................... 185 11.2 Overview ........................................................................................................................... 185 11.3 VxBus Driver Methods ................................................................................................... 186 11.4 Header Files ...................................................................................................................... 186 11.5 BSP Configuration .......................................................................................................... 186 11.6 Available Utility Routines ............................................................................................. 187 vxbDevStructAlloc( ) ........................................................................................ 187 vxbDeviceAnnounce( ) ..................................................................................... 187 vxbDevRemovalAnnounce( ) .......................................................................... 187 vxbDevStructFree( ) .......................................................................................... 188 vxbBusAnnounce( ) ........................................................................................... 188 11.7 Initialization ..................................................................................................................... 188 11.8 Device Interconnections ................................................................................................ 188 VxBus Device Driver Developer's Guide, 6.9 xii 11.8.1 Interleaved Registers ........................................................................................ 188 11.8.2 Shared Resources ............................................................................................... 189 11.8.3 Other Interactions ............................................................................................. 190 11.9 Logical Location of Subordinate Devices ................................................................... 190 11.10 Debugging ........................................................................................................................ 190 12 Network Drivers .......................................................................................... 191 12.1 Introduction ...................................................................................................................... 191 12.1.1 Terminology ....................................................................................................... 191 12.1.2 Networking Overview ..................................................................................... 192 Seven Layer OSI Model .................................................................................... 192 Transmission Media and VxWorks ................................................................. 192 Protocols ............................................................................................................. 193 12.2 Network Interface Drivers ............................................................................................. 193 12.2.1 Network Interface Driver Overview .............................................................. 193 IPNET-Native Drivers ...................................................................................... 193 Functional Modules .......................................................................................... 194 Network Driver Interrupts ............................................................................. 195 12.2.2 VxBus Driver Methods for Network Interface Drivers .............................. 196 {muxDevConnect}( ) ......................................................................................... 196 {muxDevConnect2}( ) ....................................................................................... 197 {vxbDrvUnlink}( ) .............................................................................................. 199 {miiMediaUpdate}( ) ......................................................................................... 199 {miiRead}( ) ........................................................................................................ 200 {miiWrite}( ) ........................................................................................................ 201 12.2.3 Header Files for Network Interface Drivers ................................................. 201 12.2.4 BSP Configuration for Network Interface Drivers ...................................... 202 12.2.5 Available Utility Routines for Network Interface Drivers ......................... 203 MUX Interactions .............................................................................................. 203 Job Queueing ..................................................................................................... 204 Buffer Management .......................................................................................... 205 DMA Support .................................................................................................... 209 PHY and MII bus interactions ......................................................................... 210 12.2.6 Initialization for Network Interface Drivers ................................................ 212 12.2.7 MUX: Connecting to Networking Code ........................................................ 212 12.2.8 jobQueueLib: Deferring ISRs ........................................................................... 213 12.2.9 Working with Ipcom_pkt Packets ................................................................... 214 Supporting Scatter-Gather with IPNET-Native Drivers .............................. 217 12.2.10 netBufLib: Transferring Data with M_BLKs ................................................ 218 12.2.11 Protocol Impact on Drivers .............................................................................. 220 Contents xiii 12.2.12 Other Network Interface Driver Issues .......................................................... 232 Receive Handling Method ............................................................................... 233 Receive Stall Handling ..................................................................................... 240 12.2.13 Debugging Network Interface Drivers .......................................................... 241 Using VxBus Show Routines ........................................................................... 241 Deferring Driver Registration ......................................................................... 241 Pairing with a PHY instance ............................................................................ 242 Stress Testing ...................................................................................................... 242 Netperf Test Suite .............................................................................................. 243 Interrupt Validation .......................................................................................... 243 Additional Tests ................................................................................................. 243 12.3 PHY Drivers ...................................................................................................................... 249 12.3.1 PHY Driver Overview ...................................................................................... 250 PHY Device Probing and Discovery .............................................................. 250 MAC and MII Bus Relationship ...................................................................... 251 Generic PHY Driver Support ........................................................................... 252 Generic TBI Driver Support ............................................................................. 252 12.3.2 VxBus Driver Methods for PHY Drivers ....................................................... 253 Upper Edge Methods ........................................................................................ 253 Lower Edge Methods ....................................................................................... 253 12.3.3 Header Files for PHY Drivers ......................................................................... 255 12.3.4 BSP Configuration for PHY Drivers ............................................................... 255 12.3.5 Available Utility Routines for PHY Drivers .................................................. 255 Upper Edge Utility Routines ........................................................................... 256 Lower Edge Utility Routines ........................................................................... 256 12.3.6 Initialization for PHY Drivers ......................................................................... 257 12.3.7 Debugging PHY Drivers .................................................................................. 257 12.4 Wireless Ethernet Drivers .............................................................................................. 258 12.5 Hierarchical END Drivers ............................................................................................. 258 13 Non-Volatile RAM Drivers .......................................................................... 259 13.1 Introduction ...................................................................................................................... 259 NVRAM Drivers and TrueFFS ........................................................................ 259 13.2 Non-Volatile RAM Drivers ........................................................................................... 260 13.2.1 NVRAM Driver Overview ............................................................................... 260 13.2.2 VxBus Driver Methods for NVRAM Drivers ................................................ 260 {nonVolGet}( ) .................................................................................................... 260 {nonVolSet}( ) ..................................................................................................... 261 13.2.3 Header Files ....................................................................................................... 261 13.2.4 BSP Configuration for NVRAM Drivers ....................................................... 261 VxBus Device Driver Developer's Guide, 6.9 xiv 13.2.5 Utility Routines for NVRAM Drivers ............................................................ 262 13.2.6 Initialization for NVRAM Drivers .................................................................. 262 13.2.7 NVRAM Block Sizes ......................................................................................... 262 13.2.8 Stacking NVRAM Instances ............................................................................ 263 13.2.9 Debugging NVRAM Drivers ........................................................................... 263 13.3 Flash File System Support with TrueFFS ................................................................... 263 13.3.1 TrueFFS Overview ............................................................................................. 264 Core Layer .......................................................................................................... 264 MTD Layer ........................................................................................................ 264 Socket Layer ....................................................................................................... 264 Flash Translation Layer .................................................................................... 265 13.3.2 TrueFFS Driver Development Process ........................................................... 265 Using MTD-Supported Flash Devices ........................................................... 265 Writing MTD Components .............................................................................. 269 Socket Drivers .................................................................................................... 276 Flash Translation Layer .................................................................................... 282 14 RapidIO Drivers ........................................................................................... 297 14.1 Introduction ...................................................................................................................... 297 14.2 Overview ........................................................................................................................... 297 14.3 VxBus Driver Methods ................................................................................................... 299 {vxbRapidIoCtlrInfoGet}( ) .............................................................................. 299 {sharedMemSupportAPIGet}( ) ....................................................................... 300 {vxbMsgApiGet}( ) ............................................................................................ 300 14.4 Header Files ...................................................................................................................... 301 14.5 BSP Configuration .......................................................................................................... 301 RapidIO Bus Controller Driver ....................................................................... 301 Virtual Message Network Device Driver ....................................................... 301 14.6 Initialization ..................................................................................................................... 302 Phase 1 ................................................................................................................ 302 Phase 2 ................................................................................................................ 302 Phase 3 ................................................................................................................ 303 14.7 Implementing Driver Service Routines ...................................................................... 303 RapidIO Bus Controller Driver ....................................................................... 303 Message Controller Driver ............................................................................... 307 15 Resource Drivers ........................................................................................ 311 15.1 Introduction ...................................................................................................................... 311 Contents xv 15.2 Overview ........................................................................................................................... 311 15.3 VxBus Driver Methods ................................................................................................... 312 15.4 Header Files ...................................................................................................................... 312 15.5 BSP Configuration .......................................................................................................... 312 15.6 Available Utility Routines ............................................................................................. 313 15.7 Initialization ..................................................................................................................... 313 15.8 Debugging ........................................................................................................................ 313 16 Serial Drivers ............................................................................................... 315 16.1 Introduction ...................................................................................................................... 315 16.2 Overview ........................................................................................................................... 315 16.3 VxBus Driver Methods ................................................................................................... 316 16.3.1 {sioChanGet}( ) ................................................................................................... 316 16.3.2 {sioChanConnect}( ) .......................................................................................... 317 16.4 Header Files ...................................................................................................................... 317 16.5 BSP Configuration .......................................................................................................... 318 16.6 Available Utility Routines ............................................................................................. 318 16.7 Initialization ..................................................................................................................... 318 16.8 Polled Mode Versus Interrupt-Driven Mode ............................................................. 318 16.9 SIO_CHAN and SIO_DRV_FUNCS ............................................................................ 319 16.10 WDB ................................................................................................................................... 321 16.10.1 WDB and Kernel Initialization ........................................................................ 321 16.11 Serial Drivers, Initialization, and Interrupts ............................................................. 321 16.11.1 WDB and Interrupts ......................................................................................... 322 16.11.2 Initialization Order and Interrupts ................................................................. 322 16.11.3 Initialization Order ........................................................................................... 323 16.12 Debugging ........................................................................................................................ 323 17 SPI Drivers ................................................................................................... 325 17.1 Introduction ...................................................................................................................... 325 17.2 Overview ........................................................................................................................... 325 VxBus Device Driver Developer's Guide, 6.9 xvi 17.3 VxBus Driver Methods ................................................................................................... 326 17.4 Header Files ...................................................................................................................... 326 17.5 BSP Configuration .......................................................................................................... 327 17.6 Initialization ..................................................................................................................... 328 17.7 Implementing Driver Service Routines ...................................................................... 329 17.8 Device Driver ................................................................................................................... 329 17.8.1 SPI_EEPROM ..................................................................................................... 330 17.8.2 SPI Flash ............................................................................................................. 330 18 Storage Drivers ........................................................................................... 333 18.1 Introduction ...................................................................................................................... 333 18.2 Overview ........................................................................................................................... 333 Updates in VxWorks 6.9, Update Pack 2, Service Pack 1 ............................ 334 Updates in VxWorks 6.9, Update Pack 3, Service Pack 3 ............................ 334 18.3 VxBus Driver Methods ................................................................................................... 335 18.4 Header Files ...................................................................................................................... 335 18.5 BSP Configuration .......................................................................................................... 336 18.6 Available Utility Routines ............................................................................................. 336 erfHandlerRegister( ) and erfHandlerUnregister( ) ..................................... 336 erfEventRaise( ) ................................................................................................. 336 xbdAttach( ) ....................................................................................................... 336 bio_done( ) .......................................................................................................... 337 18.7 Initialization ..................................................................................................................... 337 18.8 Interface with VxWorks File Systems ......................................................................... 337 18.8.1 Device Creation ................................................................................................. 337 ERF Registration ................................................................................................ 338 Advertisement of XBD Methods ..................................................................... 338 ERF New Device Notification ......................................................................... 339 18.8.2 Processing ........................................................................................................... 340 xbd_request processing .................................................................................... 340 18.8.3 Event Reporting ................................................................................................. 341 18.9 Writing New Storage Drivers ........................................................................................ 342 18.10 Writing New SD/MMC/SDIO host controller Drivers ............................................ 343 18.11 Device Driver ................................................................................................................... 344 Contents xvii 19 Timer Drivers ............................................................................................... 345 19.1 Introduction ...................................................................................................................... 345 19.2 Overview ........................................................................................................................... 345 19.3 VxBus Driver Methods ................................................................................................... 346 19.4 Header Files ...................................................................................................................... 349 19.5 BSP Configuration .......................................................................................................... 349 19.6 Available Utility Routines ............................................................................................. 349 19.7 Initialization ..................................................................................................................... 349 19.8 Data Structure Layout ..................................................................................................... 350 19.9 Implementing Driver Service Routines ...................................................................... 351 19.9.1 (*timerAllocate)( ) .............................................................................................. 351 19.9.2 (*timerRelease)( ) ............................................................................................... 351 19.9.3 (*timerRolloverGet)( ) ....................................................................................... 352 19.9.4 (*timerCountGet)( ) ........................................................................................... 352 19.9.5 (*timerDisable)( ) ............................................................................................... 353 19.9.6 (*timerEnable)( ) ................................................................................................ 354 19.9.7 (*timerISRSet)( ) ................................................................................................. 354 19.9.8 (*timerEnable64)( ) ............................................................................................ 355 19.9.9 (*timerRolloverGet64)( ) ................................................................................... 355 19.9.10 (*timerCountGet64)( ) ....................................................................................... 356 19.10 Integrating a Timer Driver ............................................................................................ 357 19.10.1 VxWorks System Clock .................................................................................... 357 19.10.2 VxWorks Auxiliary Clock ................................................................................ 359 19.10.3 VxWorks Timestamp Driver ............................................................................ 360 19.11 Debugging ........................................................................................................................ 361 19.12 SMP Considerations ....................................................................................................... 361 20 USB Drivers ................................................................................................. 363 20.1 Introduction ...................................................................................................................... 363 20.2 Wind River USB Overview ............................................................................................ 363 20.2.1 USB Host Stack Drivers .................................................................................... 364 VxBus Model Drivers ....................................................................................... 364 Other Host Drivers ............................................................................................ 364 VxBus Device Driver Developer's Guide, 6.9 xviii 20.2.2 USB Target Stack ............................................................................................... 364 20.3 Host Controller and Root Hub Class Drivers ............................................................ 365 20.3.1 VxBus Driver Methods ..................................................................................... 365 20.3.2 Header Files ....................................................................................................... 365 20.3.3 BSP Configuration ............................................................................................. 366 20.3.4 Available Utility Routines ................................................................................ 367 20.3.5 Initialization ....................................................................................................... 367 20.3.6 Debugging .......................................................................................................... 368 21 Other Driver Classes .................................................................................. 371 21.1 Introduction ...................................................................................................................... 371 21.2 Overview ........................................................................................................................... 371 21.3 VxBus Driver Methods ................................................................................................... 372 21.4 Header Files ...................................................................................................................... 373 21.5 BSP Configuration .......................................................................................................... 373 21.6 Available Utility Routines ............................................................................................. 373 21.7 Initialization ..................................................................................................................... 373 21.8 Debugging ........................................................................................................................ 374 PART III: DEVICE DRIVER PORTING 22 Legacy Drivers and Migration ................................................................... 377 22.1 Migration Overview ....................................................................................................... 377 22.2 Legacy Driver Overview ................................................................................................ 377 23 Migrating to VxBus ..................................................................................... 379 23.1 Overview ........................................................................................................................... 379 23.2 Available Resources ........................................................................................................ 379 Template Drivers ............................................................................................... 379 23.3 Porting an Existing VxWorks Driver to VxBus .......................................................... 380 23.3.1 Verifying Your Hardware and Driver Code .................................................. 380 23.3.2 Creating the VxBus Infrastructure ........
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值