Created
          March 19, 2012 16:31 
        
      - 
      
- 
        Save davestevens/2118282 to your computer and use it in GitHub Desktop. 
    Set stack pointers for each cpu in leon3mp
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | !! Instructions for adding assembly code for leon3mp to setup stack pointers for each available CPU. | |
| !! Running sparc-elf-gcc includes some system files in the final elf file, but editing these it is possible to set the stack pointer for each CPU before main is entered. | |
| !! Edit the file sparc-elf-*.*.*/src/libgloss/sparc_leon/crt0.s | |
| !! Add in the following assembly beneath the _start: label | |
| ! added code for setting stack pointer for each cpu | |
| rd %asr17, %g5 ! load in configuration reg into g5 | |
| srl %g5, 28, %g5 ! shift so only cpuid is seen | |
| sethi %hi(-1048576), %g1 ! set the value -1MiB into register g1 | |
| smul %g5, %g1, %g1 ! multiply cpuid with required stack size | |
| save %sp, %g1, %sp ! offset stack pointer by (cpuid * -1MebiByte) | |
| ! /added code for setting stack pointer for each cpu | |
| !! This file can then be assembled: | |
| !! ./sparc-elf-*.*.*/bin/../lib/gcc/sparc-elf/*.*.*/../../../../sparc-elf/bin/as -v -V -Qy -s -o crt0.o crt0.S | |
| !! And copied into the library directory: (probably best to make a copy of the crt0.o file before hand) | |
| !! sparc-elf-*.*.*/spark-elf/lib/ | |
| !! Now when compiling with sparc-elf-gcc this object file is included and each CPU is given a 1MebiByte stack. | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment