Browse Source

Use a common base-memory packet buffer for DHCP construction (as used

by PXE and NBI) and UNDI packets (as used by undinet and UNDI).
tags/v0.9.3
Michael Brown 17 years ago
parent
commit
e42eba4af4

src/arch/i386/core/dhcp_basemem.c → src/arch/i386/core/basemem_packet.c View File

19
 /**
19
 /**
20
  * @file
20
  * @file
21
  *
21
  *
22
- * DHCP parameter block provided to external programs in base memory
22
+ * Packet buffer in base memory.  Used by various components which
23
+ * need to pass packets to and from external real-mode code.
23
  *
24
  *
24
  */
25
  */
25
 
26
 
26
-#include <dhcp_basemem.h>
27
+#include <basemem_packet.h>
27
 
28
 
28
-#undef dhcp_basemem
29
-char __data16_array ( dhcp_basemem, [DHCP_BASEMEM_LEN] );
29
+#undef basemem_packet
30
+char __data16_array ( basemem_packet, [BASEMEM_PACKET_LEN] );

+ 5
- 11
src/arch/i386/drivers/net/undinet.c View File

22
 #include <pic8259.h>
22
 #include <pic8259.h>
23
 #include <biosint.h>
23
 #include <biosint.h>
24
 #include <pnpbios.h>
24
 #include <pnpbios.h>
25
+#include <basemem_packet.h>
25
 #include <gpxe/iobuf.h>
26
 #include <gpxe/iobuf.h>
26
 #include <gpxe/netdevice.h>
27
 #include <gpxe/netdevice.h>
27
 #include <gpxe/if_ether.h>
28
 #include <gpxe/if_ether.h>
314
  *****************************************************************************
315
  *****************************************************************************
315
  */
316
  */
316
 
317
 
317
-/** Maximum length of a packet transmitted via the UNDI API */
318
-#define UNDI_IOB_LEN 1514
319
-
320
-/** UNDI I/O buffer */
321
-static char __data16_array ( undinet_iob, [UNDI_IOB_LEN] );
322
-#define undinet_iob __use_data16 ( undinet_iob )
323
-
324
 /** UNDI transmit buffer descriptor */
318
 /** UNDI transmit buffer descriptor */
325
 static struct s_PXENV_UNDI_TBD __data16 ( undinet_tbd );
319
 static struct s_PXENV_UNDI_TBD __data16 ( undinet_tbd );
326
 #define undinet_tbd __use_data16 ( undinet_tbd )
320
 #define undinet_tbd __use_data16 ( undinet_tbd )
340
 	int rc;
334
 	int rc;
341
 
335
 
342
 	/* Copy packet to UNDI I/O buffer */
336
 	/* Copy packet to UNDI I/O buffer */
343
-	if ( len > sizeof ( undinet_iob ) )
344
-		len = sizeof ( undinet_iob );
345
-	memcpy ( &undinet_iob, iobuf->data, len );
337
+	if ( len > sizeof ( basemem_packet ) )
338
+		len = sizeof ( basemem_packet );
339
+	memcpy ( &basemem_packet, iobuf->data, len );
346
 
340
 
347
 	/* Create PXENV_UNDI_TRANSMIT data structure */
341
 	/* Create PXENV_UNDI_TRANSMIT data structure */
348
 	memset ( &undi_transmit, 0, sizeof ( undi_transmit ) );
342
 	memset ( &undi_transmit, 0, sizeof ( undi_transmit ) );
357
 	undinet_tbd.ImmedLength = len;
351
 	undinet_tbd.ImmedLength = len;
358
 	undinet_tbd.Xmit.segment = rm_ds;
352
 	undinet_tbd.Xmit.segment = rm_ds;
359
 	undinet_tbd.Xmit.offset 
353
 	undinet_tbd.Xmit.offset 
360
-		= ( ( unsigned ) & __from_data16 ( undinet_iob ) );
354
+		= ( ( unsigned ) & __from_data16 ( basemem_packet ) );
361
 
355
 
362
 	/* Issue PXE API call */
356
 	/* Issue PXE API call */
363
 	if ( ( rc = undinet_call ( undinic, PXENV_UNDI_TRANSMIT,
357
 	if ( ( rc = undinet_call ( undinic, PXENV_UNDI_TRANSMIT,

+ 5
- 5
src/arch/i386/image/nbi.c View File

3
 #include <realmode.h>
3
 #include <realmode.h>
4
 #include <gateA20.h>
4
 #include <gateA20.h>
5
 #include <memsizes.h>
5
 #include <memsizes.h>
6
-#include <dhcp_basemem.h>
6
+#include <basemem_packet.h>
7
 #include <gpxe/uaccess.h>
7
 #include <gpxe/uaccess.h>
8
 #include <gpxe/segment.h>
8
 #include <gpxe/segment.h>
9
 #include <gpxe/shutdown.h>
9
 #include <gpxe/shutdown.h>
321
 		  "=b" ( discard_b )
321
 		  "=b" ( discard_b )
322
 		: "D" ( imgheader->execaddr.segoff ),
322
 		: "D" ( imgheader->execaddr.segoff ),
323
 		  "S" ( imgheader->location ),
323
 		  "S" ( imgheader->location ),
324
-		  "b" ( __from_data16 ( dhcp_basemem ) )
324
+		  "b" ( __from_data16 ( basemem_packet ) )
325
 		: "ecx", "edx", "ebp" );
325
 		: "ecx", "edx", "ebp" );
326
 
326
 
327
 	gateA20_set();
327
 	gateA20_set();
356
 		: "D" ( imgheader->execaddr.linear ),
356
 		: "D" ( imgheader->execaddr.linear ),
357
 		  "S" ( ( imgheader->location.segment << 4 ) +
357
 		  "S" ( ( imgheader->location.segment << 4 ) +
358
 			imgheader->location.offset ),
358
 			imgheader->location.offset ),
359
-		  "b" ( virt_to_phys ( dhcp_basemem ) ),
359
+		  "b" ( virt_to_phys ( basemem_packet ) ),
360
 		  "a" ( virt_to_phys ( &loaderinfo ) )
360
 		  "a" ( virt_to_phys ( &loaderinfo ) )
361
 		: "ecx", "edx", "ebp", "memory" );
361
 		: "ecx", "edx", "ebp", "memory" );
362
 
362
 
397
 		return -ENODEV;
397
 		return -ENODEV;
398
 	}
398
 	}
399
 
399
 
400
-	if ( ( rc = create_dhcp_packet ( boot_netdev, DHCPACK,
401
-					 dhcp_basemem, sizeof ( dhcp_basemem ),
400
+	if ( ( rc = create_dhcp_packet ( boot_netdev, DHCPACK, basemem_packet,
401
+					 sizeof ( basemem_packet ),
402
 					 &dhcppkt ) ) != 0 ) {
402
 					 &dhcppkt ) ) != 0 ) {
403
 		DBGC ( image, "NBI %p failed to build DHCP packet\n", image );
403
 		DBGC ( image, "NBI %p failed to build DHCP packet\n", image );
404
 		return rc;
404
 		return rc;

+ 13
- 0
src/arch/i386/include/basemem_packet.h View File

1
+#ifndef BASEMEM_PACKET_H
2
+#define BASEMEM_PACKET_H
3
+
4
+#include <realmode.h>
5
+
6
+/** Maximum length of base memory packet buffer */
7
+#define BASEMEM_PACKET_LEN 1514
8
+
9
+/** Base memory packet buffer */
10
+extern char __data16_array ( basemem_packet, [BASEMEM_PACKET_LEN] );
11
+#define basemem_packet __use_data16 ( basemem_packet )
12
+
13
+#endif /* BASEMEM_PACKET_H */

+ 0
- 13
src/arch/i386/include/dhcp_basemem.h View File

1
-#ifndef DHCP_BASEMEM_H
2
-#define DHCP_BASEMEM_H
3
-
4
-#include <realmode.h>
5
-
6
-/** Maximum length of a DHCP data buffer */
7
-#define DHCP_BASEMEM_LEN 1514
8
-
9
-/** DHCP data buffer */
10
-extern char __data16_array ( dhcp_basemem, [DHCP_BASEMEM_LEN] );
11
-#define dhcp_basemem __use_data16 ( dhcp_basemem )
12
-
13
-#endif /* DHCP_BASEMEM_H */

+ 3
- 3
src/interface/pxe/pxe_preboot.c View File

28
 #include <stdlib.h>
28
 #include <stdlib.h>
29
 #include <gpxe/uaccess.h>
29
 #include <gpxe/uaccess.h>
30
 #include <gpxe/dhcp.h>
30
 #include <gpxe/dhcp.h>
31
-#include <dhcp_basemem.h>
31
+#include <basemem_packet.h>
32
 #include "pxe.h"
32
 #include "pxe.h"
33
 #include "pxe_call.h"
33
 #include "pxe_call.h"
34
 
34
 
99
 	 */
99
 	 */
100
 	len = get_cached_info->BufferSize;
100
 	len = get_cached_info->BufferSize;
101
 	if ( len == 0 ) {
101
 	if ( len == 0 ) {
102
-		len = sizeof ( dhcp_basemem );
102
+		len = sizeof ( basemem_packet );
103
 		get_cached_info->Buffer.segment = rm_ds;
103
 		get_cached_info->Buffer.segment = rm_ds;
104
 		get_cached_info->Buffer.offset =
104
 		get_cached_info->Buffer.offset =
105
-			( unsigned int ) ( & __from_data16 ( dhcp_basemem ) );
105
+			( unsigned int ) ( & __from_data16 ( basemem_packet ) );
106
 		get_cached_info->BufferLimit = len;
106
 		get_cached_info->BufferLimit = len;
107
 	}
107
 	}
108
 
108
 

Loading…
Cancel
Save