ACC SHELL

Path : /usr/share/YaST2/modules/
File Upload :
Current File : //usr/share/YaST2/modules/BootArch.ycp

/**
 * File:
 *      modules/BootArch.ycp
 *
 * Module:
 *      Bootloader installation and configuration
 *
 * Summary:
 *      Module containing specific data for differnt architecturese
 *      (as some architectures support multiple bootloaders, some bootloaders
 *      support multiple architectures)
 *
 * Authors:
 *      Jiri Srain <jsrain@suse.cz>
 *      Olaf Dabrunz <od@suse.de>
 *
 * $Id: BootArch.ycp 60011 2009-12-09 10:40:19Z juhliarik $
 *
 */

{

module "BootArch";

textdomain "bootloader";

import "Arch";
import "Kernel";
import "Linuxrc";
import "ProductFeatures";
import "Stage";

/**
 * Get parameters for the default kernel
 * @param resume string device to resume from (or empty not to set it)
 * @return string parameters for default kernel
 */
global string DefaultKernelParams (string resume) {
    string features = 
        ProductFeatures::GetStringFeature (
	    "globals",
	    "additional_kernel_parameters");
    string kernel_cmdline = Kernel::GetCmdLine ();

    if (Arch::i386 () || Arch::x86_64 ())
    {
	string ret = (kernel_cmdline != "") ? kernel_cmdline + " " : "";
	if (resume != "")
	    ret = ret + sformat ("resume=%1 ", resume);
	if (features != "")
	    ret = ret + features + " "; 
	if (regexpmatch (ret, "^(.* )?splash=[[:lower:]]+( .*)?$"))
	    ret = regexpsub (ret, "^((.* ))?splash=[[:lower:]]+(( .*)?)$", "\\1 \\3");
	ret = ret + "splash=silent quiet showopts";
	return ret;
    }
    else if (Arch::ia64 ())
    {
	string ret = (kernel_cmdline != "") ? kernel_cmdline + " " : "";
	if (features != "")
	    ret = ret + features + " "; 
	ret = ret + "splash=silent quiet";

	// FIXME: this does not belong here, it cannot be tracked or maintained
	// and is undocumented
	// on SGI Altix change kernel default hash tables sizes
	if (SCR::Read (.target.stat, "/proc/sgi_sn") != $[])
	{
	    ret = ret + " thash_entries=2097152";
	}
	return ret;
    }
    else if (Arch::s390 ()) {
        map <string, any> file_desc = ( map<string, any> )
	  SCR::Execute( .target.bash_output, "echo $TERM" );
	string env_term = file_desc[ "stdout" ]: "";
	string termparm = "TERM=dumb";
	if ( env_term == "linux\n" ) {
	    termparm = "TERM=linux console=ttyS0 console=ttyS1";
	}
	string parameters = sformat ("%1 %2",
	    features,
	    termparm);
	return parameters;
    }
    else
    {
	y2warning ("Default kernel parameters not defined");
	return kernel_cmdline;
    }
}

/**
 * Get parameters for the failsafe kernel
 * @return string parameters for failsafe kernel
 */
global string FailsafeKernelParams () {
    string ret = "";
    if (Arch::i386 ())
    {
	ret = "showopts apm=off noresume nosmp maxcpus=0 edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 nomodeset";
    }
    else if (Arch::x86_64 ())
    {
	ret = "showopts apm=off noresume edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 nomodeset";
    }
    else if (Arch::ia64 ())
    {
	ret = "nohalt noresume powersaved=off";
    }
    else if (Arch::s390 ())
    {
	ret = DefaultKernelParams("");
    }
    else
    {
	y2warning ("Parameters for Failsafe boot option not defined");
    }
    if (Stage::initial ())
    {
	if (Linuxrc::InstallInf ("NOPCMCIA") == "1")
	    ret = ret + " NOPCMCIA";
    }
    else
    {
	map<string,any> saved_params = (map<string,any>)SCR::Read (
	    .target.ycp, "/var/lib/YaST2/bootloader.ycp");
	ret = ret + " " + saved_params["additional_failsafe_params"]:"";
    }
    

//B#352020 kokso: - Graphical failsafe mode
    //ret = ret + " 3";
    ret = ret + " x11failsafe";
//B#352020 end
    return ret;
}

/**
 * Is VGA parameter setting available
 * @return true if vga= can be set
 */
global boolean VgaAvailable () {
    return (Arch::i386 () || Arch::x86_64 () || Arch::ia64 ());
}

/**
 * Is Suspend to Disk available?
 * @return true if STD is available
 */
global boolean ResumeAvailable () {
    return (Arch::i386 () || Arch::x86_64 () || Arch::ia64 ());
}


/**
 * Return architecture as string
 * @return string type of architecture e.g. "i386"
 */
global string StrArch () 
{
	string ret = Arch::architecture();
	if ((ret == "ppc") || (ret == "ppc64"))
	{
		if (Arch::board_iseries ())
    		{
			ret = "iseries";
    		}
    		else if (Arch::board_prep ())
    		{
			ret = "prep";
    		}
    		else if (Arch::board_chrp ())
    		{
			ret = "chrp";
    		}
    		else if (Arch::board_mac_new ())
    		{
        		ret = "pmac";
    		}
    		else if (Arch::board_mac_old ())
    		{
        		ret = "pmac";
    		}
    		else
    		{
			ret = "unknown";
    		}
	}	

	y2milestone("Type of architecture: %1", ret);
	return ret;
}

}

/*
 * Local variables:
 *     mode: ycp
 *     mode: font-lock
 *     mode: auto-fill
 *     indent-level: 4
 *     fill-column: 78
 * End:
 */

ACC SHELL 2018