prism2.device: Compiler delint
[AROS.git] / arch / all-android / kernel / displayalert.c
blob153733b4d409d693931cf7f36d86f19e6e47a761
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Display an alert in Android GUI if possible
6 Lang: english
7 */
9 #include <aros/atomic.h>
10 #include <aros/libcall.h>
11 #include <proto/exec.h>
13 #include <inttypes.h>
14 #include <signal.h>
16 #include "kernel_base.h"
17 #include "kernel_debug.h"
18 #include "kernel_intern.h"
19 #include "kernel_unix.h"
20 #include "kernel_android.h"
22 #define D(x)
24 AROS_LH2(void, KrnDisplayAlert,
25 AROS_LHA(uint32_t, code, D0),
26 AROS_LHA(const char *, text, A0),
27 struct KernelBase *, KernelBase, 35, Kernel)
29 AROS_LIBFUNC_INIT
31 struct KernelInterface *KernelIFace = KernelBase->kb_PlatformData->iface;
32 int res;
33 sigset_t sigs;
36 * These two are inlined in Android.
37 * Enable also SIGTERM - what if AROS will want to kill us...
39 sigemptyset(&sigs);
40 sigaddset(&sigs, SIGUSR2);
41 sigaddset(&sigs, SIGTERM);
44 /* Halt the system in order not to interfere with our I/O */
45 Disable();
47 /* Send alert message to the display server */
48 if (!SendAlert(code, text))
50 /* Standard pipe break reaction, see display driver code */
51 ShutdownA(SD_ACTION_POWEROFF);
54 D(bug("[KrnDisplayAlert] Request sent, halting...\n"));
56 if (!KernelIFace)
58 /* This is early alert, KernelBase is incomplete, and the condition is not recoverable. */
59 ShutdownA(SD_ACTION_POWEROFF);
63 * Wait for SIGUSR2. Java side will deliver it to us after the alert was closed.
64 * Normally it's used for KrnCause(), and in order not to execute scheduler and
65 * SoftInts, we artificially raise our virtual privilege level.
67 AROS_ATOMIC_INC(UKB(KernelBase)->SupervisorCount);
68 KernelIFace->sigwait(&sigs, &res);
69 AROS_ATOMIC_DEC(UKB(KernelBase)->SupervisorCount);
71 D(bug("[KrnDisplayAlert] Resume execution\n"));
73 /* Recovered... */
74 Enable();
76 AROS_LIBFUNC_EXIT