2000-10-09 22:31:57 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* */
|
2000-10-20 15:55:46 +00:00
|
|
|
/* dio.h */
|
2000-10-09 22:31:57 +00:00
|
|
|
/* */
|
2000-10-20 15:55:46 +00:00
|
|
|
/* Low-Level diskette I/O functions */
|
2000-10-09 22:31:57 +00:00
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* */
|
2011-02-26 22:15:24 +00:00
|
|
|
/* (C) 2005 Christian Groessler <chris@groessler.org> */
|
2000-10-09 22:31:57 +00:00
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* This software is provided 'as-is', without any expressed or implied */
|
|
|
|
/* warranty. In no event will the authors be held liable for any damages */
|
|
|
|
/* arising from the use of this software. */
|
|
|
|
/* */
|
|
|
|
/* Permission is granted to anyone to use this software for any purpose, */
|
|
|
|
/* including commercial applications, and to alter it and redistribute it */
|
|
|
|
/* freely, subject to the following restrictions: */
|
|
|
|
/* */
|
|
|
|
/* 1. The origin of this software must not be misrepresented; you must not */
|
|
|
|
/* claim that you wrote the original software. If you use this software */
|
|
|
|
/* in a product, an acknowledgment in the product documentation would be */
|
|
|
|
/* appreciated but is not required. */
|
|
|
|
/* 2. Altered source versions must be plainly marked as such, and must not */
|
|
|
|
/* be misrepresented as being the original software. */
|
|
|
|
/* 3. This notice may not be removed or altered from any source */
|
|
|
|
/* distribution. */
|
|
|
|
/* */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
2005-03-30 18:25:38 +00:00
|
|
|
|
|
|
|
|
2000-10-09 22:31:57 +00:00
|
|
|
#ifndef _DIO_H
|
|
|
|
#define _DIO_H
|
|
|
|
|
2005-03-30 18:25:38 +00:00
|
|
|
|
|
|
|
|
2005-03-31 07:20:05 +00:00
|
|
|
/* Please note: All functions in this file will set _oserror *and* return its
|
2014-06-30 09:10:35 +00:00
|
|
|
** value. The only exception is dio_open, which will return NULL, but _oserror
|
|
|
|
** will be set. All function will also set _oserror in case of successful
|
|
|
|
** execution, effectively clearing it.
|
|
|
|
*/
|
2005-03-31 07:20:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2005-03-30 18:25:38 +00:00
|
|
|
/*****************************************************************************/
|
2012-10-11 18:22:49 +00:00
|
|
|
/* Data */
|
2005-03-30 18:25:38 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-11-16 21:38:00 +00:00
|
|
|
typedef struct __dhandle_t *dhandle_t;
|
2000-10-20 15:55:46 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned char head;
|
|
|
|
unsigned track;
|
|
|
|
unsigned sector;
|
2000-11-16 21:38:00 +00:00
|
|
|
} dio_phys_pos;
|
2000-10-09 22:31:57 +00:00
|
|
|
|
|
|
|
|
2005-03-30 18:25:38 +00:00
|
|
|
|
|
|
|
/*****************************************************************************/
|
2012-10-11 18:22:49 +00:00
|
|
|
/* Code */
|
2005-03-30 18:25:38 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-10-11 18:22:49 +00:00
|
|
|
unsigned __fastcall__ dio_query_sectsize (dhandle_t handle);
|
2010-06-04 21:32:55 +00:00
|
|
|
/* returns sector size */
|
2000-10-09 22:31:57 +00:00
|
|
|
|
2012-10-11 18:22:49 +00:00
|
|
|
unsigned __fastcall__ dio_query_sectcount (dhandle_t handle);
|
2010-06-04 21:32:55 +00:00
|
|
|
/* returns sector count */
|
2005-03-30 18:25:38 +00:00
|
|
|
|
2012-10-11 18:22:49 +00:00
|
|
|
dhandle_t __fastcall__ dio_open (unsigned char device);
|
|
|
|
/* open device for subsequent dio access */
|
2000-10-09 22:31:57 +00:00
|
|
|
|
2012-10-11 18:22:49 +00:00
|
|
|
unsigned char __fastcall__ dio_close (dhandle_t handle);
|
|
|
|
/* close device, returns oserror (0 for success) */
|
2000-11-16 21:38:00 +00:00
|
|
|
|
2012-10-11 18:22:49 +00:00
|
|
|
unsigned char __fastcall__ dio_read (dhandle_t handle,
|
|
|
|
unsigned sect_num,
|
|
|
|
void *buffer);
|
|
|
|
/* read sector <sect_num> from device <handle> to memory at <buffer> */
|
2000-11-16 21:38:00 +00:00
|
|
|
/* the number of bytes transferred depends on the sector size */
|
2000-11-16 21:42:38 +00:00
|
|
|
/* returns oserror (0 for success) */
|
2000-11-16 21:38:00 +00:00
|
|
|
|
2012-10-11 18:22:49 +00:00
|
|
|
unsigned char __fastcall__ dio_write (dhandle_t handle,
|
|
|
|
unsigned sect_num,
|
|
|
|
const void *buffer);
|
|
|
|
/* write memory at <buffer> to sector <sect_num> on device <handle>, no verify */
|
2000-11-16 21:38:00 +00:00
|
|
|
/* the number of bytes transferred depends on the sector size */
|
2000-11-16 21:42:38 +00:00
|
|
|
/* returns oserror (0 for success) */
|
2000-11-16 21:38:00 +00:00
|
|
|
|
2012-10-11 18:22:49 +00:00
|
|
|
unsigned char __fastcall__ dio_write_verify (dhandle_t handle,
|
|
|
|
unsigned sect_num,
|
|
|
|
const void *buffer);
|
|
|
|
/* write memory at <buffer> to sector <sect_num> on device <handle>, verify after write */
|
2000-11-16 21:38:00 +00:00
|
|
|
/* the number of bytes transferred depends on the sector size */
|
2000-11-16 21:42:38 +00:00
|
|
|
/* returns oserror (0 for success) */
|
2000-11-16 21:38:00 +00:00
|
|
|
|
2012-10-11 18:22:49 +00:00
|
|
|
unsigned char __fastcall__ dio_phys_to_log (dhandle_t handle,
|
|
|
|
const dio_phys_pos *physpos, /* input */
|
|
|
|
unsigned *sectnum); /* output */
|
2000-11-16 21:38:00 +00:00
|
|
|
/* convert physical sector address (head/track/sector) to logical sector number */
|
2000-11-16 21:42:38 +00:00
|
|
|
/* returns oserror (0 for success) */
|
2000-11-16 21:38:00 +00:00
|
|
|
|
2012-10-11 18:22:49 +00:00
|
|
|
unsigned char __fastcall__ dio_log_to_phys (dhandle_t handle,
|
|
|
|
const unsigned *sectnum, /* input */
|
|
|
|
dio_phys_pos *physpos); /* output */
|
2000-11-16 21:38:00 +00:00
|
|
|
/* convert logical sector number to physical sector address (head/track/sector) */
|
2000-11-16 21:42:38 +00:00
|
|
|
/* returns oserror (0 for success) */
|
2000-10-09 22:31:57 +00:00
|
|
|
|
|
|
|
#endif /* #ifndef _DIO_H */
|