Index: c/src/lib/libbsp/mips/genmongoosev/ChangeLog
===================================================================
--- c/src/lib/libbsp/mips/genmongoosev/ChangeLog	(revision 25e4d24f125bf018e5f84b6a105487836b2b5cdc)
+++ c/src/lib/libbsp/mips/genmongoosev/ChangeLog	(revision 58eee41c115f4b46859a0816f41e1ca35757762e)
@@ -1,2 +1,9 @@
+2008-09-14	Joel Sherrill <joel.sherrill@oarcorp.com>
+
+	* Makefile.am, configure.ac, startup/bspstart.c, startup/linkcmds:
+	Split out bsp_get_work_area() into its own file and user BSP
+	Framework to perform more initialization.
+	* startup/bspgetworkarea.c: New file.
+
 2008-09-10	Joel Sherrill <joel.sherrill@oarcorp.com>
 
Index: c/src/lib/libbsp/mips/genmongoosev/Makefile.am
===================================================================
--- c/src/lib/libbsp/mips/genmongoosev/Makefile.am	(revision 25e4d24f125bf018e5f84b6a105487836b2b5cdc)
+++ c/src/lib/libbsp/mips/genmongoosev/Makefile.am	(revision 58eee41c115f4b46859a0816f41e1ca35757762e)
@@ -27,9 +27,9 @@
 dist_project_lib_DATA += startup/linkcmds
 
-startup_SOURCES = ../../shared/bspclean.c \
+startup_SOURCES = ../../shared/bspclean.c ../../shared/bsppretaskinghook.c \
     ../../shared/bsppredriverhook.c ../../shared/bsplibc.c \
     ../../shared/bsppost.c startup/bspstart.c ../../shared/bootcard.c \
     ../../shared/sbrk.c ../../shared/gnatinstallhandler.c \
-    ../../shared/setvec.c
+    ../../shared/setvec.c startup/bspgetworkarea.c
 clock_SOURCES = clock/clockdrv.c
 console_SOURCES = console/conscfg.c ../../shared/console.c
Index: c/src/lib/libbsp/mips/genmongoosev/configure.ac
===================================================================
--- c/src/lib/libbsp/mips/genmongoosev/configure.ac	(revision 25e4d24f125bf018e5f84b6a105487836b2b5cdc)
+++ c/src/lib/libbsp/mips/genmongoosev/configure.ac	(revision 58eee41c115f4b46859a0816f41e1ca35757762e)
@@ -17,4 +17,6 @@
 RTEMS_PROG_CCAS
 
+RTEMS_BSP_BOOTCARD_HANDLES_RAM_ALLOCATION
+
 # Explicitly list all Makefiles here
 AC_CONFIG_FILES([Makefile])
Index: c/src/lib/libbsp/mips/genmongoosev/startup/bspgetworkarea.c
===================================================================
--- c/src/lib/libbsp/mips/genmongoosev/startup/bspgetworkarea.c	(revision 58eee41c115f4b46859a0816f41e1ca35757762e)
+++ c/src/lib/libbsp/mips/genmongoosev/startup/bspgetworkarea.c	(revision 58eee41c115f4b46859a0816f41e1ca35757762e)
@@ -0,0 +1,43 @@
+/*
+ *  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 *WorkspaceBase;
+extern void *_RamBase;
+extern void *_RamSize;
+
+/*
+ *  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;
+
+  /*
+   *  Old code had hard-coded heap size of 0x20000 and a comment indicating
+   *  something about the undefined symbol MEM_NOCACHE_SIZE.  
+   */
+  size = (uintptr_t)&_RamBase + (uintptr_t)&_RamSize
+         - (uintptr_t)&WorkspaceBase;
+
+  *work_area_start = (void *)&WorkspaceBase;
+  *work_area_size  = size;
+  *heap_start      = BSP_BOOTCARD_HEAP_USES_WORK_AREA;
+  *heap_size       = BSP_BOOTCARD_HEAP_SIZE_DEFAULT;
+}
+
Index: c/src/lib/libbsp/mips/genmongoosev/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/mips/genmongoosev/startup/bspstart.c	(revision 25e4d24f125bf018e5f84b6a105487836b2b5cdc)
+++ c/src/lib/libbsp/mips/genmongoosev/startup/bspstart.c	(revision 58eee41c115f4b46859a0816f41e1ca35757762e)
@@ -26,33 +26,7 @@
 #include <libcpu/mongoose-v.h>
 
-/*
- *  Use the shared implementations of the following routines
- */
-
-void bsp_libc_init( void *, uint32_t, int );
-
-/*
- *  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)
-{
-    extern int HeapBase;
-    extern int HeapSize;
-    void         *heapStart = &HeapBase;
-    unsigned long heapSize = (unsigned long)&HeapSize;
-
-    bsp_libc_init(heapStart, (uint32_t) heapSize, 0);
-}
+extern void _sys_exit(int);
+extern void mips_install_isr_entries(void);
+extern void mips_gdb_stub_install(void);
 
 /*
@@ -61,62 +35,55 @@
  *  This routine does the bulk of the system initialization.
  */
-
 void bsp_start( void )
 {
-   extern void _sys_exit(int);
-   extern int WorkspaceBase;
-   extern void mips_install_isr_entries(void);
-   extern void mips_gdb_stub_install(void);
+ /* mask off any interrupts */
+ MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_FUNCTION_INTERRUPT_MASK_REGISTER, 0 );
 
-   /* HACK -- tied to value linkcmds */
-   if ( rtems_configuration_get_work_space_size() > (4096*1024) )
-      _sys_exit( 1 );
+ /* reset the config register & clear any pending peripheral interrupts */
+ MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_COMMAND_REGISTER, 0 );
+ MONGOOSEV_WRITE(
+   MONGOOSEV_PERIPHERAL_COMMAND_REGISTER, MONGOOSEV_UART_CMD_RESET_BOTH_PORTS );
+ MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_COMMAND_REGISTER, 0 );
 
-   Configuration.work_space_start = (void *) &WorkspaceBase;
+ /* reset both timers */
+ MONGOOSEV_WRITE_REGISTER(
+   MONGOOSEV_TIMER1_BASE, MONGOOSEV_TIMER_INITIAL_COUNTER_REGISTER, 0xffffffff);
+ MONGOOSEV_WRITE_REGISTER(
+   MONGOOSEV_TIMER1_BASE, MONGOOSEV_TIMER_CONTROL_REGISTER, 0);
 
-   /* mask off any interrupts */
-   MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_FUNCTION_INTERRUPT_MASK_REGISTER, 0 );
+ MONGOOSEV_WRITE_REGISTER(
+   MONGOOSEV_TIMER2_BASE, MONGOOSEV_TIMER_INITIAL_COUNTER_REGISTER, 0xffffffff);
+ MONGOOSEV_WRITE_REGISTER(
+   MONGOOSEV_TIMER2_BASE, MONGOOSEV_TIMER_CONTROL_REGISTER, 0);
 
-   /* reset the config register & clear any pending peripheral interrupts */
-   MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_COMMAND_REGISTER, 0 );
-   MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_COMMAND_REGISTER, MONGOOSEV_UART_CMD_RESET_BOTH_PORTS );
-   MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_COMMAND_REGISTER, 0 );
+ /* clear any pending interrupts */
+ MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_STATUS_REGISTER, 0xffffffff );
 
-   /* reset both timers */
-   MONGOOSEV_WRITE_REGISTER( MONGOOSEV_TIMER1_BASE, MONGOOSEV_TIMER_INITIAL_COUNTER_REGISTER, 0xffffffff );
-   MONGOOSEV_WRITE_REGISTER( MONGOOSEV_TIMER1_BASE, MONGOOSEV_TIMER_CONTROL_REGISTER, 0);
+ /* clear any writable bits in the cause register */
+ mips_set_cause( 0 );
 
-   MONGOOSEV_WRITE_REGISTER( MONGOOSEV_TIMER2_BASE, MONGOOSEV_TIMER_INITIAL_COUNTER_REGISTER, 0xffffffff );
-   MONGOOSEV_WRITE_REGISTER( MONGOOSEV_TIMER2_BASE, MONGOOSEV_TIMER_CONTROL_REGISTER, 0);
+ /* set interrupt mask, but globally off. */
 
-   /* clear any pending interrupts */
-   MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_STATUS_REGISTER, 0xffffffff );
+ /*
+  *  Bit 15 | Bit 14 | Bit 13 | Bit 12 | Bit 11 | Bit 10 | Bit  9 | Bit  8 |
+  *  periph | unused |  FPU   | unused | timer2 | timer1 | swint1 | swint2 |
+  *  extern |        |        |        |        |        |        |        |
+  *
+  *    1        0        1        0        0        1        0        0
+  *
+  *    0x8C00   Enable only internal Mongoose V timers.
+  *    0xA400   Enable Peripherial ints, FPU and timer1
+  *    0x0400   Timer1 only
+  */
 
-   /* clear any writable bits in the cause register */
-   mips_set_cause( 0 );
+  /* mips_set_sr( (SR_CU0 | SR_CU1 | 0xA400) ); */
 
-   /* set interrupt mask, but globally off. */
+  /* to start up, only enable coprocessor 0 & timer int. per-task
+   * processor settings will be applied as they are created, this
+   * is just to configure the processor for startup
+   */
+  mips_set_sr( (SR_CU0 | 0x400) );
 
-   /*
-   **  Bit 15 | Bit 14 | Bit 13 | Bit 12 | Bit 11 | Bit 10 | Bit  9 | Bit  8 |
-   **  periph | unused |  FPU   | unused | timer2 | timer1 | swint1 | swint2 |
-   **  extern |        |        |        |        |        |        |        |
-   **
-   **    1        0        1        0        0        1        0        0
-   **
-   **    0x8C00   Enable only internal Mongoose V timers.
-   **    0xA400   Enable Peripherial ints, FPU and timer1
-   **    0x0400   Timer1 only
-   */
-
-   /* mips_set_sr( (SR_CU0 | SR_CU1 | 0xA400) ); */
-
-   /* to start up, only enable coprocessor 0 & timer int. per-task
-   ** processor settings will be applied as they are created, this
-   ** is just to configure the processor for startup
-   */
-   mips_set_sr( (SR_CU0 | 0x400) );
-
-   mips_install_isr_entries();
+  mips_install_isr_entries();
 }
 
@@ -129,24 +96,2 @@
    promCopyDcacheFlush();
 }
-
-#if 0
-
-/* Structure filled in by get_mem_info. */
-
-struct s_mem
-{
-  unsigned int size;
-  unsigned int icsize;
-  unsigned int dcsize;
-};
-
-extern uint32_t   _RamSize;
-
-void get_mem_info ( struct s_mem *mem )
-{
-   mem->size = (uint32_t)&_RamSize;
-   mem->icsize = MONGOOSEV_IC_SIZE;
-   mem->dcsize = MONGOOSEV_DC_SIZE;
-}
-
-#endif
Index: c/src/lib/libbsp/mips/genmongoosev/startup/linkcmds
===================================================================
--- c/src/lib/libbsp/mips/genmongoosev/startup/linkcmds	(revision 25e4d24f125bf018e5f84b6a105487836b2b5cdc)
+++ c/src/lib/libbsp/mips/genmongoosev/startup/linkcmds	(revision 58eee41c115f4b46859a0816f41e1ca35757762e)
@@ -14,5 +14,4 @@
 _RamBase = DEFINED(_RamBase) ? _RamBase : 0x80000000;
 _RamSize = DEFINED(_RamSize) ? _RamSize : 32M;
-HeapSize = DEFINED(HeapSize) ? HeapSize : 0x40000;
 _StackSize = DEFINED(_StackSize) ? _StackSize : 0x4000;
 ClockRate = DEFINED(ClockRate) ? ClockRate : 12000000;
@@ -171,6 +170,4 @@
     _stack_init = .;
     _clear_end = .;
-    HeapBase = .;
-    . += HeapSize;    /* reserve some memory for heap */
     WorkspaceBase = .;
     end = .;
