summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/m68k/shared/m68kpretaskinghook.c
blob: 3856d8a3c04e4e9b96166ca60bb8d9ee2b7d3fcb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*  
 *  This routine is an implementation of the bsp_pretasking_hook
 *  that can be used by all m68k BSPs following linkcmds conventions
 *  regarding heap, stack, and workspace allocation.
 *
 *  COPYRIGHT (c) 1989-1999.
 *  On-Line Applications Research Corporation (OAR).
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.OARcorp.com/rtems/license.html.
 *
 *  $Id$
 */

#include <rtems.h>
#include <bsp.h>
#include <libcsupport.h>

/*
 *  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.
 *
 */

extern void bsp_libc_init( void *, unsigned long, int );
extern rtems_configuration_table  BSP_Configuration;

extern void          *_RamBase;
extern void          *_WorkspaceBase;
extern void          *_HeapSize;


unsigned long  _M68k_Ramsize;

void bsp_pretasking_hook(void)
{
    void         *heapStart;
    unsigned long heapSize = (unsigned long)&_HeapSize;
    unsigned long ramSpace;

    heapStart =  (void *)
       ((unsigned long)&_WorkspaceBase + BSP_Configuration.work_space_size);
    ramSpace = (unsigned long) &_RamBase + _M68k_Ramsize - (unsigned long) heapStart;

    if (heapSize == 0)
        heapSize = ramSpace;
    else if (heapSize > ramSpace)
        rtems_fatal_error_occurred (('H'<<24) | ('E'<<16) | ('A'<<8) | 'P');

    bsp_libc_init(heapStart, heapSize, 0);

#ifdef RTEMS_DEBUG
    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
#endif

}