]> git.sur5r.net Git - u-boot/blob - lib_microblaze/board.c
* Patch by Dan Malek, 07 Apr 2004:
[u-boot] / lib_microblaze / board.c
1 /*
2  * (C) Copyright 2004 Atmark Techno, Inc.
3  *
4  * Yasushi SHOJI <yashi@atmark-techno.com>
5  *
6  * See file CREDITS for list of people who contributed to this
7  * project.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of
12  * the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22  * MA 02111-1307 USA
23  */
24
25 #include <common.h>
26 #include <command.h>
27 #include <malloc.h>
28 #include <version.h>
29 #include <watchdog.h>
30
31 const char version_string[] =
32         U_BOOT_VERSION" (" __DATE__ " - " __TIME__ ")";
33
34 /*
35  * Begin and End of memory area for malloc(), and current "brk"
36  */
37 static ulong mem_malloc_start;
38 static ulong mem_malloc_end;
39 static ulong mem_malloc_brk;
40
41
42 void *sbrk (ptrdiff_t increment)
43 {
44         ulong old = mem_malloc_brk;
45         ulong new = old + increment;
46
47         if ((new < mem_malloc_start) || (new > mem_malloc_end)) {
48                 return (NULL);
49         }
50         mem_malloc_brk = new;
51         return ((void *) old);
52 }
53
54 /*
55  * All attempts to come up with a "common" initialization sequence
56  * that works for all boards and architectures failed: some of the
57  * requirements are just _too_ different. To get rid of the resulting
58  * mess of board dependend #ifdef'ed code we now make the whole
59  * initialization sequence configurable to the user.
60  *
61  * The requirements for any new initalization function is simple: it
62  * receives a pointer to the "global data" structure as it's only
63  * argument, and returns an integer return code, where 0 means
64  * "continue" and != 0 means "fatal error, hang the system".
65  */
66 typedef int (init_fnc_t) (void);
67
68 init_fnc_t *init_sequence[] = {
69         serial_init,            /* serial communications setup */
70         NULL,
71 };
72
73 void board_init(void)
74 {
75         init_fnc_t **init_fnc_ptr;
76
77         for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
78                 WATCHDOG_RESET ();
79                 if ((*init_fnc_ptr) () != 0) {
80                         hang ();
81                 }
82         }
83
84         /* main_loop */
85         for (;;) {
86                 WATCHDOG_RESET ();
87                 main_loop ();
88         }
89 }
90
91 void hang (void)
92 {
93         puts ("### ERROR ### Please RESET the board ###\n");
94         for (;;);
95 }