Browse Source

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

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
f547f148d3
1 changed files with 7 additions and 12 deletions
  1. 7
    12
      src/arch/i386/drivers/net/undiload.c

+ 7
- 12
src/arch/i386/drivers/net/undiload.c View File

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

Loading…
Cancel
Save