Chameleon

Chameleon Commit Details

Date:2010-10-20 23:33:49 (9 years 7 months ago)
Author:Azimutz
Commit:602
Parents: 601
Message:Mostly AutoResolution: restructure, clean, compact, etc... solve an allocation error and fix some glitches due to recente Chameleon code changes. Small code tweaks, mainly on common_boot().
Changes:
M/branches/azimutz/Chazi/i386/boot2/options.c
M/branches/azimutz/Chazi/i386/libsaio/ati_resolution.c
M/branches/azimutz/Chazi/i386/libsaio/autoresolution.h
M/branches/azimutz/Chazi/i386/boot2/graphics.c
M/branches/azimutz/Chazi/i386/boot2/boot.c
M/branches/azimutz/Chazi/i386/boot2/gui.c
M/branches/azimutz/Chazi/i386/libsaio/gma_resolution.c
M/branches/azimutz/Chazi/i386/libsaio/autoresolution.c
M/branches/azimutz/Chazi/i386/libsaio/nvidia_resolution.c

File differences

branches/azimutz/Chazi/i386/libsaio/ati_resolution.c
7878
7979
8080
81
81
8282
8383
8484
......
100100
101101
102102
103
103
104104
*x = modeTiming[idx + 1].hActive;
*y = modeTiming[idx + 1].vActive;
return TRUE;
return true;
}
bool atiSetMode_2(sModeTable * table, uint8_t idx, uint32_t* x, uint32_t* y)
*x = modeTiming[idx + 1].hActive;
*y = modeTiming[idx + 1].hActive;
return TRUE;
return true;
}
branches/azimutz/Chazi/i386/libsaio/autoresolution.c
1515
1616
1717
18
19
1820
1921
2022
......
208210
209211
210212
211
213
212214
213215
214216
......
271273
272274
273275
274
276
275277
276278
277279
......
344346
345347
346348
347
349
348350
349351
350352
......
361363
362364
363365
364
365
366
367
366368
367369
368370
......
378380
379381
380382
381
383
382384
383385
384386
385387
386388
387389
388
390
389391
390392
391393
......
404406
405407
406408
407
409
408410
409411
410412
......
462464
463465
464466
465
467
466468
467469
468470
......
513515
514516
515517
518
516519
517520
518521
......
560563
561564
562565
566
563567
564568
565569
......
599603
600604
601605
602
606
603607
604608
605609
606
610
607611
608612
609613
......
611615
612616
613617
614
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
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
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
//#include "libsaio.h"
//#include "autoresolution.h" - included on *_resolution.h
//#include "boot.h"
//#include "gui.h"
#include "nvidia_resolution.h"
#include "ati_resolution.h"
#include "gma_resolution.h"
while ( i != 0 )
{
table->id = tablesCount - i;
PRINT("New table with id : %d\n", table->id);
PRINT("New table with id: %d\n", table->id);
// opening the chain if it's the first table
if (i == tablesCount)
* Common initialisation
*/
map->hasSwitched = false;
//map->hasSwitched = false;
/*
* check if we have ATI Radeon and open atombios
{
PRINT("Unknown chipset type and unrecognized bios.\n");
PRINT("autoresolution only works with Intel 800/900 series graphic chipsets.\n");
PRINT("autoresolution only works with Intel 800/900 series graphic chipsets.\n"); //Azi:reminder
PRINT("Chipset Id: %x\n", map->chipsetId);
closeVbios(map);
{
PRINT("Closing VBios\n");
//make sure to turn autoResolution off
if (gAutoResolution == TRUE)
gAutoResolution = FALSE;
if (gAutoResolution == true)
gAutoResolution = false;
// if we saved the vBios, free the copy
if (map->biosBackupPtr != NULL)
{
if (table->backup != NULL)
{
PRINT("Table #%d : Freeing backup\t", table->id);
PRINT("Table #%d: Freeing backup\t", table->id);
FREE(table->backup);
PRINT("[OK]\n");
}
if (table != NULL)
{
PRINT("Table #%d : Freeing\t\t", table->id);
PRINT("Table #%d: Freeing\t\t", table->id);
FREE(table);
PRINT("[OK]\n");
}
void unlockVbios(vBiosMap * map)
{
map->unlocked = TRUE;
map->unlocked = true;
switch (map->chipset)
{
void relockVbios(vBiosMap * map)
{
map->unlocked = FALSE;
map->unlocked = false;
switch (map->chipset)
{
/*
* saveVbios - save the entire vBios in case the patch has to be removed
* Azi: only on Intel??
*/
void saveVbios(vBiosMap * map)
{
{
bcopy(table->backup, (uint8_t *)table->pointer, table->size);
table = table->next;
//verbose("Table/s restored...\n");
}
relockVbios(map);
}
x = map->currentX;
y = map->currentY;
PRINT("Patching Table #%d : \n", table->id);
PRINT("Patching Table #%d: \n", table->id);
map->setMode(table, i, &x, &y);
#ifdef AUTORES_DEBUG
getc();
pause();
#endif
table = table->next;
relockVbios(map);
return;
}
}
/*
void patchRes()
{
//UInt32 paramsAR[4];
paramsAR[3] = 0;
// Open the VBios and store VBios or Tables
map = openVbios(CT_UNKWN);
//Get Resolution from Graphics Mode key...
int count = getNumberArrayFromProperty(kGraphicsModeKey, paramsAR, 4);
// ... or EDID.
if (count < 3)
{
getResolution(paramsAR);
// check the DEBUG stuff... also on TEXT MODE (this is not printing).
PRINT("Resolution: %dx%d (EDID)\n",paramsAR[0], paramsAR[1]);
}
else
{
PRINT("Resolution: %dx%d (Graphics Mode key)\n",paramsAR[0], paramsAR[1]);
if ( paramsAR[2] == 256 ) paramsAR[2] = 8;
if ( paramsAR[2] == 555 ) paramsAR[2] = 16;
if ( paramsAR[2] == 888 ) paramsAR[2] = 32;
}
// If using GUI, patch the video bios with the extracted resolution,
// before initGui.
// perfom the actual VBIOS patching
if (paramsAR[0] != 0 && paramsAR[1] != 0)
{
patchVbios(map, paramsAR[0], paramsAR[1], paramsAR[2], 0, 0);
}
closeVbios(map);
//Azi: gAutoResolution was just set to false on closeVbios().
gAutoResolution = true;
if (bootArgs->Video.v_display == VGA_TEXT_MODE)
{
gui.screen.width = paramsAR[0];
gui.screen.height = paramsAR[1];
}
// If the patch is working properly, we're done. If not and it's just a matter
// of wrong resolution, we can try reapply the patch; see "case kF2Key:", options.c.
// The patch works properly but we're not using GUI; keep Vbios open and patch/close
// on drawBootGraphics().
// ??????Don't forget we┬┤re maybe using this to get correct resolution after login,
// despite having qe/ci or not...!!!!
}
void reloadRes()
{
//UInt32 paramsAR[4];
paramsAR[3] = 0;
map = openVbios(CT_UNKWN);
// Has the target Resolution Changed ?
int count = getNumberArrayFromProperty(kGraphicsModeKey, paramsAR, 4);
if ( count < 3 ) // why this? we are implicitly trying to change the resolution
// at boot prompt, using Graphics Mode flag...
{
getResolution(paramsAR);
}
else
{
if ( paramsAR[2] == 256 ) paramsAR[2] = 8;
if ( paramsAR[2] == 555 ) paramsAR[2] = 16;
if ( paramsAR[2] == 888 ) paramsAR[2] = 32;
}
// user changed resolution...
if ((paramsAR[0] != 0) && (paramsAR[1] != 0) &&
(paramsAR[0] != map->currentX) && (paramsAR[1] != map->currentY))
{
//Azi: same shit as "case kTabKey:" - check
// Go back to TEXT mode while we change the mode
if (bootArgs->Video.v_display == GRAPHICS_MODE)
{
CursorState cursorState;
setVideoMode(VGA_TEXT_MODE, 0);
setCursorPosition(0, 0, 0);
clearScreenRows(0, kScreenLastRow);
changeCursor( 0, 0, kCursorTypeHidden, &cursorState );
// Reapply patch
patchVbios(map, paramsAR[0], paramsAR[1], paramsAR[2], 0, 0);
if (useGUI && (gui.initialised == true))
initGUI();
// Make sure all values are set
if (bootArgs->Video.v_display != GRAPHICS_MODE)
bootArgs->Video.v_display = GRAPHICS_MODE;
if (!useGUI)
useGUI = true;
// redraw the background buffer
drawBackground();
gui.devicelist.draw = true;
gui.redraw = true;
if (showBootBanner)
{
// Display banner and show hardware info.
gprintf(&gui.screen, bootBanner + 1, (bootInfo->convmem + bootInfo->extmem) / 1024);
}
// redraw background
memcpy(gui.backbuffer->pixels, gui.screen.pixmap->pixels,
gui.backbuffer->width * gui.backbuffer->height * 4);
nextRow = kMenuTopRow;
showPrompt = true;
if (gDeviceCount)
{
showMenu( menuItems, gDeviceCount, selectIndex, kMenuTopRow + 2, kMenuMaxItems );
nextRow += min( gDeviceCount, kMenuMaxItems ) + 3;
}
// Show the boot prompt.
showPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot);
showBootPrompt( nextRow, showPrompt );
// this is used to avoid resetting the incorrect mode while quiting the boot menu
//map->hasSwitched = true;
}
}
closeVbios(map);
//Azi: gAutoResolution was just set to false on closeVbios.
gAutoResolution = true;
}*/
branches/azimutz/Chazi/i386/libsaio/autoresolution.h
1616
1717
1818
19
20
2119
2220
2321
2422
23
24
2525
2626
2727
......
4242
4343
4444
45
46
45
46
4747
4848
4949
50
5051
5152
5253
......
114115
115116
116117
117
118
118119
119120
120121
......
146147
147148
148149
150
151
152
149153
#ifndef __915_RESOLUTION_H
#define __915_RESOLUTION_H
//#define AUTORES_DEBUG 1 // enable AutoResolution debug - review!
#include "libsa.h"
#include "saio_internal.h"
#include "edid.h"
//#define AUTORES_DEBUG 1 // enable AutoResolution debug - review!
#if DEBUG
#ifndef AUTORES_DEBUG
#define AUTORES_DEBUG
#define VBIOS_START 0xc0000
#define VBIOS_SIZE 0x10000
#define FALSE 0
#define TRUE 1
//#define false 0(Reviewing...)
//#define true 1
bool gAutoResolution;
UInt32 paramsAR[4]; //Azi: testing autoresolution
typedef struct
uint32_t currentX, currentY;
uint8_t b1, b2;
bool hasSwitched;
//bool hasSwitched;
bool (*setMode)(sModeTable *,uint8_t,uint32_t*,uint32_t*);
void patchVbios(vBiosMap* map, uint32_t x, uint32_t y, uint32_t bp, uint32_t hTotal, uint32_t vTotal);
//void patchRes();
//void reloadRes();
#endif
branches/azimutz/Chazi/i386/libsaio/nvidia_resolution.c
121121
122122
123123
124
125
124
126125
127126
128127
......
215214
216215
217216
218
217
219218
saveTables(map->modeTables);
#ifdef AUTORES_DEBUG
PRINT("Press Any Key...\n");
getc();
pause();
#endif
return map;
idx++;
}
}
return TRUE;
return true;
}
branches/azimutz/Chazi/i386/libsaio/gma_resolution.c
8686
8787
8888
89
89
9090
9191
9292
......
101101
102102
103103
104
104
105105
106106
107107
108108
109109
110110
111
111
112112
113113
114114
115
115
116116
117
117
118118
119119
120120
121
121
122122
123
123
124124
125125
126126
127
127
128128
129129
130130
return 0;
}
PRINT("Mode Table at offset : 0x%x\n", (table->pointer) - map->biosPtr);
PRINT("Mode Table at offset: 0x%x\n", (table->pointer) - map->biosPtr);
/*
* Determine size of mode table
}
table->modeCount = table->size;
PRINT("Mode Table size : %d\n", table->modeCount);
PRINT("Mode Table size: %d\n", table->modeCount);
/*
* Figure out what type of bios we have
* order of detection is important
*/
if (detectBiosType(map, TRUE, sizeof(vbiosModelineType3)))
if (detectBiosType(map, true, sizeof(vbiosModelineType3)))
{
map->bios = BT_3;
map->setMode = intelSetMode_3;
PRINT("Bios Type : BT_3\n");
PRINT("Bios Type: BT_3\n");
}
else if (detectBiosType(map, TRUE, sizeof(vbiosModelineType2)))
else if (detectBiosType(map, true, sizeof(vbiosModelineType2)))
{
map->bios = BT_2;
map->setMode = intelSetMode_2;
PRINT("Bios Type : BT_2\n");
PRINT("Bios Type: BT_2\n");
}
else if (detectBiosType(map, FALSE, sizeof(vbiosResolutionType1)))
else if (detectBiosType(map, false, sizeof(vbiosResolutionType1)))
{
map->bios = BT_1;
map->setMode = intelSetMode_1;
PRINT("Bios Type : BT_1\n");
PRINT("Bios Type: BT_1\n");
}
else
{
branches/azimutz/Chazi/i386/boot2/graphics.c
427427
428428
429429
430
430
431
431432
432433
433434
434435
435436
436437
437
438438
439439
440440
441
441
442442
443
443444
444445
445446
......
11211122
11221123
11231124
1124
1125
11251126
11261127
11271128
1128
1129
1130
1131
1132
1133
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
11341140
1135
11361141
11371142
11381143
11391144
1140
1145
1146
11411147
11421148
11431149
11441150
11451151
11461152
1147
1153
11481154
11491155
1150
1151
1156
1157
1158
11521159
11531160
11541161
#ifdef AUTORES_DEBUG
printf("Is about to set mode #%d with resolution %dx%d\n", mode, minfo.XResolution, minfo.YResolution);
//getc(); //Azi: i get the hangs, like "old" Wait=y issue.
//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 )
{
break;
#ifdef AUTORES_DEBUG
printf("setVBEMode failed to set mode %d (%dx%d) with error #%d\n",
mode, minfo.XResolution, minfo.YResolution, err);
getc();
sleep(2); //Azi: i suppose the same as above.
#endif
break;
}
// Set 8-bit color palette.
{
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[]) {
branches/azimutz/Chazi/i386/boot2/boot.c
4949
5050
5151
52
53
5254
5355
5456
......
187189
188190
189191
192
193
194
195
196
197
198
199
200
201
202
190203
191204
192205
......
241254
242255
243256
244
257
245258
246259
247260
......
261274
262275
263276
264
277
265278
266279
267280
......
274287
275288
276289
290
291
277292
278
293
294
295
296
297
298
299
300
301
279302
280303
281304
......
288311
289312
290313
314
315
316
317
291318
292319
293320
294321
295322
296323
297
298
299
300324
301325
302326
303
304
305
306
327
328
329
330
331
332
333
334
335
336
337
338
339
340
307341
308
309
310
311
312
313
342
314343
315
316
344
345
346
317347
318
319
320
321
322
323
324
325
348
349
350
351
352
353
326354
327355
328356
......
338366
339367
340368
341
342
343
344
345
346
347
348
369
349370
350371
351372
373
352374
353375
354
355
356
376
357377
358378
359
360
379
380
381
382
383
384
385
386
387
361388
389
362390
363391
364
392
393
394
365395
366396
367397
368
369
370
398
399
400
401
402
371403
372404
373
374
375
405
406
407
408
409
376410
377
378
411
412
379413
380
414
415
381416
417
418
419
382420
383421
384422
......
413451
414452
415453
416
454
417455
418456
419457
......
425463
426464
427465
466
467
428468
429
430
431
432
469
470
471
433472
434
473
435474
436475
437476
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
477
467478
468
469
470
471
472
473
474
475
476
477
479
480
481
478482
479
480
483
481484
482485
486
483487
484488
485489
486
490
487491
488492
489493
......
659663
660664
661665
662
666
663667
664668
665669
666
670
667671
668672
669673
670674
671
675
672676
673677
674678
* Reworked again by Curtis Galloway (galloway@NeXT.com)
*/
//#define DEBUG 1
//#include "bootstruct.h"
//#include "libsa.h"
#include "boot.h"
// Notify modules that the kernel is about to be started
execute_hook("Kernel Start", (void*)kernelEntry, (void*)bootArgs, NULL, NULL);
if ((gAutoResolution == true) && map)
{
closeVbios(map);
//Azi: as a side note, while testing i didn't got any problems booting without
// closing Vbios... closing it just in case. (check again later!)
// gAutoResolution was just set to false on closeVbios().
// We need to be "true" for drawBootGraphics().
gAutoResolution = true;
}
// If we were in text mode, switch to graphics mode.
// This will draw the boot graphics unless we are in
bool quiet;
bool firstRun = true;
bool instantMenu;
bool rescanPrompt;
bool rescanPrompt = false;
unsigned int allowBVFlags = kBVFlagSystemVolume|kBVFlagForeignBoot;
unsigned int denyBVFlags = kBVFlagEFISystem;
// 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
#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);
// 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);
firstRun = false;
}
// 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();
}
// Loading preboot ramdisk if exists.
loadPrebootRAMDisk();
// 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 cd/dvd 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);
// Override useGUI default
getBoolForKey(kGUIKey, &useGUI, &bootInfo->bootConfig);
/*
* AutoResolution
*/
// Before initGui, patch the video bios with the correct resolution
UInt32 params[4];
params[3] = 0;
// default to "false" as it doesn't work for everyone atm.
// AutoResolution - Azi: default to false
// http://forum.voodooprojects.org/index.php/topic,1227.0.html
gAutoResolution = false;
// Check if user enabled AutoResolution on Boot.plist...
getBoolForKey(kAutoResolutionKey, &gAutoResolution, &bootInfo->bootConfig);
//Open the VBios and store VBios or Tables
map = openVbios(CT_UNKWN);
// Patch the Video Bios with the extracted resolution, before initGui.
if (gAutoResolution == true)
{
//Get Resolution from Graphics Mode key or EDID
int count = getNumberArrayFromProperty(kGraphicsModeKey, params, 4);
//patchRes();
//UInt32 paramsAR[4];
paramsAR[3] = 0;
// Open the Vbios and store VBios or Tables
map = openVbios(CT_UNKWN);
//Get Resolution from Graphics Mode key...
int count = getNumberArrayFromProperty(kGraphicsModeKey, paramsAR, 4);
// ... or EDID.
if (count < 3)
{
getResolution(params);
getResolution(paramsAR);
// check the DEBUG stuff... also on TEXT MODE (this is not printing).
PRINT("Resolution: %dx%d (EDID)\n",paramsAR[0], paramsAR[1]);
}
else
{
if ( params[2] == 256 ) params[2] = 8;
if ( params[2] == 555 ) params[2] = 16;
if ( params[2] == 888 ) params[2] = 32;
PRINT("Resolution: %dx%d (Graphics Mode key)\n",paramsAR[0], paramsAR[1]);
if ( paramsAR[2] == 256 ) paramsAR[2] = 8;
if ( paramsAR[2] == 555 ) paramsAR[2] = 16;
if ( paramsAR[2] == 888 ) paramsAR[2] = 32;
}
#ifdef AUTORES_DEBUG
printf("Resolution: %dx%d\n",params[0], params[1]);
#endif
// perfom the actual VBIOS patching
if (paramsAR[0] != 0 && paramsAR[1] != 0)
{
patchVbios(map, paramsAR[0], paramsAR[1], paramsAR[2], 0, 0);
}
//perfom the actual VBIOS patching
if (params[0] != 0 && params[1] != 0)
//Azi: passing resolution for TEXT MODE "verbose" boot. (check again later!)
if (bootArgs->Video.v_display == VGA_TEXT_MODE)
{
patchVbios(map, params[0], params[1], params[2], 0, 0);
gui.screen.width = paramsAR[0];
gui.screen.height = paramsAR[1];
}
// If the patch is working properly, we're done. If not and it's just a matter
// of wrong resolution, we can try reapply the patch; see "case kF2Key:", options.c.
}
if (useGUI && initGUI())
firstRun = false;
if (status == -1) continue;
//Azi: i'm now almost sure that here is the right place to do this! - test (gBootVolume == NULL)
//Azi: test (gBootVolume == NULL) - so far Ok!
// Turn off any GUI elements, draw background and update VRAM.
if ( bootArgs->Video.v_display == GRAPHICS_MODE )
{
drawBackground();
updateVRAM();
}
status = processBootOptions();
//
//AutoResolution - Reapply the patch or cancel if Graphics Mode was incorrect
// or EDID Info was insane
//getBoolForKey(kAutoResolutionKey, &gAutoResolution, &bootInfo->bootConfig);
//AutoResolution - cancel if Graphics Mode was incorrect or EDID Info was insane.
// Check if user disabled AutoResolution at the boot prompt.
getBoolForKey(kAutoResolutionKey, &gAutoResolution, &bootInfo->bootConfig);
//Restore the vbios for Cancelation
// Restore and close Vbios for patch cancelation.
if ((gAutoResolution == false) && map)
{
restoreVbios(map);
closeVbios(map);
}
if ((gAutoResolution == true) && map)
{
// If mode has been switched during boot menu
// use the new resolution
if (map->hasSwitched == true)
{
params[0] = map->currentX;
params[1] = map->currentY;
params[2] = 32;
}
else
{
//or get resolution from Graphics Mode or EDID
int count = getNumberArrayFromProperty(kGraphicsModeKey, params, 4);
if (count < 3)
{
getResolution(params);
}
else
{
if ( params[2] == 256 ) params[2] = 8;
if ( params[2] == 555 ) params[2] = 16;
if ( params[2] == 888 ) params[2] = 32;
}
}
closeVbios(map);
//Resolution has changed, reapply the patch
if ((params[0] != 0) && (params[1] != 0) && (params[0] != map->currentX) &&
(params[1] != map->currentY))
{
patchVbios(map, params[0], params[1], params[2], 0, 0);
}
closeVbios(map);
//Azi: gAutoResolution was just set to false on closeVbios;
// we need it to be true here for drawBootGraphics().
gAutoResolution = true;
//Azi: closing Vbios here without restoring it as above, 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 = processBootOptions();
// Status == 1 means to chainboot
if ( status ==1 ) break;
// Status == -1 means that gBootVolume is NULL. Config file is not mandatory anymore!
if ( status == -1 )
{
// gBootVolume == NULL usually means the user hit escape.
// gBootVolume == NULL usually means the user hit escape.(Reviewing...)
if (gBootVolume == NULL)
{
freeFilteredBVChain(bvChain);
} while (0);
clearActivityIndicator();
#if DEBUG
/*#if DEBUG
printf("Pausing...");
sleep(8);
#endif
Azi: annoying stuff :P */
if (ret <= 0) {
printf("Can't find %s\n", bootFile);
sleep(1);
if (gBootFileType == kNetworkDeviceType) {
// Return control back to PXE. Don't unload PXE base code.
gUnloadPXEOnExit = false;
branches/azimutz/Chazi/i386/boot2/gui.c
218218
219219
220220
221
221
222222
223223
224224
......
386386
387387
388388
389
389
390390
391391
392392
......
672672
673673
674674
675
676
675
676
677677
678678
679679
......
693693
694694
695695
696
697
698
696
699697
700698
701
702
703
704
705
706
707
708
709
710
711
712
713
714
699
700
715701
716702
717703
718
704
719705
720706
721707
......
725711
726712
727713
714
728715
729716
730717
......
754741
755742
756743
757
758
744
759745
760746
761747
......
18271813
18281814
18291815
1830
1816
1817
18311818
18321819
1833
1834
1835
1836
1820
1821
1822
1823
1824
18371825
18381826
18391827
1828
18401829
1841
1830
1831
1832
1833
18421834
1843
1835
1836
18441837
1838
18451839
18461840
18471841
......
18521846
18531847
18541848
1855
1856
1849
18571850
18581851
18591852
......
18641857
18651858
18661859
1867
1868
1860
1861
18691862
18701863
1864
18711865
1872
1873
1874
1866
18751867
18761868
1877
1878
1879
1880
1869
1870
1871
18811872
18821873
18831874
1884
1875
18851876
18861877
18871878
......
18901881
18911882
18921883
1893
1884
18941885
18951886
18961887
......
18991890
19001891
19011892
1893
19021894
19031895
19041896
19051897
1906
1898
1899
19071900
19081901
19091902
19101903
1911
1912
1904
1905
19131906
19141907
19151908
static int loadThemeImage(const char *image, int alt_image)
{
chardirspec[256];
chardirspec[128]; //Azi: testing
int i;
#ifdef EMBED_THEME
int e;
gui.backbuffer->width = gui.screen.width;
gui.backbuffer->height = gui.screen.height;
return 0;
}
int initGUI(void)
{
intval, len, count;
chardirspec[128]; //Azi: a bit of testing***
intval, len;
chardirspec[128]; //Azi: testing
getValueForKey( kThemeNameKey, &theme_name, &len, &bootInfo->bootConfig );
if ((strlen(theme_name) + 27) > sizeof(dirspec)) {
#endif
}
/*
* AutoResolution
*/
// AutoResolution
if (gAutoResolution == true)
{
// Get Resolution from Graphics Mode key
count = getNumberArrayFromProperty(kGraphicsModeKey, screen_params, 4);
// If no Graphics Mode key, get it from EDID
if ( count < 3 )
{
getResolution(screen_params);
PRINT("Resolution : %dx%d (EDID)\n",screen_params[0], screen_params[1]);
}
else
{
PRINT("Resolution : %dx%d (Graphics Mode key)\n",screen_params[0], screen_params[1]);
}
screen_params[0] = paramsAR[0];
screen_params[1] = paramsAR[1];
}
else
{
// parse display size parameters
// parse screen size parameters
if (getIntForKey("screen_width", &val, &bootInfo->themeConfig) && val > 0)
{
screen_params[0] = val;
{
screen_params[1] = val;
}
//Azi: how about using default values?
}
// Initalizing GUI strucutre.
if (createWindowBuffer(&gui.menu) == 0) {
#ifdef AUTORES_DEBUG
printf("Press Any Key...\n");
getc();
pause();
#endif
gui.logo.draw = true;
drawBackground();
// 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, "bt(0,0)/Extra/Themes/%s/boot.png", theme_name);
if (loadPngImage(dirspec, &bootImageWidth, &bootImageHeight, &bootImageData) != 0) {
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;
}
}
{
bool legacy_logo;
const char *dummyVal;
int pos;//, count;
int length, oldScreenWidth, oldScreenHeight;
int pos, length, oldScreenWidth, oldScreenHeight;
uint16_t x, y;
if (getBoolForKey(kLegacyLogoKey, &legacy_logo, &bootInfo->bootConfig) && legacy_logo)
{
loadBootGraphics();
}
// Save current screen resolution.
// Save current screen resolution.
oldScreenWidth = gui.screen.width;
oldScreenHeight = gui.screen.height;
//printf("Res: %dx%d (drawbg: current/old)\n", oldScreenWidth, oldScreenHeight);
/*
* AutoResolution
*/
// AutoResolution
if (gAutoResolution == true)
{
//Azi: if this stuff is working properly, resolution is set, Vbios is closed and
// most probably we want to use oldScreenWidth/Height so...
screen_params[0] = oldScreenWidth;
screen_params[1] = oldScreenHeight;
screen_params[0] = paramsAR[0];
screen_params[1] = paramsAR[1];
//printf("Res: %dx%d (drawbg: AR)\n", screen_params[0], screen_params[1]);
}
else
{
// parse display size parameters
// parse boot screen size parameters
if (getIntForKey("boot_width", &pos, &bootInfo->themeConfig) && pos > 0)
{
screen_params[0] = pos;
{
screen_params[0] = DEFAULT_SCREEN_WIDTH;
}
if (getIntForKey("boot_height", &pos, &bootInfo->themeConfig) && pos > 0)
{
screen_params[1] = pos;
{
screen_params[1] = DEFAULT_SCREEN_HEIGHT;
}
//Azi: and how about not using default values here? like on initGUI...
}
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);
// 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) )
if (bootArgs->Video.v_display == VGA_TEXT_MODE
|| (screen_params[0] != oldScreenWidth && screen_params[1] != oldScreenHeight))
{
setVideoMode(GRAPHICS_MODE, 0);
}
branches/azimutz/Chazi/i386/boot2/options.c
180180
181181
182182
183
183
184
184185
185186
186187
......
269270
270271
271272
272
273
274
273275
274276
275277
......
10081010
10091011
10101012
1011
1012
1013
1014
1015
1013
1014
1015
10161016
10171017
1018
1019
1020
1018
10211019
1022
1023
1024
1025
1020
1021
1022
1023
1024
1025
10261026
1027
1027
1028
1029
1030
1031
10281032
1029
1030
1031
1032
1033
1034
1035
1036
1033
1034
10371035
10381036
10391037
......
10441042
10451043
10461044
1047
1045
1046
10481047
1049
1050
10511048
10521049
10531050
......
10611058
10621059
10631060
1064
1061
1062
10651063
1064
1065
1066
10661067
1067
1068
1069
1070
1071
1068
1069
1070
10721071
1073
1074
1075
1076
10771072
10781073
10791074
......
10871082
10881083
10891084
1090
1091
1085
1086
10921087
10931088
1089
10941090
10951091
1092
1093
1094
1095
1096
1097
10961098
10971099
10981100
......
11071109
11081110
11091111
1110
1112
11111113
11121114
11131115
......
15981600
15991601
16001602
1603
16011604
16021605
16031606
static char booterCommand[BOOT_STRING_LEN];
static char booterParam[BOOT_STRING_LEN];
static void clearBootArgs(void)
//static
void clearBootArgs(void)
{
gBootArgsPtr = gBootArgs;
memset(gBootArgs, '\0', BOOT_STRING_LEN);
putchar(key); // echo to screen
else
updateGraphicBootPrompt(key);
*gBootArgsPtr++ = key;
*gBootArgsPtr++ = key;
}
break;
case kEscapeKey:
clearBootArgs();
break;
/*
* AutoResolution - Reapply the patch if Graphics Mode was incorrect
* or EDID Info was insane
*/
// AutoResolution - Reapply the patch if Graphics Mode was incorrect or EDID Info was insane.
//Azi:
case kF2Key:
//get the new Graphics Mode key
processBootOptions();
if ((gAutoResolution == TRUE) && map)
if ((gAutoResolution == true) && map)
{
UInt32 params[4];
params[3] = 0;
//Has the target Resolution Changed ?
int count = getNumberArrayFromProperty(kGraphicsModeKey, params, 4);
// get the new Graphics Mode key
processBootOptions(); //Azi: use processBootArgument instead?
//reloadRes();
//UInt32 paramsAR[4];
paramsAR[3] = 0;
if ( count < 3 )
getNumberArrayFromProperty(kGraphicsModeKey, paramsAR, 4);
// user changed resolution...
if ((paramsAR[0] != 0) && (paramsAR[1] != 0) &&
(paramsAR[0] != map->currentX) && (paramsAR[1] != map->currentY))
{
getResolution(params);
}
if ((params[0] != 0) && (params[1] != 0) &&
(params[0] != map->currentX) && (params[1] != map->currentY))
{
//Go back to TEXT mode while we change the mode
//Azi: same stuff as "case kTabKey:"(Reviewing...)
// Go back to TEXT mode while we change the mode
if (bootArgs->Video.v_display == GRAPHICS_MODE)
{
CursorState cursorState;
clearScreenRows(0, kScreenLastRow);
changeCursor( 0, 0, kCursorTypeHidden, &cursorState );
//Reapply patch in case resolution have changed
// Reapply patch
patchVbios(map, paramsAR[0], paramsAR[1], paramsAR[2], 0, 0);
patchVbios(map, params[0], params[1], params[2], 0, 0);
if (useGUI && (gui.initialised == true))
initGUI();
// Make sure all values are set
drawBackground();
gui.devicelist.draw = true;
gui.redraw = true;
if (!(gBootMode & kBootModeQuiet))
if (showBootBanner)
{
// Display banner and show hardware info.
gprintf(&gui.screen, bootBanner + 1, (bootInfo->convmem + bootInfo->extmem) / 1024);
}
// Check if "Boot Banner"=N switch is present in config file.
getBoolForKey(kBootBannerKey, &showBootBanner, &bootInfo->bootConfig);
if (showBootBanner)
// Display banner and show hardware info.
gprintf(&gui.screen, bootBanner + 1, (bootInfo->convmem + bootInfo->extmem) / 1024);
// redraw background
memcpy(gui.backbuffer->pixels, gui.screen.pixmap->pixels,
gui.backbuffer->width * gui.backbuffer->height * 4);
// redraw background
memcpy(gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4);
}
nextRow = kMenuTopRow;
showPrompt = true;
showPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot);
showBootPrompt( nextRow, showPrompt );
//this is used to avoid resetting the incorrect mode while quiting the boot menu
map->hasSwitched = true;
// this is used to avoid resetting the incorrect mode while quiting the boot menu
//map->hasSwitched = true; (check again later!)
}
}
clearBootArgs();
key = 0;
}
else // if gAutoResolution == false...
{
// ... do "nothing".
clearBootArgs();
key = 0;
}
break;
}
break;
case kF10Key:
case kF10Key: //Azi: disable "Scan Single Drive"=y (if set) and rescan disks.
gScanSingleDrive = false;
scanDisks(gBIOSDev, &bvCount);
gBootVolume = NULL;
// 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;

Archive Download the corresponding diff file

Revision: 602