Chameleon

Chameleon Commit Details

Date:2011-05-14 11:03:34 (12 years 11 months ago)
Author:Azimutz
Commit:815
Parents: 814
Message:Merging working folder, round 1 (not in a working state).
Changes:
A/branches/azimutz/Chazi/doc-azi/CHANGES.txt
A/branches/azimutz/Chazi/doc-azi
A/branches/azimutz/Chazi/i386/boot2/options.h
A/branches/azimutz/Chazi/doc-azi/Modules.txt
A/branches/azimutz/Chazi/doc-azi/BootArgs-Options.txt
A/branches/azimutz/Chazi/doc-azi/FileLoad.txt
A/branches/azimutz/Chazi/doc-azi/FileLoad-trunk.txt
A/branches/azimutz/Chazi/doc-azi/AutoResolution.txt
A/branches/azimutz/Chazi/doc-azi/README.txt
M/branches/azimutz/Chazi/i386/boot2/modules.h
M/branches/azimutz/Chazi/i386/libsa/qsort.c
M/branches/azimutz/Chazi/i386/boot0/chain0.s
M/branches/azimutz/Chazi/i386/boot2/prompt.c
M/branches/azimutz/Chazi/i386/boot2/gui.c
M/branches/azimutz/Chazi/i386/util/Makefile
M/branches/azimutz/Chazi/i386/libsa/zalloc.c
M/branches/azimutz/Chazi/i386/boot2/gui.h
M/branches/azimutz/Chazi/i386/boot0/Makefile
M/branches/azimutz/Chazi/i386/boot2/ramdisk.c
M/branches/azimutz/Chazi/i386/boot2/options.c
M/branches/azimutz/Chazi/i386/boot2/ramdisk.h
M/branches/azimutz/Chazi/i386/boot2/resume.c
M/branches/azimutz/Chazi
M/branches/azimutz/Chazi/i386/boot2/graphic_utils.h
M/branches/azimutz/Chazi/i386/boot2/boot.c
M/branches/azimutz/Chazi/i386/boot2/boot.h
M/branches/azimutz/Chazi/i386/boot2/drivers.c
M/branches/azimutz/Chazi/i386/MakeInc.dir
M/branches/azimutz/Chazi/i386/boot2/mboot.c
M/branches/azimutz/Chazi/i386/cdboot/Makefile
M/branches/azimutz/Chazi/i386/boot2/bmdecompress.c
M/branches/azimutz/Chazi/i386/boot2/mboot.h
M/branches/azimutz/Chazi/i386/util/bdmesg.c
M/branches/azimutz/Chazi/i386/boot2/lzss.c
M/branches/azimutz/Chazi/i386/boot1/Makefile
M/branches/azimutz/Chazi/i386/doc/README
M/branches/azimutz/Chazi/i386/boot2/graphics.c
M/branches/azimutz/Chazi/i386/libsa/Makefile
M/branches/azimutz/Chazi/i386/boot0/boot0.s
M/branches/azimutz/Chazi/i386/boot2/graphics.h
M/branches/azimutz/Chazi/i386/boot2/modules.c

File differences

branches/azimutz/Chazi/doc-azi/CHANGES.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
Note: this text doesn't use the "most recent layout" of the main Chameleon CHANGES file.
Also, not all the changes done on the code will end up here, for obvious reasons.
Branch copied from /trunk @ rev 264.
---------------//---------------//---------------
- (rev 299)
Change: added hands-off (without user intervention) setting of EFI32 values, for 32 bit only
processors. Works according to the architecture in use, either chosen by the booter or
forced by user.
Note: on pre 10.6 systems, the default EFI values used for 64 bit processors while booting i386
arch (only arch on these systems), will still be EFI64, which causes absolutely no problem.
EFI32 values still can be forced by using the respective booter flag.
Tested only on Leopard.
Note: there's a typo on the comment of rev 299 commit;
RC3 should read RC4.
Motif: fixes http://forge.voodooprojects.org/p/chameleon/issues/21/.
Note: included on the trunk at revs 449 & 450 :) Thanks!
---------------//---------------//---------------
- (rev 320)
Change: using the original code i suggested to Mozodojo, for memory modules Part Number extraction.
(http://www.projectosx.com/forum/index.php?s=&showtopic=1337&view=findpost&p=8809)
Motif: If i don't do:
if (isspace(sPart[i]))
break;
i get extra characters that don't belong to the Part Number, according to CPU-Z or
Everest. This is consistent on the 2 brands of modules i own, Qimonda & Kingston
and others i saw on some user reports.
If someone wishes to test this, contact me and i'll cook a booter to help debug
this behavior.
---------------//---------------//---------------
- (rev 321)
Change: a tweak that got hidden on this commit; changed RestartFix from true to false, by default.
Motif: this goes against at least one of my "Guidelines" for the booter!
(check README.txt). It's absolutely not needed by all users! If someone proves that this is
needed by more than 50% of the motherboards Chameleon needs to handle atm
(recommended OSx86 motherboards don't count), then i'll change it back to true.
---------------//---------------//---------------
- (rev 335) (REVERTED to trunk way, rev 520)
Change: merged the educational side of arch=i386 + the practical one of -x32, into a simple 32
booter flag.
Note: -x32 was removed from trunk on rev 377.
Note: only useful on 64 bit processors.
32 bit only processors, will cause i386 arch to be loaded by default.
Motif: 2 keys to do the same, should never had happen!
I really think that arch=i386 is a more "educational" definition, since what we're really
doing here is select an architecture to boot, but while reading the Chameleon TODO
"Integrate... quick shortcut modified version of 18seven" and knowing that these shortcuts
use the 3 + 2 key combination to select i386 arch, i can't avoid to think,
why not extend it to the boot prompt now!?
---------------//---------------//---------------
- (rev 335) (REMOVED, rev 520)
Change: added -legacy kernel flag. This flag tells the booter to load i386 arch before is passed to
the kernel. This procedure only needs to be done on Snow Leopard. -legacy tells the kernel
to disable "64 Bit Mode", which allows 64 bit processors to run 64 bit apps under i386
mach kernel.
Type -legacy to get you booted into Legacy Mode.
Note: only useful on 64 bit processors.
Note: just out of curiosity and for those who don't know, Legacy Mode is in fact the mode used
by 32 bit "only" processors! Since OS X kernel can handle 64 bit apps even on i386 arch,
64 bit processors need this flag to disable any handling of 64 bit instructions, when
"emulating a full" 32 bit environment.
Motif: this flag was not being passed on > 10.6; the reason why, is this mode is only available
under i386 arch. So, while testing Meklort's kernel patcher, i felt the need to add this key.
---------------//---------------//---------------
- (rev 335) (REVERTED to trunk way, rev 520)
Change: added 64 bit booter flag, to keep company to the 32 one :)
Motif: mainly to override 32 or -legacy if they are flagged on the Boot.plist.
Like -legacy, was born while testing kernel builds and with the need to do the above.
---------------//---------------//---------------
- (rev 336)
Change: removed 3 keys to handle PCI Root UID, two of them executing the exact same code
(PCIRootUID & PciRoot). Kept just the already existing PciRoot=<uid>, plus the new code.
0 is still the default value, use the key to set any other.
Motif: these many keys, should never had happened!
This came along when the Asere code was ported to Chameleon, but even on Asere's booter,
what's the point? Compatibility? None, it's seems!
The only key in use on Asere's booter is PCIRootUID. The others are commented out.
---------------//---------------//---------------
- (revs 337 --> 360)
Changes: file loading related (search algo). The short story:
Change: added a key to disable "override" Boot.plist from overriding the values on the "default"
Boot.plist. Only the values overriding is disabled, not the file loading.
CanOverride=n disables overriding of the default Boot.plist values.
Note: as far as i know, loading a override Boot.plist is not mandatory!
Please correct me if i'm wrong.
Motif: just in case ;)
I was totally unaware of this Boot.plist override for a long time; this messed with my mind
a lot of times! too many. So the first thing i did to the booter when i had the chance,
was make sure i had this under control.
The problem:
- first path checked: rd(0,0)/Extra/com.apple.Boot.plist
nice, override Boot.plist can be loaded from a ramdisk.
- second path: /Extra/com.apple.Boot.plist (the plist on Selected volume)
great, if we have the booter installed on a usb stick, that by the way it's the
main device used these days to hold a rescue booter, the Boot.plist on it will be
ignored (unlike one on a ramdisk) and the one on Selected volume loaded.
- and there's no way to override it (config=<file> is not working).
This can cause all sorts of anxiety and panic attacks, if you are unaware of this
like many people are.
Note: This key it's not mentioned on BootHelp.txt on purpose, since it's not needed
with my actual booter configuration.
---------------//---------------//---------------
Change: added a key to allow overriding the default paths to load Extra extensions.
kext=/path-to-folder/ loads drivers from an alternate folder.
e.g. kext=/Extra/test/
Note: this key needs to point to a "folder" with either a Extensions sub folder or a
Extensions.mkext kext cache, thus always ends with / (slash).
Note: there's a typo on the comment of rev 337 commit;
Extensions=/path-to-folder/ should be read like kext=/path-to-folder/.
Motif: there was no key to do this. (read next)
---------------//---------------//---------------
Change: added a "new" search algo, to load Extra extensions.
Pros:
- hands-off search of all main files. If you don't want a certain file to be loaded,
just don't place it on a default searched path (as usual) or override it with key.
First file found, is the one loaded.
Check FileLoad.txt for info on searched paths.
- easy to configure with other paths.
- easy add to another file load functions.
- no ambiguous paths!! It's bt(0,0) or nothing! (yeah, i'll explain this else were).
- consistency across all file loading.
Cons:
- none that i could test, so far. The only booter install configuration that i can't
really test is RAID.
Motif: after adding the kext= key, i still couldn't override the Extra extensions loaded from
the Selected volume, in case they were messed up and i needed to load another set from
else were. It happens that similarly as with override Boot.plist, /Extra/Extensions
(or /Extra/Extensions.mkext) is the first path to be checked on a HDD and worse,
there's no argument to limit the action; this path is ALWAYS checked and if files are
found they are loaded and will override any other files loaded from another path, like a
ramdisk (only path checked before /Extra/Extensions), making a recovery much more
complicated (not impossible).
So, according to at least one of my guidelines (simplify booter use as much as possible),
changes to the code are/were needed.
This algo was initially a merge between the search algo found on search_and_get_acpi_fd()
(acpi_patcher.c), to load ACPI table and the one on LoadDrivers() (driver.c); also, the
/Extra/* path was still included. I tried a long time playing with the used arguments
(and others) to keep this path, as all i wanted was to give another priority to the file
loading, but there was always problems; a file that kept defaulting to the Booter volume
when i was trying to load it from Selected volume or the other way around.
So, as i always wanted to try taking advantage of Chameleon's ability to load files
from specific OS folders (e.g. /Extra/10.5), i gave it a try and here is the outcome.
Note: it doesn't make any sense taking advantage of this specific OS folders and still check
the Selected volume. Thus except for the obvious files like kernel, SystemVersion.plist,
system caches, etc..., no other file is loaded from Selected volume (paths started with / ).
To put it simple, as an example, when installed to a usb stick, this booter will not search
for any files on the Extra folder of the volume were the system is installed!
Or in other words, the booter will only check the Extra folder on the booter volume
(paths started with bt(0,0) ), the usb stick in this example.
Anyway, /Extra paths can still be passed with the use of override keys!
---------------//---------------//---------------
Change: expanded this "new" search algo to dsdt.aml and smbios.plist.
Note: same override keys used.
Motif: check Guidelines.
---------------//---------------//---------------
Change: tweaked the loading of override Boot.plist (loadOverrideConfig(), stringTable.c) according
the new search algo guideline: everything loads from Booter volume.
The search for this file was also extended to specific OS folders, to "emulate" the search
on Selected volume. Also added a verbose message to signal when user doesn't provide a
override plist.
Note: again, as far as i know, loading a override Boot.plist is not mandatory!
Motif: payback for all the neurons i burned while i was not aware of override Boot.plist function!!
Not kidding :P
---------------//---------------//---------------
Change: reactivated config= key, included on loadOverrideConfig changes.
config=<file> loads override plist from specified path.
e.g. config=/Extra/test.plist
Note: with the introduction of this key, all main files can now be overrided by the user.
Motif: the key wasn't working anymore and it's useful.
---------------//---------------//---------------
Don't forget to check FileLoad.txt/FileLoad-trunk.txt for detailed info on file loading search paths
---------------//---------------//---------------
- (rev 419)
Change: started adding documentation, with the creation of a dedicated folder, doc-azi. It would get very
messy mixing these with main Chameleon documentation and as i want to keep things as clean as
possible on CleanCut, thought a separate folder would be better idea.
Motif: do i need to say? :) i thought so.
---------------//---------------//---------------
- (rev 427)
Change: removed Chameleon.xcodeproj.
Motif: it's not up to date and i need time to update it properly, at least on Chazi.
Will reintroduce it later in the process. It's also giving me problems with the svn client
when i update it; need to check what i'm doing wrong!?
---------------//---------------//---------------
- (rev 460)
Change: added a key to display some debug info, that can only be accessed via code edit.
Check http://forge.voodooprojects.org/p/chameleon/issues/12/ for history.
mm & attr, resolution specific info, are borrowed from autoResolution branch.
DebugInfo=y enables display of debug info.
Note: Boot Banner(*)=n will override DebugInfo=y , disabling the display of this info.
Disabled by default.
Motif: just making this info easily accessible.
---------------//---------------//---------------
---------------//---------------//---------------
- (rev 462)
Change:creation of this project, replacing Chazileon as my work folder;
hence, Chazileon is now frozen until archival and deletion.
Motif: Chazileon (Chazi) has no svn history.
---------------//---------------//---------------
- (revs 465 --> 467, 469 --> 471)
Change:added AutoResolution patch, by Lebidou (autoResolution branch). The main intention of this
patch, is allowing native resolution after boot, even without graphics acceleration (qe/ci).
The "side effect" is that it also enables native resolution at boot prompt (Gui).
The con: doesn't work for all devices!!
AutoResolution=y enables the patch.
Note: Obviously, it only works in Graphics Mode (Gui).
Note: resolution set on theme.plist is overriding the native one set by AutoResolution. For now the
possible solutions are, remove the boot resolution (boot_width, boot_height) from theme.plist
or add Graphics Mode=<native resolution> to com.appleBoot.plist.reminder: ""
Motif: ... mentioned above. Check the topic for more details:
http://forum.voodooprojects.org/index.php/topic,1227.0.html
---------------//---------------//---------------
- (starting at rev 480)
Change: added Meklort's Modules support, plus Kernel Patcher (Kpatcher) module.
PatchKernel=y enables Kernel Patcher.
Note: Check Modules.txt for more info.
Motif: Testing Modules support.
---------------//---------------//---------------
- (rev 520)
Change: removed -legacy flag interaction with the booter and reverted 32/64 flags to the trunk way.
Type arch=i386 to load i386 kernel architecture.
arch=x86_64 overrides i386 arch, if flagged on Boot.plist.
On Snow type arch=i386 -legacy to load i386 arch Legacy Mode.
Motif: don't want to contribute to confusion... and laziness ;)
---------------//---------------//---------------
- (rev 524)
Change: Added GraphicsEnabler module. Needs no introduction :)
Feedback is welcome.
Working as usual with my ATI Radeon X1300 openGL engine, doing the injection thing.
Newsflash: looks like it's raining modules over Meklort's branch :D
Motif: ---
---------------//---------------//---------------
- (rev 526)
Change: Added Memory detection module. Also needs no intro...
Working properly with my controler:
Intel Corporation 82945G/GZ/P/PL Memory Controller Hub [8086:2770] (rev 02)
Motif: ---
---------------//---------------//---------------
Note: latest changes need a call for ATTENTION; the bootloader install procedure is gaining
new steps! So far, we wre just playing with KernelPatcher module, which most people
don't use. Check Modules.txt for info on installing modules.
---------------//---------------//---------------
Been a while since i last updated this file, as there were no major events to justify
doing so. There was however some activity, which deserves to be mentioned; resuming
the most relevant:
- changed all the /Extra... paths to bt(0,0)/Extra... according to my approach to file
loading. I also spent time checking the code involved, which already revealed some BS
on this approach; the research isn't complete so, more news later.
- (rev 592) disabled the limit to hide only foreign partitions. Did this mostly for
testing purposes as i don't have any "foreign" partition/s to hide. I understand the
logic behind this limit, but i just can't avoid to ask my self why?
- studied and played a lot with AutoResolution code. No new functionality, just tweaked
the way it interacts with the booter, wich fixed some glitches and lost functionality,
mostly due to lack of maintenance to fit the changes on the trunk. Next on the plan it's
converting this code into a module, which i already started lining up.
Will add specific info soon.
- (rev 614) Doubled the size of memory reserved for booter log, which is more than enough
to hold the full log generated booting with -f argument and turns out to also be a fix
for some problems related with -f arg boot.
Trunk'ed on rev 616.
---------------//---------------//---------------
- (rev 625)
Change: Added HPET module, another existing patch converted to the modules cause. This carries
some new code to force enable HPET on VIA chipsets, contributed by bogdan-x86
(http://forum.voodooprojects.org/index.php/topic,1596.0.html).
Also carries any notebook support added by Meklort.
Note: Changed DEBUG_HPET messages to verbose. Don't feel i's necessary in this case, unless
some user of the patch get's annoyed by seeing them all time, when booting verbose!?
Else, they only print if ForceHPET=y is used.
Motif: ---
---------------//---------------//---------------
- (rev )
Change:template
Motif:
---------------//---------------//---------------
Azimutz
branches/azimutz/Chazi/doc-azi/Modules.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
---------------// Modules Info //---------------
Installation:
- get the source, compile; find modules at /sym/i386, with .dylib file extension.
- create an /Extra/modules folder on the volume from were the booter is going to load from,
copy Symbols.dylib (mandatory) to modules folder, plus any other module you wish to load.
- update boot file or reinstall the booter completely, as needed.
Note: GraphicsEnabler, MemDetect & ForceHPET patches are now converted to modules.
How to use?
- Just check if a key is needed to activate the functionality you pretend to use. Otherwise
all modules are loaded at startup from the default location, before the boot prompt.
---------------//---------------//---------------
What are modules?
- Modules can be refered as "plugins", adding and/or replacing booter functionality, without
touching the "core" of the booter. If you are familiar with e.g. browser plugins
(like Firefox's Addons), you know what i'm talking about; they either add completely new
functionality or replace/modify existing one; same thing with modules and Chameleon.
More info can be found on Meklort's blog and links at the bottom of the page:
http://www.meklort.com/
---------------//---------------//---------------
Featured modules:
- Symbols.dylib: first one to load, contains all the symbols found on the booter.
All other modules depend on it to load.
---------------//---------------
- KernelPatcher.dylib:
- needs key to enable patching:
PatchKernel=yat boot prompt or,
<key>PatchKernel</key>on Boot.plist.
<string>Yes</string>
- featured patches: cpuid_set - 32/64 bit ??
commpage_stuff - 32/64 bit
lapic_init - 32 bit only.
Note on functionality: as it is, Kpatcher allows my Pentium D 925 to load vanilla(*)
kernel, with the help of -legacy flag; to enter x86_64 world i still need to patch
the kernel sources, as the 925 has no Supplemental SSE3 instructions and there's
no patch to fix this on Kpatcher atm.
I assume that, the great majority of the legacy/unsupported processors with at least
SSE3 instructions, will benefit of the same treatment!
Let's just say that the only patch needed by the 925 on Legacy Mode(**) is cpuid_set!
Note: Kernel Patcher can stop working due to changes on the kernel code.
---------------//---------------
- GraphicsEnabler.dylib: GraphicsEnabler converted to module.
---------------//---------------
- Memory.dylib: MemDetection converted to module.
---------------//---------------
- HPET.dylib: ForceHPET converted to module.
---------------//---------------
- HelloWorld.dylib: just a notifier (not mandatory).
---------------//---------------//---------------
(*) In this context, "vanilla" means the use of a non pre-patched kernel; what we do here is
patch the kernel on the fly, in memory.
(**) For those who "missed" the lesson, Legacy Mode is the one 32 bit only cpu's run on OS X.
---------------//---------------//---------------
Issues:
- compiling modules under Leo (Dev tools 3.1 (9M2809)) is not possible at the moment.
---------------//---------------//---------------
Some talk here: http://forum.voodooprojects.org/index.php/topic,1556.0.html
here: http://forum.voodooprojects.org/index.php/topic,1153.0.html
and here: http://forum.voodooprojects.org/index.php/topic,1565.0.html
---------------//---------------//---------------
Thanks fly out to Meklort for this precious and huge work!
Azimutz
branches/azimutz/Chazi/doc-azi/BootArgs-Options.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
kNVCAP nvidia.c, getValFK - key is declared as a "variable", char kNVCAP[12], on setup_nvidia_devprop().
Check: http://efixusers.com/showthread.php?t=644, Update Version 1.1.9 (Asere's booter).
"If you want to override the NVCAP value, you must determine the PCI DeviceID of your graphic card.
For instance: my new GTX260 has the DeviceID 0×05e2. Knowing the DeviceID add this to your com.apple.Boot.plist:
<key>NVCAP_05e2</key>
<string>0000000000000000000000000000000000000000</string>
The NVCAP value is exactly 20 bytes long. You have to specify it using ASCII-HEX (0-9,a-f)."
00000000000000000000000000000000000000000000000000000000000000000000000000000080
Chameleon Bootloader
boot time help
The boot prompt waits for you to type advanced startup options. If you don't
type anything, the computer continues starting up normally. It will use the
kernel and configuration files on the selected/default device, which it also
uses as the root device.
Use the following syntax, when typing advanced startup options:
[device]<kernel> [arguments]
Arguments consist of either just a name, e.g. -v or a key=value pair,
e.g. rd=disk0s2. The latest are commonly referred to as "keys" and the first
as "flags". ?????????????????
Use the following syntax when typing arguments (recommended):
[flags] [Wait=y key] [any other key]
WARNINGS: (feedback is welcome)
- At least Wait=y is breaking other keys/flags?, when typed after them. This
is the main reason for the "argument" syntax above. If you have any problem
of this nature please try the recommended syntax or play with it.
- Arguments with spaces on their name (marked with (*)) are failing when
wrapped in quotation marks.
Syntax examples:
backup_kernel -legacy -v DSDT=/extra/test.aml Wait=y <-- :( DSDT= failed
backup_kernel -legacy -v Wait=y DSDT=/extra/test.aml <-- :)
rd(0,0)/test_kernel -v debug=0x144
-v Wait=y UseMemDetect=n SMBIOSDefaults=n SMBIOS=/path/to/smbios.plist
Argument's names are case sensitive, values are not. Thus:
/Extra/DSDT.aml = /extra/dsdt.aml, etc...
Thanks ?????
============================================================================79
Special booter hotkeys:
F5 Rescans optical drive.
F10 Scans and displays all BIOS accessible drives.
Special booter commands:
? Displays this file.
?memory Displays information about the computer's memory.
?video Displays VESA video modes supported by the computer's BIOS.
?norescan Leaves optical drive rescan mode.
?lspci Displays information about PCI buses and devices in the system.
?more Displays the text on an extra txt file (needs to be supplied).
Ex: ?more /extra/MoreInfo.txt
==============================================================================
Most used "flags" include: ?????????????
rd=<BSD device name> or rd=*<IODeviceTree path> flag
Used to specify the root device (selected volume), from were the booter
will load start the System. ....when using Apple software RAID helper
partitions (apple boot).?????????
Ex: rd=disk0s2 or rd=uuid (used in conjunction with boot-uuid=<UUID>)??
Ex: rd=*/PCI0@0/CHN0@0/@0:1
<kernel name>
Specify a different kernel to be loaded. Kernel must be in the "/" (root)
of the selected/default volume.
Ex: my_kernel
boot-uuid=<UUID> flag
Specify the UUID of the boot volume.
Ex: boot-uuid=12345678-1234-1234-1234-123456789012
-v Verbose boot: see what booter and kernel are doing on your back :)
-s Single User Mode: Boot into CLI to perform tasks.
-x Safe Mode: ignore System caches and disable most devices.
-f Ignore caches: ignore System caches and boot normally.
-F Ignore "Kernel Flags" specified in boot configuration file.
32 Boot i386 architecture. <---revert??
-legacy Legacy Mode: disable handling 64 bit apps on i386 arch boot.
64 Boot x86_64 architecture. <---revert??
kernel debug flags: e.g. debug=0x144
IOkit debug flags: e.g. io=0xffffffff (defined in IOKit/IOKitDebug.h)
==============================================================================
Options useful either at the prompt or in com.apple.Boot.plist file: ?????
"Root UUID"=<UUID> or y/n?????? (*) ...... man...... :-S key
"Boot Device"=hd(x,y) ?????????? key
Wait=Yes
Pause before starting the kernel.??????
config=<path to file>
Use an alternate/backup "override" Boot.plist file.
Ex: config=/extra/testBoot.plist
kext=<path to folder> (ends with a / (slash))
Use an alternate/backup folder with drivers, kext or mkext.
Ex: kext=/extra/test/
"MKext Cache"=<path to file>
Use an alternate/backup "System" cache file.
Ex: "MKext Cache"=rd(0,0)/Extensions.mkext
Kernel=<file name>
"Kernel Cache"=<path to file>
Use an alternate/backup "Kernel" cache file.
Ex: "Kernel Cache"=bt(0,0)/kernelcache_i386.A701C40B
- Devices/Other:???
UseMemDetect=No
Disable memory modules?? info detection.
0000000000000000000000000000000000000000000000000000000000000000000000000000079
EthernetBuiltIn=Yes
Automatic device-properties generation, that sets "built-in" property
for ethernet interfaces.
USBBusFix=Yes
Enable all USB fixes below (fixes can be used individually):
EHCIacquire=Yes - Enable the EHCI fix.
UHCIreset=Yes - Enable the UHCI fix.
USBLegacyOff=Yes - Enable the USB Legacy fix.
ForceHPET=Yes
Force enabling HPET device on the PC's BIOS.
- Hibernation:
Wake=No ????????change all to n/y and explain this + b.plist way.
Disable wake up after hibernation.
ForceWake=Yes
Force using the sleepimage (when desired), if you get the message:
"Hibernate image is too old by n seconds. Use ForceWake=y to override."
WakeImage=<path to file>
Use an alternate sleepimage file.
Default path: /private/var/vm/sleepimage
- ACPI:
DSDT=<path to file> or <file name>??????????????
Override the default dsdt.aml paths/name.
Default name: dsdt.aml
Default paths:?????
Ex:
0000000000000000000000000000000000000000000000000000000000000000000000000000079
DropSSDT=Yes
Skip the SSDT tables while relocating the ACPI tables.
PciRoot=<value>
Use an alternate value for PciRoot UID. Can be retrieved from dsdt.aml
by the booter, if supplied by the user and present on the ACPI table.
Default value: 0
RestartFix=yes
Enable restart fix for Intel chipsets.
GeneratePStates=Yes
Enable automatic generation PStates. ???????
GenerateCStates=Yes
Enable automatic generation of CStates. ???????
EnableC4State=Yes
Enable automatic generation of C4State. ???????
- Bios/smbios:???
SMBIOS=<path to file> or <file name>
Override the default smbios.plist paths/name.
Default name: smbios.plist
Default paths:?????
Ex:
SMBIOSdefaults=No
Disable the use of Default values for SMBIOS overriding, when smbios.plist
is not used.
SystemType=<value>
Set the system type where n is between 0..6 (default value =1 (Desktop).
0000000000000000000000000000000000000000000000000000000000000000000000000000079
According to CHANGES file, this should be SystemID, not SystemId! ????????
SystemId=<UUID>
Set manually the system UUID. (also known as Platform or Hardware UUID)
SMUUID (reserved field) in smbios.plist config is deprecated.
Ex: SystemId=12345678-1234-1234-1234-123456789012
- CD-ROM: (dvd??)
"Rescan Prompt"=Yes (*)
Prompts for enable CD-ROM rescan mode.
Rescan=Yes
Enable CD-ROM rescan mode.
"Scan Single Drive"=Yes (*)
Scan "only" the drive where the booter got loaded from.
Fixes rescan pbs when using a DVD reader in AHCI mode, on some PC's.
- Ramdisk:
add ramdisk stuff: ?rd, ?rd [m, u, e, d, i]
md0=<file name??>
Override the default "name"??? of raw img file, to be loaded into memory
for use as the kernel's md0 ramdisk.
Default name: Postboot.img
Default paths:?????
Ex:
- Gui/Graphics:
0000000000000000000000000000000000000000000000000000000000000000000000000000079
"Legacy Logo"=Yes (*)
Use the legacy grey apple logo on the boot screen.
GraphicsEnabler=Yes
Automatic device-properties generation for gfx cards.
Note: it doesn't work for all cards and you may have to perform
additional patching to get advantage of
the automatic dev-prop generation. (Leo??)
UseAtiROM=Yes
Use an alternate Ati ROM image
Default path: /Extra/<vendorid>_<devid>.rom
Ex: /Extra/1002_1234.rom
UseNvidiaROM=Yes
Use an alternate Nvidia ROM image.
Default path: /Extra/<vendorid>_<devid>.rom)
Ex: /Extra/10DE_1234.rom
VBIOS=Yes (nVidia only)
Inject VBIOS to device-properties.
NVCAP_<devid>=<value> (nVidia only)
Specify NVCAP value. This value is a 20 bytes long hex string.
Ex: NVCAP_05e2=0000000000000000000000000000000000000000
AutoResolution=Yes
Enable native resolution setting for booter Gui and System, even when
graphics acceleration (qe/ci) is not available.
Graphics Mode=WIDTHxHEIGHTxDEPTH + F2 (*) (AutoResolution only)
Change or set current resolution while at boot prompt.
Ex: Graphics Mode=1024x768x32 + press F2 key
- Modules:
PatchKernel=Yes
Enable on the fly kernel patching.
branches/azimutz/Chazi/doc-azi/AutoResolution.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---------------// AutoResolution Info //---------------
Project topic: http://forum.voodooprojects.org/index.php/topic,1227.0.html
there you can find latest sources and boot files posted by LeBidou, as well as most
of the feedback and project history. Source can also be found, in a more or less
up to date form on AutoResolution branch and CleanCut folder under my branch;
as of this writing i'm considering those as "obsolete", replaced by what i have at
the moment on Chazi folder.
Some more references can be found on this topic by DieBuche:
http://www.insanelymac.com/forum/index.php?showtopic=211294&st=0
in fact, the first post is the best explanation you can get on how the patch works,
with the difference that the patch does it "on the fly" while booting, in an "Auto"
way (hence the AutResolution name) using the resolution retrieved from the display's
EDID or provided with "Graphics Mode" argument.
But, don't stay only with the first post! I won't get into technical details, simply
because i don't have the knowledge to. All i do is try to keep the patch working with
latest Chameleon changes and that's obviously because i use it :)
Will add more info with time if it's justifiable.
Enough talk...
What can this patch do for you and when?
Well, if you never experienced booting with your native resolution, or worse, you don't
even have it after login, there's a chance that this can help you, providing you have
the luck of having the right hardware. If it works, it will provide you with native
resolution even if you don't have any graphics acceleration at all; remember, this has
nothing to do with "Graphics Enabler" or depends on it in any way.
Intel chipset is needed; the newer the worse :P read the topics and check the list below.
Graphics card, it depends... ATI's are the best supported, but BIOS and motherboard have
something to say so, the best is try it.
How to try?
Working:
Intel X4500MHD, on Acer Aspire 1810TZ, (2a428086) (no qe/ci) - leader86
GMA950, on MSI Wind u100 (Atom n270), (27ae8086) - smith@@
GMA X3100, on Sony Vaio (old model), (2a028086) - smith@@
nVidia 9800GT, on p5q deluxe and pro, (061410de) - smith@@
nVidia 8600GTS, on p5q deluxe and pro, (040010de) - smith@@
ATI Radeon X1300, on HP 7730, (81711002) - mine
Not working:
nVidia 9800GT, on p5k se epu, (061410de) - smith@@
- the screen becomes completely green with some horizontal lines.
GMA950, on HP 7730, (27728086) - mine
http://www.insanelymac.com/forum/index.php?s=44134eab9a3c0832fdff3f5a43394a72&showtopic=211294&view=findpost&p=1422921
Azimutz
branches/azimutz/Chazi/doc-azi/README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
About me:
Just the average curious guy, that likes to know a bit of this and that.
I'm not a skilled coder or even a developer, nor i pretend to be! Most of what i'm doing here
is simply tweaking code that already exists, though lack of knowledge is not the only reason
for this behavior.
Just trying to learn, share my opinion (as noob as it may be) and give back some help,
within my skills, knowledge and available time.
So bare with me :) i'll remember to do the same with you when the time comes.
Thanks.
Azi
About the branch:
First, the usual warning: use it at your own risk!
No, it's not going to set your machine on fire or something like that :)
Everything is tested on my machine first and i don't mess with stuff i don't have knowledge to mess
with, but you never know. Be sure you fully understand the changes before you use this booter
(CleanCut included) and always keep a plan B!!!
I will do my best to explain what these changes are and more.
Although i use this stuff on a daily basis, this is not meant to be an alternative to Chameleon!
Any use of this booter/s should be considered "testing". If you do find a certain patch or
functionality useful to your self and the "great" majority of Chameleon users, please make a request
to the Chameleon team, on the appropriate places(*).
Any other stuff can/should be reported to me directly, at the forum (*) by pm.
I might miss a topic so, if you create one, pm me anyway.
The layout of the branch can change, but at least 2 folders will always be present (at least for now):
CleanCut and Chazi:
- Chazi is the main stuff! It's My Work Folder, Test Bed and "Personal" Booter. Comparing it to the
trunk will probably be a "pain in" for anyone in the future. That's were CleanCut comes in.
- CleanCut, as the name implies, is a "clean" cut of Chazi; will always be as close to the trunk as
possible and i won't commit there patches that don't work for everyone, like the AutoResolution
one i use on Chazi (this may change in the future).
It's meant to be compared easily and keep the stuff i consider most useful to Chameleon "at hand".
Stuff committed there, besides trunk updates, will always come from and reflect changes on Chazi,
keeping the limitations above in mind.
This project it's not meant to be used! Want to test something, use Chazi.
Guidelines:
- learn and spread the knowledge.
- make the code more understandable for Sorcerer's Apprentice like my self.
- help applying Coding Standards.
- help improving Chameleon documentation.
- help testing and integrating new useful code to Chameleon.
- simplify booter use as much as possible.
- all files loaded by the booter stay confined to Extra folder.
- fixes that are not absolutely needed by all users, are disabled by default. (reviewable)
- no absolute priority to Selected volume.
- emulating a Mac it's not a priority!!!
---------------//---------------//---------------
Any feedback is highly appreciated. I mean ANY! Good, bad, suggestion, opinion, bug, issue, etc...
About requests, keep in mind that my knowledge is limited!
Think "baby steps" ;)
Read the rest of the docs for more info and keep an eye on the forge and forum (*) for news.
Stay safe and enjoy.
Thanks:
any contribution to this OSx86 scene, with a true sense of "community" deserves a "Thank you very much",
from the small post, to the nice booter :)
---------------//---------------//---------------
---------------//---------------//---------------
(*) http://forge.voodooprojects.org/
http://forum.voodooprojects.org/
Azimutz
branches/azimutz/Chazi/doc-azi/FileLoad.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
Well, the intention here is to give some insight on Chameleon file loading, as well as providing
detailed info about what files are (or can be) loaded, from what devices, used paths, differences
between paths, if there's user overriding available, etc...
For now, it will just focus on comparing what's available (on trunk) and one of the many "paths"
we can follow (my branch); also, only the most frequently used files are featured.
For the purpose of comparison, there's a FileLoad-trunk.txt similar to this one, that will
reflect the current Chameleon (trunk) status on the matter.
To be honest, the info on this file will depend greatly on "feedback"; writing down this stuff it's
not the most pleasing and fruitful task i have to do atm, time is never enough and i don't feel
particularly inspired for the job atm; so if i see no interest in this,
i will ditch it as quickly as i started it.
Note: unless other wise specified, first file found is the one used.
Note: path/name search is not case sensitive! Meaning that:
- this /Extra/DSDT.aml
- or this /extra/dsdt.aml
points exactly to the same location.
Before we go on:
- Selected volume = root volume (volume/partition were a system is installed)
- Booter volume = boot volume (volume/partition were the bootloader installed)
---------------//---------------//---------------
Chazi - CleanCut
---------------//---------------//---------------
- Extra extensions (kext)
Default name:Extensions (a directory with kext/s)
Name override:No
Default path/s: - User override
- ramdisk:
rd(0,0)/Extensions
- booter volume or ramdisk aliased as bt(0,0) (1*):
bt(0,0)/Extra/specificOSfolder/Extensions
- same as above:
bt(0,0)/Extra/Extensions
- Helper partition/s (Apple_Boot): checked only if exists (2*)
/com.apple.boot.P/System/Library/Extensions
/com.apple.boot.R/System/Library/Extensions
/com.apple.boot.S/System/Library/Extensions
Path override: Yes
User override: kext=path to folder with Extensions sub folder; e.g. /Extra/drivers/
Note: see CHANGES.txt, (revs 337 --> 360), second Change.
-------/-/------- - same search scheme as above.
- Extra extensions (mkext)
Default name: Extensions.mkext (kext cache)
Name override: No
Default path/s: User override
rd(0,0)/Extensions.mkext
bt(0,0)/Extra/specificOSfolder/Extensions.mkext
bt(0,0)/Extra/Extensions.mkext
/com.apple.boot.P/System/Library/Extensions.mkext
/com.apple.boot.R/System/Library/Extensions.mkext
/com.apple.boot.S/System/Library/Extensions.mkext
Path override: Yes
User override: kext=path to folder with a Extensions.mkext; e.g. /Extra/drivers/
Note: see CHANGES.txt, (revs 337 --> 360), second Change.
---------------//---------------//---------------
- Default configuration file (plist)
Default name: com.apple.Boot.plist
Name override: No
Default path/s: (3*)
bt(0,0)/Extra/com.apple.Boot.plist
/Library/Preferences/SystemConfiguration/com.apple.Boot.plist
- Helper partition/s (Apple_Boot):
/com.apple.boot.P/Library/Preferences/SystemConfiguration/com.apple.Boot.plist
/com.apple.boot.R/Library/Preferences/SystemConfiguration/com.apple.Boot.plist
/com.apple.boot.S/Library/Preferences/SystemConfiguration/com.apple.Boot.plist
Path override: No
---------------//---------------//---------------
- Override configuration file (plist)
Default name: com.apple.Boot.plist
Name override: Yes
Default path/s: User override
rd(0,0)/com.apple.Boot.plist
bt(0,0)/Extra/specificOSfolder/com.apple.Boot.plist
(4*)
Path override: Yes
User override: config=path to file; e.g. /Extra/test/com.apple.Boot.plist or /Extra/b.plist
---------------//---------------//---------------
- ACPI table (aml)
Default name: DSDT.aml
Name override: Yes
Default path/s: User override
rd(0,0)/DSDT.aml
bt(0,0)/Extra/specificOSfolder/DSDT.aml
bt(0,0)/Extra/DSDT.aml
Path override: Yes
User override: DSDT=path to file; e.g. rd(0,0)/Extra/dsdt.aml or /Extra/test.aml
-------/-/-------
ssdt.aml (5*)
---------------//---------------//---------------
- SMBIOS (plist)
Default name: SMBIOS.plist
Name override: Yes
Default path/s: User override
rd(0,0)/SMBIOS.plist
bt(0,0)/Extra/specificOSfolder/SMBIOS.plist
bt(0,0)/Extra/SMBIOS.plist
Path override: Yes
User override: SMBIOS=path to file; e.g. bt(0,0)/Extra/smbios.plist or /Extra/MP21.plist
---------------//---------------//---------------
- ramdisk (dmg)
Default name: Preboot.dmg
Name override: Yes
Default path/s: User override
bt(0,0)/Extra/Preboot.dmg
Path override: Yes
User override: rd=path to file; e.g. /Extra/Preboot.dmg or /Leo.dmg
---------------//---------------//---------------
The long story:
---------------//---------------//---------------
(1*)
Ramdisks (rd) are simple image files (dmg, etc...) most commonly associated with the pre-boot discs
used to boot retail Mac OS X Installer dvd's; in this case, they are used to load needed files into
memory, before discs can be swapped. But, pre-boot it's not their only use; they can be loaded from
any device the booter has access to and used to test/load, from kexts to complete boot configurations.
A rd aliased as bt(0,0), is a normal rd with a btalias activated pointing to it. The btalias is activated
via a configuration file placed on the root of the rd (RAMDisk.plist), using the pair BTAlias=y.
When this alias is activated on a rd, all paths started by bt(0,0) (pointing to the Booter volume)
will instead point to the rd. This makes rd's aliased as bt, ideal to load full sets of files,
like when using the mentioned pre-boot discs.
(2*)
Helper partitions - boot support partitions (Apple_Boot)
Need to gather more info on these, since i have no experience with them.
All i can say for now is that /com.apple.boot.P /com.apple.boot.R /com.apple.boot.S are directories on
Apple_boot partitions. So far, the only real case scenario i could find that uses these partitions is
software RAID, were the root partition can't be accessed before the "software RAID" is running.
In this situation, these partitions are used as Booter volume and hold the necessary files, that on a
normal setup are loaded directly from the root volume (were the system is installed).
Here is a link to the only decent explanation i ever found on the net:
http://lists.apple.com/archives/boot-dev/2009/May/msg00009.html
(RPS) Rock, Paper, Scissors (the next beats the previous)
(3*)
I'm not searching /Extra/com.apple.Boot.plist on Default paths (c.a.B.plist on selected volume).
The reason is pretty evident, if we don't forget that this booter only loads files from booter volume.
But that's not all; there's also a concept so, for now i'm going to focus only on it.
The concept is: Default configuration file should be loaded either from the Booter volume or from one
of the default system paths.
Why? Because it's the Default configuration file, with the Default configuration files, that the booter
is supposed to use by Default, on a hands-off situation. All these values can still be override by
the user in more ways than one, if the user wishes so! (read 4*)
Wish we could use just "One" default path!??
(4*)
Here i have my doubts if what i have is the ideal, if there's any ideal situation to follow?!
Anyway, explaining what i have now and why.
I'm not searching Default paths for now because:
- they are already checked when loading the Default configuration. In "many" situations
(not to say "most") this will just be reloading the already loaded values.
- on this booter, Selected volume is replaced by the use of a specific OS folder so, in some sense
the selected volume is still checked. And there's also a override key!
My doubts are related to the fact that, searching default paths here does make sense (in a way)
and i'm not entirely sure that's not needed in some configurations?! It's just that, the way
it's done now it gets confuse...
Does using a different name for the Override configuration file make any sense??
(5*)
ssdt: need to gather more info on these, since i have no experience with them.
As far as i understand, same paths as for dsdt.aml are used and if anything different from "dsdt.aml"
is found, it's loaded. 30 tables can be loaded and must be named as:
ssdt.aml, ssdt-1.aml, ssdt-2.aml,... ssdt-30.aml ??? bla bla bla... damn confusion :-/
reminder:
- no ambiguous paths
- what override paths can be used.
---------------//...still plenty to edit...//---------------
---------------//...still plenty brainstorm...//---------------
Azimutz
branches/azimutz/Chazi/doc-azi/FileLoad-trunk.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
Check FileLoad.txt for full comments.
Note: unless other wise specified, first file found is the one used.
---------------//---------------//---------------
trunk
---------------//---------------//---------------
- Extra extensions (kext)
Default name:Extensions (a directory with kext/s)
Name override:No
Default path/s: - ramdisk: checked only if exists
rd(0,0)/Extra/Extensions
- selected volume: always checked, even if theres a hit on rd(0,0)
/Extra/Extensions
- booter volume or ramdisk aliased as bt(0,0) (1*): checked only if there's no hit on the previous
bt(0,0)/Extra/specificOSfolder/Extensions
- same as previous
bt(0,0)/Extra/Extensions
- Helper partition/s (Apple_Boot): checked only if exists (2*)
/com.apple.boot.P/System/Library/Extensions
/com.apple.boot.R/System/Library/Extensions
/com.apple.boot.S/System/Library/Extensions
Path override: No
-------/-/------- - same search scheme as above.
- Extra extensions (mkext)
Default name: Extensions.mkext
Name override: No
Default path/s: rd(0,0)/Extensions.mkext
/Extra/Extensions.mkext
bt(0,0)/Extra/specificOSfolder/Extensions.mkext
bt(0,0)/Extra/Extensions.mkext
/com.apple.boot.P/System/Library/Extensions.mkext
/com.apple.boot.R/System/Library/Extensions.mkext
/com.apple.boot.S/System/Library/Extensions.mkext
Path override: No
---------------//---------------//---------------
- Default configuration file (plist)
Default name: com.apple.Boot.plist
Name override: No
Default path/s: /Extra/com.apple.Boot.plist
bt(0,0)/Extra/com.apple.Boot.plist
/Library/Preferences/SystemConfiguration/com.apple.Boot.plist
- Helper partition/s (Apple_Boot):
/com.apple.boot.P/Library/Preferences/SystemConfiguration/com.apple.Boot.plist
/com.apple.boot.R/Library/Preferences/SystemConfiguration/com.apple.Boot.plist
/com.apple.boot.S/Library/Preferences/SystemConfiguration/com.apple.Boot.plist
Path override: No
---------------//---------------//---------------
- Override configuration file (plist)
Default name: com.apple.Boot.plist
Name override: No
Default path/s: rd(0,0)/Extra/com.apple.Boot.plist
/Extra/com.apple.Boot.plist
/Library/Preferences/SystemConfiguration/com.apple.Boot.plist
Helper partition/s:
/com.apple.boot.P/Library/Preferences/SystemConfiguration/com.apple.Boot.plist
/com.apple.boot.R/Library/Preferences/SystemConfiguration/com.apple.Boot.plist
/com.apple.boot.S/Library/Preferences/SystemConfiguration/com.apple.Boot.plist
Path override: No
---------------//---------------//---------------
- ACPI table/s (aml)
Default name: DSDT.aml
Name override: Yes
Default path/s: - User override or default name:
user path or
DSDT.aml = current volume!?
- selected volume: checked only if there's no hit on the previous
/Extra/DSDT.aml
- booter volume or ramdisk aliased as bt(0,0) (1*): checked only if there's no hit on the previous
bt(0,0)/Extra/DSDT.aml
Path override: Yes
User override: DSDT=path to file; e.g. rd(0,0)/Extra/dsdt.aml or /Extra/test.aml
-------/-/-------
ssdt.aml (5*)
---------------//---------------//---------------
- SMBIOS (plist)
Default name: SMBIOS.plist
Name override: Yes
Default path/s: - User override
- selected volume: checked only if there's no hit on the previous
/Extra/SMBIOS.plist
- booter volume or ramdisk aliased as bt(0,0) (1*): checked only if there's no hit on the previous
bt(0,0)/Extra/SMBIOS.plist
Path override: Yes
User override: SMBIOS=path to file; e.g. bt(0,0)/Extra/smbios.plist or /Extra/MP21.plist
---------------//---------------//---------------
- ramdisk (dmg)
Default name: Preboot.dmg
Name override: Yes
Default path/s: User override
bt(0,0)/Extra/Preboot.dmg
Path override: Yes
User override: rd=path to file; e.g. /Extra/Preboot.dmg or /Leo.dmg
---------------//---------------//---------------
Note: (n*) comments are located on FileLoad.txt.
Azimutz
branches/azimutz/Chazi/i386/boot0/chain0.s
697697
698698
699699
700
700
times 510-($-$$) db 0
dw kBootSignature
;END
; END
branches/azimutz/Chazi/i386/boot0/boot0.s
317317
318318
319319
320
321
320
321
322322
323
323
324324
325325
326
326
327327
328
329
328
329
330330
331331
332
332
333333
334334
335335
336336
337
337
338338
339
340
339
340
341341
342342
343
344
343
344
345345
346
346
347347
348348
349349
......
359359
360360
361361
362
362
363363
364364
365365
......
369369
370370
371371
372
372
373373
374374
375375
......
406406
407407
408408
409
409
410410
411411
412412
......
496496
497497
498498
499
500499
500
501501
502502
503503
.Pass1:
%ifdef HFSFIRST
cmp BYTE [si + part.type], kPartTypeHFS; In pass 1 we're going to find a HFS+ partition
; equipped with boot1h in its boot record
; regardless if it's active or not.
; equipped with boot1h in its boot record
; regardless if it's active or not.
jne .continue
mov dh, 1 ; Argument for loadBootSector to check HFS+ partition signature.
movdh, 1 ; Argument for loadBootSector to check HFS+ partition signature.
%else
cmp BYTE [si + part.bootid], kPartActive; In pass 1 we are walking on the standard path
; by trying to hop on the active partition.
; by trying to hop on the active partition.
jne .continue
xor dh, dh ; Argument for loadBootSector to skip HFS+ partition
; signature check.
xor dh, dh ; Argument for loadBootSector to skip HFS+ partition
; signature check.
%endif
jmp .tryToBoot
jmp .tryToBoot
.Pass2:
%ifdef HFSFIRST
cmp BYTE [si + part.bootid], kPartActive; In pass 2 we are walking on the standard path
; by trying to hop on the active partition.
; by trying to hop on the active partition.
jne .continue
xor dh, dh ; Argument for loadBootSector to skip HFS+ partition
; signature check.
xordh, dh ; Argument for loadBootSector to skip HFS+ partition
; signature check.
%else
cmp BYTE [si + part.type], kPartTypeHFS; In pass 2 we're going to find a HFS+ partition
; equipped with boot1h in its boot record
; regardless if it's active or not.
; equipped with boot1h in its boot record
; regardless if it's active or not.
jne .continue
mov dh, 1 ; Argument for loadBootSector to check HFS+ partition signature.
mov dh, 1 ; Argument for loadBootSector to check HFS+ partition signature.
%endif
DebugChar('*')
jmp SHORT initBootLoader
.continue:
add si, BYTE part_size; advance SI to next partition entry
add si, BYTE part_size ; advance SI to next partition entry
loop .loop ; loop through all partition entries
;
;
dec bl
jnz .switchPass2; didn't find Protective MBR before
call checkGPT
call checkGPT
.switchPass2:
;
;
checkGPT:
push bx
mov di, kLBA1Buffer; address of GUID Partition Table Header
cmp DWORD [di], kGPTSignatureLow; looking for 'EFI '
jne .exit; not found. Giving up.
.exit:
pop bx
ret; no more GUID partitions. Giving up.
;--------------------------------------------------------------------------
; loadBootSector - Load boot sector
;
branches/azimutz/Chazi/i386/boot0/Makefile
22
33
44
5
6
5
76
87
98
109
1110
12
13
14
11
12
1513
1614
17
18
15
1916
2017
21
22
18
2319
2420
2521
DIR = boot0
include ../MakePaths.dir
#NASM = /Developer/usr/bin/nasm
NASM =$(shell which nasm)
NASM = $(shell which nasm)
INSTALLDIR = $(DSTROOT)/usr/standalone/i386
DIRS_NEEDED = $(SYMROOT)
all embedtheme: $(DIRS_NEEDED) boot0 boot0hfs chain0
boot0: boot0.s
@echo "\t[NASM] $@"
@$(NASM) boot0.s -o $(SYMROOT)/$@
boot0: boot0.s Makefile $(NASM)
$(NASM) boot0.s -o $(SYMROOT)/$@
boot0hfs: boot0.s Makefile $(NASM)
@echo "\t[NASM] $@"
@$(NASM) boot0.s -DHFSFIRST -o $(SYMROOT)/$@
$(NASM) boot0.s -DHFSFIRST -o $(SYMROOT)/$@
chain0: chain0.s Makefile $(NASM)
@echo "\t[NASM] $@"
@$(NASM) chain0.s -o $(SYMROOT)/$@
$(NASM) chain0.s -o $(SYMROOT)/$@
install_i386:: all $(INSTALLDIR)
cp $(SYMROOT)/boot0 $(SYMROOT)/chain0 $(INSTALLDIR)
branches/azimutz/Chazi/i386/MakeInc.dir
4242
4343
4444
45
46
47
48
45
46
47
4948
5049
51
52
53
54
50
51
52
5553
5654
57
58
59
60
55
56
57
6158
6259
63
64
65
66
60
61
62
6763
6864
69
70
71
72
65
66
67
7368
7469
75
76
77
78
70
71
72
7973
8074
81
82
83
84
75
76
77
8578
8679
8780
8881
8982
9083
91
92
84
9385
9486
95
96
87
9788
9889
99
100
90
10191
10292
103
104
93
.SUFFIXES: .s .i .c .o .o32 .o64
.c.o32:
@echo "\t[CC32] $<"
@$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) -arch i386 $< -o $(OBJROOT)/$*.o32 \
-MD -dependency-file $(OBJROOT)/$*.d
@md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) -arch i386 $< -o $(OBJROOT)/$*.o32 \
-MD -dependency-file $(OBJROOT)/$*.d
md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d
.c.o64:
@echo "\t[CC64] $<"
@$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) -arch x86_64 $< -o $(OBJROOT)/$*.o64 \
-MD -dependency-file $(OBJROOT)/$*.d
@md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) -arch x86_64 $< -o $(OBJROOT)/$*.o64 \
-MD -dependency-file $(OBJROOT)/$*.d
md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d
.c.o .m.o:
@echo "\t[CC] $<"
@$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) $< -o $(OBJROOT)/$*.o \
-MD -dependency-file $(OBJROOT)/$*.d
@md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) $< -o $(OBJROOT)/$*.o \
-MD -dependency-file $(OBJROOT)/$*.d
md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d
$(OBJROOT)/%.o: %.c
@echo "\t[CC] $<"
@$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) $< -o $(OBJROOT)/$*.o \
-MD -dependency-file $(OBJROOT)/$*.d
@md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) $< -o $(OBJROOT)/$*.o \
-MD -dependency-file $(OBJROOT)/$*.d
md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d
$(OBJROOT)/%.o32: %.c
@echo "\t[CC32] $<"
@$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) -arch i386 $< -o $(OBJROOT)/$*.o32 \
-MD -dependency-file $(OBJROOT)/$*.d
@md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) -arch i386 $< -o $(OBJROOT)/$*.o32 \
-MD -dependency-file $(OBJROOT)/$*.d
md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d
$(OBJROOT)/%.o64: %.c
@echo "\t[CC64] $<"
@$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) -arch x86_64 $< -o $(OBJROOT)/$*.o64 \
-MD -dependency-file $(OBJROOT)/$*.d
@md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) -arch x86_64 $< -o $(OBJROOT)/$*.o64 \
-MD -dependency-file $(OBJROOT)/$*.d
md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d
$(OBJROOT)/%.o: %.m
@echo "\t[CC] $<"
@$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) $< -o $(OBJROOT)/$*.o \
-MD -dependency-file $(OBJROOT)/$*.d
@md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) $< -o $(OBJROOT)/$*.o \
-MD -dependency-file $(OBJROOT)/$*.d
md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d
#.s.o:
#cc $(INC) -E $< > $(OBJROOT)/$*.o2
#$(AS) -o $(OBJROOT)/$@ $(OBJROOT)/$*.o2
.s.o:
@echo "\t[AS] $<"
@cc $(CPPFLAGS) -c $(INC) -arch i386 -o $(OBJROOT)/$(@F) $<
cc $(CPPFLAGS) -c $(INC) -arch i386 -o $(OBJROOT)/$(@F) $<
boot2.o:
@echo "\t[AS] boot2.s"
@cc $(CPPFLAGS) -Wa,-n -c $(INC) -arch i386 -o $(OBJROOT)/$(@F) boot2.s
cc $(CPPFLAGS) -Wa,-n -c $(INC) -arch i386 -o $(OBJROOT)/$(@F) boot2.s
$(OBJROOT)/%.o: %.s
@echo "\t[CC] $<"
@cc $(CPPFLAGS) -c $(INC) -arch i386 -o $(OBJROOT)/$(@F) $<
cc $(CPPFLAGS) -c $(INC) -arch i386 -o $(OBJROOT)/$(@F) $<
$(DIRS_NEEDED) $(INSTALLDIR) $(SRCROOT):
@echo "\t[MKDIR] $@"
@$(MKDIRS) $@
$(MKDIRS) $@
branches/azimutz/Chazi/i386/boot1/Makefile
55
66
77
8
98
109
1110
......
2120
2221
2322
24
25
26
27
28
29
30
31
23
24
25
26
3227
3328
3429
INSTALLDIR = $(DSTROOT)/usr/standalone/i386
DIRS_NEEDED = $(OBJROOT) $(SYMROOT)
#NASM = /Developer/usr/bin/nasm
NASM = $(shell which nasm)
VERSIONED_FILES = boot1h
all embedtheme: $(DIRS_NEEDED) $(VERSIONED_FILES)
boot1h: boot1.s Makefile
@echo "\t[NASM] boot1.s"
@$(NASM) boot1.s -o $(SYMROOT)/boot1h
@echo "\t[NASM] boot1hp.s"
@$(NASM) boot1hp.s -o $(SYMROOT)/boot1hp
@echo "\t[NASM] boot1he.s"
@$(NASM) boot1he.s -o $(SYMROOT)/boot1he
@echo "\t[NASM] boot1f32.s"
@$(NASM) boot1f32.s -o $(SYMROOT)/boot1f32
$(NASM) boot1.s -o $(SYMROOT)/boot1h
$(NASM) boot1hp.s -o $(SYMROOT)/boot1hp
$(NASM) boot1he.s -o $(SYMROOT)/boot1he
$(NASM) boot1f32.s -o $(SYMROOT)/boot1f32
install_i386:: all $(INSTALLDIR)
cp $(SYMROOT)/boot1h $(INSTALLDIR)/
branches/azimutz/Chazi/i386/boot2/ramdisk.h
77
88
99
10
11
1012
1113
1214
#ifndef __BOOT_RAMDISK_H
#define __BOOT_RAMDISK_H
#include "memory.h"
#define RAMDISKCONFIG_FILENAME "rd(0,0)/RAMDisk.plist"
//#define kPostbootRamdisk
void md0Ramdisk();
branches/azimutz/Chazi/i386/boot2/options.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
* Copyright (c) 1999-2004 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Portions Copyright (c) 1999-2004 Apple Computer, Inc. All Rights
* Reserved. This file contains Original Code and/or Modifications of
* Original Code as defined in and that are subject to the Apple Public
* Source License Version 2.0 (the "License"). You may not use this file
* except in compliance with the License. Please obtain a copy of the
* License at http://www.apple.com/publicsource and read it before using
* this file.
*
* The Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef __BOOT2_OPTIONS_H
#define __BOOT2_OPTIONS_H
//#include "boot.h"
//#include "bootstruct.h"
//#include "graphics.h"
//AZI: KEEP THIS FILE ???
extern intgDeviceCount;
void clearBootArgs(void);
typedef struct {
int x;
int y;
int type;
} CursorState;
enum {
kMenuTopRow = 5,
kMenuMaxItems = 10,
kScreenLastRow = 24
};
/*
extern const MenuItem * gMenuItems;
void addBootArg(const char * argStr);
void changeCursor( int col, int row, int type, CursorState * cs );
void moveCursor( int col, int row );
void restoreCursor( const CursorState * cs );
void printMemoryInfo(void);
void lspci(void);
void printMenuItem( const MenuItem * item, int highlight );
bool flushKeyboardBuffer(void);
extern bool shouldboot;
#ifdef UNUSED
extern int multiboot_timeout;
extern int multiboot_timeout_set;
#endif
extern BVRef bvChain;
//extern intmenucount;
//==========================================================================
extern char gBootArgs[BOOT_STRING_LEN];
extern char * gBootArgsPtr;
extern char * gBootArgsEnd;
extern char booterCommand[BOOT_STRING_LEN];
extern char booterParam[BOOT_STRING_LEN];
//==========================================================================
extern int gMenuItemCount;
extern int gMenuRow;
extern int gMenuHeight;
extern int gMenuTop;
extern int gMenuBottom;
extern int gMenuSelection;
extern int gMenuStart;
extern int gMenuEnd;
extern unsigned char chainbootdev;
extern unsigned char chainbootflag;
// Maximum config table value size
#define VALUE_SIZE 2048
*/
#endif /* __BOOT2_OPTIONS_H */
branches/azimutz/Chazi/i386/boot2/graphics.c
2727
2828
2929
30
3130
3231
3332
......
4241
4342
4443
45
46
4744
4845
4946
......
180177
181178
182179
183
180
181
184182
185183
186184
......
369367
370368
371369
370
371
372372
373373
374374
......
387387
388388
389389
390
391
390392
391393
392394
......
424426
425427
426428
429
430
431
432
433
434
427435
428
429436
430437
431438
432439
440
441
442
443
444
433445
434446
435447
......
438450
439451
440452
441
453
442454
443455
444456
......
461473
462474
463475
476
477
478
479
480
481
482
464483
484
485
486
487
488
465489
466490
467491
......
10301054
10311055
10321056
1033
1034
1057
1058
10351059
10361060
10371061
......
11041128
11051129
11061130
1107
1131
11081132
11091133
11101134
1111
1112
1113
1114
1115
1116
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
11171146
1118
11191147
11201148
11211149
11221150
1123
1151
1152
11241153
11251154
11261155
11271156
11281157
11291158
1130
1159
11311160
11321161
1133
1134
1162
1163
1164
11351165
11361166
11371167
......
12021232
12031233
12041234
1205
1235
12061236
12071237
12081238
......
12191249
12201250
12211251
1222
1252
12231253
12241254
12251255
*/
#include "boot.h"
#include "vbe.h"
#include "appleClut8.h"
#include "gui.h"
#include "IOHibernatePrivate.h"
uint8_t *previewSaveunder = 0;
#define VIDEO(x) (bootArgs->Video.v_ ## x)
#define MIN(x, y) ((x) < (y) ? (x) : (y))
//==========================================================================
// getVBEInfoString
// Return the VESA mode that matches the properties specified.
// If a mode is not found, then return the "best" available mode.
static unsigned short
//static //Azi:autoresolution
unsigned short
getVESAModeWithProperties( unsigned short width,
unsigned short height,
unsigned char bitsPerPixel,
unsigned char bitsPerPixel,
unsigned short refreshRate )
{
bool debugInfo = false; //Azi:debuginfo
extern bool showBootBanner; //||
VBEModeInfoBlock minfo;
unsigned short mode;
unsigned short vesaVersion;
break;
}
if (refreshRate != 60) refreshRate = 60; //Azi:autoresolution
//
// FIXME : generateCRTCTiming() causes crash.
//
// err = setVBEMode( mode | kLinearFrameBufferBit, NULL );
// }
//Azi:autoresolution
#ifdef AUTORES_DEBUG
printf("Is about to set mode #%d with resolution %dx%d\n", mode, minfo.XResolution, minfo.YResolution);
//getc(); //Azi: boot hangs, on the second call (like "old" Wait=y issue).
sleep(2);
#endif
// Set the mode with default refresh rate.
err = setVBEMode( mode | kLinearFrameBufferBit, NULL );
if ( err != errSuccess )
{
#ifdef AUTORES_DEBUG
printf("setVBEMode failed to set mode %d (%dx%d) with error #%d\n",
mode, minfo.XResolution, minfo.YResolution, err);
sleep(2); //Azi: i suppose the same as above.
#endif
break;
}
if ( minfo.BitsPerPixel == 8 )
{
VBEPalette palette;
setupPalette( &palette, appleClut8 );
setupPalette( &palette, appleClut8 ); //Azi:autoresolution - check this stuff, appleClut8
if ((err = setVBEPalette(palette)) != errSuccess)
{
break;
bootArgs->Video.v_depth = minfo.BitsPerPixel;
bootArgs->Video.v_rowBytes = minfo.BytesPerScanline;
bootArgs->Video.v_baseAddr = VBEMakeUInt32(minfo.PhysBasePtr);
/* Azi: keep this or i keep forgeting ??????
#if AUTORES_DEBUG
gui.screen.mm= minfo.MemoryModel;
gui.screen.attr= minfo.ModeAttributes;
#endif*/
//Azi: mm & attr info on DebugInfo - from autoResolution branch.
getBoolForKey(kDebugInfoKey, &debugInfo, &bootInfo->bootConfig);
if (debugInfo && showBootBanner)
{
gui.screen.mm = minfo.MemoryModel;
gui.screen.attr = minfo.ModeAttributes;
}
}
while ( 0 );
//==========================================================================
// getNumberArrayFromProperty
static int
getNumberArrayFromProperty( const char * propKey,
//static //Azi:autoresolution
int getNumberArrayFromProperty( const char * propKey,
unsigned long numbers[],
unsigned long maxArrayCount )
{
{
unsigned long params[4];
int count;
int err = errSuccess;
int err = errSuccess; // = 0
if ( mode == GRAPHICS_MODE )
{
if ( (err=initGraphicsMode ()) == errSuccess ) {
if (gVerboseMode) {
// Tell the kernel to use text mode on a linear frame buffer display
bootArgs->Video.v_display = FB_TEXT_MODE;
} else {
bootArgs->Video.v_display = GRAPHICS_MODE;
if ( (err = initGraphicsMode() ) == errSuccess )
{
if (gVerboseMode)
{
// Tell the kernel to use text mode on a linear frame buffer display
bootArgs->Video.v_display = FB_TEXT_MODE;
}
else
{
bootArgs->Video.v_display = GRAPHICS_MODE;
}
}
}
}
if ( (mode == VGA_TEXT_MODE) || (err != errSuccess) )
{
count = getNumberArrayFromProperty( kTextModeKey, params, 2 );
count = getNumberArrayFromProperty( kTextModeKey, params, 2 );
if ( count < 2 )
{
params[0] = 80; // Default text mode is 80x25.
params[1] = 25;
}
setVESATextMode( params[0], params[1], 4 );
setVESATextMode( params[0], params[1], 4 );
bootArgs->Video.v_display = VGA_TEXT_MODE;
}
currentIndicator = 0;
//printf("Res: %dx%d (setvm: gsw/h final?)\n", gui.screen.width, gui.screen.height);
currentIndicator = 0;
}
void getGraphicModeParams(unsigned long params[]) {
{
lastTickTime = currentTickTime;
}
if (getVideoMode() == VGA_TEXT_MODE)
{
if (currentIndicator >= sizeof(indicator))
{
if ( getVideoMode() == VGA_TEXT_MODE )
{
putc(' ');
putc(' ');
putc('\b');
}
}
branches/azimutz/Chazi/i386/boot2/graphic_utils.h
99
1010
1111
12
1312
1413
1514
#ifndef GRAPHIC_UTILS_H
#define GRAPHIC_UTILS_H
#include "boot.h"
typedef union {
branches/azimutz/Chazi/i386/boot2/graphics.h
77
88
99
10
11
12
13
14
1510
1611
1712
13
14
15
16
17
18
19
1820
1921
2022
......
3739
3840
3941
42
43
44
45
4046
4147
4248
49
50
51
52
53
54
55
56
57
58
4359
4460
4561
*
*/
#include "boot.h"
#include "bootstruct.h"
#include "graphic_utils.h"
#ifndef __BOOT_GRAPHICS_H
#define __BOOT_GRAPHICS_H
//#include "libsaio.h"
//#include "bootstruct.h"
//#include "boot.h"
#include "saio_types.h"
#include "graphic_utils.h"
#include "vbe.h"
#define DEFAULT_SCREEN_WIDTH 1024
#define DEFAULT_SCREEN_HEIGHT 768
int loadEmbeddedPngImage(uint8_t *pngData, int pngSize, uint16_t *width, uint16_t *height, uint8_t **imageData);
//Azi:autoresolution ??
int getNumberArrayFromProperty( const char * propKey,
unsigned long numbers[],
unsigned long maxArrayCount );
char *getVBEInfoString();
char *getVBEModeInfoString();
//Azi:autoresolution ??
unsigned short getVESAModeWithProperties( unsigned short width,
unsigned short height,
unsigned char bitsPerPixel,
unsigned short attributesSet,
unsigned short attributesClear,
VBEModeInfoBlock * outModeInfo,
unsigned short * vesaVersion );
void getGraphicModeParams(unsigned long params[]);
#endif /* !__BOOT_GRAPHICS_H */
branches/azimutz/Chazi/i386/boot2/drivers.c
3333
3434
3535
36
37
38
3639
37
38
3940
40
4141
42
43
4442
4543
4644
......
7068
7169
7270
73
71
7472
7573
7674
......
8583
8684
8785
88
86
8987
9088
9189
......
109107
110108
111109
112
113
110
111
114112
115113
116114
......
162160
163161
164162
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
255262
256263
257264
......
260267
261268
262269
263
264
270
271
265272
266
267
268
269
270
271
272
273
274
275
276
277
278
279
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
280296
281297
282298
......
294310
295311
296312
297
313
298314
299315
300316
......
305321
306322
307323
324
308325
309326
310327
......
397414
398415
399416
400
401
417
418
402419
403420
404421
......
798815
799816
800817
801
818
802819
803820
804821
#include <libkern/OSByteOrder.h>
#include <mach/machine.h>
//#include "bootstruct.h"
//#include "ramdisk.h"
#include "boot.h"
#include "sl.h"
#include "boot.h"
#include "bootstruct.h"
#include "xml.h"
#include "ramdisk.h"
//extern char gMacOSVersion[8];
struct Module {
struct Module *nextModule;
long willLoad;
unsigned long signature1;
unsigned long signature2;
unsigned long length;
unsigned long adler32;
unsigned long alder32;
unsigned long version;
unsigned long numDrivers;
unsigned long reserved1;
long (*LoadExtraDrivers_p)(FileLoadDrivers_t FileLoadDrivers_p);
/*static*/ unsigned long Adler32( unsigned char * buffer, long length );
static unsigned long Alder32( unsigned char * buffer, long length );
static long FileLoadDrivers(char *dirSpec, long plugin);
static long NetLoadDrivers(char *dirSpec);
static char * gTempSpec;
static char * gFileName;
/*static*/ unsigned long
Adler32( unsigned char * buffer, long length )
static unsigned long
Alder32( unsigned char * buffer, long length )
{
long cnt;
unsigned long result, lowHalf, highHalf;
long LoadDrivers( char * dirSpec )
{
char dirSpecExtra[1024];
if ( InitDriverSupport() != 0 )
return 0;
// Load extra drivers if a hook has been installed.
if (LoadExtraDrivers_p != NULL)
{
(*LoadExtraDrivers_p)(&FileLoadDrivers);
}
if ( gBootFileType == kNetworkDeviceType )
{
if (NetLoadDrivers(dirSpec) != 0) {
error("Could not load drivers from the network\n");
return -1;
}
}
else if ( gBootFileType == kBlockDeviceType )
{
// First try to load Extra extensions from the ramdisk if isn't aliased as bt(0,0).
if (gRAMDiskVolume && !gRAMDiskBTAliased)
{
strcpy(dirSpecExtra, "rd(0,0)/Extra/");
FileLoadDrivers(dirSpecExtra, 0);
}
// Next try to load Extra extensions from the selected root partition.
strcpy(dirSpecExtra, "/Extra/");
if (FileLoadDrivers(dirSpecExtra, 0) != 0)
{
// If failed, then try to load Extra extensions from the boot partition
// in case we have a separate booter partition or a bt(0,0) aliased ramdisk.
if ( !(gBIOSBootVolume->biosdev == gBootVolume->biosdev && gBIOSBootVolume->part_no == gBootVolume->part_no)
|| (gRAMDiskVolume && gRAMDiskBTAliased) )
{
// Next try a specfic OS version folder ie 10.5
sprintf(dirSpecExtra, "bt(0,0)/Extra/%s/", &gMacOSVersion);
if (FileLoadDrivers(dirSpecExtra, 0) != 0)
{
// Next we'll try the base
strcpy(dirSpecExtra, "bt(0,0)/Extra/");
FileLoadDrivers(dirSpecExtra, 0);
}
}
}
// Also try to load Extensions from boot helper partitions.
if (gBootVolume->flags & kBVFlagBooter)
{
strcpy(dirSpecExtra, "/com.apple.boot.P/System/Library/");
if (FileLoadDrivers(dirSpecExtra, 0) != 0)
{
strcpy(dirSpecExtra, "/com.apple.boot.R/System/Library/");
if (FileLoadDrivers(dirSpecExtra, 0) != 0)
{
strcpy(dirSpecExtra, "/com.apple.boot.S/System/Library/");
FileLoadDrivers(dirSpecExtra, 0);
}
}
}
if (gMKextName[0] != '\0')
{
verbose("LoadDrivers: Loading from [%s]\n", gMKextName);
if ( LoadDriverMKext(gMKextName) != 0 )
{
error("Could not load %s\n", gMKextName);
return -1;
}
}
else
{
strcpy(gExtensionsSpec, dirSpec);
strcat(gExtensionsSpec, "System/Library/");
FileLoadDrivers(gExtensionsSpec, 0);
}
}
else
{
return 0;
}
MatchPersonalities();
MatchLibraries();
LoadMatchedModules();
return 0;
chardirSpecExtra[128];
const char *override_pathfolder = NULL; // full path to a folder.
intfd = 0, len = 0;
if ( InitDriverSupport() != 0 )
return 0;
// Load extra drivers if a hook has been installed.
if (LoadExtraDrivers_p != NULL)
{
(*LoadExtraDrivers_p)(&FileLoadDrivers);
}
if ( gBootFileType == kNetworkDeviceType )
{
if (NetLoadDrivers(dirSpec) != 0)
{
error("Could not load drivers from the network\n");
return -1;
}
}
else if ( gBootFileType == kBlockDeviceType )
{
// Take in account user overriding. - does this still work ???
if (getValueForKey(kAltExtensionsKey, &override_pathfolder, &len, &bootInfo->bootConfig))
{
// Specify a path to a folder, ending with / e.g. kext=/Extra/testkext/
strcpy(dirSpecExtra, override_pathfolder);
fd = FileLoadDrivers(dirSpecExtra, 0);
if (fd >= 0) goto success_fd;
}
// No need to specify (gRAMDiskVolume && !gRAMDiskBTAliased).
// First try to load Extra extensions from a ramdisk if isn't aliased as bt(0,0).
strcpy(dirSpecExtra, "rd(0,0)/"); // check it's "root".
fd = FileLoadDrivers(dirSpecExtra, 0);
if (fd >= 0) goto success_fd;
// Also no need to specify (gRAMDiskVolume && gRAMDiskBTAliased); checking paths on a
// ramdisk aliased as bt(0,0) (rdbt), is the same as checking paths on booter volume.
// In this case the following two will point to the ramdisk.
// Check booter volume/rdbt Extra for specific OS files, on specific OS folders.
sprintf(dirSpecExtra, "bt(0,0)/Extra/%s/", &gMacOSVersion);
fd = FileLoadDrivers(dirSpecExtra, 0);
if (fd >= 0) goto success_fd;
// Removed /Extra path from search algo. If needed can be specified with override key!
// Check booter volume/rdbt Extra in case we don't keep specific OS folders.
strcpy(dirSpecExtra, "bt(0,0)/Extra/");
fd = FileLoadDrivers(dirSpecExtra, 0);
if (fd >= 0) goto success_fd;
// Also try to load Extensions from boot helper partitions.
if (gBootVolume->flags & kBVFlagBooter)
{
strcpy(dirSpecExtra, "/com.apple.boot.P/System/Library/");
if (FileLoadDrivers(dirSpecExtra, 0) != 0)
{
strcpy(dirSpecExtra, "/com.apple.boot.R/System/Library/");
if (FileLoadDrivers(dirSpecExtra, 0) != 0)
{
strcpy(dirSpecExtra, "/com.apple.boot.S/System/Library/");
FileLoadDrivers(dirSpecExtra, 0);
}
}
}
success_fd:
// if user initialized gMKextName ("MKext Cache" flag)...
if (gMKextName[0] != '\0')
{
verbose("LoadDrivers: Loading from [%s]\n", gMKextName);
if ( LoadDriverMKext(gMKextName) != 0 )
{
error("Could not load %s\n", gMKextName);
return -1;
}
}
else // else load kext cache from default paths.
{
strcpy(gExtensionsSpec, dirSpec); // = "/"
strcat(gExtensionsSpec, "System/Library/"); // "/" + "System/Library/"
FileLoadDrivers(gExtensionsSpec, 0); // "/System/Library/" - legacy path
}
}
else
{
return 0;
}
MatchPersonalities();
MatchLibraries();
LoadMatchedModules();
return 0;
}
//==========================================================================
static long
FileLoadMKext( const char * dirSpec, const char * extDirSpec )
{
long ret, flags, time, time2;
char altDirSpec[512];
longret, flags, time, time2;
charaltDirSpec[512];
sprintf (altDirSpec, "%s%s", dirSpec, extDirSpec);
ret = GetFileInfo(altDirSpec, "Extensions.mkext", &flags, &time);
if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeFlat))
{
ret = GetFileInfo(dirSpec, "Extensions", &flags, &time2);
if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeDirectory) ||
(((gBootMode & kBootModeSafe) == 0) && (time == (time2 + 1))))
{
sprintf(gDriverSpec, "%sExtensions.mkext", altDirSpec);
verbose("LoadDrivers: Loading from [%s]\n", gDriverSpec);
if (LoadDriverMKext(gDriverSpec) == 0) return 0;
}
}
return -1;
sprintf (altDirSpec, "%s%s", dirSpec, extDirSpec);
ret = GetFileInfo(altDirSpec, "Extensions.mkext", &flags, &time);
msglog("(%s) Extensions.mkext time = %d\n", __FUNCTION__, time);
if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeFlat))
{
ret = GetFileInfo(dirSpec, "Extensions", &flags, &time2);
//Azi: hum... finaly got it :P
verbose("(%s) Extensions time +1 = %d\n", __FUNCTION__, time2 + 1);
if ((ret != 0)
|| ((flags & kFileTypeMask) != kFileTypeDirectory)
|| (((gBootMode & kBootModeSafe) == 0) && (time == (time2 + 1))))
{
sprintf(gDriverSpec, "%sExtensions.mkext", altDirSpec);
//Azi: hum... finaly got it :P
msglog("LoadDrivers: Loading from [%s]\n", gDriverSpec);
if (LoadDriverMKext(gDriverSpec) == 0)
return 0;
}
}
return -1;
}
//==========================================================================
{
// First try 10.6's path for loading Extensions.mkext.
if (FileLoadMKext(dirSpec, "Caches/com.apple.kext.caches/Startup/") == 0)
return 0;
return 0; // "bt(0,0)/Extra/10.6/"
// Next try the legacy path.
else if (FileLoadMKext(dirSpec, "") == 0)
index = 0;
while (1) {
ret = GetDirEntry(dirSpec, &index, &name, &flags, &time);
if (ret == -1) break;
if (( GetPackageElement(signature1) != kDriverPackageSignature1) ||
( GetPackageElement(signature2) != kDriverPackageSignature2) ||
( GetPackageElement(length) > kLoadSize ) ||
( GetPackageElement(adler32) !=
Adler32((unsigned char *)&package->version, GetPackageElement(length) - 0x10) ) )
( GetPackageElement(alder32) !=
Alder32((unsigned char *)&package->version, GetPackageElement(length) - 0x10) ) )
{
return -1;
}
return -1;
}
if (OSSwapBigToHostInt32(kernel_header->adler32) !=
Adler32(binary, uncompressed_size)) {
Alder32(binary, uncompressed_size)) {
printf("adler mismatch\n");
return -1;
}
branches/azimutz/Chazi/i386/boot2/mboot.c
22
33
44
5
5
6
67
7
8
8
99
1010
1111
......
344344
345345
346346
347
347
348348
349349
350350
351351
352352
353
353
354354
355
355356
356357
357358
File added by David F. Elliott <dfe@cox.net> on 2007/06/26
*/
#include "libsaio.h"
//#include "libsaio.h"
//#include "bootstruct.h"
#include "boot.h"
#include "bootstruct.h"
#include "memory.h"
#include "mboot.h"
int multiboot_timeout=0;
bootArgs = NULL;
return bootdevice;
}
/* declared on gui.h - moved to boot.h
enum {
kReturnKey = 0x0d,
kEscapeKey = 0x1b,
kBackspaceKey = 0x08,
kASCIIKeyMask = 0x7f
};
};*/
//Azi:reminder
// This is the meat of our implementation. It grabs the boot device from
// the multiboot_info and returns it as is. If it fails it returns
// BAD_BOOT_DEVICE. We can call an awful lot of libsa and libsaio but
branches/azimutz/Chazi/i386/boot2/prompt.c
3232
3333
3434
35
36
37
3538
3639
3740
"Build date: " I386BOOT_BUILDDATE "\n"
"%dMB memory\n";
char bootLogBanner[] = "\nChameleon v" I386BOOT_CHAMELEONVERSION " r" I386BOOT_CHAMELEONREVISION "\n"
"Build date: " I386BOOT_BUILDDATE "\n\n";
char bootPrompt[] =
"Press Enter to start up Darwin/x86 with no options, or you can:\n"
" Type -v and press Enter to start up with diagnostic messages\n"
branches/azimutz/Chazi/i386/boot2/mboot.h
11
2
23
34
45
/* File added by David F. Elliott <dfe@cox.net> on 2007/06/27 */
#include "multiboot.h"
/*
branches/azimutz/Chazi/i386/boot2/resume.c
77
88
99
10
11
10
11
12
1213
1314
14
15
1615
1716
1817
......
139138
140139
141140
142
143
141
142
143
144
145
144146
145
146
147
148
147149
148150
149151
*
*/
#include "saio_internal.h"
#include "libsa.h"
//#include "libsa.h"
//#include "bootstruct.h"
#include "boot.h"
#include "IOHibernatePrivate.h"
#include "memory.h"
#include "bootstruct.h"
#include "boot.h"
#include "pci.h"
extern int previewTotalSectors;
mem_base = getmemorylimit() - allocSize;//TODO: lower this
printf("mem_base %x\n", mem_base);
// Rek : hibernate fix
if (!((long long)mem_base+allocSize<1024*bootInfo->extmem+0x100000))
// Rek : hibernate fix
// http://www.insanelymac.com/forum/index.php?s=&showtopic=225766&view=findpost&p=1598473
// http://www.insanelymac.com/forum/index.php?s=&showtopic=225766&view=findpost&p=1598502
//Azi: ??? - check Mek's!
if ( (long long)mem_base + allocSize < 1024*bootInfo->extmem + 0x100000 )
{
printf ("Not enough space to restore image. Press any key to proceed with normal boot.\n");
getc ();
printf("Not enough space to restore image. Press any key to proceed with normal boot.\n");
getc();
return;
}
branches/azimutz/Chazi/i386/boot2/boot.c
4949
5050
5151
52
5253
54
55
5356
54
55
56
57
58
57
58
5959
60
6160
61
62
63
6264
6365
6466
67
68
69
70
71
6572
66
67
73
74
6875
6976
70
7177
7278
7379
74
80
7581
76
82
7783
7884
79
85
8086
8187
8288
8389
90
8491
85
86
8792
93
8894
8995
9096
......
96102
97103
98104
99
100
101
105
106
107
108
102109
103110
104111
......
132139
133140
134141
142
143
144
145
135146
136147
137148
138149
139150
140151
141
142
152
143153
144154
145155
......
151161
152162
153163
154
155
156
157
158
159
164
165
166
167
168
169
160170
161
162171
163172
164173
......
167176
168177
169178
170
179
171180
172181
173182
......
184193
185194
186195
196
197
198
187199
188
189
200
201
190202
191203
192204
193205
206
207
208
209
194210
195
211
212
213
214
215
216
217
218
219
196220
197221
198222
......
201225
202226
203227
204
228
229
230
231
205232
206233
207234
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
235
236
237
238
239
240
241
224242
225
226
227243
228244
229245
......
260276
261277
262278
263
279
264280
265281
266282
......
275291
276292
277293
294
295
296
278297
279298
280299
281300
282301
283
302
284303
285304
286305
......
293312
294313
295314
315
316
296317
297
318
319
320
321
322
323
324
325
326
327
328
298329
299330
300331
......
303334
304335
305336
306
337
307338
308339
309340
310
311
341
342
343
312344
345
346
347
348
349
350
313351
314352
315353
316
317
318
319
354
355
356
357
358
359
360
361
362
363
364
365
366
367
320368
321
322
323
324
325
326
369
327370
328
329
371
372
373
330374
331
332
333
334
335
336
337
338
375
376
377
378
379
380
339381
340382
341383
342384
343385
344
345
386
387
388
389
390
391
392
393
394
395
396
397
398
399
346400
347
348
349
350
351
401
402
403
404
405
406
407
408
352409
353
354
355
356
410
357411
358412
359413
360414
361415
362416
417
418
363419
364420
365421
366422
367423
368424
369
425
370426
371427
372428
373429
374430
375
431
376432
377433
378434
......
385441
386442
387443
388
389
390
391
392
393
394
395
396
397
398
399444
400
401
402
403
404
405
406
407
408
409
410
411
412
413
445
446
447
448
414449
415450
416451
......
420455
421456
422457
458
459
460
461
462
463
464
465
466
423467
424
425
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
426487
427
488
489
490
491
428492
429
493
494
495
496
430497
431498
432
433
499
500
501
502
503
504
505
434506
435507
436508
437
438
439
440
441
509
510
442511
443512
444513
445514
446515
447516
448
517
449518
450519
451520
......
457526
458527
459528
460
529
461530
462531
463532
......
474543
475544
476545
477
546
547
478548
479549
480550
481551
482552
483553
484
485
486
487
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
488598
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
599
600
601
602
603
528604
529
530
605
606
531607
532
533
534
535
536
537
608
609
610
611
612
613
614
538615
539
616
540617
541
542
618
619
620
543621
544622
545
546
623
624
625
626
547627
548628
629
630
549631
550632
551
633
634
635
636
637
638
639
640
641
552642
553643
554644
645
646
555647
556648
557
649
650
651
558652
559653
560654
561
655
656
657
658
659
562660
563661
564
662
663
664
665
666
565667
566668
567669
670
671
568672
569673
570
571
674
675
676
677
678
572679
573
574
680
575681
576
577
578
579
580
581
582
583
682
683
684
584685
686
585687
586
587
688
588689
589
690
590691
591692
592693
......
594695
595696
596697
597
598
599
600
601
602
603
604
605
606
607
608
698
699
700
701
702
703
704
705
706
707
708
709
609710
610711
611
712
713
714
612715
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
716
717
632718
633719
634
635720
636721
637722
638
723
639724
640725
641726
642
643
727
728
729
644730
645731
646732
......
650736
651737
652738
653
654
739
740
741
742
743
744
745
655746
656747
657
748
658749
659750
660751
661
662
663
752
753
754
664755
665756
666
667
757
758
759
668760
669761
670762
......
689781
690782
691783
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729784
730785
731786
* Reworked again by Curtis Galloway (galloway@NeXT.com)
*/
//#define DEBUG 1
//#include "bootstruct.h"
//#include "libsa.h"
#include "boot.h"
#include "bootstruct.h"
#include "fake_efi.h"
#include "sl.h"
#include "libsa.h"
#include "ramdisk.h"
//#include "io_inline.h" // Lion
#include "ramdisk.h" // bootstruct.h: memory.h instead of saio_internal.h
#include "gui.h"
#include "platform.h"
#include "modules.h"
#include "fake_efi.h"
#include "platform.h" // bootstruct.h - device_tree.h
#include "sl.h" // bootstruct.h: memory.h instead of saio_types.h
long gBootMode; /* defaults to 0 == kBootModeNormal */
bool gOverrideKernel;
//--- testing
#define PLATFORM_NAME_LEN 64
#define ROOT_PATH_LEN 256
static char gCacheNameAdler[PLATFORM_NAME_LEN + ROOT_PATH_LEN];
#define BOOT_DEVICE_PATH "\\System\\Library\\CoreServices\\boot.efi"
static char gBootKernelCacheFile[512];
static char gCacheNameAdler[64 + 256];
char *gPlatformName = gCacheNameAdler;
//---
char *gPlatformName = gCacheNameAdler; // disabled ??
char gRootDevice[512];
char gMKextName[512];
char gMacOSVersion[8];
bool gEnableCDROMRescan;
bool gScanSingleDrive;
int bvCount = 0;
int bvCount = 0; // global ?? - Slice
//intmenucount = 0;
int gDeviceCount = 0;
int gDeviceCount = 0;
BVRef bvr;
BVRef menuBVR;
//BVRef menuBVR; - doesn't seem used here
BVRef bvChain;
bool useGUI;
//static void selectBiosDevice(void);
//Azi: this doesn't match the function; matches the "Alder32" on drivers.c
static unsigned long Adler32(unsigned char *buffer, long length);
static bool checkOSVersion(const char * version);
static bool getOSVersion();
static bool gUnloadPXEOnExit = false;
/*
/*
* Default path to kernel cache file
*/
//Slice - first one for Leopard
#define kDefaultCachePathLeo "/System/Library/Caches/com.apple.kernelcaches/"
#define kDefaultCachePathSnow "/System/Library/Caches/com.apple.kext.caches/Startup/"
// OS X 10.5 & 10.4
#define kDefaultCachePath "/System/Library/Caches/com.apple.kernelcaches/kernelcache"
// OS X 10.6
#define kDefaultCachePathSnow "/System/Library/Caches/com.apple.kext.caches/Startup/kernelcache"
//==========================================================================
// Zero the BSS.
//==========================================================================
// execKernel - Load the kernel image (mach-o) and jump to its entry point.
//Azi:autoresolution
extern void initAutoRes();
extern void finishAutoRes();
static int ExecKernel(void *binary)
{
entry_t kernelEntry;
int ret;
bootArgs->kaddr = bootArgs->ksize = 0;
execute_hook("ExecKernel", (void*)binary, NULL, NULL, NULL);
//Azi: here we get to know if we have a kernel or a prelinked kernel
ret = DecodeKernel(binary,
&kernelEntry,
(char **) &bootArgs->kaddr,
// Reserve space for boot args
reserveKernBootStruct();
// Notify modules that the kernel has been decoded
execute_hook("DecodedKernel", (void*)binary, NULL, NULL, NULL);
// Load boot drivers from the specifed root path.
if (!gHaveKernelCache)
LoadDrivers("/");
//Azi: ...
// Load boot drivers from the specifed root path,
// if we don't have a prelinked kernel - check load.c 43 & 264
if (!gHaveKernelCache) {
LoadDrivers("/");
}
clearActivityIndicator();
if (gErrors) {
sleep(kBootErrorTimeout);
}
setupFakeEfi();
setupFakeEfi(); //Azi: check position on Mek (plkernel)
md0Ramdisk();
}
bool dummyVal;
//Azi: Wait=y is breaking other keys when typed "after them" at boot prompt.
// Works properly if typed in first place or used on Boot.plist.
if (getBoolForKey(kWaitForKeypressKey, &dummyVal, &bootInfo->bootConfig) && dummyVal) {
printf("Press any key to continue...");
getc();
verbose("(Wait) ");
pause();
}
usb_loop();
//autoresolution - Check if user disabled AutoResolution at the boot prompt.
// we can't check the plist here if we have AutoResolution=n there and we anabled it
// at boot prompt...?????
//getBoolForKey(kAutoResolutionKey, &gAutoResolution, &bootInfo->bootConfig);
execute_hook("Kernel Start", (void*)kernelEntry, (void*)bootArgs, NULL, NULL);// Notify modules that the kernel is about to be started
finishAutoRes();
//Azi: closing Vbios after "if (gVerboseMode)" stuff eliminates the need for setting
// AutoResolution = true above; but creates another bug when booting in TextMode with -v arg.
// Simptoms include: staring some seconds at a nicely drawn white screen, after boot prompt.
// Think i'm just going to end up removing setting gAutoResolution = false
// on closeVbios().. the more i think, the less sense it makes doing it there!!
//autoresolution - end
// If we were in text mode, switch to graphics mode.
// This will draw the boot graphics unless we are in
// verbose mode.
setVideoMode( GRAPHICS_MODE, 0 );
else
drawBootGraphics();
// Notify modules that the kernel is about to be started
execute_hook("Kernel Start", (void*)kernelEntry, (void*)bootArgs, NULL, NULL);
setupBooterLog();
finalizeBootStruct();
if (checkOSVersion("10.7")) {
// Masking out so that Lion doesn't doublefault
outb(0x21, 0xff); /* Maskout all interrupts Pic1 */
outb(0xa1, 0xff); /* Maskout all interrupts Pic2 */
// Jump to kernel's entry point. There's no going back now.
startprog( kernelEntry, bootArgs );
}
else {
// Jump to kernel's entry point. There's no going back now.
startprog( kernelEntry, bootArgsPreLion );
}
// Jump to kernel's entry point. There's no going back now.
//Azi: Lion - http://netkas.org/?p=745
// see asm.s - same stuff by DHP http://www.insanelymac.com/forum/index.php?s=&showtopic=255866&view=findpost&p=1677779
//outb(0x21, 0xff);
//outb(0xa1, 0xff);
startprog( kernelEntry, bootArgs );
// Not reached
return 0;
bool quiet;
bool firstRun = true;
bool instantMenu;
bool rescanPrompt;
bool rescanPrompt = false;
unsigned int allowBVFlags = kBVFlagSystemVolume|kBVFlagForeignBoot;
unsigned int denyBVFlags = kBVFlagEFISystem;
initKernBootStruct();
initBooterLog();
//Azi: log booter version, revision & build date, for bdmesg.
msglog(bootLogBanner);
// Setup VGA text mode.
// Not sure if it is safe to call setVideoMode() before the
// config table has been loaded. Call video_mode() instead.
#if DEBUG
printf("before video_mode\n");
printf("before video_mode\n"); //Azi: this one is not printing... i remember it did.. check trunk.
#endif
video_mode( 2 ); // 80x25 mono text mode.
#if DEBUG
// First get info for boot volume.
scanBootVolumes(gBIOSDev, 0);
bvChain = getBVChainForBIOSDev(gBIOSDev);
//Azi: initialising gBIOSBootVolume & gBootVolume for the first time.. i think!?
// also, kDefaultPartitionKey is checked here, on selectBootVolume.
setBootGlobals(bvChain);
msglog("setBootGlobals:\n Default: %d, ->biosdev: %d, ->part_no: %d ->flags: %d\n", gBootVolume, gBootVolume->biosdev, gBootVolume->part_no, gBootVolume->flags);
msglog(" bt(0,0): %d, ->biosdev: %d, ->part_no: %d ->flags: %d\n", gBIOSBootVolume, gBIOSBootVolume->biosdev, gBIOSBootVolume->part_no, gBIOSBootVolume->flags);
// Boot Volume is set as Root at this point so, pointing to Extra, /Extra or bt(0,0)/Extra
// is exactly the same.Review bt(0,0)/bla bla paths......(Reviewing...)
//Azi: works as expected but... trying this because Kernel=mach_kernel doesn't work on a
// override Boot.plist; this makes it impossible to override e.g. Kernel=bt(0,0)mach_kernel
// on the main Boot.plist, when loading kernel from ramdisk btAliased.
loadPrebootRAMDisk();
// Load boot.plist config file
status = loadSystemConfig(&bootInfo->bootConfig);
}
// Override firstRun to get to the boot menu instantly by setting "Instant Menu"=y in system config
if (getBoolForKey(kInsantMenuKey, &instantMenu, &bootInfo->bootConfig) && instantMenu) {
if (getBoolForKey(kInstantMenuKey, &instantMenu, &bootInfo->bootConfig) && instantMenu) {
firstRun = false;
}
// Loading preboot ramdisk if exists.
loadPrebootRAMDisk();
// Loading preboot ramdisk if exists.
//loadPrebootRAMDisk(); //Azi: this needs to be done before load_all_modules()
// because of btAlias...(Reviewing...)
// Intialize module system
if (init_module_system())
{
load_all_modules();
}
// Disable rescan option by default
gEnableCDROMRescan = false;
// Enable it with Rescan=y in system config
if (getBoolForKey(kRescanKey, &gEnableCDROMRescan, &bootInfo->bootConfig) && gEnableCDROMRescan) {
gEnableCDROMRescan = true;
}
// If we're loading the booter from optical media...(Reviewing...)
if (biosDevIsCDROM(gBIOSDev))
{
// ... ask the user for Rescan option by setting "Rescan Prompt"=y in system config...
if (getBoolForKey(kRescanPromptKey, &rescanPrompt, &bootInfo->bootConfig) && rescanPrompt)
{
gEnableCDROMRescan = promptForRescanOption();
}
else // ... or enable it with Rescan=y in system config.
if (getBoolForKey(kRescanKey, &gEnableCDROMRescan, &bootInfo->bootConfig) && gEnableCDROMRescan)
{
gEnableCDROMRescan = true;
}
}
// Ask the user for Rescan option by setting "Rescan Prompt"=y in system config.
rescanPrompt = false;
if (getBoolForKey(kRescanPromptKey, &rescanPrompt , &bootInfo->bootConfig) && rescanPrompt && biosDevIsCDROM(gBIOSDev)) {
gEnableCDROMRescan = promptForRescanOption();
}
//Azi: Is this a cdrom only thing?(Reviewing...)
// Enable touching a single BIOS device only if "Scan Single Drive"=y is set in system config.
if (getBoolForKey(kScanSingleDriveKey, &gScanSingleDrive, &bootInfo->bootConfig) && gScanSingleDrive) {
gScanSingleDrive = true;
if (getBoolForKey(kScanSingleDriveKey, &gScanSingleDrive, &bootInfo->bootConfig) && gScanSingleDrive)
{
scanBootVolumes(gBIOSDev, &bvCount);
}
// Create a list of partitions on device(s).
if (gScanSingleDrive) {
scanBootVolumes(gBIOSDev, &bvCount);
} else {
scanDisks(gBIOSDev, &bvCount);
}
else
{
//Azi: scanDisks uses scanBootVolumes.
scanDisks(gBIOSDev, &bvCount);
}
// Create a separated bvr chain using the specified filters.
bvChain = newFilteredBVChain(0x80, 0xFF, allowBVFlags, denyBVFlags, &gDeviceCount);
gBootVolume = selectBootVolume(bvChain);
// Intialize module system
init_module_system();
//#if DEBUG
//printf
msglog(":something...???\n Default: %d, ->biosdev: %d, ->part_no: %d ->flags: %d\n", gBootVolume, gBootVolume->biosdev, gBootVolume->part_no, gBootVolume->flags);
msglog(" bt(0,0): %d, ->biosdev: %d, ->part_no: %d ->flags: %d\n", gBIOSBootVolume, gBIOSBootVolume->biosdev, gBIOSBootVolume->part_no, gBIOSBootVolume->flags);
// getc();
//#endif
useGUI = true;
// Override useGUI default
getBoolForKey(kGUIKey, &useGUI, &bootInfo->bootConfig);
// AutoResolution - Azi: default to false
// http://forum.voodooprojects.org/index.php/topic,1227.0.html
gAutoResolution = false;
#if DEBUG
printf(" Default: %d, ->biosdev: %d, ->part_no: %d ->flags: %d\n", gBootVolume, gBootVolume->biosdev, gBootVolume->part_no, gBootVolume->flags);
printf(" bt(0,0): %d, ->biosdev: %d, ->part_no: %d ->flags: %d\n", gBIOSBootVolume, gBIOSBootVolume->biosdev, gBIOSBootVolume->part_no, gBIOSBootVolume->flags);
getc();
#endif
// Check if user enabled AutoResolution on Boot.plist...
getBoolForKey(kAutoResolutionKey, &gAutoResolution, &bootInfo->bootConfig);
// Patch the Video Bios with the extracted resolution, before initGui.
if (gAutoResolution == true)
{
initAutoRes();
}
useGUI = true;
// Override useGUI default
getBoolForKey(kGUIKey, &useGUI, &bootInfo->bootConfig);
if (useGUI && initGUI())
if (useGUI && initGUI())
{
// initGUI() returned with an error, disabling GUI.
useGUI = false;
}
setBootGlobals(bvChain);
msglog("setBootGlobals:\n Default: %d, ->biosdev: %d, ->part_no: %d ->flags: %d\n", gBootVolume, gBootVolume->biosdev, gBootVolume->part_no, gBootVolume->flags);
msglog(" bt(0,0): %d, ->biosdev: %d, ->part_no: %d ->flags: %d\n", gBIOSBootVolume, gBIOSBootVolume->biosdev, gBIOSBootVolume->part_no, gBIOSBootVolume->flags);
// Parse args, load and start kernel.
while (1) {
const char *val;
int len;
int trycache;
long flags, cachetime, kerneltime, exttime, sleeptime, time;
long flags, cachetime, kerneltime, exttime, sleeptime, time;
int ret = -1;
void *binary = (void *)kLoadAddr;
bool tryresume;
bool tryresumedefault;
bool forceresume;
bool usecache;
bool ignoreKC = false;
// additional variable for testing alternate kernel image locations on boot helper partitions.
char bootFileSpec[512];
status = getBootOptions(firstRun);
firstRun = false;
if (status == -1) continue;
status = processBootOptions();
// Status==1 means to chainboot
if ( status == 1 ) break;
// Status==-1 means that the config file couldn't be loaded or that gBootVolume is NULL
if ( status == -1 )
{
// gBootVolume == NULL usually means the user hit escape.
if(gBootVolume == NULL)
{
freeFilteredBVChain(bvChain);
if (gEnableCDROMRescan)
rescanBIOSDevice(gBIOSDev);
bvChain = newFilteredBVChain(0x80, 0xFF, allowBVFlags, denyBVFlags, &gDeviceCount);
setBootGlobals(bvChain);
setupDeviceList(&bootInfo->themeConfig);
}
continue;
}
// Other status (e.g. 0) means that we should proceed with boot.
// Turn off any GUI elements
if( bootArgs->Video.v_display == GRAPHICS_MODE )
//Azi: test (gBootVolume == NULL) - so far Ok!
// test with optical media again...?
// Turn off any GUI elements, draw background and update VRAM.
if ( bootArgs->Video.v_display == GRAPHICS_MODE )
{
gui.devicelist.draw = false;
gui.bootprompt.draw = false;
drawBackground();
updateVRAM();
}
status = processBootOptions();
//Azi: AutoResolution - closing Vbios here without restoring, causes an allocation error,
// if the user tries to boot, after a e.g."Can't find bla_kernel" msg.
// Doing it on execKernel() instead.
// Status == 1 means to chainboot
if ( status ==1 ) break;
// Find out which version mac os we're booting.
getOSVersion();
// Status == -1 means that gBootVolume is NULL. Config file is not mandatory anymore!
if ( status == -1 )
{
// gBootVolume == NULL usually means the user hit escape.(Reviewing...)
if (gBootVolume == NULL)
{
freeFilteredBVChain(bvChain);
if (gEnableCDROMRescan)
rescanBIOSDevice(gBIOSDev);
bvChain = newFilteredBVChain(0x80, 0xFF, allowBVFlags, denyBVFlags, &gDeviceCount);
setBootGlobals(bvChain);
setupDeviceList(&bootInfo->themeConfig);
}
continue;
}
// Other status (e.g. 0) means that we should proceed with boot.
if (platformCPUFeature(CPU_FEATURE_EM64T)) {
// If cpu handles 64 bit instructions...
if (platformCPUFeature(CPU_FEATURE_EM64T))
{
// use x86_64 kernel arch,...
archCpuType = CPU_TYPE_X86_64;
} else {
}
else
{
// else use i386 kernel arch.
archCpuType = CPU_TYPE_I386;
}
if (getValueForKey(karch, &val, &len, &bootInfo->bootConfig)) {
if (strncmp(val, "i386", 4) == 0) {
// If user override...
if (getValueForKey(kArchKey, &val, &len, &bootInfo->bootConfig))
{
// matches i386...
if (strncmp(val, "i386", 4) == 0)
{
// use i386 kernel arch.
archCpuType = CPU_TYPE_I386;
}
}
// Notify moduals that we are attempting to boot
execute_hook("PreBoot", NULL, NULL, NULL, NULL);
if (!getBoolForKey (kWake, &tryresume, &bootInfo->bootConfig)) {
if (!getBoolForKey (kWakeKey, &tryresume, &bootInfo->bootConfig)) {
tryresume = true;
tryresumedefault = true;
} else {
tryresumedefault = false;
}
if (!getBoolForKey (kForceWake, &forceresume, &bootInfo->bootConfig)) {
if (!getBoolForKey (kForceWakeKey, &forceresume, &bootInfo->bootConfig)) {
forceresume = false;
}
while (tryresume) {
const char *tmp;
BVRef bvr;
if (!getValueForKey(kWakeImage, &val, &len, &bootInfo->bootConfig))
if (!getValueForKey(kWakeKeyImageKey, &val, &len, &bootInfo->bootConfig))
val="/private/var/vm/sleepimage";
// Do this first to be sure that root volume is mounted
break;
if (!forceresume && ((sleeptime+3)<bvr->modTime)) {
printf ("Hibernate image is too old by %d seconds. Use ForceWake=y to override\n",bvr->modTime-sleeptime);
//Azi: no need for printf at this point - reminder
printf ("Hibernate image is too old by %d seconds. Use ForceWake=y to override.\n",bvr->modTime-sleeptime);
break;
}
HibernateBoot((char *)val);
break;
}
if(getBoolForKey(kUseKernelCache, &usecache, &bootInfo->bootConfig)) {
if (getValueForKey(kKernelCacheKey, &val, &len, &bootInfo->bootConfig)) {
strlcpy(gBootKernelCacheFile, val, len+1);
//Azi:kernelcache stuff
//Azi: avoiding having to use -f to ignore kernel cache
//Azi: ignore kernel cache but still use kext cache (E/E.mkext & S/L/E.mkext). - explain...
getBoolForKey(kIgnoreKCKey, &ignoreKC, &bootInfo->bootConfig);
if (ignoreKC)
{
verbose("KC: cache ignored by user.\n");
// make sure the damn thing get's cleaned, just in case... :)*
bzero(gBootKernelCacheFile, sizeof(gBootKernelCacheFile));
}
else if (getValueForKey(kKernelCacheKey, &val, &len, &bootInfo->bootConfig))
{
strlcpy(gBootKernelCacheFile, val, len + 1);
verbose("KC: path set by user = %s\n", gBootKernelCacheFile);
//Azi: bypass time check when user sets path ???
// cache is still ignored if time doesn't match... (e.g. usb stick)
}
else
{
// Reset cache name.
bzero(gCacheNameAdler + 64, sizeof(gCacheNameAdler) - 64);
// kextcache_main.c: Construct entry from UUID of boot volume...(reminder)
// assemble ?string? to generate adler from...
//sprintf(gCacheNameAdler + 64, "%s,%s", gRootDevice, bootInfo->bootFile);
const char *ProductName = getStringForKey("SMproductname", &bootInfo->smbiosConfig);
sprintf(gCacheNameAdler, ProductName); // well, at least the smbios.plist can be loaded this early...
// to set/get "ProductName" this early, booter needs complete rewrite!!
verbose("KC: gCacheNameAdler 1 = %s\n", gCacheNameAdler);
sprintf(gCacheNameAdler + 64, "%s", "\\System\\Library\\CoreServices\\boot.efi");
verbose("KC: gCacheNameAdler 2 = %s\n", gCacheNameAdler + 64);
sprintf(gCacheNameAdler + (64 + 38), "%s", bootInfo->bootFile);
verbose("KC: gCacheNameAdler 3 = %s\n", gCacheNameAdler + (64 + 38));
// generate adler
adler32 = Adler32((unsigned char *)gCacheNameAdler, sizeof(gCacheNameAdler));
verbose("KC: Adler32 = %08X\n", adler32);
// append arch and/or adler (checksum) to kc path...
if (gMacOSVersion[3] < '6') // change to >= for Lion?
{
sprintf(gBootKernelCacheFile, "%s.%08lX", kDefaultCachePath, adler32);
verbose("KC: adler added to path = %s\n", gBootKernelCacheFile);
}
else {
//Lion
if (checkOSVersion("10.7")) {
sprintf(gBootKernelCacheFile, "%skernelcache", kDefaultCachePathSnow);
}
// Snow Leopard
else if (checkOSVersion("10.6")) {
sprintf(gBootKernelCacheFile, "kernelcache_%s", (archCpuType == CPU_TYPE_I386) ? "i386" : "x86_64");
int lnam = sizeof(gBootKernelCacheFile) + 9; //with adler32
//Slice - TODO
/*
- but the name is longer .adler32 and more...
kernelcache_i386.E102928C.qSs0
so will opendir and scan for some files
*/
char* name;
long prev_time = 0;
struct dirstuff* cacheDir = opendir(kDefaultCachePathSnow);
while(readdir(cacheDir, (const char**)&name, &flags, &time) >= 0)
{
if(((flags & kFileTypeMask) != kFileTypeDirectory) && time > prev_time && strstr(name, gBootKernelCacheFile) && (name[lnam] != '.'))
{
sprintf(gBootKernelCacheFile, "%s%s", kDefaultCachePathSnow, name);
prev_time = time;
}
}
}
else {
// Reset cache name.
bzero(gCacheNameAdler + 64, sizeof(gCacheNameAdler) - 64);
sprintf(gCacheNameAdler + 64, "%s,%s", gRootDevice, bootInfo->bootFile);
adler32 = Adler32((unsigned char *)gCacheNameAdler, sizeof(gCacheNameAdler));
sprintf(gBootKernelCacheFile, "%s.%08lX", kDefaultCachePathLeo, adler32);
}
else
{
sprintf(gBootKernelCacheFile, "%s_%s.%08X", kDefaultCachePathSnow,
(archCpuType == CPU_TYPE_I386) ? "i386" : "x86_64", adler32);
verbose("KC: arch & adler added to path = %s\n", gBootKernelCacheFile);
}
}
}
// Check for cache file.
trycache = (usecache &&
((gBootMode & kBootModeSafe) == 0) &&
!gOverrideKernel &&
(gBootFileType == kBlockDeviceType) &&
(gMKextName[0] == '\0') &&
(gBootKernelCacheFile[0] != '\0'));
//Azi: trycache is done if...
trycache = ( ( (gBootMode & kBootModeSafe) == 0) //... we're not booting in safe mode (-x arg),
&& !gOverrideKernel // we're not overriding default kernel "name",
&& (gBootFileType == kBlockDeviceType) // we're booting from local storage device,
&& (gMKextName[0] == '\0') // "MKext Cache" key IS NOT in use, and
&& (gBootKernelCacheFile[0] != '\0') ); // gBootKernelCacheFile is populated.
// we could add the use of "kernelpatcher" to this bunch..??
verbose("Loading Darwin %s\n", gMacOSVersion);
//verbose("Loading Darwin %s\n", gMacOSVersion); //Azi: move?? to getOSVersion? :)
if (trycache) do {
if (trycache) do
{
verbose("KC: checking kernel cache (system prelinked kernel)...\n");
// if we haven't found the kernel yet, don't use the cache
ret = GetFileInfo(NULL, bootInfo->bootFile, &flags, &kerneltime);
if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeFlat)) {
trycache = 0;
if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeFlat))
{
verbose("KC: no kernel found (shouldn't happen?!?)\n");
trycache = 0; // ignore kernel cache...
break;
}
verbose("KC: kerneltime = %d\n", kerneltime);
ret = GetFileInfo(NULL, gBootKernelCacheFile, &flags, &cachetime);
if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeFlat)
|| (cachetime < kerneltime)) {
|| (cachetime < kerneltime))
{
if (cachetime <= 100) // confirm: 100 = inexistent path, -xxxxxxxxx = wrong name
// not confirming... i also get -xxxxxxxxx with inexisting prelinked kernel
verbose("KC: cachetime = %d, kernel cache path/adler is incorrect, ignoring it. ??? \n",
cachetime);
else
verbose("KC: cachetime = %d, kernel cache is older than the kernel, ignoring it.\n",
cachetime);
trycache = 0;
break;
}
verbose("KC: cachetime = %d\n", cachetime);
ret = GetFileInfo("/System/Library/", "Extensions", &flags, &exttime);
if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeDirectory)
&& (cachetime < exttime)) {
&& (cachetime < exttime))
{
verbose("KC: exttime = %d, kernel cache is older than S/L/E, ignoring it.\n", exttime);
trycache = 0;
break;
}
if (kerneltime > exttime) {
verbose("KC: exttime = %d\n", exttime);
if (kerneltime > exttime) // if S/L/E is older than the kernel...
{
verbose("KC: S/L/E is older than the kernel, matching exttime with kerneltime...\n");
exttime = kerneltime;
}
if (cachetime != (exttime + 1)) {
verbose("KC: exttime +1 = %d\n", exttime + 1);
if (cachetime != (exttime + 1))
{
verbose("KC: kernel cache time is diff from S/L/E time, ignoring it.\n");
trycache = 0;
break;
}
verbose("KC: kernel cache found and up to date, will be used.\n");
} while (0);
do {
if (trycache) {
do
{
// Load kernel cache if not ignored.
if (trycache)
{
bootFile = gBootKernelCacheFile;
verbose("Loading kernel cache %s\n", bootFile);
verbose("Loading kernel cache %s\n", bootFile);
if (checkOSVersion("10.7")) {
ret = LoadThinFatFile(bootFile, &binary);
}
else {
ret = LoadFile(bootFile);
binary = (void *)kLoadAddr;
}
ret = LoadFile(bootFile);
binary = (void *)kLoadAddr;
if (ret >= 0)
{
break;
verbose("Kernel cache did not loaded %s\n ", bootFile);
}
}
bootFile = bootInfo->bootFile;
// Try to load kernel image from alternate locations on boot helper partitions.
ret = GetFileInfo(NULL, bootFileSpec, &flags, &time);
if (ret == -1)
{
sprintf(bootFileSpec, "com.apple.boot.R/%s", bootFile);
ret = GetFileInfo(NULL, bootFileSpec, &flags, &time);
if (ret == -1)
{
sprintf(bootFileSpec, "com.apple.boot.S/%s", bootFile);
ret = GetFileInfo(NULL, bootFileSpec, &flags, &time);
if (ret == -1)
{
// Not found any alternate locations, using the original kernel image path.
strcpy(bootFileSpec, bootFile);
}
}
sprintf(bootFileSpec, "com.apple.boot.R/%s", bootFile);
ret = GetFileInfo(NULL, bootFileSpec, &flags, &time);
if (ret == -1)
{
sprintf(bootFileSpec, "com.apple.boot.S/%s", bootFile);
ret = GetFileInfo(NULL, bootFileSpec, &flags, &time);
if (ret == -1)
{
// No alternate locations found, using the original kernel image path.
strcpy(bootFileSpec, bootFile);
}
}
}
if (checkOSVersion("10.7"))
verbose("Loading kernel %s\n", bootFileSpec);
ret = LoadThinFatFile(bootFileSpec, &binary);
if (ret <= 0 && archCpuType == CPU_TYPE_X86_64)
{
//Lion, dont load kernel if haz cache
if (!trycache) {
verbose("Loading kernel %s\n", bootFileSpec);
ret = LoadThinFatFile(bootFileSpec, &binary);
if (ret <= 0 && archCpuType == CPU_TYPE_X86_64) {
archCpuType = CPU_TYPE_I386;
ret = LoadThinFatFile(bootFileSpec, &binary);
}
}
else ret = 1;
}
else {
//Snow leopard or older
verbose("Loading kernel %s\n", bootFileSpec);
ret = LoadThinFatFile(bootFileSpec, &binary);
if (ret <= 0 && archCpuType == CPU_TYPE_X86_64) {
archCpuType = CPU_TYPE_I386;
ret = LoadThinFatFile(bootFileSpec, &binary);
}
archCpuType = CPU_TYPE_I386;
ret = LoadThinFatFile(bootFileSpec, &binary);
}
} while (0);
clearActivityIndicator();
#if DEBUG
/*#if DEBUG
printf("Pausing...");
sleep(8);
#endif
if (ret <= 0) {
Azi: annoying stuff :P */
if (ret <= 0)
{
printf("Can't find %s\n", bootFile);
sleep(1);
gUnloadPXEOnExit = false;
break;
}
} else {
/* Won't return if successful. */
}
else
{
// Won't return if successful.
// Notify modules that ExecKernel is about to be called
execute_hook("ExecKernel", binary, NULL, NULL, NULL);
ret = ExecKernel(binary);
}
}
} // while (1)
// chainboot
if (status==1) {
if (getVideoMode() == GRAPHICS_MODE) {// if we are already in graphics-mode,
setVideoMode(VGA_TEXT_MODE, 0);// switch back to text mode
}
if (getVideoMode() == GRAPHICS_MODE) {// if we are already in graphics-mode,
setVideoMode(VGA_TEXT_MODE, 0);// switch back to text mode
}
}
if ((gBootFileType == kNetworkDeviceType) && gUnloadPXEOnExit) {
nbpUnloadBaseCode();
if ((gBootFileType == kNetworkDeviceType) && gUnloadPXEOnExit)
{
nbpUnloadBaseCode();
}
}
}
*/
bool checkOSVersion(const char * version)
{
return ((gMacOSVersion[0] == version[0]) && (gMacOSVersion[1] == version[1]) && (gMacOSVersion[2] == version[2]) && (gMacOSVersion[3] == version[3]));
}
bool getOSVersion()
{
bool valid = false;
config_file_t systemVersion;
const char *val;
int len;
if (!loadConfigFile("System/Library/CoreServices/SystemVersion.plist", &systemVersion))
{
valid = true;
}
else if (!loadConfigFile("System/Library/CoreServices/ServerVersion.plist", &systemVersion))
{
valid = true;
}
if (valid)
{
if (getValueForKey(kProductVersion, &val, &len, &systemVersion))
{
// getValueForKey uses const char for val
// so copy it and trim
*gMacOSVersion = '\0';
strncat(gMacOSVersion, val, MIN(len, 4));
}
else
valid = false;
}
return valid;
}
#define BASE 65521L /* largest prime smaller than 65536 */
#define NMAX 5000
// NMAX (was 5521) the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1
branches/azimutz/Chazi/i386/boot2/boot.h
2929
3030
3131
32
32
33
34
35
3336
37
38
39
3440
35
41
3642
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
43
44
45
46
47
48
49
50
6151
62
63
64
52
53
54
6555
66
67
68
69
70
71
56
57
58
59
60
61
62
63
64
65
7266
73
74
75
76
77
78
79
80
67
68
69
70
71
72
8173
82
74
75
76
8377
84
85
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
86142
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113143
114
144
115145
116
117
118
119
120
146
147
148
149
150
151
121152
122153
123154
124155
125
126
156
157
127158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
128173
129174
130175
......
133178
134179
135180
181
136182
137183
138
184
139185
186
140187
141188
142189
......
192239
193240
194241
195
196242
197243
198244
#ifndef __BOOT2_BOOT_H
#define __BOOT2_BOOT_H
#include "libsaio.h"
//Azi:
// Todo: don't include headers like boot.h on other headers, unless...!
// move keys to the headers of the files they're in, if they have it!?
// check header wrappers...
//#include "saio_internal.h" // the only one needed by boot.h it self.
#include "bootstruct.h"
/*
* Keys used in system Boot.plist
* Default names - these end with "Name" (easier to sort them).
*/
#define kGraphicsModeKey"Graphics Mode"
#define kTextModeKey"Text Mode"
#define kQuietBootKey"Quiet Boot"
#define kKernelFlagsKey"Kernel Flags"
#define kMKextCacheKey"MKext Cache"
#define kKernelNameKey"Kernel"
#define kKernelCacheKey"Kernel Cache"
#define kBootDeviceKey"Boot Device"
#define kTimeoutKey"Timeout"
#define kRootDeviceKey"rd"
#define kBootUUIDKey"boot-uuid"
#define kHelperRootUUIDKey"Root UUID"
#define kPlatformKey"platform"
#define kACPIKey"acpi"
#define kCDROMPromptKey"CD-ROM Prompt"
#define kCDROMOptionKey"CD-ROM Option Key"
#define kRescanPromptKey"Rescan Prompt"
#define kRescanKey "Rescan"
#define kScanSingleDriveKey"Scan Single Drive"
#define kInsantMenuKey"Instant Menu"
#define kDefaultKernel"mach_kernel"
#define kGUIKey"GUI"
#define kBootBannerKey"Boot Banner"
#define kWaitForKeypressKey"Wait"
#define kDefaultKernelName"mach_kernel"
#define kDefaultThemeName"Default" // revert?
/*
#define kDefaultBootPlistName"com.apple.Boot.plist"
#define kDefaultDSDTName"dsdt.aml"
#define kDefaultSMBIOSName"smbios.plist"
#define kDefaultRamdiskName"Preboot.dmg"
???*/
#define kUseAtiROM"UseAtiROM"/* ati.c */
#define kAtiConfig"AtiConfig"/* ati.c */
#define kATYbinimage"ATYbinimage"/* ati.c */
/*
* Default paths?????
*/
#define kWake"Wake"/* boot.c */
#define kForceWake"ForceWake"/* boot.c */
#define kWakeImage"WakeImage"/* boot.c */
#define kProductVersion"ProductVersion"/* boot.c */
#define karch"arch"/* boot.c */
#define kUseKernelCache"UseKernelCache"/* boot.c */
/*
* Undeclared (or undeclared here)
*/
/*
"-checkers" gui.c, getValFK;
"biosdev" mboot.c, getValFBK
"timeout" mboot.c, getValFBK
"partno" mboot.c, getValFBK
"DumpSPD" spd.c, getBollFK
*/
#define kDSDT"DSDT"/* acpi_patcher.c */
#define kDropSSDT"DropSSDT"/* acpi_patcher.c */
#define kRestartFix"RestartFix"/* acpi_patcher.c */
#define kGeneratePStates"GeneratePStates"/* acpi_patcher.c */
#define kGenerateCStates"GenerateCStates"/* acpi_patcher.c */
#define kEnableC2States"EnableC2State"/* acpi_patcher.c */
#define kEnableC3States"EnableC3State"/* acpi_patcher.c */
#define kEnableC4States"EnableC4State"/* acpi_patcher.c */
/*
* Keys used in system Boot.plist - these end with "Key".
*/
//identifier string locationtypecomment
#define kTextModeKey "Text Mode" // graphics.cgetNumberArraiFP- default 80x25 - kFlag - does it work??
//#define kProductVersionKey "ProductVersion" // options.cgetValFK- (boot.c on trunk) - reverted
#define kDeviceProperties"device-properties"/* device_inject.c */
#define kDefaultPartitionKey "Default Partition" // sys.cgetStringFK
#define kHidePartitionKey "Hide Partition" // disk.cgetValFK
#define kRenamePartitionKey "Rename Partition" // disk.cgetStringFK
#define kHidePartition"Hide Partition"/* disk.c */
#define kRenamePartition"Rename Partition"/* disk.c */
#define kInstantMenuKey "Instant Menu" // boot.cgetBoolFK
#define kQuietBootKey "Quiet Boot" // boot.cgetBoolFK- kFlag
#define kTimeoutKey "Timeout" // options.cgetIntFK
#define kThemeNameKey "Theme" // gui.cgetValFK
#define kGUIKey "GUI" // boot.cgetBoolFK
#define kBootBannerKey "Boot Banner" // options.cgetBoolFK
#define kLegacyLogoKey "Legacy Logo" // gui.cgetBoolFK- revert?
#define kDebugInfoKey "DebugInfo" // gui.c, graphics.cgetBoolFK
#define kRescanPromptKey "Rescan Prompt" // boot.cgetBoolFK- cdrom only - firstrun
#define kRescanKey "Rescan" // boot.cgetBoolFK- cdrom only?? - firstrun
#define kCDROMPromptKey "CD-ROM Prompt" // options.cgetValFK- internal??
#define kCDROMOptionKey "CD-ROM Option Key" // options.cgetIntFK- internal?? (F8)
#define kScanSingleDriveKey "Scan Single Drive" // boot.cgetBoolFK
#define kDevicePropertiesKey "device-properties" // device_inject.cgetValFK
#define kWaitForKeypressKey "Wait" // boot.cgetBoolFK
#define kAltConfigKey "config" // stringTable.cgetValFK- kFlag - hum.. handle like kFlag??
#define kCanOverrideKey "CanOverride" // stringTable.cgetBoolFK- remember -F ***
#define kRootDeviceKey "rd" // options.cprocessBootArg- kFlag
#define kBootDeviceKey "Boot Device" // options.cgetValFK- kFlag/option??????
#define kBootUUIDKey "boot-uuid" // options.cprocessBootArg- kFlag
#define kHelperRootUUIDKey "Root UUID" // options.cgetValFK- kFlag
#define kArchKey "arch" // boot.cgetValFK- kFlag - after all,
// it's to be passed via "kernel Flags" ?? - "man com.apple.Boot.plist"
#define kKernelNameKey "Kernel" // options.cgetValFK- kFlag*** bFlag ?
#define kKernelCacheKey "Kernel Cache" // boot.cgetValFK- kFlag
#define kIgnoreKCKey "ignoreKC" // boot.cgetBoolFK- testing***
#define kKernelFlagsKey "Kernel Flags" // options.cgetValFK- kFlags***
#define kKPatcherKey "PatchKernel" // kernel_patcher.cgetBoolFK
#define kAltExtensionsKey "kext" // drivers.cgetValFK
#define kMKextCacheKey "MKext Cache" // options.cgetValFK- kFlag
#define kMD0ImageKey "md0" // ramdisk.cgetValFK
#define kWakeKey "Wake" // boot.cgetBoolFK
#define kForceWakeKey "ForceWake" // boot.cgetBoolFK
#define kWakeKeyImageKey "WakeImage" // boot.cgetValFK- location???
#define kUseAtiROMKey "UseAtiROM" // ati.cgetBoolFK
#define kUseNvidiaROMKey "UseNvidiaROM" // nvidia.cgetBoolFK
#define kVBIOSKey "VBIOS" // nvidia.cgetBoolFK
#define kGraphicsModeKey "Graphics Mode" // graphics.cgetNumberArraiFP- kFlag
#define kAutoResolutionKey "AutoResolution" // boot.cgetBoolFK
#define kGraphicsEnablerKey "GraphicsEnabler" // GraphicsEnabler.cgetBoolFK
#define kDSDTKey "DSDT" // acpi_patcher.cgetValFK
#define kDropSSDTKey "DropSSDT" // acpi_patcher.cgetBoolFK
#define kRestartFixKey "RestartFix" // acpi_patcher.cgetBoolFK- revert to true?
#define kGeneratePStatesKey "GeneratePStates" // acpi_patcher.cgetBoolFK
#define kGenerateCStatesKey "GenerateCStates" // acpi_patcher.cgetBoolFK
#define kEnableC2StatesKey "EnableC2State" // acpi_patcher.cgetBoolFK
#define kEnableC3StatesKey "EnableC3State" // acpi_patcher.cgetBoolFK
#define kEnableC4StatesKey "EnableC4State" // acpi_patcher.cgetBoolFK
#define kUseMemDetectKey "UseMemDetect" // platform.cgetBoolFK
#define kSMBIOSdefaultsKey "SMBIOSdefaults" // smbios_patcher.cgetBoolFK
#define kSMBIOSKey "SMBIOS" // fake_efi.cgetValFK
//Azi: should this be changed to "SystemID"? BootHelp.txt matches SystemId
// cleaned obsolete comments on fake_efi.c, lines 500/508 & 608.
// fixed CHANGES file, lines 39/40.
#define kSystemIDKey "SystemId" // fake_efi.cgetStringFK
#define kSystemTypeKey "SystemType" // fake_efi.cgetStringFK
#define kPCIRootUIDKey "PciRoot" // pci_root.cgetValFK
#define kEthernetBuiltInKey "EthernetBuiltIn" // pci_setup.cgetBoolFK
#define kForceHPETKey "ForceHPET" // pci_setup.cgetBoolFK
#define kUSBBusFixKey "USBBusFix" // usb.cgetBoolFK- trouble! - USBLegacyOff + the other = hang
#define kEHCIacquireKey "EHCIacquire" // usb.cgetBoolFK
#define kEHCIhardKey "EHCIhard" // usb.cgetBoolFK- ??
#define kUHCIresetKey "UHCIreset" // usb.cgetBoolFK
#define kLegacyOffKey "USBLegacyOff" // usb.cgetBoolFK
#define kSMBIOSKey"SMBIOS"/* fake_efi.c */
#define kSystemID"SystemId"/* fake_efi.c */
#define kSystemType"SystemType"/* fake_efi.c */
#define kUseNvidiaROM"UseNvidiaROM"/* nvidia.c */
#define kVBIOS"VBIOS"/* nvidia.c */
#define kPCIRootUID"PCIRootUID"/* pci_root.c */
#define kEthernetBuiltIn"EthernetBuiltIn"/* pci_setup.c */
#define kGraphicsEnabler"GraphicsEnabler"/* pci_setup.c */
#define kForceHPET"ForceHPET"/* pci_setup.c */
#define kUseMemDetect"UseMemDetect" /* platform.c */
#define kSMBIOSdefaults"SMBIOSdefaults"/* smbios_patcher.c */
#define kUSBBusFix"USBBusFix"/* usb.c */
#define kEHCIacquire"EHCIacquire"/* usb.c */
#define kUHCIreset"UHCIreset"/* usb.c */
#define kLegacyOff"USBLegacyOff"/* usb.c */
#define kEHCIhard"EHCIhard"/* usb.c */
#define kDefaultPartition"Default Partition"/* sys.c */
#define kMD0Image"md0"/* ramdisk.h */
/*
* Flags to the booter or kernel
* Flags to the booter and/or kernel - these end with "Flag".
*/
#define kVerboseModeFlag"-v"
#define kSafeModeFlag"-x"
#define kIgnoreCachesFlag"-f"
#define kIgnoreBootFileFlag"-F"
#define kSingleUserModeFlag"-s"
//identifier string locationtypecomment
#define kVerboseModeFlag "-v" // options.cgetValFK- kFlag
#define kSafeModeFlag "-x" // options.cgetValFBootK & getValFK - ?? - kFlag
#define kIgnoreCachesFlag "-f" // options.cgetValFK- kFlag
#define kIgnoreBootFileFlag "-F" // options.cgetValFBootK- kFlag
#define kSingleUserModeFlag "-s" // options.cgetValFK- kFlag
/*
* Booter behavior control
*/
#define kBootTimeout -1
#define kCDBootTimeout 8
#define kBootTimeout -1
#define kCDBootTimeout 8
//Azi: place ??
enum {
kBackspaceKey = 0x08,
kTabKey = 0x09,
kReturnKey = 0x0d,
kEscapeKey = 0x1b,
kUpArrowkey = 0x4800,
kDownArrowkey = 0x5000,
kASCIIKeyMask = 0x7f,
kF2Key = 0x3c00, //Azi:autoresolution
kF5Key = 0x3f00,
kF10Key = 0x4400
};
/*
* A global set by boot() to record the device that the booter
* was loaded from.
extern long gBootMode;
extern bool sysConfigValid;
extern char bootBanner[];
extern char bootLogBanner[];
extern char bootPrompt[];
extern bool gOverrideKernel;
extern char *gPlatformName;
extern char *gPlatformName; // disabled ??
extern char gMKextName[];
extern char gMacOSVersion[];
extern char gRootDevice[];
extern bool gEnableCDROMRescan;
extern bool gScanSingleDrive;
/*
* drivers.c
*/
extern long LoadExtraDrivers(char * dirSpec);
extern long LoadDrivers(char * dirSpec);
extern long DecodeKernel(void *binary, entry_t *rentry, char **raddr, int *rsize);
branches/azimutz/Chazi/i386/boot2/modules.c
66
77
88
9
10
11
12
13
14
15
916
1017
1118
#define DEBUG_MODULES 0
#endif
//#include "boot.h"
//#include "libsa.h"
//#include "saio_internal.h"
//#include "bootstruct.h"
//#include "multiboot.h"
//#include "modules.h"
#include "boot.h"
#include "bootstruct.h"
#include "modules.h"
branches/azimutz/Chazi/i386/boot2/modules.h
44
55
66
7
8
9
710
811
912
1013
11
12
13
1414
1515
1616
*
*/
#ifndef __BOOT_MODULES_H
#define __BOOT_MODULES_H
#include <mach-o/loader.h>
#include <mach-o/nlist.h>
#ifndef __BOOT_MODULES_H
#define __BOOT_MODULES_H
#define MODULE_PATH"/Extra/modules/"
#define SYMBOLS_MODULE "Symbols.dylib"
#define VOID_SYMBOL"dyld_void_start"
branches/azimutz/Chazi/i386/boot2/bmdecompress.c
1919
2020
2121
22
2322
23
24
2425
2526
2627
*
* @APPLE_LICENSE_HEADER_END@
*/
#include "boot.h"
#include "libsa.h" // replaced boot.h
typedef uint8_t UInt8;
typedef uint16_t UInt16;
typedef int8_t SInt8;
branches/azimutz/Chazi/i386/boot2/gui.c
88
99
1010
11
1112
1213
1314
1415
1516
16
17
17
18
19
1820
1921
2022
2123
2224
23
24
25
26
27
28
29
30
31
3225
26
3327
34
35
36
3728
3829
3930
......
138129
139130
140131
141
132
142133
143134
144135
......
168159
169160
170161
171
162
163
172164
173165
174166
......
189181
190182
191183
192
193
184
185
194186
195187
196188
......
225217
226218
227219
228
220
229221
230222
231223
......
243235
244236
245237
246
238
247239
248240
249241
......
393385
394386
395387
396
388
397389
398390
399391
......
530522
531523
532524
533
525
534526
535527
536528
......
580572
581573
582574
583
575
584576
585577
586578
......
679671
680672
681673
682
683
684
685
686
687
674
675
676
677
678
679
688680
689681
690
691
682
683
684
685
686
692687
693
694
695
696
697
698
688
689
690
691
692
693
694
699695
700696
701697
702698
703
704
705
699
700
701
702
703
706704
707
708
705
706
707
708
709
710
709711
710
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
711736
712737
713738
714739
740
715741
716
742
717743
718744
719745
720
746
747
748
749
750
721751
722
752
753
723754
724755
725756
726
757
727758
728
729
730
731
732
733
734
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
735776
736777
737778
......
739780
740781
741782
783
742784
785
743786
787
744788
789
745790
791
746792
793
747794
795
796
748797
749798
750799
......
805854
806855
807856
808
809
857
858
859
860
810861
811862
812863
......
862913
863914
864915
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
882939
883940
884941
......
17921849
17931850
17941851
1795
1852
1853
17961854
17971855
1798
1799
1800
1801
1856
1857
1858
1859
1860
18021861
18031862
18041863
1805
1806
1864
1865
1866
1867
1868
1869
18071870
1808
1871
1872
18091873
1874
18101875
18111876
18121877
......
18151880
18161881
18171882
1818
1819
1883
18201884
1821
1822
1885
18231886
18241887
1825
1888
1889
18261890
1827
1891
1892
1893
18281894
18291895
18301896
1831
1832
1833
1834
1835
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
18361908
1837
1838
1839
1840
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
18411930
18421931
1843
1844
1845
1846
18471932
18481933
1849
1934
1935
18501936
18511937
18521938
1939
18531940
18541941
1855
1942
18561943
18571944
18581945
*
*/
#include "boot.h"
#include "gui.h"
#include "appleboot.h"
#include "vers.h"
#define IMG_REQUIRED -1
#define THEME_NAME_DEFAULT"Default"
static const char *theme_name = THEME_NAME_DEFAULT;
#define LOADPNG(img, alt_img) if (loadThemeImage(#img, alt_img) != 0) { return 1; }
#define VIDEO(x) (bootArgs->Video.v_ ## x)
#define vram VIDEO(baseAddr)
#ifdef EMBED_THEME
#include "art.h"
#endif
#define LOADPNG(img, alt_img) if (loadThemeImage(#img, alt_img) != 0) { return 1; }
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#define VIDEO(x) (bootArgs->Video.v_ ## x)
#define vram VIDEO(baseAddr)
int lasttime = 0; // we need this for animating maybe
static const char *theme_name = kDefaultThemeName; // #define'ed on boot.h
extern int gDeviceCount;
/*
* ATTENTION: the enum and the following array images[] MUST match !!!
*/
int imageCnt = 0;
extern intgDeviceCount;
extern intselectIndex;
//extern intselectIndex; Azi: not in use
extern MenuItem *menuItems;
static bool infoMenuNativeBoot = false;
static unsigned long screen_params[4] = {DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT, 32, 0};// here we store the used screen resolution
// here we store the used screen resolution
static unsigned long screen_params[4] = {DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT, 32, 0};
static int getImageIndexByName(const char *name)
{
int compareIndex = (upperLimit - lowerLimit) >> 1; // Midpoint
int result;
// NOTE: This algorithm assumes that the embeddedImages is sorted.
// This is currently done using the make file. If the array is every
// NOTE: This algorithm assumes that the embedded images are sorted.
// This is currently done using the make file. If the array is ever
// manualy generated, this *will* fail to work properly.
while((result = strcmp(name, embeddedImages[compareIndex].name)) != 0)
{
static int loadThemeImage(const char *image, int alt_image)
{
chardirspec[256];
chardirspec[128]; //Azi: testing
int i;
#ifdef EMBED_THEME
int e;
if (images[i].image == NULL) {
images[i].image = malloc(sizeof(pixmap_t));
}
sprintf(dirspec, "/Extra/Themes/%s/%s.png", theme_name, image);
sprintf(dirspec, "bt(0,0)/Extra/Themes/%s/%s.png", theme_name, image);
width = 0;
height = 0;
imagedata = NULL;
gui.backbuffer->width = gui.screen.width;
gui.backbuffer->height = gui.screen.height;
return 0;
}
unsigned int pixel;
intalpha;// transparency level 0 (obligue) - 255 (transparent)
uint32_t color;// color value formatted RRGGBB
int val;
int val;
/*
* Parse screen parameters
if(getDimensionForKey("countdown_pos_y", &pixel, theme, screen_height , 0 ) )
gui.countdown.pos.y = pixel;
/*
/*
* Parse devicelist parameters
*/
setupDeviceList(theme);
int initGUI(void)
{
intval;
intlen;
chardirspec[256];
getValueForKey( "Theme", &theme_name, &len, &bootInfo->bootConfig );
if ((strlen(theme_name) + 27) > sizeof(dirspec)) {
intvalW, valH, len; //Azi: messing... AR
chardirspec[128]; //Azi: testing
getValueForKey( kThemeNameKey, &theme_name, &len, &bootInfo->bootConfig );
if ((strlen(theme_name) + 27) > sizeof(dirspec))
{
return 1;
}
sprintf(dirspec, "/Extra/Themes/%s/theme.plist", theme_name);
if (loadConfigFile(dirspec, &bootInfo->themeConfig) != 0) {
sprintf(dirspec, "bt(0,0)/Extra/Themes/%s/theme.plist", theme_name);
if (loadConfigFile(dirspec, &bootInfo->themeConfig) != 0)
{
#ifdef EMBED_THEME
config_file_t*config;
config = &bootInfo->themeConfig;
if (ParseXMLFile((char *)__theme_plist, &config->dictionary) != 0) {
return 1;
}
config_file_t*config;
config = &bootInfo->themeConfig;
if (ParseXMLFile((char *)__theme_plist, &config->dictionary) != 0)
{
return 1;
}
#else
return 1;
#endif
}
// parse display size parameters
if (getIntForKey("screen_width", &val, &bootInfo->themeConfig) && val > 0) {
screen_params[0] = val;
else
{
//Azi: just messing around...
getIntForKey("screen_width", &valW, &bootInfo->themeConfig);
getIntForKey("screen_height", &valH, &bootInfo->themeConfig);
}
if (getIntForKey("screen_height", &val, &bootInfo->themeConfig) && val > 0) {
screen_params[1] = val;
// AutoResolution
if (gAutoResolution == true)
{
screen_params[0] = paramsAR[0];
screen_params[1] = paramsAR[1];
}
else
{
if (valW > 0)
{
screen_params[0] = valW;
}
if (valH > 0)
{
screen_params[1] = valH;
}
/* parse screen size parameters
if (getIntForKey("screen_width", &val, &bootInfo->themeConfig) && val > 0)
{
screen_params[0] = val;
}
if (getIntForKey("screen_height", &val, &bootInfo->themeConfig) && val > 0)
{
screen_params[1] = val;
}*/
//Azi: how about using default values? - think Azi...
}
// Initalizing GUI strucutre.
bzero(&gui, sizeof(gui_t));
// find best matching vesa mode for our requested width & height
//loadConfigFile(dirspec, &bootInfo->themeConfig); //Azi:autoresolution - check this later.
getGraphicModeParams(screen_params);
// set our screen structure with the mode width & height
gui.screen.width = screen_params[0];
gui.screen.height = screen_params[1];
PRINT("Theme resolution: %dx%d (theme.plist)\n", valW, valH);
PRINT("Found mode %dx%d in VESA Table\n", gui.screen.width, gui.screen.height);
//Azi: check why is this printing... (reloadAutoRes/debug)
// load graphics otherwise fail and return
if (loadGraphics() == 0) {
if (loadGraphics() == 0)
{
loadThemeValues(&bootInfo->themeConfig);
colorFont(&font_small, gui.screen.font_small_color);
colorFont(&font_console, gui.screen.font_console_color);
// create the screen & window buffers
if (createBackBuffer(&gui.screen) == 0) {
if (createWindowBuffer(&gui.screen) == 0) {
if (createWindowBuffer(&gui.devicelist) == 0) {
if (createWindowBuffer(&gui.bootprompt) == 0) {
if (createWindowBuffer(&gui.infobox) == 0) {
if (createWindowBuffer(&gui.menu) == 0) {
gui.logo.draw = true;
if (createBackBuffer(&gui.screen) == 0)
{
if (createWindowBuffer(&gui.screen) == 0)
{
if (createWindowBuffer(&gui.devicelist) == 0)
{
if (createWindowBuffer(&gui.bootprompt) == 0)
{
if (createWindowBuffer(&gui.infobox) == 0)
{
if (createWindowBuffer(&gui.menu) == 0)
{
#ifdef AUTORES_DEBUG
pause();
#endif
gui.logo.draw = true;
drawBackground();
// lets copy the screen into the back buffer
memcpy( gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4 );
gui.initialised = true;
return 0;
}
else printf("createWindowBuffer(&gui.menu) Failed\n");
}
else printf("createWindowBuffer(&gui.infobox) Failed\n");
}
else printf("createWindowBuffer(&gui.bootprompt) Failed\n");
}
else printf("createWindowBuffer(&gui.devicelist) Failed\n");
}
else printf("createWindowBuffer(&gui.screen) Failed\n");
}
else printf("createBackBuffer(&gui.screen) Failed\n");
}
else printf("loadGraphics() Failed\n");
return 1;
}
void drawDeviceList (int start, int end, int selection)
{
int i;
position_t p, p_prev, p_next;
inti;
booldebugInfo = false; //Azi:debuginfo
extern bool showBootBanner; //||
position_tp, p_prev, p_next;
//uint8_tmaxDevices = MIN( gui.maxdevices, menucount );
if(gui.menu.draw)
drawInfoMenuItems();
#if DEBUG
gui.debug.cursor = pos( 10, 100);
dprintf( &gui.screen, "label %s\n", param->label );
dprintf( &gui.screen, "biosdev 0x%x\n", param->biosdev );
dprintf(&gui.screen, "width %d\n", gui.screen.width);
dprintf(&gui.screen, "height %d\n", gui.screen.height);
dprintf( &gui.screen, "type 0x%x\n", param->type );
dprintf( &gui.screen, "flags 0x%x\n", param->flags );
dprintf( &gui.screen, "part_no %d\n", param->part_no );
dprintf( &gui.screen, "part_boff 0x%x\n", param->part_boff );
dprintf( &gui.screen, "part_type 0x%x\n", param->part_type );
dprintf( &gui.screen, "bps 0x%x\n", param->bps );
dprintf( &gui.screen, "name %s\n", param->name );
dprintf( &gui.screen, "type_name %s\n", param->type_name );
dprintf( &gui.screen, "modtime %d\n", param->modTime );
#endif
//Azi: make this info more accessible.
getBoolForKey(kDebugInfoKey, &debugInfo, &bootInfo->bootConfig);
if (debugInfo && showBootBanner)
{
gui.debug.cursor = pos( 10, 100);
dprintf( &gui.screen, "label: %s\n", param->label );
dprintf( &gui.screen, "biosdev: 0x%x\n", param->biosdev );
dprintf( &gui.screen, "type: 0x%x\n", param->type );
dprintf( &gui.screen, "flags: 0x%x\n", param->flags );
dprintf( &gui.screen, "part_no: %d\n", param->part_no );
dprintf( &gui.screen, "part_boff: 0x%x\n", param->part_boff );
dprintf( &gui.screen, "part_type: 0x%x\n", param->part_type );
dprintf( &gui.screen, "bps: 0x%x\n", param->bps );
dprintf( &gui.screen, "name: %s\n", param->name );
dprintf( &gui.screen, "type_name: %s\n", param->type_name );
dprintf( &gui.screen, "modtime: %d\n", param->modTime );
dprintf( &gui.screen, "width: %d\n", gui.screen.width );
dprintf( &gui.screen, "height: %d\n", gui.screen.height );
dprintf( &gui.screen, "attr: 0x%x\n", gui.screen.attr );
dprintf( &gui.screen, "mm: %d\n", gui.screen.mm );
}
}
drawDeviceIcon( param, gui.devicelist.pixmap, p, isSelected);
// loadBootGraphics
static void loadBootGraphics(void)
{
if (bootImageData != NULL) {
if (bootImageData != NULL)
{
return;
}
char dirspec[256];
if ((strlen(theme_name) + 24) > sizeof(dirspec)) {
char dirspec[128]; //Azi: testing
if ((strlen(theme_name) + 24) > sizeof(dirspec))
{
usePngImage = false;
return;
}
sprintf(dirspec, "/Extra/Themes/%s/boot.png", theme_name);
if (loadPngImage(dirspec, &bootImageWidth, &bootImageHeight, &bootImageData) != 0) {
sprintf(dirspec, "bt(0,0)/Extra/Themes/%s/boot.png", theme_name);
if (loadPngImage(dirspec, &bootImageWidth, &bootImageHeight, &bootImageData) != 0)
{
#ifdef EMBED_THEME
if ((loadEmbeddedPngImage(__boot_png, __boot_png_len, &bootImageWidth, &bootImageHeight, &bootImageData)) != 0)
if ((loadEmbeddedPngImage(__boot_png, __boot_png_len,
&bootImageWidth, &bootImageHeight, &bootImageData)) != 0)
#endif
usePngImage = false;
}
}
// drawBootGraphics
void drawBootGraphics(void)
{
int pos;
int length;
bool legacy_logo;
const char *dummyVal;
int oldScreenWidth, oldScreenHeight;
bool legacy_logo;
int pos, length, oldScreenWidth, oldScreenHeight;
uint16_t x, y;
if (getBoolForKey("Legacy Logo", &legacy_logo, &bootInfo->bootConfig) && legacy_logo) {
if (getBoolForKey(kLegacyLogoKey, &legacy_logo, &bootInfo->bootConfig) && legacy_logo)
{
usePngImage = false;
} else if (bootImageData == NULL) {
}
else if (bootImageData == NULL)
{
loadBootGraphics();
}
// parse screen size parameters
if (getIntForKey("boot_width", &pos, &bootInfo->themeConfig) && pos > 0) {
screen_params[0] = pos;
} else {
screen_params[0] = DEFAULT_SCREEN_WIDTH;
// Save current screen resolution.
oldScreenWidth = gui.screen.width;
oldScreenHeight = gui.screen.height;
//printf("Res: %dx%d (drawbg: current/old)\n", oldScreenWidth, oldScreenHeight);
// AutoResolution
if (gAutoResolution == true)
{
screen_params[0] = paramsAR[0];
screen_params[1] = paramsAR[1];
//printf("Res: %dx%d (drawbg: AR)\n", screen_params[0], screen_params[1]);
}
if (getIntForKey("boot_height", &pos, &bootInfo->themeConfig) && pos > 0) {
screen_params[1] = pos;
} else {
screen_params[1] = DEFAULT_SCREEN_HEIGHT;
else
{
// parse boot screen size parameters
if (getIntForKey("boot_width", &pos, &bootInfo->themeConfig) && pos > 0)
{
screen_params[0] = pos;
}
else
{
screen_params[0] = DEFAULT_SCREEN_WIDTH;
}
if (getIntForKey("boot_height", &pos, &bootInfo->themeConfig) && pos > 0)
{
screen_params[1] = pos;
}
else
{
screen_params[1] = DEFAULT_SCREEN_HEIGHT;
}
//Azi: and how about not using default values here? like on initGUI...
}
// Save current screen resolution.
oldScreenWidth = gui.screen.width;
oldScreenHeight = gui.screen.height;
gui.screen.width = screen_params[0];
gui.screen.height = screen_params[1];
//printf("Res: %dx%d (drawbg: gsw/h new)\n", gui.screen.width, gui.screen.height);
// find best matching vesa mode for our requested width & height
getGraphicModeParams(screen_params);
//Azi: isn't this sort of done on ExecKernel() ??
// Set graphics mode if the booter was in text mode or the screen resolution has changed.
if (bootArgs->Video.v_display == VGA_TEXT_MODE
|| (screen_params[0] != oldScreenWidth && screen_params[1] != oldScreenHeight) )
|| (screen_params[0] != oldScreenWidth && screen_params[1] != oldScreenHeight))
{
setVideoMode(GRAPHICS_MODE, 0);
}
branches/azimutz/Chazi/i386/boot2/gui.h
88
99
1010
11
12
11
12
13
1314
14
1515
1616
17
18
19
2017
2118
2219
......
3734
3835
3936
40
37
4138
4239
4340
......
4643
4744
4845
46
4947
5048
51
49
5250
5351
5452
......
9694
9795
9896
97
98
99
100
101
102
103
104
105
106
99107
100108
101109
*
*/
#include "boot.h"
#include "bootstruct.h"
#ifndef __BOOT2_GUI_H
#define __BOOT2_GUI_H
#include "graphics.h"
#include "graphic_utils.h"
#include "picopng.h"
#ifndef __BOOT2_GUI_H
#define __BOOT2_GUI_H
#define CHARACTERS_COUNT223
#define BOOT_NORMAL0
HorizontalLayout= 0,
VerticalLayout= 1,
};
/* moved to boot.h ??
enum {
kBackspaceKey= 0x08,
kTabKey= 0x09,
kUpArrowkey= 0x4800,
kDownArrowkey= 0x5000,
kASCIIKeyMask= 0x7f,
kF2Key= 0x3c00, //Azi:autoresolution
kF5Key= 0x3f00,
kF10Key= 0x4400
};
};*/
/*
* Menu item structure.
uint32_tfont_small_color;// Color for small font AARRGGBB
uint32_tfont_console_color;// Color for consle font AARRGGBB
booldraw;// Draw flag
// Azi:autoresolution
//resolution specifics
uint16_thtotal;
uint16_tvtotal;
uint16_thsyncstart;
uint16_thsyncend;
uint16_tvsyncstart;
uint16_tvsyncend;
uint8_tmm;// Azi:autoresolution - debuginfo
uint16_tattr;
} window_t;
/*
branches/azimutz/Chazi/i386/boot2/ramdisk.c
44
55
66
7
78
8
99
1010
1111
......
1616
1717
1818
19
19
2020
2121
2222
......
2525
2626
2727
28
29
28
3029
3130
3231
3332
3433
35
34
3635
37
36
3837
3938
40
39
4140
42
41
4342
4443
4544
46
47
48
49
50
51
52
53
54
55
56
57
5845
5946
6047
6148
6249
6350
64
51
6552
6653
67
54
6855
6956
7057
7158
7259
7360
74
61
7562
7663
7764
......
9178
9279
9380
94
9581
9682
9783
......
118104
119105
120106
121
107
122108
123109
124110
......
131117
132118
133119
134
120
135121
136122
137123
......
175161
176162
177163
178
164
179165
180166
181167
......
190176
191177
192178
193
179
194180
195181
196
182
197183
198184
199185
......
206192
207193
208194
209
195
210196
211197
212198
213
199
214200
215201
216202
......
223209
224210
225211
226
212
227213
228
214
229215
230216
231217
232218
233
219
234220
235221
236222
237
223
238224
239225
240226
241227
242
228
243229
244230
245231
246232
247233
248234
235
249236
250237
251
238
252239
253240
254241
......
289276
290277
291278
279
292280
293281
294282
*
*/
//#include "bootstruct.h"
#include "boot.h"
#include "bootstruct.h"
#include "multiboot.h"
#include "ramdisk.h"
bool gRAMDiskBTAliased = false;
char gRAMDiskFile[512];
// Notify OS X that a ramdisk has been setup. XNU with attach this to /dev/md0
// Notify OS X that a ramdisk has been setup. XNU will attach this to /dev/md0
void md0Ramdisk()
{
RAMDiskParam ramdiskPtr;
int fh = -1;
int len;
if(getValueForKey(kMD0Image, &override_filename, &len,
&bootInfo->bootConfig))
if (getValueForKey(kMD0ImageKey, &override_filename, &len, &bootInfo->bootConfig))
{
// Use user specified md0 file
sprintf(filename, "%s", override_filename);
fh = open(filename, 0);
if(fh < 0)
if (fh < 0)
{
sprintf(filename, "rd(0,0)/Extra/%s", override_filename);
sprintf(filename, "rd(0,0)/Extra/Postboot.img");
fh = open(filename, 0);
if(fh < 0)
if (fh < 0)
{
sprintf(filename, "/Extra/%s", override_filename);
sprintf(filename, "bt(0,0)/Extra/Postboot.img");// Check /Extra if not in rd(0,0)
fh = open(filename, 0);
}
}
}
if(fh < 0)
{
sprintf(filename, "rd(0,0)/Extra/Postboot.img");
fh = open(filename, 0);
if(fh < 0)
{
sprintf(filename, "/Extra/Postboot.img");// Check /Extra if not in rd(0,0)
fh = open(filename, 0);
}
}
if (fh >= 0)
{
verbose("Enabling ramdisk %s\n", filename);
ramdiskPtr.size = file_size(fh);
ramdiskPtr.size = file_size(fh);
ramdiskPtr.base = AllocateKernelMemory(ramdiskPtr.size);
if(ramdiskPtr.size && ramdiskPtr.base)
if (ramdiskPtr.size && ramdiskPtr.base)
{
// Read new ramdisk image contents in kernel memory.
if (read(fh, (char*) ramdiskPtr.base, ramdiskPtr.size) == ramdiskPtr.size)
{
AllocateMemoryRange("RAMDisk", ramdiskPtr.base, ramdiskPtr.size, kBootDriverTypeInvalid);
Node* node = DT__FindNode("/chosen/memory-map", false);
if(node != NULL)
if (node != NULL)
{
DT__AddProperty(node, "RAMDisk", sizeof(RAMDiskParam), (void*)&ramdiskPtr);
}
}
close(fh);
}
}
// Reset ramdisk bvr
gRAMDiskVolume = NULL;
printf("\nunmounting: done");
printf("unmounting: done\n"); //Azi: change line breaks on all mesgs...***
}
}
fh = open(param, 0);
if (fh != -1)
{
printf("\nreading ramdisk image: %s", param);
printf("reading ramdisk image: %s\n", param); //Azi: check this later...
ramDiskSize = file_size(fh);
if (ramDiskSize > 0)
if(gRAMDiskVolume == NULL)
{
umountRAMDisk();
printf("\nRamdisk contains no partitions.");
printf("Ramdisk contains no partitions.\n");
}
else
{
}
else
{
printf("\nno ramdisk config...\n");
printf("no ramdisk config...\n");
}
printf("\nmounting: done");
printf("mounting: done\n");
}
}
}
gRAMDiskBTAliased = mode;
if (mode)
{
printf("\nEnabled bt(0,0) alias.");
printf("Enabled bt(0,0) alias.\n");
}
else
{
printf("\nDisabled bt(0,0) alias.");
printf("Disabled bt(0,0) alias.\n");
}
}
{
struct multiboot_module * ramdisk_module = (void *)gRAMDiskMI->mi_mods_addr;
printf("\nfile: %s %d", gRAMDiskFile,
printf("file: %s %d\n", gRAMDiskFile,
ramdisk_module->mm_mod_end - ramdisk_module->mm_mod_start);
printf("\nalias: %s", gRAMDiskBTAliased ? "enabled" : "disabled");
printf("alias: %s\n", gRAMDiskBTAliased ? "enabled" : "disabled");
// Display ramdisk information if available.
if (getValueForKey("Info", &val, &len, &bootInfo->ramdiskConfig))
{
printf("\ninfo: %s", val);
printf("info: %s\n", val);
}
else
{
printf("\nramdisk info not available.");
printf("ramdisk info not available.\n");
}
}
else
{
printf("\nNo ramdisk mounted.");
printf("No ramdisk mounted.\n");
}
}
int loadPrebootRAMDisk()
{
mountRAMDisk("bt(0,0)/Extra/Preboot.dmg");
if (gRAMDiskMI != NULL)
{
printf("\n");
printf("\n"); // just a line break.. helps separating bdmesg***
return 0;
}
else
clearScreenRows(0, 24);
setCursorPosition(0, 0, 1);
showInfoRAMDisk();
//Azi: check Chazileon on these line breaks here***
printf("\n\nPress any key to continue.\n");
getc();
setActiveDisplayPage(0);
branches/azimutz/Chazi/i386/boot2/lzss.c
4040
4141
4242
43
43
44
4445
4546
4647
* DRI: Josh de Cesare
*/
#include <sl.h>
//#include <sl.h> // can't find this guy on the system; maybe we should stop looking for it there first!?
#include "sl.h" //Azi:???
#define N 4096 /* size of ring buffer - must be power of 2 */
#define F 18 /* upper limit for match_length */
branches/azimutz/Chazi/i386/boot2/options.c
2323
2424
2525
26
2726
2827
2928
3029
3130
31
32
3233
34
3335
3436
3537
......
3840
3941
4042
41
43
44
45
4246
4347
4448
4549
46
47
48
49
50
51
5250
5351
54
55
56
57
58
59
60
52
53
6154
6255
6356
......
178171
179172
180173
181
174
175
182176
183177
184178
......
200194
201195
202196
203
197
198
204199
205200
206201
......
267262
268263
269264
270
265
266
271267
272268
273269
......
302298
303299
304300
305
301
302
306303
307304
308305
......
320317
321318
322319
323
320
324321
325322
326323
327
324
328325
329326
330327
......
446443
447444
448445
449
446
450447
451448
452449
453450
451
452
454453
455
454
456455
457456
458457
......
674673
675674
676675
676
677
678
679
680
681
677682
678683
679684
680685
681
682
686
687
683688
684689
685690
686
687
691
692
693
688694
689695
690696
......
775781
776782
777783
778
784
785
786
779787
780788
781
789
790
791
782792
783793
784794
795
785796
786797
787798
788799
789
800
801
790802
791
803
804
805
792806
793807
794808
......
871885
872886
873887
874
875888
876889
877890
......
897910
898911
899912
900
913
901914
902915
903916
......
941954
942955
943956
944
945
957
958
959
960
946961
947
962
963
964
948965
949966
950
951
967
968
969
970
971
952972
953
973
974
975
954976
955977
956
978
979
980
957981
958
982
983
984
959985
960
986
987
988
961989
962
963
990
991
992
993
994
964995
965996
966997
967
998
999
1000
9681001
9691002
9701003
......
9801013
9811014
9821015
1016
1017
1018
1019
1020
1021
9831022
9841023
9851024
......
9911030
9921031
9931032
994
1033
9951034
9961035
9971036
......
10221061
10231062
10241063
1025
1064
10261065
10271066
10281067
......
11381177
11391178
11401179
1180
11411181
1142
1182
11431183
11441184
11451185
......
11701210
11711211
11721212
1173
1213
1214
1215
1216
1217
1218
1219
1220
11741221
1222
1223
1224
1225
1226
1227
11751228
1176
1177
1178
1179
1180
11811229
11821230
1183
1231
11841232
11851233
1234
1235
11861236
11871237
11881238
......
11911241
11921242
11931243
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
12081266
12091267
12101268
12111269
12121270
1213
1214
1271
1272
1273
1274
1275
12151276
12161277
12171278
12181279
12191280
12201281
1221
1222
1223
1282
1283
1284
1285
12241286
1225
1226
1227
1287
1288
1289
12281290
1229
12301291
12311292
1232
1233
1293
1294
12341295
1235
1236
1237
1296
1297
1298
12381299
12391300
12401301
1241
1302
1303
12421304
1243
1305
12441306
12451307
12461308
12471309
1248
1310
1311
1312
1313
12491314
1250
1251
1315
1316
1317
1318
12521319
12531320
12541321
1255
1256
1322
1323
1324
1325
1326
12571327
1258
1259
1328
1329
1330
1331
12601332
12611333
12621334
12631335
12641336
1265
1266
1267
12681337
1269
1338
1339
1340
1341
1342
1343
12701344
12711345
1272
1273
1274
1275
1276
1277
1278
1279
1280
12811346
1282
1283
1347
1348
1349
1350
12841351
12851352
12861353
12871354
12881355
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1356
1357
13091358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
13101381
13111382
13121383
......
13141385
13151386
13161387
1317
1388
13181389
13191390
13201391
......
13291400
13301401
13311402
1403
1404
1405
1406
1407
1408
13321409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
13331439
13341440
13351441
......
14101516
14111517
14121518
1413
1519
14141520
14151521
1416
1417
1418
1522
1523
1524
14191525
1420
1526
1527
14211528
14221529
14231530
14241531
14251532
1426
1427
1533
1534
1535
1536
14281537
14291538
1430
1431
1432
1539
1540
1541
1542
1543
14331544
14341545
14351546
......
14381549
14391550
14401551
1552
14411553
14421554
14431555
*/
#include "boot.h"
#include "bootstruct.h"
#include "fdisk.h"
#include "ramdisk.h"
#include "gui.h"
#include "embedded.h"
#include "pci.h"
#include "options.h"
#include "efi.h"
bool showBootBanner = true; //Azi:debuginfo
static bool shouldboot = false;
extern int multiboot_timeout;
extern BVRef bvChain;
//extern intmenucount;
extern intgDeviceCount;
//extern intgDeviceCount; //Azi: header
chargMacOSVersion[8]; //Azi: moved from boot.c ??? declared on boot.h as extern :-/
static bool getOSVersion(char *str); //||
intselectIndex = 0;
MenuItem * menuItems = NULL;
enum {
kMenuTopRow = 5,
kMenuMaxItems = 10,
kScreenLastRow = 24
};
//==========================================================================
typedef struct {
int x;
int y;
int type;
} CursorState;
static void changeCursor( int col, int row, int type, CursorState * cs )
//static //Azi:autoresolution
void changeCursor( int col, int row, int type, CursorState * cs )
{
if (cs) getCursorPositionAndType( &cs->x, &cs->y, &cs->type );
setCursorType( type );
static char booterCommand[BOOT_STRING_LEN];
static char booterParam[BOOT_STRING_LEN];
static void clearBootArgs(void)
//static //Azi:autoresolution
void clearBootArgs(void)
{
gBootArgsPtr = gBootArgs;
memset(gBootArgs, '\0', BOOT_STRING_LEN);
//==========================================================================
static void showBootPrompt(int row, bool visible)
//static //Azi:autoresolution
void showBootPrompt(int row, bool visible)
{
extern char bootPrompt[];
extern char bootRescanPrompt[];
putchar(key); // echo to screen
else
updateGraphicBootPrompt(key);
*gBootArgsPtr++ = key;
*gBootArgsPtr++ = key;
}
break;
//==========================================================================
static void showMenu( const MenuItem * items, int count,
//static //Azi:autoresolution
void showMenu( const MenuItem * items, int count,
int selection, int row, int height )
{
int i;
gMenuHeight= height;
gMenuItemCount= count;
gMenuTop= 0;
gMenuBottom= min( count, height ) - 1;
gMenuBottom= MIN( count, height ) - 1;
gMenuSelection= selection;
gMenuStart= 0;
gMenuEnd = min( count, gui.maxdevices ) - 1;
gMenuEnd = MIN( count, gui.maxdevices ) - 1;
// If the selected item is not visible, shift the list down.
gBootMode = kBootModeNormal;
addBootArg(kVerboseModeFlag);
break;
case BOOT_IGNORECACHE:
gVerboseMode = false;
gBootMode = kBootModeNormal;
addBootArg(kIgnoreCachesFlag);
//Azi: this one crossed my mind a lot of times.. nice going :)
addBootArg(kVerboseModeFlag); //Slice - if ignore cache then verbose
break;
case BOOT_SINGLEUSER:
gVerboseMode = true;
gBootMode = kBootModeNormal;
}
//==========================================================================
//Azi: autoresolution
int key;
int nextRow;
BVRef menuBVR;
bool showPrompt;
extern void reloadAutoRes();
int getBootOptions(bool firstRun)
{
int i;
int key;
int nextRow;
//int key;
//int nextRow;
int timeout;
int bvCount;
BVRef bvr;
BVRef menuBVR;
bool showPrompt, newShowPrompt, isCDROM;
//BVRef menuBVR;
//bool showPrompt;
bool newShowPrompt, isCDROM;
// Initialize default menu selection entry.
gBootVolume = menuBVR = selectBootVolume(bvChain);
int cnt;
int optionKey;
if (getValueForKey(kCDROMPromptKey, &val, &cnt, &bootInfo->bootConfig)) {
//Azi:---
if (getValueForKey(kCDROMPromptKey, &val, &cnt, &bootInfo->bootConfig))
{
prompt = malloc(cnt + 1);
strncat(prompt, val, cnt);
} else {
}
else
{
name = malloc(80);
getBootVolumeDescription(gBootVolume, name, 79, false);
prompt = malloc(256);
//Azi: too long for 80X25, GUI=n, vmware, depending on the device name (more than 5 char).
sprintf(prompt, "Press any key to start up from %s, or press F8 to enter startup options.", name);
free(name);
}
if (getIntForKey( kCDROMOptionKey, &optionKey, &bootInfo->bootConfig )) {
if (getIntForKey( kCDROMOptionKey, &optionKey, &bootInfo->bootConfig ))
{
// The key specified is a special key.
} else {
}
else
{
// Default to F8.
optionKey = 0x4200;
}
gui.devicelist.draw = true;
gui.redraw = true;
if (!(gBootMode & kBootModeQuiet)) {
bool showBootBanner = true;
// Check if "Boot Banner"=N switch is present in config file.
getBoolForKey(kBootBannerKey, &showBootBanner, &bootInfo->bootConfig);
printf("Use \30\31 keys to select the startup volume.");
}
showMenu( menuItems, gDeviceCount, selectIndex, kMenuTopRow + 2, kMenuMaxItems );
nextRow += min( gDeviceCount, kMenuMaxItems ) + 3;
nextRow += MIN( gDeviceCount, kMenuMaxItems ) + 3;
}
// Show the boot prompt.
/*
* TODO: this needs to be refactored.
*/
if (strcmp( booterCommand, "video" ) == 0) {
if (bootArgs->Video.v_display == GRAPHICS_MODE) {
if (strcmp( booterCommand, "video" ) == 0)
{
if (bootArgs->Video.v_display == GRAPHICS_MODE)
{
showInfoBox(getVBEInfoString(), getVBEModeInfoString());
} else {
}
else
{
printVBEModeInfo();
}
} else if ( strcmp( booterCommand, "memory" ) == 0) {
if (bootArgs->Video.v_display == GRAPHICS_MODE ) {
}
else if ( strcmp( booterCommand, "memory" ) == 0)
{
if (bootArgs->Video.v_display == GRAPHICS_MODE )
{
showInfoBox("Memory Map", getMemoryInfoString());
} else {
}
else
{
printMemoryInfo();
}
} else if (strcmp(booterCommand, "lspci") == 0) {
}
else if (strcmp(booterCommand, "lspci") == 0)
{
lspci();
} else if (strcmp(booterCommand, "more") == 0) {
}
else if (strcmp(booterCommand, "more") == 0)
{
showTextFile(booterParam);
} else if (strcmp(booterCommand, "rd") == 0) {
}
else if (strcmp(booterCommand, "rd") == 0)
{
processRAMDiskCommand(&argPtr, booterParam);
} else if (strcmp(booterCommand, "norescan") == 0) {
if (gEnableCDROMRescan) {
}
else if (strcmp(booterCommand, "norescan") == 0)
{
if (gEnableCDROMRescan)
{
gEnableCDROMRescan = false;
break;
}
} else {
}
else
{
showHelp();
}
key = 0;
clearBootArgs();
break;
// AutoResolution - Reapply the patch if Graphics Mode was incorrect
// or EDID Info was insane.
case kF2Key:
reloadAutoRes();
break;
case kF5Key:
// New behavior:
// Clear gBootVolume to restart the loop
}
break;
case kF10Key:
case kF10Key: //Azi: disable "Scan Single Drive"=y (if set) and rescan disks.
gScanSingleDrive = false;
scanDisks(gBIOSDev, &bvCount);
gBootVolume = NULL;
if (gDeviceCount) {
printf("Use \30\31 keys to select the startup volume.");
showMenu(menuItems, gDeviceCount, selectIndex, kMenuTopRow + 2, kMenuMaxItems);
nextRow += min(gDeviceCount, kMenuMaxItems) + 3;
nextRow += MIN(gDeviceCount, kMenuMaxItems) + 3;
}
showPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot);
bool uuidSet = false;
char * configKernelFlags;
char * valueBuffer;
extern void setupSmbiosConfigFile(); // test :P
valueBuffer = malloc(VALUE_SIZE);
valueBuffer = malloc(VALUE_SIZE); // 2048
skipblanks( &cp );
// trying to load the config file anyway.
else
return -1;
// Moved here to enable search for override Boot.plist on OS specific folders.
// Find out which Mac OS version we're booting.
// make sure the damn thing get's cleaned, just in case... :)*
bzero(gMacOSVersion, sizeof(gMacOSVersion)); // do this to argP ??... check it*****
getOSVersion(gMacOSVersion);
//Azi: implemented at loadOverrideConfig. ???
// Load config table specified by the user, or use the default.
//if (!getValueForBootKey(cp, "config", &val, &cnt)) {
// val = 0;
// cnt = 0;
//}
//loadSystemConfig(val, cnt); Azi:reminder
// if ( !sysConfigValid ) return -1;
if (!getValueForBootKey(cp, "config", &val, &cnt)) {
val = 0;
cnt = 0;
}
// Load com.apple.Boot.plist from the selected volume
// and use its contents to override default bootConfig.
// This is not a mandatory opeartion anymore.
// This is not a mandatory operation anymore.
loadOverrideConfig(&bootInfo->overrideConfig);
// testing ugly hack :P
setupSmbiosConfigFile("SMBIOS.plist");
// Use the kernel name specified by the user, or fetch the name
// in the config table, or use the default if not specified.
// overriding the kernel, which causes the kernelcache not
// to be used.
gOverrideKernel = false;
if (( kernel = extractKernelName((char **)&cp) )) {
strcpy( bootInfo->bootFile, kernel );
gOverrideKernel = true;
} else {
if ( getValueForKey( kKernelNameKey, &val, &cnt, &bootInfo->bootConfig ) ) {
strlcpy( bootInfo->bootFile, val, cnt+1 );
if (strcmp( bootInfo->bootFile, kDefaultKernel ) != 0) {
gOverrideKernel = true;
}
} else {
strcpy( bootInfo->bootFile, kDefaultKernel );
}
}
gOverrideKernel = false;
//Azi: setting bootFile - kernel name (path) used in common_boot()
if (( kernel = extractKernelName((char **)&cp) )) // boot prompt
{
strcpy( bootInfo->bootFile, kernel );
gOverrideKernel = true;
}
else
{
if ( getValueForKey( kKernelNameKey, &val, &cnt, &bootInfo->bootConfig ) ) // Boot.plist
{
strlcpy( bootInfo->bootFile, val, cnt+1 );
if (strcmp( bootInfo->bootFile, kDefaultKernelName ) != 0)
{
gOverrideKernel = true;
}
}
else
{
strcpy( bootInfo->bootFile, kDefaultKernelName ); // mach_kernel
}
}
cntRemaining = BOOT_STRING_LEN - 2; // save 1 for NULL, 1 for space
argP = bootArgs->CommandLine;
// Get config table kernel flags, if not ignored.
if (getValueForBootKey(cp, kIgnoreBootFileFlag, &val, &cnt) ||
!getValueForKey( kKernelFlagsKey, &val, &cnt, &bootInfo->bootConfig )) {
if (getValueForBootKey(cp, kIgnoreBootFileFlag, &val, &cnt) || // if -F arg was used...
// don't get the value/s passed by "Kernel Flags" key on "override" Boot.plist.
//Azi: test this*****
!getValueForKey( kKernelFlagsKey, &val, &cnt, &bootInfo->bootConfig ))
{
val = "";
cnt = 0;
}
configKernelFlags = malloc(cnt + 1);
strlcpy(configKernelFlags, val, cnt + 1);
if (processBootArgument(kBootUUIDKey, cp, configKernelFlags, bootInfo->config, &argP, &cntRemaining, 0)) {
// boot-uuid was set either on the command-line
// or in the config file.
// user provided a uuid... at boot prompt or override Boot.plist ??
if (processBootArgument(kBootUUIDKey/*boot-uuid*/, cp, configKernelFlags, bootInfo->config, &argP, &cntRemaining, 0))
{
// "boot-uuid" was set either on the command-line or in the config file.
uuidSet = true;
} else {
//
}
else
{
// Try an alternate method for getting the root UUID on boot helper partitions.
//
if (gBootVolume->flags & kBVFlagBooter)
{
if((loadHelperConfig(&bootInfo->helperConfig) == 0)
&& getValueForKey(kHelperRootUUIDKey, &val, &cnt, &bootInfo->helperConfig) )
if ((loadHelperConfig(&bootInfo->helperConfig) == 0) &&
getValueForKey(kHelperRootUUIDKey, &val, &cnt, &bootInfo->helperConfig) )
{
getValueForKey(kHelperRootUUIDKey, &val, &cnt, &bootInfo->helperConfig);
copyArgument(kBootUUIDKey, val, cnt, &argP, &cntRemaining);
uuidSet = true;
getValueForKey(kHelperRootUUIDKey, &val, &cnt, &bootInfo->helperConfig);
copyArgument(kBootUUIDKey/*boot-uuid*/, val, cnt, &argP, &cntRemaining);
uuidSet = true;
}
}
if (!uuidSet && gBootVolume->fs_getuuid && gBootVolume->fs_getuuid (gBootVolume, uuidStr) == 0) {
if (!uuidSet && gBootVolume->fs_getuuid && gBootVolume->fs_getuuid(gBootVolume, uuidStr) == 0)
{
verbose("Setting boot-uuid to: %s\n", uuidStr);
copyArgument(kBootUUIDKey, uuidStr, strlen(uuidStr), &argP, &cntRemaining);
copyArgument(kBootUUIDKey/*boot-uuid*/, uuidStr, strlen(uuidStr), &argP, &cntRemaining);
uuidSet = true;
}
}
if (!processBootArgument(kRootDeviceKey, cp, configKernelFlags, bootInfo->config, &argP, &cntRemaining, gRootDevice)) {
// if no rd=diskXsY key issued by user... at boot prompt or override Boot.plist ??
if (!processBootArgument(kRootDeviceKey,
cp, configKernelFlags, bootInfo->config, &argP, &cntRemaining, gRootDevice))
{
cnt = 0;
if ( getValueForKey( kBootDeviceKey, &val, &cnt, &bootInfo->bootConfig)) {
valueBuffer[0] = '*';
// try "Boot Device" key ???
if (getValueForKey(kBootDeviceKey, &val, &cnt, &bootInfo->bootConfig))
{
valueBuffer[0] = '*'; // check for rd=*uuid ???
cnt++;
strlcpy(valueBuffer + 1, val, cnt);
val = valueBuffer;
} else {
if (uuidSet) {
}
else
{
if (uuidSet)
{
val = "*uuid";
cnt = 5;
} else {
cnt = 5; // nr of characters on *uuid
}
else
{
// Don't set "rd=.." if there is no boot device key
// and no UUID.
val = "";
cnt = 0;
}
}
if (cnt > 0) {
copyArgument( kRootDeviceKey, val, cnt, &argP, &cntRemaining);
}
strlcpy( gRootDevice, val, (cnt + 1));
if (cnt > 0)
{
copyArgument(kRootDeviceKey, val, cnt, &argP, &cntRemaining);
}
strlcpy(gRootDevice, val, (cnt + 1));
}
/*
* Removed. We don't need this anymore.
*
if (!processBootArgument(kPlatformKey, cp, configKernelFlags, bootInfo->config, &argP, &cntRemaining, gPlatformName)) {
getPlatformName(gPlatformName);
copyArgument(kPlatformKey, gPlatformName, strlen(gPlatformName), &argP, &cntRemaining);
}
*/
if (!getValueForBootKey(cp, kSafeModeFlag, &val, &cnt) &&
!getValueForBootKey(configKernelFlags, kSafeModeFlag, &val, &cnt)) {
if (gBootMode & kBootModeSafe) {
!getValueForBootKey(configKernelFlags, kSafeModeFlag, &val, &cnt))
{
if (gBootMode & kBootModeSafe)
{
copyArgument(0, kSafeModeFlag, strlen(kSafeModeFlag), &argP, &cntRemaining);
}
}
// Store the merged kernel flags and boot args.
cnt = strlen(configKernelFlags);
if (cnt) {
if (cnt > cntRemaining) {
error("Warning: boot arguments too long, truncating\n");
cnt = cntRemaining;
}
strncpy(argP, configKernelFlags, cnt);
argP[cnt++] = ' ';
cntRemaining -= cnt;
}
userCnt = strlen(cp);
if (userCnt > cntRemaining) {
error("Warning: boot arguments too long, truncating\n");
userCnt = cntRemaining;
}
strncpy(&argP[cnt], cp, userCnt);
argP[cnt+userCnt] = '\0';
if(!shouldboot)
cnt = strlen(configKernelFlags);
if (cnt)
{
if (cnt > cntRemaining) {
error("Warning: boot arguments too long, truncating\n");
cnt = cntRemaining;
}
strncpy(argP, configKernelFlags, cnt);
argP[cnt++] = ' ';
cntRemaining -= cnt;
}
userCnt = strlen(cp);
if (userCnt > cntRemaining)
{
error("Warning: boot arguments too long, truncating\n");
userCnt = cntRemaining;
}
strncpy(&argP[cnt], cp, userCnt);
verbose("BootArgs = %s\n", argP); //Azi: checking...
argP[cnt+userCnt] = '\0';
verbose("BootArgs check = %s\n", argP); // ||
if (!shouldboot)
{
gVerboseMode = getValueForKey( kVerboseModeFlag, &val, &cnt, &bootInfo->bootConfig ) ||
getValueForKey( kSingleUserModeFlag, &val, &cnt, &bootInfo->bootConfig );
kBootModeSafe : kBootModeNormal;
if ( getValueForKey( kIgnoreCachesFlag, &val, &cnt, &bootInfo->bootConfig ) ) {
gBootMode = kBootModeSafe;
gBootMode = kBootModeSafe; //Azi: ??
}
}
return 0;
}
static bool getOSVersion(char *str) //Azi: moved from boot.c
{
bool valid = false;
config_file_t systemVersion;
const char *val;
int len;
if (!loadConfigFile("/System/Library/CoreServices/SystemVersion.plist", &systemVersion))
{ //Azi: so, is this path on selected or current volume?? ... clean!
valid = true;
}
else if (!loadConfigFile("/System/Library/CoreServices/ServerVersion.plist", &systemVersion))
{
valid = true;
}
if (valid)
{
if (getValueForKey("ProductVersion", &val, &len, &systemVersion))
{
// getValueForKey uses const char for val
strncat(str, val, len); //Azi: nothing better to do :P
//msglog("System Version: %s\n", str);
verbose("Loading Darwin %s\n", str);
// so copy it and trim
*str = '\0';
strncat(str, val, MIN(len, 4));
}
else
valid = false;
}
return valid;
}
//==========================================================================
// Load the help file and display the file contents on the screen.
}
}
void showTextFile(const char * filename)
void showTextFile(const char * filename) //Azi:?more
{
#define MAX_TEXT_FILE_SIZE 65536
char*buf;
intfd;
intsize;
char *buf;
int fd;
int size;
if ((fd = open_bvdev("bt(0,0)", filename, 0)) < 0) {
if ((fd = open_bvdev("bt(0,0)", filename, 0)) < 0)
{
printf("\nFile not found: %s\n", filename);
sleep(2);
return;
}
size = file_size(fd);
if (size > MAX_TEXT_FILE_SIZE) {
size = file_size(fd);
if (size > MAX_TEXT_FILE_SIZE)
{
size = MAX_TEXT_FILE_SIZE;
}
buf = malloc(size);
read(fd, buf, size);
close(fd);
buf = malloc(size);
read(fd, buf, size);
close(fd);
showTextBuffer(buf, size);
free(buf);
}
// Eventually we need to do something more user-friendly like display a menu
// based off of the Multiboot device list
//Azi: is this stuff still used for anything?? check multiboot()...
int selectAlternateBootDevice(int bootdevice)
{
int key;
branches/azimutz/Chazi/i386/doc/README
2020
2121
2222
23
23
2424
2525
2626
......
5151
5252
5353
54
54
5555
5656
5757
......
6262
6363
6464
65
65
6666
6767
6868
For DOS compatibility reason, one extra stage of boot is required if
the boot device is a hard disk. The first sector of the hard disk will
contain the MOS-DOS boot code and a boot record partition table.
contain the MS-DOS boot code and a boot record partition table.
When this sector is loaded into 0000:7C00H, it will relocate itself
to somewhere else and then load the first sector of the active
partition into 0000:7C00H. Both UNIX and DOS use the command "fdisk"
stage bootstrap loader "boot2()". In order to be able to load the
big kernel image (bigger than 512K or 640K, depends on the memory
configuration), the second stage boot loader will run on the protected
mode. This bootstarp loader does not have any stand alone device
mode. This bootstrap loader does not have any stand alone device
drivers, all the I/O's are through the BIOS calls. Since the first
stage boot code will no longer be used at this moment, the memory
location of the first stage boot code (0000:1000H to 0000:1200H) will
and boot data segments must not be greater than 64K.
The boot loader loads the kernel image at memory location above 1 MB
to skip the memory hole between 521K/640K and 1MB. After the kernel
to skip the memory hole between 512K/640K and 1MB. After the kernel
is loaded, the boot loader stores the information in the stack and
then passes control to kernel. Currently, the three information passed
from the boot loader to the kernel are type of the boot device, size
branches/azimutz/Chazi/i386/cdboot/Makefile
33
44
55
6
76
87
98
10
9
1110
1211
13
14
15
12
13
1614
17
18
15
16
1917
2018
2119
include ../MakePaths.dir
NASM = $(shell which nasm)
#/Developer/usr/bin/nasm
INSTALLDIR = $(DSTROOT)/usr/standalone/i386
DIRS_NEEDED = $(SYMROOT)
all embedtheme optionrom: $(DIRS_NEEDED) cdboot
all embedtheme: $(DIRS_NEEDED) cdboot
cdboot: cdboot.s $(SYMROOT)/boot Makefile $(NASM)
@echo "\t[NASM] cdboot.s"
@$(NASM) cdboot.s -o $(SYMROOT)/cdboot
@dd if=$(SYMROOT)/boot of=$(SYMROOT)/cdboot conv=sync bs=2k seek=1 &> /dev/null
$(NASM) cdboot.s -o $(SYMROOT)/cdboot
dd if=$(SYMROOT)/boot of=$(SYMROOT)/cdboot conv=sync bs=2k seek=1 &> /dev/null
@# Update cdboot with boot file size info
@stat -f%z $(SYMROOT)/boot \
# Update cdboot with boot file size info
stat -f%z $(SYMROOT)/boot \
| perl -ane "print pack('V',@F[0]);" \
| dd of=$(SYMROOT)/cdboot bs=1 count=4 seek=2044 conv=notrunc &> /dev/null
branches/azimutz/Chazi/i386/libsa/zalloc.c
3030
3131
3232
33
33
34
3435
3536
36
37
38
39
3740
3841
3942
......
250253
251254
252255
253
254
256
257
258
255259
256260
257261
*/
#include "libsa.h"
//#include "saio_internal.h" - Azi: needed for ZDEBUG (printf)
//#include "saio_internal.h" //Azi: needed for ZDEBUG (printf).
// Check other DEBUG's, i forgot those while messing with includes.
#include "memory.h"
#define ZDEBUG 0 //Azi: booter doesn't load with this enabled; instant reboot at "boot1: ..."
#define ZDEBUG 0
//Azi: this DEBUG is messed up; it hangs while "boot1: ..." with
// black screen on my branch and instant reboot on trunk.
#if ZDEBUG
int zout;
zcoalesce();
return;
}
static void
//Azi: static - Mek
//static
void
zallocate(char * start,int size)
{
#if ZDEBUG
branches/azimutz/Chazi/i386/libsa/qsort.c
5858
5959
6060
61
62
6163
6264
6365
64
65
6666
6767
6868
......
178178
179179
180180
181
181
182182
183
183
184184
185185
186186
#include <sys/types.h>
#include <stdlib.h>
#include "saio_types.h" //Azi: min/max
static inline char*med3 __P((char *, char *, char *, int (*)()));
static inline void swapfunc __P((char *, char *, int, int));
#define min(a, b)(a) < (b) ? a : b
/*
* Qsort routine from Bentley & McIlroy's "Engineering a Sort Function".
*/
}
pn = a + n * es;
r = min(pa - (char *)a, pb - pa);
r = MIN(pa - (char *)a, pb - pa);
vecswap(a, pb - r, r);
r = min(pd - pc, (pn - pd) - (int)es);
r = MIN(pd - pc, (pn - pd) - (int)es);
vecswap(pb, pn - r, r);
if ((r = pb - pa) > (int)es)
qsort(a, r / es, es, cmp);
branches/azimutz/Chazi/i386/libsa/Makefile
4545
4646
4747
48
49
50
51
52
53
48
49
50
5451
5552
5653
all embedtheme: $(DIRS_NEEDED) $(LIBS)
libsa.a: $(SA_OBJS)
@echo "\t[RM] $(SYMROOT)/$(@F)"
@rm -f $(SYMROOT)/$(@F)
@echo "\t[AR] $@"
@ar q $(SYMROOT)/$(@F) $^ &> /dev/null
@echo "\t[RANLIB] $@"
@ranlib $(SYMROOT)/$(@F)
rm -f $(SYMROOT)/$(@F)
ar q $(SYMROOT)/$(@F) $^
ranlib $(SYMROOT)/$(@F)
$(INSTALL_SA_DIR) $(INSTALL_MD_DIR):
$(MKDIRS) $@
branches/azimutz/Chazi/i386/util/bdmesg.c
1818
1919
2020
21
21
2222
2323
2424
io_registry_entry_t root = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/");
if (!root)
{
printf("IORegistryEntry \"IOIOService:/\" not found.\n");
printf("IORegistryEntry \"IOService:/\" not found.\n");
return 0;
}
branches/azimutz/Chazi/i386/util/Makefile
2626
2727
2828
29
30
31
32
33
34
35
36
37
38
3929
40
41
42
43
44
45
46
30
31
32
33
4734
4835
4936
50
51
52
53
54
55
56
57
58
37
38
39
40
41
42
5943
6044
6145
6246
6347
64
48
all embedtheme: $(DIRS_NEEDED) $(PROGRAMS)
dyldsymboltool: dyldsymboltool.o32 dyldsymboltool.o64
@echo "\t[LD32] $@_32"
@$(CC) $(CFLAGS) $(LDFLAGS) $(DEFINES) -arch i386 -o $(SYMROOT)/$(@F)_32 $(OBJROOT)/$(@F).o32
@echo "\t[LD64] $@_64"
@$(CC) $(CFLAGS) $(LDFLAGS) $(DEFINES) -arch x86_64 -o $(SYMROOT)/$(@F)_64 $(OBJROOT)/$(@F).o64
@echo "\t[LIPO] $@"
@lipo -create -arch i386 $(SYMROOT)/$(@F)_32 -arch x86_64 $(SYMROOT)/$(@F)_64 -output $(SYMROOT)/$(@F)
@$(RM) $(SYMROOT)/$(@F)_32 $(SYMROOT)/$(@F)_64
machOconv: machOconv.o32 machOconv.o64
@echo "\t[LD32] $@_32"
@$(CC) $(CFLAGS) $(LDFLAGS) $(DEFINES) -arch i386 -o $(SYMROOT)/$(@F)_32 $(OBJROOT)/$(@F).o32
@echo "\t[LD64] $@_64"
@$(CC) $(CFLAGS) $(LDFLAGS) $(DEFINES) -arch x86_64 -o $(SYMROOT)/$(@F)_64 $(OBJROOT)/$(@F).o64
@echo "\t[LIPO] $@"
@lipo -create -arch i386 $(SYMROOT)/$(@F)_32 -arch x86_64 $(SYMROOT)/$(@F)_64 -output $(SYMROOT)/$(@F)
@$(RM) $(SYMROOT)/$(@F)_32 $(SYMROOT)/$(@F)_64
$(CC) $(CFLAGS) $(LDFLAGS) $(DEFINES) -arch i386 -o $(SYMROOT)/$(@F)_32 $(OBJROOT)/$(@F).o32
$(CC) $(CFLAGS) $(LDFLAGS) $(DEFINES) -arch x86_64 -o $(SYMROOT)/$(@F)_64 $(OBJROOT)/$(@F).o64
lipo -create -arch i386 $(SYMROOT)/$(@F)_32 -arch x86_64 $(SYMROOT)/$(@F)_64 -output $(SYMROOT)/$(@F)
$(RM) $(SYMROOT)/$(@F)_32 $(SYMROOT)/$(@F)_64
bdmesg: bdmesg.o32 bdmesg.o64
@echo "\t[LD32] $@_32"
@$(CC) $(CFLAGS) $(LDFLAGS) -framework IOKit -framework CoreFoundation -mmacosx-version-min=10.5 \
-arch i386 -o $(SYMROOT)/$(@F)_32 $(OBJROOT)/$(@F).o32
@echo "\t[LD64] $@_64"
@$(CC) $(CFLAGS) $(LDFLAGS) -framework IOKit -framework CoreFoundation -mmacosx-version-min=10.5 \
-arch x86_64 -o $(SYMROOT)/$(@F)_64 $(OBJROOT)/$(@F).o64
@echo "\t[LIPO] $@"
@lipo -create -arch i386 $(SYMROOT)/$(@F)_32 -arch x86_64 $(SYMROOT)/$(@F)_64 -output $(SYMROOT)/$(@F)
@$(RM) $(SYMROOT)/$(@F)_32 $(SYMROOT)/$(@F)_64
$(CC) $(CFLAGS) $(LDFLAGS) -framework IOKit -framework CoreFoundation -mmacosx-version-min=10.5 \
-arch i386 -o $(SYMROOT)/$(@F)_32 $(OBJROOT)/$(@F).o32
$(CC) $(CFLAGS) $(LDFLAGS) -framework IOKit -framework CoreFoundation -mmacosx-version-min=10.5 \
-arch x86_64 -o $(SYMROOT)/$(@F)_64 $(OBJROOT)/$(@F).o64
lipo -create -arch i386 $(SYMROOT)/$(@F)_32 -arch x86_64 $(SYMROOT)/$(@F)_64 -output $(SYMROOT)/$(@F)
$(RM) $(SYMROOT)/$(@F)_32 $(SYMROOT)/$(@F)_64
include ../MakeInc.dir
#dependencies
-include $(OBJROOT)/Makedep
-include $(OBJROOT)/Makedep

Archive Download the corresponding diff file

Revision: 815