]> git.sur5r.net Git - cc65/blob - include/dio.h
Stefan Haubenthal fixed a few typos.
[cc65] / include / dio.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                   dio.h                                   */
4 /*                                                                           */
5 /*                       Low-Level diskette I/O functions                    */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 2005 Christian Groessler <cpg@aladdin.de>                             */
10 /*                                                                           */
11 /*                                                                           */
12 /* This software is provided 'as-is', without any expressed or implied       */
13 /* warranty.  In no event will the authors be held liable for any damages    */
14 /* arising from the use of this software.                                    */
15 /*                                                                           */
16 /* Permission is granted to anyone to use this software for any purpose,     */
17 /* including commercial applications, and to alter it and redistribute it    */
18 /* freely, subject to the following restrictions:                            */
19 /*                                                                           */
20 /* 1. The origin of this software must not be misrepresented; you must not   */
21 /*    claim that you wrote the original software. If you use this software   */
22 /*    in a product, an acknowledgment in the product documentation would be  */
23 /*    appreciated but is not required.                                       */
24 /* 2. Altered source versions must be plainly marked as such, and must not   */
25 /*    be misrepresented as being the original software.                      */
26 /* 3. This notice may not be removed or altered from any source              */
27 /*    distribution.                                                          */
28 /*                                                                           */
29 /*****************************************************************************/
30
31
32
33 #ifndef _DIO_H
34 #define _DIO_H
35
36
37
38 /* Please note: All functions in this file will set _oserror *and* return its
39  * value. The only exception is dio_open, which will return NULL, but _oserror
40  * will be set. All function will also set _oserror in case of successful
41  * execution, effectively clearing it.
42  */
43
44
45
46 /*****************************************************************************/
47 /*                                   Data                                    */
48 /*****************************************************************************/
49
50
51
52 typedef unsigned char       driveid_t;
53 typedef unsigned int        sectnum_t;
54 typedef unsigned int        sectsize_t;
55 typedef struct __dhandle_t *dhandle_t;
56
57 typedef struct {
58   unsigned char  head;
59   unsigned       track;
60   unsigned       sector;
61 } dio_phys_pos;
62
63
64
65 /*****************************************************************************/
66 /*                                   Code                                    */
67 /*****************************************************************************/
68
69
70
71 sectsize_t __fastcall__ dio_query_sectsize(dhandle_t handle);
72 /* queries sector size, currently hardcoded */
73
74 sectnum_t __fastcall__ dio_query_sectcount(dhandle_t handle);
75 /* Return the sector count for a disk. */
76
77 dhandle_t __fastcall__ dio_open(driveid_t drive_id);
78 /* open drive for subsequent dio access */
79
80 unsigned char __fastcall__ dio_close(dhandle_t handle);
81 /* close drive, returns oserror (0 for success) */
82
83 unsigned char __fastcall__ dio_read(dhandle_t handle,
84                                     sectnum_t sect_num,
85                                     void *buffer);
86 /* read sector <sect_num> from drive <handle> to memory at <buffer> */
87 /* the number of bytes transferred depends on the sector size */
88 /* returns oserror (0 for success) */
89
90 unsigned char __fastcall__ dio_write(dhandle_t handle,
91                                      sectnum_t sect_num,
92                                      const void *buffer);
93 /* write memory at <buffer> to sector <sect_num> on drive <handle>, no verify */
94 /* the number of bytes transferred depends on the sector size */
95 /* returns oserror (0 for success) */
96
97 unsigned char __fastcall__ dio_write_verify(dhandle_t handle,
98                                             sectnum_t sect_num,
99                                             const void *buffer);
100 /* write memory at <buffer> to sector <sect_num> on drive <handle>, verify after write */
101 /* the number of bytes transferred depends on the sector size */
102 /* returns oserror (0 for success) */
103
104
105 unsigned char __fastcall__ dio_phys_to_log(dhandle_t handle,
106                                            const dio_phys_pos *physpos, /* input */
107                                            sectnum_t *sectnum);         /* output */
108 /* convert physical sector address (head/track/sector) to logical sector number */
109 /* returns oserror (0 for success) */
110
111 unsigned char __fastcall__ dio_log_to_phys(dhandle_t handle,
112                                            const sectnum_t *sectnum, /* input */
113                                            dio_phys_pos *physpos);   /* output */
114 /* convert logical sector number to physical sector address (head/track/sector) */
115 /* returns oserror (0 for success) */
116
117 #endif /* #ifndef _DIO_H */