Creating Edink From DINK32 Code
Creating Edink From DINK32 Code
1 Introduction
This document describes the method and coding for the e500 edink program running on the e500 ISS.
1.1 Terminology
The following terms are used in this document.
Bash shell Extension to the Bourne shell, which is popular on Linux systems and is
sometimes called GNU Born Again Bourne Shell. This is the default shell for most
Linux systems because Linux uses GNU tools exclusively. This is the best shell
running the ISS.
Boot Program that begins at hardware reset, which prepares the hardware for loading
an operating system
Boot address Address from which the board will attempt to boot after reset
BR Base address register
Compiler A software program that converts a high level source code into machine-specific
binary
CPU Central processor unit, that is the e500 processor
DDR Dual data rate SDRAM
DINK32 Small operating system debugger for the Sandpoint evaluation board
edink Small operating system debugger for the e500 processors and the MARS platform
Host A machine that can be used to build kernels. The host may or may not be the same
architecture. For example, Freescale builds kernels on G4 machines, UNIX
machines, and Intel machines.
ISS A software model that simulates instruction processing capability of a processor
LAW Local access window
MARS Evaluation board platform for the MPC8540 and MPC8560 processors
OR Option register
OS Operating system
PCI Peripheral component interface
RAM Random access memory
Scrub memory Setting memory with known values
SDRAM Synchronous dynamic RAM
Creating edink from DINK32 Code Using the e500 ISS, Rev. 2
2 Freescale Semiconductor
What is edink?
2 What is edink?
edink is DINK ported for the e500 core based processors. DINK stands for Demonstrative Interactive
Nano Kernel and is the program that boots and configures the Sandpoint evaluation system. Like DINK,
edink boots the e500 core, enables caches, defines TLBs, and jumps to a prompt loop. Before a processor
with an e500-based core was available in production quantities, edink was tested on a simulator. Currently,
edink also runs on the Elysium board.
3 edink Startup
The e500 core boots from the address of 0xFFFF_FFFC. At boot time, one TLB entry is defined for an
address space of 4K starting at 0xFFFF_F000. A branch instruction must be placed at address
0xFFFF_FFFC to branch to an address within the configured 4K space. From there more TLB entries can
be defined.
When edink boots it jumps to 0xFFFF_F000. Then edink performs the following MPC8540 initialization
in sequence:
1. Temporarily sets the interrupt vector offset registers (IVORs) and interrupt vector prefix register
(IVPR) to 0xFFFF_F000 so that if exception occurs it goes to a TLB covered area.
2. Sets up the PID registers. Edink uses the PID register value of 0x0000_0000. The other two PID
registers are programmed with the values of 0x0000_0001 and 0x0000_0002.
3. Sets up time base and decrementer.
4. Invalidates the L1 and L2 TLB entries. Specifically, the IL1MMU, IL2MMU, L2TLB4K, and
L2TLBCAM.
5. Sets up additional TLB entries. The TLB entry structures are discussed in Section 4, “Memory
Map,” of this document.
6. Invalidates and turns on L1 cache. The simulator does not support the L2 and L3 cache.
Consequently, edink does not attempt to enable the L2 and L3 caches.
7. Relocates the Configuration, Control, and Status Registers Base Address Register (CCSRBAR) to
0xFC00_0000.
8. Sets up Local Access Window (LAW) registers. For details see Section 4, “Memory Map.”
9. Initializes console I/O.
10. Configures local bus controller.
11. Configures DDR memory controller.
12. Configures PCI.
13. Scrubs memory and copies the exception table and the rest of edink (except the boot code,
startup.S) to low memory (RAM) starting at address 0x0000_0000.
14. Sets up the IVORs and the IVPR to point to the exception table in SDRAM. The structure of the
exception table is discussed in Section 5.1, “Exception Handling.”
15. Defines stack space. Stack space is described in Section 5, “Stack Space for edink.”
16. Sets up the MSR value to 0x0200_0000 and return from instructions (RFIs) to the main program.
The bit set in the MSR value corresponds to SPE enablement.
Creating edink from DINK32 Code Using the e500 ISS, Rev. 2
Freescale Semiconductor 3
Memory Map
4 Memory Map
Unlike processors that implement the classic PowerPC™ architecture, the e500 is based on the embedded
PowerPC architecture (Book E). These processors use TLBs rather than BAT registers. For a detailed
description of TLB entries and how to program them refer to the MPC8540 or MPC8560 processor’s
reference manual.
At reset, a 4K memory space is predefined starting at 0xFFFF_F000 with supervisor read, write, and
execute permission. This memory area is caching inhibited. The startup code (in ‘startup.S’) sets up the
processor, the TLBs (to enable more than 4K), the Local Access Windows (LAWs) to access internal
peripherals, and the corresponding embedded device setup.
Note that the CCSRBAR is relocated from the default 0xFF70_0000 to 0xFC00_0000.
Once initialization is complete and the system has been setup, the memory map shown in Table 4-1 is
available.
Table 4-1. EDINK Memory Map
Size
Start Address End Address TLB1 LAW BR/OR Description
(MB)
Creating edink from DINK32 Code Using the e500 ISS, Rev. 2
4 Freescale Semiconductor
Stack Space for edink
Address ROM
Creating edink from DINK32 Code Using the e500 ISS, Rev. 2
Freescale Semiconductor 5
Stack Space for edink
There are three types of exceptions in the e500 core. These are:
• Normal exceptions which are identical to the classic exceptions
• Critical exceptions which include the critical class exceptions
• Machine check exception.
Consequently, there are three handlers for the three types of exceptions: normal_handle_ex handles the
normal exceptions, critical_handle_ex handles the critical exceptions, and machine_handle_ex handles the
machine check exception. All the exception handlers restore the registers, print out exception names, and
causal addresses and return one of two locations depending on the following cases:
• If the exception has occurred while edink is running the return address is where edink was last
executing before the exception
• If the exception has occurred while edink is running user code the return address is dink loop
Normal exceptions return using the rfi instruction, while critical and machine check exceptions use rfci
and rfmci instructions, respectively. At the time of this writing normal exceptions are fully implemented,
however, critical and machine check exceptions are not fully implemented.
Critical and machine check exceptions will loop on a branch to self instruction forever, and the following
registers are set up:
• r10 = type of exception (that is, the address of the exception table for this exception)
• r11 = address that caused the exception.
• r12 = the user msr at the time of the exception.
Creating edink from DINK32 Code Using the e500 ISS, Rev. 2
6 Freescale Semiconductor
e500 Instruction Set Simulator
Creating edink from DINK32 Code Using the e500 ISS, Rev. 2
Freescale Semiconductor 7
e500 Instruction Set Simulator
For further usage of the sportal facility refer to the sportal user’s manual provided with the ISS in the
simPortal/doc directory.
Two example sportal files are supplied with edink, one for file input/output (I/O) and one for emulated
terminal I/O.
go
6.3 sportal_file
sportal open
ld obj/edink
6.4 sportal_term
sportal open
ld obj/edink
Creating edink from DINK32 Code Using the e500 ISS, Rev. 2
8 Freescale Semiconductor
Compiler
7 Compiler
An e500 core aware compiler/assembler tool chain should be used to build the code.
E500 compilers do not generate floating point instructions. If your compiler does not understand these
instructions then try the following:
• Signal Processing Engine (SPE) instruction
— can be coded with .long using the hex equivalent of the instruction
• the msync instruction
— is generated by the sync instruction
The following instruction, while supported, has a different form than shown in EREF: A Reference for
Freescale Book E and the e500 Core (EREF/D).
• tlbwe instruction
The compiler requires three parameter registers (tlbwe rA, rB, rC) to the instruction. These registers are
un-altered by the architecture (machine).
Creating edink from DINK32 Code Using the e500 ISS, Rev. 2
Freescale Semiconductor 9
Code Changes
9 Code Changes
Several new files are written for edink. Some of these are e500.h, vector.S, startup.S and except2e.S. edink
boots up from vector.S. There are two reasons why the boot file is written on a separate assembly file.
1. Having a boot code that is separate from the exception table is a cleaner approach.
2. e500 core boots at an address of 0xFFFF_FFFC. Having a single file with the exception table
(which is located starting at 0x0100) and the high address of 0xFFFF_FFFC is not convenient for
linking.
except2e.S contains the exception table. The exception table is similar to the classic dink exception table
and may eventually be integrated with the classic dink.
Several classic dink files are modified for edink. The following are the major changes:
• main.c
— new entry in mach_info for MARS
— call initialize functions only for e500
• reg_swap.S, spr_loc.h, dink_asm.h, reg_fields.h
— all the new and changed SPRs are handled here for dink initialize, save and restore.
• config.h
— define MARS and PPC. The PPC is defined for future MPC8540 and MPC8560 specific code
changes.
• shell.c
— define new command, sq - simulator quit.
— suppress terminal echo for standard I/O files
• par_tb.c, pmc.c
— splash screen changes
• print.c
— suppress ^M printing on sportal file I/O
• go_tr1.c, except1.c
— don’t execute cache flush for L2 or L3. e500 simulator doesn’t support them
• reg_spr.c
— srr1 user msr changed to 0x0200_0000.
— define e500 SPR fields for the “sx” command
• uart.c, rtc.c, iolib.c
— minor changes
All other files are being used without changes.
Creating edink from DINK32 Code Using the e500 ISS, Rev. 2
10 Freescale Semiconductor
edink Availability
10 edink Availability
Edink limited source will be available on the Freescale web site with the rest of the classic DINK R13.1.
Full source can be obtained with a license agreement.
Creating edink from DINK32 Code Using the e500 ISS, Rev. 2
Freescale Semiconductor 11
Example Run
## ## ##
## ## ##
## ##
###### ####### ## ####### ## ##
## ## ## ## ## ## ## ## ##
##### ## ## ## ## ## ######
## ## ## ## ## ## ## ##
##### ###### ## ## ## ## ##
Version : 13.1, GCC Build
12 Example Run
This example uses the sportal_file as explained in Section 6.3, “sportal_file.” Once this file is sourced then
the ISS will use the src/my_stdin file as input to edink and generate the file my_stdout. The ISS will read
the src/my_stdin file handing each character to edink who will then generate the my_stdout file.
src/my_stdin file has the sq, simulator quit, command as the last line, which will invoke the ISS exit code.
12.1 invocation
iss
4160749439 bytes are available for your program's heap and stack.
e500(running)>
rd r
rm r3
rm r8
Creating edink from DINK32 Code Using the e500 ISS, Rev. 2
12 Freescale Semiconductor
Example Run
8080
rd r
as 100000+
here:
lis r20,20
ori r20,r20,20
b here
ds 100000-100020
bp 100008
bp
sq
Do you desire echo on or off? Typically off for sim terminal, on for sim file io
R03 = 00000000 ? 3
Creating edink from DINK32 Code Using the e500 ISS, Rev. 2
Freescale Semiconductor 13
Documentation Revision History
Breakpoint at 00100008
Breakpoints:
1. 0x00100008
0 Initial release.
1 Changes to comply with edink for the Elysium hardware. Removed section “problems encountered with
simulator”. Added document revision history
Creating edink from DINK32 Code Using the e500 ISS, Rev. 2
14 Freescale Semiconductor
Documentation Revision History
Creating edink from DINK32 Code Using the e500 ISS, Rev. 2
Freescale Semiconductor 15
How to Reach Us:
Home Page:
www.freescale.com
email:
[email protected]
USA/Europe or Locations Not Listed:
Freescale Semiconductor
Technical Information Center, CH370
1300 N. Alma School Road Information in this document is provided solely to enable system and software
Chandler, Arizona 85224 implementers to use Freescale Semiconductor products. There are no express or
1-800-521-6274
implied copyright licenses granted hereunder to design or fabricate any integrated
480-768-2130
[email protected] circuits or integrated circuits based on the information in this document.
Europe, Middle East, and Africa: Freescale Semiconductor reserves the right to make changes without further notice to
Freescale Halbleiter Deutschland GmbH any products herein. Freescale Semiconductor makes no warranty, representation or
Technical Information Center
guarantee regarding the suitability of its products for any particular purpose, nor does
Schatzbogen 7
81829 Muenchen, Germany Freescale Semiconductor assume any liability arising out of the application or use of
+44 1296 380 456 (English) any product or circuit, and specifically disclaims any and all liability, including without
+46 8 52200080 (English) limitation consequential or incidental damages. “Typical” parameters which may be
+49 89 92103 559 (German)
provided in Freescale Semiconductor data sheets and/or specifications can and do
+33 1 69 35 48 48 (French)
[email protected] vary in different applications and actual performance may vary over time. All operating
parameters, including “Typicals” must be validated for each customer application by
Japan:
Freescale Semiconductor Japan Ltd. customer’s technical experts. Freescale Semiconductor does not convey any license
Headquarters under its patent rights nor the rights of others. Freescale Semiconductor products are
ARCO Tower 15F not designed, intended, or authorized for use as components in systems intended for
1-8-1, Shimo-Meguro, Meguro-ku
surgical implant into the body, or other applications intended to support or sustain life,
Tokyo 153-0064, Japan
0120 191014 or for any other application in which the failure of the Freescale Semiconductor product
+81 3 5437 9125 could create a situation where personal injury or death may occur. Should Buyer
[email protected] purchase or use Freescale Semiconductor products for any such unintended or
Asia/Pacific: unauthorized application, Buyer shall indemnify and hold Freescale Semiconductor
Freescale Semiconductor Hong Kong Ltd. and its officers, employees, subsidiaries, affiliates, and distributors harmless against all
Technical Information Center
claims, costs, damages, and expenses, and reasonable attorney fees arising out of,
2 Dai King Street
Tai Po Industrial Estate, directly or indirectly, any claim of personal injury or death associated with such
Tai Po, N.T., Hong Kong unintended or unauthorized use, even if such claim alleges that Freescale
+800 2666 8080 Semiconductor was negligent regarding the design or manufacture of the part.
[email protected]
For Literature Requests Only: Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc.
Freescale Semiconductor The Power Architecture and Power.org word marks and the Power and Power.org logos
Literature Distribution Center and related marks are trademarks and service marks licensed by Power.org. All other
P.O. Box 5405 product or service names are the property of their respective owners.
Denver, Colorado 80217 © Freescale Semiconductor, Inc., 2004, 2006.
1-800-441-2447
303-675-2140
Fax: 303-675-2150
LDCForFreescaleSemiconductor
@hibbertgroup.com