Root/
Source at commit 1900 created 12 years 4 months ago. By ifabio, Update GFX IDs list. | |
---|---|
1 | /*␊ |
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.␊ |
3 | *␊ |
4 | * @APPLE_LICENSE_HEADER_START@␊ |
5 | * ␊ |
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␊ |
12 | * this file.␊ |
13 | * ␊ |
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␊ |
20 | * under the License.␊ |
21 | * ␊ |
22 | * @APPLE_LICENSE_HEADER_END@␊ |
23 | */␊ |
24 | ␊ |
25 | #include "libsaio.h"␊ |
26 | ␊ |
27 | /* This NBP code is pretty useless because it just blindly calls INT 2B.␊ |
28 | Presumably INT 2B was implemented by some first-stage bootloader that␊ |
29 | is long gone.␊ |
30 | ␊ |
31 | One good reason to disable this is that nbpScanBootVolumes always␊ |
32 | succeeds. The scanBootVolumes function thus never fails because␊ |
33 | it always falls back to NBP. This is a problem because there is␊ |
34 | other code in the booter (for example, in open) which needs to␊ |
35 | fail instead of attempting to use this NBP which will often␊ |
36 | hang the machine.␊ |
37 | */␊ |
38 | #ifndef NBP_SUPPORT␊ |
39 | #define NBP_SUPPORT 0␊ |
40 | #endif␊ |
41 | ␊ |
42 | #if NBP_SUPPORT␊ |
43 | ␊ |
44 | /*␊ |
45 | * Convert zero-based linear address to far pointer.␊ |
46 | */␊ |
47 | #define GET_FP(x) ( (((x) & 0xffff0000) << (16 - 4)) | ((x) & 0xffff) )␊ |
48 | ␊ |
49 | /*==========================================================================␊ |
50 | * Issue a command to the network loader.␊ |
51 | *␊ |
52 | * The 'cmd' command structure should be allocated on the stack to␊ |
53 | * ensure that it resides within the addressable range for the␊ |
54 | * network loader, which runs in real mode.␊ |
55 | */␊ |
56 | static UInt32 nbp(nbpCommandCode_t code, nbpCommand_u * cmd)␊ |
57 | {␊ |
58 | ␉loader(code, GET_FP((UInt32) cmd));␊ |
59 | ␊ |
60 | ␉// Must re-enable the A20 address line, the PXE firmware will␊ |
61 | ␉// disable the A20 line control.␊ |
62 | ␉//␊ |
63 | ␉enableA20();␊ |
64 | ␊ |
65 | ␉return cmd->header.status;␊ |
66 | }␊ |
67 | ␊ |
68 | /*==========================================================================␊ |
69 | * Unload Base Code Stack command.␊ |
70 | */␊ |
71 | UInt32 nbpUnloadBaseCode()␊ |
72 | {␊ |
73 | return nbp(nbpCommandUnloadBaseCode, (nbpCommand_u *) 0);␊ |
74 | }␊ |
75 | ␊ |
76 | /*==========================================================================␊ |
77 | * TFTP Read File command.␊ |
78 | */␊ |
79 | static long NBPLoadFile(CICell ih, char * filePath)␊ |
80 | {␊ |
81 | nbpCommandTFTPReadFile_s cmd;␊ |
82 | ␉UInt32 ret;␊ |
83 | ␊ |
84 | ␉strcpy((char *)cmd.filename, filePath);␊ |
85 | ␉cmd.status = nbpStatusFailed;␊ |
86 | ␉cmd.bufferSize = TFTP_LEN;␊ |
87 | ␉cmd.buffer = TFTP_ADDR;␊ |
88 | ␊ |
89 | ␉verbose("Loading file: %s\n", filePath);␊ |
90 | ␊ |
91 | ␉ret = nbp(nbpCommandTFTPReadFile, (nbpCommand_u *) &cmd);␊ |
92 | ␊ |
93 | return (ret == nbpStatusSuccess) ? (long)cmd.bufferSize : -1;␊ |
94 | }␊ |
95 | ␊ |
96 | /*==========================================================================␊ |
97 | * GetDirEntry is not supported.␊ |
98 | */␊ |
99 | static long NBPGetDirEntry(CICell ih, char * dirPath, long long * dirIndex,␊ |
100 | char ** name, long * flags, long * time,␊ |
101 | FinderInfo * finderInfo, long * infoValid)␊ |
102 | {␊ |
103 | return -1;␊ |
104 | }␊ |
105 | ␊ |
106 | //==========================================================================␊ |
107 | ␊ |
108 | static void NBPGetDescription(CICell ih, char * str, long strMaxLen)␊ |
109 | {␊ |
110 | sprintf( str, "Ethernet PXE Client" );␊ |
111 | }␊ |
112 | ␊ |
113 | //==========================================================================␊ |
114 | ␊ |
115 | BVRef nbpScanBootVolumes( int biosdev, int * countPtr )␊ |
116 | {␊ |
117 | static BVRef gNetBVR = NULL;␊ |
118 | ␊ |
119 | if ( countPtr ) *countPtr = 1;␊ |
120 | ␊ |
121 | if ( !gNetBVR )␊ |
122 | {␊ |
123 | gNetBVR = malloc( sizeof(*gNetBVR) );␊ |
124 | if ( gNetBVR )␊ |
125 | {␊ |
126 | bzero(gNetBVR, sizeof(*gNetBVR));␊ |
127 | gNetBVR->biosdev = biosdev;␊ |
128 | gNetBVR->flags = kBVFlagPrimary | kBVFlagNativeBoot;␊ |
129 | gNetBVR->description = NBPGetDescription;␊ |
130 | gNetBVR->fs_loadfile = NBPLoadFile;␊ |
131 | gNetBVR->fs_getdirentry = NBPGetDirEntry;␊ |
132 | }␊ |
133 | }␊ |
134 | return gNetBVR;␊ |
135 | }␊ |
136 | #else␊ |
137 | BVRef nbpScanBootVolumes( int biosdev, int * countPtr )␊ |
138 | {␊ |
139 | return NULL;␊ |
140 | }␊ |
141 | UInt32 nbpUnloadBaseCode()␊ |
142 | {␊ |
143 | return 0;␊ |
144 | }␊ |
145 | #endif␊ |
146 |