dix: Merge AbortDDX into ddxGiveUp

These are so close to identical that most DDXes implement one in terms
of the other. All the relevant cases can be distinguished by the error
code, so merge the functions together to make things simpler.

Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
Adam Jackson 2017-11-20 14:28:13 -05:00
parent d78ac2f159
commit a23eba2a91
13 changed files with 39 additions and 122 deletions

View File

@ -1316,7 +1316,7 @@ should be terminated with a newline.
</para>
<para>
After printing the message arguments, FatalError() must be implemented
such that the server will call AbortDDX() to give the ddx layer
such that the server will call ddxGiveUp(EXIT_ERR_ABORT) to give the ddx layer
a chance to reset the hardware, and then
terminate the server; it must not return.
</para>
@ -4653,15 +4653,14 @@ An Example implementation is miPushPixels() in Xserver/mi/mipushpxl.c.</para>
<title>Shutdown Procedures</title>
<para>
<blockquote><programlisting>
void AbortDDX(enum ExitCode error)
void ddxGiveUp(enum ExitCode error)
</programlisting></blockquote>
Some hardware may require special work to be done before the server
exits so that it is not left in an intermediate state. As explained
in the OS layer, FatalError() will call AbortDDX() just before
in the OS layer, FatalError() will call ddxGiveUp() just before
terminating the server. In addition, ddxGiveUp() will be called just
before terminating the server on a "clean" death. What AbortDDX() and
ddxGiveUP do is left unspecified, only that stubs must exist in the
before terminating the server on a "clean" death. What
ddxGiveUp does is left unspecified, only that it must exist in the
ddx layer. It is up to local implementors as to what they should
accomplish before termination.</para>
<section>
@ -4923,7 +4922,6 @@ mi and fb implementations.</para>
</thead>
<tbody>
<row><entry><function>ALLOCATE_LOCAL</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
<row><entry><function>AbortDDX</function></entry><entry><literal>hd</literal></entry><entry><para></para></entry></row>
<row><entry><function>AddCallback</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
<row><entry><function>AddEnabledDevice</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
<row><entry><function>AddInputDevice</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>

View File

@ -805,11 +805,12 @@ dmxSetDefaultFontPath(const char *fp)
defaultFontPath = dmxFontPath;
}
/** This function is called in Xserver/os/utils.c from \a AbortServer().
* We must ensure that backend and console state is restored in the
* event the server shutdown wasn't clean. */
/** This function is called in Xserver/dix/main.c from \a main() when
* dispatchException & DE_TERMINATE (which is the only way to exit the
* main loop without an interruption), and from AbortServer on
* abnormal exit. */
void
AbortDDX(enum ExitCode error)
ddxGiveUp(enum ExitCode error)
{
int i;
@ -829,15 +830,6 @@ ddxBeforeReset(void)
}
#endif
/** This function is called in Xserver/dix/main.c from \a main() when
* dispatchException & DE_TERMINATE (which is the only way to exit the
* main loop without an interruption. */
void
ddxGiveUp(enum ExitCode error)
{
AbortDDX(error);
}
/** This function is called in Xserver/os/osinit.c from \a OsInit(). */
void
OsVendorInit(void)

View File

@ -163,16 +163,10 @@ KdEnableScreen(ScreenPtr pScreen)
return TRUE;
}
void
AbortDDX(enum ExitCode error)
{
KdDisableScreens();
}
void
ddxGiveUp(enum ExitCode error)
{
AbortDDX(error);
KdDisableScreens();
}
static Bool kdDumbDriver;

View File

@ -201,12 +201,6 @@ ddxGiveUp(enum ExitCode error)
}
}
void
AbortDDX(enum ExitCode error)
{
ddxGiveUp(error);
}
#ifdef __APPLE__
void
DarwinHandleGUI(int argc, char *argv[])

View File

@ -822,7 +822,7 @@ DoConfigure(void)
bail:
OsCleanup(TRUE);
AbortDDX(EXIT_ERR_CONFIGURE);
ddxGiveUp(EXIT_ERR_CONFIGURE);
fflush(stderr);
exit(0);
}
@ -875,7 +875,7 @@ DoShowOptions(void)
}
bail:
OsCleanup(TRUE);
AbortDDX(EXIT_ERR_DRIVERS);
ddxGiveUp(EXIT_ERR_DRIVERS);
fflush(stderr);
exit(0);
}

View File

@ -809,6 +809,29 @@ ddxGiveUp(enum ExitCode error)
{
int i;
if (error == EXIT_ERR_ABORT) {
input_lock();
/* try to restore the original video state */
#ifdef DPMSExtension /* Turn screens back on */
if (DPMSPowerLevel != DPMSModeOn)
DPMSSet(serverClient, DPMSModeOn);
#endif
if (xf86Screens) {
for (i = 0; i < xf86NumScreens; i++)
if (xf86Screens[i]->vtSema) {
/*
* if we are aborting before ScreenInit() has finished we
* might not have been wrapped yet. Therefore enable screen
* explicitly.
*/
xf86VGAarbiterLock(xf86Screens[i]);
(xf86Screens[i]->LeaveVT) (xf86Screens[i]);
xf86VGAarbiterUnlock(xf86Screens[i]);
}
}
}
xf86VGAarbiterFini();
if (xf86OSPMClose)
@ -832,48 +855,6 @@ ddxGiveUp(enum ExitCode error)
xf86CloseLog(error);
}
/*
* AbortDDX --
* DDX - specific abort routine. Called by AbortServer(). The attempt is
* made to restore all original setting of the displays. Also all devices
* are closed.
*/
void
AbortDDX(enum ExitCode error)
{
int i;
input_lock();
/*
* try to restore the original video state
*/
#ifdef DPMSExtension /* Turn screens back on */
if (DPMSPowerLevel != DPMSModeOn)
DPMSSet(serverClient, DPMSModeOn);
#endif
if (xf86Screens) {
for (i = 0; i < xf86NumScreens; i++)
if (xf86Screens[i]->vtSema) {
/*
* if we are aborting before ScreenInit() has finished
* we might not have been wrapped yet. Therefore enable
* screen explicitely.
*/
xf86VGAarbiterLock(xf86Screens[i]);
(xf86Screens[i]->LeaveVT) (xf86Screens[i]);
xf86VGAarbiterUnlock(xf86Screens[i]);
}
}
/*
* This is needed for an abnormal server exit, since the normal exit stuff
* MUST also be performed (i.e. the vt must be left in a defined state)
*/
ddxGiveUp(error);
}
void
OsVendorFatalError(const char *f, va_list args)
{

View File

@ -90,7 +90,7 @@
#ifndef NO_OSLIB_PROTOTYPES
/*
* This is to prevent re-entrancy to FatalError() when aborting.
* Anything that can be called as a result of AbortDDX() should use this
* Anything that can be called as a result of ddxGiveUp() should use this
* instead of FatalError().
*/

View File

@ -126,21 +126,11 @@ CloseInput(void)
mieqFini();
}
/*
* DDX - specific abort routine. Called by AbortServer().
*/
void
AbortDDX(enum ExitCode error)
{
xnestDoFullGeneration = True;
xnestCloseDisplay();
}
/* Called by GiveUp(). */
void
ddxGiveUp(enum ExitCode error)
{
AbortDDX(error);
xnestDoFullGeneration = True;
xnestCloseDisplay();
}
#ifdef __APPLE__

View File

@ -826,17 +826,3 @@ ddxGiveUp(enum ExitCode error)
{
LogClose(error);
}
/*
* AbortDDX --
* DDX - specific abort routine. Called by AbortServer(). The attempt is
* made to restore all original setting of the displays. Also all devices
* are closed.
*/
_X_NORETURN
void
AbortDDX(enum ExitCode error)
{
ErrorF(" AbortDDX\n");
OsAbort();
}

View File

@ -48,12 +48,6 @@ ddxGiveUp(enum ExitCode error)
{
}
void
AbortDDX(enum ExitCode error)
{
ddxGiveUp(error);
}
void
OsVendorInit(void)
{

View File

@ -240,16 +240,6 @@ ddxGiveUp(enum ExitCode error)
winDebug("ddxGiveUp - End\n");
}
/* See Porting Layer Definition - p. 57 */
void
AbortDDX(enum ExitCode error)
{
#if CYGDEBUG
winDebug("AbortDDX\n");
#endif
ddxGiveUp(error);
}
#ifdef __CYGWIN__
/* hasmntopt is currently not implemented for cygwin */
static const char *

View File

@ -550,8 +550,6 @@ enum ExitCode {
EXIT_ERR_DRIVERS = 3,
};
extern _X_EXPORT void
AbortDDX(enum ExitCode error);
extern _X_EXPORT void
ddxGiveUp(enum ExitCode error);
extern _X_EXPORT int

View File

@ -871,7 +871,7 @@ AbortServer(void)
CloseWellKnownConnections();
OsCleanup(TRUE);
AbortDevices();
AbortDDX(EXIT_ERR_ABORT);
ddxGiveUp(EXIT_ERR_ABORT);
fflush(stderr);
if (CoreDump)
OsAbort();