From c0ebf023b795036f6f0d8bcf887b3af27c90e85e Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 13 Jan 2000 15:06:24 +0000 Subject: New patch from Eric Norum plus some minor mods by Joel. --- c/src/lib/libbsp/m68k/gen68360/startup/Makefile.in | 4 +- c/src/lib/libbsp/m68k/gen68360/startup/bspstart.c | 31 +------------- c/src/lib/libbsp/m68k/gen68360/startup/init68360.c | 18 ++++++-- c/src/lib/libbsp/m68k/gen68360/startup/linkcmds | 48 +++++----------------- .../libbsp/m68k/gen68360/startup/linkcmds.bootp | 2 +- .../lib/libbsp/m68k/gen68360/startup/linkcmds.prom | 2 +- 6 files changed, 31 insertions(+), 74 deletions(-) (limited to 'c/src/lib/libbsp/m68k/gen68360/startup') diff --git a/c/src/lib/libbsp/m68k/gen68360/startup/Makefile.in b/c/src/lib/libbsp/m68k/gen68360/startup/Makefile.in index 771c89f5cb..81165e4564 100644 --- a/c/src/lib/libbsp/m68k/gen68360/startup/Makefile.in +++ b/c/src/lib/libbsp/m68k/gen68360/startup/Makefile.in @@ -16,8 +16,8 @@ VPATH = @srcdir@:@srcdir@/../../shared:@srcdir@/../../../shared PGM = ${ARCH}/startup.rel # C source names, if any, go here -- minus the .c -C_PIECES = alloc360 bspclean bsplibc bsppost bspstart init68360 bootcard \ - main sbrk setvec gnatinstallhandler +C_PIECES = alloc360 bspclean bsplibc bsppost m68kpretaskinghook \ + bspstart init68360 bootcard main sbrk setvec gnatinstallhandler C_FILES = $(C_PIECES:%=%.c) C_O_FILES = $(C_PIECES:%=${ARCH}/%.o) diff --git a/c/src/lib/libbsp/m68k/gen68360/startup/bspstart.c b/c/src/lib/libbsp/m68k/gen68360/startup/bspstart.c index aa3f48bf01..9279cf6cd1 100644 --- a/c/src/lib/libbsp/m68k/gen68360/startup/bspstart.c +++ b/c/src/lib/libbsp/m68k/gen68360/startup/bspstart.c @@ -28,6 +28,7 @@ extern rtems_configuration_table Configuration; rtems_configuration_table BSP_Configuration; +unsigned long _RamSize; rtems_cpu_table Cpu_table; @@ -39,33 +40,8 @@ char *rtems_progname; void bsp_postdriver_hook(void); void bsp_libc_init( void *, unsigned32, int ); +void bsp_pretasking_hook(void); /* m68k version */ -/* - * 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 void *_HeapStart; - extern rtems_unsigned32 _HeapSize; - - bsp_libc_init(&_HeapStart, _HeapSize, 0); - -#ifdef RTEMS_DEBUG - rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); -#endif -} - /* * bsp_start * @@ -83,9 +59,6 @@ void bsp_start( void ) * typically done by stock BSPs) by subtracting the required amount * of work space from the last physical address on the CPU board. */ -#if 0 - Cpu_table.interrupt_vector_table = (mc68000_isr *) 0/*&M68Kvec*/; -#endif /* * Need to "allocate" the memory for the RTEMS Workspace and diff --git a/c/src/lib/libbsp/m68k/gen68360/startup/init68360.c b/c/src/lib/libbsp/m68k/gen68360/startup/init68360.c index 91297db5eb..8a68524766 100644 --- a/c/src/lib/libbsp/m68k/gen68360/startup/init68360.c +++ b/c/src/lib/libbsp/m68k/gen68360/startup/init68360.c @@ -42,7 +42,8 @@ void _Init68360 (void) { int i; m68k_isr_entry *vbr; - extern void _CopyDataClearBSSAndStart (void); + unsigned long ramSize; + extern void _CopyDataClearBSSAndStart (unsigned long ramSize); #if (defined (__mc68040__)) /* @@ -138,6 +139,7 @@ void _Init68360 (void) * Wait for chips to power up * Perform 8 read cycles */ + ramSize = 1 * 1024 * 1024; m360.memc[1].or = M360_MEMC_OR_TCYC(0) | M360_MEMC_OR_1MB | M360_MEMC_OR_DRAM; @@ -275,6 +277,7 @@ void _Init68360 (void) /* * Step 12: Initialize the system RAM */ + ramSize = 2 * 1024 * 1024; /* first bank 1MByte DRAM */ m360.memc[1].or = M360_MEMC_OR_TCYC(2) | M360_MEMC_OR_1MB | M360_MEMC_OR_PGME | M360_MEMC_OR_DRAM; @@ -334,7 +337,7 @@ void _Init68360 (void) * Disable timers during FREEZE * Enable bus monitor during FREEZE * BCLRO* arbitration level 3 - */ + */ #elif (defined (GEN68360_WITH_SRAM)) /* @@ -417,6 +420,7 @@ void _Init68360 (void) * 512Kx32 SRAM on CS1* * 0 wait states */ + ramSize = 1 * 1024 * 1024; m360.memc[1].br = (unsigned long)&_RamBase | M360_MEMC_BR_V; m360.memc[1].or = M360_MEMC_OR_WAITS(0) | M360_MEMC_OR_2MB | M360_MEMC_OR_32BIT; @@ -606,6 +610,12 @@ void _Init68360 (void) */ m360.memc[1].br |= M360_MEMC_BR_PAREN; } + switch (m360.gmr & 0x001C0000) { + default: ramSize = 4 * 1024 * 1024; break; + case M360_GMR_PGS(1): ramSize = 1 * 1024 * 1024; break; + case M360_GMR_PGS(3): ramSize = 4 * 1024 * 1024; break; + case M360_GMR_PGS(5): ramSize = 16 * 1024 * 1024; break; + } /* * Step 13: Copy the exception vector table to system RAM @@ -650,6 +660,8 @@ void _Init68360 (void) /* * Copy data, clear BSS, switch stacks and call main() + * Must pass ramSize as argument since the data/bss segment + * may be overwritten. */ - _CopyDataClearBSSAndStart (); + _CopyDataClearBSSAndStart (ramSize); } diff --git a/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds b/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds index c72364b9d3..39f4c8dbd3 100644 --- a/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds +++ b/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds @@ -13,9 +13,10 @@ /* * Declare some sizes. + * A heap size of 0 means `use all available memory for the heap'. */ -HeapSize = DEFINED(HeapSize) ? HeapSize : 0x10000; -StackSize = DEFINED(StackSize) ? StackSize : 0x1000; +_HeapSize = DEFINED(_HeapSize) ? _HeapSize : 0x0; +_StackSize = DEFINED(_StackSize) ? _StackSize : 0x1000; /* * Declare on-board memory. @@ -57,18 +58,6 @@ SECTIONS { /* * Initialization and finalization code. - * - * Various files can provide initialization and finalization - * functions. crtbegin.o and crtend.o are two instances. The - * body of these functions are in .init and .fini sections. We - * accumulate the bodies here, and prepend function prologues - * from crti.o and function epilogues from crtn.o. crti.o must - * be linked first; crtn.o must be linked last. Because these - * are wildcards, it doesn't matter if the user does not - * actually link against crti.o and crtn.o; the linker won't - * look for a file to match a wildcard. The wildcard also - * means that it doesn't matter which directory crti.o and - * crtn.o are in. */ PROVIDE (_init = .); *crti.o(.init) @@ -81,15 +70,6 @@ SECTIONS { /* * C++ constructors/destructors - * - * gcc uses crtbegin.o to find the start of the constructors - * and destructors so we make sure it is first. Because this - * is a wildcard, it doesn't matter if the user does not - * actually link against crtbegin.o; the linker won't look for - * a file to match a wildcard. The wildcard also means that - * it doesn't matter which directory crtbegin.o is in. The - * constructor and destructor list are terminated in - * crtend.o. The same comments apply to it. */ . = ALIGN (16); *crtbegin.o(.ctors) @@ -117,33 +97,27 @@ SECTIONS { PROVIDE (etext = .); } >ram .data : { - copy_start = .; + _copy_start = .; *(.data) *(.gnu.linkonce.d*) *(.gcc_except_table) . = ALIGN (16); - PROVIDE (_edata = .); - copy_end = .; + PROVIDE (edata = .); + _copy_end = .; } >ram .bss : { M68Kvec = .; - _M68Kvec = .; . += (256 * 4); - clear_start = .; + _clear_start = .; *(.bss) *(COMMON) . = ALIGN (16); PROVIDE (end = .); - . += StackSize; - PROVIDE (_stack_init = .); - + . += _StackSize; . = ALIGN (16); - PROVIDE (_HeapStart = .); - . += HeapSize; - PROVIDE (_HeapEnd = .); - - PROVIDE (_clear_end = .); + _stack_init = .; + _clear_end = .; _WorkspaceBase = .; } >ram @@ -153,8 +127,6 @@ SECTIONS { */ dpram : { m360 = .; - _m360 = .; . += (8 * 1024); - } >dpram } diff --git a/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds.bootp b/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds.bootp index 6661fc2c2a..ff49004bc7 100644 --- a/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds.bootp +++ b/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds.bootp @@ -117,7 +117,7 @@ SECTIONS { *(.bss) *(COMMON) . = ALIGN (16); - PROVIDE (end = .); + _end = .; _HeapStart = .; . += HeapSize; diff --git a/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds.prom b/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds.prom index 522bea54ca..0903e00e4a 100644 --- a/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds.prom +++ b/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds.prom @@ -116,7 +116,7 @@ SECTIONS { *(.bss) *(COMMON) . = ALIGN (16); - PROVIDE (end = .); + _end = .; _HeapStart = .; . += HeapSize; -- cgit v1.2.3