xref: /haiku/src/add-ons/kernel/partitioning_systems/amiga/amiga_rdb.h (revision 2f470aec1c92ce6917b8a903e343795dc77af41f)
1 /*
2 ** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 ** Distributed under the terms of the OpenBeOS License.
4 */
5 #ifndef AMIGA_RDB_H
6 #define AMIGA_RDB_H
7 
8 
9 #include "SupportDefs.h"
10 #include "ByteOrder.h"
11 
12 
13 struct rigid_disk_block {
14 	uint32	id;
15 	uint32	summed_longs;
16 	int32	check_sum;
17 	uint32	host_id;
18 	uint32	block_size;
19 	uint32	flags;
20 
21 	/* block list heads */
22 
23 	uint32	bad_block_list;
24 	uint32	partition_list;
25 	uint32	fs_header_list;
26 	uint32	drive_init;
27 
28 	uint32	__reserved1[6];
29 
30 	/* physical drive characteristics */
31 
32 	uint32	cylinders;
33 	uint32	sectors;
34 	uint32	heads;
35 	uint32	interleave;
36 	uint32	park;
37 	uint32	__reserved2[3];
38 	uint32	write_precompensation;
39 	uint32	reduced_write;
40 	uint32	step_rate;
41 	uint32	__reserved3[5];
42 
43 	/* logical drive characteristics */
44 
45 	uint32	rdb_blocks_low;
46 	uint32	rdb_blocks_high;
47 	uint32	low_cylinder;
48 	uint32	high_cylinder;
49 	uint32	cylinder_blocks;
50 	uint32	auto_park_seconds;
51 
52 	uint32	__reserved4[2];
53 
54 	/* drive identification */
55 
56 	char	disk_vendor[8];
57 	char	disk_product[16];
58 	char	disk_revision[4];
59 	char	controller_vendor[8];
60 	char	controller_product[16];
61 	char	controller_revision[4];
62 
63 	uint32	__reserved5[10];
64 
65 	uint32 ID() const { return B_BENDIAN_TO_HOST_INT32(id); }
66 	uint32 SummedLongs() const { return B_BENDIAN_TO_HOST_INT32(summed_longs); }
67 	uint32 BlockSize() const { return B_BENDIAN_TO_HOST_INT32(block_size); }
68 	uint32 FirstPartition() const { return B_BENDIAN_TO_HOST_INT32(partition_list); }
69 };
70 
71 #define RDB_DISK_ID			'RDSK'
72 
73 #define RDB_LOCATION_LIMIT	16
74 
75 enum rdb_flags {
76 	RDB_LAST				= 0x01,
77 	RDB_LAST_LUN			= 0x02,
78 	RDB_LAST_TID			= 0x04,
79 	RDB_NO_RESELECT			= 0x08,
80 	RDB_HAS_DISK_ID			= 0x10,
81 	RDB_HAS_CONTROLLER_ID	= 0x20,
82 	RDB_SUPPORTS_SYNCHRONOUS = 0x40,
83 };
84 
85 
86 /************* bad blocks *************/
87 
88 struct bad_block_entry {
89 };
90 
91 struct bad_block_block {
92 };
93 
94 #define RDB_BAD_BLOCK_ID	'BADB'
95 
96 
97 /************* partition block *************/
98 
99 struct partition_block {
100 	uint32	id;
101 	uint32	summed_longs;
102 	int32	check_sum;
103 	uint32	host_id;
104 	uint32	next;
105 	uint32	flags;
106 	uint32	__reserved1[2];
107 	uint32	open_device_flags;
108 	uint8	drive_name[32];		// BSTR form (Pascal like string)
109 
110 	uint32	__reserved2[15];
111 	uint32	environment[17];
112 	uint32	__reserved3[15];
113 
114 	uint32 ID() const { return B_BENDIAN_TO_HOST_INT32(id); }
115 	uint32 SummedLongs() const { return B_BENDIAN_TO_HOST_INT32(summed_longs); }
116 	uint32 Next() const { return B_BENDIAN_TO_HOST_INT32(next); }
117 };
118 
119 #define RDB_PARTITION_ID	'PART'
120 
121 enum rdb_partition_flags {
122 		RDB_PARTITION_BOOTABLE	= 0x01,
123 		RDB_PARTITION_NO_MOUNT	= 0x02,
124 };
125 
126 
127 /************* disk environment *************/
128 
129 struct disk_environment {
130 	uint32	table_size;			// size of this environment
131 	uint32	long_block_size;	// block size in longs (128 == 512 byte)
132 	uint32	sec_org;			// always 0
133 	uint32	surfaces;
134 	uint32	sectors_per_block;
135 	uint32	blocks_per_track;
136 	uint32	reserved_blocks_at_start;
137 	uint32	reserved_blocks_at_end;
138 	uint32	interleave;
139 	uint32	first_cylinder;
140 	uint32	last_cylinder;
141 	uint32	num_buffers;
142 	uint32	buffer_mem_type;
143 	uint32	max_transfer;
144 	uint32	dma_mask;
145 	int32	boot_priority;
146 	uint32	dos_type;
147 	uint32	baud_rate;
148 	uint32	control;
149 	uint32	boot_blocks;
150 
151 	uint32 FirstCylinder() const { return B_BENDIAN_TO_HOST_INT32(first_cylinder); }
152 	uint32 LastCylinder() const { return B_BENDIAN_TO_HOST_INT32(last_cylinder); }
153 	uint32 Surfaces() const { return B_BENDIAN_TO_HOST_INT32(surfaces); }
154 	uint32 BlocksPerTrack() const { return B_BENDIAN_TO_HOST_INT32(blocks_per_track); }
155 	uint32 LongBlockSize() const { return B_BENDIAN_TO_HOST_INT32(long_block_size); }
156 	uint32 BlockSize() const { return LongBlockSize() << 2; }
157 
158 	uint64 Start()
159 	{
160 		return uint64(FirstCylinder()) * BlocksPerTrack() * Surfaces() * BlockSize();
161 	}
162 
163 	uint64 Size()
164 	{
165 		return uint64(LastCylinder() + 1 - FirstCylinder()) * BlocksPerTrack() * Surfaces()
166 			* BlockSize();
167 	}
168 };
169 
170 
171 /************* file system header block *************/
172 
173 struct fs_header_block {
174 };
175 
176 #define RDB_FS_HEADER_ID	'FSHD'
177 
178 struct load_seg_block {
179 };
180 
181 #define RDB_LOAD_SEG_ID		'LSEG'
182 
183 #endif	/* AMIGA_RDB_H */
184 
185