| 1 | /* Data structures used in disk8 */ |
| 2 | |
| 3 | #ifndef D8_STRUCTURES_H |
| 4 | #define D8_STRUCTURES_H |
| 5 | |
| 6 | /* Our basic data type representing one 12 bit word */ |
| 7 | typedef unsigned short int p8word; |
| 8 | |
| 9 | /* |
| 10 | * This represents one 256 word block system memory or file system block. |
| 11 | * Contents can be accessed by the diskblocks[] member as well. |
| 12 | */ |
| 13 | typedef union { |
| 14 | p8word data [0400]; |
| 15 | } os8_block_t; |
| 16 | |
| 17 | |
| 18 | typedef struct { |
| 19 | p8word data[4]; |
| 20 | } os8_file_name_t; |
| 21 | |
| 22 | |
| 23 | typedef union { |
| 24 | p8word data[5]; |
| 25 | struct{ |
| 26 | struct{ |
| 27 | unsigned int device_number :4; |
| 28 | unsigned int file_size : 8; /* In system blocks */ |
| 29 | unsigned int dummy: 4; |
| 30 | }; |
| 31 | os8_file_name_t file_name; |
| 32 | }; |
| 33 | } what_was_that_t; |
| 34 | |
| 35 | |
| 36 | typedef struct { |
| 37 | /* Minus the number of entries in this segment (block) */ |
| 38 | p8word neg_entries; |
| 39 | |
| 40 | /* Starting block number of first file in this segment */ |
| 41 | p8word first_file_start; |
| 42 | |
| 43 | /* Link to next segment, 0 if no next segment */ |
| 44 | p8word next_segment; |
| 45 | |
| 46 | /* Flag word */ |
| 47 | p8word flag_word; |
| 48 | |
| 49 | /* Minus the number of additional Information words */ |
| 50 | p8word additional_info_neg; |
| 51 | |
| 52 | /* The directory data */ |
| 53 | p8word entry_data[0400-06]; |
| 54 | |
| 55 | /* End of directory word */ |
| 56 | p8word end_of_dir; |
| 57 | |
| 58 | } os8_directory_segment_t; |
| 59 | |
| 60 | |
| 61 | /*! |
| 62 | *\brief OS/8 partition header |
| 63 | * |
| 64 | * This is the major structure of a device heading. |
| 65 | * Normal volumes can start the data at block 007, |
| 66 | * system volumes mustn't touch blocks 007-067. |
| 67 | */ |
| 68 | typedef struct { |
| 69 | /* 000 */ os8_block_t bootblock; |
| 70 | /* 001-006 */ os8_directory_segment_t directory[6]; |
| 71 | /* 007-012 */ os8_block_t keyboard_monitor[4]; |
| 72 | /* 013-015 */ os8_block_t usr[3]; |
| 73 | /* 016-025 */ os8_block_t device_handlers[8]; |
| 74 | /* 026 */ os8_block_t enter_processor; |
| 75 | /* 027-050 */ os8_block_t system_scratch[18]; |
| 76 | /* 051-053 */ os8_block_t command_decoder[3]; |
| 77 | /* 054-055 */ os8_block_t save_and_date_ovl[2]; |
| 78 | /* 056 */ os8_block_t mon_errors; |
| 79 | /* 057 */ os8_block_t chain_processor; |
| 80 | /* 060-063 */ os8_block_t system_odt[4]; |
| 81 | /* 064 */ os8_block_t reserved_for_expansion; |
| 82 | /* 065 */ os8_block_t ccl_reminiscences; |
| 83 | /* 066 */ os8_block_t td8e_resident_code; |
| 84 | /* 067 */ os8_block_t ccl_overlay; |
| 85 | } os8_partition_header_t; |
| 86 | |
| 87 | |
| 88 | /******************************************************************************** |
| 89 | * Following are "private" structures not directly related to OS/8. |
| 90 | */ |
| 91 | |
| 92 | |
| 93 | typedef union{ |
| 94 | os8_partition_header_t header; |
| 95 | os8_block_t data[4096]; |
| 96 | } os8_partition_t; |
| 97 | |
| 98 | typedef enum {IT_UNKNOWN=0, IT_DISK, IT_DECTAPE} image_type_t; |
| 99 | |
| 100 | |
| 101 | /* |
| 102 | * File system type |
| 103 | * System is for boot images, beginning of data at block 070. |
| 104 | */ |
| 105 | #define FST_NORMAL 0 |
| 106 | #define FST_SYSTEM 1 |
| 107 | |
| 108 | |
| 109 | /*! |
| 110 | *\brief Memory representation of a disk or tape image |
| 111 | * |
| 112 | * This structure contains all working info and data |
| 113 | * associated with a disk or DECTape image. |
| 114 | * The image itself \e can contain at most two complete |
| 115 | * filesystems as RK05 disks are split into two partitions. |
| 116 | */ |
| 117 | typedef struct { |
| 118 | |
| 119 | //! Size of the image in blocks |
| 120 | unsigned int size; |
| 121 | |
| 122 | //! Raw byte size of the imported file |
| 123 | unsigned int raw_size; |
| 124 | |
| 125 | //! Type of the image, perhaps used later |
| 126 | image_type_t type; |
| 127 | |
| 128 | union { |
| 129 | //! All blocks in the image |
| 130 | os8_block_t data[2*4096]; |
| 131 | struct { |
| 132 | //! The first (and - on tape - only) partition |
| 133 | os8_partition_t part0; |
| 134 | //! The second partition of a disk |
| 135 | os8_partition_t part1; |
| 136 | }; |
| 137 | }; |
| 138 | } image_t; |
| 139 | |
| 140 | |
| 141 | /* |
| 142 | * OS/8 file types |
| 143 | * |
| 144 | * Tentative files should not occur at the moment! |
| 145 | */ |
| 146 | typedef enum{ |
| 147 | FT_EMPTY=0, //!< A \e unused file |
| 148 | FT_PERMANENT, //!< A normal fixed file |
| 149 | FT_TENTATIVE //!< A Open file (for writing) |
| 150 | } os8_filetype_t; |
| 151 | |
| 152 | /* Maximal number of additional information words in a directory entry */ |
| 153 | #define MAX_ADDITIONAL_INFO 0200 |
| 154 | |
| 155 | typedef struct os8_dir_entry_s os8_direntry_t; |
| 156 | |
| 157 | struct os8_dir_entry_s { |
| 158 | os8_filetype_t type; //!< Filetype |
| 159 | char name[10]; //!< ASCII file name, not used on empty files |
| 160 | int size_blocks; //!< Size of the file in blocks |
| 161 | int start_block; //!< First block of the file |
| 162 | os8_direntry_t *next; //!< Pointer to next entry |
| 163 | os8_direntry_t *prev; //!< Pointer to previous entry |
| 164 | p8word additional_info[MAX_ADDITIONAL_INFO]; |
| 165 | }; |
| 166 | |
| 167 | |
| 168 | |
| 169 | typedef struct { |
| 170 | os8_direntry_t* entries; //!< Linked list of entries in this directory |
| 171 | int additional_info; //!< Size of additional info in each entry |
| 172 | } directory_t; |
| 173 | |
| 174 | |
| 175 | #endif |
| 176 | |