1117N/A * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 1117N/A * Permission is hereby granted, free of charge, to any person obtaining a 1117N/A * copy of this software and associated documentation files (the "Software"), 1117N/A * to deal in the Software without restriction, including without limitation 1117N/A * the rights to use, copy, modify, merge, publish, distribute, sublicense, 1117N/A * and/or sell copies of the Software, and to permit persons to whom the 1117N/A * Software is furnished to do so, subject to the following conditions: 1117N/A * The above copyright notice and this permission notice (including the next 1117N/A * paragraph) shall be included in all copies or substantial portions of the 1117N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1117N/A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1117N/A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1117N/A * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 1117N/A * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 1117N/A * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 1117N/A * DEALINGS IN THE SOFTWARE. 1117N/A * Frame buffer configuration software directory 1117N/A * fbconfig invokes the dcmtool script (which in turn invokes java) 1117N/A * Write a variable format error message to stderr, prefixed by the 1117N/A * Determine what X server is currently configured (Xsun, Xorg, ...). 1117N/A * Note that this is not necessarily the X server that is currently 1117N/A * Related svccfg(1M) "set" and "list" commands: 1117N/A * Allocate and initialize the necessary SCF data structures 1117N/A * Retrieve the Nul-terminated X server pathname string 1117N/A * Evaluate the simple filename 1117N/A * Return the identity of the X server 1117N/A * Become the actual device configuration program, executing it with 1117N/A * the caller-provided argument vector. This function does not 1117N/A "No configuration program pathname"));
1117N/A * Return the frame buffer model name, else an empty string, in the 1117N/A * caller-supplied device_model[GFX_MAX_MODELNAME_LEN] name buffer. 1117N/A * Note that ioctl(GFX_IOCTL_GET_IDENTIFIER) might not be supported 1117N/A * by older drivers (e.g., Xsun drivers). 1117N/A const char *
const SUNW_ =
"SUNW,";
/* Prefix on model & part strings */ 1117N/A * Get the frame buffer model name w/o any leading "SUNW," substring 1117N/A * Return the frame buffer model name, else an empty string 1117N/A * get_device_identification() 1117N/A * character special file. If the caller has provided the necessary 1117N/A * pointer, return the (struct stat).st_rdev value. Open the file 1117N/A * and return the VISUAL environment device identifier name. For 1117N/A * "SUNWjfb". If the caller has provided the necessary 1117N/A * device_model[GFX_MAX_MODELNAME_LEN] name buffer, get and return 1117N/A * the frame buffer model name. 1117N/A * In the event of an error, return an errno-style error code. An 1117N/A * EACCES code may be of special interest to the caller. 1117N/A * Make sure this is a character special file 1117N/A * Return the st_rdev value if the caller wants it 1117N/A * Open the existing device file 1117N/A * Get the VISUAL environment device identifier name 1117N/A * If the caller wants it, return the frame buffer model name 1117N/A}
/* get_device_identification() */ 1117N/A * GetDefaultDevicePathname() 1117N/A * This function looks for a default device and returns the pathname 1117N/A * of the first default frame buffer device that is found and can be 1117N/A * opened and provide a VISUAL environment device identifier. The 1117N/A * possible return values are: 1117N/A * Zero - Success; a default device exists and can be accessed 1117N/A * ENOENT - No frame buffer device was found 1117N/A * EACCES - Something was found, but the user can't access it 1117N/A * See whether any default device will open and identify itself 1117N/A return (0);
/* At least one FB device exists */ 1117N/A}
/* GetDefaultDevicePathname() */ 1117N/A * Given the pathname or simple filename of a real or default frame 1117N/A * buffer device, return the fully qualified pathname. 1117N/A * Partial pathnames will be treated arbitrarily in nonsense-in, 1117N/A * The caller-supplied buffer will be used if it is necessary to 1117N/A * construct a fully qualified pathname from path components. 1117N/A#
if (0)
/* Currently unused */ 1117N/A * If there's no device name, return the most likely default pathname 1117N/A#
endif /* Currently unused */ 1117N/A * Convert a default device name to a full pathname 1117N/A * Try to convert a real device filename to a full pathname 1117N/A * Return the full pathname or whatever 1117N/A * Given the current X server and the identifier for the frame buffer 1117N/A * device, construct the full pathname of the relevant configuration 1117N/A * program. Return the program pathname and a sense of whether it 1117N/A * exists (ENOENT), is accessible (EACCES), etc. 1117N/A * The caller is responsible for freeing the returned pathname 1117N/A * Build server-specific pathnames of config programs 1117N/A * Commandeer EINVAL to indicate that the X server is unknown 1117N/A * Allocate memory to contain any one of the pathnames: 1117N/A * * any device-specific config program 1117N/A * * the device-specific library used by fbconf_xorg 1117N/A * * the multi-device config program, fbconf_xorg 1117N/A * Note that the two-character "%s" conversion spec 1117N/A * in the sprintf() format string is replaced by the 1117N/A * vis_ident_name string. Its trifling length could 1117N/A * be ignored but we'll count it against the length 1117N/A * See if a config program exists, accessible or not 1117N/A return (0);
/* Have a device-specific program */ 1117N/A return (
errno);
/* Have a program w/ encumbrances */ 1117N/A * Make a note of whether a device-specific library exists 1117N/A * We'll return the multi-device config program path 1117N/A * in any case. The caller can decide, based on the 1117N/A * error code, whether and how it could be useful. 1117N/A * Construct the multi-device config program pathname 1117N/A * It's assumed that the states of existence and 1117N/A * accessibility of the config program, fbconf_xorg, 1117N/A * also hold true for its common library, 1117N/A * See if the config program exists and allows the user to execute it 1117N/A}
/* GetConfigProgramPath() */ 1117N/A * Return the full pathname of the configuration program associated 1117N/A * with this X server and fully qualified device pathname. 1117N/A * In the event of an error, an error code from errno.h space will be 1117N/A * returned, along with a NULL pathname pointer. 1117N/A * The caller is responsible for freeing the returned pathname 1117N/A * Validate the device and get its VISUAL environment identifier 1117N/A "Not a configurable device. " 1117N/A " Use -list to show valid devices."));
1117N/A * Get the config program to use with this X server and device type 1117N/A * Return the pathname of the DCM Tool GUI script and an errno-style 1117N/A * error code indicating whether the pathname is useable. 1117N/A * Display this program's command line syntax. Include the -gui 1117N/A * option only if PathToGUI() returns a non-zero error code, 1117N/A * indicating that the returned GUI pathname is useable. Then invoke 1117N/A * the actual device configuration program, iff known, to display its 1117N/A * own -help text. (The device configuration program must implement 1117N/A * the -dev and the -help option.) 1117N/A * Decide whether to show the -gui option synopsis and description 1117N/A#
if (
1)
/* ??? Cover for temporarily absent functionality ??? */ 1117N/A#
if (
1)
/* ??? Cover for temporarily absent functionality ??? */ 1117N/A * Display synopsis (usage) and description text 1117N/A "\tfbconfig [-dev devname] [-help] [-list]%s\n" 1117N/A "\t [device-specific-options]\n" 1117N/A "\t-dev\t\tSpecify the frame buffer device file name.\n" 1117N/A "\t-help\t\tDisplay this help text.\n" 1117N/A "\t-list\t\tList installed and configurable frame buffers.\n" 1117N/A "\t-xserver [Xorg | Xsun]\tConfigure the Xserver to the specified program.\n"),
1117N/A "\t-gui\t\tInvoke Graphical User Interface (SUNWdcm)\n" 1117N/A "\t\t\tto configure devices and update Xservers file.\n"));
1117N/A "\tdevice-specific-options are implemented by the device\n" 1117N/A "\t\t\tconfiguration program.\n" 1117N/A * Invoke the device config program to display its own -help text 1117N/A * ListDevices_StreamCheck() 1117N/A * See whether the specified "device" name and "stream" name are in 1117N/A * fact a device file and a stream file for the same device. (It is 1117N/A * possible that the device file is actually a stream for a previous 1117N/A * device. The stream file could be any frame buffer entity.) If a 1117N/A * character. Return a Nul character otherwise. 1117N/A * See if the potential stream name is the device name w/ a stream char 1117N/A return (
'\0');
/* The name strings are unrelated */ 1117N/A * See if the potential stream has the same device identifiers 1117N/A * Note that our caller, ListDevices(), has compared 1117N/A * this pathname length to the buffer length. Oversized 1117N/A return (
'\0');
/* Decline to pursue this */ 1117N/A return (
'\0');
/* Device identifiers don't match */ 1117N/A * Return with the stream suffix character 1117N/A}
/* ListDevices_StreamCheck() */ 1117N/A * In response to the -list option, display the frame buffer device 1117N/A * files found in the /dev/fbs directory, along with the frame 1117N/A * buffer configuration program appropriate for the type of device. 1117N/A * If there is some obvious problem with the device or the config 1117N/A * program, a diagnostic message may be displayed instead of the 1117N/A * Illustrative -list output, assuming Xorg is configured: 1117N/A * Device File Name Device Model Config Program 1117N/A * ---------------- ------------ -------------- 1117N/A * This and the FindConfigurableDevices() function are similar and 1117N/A * can be maintained together. 1117N/A/* Entry in a sorted, singly-linked list of potential device names */ 1117N/A char name[
1];
/* Name of potential device file */ 1117N/A * Insert each file name in the /dev/fbs directory into a sorted list 1117N/A * Read the next directory entry 1117N/A * Ignore anything that clearly isn't a device name 1117N/A continue;
/* Directories aren't devices */ 1117N/A continue;
/* Too long for a device pathname */ 1117N/A * Create a list entry for this potential device name 1117N/A * Insert the new name into the sorted list of names 1117N/A * Display information for each list entry that looks like a device 1117N/A * Construct the full pathname for this potential device 1117N/A * Note that this pathname length was compared to the 1117N/A * buffer length in the previous loop. Oversized 1117N/A * See if this file is a device and get its identifications 1117N/A * Determine the "Config Program" field contents 1117N/A continue;
/* Not a convincing device */ 1117N/A /* No VISUAL env identifier with which to proceed */ 1117N/A * Get the config program pathname for this device 1117N/A * Provide a diagnostic message 1117N/A default:
/* Some other mischief */ 1117N/A * Find the simple filename of the config prog 1117N/A * Check for streams that can be consolidated with this device 1117N/A * It is assumed that the device name list is sorted 1117N/A * such that all names for a given device are 1117N/A * adjacent, with the plain device name first and any 1117N/A * stream-suffixed names following. It's also 1117N/A * assumed that a stream name is the device name with 1117N/A * a one-character suffix from the set, 1117N/A * See if the next list entry has a related stream name 1117N/A break;
/* Not a related stream name */ 1117N/A * Append this stream suffix character to the substring 1117N/A * Free this now-consolidated stream entry 1117N/A * Terminate the non-empty stream suffix char substring 1117N/A * Append the stream suffix character substring 1117N/A * Display the file & any streams, model, and config prog field 1117N/A " Device File Name Device Model Config Program\n" 1117N/A " ---------------- ------------ --------------\n"));
1117N/A * If nothing was found then say so (before returning and terminating) 1117N/A "No configurable devices found in " 1117N/A * FindConfigurableDevices() 1117N/A * frame buffer device is found that can be opened and provide a 1117N/A * VISUAL environment device identifier. The possible return values 1117N/A * Zero - Success; at least one device exists and can be accessed 1117N/A * ENOENT - No frame buffer device was found 1117N/A * EACCES - Something was found, but the user can't access it 1117N/A * The -gui option will not launch the DCM Tool if this function 1117N/A * returns a non-zero value. 1117N/A * This and the ListDevices() function are similar and can be 1117N/A * See whether any default device will open and identify itself 1117N/A return (0);
/* At least one FB device exists */ 1117N/A * Examine each file in /dev/fbs until a working FB device is found 1117N/A * Read the next directory entry 1117N/A * Ignore anything that clearly isn't a device 1117N/A continue;
/* Directories aren't devices */ 1117N/A continue;
/* Too long for a device pathname */ 1117N/A * Construct the full pathname for the device 1117N/A * See if this file is a frame buffer device 1117N/A break;
/* At least one FB device exists */ 1117N/A}
/* FindConfigurableDevices() */ 1117N/A * Implement the -gui option: 1117N/A * -gui Executes the Graphics User Interface program DCMTool 1117N/A * This is done by invoking: 1117N/A * (RBAC's exec_attr entry makes that program setuid root.) 1117N/A * If successful, this function does not return. A non-zero exit 1117N/A * code is returned otherwise. 1117N/A * Make sure the GUI will have at least one device 1117N/A * The error_code returned by FindConfigurableDevices() 1117N/A * will be EACCES, ENOENT, or zero. 1117N/A "You do not have access to configure" 1117N/A " graphics devices on this system.\n" 1117N/A "You will have access if you log in" 1117N/A " to the console or you are superuser (root)."));
1117N/A "No configurable devices found in " 1117N/A * Get the pathname of the DCM Tool GUI script 1117N/A "GUI not present. Install SUNWdcm package."));
1117N/A /* execl() should not return; if it did, it failed */ 1117N/A printf(
"Fails to configure xserver to %s, not all graphics devices in the system can be configured to run with this xserver\n",
1117N/A * First check if all the listed devices supports Xorg. 1117N/A * If not, setting to Xorg will be denied. 1117N/A * If there is a XVR-50, XVR-100, XVR-300, check if efb driver exists 1117N/A printf(
"Fails to configure xserver to %s, efb driver is not installed\n",
1117N/A system(
"add_drv -n -m '* 0666 root sys' -i \"SUNW,XVR-50 SUNW,XVR-100 SUNW,XVR-300\" efb 2>/dev/null&");
1117N/A printf(
"A reboot needs to be performed to complete the reconfiguration to run Xorg\n");
1117N/A printf(
"Fails to switch to efb driver. Please check to see if SUNWefb is installed.\n");
1117N/A * First check if all the listed devices supports Xsun. 1117N/A * If not, setting to Xsun will be denied. 1117N/A * If there is a XVR-300, check if nfb driver exists 1117N/A printf(
"Fails to configure xserver to %s, nfb driver is not installed\n",
1117N/A * If there is a XVR-50, XVR-100, check if pfb driver exists 1117N/A printf(
"Fails to configure xserver to %s, pfb driver is not installed\n",
1117N/A printf(
"A reboot needs to be performed to complete the reconfiguration to run Xsun\n");
1117N/A * Do exactly one of the following, in order of precedence, depending 1117N/A * on options in the program command line (argv[]): 1117N/A * * Display fbconfig(1M) help text (-help) along with any 1117N/A * configuration program help text (-dev, -help) and then 1117N/A * * Display the installed frame buffer devices and the 1117N/A * corresponding configuration program for each (-list) and then 1117N/A * * Become the dcmtool GUI (-gui). 1117N/A * * Repackage the program argument vector and become the 1117N/A * appropriate device configuration program (-dev). 1117N/A * * Report a fatal error and terminate. 1117N/A int i;
/* argv[] argument vector index */ 1117N/A int n;
/* cfg_argv[] argument vector index */ 1117N/A * Allocate an argument vector to pass to the device config program 1117N/A * The config program (child) argument vector must be large 1117N/A * * The config program pathname ( 1 pointer ) 1117N/A * * The fbconfig(1M) arguments (argc-1 pointers) 1117N/A * * A NULL terminator ( 1 pointer ) 1117N/A * Process the fbconfig(1M) program command line arguments 1117N/A * Leave room in the child's argument vector to prepend these 1117N/A * three (CFG_ARG_1) strings: 1117N/A * * The pathname of the child config program 1117N/A * * A -dev option and a default frame buffer name 1117N/A /* Look for -help (for which -dev can be a modifier) */ 1117N/A continue;
/* Option isn't passed to child */ 1117N/A /* Look for a -list option and don't copy it */ 1117N/A continue;
/* Option isn't passed to child */ 1117N/A /* Look for a -list option and don't copy it */ 1117N/A continue;
/* Option isn't passed to child */ 1117N/A /* Look for a -gui option and don't copy it */ 1117N/A continue;
/* Option isn't passed to child */ 1117N/A /* Look for -dev and save the full device pathname */ 1117N/A * Check for -dev option errors 1117N/A "Option requires a value, -dev"));
1117N/A "Duplicate option, -dev %s"),
1117N/A * Get the fully qualified device pathname 1117N/A * Copy the -dev option to the new argument vector 1117N/A * Copy this string to the arg vector for the config program 1117N/A * Find out which X server is configured (Xsun, Xorg, ...) 1117N/A * If the X server isn't known, the GetConfigProgramPath() 1117N/A * function can't return a configuration program pathname. 1117N/A * Options such as -help and -list might still be useful, 1117N/A * however (and someday -gui will work too). 1117N/A * Try to make sure the frame buffer device pathname is known 1117N/A * If -help was specified or implied, display help text and exit 1117N/A * The -help option is implied iff there is no -list or -gui 1117N/A * option and no option or argument intended for a device 1117N/A * configuration program (n > CFG_ARG_1). The -dev option is 1117N/A * either a modifier for the explicit -help option or is an 1117N/A * option for the device configuration program. 1117N/A * If -list was specified, display the frame buffer devices and exit 1117N/A * If -gui was specified, try to become the GUI (else exit) 1117N/A * Invoke the GUI (w/o returning), else exit unsuccessfully 1117N/A#
if (
1)
/* ??? Cover for temporarily absent functionality ??? */ 1117N/A "A GUI interface is available only with the Xsun server");
1117N/A * Identify and invoke the device configuration program 1117N/A * The default -dev option, if any, should be prepended 1117N/A * rather than appended to the argument vector. If the 1117N/A * user-supplied argument vector ends badly (e.g. the last 1117N/A * option's argument is missing), the child config program 1117N/A * should be able to diagnose and report the problem 1117N/A * correctly, without tripping over an appended -dev option. 1117N/A n =
2;
/* Index for config program pathname */ 1117N/A n = 0;
/* Index for config program pathname */ 1117N/A return (
1);
/* Exit unsuccessfully */