Removed DIO specific typedefs which were just aliases to basic types and replaced the term 'drive' with 'device' in order to harmonize with the recently added device.h.

git-svn-id: svn://svn.cc65.org/cc65/trunk@5847 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
ol.sc
2012-10-11 18:22:49 +00:00
parent d99d5f3337
commit 61d4b6b03f
25 changed files with 94 additions and 119 deletions

View File

@@ -489,15 +489,15 @@ url="ca65.html" name="assembler manual">.
<tag/Drive ID/ <tag/Drive ID/
The function <htmlurl url="dio-1.html" name="dio_open()"> has the single The function <htmlurl url="dio-1.html" name="dio_open()"> has the single
parameter <tt/drive_id/ to identify the drive to be opened. Therefore an parameter <tt/device/ to identify the device to be opened. Therefore an
Apple&nbsp;II slot and drive pair is mapped to that <tt/drive_id/ according Apple&nbsp;II slot and drive pair is mapped to that <tt/device/ according
to the formula to the formula
<tscreen> <tscreen>
drive_id = slot * 16 + (drive - 1) * 128 device = slot * 0x10 + (drive - 1) * 0x80
</tscreen> </tscreen>
so that for example slot 6 drive 2 is mapped to <tt/drive_id/ 224. so that for example slot 6 drive 2 is mapped to <tt/device/ 0xE0.
<tag/Sector count/ <tag/Sector count/
The function <htmlurl url="dio-3.html" name="dio_query_sectcount()"> returns The function <htmlurl url="dio-3.html" name="dio_query_sectcount()"> returns

View File

@@ -495,15 +495,15 @@ url="ca65.html" name="assembler manual">.
<tag/Drive ID/ <tag/Drive ID/
The function <htmlurl url="dio-1.html" name="dio_open()"> has the single The function <htmlurl url="dio-1.html" name="dio_open()"> has the single
parameter <tt/drive_id/ to identify the drive to be opened. Therefore an parameter <tt/device/ to identify the device to be opened. Therefore an
Apple&nbsp;II slot and drive pair is mapped to that <tt/drive_id/ according Apple&nbsp;II slot and drive pair is mapped to that <tt/drive_id/ according
to the formula to the formula
<tscreen> <tscreen>
drive_id = slot * 16 + (drive - 1) * 128 device = slot * 0x10 + (drive - 1) * 0x80
</tscreen> </tscreen>
so that for example slot 6 drive 2 is mapped to <tt/drive_id/ 224. so that for example slot 6 drive 2 is mapped to <tt/device/ 0xE0.
<tag/Sector count/ <tag/Sector count/
The function <htmlurl url="dio-3.html" name="dio_query_sectcount()"> returns The function <htmlurl url="dio-3.html" name="dio_query_sectcount()"> returns

View File

@@ -17,16 +17,16 @@ Include the dio.h header file to get the necessary definitions.
<sect>Opening the disk for low level I/O<p> <sect>Opening the disk for low level I/O<p>
Prior to using these functions a handle to the drive has to be obtained. This Prior to using these functions a handle to the device has to be obtained. This
is done with the <tt>dio_open</tt> function. After use, the handle should be is done with the <tt>dio_open</tt> function. After use, the handle should be
released with the <tt>dio_close</tt> function. released with the <tt>dio_close</tt> function.
<tscreen><verb> <tscreen><verb>
dhandle_t __fastcall__ dio_open (driveid_t drive_id); dhandle_t __fastcall__ dio_open (unsigned char device);
</verb></tscreen> </verb></tscreen>
The <tt>drive_id</tt> specifies the drive to access, with 0 being the first The <tt>device</tt> specifies the device to access, with 0 being the first
disk drive, 1 the second, and so on. device, 1 the second, and so on.
<tscreen><verb> <tscreen><verb>
unsigned char __fastcall__ dio_close (dhandle_t handle); unsigned char __fastcall__ dio_close (dhandle_t handle);
@@ -41,7 +41,7 @@ The read and write functions are:
<tscreen><verb> <tscreen><verb>
unsigned char __fastcall__ dio_read (dhandle_t handle, unsigned char __fastcall__ dio_read (dhandle_t handle,
sectnum_t sect_num, unsigned sect_num,
void *buffer); void *buffer);
</verb></tscreen> </verb></tscreen>
@@ -50,7 +50,7 @@ location at buffer.
<tscreen><verb> <tscreen><verb>
unsigned char __fastcall__ dio_write (dhandle_t handle, unsigned char __fastcall__ dio_write (dhandle_t handle,
sectnum_t sect_num, unsigned sect_num,
const void *buffer); const void *buffer);
</verb></tscreen> </verb></tscreen>
@@ -59,7 +59,7 @@ by <tt>sect_num</tt>. No verify is performed.
<tscreen><verb> <tscreen><verb>
unsigned char __fastcall__ dio_write_verify (dhandle_t handle, unsigned char __fastcall__ dio_write_verify (dhandle_t handle,
sectnum_t sect_num, unsigned sect_num,
const void *buffer); const void *buffer);
</verb></tscreen> </verb></tscreen>
@@ -85,7 +85,7 @@ and/or different sector counts.
The following function returns the sector size of the currently inserted disk: The following function returns the sector size of the currently inserted disk:
<tscreen><verb> <tscreen><verb>
sectsize_t __fastcall__ dio_query_sectsize (dhandle_t handle); unsigned __fastcall__ dio_query_sectsize (dhandle_t handle);
</verb></tscreen> </verb></tscreen>
On the Atari platform, the sector size is handled specially. Please refer On the Atari platform, the sector size is handled specially. Please refer
@@ -96,13 +96,13 @@ specific platform documentation.
The following function returns the sector count of the currently inserted disk: The following function returns the sector count of the currently inserted disk:
<tscreen><verb> <tscreen><verb>
sectnum_t __fastcall__ dio_query_sectcount (dhandle_t handle); unsigned __fastcall__ dio_query_sectcount (dhandle_t handle);
</verb></tscreen> </verb></tscreen>
<sect>Converting sector numbers<p> <sect>Converting sector numbers<p>
Since the read and write functions expect a sector number, for systems where Since the read and write functions expect a sector number, for systems where
the sectors aren't addressed by a logical sector number (e.g. CBM drives), the sectors aren't addressed by a logical sector number (e.g. CBM devices),
there are 2 conversion functions. One of them converts a logical sector number there are 2 conversion functions. One of them converts a logical sector number
to a head/track/sector triple. The other conversion function works the other to a head/track/sector triple. The other conversion function works the other
way round. way round.
@@ -110,14 +110,14 @@ way round.
<tscreen><verb> <tscreen><verb>
unsigned char __fastcall__ dio_phys_to_log (dhandle_t handle, unsigned char __fastcall__ dio_phys_to_log (dhandle_t handle,
const dio_phys_pos *physpos, const dio_phys_pos *physpos,
sectnum_t *sectnum); unsigned *sectnum);
</verb></tscreen> </verb></tscreen>
This function converts track/head/sector to logical sector number. This function converts track/head/sector to logical sector number.
<tscreen><verb> <tscreen><verb>
unsigned char __fastcall__ dio_log_to_phys (dhandle_t handle, unsigned char __fastcall__ dio_log_to_phys (dhandle_t handle,
const _sectnum_t *sectnum, const unsigned *sectnum,
dio_phys_pos *physpos); dio_phys_pos *physpos);
</verb></tscreen> </verb></tscreen>
@@ -132,6 +132,3 @@ The logical sector number is returned as physical sector and vice versa.
</article> </article>

View File

@@ -49,9 +49,6 @@
typedef unsigned char driveid_t;
typedef unsigned int sectnum_t;
typedef unsigned int sectsize_t;
typedef struct __dhandle_t *dhandle_t; typedef struct __dhandle_t *dhandle_t;
typedef struct { typedef struct {
@@ -68,48 +65,47 @@ typedef struct {
sectsize_t __fastcall__ dio_query_sectsize(dhandle_t handle); unsigned __fastcall__ dio_query_sectsize (dhandle_t handle);
/* returns sector size */ /* returns sector size */
sectnum_t __fastcall__ dio_query_sectcount(dhandle_t handle); unsigned __fastcall__ dio_query_sectcount (dhandle_t handle);
/* returns sector count */ /* returns sector count */
dhandle_t __fastcall__ dio_open(driveid_t drive_id); dhandle_t __fastcall__ dio_open (unsigned char device);
/* open drive for subsequent dio access */ /* open device for subsequent dio access */
unsigned char __fastcall__ dio_close(dhandle_t handle); unsigned char __fastcall__ dio_close (dhandle_t handle);
/* close drive, returns oserror (0 for success) */ /* close device, returns oserror (0 for success) */
unsigned char __fastcall__ dio_read(dhandle_t handle, unsigned char __fastcall__ dio_read (dhandle_t handle,
sectnum_t sect_num, unsigned sect_num,
void *buffer); void *buffer);
/* read sector <sect_num> from drive <handle> to memory at <buffer> */ /* read sector <sect_num> from device <handle> to memory at <buffer> */
/* the number of bytes transferred depends on the sector size */ /* the number of bytes transferred depends on the sector size */
/* returns oserror (0 for success) */ /* returns oserror (0 for success) */
unsigned char __fastcall__ dio_write(dhandle_t handle, unsigned char __fastcall__ dio_write (dhandle_t handle,
sectnum_t sect_num, unsigned sect_num,
const void *buffer); const void *buffer);
/* write memory at <buffer> to sector <sect_num> on drive <handle>, no verify */ /* write memory at <buffer> to sector <sect_num> on device <handle>, no verify */
/* the number of bytes transferred depends on the sector size */ /* the number of bytes transferred depends on the sector size */
/* returns oserror (0 for success) */ /* returns oserror (0 for success) */
unsigned char __fastcall__ dio_write_verify(dhandle_t handle, unsigned char __fastcall__ dio_write_verify (dhandle_t handle,
sectnum_t sect_num, unsigned sect_num,
const void *buffer); const void *buffer);
/* write memory at <buffer> to sector <sect_num> on drive <handle>, verify after write */ /* write memory at <buffer> to sector <sect_num> on device <handle>, verify after write */
/* the number of bytes transferred depends on the sector size */ /* the number of bytes transferred depends on the sector size */
/* returns oserror (0 for success) */ /* returns oserror (0 for success) */
unsigned char __fastcall__ dio_phys_to_log (dhandle_t handle,
unsigned char __fastcall__ dio_phys_to_log(dhandle_t handle,
const dio_phys_pos *physpos, /* input */ const dio_phys_pos *physpos, /* input */
sectnum_t *sectnum); /* output */ unsigned *sectnum); /* output */
/* convert physical sector address (head/track/sector) to logical sector number */ /* convert physical sector address (head/track/sector) to logical sector number */
/* returns oserror (0 for success) */ /* returns oserror (0 for success) */
unsigned char __fastcall__ dio_log_to_phys(dhandle_t handle, unsigned char __fastcall__ dio_log_to_phys (dhandle_t handle,
const sectnum_t *sectnum, /* input */ const unsigned *sectnum, /* input */
dio_phys_pos *physpos); /* output */ dio_phys_pos *physpos); /* output */
/* convert logical sector number to physical sector address (head/track/sector) */ /* convert logical sector number to physical sector address (head/track/sector) */
/* returns oserror (0 for success) */ /* returns oserror (0 for success) */

View File

@@ -1,7 +1,7 @@
; ;
; Oliver Schmidt, 24.03.2005 ; Oliver Schmidt, 24.03.2005
; ;
; dhandle_t __fastcall__ dio_open (driveid_t drive_id); ; dhandle_t __fastcall__ dio_open (unsigned char device);
; ;
.export _dio_open .export _dio_open

View File

@@ -1,7 +1,7 @@
; ;
; Oliver Schmidt, 24.03.2005 ; Oliver Schmidt, 24.03.2005
; ;
; unsigned char __fastcall__ dio_read (dhandle_t handle, sectnum_t sect_num, void *buffer); ; unsigned char __fastcall__ dio_read (dhandle_t handle, unsigned sect_num, void *buffer);
; ;
.export _dio_read .export _dio_read

View File

@@ -1,7 +1,7 @@
; ;
; Oliver Schmidt, 31.03.2005 ; Oliver Schmidt, 31.03.2005
; ;
; sectnum_t __fastcall__ dio_query_sectcount (dhandle_t handle); ; unsigned __fastcall__ dio_query_sectcount (dhandle_t handle);
; ;
.export _dio_query_sectcount .export _dio_query_sectcount

View File

@@ -1,7 +1,7 @@
; ;
; Oliver Schmidt, 31.03.2005 ; Oliver Schmidt, 31.03.2005
; ;
; sectsize_t __fastcall__ dio_query_sectsize (dhandle_t handle); ; unsigned __fastcall__ dio_query_sectsize (dhandle_t handle);
; ;
.export _dio_query_sectsize .export _dio_query_sectsize

View File

@@ -1,7 +1,7 @@
; ;
; Oliver Schmidt, 24.03.2005 ; Oliver Schmidt, 24.03.2005
; ;
; unsigned char __fastcall__ dio_write (dhandle_t handle, sectnum_t sect_num, const void *buffer); ; unsigned char __fastcall__ dio_write (dhandle_t handle, unsigned sect_num, const void *buffer);
; ;
.export _dio_write .export _dio_write

View File

@@ -10,10 +10,9 @@
; ;
; unsigned char __fastcall__ dio_phys_to_log(dhandle_t handle, ; unsigned char __fastcall__ dio_phys_to_log(dhandle_t handle,
; dio_phys_pos *physpos, /* input */ ; dio_phys_pos *physpos, /* input */
; sectnum_t *sectnum); /* output */ ; unsigned *sectnum); /* output */
; ;
; dhandle_t - 16bit (ptr) ; dhandle_t - 16bit (ptr)
; sectnum_t - 16bit
; ;
.export _dio_phys_to_log .export _dio_phys_to_log

View File

@@ -8,11 +8,10 @@
; cylinder and head 0 and as sector the sectnum it got ; cylinder and head 0 and as sector the sectnum it got
; ;
; unsigned char __fastcall__ dio_log_to_phys(dhandle_t handle, ; unsigned char __fastcall__ dio_log_to_phys(dhandle_t handle,
; sectnum_t *sectnum, /* input */ ; unsigned *sectnum, /* input */
; dio_phys_pos *physpos); /* output */ ; dio_phys_pos *physpos); /* output */
; ;
; dhandle_t - 16bit (ptr) ; dhandle_t - 16bit (ptr)
; sectnum_t - 16bit
; ;
.export _dio_log_to_phys .export _dio_log_to_phys

View File

@@ -8,7 +8,7 @@
; _dio_write functions. To query the sector size, the _dio_open ; _dio_write functions. To query the sector size, the _dio_open
; accesses the disk drive. ; accesses the disk drive.
; ;
; dhandle_t __fastcall__ dio_open (driveid_t drive_id); ; dhandle_t __fastcall__ dio_open (unsigned char device);
; unsigned char __fastcall__ dio_close (dhandle_t handle); ; unsigned char __fastcall__ dio_close (dhandle_t handle);
; ;

View File

@@ -1,7 +1,7 @@
; ;
; Christian Groessler, February 2005 ; Christian Groessler, February 2005
; ;
; sectsize_t __fastcall__ dio_query_sectsize(dhandle_t handle); ; unsigned __fastcall__ dio_query_sectsize(dhandle_t handle);
; ;
.include "atari.inc" .include "atari.inc"

View File

@@ -3,9 +3,8 @@
; ;
; this file provides the _dio_read function ; this file provides the _dio_read function
; ;
; unsigned char __fastcall__ dio_read(dhandle_t handle,sectnum_t sect_num,void *buffer); ; unsigned char __fastcall__ dio_read(dhandle_t handle,unsigned sect_num,void *buffer);
; dhandle_t - 16bit (ptr) ; dhandle_t - 16bit (ptr)
; sectnum_t - 16bit
; ;
.import __sio_call,pushax .import __sio_call,pushax

View File

@@ -3,9 +3,8 @@
; ;
; this file provides the _dio_write function ; this file provides the _dio_write function
; ;
; unsigned char __fastcall__ dio_write(dhandle_t handle,sectnum_t sect_num,const void *buffer); ; unsigned char __fastcall__ dio_write(dhandle_t handle,unsigned sect_num,const void *buffer);
; dhandle_t - 16bit (ptr) ; dhandle_t - 16bit (ptr)
; sectnum_t - 16bit
; ;
.import __sio_call,pushax .import __sio_call,pushax

View File

@@ -3,9 +3,8 @@
; ;
; this file provides the _dio_write_verify function ; this file provides the _dio_write_verify function
; ;
; unsigned char __fastcall__ dio_write_verify(dhandle_t handle,sectnum_t sect_num,const void *buffer); ; unsigned char __fastcall__ dio_write_verify(dhandle_t handle,unsigned sect_num,const void *buffer);
; dhandle_t - 16bit (ptr) ; dhandle_t - 16bit (ptr)
; sectnum_t - 16bit
; ;
.import __sio_call,pushax .import __sio_call,pushax

View File

@@ -7,11 +7,10 @@
; to save space with _dio_read and _dio_write functions. ; to save space with _dio_read and _dio_write functions.
; ;
; unsigned char __fastcall__ _sio_call(dhandle_t handle, ; unsigned char __fastcall__ _sio_call(dhandle_t handle,
; sectnum_t sect_num, ; unsigned sect_num,
; void *buffer, ; void *buffer,
; unsigned int sio_val); ; unsigned sio_val);
; dhandle_t - 16bit (ptr) ; dhandle_t - 16bit (ptr)
; sectnum_t - 16bit
; sio_val is (sio_command | sio_direction << 8) ; sio_val is (sio_command | sio_direction << 8)
; ;

View File

@@ -3,12 +3,9 @@
; 2.7.2001 ; 2.7.2001
; ;
; ;
; unsigned char __fastcall__ dio_phys_to_log(dhandle_t handle, ; unsigned char __fastcall__ dio_phys_to_log (dhandle_t handle,
; dio_phys_pos *physpos, /* input */ ; dio_phys_pos *physpos, /* input */
; sectnum_t *sectnum); /* output */ ; unsigned *sectnum); /* output */
;
; dhandle_t - 16bit (ptr)
; sectnum_t - 16bit
; ;
.export _dio_phys_to_log .export _dio_phys_to_log

View File

@@ -4,7 +4,7 @@
; based on Atari version by Christian Groessler ; based on Atari version by Christian Groessler
; 2.7.2001 ; 2.7.2001
; ;
; dhandle_t __fastcall__ dio_open (driveid_t drive_id); ; dhandle_t __fastcall__ dio_open (unsigned char device);
; unsigned char __fastcall__ dio_close (dhandle_t handle); ; unsigned char __fastcall__ dio_close (dhandle_t handle);
; ;
; dio_open sets given device as current and initializes disk ; dio_open sets given device as current and initializes disk

View File

@@ -4,9 +4,7 @@
; ;
; this file provides the _dio_read function ; this file provides the _dio_read function
; ;
; unsigned char __fastcall__ dio_read(dhandle_t handle,sectnum_t sect_num,void *buffer); ; unsigned char __fastcall__ dio_read (dhandle_t handle, unsigned sect_num, void *buffer);
; dhandle_t - 16bit (ptr)
; sectnum_t - 16bit
; ;
.import dio_params, __oserror .import dio_params, __oserror

View File

@@ -2,12 +2,9 @@
; Maciej 'YTM/Elysium' Witkowiak ; Maciej 'YTM/Elysium' Witkowiak
; 2.7.2001 ; 2.7.2001
; ;
; unsigned char __fastcall__ dio_log_to_phys(dhandle_t handle, ; unsigned char __fastcall__ dio_log_to_phys (dhandle_t handle,
; sectnum_t *sectnum, /* input */ ; unsigned *sectnum, /* input */
; dio_phys_pos *physpos); /* output */ ; dio_phys_pos *physpos); /* output */
;
; dhandle_t - 16bit (ptr)
; sectnum_t - 16bit
; ;
.export _dio_log_to_phys .export _dio_log_to_phys

View File

@@ -4,9 +4,7 @@
; ;
; this file provides the _dio_write function ; this file provides the _dio_write function
; ;
; unsigned char __fastcall__ dio_write(dhandle_t handle,sectnum_t sect_num,const void *buffer); ; unsigned char __fastcall__ dio_write (dhandle_t handle, unsigned sect_num, const void *buffer);
; dhandle_t - 16bit (ptr)
; sectnum_t - 16bit
; ;
.import dio_params, setoserror .import dio_params, setoserror

View File

@@ -4,9 +4,7 @@
; ;
; this file provides the _dio_write function ; this file provides the _dio_write function
; ;
; unsigned char __fastcall__ dio_write_verify(dhandle_t handle,sectnum_t sect_num,const void *buffer); ; unsigned char __fastcall__ dio_write_verify (dhandle_t handle, unsigned sect_num, const void *buffer);
; dhandle_t - 16bit (ptr)
; sectnum_t - 16bit
; ;
.import dio_params, __oserror .import dio_params, __oserror

View File

@@ -54,10 +54,10 @@ static void ClearLine (void)
} }
static driveid_t AskForDrive (const char* Name) static unsigned char AskForDrive (const char* Name)
/* Ask for a drive id and return it */ /* Ask for a drive id and return it */
{ {
driveid_t Drive = 0; unsigned char Drive = 0;
char Char; char Char;
cprintf ("\r\n%s Drive ID ?", Name); cprintf ("\r\n%s Drive ID ?", Name);
@@ -74,7 +74,7 @@ static driveid_t AskForDrive (const char* Name)
} }
static void AskForDisk (const char* Name, driveid_t Drive) static void AskForDisk (const char* Name, unsigned char Drive)
/* Ask the user to insert a specific disk */ /* Ask the user to insert a specific disk */
{ {
ClearLine (); ClearLine ();
@@ -84,7 +84,7 @@ static void AskForDisk (const char* Name, driveid_t Drive)
} }
static char* AllocBuffer (sectsize_t SectSize, sectnum_t SectCount, sectnum_t* ChunkCount) static char* AllocBuffer (unsigned int SectSize, unsigned int SectCount, unsigned int* ChunkCount)
/* Allocate a copy buffer on the heap and return a pointer to it */ /* Allocate a copy buffer on the heap and return a pointer to it */
{ {
char* Buffer = NULL; char* Buffer = NULL;
@@ -94,7 +94,7 @@ static char* AllocBuffer (sectsize_t SectSize, sectnum_t SectCount, sectnum_t* C
/* Increase number of chunks resp. decrease size */ /* Increase number of chunks resp. decrease size */
/* of one chunk until buffer allocation succeeds */ /* of one chunk until buffer allocation succeeds */
do { do {
*ChunkCount = (sectnum_t) ((SectCount + Chunks - 1) / Chunks); *ChunkCount = (unsigned int) ((SectCount + Chunks - 1) / Chunks);
BufferSize = *ChunkCount * (unsigned long) SectSize; BufferSize = *ChunkCount * (unsigned long) SectSize;
if (BufferSize < UINT_MAX) { if (BufferSize < UINT_MAX) {
Buffer = malloc ((size_t) BufferSize); Buffer = malloc ((size_t) BufferSize);
@@ -107,16 +107,16 @@ static char* AllocBuffer (sectsize_t SectSize, sectnum_t SectCount, sectnum_t* C
int main (int argc, const char* argv[]) int main (int argc, const char* argv[])
{ {
driveid_t SourceId; unsigned char SourceId;
driveid_t TargetId; unsigned char TargetId;
dhandle_t Source = NULL; dhandle_t Source = NULL;
dhandle_t Target = NULL; dhandle_t Target = NULL;
sectsize_t SectSize; unsigned int SectSize;
sectnum_t SectCount; unsigned int SectCount;
char* Buffer; char* Buffer;
sectnum_t Sector; unsigned int Sector;
sectnum_t ChunkCount; unsigned int ChunkCount;
sectnum_t ChunkOffset = 0; unsigned int ChunkOffset = 0;
clrscr (); clrscr ();
screensize (&ScreenX, &ScreenY); screensize (&ScreenX, &ScreenY);

View File

@@ -110,7 +110,7 @@ static unsigned get_dir_entry(char* p_name)
cur_addr = *(unsigned*)(&dirent->d_mtime.hour + 1); cur_addr = *(unsigned*)(&dirent->d_mtime.hour + 1);
/* DEV_NUM is set to the drive accessed above */ /* DEV_NUM is set to the drive accessed above */
dhandle = dio_open(*(driveid_t*)0xBF30); dhandle = dio_open(*(unsigned char*)0xBF30);
if (!dhandle) { if (!dhandle) {
err_exit("dio_open", 1); err_exit("dio_open", 1);
} }