public inbox for ecos-patches@sourceware.org
 help / color / mirror / Atom feed
* PowerPC - optimize system initialization
@ 2007-10-12 15:32 Gary Thomas
  0 siblings, 0 replies; only message in thread
From: Gary Thomas @ 2007-10-12 15:32 UTC (permalink / raw)
  To: eCos patches

[-- Attachment #1: Type: text/plain, Size: 278 bytes --]

... something I've thought about for a long time :-)

-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------

[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 4322 bytes --]

Index: hal/powerpc/arch/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/hal/powerpc/arch/current/ChangeLog,v
retrieving revision 1.69
diff -u -5 -p -r1.69 ChangeLog
--- hal/powerpc/arch/current/ChangeLog	18 Apr 2006 22:29:39 -0000	1.69
+++ hal/powerpc/arch/current/ChangeLog	12 Oct 2007 15:29:51 -0000
@@ -1,5 +1,9 @@
+2007-10-12  Gary Thomas  <gary@mlbassoc.com>
+
+	* src/vectors.S: Optimize system initialization of DATA/BSS/etc.
+
 2006-04-18  Gary Thomas  <gary@mlbassoc.com>
 
 	* include/hal_arch.h: Adjust stack sizes - they were too small
 	(on machines with FPU) and didn't account for stack checking.
 
Index: hal/powerpc/arch/current/src/vectors.S
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/hal/powerpc/arch/current/src/vectors.S,v
retrieving revision 1.32
diff -u -5 -p -r1.32 vectors.S
--- hal/powerpc/arch/current/src/vectors.S	8 Dec 2003 14:26:03 -0000	1.32
+++ hal/powerpc/arch/current/src/vectors.S	12 Oct 2007 15:29:08 -0000
@@ -301,14 +301,16 @@ _hal_hardware_init_done:
 
 #if !defined(CYG_HAL_STARTUP_ROM) && defined(CYGSEM_HAL_POWERPC_COPY_VECTORS)
         lwi     r3,rom_vectors-4
         lwi     r4,((CYGHWR_HAL_POWERPC_VECTOR_BASE)-4)
         lwi     r5,rom_vectors_end-4
+        sub     r5,r5,r3                # compute number of words to copy
+        srwi    r5,r5,2
+        mtctr   r5
 0:      lwzu    r0,4(r3)
         stwu    r0,4(r4)
-        cmplw   r3,r5
-        bne     0b
+        bdnz    0b
 #endif        
 
         # set up stack
         lwi     sp,__interrupt_stack
         mtspr   SPRG0,sp        # save in sprg0 for later use
@@ -316,52 +318,55 @@ _hal_hardware_init_done:
         # Set up exception handlers and VSR table, taking care not to
         # step on any ROM monitor''s toes.
         hal_mon_init        
 
 #if defined(CYG_HAL_STARTUP_ROM)
-
         # Copy data from ROM to ram
         lwi     r3,__rom_data_start     # r3 = rom start
         lwi     r4,__ram_data_start     # r4 = ram start
         lwi     r5,__ram_data_end       # r5 = ram end
 
         cmplw   r4,r5                   # skip if no data
         beq     2f
-        
-1:
-        lwz     r0,0(r3)                # get word from ROM
-        stw     r0,0(r4)                # store in RAM
-        addi    r3,r3,4                 # increment by 1 word
-        addi    r4,r4,4                 # increment by 1 word
-        cmplw   r4,r5                   # compare
-        blt     1b                      # loop if not yet done
+        sub     r5,r5,r4                # compute number of words to copy
+        srwi    r5,r5,2
+        mtctr   r5
+        subi    r3,r3,4
+        subi    r4,r4,4
+1:      lwzu    r0,4(r3)                # get word from ROM
+        stwu    r0,4(r4)                # store in RAM
+        bdnz    1b
 2:
 #endif
 
         # clear BSS
         lwi     r3,__bss_start  # r3 = start
         lwi     r4,__bss_end    # r4 = end
         li      r0,0            # r0 = 0
         cmplw   r3,r4           # skip if no bss
         beq     2f
+        sub     r4,r4,r3        # compute number of words to clear
+        srwi    r4,r4,2
+        mtctr   r4
+        subi    r3,r3,4
         
-1:      stw     r0,0(r3)        # store zero
-        addi    r3,r3,4         # increment by 1 word
-        cmplw   r3,r4           # compare
-        blt     1b              # loop if not yet done
+1:      stwu    r0,4(r3)        # store zero & increment pointer
+        bdnz    1b
 2:
 
         # clear SBSS
         lwi     r3,__sbss_start # r3 = start
         lwi     r4,__sbss_end   # r4 = end
         cmplw   r3,r4           # skip if no sbss
         beq     2f
+        sub     r4,r4,r3        # compute number of words to clear
+        srwi    r4,r4,2
+        mtctr   r4
+        subi    r3,r3,4
         
-1:      stw     r0,0(r3)        # store zero
-        addi    r3,r3,4         # increment by 1 word
-        cmplw   r3,r4           # compare
-        blt     1b              # loop if not yet done
+1:      stwu    r0,4(r3)        # store zero & increment pointer
+        bdnz    1b
 2:
 
         # It is now safe to call C functions which may rely on initialized
         # data.
         

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-10-12 15:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-12 15:32 PowerPC - optimize system initialization Gary Thomas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).