2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
29 * Convert zero-based linear address to far pointer.
31 #define GET_FP(x) ( (((x) & 0xffff0000) << (16 - 4)) | ((x) & 0xffff) )
33 /*==========================================================================
34 * Issue a command to the network loader.
36 * The 'cmd' command structure should be allocated on the stack to
37 * ensure that it resides within the addressable range for the
38 * network loader, which runs in real mode.
40 static UInt32
nbp(nbpCommandCode_t code
, nbpCommand_u
* cmd
)
42 loader(code
, GET_FP((UInt32
) cmd
));
44 // Must re-enable the A20 address line, the PXE firmware will
45 // disable the A20 line control.
49 return cmd
->header
.status
;
52 /*==========================================================================
53 * Unload Base Code Stack command.
55 UInt32
nbpUnloadBaseCode()
57 return nbp(nbpCommandUnloadBaseCode
, (nbpCommand_u
*) 0);
60 /*==========================================================================
61 * TFTP Read File command.
63 static long NBPLoadFile(CICell ih
, char * filePath
)
65 nbpCommandTFTPReadFile_s cmd
;
68 strcpy(cmd
.filename
, filePath
);
69 cmd
.status
= nbpStatusFailed
;
70 cmd
.bufferSize
= TFTP_LEN
;
71 cmd
.buffer
= TFTP_ADDR
;
73 verbose("Loading file: %s\n", filePath
);
75 ret
= nbp(nbpCommandTFTPReadFile
, (nbpCommand_u
*) &cmd
);
77 return (ret
== nbpStatusSuccess
) ? (long)cmd
.bufferSize
: -1;
80 /*==========================================================================
81 * GetDirEntry is not supported.
83 static long NBPGetDirEntry(CICell ih
, char * dirPath
, long * dirIndex
,
84 char ** name
, long * flags
, long * time
)
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
;