1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-11 05:29:33 +00:00

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/
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
Apple&nbsp;II slot and drive pair is mapped to that <tt/drive_id/ according
parameter <tt/device/ to identify the device to be opened. Therefore an
Apple&nbsp;II slot and drive pair is mapped to that <tt/device/ according
to the formula
<tscreen>
drive_id = slot * 16 + (drive - 1) * 128
device = slot * 0x10 + (drive - 1) * 0x80
</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/
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/
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
to the formula
<tscreen>
drive_id = slot * 16 + (drive - 1) * 128
device = slot * 0x10 + (drive - 1) * 0x80
</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/
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>
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
released with the <tt>dio_close</tt> function.
<tscreen><verb>
dhandle_t __fastcall__ dio_open (driveid_t drive_id);
dhandle_t __fastcall__ dio_open (unsigned char device);
</verb></tscreen>
The <tt>drive_id</tt> specifies the drive to access, with 0 being the first
disk drive, 1 the second, and so on.
The <tt>device</tt> specifies the device to access, with 0 being the first
device, 1 the second, and so on.
<tscreen><verb>
unsigned char __fastcall__ dio_close (dhandle_t handle);
@ -41,7 +41,7 @@ The read and write functions are:
<tscreen><verb>
unsigned char __fastcall__ dio_read (dhandle_t handle,
sectnum_t sect_num,
unsigned sect_num,
void *buffer);
</verb></tscreen>
@ -50,7 +50,7 @@ location at buffer.
<tscreen><verb>
unsigned char __fastcall__ dio_write (dhandle_t handle,
sectnum_t sect_num,
unsigned sect_num,
const void *buffer);
</verb></tscreen>
@ -59,8 +59,8 @@ by <tt>sect_num</tt>. No verify is performed.
<tscreen><verb>
unsigned char __fastcall__ dio_write_verify (dhandle_t handle,
sectnum_t sect_num,
const void *buffer);
unsigned sect_num,
const void *buffer);
</verb></tscreen>
This function will write the memory contents at buffer to the sector specified
@ -85,7 +85,7 @@ and/or different sector counts.
The following function returns the sector size of the currently inserted disk:
<tscreen><verb>
sectsize_t __fastcall__ dio_query_sectsize (dhandle_t handle);
unsigned __fastcall__ dio_query_sectsize (dhandle_t handle);
</verb></tscreen>
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:
<tscreen><verb>
sectnum_t __fastcall__ dio_query_sectcount (dhandle_t handle);
unsigned __fastcall__ dio_query_sectcount (dhandle_t handle);
</verb></tscreen>
<sect>Converting sector numbers<p>
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
to a head/track/sector triple. The other conversion function works the other
way round.
@ -110,14 +110,14 @@ way round.
<tscreen><verb>
unsigned char __fastcall__ dio_phys_to_log (dhandle_t handle,
const dio_phys_pos *physpos,
sectnum_t *sectnum);
unsigned *sectnum);
</verb></tscreen>
This function converts track/head/sector to logical sector number.
<tscreen><verb>
unsigned char __fastcall__ dio_log_to_phys (dhandle_t handle,
const _sectnum_t *sectnum,
const unsigned *sectnum,
dio_phys_pos *physpos);
</verb></tscreen>
@ -132,6 +132,3 @@ The logical sector number is returned as physical sector and vice versa.
</article>

View File

@ -44,14 +44,11 @@
/*****************************************************************************/
/* Data */
/* Data */
/*****************************************************************************/
typedef unsigned char driveid_t;
typedef unsigned int sectnum_t;
typedef unsigned int sectsize_t;
typedef struct __dhandle_t *dhandle_t;
typedef struct {
@ -63,54 +60,53 @@ typedef struct {
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/
sectsize_t __fastcall__ dio_query_sectsize(dhandle_t handle);
unsigned __fastcall__ dio_query_sectsize (dhandle_t handle);
/* returns sector size */
sectnum_t __fastcall__ dio_query_sectcount(dhandle_t handle);
unsigned __fastcall__ dio_query_sectcount (dhandle_t handle);
/* returns sector count */
dhandle_t __fastcall__ dio_open(driveid_t drive_id);
/* open drive for subsequent dio access */
dhandle_t __fastcall__ dio_open (unsigned char device);
/* open device for subsequent dio access */
unsigned char __fastcall__ dio_close(dhandle_t handle);
/* close drive, returns oserror (0 for success) */
unsigned char __fastcall__ dio_close (dhandle_t handle);
/* close device, returns oserror (0 for success) */
unsigned char __fastcall__ dio_read(dhandle_t handle,
sectnum_t sect_num,
void *buffer);
/* read sector <sect_num> from drive <handle> to memory at <buffer> */
unsigned char __fastcall__ dio_read (dhandle_t handle,
unsigned sect_num,
void *buffer);
/* read sector <sect_num> from device <handle> to memory at <buffer> */
/* the number of bytes transferred depends on the sector size */
/* returns oserror (0 for success) */
unsigned char __fastcall__ dio_write(dhandle_t handle,
sectnum_t sect_num,
const void *buffer);
/* write memory at <buffer> to sector <sect_num> on drive <handle>, no verify */
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 */
/* the number of bytes transferred depends on the sector size */
/* returns oserror (0 for success) */
unsigned char __fastcall__ dio_write_verify(dhandle_t handle,
sectnum_t sect_num,
const void *buffer);
/* write memory at <buffer> to sector <sect_num> on drive <handle>, verify after write */
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 */
/* the number of bytes transferred depends on the sector size */
/* returns oserror (0 for success) */
unsigned char __fastcall__ dio_phys_to_log(dhandle_t handle,
const dio_phys_pos *physpos, /* input */
sectnum_t *sectnum); /* output */
unsigned char __fastcall__ dio_phys_to_log (dhandle_t handle,
const dio_phys_pos *physpos, /* input */
unsigned *sectnum); /* output */
/* convert physical sector address (head/track/sector) to logical sector number */
/* returns oserror (0 for success) */
unsigned char __fastcall__ dio_log_to_phys(dhandle_t handle,
const sectnum_t *sectnum, /* input */
dio_phys_pos *physpos); /* output */
unsigned char __fastcall__ dio_log_to_phys (dhandle_t handle,
const unsigned *sectnum, /* input */
dio_phys_pos *physpos); /* output */
/* convert logical sector number to physical sector address (head/track/sector) */
/* returns oserror (0 for success) */

View File

@ -1,7 +1,7 @@
;
; 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

View File

@ -1,7 +1,7 @@
;
; 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

View File

@ -1,7 +1,7 @@
;
; 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

View File

@ -1,7 +1,7 @@
;
; 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

View File

@ -1,7 +1,7 @@
;
; 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

View File

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

View File

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

View File

@ -8,7 +8,7 @@
; _dio_write functions. To query the sector size, the _dio_open
; 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);
;

View File

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

View File

@ -3,13 +3,12 @@
;
; 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 __sio_call,pushax
.export _dio_read
.export _dio_read
.include "atari.inc"
.proc _dio_read

View File

@ -3,9 +3,8 @@
;
; 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 __sio_call,pushax

View File

@ -3,9 +3,8 @@
;
; 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)
; sectnum_t - 16bit
;
.import __sio_call,pushax

View File

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

View File

@ -3,12 +3,9 @@
; 2.7.2001
;
;
; unsigned char __fastcall__ dio_phys_to_log(dhandle_t handle,
; dio_phys_pos *physpos, /* input */
; sectnum_t *sectnum); /* output */
;
; dhandle_t - 16bit (ptr)
; sectnum_t - 16bit
; unsigned char __fastcall__ dio_phys_to_log (dhandle_t handle,
; dio_phys_pos *physpos, /* input */
; unsigned *sectnum); /* output */
;
.export _dio_phys_to_log
@ -17,7 +14,7 @@
.importzp ptr1,ptr2,ptr3,tmp1,tmp2,tmp3,tmp4
.include "dio.inc"
.include "geossym.inc"
.include "geossym.inc"
.include "const.inc"
_dio_phys_to_log:

View File

@ -4,7 +4,7 @@
; based on Atari version by Christian Groessler
; 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);
;
; dio_open sets given device as current and initializes disk

View File

@ -4,13 +4,11 @@
;
; this file provides the _dio_read function
;
; unsigned char __fastcall__ dio_read(dhandle_t handle,sectnum_t sect_num,void *buffer);
; dhandle_t - 16bit (ptr)
; sectnum_t - 16bit
; unsigned char __fastcall__ dio_read (dhandle_t handle, unsigned sect_num, void *buffer);
;
.import dio_params, __oserror
.export _dio_read
.export _dio_read
.include "geossym.inc"
.include "jumptab.inc"

View File

@ -2,12 +2,9 @@
; Maciej 'YTM/Elysium' Witkowiak
; 2.7.2001
;
; unsigned char __fastcall__ dio_log_to_phys(dhandle_t handle,
; sectnum_t *sectnum, /* input */
; dio_phys_pos *physpos); /* output */
;
; dhandle_t - 16bit (ptr)
; sectnum_t - 16bit
; unsigned char __fastcall__ dio_log_to_phys (dhandle_t handle,
; unsigned *sectnum, /* input */
; dio_phys_pos *physpos); /* output */
;
.export _dio_log_to_phys
@ -16,7 +13,7 @@
.import sectab_1541_l, sectab_1541_h
.include "dio.inc"
.include "geossym.inc"
.include "geossym.inc"
.include "const.inc"
_dio_log_to_phys:

View File

@ -4,13 +4,11 @@
;
; this file provides the _dio_write function
;
; unsigned char __fastcall__ dio_write(dhandle_t handle,sectnum_t sect_num,const void *buffer);
; dhandle_t - 16bit (ptr)
; sectnum_t - 16bit
; unsigned char __fastcall__ dio_write (dhandle_t handle, unsigned sect_num, const void *buffer);
;
.import dio_params, setoserror
.export _dio_write
.export _dio_write
.include "geossym.inc"
.include "jumptab.inc"

View File

@ -4,13 +4,11 @@
;
; this file provides the _dio_write function
;
; unsigned char __fastcall__ dio_write_verify(dhandle_t handle,sectnum_t sect_num,const void *buffer);
; dhandle_t - 16bit (ptr)
; sectnum_t - 16bit
; unsigned char __fastcall__ dio_write_verify (dhandle_t handle, unsigned sect_num, const void *buffer);
;
.import dio_params, __oserror
.export _dio_write_verify
.export _dio_write_verify
.include "geossym.inc"
.include "jumptab.inc"

View File

@ -54,11 +54,11 @@ 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 */
{
driveid_t Drive = 0;
char Char;
unsigned char Drive = 0;
char Char;
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 */
{
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 */
{
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 */
/* of one chunk until buffer allocation succeeds */
do {
*ChunkCount = (sectnum_t) ((SectCount + Chunks - 1) / Chunks);
*ChunkCount = (unsigned int) ((SectCount + Chunks - 1) / Chunks);
BufferSize = *ChunkCount * (unsigned long) SectSize;
if (BufferSize < UINT_MAX) {
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[])
{
driveid_t SourceId;
driveid_t TargetId;
dhandle_t Source = NULL;
dhandle_t Target = NULL;
sectsize_t SectSize;
sectnum_t SectCount;
char* Buffer;
sectnum_t Sector;
sectnum_t ChunkCount;
sectnum_t ChunkOffset = 0;
unsigned char SourceId;
unsigned char TargetId;
dhandle_t Source = NULL;
dhandle_t Target = NULL;
unsigned int SectSize;
unsigned int SectCount;
char* Buffer;
unsigned int Sector;
unsigned int ChunkCount;
unsigned int ChunkOffset = 0;
clrscr ();
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);
/* DEV_NUM is set to the drive accessed above */
dhandle = dio_open(*(driveid_t*)0xBF30);
dhandle = dio_open(*(unsigned char*)0xBF30);
if (!dhandle) {
err_exit("dio_open", 1);
}
@ -205,7 +205,7 @@ int main(int argc, char* argv[])
for (index = 0; index < sizeof(info_signature); ++index) {
if (header_block.content.info_block[index] != info_signature[index]) {
err_exit("file signature mismatch", 0);
}
}
}
/* Check ProDOS storage type in directory entry template */