Skip to main content

If you don't have an IBM ID and password, register here.

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. This profile includes the first name, last name, and display name you identified when you registered with developerWorks. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

Introduction to embedded software development for the IBM PowerPC 970FX processor

Learn how to use your existing skills and take advantage of new capabilities

Matt Tyrlik, Senior Engineer, IBM
Matt Tyrlik is a software engineer working in embedded software development.

Summary:  The IBM PowerPC® 970FX processor is great for embedded programming, but it has a few features, such as 64-bit support, that many embedded developers might not know just how to exploit. Read on to get up-to-speed and learn what you need to know.

Date:  16 Sep 2005 (Published 01 Aug 2004)
Level:  Intermediate

Comments:  

Introduction to the IBM PowerPC 64-bit architecture

The IBM PowerPC architecture describes two computation modes: 32- and 64-bit. The IBM PowerPC 403GCX, PowerPC 405GP, PowerPC 440GX, and Power PC750FX microprocessors are examples of processors that implement only 32-bit computation mode. The PowerPC 970FX processor implements both computation modes. Generally, PowerPC processors that implement only 32-bit computation mode are referred to as 32-bit PowerPC processors. Processors that implement both computation modes are referred to as 64-bit PowerPC processors. If a processor implements the 64-bit computation mode, it also must implement the 32-bit computation mode.

All the user-level registers (except for floating-point registers, which are 64-bit wide) implemented by the 32-bit PowerPC processors are 32-bit wide. High-level language compilers generate user-level instructions, which in turn use the user-level registers. In 32-bit PowerPC processors, all the supervisor-level registers are 32 bits wide. The supervisor-level registers are typically accessed only by system software (operating system) and device drivers. The machine state register (MSR) is 32 bits wide in the 32-bit PowerPC processors.

Most user-level registers implemented by the 64-bit PowerPC processors (PowerPC 970FX) are 64-bit wide. Only the condition register (CR) and the floating-point status and control register (FPSCR) are 32-bit wide. Although the PowerPC 970FX processor implements both 32- and 64-bit computational modes, there is only one set of user- and supervisor-level registers. The single set of registers is used for both computation modes. In the PowerPC 970FX processor, the supervisor-level registers are a mix of 32- and 64-bit registers. For example, the processor version register (PVR) is 32 bits wide, but the hardware implementation register 0 (HID0) is 64 bits wide. The MSR is 64 bits wide in the PowerPC 970FX processor. The computation mode of the PowerPC 970FX processor is controlled by the setting of the MSR's Sixty-Four-Bit Mode bit. Changing this bit alters the processor's computation mode.

All the PowerPC instructions are 32 bits wide irrespective of the computation mode or processor implementation. The PowerPC 970FX processor can execute all user-level instructions implemented by the 32-bit PowerPC processors. The PowerPC 970FX processor can also execute a number of new user-level instructions that are valid only for 64-bit PowerPC implementations. The instructions implemented by the 32-bit PowerPC processors and the new 64-bit PowerPC instructions execute using the same processor execution units and use the same registers in the PowerPC 970FX processor. There is no performance penalty associated with execution of either instruction set on the PowerPC 970FX processor, regardless of the computation mode.

User-level instructions that are specific to the 64-bit PowerPC processor implementations include load and store double-word instructions as well as arithmetic and logical instructions that use 64-bit-wide operands. The user-level instructions that are specific to the 64-bit PowerPC processor implementations and the instructions implemented by the 32-bit PowerPC processor can be executed in either computation mode.


PowerPC 64-bit ELF ABI

The Application Binary Interface (ABI) describes various aspects of the execution environment for compiled programs. The PowerPC 64-bit ELF ABI is used for application programs executing in 64-bit computation mode. The PowerPC 64-bit ELF ABI is implemented by the GNU GCC compiler and by the GNU binary utilities package. The 64-bit IBM PowerOpen™ ABI is used by the IBM AIX® operating system and has the same calling convention as the PowerPC 64-bit ELF ABI. The PowerPC 64-bit ELF ABI is basically an adaptation of the 64-bit PowerOpen ABI to the ELF object file format.

Code executing in 32-bit computation mode should use the PowerPC 32-bit Embedded Application Binary Interface (EABI) or a comparable 32-bit PowerPC ABI. Code using the 32-bit PowerPC ABI can execute assembly instruction functions in 64-bit computation mode. The assembly language function can switch to the 64-bit computation mode, execute a series of instructions, and then switch back to 32-bit computation mode.

Multiprocess operating systems (for example, Linux®) can switch between application programs running in 32-bit computation mode using a 32-bit ABI, and programs running in 64-bit computation mode using the PowerPC 64-bit ELF ABI. In order to support both the 32- and 64-bit computation mode application programs, the operating system itself must execute in 64-bit computation mode and must have the ability to load multiple executable files. A single executable file cannot contain code that executes using the PowerPC 64-bit ELF ABI and PowerPC 32-bit EABI.

Single-process operating systems such as VxWorks can only execute application programs using a single ABI. It is not possible to create a single executable file with a mixture of object files compiled using PowerPC 64-bit ELF ABI and PowerPC 32-bit EABI.

The PowerPC 64-bit ELF ABI covers the following topics:

  • C and C++ language fundamental data type size and alignment
  • Register usage
  • Stack layout
  • Table of content format
  • Function descriptors
  • Traceback tables structure
  • Object file format

Development tools

Tools supporting the PowerPC 64-bit ELF ABI have to be used for 64-bit computation mode program development. Tools supporting one of the existing 32-bit PowerPC ABIs have to be used for application programs executing in 32-bit computation mode. Assembly language functions executing in 64-bit computation mode can be written using 32-bit PowerPC tools. Because the tools supporting the PowerPC 64-bit ELF ABI produce 64-bit ELF object files, and 32-bit PowerPC ABI tools typically produce 32-bit ELF object files, the output from both tool chains cannot be combined into a single executable program. It is possible to write assembly language functions that execute in 64-bit computation mode using the 32-bit tools, though.

The GNU GCC compiler and GNU binary utilities (linker, assembler, archiver) can be used for both PowerPC 970FX 64- and 32-bit computation mode application-program development. However, a single instance of the GNU GCC compiler can't support both the PowerPC 64-bit ELF ABI and 32-bit PowerPC EABI. Two independent copies of the compiler and the tools have to be created when developing software for the 32-bit computation and 64-bit computation mode. For more information on building the GNU development tools, see the "Building a GNU Toolset For Use In Embedded PowerPC Cross Development" application note (see Resources for a link). Version 3.3.1 or later of the GNU GCC compiler and Version 2.14 or later of the GNU binary utilities support the PowerPC 64-bit ELF ABI.

The RISCWatch debugger currently supports debugging of the software running on the PowerPC 970FX processor. RISCWatch is typically attached to the PowerPC 970FX processor using a Joint Test Action Group (JTAG) port. RISCWatch supports the debugging of low-level system software as well as application programs written in the C as well as the C++ language. RISCWatch supports debugging of programs using PowerPC 64-bit ELF or PowerPC 32-bit EABI.


Porting PowerPC 32-bit software to PowerPC 970FX 64-bit computation mode

Most software programs written in the C or C++ language can be easily migrated to the 64-bit computation mode of the PowerPC 970FX processor. In the C language, only long and pointer data types are different between the PowerPC 32-bit EABI and PowerPC 64-bit ELF ABI. The change in size of long and pointer data types affects the structure element alignment and structure padding, which is important if the data is accessed in multiple contexts (for example, C language and assembler). The data type change also affects results of certain assignment and arithmetic operations.

A compiler can also insert padding at the end of a structure. Structure-end padding is required in case the structure is used as an element of an array. Such padding is not required if this structure is compiled for the 32-bit ABI. Care must be taken if a structure size or field alignment is restricted. The structure mapping can be restricted because it represents data that is transmitted over the network (for example, a TCP header structure).

Another example of a problem is related to the change in size of the pointer data type as illustrated in the following sample code:

int 	test;
void 	*p;
test=(int)p;

The sample code running in 32-bit computation mode executes correctly because the size of the pointer variable is the same as the size of the integer variable. In 64-bit computation mode, the code sample might not execute correctly if the pointer value is greater than 232. The GNU GCC compiler produces a warning message when compiling this code even though an explicit cast is used. Any pointer arithmetic should be performed using variables of type long, regardless of the computation mode. Pointer assignment should only be performed between other pointers or variables of type long. In general, the use of pointers as well as the long data type might need to be examined when porting 32-bit PowerPC programs. Care must also be taken then when displaying long or pointer values because the number of characters required to display these values is different.

The use of function descriptors by the PowerPC 64-bit ELF ABI requires that changes be made to code that manipulates function addresses. In order to access function addresses, the following code can be used:

int function_name(int arg1, int arg2);
typedef struct function_descriptor {
void	*addr;
unsigned long	toc;
unsigned long	env;
} f_desc_t;
function_address=(unsigned long)(((f_desc_t *)function_name)->addr);

The process of porting current 32-bit software targeted for the 64-bit computation mode of the PowerPC 970FX is in large measure limited to changes in the programs that will execute in Supervisor mode.


Porting PowerPC 32-bit software to PowerPC 970FX 32-bit computation mode

User-level 32-bit PowerPC application programs do not require any changes in order to be executed in the 32-bit computation mode on the PowerPC 970FX processor. The 32-bit computation mode is chosen by setting the SF bit in the MSR register to 0. In order to exploit some of the 64-bit capabilities of the PowerPC 970FX processor, changes in the original 32-bit PowerPC user-level application programs can be made. For example, if 32-bit software is performing 64-bit scalar arithmetic operations, the arithmetic operations can be written in assembly language. Such assembly function can be called from high-level languages. The values passed to the function that is performing 64-bit arithmetic and the return value must be contained in lower 32-bits of general-purpose registers (GPRs).

The process of porting current 32-bit software targeted for the 32-bit computation mode of the PowerPC 970FX is in large measure limited to changes in the programs that will execute in Supervisor mode.


Summary

The PowerPC 970FX processor can execute application programs in both 32-bit computation mode and in 64-bit computation mode. Because the PowerPC architecture from the beginning described a 32-bit computation mode and a 64-bit computation mode, PowerPC 32-bit software can be ported with minimal effort to the 64-bit computation mode of the PowerPC 970FX processor. The ease of porting existing 32-bit PowerPC applications is facilitated in part by the PowerPC 64-bit ELF ABI because it offers logical extension to the 32-bit PowerPC EABI. Existing user-level PowerPC 32-bit software can be executed in 32-bit computation mode without any changes. The tasks required to port supervisor-level PowerPC 32-bit software to the PowerPC 970FX processor are not significantly different from the tasks required to port supervisor-level software between different 32-bit PowerPC processor implementations. The PowerPC 970FX 32-bit computation mode and the 64-bit computation mode programs share the same processor registers and use the same execution units. There is no performance penalty associated with running 32-bit computation mode applications on a PowerPC 970FX processor. The "Developing Embedded Software For The IBM PowerPC 970FX Processor" application note (see Resources) provides additional information on porting software to the PowerPC 970FX processor.


Resources

Learn

Get products and technologies

Discuss

About the author

Matt Tyrlik is a software engineer working in embedded software development.

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in

If you don't have an IBM ID and password, register here.


Forgot your IBM ID?


Forgot your password?
Change your password


By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. This profile includes the first name, last name, and display name you identified when you registered with developerWorks. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

(Must be between 3 – 31 characters.)


By clicking Submit, you agree to the developerWorks terms of use.

 


Rate this article

Comments

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Multicore acceleration
ArticleID=94029
ArticleTitle=Introduction to embedded software development for the IBM PowerPC 970FX processor
publish-date=09162005
author1-email=tyrlik@us.ibm.com
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

For articles in technology zones (such as Java technology, Linux, Open source, XML), Popular tags shows the top tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), Popular tags shows the top tags for just that product zone.

For articles in technology zones (such as Java technology, Linux, Open source, XML), My tags shows your tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), My tags shows your tags for just that product zone.

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).