From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Leonard Subject: [PATCH 3/7] mini-os: Moved events code under arch Date: Wed, 4 Jun 2014 17:06:34 +0100 Message-ID: <1401897998-29569-4-git-send-email-talex5@gmail.com> References: <538D9161.6090402@linaro.org> <1401897998-29569-1-git-send-email-talex5@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WsDiz-0005Ce-RU for xen-devel@lists.xenproject.org; Wed, 04 Jun 2014 16:07:38 +0000 Received: by mail-wi0-f169.google.com with SMTP id hi2so8100412wib.4 for ; Wed, 04 Jun 2014 09:07:35 -0700 (PDT) In-Reply-To: <1401897998-29569-1-git-send-email-talex5@gmail.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Thomas Leonard List-Id: xen-devel@lists.xenproject.org From: Karim Raslan Signed-off-by: Karim Allah Ahmed [talex5@gmail.com: separated from big ARM commit] Signed-off-by: Thomas Leonard --- extras/mini-os/arch/x86/events.c | 28 ++++++++++++++++++++++++++++ extras/mini-os/events.c | 26 ++++++-------------------- 2 files changed, 34 insertions(+), 20 deletions(-) create mode 100644 extras/mini-os/arch/x86/events.c diff --git a/extras/mini-os/arch/x86/events.c b/extras/mini-os/arch/x86/events.c new file mode 100644 index 0000000..87f8b77 --- /dev/null +++ b/extras/mini-os/arch/x86/events.c @@ -0,0 +1,28 @@ +#include +#include + +#if defined(__x86_64__) +char irqstack[2 * STACK_SIZE]; + +static struct pda +{ + int irqcount; /* offset 0 (used in x86_64.S) */ + char *irqstackptr; /* 8 */ +} cpu0_pda; +#endif + +void arch_init_events(void) { +#if defined(__x86_64__) + asm volatile("movl %0,%%fs ; movl %0,%%gs" :: "r" (0)); + wrmsrl(0xc0000101, &cpu0_pda); /* 0xc0000101 is MSR_GS_BASE */ + cpu0_pda.irqcount = -1; + cpu0_pda.irqstackptr = (void*) (((unsigned long)irqstack + 2 * STACK_SIZE) + & ~(STACK_SIZE - 1)); +#endif +} + +void arch_fini_events(void) { +#if defined(__x86_64__) + wrmsrl(0xc0000101, NULL); /* 0xc0000101 is MSR_GS_BASE */ +#endif +} diff --git a/extras/mini-os/events.c b/extras/mini-os/events.c index 2da9b01..c2bda1a 100644 --- a/extras/mini-os/events.c +++ b/extras/mini-os/events.c @@ -167,44 +167,30 @@ evtchn_port_t bind_pirq(uint32_t pirq, int will_share, return op.port; } -#if defined(__x86_64__) -char irqstack[2 * STACK_SIZE]; - -static struct pda -{ - int irqcount; /* offset 0 (used in x86_64.S) */ - char *irqstackptr; /* 8 */ -} cpu0_pda; -#endif - +void arch_init_events(void); /* * Initially all events are without a handler and disabled */ void init_events(void) { int i; -#if defined(__x86_64__) - asm volatile("movl %0,%%fs ; movl %0,%%gs" :: "r" (0)); - wrmsrl(0xc0000101, &cpu0_pda); /* 0xc0000101 is MSR_GS_BASE */ - cpu0_pda.irqcount = -1; - cpu0_pda.irqstackptr = (void*) (((unsigned long)irqstack + 2 * STACK_SIZE) - & ~(STACK_SIZE - 1)); -#endif + /* initialize event handler */ for ( i = 0; i < NR_EVS; i++ ) { ev_actions[i].handler = default_handler; mask_evtchn(i); } + + arch_init_events(); } +void arch_fini_events(void); void fini_events(void) { /* Dealloc all events */ unbind_all_ports(); -#if defined(__x86_64__) - wrmsrl(0xc0000101, NULL); /* 0xc0000101 is MSR_GS_BASE */ -#endif + arch_fini_events(); } void default_handler(evtchn_port_t port, struct pt_regs *regs, void *ignore) -- 2.0.0