`
charlotte
  • 浏览: 121580 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

PowerPC简介及编程

 
阅读更多

 
PowerPC简介及编程
 
来源: ChinaUnix博客  日期: 2009.06.02 21:43 (共有条评论) 我要评论
 

PowerPC 是一种
RISC
架构的
CPU
,其基本的设计源自
IBM

POWER
(Performance Optimized With Enhanced 
RISC
的缩写)架构。POWER是
1991年

Apple
、IBM、
Motorola
组成的
AIM联盟
所发展出的
微处理器
架构。PowerPC是整个
AIM联盟
平台的一部分,并且是到目前为止唯一的一部分。
PowerPC 的历史可以追溯到早在
1990年
随RISC System/6000一起被介绍的
IBM POWER
架构。该设计是从早期的RISC架构(比如
IBM 801
)与
MIPS
架构的处理器得到灵感的。
一,PowerPC芯片
   PowerPC是早期Motorola和IBM联合为Apple的MAC机开发的CPU芯片,商标权同时属于IBM和Motorola,并成为他们的主导成品.IBM主要的PowerPC产品有PowerPC604s(深蓝内部的CPU), PowerPC750,PowerPCG3(1.1GHz).Motorola主要有MC和MPC系列.尽管他们产品不一样,但都采用PowerPC的内核.这些产品大都用在嵌入式系统中.
Motorola公司网址
      
IBM公司网址
     相关文章参见 
The PowerPC Triumph
    
PowerPC Today and Tomorrow
    
IBM Pushes to 2GHz
                  
The PowerPC Initiative
    
The PowerPC Chip-Is It Future Of Electrinics ?
 
Motorola的MPC860简介(摘录)
  MPC860 PowerQUICC (Quad Integrated Communications Controller) 内部集成了微处理器和一些控制领域的常用外围组件, 特别适用于通信产品. 包括器件的适应性, 扩展能力和集成度等. MPC860 PowerQUICC集成了两个处理块. 一个处理块是嵌入的PowerPC核, 另一个是通信处理模块( CPM, Communications Processor Module), 通信处理模块支持四个串行通信控制器(SCC, Serial Communication Controller), 实际上它有八个串行通道: 四个SCC,两个串行管理控制器 (SMC, Serial Management Channels), 一个串行外围接口电路 ( SPI, Serial Peripheral Interface ) 和一个I2C( Inter-Integrated Circuit ) 接口. 由于CPM分担了嵌入式PowerPC核的外围工作任务, 这种双处理器体系结构功耗要低于传统的体系结构的处理器. 


  • 单出口, 嵌入式PowerPC核32比特版本(与PowerPC结构定义完全兼容)32x32位通用寄存器(GPRs, General Purpose Registers) 


    • 4K数据Cache和4K指令Cache, 分别带有一个MMU. 

    • 存储管理单元(MMU)32-输入翻译后备缓冲器 ( TLBs ) 

    • 32位数据,地址线 


  • 存储控制器(八个存储体) 


    • 单线存储模块无逢接口,静态随即存取存储器(RAM), EPROM, FLASH MEMORY或DRAM等。 

    • DRAM 控制器可编程支持绝大多数不同大小和速度的存储器 

    • 不同码组长度32K至256M 


  • 四个16位定时器或两个32位定时器. 

  • 系统集成单元 ( SIU, Sytstem Intergration Unit ) 主要包括: 


    • 软件看门狗 

    • 中断定时器 

    • PowerPC 时基和实时时钟 (RTC, Real Time Clock ) 

    • 复位控制器 

    • JTAG 1149.1 测试口 


  • 中断系统包括7根外部中断请求线, 12个具有中断能力的管脚, 16个内部中断源. 中断优先级可编程 

  • 通信处理器模块(CPM)主要包括: 


    • RISC 控制器 

    • 5 K字节双口RAM 

    • 16个串行DMA (SDMA) 通道 

    • 三个平行 I/O 寄存器 


  • 四个波特率独立的发生器, 可以连接到任意一个SCC和SMC, 并允许运行中改变. 支持自动波特率 

  • 四个串行通信控制器 (SCC) ,支持以太网, HDLC/SDLC, HDLC 总线(用以实现基于HDLC的局域网)、AppleTalk, 7号信令系统, UART、BISYNC, 比特流透明传输, 基于帧的透明传输 (CRC可选), 支持PPP (Point to Point Protocol)的异步HDLC等标准协议 

  • 两个串行管理控制器 (SMC), UART方式或透明传输, 含GCI(General Circuit Interface)控制器, 可以连到时分复用通道 

  • 一个串行外围接口电路( SPI ), 是MC68302 SCP的扩展, 支持主从模式, 支持同一总线上多主操作 

  • 一个I2C ( Inter-Integrated Circuit ) 接口,支持主从模式, 支持多主环境 

  • 单插座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芯片简介  
编程示例可参见 
系统初始化
  
PCI设备初始化和网络分析
32位RISC嵌入式CPU,内核主频达到200MHz PC-100,动态随即存储接口(Synchronous DRAM Interface). 
100MHz外围设备总线(External Peripheral Bus) 

  • Flash ROM/Boot ROM 接口 
  • 支持8-16-32位SRAM和外设 
  • 8个Devices 
  • 支持外部控制

DMA---,支持外设,内部UART和内存,4个通道
PCI总线接口---可设置同步,异步内置时钟
以太网(Ethernet)----支持10/100Mbps全双工(Full-duplex)
媒介独立接口(Medium Independent Interface(MII)
可编程中断控制器(Programmable Interrupt Controller)----支持来自不同资源的中断 

  • 支持24个中断,7个外部中断,17个内部中断 
  • 边沿触发或上下沿触发 
  • ......................

CPU一次只能处理一个中断,共有18个中断优先级(priority order)
32位地址线可达4GB的寻址空间
主要控制器包括: SDRAM存储控制器,外部设备总线控制器(EBC),DMA控制器,UART,IIC总线接口,通用寄存器控制器(General Purpose I/O Controller),通用中断控制器(Universal Interrupt Controller, UIC),   JTAG.
两个总线分别支持不同的外设 

  • 64位,100M Processor Local Bus(PLB),支持 high performance 外设 
  • 32位,50M On-chip Perpheral Bus(OPB),支持 less performance-critical 外设

先进的功能 

  • PCI接口 
  • 内部集成以太网口(Ethernet port on-chip) 
  • Code pack decompression to improve code density

驱动PowerPC405GP的PowerPC405B3内核包括 

  • 200MHz CPU 内核 
  • 内存管理单元(Memory Mannanagement Unit,MMU) 
  • 16K指令缓村(instruction caches)和8K数据缓存(data caches) 
  • Multiply-Accumulate (MAC)功能 
  • 计时器(Timers) 
  • 调试,JTAG和Trace debug logic 
  • 内核带有4K的SRAM

一个64位累加计时器,由CPU时钟驱动
三个计时器:可编程内部计时器(Programmable Internal Timer,PIT),固定内部计时器(Fix Internal Timer,FIT),看门狗计时器(Watch Dog Timer,WDT)
 
二,VxWorks装入PowerPC的过程
   RISCWatch 是一套软件和硬件开发工具, 主要为IBM PowerPC 600/700系列微处理器和IBM PowerPC 400系列嵌入式处理器提供软硬件, 开发, 调试. 
      开发板JTAG口 (一般开发版都会甩出一个JTAG接口供开发调试用 ) 连出一个2*8针的接头与RISCWatch的仿真器端相连, 仿真器另一端通过网络连到装有RISCWatch软件的PC机. 不同种类的处理器JTAG管脚的定义不同, 所以和2*8针的接头连接也不同, 具体连结方法参见RISCWatch用户手册. 
       通过软件和一个配套的硬件仿真器将VxWorks image写入512K的Flash Socket. RISCWatch一端接板子上的JTAG接口,另一端接网络Network. 
RISCwatch的执行过程顺序: 初始化RAM-------->清理ROM-------->写VxWorks image .bin到FlashRom
用RISCwatch装入VxWorks的操作过程
1.运行RISCwatch: 打开file----->command file------>flashwri.cmd   
2.开启Normal 初始化RAM, 在编辑框中键入run, 开始向FlashRom中写入Bootrom.bin,写入完成,键入stop,至此写入完成
系统复位后, VxWorks运行,讲程序写入RAM中的各个地址
RISCwatch中的文件定义
文件rwppc.env: 可更改,如chip type, PC405GP等
文件flashwri.com: 可以察看,改变,如IP地址,load....,   .out,  .bin
文件flashprog.c: 输出生成 .out, 是写flash Rom 的文件, 写入 .bin
 
三,调试工具及调试方法
底层驱动调试 
RISCWATCH 是一种很好的调试工具,观察内存情况及程序运行.
   通过计算机串口与处理器UART相连,设置计算机的超级终端(Hyper Terminal), 通过超级终端察看硬件情况(寄存器设置,数据等)和程序运行情况,当然程序重要加入向UART送出数据的指令,用Beep报警也是经常用的.这种调试方法是用于底层调试硬件,找出硬件存在的问题.
   VxWorks 在Tornado Shell 不能正常运行前,也是采取这种方法来调试程序,不过一般不是硬件问题,而是BSP中存在的问题,需要根据硬件,修改BSP.
以上是Shell不能正常运行是所采取的方法,Shell正常运行后,Shell是最好的调试工具.
 
上层应用程序调试跟踪
Tornade2.0中Debuger和Shell是最好的调试工具,可以单步执行跟踪程序运行,观察内存情况和系统资源情况.其中Shell的功能要好于Debuger,不过Debuger操作较为容易,直观.
 
四,内存映射
MPC860的内存资源(如寄存器等)映射在一个连续的16K Block存储区内,可通过SPR中的Internal Map Memory Register(IMMR)进行解析
对 Memory Registers 操作的几种方式
Indirectly Access Registers Via Memory-----------------------通过指定的I/O寄存器(I/O port)对一个寄存器操作,
如PCI部分I/O操作示例如下:
PCI地址I/O寄存器: PCICFGADR  0xEEC00000
PCI数据I/O寄存器: PCICFGDATA 0xEEC00004

具体操作方法:将所要读写的寄存器地址写入PCI地址I/O寄存器PCICFGADR,从PCI数据I/O寄存器PCICFGDATA读出数据,这个数据就是写入地址的寄存器的数据.
RegAddr = 0x80000000 | ((offset|BusDevFunc) & 0xFFFFFFFC);
RegAddr寄存器地址, 0x80000000 PCI core Address, offset寄存器偏移量
/*
* 写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结构特点
  •  


    • 32个32位通用寄存器 ( GPRs ) 

    • 寄存器支持用户级指令集 (不包括浮点指令),包括integer exception register (XER ),condition register(CR),link register(LR),counter register ( CTR ) 

    • 时间加减及寄存器 

    • 管理级寄存器,与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 时基和 实时时钟(RTC) 


  

  • 地址映射

 
名称
内存物理地址
备注
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(可通过Swich与Socket Flash 切换)
  

  • 中断优先级(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) 的中断分配

 
中断
极性
触发方式
中断源
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
  

  • 中断向量表

 
        中断向量表的其实地址取决于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
 



    
    这个表结合地址映射表可知系统复位的地址是 Socket Flash地址+系统复位偏移地址 = 0xFFF80000 + 0x0100 = 0xFFF80100,即系统通电后,跳到0xFFF80100的位置开始执行程序.
MPC860串口中断过程
    MPC860集成了两个处理块,一个处理块是嵌入的PowerPC核,另一个是通信处理模块(CPM).通信处理模块有4个SCC和2个SMC,这六个通信口可以通过设置来支持多种协议和通信方式,也可设置为串口UART模式(是通过寄存器GSMR或SMCMR),功能和中断的定义和通常的串口定义基本是一致的在寄存器SCCM/SCCE的位14和位15定义了在何种情况下产生硬件中断. 
    根据MPC860中SCC UART Event Register(SCCE)的位14和位15定义,位14是数据发送中断标志位,位15是数据接收中断标志位,首先设置SCC UART Mask Register(SCCM)的位14和位15为1,使能接受和发送中断.
如果串口收到数据,则产生硬件RX中断,SCCE为15置1,通知系统有数据到达,有相应的中断例程ISR来取数据. 
    发送的情况下,数据FIFO为空,产生TX中断,告诉系统发送准备就绪,可以发送,ISR把数据放入FIFO中,发送中断位清零.当发送完毕后,FIFO再为空,再次产生中断,告诉系统发送准备就绪,继续发送. 
MPC860片选信号的编程方法 
在MPC860中,有片选信号CS0,CS1,...,CS7对他们的操作主要是要改变片选信号的电平 
一般来说片选信号的发生是对和这一片选线相关联的地址进行操作(读写)时片选信号改变。片选信号通常为低电平有效。比如MPC860的CS0是boot rom,硬件reset后,CPU会从boot rom的起始地址开始执行,CS0变为低
电平。
CS0\ ____                         片选型号
             |
             |____________________
we\ _____                        写有效
              | 
              |_____________________
data _______  __  __                数据信号
                       | | | | | 
                 |_| |_| |
所以只要对一个相应的地址操作,和这个地址芯片(bank)相连的CSx就会改变。
MPC860对CSx分配地址空间的在BRx中定义,BR0,BR1...BR7分别对应8个片选线CS0--CS7。
 
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 iinstruction 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
 

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
 

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.
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics