]>
Commit | Line | Data |
---|---|---|
14c7c974 A |
1 | /* |
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
4f6e3300 A |
6 | * Portions Copyright (c) 1999 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 1.1 (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 | |
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 A |
82 | static long NBPGetDirEntry(CICell ih, char * dirPath, long * dirIndex, |
83 | char ** name, long * flags, long * time) | |
14c7c974 | 84 | { |
75b89a82 A |
85 | return -1; |
86 | } | |
87 | ||
88 | //========================================================================== | |
89 | ||
90 | static void NBPGetDescription(CICell ih, char * str, long strMaxLen) | |
91 | { | |
92 | sprintf( str, "Ethernet PXE Client" ); | |
93 | } | |
94 | ||
95 | //========================================================================== | |
96 | ||
97 | BVRef nbpScanBootVolumes( int biosdev, int * countPtr ) | |
98 | { | |
99 | static BVRef gNetBVR = NULL; | |
100 | ||
101 | if ( countPtr ) *countPtr = 1; | |
102 | ||
103 | if ( !gNetBVR ) | |
104 | { | |
105 | gNetBVR = malloc( sizeof(*gNetBVR) ); | |
106 | if ( gNetBVR ) | |
107 | { | |
108 | bzero(gNetBVR, sizeof(*gNetBVR)); | |
109 | gNetBVR->biosdev = biosdev; | |
110 | gNetBVR->flags = kBVFlagPrimary | kBVFlagNativeBoot; | |
111 | gNetBVR->description = NBPGetDescription; | |
112 | gNetBVR->fs_loadfile = NBPLoadFile; | |
113 | gNetBVR->fs_getdirentry = NBPGetDirEntry; | |
114 | } | |
115 | } | |
75b89a82 | 116 | return gNetBVR; |
14c7c974 | 117 | } |