/[pearpc]/src/io/prom/prom.cc
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /src/io/prom/prom.cc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (hide annotations)
Wed Sep 5 17:11:21 2007 UTC (16 years, 8 months ago) by dpavlin
File size: 3565 byte(s)
import upstream CVS
1 dpavlin 1 /*
2     * PearPC
3     * prom.cc
4     *
5     * Copyright (C) 2003 Sebastian Biallas (sb@biallas.net)
6     *
7     * This program is free software; you can redistribute it and/or modify
8     * it under the terms of the GNU General Public License version 2 as
9     * published by the Free Software Foundation.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18     * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19     */
20    
21    
22     #include "tools/debug.h"
23     #include "debug/tracers.h"
24     #include "configparser.h"
25     #include "promdt.h"
26     #include "prommem.h"
27     #include "prom.h"
28    
29     PromBootMethod gPromBootMethod;
30     String gPromBootPath;
31    
32     /************************************************************************
33     *
34     */
35    
36     #define PROM_KEY_BOOTMETHOD "prom_bootmethod"
37     #define PROM_KEY_ENV_BOOTPATH "prom_env_bootpath"
38     #define PROM_KEY_ENV_BOOTARGS "prom_env_bootargs"
39     #define PROM_KEY_ENV_MACHARGS "prom_env_machargs"
40     #define PROM_KEY_ENV_LOADFILE "prom_loadfile"
41     #define PROM_KEY_DRIVER_GRAPHIC "prom_driver_graphic"
42    
43     void prom_init()
44     {
45     prom_init_device_tree();
46     PromNode *chosen = findDevice("/chosen", FIND_DEVICE_FIND, NULL);
47     ASSERT(chosen);
48     String bootmethod;
49     gConfig->getConfigString(PROM_KEY_BOOTMETHOD, bootmethod);
50     if (bootmethod == (String)"auto") {
51     gPromBootMethod = prombmAuto;
52     } else if (bootmethod == (String)"select") {
53     gPromBootMethod = prombmSelect;
54     } else if (bootmethod == (String)"force") {
55     gPromBootMethod = prombmForce;
56     } else {
57     IO_PROM_ERR("unknown bootmethod '%y'\n", &bootmethod);
58     }
59     if (gConfig->haveKey(PROM_KEY_ENV_BOOTPATH)) {
60     String bootpath;
61     gConfig->getConfigString(PROM_KEY_ENV_BOOTPATH, bootpath);
62     chosen->addProp(new PromPropString("bootpath", bootpath.contentChar()));
63     gPromBootPath.assign(bootpath);
64     }
65     String bootargs;
66     gConfig->getConfigString(PROM_KEY_ENV_BOOTARGS, bootargs);
67     chosen->addProp(new PromPropString("bootargs", bootargs.contentChar()));
68     String machargs;
69     gConfig->getConfigString(PROM_KEY_ENV_MACHARGS, machargs);
70     chosen->addProp(new PromPropString("machargs", machargs.contentChar()));
71    
72     if (gConfig->haveKey(PROM_KEY_DRIVER_GRAPHIC)) {
73     String filename;
74     gConfig->getConfigString(PROM_KEY_DRIVER_GRAPHIC, filename);
75     FILE *dfile = fopen(filename.contentChar(), "rb");
76     if (!dfile) IO_PROM_ERR("%s: can't open %y\n", PROM_KEY_DRIVER_GRAPHIC, &filename);
77     fseek(dfile, 0, SEEK_END);
78     int dsize = ftell(dfile);
79     fseek(dfile, 0, SEEK_SET);
80     byte *d = (byte*)malloc(dsize);
81     fread(d, 1, dsize, dfile);
82     fclose(dfile);
83     PromNode *screen = findDevice("screen", FIND_DEVICE_FIND, NULL);
84     if (screen) {
85     screen->addProp(new PromPropMemory("driver,AAPL,MacOS,PowerPC", d, dsize));
86     } else {
87     IO_PROM_ERR("'screen' package not found.\n");
88     }
89     }
90    
91     prom_mem_init();
92     }
93    
94     void prom_init_config()
95     {
96     gConfig->acceptConfigEntryStringDef(PROM_KEY_BOOTMETHOD, "auto");
97     gConfig->acceptConfigEntryString(PROM_KEY_ENV_BOOTPATH, false);
98     gConfig->acceptConfigEntryStringDef(PROM_KEY_ENV_BOOTARGS, "");
99     gConfig->acceptConfigEntryStringDef(PROM_KEY_ENV_MACHARGS, "");
100     gConfig->acceptConfigEntryString(PROM_KEY_ENV_LOADFILE, false);
101     gConfig->acceptConfigEntryStringDef(PROM_KEY_DRIVER_GRAPHIC, "");
102     }
103    
104     void prom_quiesce()
105     {
106     prom_done();
107     }
108    
109     void prom_done()
110     {
111     prom_done_device_tree();
112     prom_mem_done();
113     }

  ViewVC Help
Powered by ViewVC 1.1.26