]>
Commit | Line | Data |
---|---|---|
14c7c974 | 1 | /* |
57c72a9a | 2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved. |
14c7c974 A |
3 | * |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
57c72a9a | 6 | * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights |
4f6e3300 A |
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 | |
57c72a9a | 9 | * Source License Version 2.0 (the "License"). You may not use this file |
4f6e3300 A |
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 | |
12 | * this file. | |
14c7c974 A |
13 | * |
14 | * The Original Code and all software distributed under the License are | |
4f6e3300 | 15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER |
14c7c974 A |
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
4f6e3300 A |
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the |
19 | * License for the specific language governing rights and limitations | |
20 | * under the License. | |
14c7c974 A |
21 | * |
22 | * @APPLE_LICENSE_HEADER_END@ | |
23 | */ | |
24 | ||
25 | #include "libsaio.h" | |
75b89a82 A |
26 | |
27 | /* | |
28 | * Convert zero-based linear address to far pointer. | |
29 | */ | |
30 | #define GET_FP(x) ( (((x) & 0xffff0000) << (16 - 4)) | ((x) & 0xffff) ) | |
14c7c974 A |
31 | |
32 | /*========================================================================== | |
33 | * Issue a command to the network loader. | |
34 | * | |
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. | |
38 | */ | |
75b89a82 | 39 | static UInt32 nbp(nbpCommandCode_t code, nbpCommand_u * cmd) |
14c7c974 A |
40 | { |
41 | loader(code, GET_FP((UInt32) cmd)); | |
42 | ||
43 | // Must re-enable the A20 address line, the PXE firmware will | |
44 | // disable the A20 line control. | |
45 | // | |
46 | enableA20(); | |
47 | ||
48 | return cmd->header.status; | |
49 | } | |
50 | ||
51 | /*========================================================================== | |
75b89a82 A |
52 | * Unload Base Code Stack command. |
53 | */ | |
54 | UInt32 nbpUnloadBaseCode() | |
55 | { | |
56 | return nbp(nbpCommandUnloadBaseCode, (nbpCommand_u *) 0); | |
57 | } | |
58 | ||
59 | /*========================================================================== | |
60 | * TFTP Read File command. | |
14c7c974 | 61 | */ |
75b89a82 | 62 | static long NBPLoadFile(CICell ih, char * filePath) |
14c7c974 A |
63 | { |
64 | nbpCommandTFTPReadFile_s cmd; | |
65 | UInt32 ret; | |
66 | ||
75b89a82 | 67 | strcpy(cmd.filename, filePath); |
14c7c974 | 68 | cmd.status = nbpStatusFailed; |
75b89a82 A |
69 | cmd.bufferSize = TFTP_LEN; |
70 | cmd.buffer = TFTP_ADDR; | |
14c7c974 | 71 | |
f083c6c3 | 72 | verbose("Loading file: %s\n", filePath); |
14c7c974 | 73 | |
75b89a82 | 74 | ret = nbp(nbpCommandTFTPReadFile, (nbpCommand_u *) &cmd); |
14c7c974 | 75 | |
f083c6c3 | 76 | return (ret == nbpStatusSuccess) ? (long)cmd.bufferSize : -1; |
14c7c974 A |
77 | } |
78 | ||
79 | /*========================================================================== | |
75b89a82 | 80 | * GetDirEntry is not supported. |
14c7c974 | 81 | */ |
75b89a82 | 82 | static long NBPGetDirEntry(CICell ih, char * dirPath, long * dirIndex, |
57c72a9a A |
83 | char ** name, long * flags, long * time, |
84 | FinderInfo * finderInfo, long * infoValid) | |
14c7c974 | 85 | { |
75b89a82 A |
86 | return -1; |
87 | } | |
88 | ||
89 | //========================================================================== | |
90 | ||
91 | static void NBPGetDescription(CICell ih, char * str, long strMaxLen) | |
92 | { | |
93 | sprintf( str, "Ethernet PXE Client" ); | |
94 | } | |
95 | ||
96 | //========================================================================== | |
97 | ||
98 | BVRef nbpScanBootVolumes( int biosdev, int * countPtr ) | |
99 | { | |
100 | static BVRef gNetBVR = NULL; | |
101 | ||
102 | if ( countPtr ) *countPtr = 1; | |
103 | ||
104 | if ( !gNetBVR ) | |
105 | { | |
106 | gNetBVR = malloc( sizeof(*gNetBVR) ); | |
107 | if ( gNetBVR ) | |
108 | { | |
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; | |
115 | } | |
116 | } | |
75b89a82 | 117 | return gNetBVR; |
14c7c974 | 118 | } |