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