* same with xv6
[mascara-docs.git] / i386 / ucla / src / lab3 / kern / trapentry.S
blob20eeadb7feb4d4619daf192d8b54c436b324191b
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.
15  * The function can be referenced from C++ after you declare it, for
16  * instance using "asmlinkage FUNCTIONNAME()".
17  * It pushes a trap number onto the stack, then jumps to _alltraps.
18  * Use TRAPHANDLER for traps where the CPU automatically pushes an error code.
19  */
20 #define TRAPHANDLER(name, num)                                          \
21         .globl name;            /* define global symbol for 'name' */   \
22         .type name, @function;  /* symbol type is function */           \
23         .align 2;               /* align function definition */         \
24         name:                   /* function starts here */              \
25         pushl $(num);                                                   \
26         jmp _alltraps
28 /* Use TRAPHANDLER_NOEC for traps where the CPU doesn't push an error code.
29  * It pushes a 0 in place of the error code, so the trap frame has the same
30  * format in either case.
31  */
32 #define TRAPHANDLER_NOEC(name, num)                                     \
33         .globl name;                                                    \
34         .type name, @function;                                          \
35         .align 2;                                                       \
36         name:                                                           \
37         pushl $0;                                                       \
38         pushl $(num);                                                   \
39         jmp _alltraps
41 .text
44  * Lab 2: Your code here for generating entry points for the different traps.
45  */
47  * Lab 2: Your code here for _alltraps
48  */