]> git.saurik.com Git - apple/boot.git/blame - i386/libsaio/saio_types.h
boot-111.1.tar.gz
[apple/boot.git] / i386 / libsaio / saio_types.h
CommitLineData
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/* 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
f083c6c3
A
60struct driveInfo {
61 boot_drive_info_t di;
62 int uses_ebios;
63 int no_emulation;
64 int biosdev;
65 int valid;
66};
67
68
75b89a82
A
69struct BootVolume;
70typedef struct BootVolume * BVRef;
71typedef struct BootVolume * CICell;
72
73typedef long (*FSInit)(CICell ih);
74typedef long (*FSLoadFile)(CICell ih, char * filePath);
75typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long * dirIndex,
76 char ** name, long * flags, long * time);
77typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen);
78
79struct iob {
80 unsigned int i_flgs; /* see F_* below */
81 unsigned int i_offset; /* seek byte offset in file */
82 int i_filesize; /* size of file */
83 char * i_buf; /* file load address */
84};
85
86#define F_READ 0x1 /* file opened for reading */
87#define F_WRITE 0x2 /* file opened for writing */
88#define F_ALLOC 0x4 /* buffer allocated */
89#define F_FILE 0x8 /* file instead of device */
90#define F_NBSF 0x10 /* no bad sector forwarding */
91#define F_SSI 0x40 /* set skip sector inhibit */
92#define F_MEM 0x80 /* memory instead of file or device */
93
94struct dirstuff {
95 char * dir_path; /* directory path */
96 long dir_index; /* directory entry index */
97 BVRef dir_bvr; /* volume reference */
98};
99
f083c6c3
A
100#define BVSTRLEN 32
101
75b89a82
A
102struct BootVolume {
103 BVRef next; /* list linkage pointer */
104 int biosdev; /* BIOS device number */
f083c6c3 105 int type; /* device type (floppy, hd, network) */
75b89a82
A
106 unsigned int flags; /* attribute flags */
107 BVGetDescription description; /* BVGetDescription function */
108 int part_no; /* partition number (1 based) */
109 unsigned int part_boff; /* partition block offset */
110 unsigned int part_type; /* partition type */
111 unsigned int fs_boff; /* 1st block # of next read */
112 FSLoadFile fs_loadfile; /* FSLoadFile function */
113 FSGetDirEntry fs_getdirentry; /* FSGetDirEntry function */
f083c6c3
A
114 unsigned int bps; /* bytes per sector for this device */
115 char name[BVSTRLEN]; /* (name of partition) */
116 char type_name[BVSTRLEN]; /* (type of partition, eg. Apple_HFS) */
117
75b89a82
A
118};
119
120enum {
121 kBVFlagPrimary = 0x01,
122 kBVFlagNativeBoot = 0x02,
123 kBVFlagForeignBoot = 0x04
124};
125
126enum {
127 kBIOSDevTypeFloppy = 0x00,
128 kBIOSDevTypeHardDrive = 0x80,
129 kBIOSDevTypeNetwork = 0xE0,
130 kBIOSDevUnitMask = 0x0F,
131 kBIOSDevTypeMask = 0xF0,
132 kBIOSDevMask = 0xFF
133};
134
f083c6c3
A
135//#define BIOS_DEV_TYPE(d) ((d) & kBIOSDevTypeMask)
136#define BIOS_DEV_UNIT(bvr) ((bvr)->biosdev - (bvr)->type)
75b89a82
A
137
138/*
139 * KernBootStruct device types.
140 */
141enum {
142 DEV_SD = 0,
143 DEV_HD = 1,
144 DEV_FD = 2,
145 DEV_EN = 3
146};
147
148#ifndef max
149#define max(a,b) ((a) > (b) ? (a) : (b))
150#endif
151
152#ifndef min
153#define min(a,b) ((a) < (b) ? (a) : (b))
154#endif
155
156#define MAKEKERNDEV(t, u, p) MAKEBOOTDEV(t, 0, 0, u, p)
157
f083c6c3
A
158enum {
159 kNetworkDeviceType = kBIOSDevTypeNetwork,
160 kBlockDeviceType = kBIOSDevTypeHardDrive
161} gBootFileType_t;
162
14c7c974 163#endif /* !__LIBSAIO_SAIO_TYPES_H */