source: rtems/c/src/lib/libbsp/arm/gp32/startup/bspstart.c @ 32cf23b1

4.104.114.84.95
Last change on this file since 32cf23b1 was 32cf23b1, checked in by Joel Sherrill <joel.sherrill@…>, on 06/02/05 at 13:41:35

2005-06-01 Philippe Simons <loki_666@…>

  • bsp_specs: Add rules for cpp support
  • include/bsp.h: Add gp32 support fct prototypes
  • console/conio.c: Moved video buffer to 0x0c7ed000
  • startup/bspstart.c: Add some init code, some cleaning...
  • Property mode set to 100644
File size: 6.6 KB
Line 
1/*-------------------------------------------------------------------------+
2| This file contains the ARM BSP startup package. It includes application,
3| board, and monitor specific initialization and configuration. The generic CPU
4| dependent initialization has been performed before this routine is invoked.
5+--------------------------------------------------------------------------+
6|
7| Copyright (c) 2000 Canon Research Centre France SA.
8| Emmanuel Raguet, mailto:raguet@crf.canon.fr
9|
10|   The license and distribution terms for this file may be
11|   found in found in the file LICENSE in this distribution or at
12|   http://www.rtems.com/license/LICENSE.
13|
14+--------------------------------------------------------------------------*/
15
16
17#include <bsp.h>
18#include <rtems/libcsupport.h>
19#include <rtems/libio.h>
20#include <rtems/bspIo.h>
21#include <s3c2400.h>
22#include <conio.h>
23
24/*-------------------------------------------------------------------------+
25| Global Variables
26+--------------------------------------------------------------------------*/
27
28extern void            *_sdram_size;
29extern void            *_sdram_base;
30extern void            *_bss_free_start;
31
32unsigned long           free_mem_start;
33unsigned long           free_mem_end;
34
35/* The original BSP configuration table from the application and our copy of it
36   with some changes. */
37
38extern rtems_configuration_table  Configuration;
39       rtems_configuration_table  BSP_Configuration;
40
41rtems_cpu_table Cpu_table;                     /* CPU configuration table.    */
42char            *rtems_progname = "RTEMS";               /* Program name - from main(). */
43
44/*-------------------------------------------------------------------------+
45| External Prototypes
46+--------------------------------------------------------------------------*/
47extern void rtems_irq_mngt_init(void);
48void bsp_libc_init( void *, uint32_t, int );
49void bsp_postdriver_hook(void);
50
51/*-------------------------------------------------------------------------+
52|         Function: bsp_pretasking_hook
53|      Description: BSP pretasking hook.  Called just before drivers are
54|                   initialized. Used to setup libc and install any BSP
55|                   extensions. NOTE: Must not use libc (to do io) from here,
56|                   since drivers are not yet initialized.
57| Global Variables: None.
58|        Arguments: None.
59|          Returns: Nothing.
60+--------------------------------------------------------------------------*/
61void bsp_pretasking_hook(void)
62{
63    uint32_t heap_start;
64    uint32_t heap_size;
65
66    /*
67     * Set up the heap.
68     */
69    heap_start =  free_mem_start;
70    heap_size = free_mem_end - free_mem_start;
71
72    /* call rtems lib init - malloc stuff */
73    bsp_libc_init((void *)heap_start, heap_size, 0);
74
75#ifdef RTEMS_DEBUG
76
77    rtems_debug_enable(RTEMS_DEBUG_ALL_MASK);
78
79#endif /* RTEMS_DEBUG */
80
81} /* bsp_pretasking_hook */
82 
83/*-------------------------------------------------------------------------+
84|         Function: bsp_start
85|      Description: Called before main is invoked.
86| Global Variables: None.
87|        Arguments: None.
88|          Returns: Nothing.
89+--------------------------------------------------------------------------*/
90void bsp_start_default( void )
91{
92    uint32_t cr;
93    uint32_t pend,last;
94    uint32_t REFCNT;
95    int i;
96    /* If we don't have command line arguments set default program name. */
97
98    Cpu_table.pretasking_hook      = bsp_pretasking_hook; /* init libc, etc. */
99    Cpu_table.predriver_hook       = NULL;                /* use system's    */
100    Cpu_table.postdriver_hook      = bsp_postdriver_hook;
101    Cpu_table.idle_task            = NULL;
102                                         
103    Cpu_table.do_zero_of_workspace = TRUE;
104    Cpu_table.interrupt_stack_size = 4096;
105    Cpu_table.extra_mpci_receive_server_stack = 0;
106
107    /* setup rCLKCON */
108    /* disable all but IIS,IIC,PWMTIMER and LCD */
109    rCLKCON=0x6048;
110
111    /* stop RTC */
112    rTICINT=0x0;
113
114    /* stop watchdog,ADC and timers */
115    rWTCON=0x0;
116    rTCON=0x0;
117    rADCCON=0x0;
118
119    /* disable interrupts */
120    rINTMOD=0x0;
121    rINTMSK=BIT_ALLMSK; /* unmasked by drivers */
122    /*rSRCPND=BIT_ALLMSK;
123    rINTMSK=BIT_ALLMSK;
124    rINTPND=BIT_ALLMSK;*/
125    for(i=0; i<4; i++) {
126        pend=rSRCPND;
127        if(pend == 0 || pend == last)
128            break;
129        rSRCPND=pend;
130        rINTPND=pend;
131        last=pend;
132    }
133
134    /* setup clocks */
135    rCLKDIVN=M_CLKDIVN;
136    rMPLLCON=((M_MDIV<<12)+(M_PDIV<<4)+M_SDIV);
137    /* setup rREFRESH */
138    REFCNT=2048+1-(15.6*get_HCLK()/1000000); /* period=15.6 us, HCLK=66Mhz, (2048+1-15.6*66) */
139    rREFRESH=((REFEN<<23)+(TREFMD<<22)+(Trp<<20)+(Trc<<18)+(Tchr<<16)+REFCNT);
140
141    /* set prescaler for timers 2,3,4 to 16(15+1) */
142    cr=rTCFG0 & 0xFFFF00FF;
143    rTCFG0=(cr | (15<<8));
144
145    /* set prescaler for timers 0,1 to 1(0+1) */
146    cr=rTCFG0 & 0xFFFFFF00;
147    rTCFG0=(cr | (0<<0));
148
149    /* Place RTEMS workspace at beginning of free memory. */
150    BSP_Configuration.work_space_start = (void *)&_bss_free_start;
151
152    free_mem_start = ((uint32_t)&_bss_free_start + BSP_Configuration.work_space_size);
153   
154    free_mem_end = ((uint32_t)&_sdram_base + (uint32_t)&_sdram_size);
155
156    /*
157     * Init rtems exceptions management
158     */
159    rtems_exception_init_mngt();
160
161    /*
162     * Init rtems interrupt management
163     */
164    rtems_irq_mngt_init();
165    /*
166     *  The following information is very useful when debugging.
167     */
168
169#if 0
170    printk( "work_space_size = 0x%x\n", BSP_Configuration.work_space_size );
171    printk( "maximum_extensions = 0x%x\n", BSP_Configuration.maximum_extensions );
172    printk( "microseconds_per_tick = 0x%x\n",
173            BSP_Configuration.microseconds_per_tick );
174    printk( "ticks_per_timeslice = 0x%x\n",
175            BSP_Configuration.ticks_per_timeslice );
176    printk( "maximum_devices = 0x%x\n", BSP_Configuration.maximum_devices );
177    printk( "number_of_device_drivers = 0x%x\n",
178            BSP_Configuration.number_of_device_drivers );
179    printk( "Device_driver_table = 0x%x\n",
180            BSP_Configuration.Device_driver_table );
181   
182    printk( "_heap_size = 0x%x\n", _heap_size );
183    /*  printk( "_stack_size = 0x%x\n", _stack_size );*/
184    printk( "rtemsFreeMemStart = 0x%x\n", rtemsFreeMemStart );
185    printk( "work_space_start = 0x%x\n", BSP_Configuration.work_space_start );
186    printk( "work_space_size = 0x%x\n", BSP_Configuration.work_space_size );
187#endif
188
189}
190
191/*
192 *  By making this a weak alias for bsp_start_default, a brave soul
193 *  can override the actual bsp_start routine used.
194 */
195
196void bsp_start (void) __attribute__ ((weak, alias("bsp_start_default")));
197
198void bsp_reset(void)
199{
200    rtems_interrupt_level level;
201    _CPU_ISR_Disable(level);
202    printk("bsp_reset.....\n");
203    ShowConIO();
204    while(1);
205}
Note: See TracBrowser for help on using the repository browser.