]> git.saurik.com Git - apple/boot.git/blame - i386/libsaio/saio_types.h
boot-132.tar.gz
[apple/boot.git] / i386 / libsaio / saio_types.h
CommitLineData
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/* Useful types. */
25
26#ifndef __LIBSAIO_SAIO_TYPES_H
27#define __LIBSAIO_SAIO_TYPES_H
28
14c7c974 29#include <sys/reboot.h>
75b89a82
A
30#include <sys/types.h>
31#include "bios.h"
32#include "nbp_cmd.h"
f083c6c3 33#include <pexpert/i386/boot.h>
14c7c974 34
f083c6c3 35#if DEBUG
75b89a82
A
36#define DEBUG_DISK(x) printf x
37#else
38#define DEBUG_DISK(x)
39#endif
14c7c974 40
75b89a82
A
41typedef char BOOL;
42#define NO 0
43#define YES 1
44
45typedef unsigned long entry_t;
14c7c974
A
46
47typedef struct {
48 unsigned int sectors:8;
49 unsigned int heads:8;
50 unsigned int cylinders:16;
51} compact_diskinfo_t;
52
53struct driveParameters {
54 int cylinders;
55 int sectors;
56 int heads;
57 int totalDrives;
58};
59
bba600dd
A
60
61/*
62 * BIOS drive information.
63 */
64struct boot_drive_info {
65 struct drive_params {
66 unsigned short buf_size;
67 unsigned short info_flags;
68 unsigned long phys_cyls;
69 unsigned long phys_heads;
70 unsigned long phys_spt;
71 unsigned long long phys_sectors;
72 unsigned short phys_nbps;
73 unsigned short dpte_offset;
74 unsigned short dpte_segment;
75 unsigned short key;
76 unsigned char path_len;
77 unsigned char reserved1;
78 unsigned short reserved2;
79 unsigned char bus_type[4];
80 unsigned char interface_type[8];
81 unsigned char interface_path[8];
82 unsigned char dev_path[8];
83 unsigned char reserved3;
84 unsigned char checksum;
85 } params __attribute__((packed));
86 struct drive_dpte {
87 unsigned short io_port_base;
88 unsigned short control_port_base;
89 unsigned char head_flags;
90 unsigned char vendor_info;
91 unsigned char irq : 4;
92 unsigned char irq_unused : 4;
93 unsigned char block_count;
94 unsigned char dma_channel : 4;
95 unsigned char dma_type : 4;
96 unsigned char pio_type : 4;
97 unsigned char pio_unused : 4;
98 unsigned short option_flags;
99 unsigned short reserved;
100 unsigned char revision;
101 unsigned char checksum;
102 } dpte __attribute__((packed));
103} __attribute__((packed));
104typedef struct boot_drive_info boot_drive_info_t;
105
f083c6c3
A
106struct driveInfo {
107 boot_drive_info_t di;
108 int uses_ebios;
109 int no_emulation;
110 int biosdev;
111 int valid;
112};
113
57c72a9a
A
114typedef struct FinderInfo {
115 unsigned char data[16];
116} FinderInfo;
f083c6c3 117
75b89a82
A
118struct BootVolume;
119typedef struct BootVolume * BVRef;
120typedef struct BootVolume * CICell;
121
122typedef long (*FSInit)(CICell ih);
123typedef long (*FSLoadFile)(CICell ih, char * filePath);
57c72a9a
A
124typedef long (*FSReadFile)(CICell ih, char *filePath, void *base, unsigned long offset, unsigned long length);
125typedef long (*FSGetFileBlock)(CICell ih, char *filePath, unsigned long long *firstBlock);
75b89a82 126typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long * dirIndex,
57c72a9a
A
127 char ** name, long * flags, long * time,
128 FinderInfo * finderInfo, long * infoValid);
bba600dd 129typedef long (* FSGetUUID)(CICell ih, char *uuidStr);
75b89a82
A
130typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen);
131
132struct iob {
133 unsigned int i_flgs; /* see F_* below */
134 unsigned int i_offset; /* seek byte offset in file */
135 int i_filesize; /* size of file */
136 char * i_buf; /* file load address */
137};
138
139#define F_READ 0x1 /* file opened for reading */
140#define F_WRITE 0x2 /* file opened for writing */
141#define F_ALLOC 0x4 /* buffer allocated */
142#define F_FILE 0x8 /* file instead of device */
143#define F_NBSF 0x10 /* no bad sector forwarding */
144#define F_SSI 0x40 /* set skip sector inhibit */
145#define F_MEM 0x80 /* memory instead of file or device */
146
147struct dirstuff {
148 char * dir_path; /* directory path */
149 long dir_index; /* directory entry index */
150 BVRef dir_bvr; /* volume reference */
151};
152
f083c6c3
A
153#define BVSTRLEN 32
154
75b89a82
A
155struct BootVolume {
156 BVRef next; /* list linkage pointer */
157 int biosdev; /* BIOS device number */
f083c6c3 158 int type; /* device type (floppy, hd, network) */
75b89a82
A
159 unsigned int flags; /* attribute flags */
160 BVGetDescription description; /* BVGetDescription function */
161 int part_no; /* partition number (1 based) */
162 unsigned int part_boff; /* partition block offset */
163 unsigned int part_type; /* partition type */
164 unsigned int fs_boff; /* 1st block # of next read */
bba600dd 165 unsigned int fs_byteoff; /* Byte offset for read within block */
75b89a82 166 FSLoadFile fs_loadfile; /* FSLoadFile function */
57c72a9a 167 FSReadFile fs_readfile; /* FSReadFile function */
75b89a82 168 FSGetDirEntry fs_getdirentry; /* FSGetDirEntry function */
57c72a9a 169 FSGetFileBlock fs_getfileblock; /* FSGetFileBlock function */
bba600dd 170 FSGetUUID fs_getuuid; /* FSGetUUID function */
f083c6c3
A
171 unsigned int bps; /* bytes per sector for this device */
172 char name[BVSTRLEN]; /* (name of partition) */
173 char type_name[BVSTRLEN]; /* (type of partition, eg. Apple_HFS) */
174
75b89a82
A
175};
176
177enum {
178 kBVFlagPrimary = 0x01,
179 kBVFlagNativeBoot = 0x02,
180 kBVFlagForeignBoot = 0x04
181};
182
183enum {
184 kBIOSDevTypeFloppy = 0x00,
185 kBIOSDevTypeHardDrive = 0x80,
186 kBIOSDevTypeNetwork = 0xE0,
187 kBIOSDevUnitMask = 0x0F,
188 kBIOSDevTypeMask = 0xF0,
189 kBIOSDevMask = 0xFF
190};
191
bba600dd 192
f083c6c3
A
193//#define BIOS_DEV_TYPE(d) ((d) & kBIOSDevTypeMask)
194#define BIOS_DEV_UNIT(bvr) ((bvr)->biosdev - (bvr)->type)
75b89a82
A
195
196/*
197 * KernBootStruct device types.
198 */
199enum {
200 DEV_SD = 0,
201 DEV_HD = 1,
202 DEV_FD = 2,
203 DEV_EN = 3
204};
205
206#ifndef max
207#define max(a,b) ((a) > (b) ? (a) : (b))
208#endif
209
210#ifndef min
211#define min(a,b) ((a) < (b) ? (a) : (b))
212#endif
213
214#define MAKEKERNDEV(t, u, p) MAKEBOOTDEV(t, 0, 0, u, p)
215
f083c6c3
A
216enum {
217 kNetworkDeviceType = kBIOSDevTypeNetwork,
218 kBlockDeviceType = kBIOSDevTypeHardDrive
219} gBootFileType_t;
220
bba600dd
A
221enum {
222 kCursorTypeHidden = 0x0100,
223 kCursorTypeUnderline = 0x0607
224};
225
14c7c974 226#endif /* !__LIBSAIO_SAIO_TYPES_H */