1 /*
2 * Creation Date: <2004/08/28 18:38:22 greg>
3 * Time-stamp: <2004/08/28 18:38:22 greg>
4 *
5 * <init.c>
6 *
7 * Initialization for briq
8 *
9 * Copyright (C) 2004 Greg Watson
10 *
11 * based on mol/init.c:
12 *
13 * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Samuel & David Rydh
14 * (samuel@ibrium.se, dary@lindesign.se)
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation
19 *
20 */
21
22 #include "config.h"
23 #include "libopenbios/openbios.h"
24 #include "libopenbios/bindings.h"
25 #include "arch/common/nvram.h"
26 #include "briq/briq.h"
27 #include "libopenbios/ofmem.h"
28 #include "openbios-version.h"
29
30 extern void unexpected_excep( int vector );
31 extern void setup_timers( void );
32
33 #if 0
34 int
35 get_bool_res( const char *res )
36 {
37 char buf[8], *p;
38
39 p = BootHGetStrRes( res, buf, sizeof(buf) );
40 if( !p )
41 return -1;
42 if( !strcasecmp(p,"true") || !strcasecmp(p,"yes") || !strcasecmp(p,"1") )
43 return 1;
44 return 0;
45 }
46 #endif
47
48 void
unexpected_excep(int vector)49 unexpected_excep( int vector )
50 {
51 printk("briQ panic: Unexpected exception %x\n", vector );
52 for( ;; )
53 ;
54 }
55
56 unsigned long isa_io_base;
57
58 void
entry(void)59 entry( void )
60 {
61 isa_io_base = 0x80000000;
62
63 printk("\n");
64 printk("=============================================================\n");
65 printk(PROGRAM_NAME " " OPENBIOS_VERSION_STR " [%s]\n",
66 OPENBIOS_BUILD_DATE);
67
68 ofmem_init();
69 initialize_forth();
70 /* won't return */
71
72 printk("of_startup returned!\n");
73 for( ;; )
74 ;
75 }
76
77 static void
setenv(char * env,char * value)78 setenv( char *env, char *value )
79 {
80 push_str( value );
81 push_str( env );
82 fword("$setenv");
83 }
84
85 void
arch_of_init(void)86 arch_of_init( void )
87 {
88 #if CONFIG_RTAS
89 phandle_t ph;
90 #endif
91 int autoboot;
92
93 devtree_init();
94 node_methods_init();
95 modules_init();
96 setup_timers();
97 #ifdef CONFIG_DRIVER_PCI
98 ob_pci_init();
99 #endif
100
101 #if CONFIG_RTAS
102 if( !(ph=find_dev("/rtas")) )
103 printk("Warning: No /rtas node\n");
104 else {
105 unsigned long size = 0x1000;
106 while( size < (unsigned long)of_rtas_end - (unsigned long)of_rtas_start )
107 size *= 2;
108 set_property( ph, "rtas-size", (char*)&size, sizeof(size) );
109 }
110 #endif
111
112 #if 0
113 /* tweak boot settings */
114 autoboot = !!get_bool_res("autoboot");
115 #endif
116 autoboot = 0;
117 if( !autoboot )
118 printk("Autobooting disabled - dropping into OpenFirmware\n");
119 setenv("auto-boot?", autoboot ? "true" : "false" );
120 setenv("boot-command", "briqboot");
121
122 #if 0
123 if( get_bool_res("tty-interface") == 1 )
124 #endif
125 fword("activate-tty-interface");
126
127 /* hack */
128 device_end();
129 bind_func("briqboot", boot );
130 }
131