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:
parent
d78ac2f159
commit
a23eba2a91
|
@ -1316,7 +1316,7 @@ should be terminated with a newline.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
After printing the message arguments, FatalError() must be implemented
|
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
|
a chance to reset the hardware, and then
|
||||||
terminate the server; it must not return.
|
terminate the server; it must not return.
|
||||||
</para>
|
</para>
|
||||||
|
@ -4653,15 +4653,14 @@ An Example implementation is miPushPixels() in Xserver/mi/mipushpxl.c.</para>
|
||||||
<title>Shutdown Procedures</title>
|
<title>Shutdown Procedures</title>
|
||||||
<para>
|
<para>
|
||||||
<blockquote><programlisting>
|
<blockquote><programlisting>
|
||||||
void AbortDDX(enum ExitCode error)
|
|
||||||
void ddxGiveUp(enum ExitCode error)
|
void ddxGiveUp(enum ExitCode error)
|
||||||
</programlisting></blockquote>
|
</programlisting></blockquote>
|
||||||
Some hardware may require special work to be done before the server
|
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
|
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
|
terminating the server. In addition, ddxGiveUp() will be called just
|
||||||
before terminating the server on a "clean" death. What AbortDDX() and
|
before terminating the server on a "clean" death. What
|
||||||
ddxGiveUP do is left unspecified, only that stubs must exist in the
|
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
|
ddx layer. It is up to local implementors as to what they should
|
||||||
accomplish before termination.</para>
|
accomplish before termination.</para>
|
||||||
<section>
|
<section>
|
||||||
|
@ -4923,7 +4922,6 @@ mi and fb implementations.</para>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<row><entry><function>ALLOCATE_LOCAL</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
|
<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>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>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>
|
<row><entry><function>AddInputDevice</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
|
||||||
|
|
|
@ -805,11 +805,12 @@ dmxSetDefaultFontPath(const char *fp)
|
||||||
defaultFontPath = dmxFontPath;
|
defaultFontPath = dmxFontPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This function is called in Xserver/os/utils.c from \a AbortServer().
|
/** This function is called in Xserver/dix/main.c from \a main() when
|
||||||
* We must ensure that backend and console state is restored in the
|
* dispatchException & DE_TERMINATE (which is the only way to exit the
|
||||||
* event the server shutdown wasn't clean. */
|
* main loop without an interruption), and from AbortServer on
|
||||||
|
* abnormal exit. */
|
||||||
void
|
void
|
||||||
AbortDDX(enum ExitCode error)
|
ddxGiveUp(enum ExitCode error)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -829,15 +830,6 @@ ddxBeforeReset(void)
|
||||||
}
|
}
|
||||||
#endif
|
#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(). */
|
/** This function is called in Xserver/os/osinit.c from \a OsInit(). */
|
||||||
void
|
void
|
||||||
OsVendorInit(void)
|
OsVendorInit(void)
|
||||||
|
|
|
@ -163,16 +163,10 @@ KdEnableScreen(ScreenPtr pScreen)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
AbortDDX(enum ExitCode error)
|
|
||||||
{
|
|
||||||
KdDisableScreens();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ddxGiveUp(enum ExitCode error)
|
ddxGiveUp(enum ExitCode error)
|
||||||
{
|
{
|
||||||
AbortDDX(error);
|
KdDisableScreens();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool kdDumbDriver;
|
static Bool kdDumbDriver;
|
||||||
|
|
|
@ -201,12 +201,6 @@ ddxGiveUp(enum ExitCode error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
AbortDDX(enum ExitCode error)
|
|
||||||
{
|
|
||||||
ddxGiveUp(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
void
|
void
|
||||||
DarwinHandleGUI(int argc, char *argv[])
|
DarwinHandleGUI(int argc, char *argv[])
|
||||||
|
|
|
@ -822,7 +822,7 @@ DoConfigure(void)
|
||||||
|
|
||||||
bail:
|
bail:
|
||||||
OsCleanup(TRUE);
|
OsCleanup(TRUE);
|
||||||
AbortDDX(EXIT_ERR_CONFIGURE);
|
ddxGiveUp(EXIT_ERR_CONFIGURE);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
@ -875,7 +875,7 @@ DoShowOptions(void)
|
||||||
}
|
}
|
||||||
bail:
|
bail:
|
||||||
OsCleanup(TRUE);
|
OsCleanup(TRUE);
|
||||||
AbortDDX(EXIT_ERR_DRIVERS);
|
ddxGiveUp(EXIT_ERR_DRIVERS);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -809,6 +809,29 @@ ddxGiveUp(enum ExitCode error)
|
||||||
{
|
{
|
||||||
int i;
|
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();
|
xf86VGAarbiterFini();
|
||||||
|
|
||||||
if (xf86OSPMClose)
|
if (xf86OSPMClose)
|
||||||
|
@ -832,48 +855,6 @@ ddxGiveUp(enum ExitCode error)
|
||||||
xf86CloseLog(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
|
void
|
||||||
OsVendorFatalError(const char *f, va_list args)
|
OsVendorFatalError(const char *f, va_list args)
|
||||||
{
|
{
|
||||||
|
|
|
@ -90,7 +90,7 @@
|
||||||
#ifndef NO_OSLIB_PROTOTYPES
|
#ifndef NO_OSLIB_PROTOTYPES
|
||||||
/*
|
/*
|
||||||
* This is to prevent re-entrancy to FatalError() when aborting.
|
* 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().
|
* instead of FatalError().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -126,21 +126,11 @@ CloseInput(void)
|
||||||
mieqFini();
|
mieqFini();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* DDX - specific abort routine. Called by AbortServer().
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
AbortDDX(enum ExitCode error)
|
|
||||||
{
|
|
||||||
xnestDoFullGeneration = True;
|
|
||||||
xnestCloseDisplay();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Called by GiveUp(). */
|
|
||||||
void
|
void
|
||||||
ddxGiveUp(enum ExitCode error)
|
ddxGiveUp(enum ExitCode error)
|
||||||
{
|
{
|
||||||
AbortDDX(error);
|
xnestDoFullGeneration = True;
|
||||||
|
xnestCloseDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
|
|
@ -826,17 +826,3 @@ ddxGiveUp(enum ExitCode error)
|
||||||
{
|
{
|
||||||
LogClose(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();
|
|
||||||
}
|
|
||||||
|
|
|
@ -48,12 +48,6 @@ ddxGiveUp(enum ExitCode error)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
AbortDDX(enum ExitCode error)
|
|
||||||
{
|
|
||||||
ddxGiveUp(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
OsVendorInit(void)
|
OsVendorInit(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -240,16 +240,6 @@ ddxGiveUp(enum ExitCode error)
|
||||||
winDebug("ddxGiveUp - End\n");
|
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__
|
#ifdef __CYGWIN__
|
||||||
/* hasmntopt is currently not implemented for cygwin */
|
/* hasmntopt is currently not implemented for cygwin */
|
||||||
static const char *
|
static const char *
|
||||||
|
|
|
@ -550,8 +550,6 @@ enum ExitCode {
|
||||||
EXIT_ERR_DRIVERS = 3,
|
EXIT_ERR_DRIVERS = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
extern _X_EXPORT void
|
|
||||||
AbortDDX(enum ExitCode error);
|
|
||||||
extern _X_EXPORT void
|
extern _X_EXPORT void
|
||||||
ddxGiveUp(enum ExitCode error);
|
ddxGiveUp(enum ExitCode error);
|
||||||
extern _X_EXPORT int
|
extern _X_EXPORT int
|
||||||
|
|
2
os/log.c
2
os/log.c
|
@ -871,7 +871,7 @@ AbortServer(void)
|
||||||
CloseWellKnownConnections();
|
CloseWellKnownConnections();
|
||||||
OsCleanup(TRUE);
|
OsCleanup(TRUE);
|
||||||
AbortDevices();
|
AbortDevices();
|
||||||
AbortDDX(EXIT_ERR_ABORT);
|
ddxGiveUp(EXIT_ERR_ABORT);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
if (CoreDump)
|
if (CoreDump)
|
||||||
OsAbort();
|
OsAbort();
|
||||||
|
|
Loading…
Reference in New Issue