diff mbox

[2/3] mini-os: provide irq on/off/save/restore functions for Mini-OS apps

Message ID 1472557883-21300-3-git-send-email-jgross@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jürgen Groß Aug. 30, 2016, 11:51 a.m. UTC
Provide non-inline variants of the local_irq_*() functions for Mini-OS
apps which should not depend on Mini-OS configuration.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 arch/x86/sched.c | 28 ++++++++++++++++++++++++++++
 include/x86/os.h | 13 +++++++++++++
 2 files changed, 41 insertions(+)

Comments

Wei Liu Aug. 30, 2016, 1:54 p.m. UTC | #1
On Tue, Aug 30, 2016 at 01:51:22PM +0200, Juergen Gross wrote:
> Provide non-inline variants of the local_irq_*() functions for Mini-OS
> apps which should not depend on Mini-OS configuration.
> 

I think it would be worth pointing out which apps need to access such
low level functionalities in commit message.

> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Jürgen Groß Aug. 30, 2016, 2:08 p.m. UTC | #2
On 30/08/16 15:54, Wei Liu wrote:
> On Tue, Aug 30, 2016 at 01:51:22PM +0200, Juergen Gross wrote:
>> Provide non-inline variants of the local_irq_*() functions for Mini-OS
>> apps which should not depend on Mini-OS configuration.
>>
> 
> I think it would be worth pointing out which apps need to access such
> low level functionalities in commit message.

I stumbled over it with ioemu-stubdom. Basically it could be any app
using e.g. wake_up() or wait_event() as those are macros fiddling with
irq on/off. xenevtchn_pending() is another candidate.

>> Signed-off-by: Juergen Gross <jgross@suse.com>
> 
> Reviewed-by: Wei Liu <wei.liu2@citrix.com>

Thanks,

Juergen
Samuel Thibault Aug. 30, 2016, 9:34 p.m. UTC | #3
Juergen Gross, on Tue 30 Aug 2016 16:08:45 +0200, wrote:
> On 30/08/16 15:54, Wei Liu wrote:
> > On Tue, Aug 30, 2016 at 01:51:22PM +0200, Juergen Gross wrote:
> >> Provide non-inline variants of the local_irq_*() functions for Mini-OS
> >> apps which should not depend on Mini-OS configuration.
> >>
> > 
> > I think it would be worth pointing out which apps need to access such
> > low level functionalities in commit message.
> 
> I stumbled over it with ioemu-stubdom. Basically it could be any app
> using e.g. wake_up() or wait_event() as those are macros fiddling with
> irq on/off. xenevtchn_pending() is another candidate.

I was thinking that we should perhaps rather make wake_up/wait_event
non-inlined, instead of exposing irq on/off.  But then I see that
it's typically used in event handlers too (e.g. *front/back.c), and
applications may want to implement some such...

> >> Signed-off-by: Juergen Gross <jgross@suse.com>
> > 
> > Reviewed-by: Wei Liu <wei.liu2@citrix.com>

Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
diff mbox

Patch

diff --git a/arch/x86/sched.c b/arch/x86/sched.c
index ec13694..e7b6954 100644
--- a/arch/x86/sched.c
+++ b/arch/x86/sched.c
@@ -135,5 +135,33 @@  void run_idle_thread(void)
 #endif
 }
 
+unsigned long __local_irq_save(void)
+{
+    unsigned long flags;
 
+    local_irq_save(flags);
+    return flags;
+}
 
+void __local_irq_restore(unsigned long flags)
+{
+    local_irq_restore(flags);
+}
+
+unsigned long __local_save_flags(void)
+{
+    unsigned long flags;
+
+    local_save_flags(flags);
+    return flags;
+}
+
+void __local_irq_disable(void)
+{
+    local_irq_disable();
+}
+
+void __local_irq_enable(void)
+{
+    local_irq_enable();
+}
diff --git a/include/x86/os.h b/include/x86/os.h
index e118b91..90ab6e6 100644
--- a/include/x86/os.h
+++ b/include/x86/os.h
@@ -176,11 +176,24 @@  static inline int irqs_disabled(void)
 
 #endif
 
+#ifdef __INSIDE_MINIOS__
 #define local_irq_save(x)	__save_and_cli(x)
 #define local_irq_restore(x)	__restore_flags(x)
 #define local_save_flags(x)	__save_flags(x)
 #define local_irq_disable()	__cli()
 #define local_irq_enable()	__sti()
+#else
+unsigned long __local_irq_save(void);
+void __local_irq_restore(unsigned long flags);
+unsigned long __local_save_flags(void);
+void __local_irq_disable(void);
+void __local_irq_enable(void);
+#define local_irq_save(x)       x = __local_irq_save()
+#define local_irq_restore(x)    __local_irq_restore(x)
+#define local_save_flags(x)     x = __local_save_flags()
+#define local_irq_disable()     __local_irq_disable()
+#define local_irq_enable()      __local_irq_enable()
+#endif
 
 /* This is a barrier for the compiler only, NOT the processor! */
 #define barrier() __asm__ __volatile__("": : :"memory")