Index: branches/azimutz/Chazi/i386/libsaio/ati_resolution.c =================================================================== --- branches/azimutz/Chazi/i386/libsaio/ati_resolution.c (revision 601) +++ branches/azimutz/Chazi/i386/libsaio/ati_resolution.c (revision 602) @@ -78,7 +78,7 @@ *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) @@ -100,5 +100,5 @@ *x = modeTiming[idx + 1].hActive; *y = modeTiming[idx + 1].hActive; - return TRUE; + return true; } Index: branches/azimutz/Chazi/i386/libsaio/autoresolution.c =================================================================== --- branches/azimutz/Chazi/i386/libsaio/autoresolution.c (revision 601) +++ branches/azimutz/Chazi/i386/libsaio/autoresolution.c (revision 602) @@ -15,6 +15,8 @@ //#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" @@ -208,7 +210,7 @@ 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) @@ -271,7 +273,7 @@ * Common initialisation */ - map->hasSwitched = false; +// map->hasSwitched = false; /* * check if we have ATI Radeon and open atombios @@ -344,7 +346,7 @@ { 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); @@ -361,8 +363,8 @@ { 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) @@ -378,14 +380,14 @@ { 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"); } @@ -404,7 +406,7 @@ void unlockVbios(vBiosMap * map) { - map->unlocked = TRUE; + map->unlocked = true; switch (map->chipset) { @@ -462,7 +464,7 @@ void relockVbios(vBiosMap * map) { - map->unlocked = FALSE; + map->unlocked = false; switch (map->chipset) { @@ -513,6 +515,7 @@ /* * saveVbios - save the entire vBios in case the patch has to be removed + * Azi: only on Intel?? */ void saveVbios(vBiosMap * map) { @@ -560,6 +563,7 @@ { bcopy(table->backup, (uint8_t *)table->pointer, table->size); table = table->next; +// verbose("Table/s restored...\n"); } relockVbios(map); } @@ -599,11 +603,11 @@ 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; @@ -611,4 +615,146 @@ relockVbios(map); return; -} \ No newline at end of file +} +/* +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; +}*/ Index: branches/azimutz/Chazi/i386/libsaio/autoresolution.h =================================================================== --- branches/azimutz/Chazi/i386/libsaio/autoresolution.h (revision 601) +++ branches/azimutz/Chazi/i386/libsaio/autoresolution.h (revision 602) @@ -16,12 +16,12 @@ #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 @@ -42,11 +42,12 @@ #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 @@ -114,7 +115,7 @@ uint32_t currentX, currentY; uint8_t b1, b2; - bool hasSwitched; +// bool hasSwitched; bool (*setMode)(sModeTable *,uint8_t,uint32_t*,uint32_t*); @@ -146,4 +147,7 @@ void patchVbios(vBiosMap* map, uint32_t x, uint32_t y, uint32_t bp, uint32_t hTotal, uint32_t vTotal); +//void patchRes(); +//void reloadRes(); + #endif Index: branches/azimutz/Chazi/i386/libsaio/nvidia_resolution.c =================================================================== --- branches/azimutz/Chazi/i386/libsaio/nvidia_resolution.c (revision 601) +++ branches/azimutz/Chazi/i386/libsaio/nvidia_resolution.c (revision 602) @@ -121,8 +121,7 @@ saveTables(map->modeTables); #ifdef AUTORES_DEBUG - PRINT("Press Any Key...\n"); - getc(); + pause(); #endif return map; @@ -215,5 +214,5 @@ idx++; } } - return TRUE; + return true; } \ No newline at end of file Index: branches/azimutz/Chazi/i386/libsaio/gma_resolution.c =================================================================== --- branches/azimutz/Chazi/i386/libsaio/gma_resolution.c (revision 601) +++ branches/azimutz/Chazi/i386/libsaio/gma_resolution.c (revision 602) @@ -86,7 +86,7 @@ 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 @@ -101,30 +101,30 @@ } 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 { Index: branches/azimutz/Chazi/i386/boot2/graphics.c =================================================================== --- branches/azimutz/Chazi/i386/boot2/graphics.c (revision 601) +++ branches/azimutz/Chazi/i386/boot2/graphics.c (revision 602) @@ -427,19 +427,20 @@ #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. @@ -1121,34 +1122,40 @@ { 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[]) { Index: branches/azimutz/Chazi/i386/boot2/boot.c =================================================================== --- branches/azimutz/Chazi/i386/boot2/boot.c (revision 601) +++ branches/azimutz/Chazi/i386/boot2/boot.c (revision 602) @@ -49,6 +49,8 @@ * Reworked again by Curtis Galloway (galloway@NeXT.com) */ +//#define DEBUG 1 + //#include "bootstruct.h" //#include "libsa.h" #include "boot.h" @@ -187,6 +189,17 @@ // 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 @@ -241,7 +254,7 @@ bool quiet; bool firstRun = true; bool instantMenu; - bool rescanPrompt; + bool rescanPrompt = false; unsigned int allowBVFlags = kBVFlagSystemVolume|kBVFlagForeignBoot; unsigned int denyBVFlags = kBVFlagEFISystem; @@ -261,7 +274,7 @@ // 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 @@ -274,8 +287,18 @@ // 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); @@ -288,41 +311,46 @@ 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); @@ -338,47 +366,57 @@ // 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()) @@ -413,7 +451,7 @@ 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 ) { @@ -425,65 +463,31 @@ 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); @@ -659,16 +663,16 @@ } 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; Index: branches/azimutz/Chazi/i386/boot2/gui.c =================================================================== --- branches/azimutz/Chazi/i386/boot2/gui.c (revision 601) +++ branches/azimutz/Chazi/i386/boot2/gui.c (revision 602) @@ -218,7 +218,7 @@ static int loadThemeImage(const char *image, int alt_image) { - char dirspec[256]; + char dirspec[128]; //Azi: testing int i; #ifdef EMBED_THEME int e; @@ -386,7 +386,7 @@ gui.backbuffer->width = gui.screen.width; gui.backbuffer->height = gui.screen.height; - + return 0; } @@ -672,8 +672,8 @@ int initGUI(void) { - int val, len, count; - char dirspec[128]; //Azi: a bit of testing*** + int val, len; + char dirspec[128]; //Azi: testing getValueForKey( kThemeNameKey, &theme_name, &len, &bootInfo->bootConfig ); if ((strlen(theme_name) + 27) > sizeof(dirspec)) { @@ -693,29 +693,15 @@ #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; @@ -725,6 +711,7 @@ { screen_params[1] = val; } + //Azi: how about using default values? } // Initalizing GUI strucutre. @@ -754,8 +741,7 @@ if (createWindowBuffer(&gui.menu) == 0) { #ifdef AUTORES_DEBUG - printf("Press Any Key...\n"); - getc(); + pause(); #endif gui.logo.draw = true; drawBackground(); @@ -1827,21 +1813,29 @@ // 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; } } @@ -1852,8 +1846,7 @@ { 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) @@ -1864,24 +1857,22 @@ { 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; @@ -1890,7 +1881,7 @@ { screen_params[0] = DEFAULT_SCREEN_WIDTH; } - + if (getIntForKey("boot_height", &pos, &bootInfo->themeConfig) && pos > 0) { screen_params[1] = pos; @@ -1899,17 +1890,19 @@ { 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); } Index: branches/azimutz/Chazi/i386/boot2/options.c =================================================================== --- branches/azimutz/Chazi/i386/boot2/options.c (revision 601) +++ branches/azimutz/Chazi/i386/boot2/options.c (revision 602) @@ -180,7 +180,8 @@ 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); @@ -269,7 +270,8 @@ putchar(key); // echo to screen else updateGraphicBootPrompt(key); - *gBootArgsPtr++ = key; + + *gBootArgsPtr++ = key; } break; @@ -1008,32 +1010,28 @@ 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; @@ -1044,10 +1042,9 @@ 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 @@ -1061,19 +1058,17 @@ 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; @@ -1087,12 +1082,19 @@ 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; @@ -1107,7 +1109,7 @@ } break; - case kF10Key: + case kF10Key: //Azi: disable "Scan Single Drive"=y (if set) and rescan disks. gScanSingleDrive = false; scanDisks(gBIOSDev, &bvCount); gBootVolume = NULL; @@ -1598,6 +1600,7 @@ // 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;