>>
Drew的主頁(yè)-->PowerPC
主頁(yè)VxWorksARMPowerPC
硬件驅動(dòng)網(wǎng)絡(luò )協(xié)議程序示例下載個(gè)人興趣PowerPC簡(jiǎn)介及編程
一,PowerPC芯片
PowerPC是早期Motorola和IBM聯(lián)合為Apple的MAC機開(kāi)發(fā)的CPU芯片,商標權同時(shí)屬于IBM和Motorola,并成為他們的主導成品.IBM主要的PowerPC產(chǎn)品有PowerPC604s(深藍內部的CPU), PowerPC750,PowerPCG3(1.1GHz).Motorola主要有MC和MPC系列.盡管他們產(chǎn)品不一樣,但都采用PowerPC的內核.這些產(chǎn)品大都用在嵌入式系統中.
Motorola公司網(wǎng)址 IBM公司網(wǎng)址相關(guān)文章參見(jiàn)
The PowerPC Triumph PowerPC Today and Tomorrow IBM Pushes to 2GHzThe PowerPC Initiative The PowerPC Chip-Is It Future Of Electrinics ?Motorola的MPC860簡(jiǎn)介(摘錄)
MPC860 PowerQUICC (Quad Integrated Communications Controller) 內部集成了微處理器和一些控制領(lǐng)域的常用外圍組件, 特別適用于通信產(chǎn)品. 包括器件的適應性, 擴展能力和集成度等. MPC860 PowerQUICC集成了兩個(gè)處理塊. 一個(gè)處理塊是嵌入的PowerPC核, 另一個(gè)是通信處理模塊( CPM, Communications Processor Module), 通信處理模塊支持四個(gè)串行通信控制器(SCC, Serial Communication Controller), 實(shí)際上它有八個(gè)串行通道: 四個(gè)SCC,兩個(gè)串行管理控制器 (SMC, Serial Management Channels), 一個(gè)串行外圍接口電路 ( SPI, Serial Peripheral Interface ) 和一個(gè)I2C( Inter-Integrated Circuit ) 接口. 由于CPM分擔了嵌入式PowerPC核的外圍工作任務(wù), 這種雙處理器體系結構功耗要低于傳統的體系結構的處理器. 單出口, 嵌入式PowerPC核32比特版本(與PowerPC結構定義完全兼容)32x32位通用寄存器(GPRs, General Purpose Registers) 4K數據Cache和4K指令Cache, 分別帶有一個(gè)MMU.
存儲管理單元(MMU)32-輸入翻譯后備緩沖器 ( TLBs )
32位數據,地址線(xiàn)
存儲控制器(八個(gè)存儲體) 單線(xiàn)存儲模塊無(wú)逢接口,靜態(tài)隨即存取存儲器(RAM), EPROM, FLASH MEMORY或DRAM等。
DRAM 控制器可編程支持絕大多數不同大小和速度的存儲器
不同碼組長(cháng)度32K至256M
四個(gè)16位定時(shí)器或兩個(gè)32位定時(shí)器.
系統集成單元 ( SIU, Sytstem Intergration Unit ) 主要包括: 軟件看門(mén)狗
中斷定時(shí)器
PowerPC 時(shí)基和實(shí)時(shí)時(shí)鐘 (RTC, Real Time Clock )
復位控制器
JTAG 1149.1 測試口
中斷系統包括7根外部中斷請求線(xiàn), 12個(gè)具有中斷能力的管腳, 16個(gè)內部中斷源. 中斷優(yōu)先級可編程
通信處理器模塊(CPM)主要包括: RISC 控制器
5 K字節雙口RAM
16個(gè)串行DMA (SDMA) 通道
三個(gè)平行 I/O 寄存器
四個(gè)波特率獨立的發(fā)生器, 可以連接到任意一個(gè)SCC和SMC, 并允許運行中改變. 支持自動(dòng)波特率
四個(gè)串行通信控制器 (SCC) ,支持以太網(wǎng), HDLC/SDLC, HDLC 總線(xiàn)(用以實(shí)現基于HDLC的局域網(wǎng))、AppleTalk, 7號信令系統, UART、BISYNC, 比特流透明傳輸, 基于幀的透明傳輸 (CRC可選), 支持PPP (Point to Point Protocol)的異步HDLC等標準協(xié)議
兩個(gè)串行管理控制器 (SMC), UART方式或透明傳輸, 含GCI(General Circuit Interface)控制器, 可以連到時(shí)分復用通道
一個(gè)串行外圍接口電路( SPI ), 是MC68302 SCP的擴展, 支持主從模式, 支持同一總線(xiàn)上多主操作
一個(gè)I2C ( Inter-Integrated Circuit ) 接口,支持主從模式, 支持多主環(huán)境
單插座PCMCIA-異步終端適陪器(ATA)接口 單PCMCIA插座
八儲存或有效輸入/輸出(I/O)窗口
Performance Frenquency (MHz) TIMER Data Bus Address Bus Ext Intterrupts Int Interruputs Watchdog PACKING
52MIPS @40MHz 40 Four 16-Bit Timers or Two 32-Bit Timers 8/16/32 32 12 16 Software Watchdog BGA357
IBM的PowerPC405GP芯片簡(jiǎn)介
編程示例可參見(jiàn)
系統初始化 PCI設備初始化和網(wǎng)絡(luò )分析32位RISC嵌入式CPU,內核主頻達到200MHz PC-100,動(dòng)態(tài)隨即存儲接口(Synchronous DRAM Interface).
100MHz外圍設備總線(xiàn)(External Peripheral Bus) Flash ROM/Boot ROM 接口 支持8-16-32位SRAM和外設 8個(gè)Devices 支持外部控制
DMA---,支持外設,內部UART和內存,4個(gè)通道
PCI總線(xiàn)接口---可設置同步,異步內置時(shí)鐘
以太網(wǎng)(Ethernet)----支持10/100Mbps全雙工(Full-duplex)
媒介獨立接口(Medium Independent Interface(MII)
可編程中斷控制器(Programmable Interrupt Controller)----支持來(lái)自不同資源的中斷 支持24個(gè)中斷,7個(gè)外部中斷,17個(gè)內部中斷 邊沿觸發(fā)或上下沿觸發(fā) ......................
CPU一次只能處理一個(gè)中斷,共有18個(gè)中斷優(yōu)先級(priority order)
32位地址線(xiàn)可達4GB的尋址空間
主要控制器包括: SDRAM存儲控制器,外部設備總線(xiàn)控制器(EBC),DMA控制器,UART,IIC總線(xiàn)接口,通用寄存器控制器(General Purpose I/O Controller),通用中斷控制器(Universal Interrupt Controller, UIC), JTAG.
兩個(gè)總線(xiàn)分別支持不同的外設 64位,100M Processor Local Bus(PLB),支持 high performance 外設 32位,50M On-chip Perpheral Bus(OPB),支持 less performance-critical 外設
先進(jìn)的功能 PCI接口 內部集成以太網(wǎng)口(Ethernet port on-chip) Code pack decompression to improve code density
驅動(dòng)PowerPC405GP的PowerPC405B3內核包括 200MHz CPU 內核 內存管理單元(Memory Mannanagement Unit,MMU) 16K指令緩村(instruction caches)和8K數據緩存(data caches) Multiply-Accumulate (MAC)功能 計時(shí)器(Timers) 調試,JTAG和Trace debug logic 內核帶有4K的SRAM
一個(gè)64位累加計時(shí)器,由CPU時(shí)鐘驅動(dòng)
三個(gè)計時(shí)器:可編程內部計時(shí)器(Programmable Internal Timer,PIT),固定內部計時(shí)器(Fix Internal Timer,FIT),看門(mén)狗計時(shí)器(Watch Dog Timer,WDT)
二,VxWorks裝入PowerPC的過(guò)程
RISCWatch 是一套軟件和硬件開(kāi)發(fā)工具, 主要為IBM PowerPC 600/700系列微處理器和IBM PowerPC 400系列嵌入式處理器提供軟硬件, 開(kāi)發(fā), 調試.
開(kāi)發(fā)板JTAG口 (一般開(kāi)發(fā)版都會(huì )甩出一個(gè)JTAG接口供開(kāi)發(fā)調試用 ) 連出一個(gè)2*8針的接頭與RISCWatch的仿真器端相連, 仿真器另一端通過(guò)網(wǎng)絡(luò )連到裝有RISCWatch軟件的PC機. 不同種類(lèi)的處理器JTAG管腳的定義不同, 所以和2*8針的接頭連接也不同, 具體連結方法參見(jiàn)RISCWatch用戶(hù)手冊.
通過(guò)軟件和一個(gè)配套的硬件仿真器將VxWorks image寫(xiě)入512K的Flash Socket. RISCWatch一端接板子上的JTAG接口,另一端接網(wǎng)絡(luò )Network.
RISCwatch的執行過(guò)程順序: 初始化RAM-------->清理ROM-------->寫(xiě)VxWorks image .bin到FlashRom
用RISCwatch裝入VxWorks的操作過(guò)程
1.運行RISCwatch: 打開(kāi)file----->command file------>flashwri.cmd
2.開(kāi)啟Normal 初始化RAM, 在編輯框中鍵入run, 開(kāi)始向FlashRom中寫(xiě)入Bootrom.bin,寫(xiě)入完成,鍵入stop,至此寫(xiě)入完成
系統復位后, VxWorks運行,講程序寫(xiě)入RAM中的各個(gè)地址
RISCwatch中的文件定義
文件rwppc.env: 可更改,如chip type, PC405GP等
文件flashwri.com: 可以察看,改變,如IP地址,load...., .out, .bin
文件flashprog.c: 輸出生成 .out, 是寫(xiě)flash Rom 的文件, 寫(xiě)入 .bin
三,調試工具及調試方法
底層驅動(dòng)調試
RISCWATCH 是一種很好的調試工具,觀(guān)察內存情況及程序運行.
通過(guò)計算機串口與處理器UART相連,設置計算機的超級終端(Hyper Terminal), 通過(guò)超級終端察看硬件情況(寄存器設置,數據等)和程序運行情況,當然程序重要加入向UART送出數據的指令,用Beep報警也是經(jīng)常用的.這種調試方法是用于底層調試硬件,找出硬件存在的問(wèn)題.
VxWorks 在Tornado Shell 不能正常運行前,也是采取這種方法來(lái)調試程序,不過(guò)一般不是硬件問(wèn)題,而是BSP中存在的問(wèn)題,需要根據硬件,修改BSP.
以上是Shell不能正常運行是所采取的方法,Shell正常運行后,Shell是最好的調試工具.
上層應用程序調試跟蹤
Tornade2.0中Debuger和Shell是最好的調試工具,可以單步執行跟蹤程序運行,觀(guān)察內存情況和系統資源情況.其中Shell的功能要好于Debuger,不過(guò)Debuger操作較為容易,直觀(guān).
四,內存映射
MPC860的內存資源(如寄存器等)映射在一個(gè)連續的16K Block存儲區內,可通過(guò)SPR中的Internal Map Memory Register(IMMR)進(jìn)行解析
對 Memory Registers 操作的幾種方式
Indirectly Access Registers Via Memory-----------------------通過(guò)指定的I/O寄存器(I/O port)對一個(gè)寄存器操作,
如PCI部分I/O操作示例如下:
PCI地址I/O寄存器: PCICFGADR 0xEEC00000
PCI數據I/O寄存器: PCICFGDATA 0xEEC00004
具體操作方法:將所要讀寫(xiě)的寄存器地址寫(xiě)入PCI地址I/O寄存器PCICFGADR,從PCI數據I/O寄存器PCICFGDATA讀出數據,這個(gè)數據就是寫(xiě)入地址的寄存器的數據.
RegAddr = 0x80000000 | ((offset|BusDevFunc) & 0xFFFFFFFC);
RegAddr寄存器地址, 0x80000000 PCI core Address, offset寄存器偏移量
/*
* 寫(xiě)RegAddr到PCI I/O地址寄存器PCICFGADR
*/
sysPciOutLong(PCICFGADR, RegAddr);
/*
* 從PCI I/O數據寄存器讀RegAddr數據data
*/
data = (unsigned int)sysPciInByte(PCICFGDATA | (offset & 0x3));
Directly Access Registers Via Memory-------------------------直接對寄存器操作
Indirectly Access Registers Via DCR-----------------------------同上,
Directly Access Regesters Via DCR-------------------------------同上,
五,PowerPC內核定義
雙處理器結構既提供了程序運行的通用處理器,又提供了用于通信用處的特殊通信處理器(CPM).
32位PowerPC結構特點(diǎn)
32個(gè)32位通用寄存器 ( GPRs )
寄存器支持用戶(hù)級指令集 (不包括浮點(diǎn)指令),包括integer exception register (XER ),condition register(CR),link register(LR),counter register ( CTR )
時(shí)間加減及寄存器
管理級寄存器,與PowerPC定義兼容
Configuration-----Machine Status Register ( MSR )
Exception model-----Save/restore registers 0 and 1 (SRR0 and SRR1), DSI status register ( DSISR ), data address register ( DAR )
PowerPC 減量器
PowerPC 時(shí)基和 實(shí)時(shí)時(shí)鐘(RTC)
地址映射
名稱(chēng)
內存物理地址
備注
SDRAM 0x00000000~0x7FFFFFFF
PCI 0x80000000~0xEF5FFFFF
Internal Peripherals
0xEF600000~0xEFFFFFFF
UART .....
..... .....
External Peripherals
0xF0000000~0xFF7FFFFF
NVRAM/RTC 0xF0000000~0xF0001FFF
(8K)下畫(huà)線(xiàn)為片選
Keybord/Mouse 0xF0100000~0xF0100001 下畫(huà)線(xiàn)為片選
FPGA_INT_ST.. 0xF0300000~0xF0300000 下畫(huà)線(xiàn)為片選
FPGA_INT_EN.. 0xF0300001~0xF0300001 下畫(huà)線(xiàn)為片選
Socket Flash
0xFFF80000~0xFFFFFFFF 512K
SRAM
0xFFF00000~0xFFF7FFFF 512K(可通過(guò)Swich與Socket Flash 切換)
中斷優(yōu)先級(Exception Priority)
Priority Exception Type Cause
1 Development port nonmaskable interrupt Signal from the development port
2 System reset interrupt IRQ0 assertion
3 Instruction-related exceptions Instruction processing
4 Peripheral breakpoint request or development port maskable interrupt Breakpoint signal from any peripheral
5 External interrupt (masked if MSR[EE] = 0) Signal from the interrupt controller
6 Decrementer interrupt(masked if MSR[EE] = 0) Decrementer request
中斷控制器 (UIC) 的中斷分配
中斷
極性 觸發(fā)方式 中斷源
0 正(High) 電平(Level) UART 0
1 正(High) 電平(Level) UART 1
2 正(High) 電平(Level) IIC
3 正(High) 電平(Level) External Master
4 正(High) 電平(Level) PCI
5 正(High) 電平(Level) DMA Channel 0
6 正(High) 電平(Level) DMA Channel 1
7 正(High) 電平(Level) DMA Channel 2
8 正(High) 電平(Level) DMA Channel 3
9 正(High) 電平(Level) MAL Wake UP
10 正(High) 電平(Level) MAL SERR
11 正(High) 電平(Level) MAL TXEOB
12 正(High) 電平(Level) MAL RXEOB
13 正(High) 電平(Level) MAL TXDE
14 正(High) 電平(Level) MAL TXDE
15 正(High) 電平(Level) Ethernet
16 正(High) 電平(Level) External PCI SERR
17 正(High) 電平(Level) ECC Correctalbe Error
18 正(High) 電平(Level) PCI Power Management
.... Reserved
25 Programmable Programmable External IRQ 0
26 Programmable Programmable External IRQ 1
27 Programmable Programmable External IRQ 2
28 Programmable Programmable External IRQ 3
29 Programmable Programmable External IRQ 4
30 Programmable Programmable External IRQ 5
31 Programmable Programmable External IRQ 6
中斷向量表
中斷向量表的其實(shí)地址取決于MSR[IP]的設置,IP位定義如下:
Exception preTx. The setting of IP speciTes whether an exception vector offset is prepended with Fs
or 0s. In the following description, nnnnn is the offset of the exception vector. See Table 7-1.
0 Exceptions are vectored to the physical address 0x000n_nnnn
1 Exceptions are vectored to the physical address 0xFFFn_nnnn
The reset value of IP is determined by the IIP bit (bit 2) in the hard reset confguration word.
Offset Exception Description
0x00000 Reserved
0x00100 System reset interrupt
0x00200 Machine check interrupt
0x00300 DSI A DSI exception is never generated by hardware, but software may branch to this location because of an data TLB error or miss exception.
0x00400 ISI An ISI exception is never generated by the hardware, but software may branch to this location because of an implementation-speciTc instruction TLB error exception.
0x00500 External Interrupt
… … …
這個(gè)表結合地址映射表可知系統復位的地址是 Socket Flash地址+系統復位偏移地址 = 0xFFF80000 + 0x0100 = 0xFFF80100,即系統通電后,跳到0xFFF80100的位置開(kāi)始執行程序.
MPC860串口中斷過(guò)程
MPC860集成了兩個(gè)處理塊,一個(gè)處理塊是嵌入的PowerPC核,另一個(gè)是通信處理模塊(CPM).通信處理模塊有4個(gè)SCC和2個(gè)SMC,這六個(gè)通信口可以通過(guò)設置來(lái)支持多種協(xié)議和通信方式,也可設置為串口UART模式(是通過(guò)寄存器GSMR或SMCMR),功能和中斷的定義和通常的串口定義基本是一致的在寄存器SCCM/SCCE的位14和位15定義了在何種情況下產(chǎn)生硬件中斷.
根據MPC860中SCC UART Event Register(SCCE)的位14和位15定義,位14是數據發(fā)送中斷標志位,位15是數據接收中斷標志位,首先設置SCC UART Mask Register(SCCM)的位14和位15為1,使能接受和發(fā)送中斷.
如果串口收到數據,則產(chǎn)生硬件RX中斷,SCCE為15置1,通知系統有數據到達,有相應的中斷例程ISR來(lái)取數據.
發(fā)送的情況下,數據FIFO為空,產(chǎn)生TX中斷,告訴系統發(fā)送準備就緒,可以發(fā)送,ISR把數據放入FIFO中,發(fā)送中斷位清零.當發(fā)送完畢后,FIFO再為空,再次產(chǎn)生中斷,告訴系統發(fā)送準備就緒,繼續發(fā)送.
MPC860片選信號的編程方法
在MPC860中,有片選信號CS0,CS1,...,CS7對他們的操作主要是要改變片選信號的電平
一般來(lái)說(shuō)片選信號的發(fā)生是對和這一片選線(xiàn)相關(guān)聯(lián)的地址進(jìn)行操作(讀寫(xiě))時(shí)片選信號改變。片選信號通常為低電平有效。比如MPC860的CS0是boot rom,硬件reset后,CPU會(huì )從boot rom的起始地址開(kāi)始執行,CS0變?yōu)榈?div style="height:15px;">
A system reset interrupt occurs when IRQ0 is asserted. When the exception is taken, processing begins at offset 0x00100. A hard or soft reset also causes program execution to begin fetching at 0x00100 after the associated reset actions.
SRR0: Set to the (Effective Address) EA of the next instruction of the interrupted process.
SRR1: Saves the machine status prior to exceptions and to restore status when an r f i instruction is executed.
Others Loaded from MSR[16-31]. SRR1[30] is cleared only by loading a zero from MSR[RI].
MSR : IP No change ME No change LE Value of MSR[ILE] of the interrupted process. Others -----0
In the MPC860 the external interrupt is generated by the on-chip interrupt controller. It is software acknowledged and maskable by MSR[EE], which hardware clears automatically to disable external interrupts when any exception is taken.
SRR0 Set to the effective address of the instruction that the processor would have attempted to execute next if no interrupt conditions were present.
1-4, Cleared; 5-9, Loaded with equivalent bits from the MSR; 10-15, Cleared; 16-31, Loaded with equivalent bits from the MSR
Note that depending on the implementation, reserved bits in the MSR may not be copied to SRR1.
MSR POW 0; ILE --; EE 0; PR 0; FP 0; ME --; SE 0; BE 0; IP --; IR 0; DR 0; RI 0; LE Set to value of ILE
The hard reset configuration word is sampled from the data bus. These bits determine the default values of the corresponding bits in the SIUMCR, IMMR, and MSR.
IIP:bit1: Initial interrupt prefix. Defines the initial value of the MSR[IP] which defines the interrupt table location. If
IIP is cleared (default), the MSR[IP] initial value is one; if it is set to one, the MSR[IP] initial value is zero.
ISB:bit 7-8, Initial internal space base select. Defines the initial value of the IMMR bits 0-15 and determines the
base address of the internal memory space.
00 0x00000000.
01 0x00F00000.
10 0xFF000000.
11 0xFFF00000.