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

4.104.114.84.95
Last change on this file since e8c785c6 was e8c785c6, checked in by Jay Monkman <jtm@…>, on Mar 11, 2005 at 7:27:56 AM

2005-03-11 Philippe Simons <loki_666@…>

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