Browse Source

Allow re-entrancy and provide a global counter of the number of

interrupts hooked.
tags/v0.9.3
Michael Brown 18 years ago
parent
commit
63499e9cfd
1 changed files with 20 additions and 0 deletions
  1. 20
    0
      src/arch/i386/interface/pcbios/biosint.c

+ 20
- 0
src/arch/i386/interface/pcbios/biosint.c View File

7
  *
7
  *
8
  */
8
  */
9
 
9
 
10
+/**
11
+ * Hooked interrupt count
12
+ *
13
+ * At exit, after unhooking all possible interrupts, this counter
14
+ * should be examined.  If it is non-zero, it means that we failed to
15
+ * unhook at least one interrupt vector, and so must not free up the
16
+ * memory we are using.  (Note that this also implies that we should
17
+ * re-hook INT 15 in order to hide ourselves from the memory map).
18
+ */
19
+int hooked_bios_interrupts = 0;
20
+
10
 /**
21
 /**
11
  * Hook INT vector
22
  * Hook INT vector
12
  *
23
  *
26
 		.offset = handler,
37
 		.offset = handler,
27
 	};
38
 	};
28
 
39
 
40
+	if ( ( chain_vector->segment != 0 ) ||
41
+	     ( chain_vector->offset != 0 ) ) {
42
+		/* Already hooked; do nothing */
43
+		return;
44
+	}
29
 	copy_from_real ( chain_vector, 0, ( interrupt * 4 ),
45
 	copy_from_real ( chain_vector, 0, ( interrupt * 4 ),
30
 			 sizeof ( *chain_vector ) );
46
 			 sizeof ( *chain_vector ) );
31
 	copy_to_real ( 0, ( interrupt * 4 ), &vector, sizeof ( vector ) );
47
 	copy_to_real ( 0, ( interrupt * 4 ), &vector, sizeof ( vector ) );
48
+	hooked_bios_interrupts++;
32
 }
49
 }
33
 
50
 
34
 /**
51
 /**
53
 		return -EBUSY;
70
 		return -EBUSY;
54
 	copy_to_real ( 0, ( interrupt * 4 ), chain_vector,
71
 	copy_to_real ( 0, ( interrupt * 4 ), chain_vector,
55
 		       sizeof ( *chain_vector ) );
72
 		       sizeof ( *chain_vector ) );
73
+	chain_vector->segment = 0;
74
+	chain_vector->offset = 0;
75
+	hooked_bios_interrupts--;
56
 	return 0;
76
 	return 0;
57
 }
77
 }

Loading…
Cancel
Save