PowerPC簡(jiǎn)介及編程
PowerPC簡(jiǎn)介及編程
本文引用地址:http://www.ex-cimer.com/article/201706/348588.htm
一.PowerPC芯片
PowerPC是早期Motorola和IBM聯(lián)合為Apple的MAC機(jī)開(kāi)發(fā)的CPU芯片,商標(biāo)權(quán)同時(shí)屬于IBM和Motorola,并成為他們的主導(dǎo)成品.IBM主要的PowerPC產(chǎn)品有PowerPC604s(深藍(lán)內(nèi)部的CPU), PowerPC750,PowerPCG3(1.1GHz).Motorola主要有MC和MPC系列.盡管他們產(chǎn)品不一樣,但都采用PowerPC的內(nèi)核.這些產(chǎn)品大都用在嵌入式系統(tǒng)中.
二. Motorola的MPC860簡(jiǎn)介(摘錄)
MPC860 PowerQUICC (Quad Integrated Communications Controller) 內(nèi)部集成了微處理器和一些控制領(lǐng)域的常用外圍組件, 特別適用于通信產(chǎn)品. 包括器件的適應(yīng)性, 擴(kuò)展能力和集成度等. 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分擔(dān)了嵌入式PowerPC核的外圍工作任務(wù), 這種雙處理器體系結(jié)構(gòu)功耗要低于傳統(tǒng)的體系結(jié)構(gòu)的處理器.
1.單出口, 嵌入式PowerPC核32比特版本(與PowerPC結(jié)構(gòu)定義完全兼容)32x32位通用寄存器(GPRs, General Purpose Registers)
4K數(shù)據(jù)Cache和4K指令Cache, 分別帶有一個(gè)MMU.
存儲(chǔ)管理單元(MMU)32-輸入翻譯后備緩沖器 ( TLBs )
32位數(shù)據(jù),地址線
2.存儲(chǔ)控制器(八個(gè)存儲(chǔ)體)
單線存儲(chǔ)模塊無(wú)逢接口,靜態(tài)隨即存取存儲(chǔ)器(RAM), EPROM, FLASH MEMORY或DRAM等。
DRAM 控制器可編程支持絕大多數(shù)不同大小和速度的存儲(chǔ)器
不同碼組長(zhǎng)度32K至256M
3.四個(gè)16位定時(shí)器或兩個(gè)32位定時(shí)器.
4.系統(tǒng)集成單元 ( SIU, Sytstem Intergration Unit ) 主要包括:
軟件看門狗
中斷定時(shí)器
PowerPC 時(shí)基和實(shí)時(shí)時(shí)鐘 (RTC, Real Time Clock )
復(fù)位控制器
JTAG 1149.1 測(cè)試口
5.中斷系統(tǒng)包括7根外部中斷請(qǐng)求線, 12個(gè)具有中斷能力的管腳, 16個(gè)內(nèi)部中斷源. 中斷優(yōu)先級(jí)可編程
6.通信處理器模塊(CPM)主要包括:
RISC 控制器
5 K字節(jié)雙口RAM
16個(gè)串行DMA (SDMA) 通道
三個(gè)平行 I/O 寄存器
7.四個(gè)波特率獨(dú)立的發(fā)生器, 可以連接到任意一個(gè)SCC和SMC, 并允許運(yùn)行中改變. 支持自動(dòng)波特率
8.四個(gè)串行通信控制器 (SCC) ,支持以太網(wǎng), HDLC/SDLC, HDLC 總線(用以實(shí)現(xiàn)基于HDLC的局域網(wǎng))、AppleTalk, 7號(hào)信令系統(tǒng), UART、BISYNC, 比特流透明傳輸, 基于幀的透明傳輸 (CRC可選), 支持PPP (Point to Point Protocol)的異步HDLC等標(biāo)準(zhǔn)協(xié)議
9.兩個(gè)串行管理控制器 (SMC), UART方式或透明傳輸, 含GCI(General Circuit Interface)控制器, 可以連到時(shí)分復(fù)用通道
10.一個(gè)串行外圍接口電路( SPI ), 是MC68302 SCP的擴(kuò)展, 支持主從模式, 支持同一總線上多主操作
11.一個(gè)I2C ( Inter-Integrated Circuit ) 接口,支持主從模式, 支持多主環(huán)境
12.單插座PCMCIA-異步終端適陪器(ATA)接口
單PCMCIA插座
八儲(chǔ)存或有效輸入/輸出(I/O)窗口
三內(nèi)存映射
MPC860的內(nèi)存資源(如寄存器等)映射在一個(gè)連續(xù)的16K Block存儲(chǔ)區(qū)內(nèi),可通過(guò)SPR中的Internal Map Memory Register(IMMR)進(jìn)行解析
對(duì) Memory Registers 操作的幾種方式
Indirectly Access Registers Via Memory-----------------------通過(guò)指定的I/O寄存器(I/O port)對(duì)一個(gè)寄存器操作,
如PCI部分I/O操作示例如下:
PCI地址I/O寄存器: PCICFGADR 0xEEC00000
PCI數(shù)據(jù)I/O寄存器: PCICFGDATA 0xEEC00004
具體操作方法:將所要讀寫的寄存器地址寫入PCI地址I/O寄存器PCICFGADR,從PCI數(shù)據(jù)I/O寄存器PCICFGDATA讀出數(shù)據(jù),這個(gè)數(shù)據(jù)就是寫入地址的寄存器的數(shù)據(jù).
RegAddr = 0x80000000 | ((offset|BusDevFunc) 0xFFFFFFFC);
RegAddr寄存器地址, 0x80000000 PCI core Address, offset寄存器偏移量
/*
* 寫RegAddr到PCI I/O地址寄存器PCICFGADR
*/
sysPciOutLong(PCICFGADR, RegAddr);
/*
* 從PCI I/O數(shù)據(jù)寄存器讀RegAddr數(shù)據(jù)data
*/
data = (unsigned int)sysPciInByte(PCICFGDATA | (offset 0x3));
Directly Access Registers Via Memory-------------------------直接對(duì)寄存器操作
Indirectly Access Registers Via DCR-----------------------------同上,
Directly Access Regesters Via DCR-------------------------------同上,
四,PowerPC內(nèi)核定義
雙處理器結(jié)構(gòu)既提供了程序運(yùn)行的通用處理器,又提供了用于通信用處的特殊通信處理器(CPM).
1.32位PowerPC結(jié)構(gòu)特點(diǎn)
32個(gè)32位通用寄存器 ( GPRs )
寄存器支持用戶級(jí)指令集 (不包括浮點(diǎn)指令),包括integer exception register (XER ),condition register(CR),link register(LR),counter register ( CTR )
時(shí)間加減及寄存器
管理級(jí)寄存器,與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)
2.地址映射
名稱 | 內(nèi)存物理地址 | 備注 |
SDRAM | 0x00000000~0x7FFFFFFF | |
PCI | 0x80000000~0xEF5FFFFF | |
Internal Peripherals | 0xEF600000~0xEFFFFFFF | |
UART | ..... | |
..... | ..... | |
External Peripherals | 0xF0000000~0xFF7FFFFF | |
NVRAM/RTC | 0xF0000000~0xF0001FFF | (8K)下畫線為片選 |
Keybord/Mouse | 0xF0100000~0xF0100001 | 下畫線為片選 |
FPGA_INT_ST.. | 0xF0300000~0xF0300000 | 下畫線為片選 |
FPGA_INT_EN.. | 0xF0300001~0xF0300001 | 下畫線為片選 |
Socket Flash | 0xFFF80000~0xFFFFFFFF | 512K |
SRAM | 0xFFF00000~0xFFF7FFFF | 512K(可通過(guò)Swich與Socket Flash 切換) |
3.中斷優(yōu)先級(jí)(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 |
4.中斷向量表
中斷向量表的起始地址取決于MSR[IP]的設(shè)置
MSR[IP]=0 Exceptions are vectored to the physical address 0x000n_nnnn
MSR[IP]=1 Exceptions are vectored to the physical address 0xFFFn_nnnn
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è)表結(jié)合地址映射表可知系統(tǒng)復(fù)位的地址是 Socket Flash地址+系統(tǒng)復(fù)位偏移地址 = 0xFFF80000 + 0x0100 = 0xFFF80100,即系統(tǒng)通電后,跳到0xFFF80100的位置開(kāi)始執(zhí)行程序.
5.MPC860串口中斷過(guò)程
MPC860集成了兩個(gè)處理塊,一個(gè)處理塊是嵌入的PowerPC核,另一個(gè)是通信處理模塊(CPM).通信處理模塊有4個(gè)SCC和2個(gè)SMC,這六個(gè)通信口可以通過(guò)設(shè)置來(lái)支持多種協(xié)議和通信方式,也可設(shè)置為串口UART模式(是通過(guò)寄存器GSMR或SMCMR),功能和中斷的定義和通常的串口定義基本是一致的在寄存器SCCM/SCCE的位14和位15定義了在何種情況下產(chǎn)生硬件中斷.
根據(jù)MPC860中SCC UART Event Register(SCCE)的位14和位15定義,位14是數(shù)據(jù)發(fā)送中斷標(biāo)志位,位15是數(shù)據(jù)接收中斷標(biāo)志位,首先設(shè)置SCC UART Mask Register(SCCM)的位14和位15為1,使能接受和發(fā)送中斷.
如果串口收到數(shù)據(jù),則產(chǎn)生硬件RX中斷,SCCE為15置1,通知系統(tǒng)有數(shù)據(jù)到達(dá),有相應(yīng)的中斷例程ISR來(lái)取數(shù)據(jù).
發(fā)送的情況下,數(shù)據(jù)FIFO為空,產(chǎn)生TX中斷,告訴系統(tǒng)發(fā)送準(zhǔn)備就緒,可以發(fā)送,ISR把數(shù)據(jù)放入FIFO中,發(fā)送中斷位清零.當(dāng)發(fā)送完畢后,FIFO再為空,再次產(chǎn)生中斷,告訴系統(tǒng)發(fā)送準(zhǔn)備就緒,繼續(xù)發(fā)送.
6.MPC860片選信號(hào)的編程方法
在MPC860中,有片選信號(hào)CS0,CS1,...,CS7對(duì)他們的操作主要是要改變片選信號(hào)的電平.
一般來(lái)說(shuō)片選信號(hào)的發(fā)生是對(duì)和這一片選線相關(guān)聯(lián)的地址進(jìn)行操作(讀寫)時(shí)片選信號(hào)改變。片選信號(hào)通常為低電平有效。比如MPC860的CS0是boot rom,硬件reset后,CPU會(huì)從boot rom的起始地址開(kāi)始執(zhí)行,CS0變?yōu)榈碗娖健?
所以只要對(duì)一個(gè)相應(yīng)的地址操作,和這個(gè)地址芯片(bank)相連的CSx就會(huì)改變。
MPC860對(duì)CSx分配地址空間的在BRx中定義,BR0,BR1...BR7分別對(duì)應(yīng)8個(gè)片選線CS0--CS7。
7.System Reset Interrupt (0x00100)
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.
Register Setting
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.
1-4 ,-------0
10-15,--- 0
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
8.External Interrupt Exception (0x00500)
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.
Register Settings after an External Interrupt
Register Setting Description
SRR0 Set to the effective address of the instruction that the processor would have attempted to execute next if no interrupt conditions were present.
SRR1: 0, Loaded with equivalent bits from the MSR
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
9.Hard Reset ConTguration Word
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.
評(píng)論