1/*
2** Copyright 2003, Axel D��rfler, axeld@pinc-software.de. All rights reserved.
3** Distributed under the terms of the MIT License.
4*/
5#ifndef ATARI_PARTITION_H
6#define ATARI_PARTITION_H
7
8/*
9 * An extented partition scheme exists, (several actually), cf.
10 * http://people.debian.org/~smarenka/d-i/atari-fdisk-README
11 * boot sector stuff:
12 * http://leonard.oxg.free.fr/articles/multi_atari/multi_atari.html
13 */
14
15#include "SupportDefs.h"
16#include "ByteOrder.h"
17
18/* this one is BIG endian */
19struct atari_partition_entry {
20#define ATARI_PART_EXISTS	0x01
21#define ATARI_PART_BOOTABLE	0x80
22	uint8	flags;
23	/* some known types */
24#define ATARI_PART_TYPE_GEM 'G', 'E', 'M'
25#define ATARI_PART_TYPE_LNX 'L', 'N', 'X'
26#define ATARI_PART_TYPE_OS9 'O', 'S', '9'
27	/* the one we'll use */
28#define ATARI_PART_TYPE_BFS 'B', 'F', 'S'
29	char	id[3];
30	uint32	start;
31	uint32	size;
32
33	uint8 Flags() const { return flags; }
34	uint32 Start() const { return B_BENDIAN_TO_HOST_INT32(start); }
35	uint32 Size() const { return B_BENDIAN_TO_HOST_INT32(size); }
36} _PACKED ;
37
38
39/* this one is BIG endian */
40struct atari_root_block {
41	uint8	bootcode[0x1b6];
42	uint16	cylinder_count;
43	uint8	head_count;
44	uint8	_reserved_1[1];
45	uint16	reduced_write_current_cylinder;
46	uint16	write_precomp_cynlinder;
47	uint8	landing_zone;
48	uint8	seek_rate_code;
49	uint8	interleave_factor;
50	uint8	sectors_per_track;
51	uint32	maximum_partition_size; /* in sectors (in clusters) */
52	struct atari_partition_entry	partitions[4];
53	uint32	bad_sector_list_start;
54	uint32	bad_sector_list_count;
55#define ATARI_BOOTABLE_MAGIC	0x1234
56	uint16	checksum; /* checksum? 0x1234 for bootable */
57
58	uint32 MaxPartitionSize() const { return B_BENDIAN_TO_HOST_INT16(maximum_partition_size); }
59	uint32 BadSectorsStart() const { return B_BENDIAN_TO_HOST_INT32(bad_sector_list_start); }
60	uint32 BadSectorsCount() const { return B_BENDIAN_TO_HOST_INT32(bad_sector_list_count); }
61	uint16 Checksum() const { return B_BENDIAN_TO_HOST_INT16(checksum); }
62} _PACKED ;
63
64/************* bad blocks *************/
65
66struct bad_block_entry {
67};
68
69struct bad_block_block {
70};
71
72/************* partition block *************/
73
74/* this one is BIG endian, but with LITTLE endian fields! marked LE */
75/* this is part of the filesystem... */
76struct atari_boot_block {
77	uint16	branch; /* branch code */
78	char	volume_id[6];
79	uint8	disk_id[3];
80	uint16	bytes_per_sector;	/* LE */
81	uint8	sectors_per_cluster;
82	uint16	reserved_sectors;	/* LE */
83	uint8	fat_count;
84	uint16	entries_in_root_dir;	/* LE */
85	uint16	sector_count;		/* LE */
86	uint8	media_descriptor;
87	uint16	sectors_per_fat;	/* LE */
88	uint16	sectors_per_track;	/* LE */
89	uint16	side_count;		/* LE */
90	uint16	hidden_sector_count;	/* LE */
91	/* boot code... */
92	uint16	execflag;
93	uint16	loadmode;
94	uint16	first_sector;
95	uint16	num_sectors;
96	uint32	load_addr;
97	uint32	fat_buffer;
98#define ATARI_BB_FILENAME_SZ (0x003a - 0x002e)
99	char	filename[ATARI_BB_FILENAME_SZ];
100#define ATARI_BB_BOOTCODE_SZ (0x01fe - 0x003a)
101	uint8	bootcode[ATARI_BB_BOOTCODE_SZ];
102	uint16	checksum;	/* 0x1234 if bootable */
103};
104
105
106
107#endif	/* ATARI_PARTITION_H */
108
109