Bläddra i källkod

Use {get,set}_fbms() so that allocated base memory is correctly hidden.

tags/v0.9.3
Michael Brown 17 år sedan
förälder
incheckning
f547f148d3
1 ändrade filer med 7 tillägg och 12 borttagningar
  1. 7
    12
      src/arch/i386/drivers/net/undiload.c

+ 7
- 12
src/arch/i386/drivers/net/undiload.c Visa fil

@@ -23,6 +23,7 @@
23 23
 #include <realmode.h>
24 24
 #include <bios.h>
25 25
 #include <pnpbios.h>
26
+#include <basemem.h>
26 27
 #include <gpxe/pci.h>
27 28
 #include <undi.h>
28 29
 #include <undirom.h>
@@ -51,7 +52,6 @@ static SEGOFF16_t __data16 ( undi_loader_entry );
51 52
  */
52 53
 int undi_load ( struct undi_device *undi, struct undi_rom *undirom ) {
53 54
 	struct s_PXE ppxe;
54
-	uint16_t fbms;
55 55
 	unsigned int fbms_seg;
56 56
 	uint16_t exit;
57 57
 	int rc;
@@ -65,9 +65,8 @@ int undi_load ( struct undi_device *undi, struct undi_rom *undirom ) {
65 65
 	undi_loader.DI = find_pnp_bios();
66 66
 
67 67
 	/* Allocate base memory for PXE stack */
68
-	get_real ( fbms, BDA_SEG, BDA_FBMS );
69
-	undi->restore_fbms = fbms;
70
-	fbms_seg = ( fbms << 6 );
68
+	undi->restore_fbms = get_fbms();
69
+	fbms_seg = ( undi->restore_fbms << 6 );
71 70
 	fbms_seg -= ( ( undirom->code_size + 0x0f ) >> 4 );
72 71
 	undi_loader.UNDI_CS = fbms_seg;
73 72
 	fbms_seg -= ( ( undirom->data_size + 0x0f ) >> 4 );
@@ -129,9 +128,8 @@ int undi_load ( struct undi_device *undi, struct undi_rom *undirom ) {
129 128
 	       undi->entry.segment, undi->entry.offset );
130 129
 
131 130
 	/* Update free base memory counter */
132
-	fbms = ( fbms_seg >> 6 );
133
-	put_real ( fbms, BDA_SEG, BDA_FBMS );
134
-	undi->fbms = fbms;
131
+	undi->fbms = ( fbms_seg >> 6 );
132
+	set_fbms ( undi->fbms );
135 133
 	DBGC ( undi, "UNDI %p using [%d,%d) kB of base memory\n",
136 134
 	       undi, undi->fbms, undi->restore_fbms );
137 135
 
@@ -149,7 +147,6 @@ int undi_load ( struct undi_device *undi, struct undi_rom *undirom ) {
149 147
  */
150 148
 int undi_unload ( struct undi_device *undi ) {
151 149
 	static uint32_t dead = 0xdeaddead;
152
-	uint16_t fbms;
153 150
 
154 151
 	DBGC ( undi, "UNDI %p unloading\n", undi );
155 152
 
@@ -160,12 +157,10 @@ int undi_unload ( struct undi_device *undi ) {
160 157
 		put_real ( dead, undi->ppxe.segment, undi->ppxe.offset );
161 158
 
162 159
 	/* Free base memory, if possible */
163
-	get_real ( fbms, BDA_SEG, BDA_FBMS );
164
-	if ( fbms == undi->fbms ) {
160
+	if ( undi->fbms == get_fbms() ) {
165 161
 		DBGC ( undi, "UNDI %p freeing [%d,%d) kB of base memory\n",
166 162
 		       undi, undi->fbms, undi->restore_fbms );
167
-		fbms = undi->restore_fbms;
168
-		put_real ( fbms, BDA_SEG, BDA_FBMS );
163
+		set_fbms ( undi->restore_fbms );
169 164
 		return 0;
170 165
 	} else {
171 166
 		DBGC ( undi, "UNDI %p leaking [%d,%d) kB of base memory\n",

Laddar…
Avbryt
Spara