Index: c/src/lib/libbsp/powerpc/virtex/ChangeLog
===================================================================
--- c/src/lib/libbsp/powerpc/virtex/ChangeLog	(revision 0f70711148e464d5e2e09b44e6c2f82909c083e3)
+++ c/src/lib/libbsp/powerpc/virtex/ChangeLog	(revision f1359069e0d26bb1a1c299c0865d8c2a86bf2b39)
@@ -1,2 +1,10 @@
+2008-09-15	Joel Sherrill <joel.sherrill@oarcorp.com>
+
+	* Makefile.am, configure.ac, include/bsp.h, include/bspopts.h.in,
+	startup/bspstart.c, startup/linkcmds: Add use of bsp_get_work_area()
+	in its own file and rely on BSP Framework to perform more
+	initialization.
+	* startup/bspgetworkarea.c: New file.
+
 2008-09-06	Ralf CorsÃ©pius <ralf.corsepius@rtems.org>
 
Index: c/src/lib/libbsp/powerpc/virtex/Makefile.am
===================================================================
--- c/src/lib/libbsp/powerpc/virtex/Makefile.am	(revision 0f70711148e464d5e2e09b44e6c2f82909c083e3)
+++ c/src/lib/libbsp/powerpc/virtex/Makefile.am	(revision f1359069e0d26bb1a1c299c0865d8c2a86bf2b39)
@@ -33,7 +33,8 @@
 dist_project_lib_DATA += startup/linkcmds
 
-startup_SOURCES = startup/bspclean.c ../../shared/bsplibc.c \
+startup_SOURCES = startup/bspclean.c startup/bspgetworkarea.c \
+    ../../shared/bsplibc.c \
     ../../shared/bsppost.c startup/bspstart.c ../../shared/bootcard.c \
-    ../../shared/bsppredriverhook.c \
+    ../../shared/bsppredriverhook.c ../../shared/bsppretaskinghook.c \
     ../../shared/sbrk.c startup/setvec.c \
     ../../shared/gnatinstallhandler.c
Index: c/src/lib/libbsp/powerpc/virtex/configure.ac
===================================================================
--- c/src/lib/libbsp/powerpc/virtex/configure.ac	(revision 0f70711148e464d5e2e09b44e6c2f82909c083e3)
+++ c/src/lib/libbsp/powerpc/virtex/configure.ac	(revision f1359069e0d26bb1a1c299c0865d8c2a86bf2b39)
@@ -42,4 +42,6 @@
 #RSG End
 
+RTEMS_BSP_BOOTCARD_HANDLES_RAM_ALLOCATION
+
 # Explicitly list all Makefiles here
 AC_CONFIG_FILES([Makefile])
Index: c/src/lib/libbsp/powerpc/virtex/include/bsp.h
===================================================================
--- c/src/lib/libbsp/powerpc/virtex/include/bsp.h	(revision 0f70711148e464d5e2e09b44e6c2f82909c083e3)
+++ c/src/lib/libbsp/powerpc/virtex/include/bsp.h	(revision f1359069e0d26bb1a1c299c0865d8c2a86bf2b39)
@@ -63,11 +63,4 @@
 #include <bsp/vectors.h>
 
-/* Constants */
-
-extern uint32_t _HeapSize;
-extern uint32_t _heap_start;
-extern uint32_t _heap_end;
-extern uint32_t _top_of_ram;
-
 /* miscellaneous stuff assumed to exist */
 
Index: c/src/lib/libbsp/powerpc/virtex/include/bspopts.h.in
===================================================================
--- c/src/lib/libbsp/powerpc/virtex/include/bspopts.h.in	(revision 0f70711148e464d5e2e09b44e6c2f82909c083e3)
+++ c/src/lib/libbsp/powerpc/virtex/include/bspopts.h.in	(revision f1359069e0d26bb1a1c299c0865d8c2a86bf2b39)
@@ -1,3 +1,11 @@
 /* include/bspopts.h.in.  Generated from configure.ac by autoheader.  */
+
+/* BSP uses shared logic in bootcard.c */
+#undef BSP_BOOTCARD_HANDLES_RAM_ALLOCATION
+
+/* If defined, then PSIM will put a non-zero pattern into the RTEMS Workspace
+   and C program heap. This should assist in finding code that assumes memory
+   starts set to zero. */
+#undef BSP_DIRTY_MEMORY
 
 /* Define to the address where bug reports for this package should be sent. */
Index: c/src/lib/libbsp/powerpc/virtex/startup/bspgetworkarea.c
===================================================================
--- c/src/lib/libbsp/powerpc/virtex/startup/bspgetworkarea.c	(revision f1359069e0d26bb1a1c299c0865d8c2a86bf2b39)
+++ c/src/lib/libbsp/powerpc/virtex/startup/bspgetworkarea.c	(revision f1359069e0d26bb1a1c299c0865d8c2a86bf2b39)
@@ -0,0 +1,39 @@
+/*
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#include <bsp.h>
+#include <bsp/bootcard.h>
+#include <stdint.h>
+
+extern void *RamBase;
+extern void *RamSize;
+extern void *WorkSpaceStart;
+
+/*
+ *  This method returns the base address and size of the area which
+ *  is to be allocated between the RTEMS Workspace and the C Program
+ *  Heap.
+ */
+void bsp_get_work_area(
+  void   **work_area_start,
+  size_t  *work_area_size,
+  void   **heap_start,
+  size_t  *heap_size
+)
+{
+  uintptr_t size;
+
+  size = (uintptr_t)&RamBase + (uintptr_t)&RamSize
+         - (uintptr_t)&WorkSpaceStart;
+
+  *work_area_start = (void *)&WorkSpaceStart;
+  *work_area_size  = size;
+  *heap_start      = BSP_BOOTCARD_HEAP_USES_WORK_AREA;
+  *heap_size       = BSP_BOOTCARD_HEAP_SIZE_DEFAULT;
+}
+
Index: c/src/lib/libbsp/powerpc/virtex/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/powerpc/virtex/startup/bspstart.c	(revision 0f70711148e464d5e2e09b44e6c2f82909c083e3)
+++ c/src/lib/libbsp/powerpc/virtex/startup/bspstart.c	(revision f1359069e0d26bb1a1c299c0865d8c2a86bf2b39)
@@ -61,6 +61,4 @@
 
 #include <bsp.h>
-#include <rtems/libio.h>
-#include <rtems/libcsupport.h>
 #include <bsp/irq.h>
 #include <rtems/bspIo.h>
@@ -95,49 +93,7 @@
 
 void bsp_XAssertHandler(const char* file, int line);
-void bsp_libc_init( void *, uint32_t, int );
-
 
 void bsp_XAssertHandler(const char* file, int line) {
   printf("\n***\n*** XAssert Failed!  File: %s, Line: %d\n***\n", file, line);
-}
-
-/*
- *  Function:   bsp_pretasking_hook
- *  Created:    95/03/10
- *
- *  Description:
- *      BSP pretasking hook.  Called just before drivers are initialized.
- *      Used to setup libc and install any BSP extensions.
- *
- *  NOTES:
- *      Must not use libc (to do io) from here, since drivers are
- *      not yet initialized.
- *
- */
-
-void bsp_pretasking_hook(void)
-{
-
-
-    uint32_t        heap_start;
-    uint32_t  	    heap_size;
-    uint32_t  	    heap_end;
-
-    /* round up from the top of workspace to next 64k boundary, get
-     * default heapsize from linker script  */
-    heap_start = (((uint32_t)Configuration.work_space_start +
-		   rtems_configuration_get_work_space_size()) + 0x18000) & 0xffff0000;
-
-    heap_end = _heap_start + (uint32_t)&_HeapSize;
-
-    heap_size = (heap_end - heap_start);
-
-    _heap_start = heap_start;
-    _heap_end = heap_end;
-
-    _top_of_ram = heap_end;
-
-    bsp_libc_init((void *) heap_start, heap_size, 0); /* 64 * 1024 */
-
 }
 
@@ -147,6 +103,4 @@
  *  This routine does the bulk of the system initialization.
  */
-
-
 void bsp_start( void )
 {
@@ -192,31 +146,4 @@
    */
   BSP_rtems_irq_mng_init(0);
-
-  /*
-   *  Allocate the memory for the RTEMS Work Space.  This can come from
-   *  a variety of places: hard coded address, malloc'ed from outside
-   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
-   *  typically done by stock BSPs) by subtracting the required amount
-   *  of work space from the last physical address on the CPU board.
-   */
-
-  /*
-   *  Need to "allocate" the memory for the RTEMS Workspace and
-   *  tell the RTEMS configuration where it is.  This memory is
-   *  not malloc'ed.  It is just "pulled from the air".
-   */
-  /* FIME: plan usage of RAM better:
-     - make top of ram dynamic,
-     - make rest of ram to heap...
-     -remove RAM_END from bsp.h, this cannot be valid...
-      or must be a function call
-   */
-  {
-    extern int _end;
-
-    /* round _end up to next 64k boundary for start of workspace */
-    Configuration.work_space_start = (void *)((((uint32_t)&_end) + 0xffff) & 0xffff0000);
-  }
-
 }
 
Index: c/src/lib/libbsp/powerpc/virtex/startup/linkcmds
===================================================================
--- c/src/lib/libbsp/powerpc/virtex/startup/linkcmds	(revision 0f70711148e464d5e2e09b44e6c2f82909c083e3)
+++ c/src/lib/libbsp/powerpc/virtex/startup/linkcmds	(revision f1359069e0d26bb1a1c299c0865d8c2a86bf2b39)
@@ -18,12 +18,12 @@
 
 
-_HeapSize = DEFINED(_HeapSize) ? _HeapSize : 8M;
-
+RamBase = DEFINED(RamBase) ? RamBase : 0x0;
+RamSize = DEFINED(RamSize) ? RamSize : 128M;
 
 MEMORY
-  {
-        RAM : ORIGIN = 0, LENGTH = 128M
-        /*FLASH : ORIGIN = 0xFFE00000, LENGTH = 16M*/
-  }
+{
+  RAM : ORIGIN = 0, LENGTH = 128M
+  /*FLASH : ORIGIN = 0xFFE00000, LENGTH = 16M*/
+}
 SECTIONS
 {
@@ -248,4 +248,5 @@
  
     PROVIDE(_end = . );
+    WorkSpaceStart = .;
 
 
