source: trunk/hal/i386/__do_interrupt.c @ 1

Last change on this file since 1 was 1, checked in by alain, 5 years ago

First import

File size: 1.9 KB
Line 
1/*
2 * __do_interrupt.c - first stage interrupt handler
3 *
4 * Copyright (c) 2008,2009,2010,2011,2012 Ghassan Almaless
5 * Copyright (c) 2011,2012 UPMC Sorbonne Universites
6 *
7 * This file is part of ALMOS-kernel.
8 *
9 * ALMOS-kernel is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 2.0 of the License.
12 *
13 * ALMOS-kernel is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with ALMOS-kernel; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#include <types.h>
24#include <kdmsg.h>
25#include <device.h>
26#include <interrupt.h>
27#include <thread.h>
28#include <cpu-internal.h>
29#include <pic.h>
30#include <cpu.h>
31#include <cpu-io.h>
32
33extern int __do_syscall (unsigned arg0,
34                         unsigned arg1,
35                         unsigned arg2,
36                         unsigned arg3,
37                         unsigned service_num,
38                         int *errno);
39
40void __do_interrupt(struct cpu_regs_s *regs)
41{
42        register uint_t irq = regs->int_nr;
43        int err;
44
45#if 0
46        isr_dmsg(DEBUG, "DEBUG: IRQ %d has been recived\n", irq);
47#endif
48
49        if(irq > PIC_IRQ_MAX)
50                PANIC("Interrupt %d", irq);
51        else
52        {
53                if(irq == PIC_IRQ_MAX)
54                {
55#if 0
56                        isr_dmsg(DEBUG, "DEBUG:syscall: %x, %x, %x, %x #%d\n",
57                                 regs->ebx, regs->ecx, regs->edx, regs->edi, regs->eax);
58#endif
59                        err = 0;
60                        regs->eax = __do_syscall(regs->ebx, regs->ecx, regs->edx, regs->edi, regs->eax, &err);
61                        regs->esi = err;
62                        return;
63                }
64
65                //isr_dmsg(DEBUG, "DEBUG: [ irq %d ], thread %x\n",irq,CURRENT_THREAD);
66                do_interrupt(CURRENT_THREAD, irq);
67
68                if(irq < 8)
69                        cpu_io_out8(0x20, 0x20);
70                else
71                        if(irq < 16)
72                                cpu_io_out8(0xA0, 0x20);
73        }
74}
Note: See TracBrowser for help on using the repository browser.