SayoriOS 0.3.3

floppy.h
1 #pragma once
2
3 #include <common.h>
4 #define floppy_dmalen 0x4800
5 #define FLOPPY_MAIN 0x03f0
6 #define FLOPPY_SECO 0x0370
7 #define FLOPPY_144_CODE 4
8 #define FLOPPY_144_SECTORS_PER_TRACK 18
9 #define FLOPPY_144_SECTOR_SIZE 512
10 #define FLOPPY_144_CYLINDER_FACE_SIZE (FLOPPY_144_SECTORS_PER_TRACK * FLOPPY_144_SECTOR_SIZE)
11 #define FLOPPY_144_HEADS 2
12 #define FLOPPY_144_CYLINDER_SIZE (FLOPPY_144_CYLINDER_FACE_SIZE * FLOPPY_144_HEADS)
13
14 #define FDA 0
15 #define FDB 1
16
17 enum FloppyErrors{
18 FLOPPY_ERROR_NOSUPPORT = 1,
19 FLOPPY_ERROR_DMA = 2,
20 FLOPPY_ERROR_MOTOR = 3,
21 FLOPPY_ERROR_CMD = 4,
22 FLOPPY_ERROR_READ = 5,
23 FLOPPY_ERROR_CALIBRATE = 6,
24 FLOPPY_ERROR_TRACK = 7,
25 FLOPPY_ERROR_EOL = 8,
26 FLOPPY_ERROR_NOREADY = 9,
27 FLOPPY_ERROR_CRC = 10,
28 FLOPPY_ERROR_CONTROLLER = 11,
29 FLOPPY_ERROR_NODATA = 12,
30 FLOPPY_ERROR_NOADDR = 13,
31 FLOPPY_ERROR_DELADDR = 14,
32 FLOPPY_ERROR_CYLINDER = 15,
33 FLOPPY_ERROR_UPD765 = 16,
34 FLOPPY_ERROR_512B = 17,
35 FLOPPY_ERROR_WRITE = 18,
36 FLOPPY_ERROR_CMD_UNK = 19,
37 FLOPPY_ERROR_20INV = 20,
38 FLOPPY_ERROR_SEEK = 21,
39 FLOPPY_ERROR_INVTRACK = 22,
40 FLOPPY_ERROR_RESET = 23,
41 };
42
43 enum FloppyCommands
44 {
45 FLOPPY_CMD_READ_TRACK = 2,
46 FLOPPY_CMD_SPECIFY = 3,
47 FLOPPY_CMD_SENSE_DRIVE_STATUS = 4,
48 FLOPPY_CMD_WRITE_DATA = 5,
49 FLOPPY_CMD_READ_DATA = 6,
50 FLOPPY_CMD_RECALIBRATE = 7,
51 FLOPPY_CMD_SENSE_INTERRUPT = 8,
52 FLOPPY_CMD_WRITE_DELETED_DATA = 9,
53 FLOPPY_CMD_READ_ID = 10,
54 FLOPPY_CMD_READ_DELETED_DATA = 12,
55 FLOPPY_CMD_FORMAT_TRACK = 13,
56 FLOPPY_CMD_DUMPREG = 14,
57 FLOPPY_CMD_SEEK = 15,
58 FLOPPY_CMD_VERSION = 16,
59 FLOPPY_CMD_SCAN_EQUAL = 17,
60 FLOPPY_CMD_PERPENDICULAR_MODE = 18,
61 FLOPPY_CMD_CONFIGURE = 19,
62 FLOPPY_CMD_LOCK = 20,
63 FLOPPY_CMD_VERIFY = 22,
64 FLOPPY_CMD_SCAN_LOW_OR_EQUAL = 25,
65 FLOPPY_CMD_SCAN_HIGH_OR_EQUAL = 29
66 };
67
68 enum {
69 floppy_motor_off = 0,
70 floppy_motor_on,
71 floppy_motor_wait
72 };
73
74 typedef enum {
75 FLOPPY_READ = 1,
76 FLOPPY_WRITE = 2
77 } FloppyMode;
78
79 enum floppy_registers {
80 FLOPPY_DOR = 2, // digital output register
81 FLOPPY_MSR = 4, // master status register, read only
82 FLOPPY_FIFO = 5, // data FIFO, in DMA operation for commands
83 FLOPPY_CCR = 7 // configuration control register, write only
84 };
85
86 // The commands of interest. There are more, but we only use these here.
87 enum floppy_commands {
88 CMD_SPECIFY = 3, // SPECIFY
89 CMD_WRITE_DATA = 5, // WRITE DATA
90 CMD_READ_DATA = 6, // READ DATA
91 CMD_RECALIBRATE = 7, // RECALIBRATE
92 CMD_SENSE_INTERRUPT = 8, // SENSE INTERRUPT
93 CMD_SEEK = 15, // SEEK
94 };
95
96 enum FloppyRegisters
97 {
98 FLOPPY_STATUS_REGISTER_A = 0,
99 FLOPPY_STATUS_REGISTER_B = 1,
100 FLOPPY_DIGITAL_OUTPUT_REGISTER = 2,
101 FLOPPY_TAPE_DRIVE_REGISTER = 3,
102 FLOPPY_MAIN_STATUS_REGISTER = 4,
103 FLOPPY_DATARATE_SELECT_REGISTER = 4,
104 FLOPPY_DATA_FIFO = 5,
105 FLOPPY_DIGITAL_INPUT_REGISTER = 7,
106 FLOPPY_CONFIGURATION_CONTROL_REGISTER = 7
107 };
108 typedef size_t (*FloppyR_t)(int,char*,uint32_t,uint32_t);
109 typedef size_t (*FloppyW_t)(int,const char*,uint32_t,uint32_t);
110 typedef int (*FloppyCache_t)(int,FloppyMode,uint32_t,uint32_t*,uint32_t*);
111 typedef struct floppy
112 {
113 int Index;
114 int Addr;
115 int Status;
116 int LastErr;
117 int Ticks;
118 int Type;
119 int Motor;
120 char Name[12];
121 char FileSystem[12];
122 unsigned Cyr;
123 FloppyR_t Read;
124 FloppyW_t Write;
125 FloppyCache_t Cache;
126 const char* Buffer;
127 } floppy_t;
common.h
Основные определения ядра
floppy
Definition: floppy.h:112
floppy::Ticks
int Ticks
Тики работы дисковода
Definition: floppy.h:117
floppy::Index
int Index
Индекс устройства
Definition: floppy.h:113
floppy::LastErr
int LastErr
Посл. ошибка
Definition: floppy.h:116
floppy::Motor
int Motor
Статус мотора
Definition: floppy.h:119
floppy::Buffer
const char * Buffer
Буфер
Definition: floppy.h:126
floppy::Addr
int Addr
Адрес устройства
Definition: floppy.h:114
floppy::FileSystem
char FileSystem[12]
Файловая система
Definition: floppy.h:121
floppy::Name
char Name[12]
Название дискеты
Definition: floppy.h:120
floppy::Cache
FloppyCache_t Cache
Команда для кэша
Definition: floppy.h:125
floppy::Read
FloppyR_t Read
Команда для чтения данных
Definition: floppy.h:123
floppy::Cyr
unsigned Cyr
Цилиндры
Definition: floppy.h:122
floppy::Type
int Type
Тип устройства
Definition: floppy.h:118
floppy::Status
int Status
Статус
Definition: floppy.h:115
floppy::Write
FloppyW_t Write
Команда для записи данных
Definition: floppy.h:124