Codewarrior® Targeting Embedded Powerpc
Total Page:16
File Type:pdf, Size:1020Kb
CodeWarrior® Targeting Embedded PowerPC Because of last-minute changes to CodeWarrior, some of the information in this manual may be inaccurate. Please read the Release Notes on the CodeWarrior CD for the most recent information. Revised: 991129-CIB Metrowerks CodeWarrior copyright ©1993–1999 by Metrowerks Inc. and its licensors. All rights reserved. Documentation stored on the compact disk(s) may be printed by licensee for personal use. Except for the foregoing, no part of this documentation may be reproduced or trans- mitted in any form by any means, electronic or mechanical, including photocopying, recording, or any information storage and retrieval system, without permission in writing from Metrowerks Inc. Metrowerks, the Metrowerks logo, CodeWarrior, and Software at Work are registered trademarks of Metrowerks Inc. PowerPlant and PowerPlant Constructor are trademarks of Metrowerks Inc. All other trademarks and registered trademarks are the property of their respective owners. ALL SOFTWARE AND DOCUMENTATION ON THE COMPACT DISK(S) ARE SUBJECT TO THE LICENSE AGREEMENT IN THE CD BOOKLET. How to Contact Metrowerks: U.S.A. and international Metrowerks Corporation 9801 Metric Blvd., Suite 100 Austin, TX 78758 U.S.A. Canada Metrowerks Inc. 1500 du College, Suite 300 Ville St-Laurent, QC Canada H4L 5G6 Ordering Voice: (800) 377–5416 Fax: (512) 873–4901 World Wide Web http://www.metrowerks.com Registration information [email protected] Technical support [email protected] Sales, marketing, & licensing [email protected] CompuServe Goto: Metrowerks Table of Contents 1 Introduction 11 Read the Release Notes! . 11 Solaris: Host-Specific Information. 12 About This Book . 12 Where to Go from Here . 15 Technical Support. 18 Metrowerks Year 2000 Compliance . 19 2 Getting Started 21 System Requirements . 21 Installing CodeWarrior for Embedded PowerPC . 24 CodeWarrior Compiler Architecture. 25 Development Tools for Embedded PowerPC . 25 CodeWarrior IDE. 26 CodeWarrior Compiler for Embedded PowerPC . 26 CodeWarrior Assembler for Embedded PowerPC. 27 CodeWarrior Linker for Embedded PowerPC . 27 CodeWarrior Debugger for Embedded PowerPC . 28 MetroTRK. 28 Metrowerks Standard Libraries . 29 The Development Process with CodeWarrior . 29 Makefiles . 30 Editing Code . 31 Compiling. 31 Linking . 31 Debugging . 32 Viewing Preprocessor Output . 32 3 Creating a Project for Embedded PowerPC 33 Types of Projects . 33 Project Stationery . 33 Creating a Project . 34 Project Stationery Targets . 37 Working with a Project . 38 Targeting Embedded PowerPC PPC–3 4 Target Settings for Embedded PowerPC 63 Target Settings Overview . 63 Settings Panels to Optimize Code . 65 Settings Panels for Embedded PowerPC . 66 Target Settings . 67 EPPC Target . 70 EPPC Assembler . 75 Global Optimizations . 78 EPPC Processor . 79 EPPC Disassembler. 87 EPPC Linker. 90 EPPC Target Settings . 101 Remote Debugging Options . 114 EPPC Exceptions . 116 Connection Settings . 118 5 Debugging for Embedded PowerPC 123 Supported Debugging Methods . 123 Setting Up for Remote Debugging . 126 Configuring Your Embedded PowerPC Board . 127 Connecting with a Debug Monitor . 127 Connecting with CodeTAP . 132 Connecting with PowerTAP . 136 Connecting with Wiggler, Hummingbird, or Raven BDM . 140 Connecting with Raven COP. 142 Connecting with Abatron BDI2000 . 143 Special Debugger Features for Embedded PowerPC . 147 Displaying Registers . 147 EPPC Menu . 150 AMC Data and Instruction Cache Windows . 152 Register Details Window . 155 Using MetroTRK . 157 MetroTRK Overview . 157 MetroTRK Baud Rates . 158 MetroTRK Memory Configuration . 158 PPC–4 Targeting Embedded PowerPC Using MetroTRK for Debugging. 162 Debugging ELF Files . 162 Customizing the Default XML Project File . 163 Debugging an ELF File. 164 ELF File Debugging: Additional Considerations . 165 6 C and C++ for Embedded PowerPC 167 Integer Formats . 168 Embedded PowerPC Integer Formats . 169 Embedded PowerPC Floating-Point Formats . 170 AltiVec Vector Data Formats . 170 Data Addressing. 171 Calling Conventions . 174 Register Variables . 174 Register Coloring Optimization . 175 Generating Code for Specific Processors . 177 Pragmas . 177 force_active. 179 function_align . 179 incompatible_return_small_structs . 180 incompatible_sfpe_double_params . 180 interrupt . 180 pack . 181 pooled_data . 182 section . 183 Linker Issues for Embedded PowerPC . 189 Linker Generated Symbols . 190 Deadstripping Unused Code and Data . 191 Link Order . 192 Linker Command Files . 192 __attribute__ ((aligned(?))) . 203 Variable Declaration Examples . 203 Struct Definition Examples . 204 Typedef Declaration Examples . 204 Struct Member Examples . 205 Targeting Embedded PowerPC PPC–5 7 Libraries and Runtime Code for Embedded PowerPC 207 MSL for Embedded PowerPC . 207 Using MSL for Embedded PowerPC . 208 Using Console I/O for Embedded PowerPC . 209 Allocating Memory and Heaps for Embedded PowerPC. 212 Runtime Libraries for Embedded PowerPC . 212 Board Initialization Code . 214 8 Inline Assembler for Embedded PowerPC 215 Working With Assembly . 216 Assembler Syntax for Embedded PowerPC . 216 Special Embedded PowerPC Instructions . 220 Support for AltiVec Instructions . 220 Creating Labels for Embedded PowerPC Assembly . 221 Using Comments in Embedded PowerPC Assembly . 221 Using the Preprocessor in Embedded PowerPC Assembly . 222 Using Local Variables and Arguments. 222 Creating a Stack Frame in Embedded PowerPC Assembly . 223 Specifying Operands in Embedded PowerPC Assembly . 224 Assembler Directives . 230 entry . 230 fralloc. 231 frfree . 231 machine. 232 nofralloc . 234 opword . 234 Intrinsic Functions . 234 Low-Level Processor Synchronization. 235 Floating-Point Functions . 236 Byte-Reversing Functions . 236 Setting the Floating-Point Environment . 237 Manipulating the Contents of a Variable or Register. 237 Data Cache Manipulation . 238 Math Functions . 239 Buffer Manipulation . 240 PPC–6 Targeting Embedded PowerPC AltiVec Intrinsics Support . 240 9 Troubleshooting for Embedded PowerPC 243 No Communications with Target Board. 243 Downloading Code Fails or Crash When Code Runs . 244 Debugger Window Does Not Appear. 245 Common Error Warnings for CodeTAP and PowerTAP . 245 Targeting BDM Devices FAQ . 246 10 Using a CodeTAP Debugging Device 249 CodeTAP Highlights . 250 CodeTAP Technical Support. 251 CodeTAP Requirements . 252 Target Settings for CodeTAP . 252 Setting Up the CodeTAP Emulator . 254 Updating the CodeTAP Firmware . 255 Debugging Using CodeTAP . 255 Resetting the Processor . 255 11 Using the PowerTAP 6xx/7xx Debugging Device 257 PowerTAP Highlights . 258 PowerTAP Technical Support . 259 PowerTAP Requirements . 260 Target Settings for PowerTAP . 260 Setting Up the PowerTAP Emulator . 262 Updating the PowerTAP Firmware. 263 Resetting the Processor . 263 Operational Notes . 264 Recoverable Interrupts . 264 Interrupts and the Machine Status Save/Restore Registers . 265 A Flash Programmer 267 What You See . 267 Console . 268 Status and Errors . 268 Help. 269 Targeting Embedded PowerPC PPC–7 Preferences . 270 Using the Flash Programmer . 273 Initialize the Programmer . 274 Specify a Flash Image . 274 Send the Flash Image . 274 Command File Syntax . 275 Write Register Commands. 275 Read, Write and Save Memory Commands . 277 Loop Commands. 282 Action Commands . 284 Wait and Abort Commands . 284 Print Commands . 285 Miscellaneous Commands. 286 B Debug Initialization Files 289 Using Debug Initialization Files . ..