X-Git-Url: http://gitweb.hachti.de/?a=blobdiff_plain;ds=sidebyside;f=sw%2Fdisk8%2Fsrc%2Fstructures.h;fp=sw%2Fdisk8%2Fsrc%2Fstructures.h;h=0a72b01c30d355aa3ef57bcc0ffdce9accb7c425;hb=919757fd611e482003ce51f366f6783cab73dea3;hp=0000000000000000000000000000000000000000;hpb=4d042122cf54c44711dcb27547816639243ca87f;p=pdp8.git diff --git a/sw/disk8/src/structures.h b/sw/disk8/src/structures.h new file mode 100644 index 0000000..0a72b01 --- /dev/null +++ b/sw/disk8/src/structures.h @@ -0,0 +1,176 @@ +/* Data structures used in disk8 */ + +#ifndef D8_STRUCTURES_H +#define D8_STRUCTURES_H + +/* Our basic data type representing one 12 bit word */ +typedef unsigned short int p8word; + +/* + * This represents one 256 word block system memory or file system block. + * Contents can be accessed by the diskblocks[] member as well. + */ +typedef union { + p8word data [0400]; +} os8_block_t; + + +typedef struct { + p8word data[4]; +} os8_file_name_t; + + +typedef union { + p8word data[5]; + struct{ + struct{ + unsigned int device_number :4; + unsigned int file_size : 8; /* In system blocks */ + unsigned int dummy: 4; + }; + os8_file_name_t file_name; + }; +} what_was_that_t; + + +typedef struct { + /* Minus the number of entries in this segment (block) */ + p8word neg_entries; + + /* Starting block number of first file in this segment */ + p8word first_file_start; + + /* Link to next segment, 0 if no next segment */ + p8word next_segment; + + /* Flag word */ + p8word flag_word; + + /* Minus the number of additional Information words */ + p8word additional_info_neg; + + /* The directory data */ + p8word entry_data[0400-06]; + + /* End of directory word */ + p8word end_of_dir; + +} os8_directory_segment_t; + + +/*! + *\brief OS/8 partition header + * + * This is the major structure of a device heading. + * Normal volumes can start the data at block 007, + * system volumes mustn't touch blocks 007-067. + */ +typedef struct { + /* 000 */ os8_block_t bootblock; + /* 001-006 */ os8_directory_segment_t directory[6]; + /* 007-012 */ os8_block_t keyboard_monitor[4]; + /* 013-015 */ os8_block_t usr[3]; + /* 016-025 */ os8_block_t device_handlers[8]; + /* 026 */ os8_block_t enter_processor; + /* 027-050 */ os8_block_t system_scratch[18]; + /* 051-053 */ os8_block_t command_decoder[3]; + /* 054-055 */ os8_block_t save_and_date_ovl[2]; + /* 056 */ os8_block_t mon_errors; + /* 057 */ os8_block_t chain_processor; + /* 060-063 */ os8_block_t system_odt[4]; + /* 064 */ os8_block_t reserved_for_expansion; + /* 065 */ os8_block_t ccl_reminiscences; + /* 066 */ os8_block_t td8e_resident_code; + /* 067 */ os8_block_t ccl_overlay; +} os8_partition_header_t; + + +/******************************************************************************** + * Following are "private" structures not directly related to OS/8. + */ + + +typedef union{ + os8_partition_header_t header; + os8_block_t data[4096]; +} os8_partition_t; + +typedef enum {IT_UNKNOWN=0, IT_DISK, IT_DECTAPE} image_type_t; + + +/* + * File system type + * System is for boot images, beginning of data at block 070. + */ +#define FST_NORMAL 0 +#define FST_SYSTEM 1 + + +/*! + *\brief Memory representation of a disk or tape image + * + * This structure contains all working info and data + * associated with a disk or DECTape image. + * The image itself \e can contain at most two complete + * filesystems as RK05 disks are split into two partitions. + */ +typedef struct { + + //! Size of the image in blocks + unsigned int size; + + //! Raw byte size of the imported file + unsigned int raw_size; + + //! Type of the image, perhaps used later + image_type_t type; + + union { + //! All blocks in the image + os8_block_t data[2*4096]; + struct { + //! The first (and - on tape - only) partition + os8_partition_t part0; + //! The second partition of a disk + os8_partition_t part1; + }; + }; +} image_t; + + +/* + * OS/8 file types + * + * Tentative files should not occur at the moment! + */ +typedef enum{ + FT_EMPTY=0, //!< A \e unused file + FT_PERMANENT, //!< A normal fixed file + FT_TENTATIVE //!< A Open file (for writing) +} os8_filetype_t; + +/* Maximal number of additional information words in a directory entry */ +#define MAX_ADDITIONAL_INFO 0200 + +typedef struct os8_dir_entry_s os8_direntry_t; + +struct os8_dir_entry_s { + os8_filetype_t type; //!< Filetype + char name[10]; //!< ASCII file name, not used on empty files + int size_blocks; //!< Size of the file in blocks + int start_block; //!< First block of the file + os8_direntry_t *next; //!< Pointer to next entry + os8_direntry_t *prev; //!< Pointer to previous entry + p8word additional_info[MAX_ADDITIONAL_INFO]; +}; + + + +typedef struct { + os8_direntry_t* entries; //!< Linked list of entries in this directory + int additional_info; //!< Size of additional info in each entry +} directory_t; + + +#endif +