2 * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 2.0 (the "License"). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
28 * Convert zero-based linear address to far pointer.
30 #define GET_FP(x) ( (((x) & 0xffff0000) << (16 - 4)) | ((x) & 0xffff) )
32 /*==========================================================================
33 * Issue a command to the network loader.
35 * The 'cmd' command structure should be allocated on the stack to
36 * ensure that it resides within the addressable range for the
37 * network loader, which runs in real mode.
39 static UInt32
nbp(nbpCommandCode_t code
, nbpCommand_u
* cmd
)
41 loader(code
, GET_FP((UInt32
) cmd
));
43 // Must re-enable the A20 address line, the PXE firmware will
44 // disable the A20 line control.
48 return cmd
->header
.status
;
51 /*==========================================================================
52 * Unload Base Code Stack command.
54 UInt32
nbpUnloadBaseCode()
56 return nbp(nbpCommandUnloadBaseCode
, (nbpCommand_u
*) 0);
59 /*==========================================================================
60 * TFTP Read File command.
62 static long NBPLoadFile(CICell ih
, char * filePath
)
64 nbpCommandTFTPReadFile_s cmd
;
67 strcpy((char *)cmd
.filename
, filePath
);
68 cmd
.status
= nbpStatusFailed
;
69 cmd
.bufferSize
= TFTP_LEN
;
70 cmd
.buffer
= TFTP_ADDR
;
72 verbose("Loading file: %s\n", filePath
);
74 ret
= nbp(nbpCommandTFTPReadFile
, (nbpCommand_u
*) &cmd
);
76 return (ret
== nbpStatusSuccess
) ? (long)cmd
.bufferSize
: -1;
79 /*==========================================================================
80 * GetDirEntry is not supported.
82 static long NBPGetDirEntry(CICell ih
, char * dirPath
, long * dirIndex
,
83 char ** name
, long * flags
, long * time
,
84 FinderInfo
* finderInfo
, long * infoValid
)
89 //==========================================================================
91 static void NBPGetDescription(CICell ih
, char * str
, long strMaxLen
)
93 sprintf( str
, "Ethernet PXE Client" );
96 //==========================================================================
98 BVRef
nbpScanBootVolumes( int biosdev
, int * countPtr
)
100 static BVRef gNetBVR
= NULL
;
102 if ( countPtr
) *countPtr
= 1;
106 gNetBVR
= malloc( sizeof(*gNetBVR
) );
109 bzero(gNetBVR
, sizeof(*gNetBVR
));
110 gNetBVR
->biosdev
= biosdev
;
111 gNetBVR
->flags
= kBVFlagPrimary
| kBVFlagNativeBoot
;
112 gNetBVR
->description
= NBPGetDescription
;
113 gNetBVR
->fs_loadfile
= NBPLoadFile
;
114 gNetBVR
->fs_getdirentry
= NBPGetDirEntry
;