source: rtems/c/src/lib/libbsp/arm/gp32/startup/bspstart.c @ 34c4852

4.104.114.84.95
Last change on this file since 34c4852 was 17a5e1d8, checked in by Joel Sherrill <joel.sherrill@…>, on 04/26/05 at 23:02:05

2005-04-26 Joel Sherrill <joel@…>

  • startup/bspstart.c: Add include rtems/bspIo.h to eliminate warning.
  • Property mode set to 100644
File size: 6.4 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
23/*-------------------------------------------------------------------------+
24| Global Variables
25+--------------------------------------------------------------------------*/
26
27extern void            *_sdram_size;
28extern void            *_sdram_base;
29extern void            *_bss_free_start;
30
31unsigned long           free_mem_start;
32unsigned long           free_mem_end;
33
34/* The original BSP configuration table from the application and our copy of it
35   with some changes. */
36
37extern rtems_configuration_table  Configuration;
38       rtems_configuration_table  BSP_Configuration;
39
40rtems_cpu_table Cpu_table;                     /* CPU configuration table.    */
41char            *rtems_progname = "RTEMS";               /* Program name - from main(). */
42
43/*-------------------------------------------------------------------------+
44| External Prototypes
45+--------------------------------------------------------------------------*/
46extern void rtems_irq_mngt_init(void);
47void bsp_libc_init( void *, uint32_t, int );
48void bsp_postdriver_hook(void);
49
50/*-------------------------------------------------------------------------+
51|         Function: bsp_pretasking_hook
52|      Description: BSP pretasking hook.  Called just before drivers are
53|                   initialized. Used to setup libc and install any BSP
54|                   extensions. NOTE: Must not use libc (to do io) from here,
55|                   since drivers are not yet initialized.
56| Global Variables: None.
57|        Arguments: None.
58|          Returns: Nothing.
59+--------------------------------------------------------------------------*/
60void bsp_pretasking_hook(void)
61{
62    uint32_t heap_start;
63    uint32_t heap_size;
64
65    /*
66     * Set up the heap.
67     */
68    heap_start =  free_mem_start;
69    heap_size = free_mem_end - free_mem_start;
70
71    /* call rtems lib init - malloc stuff */
72    bsp_libc_init((void *)heap_start, heap_size, 0);
73
74#ifdef RTEMS_DEBUG
75
76    rtems_debug_enable(RTEMS_DEBUG_ALL_MASK);
77
78#endif /* RTEMS_DEBUG */
79
80} /* bsp_pretasking_hook */
81 
82/*-------------------------------------------------------------------------+
83|         Function: bsp_start
84|      Description: Called before main is invoked.
85| Global Variables: None.
86|        Arguments: None.
87|          Returns: Nothing.
88+--------------------------------------------------------------------------*/
89void bsp_start_default( void )
90{
91    uint32_t cr;
92    /* If we don't have command line arguments set default program name. */
93
94    Cpu_table.pretasking_hook      = bsp_pretasking_hook; /* init libc, etc. */
95    Cpu_table.predriver_hook       = NULL;                /* use system's    */
96    Cpu_table.postdriver_hook      = bsp_postdriver_hook;
97    Cpu_table.idle_task            = NULL;
98                                         
99    Cpu_table.do_zero_of_workspace = TRUE;
100    Cpu_table.interrupt_stack_size = 4096;
101    Cpu_table.extra_mpci_receive_server_stack = 0;
102
103    /* stop all timers */
104    rTCON=0x0;
105
106    /* disable interrupts */
107    rINTMOD=0x0;
108    rINTMSK=BIT_ALLMSK; /* unmasked by drivers */
109    rSRCPND=BIT_ALLMSK;
110    rINTMSK=BIT_ALLMSK;
111    rINTPND=BIT_ALLMSK;
112
113    /* setup clocks 133/66/33) */
114    rCLKDIVN=3;
115    rMPLLCON=((M_MDIV<<12)+(M_PDIV<<4)+M_SDIV);
116
117    /* set prescaler for timers 2,3,4 to 16(15+1) */
118    cr=rTCFG0 & 0xFFFF00FF;
119    rTCFG0=(cr | (15<<8));
120
121    /* set prescaler for timers 0,1 to 1(0+1) */
122    cr=rTCFG0 & 0xFFFFFF00;
123    rTCFG0=(cr | (0<<0));
124
125    /* Place RTEMS workspace at beginning of free memory. */
126    BSP_Configuration.work_space_start = (void *)&_bss_free_start;
127
128    free_mem_start = ((uint32_t)&_bss_free_start + BSP_Configuration.work_space_size);
129   
130    free_mem_end = ((uint32_t)&_sdram_base + (uint32_t)&_sdram_size);
131
132    /*
133     * Init rtems exceptions management
134     */
135    rtems_exception_init_mngt();
136
137    /*
138     * Init rtems interrupt management
139     */
140    rtems_irq_mngt_init();
141    /*
142     *  The following information is very useful when debugging.
143     */
144
145#if 0
146    printk( "work_space_size = 0x%x\n", BSP_Configuration.work_space_size );
147    printk( "maximum_extensions = 0x%x\n", BSP_Configuration.maximum_extensions );
148    printk( "microseconds_per_tick = 0x%x\n",
149            BSP_Configuration.microseconds_per_tick );
150    printk( "ticks_per_timeslice = 0x%x\n",
151            BSP_Configuration.ticks_per_timeslice );
152    printk( "maximum_devices = 0x%x\n", BSP_Configuration.maximum_devices );
153    printk( "number_of_device_drivers = 0x%x\n",
154            BSP_Configuration.number_of_device_drivers );
155    printk( "Device_driver_table = 0x%x\n",
156            BSP_Configuration.Device_driver_table );
157   
158    printk( "_heap_size = 0x%x\n", _heap_size );
159    /*  printk( "_stack_size = 0x%x\n", _stack_size );*/
160    printk( "rtemsFreeMemStart = 0x%x\n", rtemsFreeMemStart );
161    printk( "work_space_start = 0x%x\n", BSP_Configuration.work_space_start );
162    printk( "work_space_size = 0x%x\n", BSP_Configuration.work_space_size );
163#endif
164
165}
166
167/*
168 *  By making this a weak alias for bsp_start_default, a brave soul
169 *  can override the actual bsp_start routine used.
170 */
171
172void bsp_start (void) __attribute__ ((weak, alias("bsp_start_default")));
173
174void bsp_reset(void)
175{
176    rtems_interrupt_level level;
177    _CPU_ISR_Disable(level);
178    printk("bsp_reset.....\n");
179    while(1);
180}
181
182void LCD_BREAK()
183{
184    int x,y;
185    unsigned short color=0;
186    volatile unsigned char* framebuffer = (unsigned char*) 0x0C7B4000;
187    while(1) {
188        for(y = 0; y < 240; y++) {
189            for(x = 0; x < 320; x++) {
190                *(framebuffer + (239 - y) + (240 * x)) = color;
191            }
192        }
193        color++;
194    }
195}
196
Note: See TracBrowser for help on using the repository browser.