Next: , Previous: Overview, Up: Example


5.2 Example Configuration File

The example configuration file is in the file or1k.cfg. It represents the state of the target at the start of executing the code of simputc, called from simputs, following its first call from main.

The stack frame is for simputc, with stack pointer 0x7eb4 and frame pointer 0x7ebc. The next instruction to be executed is at location 0x1030 (immediately after the simputc function prologue). The return address, held in the link register, gpr9, is 0x12b0, within the code of main

The machine description specifies this is an OpenRISC 1000 and big endian.

     NAME ( "OpenRISC 1000", BIG ENDIAN)

The register description specifies the 32 General Purpose Registers, the Next and Previous Program Counters and the Supervision Register. These are initialized to correspond to the program and stack described earlier.

     REGISTERS ( 35 )
     { "gpr0", 32, 0 }               // Always zero
     { "gpr1", 32, 0x7eb4 }          // Stack pointer
     { "gpr2", 32, 0x7ebc }          // Frame pointer
     { "gpr3", 32, 0 }               // Start of argument registers
     { "gpr4", 32, 0 }
     { "gpr5", 32, 0 }
     { "gpr6", 32, 0 }
     { "gpr7", 32, 0 }
     { "gpr8", 32, 0 }               // End of argument registers
     { "gpr9", 32, 0x12b0 }          // Link register
     { "gpr10", 32, 0 }
     
     ... More general purpose registers initialized to zero ...
     
     { "gpr31", 32, 0 }
     { "ppc",   32, 0x102c }         // Previous program counter
     { "npc",   32, 0x1030 }         // Next program counter
     { "sr",    32, 0 }              // Supervision register

There are four memory blocks.

The interrupt vector block specifies 256 bytes of zeros, followed by the interrupt vector code. The remainder of the interrupt vectors can be uninitialized, since we will not be analyzing them with GDB.

     WORD MEMORY (0x0, 0x1000)
     0x00000000, 0x00000000, 0x00000000, 0x00000000,
     0x00000000, 0x00000000, 0x00000000, 0x00000000,
     
     ... 60 more similar lines ...
     
     0x00000000, 0x00000000, 0x00000000, 0x00000000,
     0x00000000, 0x00000000, 0x00000000, 0x00000000,
     0x9c207f00,                     // l.addi   r1,r0,0x7f00
     0x9c410000,                     // l.addi   r2,r1,0
     0xb4600011,                     // l.mfspr  r3,r0,0x11
     0xa8630002,                     // l.ori    r3,r3,0x2
     0x0400048a,                     // l.jal    <main>
     0xc0001811                      // l.mtspr  r0,r3,0x11

The main program image is a straight word dump in hex of the program image.

     WORD MEMORY (0x1000, 0x3a0)
     0x9c21fff8, 0xd4011000, 0x9c410008, 0xd7e21ffc,
     0x15000001, 0x84410000, 0x44004800, 0x9c210008,
     0x9c21fff8, 0xd4011000, 0x9c410008, 0xd7e21ffc,
     0x15000004, 0x84410000, 0x44004800, 0x9c210008,
     
     ... lots more similar ...
     
     0x07ffffb0, 0x15000000, 0x9c60002a, 0x07ffff74,
     0x15000000, 0x18600000, 0xa86313bd, 0x07ffffa9,
     0x15000000, 0x07ffffe3, 0x15000000, 0x8562fffc,
     0x85210000, 0x84410004, 0x44004800, 0x9c21000c

The static data contains 3 strings used by the main program, “Hello World!\n”, “The answer is “ and “\n”.

     // Static data
     BYTE MEMORY (0x13a0, 31)
     0x48,			// 'H'
     0x65,			// 'e'
     0x6c,			// 'l'
     0x6c,			// 'l'
     
     ... 23 more characters ...
     
     0x20,			// ' '
     0x00,			// EOS
     0x0a,			// '\n'
     0x00			// EOS

The stack frame shows the top 80 words of the stack, which is sufficient to include the stack frames of main, simputs and simputc. Any values expected to have been stored on the frame, including frame pointer links and return addresses must be initialized correctly.

     WORD MEMORY (0x7eb0, 80)
     0x00000000,
     0x00007ef4,             // Current SP, holds pointer to prev (simputs) FP
     0x00000048,             // Start of simputc frame, arg to simputc (ASCII 'H')
     0x00001358,             // End of simputs frame, holds return address (in main)
     0x00007f00,             // Holds pointer to prev (main) FP
     0x00000000,
     0x00000000,
     0x00000048,             // Argument to pass to simputc (ASCII 'H')
     0x00000000,
     0x000013a0,             // Temporary value of str
     0x000013a0,             // Temporary value of &str[i]
     0x00000048,             // str[i]
     0x00000000,
     0x000013a0,             // Value of str
     0x000013a0,             // Value of &str[i]
     0x00000000,             // Value of i
     0x000013a0,             // Start of simputs frame, arg to simputs (str)
     0x00000118,             // End of main frame, holds return address (in start)
     0x00007f00,             // Start of main frame, holds pointer to prev (start) FP
     0x00000000