2 * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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
22 * @APPLE_LICENSE_HEADER_END@
26 #ifndef __LIBSAIO_SAIO_TYPES_H
27 #define __LIBSAIO_SAIO_TYPES_H
29 #include <sys/reboot.h>
30 #include <sys/types.h>
33 #include <pexpert/i386/boot.h>
36 #define DEBUG_DISK(x) printf x
45 typedef unsigned long entry_t
;
48 unsigned int sectors
:8;
50 unsigned int cylinders
:16;
53 struct driveParameters
{
62 * BIOS drive information.
64 struct boot_drive_info
{
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
;
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
));
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
));
104 typedef struct boot_drive_info boot_drive_info_t
;
107 boot_drive_info_t di
;
114 typedef struct FinderInfo
{
115 unsigned char data
[16];
119 typedef struct BootVolume
* BVRef
;
120 typedef struct BootVolume
* CICell
;
122 typedef long (*FSInit
)(CICell ih
);
123 typedef long (*FSLoadFile
)(CICell ih
, char * filePath
);
124 typedef long (*FSReadFile
)(CICell ih
, char *filePath
, void *base
, unsigned long offset
, unsigned long length
);
125 typedef long (*FSGetFileBlock
)(CICell ih
, char *filePath
, unsigned long long *firstBlock
);
126 typedef long (*FSGetDirEntry
)(CICell ih
, char * dirPath
, long * dirIndex
,
127 char ** name
, long * flags
, long * time
,
128 FinderInfo
* finderInfo
, long * infoValid
);
129 typedef long (* FSGetUUID
)(CICell ih
, char *uuidStr
);
130 typedef void (*BVGetDescription
)(CICell ih
, char * str
, long strMaxLen
);
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 */
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 */
148 char * dir_path
; /* directory path */
149 long dir_index
; /* directory entry index */
150 BVRef dir_bvr
; /* volume reference */
156 BVRef next
; /* list linkage pointer */
157 int biosdev
; /* BIOS device number */
158 int type
; /* device type (floppy, hd, network) */
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 */
165 unsigned int fs_byteoff
; /* Byte offset for read within block */
166 FSLoadFile fs_loadfile
; /* FSLoadFile function */
167 FSReadFile fs_readfile
; /* FSReadFile function */
168 FSGetDirEntry fs_getdirentry
; /* FSGetDirEntry function */
169 FSGetFileBlock fs_getfileblock
; /* FSGetFileBlock function */
170 FSGetUUID fs_getuuid
; /* FSGetUUID function */
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) */
178 kBVFlagPrimary
= 0x01,
179 kBVFlagNativeBoot
= 0x02,
180 kBVFlagForeignBoot
= 0x04
184 kBIOSDevTypeFloppy
= 0x00,
185 kBIOSDevTypeHardDrive
= 0x80,
186 kBIOSDevTypeNetwork
= 0xE0,
187 kBIOSDevUnitMask
= 0x0F,
188 kBIOSDevTypeMask
= 0xF0,
193 //#define BIOS_DEV_TYPE(d) ((d) & kBIOSDevTypeMask)
194 #define BIOS_DEV_UNIT(bvr) ((bvr)->biosdev - (bvr)->type)
197 * KernBootStruct device types.
207 #define max(a,b) ((a) > (b) ? (a) : (b))
211 #define min(a,b) ((a) < (b) ? (a) : (b))
214 #define MAKEKERNDEV(t, u, p) MAKEBOOTDEV(t, 0, 0, u, p)
217 kNetworkDeviceType
= kBIOSDevTypeNetwork
,
218 kBlockDeviceType
= kBIOSDevTypeHardDrive
222 kCursorTypeHidden
= 0x0100,
223 kCursorTypeUnderline
= 0x0607
226 #endif /* !__LIBSAIO_SAIO_TYPES_H */