divzero, softint, badsegment passed.
[mit-jos.git] / kern / trapentry.S
blobc7685c4b557c08fdd877b09769875f90a5f4831a
1 /* See COPYRIGHT for copyright information. */
3 #include <inc/mmu.h>
4 #include <inc/memlayout.h>
5 #include <inc/trap.h>
9 ###################################################################
10 # exceptions/interrupts
11 ###################################################################
13 /* The TRAPHANDLER macro defines a globally-visible function for handling
14  * a trap.  It pushes a trap number onto the stack, then jumps to _alltraps.
15  * Use TRAPHANDLER for traps where the CPU automatically pushes an error code.
16  */ 
17 #define TRAPHANDLER(name, num)                                          \
18         .globl name;            /* define global symbol for 'name' */   \
19         .type name, @function;  /* symbol type is function */           \
20         .align 2;               /* align function definition */         \
21         name:                   /* function starts here */              \
22         pushl $(num);                                                   \
23         jmp _alltraps
25 /* Use TRAPHANDLER_NOEC for traps where the CPU doesn't push an error code.
26  * It pushes a 0 in place of the error code, so the trap frame has the same
27  * format in either case.
28  */
29 #define TRAPHANDLER_NOEC(name, num)                                     \
30         .globl name;                                                    \
31         .type name, @function;                                          \
32         .align 2;                                                       \
33         name:                                                           \
34         pushl $0;                                                       \
35         pushl $(num);                                                   \
36         jmp _alltraps
38 .text
41  * Lab 3: Your code here for generating entry points for the different traps.
42  */
43 TRAPHANDLER_NOEC(divzero_entry, T_DIVIDE);
44 TRAPHANDLER_NOEC(debug_entry, T_DEBUG);
45 TRAPHANDLER_NOEC(nmi_entry, T_NMI);
46 TRAPHANDLER_NOEC(brkpt_entry, T_BRKPT);
47 TRAPHANDLER_NOEC(oflow_entry, T_OFLOW);
48 TRAPHANDLER_NOEC(bound_entry, T_BOUND);
49 TRAPHANDLER_NOEC(illop_entry, T_ILLOP);
50 TRAPHANDLER_NOEC(device_entry, T_DEVICE);
51 TRAPHANDLER(dblflt_entry, T_DBLFLT);
52 TRAPHANDLER(tss_entry, T_TSS);
53 TRAPHANDLER(segnp_entry, T_SEGNP);
54 TRAPHANDLER(stack_entry, T_STACK);
55 TRAPHANDLER(gpflt_entry, T_GPFLT);
56 TRAPHANDLER(pgflt_entry, T_PGFLT);
57 TRAPHANDLER_NOEC(fperr_entry, T_FPERR);
58 TRAPHANDLER(align_entry, T_ALIGN);
59 TRAPHANDLER_NOEC(mchk_entry, T_MCHK);
60 TRAPHANDLER_NOEC(simderr_entry, T_SIMDERR);
64  * Lab 3: Your code here for _alltraps
65  */
66 _alltraps:
67         pushl %ds
68         pushl %es
69         pushal
70         movl $GD_KD, %eax
71         movw %ax, %ds
72         movw %ax, %es
73         pushl %esp
74         call trap
75         pop %esp
76         popal
77         popl %es
78         popl %ds
79         iret