Opening the disk for low level I/O
-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 dio_open function. After use, the handle should be
released with the dio_close function.
- dhandle_t __fastcall__ dio_open (driveid_t drive_id);
+ dhandle_t __fastcall__ dio_open (unsigned char device);
-The drive_id specifies the drive to access, with 0 being the first
-disk drive, 1 the second, and so on.
+The device specifies the device to access, with 0 being the first
+device, 1 the second, and so on.
unsigned char __fastcall__ dio_close (dhandle_t handle);
@@ -41,7 +41,7 @@ The read and write functions are:
unsigned char __fastcall__ dio_read (dhandle_t handle,
- sectnum_t sect_num,
+ unsigned sect_num,
void *buffer);
@@ -50,7 +50,7 @@ location at buffer.
unsigned char __fastcall__ dio_write (dhandle_t handle,
- sectnum_t sect_num,
+ unsigned sect_num,
const void *buffer);
@@ -59,8 +59,8 @@ by sect_num. No verify is performed.
unsigned char __fastcall__ dio_write_verify (dhandle_t handle,
- sectnum_t sect_num,
- const void *buffer);
+ unsigned sect_num,
+ const void *buffer);
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:
- sectsize_t __fastcall__ dio_query_sectsize (dhandle_t handle);
+ unsigned __fastcall__ dio_query_sectsize (dhandle_t handle);
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:
- sectnum_t __fastcall__ dio_query_sectcount (dhandle_t handle);
+ unsigned __fastcall__ dio_query_sectcount (dhandle_t handle);
Converting sector numbers
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.
unsigned char __fastcall__ dio_phys_to_log (dhandle_t handle,
const dio_phys_pos *physpos,
- sectnum_t *sectnum);
+ unsigned *sectnum);
This function converts track/head/sector to logical sector number.
unsigned char __fastcall__ dio_log_to_phys (dhandle_t handle,
- const _sectnum_t *sectnum,
+ const unsigned *sectnum,
dio_phys_pos *physpos);
@@ -132,6 +132,3 @@ The logical sector number is returned as physical sector and vice versa.
-
-
-
diff --git a/include/dio.h b/include/dio.h
index 45d196341..1ccc1ab7c 100644
--- a/include/dio.h
+++ b/include/dio.h
@@ -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 from drive to memory at */
+unsigned char __fastcall__ dio_read (dhandle_t handle,
+ unsigned sect_num,
+ void *buffer);
+/* read sector from device to memory at */
/* 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 to sector on drive , no verify */
+unsigned char __fastcall__ dio_write (dhandle_t handle,
+ unsigned sect_num,
+ const void *buffer);
+/* write memory at to sector on device , 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 to sector on drive , verify after write */
+unsigned char __fastcall__ dio_write_verify (dhandle_t handle,
+ unsigned sect_num,
+ const void *buffer);
+/* write memory at to sector on device , 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) */
diff --git a/libsrc/apple2/dioopen.s b/libsrc/apple2/dioopen.s
index 3c664970d..8d51530fa 100644
--- a/libsrc/apple2/dioopen.s
+++ b/libsrc/apple2/dioopen.s
@@ -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
diff --git a/libsrc/apple2/dioread.s b/libsrc/apple2/dioread.s
index 21042a3b8..62a831ba2 100644
--- a/libsrc/apple2/dioread.s
+++ b/libsrc/apple2/dioread.s
@@ -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
diff --git a/libsrc/apple2/diosectcount.s b/libsrc/apple2/diosectcount.s
index 41bcb3045..f5cf14961 100644
--- a/libsrc/apple2/diosectcount.s
+++ b/libsrc/apple2/diosectcount.s
@@ -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
diff --git a/libsrc/apple2/diosectsize.s b/libsrc/apple2/diosectsize.s
index 5a66ee6d4..f9737cdd5 100644
--- a/libsrc/apple2/diosectsize.s
+++ b/libsrc/apple2/diosectsize.s
@@ -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
diff --git a/libsrc/apple2/diowrite.s b/libsrc/apple2/diowrite.s
index 32d44e470..6deb754f2 100644
--- a/libsrc/apple2/diowrite.s
+++ b/libsrc/apple2/diowrite.s
@@ -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
diff --git a/libsrc/atari/dio_cts.s b/libsrc/atari/dio_cts.s
index a618f5d8b..f76a06b8a 100644
--- a/libsrc/atari/dio_cts.s
+++ b/libsrc/atari/dio_cts.s
@@ -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
diff --git a/libsrc/atari/dio_stc.s b/libsrc/atari/dio_stc.s
index b74e49283..617989cbd 100644
--- a/libsrc/atari/dio_stc.s
+++ b/libsrc/atari/dio_stc.s
@@ -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
diff --git a/libsrc/atari/diopncls.s b/libsrc/atari/diopncls.s
index 09398b9ac..f4c806076 100644
--- a/libsrc/atari/diopncls.s
+++ b/libsrc/atari/diopncls.s
@@ -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);
;
diff --git a/libsrc/atari/dioqsize.s b/libsrc/atari/dioqsize.s
index 0c2c47bda..e6362ead3 100644
--- a/libsrc/atari/dioqsize.s
+++ b/libsrc/atari/dioqsize.s
@@ -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"
diff --git a/libsrc/atari/dioread.s b/libsrc/atari/dioread.s
index 9cdd18143..7b7cbc60c 100644
--- a/libsrc/atari/dioread.s
+++ b/libsrc/atari/dioread.s
@@ -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
diff --git a/libsrc/atari/diowrite.s b/libsrc/atari/diowrite.s
index 8606d9821..b1dc4464f 100644
--- a/libsrc/atari/diowrite.s
+++ b/libsrc/atari/diowrite.s
@@ -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
diff --git a/libsrc/atari/diowritev.s b/libsrc/atari/diowritev.s
index 83fbb6996..8eb126e00 100644
--- a/libsrc/atari/diowritev.s
+++ b/libsrc/atari/diowritev.s
@@ -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
diff --git a/libsrc/atari/siocall.s b/libsrc/atari/siocall.s
index da8a62656..eea3f040a 100644
--- a/libsrc/atari/siocall.s
+++ b/libsrc/atari/siocall.s
@@ -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)
;
diff --git a/libsrc/geos-cbm/disk/dio_cts.s b/libsrc/geos-cbm/disk/dio_cts.s
index b862a4744..b355c4ffd 100644
--- a/libsrc/geos-cbm/disk/dio_cts.s
+++ b/libsrc/geos-cbm/disk/dio_cts.s
@@ -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:
diff --git a/libsrc/geos-cbm/disk/dio_openclose.s b/libsrc/geos-cbm/disk/dio_openclose.s
index cdb9f477c..fc0fcecf2 100644
--- a/libsrc/geos-cbm/disk/dio_openclose.s
+++ b/libsrc/geos-cbm/disk/dio_openclose.s
@@ -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
diff --git a/libsrc/geos-cbm/disk/dio_read.s b/libsrc/geos-cbm/disk/dio_read.s
index 4b94a3e61..71504e79d 100644
--- a/libsrc/geos-cbm/disk/dio_read.s
+++ b/libsrc/geos-cbm/disk/dio_read.s
@@ -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"
diff --git a/libsrc/geos-cbm/disk/dio_stc.s b/libsrc/geos-cbm/disk/dio_stc.s
index bc12351ab..00be2c84e 100644
--- a/libsrc/geos-cbm/disk/dio_stc.s
+++ b/libsrc/geos-cbm/disk/dio_stc.s
@@ -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:
diff --git a/libsrc/geos-cbm/disk/dio_write.s b/libsrc/geos-cbm/disk/dio_write.s
index 905036936..1c48c562e 100644
--- a/libsrc/geos-cbm/disk/dio_write.s
+++ b/libsrc/geos-cbm/disk/dio_write.s
@@ -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"
diff --git a/libsrc/geos-cbm/disk/dio_writev.s b/libsrc/geos-cbm/disk/dio_writev.s
index 20b30ab41..f8d9cb52e 100644
--- a/libsrc/geos-cbm/disk/dio_writev.s
+++ b/libsrc/geos-cbm/disk/dio_writev.s
@@ -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"
diff --git a/samples/diodemo.c b/samples/diodemo.c
index 73ccfda97..ba97184ac 100644
--- a/samples/diodemo.c
+++ b/samples/diodemo.c
@@ -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);
diff --git a/targetutil/geos-apple/convert.c b/targetutil/geos-apple/convert.c
index 4f4170841..d69eea7a6 100644
--- a/targetutil/geos-apple/convert.c
+++ b/targetutil/geos-apple/convert.c
@@ -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 */