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 | #ifndef __LIBSAIO_SAIO_INTERNAL_H␊ |
26 | #define __LIBSAIO_SAIO_INTERNAL_H␊ |
27 | ␊ |
28 | #include "saio_types.h"␊ |
29 | ␊ |
30 | /* asm.s */␊ |
31 | extern void real_to_prot(void);␊ |
32 | extern void prot_to_real(void);␊ |
33 | extern void halt(void);␊ |
34 | extern void startprog(unsigned int address, void *arg);␊ |
35 | #ifdef NBP_SUPPORT␊ |
36 | extern void loader(UInt32 code, UInt32 cmdptr);␊ |
37 | #endif␊ |
38 | ␊ |
39 | /* bios.s */␊ |
40 | extern void bios(biosBuf_t *bb);␊ |
41 | ␊ |
42 | /* biosfn.c */␊ |
43 | #ifdef EISA_SUPPORT␊ |
44 | extern bool eisa_present(void);␊ |
45 | #endif␊ |
46 | extern int bgetc(void);␊ |
47 | extern int biosread(int dev, int cyl, int head, int sec, int num);␊ |
48 | extern int ebiosread(int dev, unsigned long long sec, int count);␊ |
49 | extern int ebioswrite(int dev, long sec, int count);␊ |
50 | extern int get_drive_info(int drive, struct driveInfo *dp);␊ |
51 | extern int ebiosEjectMedia(int biosdev);␊ |
52 | extern void putc(int ch);␊ |
53 | extern void putca(int ch, int attr, int repeat);␊ |
54 | extern int getc(void);␊ |
55 | extern void pause();␊ |
56 | extern int readKeyboardStatus(void);␊ |
57 | extern int readKeyboardShiftFlags(void);␊ |
58 | extern unsigned int time18(void);␊ |
59 | extern void delay(int ms);␊ |
60 | extern unsigned int get_diskinfo(int dev);␊ |
61 | #if APM_SUPPORT␊ |
62 | extern int APMPresent(void);␊ |
63 | extern int APMConnect32(void);␊ |
64 | #endif␊ |
65 | extern int memsize(int i);␊ |
66 | extern void video_mode(int mode);␊ |
67 | extern void setCursorPosition(int x, int y, int page);␊ |
68 | extern void setCursorType(int type);␊ |
69 | extern void getCursorPositionAndType(int *x, int *y, int *type);␊ |
70 | extern void scollPage(int x1, int y1, int x2, int y2, int attr, int rows, int dir);␊ |
71 | extern void clearScreenRows(int y1, int y2);␊ |
72 | extern void setActiveDisplayPage( int page );␊ |
73 | extern unsigned long getMemoryMap(struct MemoryRange * rangeArray, unsigned long maxRangeCount,␊ |
74 | unsigned long * conMemSizePtr, unsigned long * extMemSizePtr);␊ |
75 | extern unsigned long getExtendedMemorySize();␊ |
76 | extern unsigned long getConventionalMemorySize();␊ |
77 | extern void sleep(int n);␊ |
78 | ␊ |
79 | /* bootstruct.c */␊ |
80 | extern void initKernBootStruct(void);␊ |
81 | extern void reserveKernBootStruct(void);␊ |
82 | extern void copyKernBootStruct(void);␊ |
83 | extern void finalizeBootStruct(void);␊ |
84 | extern void reserveKernLegacyBootStruct(void);␊ |
85 | ␊ |
86 | /* cache.c */␊ |
87 | extern void CacheReset();␊ |
88 | extern void CacheInit(CICell ih, long blockSize);␊ |
89 | extern long CacheRead(CICell ih, char *buffer, long long offset,␊ |
90 | long length, long cache);␊ |
91 | ␊ |
92 | /* console.c */␊ |
93 | extern bool gVerboseMode;␊ |
94 | extern bool gErrors;␊ |
95 | extern void initBooterLog(void);␊ |
96 | extern void setupBooterLog(void);␊ |
97 | extern void putchar(int ch);␊ |
98 | extern int getchar(void);␊ |
99 | extern void msglog(const char * format, ...);␊ |
100 | extern int printf(const char *format, ...);␊ |
101 | extern int error(const char *format, ...);␊ |
102 | extern int verbose(const char *format, ...);␊ |
103 | extern void stop(const char *format, ...);␊ |
104 | ␊ |
105 | /* disk.c */␊ |
106 | extern void rescanBIOSDevice(int biosdev);␊ |
107 | extern struct DiskBVMap* diskResetBootVolumes(int biosdev);␊ |
108 | extern void diskFreeMap(struct DiskBVMap *map);␊ |
109 | extern int testBiosread( int biosdev, unsigned long long secno );␊ |
110 | extern BVRef diskScanBootVolumes(int biosdev, int *count);␊ |
111 | extern void diskSeek(BVRef bvr, long long position);␊ |
112 | extern int diskRead(BVRef bvr, long addr, long length);␊ |
113 | extern int diskIsCDROM(BVRef bvr);␊ |
114 | extern int biosDevIsCDROM(int biosdev);␊ |
115 | extern BVRef getBVChainForBIOSDev(int biosdev);␊ |
116 | extern BVRef newFilteredBVChain(int minBIOSDev, int maxBIOSDev, unsigned int allowFlags, unsigned int denyFlags, int *count);␊ |
117 | extern int freeFilteredBVChain(const BVRef chain);␊ |
118 | extern int rawDiskRead(BVRef bvr, unsigned int secno, void *buffer, unsigned int len);␊ |
119 | extern int rawDiskWrite(BVRef bvr, unsigned int secno, void *buffer, unsigned int len);␊ |
120 | extern int readBootSector(int biosdev, unsigned int secno, void *buffer);␊ |
121 | extern void turnOffFloppy(void);␊ |
122 | extern int␉ testFAT32EFIBootSector( int biosdev, unsigned int secno, void * buffer );␊ |
123 | ␊ |
124 | /* hfs_compare.c */␊ |
125 | extern int32_t FastUnicodeCompare(u_int16_t *uniStr1, u_int32_t len1,␊ |
126 | ␉␉␉␉␉␉␉ u_int16_t *uniStr2, u_int32_t len2, int byte_order);␊ |
127 | extern void utf_encodestr( const u_int16_t * ucsp, int ucslen,␊ |
128 | u_int8_t * utf8p, u_int32_t bufsize, int byte_order );␊ |
129 | extern void utf_decodestr(const u_int8_t *utf8p, u_int16_t *ucsp,␊ |
130 | u_int16_t *ucslen, u_int32_t bufsize, int byte_order );␊ |
131 | ␊ |
132 | /* load.c */␊ |
133 | extern bool gHaveKernelCache;␊ |
134 | extern long ThinFatFile(void **binary, unsigned long *length);␊ |
135 | extern long DecodeMachO(void *binary, entry_t *rentry, char **raddr, int *rsize);␊ |
136 | ␊ |
137 | /* memory.c */␊ |
138 | long AllocateKernelMemory( long inSize );␊ |
139 | long AllocateMemoryRange(char * rangeName, long start, long length, long type);␊ |
140 | ␊ |
141 | /* misc.c */␊ |
142 | extern void enableA20(void);␊ |
143 | extern int checkForSupportedHardware();␊ |
144 | extern int␉ isLaptop();␊ |
145 | extern void getPlatformName(char *nameBuf);␊ |
146 | ␊ |
147 | #ifdef NBP_SUPPORT␊ |
148 | /* nbp.c */␊ |
149 | extern UInt32 nbpUnloadBaseCode();␊ |
150 | extern BVRef nbpScanBootVolumes(int biosdev, int *count);␊ |
151 | #endif␊ |
152 | ␊ |
153 | /* stringTable.c */␊ |
154 | extern char * newStringFromList(char **list, int *size);␊ |
155 | extern int stringLength(const char *table, int compress);␊ |
156 | extern bool getValueForConfigTableKey(config_file_t *config, const char *key, const char **val, int *size);␊ |
157 | extern bool removeKeyFromTable(const char *key, char *table);␊ |
158 | extern char * newStringForStringTableKey(config_file_t *config, char *key);␊ |
159 | extern char * newStringForKey(char *key, config_file_t *configBuff);␊ |
160 | extern bool getValueForBootKey(const char *line, const char *match, const char **matchval, int *len);␊ |
161 | extern bool getValueForKey(const char *key, const char **val, int *size, config_file_t *configBuff);␊ |
162 | extern const char * getStringForKey(const char * key, config_file_t *config);␊ |
163 | extern bool getBoolForKey(const char *key, bool *val, config_file_t *configBuff);␊ |
164 | extern bool getIntForKey(const char *key, int *val, config_file_t *configBuff);␊ |
165 | extern bool getColorForKey(const char *key, unsigned int *val, config_file_t *configBuff);␊ |
166 | extern bool␉ getDimensionForKey( const char *key, unsigned int *value, config_file_t *config, unsigned int dimension_max, unsigned int object_size );␊ |
167 | extern int loadConfigFile(const char *configFile, config_file_t *configBuff);␊ |
168 | extern int loadSystemConfig(config_file_t *configBuff);␊ |
169 | #ifdef BOOT_HELPER_SUPPORT␊ |
170 | extern int loadHelperConfig(config_file_t *configBuff);␊ |
171 | #endif␊ |
172 | extern int loadOverrideConfig(config_file_t *configBuff);␊ |
173 | extern char * newString(const char *oldString);␊ |
174 | extern char * getNextArg(char ** ptr, char * val);␊ |
175 | extern int␉ ParseXMLFile( char * buffer, TagPtr * dict );␊ |
176 | ␊ |
177 | /* sys.c */␊ |
178 | extern BVRef getBootVolumeRef( const char * path, const char ** outPath );␊ |
179 | extern long LoadVolumeFile(BVRef bvr, const char *fileSpec);␊ |
180 | extern long LoadFile(const char *fileSpec);␊ |
181 | extern long ReadFileAtOffset(const char * fileSpec, void *buffer, uint64_t offset, uint64_t length);␊ |
182 | extern long LoadThinFatFile(const char *fileSpec, void **binary);␊ |
183 | extern long GetDirEntry(const char *dirSpec, long long *dirIndex, const char **name,␊ |
184 | long *flags, long *time);␊ |
185 | extern long GetFileInfo(const char *dirSpec, const char *name,␊ |
186 | long *flags, long *time);␊ |
187 | extern long GetFileBlock(const char *fileSpec, unsigned long long *firstBlock);␊ |
188 | extern long GetFSUUID(char *spec, char *uuidStr);␊ |
189 | extern long CreateUUIDString(uint8_t uubytes[], int nbytes, char *uuidStr);␊ |
190 | extern int openmem(char *buf, int len);␊ |
191 | extern int open(const char *str, int how);␊ |
192 | extern int open_bvdev(const char *bvd, const char *path, int flags);␊ |
193 | extern int close(int fdesc);␊ |
194 | extern int file_size(int fdesc);␊ |
195 | extern int read(int fdesc, char *buf, int count);␊ |
196 | extern int write(int fdesc, const char *buf, int count);␊ |
197 | extern int writebyte(int fdesc, char value);␊ |
198 | extern int writeint(int fdesc, int value);␊ |
199 | extern int b_lseek(int fdesc, int addr, int ptr);␊ |
200 | extern int tell(int fdesc);␊ |
201 | extern const char * systemConfigDir(void);␊ |
202 | extern struct dirstuff * opendir(const char *path);␊ |
203 | extern struct dirstuff * vol_opendir(BVRef bvr, const char *path);␊ |
204 | extern int closedir(struct dirstuff *dirp);␊ |
205 | extern int readdir(struct dirstuff *dirp, const char **name, long *flags, long *time);␊ |
206 | extern int readdir_ext(struct dirstuff * dirp, const char ** name, long * flags,␊ |
207 | long * time, FinderInfo *finderInfo, long *infoValid);␊ |
208 | extern void flushdev(void);␊ |
209 | extern void scanBootVolumes(int biosdev, int *count);␊ |
210 | extern void scanDisks(int biosdev, int *count);␊ |
211 | extern BVRef selectBootVolume(BVRef chain);␊ |
212 | extern void getBootVolumeDescription(BVRef bvr, char *str, long strMaxLen, bool verbose);␊ |
213 | extern void setRootVolume(BVRef volume);␊ |
214 | extern void setBootGlobals(BVRef chain);␊ |
215 | extern int getDeviceDescription(BVRef volume, char *str);␊ |
216 | ␊ |
217 | extern int gBIOSDev;␊ |
218 | extern int gBootFileType;␊ |
219 | extern BVRef gBootVolume;␊ |
220 | extern BVRef gBIOSBootVolume;␊ |
221 | ␊ |
222 | extern void turnOffFloppy(void);␊ |
223 | #if UNUSED␊ |
224 | extern void ichwd_init(void);␊ |
225 | extern void ichwd_event(int sec);␊ |
226 | extern void ichwd_free(void);␊ |
227 | ␊ |
228 | /*␊ |
229 | * Exported globals here.␊ |
230 | */␊ |
231 | ␊ |
232 | /*␊ |
233 | * "imps_enabled" is non-zero if the probe sequence found IMPS␊ |
234 | * information and was successful.␊ |
235 | */␊ |
236 | extern int imps_enabled;␊ |
237 | ␊ |
238 | /*␊ |
239 | * This contains the local APIC hardware address.␊ |
240 | */␊ |
241 | extern unsigned imps_lapic_addr;␊ |
242 | ␊ |
243 | /*␊ |
244 | * This represents the number of CPUs found.␊ |
245 | */␊ |
246 | extern int imps_num_cpus;␊ |
247 | ␊ |
248 | /*␊ |
249 | * This is the primary function for probing for Intel MPS 1.1/1.4␊ |
250 | * compatible hardware and BIOS information. While probing the CPUs␊ |
251 | * information returned from the BIOS, this also starts up each CPU␊ |
252 | * and gets it ready for use.␊ |
253 | *␊ |
254 | * Call this during the early stages of OS startup, before memory can␊ |
255 | * be messed up.␊ |
256 | *␊ |
257 | * Returns N if IMPS information was found (for number of CPUs started)␊ |
258 | * and is valid, else 0.␊ |
259 | */␊ |
260 | ␊ |
261 | extern int imps_probe(void);␊ |
262 | ␊ |
263 | /*␊ |
264 | * This one is used as a "force" function. Give it the number of CPUs␊ |
265 | * to start, and it will assume a certain number and try it.␊ |
266 | */␊ |
267 | ␊ |
268 | extern int imps_force(int ncpus);␊ |
269 | #endif␊ |
270 | #endif /* !__LIBSAIO_SAIO_INTERNAL_H */␊ |
271 | |