feat(isr): add assembly code for interrupt routines
This commit is contained in:
		
							parent
							
								
									96610353c8
								
							
						
					
					
						commit
						3587364471
					
				
							
								
								
									
										46
									
								
								k/isr.S
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										46
									
								
								k/isr.S
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,46 @@
 | 
				
			|||||||
 | 
					.section .text
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					isr:
 | 
				
			||||||
 | 
					pushal              // save registers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pushl   %esp
 | 
				
			||||||
 | 
					call    generic_c_handler
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					add     $4, %esp
 | 
				
			||||||
 | 
					popal               // restore registers
 | 
				
			||||||
 | 
					add     $8, %esp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					iret
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define ISR_ERRCODE(ISR_NAME, INT_CODE) \
 | 
				
			||||||
 | 
					    .global ISR_NAME;                   \
 | 
				
			||||||
 | 
					    ISR_NAME:;                          \
 | 
				
			||||||
 | 
					    pushl   $INT_CODE;                  \
 | 
				
			||||||
 | 
					    jmp     isr;                        \
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define ISR_NO_ERRCODE(ISR_NAME, INT_CODE) \
 | 
				
			||||||
 | 
					    .global ISR_NAME;                      \
 | 
				
			||||||
 | 
					    ISR_NAME:;                             \
 | 
				
			||||||
 | 
					    pushl   $0;                            \
 | 
				
			||||||
 | 
					    pushl   $INT_CODE;                     \
 | 
				
			||||||
 | 
					    jmp     isr;                           \
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ISR_NO_ERRCODE(int_de, 0)
 | 
				
			||||||
 | 
					ISR_NO_ERRCODE(int_db, 1)
 | 
				
			||||||
 | 
					ISR_NO_ERRCODE(int_nmi, 2)
 | 
				
			||||||
 | 
					ISR_NO_ERRCODE(int_bp, 3)
 | 
				
			||||||
 | 
					ISR_NO_ERRCODE(int_of, 4)
 | 
				
			||||||
 | 
					ISR_NO_ERRCODE(int_br, 5)
 | 
				
			||||||
 | 
					ISR_NO_ERRCODE(int_ud, 6)
 | 
				
			||||||
 | 
					ISR_NO_ERRCODE(int_nm, 7)
 | 
				
			||||||
 | 
					ISR_ERRCODE(int_df, 8)
 | 
				
			||||||
 | 
					ISR_ERRCODE(int_ts, 10)
 | 
				
			||||||
 | 
					ISR_ERRCODE(int_np, 11)
 | 
				
			||||||
 | 
					ISR_ERRCODE(int_ss, 12)
 | 
				
			||||||
 | 
					ISR_ERRCODE(int_gp, 13)
 | 
				
			||||||
 | 
					ISR_ERRCODE(int_pf, 14)
 | 
				
			||||||
 | 
					ISR_NO_ERRCODE(int_mf, 16)
 | 
				
			||||||
 | 
					ISR_ERRCODE(int_ac, 17)
 | 
				
			||||||
 | 
					ISR_NO_ERRCODE(int_mc, 18)
 | 
				
			||||||
 | 
					ISR_NO_ERRCODE(int_xm, 19)
 | 
				
			||||||
 | 
					ISR_NO_ERRCODE(int_ve, 20)
 | 
				
			||||||
							
								
								
									
										24
									
								
								k/isr.h
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										24
									
								
								k/isr.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,24 @@
 | 
				
			|||||||
 | 
					#ifndef ISR_H
 | 
				
			||||||
 | 
					#define ISR_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void int_de(void);      // Divide Error
 | 
				
			||||||
 | 
					void int_db(void);      // Debug Exception
 | 
				
			||||||
 | 
					void int_nmi(void);     // NMI Interrupt
 | 
				
			||||||
 | 
					void int_bp(void);      // Breakpoint
 | 
				
			||||||
 | 
					void int_of(void);      // Overflow
 | 
				
			||||||
 | 
					void int_br(void);      // BOUND Range Exceeded
 | 
				
			||||||
 | 
					void int_ud(void);      // Invalid Opcode (Undefined Opcode)
 | 
				
			||||||
 | 
					void int_nm(void);      // Device Not Available (No Math Coprocessor)
 | 
				
			||||||
 | 
					void int_df(void);      // Double Fault
 | 
				
			||||||
 | 
					void int_ts(void);      // Invalid TSS
 | 
				
			||||||
 | 
					void int_np(void);      // Segment Not Present
 | 
				
			||||||
 | 
					void int_ss(void);      // Stack-Segment Fault
 | 
				
			||||||
 | 
					void int_gp(void);      // General Protection
 | 
				
			||||||
 | 
					void int_pf(void);      // Page Fault
 | 
				
			||||||
 | 
					void int_mf(void);      // x87 FPU Floating-Point Error (Math Fault)
 | 
				
			||||||
 | 
					void int_ac(void);      // Alignment Check
 | 
				
			||||||
 | 
					void int_mc(void);      // Machine Check
 | 
				
			||||||
 | 
					void int_xm(void);      // SIMD Floating-Point Exception
 | 
				
			||||||
 | 
					void int_ve(void);      // Virtualization Exception
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif  /* !ISR_H */
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user